From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Lunn Subject: Re: [PATCH net-next 1/2] ixgbe: register a mdiobus Date: Fri, 30 Nov 2018 14:21:30 +0100 Message-ID: <20181130132130.GA11747@lunn.ch> References: <20181129185345.17235-1-stephend@silicom-usa.com> <20181129185345.17235-2-stephend@silicom-usa.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jeff Kirsher , "David S. Miller" , "netdev@vger.kernel.org" To: Steve Douthit Return-path: Received: from vps0.lunn.ch ([185.16.172.187]:55729 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbeLAAaz (ORCPT ); Fri, 30 Nov 2018 19:30:55 -0500 Content-Disposition: inline In-Reply-To: <20181129185345.17235-2-stephend@silicom-usa.com> Sender: netdev-owner@vger.kernel.org List-ID: Hi Steve Cool to see another interface being made DSA capable. > +/** > + * ixgbe_msca - Write the command register and poll for completion/timeout > + * @hw: pointer to hardware structure > + * @cmd: command register value to write > + **/ > +static s32 ixgbe_msca_cmd(struct ixgbe_hw *hw, u32 cmd) > +{ > + u32 i; > + > + IXGBE_WRITE_REG(hw, IXGBE_MSCA, cmd); > + > + for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) { > + udelay(10); > + cmd = IXGBE_READ_REG(hw, IXGBE_MSCA); > + if (!(cmd & IXGBE_MSCA_MDI_COMMAND)) > + return 0; > + } > + > + return -ETIMEDOUT; Please consider using readx_poll_timeout() > +} > + > +/** > + * ixgbe_msca - Use device_id to figure out if MDIO bus is shared between MACs. > + * The embedded x550(s) in the C3000 line of SoCs only have a single mii_bus > + * shared between all MACs, and that introduces some new mask flags that need > + * to be passed to the *_swfw_sync callbacks. > + * @hw: pointer to hardware structure > + **/ > +static bool ixgbe_is_shared_mii(struct ixgbe_hw *hw) > +{ > + switch (hw->device_id) { > + case IXGBE_DEV_ID_X550EM_A_KR: > + case IXGBE_DEV_ID_X550EM_A_KR_L: > + case IXGBE_DEV_ID_X550EM_A_SFP_N: > + case IXGBE_DEV_ID_X550EM_A_SGMII: > + case IXGBE_DEV_ID_X550EM_A_SGMII_L: > + case IXGBE_DEV_ID_X550EM_A_10G_T: > + case IXGBE_DEV_ID_X550EM_A_SFP: > + case IXGBE_DEV_ID_X550EM_A_1G_T: > + case IXGBE_DEV_ID_X550EM_A_1G_T_L: > + return true; > + } > + > + return false; > +} > + > +/** > + * ixgbe_mii_bus_read - Read a clause 22/45 register > + * @hw: pointer to hardware structure > + * @addr: address > + * @regnum: register number > + **/ > +static s32 ixgbe_mii_bus_read(struct mii_bus *bus, int addr, int regnum) > +{ > + struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)bus->priv; > + struct ixgbe_hw *hw = &adapter->hw; > + u32 hwaddr, cmd, gssr = hw->phy.phy_semaphore_mask; > + s32 data; > + > + if (ixgbe_is_shared_mii(hw)) { > + gssr |= IXGBE_GSSR_TOKEN_SM; > + if (hw->bus.lan_id) > + gssr |= IXGBE_GSSR_PHY1_SM; > + else > + gssr |= IXGBE_GSSR_PHY0_SM; > + } Could you explain this shared bus a bit more. If there is only one physical MDIO bus, you should only register one bus with Linux. So i would not normally expect to see ixgbe_is_shared_mii() sort of statements into the read/write functions. That tends to happen at the point you are registering the MDIO bus, and when looking for the MACs PHY on the bus. Andrew