diff options
author | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2018-02-06 22:17:36 +0000 |
---|---|---|
committer | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2018-02-07 17:43:40 +0000 |
commit | 5c795f7bd17608d441d4e2c7f862ad9d45685b93 (patch) | |
tree | 96947264d77354b9cb880f86333d961d414ce689 /examples/l4fwd/lcore.h | |
parent | 3726dc50dd2a9873ac05847be80ca615ea4a708b (diff) |
tldk: make sure it builds/works with latest dpdk (17.11/18.02)
Change-Id: I460b88661656b64558b442c7800b4edc20ad4b56
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Diffstat (limited to 'examples/l4fwd/lcore.h')
-rw-r--r-- | examples/l4fwd/lcore.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/examples/l4fwd/lcore.h b/examples/l4fwd/lcore.h index 9deddcc..ac2fbbd 100644 --- a/examples/l4fwd/lcore.h +++ b/examples/l4fwd/lcore.h @@ -43,6 +43,31 @@ lpm4_dst_lookup(void *data, const struct in_addr *addr, return rc; } +/* + * IPv6 destination lookup callback. + */ +static int +lpm6_dst_lookup(void *data, const struct in6_addr *addr, + struct tle_dest *res) +{ + int32_t rc; + dpdk_lpm6_idx_t idx; + struct netbe_lcore *lc; + struct tle_dest *dst; + uintptr_t p; + + lc = data; + p = (uintptr_t)addr->s6_addr; + + rc = rte_lpm6_lookup(lc->lpm6, (uint8_t *)p, &idx); + if (rc == 0) { + dst = &lc->dst6[idx]; + rte_memcpy(res, dst, dst->l2_len + dst->l3_len + + offsetof(struct tle_dest, hdr)); + } + return rc; +} + static int lcore_lpm_init(struct netbe_lcore *lc) { @@ -146,6 +171,73 @@ netbe_find4(const struct in_addr *laddr, const uint16_t lport, } static int +netbe_find6(const struct in6_addr *laddr, uint16_t lport, + const struct in6_addr *raddr, uint32_t belc) +{ + uint32_t i, j; + dpdk_lpm6_idx_t idx; + struct netbe_lcore *bc; + + /* we have exactly one BE, use it for all traffic */ + if (becfg.cpu_num == 1) + return 0; + + /* search by provided be_lcore */ + if (belc != LCORE_ID_ANY) { + for (i = 0; i != becfg.cpu_num; i++) { + bc = becfg.cpu + i; + if (belc == bc->id) + return i; + } + RTE_LOG(NOTICE, USER1, "%s: no stream with belcore=%u\n", + __func__, belc); + return -ENOENT; + } + + /* search by local address */ + if (memcmp(laddr, &in6addr_any, sizeof(*laddr)) != 0) { + for (i = 0; i != becfg.cpu_num; i++) { + bc = becfg.cpu + i; + /* search by queue for the local port */ + for (j = 0; j != bc->prtq_num; j++) { + if (memcmp(laddr, &bc->prtq[j].port.ipv6, + sizeof(*laddr)) == 0) { + + if (lport == 0) + return i; + + if (verify_queue_for_port(bc->prtq + j, + lport) != 0) + return i; + } + } + } + } + + /* search by remote address */ + if (memcmp(raddr, &in6addr_any, sizeof(*raddr)) == 0) { + for (i = 0; i != becfg.cpu_num; i++) { + bc = becfg.cpu + i; + if (rte_lpm6_lookup(bc->lpm6, + (uint8_t *)(uintptr_t)raddr->s6_addr, + &idx) == 0) { + + if (lport == 0) + return i; + + /* search by queue for the local port */ + for (j = 0; j != bc->prtq_num; j++) + if (verify_queue_for_port(bc->prtq + j, + lport) != 0) + return i; + } + } + } + + return -ENOENT; +} + +static int create_context(struct netbe_lcore *lc, const struct tle_ctx_param *ctx_prm) { uint32_t rc = 0, sid; |