* [PATCH v1 1/3] net/mlx5: fix meter hierarchy with represented port item
[not found] <20220917060210.3332529-1-shunh@nvidia.com>
@ 2022-09-17 6:02 ` Shun Hao
2022-09-17 6:02 ` [PATCH v1 2/3] net/mlx5: add meter flow limitation when matching all ports Shun Hao
2022-09-17 6:02 ` [PATCH v1 3/3] net/mlx5: fix meter ID tag for meter hierarchy Shun Hao
2 siblings, 0 replies; 3+ messages in thread
From: Shun Hao @ 2022-09-17 6:02 UTC (permalink / raw)
To: viacheslavo, matan, orika, Sean Zhang; +Cc: dev, rasland, stable
There is a new item type represented_port, and currently it will fail
when using meter hierarchy in flow using represented_port match.
This patch fixes this fail by adding support for represented_port item
in meter hierarchy flow split.
Fixes: e8146c63 ("net/mlx5: support represented port item in flow rules")
Cc: stable@dpdk.org
Signed-off-by: Shun Hao <shunh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.c | 10 +++++++---
drivers/net/mlx5/mlx5_flow.h | 3 +++
drivers/net/mlx5/mlx5_flow_dv.c | 20 ++++++++++++++++----
3 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 8c93a3f2e5..e93b6e144c 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -5337,7 +5337,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
switch (item_type) {
case RTE_FLOW_ITEM_TYPE_PORT_ID:
- if (mlx5_flow_get_item_vport_id(dev, items, &flow_src_port, error))
+ case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
return -rte_errno;
if (!fm->def_policy && wks->policy->is_hierarchy &&
flow_src_port != priv->representor_id) {
@@ -11025,14 +11025,18 @@ int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev,
{
struct mlx5_priv *port_priv;
const struct rte_flow_item_port_id *pid_v;
+ uint32_t esw_mgr_port;
- if (item->type != RTE_FLOW_ITEM_TYPE_PORT_ID)
+ if (item->type != RTE_FLOW_ITEM_TYPE_PORT_ID &&
+ item->type != RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT)
return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
NULL, "Incorrect item type.");
pid_v = item->spec;
if (!pid_v)
return 0;
- if (pid_v->id == MLX5_PORT_ESW_MGR) {
+ esw_mgr_port = (item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) ?
+ MLX5_REPRESENTED_PORT_ESW_MGR : MLX5_PORT_ESW_MGR;
+ if (pid_v->id == esw_mgr_port) {
*vport_id = mlx5_flow_get_esw_manager_vport_id(dev);
} else {
port_priv = mlx5_port_to_eswitch_info(pid_v->id, false);
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 4c233cd94a..2f265763a9 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -21,6 +21,9 @@
/* E-Switch Manager port, used for rte_flow_item_port_id. */
#define MLX5_PORT_ESW_MGR UINT32_MAX
+/* E-Switch Manager port, used for rte_flow_item_ethdev. */
+#define MLX5_REPRESENTED_PORT_ESW_MGR UINT16_MAX
+
/* Private rte flow items. */
enum mlx5_rte_flow_item_type {
MLX5_RTE_FLOW_ITEM_TYPE_END = INT_MIN,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 4c811fe00a..f7a5e479b6 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -7055,6 +7055,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
if (ret < 0)
return ret;
last_item = MLX5_FLOW_ITEM_REPRESENTED_PORT;
+ port_id_item = items;
break;
case RTE_FLOW_ITEM_TYPE_ETH:
ret = mlx5_flow_validate_item_eth(items, item_flags,
@@ -16642,8 +16643,13 @@ __flow_dv_create_policy_flow(struct rte_eth_dev *dev,
uint8_t misc_mask;
if (match_src_port && priv->sh->esw_mode) {
- if (flow_dv_translate_item_port_id(dev, matcher.buf,
- value.buf, item, attr)) {
+ if (item && item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT)
+ ret = flow_dv_translate_item_represented_port(dev, matcher.buf, value.buf,
+ item, attr);
+ else
+ ret = flow_dv_translate_item_port_id(dev, matcher.buf, value.buf,
+ item, attr);
+ if (ret) {
DRV_LOG(ERR, "Failed to create meter policy%d flow's"
" value with port.", color);
return -1;
@@ -16692,10 +16698,16 @@ __flow_dv_create_policy_matcher(struct rte_eth_dev *dev,
struct mlx5_flow_tbl_data_entry *tbl_data;
struct mlx5_priv *priv = dev->data->dev_private;
const uint32_t color_mask = (UINT32_C(1) << MLX5_MTR_COLOR_BITS) - 1;
+ int ret;
if (match_src_port && priv->sh->esw_mode) {
- if (flow_dv_translate_item_port_id(dev, matcher.mask.buf,
- value.buf, item, attr)) {
+ if (item && item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT)
+ ret = flow_dv_translate_item_represented_port(dev, matcher.mask.buf,
+ value.buf, item, attr);
+ else
+ ret = flow_dv_translate_item_port_id(dev, matcher.mask.buf, value.buf,
+ item, attr);
+ if (ret) {
DRV_LOG(ERR, "Failed to register meter policy%d matcher"
" with port.", priority);
return -1;
--
2.20.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v1 2/3] net/mlx5: add meter flow limitation when matching all ports
[not found] <20220917060210.3332529-1-shunh@nvidia.com>
2022-09-17 6:02 ` [PATCH v1 1/3] net/mlx5: fix meter hierarchy with represented port item Shun Hao
@ 2022-09-17 6:02 ` Shun Hao
2022-09-17 6:02 ` [PATCH v1 3/3] net/mlx5: fix meter ID tag for meter hierarchy Shun Hao
2 siblings, 0 replies; 3+ messages in thread
From: Shun Hao @ 2022-09-17 6:02 UTC (permalink / raw)
To: viacheslavo, matan, orika, Sean Zhang; +Cc: dev, rasland, stable
If there's no param in represented_port item, it will be treated as
matching all ports by default. But there's some limitation when using it
with meter hierarchy.
This patch adds the limitation that when matching all ports, the meter
hierarchy should not contain any meter having drop count.
Fixes: e8146c63 ("net/mlx5: support represented port item in flow rules")
Cc: stable@dpdk.org
Signed-off-by: Shun Hao <shunh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
doc/guides/nics/mlx5.rst | 1 +
drivers/net/mlx5/mlx5.h | 2 ++
drivers/net/mlx5/mlx5_flow.c | 11 ++++++-
drivers/net/mlx5/mlx5_flow.h | 1 +
drivers/net/mlx5/mlx5_flow_dv.c | 51 ++++++++++++++++++++-------------
5 files changed, 45 insertions(+), 21 deletions(-)
diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index d331e48ce7..631f0840eb 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -473,6 +473,7 @@ Limitations
- meter profile packet mode is supported.
- meter profiles of RFC2697, RFC2698 and RFC4115 are supported.
- RFC4115 implementation is following MEF, meaning yellow traffic may reclaim unused green bandwidth when green token bucket is full.
+ - When using DV flow engine (``dv_flow_en`` = 1), if meter has drop count or meter hierarchy contains any meter that uses drop count, it cannot be used by flow matching all ports.
- Integrity:
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index a56ee83d99..9300dc02ff 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -775,6 +775,8 @@ struct mlx5_flow_meter_policy {
/* Is queue action in policy table. */
uint32_t is_hierarchy:1;
/* Is meter action in policy table. */
+ uint32_t hierarchy_drop_cnt:1;
+ /* Is any meter in hierarchy contains drop_cnt. */
uint32_t skip_y:1;
/* If yellow color policy is skipped. */
uint32_t skip_g:1;
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index e93b6e144c..2038c4a6c0 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -5338,6 +5338,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
switch (item_type) {
case RTE_FLOW_ITEM_TYPE_PORT_ID:
case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
+ if (mlx5_flow_get_item_vport_id(dev, items, &flow_src_port, NULL, error))
return -rte_errno;
if (!fm->def_policy && wks->policy->is_hierarchy &&
flow_src_port != priv->representor_id) {
@@ -11012,6 +11013,8 @@ int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev)
* The src port id match item.
* @param[out] vport_id
* Pointer to put the vport id.
+ * @param[out] all_ports
+ * Indicate if the item matches all ports.
* @param[out] error
* Pointer to error structure.
*
@@ -11021,6 +11024,7 @@ int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev)
int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev,
const struct rte_flow_item *item,
uint16_t *vport_id,
+ bool *all_ports,
struct rte_flow_error *error)
{
struct mlx5_priv *port_priv;
@@ -11032,8 +11036,13 @@ int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev,
return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
NULL, "Incorrect item type.");
pid_v = item->spec;
- if (!pid_v)
+ if (!pid_v) {
+ if (all_ports)
+ *all_ports = (item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT);
return 0;
+ }
+ if (all_ports)
+ *all_ports = false;
esw_mgr_port = (item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) ?
MLX5_REPRESENTED_PORT_ESW_MGR : MLX5_PORT_ESW_MGR;
if (pid_v->id == esw_mgr_port) {
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 2f265763a9..0fa1735b1a 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -2087,6 +2087,7 @@ int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev);
int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev,
const struct rte_flow_item *item,
uint16_t *vport_id,
+ bool *all_ports,
struct rte_flow_error *error);
#endif /* RTE_PMD_MLX5_FLOW_H_ */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index f7a5e479b6..5a382b66a4 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -5245,6 +5245,8 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,
struct mlx5_flow_meter_info *fm;
struct mlx5_flow_meter_policy *mtr_policy;
struct mlx5_flow_mtr_mng *mtrmng = priv->sh->mtrmng;
+ uint16_t flow_src_port = priv->representor_id;
+ bool all_ports = false;
if (!am)
return rte_flow_error_set(error, EINVAL,
@@ -5307,27 +5309,34 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,
"Flow attributes domain "
"have a conflict with current "
"meter domain attributes");
- if (attr->transfer && mtr_policy->dev) {
- /**
- * When policy has fate action of port_id,
- * the flow should have the same src port as policy.
- */
- struct mlx5_priv *policy_port_priv =
- mtr_policy->dev->data->dev_private;
- uint16_t flow_src_port = priv->representor_id;
-
- if (port_id_item) {
- if (mlx5_flow_get_item_vport_id(dev, port_id_item,
- &flow_src_port, error))
- return -rte_errno;
+ if (port_id_item) {
+ if (mlx5_flow_get_item_vport_id(dev, port_id_item, &flow_src_port,
+ &all_ports, error))
+ return -rte_errno;
+ }
+ if (attr->transfer) {
+ if (mtr_policy->dev) {
+ /**
+ * When policy has fate action of port_id,
+ * the flow should have the same src port as policy.
+ */
+ struct mlx5_priv *policy_port_priv =
+ mtr_policy->dev->data->dev_private;
+
+ if (all_ports || flow_src_port != policy_port_priv->representor_id)
+ return rte_flow_error_set(error,
+ rte_errno,
+ RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
+ NULL,
+ "Flow and meter policy "
+ "have different src port.");
}
- if (flow_src_port != policy_port_priv->representor_id)
- return rte_flow_error_set(error,
- rte_errno,
- RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
- NULL,
- "Flow and meter policy "
- "have different src port.");
+ /* When flow matching all src ports, meter should not have drop count. */
+ if (all_ports && (fm->drop_cnt || mtr_policy->hierarchy_drop_cnt))
+ return rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM_SPEC, NULL,
+ "Meter drop count not supported "
+ "when matching all ports.");
} else if (mtr_policy->is_rss) {
struct mlx5_flow_meter_policy *fp;
struct mlx5_meter_policy_action_container *acg;
@@ -16251,6 +16260,8 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev,
mtr_policy->dev = next_policy->dev;
if (next_policy->mark)
mtr_policy->mark = 1;
+ if (next_fm->drop_cnt || next_policy->hierarchy_drop_cnt)
+ mtr_policy->hierarchy_drop_cnt = 1;
action_flags |=
MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY;
break;
--
2.20.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v1 3/3] net/mlx5: fix meter ID tag for meter hierarchy
[not found] <20220917060210.3332529-1-shunh@nvidia.com>
2022-09-17 6:02 ` [PATCH v1 1/3] net/mlx5: fix meter hierarchy with represented port item Shun Hao
2022-09-17 6:02 ` [PATCH v1 2/3] net/mlx5: add meter flow limitation when matching all ports Shun Hao
@ 2022-09-17 6:02 ` Shun Hao
2 siblings, 0 replies; 3+ messages in thread
From: Shun Hao @ 2022-09-17 6:02 UTC (permalink / raw)
To: viacheslavo, matan, orika, Sean Zhang; +Cc: dev, rasland, stable
Currently, when flow usese meter hierarchy, a tag action is always applied
to set the first meter's meter id, so as to update the first meter's drop
count. But it's not considered if first meter doesn't have drop count.
This patch fixes it, that in hierarchy, if the first meter doesn't have
drop count, no need to add the meter id tag action. No change for
non-hierarchy meter.
Fixes: e8146c63 ("net/mlx5: support represented port item in flow rules")
Cc: stable@dpdk.org
Signed-off-by: Shun Hao <shunh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 2038c4a6c0..e4744b0a67 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -6438,14 +6438,12 @@ flow_create_split_meter(struct rte_eth_dev *dev,
}
/*
* If it isn't default-policy Meter, and
- * 1. There's no action in flow to change
+ * 1. Not meter hierarchy and there's no action in flow to change
* packet (modify/encap/decap etc.), OR
* 2. No drop count needed for this meter.
- * 3. It's not meter hierarchy.
* Then no need to use regC to save meter id anymore.
*/
- if (!fm->def_policy && !is_mtr_hierarchy &&
- (!has_modify || !fm->drop_cnt))
+ if (!fm->def_policy && ((!has_modify && !is_mtr_hierarchy) || !fm->drop_cnt))
set_mtr_reg = false;
/* Prefix actions: meter, decap, encap, tag, jump, end, cnt. */
#define METER_PREFIX_ACTION 7
--
2.20.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-17 6:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20220917060210.3332529-1-shunh@nvidia.com>
2022-09-17 6:02 ` [PATCH v1 1/3] net/mlx5: fix meter hierarchy with represented port item Shun Hao
2022-09-17 6:02 ` [PATCH v1 2/3] net/mlx5: add meter flow limitation when matching all ports Shun Hao
2022-09-17 6:02 ` [PATCH v1 3/3] net/mlx5: fix meter ID tag for meter hierarchy Shun Hao
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).