Commit e0097ac5 authored by Ching-Te Ku's avatar Ching-Te Ku Committed by Kalle Valo

wifi: rtw89: coex: Change TDMA related logic to version separate

In order to make different version of TDMA and coming update in the future
can all work well, use BTC format version to replace chip_id, because
format could change for specific chip_id.
Signed-off-by: default avatarChing-Te Ku <ku920601@realtek.com>
Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221217141745.43291-8-pkshih@realtek.com
parent 31f12cff
...@@ -1045,12 +1045,14 @@ static u32 _chk_btc_report(struct rtw89_dev *rtwdev, ...@@ -1045,12 +1045,14 @@ static u32 _chk_btc_report(struct rtw89_dev *rtwdev,
break; break;
case BTC_RPT_TYPE_TDMA: case BTC_RPT_TYPE_TDMA:
pcinfo = &pfwinfo->rpt_fbtc_tdma.cinfo; pcinfo = &pfwinfo->rpt_fbtc_tdma.cinfo;
if (chip->chip_id == RTL8852A) { if (ver->fcxtdma == 1) {
pfinfo = &pfwinfo->rpt_fbtc_tdma.finfo; pfinfo = &pfwinfo->rpt_fbtc_tdma.finfo.v1;
pcinfo->req_len = sizeof(pfwinfo->rpt_fbtc_tdma.finfo); pcinfo->req_len = sizeof(pfwinfo->rpt_fbtc_tdma.finfo.v1);
} else if (ver->fcxtdma == 3) {
pfinfo = &pfwinfo->rpt_fbtc_tdma.finfo.v3;
pcinfo->req_len = sizeof(pfwinfo->rpt_fbtc_tdma.finfo.v3);
} else { } else {
pfinfo = &pfwinfo->rpt_fbtc_tdma.finfo_v1; goto err;
pcinfo->req_len = sizeof(pfwinfo->rpt_fbtc_tdma.finfo_v1);
} }
pcinfo->req_fver = ver->fcxtdma; pcinfo->req_fver = ver->fcxtdma;
break; break;
...@@ -1232,16 +1234,18 @@ static u32 _chk_btc_report(struct rtw89_dev *rtwdev, ...@@ -1232,16 +1234,18 @@ static u32 _chk_btc_report(struct rtw89_dev *rtwdev,
"[BTC], %s(): check %d %zu\n", __func__, "[BTC], %s(): check %d %zu\n", __func__,
BTC_DCNT_TDMA_NONSYNC, BTC_DCNT_TDMA_NONSYNC,
sizeof(dm->tdma_now)); sizeof(dm->tdma_now));
if (chip->chip_id == RTL8852A) if (ver->fcxtdma == 1)
_chk_btc_err(rtwdev, BTC_DCNT_TDMA_NONSYNC, _chk_btc_err(rtwdev, BTC_DCNT_TDMA_NONSYNC,
memcmp(&dm->tdma_now, memcmp(&dm->tdma_now,
&pfwinfo->rpt_fbtc_tdma.finfo_v1, &pfwinfo->rpt_fbtc_tdma.finfo.v1,
sizeof(dm->tdma_now))); sizeof(dm->tdma_now)));
else else if (ver->fcxtdma == 3)
_chk_btc_err(rtwdev, BTC_DCNT_TDMA_NONSYNC, _chk_btc_err(rtwdev, BTC_DCNT_TDMA_NONSYNC,
memcmp(&dm->tdma_now, memcmp(&dm->tdma_now,
&pfwinfo->rpt_fbtc_tdma.finfo, &pfwinfo->rpt_fbtc_tdma.finfo.v3.tdma,
sizeof(dm->tdma_now))); sizeof(dm->tdma_now)));
else
goto err;
break; break;
case BTC_RPT_TYPE_SLOT: case BTC_RPT_TYPE_SLOT:
rtw89_debug(rtwdev, RTW89_DBG_BTC, rtw89_debug(rtwdev, RTW89_DBG_BTC,
...@@ -1375,13 +1379,12 @@ static void _parse_btc_report(struct rtw89_dev *rtwdev, ...@@ -1375,13 +1379,12 @@ static void _parse_btc_report(struct rtw89_dev *rtwdev,
static void _append_tdma(struct rtw89_dev *rtwdev) static void _append_tdma(struct rtw89_dev *rtwdev)
{ {
const struct rtw89_chip_info *chip = rtwdev->chip;
struct rtw89_btc *btc = &rtwdev->btc; struct rtw89_btc *btc = &rtwdev->btc;
const struct rtw89_btc_ver *ver = btc->ver; const struct rtw89_btc_ver *ver = btc->ver;
struct rtw89_btc_dm *dm = &btc->dm; struct rtw89_btc_dm *dm = &btc->dm;
struct rtw89_btc_btf_tlv *tlv; struct rtw89_btc_btf_tlv *tlv;
struct rtw89_btc_fbtc_tdma *v; struct rtw89_btc_fbtc_tdma *v;
struct rtw89_btc_fbtc_tdma_v1 *v1; struct rtw89_btc_fbtc_tdma_v3 *v3;
u16 len = btc->policy_len; u16 len = btc->policy_len;
if (!btc->update_policy_force && if (!btc->update_policy_force &&
...@@ -1394,17 +1397,17 @@ static void _append_tdma(struct rtw89_dev *rtwdev) ...@@ -1394,17 +1397,17 @@ static void _append_tdma(struct rtw89_dev *rtwdev)
tlv = (struct rtw89_btc_btf_tlv *)&btc->policy[len]; tlv = (struct rtw89_btc_btf_tlv *)&btc->policy[len];
tlv->type = CXPOLICY_TDMA; tlv->type = CXPOLICY_TDMA;
if (chip->chip_id == RTL8852A) { if (ver->fcxtdma == 1) {
v = (struct rtw89_btc_fbtc_tdma *)&tlv->val[0]; v = (struct rtw89_btc_fbtc_tdma *)&tlv->val[0];
tlv->len = sizeof(*v); tlv->len = sizeof(*v);
memcpy(v, &dm->tdma, sizeof(*v)); memcpy(v, &dm->tdma, sizeof(*v));
btc->policy_len += BTC_TLV_HDR_LEN + sizeof(*v); btc->policy_len += BTC_TLV_HDR_LEN + sizeof(*v);
} else { } else {
tlv->len = sizeof(*v1); tlv->len = sizeof(*v3);
v1 = (struct rtw89_btc_fbtc_tdma_v1 *)&tlv->val[0]; v3 = (struct rtw89_btc_fbtc_tdma_v3 *)&tlv->val[0];
v1->fver = ver->fcxtdma; v3->fver = ver->fcxtdma;
v1->tdma = dm->tdma; memcpy(&v3->tdma, &dm->tdma, sizeof(v3->tdma));
btc->policy_len += BTC_TLV_HDR_LEN + sizeof(*v1); btc->policy_len += BTC_TLV_HDR_LEN + sizeof(*v3);
} }
rtw89_debug(rtwdev, RTW89_DBG_BTC, rtw89_debug(rtwdev, RTW89_DBG_BTC,
...@@ -6281,8 +6284,8 @@ static void _show_error(struct rtw89_dev *rtwdev, struct seq_file *m) ...@@ -6281,8 +6284,8 @@ static void _show_error(struct rtw89_dev *rtwdev, struct seq_file *m)
static void _show_fbtc_tdma(struct rtw89_dev *rtwdev, struct seq_file *m) static void _show_fbtc_tdma(struct rtw89_dev *rtwdev, struct seq_file *m)
{ {
const struct rtw89_chip_info *chip = rtwdev->chip;
struct rtw89_btc *btc = &rtwdev->btc; struct rtw89_btc *btc = &rtwdev->btc;
const struct rtw89_btc_ver *ver = btc->ver;
struct rtw89_btc_btf_fwinfo *pfwinfo = &btc->fwinfo; struct rtw89_btc_btf_fwinfo *pfwinfo = &btc->fwinfo;
struct rtw89_btc_rpt_cmn_info *pcinfo = NULL; struct rtw89_btc_rpt_cmn_info *pcinfo = NULL;
struct rtw89_btc_fbtc_tdma *t = NULL; struct rtw89_btc_fbtc_tdma *t = NULL;
...@@ -6294,10 +6297,10 @@ static void _show_fbtc_tdma(struct rtw89_dev *rtwdev, struct seq_file *m) ...@@ -6294,10 +6297,10 @@ static void _show_fbtc_tdma(struct rtw89_dev *rtwdev, struct seq_file *m)
if (!pcinfo->valid) if (!pcinfo->valid)
return; return;
if (chip->chip_id == RTL8852A) if (ver->fcxtdma == 1)
t = &pfwinfo->rpt_fbtc_tdma.finfo; t = &pfwinfo->rpt_fbtc_tdma.finfo.v1;
else else
t = &pfwinfo->rpt_fbtc_tdma.finfo_v1.tdma; t = &pfwinfo->rpt_fbtc_tdma.finfo.v3.tdma;
seq_printf(m, seq_printf(m,
" %-15s : ", "[tdma_policy]"); " %-15s : ", "[tdma_policy]");
......
...@@ -1450,13 +1450,18 @@ struct rtw89_btc_fbtc_tdma { ...@@ -1450,13 +1450,18 @@ struct rtw89_btc_fbtc_tdma {
u8 option_ctrl; u8 option_ctrl;
} __packed; } __packed;
struct rtw89_btc_fbtc_tdma_v1 { struct rtw89_btc_fbtc_tdma_v3 {
u8 fver; /* btc_ver::fcxtdma */ u8 fver; /* btc_ver::fcxtdma */
u8 rsvd; u8 rsvd;
__le16 rsvd1; __le16 rsvd1;
struct rtw89_btc_fbtc_tdma tdma; struct rtw89_btc_fbtc_tdma tdma;
} __packed; } __packed;
union rtw89_btc_fbtc_tdma_le32 {
struct rtw89_btc_fbtc_tdma v1;
struct rtw89_btc_fbtc_tdma_v3 v3;
};
#define CXMREG_MAX 30 #define CXMREG_MAX 30
#define FCXMAX_STEP 255 /*STEP trace record cnt, Max:65535, default:255*/ #define FCXMAX_STEP 255 /*STEP trace record cnt, Max:65535, default:255*/
#define BTC_CYCLE_SLOT_MAX 48 /* must be even number, non-zero */ #define BTC_CYCLE_SLOT_MAX 48 /* must be even number, non-zero */
...@@ -1946,10 +1951,7 @@ struct rtw89_btc_report_ctrl_state { ...@@ -1946,10 +1951,7 @@ struct rtw89_btc_report_ctrl_state {
struct rtw89_btc_rpt_fbtc_tdma { struct rtw89_btc_rpt_fbtc_tdma {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union { union rtw89_btc_fbtc_tdma_le32 finfo;
struct rtw89_btc_fbtc_tdma finfo; /* info from fw */
struct rtw89_btc_fbtc_tdma_v1 finfo_v1; /* info from fw for 52C*/
};
}; };
struct rtw89_btc_rpt_fbtc_slots { struct rtw89_btc_rpt_fbtc_slots {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment