RE: [PATCH net-next v4 1/2] net/ethernet/realtek: Add Realtek automotive PCIe driver code

From: Justin Lai
Date: Fri Aug 18 2023 - 08:02:42 EST


> +static inline void rtase_enable_hw_interrupt(const struct
> rtase_private *tp)
>
> If you read comments given to other developers, you would of seen that
> inline functions are not allowed in .C files. Let the compiler decide.
>
> > +static int rtase_get_settings(struct net_device *dev, struct
> > +ethtool_link_ksettings *cmd) {
> > + const struct rtase_private *tp = netdev_priv(dev);
> > + u32 advertising = 0;
> > + u32 supported = 0;
> > + u32 speed = 0;
> > + u16 value = 0;
> > +
> > + supported |= SUPPORTED_MII | SUPPORTED_Pause;
> > +
> > + advertising |= ADVERTISED_MII;
>
> You don't advertise anything, because you don't have a PHY.
>
> > +
> > + /* speed */
> > + switch (tp->pdev->bus->cur_bus_speed) {
>
> Speed is meant to be line side speed. That is fixed at 5G. So i would
> expect a hard coded value.
>
> > +static void rtase_get_pauseparam(struct net_device *dev, struct
> > +ethtool_pauseparam *pause) {
> > + const struct rtase_private *tp = netdev_priv(dev);
> > + u16 value = RTL_R16(tp, CPLUS_CMD);
> > +
> > + if ((value & (FORCE_TXFLOW_EN | FORCE_RXFLOW_EN)) ==
> (FORCE_TXFLOW_EN | FORCE_RXFLOW_EN)) {
> > + pause->rx_pause = 1;
> > + pause->tx_pause = 1;
> > + } else if ((value & FORCE_TXFLOW_EN) != 0u) {
> > + pause->tx_pause = 1;
> > + } else if ((value & FORCE_RXFLOW_EN) != 0u) {
> > + pause->rx_pause = 1;
> > + } else {
> > + /* not enable pause */
> > + }
>
> Probably not required, but it would be good to set pause.autoneg to
> false, just to make is clear you don't support negotiating it.
>
> > +}
> > +
> > +static int rtase_set_pauseparam(struct net_device *dev, struct
> > +ethtool_pauseparam *pause) {
> > + const struct rtase_private *tp = netdev_priv(dev);
> > + u16 value = RTL_R16(tp, CPLUS_CMD);
>
> Similar to above, you should return EOPNOTSUPP if pause.autoneg is true.
>
> > +
> > + value &= ~(FORCE_TXFLOW_EN | FORCE_RXFLOW_EN);
> > +
> > + if (pause->tx_pause == 1u)
> > + value |= FORCE_TXFLOW_EN;
> > +
> > + if (pause->rx_pause == 1u)
>
> You can treat these as boolean.
>
> > + value |= FORCE_RXFLOW_EN;
> > +
> > + RTL_W16(tp, CPLUS_CMD, value);
> > + return 0;
> > +}
>
>
> Andrew

Hi, Andrew

Thanks for your quick review, I will check our code again and make changes.
>
> ---
> pw-bot: cr
>