blob: bd6947b592733546007350b5278ef14606369600 [file] [log] [blame]
Kévin Redon9a12d682018-07-08 13:21:16 +02001/* USB buffer library
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16 */
Harald Welte8e7fca32017-05-07 16:14:33 +020017#pragma once
18
Harald Welte9d90d282018-06-29 22:25:42 +020019#include <osmocom/core/linuxlist.h>
20#include <osmocom/core/msgb.h>
Harald Welte8e7fca32017-05-07 16:14:33 +020021
22/* buffered USB endpoint (with queue of msgb) */
23struct usb_buffered_ep {
24 /* endpoint number */
25 uint8_t ep;
26 /* OUT endpoint (1) or IN/IRQ (0)? */
27 uint8_t out_from_host;
28 /* currently any transfer in progress? */
29 volatile uint32_t in_progress;
30 /* Tx queue (IN) / Rx queue (OUT) */
31 struct llist_head queue;
32};
33
34struct msgb *usb_buf_alloc(uint8_t ep);
35void usb_buf_free(struct msgb *msg);
36int usb_buf_submit(struct msgb *msg);
37struct llist_head *usb_get_queue(uint8_t ep);
38int usb_drain_queue(uint8_t ep);
39
40void usb_buf_init(void);
41struct usb_buffered_ep *usb_get_buf_ep(uint8_t ep);
42
43int usb_refill_to_host(uint8_t ep);
44int usb_refill_from_host(uint8_t ep);