From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 5D7681B28F for ; Thu, 15 Feb 2018 10:22:49 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id j21so251056wmh.1 for ; Thu, 15 Feb 2018 01:22:49 -0800 (PST) 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; bh=VBtJA7SNEU+WNwiOEtDDu6JVeYhX47M4IaW1sXE8LVQ=; b=Kwtf2GI0mt2dTkl+Tsk6WZeI1kV/8YYkK63Ny0jpuxiRk6EG0zyYV01Qbez1VjlHlx i8Hfipq831leZ4tqgTemi+PGau5yZI8zMwl7mc6TAotqB7NZ64ilAPemmBSWaSPX3Tin BUdecZ5UDvUhwJlL70yASkaF9bEMbnpzUNPUKqOFG54h3IwyRfpj+zI8bZfhJ6BL+P/D sDmGHvtW1/sD//OxHbC/yJ3fv059m7Ns5wX5ibCRjTBOuTvmuBw/tlF3Q7mcYUPRotwG LF29Gcl1x3WzO1AeLBbHkoHBJfSJS7bXJHrYIaq1DsjvKIiApyuGgQp3zNS/V5SiYSZz xcqw== 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; bh=VBtJA7SNEU+WNwiOEtDDu6JVeYhX47M4IaW1sXE8LVQ=; b=A5OSw5TD0Cd1qdh/ISm8P6KY+Mn6fOkdnWUEPo2dCNuNXxEHhWmdPepusYzKUOqX/8 SUvmLyaN1mrlGdn+QdiyxbVoPd/008zsBd+Y62m3JnUlbv1m3XEV+U8Y46Jt+V6bs0eh CdigzOcOU5csvIRXHdN6z7ZoakwcgEtFBcYB36WOhh4Js6Kf2mh982zGzuxNro2ZZ5M7 AjwckBROfYgANo3hkkmxnd8AWXJjrCTN+K6X2xS13WLNSvssNSfJ4tfj4+DNF3y3/+Yw 0I7LrXxZ5Uwu/NnyN3cSrWC/0VW3CHP7mt9Sbz+Dq9+Da0HaisHzNljstaB+KrVtHJiS sUBA== X-Gm-Message-State: APf1xPAoEYAMGlAMS7nZ12f1pzbCrU1GsjmIpWb3N26//GVbqtzhG8nR Dhb9BTylDTTsRndqPITCKUyUHG9pFA== X-Google-Smtp-Source: AH8x227fDxiyzMjaydytKaansdluFpAayaiVJUBHcrIN9F+k7TdIgr7ZkmgZCfLLS/Q2RbjzG9VN3g== X-Received: by 10.28.37.5 with SMTP id l5mr1520108wml.143.1518686568678; Thu, 15 Feb 2018 01:22:48 -0800 (PST) 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 77sm18005038wmt.37.2018.02.15.01.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Feb 2018 01:22:48 -0800 (PST) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Adrien Mazarguil , Yongseok Koh Date: Thu, 15 Feb 2018 10:23:29 +0100 Message-Id: <7aeb54018d1a8dd06638632076f25fbc88945afd.1518686582.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] 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: Thu, 15 Feb 2018 09:22:49 -0000 Packet matching inner and outer flow rules are catch 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 not collide. Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_flow.c | 72 +++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 26002c4b9..6223f1f94 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, }, }; @@ -860,8 +860,6 @@ priv_flow_convert_items_validate(struct priv *priv, * * @param priv * Pointer to private structure. - * @param[in] priority - * Flow priority. * @param[in] size * Amount of byte to allocate. * @param[out] error @@ -872,7 +870,6 @@ priv_flow_convert_items_validate(struct priv *priv, */ static struct ibv_flow_attr* priv_flow_convert_allocate(struct priv *priv, - unsigned int priority, unsigned int size, struct rte_flow_error *error) { @@ -887,11 +884,44 @@ priv_flow_convert_allocate(struct priv *priv, "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 priv + * Pointer to private structure. + * @param[in, out] parser + * Internal parser structure. + * @param attr + * User flow attribute. + */ +static void +priv_flow_update_priority(struct priv *priv, struct mlx5_flow_parse *parser, + const struct rte_flow_attr *attr) +{ + unsigned int i; + + (void)priv; + 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 priv @@ -1059,23 +1089,16 @@ priv_flow_convert(struct priv *priv, * 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 = - priv_flow_convert_allocate(priv, priority, - offset, error); + priv_flow_convert_allocate(priv, offset, error); if (!parser->queue[HASH_RXQ_ETH].ibv_attr) return 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 & @@ -1084,8 +1107,7 @@ priv_flow_convert(struct priv *priv, continue; offset = parser->queue[i].offset; parser->queue[i].ibv_attr = - priv_flow_convert_allocate(priv, priority, - offset, error); + priv_flow_convert_allocate(priv, offset, error); if (!parser->queue[i].ibv_attr) goto exit_enomem; parser->queue[i].offset = sizeof(struct ibv_flow_attr); @@ -1120,13 +1142,9 @@ priv_flow_convert(struct priv *priv, * Last step. Complete missing specification to reach the RSS * configuration. */ - if (!parser->drop) { + if (!parser->drop) priv_flow_convert_finalise(priv, parser); - } else { - parser->queue[HASH_RXQ_ETH].ibv_attr->priority = - attr->priority + - hash_rxq_init[parser->layer].flow_priority; - } + priv_flow_update_priority(priv, parser, attr); exit_free: /* Only verification is expected, all resources should be released. */ if (!parser->create) { -- 2.11.0