From patchwork Tue Jan 24 22:30:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13114820 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8689C54EED for ; Tue, 24 Jan 2023 22:30:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233302AbjAXWa5 (ORCPT ); Tue, 24 Jan 2023 17:30:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233751AbjAXWa4 (ORCPT ); Tue, 24 Jan 2023 17:30:56 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2059.outbound.protection.outlook.com [40.107.92.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4618147EF3 for ; Tue, 24 Jan 2023 14:30:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xw8urix8+6gVSdPWZqIAaEFPOxHUxzXw/AmmuTclcK2d8NhaWdxptk9gTFQD6Psww+BfaqEgEijXTcPx1NpIX3lcRi4BLuQ4eoKP5BpxGJeWCAm/Ku9G3eHmDhH3HMxb3AcKRTsL4yDyOR6efq6Ort5kmXX67FDukIeSMkHg2B90Y7SXvneahWLEfjWlEMNejzmlKWonYPTtrrTRi7jv09U1FYX+vfKfQxotApkbPmhDg7yJLhP867JNkUl2A5n2zjNbt4uB7ah3A+lH8ZjmKs/me8kykmvmMRrZb92v9JE+pXMatMIeM++oPk41FT4iBmFg9EGrDsKIU/rMisF/kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ev/BYxe0mYIWIcl8dWTcGiCoyZUM0AYLbiPwiUXPVnU=; b=fIB1i1vvbZF3wxozJ93PMB7AH6476upW40wMYBmgpf215Gp5tgL4ke70OyJYp+efHVgVHP4uFsOU+TI2bIfEYd/B3hxLeET5+SM7lkD6KOd1doAKsKsB2m1V6Ec8c4FYn/5Kcg7KJCq/fE2urAe1d6ui80cNlLZlkRg37OdV6E4xsRRs23X1xfO3OB/lYbSI7mtMR1NRupeRVVmvLE3WRSglGuLNJlDXHn1VdaZ3tjQunR1zTbQ7KZMV8gCz8FSfwiSPgKwivXkCM58YuI+oWgmoythcWBbXkIsLrr+OUGUKFjPc93YioDc1d0L9tkr8Uq2Sbya5ZZ8m2gJhX8RhIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ev/BYxe0mYIWIcl8dWTcGiCoyZUM0AYLbiPwiUXPVnU=; b=Rwg4wd0Z8I92sEp/LmrO1HmR7LFybRaaSSA0KLYwc19S2t8PAF1Uv7VRx2Nkeua1sBd/X/pJPN9dmJYvMhnkVBz1GHo6jMDfLaEt/G9cPArdHVh+/uOMZn3chfLwvY7Ki5yK+oBdiqoLTZ4RDOQgFWBkVfiGo37LwJMcQywzMo0= Received: from MW4P221CA0006.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::11) by SN7PR12MB7980.namprd12.prod.outlook.com (2603:10b6:806:341::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 22:30:49 +0000 Received: from CO1NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::f6) by MW4P221CA0006.outlook.office365.com (2603:10b6:303:8b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Tue, 24 Jan 2023 22:30:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT015.mail.protection.outlook.com (10.13.175.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.17 via Frontend Transport; Tue, 24 Jan 2023 22:30:49 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 24 Jan 2023 16:30:47 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 24 Jan 2023 16:30:47 -0600 Received: from xcbalucerop41x.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34 via Frontend Transport; Tue, 24 Jan 2023 16:30:46 -0600 From: To: , CC: , , , , , , Alejandro Lucero Subject: [PATCH v2 net-next 1/8] sfc: add devlink support for ef100 Date: Tue, 24 Jan 2023 22:30:22 +0000 Message-ID: <20230124223029.51306-2-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230124223029.51306-1-alejandro.lucero-palau@amd.com> References: <20230124223029.51306-1-alejandro.lucero-palau@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT015:EE_|SN7PR12MB7980:EE_ X-MS-Office365-Filtering-Correlation-Id: e9c88e25-ac55-44e3-5937-08dafe5aa4ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y8pa75PeeaOBwJ9sxDUvJcR/2ue83rmduTKfkBGdr2Jw0CE4HGcTPL50RrGIcIXjDZMpjFT5/xCNpSs6CYCvv/gt7jE3ZioH3Dlk05zNs1wkc1NXwK7FHzjgw6LK1RCXtBu5Di8LuBfQpTVUcRt8M1HB8hmerQQRd0QiO97qyKCdkBZbCa8shKSUuJAaNP1mJuRoiNdOX9/s/s33njxwje7FE9q5cRsccSsqdXQ1JiJqci+UfdI1xwL0yWLBKQTuyv28CGtt52bDsugNm5NG4K9SbkxnjZMTPtaGxXGfYjB7f2M8XrOnQJKSo+iSVe0pPQ7yQiBkpP1qmYbRwxzIPFydgL71h7+jvUg3/aMjOvM8yzComtY1KnvPRZukKJRPhHewn+fPDnolGqOVfLxqqbdN+n9xWWq4aavETBKUjHrIVA6MYKd+zIGnaCqRci2R4AJPo+fNTnLjrd1uf1JfKsOE0jVtbSF71MBuEb5P6SV0rVu8MU8pZEOJlea07YVbmr60wZFEdxH/36UQNL4oXSBRnGyehvN9A2R/1uApgUjPWQh5kdUcZDR5h+DA5ciuiocC14SbFhUL+EUfKJRSAOn23aWa7MbHOcwc1FEB/W7YDvqXvpJ891uBRLFo/rimD1zJr/LGb3QCoMSgFsVBcz3RXKG2O5tsOf+0RfuEkOk9vUiCfsRp2MvfGbBeEfdPNHHyaM6snZSbtdL1HKbEhqUHvLeMNsd3pGIbZhkSFCFdsXUsVTQZN7ZfnN+D62Sr X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(376002)(346002)(136003)(451199018)(36840700001)(46966006)(40470700004)(36860700001)(83380400001)(26005)(2876002)(81166007)(5660300002)(41300700001)(86362001)(356005)(82740400003)(2906002)(4326008)(8936002)(82310400005)(40460700003)(6666004)(40480700001)(316002)(186003)(8676002)(47076005)(54906003)(336012)(426003)(2616005)(478600001)(6636002)(110136005)(36756003)(70586007)(1076003)(70206006)(2004002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 22:30:49.0282 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e9c88e25-ac55-44e3-5937-08dafe5aa4ce X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7980 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Alejandro Lucero Basic devlink infrastructure support. Signed-off-by: Alejandro Lucero --- drivers/net/ethernet/sfc/Kconfig | 1 + drivers/net/ethernet/sfc/Makefile | 3 +- drivers/net/ethernet/sfc/ef100_netdev.c | 12 +++++ drivers/net/ethernet/sfc/ef100_nic.c | 3 +- drivers/net/ethernet/sfc/efx_devlink.c | 71 +++++++++++++++++++++++++ drivers/net/ethernet/sfc/efx_devlink.h | 22 ++++++++ drivers/net/ethernet/sfc/net_driver.h | 2 + 7 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/sfc/efx_devlink.c create mode 100644 drivers/net/ethernet/sfc/efx_devlink.h diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig index 0950e6b0508f..4af36ba8906b 100644 --- a/drivers/net/ethernet/sfc/Kconfig +++ b/drivers/net/ethernet/sfc/Kconfig @@ -22,6 +22,7 @@ config SFC depends on PTP_1588_CLOCK_OPTIONAL select MDIO select CRC32 + select NET_DEVLINK help This driver supports 10/40-gigabit Ethernet cards based on the Solarflare SFC9100-family controllers. diff --git a/drivers/net/ethernet/sfc/Makefile b/drivers/net/ethernet/sfc/Makefile index 712a48d00069..55b9c73cd8ef 100644 --- a/drivers/net/ethernet/sfc/Makefile +++ b/drivers/net/ethernet/sfc/Makefile @@ -6,7 +6,8 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \ mcdi.o mcdi_port.o mcdi_port_common.o \ mcdi_functions.o mcdi_filters.o mcdi_mon.o \ ef100.o ef100_nic.o ef100_netdev.o \ - ef100_ethtool.o ef100_rx.o ef100_tx.o + ef100_ethtool.o ef100_rx.o ef100_tx.o \ + efx_devlink.o sfc-$(CONFIG_SFC_MTD) += mtd.o sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o \ mae.o tc.o tc_bindings.o tc_counters.o diff --git a/drivers/net/ethernet/sfc/ef100_netdev.c b/drivers/net/ethernet/sfc/ef100_netdev.c index ddcc325ed570..b10a226f4a07 100644 --- a/drivers/net/ethernet/sfc/ef100_netdev.c +++ b/drivers/net/ethernet/sfc/ef100_netdev.c @@ -24,6 +24,7 @@ #include "rx_common.h" #include "ef100_sriov.h" #include "tc_bindings.h" +#include "efx_devlink.h" static void ef100_update_name(struct efx_nic *efx) { @@ -332,6 +333,8 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data) efx_ef100_pci_sriov_disable(efx, true); #endif + /* devlink lock */ + efx_fini_devlink_start(efx); ef100_unregister_netdev(efx); #ifdef CONFIG_SFC_SRIOV @@ -345,6 +348,9 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data) kfree(efx->phy_data); efx->phy_data = NULL; + /* devlink unlock */ + efx_fini_devlink(efx); + free_netdev(efx->net_dev); efx->net_dev = NULL; efx->state = STATE_PROBED; @@ -405,6 +411,10 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data) /* Don't fail init if RSS setup doesn't work. */ efx_mcdi_push_default_indir_table(efx, efx->n_rx_channels); + /* devlink creation, registration and lock */ + if (efx_probe_devlink(efx)) + pci_info(efx->pci_dev, "devlink registration failed"); + rc = ef100_register_netdev(efx); if (rc) goto fail; @@ -424,5 +434,7 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data) } fail: + /* devlink unlock */ + efx_probe_devlink_done(efx); return rc; } diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c index ad686c671ab8..e4aacb4ec666 100644 --- a/drivers/net/ethernet/sfc/ef100_nic.c +++ b/drivers/net/ethernet/sfc/ef100_nic.c @@ -1120,11 +1120,10 @@ int ef100_probe_netdev_pf(struct efx_nic *efx) return rc; rc = efx_ef100_get_base_mport(efx); - if (rc) { + if (rc) netif_warn(efx, probe, net_dev, "Failed to probe base mport rc %d; representors will not function\n", rc); - } rc = efx_init_tc(efx); if (rc) { diff --git a/drivers/net/ethernet/sfc/efx_devlink.c b/drivers/net/ethernet/sfc/efx_devlink.c new file mode 100644 index 000000000000..fab06aaa4b8a --- /dev/null +++ b/drivers/net/ethernet/sfc/efx_devlink.c @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0-only +/**************************************************************************** + * Driver for AMD network controllers and boards + * Copyright (C) 2023, Advanced Micro Devices, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, incorporated herein by reference. + */ + +#include +#include "net_driver.h" +#include "ef100_nic.h" +#include "efx_devlink.h" +#include "nic.h" +#include "mcdi.h" +#include "mcdi_functions.h" +#include "mcdi_pcol.h" + +struct efx_devlink { + struct efx_nic *efx; +}; + +static const struct devlink_ops sfc_devlink_ops = { +}; + +void efx_fini_devlink_start(struct efx_nic *efx) +{ + if (efx->devlink) + devl_lock(efx->devlink); +} + +void efx_fini_devlink(struct efx_nic *efx) +{ + if (efx->devlink) { + devl_unregister(efx->devlink); + devl_unlock(efx->devlink); + devlink_free(efx->devlink); + efx->devlink = NULL; + } +} + +int efx_probe_devlink(struct efx_nic *efx) +{ + struct efx_devlink *devlink_private; + + if (efx->type->is_vf) + return 0; + + efx->devlink = devlink_alloc(&sfc_devlink_ops, + sizeof(struct efx_devlink), + &efx->pci_dev->dev); + if (!efx->devlink) + return -ENOMEM; + + devl_lock(efx->devlink); + devlink_private = devlink_priv(efx->devlink); + devlink_private->efx = efx; + + devl_register(efx->devlink); + + return 0; +} + +void efx_probe_devlink_done(struct efx_nic *efx) +{ + if (!efx->devlink) + return; + + devl_unlock(efx->devlink); +} diff --git a/drivers/net/ethernet/sfc/efx_devlink.h b/drivers/net/ethernet/sfc/efx_devlink.h new file mode 100644 index 000000000000..55d0d8aeca1e --- /dev/null +++ b/drivers/net/ethernet/sfc/efx_devlink.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/**************************************************************************** + * Driver for AMD network controllers and boards + * Copyright (C) 2023, Advanced Micro Devices, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, incorporated herein by reference. + */ + +#ifndef _EFX_DEVLINK_H +#define _EFX_DEVLINK_H + +#include "net_driver.h" +#include + +int efx_probe_devlink(struct efx_nic *efx); +void efx_probe_devlink_done(struct efx_nic *efx); +void efx_fini_devlink_start(struct efx_nic *efx); +void efx_fini_devlink(struct efx_nic *efx); + +#endif /* _EFX_DEVLINK_H */ diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 3b49e216768b..d036641dc043 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -994,6 +994,7 @@ enum efx_xdp_tx_queues_mode { * xdp_rxq_info structures? * @netdev_notifier: Netdevice notifier. * @tc: state for TC offload (EF100). + * @devlink: reference to devlink structure owned by this device * @mem_bar: The BAR that is mapped into membase. * @reg_base: Offset from the start of the bar to the function control window. * @monitor_work: Hardware monitor workitem @@ -1179,6 +1180,7 @@ struct efx_nic { struct notifier_block netdev_notifier; struct efx_tc_state *tc; + struct devlink *devlink; unsigned int mem_bar; u32 reg_base;