2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 #include <linux/types.h>
17 #include <linux/module.h>
18 #include <linux/if_ether.h>
19 #include <linux/spinlock.h>
20 #include <linux/skbuff.h>
21 #include <linux/netdevice.h>
22 #include <linux/etherdevice.h>
23 #include <linux/err.h>
24 #include <linux/jiffies.h>
25 #include <net/cfg80211.h>
27 #include <brcmu_utils.h>
28 #include <brcmu_wifi.h>
30 #include "dhd_proto.h"
34 #include "fwil_types.h"
38 #include "wl_cfg80211.h"
41 * DOC: Firmware Signalling
43 * Firmware can send signals to host and vice versa, which are passed in the
44 * data packets using TLV based header. This signalling layer is on top of the
45 * BDC bus protocol layer.
49 * single definition for firmware-driver flow control tlv's.
51 * each tlv is specified by BRCMF_FWS_TLV_DEF(name, ID, length).
52 * A length value 0 indicates variable length tlv.
54 #define BRCMF_FWS_TLV_DEFLIST \
55 BRCMF_FWS_TLV_DEF(MAC_OPEN, 1, 1) \
56 BRCMF_FWS_TLV_DEF(MAC_CLOSE, 2, 1) \
57 BRCMF_FWS_TLV_DEF(MAC_REQUEST_CREDIT, 3, 2) \
58 BRCMF_FWS_TLV_DEF(TXSTATUS, 4, 4) \
59 BRCMF_FWS_TLV_DEF(PKTTAG, 5, 4) \
60 BRCMF_FWS_TLV_DEF(MACDESC_ADD, 6, 8) \
61 BRCMF_FWS_TLV_DEF(MACDESC_DEL, 7, 8) \
62 BRCMF_FWS_TLV_DEF(RSSI, 8, 1) \
63 BRCMF_FWS_TLV_DEF(INTERFACE_OPEN, 9, 1) \
64 BRCMF_FWS_TLV_DEF(INTERFACE_CLOSE, 10, 1) \
65 BRCMF_FWS_TLV_DEF(FIFO_CREDITBACK, 11, 6) \
66 BRCMF_FWS_TLV_DEF(PENDING_TRAFFIC_BMP, 12, 2) \
67 BRCMF_FWS_TLV_DEF(MAC_REQUEST_PACKET, 13, 3) \
68 BRCMF_FWS_TLV_DEF(HOST_REORDER_RXPKTS, 14, 10) \
69 BRCMF_FWS_TLV_DEF(TRANS_ID, 18, 6) \
70 BRCMF_FWS_TLV_DEF(COMP_TXSTATUS, 19, 1) \
71 BRCMF_FWS_TLV_DEF(FILLER, 255, 0)
74 * enum brcmf_fws_tlv_type - definition of tlv identifiers.
76 #define BRCMF_FWS_TLV_DEF(name, id, len) \
77 BRCMF_FWS_TYPE_ ## name = id,
78 enum brcmf_fws_tlv_type {
80 BRCMF_FWS_TYPE_INVALID
82 #undef BRCMF_FWS_TLV_DEF
85 * enum brcmf_fws_tlv_len - definition of tlv lengths.
87 #define BRCMF_FWS_TLV_DEF(name, id, len) \
88 BRCMF_FWS_TYPE_ ## name ## _LEN = (len),
89 enum brcmf_fws_tlv_len {
92 #undef BRCMF_FWS_TLV_DEF
96 * brcmf_fws_tlv_names - array of tlv names.
98 #define BRCMF_FWS_TLV_DEF(name, id, len) \
101 enum brcmf_fws_tlv_type id;
103 } brcmf_fws_tlv_names[] = {
104 BRCMF_FWS_TLV_DEFLIST
106 #undef BRCMF_FWS_TLV_DEF
108 static const char *brcmf_fws_get_tlv_name(enum brcmf_fws_tlv_type id)
112 for (i = 0; i < ARRAY_SIZE(brcmf_fws_tlv_names); i++)
113 if (brcmf_fws_tlv_names[i].id == id)
114 return brcmf_fws_tlv_names[i].name;
119 static const char *brcmf_fws_get_tlv_name(enum brcmf_fws_tlv_type id)
126 * flags used to enable tlv signalling from firmware.
128 #define BRCMF_FWS_FLAGS_RSSI_SIGNALS 0x0001
129 #define BRCMF_FWS_FLAGS_XONXOFF_SIGNALS 0x0002
130 #define BRCMF_FWS_FLAGS_CREDIT_STATUS_SIGNALS 0x0004
131 #define BRCMF_FWS_FLAGS_HOST_PROPTXSTATUS_ACTIVE 0x0008
132 #define BRCMF_FWS_FLAGS_PSQ_GENERATIONFSM_ENABLE 0x0010
133 #define BRCMF_FWS_FLAGS_PSQ_ZERO_BUFFER_ENABLE 0x0020
134 #define BRCMF_FWS_FLAGS_HOST_RXREORDER_ACTIVE 0x0040
136 #define BRCMF_FWS_MAC_DESC_TABLE_SIZE 32
137 #define BRCMF_FWS_MAC_DESC_ID_INVALID 0xff
139 #define BRCMF_FWS_HOSTIF_FLOWSTATE_OFF 0
140 #define BRCMF_FWS_HOSTIF_FLOWSTATE_ON 1
141 #define BRCMF_FWS_FLOWCONTROL_HIWATER 128
142 #define BRCMF_FWS_FLOWCONTROL_LOWATER 64
144 #define BRCMF_FWS_PSQ_PREC_COUNT ((BRCMF_FWS_FIFO_COUNT + 1) * 2)
145 #define BRCMF_FWS_PSQ_LEN 256
147 #define BRCMF_FWS_HTOD_FLAG_PKTFROMHOST 0x01
148 #define BRCMF_FWS_HTOD_FLAG_PKT_REQUESTED 0x02
150 #define BRCMF_FWS_RET_OK_NOSCHEDULE 0
151 #define BRCMF_FWS_RET_OK_SCHEDULE 1
154 * enum brcmf_fws_skb_state - indicates processing state of skb.
156 * @BRCMF_FWS_SKBSTATE_NEW: sk_buff is newly arrived in the driver.
157 * @BRCMF_FWS_SKBSTATE_DELAYED: sk_buff had to wait on queue.
158 * @BRCMF_FWS_SKBSTATE_SUPPRESSED: sk_buff has been suppressed by firmware.
159 * @BRCMF_FWS_SKBSTATE_TIM: allocated for TIM update info.
161 enum brcmf_fws_skb_state {
162 BRCMF_FWS_SKBSTATE_NEW,
163 BRCMF_FWS_SKBSTATE_DELAYED,
164 BRCMF_FWS_SKBSTATE_SUPPRESSED,
165 BRCMF_FWS_SKBSTATE_TIM
169 * struct brcmf_skbuff_cb - control buffer associated with skbuff.
171 * @if_flags: holds interface index and packet related flags.
172 * @htod: host to device packet identifier (used in PKTTAG tlv).
173 * @state: transmit state of the packet.
174 * @mac: descriptor related to destination for this packet.
176 * This information is stored in control buffer struct sk_buff::cb, which
177 * provides 48 bytes of storage so this structure should not exceed that.
179 struct brcmf_skbuff_cb {
182 enum brcmf_fws_skb_state state;
183 struct brcmf_fws_mac_descriptor *mac;
187 * macro casting skbuff control buffer to struct brcmf_skbuff_cb.
189 #define brcmf_skbcb(skb) ((struct brcmf_skbuff_cb *)((skb)->cb))
192 * sk_buff control if flags
194 * b[11] - packet sent upon firmware request.
195 * b[10] - packet only contains signalling data.
196 * b[9] - packet is a tx packet.
197 * b[8] - packet used requested credit
198 * b[7] - interface in AP mode.
199 * b[3:0] - interface index.
201 #define BRCMF_SKB_IF_FLAGS_REQUESTED_MASK 0x0800
202 #define BRCMF_SKB_IF_FLAGS_REQUESTED_SHIFT 11
203 #define BRCMF_SKB_IF_FLAGS_SIGNAL_ONLY_MASK 0x0400
204 #define BRCMF_SKB_IF_FLAGS_SIGNAL_ONLY_SHIFT 10
205 #define BRCMF_SKB_IF_FLAGS_TRANSMIT_MASK 0x0200
206 #define BRCMF_SKB_IF_FLAGS_TRANSMIT_SHIFT 9
207 #define BRCMF_SKB_IF_FLAGS_REQ_CREDIT_MASK 0x0100
208 #define BRCMF_SKB_IF_FLAGS_REQ_CREDIT_SHIFT 8
209 #define BRCMF_SKB_IF_FLAGS_IF_AP_MASK 0x0080
210 #define BRCMF_SKB_IF_FLAGS_IF_AP_SHIFT 7
211 #define BRCMF_SKB_IF_FLAGS_INDEX_MASK 0x000f
212 #define BRCMF_SKB_IF_FLAGS_INDEX_SHIFT 0
214 #define brcmf_skb_if_flags_set_field(skb, field, value) \
215 brcmu_maskset16(&(brcmf_skbcb(skb)->if_flags), \
216 BRCMF_SKB_IF_FLAGS_ ## field ## _MASK, \
217 BRCMF_SKB_IF_FLAGS_ ## field ## _SHIFT, (value))
218 #define brcmf_skb_if_flags_get_field(skb, field) \
219 brcmu_maskget16(brcmf_skbcb(skb)->if_flags, \
220 BRCMF_SKB_IF_FLAGS_ ## field ## _MASK, \
221 BRCMF_SKB_IF_FLAGS_ ## field ## _SHIFT)
224 * sk_buff control packet identifier
226 * 32-bit packet identifier used in PKTTAG tlv from host to dongle.
228 * - Generated at the host (e.g. dhd)
229 * - Seen as a generic sequence number by firmware except for the flags field.
231 * Generation : b[31] => generation number for this packet [host->fw]
232 * OR, current generation number [fw->host]
233 * Flags : b[30:27] => command, status flags
234 * FIFO-AC : b[26:24] => AC-FIFO id
235 * h-slot : b[23:8] => hanger-slot
236 * freerun : b[7:0] => A free running counter
238 #define BRCMF_SKB_HTOD_TAG_GENERATION_MASK 0x80000000
239 #define BRCMF_SKB_HTOD_TAG_GENERATION_SHIFT 31
240 #define BRCMF_SKB_HTOD_TAG_FLAGS_MASK 0x78000000
241 #define BRCMF_SKB_HTOD_TAG_FLAGS_SHIFT 27
242 #define BRCMF_SKB_HTOD_TAG_FIFO_MASK 0x07000000
243 #define BRCMF_SKB_HTOD_TAG_FIFO_SHIFT 24
244 #define BRCMF_SKB_HTOD_TAG_HSLOT_MASK 0x00ffff00
245 #define BRCMF_SKB_HTOD_TAG_HSLOT_SHIFT 8
246 #define BRCMF_SKB_HTOD_TAG_FREERUN_MASK 0x000000ff
247 #define BRCMF_SKB_HTOD_TAG_FREERUN_SHIFT 0
249 #define brcmf_skb_htod_tag_set_field(skb, field, value) \
250 brcmu_maskset32(&(brcmf_skbcb(skb)->htod), \
251 BRCMF_SKB_HTOD_TAG_ ## field ## _MASK, \
252 BRCMF_SKB_HTOD_TAG_ ## field ## _SHIFT, (value))
253 #define brcmf_skb_htod_tag_get_field(skb, field) \
254 brcmu_maskget32(brcmf_skbcb(skb)->htod, \
255 BRCMF_SKB_HTOD_TAG_ ## field ## _MASK, \
256 BRCMF_SKB_HTOD_TAG_ ## field ## _SHIFT)
258 #define BRCMF_FWS_TXSTAT_GENERATION_MASK 0x80000000
259 #define BRCMF_FWS_TXSTAT_GENERATION_SHIFT 31
260 #define BRCMF_FWS_TXSTAT_FLAGS_MASK 0x78000000
261 #define BRCMF_FWS_TXSTAT_FLAGS_SHIFT 27
262 #define BRCMF_FWS_TXSTAT_FIFO_MASK 0x07000000
263 #define BRCMF_FWS_TXSTAT_FIFO_SHIFT 24
264 #define BRCMF_FWS_TXSTAT_HSLOT_MASK 0x00FFFF00
265 #define BRCMF_FWS_TXSTAT_HSLOT_SHIFT 8
266 #define BRCMF_FWS_TXSTAT_PKTID_MASK 0x00FFFFFF
267 #define BRCMF_FWS_TXSTAT_PKTID_SHIFT 0
269 #define brcmf_txstatus_get_field(txs, field) \
270 brcmu_maskget32(txs, BRCMF_FWS_TXSTAT_ ## field ## _MASK, \
271 BRCMF_FWS_TXSTAT_ ## field ## _SHIFT)
273 /* How long to defer borrowing in jiffies */
274 #define BRCMF_FWS_BORROW_DEFER_PERIOD (HZ / 10)
277 * enum brcmf_fws_fifo - fifo indices used by dongle firmware.
279 * @BRCMF_FWS_FIFO_FIRST: first fifo, ie. background.
280 * @BRCMF_FWS_FIFO_AC_BK: fifo for background traffic.
281 * @BRCMF_FWS_FIFO_AC_BE: fifo for best-effort traffic.
282 * @BRCMF_FWS_FIFO_AC_VI: fifo for video traffic.
283 * @BRCMF_FWS_FIFO_AC_VO: fifo for voice traffic.
284 * @BRCMF_FWS_FIFO_BCMC: fifo for broadcast/multicast (AP only).
285 * @BRCMF_FWS_FIFO_ATIM: fifo for ATIM (AP only).
286 * @BRCMF_FWS_FIFO_COUNT: number of fifos.
288 enum brcmf_fws_fifo {
289 BRCMF_FWS_FIFO_FIRST,
290 BRCMF_FWS_FIFO_AC_BK = BRCMF_FWS_FIFO_FIRST,
291 BRCMF_FWS_FIFO_AC_BE,
292 BRCMF_FWS_FIFO_AC_VI,
293 BRCMF_FWS_FIFO_AC_VO,
300 * enum brcmf_fws_txstatus - txstatus flag values.
302 * @BRCMF_FWS_TXSTATUS_DISCARD:
303 * host is free to discard the packet.
304 * @BRCMF_FWS_TXSTATUS_CORE_SUPPRESS:
305 * 802.11 core suppressed the packet.
306 * @BRCMF_FWS_TXSTATUS_FW_PS_SUPPRESS:
307 * firmware suppress the packet as device is already in PS mode.
308 * @BRCMF_FWS_TXSTATUS_FW_TOSSED:
309 * firmware tossed the packet.
310 * @BRCMF_FWS_TXSTATUS_HOST_TOSSED:
311 * host tossed the packet.
313 enum brcmf_fws_txstatus {
314 BRCMF_FWS_TXSTATUS_DISCARD,
315 BRCMF_FWS_TXSTATUS_CORE_SUPPRESS,
316 BRCMF_FWS_TXSTATUS_FW_PS_SUPPRESS,
317 BRCMF_FWS_TXSTATUS_FW_TOSSED,
318 BRCMF_FWS_TXSTATUS_HOST_TOSSED
321 enum brcmf_fws_fcmode {
322 BRCMF_FWS_FCMODE_NONE,
323 BRCMF_FWS_FCMODE_IMPLIED_CREDIT,
324 BRCMF_FWS_FCMODE_EXPLICIT_CREDIT
327 enum brcmf_fws_mac_desc_state {
328 BRCMF_FWS_STATE_OPEN = 1,
329 BRCMF_FWS_STATE_CLOSE
333 * struct brcmf_fws_mac_descriptor - firmware signalling data per node/interface
335 * @occupied: slot is in use.
336 * @mac_handle: handle for mac entry determined by firmware.
337 * @interface_id: interface index.
338 * @state: current state.
339 * @suppressed: mac entry is suppressed.
340 * @generation: generation bit.
341 * @ac_bitmap: ac queue bitmap.
342 * @requested_credit: credits requested by firmware.
343 * @ea: ethernet address.
344 * @seq: per-node free-running sequence.
345 * @psq: power-save queue.
346 * @transit_count: packet in transit to firmware.
348 struct brcmf_fws_mac_descriptor {
360 u8 seq[BRCMF_FWS_FIFO_COUNT];
363 int suppr_transit_count;
364 bool send_tim_signal;
365 u8 traffic_pending_bmp;
366 u8 traffic_lastreported_bmp;
369 #define BRCMF_FWS_HANGER_MAXITEMS 1024
372 * enum brcmf_fws_hanger_item_state - state of hanger item.
374 * @BRCMF_FWS_HANGER_ITEM_STATE_FREE: item is free for use.
375 * @BRCMF_FWS_HANGER_ITEM_STATE_INUSE: item is in use.
376 * @BRCMF_FWS_HANGER_ITEM_STATE_INUSE_SUPPRESSED: item was suppressed.
378 enum brcmf_fws_hanger_item_state {
379 BRCMF_FWS_HANGER_ITEM_STATE_FREE = 1,
380 BRCMF_FWS_HANGER_ITEM_STATE_INUSE,
381 BRCMF_FWS_HANGER_ITEM_STATE_INUSE_SUPPRESSED
386 * struct brcmf_fws_hanger_item - single entry for tx pending packet.
388 * @state: entry is either free or occupied.
389 * @pkt: packet itself.
391 struct brcmf_fws_hanger_item {
392 enum brcmf_fws_hanger_item_state state;
397 * struct brcmf_fws_hanger - holds packets awaiting firmware txstatus.
399 * @pushed: packets pushed to await txstatus.
400 * @popped: packets popped upon handling txstatus.
401 * @failed_to_push: packets that could not be pushed.
402 * @failed_to_pop: packets that could not be popped.
403 * @failed_slotfind: packets for which failed to find an entry.
404 * @slot_pos: last returned item index for a free entry.
405 * @items: array of hanger items.
407 struct brcmf_fws_hanger {
414 struct brcmf_fws_hanger_item items[BRCMF_FWS_HANGER_MAXITEMS];
417 struct brcmf_fws_macdesc_table {
418 struct brcmf_fws_mac_descriptor nodes[BRCMF_FWS_MAC_DESC_TABLE_SIZE];
419 struct brcmf_fws_mac_descriptor iface[BRCMF_MAX_IFS];
420 struct brcmf_fws_mac_descriptor other;
423 struct brcmf_fws_info {
424 struct brcmf_pub *drvr;
425 struct brcmf_fws_stats stats;
426 struct brcmf_fws_hanger hanger;
427 enum brcmf_fws_fcmode fcmode;
428 bool bcmc_credit_check;
429 struct brcmf_fws_macdesc_table desc;
430 struct workqueue_struct *fws_wq;
431 struct work_struct fws_dequeue_work;
432 u32 fifo_enqpkt[BRCMF_FWS_FIFO_COUNT];
433 int fifo_credit[BRCMF_FWS_FIFO_COUNT];
434 int credits_borrowed[BRCMF_FWS_FIFO_AC_VO + 1];
435 int deq_node_pos[BRCMF_FWS_FIFO_COUNT];
438 unsigned long borrow_defer_timestamp;
439 bool bus_flow_blocked;
440 bool creditmap_received;
444 * brcmf_fws_prio2fifo - mapping from 802.1d priority to firmware fifo index.
446 static const int brcmf_fws_prio2fifo[] = {
447 BRCMF_FWS_FIFO_AC_BE,
448 BRCMF_FWS_FIFO_AC_BK,
449 BRCMF_FWS_FIFO_AC_BK,
450 BRCMF_FWS_FIFO_AC_BE,
451 BRCMF_FWS_FIFO_AC_VI,
452 BRCMF_FWS_FIFO_AC_VI,
453 BRCMF_FWS_FIFO_AC_VO,
458 module_param(fcmode, int, S_IRUSR);
459 MODULE_PARM_DESC(fcmode, "mode of firmware signalled flow control");
461 #define BRCMF_FWS_TLV_DEF(name, id, len) \
462 case BRCMF_FWS_TYPE_ ## name: \
466 * brcmf_fws_get_tlv_len() - returns defined length for given tlv id.
468 * @fws: firmware-signalling information.
469 * @id: identifier of the TLV.
471 * Return: the specified length for the given TLV; Otherwise -EINVAL.
473 static int brcmf_fws_get_tlv_len(struct brcmf_fws_info *fws,
474 enum brcmf_fws_tlv_type id)
477 BRCMF_FWS_TLV_DEFLIST
479 fws->stats.tlv_invalid_type++;
484 #undef BRCMF_FWS_TLV_DEF
486 static bool brcmf_fws_ifidx_match(struct sk_buff *skb, void *arg)
488 u32 ifidx = brcmf_skb_if_flags_get_field(skb, INDEX);
489 return ifidx == *(int *)arg;
492 static void brcmf_fws_psq_flush(struct brcmf_fws_info *fws, struct pktq *q,
495 bool (*matchfn)(struct sk_buff *, void *) = NULL;
500 matchfn = brcmf_fws_ifidx_match;
501 for (prec = 0; prec < q->num_prec; prec++) {
502 skb = brcmu_pktq_pdeq_match(q, prec, matchfn, &ifidx);
504 brcmu_pkt_buf_free_skb(skb);
505 skb = brcmu_pktq_pdeq_match(q, prec, matchfn, &ifidx);
510 static void brcmf_fws_hanger_init(struct brcmf_fws_hanger *hanger)
514 memset(hanger, 0, sizeof(*hanger));
515 for (i = 0; i < ARRAY_SIZE(hanger->items); i++)
516 hanger->items[i].state = BRCMF_FWS_HANGER_ITEM_STATE_FREE;
519 static u32 brcmf_fws_hanger_get_free_slot(struct brcmf_fws_hanger *h)
523 i = (h->slot_pos + 1) % BRCMF_FWS_HANGER_MAXITEMS;
525 while (i != h->slot_pos) {
526 if (h->items[i].state == BRCMF_FWS_HANGER_ITEM_STATE_FREE) {
531 if (i == BRCMF_FWS_HANGER_MAXITEMS)
534 brcmf_err("all slots occupied\n");
535 h->failed_slotfind++;
536 i = BRCMF_FWS_HANGER_MAXITEMS;
541 static int brcmf_fws_hanger_pushpkt(struct brcmf_fws_hanger *h,
542 struct sk_buff *pkt, u32 slot_id)
544 if (slot_id >= BRCMF_FWS_HANGER_MAXITEMS)
547 if (h->items[slot_id].state != BRCMF_FWS_HANGER_ITEM_STATE_FREE) {
548 brcmf_err("slot is not free\n");
553 h->items[slot_id].state = BRCMF_FWS_HANGER_ITEM_STATE_INUSE;
554 h->items[slot_id].pkt = pkt;
559 static int brcmf_fws_hanger_poppkt(struct brcmf_fws_hanger *h,
560 u32 slot_id, struct sk_buff **pktout,
563 if (slot_id >= BRCMF_FWS_HANGER_MAXITEMS)
566 if (h->items[slot_id].state == BRCMF_FWS_HANGER_ITEM_STATE_FREE) {
567 brcmf_err("entry not in use\n");
572 *pktout = h->items[slot_id].pkt;
574 h->items[slot_id].state = BRCMF_FWS_HANGER_ITEM_STATE_FREE;
575 h->items[slot_id].pkt = NULL;
581 static int brcmf_fws_hanger_mark_suppressed(struct brcmf_fws_hanger *h,
584 if (slot_id >= BRCMF_FWS_HANGER_MAXITEMS)
587 if (h->items[slot_id].state == BRCMF_FWS_HANGER_ITEM_STATE_FREE) {
588 brcmf_err("entry not in use\n");
592 h->items[slot_id].state = BRCMF_FWS_HANGER_ITEM_STATE_INUSE_SUPPRESSED;
596 static void brcmf_fws_hanger_cleanup(struct brcmf_fws_info *fws,
597 bool (*fn)(struct sk_buff *, void *),
600 struct brcmf_fws_hanger *h = &fws->hanger;
603 enum brcmf_fws_hanger_item_state s;
605 for (i = 0; i < ARRAY_SIZE(h->items); i++) {
606 s = h->items[i].state;
607 if (s == BRCMF_FWS_HANGER_ITEM_STATE_INUSE ||
608 s == BRCMF_FWS_HANGER_ITEM_STATE_INUSE_SUPPRESSED) {
609 skb = h->items[i].pkt;
610 if (fn == NULL || fn(skb, &ifidx)) {
611 /* suppress packets freed from psq */
612 if (s == BRCMF_FWS_HANGER_ITEM_STATE_INUSE)
613 brcmu_pkt_buf_free_skb(skb);
615 BRCMF_FWS_HANGER_ITEM_STATE_FREE;
621 static void brcmf_fws_macdesc_set_name(struct brcmf_fws_info *fws,
622 struct brcmf_fws_mac_descriptor *desc)
624 if (desc == &fws->desc.other)
625 strlcpy(desc->name, "MAC-OTHER", sizeof(desc->name));
626 else if (desc->mac_handle)
627 scnprintf(desc->name, sizeof(desc->name), "MAC-%d:%d",
628 desc->mac_handle, desc->interface_id);
630 scnprintf(desc->name, sizeof(desc->name), "MACIF:%d",
634 static void brcmf_fws_macdesc_init(struct brcmf_fws_mac_descriptor *desc,
638 "enter: desc %p ea=%pM, ifidx=%u\n", desc, addr, ifidx);
640 desc->state = BRCMF_FWS_STATE_OPEN;
641 desc->requested_credit = 0;
642 desc->requested_packet = 0;
643 /* depending on use may need ifp->bssidx instead */
644 desc->interface_id = ifidx;
645 desc->ac_bitmap = 0xff; /* update this when handling APSD */
647 memcpy(&desc->ea[0], addr, ETH_ALEN);
651 void brcmf_fws_macdesc_deinit(struct brcmf_fws_mac_descriptor *desc)
654 "enter: ea=%pM, ifidx=%u\n", desc->ea, desc->interface_id);
656 desc->state = BRCMF_FWS_STATE_CLOSE;
657 desc->requested_credit = 0;
658 desc->requested_packet = 0;
661 static struct brcmf_fws_mac_descriptor *
662 brcmf_fws_macdesc_lookup(struct brcmf_fws_info *fws, u8 *ea)
664 struct brcmf_fws_mac_descriptor *entry;
668 return ERR_PTR(-EINVAL);
670 entry = &fws->desc.nodes[0];
671 for (i = 0; i < ARRAY_SIZE(fws->desc.nodes); i++) {
672 if (entry->occupied && !memcmp(entry->ea, ea, ETH_ALEN))
677 return ERR_PTR(-ENOENT);
680 static struct brcmf_fws_mac_descriptor*
681 brcmf_fws_macdesc_find(struct brcmf_fws_info *fws, struct brcmf_if *ifp, u8 *da)
683 struct brcmf_fws_mac_descriptor *entry = &fws->desc.other;
686 multicast = is_multicast_ether_addr(da);
688 /* Multicast destination, STA and P2P clients get the interface entry.
689 * STA/GC gets the Mac Entry for TDLS destinations, TDLS destinations
690 * have their own entry.
692 if (multicast && ifp->fws_desc) {
693 entry = ifp->fws_desc;
697 entry = brcmf_fws_macdesc_lookup(fws, da);
699 entry = ifp->fws_desc;
705 static bool brcmf_fws_macdesc_closed(struct brcmf_fws_info *fws,
706 struct brcmf_fws_mac_descriptor *entry,
709 struct brcmf_fws_mac_descriptor *if_entry;
712 /* for unique destination entries the related interface
715 if (entry->mac_handle) {
716 if_entry = &fws->desc.iface[entry->interface_id];
717 if (if_entry->state == BRCMF_FWS_STATE_CLOSE)
720 /* an entry is closed when the state is closed and
721 * the firmware did not request anything.
723 closed = entry->state == BRCMF_FWS_STATE_CLOSE &&
724 !entry->requested_credit && !entry->requested_packet;
726 /* Or firmware does not allow traffic for given fifo */
727 return closed || !(entry->ac_bitmap & BIT(fifo));
730 static void brcmf_fws_macdesc_cleanup(struct brcmf_fws_info *fws,
731 struct brcmf_fws_mac_descriptor *entry,
734 if (entry->occupied && (ifidx == -1 || ifidx == entry->interface_id)) {
735 brcmf_fws_psq_flush(fws, &entry->psq, ifidx);
736 entry->occupied = !!(entry->psq.len);
740 static void brcmf_fws_bus_txq_cleanup(struct brcmf_fws_info *fws,
741 bool (*fn)(struct sk_buff *, void *),
744 struct brcmf_fws_hanger_item *hi;
750 txq = brcmf_bus_gettxq(fws->drvr->bus_if);
752 brcmf_dbg(TRACE, "no txq to clean up\n");
756 for (prec = 0; prec < txq->num_prec; prec++) {
757 skb = brcmu_pktq_pdeq_match(txq, prec, fn, &ifidx);
759 hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT);
760 hi = &fws->hanger.items[hslot];
761 WARN_ON(skb != hi->pkt);
762 hi->state = BRCMF_FWS_HANGER_ITEM_STATE_FREE;
763 brcmu_pkt_buf_free_skb(skb);
764 skb = brcmu_pktq_pdeq_match(txq, prec, fn, &ifidx);
769 static void brcmf_fws_cleanup(struct brcmf_fws_info *fws, int ifidx)
772 struct brcmf_fws_mac_descriptor *table;
773 bool (*matchfn)(struct sk_buff *, void *) = NULL;
779 matchfn = brcmf_fws_ifidx_match;
781 /* cleanup individual nodes */
782 table = &fws->desc.nodes[0];
783 for (i = 0; i < ARRAY_SIZE(fws->desc.nodes); i++)
784 brcmf_fws_macdesc_cleanup(fws, &table[i], ifidx);
786 brcmf_fws_macdesc_cleanup(fws, &fws->desc.other, ifidx);
787 brcmf_fws_bus_txq_cleanup(fws, matchfn, ifidx);
788 brcmf_fws_hanger_cleanup(fws, matchfn, ifidx);
791 static int brcmf_fws_hdrpush(struct brcmf_fws_info *fws, struct sk_buff *skb)
793 struct brcmf_fws_mac_descriptor *entry = brcmf_skbcb(skb)->mac;
797 __le32 pkttag = cpu_to_le32(brcmf_skbcb(skb)->htod);
799 brcmf_dbg(TRACE, "enter: %s, idx=%d pkttag=0x%08X, hslot=%d\n",
800 entry->name, brcmf_skb_if_flags_get_field(skb, INDEX),
801 le32_to_cpu(pkttag), (le32_to_cpu(pkttag) >> 8) & 0xffff);
802 if (entry->send_tim_signal)
803 data_offset += 2 + BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP_LEN;
805 /* +2 is for Type[1] and Len[1] in TLV, plus TIM signal */
806 data_offset += 2 + BRCMF_FWS_TYPE_PKTTAG_LEN;
807 fillers = round_up(data_offset, 4) - data_offset;
808 data_offset += fillers;
810 skb_push(skb, data_offset);
813 wlh[0] = BRCMF_FWS_TYPE_PKTTAG;
814 wlh[1] = BRCMF_FWS_TYPE_PKTTAG_LEN;
815 memcpy(&wlh[2], &pkttag, sizeof(pkttag));
816 wlh += BRCMF_FWS_TYPE_PKTTAG_LEN + 2;
818 if (entry->send_tim_signal) {
819 entry->send_tim_signal = 0;
820 wlh[0] = BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP;
821 wlh[1] = BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP_LEN;
822 wlh[2] = entry->mac_handle;
823 wlh[3] = entry->traffic_pending_bmp;
824 brcmf_dbg(TRACE, "adding TIM info: handle %d bmp 0x%X\n",
825 entry->mac_handle, entry->traffic_pending_bmp);
826 wlh += BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP_LEN + 2;
827 entry->traffic_lastreported_bmp = entry->traffic_pending_bmp;
830 memset(wlh, BRCMF_FWS_TYPE_FILLER, fillers);
832 brcmf_proto_hdrpush(fws->drvr, brcmf_skb_if_flags_get_field(skb, INDEX),
833 data_offset >> 2, skb);
837 static bool brcmf_fws_tim_update(struct brcmf_fws_info *fws,
838 struct brcmf_fws_mac_descriptor *entry,
839 int fifo, bool send_immediately)
842 struct brcmf_bus *bus;
843 struct brcmf_skbuff_cb *skcb;
847 /* check delayedQ and suppressQ in one call using bitmap */
848 if (brcmu_pktq_mlen(&entry->psq, 3 << (fifo * 2)) == 0)
849 entry->traffic_pending_bmp &= ~NBITVAL(fifo);
851 entry->traffic_pending_bmp |= NBITVAL(fifo);
853 entry->send_tim_signal = false;
854 if (entry->traffic_lastreported_bmp != entry->traffic_pending_bmp)
855 entry->send_tim_signal = true;
856 if (send_immediately && entry->send_tim_signal &&
857 entry->state == BRCMF_FWS_STATE_CLOSE) {
858 /* create a dummy packet and sent that. The traffic */
859 /* bitmap info will automatically be attached to that packet */
860 len = BRCMF_FWS_TYPE_PKTTAG_LEN + 2 +
861 BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP_LEN + 2 +
862 4 + fws->drvr->hdrlen;
863 skb = brcmu_pkt_buf_get_skb(len);
867 skcb = brcmf_skbcb(skb);
869 skcb->state = BRCMF_FWS_SKBSTATE_TIM;
870 bus = fws->drvr->bus_if;
871 err = brcmf_fws_hdrpush(fws, skb);
873 err = brcmf_bus_txdata(bus, skb);
875 brcmu_pkt_buf_free_skb(skb);
882 brcmf_fws_flow_control_check(struct brcmf_fws_info *fws, struct pktq *pq,
885 struct brcmf_if *ifp = fws->drvr->iflist[!if_id ? 0 : if_id + 1];
890 if ((ifp->netif_stop & BRCMF_NETIF_STOP_REASON_FWS_FC) &&
891 pq->len <= BRCMF_FWS_FLOWCONTROL_LOWATER)
892 brcmf_txflowblock_if(ifp,
893 BRCMF_NETIF_STOP_REASON_FWS_FC, false);
894 if (!(ifp->netif_stop & BRCMF_NETIF_STOP_REASON_FWS_FC) &&
895 pq->len >= BRCMF_FWS_FLOWCONTROL_HIWATER) {
896 fws->stats.fws_flow_block++;
897 brcmf_txflowblock_if(ifp, BRCMF_NETIF_STOP_REASON_FWS_FC, true);
902 static int brcmf_fws_rssi_indicate(struct brcmf_fws_info *fws, s8 rssi)
904 brcmf_dbg(CTL, "rssi %d\n", rssi);
908 /* using macro so sparse checking does not complain
909 * about locking imbalance.
911 #define brcmf_fws_lock(drvr, flags) \
914 spin_lock_irqsave(&((drvr)->fws_spinlock), (flags)); \
917 /* using macro so sparse checking does not complain
918 * about locking imbalance.
920 #define brcmf_fws_unlock(drvr, flags) \
921 spin_unlock_irqrestore(&((drvr)->fws_spinlock), (flags))
924 int brcmf_fws_macdesc_indicate(struct brcmf_fws_info *fws, u8 type, u8 *data)
926 struct brcmf_fws_mac_descriptor *entry, *existing;
932 mac_handle = *data++;
936 entry = &fws->desc.nodes[mac_handle & 0x1F];
937 if (type == BRCMF_FWS_TYPE_MACDESC_DEL) {
938 if (entry->occupied) {
939 brcmf_dbg(TRACE, "deleting %s mac %pM\n",
941 brcmf_fws_lock(fws->drvr, flags);
942 brcmf_fws_macdesc_cleanup(fws, entry, -1);
943 brcmf_fws_macdesc_deinit(entry);
944 brcmf_fws_unlock(fws->drvr, flags);
946 fws->stats.mac_update_failed++;
950 existing = brcmf_fws_macdesc_lookup(fws, addr);
951 if (IS_ERR(existing)) {
952 if (!entry->occupied) {
953 brcmf_fws_lock(fws->drvr, flags);
954 entry->mac_handle = mac_handle;
955 brcmf_fws_macdesc_init(entry, addr, ifidx);
956 brcmf_fws_macdesc_set_name(fws, entry);
957 brcmu_pktq_init(&entry->psq, BRCMF_FWS_PSQ_PREC_COUNT,
959 brcmf_fws_unlock(fws->drvr, flags);
960 brcmf_dbg(TRACE, "add %s mac %pM\n", entry->name, addr);
962 fws->stats.mac_update_failed++;
965 if (entry != existing) {
966 brcmf_dbg(TRACE, "copy mac %s\n", existing->name);
967 brcmf_fws_lock(fws->drvr, flags);
968 memcpy(entry, existing,
969 offsetof(struct brcmf_fws_mac_descriptor, psq));
970 entry->mac_handle = mac_handle;
971 brcmf_fws_macdesc_deinit(existing);
972 brcmf_fws_macdesc_set_name(fws, entry);
973 brcmf_fws_unlock(fws->drvr, flags);
974 brcmf_dbg(TRACE, "relocate %s mac %pM\n", entry->name,
977 brcmf_dbg(TRACE, "use existing\n");
978 WARN_ON(entry->mac_handle != mac_handle);
979 /* TODO: what should we do here: continue, reinit, .. */
985 static int brcmf_fws_macdesc_state_indicate(struct brcmf_fws_info *fws,
988 struct brcmf_fws_mac_descriptor *entry;
993 mac_handle = data[0];
994 entry = &fws->desc.nodes[mac_handle & 0x1F];
995 if (!entry->occupied) {
996 fws->stats.mac_ps_update_failed++;
999 brcmf_fws_lock(fws->drvr, flags);
1000 /* a state update should wipe old credits */
1001 entry->requested_credit = 0;
1002 entry->requested_packet = 0;
1003 if (type == BRCMF_FWS_TYPE_MAC_OPEN) {
1004 entry->state = BRCMF_FWS_STATE_OPEN;
1005 ret = BRCMF_FWS_RET_OK_SCHEDULE;
1007 entry->state = BRCMF_FWS_STATE_CLOSE;
1008 brcmf_fws_tim_update(fws, entry, BRCMF_FWS_FIFO_AC_BK, false);
1009 brcmf_fws_tim_update(fws, entry, BRCMF_FWS_FIFO_AC_BE, false);
1010 brcmf_fws_tim_update(fws, entry, BRCMF_FWS_FIFO_AC_VI, false);
1011 brcmf_fws_tim_update(fws, entry, BRCMF_FWS_FIFO_AC_VO, true);
1012 ret = BRCMF_FWS_RET_OK_NOSCHEDULE;
1014 brcmf_fws_unlock(fws->drvr, flags);
1018 static int brcmf_fws_interface_state_indicate(struct brcmf_fws_info *fws,
1021 struct brcmf_fws_mac_descriptor *entry;
1028 if (ifidx >= BRCMF_MAX_IFS) {
1033 entry = &fws->desc.iface[ifidx];
1034 if (!entry->occupied) {
1039 brcmf_dbg(TRACE, "%s (%d): %s\n", brcmf_fws_get_tlv_name(type), type,
1041 brcmf_fws_lock(fws->drvr, flags);
1043 case BRCMF_FWS_TYPE_INTERFACE_OPEN:
1044 entry->state = BRCMF_FWS_STATE_OPEN;
1045 ret = BRCMF_FWS_RET_OK_SCHEDULE;
1047 case BRCMF_FWS_TYPE_INTERFACE_CLOSE:
1048 entry->state = BRCMF_FWS_STATE_CLOSE;
1049 ret = BRCMF_FWS_RET_OK_NOSCHEDULE;
1053 brcmf_fws_unlock(fws->drvr, flags);
1056 brcmf_fws_unlock(fws->drvr, flags);
1060 fws->stats.if_update_failed++;
1064 static int brcmf_fws_request_indicate(struct brcmf_fws_info *fws, u8 type,
1067 struct brcmf_fws_mac_descriptor *entry;
1070 entry = &fws->desc.nodes[data[1] & 0x1F];
1071 if (!entry->occupied) {
1072 if (type == BRCMF_FWS_TYPE_MAC_REQUEST_CREDIT)
1073 fws->stats.credit_request_failed++;
1075 fws->stats.packet_request_failed++;
1079 brcmf_dbg(TRACE, "%s (%d): %s cnt %d bmp %d\n",
1080 brcmf_fws_get_tlv_name(type), type, entry->name,
1082 brcmf_fws_lock(fws->drvr, flags);
1083 if (type == BRCMF_FWS_TYPE_MAC_REQUEST_CREDIT)
1084 entry->requested_credit = data[0];
1086 entry->requested_packet = data[0];
1088 entry->ac_bitmap = data[2];
1089 brcmf_fws_unlock(fws->drvr, flags);
1090 return BRCMF_FWS_RET_OK_SCHEDULE;
1094 brcmf_fws_macdesc_use_req_credit(struct brcmf_fws_mac_descriptor *entry,
1095 struct sk_buff *skb)
1097 if (entry->requested_credit > 0) {
1098 entry->requested_credit--;
1099 brcmf_skb_if_flags_set_field(skb, REQUESTED, 1);
1100 brcmf_skb_if_flags_set_field(skb, REQ_CREDIT, 1);
1101 if (entry->state != BRCMF_FWS_STATE_CLOSE)
1102 brcmf_err("requested credit set while mac not closed!\n");
1103 } else if (entry->requested_packet > 0) {
1104 entry->requested_packet--;
1105 brcmf_skb_if_flags_set_field(skb, REQUESTED, 1);
1106 brcmf_skb_if_flags_set_field(skb, REQ_CREDIT, 0);
1107 if (entry->state != BRCMF_FWS_STATE_CLOSE)
1108 brcmf_err("requested packet set while mac not closed!\n");
1110 brcmf_skb_if_flags_set_field(skb, REQUESTED, 0);
1111 brcmf_skb_if_flags_set_field(skb, REQ_CREDIT, 0);
1115 static void brcmf_fws_macdesc_return_req_credit(struct sk_buff *skb)
1117 struct brcmf_fws_mac_descriptor *entry = brcmf_skbcb(skb)->mac;
1119 if ((brcmf_skb_if_flags_get_field(skb, REQ_CREDIT)) &&
1120 (entry->state == BRCMF_FWS_STATE_CLOSE))
1121 entry->requested_credit++;
1124 static void brcmf_fws_return_credits(struct brcmf_fws_info *fws,
1125 u8 fifo, u8 credits)
1134 fws->fifo_credit_map |= 1 << fifo;
1136 if ((fifo == BRCMF_FWS_FIFO_AC_BE) &&
1137 (fws->credits_borrowed[0])) {
1138 for (lender_ac = BRCMF_FWS_FIFO_AC_VO; lender_ac >= 0;
1140 borrowed = &fws->credits_borrowed[lender_ac];
1142 fws->fifo_credit_map |= (1 << lender_ac);
1143 fifo_credit = &fws->fifo_credit[lender_ac];
1144 if (*borrowed >= credits) {
1145 *borrowed -= credits;
1146 *fifo_credit += credits;
1149 credits -= *borrowed;
1150 *fifo_credit += *borrowed;
1157 fws->fifo_credit[fifo] += credits;
1160 static void brcmf_fws_schedule_deq(struct brcmf_fws_info *fws)
1162 /* only schedule dequeue when there are credits for delayed traffic */
1163 if (fws->fifo_credit_map & fws->fifo_delay_map)
1164 queue_work(fws->fws_wq, &fws->fws_dequeue_work);
1167 static int brcmf_fws_enq(struct brcmf_fws_info *fws,
1168 enum brcmf_fws_skb_state state, int fifo,
1171 int prec = 2 * fifo;
1172 u32 *qfull_stat = &fws->stats.delayq_full_error;
1174 struct brcmf_fws_mac_descriptor *entry;
1176 entry = brcmf_skbcb(p)->mac;
1177 if (entry == NULL) {
1178 brcmf_err("no mac descriptor found for skb %p\n", p);
1182 brcmf_dbg(DATA, "enter: fifo %d skb %p\n", fifo, p);
1183 if (state == BRCMF_FWS_SKBSTATE_SUPPRESSED) {
1185 qfull_stat = &fws->stats.supprq_full_error;
1188 if (brcmu_pktq_penq(&entry->psq, prec, p) == NULL) {
1193 /* increment total enqueued packet count */
1194 fws->fifo_delay_map |= 1 << fifo;
1195 fws->fifo_enqpkt[fifo]++;
1197 /* update the sk_buff state */
1198 brcmf_skbcb(p)->state = state;
1201 * A packet has been pushed so update traffic
1202 * availability bitmap, if applicable
1204 brcmf_fws_tim_update(fws, entry, fifo, true);
1205 brcmf_fws_flow_control_check(fws, &entry->psq,
1206 brcmf_skb_if_flags_get_field(p, INDEX));
1210 static struct sk_buff *brcmf_fws_deq(struct brcmf_fws_info *fws, int fifo)
1212 struct brcmf_fws_mac_descriptor *table;
1213 struct brcmf_fws_mac_descriptor *entry;
1221 table = (struct brcmf_fws_mac_descriptor *)&fws->desc;
1222 num_nodes = sizeof(fws->desc) / sizeof(struct brcmf_fws_mac_descriptor);
1223 node_pos = fws->deq_node_pos[fifo];
1225 for (i = 0; i < num_nodes; i++) {
1226 entry = &table[(node_pos + i) % num_nodes];
1227 if (!entry->occupied ||
1228 brcmf_fws_macdesc_closed(fws, entry, fifo))
1231 if (entry->suppressed)
1235 p = brcmu_pktq_mdeq(&entry->psq, pmsk << (fifo * 2), &prec_out);
1237 if (entry->suppressed) {
1238 if (entry->suppr_transit_count)
1240 entry->suppressed = false;
1241 p = brcmu_pktq_mdeq(&entry->psq,
1242 1 << (fifo * 2), &prec_out);
1248 brcmf_fws_macdesc_use_req_credit(entry, p);
1250 /* move dequeue position to ensure fair round-robin */
1251 fws->deq_node_pos[fifo] = (node_pos + i + 1) % num_nodes;
1252 brcmf_fws_flow_control_check(fws, &entry->psq,
1253 brcmf_skb_if_flags_get_field(p,
1257 * A packet has been picked up, update traffic
1258 * availability bitmap, if applicable
1260 brcmf_fws_tim_update(fws, entry, fifo, false);
1263 * decrement total enqueued fifo packets and
1264 * clear delay bitmap if done.
1266 fws->fifo_enqpkt[fifo]--;
1267 if (fws->fifo_enqpkt[fifo] == 0)
1268 fws->fifo_delay_map &= ~(1 << fifo);
1273 brcmf_dbg(DATA, "exit: fifo %d skb %p\n", fifo, p);
1277 static int brcmf_fws_txstatus_suppressed(struct brcmf_fws_info *fws, int fifo,
1278 struct sk_buff *skb, u32 genbit)
1280 struct brcmf_fws_mac_descriptor *entry = brcmf_skbcb(skb)->mac;
1285 hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT);
1287 /* this packet was suppressed */
1288 if (!entry->suppressed) {
1289 entry->suppressed = true;
1290 entry->suppr_transit_count = entry->transit_count;
1291 brcmf_dbg(DATA, "suppress %s: transit %d\n",
1292 entry->name, entry->transit_count);
1295 entry->generation = genbit;
1297 ret = brcmf_proto_hdrpull(fws->drvr, false, &ifidx, skb);
1299 ret = brcmf_fws_enq(fws, BRCMF_FWS_SKBSTATE_SUPPRESSED, fifo,
1302 /* suppress q is full or hdrpull failed, drop this packet */
1303 brcmf_fws_hanger_poppkt(&fws->hanger, hslot, &skb,
1307 * Mark suppressed to avoid a double free during
1310 brcmf_fws_hanger_mark_suppressed(&fws->hanger, hslot);
1317 brcmf_fws_txs_process(struct brcmf_fws_info *fws, u8 flags, u32 hslot,
1322 bool remove_from_hanger = true;
1323 struct sk_buff *skb;
1324 struct brcmf_skbuff_cb *skcb;
1325 struct brcmf_fws_mac_descriptor *entry = NULL;
1327 brcmf_dbg(DATA, "flags %d\n", flags);
1329 if (flags == BRCMF_FWS_TXSTATUS_DISCARD)
1330 fws->stats.txs_discard++;
1331 else if (flags == BRCMF_FWS_TXSTATUS_CORE_SUPPRESS) {
1332 fws->stats.txs_supp_core++;
1333 remove_from_hanger = false;
1334 } else if (flags == BRCMF_FWS_TXSTATUS_FW_PS_SUPPRESS) {
1335 fws->stats.txs_supp_ps++;
1336 remove_from_hanger = false;
1337 } else if (flags == BRCMF_FWS_TXSTATUS_FW_TOSSED)
1338 fws->stats.txs_tossed++;
1339 else if (flags == BRCMF_FWS_TXSTATUS_HOST_TOSSED)
1340 fws->stats.txs_host_tossed++;
1342 brcmf_err("unexpected txstatus\n");
1344 ret = brcmf_fws_hanger_poppkt(&fws->hanger, hslot, &skb,
1345 remove_from_hanger);
1347 brcmf_err("no packet in hanger slot: hslot=%d\n", hslot);
1351 skcb = brcmf_skbcb(skb);
1353 if (WARN_ON(!entry)) {
1354 brcmu_pkt_buf_free_skb(skb);
1357 entry->transit_count--;
1358 if (entry->suppressed && entry->suppr_transit_count)
1359 entry->suppr_transit_count--;
1361 brcmf_dbg(DATA, "%s flags %X htod %X\n", entry->name, skcb->if_flags,
1364 /* pick up the implicit credit from this packet */
1365 fifo = brcmf_skb_htod_tag_get_field(skb, FIFO);
1366 if ((fws->fcmode == BRCMF_FWS_FCMODE_IMPLIED_CREDIT) ||
1367 (brcmf_skb_if_flags_get_field(skb, REQ_CREDIT)) ||
1368 (flags == BRCMF_FWS_TXSTATUS_HOST_TOSSED)) {
1369 brcmf_fws_return_credits(fws, fifo, 1);
1370 brcmf_fws_schedule_deq(fws);
1372 brcmf_fws_macdesc_return_req_credit(skb);
1374 if (!remove_from_hanger)
1375 ret = brcmf_fws_txstatus_suppressed(fws, fifo, skb, genbit);
1377 if (remove_from_hanger || ret)
1378 brcmf_txfinalize(fws->drvr, skb, true);
1383 static int brcmf_fws_fifocreditback_indicate(struct brcmf_fws_info *fws,
1389 if (fws->fcmode != BRCMF_FWS_FCMODE_EXPLICIT_CREDIT) {
1390 brcmf_dbg(INFO, "ignored\n");
1391 return BRCMF_FWS_RET_OK_NOSCHEDULE;
1394 brcmf_dbg(DATA, "enter: data %pM\n", data);
1395 brcmf_fws_lock(fws->drvr, flags);
1396 for (i = 0; i < BRCMF_FWS_FIFO_COUNT; i++)
1397 brcmf_fws_return_credits(fws, i, data[i]);
1399 brcmf_dbg(DATA, "map: credit %x delay %x\n", fws->fifo_credit_map,
1400 fws->fifo_delay_map);
1401 brcmf_fws_unlock(fws->drvr, flags);
1402 return BRCMF_FWS_RET_OK_SCHEDULE;
1405 static int brcmf_fws_txstatus_indicate(struct brcmf_fws_info *fws, u8 *data)
1414 fws->stats.txs_indicate++;
1415 memcpy(&status_le, data, sizeof(status_le));
1416 status = le32_to_cpu(status_le);
1417 flags = brcmf_txstatus_get_field(status, FLAGS);
1418 hslot = brcmf_txstatus_get_field(status, HSLOT);
1419 genbit = brcmf_txstatus_get_field(status, GENERATION);
1421 brcmf_fws_lock(fws->drvr, lflags);
1422 brcmf_fws_txs_process(fws, flags, hslot, genbit);
1423 brcmf_fws_unlock(fws->drvr, lflags);
1424 return BRCMF_FWS_RET_OK_NOSCHEDULE;
1427 static int brcmf_fws_dbg_seqnum_check(struct brcmf_fws_info *fws, u8 *data)
1431 memcpy(×tamp, &data[2], sizeof(timestamp));
1432 brcmf_dbg(CTL, "received: seq %d, timestamp %d\n", data[1],
1433 le32_to_cpu(timestamp));
1437 static int brcmf_fws_notify_credit_map(struct brcmf_if *ifp,
1438 const struct brcmf_event_msg *e,
1441 struct brcmf_fws_info *fws = ifp->drvr->fws;
1446 if (e->datalen < BRCMF_FWS_FIFO_COUNT) {
1447 brcmf_err("event payload too small (%d)\n", e->datalen);
1450 if (fws->creditmap_received)
1453 fws->creditmap_received = true;
1455 brcmf_dbg(TRACE, "enter: credits %pM\n", credits);
1456 brcmf_fws_lock(ifp->drvr, flags);
1457 for (i = 0; i < ARRAY_SIZE(fws->fifo_credit); i++) {
1459 fws->fifo_credit_map |= 1 << i;
1461 fws->fifo_credit_map &= ~(1 << i);
1462 fws->fifo_credit[i] = *credits++;
1464 brcmf_fws_schedule_deq(fws);
1465 brcmf_fws_unlock(ifp->drvr, flags);
1469 static int brcmf_fws_notify_bcmc_credit_support(struct brcmf_if *ifp,
1470 const struct brcmf_event_msg *e,
1473 struct brcmf_fws_info *fws = ifp->drvr->fws;
1476 brcmf_fws_lock(ifp->drvr, flags);
1478 fws->bcmc_credit_check = true;
1479 brcmf_fws_unlock(ifp->drvr, flags);
1483 int brcmf_fws_hdrpull(struct brcmf_pub *drvr, int ifidx, s16 signal_len,
1484 struct sk_buff *skb)
1486 struct brcmf_fws_info *fws = drvr->fws;
1495 brcmf_dbg(HDRS, "enter: ifidx %d, skblen %u, sig %d\n",
1496 ifidx, skb->len, signal_len);
1498 WARN_ON(signal_len > skb->len);
1500 /* if flow control disabled, skip to packet data and leave */
1501 if (!signal_len || !drvr->fw_signals) {
1502 skb_pull(skb, signal_len);
1506 fws->stats.header_pulls++;
1507 data_len = signal_len;
1508 signal_data = skb->data;
1510 status = BRCMF_FWS_RET_OK_NOSCHEDULE;
1511 while (data_len > 0) {
1512 /* extract tlv info */
1513 type = signal_data[0];
1515 /* FILLER type is actually not a TLV, but
1516 * a single byte that can be skipped.
1518 if (type == BRCMF_FWS_TYPE_FILLER) {
1523 len = signal_data[1];
1524 data = signal_data + 2;
1526 brcmf_dbg(HDRS, "tlv type=%s (%d), len=%d (%d)\n",
1527 brcmf_fws_get_tlv_name(type), type, len,
1528 brcmf_fws_get_tlv_len(fws, type));
1530 /* abort parsing when length invalid */
1531 if (data_len < len + 2)
1534 if (len < brcmf_fws_get_tlv_len(fws, type))
1537 err = BRCMF_FWS_RET_OK_NOSCHEDULE;
1539 case BRCMF_FWS_TYPE_HOST_REORDER_RXPKTS:
1540 case BRCMF_FWS_TYPE_COMP_TXSTATUS:
1542 case BRCMF_FWS_TYPE_MACDESC_ADD:
1543 case BRCMF_FWS_TYPE_MACDESC_DEL:
1544 brcmf_fws_macdesc_indicate(fws, type, data);
1546 case BRCMF_FWS_TYPE_MAC_OPEN:
1547 case BRCMF_FWS_TYPE_MAC_CLOSE:
1548 err = brcmf_fws_macdesc_state_indicate(fws, type, data);
1550 case BRCMF_FWS_TYPE_INTERFACE_OPEN:
1551 case BRCMF_FWS_TYPE_INTERFACE_CLOSE:
1552 err = brcmf_fws_interface_state_indicate(fws, type,
1555 case BRCMF_FWS_TYPE_MAC_REQUEST_CREDIT:
1556 case BRCMF_FWS_TYPE_MAC_REQUEST_PACKET:
1557 err = brcmf_fws_request_indicate(fws, type, data);
1559 case BRCMF_FWS_TYPE_TXSTATUS:
1560 brcmf_fws_txstatus_indicate(fws, data);
1562 case BRCMF_FWS_TYPE_FIFO_CREDITBACK:
1563 err = brcmf_fws_fifocreditback_indicate(fws, data);
1565 case BRCMF_FWS_TYPE_RSSI:
1566 brcmf_fws_rssi_indicate(fws, *data);
1568 case BRCMF_FWS_TYPE_TRANS_ID:
1569 brcmf_fws_dbg_seqnum_check(fws, data);
1571 case BRCMF_FWS_TYPE_PKTTAG:
1572 case BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP:
1574 fws->stats.tlv_invalid_type++;
1577 if (err == BRCMF_FWS_RET_OK_SCHEDULE)
1578 status = BRCMF_FWS_RET_OK_SCHEDULE;
1579 signal_data += len + 2;
1580 data_len -= len + 2;
1584 fws->stats.tlv_parse_failed++;
1586 if (status == BRCMF_FWS_RET_OK_SCHEDULE)
1587 brcmf_fws_schedule_deq(fws);
1589 /* signalling processing result does
1590 * not affect the actual ethernet packet.
1592 skb_pull(skb, signal_len);
1594 /* this may be a signal-only packet
1597 fws->stats.header_only_pkt++;
1602 static void brcmf_fws_precommit_skb(struct brcmf_fws_info *fws, int fifo,
1605 struct brcmf_skbuff_cb *skcb = brcmf_skbcb(p);
1606 struct brcmf_fws_mac_descriptor *entry = skcb->mac;
1609 brcmf_skb_if_flags_set_field(p, TRANSMIT, 1);
1610 brcmf_skb_htod_tag_set_field(p, GENERATION, entry->generation);
1611 flags = BRCMF_FWS_HTOD_FLAG_PKTFROMHOST;
1612 if (brcmf_skb_if_flags_get_field(p, REQUESTED)) {
1614 * Indicate that this packet is being sent in response to an
1615 * explicit request from the firmware side.
1617 flags |= BRCMF_FWS_HTOD_FLAG_PKT_REQUESTED;
1619 brcmf_skb_htod_tag_set_field(p, FLAGS, flags);
1620 brcmf_fws_hdrpush(fws, p);
1623 static void brcmf_fws_rollback_toq(struct brcmf_fws_info *fws,
1624 struct sk_buff *skb, int fifo)
1626 struct brcmf_fws_mac_descriptor *entry;
1627 struct sk_buff *pktout;
1631 entry = brcmf_skbcb(skb)->mac;
1632 if (entry->occupied) {
1634 if (brcmf_skbcb(skb)->state == BRCMF_FWS_SKBSTATE_SUPPRESSED)
1637 pktout = brcmu_pktq_penq_head(&entry->psq, qidx, skb);
1638 if (pktout == NULL) {
1639 brcmf_err("%s queue %d full\n", entry->name, qidx);
1643 brcmf_err("%s entry removed\n", entry->name);
1648 fws->stats.rollback_failed++;
1649 hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT);
1650 brcmf_fws_txs_process(fws, BRCMF_FWS_TXSTATUS_HOST_TOSSED,
1653 fws->stats.rollback_success++;
1654 brcmf_fws_return_credits(fws, fifo, 1);
1655 brcmf_fws_macdesc_return_req_credit(skb);
1659 static int brcmf_fws_borrow_credit(struct brcmf_fws_info *fws)
1663 if (time_after(fws->borrow_defer_timestamp, jiffies)) {
1664 fws->fifo_credit_map &= ~(1 << BRCMF_FWS_FIFO_AC_BE);
1668 for (lender_ac = 0; lender_ac <= BRCMF_FWS_FIFO_AC_VO; lender_ac++) {
1669 if (fws->fifo_credit[lender_ac]) {
1670 fws->credits_borrowed[lender_ac]++;
1671 fws->fifo_credit[lender_ac]--;
1672 if (fws->fifo_credit[lender_ac] == 0)
1673 fws->fifo_credit_map &= ~(1 << lender_ac);
1674 fws->fifo_credit_map |= (1 << BRCMF_FWS_FIFO_AC_BE);
1675 brcmf_dbg(DATA, "borrow credit from: %d\n", lender_ac);
1679 fws->fifo_credit_map &= ~(1 << BRCMF_FWS_FIFO_AC_BE);
1683 static int brcmf_fws_commit_skb(struct brcmf_fws_info *fws, int fifo,
1684 struct sk_buff *skb)
1686 struct brcmf_skbuff_cb *skcb = brcmf_skbcb(skb);
1687 struct brcmf_fws_mac_descriptor *entry;
1688 struct brcmf_bus *bus = fws->drvr->bus_if;
1694 return PTR_ERR(entry);
1696 brcmf_fws_precommit_skb(fws, fifo, skb);
1697 rc = brcmf_bus_txdata(bus, skb);
1698 brcmf_dbg(DATA, "%s flags %X htod %X bus_tx %d\n", entry->name,
1699 skcb->if_flags, skcb->htod, rc);
1701 brcmf_proto_hdrpull(fws->drvr, false, &ifidx, skb);
1705 entry->transit_count++;
1706 if (entry->suppressed)
1707 entry->suppr_transit_count++;
1708 fws->stats.pkt2bus++;
1709 fws->stats.send_pkts[fifo]++;
1710 if (brcmf_skb_if_flags_get_field(skb, REQUESTED))
1711 fws->stats.requested_sent[fifo]++;
1716 brcmf_fws_rollback_toq(fws, skb, fifo);
1720 static int brcmf_fws_assign_htod(struct brcmf_fws_info *fws, struct sk_buff *p,
1723 struct brcmf_skbuff_cb *skcb = brcmf_skbcb(p);
1726 hslot = brcmf_fws_hanger_get_free_slot(&fws->hanger);
1727 brcmf_skb_htod_tag_set_field(p, HSLOT, hslot);
1728 brcmf_skb_htod_tag_set_field(p, FREERUN, skcb->mac->seq[fifo]);
1729 brcmf_skb_htod_tag_set_field(p, FIFO, fifo);
1730 rc = brcmf_fws_hanger_pushpkt(&fws->hanger, p, hslot);
1732 skcb->mac->seq[fifo]++;
1734 fws->stats.generic_error++;
1738 int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb)
1740 struct brcmf_pub *drvr = ifp->drvr;
1741 struct brcmf_fws_info *fws = drvr->fws;
1742 struct brcmf_skbuff_cb *skcb = brcmf_skbcb(skb);
1743 struct ethhdr *eh = (struct ethhdr *)(skb->data);
1745 int fifo = BRCMF_FWS_FIFO_BCMC;
1746 bool multicast = is_multicast_ether_addr(eh->h_dest);
1748 /* determine the priority */
1750 skb->priority = cfg80211_classify8021d(skb);
1752 drvr->tx_multicast += !!multicast;
1753 if (ntohs(eh->h_proto) == ETH_P_PAE)
1754 atomic_inc(&ifp->pend_8021x_cnt);
1756 if (!brcmf_fws_fc_active(fws)) {
1757 /* If the protocol uses a data header, apply it */
1758 brcmf_proto_hdrpush(drvr, ifp->ifidx, 0, skb);
1760 /* Use bus module to send data frame */
1761 return brcmf_bus_txdata(drvr->bus_if, skb);
1764 /* set control buffer information */
1766 skcb->state = BRCMF_FWS_SKBSTATE_NEW;
1767 brcmf_skb_if_flags_set_field(skb, INDEX, ifp->ifidx);
1769 fifo = brcmf_fws_prio2fifo[skb->priority];
1771 brcmf_fws_lock(drvr, flags);
1772 if (fifo != BRCMF_FWS_FIFO_AC_BE && fifo < BRCMF_FWS_FIFO_BCMC)
1773 fws->borrow_defer_timestamp = jiffies +
1774 BRCMF_FWS_BORROW_DEFER_PERIOD;
1776 skcb->mac = brcmf_fws_macdesc_find(fws, ifp, eh->h_dest);
1777 brcmf_dbg(DATA, "%s mac %pM multi %d fifo %d\n", skcb->mac->name,
1778 eh->h_dest, multicast, fifo);
1779 if (!brcmf_fws_assign_htod(fws, skb, fifo)) {
1780 brcmf_fws_enq(fws, BRCMF_FWS_SKBSTATE_DELAYED, fifo, skb);
1781 brcmf_fws_schedule_deq(fws);
1783 brcmf_err("drop skb: no hanger slot\n");
1784 brcmu_pkt_buf_free_skb(skb);
1786 brcmf_fws_unlock(drvr, flags);
1790 void brcmf_fws_reset_interface(struct brcmf_if *ifp)
1792 struct brcmf_fws_mac_descriptor *entry = ifp->fws_desc;
1794 brcmf_dbg(TRACE, "enter: idx=%d\n", ifp->bssidx);
1798 brcmf_fws_macdesc_init(entry, ifp->mac_addr, ifp->ifidx);
1801 void brcmf_fws_add_interface(struct brcmf_if *ifp)
1803 struct brcmf_fws_info *fws = ifp->drvr->fws;
1804 struct brcmf_fws_mac_descriptor *entry;
1806 if (!ifp->ndev || !ifp->drvr->fw_signals)
1809 entry = &fws->desc.iface[ifp->ifidx];
1810 ifp->fws_desc = entry;
1811 brcmf_fws_macdesc_init(entry, ifp->mac_addr, ifp->ifidx);
1812 brcmf_fws_macdesc_set_name(fws, entry);
1813 brcmu_pktq_init(&entry->psq, BRCMF_FWS_PSQ_PREC_COUNT,
1815 brcmf_dbg(TRACE, "added %s\n", entry->name);
1818 void brcmf_fws_del_interface(struct brcmf_if *ifp)
1820 struct brcmf_fws_mac_descriptor *entry = ifp->fws_desc;
1826 brcmf_fws_lock(ifp->drvr, flags);
1827 ifp->fws_desc = NULL;
1828 brcmf_dbg(TRACE, "deleting %s\n", entry->name);
1829 brcmf_fws_macdesc_deinit(entry);
1830 brcmf_fws_cleanup(ifp->drvr->fws, ifp->ifidx);
1831 brcmf_fws_unlock(ifp->drvr, flags);
1834 static void brcmf_fws_dequeue_worker(struct work_struct *worker)
1836 struct brcmf_fws_info *fws;
1837 struct sk_buff *skb;
1841 fws = container_of(worker, struct brcmf_fws_info, fws_dequeue_work);
1843 brcmf_fws_lock(fws->drvr, flags);
1844 for (fifo = BRCMF_FWS_FIFO_BCMC; fifo >= 0 && !fws->bus_flow_blocked;
1846 while ((fws->fifo_credit[fifo]) || ((!fws->bcmc_credit_check) &&
1847 (fifo == BRCMF_FWS_FIFO_BCMC))) {
1848 skb = brcmf_fws_deq(fws, fifo);
1851 fws->fifo_credit[fifo]--;
1852 if (brcmf_fws_commit_skb(fws, fifo, skb))
1854 if (fws->bus_flow_blocked)
1857 if ((fifo == BRCMF_FWS_FIFO_AC_BE) &&
1858 (fws->fifo_credit[fifo] == 0) &&
1859 (!fws->bus_flow_blocked)) {
1860 while (brcmf_fws_borrow_credit(fws) == 0) {
1861 skb = brcmf_fws_deq(fws, fifo);
1863 brcmf_fws_return_credits(fws, fifo, 1);
1866 if (brcmf_fws_commit_skb(fws, fifo, skb))
1868 if (fws->bus_flow_blocked)
1873 brcmf_fws_unlock(fws->drvr, flags);
1876 int brcmf_fws_init(struct brcmf_pub *drvr)
1878 u32 tlv = BRCMF_FWS_FLAGS_RSSI_SIGNALS;
1881 if (!drvr->fw_signals)
1884 spin_lock_init(&drvr->fws_spinlock);
1886 drvr->fws = kzalloc(sizeof(*(drvr->fws)), GFP_KERNEL);
1892 /* set linkage back */
1893 drvr->fws->drvr = drvr;
1894 drvr->fws->fcmode = fcmode;
1896 drvr->fws->fws_wq = create_singlethread_workqueue("brcmf_fws_wq");
1897 if (drvr->fws->fws_wq == NULL) {
1898 brcmf_err("workqueue creation failed\n");
1902 INIT_WORK(&drvr->fws->fws_dequeue_work, brcmf_fws_dequeue_worker);
1904 /* enable firmware signalling if fcmode active */
1905 if (drvr->fws->fcmode != BRCMF_FWS_FCMODE_NONE)
1906 tlv |= BRCMF_FWS_FLAGS_XONXOFF_SIGNALS |
1907 BRCMF_FWS_FLAGS_CREDIT_STATUS_SIGNALS |
1908 BRCMF_FWS_FLAGS_HOST_PROPTXSTATUS_ACTIVE;
1910 rc = brcmf_fweh_register(drvr, BRCMF_E_FIFO_CREDIT_MAP,
1911 brcmf_fws_notify_credit_map);
1913 brcmf_err("register credit map handler failed\n");
1916 rc = brcmf_fweh_register(drvr, BRCMF_E_BCMC_CREDIT_SUPPORT,
1917 brcmf_fws_notify_bcmc_credit_support);
1919 brcmf_err("register bcmc credit handler failed\n");
1920 brcmf_fweh_unregister(drvr, BRCMF_E_FIFO_CREDIT_MAP);
1924 /* setting the iovar may fail if feature is unsupported
1925 * so leave the rc as is so driver initialization can
1928 if (brcmf_fil_iovar_int_set(drvr->iflist[0], "tlv", tlv)) {
1929 brcmf_err("failed to set bdcv2 tlv signaling\n");
1933 brcmf_fws_hanger_init(&drvr->fws->hanger);
1934 brcmf_fws_macdesc_init(&drvr->fws->desc.other, NULL, 0);
1935 brcmf_fws_macdesc_set_name(drvr->fws, &drvr->fws->desc.other);
1936 brcmu_pktq_init(&drvr->fws->desc.other.psq, BRCMF_FWS_PSQ_PREC_COUNT,
1939 /* create debugfs file for statistics */
1940 brcmf_debugfs_create_fws_stats(drvr, &drvr->fws->stats);
1942 brcmf_dbg(INFO, "%s bdcv2 tlv signaling [%x]\n",
1943 drvr->fw_signals ? "enabled" : "disabled", tlv);
1947 brcmf_fweh_unregister(drvr, BRCMF_E_BCMC_CREDIT_SUPPORT);
1948 brcmf_fweh_unregister(drvr, BRCMF_E_FIFO_CREDIT_MAP);
1950 brcmf_fws_deinit(drvr);
1954 void brcmf_fws_deinit(struct brcmf_pub *drvr)
1956 struct brcmf_fws_info *fws = drvr->fws;
1962 /* disable firmware signalling entirely
1963 * to avoid using the workqueue.
1965 drvr->fw_signals = false;
1967 if (drvr->fws->fws_wq)
1968 destroy_workqueue(drvr->fws->fws_wq);
1971 brcmf_fws_lock(drvr, flags);
1972 brcmf_fws_cleanup(fws, -1);
1974 brcmf_fws_unlock(drvr, flags);
1976 /* free top structure */
1980 bool brcmf_fws_fc_active(struct brcmf_fws_info *fws)
1985 return fws->fcmode != BRCMF_FWS_FCMODE_NONE;
1988 void brcmf_fws_bustxfail(struct brcmf_fws_info *fws, struct sk_buff *skb)
1993 if (brcmf_skbcb(skb)->state == BRCMF_FWS_SKBSTATE_TIM) {
1994 brcmu_pkt_buf_free_skb(skb);
1997 brcmf_fws_lock(fws->drvr, flags);
1998 hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT);
1999 brcmf_fws_txs_process(fws, BRCMF_FWS_TXSTATUS_HOST_TOSSED, hslot, 0);
2000 brcmf_fws_unlock(fws->drvr, flags);
2003 void brcmf_fws_bus_blocked(struct brcmf_pub *drvr, bool flow_blocked)
2005 struct brcmf_fws_info *fws = drvr->fws;
2007 fws->bus_flow_blocked = flow_blocked;
2009 brcmf_fws_schedule_deq(fws);
2011 fws->stats.bus_flow_block++;