Sfoglia il codice sorgente

qcacld-3.0: Add support for packet capture callbacks

Add support to register/deregister packet capture callbacks.

Change-Id: I37c713d6929879aea7e39f6fd87ba2aecd86d802
CRs-Fixed: 2619312
Vulupala Shashank Reddy 5 anni fa
parent
commit
a69961d7dd

+ 40 - 0
components/pkt_capture/core/inc/wlan_pkt_capture_main.h

@@ -106,4 +106,44 @@ pkt_capture_psoc_create_notification(struct wlan_objmgr_psoc *psoc, void *arg);
  */
 QDF_STATUS
 pkt_capture_psoc_destroy_notification(struct wlan_objmgr_psoc *psoc, void *arg);
+
+/**
+ * pkt_capture_register_callbacks - Register packet capture callbacks
+ * @vdev: pointer to wlan vdev object manager
+ * @mon_cb: callback to call
+ * @context: callback context
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+pkt_capture_register_callbacks(struct wlan_objmgr_vdev *vdev,
+			       QDF_STATUS (*mon_cb)(void *, qdf_nbuf_t),
+			       void *context);
+
+/**
+ * pkt_capture_deregister_callbacks - De-register packet capture callbacks
+ * @vdev: pointer to wlan vdev object manager
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS pkt_capture_deregister_callbacks(struct wlan_objmgr_vdev *vdev);
+
+/**
+ * pkt_capture_set_pktcap_mode - Set packet capture mode
+ * @psoc: pointer to psoc object
+ * @mode: mode to be set
+ *
+ * Return: None
+ */
+void pkt_capture_set_pktcap_mode(struct wlan_objmgr_psoc *psoc,
+				 enum pkt_capture_mode mode);
+
+/**
+ * pkt_capture_get_pktcap_mode - Get packet capture mode
+ * @psoc: pointer to psoc object
+ *
+ * Return: enum pkt_capture_mode
+ */
+enum pkt_capture_mode
+pkt_capture_get_pktcap_mode(struct wlan_objmgr_psoc *psoc);
 #endif /* end of _WLAN_PKT_CAPTURE_MAIN_H_ */

+ 14 - 0
components/pkt_capture/core/inc/wlan_pkt_capture_priv.h

@@ -39,14 +39,28 @@ struct pkt_capture_cfg {
 	enum pkt_capture_mode pkt_capture_mode;
 };
 
+/**
+ * struct pkt_capture_cb_context - packet capture callback context
+ * @mon_cb: monitor callback function pointer
+ * @mon_ctx: monitor callback context
+ * @pkt_capture_mode: packet capture mode
+ */
+struct pkt_capture_cb_context {
+	QDF_STATUS (*mon_cb)(void *, qdf_nbuf_t);
+	void *mon_ctx;
+	enum pkt_capture_mode pkt_capture_mode;
+};
+
 /**
  * struct pkt_capture_vdev_priv - Private object to be stored in vdev
  * @vdev: pointer to vdev object
  * @pkt_capture_mon_ctx: pointer to packet capture mon context
+ * @cb_ctx: pointer to packet capture mon callback context
  */
 struct pkt_capture_vdev_priv {
 	struct wlan_objmgr_vdev *vdev;
 	struct pkt_capture_mon_context *mon_ctx;
+	struct pkt_capture_cb_context *cb_ctx;
 };
 
 /**

+ 148 - 1
components/pkt_capture/core/src/wlan_pkt_capture_main.c

@@ -43,6 +43,143 @@ enum pkt_capture_mode pkt_capture_get_mode(struct wlan_objmgr_psoc *psoc)
 	return psoc_priv->cfg_param.pkt_capture_mode;
 }
 
+QDF_STATUS
+pkt_capture_register_callbacks(struct wlan_objmgr_vdev *vdev,
+			       QDF_STATUS (*mon_cb)(void *, qdf_nbuf_t),
+			       void *context)
+{
+	struct pkt_capture_vdev_priv *vdev_priv;
+
+	if (!vdev) {
+		pkt_capture_err("vdev is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	vdev_priv = pkt_capture_vdev_get_priv(vdev);
+	if (!vdev_priv) {
+		pkt_capture_err("vdev priv is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	vdev_priv->cb_ctx->mon_cb = mon_cb;
+	vdev_priv->cb_ctx->mon_ctx = context;
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS pkt_capture_deregister_callbacks(struct wlan_objmgr_vdev *vdev)
+{
+	struct pkt_capture_vdev_priv *vdev_priv;
+
+	if (!vdev) {
+		pkt_capture_err("vdev is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	vdev_priv = pkt_capture_vdev_get_priv(vdev);
+	if (!vdev_priv) {
+		pkt_capture_err("vdev priv is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	vdev_priv->cb_ctx->mon_cb = NULL;
+	vdev_priv->cb_ctx->mon_ctx = NULL;
+
+	return QDF_STATUS_SUCCESS;
+}
+
+void pkt_capture_set_pktcap_mode(struct wlan_objmgr_psoc *psoc,
+				 enum pkt_capture_mode mode)
+{
+	struct pkt_capture_vdev_priv *vdev_priv;
+	struct wlan_objmgr_vdev *vdev;
+
+	if (!psoc) {
+		pkt_capture_err("psoc is NULL");
+		return;
+	}
+
+	vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(psoc,
+							QDF_STA_MODE,
+							WLAN_PKT_CAPTURE_ID);
+	if (!vdev) {
+		pkt_capture_err("vdev is NULL");
+		return;
+	}
+
+	vdev_priv = pkt_capture_vdev_get_priv(vdev);
+	if (vdev_priv)
+		vdev_priv->cb_ctx->pkt_capture_mode = mode;
+	else
+		pkt_capture_err("vdev_priv is NULL");
+
+	wlan_objmgr_vdev_release_ref(vdev, WLAN_PKT_CAPTURE_ID);
+}
+
+enum pkt_capture_mode
+pkt_capture_get_pktcap_mode(struct wlan_objmgr_psoc *psoc)
+{
+	enum pkt_capture_mode mode = PACKET_CAPTURE_MODE_DISABLE;
+	struct pkt_capture_vdev_priv *vdev_priv;
+	struct wlan_objmgr_vdev *vdev;
+
+	if (!psoc) {
+		pkt_capture_err("psoc is NULL");
+		return 0;
+	}
+
+	vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(psoc,
+							QDF_STA_MODE,
+							WLAN_PKT_CAPTURE_ID);
+	if (!vdev) {
+		pkt_capture_err("vdev is NULL");
+		return 0;
+	}
+
+	vdev_priv = pkt_capture_vdev_get_priv(vdev);
+	if (!vdev_priv)
+		pkt_capture_err("vdev_priv is NULL");
+	else
+		mode = vdev_priv->cb_ctx->pkt_capture_mode;
+
+	wlan_objmgr_vdev_release_ref(vdev, WLAN_PKT_CAPTURE_ID);
+	return mode;
+}
+
+/**
+ * pkt_capture_callback_ctx_create() - Create packet capture callback context
+ * @vdev_priv: pointer to packet capture vdev priv obj
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS
+pkt_capture_callback_ctx_create(struct pkt_capture_vdev_priv *vdev_priv)
+{
+	struct pkt_capture_cb_context *cb_ctx;
+
+	cb_ctx = qdf_mem_malloc(sizeof(*cb_ctx));
+	if (!cb_ctx) {
+		pkt_capture_err("MON context create failed");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	vdev_priv->cb_ctx = cb_ctx;
+
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * pkt_capture_callback_ctx_destroy() - Destroy packet capture callback context
+ * @vdev_priv: pointer to packet capture vdev priv obj
+ *
+ * Return: None
+ */
+static void
+pkt_capture_callback_ctx_destroy(struct pkt_capture_vdev_priv *vdev_priv)
+{
+	qdf_mem_free(vdev_priv->cb_ctx);
+}
+
 /**
  * pkt_capture_mon_context_create() - Create packet capture mon context
  * @vdev_priv: pointer to packet capture vdev priv obj
@@ -120,11 +257,18 @@ pkt_capture_vdev_create_notification(struct wlan_objmgr_vdev *vdev, void *arg)
 
 	vdev_priv->vdev = vdev;
 
+	status = pkt_capture_callback_ctx_create(vdev_priv);
+	if (!QDF_IS_STATUS_SUCCESS(status)) {
+		pkt_capture_err("Failed to create callback context");
+		goto detach_vdev_priv;
+	}
+
 	status = pkt_capture_mon_context_create(vdev_priv);
 	if (QDF_IS_STATUS_ERROR(status)) {
 		pkt_capture_err("Failed to create mon context");
-		goto detach_vdev_priv;
+		goto destroy_pkt_capture_cb_context;
 	}
+
 	mon_ctx = vdev_priv->mon_ctx;
 
 	status = pkt_capture_alloc_mon_thread(mon_ctx);
@@ -144,6 +288,8 @@ open_mon_thread_fail:
 	pkt_capture_free_mon_pkt_freeq(mon_ctx);
 destroy_mon_context:
 	pkt_capture_mon_context_destroy(vdev_priv);
+destroy_pkt_capture_cb_context:
+	pkt_capture_callback_ctx_destroy(vdev_priv);
 detach_vdev_priv:
 	wlan_objmgr_vdev_component_obj_detach(vdev,
 					      WLAN_UMAC_COMP_PKT_CAPTURE,
@@ -174,6 +320,7 @@ pkt_capture_vdev_destroy_notification(struct wlan_objmgr_vdev *vdev, void *arg)
 
 	pkt_capture_close_mon_thread(vdev_priv->mon_ctx);
 	pkt_capture_mon_context_destroy(vdev_priv);
+	pkt_capture_callback_ctx_destroy(vdev_priv);
 	qdf_mem_free(vdev_priv);
 	return status;
 }

+ 67 - 0
components/pkt_capture/dispatcher/inc/wlan_pkt_capture_ucfg_api.h

@@ -74,6 +74,47 @@ int ucfg_pkt_capture_suspend_mon_thread(struct wlan_objmgr_vdev *vdev);
  * Return: None
  */
 void ucfg_pkt_capture_resume_mon_thread(struct wlan_objmgr_vdev *vdev);
+
+/**
+ * ucfg_pkt_capture_register_callbacks - Register packet capture callbacks
+ * @vdev: pointer to wlan vdev object manager
+ * mon_cb: callback to call
+ * context: callback context
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+ucfg_pkt_capture_register_callbacks(struct wlan_objmgr_vdev *vdev,
+				    QDF_STATUS (*mon_cb)(void *, qdf_nbuf_t),
+				    void *context);
+
+/**
+ * ucfg_pkt_capture_deregister_callbacks - De-register packet capture callbacks
+ * @vdev: pointer to wlan vdev object manager
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+ucfg_pkt_capture_deregister_callbacks(struct wlan_objmgr_vdev *vdev);
+
+/**
+ * ucfg_pkt_capturee_set_pktcap_mode - Set packet capture mode
+ * @psoc: pointer to psoc object
+ * @mode: mode to be set
+ *
+ * Return: None
+ */
+void ucfg_pkt_capture_set_pktcap_mode(struct wlan_objmgr_psoc *psoc,
+				      enum pkt_capture_mode val);
+
+/**
+ * ucfg_pkt_capture_get_pktcap_mode - Get packet capture mode
+ * @psoc: pointer to psoc object
+ *
+ * Return: enum pkt_capture_mode
+ */
+enum pkt_capture_mode
+ucfg_pkt_capture_get_pktcap_mode(struct wlan_objmgr_psoc *psoc);
 #else
 static inline
 QDF_STATUS ucfg_pkt_capture_init(void)
@@ -102,5 +143,31 @@ int ucfg_pkt_capture_suspend_mon_thread(struct wlan_objmgr_vdev *vdev)
 {
 	return 0;
 }
+
+static inline QDF_STATUS
+ucfg_pkt_capture_register_callbacks(struct wlan_objmgr_vdev *vdev,
+				    QDF_STATUS (*mon_cb)(void *, qdf_nbuf_t),
+				    void *context)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline
+QDF_STATUS ucfg_pkt_capture_deregister_callbacks(struct wlan_objmgr_vdev *vdev)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline
+void ucfg_pkt_capture_set_pktcap_mode(struct wlan_objmgr_psoc *psoc,
+				      uint8_t val)
+{
+}
+
+static inline enum pkt_capture_mode
+ucfg_pkt_capture_get_pktcap_mode(struct wlan_objmgr_psoc *psoc)
+{
+	return PACKET_CAPTURE_MODE_DISABLE;
+}
 #endif /* WLAN_FEATURE_PKT_CAPTURE */
 #endif /* _WLAN_PKT_CAPTURE_UCFG_API_H_ */

+ 59 - 0
components/pkt_capture/dispatcher/src/wlan_pkt_capture_ucfg_api.c

@@ -30,6 +30,65 @@ enum pkt_capture_mode ucfg_pkt_capture_get_mode(struct wlan_objmgr_psoc *psoc)
 	return pkt_capture_get_mode(psoc);
 }
 
+/**
+ * ucfg_pkt_capture_register_callbacks - Register packet capture callbacks
+ * @vdev: pointer to wlan vdev object manager
+ * mon_cb: callback to call
+ * context: callback context
+ *
+ * Return: 0 in case of success, invalid in case of failure.
+ */
+QDF_STATUS
+ucfg_pkt_capture_register_callbacks(struct wlan_objmgr_vdev *vdev,
+				    QDF_STATUS (*mon_cb)(void *, qdf_nbuf_t),
+				    void *context)
+{
+	return pkt_capture_register_callbacks(vdev, mon_cb, context);
+}
+
+/**
+ * ucfg_pkt_capture_deregister_callbacks - De-register packet capture callbacks
+ * @vdev: pointer to wlan vdev object manager
+ *
+ * Return: 0 in case of success, invalid in case of failure.
+ */
+QDF_STATUS ucfg_pkt_capture_deregister_callbacks(struct wlan_objmgr_vdev *vdev)
+{
+	return pkt_capture_deregister_callbacks(vdev);
+}
+
+/**
+ * ucfg_pkt_capture_set_pktcap_mode - Set packet capture mode
+ * @psoc: pointer to psoc object
+ * @mode: mode to be set
+ *
+ * Return: None
+ */
+void ucfg_pkt_capture_set_pktcap_mode(struct wlan_objmgr_psoc *psoc,
+				      enum pkt_capture_mode mode)
+{
+	pkt_capture_set_pktcap_mode(psoc, mode);
+}
+
+/**
+ * ucfg_pkt_capture_get_pktcap_mode - Get packet capture mode
+ * @psoc: pointer to psoc object
+ *
+ * Return: enum pkt_capture_mode
+ */
+enum pkt_capture_mode
+ucfg_pkt_capture_get_pktcap_mode(struct wlan_objmgr_psoc *psoc)
+{
+	return pkt_capture_get_pktcap_mode(psoc);
+}
+
+/**
+ * ucfg_pkt_capture_init() - Packet capture component initialization.
+ *
+ * This function gets called when packet capture initializing.
+ *
+ * Return: QDF_STATUS_SUCCESS - in case of success.
+ */
 QDF_STATUS ucfg_pkt_capture_init(void)
 {
 	QDF_STATUS status;