roc_nix_inl_dev_lock();
if (inbound) {
+ struct roc_ot_ipsec_inb_sa *inb_sa, *inb_sa_dptr;
struct cn10k_inb_priv_data *inb_priv;
- struct roc_ot_ipsec_inb_sa *inb_sa;
uintptr_t sa;
PLT_STATIC_ASSERT(sizeof(struct cn10k_inb_priv_data) <
goto mempool_put;
}
- memset(inb_sa, 0, sizeof(struct roc_ot_ipsec_inb_sa));
+ inb_sa_dptr = (struct roc_ot_ipsec_inb_sa *)dev->inb.sa_dptr;
+ memset(inb_sa_dptr, 0, sizeof(struct roc_ot_ipsec_inb_sa));
/* Fill inbound sa params */
- rc = cnxk_ot_ipsec_inb_sa_fill(inb_sa, ipsec, crypto);
+ rc = cnxk_ot_ipsec_inb_sa_fill(inb_sa_dptr, ipsec, crypto);
if (rc) {
plt_err("Failed to init inbound sa, rc=%d", rc);
goto mempool_put;
inb_priv->userdata = conf->userdata;
/* Save SA index/SPI in cookie for now */
- inb_sa->w1.s.cookie = rte_cpu_to_be_32(ipsec->spi);
+ inb_sa_dptr->w1.s.cookie = rte_cpu_to_be_32(ipsec->spi);
/* Prepare session priv */
sess_priv.inb_sa = 1;
TAILQ_INSERT_TAIL(&dev->inb.list, eth_sec, entry);
dev->inb.nb_sess++;
+ /* Sync session in context cache */
+ rc = roc_nix_inl_ctx_write(&dev->nix, inb_sa_dptr, eth_sec->sa,
+ eth_sec->inb,
+ sizeof(struct roc_ot_ipsec_inb_sa));
+ if (rc)
+ goto mempool_put;
} else {
+ struct roc_ot_ipsec_outb_sa *outb_sa, *outb_sa_dptr;
struct cn10k_outb_priv_data *outb_priv;
- struct roc_ot_ipsec_outb_sa *outb_sa;
struct cnxk_ipsec_outb_rlens *rlens;
uint64_t sa_base = dev->outb.sa_base;
uint32_t sa_idx;
outb_priv = roc_nix_inl_ot_ipsec_outb_sa_sw_rsvd(outb_sa);
rlens = &outb_priv->rlens;
- memset(outb_sa, 0, sizeof(struct roc_ot_ipsec_outb_sa));
+ outb_sa_dptr = (struct roc_ot_ipsec_outb_sa *)dev->outb.sa_dptr;
+ memset(outb_sa_dptr, 0, sizeof(struct roc_ot_ipsec_outb_sa));
/* Fill outbound sa params */
- rc = cnxk_ot_ipsec_outb_sa_fill(outb_sa, ipsec, crypto);
+ rc = cnxk_ot_ipsec_outb_sa_fill(outb_sa_dptr, ipsec, crypto);
if (rc) {
plt_err("Failed to init outbound sa, rc=%d", rc);
rc |= cnxk_eth_outb_sa_idx_put(dev, sa_idx);
sess_priv.roundup_byte = rlens->roundup_byte;
sess_priv.roundup_len = rlens->roundup_len;
sess_priv.partial_len = rlens->partial_len;
- sess_priv.mode = outb_sa->w2.s.ipsec_mode;
- sess_priv.outer_ip_ver = outb_sa->w2.s.outer_ip_ver;
+ sess_priv.mode = outb_sa_dptr->w2.s.ipsec_mode;
+ sess_priv.outer_ip_ver = outb_sa_dptr->w2.s.outer_ip_ver;
/* Pointer from eth_sec -> outb_sa */
eth_sec->sa = outb_sa;
TAILQ_INSERT_TAIL(&dev->outb.list, eth_sec, entry);
dev->outb.nb_sess++;
+ /* Sync session in context cache */
+ rc = roc_nix_inl_ctx_write(&dev->nix, outb_sa_dptr, eth_sec->sa,
+ eth_sec->inb,
+ sizeof(struct roc_ot_ipsec_outb_sa));
+ if (rc)
+ goto mempool_put;
}
-
- /* Sync session in context cache */
- roc_nix_inl_sa_sync(&dev->nix, eth_sec->sa, eth_sec->inb,
- ROC_NIX_INL_SA_OP_RELOAD);
-
if (inbound && inl_dev)
roc_nix_inl_dev_unlock();
{
struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)device;
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
- struct roc_ot_ipsec_inb_sa *inb_sa;
- struct roc_ot_ipsec_outb_sa *outb_sa;
struct cnxk_eth_sec_sess *eth_sec;
struct rte_mempool *mp;
+ void *sa_dptr;
eth_sec = cnxk_eth_sec_sess_get_by_sess(dev, sess);
if (!eth_sec)
roc_nix_inl_dev_lock();
if (eth_sec->inb) {
- inb_sa = eth_sec->sa;
/* Disable SA */
- inb_sa->w2.s.valid = 0;
+ sa_dptr = dev->inb.sa_dptr;
+ roc_nix_inl_inb_sa_init(sa_dptr);
+ roc_nix_inl_ctx_write(&dev->nix, sa_dptr, eth_sec->sa,
+ eth_sec->inb,
+ sizeof(struct roc_ot_ipsec_inb_sa));
TAILQ_REMOVE(&dev->inb.list, eth_sec, entry);
dev->inb.nb_sess--;
} else {
- outb_sa = eth_sec->sa;
/* Disable SA */
- outb_sa->w2.s.valid = 0;
+ sa_dptr = dev->outb.sa_dptr;
+ roc_nix_inl_outb_sa_init(sa_dptr);
+ roc_nix_inl_ctx_write(&dev->nix, sa_dptr, eth_sec->sa,
+ eth_sec->inb,
+ sizeof(struct roc_ot_ipsec_outb_sa));
/* Release Outbound SA index */
cnxk_eth_outb_sa_idx_put(dev, eth_sec->sa_idx);
TAILQ_REMOVE(&dev->outb.list, eth_sec, entry);
dev->outb.nb_sess--;
}
-
- /* Sync session in context cache */
- roc_nix_inl_sa_sync(&dev->nix, eth_sec->sa, eth_sec->inb,
- ROC_NIX_INL_SA_OP_RELOAD);
-
if (eth_sec->inl_dev)
roc_nix_inl_dev_unlock();
* Will be overridden when event mode rq's are setup.
*/
cnxk_nix_inb_mode_set(dev, true);
+
+ /* Allocate memory to be used as dptr for CPT ucode
+ * WRITE_SA op.
+ */
+ dev->inb.sa_dptr =
+ plt_zmalloc(ROC_NIX_INL_OT_IPSEC_INB_HW_SZ, 0);
+ if (!dev->inb.sa_dptr) {
+ plt_err("Couldn't allocate memory for SA dptr");
+ rc = -ENOMEM;
+ goto cleanup;
+ }
}
if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY ||
if (rc) {
plt_err("Failed to initialize nix inline outb, rc=%d",
rc);
- goto cleanup;
+ goto sa_dptr_free;
}
dev->outb.lf_base = roc_nix_inl_outb_lf_base_get(nix);
- /* Skip the rest if RTE_ETH_TX_OFFLOAD_SECURITY is not enabled */
+ /* Skip the rest if DEV_TX_OFFLOAD_SECURITY is not enabled */
if (!(dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY))
- goto done;
+ return 0;
+
+ /* Allocate memory to be used as dptr for CPT ucode
+ * WRITE_SA op.
+ */
+ dev->outb.sa_dptr =
+ plt_zmalloc(ROC_NIX_INL_OT_IPSEC_OUTB_HW_SZ, 0);
+ if (!dev->outb.sa_dptr) {
+ plt_err("Couldn't allocate memory for SA dptr");
+ rc = -ENOMEM;
+ goto sa_dptr_free;
+ }
rc = -ENOMEM;
/* Allocate a bitmap to alloc and free sa indexes */
plt_err("Outbound SA bmap alloc failed");
rc |= roc_nix_inl_outb_fini(nix);
- goto cleanup;
+ goto sa_dptr_free;
}
rc = -EIO;
rc |= roc_nix_inl_outb_fini(nix);
plt_free(mem);
- goto cleanup;
+ goto sa_dptr_free;
}
for (i = 0; i < dev->outb.max_sa; i++)
dev->outb.sa_bmap_mem = mem;
dev->outb.sa_bmap = bmap;
}
-
-done:
return 0;
+
+sa_dptr_free:
+ if (dev->inb.sa_dptr)
+ plt_free(dev->inb.sa_dptr);
+ if (dev->outb.sa_dptr)
+ plt_free(dev->outb.sa_dptr);
cleanup:
if (dev->rx_offloads & RTE_ETH_RX_OFFLOAD_SECURITY)
rc |= roc_nix_inl_inb_fini(nix);
if (rc)
plt_err("Failed to cleanup nix inline inb, rc=%d", rc);
ret |= rc;
+
+ if (dev->inb.sa_dptr) {
+ plt_free(dev->inb.sa_dptr);
+ dev->inb.sa_dptr = NULL;
+ }
}
/* Cleanup Inline outbound */
plt_free(dev->outb.sa_bmap_mem);
dev->outb.sa_bmap = NULL;
dev->outb.sa_bmap_mem = NULL;
+ if (dev->outb.sa_dptr) {
+ plt_free(dev->outb.sa_dptr);
+ dev->outb.sa_dptr = NULL;
+ }
}
dev->inb.inl_dev = false;