qcacld-3.0: Refactor ANT_DIV_PERIOD 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 interdependent attribute
handling into a separate function and add that function to the vtable:
- QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_PERIOD
- QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_STAY_PERIOD

Change-Id: I13f76951f8f8451d70e1cc64f0116a8b6de163d0
CRs-Fixed: 2371591
This commit is contained in:
Jeff Johnson 2018-11-16 17:38:27 -08:00 committed by nshrivas
parent 0fbb43b96a
commit 7bf20cb5eb

View File

@ -5188,10 +5188,6 @@ nla_put_failure:
(((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_MGMT_SNR_WEIGHT \
QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_MGMT_SNR_WEIGHT
#define ANT_DIV_DATA_SNR_WEIGHT \
@ -5228,8 +5224,8 @@ wlan_hdd_wifi_config_policy[QCA_WLAN_VENDOR_ATTR_CONFIG_MAX + 1] = {
[QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_ABS_DELAY] = {
.type = NLA_U32 },
[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},
[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_PERIOD] = {.type = NLA_U32},
[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_STAY_PERIOD] = {.type = NLA_U32},
[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SNR_DIFF] = {.type = NLA_U32},
[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_DWELL_TIME] = {
.type = NLA_U32},
@ -5688,6 +5684,40 @@ static int hdd_config_mpdu_aggregation(struct hdd_adapter *adapter,
return qdf_status_to_os_return(status);
}
static int hdd_config_ant_div_period(struct hdd_adapter *adapter,
struct nlattr *tb[])
{
struct nlattr *probe_attr =
tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_PERIOD];
struct nlattr *stay_attr =
tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_STAY_PERIOD];
uint32_t probe_period, stay_period, ant_div_usrcfg;
int errno;
/* nothing to do if neither attribute is present */
if (!probe_attr && !stay_attr)
return 0;
/* if one is present, both must be present */
if (!probe_attr || !stay_attr) {
hdd_err("Missing attribute for %s",
probe_attr ? "STAY" : "PROBE");
return -EINVAL;
}
probe_period = nla_get_u32(probe_attr);
stay_period = nla_get_u32(stay_attr);
ant_div_usrcfg = ANT_DIV_SET_PERIOD(probe_period, stay_period);
hdd_debug("ant div set period: %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 ant div period, %d", errno);
return errno;
}
static int hdd_config_fine_time_measurement(struct hdd_adapter *adapter,
const struct nlattr *attr)
{
@ -6456,6 +6486,7 @@ typedef int (*interdependent_setter_fn)(struct hdd_adapter *adapter,
static const interdependent_setter_fn interdependent_setters[] = {
hdd_config_access_policy,
hdd_config_mpdu_aggregation,
hdd_config_ant_div_period,
};
/**
@ -6545,28 +6576,6 @@ __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
/* return errno here when all attributes have been refactored */
if (tb[ANT_DIV_PROBE_PERIOD] ||
tb[ANT_DIV_STAY_PERIOD]) {
if (!tb[ANT_DIV_PROBE_PERIOD] ||
!tb[ANT_DIV_STAY_PERIOD]) {
hdd_err("Both probe and stay period required");
return -EINVAL;
}
ant_div_usrcfg = ANT_DIV_SET_PERIOD(
nla_get_u32(tb[ANT_DIV_PROBE_PERIOD]),
nla_get_u32(tb[ANT_DIV_STAY_PERIOD]));
hdd_debug("ant div set period: %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 div period");
return ret_val;
}
}
if (tb[ANT_DIV_MGMT_SNR_WEIGHT] ||
tb[ANT_DIV_DATA_SNR_WEIGHT] ||
tb[ANT_DIV_ACK_SNR_WEIGHT]) {