lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 19 Jul 2022 14:29:30 +0200
From:   Christian Marangi <ansuelsmth@...il.com>
To:     Vladimir Oltean <olteanv@...il.com>
Cc:     Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jens Axboe <axboe@...nel.dk>, linux-kernel@...r.kernel.org,
        netdev@...r.kernel.org
Subject: Re: [net-next PATCH v2 01/15] net: dsa: qca8k: make mib autocast
 feature optional

On Tue, Jul 19, 2022 at 03:26:36PM +0300, Vladimir Oltean wrote:
> On Tue, Jul 19, 2022 at 02:57:11AM +0200, Christian Marangi wrote:
> > Some switch may not support mib autocast feature and require the legacy
> > way of reading the regs directly.
> > Make the mib autocast feature optional and permit to declare support for
> > it using match_data struct.
> > 
> > Signed-off-by: Christian Marangi <ansuelsmth@...il.com>
> > ---
> >  drivers/net/dsa/qca/qca8k.c | 11 +++++++----
> >  drivers/net/dsa/qca/qca8k.h |  1 +
> >  2 files changed, 8 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/net/dsa/qca/qca8k.c b/drivers/net/dsa/qca/qca8k.c
> > index 1cbb05b0323f..a57c53ce2f0c 100644
> > --- a/drivers/net/dsa/qca/qca8k.c
> > +++ b/drivers/net/dsa/qca/qca8k.c
> > @@ -2112,12 +2112,12 @@ qca8k_get_ethtool_stats(struct dsa_switch *ds, int port,
> >  	u32 hi = 0;
> >  	int ret;
> >  
> > -	if (priv->mgmt_master &&
> > -	    qca8k_get_ethtool_stats_eth(ds, port, data) > 0)
> > -		return;
> > -
> >  	match_data = of_device_get_match_data(priv->dev);
> 
> I didn't notice at the time that you already call of_device_get_match_data()
> at driver runtime, but please be aware that it is a relatively expensive
> operation (takes raw spinlocks, iterates etc), or at least much more
> expensive than it needs to be. What other drivers do is cache the result
> of this function once in priv->info and just use priv->info, since it
> won't change during the lifetime of the driver.
>

Ok makes sense. Can I make a patch drop the use of
of_device_get_match_data and then apply this on top?

(we use of_device_get_match_data also in other functions)

> >  
> > +	if (priv->mgmt_master && match_data->autocast_mib &&
> > +	    match_data->autocast_mib(ds, port, data) > 0)
> > +		return;
> > +
> >  	for (i = 0; i < match_data->mib_count; i++) {
> >  		mib = &ar8327_mib[i];
> >  		reg = QCA8K_PORT_MIB_COUNTER(port) + mib->offset;
> > @@ -3260,16 +3260,19 @@ static const struct qca8k_match_data qca8327 = {
> >  	.id = QCA8K_ID_QCA8327,
> >  	.reduced_package = true,
> >  	.mib_count = QCA8K_QCA832X_MIB_COUNT,
> > +	.autocast_mib = qca8k_get_ethtool_stats_eth,
> 
> I thought you were going to create a dedicated sub-structure for
> function pointers?
> 

Sorry... totally forgot this as I was very busy with giving good series.
Will handle this in the next version.

(will be also useful later for the single dsa_switch_ops transition if
we want to put all of them there)

> >  };
> >  
> >  static const struct qca8k_match_data qca8328 = {
> >  	.id = QCA8K_ID_QCA8327,
> >  	.mib_count = QCA8K_QCA832X_MIB_COUNT,
> > +	.autocast_mib = qca8k_get_ethtool_stats_eth,
> >  };
> >  
> >  static const struct qca8k_match_data qca833x = {
> >  	.id = QCA8K_ID_QCA8337,
> >  	.mib_count = QCA8K_QCA833X_MIB_COUNT,
> > +	.autocast_mib = qca8k_get_ethtool_stats_eth,
> >  };
> >  
> >  static const struct of_device_id qca8k_of_match[] = {
> > diff --git a/drivers/net/dsa/qca/qca8k.h b/drivers/net/dsa/qca/qca8k.h
> > index ec58d0e80a70..c3df0a56cda4 100644
> > --- a/drivers/net/dsa/qca/qca8k.h
> > +++ b/drivers/net/dsa/qca/qca8k.h
> > @@ -328,6 +328,7 @@ struct qca8k_match_data {
> >  	u8 id;
> >  	bool reduced_package;
> >  	u8 mib_count;
> > +	int (*autocast_mib)(struct dsa_switch *ds, int port, u64 *data);
> >  };
> >  
> >  enum {
> > -- 
> > 2.36.1
> > 
> 

-- 
	Ansuel

Powered by blists - more mailing lists