From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C15EFA04AB; Fri, 8 Nov 2019 04:49:35 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 00F651BF49; Fri, 8 Nov 2019 04:49:35 +0100 (CET) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id A3AA91BF2C for ; Fri, 8 Nov 2019 04:49:32 +0100 (CET) From: Suanming Mou To: viacheslavo@mellanox.com, matan@mellanox.com Cc: orika@mellanox.com, rasland@mellanox.com, dev@dpdk.org Date: Fri, 8 Nov 2019 05:49:07 +0200 Message-Id: <1573184965-49691-2-git-send-email-suanmingm@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573184965-49691-1-git-send-email-suanmingm@mellanox.com> References: <1573053090-179521-1-git-send-email-suanmingm@mellanox.com> <1573184965-49691-1-git-send-email-suanmingm@mellanox.com> Subject: [dpdk-dev] [PATCH v2 01/19] net/mlx5: add meter operation callback X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add the new mlx5_flow_meter.c file for metering support. Signed-off-by: Suanming Mou --- drivers/net/mlx5/Makefile | 6 ++++++ drivers/net/mlx5/meson.build | 3 +++ drivers/net/mlx5/mlx5.c | 2 ++ drivers/net/mlx5/mlx5.h | 4 ++++ drivers/net/mlx5/mlx5_flow_meter.c | 43 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+) create mode 100644 drivers/net/mlx5/mlx5_flow_meter.c diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index 44cc26a..0065e55 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -32,6 +32,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_stats.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rss.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mr.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow.c +SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_meter.c 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 @@ -199,6 +200,11 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh 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_ETHTOOL_LINK_MODE_25G \ /usr/include/linux/ethtool.h \ enum ETHTOOL_LINK_MODE_25000baseCR_Full_BIT \ diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build index b72ddb4..511f5b7 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -44,6 +44,7 @@ if build 'mlx5.c', 'mlx5_ethdev.c', 'mlx5_flow.c', + 'mlx5_flow_meter.c', 'mlx5_flow_dv.c', 'mlx5_flow_verbs.c', 'mlx5_mac.c', @@ -131,6 +132,8 @@ if build '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_DR', 'infiniband/mlx5dv.h', 'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ], [ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h', diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 91aaa9b..062666c 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1173,6 +1173,7 @@ struct mlx5_flow_id_pool * .get_module_info = mlx5_get_module_info, .get_module_eeprom = mlx5_get_module_eeprom, .hairpin_cap_get = mlx5_hairpin_cap_get, + .mtr_ops_get = mlx5_flow_meter_ops_get, }; /* Available operations from secondary process. */ @@ -1236,6 +1237,7 @@ struct mlx5_flow_id_pool * .get_module_info = mlx5_get_module_info, .get_module_eeprom = mlx5_get_module_eeprom, .hairpin_cap_get = mlx5_hairpin_cap_get, + .mtr_ops_get = mlx5_flow_meter_ops_get, }; /** diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index fab58c9..ea8bcff 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1001,4 +1001,8 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_tis (struct ibv_context *ctx, struct mlx5_devx_tis_attr *tis_attr); struct mlx5_devx_obj *mlx5_devx_cmd_create_td(struct ibv_context *ctx); +/* mlx5_flow_meter.c */ + +int mlx5_flow_meter_ops_get(struct rte_eth_dev *dev, void *arg); + #endif /* RTE_PMD_MLX5_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c new file mode 100644 index 0000000..6c7a005 --- /dev/null +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: BSD-3-Clause +/* + * Copyright 2018 Mellanox Technologies, Ltd + */ +#include + +#include +#include + +#include "mlx5.h" + +static const struct rte_mtr_ops mlx5_flow_mtr_ops = { + .capabilities_get = NULL, + .meter_profile_add = NULL, + .meter_profile_delete = NULL, + .create = NULL, + .destroy = NULL, + .meter_enable = NULL, + .meter_disable = NULL, + .meter_profile_update = NULL, + .meter_dscp_table_update = NULL, + .policer_actions_update = NULL, + .stats_update = NULL, + .stats_read = NULL, +}; + +/** + * Get meter operations. + * + * @param dev + * Pointer to Ethernet device structure. + * @param arg + * Pointer to set the mtr operations. + * + * @return + * Always 0. + */ +int +mlx5_flow_meter_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg) +{ + *(const struct rte_mtr_ops **)arg = &mlx5_flow_mtr_ops; + return 0; +} -- 1.8.3.1