From: Ophir Munk <ophirmu@mellanox.com>
To: dev@dpdk.org
Cc: Raslan Darawsheh <rasland@mellanox.com>,
Ophir Munk <ophirmu@mellanox.com>,
Matan Azrad <matan@mellanox.com>
Subject: [dpdk-dev] [PATCH v3 1/8] net/mlx5: move flow prio discovery and adjust under Verbs
Date: Sun, 19 Jul 2020 10:18:09 +0000 [thread overview]
Message-ID: <20200719101816.16406-2-ophirmu@mellanox.com> (raw)
In-Reply-To: <20200719101816.16406-1-ophirmu@mellanox.com>
Function calls mlx5_flow_adjust_priority() and
mlx5_flow_discover_priorities() are Verbs based. Move them from file
mlx5_flow.c to file mlx5_flow_verbs.c
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
drivers/net/mlx5/mlx5.h | 1 -
drivers/net/mlx5/mlx5_flow.c | 112 -------------------------------------
drivers/net/mlx5/mlx5_flow.h | 1 +
drivers/net/mlx5/mlx5_flow_verbs.c | 112 +++++++++++++++++++++++++++++++++++++
4 files changed, 113 insertions(+), 113 deletions(-)
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 9722662..3df4149 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -926,7 +926,6 @@ int mlx5_traffic_restart(struct rte_eth_dev *dev);
int mlx5_flow_discover_mreg_c(struct rte_eth_dev *eth_dev);
bool mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev);
-int mlx5_flow_discover_priorities(struct rte_eth_dev *dev);
void mlx5_flow_print(struct rte_flow *flow);
int mlx5_flow_validate(struct rte_eth_dev *dev,
const struct rte_flow_attr *attr,
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index d171ab0..52047db 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -29,7 +29,6 @@
#include <rte_malloc.h>
#include <rte_ip.h>
-#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
#include <mlx5_prm.h>
#include <mlx5_malloc.h>
@@ -267,17 +266,6 @@ struct mlx5_fdir {
struct rte_flow_action_queue queue;
};
-/* Map of Verbs to Flow priority with 8 Verbs priorities. */
-static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = {
- { 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 },
-};
-
-/* Map of Verbs to Flow priority with 16 Verbs priorities. */
-static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = {
- { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 },
- { 9, 10, 11 }, { 12, 13, 14 },
-};
-
/* Tunnel information. */
struct mlx5_flow_tunnel_info {
uint64_t tunnel; /**< Tunnel bit (see MLX5_FLOW_*). */
@@ -484,106 +472,6 @@ mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev)
}
/**
- * Discover the maximum number of priority available.
- *
- * @param[in] dev
- * Pointer to the Ethernet device structure.
- *
- * @return
- * number of supported flow priority on success, a negative errno
- * value otherwise and rte_errno is set.
- */
-int
-mlx5_flow_discover_priorities(struct rte_eth_dev *dev)
-{
- struct mlx5_priv *priv = dev->data->dev_private;
- struct {
- struct ibv_flow_attr attr;
- struct ibv_flow_spec_eth eth;
- struct ibv_flow_spec_action_drop drop;
- } flow_attr = {
- .attr = {
- .num_of_specs = 2,
- .port = (uint8_t)priv->dev_port,
- },
- .eth = {
- .type = IBV_FLOW_SPEC_ETH,
- .size = sizeof(struct ibv_flow_spec_eth),
- },
- .drop = {
- .size = sizeof(struct ibv_flow_spec_action_drop),
- .type = IBV_FLOW_SPEC_ACTION_DROP,
- },
- };
- struct ibv_flow *flow;
- struct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev);
- uint16_t vprio[] = { 8, 16 };
- int i;
- int priority = 0;
-
- if (!drop) {
- rte_errno = ENOTSUP;
- return -rte_errno;
- }
- for (i = 0; i != RTE_DIM(vprio); i++) {
- flow_attr.attr.priority = vprio[i] - 1;
- flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr);
- if (!flow)
- break;
- claim_zero(mlx5_glue->destroy_flow(flow));
- priority = vprio[i];
- }
- mlx5_hrxq_drop_release(dev);
- switch (priority) {
- case 8:
- priority = RTE_DIM(priority_map_3);
- break;
- case 16:
- priority = RTE_DIM(priority_map_5);
- break;
- default:
- rte_errno = ENOTSUP;
- DRV_LOG(ERR,
- "port %u verbs maximum priority: %d expected 8/16",
- dev->data->port_id, priority);
- return -rte_errno;
- }
- DRV_LOG(INFO, "port %u flow maximum priority: %d",
- dev->data->port_id, priority);
- return priority;
-}
-
-/**
- * Adjust flow priority based on the highest layer and the request priority.
- *
- * @param[in] dev
- * Pointer to the Ethernet device structure.
- * @param[in] priority
- * The rule base priority.
- * @param[in] subpriority
- * The priority based on the items.
- *
- * @return
- * The new priority.
- */
-uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
- uint32_t subpriority)
-{
- uint32_t res = 0;
- struct mlx5_priv *priv = dev->data->dev_private;
-
- switch (priv->config.flow_prio) {
- case RTE_DIM(priority_map_3):
- res = priority_map_3[priority][subpriority];
- break;
- case RTE_DIM(priority_map_5):
- res = priority_map_5[priority][subpriority];
- break;
- }
- return res;
-}
-
-/**
* Verify the @p item specifications (spec, last, mask) are compatible with the
* NIC capabilities.
*
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 6dfeef3..314b5e3 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -922,6 +922,7 @@ int mlx5_flow_group_to_table(const struct rte_flow_attr *attributes,
uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow_rss_desc *rss_desc,
int tunnel, uint64_t layer_types,
uint64_t hash_fields);
+int mlx5_flow_discover_priorities(struct rte_eth_dev *dev);
uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
uint32_t subpriority);
int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 72106b4..5d11ba7 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -38,6 +38,118 @@
#define VERBS_SPEC_INNER(item_flags) \
(!!((item_flags) & MLX5_FLOW_LAYER_TUNNEL) ? IBV_FLOW_SPEC_INNER : 0)
+/* Map of Verbs to Flow priority with 8 Verbs priorities. */
+static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = {
+ { 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 },
+};
+
+/* Map of Verbs to Flow priority with 16 Verbs priorities. */
+static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = {
+ { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 },
+ { 9, 10, 11 }, { 12, 13, 14 },
+};
+
+/**
+ * Discover the maximum number of priority available.
+ *
+ * @param[in] dev
+ * Pointer to the Ethernet device structure.
+ *
+ * @return
+ * number of supported flow priority on success, a negative errno
+ * value otherwise and rte_errno is set.
+ */
+int
+mlx5_flow_discover_priorities(struct rte_eth_dev *dev)
+{
+ struct mlx5_priv *priv = dev->data->dev_private;
+ struct {
+ struct ibv_flow_attr attr;
+ struct ibv_flow_spec_eth eth;
+ struct ibv_flow_spec_action_drop drop;
+ } flow_attr = {
+ .attr = {
+ .num_of_specs = 2,
+ .port = (uint8_t)priv->dev_port,
+ },
+ .eth = {
+ .type = IBV_FLOW_SPEC_ETH,
+ .size = sizeof(struct ibv_flow_spec_eth),
+ },
+ .drop = {
+ .size = sizeof(struct ibv_flow_spec_action_drop),
+ .type = IBV_FLOW_SPEC_ACTION_DROP,
+ },
+ };
+ struct ibv_flow *flow;
+ struct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev);
+ uint16_t vprio[] = { 8, 16 };
+ int i;
+ int priority = 0;
+
+ if (!drop) {
+ rte_errno = ENOTSUP;
+ return -rte_errno;
+ }
+ for (i = 0; i != RTE_DIM(vprio); i++) {
+ flow_attr.attr.priority = vprio[i] - 1;
+ flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr);
+ if (!flow)
+ break;
+ claim_zero(mlx5_glue->destroy_flow(flow));
+ priority = vprio[i];
+ }
+ mlx5_hrxq_drop_release(dev);
+ switch (priority) {
+ case 8:
+ priority = RTE_DIM(priority_map_3);
+ break;
+ case 16:
+ priority = RTE_DIM(priority_map_5);
+ break;
+ default:
+ rte_errno = ENOTSUP;
+ DRV_LOG(ERR,
+ "port %u verbs maximum priority: %d expected 8/16",
+ dev->data->port_id, priority);
+ return -rte_errno;
+ }
+ DRV_LOG(INFO, "port %u flow maximum priority: %d",
+ dev->data->port_id, priority);
+ return priority;
+}
+
+/**
+ * Adjust flow priority based on the highest layer and the request priority.
+ *
+ * @param[in] dev
+ * Pointer to the Ethernet device structure.
+ * @param[in] priority
+ * The rule base priority.
+ * @param[in] subpriority
+ * The priority based on the items.
+ *
+ * @return
+ * The new priority.
+ */
+uint32_t
+mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
+ uint32_t subpriority)
+{
+ uint32_t res = 0;
+ struct mlx5_priv *priv = dev->data->dev_private;
+
+ switch (priv->config.flow_prio) {
+ case RTE_DIM(priority_map_3):
+ res = priority_map_3[priority][subpriority];
+ break;
+ case RTE_DIM(priority_map_5):
+ res = priority_map_5[priority][subpriority];
+ break;
+ }
+ return res;
+}
+
/**
* Get Verbs flow counter by index.
*
--
2.8.4
next prev parent reply other threads:[~2020-07-19 10:18 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-14 14:20 [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 1/8] net/mlx5: move flow prio discovery and adjust under verbs Ophir Munk
2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 6/8] net/mlx5: header file cleanup Ophir Munk
2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 7/8] net/mlx5: refactor multi process communication Ophir Munk
2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 8/8] mlx5: remove inclusion of verbs header files Ophir Munk
2020-07-19 7:11 ` [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
2020-07-19 7:11 ` [dpdk-dev] [PATCH v2 1/8] net/mlx5: move flow prio discovery and adjust under Verbs Ophir Munk
2020-07-19 7:11 ` [dpdk-dev] [PATCH v2 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
2020-07-19 7:11 ` [dpdk-dev] [PATCH v2 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
2020-07-19 7:11 ` [dpdk-dev] [PATCH v2 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
2020-07-19 7:11 ` [dpdk-dev] [PATCH v2 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
2020-07-19 7:11 ` [dpdk-dev] [PATCH v2 6/8] net/mlx5: header file cleanup Ophir Munk
2020-07-19 7:11 ` [dpdk-dev] [PATCH v2 7/8] net/mlx5: refactor multi process communication Ophir Munk
2020-07-19 7:11 ` [dpdk-dev] [PATCH v2 8/8] mlx5: remove inclusion of Verbs header files Ophir Munk
2020-07-19 10:18 ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
2020-07-19 10:18 ` Ophir Munk [this message]
2020-07-19 10:18 ` [dpdk-dev] [PATCH v3 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
2020-07-19 10:18 ` [dpdk-dev] [PATCH v3 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
2020-07-19 10:18 ` [dpdk-dev] [PATCH v3 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
2020-07-19 10:18 ` [dpdk-dev] [PATCH v3 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
2020-07-19 10:18 ` [dpdk-dev] [PATCH v3 6/8] net/mlx5: header file cleanup Ophir Munk
2020-07-19 10:18 ` [dpdk-dev] [PATCH v3 7/8] net/mlx5: refactor multi process communication Ophir Munk
2020-07-19 10:18 ` [dpdk-dev] [PATCH v3 8/8] mlx5: remove inclusion of Verbs header files Ophir Munk
2020-07-19 14:56 ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Raslan Darawsheh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200719101816.16406-2-ophirmu@mellanox.com \
--to=ophirmu@mellanox.com \
--cc=dev@dpdk.org \
--cc=matan@mellanox.com \
--cc=rasland@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).