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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EEA7C2D0A8 for ; Sat, 26 Sep 2020 17:28:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA1BF207C4 for ; Sat, 26 Sep 2020 17:28:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728504AbgIZR23 (ORCPT ); Sat, 26 Sep 2020 13:28:29 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:56854 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbgIZR23 (ORCPT ); Sat, 26 Sep 2020 13:28:29 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1kMDzm-00GIHi-Mh; Sat, 26 Sep 2020 19:28:26 +0200 Date: Sat, 26 Sep 2020 19:28:26 +0200 From: Andrew Lunn To: Vladimir Oltean Cc: netdev , Florian Fainelli , Jakub Kicinski , Jiri Pirko , Chris Healy Subject: Re: [PATCH net-next RFC v1 3/4] net: dsa: Add helper for converting devlink port to ds and port Message-ID: <20200926172826.GA3883417@lunn.ch> References: <20200919144332.3665538-1-andrew@lunn.ch> <20200919144332.3665538-4-andrew@lunn.ch> <20200920235203.5r4srjqyjl5lutan@skbuf> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200920235203.5r4srjqyjl5lutan@skbuf> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Sun, Sep 20, 2020 at 11:52:03PM +0000, Vladimir Oltean wrote: > On Sat, Sep 19, 2020 at 04:43:31PM +0200, Andrew Lunn wrote: > > Hide away from DSA drivers how devlink works. > > > > Signed-off-by: Andrew Lunn > > --- > > include/net/dsa.h | 14 ++++++++++++++ > > 1 file changed, 14 insertions(+) > > > > diff --git a/include/net/dsa.h b/include/net/dsa.h > > index 01da896b2998..a24d5158ee0c 100644 > > --- a/include/net/dsa.h > > +++ b/include/net/dsa.h > > @@ -685,6 +685,20 @@ static inline struct dsa_switch *dsa_devlink_to_ds(struct devlink *dl) > > return dl_priv->ds; > > } > > > > +static inline > > +struct dsa_switch *dsa_devlink_port_to_ds(struct devlink_port *port) > > +{ > > + struct devlink *dl = port->devlink; > > + struct dsa_devlink_priv *dl_priv = devlink_priv(dl); > > + > > + return dl_priv->ds; > > +} > > + > > +static inline int dsa_devlink_port_to_port(struct devlink_port *port) > > How about dsa_devlink_port_to_index? > It avoids the repetition and it also indicates more clearly that it > returns an index rather than a struct dsa_port, without needing to fire > up ctags. Hi Vladimir Just finishing off the next version of these patches, and i looped back to check i addressed all the comments. This one i tend to disagree with. If you look at DSA drivers, a port variable is always an integer index. dp is used to refer to a dsa_port. If anything, i would suggest we rename dsa_to_port() to dsa_to_dp(), and dsa_port_from_netdev to dsa_dp_from_netdev() or maybe dsa_netdev_to_dp(). Andrew