From patchwork Tue Jan 24 22:30:27 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: 13114824 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 58421C54E94 for ; Tue, 24 Jan 2023 22:31:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233778AbjAXWbQ (ORCPT ); Tue, 24 Jan 2023 17:31:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234343AbjAXWbM (ORCPT ); Tue, 24 Jan 2023 17:31:12 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2088.outbound.protection.outlook.com [40.107.243.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B2BD47EF3 for ; Tue, 24 Jan 2023 14:31:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DDAgvEWmvzPsrLiSCjZQLmzQ20zG2xf3P0ZKWc0lEaOd5fr1zidbALUGc0UWoTkccKH5j48N3wyN2vcWb3UV7quHWfhcu56a7o6PN4hE+dOzpcnj8NWp/TSP8Z5pD48vNpd12YGpQW3onTdjZO0q9+sEmIaeqTDxO4Mni9SFp3Ba5Xu8OYJ3hLAaKqeepe0NnxJPVCkcKJ3HZn/JLWIxE0U6FN7owknXjqgM4kPWv3wgVRWdRC5vnhRovBk1qdVbAv72E08k4VEn7Ton6Ho/fnEVABkEcMSry9RzJpTn6ByKeZoTvj+5IfDLvcJKWgWFKZ9lcqziA5LbqkWaO/xHYQ== 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=qDMhZFOyzmtTJTTvWlpKjfCTaQ3KE0ptNvOmsmEV0Hk=; b=ZRIU9Fps95wTGHh4WkKL94VdWF1VXnNetm73P7yY3YIHGC49EJMQOEdGQOWWdxvo1U/9qaBTbVkKTOWbYttww4AVvR38IjtoAmyG2VD2StUEq8NMoU80fn61Fgqp9mPjqBuGom+i0bzxRnXK8D4lRsvZeaw/IysHCKr0D+uDSYFTvf5+cN42be+qjAIiZKxQDWzrQE8ss5iYe7N8I05XUTu3/6QRAJLzUZljsqaubFizObTqOAZMZKQ1yhNwi2mqKJaTHoU4V+DILU5kOseNTHwYDQ1B4T7MoEhAHlbwlLOGKmOhVEgLzSdk2/nokDHRMJVn7V8zsJTitepEwBHUiQ== 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=qDMhZFOyzmtTJTTvWlpKjfCTaQ3KE0ptNvOmsmEV0Hk=; b=i5/ihTsPqKPq1GmohX4PneiR58ZZuI0uwm1DATDdJ06cCTdOZNhhuPJgxCGXt69WrSVatol9l3dTcoftzs6s2ytcCd2t8YlWOqjxcFnN2B+wKT6wg3rYQd0KGlQcsLHk5USBUuqPNfAHH1AWkEb6lkO9S+up6QaLo8RgtKGbtBI= Received: from BN0PR10CA0029.namprd10.prod.outlook.com (2603:10b6:408:143::7) by DS0PR12MB8456.namprd12.prod.outlook.com (2603:10b6:8:161::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.27; Tue, 24 Jan 2023 22:31:00 +0000 Received: from BN8NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:408:143:cafe::66) by BN0PR10CA0029.outlook.office365.com (2603:10b6:408:143::7) 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:59 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT014.mail.protection.outlook.com (10.13.177.142) 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:59 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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; Tue, 24 Jan 2023 16:30:59 -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:58 -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:57 -0600 From: To: , CC: , , , , , , Alejandro Lucero Subject: [PATCH v2 net-next 6/8] sfc: obtain device mac address based on firmware handle for ef100 Date: Tue, 24 Jan 2023 22:30:27 +0000 Message-ID: <20230124223029.51306-7-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: BN8NAM11FT014:EE_|DS0PR12MB8456:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e1e2897-c9f1-48c8-95b5-08dafe5aaafe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v2lBc4TN98vmJWYLnd8/r3PSA1IyuZ2kGHvlolltPSy7cq/dRu6IoOZsrQiSO9I+b1jMf9GFBIBpL4YD4U9Kt88AfGOoDaw9DTXQMLDTVGiYj0kliQy7EEz57GyC6+5KjbpLMKzxzjHCId9rrhVGQMdRs9U1tlxL5HJoFuOueufJVRzyN04a6WEbpFlaf9Kmxqw77SW5FLe9YIazDydzEF1AeP8tUS7jQHYcLQgumS51hVQ82ReuiPy76BKG4tzhhR7c3ksDEFNX/dYW4KTxImuugiBKpewm5PWfFwk8ueaISb31sQmM67xgAKCz4LnaAF5evWmKg7/ZFxNsHtOgqW87zzDMV4lGIQBJt/m1oX5XqHwDOams4vwn4TTepF1Q3FV+0vlpAHJLTb4MjkmKUHwX+nKhOzBPRKXvpy4NoC5ym4LM84WOGXVIt+VT95s0pAHhQ5+7VvYIxllcAd2OUIjhUIXjHJwYy1uf+nJwQuZKARQYmrTw6dDqo/4OaBs1+IeGY4n9ga+KenePCW70kpf2afV+C0cbeRMzumMXqNTt7QGLRN7+H4bIWdBk9NifVIaoZ4VbQgH61ACPOyHVbH1jqJ/RAuNliUPxwIQAfvFSREEYgT+1x2fXnZ9mzrsvOnF4s9zoxPH9YkAmD545z2J80bjHPHa4ckuNE6/X4s/SiO6PHZf1IujM5e94KtHIqRsXlM0xYGA8SF8xq/bbU1yXRwFI2wXirTQSeEedCSo= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(396003)(346002)(376002)(136003)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(26005)(82310400005)(186003)(86362001)(478600001)(41300700001)(426003)(40460700003)(336012)(70586007)(82740400003)(70206006)(4326008)(8676002)(47076005)(8936002)(2876002)(5660300002)(36756003)(356005)(36860700001)(40480700001)(6666004)(1076003)(2906002)(81166007)(2616005)(6636002)(316002)(54906003)(110136005)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 22:30:59.5200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e1e2897-c9f1-48c8-95b5-08dafe5aaafe 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8456 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 --- 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 36774b55d413..d591ad150972 100644 --- a/drivers/net/ethernet/sfc/ef100_netdev.c +++ b/drivers/net/ethernet/sfc/ef100_netdev.c @@ -362,6 +362,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; @@ -413,6 +414,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 */ if (efx_probe_devlink(efx)) pci_info(efx->pci_dev, "devlink registration failed"); diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c index 04774f33b493..bcf937fb3d95 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; } @@ -1116,13 +1127,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; @@ -1161,9 +1165,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 */