qcacld-3.0: Update wlan_hdd_add_virtual_intf for Kernel upgrade

Commit: 6bab2e19 ("cfg80211: pass name_assign_type to
rdev_add_virtual_intf)

Above commit add new parameter - name_assign_type to indicate the
ifname is set by userspace or generated by the kernel.

Also add this new param to all underlying interfaces, so that we can
get rid of the conditional flag interleave in APIs but only to the
toppest and lowest one.

Change-Id: I2233391f4e7313cf4134c975e14b6060ad852c5d
CRs-fixed: 966067
This commit is contained in:
Ryan Hsu 2016-01-21 15:25:39 -08:00 • committed by Vishwajith Upendra
commit 07495ea2e6
7 changed files with 144 additions and 32 deletions

View file

@ -247,6 +247,15 @@
#endif
#endif
/*
* NET_NAME_UNKNOWN is only introduced after Kernel 3.17, to have a macro
* here if the Kernel version is less than 3.17 to avoid the interleave
* conditional compilation.
*/
#if !((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS))
#define NET_NAME_UNKNOWN 0
#endif
#define BSS_WAIT_TIMEOUT 10000
/*
@ -1398,6 +1407,7 @@ QDF_STATUS hdd_add_adapter_front(hdd_context_t *pHddCtx,
hdd_adapter_t *hdd_open_adapter(hdd_context_t *pHddCtx, uint8_t session_type,
const char *name, tSirMacAddr macAddr,
unsigned char name_assign_type,
bool rtnl_held);
QDF_STATUS hdd_close_adapter(hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter,
bool rtnl_held);

View file

@ -129,12 +129,22 @@ int wlan_hdd_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
bool dont_wait_for_ack, u64 *cookie);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) || defined(WITH_BACKPORTS)
struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
const char *name,
unsigned char name_assign_type,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params);
#else
struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
const char *name,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params);
#endif
int wlan_hdd_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);

View file

@ -612,7 +612,8 @@ static int hdd_ftm_service_registration(hdd_context_t *hdd_ctx)
{
hdd_adapter_t *adapter;
adapter = hdd_open_adapter(hdd_ctx, WLAN_HDD_FTM, "wlan%d",
wlan_hdd_get_intf_addr(hdd_ctx), false);
wlan_hdd_get_intf_addr(hdd_ctx),
NET_NAME_UNKNOWN, false);
if (NULL == adapter) {
hddLog(QDF_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed",
__func__);

View file

@ -6143,6 +6143,7 @@ error_wmm_init:
* hdd_wlan_create_ap_dev() - create an AP-mode device
* @pHddCtx: Global HDD context
* @macAddr: MAC address to assign to the interface
* @name_assign_type: the name of assign type of the netdev
* @iface_name: User-visible name of the interface
*
* This function will allocate a Linux net_device and configuration it
@ -6154,19 +6155,19 @@ error_wmm_init:
*/
hdd_adapter_t *hdd_wlan_create_ap_dev(hdd_context_t *pHddCtx,
tSirMacAddr macAddr,
uint8_t *iface_name) {
unsigned char name_assign_type,
uint8_t *iface_name)
{
struct net_device *pWlanHostapdDev = NULL;
hdd_adapter_t *pHostapdAdapter = NULL;
hddLog(LOG4, FL("iface_name = %s"), iface_name);
pWlanHostapdDev =
alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0))
NET_NAME_UNKNOWN,
pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
name_assign_type,
#endif
ether_setup,
NUM_TX_QUEUES);
ether_setup, NUM_TX_QUEUES);
if (pWlanHostapdDev != NULL) {
pHostapdAdapter = netdev_priv(pWlanHostapdDev);

View file

@ -48,7 +48,9 @@
#define HOSTAPD_IOCTL_COMMAND_STRLEN_MAX 8192
hdd_adapter_t *hdd_wlan_create_ap_dev(hdd_context_t *pHddCtx,
tSirMacAddr macAddr, uint8_t *name);
tSirMacAddr macAddr,
unsigned char name_assign_type,
uint8_t *name);
QDF_STATUS hdd_register_hostapd(hdd_adapter_t *pAdapter, uint8_t rtnl_held);

View file

@ -1887,8 +1887,20 @@ void hdd_set_station_ops(struct net_device *pWlanDev)
pWlanDev->netdev_ops = &wlan_drv_ops;
}
/**
* hdd_alloc_station_adapter() - allocate the station hdd adapter
* @hdd_ctx: global hdd context
* @macAddr: mac address to assign to the interface
* @name: User-visible name of the interface
*
* hdd adapter pointer would point to the netdev->priv space, this function
* would retrive the pointer, and setup the hdd adapter configuration.
*
* Return: the pointer to hdd adapter, otherwise NULL
*/
static hdd_adapter_t *hdd_alloc_station_adapter(hdd_context_t *hdd_ctx,
tSirMacAddr macAddr,
unsigned char name_assign_type,
const char *name)
{
struct net_device *pWlanDev = NULL;
@ -1896,13 +1908,11 @@ static hdd_adapter_t *hdd_alloc_station_adapter(hdd_context_t *hdd_ctx,
/*
* cfg80211 initialization and registration....
*/
pWlanDev =
alloc_netdev_mq(sizeof(hdd_adapter_t), name,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0))
NET_NAME_UNKNOWN,
pWlanDev = alloc_netdev_mq(sizeof(hdd_adapter_t), name,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
name_assign_type,
#endif
ether_setup,
NUM_TX_QUEUES);
ether_setup, NUM_TX_QUEUES);
if (pWlanDev != NULL) {
@ -2347,8 +2357,25 @@ QDF_STATUS hdd_check_for_existing_macaddr(hdd_context_t *hdd_ctx,
}
return QDF_STATUS_SUCCESS;
}
/**
* hdd_open_adapter() - open and setup the hdd adatper
* @hdd_ctx: global hdd context
* @session_type: type of the interface to be created
* @iface_name: User-visible name of the interface
* @macAddr: MAC address to assign to the interface
* @name_assign_type: the name of assign type of the netdev
* @rtnl_held: the rtnl lock hold flag
*
* This function open and setup the hdd adpater according to the device
* type request, assign the name, the mac address assigned, and then prepared
* the hdd related parameters, queue, lock and ready to start.
*
* Return: the pointer of hdd adapter, otherwise NULL.
*/
hdd_adapter_t *hdd_open_adapter(hdd_context_t *hdd_ctx, uint8_t session_type,
const char *iface_name, tSirMacAddr macAddr,
unsigned char name_assign_type,
bool rtnl_held)
{
hdd_adapter_t *adapter = NULL;
@ -2398,8 +2425,9 @@ hdd_adapter_t *hdd_open_adapter(hdd_context_t *hdd_ctx, uint8_t session_type,
case WLAN_HDD_P2P_DEVICE:
case WLAN_HDD_OCB:
{
adapter =
hdd_alloc_station_adapter(hdd_ctx, macAddr, iface_name);
adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr,
name_assign_type,
iface_name);
if (NULL == adapter) {
hddLog(QDF_TRACE_LEVEL_FATAL,
@ -2470,9 +2498,9 @@ hdd_adapter_t *hdd_open_adapter(hdd_context_t *hdd_ctx, uint8_t session_type,
case WLAN_HDD_P2P_GO:
case WLAN_HDD_SOFTAP:
{
adapter =
hdd_wlan_create_ap_dev(hdd_ctx, macAddr,
(uint8_t *) iface_name);
adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr,
name_assign_type,
(uint8_t *) iface_name);
if (NULL == adapter) {
hddLog(QDF_TRACE_LEVEL_FATAL,
FL("failed to allocate adapter for session %d"),
@ -2505,8 +2533,9 @@ hdd_adapter_t *hdd_open_adapter(hdd_context_t *hdd_ctx, uint8_t session_type,
}
case WLAN_HDD_FTM:
{
adapter =
hdd_alloc_station_adapter(hdd_ctx, macAddr, iface_name);
adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr,
name_assign_type,
iface_name);
if (NULL == adapter) {
hddLog(QDF_TRACE_LEVEL_FATAL,
@ -5307,7 +5336,7 @@ static int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, bool rtnl_held)
adapter = hdd_open_adapter(hdd_ctx, WLAN_HDD_P2P_DEVICE, "p2p%d",
&hdd_ctx->p2pDeviceAddress.bytes[0],
rtnl_held);
NET_NAME_UNKNOWN, rtnl_held);
if (NULL == adapter) {
hdd_alert("Failed to do hdd_open_adapter for P2P Device Interface");
@ -5344,7 +5373,7 @@ static hdd_adapter_t *hdd_open_interfaces(hdd_context_t *hdd_ctx,
if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) {
adapter = hdd_open_adapter(hdd_ctx, WLAN_HDD_OCB, "wlanocb%d",
wlan_hdd_get_intf_addr(hdd_ctx),
rtnl_held);
NET_NAME_UNKNOWN, rtnl_held);
if (adapter == NULL)
return ERR_PTR(-ENOSPC);
@ -5354,7 +5383,7 @@ static hdd_adapter_t *hdd_open_interfaces(hdd_context_t *hdd_ctx,
adapter = hdd_open_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION, "wlan%d",
wlan_hdd_get_intf_addr(hdd_ctx),
rtnl_held);
NET_NAME_UNKNOWN, rtnl_held);
if (adapter == NULL)
return ERR_PTR(-ENOSPC);
@ -5368,7 +5397,7 @@ static hdd_adapter_t *hdd_open_interfaces(hdd_context_t *hdd_ctx,
adapter_11p = hdd_open_adapter(hdd_ctx, WLAN_HDD_OCB,
"wlanocb%d",
wlan_hdd_get_intf_addr(hdd_ctx),
rtnl_held);
NET_NAME_UNKNOWN, rtnl_held);
if (adapter_11p == NULL) {
hdd_err("Failed to open 802.11p interface");
goto err_close_adapter;

View file

@ -1949,8 +1949,20 @@ static uint8_t wlan_hdd_get_session_type(enum nl80211_iftype type)
return sessionType;
}
/**
* __wlan_hdd_add_virtual_intf() - Add virtual interface
* @wiphy: wiphy pointer
* @name: User-visible name of the interface
* @name_assign_type: the name of assign type of the netdev
* @nl80211_iftype: (virtual) interface types
* @flags: moniter configuraiton flags (not used)
* @vif_params: virtual interface parameters (not used)
*
* Return: the pointer of wireless dev, otherwise NULL.
*/
struct wireless_dev *__wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
const char *name,
unsigned char name_assign_type,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params)
@ -2020,12 +2032,16 @@ struct wireless_dev *__wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
p2pDeviceAddress.bytes[4] ^= 0x80;
pAdapter = hdd_open_adapter(pHddCtx,
wlan_hdd_get_session_type(type),
name, p2pDeviceAddress.bytes, true);
name, p2pDeviceAddress.bytes,
name_assign_type,
true);
} else {
pAdapter =
hdd_open_adapter(pHddCtx, wlan_hdd_get_session_type(type),
name, wlan_hdd_get_intf_addr(pHddCtx),
true);
pAdapter = hdd_open_adapter(pHddCtx,
wlan_hdd_get_session_type(type),
name,
wlan_hdd_get_intf_addr(pHddCtx),
name_assign_type,
true);
}
if (NULL == pAdapter) {
@ -2037,8 +2053,21 @@ struct wireless_dev *__wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
return pAdapter->dev->ieee80211_ptr;
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) || defined(WITH_BACKPORTS)
/**
* wlan_hdd_add_virtual_intf() - Add virtual interface wrapper
* @wiphy: wiphy pointer
* @name: User-visible name of the interface
* @name_assign_type: the name of assign type of the netdev
* @nl80211_iftype: (virtual) interface types
* @flags: monitor mode configuration flags (not used)
* @vif_params: virtual interface parameters (not used)
*
* Return: the pointer of wireless dev, otherwise NULL.
*/
struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
const char *name,
unsigned char name_assign_type,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params)
@ -2046,10 +2075,40 @@ struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
struct wireless_dev *wdev;
cds_ssr_protect(__func__);
wdev = __wlan_hdd_add_virtual_intf(wiphy, name, type, flags, params);
wdev = __wlan_hdd_add_virtual_intf(wiphy, name, name_assign_type,
type, flags, params);
cds_ssr_unprotect(__func__);
return wdev;
}
#else
/**
* wlan_hdd_add_virtual_intf() - Add virtual interface wrapper
* @wiphy: wiphy pointer
* @name: User-visible name of the interface
* @nl80211_iftype: (virtual) interface types
* @flags: monitor mode configuration flags (not used)
* @vif_params: virtual interface parameters (not used)
*
* Return: the pointer of wireless dev, otherwise NULL.
*/
struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
const char *name,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params)
{
struct wireless_dev *wdev;
unsigned char name_assign_type = 0;
cds_ssr_protect(__func__);
wdev = __wlan_hdd_add_virtual_intf(wiphy, name, name_assign_type,
type, flags, params);
cds_ssr_unprotect(__func__);
return wdev;
}
#endif
int __wlan_hdd_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
{