From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60044.outbound.protection.outlook.com [40.107.6.44]) by dpdk.org (Postfix) with ESMTP id 558CA1BE21 for ; Wed, 4 Jul 2018 01:56:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2rffekASv1nwoHuS5+PaXXgQV7fpc+kcIQOJC1BHvT8=; b=QpGDeShjXDePZomuQQPHFXrpMW89+tHo94I8qTakHRMfKA4tkTk2/dbE8VBb1evwNMj9h2bDur63Skc6HFT0b9VXyakca2+h5c7ZohCn+R2tbBtD+0yUFWKb35hIOHTRK9BGzy193iaTOXYnF/q4q4Wz04FWKo1mo685FwgHmkc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; Received: from yongseok-MBP.local (209.116.155.178) by VI1PR0501MB2047.eurprd05.prod.outlook.com (2603:10a6:800:36::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.24; Tue, 3 Jul 2018 23:56:35 +0000 Date: Tue, 3 Jul 2018 16:56:21 -0700 From: Yongseok Koh To: Nelio Laranjeiro Cc: dev@dpdk.org, Adrien Mazarguil Message-ID: <20180703235620.GE41721@yongseok-MBP.local> References: <39544c46ba7237c339e89f10480c3e24a3810754.1530111623.git.nelio.laranjeiro@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <39544c46ba7237c339e89f10480c3e24a3810754.1530111623.git.nelio.laranjeiro@6wind.com> User-Agent: Mutt/1.9.3 (2018-01-21) X-Originating-IP: [209.116.155.178] X-ClientProxiedBy: BN6PR2001CA0033.namprd20.prod.outlook.com (2603:10b6:405:16::19) To VI1PR0501MB2047.eurprd05.prod.outlook.com (2603:10a6:800:36::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 419a45fb-e649-4b41-cf1b-08d5e1409c4e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2047; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2047; 3:0WDrB9kDai63bua84LdEkcHlyQsOeTHxaQIMx9gALBTIXJfhknnYVItBQQjnL16e66S4edAHAWD3dcHyghnybbekuR2DYNNxiPI+aMUXSegHAivzfno5xYZRaSjK1M/wmqMYSKyaA63YyyiVLX7N2jxPwHxtOhYOsBAJZqEXAXJaVnqYUrjOPqSw+33dJpN3Ot8lx8pO8FFJGa5SI4R8r001EzZn9LnJa4WDa0Zyc1HQYjDdmgfBHaLhv3lJ8dJO; 25:0uerUQXA9/h10kYlzjvEEdOPFgL4PSf9bo5OIioiRQOkuptl0tYCMoeHAjowAJGV7SSSQYlfGiXPAvZP+JqX+U2ReDhmVqToYZIX5ZCf+BEzf1l9yRokUAzM+xnno5Ak4/OvILMiwutvD1Ifm5b85QogutiCoXnfMslUXl3YTaoDvGRJyfPEszzW3//SrWC8C4zdyr5dcTrvasEDyGn02NftRnczHIp1f1ujO9QGtbp5rIZ6HqEygFPmPIzrdz0P6ksix+HVoVJ3AEePy/0DOrY/GJ1Wdu7eb7SZ8YAAS/E2yamaY8WmIZ385WMRtv48cVaQ4QYLOhV7MzXGKOSkIA==; 31:7q79zy5dXWr5ubY8yNJChFC0g+GL4cNSM0UyicVbr1RRwCQ2cQsmrFLsnA33wJaj+tS2dLnAiT68S2I6AeY5hrBQw1LbNL6YyNsEDUXPqenJkcKQl6DdG0R6eRcTP6++RFLEbAlCOr0BDzmfDFikMdqx9qid6RsffBup/1wihB/qVLXojRgXPtyKvQietXXA+gfSKDycdvxrOTBjUIvqFAH/64TsLilDVL2dBe1C4ek= X-MS-TrafficTypeDiagnostic: VI1PR0501MB2047: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2047; 20:WYup4Z2dOIi6zJ54kxfyz86npVF2BImhftsGf66U4r7Wi0y7IXk35zQll0EQyoVx+91evg/myCEkF2XWrI7LkAC/lzdgb1OHnqwcKj1CYA9bD92p0JssCKyulWTpPC2CxR4YbnQIq6VNN045usOX5a5Qo6QYm/0Qh8mO5l2/oX6zGd9tYviez2GrMTfu8VXKLU1YsCF3NOOr5g/5p/45MiuTfZfGABuYN95WQRFAJBghAQRAWPx14Y0ZV7fL2KWMCX4alYw2nnIOf4izFIYyuHSIJDdE7Ed4ZwP/xeEtb8SvNhoVzmE69CyLii5t87VnqEY6mDjF4r14ABa2eirG2Jqb7I8MPPjXdB6wy0Wkbw+2LZC7gC1m7dpx44efkJEWGSGoU7q9N11ri2Ubvl8650VOq1mGmqrUseww+3dVWlgsVuYn7vwTNZG4TExKr2AuK6v25epLR2AIUo47lpeE558EEMeF2MizXNuSMM19B1OLxTtkiLJuCymGc0VV17PJ; 4:V3U9HIa+sM/kIBZqBqyDXwL80zyiEA2O4Iq0EPpTUUyq1oEMAzg3Jql9MkKhBJAoYO0/MKLcK7pa0KpScYCj6JnefJLES8gZoQCS8LMaH06pY8NdyCR8h3BX4zXJr+MLSN+TcqXmLm4HKNb+erNhjA5H8NLruGI/4jYSE2u46bZWTqxUOv+KGLq9n75z1RQcDhV4FmcoHzB67My76f8HgNBupXxFrcttBGaf/87s9kMW9hKINk7udKcIdGAxkSEPUb2qXubzo7CBhhqNQq9lyg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231254)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2047; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2047; X-Forefront-PRVS: 0722981D2A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(136003)(376002)(396003)(346002)(39860400002)(199004)(189003)(6506007)(316002)(33896004)(486006)(386003)(26005)(7696005)(186003)(16526019)(106356001)(76176011)(98436002)(52116002)(55016002)(58126008)(16586007)(9686003)(81156014)(81166006)(105586002)(4326008)(3846002)(6666003)(47776003)(476003)(6116002)(1076002)(6246003)(14444005)(478600001)(8676002)(7736002)(53936002)(305945005)(8936002)(33656002)(23726003)(575784001)(50466002)(446003)(956004)(11346002)(5660300001)(86362001)(229853002)(66066001)(68736007)(2906002)(6916009)(97736004)(25786009)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2047; H:yongseok-MBP.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0501MB2047; 23:znlGpFGHEqbEQGHyGaXVkEmGyBUqI10tJKlFumJ?= =?us-ascii?Q?Cgv3PpsvlakrjSujDJoEka62VsilXekxBTBZ3Qy22drkZPXphOhBKplhzBT4?= =?us-ascii?Q?UoxcJ3Ny9zEFhDiKA6hE66TasQCtHaw9Yxv0RdHVTufUWTn7pnrnPp5ipSW1?= =?us-ascii?Q?NxE56tjeUCft6x6UwzcSnKQaGgx4hme4IHu/2eOXDwEeaaaZ303o3FDCehO7?= =?us-ascii?Q?8WLA7t/ZAV5MRh+qNoco35o8pzQCBTRg44syV1UT4/7q05yYjac4H4gb9H48?= =?us-ascii?Q?k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7Trgi6ciUtRNLPe76deeiSW+2XhTnjGtGQ==; 5:bftRquvCtaEFW7ggTnvZ2TxtxVAr5qh8RVo22Q6OcNNb0y9igh4bv4JEJ7rtRy+dD4QT6IGN+uU1yGJHO3/9N6Fn0U9clpmRMgua3+K49dLi6N2/65Rzh6BwT7zndlxc8QoyigtOQ6LHYOIhrU8dXXGubU9Vjc8bQI7SpRuOjUU=; 24:jy5KqTwUBucs8gk3RpTYmtv5JKCLM2kDS8DFK+AAdZ/XvpDkcS1J2zPeczRfgOYiGWnbJOoosSgedRynHW1123OQfWKrcMr4l+pt/HaheIE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2047; 7:1wwK/KSOaqplRVGRWEScJUQhxR0UYDKarLQ332AHxA3rALFOksYGufck6O3foz0X9SOU3MNCVcrSCkH8oth7SCtBZTuTItP5FKjNZXgHVRSF5yZIWaquwxQYijs7J0XTKbgImPvLMVEYsDcjrwyV5WbuYtg9TWcFnlRXAH+JbzLzC5Ivtx8LwYsUCqnczytH6eZIjBv5vB4dcuDPC6AnCqwILdcjAJqspozE8YOPQbPUdwIOfcqoZUx57AAdqj3V X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2018 23:56:35.0823 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 419a45fb-e649-4b41-cf1b-08d5e1409c4e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2047 Subject: Re: [dpdk-dev] [PATCH v2 07/20] net/mlx5: add flow VLAN 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: Tue, 03 Jul 2018 23:56:38 -0000 On Wed, Jun 27, 2018 at 05:07:39PM +0200, Nelio Laranjeiro wrote: > Signed-off-by: Nelio Laranjeiro > --- > drivers/net/mlx5/mlx5_flow.c | 123 +++++++++++++++++++++++++++++++++++ > 1 file changed, 123 insertions(+) > > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index 6593eafa0..6a576ddd9 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -420,6 +420,126 @@ mlx5_flow_item_eth(const struct rte_flow_item *item, struct rte_flow *flow, > return size; > } > > +/** > + * Update the VLAN tag in the Ethernet spec. > + * > + * @param attr[in, out] > + * Pointer to Verbs attributes structure. > + * @param eth[in] > + * Verbs structure containing the VLAN information to copy. > + */ > +static void > +mlx5_flow_item_vlan_update(struct ibv_flow_attr *attr, > + struct ibv_flow_spec_eth *eth) > +{ > + unsigned int i; > + enum ibv_flow_spec_type search = IBV_FLOW_SPEC_ETH; > + struct ibv_spec_header *hdr = (struct ibv_spec_header *) > + ((uint8_t *)attr + sizeof(struct ibv_flow_attr)); > + > + for (i = 0; i != attr->num_of_specs; ++i) { > + if (hdr->type == search) { > + struct ibv_flow_spec_eth *e = > + (struct ibv_flow_spec_eth *)hdr; > + > + e->val.vlan_tag = eth->val.vlan_tag; > + e->mask.vlan_tag = eth->mask.vlan_tag; You'll have to overwrite ether_type as well, otherwise the e->ether_type would have TPID. > + break; > + } > + hdr = (struct ibv_spec_header *)((uint8_t *)hdr + hdr->size); > + } > +} > + > +/** > + * Validate VLAN layer and possibly create/modify the Verbs specification. > + * > + * @param item[in] > + * Item specification. > + * @param flow[in, out] > + * Pointer to flow structure. > + * @param flow_size[in] > + * Size of the buffer to store the specification. > + * @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_vlan(const struct rte_flow_item *item, struct rte_flow *flow, > + const size_t flow_size, struct rte_flow_error *error) > +{ > + const struct rte_flow_item_vlan *spec = item->spec; > + const struct rte_flow_item_vlan *mask = item->mask; > + const struct rte_flow_item_vlan nic_mask = { > + .tci = RTE_BE16(0x0fff), > + }; > + unsigned int size = sizeof(struct ibv_flow_spec_eth); > + struct ibv_flow_spec_eth eth = { > + .type = IBV_FLOW_SPEC_ETH, > + .size = size, > + }; > + int ret; > + const uint32_t lm = MLX5_FLOW_LAYER_OUTER_L3 | > + MLX5_FLOW_LAYER_OUTER_L4; What does 'lm' stand for? Better to use l34m? > + const uint32_t vlanm = MLX5_FLOW_LAYER_OUTER_VLAN; > + const uint32_t l2m = MLX5_FLOW_LAYER_OUTER_L2; > + > + if (flow->layers & vlanm) > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "L2 layers already configured"); L2? Not VLAN? > + else if ((flow->layers & lm) != 0) > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "L2 layer cannot follow L3/L4 layer"); > + if (!mask) > + mask = &rte_flow_item_vlan_mask; > + ret = mlx5_flow_item_validate(item, (const uint8_t *)mask, > + (const uint8_t *)&nic_mask, > + sizeof(struct rte_flow_item_vlan), error); > + if (ret) > + return ret; > + if (spec) { > + eth.val.vlan_tag = spec->tci; > + eth.mask.vlan_tag = mask->tci; > + eth.val.vlan_tag &= eth.mask.vlan_tag; > + eth.val.ether_type = spec->inner_type; > + eth.mask.ether_type = mask->inner_type; > + eth.val.ether_type &= eth.mask.ether_type; > + } > + /* > + * From verbs perspective an empty VLAN is equivalent > + * to a packet without VLAN layer. > + */ > + if (!eth.mask.vlan_tag) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, > + item->spec, > + "VLAN cannot be empty"); > + /* Outer TPID cannot be matched. */ > + if (eth.mask.ether_type) > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, > + item->spec, > + "VLAN TPID matching is not" > + " supported"); Not sure 100% but I don't think ether_type means TPID but the inner packet type coming after the VLAN ID. E.g. /dmac/smac/0x8100/TCI/0x0800/ipv4... ^ | > + if (!(flow->layers & l2m)) { > + if (size <= flow_size) > + mlx5_flow_spec_verbs_add(flow, ð, size); > + } else { > + if (flow->verbs.attr) > + mlx5_flow_item_vlan_update(flow->verbs.attr, ð); > + size = 0; /**< Only an update is done in eth specification. */ Any specific reason to use doxygen style comment only here? > + } > + flow->layers |= MLX5_FLOW_LAYER_OUTER_L2 | > + MLX5_FLOW_LAYER_OUTER_VLAN; > + return size; > +} > + > /** > * Validate items provided by the user. > * > @@ -453,6 +573,9 @@ mlx5_flow_items(const struct rte_flow_item items[], > case RTE_FLOW_ITEM_TYPE_ETH: > ret = mlx5_flow_item_eth(items, flow, remain, error); > break; > + case RTE_FLOW_ITEM_TYPE_VLAN: > + ret = mlx5_flow_item_vlan(items, flow, remain, error); > + break; > default: > return rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_ITEM, > -- > 2.18.0 >