From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0089.outbound.protection.outlook.com [104.47.42.89]) by dpdk.org (Postfix) with ESMTP id C996E4D3A for ; Fri, 7 Sep 2018 17:23:24 +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=5TmLjhTQEHTPCgsz8ClHtnGMQr19MRIt4X1J290m3nk=; b=pC/ZqlsUpPQwuGpcwQhKlAy15Y/SH0CBXEWweT/mauQM/CDcY3ArVpVLshpfdg/VYUzn4D4L7qhqSNJKYn7lt+7vzcqw+oe1eQ2emFF+gwKTvfgEVAREKWCiiBH11KF6++KwY7CBRMwJT8YJpEIgZszWWG5sahxJpNOMZ2FGPMQ= 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:18 +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:47 +0300 Message-Id: <1536333719-32155-10-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: 45f0e062-a56b-4410-463e-08d614d5d771 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:5fW5vtxbvGvrRioEln1Y7t1oknqe8uXU+dFAdKsDqpdqfVIuphzD5GI1BIlQBivpBND3/LYyPZVbCJOTgFNgPhesqN+4bZM0jh80SXsU6LqPOuC5B7zIfgpB/rZ3QYoNSZLc+6hHsO2rGPEtHSr0RV/OB9ulUnAqxVJa7tKAxNYSsw/4CmojIpziX7MLz2eEy8CIFqMRV84FYs5EbU9SVo++vkd/QF/RxcMGlSuJ5JJ4tS7HQA8XwqDnTEv4G05b; 25:a1SsdJ2ReXwPZJ7BsgoxXY5nQd2dI2PWKu7OVxORDGDgJANwMy2K39Uv72oQyCGyK/csydQXWznybsxQbFLISJ8hxfGNBnTbUULp5Ond+wivFjm9zmI5dGraHjRmZX35KxiPWSGESdTXmv1aQD4McVu9E+LztJiF6E+FhPX6jpGoiIhWRTh6WZzzlI6PFRe8nUFVMxXY3wpxc1KnxiAS5PLmt/2ufEccxyd1bFHr1UHexRfVtVveraf3crFKCY86b67muBGWbfqQ31RZNSIo0vkBW2UcoMfBaEklx8b6i5fiYUcyJT+9zZpDcY9tndzlsyAt2IRwY0+kn+MuhmM9kw==; 31:hBlV8lLp0g9raibawT+Txovu1AqjZx+tYXYu0cxx4iu2RwuSK2WPXmRcC9QIVk/pISNuce2GhwdiDjKCKTv36nb9V1jk3/y6fP+ahAxI0PF4DR5eWbRuH9hl5n/hyGawusoLG1fXEyy3EIADVD31LCbpPq1BMRZETXExQ7mtvCSI6AbwBeyskB54p1+apf7QU9YYT/SoUW4O4DzAVzp6e4L7590Rw6oCfcZ8M4bhf/0= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1652: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1652; 20:u8ZhbSLRLJRQwzyoVKqhXcU1Rphu4IfljW5oXOr5CBX4IvasreBIVviiwgrQQt5KAw/uzxJ7u4okJiVFThbl7bt4ZN9UXBuMjc57Dmcoq4XaPvBKXysjjfUJJ1vtl3iRAIoYngMmoe+mBH71qf+3hG8TSHpJXbeDHyrR6/ejaFvDYDyDj2dJCf62YpnTjhiQiT01APqOrKGuiKgVBOFQupffAapYj6+iaehQa+80EP9zWizssgqfEqdZth5LqS8aVDsOs2EcgP6mwhblMHPRBsljMSwbHlWQW0OI/q7uaztWyT/zBXBIbNzKAmPLU4p1bho0GTH3ut9OWJDZ2X8/bX8R63tfKkr0JdIIrUk16yKv5j9MKjphugaHX1TvjGMn1j2HgF/HPmvI6Lob3dKehtUQ1HeNOHgdSunUaJoAxnIW37OD2yGRHVcNpqrMXtDaBWRNGDbTX5r0cTdEbb79fXnogw8aMEPjaMfeDzkCBuvsFYA2QS4myqlXfEPUZmLR; 4:rc9qbh4/z8e6oUEV3A+Ug12tB9ygxnHi179TYdFnViq+pM8Ke9ZSj4QmmKNQR/d+MP1oev7xj2DL92V0qUztRp/YK/q1e6xWfhidfQdPM5uhAGYnzLG2UbQjF6p+KmJ9f1f1N5wL2SHjIKzElByg5yZZKkwB50i0FUsvddErPn7NPARx6fBRcq1H6NtKmsCpNUm/7pLnw5GSK/VkDeumgx4jxG3FZIPYCdATHETkZty6Vci/K5zqFi/habM5HzrSk0QD/qu5G6Uebsepv22lsqztd8B0W6sLLmx3WCD5rfzx5h6EHQ+1vyf0z9vJoG+9 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(269456686620040); 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:cwItGoAbxI6GII/pkb3w1GEG4yapSpnvZXPYtwl?= =?us-ascii?Q?YWSN5cRLNhrH56kR3HgKZpipx142BeY0ih9ZBn7FSZKDSixspVWVbFtSxTmm?= =?us-ascii?Q?HAHV4RTKuEzzC4A/8oqISjYGn9Gs+wQ0MGnXOD4qs7BgJXg5v5JOJAqre+/2?= =?us-ascii?Q?D+/uEhZMIkRt7l4/qC01GQqgR2QGUd921eOhr/TOuhZrMb4YEmd5C6fIzYzu?= =?us-ascii?Q?OOF0p+ZjhXrTRlrCxwOSI6a4tnlK5zEPkn+5PfkLOvNN9FwW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yJSIIyXQ99EfhZqbSKOU+AGj/gzAK65w+hieghKUC/PnZfUOqjst/yPEehkWjGg5FmTDa1xcyJ+3/Q67H8AqtmAWr5VXCN8U4E/b8/TAphTUFtcq1jmOpyK3wXo5uQVkpsu/VuXSaIUHJ4a8a0NmL/fw26M=; 7:T3cEF5WaJrZMsUcDOSHggba19SZLZnFBToCfrjOGp6TAcU+b7JxR1mHASrLXSYZW11bVcvE17XpEPSos4vD94Ug4FX/HgT0AfywsE19qcdkWECRLtzCe+QSljYgsGROJfCkZsELSMY2WRn/V527h+VuBWl4Qk0nMCy3nZp1iemwt+s0yfw+D8GRcw71JVd4TwbDbs6Skgf2Th6kgHIz8l25gJgYDwsN/VpfQT+kpoBEzdpGZk+w6cT6WwuLRtoet SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2018 15:23:18.1147 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45f0e062-a56b-4410-463e-08d614d5d771 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 09/21] net/atlantic: link status and interrupt management 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:25 -0000 From: Pavel Belous Implement link interrupt, link info, link polling Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_ethdev.c | 255 ++++++++++++++++++++++++++++++++++++++ drivers/net/atlantic/atl_ethdev.h | 10 ++ 2 files changed, 265 insertions(+) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 78438174e..6dda8280a 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -49,8 +49,11 @@ static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev); static int atl_dev_configure(struct rte_eth_dev *dev); static int atl_dev_start(struct rte_eth_dev *dev); static void atl_dev_stop(struct rte_eth_dev *dev); +static int atl_dev_set_link_up(struct rte_eth_dev *dev); +static int atl_dev_set_link_down(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); +static int atl_dev_link_update(struct rte_eth_dev *dev, int wait); static int atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id, @@ -63,6 +66,15 @@ 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); +/* Interrupts */ +static int atl_dev_rxq_interrupt_setup(struct rte_eth_dev *dev); +static int atl_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on); +static int atl_dev_interrupt_get_status(struct rte_eth_dev *dev); +static int atl_dev_interrupt_action(struct rte_eth_dev *dev, + struct rte_intr_handle *handle); +static void atl_dev_interrupt_handler(void *param); + + 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); @@ -125,10 +137,66 @@ static const struct eth_dev_ops atl_eth_dev_ops = { .dev_configure = atl_dev_configure, .dev_start = atl_dev_start, .dev_stop = atl_dev_stop, + .dev_set_link_up = atl_dev_set_link_up, + .dev_set_link_down = atl_dev_set_link_down, .dev_close = atl_dev_close, .dev_reset = atl_dev_reset, + /* Link */ + .link_update = atl_dev_link_update, }; +/** + * Atomically reads the link status information from global + * structure rte_eth_dev. + * + * @param dev + * - Pointer to the structure rte_eth_dev to read from. + * - Pointer to the buffer to be saved with the link status. + * + * @return + * - On success, zero. + * - On failure, negative value. + */ +static inline int +rte_atl_dev_atomic_read_link_status(struct rte_eth_dev *dev, + struct rte_eth_link *link) +{ + struct rte_eth_link *dst = link; + struct rte_eth_link *src = &(dev->data->dev_link); + + if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, + *(uint64_t *)src) == 0) + return -1; + + return 0; +} + +/** + * Atomically writes the link status information into global + * structure rte_eth_dev. + * + * @param dev + * - Pointer to the structure rte_eth_dev to read from. + * - Pointer to the buffer to be saved with the link status. + * + * @return + * - On success, zero. + * - On failure, negative value. + */ +static inline int +rte_atl_dev_atomic_write_link_status(struct rte_eth_dev *dev, + struct rte_eth_link *link) +{ + struct rte_eth_link *dst = &(dev->data->dev_link); + struct rte_eth_link *src = link; + + if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, + *(uint64_t *)src) == 0) + return -1; + + return 0; +} + static inline int32_t atl_reset_hw(struct aq_hw_s *hw) { @@ -383,6 +451,38 @@ atl_dev_start(struct rte_eth_dev *dev) } } + + err = hw->aq_fw_ops->update_link_status(hw); + + if (err) { + goto error; + } + + dev->data->dev_link.link_status = hw->aq_link_status.mbps != 0; + + link_speeds = &dev->data->dev_conf.link_speeds; + + speed = 0x0; + + if (*link_speeds == ETH_LINK_SPEED_AUTONEG) { + speed = hw->aq_nic_cfg->link_speed_msk; + } else { + if (*link_speeds & ETH_LINK_SPEED_10G) + speed |= AQ_NIC_RATE_10G; + if (*link_speeds & ETH_LINK_SPEED_5G) + speed |= AQ_NIC_RATE_5G; + if (*link_speeds & ETH_LINK_SPEED_1G) + speed |= AQ_NIC_RATE_1G; + if (*link_speeds & ETH_LINK_SPEED_2_5G) + speed |= AQ_NIC_RATE_2G5; + if (*link_speeds & ETH_LINK_SPEED_100M) + speed |= AQ_NIC_RATE_100M; + } + + err = hw->aq_fw_ops->set_link_speed(hw, speed); + if (err) + goto error; + if (rte_intr_allow_others(intr_handle)) { /* check if lsc interrupt is enabled */ if (dev->data->dev_conf.intr_conf.lsc != 0) @@ -460,6 +560,28 @@ atl_dev_stop(struct rte_eth_dev *dev) } /* + * Set device link up: enable tx. + */ +static int +atl_dev_set_link_up(struct rte_eth_dev *dev) +{ + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + return hw->aq_fw_ops->set_link_speed(hw, hw->aq_nic_cfg->link_speed_msk); +} + +/* + * Set device link down: disable tx. + */ +static int +atl_dev_set_link_down(struct rte_eth_dev *dev) +{ + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + return hw->aq_fw_ops->set_link_speed(hw, 0); +} + +/* * Reset and stop device. */ static void @@ -490,6 +612,139 @@ atl_dev_reset(struct rte_eth_dev *dev) } +/* return 0 means link status changed, -1 means not changed */ +static int +atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused) +{ + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct atl_interrupt *intr = ATL_DEV_PRIVATE_TO_INTR(dev->data->dev_private); + struct rte_eth_link link, old; + int err = 0; + + link.link_status = ETH_LINK_DOWN; + link.link_speed = 0; + link.link_duplex = ETH_LINK_FULL_DUPLEX; + link.link_autoneg = hw->is_autoneg ? ETH_LINK_AUTONEG : ETH_LINK_FIXED; + memset(&old, 0, sizeof(old)); + + /* load old link status */ + rte_atl_dev_atomic_read_link_status(dev, &old); + + /* read current link status */ + err = hw->aq_fw_ops->update_link_status(hw); + + if (err) + return 0; + + if (hw->aq_link_status.mbps == 0) { + /* write default (down) link status */ + rte_atl_dev_atomic_write_link_status(dev, &link); + if (link.link_status == old.link_status) + return -1; + return 0; + } + + intr->flags &= ~ATL_FLAG_NEED_LINK_CONFIG; + + link.link_status = ETH_LINK_UP; + link.link_duplex = ETH_LINK_FULL_DUPLEX; + link.link_speed = hw->aq_link_status.mbps; + + rte_atl_dev_atomic_write_link_status(dev, &link); + + if (link.link_status == old.link_status) + return -1; + + return 0; +} + +/** + * It clears the interrupt causes and enables the interrupt. + * It will be called once only during nic initialized. + * + * @param dev + * Pointer to struct rte_eth_dev. + * @param on + * Enable or Disable. + * + * @return + * - On success, zero. + * - On failure, a negative value. + */ + +static int +atl_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on __rte_unused) +{ + atl_dev_link_status_print(dev); + return 0; +} + +static int +atl_dev_rxq_interrupt_setup(struct rte_eth_dev *dev __rte_unused) +{ + return 0; +} + + +static int +atl_dev_interrupt_get_status(struct rte_eth_dev *dev) +{ + struct atl_interrupt *intr = ATL_DEV_PRIVATE_TO_INTR(dev->data->dev_private); + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + u64 cause = 0; + + hw_atl_b0_hw_irq_read(hw, &cause); + + atl_disable_intr(hw); + intr->flags = cause & BIT(ATL_IRQ_CAUSE_LINK) ? ATL_FLAG_NEED_LINK_UPDATE : 0; + + return 0; +} + +/** + * It gets and then prints the link status. + * + * @param dev + * Pointer to struct rte_eth_dev. + * + * @return + * - On success, zero. + * - On failure, a negative value. + */ +static void +atl_dev_link_status_print(struct rte_eth_dev *dev) +{ + struct rte_eth_link link; + + memset(&link, 0, sizeof(link)); + rte_atl_dev_atomic_read_link_status(dev, &link); + if (link.link_status) { + PMD_DRV_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s", + (int)(dev->data->port_id), + (unsigned)link.link_speed, + link.link_duplex == ETH_LINK_FULL_DUPLEX ? + "full-duplex" : "half-duplex"); + } else { + PMD_DRV_LOG(INFO, " Port %d: Link Down", + (int)(dev->data->port_id)); + } + + +#ifdef DEBUG +{ + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + + PMD_DRV_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT, + pci_dev->addr.domain, + pci_dev->addr.bus, + pci_dev->addr.devid, + pci_dev->addr.function); +} +#endif + + PMD_DRV_LOG(INFO, "Link speed:%d", link.link_speed); +} + /* * It executes link_update after knowing an interrupt occurred. * diff --git a/drivers/net/atlantic/atl_ethdev.h b/drivers/net/atlantic/atl_ethdev.h index 0018fa898..5b9fc63c6 100644 --- a/drivers/net/atlantic/atl_ethdev.h +++ b/drivers/net/atlantic/atl_ethdev.h @@ -22,9 +22,19 @@ struct atl_adapter { struct aq_hw_s hw; struct aq_hw_cfg_s hw_cfg; + struct atl_interrupt intr; }; #define ATL_DEV_TO_ADAPTER(dev) \ ((struct atl_adapter *)(dev)->data->dev_private) +#define ATL_DEV_PRIVATE_TO_HW(adapter) \ + (&((struct atl_adapter *)adapter)->hw) + +#define ATL_DEV_PRIVATE_TO_INTR(adapter) \ + (&((struct atl_adapter *)adapter)->intr) + +#define ATL_DEV_PRIVATE_TO_CFG(adapter) \ + (&((struct atl_adapter *)adapter)->hw_cfg) + #endif /* _ATLANTIC_ETHDEV_H_ */ -- 2.13.3.windows.1