History

nl80211: add common API to configure SAR power limitations

NL80211_CMD_SET_SAR_SPECS is added to configure SAR from user space. NL80211_ATTR_SAR_SPEC is used to pass the SAR power specification when used with NL80211_CMD_SET_SAR_SPECS. Wireless driver needs to register SAR type, supported frequency ranges to wiphy, so user space can query it. The index in frequency range is used to specify which sub band the power limitation applies to. The SAR type is for compatibility, so later other SAR mechanism can be implemented without breaking the user space SAR applications. Normal process is user space queries the SAR capability, and gets the index of supported frequency ranges and associates the power limitation with this index and sends to kernel. Here is an example of message send to kernel: 8c 00 00 00 08 00 01 00 00 00 00 00 38 00 2b 81 08 00 01 00 00 00 00 00 2c 00 02 80 14 00 00 80 08 00 02 00 00 00 00 00 08 00 01 00 38 00 00 00 14 00 01 80 08 00 02 00 01 00 00 00 08 00 01 00 48 00 00 00 NL80211_CMD_SET_SAR_SPECS: 0x8c NL80211_ATTR_WIPHY: 0x01(phy idx is 0) NL80211_ATTR_SAR_SPEC: 0x812b (NLA_NESTED) NL80211_SAR_ATTR_TYPE: 0x00 (NL80211_SAR_TYPE_POWER) NL80211_SAR_ATTR_SPECS: 0x8002 (NLA_NESTED) freq range 0 power: 0x38 in 0.25dbm unit (14dbm) freq range 1 power: 0x48 in 0.25dbm unit (18dbm)

Carl Huang committed 5 years ago

Commit 6bdb68c1 parent f879ac85 files · +371 −0Browse files

Showing the changes to include/uapi (1 of 5 files). Show all

Unified · Split

include/uapi/linux/nl80211.h+105−0
@@ -1178,6 +1178,10 @@ · 1177 unmodified lines
1178 * includes the contents of the frame. %NL80211_ATTR_ACK flag is included1178 * includes the contents of the frame. %NL80211_ATTR_ACK flag is included
1179 * if the recipient acknowledged the frame.1179 * if the recipient acknowledged the frame.
1180 *1180 *
1181 * @NL80211_CMD_SET_SAR_SPECS: SAR power limitation configuration is
1182 * passed using %NL80211_ATTR_SAR_SPEC. %NL80211_ATTR_WIPHY is used to
1183 * specify the wiphy index to be applied to.
1184 *
1181 * @NL80211_CMD_MAX: highest used command number1185 * @NL80211_CMD_MAX: highest used command number
1182 * @__NL80211_CMD_AFTER_LAST: internal use1186 * @__NL80211_CMD_AFTER_LAST: internal use
1183 */1187 */
@@ -1408,6 +1412,8 @@ enum nl80211_commands { · 224 unmodified lines
1408 1412
1409 NL80211_CMD_CONTROL_PORT_FRAME_TX_STATUS,1413 NL80211_CMD_CONTROL_PORT_FRAME_TX_STATUS,
1410 1414
1415 NL80211_CMD_SET_SAR_SPECS,
1416
1411 /* add new commands above here */1417 /* add new commands above here */
1412 1418
1413 /* used to define NL80211_CMD_MAX below */1419 /* used to define NL80211_CMD_MAX below */
@@ -2535,6 +2541,11 @@ enum nl80211_commands { · 1121 unmodified lines
2535 * This is a u8 attribute that encapsulates one of the values from2541 * This is a u8 attribute that encapsulates one of the values from
2536 * &enum nl80211_sae_pwe_mechanism.2542 * &enum nl80211_sae_pwe_mechanism.
2537 *2543 *
2544 * @NL80211_ATTR_SAR_SPEC: SAR power limitation specification when
2545 * used with %NL80211_CMD_SET_SAR_SPECS. The message contains fields
2546 * of %nl80211_sar_attrs which specifies the sar type and related
2547 * sar specs. Sar specs contains array of %nl80211_sar_specs_attrs.
2548 *
2538 * @NL80211_ATTR_RECONNECT_REQUESTED: flag attribute, used with deauth and2549 * @NL80211_ATTR_RECONNECT_REQUESTED: flag attribute, used with deauth and
2539 * disassoc events to indicate that an immediate reconnect to the AP2550 * disassoc events to indicate that an immediate reconnect to the AP
2540 * is desired.2551 * is desired.
@@ -3032,6 +3043,8 @@ enum nl80211_attrs { · 491 unmodified lines
3032 3043
3033 NL80211_ATTR_RECONNECT_REQUESTED,3044 NL80211_ATTR_RECONNECT_REQUESTED,
3034 3045
3046 NL80211_ATTR_SAR_SPEC,
3047
3035 /* add attributes here, update the policy in nl80211.c */3048 /* add attributes here, update the policy in nl80211.c */
3036 3049
3037 __NL80211_ATTR_AFTER_LAST,3050 __NL80211_ATTR_AFTER_LAST,
@@ -7163,4 +7176,96 @@ enum nl80211_sae_pwe_mechanism { · 4125 unmodified lines
7163 NL80211_SAE_PWE_HASH_TO_ELEMENT,7176 NL80211_SAE_PWE_HASH_TO_ELEMENT,
7164 NL80211_SAE_PWE_BOTH,7177 NL80211_SAE_PWE_BOTH,
7165};7178};
7179
7180/**
7181 * enum nl80211_sar_type - type of SAR specs
7182 *
7183 * @NL80211_SAR_TYPE_POWER: power limitation specified in 0.25dBm unit
7184 *
7185 */
7186enum nl80211_sar_type {
7187 NL80211_SAR_TYPE_POWER,
7188
7189 /* add new type here */
7190
7191 /* Keep last */
7192 NUM_NL80211_SAR_TYPE,
7193};
7194
7195/**
7196 * enum nl80211_sar_attrs - Attributes for SAR spec
7197 *
7198 * @NL80211_SAR_ATTR_TYPE: the SAR type as defined in &enum nl80211_sar_type.
7199 *
7200 * @NL80211_SAR_ATTR_SPECS: Nested array of SAR power
7201 * limit specifications. Each specification contains a set
7202 * of %nl80211_sar_specs_attrs.
7203 *
7204 * For SET operation, it contains array of %NL80211_SAR_ATTR_SPECS_POWER
7205 * and %NL80211_SAR_ATTR_SPECS_RANGE_INDEX.
7206 *
7207 * For sar_capa dump, it contains array of
7208 * %NL80211_SAR_ATTR_SPECS_START_FREQ
7209 * and %NL80211_SAR_ATTR_SPECS_END_FREQ.
7210 *
7211 * @__NL80211_SAR_ATTR_LAST: Internal
7212 * @NL80211_SAR_ATTR_MAX: highest sar attribute
7213 *
7214 * These attributes are used with %NL80211_CMD_SET_SAR_SPEC
7215 */
7216enum nl80211_sar_attrs {
7217 __NL80211_SAR_ATTR_INVALID,
7218
7219 NL80211_SAR_ATTR_TYPE,
7220 NL80211_SAR_ATTR_SPECS,
7221
7222 __NL80211_SAR_ATTR_LAST,
7223 NL80211_SAR_ATTR_MAX = __NL80211_SAR_ATTR_LAST - 1,
7224};
7225
7226/**
7227 * enum nl80211_sar_specs_attrs - Attributes for SAR power limit specs
7228 *
7229 * @NL80211_SAR_ATTR_SPECS_POWER: Required (s32)value to specify the actual
7230 * power limit value in units of 0.25 dBm if type is
7231 * NL80211_SAR_TYPE_POWER. (i.e., a value of 44 represents 11 dBm).
7232 * 0 means userspace doesn't have SAR limitation on this associated range.
7233 *
7234 * @NL80211_SAR_ATTR_SPECS_RANGE_INDEX: Required (u32) value to specify the
7235 * index of exported freq range table and the associated power limitation
7236 * is applied to this range.
7237 *
7238 * Userspace isn't required to set all the ranges advertised by WLAN driver,
7239 * and userspace can skip some certain ranges. These skipped ranges don't
7240 * have SAR limitations, and they are same as setting the
7241 * %NL80211_SAR_ATTR_SPECS_POWER to any unreasonable high value because any
7242 * value higher than regulatory allowed value just means SAR power
7243 * limitation is removed, but it's required to set at least one range.
7244 * It's not allowed to set duplicated range in one SET operation.
7245 *
7246 * Every SET operation overwrites previous SET operation.
7247 *
7248 * @NL80211_SAR_ATTR_SPECS_START_FREQ: Required (u32) value to specify the start
7249 * frequency of this range edge when registering SAR capability to wiphy.
7250 * It's not a channel center frequency. The unit is kHz.
7251 *
7252 * @NL80211_SAR_ATTR_SPECS_END_FREQ: Required (u32) value to specify the end
7253 * frequency of this range edge when registering SAR capability to wiphy.
7254 * It's not a channel center frequency. The unit is kHz.
7255 *
7256 * @__NL80211_SAR_ATTR_SPECS_LAST: Internal
7257 * @NL80211_SAR_ATTR_SPECS_MAX: highest sar specs attribute
7258 */
7259enum nl80211_sar_specs_attrs {
7260 __NL80211_SAR_ATTR_SPECS_INVALID,
7261
7262 NL80211_SAR_ATTR_SPECS_POWER,
7263 NL80211_SAR_ATTR_SPECS_RANGE_INDEX,
7264 NL80211_SAR_ATTR_SPECS_START_FREQ,
7265 NL80211_SAR_ATTR_SPECS_END_FREQ,
7266
7267 __NL80211_SAR_ATTR_SPECS_LAST,
7268 NL80211_SAR_ATTR_SPECS_MAX = __NL80211_SAR_ATTR_SPECS_LAST - 1,
7269};
7270
7166#endif /* __LINUX_NL80211_H */7271#endif /* __LINUX_NL80211_H */