1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright 2015 6WIND S.A.
3 # Copyright 2015 Mellanox Technologies, Ltd
5 include $(RTE_SDK)/mk/rte.vars.mk
8 LIB = librte_pmd_mlx5.a
9 LIB_GLUE = $(LIB_GLUE_BASE).$(LIB_GLUE_VERSION)
10 LIB_GLUE_BASE = librte_pmd_mlx5_glue.so
11 LIB_GLUE_VERSION = 19.02.0
14 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5.c
15 ifneq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
16 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_glue.c
18 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxq.c
19 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_txq.c
20 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxtx.c
21 ifneq ($(filter y,$(CONFIG_RTE_ARCH_X86_64) \
22 $(CONFIG_RTE_ARCH_ARM64)),)
23 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxtx_vec.c
25 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_trigger.c
26 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_ethdev.c
27 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mac.c
28 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxmode.c
29 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_vlan.c
30 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_stats.c
31 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rss.c
32 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mr.c
33 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow.c
34 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_dv.c
35 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_tcf.c
36 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_verbs.c
37 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_socket.c
38 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_nl.c
39 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_devx_cmds.c
41 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
42 INSTALL-$(CONFIG_RTE_LIBRTE_MLX5_PMD)-lib += $(LIB_GLUE)
47 CFLAGS += -std=c11 -Wall -Wextra
50 CFLAGS += -D_BSD_SOURCE
51 CFLAGS += -D_DEFAULT_SOURCE
52 CFLAGS += -D_XOPEN_SOURCE=600
53 CFLAGS += $(WERROR_FLAGS)
54 CFLAGS += -Wno-strict-prototypes
55 CFLAGS += $(shell command -v pkg-config > /dev/null 2>&1 && pkg-config --cflags libmnl)
56 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
57 CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"'
58 CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
59 CFLAGS_mlx5_glue.o += -fPIC
61 else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y)
62 LDLIBS += $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh)
64 LDLIBS += -libverbs -lmlx5
66 LDLIBS += $(shell command -v pkg-config > /dev/null 2>&1 && pkg-config --libs libmnl || echo "-lmnl")
67 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
68 LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
69 LDLIBS += -lrte_bus_pci
71 # A few warnings cannot be avoided in external headers.
72 CFLAGS += -Wno-error=cast-qual
74 EXPORT_MAP := rte_pmd_mlx5_version.map
77 # memseg walk is not part of stable API
78 CFLAGS += -DALLOW_EXPERIMENTAL_API
80 # DEBUG which is usually provided on the command-line may enable
81 # CONFIG_RTE_LIBRTE_MLX5_DEBUG.
83 CONFIG_RTE_LIBRTE_MLX5_DEBUG := y
86 # User-defined CFLAGS.
87 ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DEBUG),y)
88 CFLAGS += -pedantic -UNDEBUG -DPEDANTIC
90 CFLAGS += -DNDEBUG -UPEDANTIC
93 include $(RTE_SDK)/mk/rte.lib.mk
95 # Generate and clean-up mlx5_autoconf.h.
97 export CC CFLAGS CPPFLAGS EXTRA_CFLAGS EXTRA_CPPFLAGS
98 export AUTO_CONFIG_CFLAGS = -Wno-error
101 AUTOCONF_OUTPUT := >/dev/null
104 mlx5_autoconf.h.new: FORCE
106 mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
109 HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT \
110 infiniband/mlx5dv.h \
111 enum MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX \
114 HAVE_IBV_DEVICE_TUNNEL_SUPPORT \
115 infiniband/mlx5dv.h \
116 enum MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS \
119 HAVE_IBV_DEVICE_MPLS_SUPPORT \
121 enum IBV_FLOW_SPEC_MPLS \
124 HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING \
126 enum IBV_WQ_FLAGS_PCI_WRITE_END_PADDING \
129 HAVE_IBV_WQ_FLAG_RX_END_PADDING \
131 enum IBV_WQ_FLAG_RX_END_PADDING \
134 HAVE_IBV_MLX5_MOD_SWP \
135 infiniband/mlx5dv.h \
136 type 'struct mlx5dv_sw_parsing_caps' \
139 HAVE_IBV_MLX5_MOD_MPW \
140 infiniband/mlx5dv.h \
141 enum MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED \
144 HAVE_IBV_MLX5_MOD_CQE_128B_COMP \
145 infiniband/mlx5dv.h \
146 enum MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP \
149 HAVE_IBV_MLX5_MOD_CQE_128B_PAD \
150 infiniband/mlx5dv.h \
151 enum MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD \
154 HAVE_IBV_FLOW_DV_SUPPORT \
155 infiniband/mlx5dv.h \
156 func mlx5dv_create_flow_action_packet_reformat \
160 infiniband/mlx5dv.h \
161 func mlx5dv_devx_obj_create \
164 HAVE_IBV_FLOW_DEVX_COUNTERS \
165 infiniband/mlx5dv.h \
166 enum MLX5DV_FLOW_ACTION_COUNTER_DEVX \
169 HAVE_ETHTOOL_LINK_MODE_25G \
170 /usr/include/linux/ethtool.h \
171 enum ETHTOOL_LINK_MODE_25000baseCR_Full_BIT \
174 HAVE_ETHTOOL_LINK_MODE_50G \
175 /usr/include/linux/ethtool.h \
176 enum ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT \
179 HAVE_ETHTOOL_LINK_MODE_100G \
180 /usr/include/linux/ethtool.h \
181 enum ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT \
184 HAVE_IBV_DEVICE_COUNTERS_SET_V42 \
186 type 'struct ibv_counter_set_init_attr' \
189 HAVE_IBV_DEVICE_COUNTERS_SET_V45 \
191 type 'struct ibv_counters_init_attr' \
195 rdma/rdma_netlink.h \
199 HAVE_RDMA_NLDEV_CMD_GET \
200 rdma/rdma_netlink.h \
201 enum RDMA_NLDEV_CMD_GET \
204 HAVE_RDMA_NLDEV_CMD_PORT_GET \
205 rdma/rdma_netlink.h \
206 enum RDMA_NLDEV_CMD_PORT_GET \
209 HAVE_RDMA_NLDEV_ATTR_DEV_INDEX \
210 rdma/rdma_netlink.h \
211 enum RDMA_NLDEV_ATTR_DEV_INDEX \
214 HAVE_RDMA_NLDEV_ATTR_DEV_NAME \
215 rdma/rdma_netlink.h \
216 enum RDMA_NLDEV_ATTR_DEV_NAME \
219 HAVE_RDMA_NLDEV_ATTR_PORT_INDEX \
220 rdma/rdma_netlink.h \
221 enum RDMA_NLDEV_ATTR_PORT_INDEX \
224 HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX \
225 rdma/rdma_netlink.h \
226 enum RDMA_NLDEV_ATTR_NDEV_INDEX \
239 HAVE_IFLA_PHYS_SWITCH_ID \
241 enum IFLA_PHYS_SWITCH_ID \
244 HAVE_IFLA_PHYS_PORT_NAME \
246 enum IFLA_PHYS_PORT_NAME \
249 HAVE_IFLA_VXLAN_COLLECT_METADATA \
251 enum IFLA_VXLAN_COLLECT_METADATA \
259 HAVE_TCA_FLOWER_ACT \
261 enum TCA_FLOWER_ACT \
264 HAVE_TCA_FLOWER_FLAGS \
266 enum TCA_FLOWER_FLAGS \
269 HAVE_TCA_FLOWER_KEY_ETH_TYPE \
271 enum TCA_FLOWER_KEY_ETH_TYPE \
274 HAVE_TCA_FLOWER_KEY_ETH_DST \
276 enum TCA_FLOWER_KEY_ETH_DST \
279 HAVE_TCA_FLOWER_KEY_ETH_DST_MASK \
281 enum TCA_FLOWER_KEY_ETH_DST_MASK \
284 HAVE_TCA_FLOWER_KEY_ETH_SRC \
286 enum TCA_FLOWER_KEY_ETH_SRC \
289 HAVE_TCA_FLOWER_KEY_ETH_SRC_MASK \
291 enum TCA_FLOWER_KEY_ETH_SRC_MASK \
294 HAVE_TCA_FLOWER_KEY_IP_PROTO \
296 enum TCA_FLOWER_KEY_IP_PROTO \
299 HAVE_TCA_FLOWER_KEY_IPV4_SRC \
301 enum TCA_FLOWER_KEY_IPV4_SRC \
304 HAVE_TCA_FLOWER_KEY_IPV4_SRC_MASK \
306 enum TCA_FLOWER_KEY_IPV4_SRC_MASK \
309 HAVE_TCA_FLOWER_KEY_IPV4_DST \
311 enum TCA_FLOWER_KEY_IPV4_DST \
314 HAVE_TCA_FLOWER_KEY_IPV4_DST_MASK \
316 enum TCA_FLOWER_KEY_IPV4_DST_MASK \
319 HAVE_TCA_FLOWER_KEY_IPV6_SRC \
321 enum TCA_FLOWER_KEY_IPV6_SRC \
324 HAVE_TCA_FLOWER_KEY_IPV6_SRC_MASK \
326 enum TCA_FLOWER_KEY_IPV6_SRC_MASK \
329 HAVE_TCA_FLOWER_KEY_IPV6_DST \
331 enum TCA_FLOWER_KEY_IPV6_DST \
334 HAVE_TCA_FLOWER_KEY_IPV6_DST_MASK \
336 enum TCA_FLOWER_KEY_IPV6_DST_MASK \
339 HAVE_TCA_FLOWER_KEY_TCP_SRC \
341 enum TCA_FLOWER_KEY_TCP_SRC \
344 HAVE_TCA_FLOWER_KEY_TCP_SRC_MASK \
346 enum TCA_FLOWER_KEY_TCP_SRC_MASK \
349 HAVE_TCA_FLOWER_KEY_TCP_DST \
351 enum TCA_FLOWER_KEY_TCP_DST \
354 HAVE_TCA_FLOWER_KEY_TCP_DST_MASK \
356 enum TCA_FLOWER_KEY_TCP_DST_MASK \
359 HAVE_TCA_FLOWER_KEY_UDP_SRC \
361 enum TCA_FLOWER_KEY_UDP_SRC \
364 HAVE_TCA_FLOWER_KEY_UDP_SRC_MASK \
366 enum TCA_FLOWER_KEY_UDP_SRC_MASK \
369 HAVE_TCA_FLOWER_KEY_UDP_DST \
371 enum TCA_FLOWER_KEY_UDP_DST \
374 HAVE_TCA_FLOWER_KEY_UDP_DST_MASK \
376 enum TCA_FLOWER_KEY_UDP_DST_MASK \
379 HAVE_TCA_FLOWER_KEY_VLAN_ID \
381 enum TCA_FLOWER_KEY_VLAN_ID \
384 HAVE_TCA_FLOWER_KEY_VLAN_PRIO \
386 enum TCA_FLOWER_KEY_VLAN_PRIO \
389 HAVE_TCA_FLOWER_KEY_VLAN_ETH_TYPE \
391 enum TCA_FLOWER_KEY_VLAN_ETH_TYPE \
394 HAVE_TCA_FLOWER_KEY_TCP_FLAGS \
396 enum TCA_FLOWER_KEY_TCP_FLAGS \
399 HAVE_TCA_FLOWER_KEY_TCP_FLAGS_MASK \
401 enum TCA_FLOWER_KEY_TCP_FLAGS_MASK \
404 HAVE_TCA_FLOWER_KEY_IP_TOS \
406 enum TCA_FLOWER_KEY_IP_TOS \
409 HAVE_TCA_FLOWER_KEY_IP_TOS_MASK \
411 enum TCA_FLOWER_KEY_IP_TOS_MASK \
414 HAVE_TCA_FLOWER_KEY_IP_TTL \
416 enum TCA_FLOWER_KEY_IP_TTL \
419 HAVE_TCA_FLOWER_KEY_IP_TTL_MASK \
421 enum TCA_FLOWER_KEY_IP_TTL_MASK \
424 HAVE_TC_ACT_GOTO_CHAIN \
426 define TC_ACT_GOTO_CHAIN \
430 linux/tc_act/tc_vlan.h \
431 enum TCA_VLAN_PUSH_VLAN_PRIORITY \
434 HAVE_TCA_FLOWER_KEY_ENC_KEY_ID \
436 enum TCA_FLOWER_KEY_ENC_KEY_ID \
439 HAVE_TCA_FLOWER_KEY_ENC_IPV4_SRC \
441 enum TCA_FLOWER_KEY_ENC_IPV4_SRC \
444 HAVE_TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK \
446 enum TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK \
449 HAVE_TCA_FLOWER_KEY_ENC_IPV4_DST \
451 enum TCA_FLOWER_KEY_ENC_IPV4_DST \
454 HAVE_TCA_FLOWER_KEY_ENC_IPV4_DST_MASK \
456 enum TCA_FLOWER_KEY_ENC_IPV4_DST_MASK \
459 HAVE_TCA_FLOWER_KEY_ENC_IPV6_SRC \
461 enum TCA_FLOWER_KEY_ENC_IPV6_SRC \
464 HAVE_TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK \
466 enum TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK \
469 HAVE_TCA_FLOWER_KEY_ENC_IPV6_DST \
471 enum TCA_FLOWER_KEY_ENC_IPV6_DST \
474 HAVE_TCA_FLOWER_KEY_ENC_IPV6_DST_MASK \
476 enum TCA_FLOWER_KEY_ENC_IPV6_DST_MASK \
479 HAVE_TCA_FLOWER_KEY_ENC_UDP_SRC_PORT \
481 enum TCA_FLOWER_KEY_ENC_UDP_SRC_PORT \
484 HAVE_TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK \
486 enum TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK \
489 HAVE_TCA_FLOWER_KEY_ENC_UDP_DST_PORT \
491 enum TCA_FLOWER_KEY_ENC_UDP_DST_PORT \
494 HAVE_TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK \
496 enum TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK \
499 HAVE_TCA_FLOWER_KEY_ENC_IP_TOS \
501 enum TCA_FLOWER_KEY_ENC_IP_TOS \
504 HAVE_TCA_FLOWER_KEY_ENC_IP_TOS_MASK \
506 enum TCA_FLOWER_KEY_ENC_IP_TOS_MASK \
509 HAVE_TCA_FLOWER_KEY_ENC_IP_TTL \
511 enum TCA_FLOWER_KEY_ENC_IP_TTL \
514 HAVE_TCA_FLOWER_KEY_ENC_IP_TTL_MASK \
516 enum TCA_FLOWER_KEY_ENC_IP_TTL_MASK \
519 HAVE_TC_ACT_TUNNEL_KEY \
520 linux/tc_act/tc_tunnel_key.h \
521 define TCA_ACT_TUNNEL_KEY \
524 HAVE_TCA_TUNNEL_KEY_ENC_DST_PORT \
525 linux/tc_act/tc_tunnel_key.h \
526 enum TCA_TUNNEL_KEY_ENC_DST_PORT \
529 HAVE_TCA_TUNNEL_KEY_ENC_TOS \
530 linux/tc_act/tc_tunnel_key.h \
531 enum TCA_TUNNEL_KEY_ENC_TOS \
534 HAVE_TCA_TUNNEL_KEY_ENC_TTL \
535 linux/tc_act/tc_tunnel_key.h \
536 enum TCA_TUNNEL_KEY_ENC_TTL \
539 HAVE_TCA_TUNNEL_KEY_NO_CSUM \
540 linux/tc_act/tc_tunnel_key.h \
541 enum TCA_TUNNEL_KEY_NO_CSUM \
545 linux/tc_act/tc_pedit.h \
546 enum TCA_PEDIT_KEY_EX_HDR_TYPE_UDP \
549 HAVE_SUPPORTED_40000baseKR4_Full \
550 /usr/include/linux/ethtool.h \
551 define SUPPORTED_40000baseKR4_Full \
554 HAVE_SUPPORTED_40000baseCR4_Full \
555 /usr/include/linux/ethtool.h \
556 define SUPPORTED_40000baseCR4_Full \
559 HAVE_SUPPORTED_40000baseSR4_Full \
560 /usr/include/linux/ethtool.h \
561 define SUPPORTED_40000baseSR4_Full \
564 HAVE_SUPPORTED_40000baseLR4_Full \
565 /usr/include/linux/ethtool.h \
566 define SUPPORTED_40000baseLR4_Full \
569 HAVE_SUPPORTED_56000baseKR4_Full \
570 /usr/include/linux/ethtool.h \
571 define SUPPORTED_56000baseKR4_Full \
574 HAVE_SUPPORTED_56000baseCR4_Full \
575 /usr/include/linux/ethtool.h \
576 define SUPPORTED_56000baseCR4_Full \
579 HAVE_SUPPORTED_56000baseSR4_Full \
580 /usr/include/linux/ethtool.h \
581 define SUPPORTED_56000baseSR4_Full \
584 HAVE_SUPPORTED_56000baseLR4_Full \
585 /usr/include/linux/ethtool.h \
586 define SUPPORTED_56000baseLR4_Full \
590 /usr/include/assert.h \
591 define static_assert \
594 # Create mlx5_autoconf.h or update it in case it differs from the new one.
596 mlx5_autoconf.h: mlx5_autoconf.h.new
598 cmp '$<' '$@' $(AUTOCONF_OUTPUT) || \
601 $(SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD):.c=.o): mlx5_autoconf.h
603 # Generate dependency plug-in for rdma-core when the PMD must not be linked
604 # directly, so that applications do not inherit this dependency.
606 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
610 ifeq ($(LINK_USING_CC),1)
611 GLUE_LDFLAGS := $(call linkerprefix,$(LDFLAGS))
613 GLUE_LDFLAGS := $(LDFLAGS)
615 $(LIB_GLUE): mlx5_glue.o
616 $Q $(LD) $(GLUE_LDFLAGS) $(EXTRA_LDFLAGS) \
618 -shared -o $@ $< -libverbs -lmlx5
620 mlx5_glue.o: mlx5_autoconf.h
625 $Q rm -f -- mlx5_autoconf.h mlx5_autoconf.h.new
626 $Q rm -f -- mlx5_glue.o $(LIB_GLUE_BASE)*