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 4FF75C00140 for ; Thu, 18 Aug 2022 15:36:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343769AbiHRPgT (ORCPT ); Thu, 18 Aug 2022 11:36:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343569AbiHRPgQ (ORCPT ); Thu, 18 Aug 2022 11:36:16 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65E53C00C7 for ; Thu, 18 Aug 2022 08:36:15 -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=Xn8X8SospVugTd8QNjQDoRAh6YrP5q7TVyjrKFm7znY=; b=TeXnLWhW6mPDdUHPEx6hix1cJe AChTpv1jvYjZBxmrB34lMCf8ja1NThoK8Fy2l+cqA23niY8MFmN/hnfEjz6hIarIHLoEBerEppklU MeyhhkgVGg4rcOY2wppEUAeg9JnQuLSPunAxHH2f/vVGeM4hMV2o+yarNaOufrO7/RIc=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1oOhZ6-00DlYH-Rl; Thu, 18 Aug 2022 17:36:12 +0200 Date: Thu, 18 Aug 2022 17:36:12 +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: [RFC net-next PATCH 3/3] mv88e6xxx: rmon: Use RMU to collect rmon data. Message-ID: References: <20220818102924.287719-1-mattias.forsblad@gmail.com> <20220818102924.287719-4-mattias.forsblad@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220818102924.287719-4-mattias.forsblad@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org > @@ -1310,16 +1323,22 @@ static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, > struct mv88e6xxx_chip *chip = ds->priv; > int ret; > > - mv88e6xxx_reg_lock(chip); > + if (chip->rmu.ops && chip->rmu.ops->get_rmon) { > + ret = chip->rmu.ops->get_rmon(chip, port, data); > + if (ret == -ETIMEDOUT) > + return; > + } else { > > - ret = mv88e6xxx_stats_snapshot(chip, port); > - mv88e6xxx_reg_unlock(chip); > + mv88e6xxx_reg_lock(chip); > > - if (ret < 0) > - return; > + ret = mv88e6xxx_stats_snapshot(chip, port); > + mv88e6xxx_reg_unlock(chip); > > - mv88e6xxx_get_stats(chip, port, data); > + if (ret < 0) > + return; > > + mv88e6xxx_get_stats(chip, port, data); > + } > } I don't particularly like the way this is all mixed together. Could you try to split it, so there is an MDIO set of functions and an RMU set of functions. Maybe you have some helpers which are used by both. I would also suggest you try to think about ATU dump and VTU dump. You ideally want a code structure which is very similar for all these dump operations. Take a look at how qca8k-8xxx.c does things. Is it documented in the datasheet that when RMU is used a snapshot is not required? Andrew