From patchwork Wed Dec 28 10:37:16 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: 18606 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 C5465689B; Wed, 28 Dec 2016 11:38:16 +0100 (CET) Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id B58305320 for ; Wed, 28 Dec 2016 11:37:38 +0100 (CET) Received: by mail-wm0-f47.google.com with SMTP id c85so94217733wmi.1 for ; Wed, 28 Dec 2016 02:37:38 -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=7JxjMCxAILijhzDNXYuOkRQ7hQqStj2HJzSDHxzXz20=; b=qL8JngMwR+onfZLNrVQm4fwKzQ4mYhzOFKC1u1ElEptLIXOVvYPrQ3eK5QGGk+1ZMU IhKVAAAL1KvXnamAnqgHj0bPe/K8Y4yhkpQTVJya6SWiSWtI+8hzsrrK0zjVjsGnNS41 YaK96dalSgmtRj4acG6GrIsPDGm/GL8wgJIm10N1J9CIFU50gvfO1V2jKeFhR4zaLDyK zyc5U6/SKWQ6fuIyubGHg4GM9jF94yxAQFTQPWlIS3EcWGitbpRGsbyMGgmjqMY9pAb1 0bjV/8XgGeo/uy67p0B0I9axB/ee5IPtgyiTyKKuTK+N2f0HFhCjuqxm2+VbktIeQ9lX aVNA== 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=7JxjMCxAILijhzDNXYuOkRQ7hQqStj2HJzSDHxzXz20=; b=h5CErMmH7BNibI7ciXd8997+/ug7C5m9OxxG39IQAfeMasu4POI48fSq2xJN+bgI83 f7ws2ADC6cvxIF7HaUAX3KkQUvAkgq56T7LzTzU7WxOR55/hhyV9vVCNvFSVBuUICLCk oR28O/HcEyHUpJalsmZEnohHutuogYILS5oDtpK5kQ0LJ0Ek5dUyXXAZIewVA+s3rgjT JpZZj5ELNStAAgTlM+iFgeP0enzQiOSBrD06kjb5vr8EvvnJQ/oT8bNANYBOo2DYmL+X 1WR/D0mMhJLN4Q2cocJxoqoIi2h+Oi0HLpgSOi+flTE5dcGeXVTmzKht8YT5tvDnteaw p9xg== X-Gm-Message-State: AIkVDXKNiifLNpVxndzRnwIX021nPBX3vSbuHL294hUJIuwno5eVt5M7fXTpavpQmBwzPdlW X-Received: by 10.28.214.84 with SMTP id n81mr30128720wmg.120.1482921458261; Wed, 28 Dec 2016 02:37:38 -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 kq6sm30022703wjc.7.2016.12.28.02.37.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Dec 2016 02:37:37 -0800 (PST) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Adrien Mazarguil Date: Wed, 28 Dec 2016 11:37:16 +0100 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 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 | 54 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index ebae2b5..549da6c 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -55,6 +55,9 @@ static int mlx5_flow_create_eth(const struct rte_flow_item *item, void *data); static int +mlx5_flow_create_vlan(const struct rte_flow_item *item, void *data); + +static int mlx5_flow_create_ipv4(const struct rte_flow_item *item, void *data); static int @@ -131,7 +134,8 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { .dst_sz = sizeof(struct ibv_exp_flow_spec_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){ @@ -142,6 +146,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), @@ -348,6 +363,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; @@ -471,6 +497,32 @@ mlx5_flow_create_eth(const struct rte_flow_item *item, void *data) } /** + * Convert VLAN item to Verbs specification. + * + * @param item[in] + * Item specification. + * @param data[in, out] + * User structure. + */ +static int +mlx5_flow_create_vlan(const struct rte_flow_item *item, 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) + eth->val.vlan_tag = spec->tci; + if (mask) + 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]