qcacld-3.0: Refine wlan_hdd_update_phymode()

Function wlan_hdd_update_phymode() is called from two ioctl handler
functions, __iw_softap_setparam() and __iw_setint_getnone(). Unlike
most of the ioctl "setter" functions which take two parameters (an
adapter and a value), wlan_hdd_update_phymode() currently takes four
parameters (a net device, a mac handle, an hdd context, and a value).

In addition, currently the HDD function with the highest cyclomatic
complexity is __iw_setint_getnone(). In order to reduce the complexity
of that function all of the switch/case handlers are being refactored,
and in anticipation of eventually using a vtable, the refactored
functions all expect two parameters, an adapter and a value.

In order to align with that goal, refine wlan_hdd_update_phymode() to
expect those same two parameters. Note that the net device, mac
handle, and hdd context that are currently being passed can all be
derived from the adapter.

Change-Id: Ib919e6751aee182e2d8fde90a8446935447123db
CRs-Fixed: 2338381
This commit is contained in:
Jeff Johnson 2018-10-23 13:45:42 -07:00
commit c171324c3d
3 changed files with 36 additions and 44 deletions

View file

@ -248,8 +248,20 @@ int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate);
int hdd_set_11ax_rate(struct hdd_adapter *adapter, int value,
struct sap_config *sap_config);
int wlan_hdd_update_phymode(struct net_device *net, mac_handle_t mac_handle,
int new_phymode, struct hdd_context *phddctx);
/**
* wlan_hdd_update_phymode() - handle change in PHY mode
* @adapter: adapter being modified
* @new_phymode: new PHY mode for the device
*
* This function is called when the device is set to a new PHY mode.
* It takes a holistic look at the desired PHY mode along with the
* configured capabilities of the driver and the reported capabilities
* of the hardware in order to correctly configure all PHY-related
* parameters.
*
* Return: 0 on success, negative errno value on error
*/
int wlan_hdd_update_phymode(struct hdd_adapter *adapter, int new_phymode);
struct iw_request_info;

View file

@ -1028,8 +1028,7 @@ static __iw_softap_setparam(struct net_device *dev,
}
case QCASAP_SET_PHYMODE:
ret = wlan_hdd_update_phymode(dev, mac_handle, set_value,
hdd_ctx);
ret = wlan_hdd_update_phymode(adapter, set_value);
break;
case QCASAP_DUMP_STATS:

View file

@ -3656,28 +3656,11 @@ static int iw_get_linkspeed(struct net_device *dev,
return ret;
}
/**
* wlan_hdd_update_phymode() - handle change in PHY mode
* @net: device upon which PHY mode change was received
* @mac_handle: umac handle for the driver
* @new_phymode: new PHY mode for the device
* @phddctx: pointer to the HDD context
*
* This function is called when the device is set to a new PHY mode.
* It takes a holistic look at the desired PHY mode along with the
* configured capabilities of the driver and the reported capabilities
* of the hardware in order to correctly configure all PHY-related
* parameters.
*
* Return: 0 on success, negative errno value on error
*/
int wlan_hdd_update_phymode(struct net_device *net, mac_handle_t mac_handle,
int new_phymode, struct hdd_context *phddctx)
int wlan_hdd_update_phymode(struct hdd_adapter *adapter, int new_phymode)
{
#ifdef QCA_HT_2040_COEX
struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(net);
QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
#endif
struct net_device *net = adapter->dev;
struct hdd_context *phddctx = WLAN_HDD_GET_CTX(adapter);
mac_handle_t mac_handle = phddctx->mac_handle;
bool band_24 = false, band_5g = false;
bool ch_bond24 = false, ch_bond5g = false;
tSmeConfigParams *sme_config;
@ -3690,6 +3673,9 @@ int wlan_hdd_update_phymode(struct net_device *net, mac_handle_t mac_handle,
uint8_t band_capability;
QDF_STATUS status;
if (!mac_handle)
return -EINVAL;
old_phymode = sme_get_phy_mode(mac_handle);
if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
@ -3715,9 +3701,8 @@ int wlan_hdd_update_phymode(struct net_device *net, mac_handle_t mac_handle,
else if (band_capability == BAND_5G)
band_5g = true;
halStatus = ucfg_mlme_get_vht_channel_width(phddctx->psoc,
&vhtchanwidth);
if (!QDF_IS_STATUS_SUCCESS(halStatus))
status = ucfg_mlme_get_vht_channel_width(phddctx->psoc, &vhtchanwidth);
if (!QDF_IS_STATUS_SUCCESS(status))
hdd_err("Failed to set channel_width");
hdd_debug("ch_bond24=%d ch_bond5g=%d band_24=%d band_5g=%d VHT_ch_width=%u",
@ -3902,9 +3887,9 @@ int wlan_hdd_update_phymode(struct net_device *net, mac_handle_t mac_handle,
vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
break;
default:
halStatus = ucfg_mlme_get_vht_channel_width(phddctx->psoc,
&vhtchanwidth);
if (!QDF_IS_STATUS_SUCCESS(halStatus))
status = ucfg_mlme_get_vht_channel_width(phddctx->psoc,
&vhtchanwidth);
if (!QDF_IS_STATUS_SUCCESS(status))
hdd_err("Failed to set channel_width");
break;
}
@ -3922,10 +3907,10 @@ int wlan_hdd_update_phymode(struct net_device *net, mac_handle_t mac_handle,
if (phymode == eCSR_DOT11_MODE_11n &&
chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
sme_config->csrConfig.obssEnabled = false;
halStatus = sme_set_ht2040_mode(mac_handle,
adapter->session_id,
eHT_CHAN_HT20, false);
if (halStatus == QDF_STATUS_E_FAILURE) {
status = sme_set_ht2040_mode(mac_handle,
adapter->session_id,
eHT_CHAN_HT20, false);
if (status == QDF_STATUS_E_FAILURE) {
hdd_err("Failed to disable OBSS");
retval = -EIO;
goto free;
@ -3933,10 +3918,10 @@ int wlan_hdd_update_phymode(struct net_device *net, mac_handle_t mac_handle,
} else if (phymode == eCSR_DOT11_MODE_11n &&
chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
sme_config->csrConfig.obssEnabled = true;
halStatus = sme_set_ht2040_mode(mac_handle,
adapter->session_id,
eHT_CHAN_HT20, true);
if (halStatus == QDF_STATUS_E_FAILURE) {
status = sme_set_ht2040_mode(mac_handle,
adapter->session_id,
eHT_CHAN_HT20, true);
if (status == QDF_STATUS_E_FAILURE) {
hdd_err("Failed to enable OBSS");
retval = -EIO;
goto free;
@ -4382,11 +4367,7 @@ static int __iw_setint_getnone(struct net_device *dev,
break;
case WE_SET_PHYMODE:
if (!mac_handle)
return -EINVAL;
ret = wlan_hdd_update_phymode(dev, mac_handle, set_value,
hdd_ctx);
ret = wlan_hdd_update_phymode(adapter, set_value);
break;
case WE_SET_NSS: