Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2665952rwb; Sat, 8 Oct 2022 11:54:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM640I3bGq6yvstm1szSZA+S7vJ5mRwkcXxd//m0qFR5oAY8h7a0Fic3cxOUZ222ohMgTU4/ X-Received: by 2002:a17:907:2cca:b0:77d:6542:d912 with SMTP id hg10-20020a1709072cca00b0077d6542d912mr8748039ejc.528.1665255287382; Sat, 08 Oct 2022 11:54:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665255287; cv=pass; d=google.com; s=arc-20160816; b=aTastPdryC0cJRURn/nG6TTI4zZxb9es+VAQX5cTdKgoY3W9XjBgo2hkK40kHwEQ8i BXYe5QjgmcqPzunk4Sj4vqO3YH+1CtDzHa9ImeU/cMOyHBcut120g4bazume2ZxV+N4i az9Y+l6snc1+KRZAi/4OPPi/TqMXc52IL38JwwlXDv4cZeEZtalcSaA2KdJDkJN0ybBd XANVj/0pjwMFYTXE3UGN7yHS2yuBChxCgOC56cYAiTvbpm2jxX5ICtvgD7sGGOWXPI0R YPPxUYLiork4rKPEa5yhsfAFA4YU4RFzr1D+loO+yD2LIQY1697xb8O40umKXCc/Mtdu Qr4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KabyPpxqHaUVuLst3aoqtRb3Z3BPXs73xlm3XX/dlW8=; b=KMiGmhn7d6dUDcrtcEb9T1oGlEqhcaQvueILSetm4CDqkokE3xMpEyeHq2UOAsU5Yu iyvmxEg9vNr3b5pQrlt26pfuy6yLxKzGr29oOXiVyd1/bwF+Jw1bdi4u/X4C2p6JmOAH T7acNYcT53icH4c3DFbZ1ux+DJ5j694phsGxftJfdTQdDx5JHxEg9AsEhBYcyGq40d2c jM9/rM4fNg/7ycOgacit5uUtM89JxKZvlEhJFLrYougvdObnaLweqFlwnE9PJJ50ab4P RQ59/luIkADwCCq6l+BMblIBDrgBWoiF8dI7tSIb7/YyBXw8UE7GT7UtArSHEh2/+EMA s09Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inadvantage.onmicrosoft.com header.s=selector2-inadvantage-onmicrosoft-com header.b="yFE44Na/"; arc=pass (i=1 spf=pass spfdomain=in-advantage.com dkim=pass dkdomain=in-advantage.com dmarc=pass fromdomain=in-advantage.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=in-advantage.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd25-20020a1709076e1900b0073d9c412570si4609080ejc.785.2022.10.08.11.54.21; Sat, 08 Oct 2022 11:54:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inadvantage.onmicrosoft.com header.s=selector2-inadvantage-onmicrosoft-com header.b="yFE44Na/"; arc=pass (i=1 spf=pass spfdomain=in-advantage.com dkim=pass dkdomain=in-advantage.com dmarc=pass fromdomain=in-advantage.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=in-advantage.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229755AbiJHSwL (ORCPT + 99 others); Sat, 8 Oct 2022 14:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbiJHSwJ (ORCPT ); Sat, 8 Oct 2022 14:52:09 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2102.outbound.protection.outlook.com [40.107.94.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC54C3F1F5; Sat, 8 Oct 2022 11:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UTX5Hdk81YfrJ1l+9nxGy8hbPdx3N+ftckSBw4rq1X+txos5YkovDOhOYPQzdsNnunvc5ZVAhw3NCyjJf7HfRXVx/hot9xE5In3wmWCEZv32Z0oF2AEY7Lo6lsvN+EU4XwLml48+346siTb46AJCSwqZg4Q6L9ruQB1pWzPkTVYleSR3d0cNcvxY9iuK+anLz1Jg4U9YVoMumUhBVXPWgy//1G2ONBBwcQ3mgoWLPq52BYwGpl/JGOdhlK9MJbBeaycinQMFOlAoQ3iLV39B9kLqBSww9RVC9lPFIMhaXpaxr+TjvRwjlsG1kT3MCzd/q5kSA5Zcgc9K8uhltbTalA== 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=KabyPpxqHaUVuLst3aoqtRb3Z3BPXs73xlm3XX/dlW8=; b=Rz5ar7y8N7pftZZEMpQGQNnYgUOd1DXNdTExBU49v4hQjSD9OcYfRS5J60/faeZW9tUyfiTe2OFqP6Y7Wx/GtMbsDJLwm9QlqVJDLe0/jQ75VFciFDZ+E7Xuo5xTlF8OwRXlp3ynPwlwiMhVOuwjQRsx6eQKUc2gH+pSr7cXjr7J1tsnPCNdMR6kRFiy8JJW/Jq9qNhwe5lqilFxmSdWzrBcK+XY95a+xyhgA7u9monC+cF7ReCM+48/eR8JuwysEgpMj5lBrJ+6mXo2/bl4g0dpYveJ3ytqYUFSZwsYJDsAlZbffu7z3Gopi32gAw6zxQdIa1GE5lep4LSber4sEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KabyPpxqHaUVuLst3aoqtRb3Z3BPXs73xlm3XX/dlW8=; b=yFE44Na/HwPrJJLhivtqf4JNRYN6Wka4EaQj78LCvU/sPP0RrArTMeLkzJeIQlQ3cvLwsiPc6sLLoRUr6BUDBU0RqFxFSPTCdy+9ZCuUFcggyLSV1LCHAhQdOA0OuGcxdvoL9slNHHs3BfftDd6+9kF7SreuuuHbO/+R0Yg3YEI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by PH7PR10MB6129.namprd10.prod.outlook.com (2603:10b6:510:1f7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.20; Sat, 8 Oct 2022 18:52:04 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::ee5e:cbf9:e304:942f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::ee5e:cbf9:e304:942f%7]) with mapi id 15.20.5676.028; Sat, 8 Oct 2022 18:52:04 +0000 From: Colin Foster To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Russell King , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Vladimir Oltean , Florian Fainelli , Vivien Didelot , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , Vladimir Oltean Subject: [RFC v4 net-next 01/17] net: mscc: ocelot: expose ocelot wm functions Date: Sat, 8 Oct 2022 11:51:36 -0700 Message-Id: <20221008185152.2411007-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221008185152.2411007-1-colin.foster@in-advantage.com> References: <20221008185152.2411007-1-colin.foster@in-advantage.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MW4PR03CA0304.namprd03.prod.outlook.com (2603:10b6:303:dd::9) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2351:EE_|PH7PR10MB6129:EE_ X-MS-Office365-Filtering-Correlation-Id: 45c85711-904d-4306-0bdf-08daa95e30d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OgvgygnLVnPTffv+PKytRFnQ0+cowmj+3yfmNCqfRGEt24IcP6/Ztol3l+c8FDdA3WF2/0+N/YuzNDnCWh50WVs0ZPdZmmqk+IzLl7g3X8AJW9Ta2Bx75bB4t2zmqvx7Nu8w0BmZUB21crxlIYhfja50M3KapSkQ5KBGbrgzgyJc68SJsnxGm8XGXQlqEf8Ow3wgAMy0IeD5pFQN1EBgLt2Gguq9/rMnDa+kTIUAXH1g4/dpq8ao1zmKQP7NbWj0IcN7Eyo//Cy10vhLHHGAvk0INyGzKcZ9IRMtsCt/ol0jjhGffh0ybMgODZWZPL3RW1tfhgp783B/5QRtS+95P3PgdrJ8xs3kUjpWyIZ4bGRjj6moOYOAfvaOL56PBCjtCNiKKZ/zbzbSZhEQkI3RuVG4QR1p37Vds5YUb3KmaDlGax5glO/U3CI7Ktrhufmo/2Hej7FYozEIo8ABzFPfIUTtq2Uhvgbg5/tyIaAAVuQWSA+ZfBZ7Bx7WJHKnVIuoTlIWHM75nKDMEkR4ianWwgCnF6giUXyV4+TAu5CKzfiY7824KdrCJXoJPDDS3i1tkON2jUXNK/MXzZqCQQ694TjKZu/89Bed+p7ZMCtk1P86bfj0/AL9i4YuWHua8d1nLRZjIJk2f3VB7VdNvAmeTS9f2mQBefRSkm2rWolXu08RANrwnbHdW89/mM7FilGoXc213OCv1aqNwdJXyHrNBt7EL5hywURShSwKgShTrVpizVFeB39BW0MrhIv+477vVb5ine0qDxiMA/9EOPm30w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2351.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(39830400003)(376002)(366004)(136003)(396003)(451199015)(44832011)(186003)(6512007)(6666004)(26005)(6486002)(6506007)(2616005)(316002)(54906003)(38100700002)(38350700002)(52116002)(4326008)(86362001)(83380400001)(1076003)(478600001)(36756003)(7416002)(2906002)(41300700001)(8676002)(66476007)(8936002)(5660300002)(66946007)(66556008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?8wvSoL+lXh7J99x5H9SHp5ugetJ/yAtT/mlaBleLdI2Ny0xSg9HK0dhDdb/U?= =?us-ascii?Q?Z1NGF91y+ovB/4QO2ksX4F+LONT4ir5Iq1vCcJtghSHCt6z1wX49lPqIKcwA?= =?us-ascii?Q?pz7Pyx8nFhxOiidmcDUCl71XQk3+BrxG2g4kSP+PVbzOSzI8MDQYuDK0iTGy?= =?us-ascii?Q?lolEeWHaTD4EeELqWeOws+BFzXpRWZL9IZ225NqzO6kHl5Q1o++zqxBK8xcN?= =?us-ascii?Q?pPigKFZj5verq9+za27VXH8M8JR0K5+iwtRGSXujNBtek43i8e+0E0iy7ump?= =?us-ascii?Q?dYUS4pZecdB9ucv2DdFAux+3QrJ78Ns48XK6pvFVh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oTHQAM26qNp78ZO8SeBCKtGSSOn7hKtvT/2QB0laqjPc?= =?us-ascii?Q?9V/g9ZfFkUsr1tH4yx+C5oanao+goW49bw4Dfa/oIlLsmabppm39Ngrj2qBr?= =?us-ascii?Q?xRHA2D0yi4u+JyCz0F7igSPib/VfyPHiiJxSUn6vutzO8c3q10mTq7CQcI/a?= =?us-ascii?Q?bzElz7SJn5cknzK1rB302+JBlrja9qb2Skl3SgxDgEyy0E/oqHxB/OO/nU1o?= =?us-ascii?Q?lBqqonrPlOsnkRAqqveoBZIuuxLqdXGLwyXk17FRaf0ERHhmQ3BeNoNxqadR?= =?us-ascii?Q?nndTgJ6AkZz1CCGy5n0x8+2Cy1lT3tkNyNIYMBnaXphDKLz7PlJvD+Kvpfze?= =?us-ascii?Q?eT0A5Y4c5ggHcfDoXTvFI11zL4nlEWI11qQXMNRfwbyCfwZFZ4G/MlATVlzt?= =?us-ascii?Q?cGC89wpeV0B9GRR8Dloj00Q=3D?= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45c85711-904d-4306-0bdf-08daa95e30d4 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2022 18:52:03.9288 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8ze5kIzNT78IQRPJjnmyEn74GPcalnpRiUNUtfSfLh4m/flPvXeLiG5EhZoEFH5x65H9Ut8+5CU7zMZyRN9gQfYJXlxjYFnNy/vIjBAq5fs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6129 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Expose ocelot_wm functions so they can be shared with other drivers. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean --- v1 - v4: * No changes since previous RFC --- drivers/net/ethernet/mscc/ocelot_devlink.c | 31 ++++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot_vsc7514.c | 28 ------------------- include/soc/mscc/ocelot.h | 5 ++++ 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_devlink.c b/drivers/net/ethernet/mscc/ocelot_devlink.c index b8737efd2a85..d9ea75a14f2f 100644 --- a/drivers/net/ethernet/mscc/ocelot_devlink.c +++ b/drivers/net/ethernet/mscc/ocelot_devlink.c @@ -487,6 +487,37 @@ static void ocelot_watermark_init(struct ocelot *ocelot) ocelot_setup_sharing_watermarks(ocelot); } +/* Watermark encode + * Bit 8: Unit; 0:1, 1:16 + * Bit 7-0: Value to be multiplied with unit + */ +u16 ocelot_wm_enc(u16 value) +{ + WARN_ON(value >= 16 * BIT(8)); + + if (value >= BIT(8)) + return BIT(8) | (value / 16); + + return value; +} +EXPORT_SYMBOL(ocelot_wm_enc); + +u16 ocelot_wm_dec(u16 wm) +{ + if (wm & BIT(8)) + return (wm & GENMASK(7, 0)) * 16; + + return wm; +} +EXPORT_SYMBOL(ocelot_wm_dec); + +void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse) +{ + *inuse = (val & GENMASK(23, 12)) >> 12; + *maxuse = val & GENMASK(11, 0); +} +EXPORT_SYMBOL(ocelot_wm_stat); + /* Pool size and type are fixed up at runtime. Keeping this structure to * look up the cell size multipliers. */ diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c index 6f22aea08a64..bac0ee9126f8 100644 --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c @@ -234,34 +234,6 @@ static int ocelot_reset(struct ocelot *ocelot) return regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1); } -/* Watermark encode - * Bit 8: Unit; 0:1, 1:16 - * Bit 7-0: Value to be multiplied with unit - */ -static u16 ocelot_wm_enc(u16 value) -{ - WARN_ON(value >= 16 * BIT(8)); - - if (value >= BIT(8)) - return BIT(8) | (value / 16); - - return value; -} - -static u16 ocelot_wm_dec(u16 wm) -{ - if (wm & BIT(8)) - return (wm & GENMASK(7, 0)) * 16; - - return wm; -} - -static void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse) -{ - *inuse = (val & GENMASK(23, 12)) >> 12; - *maxuse = val & GENMASK(11, 0); -} - static const struct ocelot_ops ocelot_ops = { .reset = ocelot_reset, .wm_enc = ocelot_wm_enc, diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 967ba30ea636..55bbd5319128 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -1145,6 +1145,11 @@ void ocelot_port_assign_dsa_8021q_cpu(struct ocelot *ocelot, int port, int cpu); void ocelot_port_unassign_dsa_8021q_cpu(struct ocelot *ocelot, int port); u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port); +/* Watermark interface */ +u16 ocelot_wm_enc(u16 value); +u16 ocelot_wm_dec(u16 wm); +void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse); + /* DSA callbacks */ void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data); void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data); -- 2.25.1