blob: 3a4eda2fc9e62a0a66855d85cd78309310bd8781 [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;
Harald Weltef4a625b2019-12-14 19:07:57 +010032 /* current length of queue */
33 unsigned int queue_len;
Harald Welte8e7fca32017-05-07 16:14:33 +020034};
35
36struct msgb *usb_buf_alloc(uint8_t ep);
37void usb_buf_free(struct msgb *msg);
38int usb_buf_submit(struct msgb *msg);
39struct llist_head *usb_get_queue(uint8_t ep);
40int usb_drain_queue(uint8_t ep);
41
42void usb_buf_init(void);
43struct usb_buffered_ep *usb_get_buf_ep(uint8_t ep);
44
45int usb_refill_to_host(uint8_t ep);
46int usb_refill_from_host(uint8_t ep);