3 #ifndef __i1480u_wlp_h__
4 #define __i1480u_wlp_h__
7 #include <linux/netdevice.h>
8 #include <linux/uwb.h> /* struct uwb_rc, struct uwb_notifs_handler */
10 #include "../i1480-wlp.h"
12 #undef i1480u_FLOW_CONTROL /* Enable flow control code */
18 i1480u_TX_INFLIGHT_MAX
= 1000,
19 i1480u_TX_INFLIGHT_THRESHOLD
= 100,
22 /** Maximum size of a transaction that we can tx/rx */
24 /* Maximum packet size computed as follows: max UNTD header (8) +
25 * i1480 RX header (8) + max Ethernet header and payload (4096) +
26 * Padding added by skb_reserve (2) to make post Ethernet payload
27 * start on 16 byte boundary*/
28 i1480u_MAX_RX_PKT_SIZE
= 4114,
29 i1480u_MAX_FRG_SIZE
= 512,
37 * We need to fragment any payload whose UNTD packet is going to be
38 * bigger than i1480u_MAX_FRG_SIZE.
40 enum i1480u_pkt_type
{
41 i1480u_PKT_FRAG_1ST
= 0x1,
42 i1480u_PKT_FRAG_NXT
= 0x0,
43 i1480u_PKT_FRAG_LST
= 0x2,
44 i1480u_PKT_FRAG_CMP
= 0x3
47 i1480u_PKT_NONE
= 0x4,
50 /** USB Network Transfer Descriptor - common */
54 } __attribute__((packed
));
56 static inline enum i1480u_pkt_type
untd_hdr_type(const struct untd_hdr
*hdr
)
58 return hdr
->type
& 0x03;
61 static inline int untd_hdr_rx_tx(const struct untd_hdr
*hdr
)
63 return (hdr
->type
>> 2) & 0x01;
66 static inline void untd_hdr_set_type(struct untd_hdr
*hdr
, enum i1480u_pkt_type type
)
68 hdr
->type
= (hdr
->type
& ~0x03) | type
;
71 static inline void untd_hdr_set_rx_tx(struct untd_hdr
*hdr
, int rx_tx
)
73 hdr
->type
= (hdr
->type
& ~0x04) | (rx_tx
<< 2);
78 * USB Network Transfer Descriptor - Complete Packet
80 * This is for a packet that is smaller (header + payload) than
81 * i1480u_MAX_FRG_SIZE.
83 * @hdr.total_len is the size of the payload; the payload doesn't
84 * count this header nor the padding, but includes the size of i1480
90 } __attribute__((packed
));
94 * USB Network Transfer Descriptor - First fragment
96 * @hdr.len is the size of the *whole packet* (excluding UNTD
97 * headers); @fragment_len is the size of the payload (excluding UNTD
98 * headers, but including i1480 headers).
100 struct untd_hdr_1st
{
104 } __attribute__((packed
));
108 * USB Network Transfer Descriptor - Next / Last [Rest]
110 * @hdr.len is the size of the payload, not including headrs.
112 struct untd_hdr_rst
{
115 } __attribute__((packed
));
119 * Transmission context
121 * Wraps all the stuff needed to track a pending/active tx
125 struct list_head list_node
;
126 struct i1480u
*i1480u
;
130 struct wlp_tx_hdr
*wlp_tx_hdr
;
132 void *buf
; /* if NULL, no new buf was used */
139 * We maintain a basic flow control counter. "count" how many TX URBs are
140 * outstanding. Only allow "max"
141 * TX URBs to be outstanding. If this value is reached the queue will be
142 * stopped. The queue will be restarted when there are
143 * "threshold" URBs outstanding.
144 * Maintain a counter of how many time the TX queue needed to be restarted
145 * due to the "max" being exceeded and the "threshold" reached again. The
146 * timestamp "restart_ts" is to keep track from when the counter was last
147 * queried (see sysfs handling of file wlp_tx_inflight).
149 struct i1480u_tx_inflight
{
152 unsigned long threshold
;
153 unsigned long restart_ts
;
154 atomic_t restart_count
;
158 * Instance of a i1480u WLP interface
160 * Keeps references to the USB device that wraps it, as well as it's
161 * interface and associated UWB host controller. As well, it also
162 * keeps a link to the netdevice for integration into the networking
164 * We maintian separate error history for the tx and rx endpoints because
165 * the implementation does not rely on locking - having one shared
166 * structure between endpoints may cause problems. Adding locking to the
167 * implementation will have higher cost than adding a separate structure.
170 struct usb_device
*usb_dev
;
171 struct usb_interface
*usb_iface
;
172 struct net_device
*net_dev
;
176 /* RX context handling */
177 struct sk_buff
*rx_skb
;
178 struct uwb_dev_addr rx_srcaddr
;
179 size_t rx_untd_pkt_size
;
180 struct i1480u_rx_buf
{
181 struct i1480u
*i1480u
; /* back pointer */
183 struct sk_buff
*data
; /* i1480u_MAX_RX_PKT_SIZE each */
184 } rx_buf
[i1480u_RX_BUFS
]; /* N bufs */
186 spinlock_t tx_list_lock
; /* TX context */
187 struct list_head tx_list
;
190 struct stats lqe_stats
, rssi_stats
; /* radio statistics */
192 /* Options we can set from sysfs */
193 struct wlp_options options
;
194 struct uwb_notifs_handler uwb_notifs_handler
;
195 struct edc tx_errors
;
196 struct edc rx_errors
;
198 #ifdef i1480u_FLOW_CONTROL
199 struct urb
*notif_urb
;
200 struct edc notif_edc
; /* error density counter */
203 struct i1480u_tx_inflight tx_inflight
;
206 /* Internal interfaces */
207 extern void i1480u_rx_cb(struct urb
*urb
);
208 extern int i1480u_rx_setup(struct i1480u
*);
209 extern void i1480u_rx_release(struct i1480u
*);
210 extern void i1480u_tx_release(struct i1480u
*);
211 extern int i1480u_xmit_frame(struct wlp
*, struct sk_buff
*,
212 struct uwb_dev_addr
*);
213 extern void i1480u_stop_queue(struct wlp
*);
214 extern void i1480u_start_queue(struct wlp
*);
215 extern int i1480u_sysfs_setup(struct i1480u
*);
216 extern void i1480u_sysfs_release(struct i1480u
*);
218 /* netdev interface */
219 extern int i1480u_open(struct net_device
*);
220 extern int i1480u_stop(struct net_device
*);
221 extern netdev_tx_t
i1480u_hard_start_xmit(struct sk_buff
*,
222 struct net_device
*);
223 extern void i1480u_tx_timeout(struct net_device
*);
224 extern int i1480u_set_config(struct net_device
*, struct ifmap
*);
225 extern int i1480u_change_mtu(struct net_device
*, int);
226 extern void i1480u_uwb_notifs_cb(void *, struct uwb_dev
*, enum uwb_notifs
);
228 /* bandwidth allocation callback */
229 extern void i1480u_bw_alloc_cb(struct uwb_rsv
*);
232 extern struct attribute_group i1480u_wlp_attr_group
;
234 #endif /* #ifndef __i1480u_wlp_h__ */