Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp4486397rwn; Sun, 11 Sep 2022 13:19:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR5IaWBXOEEnn41iJzAKxWiOTzmmMtMgGUis3ViqamwGHaBmU4a+GqhvppWyHydvX5qvl/km X-Received: by 2002:a17:906:9b88:b0:773:dd14:465f with SMTP id dd8-20020a1709069b8800b00773dd14465fmr12773944ejc.293.1662927582398; Sun, 11 Sep 2022 13:19:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1662927582; cv=pass; d=google.com; s=arc-20160816; b=QxIQ7YZ9DHdQ3h//MhyOeU9FeED1JqIsJtS0PmboO9gL/snO24UFL7fqXS+W+Wm1G7 vQHi5BH2ftLVj0H4ofV0JK/ni/SiDqTHksKZlHmLy+MJy44VSqjTkFli+6wt0XrV9zzU jUOhY+7rgI6+iaFALAN2a1iaVnDnHwA8zAtDyTEBrEEdof9+eegHXU8U1riePR56m1fZ 8031yVj0h8a1WUHR03rZ8z7pssPp6IMPUfIc/6nu9kbpZm+XwNgaoth9QuJ0/cI0rb5S NyugTjT68+9Nqd/9X8Lkx/2r3Y3tahNihSSWePnMSaB1six463uQFCXG2f9c2dhtesir gajw== 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=vDJ2asZMCdzcj2h86rioZCydCbuKZdsmG0yk8E6bA6g=; b=y86tyPF/VxTMuN9ooaNhgi26Z/eMhX4vsjhSbCLTBYduVgymnFsyxjpOl739E1cryW dDjUlzVwnWJkADZZDz3fUURmZE6Jxnln+a8xUhaRh9xJpdFNvRmMRkMxL16KFU74eDSB pTcjaaBG2CRZXH3DTZKoPh78S9NTE+kI74hlgI/oaptYqG849pxkYRxVsgKyXoo9R5US 2uo0IIfwrhU9S6VU/vi8A70EBLeMvpAYqv+WD4TkpN/I2TtNG3aCLosWs2C5iFtuKxO/ NdtER/e8xy7wV/KC9jmVFkvbR7uLPlh6me0h5aFnWRSaPfcAQXx0/xCIRUsNvFc6iQ/Y +a9g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inadvantage.onmicrosoft.com header.s=selector2-inadvantage-onmicrosoft-com header.b=eFesBvec; 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 l21-20020a170906795500b0073ddf717266si3901037ejo.449.2022.09.11.13.19.12; Sun, 11 Sep 2022 13:19:42 -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=eFesBvec; 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 S229780AbiIKUD0 (ORCPT + 99 others); Sun, 11 Sep 2022 16:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbiIKUDF (ORCPT ); Sun, 11 Sep 2022 16:03:05 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2121.outbound.protection.outlook.com [40.107.243.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D68E722BE7; Sun, 11 Sep 2022 13:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mJNgUEmNXrUyxygg2WM2bakSHnPMgQF5dnqwO/u46njp/hiPT4U11zZ72nGmg9UnSi6Qb1k11xK2u5ncS3nPGC2eyCgi+4ZkIWP7vZDKPGUe6hPXofBN4Znv7sv6wmKiRbMbJ4pa2X/qJi75kvDXJ04Lo5i4/Z4FiC/xaLtouMMp3KhZUjloLiEophBUjSzRzf40W34eupIh8Y2cBHQMrAkfXTbKT1W2CVZ5tEjV/63vbGlmXMBJsOELSC7g/ZKP7AEdmQFvxWQUqH+7fappnufgTjPWq4PbkZM/Gum5y/0bx2uDRoOT2GKQLIJwdr7mWabbRV6qOzR529MTGQdQZQ== 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=vDJ2asZMCdzcj2h86rioZCydCbuKZdsmG0yk8E6bA6g=; b=OLVlQvw/Gu89Q0IGobC/74eSMiAMQSo4Vi1zugg35UjM/3lzBZsNOFUxM6KsXSCHfTzygIjVmf0Ixpr0ydRzyUAAiIwEyDhhBlpUfbh2eYk8Cup6Q34tSg4MAihnnpY9PFi5gLvPgsSaDb+OYh1qB2w32wezoVUCwwhVTLg6QpjCT9P4ZZEhTPwiHpW0eHs1lGQIuxsxQ+TKqvI97qsb7SjAADbGqnbrE8xpAyWApoT6vAv/PomPrHoq83ROIFoGHU34/sqhW0pTrx8cY8V/drSIqw2lHYhDsw9M/NjLHM9JWam/mq8zA+pL70LpPU/lx3lxlC5TeHsuBDex5s7Xzg== 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=vDJ2asZMCdzcj2h86rioZCydCbuKZdsmG0yk8E6bA6g=; b=eFesBvecSsj6fVOd5bLkKytMyOszvlSn9egngoFZ7aoltorp6sFXMG7stGX9/cLu3O3uvPL5o17Fz21ohZ0ZZdrN+IVUbJHxwRuFung0vJrdG38ovwQinr+USzRjxexCwMkoYpPSEx+/9zY9XCPEBZvK89mla7t7A1s+O3tc0c8= 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 BN0PR10MB5335.namprd10.prod.outlook.com (2603:10b6:408:127::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.14; Sun, 11 Sep 2022 20:02:55 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::38ee:4bfb:c7b8:72e1]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::38ee:4bfb:c7b8:72e1%7]) with mapi id 15.20.5588.020; Sun, 11 Sep 2022 20:02:55 +0000 From: Colin Foster To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Russell King , 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 v1 net-next 1/8] net: mscc: ocelot: expose ocelot wm functions Date: Sun, 11 Sep 2022 13:02:37 -0700 Message-Id: <20220911200244.549029-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220911200244.549029-1-colin.foster@in-advantage.com> References: <20220911200244.549029-1-colin.foster@in-advantage.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MW4PR03CA0318.namprd03.prod.outlook.com (2603:10b6:303:dd::23) 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: 8ec766c8-008b-4cc5-cbf0-08da94309d8b X-MS-TrafficTypeDiagnostic: BN0PR10MB5335:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ICA9ww3eJ8tHZbENyAlqmth1FFDRm+V5LZRt0E8M1gnFAgLLq0BrPT57nI0jht79a6lPs2YbHL2SggnDwbE+G7zOZ+0PlLnrF0Mg8yXABx+hgnOkE6AM4xsUGU47YHrzIk21K41cdqiitZcthdfcZBnQ2mZAyGV3CfclmIra1jmU+aTndqQB2FZ9n70GoeTP6wjXSUQnBMTC0AKUrE9Lf67g70oX+jSOZ0ntdqR41VbOKGhwbsVz4nQgFqpq/NTE2pmbG6G0Km4z+R2TSoItcMvkwJfyqRjMsCVhq4dp9IeZczlE4vILy0kKwilC4NKVkXO6uKORLHswzHkRWuZQdTyQtyVeZjVNVd7o9RArzKx/vB7wrSdlPaA7SvTZNGT0Ju86r94pFmPltEOeM8j+R2oVRaHovxyR4b7BdSmd8Nm1eLdoDytkg9jQ9GY68Xm/e0qd9HDTz13H5vgRad9IubjfNpuAgCi/NGK1b/PDLufic8dlWBP6+YeuhM/Wt53k+G9F4VmF+HaQrCHrlx0dDrbMb8yC0llg24ZUM4+KfE4ecQrCotVXgaAu8Rj89Nzf1iYRzOJ064YnRrlGtM8hxQwPDHOwkc6D6XjKWWiNe214JUJkSHSNx4524t+3gXtlpIsbXuKdmxYe4AHy4iH8Det/KFNmk/v8v0gIH4S6Bp80wR8kiKmd9V+ac9Ib+cGpb9XU6VOx9Rd5paY6v7bUbss/QGSPDBO48pdWRLngMNkXlSy8dYq3lw5jjeZPikjzJ9umugfA9QrjV4b2KdaquA== 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:(13230016)(396003)(136003)(366004)(39830400003)(376002)(346002)(38350700002)(38100700002)(8676002)(4326008)(66946007)(36756003)(86362001)(66556008)(66476007)(2906002)(83380400001)(186003)(2616005)(6512007)(6506007)(1076003)(52116002)(478600001)(6486002)(6666004)(26005)(316002)(54906003)(44832011)(41300700001)(8936002)(5660300002)(7416002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?KW4Znoj6WvtNKZSFNFEzs84LfXtxg7JPuSMFi6gpSibVW55gVq88/PU+lEeJ?= =?us-ascii?Q?is+qiAYTJ51YXA5f8nymujCUGVnv6wF4v5pnxDAvEx57m49C2zMoX/rNZ0QV?= =?us-ascii?Q?mosltOjfgrkCVftNn2MKOUGsT4hgzc8Gd+NnKPZI/qXHmh8YSvE9ePwytRqB?= =?us-ascii?Q?I+jMEiVp3hhcCdiTGYMBlj0TrRHHbxyKtNP7/QcEtsBO4VEUwU6O94FpZBm+?= =?us-ascii?Q?nkdmZmrZJsXsj4cz8auK3iXJzRG+hda4dMmzhTAGUJ9q5q3Yd5+Nbs/JVxAI?= =?us-ascii?Q?5CvrckhYNNalKPheKwTQvdN02TZDmO0Ag1mkHYVgyzgVq5J/6+iFZSZuQ5w5?= =?us-ascii?Q?dyVVMPX3M5Iq6vbEz8rXGNXdVKYhKDG42MD/QdyDuOTWYP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Z26gvDxHecusAHoH8x6xPdqYrsPYG5l5jn?= =?us-ascii?Q?VmeaxSGWvZLAhEHTHEY48RARycO/yelLi646YU2Egkh482pxp0eG2qgRcXZR?= =?us-ascii?Q?vrVm8trZJpSVPpxFR7ZGVW0UuG1DrKTZkJ8lQlwvJaZ6IhDp/h4P2gBKMTcv?= =?us-ascii?Q?A+6iK5vrub/sEA67q+g9bDSArMZcx4kB43N6cN9Aa8C84umazc6mUyVHH+mS?= =?us-ascii?Q?Hbcm6aVsh1oT3tJN5ViWbNkMdaHeUoES59E9jwDMtWzXGvGvbnVG6DZDA38P?= =?us-ascii?Q?42qyu6wvCuXrIaLhXZL19eAIWnFw2UoHXWHCkVZEVwDnNT5DtzWmKqC3CYAd?= =?us-ascii?Q?yESUegQ419sNrpoEvHKxfqc=3D?= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ec766c8-008b-4cc5-cbf0-08da94309d8b X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2022 20:02:55.1059 (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: ulclVo0JyinfMFATda+2yFdtq5VGIt1lH2W/iw8azRPsjmeDgGGsQyfvD56YwQTLcRhHOilxruWqbLQh8hTHcN4aff+I13S0HgBgzWRpY/E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5335 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, T_SCC_BODY_TEXT_LINE 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: * 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 ae42bbba5747..80e88bfd38ad 100644 --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c @@ -214,34 +214,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 355cfdedc43b..17dd61f36563 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