MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ipsec_satbl_init

Function ipsec_satbl_init

dpdk/examples/ipsec-secgw/sa.c:1611–1656  ·  view source on GitHub ↗

* Allocate space and init rte_ipsec_sa structures, * one per session. */

Source from the content-addressed store, hash-verified

1609 * one per session.
1610 */
1611static int
1612ipsec_satbl_init(struct sa_ctx *ctx, uint32_t nb_ent, int32_t socket,
1613 struct socket_ctx *skt_ctx, struct ipsec_ctx *ips_ctx[],
1614 const struct eventmode_conf *em_conf)
1615{
1616 int32_t rc, sz;
1617 uint32_t i, idx;
1618 size_t tsz;
1619 struct rte_ipsec_sa *sa;
1620 struct ipsec_sa *lsa;
1621 struct rte_ipsec_sa_prm prm;
1622
1623 /* determine SA size */
1624 idx = 0;
1625 fill_ipsec_sa_prm(&prm, ctx->sa + idx, NULL, NULL);
1626 sz = rte_ipsec_sa_size(&prm);
1627 if (sz < 0) {
1628 RTE_LOG(ERR, IPSEC, "%s(%p, %u, %d): "
1629 "failed to determine SA size, error code: %d\n",
1630 __func__, ctx, nb_ent, socket, sz);
1631 return sz;
1632 }
1633
1634 tsz = sz * nb_ent;
1635
1636 ctx->satbl = rte_zmalloc_socket(NULL, tsz, RTE_CACHE_LINE_SIZE, socket);
1637 if (ctx->satbl == NULL) {
1638 RTE_LOG(ERR, IPSEC,
1639 "%s(%p, %u, %d): failed to allocate %zu bytes\n",
1640 __func__, ctx, nb_ent, socket, tsz);
1641 return -ENOMEM;
1642 }
1643
1644 rc = 0;
1645 for (i = 0; i != nb_ent && rc == 0; i++) {
1646
1647 idx = i;
1648
1649 sa = (struct rte_ipsec_sa *)((uintptr_t)ctx->satbl + sz * i);
1650 lsa = ctx->sa + idx;
1651
1652 rc = ipsec_sa_init(lsa, sa, sz, skt_ctx, ips_ctx, em_conf);
1653 }
1654
1655 return rc;
1656}
1657
1658static int
1659sa_cmp(const void *p, const void *q)

Callers 1

sa_initFunction · 0.85

Calls 4

fill_ipsec_sa_prmFunction · 0.85
rte_ipsec_sa_sizeFunction · 0.85
rte_zmalloc_socketFunction · 0.85
ipsec_sa_initFunction · 0.85

Tested by

no test coverage detected