From patchwork Wed Dec 21 15:19:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?N=C3=A9lio_Laranjeiro?= X-Patchwork-Id: 18411 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id ACA2510D1F; Wed, 21 Dec 2016 16:20:35 +0100 (CET) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by dpdk.org (Postfix) with ESMTP id 927FE10C93 for ; Wed, 21 Dec 2016 16:20:09 +0100 (CET) Received: by mail-wm0-f52.google.com with SMTP id a197so151099878wmd.0 for ; Wed, 21 Dec 2016 07:20:09 -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:in-reply-to:references :in-reply-to:references; bh=1EhG4lgbpJRGMcY6+dNinFEUT1VVhVy5yphTVB0BsF8=; b=o7JOLQalns6iyYSXg9+uQWqcy5BMJWrwizQTCZEWWi8WxuF/swkUEFrZSuroZVdScd nnEoRKkK5Rk0IsgPeEd6NmM63kEv5ubQ4BK6I8yHfqnB4EBQMXfwyry6lUPRmWhkwZdR g5hwp9brUbIaNIEpTT6GfNSyQemOexpQl+73ZEeY1uXlicEnefl9NgmzZvH09K5Zw5J4 1UQtP5X+12CXdcN0sgdYGztYPQO03LTNhp83asgf+/8BLGg4F5txgaTG+AyVtbtVYFWo z/wenLdirGaIPzZR1QnSUkKnQOAXCsCjD8OK2WnkGh4CezpujE8/k0B/zb1OeW5LSXwF jSIw== 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=1EhG4lgbpJRGMcY6+dNinFEUT1VVhVy5yphTVB0BsF8=; b=KcAM99eK+oGIPW16nPEOz5Z9tW98bQvbcMCGDyqiDOXPyxLftTaZOGxyMvl8t+hvq/ YsS9WDnY+T2cNs3b3prXLu6u8jfm7gmhI3MHa1+Kasvqvy4qC2puF5LSuHshcC/pLVfk 6J01w+XWWf+NvLRl4M2NtghYLD17dtCb5aF+m0eUXF7k74/lUbZi8gkkVVrJfDnmErEk R3482gdJ3OIReyHB6jzHUQyIz97mfu8sk4OlZRXjPLRdvSkJRXVCq2JQKTOZBWij9kTE DZewj0dsu515mKkotElY776rcVA3iNaCaqhhH875SJzFtgpUlg/B9qKCBNPLyLs7BN/I yqpA== X-Gm-Message-State: AIkVDXIZwG0VWLEgkPxWeHAQTjdUf/2mzovVvbvJ0WFn6ZO2ckpwbMJ6BZK9ohISJZu/azWX X-Received: by 10.28.67.69 with SMTP id q66mr5250693wma.22.1482333609077; Wed, 21 Dec 2016 07:20:09 -0800 (PST) Received: from ping.vm.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id gk6sm30984584wjc.46.2016.12.21.07.20.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Dec 2016 07:20:08 -0800 (PST) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Adrien Mazarguil Date: Wed, 21 Dec 2016 16:19:47 +0100 Message-Id: <297c72974f64847299a3533994470791cccf436e.1482331954.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 4/4] net/mlx5: add VLAN filter support in rte_flow 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_flow.c | 59 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index a33c568..2478fb6 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -184,6 +184,9 @@ priv_flow_validate(struct priv *priv, .dst_port = -1, }, }; + const struct rte_flow_item_vlan vlan_mask = { + .tci = -1, + }; if (attr->group) { rte_flow_error_set(error, ENOTSUP, @@ -228,11 +231,32 @@ priv_flow_validate(struct priv *priv, sizeof(eth_mask)); if (err) goto exit_item_not_supported; - } else if (items->type == RTE_FLOW_ITEM_TYPE_IPV4) { + } else if (items->type == RTE_FLOW_ITEM_TYPE_VLAN) { if (!ilast) goto exit_item_not_supported; else if (ilast->type != RTE_FLOW_ITEM_TYPE_ETH) goto exit_item_not_supported; + if (((const struct rte_flow_item_vlan *)items)->tci > + ETHER_MAX_VLAN_ID) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + items, + "wrong VLAN tci value"); + goto exit; + } + ilast = items; + err = mlx5_flow_item_validate( + items, + (const uint8_t *)&vlan_mask, + sizeof(vlan_mask)); + if (err) + goto exit_item_not_supported; + } else if (items->type == RTE_FLOW_ITEM_TYPE_IPV4) { + if (!ilast) + goto exit_item_not_supported; + else if (ilast->type != RTE_FLOW_ITEM_TYPE_ETH && + ilast->type != RTE_FLOW_ITEM_TYPE_VLAN) + goto exit_item_not_supported; ilast = items; err = mlx5_flow_item_validate( items, @@ -243,7 +267,8 @@ priv_flow_validate(struct priv *priv, } else if (items->type == RTE_FLOW_ITEM_TYPE_IPV6) { if (!ilast) goto exit_item_not_supported; - else if (ilast->type != RTE_FLOW_ITEM_TYPE_ETH) + else if (ilast->type != RTE_FLOW_ITEM_TYPE_ETH && + ilast->type != RTE_FLOW_ITEM_TYPE_VLAN) goto exit_item_not_supported; ilast = items; err = mlx5_flow_item_validate( @@ -372,6 +397,28 @@ mlx5_flow_create_eth(const struct rte_flow_item *item, } /** + * Convert VLAN item to Verbs specification. + * + * @param item[in] + * Item specification. + * @param eth[in, out] + * Verbs Ethernet specification structure. + */ +static void +mlx5_flow_create_vlan(const struct rte_flow_item *item, + struct ibv_exp_flow_spec_eth *eth) +{ + const struct rte_flow_item_vlan *spec = item->spec; + const struct rte_flow_item_vlan *mask = item->mask; + + if (spec) + eth->val.vlan_tag = spec->tci; + if (mask) + eth->mask.vlan_tag = mask->tci; + eth->val.vlan_tag &= eth->mask.vlan_tag; +} + +/** * Convert IPv4 item to Verbs specification. * * @param item[in] @@ -700,6 +747,14 @@ priv_flow_create(struct priv *priv, flow_size += eth_size; ++ibv_attr->num_of_specs; ibv_attr->priority = 2; + } else if (items->type == RTE_FLOW_ITEM_TYPE_VLAN) { + struct ibv_exp_flow_spec_eth *eth; + unsigned int eth_size = + sizeof(struct ibv_exp_flow_spec_eth); + + eth = (void *)((uintptr_t)ibv_attr + flow_size - + eth_size); + mlx5_flow_create_vlan(items, eth); } else if (items->type == RTE_FLOW_ITEM_TYPE_IPV4) { struct ibv_exp_flow_spec_ipv4 *ipv4; unsigned int ipv4_size =