From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id DCEAE1B550 for ; Thu, 12 Jul 2018 11:31:29 +0200 (CEST) Received: by mail-wr1-f65.google.com with SMTP id g6-v6so12048228wrp.0 for ; Thu, 12 Jul 2018 02:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZEIFVBxPBpaxjyp1iYHHlFX3tzI/If+jotUy4ZQt4/4=; b=ln3vUCj0b87/+Hvc0r1RWyUAhLRW9aGAHYFVT4VrAYLjurl37jex8RMdYwysvedCR5 jUChWYwatVWVHZF5/OcpSqXH8fH/yQ/gGRan2Ea22O3CXuSEzh+w+FA6fEBeLS/ViF7T gP4TZYjLm6vUFv4leTRf/eeo2X6WwAr/zg0iGuw1biC5bCeCldUVppYEy0C9kx+yL9zj WgxIy6/Y/E+ne5xv4LkapmmBppsPqKhPrWwWq1hOmd8BNmpRsI7qJtbpppcT/os68ZA+ 98WyC5tyrizq6e28Fs0CrcbYoFZEPHWVRhB10PV3+r/PjSwgkId0w1mZ2QOQNiVPPVhU T3Dw== 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:in-reply-to :references; bh=ZEIFVBxPBpaxjyp1iYHHlFX3tzI/If+jotUy4ZQt4/4=; b=Y9gY9NnYeXhHXAGPlOrp/7Dz7E1NmGmFGU/Xuz5Iu84yB5wn5BX8xYXZc1eF1DDB/B G/ohilIC9XEhsBfTzVtLKWXd9tzm0VMqCvdd/hv+q7LT1k4qDHPVRelteReOAH33OaU8 Ye4VQrAmjvwwNyRZ4K5Ecx96LD2hCbu1wdnd2OxQQigTiIso8CsDqFInbsbpCQVLwcn4 ZcXjk40P1pAEuypKFfhT59M7W2YEc3+dTAOKutisnp3KygPsl76oeGmAcyxEjFQktulN 83bVg5Y9SZe3qUZKzpjwtQdLZwgBbv0gbFbF4bzR7n2GZMYJWWbdHf96Q2ezPgUb23fj 0IrQ== X-Gm-Message-State: AOUpUlFF/kICzZk8pyh+oiOAeu+EUsXQ9x/Th3Csyxv3rFMg/tM0l8/q i+Y5T3VWhrDU97c+GlX87J+iBsrj3Q== X-Google-Smtp-Source: AAOMgpdwOnrYG0Zmq8sTjsvVTuj20Gj4hstHpqPw4KRFOO4YyT5KUKIM/fTgJWKbHpTtTYsWCDLy4A== X-Received: by 2002:adf:c4a7:: with SMTP id m36-v6mr1124617wrf.103.1531387889214; Thu, 12 Jul 2018 02:31:29 -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 s2-v6sm18717603wrn.75.2018.07.12.02.31.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 02:31:28 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org, Yongseok Koh Cc: Adrien Mazarguil Date: Thu, 12 Jul 2018 11:30:51 +0200 Message-Id: <71d19729a8df211297b6e3bdf74807b0ef05e54c.1531387413.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 05/21] 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: Thu, 12 Jul 2018 09:31:30 -0000 Signed-off-by: Nelio Laranjeiro Acked-by: Yongseok Koh --- drivers/net/mlx5/mlx5_flow.c | 97 ++++++++++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 036a8d440..6041a4573 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; /* Actions that modify the fate of matching traffic. */ #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_LAYER_*. */ 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 = { @@ -492,6 +494,52 @@ mlx5_flow_action_drop(const struct rte_flow_action *action, return size; } +/** + * Convert the @p action into @p flow after ensuring the NIC will understand + * and process it correctly. + * + * @param[in] dev + * Pointer to Ethernet device structure. + * @param[in] action + * Action configuration. + * @param[in, out] flow + * Pointer to flow structure. + * @param[out] 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 *action, + struct rte_flow *flow, + struct rte_flow_error *error) +{ + struct priv *priv = dev->data->dev_private; + const struct rte_flow_action_queue *queue = action->conf; + + if (flow->fate) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + action, + "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; +} + /** * Convert the @p action into @p flow after ensuring the NIC will understand * and process it correctly. @@ -520,7 +568,7 @@ mlx5_flow_action_drop(const struct rte_flow_action *action, * On error, a negative errno value is returned 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) @@ -537,6 +585,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, @@ -661,7 +712,10 @@ mlx5_flow_remove(struct rte_eth_dev *dev, struct rte_flow *flow) } } if (flow->verbs.hrxq) { - mlx5_hrxq_drop_release(dev); + if (flow->fate & MLX5_FLOW_FATE_DROP) + mlx5_hrxq_drop_release(dev); + else if (flow->fate & MLX5_FLOW_FATE_QUEUE) + mlx5_hrxq_release(dev, flow->verbs.hrxq); flow->verbs.hrxq = NULL; } } @@ -683,17 +737,38 @@ static int mlx5_flow_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); + if (flow->fate & MLX5_FLOW_FATE_DROP) + mlx5_hrxq_drop_release(dev); + 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