Based on thread context, mbox API will get response for submitted request. If thread runs in interrupt context then it uses polling based get response API otherwise interrupt based.
Signed-off-by: Sunil Kumar Kori <sk...@marvell.com> --- drivers/common/octeontx2/otx2_dev.c | 27 ++++++++++++--------------- drivers/common/octeontx2/otx2_mbox.h | 21 +++++++++++++++++---- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/drivers/common/octeontx2/otx2_dev.c b/drivers/common/octeontx2/otx2_dev.c index 6f29d6108..d61c712fa 100644 --- a/drivers/common/octeontx2/otx2_dev.c +++ b/drivers/common/octeontx2/otx2_dev.c @@ -577,17 +577,16 @@ otx2_pf_vf_mbox_irq(void *param) intr = otx2_read64(dev->bar2 + RVU_VF_INT); if (intr == 0) - return; + otx2_base_dbg("Proceeding to check mbox UP messages if any"); otx2_write64(intr, dev->bar2 + RVU_VF_INT); otx2_base_dbg("Irq 0x%" PRIx64 "(pf:%d,vf:%d)", intr, dev->pf, dev->vf); - if (intr) { - /* First process all configuration messages */ - otx2_process_msgs(dev, dev->mbox); - /* Process Uplink messages */ - otx2_process_msgs_up(dev, &dev->mbox_up); - } + /* First process all configuration messages */ + otx2_process_msgs(dev, dev->mbox); + + /* Process Uplink messages */ + otx2_process_msgs_up(dev, &dev->mbox_up); } static void @@ -598,18 +597,16 @@ otx2_af_pf_mbox_irq(void *param) intr = otx2_read64(dev->bar2 + RVU_PF_INT); if (intr == 0) - return; + otx2_base_dbg("Proceeding to check mbox UP messages if any"); otx2_write64(intr, dev->bar2 + RVU_PF_INT); - otx2_base_dbg("Irq 0x%" PRIx64 "(pf:%d,vf:%d)", intr, dev->pf, dev->vf); - if (intr) { - /* First process all configuration messages */ - otx2_process_msgs(dev, dev->mbox); - /* Process Uplink messages */ - otx2_process_msgs_up(dev, &dev->mbox_up); - } + /* First process all configuration messages */ + otx2_process_msgs(dev, dev->mbox); + + /* Process Uplink messages */ + otx2_process_msgs_up(dev, &dev->mbox_up); } static int diff --git a/drivers/common/octeontx2/otx2_mbox.h b/drivers/common/octeontx2/otx2_mbox.h index 237d4cf45..e82dfe530 100644 --- a/drivers/common/octeontx2/otx2_mbox.h +++ b/drivers/common/octeontx2/otx2_mbox.h @@ -9,6 +9,7 @@ #include <stdbool.h> #include <rte_ether.h> +#include <rte_interrupts.h> #include <rte_spinlock.h> #include <otx2_common.h> @@ -1627,28 +1628,40 @@ static inline int otx2_mbox_process(struct otx2_mbox *mbox) { otx2_mbox_msg_send(mbox, 0); - return otx2_mbox_get_rsp(mbox, 0, NULL); + if (rte_thread_is_intr()) + return otx2_mbox_get_rsp_poll(mbox, 0, NULL); + else + return otx2_mbox_get_rsp(mbox, 0, NULL); } static inline int otx2_mbox_process_msg(struct otx2_mbox *mbox, void **msg) { otx2_mbox_msg_send(mbox, 0); - return otx2_mbox_get_rsp(mbox, 0, msg); + if (rte_thread_is_intr()) + return otx2_mbox_get_rsp_poll(mbox, 0, msg); + else + return otx2_mbox_get_rsp(mbox, 0, msg); } static inline int otx2_mbox_process_tmo(struct otx2_mbox *mbox, uint32_t tmo) { otx2_mbox_msg_send(mbox, 0); - return otx2_mbox_get_rsp_tmo(mbox, 0, NULL, tmo); + if (rte_thread_is_intr()) + return otx2_mbox_get_rsp_poll_tmo(mbox, 0, NULL, tmo); + else + return otx2_mbox_get_rsp_tmo(mbox, 0, NULL, tmo); } static inline int otx2_mbox_process_msg_tmo(struct otx2_mbox *mbox, void **msg, uint32_t tmo) { otx2_mbox_msg_send(mbox, 0); - return otx2_mbox_get_rsp_tmo(mbox, 0, msg, tmo); + if (rte_thread_is_intr()) + return otx2_mbox_get_rsp_poll_tmo(mbox, 0, msg, tmo); + else + return otx2_mbox_get_rsp_tmo(mbox, 0, msg, tmo); } int otx2_send_ready_msg(struct otx2_mbox *mbox, uint16_t *pf_func /* out */); -- 2.17.1