diff options
author | Matias Elo <matias.elo@nokia.com> | 2022-05-03 16:29:04 +0300 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2022-05-25 10:58:00 +0300 |
commit | 3360d226c2c6382caafb4024f7836bc3e72f997d (patch) | |
tree | c67fb6567ce8f4ece7f792cbeb6b75e7a7cefe9d /platform | |
parent | ac48a2a2110e668d23b8f5477a0529f7c27ccddb (diff) |
Port d7b705a71 "linux-gen: dpdk: add support for DPDK 21.11"
Port original commit from linux-generic.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Diffstat (limited to 'platform')
-rw-r--r-- | platform/linux-dpdk/odp_packet.c | 8 | ||||
-rw-r--r-- | platform/linux-dpdk/odp_packet_dpdk.c | 33 |
2 files changed, 31 insertions, 10 deletions
diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c index 24e3ab69a..b28f45b0e 100644 --- a/platform/linux-dpdk/odp_packet.c +++ b/platform/linux-dpdk/odp_packet.c @@ -30,6 +30,8 @@ #include <odp_packet_io_internal.h> #include <odp_parse_internal.h> +#include <rte_version.h> + #include <protocols/eth.h> #include <protocols/ip.h> #include <protocols/sctp.h> @@ -41,6 +43,10 @@ #include <stddef.h> #include <inttypes.h> +#if RTE_VERSION < RTE_VERSION_NUM(21, 11, 0, 0) + #define RTE_MBUF_F_RX_RSS_HASH PKT_RX_RSS_HASH +#endif + #include <odp/visibility_begin.h> /* Fill in packet header field offsets for inline functions */ @@ -65,7 +71,7 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = { .user_area = offsetof(odp_packet_hdr_t, uarea_addr), .rss = offsetof(odp_packet_hdr_t, event_hdr.mb.hash.rss), .ol_flags = offsetof(odp_packet_hdr_t, event_hdr.mb.ol_flags), - .rss_flag = PKT_RX_RSS_HASH + .rss_flag = RTE_MBUF_F_RX_RSS_HASH }; #include <odp/visibility_end.h> diff --git a/platform/linux-dpdk/odp_packet_dpdk.c b/platform/linux-dpdk/odp_packet_dpdk.c index 4ffe11092..45d8e65bc 100644 --- a/platform/linux-dpdk/odp_packet_dpdk.c +++ b/platform/linux-dpdk/odp_packet_dpdk.c @@ -50,6 +50,15 @@ #include <rte_ip_frag.h> #include <rte_udp.h> #include <rte_tcp.h> +#include <rte_version.h> + +#if RTE_VERSION < RTE_VERSION_NUM(21, 11, 0, 0) + #define RTE_MBUF_F_TX_IPV4 PKT_TX_IPV4 + #define RTE_MBUF_F_TX_IPV6 PKT_TX_IPV6 + #define RTE_MBUF_F_TX_IP_CKSUM PKT_TX_IP_CKSUM + #define RTE_MBUF_F_TX_UDP_CKSUM PKT_TX_UDP_CKSUM + #define RTE_MBUF_F_TX_TCP_CKSUM PKT_TX_TCP_CKSUM +#endif /* DPDK poll mode drivers requiring minimum RX burst size DPDK_MIN_RX_BURST */ #define IXGBE_DRV_NAME "net_ixgbe" @@ -293,7 +302,11 @@ static int dpdk_setup_eth_dev(pktio_entry_t *pktio_entry) /* RX packet len same size as pool segment minus headroom and double * VLAN tag */ +#if RTE_VERSION < RTE_VERSION_NUM(21, 11, 0, 0) eth_conf.rxmode.max_rx_pkt_len = +#else + eth_conf.rxmode.mtu = +#endif rte_pktmbuf_data_room_size(pool->rte_mempool) - 2 * 4 - RTE_PKTMBUF_HEADROOM; @@ -508,16 +521,18 @@ static int dpdk_init_capability(pktio_entry_t *pktio_entry, /* Check if setting MTU is supported */ ret = rte_eth_dev_set_mtu(pkt_dpdk->port_id, pkt_dpdk->mtu - _ODP_ETHHDR_LEN); - if (ret == 0) { + /* From DPDK 21.11 onwards, calling rte_eth_dev_set_mtu() before device is configured with + * rte_eth_dev_configure() will result in failure. The least hacky (unfortunately still + * very hacky) way to continue checking the support is to take into account that the + * function will fail earlier with -ENOTSUP if MTU setting is not supported by device than + * if the device was not yet configured. */ + if (ret != -ENOTSUP) { capa->set_op.op.maxlen = 1; capa->maxlen.equal = true; capa->maxlen.min_input = DPDK_MTU_MIN; capa->maxlen.max_input = pkt_dpdk->mtu_max; capa->maxlen.min_output = DPDK_MTU_MIN; capa->maxlen.max_output = pkt_dpdk->mtu_max; - } else if (ret != -ENOTSUP) { - ODP_ERR("Failed to set interface MTU: %d\n", ret); - return -1; } ptype_cnt = rte_eth_dev_get_supported_ptypes(pkt_dpdk->port_id, @@ -1128,12 +1143,12 @@ static inline void pkt_set_ol_tx(odp_pktout_config_opt_t *pktout_cfg, mbuf->l2_len = pkt_p->l3_offset - pkt_p->l2_offset; if (l3_proto_v4) - mbuf->ol_flags = PKT_TX_IPV4; + mbuf->ol_flags = RTE_MBUF_F_TX_IPV4; else - mbuf->ol_flags = PKT_TX_IPV6; + mbuf->ol_flags = RTE_MBUF_F_TX_IPV6; if (ipv4_chksum_pkt) { - mbuf->ol_flags |= PKT_TX_IP_CKSUM; + mbuf->ol_flags |= RTE_MBUF_F_TX_IP_CKSUM; ((struct rte_ipv4_hdr *)l3_hdr)->hdr_checksum = 0; mbuf->l3_len = _ODP_IPV4HDR_IHL(*(uint8_t *)l3_hdr) * 4; @@ -1147,12 +1162,12 @@ static inline void pkt_set_ol_tx(odp_pktout_config_opt_t *pktout_cfg, l4_hdr = (void *)(mbuf_data + pkt_p->l4_offset); if (udp_chksum_pkt) { - mbuf->ol_flags |= PKT_TX_UDP_CKSUM; + mbuf->ol_flags |= RTE_MBUF_F_TX_UDP_CKSUM; ((struct rte_udp_hdr *)l4_hdr)->dgram_cksum = phdr_csum(l3_proto_v4, l3_hdr, mbuf->ol_flags); } else if (tcp_chksum_pkt) { - mbuf->ol_flags |= PKT_TX_TCP_CKSUM; + mbuf->ol_flags |= RTE_MBUF_F_TX_TCP_CKSUM; ((struct rte_tcp_hdr *)l4_hdr)->cksum = phdr_csum(l3_proto_v4, l3_hdr, mbuf->ol_flags); |