From patchwork Mon Sep 26 00:29:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 609442 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 6F569C6FA82 for ; Mon, 26 Sep 2022 00:30:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233074AbiIZAaX (ORCPT ); Sun, 25 Sep 2022 20:30:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232731AbiIZAaU (ORCPT ); Sun, 25 Sep 2022 20:30:20 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2093.outbound.protection.outlook.com [40.107.237.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60CE322BEB; Sun, 25 Sep 2022 17:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HwCjauJMZAN68KzIzYKZ1MQU0xj6S4vbOPgA1Y5kFHHSXjT4QAsM8OPubkO/FPLlqZb1mP23os/cH9ynLhUja1gIPoP13iQd3FHiI3dofyjmkmvcRnL4LRcQv/aFL9wvvXbdZOW7PMOkKrmXhNflfzqhJ3SEXjRpD81Fh1AalFQbmrsBusSrLrc/fOp3Iv8b481iKASEJ7q4xCqOXUbqw8/OYnaUpuLqsgvPOE+sG8wTNGc+JQ3ijzQKZTYk9F3Dl5D2UuaayN4OMwJXIG9eVGe/6KU6xBR7PZPhV7uMBKqhTFXpIw9b5qv2EQv+GJYU80KvJR+10VkGs6utR+HNlg== 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=P0c8wNJsp1ue06+XveUThFK29wEf2+TwqK+jWrEvygo=; b=ayyo2lzxsDwdfDs+rtTOszI36sUJOuw3Rthvfy3DwXZ78wlHH8S88yka+dLnSH6IO9OQfFF70Je7gkVK9g3XCZkQI6utx0ozVgNTUjYFl3iCuH3TlNR6dH8OA9WLT68mshoYyrj5GNgyvUk3D5RTptsIVZZ8U4YPBAqGqxwPVSBLLvny2asLNQiRpa2IffEbZYib1wztLUt2Mh/5UU6U7VhPVhx0xW/FPG1J543KnKnOKPLiJ2WLXxgylCy9zUvOrNdOW8embKrIbdIQGG+UemE//GsRCBjbCOYpVmJgBkNRzwPCsK5dWynbiVVxl1+cDyRFmPuUBywTjubgV1u1aA== 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=P0c8wNJsp1ue06+XveUThFK29wEf2+TwqK+jWrEvygo=; b=Zcktaq4BHs7Fy2RJ1j8ShqJKW7eVulC9Jr6Amqqsm+PsSwnJqw1FEI+P/OQGBvv2C+NtXLujmylittc7begdVpCrDd/I+SA05Y8Pu8U8Os0/x+0jRPX6tmOxeqc/NxuSh04fjfYyfZlbii7oMy2PPX7mU3sBxbD7S4POzSXQSuM= 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 DM4PR10MB6062.namprd10.prod.outlook.com (2603:10b6:8:b7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Mon, 26 Sep 2022 00:30:16 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b417:2ac7:1925:8f69]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b417:2ac7:1925:8f69%4]) with mapi id 15.20.5654.025; Mon, 26 Sep 2022 00:30:16 +0000 From: Colin Foster To: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, netdev@vger.kernel.org Cc: Russell King , Linus Walleij , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Lee Jones , Krzysztof Kozlowski , Rob Herring , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Vladimir Oltean , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean Subject: [PATCH v3 net-next 01/14] net: mscc: ocelot: expose ocelot wm functions Date: Sun, 25 Sep 2022 17:29:15 -0700 Message-Id: <20220926002928.2744638-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220926002928.2744638-1-colin.foster@in-advantage.com> References: <20220926002928.2744638-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0260.namprd04.prod.outlook.com (2603:10b6:303:88::25) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2351:EE_|DM4PR10MB6062:EE_ X-MS-Office365-Filtering-Correlation-Id: f12891e9-c8a1-48e1-271a-08da9f564893 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fh65UwbIIfkLh+EfAI3tbz68Clq3i4cOXVVOTPhvd1rg5QJsx/gJ968eLZ/HpkvgmCZ/UZzFRe7O9p/zN+ICHQeQGN5Vbdm68cCEhn/3CgN4uLMfZ2v8QEP6/ip5b8EvARKDmVResX6+cWPnmNDXZs2qUoQ2qbDFw8kJ23GE9UeM5VMi3KcCNU5gwruVw3gxT5Fa+slmMArSsiW2Ywjx96noeYBv7si4x2gmsCd1Y+URdcA/jFQ5uYLLf6X22LdfFRQuBpl8LW+H3zLrFlYZQp5DyuvN8tu5r82i0Y1/r29PBXXXMlMCej1HnRIESLKoQBX0iINJPOi16FRdBu1Ed+qqjfaoNzdAYb0SUB1iaNpdkR6g0Zoe7kxMUKjgvH//X8CItQaH65Mh4jY9yyF2sXO9ZDu1gKLW9CDqzjpZYJbg41p8cy7lzf+VUBHUorzkPwoE6c+NIIcSpaPe5Q11D68grl+mRbcR0G/bk98I4DnWAddDkMNLiOccsKv2h7KWxaGbjcdxS8qDyCveeAwupOzykW+gdxjQoQE2uU2zePRk4B+rMVMt5FnJE3JCIKslMfSx9cn8FVFv7MAiJYTLwXAy8D3mopXViKzH9KGGjcm85/RAmbKNKiUcU5CbV7ZQGnf30nPdZF+qYQrvbzSMgSq6X6vhcy25FDrpIsmxTqSRBGG5npoyM8RilvDzVwXvoy3jpLZ10hG52w6kKYBLHmI409hTAqHV7C5CiNRT4yzXyNf6HoK+18+9TjZ1JKssQwOAfFNhLhwbbNxx/7/tSg== 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)(366004)(376002)(346002)(396003)(39830400003)(136003)(451199015)(66556008)(66476007)(478600001)(8676002)(4326008)(66946007)(316002)(6486002)(54906003)(38100700002)(38350700002)(2616005)(1076003)(186003)(86362001)(26005)(6506007)(6512007)(52116002)(83380400001)(36756003)(8936002)(44832011)(7416002)(2906002)(5660300002)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiS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hGJSI6wIzT6bSSMoF5eAwcfTBwyNPdnfthEdICbpSIotnafbKl1CMqyjoKZ+mwZnqZtAo7SdU4yt2W2vlsEPC4EdYrcSIpoCPH2VpOEDJD0PRae5oHjX8tXOYnWTsbDrIyw41Y41g1Nhf4QDqkm9T/g3ZXI42K0PSKQ8a9scZ8lb4lQYq1loDQl+WF4cMRjJSDnmqUBvEk4htHjtE1lMR8f0boeYLSRevgIMAN6JlK8NtpgEwbkzN/a18g7U0SNiqUvVtehREL8V+zjHikh4YNnNdDnogCPXKa3D7Mu0CZglhxGINbqRFW7gWAbyS3Ow9FpvPyPFD4ShD2HT1KQkm0i5i4Tdlwc5Kjo9Wr6O40YJzcVR1dteFE1v8PYHar/WD4ZW6FCoAgEdoTRAsmVm8RcW6MavliDvu1vM9MyKCRzii8qgHsfaZtUGr6Nx0IctT3Ti8yai8dPNNzEBNt+MduN0jAMsXEHNlnqnKVOW+eVBRry4ZJxeJp7bP4E1dUplOQfuMK7tA80WfKSA5f2n+WJe+otnkiPbSj7KdY6TEAyMWa1D/9qJE4h2gmGgqzWihTfj8JD5OKEEY= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: f12891e9-c8a1-48e1-271a-08da9f564893 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 00:30:16.7453 (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: mrEQB5ykCuuI/aTqe48R0WneSVxMp3bYTgB67iKxjw3MzRq80Lf6ndWYrx9UFjbPPx2ccp5Cr56w+Wc2QtJLmeXgoAwCzo1FQXb2t2jSGGw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6062 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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 - v3: * 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);