1 From e4af3ffb43d50f070134aa1b40d5c3573f57deb1 Mon Sep 17 00:00:00 2001
2 From: Chung-Hsien Hsu <stanley.hsu@cypress.com>
3 Date: Mon, 5 Nov 2018 05:52:05 +0000
4 Subject: [PATCH] brcmfmac: handle compressed tx status signal
6 Firmware inform the driver about tx status by normal tx status signal
7 or compressed tx status signal. This patch adds support to handle the
8 compressed tx status signal.
10 Signed-off-by: Chung-Hsien Hsu <stanley.hsu@cypress.com>
11 Signed-off-by: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
12 Signed-off-by: Wright Feng <wright.feng@cypress.com>
13 Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
14 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
16 .../broadcom/brcm80211/brcmfmac/fwsignal.c | 121 ++++++++++--------
17 1 file changed, 71 insertions(+), 50 deletions(-)
19 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
20 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
21 @@ -1455,9 +1455,10 @@ static int brcmf_fws_txstatus_suppressed
24 brcmf_fws_txs_process(struct brcmf_fws_info *fws, u8 flags, u32 hslot,
25 - u32 genbit, u16 seq)
26 + u32 genbit, u16 seq, u8 compcnt)
31 bool remove_from_hanger = true;
33 @@ -1468,60 +1469,71 @@ brcmf_fws_txs_process(struct brcmf_fws_i
34 brcmf_dbg(DATA, "flags %d\n", flags);
36 if (flags == BRCMF_FWS_TXSTATUS_DISCARD)
37 - fws->stats.txs_discard++;
38 + fws->stats.txs_discard += compcnt;
39 else if (flags == BRCMF_FWS_TXSTATUS_CORE_SUPPRESS) {
40 - fws->stats.txs_supp_core++;
41 + fws->stats.txs_supp_core += compcnt;
42 remove_from_hanger = false;
43 } else if (flags == BRCMF_FWS_TXSTATUS_FW_PS_SUPPRESS) {
44 - fws->stats.txs_supp_ps++;
45 + fws->stats.txs_supp_ps += compcnt;
46 remove_from_hanger = false;
47 } else if (flags == BRCMF_FWS_TXSTATUS_FW_TOSSED)
48 - fws->stats.txs_tossed++;
49 + fws->stats.txs_tossed += compcnt;
50 else if (flags == BRCMF_FWS_TXSTATUS_HOST_TOSSED)
51 - fws->stats.txs_host_tossed++;
52 + fws->stats.txs_host_tossed += compcnt;
54 brcmf_err("unexpected txstatus\n");
56 - ret = brcmf_fws_hanger_poppkt(&fws->hanger, hslot, &skb,
57 - remove_from_hanger);
59 - brcmf_err("no packet in hanger slot: hslot=%d\n", hslot);
62 + while (cnt < compcnt) {
63 + ret = brcmf_fws_hanger_poppkt(&fws->hanger, hslot, &skb,
64 + remove_from_hanger);
66 + brcmf_err("no packet in hanger slot: hslot=%d\n",
71 - skcb = brcmf_skbcb(skb);
73 - if (WARN_ON(!entry)) {
74 - brcmu_pkt_buf_free_skb(skb);
77 - entry->transit_count--;
78 - if (entry->suppressed && entry->suppr_transit_count)
79 - entry->suppr_transit_count--;
80 + skcb = brcmf_skbcb(skb);
82 + if (WARN_ON(!entry)) {
83 + brcmu_pkt_buf_free_skb(skb);
86 + entry->transit_count--;
87 + if (entry->suppressed && entry->suppr_transit_count)
88 + entry->suppr_transit_count--;
90 - brcmf_dbg(DATA, "%s flags %d htod %X seq %X\n", entry->name, flags,
92 + brcmf_dbg(DATA, "%s flags %d htod %X seq %X\n", entry->name,
93 + flags, skcb->htod, seq);
95 - /* pick up the implicit credit from this packet */
96 - fifo = brcmf_skb_htod_tag_get_field(skb, FIFO);
97 - if ((fws->fcmode == BRCMF_FWS_FCMODE_IMPLIED_CREDIT) ||
98 - (brcmf_skb_if_flags_get_field(skb, REQ_CREDIT)) ||
99 - (flags == BRCMF_FWS_TXSTATUS_HOST_TOSSED)) {
100 - brcmf_fws_return_credits(fws, fifo, 1);
101 - brcmf_fws_schedule_deq(fws);
103 - brcmf_fws_macdesc_return_req_credit(skb);
104 + /* pick up the implicit credit from this packet */
105 + fifo = brcmf_skb_htod_tag_get_field(skb, FIFO);
106 + if (fws->fcmode == BRCMF_FWS_FCMODE_IMPLIED_CREDIT ||
107 + (brcmf_skb_if_flags_get_field(skb, REQ_CREDIT)) ||
108 + flags == BRCMF_FWS_TXSTATUS_HOST_TOSSED) {
109 + brcmf_fws_return_credits(fws, fifo, 1);
110 + brcmf_fws_schedule_deq(fws);
112 + brcmf_fws_macdesc_return_req_credit(skb);
114 - ret = brcmf_proto_hdrpull(fws->drvr, false, skb, &ifp);
116 - brcmu_pkt_buf_free_skb(skb);
118 + ret = brcmf_proto_hdrpull(fws->drvr, false, skb, &ifp);
120 + brcmu_pkt_buf_free_skb(skb);
123 + if (!remove_from_hanger)
124 + ret = brcmf_fws_txstatus_suppressed(fws, fifo, skb,
126 + if (remove_from_hanger || ret)
127 + brcmf_txfinalize(ifp, skb, true);
130 + hslot = (hslot + 1) & (BRCMF_FWS_TXSTAT_HSLOT_MASK >>
131 + BRCMF_FWS_TXSTAT_HSLOT_SHIFT);
132 + if (BRCMF_FWS_MODE_GET_REUSESEQ(fws->mode))
133 + seq = (seq + 1) & BRCMF_SKB_HTOD_SEQ_NR_MASK;
137 - if (!remove_from_hanger)
138 - ret = brcmf_fws_txstatus_suppressed(fws, fifo, skb,
140 - if (remove_from_hanger || ret)
141 - brcmf_txfinalize(ifp, skb, true);
145 @@ -1547,7 +1559,8 @@ static int brcmf_fws_fifocreditback_indi
146 return BRCMF_FWS_RET_OK_SCHEDULE;
149 -static int brcmf_fws_txstatus_indicate(struct brcmf_fws_info *fws, u8 *data)
150 +static int brcmf_fws_txstatus_indicate(struct brcmf_fws_info *fws, u8 type,
155 @@ -1556,23 +1569,31 @@ static int brcmf_fws_txstatus_indicate(s
160 + u8 compcnt_offset = BRCMF_FWS_TYPE_TXSTATUS_LEN;
162 - fws->stats.txs_indicate++;
163 memcpy(&status_le, data, sizeof(status_le));
164 status = le32_to_cpu(status_le);
165 flags = brcmf_txstatus_get_field(status, FLAGS);
166 hslot = brcmf_txstatus_get_field(status, HSLOT);
167 genbit = brcmf_txstatus_get_field(status, GENERATION);
168 if (BRCMF_FWS_MODE_GET_REUSESEQ(fws->mode)) {
169 - memcpy(&seq_le, &data[BRCMF_FWS_TYPE_PKTTAG_LEN],
170 + memcpy(&seq_le, &data[BRCMF_FWS_TYPE_TXSTATUS_LEN],
172 seq = le16_to_cpu(seq_le);
173 + compcnt_offset += BRCMF_FWS_TYPE_SEQ_LEN;
178 + if (type == BRCMF_FWS_TYPE_COMP_TXSTATUS)
179 + compcnt = data[compcnt_offset];
182 + fws->stats.txs_indicate += compcnt;
185 - brcmf_fws_txs_process(fws, flags, hslot, genbit, seq);
186 + brcmf_fws_txs_process(fws, flags, hslot, genbit, seq, compcnt);
187 brcmf_fws_unlock(fws);
188 return BRCMF_FWS_RET_OK_NOSCHEDULE;
190 @@ -1888,8 +1909,6 @@ void brcmf_fws_hdrpull(struct brcmf_if *
192 err = BRCMF_FWS_RET_OK_NOSCHEDULE;
194 - case BRCMF_FWS_TYPE_COMP_TXSTATUS:
196 case BRCMF_FWS_TYPE_HOST_REORDER_RXPKTS:
197 rd = (struct brcmf_skb_reorder_data *)skb->cb;
199 @@ -1912,7 +1931,8 @@ void brcmf_fws_hdrpull(struct brcmf_if *
200 err = brcmf_fws_request_indicate(fws, type, data);
202 case BRCMF_FWS_TYPE_TXSTATUS:
203 - brcmf_fws_txstatus_indicate(fws, data);
204 + case BRCMF_FWS_TYPE_COMP_TXSTATUS:
205 + brcmf_fws_txstatus_indicate(fws, type, data);
207 case BRCMF_FWS_TYPE_FIFO_CREDITBACK:
208 err = brcmf_fws_fifocreditback_indicate(fws, data);
209 @@ -2001,7 +2021,7 @@ static void brcmf_fws_rollback_toq(struc
210 fws->stats.rollback_failed++;
211 hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT);
212 brcmf_fws_txs_process(fws, BRCMF_FWS_TXSTATUS_HOST_TOSSED,
216 fws->stats.rollback_success++;
217 brcmf_fws_return_credits(fws, fifo, 1);
218 @@ -2462,7 +2482,8 @@ void brcmf_fws_bustxfail(struct brcmf_fw
221 hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT);
222 - brcmf_fws_txs_process(fws, BRCMF_FWS_TXSTATUS_HOST_TOSSED, hslot, 0, 0);
223 + brcmf_fws_txs_process(fws, BRCMF_FWS_TXSTATUS_HOST_TOSSED, hslot, 0, 0,
225 brcmf_fws_unlock(fws);