]> git.droids-corp.org - dpdk.git/commitdiff
common/cnxk: support inline device API without ROC NIX
authorVidya Sagar Velumuri <vvelumuri@marvell.com>
Tue, 22 Feb 2022 19:34:55 +0000 (01:04 +0530)
committerJerin Jacob <jerinj@marvell.com>
Wed, 23 Feb 2022 16:34:44 +0000 (17:34 +0100)
Update the inline device functions to work when roc_nix is NULL.
This is required, as IPsec driver have to use these APIs to work
with inline IPsec device, but the IPsec driver might not have roc_nix
information.

Signed-off-by: Vidya Sagar Velumuri <vvelumuri@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
drivers/common/cnxk/roc_nix_inl.c
drivers/common/cnxk/roc_nix_inl.h
drivers/common/cnxk/roc_nix_inl_dev.c
drivers/common/cnxk/roc_nix_inl_priv.h
drivers/common/cnxk/version.map
drivers/net/cnxk/cnxk_ethdev_sec.c

index e8981c4aa4a4dae9dff5ed3eb40f594414d307e9..356d11d237e155a2f76fb3854abb6f3149786eee 100644 (file)
@@ -107,18 +107,24 @@ roc_nix_inl_outb_sa_base_get(struct roc_nix *roc_nix)
 uintptr_t
 roc_nix_inl_inb_sa_base_get(struct roc_nix *roc_nix, bool inb_inl_dev)
 {
-       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
        struct idev_cfg *idev = idev_get_cfg();
        struct nix_inl_dev *inl_dev;
+       struct nix *nix = NULL;
 
        if (idev == NULL)
                return 0;
 
-       if (!nix->inl_inb_ena)
-               return 0;
+       if (!inb_inl_dev && roc_nix == NULL)
+               return -EINVAL;
+
+       if (roc_nix) {
+               nix = roc_nix_to_nix_priv(roc_nix);
+               if (!nix->inl_inb_ena)
+                       return 0;
+       }
 
-       inl_dev = idev->nix_inl_dev;
        if (inb_inl_dev) {
+               inl_dev = idev->nix_inl_dev;
                /* Return inline dev sa base */
                if (inl_dev)
                        return (uintptr_t)inl_dev->inb_sa_base;
@@ -131,18 +137,24 @@ roc_nix_inl_inb_sa_base_get(struct roc_nix *roc_nix, bool inb_inl_dev)
 uint32_t
 roc_nix_inl_inb_sa_max_spi(struct roc_nix *roc_nix, bool inb_inl_dev)
 {
-       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
        struct idev_cfg *idev = idev_get_cfg();
        struct nix_inl_dev *inl_dev;
+       struct nix *nix;
 
        if (idev == NULL)
                return 0;
 
-       if (!nix->inl_inb_ena)
-               return 0;
+       if (!inb_inl_dev && roc_nix == NULL)
+               return -EINVAL;
+
+       if (roc_nix) {
+               nix = roc_nix_to_nix_priv(roc_nix);
+               if (!nix->inl_inb_ena)
+                       return 0;
+       }
 
-       inl_dev = idev->nix_inl_dev;
        if (inb_inl_dev) {
+               inl_dev = idev->nix_inl_dev;
                if (inl_dev)
                        return inl_dev->ipsec_in_max_spi;
                return 0;
@@ -154,21 +166,28 @@ roc_nix_inl_inb_sa_max_spi(struct roc_nix *roc_nix, bool inb_inl_dev)
 uint32_t
 roc_nix_inl_inb_sa_sz(struct roc_nix *roc_nix, bool inl_dev_sa)
 {
-       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
        struct idev_cfg *idev = idev_get_cfg();
        struct nix_inl_dev *inl_dev;
+       struct nix *nix;
 
        if (idev == NULL)
                return 0;
 
-       if (!inl_dev_sa)
-               return nix->inb_sa_sz;
+       if (!inl_dev_sa && roc_nix == NULL)
+               return -EINVAL;
 
-       inl_dev = idev->nix_inl_dev;
-       if (inl_dev_sa && inl_dev)
-               return inl_dev->inb_sa_sz;
+       if (roc_nix) {
+               nix = roc_nix_to_nix_priv(roc_nix);
+               if (!inl_dev_sa)
+                       return nix->inb_sa_sz;
+       }
+
+       if (inl_dev_sa) {
+               inl_dev = idev->nix_inl_dev;
+               if (inl_dev)
+                       return inl_dev->inb_sa_sz;
+       }
 
-       /* On error */
        return 0;
 }
 
@@ -536,7 +555,7 @@ roc_nix_inl_dev_rq_get(struct roc_nix_rq *rq)
        inl_rq->tag_mask = 0xFFF00000;
        inl_rq->tt = SSO_TT_ORDERED;
        inl_rq->hwgrp = 0;
-       inl_rq->wqe_skip = 1;
+       inl_rq->wqe_skip = inl_dev->wqe_skip;
        inl_rq->sso_ena = true;
 
        /* Prepare and send RQ init mbox */
@@ -731,13 +750,14 @@ int
 roc_nix_inl_sa_sync(struct roc_nix *roc_nix, void *sa, bool inb,
                    enum roc_nix_inl_sa_sync_op op)
 {
-       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
-       struct roc_cpt_lf *outb_lf = nix->cpt_lf_base;
        struct idev_cfg *idev = idev_get_cfg();
        struct nix_inl_dev *inl_dev = NULL;
+       struct roc_cpt_lf *outb_lf = NULL;
        union cpt_lf_ctx_reload reload;
        union cpt_lf_ctx_flush flush;
+       bool get_inl_lf = true;
        uintptr_t rbase;
+       struct nix *nix;
 
        /* Nothing much to do on cn9k */
        if (roc_model_is_cn9k()) {
@@ -745,11 +765,22 @@ roc_nix_inl_sa_sync(struct roc_nix *roc_nix, void *sa, bool inb,
                return 0;
        }
 
-       if (inb && nix->inb_inl_dev) {
+       if (idev)
+               inl_dev = idev->nix_inl_dev;
+
+       if (!inl_dev && roc_nix == NULL)
+               return -EINVAL;
+
+       if (roc_nix) {
+               nix = roc_nix_to_nix_priv(roc_nix);
+               outb_lf = nix->cpt_lf_base;
+               if (inb && !nix->inb_inl_dev)
+                       get_inl_lf = false;
+       }
+
+       if (inb && get_inl_lf) {
                outb_lf = NULL;
-               if (idev)
-                       inl_dev = idev->nix_inl_dev;
-               if (inl_dev)
+               if (inl_dev && inl_dev->attach_cptlf)
                        outb_lf = &inl_dev->cpt_lf;
        }
 
@@ -783,12 +814,13 @@ int
 roc_nix_inl_ctx_write(struct roc_nix *roc_nix, void *sa_dptr, void *sa_cptr,
                      bool inb, uint16_t sa_len)
 {
-       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
-       struct roc_cpt_lf *outb_lf = nix->cpt_lf_base;
        struct idev_cfg *idev = idev_get_cfg();
        struct nix_inl_dev *inl_dev = NULL;
+       struct roc_cpt_lf *outb_lf = NULL;
        union cpt_lf_ctx_flush flush;
+       bool get_inl_lf = true;
        uintptr_t rbase;
+       struct nix *nix;
        int rc;
 
        /* Nothing much to do on cn9k */
@@ -797,10 +829,22 @@ roc_nix_inl_ctx_write(struct roc_nix *roc_nix, void *sa_dptr, void *sa_cptr,
                return 0;
        }
 
-       if (inb && nix->inb_inl_dev) {
+       if (idev)
+               inl_dev = idev->nix_inl_dev;
+
+       if (!inl_dev && roc_nix == NULL)
+               return -EINVAL;
+
+       if (roc_nix) {
+               nix = roc_nix_to_nix_priv(roc_nix);
+               outb_lf = nix->cpt_lf_base;
+
+               if (inb && !nix->inb_inl_dev)
+                       get_inl_lf = false;
+       }
+
+       if (inb && get_inl_lf) {
                outb_lf = NULL;
-               if (idev)
-                       inl_dev = idev->nix_inl_dev;
                if (inl_dev && inl_dev->attach_cptlf)
                        outb_lf = &inl_dev->cpt_lf;
        }
index bbdcbc82ee95f92c57a2b76cde5cc9fe9c2ee9e5..ceeccabaeaa7d2d94358524d7d00ff7d58a6bd85 100644 (file)
@@ -111,6 +111,7 @@ struct roc_nix_inl_dev {
        uint16_t channel;
        uint16_t chan_mask;
        bool attach_cptlf;
+       bool wqe_skip;
        /* End of input parameters */
 
 #define ROC_NIX_INL_MEM_SZ (1280)
@@ -125,6 +126,7 @@ bool __roc_api roc_nix_inl_dev_is_probed(void);
 void __roc_api roc_nix_inl_dev_lock(void);
 void __roc_api roc_nix_inl_dev_unlock(void);
 int __roc_api roc_nix_inl_dev_xaq_realloc(uint64_t aura_handle);
+uint16_t __roc_api roc_nix_inl_dev_pffunc_get(void);
 
 /* NIX Inline Inbound API */
 int __roc_api roc_nix_inl_inb_init(struct roc_nix *roc_nix);
index 1d14f0481ef3a6a7a794deeddda7cf0f5c80785d..12160e93a9b37c158410324d6b114c74dbf0d34b 100644 (file)
@@ -27,6 +27,12 @@ nix_inl_dev_pffunc_get(void)
        return 0;
 }
 
+uint16_t
+roc_nix_inl_dev_pffunc_get(void)
+{
+       return nix_inl_dev_pffunc_get();
+}
+
 static void
 nix_inl_selftest_work_cb(uint64_t *gw, void *args)
 {
@@ -655,6 +661,7 @@ roc_nix_inl_dev_init(struct roc_nix_inl_dev *roc_inl_dev)
        inl_dev->channel = roc_inl_dev->channel;
        inl_dev->chan_mask = roc_inl_dev->chan_mask;
        inl_dev->attach_cptlf = roc_inl_dev->attach_cptlf;
+       inl_dev->wqe_skip = roc_inl_dev->wqe_skip;
 
        /* Initialize base device */
        rc = dev_init(&inl_dev->dev, pci_dev);
index 17df23fbb57b9a232594b0de976f00a72b757759..dcf752e2565342fe24a5d3af0be00d47667216db 100644 (file)
@@ -58,6 +58,7 @@ struct nix_inl_dev {
        bool is_multi_channel;
        uint16_t ipsec_in_max_spi;
        bool attach_cptlf;
+       bool wqe_skip;
 };
 
 int nix_inl_sso_register_irqs(struct nix_inl_dev *inl_dev);
index 850145bc03f54df52b59bb3ed532452c8cbf6ec2..8d0e4bda81b954ea5712618fed895e32f115ab32 100644 (file)
@@ -158,6 +158,7 @@ INTERNAL {
        roc_nix_inl_outb_is_enabled;
        roc_nix_inl_sa_sync;
        roc_nix_inl_ctx_write;
+       roc_nix_inl_dev_pffunc_get;
        roc_nix_inl_inb_sa_init;
        roc_nix_inl_outb_sa_init;
        roc_nix_cpt_ctx_cache_sync;
index 3fef0562ea2c49a2ad99856e9f14c98b3d2db35b..ea204ca882c382dd62283b2463f5d2b6c7ff25b6 100644 (file)
@@ -278,6 +278,8 @@ cnxk_nix_inl_dev_probe(struct rte_pci_driver *pci_drv,
        }
 
        inl_dev->attach_cptlf = true;
+       /* WQE skip is one for DPDK */
+       inl_dev->wqe_skip = true;
        rc = roc_nix_inl_dev_init(inl_dev);
        if (rc) {
                plt_err("Failed to init nix inl device, rc=%d(%s)", rc,