Skip to content

Commit

Permalink
net/cnxk: support Rx inject
Browse files Browse the repository at this point in the history
Add Rx inject security callback APIs to configure, inject
packet to CPT and receive back as in receive path.
Devargs "rx_inj_ena=1" will be required to enable the
inline IPsec Rx inject feature. If inline device is used
then this devarg will be required for both inline device
and eth device.

Signed-off-by: Rahul Bhansali <[email protected]>
  • Loading branch information
rbhansali authored and jerinjacobk committed Mar 4, 2024
1 parent 4b8eb5b commit 47cca25
Show file tree
Hide file tree
Showing 11 changed files with 405 additions and 69 deletions.
26 changes: 26 additions & 0 deletions doc/guides/nics/cnxk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,19 @@ Runtime Config Options
With the above configuration, PMD would allocate meta buffers of size 512 for
inline inbound IPsec processing second pass.

- ``Rx Inject Enable inbound inline IPsec for second pass`` (default ``0``)

Rx packet inject feature for inbound inline IPsec processing can be enabled
by ``rx_inj_ena`` devargs parameter.
This option is for OCTEON CN106-B0/CN103XX SoC family.

For example::

-a 0002:02:00.0,rx_inj_ena=1

With the above configuration, driver would enable packet inject from ARM cores
to crypto to process and send back in Rx path.

.. note::

Above devarg parameters are configurable per device, user needs to pass the
Expand Down Expand Up @@ -613,6 +626,19 @@ Runtime Config Options for inline device
With the above configuration, driver would poll for aging flows every 50
seconds.

- ``Rx Inject Enable inbound inline IPsec for second pass`` (default ``0``)

Rx packet inject feature for inbound inline IPsec processing can be enabled
by ``rx_inj_ena`` devargs parameter with both inline device and ethdev device.
This option is for OCTEON CN106-B0/CN103XX SoC family.

For example::

-a 0002:1d:00.0,rx_inj_ena=1

With the above configuration, driver would enable packet inject from ARM cores
to crypto to process and send back in Rx path.

Debugging Options
-----------------

Expand Down
1 change: 1 addition & 0 deletions doc/guides/rel_notes/release_24_03.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ New Features

* Added support for ``RTE_FLOW_ITEM_TYPE_PPPOES`` flow item.
* Added support for ``RTE_FLOW_ACTION_TYPE_SAMPLE`` flow item.
* Added support for Rx inject.

* **Updated Marvell OCTEON EP driver.**

Expand Down
4 changes: 4 additions & 0 deletions drivers/net/cnxk/cn10k_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,10 @@ cn10k_nix_dev_start(struct rte_eth_dev *eth_dev)
if (dev->rx_offload_flags & NIX_RX_OFFLOAD_SECURITY_F)
cn10k_nix_rx_queue_meta_aura_update(eth_dev);

/* Set flags for Rx Inject feature */
if (roc_idev_nix_rx_inject_get(nix->port_id))
dev->rx_offload_flags |= NIX_RX_SEC_REASSEMBLY_F;

cn10k_eth_set_tx_function(eth_dev);
cn10k_eth_set_rx_function(eth_dev);
return 0;
Expand Down
48 changes: 48 additions & 0 deletions drivers/net/cnxk/cn10k_ethdev_sec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,52 @@ eth_sec_caps_add(struct rte_security_capability eth_sec_caps[], uint32_t *idx,
*idx += nb_caps;
}

static uint16_t __rte_hot
cn10k_eth_sec_inb_rx_inject(void *device, struct rte_mbuf **pkts,
struct rte_security_session **sess, uint16_t nb_pkts)
{
struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)device;
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);

return cn10k_nix_inj_pkts(sess, &dev->inj_cfg, pkts, nb_pkts);
}

static int
cn10k_eth_sec_rx_inject_config(void *device, uint16_t port_id, bool enable)
{
struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)device;
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
uint64_t channel, pf_func, inj_match_id = 0xFFFFUL;
struct cnxk_ethdev_inj_cfg *inj_cfg;
struct roc_nix *nix = &dev->nix;
struct roc_cpt_lf *inl_lf;
uint64_t sa_base;

if (!rte_eth_dev_is_valid_port(port_id))
return -EINVAL;

if (eth_dev->data->dev_started || !eth_dev->data->dev_configured)
return -EBUSY;

if (!roc_nix_inl_inb_rx_inject_enable(nix, dev->inb.inl_dev))
return -ENOTSUP;

roc_idev_nix_rx_inject_set(port_id, enable);

inl_lf = roc_nix_inl_inb_inj_lf_get(nix);
sa_base = roc_nix_inl_inb_sa_base_get(nix, dev->inb.inl_dev);

inj_cfg = &dev->inj_cfg;
inj_cfg->sa_base = sa_base | eth_dev->data->port_id;
inj_cfg->io_addr = inl_lf->io_addr;
inj_cfg->lmt_base = nix->lmt_base;
channel = roc_nix_get_base_chan(nix);
pf_func = roc_nix_inl_dev_pffunc_get();
inj_cfg->cmd_w0 = pf_func << 48 | inj_match_id << 32 | channel << 4;

return 0;
}

void
cn10k_eth_sec_ops_override(void)
{
Expand Down Expand Up @@ -1287,4 +1333,6 @@ cn10k_eth_sec_ops_override(void)
cnxk_eth_sec_ops.session_stats_get = cn10k_eth_sec_session_stats_get;
cnxk_eth_sec_ops.macsec_sc_stats_get = cnxk_eth_macsec_sc_stats_get;
cnxk_eth_sec_ops.macsec_sa_stats_get = cnxk_eth_macsec_sa_stats_get;
cnxk_eth_sec_ops.rx_inject_configure = cn10k_eth_sec_rx_inject_config;
cnxk_eth_sec_ops.inb_pkt_rx_inject = cn10k_eth_sec_inb_rx_inject;
}
Loading

0 comments on commit 47cca25

Please sign in to comment.