mac80211: brcmfmac: backport remaining patches from the Linux 5.0
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / brcm / 328-v5.0-0001-brcmfmac-add-credit-numbers-updating-support.patch
1 From 153e22c0ff1260035cd7fe72c8aeead1f5fac757 Mon Sep 17 00:00:00 2001
2 From: Wright Feng <Wright.Feng@cypress.com>
3 Date: Mon, 5 Nov 2018 05:51:54 +0000
4 Subject: [PATCH] brcmfmac: add credit numbers updating support
5
6 The credit numbers are static and tunable per chip in firmware side.
7 However the credit number may be changed that is based on packet pool
8 length and will send BRCMF_E_FIFO_CREDIT_MAP event to notify host driver
9 updates the credit numbers during interface up.
10 The purpose of this patch is making host driver has ability of updating
11 the credit numbers when receiving the BRCMF_E_FIFO_CREDIT_MAP event.
12
13 Signed-off-by: Wright Feng <wright.feng@cypress.com>
14 Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
15 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
16 ---
17 .../broadcom/brcm80211/brcmfmac/fwsignal.c | 23 ++++++++++++-------
18 1 file changed, 15 insertions(+), 8 deletions(-)
19
20 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
21 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
22 @@ -511,6 +511,7 @@ struct brcmf_fws_info {
23 struct work_struct fws_dequeue_work;
24 u32 fifo_enqpkt[BRCMF_FWS_FIFO_COUNT];
25 int fifo_credit[BRCMF_FWS_FIFO_COUNT];
26 + int init_fifo_credit[BRCMF_FWS_FIFO_COUNT];
27 int credits_borrowed[BRCMF_FWS_FIFO_AC_VO + 1];
28 int deq_node_pos[BRCMF_FWS_FIFO_COUNT];
29 u32 fifo_credit_map;
30 @@ -1237,6 +1238,9 @@ static void brcmf_fws_return_credits(str
31 }
32
33 fws->fifo_credit[fifo] += credits;
34 + if (fws->fifo_credit[fifo] > fws->init_fifo_credit[fifo])
35 + fws->fifo_credit[fifo] = fws->init_fifo_credit[fifo];
36 +
37 }
38
39 static void brcmf_fws_schedule_deq(struct brcmf_fws_info *fws)
40 @@ -1595,19 +1599,21 @@ static int brcmf_fws_notify_credit_map(s
41 brcmf_err("event payload too small (%d)\n", e->datalen);
42 return -EINVAL;
43 }
44 - if (fws->creditmap_received)
45 - return 0;
46
47 fws->creditmap_received = true;
48
49 brcmf_dbg(TRACE, "enter: credits %pM\n", credits);
50 brcmf_fws_lock(fws);
51 for (i = 0; i < ARRAY_SIZE(fws->fifo_credit); i++) {
52 - if (*credits)
53 + fws->fifo_credit[i] += credits[i] - fws->init_fifo_credit[i];
54 + fws->init_fifo_credit[i] = credits[i];
55 + if (fws->fifo_credit[i] > 0)
56 fws->fifo_credit_map |= 1 << i;
57 else
58 fws->fifo_credit_map &= ~(1 << i);
59 - fws->fifo_credit[i] = *credits++;
60 + WARN_ONCE(fws->fifo_credit[i] < 0,
61 + "fifo_credit[%d] is negative(%d)\n", i,
62 + fws->fifo_credit[i]);
63 }
64 brcmf_fws_schedule_deq(fws);
65 brcmf_fws_unlock(fws);
66 @@ -2013,7 +2019,7 @@ static int brcmf_fws_borrow_credit(struc
67 }
68
69 for (lender_ac = 0; lender_ac <= BRCMF_FWS_FIFO_AC_VO; lender_ac++) {
70 - if (fws->fifo_credit[lender_ac]) {
71 + if (fws->fifo_credit[lender_ac] > 0) {
72 fws->credits_borrowed[lender_ac]++;
73 fws->fifo_credit[lender_ac]--;
74 if (fws->fifo_credit[lender_ac] == 0)
75 @@ -2210,8 +2216,9 @@ static void brcmf_fws_dequeue_worker(str
76 }
77 continue;
78 }
79 - while ((fws->fifo_credit[fifo]) || ((!fws->bcmc_credit_check) &&
80 - (fifo == BRCMF_FWS_FIFO_BCMC))) {
81 + while ((fws->fifo_credit[fifo] > 0) ||
82 + ((!fws->bcmc_credit_check) &&
83 + (fifo == BRCMF_FWS_FIFO_BCMC))) {
84 skb = brcmf_fws_deq(fws, fifo);
85 if (!skb)
86 break;
87 @@ -2222,7 +2229,7 @@ static void brcmf_fws_dequeue_worker(str
88 break;
89 }
90 if ((fifo == BRCMF_FWS_FIFO_AC_BE) &&
91 - (fws->fifo_credit[fifo] == 0) &&
92 + (fws->fifo_credit[fifo] <= 0) &&
93 (!fws->bus_flow_blocked)) {
94 while (brcmf_fws_borrow_credit(fws) == 0) {
95 skb = brcmf_fws_deq(fws, fifo);