From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0057.outbound.protection.outlook.com [104.47.32.57]) by dpdk.org (Postfix) with ESMTP id B2B16199AE for ; Thu, 13 Sep 2018 13:36:12 +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=bcZLp7xK3+ut/YLid6qbSS/T2EP7h+0vr2HQ9Pldtaw=; b=fw4oO8U1FClNrdzgD4sRCmihnEipKbpH3NpV/Ld9SwH6utA8Xce3BlusiOdZOGMeUB2QUF4V28JlDmQO313z7d6G3Q1t/3/rl9HZByQeTK5DcDII+VHYNDaNtiO1LMFNAal2RYWVpKLZ6i6UjjDuxSZ9ab3aqCtuwrhpDYAFtr8= 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.1143.15; Thu, 13 Sep 2018 11:36:10 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, igor.russkikh@aquantia.com Date: Thu, 13 Sep 2018 14:35:25 +0300 Message-Id: <1536838528-11800-18-git-send-email-igor.russkikh@aquantia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536838528-11800-1-git-send-email-igor.russkikh@aquantia.com> References: <1536838528-11800-1-git-send-email-igor.russkikh@aquantia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.79.108.179] X-ClientProxiedBy: VI1PR0202CA0026.eurprd02.prod.outlook.com (2603:10a6:803:14::39) To BLUPR0701MB1650.namprd07.prod.outlook.com (2a01:111:e400:58c6::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8b886267-b70a-477f-a8b4-08d6196d1b09 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1650; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 3:whxHYCAy7rFdEJgLTscsi0G5m52Q6g+AqQKESvAxWkUJVm4Tmzeamugx+vro56XdgZvl4znu5xflsalH3QaKM6CyvyVrv6q93bI8POXtBq7GXc3BdKZAiRAd3b6/9IGN1UtDdecswQpEAWfDkSAZIIhz5pElj3NLC9pYDtGBJHwei/aDMV4KXCTb3CThCFBTGsMO44gJN8REHiXAOpZrPV5iZ217XSd553oQ3dqM76LJ3urbw3wSNtv+/q3UiDHw; 25:p2wqnRGRuSJPkPwFB3QWMhuMNY6x/y9xA2Ihgay8SqEkMEjBnIgZ93tAMDPD4YSLo1IWLTN8vPx7zMIUAXHbXezxvuQ154ePnt3vuB2PSKC4t7GrCSgGlFZLySeZJ1nUQQWZvE2T4YlwbCf7hgFs1Kvm+Js9cNqjgvuY5L+7XxaejNr1o++3ni5qt0WQZ8QOOTDYkBMQw1gXU85BX0aM7WQYcNm8b5rPZCQpBqaKHBcWizbpNk5529nhvfAY6oCWrwtXVA0lvzfXzZzpAbKwB8jpKcW0DlxQzVmEvztKP33xNjh7azTpxA28pJkPTeE39sx3QXd3bfk/8N6pJ8MKmFowfr9evbR+KIiQXmot/wA=; 31:NOb8gA2T+6xUMvc38M4NdwNvJ+7TtB1XSTmKuzLoF81YQT8zKNdl+6c/QN0Ky7ayhLKZPemXdCCNhbXANBsjtbLaZkBXEyAPLs0kBZ65caFyk5FWQgAstWOE2MwGXRNWIm/J3XmVhwHoJ28vMT5R8tLMLiSzK7k43NWSbLLVHHAHUBSsHKb68y0tbZBjihOwHnpM5E3nK0lcy1JecLQ/Mh5kqmxAr9WTACGOkDHqKE8= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1650: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 20:UF/w1EGm6KV03F8vAVOMrKR3r6fhRRVFdLkTpFgC6l2VRIG5HwAQluyV210AnK+eddmTLHrwHI9lI/vCFqd4QzOkedt6U/UWlhigOpcn5j9np/8vsG/6hbY9XkvxneiBoBR7gpFbAX8kRSXaitXYZEWT0J5yQEPj4/beDkIWyWbLyWkbg3Y3nIvQt8X0gY1mH75Xhg+MeHPz+tUktfUUxWnjJepWrAnVZijxHhlY8IwZBfeMKkOeSE2X1/NUpl0O1dXRWxok0P+RjoQ2ih/OTTq0m/wmLUyhDShvkZEsHHs7JsdERCG34H6jKFfdDAjuzVfyh8WeitLB1cgzAlH2DMqvfMPk22wBKQfabPXBOoaRO/ULFtBW2250oyON/Jx5jc5qkQwJKG+idrs2Rsm9uPeVckTA4sa7loPAaiuqF74S5/eZ+q1ILm4YzQzaleOnHL5HgCb+9U1+Q9A1vkXCwcsJ2nQ0ISN772mFvkxPm0MN3uVmD46b26mYV4dSp2kv; 4:aVQKuGkX4/4U3j5QVOiKyo60tonXTsD+BGmV7UD8bEluPhhOd2DFMevY8Dh/DotHjdkFfxO6rAdcJOYv1Dh1jgg0pXGixq0+uMp3ZLc1LxpzSGNeEou1+Ph1kSFdq08BV7TgO08OgoPrwQx5pR0jPfYnqwwPkhuSWgCpPUU3eT8jsxw6CRK4GDoxBRqzdL203hD6wJZQGfd6oHqkB0VWvzSp6HfVw9KxPYJfTnIfSpnCoQsh7f823RjoJNcMNv03lwcvB73inL3qMZZqQ5kkjw== 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)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699050); SRVR:BLUPR0701MB1650; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1650; X-Forefront-PRVS: 07943272E1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39840400004)(366004)(396003)(376002)(136003)(346002)(199004)(189003)(6666003)(6916009)(97736004)(8936002)(68736007)(25786009)(50226002)(81166006)(81156014)(4326008)(107886003)(6486002)(51416003)(2906002)(53936002)(5660300001)(36756003)(86362001)(316002)(52116002)(8676002)(16586007)(7736002)(305945005)(11346002)(446003)(476003)(956004)(47776003)(72206003)(66066001)(44832011)(478600001)(486006)(186003)(26005)(16526019)(14444005)(386003)(48376002)(2351001)(106356001)(2361001)(2616005)(3846002)(105586002)(50466002)(7696005)(6116002)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1650; H:ubuntubox.rdc.aquantia.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX: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:TZmc/yIiTykV2G2p7avHWbv0KCPGwAYpf2GsdCd?= =?us-ascii?Q?2/EQBbSahOHgr3/1WMyH47bhiOlFsHWuImp88fmFUT0smhNzMWwwFQovdcVI?= =?us-ascii?Q?dioYe+5QTsgmiuoYsiXz8DOIciUOScVZF6rwWTduaKzDluNAU14vz4025zSe?= =?us-ascii?Q?3jYF9lGAhkfMIsBnWlIZAs7wYZ/3HSSLduQgB2GpobcGOYjfzCim7/mpfZg7?= =?us-ascii?Q?0eMbtIPKkgCTeGDFaBdtjgt1T7NA+sT04dV4gYOtjp0Lr+ltFh27XCyUJHtU?= =?us-ascii?Q?Z/NW0Fg01f4NMBqi7Zr3qNZUlZ7L3su9svjx+H5yjY3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4VqxEzPHHS8TqWeZAf8KIy3J6Km7cAIFgmroBKEqBA273Ton?= =?us-ascii?Q?ivAhfMUtGkggxmnslfM0K5Ztu5sxHjrCVjI+g3l7Z?= X-Microsoft-Antispam-Message-Info: MgEhD4rRYZEVO6wi/IyheGWvsUdZ2rqlGV+mRfszhIhWW4almBupR5tD1Pn/DVCE9fqBVXYlcR0Fglk9aRSKwrxSEglGSqvcUjATMU/Tqapx12K5hEHom/NZCe1bNsw2kYFe+0JF06OvD3nmu7Hkd17stoD8wK1gYaMt4YCdnkcK92ZTe5H6vU6wUlGKy9teC/a/9Y3ujjX32rW+YR00ktk0FWrAc8jJ1ldQoQ18BR74NrHmbcWJA/veTiACqhvUTqFKS82uwflrTL39vITfFqiRSAk10571nmil9SizefWFMFcMzOuln5OR5ko3FOs7H4ze2qvlykwXnjfpy4U3H2M2XA4ktLszi1VJDj/VTGs= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 6:CBixDYLR2oEEvdmiTrR6LBrRn0oBIzLFhkxLoMQaAMOCKC4YMz+P9lcPb2ss/wdyWLh4Z6g2+UMNartnKqEv8eJZvNCR8QNc5k96mcL5uV3U19IiSUjtogAPuVdkp1GaZE8c2TWfRlt/prTbHNet1LAEVY1EDgcTlzscpGEfcHCpsU+rt4gnD0f2d3bQYjQHnBnagtEDvhCp12tTqguXLm4z3SkT1x6USTwn5MXQJe4bpJ0r6JaTKRphOv60PMx/HtlMrvCkRx6vyXt540Gtgsstgk5QTa2vtv45uyxylUj4IqgRc16FQQ4GddxVMAioyVoIRGSDVHk6MwCA8BgmaRbNicESYvUMnuofs107qKLc4iRJUjcAEmWbUWBJUvJbfXCtltf4znboF4535/uakM6YAT5RptGP6lH387EG6cY31lNmd3EfBnlFTuFXOyG/cZni7gTzlqU87kSHkfXf+Q==; 5:sHT3XkOayV9q/3JB3xQmnP0fP4hj4Q00qbfREVRVaaGqf/nnNMF/Z/2MEUGIwR6t6Eh5oCczRZuII6CvMeVkwosl2QkAj/NWuHmMkBih/lxetzmOBmDsVfpO+6hpdqsfXQJsoU1vV2O+j0NI9Bj2zTnxyXprC5RCQj63egsrmdE=; 7:ipmznmPpkH3HHhbMVSTgsU69O+wihRKj4h4sBSGJMsdnz66n28J5Sp7EBfZ0nh9nFlSHr3/qOh3DJDUHLzHDpofNp/C8+VBwHeYCBfhYqE0/EF8b1yXSrwmh1pE+ICsO3IIpca5LBA8imS1jouiWWebWaVoG+zuhxwZ5sCkzKl8FaJ7xyPAL8ZWnVEdBzx2lYP0Ii7xQUjA48teObqhnf5MVr8Te9oE+XX17zUmXdxy5ivDTwSu0howXx1GU/Kg+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2018 11:36:10.6313 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8b886267-b70a-477f-a8b4-08d6196d1b09 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 v2 18/21] 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: Thu, 13 Sep 2018 11:36:13 -0000 From: Pavel Belous Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_ethdev.c | 159 +++++++++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 2 deletions(-) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 37f32c421..7ff1126d7 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -84,6 +84,18 @@ static void atl_dev_info_get(struct rte_eth_dev *dev, static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev); +/* 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); + /* LEDs */ static int atl_dev_led_on(struct rte_eth_dev *dev); static int atl_dev_led_off(struct rte_eth_dev *dev); @@ -251,6 +263,11 @@ static const struct eth_dev_ops atl_eth_dev_ops = { .xstats_get_names = atl_dev_xstats_get_names, .stats_reset = atl_dev_stats_reset, .xstats_reset = atl_dev_xstats_reset, + /* 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, /* LEDs */ .dev_led_on = atl_dev_led_on, @@ -532,7 +549,6 @@ atl_dev_start(struct rte_eth_dev *dev) uint32_t intr_vector = 0; uint32_t *link_speeds; uint32_t speed = 0; - int vlan_mask = 0; int status; int err; @@ -588,7 +604,6 @@ atl_dev_start(struct rte_eth_dev *dev) } } - err = hw->aq_fw_ops->update_link_status(hw); if (err) @@ -1260,6 +1275,146 @@ atl_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr) return 0; } +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, -- 2.13.3.windows.1