--- a/interface.c +++ b/interface.c @@ -727,3 +727,78 @@ COMMAND(switch, freq, "Switch the operating channel by sending a channel switch announcement (CSA)."); COMMAND(switch, channel, " [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons ] [block-tx]", NL80211_CMD_CHANNEL_SWITCH, 0, CIB_NETDEV, handle_chan, NULL); + +static int handle_retry_count(struct nl80211_state *state, + struct nl_msg *msg, + int argc, char **argv, + enum id_input id) +{ + struct nl_msg *tid = NULL; + unsigned char mac_addr[ETH_ALEN]; + uint8_t retry_short, retry_long, tid_no; + char *end; + int ret = -ENOSPC; + + if (argc < 4) + return 1; + + tid = nlmsg_alloc(); + if (!tid) + return -ENOMEM; + + while (argc) { + if (strcmp(argv[0], "tid") == 0) { + if (argc < 2) + return 1; + + tid_no = strtoul(argv[1], &end, 8); + if (*end) + return 1; + + NLA_PUT_U8(tid, NL80211_ATTR_TID, tid_no); + } else if (strcmp(argv[0], "peer") == 0) { + if (argc < 2) + return 1; + + if (mac_addr_a2n(mac_addr, argv[1])) { + fprintf(stderr, "invalid mac address\n"); + return 2; + } + + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); + } else if (strcmp(argv[0], "short") == 0) { + if (argc < 2) + return 1; + + retry_short = strtoul(argv[1], &end, 0); + if (*end) + return 1; + + NLA_PUT_U8(tid, NL80211_ATTR_TID_RETRY_SHORT, retry_short); + } else if (strcmp(argv[0], "long") == 0) { + if (argc < 2) + return 1; + retry_long = strtoul(argv[1], &end, 0); + if (*end) + return 1; + + NLA_PUT_U8(tid, NL80211_ATTR_TID_RETRY_LONG, retry_long); + } else { + return 1; + } + argc -= 2; + argv += 2; + } + + NLA_PUT_FLAG(tid, NL80211_ATTR_TID_RETRY_CONFIG); + nla_put_nested(msg, NL80211_ATTR_TID_CONFIG, tid); + + ret = 0; + +nla_put_failure: + nlmsg_free(tid); + return ret; +} +COMMAND(set, tid_retry_count, "tid <[peer ] short long ]>", + NL80211_CMD_SET_TID_CONFIG, 0, CIB_NETDEV, handle_retry_count, + "Set the retry count for the TIDs "); --- a/nl80211.h +++ b/nl80211.h @@ -1101,6 +1101,10 @@ * peer MAC address and %NL80211_ATTR_FRAME is used to specify the frame * content. The frame is ethernet data. * + * @NL80211_CMD_SET_TID_CONFIG: Data frame TID specific configuration + * is passed through this command using %NL80211_ATTR_TID_CONFIG + * nested attributes. + * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */ @@ -1325,6 +1329,8 @@ enum nl80211_commands { NL80211_CMD_PROBE_MESH_LINK, + NL80211_CMD_SET_TID_CONFIG, + /* add new commands above here */ /* used to define NL80211_CMD_MAX below */ @@ -2367,15 +2373,23 @@ enum nl80211_commands { * functionality. * * @NL80211_ATTR_WIPHY_EDMG_CHANNELS: bitmap that indicates the 2.16 GHz - * channel(s) that are allowed to be used for EDMG transmissions. - * Defined by IEEE P802.11ay/D4.0 section 9.4.2.251. (u8 attribute) + * channel(s) that are allowed to be used for EDMG transmissions. + * Defined by IEEE P802.11ay/D4.0 section 9.4.2.251. (u8 attribute) * @NL80211_ATTR_WIPHY_EDMG_BW_CONFIG: Channel BW Configuration subfield encodes - * the allowed channel bandwidth configurations. (u8 attribute) - * Defined by IEEE P802.11ay/D4.0 section 9.4.2.251, Table 13. + * the allowed channel bandwidth configurations. (u8 attribute) + * Defined by IEEE P802.11ay/D4.0 section 9.4.2.251, Table 13. + * + * @NL80211_ATTR_VLAN_ID: VLAN ID (1..4094) for the station and VLAN group key + * (u16). * * @NL80211_ATTR_WIPHY_ANTENNA_GAIN: Configured antenna gain. Used to reduce * transmit power to stay within regulatory limits. u32, dBi. * + * @NL80211_ATTR_TID_CONFIG: TID specific configuration in a + * nested attribute with %NL80211_ATTR_TID_* sub-attributes. + * @NL80211_ATTR_MAX_RETRY_COUNT: The upper limit for the retry count + * configuration that the driver can accept. + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -2838,6 +2852,11 @@ enum nl80211_attrs { NL80211_ATTR_WIPHY_EDMG_CHANNELS, NL80211_ATTR_WIPHY_EDMG_BW_CONFIG, + NL80211_ATTR_VLAN_ID, + + NL80211_ATTR_TID_CONFIG, + NL80211_ATTR_MAX_RETRY_COUNT, + NL80211_ATTR_WIPHY_ANTENNA_GAIN, /* add attributes here, update the policy in nl80211.c */ @@ -4601,7 +4620,55 @@ enum nl80211_ps_state { NL80211_PS_DISABLED, NL80211_PS_ENABLED, }; - +/* + * @NL80211_ATTR_TID: a TID value (u8 attribute) + * @NL80211_ATTR_TID_RETRY_CONFIG: Data frame retry count should be + * applied with the value passed through %NL80211_ATTR_RETRY_LONG + * and/or %NL80211_ATTR_RETRY_SHORT. This configuration is per-TID, + * TID is specified with %NL80211_ATTR_TID. If the peer MAC address + * is passed in %NL80211_ATTR_MAC, the retry configuration is applied + * to the data frame for the tid to that connected station. + * This attribute will be useful to notfiy the driver to apply default + * retry values for the connected station (%NL80211_ATTR_MAC), when the + * command received without %NL80211_ATTR_RETRY_LONG and/or + * %NL80211_ATTR_RETRY_SHORT. + * Station specific retry configuration is valid only for STA's + * current connection. i.e. the configuration will be reset to default when + * the station connects back after disconnection/roaming. + * when user-space does not include %NL80211_ATTR_MAC, this configuration + * should be treated as per-netdev configuration. This configuration will + * be cleared when the interface goes down and on the disconnection from a + * BSS. When retry count has never been configured using this command, the + * other available radio level retry configuration + * (%NL80211_ATTR_WIPHY_RETRY_SHORT and %NL80211_ATTR_WIPHY_RETRY_LONG) + * should be used. Driver supporting this feature should advertise + * NL80211_EXT_FEATURE_PER_TID_RETRY_CONFIG and supporting per station + * retry count configuration should advertise + * NL80211_EXT_FEATURE_PER_STA_RETRY_CONFIG. + * @NL80211_ATTR_TID_RETRY_SHORT: Number of retries used with data frame + * transmission, user-space sets this configuration in + * &NL80211_CMD_SET_TID_CONFIG. Its type is u8, min value is 1 and + * the max value should be advertised by the driver through + * max_data_retry_count. when this attribute is not present, the driver + * would use the default configuration. + * @NL80211_ATTR_TID_RETRY_LONG: Number of retries used with data frame + * transmission, user-space sets this configuration in + * &NL80211_CMD_SET_TID_CONFIG. Its type is u8, min value is 1 and + * the max value should be advertised by the driver through + * max_data_retry_count. when this attribute is not present, the driver + * would use the default configuration. + */ +enum nl80211_attr_tid_config { + __NL80211_ATTR_TID_INVALID, + NL80211_ATTR_TID, + NL80211_ATTR_TID_RETRY_CONFIG, + NL80211_ATTR_TID_RETRY_SHORT, + NL80211_ATTR_TID_RETRY_LONG, + + /* keep last */ + __NL80211_ATTR_TID_AFTER_LAST, + NL80211_ATTR_TID_MAX = __NL80211_ATTR_TID_AFTER_LAST - 1 +}; /** * enum nl80211_attr_cqm - connection quality monitor attributes * @__NL80211_ATTR_CQM_INVALID: invalid