From patchwork Thu Dec 29 15:15:19 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: 18670 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 E12826932; Thu, 29 Dec 2016 16:16:39 +0100 (CET) Received: from mail-wj0-f170.google.com (mail-wj0-f170.google.com [209.85.210.170]) by dpdk.org (Postfix) with ESMTP id E8DE637A8 for ; Thu, 29 Dec 2016 16:15:41 +0100 (CET) Received: by mail-wj0-f170.google.com with SMTP id sd9so175176723wjb.1 for ; Thu, 29 Dec 2016 07:15:41 -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=/chTILvVe5O372yHfNIv8RoqjYmlTHdRsq93X1Snxb8=; b=uRlCVgI155ATtHzQxielQX2d9Hx/qbq6HtebKs8xvl+qnqGLhAUoPka+Hz2ypl/FN4 uKuBPMbWK0v/sNGg/DUOuGy7E41umzZm/0vENZEHdh5S588nsZ8b946nHQ+vtIDIxQ0A TGfnvjXDLgokbzqCZOBUZO1RKui+LbXHa5t8sPCRn1wdNV7z4FakB96SS9Crap61z51l +olNq2ICZJGyAhB/YRf6d0x0chk5aZNUz25QCo0JDDnH6yCT2/dyiWrK8g9s3KaUoFYZ C6zjku6psdBl2vd3/b7a2uRi/RFHv8V9gdD05O73GuLG7JMAyxqI7CJVE0wjCD6G1kph Me+A== 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=/chTILvVe5O372yHfNIv8RoqjYmlTHdRsq93X1Snxb8=; b=LG9Fp23YpE4QWWs1Bwe6q05RJjTI3ChiqBdmttj5Wg7lsw6McsSCjwmgtyPfyA6EF7 Vu2qK8fYnWQkUcjg+CgpIoEklCTBy49JueYKAsEt7aDbns6aaVjtN20GUim9vw/XMyfc NFXx9zMywaghKVjGUHOR9kqGZQnBPirZFkvT9es/PsOp9Jy0nOJMWa+Y44YibPz72iMl WWvedDk+9y0VEOipFgDrM8HbMPBEqpC997sdWJUqMLvbdBLP7ucdOlFUxJUnSfl2W3zb 0EOBFL63xw+lRQWec7j+aMgTmp7xmMYuh6woMhb5w7nW0hF6XfAWd46zWNor7TyVCj9N 7v/w== X-Gm-Message-State: AIkVDXIrW2vodxni+32LswCz4mjuXdy5H4eoecIla30Y2Njqff/RqYFvzsqfGc80YCOK49D/ X-Received: by 10.194.179.135 with SMTP id dg7mr36552563wjc.219.1483024541381; Thu, 29 Dec 2016 07:15:41 -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 o3sm69289997wjx.39.2016.12.29.07.15.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Dec 2016 07:15:40 -0800 (PST) From: Nelio Laranjeiro To: dev@dpdk.org, Ferruh Yigit Cc: Adrien Mazarguil Date: Thu, 29 Dec 2016 16:15:19 +0100 Message-Id: <962da76f2f17e841bfa083dafbf17b4ef4220575.1483022600.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 v5 3/6] net/mlx5: support VLAN flow 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Nelio Laranjeiro Acked-by: Adrien Mazarguil --- drivers/net/mlx5/mlx5_flow.c | 62 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 4f6696e..8f2f4d5 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -57,6 +57,11 @@ mlx5_flow_create_eth(const struct rte_flow_item *item, void *data); static int +mlx5_flow_create_vlan(const struct rte_flow_item *item, + const void *default_mask, + void *data); + +static int mlx5_flow_create_ipv4(const struct rte_flow_item *item, const void *default_mask, void *data); @@ -136,7 +141,8 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { .items = ITEMS(RTE_FLOW_ITEM_TYPE_ETH), }, [RTE_FLOW_ITEM_TYPE_ETH] = { - .items = ITEMS(RTE_FLOW_ITEM_TYPE_IPV4, + .items = ITEMS(RTE_FLOW_ITEM_TYPE_VLAN, + RTE_FLOW_ITEM_TYPE_IPV4, RTE_FLOW_ITEM_TYPE_IPV6), .actions = valid_actions, .mask = &(const struct rte_flow_item_eth){ @@ -147,6 +153,17 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { .convert = mlx5_flow_create_eth, .dst_sz = sizeof(struct ibv_exp_flow_spec_eth), }, + [RTE_FLOW_ITEM_TYPE_VLAN] = { + .items = ITEMS(RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_IPV6), + .actions = valid_actions, + .mask = &(const struct rte_flow_item_vlan){ + .tci = -1, + }, + .mask_sz = sizeof(struct rte_flow_item_vlan), + .convert = mlx5_flow_create_vlan, + .dst_sz = 0, + }, [RTE_FLOW_ITEM_TYPE_IPV4] = { .items = ITEMS(RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_TCP), @@ -355,6 +372,17 @@ priv_flow_validate(struct priv *priv, if (items->type == RTE_FLOW_ITEM_TYPE_VOID) continue; + /* Handle special situation for VLAN. */ + if (items->type == RTE_FLOW_ITEM_TYPE_VLAN) { + 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 id value"); + return -rte_errno; + } + } for (i = 0; cur_item->items && cur_item->items[i] != RTE_FLOW_ITEM_TYPE_END; @@ -481,6 +509,38 @@ mlx5_flow_create_eth(const struct rte_flow_item *item, } /** + * Convert VLAN item to Verbs specification. + * + * @param item[in] + * Item specification. + * @param default_mask[in] + * Default bit-masks to use when item->mask is not provided. + * @param data[in, out] + * User structure. + */ +static int +mlx5_flow_create_vlan(const struct rte_flow_item *item, + const void *default_mask, + void *data) +{ + const struct rte_flow_item_vlan *spec = item->spec; + const struct rte_flow_item_vlan *mask = item->mask; + struct mlx5_flow *flow = (struct mlx5_flow *)data; + struct ibv_exp_flow_spec_eth *eth; + const unsigned int eth_size = sizeof(struct ibv_exp_flow_spec_eth); + + eth = (void *)((uintptr_t)flow->ibv_attr + flow->offset - eth_size); + if (!spec) + return 0; + if (!mask) + mask = default_mask; + eth->val.vlan_tag = spec->tci; + eth->mask.vlan_tag = mask->tci; + eth->val.vlan_tag &= eth->mask.vlan_tag; + return 0; +} + +/** * Convert IPv4 item to Verbs specification. * * @param item[in]