Skip to contentSkip to conversation

net/mlx5: allow install more meter actions

PATCH NAK [email protected] 2 participants 6 messages Dec 17, 2019 – Jan 8, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: allow install more meter actions

From: Tonghao Zhang <[email protected]>

When creating the dr rule of meter, the matcher which struct is "struct mlx5dv_dr_matcher" should not be shared, if shared, mlx5dv_dr_rule_create will return NULL. We can't install more metering offload actions.

The call tree (rdma-core-47mlnx1 OFED 4.7-3.2.9):
* dr_rule_handle_ste_branch
* dr_rule_create_rule_nic
* dr_rule_create_rule_fdb
* dr_rule_create_rule
* mlx5dv_dr_rule_create

In the dr_rule_handle_ste_branch, if ste is not used, mlx5dv_dr_rule_create will return rule, if the ste is used, and the ste is the last in the rule, mlx5dv_dr_rule_create will return NULL.

dr_rule_handle_ste_branch:

    if dr_ste_not_used_ste
        dr_rule_handle_empty_entry
    else
        dr_rule_find_ste_in_miss_list
	dr_ste_is_last_in_rule: if so return NULL and set errno = EINVAL;
Fixes 9ea9b049a960 ("net/mlx5: split meter flow")
Cc Suanming Mou <[email protected]>
---
 drivers/net/mlx5/mlx5_flow.c    | 20 +++++++++++++-------
 drivers/net/mlx5/mlx5_flow.h    |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c |  5 +++++
 3 files changed, 20 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_flow.c +13 -7
index 0087163..f8cdc25 100644
@@ -3421,7 +3421,9 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 			const struct rte_flow_attr *attr,
 			const struct rte_flow_item items[],
 			const struct rte_flow_action actions[],
-			bool external, struct rte_flow_error *error)
+			bool external,
+			bool shared,
+			struct rte_flow_error *error)
 {
 	struct mlx5_flow *dev_flow;
 
@@ -3434,6 +3436,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next);
 	if (sub_flow)
 		*sub_flow = dev_flow;
+	dev_flow->matcher_shared = shared;
 	return flow_drv_translate(dev, dev_flow, attr, items, actions, error);
 }
 
@@ -3741,7 +3744,9 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 			   const struct rte_flow_attr *attr,
 			   const struct rte_flow_item items[],
 			   const struct rte_flow_action actions[],
-			   bool external, struct rte_flow_error *error)
+			   bool external,
+			   bool shared,
+			   struct rte_flow_error *error)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_dev_config *config = &priv->config;
@@ -3759,7 +3764,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	    config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY ||
 	    !mlx5_flow_ext_mreg_supported(dev))
 		return flow_create_split_inner(dev, flow, NULL, attr, items,
-					       actions, external, error);
+					       actions, external,
+					       shared, error);
 	actions_n = flow_parse_qrss_action(actions, &qrss);
 	if (qrss) {
 		/* Exclude hairpin flows from splitting. */
@@ -3842,7 +3848,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	/* Add the unmodified original or prefix subflow. */
 	ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
 				      ext_actions ? ext_actions : actions,
-				      external, error);
+				      external, shared, error);
 	if (ret < 0)
 		goto exit;
 	assert(dev_flow);
@@ -3906,7 +3912,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 		ret = flow_create_split_inner(dev, flow, &dev_flow,
 					      &q_attr, mtr_sfx ? items :
 					      q_items, q_actions,
-					      external, error);
+					      external, shared, error);
 		if (ret < 0)
 			goto exit;
 		assert(dev_flow);
@@ -3999,7 +4005,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 		}
 		/* Add the prefix subflow. */
 		ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
-						  pre_actions, external, error);
+					      pre_actions, external, false, error);
 		if (ret) {
 			ret = -rte_errno;
 			goto exit;
@@ -4035,7 +4041,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	ret = flow_create_split_metadata(dev, flow, &sfx_attr,
 					 sfx_items ? sfx_items : items,
 					 sfx_actions ? sfx_actions : actions,
-					 external, error);
+					 external, sfx_items == NULL, error);
 exit:
 	if (sfx_actions)
 		rte_free(sfx_actions);
drivers/net/mlx5/mlx5_flow.h +2 -0
index 3fff5dd..84636be 100644
@@ -338,6 +338,7 @@ struct mlx5_flow_dv_matcher {
 	/**< Pointer to the table(group) the matcher associated with. */
 	rte_atomic32_t refcnt; /**< Reference counter. */
 	void *matcher_object; /**< Pointer to DV matcher */
+	bool shared;
 	uint16_t crc; /**< CRC of key. */
 	uint16_t priority; /**< Priority of matcher. */
 	struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
@@ -532,6 +533,7 @@ struct mlx5_flow {
 		uint32_t mtr_flow_id; /**< Unique meter match flow id. */
 	};
 	bool external; /**< true if the flow is created external to PMD. */
+	bool matcher_shared;
 };
 
 /* Flow meter state. */
drivers/net/mlx5/mlx5_flow_dv.c +5 -0
index 7528556..362c36c 100644
@@ -6324,10 +6324,13 @@ struct field_modify_info modify_tcp[] = {
 	if (!tbl)
 		return -rte_errno;	/* No need to refill the error info */
 	tbl_data = container_of(tbl, struct mlx5_flow_tbl_data_entry, tbl);
+	if (!dev_flow->matcher_shared)
+		goto create_matcher;
 	/* Lookup from cache. */
 	LIST_FOREACH(cache_matcher, &tbl_data->matchers, next) {
 		if (matcher->crc == cache_matcher->crc &&
 		    matcher->priority == cache_matcher->priority &&
+		    cache_matcher->shared &&
 		    !memcmp((const void *)matcher->mask.buf,
 			    (const void *)cache_matcher->mask.buf,
 			    cache_matcher->mask.size)) {
@@ -6346,6 +6349,7 @@ struct field_modify_info modify_tcp[] = {
 			return 0;
 		}
 	}
+create_matcher:
 	/* Register new matcher. */
 	cache_matcher = rte_calloc(__func__, 1, sizeof(*cache_matcher), 0);
 	if (!cache_matcher) {
@@ -6355,6 +6359,7 @@ struct field_modify_info modify_tcp[] = {
 					  "cannot allocate matcher memory");
 	}
 	*cache_matcher = *matcher;
+	cache_matcher->shared = dev_flow->matcher_shared;
 	dv_attr.match_criteria_enable =
 		flow_dv_matcher_enable(cache_matcher->mask.buf);
 	dv_attr.priority = matcher->priority;
Signature · 1 line
1.8.3.1
#1 lore raw

ping

Quoted 175 lines · On Tue, Dec 17, 2019 at 3:29 PM <[email protected]> wrote:

From: Tonghao Zhang <[email protected]>

When creating the dr rule of meter, the matcher which struct is "struct mlx5dv_dr_matcher" should not be shared, if shared, mlx5dv_dr_rule_create will return NULL. We can't install more metering offload actions.

The call tree (rdma-core-47mlnx1 OFED 4.7-3.2.9):
* dr_rule_handle_ste_branch
* dr_rule_create_rule_nic
* dr_rule_create_rule_fdb
* dr_rule_create_rule
* mlx5dv_dr_rule_create

In the dr_rule_handle_ste_branch, if ste is not used, mlx5dv_dr_rule_create will return rule, if the ste is used, and the ste is the last in the rule, mlx5dv_dr_rule_create will return NULL.

dr_rule_handle_ste_branch:

    if dr_ste_not_used_ste
        dr_rule_handle_empty_entry
    else
        dr_rule_find_ste_in_miss_list
        dr_ste_is_last_in_rule: if so return NULL and set errno = EINVAL;
Fixes 9ea9b049a960 ("net/mlx5: split meter flow")
Cc Suanming Mou <[email protected]>
---
 drivers/net/mlx5/mlx5_flow.c    | 20 +++++++++++++-------
 drivers/net/mlx5/mlx5_flow.h    |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c |  5 +++++
 3 files changed, 20 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_flow.c +13 -7
index 0087163..f8cdc25 100644
@@ -3421,7 +3421,9 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
                        const struct rte_flow_attr *attr,
                        const struct rte_flow_item items[],
                        const struct rte_flow_action actions[],
-                       bool external, struct rte_flow_error *error)
+                       bool external,
+                       bool shared,
+                       struct rte_flow_error *error)
 {
        struct mlx5_flow *dev_flow;
 
@@ -3434,6 +3436,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
        LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next);
        if (sub_flow)
                *sub_flow = dev_flow;
+       dev_flow->matcher_shared = shared;
        return flow_drv_translate(dev, dev_flow, attr, items, actions, error);
 }
 
@@ -3741,7 +3744,9 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
                           const struct rte_flow_attr *attr,
                           const struct rte_flow_item items[],
                           const struct rte_flow_action actions[],
-                          bool external, struct rte_flow_error *error)
+                          bool external,
+                          bool shared,
+                          struct rte_flow_error *error)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_dev_config *config = &priv->config;
@@ -3759,7 +3764,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
            config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY ||
            !mlx5_flow_ext_mreg_supported(dev))
                return flow_create_split_inner(dev, flow, NULL, attr, items,
-                                              actions, external, error);
+                                              actions, external,
+                                              shared, error);
        actions_n = flow_parse_qrss_action(actions, &qrss);
        if (qrss) {
                /* Exclude hairpin flows from splitting. */
@@ -3842,7 +3848,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
        /* Add the unmodified original or prefix subflow. */
        ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
                                      ext_actions ? ext_actions : actions,
-                                     external, error);
+                                     external, shared, error);
        if (ret < 0)
                goto exit;
        assert(dev_flow);
@@ -3906,7 +3912,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
                ret = flow_create_split_inner(dev, flow, &dev_flow,
                                              &q_attr, mtr_sfx ? items :
                                              q_items, q_actions,
-                                             external, error);
+                                             external, shared, error);
                if (ret < 0)
                        goto exit;
                assert(dev_flow);
@@ -3999,7 +4005,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
                }
                /* Add the prefix subflow. */
                ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
-                                                 pre_actions, external, error);
+                                             pre_actions, external, false, error);
                if (ret) {
                        ret = -rte_errno;
                        goto exit;
@@ -4035,7 +4041,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
        ret = flow_create_split_metadata(dev, flow, &sfx_attr,
                                         sfx_items ? sfx_items : items,
                                         sfx_actions ? sfx_actions : actions,
-                                        external, error);
+                                        external, sfx_items == NULL, error);
 exit:
        if (sfx_actions)
                rte_free(sfx_actions);
drivers/net/mlx5/mlx5_flow.h +2 -0
index 3fff5dd..84636be 100644
@@ -338,6 +338,7 @@ struct mlx5_flow_dv_matcher {
        /**< Pointer to the table(group) the matcher associated with. */
        rte_atomic32_t refcnt; /**< Reference counter. */
        void *matcher_object; /**< Pointer to DV matcher */
+       bool shared;
        uint16_t crc; /**< CRC of key. */
        uint16_t priority; /**< Priority of matcher. */
        struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
@@ -532,6 +533,7 @@ struct mlx5_flow {
                uint32_t mtr_flow_id; /**< Unique meter match flow id. */
        };
        bool external; /**< true if the flow is created external to PMD. */
+       bool matcher_shared;
 };
 
 /* Flow meter state. */
drivers/net/mlx5/mlx5_flow_dv.c +5 -1
index 7528556..362c36c 100644
@@ -6324,10 +6324,13 @@ struct field_modify_info modify_tcp[] = {
        if (!tbl)
                return -rte_errno;      /* No need to refill the error info */
        tbl_data = container_of(tbl, struct mlx5_flow_tbl_data_entry, tbl);
+       if (!dev_flow->matcher_shared)
+               goto create_matcher;
        /* Lookup from cache. */
        LIST_FOREACH(cache_matcher, &tbl_data->matchers, next) {
                if (matcher->crc == cache_matcher->crc &&
                    matcher->priority == cache_matcher->priority &&
+                   cache_matcher->shared &&
                    !memcmp((const void *)matcher->mask.buf,
                            (const void *)cache_matcher->mask.buf,
                            cache_matcher->mask.size)) {
@@ -6346,6 +6349,7 @@ struct field_modify_info modify_tcp[] = {
                        return 0;
                }
        }
+create_matcher:
        /* Register new matcher. */
        cache_matcher = rte_calloc(__func__, 1, sizeof(*cache_matcher), 0);
        if (!cache_matcher) {
@@ -6355,6 +6359,7 @@ struct field_modify_info modify_tcp[] = {
                                          "cannot allocate matcher memory");
        }
        *cache_matcher = *matcher;
+       cache_matcher->shared = dev_flow->matcher_shared;
        dv_attr.match_criteria_enable =
                flow_dv_matcher_enable(cache_matcher->mask.buf);
        dv_attr.priority = matcher->priority;
--

1.8.3.1

#2 lore raw

Hello Tonghao,

Could you please explain much detail about your issue scenario?

If I understand correctly, you are trying to create two flows with the two same match criteria?

Example from testpmd just like that:
add port meter profile srtcm_rfc2697 0 24 65536 32768 0
create port meter 0 0 24 yes G Y D 0xffff 1 0
flow create 0 ingress pattern eth / end actions jump group 1 / end
flow create 0 priority 3 group 1 ingress pattern eth / end actions meter mtr_id 0 / queue index 0 / end flow create 0 priority 3 group 1 ingress pattern eth / end actions meter mtr_id 0 / queue index 1 / end

Then the third flow will report "hardware refuses to create flow: Invalid argument".

Please correct me if I'm wrong.
And better to give the issue reproduce method via testpmd cmdline.

Thanks
SuanmingMou

Quoted 198 lines

-----Original Message-----
From: Tonghao Zhang <[email protected]>
Sent: Thursday, December 19, 2019 6:00 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] net/mlx5: allow install more meter actions

ping

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 43 lines · On Tue, Dec 17, 2019 at 3:29 PM <[email protected]> wrote:

From: Tonghao Zhang <[email protected]>

When creating the dr rule of meter, the matcher which struct is "struct mlx5dv_dr_matcher" should not be shared, if shared, mlx5dv_dr_rule_create will return NULL. We can't install more metering offload actions.

The call tree (rdma-core-47mlnx1 OFED 4.7-3.2.9):
* dr_rule_handle_ste_branch
* dr_rule_create_rule_nic
* dr_rule_create_rule_fdb
* dr_rule_create_rule
* mlx5dv_dr_rule_create

In the dr_rule_handle_ste_branch, if ste is not used, mlx5dv_dr_rule_create will return rule, if the ste is used, and the ste is the last in the rule, mlx5dv_dr_rule_create will return NULL.

dr_rule_handle_ste_branch:
if dr_ste_not_used_ste
dr_rule_handle_empty_entry
else
dr_rule_find_ste_in_miss_list
dr_ste_is_last_in_rule: if so return NULL and set errno =
EINVAL;

Fixes 9ea9b049a960 ("net/mlx5: split meter flow")
Cc Suanming Mou <[email protected]>
---
 drivers/net/mlx5/mlx5_flow.c    | 20 +++++++++++++-------
 drivers/net/mlx5/mlx5_flow.h    |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c |  5 +++++
 3 files changed, 20 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow.c index 0087163..f8cdc25 100644

drivers/net/mlx5/mlx5_flow.c +0 -0
@@ -3421,7 +3421,9 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 11 lines
drivers/net/mlx5/mlx5_flow.c +3 -1
                        const struct rte_flow_attr *attr,
                        const struct rte_flow_item items[],
                        const struct rte_flow_action actions[],
-                       bool external, struct rte_flow_error *error)
+                       bool external,
+                       bool shared,
+                       struct rte_flow_error *error)
 {
        struct mlx5_flow *dev_flow;
 
@@ -3434,6 +3436,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 8 lines
drivers/net/mlx5/mlx5_flow.c +1 -0
        LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next);
        if (sub_flow)
                *sub_flow = dev_flow;
+       dev_flow->matcher_shared = shared;
        return flow_drv_translate(dev, dev_flow, attr, items, actions,
 error);  }
 
@@ -3741,7 +3744,9 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,

Quoted 11 lines
drivers/net/mlx5/mlx5_flow.c +4 -1
                           const struct rte_flow_attr *attr,
                           const struct rte_flow_item items[],
                           const struct rte_flow_action actions[],
-                          bool external, struct rte_flow_error *error)
+                          bool external,
+                          bool shared,
+                          struct rte_flow_error *error)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_dev_config *config = &priv->config; @@ -3759,7
+3764,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev,

int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,

Quoted 10 lines
            config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY ||
            !mlx5_flow_ext_mreg_supported(dev))
                return flow_create_split_inner(dev, flow, NULL, attr, items,
drivers/net/mlx5/mlx5_flow.c +3 -1
-                                              actions, external, error);
+                                              actions, external,
+                                              shared, error);
        actions_n = flow_parse_qrss_action(actions, &qrss);
        if (qrss) {
                /* Exclude hairpin flows from splitting. */ @@ -3842,7
+3848,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev,

int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 9 lines

/* Add the unmodified original or prefix subflow. */ ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
ext_actions ? ext_actions : actions,

drivers/net/mlx5/mlx5_flow.c +1 -1
-                                     external, error);
+                                     external, shared, error);
        if (ret < 0)
                goto exit;
        assert(dev_flow);
@@ -3906,7 +3912,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 10 lines
drivers/net/mlx5/mlx5_flow.c +2 -1
                ret = flow_create_split_inner(dev, flow, &dev_flow,
                                              &q_attr, mtr_sfx ? items :
                                              q_items, q_actions,
-                                             external, error);
+                                             external, shared,
+ error);
                if (ret < 0)
                        goto exit;
                assert(dev_flow);
@@ -3999,7 +4005,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 10 lines
drivers/net/mlx5/mlx5_flow.c +2 -1
                }
                /* Add the prefix subflow. */
                ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
-                                                 pre_actions, external, error);
+                                             pre_actions, external,
+ false, error);
                if (ret) {
                        ret = -rte_errno;
                        goto exit;
@@ -4035,7 +4041,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

Quoted 68 lines
drivers/net/mlx5/mlx5_flow.c +2 -1
        ret = flow_create_split_metadata(dev, flow, &sfx_attr,
                                         sfx_items ? sfx_items : items,
                                         sfx_actions ? sfx_actions : actions,
-                                        external, error);
+                                        external, sfx_items == NULL,
+ error);
 exit:
        if (sfx_actions)
                rte_free(sfx_actions); diff --git

a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 3fff5dd..84636be 100644

drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -338,6 +338,7 @@ struct mlx5_flow_dv_matcher {
        /**< Pointer to the table(group) the matcher associated with. */
        rte_atomic32_t refcnt; /**< Reference counter. */
        void *matcher_object; /**< Pointer to DV matcher */
+       bool shared;
        uint16_t crc; /**< CRC of key. */
        uint16_t priority; /**< Priority of matcher. */
        struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
@@ -532,6 +533,7 @@ struct mlx5_flow {
                uint32_t mtr_flow_id; /**< Unique meter match flow id. */
        };
        bool external; /**< true if the flow is created external to

PMD. */

drivers/net/mlx5/mlx5_flow.h +1 -0
+       bool matcher_shared;
 };
 
 /* Flow meter state. */
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow_dv.c index 7528556..362c36c 100644

drivers/net/mlx5/mlx5_flow_dv.c +3 -0
@@ -6324,10 +6324,13 @@ struct field_modify_info modify_tcp[] = {
        if (!tbl)
                return -rte_errno;      /* No need to refill the error info */
        tbl_data = container_of(tbl, struct mlx5_flow_tbl_data_entry,
 tbl);
+       if (!dev_flow->matcher_shared)
+               goto create_matcher;
        /* Lookup from cache. */
        LIST_FOREACH(cache_matcher, &tbl_data->matchers, next) {
                if (matcher->crc == cache_matcher->crc &&
                    matcher->priority == cache_matcher->priority &&
+                   cache_matcher->shared &&
                    !memcmp((const void *)matcher->mask.buf,
                            (const void *)cache_matcher->mask.buf,
                            cache_matcher->mask.size)) { @@ -6346,6
+6349,7 @@ struct field_modify_info modify_tcp[] = {
                        return 0;
                }
        }
drivers/net/mlx5/mlx5_flow_dv.c +2 -1
+create_matcher:
        /* Register new matcher. */
        cache_matcher = rte_calloc(__func__, 1, sizeof(*cache_matcher), 0);
        if (!cache_matcher) {
@@ -6355,6 +6359,7 @@ struct field_modify_info modify_tcp[] = {
                                          "cannot allocate matcher memory");
        }
        *cache_matcher = *matcher;
+       cache_matcher->shared = dev_flow->matcher_shared;
        dv_attr.match_criteria_enable =
                flow_dv_matcher_enable(cache_matcher->mask.buf);
        dv_attr.priority = matcher->priority;
--

1.8.3.1

#3 lore raw
Quoted 14 lines · Suanming Mou

Hello Tonghao,

Could you please explain much detail about your issue scenario?

If I understand correctly, you are trying to create two flows with the two same match criteria?

Example from testpmd just like that:
add port meter profile srtcm_rfc2697 0 24 65536 32768 0
create port meter 0 0 24 yes G Y D 0xffff 1 0
flow create 0 ingress pattern eth / end actions jump group 1 / end
flow create 0 priority 3 group 1 ingress pattern eth / end actions meter mtr_id 0 / queue index 0 / end flow create 0 priority 3 group 1 ingress pattern eth / end actions meter mtr_id 0 / queue index 1 / end

Quoted 4 lines

Then the third flow will report "hardware refuses to create flow: Invalid argument".

Please correct me if I'm wrong.
And better to give the issue reproduce method via testpmd cmdline.

./testpmd -l 0-3 -n 4 -w 0000:82:00.0 -w 0000:82:00.1 -- -i --portmask=0x3 --rxq=2 --nb-cores=2

add port meter profile srtcm_rfc2697 0 100 1024 1024 0 add port meter profile srtcm_rfc2697 0 101 2048 2048 0 create port meter 0 100 100 yes G Y D 0xffff 1 0 create port meter 0 101 101 yes G Y D 0xffff 1 0

flow create 0 ingress pattern eth / end actions jump group 1 / end flow create 0 group 1 priority 3 ingress pattern eth / ipv4 dst is 1.1.1.100 / end actions meter mtr_id 100 / queue index 0 / end

The one of commands below will run fail:
flow create 0 group 1 priority 3 ingress pattern eth / ipv4 dst is 1.1.1.200 / end actions meter mtr_id 101 / queue index 1 / end flow create 0 group 1 priority 3 ingress pattern eth / ipv4 dst is 1.1.1.200 / tcp dst is 80 / end actions meter mtr_id 101 / queue index 1 / end
flow create 0 group 1 priority 3 ingress pattern eth / ipv4 / tcp dst is 80 / end actions meter mtr_id 101 / queue index 1 / end

Caught error type 1 (cause unspecified): hardware refuses to create
flow: Invalid argument

And with this patch, it works fine.

Quoted 201 lines

Thanks
SuanmingMou

Quoted 198 lines

-----Original Message-----
From: Tonghao Zhang <[email protected]>
Sent: Thursday, December 19, 2019 6:00 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] net/mlx5: allow install more meter actions

ping

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 43 lines · On Tue, Dec 17, 2019 at 3:29 PM <[email protected]> wrote:

From: Tonghao Zhang <[email protected]>

When creating the dr rule of meter, the matcher which struct is "struct mlx5dv_dr_matcher" should not be shared, if shared, mlx5dv_dr_rule_create will return NULL. We can't install more metering offload actions.

The call tree (rdma-core-47mlnx1 OFED 4.7-3.2.9):
* dr_rule_handle_ste_branch
* dr_rule_create_rule_nic
* dr_rule_create_rule_fdb
* dr_rule_create_rule
* mlx5dv_dr_rule_create

In the dr_rule_handle_ste_branch, if ste is not used, mlx5dv_dr_rule_create will return rule, if the ste is used, and the ste is the last in the rule, mlx5dv_dr_rule_create will return NULL.

dr_rule_handle_ste_branch:
if dr_ste_not_used_ste
dr_rule_handle_empty_entry
else
dr_rule_find_ste_in_miss_list
dr_ste_is_last_in_rule: if so return NULL and set errno =
EINVAL;

Fixes 9ea9b049a960 ("net/mlx5: split meter flow")
Cc Suanming Mou <[email protected]>
---
 drivers/net/mlx5/mlx5_flow.c    | 20 +++++++++++++-------
 drivers/net/mlx5/mlx5_flow.h    |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c |  5 +++++
 3 files changed, 20 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow.c index 0087163..f8cdc25 100644

drivers/net/mlx5/mlx5_flow.c +0 -0
@@ -3421,7 +3421,9 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 11 lines
drivers/net/mlx5/mlx5_flow.c +3 -1
                        const struct rte_flow_attr *attr,
                        const struct rte_flow_item items[],
                        const struct rte_flow_action actions[],
-                       bool external, struct rte_flow_error *error)
+                       bool external,
+                       bool shared,
+                       struct rte_flow_error *error)
 {
        struct mlx5_flow *dev_flow;
 
@@ -3434,6 +3436,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 8 lines
drivers/net/mlx5/mlx5_flow.c +1 -0
        LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next);
        if (sub_flow)
                *sub_flow = dev_flow;
+       dev_flow->matcher_shared = shared;
        return flow_drv_translate(dev, dev_flow, attr, items, actions,
 error);  }
 
@@ -3741,7 +3744,9 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,

Quoted 11 lines
drivers/net/mlx5/mlx5_flow.c +4 -1
                           const struct rte_flow_attr *attr,
                           const struct rte_flow_item items[],
                           const struct rte_flow_action actions[],
-                          bool external, struct rte_flow_error *error)
+                          bool external,
+                          bool shared,
+                          struct rte_flow_error *error)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_dev_config *config = &priv->config; @@ -3759,7
+3764,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev,

int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,

Quoted 10 lines
            config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY ||
            !mlx5_flow_ext_mreg_supported(dev))
                return flow_create_split_inner(dev, flow, NULL, attr, items,
drivers/net/mlx5/mlx5_flow.c +3 -1
-                                              actions, external, error);
+                                              actions, external,
+                                              shared, error);
        actions_n = flow_parse_qrss_action(actions, &qrss);
        if (qrss) {
                /* Exclude hairpin flows from splitting. */ @@ -3842,7
+3848,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev,

int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 9 lines

/* Add the unmodified original or prefix subflow. */ ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
ext_actions ? ext_actions : actions,

drivers/net/mlx5/mlx5_flow.c +1 -1
-                                     external, error);
+                                     external, shared, error);
        if (ret < 0)
                goto exit;
        assert(dev_flow);
@@ -3906,7 +3912,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 10 lines
drivers/net/mlx5/mlx5_flow.c +2 -1
                ret = flow_create_split_inner(dev, flow, &dev_flow,
                                              &q_attr, mtr_sfx ? items :
                                              q_items, q_actions,
-                                             external, error);
+                                             external, shared,
+ error);
                if (ret < 0)
                        goto exit;
                assert(dev_flow);
@@ -3999,7 +4005,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 10 lines
drivers/net/mlx5/mlx5_flow.c +2 -1
                }
                /* Add the prefix subflow. */
                ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
-                                                 pre_actions, external, error);
+                                             pre_actions, external,
+ false, error);
                if (ret) {
                        ret = -rte_errno;
                        goto exit;
@@ -4035,7 +4041,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

Quoted 68 lines
drivers/net/mlx5/mlx5_flow.c +2 -1
        ret = flow_create_split_metadata(dev, flow, &sfx_attr,
                                         sfx_items ? sfx_items : items,
                                         sfx_actions ? sfx_actions : actions,
-                                        external, error);
+                                        external, sfx_items == NULL,
+ error);
 exit:
        if (sfx_actions)
                rte_free(sfx_actions); diff --git

a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 3fff5dd..84636be 100644

drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -338,6 +338,7 @@ struct mlx5_flow_dv_matcher {
        /**< Pointer to the table(group) the matcher associated with. */
        rte_atomic32_t refcnt; /**< Reference counter. */
        void *matcher_object; /**< Pointer to DV matcher */
+       bool shared;
        uint16_t crc; /**< CRC of key. */
        uint16_t priority; /**< Priority of matcher. */
        struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
@@ -532,6 +533,7 @@ struct mlx5_flow {
                uint32_t mtr_flow_id; /**< Unique meter match flow id. */
        };
        bool external; /**< true if the flow is created external to

PMD. */

drivers/net/mlx5/mlx5_flow.h +1 -0
+       bool matcher_shared;
 };
 
 /* Flow meter state. */
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow_dv.c index 7528556..362c36c 100644

drivers/net/mlx5/mlx5_flow_dv.c +3 -0
@@ -6324,10 +6324,13 @@ struct field_modify_info modify_tcp[] = {
        if (!tbl)
                return -rte_errno;      /* No need to refill the error info */
        tbl_data = container_of(tbl, struct mlx5_flow_tbl_data_entry,
 tbl);
+       if (!dev_flow->matcher_shared)
+               goto create_matcher;
        /* Lookup from cache. */
        LIST_FOREACH(cache_matcher, &tbl_data->matchers, next) {
                if (matcher->crc == cache_matcher->crc &&
                    matcher->priority == cache_matcher->priority &&
+                   cache_matcher->shared &&
                    !memcmp((const void *)matcher->mask.buf,
                            (const void *)cache_matcher->mask.buf,
                            cache_matcher->mask.size)) { @@ -6346,6
+6349,7 @@ struct field_modify_info modify_tcp[] = {
                        return 0;
                }
        }
drivers/net/mlx5/mlx5_flow_dv.c +2 -1
+create_matcher:
        /* Register new matcher. */
        cache_matcher = rte_calloc(__func__, 1, sizeof(*cache_matcher), 0);
        if (!cache_matcher) {
@@ -6355,6 +6359,7 @@ struct field_modify_info modify_tcp[] = {
                                          "cannot allocate matcher memory");
        }
        *cache_matcher = *matcher;
+       cache_matcher->shared = dev_flow->matcher_shared;
        dv_attr.match_criteria_enable =
                flow_dv_matcher_enable(cache_matcher->mask.buf);
        dv_attr.priority = matcher->priority;
--

1.8.3.1

#4 lore raw

Hi,

Quoted 50 lines

-----Original Message-----
From: Tonghao Zhang <[email protected]>
Sent: Monday, January 6, 2020 9:47 AM
To: Suanming Mou <[email protected]>
Cc: [email protected]; [email protected]; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>
Subject: Re: [PATCH] net/mlx5: allow install more meter actions

Quoted 6 lines · Suanming Mou

Hello Tonghao,

Could you please explain much detail about your issue scenario?

If I understand correctly, you are trying to create two flows with the two same

match criteria?

Quoted 10 lines

Example from testpmd just like that:
add port meter profile srtcm_rfc2697 0 24 65536 32768 0 create port meter 0 0 24 yes G Y D 0xffff 1 0 flow create 0 ingress pattern eth / end actions jump group 1 / end flow create 0 priority 3 group 1 ingress pattern eth / end actions meter mtr_id 0 / queue index 0 / end flow create 0 priority 3 group 1 ingress pattern eth / end actions meter mtr_id 0 / queue index 1 / end

Then the third flow will report "hardware refuses to create flow: Invalid

argument".

Quoted 3 lines

Please correct me if I'm wrong.
And better to give the issue reproduce method via testpmd cmdline.

./testpmd -l 0-3 -n 4 -w 0000:82:00.0 -w 0000:82:00.1 -- -i --portmask=0x3 --rxq=2 --nb-cores=2

add port meter profile srtcm_rfc2697 0 100 1024 1024 0 add port meter profile srtcm_rfc2697 0 101 2048 2048 0 create port meter 0 100 100 yes G Y D 0xffff 1 0 create port meter 0 101 101 yes G Y D 0xffff 1 0

flow create 0 ingress pattern eth / end actions jump group 1 / end flow create 0 group 1 priority 3 ingress pattern eth / ipv4 dst is
1.1.1.100 / end actions meter mtr_id 100 / queue index 0 / end

The one of commands below will run fail:
flow create 0 group 1 priority 3 ingress pattern eth / ipv4 dst is 1.1.1.200 / end actions meter mtr_id 101 / queue index 1 / end flow create 0 group 1 priority 3 ingress pattern eth / ipv4 dst is
1.1.1.200 / tcp dst is 80 / end actions meter mtr_id 101 / queue index 1 / end flow create 0 group 1 priority 3 ingress pattern eth / ipv4 / tcp dst is 80 / end actions meter mtr_id 101 / queue index 1 / end

Quoted 49 lines

Caught error type 1 (cause unspecified): hardware refuses to create
flow: Invalid argument

And with this patch, it works fine.

Quoted 45 lines

Thanks
SuanmingMou

Quoted 42 lines

-----Original Message-----
From: Tonghao Zhang <[email protected]>
Sent: Thursday, December 19, 2019 6:00 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] net/mlx5: allow install more meter actions

ping

Quoted 32 lines · On Tue, Dec 17, 2019 at 3:29 PM <[email protected]> wrote:

From: Tonghao Zhang <[email protected]>

When creating the dr rule of meter, the matcher which struct is "struct mlx5dv_dr_matcher" should not be shared, if shared, mlx5dv_dr_rule_create will return NULL. We can't install more metering offload actions.

The call tree (rdma-core-47mlnx1 OFED 4.7-3.2.9):
* dr_rule_handle_ste_branch
* dr_rule_create_rule_nic
* dr_rule_create_rule_fdb
* dr_rule_create_rule
* mlx5dv_dr_rule_create

In the dr_rule_handle_ste_branch, if ste is not used, mlx5dv_dr_rule_create will return rule, if the ste is used, and the ste is the last in the rule, mlx5dv_dr_rule_create will return NULL.

dr_rule_handle_ste_branch:
if dr_ste_not_used_ste
dr_rule_handle_empty_entry
else
dr_rule_find_ste_in_miss_list
dr_ste_is_last_in_rule: if so return NULL and set errno =
EINVAL;

Fixes 9ea9b049a960 ("net/mlx5: split meter flow")
Cc Suanming Mou <[email protected]>

NACK, as we have another fix about that:
https://patches.dpdk.org/patch/64288/

Quoted 161 lines
Quoted 161 lines
Quoted 161 lines

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 11 lines
---
 drivers/net/mlx5/mlx5_flow.c    | 20 +++++++++++++-------
 drivers/net/mlx5/mlx5_flow.h    |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c |  5 +++++
 3 files changed, 20 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow.c index 0087163..f8cdc25 100644

drivers/net/mlx5/mlx5_flow.c +0 -0
@@ -3421,7 +3421,9 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 11 lines
drivers/net/mlx5/mlx5_flow.c +3 -1
                        const struct rte_flow_attr *attr,
                        const struct rte_flow_item items[],
                        const struct rte_flow_action actions[],
-                       bool external, struct rte_flow_error *error)
+                       bool external,
+                       bool shared,
+                       struct rte_flow_error *error)
 {
        struct mlx5_flow *dev_flow;
 
@@ -3434,6 +3436,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 8 lines
drivers/net/mlx5/mlx5_flow.c +1 -0
        LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next);
        if (sub_flow)
                *sub_flow = dev_flow;
+       dev_flow->matcher_shared = shared;
        return flow_drv_translate(dev, dev_flow, attr, items,
 actions, error);  }
 
@@ -3741,7 +3744,9 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,

Quoted 12 lines
drivers/net/mlx5/mlx5_flow.c +5 -1
                           const struct rte_flow_attr *attr,
                           const struct rte_flow_item items[],
                           const struct rte_flow_action actions[],
-                          bool external, struct rte_flow_error *error)
+                          bool external,
+                          bool shared,
+                          struct rte_flow_error *error)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_dev_config *config = &priv->config; @@ -3759,7
+3764,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev
+*dev,

int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,

Quoted 12 lines
            config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY ||
            !mlx5_flow_ext_mreg_supported(dev))
                return flow_create_split_inner(dev, flow, NULL, attr, items,
drivers/net/mlx5/mlx5_flow.c +4 -2
-                                              actions, external, error);
+                                              actions, external,
+                                              shared, error);
        actions_n = flow_parse_qrss_action(actions, &qrss);
        if (qrss) {
                /* Exclude hairpin flows from splitting. */ @@
-3842,7
+3848,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev
+*dev,

int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 9 lines

/* Add the unmodified original or prefix subflow. */ ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
ext_actions ? ext_actions : actions,

drivers/net/mlx5/mlx5_flow.c +1 -1
-                                     external, error);
+                                     external, shared, error);
        if (ret < 0)
                goto exit;
        assert(dev_flow);
@@ -3906,7 +3912,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 10 lines
drivers/net/mlx5/mlx5_flow.c +2 -1
                ret = flow_create_split_inner(dev, flow, &dev_flow,
                                              &q_attr, mtr_sfx ? items :
                                              q_items, q_actions,
-                                             external, error);
+                                             external, shared,
+ error);
                if (ret < 0)
                        goto exit;
                assert(dev_flow);
@@ -3999,7 +4005,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

Quoted 10 lines
drivers/net/mlx5/mlx5_flow.c +2 -1
                }
                /* Add the prefix subflow. */
                ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
-                                                 pre_actions, external, error);
+                                             pre_actions,
+ external, false, error);
                if (ret) {
                        ret = -rte_errno;
                        goto exit; @@ -4035,7 +4041,7 @@ uint32_t

mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

Quoted 70 lines

ret = flow_create_split_metadata(dev, flow, &sfx_attr,
sfx_items ? sfx_items : items, sfx_actions ? sfx_actions : actions,

drivers/net/mlx5/mlx5_flow.c +2 -1
-                                        external, error);
+                                        external, sfx_items ==
+ NULL, error);
 exit:
        if (sfx_actions)
                rte_free(sfx_actions); diff --git

a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 3fff5dd..84636be 100644

drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -338,6 +338,7 @@ struct mlx5_flow_dv_matcher {
        /**< Pointer to the table(group) the matcher associated with. */
        rte_atomic32_t refcnt; /**< Reference counter. */
        void *matcher_object; /**< Pointer to DV matcher */
+       bool shared;
        uint16_t crc; /**< CRC of key. */
        uint16_t priority; /**< Priority of matcher. */
        struct mlx5_flow_dv_match_params mask; /**< Matcher mask.

*/ @@ -532,6 +533,7 @@ struct mlx5_flow {
uint32_t mtr_flow_id; /**< Unique meter match flow id. */
};
bool external; /**< true if the flow is created external
to PMD. */

drivers/net/mlx5/mlx5_flow.h +1 -0
+       bool matcher_shared;
 };
 
 /* Flow meter state. */
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow_dv.c index 7528556..362c36c 100644

drivers/net/mlx5/mlx5_flow_dv.c +2 -0
@@ -6324,10 +6324,13 @@ struct field_modify_info modify_tcp[] = {
        if (!tbl)
                return -rte_errno;      /* No need to refill the error info */
        tbl_data = container_of(tbl, struct
 mlx5_flow_tbl_data_entry, tbl);
+       if (!dev_flow->matcher_shared)
+               goto create_matcher;
        /* Lookup from cache. */
        LIST_FOREACH(cache_matcher, &tbl_data->matchers, next) {
                if (matcher->crc == cache_matcher->crc &&
                    matcher->priority == cache_matcher->priority

&&

drivers/net/mlx5/mlx5_flow_dv.c +4 -2
+                   cache_matcher->shared &&
                    !memcmp((const void *)matcher->mask.buf,
                            (const void *)cache_matcher->mask.buf,
                            cache_matcher->mask.size)) { @@
-6346,6
+6349,7 @@ struct field_modify_info modify_tcp[] = {
                        return 0;
                }
        }
+create_matcher:
        /* Register new matcher. */
        cache_matcher = rte_calloc(__func__, 1, sizeof(*cache_matcher), 0);
        if (!cache_matcher) {
@@ -6355,6 +6359,7 @@ struct field_modify_info modify_tcp[] = {
                                          "cannot allocate matcher memory");
        }
        *cache_matcher = *matcher;
+       cache_matcher->shared = dev_flow->matcher_shared;
        dv_attr.match_criteria_enable =
                flow_dv_matcher_enable(cache_matcher->mask.buf);
        dv_attr.priority = matcher->priority;
--

1.8.3.1

#5 lore raw
In reply to Tonghao Zhang

Hi,

Quoted 50 lines

-----Original Message-----
From: Tonghao Zhang <[email protected]>
Sent: Monday, January 6, 2020 9:47 AM
To: Suanming Mou <[email protected]>
Cc: [email protected]; [email protected]; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>
Subject: Re: [PATCH] net/mlx5: allow install more meter actions

Quoted 6 lines · Suanming Mou

Hello Tonghao,

Could you please explain much detail about your issue scenario?

If I understand correctly, you are trying to create two flows with the two same

match criteria?

Quoted 10 lines

Example from testpmd just like that:
add port meter profile srtcm_rfc2697 0 24 65536 32768 0 create port meter 0 0 24 yes G Y D 0xffff 1 0 flow create 0 ingress pattern eth / end actions jump group 1 / end flow create 0 priority 3 group 1 ingress pattern eth / end actions meter mtr_id 0 / queue index 0 / end flow create 0 priority 3 group 1 ingress pattern eth / end actions meter mtr_id 0 / queue index 1 / end

Then the third flow will report "hardware refuses to create flow: Invalid

argument".

Quoted 3 lines

Please correct me if I'm wrong.
And better to give the issue reproduce method via testpmd cmdline.

./testpmd -l 0-3 -n 4 -w 0000:82:00.0 -w 0000:82:00.1 -- -i --portmask=0x3 --rxq=2 --nb-cores=2

add port meter profile srtcm_rfc2697 0 100 1024 1024 0 add port meter profile srtcm_rfc2697 0 101 2048 2048 0 create port meter 0 100 100 yes G Y D 0xffff 1 0 create port meter 0 101 101 yes G Y D 0xffff 1 0

flow create 0 ingress pattern eth / end actions jump group 1 / end flow create 0 group 1 priority 3 ingress pattern eth / ipv4 dst is
1.1.1.100 / end actions meter mtr_id 100 / queue index 0 / end

The one of commands below will run fail:
flow create 0 group 1 priority 3 ingress pattern eth / ipv4 dst is 1.1.1.200 / end actions meter mtr_id 101 / queue index 1 / end flow create 0 group 1 priority 3 ingress pattern eth / ipv4 dst is
1.1.1.200 / tcp dst is 80 / end actions meter mtr_id 101 / queue index 1 / end flow create 0 group 1 priority 3 ingress pattern eth / ipv4 / tcp dst is 80 / end actions meter mtr_id 101 / queue index 1 / end

Quoted 49 lines

Caught error type 1 (cause unspecified): hardware refuses to create
flow: Invalid argument

And with this patch, it works fine.

Quoted 45 lines

Thanks
SuanmingMou

Quoted 42 lines

-----Original Message-----
From: Tonghao Zhang <[email protected]>
Sent: Thursday, December 19, 2019 6:00 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] net/mlx5: allow install more meter actions

ping

Quoted 32 lines · On Tue, Dec 17, 2019 at 3:29 PM <[email protected]> wrote:

From: Tonghao Zhang <[email protected]>

When creating the dr rule of meter, the matcher which struct is "struct mlx5dv_dr_matcher" should not be shared, if shared, mlx5dv_dr_rule_create will return NULL. We can't install more metering offload actions.

The call tree (rdma-core-47mlnx1 OFED 4.7-3.2.9):
* dr_rule_handle_ste_branch
* dr_rule_create_rule_nic
* dr_rule_create_rule_fdb
* dr_rule_create_rule
* mlx5dv_dr_rule_create

In the dr_rule_handle_ste_branch, if ste is not used, mlx5dv_dr_rule_create will return rule, if the ste is used, and the ste is the last in the rule, mlx5dv_dr_rule_create will return NULL.

dr_rule_handle_ste_branch:
if dr_ste_not_used_ste
dr_rule_handle_empty_entry
else
dr_rule_find_ste_in_miss_list
dr_ste_is_last_in_rule: if so return NULL and set errno =
EINVAL;

Fixes 9ea9b049a960 ("net/mlx5: split meter flow")
Cc Suanming Mou <[email protected]>

NACK, as we have another fix about that:
https://patches.dpdk.org/patch/64288/

Quoted 161 lines
Quoted 161 lines
Quoted 161 lines

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 11 lines
---
 drivers/net/mlx5/mlx5_flow.c    | 20 +++++++++++++-------
 drivers/net/mlx5/mlx5_flow.h    |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c |  5 +++++
 3 files changed, 20 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow.c index 0087163..f8cdc25 100644

drivers/net/mlx5/mlx5_flow.c +0 -0
@@ -3421,7 +3421,9 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 11 lines
drivers/net/mlx5/mlx5_flow.c +3 -1
                        const struct rte_flow_attr *attr,
                        const struct rte_flow_item items[],
                        const struct rte_flow_action actions[],
-                       bool external, struct rte_flow_error *error)
+                       bool external,
+                       bool shared,
+                       struct rte_flow_error *error)
 {
        struct mlx5_flow *dev_flow;
 
@@ -3434,6 +3436,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 8 lines
drivers/net/mlx5/mlx5_flow.c +1 -0
        LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next);
        if (sub_flow)
                *sub_flow = dev_flow;
+       dev_flow->matcher_shared = shared;
        return flow_drv_translate(dev, dev_flow, attr, items,
 actions, error);  }
 
@@ -3741,7 +3744,9 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,

Quoted 12 lines
drivers/net/mlx5/mlx5_flow.c +5 -1
                           const struct rte_flow_attr *attr,
                           const struct rte_flow_item items[],
                           const struct rte_flow_action actions[],
-                          bool external, struct rte_flow_error *error)
+                          bool external,
+                          bool shared,
+                          struct rte_flow_error *error)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_dev_config *config = &priv->config; @@ -3759,7
+3764,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev
+*dev,

int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,

Quoted 12 lines
            config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY ||
            !mlx5_flow_ext_mreg_supported(dev))
                return flow_create_split_inner(dev, flow, NULL, attr, items,
drivers/net/mlx5/mlx5_flow.c +4 -2
-                                              actions, external, error);
+                                              actions, external,
+                                              shared, error);
        actions_n = flow_parse_qrss_action(actions, &qrss);
        if (qrss) {
                /* Exclude hairpin flows from splitting. */ @@
-3842,7
+3848,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev
+*dev,

int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 9 lines

/* Add the unmodified original or prefix subflow. */ ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
ext_actions ? ext_actions : actions,

drivers/net/mlx5/mlx5_flow.c +1 -1
-                                     external, error);
+                                     external, shared, error);
        if (ret < 0)
                goto exit;
        assert(dev_flow);
@@ -3906,7 +3912,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

drivers/net/mlx5/mlx5_flow.c uint32_t mlx5_flow_adjust_priority(struct

Quoted 10 lines
drivers/net/mlx5/mlx5_flow.c +2 -1
                ret = flow_create_split_inner(dev, flow, &dev_flow,
                                              &q_attr, mtr_sfx ? items :
                                              q_items, q_actions,
-                                             external, error);
+                                             external, shared,
+ error);
                if (ret < 0)
                        goto exit;
                assert(dev_flow);
@@ -3999,7 +4005,7 @@ uint32_t mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

Quoted 10 lines
drivers/net/mlx5/mlx5_flow.c +2 -1
                }
                /* Add the prefix subflow. */
                ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items,
-                                                 pre_actions, external, error);
+                                             pre_actions,
+ external, false, error);
                if (ret) {
                        ret = -rte_errno;
                        goto exit; @@ -4035,7 +4041,7 @@ uint32_t

mlx5_flow_adjust_priority(struct

rte_eth_dev *dev, int32_t priority,

Quoted 70 lines

ret = flow_create_split_metadata(dev, flow, &sfx_attr,
sfx_items ? sfx_items : items, sfx_actions ? sfx_actions : actions,

drivers/net/mlx5/mlx5_flow.c +2 -1
-                                        external, error);
+                                        external, sfx_items ==
+ NULL, error);
 exit:
        if (sfx_actions)
                rte_free(sfx_actions); diff --git

a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 3fff5dd..84636be 100644

drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -338,6 +338,7 @@ struct mlx5_flow_dv_matcher {
        /**< Pointer to the table(group) the matcher associated with. */
        rte_atomic32_t refcnt; /**< Reference counter. */
        void *matcher_object; /**< Pointer to DV matcher */
+       bool shared;
        uint16_t crc; /**< CRC of key. */
        uint16_t priority; /**< Priority of matcher. */
        struct mlx5_flow_dv_match_params mask; /**< Matcher mask.

*/ @@ -532,6 +533,7 @@ struct mlx5_flow {
uint32_t mtr_flow_id; /**< Unique meter match flow id. */
};
bool external; /**< true if the flow is created external
to PMD. */

drivers/net/mlx5/mlx5_flow.h +1 -0
+       bool matcher_shared;
 };
 
 /* Flow meter state. */
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow_dv.c index 7528556..362c36c 100644

drivers/net/mlx5/mlx5_flow_dv.c +2 -0
@@ -6324,10 +6324,13 @@ struct field_modify_info modify_tcp[] = {
        if (!tbl)
                return -rte_errno;      /* No need to refill the error info */
        tbl_data = container_of(tbl, struct
 mlx5_flow_tbl_data_entry, tbl);
+       if (!dev_flow->matcher_shared)
+               goto create_matcher;
        /* Lookup from cache. */
        LIST_FOREACH(cache_matcher, &tbl_data->matchers, next) {
                if (matcher->crc == cache_matcher->crc &&
                    matcher->priority == cache_matcher->priority

&&

drivers/net/mlx5/mlx5_flow_dv.c +4 -2
+                   cache_matcher->shared &&
                    !memcmp((const void *)matcher->mask.buf,
                            (const void *)cache_matcher->mask.buf,
                            cache_matcher->mask.size)) { @@
-6346,6
+6349,7 @@ struct field_modify_info modify_tcp[] = {
                        return 0;
                }
        }
+create_matcher:
        /* Register new matcher. */
        cache_matcher = rte_calloc(__func__, 1, sizeof(*cache_matcher), 0);
        if (!cache_matcher) {
@@ -6355,6 +6359,7 @@ struct field_modify_info modify_tcp[] = {
                                          "cannot allocate matcher memory");
        }
        *cache_matcher = *matcher;
+       cache_matcher->shared = dev_flow->matcher_shared;
        dv_attr.match_criteria_enable =
                flow_dv_matcher_enable(cache_matcher->mask.buf);
        dv_attr.priority = matcher->priority;
--

1.8.3.1