From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730046.outbound.protection.outlook.com [40.107.73.46]) by dpdk.org (Postfix) with ESMTP id C631D1B188 for ; Sat, 29 Sep 2018 12:32:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=AQUANTIA1COM.onmicrosoft.com; s=selector1-aquantia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3EcjG9rta78DkNU81ClDqkC3O4GsrmPr9ACgSKbBidU=; b=hTmTH/gzZk28kdtPNB9YDJISiZL+5OqMwHwaXUq0Nu4GpIteMv+5Qdl55tmi5IT17XXs1hvoNe5F3GeabxpBp4/7ddMf9oeBCPUpucE8dMQ3y6Lg4IF3H4jobksI0hGOLMW5uCiDeqCn+Wwv8KmGqMuj0i7wK7RwMNRXncjQexI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; Received: from ubuntubox.rdc.aquantia.com (95.79.108.179) by BLUPR0701MB1650.namprd07.prod.outlook.com (2a01:111:e400:58c6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.22; Sat, 29 Sep 2018 10:32:34 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, igor.russkikh@aquantia.com, Pavel Belous Date: Sat, 29 Sep 2018 13:30:32 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.79.108.179] X-ClientProxiedBy: VI1P193CA0009.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::19) To BLUPR0701MB1650.namprd07.prod.outlook.com (2a01:111:e400:58c6::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 36c78846-dbe4-4546-1849-08d625f6e221 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1650; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 3:ay0VmzHPT0+XbB9SJpIRn1Vqdjc1lWovw3uLtD758CanB1ktwtyydBeT2oMadtlIE54aKCoEkMWhGma31SE38/vcWiEsB7ZydKPZOrm3fiXDLIi/Wsv3XCkfpn9DtmBEkpMIQaso0hIxBSGWl7ssd8+BAd//Hn0qr5y8K/Br8W7NB/EpCQnHovjBvkmxxzbBpuni/ShvLS2hSX92wVJ2hmvoxqTNgETLohr5nkZ1J+7TFEcGih/70TDvm7bc2tIg; 25:YbAkDdWN7uG0shGmdFaw7gppiH4MRFZoLGGEzmFNIfLj85tDfN4y4yvaq3R/u1YoggekkL4FS6Ml4qS2ej+R+P4jlkL/H/eQWkisHsFnepjuIodI7EEAaZGjBSQpKKjIkPHHmp6J6xXBzF4cyTG3mCC4XVbY/XbVlMtaytbbh//1aAarIpam+D4jLcCcyeI0NBMHWoL0FnP76daw9h/ZPIIk6jNZvzpbiKYLjwrs0fxvgXNLI6lmJ36p44hY/bqhDz6HLdWm3D/tqyq1QwV35uacFrXM+bt/obBotugafbJP6iayJridUCNOin3Cq1Jgc5rRRvK4IquGh5m6347QJvCV4V8lsy1KnZXOqbfoIaA=; 31:fCVZLkeyw/jmlTI+9M8BD4jKVkU6CA6xv6E48RpuKWdyxmQ6aPwZa5rnFgUC+0MfM2CjX8gpnlZNwqIaYGQSb2s8Z31ZPTVVojooysDYxPfAZAA8tKKvBSKpd4sn0blewk4cP2VhXiNA87rO1bm73J0E1OGaDWl/Sbu2+9e8vfGQdi6tnRLp8ffouWECEVdwLrMTXgBscqakcrzmXJ9XMRm+75eOylrd9/dTDw2hCI4= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1650: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 20:db3va+zY6/wVaOykh6611lAKJdfPkIeEPDhY+XtNdQC0ttDJCU1r/yFChEs2ZF3uDacTh46XinShDMHYNLKcNEnoZyqiAg2iM8cEzb2Led9X+wqKrttEblhZKw/Cvs6rSmRVMdru5wkq3wdBp0A+sJ5LfNgALGgUuAd21u/VFS+QBqZDWPlUL0j35BPVk4RXdRzEOgGv6vWoDIJ7JtHsNvmuSL65myKy2Tt4gEfHBl1+slpT0c1nW8zWZbyYGh7m7X1AXjm9jK9kTW2sx7nE3Gb2FmNwyOxJ+Y9SuetsUzhOV45RMJs2vNrM7x6SeDF34uLtG52nzs513i6le/k97AztZ81Po+IUSBnCOCVNVUNpkcHNfDSXS/XdkMApHonhm06/btNv4CF1GHJ13+xKDRFzzDyVUgMV2IlmScspbaQp4X/lkUjBzPBM3A37rTrxuDA+NHzCk8X0OmD9EHLgvZdWWE/W9xRa69Uo1GuiHw7hoHJewiZv9hkMG7zFabaq; 4:f1BhsBa5mx1dWmhV1JhjTqifpb5DJledPW6kUDq7gDnF2iS7z8G2jUX2W4tBzKVXowtkaM+R4NVZdB07TgFBvUlvE6iGZdPWOEOygbCMuKwhOOpdRphXWRuanNOiXQ0RPA2KhAeMmBWsC2Tm32J1Qtvf6VYy2D6aXz5meWHFAtasCjmtXcftgBWdyB6lc7zq/X8tKhKWc89+ADB/Wm/WEPYjbKDmGDBKHpWXcdcthR4kTfb21yPO75s0epS8rzYWYyGEn6iFg8rSZESp957o7A== 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:(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231355)(944501410)(52105095)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051); SRVR:BLUPR0701MB1650; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1650; X-Forefront-PRVS: 0810818DA0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(136003)(396003)(376002)(39850400004)(366004)(189003)(199004)(16526019)(14444005)(446003)(76176011)(2906002)(6916009)(97736004)(8676002)(81166006)(81156014)(36756003)(4326008)(316002)(8936002)(50226002)(34290500001)(86362001)(5660300001)(68736007)(16586007)(118296001)(72206003)(3846002)(6116002)(53936002)(386003)(105586002)(6486002)(47776003)(66066001)(486006)(25786009)(305945005)(50466002)(44832011)(956004)(2616005)(26005)(107886003)(52116002)(51416003)(7696005)(186003)(476003)(478600001)(2361001)(7736002)(2351001)(48376002)(106356001)(11346002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1650; H:ubuntubox.rdc.aquantia.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1650; 23:Txe92TCpmM+w3Z0DljFi/3cXYFIRDTseOZFNS6G?= =?us-ascii?Q?58pNd1NWHeK3HE9VGrG0+glPXzeCDmkTrzrvK8M7MaMvXxVKA2wInh+e8yUw?= =?us-ascii?Q?T7+HgjLxREiHT8WMvE7KfmKriY+SVNKdBdo8a31AbfIprQ6OoDQ4vDOpYeG1?= =?us-ascii?Q?QrvecaxK9U2FeGr3vaP34F6cYo+muhBbQnriTGGMwc01pRlqIUNmMSSb7uQW?= =?us-ascii?Q?IpVPWUGalhdN8YNXMqCQ9YYfweL1fre8XoMsBkFQVbqyw+I9d8en+nhA+xxh?= =?us-ascii?Q?DoDOTK9nHRSxdK29CidNjpxwwNCNHK/Dju8taueF/FILPPiqifI4xkOmhBgo?= =?us-ascii?Q?Q4LEVQ2ZLZXsVzLrTwiJ7HXMT8i8ikuHnrLKZkoz1/bAoFbBCF61lZ4dxt78?= =?us-ascii?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Bh2bFlFVXR9WoA2NDiON8EB8sbSggptaSpSDlOoj+NfvYkW28rd5M0v3kMbM=; 7:HYVFXxnUc8aTzteTbDbnPuOND6JBQOoAtlWAPKCq4ekffm5lTcGWBN929vWulHRZkWmWSrpsQtLu4wmRXoRr2p7r54m07LLaLiYGX2otTJAQtku5Y9l+sXsQjRSrefAYOypK73YKNZ08+NV8e8iicyDsBvwoGSU78iNKsVCMm3KHBZWb20CXr9v1G+A5NHprVlqXKmmEXek0iWBEhx8LMWrrteMJd+btyJnXc6JCK29NfxZiXGbVmqM9uX/V1E5b SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2018 10:32:34.4721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 36c78846-dbe4-4546-1849-08d625f6e221 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1650 Subject: [dpdk-dev] [PATCH v3 18/22] net/atlantic: VLAN filters and offloads 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: Sat, 29 Sep 2018 10:32:42 -0000 From: Pavel Belous Signed-off-by: Igor Russkikh Signed-off-by: Pavel Belous --- drivers/net/atlantic/atl_ethdev.c | 161 ++++++++++++++++++++++++++++++++++++++ drivers/net/atlantic/atl_types.h | 2 + 2 files changed, 163 insertions(+) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index b71028d9d227..792dd7be127a 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -56,6 +56,20 @@ static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev); static int atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); + +/* VLAN stuff */ +static int atl_vlan_filter_set(struct rte_eth_dev *dev, + uint16_t vlan_id, int on); + +static int atl_vlan_offload_set(struct rte_eth_dev *dev, int mask); + +static void atl_vlan_strip_queue_set(struct rte_eth_dev *dev, + uint16_t queue_id, int on); + +static int atl_vlan_tpid_set(struct rte_eth_dev *dev, + enum rte_vlan_type vlan_type, uint16_t tpid); + + /* Flow control */ static int atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf); @@ -227,6 +241,12 @@ static const struct eth_dev_ops atl_eth_dev_ops = { .mtu_set = atl_dev_mtu_set, + /* VLAN */ + .vlan_filter_set = atl_vlan_filter_set, + .vlan_offload_set = atl_vlan_offload_set, + .vlan_tpid_set = atl_vlan_tpid_set, + .vlan_strip_queue_set = atl_vlan_strip_queue_set, + /* Queue Control */ .rx_queue_start = atl_rx_queue_start, .rx_queue_stop = atl_rx_queue_stop, @@ -1265,6 +1285,147 @@ atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) } static int +atl_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) +{ + struct aq_hw_cfg_s *cfg = + ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private); + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + int err = 0; + int i = 0; + + PMD_INIT_FUNC_TRACE(); + + for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) { + if (cfg->vlan_filter[i] == vlan_id) { + if (!on) { + /* Disable VLAN filter. */ + hw_atl_rpf_vlan_flr_en_set(hw, 0U, i); + + /* Clear VLAN filter entry */ + cfg->vlan_filter[i] = 0; + } + break; + } + } + + /* VLAN_ID was not found. So, nothing to delete. */ + if (i == HW_ATL_B0_MAX_VLAN_IDS && !on) + goto exit; + + /* VLAN_ID already exist, or already removed above. Nothing to do. */ + if (i != HW_ATL_B0_MAX_VLAN_IDS) + goto exit; + + /* Try to found free VLAN filter to add new VLAN_ID */ + for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) { + if (cfg->vlan_filter[i] == 0) + break; + } + + if (i == HW_ATL_B0_MAX_VLAN_IDS) { + /* We have no free VLAN filter to add new VLAN_ID*/ + err = -ENOMEM; + goto exit; + } + + cfg->vlan_filter[i] = vlan_id; + hw_atl_rpf_vlan_flr_act_set(hw, 1U, i); + hw_atl_rpf_vlan_id_flr_set(hw, vlan_id, i); + hw_atl_rpf_vlan_flr_en_set(hw, 1U, i); + +exit: + /* Enable VLAN promisc mode if vlan_filter empty */ + for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) { + if (cfg->vlan_filter[i] != 0) + break; + } + + hw_atl_rpf_vlan_prom_mode_en_set(hw, i == HW_ATL_B0_MAX_VLAN_IDS); + + return err; +} + +static int +atl_enable_vlan_filter(struct rte_eth_dev *dev, int en) +{ + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct aq_hw_cfg_s *cfg = + ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private); + int i; + + PMD_INIT_FUNC_TRACE(); + + for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) { + if (cfg->vlan_filter[i]) + hw_atl_rpf_vlan_flr_en_set(hw, en, i); + } + return 0; +} + +static int +atl_vlan_offload_set(struct rte_eth_dev *dev, int mask) +{ + struct aq_hw_cfg_s *cfg = + ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private); + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + int ret = 0; + int i; + + PMD_INIT_FUNC_TRACE(); + + ret = atl_enable_vlan_filter(dev, mask & ETH_VLAN_FILTER_MASK); + + cfg->vlan_strip = !!(mask & ETH_VLAN_STRIP_MASK); + + for (i = 0; i < dev->data->nb_rx_queues; i++) + hw_atl_rpo_rx_desc_vlan_stripping_set(hw, cfg->vlan_strip, i); + + if (mask & ETH_VLAN_EXTEND_MASK) + ret = -ENOTSUP; + + return ret; +} + +static int +atl_vlan_tpid_set(struct rte_eth_dev *dev, enum rte_vlan_type vlan_type, + uint16_t tpid) +{ + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + int err = 0; + + PMD_INIT_FUNC_TRACE(); + + switch (vlan_type) { + case ETH_VLAN_TYPE_INNER: + hw_atl_rpf_vlan_inner_etht_set(hw, tpid); + break; + case ETH_VLAN_TYPE_OUTER: + hw_atl_rpf_vlan_outer_etht_set(hw, tpid); + break; + default: + PMD_DRV_LOG(ERR, "Unsupported VLAN type"); + err = -ENOTSUP; + } + + return err; +} + +static void +atl_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue_id, int on) +{ + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + PMD_INIT_FUNC_TRACE(); + + if (queue_id > dev->data->nb_rx_queues) { + PMD_DRV_LOG(ERR, "Invalid queue id"); + return; + } + + hw_atl_rpo_rx_desc_vlan_stripping_set(hw, on, queue_id); +} + +static int atl_dev_set_mc_addr_list(struct rte_eth_dev *dev, struct ether_addr *mc_addr_set, uint32_t nb_mc_addr) diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_types.h index 99e920315014..eb6feec177ff 100644 --- a/drivers/net/atlantic/atl_types.h +++ b/drivers/net/atlantic/atl_types.h @@ -77,6 +77,8 @@ struct aq_hw_cfg_s { int irq_mask; unsigned int vecs; + bool vlan_strip; + uint32_t vlan_filter[HW_ATL_B0_MAX_VLAN_IDS]; uint32_t flow_control; struct aq_rss_parameters aq_rss; -- 2.7.4