qcacld-3.0: Refactor ANT_DIV_SNR_DIFF configuration

One of the HDD functions with the highest cyclomatic complexity is
__wlan_hdd_cfg80211_wifi_configuration_set(). In order to reduce the
complexity there is a plan to replace the inline attribute handling
with a vtable-based approach.

As part of that goal refactor the following independent attribute
handling into a separate function and add that function to the vtable:
- QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SNR_DIFF

Change-Id: I1fa384b98c276ab5cf09c96d8d47be9fc0a93acd
CRs-Fixed: 2371578
This commit is contained in:
Jeff Johnson 2018-11-16 07:53:37 -08:00
commit 91f90ffa51

View file

@ -5175,12 +5175,29 @@ nla_put_failure:
}
#endif
#define ANT_DIV_SET_PERIOD(probe_period, stay_period) \
((1 << 26) | \
(((probe_period) & 0x1fff) << 13) | \
((stay_period) & 0x1fff))
#define ANT_DIV_SET_SNR_DIFF(snr_diff) \
((1 << 27) | \
((snr_diff) & 0x1fff))
#define ANT_DIV_SET_PROBE_DWELL_TIME(probe_dwell_time) \
((1 << 28) | \
((probe_dwell_time) & 0x1fff))
#define ANT_DIV_SET_WEIGHT(mgmt_snr_weight, data_snr_weight, ack_snr_weight) \
((1 << 29) | \
(((mgmt_snr_weight) & 0xff) << 16) | \
(((data_snr_weight) & 0xff) << 8) | \
((ack_snr_weight) & 0xff))
#define ANT_DIV_PROBE_PERIOD \
QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_PERIOD
#define ANT_DIV_STAY_PERIOD \
QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_STAY_PERIOD
#define ANT_DIV_SNR_DIFF \
QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SNR_DIFF
#define ANT_DIV_PROBE_DWELL_TIME \
QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_DWELL_TIME
#define ANT_DIV_MGMT_SNR_WEIGHT \
@ -5221,7 +5238,7 @@ wlan_hdd_wifi_config_policy[QCA_WLAN_VENDOR_ATTR_CONFIG_MAX + 1] = {
[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_FAIL_COUNT] = {.type = NLA_U32 },
[ANT_DIV_PROBE_PERIOD] = {.type = NLA_U32},
[ANT_DIV_STAY_PERIOD] = {.type = NLA_U32},
[ANT_DIV_SNR_DIFF] = {.type = NLA_U32},
[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SNR_DIFF] = {.type = NLA_U32},
[ANT_DIV_PROBE_DWELL_TIME] = {.type = NLA_U32},
[ANT_DIV_MGMT_SNR_WEIGHT] = {.type = NLA_U32},
[ANT_DIV_DATA_SNR_WEIGHT] = {.type = NLA_U32},
@ -5913,6 +5930,28 @@ static int hdd_config_ant_div_ena(struct hdd_adapter *adapter,
return errno;
}
static int hdd_config_ant_div_snr_diff(struct hdd_adapter *adapter,
const struct nlattr *attr)
{
uint32_t ant_div_snr_diff;
uint32_t ant_div_usrcfg;
int errno;
ant_div_snr_diff = nla_get_u32(attr);
hdd_debug("snr diff: %x", ant_div_snr_diff);
ant_div_usrcfg = ANT_DIV_SET_SNR_DIFF(ant_div_snr_diff);
hdd_debug("usrcfg: %x", ant_div_usrcfg);
errno = wma_cli_set_command(adapter->session_id,
WMI_PDEV_PARAM_ANT_DIV_USRCFG,
ant_div_usrcfg, PDEV_CMD);
if (errno)
hdd_err("Failed to set snr diff, %d", errno);
return errno;
}
static int hdd_config_ignore_assoc_disallowed(struct hdd_adapter *adapter,
const struct nlattr *attr)
{
@ -5993,6 +6032,8 @@ static const struct independent_setters independent_setters[] = {
hdd_config_channel_avoidance_ind},
{QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_ENA,
hdd_config_ant_div_ena},
{QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SNR_DIFF,
hdd_config_ant_div_snr_diff},
{QCA_WLAN_VENDOR_ATTR_CONFIG_IGNORE_ASSOC_DISALLOWED,
hdd_config_ignore_assoc_disallowed},
};
@ -6240,19 +6281,6 @@ __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
}
}
#define ANT_DIV_SET_PERIOD(probe_period, stay_period) \
((1<<26)|((probe_period&0x1fff)<<13)|(stay_period&0x1fff))
#define ANT_DIV_SET_SNR_DIFF(snr_diff) \
((1<<27)|(snr_diff&0x1fff))
#define ANT_DIV_SET_PROBE_DWELL_TIME(probe_dwell_time) \
((1<<28)|(probe_dwell_time&0x1fff))
#define ANT_DIV_SET_WEIGHT(mgmt_snr_weight, data_snr_weight, ack_snr_weight) \
((1<<29)|((mgmt_snr_weight&0xff)<<16)|((data_snr_weight&0xff)<<8)| \
(ack_snr_weight&0xff))
if (tb[ANT_DIV_PROBE_PERIOD] ||
tb[ANT_DIV_STAY_PERIOD]) {
@ -6275,19 +6303,6 @@ __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
}
}
if (tb[ANT_DIV_SNR_DIFF]) {
ant_div_usrcfg = ANT_DIV_SET_SNR_DIFF(
nla_get_u32(tb[ANT_DIV_SNR_DIFF]));
hdd_debug("ant div set snr diff: %x", ant_div_usrcfg);
ret_val = wma_cli_set_command((int)adapter->session_id,
(int)WMI_PDEV_PARAM_ANT_DIV_USRCFG,
ant_div_usrcfg, PDEV_CMD);
if (ret_val) {
hdd_err("Failed to set ant snr diff");
return ret_val;
}
}
if (tb[ANT_DIV_PROBE_DWELL_TIME]) {
ant_div_usrcfg = ANT_DIV_SET_PROBE_DWELL_TIME(
nla_get_u32(tb[ANT_DIV_PROBE_DWELL_TIME]));