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 68BFB7CFA for ; Tue, 13 Mar 2018 15:18:56 +0100 (CET) Received: by mail-wr0-f194.google.com with SMTP id o1so11440694wro.10 for ; Tue, 13 Mar 2018 07:18:56 -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=O1pRbxv7J1JxOqAm+zY2AlP3z0qv6zHUoDs6rS8iN98=; b=TDjR3C+h7y6iXcGiyr9miTLmiSaKnm16qwjYGz4SWvFdltfLmilrELgC7spar1dOz5 evIdD6P8eSiUTbDgL+xwRVHHmJJ0o4GCxlTAJduWKJaEqHiwdJLXxrb2tud7lRicEZ9K ZL6XZ6j0K9l0QXmtmYZpkhNfvq8qzX96N0T2PDRwAgXCyIerz71J55E2JXa8d2vskXoO F5Snql6hN0eVBqwEy8KHu0fluK83l6GpeEG/bbyiWhdqTq3dEc7ISH2SSdfTqLLXwqGC /+ZgwbbC6HA/mymXugS+LCDeCqHEuUFTj91n/6bHE47rX9VTCwmwLfHnfh0iR21CwDFT Egzg== 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=O1pRbxv7J1JxOqAm+zY2AlP3z0qv6zHUoDs6rS8iN98=; b=NRI4XimIFylSf1jQTICu7n1ENdcEn7SdgF1V4UlwvvmCjUWCU7zgMBat4t/rn2oevj OGu2W/ePdNrP07oEOoUU0lMOFBcAdIGXmzGhJDcebDdCz/PVN9xBXnip0Qd/bMwDjYeo IEK24D4oPalPDVp6U3tMFHs+MW8p5PsOBlIgKV1H4In+q3s51udQ3MksH/G1IzD2XI69 3ELgyBH6pP/UWHJblw+e3f/UPsHzOw7OuLAKDh+IfYebGIm7OI+21nghp4OXVqmJfxsk +GkhKpvnejVOyn/K4rWq4EaHg/EWKU1idjtQKzNQjRFo0P2nqiLgQyu7v5Jdn187QmWa hpSw== X-Gm-Message-State: AElRT7FAwnT58EDXEqbck53P0HIRAP19lQOoqAw889ZLw5G/Q95tn236 9J9QeIuQPYD34YoMgZqXHm2b X-Google-Smtp-Source: AG47ELvS6rUH/ss2t1RFq9XhIRp4CzBPgEu4B0OMNiAnE6S82Btp74Qi8s6CuOZVbeRxsQWUiTyQug== X-Received: by 10.28.159.68 with SMTP id i65mr968828wme.27.1520950736122; Tue, 13 Mar 2018 07:18:56 -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 x78sm466302wmd.2.2018.03.13.07.18.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 07:18:55 -0700 (PDT) From: Nelio Laranjeiro To: Adrien Mazarguil , Yongseok Koh Cc: dev@dpdk.org Date: Tue, 13 Mar 2018 15:17:36 +0100 Message-Id: <0ec8da6a32575759391b2308c5287ae9a71774ce.1520950386.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: <7aeb54018d1a8dd06638632076f25fbc88945afd.1518686582.git.nelio.laranjeiro@6wind.com> Subject: [dpdk-dev] [PATCH 1/4] net/mlx5: change tunnel flow priority 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: Tue, 13 Mar 2018 14:18:56 -0000 Packet matching inner and outer flow rules are caught by the first one added in the device as both flows are configured with the same priority. To avoid such situation, the inner flow can have an higher priority than the outer ones as their pattern matching will otherwise collide. Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_flow.c | 71 +++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index e5e6be6cc..e1ffb38a5 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -118,7 +118,7 @@ const struct hash_rxq_init hash_rxq_init[] = { IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_DST_PORT_TCP), .dpdk_rss_hf = ETH_RSS_NONFRAG_IPV4_TCP, - .flow_priority = 0, + .flow_priority = 1, .ip_version = MLX5_IPV4, }, [HASH_RXQ_UDPV4] = { @@ -127,7 +127,7 @@ const struct hash_rxq_init hash_rxq_init[] = { IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP), .dpdk_rss_hf = ETH_RSS_NONFRAG_IPV4_UDP, - .flow_priority = 0, + .flow_priority = 1, .ip_version = MLX5_IPV4, }, [HASH_RXQ_IPV4] = { @@ -135,7 +135,7 @@ const struct hash_rxq_init hash_rxq_init[] = { IBV_RX_HASH_DST_IPV4), .dpdk_rss_hf = (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4), - .flow_priority = 1, + .flow_priority = 2, .ip_version = MLX5_IPV4, }, [HASH_RXQ_TCPV6] = { @@ -144,7 +144,7 @@ const struct hash_rxq_init hash_rxq_init[] = { IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_DST_PORT_TCP), .dpdk_rss_hf = ETH_RSS_NONFRAG_IPV6_TCP, - .flow_priority = 0, + .flow_priority = 1, .ip_version = MLX5_IPV6, }, [HASH_RXQ_UDPV6] = { @@ -153,7 +153,7 @@ const struct hash_rxq_init hash_rxq_init[] = { IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP), .dpdk_rss_hf = ETH_RSS_NONFRAG_IPV6_UDP, - .flow_priority = 0, + .flow_priority = 1, .ip_version = MLX5_IPV6, }, [HASH_RXQ_IPV6] = { @@ -161,13 +161,13 @@ const struct hash_rxq_init hash_rxq_init[] = { IBV_RX_HASH_DST_IPV6), .dpdk_rss_hf = (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6), - .flow_priority = 1, + .flow_priority = 2, .ip_version = MLX5_IPV6, }, [HASH_RXQ_ETH] = { .hash_fields = 0, .dpdk_rss_hf = 0, - .flow_priority = 2, + .flow_priority = 3, }, }; @@ -861,8 +861,6 @@ mlx5_flow_convert_items_validate(const struct rte_flow_item items[], /** * Allocate memory space to store verbs flow attributes. * - * @param[in] priority - * Flow priority. * @param[in] size * Amount of byte to allocate. * @param[out] error @@ -872,9 +870,7 @@ mlx5_flow_convert_items_validate(const struct rte_flow_item items[], * A verbs flow attribute on success, NULL otherwise and rte_errno is set. */ static struct ibv_flow_attr * -mlx5_flow_convert_allocate(unsigned int priority, - unsigned int size, - struct rte_flow_error *error) +mlx5_flow_convert_allocate(unsigned int size, struct rte_flow_error *error) { struct ibv_flow_attr *ibv_attr; @@ -886,11 +882,41 @@ mlx5_flow_convert_allocate(unsigned int priority, "cannot allocate verbs spec attributes"); return NULL; } - ibv_attr->priority = priority; return ibv_attr; } /** + * Make inner packet matching with an higher priority from the non Inner + * matching. + * + * @param[in, out] parser + * Internal parser structure. + * @param attr + * User flow attribute. + */ +static void +mlx5_flow_update_priority(struct mlx5_flow_parse *parser, + const struct rte_flow_attr *attr) +{ + unsigned int i; + + if (parser->drop) { + parser->queue[HASH_RXQ_ETH].ibv_attr->priority = + attr->priority + + hash_rxq_init[HASH_RXQ_ETH].flow_priority; + return; + } + for (i = 0; i != hash_rxq_init_n; ++i) { + if (parser->queue[i].ibv_attr) { + parser->queue[i].ibv_attr->priority = + attr->priority + + hash_rxq_init[i].flow_priority - + (parser->inner ? 1 : 0); + } + } +} + +/** * Finalise verbs flow attributes. * * @param[in, out] parser @@ -1064,22 +1090,16 @@ mlx5_flow_convert(struct rte_eth_dev *dev, * Allocate the memory space to store verbs specifications. */ if (parser->drop) { - unsigned int priority = - attr->priority + - hash_rxq_init[HASH_RXQ_ETH].flow_priority; unsigned int offset = parser->queue[HASH_RXQ_ETH].offset; parser->queue[HASH_RXQ_ETH].ibv_attr = - mlx5_flow_convert_allocate(priority, offset, error); + mlx5_flow_convert_allocate(offset, error); if (!parser->queue[HASH_RXQ_ETH].ibv_attr) goto exit_enomem; parser->queue[HASH_RXQ_ETH].offset = sizeof(struct ibv_flow_attr); } else { for (i = 0; i != hash_rxq_init_n; ++i) { - unsigned int priority = - attr->priority + - hash_rxq_init[i].flow_priority; unsigned int offset; if (!(parser->rss_conf.rss_hf & @@ -1088,8 +1108,7 @@ mlx5_flow_convert(struct rte_eth_dev *dev, continue; offset = parser->queue[i].offset; parser->queue[i].ibv_attr = - mlx5_flow_convert_allocate(priority, - offset, error); + mlx5_flow_convert_allocate(offset, error); if (!parser->queue[i].ibv_attr) goto exit_enomem; parser->queue[i].offset = sizeof(struct ibv_flow_attr); @@ -1124,13 +1143,9 @@ mlx5_flow_convert(struct rte_eth_dev *dev, * Last step. Complete missing specification to reach the RSS * configuration. */ - if (!parser->drop) { + if (!parser->drop) mlx5_flow_convert_finalise(parser); - } else { - parser->queue[HASH_RXQ_ETH].ibv_attr->priority = - attr->priority + - hash_rxq_init[parser->layer].flow_priority; - } + mlx5_flow_update_priority(parser, attr); exit_free: /* Only verification is expected, all resources should be released. */ if (!parser->create) { -- 2.11.0