From patchwork Wed Feb 15 09:08:26 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: 13141462 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 4DD34C64EC7 for ; Wed, 15 Feb 2023 09:09:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233637AbjBOJJ2 (ORCPT ); Wed, 15 Feb 2023 04:09:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233644AbjBOJJZ (ORCPT ); Wed, 15 Feb 2023 04:09:25 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2052.outbound.protection.outlook.com [40.107.237.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8027D367C9; Wed, 15 Feb 2023 01:09:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oeEZeagMJG4Hd7ALfuwk5y5QdEFqcbphDDLHXJ1rTujVKa+dAcAHlY500dzoT3+Bi9sjjXNW6ewnufeJ68VsVW6n4IgDFgrF1dxrIQ9OtDFeLeQ9xJp0bOCpbub/MVPlJmmkxetkM+L8dr+vhC1HxOtxSLPOBS0krgOXcEeNgBATCBgAJ+bKNhhZyQWvI3ER+fRsuC7HeFBT+Agh8LRlheZXc8QG3Qu9ufgni329I9zpesuvN8gjVeoOuQsV+uY4g8puvEfIlWSqfTJQKxITKo/5NSmG3DW676tq8kH46E3xR8NlGnE+AMxZNt/CCz8tHRltoOuPqjx5qKpD9XDDxg== 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=Ctdc6qyStytXEYamuhZtEVEBWQrivfURIzKu8q6KOYU=; b=LysjV/rrqXew5yJM9LVRW6+4p5iRu5m7rb1sFwPQ8DW5ZdMM/dKvw5zd2Pbq7EYijUPfcXq1ZqCS9Rfc4pack/+goqe+ZG2ivPW1RqMJF+FZBGiHTLrMWDsv2wciYRIOZq78B8AboLjUiyL2lAbuPH88IrKs/gjEXLD/4vsKo8GuCYUXXZkooFzVFZkBuOSBdCuhpWw5/nhIZuA5cJrm3hCendi90dPsrYNTDDvx1YV+XE7aVOUL+UzFsccVufsVAmoyNMdxhxXkx/umq4brBDfnhskInZ0vpVvJ5GibXlCZpKJ+R7w6sTFQikL16L/SLZIx7lpjEMcBwE0Fjo3NHQ== 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=Ctdc6qyStytXEYamuhZtEVEBWQrivfURIzKu8q6KOYU=; b=3+J3x1lmBff+UILx9f68N904ExOCOfVpNbl3rUtY3LxScMtk06Tdtll5ViQ8WhHFXPv27xdFi2ps3M3pnJlIq4uJjxhIW0GNupjfIA7u3J5AynOqoQaOOuvAiv2Mg+kVcxhqlN2SN3ue0MxCgxf1PBOCoKh+ndfcnocS8pTn+O8= Received: from DM6PR14CA0069.namprd14.prod.outlook.com (2603:10b6:5:18f::46) by SJ0PR12MB7473.namprd12.prod.outlook.com (2603:10b6:a03:48d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Wed, 15 Feb 2023 09:09:21 +0000 Received: from DM6NAM11FT089.eop-nam11.prod.protection.outlook.com (2603:10b6:5:18f:cafe::93) by DM6PR14CA0069.outlook.office365.com (2603:10b6:5:18f::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26 via Frontend Transport; Wed, 15 Feb 2023 09:09:21 +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 DM6NAM11FT089.mail.protection.outlook.com (10.13.173.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6111.12 via Frontend Transport; Wed, 15 Feb 2023 09:09:20 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Wed, 15 Feb 2023 03:09:13 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 15 Feb 2023 01:09:00 -0800 Received: from xcbalucerop41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34 via Frontend Transport; Wed, 15 Feb 2023 03:08:59 -0600 From: To: , CC: , , , , , , , , , "Alejandro Lucero" Subject: [PATCH v8 net-next 6/8] sfc: obtain device mac address based on firmware handle for ef100 Date: Wed, 15 Feb 2023 09:08:26 +0000 Message-ID: <20230215090828.11697-7-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230215090828.11697-1-alejandro.lucero-palau@amd.com> References: <20230215090828.11697-1-alejandro.lucero-palau@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT089:EE_|SJ0PR12MB7473:EE_ X-MS-Office365-Filtering-Correlation-Id: db9b2934-1963-4ec6-0598-08db0f345311 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bsAyOdM91vVioRekVCKBw2oMe3/TYHFq+f1IU73btMn7EQz+beLuiIkVajkN6GazCvmndMTHw0ZYzUyMxM8QJwY0miAqCn3MxsicT94VmzLwJveZYg3AwFr+LJSennyieYZH+hhv9fL6X9ZfD2NelI3hJM6AubW2J+1H7kJaSyFs0nDtzmLZFxkPr1UBSfefgZ4RbivKkHULsP50IvwnSYmAooW4ilkdA5Jp2PoiLgkVZAlhoyJjiPUm5CpubA0QiNXr6u3JNZXorr5nJ/mgITqo6WNJj+X/dH15fqkVhQynOZ+rtafqOyCMIhsUSOzfzxPvBaWkG6nIr52cyAJgBh+E0i7Nz5kkPwufv5Fsz51f5Bk9riKs3WToTkoxQxN9gZekFjnNAYcvoTqbHgZvQhdT0M3Wnkm5cn/3oyXGvkRexdQMBlWkrO5hmqgX9Iz08ucXmh9SF7so7x1eEWr+9kVh5OnaMmtoNMr113VMyPtwl6C63NlKf1G+AmCZCimubRnQwz/GQYh7PoS4bxjvGSqm0sFxtgoawxEbfTHcI5vg7DG8ee+GzTj5icMNvC2rZsvPCaaBUIqpTVLsnoWNvTbkkJNbauu6FM6VkN11M6V1O4LnnFcUkSBZAqu8+xvlW5PizgDpkw8e4c9PSN7Fqbh4j+gRVnSPPTsNUmcdC0ju6qIBYlGCfhMHaKXGQmFfwjNH+RVn1TZL8mVMa7I2R0kU5kM1OsSeY5m8wm4EJA8= 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)(376002)(136003)(396003)(346002)(39860400002)(451199018)(46966006)(36840700001)(40470700004)(110136005)(6636002)(54906003)(83380400001)(426003)(478600001)(336012)(2616005)(47076005)(1076003)(6666004)(36756003)(186003)(26005)(356005)(41300700001)(5660300002)(7416002)(86362001)(8936002)(40460700003)(40480700001)(316002)(81166007)(2906002)(70206006)(70586007)(82310400005)(82740400003)(4326008)(8676002)(36860700001)(2876002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2023 09:09:20.8616 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db9b2934-1963-4ec6-0598-08db0f345311 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: DM6NAM11FT089.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7473 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Alejandro Lucero Getting device mac address is currently based on a specific MCDI command only available for the PF. This patch changes the MCDI command to a generic one for PFs and VFs based on a client handle. This allows both PFs and VFs to ask for their mac address during initialization using the CLIENT_HANDLE_SELF. Moreover, the patch allows other client handles which will be used by the PF to ask for mac addresses linked to VFs. This is necessary for suporting the port_function_hw_addr_get devlink function in further patches. Signed-off-by: Alejandro Lucero Acked-by: Martin Habets --- drivers/net/ethernet/sfc/ef100_netdev.c | 10 +++++++ drivers/net/ethernet/sfc/ef100_nic.c | 37 +++++++++++++------------ drivers/net/ethernet/sfc/ef100_nic.h | 2 ++ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef100_netdev.c b/drivers/net/ethernet/sfc/ef100_netdev.c index 368147359299..d916877b5a9a 100644 --- a/drivers/net/ethernet/sfc/ef100_netdev.c +++ b/drivers/net/ethernet/sfc/ef100_netdev.c @@ -359,6 +359,7 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data) { struct efx_nic *efx = &probe_data->efx; struct efx_probe_data **probe_ptr; + struct ef100_nic_data *nic_data; struct net_device *net_dev; int rc; @@ -410,6 +411,15 @@ 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); + nic_data = efx->nic_data; + rc = ef100_get_mac_address(efx, net_dev->perm_addr, CLIENT_HANDLE_SELF, + efx->type->is_vf); + if (rc) + return rc; + /* Assign MAC address */ + eth_hw_addr_set(net_dev, net_dev->perm_addr); + ether_addr_copy(nic_data->port_id, net_dev->perm_addr); + /* devlink creation, registration and lock */ rc = efx_probe_devlink_and_lock(efx); if (rc) diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c index aa11f0925e27..aa48c79a2149 100644 --- a/drivers/net/ethernet/sfc/ef100_nic.c +++ b/drivers/net/ethernet/sfc/ef100_nic.c @@ -130,23 +130,34 @@ static void ef100_mcdi_reboot_detected(struct efx_nic *efx) /* MCDI calls */ -static int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address) +int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address, + int client_handle, bool empty_ok) { - MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_MAC_ADDRESSES_OUT_LEN); + MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CLIENT_MAC_ADDRESSES_OUT_LEN(1)); + MCDI_DECLARE_BUF(inbuf, MC_CMD_GET_CLIENT_MAC_ADDRESSES_IN_LEN); size_t outlen; int rc; BUILD_BUG_ON(MC_CMD_GET_MAC_ADDRESSES_IN_LEN != 0); + MCDI_SET_DWORD(inbuf, GET_CLIENT_MAC_ADDRESSES_IN_CLIENT_HANDLE, + client_handle); - rc = efx_mcdi_rpc(efx, MC_CMD_GET_MAC_ADDRESSES, NULL, 0, - outbuf, sizeof(outbuf), &outlen); + rc = efx_mcdi_rpc(efx, MC_CMD_GET_CLIENT_MAC_ADDRESSES, inbuf, + sizeof(inbuf), outbuf, sizeof(outbuf), &outlen); if (rc) return rc; - if (outlen < MC_CMD_GET_MAC_ADDRESSES_OUT_LEN) - return -EIO; - ether_addr_copy(mac_address, - MCDI_PTR(outbuf, GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE)); + if (outlen >= MC_CMD_GET_CLIENT_MAC_ADDRESSES_OUT_LEN(1)) { + ether_addr_copy(mac_address, + MCDI_PTR(outbuf, GET_CLIENT_MAC_ADDRESSES_OUT_MAC_ADDRS)); + } else if (empty_ok) { + pci_warn(efx->pci_dev, + "No MAC address provisioned for client ID %#x.\n", + client_handle); + eth_zero_addr(mac_address); + } else { + return -ENOENT; + } return 0; } @@ -1117,13 +1128,6 @@ int ef100_probe_netdev_pf(struct efx_nic *efx) struct net_device *net_dev = efx->net_dev; int rc; - rc = ef100_get_mac_address(efx, net_dev->perm_addr); - if (rc) - goto fail; - /* Assign MAC address */ - eth_hw_addr_set(net_dev, net_dev->perm_addr); - memcpy(nic_data->port_id, net_dev->perm_addr, ETH_ALEN); - if (!nic_data->grp_mae) return 0; @@ -1163,9 +1167,6 @@ int ef100_probe_netdev_pf(struct efx_nic *efx) efx->fixed_features |= NETIF_F_HW_TC; } #endif - return 0; - -fail: return rc; } diff --git a/drivers/net/ethernet/sfc/ef100_nic.h b/drivers/net/ethernet/sfc/ef100_nic.h index 496aea43c60f..e59044072333 100644 --- a/drivers/net/ethernet/sfc/ef100_nic.h +++ b/drivers/net/ethernet/sfc/ef100_nic.h @@ -92,4 +92,6 @@ int efx_ef100_init_datapath_caps(struct efx_nic *efx); int ef100_phy_probe(struct efx_nic *efx); int ef100_filter_table_probe(struct efx_nic *efx); +int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address, + int client_handle, bool empty_ok); #endif /* EFX_EF100_NIC_H */