From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0060.outbound.protection.outlook.com [104.47.32.60]) by dpdk.org (Postfix) with ESMTP id 458255F3D for ; Thu, 13 Sep 2018 13:35:58 +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=lcviMHdJexvnZxuaCUkaP4z/f0dAvfuqJFYD4sGrmbc=; b=FoQuWkhfwN76iZ5VW2u8pZUvmpTKbVCl8gbTpLExrITA6dSbQgzjn1Gi02BICroLT/Ef7L9f7rNpRmXJJud5yAnEE99wKjh48qMGqJOrxm0zj1vRI4XneXggrtSwh5EZopgvrA6YH1O+JjpAIWjkKXbulFqTl+FlkCganAQNgZw= 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:35:55 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, igor.russkikh@aquantia.com Date: Thu, 13 Sep 2018 14:35:15 +0300 Message-Id: <1536838528-11800-8-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: 91d2aa97-5e26-42ea-e3ad-08d6196d124d 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:zhmUM1UUY2dlTzzBEDq7b2pX4127150NZgl4/vYGwqvW9tVzbkOgnbA+k0/dQ0/dRIAGhytRaYYJRkkZw6PYp3/2t8HHXv4o3Mor0qocnxdr21lFOYk4bB8nGFw6SnrOqNQaPwUdY8evm5RW8HpfBJ20Lo5cG11P3giMgz3+X1sjIONi9wBfS1k1IYnmRuWWrLlfcN3YXgMoQlBvQK/mfoz6c8FQvlpT2C6fRWjbBjlTAhvUjDnn71dcXjcujrS4; 25:ZVlI2wTF9aFKzG5P/nTK86kfUfTHoD+9/bVkzJRLotcAilAB0td7OGewGbPP/2k0Q12xSAPj2EYfwyV1uzPMjPr1iy3hDl4Ex+JDizJ/56OcqsSj5WiueMX/h2VC1QlCL+uDTVNpwvHaiMo8LDYMg/RvA+eqEjz9ddke1oKd3951bRf1ocNNFz0stQFM8Q+2vxMB1iWN4P0Xw1Zcgjsw1dMp0M3O+l5KSLw5LbjRjzCnk7nI/Ckuqipqu2t/o2B0uA2SggGkJjWC1akHyMmg/eOaeGcsvysJHm5vQa3qREc8rl81/+uhDC9eV4qrxoLaHVur+STuWSehbPOz7qV6Cri8ZT25wCj2jyFqpofbk/Q=; 31:LwGa9d5C4GHoaDuYWJ3iyCtBJAnj8nFXt0nwQgbYt7fNXOvXMMaqYz1EwHu1DBKHTg4wtmnnFI3f7Tgx08Rky8SDltpGJyWrIXqnReOMdASNX/sWszbjoNw9oxiyH9du300KxQ1h4gwBAP8Jnq5C8qiZf5/c/SgLz+QfI8OoNOkUxiAih8rUXhNdZa5ZIDRxEEgNN+9RedR+lBednsozsZUPOMb1kjFlL5kPnwokR0o= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1650: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 20:qDkkzzx6dKYFVEgW67oa9bmwoZGX5BYvjZpudq413NpjfloZVT6Mc4pmMRlMpggv5o0JgK6oTGMLu5R8pusidtqfpHjjl9sagls59/QkbMmtj6oykRxHbvvLBdvkZRy58LexVUOtGadCMJqFYejJjYE2ZRDCZCd/c9HuIHmGt/LFjkM/OcwqO9geixgNr/TcEVmIgRA0zYv9WzgRB0lf3h2IFbFBfsprQaf9982OozlxdbkXmvd4mcbRvLcHdNCz5Qry26UChB4XkF+3KgnEUGqEf99WVIQL8iqBOGP4fgjCnUzJLYTdzVVhIm/JdmUxknHYM39JC1CO3YHpWkRaeIxgquWesEGpRGqrqmf1l7X5Wiidk9g3jIKTgxHelX2rxNOgf2B8VV+mhU488OEgU7O9dP9R8aORr6lF9P/i8UeLNku26xfQq4VUnBiU3bRbfgKRkRJo76QmPLrIwoct4Oiai0SHNDpHJWiyQZqvD6iylchKcnXUv3joENOcU0ef; 4:53hasrGkbu8DgyOpic18+K+7wPKS22ZdJ5sBhIYaxQlbPTlkX+d6CIvRp7HQEPSJ16fD28k95V912aPpwQhDGFR3po6/jV1ngTBu5uCgR4m1zB7fEyU6lYHNiGm5rtNtOO4Bm256wzBFqWyKrGzVB8keEUg2z2cWvrAzdrn06cQYMKsmaERO7FA2xhJm/rERQsHbPeUkLErc2yAnv2GltJ+nLEJ7VtZ4k6WTf+49NxU8WhP0W8+kmKJKKwxsuEI6ODmKQ9O9ncxzpxg2ODHTcW8w0JPjFkAiBnbbdZCRBBqhWwVCysh5CjzBlILipLXjCWSetwx9bhj0pU99kaKDApaN9mc1JV8aoxnFTBZhNmU= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705)(211171220733660); 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)(575784001)(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:X02JbGDoAlm2Nk3SGp7FJtgJYM5QTvkuLQH1mz3?= =?us-ascii?Q?f8HB1HwgNQ+dKJypeClVcTyB8a9i/BQmAOtPexnGQmhuXDWsY//+BWGDIF4G?= =?us-ascii?Q?uP5Crf0I037rzldUvL/MC6mhpETTjIgSZy+gzvHUPdH6T/C5usoJpvNcdFUi?= =?us-ascii?Q?aHkYqpraqrgszYB/jO4DL49UVWf9mefsZ4JUxSf4EpIpoDTpzCcb9LNWpzCD?= =?us-ascii?Q?ymdU32jJS4kQL7S4TlrC5ZvTKBlhDPHW9pLzG2LBrwlowECFOKb4Ydeq01ZW?= =?us-ascii?Q?6ohz6JbaaZO7G+icyhzhnJLEuhimU6GT3NkdmYlrP5OF6Ew0c4mG75a479Ra?= =?us-ascii?Q?pRgbNfC8saPRbbmQYS3UNYxYsFtrYzx6vT93LfP0N7P4gTbVwGuxk57y4vlw?= =?us-ascii?Q?/thl7YWvXG26m5WUVEb8EfhMOCEIMnoWaUGUTrTJIQ+qXhpl1Sz/sx47I8Z+?= =?us-ascii?Q?gtcKhpaXVl2uMhLxxZjbbwGb5Kj2Ay3UhVawX+ihRTldQbv0QU4dlkdUO4QR?= =?us-ascii?Q?UfP8h4oHPWb1ssxCzmLRPe7rrWM/L4AlwJK6RmyQHAKykDmqvrM0ORmIstId?= =?us-ascii?Q?drQ7wXb2t3E2RLoki38OY9a4Ki2INxog7cf8EeaD1SnQ4TMxQqbyBujDMoAF?= =?us-ascii?Q?TutTWTMSXf7X9dJrXyNWaCUsDTUhu+OCCKGAKKJVibUwYUR+V7AV+fmTXgoZ?= =?us-ascii?Q?731BDlSwVvvkpB4wkfswV0t2nn6TyaU7BwwJ3BigtYLSL8bBX/bC4fgjWgCV?= =?us-ascii?Q?PH3uBceoOeA0af25GrfjKJgq6ZJEcylvY++V26Z0OjoEk3C609L2LZ/GQWlq?= =?us-ascii?Q?DLac+Yfk8mawlNebyyzknxVFDpZ9Vzz1EKawN6tiK1VoOfk14+bIY1YB4aVi?= =?us-ascii?Q?hc94jjW57XtL3GI7SOlB5TQ8SAqk6SD98Z/XXuHCQ2h/Ei8AaiwJ4Dby80Ay?= =?us-ascii?Q?j+9gVHBM/zNJsvHJrNt2bA2BLrkwQw699eMHRRZomNvwvVCOP9iysujIXcKf?= =?us-ascii?Q?GBXXcYNNUrbHO9WgJ+a0lY8eoh381AGIKQMtnT7KToKDFI0B66jv8zYmn88V?= =?us-ascii?Q?mPmQQJ7vKggKdkrxxicqe8oons55kEinGXJyMtP57rU6Ji/yRTjiIWuhI0Ba?= =?us-ascii?Q?xGQhEy5kqck75oWS/nOL2WgJvb5OzTUMZIM+9pxR/PKeU4YOVm6dMVd7FpRz?= =?us-ascii?Q?F1w4AZZplMpHTDAOyzvZXkaVAvDOmnHU5t2XWF680E07DFgAwqaVoDVJYghg?= =?us-ascii?Q?MskDSpy2hWd7wmjjap/CCb9WicA90kE9YJhNB2joHfV5S4//B8qpBXGeAXla?= =?us-ascii?Q?+MA=3D=3D?= X-Microsoft-Antispam-Message-Info: wH2m5vmjvp3m/9mdITHAIeuAEITXSWx61suyWESVgVcJP8vUpuJJjARM5kOJ7HZsg24JpGnWe0DJuzcQRH/9RFWkKkmid2oHUw2LSO7rPob30Akqja+e79pMix7fqWLkMv20wXGnwe0nRLdfyZp/KMzQ392K2kncz4KUvekzeCJ0PRWKPLIEElPlgLWK3pJG9OvVMGdPG4Ak7gWCBBJRl8jms1ZL0Ngi5QWkw5bBzFleHv/Adl6UuZoXZPvyOzLyPreQN9eFjtKzkoFbnW+JumAH+QEsRa45ScjOgtB/Po0ZCIecMB+St93YktfXd8/u9l8DLq86g2l7NDqer6gTB/wFvsbJoOUt2s/aWGRtmng= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 6:0urNvszt0iBLpJYPHHbFZq4A/YCx6yn8plYfm0KOSfmAG4jrjfu0ZDUZXg6shYEhvWw5Bmjbz7LigfJpcGxKGm7/lauOMznTG03AFxYJ4mvDXZC13bfe2mVCXxGqishBUUq0mHQaEhwiSbzwWwC/xq1V4akjiCBZHDONDFPIDYvjqu1VuPlvawOBK8be3MCzNJNfjon3aiGqJ9+4y9osSRiynifVOUTQ57vhYmjwfF9Ca/rquTZXxHdyPthcANZI/ezxMHLkCfx2CA/4/3JYtcpC2uEsNhobAj2Jgkp8602haRZx7SSGC7K/ouxauPoM1vmwoSEgSSOexNL/UBrY8aNkp9ahbVHi9R4ZFiN0dP4HRiMknbdhPEJ5Bf974dr3357aZAHgfEKqL6mbemtIaVh5J2j+8GarpdCjGpahe56s2I5qeG/bKjIGPlBBd8u7L8c4JAj1nqoNOxNEj/X1cA==; 5:kGsoQyUK1rRuE8qBbvaBnjogdYEgvNxywNaeY4E+6X+BPWB+QUM6pZtjujjuDqCJmhXFE9FYrZxGbtvuhRMm/NB7Qm8nUaTlmD487CirSWR9P97GpOF5YlQmGPTxNK2BW4z+Q3lVfSueJ2bGl0FQTe0bCDuKj6LWJHiS7LNNQTw=; 7:rFNBovptER7wwr6x7T96DMc/V/UoyNsygXIGNXRlzf96ZF95jm9H5JszE0YtsWffs9BNG53zDEt6MxzDgsJmIzUrfisqn/FwFRtUuxeVtbfVyCl5Ao0NPuzFMUGGn1R4fKdKJ542gg6HaKHuWTRU4sDQgdJusDIfUCe+1kj7vnQCuIS75g6gubPblM9IsbELa5pmpnekp26q6JxarI6CuwoPV/eGSsOJ8DjuXbkETk/RysjIBRgb/MvApkbJhtOg SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2018 11:35:55.9810 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91d2aa97-5e26-42ea-e3ad-08d6196d124d 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 08/21] net/atlantic: rte device start, stop, initial configuration 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:35:58 -0000 Start, stop and reset are all done via hw_atl layer. Link interrupt configuration is also done here. Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_ethdev.c | 256 ++++++++++++++++++++++++++++++++++++++ drivers/net/atlantic/atl_ethdev.h | 2 + 2 files changed, 258 insertions(+) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 951e0f386..5de295f6f 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -39,6 +39,9 @@ #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" static int eth_atl_dev_init(struct rte_eth_dev *eth_dev); static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev); @@ -126,6 +129,26 @@ static const struct eth_dev_ops atl_eth_dev_ops = { .dev_reset = atl_dev_reset, }; +static inline int32_t +atl_reset_hw(struct aq_hw_s *hw) +{ + return hw_atl_b0_hw_reset(hw); +} + +static inline void +atl_enable_intr(struct rte_eth_dev *dev) +{ + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + hw_atl_itr_irq_msk_setlsw_set(hw, 0xffffffff); +} + +static void +atl_disable_intr(struct aq_hw_s *hw) +{ + PMD_INIT_FUNC_TRACE(); + hw_atl_itr_irq_msk_clearlsw_set(hw, 0xffffffff); +} static int atl_get_bus_info(struct aq_hw_s *hw) @@ -136,6 +159,16 @@ atl_get_bus_info(struct aq_hw_s *hw) return 0; } +static void +atl_print_adapter_info(struct aq_hw_s *hw __rte_unused) +{ + 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); +} + static int eth_atl_dev_init(struct rte_eth_dev *eth_dev) { @@ -157,6 +190,62 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; + rte_eth_copy_pci_info(eth_dev, pci_dev); + + /* Vendor and Device ID need to be set before init of shared code */ + hw->device_id = pci_dev->id.device_id; + hw->vendor_id = pci_dev->id.vendor_id; + hw->mmio = (void *)pci_dev->mem_resource[0].addr; + hw->allow_unsupported_sfp = 1; + + /* Hardware configuration - hardcode */ + adapter->hw_cfg.is_lro = false; + adapter->hw_cfg.is_rss = false; + adapter->hw_cfg.num_rss_queues = HW_ATL_B0_RSS_MAX; + adapter->hw_cfg.wol = false; + adapter->hw_cfg.link_speed_msk = AQ_NIC_RATE_10G | + AQ_NIC_RATE_5G | + AQ_NIC_RATE_2G5 | + AQ_NIC_RATE_1G | + AQ_NIC_RATE_100M; + + adapter->hw_cfg.flow_control = (AQ_NIC_FC_RX | AQ_NIC_FC_TX); + adapter->hw_cfg.aq_rss.indirection_table_size = + HW_ATL_B0_RSS_REDIRECTION_MAX; + + hw->aq_nic_cfg = &adapter->hw_cfg; + + /* pick up the PCI bus settings for reporting later */ + atl_get_bus_info(hw); + + /* disable interrupt */ + atl_disable_intr(hw); + + /* Allocate memory for storing MAC addresses */ + eth_dev->data->mac_addrs = rte_zmalloc("atlantic", ETHER_ADDR_LEN, 0); + if (eth_dev->data->mac_addrs == NULL) { + PMD_INIT_LOG(ERR, "MAC Malloc failed"); + return -ENOMEM; + } + + err = 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, + (u8 *)ð_dev->data->mac_addrs[0]) != 0) + return -EINVAL; + + rte_intr_callback_register(intr_handle, + atl_dev_interrupt_handler, eth_dev); + + /* enable uio/vfio intr/eventfd mapping */ + rte_intr_enable(intr_handle); + + /* enable support intr */ + atl_enable_intr(eth_dev); + return err; } @@ -172,10 +261,30 @@ eth_atl_dev_uninit(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return -EPERM; + hw = ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + + if (hw->adapter_stopped == 0) + atl_dev_close(eth_dev); + eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; + /* disable uio intr before callback unregister */ + rte_intr_disable(intr_handle); + rte_intr_callback_unregister(intr_handle, + atl_dev_interrupt_handler, eth_dev); + + rte_free(eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs = NULL; + + rte_free(eth_dev->data->hash_mac_addrs); + eth_dev->data->hash_mac_addrs = NULL; + +#ifdef RTE_LIBRTE_SECURITY + rte_free(eth_dev->security_ctx); +#endif + return 0; } @@ -199,6 +308,11 @@ atl_dev_configure(struct rte_eth_dev *dev) struct atl_interrupt *intr = ATL_DEV_PRIVATE_TO_INTR(dev->data->dev_private); + PMD_INIT_FUNC_TRACE(); + + /* set flag to update link status after init */ + intr->flags |= ATL_FLAG_NEED_LINK_UPDATE; + return 0; } @@ -219,6 +333,32 @@ atl_dev_start(struct rte_eth_dev *dev) int status; int err; + PMD_INIT_FUNC_TRACE(); + + if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) { + PMD_INIT_LOG(ERR, + "Invalid link_speeds for port %u, fix speed not supported", + dev->data->port_id); + return -EINVAL; + } + + /* disable uio/vfio intr/eventfd mapping */ + rte_intr_disable(intr_handle); + + /* stop adapter */ + hw->adapter_stopped = 0; + + /* reinitialize adapter + * this calls reset and start + */ + status = atl_reset_hw(hw); + if (status != 0) + return -1; + + err = hw_atl_b0_hw_init(hw, (uint8_t *)dev->data->mac_addrs); + + hw_atl_b0_hw_start(hw); + /* check and configure queue intr-vector mapping */ if ((rte_intr_cap_multiple(intr_handle) || !RTE_ETH_DEV_SRIOV(dev).active) && @@ -245,6 +385,33 @@ atl_dev_start(struct rte_eth_dev *dev) } } + if (rte_intr_allow_others(intr_handle)) { + /* check if lsc interrupt is enabled */ + if (dev->data->dev_conf.intr_conf.lsc != 0) + atl_dev_lsc_interrupt_setup(dev, TRUE); + else + atl_dev_lsc_interrupt_setup(dev, FALSE); + } else { + rte_intr_callback_unregister(intr_handle, + atl_dev_interrupt_handler, dev); + if (dev->data->dev_conf.intr_conf.lsc != 0) + PMD_INIT_LOG(INFO, "lsc won't enable because of" + " no intr multiplex"); + } + + /* check if rxq interrupt is enabled */ + if (dev->data->dev_conf.intr_conf.rxq != 0 && + rte_intr_dp_is_en(intr_handle)) + atl_dev_rxq_interrupt_setup(dev); + + /* enable uio/vfio intr/eventfd mapping */ + rte_intr_enable(intr_handle); + + /* resume enabled intr since hw reset */ + atl_enable_intr(dev); + + atl_print_adapter_info(hw); + return 0; error: @@ -258,6 +425,40 @@ atl_dev_start(struct rte_eth_dev *dev) static void atl_dev_stop(struct rte_eth_dev *dev) { + struct rte_eth_link link; + struct aq_hw_s *hw = + ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; + + PMD_INIT_FUNC_TRACE(); + + /* disable interrupts */ + atl_disable_intr(hw); + + /* reset the NIC */ + atl_reset_hw(hw); + hw->adapter_stopped = 0; + /* Clear stored conf */ + dev->data->scattered_rx = 0; + dev->data->lro = 0; + + /* Clear recorded link status */ + memset(&link, 0, sizeof(link)); + rte_atl_dev_atomic_write_link_status(dev, &link); + + if (!rte_intr_allow_others(intr_handle)) + /* resume to the default handler */ + rte_intr_callback_register(intr_handle, + atl_dev_interrupt_handler, + (void *)dev); + + /* Clean datapath event and queue/vec mapping */ + rte_intr_efd_disable(intr_handle); + if (intr_handle->intr_vec != NULL) { + rte_free(intr_handle->intr_vec); + intr_handle->intr_vec = NULL; + } } /* @@ -270,6 +471,8 @@ atl_dev_close(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); + atl_reset_hw(hw); + atl_dev_stop(dev); hw->adapter_stopped = 1; } @@ -288,6 +491,59 @@ atl_dev_reset(struct rte_eth_dev *dev) return ret; } + +/* + * It executes link_update after knowing an interrupt occurred. + * + * @param dev + * Pointer to struct rte_eth_dev. + * + * @return + * - On success, zero. + * - On failure, a negative value. + */ +static int +atl_dev_interrupt_action(struct rte_eth_dev *dev, + struct rte_intr_handle *intr_handle) +{ + struct atl_interrupt *intr = + ATL_DEV_PRIVATE_TO_INTR(dev->data->dev_private); + + if (intr->flags & ATL_FLAG_NEED_LINK_UPDATE) { + atl_dev_link_update(dev, 0); + intr->flags &= ~ATL_FLAG_NEED_LINK_UPDATE; + atl_dev_link_status_print(dev); + _rte_eth_dev_callback_process(dev, + RTE_ETH_EVENT_INTR_LSC, NULL); + } + + atl_enable_intr(dev); + rte_intr_enable(intr_handle); + + return 0; +} + +/** + * Interrupt handler triggered by NIC for handling + * specific interrupt. + * + * @param handle + * Pointer to interrupt handle. + * @param param + * The address of parameter (struct rte_eth_dev *) regsitered before. + * + * @return + * void + */ +static void +atl_dev_interrupt_handler(void *param) +{ + struct rte_eth_dev *dev = (struct rte_eth_dev *)param; + + atl_dev_interrupt_get_status(dev); + atl_dev_interrupt_action(dev, dev->intr_handle); +} + RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map); RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic"); diff --git a/drivers/net/atlantic/atl_ethdev.h b/drivers/net/atlantic/atl_ethdev.h index 18a814a32..0018fa898 100644 --- a/drivers/net/atlantic/atl_ethdev.h +++ b/drivers/net/atlantic/atl_ethdev.h @@ -20,6 +20,8 @@ * 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; }; #define ATL_DEV_TO_ADAPTER(dev) \ -- 2.13.3.windows.1