1#   BSD LICENSE
2#
3#   Copyright 2015 6WIND S.A.
4#   Copyright 2015 Mellanox.
5#
6#   Redistribution and use in source and binary forms, with or without
7#   modification, are permitted provided that the following conditions
8#   are met:
9#
10#     * Redistributions of source code must retain the above copyright
11#       notice, this list of conditions and the following disclaimer.
12#     * Redistributions in binary form must reproduce the above copyright
13#       notice, this list of conditions and the following disclaimer in
14#       the documentation and/or other materials provided with the
15#       distribution.
16#     * Neither the name of 6WIND S.A. nor the names of its
17#       contributors may be used to endorse or promote products derived
18#       from this software without specific prior written permission.
19#
20#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32include $(RTE_SDK)/mk/rte.vars.mk
33
34# Library name.
35LIB = librte_pmd_mlx5.a
36
37# Sources.
38SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5.c
39SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxq.c
40SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_txq.c
41SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxtx.c
42SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_trigger.c
43SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_ethdev.c
44SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mac.c
45SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxmode.c
46SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_vlan.c
47SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_stats.c
48SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rss.c
49SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_fdir.c
50SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mr.c
51
52# Dependencies.
53DEPDIRS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += lib/librte_ether
54DEPDIRS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += lib/librte_mbuf
55DEPDIRS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += lib/librte_eal
56DEPDIRS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += lib/librte_mempool
57DEPDIRS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += lib/librte_kvargs
58
59# Basic CFLAGS.
60CFLAGS += -O3
61CFLAGS += -std=gnu99 -Wall -Wextra
62CFLAGS += -g
63CFLAGS += -I.
64CFLAGS += -D_BSD_SOURCE
65CFLAGS += -D_DEFAULT_SOURCE
66CFLAGS += -D_XOPEN_SOURCE=600
67CFLAGS += $(WERROR_FLAGS)
68CFLAGS += -Wno-strict-prototypes
69LDLIBS += -libverbs
70
71# A few warnings cannot be avoided in external headers.
72CFLAGS += -Wno-error=cast-qual
73
74EXPORT_MAP := rte_pmd_mlx5_version.map
75LIBABIVER := 1
76
77# DEBUG which is usually provided on the command-line may enable
78# CONFIG_RTE_LIBRTE_MLX5_DEBUG.
79ifeq ($(DEBUG),1)
80CONFIG_RTE_LIBRTE_MLX5_DEBUG := y
81endif
82
83# User-defined CFLAGS.
84ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DEBUG),y)
85CFLAGS += -pedantic -UNDEBUG -DPEDANTIC
86else
87CFLAGS += -DNDEBUG -UPEDANTIC
88endif
89
90ifdef CONFIG_RTE_LIBRTE_MLX5_TX_MP_CACHE
91CFLAGS += -DMLX5_PMD_TX_MP_CACHE=$(CONFIG_RTE_LIBRTE_MLX5_TX_MP_CACHE)
92endif
93
94include $(RTE_SDK)/mk/rte.lib.mk
95
96# Generate and clean-up mlx5_autoconf.h.
97
98export CC CFLAGS CPPFLAGS EXTRA_CFLAGS EXTRA_CPPFLAGS
99export AUTO_CONFIG_CFLAGS = -Wno-error
100
101ifndef V
102AUTOCONF_OUTPUT := >/dev/null
103endif
104
105mlx5_autoconf.h.new: FORCE
106
107mlx5_autoconf.h.new: $(RTE_SDK)/scripts/auto-config-h.sh
108	$Q $(RM) -f -- '$@'
109	$Q sh -- '$<' '$@' \
110		HAVE_VERBS_IBV_EXP_CQ_COMPRESSED_CQE \
111		infiniband/verbs_exp.h \
112		enum IBV_EXP_CQ_COMPRESSED_CQE \
113		$(AUTOCONF_OUTPUT)
114	$Q sh -- '$<' '$@' \
115		HAVE_VERBS_MLX5_ETH_VLAN_INLINE_HEADER_SIZE \
116		infiniband/mlx5_hw.h \
117		enum MLX5_ETH_VLAN_INLINE_HEADER_SIZE \
118		$(AUTOCONF_OUTPUT)
119	$Q sh -- '$<' '$@' \
120		HAVE_VERBS_MLX5_OPCODE_TSO \
121		infiniband/mlx5_hw.h \
122		enum MLX5_OPCODE_TSO \
123		$(AUTOCONF_OUTPUT)
124	$Q sh -- '$<' '$@' \
125		HAVE_ETHTOOL_LINK_MODE_25G \
126		/usr/include/linux/ethtool.h \
127		enum ETHTOOL_LINK_MODE_25000baseCR_Full_BIT \
128		$(AUTOCONF_OUTPUT)
129	$Q sh -- '$<' '$@' \
130		HAVE_ETHTOOL_LINK_MODE_50G \
131		/usr/include/linux/ethtool.h \
132		enum ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT \
133		$(AUTOCONF_OUTPUT)
134	$Q sh -- '$<' '$@' \
135		HAVE_ETHTOOL_LINK_MODE_100G \
136		/usr/include/linux/ethtool.h \
137		enum ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT \
138		$(AUTOCONF_OUTPUT)
139
140# Create mlx5_autoconf.h or update it in case it differs from the new one.
141
142mlx5_autoconf.h: mlx5_autoconf.h.new
143	$Q [ -f '$@' ] && \
144		cmp '$<' '$@' $(AUTOCONF_OUTPUT) || \
145		mv '$<' '$@'
146
147$(SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD):.c=.o): mlx5_autoconf.h
148
149clean_mlx5: FORCE
150	$Q rm -f -- mlx5_autoconf.h mlx5_autoconf.h.new
151
152clean: clean_mlx5
153