Browse Source

qcacld-3.0: Refine the TX Queue callback API

The TX Queue callback currently specifies a void pointer for the
context. In the case of this API the context is actually known to be
an HDD handle, so update the API to explicitly use this type. This
will allow the compiler to verify that the correct type of parameter
is being passed.

Change-Id: I125b80eb250a5cfcb78f4a19d7a803838a4d147b
CRs-Fixed: 2277286
Jeff Johnson 6 years ago
parent
commit
da2afa4202

+ 2 - 2
core/hdd/inc/wlan_hdd_tx_rx.h

@@ -108,14 +108,14 @@ void hdd_tx_rx_collect_connectivity_stats_info(struct sk_buff *skb,
 
 /**
  * hdd_tx_queue_cb() - Disable/Enable the Transmit Queues
- * @context: HDD context
+ * @hdd_handle: HDD handle
  * @vdev_id: vdev id
  * @action: Action to be taken on the Tx Queues
  * @reason: Reason for the netif action
  *
  * Return: None
  */
-void hdd_tx_queue_cb(void *context, uint32_t vdev_id,
+void hdd_tx_queue_cb(hdd_handle_t hdd_handle, uint32_t vdev_id,
 		     enum netif_action_type action,
 		     enum netif_reason_type reason);
 

+ 5 - 5
core/hdd/src/wlan_hdd_tx_rx.c

@@ -2545,12 +2545,12 @@ void hdd_send_rps_disable_ind(struct hdd_adapter *adapter)
 	cds_cfg->rps_enabled = false;
 }
 
-void hdd_tx_queue_cb(void *context, uint32_t vdev_id,
+void hdd_tx_queue_cb(hdd_handle_t hdd_handle, uint32_t vdev_id,
 		     enum netif_action_type action,
 		     enum netif_reason_type reason)
 {
-	struct hdd_context *hdd_ctx = (struct hdd_context *)context;
-	struct hdd_adapter *adapter = NULL;
+	struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle);
+	struct hdd_adapter *adapter;
 
 	/*
 	 * Validating the context is not required here.
@@ -2559,13 +2559,13 @@ void hdd_tx_queue_cb(void *context, uint32_t vdev_id,
 	 * driver got a firmware event of sta kick out, then it is
 	 * good to disable the Tx Queue to stop the influx of traffic.
 	 */
-	if (hdd_ctx == NULL) {
+	if (!hdd_ctx) {
 		hdd_err("Invalid context passed");
 		return;
 	}
 
 	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (adapter == NULL) {
+	if (!adapter) {
 		hdd_err("vdev_id %d does not exist with host", vdev_id);
 		return;
 	}

+ 5 - 8
core/sme/inc/sme_api.h

@@ -1748,24 +1748,21 @@ QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
 
 /**
  * sme_register_tx_queue_cb(): Register tx queue callback
- * @hal: handler for HAL
+ * @mac_handle: Opaque handle for MAC context
  * @tx_queue_cb: Transmit Queues callback
  *
  * Return: QDF_STATUS
  */
-QDF_STATUS sme_register_tx_queue_cb(tHalHandle hal,
-				    void (*tx_queue_cb)(void *,
-				    uint32_t vdev_id,
-				    enum netif_action_type action,
-				    enum netif_reason_type reason));
+QDF_STATUS sme_register_tx_queue_cb(mac_handle_t mac_handle,
+				    tx_queue_cb tx_queue_cb);
 
 /**
  * sme_deregister_tx_queue_cb() - Deregister the tx queue callback
- * @hal: HAL handle
+ * @mac_handle: Opaque handle for MAC context
  *
  * Return: QDF status
  */
-QDF_STATUS sme_deregister_tx_queue_cb(tHalHandle hal);
+QDF_STATUS sme_deregister_tx_queue_cb(mac_handle_t mac_handle);
 
 /**
  * sme_rso_cmd_status_cb() - Set RSO cmd status callback

+ 5 - 3
core/sme/inc/sme_internal.h

@@ -186,6 +186,10 @@ struct chain_rssi_result;
 typedef void (*get_chain_rssi_callback)(void *context,
 					struct chain_rssi_result *data);
 
+typedef void (*tx_queue_cb)(hdd_handle_t hdd_handle, uint32_t vdev_id,
+			    enum netif_action_type action,
+			    enum netif_reason_type reason);
+
 /**
  * typedef pwr_save_fail_cb - power save fail callback function
  * @hdd_handle: HDD handle registered with SME
@@ -296,9 +300,7 @@ typedef struct tagSmeStruct {
 	void (*get_arp_stats_cb)(void *, struct rsp_stats *, void *);
 	get_chain_rssi_callback get_chain_rssi_cb;
 	void *get_chain_rssi_context;
-	void (*tx_queue_cb)(void *, uint32_t vdev_id,
-			    enum netif_action_type action,
-			    enum netif_reason_type reason);
+	tx_queue_cb tx_queue_cb;
 	twt_enable_cb twt_enable_cb;
 	twt_disable_cb twt_disable_cb;
 #ifdef FEATURE_WLAN_APF

+ 5 - 8
core/sme/src/common/sme_api.c

@@ -15375,14 +15375,11 @@ QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
 	return status;
 }
 
-QDF_STATUS sme_register_tx_queue_cb(tHalHandle hal,
-				    void (*tx_queue_cb)(void *,
-				    uint32_t vdev_id,
-				    enum netif_action_type action,
-				    enum netif_reason_type reason))
+QDF_STATUS sme_register_tx_queue_cb(mac_handle_t mac_handle,
+				    tx_queue_cb tx_queue_cb)
 {
 	QDF_STATUS status;
-	tpAniSirGlobal mac = PMAC_STRUCT(hal);
+	tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
 
 	status = sme_acquire_global_lock(&mac->sme);
 	if (QDF_IS_STATUS_SUCCESS(status)) {
@@ -15396,9 +15393,9 @@ QDF_STATUS sme_register_tx_queue_cb(tHalHandle hal,
 	return status;
 }
 
-QDF_STATUS sme_deregister_tx_queue_cb(tHalHandle hal)
+QDF_STATUS sme_deregister_tx_queue_cb(mac_handle_t mac_handle)
 {
-	return sme_register_tx_queue_cb(hal, NULL);
+	return sme_register_tx_queue_cb(mac_handle, NULL);
 }
 
 #ifdef WLAN_SUPPORT_TWT