From mboxrd@z Thu Jan 1 00:00:00 1970 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 2FE7FC38145 for ; Wed, 7 Sep 2022 22:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229688AbiIGWga (ORCPT ); Wed, 7 Sep 2022 18:36:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbiIGWg3 (ORCPT ); Wed, 7 Sep 2022 18:36:29 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C5AD8980D for ; Wed, 7 Sep 2022 15:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=xffrmXpJPrhu+9xL7p3pMXRSj8cblTFtyWCSFz8oR6s=; b=hNOlrKe4BlUG9h8rLTuFg1aqFm 26iY4YYC62opfUnFMW0WltvWbpJKx29uTovI/CZyhDj4ODqX9pd2ii0hx0bEdwkF6a/qlWarH2MDh NLal9dd+QHj5iYJia9agS4I9Y9b+/XRv4OZTIZ4yG1flKl5B1fqoluHrYLYNgwKYPQoY=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1oW3ej-00FuNK-3n; Thu, 08 Sep 2022 00:36:25 +0200 Date: Thu, 8 Sep 2022 00:36:25 +0200 From: Andrew Lunn To: Mattias Forsblad Cc: netdev@vger.kernel.org, Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: Re: [PATCH net-next v5 5/6] net: dsa: mv88e6xxx: rmon: Use RMU for reading RMON data Message-ID: References: <20220907072950.2329571-1-mattias.forsblad@gmail.com> <20220907072950.2329571-6-mattias.forsblad@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220907072950.2329571-6-mattias.forsblad@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org > @@ -430,6 +431,7 @@ struct mv88e6xxx_bus_ops { > int (*read)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val); > int (*write)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val); > int (*init)(struct mv88e6xxx_chip *chip); > + int (*get_rmon)(struct mv88e6xxx_chip *chip, int port, uint64_t *data); > }; I think you can make this a lot cleaner. You are adding this get_rmon op here. Add it to mv88e6xxx_smi_indirect_ops, mv88e6xxx_smi_direct_ops, and mv88e6xxx_smi_dual_direct_ops, calling the MDIO version. Then the top level mv88e6xxx_get_ethtool_stats() just calls the get_rmon() method in mv88e6xxx_bus_ops. Notice how mv88e6xxx_smi_init() sets chip->smi_ops depending on the chip type. What you can do is when RMU is successfully enabled, replace chip->smi_ops with a version which goes via RMU. You can keep .read and .write pointing to the MDIO versions for the moment, until they also use RMU. Doing it like this removes all the checking is RMU setup or not. Andrew