Skip to content

Commit

Permalink
net/cnxk: support inline ingress out-of-place session
Browse files Browse the repository at this point in the history
Add support for inline ingress session with out-of-place
support.

Signed-off-by: Nithin Dabilpuram <[email protected]>
Acked-by: Akhil Goyal <[email protected]>
  • Loading branch information
nithind1988 authored and Akhil Goyal committed Oct 9, 2023
1 parent 0cea5ca commit 373c48f
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 30 deletions.
12 changes: 11 additions & 1 deletion drivers/event/cnxk/cn10k_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ cn10k_process_vwqe(uintptr_t vwqe, uint16_t port_id, const uint32_t flags, struc
uint16_t lmt_id, d_off;
struct rte_mbuf **wqe;
struct rte_mbuf *mbuf;
uint64_t sa_base = 0;
uintptr_t cpth = 0;
uint8_t loff = 0;
uint64_t sa_base;
int i;

mbuf_init |= ((uint64_t)port_id) << 48;
Expand Down Expand Up @@ -125,6 +125,11 @@ cn10k_process_vwqe(uintptr_t vwqe, uint16_t port_id, const uint32_t flags, struc

cpth = ((uintptr_t)mbuf + (uint16_t)d_off);

/* Update mempool pointer for full mode pkt */
if ((flags & NIX_RX_REAS_F) && (cq_w1 & BIT(11)) &&
!((*(uint64_t *)cpth) & BIT(15)))
mbuf->pool = mp;

mbuf = nix_sec_meta_to_mbuf_sc(cq_w1, cq_w5, sa_base, laddr,
&loff, mbuf, d_off,
flags, mbuf_init);
Expand Down Expand Up @@ -199,6 +204,11 @@ cn10k_sso_hws_post_process(struct cn10k_sso_hws *ws, uint64_t *u64,
mp = (struct rte_mempool *)cnxk_nix_inl_metapool_get(port, lookup_mem);
meta_aura = mp ? mp->pool_id : m->pool->pool_id;

/* Update mempool pointer for full mode pkt */
if (mp && (flags & NIX_RX_REAS_F) && (cq_w1 & BIT(11)) &&
!((*(uint64_t *)cpth) & BIT(15)))
((struct rte_mbuf *)mbuf)->pool = mp;

mbuf = (uint64_t)nix_sec_meta_to_mbuf_sc(
cq_w1, cq_w5, sa_base, (uintptr_t)&iova, &loff,
(struct rte_mbuf *)mbuf, d_off, flags,
Expand Down
13 changes: 9 additions & 4 deletions drivers/net/cnxk/cn10k_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,13 @@ cn10k_nix_rx_queue_meta_aura_update(struct rte_eth_dev *eth_dev)
rq = &dev->rqs[i];
rxq = eth_dev->data->rx_queues[i];
rxq->meta_aura = rq->meta_aura_handle;
rxq->meta_pool = dev->nix.meta_mempool;
/* Assume meta packet from normal aura if meta aura is not setup
*/
if (!rxq->meta_aura) {
rxq_sp = cnxk_eth_rxq_to_sp(rxq);
rxq->meta_aura = rxq_sp->qconf.mp->pool_id;
rxq->meta_pool = (uintptr_t)rxq_sp->qconf.mp;
}
}
/* Store mempool in lookup mem */
Expand Down Expand Up @@ -639,14 +641,17 @@ cn10k_nix_reassembly_conf_set(struct rte_eth_dev *eth_dev,

if (!conf->flags) {
/* Clear offload flags on disable */
dev->rx_offload_flags &= ~NIX_RX_REAS_F;
if (!dev->inb.nb_oop)
dev->rx_offload_flags &= ~NIX_RX_REAS_F;
dev->inb.reass_en = false;
return 0;
}

rc = roc_nix_reassembly_configure(conf->timeout_ms,
conf->max_frags);
if (!rc && dev->rx_offloads & RTE_ETH_RX_OFFLOAD_SECURITY)
rc = roc_nix_reassembly_configure(conf->timeout_ms, conf->max_frags);
if (!rc && dev->rx_offloads & RTE_ETH_RX_OFFLOAD_SECURITY) {
dev->rx_offload_flags |= NIX_RX_REAS_F;
dev->inb.reass_en = true;
}

return rc;
}
Expand Down
43 changes: 43 additions & 0 deletions drivers/net/cnxk/cn10k_ethdev_sec.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <rte_pmd_cnxk.h>

#include <cn10k_ethdev.h>
#include <cn10k_rx.h>
#include <cnxk_ethdev_mcs.h>
#include <cnxk_security.h>
#include <roc_priv.h>
Expand Down Expand Up @@ -324,6 +325,7 @@ static const struct rte_security_capability cn10k_eth_sec_ipsec_capabilities[] =
.l4_csum_enable = 1,
.stats = 1,
.esn = 1,
.ingress_oop = 1,
},
},
.crypto_capabilities = cn10k_eth_sec_crypto_caps,
Expand Down Expand Up @@ -373,6 +375,7 @@ static const struct rte_security_capability cn10k_eth_sec_ipsec_capabilities[] =
.l4_csum_enable = 1,
.stats = 1,
.esn = 1,
.ingress_oop = 1,
},
},
.crypto_capabilities = cn10k_eth_sec_crypto_caps,
Expand All @@ -396,6 +399,7 @@ static const struct rte_security_capability cn10k_eth_sec_ipsec_capabilities[] =
.l4_csum_enable = 1,
.stats = 1,
.esn = 1,
.ingress_oop = 1,
},
},
.crypto_capabilities = cn10k_eth_sec_crypto_caps,
Expand Down Expand Up @@ -746,6 +750,20 @@ cn10k_eth_sec_session_create(void *device,
return -rte_errno;
}

if (conf->ipsec.options.ingress_oop &&
rte_security_oop_dynfield_offset < 0) {
/* Register for security OOP dynfield if required */
if (rte_security_oop_dynfield_register() < 0)
return -rte_errno;
}

/* We cannot support inbound reassembly and OOP together */
if (conf->ipsec.options.ip_reassembly_en &&
conf->ipsec.options.ingress_oop) {
plt_err("Cannot support Inbound reassembly and OOP together");
return -ENOTSUP;
}

ipsec = &conf->ipsec;
crypto = conf->crypto_xform;
inbound = !!(ipsec->direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS);
Expand Down Expand Up @@ -832,6 +850,12 @@ cn10k_eth_sec_session_create(void *device,
inb_sa_dptr->w0.s.count_mib_bytes = 1;
inb_sa_dptr->w0.s.count_mib_pkts = 1;
}

/* Enable out-of-place processing */
if (ipsec->options.ingress_oop)
inb_sa_dptr->w0.s.pkt_format =
ROC_IE_OT_SA_PKT_FMT_FULL;

/* Prepare session priv */
sess_priv.inb_sa = 1;
sess_priv.sa_idx = ipsec->spi & spi_mask;
Expand All @@ -843,6 +867,7 @@ cn10k_eth_sec_session_create(void *device,
eth_sec->spi = ipsec->spi;
eth_sec->inl_dev = !!dev->inb.inl_dev;
eth_sec->inb = true;
eth_sec->inb_oop = !!ipsec->options.ingress_oop;

TAILQ_INSERT_TAIL(&dev->inb.list, eth_sec, entry);
dev->inb.nb_sess++;
Expand All @@ -858,6 +883,15 @@ cn10k_eth_sec_session_create(void *device,
inb_priv->reass_dynflag_bit = dev->reass_dynflag_bit;
}

if (ipsec->options.ingress_oop)
dev->inb.nb_oop++;

/* Update function pointer to handle OOP sessions */
if (dev->inb.nb_oop &&
!(dev->rx_offload_flags & NIX_RX_REAS_F)) {
dev->rx_offload_flags |= NIX_RX_REAS_F;
cn10k_eth_set_rx_function(eth_dev);
}
} else {
struct roc_ot_ipsec_outb_sa *outb_sa, *outb_sa_dptr;
struct cn10k_outb_priv_data *outb_priv;
Expand Down Expand Up @@ -1007,6 +1041,15 @@ cn10k_eth_sec_session_destroy(void *device, struct rte_security_session *sess)
sizeof(struct roc_ot_ipsec_inb_sa));
TAILQ_REMOVE(&dev->inb.list, eth_sec, entry);
dev->inb.nb_sess--;
if (eth_sec->inb_oop)
dev->inb.nb_oop--;

/* Clear offload flags if was used by OOP */
if (!dev->inb.nb_oop && !dev->inb.reass_en &&
dev->rx_offload_flags & NIX_RX_REAS_F) {
dev->rx_offload_flags &= ~NIX_RX_REAS_F;
cn10k_eth_set_rx_function(eth_dev);
}
} else {
/* Disable SA */
sa_dptr = dev->outb.sa_dptr;
Expand Down
Loading

0 comments on commit 373c48f

Please sign in to comment.