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.08.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_PPC_64) \
23 $(CONFIG_RTE_ARCH_ARM64)),)
24 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxtx_vec.c
26 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_trigger.c
27 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_ethdev.c
28 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mac.c
29 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxmode.c
30 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_vlan.c
31 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_stats.c
32 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rss.c
33 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mr.c
34 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow.c
35 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_dv.c
36 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_verbs.c
37 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mp.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 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
56 CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"'
57 CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
58 CFLAGS_mlx5_glue.o += -fPIC
60 else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y)
61 LDLIBS += $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh)
63 LDLIBS += -libverbs -lmlx5
65 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
66 LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
67 LDLIBS += -lrte_bus_pci
69 # A few warnings cannot be avoided in external headers.
70 CFLAGS += -Wno-error=cast-qual
72 EXPORT_MAP := rte_pmd_mlx5_version.map
75 # memseg walk is not part of stable API
76 CFLAGS += -DALLOW_EXPERIMENTAL_API
78 # DEBUG which is usually provided on the command-line may enable
79 # CONFIG_RTE_LIBRTE_MLX5_DEBUG.
81 CONFIG_RTE_LIBRTE_MLX5_DEBUG := y
84 # User-defined CFLAGS.
85 ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DEBUG),y)
86 CFLAGS += -pedantic -UNDEBUG
87 ifneq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
90 AUTO_CONFIG_CFLAGS += -Wno-pedantic
92 CFLAGS += -DNDEBUG -UPEDANTIC
95 include $(RTE_SDK)/mk/rte.lib.mk
97 # Generate and clean-up mlx5_autoconf.h.
99 export CC CFLAGS CPPFLAGS EXTRA_CFLAGS EXTRA_CPPFLAGS
100 export AUTO_CONFIG_CFLAGS += -Wno-error
103 AUTOCONF_OUTPUT := >/dev/null
106 mlx5_autoconf.h.new: FORCE
108 mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
111 HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT \
112 infiniband/mlx5dv.h \
113 enum MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX \
116 HAVE_IBV_DEVICE_TUNNEL_SUPPORT \
117 infiniband/mlx5dv.h \
118 enum MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS \
121 HAVE_IBV_DEVICE_MPLS_SUPPORT \
123 enum IBV_FLOW_SPEC_MPLS \
126 HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING \
128 enum IBV_WQ_FLAGS_PCI_WRITE_END_PADDING \
131 HAVE_IBV_WQ_FLAG_RX_END_PADDING \
133 enum IBV_WQ_FLAG_RX_END_PADDING \
136 HAVE_IBV_MLX5_MOD_SWP \
137 infiniband/mlx5dv.h \
138 type 'struct mlx5dv_sw_parsing_caps' \
141 HAVE_IBV_MLX5_MOD_MPW \
142 infiniband/mlx5dv.h \
143 enum MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED \
146 HAVE_IBV_MLX5_MOD_CQE_128B_COMP \
147 infiniband/mlx5dv.h \
148 enum MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP \
151 HAVE_IBV_MLX5_MOD_CQE_128B_PAD \
152 infiniband/mlx5dv.h \
153 enum MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD \
156 HAVE_IBV_FLOW_DV_SUPPORT \
157 infiniband/mlx5dv.h \
158 func mlx5dv_create_flow_action_packet_reformat \
162 infiniband/mlx5dv.h \
163 enum MLX5DV_DR_DOMAIN_TYPE_NIC_RX \
166 HAVE_MLX5DV_DR_ESWITCH \
167 infiniband/mlx5dv.h \
168 enum MLX5DV_DR_DOMAIN_TYPE_FDB \
171 HAVE_MLX5DV_DR_VLAN \
172 infiniband/mlx5dv.h \
173 func mlx5dv_dr_action_create_push_vlan \
176 HAVE_MLX5DV_DR_DEVX_PORT \
177 infiniband/mlx5dv.h \
178 func mlx5dv_query_devx_port \
182 infiniband/mlx5dv.h \
183 func mlx5dv_devx_obj_create \
186 HAVE_IBV_FLOW_DEVX_COUNTERS \
187 infiniband/mlx5dv.h \
188 enum MLX5DV_FLOW_ACTION_COUNTERS_DEVX \
191 HAVE_IBV_DEVX_ASYNC \
192 infiniband/mlx5dv.h \
193 func mlx5dv_devx_obj_query_async \
196 HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR \
197 infiniband/mlx5dv.h \
198 func mlx5dv_dr_action_create_dest_devx_tir \
201 HAVE_ETHTOOL_LINK_MODE_25G \
202 /usr/include/linux/ethtool.h \
203 enum ETHTOOL_LINK_MODE_25000baseCR_Full_BIT \
206 HAVE_ETHTOOL_LINK_MODE_50G \
207 /usr/include/linux/ethtool.h \
208 enum ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT \
211 HAVE_ETHTOOL_LINK_MODE_100G \
212 /usr/include/linux/ethtool.h \
213 enum ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT \
216 HAVE_IBV_DEVICE_COUNTERS_SET_V42 \
218 type 'struct ibv_counter_set_init_attr' \
221 HAVE_IBV_DEVICE_COUNTERS_SET_V45 \
223 type 'struct ibv_counters_init_attr' \
227 rdma/rdma_netlink.h \
231 HAVE_RDMA_NLDEV_CMD_GET \
232 rdma/rdma_netlink.h \
233 enum RDMA_NLDEV_CMD_GET \
236 HAVE_RDMA_NLDEV_CMD_PORT_GET \
237 rdma/rdma_netlink.h \
238 enum RDMA_NLDEV_CMD_PORT_GET \
241 HAVE_RDMA_NLDEV_ATTR_DEV_INDEX \
242 rdma/rdma_netlink.h \
243 enum RDMA_NLDEV_ATTR_DEV_INDEX \
246 HAVE_RDMA_NLDEV_ATTR_DEV_NAME \
247 rdma/rdma_netlink.h \
248 enum RDMA_NLDEV_ATTR_DEV_NAME \
251 HAVE_RDMA_NLDEV_ATTR_PORT_INDEX \
252 rdma/rdma_netlink.h \
253 enum RDMA_NLDEV_ATTR_PORT_INDEX \
256 HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX \
257 rdma/rdma_netlink.h \
258 enum RDMA_NLDEV_ATTR_NDEV_INDEX \
271 HAVE_IFLA_PHYS_SWITCH_ID \
273 enum IFLA_PHYS_SWITCH_ID \
276 HAVE_IFLA_PHYS_PORT_NAME \
278 enum IFLA_PHYS_PORT_NAME \
281 HAVE_SUPPORTED_40000baseKR4_Full \
282 /usr/include/linux/ethtool.h \
283 define SUPPORTED_40000baseKR4_Full \
286 HAVE_SUPPORTED_40000baseCR4_Full \
287 /usr/include/linux/ethtool.h \
288 define SUPPORTED_40000baseCR4_Full \
291 HAVE_SUPPORTED_40000baseSR4_Full \
292 /usr/include/linux/ethtool.h \
293 define SUPPORTED_40000baseSR4_Full \
296 HAVE_SUPPORTED_40000baseLR4_Full \
297 /usr/include/linux/ethtool.h \
298 define SUPPORTED_40000baseLR4_Full \
301 HAVE_SUPPORTED_56000baseKR4_Full \
302 /usr/include/linux/ethtool.h \
303 define SUPPORTED_56000baseKR4_Full \
306 HAVE_SUPPORTED_56000baseCR4_Full \
307 /usr/include/linux/ethtool.h \
308 define SUPPORTED_56000baseCR4_Full \
311 HAVE_SUPPORTED_56000baseSR4_Full \
312 /usr/include/linux/ethtool.h \
313 define SUPPORTED_56000baseSR4_Full \
316 HAVE_SUPPORTED_56000baseLR4_Full \
317 /usr/include/linux/ethtool.h \
318 define SUPPORTED_56000baseLR4_Full \
322 /usr/include/assert.h \
323 define static_assert \
326 # Create mlx5_autoconf.h or update it in case it differs from the new one.
328 mlx5_autoconf.h: mlx5_autoconf.h.new
330 cmp '$<' '$@' $(AUTOCONF_OUTPUT) || \
333 $(SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD):.c=.o): mlx5_autoconf.h
335 # Generate dependency plug-in for rdma-core when the PMD must not be linked
336 # directly, so that applications do not inherit this dependency.
338 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
342 ifeq ($(LINK_USING_CC),1)
343 GLUE_LDFLAGS := $(call linkerprefix,$(LDFLAGS))
345 GLUE_LDFLAGS := $(LDFLAGS)
347 $(LIB_GLUE): mlx5_glue.o
348 $Q $(LD) $(GLUE_LDFLAGS) $(EXTRA_LDFLAGS) \
350 -shared -o $@ $< -libverbs -lmlx5
352 mlx5_glue.o: mlx5_autoconf.h
357 $Q rm -f -- mlx5_autoconf.h mlx5_autoconf.h.new
358 $Q rm -f -- mlx5_glue.o $(LIB_GLUE_BASE)*