From patchwork Mon Oct 9 14:45:00 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: 29979 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 C38941B2AA; Mon, 9 Oct 2017 16:46:02 +0200 (CEST) Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by dpdk.org (Postfix) with ESMTP id 3D7201B20F for ; Mon, 9 Oct 2017 16:45:46 +0200 (CEST) Received: by mail-wm0-f43.google.com with SMTP id q132so24173145wmd.2 for ; Mon, 09 Oct 2017 07:45: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=VkX6Ibx1m+FomQ74n71ukYUeQ93DDDGWU0cCyM1fR+A=; b=VsF5K7Wo8d/ZPnl7uBHukMuZtaQlMEIPMegNBQNKxfQtFtxNiPASdo7jkja9+52QV4 Y1n9LdG3o1xwCw0ULFAyoVb2UivBaL9nmDaZ+DRMKzWHRYIy9mnqyN3QIeO4FrKUjx0j 0B+oue4ShXXj0OhmrF9L9Azbx/SrF3K+Zj2EJE2WWVyKPeCbPKAXIOWs53KQ8U1LVPNI Wsu4A/uqNJQ6JjeRG86rxBFX63N0qm+43IKXmsbSsZd0eb8pHH1dTXzyvzV0AoDxRtTj DEtHeWBUwBiORIwFbviM6W/hm4YtHceEIZeCEyd6XNZfNwvokv4c4BbpG610Lwa+9JwO GK4g== 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=VkX6Ibx1m+FomQ74n71ukYUeQ93DDDGWU0cCyM1fR+A=; b=BBe+p2s/7Eq2HpjKeSW4B1LmpTSaXZcuSBCoaLeuw/G04Lr3DRMafexqXhO0Q0gLkM fm8QKqgFWKf/S4Pl5ncW4c9zx5MNKlJIixF42gINpNDxxnxqjwQjvEAa0T2iy0vqeTAr nwPsLuyX0+xaToqO3mrwcbhiMc+4a4lwbQameqrOW1gtgbh33FfpVjo3uxdZBqwbWFXu y1fNlaPhS37Dc2qWEXpUT35OZ2W1Q3RIaAd77flOTxUn1d2nsHlISmCUUodgJWJAoIau DfjxLOCKudlYiWzPVBEsY/lgPUT/QJY49kFpJTsKUR7T/dkrmAKSXnyjlLlve1Vs7Ibn By/w== X-Gm-Message-State: AMCzsaWIDGcMFqojlueGue48HIsLlhjlQwuU+W+WHNsmHJjqYKkaX1VR RxQ8CTu5yo0iBKrIQu8dFDx3AnHpqw== X-Google-Smtp-Source: AOwi7QD1Qa/DQ8g+euI8AZ1aojwVn0qVrhbDYjqliqF/dxPV/pPSkNks1LVERooHt+nxO38IE4aNyA== X-Received: by 10.28.54.89 with SMTP id d86mr8010000wma.101.1507560345483; Mon, 09 Oct 2017 07:45: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 x15sm6791495wma.32.2017.10.09.07.45.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Oct 2017 07:45:44 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org Cc: adrien.mazarguil@6wind.com, yskoh@mellanox.com, ferruh.yigit@intel.com Date: Mon, 9 Oct 2017 16:45:00 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 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 6a58194..f10f2b3 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);