mirror of
https://github.com/optim-enterprises-bv/openwrt-ipq.git
synced 2025-10-29 17:33:01 +00:00
ath11k_nss: Improve NSS event callback handling
Improve NSS event callback ihandling for better clarity and type safety This patch modifies ath11k_nss_wifili_event_receive to take a context parameter , enhancing code clarity by explicitly passing the ath11k_base. A wrapper function, ath11k_nss_wifili_ext_callback_wrapper, retrieves the ath11k_base from the net_device's private data, ensuring correct context handling. Signed-off-by: Sean Khan <datapronix@protonmail.com>
This commit is contained in:
@@ -0,0 +1,270 @@
|
||||
--- a/drivers/net/wireless/ath/ath11k/nss.c
|
||||
+++ b/drivers/net/wireless/ath/ath11k/nss.c
|
||||
@@ -313,13 +313,14 @@ static void ath11k_nss_peer_mem_free(str
|
||||
|
||||
/*-----------------------------Events/Callbacks------------------------------*/
|
||||
|
||||
-void ath11k_nss_wifili_event_receive(struct ath11k_base *ab, struct nss_wifili_msg *msg)
|
||||
+void ath11k_nss_wifili_event_receive(void *context, struct nss_wifili_msg *msg)
|
||||
{
|
||||
u32 msg_type = msg->cm.type;
|
||||
enum nss_cmn_response response = msg->cm.response;
|
||||
u32 error = msg->cm.error;
|
||||
u32 peer_id;
|
||||
struct nss_wifili_peer_stats *peer_stats;
|
||||
+ struct ath11k_base *ab = (struct ath11k_base *)context;
|
||||
|
||||
if (!ab)
|
||||
return;
|
||||
@@ -519,6 +520,17 @@ ath11k_nss_wifili_ext_callback_fn(struct
|
||||
}
|
||||
}
|
||||
|
||||
+static inline void ath11k_nss_wifili_ext_callback_wrapper(struct net_device *netdev,
|
||||
+ struct sk_buff *skb,
|
||||
+ struct napi_struct *napi)
|
||||
+{
|
||||
+ // Retrieve the ath11k_base from the net_device's private data
|
||||
+ struct ath11k_base *ab = (struct ath11k_base *)netdev_priv(netdev);
|
||||
+
|
||||
+ // Call the original function with the retrieved ath11k_base
|
||||
+ ath11k_nss_wifili_ext_callback_fn(ab, skb, napi);
|
||||
+}
|
||||
+
|
||||
void ath11k_nss_vdev_cfg_cb(void *app_data, struct nss_cmn_msg *msg)
|
||||
{
|
||||
struct ath11k_vif *arvif = (struct ath11k_vif *)app_data;
|
||||
@@ -1431,7 +1443,7 @@ int ath11k_nss_mesh_exception_flags(stru
|
||||
nss_tx_status_t status;
|
||||
int ret = 0;
|
||||
|
||||
- msg_cb = (nss_wifi_mesh_msg_callback_t)ath11k_nss_mesh_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_mesh_wifili_event_receive;
|
||||
|
||||
status = (nss_tx_status_t)nss_wifi_meshmgr_mesh_path_exception(arvif->nss.mesh_handle, nss_msg,
|
||||
msg_cb, arvif->ar->ab);
|
||||
@@ -1532,7 +1544,7 @@ static int ath11k_nss_mesh_mpath_add(str
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
- msg_cb = (nss_wifi_mesh_msg_callback_t)ath11k_nss_mesh_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_mesh_wifili_event_receive;
|
||||
|
||||
ether_addr_copy(msg->dest_mac_addr, path->mesh_da);
|
||||
ether_addr_copy(msg->next_hop_mac_addr, path->next_hop);
|
||||
@@ -1578,7 +1590,7 @@ static int ath11k_nss_mesh_mpath_update(
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
- msg_cb = (nss_wifi_mesh_msg_callback_t)ath11k_nss_mesh_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_mesh_wifili_event_receive;
|
||||
|
||||
ether_addr_copy(msg->dest_mac_addr, path->mesh_da);
|
||||
ether_addr_copy(msg->next_hop_mac_addr, path->next_hop);
|
||||
@@ -1634,7 +1646,7 @@ static int ath11k_nss_mesh_mpath_del(str
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
- msg_cb = (nss_wifi_mesh_msg_callback_t)ath11k_nss_mesh_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_mesh_wifili_event_receive;
|
||||
|
||||
ether_addr_copy(msg->mesh_dest_mac_addr, path->mesh_da);
|
||||
ether_addr_copy(msg->next_hop_mac_addr, path->next_hop);
|
||||
@@ -1670,7 +1682,7 @@ static int ath11k_nss_mesh_mpp_add_cmd(s
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
- msg_cb = (nss_wifi_mesh_msg_callback_t)ath11k_nss_mesh_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_mesh_wifili_event_receive;
|
||||
|
||||
ether_addr_copy(msg->dest_mac_addr, path->da);
|
||||
ether_addr_copy(msg->mesh_dest_mac, path->mesh_da);
|
||||
@@ -1706,7 +1718,7 @@ static int ath11k_nss_mesh_mpp_update_cm
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
- msg_cb = (nss_wifi_mesh_msg_callback_t)ath11k_nss_mesh_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_mesh_wifili_event_receive;
|
||||
|
||||
ether_addr_copy(msg->dest_mac_addr, path->da);
|
||||
ether_addr_copy(msg->mesh_dest_mac, path->mesh_da);
|
||||
@@ -1744,7 +1756,7 @@ static int ath11k_nss_mesh_mpp_del_cmd(s
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
- msg_cb = (nss_wifi_mesh_msg_callback_t)ath11k_nss_mesh_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_mesh_wifili_event_receive;
|
||||
|
||||
ether_addr_copy(msg->dest_mac_addr, path->da);
|
||||
ether_addr_copy(msg->mesh_dest_mac_addr, path->mesh_da);
|
||||
@@ -1933,7 +1945,7 @@ void ath11k_nss_mpp_timer_cb(struct time
|
||||
LIST_HEAD(local_entry);
|
||||
nss_tx_status_t status;
|
||||
|
||||
- msg_cb = (nss_wifi_mesh_msg_callback_t)ath11k_nss_mesh_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_mesh_wifili_event_receive;
|
||||
|
||||
if (!arvif->nss.mpp_dump_req)
|
||||
arvif->nss.mpp_dump_num_entries = 0;
|
||||
@@ -3067,7 +3079,7 @@ int ath11k_nss_ext_vdev_wds_4addr_allow(
|
||||
cfg_4addr_msg->if_num = arvif->nss.if_num;
|
||||
cfg_4addr_msg->enable = true;
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ar->ab->nss.if_num,
|
||||
NSS_WIFILI_PEER_4ADDR_EVENT_MSG,
|
||||
@@ -3472,7 +3484,7 @@ int ath11k_nss_set_peer_sec_type(struct
|
||||
memcpy(&sec_msg->mic_key[0], mic_key, NSS_WIFILI_MIC_KEY_LEN);
|
||||
}
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ar->ab->nss.if_num,
|
||||
NSS_WIFILI_PEER_SECURITY_TYPE_MSG,
|
||||
@@ -3511,7 +3523,7 @@ int ath11k_nss_set_peer_authorize(struct
|
||||
auth_msg->peer_id = peer_id;
|
||||
auth_msg->auth_flag = 1;
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ar->ab->nss.if_num,
|
||||
NSS_WIFILI_PEER_UPDATE_AUTH_FLAG,
|
||||
@@ -3743,7 +3755,7 @@ int ath11k_nss_peer_delete(struct ath11k
|
||||
peer_msg->vdev_id = peer->vdev_id;
|
||||
peer_msg->peer_id = peer->peer_id;
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ar->ab->nss.if_num,
|
||||
NSS_WIFILI_PEER_DELETE_MSG,
|
||||
@@ -3841,7 +3853,7 @@ int ath11k_nss_peer_create(struct ath11k
|
||||
peer_msg->nss_peer_mem = peer->nss.paddr;
|
||||
peer_msg->psta_vdev_id = peer->vdev_id;
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
NSS_WIFILI_PEER_CREATE_MSG,
|
||||
@@ -3909,7 +3921,7 @@ int ath11k_nss_add_wds_peer(struct ath11
|
||||
ether_addr_copy(wds_peer_msg->peer_mac, peer->addr);
|
||||
ether_addr_copy(wds_peer_msg->dest_mac, dest_mac);
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
NSS_WIFILI_WDS_PEER_ADD_MSG,
|
||||
@@ -3955,7 +3967,7 @@ int ath11k_nss_update_wds_peer(struct at
|
||||
ether_addr_copy(wds_peer_msg->peer_mac, peer->addr);
|
||||
ether_addr_copy(wds_peer_msg->dest_mac, dest_mac);
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
NSS_WIFILI_WDS_PEER_UPDATE_MSG,
|
||||
@@ -4006,7 +4018,7 @@ int ath11k_nss_map_wds_peer(struct ath11
|
||||
|
||||
ether_addr_copy(wds_peer_map_msg->dest_mac, dest_mac);
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
NSS_WIFILI_WDS_PEER_MAP_MSG,
|
||||
@@ -4052,7 +4064,7 @@ int ath11k_nss_del_wds_peer(struct ath11
|
||||
ether_addr_copy(wds_peer_msg->peer_mac, peer_addr);
|
||||
ether_addr_copy(wds_peer_msg->dest_mac, dest_mac);
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
NSS_WIFILI_WDS_PEER_DEL_MSG,
|
||||
@@ -4366,7 +4378,7 @@ static int ath11k_nss_mesh_capability(st
|
||||
if (!wlmsg)
|
||||
return -ENOMEM;
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
reinit_completion(&ab->nss.complete);
|
||||
|
||||
@@ -4483,7 +4495,7 @@ static int ath11k_nss_init(struct ath11k
|
||||
|
||||
/* register callbacks for events and exceptions with nss */
|
||||
nss_contex = nss_register_wifili_if(ab->nss.if_num, NULL,
|
||||
- (nss_wifili_callback_t)ath11k_nss_wifili_ext_callback_fn,
|
||||
+ (nss_wifili_callback_t)ath11k_nss_wifili_ext_callback_wrapper,
|
||||
(nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive,
|
||||
(struct net_device *)ab, features);
|
||||
|
||||
@@ -4502,7 +4514,7 @@ static int ath11k_nss_init(struct ath11k
|
||||
*/
|
||||
ab->nss.ctx = nss_contex;
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
/* Initialize the common part of the wlmsg */
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
@@ -4574,7 +4586,7 @@ static int ath11k_nss_stats_cfg(struct a
|
||||
stats_cfg = &wlmsg->msg.scm;
|
||||
stats_cfg->cfg = enable;
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
nss_msg,
|
||||
@@ -4684,7 +4696,7 @@ int ath11k_nss_pdev_init(struct ath11k_b
|
||||
refill_ring_id = ar->dp.rx_refill_buf_ring.refill_buf_ring.ring_id;
|
||||
ath11k_nss_fill_srng_info(ab, refill_ring_id, &pdevmsg->rxdma_ring);
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
NSS_WIFILI_PDEV_INIT_MSG,
|
||||
@@ -4758,7 +4770,7 @@ int ath11k_nss_start(struct ath11k_base
|
||||
if (!wlmsg)
|
||||
return -ENOMEM;
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
/* Empty message for NSS Start message */
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
@@ -4816,7 +4828,7 @@ static void ath11k_nss_reset(struct ath1
|
||||
return;
|
||||
}
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
/* Empty message for NSS Reset message */
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
@@ -4869,7 +4881,7 @@ static int ath11k_nss_stop(struct ath11k
|
||||
if (!wlmsg)
|
||||
return -ENOMEM;
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
/* Empty message for Stop command */
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
@@ -4936,7 +4948,7 @@ int ath11k_nss_pdev_deinit(struct ath11k
|
||||
deinit = &wlmsg->msg.pdevdeinit;
|
||||
deinit->ifnum = radio_id;
|
||||
|
||||
- msg_cb = (nss_wifili_msg_callback_t)ath11k_nss_wifili_event_receive;
|
||||
+ msg_cb = ath11k_nss_wifili_event_receive;
|
||||
|
||||
nss_cmn_msg_init(&wlmsg->cm, ab->nss.if_num,
|
||||
NSS_WIFILI_PDEV_DEINIT_MSG,
|
||||
Reference in New Issue
Block a user