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 17042A04FB; Tue, 17 Dec 2019 08:29:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 75BE41BE9D; Tue, 17 Dec 2019 08:29:45 +0100 (CET) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 248CB3576; Tue, 17 Dec 2019 08:29:44 +0100 (CET) Received: by mail-pf1-f193.google.com with SMTP id h14so5157923pfe.10; Mon, 16 Dec 2019 23:29:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=1NqwdLX50YrXmeKLuLTCAXT+wPfauDq/od5zmihHbeM=; b=aXI3jNe8VhJmpKgyZvSoHAswefl35oBwfiio/6We9uMf8uHWZToBCbKwhJLIwC096T HtRsUE7galT1o3A8TmigKRX8Y8x+rDBLnM1BG068Emqb5U0I1NdUIvqWpVYKs3/tLGed JbsdnieUU1/8Y+YUP6LD6lAYX9k62/PGvy2cJCeMuMPYsSoGomKWyM/MzZhHhSI1eavs ghEr4AWqb3ypfXxu82a7cdl8GuUNtWPXWfS5mXYoLYxT20WdtdPvzZHNOj46xc4quCTL 2SM4cc46VFxHGiyGKe0QHHt+aYaJMDrdL4BW+tgS2/Prv0UeyjqHAqtFVC7PaSe9MaP3 w6+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1NqwdLX50YrXmeKLuLTCAXT+wPfauDq/od5zmihHbeM=; b=TXHvj74io8BrW42EsKzQm5R5IVn2JF7h6ueDawjfVCwIkwR/DXxmBrxnxxwWed1yGW xKU/ZL+/30HHdS2maSOOFu/9ul9+fffy74TlPDs7YQeHGlD3OxItiFEukkaxucjMBPm8 bwJwN10CvjEsMh3C32fEbLyhMoORCw4tpXcut3sg4/b6u8OV23QhwRqmbx9p/C1/rJ9v Ngrpm1eL2wYDkpMyg3oAtKcM7uGZxI3VPwNWmdkwI7KyV0CBKBjfLeG7AOCdmefC/ui5 506GfJlIbEka2bOFQr+5QL5yTd04ch9yOqoCxPIV8Wxja8cwPP3rYIDf9go0qxMIw3LN EHQw== X-Gm-Message-State: APjAAAUzeL05b+YCReqMQmRGxZmKrloJGnTTD8rPUNshIbuHAs+hAVKn srjw385rmzhyHKzN637IFgM= X-Google-Smtp-Source: APXvYqy2PdpHchIJ/UzdMjUs8r3oIAuQiG4CLiFgOBIxthVbMf6Qvgxv4DUZ+Xv885pJrF+GvNe2lw== X-Received: by 2002:a63:364f:: with SMTP id d76mr23948894pga.215.1576567783215; Mon, 16 Dec 2019 23:29:43 -0800 (PST) Received: from local.opencloud.tech.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id a22sm27081599pfk.108.2019.12.16.23.29.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Dec 2019 23:29:42 -0800 (PST) From: xiangxia.m.yue@gmail.com To: suanmingm@mellanox.com Cc: dev@dpdk.org, Tonghao Zhang , stable@dpdk.org Date: Tue, 17 Dec 2019 15:29:31 +0800 Message-Id: <1576567771-46094-1-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: allow install more meter actions 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" From: Tonghao Zhang 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 Cc: stable@dpdk.org Signed-off-by: Tonghao Zhang --- 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(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 0087163..f8cdc25 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -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); diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 3fff5dd..84636be 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -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. */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 7528556..362c36c 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -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