From patchwork Thu Feb 10 04:13:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12741236 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 6156AC433EF for ; Thu, 10 Feb 2022 04:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233099AbiBJEPi (ORCPT ); Wed, 9 Feb 2022 23:15:38 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233087AbiBJEPg (ORCPT ); Wed, 9 Feb 2022 23:15:36 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2098.outbound.protection.outlook.com [40.107.93.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EAC05591; Wed, 9 Feb 2022 20:15:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=goBu0WqNtqRpRZIg53BYFwrETO5LgbvwHbSU1cDmvUSPgRjtKYtyo7Ifscd7i4j83Q+yFOi6EwwR6AXvgRHs2IT1R6wnICLfvlpER3wJot7gN78i5yPnR8b3L2dFoh/hnxnDBou2Pkq+eCv27sQw6TDInazzu0oRdU+Xxef0EV6sMx7q4eWhl9xXe9lV+euwZGPCW/IOk8PkjunDTTGk1VeG+I35laQyQ96/jWhduT/I06sjNarlAdVa1wYLR8P/tBPq4mRRJJbraBtS0fbqmCaQw+jjfALVMi6h2mAUYAywu/l3y2gTSBYlHp9eDfdC8CqDZVoTl1ZkUuav9x7oeQ== 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=4aG2oIUQ/mI7G40At3g+APWfeyXJe5mF7JaV+F+KQ6s=; b=kqNgkw1/7cacLN1DITOT0NBIcXm4pjOJuMLV2jBQQ2dzSh2kZSyH+zUMbtgx3n4g5cYTpfDav+aJ92D8ok1nX1VImTLqa+VFtpp19+kkJDWrSy4ujiG0DI5WGCOGYms1v2nOyCh/IwAfQe30xycN74g/0h0AxU+/t6yaZnoCRw4K59pgQvfrUZdC61kD56CAf1N0rVNLFzrJCTzVCwVY4MuGY4x5KhgK/R6kV89lH5+v2qJsi5LkjyX6zwt/4wb754xS7vG2H7TLwHKQCmLvKVFv3EGRwejMU8pxvb3XxWZL2J66HreND6IKoLWjsiOsh/UvIYodMWHYp134H+1vdw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=4aG2oIUQ/mI7G40At3g+APWfeyXJe5mF7JaV+F+KQ6s=; b=NsxGzcsNUT7nBJJHQrD9GhqdpajgXcq9Kl/9Ev0OSeZRroweuh4l/q2O45qmXMhxn/pnHZoD7z/rxYr1Ffha3t9KPsgGhB9ceTWw92oSPObLuA3U3fbBezz7/cm+V2++B1cJK6pthakInewnaUxOIc5x2+Wt08NKQkcosJScUJU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) by BN7PR10MB2564.namprd10.prod.outlook.com (2603:10b6:406:c7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Thu, 10 Feb 2022 04:15:34 +0000 Received: from DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4]) by DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4%3]) with mapi id 15.20.4951.017; Thu, 10 Feb 2022 04:15:34 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean , Vladimir Oltean Subject: [PATCH v6 net-next 1/5] net: mscc: ocelot: fix mutex lock error during ethtool stats read Date: Wed, 9 Feb 2022 20:13:41 -0800 Message-Id: <20220210041345.321216-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210041345.321216-1-colin.foster@in-advantage.com> References: <20220210041345.321216-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0084.namprd04.prod.outlook.com (2603:10b6:303:6b::29) To DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4b184d77-46e9-4dcf-bdc1-08d9ec4bfbc6 X-MS-TrafficTypeDiagnostic: BN7PR10MB2564:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lm0nirG4HIOyP0crUpvJ7KsZb/k8KCQ/64J5RHIA/YCy5BN1UKrscBHo6bhEUXAx0slPl4bLId5xBmsEBpW9C1rQZ4ZHnp9rNg0EuXpDd2bpx+nTkn4nLu+VUT8MdcaEOK+rbDogEnIeAr46yQ9wMNjxanm+oY5YHJmNKj+QPE29jpSAZSYCYmCN3Wh+5N6xUrRWkA+aVUSDnU+AgDYJ7qHtYAl4FZyupEXFKHYGV1E2dOp80j0J5nszFGhOuG4CfgnW8L8sB8crhWfimqp8WveMtO9oymgMX4Pn0DiBg+f9Ywf0cj+anBLXGNdqZ+U1o9reZ/rq44tL2A8EE2wJhVNJL2u7VxofmXoJE+vQCxaz2up9X69M3/uJbRSFRuambnrrxGH+mFOEgWnXdJsg0WHFvyYPsbcuEMWwLUHjJpwz9su0hUGsQvowaTVGZA/jgjcb2YA2TLNOHJiT+5zo1+nAD5II1/toaL3jh1AmDKqy/B1o4gdORFwxfTxnY+NPmUQjd3OKllIhASLFoIMkskyz36+9yjsJx6fDFTdl6rDVPvX5nwNmdChqaEQ5zWekEFTqQ2B6yDYSl7ER20fIABUeUi8Yfm77kegDZzcivoZ/NEc3E9UOC8NudBTiG2HvEEQ6e/7dxg6+Q4GI9KA8YpQtfeGKop7TmEq/HOAl11t/5swPUUl2deqER1JQof3fi3mKIwgiRJ5ILwA0h8Ldjg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR1001MB2345.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(346002)(42606007)(366004)(39830400003)(396003)(376002)(136003)(316002)(66946007)(86362001)(508600001)(8676002)(38350700002)(8936002)(4326008)(38100700002)(2616005)(54906003)(66476007)(66556008)(5660300002)(26005)(44832011)(6486002)(6512007)(2906002)(6506007)(6666004)(83380400001)(36756003)(52116002)(186003)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aVeDfyUUkcTkHkLUVkrijv6Nt98EHQUhUL8PjoMhRCqVxXSCP4LVAecYIWeykXn1ONT8Sc88swK/UYLGiOydF+RGCY6+KDLF8kctTii+efca2xhPCw/+pC1BZ9wNv/onzfYtQevmEXLKuzmLy0v5gJrVlI3Fpz95sygxJRVLx+6NgpU0ll3CBju8tK05Bz2fxU5NzK+Iu46AjAPP9Ae06eSusUtLtAcuKpHXG2DgHhV9JLHFlZ72FcHQWTQF0wF1wQUlYNbR+s1uBozRmUnChrx/bsh0haQuOoMqLvqVNVqABB/Z3NNHh94UEqtSM1aJsQsHkWJoFRNo4l+URazDWTNY7aE00wwvz5IyuJJgucO9t1zVEzMkhRGi9D4u25VUQMM6tyc2iMGple5kuom5bhh9vsUOYA08yCxHhxLs5LBdL2OtPO3awwHM6bP6Pg9mJ4rWjbBLwr+yqRAj07n41gX+WEwMRmZ/bkMdOeqL/SBVUbxDebfMgN2EI7kXBLIw5JJvw4FVAb1t6UtKZk5bmgd50wHe5usjSMf3coVob6ZSz2nOv7A3lRslbteibfGARTwszwwWjJuk0dynQFit0CG1lAXCLaPtfg2ltfK1rATN4UCM5lDk3kie65eMtLSHKAwLNKEQeNLLkhhp4zHSOXGA1nJ3AQ5BTBWgHkPOuEBza+OBzKwXYLiPyWvENNHKdqOoPVtI9LmF/nlG6KMYdUn8yDuQ7WbrAvguahkM1GL0vA2Cfzf3s9vtMQ5mjhTvLTdrhROw3YdKBjP3qv6LZySVEyZBwwH886yqMf6qp4yvNhIVSqVuQ542PY3gDNT2BtcUlAirYzLuSXAUyGq3eFrqMktPlN4G9FsQwwkO++KEGT7tlw81zSZWd5YxhjtOR86eINqoX4eb9eN7Hl44kPLIkbSeuObIBptGA287Em1A1W5+lGR71FOXpvC8UrC+XolLc2XfMkLv5jKX/Y1Z0eH0adPLPqssZ/aAlotxRpxjWA5IwmZL3rFfCoLXcJuqyIQ5LWWN7uPMZ0arfueZR/isPAEo6o1/YolM2ZtovSE/vs/EQIqAjxdRNIcSVPiq8eDO+0WE42wjDNhfrsjYM/UqiS2HLBzm09efsTQjJjXNShLUjq2lB5lWhsaN9wZKg9jgUHOYqaqYIHX21dmHrlUWI/O/OPBiH4PY1YkPvPU3gb5T6wmOX3gCb4LBN4/wYGejMMjwEYoiar+vcOgcQICB8Brq1xPdm/BAlGMHRc/Z33Fvps/aCqI/GXsMLoXLadrpOP4Er7karRPjGbLKsWyT4VcYMjNs5pEhwMGuIlRIgvAi+igWtXdxVTQ8Y/J028eeYDwNhNW2qwOJaO2CXseeGQKZqg5sJeVttG6ns52W3t40v2eWgOSljb+9VylcGpUkdZDh5KPzXkYSehjbg+5bMQblkcVzzCqF6zdrtHY3li8woXMxk6F8O5BAUuLpfovj27pk/E6Op1lxJCXnZXWlgz2AinuJV4yWpoOJL0/YLmITg6J1DJ5zQP2oeG6pfMHGfXEDSqzs/S39f0ocU5tJY3JhELEX8lFOXBWHuMNNkTcCE4tvdChNeMe+wFmu0D4dufRbOwJJCoYVuNIFg4HdleeNN1a4ojbPRnVKOkBjYltemKCkZolIbYWVvSAWMdFwNveq+XzqeHQRCaVbngZa6pr3+575qQ8wtjyshYQ= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b184d77-46e9-4dcf-bdc1-08d9ec4bfbc6 X-MS-Exchange-CrossTenant-AuthSource: DM5PR1001MB2345.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2022 04:15:34.3100 (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: eegGckG9wKtdC4q6HJSw8wB0zEC3IPlVWSYojEtp/NQ2SgNj9CnkuDY6dNmBAv/jNVzKaApihLYyD2Hkqc5Ukqj5/KzCOhOdxQ/Y4VDk7pQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR10MB2564 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org An ongoing workqueue populates the stats buffer. At the same time, a user might query the statistics. While writing to the buffer is mutex-locked, reading from the buffer wasn't. This could lead to buggy reads by ethtool. Signed-off-by: Colin Foster Fixes: a556c76adc052 ("net: mscc: Add initial Ocelot switch support") Reported-by: Vladimir Oltean Reviewed-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 455293aa6343..6933dff1dd37 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1737,12 +1737,11 @@ void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data) } EXPORT_SYMBOL(ocelot_get_strings); +/* Caller must hold &ocelot->stats_lock */ static void ocelot_update_stats(struct ocelot *ocelot) { int i, j; - mutex_lock(&ocelot->stats_lock); - for (i = 0; i < ocelot->num_phys_ports; i++) { /* Configure the port to read the stats from */ ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(i), SYS_STAT_CFG); @@ -1761,8 +1760,6 @@ static void ocelot_update_stats(struct ocelot *ocelot) ~(u64)U32_MAX) + val; } } - - mutex_unlock(&ocelot->stats_lock); } static void ocelot_check_stats_work(struct work_struct *work) @@ -1771,7 +1768,9 @@ static void ocelot_check_stats_work(struct work_struct *work) struct ocelot *ocelot = container_of(del_work, struct ocelot, stats_work); + mutex_lock(&ocelot->stats_lock); ocelot_update_stats(ocelot); + mutex_unlock(&ocelot->stats_lock); queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, OCELOT_STATS_CHECK_DELAY); @@ -1781,12 +1780,16 @@ void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data) { int i; + mutex_lock(&ocelot->stats_lock); + /* check and update now */ ocelot_update_stats(ocelot); /* Copy all counters */ for (i = 0; i < ocelot->num_stats; i++) *data++ = ocelot->stats[port * ocelot->num_stats + i]; + + mutex_unlock(&ocelot->stats_lock); } EXPORT_SYMBOL(ocelot_get_ethtool_stats); From patchwork Thu Feb 10 04:13:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12741237 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 D32E5C433F5 for ; Thu, 10 Feb 2022 04:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233155AbiBJEPj (ORCPT ); Wed, 9 Feb 2022 23:15:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233116AbiBJEPg (ORCPT ); Wed, 9 Feb 2022 23:15:36 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2098.outbound.protection.outlook.com [40.107.93.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C931655B6; Wed, 9 Feb 2022 20:15:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aumz750zjEbrmhQ4gCx8Q9DT9zCgjH0tI+kyn2/fKZz/9Pah2MtiG95AmWslAlot4xspgSLJHZBPKubju0Wwm6VDSzMlBq8Jzoy9f9EveQo8EN4grcJR8F0bLKbw36ABzdG1eJKLDhJMV94sc5NIUeod+IpmW/5mJP8FJa4Tn0eslVT5VnoPPL1hcTKCqtXI0EVeKA1507rhH1ZydI9iAj+bMTR/dpRWgkbwfDSqGaGPd65P0MX9Hv8xKDjGC6rGjMQhuaVgey4LjgYeeb/7UfY6W1H4Orl67haTIoGJKTEAjgqvEBKpSprPIlJGjZ5ohxeXDUMusGPyx0zniJa2Cw== 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=64JdQrorSOzXXiUx/CxRquRBwwgUczwJ+Erb//gyknY=; b=oUOwRP/RpPiLSTKjjkKbA6mmt16hpo8oN4AXDJQxI3TtZjo3BCz1357tLy/3RFIycwrEPQvUIzp1oEYmAFzZJNhslo6Ue/pHTjXhyThx5zZQw3I0awqcJm5F2286tJ9PsWRuDCW5PLuNEkrg1CTv8aZpVUmhjISPHumpusFvKXjsanSgzrW0jenOdpCy1SbnAe4vIdsMSf2hWDx+mu27IfM9rnbI2GrWrSpLch30aITCg+Nmjgy//2krn4uU1x5BQxFGpbuot4/xluWEa//6LJdjI4dKb4R3IuYNNyZMFYGj1quePKDq1Vnh63X/YGD5FBxvngHPvk4t+IB+i3UnnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=64JdQrorSOzXXiUx/CxRquRBwwgUczwJ+Erb//gyknY=; b=rlERPA8EBZbqa+Y5lSFes0Bh1CCBuNmHQIbv5o+taDwvs6dDSPaJXJBCEQkXaEW5OFXnm3QKE+EsL0KXcAxeT20Q29I90kyXvk9tZAuVmObu2x6FV0uPICtkCrffhePUiD9cMLL9Ywes6hTJF11M27kcOe7GJIifULp5eP/j2W4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) by BN7PR10MB2564.namprd10.prod.outlook.com (2603:10b6:406:c7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Thu, 10 Feb 2022 04:15:35 +0000 Received: from DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4]) by DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4%3]) with mapi id 15.20.4951.017; Thu, 10 Feb 2022 04:15:35 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean Subject: [PATCH v6 net-next 2/5] net: mscc: ocelot: remove unnecessary stat reading from ethtool Date: Wed, 9 Feb 2022 20:13:42 -0800 Message-Id: <20220210041345.321216-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210041345.321216-1-colin.foster@in-advantage.com> References: <20220210041345.321216-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0084.namprd04.prod.outlook.com (2603:10b6:303:6b::29) To DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eefa4083-9ead-4a6e-018f-08d9ec4bfc70 X-MS-TrafficTypeDiagnostic: BN7PR10MB2564:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: knRJ6UyEAnXOZnVvlgIHsNXMcVUGcgS/KtgGtn32XMUj0RauaINP/UsemDW1Z0UubeV24W+LTjC+yZ23aWnp6yC8aNNQa+nbDaHKzFqLF2MCN8rM8Y6OZeNmb3jgwvEWAOAjgNgLy8rWR8N7fsde8siSzBzGnNkGmkHwNvz56ZigN3a463CUHoW7db251N/G3GC3pUMyCKJMyzeQzbp4QOsSJiqXz03/JP1r8GsL2gFbFdrnQZ402DMVhFFNyct6JnvDw2RQsT1yTawLljhJIPd2/nCgWmD2FxhrmaRHIB168cf6nocRHAAimUUpzITQXVb4pWDwd5I80K4bM27eyCFSOTuZsnBWbO97/tHKru+wbDZpPT5rHITsNwNbHnP6eHC1d9VA7asCYnXUH3ox/z4wEGTCs8a++yj3gvIdIAq9mymY4JUnt3dypt3PLdDZS048bejUsrBuci7WiB1HQLLy++19cmsZ2A56suwlq2RJ6+B3BmVTg8vu60ZX6SkTyVxK+/kihiLMTb7bgZKaGLG0yDtwkw2Zh3Q3pPkH2yHgujThFcFqA/07jET4mplGXLiPR2PXFV8fjQPeRla67+nZhgNJPaICQu0Qzda0bFc8hxGZJZFEAVSAqFQffK6RMh38YSFzA1KwMo7F0z7XyPoJtiZkZztbFXWnrcE/PlNrkXU/Jxz0FNg1w9iJGEuQksQ+66eggi5kCo7EZRi45g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR1001MB2345.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(346002)(42606007)(366004)(39830400003)(396003)(376002)(136003)(316002)(66946007)(86362001)(508600001)(8676002)(38350700002)(8936002)(4326008)(38100700002)(2616005)(54906003)(66476007)(66556008)(5660300002)(26005)(44832011)(6486002)(6512007)(2906002)(6506007)(6666004)(83380400001)(36756003)(52116002)(186003)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5c1mrxgVfSLWm/kbk9H3l19fQ9wJtV9t682NTRFpzH55JcNnJkmy4ogv3cTsODyHedXcSynd6sij4L0ZOLQp70QtmI/vZ4+qxv7Y0vTEoNFiPFvPL/xSXUHUMR0idufpxqm6+Yzgyun/H5HWWAWJH+AXtUp7jGb1MVAJwAkqImhGHeczLIC9E2Q1sqGns4+NXG9GCHySXqyhUoeck4WmVYyzHU6bKNd5nS4j3IegCgepz+rjF8eYFfCAkyqQzHYb+G94FQCW6CLXjtViobIgOFY6feSCeaH6zJrTZtZAWm6b90Uz3PldkQ7TvyLAYiU8ABP6G/aZf8FDq8udZZbnLsD4flMTgnxFlE7WfANfaf/5zkc4g61FNAnPPJgASjnpF8rwvc5M3xD24JI7PfpjzcRRpJoJRWZ98YW1IrLaAKWlRRjtfTIshpgLtuGbQ74cxlEDlQtQ6/fKBPAtHvaa3W/uPurVvcZRCBl1chNV3Q0dFBNdu5sOWMhIa4qXxi3oz+wSW1uR5q0s4qTts0ZGQxpO3+EuL+CFpa4CD09w9aMB1NgJqxY4YnS68J6eCu6ADCfzhVZriqyvn+Epw1aG16g1hQWJ1x3hgj22OS+n0iexwB896E7NBD0O+PCdBHNXLte1M/Y3B9aZUP59E2ym4Nc+d+a97Yewvl6Q1ADS2e9FScdsPTllz8beGuso3qM3smUm3LIfEI6k7B8PXQc5sEz5J4MIoMWcuqnFvzfOQvLoZ+dsFXWfq//fg07ySzXI3Jp7zLmhJK/IEJbaotsWvvbyjN630b5le6QyRRmpyTJswdVZ61IXcVuhzItrft3p2G7KVySD2VDDHNjpJclH8oqAlhDPUIX22ZOdhjK+uFBmusLRG1DXOqelM1erv3gQvd4A9vTj6fxEse2jnt5ekmMdcLBmJOLqzUHDCLd/S282p20SWSa7S8rBcEI4B94BQwtg88RGeDvJn6RrdvVkX9QDtW2BgCF/2LoqTOTbP9CfYfEqKeykbQl6pdyc/G1YnXarddfQ0PQL+SnJdjJ5LX4fT8p957gHWWQF21hgc8Xa4nGuejgehyxbMSAzIoh1u7RWBd48bDDCIGkhRkCy0xp5WnOFcao5U+idAU9IudTcPeh/g+DNILri3zUx+8DG0CrQsC9SMZwZ2wCH/8uMCksuN7OhyiNSU4PlMuBExAR3ItDcQRugNhcwdbtCr4Uz0q6gTcAYJl/Z1XDTFvrqyxzkA0KWp3tScoSgFkLYkgu43Qqz3Ix+fMk7JnAloBPWgYKK5vGDz1OGqhSmcwtYMykrpRXdnO1YEFA2YopZug0Xcsvj9KGcXx0gbEdM0ql7ClCtfbM+M8buv9FOFgF8buVabvogVF8d6G87/5AS7JeJnauNDz8TTTKabZ6H3et9gR2sY3oxU2pY5lQJERRc+tMWBPm7cfzdeVazkBZojzp6ISdvdwR3cuR4qcQL1kjw+kBmsRRCFwAQlxkIu+zSC7gITA1fzW0JYjRTyERwPSDJsD7pCwFjv/eQ83iUnxNwWehvN+3mwmvCxb325cy01wieA7iv0FJiVLcLKaFyhYqqfgGshkZpW9r+eKNDMw0T9lTQrzovMAiEI6MMGW1hmzSCu9SisJsYmd/IzpV/8+P0JZJgxzNn2BJR50HiHbG+Awv+catUhvxA92AUVRl9+wQF+l4vluP+4Tv0fze0j5Y= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: eefa4083-9ead-4a6e-018f-08d9ec4bfc70 X-MS-Exchange-CrossTenant-AuthSource: DM5PR1001MB2345.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2022 04:15:35.3255 (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: 5hONyVS08VSCECmBtnJ/NMrvbGdHAuunNXjgJ+T2VBXfTl9bsqakrgmR0wB81bEtgMkms1kM6MjyYgwC7jbEpdsUKmtc5J0qD8KoGgItRg8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR10MB2564 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The ocelot_update_stats function only needs to read from one port, yet it was updating the stats for all ports. Update to only read the stats that are necessary. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 6933dff1dd37..ab36732e7d3f 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1738,27 +1738,24 @@ void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data) EXPORT_SYMBOL(ocelot_get_strings); /* Caller must hold &ocelot->stats_lock */ -static void ocelot_update_stats(struct ocelot *ocelot) +static void ocelot_update_stats_for_port(struct ocelot *ocelot, int port) { - int i, j; + int j; - for (i = 0; i < ocelot->num_phys_ports; i++) { - /* Configure the port to read the stats from */ - ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(i), SYS_STAT_CFG); + /* Configure the port to read the stats from */ + ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port), SYS_STAT_CFG); - for (j = 0; j < ocelot->num_stats; j++) { - u32 val; - unsigned int idx = i * ocelot->num_stats + j; + for (j = 0; j < ocelot->num_stats; j++) { + u32 val; + unsigned int idx = port * ocelot->num_stats + j; - val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, - ocelot->stats_layout[j].offset); + val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, + ocelot->stats_layout[j].offset); - if (val < (ocelot->stats[idx] & U32_MAX)) - ocelot->stats[idx] += (u64)1 << 32; + if (val < (ocelot->stats[idx] & U32_MAX)) + ocelot->stats[idx] += (u64)1 << 32; - ocelot->stats[idx] = (ocelot->stats[idx] & - ~(u64)U32_MAX) + val; - } + ocelot->stats[idx] = (ocelot->stats[idx] & ~(u64)U32_MAX) + val; } } @@ -1767,9 +1764,11 @@ static void ocelot_check_stats_work(struct work_struct *work) struct delayed_work *del_work = to_delayed_work(work); struct ocelot *ocelot = container_of(del_work, struct ocelot, stats_work); + int i; mutex_lock(&ocelot->stats_lock); - ocelot_update_stats(ocelot); + for (i = 0; i < ocelot->num_phys_ports; i++) + ocelot_update_stats_for_port(ocelot, i); mutex_unlock(&ocelot->stats_lock); queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, @@ -1783,7 +1782,7 @@ void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data) mutex_lock(&ocelot->stats_lock); /* check and update now */ - ocelot_update_stats(ocelot); + ocelot_update_stats_for_port(ocelot, port); /* Copy all counters */ for (i = 0; i < ocelot->num_stats; i++) From patchwork Thu Feb 10 04:13:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12741238 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 465D2C433EF for ; Thu, 10 Feb 2022 04:15:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233195AbiBJEPm (ORCPT ); Wed, 9 Feb 2022 23:15:42 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233134AbiBJEPh (ORCPT ); Wed, 9 Feb 2022 23:15:37 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2098.outbound.protection.outlook.com [40.107.93.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6D2F273A; Wed, 9 Feb 2022 20:15:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K3VBYf7+ru4CoJhH8EPOJOS/HzNCp2LPqinJ60+J7X3V73dy0FKd48OgxRU9C2PFejEjFIXE0PXsmzn5taH4AgoRuhjzj3lPhUkP3xtSgLYGyeWjaaAxV+z09FDJltS56LGu3icpHsCAm0RX5jWTdPZOB0GQ7YmhFis6V8b6TNcAfiC7pXYOOEqvtwdLUQGfAz7OD+RVyFYMm5W571/Bzm4Rv88tYA35GAid4CqC9KnR035ETo/j/43ce91ywjtnL24kRZZHA4pGpZMO0PCwH2AbMboh3jTfELh6jCgSH7yTVdGWHsLcvG7dsWcpjzrR/PYup3X0tVJVIJr80M3nww== 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=h5VZeZLsIGqRGKTJuhtykj1JlNQTe0Ojr+G1AalvZ+A=; b=EsGSLNmgA3+9EsDmW8LGMrGHdFdsD8SkqqchX2Oxq8WhaAgBc/f/PvBebUNtXDQ1cO7LcXssPS6mH/JfWRLlGot0QU1NTIRUva4n81Aii3sae9ldyAfk0LYEXvop4la4sziXY6PePFITODBfa+IJ/aCtsUjw5qv77oMzek1UZaiNXsYQcGCIjuQ83ie1Hm6kWJLXhT2tG+JEudP1ucUYhRZd1eFGXuWKtTv86HoVJyj9dH/h7TwHT6A0LD57WKZfII/XHLU4ctieGWJU+pARrynHh+BWxjoiwU/j9AZcJoKXg4tG27gU8KaHfwykqSaGG5DPts+fFCDeexfgCB1tVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=h5VZeZLsIGqRGKTJuhtykj1JlNQTe0Ojr+G1AalvZ+A=; b=Kmt+MDg5ybZIN7yrKjSJdg7m3qahRMRPlA+vYcanZQ8uxdF3q9XUU3jslBO782FNXVivNTxXVsxbSMmEbme8aNQPYJK4PY+lXJslPHlC47roExmqnVfBdbQpMF4027SsDIdAk1TdMFzMvhxlcgutYzbEtSJXMZAE4iw8/6ztZqs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) by BN7PR10MB2564.namprd10.prod.outlook.com (2603:10b6:406:c7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Thu, 10 Feb 2022 04:15:36 +0000 Received: from DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4]) by DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4%3]) with mapi id 15.20.4951.017; Thu, 10 Feb 2022 04:15:36 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean Subject: [PATCH v6 net-next 3/5] net: ocelot: align macros for consistency Date: Wed, 9 Feb 2022 20:13:43 -0800 Message-Id: <20220210041345.321216-4-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210041345.321216-1-colin.foster@in-advantage.com> References: <20220210041345.321216-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0084.namprd04.prod.outlook.com (2603:10b6:303:6b::29) To DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a30a696d-aa05-46f3-954f-08d9ec4bfd08 X-MS-TrafficTypeDiagnostic: BN7PR10MB2564:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O/y0SZ5Dn98uUwrlLrWA3Xeka0xMXQA82x2lKkzdSvuwCG2xZuHHcAMZrJ7J8Okwbq4XolrOoYj5c/BeVEapMYz1UIMMycsyFg1j/dNxeWBkYjfsHBg6TMRvLr1sNMyDiYBfbz3xtpAfiTYWS0rzw7IT9RJUk9l+it/Wf1H5ZPPhkgAGhRQdkJnhV+0QUsMKLlV1LIwoVXodWL/lTUutACSlUiNGmnjtS+0v3nutTxnTzl+BWNhIw+rLoClATI0DKIr+gKDK4W2mdbbqmm+Fyjl08m7DHhVOgROkcPe1JFulMCCS59wtj6e3wg2lox3CHQXbdBTzgCsG4wIQzIvuCjP9Aegs2136ZsfpW49vGpp9co25Jjl+E6+tHDlmHOkbH49cgPGASfZJE+9JEX7F0nNPu5T8QiVCZDSM1CWCIjMuMSXf8vV5UINc0H/BTwCG3q3g6p1N9+AoNLx/xIccC8SAo6vxqirNnhXhr7NEIPT+i9R2mrzvZLAFnscnwdNw8BARQQB/E/KmgYocPCfEXV9gZ+bzewlFsn3BIdxsFWfMO3/gWd39vElX3IHPaPLxuUb17ThuzNyrlj2D4XfdzRhbDe1NoTQ1f8rLmU/ut2QFhntRQD1z2PNzqesvsa/VQYqkUp+Yxe8dyK5ucjnduz0PrnRlzqMjFqpxVjmx7lboVziob/c13nFm5gXKf3LCIXsnGOWscy18W/4/ebWi5g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR1001MB2345.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(346002)(42606007)(366004)(39830400003)(396003)(376002)(136003)(316002)(66946007)(86362001)(508600001)(8676002)(38350700002)(8936002)(4326008)(38100700002)(2616005)(54906003)(66476007)(66556008)(5660300002)(26005)(44832011)(6486002)(6512007)(2906002)(6506007)(6666004)(83380400001)(36756003)(52116002)(186003)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GJIIes15F3thn95N08V8c00NCE37O/gquOreOZJx5OiDGW+yYe/aGvf8CN//56oP7C1wxiMzK0mtP2dFHdPcb+4q3IhyLLnlXSU1FnGr6izJdVOPvNOzUJFXyDxTb4BmZRpSX0wTgRL+WBoQ5EDeGVSKA95BPauoJ2NtKQaEwYRMqax371jC9SkgqFqenUYpc3BMRdLjUTSmhUW70gkKtqPxBdHXAJygYCVloj0Aqi+dcf8aj2gwvcVAl7wlT8BFXIAcU6sA4kDNORRzFWcaU0CKvEcgW3SXuQ+Ldv2CRTreYoLKW3eqXesJNtQuktiZ/qmof2r/1J+ccy18/RGeKNCV/p9OlRpF/T9ZK9zEN5FQmp1U+0Pnpc8sW6/ozdDiQhkjofJ41vnLmFUQg/C3GbflvDTTou5MPAFSvlW1tuIrSAB2kIc/+xnkEW2E39ew1oEHca2+zMhxyF3qQEkQI5q8o3Ok4WigGLRtnT2JvmAbEZGZwyMKNSNhmDk3/ai/AxXLMUjJWYAAqe/PwNh9lQfAyNm1JaxFiRMyYqqeZzO4o0Wab/YDm3HyNTJVoTmHz+yTWLsc++SCB8i+Ni8PTsjvCXrCaD7Q/3js4mHvB1lSUFaVIXOCm9liTpF/s9GIUii4txZkMd1KYBirDEXfhOvNWRvl95DY3SvheV10Mrj8COHDnZFfwH9Q/cnsVox/vf8IOanJjHStpoyZUWhIKGbmq/4FcBJloO8Z7vAaT7eZ3d7LYbXyL7cMiuseVjBvbsN787Bk/Tcu/d9WTfyZaFtVR+ERsjCzlY3OT4MuclDktoDv+bZ/i79o8C7XDU9fphwJ0SmF8NWv6u/qbO0c/vnfsq5v8Lx9JUzucSbgoY53YhK91UaAKzXFNl0UHofFZhIqkSHJ6PMyTJjXotKxajsDa/xk21f3OP5EpFkvhXWqE4cnRBuSFNObZ0M76DmAsS+TUdplaRLg3zmN5eQmDTbuDYXR2JGgw92obtCUvD1lmwA941Os3dJT3kkrkACh7wCU9eapnp4AIxitvPsMR6rMXOZJIKalZnHp/zYeNtEyXb2a95UKYQ9wq31tO/DiuCFUSYEvOj98fjIUfMC2KGWh4FrE5z2ptACv/zRwsnYh5qQGa0+G1JdxXq6Cq/Bd+EIISqg4BdmV3Vp5VOBm+PmPDYvdDEWRy5etaBzxp6p4OyIjGf/HZrwqr8YPLbHWmTwyt+9ZaRwBoXbMOuSdWKMAdrsKJMAPqmJmz2yQ3ohjunnnpWuh9DhrVxDOwDFB9whgtytlIB3LbIXg0LdJ445njxUQDqNPkEpNYlYeUoruQVab2PoSh0jMI/ZjNztMM3nePoan8xLmXpA24ecg3bzjoLAFZo8F/yjncxrDGaLlFYckpR2gpwynL//GxjS3JrgcjgsCVtmxj1qwr9Xb5N/LYpvzA8vc5jNcjR8pjMqJc2vw8AsaqrnaigRCL49Ta7Ulcu32Cmwcj4RM6soiInnXs8yGOCCr3y5bf8YDt5iaa3mGYY7FlInrpOjB+Te212k4MI/1adu8q8kr1p0W9mFlnH7Dwd9BcHSy7ZbuGhORj1386sLHSRFw6x+YfjbvyHkzi/6U4tUgDkVMjDoVgrGFm9EELsKIC471wNiDPHJZ25N7kmcgxseDkCsehAJIb3+xWqkWj3wS1R1mqkkT1w== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: a30a696d-aa05-46f3-954f-08d9ec4bfd08 X-MS-Exchange-CrossTenant-AuthSource: DM5PR1001MB2345.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2022 04:15:36.5286 (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: 5p8XGTJcVLxlMD7w2pC5d8PjM+N3W+ror4TyxO3uo17k+zCB3VJI12XO7iSawTWDkCxuyCACYTM4PN93bpAo6FIYrpIBoOvQUIR5bXBk4yA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR10MB2564 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In the ocelot.h file, several read / write macros were split across multiple lines, while others weren't. Split all macros that exceed the 80 character column width and match the style of the rest of the file. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean --- include/soc/mscc/ocelot.h | 44 ++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 62cd61d4142e..14a6f4de8e1f 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -744,25 +744,39 @@ struct ocelot_policer { u32 burst; /* bytes */ }; -#define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) -#define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi)) -#define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri)) -#define ocelot_read(ocelot, reg) __ocelot_read_ix(ocelot, reg, 0) - -#define ocelot_write_ix(ocelot, val, reg, gi, ri) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) -#define ocelot_write_gix(ocelot, val, reg, gi) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi)) -#define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri)) +#define ocelot_read_ix(ocelot, reg, gi, ri) \ + __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) +#define ocelot_read_gix(ocelot, reg, gi) \ + __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi)) +#define ocelot_read_rix(ocelot, reg, ri) \ + __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri)) +#define ocelot_read(ocelot, reg) \ + __ocelot_read_ix(ocelot, reg, 0) + +#define ocelot_write_ix(ocelot, val, reg, gi, ri) \ + __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) +#define ocelot_write_gix(ocelot, val, reg, gi) \ + __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi)) +#define ocelot_write_rix(ocelot, val, reg, ri) \ + __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri)) #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0) -#define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) -#define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi)) -#define ocelot_rmw_rix(ocelot, val, m, reg, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri)) +#define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) \ + __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) +#define ocelot_rmw_gix(ocelot, val, m, reg, gi) \ + __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi)) +#define ocelot_rmw_rix(ocelot, val, m, reg, ri) \ + __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri)) #define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0) -#define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val)) -#define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val)) -#define ocelot_fields_write(ocelot, id, reg, val) regmap_fields_write((ocelot)->regfields[(reg)], (id), (val)) -#define ocelot_fields_read(ocelot, id, reg, val) regmap_fields_read((ocelot)->regfields[(reg)], (id), (val)) +#define ocelot_field_write(ocelot, reg, val) \ + regmap_field_write((ocelot)->regfields[(reg)], (val)) +#define ocelot_field_read(ocelot, reg, val) \ + regmap_field_read((ocelot)->regfields[(reg)], (val)) +#define ocelot_fields_write(ocelot, id, reg, val) \ + regmap_fields_write((ocelot)->regfields[(reg)], (id), (val)) +#define ocelot_fields_read(ocelot, id, reg, val) \ + regmap_fields_read((ocelot)->regfields[(reg)], (id), (val)) #define ocelot_target_read_ix(ocelot, target, reg, gi, ri) \ __ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) From patchwork Thu Feb 10 04:13:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12741239 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 57819C433EF for ; Thu, 10 Feb 2022 04:15:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233263AbiBJEPy (ORCPT ); Wed, 9 Feb 2022 23:15:54 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233188AbiBJEPj (ORCPT ); Wed, 9 Feb 2022 23:15:39 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2134.outbound.protection.outlook.com [40.107.243.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98A97272D; Wed, 9 Feb 2022 20:15:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BBeUBeacs5vzvXsFTRaHcZPnDEP7n5Iym45qhJfZGTcozEYRGO8+GG+nOFfBL2AdhjT7Rn6JtF3OfI5rFFnFjb5S9SMhyqkWArJ7KpnMzmkm4at6PbEDDwJkUUBqfXGsSjfqQF1NWyiyXasQqzpguM2fdeoo3Jz9P4ncIt4qnyysnpWvKHHaL1mFFUBi/SmZehdhxtINGABzjf4CQUzizU5xbN8mWRdkQ9PI1nsQz22RSCrKmyM/yvhgeGS3ek1bJzIwp4YtGaUluyYuFFMzCdUrjGrpDFJAcyA5EJdsEQ1+NirugK6Hf/RaBie9QX28mIMrjBX9wTt0Y3h+iBi8Zg== 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=/nv5AjNp/bsPNTC6KiiFtIi7/+Szne1J4+M/2V0nzN8=; b=i5wqJf3sh6Iq6nPFpldFxMBEKWNECJ/tJ3RdClF/jbpi7+5L0o6+YLtpNvxpgq6URUYyzoRkG07ZGtH7SISWdCaLKBnOcxMNtRp7r9odXqPyiqKSh+ZOg9aj2C38xGNFsHtFQKmkEwcG1qFAROvrt6kpK/7N65BvSFkouBBFMPehAAWiMhDzXEbuszBUDdQnWwIYopFLWqZpPUymFXIcgX5LJt7q2fT95lj9M9vumzMrPAiWAErytfifcXqbOX20ty0E6tc7GHAsimwYanRZWi0s1J3wCtwZdLiFmffZOsK97U6M3dFc4NCdSLg7KI8YUun+MVYHGaVtQbRtfM0mBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=/nv5AjNp/bsPNTC6KiiFtIi7/+Szne1J4+M/2V0nzN8=; b=zWOiNrW1ws2OwB0Zx/bQkZeg1v/8UnMcKsIyRehWosktzPPpuTUes4g1TinZxcL0G3Rcfm4HmGNzPXhi/XiRQ+ZAT4FtylsX/YdTG83UudeSYGEtUVrcjagVoNVJK26EuYBZ9nSSkA9B9ZAzT2/tie1Kl9ASYcz+FxQCvgAlm8I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) by BN0PR10MB5048.namprd10.prod.outlook.com (2603:10b6:408:117::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Thu, 10 Feb 2022 04:15:37 +0000 Received: from DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4]) by DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4%3]) with mapi id 15.20.4951.017; Thu, 10 Feb 2022 04:15:37 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean Subject: [PATCH v6 net-next 4/5] net: mscc: ocelot: add ability to perform bulk reads Date: Wed, 9 Feb 2022 20:13:44 -0800 Message-Id: <20220210041345.321216-5-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210041345.321216-1-colin.foster@in-advantage.com> References: <20220210041345.321216-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0084.namprd04.prod.outlook.com (2603:10b6:303:6b::29) To DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b8d0da1a-ec18-4e4c-76d6-08d9ec4bfdaf X-MS-TrafficTypeDiagnostic: BN0PR10MB5048:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hEaMtEUSzfFQa+35YOEOOG65UayMK9W8ZOK0J1UvzDHJNu8f26qlGMJcB+qlWiTzObAubhIvt1/KcY1SON4TnjanUjoFRQzWFygdgrKj45mZcHfTYkoqJuPImVsE16+0jhfD84VFKkFcxxCJVtXeTPzW9Nlt0hggPr7ghWZWSw0RkDLxmsu2HDkymhGnoQgmNWVQQmHZB/dGK6uv3EJCCpI9uqOSORWGUaMWGuK/+mLOI8sKPfFSVnYf8WcalmpbN0+U6Vjt4painzZKINQC+6DvSiNlbd9nQqZUeV3i1Ja4/ZlRN/CrJZuLdd9KMWhnfRMiDaHu1in5+YSJKbPda6QHyv1jTOvSfwNApbenO+8GJ4x+NM9IVojPftGn4Sn8nZkWAii7t18IeAp2KkSz0Ko9SGb1R3OGPM70O7dJRvgrZSgAwlWPGLTAreRqB0Rb7gDRLEybeZekxI1QhVcRCpPEygWtT7LcF8fOivWXlBoiDM/sUuhpQKQFkKkw7Vd7/sTeWWakCSpE8nZ3bbNkcfGq/xUJslbPO3GA0LiwneacKvGnjmF1Z1vpjd6TIY5eX2iO1t+YNIjSEgPJVX9jWPgBgsebPwnm7KejP0Liu2/F63D3ozMq34r4FLFfrgJhVesT9hAEqJjwoPKPwNfxFHIBSQUa8+BWetjKczYD8piTKmWM0ptO/pMaprbEBt8UyFpXHXmpTAmpRjqpvmvjwg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR1001MB2345.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(346002)(366004)(42606007)(136003)(39830400003)(396003)(376002)(316002)(4326008)(44832011)(66946007)(6512007)(86362001)(52116002)(66476007)(8936002)(6506007)(66556008)(54906003)(83380400001)(8676002)(1076003)(36756003)(2906002)(186003)(2616005)(5660300002)(26005)(38350700002)(38100700002)(6486002)(508600001)(6666004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FkX6hErs5t8jncaHoA7nJaSM43s39VWrOad7sgHDFqBYCYhOXby68pjT0cLyC2bfcBvb1Db4JqMdp/aGiom5mIFwnNN8VlsG+jYpAlMCa9ETrmL3SfF3Ui6s0xI059PnpTincp1Ocq80nvUN5pPWB/fN6h+ZoprCPZoSiewxhZiH3jCvSAEfJQgPidhS3JyfRINndm4iiPIRa737GKZOG8SBt0Qtxoi9J+NeWECAvp5CSmFCVNQpHIPLbKGEQaEJ846URN/PBi7EJkb0Wg2Fc6ScH0OpwErbmV5/1qIa58i0zll++WdoC4LMVx5bqyJxFO/voJBKN0jt1djeyWtJz2v/7Mtvqz97CH1Mu0XcY9nXa8UpY6a8JvG6HHLzsLcb9q9YWend7WHe2MFhCn99F4tXNYdTdtxIZvjoxEARcXXoeCDD+8hhGVfUZne+vyClBq+g4Ou6e2s7EwptZJEudaB17sSyjyYRBYAgZKkGRoy8eYjrtWodn8A5Or+F3YED3tGyFkOC/IDJ0v0AH7EZPGqS/dzaDplBzGXLtDao2JeiUPuKYdVfElk0JRDLEhQVPNapoS+xu5Bq7SnyPSQCzbkY+XFoMWtoEc/W3AczP25iWKpTBKPwOOg4mwgZpxQhocQxbmHJP9ohDmYv28VtQTBzbK6MPgRvtE4zteoXDW8h8C63dfAxeo8X2UL2/n5NAvMc9esYti/nKIxFRyp3xoVl4RnXL5VXbJaDxDuPMgADRY972goThcsCe5U9KEUva9MvCV1QlpqoRdAqNUY6rzo6pKenkaK7cDaAgQ3KlzxTeAV6mIGRRopFNpV5zAglj+tpbJ/FvWydwjWQiyFDI+OsSSLlGXBYfPACMlOLPRg9ofUlTbMVSWpxOfziJE2FBKRNu6JbG/kX7i06Hv00VgR4cPY40ma2RPcHL4sv4Hb7EQCmdvO0amoWwaPEQbFTmcESYCiT5lTLRDSZMlDpBI9qseqoBRKgCdXYZs8LWnzftEdHvvwXMv2+Zs7EXLlcFomEocI40n/4LLXDdeoWrH2ThMLDxm7camAmpo9qhKP1c8owivQnJdnHrHaqkXzB9svpoEheX63WXUSxidsb1yMif5UHhFiwe46BlQ/y7W6L7at1SKwcHwin6GTEbkwRVtyiFXY+uGZpZHURFzZ5gG7mxLzJN8hR7fKtidvcltUVbtB4gw5FQUIdVjYFl/xdUEjt0JBjVB6oFYeg6FzJXnwU1mzjQSY/Ki+8KC+zkjIUc433jtP+PUA4SFYrRa+0DBctVrsjPr4RKjjvRz1p+ADP/43xmg31jfM8w/Vr6nEBKweWtxv6fj/PQSuhoOYYW2HHj8DIcEAXINwtpuEsuPBk1WbNu5jHpNgL5hIB0hgSkLRoZ5/AzQ6v+gTQ2nQpZClVI8Mk8ovL+I+a+wVROglxfgfcWmGdyESZHF6xlfCwY4tqeTPCXQu85k515KVRGrm5ufzsKGu8VA3mRoY2f93PPCs1PinNxDj5s0/1l7Vd0dAO8yqm9c5TajBei9nbHoWDTJLAU52dbAOob1t/zeh2oAkxFNLqTRJP/mTyuEaIwX/ZVsJyTEaZuM+/IFZHL1k/My9gJZopwdq1J8X9eTOhX0JhfVPux77rdeE+/A1bdSrfq1L4X4TvE/pFI0bKTCix9xu3uabc031hv76tNQ== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8d0da1a-ec18-4e4c-76d6-08d9ec4bfdaf X-MS-Exchange-CrossTenant-AuthSource: DM5PR1001MB2345.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2022 04:15:37.5910 (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: 7dW+pRO8RGVLs/X2CFwt4T0loEzBE/1ehlhjKMDSupoJ6RvaZ+0VZPPR7e142DaQoHWa/r+GBSS5a+lc5hTAvpMaGmoTF7bYshdJnYw/lkU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5048 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Regmap supports bulk register reads. Ocelot does not. This patch adds support for Ocelot to invoke bulk regmap reads. That will allow any driver that performs consecutive reads over memory regions to optimize that access. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot_io.c | 13 +++++++++++++ include/soc/mscc/ocelot.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/drivers/net/ethernet/mscc/ocelot_io.c b/drivers/net/ethernet/mscc/ocelot_io.c index 7390fa3980ec..2067382d0ee1 100644 --- a/drivers/net/ethernet/mscc/ocelot_io.c +++ b/drivers/net/ethernet/mscc/ocelot_io.c @@ -10,6 +10,19 @@ #include "ocelot.h" +int __ocelot_bulk_read_ix(struct ocelot *ocelot, u32 reg, u32 offset, void *buf, + int count) +{ + u16 target = reg >> TARGET_OFFSET; + + WARN_ON(!target); + + return regmap_bulk_read(ocelot->targets[target], + ocelot->map[target][reg & REG_MASK] + offset, + buf, count); +} +EXPORT_SYMBOL_GPL(__ocelot_bulk_read_ix); + u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset) { u16 target = reg >> TARGET_OFFSET; diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 14a6f4de8e1f..312b72558659 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -744,6 +744,9 @@ struct ocelot_policer { u32 burst; /* bytes */ }; +#define ocelot_bulk_read_rix(ocelot, reg, ri, buf, count) \ + __ocelot_bulk_read_ix(ocelot, reg, reg##_RSZ * (ri), buf, count) + #define ocelot_read_ix(ocelot, reg, gi, ri) \ __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) #define ocelot_read_gix(ocelot, reg, gi) \ @@ -800,6 +803,8 @@ struct ocelot_policer { u32 ocelot_port_readl(struct ocelot_port *port, u32 reg); void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg); void ocelot_port_rmwl(struct ocelot_port *port, u32 val, u32 mask, u32 reg); +int __ocelot_bulk_read_ix(struct ocelot *ocelot, u32 reg, u32 offset, void *buf, + int count); u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset); void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset); void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg, From patchwork Thu Feb 10 04:13:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12741240 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 6C138C433EF for ; Thu, 10 Feb 2022 04:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233340AbiBJEP4 (ORCPT ); Wed, 9 Feb 2022 23:15:56 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233214AbiBJEPq (ORCPT ); Wed, 9 Feb 2022 23:15:46 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2134.outbound.protection.outlook.com [40.107.243.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50B7555A6; Wed, 9 Feb 2022 20:15:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k0j2gcqgSe/7QN/2xh4nJnNf73KktUzIqqAnBB1orB74fiTdGPCPj/cKU3GbCQluomnwtcm+JnPv4oCx6I01EIdFzj2k4LIqFTiRkT/iLCbh6ODeoF5Pafc4g+4s/KNju0sBS9Fyo9xJ1YS+u8AeyP5wifQipvlt4/PjgdrFAOTnPG5eWIrJyVW9FFfF/dd1Vz1Hqhr6eDW8/wN/1/X5SsmjayXHenS37+empPMunzHN+wDmNodnCoFuzdGRKTSUA0xdcSp9dHRyzCE99QghbbkcN3P4eMaGiMPdi9UJwWNk06/ohW141vCE6q4fF/k33orw3/VDL1KE9n7Tp52x4A== 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=rCdbYV1Xq8sohXnLl98Hp3cJeFl4JNmhf19w3d0IQbA=; b=Q0JPFkNz4Q1FI1yiFsLmNiBJRBVszZqg2Bur1M5lUkPl4go0ARhNdTj/+KZkefJ0eRRMLbhemzLinawLPcbgk6Xd5T+1UxM31bo14HYWPr75/I3fUjioksTDrAHxuEQ6cIw2wyEpj7l4Y23EgQoGFCxQ6Y4t9+SOSr4ihb5puJm4yqsPBy0GjoBCJfvGqB2LiCXQ1ALPhFRKzlJw8Hw3QzQjZbnAqAEA3rq6ghVpLRilvckscpMsKU5yvLjASVrgJjvZi0vXLCrFLdfzh/NSL4g1MR97/1NPE2MFL7Z3O2RwuIHauR71j/ihoc1VnaLzBS7CFFNDASyPgQBHj693dw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=rCdbYV1Xq8sohXnLl98Hp3cJeFl4JNmhf19w3d0IQbA=; b=qsxgxWPUso7PpgHTlU3T87w+IHofy7w9usptO/XbmyXKYz9Zzy2DxliArZvtU9c9syqj1Bblm3jRtO/FggwfnWIa3HPqhSEakaRF1h1U1EKJEhi4JOE9YuIaafvHPfZX+USq/q6Bgx5XTyNuroc4WOlwrL2eUmvMZvbq6Sb3eOI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) by BN0PR10MB5048.namprd10.prod.outlook.com (2603:10b6:408:117::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Thu, 10 Feb 2022 04:15:38 +0000 Received: from DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4]) by DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4%3]) with mapi id 15.20.4951.017; Thu, 10 Feb 2022 04:15:38 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean Subject: [PATCH v6 net-next 5/5] net: mscc: ocelot: use bulk reads for stats Date: Wed, 9 Feb 2022 20:13:45 -0800 Message-Id: <20220210041345.321216-6-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210041345.321216-1-colin.foster@in-advantage.com> References: <20220210041345.321216-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0084.namprd04.prod.outlook.com (2603:10b6:303:6b::29) To DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c9749d73-4807-40b7-e1ad-08d9ec4bfe5f X-MS-TrafficTypeDiagnostic: BN0PR10MB5048:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1060; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aUVMUOiTr8t9/q7D6w5Yo+FhYxIwVnfPHKJoyCjYyHF1bA2yKwmLa223Yy20QLCSgOEXxHgnvXfdVHVQ9+BPPf+RraSF+Ovhs2PFDT4m9Vw/mM8zQgVRCE+K2NAB07yPts5NK8p2jQzn6SqTqF40SP3Tv7rxU8fDrpUkCIEL1LFdpKYHqa6hIiLLBCsxjlO4CYa9vK+zVQzhBriX35bOZdu76a3xLNRMw685koVXIxAj7JDxE9fCHCEJKTMH+u3yhbmpQGDLRiLoSTyVN2bqKZA+FKL2LYrm3s0yYKGEUlOw0p9x1von65Ae4jne79PfhH2sB89QSQuy5EXx94m+8/GBpM77Hwflz0pTifb5NkEXMwga1kvmCjxSsecqsrGM2NUiFkNegjWQtxwF3dptalCKNBnbyt9/Lx09ZNnF0NYo/umrx3y1He/07PWPwmz8/97Rqd7onYQWbHjOP5zyIlsETknqYxLawNs0mS3uBqV3rhGe3zEYqUKL//XSf5Sxo33kExK4Q4Kr2Ck1cNQE63QI8d2EXESXHyiu4/s6ZbPO0NPb/+UExepxsS2v4F3NfWh0YpRPLXYabhVBsOp7vDUh2+nF3kQvU3TZ0MrpDEmUjNx+HRCt7JcyOsDzf7GVifkxU1AlrIvOol47YVS9i61SkaUWhC6eQUVXZCFd0v9lTV0kpNoqDphL9DWK/kYk0M9fAFmWH7J9DRTUuF1SYw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR1001MB2345.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(346002)(366004)(42606007)(136003)(39830400003)(396003)(376002)(316002)(4326008)(44832011)(66946007)(6512007)(86362001)(52116002)(66476007)(8936002)(6506007)(66556008)(54906003)(83380400001)(8676002)(1076003)(36756003)(2906002)(186003)(2616005)(5660300002)(26005)(38350700002)(38100700002)(6486002)(508600001)(6666004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fD6NPwvY7oksXDFeK37epNxlB+KNs+S+VajJoU1mu+jrUM00wlf3zxmM+ZIHkerPbDgeYbqgLbaMCp+/qfgydWydfwD6jybzW/DOH39cTDly7WxIM0FcWceQAMatk33GOa+Gi9H8dhZdQTWUGVRPTQYN4+qAjwS0GSI5WccN/U4PWKADvxW5N6CGXzVylWZ/2YJP1WUf+ywwxm/uiBEeBqUO1ZRCGJsAF4IVjhYoLaCA3LYStjM8qNTEvAw3w/Zbt8qpVkT3Mgrl2w1Cr/rggzYpqm/fHHHn9KaXPV/ejfWpFkbMNA7CdV6caA9Uvb5Mh6nCwHIBdOwoxF9kiOkllnifF201zmZg4hAZO2VuRvob7d/1ZWJbBbPYkq057+uC+bJRdkD2PTqb3JJQZgtQVTj+j6vWczD7hsE80QbF6cYI626JnsaRixKFSo/yqEHhY+b3jw319qHYwLcJj0TPV2CaUTbXmyFyLoc5NP0clWHU4eYobKwV7uNhV73o0HivvCfp8WYmokbZplz5W0GJkXzB0GSDOaRcrCSBHLSuZHvIrE9AfuIw8hs/ZL+puaBKLUWoPBy2ZvD8VkopqmKPRiZHZgZSUsbATlBoMaGAa1sLYJIX7NIr5CB+9S+npxoJoOciM3Ie2WckI7dBS1M3b5aS3sJvy3Ku4lclQ5/7a1G/H0x3kW5JgTe+KeLD2zISeA0S2maN+GkUr13oKGv2d3knftYPdNxjxTqZNKj32Tt9XL2YlOsbEDsFEjOFs6UDjDG0s/MBaKWPSZct0BIj/Z8labu4YfdSZeVotPa2HM3zqNqZaV76+O/ldZ3Q4pk+i2Fh2Upj6wT7R28h0EEyvbb8oYF6pGcHKBXC9QNPj+/L0faVfkCvazpyETAi5hNWEve1tGhohUeI7p48+HV80gjARa15R/wW8Tm7dxLhQvGtOAGNBnfwTlRLzpeDBQk1jQlWBF2nYaOuxKCAn4XOiuXLGyNeDnJEP/95kTZ+ZAPwWk6vxmWlcMr5fpibV5uAymqCDMdXcU3vzCuG+vH+l4/qFme1s9l1RSvVwZT01SmxDvmRAEi3axbGBEFMDGR3wklClPLMp6Fn8gm6cWtm0mCE5lvGXIdLD4QToafTs/cfmqx9RBTjFOALMEhlOun3lRr3DsMwtwCYjrh9p6dY3Cfe2oqbDEN6JDjA3ykU4FqwCJC61kf7u7WWTYYs39ZjOtjOfNV/YfbqPaiQ8MumDHW54NNheP435Osz9+MJgNQ26vY2KWKvZkUU6OoOD12b5ErRG45S7TWOTHfnM9swrABhdYHHtQfpc07L3UpjNBgzNWWBsq6Jxmk4kuAttUCYyLYqH9qDGORtB7z7Rn/c6Tt9/vOA7HtybQtTy2bCMcsxYmpkNbOd+SpR8h0aSG3gDv92h/WtbkxmWhakalit+17JQJeqSNy5ALYlbcUeqz0FRtKf5UeQQtxB03sJA29dexuSPadQ4Ya7e3eqCoUUwu6vFBnJhPt6nad5zCSOTr1JU/6WMS93BmCEOFoMOFabqnVlHz3D0g5fQg/3fojLGQSIRvyJP0MqlgYWOws6Fjs8474EdGtl12wz46zjT34vtUz1cA7BimYvBamow5wkMYhk7fumBbpvQ7PGuuhjeL2ofkHYz2+I+RU0JT2nUgXgatX1WDiI/GL5ReXUwSL33w== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9749d73-4807-40b7-e1ad-08d9ec4bfe5f X-MS-Exchange-CrossTenant-AuthSource: DM5PR1001MB2345.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2022 04:15:38.6690 (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: pRnIRwsVyYe7QWxKXhEnK83fBDVai3rGPquoTY4/dGUYV2Dku6QSr5CfWRyDy2LX6jhkFSn682KjwUj5WRm5AJ6BNelB9KPa0qVxmymdV/U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5048 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Create and utilize bulk regmap reads instead of single access for gathering stats. The background reading of statistics happens frequently, and over a few contiguous memory regions. High speed PCIe buses and MMIO access will probably see negligible performance increase. Lower speed buses like SPI and I2C could see significant performance increase, since the bus configuration and register access times account for a large percentage of data transfer time. Signed-off-by: Colin Foster --- drivers/net/ethernet/mscc/ocelot.c | 79 +++++++++++++++++++++++++----- include/soc/mscc/ocelot.h | 8 +++ 2 files changed, 75 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index ab36732e7d3f..fdbd31149dfc 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1738,25 +1738,36 @@ void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data) EXPORT_SYMBOL(ocelot_get_strings); /* Caller must hold &ocelot->stats_lock */ -static void ocelot_update_stats_for_port(struct ocelot *ocelot, int port) +static int ocelot_update_stats_for_port(struct ocelot *ocelot, int port) { - int j; + unsigned int idx = port * ocelot->num_stats; + struct ocelot_stats_region *region; + int err, j; /* Configure the port to read the stats from */ ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port), SYS_STAT_CFG); - for (j = 0; j < ocelot->num_stats; j++) { - u32 val; - unsigned int idx = port * ocelot->num_stats + j; + list_for_each_entry(region, &ocelot->stats_regions, node) { + err = ocelot_bulk_read_rix(ocelot, SYS_COUNT_RX_OCTETS, + region->offset, region->buf, + region->count); + if (err) + return err; - val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, - ocelot->stats_layout[j].offset); + for (j = 0; j < region->count; j++) { + u64 *stat = &ocelot->stats[idx + j]; + u64 val = region->buf[j]; - if (val < (ocelot->stats[idx] & U32_MAX)) - ocelot->stats[idx] += (u64)1 << 32; + if (val < (*stat & U32_MAX)) + *stat += (u64)1 << 32; + + *stat = (*stat & ~(u64)U32_MAX) + val; + } - ocelot->stats[idx] = (ocelot->stats[idx] & ~(u64)U32_MAX) + val; + idx += region->count; } + + return err; } static void ocelot_check_stats_work(struct work_struct *work) @@ -1777,12 +1788,14 @@ static void ocelot_check_stats_work(struct work_struct *work) void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data) { - int i; + int i, err; mutex_lock(&ocelot->stats_lock); /* check and update now */ - ocelot_update_stats_for_port(ocelot, port); + err = ocelot_update_stats_for_port(ocelot, port); + if (err) + dev_err(ocelot->dev, "Error %d updating ethtool stats\n", err); /* Copy all counters */ for (i = 0; i < ocelot->num_stats; i++) @@ -1801,6 +1814,41 @@ int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset) } EXPORT_SYMBOL(ocelot_get_sset_count); +static int ocelot_prepare_stats_regions(struct ocelot *ocelot) +{ + struct ocelot_stats_region *region = NULL; + unsigned int last; + int i; + + INIT_LIST_HEAD(&ocelot->stats_regions); + + for (i = 0; i < ocelot->num_stats; i++) { + if (region && ocelot->stats_layout[i].offset == last + 1) { + region->count++; + } else { + region = devm_kzalloc(ocelot->dev, sizeof(*region), + GFP_KERNEL); + if (!region) + return -ENOMEM; + + region->offset = ocelot->stats_layout[i].offset; + region->count = 1; + list_add_tail(®ion->node, &ocelot->stats_regions); + } + + last = ocelot->stats_layout[i].offset; + } + + list_for_each_entry(region, &ocelot->stats_regions, node) { + region->buf = devm_kcalloc(ocelot->dev, region->count, + sizeof(*region->buf), GFP_KERNEL); + if (!region->buf) + return -ENOMEM; + } + + return 0; +} + int ocelot_get_ts_info(struct ocelot *ocelot, int port, struct ethtool_ts_info *info) { @@ -2801,6 +2849,13 @@ int ocelot_init(struct ocelot *ocelot) ANA_CPUQ_8021_CFG_CPUQ_BPDU_VAL(6), ANA_CPUQ_8021_CFG, i); + ret = ocelot_prepare_stats_regions(ocelot); + if (ret) { + destroy_workqueue(ocelot->stats_queue); + destroy_workqueue(ocelot->owq); + return ret; + } + INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats_work); queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, OCELOT_STATS_CHECK_DELAY); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 312b72558659..d3291a5f7e88 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -542,6 +542,13 @@ struct ocelot_stat_layout { char name[ETH_GSTRING_LEN]; }; +struct ocelot_stats_region { + struct list_head node; + u32 offset; + int count; + u32 *buf; +}; + enum ocelot_tag_prefix { OCELOT_TAG_PREFIX_DISABLED = 0, OCELOT_TAG_PREFIX_NONE, @@ -673,6 +680,7 @@ struct ocelot { struct regmap_field *regfields[REGFIELD_MAX]; const u32 *const *map; const struct ocelot_stat_layout *stats_layout; + struct list_head stats_regions; unsigned int num_stats; u32 pool_size[OCELOT_SB_NUM][OCELOT_SB_POOL_NUM];