提交 216cdfb5 编写于 作者: L Luca Coelho

iwlwifi: add a common struct for all iwl_tx_power_cmd versions

Create a common structure to contain all different versions of the
tx_power_cmd instead of making a union of the different structs
everywhere we need them.  Also move the common part of these structs
into a separate structure (instead of reusing v3) and leave the
per_chain_restriction part out of the common part, because this will
change in version 6 of the command (which will be added soon).

While at it, rename per_chain_restriction to per_chain to shorten it.
Signed-off-by: NLuca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200928121852.4f0bea9fe077.Ib3b540a8288af32d6fa213448e13f82763f85bc9@changeidSigned-off-by: NLuca Coelho <luciano.coelho@intel.com>
上级 38cb52dd
...@@ -420,7 +420,7 @@ static int iwl_sar_set_profile(union acpi_object *table, ...@@ -420,7 +420,7 @@ static int iwl_sar_set_profile(union acpi_object *table,
} }
int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt, int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt,
__le16 per_chain_restriction[][IWL_NUM_SUB_BANDS], __le16 per_chain[][IWL_NUM_SUB_BANDS],
int prof_a, int prof_b) int prof_a, int prof_b)
{ {
int i, j, idx; int i, j, idx;
...@@ -462,8 +462,7 @@ int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt, ...@@ -462,8 +462,7 @@ int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt,
IWL_DEBUG_RADIO(fwrt, " Chain[%d]:\n", i); IWL_DEBUG_RADIO(fwrt, " Chain[%d]:\n", i);
for (j = 0; j < ACPI_SAR_NUM_SUB_BANDS; j++) { for (j = 0; j < ACPI_SAR_NUM_SUB_BANDS; j++) {
idx = (i * ACPI_SAR_NUM_SUB_BANDS) + j; idx = (i * ACPI_SAR_NUM_SUB_BANDS) + j;
per_chain_restriction[i][j] = per_chain[i][j] = cpu_to_le16(prof->table[idx]);
cpu_to_le16(prof->table[idx]);
IWL_DEBUG_RADIO(fwrt, " Band[%d] = %d * .125dBm\n", IWL_DEBUG_RADIO(fwrt, " Band[%d] = %d * .125dBm\n",
j, prof->table[idx]); j, prof->table[idx]);
} }
......
...@@ -183,7 +183,7 @@ u64 iwl_acpi_get_pwr_limit(struct device *dev); ...@@ -183,7 +183,7 @@ u64 iwl_acpi_get_pwr_limit(struct device *dev);
int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk); int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk);
int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt, int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt,
__le16 per_chain_restriction[][IWL_NUM_SUB_BANDS], __le16 per_chain[][IWL_NUM_SUB_BANDS],
int prof_a, int prof_b); int prof_a, int prof_b);
int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt); int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt);
...@@ -242,7 +242,7 @@ static inline int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk) ...@@ -242,7 +242,7 @@ static inline int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk)
} }
static inline int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt, static inline int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt,
__le16 per_chain_restriction[][IWL_NUM_SUB_BANDS], __le16 per_chain[][IWL_NUM_SUB_BANDS],
int prof_a, int prof_b) int prof_a, int prof_b)
{ {
return -ENOENT; return -ENOENT;
......
...@@ -431,8 +431,7 @@ enum iwl_legacy_cmds { ...@@ -431,8 +431,7 @@ enum iwl_legacy_cmds {
/** /**
* @REDUCE_TX_POWER_CMD: * @REDUCE_TX_POWER_CMD:
* &struct iwl_dev_tx_power_cmd_v3 or &struct iwl_dev_tx_power_cmd_v4 * &struct iwl_dev_tx_power_cmd
* or &struct iwl_dev_tx_power_cmd
*/ */
REDUCE_TX_POWER_CMD = 0x9f, REDUCE_TX_POWER_CMD = 0x9f,
......
...@@ -334,44 +334,49 @@ enum iwl_dev_tx_power_cmd_mode { ...@@ -334,44 +334,49 @@ enum iwl_dev_tx_power_cmd_mode {
#define IWL_NUM_SUB_BANDS_V2 11 #define IWL_NUM_SUB_BANDS_V2 11
/** /**
* struct iwl_dev_tx_power_cmd - TX power reduction command * struct iwl_dev_tx_power_common - Common part of the TX power reduction cmd
* @set_mode: see &enum iwl_dev_tx_power_cmd_mode * @set_mode: see &enum iwl_dev_tx_power_cmd_mode
* @mac_context_id: id of the mac ctx for which we are reducing TX power. * @mac_context_id: id of the mac ctx for which we are reducing TX power.
* @pwr_restriction: TX power restriction in 1/8 dBms. * @pwr_restriction: TX power restriction in 1/8 dBms.
* @dev_24: device TX power restriction in 1/8 dBms * @dev_24: device TX power restriction in 1/8 dBms
* @dev_52_low: device TX power restriction upper band - low * @dev_52_low: device TX power restriction upper band - low
* @dev_52_high: device TX power restriction upper band - high * @dev_52_high: device TX power restriction upper band - high
* @per_chain_restriction: per chain restrictions
*/ */
struct iwl_dev_tx_power_cmd_v3 { struct iwl_dev_tx_power_common {
__le32 set_mode; __le32 set_mode;
__le32 mac_context_id; __le32 mac_context_id;
__le16 pwr_restriction; __le16 pwr_restriction;
__le16 dev_24; __le16 dev_24;
__le16 dev_52_low; __le16 dev_52_low;
__le16 dev_52_high; __le16 dev_52_high;
__le16 per_chain_restriction[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS]; };
/**
* struct iwl_dev_tx_power_cmd_v3 - TX power reduction command version 3
* @per_chain: per chain restrictions
*/
struct iwl_dev_tx_power_cmd_v3 {
__le16 per_chain[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS];
} __packed; /* TX_REDUCED_POWER_API_S_VER_3 */ } __packed; /* TX_REDUCED_POWER_API_S_VER_3 */
#define IWL_DEV_MAX_TX_POWER 0x7FFF #define IWL_DEV_MAX_TX_POWER 0x7FFF
/** /**
* struct iwl_dev_tx_power_cmd - TX power reduction command * struct iwl_dev_tx_power_cmd_v4 - TX power reduction command version 4
* @v3: version 3 of the command, embedded here for easier software handling * @per_chain: per chain restrictions
* @enable_ack_reduction: enable or disable close range ack TX power * @enable_ack_reduction: enable or disable close range ack TX power
* reduction. * reduction.
* @reserved: reserved (padding) * @reserved: reserved (padding)
*/ */
struct iwl_dev_tx_power_cmd_v4 { struct iwl_dev_tx_power_cmd_v4 {
/* v4 is just an extension of v3 - keep this here */ __le16 per_chain[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS];
struct iwl_dev_tx_power_cmd_v3 v3;
u8 enable_ack_reduction; u8 enable_ack_reduction;
u8 reserved[3]; u8 reserved[3];
} __packed; /* TX_REDUCED_POWER_API_S_VER_4 */ } __packed; /* TX_REDUCED_POWER_API_S_VER_4 */
/** /**
* struct iwl_dev_tx_power_cmd - TX power reduction command * struct iwl_dev_tx_power_cmd_v5 - TX power reduction command version 5
* @v3: version 3 of the command, embedded here for easier software handling * @per_chain: per chain restrictions
* @enable_ack_reduction: enable or disable close range ack TX power * @enable_ack_reduction: enable or disable close range ack TX power
* reduction. * reduction.
* @per_chain_restriction_changed: is per_chain_restriction has changed * @per_chain_restriction_changed: is per_chain_restriction has changed
...@@ -382,15 +387,30 @@ struct iwl_dev_tx_power_cmd_v4 { ...@@ -382,15 +387,30 @@ struct iwl_dev_tx_power_cmd_v4 {
* @timer_period: timer in milliseconds. if expires FW will change to default * @timer_period: timer in milliseconds. if expires FW will change to default
* BIOS values. relevant if setMode is IWL_TX_POWER_MODE_SET_SAR_TIMER * BIOS values. relevant if setMode is IWL_TX_POWER_MODE_SET_SAR_TIMER
*/ */
struct iwl_dev_tx_power_cmd { struct iwl_dev_tx_power_cmd_v5 {
/* v5 is just an extension of v3 - keep this here */ __le16 per_chain[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS];
struct iwl_dev_tx_power_cmd_v3 v3;
u8 enable_ack_reduction; u8 enable_ack_reduction;
u8 per_chain_restriction_changed; u8 per_chain_restriction_changed;
u8 reserved[2]; u8 reserved[2];
__le32 timer_period; __le32 timer_period;
} __packed; /* TX_REDUCED_POWER_API_S_VER_5 */ } __packed; /* TX_REDUCED_POWER_API_S_VER_5 */
/**
* struct iwl_dev_tx_power_cmd - TX power reduction command (multiversion)
* @common: common part of the command
* @v3: version 3 part of the command
* @v4: version 4 part of the command
* @v5: version 5 part of the command
*/
struct iwl_dev_tx_power_cmd {
struct iwl_dev_tx_power_common common;
union {
struct iwl_dev_tx_power_cmd_v3 v3;
struct iwl_dev_tx_power_cmd_v4 v4;
struct iwl_dev_tx_power_cmd_v5 v5;
};
};
#define IWL_NUM_GEO_PROFILES 3 #define IWL_NUM_GEO_PROFILES 3
/** /**
......
...@@ -736,11 +736,8 @@ static int iwl_mvm_config_ltr(struct iwl_mvm *mvm) ...@@ -736,11 +736,8 @@ static int iwl_mvm_config_ltr(struct iwl_mvm *mvm)
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b) int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b)
{ {
union { struct iwl_dev_tx_power_cmd cmd = {
struct iwl_dev_tx_power_cmd v5; .common.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_CHAINS),
struct iwl_dev_tx_power_cmd_v4 v4;
} cmd = {
.v5.v3.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_CHAINS),
}; };
int ret; int ret;
u16 len = 0; u16 len = 0;
...@@ -750,13 +747,14 @@ int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b) ...@@ -750,13 +747,14 @@ int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b)
len = sizeof(cmd.v5); len = sizeof(cmd.v5);
else if (fw_has_capa(&mvm->fw->ucode_capa, else if (fw_has_capa(&mvm->fw->ucode_capa,
IWL_UCODE_TLV_CAPA_TX_POWER_ACK)) IWL_UCODE_TLV_CAPA_TX_POWER_ACK))
len = sizeof(struct iwl_dev_tx_power_cmd_v4); len = sizeof(cmd.v4);
else else
len = sizeof(cmd.v4.v3); len = sizeof(cmd.v3);
/* all structs have the same common part, add it */
len += sizeof(cmd.common);
ret = iwl_sar_select_profile(&mvm->fwrt, ret = iwl_sar_select_profile(&mvm->fwrt, cmd.v5.per_chain,
cmd.v5.v3.per_chain_restriction,
prof_a, prof_b); prof_a, prof_b);
/* return on error or if the profile is disabled (positive number) */ /* return on error or if the profile is disabled (positive number) */
......
...@@ -1308,18 +1308,15 @@ static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -1308,18 +1308,15 @@ static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
s16 tx_power) s16 tx_power)
{ {
int len; int len;
union { struct iwl_dev_tx_power_cmd cmd = {
struct iwl_dev_tx_power_cmd v5; .common.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_MAC),
struct iwl_dev_tx_power_cmd_v4 v4; .common.mac_context_id =
} cmd = {
.v5.v3.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_MAC),
.v5.v3.mac_context_id =
cpu_to_le32(iwl_mvm_vif_from_mac80211(vif)->id), cpu_to_le32(iwl_mvm_vif_from_mac80211(vif)->id),
.v5.v3.pwr_restriction = cpu_to_le16(8 * tx_power), .common.pwr_restriction = cpu_to_le16(8 * tx_power),
}; };
if (tx_power == IWL_DEFAULT_MAX_TX_POWER) if (tx_power == IWL_DEFAULT_MAX_TX_POWER)
cmd.v5.v3.pwr_restriction = cpu_to_le16(IWL_DEV_MAX_TX_POWER); cmd.common.pwr_restriction = cpu_to_le16(IWL_DEV_MAX_TX_POWER);
if (fw_has_api(&mvm->fw->ucode_capa, if (fw_has_api(&mvm->fw->ucode_capa,
IWL_UCODE_TLV_API_REDUCE_TX_POWER)) IWL_UCODE_TLV_API_REDUCE_TX_POWER))
...@@ -1328,7 +1325,10 @@ static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -1328,7 +1325,10 @@ static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
IWL_UCODE_TLV_CAPA_TX_POWER_ACK)) IWL_UCODE_TLV_CAPA_TX_POWER_ACK))
len = sizeof(cmd.v4); len = sizeof(cmd.v4);
else else
len = sizeof(cmd.v4.v3); len = sizeof(cmd.v3);
/* all structs have the same common part, add it */
len += sizeof(cmd.common);
return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd); return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册