mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 09:01:36 -04:00
wifi: rtw89: update statistics to FW for fine-tuning performance
Since firmware can't have proper statistics, driver update the statistics periodically to firmware to assist in tuning performance. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230415034900.15679-5-pkshih@realtek.com
This commit is contained in:
@@ -2494,8 +2494,10 @@ static bool rtw89_traffic_stats_track(struct rtw89_dev *rtwdev)
|
||||
bool tfc_changed;
|
||||
|
||||
tfc_changed = rtw89_traffic_stats_calc(rtwdev, &rtwdev->stats);
|
||||
rtw89_for_each_rtwvif(rtwdev, rtwvif)
|
||||
rtw89_for_each_rtwvif(rtwdev, rtwvif) {
|
||||
rtw89_traffic_stats_calc(rtwdev, &rtwvif->stats);
|
||||
rtw89_fw_h2c_tp_offload(rtwdev, rtwvif);
|
||||
}
|
||||
|
||||
return tfc_changed;
|
||||
}
|
||||
|
||||
@@ -1855,6 +1855,47 @@ int rtw89_fw_h2c_rssi_offload(struct rtw89_dev *rtwdev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int rtw89_fw_h2c_tp_offload(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
|
||||
{
|
||||
struct rtw89_traffic_stats *stats = &rtwvif->stats;
|
||||
struct rtw89_h2c_ofld *h2c;
|
||||
u32 len = sizeof(*h2c);
|
||||
struct sk_buff *skb;
|
||||
int ret;
|
||||
|
||||
if (rtwvif->net_type != RTW89_NET_TYPE_INFRA)
|
||||
return -EINVAL;
|
||||
|
||||
skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, len);
|
||||
if (!skb) {
|
||||
rtw89_err(rtwdev, "failed to alloc skb for h2c tp\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
skb_put(skb, len);
|
||||
h2c = (struct rtw89_h2c_ofld *)skb->data;
|
||||
|
||||
h2c->w0 = le32_encode_bits(rtwvif->mac_id, RTW89_H2C_OFLD_W0_MAC_ID) |
|
||||
le32_encode_bits(stats->tx_throughput, RTW89_H2C_OFLD_W0_TX_TP) |
|
||||
le32_encode_bits(stats->rx_throughput, RTW89_H2C_OFLD_W0_RX_TP);
|
||||
|
||||
rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C,
|
||||
H2C_CAT_MAC, H2C_CL_MAC_FW_OFLD,
|
||||
H2C_FUNC_OFLD_TP, 0, 1, len);
|
||||
|
||||
ret = rtw89_h2c_tx(rtwdev, skb, false);
|
||||
if (ret) {
|
||||
rtw89_err(rtwdev, "failed to send h2c\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
dev_kfree_skb_any(skb);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define H2C_RA_LEN 16
|
||||
int rtw89_fw_h2c_ra(struct rtw89_dev *rtwdev, struct rtw89_ra_info *ra, bool csi)
|
||||
{
|
||||
|
||||
@@ -3361,6 +3361,14 @@ struct rtw89_h2c_ofld_rssi {
|
||||
#define RTW89_H2C_OFLD_RSSI_W0_NUM GENMASK(15, 8)
|
||||
#define RTW89_H2C_OFLD_RSSI_W1_VAL GENMASK(7, 0)
|
||||
|
||||
struct rtw89_h2c_ofld {
|
||||
__le32 w0;
|
||||
} __packed;
|
||||
|
||||
#define RTW89_H2C_OFLD_W0_MAC_ID GENMASK(7, 0)
|
||||
#define RTW89_H2C_OFLD_W0_TX_TP GENMASK(17, 8)
|
||||
#define RTW89_H2C_OFLD_W0_RX_TP GENMASK(27, 18)
|
||||
|
||||
#define RTW89_FW_HDR_SIZE 32
|
||||
#define RTW89_FW_SECTION_HDR_SIZE 16
|
||||
|
||||
@@ -3499,6 +3507,7 @@ struct rtw89_fw_h2c_rf_reg_info {
|
||||
#define H2C_FUNC_PKT_DROP 0x1b
|
||||
#define H2C_FUNC_CFG_BCNFLTR 0x1e
|
||||
#define H2C_FUNC_OFLD_RSSI 0x1f
|
||||
#define H2C_FUNC_OFLD_TP 0x20
|
||||
|
||||
/* CLASS 10 - Security CAM */
|
||||
#define H2C_CL_MAC_SEC_CAM 0xa
|
||||
@@ -3605,6 +3614,7 @@ int rtw89_fw_h2c_set_bcn_fltr_cfg(struct rtw89_dev *rtwdev,
|
||||
bool connect);
|
||||
int rtw89_fw_h2c_rssi_offload(struct rtw89_dev *rtwdev,
|
||||
struct rtw89_rx_phy_ppdu *phy_ppdu);
|
||||
int rtw89_fw_h2c_tp_offload(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif);
|
||||
int rtw89_fw_h2c_ra(struct rtw89_dev *rtwdev, struct rtw89_ra_info *ra, bool csi);
|
||||
int rtw89_fw_h2c_cxdrv_init(struct rtw89_dev *rtwdev);
|
||||
int rtw89_fw_h2c_cxdrv_role(struct rtw89_dev *rtwdev);
|
||||
|
||||
Reference in New Issue
Block a user