From: Vidya Sagar Velumuri <vvelum...@marvell.com>

Add API to configure NIX block for inline IPSec.

Signed-off-by: Vidya Sagar Velumuri <vvelum...@marvell.com>
---
 drivers/common/cnxk/roc_nix.c   | 28 ++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_nix.h   | 10 ++++++++++
 drivers/common/cnxk/version.map |  1 +
 3 files changed, 39 insertions(+)

diff --git a/drivers/common/cnxk/roc_nix.c b/drivers/common/cnxk/roc_nix.c
index e64936e..0621976 100644
--- a/drivers/common/cnxk/roc_nix.c
+++ b/drivers/common/cnxk/roc_nix.c
@@ -81,6 +81,34 @@ roc_nix_get_pf_func(struct roc_nix *roc_nix)
 }
 
 int
+roc_nix_lf_inl_ipsec_cfg(struct roc_nix *roc_nix, struct roc_nix_ipsec_cfg 
*cfg,
+                        bool enb)
+{
+       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+       struct nix_inline_ipsec_lf_cfg *lf_cfg;
+       struct mbox *mbox = (&nix->dev)->mbox;
+
+       lf_cfg = mbox_alloc_msg_nix_inline_ipsec_lf_cfg(mbox);
+       if (lf_cfg == NULL)
+               return -ENOSPC;
+
+       if (enb) {
+               lf_cfg->enable = 1;
+               lf_cfg->sa_base_addr = cfg->iova;
+               lf_cfg->ipsec_cfg1.sa_idx_w = plt_log2_u32(cfg->max_sa);
+               lf_cfg->ipsec_cfg0.lenm1_max = roc_nix_max_pkt_len(roc_nix) - 1;
+               lf_cfg->ipsec_cfg1.sa_idx_max = cfg->max_sa - 1;
+               lf_cfg->ipsec_cfg0.sa_pow2_size = plt_log2_u32(cfg->sa_size);
+               lf_cfg->ipsec_cfg0.tag_const = cfg->tag_const;
+               lf_cfg->ipsec_cfg0.tt = cfg->tt;
+       } else {
+               lf_cfg->enable = 0;
+       }
+
+       return mbox_process(mbox);
+}
+
+int
 roc_nix_max_pkt_len(struct roc_nix *roc_nix)
 {
        struct nix *nix = roc_nix_to_nix_priv(roc_nix);
diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
index 638f827..1c097cb 100644
--- a/drivers/common/cnxk/roc_nix.h
+++ b/drivers/common/cnxk/roc_nix.h
@@ -110,6 +110,14 @@ struct roc_nix_link_info {
        uint64_t port : 8;
 };
 
+struct roc_nix_ipsec_cfg {
+       uint32_t sa_size;
+       uint32_t tag_const;
+       plt_iova_t iova;
+       uint16_t max_sa;
+       uint8_t tt;
+};
+
 /* Link status update callback */
 typedef void (*link_status_t)(struct roc_nix *roc_nix,
                              struct roc_nix_link_info *link);
@@ -156,6 +164,8 @@ int __roc_api roc_nix_max_pkt_len(struct roc_nix *roc_nix);
 int __roc_api roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t nb_rxq,
                               uint32_t nb_txq, uint64_t rx_cfg);
 int __roc_api roc_nix_lf_free(struct roc_nix *roc_nix);
+int __roc_api roc_nix_lf_inl_ipsec_cfg(struct roc_nix *roc_nix,
+                                      struct roc_nix_ipsec_cfg *cfg, bool enb);
 
 /* IRQ */
 void __roc_api roc_nix_rx_queue_intr_enable(struct roc_nix *roc_nix,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 2ca6368..fdb1aee 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -28,6 +28,7 @@ INTERNAL {
        roc_nix_is_sdp;
        roc_nix_is_vf_or_sdp;
        roc_nix_lf_alloc;
+       roc_nix_lf_inl_ipsec_cfg;
        roc_nix_lf_free;
        roc_nix_mac_addr_add;
        roc_nix_mac_addr_del;
-- 
2.8.4

Reply via email to