diff --git a/umac/p2p/core/src/wlan_p2p_main.c b/umac/p2p/core/src/wlan_p2p_main.c index e76f06ffb40d..d7944cf084ad 100644 --- a/umac/p2p/core/src/wlan_p2p_main.c +++ b/umac/p2p/core/src/wlan_p2p_main.c @@ -821,6 +821,7 @@ QDF_STATUS p2p_psoc_object_open(struct wlan_objmgr_psoc *soc) qdf_runtime_lock_init(&p2p_soc_obj->roc_runtime_lock); p2p_soc_obj->cur_roc_vdev_id = P2P_INVALID_VDEV_ID; + qdf_idr_create(&p2p_soc_obj->p2p_idr); p2p_register_pmo_handler(); p2p_debug("p2p psoc object open successful"); @@ -852,6 +853,7 @@ QDF_STATUS p2p_psoc_object_close(struct wlan_objmgr_psoc *soc) } p2p_unregister_pmo_handler(); + qdf_idr_destroy(&p2p_soc_obj->p2p_idr); qdf_runtime_lock_deinit(&p2p_soc_obj->roc_runtime_lock); qdf_event_destroy(&p2p_soc_obj->cancel_roc_done); qdf_list_destroy(&p2p_soc_obj->tx_q_ack); diff --git a/umac/p2p/core/src/wlan_p2p_main.h b/umac/p2p/core/src/wlan_p2p_main.h index 7f0950abb24b..013505f652eb 100644 --- a/umac/p2p/core/src/wlan_p2p_main.h +++ b/umac/p2p/core/src/wlan_p2p_main.h @@ -28,6 +28,7 @@ #include #include #include +#include #define MAX_QUEUE_LENGTH 20 #define P2P_NOA_ATTR_IND 0x1090 @@ -169,6 +170,7 @@ enum p2p_connection_status { * @roc_runtime_lock: Runtime lock for roc request * @p2p_cb: Callbacks to protocol stack * @cur_roc_vdev_id: Vdev id of current roc + * @p2p_idr: p2p idr * @connection_status:Global P2P connection status */ struct p2p_soc_priv_obj { @@ -182,6 +184,7 @@ struct p2p_soc_priv_obj { qdf_runtime_lock_t roc_runtime_lock; struct p2p_protocol_callbacks p2p_cb; uint32_t cur_roc_vdev_id; + qdf_idr p2p_idr; #ifdef WLAN_FEATURE_P2P_DEBUG enum p2p_connection_status connection_status; #endif diff --git a/umac/p2p/core/src/wlan_p2p_off_chan_tx.c b/umac/p2p/core/src/wlan_p2p_off_chan_tx.c index 65b514c4f2b8..d8fc89eec7b6 100644 --- a/umac/p2p/core/src/wlan_p2p_off_chan_tx.c +++ b/umac/p2p/core/src/wlan_p2p_off_chan_tx.c @@ -841,7 +841,7 @@ static QDF_STATUS p2p_send_tx_conf(struct tx_action_context *tx_ctx, if (tx_ctx->no_ack) tx_cnf.action_cookie = 0; else - tx_cnf.action_cookie = (uintptr_t)tx_ctx; + tx_cnf.action_cookie = (uint64_t)tx_ctx->id; tx_cnf.vdev_id = tx_ctx->vdev_id; tx_cnf.buf = tx_ctx->buf; @@ -1242,6 +1242,7 @@ static QDF_STATUS p2p_remove_tx_context( } end: + qdf_idr_remove(&p2p_soc_obj->p2p_idr, tx_ctx->id); qdf_mem_free(tx_ctx->buf); qdf_mem_free(tx_ctx); diff --git a/umac/p2p/core/src/wlan_p2p_off_chan_tx.h b/umac/p2p/core/src/wlan_p2p_off_chan_tx.h index 713c3c35a811..19287c3fedef 100644 --- a/umac/p2p/core/src/wlan_p2p_off_chan_tx.h +++ b/umac/p2p/core/src/wlan_p2p_off_chan_tx.h @@ -148,6 +148,7 @@ struct p2p_frame_info { * @vdev_id: Vdev id on which this request has come * @scan_id: Scan id given by scan component for this roc req * @roc_cookie: Cookie for remain on channel request + * @id: Identifier of this tx context * @chan: Chan for which this tx has been requested * @buf: tx buffer * @buf_len: Length of tx buffer @@ -165,6 +166,7 @@ struct tx_action_context { int vdev_id; int scan_id; uint64_t roc_cookie; + int32_t id; uint8_t chan; uint8_t *buf; int buf_len; diff --git a/umac/p2p/core/src/wlan_p2p_roc.c b/umac/p2p/core/src/wlan_p2p_roc.c index 4b968214dcfc..ff8a55c2ec3e 100644 --- a/umac/p2p/core/src/wlan_p2p_roc.c +++ b/umac/p2p/core/src/wlan_p2p_roc.c @@ -199,7 +199,7 @@ static QDF_STATUS p2p_send_roc_event( p2p_evt.vdev_id = roc_ctx->vdev_id; p2p_evt.roc_event = evt; - p2p_evt.cookie = (uintptr_t)roc_ctx; + p2p_evt.cookie = (uint64_t)roc_ctx->id; p2p_evt.chan = roc_ctx->chan; p2p_evt.duration = roc_ctx->duration; @@ -244,6 +244,7 @@ static QDF_STATUS p2p_destroy_roc_ctx(struct p2p_roc_context *roc_ctx, p2p_err("Failed to remove roc req, status %d", status); } + qdf_idr_remove(&p2p_soc_obj->p2p_idr, roc_ctx->id); qdf_mem_free(roc_ctx); return status; diff --git a/umac/p2p/core/src/wlan_p2p_roc.h b/umac/p2p/core/src/wlan_p2p_roc.h index 84cadf99aeed..fa40e7aa885d 100644 --- a/umac/p2p/core/src/wlan_p2p_roc.h +++ b/umac/p2p/core/src/wlan_p2p_roc.h @@ -84,6 +84,7 @@ enum roc_state { * @roc_type: RoC type User requested or internal * @roc_timer: RoC timer * @roc_state: Roc state + * @id: identifier of roc */ struct p2p_roc_context { qdf_list_node_t node; @@ -97,6 +98,7 @@ struct p2p_roc_context { enum roc_type roc_type; qdf_mc_timer_t roc_timer; enum roc_state roc_state; + int32_t id; }; /** diff --git a/umac/p2p/dispatcher/src/wlan_p2p_tgt_api.c b/umac/p2p/dispatcher/src/wlan_p2p_tgt_api.c index 6c41bb27a2dd..50017d7f5688 100644 --- a/umac/p2p/dispatcher/src/wlan_p2p_tgt_api.c +++ b/umac/p2p/dispatcher/src/wlan_p2p_tgt_api.c @@ -167,7 +167,7 @@ QDF_STATUS tgt_p2p_mgmt_ota_comp_cb(void *context, qdf_nbuf_t buf, qdf_nbuf_free(buf); tx_cnf->vdev_id = tx_ctx->vdev_id; - tx_cnf->action_cookie = (uintptr_t)tx_ctx; + tx_cnf->action_cookie = (uint64_t)tx_ctx->id; tx_cnf->buf = tx_ctx->buf; tx_cnf->buf_len = tx_ctx->buf_len; tx_cnf->status = status; diff --git a/umac/p2p/dispatcher/src/wlan_p2p_ucfg_api.c b/umac/p2p/dispatcher/src/wlan_p2p_ucfg_api.c index 4246f4bded0e..1956b13e9bb1 100644 --- a/umac/p2p/dispatcher/src/wlan_p2p_ucfg_api.c +++ b/umac/p2p/dispatcher/src/wlan_p2p_ucfg_api.c @@ -114,6 +114,8 @@ QDF_STATUS ucfg_p2p_roc_req(struct wlan_objmgr_psoc *soc, struct scheduler_msg msg = {0}; struct p2p_soc_priv_obj *p2p_soc_obj; struct p2p_roc_context *roc_ctx; + QDF_STATUS status; + int32_t id; p2p_debug("soc:%pK, vdev_id:%d, chan:%d, phy_mode:%d, duration:%d", soc, roc_req->vdev_id, roc_req->chan, @@ -137,7 +139,14 @@ QDF_STATUS ucfg_p2p_roc_req(struct wlan_objmgr_psoc *soc, return QDF_STATUS_E_NOMEM; } - *cookie = (uintptr_t)roc_ctx; + status = qdf_idr_alloc(&p2p_soc_obj->p2p_idr, roc_ctx, &id); + if (status != QDF_STATUS_SUCCESS) { + qdf_mem_free(roc_ctx); + p2p_err("failed to alloc idr, status %d", status); + return status; + } + + *cookie = (uint64_t)id; roc_ctx->p2p_soc_obj = p2p_soc_obj; roc_ctx->vdev_id = roc_req->vdev_id; roc_ctx->chan = roc_req->chan; @@ -145,10 +154,12 @@ QDF_STATUS ucfg_p2p_roc_req(struct wlan_objmgr_psoc *soc, roc_ctx->duration = roc_req->duration; roc_ctx->roc_state = ROC_STATE_IDLE; roc_ctx->roc_type = USER_REQUESTED; + roc_ctx->id = id; msg.type = P2P_ROC_REQ; msg.bodyptr = roc_ctx; msg.callback = p2p_process_cmd; scheduler_post_msg(QDF_MODULE_ID_OS_IF, &msg); + p2p_debug("cookie = 0x%llx", *cookie); return QDF_STATUS_SUCCESS; } @@ -159,6 +170,7 @@ QDF_STATUS ucfg_p2p_roc_cancel_req(struct wlan_objmgr_psoc *soc, struct scheduler_msg msg = {0}; struct p2p_soc_priv_obj *p2p_soc_obj; struct cancel_roc_context *cancel_roc; + void *roc_ctx = NULL; p2p_debug("soc:%pK, cookie:0x%llx", soc, cookie); @@ -174,6 +186,12 @@ QDF_STATUS ucfg_p2p_roc_cancel_req(struct wlan_objmgr_psoc *soc, return QDF_STATUS_E_FAILURE; } + if (QDF_STATUS_SUCCESS != qdf_idr_find(&p2p_soc_obj->p2p_idr, + cookie, &roc_ctx)) { + p2p_err("invalid id"); + return QDF_STATUS_E_INVAL; + } + cancel_roc = qdf_mem_malloc(sizeof(*cancel_roc)); if (!cancel_roc) { p2p_err("failed to allocate cancel p2p roc"); @@ -181,7 +199,7 @@ QDF_STATUS ucfg_p2p_roc_cancel_req(struct wlan_objmgr_psoc *soc, } cancel_roc->p2p_soc_obj = p2p_soc_obj; - cancel_roc->cookie = cookie; + cancel_roc->cookie = (uintptr_t)roc_ctx; msg.type = P2P_CANCEL_ROC_REQ; msg.bodyptr = cancel_roc; msg.callback = p2p_process_cmd; @@ -226,6 +244,8 @@ QDF_STATUS ucfg_p2p_mgmt_tx(struct wlan_objmgr_psoc *soc, struct scheduler_msg msg = {0}; struct p2p_soc_priv_obj *p2p_soc_obj; struct tx_action_context *tx_action; + QDF_STATUS status; + int32_t id; p2p_debug("soc:%pK, vdev_id:%d, chan:%d, wait:%d, buf_len:%d, cck:%d, no ack:%d, off chan:%d", soc, mgmt_frm->vdev_id, mgmt_frm->chan, @@ -253,9 +273,17 @@ QDF_STATUS ucfg_p2p_mgmt_tx(struct wlan_objmgr_psoc *soc, /* return cookie just for ota ack frames */ if (mgmt_frm->dont_wait_for_ack) *cookie = 0; - else - *cookie = (uintptr_t)tx_action; + else { + status = qdf_idr_alloc(&p2p_soc_obj->p2p_idr, + tx_action, &id); + if (status != QDF_STATUS_SUCCESS) { + qdf_mem_free(tx_action); + p2p_err("failed to alloc idr, status :%d", status); + return status; + } + } + *cookie = (uint64_t)id; tx_action->p2p_soc_obj = p2p_soc_obj; tx_action->vdev_id = mgmt_frm->vdev_id; tx_action->chan = mgmt_frm->chan; @@ -273,6 +301,7 @@ QDF_STATUS ucfg_p2p_mgmt_tx(struct wlan_objmgr_psoc *soc, } qdf_mem_copy(tx_action->buf, mgmt_frm->buf, tx_action->buf_len); tx_action->nbuf = NULL; + tx_action->id = id; msg.type = P2P_MGMT_TX; msg.bodyptr = tx_action; msg.callback = p2p_process_cmd; @@ -287,6 +316,7 @@ QDF_STATUS ucfg_p2p_mgmt_tx_cancel(struct wlan_objmgr_psoc *soc, struct scheduler_msg msg = {0}; struct p2p_soc_priv_obj *p2p_soc_obj; struct cancel_roc_context *cancel_tx; + void *tx_ctx; p2p_debug("soc:%pK, cookie:0x%llx", soc, cookie); @@ -302,6 +332,12 @@ QDF_STATUS ucfg_p2p_mgmt_tx_cancel(struct wlan_objmgr_psoc *soc, return QDF_STATUS_E_FAILURE; } + if (QDF_STATUS_SUCCESS != qdf_idr_find(&p2p_soc_obj->p2p_idr, + cookie, &tx_ctx)) { + p2p_err("invalid id"); + return QDF_STATUS_E_INVAL; + } + cancel_tx = qdf_mem_malloc(sizeof(*cancel_tx)); if (!cancel_tx) { p2p_err("Failed to allocate cancel p2p roc"); @@ -309,7 +345,7 @@ QDF_STATUS ucfg_p2p_mgmt_tx_cancel(struct wlan_objmgr_psoc *soc, } cancel_tx->p2p_soc_obj = p2p_soc_obj; - cancel_tx->cookie = cookie; + cancel_tx->cookie = (uintptr_t)tx_ctx; msg.type = P2P_MGMT_TX_CANCEL; msg.bodyptr = cancel_tx; msg.callback = p2p_process_cmd;