Since nl80211 requires valid link id (NL80211_FLAG_MLO_VALID_LINK_ID), support link-id field for MLD. For non-MLD, just as before, no need to assign link-id field. Signed-off-by: Zong-Zhe Yang --- bitrate.c | 29 +++++++++++++++++++++++++++-- interface.c | 32 +++++++++++++++++++++++++++----- iw.h | 2 +- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/bitrate.c b/bitrate.c index 16f118cce4ec..78d399d227e2 100644 --- a/bitrate.c +++ b/bitrate.c @@ -195,7 +195,7 @@ static int parse_eht_gi(char *eht_gi) int set_bitrates(struct nl_msg *msg, int argc, char **argv, - enum nl80211_attrs attr) + enum nl80211_attrs attr, int *link_id) { struct nlattr *nl_rates, *nl_band; int i, ret = 0; @@ -242,6 +242,7 @@ int set_bitrates(struct nl_msg *msg, char *he_gi_argv = NULL; int eht_gi = 0, eht_ltf = 0; char *eht_gi_argv = NULL; + bool has_link_id = false; enum { S_NONE, @@ -250,6 +251,7 @@ int set_bitrates(struct nl_msg *msg, S_VHT, S_HE, S_EHT, + S_LINK_ID, S_GI, S_HE_GI, S_HE_LTF, @@ -347,6 +349,11 @@ int set_bitrates(struct nl_msg *msg, eht_argv = eht_argv_6; eht_argc = &eht_argc_6; have_eht_mcs_6 = true; + } else if (strcmp(argv[i], "link-id") == 0) { + if (has_link_id) + return 1; + parser_state = S_LINK_ID; + has_link_id = true; } else if (strcmp(argv[i], "sgi-2.4") == 0) { sgi_24 = 1; parser_state = S_GI; @@ -427,6 +434,11 @@ int set_bitrates(struct nl_msg *msg, return 1; eht_argv[(*eht_argc)++] = argv[i]; break; + case S_LINK_ID: + *link_id = strtol(argv[i], &end, 0); + if (*end != '\0') + return 1; + break; case S_GI: break; case S_HE_GI: @@ -618,7 +630,20 @@ static int handle_bitrates(struct nl80211_state *state, int argc, char **argv, enum id_input id) { - return set_bitrates(msg, argc, argv, NL80211_ATTR_TX_RATES); + int link_id = -1; + int ret; + + ret = set_bitrates(msg, argc, argv, NL80211_ATTR_TX_RATES, &link_id); + if (ret) + return ret; + + if (link_id >= 0) + NLA_PUT_U8(msg, NL80211_ATTR_MLO_LINK_ID, link_id); + + return 0; + + nla_put_failure: + return -ENOBUFS; } #define DESCR_LEGACY "[legacy-<2.4|5> *]" diff --git a/interface.c b/interface.c index 65a4006963e5..0f1e9647f0e4 100644 --- a/interface.c +++ b/interface.c @@ -796,10 +796,11 @@ static int toggle_tid_param(const char *argv0, const char *argv1, return -ENOBUFS; } -static int handle_tid_config(struct nl80211_state *state, - struct nl_msg *msg, - int argc, char **argv, - enum id_input id) +static int __handle_tid_config(struct nl80211_state *state, + struct nl_msg *msg, + int argc, char **argv, + enum id_input id, + int *link_id) { struct nlattr *tids_array = NULL; struct nlattr *tids_entry = NULL; @@ -989,7 +990,7 @@ static int handle_tid_config(struct nl80211_state *state, if (txrate_type != NL80211_TX_RATE_AUTOMATIC) { attr = NL80211_TID_CONFIG_ATTR_TX_RATE; ret = set_bitrates(msg, argc, argv, - attr); + attr, link_id); if (ret < 2) return 1; @@ -1020,6 +1021,27 @@ nla_put_failure: return -ENOBUFS; } +static int handle_tid_config(struct nl80211_state *state, + struct nl_msg *msg, + int argc, char **argv, + enum id_input id) +{ + int link_id = -1; + int ret; + + ret = __handle_tid_config(state, msg, argc, argv, id, &link_id); + if (ret) + return ret; + + if (link_id >= 0) + NLA_PUT_U8(msg, NL80211_ATTR_MLO_LINK_ID, link_id); + + return 0; + + nla_put_failure: + return -ENOBUFS; +} + COMMAND(set, tidconf, "[peer ] tids [override] [sretry ] [lretry ] " "[ampdu [on|off]] [amsdu [on|off]] [noack [on|off]] [rtscts [on|off]]" "[bitrates [legacy-<2.4|5> *] [ht-mcs-<2.4|5> *]" diff --git a/iw.h b/iw.h index 145b058d86ba..5c4ab6b0b38e 100644 --- a/iw.h +++ b/iw.h @@ -302,7 +302,7 @@ void nan_bf(uint8_t idx, uint8_t *bf, uint16_t bf_len, const uint8_t *buf, char *hex2bin(const char *hex, char *buf); int set_bitrates(struct nl_msg *msg, int argc, char **argv, - enum nl80211_attrs attr); + enum nl80211_attrs attr, int *link_id); int calc_s1g_ch_center_freq(__u8 ch_index, __u8 s1g_oper_class); -- 2.39.0