Explorar el Código

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

Currently driver uses iface name to get netdev when it processes
ndp responder request. There is a possibility that framework does
not know the iface name when it sends the error response.

if driver does not receive iface name it fails to get the netdev
and fails to perform the dsc operation, because of which driver
drops the ndp responder request command.

To address this issue, use wdev to get netdev instead of iface name.

Change-Id: Idf394f4a22ace8757f947b2ef8e4a7d22e66d65e
CRs-Fixed: 3124009
Ashish hace 3 años
padre
commit
db7441ab3f
Se han modificado 3 ficheros con 37 adiciones y 70 borrados
  1. 2 2
      core/hdd/src/wlan_hdd_nan_datapath.c
  2. 4 1
      os_if/nan/inc/os_if_nan.h
  3. 31 67
      os_if/nan/src/os_if_nan.c

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

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2016-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
@@ -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));
+					 hdd_is_ndp_allowed(hdd_ctx), wdev);
 }
 
 /**

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

@@ -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
@@ -54,12 +55,14 @@ 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);
+			      bool is_ndp_allowed,
+			      struct wireless_dev *wdev);
 
 /**
  * os_if_nan_register_hdd_callbacks: os_if api to register hdd callbacks

+ 31 - 67
os_if/nan/src/os_if_nan.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2016-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
@@ -353,35 +353,11 @@ 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 nlattr **tb,
+					struct wireless_dev *wdev)
 {
 	struct device *dev;
-	struct net_device *net_dev;
 	struct osif_vdev_sync *vdev_sync;
 	char *ifname;
 	int errno;
@@ -402,11 +378,7 @@ static int os_if_nan_process_ndi_create(struct wlan_objmgr_psoc *psoc,
 	if (errno)
 		goto destroy_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_register(wdev->netdev, vdev_sync);
 	osif_vdev_sync_trans_stop(vdev_sync);
 
 	return 0;
@@ -465,9 +437,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 nlattr **tb,
+					struct wireless_dev *wdev)
 {
-	struct net_device *net_dev;
 	struct osif_vdev_sync *vdev_sync;
 	char *ifname;
 	int errno;
@@ -476,15 +448,11 @@ static int os_if_nan_process_ndi_delete(struct wlan_objmgr_psoc *psoc,
 	if (errno)
 		return errno;
 
-	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);
+	errno = osif_vdev_sync_trans_start_wait(wdev->netdev, &vdev_sync);
 	if (errno)
 		return errno;
 
-	osif_vdev_sync_unregister(net_dev);
+	osif_vdev_sync_unregister(wdev->netdev);
 	osif_vdev_sync_wait_for_ops(vdev_sync);
 
 	errno = __os_if_nan_process_ndi_delete(psoc, ifname, tb);
@@ -497,7 +465,7 @@ static int os_if_nan_process_ndi_delete(struct wlan_objmgr_psoc *psoc,
 	return 0;
 
 reregister:
-	osif_vdev_sync_register(net_dev, vdev_sync);
+	osif_vdev_sync_register(wdev->netdev, vdev_sync);
 	osif_vdev_sync_trans_stop(vdev_sync);
 
 	return errno;
@@ -710,9 +678,9 @@ initiator_req_failed:
 }
 
 static int os_if_nan_process_ndp_initiator_req(struct wlan_objmgr_psoc *psoc,
-					       struct nlattr **tb)
+					       struct nlattr **tb,
+					       struct wireless_dev *wdev)
 {
-	struct net_device *net_dev;
 	struct osif_vdev_sync *vdev_sync;
 	char *ifname;
 	int errno;
@@ -721,11 +689,7 @@ static int os_if_nan_process_ndp_initiator_req(struct wlan_objmgr_psoc *psoc,
 	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);
+	errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync);
 	if (errno)
 		return errno;
 
@@ -756,7 +720,6 @@ 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;
@@ -764,6 +727,8 @@ 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");
@@ -772,6 +737,13 @@ 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) {
@@ -899,26 +871,17 @@ responder_req_failed:
 }
 
 static int os_if_nan_process_ndp_responder_req(struct wlan_objmgr_psoc *psoc,
-					       struct nlattr **tb)
+					       struct nlattr **tb,
+					       struct wireless_dev *wdev)
 {
-	struct net_device *net_dev;
 	struct osif_vdev_sync *vdev_sync;
-	char *ifname;
 	int errno;
 
-	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);
+	errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync);
 	if (errno)
 		return errno;
 
-	errno = __os_if_nan_process_ndp_responder_req(psoc, ifname, tb);
+	errno = __os_if_nan_process_ndp_responder_req(psoc, tb);
 
 	osif_vdev_sync_op_stop(vdev_sync);
 
@@ -1018,7 +981,8 @@ 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)
+			      bool is_ndp_allowed,
+			      struct wireless_dev *wdev)
 {
 	uint32_t ndp_cmd_type;
 	uint16_t transaction_id;
@@ -1066,21 +1030,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);
+		return os_if_nan_process_ndi_create(psoc, tb, wdev);
 	case QCA_WLAN_VENDOR_ATTR_NDP_INTERFACE_DELETE:
-		return os_if_nan_process_ndi_delete(psoc, tb);
+		return os_if_nan_process_ndi_delete(psoc, tb, wdev);
 	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);
+		return os_if_nan_process_ndp_initiator_req(psoc, tb, wdev);
 	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);
+		return os_if_nan_process_ndp_responder_req(psoc, tb, wdev);
 	case QCA_WLAN_VENDOR_ATTR_NDP_END_REQUEST:
 		if (!is_ndp_allowed) {
 			osif_err("Unsupported concurrency for NAN datapath");