From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id 1B7FE1B5CE for ; Thu, 12 Jul 2018 11:31:43 +0200 (CEST) Received: by mail-wr1-f68.google.com with SMTP id e7-v6so1401563wrs.9 for ; Thu, 12 Jul 2018 02:31:43 -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; bh=XkLu9STtfJiBZkEvK8aHvPW9fQZoH4oqfYEml2jAkGk=; b=otn7+guR9ku/LKr+NQaVHwRJ4FyBq9FiK/HDTmpiOU2ft9AUOCNAXT9c5r4ACVFueg IElzdkWarqEjOhO2Rb88tnpX3YGNuq1xWDClVt3BI79MHN270lzwSkFcE5OpHGOd3rAA 6Ehqv84bITcQzlZtvYVEW5CWZn4KrMJsN0alpLaRFTxhNMJj6woEh+yR77JsuzOuAEpU QFfhxenICxKVS4u3Afbm0rURaSEz69uc/Y8v2MN5GF4+u0rSghIl2UpUcgLjJEXqzlPy 7IFslBPFcjr5CwwZUHoCOHalE5Vk8SnJk+rS7kU16WtxSu831noFb+ZhQ4Z4Zjjju2lF AJYg== 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; bh=XkLu9STtfJiBZkEvK8aHvPW9fQZoH4oqfYEml2jAkGk=; b=qfI1lHzyn4DX7PoYnUUdMLWmBrv4U4f3qaPrTVFZ47Lr/Hja/qZcYlNUuL0KLmnRV9 6kLgtO1h85MIp9uaijRIknkQtIx7hVqD9ZCXq4xrDzv39OfJd69RUnJiJt8/+qLhmVWR f3NSeF5gaQWgMW8KhNV/YSfokU0Uf0QPppk4XMEkjXdmE6+wHlPSb6wZGtxWKe95LB1H uLoVL+J9rS3RTUrBGRhs5PchEsQEiaO8W0ZKFUvDS0G8t1IUISnuFBnsRiWo+fe/e33f UkmxfEkGE1z3pAAoh5v+zlY/8o7cKT95xemM/sG1tj45xTNn3NUpxMispTX8zzts2pr4 UANA== X-Gm-Message-State: AOUpUlE2/Euar12EpqKzB6bbVqhskbvGCC/tMl4MqeG7twd68QmLjdXo ZqdZBKEQWRUfRXvIbSnyrbr8Y2dBDw== X-Google-Smtp-Source: AAOMgpflv/gpoUg6A1gwoRQ/RbwRrd2oMvKFFAl7/+ZLJxg/PFrqdUokm5YJJIuNFG+paUjSy01fJg== X-Received: by 2002:adf:c78e:: with SMTP id l14-v6mr1125353wrg.230.1531387902661; Thu, 12 Jul 2018 02:31:42 -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 s2-v6sm18717603wrn.75.2018.07.12.02.31.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 02:31:42 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org, Yongseok Koh Cc: Adrien Mazarguil Date: Thu, 12 Jul 2018 11:31:06 +0200 Message-Id: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 20/21] net/mlx5: add flow MPLS item 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, 12 Jul 2018 09:31:43 -0000 Signed-off-by: Nelio Laranjeiro Acked-by: Yongseok Koh --- drivers/net/mlx5/mlx5_flow.c | 102 ++++++++++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_rxtx.h | 2 +- 2 files changed, 101 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index b05e30204..1d7b72ac1 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -55,6 +55,7 @@ extern const struct eth_dev_ops mlx5_dev_ops_isolate; #define MLX5_FLOW_LAYER_VXLAN (1u << 12) #define MLX5_FLOW_LAYER_VXLAN_GPE (1u << 13) #define MLX5_FLOW_LAYER_GRE (1u << 14) +#define MLX5_FLOW_LAYER_MPLS (1u << 15) /* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ @@ -68,7 +69,7 @@ extern const struct eth_dev_ops mlx5_dev_ops_isolate; /* Tunnel Masks. */ #define MLX5_FLOW_LAYER_TUNNEL \ (MLX5_FLOW_LAYER_VXLAN | MLX5_FLOW_LAYER_VXLAN_GPE | \ - MLX5_FLOW_LAYER_GRE) + MLX5_FLOW_LAYER_GRE | MLX5_FLOW_LAYER_MPLS) /* Inner Masks. */ #define MLX5_FLOW_LAYER_INNER_L3 \ @@ -92,6 +93,7 @@ extern const struct eth_dev_ops mlx5_dev_ops_isolate; #define MLX5_IP_PROTOCOL_TCP 6 #define MLX5_IP_PROTOCOL_UDP 17 #define MLX5_IP_PROTOCOL_GRE 47 +#define MLX5_IP_PROTOCOL_MPLS 147 /* Priority reserved for default flows. */ #define MLX5_FLOW_PRIO_RSVD ((uint32_t)-1) @@ -109,6 +111,7 @@ enum mlx5_expansion { MLX5_EXPANSION_VXLAN, MLX5_EXPANSION_VXLAN_GPE, MLX5_EXPANSION_GRE, + MLX5_EXPANSION_MPLS, MLX5_EXPANSION_ETH, MLX5_EXPANSION_IPV4, MLX5_EXPANSION_IPV4_UDP, @@ -134,7 +137,8 @@ static const struct rte_flow_expand_node mlx5_support_expansion[] = { }, [MLX5_EXPANSION_OUTER_ETH] = { .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_IPV4, - MLX5_EXPANSION_OUTER_IPV6), + MLX5_EXPANSION_OUTER_IPV6, + MLX5_EXPANSION_MPLS), .type = RTE_FLOW_ITEM_TYPE_ETH, .rss_types = 0, }, @@ -189,6 +193,11 @@ static const struct rte_flow_expand_node mlx5_support_expansion[] = { .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4), .type = RTE_FLOW_ITEM_TYPE_GRE, }, + [MLX5_EXPANSION_MPLS] = { + .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4, + MLX5_EXPANSION_IPV6), + .type = RTE_FLOW_ITEM_TYPE_MPLS, + }, [MLX5_EXPANSION_ETH] = { .next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4, MLX5_EXPANSION_IPV6), @@ -341,6 +350,14 @@ static struct mlx5_flow_tunnel_info tunnels_info[] = { .tunnel = MLX5_FLOW_LAYER_GRE, .ptype = RTE_PTYPE_TUNNEL_GRE, }, + { + .tunnel = MLX5_FLOW_LAYER_MPLS | MLX5_FLOW_LAYER_OUTER_L4_UDP, + .ptype = RTE_PTYPE_TUNNEL_MPLS_IN_GRE | RTE_PTYPE_L4_UDP, + }, + { + .tunnel = MLX5_FLOW_LAYER_MPLS, + .ptype = RTE_PTYPE_TUNNEL_MPLS_IN_GRE, + }, }; /** @@ -1593,6 +1610,84 @@ mlx5_flow_item_gre(const struct rte_flow_item *item, return size; } +/** + * Convert the @p item into a Verbs specification after ensuring the NIC + * will understand and process it correctly. + * If the necessary size for the conversion is greater than the @p flow_size, + * nothing is written in @p flow, the validation is still performed. + * + * @param[in] item + * Item specification. + * @param[in, out] flow + * Pointer to flow structure. + * @param[in] flow_size + * Size in bytes of the available space in @p flow, if too small, nothing is + * written. + * @param[out] error + * Pointer to error structure. + * + * @return + * On success the number of bytes consumed/necessary, if the returned value + * is lesser or equal to @p flow_size, the @p item has fully been converted, + * otherwise another call with this returned memory size should be done. + * On error, a negative errno value is returned and rte_errno is set. + */ +static int +mlx5_flow_item_mpls(const struct rte_flow_item *item __rte_unused, + struct rte_flow *flow __rte_unused, + const size_t flow_size __rte_unused, + struct rte_flow_error *error) +{ +#ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT + const struct rte_flow_item_mpls *spec = item->spec; + const struct rte_flow_item_mpls *mask = item->mask; + unsigned int size = sizeof(struct ibv_flow_spec_mpls); + struct ibv_flow_spec_mpls mpls = { + .type = IBV_FLOW_SPEC_MPLS, + .size = size, + }; + int ret; + + if (flow->l3_protocol_en && flow->l3_protocol != MLX5_IP_PROTOCOL_MPLS) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "protocol filtering not compatible" + " with MPLS layer"); + if (flow->layers & MLX5_FLOW_LAYER_TUNNEL) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "a tunnel is already" + " present"); + if (!mask) + mask = &rte_flow_item_mpls_mask; + ret = mlx5_flow_item_acceptable + (item, (const uint8_t *)mask, + (const uint8_t *)&rte_flow_item_mpls_mask, + sizeof(struct rte_flow_item_mpls), error); + if (ret < 0) + return ret; + if (spec) { + memcpy(&mpls.val.label, spec, sizeof(mpls.val.label)); + memcpy(&mpls.mask.label, mask, sizeof(mpls.mask.label)); + /* Remove unwanted bits from values. */ + mpls.val.label &= mpls.mask.label; + } + if (size <= flow_size) { + mlx5_flow_spec_verbs_add(flow, &mpls, size); + flow->cur_verbs->attr->priority = MLX5_PRIORITY_MAP_L2; + } + flow->layers |= MLX5_FLOW_LAYER_MPLS; + return size; +#endif /* !HAVE_IBV_DEVICE_MPLS_SUPPORT */ + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "MPLS is not supported by Verbs, please" + " update."); +} + /** * Convert the @p pattern into a Verbs specifications after ensuring the NIC * will understand and process it correctly. @@ -1662,6 +1757,9 @@ mlx5_flow_items(struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_GRE: ret = mlx5_flow_item_gre(pattern, flow, remain, error); break; + case RTE_FLOW_ITEM_TYPE_MPLS: + ret = mlx5_flow_item_mpls(pattern, flow, remain, error); + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 53992e8db..a04a84fec 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -35,7 +35,7 @@ #include "mlx5_prm.h" /* Support tunnel matching. */ -#define MLX5_FLOW_TUNNEL 3 +#define MLX5_FLOW_TUNNEL 5 struct mlx5_rxq_stats { unsigned int idx; /**< Mapping index. */ -- 2.18.0