usb_mbuf.h (193074) | usb_mbuf.h (194228) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/usb_mbuf.h 193074 2009-05-30 00:22:57Z thompsa $ */ | 1/* $FreeBSD: head/sys/dev/usb/usb_mbuf.h 194228 2009-06-15 01:02:43Z thompsa $ */ |
2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 19 unchanged lines hidden (view full) --- 29 30/* 31 * The following structure defines a minimum re-implementation of the 32 * mbuf system in the kernel. 33 */ 34struct usb_mbuf { 35 uint8_t *cur_data_ptr; 36 uint8_t *min_data_ptr; | 2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 19 unchanged lines hidden (view full) --- 29 30/* 31 * The following structure defines a minimum re-implementation of the 32 * mbuf system in the kernel. 33 */ 34struct usb_mbuf { 35 uint8_t *cur_data_ptr; 36 uint8_t *min_data_ptr; |
37 struct usb_mbuf *usb2_nextpkt; 38 struct usb_mbuf *usb2_next; | 37 struct usb_mbuf *usb_nextpkt; 38 struct usb_mbuf *usb_next; |
39 40 usb_size_t cur_data_len; 41 usb_size_t max_data_len; 42 uint8_t last_packet:1; 43 uint8_t unused:7; 44}; 45 46/* --- 4 unchanged lines hidden (view full) --- 51 struct usb_mbuf *ifq_head; 52 struct usb_mbuf *ifq_tail; 53 54 usb_size_t ifq_len; 55 usb_size_t ifq_maxlen; 56}; 57 58#define USB_IF_ENQUEUE(ifq, m) do { \ | 39 40 usb_size_t cur_data_len; 41 usb_size_t max_data_len; 42 uint8_t last_packet:1; 43 uint8_t unused:7; 44}; 45 46/* --- 4 unchanged lines hidden (view full) --- 51 struct usb_mbuf *ifq_head; 52 struct usb_mbuf *ifq_tail; 53 54 usb_size_t ifq_len; 55 usb_size_t ifq_maxlen; 56}; 57 58#define USB_IF_ENQUEUE(ifq, m) do { \ |
59 (m)->usb2_nextpkt = NULL; \ | 59 (m)->usb_nextpkt = NULL; \ |
60 if ((ifq)->ifq_tail == NULL) \ 61 (ifq)->ifq_head = (m); \ 62 else \ | 60 if ((ifq)->ifq_tail == NULL) \ 61 (ifq)->ifq_head = (m); \ 62 else \ |
63 (ifq)->ifq_tail->usb2_nextpkt = (m); \ | 63 (ifq)->ifq_tail->usb_nextpkt = (m); \ |
64 (ifq)->ifq_tail = (m); \ 65 (ifq)->ifq_len++; \ 66 } while (0) 67 68#define USB_IF_DEQUEUE(ifq, m) do { \ 69 (m) = (ifq)->ifq_head; \ 70 if (m) { \ | 64 (ifq)->ifq_tail = (m); \ 65 (ifq)->ifq_len++; \ 66 } while (0) 67 68#define USB_IF_DEQUEUE(ifq, m) do { \ 69 (m) = (ifq)->ifq_head; \ 70 if (m) { \ |
71 if (((ifq)->ifq_head = (m)->usb2_nextpkt) == NULL) { \ | 71 if (((ifq)->ifq_head = (m)->usb_nextpkt) == NULL) { \ |
72 (ifq)->ifq_tail = NULL; \ 73 } \ | 72 (ifq)->ifq_tail = NULL; \ 73 } \ |
74 (m)->usb2_nextpkt = NULL; \ | 74 (m)->usb_nextpkt = NULL; \ |
75 (ifq)->ifq_len--; \ 76 } \ 77 } while (0) 78 79#define USB_IF_PREPEND(ifq, m) do { \ | 75 (ifq)->ifq_len--; \ 76 } \ 77 } while (0) 78 79#define USB_IF_PREPEND(ifq, m) do { \ |
80 (m)->usb2_nextpkt = (ifq)->ifq_head; \ | 80 (m)->usb_nextpkt = (ifq)->ifq_head; \ |
81 if ((ifq)->ifq_tail == NULL) { \ 82 (ifq)->ifq_tail = (m); \ 83 } \ 84 (ifq)->ifq_head = (m); \ 85 (ifq)->ifq_len++; \ 86 } while (0) 87 88#define USB_IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen) 89#define USB_IF_QLEN(ifq) ((ifq)->ifq_len) 90#define USB_IF_POLL(ifq, m) ((m) = (ifq)->ifq_head) 91 92#define USB_MBUF_RESET(m) do { \ 93 (m)->cur_data_ptr = (m)->min_data_ptr; \ 94 (m)->cur_data_len = (m)->max_data_len; \ 95 (m)->last_packet = 0; \ 96 } while (0) 97 98/* prototypes */ | 81 if ((ifq)->ifq_tail == NULL) { \ 82 (ifq)->ifq_tail = (m); \ 83 } \ 84 (ifq)->ifq_head = (m); \ 85 (ifq)->ifq_len++; \ 86 } while (0) 87 88#define USB_IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen) 89#define USB_IF_QLEN(ifq) ((ifq)->ifq_len) 90#define USB_IF_POLL(ifq, m) ((m) = (ifq)->ifq_head) 91 92#define USB_MBUF_RESET(m) do { \ 93 (m)->cur_data_ptr = (m)->min_data_ptr; \ 94 (m)->cur_data_len = (m)->max_data_len; \ 95 (m)->last_packet = 0; \ 96 } while (0) 97 98/* prototypes */ |
99void *usb2_alloc_mbufs(struct malloc_type *type, struct usb_ifqueue *ifq, | 99void *usb_alloc_mbufs(struct malloc_type *type, struct usb_ifqueue *ifq, |
100 usb_size_t block_size, uint16_t nblocks); 101 102#endif /* _USB2_MBUF_H_ */ | 100 usb_size_t block_size, uint16_t nblocks); 101 102#endif /* _USB2_MBUF_H_ */ |