From patchwork Mon Jan 25 15:04:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 370472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A39AC433E0 for ; Mon, 25 Jan 2021 15:46:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5958229C5 for ; Mon, 25 Jan 2021 15:46:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730372AbhAYPqC (ORCPT ); Mon, 25 Jan 2021 10:46:02 -0500 Received: from mail-eopbgr10138.outbound.protection.outlook.com ([40.107.1.138]:20037 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730329AbhAYPpd (ORCPT ); Mon, 25 Jan 2021 10:45:33 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jCmPnvRKfbuM1Unjc+pPWs3tVo6WWZhiVDDhEyFvnM5UW28mzVQI4AzbYGBS47V5wEWuTmOVGQs6wPb5fI6OZOksipHSFNNOScucIWSEh6nEIWJCRl9g/uDT+Q91YbJcleykDEhkK4x2dM3OCqcL08mb9QWjnEGv8XrB/t1pHS/LNFaCiMCr3PPCyaXEIYnWq/IN8SLF9tKZzMtxJbw4JMt4lozXSUGBh/tQLJR8RexGwitjh5fyI9N37ab2pNmewtI1iYc0Zngk+LkUTyl+RCD5FQvvIxj8Yq2NcgimWdXMVhIYM79vm/fz8S/30qYcoCtcUTAuuq2uqPuu3dWcuA== 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-SenderADCheck; bh=FfYRDUF3SArLheaRMmMBrOobpukxBVqzPEcTRMbyrbo=; b=KznbACWU4nlPESkzTX9sb2RxxiJQwrXKkCU9lVjaV5+ONShKU3f4na+r/uOMsaDTbshIfWD4vrFAG3mh5nwNM6lYHNxmuDSsnZhw1HJGg6K75YkLJOt6bc9Y9kKloMTGEB5IZo6w2WPS4QVh5rTqeHxhQz5uIkT+9Dyu/VNMiR5B+vmhOWJhA29klrOgb/row3FsjfL3jsgTWfThbNjQIdvqWH9vB0WfhkxscSsq1wbQQa2eJFDwTWGqFqlTRO3tgK6k8yAWzdbQH9wtBlWjjS9fYaeMK2hDcLq/LxkbIc2W3fxHoMr7yh1cVZ4AFu9XY42En/TTyvPR1EoHZul4Tg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FfYRDUF3SArLheaRMmMBrOobpukxBVqzPEcTRMbyrbo=; b=GsSBRcrb2+qTue4MpUiiZSFdWyq72yMfff4x6gEzfjK/hWD3ckQhmpbqdO2WiwytqX79c9K5Kn7TCGJ6wObhYABaRo1XIPAhp+UFKFJ6p8HCW2h+/FYbkDzOAjp4uVtuW5QX7eHgzmgChKDaac68iyigDmhkKob5ZFqYCz4Njd4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=prevas.dk; Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) by AM0PR10MB3331.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:18b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Mon, 25 Jan 2021 15:04:58 +0000 Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::58b2:6a2a:b8f9:bc1a]) by AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::58b2:6a2a:b8f9:bc1a%3]) with mapi id 15.20.3784.017; Mon, 25 Jan 2021 15:04:58 +0000 From: Rasmus Villemoes To: netdev@vger.kernel.org Cc: Florian Fainelli , Vladimir Oltean , Tobias Waldekranz , Jakub Kicinski , "David S . Miller" , Vivien Didelot , Rasmus Villemoes Subject: [PATCH net-next v2 1/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_getnext() for the 6250 Date: Mon, 25 Jan 2021 16:04:48 +0100 Message-Id: <20210125150449.115032-2-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210125150449.115032-1-rasmus.villemoes@prevas.dk> References: <20210125150449.115032-1-rasmus.villemoes@prevas.dk> X-Originating-IP: [5.186.115.188] X-ClientProxiedBy: AM5PR1001CA0048.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:15::25) To AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.115.188) by AM5PR1001CA0048.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:15::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Mon, 25 Jan 2021 15:04:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8827f3f1-5d7e-44e1-2bf7-08d8c1429495 X-MS-TrafficTypeDiagnostic: AM0PR10MB3331: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:590; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cD+XG/E7eirKW4gp1XzL+BuKmL9GPOQvC4dTToPhBoCDSAaQALsMocSVHPnOeIxHZhIlMrYTa+ZvRCqQYydj35IVShkAXqzFFMUnXAAr1KDfTrbp677VHxGbEF7K7/9p/yaGoK5LA8lRTipspTlvTrC0sw8bki6eHofZs7GDtu0cppgis3Ql0lmQsfs//FUbxkRBEjBt933/tSiZCXhRB4Kn3kd15QBYaZolA2blYR4JvYo3gUso3Nodle0R7i0FZasCI6lrx4CozlGos22irhAYSKkL0ogunsYG+gLMxjwdi9WXpfvzUB5RIbxVIn8YjChowEzWolWnzxXxEisIBwfI0bxWKyTyQYEJSl5dewK+rHi38rtvTF43MJemFSREz6JVNNXb+HTrLa4N4A4y4iof1yCeij3Jxlkz3AJe4Gh9GHW+PjymE7bAsUjL613Tipld7o9e60vwSyEO6nqVewVW5RJwkvRY2rbEw/WDoMFK9fMOISqhwTQsWZkHA4Aquk/Bhpon/Pr9uRGrmXJNBg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(346002)(366004)(39850400004)(136003)(396003)(376002)(52116002)(83380400001)(4326008)(8676002)(6486002)(66476007)(5660300002)(66556008)(107886003)(66946007)(36756003)(54906003)(44832011)(6512007)(8976002)(16526019)(316002)(8936002)(478600001)(186003)(26005)(2906002)(6916009)(6666004)(1076003)(2616005)(86362001)(956004)(6506007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: o+NW5QC651klYvH3uHaFTbjWjb++7sSIoZlQBfvAPh7ODvTXLHAnkjAilGK6VC1KScAEaUHA/jMEQVyyBW17ctrSdjxIUsTjqZOWEpFvWZjrmL243wHAVfF4O9QDy9WSljj3Z3OhGHtF8t89EgX79Z0ER6bFSBH9l9o6MW9RiiqJzzTeTUSStTgP8N/QRQpbk7Rndz8F9Wl+0L7rjzPRd0g5LM/9aNzB2uDXJNqbr6ThOhUsUZnfjXPUOShzHOq3NAsNuHQZu8oS2ZdIi8BBGIUc5Ic/bc4HsmoDi6s0tgA8ALATY9Ig7Rn3w8tHngKUvVRqeVSdSAVmGMI1GoEHuYdJeDs9c069sLjrJb2sF85CMh2n8vdsFjWQKJJ82RXsFvE3w8O0EYF1T1V6RxBJGG+2U7xd0s4R46P0BQAA29uYrO9ahA52jE5REorc7N+F31k0qS8BMIDz8TgiejOI9A6hnNyHc9URXzvyekuY23uoZ/8J+5EHhrG7dTJmX9t8zvY6bDEWEyiQuHeDJL68kPTAfUHfFdDOFiJr8Xyd/zTNA2n1Jy3O6jbTc+77pkXzXwQaqq3M8vQZESGjNfaAPZujirWO3nwdRZO+0j6mQNG5UexKGCwY8Ju+RXFbC4sRVLdaVTe+6AREDaZUxrrs6VEfp8w0eqj9GzPypgVIQn1IXoDf7TpwgZe5zdV9+G0ICGihC819x6reC+hu7PlI0k2k8TumcHpwIQCTl8TCqDnJgg/YltRcugHpvT91vmxDZi33NdhJ8ZwtY9mxPrWP2YCNwaS0/+kp/Pjb9/cuOzlbOh8bAWGbngB8W4kt0Jn166PqMtP50gGGtA4QXfiqE9WoukQ7TDrjNH33c/w71d8GCeSBPLaFlzn141E4A1DJKEdO/mBMT47PLhPrf+Yi32Zast4oB7hBVaVzTrtT9OARt5aOQoR98Aa+GcbDSHtQnTEFjhE7KqdnYxFJQGTMJqiArYlxn5Edmt0mU4vzXO4lvjitE5ohdp+yDLi4LsFP X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 8827f3f1-5d7e-44e1-2bf7-08d8c1429495 X-MS-Exchange-CrossTenant-AuthSource: AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2021 15:04:58.3608 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JaiG+6KJ6jUj/AW9DMShyI0mgMJwZ3RL53NclHjmBnaYsCH135DSUeDPBFyljqf0rtm3UjfHtCSUybGJ954bPi3lRgSfR55rurtxTAgN3GM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR10MB3331 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org mv88e6250_g1_vtu_getnext is almost identical to mv88e6185_g1_vtu_getnext, except for the 6250 only having 64 databases instead of 256. We can reduce code duplication by simply masking off the extra two garbage bits when assembling the fid from VTU op [3:0] and [11:8]. Reviewed-by: Tobias Waldekranz Tested-by: Tobias Waldekranz Reviewed-by: Florian Fainelli Signed-off-by: Rasmus Villemoes Reviewed-by: Vladimir Oltean --- drivers/net/dsa/mv88e6xxx/chip.c | 2 +- drivers/net/dsa/mv88e6xxx/global1.h | 2 -- drivers/net/dsa/mv88e6xxx/global1_vtu.c | 36 ++----------------------- 3 files changed, 3 insertions(+), 37 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 5cc1465fd635..8a0df1e903bf 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -4023,7 +4023,7 @@ static const struct mv88e6xxx_ops mv88e6250_ops = { .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, .reset = mv88e6250_g1_reset, - .vtu_getnext = mv88e6250_g1_vtu_getnext, + .vtu_getnext = mv88e6185_g1_vtu_getnext, .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge, .avb_ops = &mv88e6352_avb_ops, .ptp_ops = &mv88e6250_ptp_ops, diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h index 80a182c5b98a..d2dd2f4e4730 100644 --- a/drivers/net/dsa/mv88e6xxx/global1.h +++ b/drivers/net/dsa/mv88e6xxx/global1.h @@ -336,8 +336,6 @@ int mv88e6185_g1_vtu_getnext(struct mv88e6xxx_chip *chip, struct mv88e6xxx_vtu_entry *entry); int mv88e6185_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip, struct mv88e6xxx_vtu_entry *entry); -int mv88e6250_g1_vtu_getnext(struct mv88e6xxx_chip *chip, - struct mv88e6xxx_vtu_entry *entry); int mv88e6250_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip, struct mv88e6xxx_vtu_entry *entry); int mv88e6352_g1_vtu_getnext(struct mv88e6xxx_chip *chip, diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c b/drivers/net/dsa/mv88e6xxx/global1_vtu.c index 7b96396be609..519ae48ba96e 100644 --- a/drivers/net/dsa/mv88e6xxx/global1_vtu.c +++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c @@ -336,39 +336,6 @@ int mv88e6xxx_g1_vtu_getnext(struct mv88e6xxx_chip *chip, return mv88e6xxx_g1_vtu_vid_read(chip, entry); } -int mv88e6250_g1_vtu_getnext(struct mv88e6xxx_chip *chip, - struct mv88e6xxx_vtu_entry *entry) -{ - u16 val; - int err; - - err = mv88e6xxx_g1_vtu_getnext(chip, entry); - if (err) - return err; - - if (entry->valid) { - err = mv88e6185_g1_vtu_data_read(chip, entry); - if (err) - return err; - - err = mv88e6185_g1_stu_data_read(chip, entry); - if (err) - return err; - - /* VTU DBNum[3:0] are located in VTU Operation 3:0 - * VTU DBNum[5:4] are located in VTU Operation 9:8 - */ - err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_VTU_OP, &val); - if (err) - return err; - - entry->fid = val & 0x000f; - entry->fid |= (val & 0x0300) >> 4; - } - - return 0; -} - int mv88e6185_g1_vtu_getnext(struct mv88e6xxx_chip *chip, struct mv88e6xxx_vtu_entry *entry) { @@ -389,7 +356,7 @@ int mv88e6185_g1_vtu_getnext(struct mv88e6xxx_chip *chip, return err; /* VTU DBNum[3:0] are located in VTU Operation 3:0 - * VTU DBNum[7:4] are located in VTU Operation 11:8 + * VTU DBNum[7:4] ([5:4] for 6250) are located in VTU Operation 11:8 (9:8) */ err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_VTU_OP, &val); if (err) @@ -397,6 +364,7 @@ int mv88e6185_g1_vtu_getnext(struct mv88e6xxx_chip *chip, entry->fid = val & 0x000f; entry->fid |= (val & 0x0f00) >> 4; + entry->fid &= mv88e6xxx_num_databases(chip) - 1; } return 0; From patchwork Mon Jan 25 15:04:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 371216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61D09C43332 for ; Tue, 26 Jan 2021 05:21:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C1E822DFB for ; Tue, 26 Jan 2021 05:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732116AbhAZFUa (ORCPT ); Tue, 26 Jan 2021 00:20:30 -0500 Received: from mail-eopbgr80091.outbound.protection.outlook.com ([40.107.8.91]:12165 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730328AbhAYPoH (ORCPT ); Mon, 25 Jan 2021 10:44:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fvpGLfNqOWKloeA2v95v68BFLd2Cd499JLo5bImp9aH5s2vZ4rtIPkaeVJWGnAYez0mKQsDwnf/NCo+C6w2C8lCWMBWDsxzExWV6h2A9sYznK0P2CQF8LWR6xiyh0DBbEoOyixux+1rr0aI8vJXXoe2fjQhOIVcEqqtXYF10WPe9S6sS9NELRNmzJDi3hqhdly9M9kcwoyeBWu3E+Pryhjp7x/Eaqd4mGrY1ERvLYjXc1tHkEWRi0JWSV91OsXiiq7STy6Z8SY0wPQh4FfpDIGZMfHo1QH0lixK2Elyocby4dKIkbOaeJK2s/sIVJ0lRTdWznSQY9zt96/IKYzgt+A== 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-SenderADCheck; bh=h3/Fxap1DysBcMnQcZvquAQC0w2LccdslgETEt2RNj0=; b=cM2UN2QAutssrw+lius0F1DAkzXtAemfMWTrFxjx5oWcnNm+5xsT0QiTr3p8V1QIiIhnR8epgcpV6yKvzdy5yOvD4EUvLMcdt8hGspviuDORm4P96ItEoId+btLhe32/votqG/hL7LPLV/pSo1Wu2jXf0MQrO7qm64K9A3H+ifgDN6xlFOADwvpr+aM6M8O56AIM2sJzJoaByykCWtZMEoc5eGFpJEsWNm2xQFV5sl1lwqnLwDIv9soB4hP/0q+dEVQONiqZZnME0jFUIQB/7xiHIsUKyT7JYONVBnehRvEiKQ+ADTIPpN9KNMRh5Buj49gj1cfKrCW+UXAk33Cg8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h3/Fxap1DysBcMnQcZvquAQC0w2LccdslgETEt2RNj0=; b=jRHQm49qvsd0Wz7WRNvhD0reTuxHAreQZ30m+cCSc9zSsVSF5TAm4k5KuaEJj3Cm2R8EEPUktk/XOKMUXspNfObFJbDtFEGouzqcc/QhRNPAzOf4HRdt/aEBuxPMAxx2w8lxfyu6fBK75ccba6TYM68qV24kjx4x4c6f37mwf90= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=prevas.dk; Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) by AM0PR10MB3331.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:18b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Mon, 25 Jan 2021 15:04:59 +0000 Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::58b2:6a2a:b8f9:bc1a]) by AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::58b2:6a2a:b8f9:bc1a%3]) with mapi id 15.20.3784.017; Mon, 25 Jan 2021 15:04:59 +0000 From: Rasmus Villemoes To: netdev@vger.kernel.org Cc: Florian Fainelli , Vladimir Oltean , Tobias Waldekranz , Jakub Kicinski , "David S . Miller" , Vivien Didelot , Rasmus Villemoes Subject: [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_loadpurge() for the 6250 Date: Mon, 25 Jan 2021 16:04:49 +0100 Message-Id: <20210125150449.115032-3-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210125150449.115032-1-rasmus.villemoes@prevas.dk> References: <20210125150449.115032-1-rasmus.villemoes@prevas.dk> X-Originating-IP: [5.186.115.188] X-ClientProxiedBy: AM5PR1001CA0048.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:15::25) To AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.115.188) by AM5PR1001CA0048.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:15::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Mon, 25 Jan 2021 15:04:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2bf1ddb-fd30-41aa-0340-08d8c142952a X-MS-TrafficTypeDiagnostic: AM0PR10MB3331: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YcUDoiz4Rc7FHk4rR6miotBIbKMdFp0o+NMtYkXfUWpphzaPGbsALlkcBkk3H+gLF9v5re8mEH46MbpmcQlJ/hLQNlzK/MzCSS3cVGSANKgs2tBiRymZRGSjc6dM/wSJBb9XKUIiVwHRxDSsrMC5MSuQSlpmEfiva6Ndeq2b+Wr2/d9hvINWSj6D1iXPTM0oU8Ek9EwMXuyox7uV7NFqgF4XtEs+3r225dpmJE21/ZPIdE3cWRds6p1GbOpP/+deL00JhTjRSKGqlfz71D/z8oc9xalsKNvGp47WANRm1zBfBTKXznWnK8cFfFAMbKM1WfgInuEvvUiJDTgi+KnoCsia92Gg4gVHPlDBShgA0iNwQanG+0J4XuTUPOPTr6yiVaOzFbM1524yG3+Dd/NcPaGWNWvCoU3KKBDvKvlY1hiv+U1AYhSbFCizeD7IMN2tQbIQ9MlT3lYmcMSLKzKarP11yxHxb2frx3lZGAANIWiKQ5A+YogO7Vfqp/D3sTzcocj7ta7YsaNPo43nK3UpmA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(346002)(366004)(39850400004)(136003)(396003)(376002)(52116002)(83380400001)(4326008)(8676002)(6486002)(66476007)(5660300002)(66556008)(107886003)(66946007)(36756003)(54906003)(44832011)(6512007)(8976002)(16526019)(316002)(8936002)(478600001)(186003)(26005)(2906002)(6916009)(6666004)(1076003)(2616005)(86362001)(956004)(6506007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: +UOcg5wnhfReMfFzCm0o/Pw8FzXYRkADX90Lvy1L57RwJZ+nhI+jkH/bvp4SapQ1N3z+0E7YV4fz3WRykqGuOk78Rs4a7UtZPFC6Wjau4eW9CJdchg+ZJ3RR9SLARev3kPyqfnQB31DJ1Ab/JsoTNnYb9xYwxnmPgkS0ZXGkBJsKKI293/Yr9RrX0D54PTHp019EvK38D3nxQAGgxY0WYXI/ym28yRoV0s83XBMSuZ+pF7bNJYlump8qxMWhbn+/1j7NdDPnYxNHvABg9tX2kklqC/pcKcCKROzUIe/k1APjhcKfqbaJEwNdhsE1DMVkFtW+in6zC/grbg2EU81T3RsaBOcsMRi8ty1EgwADeFO1jOmEmHgPiAONMlcLgamizB6L1wGDWHF7i6vdYEP5e/kJpBYtNvThLjmTWiM5PrkXuCg5sMCdAku0/cefD6HtEK+nqjsql0+dZa+Bbo5oZtbWEBeosoVtsyi+Sfnq1ZTynKhGDKNwskuMo8nqCgYLW1QdiJnIpEcBq63sljHsb/f2yNMKRdlVT6xfhxxYmi7lZAifdnCItt+M5b2R/Zp3Oe2lfexpFgPl98+EpmBHzPhvg8qvjKKLa18LeDpZraEjQelssHwD8lnykPYKEyb/bXXXF2Oc67R4h062SBfmG7XzszFOPC7ENHQBIedKVOefpebF7ol5SOXE4v/dZMqqF6MhipfrYWIM4Q5E8dzyrD3XeQygWc6j9swp4HCT4GhBpdK33N6FAtGlRZEEsoKs46dGaZK4qJ8QUkwjIfzwApvaKL31brjtmYFH6yM+TChsdjjHLixNVvY/U2pDtLMokSssIZPHBUUR5fjdjyhgJrqByG6Wq9KxHBJ/pUm0VKBGliFgX4QfqBu4CBEvNubuWWfYcRi6wvMGTe1U64r4MTLpGA2sxrm79YnErw3bDLJ3RyjOSAl5acUA8qVztf5N9FL82qsKA0mlkneaQ8pupj7QjIFtQ8xzwUArqY1Wmo4bOsXXGCB4LM1EKrBICtAz X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: b2bf1ddb-fd30-41aa-0340-08d8c142952a X-MS-Exchange-CrossTenant-AuthSource: AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2021 15:04:58.9354 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DiGwGfFhOfB9FY0FRKUVEUVUn4JIV48FPv9oPJUar4OkI02hmDM5g9JXsV6MhuGIM/ITyKNq2SoYGkXdo8wCpsTeMPHRSYZD6krf3BVKjww= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR10MB3331 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Apart from the mask used to get the high bits of the fid, mv88e6185_g1_vtu_loadpurge() and mv88e6250_g1_vtu_loadpurge() are identical. Since the entry->fid passed in should never exceed the number of databases, we can simply use the former as-is as replacement for the latter. Suggested-by: Tobias Waldekranz Signed-off-by: Rasmus Villemoes Reviewed-by: Vladimir Oltean --- drivers/net/dsa/mv88e6xxx/chip.c | 2 +- drivers/net/dsa/mv88e6xxx/global1.h | 2 -- drivers/net/dsa/mv88e6xxx/global1_vtu.c | 33 +++---------------------- 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 8a0df1e903bf..7e1bbb400e8a 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -4024,7 +4024,7 @@ static const struct mv88e6xxx_ops mv88e6250_ops = { .pot_clear = mv88e6xxx_g2_pot_clear, .reset = mv88e6250_g1_reset, .vtu_getnext = mv88e6185_g1_vtu_getnext, - .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge, + .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, .avb_ops = &mv88e6352_avb_ops, .ptp_ops = &mv88e6250_ptp_ops, .phylink_validate = mv88e6065_phylink_validate, diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h index d2dd2f4e4730..7c396964d0b2 100644 --- a/drivers/net/dsa/mv88e6xxx/global1.h +++ b/drivers/net/dsa/mv88e6xxx/global1.h @@ -336,8 +336,6 @@ int mv88e6185_g1_vtu_getnext(struct mv88e6xxx_chip *chip, struct mv88e6xxx_vtu_entry *entry); int mv88e6185_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip, struct mv88e6xxx_vtu_entry *entry); -int mv88e6250_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip, - struct mv88e6xxx_vtu_entry *entry); int mv88e6352_g1_vtu_getnext(struct mv88e6xxx_chip *chip, struct mv88e6xxx_vtu_entry *entry); int mv88e6352_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip, diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c b/drivers/net/dsa/mv88e6xxx/global1_vtu.c index 519ae48ba96e..ae12c981923e 100644 --- a/drivers/net/dsa/mv88e6xxx/global1_vtu.c +++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c @@ -434,35 +434,6 @@ int mv88e6390_g1_vtu_getnext(struct mv88e6xxx_chip *chip, return 0; } -int mv88e6250_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip, - struct mv88e6xxx_vtu_entry *entry) -{ - u16 op = MV88E6XXX_G1_VTU_OP_VTU_LOAD_PURGE; - int err; - - err = mv88e6xxx_g1_vtu_op_wait(chip); - if (err) - return err; - - err = mv88e6xxx_g1_vtu_vid_write(chip, entry); - if (err) - return err; - - if (entry->valid) { - err = mv88e6185_g1_vtu_data_write(chip, entry); - if (err) - return err; - - /* VTU DBNum[3:0] are located in VTU Operation 3:0 - * VTU DBNum[5:4] are located in VTU Operation 9:8 - */ - op |= entry->fid & 0x000f; - op |= (entry->fid & 0x0030) << 4; - } - - return mv88e6xxx_g1_vtu_op(chip, op); -} - int mv88e6185_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip, struct mv88e6xxx_vtu_entry *entry) { @@ -484,6 +455,10 @@ int mv88e6185_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip, /* VTU DBNum[3:0] are located in VTU Operation 3:0 * VTU DBNum[7:4] are located in VTU Operation 11:8 + * + * For the 6250/6220, the latter are really [5:4] and + * 9:8, but in those cases bits 7:6 of entry->fid are + * 0 since they have num_databases = 64. */ op |= entry->fid & 0x000f; op |= (entry->fid & 0x00f0) << 4;