Commit 85eacdca authored by Ping-Ke Shih's avatar Ping-Ke Shih Committed by Kalle Valo

wifi: rtw89: fw: use struct to fill JOIN H2C command

The JOIN command is used to tell firmware an new station is joining, and
create an entry for it. This patch is only to convert to set data via
struct, and don't change logic at all.
Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240115033742.16372-8-pkshih@realtek.com
parent 011e2768
...@@ -2904,7 +2904,6 @@ int rtw89_fw_h2c_role_maintain(struct rtw89_dev *rtwdev, ...@@ -2904,7 +2904,6 @@ int rtw89_fw_h2c_role_maintain(struct rtw89_dev *rtwdev,
return ret; return ret;
} }
#define H2C_JOIN_INFO_LEN 4
int rtw89_fw_h2c_join_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, int rtw89_fw_h2c_join_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
struct rtw89_sta *rtwsta, bool dis_conn) struct rtw89_sta *rtwsta, bool dis_conn)
{ {
...@@ -2912,6 +2911,8 @@ int rtw89_fw_h2c_join_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, ...@@ -2912,6 +2911,8 @@ int rtw89_fw_h2c_join_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
u8 mac_id = rtwsta ? rtwsta->mac_id : rtwvif->mac_id; u8 mac_id = rtwsta ? rtwsta->mac_id : rtwvif->mac_id;
u8 self_role = rtwvif->self_role; u8 self_role = rtwvif->self_role;
u8 net_type = rtwvif->net_type; u8 net_type = rtwvif->net_type;
struct rtw89_h2c_join *h2c;
u32 len = sizeof(*h2c);
int ret; int ret;
if (net_type == RTW89_NET_TYPE_AP_MODE && rtwsta) { if (net_type == RTW89_NET_TYPE_AP_MODE && rtwsta) {
...@@ -2919,30 +2920,32 @@ int rtw89_fw_h2c_join_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, ...@@ -2919,30 +2920,32 @@ int rtw89_fw_h2c_join_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
net_type = dis_conn ? RTW89_NET_TYPE_NO_LINK : net_type; net_type = dis_conn ? RTW89_NET_TYPE_NO_LINK : net_type;
} }
skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, H2C_JOIN_INFO_LEN); skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, len);
if (!skb) { if (!skb) {
rtw89_err(rtwdev, "failed to alloc skb for h2c join\n"); rtw89_err(rtwdev, "failed to alloc skb for h2c join\n");
return -ENOMEM; return -ENOMEM;
} }
skb_put(skb, H2C_JOIN_INFO_LEN); skb_put(skb, len);
SET_JOININFO_MACID(skb->data, mac_id); h2c = (struct rtw89_h2c_join *)skb->data;
SET_JOININFO_OP(skb->data, dis_conn);
SET_JOININFO_BAND(skb->data, rtwvif->mac_idx); h2c->w0 = le32_encode_bits(mac_id, RTW89_H2C_JOININFO_W0_MACID) |
SET_JOININFO_WMM(skb->data, rtwvif->wmm); le32_encode_bits(dis_conn, RTW89_H2C_JOININFO_W0_OP) |
SET_JOININFO_TGR(skb->data, rtwvif->trigger); le32_encode_bits(rtwvif->mac_idx, RTW89_H2C_JOININFO_W0_BAND) |
SET_JOININFO_ISHESTA(skb->data, 0); le32_encode_bits(rtwvif->wmm, RTW89_H2C_JOININFO_W0_WMM) |
SET_JOININFO_DLBW(skb->data, 0); le32_encode_bits(rtwvif->trigger, RTW89_H2C_JOININFO_W0_TGR) |
SET_JOININFO_TF_MAC_PAD(skb->data, 0); le32_encode_bits(0, RTW89_H2C_JOININFO_W0_ISHESTA) |
SET_JOININFO_DL_T_PE(skb->data, 0); le32_encode_bits(0, RTW89_H2C_JOININFO_W0_DLBW) |
SET_JOININFO_PORT_ID(skb->data, rtwvif->port); le32_encode_bits(0, RTW89_H2C_JOININFO_W0_TF_MAC_PAD) |
SET_JOININFO_NET_TYPE(skb->data, net_type); le32_encode_bits(0, RTW89_H2C_JOININFO_W0_DL_T_PE) |
SET_JOININFO_WIFI_ROLE(skb->data, rtwvif->wifi_role); le32_encode_bits(rtwvif->port, RTW89_H2C_JOININFO_W0_PORT_ID) |
SET_JOININFO_SELF_ROLE(skb->data, self_role); le32_encode_bits(net_type, RTW89_H2C_JOININFO_W0_NET_TYPE) |
le32_encode_bits(rtwvif->wifi_role, RTW89_H2C_JOININFO_W0_WIFI_ROLE) |
le32_encode_bits(self_role, RTW89_H2C_JOININFO_W0_SELF_ROLE);
rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C, rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C,
H2C_CAT_MAC, H2C_CL_MAC_MEDIA_RPT, H2C_CAT_MAC, H2C_CL_MAC_MEDIA_RPT,
H2C_FUNC_MAC_JOININFO, 0, 1, H2C_FUNC_MAC_JOININFO, 0, 1,
H2C_JOIN_INFO_LEN); len);
ret = rtw89_h2c_tx(rtwdev, skb, false); ret = rtw89_h2c_tx(rtwdev, skb, false);
if (ret) { if (ret) {
......
...@@ -1747,70 +1747,23 @@ static inline void SET_FWROLE_MAINTAIN_WIFI_ROLE(void *h2c, u32 val) ...@@ -1747,70 +1747,23 @@ static inline void SET_FWROLE_MAINTAIN_WIFI_ROLE(void *h2c, u32 val)
le32p_replace_bits((__le32 *)h2c, val, GENMASK(16, 13)); le32p_replace_bits((__le32 *)h2c, val, GENMASK(16, 13));
} }
static inline void SET_JOININFO_MACID(void *h2c, u32 val) struct rtw89_h2c_join {
{ __le32 w0;
le32p_replace_bits((__le32 *)h2c, val, GENMASK(7, 0)); } __packed;
}
static inline void SET_JOININFO_OP(void *h2c, u32 val)
{
le32p_replace_bits((__le32 *)h2c, val, BIT(8));
}
static inline void SET_JOININFO_BAND(void *h2c, u32 val)
{
le32p_replace_bits((__le32 *)h2c, val, BIT(9));
}
static inline void SET_JOININFO_WMM(void *h2c, u32 val)
{
le32p_replace_bits((__le32 *)h2c, val, GENMASK(11, 10));
}
static inline void SET_JOININFO_TGR(void *h2c, u32 val)
{
le32p_replace_bits((__le32 *)h2c, val, BIT(12));
}
static inline void SET_JOININFO_ISHESTA(void *h2c, u32 val)
{
le32p_replace_bits((__le32 *)h2c, val, BIT(13));
}
static inline void SET_JOININFO_DLBW(void *h2c, u32 val)
{
le32p_replace_bits((__le32 *)h2c, val, GENMASK(15, 14));
}
static inline void SET_JOININFO_TF_MAC_PAD(void *h2c, u32 val)
{
le32p_replace_bits((__le32 *)h2c, val, GENMASK(17, 16));
}
static inline void SET_JOININFO_DL_T_PE(void *h2c, u32 val)
{
le32p_replace_bits((__le32 *)h2c, val, GENMASK(20, 18));
}
static inline void SET_JOININFO_PORT_ID(void *h2c, u32 val)
{
le32p_replace_bits((__le32 *)h2c, val, GENMASK(23, 21));
}
static inline void SET_JOININFO_NET_TYPE(void *h2c, u32 val)
{
le32p_replace_bits((__le32 *)h2c, val, GENMASK(25, 24));
}
static inline void SET_JOININFO_WIFI_ROLE(void *h2c, u32 val)
{
le32p_replace_bits((__le32 *)h2c, val, GENMASK(29, 26));
}
static inline void SET_JOININFO_SELF_ROLE(void *h2c, u32 val) #define RTW89_H2C_JOININFO_W0_MACID GENMASK(7, 0)
{ #define RTW89_H2C_JOININFO_W0_OP BIT(8)
le32p_replace_bits((__le32 *)h2c, val, GENMASK(31, 30)); #define RTW89_H2C_JOININFO_W0_BAND BIT(9)
} #define RTW89_H2C_JOININFO_W0_WMM GENMASK(11, 10)
#define RTW89_H2C_JOININFO_W0_TGR BIT(12)
#define RTW89_H2C_JOININFO_W0_ISHESTA BIT(13)
#define RTW89_H2C_JOININFO_W0_DLBW GENMASK(15, 14)
#define RTW89_H2C_JOININFO_W0_TF_MAC_PAD GENMASK(17, 16)
#define RTW89_H2C_JOININFO_W0_DL_T_PE GENMASK(20, 18)
#define RTW89_H2C_JOININFO_W0_PORT_ID GENMASK(23, 21)
#define RTW89_H2C_JOININFO_W0_NET_TYPE GENMASK(25, 24)
#define RTW89_H2C_JOININFO_W0_WIFI_ROLE GENMASK(29, 26)
#define RTW89_H2C_JOININFO_W0_SELF_ROLE GENMASK(31, 30)
struct rtw89_h2c_notify_dbcc { struct rtw89_h2c_notify_dbcc {
__le32 w0; __le32 w0;
......
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