From patchwork Sun May 8 18:53:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12842516 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 8FB30C43219 for ; Sun, 8 May 2022 19:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238772AbiEHTGD (ORCPT ); Sun, 8 May 2022 15:06:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241817AbiEHS5m (ORCPT ); Sun, 8 May 2022 14:57:42 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2124.outbound.protection.outlook.com [40.107.220.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F6AFA1B1; Sun, 8 May 2022 11:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bRJxtVS+2JK5VIlrTsZP6K4tMhxpi4jTugP84yfyuqDhtys14l6YN7HF/fzRckabiQx1h7BsZXwUOpeoKjCsaHcoAa1Ru1tjRror4rH0rzKE0J/O54r17Z8wHEDMSRxNnHrDMJfIDDSywiT/Ks6TNT+S/O1Hh4xyUDvjhdBa+xvQEjMT2PxE/0F897n5drzZThB4tyRSZkrqCnEJWjT454PK6LpT1WS1CJaX7X3YCIUyRvZh+xY5LIRMMJP4eA9bZscBKrHNAFP8+PQpY8GI2CelWdDQ5qrAVaYcn6QA0RMq+KDEuAj9L1WbyCs3vh5NwM5w5bmihA71Ne2wNOdjHA== 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=SYnUe1IeJdpSC4yXti3PENMjZ6Mv2WHCNFpsCo+hzqE=; b=ZtuU32Bd5jAC5FwiT/aVu2yqD2wfXB4oI6vFWt8ijYVQdtaRrXFY1xaPRm0PtPsoU6vhxJk9zStwCAe3Jxna8jDpReEtT+baUwNNanifYRfk8O0cjC+/XOk5YEgilM9cohP/4zkszNauqjxSnseq6va27oZMRtZS4F5nqedKvUxcgvS2RFuVr/3IdkOdkmNiwH5NzTx5zw/ZjSXnVnYc2AZWPT1NWniPRbWvGno1xZMI8yjXtXoQCVFO4JJENa6gVvSwsaxtzltBF6l23xk2sDbYwavQeL0OizWVoa/+MiwLJ8+1usrVnrjcpw6vSIlBqREf6ZHOR5bh9HPxpJPp2w== 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=SYnUe1IeJdpSC4yXti3PENMjZ6Mv2WHCNFpsCo+hzqE=; b=wdp0zgXvCU5vslSswFEkkQ57yosmbH76Axfpwmefc6o15MTCaJJLU8IDliBN89Btlr+/oF5ydiufG5bBopd7CXDOJxzugdw0LaGHKGd0xuLyOiZdaoIjiwrlJHZDHkQhq7NpqO7c2wjlLySG8WP1rkNKmkTBmxOGndiFTtwR5vk= 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 SJ0PR10MB5672.namprd10.prod.outlook.com (2603:10b6:a03:3ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.18; Sun, 8 May 2022 18:53:48 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::4581:787c:1a7a:873e]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::4581:787c:1a7a:873e%3]) with mapi id 15.20.5227.020; Sun, 8 May 2022 18:53:48 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org Cc: Terry Bowman , Wolfram Sang , Andy Shevchenko , Steen Hegelund , Lars Povlsen , Linus Walleij , Russell King , Heiner Kallweit , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Florian Fainelli , Vivien Didelot , Andrew Lunn , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean , Lee Jones Subject: [RFC v8 net-next 09/16] net: mscc: ocelot: expose ocelot wm functions Date: Sun, 8 May 2022 11:53:06 -0700 Message-Id: <20220508185313.2222956-10-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220508185313.2222956-1-colin.foster@in-advantage.com> References: <20220508185313.2222956-1-colin.foster@in-advantage.com> X-ClientProxiedBy: SJ0PR03CA0045.namprd03.prod.outlook.com (2603:10b6:a03:33e::20) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e0d43d1-05a0-42e2-61a4-08da312415c6 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5672:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aGH9gPOkAEjoh7KgyEl7KpDcqaoOlF5EEV1KWKtOW39ipcXA79du7EwERiYOaIzWRX3MVArQAc6KFDXxPRhaYXMxBMbTRF5nxbE/yMxfjCL9cJFgF8qlMiG5uNZHQIeRKCl72kVwOw9Zk6aMA8r4b5StQKYDH2RHfWBp+j+FspgP1ugZtlclGMb8qSwuADwXR0KeoW7yErVaMcyHnGJN78yfeC9G2pN9HgI4Kvd4+SSWCpJairM/QTftbXUpFQDn6iabvbMJy7bKiiasBwsh76roUIFs2Kl1sc1jfqQyGugMYYrXq+9w9E+8X9P0BRFBqqwZERNKh3WcO1p5xFT4Z1G1suE33vlfLagDdGh4v/c4wyeZ7FPIfoLcHbARf5NoySExa2unqVLAJa2VjaDThRneGH2heqjxAYZ3bQyf/rhE5Leo4N0bea6pD4Oy8M5zD44VmSch2sxU2MZoJ2Nh0C1xn3cVCmJ5ipKBj9nKXxVn+bSca/8bkV52BQ4lH2yFiuIP42LeVk0RPXzWkXC0W3qpgTJnluGKTbYkix8NriUyUX7cML2OponBCirGInYkqne5twBfue6Azj3cVc64d00ONOHcgPx1/upRO0Ax3+/PSZS5g4jggxhYDNKqEBGpx3aTh9TkNevBAlM4kiD3FHTTNiHAkOOHcPnuANfy86PI3Hxneq31XmR+9Z/7O3JToSKHeIsfUwRFODJqT0FdVg== 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:(13230001)(39830400003)(396003)(366004)(346002)(376002)(136003)(6506007)(6666004)(6512007)(2906002)(8676002)(7416002)(52116002)(8936002)(4326008)(36756003)(5660300002)(86362001)(44832011)(66556008)(66476007)(26005)(2616005)(66946007)(6486002)(508600001)(38350700002)(1076003)(38100700002)(54906003)(186003)(316002)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c8EovN0Lqd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rR+NST3M+4rRjvdYWyLmLtlzNw+f5eW4MXCvf89ZIRE3uNs9pFGGvs6Wfdve6Qz8TlSzJ64IODQwRkm60urS1uSb6r0kuu/KAkQ3YNikbHwNmGhlhFBhFEblRbJvhpaJ9H+dwdUfL0wWeWuHTCTU3S5E7x+1Ff8DVsiDlNjqtPEYlb/mXdwc7snEfYGkW94SUV7QSzr7KgcqdBBqRimP8PE1tMKGz0eHW5Byj0dIRl/gEzxMvnBJC1PY288FBAv/Hnt8MTR/AjmFS2yDsOCs4KpM1HAcckoATQ1Y7mtqI5dPgA1LOmv1OIdbRxq87wQL0OWaBE92WylFehRdbnoEhHIXvuWGXlZe28l0p1lM67BmM5PCQuB0nmJYI9nefbOEt5z8jUO0tEVvSA14EikFBPIfcwRfxs5e+LAgLTR8h9nS7Cs43N5YLIFuiLIe596csuWGkAVUTy7VrwaSLc/fwJq9v2i7P5cdxHYyQsyXzlqdpl5Bc4VgFFNO9pGKlEdJmHLoyrz00dOD4iTuZCwfDrsxrd+gVtknT44PvQTnNcOglxvK8yLnHRIJhSNfTlLyVbpfVANPmD53pB8LuLw2W9ZY2hdKcJ3y9DaxezGaQm7X8gkTirguW/DBsdC2URlk3IrhfKuiuwtMGdgXh+CiKc3t9rR7OA7dZ2Iyk46WXyA2ujXWIQzbRyoQFO X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e0d43d1-05a0-42e2-61a4-08da312415c6 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2022 18:53:48.2283 (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: ib8uPaa+B8ti5/pwO5DlXoyG+Pg19xjh0eJg5d1mKKyoXP2Pkt86bymwBT8Of/W+R49NkVa43ti4mPzx7hhzh3WgR+IsFRJAoCws+Mr36fs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5672 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Expose ocelot_wm functions so they can be shared with other drivers. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean --- 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 961f803aca19..68d205088665 100644 --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c @@ -307,34 +307,6 @@ static int ocelot_reset(struct ocelot *ocelot) return 0; } -/* 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 f9124a66e386..61888453f913 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -865,6 +865,11 @@ void ocelot_deinit_port(struct ocelot *ocelot, int port); void ocelot_port_set_dsa_8021q_cpu(struct ocelot *ocelot, int port); void ocelot_port_unset_dsa_8021q_cpu(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);