From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0042.outbound.protection.outlook.com [104.47.42.42]) by dpdk.org (Postfix) with ESMTP id 713A25F16 for ; Fri, 7 Sep 2018 17:23:38 +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=hvXrJuVxAMhLlODkVS7ARfvgPAkrThafR+Szjq0sOng=; b=ChAxxDd/UqqW7Xw9rDxU3VkWN3HO8lphOHtrntXECeH2AOcXwzSyR2K/T6lUyESma6D4Tzmnkt2pQlE6H6j9OWzdJfAPtj6Vkq0v7yzc4/15ZcjKj1fCtqC5BXnlx75H27GBq9i379JTjm0+7lXFavSgwgxJEuf54NJgy9NIgB8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; Received: from ubuntubox.rdc.aquantia.com (95.79.108.179) by BLUPR0701MB1652.namprd07.prod.outlook.com (2a01:111:e400:58c6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Fri, 7 Sep 2018 15:23:35 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, Nadezhda.Krupnina@aquantia.com, igor.russkikh@aquantia.com, Simon.Edelhaus@aquantia.com, Corey Melton , Ashish Kumar Date: Fri, 7 Sep 2018 18:21:56 +0300 Message-Id: <1536333719-32155-19-git-send-email-igor.russkikh@aquantia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536333719-32155-1-git-send-email-igor.russkikh@aquantia.com> References: <1536333719-32155-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: BN6PR20CA0060.namprd20.prod.outlook.com (2603:10b6:404:151::22) To BLUPR0701MB1652.namprd07.prod.outlook.com (2a01:111:e400:58c6::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b32932f0-9e28-42df-215e-08d614d5e19c X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1652; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1652; 3:49rTPL+91bOUj1TLaLx6dRyEjkEKq37fbaERf0MUjpZQLWHIL6URbz9t6KcyqM33pXnffDPSBzWvStS1TUugUwU/lFx3ZPzY5EIvOx/UgKFZWbUOBvzsVbOdmYGggBxclTalKZcqFC7Zkz2EJIdd+DeJNl3yMpc3jsNaeLPemPV1QqZ2BTaXaLuqm0IAcoSa39/mw716I3dLl68WwMu35Hv31lMEMWVq29X5DdUZc17JK5O75HwZXpYiNVtborAG; 25:Ru/ywDIwjiyL3gJzX/FC8plmCA+sSfdmIEmspYWSc8SgJeO8ymxvecHQjGISNFyKDEEBTl5/WumJklgkhbY5Ql898ctiMDld9ARtmURsQeVkb/YwIYqhv8CXektnct4RY+ijF0TXlGlxaie2M83ukOaMdFxm+Th7oPBUw0xj6f9tdh5arA+GEnhF7HutfP5eQrS7U2qLF+9gh2QHcmr8L4XHRDSJPo7o3AsBmv/Jzhu119HGq5+kjSRnrOg6/IR8a8qUzujkdDkIFplcPg6WfaG/5CBuuB/X+BV6lBwWLHtykBylN0uXW573cV5hodaOsN3w2e3jVXmRy4zyYejvDg==; 31:a4rIT7ymKFuv27GSiaS3yock9TXJzfDSjy4jJEpyo6yhVtQNufPTsXZFxW3CwNxFy52vNS9RsJJnc6jIjR0jVpGTAFn+myRbHmwLUFUgsCmlRjeItXA+lHVpl0ZjUXB77vfTQ6dPpSI6kBYRdOOu5dRLBouWKzJacytAqsp00VpS+LwA4Bm2Ut2F2IETV5PjU5Iy4Iurjy1eUWVBmE9o/YjC/JmtuKBPbsmdYr94yLc= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1652: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1652; 20:qEQ83Zk2J9B4yDOKUfhZgwbXu5VYYszGMICSZZraGFWiUTOK9KlPN4+4h8VYgw3iKiD/fWsSwetC5XIZLxvQO39rZT6FW2vLCiU3eaxnND5PcdZkbMW7n+44vdaLvq7AqNTUBIiGbMfjJCFFxNPsjNH47oTJTDK3b9EUXx0DHM72XslH0KXRTPBBSJSxzh2XKn35sZb4Jcdhi42Okaf1+SJRgXTMsNnl8Qs4bZlDXT6yyqCFjVPgz8u7n59NCO/8K2atIebdp4bLChoJRaylbAhZx2mO9Bczgx0xCO0j2AdFcvV2qjo+Wvvhd3XMlhgodA7KRKLrO+7mqYUnjXucSk1oyJroFFQr7ndnq/4iED60sOJB/dhNJKOqcB8ziUwWgTGGy962Z5ygGAJS465s2mfKlkNshW3d1AMvWkSW3bqWWIRII9EjmhksWMSwQMvQplysyBKjTxjuiGx7oj/qI60jvixLf1C7L7nVQNZ1DKb0e2gO1/rjvvLoIlZzmNbP; 4:ZOs6MXm2t5Fl7y9XHee0NuIgIDjg/wtFczdkdr4I+vGH2K3IMVfJqnHA/9axCSFxWw1nTKVOP0QzznwNK+Fw5q9d1USXJ+14xFy14FgGTt4qKyQhNlNFoAZ/ZPzzrtDbdV7X2x6gjhV6Di/w/QDmIvCUK3f97/wXY1SgZRE9C/SVwKLNWgv4aSmsItCcp2X44pcVZKP3+j5dA+hbeXUTsv82yy/hfq9ANTGYL9dklbhNYSyNzNlxsHr8B9rEZd3dIhMrgGy0lzw6PpiUHRpdpg== 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)(5005006)(8121501046)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699050); SRVR:BLUPR0701MB1652; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1652; X-Forefront-PRVS: 07880C4932 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39850400004)(396003)(376002)(366004)(346002)(136003)(189003)(199004)(81156014)(81166006)(44832011)(8936002)(2351001)(486006)(106356001)(2361001)(105586002)(446003)(2906002)(50226002)(476003)(11346002)(956004)(2616005)(305945005)(7736002)(16586007)(316002)(54906003)(14444005)(16526019)(66066001)(26005)(7696005)(52116002)(8676002)(51416003)(76176011)(186003)(386003)(68736007)(478600001)(6666003)(6916009)(6486002)(5660300001)(53936002)(47776003)(4326008)(25786009)(86362001)(48376002)(50466002)(72206003)(6116002)(97736004)(36756003)(3846002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1652; 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; BLUPR0701MB1652; 23:18vSGqpq3BQ4In3eiskW7ohJGuSMZ4N4M53vPeq?= =?us-ascii?Q?gele52YsY4vgfI03PosZwnjrnaHX+zLD89kBBAw4kZsQ06shkAXQu2xPO5fu?= =?us-ascii?Q?RWKt+dIVpkQ4SM7zrdhzbnnlXoaAUa/Bk6bHp8t/4Ab8G7eiP01nDJx3xyLq?= =?us-ascii?Q?3+7CSVDqdKntwJwwrP2uqJwL9ja6w7RuasKO9ooAxYg0QP+hVy3CLGhL+/QH?= =?us-ascii?Q?6KZ0ZEkK3gq6Y85yYpIloqv4pFcfb5pha5MfpzTGRZK1QYJCMK52iQHOKk2S?= =?us-ascii?Q?9FnC4/AHOj+cYuRRrihctY7P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OChG6g0Tb2GC+gUBTJ1V8cw8Jg4znF5ejCuM7A2SJGFWb0hgZdqsswW73VeGqY2l5Wiw7XeWshngKbFdw8ymq2WUCxn+U7FcD6uqQ2w=; 7:KOyCt4GxHdlA1gYn4tDF2eppijzeT0n7kADTueqvvEoyGoSLzLX9cvumhayx91vHJ4GTnPOPkWWnUowU4ETZr0ocAU5B2F3w0V+Eqxtk7Us7wTZnqykYiG56Ge0sQ3a0A7WmS6L/EaM9NXnW0S5PGb2O9xDqvFAjPkIO89we/2shnoiq4a+7P1cd3kpA09oL1zKWB1K5Mgyye3v3SVQae7BMul7ouSM9eqPTHb+cgWgWEh7pGA6lOZemEtOmF7SS SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2018 15:23:35.1668 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b32932f0-9e28-42df-215e-08d614d5e19c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1652 Subject: [dpdk-dev] [PATCH 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: Fri, 07 Sep 2018 15:23:39 -0000 From: Pavel Belous Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_ethdev.c | 156 +++++++++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 2 deletions(-) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index c99d321c9..80b7ac88e 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -84,6 +84,16 @@ 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); @@ -247,6 +257,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, @@ -525,7 +540,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; @@ -582,7 +596,6 @@ atl_dev_start(struct rte_eth_dev *dev) } } - err = hw->aq_fw_ops->update_link_status(hw); if (err) { @@ -1241,6 +1254,145 @@ 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_act_set(hw, 1U, i); + //hw_atl_rpf_vlan_id_flr_set(hw, vlan_filter[i], i); + hw_atl_rpf_vlan_flr_en_set(hw, 0U, i); + + /* Clear VLAN filter entry */ + cfg->vlan_filter[i] = 0; + } + break; + } + } + + if (i == HW_ATL_B0_MAX_VLAN_IDS && !on) + goto exit; /* VLAN_ID was not found. So, nothing to delete. */ + + if (i != HW_ATL_B0_MAX_VLAN_IDS) + goto exit; /* VLAN_ID already exist, or already removed above. Nothing to do. */ + + /* 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