Kévin Redon | 9a12d68 | 2018-07-08 13:21:16 +0200 | [diff] [blame] | 1 | /* 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 Welte | 8e7fca3 | 2017-05-07 16:14:33 +0200 | [diff] [blame] | 17 | #pragma once |
| 18 | |
Harald Welte | 9d90d28 | 2018-06-29 22:25:42 +0200 | [diff] [blame] | 19 | #include <osmocom/core/linuxlist.h> |
| 20 | #include <osmocom/core/msgb.h> |
Harald Welte | 8e7fca3 | 2017-05-07 16:14:33 +0200 | [diff] [blame] | 21 | |
| 22 | /* buffered USB endpoint (with queue of msgb) */ |
| 23 | struct 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 Welte | f4a625b | 2019-12-14 19:07:57 +0100 | [diff] [blame] | 32 | /* current length of queue */ |
| 33 | unsigned int queue_len; |
Harald Welte | 8e7fca3 | 2017-05-07 16:14:33 +0200 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | struct msgb *usb_buf_alloc(uint8_t ep); |
| 37 | void usb_buf_free(struct msgb *msg); |
| 38 | int usb_buf_submit(struct msgb *msg); |
| 39 | struct llist_head *usb_get_queue(uint8_t ep); |
| 40 | int usb_drain_queue(uint8_t ep); |
| 41 | |
| 42 | void usb_buf_init(void); |
| 43 | struct usb_buffered_ep *usb_get_buf_ep(uint8_t ep); |
| 44 | |
| 45 | int usb_refill_to_host(uint8_t ep); |
| 46 | int usb_refill_from_host(uint8_t ep); |