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 <matan@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
This commit is contained in:
Matan Azrad 2020-01-29 12:38:27 +00:00 committed by Ferruh Yigit
parent 543e218fa5
commit 7b4f1e6bd3
40 changed files with 986 additions and 829 deletions

View File

@ -741,6 +741,7 @@ M: Matan Azrad <matan@mellanox.com>
M: Shahaf Shuler <shahafs@mellanox.com>
M: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
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

View File

@ -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

View File

@ -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@'

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,186 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright 2019 Mellanox Technologies, Ltd
*/
#include <dlfcn.h>
#include <unistd.h>
#include <string.h>
#include <rte_errno.h>
#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;
}

View File

@ -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 <assert.h>
#include <rte_log.h>
/*
* 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_ */

View File

@ -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_ */

View File

@ -3,12 +3,12 @@
#include <unistd.h>
#include <rte_flow_driver.h>
#include <rte_errno.h>
#include <rte_malloc.h>
#include "mlx5_prm.h"
#include "mlx5_devx_cmds.h"
#include "mlx5_utils.h"
#include "mlx5_common_utils.h"
/**

View File

@ -8,26 +8,14 @@
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
/*
* Not needed by this file; included to work around the lack of off_t
* definition for mlx5dv.h with unpatched rdma-core versions.
*/
#include <sys/types.h>
/* Verbs headers do not support -pedantic. */
#ifdef PEDANTIC
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#include <infiniband/mlx5dv.h>
#include <infiniband/verbs.h>
#ifdef PEDANTIC
#pragma GCC diagnostic error "-Wpedantic"
#endif
#include <rte_config.h>
#include "mlx5_autoconf.h"
#include "mlx5_glue.h"
static int

View File

@ -8,9 +8,6 @@
#include <stddef.h>
#include <stdint.h>
#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 <rte_byteorder.h>
#include "mlx5_autoconf.h"
#ifndef MLX5_GLUE_VERSION
#define MLX5_GLUE_VERSION ""
#endif

View File

@ -7,7 +7,6 @@
#define RTE_PMD_MLX5_PRM_H_
#include <assert.h>
/* Verbs header. */
/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
#ifdef PEDANTIC
@ -19,6 +18,8 @@
#endif
#include <rte_vect.h>
#include <rte_byteorder.h>
#include "mlx5_autoconf.h"
/* RSS hash key size. */

View File

@ -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;
};

View File

@ -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

View File

@ -7,39 +7,9 @@ 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),
]
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']
ext_deps += libs
deps += ['hash', 'common_mlx5']
sources = files(
'mlx5.c',
'mlx5_ethdev.c',
@ -59,7 +29,6 @@ if build
'mlx5_trigger.c',
'mlx5_txq.c',
'mlx5_vlan.c',
'mlx5_devx_cmds.c',
'mlx5_utils.c',
'mlx5_socket.c',
)
@ -68,9 +37,6 @@ if build
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',
@ -88,143 +54,3 @@ if build
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

View File

@ -7,7 +7,6 @@
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <dlfcn.h>
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
@ -38,15 +37,16 @@
#include <rte_string_fns.h>
#include <rte_alarm.h>
#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
#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,42 +3518,7 @@ 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();
if (mlx5_glue)
rte_pci_register(&mlx5_driver);
}

View File

@ -32,13 +32,14 @@
#include <rte_errno.h>
#include <rte_flow.h>
#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
#include <mlx5_prm.h>
#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,

View File

@ -36,9 +36,10 @@
#include <rte_rwlock.h>
#include <rte_cycles.h>
#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
#include "mlx5.h"
#include "mlx5_glue.h"
#include "mlx5_devx_cmds.h"
#include "mlx5_rxtx.h"
#include "mlx5_utils.h"

View File

@ -27,12 +27,13 @@
#include <rte_malloc.h>
#include <rte_ip.h>
#include "mlx5.h"
#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
#include <mlx5_prm.h>
#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 */

View File

@ -25,8 +25,9 @@
#include <rte_alarm.h>
#include <rte_mtr.h>
#include <mlx5_prm.h>
#include "mlx5.h"
#include "mlx5_prm.h"
/* Private rte flow items. */
enum mlx5_rte_flow_item_type {

View File

@ -29,12 +29,13 @@
#include <rte_vxlan.h>
#include <rte_gtp.h>
#include "mlx5.h"
#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
#include <mlx5_prm.h>
#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

View File

@ -9,6 +9,8 @@
#include <rte_mtr.h>
#include <rte_mtr_driver.h>
#include <mlx5_devx_cmds.h>
#include "mlx5.h"
#include "mlx5_flow.h"

View File

@ -26,11 +26,12 @@
#include <rte_malloc.h>
#include <rte_ip.h>
#include "mlx5.h"
#include <mlx5_glue.h>
#include <mlx5_prm.h>
#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) \

View File

@ -27,10 +27,10 @@
#include <rte_ethdev_driver.h>
#include <rte_common.h>
#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.

View File

@ -17,10 +17,11 @@
#include <rte_rwlock.h>
#include <rte_bus_pci.h>
#include <mlx5_glue.h>
#include "mlx5.h"
#include "mlx5_mr.h"
#include "mlx5_rxtx.h"
#include "mlx5_glue.h"
struct mr_find_contig_memsegs_data {
uintptr_t addr;

View File

@ -22,8 +22,8 @@
#include <rte_malloc.h>
#include <rte_ethdev_driver.h>
#include "mlx5.h"
#include "mlx5_defs.h"
#include "mlx5.h"
#include "mlx5_rxtx.h"
/**

View File

@ -30,14 +30,16 @@
#include <rte_debug.h>
#include <rte_io.h>
#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
#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[] = {

View File

@ -28,13 +28,14 @@
#include <rte_cycles.h>
#include <rte_flow.h>
#include <mlx5_devx_cmds.h>
#include <mlx5_prm.h>
#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 {

View File

@ -31,13 +31,14 @@
#include <rte_bus_pci.h>
#include <rte_malloc.h>
#include <mlx5_glue.h>
#include <mlx5_prm.h>
#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

View File

@ -23,13 +23,14 @@
#include <rte_mempool.h>
#include <rte_prefetch.h>
#include <mlx5_prm.h>
#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"

View File

@ -9,8 +9,9 @@
#include <rte_common.h>
#include <rte_mbuf.h>
#include <mlx5_prm.h>
#include "mlx5_autoconf.h"
#include "mlx5_prm.h"
/* HW checksum offload capabilities of vectorized Tx. */
#define MLX5_VEC_TX_CKSUM_OFFLOAD_CAP \

View File

@ -17,13 +17,14 @@
#include <rte_mempool.h>
#include <rte_prefetch.h>
#include <mlx5_prm.h>
#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"

View File

@ -16,13 +16,14 @@
#include <rte_mempool.h>
#include <rte_prefetch.h>
#include <mlx5_prm.h>
#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"

View File

@ -16,13 +16,14 @@
#include <rte_mempool.h>
#include <rte_prefetch.h>
#include <mlx5_prm.h>
#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"

View File

@ -13,9 +13,9 @@
#include <rte_common.h>
#include <rte_malloc.h>
#include "mlx5_defs.h"
#include "mlx5.h"
#include "mlx5_rxtx.h"
#include "mlx5_defs.h"
static const struct mlx5_counter_ctrl mlx5_counters_init[] = {
{

View File

@ -28,13 +28,14 @@
#include <rte_ethdev_driver.h>
#include <rte_common.h>
#include "mlx5_utils.h"
#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
#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.

View File

@ -13,8 +13,11 @@
#include <assert.h>
#include <errno.h>
#include <mlx5_common.h>
#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.
*

View File

@ -27,10 +27,11 @@
#include <rte_ethdev_driver.h>
#include <rte_common.h>
#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
#include "mlx5.h"
#include "mlx5_autoconf.h"
#include "mlx5_glue.h"
#include "mlx5_devx_cmds.h"
#include "mlx5_rxtx.h"
#include "mlx5_utils.h"

View File

@ -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