Skip to content

Commit

Permalink
dpdk: update version checking to DPDK-intended version checking API
Browse files Browse the repository at this point in the history
Ticket: OISF#5937
  • Loading branch information
Lukas Sismis authored and lukashino committed Apr 5, 2023
1 parent 87b8b26 commit 9b7c330
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/runmode-dpdk.c
Expand Up @@ -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)) {
Expand All @@ -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;
Expand All @@ -966,7 +966,7 @@ static int32_t DeviceSetSocketID(uint16_t port_id, int32_t *socket_id)
retval = rte_eth_dev_socket_id(port_id);
*socket_id = retval;

#if RTE_VER_YEAR > 22 || RTE_VER_YEAR == 22 && RTE_VER_MONTH == 11
#if RTE_VERSION >= RTE_VERSION_NUM(22, 11, 0, 0)
retval = -rte_errno;
#endif

Expand Down
28 changes: 14 additions & 14 deletions src/util-dpdk-i40e.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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 */
Expand Down
13 changes: 7 additions & 6 deletions src/util-dpdk-ice.c
Expand Up @@ -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 */
Expand Down
6 changes: 3 additions & 3 deletions src/util-dpdk.h
Expand Up @@ -34,13 +34,13 @@
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_flow.h>
#include <rte_version.h>

#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
Expand Down

0 comments on commit 9b7c330

Please sign in to comment.