Browse Source

Revert "qcacld-3.0: Get netdev from wdev instead of iface name"

This reverts commit Idf394f4a22ace8757f947b2ef8e4a7d22e66d65e
which is causing termination of NDP session immediately after
formation.

Change-Id: I88a9c4ab80b727e5bda7a9f9c7e8b48399f98a34
CRs-Fixed: 3133498
Ashish 3 years ago
parent
commit
b9745bd455
3 changed files with 68 additions and 34 deletions
  1. 1 1
      core/hdd/src/wlan_hdd_nan_datapath.c
  2. 1 3
      os_if/nan/inc/os_if_nan.h
  3. 66 30
      os_if/nan/src/os_if_nan.c

+ 1 - 1
core/hdd/src/wlan_hdd_nan_datapath.c

@@ -557,7 +557,7 @@ static int __wlan_hdd_cfg80211_process_ndp_cmd(struct wiphy *wiphy,
 	}
 
 	return os_if_nan_process_ndp_cmd(hdd_ctx->psoc, data, data_len,
-					 hdd_is_ndp_allowed(hdd_ctx), wdev);
+					 hdd_is_ndp_allowed(hdd_ctx));
 }
 
 /**

+ 1 - 3
os_if/nan/inc/os_if_nan.h

@@ -55,14 +55,12 @@ struct ndi_find_vdev_filter {
  * @data_len: length of data
  * @is_ndp_allowed: Indicates whether to allow NDP creation.
  *		    NDI creation is always allowed.
- * @wdev: Wireless device structure pointer
  *
  * Return: status of operation
  */
 int os_if_nan_process_ndp_cmd(struct wlan_objmgr_psoc *psoc,
 			      const void *data, int data_len,
-			      bool is_ndp_allowed,
-			      struct wireless_dev *wdev);
+			      bool is_ndp_allowed);
 
 /**
  * os_if_nan_register_hdd_callbacks: os_if api to register hdd callbacks

+ 66 - 30
os_if/nan/src/os_if_nan.c

@@ -353,11 +353,35 @@ static int osif_net_dev_from_vdev(struct wlan_objmgr_vdev *vdev,
 	return 0;
 }
 
+static int osif_net_dev_from_ifname(struct wlan_objmgr_psoc *psoc,
+				    char *iface_name,
+				    struct net_device **out_net_dev)
+{
+	struct wlan_objmgr_vdev *vdev;
+	struct net_device *net_dev;
+	int errno;
+
+	vdev = os_if_get_ndi_vdev_by_ifname(psoc, iface_name);
+	if (!vdev)
+		return -EINVAL;
+
+	errno = osif_net_dev_from_vdev(vdev, &net_dev);
+
+	wlan_objmgr_vdev_release_ref(vdev, WLAN_NAN_ID);
+
+	if (errno)
+		return errno;
+
+	*out_net_dev = net_dev;
+
+	return 0;
+}
+
 static int os_if_nan_process_ndi_create(struct wlan_objmgr_psoc *psoc,
-					struct nlattr **tb,
-					struct wireless_dev *wdev)
+					struct nlattr **tb)
 {
 	struct device *dev;
+	struct net_device *net_dev;
 	struct osif_vdev_sync *vdev_sync;
 	char *ifname;
 	int errno;
@@ -378,7 +402,11 @@ static int os_if_nan_process_ndi_create(struct wlan_objmgr_psoc *psoc,
 	if (errno)
 		goto destroy_sync;
 
-	osif_vdev_sync_register(wdev->netdev, vdev_sync);
+	errno = osif_net_dev_from_ifname(psoc, ifname, &net_dev);
+	if (errno)
+		goto destroy_sync;
+
+	osif_vdev_sync_register(net_dev, vdev_sync);
 	osif_vdev_sync_trans_stop(vdev_sync);
 
 	return 0;
@@ -437,9 +465,9 @@ static int __os_if_nan_process_ndi_delete(struct wlan_objmgr_psoc *psoc,
 }
 
 static int os_if_nan_process_ndi_delete(struct wlan_objmgr_psoc *psoc,
-					struct nlattr **tb,
-					struct wireless_dev *wdev)
+					struct nlattr **tb)
 {
+	struct net_device *net_dev;
 	struct osif_vdev_sync *vdev_sync;
 	char *ifname;
 	int errno;
@@ -448,11 +476,15 @@ static int os_if_nan_process_ndi_delete(struct wlan_objmgr_psoc *psoc,
 	if (errno)
 		return errno;
 
-	errno = osif_vdev_sync_trans_start_wait(wdev->netdev, &vdev_sync);
+	errno = osif_net_dev_from_ifname(psoc, ifname, &net_dev);
+	if (errno)
+		return errno;
+
+	errno = osif_vdev_sync_trans_start_wait(net_dev, &vdev_sync);
 	if (errno)
 		return errno;
 
-	osif_vdev_sync_unregister(wdev->netdev);
+	osif_vdev_sync_unregister(net_dev);
 	osif_vdev_sync_wait_for_ops(vdev_sync);
 
 	errno = __os_if_nan_process_ndi_delete(psoc, ifname, tb);
@@ -465,7 +497,7 @@ static int os_if_nan_process_ndi_delete(struct wlan_objmgr_psoc *psoc,
 	return 0;
 
 reregister:
-	osif_vdev_sync_register(wdev->netdev, vdev_sync);
+	osif_vdev_sync_register(net_dev, vdev_sync);
 	osif_vdev_sync_trans_stop(vdev_sync);
 
 	return errno;
@@ -678,9 +710,9 @@ initiator_req_failed:
 }
 
 static int os_if_nan_process_ndp_initiator_req(struct wlan_objmgr_psoc *psoc,
-					       struct nlattr **tb,
-					       struct wireless_dev *wdev)
+					       struct nlattr **tb)
 {
+	struct net_device *net_dev;
 	struct osif_vdev_sync *vdev_sync;
 	char *ifname;
 	int errno;
@@ -689,7 +721,11 @@ static int os_if_nan_process_ndp_initiator_req(struct wlan_objmgr_psoc *psoc,
 	if (errno)
 		return errno;
 
-	errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync);
+	errno = osif_net_dev_from_ifname(psoc, ifname, &net_dev);
+	if (errno)
+		return errno;
+
+	errno = osif_vdev_sync_op_start(net_dev, &vdev_sync);
 	if (errno)
 		return errno;
 
@@ -720,6 +756,7 @@ static int os_if_nan_process_ndp_initiator_req(struct wlan_objmgr_psoc *psoc,
  * Return: 0 on success or error code on failure
  */
 static int __os_if_nan_process_ndp_responder_req(struct wlan_objmgr_psoc *psoc,
+						 char *iface_name,
 						 struct nlattr **tb)
 {
 	int ret = 0;
@@ -727,8 +764,6 @@ static int __os_if_nan_process_ndp_responder_req(struct wlan_objmgr_psoc *psoc,
 	enum nan_datapath_state state;
 	struct wlan_objmgr_vdev *nan_vdev = NULL;
 	struct nan_datapath_responder_req req = {0};
-	char *iface_name;
-	int errno;
 
 	if (!tb[QCA_WLAN_VENDOR_ATTR_NDP_RESPONSE_CODE]) {
 		osif_err("ndp_rsp is unavailable");
@@ -737,13 +772,6 @@ static int __os_if_nan_process_ndp_responder_req(struct wlan_objmgr_psoc *psoc,
 	req.ndp_rsp = nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_NDP_RESPONSE_CODE]);
 
 	if (req.ndp_rsp == NAN_DATAPATH_RESPONSE_ACCEPT) {
-
-		errno = osif_nla_str(tb, QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR,
-				     &iface_name);
-		if (errno) {
-			osif_err("NAN data iface not provided");
-			return errno;
-		}
 		/* Check for an existing NAN interface */
 		nan_vdev = os_if_get_ndi_vdev_by_ifname(psoc, iface_name);
 		if (!nan_vdev) {
@@ -871,17 +899,26 @@ responder_req_failed:
 }
 
 static int os_if_nan_process_ndp_responder_req(struct wlan_objmgr_psoc *psoc,
-					       struct nlattr **tb,
-					       struct wireless_dev *wdev)
+					       struct nlattr **tb)
 {
+	struct net_device *net_dev;
 	struct osif_vdev_sync *vdev_sync;
+	char *ifname;
 	int errno;
 
-	errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync);
+	errno = osif_nla_str(tb, QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR, &ifname);
+	if (errno)
+		return errno;
+
+	errno = osif_net_dev_from_ifname(psoc, ifname, &net_dev);
+	if (errno)
+		return errno;
+
+	errno = osif_vdev_sync_op_start(net_dev, &vdev_sync);
 	if (errno)
 		return errno;
 
-	errno = __os_if_nan_process_ndp_responder_req(psoc, tb);
+	errno = __os_if_nan_process_ndp_responder_req(psoc, ifname, tb);
 
 	osif_vdev_sync_op_stop(vdev_sync);
 
@@ -981,8 +1018,7 @@ static int os_if_nan_process_ndp_end_req(struct wlan_objmgr_psoc *psoc,
 
 int os_if_nan_process_ndp_cmd(struct wlan_objmgr_psoc *psoc,
 			      const void *data, int data_len,
-			      bool is_ndp_allowed,
-			      struct wireless_dev *wdev)
+			      bool is_ndp_allowed)
 {
 	uint32_t ndp_cmd_type;
 	uint16_t transaction_id;
@@ -1030,21 +1066,21 @@ int os_if_nan_process_ndp_cmd(struct wlan_objmgr_psoc *psoc,
 			osif_err("NDI creation is not allowed when NAN discovery is not running");
 			return -EOPNOTSUPP;
 		}
-		return os_if_nan_process_ndi_create(psoc, tb, wdev);
+		return os_if_nan_process_ndi_create(psoc, tb);
 	case QCA_WLAN_VENDOR_ATTR_NDP_INTERFACE_DELETE:
-		return os_if_nan_process_ndi_delete(psoc, tb, wdev);
+		return os_if_nan_process_ndi_delete(psoc, tb);
 	case QCA_WLAN_VENDOR_ATTR_NDP_INITIATOR_REQUEST:
 		if (!is_ndp_allowed) {
 			osif_err("Unsupported concurrency for NAN datapath");
 			return -EOPNOTSUPP;
 		}
-		return os_if_nan_process_ndp_initiator_req(psoc, tb, wdev);
+		return os_if_nan_process_ndp_initiator_req(psoc, tb);
 	case QCA_WLAN_VENDOR_ATTR_NDP_RESPONDER_REQUEST:
 		if (!is_ndp_allowed) {
 			osif_err("Unsupported concurrency for NAN datapath");
 			return -EOPNOTSUPP;
 		}
-		return os_if_nan_process_ndp_responder_req(psoc, tb, wdev);
+		return os_if_nan_process_ndp_responder_req(psoc, tb);
 	case QCA_WLAN_VENDOR_ATTR_NDP_END_REQUEST:
 		if (!is_ndp_allowed) {
 			osif_err("Unsupported concurrency for NAN datapath");