1: bd85cab0820e < -: ------------ wifi: nl80211: vendor-cmd: add NXP vendor command definitions -: ------------ > 1: 690d86feab04 wifi: nl80211: vendor-cmd: add NXP vendor command definitions 2: 792480fef7c7 ! 2: a93ba79f4092 wifi: nxpwifi: add firmware TRPC command support @@ Metadata ## Commit message ## wifi: nxpwifi: add firmware TRPC command support  - Add support for the firmware channel TRPC configuration command used to + Add support for the firmware TRPC configuration command used to retrieve and update TX power limit data.  Assisted-by: LLM @@ drivers/net/wireless/nxp/nxpwifi/sta_cmd.c: nxpwifi_ret_sta_twt_cfg(struct nxpwi  + u16 resp_len;  +  + if (resp_size < S_DS_GEN) -+ return -EINVAL; ++ return -EIO;  +  + resp_len = resp_size - S_DS_GEN;  + /* The firmware response contains action, subband, and TRPC @@ drivers/net/wireless/nxp/nxpwifi/sta_cmd.c: nxpwifi_ret_sta_twt_cfg(struct nxpwi  + NXPWIFI_MAX_TRPC_BUF) {  + nxpwifi_dbg(priv->adapter, ERROR,  + "chan_trpc bad resp len: %u\n", resp_len); -+ return -EINVAL; ++ return -EIO;  + }  +  + usr_chan_trpc_cfg->len = resp_len; 3: 2839ca529dbb ! 3: d8310956d61a wifi: nxpwifi: add netlink vendor command for TX power limits @@ drivers/net/wireless/nxp/nxpwifi/vendor.c (new)  +  +/* Attributes for NXP_VENDOR_CMD_TXPOWER_LIMIT. */  +static const struct nla_policy -+nxpwifi_txpwr_policy[NXP_ATTR_TXPWR_MAX + 1] = { -+ [NXP_ATTR_TXPWR_ACTION] = NLA_POLICY_MAX(NLA_U8, -+ NXP_TXPWR_ACTION_SET), -+ [NXP_ATTR_TXPWR_SUBBAND] = { .type = NLA_U8 }, -+ [NXP_ATTR_TXPWR_DATA] = { .type = NLA_BINARY, -+ .len = NXPWIFI_MAX_TRPC_BUF }, ++nxpwifi_txpwrlimit_policy[NXP_ATTR_TXPWRLIMIT_MAX + 1] = { ++ [NXP_ATTR_TXPWRLIMIT_ACTION] = ++ NLA_POLICY_MAX(NLA_U8, NXP_TXPWRLIMIT_ACTION_SET), ++ [NXP_ATTR_TXPWRLIMIT_SUBBAND] = { .type = NLA_U8 }, ++ [NXP_ATTR_TXPWRLIMIT_DATA] = { .type = NLA_BINARY, ++ .len = NXPWIFI_MAX_TRPC_BUF },  +};  + -+static bool nxpwifi_txpwr_subband_valid(u8 subband) ++static bool nxpwifi_txpwrlimit_subband_valid(u8 subband)  +{  + switch (subband) { -+ case NXP_TXPWR_SUBBAND_2G: -+ case NXP_TXPWR_SUBBAND_5G_0: -+ case NXP_TXPWR_SUBBAND_5G_1: -+ case NXP_TXPWR_SUBBAND_5G_2: -+ case NXP_TXPWR_SUBBAND_5G_3: ++ case NXP_TXPWRLIMIT_SUBBAND_2G: ++ case NXP_TXPWRLIMIT_SUBBAND_5G_0: ++ case NXP_TXPWRLIMIT_SUBBAND_5G_1: ++ case NXP_TXPWRLIMIT_SUBBAND_5G_2: ++ case NXP_TXPWRLIMIT_SUBBAND_5G_3:  + return true;  + default:  + return false; @@ drivers/net/wireless/nxp/nxpwifi/vendor.c (new)  + const void *data, int data_len)  +{  + struct nxpwifi_adapter *adapter = nxpwifi_cfg80211_get_adapter(wiphy); -+ struct nlattr *tb[NXP_ATTR_TXPWR_MAX + 1]; ++ struct nlattr *tb[NXP_ATTR_TXPWRLIMIT_MAX + 1];  + struct nxpwifi_ds_chan_trpc_cfg *ch_trpc;  + struct nxpwifi_private *priv;  + struct sk_buff *resp; @@ drivers/net/wireless/nxp/nxpwifi/vendor.c (new)  + u16 tlv_len = 0;  + int ret;  + -+ ret = nla_parse(tb, NXP_ATTR_TXPWR_MAX, data, data_len, -+ nxpwifi_txpwr_policy, NULL); ++ ret = nla_parse(tb, NXP_ATTR_TXPWRLIMIT_MAX, data, data_len, ++ nxpwifi_txpwrlimit_policy, NULL);  + if (ret)  + return ret;  + -+ if (!tb[NXP_ATTR_TXPWR_ACTION]) ++ if (!tb[NXP_ATTR_TXPWRLIMIT_ACTION])  + return -EINVAL; -+ action = nla_get_u8(tb[NXP_ATTR_TXPWR_ACTION]); ++ action = nla_get_u8(tb[NXP_ATTR_TXPWRLIMIT_ACTION]);  + -+ if (tb[NXP_ATTR_TXPWR_SUBBAND]) { -+ subband = nla_get_u8(tb[NXP_ATTR_TXPWR_SUBBAND]); -+ if (!nxpwifi_txpwr_subband_valid(subband)) ++ if (tb[NXP_ATTR_TXPWRLIMIT_SUBBAND]) { ++ subband = nla_get_u8(tb[NXP_ATTR_TXPWRLIMIT_SUBBAND]); ++ if (!nxpwifi_txpwrlimit_subband_valid(subband))  + return -EINVAL; -+ } else if (action == NXP_TXPWR_ACTION_GET) { ++ } else if (action == NXP_TXPWRLIMIT_ACTION_GET) {  + /* A subband selector is required for GET operations. */  + return -EINVAL;  + }  + -+ if (action == NXP_TXPWR_ACTION_SET) { -+ if (!tb[NXP_ATTR_TXPWR_DATA]) ++ if (action == NXP_TXPWRLIMIT_ACTION_SET) { ++ if (!tb[NXP_ATTR_TXPWRLIMIT_DATA])  + return -EINVAL; -+ tlv_len = nla_len(tb[NXP_ATTR_TXPWR_DATA]); ++ tlv_len = nla_len(tb[NXP_ATTR_TXPWRLIMIT_DATA]);  + }  +  + priv = nxpwifi_get_priv(adapter, NXPWIFI_BSS_ROLE_STA); @@ drivers/net/wireless/nxp/nxpwifi/vendor.c (new)  +  + /* Reserve space for the returned TRPC table on GET requests. */  + ch_trpc = kzalloc_flex(*ch_trpc, tlvbuffer, -+ (action == NXP_TXPWR_ACTION_SET) ? ++ (action == NXP_TXPWRLIMIT_ACTION_SET) ?  + tlv_len : NXPWIFI_MAX_TRPC_BUF, GFP_KERNEL);  + if (!ch_trpc)  + return -ENOMEM;  + -+ ch_trpc->action = (action == NXP_TXPWR_ACTION_SET) ? ++ ch_trpc->action = (action == NXP_TXPWRLIMIT_ACTION_SET) ?  + HOST_ACT_GEN_SET : HOST_ACT_GEN_GET;  + ch_trpc->subband = subband;  +  + if (tlv_len)  + memcpy(ch_trpc->tlvbuffer, -+ nla_data(tb[NXP_ATTR_TXPWR_DATA]), tlv_len); ++ nla_data(tb[NXP_ATTR_TXPWRLIMIT_DATA]), tlv_len);  +  + ch_trpc->len = sizeof(ch_trpc->action) + sizeof(ch_trpc->subband) +  + tlv_len; @@ drivers/net/wireless/nxp/nxpwifi/vendor.c (new)  + if (ret)  + goto done;  + -+ if (action == NXP_TXPWR_ACTION_GET) { ++ if (action == NXP_TXPWRLIMIT_ACTION_GET) {  + u16 hdr_len = sizeof(ch_trpc->action) +  + sizeof(ch_trpc->subband);  + u16 resp_len, skb_len; @@ drivers/net/wireless/nxp/nxpwifi/vendor.c (new)  + goto done;  + }  + -+ if (nla_put(resp, NXP_ATTR_TXPWR_DATA, resp_len, ++ if (nla_put(resp, NXP_ATTR_TXPWRLIMIT_DATA, resp_len,  + ch_trpc->tlvbuffer)) {  + kfree_skb(resp);  + ret = -ENOBUFS; @@ drivers/net/wireless/nxp/nxpwifi/vendor.c (new)  + },  + .flags = 0,  + .doit = nxpwifi_vendor_txpower_limit, -+ .policy = nxpwifi_txpwr_policy, -+ .maxattr = NXP_ATTR_TXPWR_MAX, ++ .policy = nxpwifi_txpwrlimit_policy, ++ .maxattr = NXP_ATTR_TXPWRLIMIT_MAX,  + },  +};  +