From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id F2B7C1BFA3 for ; Wed, 27 Jun 2018 17:07:38 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id p11-v6so5849144wmc.4 for ; Wed, 27 Jun 2018 08:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=frA28TyoYiIm21r8XOA6BHu/xZcgzKPFfM+d6AlYP8I=; b=oO4ZXcYOGLIey7ifTKCH9frO4nG53IBcNxHn2eatbimh7lpBBI1r2271wjI3SnQiN5 xNvcwg/OlBFOs9kt5SyesdnLbl1c7uOFzB2/TOVZGLwRKN8vg0NZvPQTKmB4Y7oYmHXi jdHskBeMvOVRNy/mWaFHNBf3zNrcUa3fXPJHyoAnKhE8lU14lVqGYPSKoP5pPndQZgsM B5oHLXqZeBeFuTfsMuzQ+bd0WMdZGsTkPtvBsNPlznerVSiGEF5nCnY7XOh1bIK7OVj2 flLsrPN1i+9xhg4oxlxYsPoPq1vc+41h5963D1d7vp4A064M+AnnF7qRLPcqG8ubBwwq GxQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=frA28TyoYiIm21r8XOA6BHu/xZcgzKPFfM+d6AlYP8I=; b=AehmGynuli3yqIkQT68ZJYJphJVe7yEik3jbS6QBLJX0K7C1f4/Q12xlq0hHLgydWC J+jNvl9StHQO4BKO4BlJ8m8ccynKXGPQG0K+50I/h+hSWaV9yLPVRfJh1O4nowWQn8sH 96PcXd5MWjrKK/7WVJyE2GJWt/7ea9HsKLRvdNJuuYPoHyuTC/m+uRm5JUKHFwZvaAR7 hSbhltzcC6I/yYTeNovqBudZQeiqx2Rvi/zK1Mqf5YmZRGZB8LrGl7op3l7a4bemZ7UQ cRtHpLhiWle+oGMd2HJr3sVdSB1Ov1V8uyiNLLUtRcJKNQ0Rh9ucQPZgvOt8EQsOe5GO JPag== X-Gm-Message-State: APt69E3SUFBo2N45zsPa2IcKJR2rcjeStnWKf5BRXNdeT78nuMPaGqyw xqLQnBWzPpvGva3QJkwpY/APrYjPkg== X-Google-Smtp-Source: AAOMgped7+DDyI5f+yP1hD6q2iOPd2f0XMF4SwJBEfaurtmKhZvCNQm8puL+WTg2RglSr1pTly7XMw== X-Received: by 2002:a1c:ea06:: with SMTP id i6-v6mr4986682wmh.144.1530112058427; Wed, 27 Jun 2018 08:07:38 -0700 (PDT) Received: from laranjeiro-vm.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id k17-v6sm4872513wrp.19.2018.06.27.08.07.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 08:07:37 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org, Adrien Mazarguil , Yongseok Koh Date: Wed, 27 Jun 2018 17:07:37 +0200 Message-Id: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 05/20] net/mlx5: add flow queue action 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: , X-List-Received-Date: Wed, 27 Jun 2018 15:07:39 -0000 Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_flow.c | 100 +++++++++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index bc8c5de33..7ac1ba24c 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -50,6 +50,7 @@ extern const struct eth_dev_ops mlx5_dev_ops_isolate; /* Action fate on the packet. */ #define MLX5_FLOW_FATE_DROP (1u << 0) +#define MLX5_FLOW_FATE_QUEUE (1u << 1) /** Handles information leading to a drop fate. */ struct mlx5_flow_verbs { @@ -71,7 +72,8 @@ struct rte_flow { /**< Bit-fields of present layers see MLX5_FLOW_ITEMS_*. */ uint32_t fate; /**< Bit-fields of present fate see MLX5_FLOW_FATE_*. */ - struct mlx5_flow_verbs verbs; /* Verbs drop flow. */ + struct mlx5_flow_verbs verbs; /* Verbs flow. */ + uint16_t queue; /**< Destination queue to redirect traffic to. */ }; static const struct rte_flow_ops mlx5_flow_ops = { @@ -191,6 +193,8 @@ mlx5_flow_print(struct rte_flow *flow __rte_unused) flow->layers & MLX5_FLOW_LAYER_OUTER_L4 ? "l4" : "-"); if (flow->fate & MLX5_FLOW_FATE_DROP) fprintf(stdout, " fate: drop queue\n"); + else if (flow->fate & MLX5_FLOW_FATE_QUEUE) + fprintf(stdout, " fate: target queue %u\n", flow->queue); if (flow->verbs.attr) { struct ibv_spec_header *hdr = (struct ibv_spec_header *)flow->verbs.specs; @@ -512,6 +516,53 @@ mlx5_flow_action_drop(const struct rte_flow_action *actions, return size; } +/** + * Validate action queue provided by the user. + * + * @param dev + * Pointer to Ethernet device structure. + * @param actions + * Pointer to flow actions array. + * @param flow + * Pointer to the rte_flow structure. + * @param flow_size + * Size in bytes of the available space for to store the flow information. + * @param error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_flow_action_queue(struct rte_eth_dev *dev, + const struct rte_flow_action *actions, + struct rte_flow *flow, + struct rte_flow_error *error) +{ + struct priv *priv = dev->data->dev_private; + const struct rte_flow_action_queue *queue = actions->conf; + + if (flow->fate) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "multiple fate actions are not" + " supported"); + if (queue->index >= priv->rxqs_n) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + &queue->index, + "queue index out of range"); + if (!(*priv->rxqs)[queue->index]) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + &queue->index, + "queue is not configured"); + flow->queue = queue->index; + flow->fate |= MLX5_FLOW_FATE_QUEUE; + return 0; +} + /** * Validate actions provided by the user. * @@ -531,7 +582,7 @@ mlx5_flow_action_drop(const struct rte_flow_action *actions, * otherwise and rte_errno is set. */ static int -mlx5_flow_actions(struct rte_eth_dev *dev __rte_unused, +mlx5_flow_actions(struct rte_eth_dev *dev, const struct rte_flow_action actions[], struct rte_flow *flow, const size_t flow_size, struct rte_flow_error *error) @@ -548,6 +599,9 @@ mlx5_flow_actions(struct rte_eth_dev *dev __rte_unused, ret = mlx5_flow_action_drop(actions, flow, remain, error); break; + case RTE_FLOW_ACTION_TYPE_QUEUE: + ret = mlx5_flow_action_queue(dev, actions, flow, error); + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, @@ -662,7 +716,10 @@ mlx5_flow_fate_remove(struct rte_eth_dev *dev, struct rte_flow *flow) } } if (flow->verbs.hrxq) { - mlx5_hrxq_drop_release(dev, flow->verbs.hrxq); + if (flow->fate & MLX5_FLOW_FATE_DROP) + mlx5_hrxq_drop_release(dev, flow->verbs.hrxq); + else if (flow->fate & MLX5_FLOW_FATE_QUEUE) + mlx5_hrxq_release(dev, flow->verbs.hrxq); flow->verbs.hrxq = NULL; } } @@ -684,17 +741,38 @@ static int mlx5_flow_fate_apply(struct rte_eth_dev *dev, struct rte_flow *flow, struct rte_flow_error *error) { - flow->verbs.hrxq = mlx5_hrxq_drop_new(dev); - if (!flow->verbs.hrxq) - return rte_flow_error_set - (error, errno, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, - "cannot allocate Drop queue"); + if (flow->fate & MLX5_FLOW_FATE_DROP) { + flow->verbs.hrxq = mlx5_hrxq_drop_new(dev); + if (!flow->verbs.hrxq) + return rte_flow_error_set + (error, errno, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "cannot allocate Drop queue"); + } else if (flow->fate & MLX5_FLOW_FATE_QUEUE) { + struct mlx5_hrxq *hrxq; + + hrxq = mlx5_hrxq_get(dev, rss_hash_default_key, + rss_hash_default_key_len, 0, + &flow->queue, 1, 0, 0); + if (!hrxq) + hrxq = mlx5_hrxq_new(dev, rss_hash_default_key, + rss_hash_default_key_len, 0, + &flow->queue, 1, 0, 0); + if (!hrxq) + return rte_flow_error_set(error, rte_errno, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "cannot create flow"); + flow->verbs.hrxq = hrxq; + } flow->verbs.flow = mlx5_glue->create_flow(flow->verbs.hrxq->qp, flow->verbs.attr); if (!flow->verbs.flow) { - mlx5_hrxq_drop_release(dev, flow->verbs.hrxq); + if (flow->fate & MLX5_FLOW_FATE_DROP) + mlx5_hrxq_drop_release(dev, flow->verbs.hrxq); + else + mlx5_hrxq_release(dev, flow->verbs.hrxq); flow->verbs.hrxq = NULL; return rte_flow_error_set(error, errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, -- 2.18.0