From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0056.outbound.protection.outlook.com [104.47.32.56]) by dpdk.org (Postfix) with ESMTP id 0DA121B610 for ; Fri, 12 Oct 2018 13:09:51 +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=nUtfXHJQr7AJEqt7jccY/8xbNsDQmcYl8o+lgOeueKY=; b=fvN02pva3s/TOH3sdnrlVRYW/yld83AwynX3H/2V1cwpkVv/j5T2QunfUk38jXtICjlYBQKI1V1gwWEzDS9aHDSuYuJASIlekQCOyZHRAcxFJB8sCFAbQ1Hq6YM+zEl1cUlr1lArIUxZYCUS86C/Z6oEybm+e6jEe3BI3cbTvWY= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1627.namprd07.prod.outlook.com (10.162.110.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.22; Fri, 12 Oct 2018 11:09:49 +0000 Received: from BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17]) by BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17%3]) with mapi id 15.20.1228.020; Fri, 12 Oct 2018 11:09:49 +0000 From: Igor Russkikh To: "dev@dpdk.org" CC: Pavel Belous , Igor Russkikh , "ferruh.yigit@intel.com" , Pavel Belous Thread-Topic: [PATCH v6 19/22] net/atlantic: implement VLAN filters and offloads Thread-Index: AQHUYhwXWjt8mind30Cn8O3BLuY/YA== Date: Fri, 12 Oct 2018 11:09:49 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM5PR0701CA0008.eurprd07.prod.outlook.com (2603:10a6:203:51::18) To BY1PR0701MB1660.namprd07.prod.outlook.com (2a01:111:e400:522a::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [95.79.108.179] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BY1PR0701MB1627; 6:A3gEClRfhmn20efh5UBEhh1qYNEi9jB4+lf73bXVnvz+NzOY3aDgm5jBLGG/MCR2+TKb7Isv42bTcxOJWHzb3Gua37d5ahLi30aPa7qCAJAlAOAB1QbOps6a+kFMWrIQ95zw3FSBBpSAv4+9q+li2QXDLoIcqQ2mSf/WpUHycPuQznzZSOVqHP2VkGX3ag3XAiOds+S90egi8wxDnhl7YquGV/3rtu1YNWivib+fMVvoxXCYbVPtVnRpcxHJSkZo0wlYUWHpxDuKkFEC9wuBricelv9Bc5ey4ySSZR/R1sYqyCulq3J07/r3INDGPb7gJXrIsTp89vZDcFRSlt9tMJuUKuBQzdcQeGYG4lPg9fzHI0Tj3bdX/vrCWqWc8EzkV2ieGJdkQN+F2JSvlL82TOnEYwLFRSqZ+sEyLHWoBAWLvxtNP+XXhjVaWDrZFeFARXDYKDObLj71JEjofCwSNvEK9EIuStxCsYWKbLuNMtk=; 5:v02Ad+2MlYg2ZgGNlu7Qm4yd9/Sl1y7CzY8aa0iAivw69w+tdE8uTz0mBLrUrEh/wo+N+Nu5HXWefj/9Fh/RWGLl5WHZov4hmh6BHQHoUY7doa0gfonpcFaIHiCaj8mNlFeu0/cjMbpG3iEdnuZXAOYckT+3wAjrJsxQyIJ3K+o=; 7:+aXeQyLXzJy4MjizOSf14ga5NIFqvQhftl/eY8dDTV8QOGdyBvkCuD9nn5IjgmTAxpaTmNFXw+woKWk4iJsKB/28uKp7WGiGZtarbVsQFyNLoflsBfctw6lR8vNHoyvyTBIEeKlW6oPRpp+Cy3WbJGJTHsZ/uvh4L/Yl59q2vWWIJxxsLD40ERokWq2XfAt2w8uJv7moS2UBWKcY1mWWay3AJ/xjFpI1UQjV/TmqJDjHmEQU2Hvz3z4NySWL+29i x-ms-office365-filtering-correlation-id: fcb466a9-598f-4d98-1ebe-08d63033390c x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BY1PR0701MB1627; x-ms-traffictypediagnostic: BY1PR0701MB1627: 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)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991067); SRVR:BY1PR0701MB1627; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1627; x-forefront-prvs: 0823A5777B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(376002)(136003)(39850400004)(396003)(189003)(199004)(186003)(6116002)(486006)(5640700003)(446003)(6436002)(6512007)(53936002)(71200400001)(71190400001)(14454004)(72206003)(316002)(2351001)(44832011)(3846002)(7736002)(305945005)(2906002)(4326008)(6486002)(107886003)(97736004)(26005)(2501003)(102836004)(5250100002)(11346002)(86362001)(25786009)(476003)(2616005)(106356001)(54906003)(105586002)(256004)(14444005)(5660300001)(66066001)(81166006)(81156014)(1730700003)(8676002)(478600001)(36756003)(68736007)(6916009)(8936002)(99286004)(386003)(6506007)(118296001)(2900100001)(52116002)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1627; H:BY1PR0701MB1660.namprd07.prod.outlook.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-antispam-message-info: weBkuNDOuVETcAU7vDr9m6Uti4b4ZMJkbvBEV8hhT+VO4G3N9o6Y5CfmDy6Ci0iatWuJxOZzQMt0CTlzpuDTu0aJNrB/SNK/YWR4TmGiiR1dKjUroF3Vcc6f3kSRiKbtK+uiSOyKWTIATjuu86OJYcPXMYIp3r5ri95+zvKkqVtIwj/GzJQxOS53waj7vxdV18S/oNPX/F2tl1JJIaWQd/nih6ywTkqTmt6EPJ8EADsLCUDPbDaIrnzmQkTgQ0zX/JPf2Yvz9h6GCkPJLf7CwY9riI3vBMoKUOKti4PbBH5R7c7t9hZFNPF3FRiWhlnsc3U248ZYFt21WA/122XS3MnyBYnOdy9SjaDTbsviYk0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcb466a9-598f-4d98-1ebe-08d63033390c X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Oct 2018 11:09:49.1215 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1627 Subject: [dpdk-dev] [PATCH v6 19/22] net/atlantic: implement 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, 12 Oct 2018 11:09:51 -0000 From: Pavel Belous VLAN filters and VLAN offloads implementation. Signed-off-by: Igor Russkikh Signed-off-by: Pavel Belous --- doc/guides/nics/features/atlantic.ini | 2 + drivers/net/atlantic/atl_ethdev.c | 159 ++++++++++++++++++++++++++++++= ++++ drivers/net/atlantic/atl_rxtx.c | 12 +++ drivers/net/atlantic/atl_types.h | 2 + 4 files changed, 175 insertions(+) diff --git a/doc/guides/nics/features/atlantic.ini b/doc/guides/nics/featur= es/atlantic.ini index dd44ed75aef4..66949b816284 100644 --- a/doc/guides/nics/features/atlantic.ini +++ b/doc/guides/nics/features/atlantic.ini @@ -16,8 +16,10 @@ Unicast MAC filter =3D Y RSS hash =3D Y RSS key update =3D Y RSS reta update =3D Y +VLAN filter =3D Y Flow control =3D Y CRC offload =3D Y +VLAN offload =3D Y L3 checksum offload =3D Y L4 checksum offload =3D Y Packet type parsing =3D Y diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_e= thdev.c index db2d798f28aa..6ebc02864cfe 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -50,6 +50,18 @@ static const uint32_t *atl_dev_supported_ptypes_get(stru= ct rte_eth_dev *dev); =20 static int atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); =20 +/* 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); @@ -223,6 +235,12 @@ static const struct eth_dev_ops atl_eth_dev_ops =3D { =20 .mtu_set =3D atl_dev_mtu_set, =20 + /* VLAN */ + .vlan_filter_set =3D atl_vlan_filter_set, + .vlan_offload_set =3D atl_vlan_offload_set, + .vlan_tpid_set =3D atl_vlan_tpid_set, + .vlan_strip_queue_set =3D atl_vlan_strip_queue_set, + /* Queue Control */ .rx_queue_start =3D atl_rx_queue_start, .rx_queue_stop =3D atl_rx_queue_stop, @@ -1172,6 +1190,147 @@ atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t m= tu) } =20 static int +atl_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) +{ + struct aq_hw_cfg_s *cfg =3D + ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private); + struct aq_hw_s *hw =3D ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + int err =3D 0; + int i =3D 0; + + PMD_INIT_FUNC_TRACE(); + + for (i =3D 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) { + if (cfg->vlan_filter[i] =3D=3D 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] =3D 0; + } + break; + } + } + + /* VLAN_ID was not found. So, nothing to delete. */ + if (i =3D=3D HW_ATL_B0_MAX_VLAN_IDS && !on) + goto exit; + + /* VLAN_ID already exist, or already removed above. Nothing to do. */ + if (i !=3D HW_ATL_B0_MAX_VLAN_IDS) + goto exit; + + /* Try to found free VLAN filter to add new VLAN_ID */ + for (i =3D 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) { + if (cfg->vlan_filter[i] =3D=3D 0) + break; + } + + if (i =3D=3D HW_ATL_B0_MAX_VLAN_IDS) { + /* We have no free VLAN filter to add new VLAN_ID*/ + err =3D -ENOMEM; + goto exit; + } + + cfg->vlan_filter[i] =3D 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 =3D 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) { + if (cfg->vlan_filter[i] !=3D 0) + break; + } + + hw_atl_rpf_vlan_prom_mode_en_set(hw, i =3D=3D 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 =3D ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct aq_hw_cfg_s *cfg =3D + ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private); + int i; + + PMD_INIT_FUNC_TRACE(); + + for (i =3D 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 =3D + ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private); + struct aq_hw_s *hw =3D ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + int ret =3D 0; + int i; + + PMD_INIT_FUNC_TRACE(); + + ret =3D atl_enable_vlan_filter(dev, mask & ETH_VLAN_FILTER_MASK); + + cfg->vlan_strip =3D !!(mask & ETH_VLAN_STRIP_MASK); + + for (i =3D 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 =3D -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 =3D ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + int err =3D 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 =3D -ENOTSUP; + } + + return err; +} + +static void +atl_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue_id, int o= n) +{ + struct aq_hw_s *hw =3D 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_rxtx.c b/drivers/net/atlantic/atl_rxt= x.c index 01267214088b..fd909476c45f 100644 --- a/drivers/net/atlantic/atl_rxtx.c +++ b/drivers/net/atlantic/atl_rxtx.c @@ -919,6 +919,8 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts= , uint16_t nb_pkts) struct atl_adapter *adapter =3D ATL_DEV_TO_ADAPTER(&rte_eth_devices[rxq->port_id]); struct aq_hw_s *hw =3D ATL_DEV_PRIVATE_TO_HW(adapter); + struct aq_hw_cfg_s *cfg =3D + ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private); struct atl_rx_entry *sw_ring =3D rxq->sw_ring; =20 struct rte_mbuf *new_mbuf; @@ -1036,8 +1038,18 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_p= kts, uint16_t nb_pkts) =20 rx_mbuf->ol_flags =3D atl_desc_to_offload_flags(rxq, &rxd_wb); + rx_mbuf->packet_type =3D atl_desc_to_pkt_type(&rxd_wb); =20 + if (rx_mbuf->packet_type & RTE_PTYPE_L2_ETHER_VLAN) { + rx_mbuf->ol_flags |=3D PKT_RX_VLAN; + rx_mbuf->vlan_tci =3D rxd_wb.vlan; + + if (cfg->vlan_strip) + rx_mbuf->ol_flags |=3D + PKT_RX_VLAN_STRIPPED; + } + if (!rx_mbuf_first) rx_mbuf_first =3D rx_mbuf; rx_mbuf_first->nb_segs++; diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_ty= pes.h index 56887b14d6f8..3d90f6caefc2 100644 --- a/drivers/net/atlantic/atl_types.h +++ b/drivers/net/atlantic/atl_types.h @@ -70,6 +70,8 @@ struct aq_hw_cfg_s { int irq_mask; unsigned int vecs; =20 + bool vlan_strip; + uint32_t vlan_filter[HW_ATL_B0_MAX_VLAN_IDS]; uint32_t flow_control; =20 struct aq_rss_parameters aq_rss; --=20 2.7.4