From 7b4f1e6bd367855716d84e95a1dd85ac3647a4c8 Mon Sep 17 00:00:00 2001 From: Matan Azrad Date: Wed, 29 Jan 2020 12:38:27 +0000 Subject: [PATCH] common/mlx5: introduce common library A new Mellanox vdpa PMD will be added to support vdpa operations by Mellanox adapters. This vdpa PMD design includes mlx5_glue and mlx5_devx operations and large parts of them are shared with the net/mlx5 PMD. Create a new common library in drivers/common for mlx5 PMDs. Move mlx5_glue, mlx5_devx_cmds and their dependencies to the new mlx5 common library in drivers/common. The files mlx5_devx_cmds.c, mlx5_devx_cmds.h, mlx5_glue.c, mlx5_glue.h and mlx5_prm.h are moved as is from drivers/net/mlx5 to drivers/common/mlx5. Share the log mechanism macros. Separate also the log mechanism to allow different log level control to the common library. Build files and version files are adjusted accordingly. Include lines are adjusted accordingly. Signed-off-by: Matan Azrad Acked-by: Viacheslav Ovsiienko --- MAINTAINERS | 1 + drivers/common/Makefile | 4 + drivers/common/meson.build | 2 +- drivers/common/mlx5/Makefile | 331 ++++++++++++++++++ drivers/common/mlx5/meson.build | 205 +++++++++++ drivers/common/mlx5/mlx5_common.c | 186 ++++++++++ drivers/common/mlx5/mlx5_common.h | 87 +++++ drivers/common/mlx5/mlx5_common_utils.h | 20 ++ drivers/{net => common}/mlx5/mlx5_devx_cmds.c | 4 +- drivers/{net => common}/mlx5/mlx5_devx_cmds.h | 0 drivers/{net => common}/mlx5/mlx5_glue.c | 12 - drivers/{net => common}/mlx5/mlx5_glue.h | 7 +- drivers/{net => common}/mlx5/mlx5_prm.h | 3 +- .../common/mlx5/rte_common_mlx5_version.map | 20 ++ drivers/net/mlx5/Makefile | 306 +--------------- drivers/net/mlx5/meson.build | 258 +++----------- drivers/net/mlx5/mlx5.c | 179 +--------- drivers/net/mlx5/mlx5.h | 9 +- drivers/net/mlx5/mlx5_ethdev.c | 5 +- drivers/net/mlx5/mlx5_flow.c | 9 +- drivers/net/mlx5/mlx5_flow.h | 3 +- drivers/net/mlx5/mlx5_flow_dv.c | 9 +- drivers/net/mlx5/mlx5_flow_meter.c | 2 + drivers/net/mlx5/mlx5_flow_verbs.c | 7 +- drivers/net/mlx5/mlx5_mac.c | 2 +- drivers/net/mlx5/mlx5_mr.c | 3 +- drivers/net/mlx5/mlx5_rss.c | 2 +- drivers/net/mlx5/mlx5_rxq.c | 8 +- drivers/net/mlx5/mlx5_rxtx.c | 7 +- drivers/net/mlx5/mlx5_rxtx.h | 7 +- drivers/net/mlx5/mlx5_rxtx_vec.c | 5 +- drivers/net/mlx5/mlx5_rxtx_vec.h | 3 +- drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 5 +- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 5 +- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 5 +- drivers/net/mlx5/mlx5_stats.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 7 +- drivers/net/mlx5/mlx5_utils.h | 79 +---- drivers/net/mlx5/mlx5_vlan.c | 5 +- mk/rte.app.mk | 1 + 40 files changed, 986 insertions(+), 829 deletions(-) create mode 100644 drivers/common/mlx5/Makefile create mode 100644 drivers/common/mlx5/meson.build create mode 100644 drivers/common/mlx5/mlx5_common.c create mode 100644 drivers/common/mlx5/mlx5_common.h create mode 100644 drivers/common/mlx5/mlx5_common_utils.h rename drivers/{net => common}/mlx5/mlx5_devx_cmds.c (99%) rename drivers/{net => common}/mlx5/mlx5_devx_cmds.h (100%) rename drivers/{net => common}/mlx5/mlx5_glue.c (98%) rename drivers/{net => common}/mlx5/mlx5_glue.h (99%) rename drivers/{net => common}/mlx5/mlx5_prm.h (99%) create mode 100644 drivers/common/mlx5/rte_common_mlx5_version.map diff --git a/MAINTAINERS b/MAINTAINERS index 08aa0d8a81..92eebd4839 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -741,6 +741,7 @@ M: Matan Azrad M: Shahaf Shuler M: Viacheslav Ovsiienko T: git://dpdk.org/next/dpdk-next-net-mlx +F: drivers/common/mlx5/ F: drivers/net/mlx5/ F: buildtools/options-ibverbs-static.sh F: doc/guides/nics/mlx5.rst diff --git a/drivers/common/Makefile b/drivers/common/Makefile index 3254c5274e..4775d4b70f 100644 --- a/drivers/common/Makefile +++ b/drivers/common/Makefile @@ -35,4 +35,8 @@ ifneq (,$(findstring y,$(IAVF-y))) DIRS-y += iavf endif +ifeq ($(CONFIG_RTE_LIBRTE_MLX5_PMD),y) +DIRS-y += mlx5 +endif + include $(RTE_SDK)/mk/rte.subdir.mk diff --git a/drivers/common/meson.build b/drivers/common/meson.build index fc620f7415..ffd06e2c3c 100644 --- a/drivers/common/meson.build +++ b/drivers/common/meson.build @@ -2,6 +2,6 @@ # Copyright(c) 2018 Cavium, Inc std_deps = ['eal'] -drivers = ['cpt', 'dpaax', 'iavf', 'mvep', 'octeontx', 'octeontx2', 'qat'] +drivers = ['cpt', 'dpaax', 'iavf', 'mlx5', 'mvep', 'octeontx', 'octeontx2', 'qat'] config_flag_fmt = 'RTE_LIBRTE_@0@_COMMON' driver_name_fmt = 'rte_common_@0@' diff --git a/drivers/common/mlx5/Makefile b/drivers/common/mlx5/Makefile new file mode 100644 index 0000000000..b94d3c0465 --- /dev/null +++ b/drivers/common/mlx5/Makefile @@ -0,0 +1,331 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2019 Mellanox Technologies, Ltd + +include $(RTE_SDK)/mk/rte.vars.mk + +# Library name. +LIB = librte_common_mlx5.a +LIB_GLUE = $(LIB_GLUE_BASE).$(LIB_GLUE_VERSION) +LIB_GLUE_BASE = librte_pmd_mlx5_glue.so +LIB_GLUE_VERSION = 20.02.0 + +# Sources. +ifneq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y) +SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_glue.c +endif +SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_devx_cmds.c +SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_common.c + +ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y) +INSTALL-$(CONFIG_RTE_LIBRTE_MLX5_PMD)-lib += $(LIB_GLUE) +endif + +# Basic CFLAGS. +CFLAGS += -O3 +CFLAGS += -std=c11 -Wall -Wextra +CFLAGS += -g +CFLAGS += -I. +CFLAGS += -D_BSD_SOURCE +CFLAGS += -D_DEFAULT_SOURCE +CFLAGS += -D_XOPEN_SOURCE=600 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -Wno-strict-prototypes +ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y) +CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"' +CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"' +CFLAGS_mlx5_glue.o += -fPIC +LDLIBS += -ldl +else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y) +LDLIBS += $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh) +else +LDLIBS += -libverbs -lmlx5 +endif + +LDLIBS += -lrte_eal + +# A few warnings cannot be avoided in external headers. +CFLAGS += -Wno-error=cast-qual -DNDEBUG -UPEDANTIC + +EXPORT_MAP := rte_common_mlx5_version.map + +include $(RTE_SDK)/mk/rte.lib.mk + +# Generate and clean-up mlx5_autoconf.h. + +export CC CFLAGS CPPFLAGS EXTRA_CFLAGS EXTRA_CPPFLAGS +export AUTO_CONFIG_CFLAGS = -Wno-error + +ifndef V +AUTOCONF_OUTPUT := >/dev/null +endif + +mlx5_autoconf.h.new: FORCE + +mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh + $Q $(RM) -f -- '$@' + $Q sh -- '$<' '$@' \ + HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT \ + infiniband/mlx5dv.h \ + enum MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_DEVICE_TUNNEL_SUPPORT \ + infiniband/mlx5dv.h \ + enum MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_DEVICE_MPLS_SUPPORT \ + infiniband/verbs.h \ + enum IBV_FLOW_SPEC_MPLS \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING \ + infiniband/verbs.h \ + enum IBV_WQ_FLAGS_PCI_WRITE_END_PADDING \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_WQ_FLAG_RX_END_PADDING \ + infiniband/verbs.h \ + enum IBV_WQ_FLAG_RX_END_PADDING \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_MLX5_MOD_SWP \ + infiniband/mlx5dv.h \ + type 'struct mlx5dv_sw_parsing_caps' \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_MLX5_MOD_MPW \ + infiniband/mlx5dv.h \ + enum MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_MLX5_MOD_CQE_128B_COMP \ + infiniband/mlx5dv.h \ + enum MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_MLX5_MOD_CQE_128B_PAD \ + infiniband/mlx5dv.h \ + enum MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_FLOW_DV_SUPPORT \ + infiniband/mlx5dv.h \ + func mlx5dv_create_flow_action_packet_reformat \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_MLX5DV_DR \ + infiniband/mlx5dv.h \ + enum MLX5DV_DR_DOMAIN_TYPE_NIC_RX \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_MLX5DV_DR_ESWITCH \ + infiniband/mlx5dv.h \ + enum MLX5DV_DR_DOMAIN_TYPE_FDB \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_MLX5DV_DR_VLAN \ + infiniband/mlx5dv.h \ + func mlx5dv_dr_action_create_push_vlan \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_MLX5DV_DR_DEVX_PORT \ + infiniband/mlx5dv.h \ + func mlx5dv_query_devx_port \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_DEVX_OBJ \ + infiniband/mlx5dv.h \ + func mlx5dv_devx_obj_create \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_FLOW_DEVX_COUNTERS \ + infiniband/mlx5dv.h \ + enum MLX5DV_FLOW_ACTION_COUNTERS_DEVX \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_DEVX_ASYNC \ + infiniband/mlx5dv.h \ + func mlx5dv_devx_obj_query_async \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR \ + infiniband/mlx5dv.h \ + func mlx5dv_dr_action_create_dest_devx_tir \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER \ + infiniband/mlx5dv.h \ + func mlx5dv_dr_action_create_flow_meter \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_MLX5_DR_FLOW_DUMP \ + infiniband/mlx5dv.h \ + func mlx5dv_dump_dr_domain \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD \ + infiniband/mlx5dv.h \ + enum MLX5_MMAP_GET_NC_PAGES_CMD \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_ETHTOOL_LINK_MODE_25G \ + /usr/include/linux/ethtool.h \ + enum ETHTOOL_LINK_MODE_25000baseCR_Full_BIT \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_ETHTOOL_LINK_MODE_50G \ + /usr/include/linux/ethtool.h \ + enum ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_ETHTOOL_LINK_MODE_100G \ + /usr/include/linux/ethtool.h \ + enum ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_DEVICE_COUNTERS_SET_V42 \ + infiniband/verbs.h \ + type 'struct ibv_counter_set_init_attr' \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_DEVICE_COUNTERS_SET_V45 \ + infiniband/verbs.h \ + type 'struct ibv_counters_init_attr' \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_RDMA_NL_NLDEV \ + rdma/rdma_netlink.h \ + enum RDMA_NL_NLDEV \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_RDMA_NLDEV_CMD_GET \ + rdma/rdma_netlink.h \ + enum RDMA_NLDEV_CMD_GET \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_RDMA_NLDEV_CMD_PORT_GET \ + rdma/rdma_netlink.h \ + enum RDMA_NLDEV_CMD_PORT_GET \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_RDMA_NLDEV_ATTR_DEV_INDEX \ + rdma/rdma_netlink.h \ + enum RDMA_NLDEV_ATTR_DEV_INDEX \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_RDMA_NLDEV_ATTR_DEV_NAME \ + rdma/rdma_netlink.h \ + enum RDMA_NLDEV_ATTR_DEV_NAME \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_RDMA_NLDEV_ATTR_PORT_INDEX \ + rdma/rdma_netlink.h \ + enum RDMA_NLDEV_ATTR_PORT_INDEX \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX \ + rdma/rdma_netlink.h \ + enum RDMA_NLDEV_ATTR_NDEV_INDEX \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IFLA_NUM_VF \ + linux/if_link.h \ + enum IFLA_NUM_VF \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IFLA_EXT_MASK \ + linux/if_link.h \ + enum IFLA_EXT_MASK \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IFLA_PHYS_SWITCH_ID \ + linux/if_link.h \ + enum IFLA_PHYS_SWITCH_ID \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IFLA_PHYS_PORT_NAME \ + linux/if_link.h \ + enum IFLA_PHYS_PORT_NAME \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_SUPPORTED_40000baseKR4_Full \ + /usr/include/linux/ethtool.h \ + define SUPPORTED_40000baseKR4_Full \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_SUPPORTED_40000baseCR4_Full \ + /usr/include/linux/ethtool.h \ + define SUPPORTED_40000baseCR4_Full \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_SUPPORTED_40000baseSR4_Full \ + /usr/include/linux/ethtool.h \ + define SUPPORTED_40000baseSR4_Full \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_SUPPORTED_40000baseLR4_Full \ + /usr/include/linux/ethtool.h \ + define SUPPORTED_40000baseLR4_Full \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_SUPPORTED_56000baseKR4_Full \ + /usr/include/linux/ethtool.h \ + define SUPPORTED_56000baseKR4_Full \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_SUPPORTED_56000baseCR4_Full \ + /usr/include/linux/ethtool.h \ + define SUPPORTED_56000baseCR4_Full \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_SUPPORTED_56000baseSR4_Full \ + /usr/include/linux/ethtool.h \ + define SUPPORTED_56000baseSR4_Full \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_SUPPORTED_56000baseLR4_Full \ + /usr/include/linux/ethtool.h \ + define SUPPORTED_56000baseLR4_Full \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_STATIC_ASSERT \ + /usr/include/assert.h \ + define static_assert \ + $(AUTOCONF_OUTPUT) + +# Create mlx5_autoconf.h or update it in case it differs from the new one. + +mlx5_autoconf.h: mlx5_autoconf.h.new + $Q [ -f '$@' ] && \ + cmp '$<' '$@' $(AUTOCONF_OUTPUT) || \ + mv '$<' '$@' + +$(SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD):.c=.o): mlx5_autoconf.h + +# Generate dependency plug-in for rdma-core when the PMD must not be linked +# directly, so that applications do not inherit this dependency. + +ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y) + +$(LIB): $(LIB_GLUE) + +ifeq ($(LINK_USING_CC),1) +GLUE_LDFLAGS := $(call linkerprefix,$(LDFLAGS)) +else +GLUE_LDFLAGS := $(LDFLAGS) +endif +$(LIB_GLUE): mlx5_glue.o + $Q $(LD) $(GLUE_LDFLAGS) $(EXTRA_LDFLAGS) \ + -Wl,-h,$(LIB_GLUE) \ + -shared -o $@ $< -libverbs -lmlx5 + +mlx5_glue.o: mlx5_autoconf.h + +endif + +clean_mlx5: FORCE + $Q rm -f -- mlx5_autoconf.h mlx5_autoconf.h.new + $Q rm -f -- mlx5_glue.o $(LIB_GLUE_BASE)* + +clean: clean_mlx5 diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build new file mode 100644 index 0000000000..718cef2608 --- /dev/null +++ b/drivers/common/mlx5/meson.build @@ -0,0 +1,205 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2019 Mellanox Technologies, Ltd + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif +build = true + +pmd_dlopen = (get_option('ibverbs_link') == 'dlopen') +LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so' +LIB_GLUE_VERSION = '20.02.0' +LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION +if pmd_dlopen + dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1) + cflags += [ + '-DMLX5_GLUE="@0@"'.format(LIB_GLUE), + '-DMLX5_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION), + ] +endif + +libnames = [ 'mlx5', 'ibverbs' ] +libs = [] +foreach libname:libnames + lib = dependency('lib' + libname, required:false) + if not lib.found() + lib = cc.find_library(libname, required:false) + endif + if lib.found() + libs += lib + else + build = false + reason = 'missing dependency, "' + libname + '"' + endif +endforeach + +if build + allow_experimental_apis = true + deps += ['hash', 'pci', 'net', 'eal'] + ext_deps += libs + sources = files( + 'mlx5_devx_cmds.c', + 'mlx5_common.c', + ) + if not pmd_dlopen + sources += files('mlx5_glue.c') + endif + cflags_options = [ + '-std=c11', + '-Wno-strict-prototypes', + '-D_BSD_SOURCE', + '-D_DEFAULT_SOURCE', + '-D_XOPEN_SOURCE=600' + ] + foreach option:cflags_options + if cc.has_argument(option) + cflags += option + endif + endforeach + if get_option('buildtype').contains('debug') + cflags += [ '-pedantic', '-UNDEBUG', '-DPEDANTIC' ] + else + cflags += [ '-DNDEBUG', '-UPEDANTIC' ] + endif + # To maintain the compatibility with the make build system + # mlx5_autoconf.h file is still generated. + # input array for meson member search: + # [ "MACRO to define if found", "header for the search", + # "symbol to search", "struct member to search" ] + has_member_args = [ + [ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h', + 'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ], + [ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h', + 'struct ibv_counter_set_init_attr', 'counter_set_id' ], + [ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45', 'infiniband/verbs.h', + 'struct ibv_counters_init_attr', 'comp_mask' ], + ] + # input array for meson symbol search: + # [ "MACRO to define if found", "header for the search", + # "symbol to search" ] + has_sym_args = [ + [ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT', 'infiniband/mlx5dv.h', + 'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ], + [ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT', 'infiniband/mlx5dv.h', + 'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ], + [ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h', + 'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ], + [ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h', + 'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ], + [ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD', 'infiniband/mlx5dv.h', + 'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ], + [ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h', + 'mlx5dv_create_flow_action_packet_reformat' ], + [ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h', + 'IBV_FLOW_SPEC_MPLS' ], + [ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING', 'infiniband/verbs.h', + 'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ], + [ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h', + 'IBV_WQ_FLAG_RX_END_PADDING' ], + [ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h', + 'mlx5dv_query_devx_port' ], + [ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h', + 'mlx5dv_devx_obj_create' ], + [ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h', + 'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ], + [ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h', + 'mlx5dv_devx_obj_query_async' ], + [ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR', 'infiniband/mlx5dv.h', + 'mlx5dv_dr_action_create_dest_devx_tir' ], + [ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER', 'infiniband/mlx5dv.h', + 'mlx5dv_dr_action_create_flow_meter' ], + [ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD', 'infiniband/mlx5dv.h', + 'MLX5_MMAP_GET_NC_PAGES_CMD' ], + [ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h', + 'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ], + [ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h', + 'MLX5DV_DR_DOMAIN_TYPE_FDB' ], + [ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h', + 'mlx5dv_dr_action_create_push_vlan' ], + [ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h', + 'SUPPORTED_40000baseKR4_Full' ], + [ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h', + 'SUPPORTED_40000baseCR4_Full' ], + [ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h', + 'SUPPORTED_40000baseSR4_Full' ], + [ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h', + 'SUPPORTED_40000baseLR4_Full' ], + [ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h', + 'SUPPORTED_56000baseKR4_Full' ], + [ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h', + 'SUPPORTED_56000baseCR4_Full' ], + [ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h', + 'SUPPORTED_56000baseSR4_Full' ], + [ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h', + 'SUPPORTED_56000baseLR4_Full' ], + [ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h', + 'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ], + [ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h', + 'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ], + [ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h', + 'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ], + [ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h', + 'IFLA_NUM_VF' ], + [ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h', + 'IFLA_EXT_MASK' ], + [ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h', + 'IFLA_PHYS_SWITCH_ID' ], + [ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h', + 'IFLA_PHYS_PORT_NAME' ], + [ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h', + 'RDMA_NL_NLDEV' ], + [ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h', + 'RDMA_NLDEV_CMD_GET' ], + [ 'HAVE_RDMA_NLDEV_CMD_PORT_GET', 'rdma/rdma_netlink.h', + 'RDMA_NLDEV_CMD_PORT_GET' ], + [ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX', 'rdma/rdma_netlink.h', + 'RDMA_NLDEV_ATTR_DEV_INDEX' ], + [ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME', 'rdma/rdma_netlink.h', + 'RDMA_NLDEV_ATTR_DEV_NAME' ], + [ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX', 'rdma/rdma_netlink.h', + 'RDMA_NLDEV_ATTR_PORT_INDEX' ], + [ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX', 'rdma/rdma_netlink.h', + 'RDMA_NLDEV_ATTR_NDEV_INDEX' ], + [ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h', + 'mlx5dv_dump_dr_domain'], + ] + config = configuration_data() + foreach arg:has_sym_args + config.set(arg[0], cc.has_header_symbol(arg[1], arg[2], + dependencies: libs)) + endforeach + foreach arg:has_member_args + file_prefix = '#include <' + arg[1] + '>' + config.set(arg[0], cc.has_member(arg[2], arg[3], + prefix : file_prefix, dependencies: libs)) + endforeach + configure_file(output : 'mlx5_autoconf.h', configuration : config) +endif +# Build Glue Library +if pmd_dlopen and build + dlopen_name = 'mlx5_glue' + dlopen_lib_name = driver_name_fmt.format(dlopen_name) + dlopen_so_version = LIB_GLUE_VERSION + dlopen_sources = files('mlx5_glue.c') + dlopen_install_dir = [ eal_pmd_path + '-glue' ] + dlopen_includes = [global_inc] + dlopen_includes += include_directories( + '../../../lib/librte_eal/common/include/generic', + ) + shared_lib = shared_library( + dlopen_lib_name, + dlopen_sources, + include_directories: dlopen_includes, + c_args: cflags, + dependencies: libs, + link_args: [ + '-Wl,-export-dynamic', + '-Wl,-h,@0@'.format(LIB_GLUE), + ], + soversion: dlopen_so_version, + install: true, + install_dir: dlopen_install_dir, + ) +endif diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c new file mode 100644 index 0000000000..9c88a639c1 --- /dev/null +++ b/drivers/common/mlx5/mlx5_common.c @@ -0,0 +1,186 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2019 Mellanox Technologies, Ltd + */ + +#include +#include +#include + +#include + +#include "mlx5_common.h" +#include "mlx5_common_utils.h" +#include "mlx5_glue.h" + + +int mlx5_common_logtype; + + +#ifdef RTE_IBVERBS_LINK_DLOPEN + +/** + * Suffix RTE_EAL_PMD_PATH with "-glue". + * + * This function performs a sanity check on RTE_EAL_PMD_PATH before + * suffixing its last component. + * + * @param buf[out] + * Output buffer, should be large enough otherwise NULL is returned. + * @param size + * Size of @p out. + * + * @return + * Pointer to @p buf or @p NULL in case suffix cannot be appended. + */ +static char * +mlx5_glue_path(char *buf, size_t size) +{ + static const char *const bad[] = { "/", ".", "..", NULL }; + const char *path = RTE_EAL_PMD_PATH; + size_t len = strlen(path); + size_t off; + int i; + + while (len && path[len - 1] == '/') + --len; + for (off = len; off && path[off - 1] != '/'; --off) + ; + for (i = 0; bad[i]; ++i) + if (!strncmp(path + off, bad[i], (int)(len - off))) + goto error; + i = snprintf(buf, size, "%.*s-glue", (int)len, path); + if (i == -1 || (size_t)i >= size) + goto error; + return buf; +error: + RTE_LOG(ERR, PMD, "unable to append \"-glue\" to last component of" + " RTE_EAL_PMD_PATH (\"" RTE_EAL_PMD_PATH "\"), please" + " re-configure DPDK"); + return NULL; +} +#endif + +/** + * Initialization routine for run-time dependency on rdma-core. + */ +RTE_INIT_PRIO(mlx5_glue_init, CLASS) +{ + void *handle = NULL; + + /* Initialize common log type. */ + mlx5_common_logtype = rte_log_register("pmd.common.mlx5"); + if (mlx5_common_logtype >= 0) + rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE); + /* + * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use + * huge pages. Calling ibv_fork_init() during init allows + * applications to use fork() safely for purposes other than + * using this PMD, which is not supported in forked processes. + */ + setenv("RDMAV_HUGEPAGES_SAFE", "1", 1); + /* Match the size of Rx completion entry to the size of a cacheline. */ + if (RTE_CACHE_LINE_SIZE == 128) + setenv("MLX5_CQE_SIZE", "128", 0); + /* + * MLX5_DEVICE_FATAL_CLEANUP tells ibv_destroy functions to + * cleanup all the Verbs resources even when the device was removed. + */ + setenv("MLX5_DEVICE_FATAL_CLEANUP", "1", 1); + /* The glue initialization was done earlier by mlx5 common library. */ +#ifdef RTE_IBVERBS_LINK_DLOPEN + char glue_path[sizeof(RTE_EAL_PMD_PATH) - 1 + sizeof("-glue")]; + const char *path[] = { + /* + * A basic security check is necessary before trusting + * MLX5_GLUE_PATH, which may override RTE_EAL_PMD_PATH. + */ + (geteuid() == getuid() && getegid() == getgid() ? + getenv("MLX5_GLUE_PATH") : NULL), + /* + * When RTE_EAL_PMD_PATH is set, use its glue-suffixed + * variant, otherwise let dlopen() look up libraries on its + * own. + */ + (*RTE_EAL_PMD_PATH ? + mlx5_glue_path(glue_path, sizeof(glue_path)) : ""), + }; + unsigned int i = 0; + void **sym; + const char *dlmsg; + + while (!handle && i != RTE_DIM(path)) { + const char *end; + size_t len; + int ret; + + if (!path[i]) { + ++i; + continue; + } + end = strpbrk(path[i], ":;"); + if (!end) + end = path[i] + strlen(path[i]); + len = end - path[i]; + ret = 0; + do { + char name[ret + 1]; + + ret = snprintf(name, sizeof(name), "%.*s%s" MLX5_GLUE, + (int)len, path[i], + (!len || *(end - 1) == '/') ? "" : "/"); + if (ret == -1) + break; + if (sizeof(name) != (size_t)ret + 1) + continue; + DRV_LOG(DEBUG, "Looking for rdma-core glue as " + "\"%s\"", name); + handle = dlopen(name, RTLD_LAZY); + break; + } while (1); + path[i] = end + 1; + if (!*end) + ++i; + } + if (!handle) { + rte_errno = EINVAL; + dlmsg = dlerror(); + if (dlmsg) + DRV_LOG(WARNING, "Cannot load glue library: %s", dlmsg); + goto glue_error; + } + sym = dlsym(handle, "mlx5_glue"); + if (!sym || !*sym) { + rte_errno = EINVAL; + dlmsg = dlerror(); + if (dlmsg) + DRV_LOG(ERR, "Cannot resolve glue symbol: %s", dlmsg); + goto glue_error; + } + mlx5_glue = *sym; +#endif /* RTE_IBVERBS_LINK_DLOPEN */ +#ifndef NDEBUG + /* Glue structure must not contain any NULL pointers. */ + { + unsigned int i; + + for (i = 0; i != sizeof(*mlx5_glue) / sizeof(void *); ++i) + assert(((const void *const *)mlx5_glue)[i]); + } +#endif + if (strcmp(mlx5_glue->version, MLX5_GLUE_VERSION)) { + rte_errno = EINVAL; + DRV_LOG(ERR, "rdma-core glue \"%s\" mismatch: \"%s\" is " + "required", mlx5_glue->version, MLX5_GLUE_VERSION); + goto glue_error; + } + mlx5_glue->fork_init(); + return; +glue_error: + if (handle) + dlclose(handle); + DRV_LOG(WARNING, "Cannot initialize MLX5 common due to missing" + " run-time dependency on rdma-core libraries (libibverbs," + " libmlx5)"); + mlx5_glue = NULL; + return; +} diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h new file mode 100644 index 0000000000..9f10defa64 --- /dev/null +++ b/drivers/common/mlx5/mlx5_common.h @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2019 Mellanox Technologies, Ltd + */ + +#ifndef RTE_PMD_MLX5_COMMON_H_ +#define RTE_PMD_MLX5_COMMON_H_ + +#include + +#include + + +/* + * Helper macros to work around __VA_ARGS__ limitations in a C99 compliant + * manner. + */ +#define PMD_DRV_LOG_STRIP(a, b) a +#define PMD_DRV_LOG_OPAREN ( +#define PMD_DRV_LOG_CPAREN ) +#define PMD_DRV_LOG_COMMA , + +/* Return the file name part of a path. */ +static inline const char * +pmd_drv_log_basename(const char *s) +{ + const char *n = s; + + while (*n) + if (*(n++) == '/') + s = n; + return s; +} + +#define PMD_DRV_LOG___(level, type, name, ...) \ + rte_log(RTE_LOG_ ## level, \ + type, \ + RTE_FMT(name ": " \ + RTE_FMT_HEAD(__VA_ARGS__,), \ + RTE_FMT_TAIL(__VA_ARGS__,))) + +/* + * When debugging is enabled (NDEBUG not defined), file, line and function + * information replace the driver name (MLX5_DRIVER_NAME) in log messages. + */ +#ifndef NDEBUG + +#define PMD_DRV_LOG__(level, type, name, ...) \ + PMD_DRV_LOG___(level, type, name, "%s:%u: %s(): " __VA_ARGS__) +#define PMD_DRV_LOG_(level, type, name, s, ...) \ + PMD_DRV_LOG__(level, type, name,\ + s "\n" PMD_DRV_LOG_COMMA \ + pmd_drv_log_basename(__FILE__) PMD_DRV_LOG_COMMA \ + __LINE__ PMD_DRV_LOG_COMMA \ + __func__, \ + __VA_ARGS__) + +#else /* NDEBUG */ +#define PMD_DRV_LOG__(level, type, name, ...) \ + PMD_DRV_LOG___(level, type, name, __VA_ARGS__) +#define PMD_DRV_LOG_(level, type, name, s, ...) \ + PMD_DRV_LOG__(level, type, name, s "\n", __VA_ARGS__) + +#endif /* NDEBUG */ + +/* claim_zero() does not perform any check when debugging is disabled. */ +#ifndef NDEBUG + +#define DEBUG(...) DRV_LOG(DEBUG, __VA_ARGS__) +#define claim_zero(...) assert((__VA_ARGS__) == 0) +#define claim_nonzero(...) assert((__VA_ARGS__) != 0) + +#else /* NDEBUG */ + +#define DEBUG(...) (void)0 +#define claim_zero(...) (__VA_ARGS__) +#define claim_nonzero(...) (__VA_ARGS__) + +#endif /* NDEBUG */ + +/* Allocate a buffer on the stack and fill it with a printf format string. */ +#define MKSTR(name, ...) \ + int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \ + char name[mkstr_size_##name + 1]; \ + \ + snprintf(name, sizeof(name), "" __VA_ARGS__) + +#endif /* RTE_PMD_MLX5_COMMON_H_ */ diff --git a/drivers/common/mlx5/mlx5_common_utils.h b/drivers/common/mlx5/mlx5_common_utils.h new file mode 100644 index 0000000000..32c3adfab2 --- /dev/null +++ b/drivers/common/mlx5/mlx5_common_utils.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2019 Mellanox Technologies, Ltd + */ + +#ifndef RTE_PMD_MLX5_COMMON_UTILS_H_ +#define RTE_PMD_MLX5_COMMON_UTILS_H_ + +#include "mlx5_common.h" + + +extern int mlx5_common_logtype; + +#define MLX5_COMMON_LOG_PREFIX "common_mlx5" +/* Generic printf()-like logging macro with automatic line feed. */ +#define DRV_LOG(level, ...) \ + PMD_DRV_LOG_(level, mlx5_common_logtype, MLX5_COMMON_LOG_PREFIX, \ + __VA_ARGS__ PMD_DRV_LOG_STRIP PMD_DRV_LOG_OPAREN, \ + PMD_DRV_LOG_CPAREN) + +#endif /* RTE_PMD_MLX5_COMMON_UTILS_H_ */ diff --git a/drivers/net/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c similarity index 99% rename from drivers/net/mlx5/mlx5_devx_cmds.c rename to drivers/common/mlx5/mlx5_devx_cmds.c index 62ca590c30..4d94f923fd 100644 --- a/drivers/net/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -3,12 +3,12 @@ #include -#include +#include #include #include "mlx5_prm.h" #include "mlx5_devx_cmds.h" -#include "mlx5_utils.h" +#include "mlx5_common_utils.h" /** diff --git a/drivers/net/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h similarity index 100% rename from drivers/net/mlx5/mlx5_devx_cmds.h rename to drivers/common/mlx5/mlx5_devx_cmds.h diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/common/mlx5/mlx5_glue.c similarity index 98% rename from drivers/net/mlx5/mlx5_glue.c rename to drivers/common/mlx5/mlx5_glue.c index 4906eebc01..d5bc84e10a 100644 --- a/drivers/net/mlx5/mlx5_glue.c +++ b/drivers/common/mlx5/mlx5_glue.c @@ -8,26 +8,14 @@ #include #include #include - /* * Not needed by this file; included to work around the lack of off_t * definition for mlx5dv.h with unpatched rdma-core versions. */ #include -/* Verbs headers do not support -pedantic. */ -#ifdef PEDANTIC -#pragma GCC diagnostic ignored "-Wpedantic" -#endif -#include -#include -#ifdef PEDANTIC -#pragma GCC diagnostic error "-Wpedantic" -#endif - #include -#include "mlx5_autoconf.h" #include "mlx5_glue.h" static int diff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/common/mlx5/mlx5_glue.h similarity index 99% rename from drivers/net/mlx5/mlx5_glue.h rename to drivers/common/mlx5/mlx5_glue.h index 6771a18c64..f4c31805ff 100644 --- a/drivers/net/mlx5/mlx5_glue.h +++ b/drivers/common/mlx5/mlx5_glue.h @@ -8,9 +8,6 @@ #include #include - -#include "rte_byteorder.h" - /* Verbs headers do not support -pedantic. */ #ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic" @@ -21,6 +18,10 @@ #pragma GCC diagnostic error "-Wpedantic" #endif +#include + +#include "mlx5_autoconf.h" + #ifndef MLX5_GLUE_VERSION #define MLX5_GLUE_VERSION "" #endif diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h similarity index 99% rename from drivers/net/mlx5/mlx5_prm.h rename to drivers/common/mlx5/mlx5_prm.h index 8a67025797..5730ad190d 100644 --- a/drivers/net/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -7,7 +7,6 @@ #define RTE_PMD_MLX5_PRM_H_ #include - /* Verbs header. */ /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */ #ifdef PEDANTIC @@ -19,6 +18,8 @@ #endif #include +#include + #include "mlx5_autoconf.h" /* RSS hash key size. */ diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map b/drivers/common/mlx5/rte_common_mlx5_version.map new file mode 100644 index 0000000000..e4f85e2dc3 --- /dev/null +++ b/drivers/common/mlx5/rte_common_mlx5_version.map @@ -0,0 +1,20 @@ +DPDK_20.02 { + global: + + mlx5_devx_cmd_create_rq; + mlx5_devx_cmd_create_rqt; + mlx5_devx_cmd_create_sq; + mlx5_devx_cmd_create_tir; + mlx5_devx_cmd_create_td; + mlx5_devx_cmd_create_tis; + mlx5_devx_cmd_destroy; + mlx5_devx_cmd_flow_counter_alloc; + mlx5_devx_cmd_flow_counter_query; + mlx5_devx_cmd_flow_dump; + mlx5_devx_cmd_mkey_create; + mlx5_devx_cmd_modify_rq; + mlx5_devx_cmd_modify_sq; + mlx5_devx_cmd_qp_query_tis_td; + mlx5_devx_cmd_query_hca_attr; + mlx5_devx_get_out_command_status; +}; diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index 0466d9d00c..dc6b3c8c38 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -6,15 +6,9 @@ include $(RTE_SDK)/mk/rte.vars.mk # Library name. LIB = librte_pmd_mlx5.a -LIB_GLUE = $(LIB_GLUE_BASE).$(LIB_GLUE_VERSION) -LIB_GLUE_BASE = librte_pmd_mlx5_glue.so -LIB_GLUE_VERSION = 20.02.0 # Sources. SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5.c -ifneq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y) -SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_glue.c -endif SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxq.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_txq.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxtx.c @@ -37,34 +31,22 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_dv.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_verbs.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mp.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_nl.c -SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_devx_cmds.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_utils.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_socket.c -ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y) -INSTALL-$(CONFIG_RTE_LIBRTE_MLX5_PMD)-lib += $(LIB_GLUE) -endif - # Basic CFLAGS. CFLAGS += -O3 CFLAGS += -std=c11 -Wall -Wextra CFLAGS += -g -CFLAGS += -I. +CFLAGS += -I$(RTE_SDK)/drivers/common/mlx5 +CFLAGS += -I$(RTE_SDK)/drivers/net/mlx5 +CFLAGS += -I$(BUILDDIR)/drivers/common/mlx5 CFLAGS += -D_BSD_SOURCE CFLAGS += -D_DEFAULT_SOURCE CFLAGS += -D_XOPEN_SOURCE=600 CFLAGS += $(WERROR_FLAGS) CFLAGS += -Wno-strict-prototypes -ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y) -CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"' -CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"' -CFLAGS_mlx5_glue.o += -fPIC -LDLIBS += -ldl -else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y) -LDLIBS += $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh) -else -LDLIBS += -libverbs -lmlx5 -endif +LDLIBS += -lrte_common_mlx5 LDLIBS += -lm LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs @@ -74,6 +56,7 @@ LDLIBS += -lrte_bus_pci CFLAGS += -Wno-error=cast-qual EXPORT_MAP := rte_pmd_mlx5_version.map + # memseg walk is not part of stable API CFLAGS += -DALLOW_EXPERIMENTAL_API @@ -96,282 +79,3 @@ endif include $(RTE_SDK)/mk/rte.lib.mk -# Generate and clean-up mlx5_autoconf.h. - -export CC CFLAGS CPPFLAGS EXTRA_CFLAGS EXTRA_CPPFLAGS -export AUTO_CONFIG_CFLAGS += -Wno-error - -ifndef V -AUTOCONF_OUTPUT := >/dev/null -endif - -mlx5_autoconf.h.new: FORCE - -mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh - $Q $(RM) -f -- '$@' - $Q sh -- '$<' '$@' \ - HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT \ - infiniband/mlx5dv.h \ - enum MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_DEVICE_TUNNEL_SUPPORT \ - infiniband/mlx5dv.h \ - enum MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_DEVICE_MPLS_SUPPORT \ - infiniband/verbs.h \ - enum IBV_FLOW_SPEC_MPLS \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING \ - infiniband/verbs.h \ - enum IBV_WQ_FLAGS_PCI_WRITE_END_PADDING \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_WQ_FLAG_RX_END_PADDING \ - infiniband/verbs.h \ - enum IBV_WQ_FLAG_RX_END_PADDING \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_MLX5_MOD_SWP \ - infiniband/mlx5dv.h \ - type 'struct mlx5dv_sw_parsing_caps' \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_MLX5_MOD_MPW \ - infiniband/mlx5dv.h \ - enum MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_MLX5_MOD_CQE_128B_COMP \ - infiniband/mlx5dv.h \ - enum MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_MLX5_MOD_CQE_128B_PAD \ - infiniband/mlx5dv.h \ - enum MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_FLOW_DV_SUPPORT \ - infiniband/mlx5dv.h \ - func mlx5dv_create_flow_action_packet_reformat \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_MLX5DV_DR \ - infiniband/mlx5dv.h \ - enum MLX5DV_DR_DOMAIN_TYPE_NIC_RX \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_MLX5DV_DR_ESWITCH \ - infiniband/mlx5dv.h \ - enum MLX5DV_DR_DOMAIN_TYPE_FDB \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_MLX5DV_DR_VLAN \ - infiniband/mlx5dv.h \ - func mlx5dv_dr_action_create_push_vlan \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_MLX5DV_DR_DEVX_PORT \ - infiniband/mlx5dv.h \ - func mlx5dv_query_devx_port \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_DEVX_OBJ \ - infiniband/mlx5dv.h \ - func mlx5dv_devx_obj_create \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_FLOW_DEVX_COUNTERS \ - infiniband/mlx5dv.h \ - enum MLX5DV_FLOW_ACTION_COUNTERS_DEVX \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_DEVX_ASYNC \ - infiniband/mlx5dv.h \ - func mlx5dv_devx_obj_query_async \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR \ - infiniband/mlx5dv.h \ - func mlx5dv_dr_action_create_dest_devx_tir \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER \ - infiniband/mlx5dv.h \ - func mlx5dv_dr_action_create_flow_meter \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_MLX5_DR_FLOW_DUMP \ - infiniband/mlx5dv.h \ - func mlx5dv_dump_dr_domain \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD \ - infiniband/mlx5dv.h \ - enum MLX5_MMAP_GET_NC_PAGES_CMD \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_ETHTOOL_LINK_MODE_25G \ - /usr/include/linux/ethtool.h \ - enum ETHTOOL_LINK_MODE_25000baseCR_Full_BIT \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_ETHTOOL_LINK_MODE_50G \ - /usr/include/linux/ethtool.h \ - enum ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_ETHTOOL_LINK_MODE_100G \ - /usr/include/linux/ethtool.h \ - enum ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_DEVICE_COUNTERS_SET_V42 \ - infiniband/verbs.h \ - type 'struct ibv_counter_set_init_attr' \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IBV_DEVICE_COUNTERS_SET_V45 \ - infiniband/verbs.h \ - type 'struct ibv_counters_init_attr' \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_RDMA_NL_NLDEV \ - rdma/rdma_netlink.h \ - enum RDMA_NL_NLDEV \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_RDMA_NLDEV_CMD_GET \ - rdma/rdma_netlink.h \ - enum RDMA_NLDEV_CMD_GET \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_RDMA_NLDEV_CMD_PORT_GET \ - rdma/rdma_netlink.h \ - enum RDMA_NLDEV_CMD_PORT_GET \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_RDMA_NLDEV_ATTR_DEV_INDEX \ - rdma/rdma_netlink.h \ - enum RDMA_NLDEV_ATTR_DEV_INDEX \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_RDMA_NLDEV_ATTR_DEV_NAME \ - rdma/rdma_netlink.h \ - enum RDMA_NLDEV_ATTR_DEV_NAME \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_RDMA_NLDEV_ATTR_PORT_INDEX \ - rdma/rdma_netlink.h \ - enum RDMA_NLDEV_ATTR_PORT_INDEX \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX \ - rdma/rdma_netlink.h \ - enum RDMA_NLDEV_ATTR_NDEV_INDEX \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IFLA_NUM_VF \ - linux/if_link.h \ - enum IFLA_NUM_VF \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IFLA_EXT_MASK \ - linux/if_link.h \ - enum IFLA_EXT_MASK \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IFLA_PHYS_SWITCH_ID \ - linux/if_link.h \ - enum IFLA_PHYS_SWITCH_ID \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_IFLA_PHYS_PORT_NAME \ - linux/if_link.h \ - enum IFLA_PHYS_PORT_NAME \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_SUPPORTED_40000baseKR4_Full \ - /usr/include/linux/ethtool.h \ - define SUPPORTED_40000baseKR4_Full \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_SUPPORTED_40000baseCR4_Full \ - /usr/include/linux/ethtool.h \ - define SUPPORTED_40000baseCR4_Full \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_SUPPORTED_40000baseSR4_Full \ - /usr/include/linux/ethtool.h \ - define SUPPORTED_40000baseSR4_Full \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_SUPPORTED_40000baseLR4_Full \ - /usr/include/linux/ethtool.h \ - define SUPPORTED_40000baseLR4_Full \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_SUPPORTED_56000baseKR4_Full \ - /usr/include/linux/ethtool.h \ - define SUPPORTED_56000baseKR4_Full \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_SUPPORTED_56000baseCR4_Full \ - /usr/include/linux/ethtool.h \ - define SUPPORTED_56000baseCR4_Full \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_SUPPORTED_56000baseSR4_Full \ - /usr/include/linux/ethtool.h \ - define SUPPORTED_56000baseSR4_Full \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_SUPPORTED_56000baseLR4_Full \ - /usr/include/linux/ethtool.h \ - define SUPPORTED_56000baseLR4_Full \ - $(AUTOCONF_OUTPUT) - $Q sh -- '$<' '$@' \ - HAVE_STATIC_ASSERT \ - /usr/include/assert.h \ - define static_assert \ - $(AUTOCONF_OUTPUT) - -# Create mlx5_autoconf.h or update it in case it differs from the new one. - -mlx5_autoconf.h: mlx5_autoconf.h.new - $Q [ -f '$@' ] && \ - cmp '$<' '$@' $(AUTOCONF_OUTPUT) || \ - mv '$<' '$@' - -$(SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD):.c=.o): mlx5_autoconf.h - -# Generate dependency plug-in for rdma-core when the PMD must not be linked -# directly, so that applications do not inherit this dependency. - -ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y) - -$(LIB): $(LIB_GLUE) - -ifeq ($(LINK_USING_CC),1) -GLUE_LDFLAGS := $(call linkerprefix,$(LDFLAGS)) -else -GLUE_LDFLAGS := $(LDFLAGS) -endif -$(LIB_GLUE): mlx5_glue.o - $Q $(LD) $(GLUE_LDFLAGS) $(EXTRA_LDFLAGS) \ - -Wl,-h,$(LIB_GLUE) \ - -shared -o $@ $< -libverbs -lmlx5 - -mlx5_glue.o: mlx5_autoconf.h - -endif - -clean_mlx5: FORCE - $Q rm -f -- mlx5_autoconf.h mlx5_autoconf.h.new - $Q rm -f -- mlx5_glue.o $(LIB_GLUE_BASE)* - -clean: clean_mlx5 diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build index 3ad4f02a53..e10ef3ab2d 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -7,224 +7,50 @@ if not is_linux reason = 'only supported on Linux' subdir_done() endif -build = true -pmd_dlopen = (get_option('ibverbs_link') == 'dlopen') -LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so' -LIB_GLUE_VERSION = '20.02.0' -LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION -if pmd_dlopen - dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1) - cflags += [ - '-DMLX5_GLUE="@0@"'.format(LIB_GLUE), - '-DMLX5_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION), - ] +allow_experimental_apis = true +deps += ['hash', 'common_mlx5'] +sources = files( + 'mlx5.c', + 'mlx5_ethdev.c', + 'mlx5_flow.c', + 'mlx5_flow_meter.c', + 'mlx5_flow_dv.c', + 'mlx5_flow_verbs.c', + 'mlx5_mac.c', + 'mlx5_mr.c', + 'mlx5_nl.c', + 'mlx5_rss.c', + 'mlx5_rxmode.c', + 'mlx5_rxq.c', + 'mlx5_rxtx.c', + 'mlx5_mp.c', + 'mlx5_stats.c', + 'mlx5_trigger.c', + 'mlx5_txq.c', + 'mlx5_vlan.c', + 'mlx5_utils.c', + 'mlx5_socket.c', +) +if (dpdk_conf.has('RTE_ARCH_X86_64') + or dpdk_conf.has('RTE_ARCH_ARM64') + or dpdk_conf.has('RTE_ARCH_PPC_64')) + sources += files('mlx5_rxtx_vec.c') endif - -libnames = [ 'mlx5', 'ibverbs' ] -libs = [] -foreach libname:libnames - lib = dependency('lib' + libname, required:false) - if not lib.found() - lib = cc.find_library(libname, required:false) - endif - if lib.found() - libs += [ lib ] - else - build = false - reason = 'missing dependency, "' + libname + '"' +cflags_options = [ + '-std=c11', + '-Wno-strict-prototypes', + '-D_BSD_SOURCE', + '-D_DEFAULT_SOURCE', + '-D_XOPEN_SOURCE=600' +] +foreach option:cflags_options + if cc.has_argument(option) + cflags += option endif endforeach - -if build - allow_experimental_apis = true - deps += ['hash'] - ext_deps += libs - sources = files( - 'mlx5.c', - 'mlx5_ethdev.c', - 'mlx5_flow.c', - 'mlx5_flow_meter.c', - 'mlx5_flow_dv.c', - 'mlx5_flow_verbs.c', - 'mlx5_mac.c', - 'mlx5_mr.c', - 'mlx5_nl.c', - 'mlx5_rss.c', - 'mlx5_rxmode.c', - 'mlx5_rxq.c', - 'mlx5_rxtx.c', - 'mlx5_mp.c', - 'mlx5_stats.c', - 'mlx5_trigger.c', - 'mlx5_txq.c', - 'mlx5_vlan.c', - 'mlx5_devx_cmds.c', - 'mlx5_utils.c', - 'mlx5_socket.c', - ) - if (dpdk_conf.has('RTE_ARCH_X86_64') - or dpdk_conf.has('RTE_ARCH_ARM64') - or dpdk_conf.has('RTE_ARCH_PPC_64')) - sources += files('mlx5_rxtx_vec.c') - endif - if not pmd_dlopen - sources += files('mlx5_glue.c') - endif - cflags_options = [ - '-std=c11', - '-Wno-strict-prototypes', - '-D_BSD_SOURCE', - '-D_DEFAULT_SOURCE', - '-D_XOPEN_SOURCE=600' - ] - foreach option:cflags_options - if cc.has_argument(option) - cflags += option - endif - endforeach - if get_option('buildtype').contains('debug') - cflags += [ '-pedantic', '-UNDEBUG', '-DPEDANTIC' ] - else - cflags += [ '-DNDEBUG', '-UPEDANTIC' ] - endif - # To maintain the compatibility with the make build system - # mlx5_autoconf.h file is still generated. - # input array for meson member search: - # [ "MACRO to define if found", "header for the search", - # "symbol to search", "struct member to search" ] - has_member_args = [ - [ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h', - 'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ], - [ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h', - 'struct ibv_counter_set_init_attr', 'counter_set_id' ], - [ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45', 'infiniband/verbs.h', - 'struct ibv_counters_init_attr', 'comp_mask' ], - ] - # input array for meson symbol search: - # [ "MACRO to define if found", "header for the search", - # "symbol to search" ] - has_sym_args = [ - [ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT', 'infiniband/mlx5dv.h', - 'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ], - [ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT', 'infiniband/mlx5dv.h', - 'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ], - [ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h', - 'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ], - [ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h', - 'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ], - [ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD', 'infiniband/mlx5dv.h', - 'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ], - [ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h', - 'mlx5dv_create_flow_action_packet_reformat' ], - [ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h', - 'IBV_FLOW_SPEC_MPLS' ], - [ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING', 'infiniband/verbs.h', - 'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ], - [ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h', - 'IBV_WQ_FLAG_RX_END_PADDING' ], - [ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h', - 'mlx5dv_query_devx_port' ], - [ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h', - 'mlx5dv_devx_obj_create' ], - [ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h', - 'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ], - [ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h', - 'mlx5dv_devx_obj_query_async' ], - [ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR', 'infiniband/mlx5dv.h', - 'mlx5dv_dr_action_create_dest_devx_tir' ], - [ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER', 'infiniband/mlx5dv.h', - 'mlx5dv_dr_action_create_flow_meter' ], - [ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD', 'infiniband/mlx5dv.h', - 'MLX5_MMAP_GET_NC_PAGES_CMD' ], - [ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h', - 'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ], - [ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h', - 'MLX5DV_DR_DOMAIN_TYPE_FDB' ], - [ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h', - 'mlx5dv_dr_action_create_push_vlan' ], - [ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h', - 'SUPPORTED_40000baseKR4_Full' ], - [ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h', - 'SUPPORTED_40000baseCR4_Full' ], - [ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h', - 'SUPPORTED_40000baseSR4_Full' ], - [ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h', - 'SUPPORTED_40000baseLR4_Full' ], - [ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h', - 'SUPPORTED_56000baseKR4_Full' ], - [ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h', - 'SUPPORTED_56000baseCR4_Full' ], - [ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h', - 'SUPPORTED_56000baseSR4_Full' ], - [ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h', - 'SUPPORTED_56000baseLR4_Full' ], - [ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h', - 'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ], - [ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h', - 'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ], - [ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h', - 'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ], - [ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h', - 'IFLA_NUM_VF' ], - [ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h', - 'IFLA_EXT_MASK' ], - [ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h', - 'IFLA_PHYS_SWITCH_ID' ], - [ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h', - 'IFLA_PHYS_PORT_NAME' ], - [ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h', - 'RDMA_NL_NLDEV' ], - [ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h', - 'RDMA_NLDEV_CMD_GET' ], - [ 'HAVE_RDMA_NLDEV_CMD_PORT_GET', 'rdma/rdma_netlink.h', - 'RDMA_NLDEV_CMD_PORT_GET' ], - [ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX', 'rdma/rdma_netlink.h', - 'RDMA_NLDEV_ATTR_DEV_INDEX' ], - [ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME', 'rdma/rdma_netlink.h', - 'RDMA_NLDEV_ATTR_DEV_NAME' ], - [ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX', 'rdma/rdma_netlink.h', - 'RDMA_NLDEV_ATTR_PORT_INDEX' ], - [ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX', 'rdma/rdma_netlink.h', - 'RDMA_NLDEV_ATTR_NDEV_INDEX' ], - [ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h', - 'mlx5dv_dump_dr_domain'], - ] - config = configuration_data() - foreach arg:has_sym_args - config.set(arg[0], cc.has_header_symbol(arg[1], arg[2], - dependencies: libs)) - endforeach - foreach arg:has_member_args - file_prefix = '#include <' + arg[1] + '>' - config.set(arg[0], cc.has_member(arg[2], arg[3], - prefix : file_prefix, dependencies: libs)) - endforeach - configure_file(output : 'mlx5_autoconf.h', configuration : config) -endif -# Build Glue Library -if pmd_dlopen and build - dlopen_name = 'mlx5_glue' - dlopen_lib_name = driver_name_fmt.format(dlopen_name) - dlopen_so_version = LIB_GLUE_VERSION - dlopen_sources = files('mlx5_glue.c') - dlopen_install_dir = [ eal_pmd_path + '-glue' ] - dlopen_includes = [global_inc] - dlopen_includes += include_directories( - '../../../lib/librte_eal/common/include/generic', - ) - shared_lib = shared_library( - dlopen_lib_name, - dlopen_sources, - include_directories: dlopen_includes, - c_args: cflags, - dependencies: libs, - link_args: [ - '-Wl,-export-dynamic', - '-Wl,-h,@0@'.format(LIB_GLUE), - ], - soversion: dlopen_so_version, - install: true, - install_dir: dlopen_install_dir, - ) +if get_option('buildtype').contains('debug') + cflags += [ '-pedantic', '-UNDEBUG', '-DPEDANTIC' ] +else + cflags += [ '-DNDEBUG', '-UPEDANTIC' ] endif diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 7126edff02..8fbe8268f0 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -38,15 +37,16 @@ #include #include +#include +#include + +#include "mlx5_defs.h" #include "mlx5.h" #include "mlx5_utils.h" #include "mlx5_rxtx.h" #include "mlx5_autoconf.h" -#include "mlx5_defs.h" -#include "mlx5_glue.h" #include "mlx5_mr.h" #include "mlx5_flow.h" -#include "mlx5_devx_cmds.h" /* Device parameter to enable RX completion queue compression. */ #define MLX5_RXQ_CQE_COMP_EN "rxq_cqe_comp_en" @@ -3504,138 +3504,6 @@ static struct rte_pci_driver mlx5_driver = { RTE_PCI_DRV_PROBE_AGAIN, }; -#ifdef RTE_IBVERBS_LINK_DLOPEN - -/** - * Suffix RTE_EAL_PMD_PATH with "-glue". - * - * This function performs a sanity check on RTE_EAL_PMD_PATH before - * suffixing its last component. - * - * @param buf[out] - * Output buffer, should be large enough otherwise NULL is returned. - * @param size - * Size of @p out. - * - * @return - * Pointer to @p buf or @p NULL in case suffix cannot be appended. - */ -static char * -mlx5_glue_path(char *buf, size_t size) -{ - static const char *const bad[] = { "/", ".", "..", NULL }; - const char *path = RTE_EAL_PMD_PATH; - size_t len = strlen(path); - size_t off; - int i; - - while (len && path[len - 1] == '/') - --len; - for (off = len; off && path[off - 1] != '/'; --off) - ; - for (i = 0; bad[i]; ++i) - if (!strncmp(path + off, bad[i], (int)(len - off))) - goto error; - i = snprintf(buf, size, "%.*s-glue", (int)len, path); - if (i == -1 || (size_t)i >= size) - goto error; - return buf; -error: - DRV_LOG(ERR, - "unable to append \"-glue\" to last component of" - " RTE_EAL_PMD_PATH (\"" RTE_EAL_PMD_PATH "\")," - " please re-configure DPDK"); - return NULL; -} - -/** - * Initialization routine for run-time dependency on rdma-core. - */ -static int -mlx5_glue_init(void) -{ - char glue_path[sizeof(RTE_EAL_PMD_PATH) - 1 + sizeof("-glue")]; - const char *path[] = { - /* - * A basic security check is necessary before trusting - * MLX5_GLUE_PATH, which may override RTE_EAL_PMD_PATH. - */ - (geteuid() == getuid() && getegid() == getgid() ? - getenv("MLX5_GLUE_PATH") : NULL), - /* - * When RTE_EAL_PMD_PATH is set, use its glue-suffixed - * variant, otherwise let dlopen() look up libraries on its - * own. - */ - (*RTE_EAL_PMD_PATH ? - mlx5_glue_path(glue_path, sizeof(glue_path)) : ""), - }; - unsigned int i = 0; - void *handle = NULL; - void **sym; - const char *dlmsg; - - while (!handle && i != RTE_DIM(path)) { - const char *end; - size_t len; - int ret; - - if (!path[i]) { - ++i; - continue; - } - end = strpbrk(path[i], ":;"); - if (!end) - end = path[i] + strlen(path[i]); - len = end - path[i]; - ret = 0; - do { - char name[ret + 1]; - - ret = snprintf(name, sizeof(name), "%.*s%s" MLX5_GLUE, - (int)len, path[i], - (!len || *(end - 1) == '/') ? "" : "/"); - if (ret == -1) - break; - if (sizeof(name) != (size_t)ret + 1) - continue; - DRV_LOG(DEBUG, "looking for rdma-core glue as \"%s\"", - name); - handle = dlopen(name, RTLD_LAZY); - break; - } while (1); - path[i] = end + 1; - if (!*end) - ++i; - } - if (!handle) { - rte_errno = EINVAL; - dlmsg = dlerror(); - if (dlmsg) - DRV_LOG(WARNING, "cannot load glue library: %s", dlmsg); - goto glue_error; - } - sym = dlsym(handle, "mlx5_glue"); - if (!sym || !*sym) { - rte_errno = EINVAL; - dlmsg = dlerror(); - if (dlmsg) - DRV_LOG(ERR, "cannot resolve glue symbol: %s", dlmsg); - goto glue_error; - } - mlx5_glue = *sym; - return 0; -glue_error: - if (handle) - dlclose(handle); - DRV_LOG(WARNING, - "cannot initialize PMD due to missing run-time dependency on" - " rdma-core libraries (libibverbs, libmlx5)"); - return -rte_errno; -} - -#endif - /** * Driver initialization routine. */ @@ -3650,43 +3518,8 @@ RTE_INIT(rte_mlx5_pmd_init) mlx5_set_ptype_table(); mlx5_set_cksum_table(); mlx5_set_swp_types_table(); - /* - * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use - * huge pages. Calling ibv_fork_init() during init allows - * applications to use fork() safely for purposes other than - * using this PMD, which is not supported in forked processes. - */ - setenv("RDMAV_HUGEPAGES_SAFE", "1", 1); - /* Match the size of Rx completion entry to the size of a cacheline. */ - if (RTE_CACHE_LINE_SIZE == 128) - setenv("MLX5_CQE_SIZE", "128", 0); - /* - * MLX5_DEVICE_FATAL_CLEANUP tells ibv_destroy functions to - * cleanup all the Verbs resources even when the device was removed. - */ - setenv("MLX5_DEVICE_FATAL_CLEANUP", "1", 1); -#ifdef RTE_IBVERBS_LINK_DLOPEN - if (mlx5_glue_init()) - return; - assert(mlx5_glue); -#endif -#ifndef NDEBUG - /* Glue structure must not contain any NULL pointers. */ - { - unsigned int i; - - for (i = 0; i != sizeof(*mlx5_glue) / sizeof(void *); ++i) - assert(((const void *const *)mlx5_glue)[i]); - } -#endif - if (strcmp(mlx5_glue->version, MLX5_GLUE_VERSION)) { - DRV_LOG(ERR, - "rdma-core glue \"%s\" mismatch: \"%s\" is required", - mlx5_glue->version, MLX5_GLUE_VERSION); - return; - } - mlx5_glue->fork_init(); - rte_pci_register(&mlx5_driver); + if (mlx5_glue) + rte_pci_register(&mlx5_driver); } RTE_PMD_EXPORT_NAME(net_mlx5, __COUNTER__); diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 4d0485d1cd..872fccb971 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -32,13 +32,14 @@ #include #include +#include +#include +#include + +#include "mlx5_defs.h" #include "mlx5_utils.h" #include "mlx5_mr.h" #include "mlx5_autoconf.h" -#include "mlx5_defs.h" -#include "mlx5_glue.h" -#include "mlx5_prm.h" -#include "mlx5_devx_cmds.h" enum { PCI_VENDOR_ID_MELLANOX = 0x15b3, diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index ce0109c29e..eddf888e10 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -36,9 +36,10 @@ #include #include +#include +#include + #include "mlx5.h" -#include "mlx5_glue.h" -#include "mlx5_devx_cmds.h" #include "mlx5_rxtx.h" #include "mlx5_utils.h" diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 983b1c3ad2..47ba521a77 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -27,12 +27,13 @@ #include #include -#include "mlx5.h" +#include +#include +#include + #include "mlx5_defs.h" +#include "mlx5.h" #include "mlx5_flow.h" -#include "mlx5_glue.h" -#include "mlx5_devx_cmds.h" -#include "mlx5_prm.h" #include "mlx5_rxtx.h" /* Dev ops structure defined in mlx5.c */ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 39be5ba095..4255472e54 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -25,8 +25,9 @@ #include #include +#include + #include "mlx5.h" -#include "mlx5_prm.h" /* Private rte flow items. */ enum mlx5_rte_flow_item_type { diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 653d64900a..1b3160280d 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -29,12 +29,13 @@ #include #include -#include "mlx5.h" +#include +#include +#include + #include "mlx5_defs.h" -#include "mlx5_glue.h" -#include "mlx5_devx_cmds.h" +#include "mlx5.h" #include "mlx5_flow.h" -#include "mlx5_prm.h" #include "mlx5_rxtx.h" #ifdef HAVE_IBV_FLOW_DV_SUPPORT diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index c4d28b282e..32d51c0b19 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -9,6 +9,8 @@ #include #include +#include + #include "mlx5.h" #include "mlx5_flow.h" diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 72fb1e4669..92314512ab 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -26,11 +26,12 @@ #include #include -#include "mlx5.h" +#include +#include + #include "mlx5_defs.h" +#include "mlx5.h" #include "mlx5_flow.h" -#include "mlx5_glue.h" -#include "mlx5_prm.h" #include "mlx5_rxtx.h" #define VERBS_SPEC_INNER(item_flags) \ diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c index 7bdaa2a392..a646b9074d 100644 --- a/drivers/net/mlx5/mlx5_mac.c +++ b/drivers/net/mlx5/mlx5_mac.c @@ -27,10 +27,10 @@ #include #include +#include "mlx5_defs.h" #include "mlx5.h" #include "mlx5_utils.h" #include "mlx5_rxtx.h" -#include "mlx5_defs.h" /** * Get MAC address by querying netdevice. diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index 0d549b68e6..b1cd9f76cc 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -17,10 +17,11 @@ #include #include +#include + #include "mlx5.h" #include "mlx5_mr.h" #include "mlx5_rxtx.h" -#include "mlx5_glue.h" struct mr_find_contig_memsegs_data { uintptr_t addr; diff --git a/drivers/net/mlx5/mlx5_rss.c b/drivers/net/mlx5/mlx5_rss.c index 102826452d..345ce3abd4 100644 --- a/drivers/net/mlx5/mlx5_rss.c +++ b/drivers/net/mlx5/mlx5_rss.c @@ -22,8 +22,8 @@ #include #include -#include "mlx5.h" #include "mlx5_defs.h" +#include "mlx5.h" #include "mlx5_rxtx.h" /** diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 371b996100..e01cbfdd61 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -30,14 +30,16 @@ #include #include +#include +#include + +#include "mlx5_defs.h" #include "mlx5.h" #include "mlx5_rxtx.h" #include "mlx5_utils.h" #include "mlx5_autoconf.h" -#include "mlx5_defs.h" -#include "mlx5_glue.h" #include "mlx5_flow.h" -#include "mlx5_devx_cmds.h" + /* Default RSS hash key also used for ConnectX-3. */ uint8_t rss_hash_default_key[] = { diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 5a03556048..d8f6671e27 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -28,13 +28,14 @@ #include #include +#include +#include + +#include "mlx5_defs.h" #include "mlx5.h" -#include "mlx5_devx_cmds.h" #include "mlx5_utils.h" #include "mlx5_rxtx.h" #include "mlx5_autoconf.h" -#include "mlx5_defs.h" -#include "mlx5_prm.h" /* TX burst subroutines return codes. */ enum mlx5_txcmp_code { diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 3f659d293c..fb13919ee1 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -31,13 +31,14 @@ #include #include +#include +#include + +#include "mlx5_defs.h" #include "mlx5_utils.h" #include "mlx5.h" #include "mlx5_mr.h" #include "mlx5_autoconf.h" -#include "mlx5_defs.h" -#include "mlx5_prm.h" -#include "mlx5_glue.h" /* Support tunnel matching. */ #define MLX5_FLOW_TUNNEL 10 diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.c b/drivers/net/mlx5/mlx5_rxtx_vec.c index d85f90874d..550576260f 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec.c +++ b/drivers/net/mlx5/mlx5_rxtx_vec.c @@ -23,13 +23,14 @@ #include #include +#include + +#include "mlx5_defs.h" #include "mlx5.h" #include "mlx5_utils.h" #include "mlx5_rxtx.h" #include "mlx5_rxtx_vec.h" #include "mlx5_autoconf.h" -#include "mlx5_defs.h" -#include "mlx5_prm.h" #if defined RTE_ARCH_X86_64 #include "mlx5_rxtx_vec_sse.h" diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.h b/drivers/net/mlx5/mlx5_rxtx_vec.h index d8c07f285a..82f77e5e37 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec.h @@ -9,8 +9,9 @@ #include #include +#include + #include "mlx5_autoconf.h" -#include "mlx5_prm.h" /* HW checksum offload capabilities of vectorized Tx. */ #define MLX5_VEC_TX_CKSUM_OFFLOAD_CAP \ diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h index 9e5c6ee7ab..1467a42b5e 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h @@ -17,13 +17,14 @@ #include #include +#include + +#include "mlx5_defs.h" #include "mlx5.h" #include "mlx5_utils.h" #include "mlx5_rxtx.h" #include "mlx5_rxtx_vec.h" #include "mlx5_autoconf.h" -#include "mlx5_defs.h" -#include "mlx5_prm.h" #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wcast-qual" diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h index 332e9ac406..5b846c1747 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h @@ -16,13 +16,14 @@ #include #include +#include + +#include "mlx5_defs.h" #include "mlx5.h" #include "mlx5_utils.h" #include "mlx5_rxtx.h" #include "mlx5_rxtx_vec.h" #include "mlx5_autoconf.h" -#include "mlx5_defs.h" -#include "mlx5_prm.h" #pragma GCC diagnostic ignored "-Wcast-qual" diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h index 07d40d5f48..6e1b967a36 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h @@ -16,13 +16,14 @@ #include #include +#include + +#include "mlx5_defs.h" #include "mlx5.h" #include "mlx5_utils.h" #include "mlx5_rxtx.h" #include "mlx5_rxtx_vec.h" #include "mlx5_autoconf.h" -#include "mlx5_defs.h" -#include "mlx5_prm.h" #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wcast-qual" diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c index 205e4fec78..0ed717033e 100644 --- a/drivers/net/mlx5/mlx5_stats.c +++ b/drivers/net/mlx5/mlx5_stats.c @@ -13,9 +13,9 @@ #include #include +#include "mlx5_defs.h" #include "mlx5.h" #include "mlx5_rxtx.h" -#include "mlx5_defs.h" static const struct mlx5_counter_ctrl mlx5_counters_init[] = { { diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index 5adb4dc887..1d2ba8af58 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -28,13 +28,14 @@ #include #include -#include "mlx5_utils.h" +#include +#include + #include "mlx5_defs.h" +#include "mlx5_utils.h" #include "mlx5.h" #include "mlx5_rxtx.h" #include "mlx5_autoconf.h" -#include "mlx5_glue.h" -#include "mlx5_devx_cmds.h" /** * Allocate TX queue elements. diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h index ebf79b80a4..c868aee3d8 100644 --- a/drivers/net/mlx5/mlx5_utils.h +++ b/drivers/net/mlx5/mlx5_utils.h @@ -13,8 +13,11 @@ #include #include +#include + #include "mlx5_defs.h" + /* * Compilation workaround for PPC64 when AltiVec is fully enabled, e.g. std=c11. * Otherwise there would be a type conflict between stdbool and altivec. @@ -50,81 +53,14 @@ /* Save and restore errno around argument evaluation. */ #define ERRNO_SAFE(x) ((errno = (int []){ errno, ((x), 0) }[0])) -/* - * Helper macros to work around __VA_ARGS__ limitations in a C99 compliant - * manner. - */ -#define PMD_DRV_LOG_STRIP(a, b) a -#define PMD_DRV_LOG_OPAREN ( -#define PMD_DRV_LOG_CPAREN ) -#define PMD_DRV_LOG_COMMA , - -/* Return the file name part of a path. */ -static inline const char * -pmd_drv_log_basename(const char *s) -{ - const char *n = s; - - while (*n) - if (*(n++) == '/') - s = n; - return s; -} - extern int mlx5_logtype; -#define PMD_DRV_LOG___(level, ...) \ - rte_log(RTE_LOG_ ## level, \ - mlx5_logtype, \ - RTE_FMT(MLX5_DRIVER_NAME ": " \ - RTE_FMT_HEAD(__VA_ARGS__,), \ - RTE_FMT_TAIL(__VA_ARGS__,))) - -/* - * When debugging is enabled (NDEBUG not defined), file, line and function - * information replace the driver name (MLX5_DRIVER_NAME) in log messages. - */ -#ifndef NDEBUG - -#define PMD_DRV_LOG__(level, ...) \ - PMD_DRV_LOG___(level, "%s:%u: %s(): " __VA_ARGS__) -#define PMD_DRV_LOG_(level, s, ...) \ - PMD_DRV_LOG__(level, \ - s "\n" PMD_DRV_LOG_COMMA \ - pmd_drv_log_basename(__FILE__) PMD_DRV_LOG_COMMA \ - __LINE__ PMD_DRV_LOG_COMMA \ - __func__, \ - __VA_ARGS__) - -#else /* NDEBUG */ -#define PMD_DRV_LOG__(level, ...) \ - PMD_DRV_LOG___(level, __VA_ARGS__) -#define PMD_DRV_LOG_(level, s, ...) \ - PMD_DRV_LOG__(level, s "\n", __VA_ARGS__) - -#endif /* NDEBUG */ - /* Generic printf()-like logging macro with automatic line feed. */ #define DRV_LOG(level, ...) \ - PMD_DRV_LOG_(level, \ + PMD_DRV_LOG_(level, mlx5_logtype, MLX5_DRIVER_NAME, \ __VA_ARGS__ PMD_DRV_LOG_STRIP PMD_DRV_LOG_OPAREN, \ PMD_DRV_LOG_CPAREN) -/* claim_zero() does not perform any check when debugging is disabled. */ -#ifndef NDEBUG - -#define DEBUG(...) DRV_LOG(DEBUG, __VA_ARGS__) -#define claim_zero(...) assert((__VA_ARGS__) == 0) -#define claim_nonzero(...) assert((__VA_ARGS__) != 0) - -#else /* NDEBUG */ - -#define DEBUG(...) (void)0 -#define claim_zero(...) (__VA_ARGS__) -#define claim_nonzero(...) (__VA_ARGS__) - -#endif /* NDEBUG */ - #define INFO(...) DRV_LOG(INFO, __VA_ARGS__) #define WARN(...) DRV_LOG(WARNING, __VA_ARGS__) #define ERROR(...) DRV_LOG(ERR, __VA_ARGS__) @@ -144,13 +80,6 @@ extern int mlx5_logtype; (((val) & (from)) / ((from) / (to))) : \ (((val) & (from)) * ((to) / (from)))) -/* Allocate a buffer on the stack and fill it with a printf format string. */ -#define MKSTR(name, ...) \ - int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \ - char name[mkstr_size_##name + 1]; \ - \ - snprintf(name, sizeof(name), "" __VA_ARGS__) - /** * Return logarithm of the nearest power of two above input value. * diff --git a/drivers/net/mlx5/mlx5_vlan.c b/drivers/net/mlx5/mlx5_vlan.c index feac0f150f..b0fa31a6e5 100644 --- a/drivers/net/mlx5/mlx5_vlan.c +++ b/drivers/net/mlx5/mlx5_vlan.c @@ -27,10 +27,11 @@ #include #include +#include +#include + #include "mlx5.h" #include "mlx5_autoconf.h" -#include "mlx5_glue.h" -#include "mlx5_devx_cmds.h" #include "mlx5_rxtx.h" #include "mlx5_utils.h" diff --git a/mk/rte.app.mk b/mk/rte.app.mk index 15acf95db6..45f4cad2a1 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -196,6 +196,7 @@ endif _LDLIBS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += -lrte_pmd_lio _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_MEMIF) += -lrte_pmd_memif _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += -lrte_pmd_mlx4 +_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += -lrte_common_mlx5 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += -lrte_pmd_mlx5 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += -ldl -- 2.20.1