Browse Source

qcacld-3.0: Add support to query local packet capture status

Add support to query local packet capture status.

Change-Id: I8582b8af89b0582cc94ba04ea3e875916617505b
CRs-Fixed: 3415881
Srinivas Girigowda 2 years ago
parent
commit
1a6bd34a09

+ 83 - 0
core/hdd/src/wlan_hdd_cfg80211.c

@@ -17906,6 +17906,7 @@ QDF_STATUS os_if_monitor_mode_configure(struct hdd_adapter *adapter,
 	hdd_objmgr_put_vdev_by_user(vdev, WLAN_DP_ID);
 	return status;
 }
+
 #endif /* WLAN_FEATURE_LOCAL_PKT_CAPTURE */
 
 #if defined(WLAN_FEATURE_PKT_CAPTURE) || defined(WLAN_FEATURE_LOCAL_PKT_CAPTURE)
@@ -17987,7 +17988,89 @@ static int wlan_hdd_cfg80211_set_monitor_mode(struct wiphy *wiphy,
 
 	return errno;
 }
+#endif
+
+#ifdef WLAN_FEATURE_LOCAL_PKT_CAPTURE
+
+/**
+ * __wlan_hdd_cfg80211_get_monitor_mode() - Get wifi monitor mode configuration
+ * vendor command
+ * @wiphy: wiphy device pointer
+ * @wdev: wireless device pointer
+ * @data: Vendor command data buffer
+ * @data_len: Buffer length
+ *
+ * Return: 0 for Success and negative value for failure
+ */
+static int
+__wlan_hdd_cfg80211_get_monitor_mode(struct wiphy *wiphy,
+				     struct wireless_dev *wdev,
+				     const void *data, int data_len)
+{
+	struct net_device *dev = wdev->netdev;
+	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
+	struct hdd_context *hdd_ctx  = wiphy_priv(wiphy);
+	struct wlan_objmgr_vdev *vdev;
+	int errno;
+	QDF_STATUS status;
+
+	if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) {
+		hdd_err("Command not allowed in FTM mode");
+		return -EPERM;
+	}
+
+	errno = wlan_hdd_validate_context(hdd_ctx);
+	if (errno)
+		return errno;
+
+	errno = hdd_validate_adapter(adapter);
+	if (errno)
+		return errno;
+
+	if (!ucfg_dp_is_local_pkt_capture_enabled(hdd_ctx->psoc))
+		return -EPERM;
+
+	vdev = hdd_objmgr_get_vdev_by_user(adapter, WLAN_DP_ID);
+	if (!vdev)
+		return -EINVAL;
+
+	status = os_if_dp_get_lpc_state(vdev, data, data_len);
+	hdd_objmgr_put_vdev_by_user(vdev, WLAN_DP_ID);
+
+	return qdf_status_to_os_return(status);
+}
+
+/**
+ * wlan_hdd_cfg80211_get_monitor_mode() - get monitor mode
+ * @wiphy: wiphy pointer
+ * @wdev: pointer to struct wireless_dev
+ * @data: pointer to incoming NL vendor data
+ * @data_len: length of @data
+ *
+ * Return: 0 on success; error number otherwise.
+ */
+static int wlan_hdd_cfg80211_get_monitor_mode(struct wiphy *wiphy,
+					      struct wireless_dev *wdev,
+					      const void *data, int data_len)
+{
+	int errno;
+	struct osif_vdev_sync *vdev_sync;
 
+	hdd_enter_dev(wdev->netdev);
+
+	errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync);
+	if (errno)
+		return errno;
+
+	errno = __wlan_hdd_cfg80211_get_monitor_mode(wiphy, wdev,
+						     data, data_len);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	hdd_exit();
+
+	return errno;
+}
 #endif
 
 /**

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

@@ -552,7 +552,7 @@ wlan_hdd_lpc_del_monitor_interface(struct hdd_context *hdd_ctx)
 	if (!soc)
 		return;
 
-	running = cdp_local_pkt_capture_running(soc, OL_TXRX_PDEV_ID);
+	running = cdp_is_local_pkt_capture_running(soc, OL_TXRX_PDEV_ID);
 	if (!running)
 		return;
 

+ 29 - 0
os_if/dp/inc/os_if_dp_local_pkt_capture.h

@@ -32,6 +32,15 @@
 		.doit = wlan_hdd_cfg80211_set_monitor_mode,		   \
 		vendor_command_policy(set_monitor_mode_policy,		   \
 				QCA_WLAN_VENDOR_ATTR_SET_MONITOR_MODE_MAX) \
+	},								   \
+	{								   \
+		.info.vendor_id = QCA_NL80211_VENDOR_ID,		   \
+		.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_MONITOR_MODE, \
+		.flags = WIPHY_VENDOR_CMD_NEED_WDEV |			   \
+			WIPHY_VENDOR_CMD_NEED_NETDEV |			   \
+			WIPHY_VENDOR_CMD_NEED_RUNNING,			   \
+		.doit = wlan_hdd_cfg80211_get_monitor_mode,		   \
+		vendor_command_policy(VENDOR_CMD_RAW_DATA, 0)		   \
 	},
 
 extern const struct nla_policy
@@ -58,6 +67,19 @@ QDF_STATUS os_if_dp_set_lpc_configure(struct wlan_objmgr_vdev *vdev,
  */
 QDF_STATUS os_if_dp_local_pkt_capture_stop(struct wlan_objmgr_vdev *vdev);
 
+/**
+ * os_if_dp_get_lpc_state() - get local packet capture state
+ * in the received vendor command
+ * @vdev: vdev
+ * @data: NL data
+ * @data_len: NL data length
+ *
+ * Return: QDF_STATUS_SUCCESS if Success;
+ *         QDF_STATUS_E_* if Failure
+ */
+QDF_STATUS os_if_dp_get_lpc_state(struct wlan_objmgr_vdev *vdev,
+				  const void *data, int data_len);
+
 #else
 static inline
 QDF_STATUS os_if_dp_set_lpc_configure(struct wlan_objmgr_vdev *vdev,
@@ -72,5 +94,12 @@ QDF_STATUS os_if_dp_local_pkt_capture_stop(struct wlan_objmgr_vdev *vdev)
 	return QDF_STATUS_SUCCESS;
 }
 
+static inline
+QDF_STATUS os_if_dp_get_lpc_state(struct wlan_objmgr_vdev *vdev,
+				  const void *data, int data_len)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
 #endif /* WLAN_FEATURE_LOCAL_PKT_CAPTURE */
 #endif

+ 70 - 1
os_if/dp/src/os_if_dp_local_pkt_capture.c

@@ -46,6 +46,14 @@
 #define SET_MONITOR_MODE_CTRL_RX_FRAME_TYPE \
 	QCA_WLAN_VENDOR_ATTR_SET_MONITOR_MODE_CTRL_RX_FRAME_TYPE
 
+/* Short name for QCA_NL80211_VENDOR_SUBCMD_GET_MONITOR_MODE command */
+#define GET_MONITOR_MODE_CONFIG_MAX \
+	QCA_WLAN_VENDOR_ATTR_GET_MONITOR_MODE_MAX
+#define GET_MONITOR_MODE_INVALID \
+	QCA_WLAN_VENDOR_ATTR_GET_MONITOR_MODE_INVALID
+#define GET_MONITOR_MODE_STATUS \
+	QCA_WLAN_VENDOR_ATTR_GET_MONITOR_MODE_STATUS
+
 #define MGMT_FRAME_TYPE    0
 #define DATA_FRAME_TYPE    1
 #define CTRL_FRAME_TYPE    2
@@ -155,7 +163,7 @@ static QDF_STATUS os_if_stop_capture_allowed(struct wlan_objmgr_vdev *vdev)
 		return QDF_STATUS_E_NOSUPPORT;
 	}
 
-	if (!cdp_local_pkt_capture_running(soc, OL_TXRX_PDEV_ID)) {
+	if (!cdp_is_local_pkt_capture_running(soc, OL_TXRX_PDEV_ID)) {
 		osif_debug("local pkt capture not running, no need to stop");
 		return QDF_STATUS_E_PERM;
 	}
@@ -311,3 +319,64 @@ QDF_STATUS os_if_dp_local_pkt_capture_stop(struct wlan_objmgr_vdev *vdev)
 	return cdp_stop_local_pkt_capture(soc, OL_TXRX_PDEV_ID);
 }
 
+QDF_STATUS os_if_dp_get_lpc_state(struct wlan_objmgr_vdev *vdev,
+				  const void *data, int data_len)
+{
+	struct wlan_objmgr_psoc *psoc;
+	struct vdev_osif_priv *osif_priv;
+	struct sk_buff *reply_skb;
+	uint32_t skb_len = NLMSG_HDRLEN, val;
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	struct wireless_dev *wdev;
+	bool running;
+	void *soc;
+
+	psoc = wlan_vdev_get_psoc(vdev);
+	if (!psoc)
+		return QDF_STATUS_E_INVAL;
+
+	osif_priv = wlan_vdev_get_ospriv(vdev);
+	if (!osif_priv) {
+		osif_err("osif_priv is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	wdev = osif_priv->wdev;
+	if (!wdev) {
+		osif_err("wireless dev is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	soc = cds_get_context(QDF_MODULE_ID_SOC);
+	if (!soc)
+		return QDF_STATUS_E_INVAL;
+
+	/* Length of attribute QCA_WLAN_VENDOR_ATTR_SET_MONITOR_MODE_STATUS */
+	skb_len += nla_total_size(sizeof(u32));
+
+	reply_skb = wlan_cfg80211_vendor_cmd_alloc_reply_skb(wdev->wiphy,
+							     skb_len);
+	if (!reply_skb) {
+		osif_err("alloc reply skb failed");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	running = cdp_is_local_pkt_capture_running(soc, OL_TXRX_PDEV_ID);
+	val = running ? QCA_WLAN_VENDOR_MONITOR_MODE_CAPTURE_RUNNING :
+			QCA_WLAN_VENDOR_MONITOR_MODE_NO_CAPTURE_RUNNING;
+
+	if (nla_put_u32(reply_skb, GET_MONITOR_MODE_STATUS, val)) {
+		osif_err("nla put failed");
+		status = QDF_STATUS_E_INVAL;
+		goto fail;
+	}
+
+	if (wlan_cfg80211_vendor_cmd_reply(reply_skb))
+		status = QDF_STATUS_E_INVAL;
+
+	return status;
+fail:
+	wlan_cfg80211_vendor_free_skb(reply_skb);
+	return status;
+}
+