From: Lukas Sismis Date: Thu, 23 Mar 2023 14:47:18 +0000 (+0100) Subject: dpdk: update version checking to DPDK-intended version checking API X-Git-Tag: suricata-7.0.0-rc2~173 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a331726eef2e8b4f5c708aaf592a6085eaeb8590;p=thirdparty%2Fsuricata.git dpdk: update version checking to DPDK-intended version checking API Ticket: #5937 --- diff --git a/src/runmode-dpdk.c b/src/runmode-dpdk.c index d421d759f9..72e3ed2a51 100644 --- a/src/runmode-dpdk.c +++ b/src/runmode-dpdk.c @@ -930,7 +930,7 @@ static int DeviceValidateMTU(const DPDKIfaceConfig *iconf, const struct rte_eth_ SCReturnInt(-ERANGE); } -#if RTE_VER_YEAR < 21 || RTE_VER_YEAR == 21 && RTE_VER_MONTH < 11 +#if RTE_VERSION < RTE_VERSION_NUM(21, 11, 0, 0) // check if jumbo frames are set and are available if (iconf->mtu > RTE_ETHER_MAX_LEN && !(dev_info->rx_offload_capa & DEV_RX_OFFLOAD_JUMBO_FRAME)) { @@ -944,7 +944,7 @@ static int DeviceValidateMTU(const DPDKIfaceConfig *iconf, const struct rte_eth_ static void DeviceSetMTU(struct rte_eth_conf *port_conf, uint16_t mtu) { -#if RTE_VER_YEAR > 21 || RTE_VER_YEAR == 21 && RTE_VER_MONTH == 11 +#if RTE_VERSION >= RTE_VERSION_NUM(21, 11, 0, 0) port_conf->rxmode.mtu = mtu; #else port_conf->rxmode.max_rx_pkt_len = mtu; @@ -965,7 +965,7 @@ static int32_t DeviceSetSocketID(uint16_t port_id, int32_t *socket_id) int retval = rte_eth_dev_socket_id(port_id); *socket_id = retval; -#if RTE_VER_YEAR > 22 || RTE_VER_YEAR == 22 && RTE_VER_MONTH == 11 // DPDK API changed since 22.11 +#if RTE_VERSION >= RTE_VERSION_NUM(22, 11, 0, 0) // DPDK API changed since 22.11 retval = -rte_errno; #endif diff --git a/src/util-dpdk-i40e.c b/src/util-dpdk-i40e.c index 38618ce7a3..4191b7750c 100644 --- a/src/util-dpdk-i40e.c +++ b/src/util-dpdk-i40e.c @@ -38,7 +38,7 @@ #define I40E_RSS_HKEY_LEN 52 -#if RTE_VER_YEAR <= 19 +#if RTE_VERSION < RTE_VERSION_NUM(20, 0, 0, 0) static int i40eDeviceEnableSymHash( int port_id, const char *port_name, uint32_t ftype, enum rte_eth_hash_function function) { @@ -349,7 +349,7 @@ static int i40eDeviceSetRSSWithFlows(int port_id, const char *port_name, int nb_ return 0; } -#endif /* RTE_VER_YEAR < 19 */ +#endif /* RTE_VERSION < RTE_VERSION_NUM(20,0,0,0) */ int i40eDeviceSetRSS(int port_id, int nb_rx_queues) { @@ -364,25 +364,25 @@ int i40eDeviceSetRSS(int port_id, int nb_rx_queues) return retval; } -#if RTE_VER_YEAR <= 19 - i40eDeviceSetRSSWithFilter(port_id, port_name); -#else +#if RTE_VERSION >= RTE_VERSION_NUM(20, 0, 0, 0) i40eDeviceSetRSSWithFlows(port_id, port_name, nb_rx_queues); +#else + i40eDeviceSetRSSWithFilter(port_id, port_name); #endif return 0; } void i40eDeviceSetRSSHashFunction(uint64_t *rss_hf) { - if (RTE_VER_YEAR <= 19) - *rss_hf = RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_TCP | - RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_NONFRAG_IPV4_SCTP | - RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_FRAG_IPV6 | - RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_NONFRAG_IPV6_UDP | - RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_SCTP; - else - *rss_hf = RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_FRAG_IPV6 | - RTE_ETH_RSS_NONFRAG_IPV6_OTHER; +#if RTE_VERSION >= RTE_VERSION_NUM(20, 0, 0, 0) + *rss_hf = RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_FRAG_IPV6 | + RTE_ETH_RSS_NONFRAG_IPV6_OTHER; +#else + *rss_hf = RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV4_UDP | + RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_NONFRAG_IPV4_OTHER | + RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_NONFRAG_IPV6_UDP | + RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_SCTP; +#endif } #endif /* HAVE_DPDK */ diff --git a/src/util-dpdk-ice.c b/src/util-dpdk-ice.c index 709358b2f1..36f4481dea 100644 --- a/src/util-dpdk-ice.c +++ b/src/util-dpdk-ice.c @@ -37,12 +37,13 @@ void iceDeviceSetRSSHashFunction(uint64_t *rss_hf) { - if (RTE_VER_YEAR <= 19) - *rss_hf = RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_FRAG_IPV6 | - RTE_ETH_RSS_NONFRAG_IPV6_OTHER; - else - *rss_hf = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_OTHER | - RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_NONFRAG_IPV6_OTHER; +#if RTE_VERSION < RTE_VERSION_NUM(20, 0, 0, 0) + *rss_hf = RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_FRAG_IPV6 | + RTE_ETH_RSS_NONFRAG_IPV6_OTHER; +#else + *rss_hf = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_OTHER | + RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_NONFRAG_IPV6_OTHER; +#endif } #endif /* HAVE_DPDK */ diff --git a/src/util-dpdk.h b/src/util-dpdk.h index 313501d931..f92f61b45d 100644 --- a/src/util-dpdk.h +++ b/src/util-dpdk.h @@ -34,13 +34,13 @@ #include #include #include +#include -#if RTE_VER_YEAR < 22 +#if RTE_VERSION < RTE_VERSION_NUM(22, 0, 0, 0) #define RTE_ETH_MQ_RX_RSS ETH_MQ_RX_RSS - #endif -#if RTE_VER_YEAR < 21 || RTE_VER_YEAR == 21 && RTE_VER_MONTH < 11 +#if RTE_VERSION < RTE_VERSION_NUM(21, 11, 0, 0) #define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE DEV_TX_OFFLOAD_MBUF_FAST_FREE #define RTE_ETH_RX_OFFLOAD_CHECKSUM DEV_RX_OFFLOAD_CHECKSUM