devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Prasanna Vengateshan <prasanna.vengateshan@microchip.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: <netdev@vger.kernel.org>, <olteanv@gmail.com>,
	<robh+dt@kernel.org>, <UNGLinuxDriver@microchip.com>,
	<woojung.huh@microchip.com>, <hkallweit1@gmail.com>,
	<linux@armlinux.org.uk>, <davem@davemloft.net>, <kuba@kernel.org>,
	<linux-kernel@vger.kernel.org>, <vivien.didelot@gmail.com>,
	<f.fainelli@gmail.com>, <devicetree@vger.kernel.org>
Subject: Re: [PATCH v9 net-next 06/11] net: dsa: microchip: add DSA support for microchip lan937x
Date: Tue, 22 Mar 2022 01:39:28 +0530	[thread overview]
Message-ID: <3441a9f60834f8a32a537145303f4a93e2e76c60.camel@microchip.com> (raw)
In-Reply-To: <YjaAqXfiBrMggIdA@lunn.ch>

On Sun, 2022-03-20 at 02:17 +0100, Andrew Lunn wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the
> content is safe
> 
> > +int lan937x_reset_switch(struct ksz_device *dev)
> > +{
> > +     u32 data32;
> > +     u8 data8;
> > +     int ret;
> > +
> > +     /* reset switch */
> > +     ret = lan937x_cfg(dev, REG_SW_OPERATION, SW_RESET, true);
> > +     if (ret < 0)
> > +             return ret;
> > +
> > +     ret = ksz_read8(dev, REG_SW_LUE_CTRL_1, &data8);
> > +     if (ret < 0)
> > +             return ret;
> > +
> > +     /* Enable Auto Aging */
> > +     ret = ksz_write8(dev, REG_SW_LUE_CTRL_1, data8 | SW_LINK_AUTO_AGING);
> > +     if (ret < 0)
> > +             return ret;
> > +
> > +     /* disable interrupts */
> > +     ret = ksz_write32(dev, REG_SW_INT_MASK__4, SWITCH_INT_MASK);
> > +     if (ret < 0)
> > +             return ret;
> > +
> > +     ret = ksz_write32(dev, REG_SW_PORT_INT_MASK__4, 0xFF);
> > +     if (ret < 0)
> > +             return ret;
> > +
> > +     return ksz_read32(dev, REG_SW_PORT_INT_STATUS__4, &data32);
> 
> I would probably enable auto aging in the setup routing, not the
> reset.  Disabling interrupts is less clear, maybe it also belongs in
> setup?

Actually lan937x_reset_switch() gets called from setup() as well.

> 
> > +static void lan937x_switch_exit(struct ksz_device *dev)
> > +{
> > +     lan937x_reset_switch(dev);
> > +}
> 
> Humm. Does a reset leave the switch in a dumb mode, or is it totally
> disabled?

Its a kind of unconfiguring and you are right, Auto aging & disabling interrupts
can be directly moved to setup().


> 
> > +int lan937x_internal_phy_write(struct ksz_device *dev, int addr, int reg,
> > +                            u16 val)
> > +{
> > +     u16 temp, addr_base;
> > +     unsigned int value;
> > +     int ret;
> > +
> > +     /* Check for internal phy port */
> > +     if (!lan937x_is_internal_phy_port(dev, addr))
> > +             return -EOPNOTSUPP;
> > +
> > +     if (lan937x_is_internal_base_tx_phy_port(dev, addr))
> > +             addr_base = REG_PORT_TX_PHY_CTRL_BASE;
> > +     else
> > +             addr_base = REG_PORT_T1_PHY_CTRL_BASE;
> > +
> > +     temp = PORT_CTRL_ADDR(addr, (addr_base + (reg << 2)));
> > +
> > +     ret = ksz_write16(dev, REG_VPHY_IND_ADDR__2, temp);
> > +     if (ret < 0)
> > +             return ret;
> 
> ...
> 
> > +}
> > +
> > +int lan937x_internal_phy_read(struct ksz_device *dev, int addr, int reg,
> > +                           u16 *val)
> > +{
> > +     u16 temp, addr_base;
> > +     unsigned int value;
> > +     int ret;
> > +
> > +     /* Check for internal phy port, return 0xffff for non-existent phy */
> > +     if (!lan937x_is_internal_phy_port(dev, addr))
> > +             return 0xffff;
> > +
> > +     if (lan937x_is_internal_base_tx_phy_port(dev, addr))
> > +             addr_base = REG_PORT_TX_PHY_CTRL_BASE;
> > +     else
> > +             addr_base = REG_PORT_T1_PHY_CTRL_BASE;
> > +
> > +     /* get register address based on the logical port */
> > +     temp = PORT_CTRL_ADDR(addr, (addr_base + (reg << 2)));
> > +
> > +     ret = ksz_write16(dev, REG_VPHY_IND_ADDR__2, temp);
> > +     if (ret < 0)
> > +             return ret;
> 
> Looks pretty similar to me. You should pull this out into a helper.

Sure, i think it can be made except if check lan937x_is_internal_phy_port() 

> 
> 
> > +struct lan_alu_struct {
> > +     /* entry 1 */
> > +     u8      is_static:1;
> > +     u8      is_src_filter:1;
> > +     u8      is_dst_filter:1;
> > +     u8      prio_age:3;
> > +     u32     _reserv_0_1:23;
> > +     u8      mstp:3;
> 
> I assume this works O.K, but bitfields are nornaly defined using one
> type. I would of used u32 for them all. Is there some advantage of
> missing u8 and u32?

It works because direct assignments are used. But using one type is the right
way. I will change it in the next patch.

> 
> > +     /* entry 2 */
> > +     u8      is_override:1;
> > +     u8      is_use_fid:1;
> > +     u32     _reserv_1_1:22;
> > +     u8      port_forward:8;
> > +     /* entry 3 & 4*/
> > +     u32     _reserv_2_1:9;
> > +     u8      fid:7;
> > +     u8      mac[ETH_ALEN];
> > +};
> 
>   Andrew



  reply	other threads:[~2022-03-21 20:12 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18  8:55 [PATCH v9 net-next 00/11] net: dsa: microchip: DSA driver support for LAN937x switch Prasanna Vengateshan
2022-03-18  8:55 ` [PATCH v9 net-next 01/11] dt-bindings: net: make internal-delay-ps based on phy-mode Prasanna Vengateshan
2022-03-20  0:41   ` Andrew Lunn
2022-03-20  2:13   ` Rob Herring
2022-03-18  8:55 ` [PATCH v9 net-next 02/11] dt-bindings: net: add mdio property Prasanna Vengateshan
2022-03-20  0:41   ` Andrew Lunn
2022-03-21 23:27   ` Rob Herring
2022-03-22 14:46     ` Prasanna Vengateshan
2022-03-22 14:56       ` Rob Herring
2022-03-18  8:55 ` [PATCH v9 net-next 03/11] dt-bindings: net: dsa: dt bindings for microchip lan937x Prasanna Vengateshan
2022-03-20  0:49   ` Andrew Lunn
2022-03-21 20:19     ` Prasanna Vengateshan
2022-03-18  8:55 ` [PATCH v9 net-next 04/11] net: dsa: move mib->cnt_ptr reset code to ksz_common.c Prasanna Vengateshan
2022-03-18  8:55 ` [PATCH v9 net-next 05/11] net: dsa: tag_ksz: add tag handling for Microchip LAN937x Prasanna Vengateshan
2022-03-18  8:55 ` [PATCH v9 net-next 06/11] net: dsa: microchip: add DSA support for microchip lan937x Prasanna Vengateshan
2022-03-20  1:17   ` Andrew Lunn
2022-03-21 20:09     ` Prasanna Vengateshan [this message]
2022-03-18  8:55 ` [PATCH v9 net-next 07/11] net: dsa: microchip: add support for phylink management Prasanna Vengateshan
2022-03-18  8:55 ` [PATCH v9 net-next 08/11] net: dsa: microchip: add support for ethtool port counters Prasanna Vengateshan
2022-03-20  1:26   ` Andrew Lunn
2022-03-21 19:33     ` Prasanna Vengateshan
2022-03-18  8:55 ` [PATCH v9 net-next 09/11] net: dsa: microchip: add support for port mirror operations Prasanna Vengateshan
2022-03-18 11:00   ` Vladimir Oltean
2022-03-21 20:22     ` Prasanna Vengateshan
2022-03-18  8:55 ` [PATCH v9 net-next 10/11] net: dsa: microchip: add support for fdb and mdb management Prasanna Vengateshan
2022-03-18  8:55 ` [PATCH v9 net-next 11/11] net: dsa: microchip: add support for vlan operations Prasanna Vengateshan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3441a9f60834f8a32a537145303f4a93e2e76c60.camel@microchip.com \
    --to=prasanna.vengateshan@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=woojung.huh@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).