From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7E02FA034D; Mon, 10 Jan 2022 12:35:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 98AA541159; Mon, 10 Jan 2022 12:35:40 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) by mails.dpdk.org (Postfix) with ESMTP id 5380B41174 for ; Mon, 10 Jan 2022 12:35:39 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FpR/JphyBjpkSKVj2uKyZaaGmONrbPZ+kZgg7U64YyMtAChp1yzLyXn7++YgsTY8aMvPA11Nx8VlOLB9VZ7Dmyo+07EKSTv4XfeVxLsz1m+mbqHsSmZ+IkY8xE5WitNcmjEY/woeobpAdCj75r3HeAk1SE652o4wSD7JLbNVWfkN8ewz1AcugVRaj/efGAOU4X9UAQuA/vothmJ/c6bATotSXv330vrrctpIBlquKuN16NwEMgOnscC6z9mSOrn7QKeN/aRI+Bk7EumiZ0/iRbNVlwEaRuVrKcXLsPJRPpwyvSbjB1ppur8WOlxUghjWZr0/qIHo6iBhd6jP+Chdnw== 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=EDNq/bUaboLX1syhoRERxWGpOwl5JGhCkcks2RDjzMY=; b=GdlIJkNTcusV2sDWxGumQ4Z6d3oetMQAkrVxJMCwhaJcK4EH7PXj6ZKN+o2y/rEHPA/427qKpZj5OazBYIJcus3NYLpOVzusbmlXDk0FNoDYfGFFbTNkAE8ibBlKGMRgyXifQSaAs2c5w7l4rXwDAYXWZO4n4CrNsd0qptMpgboyp+W2ePNbEtZzyN28JvV5VI104pXkVakDcMEU1AFkby6d5VgRVz6j9p/RqR9EB+fMLYNzxFMPt4/KwTIka2Pn072gK5w853dGZ7DeUET7Rq2/2UM619tsUXdAhtzrTSUFo3za//Y/SnVY/vpAnwqkLGNr9pRe0uUEv+kOQYj1tw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EDNq/bUaboLX1syhoRERxWGpOwl5JGhCkcks2RDjzMY=; b=a4/aYdZwOGafhwQIMtqEm4GrLzLA56eL2XhsitWJWX77qH5UD35rj1/AoYVGtW9gyxSNLHK5YhWTmITJ5EfKvLm/+AoQnPCMrXWeMFTaZydx+9SXx/T4vS7wMsvAb1LqYcGw1qx9waS8NhLdQQ5xDpWjr2GkNnv0TdoJDtXS9GA= Received: from CO2PR04CA0152.namprd04.prod.outlook.com (2603:10b6:104::30) by BN9PR12MB5383.namprd12.prod.outlook.com (2603:10b6:408:104::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.9; Mon, 10 Jan 2022 11:35:36 +0000 Received: from CO1NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:104:0:cafe::50) by CO2PR04CA0152.outlook.office365.com (2603:10b6:104::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.9 via Frontend Transport; Mon, 10 Jan 2022 11:35:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT021.mail.protection.outlook.com (10.13.175.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4867.7 via Frontend Transport; Mon, 10 Jan 2022 11:35:35 +0000 Received: from cae-Lilac-RMB.amd.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.17; Mon, 10 Jan 2022 05:35:34 -0600 From: To: Subject: [PATCH v1 3/6] net/axgbe: simplify mailbox interface rate change code Date: Mon, 10 Jan 2022 17:05:06 +0530 Message-ID: <20220110113509.553184-4-ssebasti@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220110113509.553184-1-ssebasti@amd.com> References: <20220110113509.553184-1-ssebasti@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb3d563f-2a14-4922-5d40-08d9d42d51e6 X-MS-TrafficTypeDiagnostic: BN9PR12MB5383:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PQ0ByDEdBaGnRMx0cIOC91lKxgHiTEiyb3+K6cKmJiuUiX6/7GZW3kM2HHPjroAE3mg0o0l3ViRzanDb7H4mjrVF0n1VrMxunMiXO4Js2ZqIHFkfOL/Zq6PxDNylBciZnj57i90WXrrskK33fVzYogycURIh+sWi6IqCZ3l0Snw5HrmgjAP2EUMh+KGtmJSZYeKHjx/2r1CJzEnPJ8iTuwDwCxxcqUaQsSamJuVr40sCe09OfciSvZ50psUpEj+VXlFZyqvK8q1qOhv2fICsS+3KCg4G2s6nDaZF/oCTL4wWUor5bu70qOnLMDm4cGo2LGlD4KSiq+T7DLZfSmzAVJt/VS+vi50ktd2IoFhJkO2QnR0sxIHXbvLzTdZUSpXnKiLBvTQdN9AmQjgJ40MhnrqiHU06q2rMmM1vdgN0ZGaZsmCiYNJrXzthqxOcN0HKDr8Kby7Uh2tjkM3/+FESA9JJwHUXmwr51hvOGKsfwDYnByMYFCO8fi+yBL8FPxEtz2THeYQ6cniSw/11dM6enqiyNcPs435X/0uvnCpICKyZN5863EUA1xwvjSYOpeWpaf2LlS4ZhcgC+DNaHLtkFabSmjv3L6Utp6xNgAg8Y/8DIEDGqTDbXmGmnjZCFSwGo+AtpeoCPDkSDPO5ISorObY/Mn5S8/cPnAThILCn2T/eU92eyt1Cd73CaHvd4ZWQS4lg8Ku0mRsJzyzcg2SKtsTcxnPnJOYYBIYdwq7xySqxyDAxPmzoTV2RtK7WXTA8HJmUVI/3M8qtIv8J8HdhCgHBhbVpd9dW/UB0NM9hR3Y= 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:(4636009)(40470700002)(36840700001)(46966006)(6916009)(83380400001)(6666004)(8936002)(2876002)(8676002)(426003)(5660300002)(26005)(336012)(7696005)(1076003)(316002)(186003)(16526019)(508600001)(356005)(36756003)(2906002)(70586007)(2616005)(81166007)(70206006)(15650500001)(36860700001)(47076005)(82310400004)(40460700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2022 11:35:35.9960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fb3d563f-2a14-4922-5d40-08d9d42d51e6 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: CO1NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5383 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Selwin Sebastian Simplify and centralize the mailbox command rate change interface by having a single function perform the writes to the mailbox registers to issue the request. Signed-off-by: Selwin Sebastian --- drivers/net/axgbe/axgbe_phy_impl.c | 95 ++++++++---------------------- 1 file changed, 23 insertions(+), 72 deletions(-) diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c index dc9489f0aa..0894dbf74b 100644 --- a/drivers/net/axgbe/axgbe_phy_impl.c +++ b/drivers/net/axgbe/axgbe_phy_impl.c @@ -1207,21 +1207,26 @@ static void axgbe_phy_pll_ctrl(struct axgbe_port *pdata, bool enable) rte_delay_us(150); } -static void axgbe_phy_start_ratechange(struct axgbe_port *pdata) +static void axgbe_phy_perform_ratechange(struct axgbe_port *pdata, + unsigned int cmd, unsigned int sub_cmd) { + unsigned int s0 = 0; + unsigned int wait; /* Clear the PLL so that it helps in power down sequence */ axgbe_phy_pll_ctrl(pdata, false); /* Log if a previous command did not complete */ if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) PMD_DRV_LOG(NOTICE, "firmware mailbox not ready for command\n"); - else - return; -} -static void axgbe_phy_complete_ratechange(struct axgbe_port *pdata) -{ - unsigned int wait; + /* Construct the command */ + XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, COMMAND, cmd); + XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, sub_cmd); + + /* Issue the command */ + XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); + XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); + XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); /* Wait for command to complete */ wait = AXGBE_RATECHANGE_COUNT; @@ -1240,21 +1245,10 @@ static void axgbe_phy_complete_ratechange(struct axgbe_port *pdata) static void axgbe_phy_rrc(struct axgbe_port *pdata) { - unsigned int s0; - axgbe_phy_start_ratechange(pdata); /* Receiver Reset Cycle */ - s0 = 0; - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, COMMAND, 5); - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 0); - - /* Call FW to make the change */ - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); - XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); - - axgbe_phy_complete_ratechange(pdata); + axgbe_phy_perform_ratechange(pdata, 5, 0); PMD_DRV_LOG(DEBUG, "receiver reset complete\n"); } @@ -1263,13 +1257,9 @@ static void axgbe_phy_power_off(struct axgbe_port *pdata) { struct axgbe_phy_data *phy_data = pdata->phy_data; - axgbe_phy_start_ratechange(pdata); + /* Power off */ + axgbe_phy_perform_ratechange(pdata, 0, 0); - /* Call FW to make the change */ - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, 0); - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); - XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); - axgbe_phy_complete_ratechange(pdata); phy_data->cur_mode = AXGBE_MODE_UNKNOWN; PMD_DRV_LOG(DEBUG, "phy powered off\n"); @@ -1278,31 +1268,21 @@ static void axgbe_phy_power_off(struct axgbe_port *pdata) static void axgbe_phy_sfi_mode(struct axgbe_port *pdata) { struct axgbe_phy_data *phy_data = pdata->phy_data; - unsigned int s0; axgbe_phy_set_redrv_mode(pdata); - axgbe_phy_start_ratechange(pdata); - /* 10G/SFI */ - s0 = 0; - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, COMMAND, 3); if (phy_data->sfp_cable != AXGBE_SFP_CABLE_PASSIVE) { - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 0); + axgbe_phy_perform_ratechange(pdata, 3, 0); } else { if (phy_data->sfp_cable_len <= 1) - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 1); + axgbe_phy_perform_ratechange(pdata, 3, 1); else if (phy_data->sfp_cable_len <= 3) - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 2); + axgbe_phy_perform_ratechange(pdata, 3, 2); else - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 3); + axgbe_phy_perform_ratechange(pdata, 3, 3); } - /* Call FW to make the change */ - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); - XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); - axgbe_phy_complete_ratechange(pdata); phy_data->cur_mode = AXGBE_MODE_SFI; PMD_DRV_LOG(DEBUG, "10GbE SFI mode set\n"); @@ -1311,22 +1291,11 @@ static void axgbe_phy_sfi_mode(struct axgbe_port *pdata) static void axgbe_phy_kr_mode(struct axgbe_port *pdata) { struct axgbe_phy_data *phy_data = pdata->phy_data; - unsigned int s0; axgbe_phy_set_redrv_mode(pdata); - axgbe_phy_start_ratechange(pdata); - /* 10G/KR */ - s0 = 0; - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, COMMAND, 4); - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 0); - - /* Call FW to make the change */ - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); - XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); - axgbe_phy_complete_ratechange(pdata); + axgbe_phy_perform_ratechange(pdata, 4, 0); phy_data->cur_mode = AXGBE_MODE_KR; PMD_DRV_LOG(DEBUG, "10GbE KR mode set\n"); @@ -1335,40 +1304,22 @@ static void axgbe_phy_kr_mode(struct axgbe_port *pdata) static void axgbe_phy_kx_2500_mode(struct axgbe_port *pdata) { struct axgbe_phy_data *phy_data = pdata->phy_data; - unsigned int s0; axgbe_phy_set_redrv_mode(pdata); - /* 2.5G/KX */ - axgbe_phy_start_ratechange(pdata); - s0 = 0; - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, COMMAND, 2); - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 0); - - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); - - XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); + /* 2.5G/KX */ + axgbe_phy_perform_ratechange(pdata, 2, 0); phy_data->cur_mode = AXGBE_MODE_KX_2500; } static void axgbe_phy_sgmii_1000_mode(struct axgbe_port *pdata) { struct axgbe_phy_data *phy_data = pdata->phy_data; - unsigned int s0; axgbe_phy_set_redrv_mode(pdata); /* 1G/SGMII */ - axgbe_phy_start_ratechange(pdata); - s0 = 0; - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, COMMAND, 1); - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 2); - - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); - XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); - - XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); + axgbe_phy_perform_ratechange(pdata, 1, 2); phy_data->cur_mode = AXGBE_MODE_SGMII_1000; } -- 2.25.1