raw/cnxk_bphy: support reading NPA/SSO PF function
authorTomasz Duszynski <tduszynski@marvell.com>
Sun, 15 Aug 2021 23:12:02 +0000 (01:12 +0200)
committerJerin Jacob <jerinj@marvell.com>
Tue, 28 Sep 2021 13:16:28 +0000 (15:16 +0200)
Add support for reading NPA/SSO pf_func which will be used
by a PSM to access NPA/SSO. PSM is a hardware block capable
of dispatching jobs to different blocks within a baseband
module.

Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
drivers/raw/cnxk_bphy/cnxk_bphy.c
drivers/raw/cnxk_bphy/rte_pmd_bphy.h

index 69fd040..4b7669b 100644 (file)
@@ -68,6 +68,14 @@ bphy_rawdev_selftest(uint16_t dev_id)
                goto err_desc;
        }
 
+       ret = rte_pmd_bphy_npa_pf_func_get(dev_id);
+       if (ret == 0)
+               plt_warn("NPA pf_func is invalid");
+
+       ret = rte_pmd_bphy_sso_pf_func_get(dev_id);
+       if (ret == 0)
+               plt_warn("SSO pf_func is invalid");
+
        ret = rte_pmd_bphy_intr_init(dev_id);
        if (ret) {
                plt_err("intr init failed");
@@ -191,6 +199,14 @@ cnxk_bphy_irq_enqueue_bufs(struct rte_rawdev *dev,
        case CNXK_BPHY_IRQ_MSG_TYPE_MEM_GET:
                bphy_dev->queues[queue].rsp = &bphy_dev->mem;
                break;
+       case CNXK_BPHY_MSG_TYPE_NPA_PF_FUNC:
+               bphy_dev->queues[queue].rsp =
+                       (void *)(size_t)roc_bphy_npa_pf_func_get();
+               break;
+       case CNXK_BPHY_MSG_TYPE_SSO_PF_FUNC:
+               bphy_dev->queues[queue].rsp =
+                       (void *)(size_t)roc_bphy_sso_pf_func_get();
+               break;
        default:
                ret = -EINVAL;
        }
index d459c3a..bcd165f 100644 (file)
@@ -114,6 +114,8 @@ enum cnxk_bphy_irq_msg_type {
        CNXK_BPHY_IRQ_MSG_TYPE_REGISTER,
        CNXK_BPHY_IRQ_MSG_TYPE_UNREGISTER,
        CNXK_BPHY_IRQ_MSG_TYPE_MEM_GET,
+       CNXK_BPHY_MSG_TYPE_NPA_PF_FUNC,
+       CNXK_BPHY_MSG_TYPE_SSO_PF_FUNC,
 };
 
 struct cnxk_bphy_irq_msg {
@@ -232,4 +234,52 @@ rte_pmd_bphy_intr_mem_get(uint16_t dev_id)
        return buf.buf_addr;
 }
 
+static __rte_always_inline uint16_t
+rte_pmd_bphy_npa_pf_func_get(uint16_t dev_id)
+{
+       struct cnxk_bphy_irq_msg msg = {
+               .type = CNXK_BPHY_MSG_TYPE_NPA_PF_FUNC,
+       };
+       struct rte_rawdev_buf *bufs[1];
+       struct rte_rawdev_buf buf;
+       int ret;
+
+       buf.buf_addr = &msg;
+       bufs[0] = &buf;
+
+       ret = rte_rawdev_enqueue_buffers(dev_id, bufs, 1, CNXK_BPHY_DEF_QUEUE);
+       if (ret)
+               return 0;
+
+       ret = rte_rawdev_dequeue_buffers(dev_id, bufs, 1, CNXK_BPHY_DEF_QUEUE);
+       if (ret)
+               return 0;
+
+       return (uint16_t)(size_t)buf.buf_addr;
+}
+
+static __rte_always_inline uint16_t
+rte_pmd_bphy_sso_pf_func_get(uint16_t dev_id)
+{
+       struct cnxk_bphy_irq_msg msg = {
+               .type = CNXK_BPHY_MSG_TYPE_SSO_PF_FUNC,
+       };
+       struct rte_rawdev_buf *bufs[1];
+       struct rte_rawdev_buf buf;
+       int ret;
+
+       buf.buf_addr = &msg;
+       bufs[0] = &buf;
+
+       ret = rte_rawdev_enqueue_buffers(dev_id, bufs, 1, CNXK_BPHY_DEF_QUEUE);
+       if (ret)
+               return 0;
+
+       ret = rte_rawdev_dequeue_buffers(dev_id, bufs, 1, CNXK_BPHY_DEF_QUEUE);
+       if (ret)
+               return 0;
+
+       return (uint16_t)(size_t)buf.buf_addr;
+}
+
 #endif /* _CNXK_BPHY_H_ */