From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 74C721BFB3 for ; Wed, 27 Jun 2018 17:07:51 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id z13-v6so5887360wma.5 for ; Wed, 27 Jun 2018 08:07:51 -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=PRNbGMzLnw+u8zm2HpUIy0dpaKmm+KntfFVkJ/PR6wU=; b=r3P78um5b/UV6E3h4D2+qEP0txvIRT9d3vh70Xw/U+bV3W4EsHn62OsoraSaP2usw0 JPPAF8iTaSsD3dux3V09mesnKSfVjJQpJppnDpm9zIvcVioq5EHm3AW9Lb5pCp291k1+ /njHinUn885pTscNWtu7J8qGZBbSQESbJanKjGgh8HEHAPNQyCBmkFWG+Vm2tafVdx7S ZbzTZpnUqH+qAdC7nxO7ZxGrF0EIdr9CMpss2QDs3emk75s4/zg+rzmF+6kyy5xrwiop CrIjG0x3kAKUGZbUEWZbnG/m05u2xIutFT2t5iaiFOu/jRi9drtwK+oEc1farjz74AaM n/2g== 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=PRNbGMzLnw+u8zm2HpUIy0dpaKmm+KntfFVkJ/PR6wU=; b=Hc6A76vZ7jVXKUjpdAy9cerGwoYBYDTsCZ1JApJTpMfRlS2ehDTo3ox0t/y562yAaD sLxI2wh44M4xWVK6iSXbkG8d5CLT87nKlVqal2GS2Jxz7wobCT2UnuEOe1LFcVq3mkMk CThg0gspJ25im+Fb/2v29100tvXdwgi09jGiGYYTe+FMRXzidWbGYSLj0RUacDdrFbi4 b+g4x3oCZL4TRUMnVpva7Ddg1aIfKW/KOQoIO6cpZRLOyR6fgoP908Fh+2JCn36XHPYV FkkVFOYAZDvYfKJN0wMHD058I9JArKYCffJkkELbEUu9kqiuKrURZ4dEUI6D3HDOr1Ec BugQ== X-Gm-Message-State: APt69E2xb47QFGtzb6s8ojVg5/7RT8ulTPo84s/EjRFylg46F2kF/PEb DqNws3dSPJPugmYsBPBLvsBPmjpGAg== X-Google-Smtp-Source: AAOMgpdnrt2fZYdy/HDyZe0y4L4U3QlhNfr3tXzMFa/HhykwcruZ/5qsS2erekbJH8kVP5x/EECBVw== X-Received: by 2002:a1c:7153:: with SMTP id m80-v6mr5088411wmc.7.1530112070935; Wed, 27 Jun 2018 08:07:50 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 08:07:50 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org, Adrien Mazarguil , Yongseok Koh Date: Wed, 27 Jun 2018 17:07:51 +0200 Message-Id: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 19/20] 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: Wed, 27 Jun 2018 15:07:51 -0000 Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_flow.c | 77 +++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 636aaabe8..7aa4e6ed5 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 \ @@ -1589,6 +1590,77 @@ mlx5_flow_item_gre(const struct rte_flow_item *item, return size; } +/** + * Validate MPLS layer and possibly create the Verbs specification. + * + * @param dev + * Pointer to Ethernet device. + * @param item[in] + * Item specification. + * @param flow[in, out] + * Pointer to flow structure. + * @param flow_size[in] + * Size in bytes of the available space for to store the flow information. + * @param error + * Pointer to error structure. + * + * @return + * size in bytes necessary for the conversion, a negative errno value + * otherwise 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, + }; + const uint32_t layers = mlx5_flow_layers(flow); + int ret; + + if (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_validate + (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); + mlx5_flow_layers_update(flow, MLX5_FLOW_LAYER_MPLS); + if (layers & MLX5_FLOW_LAYER_OUTER_L4_UDP) + flow->ptype = RTE_PTYPE_TUNNEL_MPLS_IN_GRE | RTE_PTYPE_L4_UDP; + else + flow->ptype = RTE_PTYPE_TUNNEL_MPLS_IN_GRE; + 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."); +} + /** * Validate items provided by the user. * @@ -1650,6 +1722,9 @@ mlx5_flow_items(struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_GRE: ret = mlx5_flow_item_gre(items, flow, remain, error); break; + case RTE_FLOW_ITEM_TYPE_MPLS: + ret = mlx5_flow_item_mpls(items, flow, remain, error); + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, -- 2.18.0