From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM05-CO1-obe.outbound.protection.outlook.com (mail-eopbgr720067.outbound.protection.outlook.com [40.107.72.67]) by dpdk.org (Postfix) with ESMTP id 3E8521B56D for ; Fri, 12 Oct 2018 13:09:22 +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=7W4emC9LlU05VozK5DadBm9BmNL8i6g9FQ0BvrH7eJQ=; b=SC1J3qlgmVrhl1vgOs0xKxMPOCheyUhB8gPPvw0liyIDQC8Do6hZo8cKBkODBZgNaNH18oq9tJt8C+yXaehrXUWoPEDADlnp5PmOOXLOV7DA9+OOVXi6NZ4JCE2CisR4Sb/uiW60Kb5hPgLiq1t8b5KifpTKUNZxUvAQBx9NU6E= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1879.namprd07.prod.outlook.com (10.162.143.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.26; Fri, 12 Oct 2018 11:09:20 +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:20 +0000 From: Igor Russkikh To: "dev@dpdk.org" CC: Pavel Belous , Igor Russkikh , "ferruh.yigit@intel.com" Thread-Topic: [PATCH v6 07/22] net/atlantic: configure rte device start/stop Thread-Index: AQHUYhwGbOn0mEMLCEW5j1OTsn6dRA== Date: Fri, 12 Oct 2018 11:09:20 +0000 Message-ID: <9a99afae180726da58f68bab92f25a472720fd8a.1539338074.git.igor.russkikh@aquantia.com> 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; BY1PR0701MB1879; 6:BsxcEHJiDdpZzqC1WAx4kMlzbw9n9OaSAyr/H7ellhjd10KGtpv0GQTpZG8SL6xWyw6b7PCb/aH3A0hcIvGfd2/j+4Ku/XPByX2lY0kdA6jgMJ2bKz10BjE6HrNSqBiMHrKuL/Oid/XmLHX5l1O0r8S3WLxjGRbVkLrdy3+i7SgGrsrSVcJ+b0l+XE3RYhzS1/vWFvGvsf6CnnW0OmuVVY9nLWMTp141dhxqMRaskHHeAWnuvIHhFtwoZ/DEkjFQz17WSdpnsx05Z0YdrbKcL5bFb6KL+T8rs7Jq0P0uolQFJtJTqLpp1kyQqQ3zhwfOvHmeUY2lLPTErlgGqVYhsOaqa0erMxpzWMjuFqyZkmGc1YJE96gV6Ffnw38IuXxDvlQuXrQqe6gLkhD1BPf8XtMnCujNltNPAdLrx8KoyT5utLwoBeR9RDtuGw5NBg+CEDvBAWe3BkeX82+BpOQSHM98u4AkRX//3YX7sHaBbj0=; 5:IQDQuc+p27owW2Kk1fedU4z5puo8EFvxA1q5Xy6Vat68M4SX6ajKOxoSmdPOmlqSb0f2b/L6j5zJ2Obl212RsNzrubiNxR3U+X+MCgxXO+qkcg/Zy/mvBMlcjs8IMOxk4CsbYVeUK4+MMPvAh6GZA4/x6FCZpUTBfL+lqpv3Aas=; 7:daqBoSh1odIkByfOudGryH/3wB0wGOxmGiWVOqVFfHLi2f+XrY9er4BCuXyA4F3DTbcgfw+7xW6EyI/sqHAEVbmvW28rcFFgqqs3KySkElSfxvNdg8tBigQZFDU2uS9z4B1CkOMxR4aYxdvpP5DI54ZmhIaYW9xo3iBh9nNMGVtRXgK8ly8YfmVEg/7QN1R3k075xUYtF6TA+qhwXby7hAs2fH30UK0Z9NitdiX6BMpzz1bCF1VPlq09tPeiZwLU x-ms-office365-filtering-correlation-id: 76f1ffa4-0558-4e50-28a4-08d630332815 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BY1PR0701MB1879; x-ms-traffictypediagnostic: BY1PR0701MB1879: 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)(10201501046)(3002001)(3231355)(944501410)(52105095)(149066)(150057)(6041310)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991067); SRVR:BY1PR0701MB1879; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1879; x-forefront-prvs: 0823A5777B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(346002)(376002)(366004)(136003)(39850400004)(396003)(189003)(199004)(6436002)(5640700003)(3846002)(68736007)(2900100001)(478600001)(6486002)(14454004)(2906002)(72206003)(71190400001)(71200400001)(26005)(2616005)(44832011)(102836004)(446003)(486006)(256004)(118296001)(186003)(105586002)(2351001)(6116002)(106356001)(6512007)(97736004)(6916009)(5660300001)(54906003)(6506007)(386003)(11346002)(476003)(14444005)(53936002)(5250100002)(2501003)(25786009)(8936002)(8676002)(4326008)(86362001)(305945005)(7736002)(575784001)(99286004)(81166006)(1730700003)(81156014)(66066001)(52116002)(36756003)(316002)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1879; 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: 0PdKjWf8NimBZUYJLSz5ougJk4x0eKxsXaOFHVC6Z4b2OLqv6Y1wy7uzbs3FNfCAH3/CSYwAsAtOuuqwKIScmdMcRnvQgEm5b6i2kv//kzgZ70FUWGfxSblvpzJJcGucat+i5ZYlzcPJR64HuBTR36P87KuvowWoC2zg+/pmCaJlj3Piz6bbK8aXbB8wHWVsx5XO7FrwvHiZbXtUGZuTB6pxygL9kHO8ailYeA6ZJIVD7kEcjep8Kv2NnE4eU9/pLN21FbFRHiSTfu3mnBVlZhNFZLy76S4/cC+JOLxDqgXLMREWFk6shIPe4OE6HVlj5Dc0Vc1XLXscuoWahHbWxAwDRQWoSPNDgHmbmwNTAE8= 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: 76f1ffa4-0558-4e50-28a4-08d630332815 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Oct 2018 11:09:20.1961 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1879 Subject: [dpdk-dev] [PATCH v6 07/22] net/atlantic: configure rte device start/stop 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:23 -0000 From: Pavel Belous Start, stop and reset are all done via hw_atl layer. Signed-off-by: Igor Russkikh Signed-off-by: Pavel Belous --- doc/guides/nics/features/atlantic.ini | 1 + drivers/net/atlantic/atl_ethdev.c | 140 ++++++++++++++++++++++++++++++= ++-- drivers/net/atlantic/atl_ethdev.h | 9 +++ drivers/net/atlantic/atl_types.h | 4 + 4 files changed, 147 insertions(+), 7 deletions(-) diff --git a/doc/guides/nics/features/atlantic.ini b/doc/guides/nics/featur= es/atlantic.ini index e6c5676acf7a..1b9cbf95077f 100644 --- a/doc/guides/nics/features/atlantic.ini +++ b/doc/guides/nics/features/atlantic.ini @@ -4,6 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +FW version =3D Y Linux UIO =3D Y ARMv8 =3D Y x86-32 =3D Y diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_e= thdev.c index 5b05ca180bc7..d756ad4c8b99 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -6,6 +6,11 @@ =20 #include "atl_ethdev.h" #include "atl_common.h" +#include "atl_hw_regs.h" +#include "atl_logs.h" +#include "hw_atl/hw_atl_llh.h" +#include "hw_atl/hw_atl_b0.h" +#include "hw_atl/hw_atl_b0_internal.h" =20 static int eth_atl_dev_init(struct rte_eth_dev *eth_dev); static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev); @@ -16,6 +21,13 @@ static void atl_dev_stop(struct rte_eth_dev *dev); static void atl_dev_close(struct rte_eth_dev *dev); static int atl_dev_reset(struct rte_eth_dev *dev); =20 +static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, + size_t fw_size); + +static void atl_dev_info_get(struct rte_eth_dev *dev, + struct rte_eth_dev_info *dev_info); + + static int eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev); static int eth_atl_pci_remove(struct rte_pci_device *pci_dev); @@ -69,26 +81,83 @@ static const struct eth_dev_ops atl_eth_dev_ops =3D { .dev_stop =3D atl_dev_stop, .dev_close =3D atl_dev_close, .dev_reset =3D atl_dev_reset, - .dev_infos_get =3D atl_dev_info_get, + + .fw_version_get =3D atl_fw_version_get, + .dev_infos_get =3D atl_dev_info_get, }; =20 +static inline int32_t +atl_reset_hw(struct aq_hw_s *hw) +{ + return hw_atl_b0_hw_reset(hw); +} + static int eth_atl_dev_init(struct rte_eth_dev *eth_dev) { + struct atl_adapter *adapter =3D + (struct atl_adapter *)eth_dev->data->dev_private; + struct rte_pci_device *pci_dev =3D RTE_ETH_DEV_TO_PCI(eth_dev); + struct aq_hw_s *hw =3D ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + int err =3D 0; + + PMD_INIT_FUNC_TRACE(); + eth_dev->dev_ops =3D &atl_eth_dev_ops; =20 + /* For secondary processes, the primary process has done all the work */ + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) + return 0; + + /* Vendor and Device ID need to be set before init of shared code */ + hw->device_id =3D pci_dev->id.device_id; + hw->vendor_id =3D pci_dev->id.vendor_id; + hw->mmio =3D (void *)pci_dev->mem_resource[0].addr; + + /* Hardware configuration - hardcode */ + adapter->hw_cfg.is_lro =3D false; + adapter->hw_cfg.wol =3D false; + + hw->aq_nic_cfg =3D &adapter->hw_cfg; + /* Allocate memory for storing MAC addresses */ eth_dev->data->mac_addrs =3D rte_zmalloc("atlantic", ETHER_ADDR_LEN, 0); - if (eth_dev->data->mac_addrs =3D=3D NULL) + if (eth_dev->data->mac_addrs =3D=3D NULL) { + PMD_INIT_LOG(ERR, "MAC Malloc failed"); return -ENOMEM; + } =20 - return 0; + err =3D hw_atl_utils_initfw(hw, &hw->aq_fw_ops); + if (err) + return err; + + /* Copy the permanent MAC address */ + if (hw->aq_fw_ops->get_mac_permanent(hw, + eth_dev->data->mac_addrs->addr_bytes) !=3D 0) + return -EINVAL; + + return err; } =20 static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev) { + struct aq_hw_s *hw; + + PMD_INIT_FUNC_TRACE(); + + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) + return -EPERM; + + hw =3D ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + + if (hw->adapter_stopped =3D=3D 0) + atl_dev_close(eth_dev); + + eth_dev->dev_ops =3D NULL; + rte_free(eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs =3D NULL; =20 return 0; } @@ -118,25 +187,60 @@ atl_dev_configure(struct rte_eth_dev *dev __rte_unuse= d) * It returns 0 on success. */ static int -atl_dev_start(struct rte_eth_dev *dev __rte_unused) +atl_dev_start(struct rte_eth_dev *dev) { - return 0; + struct aq_hw_s *hw =3D ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + int status; + int err; + + PMD_INIT_FUNC_TRACE(); + + /* set adapter started */ + hw->adapter_stopped =3D 0; + + /* reinitialize adapter + * this calls reset and start + */ + status =3D atl_reset_hw(hw); + if (status !=3D 0) + return -EIO; + + err =3D hw_atl_b0_hw_init(hw, dev->data->mac_addrs->addr_bytes); + + hw_atl_b0_hw_start(hw); + + PMD_INIT_LOG(DEBUG, "FW version: %u.%u.%u", + hw->fw_ver_actual >> 24, + (hw->fw_ver_actual >> 16) & 0xFF, + hw->fw_ver_actual & 0xFFFF); + PMD_INIT_LOG(DEBUG, "Driver version: %s", ATL_PMD_DRIVER_VERSION); + + return err; } =20 /* * Stop device: disable rx and tx functions to allow for reconfiguring. */ static void -atl_dev_stop(struct rte_eth_dev *dev __rte_unused) +atl_dev_stop(struct rte_eth_dev *dev) { + struct aq_hw_s *hw =3D + ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + /* reset the NIC */ + atl_reset_hw(hw); + hw->adapter_stopped =3D 1; } =20 /* * Reset and stop device. */ static void -atl_dev_close(struct rte_eth_dev *dev __rte_unused) +atl_dev_close(struct rte_eth_dev *dev) { + PMD_INIT_FUNC_TRACE(); + + atl_dev_stop(dev); } =20 static int @@ -153,6 +257,28 @@ atl_dev_reset(struct rte_eth_dev *dev) return ret; } =20 +static int +atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_si= ze) +{ + struct aq_hw_s *hw =3D ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint32_t fw_ver =3D 0; + unsigned int ret =3D 0; + + ret =3D hw_atl_utils_get_fw_version(hw, &fw_ver); + if (ret) + return -EIO; + + ret =3D snprintf(fw_version, fw_size, "%u.%u.%u", fw_ver >> 24, + (fw_ver >> 16) & 0xFFU, fw_ver & 0xFFFFU); + + ret +=3D 1; /* add string null-terminator */ + + if (fw_size < ret) + return ret; + + return 0; +} + static void atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_inf= o) { diff --git a/drivers/net/atlantic/atl_ethdev.h b/drivers/net/atlantic/atl_e= thdev.h index 622806837379..c0cc5475a091 100644 --- a/drivers/net/atlantic/atl_ethdev.h +++ b/drivers/net/atlantic/atl_ethdev.h @@ -6,10 +6,19 @@ #define _ATLANTIC_ETHDEV_H_ #include #include "rte_ethdev.h" + +#include "atl_types.h" +#include "hw_atl/hw_atl_utils.h" + +#define ATL_DEV_PRIVATE_TO_HW(adapter) \ + (&((struct atl_adapter *)adapter)->hw) + /* * Structure to store private data for each driver instance (for each port= ). */ struct atl_adapter { + struct aq_hw_s hw; + struct aq_hw_cfg_s hw_cfg; }; =20 #endif /* _ATLANTIC_ETHDEV_H_ */ diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_ty= pes.h index c9ebbf4e91d8..37ad43a110f0 100644 --- a/drivers/net/atlantic/atl_types.h +++ b/drivers/net/atlantic/atl_types.h @@ -76,6 +76,10 @@ struct aq_hw_cfg_s { }; =20 struct aq_hw_s { + u16 device_id; + u16 vendor_id; + bool adapter_stopped; + u8 rbl_enabled:1; struct aq_hw_cfg_s *aq_nic_cfg; const struct aq_fw_ops *aq_fw_ops; --=20 2.7.4