From patchwork Wed Jul 20 18:29:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12924374 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 5FD82C43334 for ; Wed, 20 Jul 2022 18:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230343AbiGTSag (ORCPT ); Wed, 20 Jul 2022 14:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231618AbiGTSaf (ORCPT ); Wed, 20 Jul 2022 14:30:35 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2081.outbound.protection.outlook.com [40.107.243.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42D496FA02 for ; Wed, 20 Jul 2022 11:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h/8VtAq/6weDDwWQaQUt1WLCZ0tnc+mlIdRtYpAKFRVWg8Nw2ql6pvsuar20JTss/zSmgKa5xvI5to/DEveDE8JuhR7YfLHeYePyW5kKGMuDfQ26CP3y40XIbOV+XZTOoMITcP+Pgw8v62NQeaqsn1F4KwD5TWnmXKDfJrlaynOTmEGlNJvViO89J7+Pkk2zYmP+N3HlzdNGwTRodbBSxiLykAGrcXWZuTge97KRTpyfwCC6TPSHuUfYtG2tG1POURgDPjxPOQNXsBHB1IcbI6IBx+5Bauby51STAq27rMO9dh0bcgGeaU92tRfrQF+kxkcrqZNY/okgW3FjMx//DA== 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=Dy+zoS7b7v8jAwNPs8NVJkMgVn/vOfQYzCfg04e//lw=; b=JUW9v53WL4evlxLgnPS7tVIs1yCtCOvWnQJbMUf1l0K0bZoNKpxSkGzw712/1G7977VqnhstCbh6bq6Z8V8TU4HwqTicaY2d92l9pMM7rxjYyncbecD8HjgqPK6WHBzAa3pfYSYusIHubbKvUKgLx6q82KpsdD3YsWnXAod0GyDEYY/WygHGpELVZ3bXZUtvf/rTQWazft3+pokbqn93XZkH4jdWXdBB7LmBfJv2rJCPVU0V5QVZFbZwwmofciqgLrq8RJTa7hwcCUaI0CkCGXx4l3IN5fIYy+ctCXtuXNum8jllFYG/iKdUT6tQ8jQ0+bxRP5QjD/xvxIe/fo6Kpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dy+zoS7b7v8jAwNPs8NVJkMgVn/vOfQYzCfg04e//lw=; b=B5KGXNsYeh5NNgiSeH6cevhgkfozNpwFzEQ+mYrOSrqPCi2uIjuLJdWyJqsw9ZQCMRqzzuwspQePyGYA/h8VAo0wHMfOU5BfIY5S86POIZjaptx60wQ/UsLJlXUKw+G8shZLku7W8Hnq1QJqVy1ZZdCK1jiF1C+LKig3km6J/jplj43ZxHeNQ6bp5yhtMxUZBBOU5NTJcWkz4IfwB18lOWtZd5mg7Wro0HPSt4Wsl9mYdpf7sq5GUpENhSeGePEMBAySrK5+mCVEDaPoOmcB2FdN5RK2pfnSvPlSz9KarfkilAV9Jq7bsY3HpKe9Pp/WMsyDVw/RpKOFX1GzqVhM0A== Received: from MW4PR04CA0241.namprd04.prod.outlook.com (2603:10b6:303:88::6) by BL3PR12MB6380.namprd12.prod.outlook.com (2603:10b6:208:3b3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Wed, 20 Jul 2022 18:30:32 +0000 Received: from CO1NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:303:88:cafe::d1) by MW4PR04CA0241.outlook.office365.com (2603:10b6:303:88::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.24 via Frontend Transport; Wed, 20 Jul 2022 18:30:31 +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=fail action=none header.from=xilinx.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 CO1NAM11FT028.mail.protection.outlook.com (10.13.175.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5458.17 via Frontend Transport; Wed, 20 Jul 2022 18:30:31 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.28; Wed, 20 Jul 2022 13:30:30 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 20 Jul 2022 13:30:30 -0500 Received: from xcbecree41x.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.28 via Frontend Transport; Wed, 20 Jul 2022 13:30:29 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH v3 net-next 1/9] sfc: update EF100 register descriptions Date: Wed, 20 Jul 2022 19:29:24 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75a6bc62-8f40-404c-7997-08da6a7dedac X-MS-TrafficTypeDiagnostic: BL3PR12MB6380:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 94a7IGuX92bqTr5vp8gkNLn0/ZQjwwSE/qRGTAS+cZb1rcqdR5p55ibEzCSMnf03JZ8ALc83cND4BNrKM2G/gFfqQGqU/ApzCuS2m4mS4e0sfOvxYZ4NAtqZv7+RA02rPzsQTs7BUAGXBoJY/tDfL8hXoQSn0vWawCYg05JjyIna/zByd3VXRBfhHH+OWMJSKGJHbRvRBT58Eh2a26rd6QBgFpM/zSjsCZfFTYCAjlfqbHgXSNwLdbFuAcGTZ7FBUm3FshNML9AWI8WA5IhoTAkNhVgUq4XqK0VRMIofxGHsLQtN7sPv4bHQbhtseqlyBGxHGZvv4cvydK27eYJ8g7hF/FR3ksbYBZ06gj1AMLxStYV+If+Ic1+GXgDfsBNCfl0nEwRL2db9DMFdr+bkPgotiFBJuQgK4CZOo5vKg/a8Lo9vsyr7vUcA4r5DQYF5a+F0xDLUfjFnSM7NTwXjHqfTLlkyHH1AU2RX+lZHchW0tVUBFV6OFL5mNIrEH61ZX0/Xng5rE3EO2cFNxeBpK0FzDfisAuEr734+jUHwmvFnbB7beqxAZTCsMcb6IN+1IfIIzwzSA5wsqsg66d1mXH1WyJ1BqLYJFxyc2dSrrVrX74ti2+cmPxhlKXECEKrpVNy3pusMEtC/+jSPt8RKN4/ODbuTUannvByRmUn4jexmyOqAljysiClQu7XL3pPAhUyfZexnDLCAZ/SC0NlaCdH5LzPIcwyxeju4YAMyd7N1lBYlzbmQTFpKwIbPrHt8Gxv12jn2hMMrbVOUz51uCFK7hFf+n03gBpvHuHDLgGHosIBXRs5bv1Tp1zHuF00UMfngtwEE2p9JNajcXTMfGiiEec0U45jIUhRaFajoyzQ= 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:(13230016)(4636009)(346002)(396003)(39860400002)(136003)(376002)(46966006)(40470700004)(36840700001)(6666004)(8936002)(41300700001)(5660300002)(82740400003)(356005)(478600001)(81166007)(9686003)(8676002)(83170400001)(42882007)(336012)(70206006)(47076005)(83380400001)(54906003)(110136005)(40460700003)(70586007)(36860700001)(26005)(316002)(186003)(4326008)(2906002)(55446002)(36756003)(2876002)(40480700001)(82310400005)(2004002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 18:30:31.5431 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75a6bc62-8f40-404c-7997-08da6a7dedac 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: CO1NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6380 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_regs.h | 83 +++++++++++++++++++-------- 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef100_regs.h b/drivers/net/ethernet/sfc/ef100_regs.h index 710bbdb19885..982b6ab1eb62 100644 --- a/drivers/net/ethernet/sfc/ef100_regs.h +++ b/drivers/net/ethernet/sfc/ef100_regs.h @@ -2,7 +2,7 @@ /**************************************************************************** * Driver for Solarflare network controllers and boards * Copyright 2018 Solarflare Communications Inc. - * Copyright 2019-2020 Xilinx Inc. + * Copyright 2019-2022 Xilinx 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 @@ -181,12 +181,6 @@ /* RHEAD_BASE_EVENT */ #define ESF_GZ_E_TYPE_LBN 60 #define ESF_GZ_E_TYPE_WIDTH 4 -#define ESE_GZ_EF100_EV_DRIVER 5 -#define ESE_GZ_EF100_EV_MCDI 4 -#define ESE_GZ_EF100_EV_CONTROL 3 -#define ESE_GZ_EF100_EV_TX_TIMESTAMP 2 -#define ESE_GZ_EF100_EV_TX_COMPLETION 1 -#define ESE_GZ_EF100_EV_RX_PKTS 0 #define ESF_GZ_EV_EVQ_PHASE_LBN 59 #define ESF_GZ_EV_EVQ_PHASE_WIDTH 1 #define ESE_GZ_RHEAD_BASE_EVENT_STRUCT_SIZE 64 @@ -369,14 +363,18 @@ #define ESF_GZ_RX_PREFIX_VLAN_STRIP_TCI_WIDTH 16 #define ESF_GZ_RX_PREFIX_CSUM_FRAME_LBN 144 #define ESF_GZ_RX_PREFIX_CSUM_FRAME_WIDTH 16 -#define ESF_GZ_RX_PREFIX_INGRESS_VPORT_LBN 128 -#define ESF_GZ_RX_PREFIX_INGRESS_VPORT_WIDTH 16 +#define ESF_GZ_RX_PREFIX_INGRESS_MPORT_LBN 128 +#define ESF_GZ_RX_PREFIX_INGRESS_MPORT_WIDTH 16 #define ESF_GZ_RX_PREFIX_USER_MARK_LBN 96 #define ESF_GZ_RX_PREFIX_USER_MARK_WIDTH 32 #define ESF_GZ_RX_PREFIX_RSS_HASH_LBN 64 #define ESF_GZ_RX_PREFIX_RSS_HASH_WIDTH 32 -#define ESF_GZ_RX_PREFIX_PARTIAL_TSTAMP_LBN 32 -#define ESF_GZ_RX_PREFIX_PARTIAL_TSTAMP_WIDTH 32 +#define ESF_GZ_RX_PREFIX_PARTIAL_TSTAMP_LBN 34 +#define ESF_GZ_RX_PREFIX_PARTIAL_TSTAMP_WIDTH 30 +#define ESF_GZ_RX_PREFIX_VSWITCH_STATUS_LBN 33 +#define ESF_GZ_RX_PREFIX_VSWITCH_STATUS_WIDTH 1 +#define ESF_GZ_RX_PREFIX_VLAN_STRIPPED_LBN 32 +#define ESF_GZ_RX_PREFIX_VLAN_STRIPPED_WIDTH 1 #define ESF_GZ_RX_PREFIX_CLASS_LBN 16 #define ESF_GZ_RX_PREFIX_CLASS_WIDTH 16 #define ESF_GZ_RX_PREFIX_USER_FLAG_LBN 15 @@ -454,12 +452,8 @@ #define ESF_GZ_M2M_TRANSLATE_ADDR_WIDTH 1 #define ESF_GZ_M2M_RSVD_LBN 120 #define ESF_GZ_M2M_RSVD_WIDTH 2 -#define ESF_GZ_M2M_ADDR_SPC_LBN 108 -#define ESF_GZ_M2M_ADDR_SPC_WIDTH 12 -#define ESF_GZ_M2M_ADDR_SPC_PASID_LBN 86 -#define ESF_GZ_M2M_ADDR_SPC_PASID_WIDTH 22 -#define ESF_GZ_M2M_ADDR_SPC_MODE_LBN 84 -#define ESF_GZ_M2M_ADDR_SPC_MODE_WIDTH 2 +#define ESF_GZ_M2M_ADDR_SPC_ID_LBN 84 +#define ESF_GZ_M2M_ADDR_SPC_ID_WIDTH 36 #define ESF_GZ_M2M_LEN_MINUS_1_LBN 64 #define ESF_GZ_M2M_LEN_MINUS_1_WIDTH 20 #define ESF_GZ_M2M_ADDR_LBN 0 @@ -492,12 +486,8 @@ #define ESF_GZ_TX_SEG_TRANSLATE_ADDR_WIDTH 1 #define ESF_GZ_TX_SEG_RSVD2_LBN 120 #define ESF_GZ_TX_SEG_RSVD2_WIDTH 2 -#define ESF_GZ_TX_SEG_ADDR_SPC_LBN 108 -#define ESF_GZ_TX_SEG_ADDR_SPC_WIDTH 12 -#define ESF_GZ_TX_SEG_ADDR_SPC_PASID_LBN 86 -#define ESF_GZ_TX_SEG_ADDR_SPC_PASID_WIDTH 22 -#define ESF_GZ_TX_SEG_ADDR_SPC_MODE_LBN 84 -#define ESF_GZ_TX_SEG_ADDR_SPC_MODE_WIDTH 2 +#define ESF_GZ_TX_SEG_ADDR_SPC_ID_LBN 84 +#define ESF_GZ_TX_SEG_ADDR_SPC_ID_WIDTH 36 #define ESF_GZ_TX_SEG_RSVD_LBN 80 #define ESF_GZ_TX_SEG_RSVD_WIDTH 4 #define ESF_GZ_TX_SEG_LEN_LBN 64 @@ -583,6 +573,12 @@ #define ESE_GZ_SF_TX_TSO_DSC_FMT_STRUCT_SIZE 124 +/* Enum D2VIO_MSG_OP */ +#define ESE_GZ_QUE_JBDNE 3 +#define ESE_GZ_QUE_EVICT 2 +#define ESE_GZ_QUE_EMPTY 1 +#define ESE_GZ_NOP 0 + /* Enum DESIGN_PARAMS */ #define ESE_EF100_DP_GZ_RX_MAX_RUNT 17 #define ESE_EF100_DP_GZ_VI_STRIDES 16 @@ -630,6 +626,19 @@ #define ESE_GZ_PCI_BASE_CONFIG_SPACE_SIZE 256 #define ESE_GZ_PCI_EXPRESS_XCAP_HDR_SIZE 4 +/* Enum RH_DSC_TYPE */ +#define ESE_GZ_TX_TOMB 0xF +#define ESE_GZ_TX_VIO 0xE +#define ESE_GZ_TX_TSO_OVRRD 0x8 +#define ESE_GZ_TX_D2CMP 0x7 +#define ESE_GZ_TX_DATA 0x6 +#define ESE_GZ_TX_D2M 0x5 +#define ESE_GZ_TX_M2M 0x4 +#define ESE_GZ_TX_SEG 0x3 +#define ESE_GZ_TX_TSO 0x2 +#define ESE_GZ_TX_OVRRD 0x1 +#define ESE_GZ_TX_SEND 0x0 + /* Enum RH_HCLASS_L2_CLASS */ #define ESE_GZ_RH_HCLASS_L2_CLASS_E2_0123VLAN 1 #define ESE_GZ_RH_HCLASS_L2_CLASS_OTHER 0 @@ -666,6 +675,25 @@ #define ESE_GZ_RH_HCLASS_TUNNEL_CLASS_VXLAN 1 #define ESE_GZ_RH_HCLASS_TUNNEL_CLASS_NONE 0 +/* Enum SF_CTL_EVENT_SUBTYPE */ +#define ESE_GZ_EF100_CTL_EV_EVQ_TIMEOUT 0x3 +#define ESE_GZ_EF100_CTL_EV_FLUSH 0x2 +#define ESE_GZ_EF100_CTL_EV_TIME_SYNC 0x1 +#define ESE_GZ_EF100_CTL_EV_UNSOL_OVERFLOW 0x0 + +/* Enum SF_EVENT_TYPE */ +#define ESE_GZ_EF100_EV_DRIVER 0x5 +#define ESE_GZ_EF100_EV_MCDI 0x4 +#define ESE_GZ_EF100_EV_CONTROL 0x3 +#define ESE_GZ_EF100_EV_TX_TIMESTAMP 0x2 +#define ESE_GZ_EF100_EV_TX_COMPLETION 0x1 +#define ESE_GZ_EF100_EV_RX_PKTS 0x0 + +/* Enum SF_EW_EVENT_TYPE */ +#define ESE_GZ_EF100_EWEV_VIRTQ_DESC 0x2 +#define ESE_GZ_EF100_EWEV_TXQ_DESC 0x1 +#define ESE_GZ_EF100_EWEV_64BIT 0x0 + /* Enum TX_DESC_CSO_PARTIAL_EN */ #define ESE_GZ_TX_DESC_CSO_PARTIAL_EN_TCP 2 #define ESE_GZ_TX_DESC_CSO_PARTIAL_EN_UDP 1 @@ -681,6 +709,15 @@ #define ESE_GZ_TX_DESC_IP4_ID_INC_MOD16 2 #define ESE_GZ_TX_DESC_IP4_ID_INC_MOD15 1 #define ESE_GZ_TX_DESC_IP4_ID_NO_OP 0 + +/* Enum VIRTIO_NET_HDR_F */ +#define ESE_GZ_NEEDS_CSUM 0x1 + +/* Enum VIRTIO_NET_HDR_GSO */ +#define ESE_GZ_TCPV6 0x4 +#define ESE_GZ_UDP 0x3 +#define ESE_GZ_TCPV4 0x1 +#define ESE_GZ_NONE 0x0 /**************************************************************************/ #define ESF_GZ_EV_DEBUG_EVENT_GEN_FLAGS_LBN 44 From patchwork Wed Jul 20 18:29:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12924375 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 15AA1C433EF for ; Wed, 20 Jul 2022 18:31:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234607AbiGTSa7 (ORCPT ); Wed, 20 Jul 2022 14:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbiGTSa6 (ORCPT ); Wed, 20 Jul 2022 14:30:58 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2076.outbound.protection.outlook.com [40.107.95.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D26D709A3 for ; Wed, 20 Jul 2022 11:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pd3faPFLBQevJ/EdjyhPiHC7A/WDLVLWYSm08Vs9UoiSFrO3hracc4GCFS5zewd9B7I8enfkCSFHg4mHGBoRiPmnWfAQwHp3BhxfQhx01RwdPx5Htr9BJcu1W469qDDmBIbrhGNE3/iOq8GDo1KVPVV6AiUezx/yWTMl0lCF82Ab+IuA2cgjZQ1pci9/REs0IO7A4vBoit1VjZSffFeYoBOmBoQItuz5JX0u5VTLGGuKdo6b5AWmo0eQPWpxSB/4A5IP3tF7TYwCtZFpQGoSzkjgqTm4JORebHvgxDBx3zbd0r59EJZ6qKFVuwoXnHji/dinXJL/oSx/guKpqp9X9Q== 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=MhYl6mdr1Flx50bFmY0630NWO+UtakKW/K3+4N+sgK8=; b=Qon66STp4c/T64Uu1KLpzkjMuJDLr0qvBUpFvgnuVpOM0qeWIiwbbDWywKyg8fVKAVafy7QWjcOErzMsqYaqggGsGNxh5+s37tNCvaAtR5WEYdbICIY224uhb2cbf5vjRMjCk16FbKYFPSgP/br5nAPpSi2asvgAIDAad+TMlp+CHlzKEC7VkfnemEfF7sSUECS8GM7QzE9kRpvwxVCLeAHQxCRopORMFRoVSHNmoiDHSjFrlrZFRmEvWAo5JC9n/Vwn2j7LTAUOayNMPoar+ESPwrsFlwDlaJAOFGTlB81Ba7+troEDaaoGnJH60bynXeM5n8ajonBCQFuuFFH5IA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MhYl6mdr1Flx50bFmY0630NWO+UtakKW/K3+4N+sgK8=; b=q5OxA5rvlEYHGgJiowEpbeF+mbA3rtzw7IUxvJpHsWbYifTJqqxFy4sHWfaQG7/kJbIujvpcpQ+04E5Ll6CSCu3HIdnyDPVX7VqDWS9vGVTWILNpT5RJ1gz1AVerY1RnlSnkqpGc3SxqI25yMXTM4ENXUQ1yh1cFUyJxt5d5BmIt6x4BWTVIA4SeDyYtj8x3rBFR+6a3jhEKndA5xkBVywdOv9MKCUMe3QsN9f15H99GCJ40Okm43coueI+Em4hTs3kQJp7vFieYbSgxatK7bgoz66vE2BFeS15gtdLnGOH5JxeHYUXk79JLSmhQjOFDJbsEPtWZF1FKFYO8U0We0g== Received: from DS7PR03CA0232.namprd03.prod.outlook.com (2603:10b6:5:3ba::27) by BYAPR12MB2983.namprd12.prod.outlook.com (2603:10b6:a03:d6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.21; Wed, 20 Jul 2022 18:30:53 +0000 Received: from DM6NAM11FT065.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ba::4) by DS7PR03CA0232.outlook.office365.com (2603:10b6:5:3ba::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.21 via Frontend Transport; Wed, 20 Jul 2022 18:30:53 +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=fail action=none header.from=xilinx.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 DM6NAM11FT065.mail.protection.outlook.com (10.13.172.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5458.17 via Frontend Transport; Wed, 20 Jul 2022 18:30:53 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) 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.28; Wed, 20 Jul 2022 13:30:53 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 20 Jul 2022 11:30:52 -0700 Received: from xcbecree41x.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.28 via Frontend Transport; Wed, 20 Jul 2022 13:30:51 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH v3 net-next 2/9] sfc: detect ef100 MAE admin privilege/capability at probe time Date: Wed, 20 Jul 2022 19:29:26 +0100 Message-ID: <1efa3ac7290be1baab39447b16b05b118ec659ba.1658341691.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6351bc3f-e652-43c8-cbd1-08da6a7dfab4 X-MS-TrafficTypeDiagnostic: BYAPR12MB2983:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4Fe3MWuH8StY1pyu5OMxiLGIz4HX3O1oPO2QA1GhUBTb4LB++EeuR4SD0xqLCKHzwpUV6hQq8e6xYo5EonPjA9N5Z0PgXHfBGSfxusL7ABMBSlIT1eXhjDk7FdijqO3OP/H67AnHxyJoid33JGcXjDDhZZqqKCAcm/aPPyv5WlorrVf5aueL8zjVc8qvnt/hmr3rcKCM3Zo96FU+4xHJMpxWxSgWsbioEQhHxlN7xE/QMJXjMcSaIjLcYKmyUVrzyOcGpboIfqpFokmuMyz2IoHAFWotIan0iSlEdqcqweg9ejFx+VytBdugNOXX2E/k8gPLJOrLNXh3YRgSC84Jf9kJJX5rOyoC/NMKNY+5dZX00h3L0baX1YfmyIuAWJ2+ld9bFJu+EwqiOVZYhCZHvQJbVobSMy5hlI1es5JycciYektXsh/21y3N9vSZs33fckh+7ECuE5NofkIz/aYGkBYnPhpO8K+3weMQvlcTr8UlzuDj9ALJOQM4LV0R8tLOXV4HWUWkS41tn/8uLwBcnE2imOV4zmN3InJ2hQLANwoZRW+RI8ujjbjMKV15YWDEw+ZcHKT93TzVoW2rfWUIE7Uag+azxIaolfHtGUXnZaDys0yepbQ6n10jMYz1SbgdNPsOIWqIgUrM8M2qqTnVK9nSXd3S3LLa7K0GQVZGQBQVAYXCT24T5JvxCWwzC6PeMbxz5l9f+MKjvrlZWlZE0BHhGm9aFWtMbubQEWkVjEPU/vchZ00/94EmSowMVOtlMRROOhJVcCYkimIVSfxzi6NpK+vUNVzHwe02CXHoF6yCbqwANWNvtluU5fdH2lyfOEe99zuXdXuw8C/lk1aYqw== 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:(13230016)(4636009)(396003)(39860400002)(346002)(376002)(136003)(36840700001)(46966006)(40470700004)(82740400003)(186003)(36756003)(41300700001)(9686003)(36860700001)(82310400005)(478600001)(40480700001)(5660300002)(83380400001)(336012)(42882007)(6666004)(54906003)(2906002)(47076005)(4326008)(2876002)(8936002)(8676002)(70206006)(55446002)(356005)(70586007)(110136005)(26005)(40460700003)(81166007)(83170400001)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 18:30:53.4861 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6351bc3f-e652-43c8-cbd1-08da6a7dfab4 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: DM6NAM11FT065.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2983 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree One PCIe function per network port (more precisely, per m-port group) is responsible for configuring the Match-Action Engine which performs switching and packet modification in the slice to support flower/OVS offload. The GRP_MAE bit in the privilege mask indicates whether a given function has this capability. At probe time, call MCDIs to read the calling function's privilege mask, and store the GRP_MAE bit in a new ef100_nic_data member. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_nic.c | 7 +++++ drivers/net/ethernet/sfc/ef100_nic.h | 1 + drivers/net/ethernet/sfc/mcdi.c | 46 ++++++++++++++++++++++++++++ drivers/net/ethernet/sfc/mcdi.h | 1 + 4 files changed, 55 insertions(+) diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c index f89e695cf8ac..4625d35269e6 100644 --- a/drivers/net/ethernet/sfc/ef100_nic.c +++ b/drivers/net/ethernet/sfc/ef100_nic.c @@ -946,6 +946,7 @@ static int ef100_probe_main(struct efx_nic *efx) unsigned int bar_size = resource_size(&efx->pci_dev->resource[efx->mem_bar]); struct ef100_nic_data *nic_data; char fw_version[32]; + u32 priv_mask = 0; int i, rc; if (WARN_ON(bar_size == 0)) @@ -1027,6 +1028,12 @@ static int ef100_probe_main(struct efx_nic *efx) efx_mcdi_print_fwver(efx, fw_version, sizeof(fw_version)); pci_dbg(efx->pci_dev, "Firmware version %s\n", fw_version); + rc = efx_mcdi_get_privilege_mask(efx, &priv_mask); + if (rc) /* non-fatal, and priv_mask will still be 0 */ + pci_info(efx->pci_dev, + "Failed to get privilege mask from FW, rc %d\n", rc); + nic_data->grp_mae = !!(priv_mask & MC_CMD_PRIVILEGE_MASK_IN_GRP_MAE); + if (compare_versions(fw_version, "1.1.0.1000") < 0) { pci_info(efx->pci_dev, "Firmware uses old event descriptors\n"); rc = -EINVAL; diff --git a/drivers/net/ethernet/sfc/ef100_nic.h b/drivers/net/ethernet/sfc/ef100_nic.h index 744dbbdb4adc..40f84a275057 100644 --- a/drivers/net/ethernet/sfc/ef100_nic.h +++ b/drivers/net/ethernet/sfc/ef100_nic.h @@ -72,6 +72,7 @@ struct ef100_nic_data { u8 port_id[ETH_ALEN]; DECLARE_BITMAP(evq_phases, EFX_MAX_CHANNELS); u64 stats[EF100_STAT_COUNT]; + bool grp_mae; /* MAE Privilege */ u16 tso_max_hdr_len; u16 tso_max_payload_num_segs; u16 tso_max_frames; diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index 3225fe64c397..af338208eae9 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -2129,6 +2129,52 @@ int efx_mcdi_get_workarounds(struct efx_nic *efx, unsigned int *impl_out, return rc; } +/* Failure to read a privilege mask is never fatal, because we can always + * carry on as though we didn't have the privilege we were interested in. + * So use efx_mcdi_rpc_quiet(). + */ +int efx_mcdi_get_privilege_mask(struct efx_nic *efx, u32 *mask) +{ + MCDI_DECLARE_BUF(fi_outbuf, MC_CMD_GET_FUNCTION_INFO_OUT_LEN); + MCDI_DECLARE_BUF(pm_inbuf, MC_CMD_PRIVILEGE_MASK_IN_LEN); + MCDI_DECLARE_BUF(pm_outbuf, MC_CMD_PRIVILEGE_MASK_OUT_LEN); + size_t outlen; + u16 pf, vf; + int rc; + + if (!efx || !mask) + return -EINVAL; + + /* Get our function number */ + rc = efx_mcdi_rpc_quiet(efx, MC_CMD_GET_FUNCTION_INFO, NULL, 0, + fi_outbuf, MC_CMD_GET_FUNCTION_INFO_OUT_LEN, + &outlen); + if (rc != 0) + return rc; + if (outlen < MC_CMD_GET_FUNCTION_INFO_OUT_LEN) + return -EIO; + + pf = MCDI_DWORD(fi_outbuf, GET_FUNCTION_INFO_OUT_PF); + vf = MCDI_DWORD(fi_outbuf, GET_FUNCTION_INFO_OUT_VF); + + MCDI_POPULATE_DWORD_2(pm_inbuf, PRIVILEGE_MASK_IN_FUNCTION, + PRIVILEGE_MASK_IN_FUNCTION_PF, pf, + PRIVILEGE_MASK_IN_FUNCTION_VF, vf); + + rc = efx_mcdi_rpc_quiet(efx, MC_CMD_PRIVILEGE_MASK, + pm_inbuf, sizeof(pm_inbuf), + pm_outbuf, sizeof(pm_outbuf), &outlen); + + if (rc != 0) + return rc; + if (outlen < MC_CMD_PRIVILEGE_MASK_OUT_LEN) + return -EIO; + + *mask = MCDI_DWORD(pm_outbuf, PRIVILEGE_MASK_OUT_OLD_MASK); + + return 0; +} + #ifdef CONFIG_SFC_MTD #define EFX_MCDI_NVRAM_LEN_MAX 128 diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h index 69c2924a147c..f74f6ce8b27d 100644 --- a/drivers/net/ethernet/sfc/mcdi.h +++ b/drivers/net/ethernet/sfc/mcdi.h @@ -366,6 +366,7 @@ int efx_mcdi_set_workaround(struct efx_nic *efx, u32 type, bool enabled, unsigned int *flags); int efx_mcdi_get_workarounds(struct efx_nic *efx, unsigned int *impl_out, unsigned int *enabled_out); +int efx_mcdi_get_privilege_mask(struct efx_nic *efx, u32 *mask); #ifdef CONFIG_SFC_MCDI_MON int efx_mcdi_mon_probe(struct efx_nic *efx); From patchwork Wed Jul 20 18:29:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12924376 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 116E8C43334 for ; Wed, 20 Jul 2022 18:31:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237471AbiGTSbC (ORCPT ); Wed, 20 Jul 2022 14:31:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbiGTSbA (ORCPT ); Wed, 20 Jul 2022 14:31:00 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2055.outbound.protection.outlook.com [40.107.101.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5117770E58 for ; Wed, 20 Jul 2022 11:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FAZWLVU43/4ZbMG1589hhn0C0DlbWTA4Mhky9MnXmu5e7W34x8cZZBDkoWl3DULKwsNgx2GeABM+F9NnkHRruxP8euDZZ7gUji2oaKJ2FH7i186dF5jpe7TVeIndnGnbvCjVSvIKQT2CjyG00/+d5q9W4xobaU+Iicn6PY4yU7dTY8x6vcnYRwUqUvDVdi0WMpI4LVorey+T+lp5Dag3b8XoevqOebj6UW8KXyPyWjj2dvYLZF6cGaLjfAXtE45eE5/FQQdbco/yL0W0H3wXqAHasCDHERjxY8kqP3BiMYY3dygPY/GKTEvI2W2nv/HAr/3JoJlCK03Yc1h457hV9w== 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=Pv2m/A0KeVRnCccx3IE38omnw82zClPfwE4aWVprL2s=; b=LAActmHBjKvfKJ/xY0vtRe3mSISNwpBIN6SvTm6WVcnTz2fvjJfHBqleCjdgNDHN264VVG8Toz8woIZtTv05ZBdwBQQUYZe2tZmFzsd71B6QCgFGPHMICvR3XS9ZNxCe+3UIOtwLOk9cdVRaSkgbRxe4AoeY34KJe54eunAtOmqr9Qm9yY5p7hUgATQLwnKmYze18xx9yh74/nHO6A95HwgXSkvxAC9CT6sof92c11IHsztXOS0fyw97LjJ1c4vKXk5pRNHM0TS4qzTN6N4FlyNzoedyfRdCJ7U9VtGS/jgHbgQG8CaLMGNppgH9mwmuqdV3QklddbbhIGbPkK66Yg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pv2m/A0KeVRnCccx3IE38omnw82zClPfwE4aWVprL2s=; b=yTViR406QAWgGNCx3EG4NUv7T+QHXxAG8gsVZrWkop9aQXDxjbnQVcEEcYKD8ErqgIdD6Cmdu02gektYdYz8B0p6g6XQevBh6hv6c1c6HR8curAOa2+Ij6uerc8EHDjif4r8lsNwMGAnfpH+tgdiW2vpkn4O+Wh7HcLDioPMZtOkrjzeM73WvdGijC/yzXyMrBv1qh3kz9lnR7UgFmMYz8ZZToW8mTLCCPLgf9dskUuUPbbXv/jPVsgK2BXL3HmbDPRlmezkjtMvuNoESaQpX7CiavSNsXIgUlxYGZLGVgUN4V6h2reD7eX6CrizQzyZkJ13b0+zm6u05WhYpgTGKg== Received: from DM6PR03CA0043.namprd03.prod.outlook.com (2603:10b6:5:100::20) by DM4PR12MB6638.namprd12.prod.outlook.com (2603:10b6:8:b5::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Wed, 20 Jul 2022 18:30:57 +0000 Received: from DM6NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:5:100:cafe::c7) by DM6PR03CA0043.outlook.office365.com (2603:10b6:5:100::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18 via Frontend Transport; Wed, 20 Jul 2022 18:30:57 +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=fail action=none header.from=xilinx.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 DM6NAM11FT031.mail.protection.outlook.com (10.13.172.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5458.17 via Frontend Transport; Wed, 20 Jul 2022 18:30:57 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) 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.28; Wed, 20 Jul 2022 13:30:55 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 20 Jul 2022 11:30:55 -0700 Received: from xcbecree41x.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.28 via Frontend Transport; Wed, 20 Jul 2022 13:30:54 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH v3 net-next 3/9] sfc: add skeleton ef100 VF representors Date: Wed, 20 Jul 2022 19:29:28 +0100 Message-ID: <0157d7fe8b7cc25d5c18ea1ee8c50dc37e3fe697.1658341691.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1237f144-bb65-40be-aa12-08da6a7dfce5 X-MS-TrafficTypeDiagnostic: DM4PR12MB6638:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6XygyOp2P7EGbM0UVWftBtlfelM0CUgL1KioOW1n/AYd8R6WXNAjEzSQgZDpCtfAlJcbcAewYmdcf8CZ1bSZTzkGZZ8DQRDhniUphrSJG5jq9JxKH7qb6P3bQgcsbx0rzCubEImwT0SehLxG+WC33vRf2vFTMqGsBLPOetjFfr4Ua9hTZks4gotQP1US3oGO3i5dm+AI9U83T7TsuuO52mqlHIpssjstELFgScZIzVXhk80eSXxQT0gZpyWGYXlQgDD3B1mxMrUPTWDvUKbRDlzLY2Ppn4zXSzUnnagyxbmU2uJhNTfgz8r/kL6dN4k5BFu91jSyhLAic1Rp9hSQQDL4s06sVGYOwR2m/tsLSyJxZqSPlPXWSMAHqoo42pEtCkich31xgnV8XrD/GVIxDhitHtby7q7UpnixoOEV2rLaLMXc2E3REzAcdeHloU/ffdpeW3U096G8MmPZJWZGTMiwcph/J34aipOaWdQYvvrUAEM9uvsfCHsqB7Hpn5VGZ+hn1z1KHuo7u97REJm+ry7tlxvc/Vwt0vU7fGyIQJylaXGgq7BndGA4oSU0PugeTehGmEne/hG0CZLrLR3lFDqO5QFOuQkLyc8KD3Hv/a73BiuwYcX6AWmx3FUJjnKESXQDj8QBik4f8SefzsU/Ow/wWcfonmhSBbOUkAwfo0fm6Ywql25QKZhlTRIZ7KRe8DPnuZYj8QYTlR6zSgHh7aQ0i4ASbEEkms5+Hs3AU8L2aj8wUugs6rHcXwYgtjgipbdcQBtaloHv7uSXMMX+Hj9ZRdEwmcri3bK1dRN/ptTscSWnNmTQjKF7UTpIjUQEJoucWlBIur1zowuN9E9FqkMW7SxLdjrQ1feXDehw5ME= 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:(13230016)(4636009)(396003)(136003)(346002)(376002)(39860400002)(46966006)(36840700001)(40470700004)(40480700001)(47076005)(40460700003)(26005)(82310400005)(42882007)(36756003)(36860700001)(186003)(9686003)(54906003)(110136005)(336012)(478600001)(2876002)(70206006)(2906002)(83380400001)(6666004)(8936002)(81166007)(4326008)(356005)(41300700001)(55446002)(316002)(83170400001)(5660300002)(70586007)(8676002)(82740400003)(30864003)(2004002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 18:30:57.1618 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1237f144-bb65-40be-aa12-08da6a7dfce5 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: DM6NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6638 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree No net_device_ops yet, just a placeholder netdev created per VF. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/Makefile | 2 +- drivers/net/ethernet/sfc/ef100_netdev.c | 2 +- drivers/net/ethernet/sfc/ef100_rep.c | 126 ++++++++++++++++++++++++ drivers/net/ethernet/sfc/ef100_rep.h | 37 +++++++ drivers/net/ethernet/sfc/ef100_sriov.c | 32 ++++-- drivers/net/ethernet/sfc/ef100_sriov.h | 2 +- drivers/net/ethernet/sfc/efx_common.c | 2 + drivers/net/ethernet/sfc/net_driver.h | 4 + 8 files changed, 196 insertions(+), 11 deletions(-) create mode 100644 drivers/net/ethernet/sfc/ef100_rep.c create mode 100644 drivers/net/ethernet/sfc/ef100_rep.h diff --git a/drivers/net/ethernet/sfc/Makefile b/drivers/net/ethernet/sfc/Makefile index b9298031ea51..7a6772bfde06 100644 --- a/drivers/net/ethernet/sfc/Makefile +++ b/drivers/net/ethernet/sfc/Makefile @@ -8,7 +8,7 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \ ef100.o ef100_nic.o ef100_netdev.o \ ef100_ethtool.o ef100_rx.o ef100_tx.o sfc-$(CONFIG_SFC_MTD) += mtd.o -sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o +sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o obj-$(CONFIG_SFC) += sfc.o diff --git a/drivers/net/ethernet/sfc/ef100_netdev.c b/drivers/net/ethernet/sfc/ef100_netdev.c index 060392ddd612..f4a124b8ffbe 100644 --- a/drivers/net/ethernet/sfc/ef100_netdev.c +++ b/drivers/net/ethernet/sfc/ef100_netdev.c @@ -312,7 +312,7 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data) unregister_netdevice_notifier(&efx->netdev_notifier); #if defined(CONFIG_SFC_SRIOV) if (!efx->type->is_vf) - efx_ef100_pci_sriov_disable(efx); + efx_ef100_pci_sriov_disable(efx, true); #endif ef100_unregister_netdev(efx); diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c new file mode 100644 index 000000000000..f10c25d6f134 --- /dev/null +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: GPL-2.0-only +/**************************************************************************** + * Driver for Solarflare network controllers and boards + * Copyright 2019 Solarflare Communications Inc. + * Copyright 2020-2022 Xilinx 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 "ef100_rep.h" +#include "ef100_nic.h" + +static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv) +{ + efv->parent = efx; + INIT_LIST_HEAD(&efv->list); + efv->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE | + NETIF_MSG_LINK | NETIF_MSG_IFDOWN | + NETIF_MSG_IFUP | NETIF_MSG_RX_ERR | + NETIF_MSG_TX_ERR | NETIF_MSG_HW; + return 0; +} + +static const struct net_device_ops efx_ef100_rep_netdev_ops = { +}; + +static const struct ethtool_ops efx_ef100_rep_ethtool_ops = { +}; + +static struct efx_rep *efx_ef100_rep_create_netdev(struct efx_nic *efx, + unsigned int i) +{ + struct net_device *net_dev; + struct efx_rep *efv; + int rc; + + net_dev = alloc_etherdev_mq(sizeof(*efv), 1); + if (!net_dev) + return ERR_PTR(-ENOMEM); + + efv = netdev_priv(net_dev); + rc = efx_ef100_rep_init_struct(efx, efv); + if (rc) + goto fail1; + efv->net_dev = net_dev; + rtnl_lock(); + spin_lock_bh(&efx->vf_reps_lock); + list_add_tail(&efv->list, &efx->vf_reps); + spin_unlock_bh(&efx->vf_reps_lock); + netif_carrier_off(net_dev); + netif_tx_stop_all_queues(net_dev); + rtnl_unlock(); + + net_dev->netdev_ops = &efx_ef100_rep_netdev_ops; + net_dev->ethtool_ops = &efx_ef100_rep_ethtool_ops; + net_dev->min_mtu = EFX_MIN_MTU; + net_dev->max_mtu = EFX_MAX_MTU; + return efv; +fail1: + free_netdev(net_dev); + return ERR_PTR(rc); +} + +static void efx_ef100_rep_destroy_netdev(struct efx_rep *efv) +{ + struct efx_nic *efx = efv->parent; + + spin_lock_bh(&efx->vf_reps_lock); + list_del(&efv->list); + spin_unlock_bh(&efx->vf_reps_lock); + free_netdev(efv->net_dev); +} + +int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i) +{ + struct efx_rep *efv; + int rc; + + efv = efx_ef100_rep_create_netdev(efx, i); + if (IS_ERR(efv)) { + rc = PTR_ERR(efv); + pci_err(efx->pci_dev, + "Failed to create representor for VF %d, rc %d\n", i, + rc); + return rc; + } + rc = register_netdev(efv->net_dev); + if (rc) { + pci_err(efx->pci_dev, + "Failed to register representor for VF %d, rc %d\n", + i, rc); + goto fail; + } + pci_dbg(efx->pci_dev, "Representor for VF %d is %s\n", i, + efv->net_dev->name); + return 0; +fail: + efx_ef100_rep_destroy_netdev(efv); + return rc; +} + +void efx_ef100_vfrep_destroy(struct efx_nic *efx, struct efx_rep *efv) +{ + struct net_device *rep_dev; + + rep_dev = efv->net_dev; + if (!rep_dev) + return; + netif_dbg(efx, drv, rep_dev, "Removing VF representor\n"); + unregister_netdev(rep_dev); + efx_ef100_rep_destroy_netdev(efv); +} + +void efx_ef100_fini_vfreps(struct efx_nic *efx) +{ + struct ef100_nic_data *nic_data = efx->nic_data; + struct efx_rep *efv, *next; + + if (!nic_data->grp_mae) + return; + + list_for_each_entry_safe(efv, next, &efx->vf_reps, list) + efx_ef100_vfrep_destroy(efx, efv); +} diff --git a/drivers/net/ethernet/sfc/ef100_rep.h b/drivers/net/ethernet/sfc/ef100_rep.h new file mode 100644 index 000000000000..7d85811f0adb --- /dev/null +++ b/drivers/net/ethernet/sfc/ef100_rep.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/**************************************************************************** + * Driver for Solarflare network controllers and boards + * Copyright 2019 Solarflare Communications Inc. + * Copyright 2020-2022 Xilinx 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. + */ + +/* Handling for ef100 representor netdevs */ +#ifndef EF100_REP_H +#define EF100_REP_H + +#include "net_driver.h" + +/** + * struct efx_rep - Private data for an Efx representor + * + * @parent: the efx PF which manages this representor + * @net_dev: representor netdevice + * @msg_enable: log message enable flags + * @list: entry on efx->vf_reps + */ +struct efx_rep { + struct efx_nic *parent; + struct net_device *net_dev; + u32 msg_enable; + struct list_head list; +}; + +int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i); +void efx_ef100_vfrep_destroy(struct efx_nic *efx, struct efx_rep *efv); +void efx_ef100_fini_vfreps(struct efx_nic *efx); + +#endif /* EF100_REP_H */ diff --git a/drivers/net/ethernet/sfc/ef100_sriov.c b/drivers/net/ethernet/sfc/ef100_sriov.c index 664578176bfe..94bdbfcb47e8 100644 --- a/drivers/net/ethernet/sfc/ef100_sriov.c +++ b/drivers/net/ethernet/sfc/ef100_sriov.c @@ -11,46 +11,62 @@ #include "ef100_sriov.h" #include "ef100_nic.h" +#include "ef100_rep.h" static int efx_ef100_pci_sriov_enable(struct efx_nic *efx, int num_vfs) { + struct ef100_nic_data *nic_data = efx->nic_data; struct pci_dev *dev = efx->pci_dev; - int rc; + struct efx_rep *efv, *next; + int rc, i; efx->vf_count = num_vfs; rc = pci_enable_sriov(dev, num_vfs); if (rc) - goto fail; + goto fail1; + if (!nic_data->grp_mae) + return 0; + + for (i = 0; i < num_vfs; i++) { + rc = efx_ef100_vfrep_create(efx, i); + if (rc) + goto fail2; + } return 0; -fail: +fail2: + list_for_each_entry_safe(efv, next, &efx->vf_reps, list) + efx_ef100_vfrep_destroy(efx, efv); + pci_disable_sriov(dev); +fail1: netif_err(efx, probe, efx->net_dev, "Failed to enable SRIOV VFs\n"); efx->vf_count = 0; return rc; } -int efx_ef100_pci_sriov_disable(struct efx_nic *efx) +int efx_ef100_pci_sriov_disable(struct efx_nic *efx, bool force) { struct pci_dev *dev = efx->pci_dev; unsigned int vfs_assigned; vfs_assigned = pci_vfs_assigned(dev); - if (vfs_assigned) { + if (vfs_assigned && !force) { netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; " "please detach them before disabling SR-IOV\n"); return -EBUSY; } - pci_disable_sriov(dev); - + efx_ef100_fini_vfreps(efx); + if (!vfs_assigned) + pci_disable_sriov(dev); return 0; } int efx_ef100_sriov_configure(struct efx_nic *efx, int num_vfs) { if (num_vfs == 0) - return efx_ef100_pci_sriov_disable(efx); + return efx_ef100_pci_sriov_disable(efx, false); else return efx_ef100_pci_sriov_enable(efx, num_vfs); } diff --git a/drivers/net/ethernet/sfc/ef100_sriov.h b/drivers/net/ethernet/sfc/ef100_sriov.h index c48fccd46c57..8ffdf464dd1d 100644 --- a/drivers/net/ethernet/sfc/ef100_sriov.h +++ b/drivers/net/ethernet/sfc/ef100_sriov.h @@ -11,4 +11,4 @@ #include "net_driver.h" int efx_ef100_sriov_configure(struct efx_nic *efx, int num_vfs); -int efx_ef100_pci_sriov_disable(struct efx_nic *efx); +int efx_ef100_pci_sriov_disable(struct efx_nic *efx, bool force); diff --git a/drivers/net/ethernet/sfc/efx_common.c b/drivers/net/ethernet/sfc/efx_common.c index 56eb717bb07a..fb6b66b8707b 100644 --- a/drivers/net/ethernet/sfc/efx_common.c +++ b/drivers/net/ethernet/sfc/efx_common.c @@ -1021,6 +1021,8 @@ int efx_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev) efx->rps_hash_table = kcalloc(EFX_ARFS_HASH_TABLE_SIZE, sizeof(*efx->rps_hash_table), GFP_KERNEL); #endif + spin_lock_init(&efx->vf_reps_lock); + INIT_LIST_HEAD(&efx->vf_reps); INIT_WORK(&efx->mac_work, efx_mac_work); init_waitqueue_head(&efx->flush_wq); diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 2228c88a7f31..037cfa184764 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -966,6 +966,8 @@ enum efx_xdp_tx_queues_mode { * @vf_count: Number of VFs intended to be enabled. * @vf_init_count: Number of VFs that have been fully initialised. * @vi_scale: log2 number of vnics per VF. + * @vf_reps_lock: Protects vf_reps list + * @vf_reps: local VF reps * @ptp_data: PTP state data * @ptp_warned: has this NIC seen and warned about unexpected PTP events? * @vpd_sn: Serial number read from VPD @@ -1145,6 +1147,8 @@ struct efx_nic { unsigned vf_init_count; unsigned vi_scale; #endif + spinlock_t vf_reps_lock; + struct list_head vf_reps; struct efx_ptp_data *ptp_data; bool ptp_warned; From patchwork Wed Jul 20 18:29:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12924377 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 DBAFCC433EF for ; Wed, 20 Jul 2022 18:31:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230042AbiGTSbP (ORCPT ); Wed, 20 Jul 2022 14:31:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233028AbiGTSbE (ORCPT ); Wed, 20 Jul 2022 14:31:04 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2043.outbound.protection.outlook.com [40.107.223.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CF6670E63 for ; Wed, 20 Jul 2022 11:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oTGtIsVQfEbwG++8G5npj/A5f+9WXUhxDYXYKOA9nSw9z87CczRuiZfI0Z6NDarEdyI2YL45B3OCTbwn98CS63ZPA3QNNwtqKZwRwYxBfiA+FcXJoAcMN23j9Z5zKwmAm+5Um0aM4UHvb7ksBQNe5hSysUK/5jn0BH3RMWi81Ek4LIQEPnuMrFnLteHP6gD47fbKilPKOnJLK2IRfWYc2FiPrOFTnm6Koq+0rvu32q3uSOmdpMe9oPVACkQlD0ZgJNl6sjqxwRjt9DxiE8/fGbCGm0O7myZ1JzK26A45DbSSAVX1J4F1fBVuvwtP5xkGH5NhWaxlxuU1hcsbhst56w== 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=uTjytkjfFiBdG4JuZj3x7e/V21dEXahuIUI5YVeL3Vw=; b=NRjhpB94yf3jNIeOrvzv1MwsCDbqDwoNNIY5j1MwLbTbeUBM0rXRkd4fu2kLhu1DChrTZqcNpocOSVQ3tILs3hwbxtvN7Q+3ye5WlO9eBwD2j4GQtRB4nd+EE5YmYlwZ7ujxYVEaVSfFjJ/8HX40gNDAJankMEF1MltsW89rZuNpqiKvs5l9IAdhSsso3eXS5K5s8+dATxj/CbZsUbpRZFFxxJ4eVna883+3uO0u7BBULzBQMbZXyNt7o0QcNXDdZhQ+1K1uz4vX2NoinoUrJIjZ6BdtewXwa+kYrjCZRiJn6V3r3CsUV3eu4Gnxk46azyF9Lsx6wwiyta/cNFUCJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uTjytkjfFiBdG4JuZj3x7e/V21dEXahuIUI5YVeL3Vw=; b=12xfbHfpSg1fK8+K9qVQNb35I6UXKZl/AFPz8Vc3G20GR7Kx+uPJ3H5jo1WAzDfAvVKS5WnPtEmmW3N9AHcgNN4wtqNQo/qFjVd6pc3LVGYgpu+qoQ3f9f8v5oWO2ev0Llay1VrRxvZFLQkuY05GZHHwDdWIUUB8WcU9Yf1FsEHKAyhjDvy0Z6mnVo8Wdd7XapySZcx0kAuLwAv0DhKg0GLHPZI+vBo9rQqfVN/cV37Yh9YuS38Wswi0lVCMNiKUk5Jh6KwiCzF59YBwcr7ebtSSksR9G9VbmtjHQ23xr7p6I+GKi+BUSFhT9Di0vLJPQkIMwmbfKSETofAHF3amxQ== Received: from MW4PR03CA0010.namprd03.prod.outlook.com (2603:10b6:303:8f::15) by CH2PR12MB5561.namprd12.prod.outlook.com (2603:10b6:610:69::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Wed, 20 Jul 2022 18:31:01 +0000 Received: from CO1NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8f:cafe::4a) by MW4PR03CA0010.outlook.office365.com (2603:10b6:303:8f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23 via Frontend Transport; Wed, 20 Jul 2022 18:31:00 +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=fail action=none header.from=xilinx.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 CO1NAM11FT036.mail.protection.outlook.com (10.13.174.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5458.17 via Frontend Transport; Wed, 20 Jul 2022 18:31:00 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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.28; Wed, 20 Jul 2022 13:30:57 -0500 Received: from xcbecree41x.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.28 via Frontend Transport; Wed, 20 Jul 2022 13:30:56 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH v3 net-next 4/9] sfc: add basic ethtool ops to ef100 reps Date: Wed, 20 Jul 2022 19:29:30 +0100 Message-ID: <77192426118d089e6b9e7b3e800d05b23a89fc96.1658341691.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2c0adc1d-df6b-4243-8f13-08da6a7dfef4 X-MS-TrafficTypeDiagnostic: CH2PR12MB5561:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wHo9JUHVGkqiSHmkJVJf1KwNerHduCixbkOVbd4g0qhRPUcuwgmW+gmt7fPCVNNWjlm9dIX5Dxgvn7Xrzpt9Ynsxk4EczFMKhF/ch9MeNUr7CXNjRqnuvsMZgLYPPaeS1uCVsr5lVKztJCSX51R1J5Wy27x+bNm96eAeM665WIQXUcOLkEMzxcYKEXHdtOZQKntJ+La8Fuk59hW8JgkKYuEug/8sTmpBvjVnS6VRcEQ4MM4TipLzPLvH2Q2GLG3dksmqEotCTHRvfUbMErTLOivDcIXR4ukG2cellsuV005Cp62bojfNSEYMG5TL/xKlbl9ynyRg3NSfdSxmMA7+vYHm5MFyR68BvO7hWbbO3WHvhAOkiQWdcW6h4VYrlJRF2GjlHksz0chCXpTBiSneKV/2OdZdz8juiv87tQODUyMGkRluslbk03kwEBPkBfofhJwlcl1xuNv+cFNmHsahkzbFCT/2j+QSHM8pXxSd1gBSjezJcerI14exWXe8vpkPW9KCtgkprOtaGGXRhxp+YzpQEEv6Lvwfe68RPHjXiLq6+cjmLsNkrCNCzuEtVrUX1j2aQbAfSGC4RMIBvaBKGUFBpZq5zMJwQ8xC0dp1qg1m8EFFXlxvAWZitlQXQOxDbx0Gbtq8O7aQ1gI3SfmV7JgZRgXO2Cjl6Y5E2fbXlEZtxv1vtBhmz2Y2jRu07L1EFFVKkARUNv5O92cogvbh2JykHq/UycXvB2WBFy3Nsaz80wdNy8MiaCcJaQb/XCrNMPlT7Lj5TwJOQjsj2fmWjwzZNYzN4HeTHtu393/0dqiqjj6kbLqHhwqqR5pzdiQD5URSR6odEi+k6gneUp41Ng== 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:(13230016)(4636009)(396003)(346002)(39860400002)(136003)(376002)(36840700001)(40470700004)(46966006)(40460700003)(336012)(110136005)(4326008)(356005)(47076005)(42882007)(82740400003)(26005)(82310400005)(186003)(54906003)(316002)(81166007)(8676002)(9686003)(5660300002)(478600001)(83170400001)(36860700001)(8936002)(41300700001)(2906002)(6666004)(40480700001)(70586007)(36756003)(55446002)(2876002)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 18:31:00.5368 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2c0adc1d-df6b-4243-8f13-08da6a7dfef4 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: CO1NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB5561 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_rep.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c index f10c25d6f134..1121bf162b2f 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.c +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -12,6 +12,8 @@ #include "ef100_rep.h" #include "ef100_nic.h" +#define EFX_EF100_REP_DRIVER "efx_ef100_rep" + static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv) { efv->parent = efx; @@ -26,7 +28,31 @@ static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv) static const struct net_device_ops efx_ef100_rep_netdev_ops = { }; +static void efx_ef100_rep_get_drvinfo(struct net_device *dev, + struct ethtool_drvinfo *drvinfo) +{ + strscpy(drvinfo->driver, EFX_EF100_REP_DRIVER, sizeof(drvinfo->driver)); +} + +static u32 efx_ef100_rep_ethtool_get_msglevel(struct net_device *net_dev) +{ + struct efx_rep *efv = netdev_priv(net_dev); + + return efv->msg_enable; +} + +static void efx_ef100_rep_ethtool_set_msglevel(struct net_device *net_dev, + u32 msg_enable) +{ + struct efx_rep *efv = netdev_priv(net_dev); + + efv->msg_enable = msg_enable; +} + static const struct ethtool_ops efx_ef100_rep_ethtool_ops = { + .get_drvinfo = efx_ef100_rep_get_drvinfo, + .get_msglevel = efx_ef100_rep_ethtool_get_msglevel, + .set_msglevel = efx_ef100_rep_ethtool_set_msglevel, }; static struct efx_rep *efx_ef100_rep_create_netdev(struct efx_nic *efx, From patchwork Wed Jul 20 18:29:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12924378 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 5DD3BC433EF for ; Wed, 20 Jul 2022 18:31:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240923AbiGTSbR (ORCPT ); Wed, 20 Jul 2022 14:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240915AbiGTSbG (ORCPT ); Wed, 20 Jul 2022 14:31:06 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2080.outbound.protection.outlook.com [40.107.244.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0010C70E79 for ; Wed, 20 Jul 2022 11:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OvrLIm7xBjv35ngRMldTNt/SmuByIY5b4q1+XPx3wthYjA8XAxc4Pvne+l9n0GfY+u5DiHjZr3X0iqQ5eu/yTkcbTZ9OXnCeNAikCQNGjed+DXHT8fhsbCigeIMOaIfkSL95MDpg/f+XhfS1z53pX6IZHpHcUBr/QYK71EIk1bTeDEDvq29JLjaL3UL486/gCjWNcP2cwTUoUH4v2WgdqYlQGyvArRYbv2JOC2gX3f0ni7FEu1o3XWp99N6rZhUj45zhgn1YkHMzFciDyOcFm9GBNuHUxwzIQVhwKasyqmsjyU6SqgElL4nLm6HtXsXElchQGN9oHzkXh6iPwfm6Xw== 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=x7Jnv2jzJLYjwqPpssW/ecB3FPAxueiMV+fZ5eTaNx4=; b=BPCYW0vwh4mr6slSgo07j0nEu4Qpbk2BzTMXl5Hmm+JE3/ZwJ3gyCeS0IB/4/3zjz1KrcDM9SMWmB3B2WUnSYBD3AMgV/DGuxY2qC6cM8o32H0P5yBLCjF8Zw2s8XVFcD+VrTCDSezWj9N9M4I9s2SDGrjbRx7t7ye4ASnJe1ji/vHFlHkQ4JkAj4BBMyXPEPqX2T2R2mu34Ma/HrIvui3SmFjZpMjWO3QnS+ICR0avnCJ+SyJ9wd6GeEpttU7UzcrY3tAaLjuSBd8ab64HP/91UlZZSsfk+4MF2D0bEBsbngUl8fVkjLnQjYvC2AQRaxaoK5DJtJHrV5QKduBqBug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x7Jnv2jzJLYjwqPpssW/ecB3FPAxueiMV+fZ5eTaNx4=; b=L9Yl0fQ43c/HGjhyil8/l80l7KXaC2l9rYROyro5ULDnmqp+w+PBd9+E+8muue3YG1r2j/u9STi7xi3oXHjONMIkXZMEd0krB5NyXwUbnABf3VSFXjj0rUkLZUZAhFG4rfN/3futD9LRy3CZ+FadxfuQRkQIO5RB0/3GBVTRg6aQ0jgEjy0WLLcEGaRuoLcIzsPmbOE695DTNScEQHtit9OvNC4/C1wXPztWT/CasawiTJmmOvk5Zbk5YtoVLa/56aFV+wJgHHHWPXdR7k9Kj6/lERKhm1v6yc7OdGaHraaaOJWsC4+hXBmaGoGDl/TsZFh4z09z0kvZd2JcZJ6RZw== Received: from MW4PR03CA0028.namprd03.prod.outlook.com (2603:10b6:303:8f::33) by DM4PR12MB5294.namprd12.prod.outlook.com (2603:10b6:5:39e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.14; Wed, 20 Jul 2022 18:31:04 +0000 Received: from CO1NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8f:cafe::18) by MW4PR03CA0028.outlook.office365.com (2603:10b6:303:8f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.23 via Frontend Transport; Wed, 20 Jul 2022 18:31:04 +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=fail action=none header.from=xilinx.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 CO1NAM11FT036.mail.protection.outlook.com (10.13.174.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5458.17 via Frontend Transport; Wed, 20 Jul 2022 18:31:04 +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.28; Wed, 20 Jul 2022 13:31:02 -0500 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.28; Wed, 20 Jul 2022 11:31:01 -0700 Received: from xcbecree41x.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.28 via Frontend Transport; Wed, 20 Jul 2022 13:31:00 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH v3 net-next 5/9] sfc: phys port/switch identification for ef100 reps Date: Wed, 20 Jul 2022 19:29:33 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cfae20f0-cc18-457d-cdcb-08da6a7e0124 X-MS-TrafficTypeDiagnostic: DM4PR12MB5294:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1/FA0hkAohCPiC8wtKPEfkj70VW23FYptBOeTO0aepdSLimrXjtPtHWBV0HyokTdo3tEpyzS0C0dTMSxQ3JvKOA3G7i5lLXZpkpHdQnwvB3OocHtF/tDI1LZmF0EOh9+Jn65DR0fuump56hpuNvimHsgvkOr/Op3xHBHbuHmLFUWlhNMsibYEnzIog72J7VkwU9njqghof1dizVotBziYpYej+fcqRRoLnCGjgvGbFq6kAxrtdR7ZCYHiwEbL/3D7suW6s7t1hi26mC3KOYEqQUeUoRieywWsZmOmZMPjfb0VwYPoFFPZIU24iLnZcxSM+p1jOF9WGSYS4PpJCuYYAOYO6sYohdvDi1y1rkjxkItrT8xTp189lPSjoRh2S9Z//4jbgv6xJyauuYtuvtzbE/FY1bnTb/ek/n0PcIW3h5I4ruoL+cqpynuaRfsg0s9IKQxiPvz/AzLTA5Q2dfjAPFi8gqSDUGJryb3ZXTJN6zW/3h4gO9nKwsjGRtnCZV53yQrLqWyCs0OdrzcSquoDYQifvx+dGBe1vvZKGkhLV4EuEHnn1TM3WA+K/VvhmWj49nWSAFPLQ098DNqVvu3RZRyqzVsqO8MQItuZChvIbTCS8tKb7LaVHVD04WwU0bx5GYCgZGksMnPeVYfSynMneTwJlLGlfeC5WCHAV15ns8YTRUZSPD30yN88Tg31YSd9p4/Hb3NTj+1uUk+zv0tv/MRvVDvIBHybpLtfF0t22HqTeGLS7kRJiiked15H2XcpwHC4oWvHo83q57gsj0852mBcDYXZfGfiaxVceqCcgFyQrMHXSwg93bi+zLe4lUUs5nxGhWdCJ5kQO9I38K5ww== 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:(13230016)(4636009)(376002)(39860400002)(396003)(346002)(136003)(40470700004)(36840700001)(46966006)(40460700003)(81166007)(4326008)(316002)(70206006)(8676002)(8936002)(70586007)(478600001)(40480700001)(55446002)(82310400005)(5660300002)(83380400001)(47076005)(336012)(42882007)(2876002)(36756003)(36860700001)(6666004)(9686003)(26005)(82740400003)(356005)(83170400001)(186003)(54906003)(2906002)(110136005)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 18:31:04.2084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cfae20f0-cc18-457d-cdcb-08da6a7e0124 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: CO1NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5294 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Requires storing VF index in struct efx_rep. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_rep.c | 39 ++++++++++++++++++++++++++-- drivers/net/ethernet/sfc/ef100_rep.h | 2 ++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c index 1121bf162b2f..0b4f7d536ae6 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.c +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -14,9 +14,11 @@ #define EFX_EF100_REP_DRIVER "efx_ef100_rep" -static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv) +static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv, + unsigned int i) { efv->parent = efx; + efv->idx = i; INIT_LIST_HEAD(&efv->list); efv->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | NETIF_MSG_IFDOWN | @@ -25,7 +27,40 @@ static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv) return 0; } +static int efx_ef100_rep_get_port_parent_id(struct net_device *dev, + struct netdev_phys_item_id *ppid) +{ + struct efx_rep *efv = netdev_priv(dev); + struct efx_nic *efx = efv->parent; + struct ef100_nic_data *nic_data; + + nic_data = efx->nic_data; + /* nic_data->port_id is a u8[] */ + ppid->id_len = sizeof(nic_data->port_id); + memcpy(ppid->id, nic_data->port_id, sizeof(nic_data->port_id)); + return 0; +} + +static int efx_ef100_rep_get_phys_port_name(struct net_device *dev, + char *buf, size_t len) +{ + struct efx_rep *efv = netdev_priv(dev); + struct efx_nic *efx = efv->parent; + struct ef100_nic_data *nic_data; + int ret; + + nic_data = efx->nic_data; + ret = snprintf(buf, len, "p%upf%uvf%u", efx->port_num, + nic_data->pf_index, efv->idx); + if (ret >= len) + return -EOPNOTSUPP; + + return 0; +} + static const struct net_device_ops efx_ef100_rep_netdev_ops = { + .ndo_get_port_parent_id = efx_ef100_rep_get_port_parent_id, + .ndo_get_phys_port_name = efx_ef100_rep_get_phys_port_name, }; static void efx_ef100_rep_get_drvinfo(struct net_device *dev, @@ -67,7 +102,7 @@ static struct efx_rep *efx_ef100_rep_create_netdev(struct efx_nic *efx, return ERR_PTR(-ENOMEM); efv = netdev_priv(net_dev); - rc = efx_ef100_rep_init_struct(efx, efv); + rc = efx_ef100_rep_init_struct(efx, efv, i); if (rc) goto fail1; efv->net_dev = net_dev; diff --git a/drivers/net/ethernet/sfc/ef100_rep.h b/drivers/net/ethernet/sfc/ef100_rep.h index 7d85811f0adb..235565869619 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.h +++ b/drivers/net/ethernet/sfc/ef100_rep.h @@ -21,12 +21,14 @@ * @parent: the efx PF which manages this representor * @net_dev: representor netdevice * @msg_enable: log message enable flags + * @idx: VF index * @list: entry on efx->vf_reps */ struct efx_rep { struct efx_nic *parent; struct net_device *net_dev; u32 msg_enable; + unsigned int idx; struct list_head list; }; From patchwork Wed Jul 20 18:29:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12924379 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 63EE6C433EF for ; Wed, 20 Jul 2022 18:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240939AbiGTSbT (ORCPT ); Wed, 20 Jul 2022 14:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240919AbiGTSbI (ORCPT ); Wed, 20 Jul 2022 14:31:08 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2051.outbound.protection.outlook.com [40.107.220.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33A124BD08 for ; Wed, 20 Jul 2022 11:31:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LthrQqeYUc1Y/b3DvNnK08vWNk6TcNrLu5VK1VUSxp242TT1SPuJrSAldLTseZNKqXQKvG/3ZlmOYDsQLUuwf2LNt6DCBsf/R9apuAcpxJKog7Xgg7+WJ4LtElvyVG8qaIhsdtpoICKecefMJOpRgBvUN/pdfV4k0c8ejXPfZgqAo/phTog/WFFVdsk6UEwllg2pSyLE2CcoxuJmrPJXpE9wf5BXhh6fEIl/7YdMwzyJGJTTcr5ohrnEF67vJ5UNb/ZAPz3a147Gu5yE7lJ4DGjxDIZqFJ668aW5hOjPJD3yyBCv8afA0Vq+Be8s/ac66EF1TcIvZpRKgdCrnxAkBg== 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=g0NAmz/Q8Du0IHDC+BeK9+dh+znfxRA5WQTiVuPlAFU=; b=L1u319QS0T4jaQRdirqjP0XccSAlWmPsb9A3nxQo3ppOHVHC2cN6rAiacCTzYx4GoTqEYhTf0ETOU7XcYJ2GClotBXC3cHD3JmcXNJWUW6OswrKLeFaG69FfwlSU2DGDQVhM709Wgggklw9KsNklIOJcpczEww/vIRcjlhCN3fPX3PNrQ7HkXAOPiQh3vJkhRGx4AtGXwUDsaLbQ+o2KhurXiiVCXSctTP93/WDiPyqqa3Kf4mVMH2+MYq4DH5ANF5edLvJBoJi08ssMqdiS8VO7Ho8I961yHXmRLDfC6L30eQ5vnZsT/scXc5EWf22XlnGJ1G90D50VIrx8dUVuFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g0NAmz/Q8Du0IHDC+BeK9+dh+znfxRA5WQTiVuPlAFU=; b=xhH51JrTqjtwGr7XKxo68mgfgQeN9PtiqIgQhFoSITcXsP2IsJ7Wxsnbqdz8ThL34+Ij9uV7Z8117qTQoQc5gULrEfKXLSWKBnO+fxSlPNHlTo8PSmMu5Y2YMSqRKcUQKYBu+li3Dqq9IAcZ97IRWftI/hWNXnm/O2W2wJEZopT34/P46+UzR0crbWY3P/D2kOk+tonuQErVSasHEfSdicMUxMVYJUDjrp38j8cYDmn6MOVHf3h7i3hnSc4K4XMWzxx/SPeaMSy/eNtt1B9wm2sZPk0adIXuy4P04MZIt/CnBqou+BnjyNewDS7xmQ2aL7ccG3ZiqjGl4593+T+3Gg== Received: from DM6PR03CA0051.namprd03.prod.outlook.com (2603:10b6:5:100::28) by DM6PR12MB2907.namprd12.prod.outlook.com (2603:10b6:5:183::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.21; Wed, 20 Jul 2022 18:31:04 +0000 Received: from DM6NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:5:100:cafe::c8) by DM6PR03CA0051.outlook.office365.com (2603:10b6:5:100::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.21 via Frontend Transport; Wed, 20 Jul 2022 18:31:04 +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=fail action=none header.from=xilinx.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 DM6NAM11FT031.mail.protection.outlook.com (10.13.172.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5458.17 via Frontend Transport; Wed, 20 Jul 2022 18:31:04 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.28; Wed, 20 Jul 2022 13:31:03 -0500 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.28; Wed, 20 Jul 2022 11:31:02 -0700 Received: from xcbecree41x.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.28 via Frontend Transport; Wed, 20 Jul 2022 13:31:01 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH v3 net-next 6/9] sfc: determine representee m-port for EF100 representors Date: Wed, 20 Jul 2022 19:29:34 +0100 Message-ID: <7c76889271f6e73bbbdd239cc8615a46cd46adad.1658341691.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75ef219e-f3bc-412a-7407-08da6a7e0154 X-MS-TrafficTypeDiagnostic: DM6PR12MB2907:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V0uZbLG7RXfOqhFgmb7Kyr3T0qD3h6+nttPbbgpojJFn0RK0/Niax8um3+aXTWmskwleleTkqDS837lWLIO7ThJ6wmlaRbV7MsF7N8rfnpYJNOQVQmSIzkYL1uREV9iByvxJQh5w02OMAfvVqJqVp/3nnVB725mUo1877t8RCe4OmHexVQoPjG7leEH7d/WPclEZQnusKey2Oq7+3jxwBqVKg5bZywkBjbJFesBXOE1Su2V9Kbui1mjWQFB0FufQAJSgaFKQqXM0GJDqok9me3phrM2+U/ht7XoqHmV5WiLrW3xwQ2Ixno7ogbJPh3TQDQAG8qfjGtB0280tY5/AY80djQ8YfgihM/MsxzblgKb2xSUMi9Fyi+69MFkdzI7IuXsf+0rzeh9uuzBVRXkts7RhWCdSdhN8WtvUxIJIeox5pUbDbQwEEguPlu2k2UtxQdAawSwZGO8hFjUdMN0+r8j88oONr0eCAtRMS7QDslbhrJdORC/8vSIWygZzt3guHmaD+gzHi25bGZzeNI3djRo9BkeQ5TvJI/IprN43qjTNg/4j7Lty2N/xPctzs2vxs1Xr+96vxPvZUkS18jdYF8c2IME64ZXi/LgvB0x/+JKgEhtR66O5LkzXoQ9jMDVvPWrZWPOuuPNwBayhrq5f1OwOh0ZwVVu5lYfEY8AotxtvZXHMalivCtvCBGb6SvcferH/9nDIXnWZM+RPLTNfotW5+4dnKRtB8L6b59dr7HrRapNZr0TQbItUH/O+/LTQBZ0DmUYNhdXnEidsfwgPUUAvZX33+9kdTcECrNYF2ReTf6AVG4F3o/LIs7fInC5hCvV0H39rwVF8ph1cGBZatJjuqnzUjb2wnLq6bpdHPUM= 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:(13230016)(4636009)(346002)(396003)(39860400002)(136003)(376002)(36840700001)(40470700004)(46966006)(70586007)(82740400003)(356005)(36756003)(83380400001)(83170400001)(36860700001)(40460700003)(55446002)(81166007)(186003)(42882007)(47076005)(8936002)(336012)(478600001)(110136005)(6666004)(70206006)(54906003)(2906002)(41300700001)(26005)(316002)(4326008)(9686003)(40480700001)(82310400005)(2876002)(5660300002)(8676002)(2004002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 18:31:04.5519 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75ef219e-f3bc-412a-7407-08da6a7e0154 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: DM6NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2907 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree An MAE port, or m-port, is a port (source/destination for traffic) on the Match-Action Engine (the internal switch on EF100). Representors will use their representee's m-port for two purposes: as a destination override on TX from the representor, and as a source match in 'default rules' to steer representee traffic (when not matched by e.g. a TC flower rule) to representor RX via the parent PF's receive queue. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/Makefile | 2 +- drivers/net/ethernet/sfc/ef100_rep.c | 27 +++++++++++++++++ drivers/net/ethernet/sfc/ef100_rep.h | 2 ++ drivers/net/ethernet/sfc/mae.c | 44 ++++++++++++++++++++++++++++ drivers/net/ethernet/sfc/mae.h | 22 ++++++++++++++ 5 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/sfc/mae.c create mode 100644 drivers/net/ethernet/sfc/mae.h diff --git a/drivers/net/ethernet/sfc/Makefile b/drivers/net/ethernet/sfc/Makefile index 7a6772bfde06..4c759488fc77 100644 --- a/drivers/net/ethernet/sfc/Makefile +++ b/drivers/net/ethernet/sfc/Makefile @@ -8,7 +8,7 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \ ef100.o ef100_nic.o ef100_netdev.o \ ef100_ethtool.o ef100_rx.o ef100_tx.o sfc-$(CONFIG_SFC_MTD) += mtd.o -sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o +sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o mae.o obj-$(CONFIG_SFC) += sfc.o diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c index 0b4f7d536ae6..cf0eac920592 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.c +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -11,6 +11,7 @@ #include "ef100_rep.h" #include "ef100_nic.h" +#include "mae.h" #define EFX_EF100_REP_DRIVER "efx_ef100_rep" @@ -124,6 +125,25 @@ static struct efx_rep *efx_ef100_rep_create_netdev(struct efx_nic *efx, return ERR_PTR(rc); } +static int efx_ef100_configure_rep(struct efx_rep *efv) +{ + struct efx_nic *efx = efv->parent; + u32 selector; + int rc; + + /* Construct mport selector for corresponding VF */ + efx_mae_mport_vf(efx, efv->idx, &selector); + /* Look up actual mport ID */ + rc = efx_mae_lookup_mport(efx, selector, &efv->mport); + if (rc) + return rc; + pci_dbg(efx->pci_dev, "VF %u has mport ID %#x\n", efv->idx, efv->mport); + /* mport label should fit in 16 bits */ + WARN_ON(efv->mport >> 16); + + return 0; +} + static void efx_ef100_rep_destroy_netdev(struct efx_rep *efv) { struct efx_nic *efx = efv->parent; @@ -147,6 +167,13 @@ int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i) rc); return rc; } + rc = efx_ef100_configure_rep(efv); + if (rc) { + pci_err(efx->pci_dev, + "Failed to configure representor for VF %d, rc %d\n", + i, rc); + goto fail; + } rc = register_netdev(efv->net_dev); if (rc) { pci_err(efx->pci_dev, diff --git a/drivers/net/ethernet/sfc/ef100_rep.h b/drivers/net/ethernet/sfc/ef100_rep.h index 235565869619..1d17aaf6cd5c 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.h +++ b/drivers/net/ethernet/sfc/ef100_rep.h @@ -21,6 +21,7 @@ * @parent: the efx PF which manages this representor * @net_dev: representor netdevice * @msg_enable: log message enable flags + * @mport: m-port ID of corresponding VF * @idx: VF index * @list: entry on efx->vf_reps */ @@ -28,6 +29,7 @@ struct efx_rep { struct efx_nic *parent; struct net_device *net_dev; u32 msg_enable; + u32 mport; unsigned int idx; struct list_head list; }; diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c new file mode 100644 index 000000000000..011ebd46ada5 --- /dev/null +++ b/drivers/net/ethernet/sfc/mae.c @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0-only +/**************************************************************************** + * Driver for Solarflare network controllers and boards + * Copyright 2019 Solarflare Communications Inc. + * Copyright 2020-2022 Xilinx 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 "mae.h" +#include "mcdi.h" +#include "mcdi_pcol.h" + +void efx_mae_mport_vf(struct efx_nic *efx __always_unused, u32 vf_id, u32 *out) +{ + efx_dword_t mport; + + EFX_POPULATE_DWORD_3(mport, + MAE_MPORT_SELECTOR_TYPE, MAE_MPORT_SELECTOR_TYPE_FUNC, + MAE_MPORT_SELECTOR_FUNC_PF_ID, MAE_MPORT_SELECTOR_FUNC_PF_ID_CALLER, + MAE_MPORT_SELECTOR_FUNC_VF_ID, vf_id); + *out = EFX_DWORD_VAL(mport); +} + +/* id is really only 24 bits wide */ +int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id) +{ + MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_MPORT_LOOKUP_OUT_LEN); + MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_MPORT_LOOKUP_IN_LEN); + size_t outlen; + int rc; + + MCDI_SET_DWORD(inbuf, MAE_MPORT_LOOKUP_IN_MPORT_SELECTOR, selector); + rc = efx_mcdi_rpc(efx, MC_CMD_MAE_MPORT_LOOKUP, inbuf, sizeof(inbuf), + outbuf, sizeof(outbuf), &outlen); + if (rc) + return rc; + if (outlen < sizeof(outbuf)) + return -EIO; + *id = MCDI_DWORD(outbuf, MAE_MPORT_LOOKUP_OUT_MPORT_ID); + return 0; +} diff --git a/drivers/net/ethernet/sfc/mae.h b/drivers/net/ethernet/sfc/mae.h new file mode 100644 index 000000000000..27e69e8a54b6 --- /dev/null +++ b/drivers/net/ethernet/sfc/mae.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/**************************************************************************** + * Driver for Solarflare network controllers and boards + * Copyright 2019 Solarflare Communications Inc. + * Copyright 2020-2022 Xilinx 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 EF100_MAE_H +#define EF100_MAE_H +/* MCDI interface for the ef100 Match-Action Engine */ + +#include "net_driver.h" + +void efx_mae_mport_vf(struct efx_nic *efx, u32 vf_id, u32 *out); + +int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id); + +#endif /* EF100_MAE_H */ From patchwork Wed Jul 20 18:33:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12924382 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 1FF28CCA485 for ; Wed, 20 Jul 2022 18:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230491AbiGTSeQ (ORCPT ); Wed, 20 Jul 2022 14:34:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbiGTSeN (ORCPT ); Wed, 20 Jul 2022 14:34:13 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2088.outbound.protection.outlook.com [40.107.223.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6837173D for ; Wed, 20 Jul 2022 11:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nJMyciNJEXDJQ2c7v0/SAVdbwYeCB9ZgugcQOS5lbxyff4oPX7wHBuI8SRCDz1XE3bVpCWlNmoeLayRjQN+7dXCLex4h38pJSAoqCgOwOIl9Ahnon+UsGUkbCzBMSxIqZF5T5JFQgvWfYKaOVVUOhMalm2YIsBeDPh4UkUXnqXtz1MX06xeWHI/7VFTKpCfLU51lUOSYVfmO2zWp+huHZT7OKU6OdsnmFQvKcXUz20fnzPhNJ1PHVzfqMGO6qJ2SSRhR+EG5JoYzvLbxxetolW0HhLRO31UEebyic5AuFk6LehNJ3AJWp2OUNSpagWDXk2uHmROBpe05KHwMZE0tKA== 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=l+lnXKUBmb/sOxUIWMROnw8li5pp27ebFnI6xsHH0hY=; b=MvsmNdIunosf3iMiiBkGw+YMg0VCO7eRs3IADHPRAXCQ4aoNzoEyJCD+Bbt7XBXe5d1lVOVAeAFrlb96Ublp8OF6BwtbNLM2S6LEAFnoa6/lqoBu88IfGgtYSe2spBDkNAmJ/4jk9ncSnm3lB9OGfwlQRMJlxRcdcBNj7ic7PUfVhBa9G/Ovzk4txgDn1MMHR76NGw/48iiq4TXZCBAQfCNguU6PvqN3ADM8SC/gbMOp8SF8ZKkeTqo2i/Mmy/eCQiv256zZhc3J83ovUu57FsouMncS4fCWuoK6LRf2KZrk3ab7rbPyypzAHl5kRE7V6Vt1DAwzbzubHSOrZMW2PQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l+lnXKUBmb/sOxUIWMROnw8li5pp27ebFnI6xsHH0hY=; b=IeST1L4t0vQecbGZ5rTLaZf5k609TGdCId4qYUToApLdJvafoNu2novZWftOye12C3o9IcZYgK45hvmMrKmDgw6gBAW3paBSBCUCHM6N/OhLs455c+GT55eNJoletRF9PhSN+bP1flPeEZnzJZpAM8yyDaup3jLuKTnCrwb64L0JuBYkeT45SILvRDYORio1iRCYjcNp4r0RO38d8f5x/bCNokXrkQpIAyyMP67ZLyOB84YxO4Ss7ZOJD6pTC6tARmgr0A/TlyOQUIGwxor3nvnsgDzmo+6FSTVKkmfUhGz9gedeKCZgiGqBriqOz/kSfPwg2RrVBTC3gaP6XbEMNg== Received: from MW4PR03CA0024.namprd03.prod.outlook.com (2603:10b6:303:8f::29) by CH2PR12MB3751.namprd12.prod.outlook.com (2603:10b6:610:25::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Wed, 20 Jul 2022 18:34:07 +0000 Received: from CO1NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8f:cafe::f5) by MW4PR03CA0024.outlook.office365.com (2603:10b6:303:8f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15 via Frontend Transport; Wed, 20 Jul 2022 18:34:07 +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=fail action=none header.from=xilinx.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 CO1NAM11FT013.mail.protection.outlook.com (10.13.174.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5458.17 via Frontend Transport; Wed, 20 Jul 2022 18:34:07 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.28; Wed, 20 Jul 2022 13:34:06 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 20 Jul 2022 13:34:05 -0500 Received: from xcbecree41x.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.28 via Frontend Transport; Wed, 20 Jul 2022 13:34:04 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH v3 net-next 7/9] sfc: support passing a representor to the EF100 TX path Date: Wed, 20 Jul 2022 19:33:47 +0100 Message-ID: <20220720183349.29448-1-ecree@xilinx.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 009a7c1c-9753-4a7d-2456-08da6a7e6e4b X-MS-TrafficTypeDiagnostic: CH2PR12MB3751:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RsTpRb+ab2c9hCvb+kTCmGCmZzLXltVaTNAYcLz3EjZWM3TMOZ7TxqNxv5BFs2dxSY/qtRiErhgv8LePRdIzV+ot8Jdy1lgJULB6rOcwuWIRx5OrHP9hkXC/C9tuehuEiufUCixhjEsM+HfqZ0IT2/2FludxCGI1McuPCaFcRbGAgR9wZemzYe3p5w7hLChKaU+UWsPTOssfDXRAf3iBkCqPuZKN7/J/egRvVml5cEFXSv1wXl0Nzq47eIVLuDktRlI1zdIkeH8DAuJmpiVUnzQu3uZ/w+E4QQmpuFLyyDJdKqZixCPh84wJz1deJlL1xjbESIHtR/tj1b7E+s6o+wdWPcbTPd9zlY9byiENa4kUMV67WwdlqiITi7bFlvZ2XQS3m53EjoykTag/F8656i4YoSVMJXwUDAWbNExCoWY/RPCWShptyn2aM+ekfnR0am4+yGmgBINFxG1Cqs1nTWoPIAWiSQO1t51tLfzCGVeN7HZwPeViP8Wd+07c9Ykb0DkS71XqMqMCv0EW9X+jweOveZI0qcITPHTvQMm44urtKHgvZOfIcBCXy+trsFYqySeSUHF8v/13gdzzXNnPvgVMWjGzXqKH08KbWIlTf69w8ROfSS9jDjK+jblC9U/bg8Y2O5bLwZ2PbSCQCD5QeaG994fh/R1iHo1kHKa2bA1I7H0GtZObKuW9YObYLEQq3worYMY3s/+SWMR2K6AGTzPKZ/Ggo4lNIG2+7axwg2KAkhdDBvqSpM2vdq6aGAlKVplJdW6F0ntgjmid6t6HgBZrm4rxYHVTXSlg+JwvzccCDBPDm89IHYrSIMPS0QSjbzLkXfhv+6bRpmoHW9t4iA== 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:(13230016)(4636009)(136003)(396003)(376002)(39860400002)(346002)(46966006)(40470700004)(36840700001)(70586007)(70206006)(54906003)(40460700003)(110136005)(316002)(26005)(47076005)(36860700001)(83380400001)(42882007)(8676002)(336012)(40480700001)(2876002)(36756003)(4326008)(82310400005)(186003)(2906002)(41300700001)(6666004)(8936002)(83170400001)(7696005)(81166007)(478600001)(1076003)(30864003)(82740400003)(356005)(2616005)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 18:34:07.3313 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 009a7c1c-9753-4a7d-2456-08da6a7e6e4b 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: CO1NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3751 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree A non-null efv in __ef100_enqueue_skb() indicates that the packet is from that representor, should be transmitted with a suitable option descriptor (to instruct the switch to deliver it to the representee), and should not be accounted to the parent PF's stats or BQL. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_rep.h | 8 +++ drivers/net/ethernet/sfc/ef100_tx.c | 84 +++++++++++++++++++++++++-- drivers/net/ethernet/sfc/ef100_tx.h | 3 + drivers/net/ethernet/sfc/net_driver.h | 1 + drivers/net/ethernet/sfc/tx.c | 6 +- drivers/net/ethernet/sfc/tx_common.c | 35 +++++++---- drivers/net/ethernet/sfc/tx_common.h | 3 +- 7 files changed, 123 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef100_rep.h b/drivers/net/ethernet/sfc/ef100_rep.h index 1d17aaf6cd5c..d47fd8ff6220 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.h +++ b/drivers/net/ethernet/sfc/ef100_rep.h @@ -15,6 +15,12 @@ #include "net_driver.h" +struct efx_rep_sw_stats { + atomic64_t rx_packets, tx_packets; + atomic64_t rx_bytes, tx_bytes; + atomic64_t rx_dropped, tx_errors; +}; + /** * struct efx_rep - Private data for an Efx representor * @@ -24,6 +30,7 @@ * @mport: m-port ID of corresponding VF * @idx: VF index * @list: entry on efx->vf_reps + * @stats: software traffic counters for netdev stats */ struct efx_rep { struct efx_nic *parent; @@ -32,6 +39,7 @@ struct efx_rep { u32 mport; unsigned int idx; struct list_head list; + struct efx_rep_sw_stats stats; }; int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i); diff --git a/drivers/net/ethernet/sfc/ef100_tx.c b/drivers/net/ethernet/sfc/ef100_tx.c index 26ef51d6b542..102ddc7e206a 100644 --- a/drivers/net/ethernet/sfc/ef100_tx.c +++ b/drivers/net/ethernet/sfc/ef100_tx.c @@ -254,7 +254,8 @@ static void ef100_make_tso_desc(struct efx_nic *efx, static void ef100_tx_make_descriptors(struct efx_tx_queue *tx_queue, const struct sk_buff *skb, - unsigned int segment_count) + unsigned int segment_count, + struct efx_rep *efv) { unsigned int old_write_count = tx_queue->write_count; unsigned int new_write_count = old_write_count; @@ -272,6 +273,20 @@ static void ef100_tx_make_descriptors(struct efx_tx_queue *tx_queue, else next_desc_type = ESE_GZ_TX_DESC_TYPE_SEND; + if (unlikely(efv)) { + /* Create TX override descriptor */ + write_ptr = new_write_count & tx_queue->ptr_mask; + txd = ef100_tx_desc(tx_queue, write_ptr); + ++new_write_count; + + tx_queue->packet_write_count = new_write_count; + EFX_POPULATE_OWORD_3(*txd, + ESF_GZ_TX_DESC_TYPE, ESE_GZ_TX_DESC_TYPE_PREFIX, + ESF_GZ_TX_PREFIX_EGRESS_MPORT, efv->mport, + ESF_GZ_TX_PREFIX_EGRESS_MPORT_EN, 1); + nr_descs--; + } + /* if it's a raw write (such as XDP) then always SEND single frames */ if (!skb) nr_descs = 1; @@ -306,6 +321,9 @@ static void ef100_tx_make_descriptors(struct efx_tx_queue *tx_queue, /* if it's a raw write (such as XDP) then always SEND */ next_desc_type = skb ? ESE_GZ_TX_DESC_TYPE_SEG : ESE_GZ_TX_DESC_TYPE_SEND; + /* mark as an EFV buffer if applicable */ + if (unlikely(efv)) + buffer->flags |= EFX_TX_BUF_EFV; } while (new_write_count != tx_queue->insert_count); @@ -324,7 +342,7 @@ static void ef100_tx_make_descriptors(struct efx_tx_queue *tx_queue, void ef100_tx_write(struct efx_tx_queue *tx_queue) { - ef100_tx_make_descriptors(tx_queue, NULL, 0); + ef100_tx_make_descriptors(tx_queue, NULL, 0, NULL); ef100_tx_push_buffers(tx_queue); } @@ -350,6 +368,12 @@ void ef100_ev_tx(struct efx_channel *channel, const efx_qword_t *p_event) * function will free the SKB. */ int ef100_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb) +{ + return __ef100_enqueue_skb(tx_queue, skb, NULL); +} + +int __ef100_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb, + struct efx_rep *efv) { unsigned int old_insert_count = tx_queue->insert_count; struct efx_nic *efx = tx_queue->efx; @@ -376,16 +400,64 @@ int ef100_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb) return 0; } + if (unlikely(efv)) { + struct efx_tx_buffer *buffer = __efx_tx_queue_get_insert_buffer(tx_queue); + + /* Drop representor packets if the queue is stopped. + * We currently don't assert backoff to representors so this is + * to make sure representor traffic can't starve the main + * net device. + * And, of course, if there are no TX descriptors left. + */ + if (netif_tx_queue_stopped(tx_queue->core_txq) || + unlikely(efx_tx_buffer_in_use(buffer))) { + atomic64_inc(&efv->stats.tx_errors); + rc = -ENOSPC; + goto err; + } + + /* Also drop representor traffic if it could cause us to + * stop the queue. If we assert backoff and we haven't + * received traffic on the main net device recently then the + * TX watchdog can go off erroneously. + */ + fill_level = efx_channel_tx_old_fill_level(tx_queue->channel); + fill_level += efx_tx_max_skb_descs(efx); + if (fill_level > efx->txq_stop_thresh) { + struct efx_tx_queue *txq2; + + /* Refresh cached fill level and re-check */ + efx_for_each_channel_tx_queue(txq2, tx_queue->channel) + txq2->old_read_count = READ_ONCE(txq2->read_count); + + fill_level = efx_channel_tx_old_fill_level(tx_queue->channel); + fill_level += efx_tx_max_skb_descs(efx); + if (fill_level > efx->txq_stop_thresh) { + atomic64_inc(&efv->stats.tx_errors); + rc = -ENOSPC; + goto err; + } + } + + buffer->flags = EFX_TX_BUF_OPTION | EFX_TX_BUF_EFV; + tx_queue->insert_count++; + } + /* Map for DMA and create descriptors */ rc = efx_tx_map_data(tx_queue, skb, segments); if (rc) goto err; - ef100_tx_make_descriptors(tx_queue, skb, segments); + ef100_tx_make_descriptors(tx_queue, skb, segments, efv); fill_level = efx_channel_tx_old_fill_level(tx_queue->channel); if (fill_level > efx->txq_stop_thresh) { struct efx_tx_queue *txq2; + /* Because of checks above, representor traffic should + * not be able to stop the queue. + */ + WARN_ON(efv); + netif_tx_stop_queue(tx_queue->core_txq); /* Re-read after a memory barrier in case we've raced with * the completion path. Otherwise there's a danger we'll never @@ -404,8 +476,12 @@ int ef100_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb) /* If xmit_more then we don't need to push the doorbell, unless there * are 256 descriptors already queued in which case we have to push to * ensure we never push more than 256 at once. + * + * Always push for representor traffic, and don't account it to parent + * PF netdevice's BQL. */ - if (__netdev_tx_sent_queue(tx_queue->core_txq, skb->len, xmit_more) || + if (unlikely(efv) || + __netdev_tx_sent_queue(tx_queue->core_txq, skb->len, xmit_more) || tx_queue->write_count - tx_queue->notify_count > 255) ef100_tx_push_buffers(tx_queue); diff --git a/drivers/net/ethernet/sfc/ef100_tx.h b/drivers/net/ethernet/sfc/ef100_tx.h index ddc4b98fa6db..e9e11540fcde 100644 --- a/drivers/net/ethernet/sfc/ef100_tx.h +++ b/drivers/net/ethernet/sfc/ef100_tx.h @@ -13,6 +13,7 @@ #define EFX_EF100_TX_H #include "net_driver.h" +#include "ef100_rep.h" int ef100_tx_probe(struct efx_tx_queue *tx_queue); void ef100_tx_init(struct efx_tx_queue *tx_queue); @@ -22,4 +23,6 @@ unsigned int ef100_tx_max_skb_descs(struct efx_nic *efx); void ef100_ev_tx(struct efx_channel *channel, const efx_qword_t *p_event); netdev_tx_t ef100_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb); +int __ef100_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb, + struct efx_rep *efv); #endif diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 037cfa184764..4cde54cf77b9 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -178,6 +178,7 @@ struct efx_tx_buffer { #define EFX_TX_BUF_OPTION 0x10 /* empty buffer for option descriptor */ #define EFX_TX_BUF_XDP 0x20 /* buffer was sent with XDP */ #define EFX_TX_BUF_TSO_V3 0x40 /* empty buffer for a TSO_V3 descriptor */ +#define EFX_TX_BUF_EFV 0x100 /* buffer was sent from representor */ /** * struct efx_tx_queue - An Efx TX queue diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c index 79cc0bb76321..d12474042c84 100644 --- a/drivers/net/ethernet/sfc/tx.c +++ b/drivers/net/ethernet/sfc/tx.c @@ -559,6 +559,7 @@ netdev_tx_t efx_hard_start_xmit(struct sk_buff *skb, void efx_xmit_done_single(struct efx_tx_queue *tx_queue) { unsigned int pkts_compl = 0, bytes_compl = 0; + unsigned int efv_pkts_compl = 0; unsigned int read_ptr; bool finished = false; @@ -580,7 +581,8 @@ void efx_xmit_done_single(struct efx_tx_queue *tx_queue) /* Need to check the flag before dequeueing. */ if (buffer->flags & EFX_TX_BUF_SKB) finished = true; - efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl); + efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl, + &efv_pkts_compl); ++tx_queue->read_count; read_ptr = tx_queue->read_count & tx_queue->ptr_mask; @@ -589,7 +591,7 @@ void efx_xmit_done_single(struct efx_tx_queue *tx_queue) tx_queue->pkts_compl += pkts_compl; tx_queue->bytes_compl += bytes_compl; - EFX_WARN_ON_PARANOID(pkts_compl != 1); + EFX_WARN_ON_PARANOID(pkts_compl + efv_pkts_compl != 1); efx_xmit_done_check_empty(tx_queue); } diff --git a/drivers/net/ethernet/sfc/tx_common.c b/drivers/net/ethernet/sfc/tx_common.c index 658ea2d34070..67e789b96c43 100644 --- a/drivers/net/ethernet/sfc/tx_common.c +++ b/drivers/net/ethernet/sfc/tx_common.c @@ -109,9 +109,11 @@ void efx_fini_tx_queue(struct efx_tx_queue *tx_queue) /* Free any buffers left in the ring */ while (tx_queue->read_count != tx_queue->write_count) { unsigned int pkts_compl = 0, bytes_compl = 0; + unsigned int efv_pkts_compl = 0; buffer = &tx_queue->buffer[tx_queue->read_count & tx_queue->ptr_mask]; - efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl); + efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl, + &efv_pkts_compl); ++tx_queue->read_count; } @@ -146,7 +148,8 @@ void efx_remove_tx_queue(struct efx_tx_queue *tx_queue) void efx_dequeue_buffer(struct efx_tx_queue *tx_queue, struct efx_tx_buffer *buffer, unsigned int *pkts_compl, - unsigned int *bytes_compl) + unsigned int *bytes_compl, + unsigned int *efv_pkts_compl) { if (buffer->unmap_len) { struct device *dma_dev = &tx_queue->efx->pci_dev->dev; @@ -164,9 +167,15 @@ void efx_dequeue_buffer(struct efx_tx_queue *tx_queue, if (buffer->flags & EFX_TX_BUF_SKB) { struct sk_buff *skb = (struct sk_buff *)buffer->skb; - EFX_WARN_ON_PARANOID(!pkts_compl || !bytes_compl); - (*pkts_compl)++; - (*bytes_compl) += skb->len; + if (unlikely(buffer->flags & EFX_TX_BUF_EFV)) { + EFX_WARN_ON_PARANOID(!efv_pkts_compl); + (*efv_pkts_compl)++; + } else { + EFX_WARN_ON_PARANOID(!pkts_compl || !bytes_compl); + (*pkts_compl)++; + (*bytes_compl) += skb->len; + } + if (tx_queue->timestamping && (tx_queue->completed_timestamp_major || tx_queue->completed_timestamp_minor)) { @@ -199,7 +208,8 @@ void efx_dequeue_buffer(struct efx_tx_queue *tx_queue, static void efx_dequeue_buffers(struct efx_tx_queue *tx_queue, unsigned int index, unsigned int *pkts_compl, - unsigned int *bytes_compl) + unsigned int *bytes_compl, + unsigned int *efv_pkts_compl) { struct efx_nic *efx = tx_queue->efx; unsigned int stop_index, read_ptr; @@ -218,7 +228,8 @@ static void efx_dequeue_buffers(struct efx_tx_queue *tx_queue, return; } - efx_dequeue_buffer(tx_queue, buffer, pkts_compl, bytes_compl); + efx_dequeue_buffer(tx_queue, buffer, pkts_compl, bytes_compl, + efv_pkts_compl); ++tx_queue->read_count; read_ptr = tx_queue->read_count & tx_queue->ptr_mask; @@ -241,15 +252,17 @@ void efx_xmit_done_check_empty(struct efx_tx_queue *tx_queue) void efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index) { unsigned int fill_level, pkts_compl = 0, bytes_compl = 0; + unsigned int efv_pkts_compl = 0; struct efx_nic *efx = tx_queue->efx; EFX_WARN_ON_ONCE_PARANOID(index > tx_queue->ptr_mask); - efx_dequeue_buffers(tx_queue, index, &pkts_compl, &bytes_compl); + efx_dequeue_buffers(tx_queue, index, &pkts_compl, &bytes_compl, + &efv_pkts_compl); tx_queue->pkts_compl += pkts_compl; tx_queue->bytes_compl += bytes_compl; - if (pkts_compl > 1) + if (pkts_compl + efv_pkts_compl > 1) ++tx_queue->merge_events; /* See if we need to restart the netif queue. This memory @@ -274,6 +287,7 @@ void efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index) void efx_enqueue_unwind(struct efx_tx_queue *tx_queue, unsigned int insert_count) { + unsigned int efv_pkts_compl = 0; struct efx_tx_buffer *buffer; unsigned int bytes_compl = 0; unsigned int pkts_compl = 0; @@ -282,7 +296,8 @@ void efx_enqueue_unwind(struct efx_tx_queue *tx_queue, while (tx_queue->insert_count != insert_count) { --tx_queue->insert_count; buffer = __efx_tx_queue_get_insert_buffer(tx_queue); - efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl); + efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl, + &efv_pkts_compl); } } diff --git a/drivers/net/ethernet/sfc/tx_common.h b/drivers/net/ethernet/sfc/tx_common.h index bbab7f248250..d87aecbc7bf1 100644 --- a/drivers/net/ethernet/sfc/tx_common.h +++ b/drivers/net/ethernet/sfc/tx_common.h @@ -19,7 +19,8 @@ void efx_remove_tx_queue(struct efx_tx_queue *tx_queue); void efx_dequeue_buffer(struct efx_tx_queue *tx_queue, struct efx_tx_buffer *buffer, unsigned int *pkts_compl, - unsigned int *bytes_compl); + unsigned int *bytes_compl, + unsigned int *efv_pkts_compl); static inline bool efx_tx_buffer_in_use(struct efx_tx_buffer *buffer) { From patchwork Wed Jul 20 18:33:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12924380 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 1D24AC433EF for ; Wed, 20 Jul 2022 18:34:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbiGTSeO (ORCPT ); Wed, 20 Jul 2022 14:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbiGTSeN (ORCPT ); Wed, 20 Jul 2022 14:34:13 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2057.outbound.protection.outlook.com [40.107.94.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE99F71BC4 for ; Wed, 20 Jul 2022 11:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UxRnnmxjxF6p1755OiFppo8NoFo0NFCUnea63f8zAWnQvR5It2iXcQjaAB1aeDHpDIxbQ3Xab9nJHiEe2yPwhi9BixUKqi8D/SX1eCKpL8mgdNXi5lkuF3QVjewMGPl6HYjoppQsXu6qcPnd913YAlvWEh8MbskX9kJQSa7D+k1dWOivsjFRudyUwyiM5ekF4qeRezXJaOSuY/vQYY7jZ5Ij8Ag42xwbD+nEB5Q/nfiIth4amrL5qeDVrEaaFmtvZZ2XcT1O4Efov4dc1+C+njCJ0DgRipaaOF1KENKwca4gG9QGWCmlb6XQGACVgqDlkRkiiclwXtFZivDrFpAqHg== 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=Ai17Nip/Ow4qGFBtiy6u21q1ROOifzIXjDoRkWInieQ=; b=NhThGSPnITcGk+p7QtSTywhghGcNgifHCTTLYgVPoWgxhHfrG89FpJkcCYyqkGPAs9WhATFq91aYa0CQuj60nUzB0bMdlsW9PrvXoXmTg9wPHP0sxr+gZlQaksY/J6pIDqOgFrDleqEY0QhEzbiMz0MopiRnZzeoBVnzy1D84ya5v9Re/rryuy/iGo6sCHPbFVAGRtzlml5yzDlHOOsQ8C0W+CsseiiCNvGwfqnkrUqE58H3uptxc3gi4LVan7E8dVQOZndhq0pnyAEpeyGC/0JeanB3DxDZOHJzrfVtm8rGLMp5FJJUwfm/bYschmJUrNTTSV6Ns/2fcgESmbtkYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ai17Nip/Ow4qGFBtiy6u21q1ROOifzIXjDoRkWInieQ=; b=lrNBCfACPfqogomJNB7YTEqp2ecqNtMwXB3JCd9JKY71+lxGL7dRNC2ylMZjaRs6HAfiLG/l1zhj8Z4SP006Ng4JqHh3xGrA75rqNZGQ5nE6ev6lC7M6pCxjTPMek8IIAYrIGrz2j0cLzlWfJMmw43+Go3LAdDKUIHVvjQ5U4y2Cgj8rc49BIewldxIS1matnZQNmBjmY11Z9U+VHhdVY3OdnvjU08yXnXrjVN9Drd3xC3ZV5+VaCklIjfF9AnyUlVqtcmENJbeebpmQQuyY2OyvOE8kpKjLvPZKCWBUYFg0RrHgcms1akJFfKnXsu4v9ZsaayWG0B0W1zEA+Yqw/g== Received: from MW4PR04CA0248.namprd04.prod.outlook.com (2603:10b6:303:88::13) by MW4PR12MB6803.namprd12.prod.outlook.com (2603:10b6:303:20e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.15; Wed, 20 Jul 2022 18:34:09 +0000 Received: from CO1NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:303:88:cafe::72) by MW4PR04CA0248.outlook.office365.com (2603:10b6:303:88::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.24 via Frontend Transport; Wed, 20 Jul 2022 18:34:09 +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=fail action=none header.from=xilinx.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 CO1NAM11FT044.mail.protection.outlook.com (10.13.175.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5458.17 via Frontend Transport; Wed, 20 Jul 2022 18:34:08 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.28; Wed, 20 Jul 2022 13:34:07 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 20 Jul 2022 13:34:07 -0500 Received: from xcbecree41x.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.28 via Frontend Transport; Wed, 20 Jul 2022 13:34:06 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH v3 net-next 8/9] sfc: hook up ef100 representor TX Date: Wed, 20 Jul 2022 19:33:48 +0100 Message-ID: <20220720183349.29448-2-ecree@xilinx.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8bc25a0c-ac58-434f-9b05-08da6a7e6f0b X-MS-TrafficTypeDiagnostic: MW4PR12MB6803:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nmNJJTrNXBP9cGSmOF6oSUzGMjs1EsJLVixeRo02AD0akuOf3Xkb8S+6YQiEyyadgOhEKN+PYAcWYgSgGUWjXJncb5AxMSPS9BAgmVD9KIH17p5PGccPZdSA6f3Ll0X5d2SovFGQRovvb6r9k0++8Ztx8oG1DEL0sxLbgisFcIs0iDoHr9upFCWDzoa7oTqzMnQlQjjULHVFXUFen+UEj6qcx2Mk5g7gbT4A8NO6bXb/4VXh4iHX7Z+XWI8vgYu6TvccOHt9AqT7VEKxDHn2vlL/u0+2SCaq6K+9d3pwaID2T/D4EQ6fEmiWMHMZeMA73GAqpmZm+BnE/a0qoDz1W+eiTqPJv0AsN54RxyecldpgE7gi7yv0i6PcWtw69Bvivura+RT6vK4Z7YA66o/OIvWPM2q72PKPD6g9Y6GE/C11+DURJTwtXYJBA4IboGaD8VFoaLF7vhQsokAV+qD38L3RxI6kQnm4zEYM31G3Mx2HmjfvdpCKKbd+iNjAqePCjM4rrelPd4bIgKyYxVcIsDJi9VbZACi8eowQcwJHaQtQQlCXoIKv4sH156jJ8GSSObbsc8smURV2eKH9XkXtZOeSEh61nU0iWkl7bJ00lKzMmNEXwrk/+HCTcYgXP8MgTK6Sk+ji4vL626wdSHsdy6480qF1oZNJ4RUoMydBExeLgFSjgHWI4UotD988QghH73qv4FmgDcekMAnSaEWHHuDQB8rSuRehRo8UuoOrXvb7OEnHf2/dDag+Pd4Jip0cmpRzwdwhQWVQ39sadrD7X5DX55xjs1PBgAZV9V/r5WN3GT1CxGTaBVcDV1tVGu0qDNzVGA6NSNR3yvyR3AKQMzqttGWorbt5HY1hw87osSaOVREcpuP28U0Mkg6AI9g1gDuey0ouAcWtnDogkebfZA== 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:(13230016)(4636009)(346002)(39860400002)(376002)(396003)(136003)(36840700001)(46966006)(40470700004)(70586007)(81166007)(8936002)(2906002)(4326008)(2876002)(5660300002)(6666004)(41300700001)(54906003)(478600001)(40460700003)(2616005)(82310400005)(83170400001)(82740400003)(336012)(83380400001)(1076003)(7696005)(186003)(36860700001)(356005)(26005)(40480700001)(8676002)(110136005)(316002)(36756003)(70206006)(42882007)(47076005)(52103002)(158003001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 18:34:08.5926 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8bc25a0c-ac58-434f-9b05-08da6a7e6f0b 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: CO1NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6803 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Implement .ndo_start_xmit() by calling into the parent PF's TX path. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_netdev.c | 11 ++++++++++- drivers/net/ethernet/sfc/ef100_netdev.h | 5 +++++ drivers/net/ethernet/sfc/ef100_rep.c | 23 +++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/ef100_netdev.c b/drivers/net/ethernet/sfc/ef100_netdev.c index f4a124b8ffbe..3443477c26da 100644 --- a/drivers/net/ethernet/sfc/ef100_netdev.c +++ b/drivers/net/ethernet/sfc/ef100_netdev.c @@ -195,6 +195,15 @@ static netdev_tx_t ef100_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev) { struct efx_nic *efx = efx_netdev_priv(net_dev); + + return __ef100_hard_start_xmit(skb, efx, net_dev, NULL); +} + +netdev_tx_t __ef100_hard_start_xmit(struct sk_buff *skb, + struct efx_nic *efx, + struct net_device *net_dev, + struct efx_rep *efv) +{ struct efx_tx_queue *tx_queue; struct efx_channel *channel; int rc; @@ -209,7 +218,7 @@ static netdev_tx_t ef100_hard_start_xmit(struct sk_buff *skb, } tx_queue = &channel->tx_queue[0]; - rc = ef100_enqueue_skb(tx_queue, skb); + rc = __ef100_enqueue_skb(tx_queue, skb, efv); if (rc == 0) return NETDEV_TX_OK; diff --git a/drivers/net/ethernet/sfc/ef100_netdev.h b/drivers/net/ethernet/sfc/ef100_netdev.h index 38b032ba0953..86bf985e0951 100644 --- a/drivers/net/ethernet/sfc/ef100_netdev.h +++ b/drivers/net/ethernet/sfc/ef100_netdev.h @@ -10,7 +10,12 @@ */ #include +#include "ef100_rep.h" +netdev_tx_t __ef100_hard_start_xmit(struct sk_buff *skb, + struct efx_nic *efx, + struct net_device *net_dev, + struct efx_rep *efv); int ef100_netdev_event(struct notifier_block *this, unsigned long event, void *ptr); int ef100_probe_netdev(struct efx_probe_data *probe_data); diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c index cf0eac920592..6d4c3f0eee0a 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.c +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -10,6 +10,7 @@ */ #include "ef100_rep.h" +#include "ef100_netdev.h" #include "ef100_nic.h" #include "mae.h" @@ -28,6 +29,25 @@ static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv, return 0; } +static netdev_tx_t efx_ef100_rep_xmit(struct sk_buff *skb, + struct net_device *dev) +{ + struct efx_rep *efv = netdev_priv(dev); + struct efx_nic *efx = efv->parent; + netdev_tx_t rc; + + /* __ef100_hard_start_xmit() will always return success even in the + * case of TX drops, where it will increment efx's tx_dropped. The + * efv stats really only count attempted TX, not success/failure. + */ + atomic64_inc(&efv->stats.tx_packets); + atomic64_add(skb->len, &efv->stats.tx_bytes); + netif_tx_lock(efx->net_dev); + rc = __ef100_hard_start_xmit(skb, efx, dev, efv); + netif_tx_unlock(efx->net_dev); + return rc; +} + static int efx_ef100_rep_get_port_parent_id(struct net_device *dev, struct netdev_phys_item_id *ppid) { @@ -60,6 +80,7 @@ static int efx_ef100_rep_get_phys_port_name(struct net_device *dev, } static const struct net_device_ops efx_ef100_rep_netdev_ops = { + .ndo_start_xmit = efx_ef100_rep_xmit, .ndo_get_port_parent_id = efx_ef100_rep_get_port_parent_id, .ndo_get_phys_port_name = efx_ef100_rep_get_phys_port_name, }; @@ -119,6 +140,8 @@ static struct efx_rep *efx_ef100_rep_create_netdev(struct efx_nic *efx, net_dev->ethtool_ops = &efx_ef100_rep_ethtool_ops; net_dev->min_mtu = EFX_MIN_MTU; net_dev->max_mtu = EFX_MAX_MTU; + net_dev->features |= NETIF_F_LLTX; + net_dev->hw_features |= NETIF_F_LLTX; return efv; fail1: free_netdev(net_dev); From patchwork Wed Jul 20 18:33:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12924381 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 BD339C43334 for ; Wed, 20 Jul 2022 18:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230081AbiGTSeO (ORCPT ); Wed, 20 Jul 2022 14:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbiGTSeN (ORCPT ); Wed, 20 Jul 2022 14:34:13 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2042.outbound.protection.outlook.com [40.107.223.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 422C071BC7 for ; Wed, 20 Jul 2022 11:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zq8fuvM4MOddnO065MZDL6iJrt1mcCACi02yrxl9XL2Co1m8KDTMYOhTZtPTrC6Hl4tGUH4SQqQKwik+cOOCIGgE+v/skXeqPqLnvjZ6lvdvW8XEc2SzZTS/JjZQ0lSO++K8JYfWeS6NrQ+3GC1YPTSdy1Iq+Fde1dSTx3IVzIMdKkNPgUH8OYkwzdS+V/7m1M2wyI0uTp2+h0khqmhmpmgDY7kzZLlqrHru6dSESCCXekHkP9vC6Fm/Xi31jUuVU/7thwHIPccbsXqWWSXUl9naYLOpdYfCELrkNxIbvm91pfHW6n/GPZpvGJ5Z/xMs0xDBtoD6DnjUTtLkljdqKQ== 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=56SHEc+/z+mysZCWVUPvy2fU2ZqtSDOWlbQEJBR3G+0=; b=Zhn8D6KznJdlwF+IAx3LCL1FrxkDYE0M9Fy3RKKODQ65DiaV/3Sr94w2fnfQjMTwAQj180lZl2tVb+wo/Pu9t/z+BI9TEO9tXckVCbWf2I8TupFz8XB7ElVPeiOWTjpRZ7Ag0x7JM05LHhjwqB1+AiLVPyFNkcl6D93MOo+VJd6YCTkz3FHfd/a/Q59jH0hr3ONMC+RfvMD+grfKjUOsmgwIAjIZpNzP0jsHspU3rS5fcexj9lfNyB1UutNhITDXegOqaQPe3ygOgnoSM6aPZh45kt9paDOAhFgozQRPcPyhamrSwmqKf+Aeq3HT5opIDNFYhBXiFic5J6Lrw2t9oQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=56SHEc+/z+mysZCWVUPvy2fU2ZqtSDOWlbQEJBR3G+0=; b=Mqb9yUj5ao9VKotaZ54HMlP2roqAk+0Ecz7KYSbIHfxxK95FQbSV/tf7oh1fvhcGbpL/smAnPGUUR0tcQ5wXqqzGZQ9n7ZvZCeuuhU2Sq2lSF3BNC54kzwCXtuHLB/73jKvwetR/wFFWkDT+9gO2VpxqFb6QN7d05aPM9WRo0KUN4hvhKdFR0R0PCLIsZFZlqnSG02Y5c1on8QUqgZgRZ4s1CKHDubyNdjHF1xTYBCMNw2j/L7PB/dqCec4fKj/UK4QFDYyR6DDn9HRIudnbRzmw41RpdagDWr6XXXAEvG2R5BN0TsnNGJlMcOj4Ip8T9Ir+Er4fmbQM4ryCuUH83A== Received: from MW4PR03CA0026.namprd03.prod.outlook.com (2603:10b6:303:8f::31) by DM4PR12MB5151.namprd12.prod.outlook.com (2603:10b6:5:392::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Wed, 20 Jul 2022 18:34:09 +0000 Received: from CO1NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8f:cafe::85) by MW4PR03CA0026.outlook.office365.com (2603:10b6:303:8f::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.25 via Frontend Transport; Wed, 20 Jul 2022 18:34:09 +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=fail action=none header.from=xilinx.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 CO1NAM11FT013.mail.protection.outlook.com (10.13.174.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5458.17 via Frontend Transport; Wed, 20 Jul 2022 18:34:09 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.28; Wed, 20 Jul 2022 13:34:08 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 20 Jul 2022 13:34:08 -0500 Received: from xcbecree41x.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.28 via Frontend Transport; Wed, 20 Jul 2022 13:34:07 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH v3 net-next 9/9] sfc: attach/detach EF100 representors along with their owning PF Date: Wed, 20 Jul 2022 19:33:49 +0100 Message-ID: <20220720183349.29448-3-ecree@xilinx.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 392e41e1-1490-4010-9af2-08da6a7e6f6b X-MS-TrafficTypeDiagnostic: DM4PR12MB5151:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BCZ/9VEVEcahMtKkSHFZLUKUDeFw4oPW9jX5IcnrZZNRml1+/5Hkg+ip3d+sS32BbrDYE57s2IbPUHZdhQVdKJMdReUplAEHs/1487QdvIq/H23PSaX82UTTL72an4NkXM//DYCO4hB4hiqN6uny89cAWRsqUcWjdqoP6w2qvEakU/Vwa04PZFyOfCvNyjPseCE2THg7w+wiLLffF+Wq8SGPGPRwZ157ty5PwNHR1LpfbvRoPv8yOP10MfN9/44dSwBlmAgQPCUBE/GnqQTBoYsppLn3MqFIrKskUtdBrSMaqQ4wPMzP93P6qyB8QqYWqnwxJGNZLo2yg9mtVs26+n+sgUY/w0yMkEghTnxDDgTUIvGUZqzeffMR6qESpLYl9C99T2Gcken1cYPSLmfq+w1OCj2KZ1khl+jthE8PHTUNqzrnKjkOVTTmbNGFLR+1vzefBqLr/5HhvZQc9T2HOtyQ2DiwRfIHnw4W3b8UOvDloYp6pz6XLTqIdJPQcxo9DZGdc3PY8Yu1MYQ1JHigvQWXi13K0ZvXJqLHXeQe/Kdbk02PDFmBBGQvP6huYXuWWS6l+qAEtjiNDAJeCVvLSalNcbxyrHsJ56Yp8kvUaY61KXIdc9W1Cu+DIoua7AX/Cn1oeAfP0CQDN8t3nDtJ3RwdLF2/+5DQESqSDDBWPP90mQ03hV4tIS4NpYXtsKhjw82Tr5uv3fIE35U04E+F2nTjXCI6s7ldJXB8aXBxBjVm9tIhdXb6zfBTVh6iQlS3oBsR/DB8GWciwXHIzJ+c4as8CdNG3/rwqB7UJrIgp8ZAYXpBd7bUeb5r/qtV75G74ZVszeTZ2OzAL/4lRErjtA== 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:(13230016)(4636009)(346002)(39860400002)(396003)(136003)(376002)(46966006)(40470700004)(36840700001)(2876002)(7696005)(2616005)(6666004)(41300700001)(8936002)(5660300002)(82740400003)(478600001)(83170400001)(81166007)(4326008)(1076003)(70586007)(47076005)(356005)(336012)(83380400001)(42882007)(70206006)(40460700003)(110136005)(36860700001)(26005)(54906003)(316002)(36756003)(40480700001)(186003)(8676002)(2906002)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 18:34:09.2218 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 392e41e1-1490-4010-9af2-08da6a7e6f6b 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: CO1NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5151 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Since representors piggy-back on the PF's queues for TX, they can only accept new TXes while the PF is up. Thus, any operation which detaches the PF must first detach all its VFreps. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_netdev.c | 3 +++ drivers/net/ethernet/sfc/ef100_rep.c | 11 ++++++-- drivers/net/ethernet/sfc/efx.h | 9 ++++++- drivers/net/ethernet/sfc/efx_common.c | 36 +++++++++++++++++++++++++ drivers/net/ethernet/sfc/efx_common.h | 3 +++ 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef100_netdev.c b/drivers/net/ethernet/sfc/ef100_netdev.c index 3443477c26da..9e65de1ab889 100644 --- a/drivers/net/ethernet/sfc/ef100_netdev.c +++ b/drivers/net/ethernet/sfc/ef100_netdev.c @@ -85,6 +85,7 @@ static int ef100_net_stop(struct net_device *net_dev) netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n", raw_smp_processor_id()); + efx_detach_reps(efx); netif_stop_queue(net_dev); efx_stop_all(efx); efx_mcdi_mac_fini_stats(efx); @@ -176,6 +177,8 @@ static int ef100_net_open(struct net_device *net_dev) mutex_unlock(&efx->mac_lock); efx->state = STATE_NET_UP; + if (netif_running(efx->net_dev)) + efx_attach_reps(efx); return 0; diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c index 6d4c3f0eee0a..d07539f091b8 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.c +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -132,8 +132,13 @@ static struct efx_rep *efx_ef100_rep_create_netdev(struct efx_nic *efx, spin_lock_bh(&efx->vf_reps_lock); list_add_tail(&efv->list, &efx->vf_reps); spin_unlock_bh(&efx->vf_reps_lock); - netif_carrier_off(net_dev); - netif_tx_stop_all_queues(net_dev); + if (netif_running(efx->net_dev) && efx->state == STATE_NET_UP) { + netif_device_attach(net_dev); + netif_carrier_on(net_dev); + } else { + netif_carrier_off(net_dev); + netif_tx_stop_all_queues(net_dev); + } rtnl_unlock(); net_dev->netdev_ops = &efx_ef100_rep_netdev_ops; @@ -171,9 +176,11 @@ static void efx_ef100_rep_destroy_netdev(struct efx_rep *efv) { struct efx_nic *efx = efv->parent; + rtnl_lock(); spin_lock_bh(&efx->vf_reps_lock); list_del(&efv->list); spin_unlock_bh(&efx->vf_reps_lock); + rtnl_unlock(); free_netdev(efv->net_dev); } diff --git a/drivers/net/ethernet/sfc/efx.h b/drivers/net/ethernet/sfc/efx.h index c05a83da9e44..4239c7ece123 100644 --- a/drivers/net/ethernet/sfc/efx.h +++ b/drivers/net/ethernet/sfc/efx.h @@ -12,6 +12,7 @@ #include "net_driver.h" #include "ef100_rx.h" #include "ef100_tx.h" +#include "efx_common.h" #include "filter.h" int efx_net_open(struct net_device *net_dev); @@ -206,6 +207,9 @@ static inline void efx_device_detach_sync(struct efx_nic *efx) { struct net_device *dev = efx->net_dev; + /* We must stop reps (which use our TX) before we stop ourselves. */ + efx_detach_reps(efx); + /* Lock/freeze all TX queues so that we can be sure the * TX scheduler is stopped when we're done and before * netif_device_present() becomes false. @@ -217,8 +221,11 @@ static inline void efx_device_detach_sync(struct efx_nic *efx) static inline void efx_device_attach_if_not_resetting(struct efx_nic *efx) { - if ((efx->state != STATE_DISABLED) && !efx->reset_pending) + if ((efx->state != STATE_DISABLED) && !efx->reset_pending) { netif_device_attach(efx->net_dev); + if (efx->state == STATE_NET_UP) + efx_attach_reps(efx); + } } static inline bool efx_rwsem_assert_write_locked(struct rw_semaphore *sem) diff --git a/drivers/net/ethernet/sfc/efx_common.c b/drivers/net/ethernet/sfc/efx_common.c index fb6b66b8707b..a929a1aaba92 100644 --- a/drivers/net/ethernet/sfc/efx_common.c +++ b/drivers/net/ethernet/sfc/efx_common.c @@ -24,6 +24,7 @@ #include "mcdi_port_common.h" #include "io.h" #include "mcdi_pcol.h" +#include "ef100_rep.h" static unsigned int debug = (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | NETIF_MSG_IFDOWN | @@ -1391,3 +1392,38 @@ int efx_get_phys_port_name(struct net_device *net_dev, char *name, size_t len) return -EINVAL; return 0; } + +void efx_detach_reps(struct efx_nic *efx) +{ + struct net_device *rep_dev; + struct efx_rep *efv; + + ASSERT_RTNL(); + netif_dbg(efx, drv, efx->net_dev, "Detaching VF representors\n"); + list_for_each_entry(efv, &efx->vf_reps, list) { + rep_dev = efv->net_dev; + if (!rep_dev) + continue; + netif_carrier_off(rep_dev); + /* See efx_device_detach_sync() */ + netif_tx_lock_bh(rep_dev); + netif_tx_stop_all_queues(rep_dev); + netif_tx_unlock_bh(rep_dev); + } +} + +void efx_attach_reps(struct efx_nic *efx) +{ + struct net_device *rep_dev; + struct efx_rep *efv; + + ASSERT_RTNL(); + netif_dbg(efx, drv, efx->net_dev, "Attaching VF representors\n"); + list_for_each_entry(efv, &efx->vf_reps, list) { + rep_dev = efv->net_dev; + if (!rep_dev) + continue; + netif_tx_wake_all_queues(rep_dev); + netif_carrier_on(rep_dev); + } +} diff --git a/drivers/net/ethernet/sfc/efx_common.h b/drivers/net/ethernet/sfc/efx_common.h index 93babc1a2678..2c54dac3e662 100644 --- a/drivers/net/ethernet/sfc/efx_common.h +++ b/drivers/net/ethernet/sfc/efx_common.h @@ -111,4 +111,7 @@ int efx_get_phys_port_id(struct net_device *net_dev, int efx_get_phys_port_name(struct net_device *net_dev, char *name, size_t len); + +void efx_detach_reps(struct efx_nic *efx); +void efx_attach_reps(struct efx_nic *efx); #endif