brcmfmac: allow credit borrowing for all access categories
Current credit borrowing allows only the access category BE to borrow the credits. This change is to fix the credit borrowing logic, to make borrowing available for all access categories and also to borrow only from the lower categories. This fixes WFA 802.11n certs 5.2.27 failures. Signed-off-by: Raveendran Somu <raveendran.somu@cypress.com> Signed-off-by: Jia-Shyr Chuang <joseph.chuang@cypress.com> Signed-off-by: Chung-Hsien Hsu <stanley.hsu@cypress.com> Signed-off-by: Chi-hsien Lin <chi-hsien.lin@cypress.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200610152106.175257-2-chi-hsien.lin@cypress.com
This commit is contained in:
parent
fa3266541b
commit
683608bde0
|
@ -383,6 +383,7 @@ struct brcmf_fws_mac_descriptor {
|
|||
};
|
||||
|
||||
#define BRCMF_FWS_HANGER_MAXITEMS 3072
|
||||
#define BRCMF_BORROW_RATIO 3
|
||||
|
||||
/**
|
||||
* enum brcmf_fws_hanger_item_state - state of hanger item.
|
||||
|
@ -479,7 +480,8 @@ struct brcmf_fws_info {
|
|||
u32 fifo_enqpkt[BRCMF_FWS_FIFO_COUNT];
|
||||
int fifo_credit[BRCMF_FWS_FIFO_COUNT];
|
||||
int init_fifo_credit[BRCMF_FWS_FIFO_COUNT];
|
||||
int credits_borrowed[BRCMF_FWS_FIFO_AC_VO + 1];
|
||||
int credits_borrowed[BRCMF_FWS_FIFO_AC_VO + 1]
|
||||
[BRCMF_FWS_FIFO_AC_VO + 1];
|
||||
int deq_node_pos[BRCMF_FWS_FIFO_COUNT];
|
||||
u32 fifo_credit_map;
|
||||
u32 fifo_delay_map;
|
||||
|
@ -1185,13 +1187,11 @@ static void brcmf_fws_return_credits(struct brcmf_fws_info *fws,
|
|||
if (!credits)
|
||||
return;
|
||||
|
||||
fws->fifo_credit_map |= 1 << fifo;
|
||||
|
||||
if ((fifo == BRCMF_FWS_FIFO_AC_BE) &&
|
||||
(fws->credits_borrowed[0])) {
|
||||
if (fifo > BRCMF_FWS_FIFO_AC_BK &&
|
||||
fifo <= BRCMF_FWS_FIFO_AC_VO) {
|
||||
for (lender_ac = BRCMF_FWS_FIFO_AC_VO; lender_ac >= 0;
|
||||
lender_ac--) {
|
||||
borrowed = &fws->credits_borrowed[lender_ac];
|
||||
borrowed = &fws->credits_borrowed[fifo][lender_ac];
|
||||
if (*borrowed) {
|
||||
fws->fifo_credit_map |= (1 << lender_ac);
|
||||
fifo_credit = &fws->fifo_credit[lender_ac];
|
||||
|
@ -1208,7 +1208,11 @@ static void brcmf_fws_return_credits(struct brcmf_fws_info *fws,
|
|||
}
|
||||
}
|
||||
|
||||
fws->fifo_credit[fifo] += credits;
|
||||
if (credits) {
|
||||
fws->fifo_credit[fifo] += credits;
|
||||
fws->fifo_credit_map |= 1 << fifo;
|
||||
}
|
||||
|
||||
if (fws->fifo_credit[fifo] > fws->init_fifo_credit[fifo])
|
||||
fws->fifo_credit[fifo] = fws->init_fifo_credit[fifo];
|
||||
|
||||
|
@ -2008,27 +2012,31 @@ static void brcmf_fws_rollback_toq(struct brcmf_fws_info *fws,
|
|||
}
|
||||
}
|
||||
|
||||
static int brcmf_fws_borrow_credit(struct brcmf_fws_info *fws)
|
||||
static int brcmf_fws_borrow_credit(struct brcmf_fws_info *fws,
|
||||
int highest_lender_ac, int borrower_ac,
|
||||
bool borrow_all)
|
||||
{
|
||||
int lender_ac;
|
||||
int lender_ac, borrow_limit = 0;
|
||||
|
||||
if (time_after(fws->borrow_defer_timestamp, jiffies)) {
|
||||
fws->fifo_credit_map &= ~(1 << BRCMF_FWS_FIFO_AC_BE);
|
||||
return -ENAVAIL;
|
||||
}
|
||||
for (lender_ac = 0; lender_ac <= highest_lender_ac; lender_ac++) {
|
||||
|
||||
for (lender_ac = 0; lender_ac <= BRCMF_FWS_FIFO_AC_VO; lender_ac++) {
|
||||
if (fws->fifo_credit[lender_ac] > 0) {
|
||||
fws->credits_borrowed[lender_ac]++;
|
||||
if (!borrow_all)
|
||||
borrow_limit =
|
||||
fws->init_fifo_credit[lender_ac] / BRCMF_BORROW_RATIO;
|
||||
else
|
||||
borrow_limit = 0;
|
||||
|
||||
if (fws->fifo_credit[lender_ac] > borrow_limit) {
|
||||
fws->credits_borrowed[borrower_ac][lender_ac]++;
|
||||
fws->fifo_credit[lender_ac]--;
|
||||
if (fws->fifo_credit[lender_ac] == 0)
|
||||
fws->fifo_credit_map &= ~(1 << lender_ac);
|
||||
fws->fifo_credit_map |= (1 << BRCMF_FWS_FIFO_AC_BE);
|
||||
fws->fifo_credit_map |= (1 << borrower_ac);
|
||||
brcmf_dbg(DATA, "borrow credit from: %d\n", lender_ac);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
fws->fifo_credit_map &= ~(1 << BRCMF_FWS_FIFO_AC_BE);
|
||||
fws->fifo_credit_map &= ~(1 << borrower_ac);
|
||||
return -ENAVAIL;
|
||||
}
|
||||
|
||||
|
@ -2219,9 +2227,10 @@ static void brcmf_fws_dequeue_worker(struct work_struct *worker)
|
|||
}
|
||||
continue;
|
||||
}
|
||||
while ((fws->fifo_credit[fifo] > 0) ||
|
||||
|
||||
while ((fws->fifo_credit[fifo]) ||
|
||||
((!fws->bcmc_credit_check) &&
|
||||
(fifo == BRCMF_FWS_FIFO_BCMC))) {
|
||||
(fifo == BRCMF_FWS_FIFO_BCMC))) {
|
||||
skb = brcmf_fws_deq(fws, fifo);
|
||||
if (!skb)
|
||||
break;
|
||||
|
@ -2231,10 +2240,14 @@ static void brcmf_fws_dequeue_worker(struct work_struct *worker)
|
|||
if (fws->bus_flow_blocked)
|
||||
break;
|
||||
}
|
||||
if ((fifo == BRCMF_FWS_FIFO_AC_BE) &&
|
||||
(fws->fifo_credit[fifo] <= 0) &&
|
||||
(!fws->bus_flow_blocked)) {
|
||||
while (brcmf_fws_borrow_credit(fws) == 0) {
|
||||
|
||||
if (fifo >= BRCMF_FWS_FIFO_AC_BE &&
|
||||
fifo <= BRCMF_FWS_FIFO_AC_VO &&
|
||||
fws->fifo_credit[fifo] == 0 &&
|
||||
!fws->bus_flow_blocked) {
|
||||
while (brcmf_fws_borrow_credit(fws,
|
||||
fifo - 1, fifo,
|
||||
true) == 0) {
|
||||
skb = brcmf_fws_deq(fws, fifo);
|
||||
if (!skb) {
|
||||
brcmf_fws_return_credits(fws, fifo, 1);
|
||||
|
|
Loading…
Reference in New Issue