qcacld-3.0: Use cfg80211_register_netdevice() for kernel 5.12+

For Kernel 5.12+ in order to be in line with cfg80211 changes
in upstream code, use cfg80211_register_netdevice() and
cfg80211_unregister_netdevice() when request to register device is
coming from add virtual interface.

Change-Id: Ibc11d405ab8b06e170bcb261970bc4ccccafe291
CRs-Fixed: 3133264
This commit is contained in:
Alan Chen
2022-02-17 13:30:20 -08:00
committed by Madan Koyyalamudi
parent 9baa0c1243
commit 40a7b4a2f9
4 changed files with 59 additions and 8 deletions

View File

@@ -1248,6 +1248,7 @@ struct hdd_context;
* @delete_in_progress: Flag to indicate that the adapter delete is in
* progress, and any operation using rtnl lock inside
* the driver can be avoided/skipped.
* @is_virtual_iface: Indicates that netdev is called from virtual interface
* @mon_adapter: hdd_adapter of monitor mode.
* @set_mac_addr_req_ctx: Set MAC address command request context
*/
@@ -1569,6 +1570,7 @@ struct hdd_adapter {
/* Flag to indicate whether it is a pre cac adapter or not */
bool is_pre_cac_adapter;
bool delete_in_progress;
bool is_virtual_iface;
#ifdef WLAN_FEATURE_BIG_DATA_STATS
struct big_data_stats_event big_data_stats;
#endif

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -31,12 +31,14 @@
* @only_wdev_register: Register only the wdev not the netdev
* @associate_with_ml_adapter: Vdev points to the same netdev adapter
* @is_ml_adapter: is a ml adapter with associated netdev
* @is_add_virtual_iface: is netdev create request from add virtual interface
*/
struct hdd_adapter_create_param {
uint32_t only_wdev_register:1,
associate_with_ml_adapter:1,
is_ml_adapter:1,
unused:29;
is_add_virtual_iface:1,
unused:28;
};
#if defined(WLAN_FEATURE_11BE_MLO) && defined(CFG80211_11BE_BASIC)

View File

@@ -6237,7 +6237,32 @@ free_net_dev:
return NULL;
}
static QDF_STATUS hdd_register_interface(struct hdd_adapter *adapter, bool rtnl_held)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
static int
hdd_register_netdevice(struct hdd_adapter *adapter, struct net_device *dev,
struct hdd_adapter_create_param *params)
{
int ret;
if (params->is_add_virtual_iface)
ret = wlan_cfg80211_register_netdevice(dev);
else
ret = register_netdevice(dev);
return ret;
}
#else
static int
hdd_register_netdevice(struct hdd_adapter *adapter, struct net_device *dev,
struct hdd_adapter_create_param *params)
{
return register_netdevice(dev);
}
#endif
static QDF_STATUS
hdd_register_interface(struct hdd_adapter *adapter, bool rtnl_held,
struct hdd_adapter_create_param *params)
{
struct net_device *dev = adapter->dev;
int ret;
@@ -6256,7 +6281,7 @@ static QDF_STATUS hdd_register_interface(struct hdd_adapter *adapter, bool rtnl_
}
}
ret = register_netdevice(dev);
ret = hdd_register_netdevice(adapter, dev, params);
if (ret) {
hdd_err("register_netdevice(%s) failed, err = 0x%x",
dev->name, ret);
@@ -6971,6 +6996,25 @@ void hdd_sta_destroy_ctx_all(struct hdd_context *hdd_ctx)
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
static void
hdd_unregister_netdevice(struct hdd_adapter *adapter, struct net_device *dev)
{
if (adapter->is_virtual_iface) {
wlan_cfg80211_unregister_netdevice(dev);
adapter->is_virtual_iface = false;
} else {
unregister_netdevice(dev);
}
}
#else
static void
hdd_unregister_netdevice(struct hdd_adapter *adapter, struct net_device *dev)
{
unregister_netdevice(dev);
}
#endif
static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx,
struct hdd_adapter *adapter,
bool rtnl_held)
@@ -7009,7 +7053,7 @@ static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx,
if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) {
if (rtnl_held)
unregister_netdevice(dev);
hdd_unregister_netdevice(adapter, dev);
else
unregister_netdev(dev);
/*
@@ -7644,7 +7688,7 @@ struct hdd_adapter *hdd_open_adapter(struct hdd_context *hdd_ctx,
break;
}
status = hdd_register_interface(adapter, rtnl_held);
status = hdd_register_interface(adapter, rtnl_held, params);
if (QDF_STATUS_SUCCESS != status)
goto err_free_netdev;
@@ -7680,7 +7724,7 @@ struct hdd_adapter *hdd_open_adapter(struct hdd_context *hdd_ctx,
NL80211_IFTYPE_P2P_GO;
adapter->device_mode = session_type;
status = hdd_register_interface(adapter, rtnl_held);
status = hdd_register_interface(adapter, rtnl_held, params);
if (QDF_STATUS_SUCCESS != status)
goto err_free_netdev;
@@ -7721,7 +7765,7 @@ struct hdd_adapter *hdd_open_adapter(struct hdd_context *hdd_ctx,
adapter->wdev.iftype = NL80211_IFTYPE_STATION;
adapter->device_mode = session_type;
status = hdd_register_interface(adapter, rtnl_held);
status = hdd_register_interface(adapter, rtnl_held, params);
if (QDF_STATUS_SUCCESS != status)
goto err_free_netdev;

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -719,6 +720,7 @@ struct wireless_dev *__wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
break;
}
create_params.is_add_virtual_iface = 1;
adapter = hdd_get_adapter(hdd_ctx, QDF_STA_MODE);
if (adapter && !wlan_hdd_validate_vdev_id(adapter->vdev_id)) {
vdev = hdd_objmgr_get_vdev_by_user(adapter, WLAN_OSIF_P2P_ID);
@@ -963,6 +965,7 @@ int wlan_hdd_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
osif_vdev_sync_unregister(wdev->netdev);
osif_vdev_sync_wait_for_ops(vdev_sync);
adapter->is_virtual_iface = true;
errno = __wlan_hdd_del_virtual_intf(wiphy, wdev);
osif_vdev_sync_trans_stop(vdev_sync);