From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CD056A0C52 for ; Mon, 16 Aug 2021 11:02:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C092E4003C; Mon, 16 Aug 2021 11:02:29 +0200 (CEST) Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by mails.dpdk.org (Postfix) with ESMTP id 3FCA04003C for ; Mon, 16 Aug 2021 11:02:29 +0200 (CEST) Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id 2542F3F0A7 for ; Mon, 16 Aug 2021 09:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1629104549; bh=+Ugu5b0iaMUdR7UtLjdCHqMVBcByuGrlQWczW6VK50U=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=k/U5s/b684Obkq07FxObJDpMXEmirzb69EJT3pQS0IIBBI5iJ5rvkmEh0SM13lPSU 54zwRl4ligRKFkMJMUM+Yvr4gu6tNSbYCtzRL765Sm8Ot5xX2jvxQQnojV5KDDFzwU mBG/Dwq6mnjUQdoMBn07TkItrvfvbc17B90Ahg5CPjJxt1IpM3H3VpU5+Jk2/xYIKc dJ8VVE/b+LsF2Up5ZEbyJOl+/EGyWuk+vFHDySaqnAtt66pmm194z3Bt000R/nFMGt +E1SwwOXjVs1L0JyoWH30R9XL9QbOMw2A7RmQVlhNqsUfHwpHTvK3KDIF7eec/5W+A MONNmmWJDv7kQ== Received: by mail-qv1-f71.google.com with SMTP id bo13-20020a05621414adb029035561c68664so12589486qvb.1 for ; Mon, 16 Aug 2021 02:02:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+Ugu5b0iaMUdR7UtLjdCHqMVBcByuGrlQWczW6VK50U=; b=ZiJLLp8Wh54Zk1POJR4XYxjbUzLcNUw2I8LhIV/yxS3gMFTtMrkVIEQ8k14HUEWd5s cORVw7jtspLyPWvJ3gQrbz/uLVKN6SmhIUjNKbIkgXVbTdX9fsLSdIXgH04u4TPz45c4 h+wu8M7QiUu6WbkRaJL1cKVO//uzCczocsmqAd+7naffvxgAhfj+80C8JraGXKMMb5Fw LJq+8ntJvkYPJlWglenhIhLhJ7ZRv5nLNJSiQFL8k1vrvSoCKIjcWa6oBd8MXHd3ylq4 8/A0nCC4f48YoZg96UkXhwkD/AqS8fO6VSPqITi6T4BB8PTP3G7u2FXYC/15BKwuWoRs nPcA== X-Gm-Message-State: AOAM532cOkIIohR3wFYP8GjzJsgCcZrQwUjhieG9M3XrIgWZ+UccjTTq tFKAwm937lAFjfs712tbKcizs35KUdmFI2UvvmjbgjwbPPZp/O6AKDtjZEkCbecRh1JIpUhmCv3 yrOVyrjWXgBvnYxgvnvzZWLjQLq+PODv04L3o/3WC X-Received: by 2002:a37:9c4:: with SMTP id 187mr7651qkj.462.1629104548089; Mon, 16 Aug 2021 02:02:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4hoq9Zv2KDD/BjpSB7ZNS92JyuE+2VRsw5DXMNJPFhDXhqqfMcbPW185tXPHAJmP0wn0sqWYDf+qzCtDx8J4= X-Received: by 2002:a37:9c4:: with SMTP id 187mr7631qkj.462.1629104547858; Mon, 16 Aug 2021 02:02:27 -0700 (PDT) MIME-Version: 1.0 References: <20210816015224.12275-1-suanmingm@nvidia.com> In-Reply-To: <20210816015224.12275-1-suanmingm@nvidia.com> From: Christian Ehrhardt Date: Mon, 16 Aug 2021 11:02:01 +0200 Message-ID: To: Suanming Mou Cc: Viacheslav Ovsiienko , Matan Azrad , dpdk stable Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-stable] [PATCH 19.11] net/mlx5: workaround drop action with old kernel X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Mon, Aug 16, 2021 at 3:52 AM Suanming Mou wrote: > > [ upstream commit 45633c460c223a67dd1a7cc084c3eceb5e17687c ] Thanks, applied > Currently, there are two types of drop action implementation > in the PMD. One is the DR (Direct Rules) dummy placeholder drop > action and another is the dedicated dummy queue drop action. > When creates flow on the root table with DR drop action, the > action will be converted to MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP > Verbs attribute in rdma-core. > > In some inbox systems, MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP Verbs > attribute may not be supported in the kernel driver. Create flow > with drop action on the root table will be failed as it is not > supported. In this case, the dummy queue drop action should be > used instead of DR dummy placeholder drop action. > > This commit adds the DR drop action support detect on the root > table. If MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP Verbs is not > supported in the system, a dummy queue will be used as drop > action. > > Fixes: da845ae9d7c1 ("net/mlx5: fix drop action for Direct Rules/Verbs") > Cc: stable@dpdk.org > > Signed-off-by: Suanming Mou > Acked-by: Matan Azrad > --- > drivers/net/mlx5/mlx5.c | 28 +++++++++++++ > drivers/net/mlx5/mlx5.h | 1 + > drivers/net/mlx5/mlx5_flow.h | 1 + > drivers/net/mlx5/mlx5_flow_dv.c | 72 +++++++++++++++++++++++++++++++-- > 4 files changed, 99 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c > index 3208b2eda7..ee019d6db1 100644 > --- a/drivers/net/mlx5/mlx5.c > +++ b/drivers/net/mlx5/mlx5.c > @@ -2129,6 +2129,33 @@ mlx5_dev_check_sibling_config(struct mlx5_priv *priv, > } > return 0; > } > + > +/** > + * DR flow drop action support detect. > + * > + * @param dev > + * Pointer to rte_eth_dev structure. > + * > + */ > +static void > +mlx5_flow_drop_action_config(struct rte_eth_dev *dev __rte_unused) > +{ > +#ifdef HAVE_MLX5DV_DR > + struct mlx5_priv *priv = dev->data->dev_private; > + > + if (!priv->config.dv_flow_en || !priv->sh->dr_drop_action) > + return; > + /** > + * DR supports drop action placeholder when it is supported; > + * otherwise, use the queue drop action. > + */ > + if (mlx5_flow_discover_dr_action_support(dev)) > + priv->root_verbs_drop_action = 1; > + else > + priv->root_verbs_drop_action = 0; > +#endif > +} > + > /** > * Spawn an Ethernet device from Verbs information. > * > @@ -2844,6 +2871,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, > goto error; > } > } > + mlx5_flow_drop_action_config(eth_dev); > return eth_dev; > error: > if (priv) { > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h > index 70509959fe..b2dc9e291b 100644 > --- a/drivers/net/mlx5/mlx5.h > +++ b/drivers/net/mlx5/mlx5.h > @@ -736,6 +736,7 @@ struct mlx5_priv { > unsigned int counter_fallback:1; /* Use counter fallback management. */ > unsigned int mtr_en:1; /* Whether support meter. */ > unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */ > + unsigned int root_verbs_drop_action; /* Root uses verbs drop action. */ > uint16_t domain_id; /* Switch domain identifier. */ > uint16_t vport_id; /* Associated VF vport index (if any). */ > uint32_t vport_meta_tag; /* Used for vport index match ove VF LAG. */ > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index 4300e62fad..caf6afd4d8 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -893,4 +893,5 @@ int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev, > const struct rte_flow_attr *attr); > int mlx5_flow_meter_flush(struct rte_eth_dev *dev, > struct rte_mtr_error *error); > +int mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev); > #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 a021ac9d20..22649cd79b 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -7920,12 +7920,14 @@ __flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow, > if (dev_flow->transfer) { > assert(priv->sh->dr_drop_action); > dv->actions[n++] = priv->sh->dr_drop_action; > - } else { > #ifdef HAVE_MLX5DV_DR > + } else if (dev_flow->group || > + !priv->root_verbs_drop_action) { > /* DR supports drop action placeholder. */ > assert(priv->sh->dr_drop_action); > dv->actions[n++] = priv->sh->dr_drop_action; > -#else > +#endif > + } else { > /* For DV we use the explicit drop queue. */ > dv->hrxq = mlx5_hrxq_drop_new(dev); > if (!dv->hrxq) { > @@ -7937,7 +7939,6 @@ __flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow, > goto error; > } > dv->actions[n++] = dv->hrxq->action; > -#endif > } > } else if (dev_flow->actions & > (MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)) { > @@ -8373,6 +8374,71 @@ flow_dv_query(struct rte_eth_dev *dev, > return ret; > } > > +/** > + * Check whether the DR drop action is supported on the root table or not. > + * > + * Create a simple flow with DR drop action on root table to validate > + * if DR drop action on root table is supported or not. > + * > + * @param[in] dev > + * Pointer to rte_eth_dev structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set. > + */ > +int > +mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev) > +{ > + struct mlx5_priv *priv = dev->data->dev_private; > + struct mlx5_ibv_shared *sh = priv->sh; > + struct mlx5_flow_dv_match_params mask = { > + .size = sizeof(mask.buf), > + }; > + struct mlx5_flow_dv_match_params value = { > + .size = sizeof(value.buf), > + }; > + struct mlx5dv_flow_matcher_attr dv_attr = { > + .type = IBV_FLOW_ATTR_NORMAL, > + .priority = 0, > + .match_criteria_enable = 0, > + .match_mask = (void *)&mask, > + }; > + struct mlx5_flow_tbl_resource *tbl = NULL; > + void *matcher = NULL; > + void *flow = NULL; > + int ret = -1; > + > + tbl = flow_dv_tbl_resource_get(dev, 0, 0, 0, NULL); > + if (!tbl) > + goto err; > + matcher = mlx5_glue->dv_create_flow_matcher(sh->ctx, &dv_attr, > + tbl->obj); > + if (!matcher) > + goto err; > + flow = mlx5_glue->dv_create_flow(matcher, (void *)&value, 1, > + &sh->dr_drop_action); > +err: > + /* > + * If DR drop action is not supported on root table, flow create will > + * be failed with EOPNOTSUPP or EPROTONOSUPPORT. > + */ > + if (!flow) { > + if (matcher && > + (errno == EPROTONOSUPPORT || errno == EOPNOTSUPP)) > + DRV_LOG(INFO, "DR drop action is not supported in root table."); > + else > + DRV_LOG(ERR, "Unexpected error in DR drop action support detection"); > + ret = -1; > + } else { > + claim_zero(mlx5_glue->dv_destroy_flow(flow)); > + } > + if (matcher) > + claim_zero(mlx5_glue->dv_destroy_flow_matcher(matcher)); > + if (tbl) > + flow_dv_tbl_resource_release(dev, tbl); > + return ret; > +} > + > /** > * Destroy the meter table set. > * Lock free, (mutex should be acquired by caller). > -- > 2.25.1 > -- Christian Ehrhardt Staff Engineer, Ubuntu Server Canonical Ltd