From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0057.outbound.protection.outlook.com [104.47.32.57]) by dpdk.org (Postfix) with ESMTP id C35A35F2A for ; Thu, 13 Sep 2018 13:35:59 +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=eVvJFjcZ3ePiyWOibEAteGxOYIf8W0iM0o9ToWgIiyM=; b=vbXVXW61dKhnpPkiMuT7DGVfFE5QKPsqSO59JYwulS8NX+J2bf9gc4m809YMZdL+g34JoN6Ha0Qf3nztSRJ31FQntOmUIHeMgP94XXpU6GdqgZ7MKszRUCifHHtHhH26aedZZEnikQAM1r+hSpBFZihRiCL/dlP1eL+Gw6QTiy4= 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:57 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, igor.russkikh@aquantia.com Date: Thu, 13 Sep 2018 14:35:16 +0300 Message-Id: <1536838528-11800-9-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: 07cbcd63-75c6-4135-a724-08d6196d131e 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:Bh5ZQHXaRVtqL5ipVSBeEZRO88WWSzufN240GT96GZcTbILCHepfslJ4L1JpZm+k5WzMvSDxepLwHXuG1P3XH3dKYqbR7kefcAs8JWnDMWDj8hjVghlLszkx++yTWcQz5PMJT1FNGcXMYidf0R0XIeu964k7TJkTMxf3PIK1z22Ks6d2IcjscJh0FRPvT64RaethHAP6s7D2e0SYft3oXBCtBiOTT66CD81wk71uko/AJkcY9U9iWOb5HVafA8bl; 25:9dueC0UmsKLxCIcFq5/Lyw75bR02pxKSN4mLDb6Csq2trq/5b36mOAtxZoegNCxORc8vWiqF3kXLxzjzxUo2H8rAJ3MLI5CTPQQ/Nxcatg1tkF2+7SIpk93/uPvGWuxVzxlIpo9KEBdt29G1ktS7Q+n6ewmzIWISubiKeupAc6K2FtuHkoLOTeRzcVOMWhxLao+N/NM4/6I95prSVmWLCAT1AAmgkUFpT7zhge+HQxyjb86HhX1z3lkSKfRHdYnCpChep7EelF6wUT4MigIosvMtCFr/NTjO8Y2n3/tijf3cuq7BF5qMb19fZpl7gsF/YWSm+9a7GP53C2ulWnFKFA==; 31:3c4UOobC9FjBFYB9ypPnE/sYRNM3KMaE4qEDFxlW+fv4JrEzXM0+5uXifDfLWt7z5UsSKR0fAko/INbpqMbTVhjimM+0G6eDc+gNevjHK/A8sfi8Fb+iWQHJVAG6uT+0Mt9x0X+Nit+eggbjBnwCxANq2slbSpu+eeexrYkI21HyeJJ1JCUyvjY8RvJPnk/SyX04cp5jMZ4UKJOlJvzIPlAnZUlnYG+oU+UkMQN1Sl8= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1650: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 20:l1538d4CNDgPrPtAM82S0VuieyF1MWFlEyGxubamlGYvflRxeK6VPg5tshgU38WikOLn0hZcigjnUU4hVxFU6p/XJN+5mDiY8Pn0LvI0shTBXkY17sYFDk31o7nLEGOhVJV49LKX1WV4R+T6/ePpC6q79S5761clhKXP4rJKki2X9H7OKaOmW0YSG+Ocx2lTVfLtYBzoLVxdJxf2DuX54mWgFV7ckAFjh0nbRWxSmHf3u4ZpoDfej4kLtZ8DQEE0JwAeCNdsaLmIkucCf6uqz53uNUqmTiBv6xJJJ1P5Th0TQD8b/jGZZYU5l6eRKrDUnioS2B8qXY92JHU/WU0I5dCCbl7m7fJ5CFq+r7r//x85ST0X+7FWjFI7+hIQbHc/DkMH3cq7kAOrB6b84ogKx1EkeT85hPRHT7orctCqWIJdWsGHAPDa7SAucI/GXuePiX6OVsYtNgoso+NdySveBVwwShjo2lMu8FRfyFLG1bcczidDGp6hbF9iXFuB8vJA; 4:e/EFv73JmMc9mhx4eoOPpgyMgSI+hq10QtFcbegRcq/0qaqZe0km5q+XfnG/XJmZ9KfzJEuZKWT+oGkwTeH5FWTjriAPKxrEz8T/s/tOkp52s8GY2g0nJ1E4uSHlCYHKElmhsXW0Ghv7LgaqtuUuNGwDSpvGDhGgpSW1dVOdODbIfEc4EFKWFXFot4o8wyzRGJXAlqPnUMPZ+Go1Yt/nwwT7lU1q66jwEPsr17Q0j7Eg5rYc9U9dSr1un8VqfwVrZiElGc3Uj4J1ONdpohYprmMrb01GZfHOWq/KoxtSlENhfElxlB+Ap3aw3WBy/1q7 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)(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:A4GlrduDR+KUxl97Uuwl8TK0WHycKv/ixpzaezf?= =?us-ascii?Q?4lJ9OeaaKXCPC7O3oF5Cd7S7uSYm2SJsqE+a5uthsQQgsYSFhYCoFxYL9Hh6?= =?us-ascii?Q?50FxZzTyvEtAwxJQlvSY50f6gZNTv3XmzcCe8noidC9xP+XGf0cy4fj4Uh5z?= =?us-ascii?Q?iqAex4y2KYyskphlaHUfxXOvhnzdxxn/gcb01c8JlXvDfIyBpuBPPEu58nkT?= =?us-ascii?Q?3OkRshNGMY0j/zdHF469AAj5YSEiMwK94HfeXNsjtTxLsq66ecdOydbBGWzD?= =?us-ascii?Q?N8y/WE20CIyb9A5f+wEtw4YasFUtEayowbt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qI7eKe2cx3ulmJLY2Oc4Zsfk8Zm/vJaEk9rmVx8fAsekaa+O8qhgAwsDyx8fMBx/5ryxUWLHGiVX4PQg8PtQSBIoVQ5sKnph81gw7D61YQ/ckJX6nstBJ13XLeS/0iAQiD4LRoqrpkGGLVqjdA=; 7:JdA+H9UpYfEdIExdNMTPkWf8xo5vomYOZ136TEo7plwy7eCuhOXxZVTGohIB4TGeBXHalJboUlKo0SNcyYzpM/DAXaQu5ljtkqX3CAI8D9xSuGlA50o7rRQbbNp8/HPPn7ip0/cPziybd8IMwzl84ZrWge21Qj5zBWMoSmfYS/ZZhfnRt72TMHJatmD8lshxr+MFMYVicsSDJjnXmqi9R3+tQzYreWkXsZ+T9/niFBwa0u5JVkHwI+0zIQkNdW/4 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2018 11:35:57.3471 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07cbcd63-75c6-4135-a724-08d6196d131e 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 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: Thu, 13 Sep 2018 11:36:00 -0000 From: Pavel Belous Implement link interrupt, link info, link polling Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_ethdev.c | 258 ++++++++++++++++++++++++++++++++++++++ drivers/net/atlantic/atl_ethdev.h | 10 ++ 2 files changed, 268 insertions(+) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 5de295f6f..71f4e8e0a 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) { @@ -385,6 +453,37 @@ 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) @@ -462,6 +561,29 @@ 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 @@ -492,6 +614,142 @@ 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 int)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