Re: [PATCH 07/19] wifi: rtw88: fw: add the vendor firmware commands used by RTL8723BS

From: Bitterblue Smith

Date: Sat Jul 25 2026 - 06:21:43 EST


On 24/07/2026 21:18, luka.gejak@xxxxxxxxx wrote:
> From: Luka Gejak <luka.gejak@xxxxxxxxx>
>
> The RTL8723BS join and coexistence sequences need four commands that
> rtw88 does not implement: MACID_CFG to configure rate adaptation after
> association, the WL channel info report, the firmware GNT_BT state, and
> the coexistence antenna select reserve that forms part of the vendor
> initialisation toggle.

But rtw88 does implement the first two.

>
> Add them here so the coexistence and association changes that follow
> have the commands available.
>
> Signed-off-by: Luka Gejak <luka.gejak@xxxxxxxxx>
> ---
> drivers/net/wireless/realtek/rtw88/fw.c | 59 +++++++++++++++++++++++++
> drivers/net/wireless/realtek/rtw88/fw.h | 13 ++++++
> 2 files changed, 72 insertions(+)
>
> diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
> index 87da0dd82aaa..b43ee5d951fd 100644
> --- a/drivers/net/wireless/realtek/rtw88/fw.c
> +++ b/drivers/net/wireless/realtek/rtw88/fw.c
> @@ -856,6 +856,65 @@ void rtw_fw_media_status_report(struct rtw_dev *rtwdev, u8 mac_id, bool connect)
> rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
> }
>
> +/* 8723BS SDIO: post-assoc rate-adaptation config in the vendor v5.2.17
> + * MACID_CFG byte layout. disra (bit7 of [2]) must stay 0 so the firmware keeps
> + * running rate adaptation for this mac_id.
> + */
> +void rtw_fw_macid_cfg(struct rtw_dev *rtwdev, u8 mac_id, u8 raid, u8 bw,
> + u8 sgi, u32 rate_mask)
> +{
> + u8 h2c_pkt[H2C_PKT_SIZE] = {0};
> +
> + SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO);
> +
> + h2c_pkt[1] = mac_id & 0x7f;
> + h2c_pkt[2] = (raid & 0x1f) | (sgi ? BIT(7) : 0) | 0x60;
> + h2c_pkt[3] = (bw ? 3 : 1) & 0x3;
> + h2c_pkt[4] = rate_mask & 0xff;
> + h2c_pkt[5] = (rate_mask >> 8) & 0xff;
> + h2c_pkt[6] = (rate_mask >> 16) & 0xff;
> + h2c_pkt[7] = (rate_mask >> 24) & 0xff;
> +
> + rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
> +}
> +
> +/* 8723BS SDIO: report the connected channel/bandwidth to the vendor firmware. */
> +void rtw_fw_send_wl_ch_info(struct rtw_dev *rtwdev, u8 ch, u8 bw)
> +{
> + u8 h2c_pkt[H2C_PKT_SIZE] = {0};
> + u8 bw_byte = bw == RTW_CHANNEL_WIDTH_40 ? 0x30 : 0x20;
> +
> + SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_WL_CH_INFO);
> + h2c_pkt[1] = 0x00;
> + h2c_pkt[2] = ch;
> + h2c_pkt[3] = bw_byte;
> +
> + rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
> +}
> +
> +/* 8723BS SDIO: set the firmware GNT_BT state (0 = WiFi owns the antenna). */
> +void rtw_fw_set_gnt_bt(struct rtw_dev *rtwdev, u8 state)
> +{
> + u8 h2c_pkt[H2C_PKT_SIZE] = {0};
> +
> + SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_GNT_BT);
> + SET_GNT_BT_STATE(h2c_pkt, state);
> +
> + rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
> +}
> +
> +/* 8723BS SDIO: vendor coex antenna-select reserve H2C (part of the init toggle). */
> +void rtw_fw_coex_ant_sel_rsv(struct rtw_dev *rtwdev, u8 inverse, u8 type)
> +{
> + u8 h2c_pkt[H2C_PKT_SIZE] = {0};
> +
> + SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_COEX_ANT_SEL_RSV);
> + SET_COEX_ANT_SEL_RSV_INVERSE(h2c_pkt, inverse);
> + SET_COEX_ANT_SEL_RSV_TYPE(h2c_pkt, type);
> +
> + rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
> +}
> +
> void rtw_fw_update_wl_phy_info(struct rtw_dev *rtwdev)
> {
> struct rtw_traffic_stats *stats = &rtwdev->stats;
> diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h
> index 6927d2041d24..8b238b41decf 100644
> --- a/drivers/net/wireless/realtek/rtw88/fw.h
> +++ b/drivers/net/wireless/realtek/rtw88/fw.h
> @@ -572,10 +572,12 @@ static inline void rtw_h2c_pkt_set_header(u8 *h2c_pkt, u8 sub_id)
> #define H2C_CMD_QUERY_BT_INFO 0x61
> #define H2C_CMD_FORCE_BT_TX_POWER 0x62
> #define H2C_CMD_IGNORE_WLAN_ACTION 0x63
> +#define H2C_CMD_COEX_ANT_SEL_RSV 0x65
> #define H2C_CMD_WL_CH_INFO 0x66
> #define H2C_CMD_QUERY_BT_MP_INFO 0x67
> #define H2C_CMD_BT_WIFI_CONTROL 0x69
> #define H2C_CMD_WIFI_CALIBRATION 0x6d
> +#define H2C_CMD_GNT_BT 0x6e
> #define H2C_CMD_QUERY_BT_HID_INFO 0x73
>
> #define H2C_CMD_KEEP_ALIVE 0x03
> @@ -688,6 +690,12 @@ static inline void rtw_h2c_pkt_set_header(u8 *h2c_pkt, u8 sub_id)
> le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(31, 24))
> #define SET_QUERY_BT_INFO(h2c_pkt, value) \
> le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
> +#define SET_GNT_BT_STATE(h2c_pkt, value) \
> + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
> +#define SET_COEX_ANT_SEL_RSV_INVERSE(h2c_pkt, value) \
> + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
> +#define SET_COEX_ANT_SEL_RSV_TYPE(h2c_pkt, value) \
> + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
> #define SET_WL_CH_INFO_LINK(h2c_pkt, value) \
> le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
> #define SET_WL_CH_INFO_CHNL(h2c_pkt, value) \
> @@ -853,6 +861,11 @@ void rtw_fw_send_rssi_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si);
> void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
> bool reset_ra_mask);
> void rtw_fw_media_status_report(struct rtw_dev *rtwdev, u8 mac_id, bool conn);
> +void rtw_fw_macid_cfg(struct rtw_dev *rtwdev, u8 mac_id, u8 raid, u8 bw,
> + u8 sgi, u32 rate_mask);
> +void rtw_fw_send_wl_ch_info(struct rtw_dev *rtwdev, u8 ch, u8 bw);
> +void rtw_fw_set_gnt_bt(struct rtw_dev *rtwdev, u8 state);
> +void rtw_fw_coex_ant_sel_rsv(struct rtw_dev *rtwdev, u8 inverse, u8 type);
> void rtw_fw_update_wl_phy_info(struct rtw_dev *rtwdev);
> void rtw_fw_beacon_filter_config(struct rtw_dev *rtwdev, bool connect,
> struct ieee80211_vif *vif);