From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by dpdk.org (Postfix) with ESMTP id 105701BFC9 for ; Wed, 27 Jun 2018 17:07:48 +0200 (CEST) Received: by mail-wr0-f194.google.com with SMTP id p1-v6so2404710wrs.9 for ; Wed, 27 Jun 2018 08:07:48 -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=jPfyD6CAN2aKYBZB50wtlhj7p+BVpkVkul6J4E3lU9k=; b=S88vsgJP5/cNV6tdekHlBCk1hEuaJBb0PdlIAF60l0nIEDOa8lNllEigenOwsGNP6U 683HQ3y4kyq7fq/rj8fu939Dh4FdKyByX4E4Nt84wvtYyyJ8KtJiGjBU+ejb2dLuwxgP XYqEUcD4YvW3rF7quseeC5vjyfvVjMZHK8S3KpFniqNvuB4Qby4e+4FXOn+/C2ig7TXk BmOY6AFpOUqlKYPt0PgdOz9T0yOKIZDRODYgTCEmSbxu0NqnXOOChMygOSfeugxUcaIY EUReuV3l6bpptnL6xARWSEZaUwYUAO4bRW64mZpPGdCWje9uYPZkrGvmatT3XdpLfa84 CxPw== 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=jPfyD6CAN2aKYBZB50wtlhj7p+BVpkVkul6J4E3lU9k=; b=QlIgUEvvRmjWp0QmFPR/M7na6TN9dQhKuBNYZCwutxhHlvjAg3SASXdM/tSXYTLPQw HRZ0zStXY7gbpMrwmEtbMko4AT/PwwWdOlAwXHElf9lPBgLscd9UrtyxEwk0Dm3/g6lR hKnZXzldkDtF8qEElVw7GrP6MlFziiuXn1zu+ACjZ60yS19TNNlqcmQORdTTdBF1/9ex 1U5hwV+xLltXR2hB3nPoMdT0nPLkf73FcXWrb9fza0MoDEDh8+nfO4svipcyQCggNg3+ U2YcZocSwtHauozgs++OyEPcAAAFV1KIDfGglqMqGryLpcrcVARC/LfBKt9/VkG8wHCh h42Q== X-Gm-Message-State: APt69E1BfMEpcKQxCANheB0W0UezXiAg4QQVkgOoc/6oJSnXFdM3CRoU +myYV1/Yr+ue1NljWOyDbRn1yPjssw== X-Google-Smtp-Source: AAOMgpeEkjVTtUygdG3BGTK8M7MKQq14j9vG06nRVybNNVq4kCe3vzq8/0wEvHP9oRxdVfPMhKBPhQ== X-Received: by 2002:adf:8227:: with SMTP id 36-v6mr5429344wrb.144.1530112067482; Wed, 27 Jun 2018 08:07:47 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 08:07:47 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org, Adrien Mazarguil , Yongseok Koh Date: Wed, 27 Jun 2018 17:07:47 +0200 Message-Id: <3d98905c5684a15c9cf96be6b65fc6d83d5443d8.1530111623.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 15/20] net/mlx5: support inner RSS computation 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:48 -0000 Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_flow.c | 131 +++++++++++++++++++++++++---------- drivers/net/mlx5/mlx5_rxtx.h | 1 - 2 files changed, 96 insertions(+), 36 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 7dda88641..eedf0c461 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -219,6 +219,8 @@ struct rte_flow { struct mlx5_flow_verbs *cur_verbs; /**< Current Verbs flow structure being filled. */ struct rte_flow_action_rss rss;/**< RSS context. */ + uint32_t ptype; + /**< Store tunnel packet type data to store in Rx queue. */ uint8_t key[40]; /**< RSS hash key. */ uint16_t (*queue)[]; /**< Destination queues to redirect traffic to. */ }; @@ -1320,13 +1322,15 @@ mlx5_flow_action_queue(struct rte_eth_dev *dev, * Pointer to flow structure. * @param types * RSS types for this flow (see ETH_RSS_*). + * @param level + * RSS level. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int mlx5_flow_action_rss_verbs_attr(struct rte_eth_dev *dev, struct rte_flow *flow, - uint32_t types) + uint32_t types, uint32_t level) { const uint32_t layers = mlx5_flow_layers(flow); uint64_t hash_fields; @@ -1374,6 +1378,8 @@ mlx5_flow_action_rss_verbs_attr(struct rte_eth_dev *dev, struct rte_flow *flow, hash_fields = 0; priority = 2; } + if (hash_fields && level == 2) + hash_fields |= IBV_RX_HASH_INNER; flow->cur_verbs->hash_fields = hash_fields; flow->cur_verbs->attr->priority = mlx5_flow_priority(dev, flow->attributes.priority, priority); @@ -1416,7 +1422,7 @@ mlx5_flow_action_rss(struct rte_eth_dev *dev, RTE_FLOW_ERROR_TYPE_ACTION_CONF, &rss->func, "RSS hash function not supported"); - if (rss->level > 1) + if (rss->level > 2) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION_CONF, &rss->level, @@ -1456,6 +1462,7 @@ mlx5_flow_action_rss(struct rte_eth_dev *dev, flow->rss.queue_num = rss->queue_num; memcpy(flow->key, rss->key, rss_hash_default_key_len); flow->rss.types = rss->types; + flow->rss.level = rss->level; flow->fate |= MLX5_FLOW_FATE_RSS; return 0; } @@ -1814,7 +1821,8 @@ mlx5_flow_merge(struct rte_eth_dev *dev, struct rte_flow *flow, flow->cur_verbs->attr->priority = flow->attributes.priority; ret = mlx5_flow_action_rss_verbs_attr(dev, flow, - flow->rss.types); + flow->rss.types, + flow->rss.level); if (ret < 0) goto error; LIST_INSERT_HEAD(&flow->verbs, flow->cur_verbs, next); @@ -1828,27 +1836,6 @@ mlx5_flow_merge(struct rte_eth_dev *dev, struct rte_flow *flow, return ret; } -/** - * Mark the Rx queues mark flag if the flow has a mark or flag modifier. - * - * @param dev - * Pointer to Ethernet device. - * @param flow - * Pointer to flow structure. - */ -static void -mlx5_flow_rxq_mark(struct rte_eth_dev *dev, struct rte_flow *flow) -{ - struct priv *priv = dev->data->dev_private; - const uint32_t mask = MLX5_FLOW_MOD_FLAG | MLX5_FLOW_MOD_MARK; - uint32_t i; - - if (!(flow->modifier & mask)) - return; - for (i = 0; i != flow->rss.queue_num; ++i) - (*priv->rxqs)[(*flow->queue)[i]]->mark = 1; -} - /** * Validate a flow supported by the NIC. * @@ -1978,6 +1965,88 @@ mlx5_flow_fate_apply(struct rte_eth_dev *dev, struct rte_flow *flow, return -rte_errno; } +/** + * Set the Tunnel packet type and the Mark in the Rx queue. + * + * @param dev + * Pointer to Ethernet device. + * @param idx + * Rx queue index. + */ +static void +mlx5_flow_rxq(struct rte_eth_dev *dev, uint16_t idx) +{ + struct priv *priv = dev->data->dev_private; + struct rte_flow *flow; + const uint32_t mark_m = MLX5_FLOW_MOD_FLAG | MLX5_FLOW_MOD_MARK; + uint32_t ptype = 0; + uint32_t mark = 0; + + TAILQ_FOREACH(flow, &priv->flows, next) { + unsigned int i; + + for (i = 0; i != flow->rss.queue_num; ++i) { + if ((*flow->queue)[i] == idx) { + mark |= !!(flow->modifier & mark_m); + if (ptype == 0) + ptype = flow->ptype; + else if (ptype != flow->ptype) + ptype = (uint32_t)-1; + break; + } + } + } + if (ptype == (uint32_t)-1) + ptype = 0; + (*priv->rxqs)[idx]->tunnel = ptype; + (*priv->rxqs)[idx]->mark = mark; +} + +/** + * Set the tunnel packet type and Mark in the Rx queues, if several packet + * types are possible, the information in the Rx queue is just cleared. + * Mark is not impacted by this case. + * + * @param dev + * Pointer to Ethernet device. + */ +static void +mlx5_flow_rxqs(struct rte_eth_dev *dev) +{ + struct priv *priv = dev->data->dev_private; + unsigned int idx; + unsigned int n; + + for (idx = 0, n = 0; n != priv->rxqs_n; ++idx) { + if (!(*priv->rxqs)[idx]) + continue; + mlx5_flow_rxq(dev, idx); + n++; + } +} + +/** + * Clear tunnel ptypes and Mark in Rx queues. + * + * @param dev + * Pointer to Ethernet device. + */ +static void +mlx5_flow_rxqs_clear(struct rte_eth_dev *dev) +{ + struct priv *priv = dev->data->dev_private; + unsigned int idx; + unsigned int n; + + for (idx = 0, n = 0; n != priv->rxqs_n; ++idx) { + if (!(*priv->rxqs)[idx]) + continue; + (*priv->rxqs)[idx]->tunnel = 0; + (*priv->rxqs)[idx]->mark = 0; + n++; + } +} + /** * Create a flow. * @@ -2039,8 +2108,8 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, return NULL; } } - mlx5_flow_rxq_mark(dev, flow); TAILQ_INSERT_TAIL(list, flow, next); + mlx5_flow_rxqs(dev); return flow; } @@ -2144,19 +2213,11 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, struct mlx5_flows *list) void mlx5_flow_stop(struct rte_eth_dev *dev, struct mlx5_flows *list) { - struct priv *priv = dev->data->dev_private; struct rte_flow *flow; - unsigned int i; - unsigned int idx; TAILQ_FOREACH_REVERSE(flow, list, mlx5_flows, next) mlx5_flow_fate_remove(dev, flow); - for (idx = 0, i = 0; idx != priv->rxqs_n; ++i) { - if (!(*priv->rxqs)[idx]) - continue; - (*priv->rxqs)[idx]->mark = 0; - ++idx; - } + mlx5_flow_rxqs_clear(dev); } /** @@ -2181,8 +2242,8 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) ret = mlx5_flow_fate_apply(dev, flow, &error); if (ret < 0) goto error; - mlx5_flow_rxq_mark(dev, flow); } + mlx5_flow_rxqs(dev); return 0; error: ret = rte_errno; /* Save rte_errno before cleanup. */ diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index bb67c32a6..57504ceb2 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -136,7 +136,6 @@ struct mlx5_rxq_ctrl { struct priv *priv; /* Back pointer to private data. */ struct mlx5_rxq_data rxq; /* Data path structure. */ unsigned int socket; /* CPU socket ID for allocations. */ - uint32_t tunnel_types[16]; /* Tunnel type counter. */ unsigned int irq:1; /* Whether IRQ is enabled. */ uint16_t idx; /* Queue index. */ }; -- 2.18.0