aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/l4fwd/dpdk_legacy.h104
-rw-r--r--examples/l4fwd/lcore.h92
-rw-r--r--examples/l4fwd/netbe.h4
-rw-r--r--examples/l4fwd/pkt.c28
-rw-r--r--examples/l4fwd/port.h12
5 files changed, 122 insertions, 118 deletions
diff --git a/examples/l4fwd/dpdk_legacy.h b/examples/l4fwd/dpdk_legacy.h
index 7bf856f..29886b1 100644
--- a/examples/l4fwd/dpdk_legacy.h
+++ b/examples/l4fwd/dpdk_legacy.h
@@ -19,109 +19,15 @@
#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
-
-/*
- * IPv6 destination lookup callback.
- */
-static int
-lpm6_dst_lookup(void *data, const struct in6_addr *addr,
- struct tle_dest *res)
-{
- int32_t rc;
-#ifdef DPDK_VERSION_GE_1705
- uint32_t idx;
+typedef uint32_t dpdk_lpm6_idx_t;
#else
- uint8_t idx;
+typedef uint8_t dpdk_lpm6_idx_t;
#endif
- 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
-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_1705
- uint32_t idx;
+#if RTE_VERSION_NUM(17, 11, 0, 0) <= RTE_VERSION
+typedef uint16_t dpdk_port_t;
#else
- uint8_t idx;
+typedef uint8_t dpdk_port_t;
#endif
- 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;
-}
#endif /* DPDK_LEGACY_H_ */
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;
diff --git a/examples/l4fwd/netbe.h b/examples/l4fwd/netbe.h
index ebb1345..6d9aa35 100644
--- a/examples/l4fwd/netbe.h
+++ b/examples/l4fwd/netbe.h
@@ -71,8 +71,8 @@ struct netbe_port {
uint32_t nb_lcore;
uint32_t *lcore_id;
uint32_t mtu;
- uint32_t rx_offload;
- uint32_t tx_offload;
+ uint64_t rx_offload;
+ uint64_t tx_offload;
uint32_t ipv4;
struct in6_addr ipv6;
struct ether_addr mac;
diff --git a/examples/l4fwd/pkt.c b/examples/l4fwd/pkt.c
index b9d53ce..6dfad0e 100644
--- a/examples/l4fwd/pkt.c
+++ b/examples/l4fwd/pkt.c
@@ -17,6 +17,7 @@
#include <rte_arp.h>
#include "netbe.h"
+#include "dpdk_legacy.h"
struct ptype2cb {
uint32_t mask;
@@ -230,7 +231,7 @@ fill_ipv6_hdr_len(struct rte_mbuf *m, uint32_t l2, uint32_t fproto,
}
static inline struct rte_mbuf *
-handle_arp(struct rte_mbuf *m, struct netbe_lcore *lc, uint8_t port,
+handle_arp(struct rte_mbuf *m, struct netbe_lcore *lc, dpdk_port_t port,
uint32_t l2len)
{
const struct arp_hdr *ahdr;
@@ -258,7 +259,7 @@ handle_arp(struct rte_mbuf *m, struct netbe_lcore *lc, uint8_t port,
static inline struct rte_mbuf *
fill_eth_tcp_arp_hdr_len(struct rte_mbuf *m, struct netbe_lcore *lc,
- uint8_t port)
+ dpdk_port_t port)
{
uint32_t dlen, l2_len, l3_len, l4_len;
uint16_t etp;
@@ -431,7 +432,7 @@ fix_reassembled(struct rte_mbuf *m, int32_t hwcsum, uint32_t proto)
static struct rte_mbuf *
reassemble(struct rte_mbuf *m, struct netbe_lcore *lc, uint64_t tms,
- uint8_t port, uint32_t proto)
+ dpdk_port_t port, uint32_t proto)
{
uint32_t l3cs;
struct rte_ip_frag_tbl *tbl;
@@ -526,7 +527,8 @@ do { \
* HW can recognize L2/L3 with/without extensions/L4 (ixgbe/igb/fm10k)
*/
static uint16_t
-type0_tcp_rx_callback(__rte_unused uint8_t port, __rte_unused uint16_t queue,
+type0_tcp_rx_callback(__rte_unused dpdk_port_t port,
+ __rte_unused uint16_t queue,
struct rte_mbuf *pkt[], uint16_t nb_pkts,
__rte_unused uint16_t max_pkts, void *user_param)
{
@@ -594,7 +596,7 @@ type0_tcp_rx_callback(__rte_unused uint8_t port, __rte_unused uint16_t queue,
* HW can recognize L2/L3 with/without extensions/L4 (ixgbe/igb/fm10k)
*/
static uint16_t
-type0_udp_rx_callback(uint8_t port, __rte_unused uint16_t queue,
+type0_udp_rx_callback(dpdk_port_t port, __rte_unused uint16_t queue,
struct rte_mbuf *pkt[], uint16_t nb_pkts,
__rte_unused uint16_t max_pkts, void *user_param)
{
@@ -680,7 +682,8 @@ type0_udp_rx_callback(uint8_t port, __rte_unused uint16_t queue,
* HW can recognize L2/L3/L4 and fragments (i40e).
*/
static uint16_t
-type1_tcp_rx_callback(__rte_unused uint8_t port, __rte_unused uint16_t queue,
+type1_tcp_rx_callback(__rte_unused dpdk_port_t port,
+ __rte_unused uint16_t queue,
struct rte_mbuf *pkt[], uint16_t nb_pkts,
__rte_unused uint16_t max_pkts, void *user_param)
{
@@ -734,7 +737,7 @@ type1_tcp_rx_callback(__rte_unused uint8_t port, __rte_unused uint16_t queue,
* HW can recognize L2/L3/L4 and fragments (i40e).
*/
static uint16_t
-type1_udp_rx_callback(uint8_t port, __rte_unused uint16_t queue,
+type1_udp_rx_callback(dpdk_port_t port, __rte_unused uint16_t queue,
struct rte_mbuf *pkt[], uint16_t nb_pkts,
__rte_unused uint16_t max_pkts, void *user_param)
{
@@ -804,8 +807,9 @@ type1_udp_rx_callback(uint8_t port, __rte_unused uint16_t queue,
* generic, assumes HW doesn't recognize any packet type.
*/
static uint16_t
-typen_tcp_arp_rx_callback(uint8_t port, uint16_t queue, struct rte_mbuf *pkt[],
- uint16_t nb_pkts, uint16_t max_pkts, void *user_param)
+typen_tcp_arp_rx_callback(dpdk_port_t port, uint16_t queue,
+ struct rte_mbuf *pkt[], uint16_t nb_pkts, uint16_t max_pkts,
+ void *user_param)
{
uint32_t j, x;
struct netbe_lcore *lc;
@@ -830,8 +834,8 @@ typen_tcp_arp_rx_callback(uint8_t port, uint16_t queue, struct rte_mbuf *pkt[],
}
static uint16_t
-typen_tcp_rx_callback(__rte_unused uint8_t port, __rte_unused uint16_t queue,
- struct rte_mbuf *pkt[], uint16_t nb_pkts,
+typen_tcp_rx_callback(__rte_unused dpdk_port_t port,
+ __rte_unused uint16_t queue, struct rte_mbuf *pkt[], uint16_t nb_pkts,
__rte_unused uint16_t max_pkts, void *user_param)
{
uint32_t j;
@@ -851,7 +855,7 @@ typen_tcp_rx_callback(__rte_unused uint8_t port, __rte_unused uint16_t queue,
}
static uint16_t
-typen_udp_rx_callback(uint8_t port, __rte_unused uint16_t queue,
+typen_udp_rx_callback(dpdk_port_t port, __rte_unused uint16_t queue,
struct rte_mbuf *pkt[], uint16_t nb_pkts,
__rte_unused uint16_t max_pkts, void *user_param)
{
diff --git a/examples/l4fwd/port.h b/examples/l4fwd/port.h
index 04f3ec2..a451f7b 100644
--- a/examples/l4fwd/port.h
+++ b/examples/l4fwd/port.h
@@ -162,15 +162,17 @@ port_init(struct netbe_port *uprt, uint32_t proto)
if ((dev_info.rx_offload_capa & uprt->rx_offload) != uprt->rx_offload) {
RTE_LOG(ERR, USER1,
"port#%u supported/requested RX offloads don't match, "
- "supported: %#x, requested: %#x;\n",
- uprt->id, dev_info.rx_offload_capa, uprt->rx_offload);
+ "supported: %#" PRIx64 ", requested: %#" PRIx64 ";\n",
+ uprt->id, (uint64_t)dev_info.rx_offload_capa,
+ (uint64_t)uprt->rx_offload);
return -EINVAL;
}
if ((dev_info.tx_offload_capa & uprt->tx_offload) != uprt->tx_offload) {
RTE_LOG(ERR, USER1,
"port#%u supported/requested TX offloads don't match, "
- "supported: %#x, requested: %#x;\n",
- uprt->id, dev_info.tx_offload_capa, uprt->tx_offload);
+ "supported: %#" PRIx64 ", requested: %#" PRIx64 ";\n",
+ uprt->id, (uint64_t)dev_info.tx_offload_capa,
+ (uint64_t)uprt->tx_offload);
return -EINVAL;
}
@@ -282,7 +284,7 @@ log_netbe_prt(const struct netbe_port *uprt)
RTE_LOG(NOTICE, USER1,
"uprt %p = <id = %u, lcore = <%s>, mtu = %u, "
- "rx_offload = %u, tx_offload = %u,\n"
+ "rx_offload = %#" PRIx64 ", tx_offload = %#" PRIx64 ",\n"
"ipv4 = %#x, "
"ipv6 = %04hx:%04hx:%04hx:%04hx:%04hx:%04hx:%04hx:%04hx, "
"mac = %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx>;\n"