Jelajahi Sumber

qcacld-3.0: Remove the dependency on NDI name

Currently in driver, NAN Data Interface can be created with
only name "aware_data" which creates dependency on interface name.

To remove the dependency, the interface is created now by name
provided by Wifi-HAL.

For this, interface is created in STA mode with name provided by
WiFi-HAl. While processing  vendor cmd QCA_NL80211_VENDOR_SUBCMD_NDP,
given ifname is searched in adapter list and mode is changed to NDI.

CRs-Fixed: 3196179
Change-Id: I62dd512f8a7de4c69a53babf3112942d348bf3b6
Rahul Gusain 2 tahun lalu
induk
melakukan
bfc2c02560

+ 2 - 0
components/nan/core/inc/nan_public_structs.h

@@ -784,6 +784,7 @@ struct nan_datapath_host_event {
  * request processing is complete
  * @ndi_open: HDD callback for creating the NAN Datapath Interface
  * @ndi_start: HDD callback for starting the NAN Datapath Interface
+ * @ndi_set_mode: HDD callback for setting the adapter mode to NDI
  * @ndi_close: HDD callback for closing the NAN Datapath Interface
  * @ndi_delete: HDD callback for deleting the NAN Datapath Interface
  * @drv_ndi_create_rsp_handler: HDD callback for handling NDI interface creation
@@ -804,6 +805,7 @@ struct nan_callbacks {
 					uint32_t type, void *msg);
 	void (*ucfg_nan_request_process_cb)(void *cookie);
 	int (*ndi_open)(const char *iface_name, bool is_add_virtual_iface);
+	int (*ndi_set_mode)(const char *iface_name);
 	int (*ndi_start)(const char *iface_name, uint16_t);
 	void (*ndi_close)(uint8_t);
 	int (*ndi_delete)(uint8_t, const char *iface_name, uint16_t transaction_id);

+ 1 - 0
components/nan/dispatcher/src/nan_ucfg_api.c

@@ -604,6 +604,7 @@ int ucfg_nan_register_hdd_callbacks(struct wlan_objmgr_psoc *psoc,
 	}
 
 	psoc_obj->cb_obj.ndi_open = cb_obj->ndi_open;
+	psoc_obj->cb_obj.ndi_set_mode = cb_obj->ndi_set_mode;
 	psoc_obj->cb_obj.ndi_start = cb_obj->ndi_start;
 	psoc_obj->cb_obj.ndi_delete = cb_obj->ndi_delete;
 	psoc_obj->cb_obj.ndi_close = cb_obj->ndi_close;

+ 1 - 0
core/hdd/src/wlan_hdd_main.c

@@ -3905,6 +3905,7 @@ static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx)
 
 	cb_obj.ndi_open = hdd_ndi_open;
 	cb_obj.ndi_close = hdd_ndi_close;
+	cb_obj.ndi_set_mode = hdd_ndi_set_mode;
 	cb_obj.ndi_start = hdd_ndi_start;
 	cb_obj.ndi_delete = hdd_ndi_delete;
 	cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler;

+ 44 - 21
core/hdd/src/wlan_hdd_nan_datapath.c

@@ -735,6 +735,50 @@ int hdd_ndi_open(const char *iface_name, bool is_add_virtual_iface)
 	return 0;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0))
+int hdd_ndi_set_mode(const char *iface_name)
+{
+	struct hdd_adapter *adapter;
+	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	struct qdf_mac_addr random_ndi_mac;
+	uint8_t *ndi_mac_addr = NULL;
+
+	hdd_enter();
+	if (!hdd_ctx)
+		return -EINVAL;
+
+	adapter = hdd_get_adapter_by_iface_name(hdd_ctx, iface_name);
+	if (!adapter) {
+		hdd_err("adapter is null");
+		return -EINVAL;
+	}
+
+	if (cfg_nan_get_ndi_mac_randomize(hdd_ctx->psoc)) {
+		if (hdd_get_random_nan_mac_addr(hdd_ctx, &random_ndi_mac)) {
+			hdd_err("get random mac address failed");
+			return -EFAULT;
+		}
+		ndi_mac_addr = &random_ndi_mac.bytes[0];
+	}
+
+	if (!ndi_mac_addr) {
+		hdd_err("ndi mac address is null");
+		return -EINVAL;
+	}
+
+	hdd_update_dynamic_mac(hdd_ctx, &adapter->mac_addr,
+			       (struct qdf_mac_addr *)ndi_mac_addr);
+	qdf_mem_copy(&adapter->mac_addr, ndi_mac_addr, ETH_ALEN);
+	qdf_mem_copy(adapter->dev->dev_addr, ndi_mac_addr, ETH_ALEN);
+
+	adapter->device_mode = QDF_NDI_MODE;
+	hdd_debug("Created NDI with device mode:%d and iface_name:%s",
+		  adapter->device_mode, iface_name);
+
+	return 0;
+}
+#endif
+
 int hdd_ndi_start(const char *iface_name, uint16_t transaction_id)
 {
 	int ret;
@@ -791,27 +835,6 @@ err_handler:
 	return ret;
 }
 
-struct wireless_dev *hdd_add_ndi_intf(struct hdd_context *hdd_ctx,
-				      const char *name)
-{
-	int ret;
-	struct hdd_adapter *adapter;
-
-	hdd_debug("change mode to NDI");
-
-	ret = hdd_ndi_open(name, true);
-	if (ret) {
-		hdd_err("ndi_open failed");
-		return ERR_PTR(-EINVAL);
-	}
-	adapter = hdd_get_adapter_by_iface_name(hdd_ctx, name);
-	if (!adapter) {
-		hdd_err("adapter is null");
-		return ERR_PTR(-EINVAL);
-	}
-	return adapter->dev->ieee80211_ptr;
-}
-
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0))
 static int hdd_delete_ndi_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
 {

+ 20 - 13
core/hdd/src/wlan_hdd_nan_datapath.h

@@ -84,16 +84,6 @@ void hdd_cleanup_ndi(struct hdd_context *hdd_ctx,
  */
 int hdd_ndi_start(const char *iface_name, uint16_t transaction_id);
 
-/**
- * hdd_add_ndi_intf(): Add NDI interface
- * @hdd_ctx: Hdd context
- * @name: NDI interface name
- *
- * Return: wireless dev
- */
-struct wireless_dev *hdd_add_ndi_intf(struct hdd_context *hdd_ctx,
-				      const char *name);
-
 enum nan_datapath_state;
 struct nan_datapath_inf_create_rsp;
 
@@ -170,6 +160,24 @@ void hdd_ndp_peer_departed_handler(uint8_t vdev_id, uint16_t sta_id,
 				   struct qdf_mac_addr *peer_mac_addr,
 				   bool last_peer);
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0))
+/**
+ * hdd_ndi_set_mode(): set the adapter mode to NDI
+ * @iface_name: NDI interface name
+ *
+ * The adapter mode is STA while creating virtual interface.
+ * mode is set to NDI while creating NDI.
+ *
+ * Return: 0 upon success
+ */
+int hdd_ndi_set_mode(const char *iface_name);
+#else
+static inline int hdd_ndi_set_mode(const char *iface_name)
+{
+	return 0;
+}
+#endif /* LINUX_VERSION_CODE  */
+
 #else
 #define WLAN_HDD_IS_NDI(adapter)	(false)
 #define WLAN_HDD_IS_NDI_CONNECTED(adapter) (false)
@@ -207,10 +215,9 @@ static inline int hdd_ndi_start(const char *iface_name, uint16_t transaction_id)
 	return 0;
 }
 
-static inline struct wireless_dev *hdd_add_ndi_intf(struct hdd_context *hdd_ctx,
-						    const char *name)
+static inline int hdd_ndi_set_mode(const char *iface_name)
 {
-	return NULL;
+	return 0;
 }
 
 enum nan_datapath_state;

+ 1 - 5
core/hdd/src/wlan_hdd_p2p.c

@@ -787,10 +787,6 @@ struct wireless_dev *__wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
 		if (strnstr(name, "p2p", 3) && mode == QDF_STA_MODE) {
 			hdd_debug("change mode to p2p device");
 			mode = QDF_P2P_DEVICE_MODE;
-		} else if (strnstr(name, "aware_data", 10) &&
-			   mode == QDF_STA_MODE) {
-			hdd_debug("add interface %s", name);
-			return hdd_add_ndi_intf(hdd_ctx, name);
 		}
 
 		device_address = wlan_hdd_get_intf_addr(hdd_ctx, mode);
@@ -806,7 +802,7 @@ struct wireless_dev *__wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
 	}
 
 	if (!adapter) {
-		hdd_err("hdd_open_adapter failed");
+		hdd_err("hdd_open_adapter failed with iftype %d", type);
 		return ERR_PTR(-ENOSPC);
 	}
 

+ 5 - 0
os_if/nan/src/os_if_nan.c

@@ -331,6 +331,11 @@ static int __os_if_nan_process_ndi_create(struct wlan_objmgr_psoc *psoc,
 		return -EINVAL;
 	}
 
+	if (cb_obj.ndi_set_mode(iface_name)) {
+		osif_err("NDI set mode fails");
+		return -EINVAL;
+	}
+
 	ret = os_if_nan_ndi_open(psoc, iface_name);
 	if (ret)
 		return ret;