1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2010 Broadcom Corporation
5 #include <linux/types.h>
6 #include <linux/module.h>
7 #include <linux/if_ether.h>
8 #include <linux/spinlock.h>
9 #include <linux/skbuff.h>
10 #include <linux/netdevice.h>
11 #include <linux/etherdevice.h>
12 #include <linux/err.h>
13 #include <linux/jiffies.h>
14 #include <net/cfg80211.h>
16 #include <brcmu_utils.h>
17 #include <brcmu_wifi.h>
22 #include "fwil_types.h"
32 * DOC: Firmware Signalling
34 * Firmware can send signals to host and vice versa, which are passed in the
35 * data packets using TLV based header. This signalling layer is on top of the
36 * BDC bus protocol layer.
40 * single definition for firmware-driver flow control tlv's.
42 * each tlv is specified by BRCMF_FWS_TLV_DEF(name, ID, length).
43 * A length value 0 indicates variable length tlv.
45 #define BRCMF_FWS_TLV_DEFLIST \
46 BRCMF_FWS_TLV_DEF(MAC_OPEN, 1, 1) \
47 BRCMF_FWS_TLV_DEF(MAC_CLOSE, 2, 1) \
48 BRCMF_FWS_TLV_DEF(MAC_REQUEST_CREDIT, 3, 2) \
49 BRCMF_FWS_TLV_DEF(TXSTATUS, 4, 4) \
50 BRCMF_FWS_TLV_DEF(PKTTAG, 5, 4) \
51 BRCMF_FWS_TLV_DEF(MACDESC_ADD, 6, 8) \
52 BRCMF_FWS_TLV_DEF(MACDESC_DEL, 7, 8) \
53 BRCMF_FWS_TLV_DEF(RSSI, 8, 1) \
54 BRCMF_FWS_TLV_DEF(INTERFACE_OPEN, 9, 1) \
55 BRCMF_FWS_TLV_DEF(INTERFACE_CLOSE, 10, 1) \
56 BRCMF_FWS_TLV_DEF(FIFO_CREDITBACK, 11, 6) \
57 BRCMF_FWS_TLV_DEF(PENDING_TRAFFIC_BMP, 12, 2) \
58 BRCMF_FWS_TLV_DEF(MAC_REQUEST_PACKET, 13, 3) \
59 BRCMF_FWS_TLV_DEF(HOST_REORDER_RXPKTS, 14, 10) \
60 BRCMF_FWS_TLV_DEF(TRANS_ID, 18, 6) \
61 BRCMF_FWS_TLV_DEF(COMP_TXSTATUS, 19, 1) \
62 BRCMF_FWS_TLV_DEF(FILLER, 255, 0)
65 * enum brcmf_fws_tlv_type - definition of tlv identifiers.
67 #define BRCMF_FWS_TLV_DEF(name, id, len) \
68 BRCMF_FWS_TYPE_ ## name = id,
69 enum brcmf_fws_tlv_type
{
71 BRCMF_FWS_TYPE_INVALID
73 #undef BRCMF_FWS_TLV_DEF
76 * enum brcmf_fws_tlv_len - definition of tlv lengths.
78 #define BRCMF_FWS_TLV_DEF(name, id, len) \
79 BRCMF_FWS_TYPE_ ## name ## _LEN = (len),
80 enum brcmf_fws_tlv_len
{
83 #undef BRCMF_FWS_TLV_DEF
85 /* AMPDU rx reordering definitions */
86 #define BRCMF_RXREORDER_FLOWID_OFFSET 0
87 #define BRCMF_RXREORDER_MAXIDX_OFFSET 2
88 #define BRCMF_RXREORDER_FLAGS_OFFSET 4
89 #define BRCMF_RXREORDER_CURIDX_OFFSET 6
90 #define BRCMF_RXREORDER_EXPIDX_OFFSET 8
92 #define BRCMF_RXREORDER_DEL_FLOW 0x01
93 #define BRCMF_RXREORDER_FLUSH_ALL 0x02
94 #define BRCMF_RXREORDER_CURIDX_VALID 0x04
95 #define BRCMF_RXREORDER_EXPIDX_VALID 0x08
96 #define BRCMF_RXREORDER_NEW_HOLE 0x10
100 * brcmf_fws_tlv_names - array of tlv names.
102 #define BRCMF_FWS_TLV_DEF(name, id, len) \
105 enum brcmf_fws_tlv_type id
;
107 } brcmf_fws_tlv_names
[] = {
108 BRCMF_FWS_TLV_DEFLIST
110 #undef BRCMF_FWS_TLV_DEF
113 static const char *brcmf_fws_get_tlv_name(enum brcmf_fws_tlv_type id
)
117 for (i
= 0; i
< ARRAY_SIZE(brcmf_fws_tlv_names
); i
++)
118 if (brcmf_fws_tlv_names
[i
].id
== id
)
119 return brcmf_fws_tlv_names
[i
].name
;
124 static const char *brcmf_fws_get_tlv_name(enum brcmf_fws_tlv_type id
)
131 * The PKTTAG tlv has additional bytes when firmware-signalling
132 * mode has REUSESEQ flag set.
134 #define BRCMF_FWS_TYPE_SEQ_LEN 2
137 * flags used to enable tlv signalling from firmware.
139 #define BRCMF_FWS_FLAGS_RSSI_SIGNALS 0x0001
140 #define BRCMF_FWS_FLAGS_XONXOFF_SIGNALS 0x0002
141 #define BRCMF_FWS_FLAGS_CREDIT_STATUS_SIGNALS 0x0004
142 #define BRCMF_FWS_FLAGS_HOST_PROPTXSTATUS_ACTIVE 0x0008
143 #define BRCMF_FWS_FLAGS_PSQ_GENERATIONFSM_ENABLE 0x0010
144 #define BRCMF_FWS_FLAGS_PSQ_ZERO_BUFFER_ENABLE 0x0020
145 #define BRCMF_FWS_FLAGS_HOST_RXREORDER_ACTIVE 0x0040
147 #define BRCMF_FWS_MAC_DESC_TABLE_SIZE 32
148 #define BRCMF_FWS_MAC_DESC_ID_INVALID 0xff
150 #define BRCMF_FWS_HOSTIF_FLOWSTATE_OFF 0
151 #define BRCMF_FWS_HOSTIF_FLOWSTATE_ON 1
152 #define BRCMF_FWS_FLOWCONTROL_HIWATER 128
153 #define BRCMF_FWS_FLOWCONTROL_LOWATER 64
155 #define BRCMF_FWS_PSQ_PREC_COUNT ((BRCMF_FWS_FIFO_COUNT + 1) * 2)
156 #define BRCMF_FWS_PSQ_LEN 256
158 #define BRCMF_FWS_HTOD_FLAG_PKTFROMHOST 0x01
159 #define BRCMF_FWS_HTOD_FLAG_PKT_REQUESTED 0x02
161 #define BRCMF_FWS_RET_OK_NOSCHEDULE 0
162 #define BRCMF_FWS_RET_OK_SCHEDULE 1
164 #define BRCMF_FWS_MODE_REUSESEQ_SHIFT 3 /* seq reuse */
165 #define BRCMF_FWS_MODE_SET_REUSESEQ(x, val) ((x) = \
166 ((x) & ~(1 << BRCMF_FWS_MODE_REUSESEQ_SHIFT)) | \
167 (((val) & 1) << BRCMF_FWS_MODE_REUSESEQ_SHIFT))
168 #define BRCMF_FWS_MODE_GET_REUSESEQ(x) \
169 (((x) >> BRCMF_FWS_MODE_REUSESEQ_SHIFT) & 1)
172 * enum brcmf_fws_skb_state - indicates processing state of skb.
174 * @BRCMF_FWS_SKBSTATE_NEW: sk_buff is newly arrived in the driver.
175 * @BRCMF_FWS_SKBSTATE_DELAYED: sk_buff had to wait on queue.
176 * @BRCMF_FWS_SKBSTATE_SUPPRESSED: sk_buff has been suppressed by firmware.
177 * @BRCMF_FWS_SKBSTATE_TIM: allocated for TIM update info.
179 enum brcmf_fws_skb_state
{
180 BRCMF_FWS_SKBSTATE_NEW
,
181 BRCMF_FWS_SKBSTATE_DELAYED
,
182 BRCMF_FWS_SKBSTATE_SUPPRESSED
,
183 BRCMF_FWS_SKBSTATE_TIM
187 * struct brcmf_skbuff_cb - control buffer associated with skbuff.
189 * @bus_flags: 2 bytes reserved for bus specific parameters
190 * @if_flags: holds interface index and packet related flags.
191 * @htod: host to device packet identifier (used in PKTTAG tlv).
192 * @htod_seq: this 16-bit is original seq number for every suppress packet.
193 * @state: transmit state of the packet.
194 * @mac: descriptor related to destination for this packet.
196 * This information is stored in control buffer struct sk_buff::cb, which
197 * provides 48 bytes of storage so this structure should not exceed that.
199 struct brcmf_skbuff_cb
{
204 enum brcmf_fws_skb_state state
;
205 struct brcmf_fws_mac_descriptor
*mac
;
209 * macro casting skbuff control buffer to struct brcmf_skbuff_cb.
211 #define brcmf_skbcb(skb) ((struct brcmf_skbuff_cb *)((skb)->cb))
214 * sk_buff control if flags
216 * b[11] - packet sent upon firmware request.
217 * b[10] - packet only contains signalling data.
218 * b[9] - packet is a tx packet.
219 * b[8] - packet used requested credit
220 * b[7] - interface in AP mode.
221 * b[3:0] - interface index.
223 #define BRCMF_SKB_IF_FLAGS_REQUESTED_MASK 0x0800
224 #define BRCMF_SKB_IF_FLAGS_REQUESTED_SHIFT 11
225 #define BRCMF_SKB_IF_FLAGS_SIGNAL_ONLY_MASK 0x0400
226 #define BRCMF_SKB_IF_FLAGS_SIGNAL_ONLY_SHIFT 10
227 #define BRCMF_SKB_IF_FLAGS_TRANSMIT_MASK 0x0200
228 #define BRCMF_SKB_IF_FLAGS_TRANSMIT_SHIFT 9
229 #define BRCMF_SKB_IF_FLAGS_REQ_CREDIT_MASK 0x0100
230 #define BRCMF_SKB_IF_FLAGS_REQ_CREDIT_SHIFT 8
231 #define BRCMF_SKB_IF_FLAGS_IF_AP_MASK 0x0080
232 #define BRCMF_SKB_IF_FLAGS_IF_AP_SHIFT 7
233 #define BRCMF_SKB_IF_FLAGS_INDEX_MASK 0x000f
234 #define BRCMF_SKB_IF_FLAGS_INDEX_SHIFT 0
236 #define brcmf_skb_if_flags_set_field(skb, field, value) \
237 brcmu_maskset16(&(brcmf_skbcb(skb)->if_flags), \
238 BRCMF_SKB_IF_FLAGS_ ## field ## _MASK, \
239 BRCMF_SKB_IF_FLAGS_ ## field ## _SHIFT, (value))
240 #define brcmf_skb_if_flags_get_field(skb, field) \
241 brcmu_maskget16(brcmf_skbcb(skb)->if_flags, \
242 BRCMF_SKB_IF_FLAGS_ ## field ## _MASK, \
243 BRCMF_SKB_IF_FLAGS_ ## field ## _SHIFT)
246 * sk_buff control packet identifier
248 * 32-bit packet identifier used in PKTTAG tlv from host to dongle.
250 * - Generated at the host (e.g. dhd)
251 * - Seen as a generic sequence number by firmware except for the flags field.
253 * Generation : b[31] => generation number for this packet [host->fw]
254 * OR, current generation number [fw->host]
255 * Flags : b[30:27] => command, status flags
256 * FIFO-AC : b[26:24] => AC-FIFO id
257 * h-slot : b[23:8] => hanger-slot
258 * freerun : b[7:0] => A free running counter
260 #define BRCMF_SKB_HTOD_TAG_GENERATION_MASK 0x80000000
261 #define BRCMF_SKB_HTOD_TAG_GENERATION_SHIFT 31
262 #define BRCMF_SKB_HTOD_TAG_FLAGS_MASK 0x78000000
263 #define BRCMF_SKB_HTOD_TAG_FLAGS_SHIFT 27
264 #define BRCMF_SKB_HTOD_TAG_FIFO_MASK 0x07000000
265 #define BRCMF_SKB_HTOD_TAG_FIFO_SHIFT 24
266 #define BRCMF_SKB_HTOD_TAG_HSLOT_MASK 0x00ffff00
267 #define BRCMF_SKB_HTOD_TAG_HSLOT_SHIFT 8
268 #define BRCMF_SKB_HTOD_TAG_FREERUN_MASK 0x000000ff
269 #define BRCMF_SKB_HTOD_TAG_FREERUN_SHIFT 0
271 #define brcmf_skb_htod_tag_set_field(skb, field, value) \
272 brcmu_maskset32(&(brcmf_skbcb(skb)->htod), \
273 BRCMF_SKB_HTOD_TAG_ ## field ## _MASK, \
274 BRCMF_SKB_HTOD_TAG_ ## field ## _SHIFT, (value))
275 #define brcmf_skb_htod_tag_get_field(skb, field) \
276 brcmu_maskget32(brcmf_skbcb(skb)->htod, \
277 BRCMF_SKB_HTOD_TAG_ ## field ## _MASK, \
278 BRCMF_SKB_HTOD_TAG_ ## field ## _SHIFT)
280 #define BRCMF_SKB_HTOD_SEQ_FROMFW_MASK 0x2000
281 #define BRCMF_SKB_HTOD_SEQ_FROMFW_SHIFT 13
282 #define BRCMF_SKB_HTOD_SEQ_FROMDRV_MASK 0x1000
283 #define BRCMF_SKB_HTOD_SEQ_FROMDRV_SHIFT 12
284 #define BRCMF_SKB_HTOD_SEQ_NR_MASK 0x0fff
285 #define BRCMF_SKB_HTOD_SEQ_NR_SHIFT 0
287 #define brcmf_skb_htod_seq_set_field(skb, field, value) \
288 brcmu_maskset16(&(brcmf_skbcb(skb)->htod_seq), \
289 BRCMF_SKB_HTOD_SEQ_ ## field ## _MASK, \
290 BRCMF_SKB_HTOD_SEQ_ ## field ## _SHIFT, (value))
291 #define brcmf_skb_htod_seq_get_field(skb, field) \
292 brcmu_maskget16(brcmf_skbcb(skb)->htod_seq, \
293 BRCMF_SKB_HTOD_SEQ_ ## field ## _MASK, \
294 BRCMF_SKB_HTOD_SEQ_ ## field ## _SHIFT)
296 #define BRCMF_FWS_TXSTAT_GENERATION_MASK 0x80000000
297 #define BRCMF_FWS_TXSTAT_GENERATION_SHIFT 31
298 #define BRCMF_FWS_TXSTAT_FLAGS_MASK 0x78000000
299 #define BRCMF_FWS_TXSTAT_FLAGS_SHIFT 27
300 #define BRCMF_FWS_TXSTAT_FIFO_MASK 0x07000000
301 #define BRCMF_FWS_TXSTAT_FIFO_SHIFT 24
302 #define BRCMF_FWS_TXSTAT_HSLOT_MASK 0x00FFFF00
303 #define BRCMF_FWS_TXSTAT_HSLOT_SHIFT 8
304 #define BRCMF_FWS_TXSTAT_FREERUN_MASK 0x000000FF
305 #define BRCMF_FWS_TXSTAT_FREERUN_SHIFT 0
307 #define brcmf_txstatus_get_field(txs, field) \
308 brcmu_maskget32(txs, BRCMF_FWS_TXSTAT_ ## field ## _MASK, \
309 BRCMF_FWS_TXSTAT_ ## field ## _SHIFT)
311 /* How long to defer borrowing in jiffies */
312 #define BRCMF_FWS_BORROW_DEFER_PERIOD (HZ / 10)
316 * enum brcmf_fws_txstatus - txstatus flag values.
318 * @BRCMF_FWS_TXSTATUS_DISCARD:
319 * host is free to discard the packet.
320 * @BRCMF_FWS_TXSTATUS_CORE_SUPPRESS:
321 * 802.11 core suppressed the packet.
322 * @BRCMF_FWS_TXSTATUS_FW_PS_SUPPRESS:
323 * firmware suppress the packet as device is already in PS mode.
324 * @BRCMF_FWS_TXSTATUS_FW_TOSSED:
325 * firmware tossed the packet.
326 * @BRCMF_FWS_TXSTATUS_FW_DISCARD_NOACK:
327 * firmware tossed the packet after retries.
328 * @BRCMF_FWS_TXSTATUS_FW_SUPPRESS_ACKED:
329 * firmware wrongly reported suppressed previously, now fixing to acked.
330 * @BRCMF_FWS_TXSTATUS_HOST_TOSSED:
331 * host tossed the packet.
333 enum brcmf_fws_txstatus
{
334 BRCMF_FWS_TXSTATUS_DISCARD
,
335 BRCMF_FWS_TXSTATUS_CORE_SUPPRESS
,
336 BRCMF_FWS_TXSTATUS_FW_PS_SUPPRESS
,
337 BRCMF_FWS_TXSTATUS_FW_TOSSED
,
338 BRCMF_FWS_TXSTATUS_FW_DISCARD_NOACK
,
339 BRCMF_FWS_TXSTATUS_FW_SUPPRESS_ACKED
,
340 BRCMF_FWS_TXSTATUS_HOST_TOSSED
343 enum brcmf_fws_fcmode
{
344 BRCMF_FWS_FCMODE_NONE
,
345 BRCMF_FWS_FCMODE_IMPLIED_CREDIT
,
346 BRCMF_FWS_FCMODE_EXPLICIT_CREDIT
349 enum brcmf_fws_mac_desc_state
{
350 BRCMF_FWS_STATE_OPEN
= 1,
351 BRCMF_FWS_STATE_CLOSE
355 * struct brcmf_fws_mac_descriptor - firmware signalling data per node/interface
357 * @name: name of the descriptor.
358 * @occupied: slot is in use.
359 * @mac_handle: handle for mac entry determined by firmware.
360 * @interface_id: interface index.
361 * @state: current state.
362 * @suppressed: mac entry is suppressed.
363 * @generation: generation bit.
364 * @ac_bitmap: ac queue bitmap.
365 * @requested_credit: credits requested by firmware.
366 * @requested_packet: packet requested by firmware.
367 * @ea: ethernet address.
368 * @seq: per-node free-running sequence.
369 * @psq: power-save queue.
370 * @transit_count: packet in transit to firmware.
371 * @suppr_transit_count: suppressed packet in transit to firmware.
372 * @send_tim_signal: if set tim signal will be sent.
373 * @traffic_pending_bmp: traffic pending bitmap.
374 * @traffic_lastreported_bmp: traffic last reported bitmap.
376 struct brcmf_fws_mac_descriptor
{
388 u8 seq
[BRCMF_FWS_FIFO_COUNT
];
391 int suppr_transit_count
;
392 bool send_tim_signal
;
393 u8 traffic_pending_bmp
;
394 u8 traffic_lastreported_bmp
;
397 #define BRCMF_FWS_HANGER_MAXITEMS 3072
398 #define BRCMF_BORROW_RATIO 3
401 * enum brcmf_fws_hanger_item_state - state of hanger item.
403 * @BRCMF_FWS_HANGER_ITEM_STATE_FREE: item is free for use.
404 * @BRCMF_FWS_HANGER_ITEM_STATE_INUSE: item is in use.
405 * @BRCMF_FWS_HANGER_ITEM_STATE_INUSE_SUPPRESSED: item was suppressed.
407 enum brcmf_fws_hanger_item_state
{
408 BRCMF_FWS_HANGER_ITEM_STATE_FREE
= 1,
409 BRCMF_FWS_HANGER_ITEM_STATE_INUSE
,
410 BRCMF_FWS_HANGER_ITEM_STATE_INUSE_SUPPRESSED
415 * struct brcmf_fws_hanger_item - single entry for tx pending packet.
417 * @state: entry is either free or occupied.
418 * @pkt: packet itself.
420 struct brcmf_fws_hanger_item
{
421 enum brcmf_fws_hanger_item_state state
;
426 * struct brcmf_fws_hanger - holds packets awaiting firmware txstatus.
428 * @pushed: packets pushed to await txstatus.
429 * @popped: packets popped upon handling txstatus.
430 * @failed_to_push: packets that could not be pushed.
431 * @failed_to_pop: packets that could not be popped.
432 * @failed_slotfind: packets for which failed to find an entry.
433 * @slot_pos: last returned item index for a free entry.
434 * @items: array of hanger items.
436 struct brcmf_fws_hanger
{
443 struct brcmf_fws_hanger_item items
[BRCMF_FWS_HANGER_MAXITEMS
];
446 struct brcmf_fws_macdesc_table
{
447 struct brcmf_fws_mac_descriptor nodes
[BRCMF_FWS_MAC_DESC_TABLE_SIZE
];
448 struct brcmf_fws_mac_descriptor iface
[BRCMF_MAX_IFS
];
449 struct brcmf_fws_mac_descriptor other
;
452 struct brcmf_fws_stats
{
453 u32 tlv_parse_failed
;
454 u32 tlv_invalid_type
;
459 u32 requested_sent
[5];
461 u32 mac_update_failed
;
462 u32 mac_ps_update_failed
;
463 u32 if_update_failed
;
464 u32 packet_request_failed
;
465 u32 credit_request_failed
;
466 u32 rollback_success
;
468 u32 delayq_full_error
;
469 u32 supprq_full_error
;
480 struct brcmf_fws_info
{
481 struct brcmf_pub
*drvr
;
484 struct brcmf_fws_stats stats
;
485 struct brcmf_fws_hanger hanger
;
486 enum brcmf_fws_fcmode fcmode
;
488 bool bcmc_credit_check
;
489 struct brcmf_fws_macdesc_table desc
;
490 struct workqueue_struct
*fws_wq
;
491 struct work_struct fws_dequeue_work
;
492 u32 fifo_enqpkt
[BRCMF_FWS_FIFO_COUNT
];
493 int fifo_credit
[BRCMF_FWS_FIFO_COUNT
];
494 int init_fifo_credit
[BRCMF_FWS_FIFO_COUNT
];
495 int credits_borrowed
[BRCMF_FWS_FIFO_AC_VO
+ 1]
496 [BRCMF_FWS_FIFO_AC_VO
+ 1];
497 int deq_node_pos
[BRCMF_FWS_FIFO_COUNT
];
500 unsigned long borrow_defer_timestamp
;
501 bool bus_flow_blocked
;
502 bool creditmap_received
;
507 #define BRCMF_FWS_TLV_DEF(name, id, len) \
508 case BRCMF_FWS_TYPE_ ## name: \
512 * brcmf_fws_get_tlv_len() - returns defined length for given tlv id.
514 * @fws: firmware-signalling information.
515 * @id: identifier of the TLV.
517 * Return: the specified length for the given TLV; Otherwise -EINVAL.
519 static int brcmf_fws_get_tlv_len(struct brcmf_fws_info
*fws
,
520 enum brcmf_fws_tlv_type id
)
523 BRCMF_FWS_TLV_DEFLIST
525 fws
->stats
.tlv_invalid_type
++;
530 #undef BRCMF_FWS_TLV_DEF
532 static void brcmf_fws_lock(struct brcmf_fws_info
*fws
)
533 __acquires(&fws
->spinlock
)
535 spin_lock_irqsave(&fws
->spinlock
, fws
->flags
);
538 static void brcmf_fws_unlock(struct brcmf_fws_info
*fws
)
539 __releases(&fws
->spinlock
)
541 spin_unlock_irqrestore(&fws
->spinlock
, fws
->flags
);
544 static bool brcmf_fws_ifidx_match(struct sk_buff
*skb
, void *arg
)
546 u32 ifidx
= brcmf_skb_if_flags_get_field(skb
, INDEX
);
547 return ifidx
== *(int *)arg
;
550 static void brcmf_fws_hanger_init(struct brcmf_fws_hanger
*hanger
)
554 memset(hanger
, 0, sizeof(*hanger
));
555 for (i
= 0; i
< ARRAY_SIZE(hanger
->items
); i
++)
556 hanger
->items
[i
].state
= BRCMF_FWS_HANGER_ITEM_STATE_FREE
;
559 static u32
brcmf_fws_hanger_get_free_slot(struct brcmf_fws_hanger
*h
)
563 i
= (h
->slot_pos
+ 1) % BRCMF_FWS_HANGER_MAXITEMS
;
565 while (i
!= h
->slot_pos
) {
566 if (h
->items
[i
].state
== BRCMF_FWS_HANGER_ITEM_STATE_FREE
) {
571 if (i
== BRCMF_FWS_HANGER_MAXITEMS
)
574 brcmf_err("all slots occupied\n");
575 h
->failed_slotfind
++;
576 i
= BRCMF_FWS_HANGER_MAXITEMS
;
581 static int brcmf_fws_hanger_pushpkt(struct brcmf_fws_hanger
*h
,
582 struct sk_buff
*pkt
, u32 slot_id
)
584 if (slot_id
>= BRCMF_FWS_HANGER_MAXITEMS
)
587 if (h
->items
[slot_id
].state
!= BRCMF_FWS_HANGER_ITEM_STATE_FREE
) {
588 brcmf_err("slot is not free\n");
593 h
->items
[slot_id
].state
= BRCMF_FWS_HANGER_ITEM_STATE_INUSE
;
594 h
->items
[slot_id
].pkt
= pkt
;
599 static inline int brcmf_fws_hanger_poppkt(struct brcmf_fws_hanger
*h
,
600 u32 slot_id
, struct sk_buff
**pktout
,
603 if (slot_id
>= BRCMF_FWS_HANGER_MAXITEMS
)
606 if (h
->items
[slot_id
].state
== BRCMF_FWS_HANGER_ITEM_STATE_FREE
) {
607 brcmf_err("entry not in use\n");
612 *pktout
= h
->items
[slot_id
].pkt
;
614 h
->items
[slot_id
].state
= BRCMF_FWS_HANGER_ITEM_STATE_FREE
;
615 h
->items
[slot_id
].pkt
= NULL
;
621 static void brcmf_fws_psq_flush(struct brcmf_fws_info
*fws
, struct pktq
*q
,
624 struct brcmf_fws_hanger_item
*hi
;
625 bool (*matchfn
)(struct sk_buff
*, void *) = NULL
;
631 matchfn
= brcmf_fws_ifidx_match
;
632 for (prec
= 0; prec
< q
->num_prec
; prec
++) {
633 skb
= brcmu_pktq_pdeq_match(q
, prec
, matchfn
, &ifidx
);
635 hslot
= brcmf_skb_htod_tag_get_field(skb
, HSLOT
);
636 hi
= &fws
->hanger
.items
[hslot
];
637 WARN_ON(skb
!= hi
->pkt
);
638 hi
->state
= BRCMF_FWS_HANGER_ITEM_STATE_FREE
;
639 brcmf_fws_hanger_poppkt(&fws
->hanger
, hslot
, &skb
,
641 brcmu_pkt_buf_free_skb(skb
);
642 skb
= brcmu_pktq_pdeq_match(q
, prec
, matchfn
, &ifidx
);
647 static int brcmf_fws_hanger_mark_suppressed(struct brcmf_fws_hanger
*h
,
650 if (slot_id
>= BRCMF_FWS_HANGER_MAXITEMS
)
653 if (h
->items
[slot_id
].state
== BRCMF_FWS_HANGER_ITEM_STATE_FREE
) {
654 brcmf_err("entry not in use\n");
658 h
->items
[slot_id
].state
= BRCMF_FWS_HANGER_ITEM_STATE_INUSE_SUPPRESSED
;
662 static void brcmf_fws_hanger_cleanup(struct brcmf_fws_info
*fws
,
663 bool (*fn
)(struct sk_buff
*, void *),
666 struct brcmf_fws_hanger
*h
= &fws
->hanger
;
669 enum brcmf_fws_hanger_item_state s
;
671 for (i
= 0; i
< ARRAY_SIZE(h
->items
); i
++) {
672 s
= h
->items
[i
].state
;
673 if (s
== BRCMF_FWS_HANGER_ITEM_STATE_INUSE
||
674 s
== BRCMF_FWS_HANGER_ITEM_STATE_INUSE_SUPPRESSED
) {
675 skb
= h
->items
[i
].pkt
;
676 if (fn
== NULL
|| fn(skb
, &ifidx
)) {
677 /* suppress packets freed from psq */
678 if (s
== BRCMF_FWS_HANGER_ITEM_STATE_INUSE
)
679 brcmu_pkt_buf_free_skb(skb
);
681 BRCMF_FWS_HANGER_ITEM_STATE_FREE
;
687 static void brcmf_fws_macdesc_set_name(struct brcmf_fws_info
*fws
,
688 struct brcmf_fws_mac_descriptor
*desc
)
690 if (desc
== &fws
->desc
.other
)
691 strscpy(desc
->name
, "MAC-OTHER", sizeof(desc
->name
));
692 else if (desc
->mac_handle
)
693 scnprintf(desc
->name
, sizeof(desc
->name
), "MAC-%d:%d",
694 desc
->mac_handle
, desc
->interface_id
);
696 scnprintf(desc
->name
, sizeof(desc
->name
), "MACIF:%d",
700 static void brcmf_fws_macdesc_init(struct brcmf_fws_mac_descriptor
*desc
,
704 "enter: desc %p ea=%pM, ifidx=%u\n", desc
, addr
, ifidx
);
706 desc
->state
= BRCMF_FWS_STATE_OPEN
;
707 desc
->requested_credit
= 0;
708 desc
->requested_packet
= 0;
709 /* depending on use may need ifp->bsscfgidx instead */
710 desc
->interface_id
= ifidx
;
711 desc
->ac_bitmap
= 0xff; /* update this when handling APSD */
713 memcpy(&desc
->ea
[0], addr
, ETH_ALEN
);
717 void brcmf_fws_macdesc_deinit(struct brcmf_fws_mac_descriptor
*desc
)
720 "enter: ea=%pM, ifidx=%u\n", desc
->ea
, desc
->interface_id
);
722 desc
->state
= BRCMF_FWS_STATE_CLOSE
;
723 desc
->requested_credit
= 0;
724 desc
->requested_packet
= 0;
727 static struct brcmf_fws_mac_descriptor
*
728 brcmf_fws_macdesc_lookup(struct brcmf_fws_info
*fws
, u8
*ea
)
730 struct brcmf_fws_mac_descriptor
*entry
;
734 return ERR_PTR(-EINVAL
);
736 entry
= &fws
->desc
.nodes
[0];
737 for (i
= 0; i
< ARRAY_SIZE(fws
->desc
.nodes
); i
++) {
738 if (entry
->occupied
&& !memcmp(entry
->ea
, ea
, ETH_ALEN
))
743 return ERR_PTR(-ENOENT
);
746 static struct brcmf_fws_mac_descriptor
*
747 brcmf_fws_macdesc_find(struct brcmf_fws_info
*fws
, struct brcmf_if
*ifp
, u8
*da
)
749 struct brcmf_fws_mac_descriptor
*entry
;
752 multicast
= is_multicast_ether_addr(da
);
754 /* Multicast destination, STA and P2P clients get the interface entry.
755 * STA/GC gets the Mac Entry for TDLS destinations, TDLS destinations
756 * have their own entry.
758 if (multicast
&& ifp
->fws_desc
) {
759 entry
= ifp
->fws_desc
;
763 entry
= brcmf_fws_macdesc_lookup(fws
, da
);
765 entry
= ifp
->fws_desc
;
771 static bool brcmf_fws_macdesc_closed(struct brcmf_fws_info
*fws
,
772 struct brcmf_fws_mac_descriptor
*entry
,
775 struct brcmf_fws_mac_descriptor
*if_entry
;
778 /* for unique destination entries the related interface
781 if (entry
->mac_handle
) {
782 if_entry
= &fws
->desc
.iface
[entry
->interface_id
];
783 if (if_entry
->state
== BRCMF_FWS_STATE_CLOSE
)
786 /* an entry is closed when the state is closed and
787 * the firmware did not request anything.
789 closed
= entry
->state
== BRCMF_FWS_STATE_CLOSE
&&
790 !entry
->requested_credit
&& !entry
->requested_packet
;
792 /* Or firmware does not allow traffic for given fifo */
793 return closed
|| !(entry
->ac_bitmap
& BIT(fifo
));
796 static void brcmf_fws_macdesc_cleanup(struct brcmf_fws_info
*fws
,
797 struct brcmf_fws_mac_descriptor
*entry
,
800 if (entry
->occupied
&& (ifidx
== -1 || ifidx
== entry
->interface_id
)) {
801 brcmf_fws_psq_flush(fws
, &entry
->psq
, ifidx
);
802 entry
->occupied
= !!(entry
->psq
.len
);
806 static void brcmf_fws_bus_txq_cleanup(struct brcmf_fws_info
*fws
,
807 bool (*fn
)(struct sk_buff
*, void *),
810 struct brcmf_fws_hanger_item
*hi
;
816 txq
= brcmf_bus_gettxq(fws
->drvr
->bus_if
);
818 brcmf_dbg(TRACE
, "no txq to clean up\n");
822 for (prec
= 0; prec
< txq
->num_prec
; prec
++) {
823 skb
= brcmu_pktq_pdeq_match(txq
, prec
, fn
, &ifidx
);
825 hslot
= brcmf_skb_htod_tag_get_field(skb
, HSLOT
);
826 hi
= &fws
->hanger
.items
[hslot
];
827 WARN_ON(skb
!= hi
->pkt
);
828 hi
->state
= BRCMF_FWS_HANGER_ITEM_STATE_FREE
;
829 brcmu_pkt_buf_free_skb(skb
);
830 skb
= brcmu_pktq_pdeq_match(txq
, prec
, fn
, &ifidx
);
835 static void brcmf_fws_cleanup(struct brcmf_fws_info
*fws
, int ifidx
)
838 struct brcmf_fws_mac_descriptor
*table
;
839 bool (*matchfn
)(struct sk_buff
*, void *) = NULL
;
845 matchfn
= brcmf_fws_ifidx_match
;
847 /* cleanup individual nodes */
848 table
= &fws
->desc
.nodes
[0];
849 for (i
= 0; i
< ARRAY_SIZE(fws
->desc
.nodes
); i
++)
850 brcmf_fws_macdesc_cleanup(fws
, &table
[i
], ifidx
);
852 brcmf_fws_macdesc_cleanup(fws
, &fws
->desc
.other
, ifidx
);
853 brcmf_fws_bus_txq_cleanup(fws
, matchfn
, ifidx
);
854 brcmf_fws_hanger_cleanup(fws
, matchfn
, ifidx
);
857 static u8
brcmf_fws_hdrpush(struct brcmf_fws_info
*fws
, struct sk_buff
*skb
)
859 struct brcmf_fws_mac_descriptor
*entry
= brcmf_skbcb(skb
)->mac
;
863 __le32 pkttag
= cpu_to_le32(brcmf_skbcb(skb
)->htod
);
864 __le16 pktseq
= cpu_to_le16(brcmf_skbcb(skb
)->htod_seq
);
866 brcmf_dbg(TRACE
, "enter: %s, idx=%d hslot=%d htod %X seq %X\n",
867 entry
->name
, brcmf_skb_if_flags_get_field(skb
, INDEX
),
868 (le32_to_cpu(pkttag
) >> 8) & 0xffff,
869 brcmf_skbcb(skb
)->htod
, brcmf_skbcb(skb
)->htod_seq
);
870 if (entry
->send_tim_signal
)
871 data_offset
+= 2 + BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP_LEN
;
872 if (BRCMF_FWS_MODE_GET_REUSESEQ(fws
->mode
))
873 data_offset
+= BRCMF_FWS_TYPE_SEQ_LEN
;
874 /* +2 is for Type[1] and Len[1] in TLV, plus TIM signal */
875 data_offset
+= 2 + BRCMF_FWS_TYPE_PKTTAG_LEN
;
876 fillers
= round_up(data_offset
, 4) - data_offset
;
877 data_offset
+= fillers
;
879 skb_push(skb
, data_offset
);
882 wlh
[0] = BRCMF_FWS_TYPE_PKTTAG
;
883 wlh
[1] = BRCMF_FWS_TYPE_PKTTAG_LEN
;
884 memcpy(&wlh
[2], &pkttag
, sizeof(pkttag
));
885 if (BRCMF_FWS_MODE_GET_REUSESEQ(fws
->mode
)) {
886 wlh
[1] += BRCMF_FWS_TYPE_SEQ_LEN
;
887 memcpy(&wlh
[2 + BRCMF_FWS_TYPE_PKTTAG_LEN
], &pktseq
,
892 if (entry
->send_tim_signal
) {
893 entry
->send_tim_signal
= false;
894 wlh
[0] = BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP
;
895 wlh
[1] = BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP_LEN
;
896 wlh
[2] = entry
->mac_handle
;
897 wlh
[3] = entry
->traffic_pending_bmp
;
898 brcmf_dbg(TRACE
, "adding TIM info: handle %d bmp 0x%X\n",
899 entry
->mac_handle
, entry
->traffic_pending_bmp
);
900 wlh
+= BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP_LEN
+ 2;
901 entry
->traffic_lastreported_bmp
= entry
->traffic_pending_bmp
;
904 memset(wlh
, BRCMF_FWS_TYPE_FILLER
, fillers
);
906 return (u8
)(data_offset
>> 2);
909 static bool brcmf_fws_tim_update(struct brcmf_fws_info
*fws
,
910 struct brcmf_fws_mac_descriptor
*entry
,
911 int fifo
, bool send_immediately
)
914 struct brcmf_skbuff_cb
*skcb
;
920 /* check delayedQ and suppressQ in one call using bitmap */
921 if (brcmu_pktq_mlen(&entry
->psq
, 3 << (fifo
* 2)) == 0)
922 entry
->traffic_pending_bmp
&= ~NBITVAL(fifo
);
924 entry
->traffic_pending_bmp
|= NBITVAL(fifo
);
926 entry
->send_tim_signal
= false;
927 if (entry
->traffic_lastreported_bmp
!= entry
->traffic_pending_bmp
)
928 entry
->send_tim_signal
= true;
929 if (send_immediately
&& entry
->send_tim_signal
&&
930 entry
->state
== BRCMF_FWS_STATE_CLOSE
) {
931 /* create a dummy packet and sent that. The traffic */
932 /* bitmap info will automatically be attached to that packet */
933 len
= BRCMF_FWS_TYPE_PKTTAG_LEN
+ 2 +
934 BRCMF_FWS_TYPE_SEQ_LEN
+
935 BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP_LEN
+ 2 +
936 4 + fws
->drvr
->hdrlen
;
937 skb
= brcmu_pkt_buf_get_skb(len
);
941 skcb
= brcmf_skbcb(skb
);
943 skcb
->state
= BRCMF_FWS_SKBSTATE_TIM
;
946 data_offset
= brcmf_fws_hdrpush(fws
, skb
);
947 ifidx
= brcmf_skb_if_flags_get_field(skb
, INDEX
);
948 brcmf_fws_unlock(fws
);
949 err
= brcmf_proto_txdata(fws
->drvr
, ifidx
, data_offset
, skb
);
952 brcmu_pkt_buf_free_skb(skb
);
959 brcmf_fws_flow_control_check(struct brcmf_fws_info
*fws
, struct pktq
*pq
,
962 struct brcmf_if
*ifp
= brcmf_get_ifp(fws
->drvr
, if_id
);
967 if ((ifp
->netif_stop
& BRCMF_NETIF_STOP_REASON_FWS_FC
) &&
968 pq
->len
<= BRCMF_FWS_FLOWCONTROL_LOWATER
)
969 brcmf_txflowblock_if(ifp
,
970 BRCMF_NETIF_STOP_REASON_FWS_FC
, false);
971 if (!(ifp
->netif_stop
& BRCMF_NETIF_STOP_REASON_FWS_FC
) &&
972 pq
->len
>= BRCMF_FWS_FLOWCONTROL_HIWATER
) {
973 fws
->stats
.fws_flow_block
++;
974 brcmf_txflowblock_if(ifp
, BRCMF_NETIF_STOP_REASON_FWS_FC
, true);
979 static int brcmf_fws_rssi_indicate(struct brcmf_fws_info
*fws
, s8 rssi
)
981 brcmf_dbg(CTL
, "rssi %d\n", rssi
);
986 int brcmf_fws_macdesc_indicate(struct brcmf_fws_info
*fws
, u8 type
, u8
*data
)
988 struct brcmf_fws_mac_descriptor
*entry
, *existing
;
993 mac_handle
= *data
++;
997 entry
= &fws
->desc
.nodes
[mac_handle
& 0x1F];
998 if (type
== BRCMF_FWS_TYPE_MACDESC_DEL
) {
999 if (entry
->occupied
) {
1000 brcmf_dbg(TRACE
, "deleting %s mac %pM\n",
1002 brcmf_fws_lock(fws
);
1003 brcmf_fws_macdesc_cleanup(fws
, entry
, -1);
1004 brcmf_fws_macdesc_deinit(entry
);
1005 brcmf_fws_unlock(fws
);
1007 fws
->stats
.mac_update_failed
++;
1011 existing
= brcmf_fws_macdesc_lookup(fws
, addr
);
1012 if (IS_ERR(existing
)) {
1013 if (!entry
->occupied
) {
1014 brcmf_fws_lock(fws
);
1015 entry
->mac_handle
= mac_handle
;
1016 brcmf_fws_macdesc_init(entry
, addr
, ifidx
);
1017 brcmf_fws_macdesc_set_name(fws
, entry
);
1018 brcmu_pktq_init(&entry
->psq
, BRCMF_FWS_PSQ_PREC_COUNT
,
1020 brcmf_fws_unlock(fws
);
1021 brcmf_dbg(TRACE
, "add %s mac %pM\n", entry
->name
, addr
);
1023 fws
->stats
.mac_update_failed
++;
1026 if (entry
!= existing
) {
1027 brcmf_dbg(TRACE
, "copy mac %s\n", existing
->name
);
1028 brcmf_fws_lock(fws
);
1029 memcpy(entry
, existing
,
1030 offsetof(struct brcmf_fws_mac_descriptor
, psq
));
1031 entry
->mac_handle
= mac_handle
;
1032 brcmf_fws_macdesc_deinit(existing
);
1033 brcmf_fws_macdesc_set_name(fws
, entry
);
1034 brcmf_fws_unlock(fws
);
1035 brcmf_dbg(TRACE
, "relocate %s mac %pM\n", entry
->name
,
1038 brcmf_dbg(TRACE
, "use existing\n");
1039 WARN_ON(entry
->mac_handle
!= mac_handle
);
1040 /* TODO: what should we do here: continue, reinit, .. */
1046 static int brcmf_fws_macdesc_state_indicate(struct brcmf_fws_info
*fws
,
1049 struct brcmf_fws_mac_descriptor
*entry
;
1053 mac_handle
= data
[0];
1054 entry
= &fws
->desc
.nodes
[mac_handle
& 0x1F];
1055 if (!entry
->occupied
) {
1056 fws
->stats
.mac_ps_update_failed
++;
1059 brcmf_fws_lock(fws
);
1060 /* a state update should wipe old credits */
1061 entry
->requested_credit
= 0;
1062 entry
->requested_packet
= 0;
1063 if (type
== BRCMF_FWS_TYPE_MAC_OPEN
) {
1064 entry
->state
= BRCMF_FWS_STATE_OPEN
;
1065 ret
= BRCMF_FWS_RET_OK_SCHEDULE
;
1067 entry
->state
= BRCMF_FWS_STATE_CLOSE
;
1068 brcmf_fws_tim_update(fws
, entry
, BRCMF_FWS_FIFO_AC_BK
, false);
1069 brcmf_fws_tim_update(fws
, entry
, BRCMF_FWS_FIFO_AC_BE
, false);
1070 brcmf_fws_tim_update(fws
, entry
, BRCMF_FWS_FIFO_AC_VI
, false);
1071 brcmf_fws_tim_update(fws
, entry
, BRCMF_FWS_FIFO_AC_VO
, true);
1072 ret
= BRCMF_FWS_RET_OK_NOSCHEDULE
;
1074 brcmf_fws_unlock(fws
);
1078 static int brcmf_fws_interface_state_indicate(struct brcmf_fws_info
*fws
,
1081 struct brcmf_fws_mac_descriptor
*entry
;
1087 if (ifidx
>= BRCMF_MAX_IFS
) {
1092 entry
= &fws
->desc
.iface
[ifidx
];
1093 if (!entry
->occupied
) {
1098 brcmf_dbg(TRACE
, "%s (%d): %s\n", brcmf_fws_get_tlv_name(type
), type
,
1100 brcmf_fws_lock(fws
);
1102 case BRCMF_FWS_TYPE_INTERFACE_OPEN
:
1103 entry
->state
= BRCMF_FWS_STATE_OPEN
;
1104 ret
= BRCMF_FWS_RET_OK_SCHEDULE
;
1106 case BRCMF_FWS_TYPE_INTERFACE_CLOSE
:
1107 entry
->state
= BRCMF_FWS_STATE_CLOSE
;
1108 ret
= BRCMF_FWS_RET_OK_NOSCHEDULE
;
1112 brcmf_fws_unlock(fws
);
1115 brcmf_fws_unlock(fws
);
1119 fws
->stats
.if_update_failed
++;
1123 static int brcmf_fws_request_indicate(struct brcmf_fws_info
*fws
, u8 type
,
1126 struct brcmf_fws_mac_descriptor
*entry
;
1128 entry
= &fws
->desc
.nodes
[data
[1] & 0x1F];
1129 if (!entry
->occupied
) {
1130 if (type
== BRCMF_FWS_TYPE_MAC_REQUEST_CREDIT
)
1131 fws
->stats
.credit_request_failed
++;
1133 fws
->stats
.packet_request_failed
++;
1137 brcmf_dbg(TRACE
, "%s (%d): %s cnt %d bmp %d\n",
1138 brcmf_fws_get_tlv_name(type
), type
, entry
->name
,
1140 brcmf_fws_lock(fws
);
1141 if (type
== BRCMF_FWS_TYPE_MAC_REQUEST_CREDIT
)
1142 entry
->requested_credit
= data
[0];
1144 entry
->requested_packet
= data
[0];
1146 entry
->ac_bitmap
= data
[2];
1147 brcmf_fws_unlock(fws
);
1148 return BRCMF_FWS_RET_OK_SCHEDULE
;
1152 brcmf_fws_macdesc_use_req_credit(struct brcmf_fws_mac_descriptor
*entry
,
1153 struct sk_buff
*skb
)
1155 if (entry
->requested_credit
> 0) {
1156 entry
->requested_credit
--;
1157 brcmf_skb_if_flags_set_field(skb
, REQUESTED
, 1);
1158 brcmf_skb_if_flags_set_field(skb
, REQ_CREDIT
, 1);
1159 if (entry
->state
!= BRCMF_FWS_STATE_CLOSE
)
1160 brcmf_err("requested credit set while mac not closed!\n");
1161 } else if (entry
->requested_packet
> 0) {
1162 entry
->requested_packet
--;
1163 brcmf_skb_if_flags_set_field(skb
, REQUESTED
, 1);
1164 brcmf_skb_if_flags_set_field(skb
, REQ_CREDIT
, 0);
1165 if (entry
->state
!= BRCMF_FWS_STATE_CLOSE
)
1166 brcmf_err("requested packet set while mac not closed!\n");
1168 brcmf_skb_if_flags_set_field(skb
, REQUESTED
, 0);
1169 brcmf_skb_if_flags_set_field(skb
, REQ_CREDIT
, 0);
1173 static void brcmf_fws_macdesc_return_req_credit(struct sk_buff
*skb
)
1175 struct brcmf_fws_mac_descriptor
*entry
= brcmf_skbcb(skb
)->mac
;
1177 if ((brcmf_skb_if_flags_get_field(skb
, REQ_CREDIT
)) &&
1178 (entry
->state
== BRCMF_FWS_STATE_CLOSE
))
1179 entry
->requested_credit
++;
1182 static void brcmf_fws_return_credits(struct brcmf_fws_info
*fws
,
1183 u8 fifo
, u8 credits
)
1192 fws
->fifo_credit_map
|= 1 << fifo
;
1194 if (fifo
> BRCMF_FWS_FIFO_AC_BK
&&
1195 fifo
<= BRCMF_FWS_FIFO_AC_VO
) {
1196 for (lender_ac
= BRCMF_FWS_FIFO_AC_VO
; lender_ac
>= 0;
1198 borrowed
= &fws
->credits_borrowed
[fifo
][lender_ac
];
1200 fws
->fifo_credit_map
|= (1 << lender_ac
);
1201 fifo_credit
= &fws
->fifo_credit
[lender_ac
];
1202 if (*borrowed
>= credits
) {
1203 *borrowed
-= credits
;
1204 *fifo_credit
+= credits
;
1207 credits
-= *borrowed
;
1208 *fifo_credit
+= *borrowed
;
1216 fws
->fifo_credit
[fifo
] += credits
;
1219 if (fws
->fifo_credit
[fifo
] > fws
->init_fifo_credit
[fifo
])
1220 fws
->fifo_credit
[fifo
] = fws
->init_fifo_credit
[fifo
];
1224 static void brcmf_fws_schedule_deq(struct brcmf_fws_info
*fws
)
1226 /* only schedule dequeue when there are credits for delayed traffic */
1227 if ((fws
->fifo_credit_map
& fws
->fifo_delay_map
) ||
1228 (!brcmf_fws_fc_active(fws
) && fws
->fifo_delay_map
))
1229 queue_work(fws
->fws_wq
, &fws
->fws_dequeue_work
);
1232 static int brcmf_fws_enq(struct brcmf_fws_info
*fws
,
1233 enum brcmf_fws_skb_state state
, int fifo
,
1236 struct brcmf_pub
*drvr
= fws
->drvr
;
1237 int prec
= 2 * fifo
;
1238 u32
*qfull_stat
= &fws
->stats
.delayq_full_error
;
1239 struct brcmf_fws_mac_descriptor
*entry
;
1241 struct sk_buff_head
*queue
;
1242 struct sk_buff
*p_head
;
1243 struct sk_buff
*p_tail
;
1247 entry
= brcmf_skbcb(p
)->mac
;
1248 if (entry
== NULL
) {
1249 bphy_err(drvr
, "no mac descriptor found for skb %p\n", p
);
1253 brcmf_dbg(DATA
, "enter: fifo %d skb %p\n", fifo
, p
);
1254 if (state
== BRCMF_FWS_SKBSTATE_SUPPRESSED
) {
1256 qfull_stat
= &fws
->stats
.supprq_full_error
;
1258 /* Fix out of order delivery of frames. Dont assume frame */
1259 /* can be inserted at the end, but look for correct position */
1261 if (pktq_full(pq
) || pktq_pfull(pq
, prec
)) {
1265 queue
= &pq
->q
[prec
].skblist
;
1267 p_head
= skb_peek(queue
);
1268 p_tail
= skb_peek_tail(queue
);
1269 fr_new
= brcmf_skb_htod_tag_get_field(p
, FREERUN
);
1271 while (p_head
!= p_tail
) {
1272 fr_compare
= brcmf_skb_htod_tag_get_field(p_tail
,
1274 /* be sure to handle wrap of 256 */
1275 if (((fr_new
> fr_compare
) &&
1276 ((fr_new
- fr_compare
) < 128)) ||
1277 ((fr_new
< fr_compare
) &&
1278 ((fr_compare
- fr_new
) > 128)))
1280 p_tail
= skb_queue_prev(queue
, p_tail
);
1282 /* Position found. Determine what to do */
1283 if (p_tail
== NULL
) {
1285 __skb_queue_tail(queue
, p
);
1287 fr_compare
= brcmf_skb_htod_tag_get_field(p_tail
,
1289 if (((fr_new
> fr_compare
) &&
1290 ((fr_new
- fr_compare
) < 128)) ||
1291 ((fr_new
< fr_compare
) &&
1292 ((fr_compare
- fr_new
) > 128))) {
1294 __skb_queue_after(queue
, p_tail
, p
);
1297 __skb_insert(p
, p_tail
->prev
, p_tail
, queue
);
1301 /* Complete the counters and statistics */
1303 if (pq
->hi_prec
< prec
)
1304 pq
->hi_prec
= (u8
) prec
;
1305 } else if (brcmu_pktq_penq(&entry
->psq
, prec
, p
) == NULL
) {
1310 /* increment total enqueued packet count */
1311 fws
->fifo_delay_map
|= 1 << fifo
;
1312 fws
->fifo_enqpkt
[fifo
]++;
1314 /* update the sk_buff state */
1315 brcmf_skbcb(p
)->state
= state
;
1318 * A packet has been pushed so update traffic
1319 * availability bitmap, if applicable
1321 brcmf_fws_tim_update(fws
, entry
, fifo
, true);
1322 brcmf_fws_flow_control_check(fws
, &entry
->psq
,
1323 brcmf_skb_if_flags_get_field(p
, INDEX
));
1327 static struct sk_buff
*brcmf_fws_deq(struct brcmf_fws_info
*fws
, int fifo
)
1329 struct brcmf_fws_mac_descriptor
*table
;
1330 struct brcmf_fws_mac_descriptor
*entry
;
1338 table
= (struct brcmf_fws_mac_descriptor
*)&fws
->desc
;
1339 num_nodes
= sizeof(fws
->desc
) / sizeof(struct brcmf_fws_mac_descriptor
);
1340 node_pos
= fws
->deq_node_pos
[fifo
];
1342 for (i
= 0; i
< num_nodes
; i
++) {
1343 entry
= &table
[(node_pos
+ i
) % num_nodes
];
1344 if (!entry
->occupied
||
1345 brcmf_fws_macdesc_closed(fws
, entry
, fifo
))
1348 if (entry
->suppressed
)
1352 p
= brcmu_pktq_mdeq(&entry
->psq
, pmsk
<< (fifo
* 2), &prec_out
);
1354 if (entry
->suppressed
) {
1355 if (entry
->suppr_transit_count
)
1357 entry
->suppressed
= false;
1358 p
= brcmu_pktq_mdeq(&entry
->psq
,
1359 1 << (fifo
* 2), &prec_out
);
1365 brcmf_fws_macdesc_use_req_credit(entry
, p
);
1367 /* move dequeue position to ensure fair round-robin */
1368 fws
->deq_node_pos
[fifo
] = (node_pos
+ i
+ 1) % num_nodes
;
1369 brcmf_fws_flow_control_check(fws
, &entry
->psq
,
1370 brcmf_skb_if_flags_get_field(p
,
1374 * A packet has been picked up, update traffic
1375 * availability bitmap, if applicable
1377 brcmf_fws_tim_update(fws
, entry
, fifo
, false);
1380 * decrement total enqueued fifo packets and
1381 * clear delay bitmap if done.
1383 fws
->fifo_enqpkt
[fifo
]--;
1384 if (fws
->fifo_enqpkt
[fifo
] == 0)
1385 fws
->fifo_delay_map
&= ~(1 << fifo
);
1390 brcmf_dbg(DATA
, "exit: fifo %d skb %p\n", fifo
, p
);
1394 static int brcmf_fws_txstatus_suppressed(struct brcmf_fws_info
*fws
, int fifo
,
1395 struct sk_buff
*skb
,
1396 u32 genbit
, u16 seq
)
1398 struct brcmf_fws_mac_descriptor
*entry
= brcmf_skbcb(skb
)->mac
;
1402 hslot
= brcmf_skb_htod_tag_get_field(skb
, HSLOT
);
1404 /* this packet was suppressed */
1405 if (!entry
->suppressed
) {
1406 entry
->suppressed
= true;
1407 entry
->suppr_transit_count
= entry
->transit_count
;
1408 brcmf_dbg(DATA
, "suppress %s: transit %d\n",
1409 entry
->name
, entry
->transit_count
);
1412 entry
->generation
= genbit
;
1414 brcmf_skb_htod_tag_set_field(skb
, GENERATION
, genbit
);
1415 brcmf_skbcb(skb
)->htod_seq
= seq
;
1416 if (brcmf_skb_htod_seq_get_field(skb
, FROMFW
)) {
1417 brcmf_skb_htod_seq_set_field(skb
, FROMDRV
, 1);
1418 brcmf_skb_htod_seq_set_field(skb
, FROMFW
, 0);
1420 brcmf_skb_htod_seq_set_field(skb
, FROMDRV
, 0);
1422 ret
= brcmf_fws_enq(fws
, BRCMF_FWS_SKBSTATE_SUPPRESSED
, fifo
, skb
);
1425 /* suppress q is full drop this packet */
1426 brcmf_fws_hanger_poppkt(&fws
->hanger
, hslot
, &skb
, true);
1428 /* Mark suppressed to avoid a double free during wlfc cleanup */
1429 brcmf_fws_hanger_mark_suppressed(&fws
->hanger
, hslot
);
1436 brcmf_fws_txs_process(struct brcmf_fws_info
*fws
, u8 flags
, u32 hslot
,
1437 u32 genbit
, u16 seq
, u8 compcnt
)
1439 struct brcmf_pub
*drvr
= fws
->drvr
;
1443 bool remove_from_hanger
= true;
1444 struct sk_buff
*skb
;
1445 struct brcmf_skbuff_cb
*skcb
;
1446 struct brcmf_fws_mac_descriptor
*entry
= NULL
;
1447 struct brcmf_if
*ifp
;
1449 brcmf_dbg(DATA
, "flags %d\n", flags
);
1451 if (flags
== BRCMF_FWS_TXSTATUS_DISCARD
)
1452 fws
->stats
.txs_discard
+= compcnt
;
1453 else if (flags
== BRCMF_FWS_TXSTATUS_CORE_SUPPRESS
) {
1454 fws
->stats
.txs_supp_core
+= compcnt
;
1455 remove_from_hanger
= false;
1456 } else if (flags
== BRCMF_FWS_TXSTATUS_FW_PS_SUPPRESS
) {
1457 fws
->stats
.txs_supp_ps
+= compcnt
;
1458 remove_from_hanger
= false;
1459 } else if (flags
== BRCMF_FWS_TXSTATUS_FW_TOSSED
)
1460 fws
->stats
.txs_tossed
+= compcnt
;
1461 else if (flags
== BRCMF_FWS_TXSTATUS_FW_DISCARD_NOACK
)
1462 fws
->stats
.txs_discard
+= compcnt
;
1463 else if (flags
== BRCMF_FWS_TXSTATUS_FW_SUPPRESS_ACKED
)
1464 fws
->stats
.txs_discard
+= compcnt
;
1465 else if (flags
== BRCMF_FWS_TXSTATUS_HOST_TOSSED
)
1466 fws
->stats
.txs_host_tossed
+= compcnt
;
1468 bphy_err(drvr
, "unexpected txstatus\n");
1470 while (cnt
< compcnt
) {
1471 ret
= brcmf_fws_hanger_poppkt(&fws
->hanger
, hslot
, &skb
,
1472 remove_from_hanger
);
1474 bphy_err(drvr
, "no packet in hanger slot: hslot=%d\n",
1479 skcb
= brcmf_skbcb(skb
);
1481 if (WARN_ON(!entry
)) {
1482 brcmu_pkt_buf_free_skb(skb
);
1485 entry
->transit_count
--;
1486 if (entry
->suppressed
&& entry
->suppr_transit_count
)
1487 entry
->suppr_transit_count
--;
1489 brcmf_dbg(DATA
, "%s flags %d htod %X seq %X\n", entry
->name
,
1490 flags
, skcb
->htod
, seq
);
1492 /* pick up the implicit credit from this packet */
1493 fifo
= brcmf_skb_htod_tag_get_field(skb
, FIFO
);
1494 if (fws
->fcmode
== BRCMF_FWS_FCMODE_IMPLIED_CREDIT
||
1495 (brcmf_skb_if_flags_get_field(skb
, REQ_CREDIT
)) ||
1496 flags
== BRCMF_FWS_TXSTATUS_HOST_TOSSED
) {
1497 brcmf_fws_return_credits(fws
, fifo
, 1);
1498 brcmf_fws_schedule_deq(fws
);
1500 brcmf_fws_macdesc_return_req_credit(skb
);
1502 ret
= brcmf_proto_hdrpull(fws
->drvr
, false, skb
, &ifp
);
1504 brcmu_pkt_buf_free_skb(skb
);
1507 if (!remove_from_hanger
)
1508 ret
= brcmf_fws_txstatus_suppressed(fws
, fifo
, skb
,
1510 if (remove_from_hanger
|| ret
)
1511 brcmf_txfinalize(ifp
, skb
, true);
1514 hslot
= (hslot
+ 1) & (BRCMF_FWS_TXSTAT_HSLOT_MASK
>>
1515 BRCMF_FWS_TXSTAT_HSLOT_SHIFT
);
1516 if (BRCMF_FWS_MODE_GET_REUSESEQ(fws
->mode
))
1517 seq
= (seq
+ 1) & BRCMF_SKB_HTOD_SEQ_NR_MASK
;
1525 static int brcmf_fws_fifocreditback_indicate(struct brcmf_fws_info
*fws
,
1530 if (fws
->fcmode
!= BRCMF_FWS_FCMODE_EXPLICIT_CREDIT
) {
1531 brcmf_dbg(INFO
, "ignored\n");
1532 return BRCMF_FWS_RET_OK_NOSCHEDULE
;
1535 brcmf_dbg(DATA
, "enter: data %pM\n", data
);
1536 brcmf_fws_lock(fws
);
1537 for (i
= 0; i
< BRCMF_FWS_FIFO_COUNT
; i
++)
1538 brcmf_fws_return_credits(fws
, i
, data
[i
]);
1540 brcmf_dbg(DATA
, "map: credit %x delay %x\n", fws
->fifo_credit_map
,
1541 fws
->fifo_delay_map
);
1542 brcmf_fws_unlock(fws
);
1543 return BRCMF_FWS_RET_OK_SCHEDULE
;
1546 static int brcmf_fws_txstatus_indicate(struct brcmf_fws_info
*fws
, u8 type
,
1557 u8 compcnt_offset
= BRCMF_FWS_TYPE_TXSTATUS_LEN
;
1559 memcpy(&status_le
, data
, sizeof(status_le
));
1560 status
= le32_to_cpu(status_le
);
1561 flags
= brcmf_txstatus_get_field(status
, FLAGS
);
1562 hslot
= brcmf_txstatus_get_field(status
, HSLOT
);
1563 genbit
= brcmf_txstatus_get_field(status
, GENERATION
);
1564 if (BRCMF_FWS_MODE_GET_REUSESEQ(fws
->mode
)) {
1565 memcpy(&seq_le
, &data
[BRCMF_FWS_TYPE_TXSTATUS_LEN
],
1567 seq
= le16_to_cpu(seq_le
);
1568 compcnt_offset
+= BRCMF_FWS_TYPE_SEQ_LEN
;
1573 if (type
== BRCMF_FWS_TYPE_COMP_TXSTATUS
)
1574 compcnt
= data
[compcnt_offset
];
1577 fws
->stats
.txs_indicate
+= compcnt
;
1579 brcmf_fws_lock(fws
);
1580 brcmf_fws_txs_process(fws
, flags
, hslot
, genbit
, seq
, compcnt
);
1581 brcmf_fws_unlock(fws
);
1582 return BRCMF_FWS_RET_OK_NOSCHEDULE
;
1585 static int brcmf_fws_dbg_seqnum_check(struct brcmf_fws_info
*fws
, u8
*data
)
1589 memcpy(×tamp
, &data
[2], sizeof(timestamp
));
1590 brcmf_dbg(CTL
, "received: seq %d, timestamp %d\n", data
[1],
1591 le32_to_cpu(timestamp
));
1595 static int brcmf_fws_notify_credit_map(struct brcmf_if
*ifp
,
1596 const struct brcmf_event_msg
*e
,
1599 struct brcmf_pub
*drvr
= ifp
->drvr
;
1600 struct brcmf_fws_info
*fws
= drvr_to_fws(drvr
);
1604 if (e
->datalen
< BRCMF_FWS_FIFO_COUNT
) {
1605 bphy_err(drvr
, "event payload too small (%d)\n", e
->datalen
);
1609 fws
->creditmap_received
= true;
1611 brcmf_dbg(TRACE
, "enter: credits %pM\n", credits
);
1612 brcmf_fws_lock(fws
);
1613 for (i
= 0; i
< ARRAY_SIZE(fws
->fifo_credit
); i
++) {
1614 fws
->fifo_credit
[i
] += credits
[i
] - fws
->init_fifo_credit
[i
];
1615 fws
->init_fifo_credit
[i
] = credits
[i
];
1616 if (fws
->fifo_credit
[i
] > 0)
1617 fws
->fifo_credit_map
|= 1 << i
;
1619 fws
->fifo_credit_map
&= ~(1 << i
);
1620 WARN_ONCE(fws
->fifo_credit
[i
] < 0,
1621 "fifo_credit[%d] is negative(%d)\n", i
,
1622 fws
->fifo_credit
[i
]);
1624 brcmf_fws_schedule_deq(fws
);
1625 brcmf_fws_unlock(fws
);
1629 static int brcmf_fws_notify_bcmc_credit_support(struct brcmf_if
*ifp
,
1630 const struct brcmf_event_msg
*e
,
1633 struct brcmf_fws_info
*fws
= drvr_to_fws(ifp
->drvr
);
1636 brcmf_fws_lock(fws
);
1637 fws
->bcmc_credit_check
= true;
1638 brcmf_fws_unlock(fws
);
1643 static void brcmf_rxreorder_get_skb_list(struct brcmf_ampdu_rx_reorder
*rfi
,
1645 struct sk_buff_head
*skb_list
)
1647 /* initialize return list */
1648 __skb_queue_head_init(skb_list
);
1650 if (rfi
->pend_pkts
== 0) {
1651 brcmf_dbg(INFO
, "no packets in reorder queue\n");
1656 if (rfi
->pktslots
[start
]) {
1657 __skb_queue_tail(skb_list
, rfi
->pktslots
[start
]);
1658 rfi
->pktslots
[start
] = NULL
;
1661 if (start
> rfi
->max_idx
)
1663 } while (start
!= end
);
1664 rfi
->pend_pkts
-= skb_queue_len(skb_list
);
1667 void brcmf_fws_rxreorder(struct brcmf_if
*ifp
, struct sk_buff
*pkt
)
1669 struct brcmf_pub
*drvr
= ifp
->drvr
;
1671 u8 flow_id
, max_idx
, cur_idx
, exp_idx
, end_idx
;
1672 struct brcmf_ampdu_rx_reorder
*rfi
;
1673 struct sk_buff_head reorder_list
;
1674 struct sk_buff
*pnext
;
1677 reorder_data
= ((struct brcmf_skb_reorder_data
*)pkt
->cb
)->reorder
;
1678 flow_id
= reorder_data
[BRCMF_RXREORDER_FLOWID_OFFSET
];
1679 flags
= reorder_data
[BRCMF_RXREORDER_FLAGS_OFFSET
];
1681 /* validate flags and flow id */
1682 if (flags
== 0xFF) {
1683 bphy_err(drvr
, "invalid flags...so ignore this packet\n");
1684 brcmf_netif_rx(ifp
, pkt
);
1688 rfi
= ifp
->drvr
->reorder_flows
[flow_id
];
1689 if (flags
& BRCMF_RXREORDER_DEL_FLOW
) {
1690 brcmf_dbg(INFO
, "flow-%d: delete\n",
1694 brcmf_dbg(INFO
, "received flags to cleanup, but no flow (%d) yet\n",
1696 brcmf_netif_rx(ifp
, pkt
);
1700 brcmf_rxreorder_get_skb_list(rfi
, rfi
->exp_idx
, rfi
->exp_idx
,
1702 /* add the last packet */
1703 __skb_queue_tail(&reorder_list
, pkt
);
1705 ifp
->drvr
->reorder_flows
[flow_id
] = NULL
;
1708 /* from here on we need a flow reorder instance */
1710 max_idx
= reorder_data
[BRCMF_RXREORDER_MAXIDX_OFFSET
];
1712 /* allocate space for flow reorder info */
1713 brcmf_dbg(INFO
, "flow-%d: start, maxidx %d\n",
1715 rfi
= kzalloc(struct_size(rfi
, pktslots
, max_idx
+ 1),
1718 bphy_err(drvr
, "failed to alloc buffer\n");
1719 brcmf_netif_rx(ifp
, pkt
);
1723 ifp
->drvr
->reorder_flows
[flow_id
] = rfi
;
1724 rfi
->max_idx
= max_idx
;
1726 if (flags
& BRCMF_RXREORDER_NEW_HOLE
) {
1727 if (rfi
->pend_pkts
) {
1728 brcmf_rxreorder_get_skb_list(rfi
, rfi
->exp_idx
,
1731 WARN_ON(rfi
->pend_pkts
);
1733 __skb_queue_head_init(&reorder_list
);
1735 rfi
->cur_idx
= reorder_data
[BRCMF_RXREORDER_CURIDX_OFFSET
];
1736 rfi
->exp_idx
= reorder_data
[BRCMF_RXREORDER_EXPIDX_OFFSET
];
1737 rfi
->max_idx
= reorder_data
[BRCMF_RXREORDER_MAXIDX_OFFSET
];
1738 rfi
->pktslots
[rfi
->cur_idx
] = pkt
;
1740 brcmf_dbg(DATA
, "flow-%d: new hole %d (%d), pending %d\n",
1741 flow_id
, rfi
->cur_idx
, rfi
->exp_idx
, rfi
->pend_pkts
);
1742 } else if (flags
& BRCMF_RXREORDER_CURIDX_VALID
) {
1743 cur_idx
= reorder_data
[BRCMF_RXREORDER_CURIDX_OFFSET
];
1744 exp_idx
= reorder_data
[BRCMF_RXREORDER_EXPIDX_OFFSET
];
1746 if ((exp_idx
== rfi
->exp_idx
) && (cur_idx
!= rfi
->exp_idx
)) {
1747 /* still in the current hole */
1748 /* enqueue the current on the buffer chain */
1749 if (rfi
->pktslots
[cur_idx
] != NULL
) {
1750 brcmf_dbg(INFO
, "HOLE: ERROR buffer pending..free it\n");
1751 brcmu_pkt_buf_free_skb(rfi
->pktslots
[cur_idx
]);
1752 rfi
->pktslots
[cur_idx
] = NULL
;
1754 rfi
->pktslots
[cur_idx
] = pkt
;
1756 rfi
->cur_idx
= cur_idx
;
1757 brcmf_dbg(DATA
, "flow-%d: store pkt %d (%d), pending %d\n",
1758 flow_id
, cur_idx
, exp_idx
, rfi
->pend_pkts
);
1760 /* can return now as there is no reorder
1765 if (rfi
->exp_idx
== cur_idx
) {
1766 if (rfi
->pktslots
[cur_idx
] != NULL
) {
1767 brcmf_dbg(INFO
, "error buffer pending..free it\n");
1768 brcmu_pkt_buf_free_skb(rfi
->pktslots
[cur_idx
]);
1769 rfi
->pktslots
[cur_idx
] = NULL
;
1771 rfi
->pktslots
[cur_idx
] = pkt
;
1774 /* got the expected one. flush from current to expected
1775 * and update expected
1777 brcmf_dbg(DATA
, "flow-%d: expected %d (%d), pending %d\n",
1778 flow_id
, cur_idx
, exp_idx
, rfi
->pend_pkts
);
1780 rfi
->cur_idx
= cur_idx
;
1781 rfi
->exp_idx
= exp_idx
;
1783 brcmf_rxreorder_get_skb_list(rfi
, cur_idx
, exp_idx
,
1785 brcmf_dbg(DATA
, "flow-%d: freeing buffers %d, pending %d\n",
1786 flow_id
, skb_queue_len(&reorder_list
),
1791 brcmf_dbg(DATA
, "flow-%d (0x%x): both moved, old %d/%d, new %d/%d\n",
1792 flow_id
, flags
, rfi
->cur_idx
, rfi
->exp_idx
,
1794 if (flags
& BRCMF_RXREORDER_FLUSH_ALL
)
1795 end_idx
= rfi
->exp_idx
;
1799 /* flush pkts first */
1800 brcmf_rxreorder_get_skb_list(rfi
, rfi
->exp_idx
, end_idx
,
1803 if (exp_idx
== ((cur_idx
+ 1) % (rfi
->max_idx
+ 1))) {
1804 __skb_queue_tail(&reorder_list
, pkt
);
1806 rfi
->pktslots
[cur_idx
] = pkt
;
1809 rfi
->exp_idx
= exp_idx
;
1810 rfi
->cur_idx
= cur_idx
;
1813 /* explicity window move updating the expected index */
1814 exp_idx
= reorder_data
[BRCMF_RXREORDER_EXPIDX_OFFSET
];
1816 brcmf_dbg(DATA
, "flow-%d (0x%x): change expected: %d -> %d\n",
1817 flow_id
, flags
, rfi
->exp_idx
, exp_idx
);
1818 if (flags
& BRCMF_RXREORDER_FLUSH_ALL
)
1819 end_idx
= rfi
->exp_idx
;
1823 brcmf_rxreorder_get_skb_list(rfi
, rfi
->exp_idx
, end_idx
,
1825 __skb_queue_tail(&reorder_list
, pkt
);
1826 /* set the new expected idx */
1827 rfi
->exp_idx
= exp_idx
;
1830 skb_queue_walk_safe(&reorder_list
, pkt
, pnext
) {
1831 __skb_unlink(pkt
, &reorder_list
);
1832 brcmf_netif_rx(ifp
, pkt
);
1836 void brcmf_fws_hdrpull(struct brcmf_if
*ifp
, s16 siglen
, struct sk_buff
*skb
)
1838 struct brcmf_skb_reorder_data
*rd
;
1839 struct brcmf_fws_info
*fws
= drvr_to_fws(ifp
->drvr
);
1848 brcmf_dbg(HDRS
, "enter: ifidx %d, skblen %u, sig %d\n",
1849 ifp
->ifidx
, skb
->len
, siglen
);
1851 WARN_ON(siglen
> skb
->len
);
1853 if (siglen
> skb
->len
)
1858 /* if flow control disabled, skip to packet data and leave */
1859 if ((!fws
) || (!fws
->fw_signals
)) {
1860 skb_pull(skb
, siglen
);
1864 fws
->stats
.header_pulls
++;
1866 signal_data
= skb
->data
;
1868 status
= BRCMF_FWS_RET_OK_NOSCHEDULE
;
1869 while (data_len
> 0) {
1870 /* extract tlv info */
1871 type
= signal_data
[0];
1873 /* FILLER type is actually not a TLV, but
1874 * a single byte that can be skipped.
1876 if (type
== BRCMF_FWS_TYPE_FILLER
) {
1881 len
= signal_data
[1];
1882 data
= signal_data
+ 2;
1884 brcmf_dbg(HDRS
, "tlv type=%s (%d), len=%d (%d)\n",
1885 brcmf_fws_get_tlv_name(type
), type
, len
,
1886 brcmf_fws_get_tlv_len(fws
, type
));
1888 /* abort parsing when length invalid */
1889 if (data_len
< len
+ 2)
1892 if (len
< brcmf_fws_get_tlv_len(fws
, type
))
1895 err
= BRCMF_FWS_RET_OK_NOSCHEDULE
;
1897 case BRCMF_FWS_TYPE_HOST_REORDER_RXPKTS
:
1898 rd
= (struct brcmf_skb_reorder_data
*)skb
->cb
;
1901 case BRCMF_FWS_TYPE_MACDESC_ADD
:
1902 case BRCMF_FWS_TYPE_MACDESC_DEL
:
1903 brcmf_fws_macdesc_indicate(fws
, type
, data
);
1905 case BRCMF_FWS_TYPE_MAC_OPEN
:
1906 case BRCMF_FWS_TYPE_MAC_CLOSE
:
1907 err
= brcmf_fws_macdesc_state_indicate(fws
, type
, data
);
1909 case BRCMF_FWS_TYPE_INTERFACE_OPEN
:
1910 case BRCMF_FWS_TYPE_INTERFACE_CLOSE
:
1911 err
= brcmf_fws_interface_state_indicate(fws
, type
,
1914 case BRCMF_FWS_TYPE_MAC_REQUEST_CREDIT
:
1915 case BRCMF_FWS_TYPE_MAC_REQUEST_PACKET
:
1916 err
= brcmf_fws_request_indicate(fws
, type
, data
);
1918 case BRCMF_FWS_TYPE_TXSTATUS
:
1919 case BRCMF_FWS_TYPE_COMP_TXSTATUS
:
1920 brcmf_fws_txstatus_indicate(fws
, type
, data
);
1922 case BRCMF_FWS_TYPE_FIFO_CREDITBACK
:
1923 err
= brcmf_fws_fifocreditback_indicate(fws
, data
);
1925 case BRCMF_FWS_TYPE_RSSI
:
1926 brcmf_fws_rssi_indicate(fws
, *data
);
1928 case BRCMF_FWS_TYPE_TRANS_ID
:
1929 brcmf_fws_dbg_seqnum_check(fws
, data
);
1931 case BRCMF_FWS_TYPE_PKTTAG
:
1932 case BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP
:
1934 fws
->stats
.tlv_invalid_type
++;
1937 if (err
== BRCMF_FWS_RET_OK_SCHEDULE
)
1938 status
= BRCMF_FWS_RET_OK_SCHEDULE
;
1939 signal_data
+= len
+ 2;
1940 data_len
-= len
+ 2;
1944 fws
->stats
.tlv_parse_failed
++;
1946 if (status
== BRCMF_FWS_RET_OK_SCHEDULE
)
1947 brcmf_fws_schedule_deq(fws
);
1949 /* signalling processing result does
1950 * not affect the actual ethernet packet.
1952 skb_pull(skb
, siglen
);
1954 /* this may be a signal-only packet
1957 fws
->stats
.header_only_pkt
++;
1960 static u8
brcmf_fws_precommit_skb(struct brcmf_fws_info
*fws
, int fifo
,
1963 struct brcmf_skbuff_cb
*skcb
= brcmf_skbcb(p
);
1964 struct brcmf_fws_mac_descriptor
*entry
= skcb
->mac
;
1967 if (skcb
->state
!= BRCMF_FWS_SKBSTATE_SUPPRESSED
)
1968 brcmf_skb_htod_tag_set_field(p
, GENERATION
, entry
->generation
);
1969 flags
= BRCMF_FWS_HTOD_FLAG_PKTFROMHOST
;
1970 if (brcmf_skb_if_flags_get_field(p
, REQUESTED
)) {
1972 * Indicate that this packet is being sent in response to an
1973 * explicit request from the firmware side.
1975 flags
|= BRCMF_FWS_HTOD_FLAG_PKT_REQUESTED
;
1977 brcmf_skb_htod_tag_set_field(p
, FLAGS
, flags
);
1978 return brcmf_fws_hdrpush(fws
, p
);
1981 static void brcmf_fws_rollback_toq(struct brcmf_fws_info
*fws
,
1982 struct sk_buff
*skb
, int fifo
)
1984 struct brcmf_pub
*drvr
= fws
->drvr
;
1985 struct brcmf_fws_mac_descriptor
*entry
;
1986 struct sk_buff
*pktout
;
1990 entry
= brcmf_skbcb(skb
)->mac
;
1991 if (entry
->occupied
) {
1993 if (brcmf_skbcb(skb
)->state
== BRCMF_FWS_SKBSTATE_SUPPRESSED
)
1996 pktout
= brcmu_pktq_penq_head(&entry
->psq
, qidx
, skb
);
1997 if (pktout
== NULL
) {
1998 bphy_err(drvr
, "%s queue %d full\n", entry
->name
, qidx
);
2002 bphy_err(drvr
, "%s entry removed\n", entry
->name
);
2007 fws
->stats
.rollback_failed
++;
2008 hslot
= brcmf_skb_htod_tag_get_field(skb
, HSLOT
);
2009 brcmf_fws_txs_process(fws
, BRCMF_FWS_TXSTATUS_HOST_TOSSED
,
2012 fws
->stats
.rollback_success
++;
2013 brcmf_fws_return_credits(fws
, fifo
, 1);
2014 brcmf_fws_macdesc_return_req_credit(skb
);
2018 static int brcmf_fws_borrow_credit(struct brcmf_fws_info
*fws
,
2019 int highest_lender_ac
, int borrower_ac
,
2022 int lender_ac
, borrow_limit
= 0;
2024 for (lender_ac
= 0; lender_ac
<= highest_lender_ac
; lender_ac
++) {
2028 fws
->init_fifo_credit
[lender_ac
] / BRCMF_BORROW_RATIO
;
2032 if (fws
->fifo_credit
[lender_ac
] > borrow_limit
) {
2033 fws
->credits_borrowed
[borrower_ac
][lender_ac
]++;
2034 fws
->fifo_credit
[lender_ac
]--;
2035 if (fws
->fifo_credit
[lender_ac
] == 0)
2036 fws
->fifo_credit_map
&= ~(1 << lender_ac
);
2037 fws
->fifo_credit_map
|= (1 << borrower_ac
);
2038 brcmf_dbg(DATA
, "borrow credit from: %d\n", lender_ac
);
2042 fws
->fifo_credit_map
&= ~(1 << borrower_ac
);
2046 static int brcmf_fws_commit_skb(struct brcmf_fws_info
*fws
, int fifo
,
2047 struct sk_buff
*skb
)
2049 struct brcmf_skbuff_cb
*skcb
= brcmf_skbcb(skb
);
2050 struct brcmf_fws_mac_descriptor
*entry
;
2057 return PTR_ERR(entry
);
2059 data_offset
= brcmf_fws_precommit_skb(fws
, fifo
, skb
);
2060 entry
->transit_count
++;
2061 if (entry
->suppressed
)
2062 entry
->suppr_transit_count
++;
2063 ifidx
= brcmf_skb_if_flags_get_field(skb
, INDEX
);
2064 brcmf_fws_unlock(fws
);
2065 rc
= brcmf_proto_txdata(fws
->drvr
, ifidx
, data_offset
, skb
);
2066 brcmf_fws_lock(fws
);
2067 brcmf_dbg(DATA
, "%s flags %X htod %X bus_tx %d\n", entry
->name
,
2068 skcb
->if_flags
, skcb
->htod
, rc
);
2070 entry
->transit_count
--;
2071 if (entry
->suppressed
)
2072 entry
->suppr_transit_count
--;
2073 (void)brcmf_proto_hdrpull(fws
->drvr
, false, skb
, NULL
);
2077 fws
->stats
.pkt2bus
++;
2078 fws
->stats
.send_pkts
[fifo
]++;
2079 if (brcmf_skb_if_flags_get_field(skb
, REQUESTED
))
2080 fws
->stats
.requested_sent
[fifo
]++;
2085 brcmf_fws_rollback_toq(fws
, skb
, fifo
);
2089 static int brcmf_fws_assign_htod(struct brcmf_fws_info
*fws
, struct sk_buff
*p
,
2092 struct brcmf_skbuff_cb
*skcb
= brcmf_skbcb(p
);
2097 hslot
= brcmf_fws_hanger_get_free_slot(&fws
->hanger
);
2098 brcmf_skb_htod_tag_set_field(p
, HSLOT
, hslot
);
2099 brcmf_skb_htod_tag_set_field(p
, FREERUN
, skcb
->mac
->seq
[fifo
]);
2100 brcmf_skb_htod_tag_set_field(p
, FIFO
, fifo
);
2101 rc
= brcmf_fws_hanger_pushpkt(&fws
->hanger
, p
, hslot
);
2103 skcb
->mac
->seq
[fifo
]++;
2105 fws
->stats
.generic_error
++;
2109 int brcmf_fws_process_skb(struct brcmf_if
*ifp
, struct sk_buff
*skb
)
2111 struct brcmf_pub
*drvr
= ifp
->drvr
;
2112 struct brcmf_fws_info
*fws
= drvr_to_fws(drvr
);
2113 struct brcmf_skbuff_cb
*skcb
= brcmf_skbcb(skb
);
2114 struct ethhdr
*eh
= (struct ethhdr
*)(skb
->data
);
2115 int fifo
= BRCMF_FWS_FIFO_BCMC
;
2116 bool multicast
= is_multicast_ether_addr(eh
->h_dest
);
2119 brcmf_dbg(DATA
, "tx proto=0x%X\n", ntohs(eh
->h_proto
));
2121 /* set control buffer information */
2123 skcb
->state
= BRCMF_FWS_SKBSTATE_NEW
;
2124 brcmf_skb_if_flags_set_field(skb
, INDEX
, ifp
->ifidx
);
2126 /* mapping from 802.1d priority to firmware fifo index */
2128 fifo
= brcmf_map_prio_to_aci(drvr
->config
, skb
->priority
);
2130 brcmf_fws_lock(fws
);
2131 if (fifo
!= BRCMF_FWS_FIFO_AC_BE
&& fifo
< BRCMF_FWS_FIFO_BCMC
)
2132 fws
->borrow_defer_timestamp
= jiffies
+
2133 BRCMF_FWS_BORROW_DEFER_PERIOD
;
2135 skcb
->mac
= brcmf_fws_macdesc_find(fws
, ifp
, eh
->h_dest
);
2136 brcmf_dbg(DATA
, "%s mac %pM multi %d fifo %d\n", skcb
->mac
->name
,
2137 eh
->h_dest
, multicast
, fifo
);
2138 if (!brcmf_fws_assign_htod(fws
, skb
, fifo
)) {
2139 brcmf_fws_enq(fws
, BRCMF_FWS_SKBSTATE_DELAYED
, fifo
, skb
);
2140 brcmf_fws_schedule_deq(fws
);
2142 bphy_err(drvr
, "no hanger slot available\n");
2145 brcmf_fws_unlock(fws
);
2150 void brcmf_fws_reset_interface(struct brcmf_if
*ifp
)
2152 struct brcmf_fws_mac_descriptor
*entry
= ifp
->fws_desc
;
2154 brcmf_dbg(TRACE
, "enter: bsscfgidx=%d\n", ifp
->bsscfgidx
);
2158 brcmf_fws_macdesc_init(entry
, ifp
->mac_addr
, ifp
->ifidx
);
2161 void brcmf_fws_add_interface(struct brcmf_if
*ifp
)
2163 struct brcmf_fws_info
*fws
= drvr_to_fws(ifp
->drvr
);
2164 struct brcmf_fws_mac_descriptor
*entry
;
2166 if (!ifp
->ndev
|| !brcmf_fws_queue_skbs(fws
))
2169 entry
= &fws
->desc
.iface
[ifp
->ifidx
];
2170 ifp
->fws_desc
= entry
;
2171 brcmf_fws_macdesc_init(entry
, ifp
->mac_addr
, ifp
->ifidx
);
2172 brcmf_fws_macdesc_set_name(fws
, entry
);
2173 brcmu_pktq_init(&entry
->psq
, BRCMF_FWS_PSQ_PREC_COUNT
,
2175 brcmf_dbg(TRACE
, "added %s\n", entry
->name
);
2178 void brcmf_fws_del_interface(struct brcmf_if
*ifp
)
2180 struct brcmf_fws_mac_descriptor
*entry
= ifp
->fws_desc
;
2181 struct brcmf_fws_info
*fws
= drvr_to_fws(ifp
->drvr
);
2186 brcmf_fws_lock(fws
);
2187 ifp
->fws_desc
= NULL
;
2188 brcmf_dbg(TRACE
, "deleting %s\n", entry
->name
);
2189 brcmf_fws_macdesc_cleanup(fws
, &fws
->desc
.iface
[ifp
->ifidx
],
2191 brcmf_fws_macdesc_deinit(entry
);
2192 brcmf_fws_cleanup(fws
, ifp
->ifidx
);
2193 brcmf_fws_unlock(fws
);
2196 static void brcmf_fws_dequeue_worker(struct work_struct
*worker
)
2198 struct brcmf_fws_info
*fws
;
2199 struct brcmf_pub
*drvr
;
2200 struct sk_buff
*skb
;
2206 fws
= container_of(worker
, struct brcmf_fws_info
, fws_dequeue_work
);
2209 brcmf_fws_lock(fws
);
2210 for (fifo
= BRCMF_FWS_FIFO_BCMC
; fifo
>= 0 && !fws
->bus_flow_blocked
;
2212 if (!brcmf_fws_fc_active(fws
)) {
2213 while ((skb
= brcmf_fws_deq(fws
, fifo
)) != NULL
) {
2214 hslot
= brcmf_skb_htod_tag_get_field(skb
,
2216 brcmf_fws_hanger_poppkt(&fws
->hanger
, hslot
,
2218 ifidx
= brcmf_skb_if_flags_get_field(skb
,
2220 /* Use proto layer to send data frame */
2221 brcmf_fws_unlock(fws
);
2222 ret
= brcmf_proto_txdata(drvr
, ifidx
, 0, skb
);
2223 brcmf_fws_lock(fws
);
2225 brcmf_txfinalize(brcmf_get_ifp(drvr
,
2228 if (fws
->bus_flow_blocked
)
2234 while ((fws
->fifo_credit
[fifo
]) ||
2235 ((!fws
->bcmc_credit_check
) &&
2236 (fifo
== BRCMF_FWS_FIFO_BCMC
))) {
2237 skb
= brcmf_fws_deq(fws
, fifo
);
2240 fws
->fifo_credit
[fifo
]--;
2241 if (brcmf_fws_commit_skb(fws
, fifo
, skb
))
2243 if (fws
->bus_flow_blocked
)
2247 if (fifo
>= BRCMF_FWS_FIFO_AC_BE
&&
2248 fifo
<= BRCMF_FWS_FIFO_AC_VO
&&
2249 fws
->fifo_credit
[fifo
] == 0 &&
2250 !fws
->bus_flow_blocked
) {
2251 while (brcmf_fws_borrow_credit(fws
,
2254 skb
= brcmf_fws_deq(fws
, fifo
);
2256 brcmf_fws_return_credits(fws
, fifo
, 1);
2259 if (brcmf_fws_commit_skb(fws
, fifo
, skb
))
2261 if (fws
->bus_flow_blocked
)
2266 brcmf_fws_unlock(fws
);
2270 static int brcmf_debugfs_fws_stats_read(struct seq_file
*seq
, void *data
)
2272 struct brcmf_bus
*bus_if
= dev_get_drvdata(seq
->private);
2273 struct brcmf_fws_stats
*fwstats
= &(drvr_to_fws(bus_if
->drvr
)->stats
);
2276 "header_pulls: %u\n"
2277 "header_only_pkt: %u\n"
2278 "tlv_parse_failed: %u\n"
2279 "tlv_invalid_type: %u\n"
2280 "mac_update_fails: %u\n"
2281 "ps_update_fails: %u\n"
2282 "if_update_fails: %u\n"
2284 "generic_error: %u\n"
2285 "rollback_success: %u\n"
2286 "rollback_failed: %u\n"
2289 "txs_indicate: %u\n"
2291 "txs_suppr_core: %u\n"
2292 "txs_suppr_ps: %u\n"
2294 "txs_host_tossed: %u\n"
2295 "bus_flow_block: %u\n"
2296 "fws_flow_block: %u\n"
2297 "send_pkts: BK:%u BE:%u VO:%u VI:%u BCMC:%u\n"
2298 "requested_sent: BK:%u BE:%u VO:%u VI:%u BCMC:%u\n",
2299 fwstats
->header_pulls
,
2300 fwstats
->header_only_pkt
,
2301 fwstats
->tlv_parse_failed
,
2302 fwstats
->tlv_invalid_type
,
2303 fwstats
->mac_update_failed
,
2304 fwstats
->mac_ps_update_failed
,
2305 fwstats
->if_update_failed
,
2307 fwstats
->generic_error
,
2308 fwstats
->rollback_success
,
2309 fwstats
->rollback_failed
,
2310 fwstats
->delayq_full_error
,
2311 fwstats
->supprq_full_error
,
2312 fwstats
->txs_indicate
,
2313 fwstats
->txs_discard
,
2314 fwstats
->txs_supp_core
,
2315 fwstats
->txs_supp_ps
,
2316 fwstats
->txs_tossed
,
2317 fwstats
->txs_host_tossed
,
2318 fwstats
->bus_flow_block
,
2319 fwstats
->fws_flow_block
,
2320 fwstats
->send_pkts
[0], fwstats
->send_pkts
[1],
2321 fwstats
->send_pkts
[2], fwstats
->send_pkts
[3],
2322 fwstats
->send_pkts
[4],
2323 fwstats
->requested_sent
[0],
2324 fwstats
->requested_sent
[1],
2325 fwstats
->requested_sent
[2],
2326 fwstats
->requested_sent
[3],
2327 fwstats
->requested_sent
[4]);
2332 static int brcmf_debugfs_fws_stats_read(struct seq_file
*seq
, void *data
)
2338 struct brcmf_fws_info
*brcmf_fws_attach(struct brcmf_pub
*drvr
)
2340 struct brcmf_fws_info
*fws
;
2341 struct brcmf_if
*ifp
;
2342 u32 tlv
= BRCMF_FWS_FLAGS_RSSI_SIGNALS
;
2346 fws
= kzalloc(sizeof(*fws
), GFP_KERNEL
);
2352 spin_lock_init(&fws
->spinlock
);
2354 /* store drvr reference */
2356 fws
->fcmode
= drvr
->settings
->fcmode
;
2358 if (!drvr
->bus_if
->always_use_fws_queue
&&
2359 (fws
->fcmode
== BRCMF_FWS_FCMODE_NONE
)) {
2360 fws
->avoid_queueing
= true;
2361 brcmf_dbg(INFO
, "FWS queueing will be avoided\n");
2365 fws
->fws_wq
= create_singlethread_workqueue("brcmf_fws_wq");
2366 if (fws
->fws_wq
== NULL
) {
2367 bphy_err(drvr
, "workqueue creation failed\n");
2371 INIT_WORK(&fws
->fws_dequeue_work
, brcmf_fws_dequeue_worker
);
2373 /* enable firmware signalling if fcmode active */
2374 if (fws
->fcmode
!= BRCMF_FWS_FCMODE_NONE
)
2375 tlv
|= BRCMF_FWS_FLAGS_XONXOFF_SIGNALS
|
2376 BRCMF_FWS_FLAGS_CREDIT_STATUS_SIGNALS
|
2377 BRCMF_FWS_FLAGS_HOST_PROPTXSTATUS_ACTIVE
|
2378 BRCMF_FWS_FLAGS_HOST_RXREORDER_ACTIVE
;
2380 rc
= brcmf_fweh_register(drvr
, BRCMF_E_FIFO_CREDIT_MAP
,
2381 brcmf_fws_notify_credit_map
);
2383 bphy_err(drvr
, "register credit map handler failed\n");
2386 rc
= brcmf_fweh_register(drvr
, BRCMF_E_BCMC_CREDIT_SUPPORT
,
2387 brcmf_fws_notify_bcmc_credit_support
);
2389 bphy_err(drvr
, "register bcmc credit handler failed\n");
2390 brcmf_fweh_unregister(drvr
, BRCMF_E_FIFO_CREDIT_MAP
);
2394 /* Setting the iovar may fail if feature is unsupported
2395 * so leave the rc as is so driver initialization can
2396 * continue. Set mode back to none indicating not enabled.
2398 fws
->fw_signals
= true;
2399 ifp
= brcmf_get_ifp(drvr
, 0);
2400 if (brcmf_fil_iovar_int_set(ifp
, "tlv", tlv
)) {
2401 bphy_err(drvr
, "failed to set bdcv2 tlv signaling\n");
2402 fws
->fcmode
= BRCMF_FWS_FCMODE_NONE
;
2403 fws
->fw_signals
= false;
2406 if (brcmf_fil_iovar_int_set(ifp
, "ampdu_hostreorder", 1))
2407 brcmf_dbg(INFO
, "enabling AMPDU host-reorder failed\n");
2409 /* Enable seq number reuse, if supported */
2410 if (brcmf_fil_iovar_int_get(ifp
, "wlfc_mode", &mode
) == 0) {
2411 if (BRCMF_FWS_MODE_GET_REUSESEQ(mode
)) {
2413 BRCMF_FWS_MODE_SET_REUSESEQ(mode
, 1);
2414 if (brcmf_fil_iovar_int_set(ifp
,
2415 "wlfc_mode", mode
) == 0) {
2416 BRCMF_FWS_MODE_SET_REUSESEQ(fws
->mode
, 1);
2421 brcmf_fws_hanger_init(&fws
->hanger
);
2422 brcmf_fws_macdesc_init(&fws
->desc
.other
, NULL
, 0);
2423 brcmf_fws_macdesc_set_name(fws
, &fws
->desc
.other
);
2424 brcmf_dbg(INFO
, "added %s\n", fws
->desc
.other
.name
);
2425 brcmu_pktq_init(&fws
->desc
.other
.psq
, BRCMF_FWS_PSQ_PREC_COUNT
,
2428 brcmf_dbg(INFO
, "%s bdcv2 tlv signaling [%x]\n",
2429 fws
->fw_signals
? "enabled" : "disabled", tlv
);
2433 brcmf_fws_detach(fws
);
2437 void brcmf_fws_detach(struct brcmf_fws_info
*fws
)
2443 destroy_workqueue(fws
->fws_wq
);
2446 brcmf_fws_lock(fws
);
2447 brcmf_fws_cleanup(fws
, -1);
2448 brcmf_fws_unlock(fws
);
2450 /* free top structure */
2454 void brcmf_fws_debugfs_create(struct brcmf_pub
*drvr
)
2456 /* create debugfs file for statistics */
2457 brcmf_debugfs_add_entry(drvr
, "fws_stats",
2458 brcmf_debugfs_fws_stats_read
);
2461 bool brcmf_fws_queue_skbs(struct brcmf_fws_info
*fws
)
2463 return !fws
->avoid_queueing
;
2466 bool brcmf_fws_fc_active(struct brcmf_fws_info
*fws
)
2468 if (!fws
->creditmap_received
)
2471 return fws
->fcmode
!= BRCMF_FWS_FCMODE_NONE
;
2474 void brcmf_fws_bustxcomplete(struct brcmf_fws_info
*fws
, struct sk_buff
*skb
,
2479 if (brcmf_skbcb(skb
)->state
== BRCMF_FWS_SKBSTATE_TIM
) {
2480 brcmu_pkt_buf_free_skb(skb
);
2485 brcmf_fws_lock(fws
);
2486 hslot
= brcmf_skb_htod_tag_get_field(skb
, HSLOT
);
2487 brcmf_fws_txs_process(fws
, BRCMF_FWS_TXSTATUS_HOST_TOSSED
, hslot
,
2489 brcmf_fws_unlock(fws
);
2493 void brcmf_fws_bus_blocked(struct brcmf_pub
*drvr
, bool flow_blocked
)
2495 struct brcmf_fws_info
*fws
= drvr_to_fws(drvr
);
2496 struct brcmf_if
*ifp
;
2499 if (fws
->avoid_queueing
) {
2500 for (i
= 0; i
< BRCMF_MAX_IFS
; i
++) {
2501 ifp
= drvr
->iflist
[i
];
2502 if (!ifp
|| !ifp
->ndev
)
2504 brcmf_txflowblock_if(ifp
, BRCMF_NETIF_STOP_REASON_FLOW
,
2508 fws
->bus_flow_blocked
= flow_blocked
;
2510 brcmf_fws_schedule_deq(fws
);
2512 fws
->stats
.bus_flow_block
++;