Commit ac83f380 authored by Po-Hao Huang's avatar Po-Hao Huang Committed by Kalle Valo

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: default avatarPo-Hao Huang <phhuang@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/20230415034900.15679-5-pkshih@realtek.com
parent 8b048bd5
...@@ -2494,8 +2494,10 @@ static bool rtw89_traffic_stats_track(struct rtw89_dev *rtwdev) ...@@ -2494,8 +2494,10 @@ static bool rtw89_traffic_stats_track(struct rtw89_dev *rtwdev)
bool tfc_changed; bool tfc_changed;
tfc_changed = rtw89_traffic_stats_calc(rtwdev, &rtwdev->stats); 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_traffic_stats_calc(rtwdev, &rtwvif->stats);
rtw89_fw_h2c_tp_offload(rtwdev, rtwvif);
}
return tfc_changed; return tfc_changed;
} }
......
...@@ -1855,6 +1855,47 @@ int rtw89_fw_h2c_rssi_offload(struct rtw89_dev *rtwdev, ...@@ -1855,6 +1855,47 @@ int rtw89_fw_h2c_rssi_offload(struct rtw89_dev *rtwdev,
return ret; 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 #define H2C_RA_LEN 16
int rtw89_fw_h2c_ra(struct rtw89_dev *rtwdev, struct rtw89_ra_info *ra, bool csi) 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 { ...@@ -3361,6 +3361,14 @@ struct rtw89_h2c_ofld_rssi {
#define RTW89_H2C_OFLD_RSSI_W0_NUM GENMASK(15, 8) #define RTW89_H2C_OFLD_RSSI_W0_NUM GENMASK(15, 8)
#define RTW89_H2C_OFLD_RSSI_W1_VAL GENMASK(7, 0) #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_HDR_SIZE 32
#define RTW89_FW_SECTION_HDR_SIZE 16 #define RTW89_FW_SECTION_HDR_SIZE 16
...@@ -3499,6 +3507,7 @@ struct rtw89_fw_h2c_rf_reg_info { ...@@ -3499,6 +3507,7 @@ struct rtw89_fw_h2c_rf_reg_info {
#define H2C_FUNC_PKT_DROP 0x1b #define H2C_FUNC_PKT_DROP 0x1b
#define H2C_FUNC_CFG_BCNFLTR 0x1e #define H2C_FUNC_CFG_BCNFLTR 0x1e
#define H2C_FUNC_OFLD_RSSI 0x1f #define H2C_FUNC_OFLD_RSSI 0x1f
#define H2C_FUNC_OFLD_TP 0x20
/* CLASS 10 - Security CAM */ /* CLASS 10 - Security CAM */
#define H2C_CL_MAC_SEC_CAM 0xa #define H2C_CL_MAC_SEC_CAM 0xa
...@@ -3605,6 +3614,7 @@ int rtw89_fw_h2c_set_bcn_fltr_cfg(struct rtw89_dev *rtwdev, ...@@ -3605,6 +3614,7 @@ int rtw89_fw_h2c_set_bcn_fltr_cfg(struct rtw89_dev *rtwdev,
bool connect); bool connect);
int rtw89_fw_h2c_rssi_offload(struct rtw89_dev *rtwdev, int rtw89_fw_h2c_rssi_offload(struct rtw89_dev *rtwdev,
struct rtw89_rx_phy_ppdu *phy_ppdu); 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_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_init(struct rtw89_dev *rtwdev);
int rtw89_fw_h2c_cxdrv_role(struct rtw89_dev *rtwdev); int rtw89_fw_h2c_cxdrv_role(struct rtw89_dev *rtwdev);
......
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