diff options
Diffstat (limited to 'examples/l4fwd/dpdk_legacy.h')
-rw-r--r-- | examples/l4fwd/dpdk_legacy.h | 87 |
1 files changed, 27 insertions, 60 deletions
diff --git a/examples/l4fwd/dpdk_legacy.h b/examples/l4fwd/dpdk_legacy.h index 84fab17..7bf856f 100644 --- a/examples/l4fwd/dpdk_legacy.h +++ b/examples/l4fwd/dpdk_legacy.h @@ -13,32 +13,40 @@ * limitations under the License. */ -#ifndef MAIN_DPDK_LEGACY_H_ -#define MAIN_DPDK_LEGACY_H_ +#ifndef DPDK_LEGACY_H_ +#define DPDK_LEGACY_H_ -#include "dpdk_version.h" +#include <rte_version.h> + +#if RTE_VERSION_NUM(17, 5, 0, 0) <= RTE_VERSION +#ifndef DPDK_VERSION_GE_1705 +#define DPDK_VERSION_GE_1705 +#endif +#endif /* - * UDP IPv4 destination lookup callback. + * IPv6 destination lookup callback. */ static int -lpm4_dst_lookup(void *data, const struct in_addr *addr, +lpm6_dst_lookup(void *data, const struct in6_addr *addr, struct tle_dest *res) { int32_t rc; -#ifdef DPDK_VERSION_GE_1604 +#ifdef DPDK_VERSION_GE_1705 uint32_t idx; #else uint8_t idx; #endif struct netbe_lcore *lc; struct tle_dest *dst; + uintptr_t p; lc = data; + p = (uintptr_t)addr->s6_addr; - rc = rte_lpm_lookup(lc->lpm4, rte_be_to_cpu_32(addr->s_addr), &idx); + rc = rte_lpm6_lookup(lc->lpm6, (uint8_t *)p, &idx); if (rc == 0) { - dst = &lc->dst4[idx]; + dst = &lc->dst6[idx]; rte_memcpy(res, dst, dst->l2_len + dst->l3_len + offsetof(struct tle_dest, hdr)); } @@ -46,53 +54,11 @@ lpm4_dst_lookup(void *data, const struct in_addr *addr, } static int -lcore_lpm_init(struct netbe_lcore *lc) -{ - int32_t sid; - char str[RTE_LPM_NAMESIZE]; -#ifdef DPDK_VERSION_GE_1604 - const struct rte_lpm_config lpm4_cfg = { - .max_rules = MAX_RULES, - .number_tbl8s = MAX_TBL8, - }; -#endif - const struct rte_lpm6_config lpm6_cfg = { - .max_rules = MAX_RULES, - .number_tbl8s = MAX_TBL8, - }; - - sid = rte_lcore_to_socket_id(lc->id); - - snprintf(str, sizeof(str), "LPM4%u\n", lc->id); -#ifdef DPDK_VERSION_GE_1604 - lc->lpm4 = rte_lpm_create(str, sid, &lpm4_cfg); -#else - lc->lpm4 = rte_lpm_create(str, sid, MAX_RULES, 0); -#endif - RTE_LOG(NOTICE, USER1, "%s(lcore=%u): lpm4=%p;\n", - __func__, lc->id, lc->lpm4); - if (lc->lpm4 == NULL) - return -ENOMEM; - - snprintf(str, sizeof(str), "LPM6%u\n", lc->id); - lc->lpm6 = rte_lpm6_create(str, sid, &lpm6_cfg); - RTE_LOG(NOTICE, USER1, "%s(lcore=%u): lpm6=%p;\n", - __func__, lc->id, lc->lpm6); - if (lc->lpm6 == NULL) - return -ENOMEM; - - return 0; -} - -/* - * Helper functions, finds BE by given local and remote addresses. - */ -static int -netbe_find4(const struct in_addr *laddr, const uint16_t lport, - const struct in_addr *raddr, const uint32_t belc) +netbe_find6(const struct in6_addr *laddr, uint16_t lport, + const struct in6_addr *raddr, uint32_t belc) { uint32_t i, j; -#ifdef DPDK_VERSION_GE_1604 +#ifdef DPDK_VERSION_GE_1705 uint32_t idx; #else uint8_t idx; @@ -110,18 +76,19 @@ netbe_find4(const struct in_addr *laddr, const uint16_t lport, if (belc == bc->id) return i; } - RTE_LOG(NOTICE, USER1, "%s: no stream with be_lcore=%u\n", + RTE_LOG(NOTICE, USER1, "%s: no stream with belcore=%u\n", __func__, belc); return -ENOENT; } /* search by local address */ - if (laddr->s_addr != INADDR_ANY) { + 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 (laddr->s_addr == bc->prtq[j].port.ipv4) { + if (memcmp(laddr, &bc->prtq[j].port.ipv6, + sizeof(*laddr)) == 0) { if (lport == 0) return i; @@ -135,11 +102,11 @@ netbe_find4(const struct in_addr *laddr, const uint16_t lport, } /* search by remote address */ - if (raddr->s_addr != INADDR_ANY) { + if (memcmp(raddr, &in6addr_any, sizeof(*raddr)) == 0) { for (i = 0; i != becfg.cpu_num; i++) { bc = becfg.cpu + i; - if (rte_lpm_lookup(bc->lpm4, - rte_be_to_cpu_32(raddr->s_addr), + if (rte_lpm6_lookup(bc->lpm6, + (uint8_t *)(uintptr_t)raddr->s6_addr, &idx) == 0) { if (lport == 0) @@ -157,4 +124,4 @@ netbe_find4(const struct in_addr *laddr, const uint16_t lport, return -ENOENT; } -#endif /* MAIN_DPDK_LEGACY_H_ */ +#endif /* DPDK_LEGACY_H_ */ |