1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright 2012 6WIND S.A.
3 # Copyright 2012 Mellanox Technologies, Ltd
5 include $(RTE_SDK)/mk/rte.vars.mk
8 LIB = librte_pmd_mlx4.a
9 LIB_GLUE = $(LIB_GLUE_BASE).$(LIB_GLUE_VERSION)
10 LIB_GLUE_BASE = librte_pmd_mlx4_glue.so
11 LIB_GLUE_VERSION = 18.02.0
14 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4.c
15 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_ethdev.c
16 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_flow.c
17 ifneq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
18 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_glue.c
20 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_intr.c
21 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_mp.c
22 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_mr.c
23 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_rxq.c
24 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_rxtx.c
25 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_txq.c
26 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_utils.c
28 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
29 INSTALL-$(CONFIG_RTE_LIBRTE_MLX4_PMD)-lib += $(LIB_GLUE)
34 CFLAGS += -std=c11 -Wall -Wextra
37 CFLAGS += -D_BSD_SOURCE
38 CFLAGS += -D_DEFAULT_SOURCE
39 CFLAGS += -D_XOPEN_SOURCE=600
40 CFLAGS += $(WERROR_FLAGS)
41 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
42 CFLAGS += -DMLX4_GLUE='"$(LIB_GLUE)"'
43 CFLAGS += -DMLX4_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
44 CFLAGS_mlx4_glue.o += -fPIC
46 else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y)
47 LDLIBS += $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh)
49 LDLIBS += -libverbs -lmlx4
51 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
52 LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
53 LDLIBS += -lrte_bus_pci
55 # A few warnings cannot be avoided in external headers.
56 CFLAGS += -Wno-error=cast-qual
58 EXPORT_MAP := rte_pmd_mlx4_version.map
59 # DEBUG which is usually provided on the command-line may enable
60 # CONFIG_RTE_LIBRTE_MLX4_DEBUG.
62 CONFIG_RTE_LIBRTE_MLX4_DEBUG := y
65 # User-defined CFLAGS.
66 ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DEBUG),y)
68 ifneq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
71 AUTO_CONFIG_CFLAGS += -Wno-pedantic
76 include $(RTE_SDK)/mk/rte.lib.mk
78 # Generate and clean-up mlx4_autoconf.h.
80 export CC CFLAGS CPPFLAGS EXTRA_CFLAGS EXTRA_CPPFLAGS
81 export AUTO_CONFIG_CFLAGS += -Wno-error
84 AUTOCONF_OUTPUT := >/dev/null
87 mlx4_autoconf.h.new: FORCE
89 mlx4_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
93 HAVE_IBV_MLX4_BUF_ALLOCATORS \
95 enum MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS \
98 HAVE_IBV_MLX4_UAR_MMAP_OFFSET \
100 enum MLX4DV_QP_MASK_UAR_MMAP_OFFSET \
103 HAVE_IBV_MLX4_WQE_LSO_SEG \
104 infiniband/mlx4dv.h \
105 type 'struct mlx4_wqe_lso_seg' \
108 # Create mlx4_autoconf.h or update it in case it differs from the new one.
110 mlx4_autoconf.h: mlx4_autoconf.h.new
112 cmp '$<' '$@' $(AUTOCONF_OUTPUT) || \
115 $(SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD):.c=.o): mlx4_autoconf.h
117 # Generate dependency plug-in for rdma-core when the PMD must not be linked
118 # directly, so that applications do not inherit this dependency.
120 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
124 ifeq ($(LINK_USING_CC),1)
125 GLUE_LDFLAGS := $(call linkerprefix,$(LDFLAGS))
127 GLUE_LDFLAGS := $(LDFLAGS)
129 $(LIB_GLUE): mlx4_glue.o
130 $Q $(LD) $(GLUE_LDFLAGS) $(EXTRA_LDFLAGS) \
132 -shared -o $@ $< -libverbs -lmlx4
134 mlx4_glue.o: mlx4_autoconf.h
139 $Q rm -f -- mlx4_autoconf.h mlx4_autoconf.h.new
140 $Q rm -f -- mlx4_glue.o $(LIB_GLUE_BASE)*