+++ /dev/null
---- a/include/net/cfg80211.h
-+++ b/include/net/cfg80211.h
-@@ -4084,6 +4084,7 @@ struct mgmt_frame_regs {
- * (as advertised by the nl80211 feature flag.)
- * @get_tx_power: store the current TX power into the dbm variable;
- * return 0 if successful
-+ * @set_antenna_gain: set antenna gain to reduce maximum tx power if necessary
- *
- * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
- * functions to adjust rfkill hw state
-@@ -4434,6 +4435,7 @@ struct cfg80211_ops {
- enum nl80211_tx_power_setting type, int mbm);
- int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
- int *dbm);
-+ int (*set_antenna_gain)(struct wiphy *wiphy, int dbi);
-
- void (*rfkill_poll)(struct wiphy *wiphy);
-
---- a/include/net/mac80211.h
-+++ b/include/net/mac80211.h
-@@ -1677,6 +1677,7 @@ enum ieee80211_smps_mode {
- *
- * @power_level: requested transmit power (in dBm), backward compatibility
- * value only that is set to the minimum of all interfaces
-+ * @max_antenna_gain: maximum antenna gain adjusted by user config (in dBi)
- *
- * @chandef: the channel definition to tune to
- * @radar_enabled: whether radar detection is enabled
-@@ -1697,6 +1698,7 @@ enum ieee80211_smps_mode {
- struct ieee80211_conf {
- u32 flags;
- int power_level, dynamic_ps_timeout;
-+ int max_antenna_gain;
-
- u16 listen_interval;
- u8 ps_dtim_period;
---- a/include/uapi/linux/nl80211.h
-+++ b/include/uapi/linux/nl80211.h
-@@ -2749,6 +2749,9 @@ enum nl80211_commands {
- * When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the ack RX
- * timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates
- * the incoming frame RX timestamp.
-+ * @NL80211_ATTR_WIPHY_ANTENNA_GAIN: Configured antenna gain. Used to reduce
-+ * transmit power to stay within regulatory limits. u32, dBi.
-+ *
- * @NUM_NL80211_ATTR: total number of nl80211_attrs available
- * @NL80211_ATTR_MAX: highest attribute number currently defined
- * @__NL80211_ATTR_AFTER_LAST: internal use
-@@ -3277,6 +3280,8 @@ enum nl80211_attrs {
- NL80211_ATTR_TX_HW_TIMESTAMP,
- NL80211_ATTR_RX_HW_TIMESTAMP,
-
-+ NL80211_ATTR_WIPHY_ANTENNA_GAIN,
-+
- /* add attributes here, update the policy in nl80211.c */
-
- __NL80211_ATTR_AFTER_LAST,
---- a/net/mac80211/cfg.c
-+++ b/net/mac80211/cfg.c
-@@ -3046,6 +3046,19 @@ static int ieee80211_get_tx_power(struct
- return 0;
- }
-
-+static int ieee80211_set_antenna_gain(struct wiphy *wiphy, int dbi)
-+{
-+ struct ieee80211_local *local = wiphy_priv(wiphy);
-+
-+ if (dbi < 0)
-+ return -EINVAL;
-+
-+ local->user_antenna_gain = dbi;
-+ ieee80211_hw_config(local, 0);
-+
-+ return 0;
-+}
-+
- static void ieee80211_rfkill_poll(struct wiphy *wiphy)
- {
- struct ieee80211_local *local = wiphy_priv(wiphy);
-@@ -4956,6 +4969,7 @@ const struct cfg80211_ops mac80211_confi
- .set_wiphy_params = ieee80211_set_wiphy_params,
- .set_tx_power = ieee80211_set_tx_power,
- .get_tx_power = ieee80211_get_tx_power,
-+ .set_antenna_gain = ieee80211_set_antenna_gain,
- .rfkill_poll = ieee80211_rfkill_poll,
- CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
- CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
---- a/net/mac80211/ieee80211_i.h
-+++ b/net/mac80211/ieee80211_i.h
-@@ -1542,6 +1542,7 @@ struct ieee80211_local {
- int dynamic_ps_forced_timeout;
-
- int user_power_level; /* in dBm, for all interfaces */
-+ int user_antenna_gain; /* in dBi */
-
- enum ieee80211_smps_mode smps_mode;
-
---- a/net/mac80211/main.c
-+++ b/net/mac80211/main.c
-@@ -96,7 +96,7 @@ static u32 ieee80211_hw_conf_chan(struct
- struct ieee80211_sub_if_data *sdata;
- struct cfg80211_chan_def chandef = {};
- u32 changed = 0;
-- int power;
-+ int power, max_power;
- u32 offchannel_flag;
-
- offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL;
-@@ -157,6 +157,12 @@ static u32 ieee80211_hw_conf_chan(struct
- }
- rcu_read_unlock();
-
-+ max_power = chandef.chan->max_reg_power;
-+ if (local->user_antenna_gain > 0) {
-+ max_power -= local->user_antenna_gain;
-+ power = min(power, max_power);
-+ }
-+
- if (local->hw.conf.power_level != power) {
- changed |= IEEE80211_CONF_CHANGE_POWER;
- local->hw.conf.power_level = power;
-@@ -762,6 +768,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_
- IEEE80211_RADIOTAP_MCS_HAVE_BW;
- local->hw.radiotap_vht_details = IEEE80211_RADIOTAP_VHT_KNOWN_GI |
- IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH;
-+ local->user_antenna_gain = 0;
- local->hw.uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES;
- local->hw.uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN;
- local->hw.max_mtu = IEEE80211_MAX_DATA_LEN;
---- a/net/wireless/nl80211.c
-+++ b/net/wireless/nl80211.c
-@@ -799,6 +799,7 @@ static const struct nla_policy nl80211_p
- [NL80211_ATTR_MLD_ADDR] = NLA_POLICY_EXACT_LEN(ETH_ALEN),
- [NL80211_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG },
- [NL80211_ATTR_MAX_NUM_AKM_SUITES] = { .type = NLA_REJECT },
-+ [NL80211_ATTR_WIPHY_ANTENNA_GAIN] = { .type = NLA_U32 },
- };
-
- /* policy for the key attributes */
-@@ -3511,6 +3512,22 @@ static int nl80211_set_wiphy(struct sk_b
- if (result)
- goto out;
- }
-+
-+ if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_GAIN]) {
-+ int idx, dbi = 0;
-+
-+ if (!rdev->ops->set_antenna_gain) {
-+ result = -EOPNOTSUPP;
-+ goto out;
-+ }
-+
-+ idx = NL80211_ATTR_WIPHY_ANTENNA_GAIN;
-+ dbi = nla_get_u32(info->attrs[idx]);
-+
-+ result = rdev->ops->set_antenna_gain(&rdev->wiphy, dbi);
-+ if (result)
-+ goto out;
-+ }
-
- if (info->attrs[NL80211_ATTR_WIPHY_TX_POWER_SETTING]) {
- struct wireless_dev *txp_wdev = wdev;
+++ /dev/null
---- a/nl80211.h
-+++ b/nl80211.h
-@@ -324,6 +324,17 @@
- */
-
- /**
-+ * DOC: Multi-Link Operation
-+ *
-+ * In Multi-Link Operation, a connection between to MLDs utilizes multiple
-+ * links. To use this in nl80211, various commands and responses now need
-+ * to or will include the new %NL80211_ATTR_MLO_LINKS attribute.
-+ * Additionally, various commands that need to operate on a specific link
-+ * now need to be given the %NL80211_ATTR_MLO_LINK_ID attribute, e.g. to
-+ * use %NL80211_CMD_START_AP or similar functions.
-+ */
-+
-+/**
- * enum nl80211_commands - supported nl80211 commands
- *
- * @NL80211_CMD_UNSPEC: unspecified command to catch errors
-@@ -366,14 +377,22 @@
- * the non-transmitting interfaces are deleted as well.
- *
- * @NL80211_CMD_GET_KEY: Get sequence counter information for a key specified
-- * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC.
-+ * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC. %NL80211_ATTR_MAC
-+ * represents peer's MLD address for MLO pairwise key. For MLO group key,
-+ * the link is identified by %NL80211_ATTR_MLO_LINK_ID.
- * @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT,
- * %NL80211_ATTR_KEY_DEFAULT_MGMT, or %NL80211_ATTR_KEY_THRESHOLD.
-+ * For MLO connection, the link to set default key is identified by
-+ * %NL80211_ATTR_MLO_LINK_ID.
- * @NL80211_CMD_NEW_KEY: add a key with given %NL80211_ATTR_KEY_DATA,
- * %NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC, %NL80211_ATTR_KEY_CIPHER,
-- * and %NL80211_ATTR_KEY_SEQ attributes.
-+ * and %NL80211_ATTR_KEY_SEQ attributes. %NL80211_ATTR_MAC represents
-+ * peer's MLD address for MLO pairwise key. The link to add MLO
-+ * group key is identified by %NL80211_ATTR_MLO_LINK_ID.
- * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
-- * or %NL80211_ATTR_MAC.
-+ * or %NL80211_ATTR_MAC. %NL80211_ATTR_MAC represents peer's MLD address
-+ * for MLO pairwise key. The link to delete group key is identified by
-+ * %NL80211_ATTR_MLO_LINK_ID.
- *
- * @NL80211_CMD_GET_BEACON: (not used)
- * @NL80211_CMD_SET_BEACON: change the beacon on an access point interface
-@@ -753,6 +772,13 @@
- * %NL80211_ATTR_CSA_C_OFFSETS_TX is an array of offsets to CSA
- * counters which will be updated to the current value. This attribute
- * is used during CSA period.
-+ * For TX on an MLD, the frequency can be omitted and the link ID be
-+ * specified, or if transmitting to a known peer MLD (with MLD addresses
-+ * in the frame) both can be omitted and the link will be selected by
-+ * lower layers.
-+ * For RX notification, %NL80211_ATTR_RX_HW_TIMESTAMP may be included to
-+ * indicate the frame RX timestamp and %NL80211_ATTR_TX_HW_TIMESTAMP may
-+ * be included to indicate the ack TX timestamp.
- * @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this
- * command may be used with the corresponding cookie to cancel the wait
- * time if it is known that it is no longer necessary. This command is
-@@ -763,7 +789,9 @@
- * transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies
- * the TX command and %NL80211_ATTR_FRAME includes the contents of the
- * frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged
-- * the frame.
-+ * the frame. %NL80211_ATTR_TX_HW_TIMESTAMP may be included to indicate the
-+ * tx timestamp and %NL80211_ATTR_RX_HW_TIMESTAMP may be included to
-+ * indicate the ack RX timestamp.
- * @NL80211_CMD_ACTION_TX_STATUS: Alias for @NL80211_CMD_FRAME_TX_STATUS for
- * backward compatibility.
- *
-@@ -1108,6 +1136,12 @@
- * has been received. %NL80211_ATTR_FRAME is used to specify the
- * frame contents. The frame is the raw EAPoL data, without ethernet or
- * 802.11 headers.
-+ * For an MLD transmitter, the %NL80211_ATTR_MLO_LINK_ID may be given and
-+ * its effect will depend on the destination: If the destination is known
-+ * to be an MLD, this will be used as a hint to select the link to transmit
-+ * the frame on. If the destination is not an MLD, this will select both
-+ * the link to transmit on and the source address will be set to the link
-+ * address of that link.
- * When used as an event indication %NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
- * %NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT and %NL80211_ATTR_MAC are added
- * indicating the protocol type of the received frame; whether the frame
-@@ -1237,6 +1271,16 @@
- * to describe the BSSID address of the AP and %NL80211_ATTR_TIMEOUT to
- * specify the timeout value.
- *
-+ * @NL80211_CMD_ADD_LINK: Add a new link to an interface. The
-+ * %NL80211_ATTR_MLO_LINK_ID attribute is used for the new link.
-+ * @NL80211_CMD_REMOVE_LINK: Remove a link from an interface. This may come
-+ * without %NL80211_ATTR_MLO_LINK_ID as an easy way to remove all links
-+ * in preparation for e.g. roaming to a regular (non-MLO) AP.
-+ *
-+ * @NL80211_CMD_ADD_LINK_STA: Add a link to an MLD station
-+ * @NL80211_CMD_MODIFY_LINK_STA: Modify a link of an MLD station
-+ * @NL80211_CMD_REMOVE_LINK_STA: Remove a link of an MLD station
-+ *
- * @NL80211_CMD_MAX: highest used command number
- * @__NL80211_CMD_AFTER_LAST: internal use
- */
-@@ -1481,6 +1525,13 @@ enum nl80211_commands {
-
- NL80211_CMD_ASSOC_COMEBACK,
-
-+ NL80211_CMD_ADD_LINK,
-+ NL80211_CMD_REMOVE_LINK,
-+
-+ NL80211_CMD_ADD_LINK_STA,
-+ NL80211_CMD_MODIFY_LINK_STA,
-+ NL80211_CMD_REMOVE_LINK_STA,
-+
- /* add new commands above here */
-
- /* used to define NL80211_CMD_MAX below */
-@@ -2340,8 +2391,10 @@ enum nl80211_commands {
- *
- * @NL80211_ATTR_IFTYPE_EXT_CAPA: Nested attribute of the following attributes:
- * %NL80211_ATTR_IFTYPE, %NL80211_ATTR_EXT_CAPA,
-- * %NL80211_ATTR_EXT_CAPA_MASK, to specify the extended capabilities per
-- * interface type.
-+ * %NL80211_ATTR_EXT_CAPA_MASK, to specify the extended capabilities and
-+ * other interface-type specific capabilities per interface type. For MLO,
-+ * %NL80211_ATTR_EML_CAPABILITY and %NL80211_ATTR_MLD_CAPA_AND_OPS are
-+ * present.
- *
- * @NL80211_ATTR_MU_MIMO_GROUP_DATA: array of 24 bytes that defines a MU-MIMO
- * groupID for monitor mode.
-@@ -2663,6 +2716,44 @@ enum nl80211_commands {
- * association request when used with NL80211_CMD_NEW_STATION). Can be set
- * only if %NL80211_STA_FLAG_WME is set.
- *
-+ * @NL80211_ATTR_MLO_LINK_ID: A (u8) link ID for use with MLO, to be used with
-+ * various commands that need a link ID to operate.
-+ * @NL80211_ATTR_MLO_LINKS: A nested array of links, each containing some
-+ * per-link information and a link ID.
-+ * @NL80211_ATTR_MLD_ADDR: An MLD address, used with various commands such as
-+ * authenticate/associate.
-+ *
-+ * @NL80211_ATTR_MLO_SUPPORT: Flag attribute to indicate user space supports MLO
-+ * connection. Used with %NL80211_CMD_CONNECT. If this attribute is not
-+ * included in NL80211_CMD_CONNECT drivers must not perform MLO connection.
-+ *
-+ * @NL80211_ATTR_MAX_NUM_AKM_SUITES: U16 attribute. Indicates maximum number of
-+ * AKM suites allowed for %NL80211_CMD_CONNECT, %NL80211_CMD_ASSOCIATE and
-+ * %NL80211_CMD_START_AP in %NL80211_CMD_GET_WIPHY response. If this
-+ * attribute is not present userspace shall consider maximum number of AKM
-+ * suites allowed as %NL80211_MAX_NR_AKM_SUITES which is the legacy maximum
-+ * number prior to the introduction of this attribute.
-+ *
-+ * @NL80211_ATTR_EML_CAPABILITY: EML Capability information (u16)
-+ * @NL80211_ATTR_MLD_CAPA_AND_OPS: MLD Capabilities and Operations (u16)
-+ *
-+ * @NL80211_ATTR_TX_HW_TIMESTAMP: Hardware timestamp for TX operation in
-+ * nanoseconds (u64). This is the device clock timestamp so it will
-+ * probably reset when the device is stopped or the firmware is reset.
-+ * When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the frame TX
-+ * timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates
-+ * the ack TX timestamp.
-+ * @NL80211_ATTR_RX_HW_TIMESTAMP: Hardware timestamp for RX operation in
-+ * nanoseconds (u64). This is the device clock timestamp so it will
-+ * probably reset when the device is stopped or the firmware is reset.
-+ * When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the ack RX
-+ * timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates
-+ * the incoming frame RX timestamp.
-+ * @NL80211_ATTR_TD_BITMAP: Transition Disable bitmap, for subsequent
-+ * (re)associations.
-+ * @NL80211_ATTR_WIPHY_ANTENNA_GAIN: Configured antenna gain. Used to reduce
-+ * transmit power to stay within regulatory limits. u32, dBi.
-+ *
- * @NUM_NL80211_ATTR: total number of nl80211_attrs available
- * @NL80211_ATTR_MAX: highest attribute number currently defined
- * @__NL80211_ATTR_AFTER_LAST: internal use
-@@ -3177,6 +3268,23 @@ enum nl80211_attrs {
-
- NL80211_ATTR_DISABLE_EHT,
-
-+ NL80211_ATTR_MLO_LINKS,
-+ NL80211_ATTR_MLO_LINK_ID,
-+ NL80211_ATTR_MLD_ADDR,
-+
-+ NL80211_ATTR_MLO_SUPPORT,
-+
-+ NL80211_ATTR_MAX_NUM_AKM_SUITES,
-+
-+ NL80211_ATTR_EML_CAPABILITY,
-+ NL80211_ATTR_MLD_CAPA_AND_OPS,
-+
-+ NL80211_ATTR_TX_HW_TIMESTAMP,
-+ NL80211_ATTR_RX_HW_TIMESTAMP,
-+ NL80211_ATTR_TD_BITMAP,
-+
-+ NL80211_ATTR_WIPHY_ANTENNA_GAIN,
-+
- /* add attributes here, update the policy in nl80211.c */
-
- __NL80211_ATTR_AFTER_LAST,
-@@ -3231,6 +3339,11 @@ enum nl80211_attrs {
- #define NL80211_HE_MIN_CAPABILITY_LEN 16
- #define NL80211_HE_MAX_CAPABILITY_LEN 54
- #define NL80211_MAX_NR_CIPHER_SUITES 5
-+
-+/*
-+ * NL80211_MAX_NR_AKM_SUITES is obsolete when %NL80211_ATTR_MAX_NUM_AKM_SUITES
-+ * present in %NL80211_CMD_GET_WIPHY response.
-+ */
- #define NL80211_MAX_NR_AKM_SUITES 2
- #define NL80211_EHT_MIN_CAPABILITY_LEN 13
- #define NL80211_EHT_MAX_CAPABILITY_LEN 51
-@@ -4853,6 +4966,8 @@ enum nl80211_bss_scan_width {
- * Contains a nested array of signal strength attributes (u8, dBm),
- * using the nesting index as the antenna number.
- * @NL80211_BSS_FREQUENCY_OFFSET: frequency offset in KHz
-+ * @NL80211_BSS_MLO_LINK_ID: MLO link ID of the BSS (u8).
-+ * @NL80211_BSS_MLD_ADDR: MLD address of this BSS if connected to it.
- * @__NL80211_BSS_AFTER_LAST: internal
- * @NL80211_BSS_MAX: highest BSS attribute
- */
-@@ -4878,6 +4993,8 @@ enum nl80211_bss {
- NL80211_BSS_PARENT_BSSID,
- NL80211_BSS_CHAIN_SIGNAL,
- NL80211_BSS_FREQUENCY_OFFSET,
-+ NL80211_BSS_MLO_LINK_ID,
-+ NL80211_BSS_MLD_ADDR,
-
- /* keep last */
- __NL80211_BSS_AFTER_LAST,
-@@ -5874,7 +5991,7 @@ enum nl80211_ap_sme_features {
- * @NL80211_FEATURE_INACTIVITY_TIMER: This driver takes care of freeing up
- * the connected inactive stations in AP mode.
- * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested
-- * to work properly to suppport receiving regulatory hints from
-+ * to work properly to support receiving regulatory hints from
- * cellular base stations.
- * @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: (no longer available, only
- * here to reserve the value for API/ABI compatibility)
-@@ -6174,6 +6291,14 @@ enum nl80211_feature_flags {
- * @NL80211_EXT_FEATURE_RADAR_BACKGROUND: Device supports background radar/CAC
- * detection.
- *
-+ * @NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE: Device can perform a MAC address
-+ * change without having to bring the underlying network device down
-+ * first. For example, in station mode this can be used to vary the
-+ * origin MAC address prior to a connection to a new AP for privacy
-+ * or other reasons. Note that certain driver specific restrictions
-+ * might apply, e.g. no scans in progress, no offchannel operations
-+ * in progress, and no active connections.
-+ *
- * @NUM_NL80211_EXT_FEATURES: number of extended features.
- * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
- */
-@@ -6241,6 +6366,7 @@ enum nl80211_ext_feature_index {
- NL80211_EXT_FEATURE_BSS_COLOR,
- NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD,
- NL80211_EXT_FEATURE_RADAR_BACKGROUND,
-+ NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE,
-
- /* add new features before the definition below */
- NUM_NL80211_EXT_FEATURES,