Browse Source

qcacmn: Send AFC power event data to user application

Add an API to register a callback function that will be called when
the AFC power event is received from the AFC server. The second parameter
of the callback function is 'reg_fw_afc_power_event' structure which
holds the entire power event so that callback function can process the
part or whole of the power event.

Change-Id: I2d6247e54f92c02e9b4ec98bec678e662f1009f4
CRs-Fixed: 3114593
Hariharan Basuthkar 3 years ago
parent
commit
08f1f6b1af

+ 1 - 0
umac/regulatory/core/src/reg_build_chan_list.c

@@ -3976,6 +3976,7 @@ reg_process_afc_power_event(struct afc_regulatory_info *afc_info)
 	    reg_is_afc_mas_chan_list_valid(pdev_priv_obj->mas_chan_list_6g_afc))
 		tx_ops->trigger_acs_for_afc(pdev);
 
+	reg_send_afc_power_event(pdev, afc_info->power_info);
 	wlan_objmgr_pdev_release_ref(pdev, dbg_id);
 
 	return QDF_STATUS_SUCCESS;

+ 3 - 0
umac/regulatory/core/src/reg_priv_objs.h

@@ -211,6 +211,8 @@ struct wlan_regulatory_psoc_priv_obj {
  * @avoid_chan_ext_list: the extended avoid frequency list.
  * @afc_cb_lock: The spinlock to synchronize afc callbacks
  * @afc_cb_obj: The object containing the callback function and opaque argument
+ * @afc_pow_evt_cb_obj: The object containing the callback function and opaque
+ * argument for the AFC power event
  * @afc_request_id: The last AFC request id received from FW/halphy
  * @is_6g_afc_power_event_received: indicates if the AFC power event is
  * received
@@ -287,6 +289,7 @@ struct wlan_regulatory_pdev_priv_obj {
 #ifdef CONFIG_AFC_SUPPORT
 	qdf_spinlock_t afc_cb_lock;
 	struct afc_cb_handler afc_cb_obj;
+	struct afc_pow_evt_cb_handler afc_pow_evt_cb_obj;
 	uint64_t afc_request_id;
 	bool is_6g_afc_power_event_received;
 	bool is_6g_afc_expiry_event_received;

+ 70 - 0
umac/regulatory/core/src/reg_services_common.c

@@ -5786,6 +5786,31 @@ QDF_STATUS reg_afc_start(struct wlan_objmgr_pdev *pdev, uint64_t req_id)
 	return QDF_STATUS_SUCCESS;
 }
 
+QDF_STATUS reg_send_afc_power_event(struct wlan_objmgr_pdev *pdev,
+				    struct reg_fw_afc_power_event *power_info)
+{
+	afc_power_tx_evt_handler cbf;
+	void *arg;
+	struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
+
+	pdev_priv_obj = reg_get_pdev_obj(pdev);
+	if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) {
+		reg_err("pdev reg component is NULL");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	qdf_spin_lock_bh(&pdev_priv_obj->afc_cb_lock);
+	cbf = pdev_priv_obj->afc_pow_evt_cb_obj.func;
+	if (cbf) {
+		arg = pdev_priv_obj->afc_pow_evt_cb_obj.arg;
+		cbf(pdev, power_info, arg);
+	}
+
+	qdf_spin_unlock_bh(&pdev_priv_obj->afc_cb_lock);
+
+	return QDF_STATUS_SUCCESS;
+}
+
 QDF_STATUS reg_register_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev,
 					    afc_req_rx_evt_handler cbf,
 					    void *arg)
@@ -5830,6 +5855,51 @@ QDF_STATUS reg_unregister_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev,
 	return QDF_STATUS_SUCCESS;
 }
 
+QDF_STATUS
+reg_register_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
+				      afc_power_tx_evt_handler cbf,
+				      void *arg)
+{
+	struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
+
+	pdev_priv_obj = reg_get_pdev_obj(pdev);
+	if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) {
+		reg_err("pdev reg component is NULL");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	qdf_spin_lock_bh(&pdev_priv_obj->afc_cb_lock);
+	pdev_priv_obj->afc_pow_evt_cb_obj.func = cbf;
+	pdev_priv_obj->afc_pow_evt_cb_obj.arg = arg;
+	qdf_spin_unlock_bh(&pdev_priv_obj->afc_cb_lock);
+	reg_debug("afc_power_event_cb: 0x%pK, arg: 0x%pK", cbf, arg);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+reg_unregister_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
+					afc_power_tx_evt_handler cbf)
+{
+	struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
+
+	pdev_priv_obj = reg_get_pdev_obj(pdev);
+	if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) {
+		reg_err("pdev reg component is NULL");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	qdf_spin_lock_bh(&pdev_priv_obj->afc_cb_lock);
+	if (pdev_priv_obj->afc_pow_evt_cb_obj.func == cbf) {
+		pdev_priv_obj->afc_pow_evt_cb_obj.func = NULL;
+		pdev_priv_obj->afc_pow_evt_cb_obj.arg = NULL;
+	} else {
+		reg_err("cb function=0x%pK not found", cbf);
+	}
+	qdf_spin_unlock_bh(&pdev_priv_obj->afc_cb_lock);
+
+	return QDF_STATUS_SUCCESS;
+}
 #endif /* CONFIG_AFC_SUPPORT */
 
 QDF_STATUS

+ 46 - 0
umac/regulatory/core/src/reg_services_common.h

@@ -176,6 +176,17 @@ struct afc_cb_handler {
 	void *arg;
 };
 
+/**
+ * struct afc_pow_evt_cb_handler - defines structure for afc power received
+ * event  handler call back function and argument
+ * @func: handler function pointer
+ * @arg: argument to handler function
+ */
+struct afc_pow_evt_cb_handler {
+	afc_power_tx_evt_handler func;
+	void *arg;
+};
+
 /**
  * reg_init_freq_range() - Initialize a freq_range object
  * @left: The left frequency range
@@ -1313,6 +1324,41 @@ QDF_STATUS reg_register_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev,
  */
 QDF_STATUS reg_unregister_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev,
 					      afc_req_rx_evt_handler cbf);
+
+/**
+ * reg_register_afc_power_event_callback() - add AFC power event received
+ * @pdev: Pointer to pdev
+ * @cbf: Pointer to callback function
+ * @arg: Pointer to opaque argument
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+reg_register_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
+				      afc_power_tx_evt_handler cbf,
+				      void *arg);
+/**
+ * reg_unregister_afc_power_event_callback() - remove AFC power event received
+ * callback
+ * @pdev: Pointer to pdev
+ * @cbf: Pointer to callback function
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+reg_unregister_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
+					afc_power_tx_evt_handler cbf);
+
+/**
+ * reg_send_afc_power_event() - Send AFC power event to registered
+ * recipient
+ * @pdev: Pointer to pdev
+ * @power_info: Pointer to afc power info
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS reg_send_afc_power_event(struct wlan_objmgr_pdev *pdev,
+				    struct reg_fw_afc_power_event *power_info);
 #endif
 
 /**

+ 14 - 0
umac/regulatory/dispatcher/inc/reg_services_public_struct.h

@@ -2180,5 +2180,19 @@ struct reg_afc_resp_rx_ind_info {
 typedef void (*afc_req_rx_evt_handler)(struct wlan_objmgr_pdev *pdev,
 				       struct wlan_afc_host_partial_request *afc_par_req,
 				       void *arg);
+
+/**
+ * afc_power_tx_evt_handler() - Function prototype of AFC power event sent
+ * handler
+ * @pdev: Pointer to pdev
+ * @power_info: Pointer to AFC power event data
+ * @arg: Pointer to void (opaque) argument object
+ *
+ * Return: void
+ */
+typedef void
+(*afc_power_tx_evt_handler)(struct wlan_objmgr_pdev *pdev,
+			    struct reg_fw_afc_power_event *power_info,
+			    void *arg);
 #endif
 #endif

+ 25 - 0
umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h

@@ -350,6 +350,31 @@ QDF_STATUS ucfg_reg_get_partial_afc_req_info(
 		struct wlan_objmgr_pdev *pdev,
 		struct wlan_afc_host_partial_request **afc_req,
 		uint64_t req_id);
+
+/**
+ * ucfg_reg_register_afc_power_event_callback() - add AFC power event received
+ * @pdev: Pointer to pdev
+ * @cbf: Pointer to callback function
+ * @arg: Pointer to opaque argument
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+ucfg_reg_register_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
+					   afc_power_tx_evt_handler cbf,
+					   void *arg);
+
+/**
+ * ucfg_reg_unregister_afc_power_event_callback() - remove AFC power event
+ * received callback
+ * @pdev: Pointer to pdev
+ * @cbf: Pointer to callback function
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+ucfg_reg_unregister_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
+					     afc_power_tx_evt_handler cbf);
 #endif
 
 /**

+ 17 - 0
umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c

@@ -260,6 +260,23 @@ QDF_STATUS ucfg_reg_unregister_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev
 	return reg_unregister_afc_req_rx_callback(pdev, cbf);
 }
 
+QDF_STATUS
+ucfg_reg_register_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
+					   afc_power_tx_evt_handler cbf,
+					   void *arg)
+{
+	return reg_register_afc_power_event_callback(pdev, cbf, arg);
+}
+
+qdf_export_symbol(ucfg_reg_register_afc_power_event_callback);
+
+QDF_STATUS
+ucfg_reg_unregister_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
+					     afc_power_tx_evt_handler cbf)
+{
+	return reg_unregister_afc_power_event_callback(pdev, cbf);
+}
+
 QDF_STATUS ucfg_reg_get_partial_afc_req_info(
 		struct wlan_objmgr_pdev *pdev,
 		struct wlan_afc_host_partial_request **afc_req,