From patchwork Thu Oct 5 12:49:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?N=C3=A9lio_Laranjeiro?= X-Patchwork-Id: 29716 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 799771B288; Thu, 5 Oct 2017 14:50:58 +0200 (CEST) Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by dpdk.org (Postfix) with ESMTP id 45CD21B222 for ; Thu, 5 Oct 2017 14:50:46 +0200 (CEST) Received: by mail-wr0-f182.google.com with SMTP id p46so8301982wrb.0 for ; Thu, 05 Oct 2017 05:50:46 -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 :in-reply-to:references; bh=Q44TFgmd3B4E/fs3ZMGqQ1W5Jc23Vy3TtT93hWC2PLU=; b=MfdviyOnjdJthtZwj56h/HbdOtXVnBJBzg8cmBzz79fGeroOwz7OYa6947RfddfQGi rRjQULzodeEIqyZvtkiFjP+4yX3d6HCoir14yGZMhFfty5ILdXtbVQDqKWJjD/laOcFV 9uAvshis8amQJSD2ps5RB923Klz5f+AsHY6jw8FQe5h406QAlfUQKuRkWsGPVNZ9Lez2 Ux8A6UD86DrttFCjNXbp4GztgAzrH/0JAO47FKa5khxXt9QsaSSzD2o9Mz1cE1M165jP tWHX6vZwv5m50ieQNK2rAzs7tFU+K5cFWCLcwxFHblbz/1YE03F9MWIreoC3MQG3zPFu nC+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:in-reply-to :references:in-reply-to:references; bh=Q44TFgmd3B4E/fs3ZMGqQ1W5Jc23Vy3TtT93hWC2PLU=; b=agAjquEwmEtIOchSGdRpkvoCrEocPazO8HbRhj0IxamGzzLs4FAQ0IAEKfvBjN5O4s E26I8+TMZA1zfCkFSSZX5NJWx5R4vtHzvnsNQzfsDxmNV0ikfj4xBVxgts+mESEYZHKl w5zIoa4vUswXqPx+YlcBI6BFIR3I7jmVyFomgVfT6+o2EgtWmWGXKtx76IJyTfL5hw6A MFDVtUxxh0DzQC+Y5e+k06HovYMnSH7GOCaHK2DDZLVJKXLMqNqkBVQFd5LGTbEtto0X Bq8yrY/QoCztyNDvaMGVxVCDkSdx+nMAk8EPE3crIsfi5kxfbqTqTMXUv3UMUxE4FijI GSsA== X-Gm-Message-State: AMCzsaVS0yVisCJeMJe+zwmD3GFAw5URet+jbAduSU1PaWFyKb8N7vri SlwR4HT2RYrLxPw49Ybp9cAiM3vABg== X-Google-Smtp-Source: AOwi7QB0s3mTpUR3273/VxGTpXEIQhkaRSjnzks9PkaIpwUF+McrkCuXj8L94wczowADE1bsuSwaCw== X-Received: by 10.223.173.97 with SMTP id p88mr12970956wrc.280.1507207845448; Thu, 05 Oct 2017 05:50:45 -0700 (PDT) Received: from ping.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id k9sm26405823wrk.27.2017.10.05.05.50.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Oct 2017 05:50:44 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org Cc: adrien.mazarguil@6wind.com, yskoh@mellanox.com, ferruh.yigit@intel.com Date: Thu, 5 Oct 2017 14:49:56 +0200 Message-Id: <2d7d6a80df46adc1e372e8e2dd3d8a44249d790e.1507207731.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 24/30] net/mlx5: merge internal parser and actions structures 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" struct mlx5_flow_parse now embed fields from struct mlx5_flow_action. Signed-off-by: Nelio Laranjeiro Acked-by: Yongseok Koh --- drivers/net/mlx5/mlx5_flow.c | 94 ++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 51 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index a30f1ae..98ee807 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -292,24 +292,19 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { }, }; -/* Structure to parse actions. */ -struct mlx5_flow_action { - uint32_t queue:1; /**< Target is a receive queue. */ - uint32_t drop:1; /**< Target is a drop queue. */ - uint32_t mark:1; /**< Mark is present in the flow. */ - uint32_t mark_id; /**< Mark identifier. */ - uint16_t queues[RTE_MAX_QUEUES_PER_PORT]; /**< Queues indexes to use. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ -}; - /** Structure to pass to the conversion function. */ struct mlx5_flow_parse { struct ibv_flow_attr *ibv_attr; /**< Verbs attribute. */ unsigned int offset; /**< Offset in bytes in the ibv_attr buffer. */ uint32_t inner; /**< Set once VXLAN is encountered. */ uint32_t create:1; /**< Leave allocated resources on exit. */ + uint32_t queue:1; /**< Target is a receive queue. */ + uint32_t drop:1; /**< Target is a drop queue. */ + uint32_t mark:1; /**< Mark is present in the flow. */ + uint32_t mark_id; /**< Mark identifier. */ uint64_t hash_fields; /**< Fields that participate in the hash. */ - struct mlx5_flow_action actions; /**< Parsed action result. */ + uint16_t queues[RTE_MAX_QUEUES_PER_PORT]; /**< Queues indexes to use. */ + uint16_t queues_n; /**< Number of entries in queue[]. */ }; static const struct rte_flow_ops mlx5_flow_ops = { @@ -452,9 +447,7 @@ priv_flow_convert(struct priv *priv, .ibv_attr = flow->ibv_attr, .create = flow->create, .offset = sizeof(struct ibv_flow_attr), - .actions = { - .mark_id = MLX5_FLOW_MARK_DEFAULT, - }, + .mark_id = MLX5_FLOW_MARK_DEFAULT, }; if (attr->group) { rte_flow_error_set(error, ENOTSUP, @@ -488,7 +481,7 @@ priv_flow_convert(struct priv *priv, if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; } else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) { - flow->actions.drop = 1; + flow->drop = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_QUEUE) { const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) @@ -498,13 +491,13 @@ priv_flow_convert(struct priv *priv, if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - for (n = 0; n < flow->actions.queues_n; ++n) { - if (flow->actions.queues[n] == queue->index) { + for (n = 0; n < flow->queues_n; ++n) { + if (flow->queues[n] == queue->index) { found = 1; break; } } - if (flow->actions.queues_n > 1 && !found) { + if (flow->queues_n > 1 && !found) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, actions, @@ -512,9 +505,9 @@ priv_flow_convert(struct priv *priv, return -rte_errno; } if (!found) { - flow->actions.queue = 1; - flow->actions.queues_n = 1; - flow->actions.queues[0] = queue->index; + flow->queue = 1; + flow->queues_n = 1; + flow->queues[0] = queue->index; } } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = @@ -529,12 +522,12 @@ priv_flow_convert(struct priv *priv, "no valid queues"); return -rte_errno; } - if (flow->actions.queues_n == 1) { + if (flow->queues_n == 1) { uint16_t found = 0; - assert(flow->actions.queues_n); + assert(flow->queues_n); for (n = 0; n < rss->num; ++n) { - if (flow->actions.queues[0] == + if (flow->queues[0] == rss->queue[n]) { found = 1; break; @@ -559,10 +552,10 @@ priv_flow_convert(struct priv *priv, return -rte_errno; } } - flow->actions.queue = 1; + flow->queue = 1; for (n = 0; n < rss->num; ++n) - flow->actions.queues[n] = rss->queue[n]; - flow->actions.queues_n = rss->num; + flow->queues[n] = rss->queue[n]; + flow->queues_n = rss->num; } else if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) { const struct rte_flow_action_mark *mark = (const struct rte_flow_action_mark *) @@ -582,19 +575,19 @@ priv_flow_convert(struct priv *priv, " and 16777199"); return -rte_errno; } - flow->actions.mark = 1; - flow->actions.mark_id = mark->id; + flow->mark = 1; + flow->mark_id = mark->id; } else if (actions->type == RTE_FLOW_ACTION_TYPE_FLAG) { - flow->actions.mark = 1; + flow->mark = 1; } else { goto exit_action_not_supported; } } - if (flow->actions.mark && !flow->ibv_attr && !flow->actions.drop) + if (flow->mark && !flow->ibv_attr && !flow->drop) flow->offset += sizeof(struct ibv_flow_spec_action_tag); - if (!flow->ibv_attr && flow->actions.drop) + if (!flow->ibv_attr && flow->drop) flow->offset += sizeof(struct ibv_flow_spec_action_drop); - if (!flow->actions.queue && !flow->actions.drop) { + if (!flow->queue && !flow->drop) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "no valid action"); return -rte_errno; @@ -996,7 +989,7 @@ mlx5_flow_create_flag_mark(struct mlx5_flow_parse *flow, uint32_t mark_id) struct ibv_flow_spec_action_tag *tag; unsigned int size = sizeof(struct ibv_flow_spec_action_tag); - assert(flow->actions.mark); + assert(flow->mark); tag = (void *)((uintptr_t)flow->ibv_attr + flow->offset); *tag = (struct ibv_flow_spec_action_tag){ .type = IBV_FLOW_SPEC_ACTION_TAG, @@ -1087,23 +1080,22 @@ priv_flow_create_action_queue(struct priv *priv, assert(priv->pd); assert(priv->ctx); - assert(!flow->actions.drop); - rte_flow = - rte_calloc(__func__, 1, - sizeof(*flow) + - flow->actions.queues_n * sizeof(uint16_t), - 0); + assert(!flow->drop); + rte_flow = rte_calloc(__func__, 1, + sizeof(*rte_flow) + + flow->queues_n * sizeof(uint16_t), + 0); if (!rte_flow) { rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "cannot allocate flow memory"); return NULL; } - rte_flow->mark = flow->actions.mark; + rte_flow->mark = flow->mark; rte_flow->ibv_attr = flow->ibv_attr; rte_flow->queues = (uint16_t (*)[])(rte_flow + 1); - memcpy(rte_flow->queues, flow->actions.queues, - flow->actions.queues_n * sizeof(uint16_t)); - rte_flow->queues_n = flow->actions.queues_n; + memcpy(rte_flow->queues, flow->queues, + flow->queues_n * sizeof(uint16_t)); + rte_flow->queues_n = flow->queues_n; rte_flow->frxq.hash_fields = flow->hash_fields; rte_flow->frxq.hrxq = mlx5_priv_hrxq_get(priv, rss_hash_default_key, rss_hash_default_key_len, @@ -1124,11 +1116,11 @@ priv_flow_create_action_queue(struct priv *priv, goto error; } } - for (i = 0; i != flow->actions.queues_n; ++i) { + for (i = 0; i != flow->queues_n; ++i) { struct mlx5_rxq_data *q = - (*priv->rxqs)[flow->actions.queues[i]]; + (*priv->rxqs)[flow->queues[i]]; - q->mark |= flow->actions.mark; + q->mark |= flow->mark; } if (!priv->dev->data->dev_started) return rte_flow; @@ -1180,7 +1172,7 @@ priv_flow_validate(struct priv *priv, err = priv_flow_convert(priv, attr, items, actions, error, parser); if (err) goto exit; - if (parser->actions.mark) + if (parser->mark) parser->offset += sizeof(struct ibv_flow_spec_action_tag); parser->ibv_attr = rte_malloc(__func__, parser->offset, 0); if (!parser->ibv_attr) { @@ -1200,8 +1192,8 @@ priv_flow_validate(struct priv *priv, err = priv_flow_convert(priv, attr, items, actions, error, parser); if (err || parser->create) goto exit; - if (parser->actions.mark) - mlx5_flow_create_flag_mark(parser, parser->actions.mark_id); + if (parser->mark) + mlx5_flow_create_flag_mark(parser, parser->mark_id); return 0; exit: if (parser->ibv_attr) @@ -1243,7 +1235,7 @@ priv_flow_create(struct priv *priv, err = priv_flow_validate(priv, attr, items, actions, error, &parser); if (err) goto exit; - if (parser.actions.drop) + if (parser.drop) flow = priv_flow_create_action_queue_drop(priv, &parser, error); else flow = priv_flow_create_action_queue(priv, &parser, error);