Commit 04c2632a authored by David S. Miller's avatar David S. Miller

Merge branch 'net-mvpp2-fixes-and-improvements'

Antoine Tenart says:

====================
net: mvpp2: fixes and improvements

This series aims to improve the Marvell PPv2 driver and to fix various
issues we encountered while testing the ports in many different
configurations. The series is based on top of Russell PPv2 phylink
rework and improvement.

I'm not sending a v2 of the previous fixes series as half the patches
are not the same and lots of development happened in between.

While this series contains fixes, it's sent to net-next as it is based
on top of Russell patches that were merged into net-next. I'm also
aiming at net-next as the series reworks critical paths of the PPv2
driver, such as the reset handling of various blocks, to let more weeks
for users to tests and for possible fixes to be sent before it lands
into a stable kernel version.

The series is divided into three parts:

- Patches 1 to 3 are cosmetic changes, sent alongside the series, as I
  saw these small issues while working on this.

- Patches 5 to 8 are fixing (or improving) individual issues that we
  found while testing PPv2.1 and PPv2.2 ports while using various
  interfaces.

  Notable fixes are we support back RGMII interfaces (on both PPv2.1 and
  PPv2.2), as their support was broken by previous patches. We also
  reworked the RXQ computation as the RXQ assignment was not checking
  the maximum number of RXQ available, and was broken for PPv2.1.

- As discussed in a previous fixes series, patches 9 to 15 rework the
  way blocks are set in reset in the PPv2 engine (plus related changes).

  There are four blocks we want to control the reset status: two MAC
  (GMAC and XLG MAC) and two PCS (MPCS and XPCS). The XLG MAC is used
  for 10G connexions and uses the MPCS or the XPCS depending on the mode
  used (10GKR / XAUI / RXAUI) and the GMAC is used for the other modes.

  The idea is to set all blocks in reset by default, and when not used,
  and to de-assert the reset only when a block is used. There are four
  cases to take in account:

  1. Boot time: all four blocks should be put in reset, as we do not
     know their initial state (configured by the firmware/bootloader).

  2. Link up: only the blocks used by a given mode should be put out of
     reset (eg. 10GKR uses the XLG MAC and the MPCS).

  3. Mode reconfiguration: some ports may support mode reconfiguration,
     and switching between the GMAC and the XLG MAC (or between the two
     PCS). All blocks should be put in reset, and only the one used
     should be put out of reset.

  4. Link down: all four blocks are put in reset.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 57d37aea 1f69afce
...@@ -389,7 +389,7 @@ ...@@ -389,7 +389,7 @@
#define MVPP2_GMAC_IN_BAND_AUTONEG BIT(2) #define MVPP2_GMAC_IN_BAND_AUTONEG BIT(2)
#define MVPP2_GMAC_IN_BAND_AUTONEG_BYPASS BIT(3) #define MVPP2_GMAC_IN_BAND_AUTONEG_BYPASS BIT(3)
#define MVPP2_GMAC_IN_BAND_RESTART_AN BIT(4) #define MVPP2_GMAC_IN_BAND_RESTART_AN BIT(4)
#define MVPP2_GMAC_CONFIG_MII_SPEED BIT(5) #define MVPP2_GMAC_CONFIG_MII_SPEED BIT(5)
#define MVPP2_GMAC_CONFIG_GMII_SPEED BIT(6) #define MVPP2_GMAC_CONFIG_GMII_SPEED BIT(6)
#define MVPP2_GMAC_AN_SPEED_EN BIT(7) #define MVPP2_GMAC_AN_SPEED_EN BIT(7)
#define MVPP2_GMAC_FC_ADV_EN BIT(9) #define MVPP2_GMAC_FC_ADV_EN BIT(9)
...@@ -430,6 +430,8 @@ ...@@ -430,6 +430,8 @@
#define MVPP22_XLG_CTRL0_REG 0x100 #define MVPP22_XLG_CTRL0_REG 0x100
#define MVPP22_XLG_CTRL0_PORT_EN BIT(0) #define MVPP22_XLG_CTRL0_PORT_EN BIT(0)
#define MVPP22_XLG_CTRL0_MAC_RESET_DIS BIT(1) #define MVPP22_XLG_CTRL0_MAC_RESET_DIS BIT(1)
#define MVPP22_XLG_CTRL0_FORCE_LINK_DOWN BIT(2)
#define MVPP22_XLG_CTRL0_FORCE_LINK_PASS BIT(3)
#define MVPP22_XLG_CTRL0_RX_FLOW_CTRL_EN BIT(7) #define MVPP22_XLG_CTRL0_RX_FLOW_CTRL_EN BIT(7)
#define MVPP22_XLG_CTRL0_TX_FLOW_CTRL_EN BIT(8) #define MVPP22_XLG_CTRL0_TX_FLOW_CTRL_EN BIT(8)
#define MVPP22_XLG_CTRL0_MIB_CNT_DIS BIT(14) #define MVPP22_XLG_CTRL0_MIB_CNT_DIS BIT(14)
...@@ -481,6 +483,7 @@ ...@@ -481,6 +483,7 @@
/* XPCS registers. PPv2.2 only */ /* XPCS registers. PPv2.2 only */
#define MVPP22_XPCS_BASE(port) (0x7400 + (port) * 0x1000) #define MVPP22_XPCS_BASE(port) (0x7400 + (port) * 0x1000)
#define MVPP22_XPCS_CFG0 0x0 #define MVPP22_XPCS_CFG0 0x0
#define MVPP22_XPCS_CFG0_RESET_DIS BIT(0)
#define MVPP22_XPCS_CFG0_PCS_MODE(n) ((n) << 3) #define MVPP22_XPCS_CFG0_PCS_MODE(n) ((n) << 3)
#define MVPP22_XPCS_CFG0_ACTIVE_LANE(n) ((n) << 5) #define MVPP22_XPCS_CFG0_ACTIVE_LANE(n) ((n) << 5)
...@@ -549,8 +552,8 @@ ...@@ -549,8 +552,8 @@
#define MVPP2_MAX_TSO_SEGS 300 #define MVPP2_MAX_TSO_SEGS 300
#define MVPP2_MAX_SKB_DESCS (MVPP2_MAX_TSO_SEGS * 2 + MAX_SKB_FRAGS) #define MVPP2_MAX_SKB_DESCS (MVPP2_MAX_TSO_SEGS * 2 + MAX_SKB_FRAGS)
/* Dfault number of RXQs in use */ /* Max number of RXQs per port */
#define MVPP2_DEFAULT_RXQ 1 #define MVPP2_PORT_MAX_RXQ 32
/* Max number of Rx descriptors */ /* Max number of Rx descriptors */
#define MVPP2_MAX_RXD_MAX 1024 #define MVPP2_MAX_RXD_MAX 1024
...@@ -803,7 +806,7 @@ struct mvpp2_port { ...@@ -803,7 +806,7 @@ struct mvpp2_port {
u8 id; u8 id;
/* Index of the port from the "group of ports" complex point /* Index of the port from the "group of ports" complex point
* of view * of view. This is specific to PPv2.2.
*/ */
int gop_id; int gop_id;
......
...@@ -1015,27 +1015,20 @@ static void mvpp22_gop_init_10gkr(struct mvpp2_port *port) ...@@ -1015,27 +1015,20 @@ static void mvpp22_gop_init_10gkr(struct mvpp2_port *port)
void __iomem *xpcs = priv->iface_base + MVPP22_XPCS_BASE(port->gop_id); void __iomem *xpcs = priv->iface_base + MVPP22_XPCS_BASE(port->gop_id);
u32 val; u32 val;
/* XPCS */
val = readl(xpcs + MVPP22_XPCS_CFG0); val = readl(xpcs + MVPP22_XPCS_CFG0);
val &= ~(MVPP22_XPCS_CFG0_PCS_MODE(0x3) | val &= ~(MVPP22_XPCS_CFG0_PCS_MODE(0x3) |
MVPP22_XPCS_CFG0_ACTIVE_LANE(0x3)); MVPP22_XPCS_CFG0_ACTIVE_LANE(0x3));
val |= MVPP22_XPCS_CFG0_ACTIVE_LANE(2); val |= MVPP22_XPCS_CFG0_ACTIVE_LANE(2);
writel(val, xpcs + MVPP22_XPCS_CFG0); writel(val, xpcs + MVPP22_XPCS_CFG0);
/* MPCS */
val = readl(mpcs + MVPP22_MPCS_CTRL); val = readl(mpcs + MVPP22_MPCS_CTRL);
val &= ~MVPP22_MPCS_CTRL_FWD_ERR_CONN; val &= ~MVPP22_MPCS_CTRL_FWD_ERR_CONN;
writel(val, mpcs + MVPP22_MPCS_CTRL); writel(val, mpcs + MVPP22_MPCS_CTRL);
val = readl(mpcs + MVPP22_MPCS_CLK_RESET); val = readl(mpcs + MVPP22_MPCS_CLK_RESET);
val &= ~(MVPP22_MPCS_CLK_RESET_DIV_RATIO(0x7) | MAC_CLK_RESET_MAC | val &= ~MVPP22_MPCS_CLK_RESET_DIV_RATIO(0x7);
MAC_CLK_RESET_SD_RX | MAC_CLK_RESET_SD_TX);
val |= MVPP22_MPCS_CLK_RESET_DIV_RATIO(1); val |= MVPP22_MPCS_CLK_RESET_DIV_RATIO(1);
writel(val, mpcs + MVPP22_MPCS_CLK_RESET); writel(val, mpcs + MVPP22_MPCS_CLK_RESET);
val &= ~MVPP22_MPCS_CLK_RESET_DIV_SET;
val |= MAC_CLK_RESET_MAC | MAC_CLK_RESET_SD_RX | MAC_CLK_RESET_SD_TX;
writel(val, mpcs + MVPP22_MPCS_CLK_RESET);
} }
static int mvpp22_gop_init(struct mvpp2_port *port) static int mvpp22_gop_init(struct mvpp2_port *port)
...@@ -1188,8 +1181,7 @@ static void mvpp2_port_enable(struct mvpp2_port *port) ...@@ -1188,8 +1181,7 @@ static void mvpp2_port_enable(struct mvpp2_port *port)
/* Only GOP port 0 has an XLG MAC */ /* Only GOP port 0 has an XLG MAC */
if (port->gop_id == 0 && mvpp2_is_xlg(port->phy_interface)) { if (port->gop_id == 0 && mvpp2_is_xlg(port->phy_interface)) {
val = readl(port->base + MVPP22_XLG_CTRL0_REG); val = readl(port->base + MVPP22_XLG_CTRL0_REG);
val |= MVPP22_XLG_CTRL0_PORT_EN | val |= MVPP22_XLG_CTRL0_PORT_EN;
MVPP22_XLG_CTRL0_MAC_RESET_DIS;
val &= ~MVPP22_XLG_CTRL0_MIB_CNT_DIS; val &= ~MVPP22_XLG_CTRL0_MIB_CNT_DIS;
writel(val, port->base + MVPP22_XLG_CTRL0_REG); writel(val, port->base + MVPP22_XLG_CTRL0_REG);
} else { } else {
...@@ -1209,15 +1201,11 @@ static void mvpp2_port_disable(struct mvpp2_port *port) ...@@ -1209,15 +1201,11 @@ static void mvpp2_port_disable(struct mvpp2_port *port)
val = readl(port->base + MVPP22_XLG_CTRL0_REG); val = readl(port->base + MVPP22_XLG_CTRL0_REG);
val &= ~MVPP22_XLG_CTRL0_PORT_EN; val &= ~MVPP22_XLG_CTRL0_PORT_EN;
writel(val, port->base + MVPP22_XLG_CTRL0_REG); writel(val, port->base + MVPP22_XLG_CTRL0_REG);
/* Disable & reset should be done separately */
val &= ~MVPP22_XLG_CTRL0_MAC_RESET_DIS;
writel(val, port->base + MVPP22_XLG_CTRL0_REG);
} else {
val = readl(port->base + MVPP2_GMAC_CTRL_0_REG);
val &= ~(MVPP2_GMAC_PORT_EN_MASK);
writel(val, port->base + MVPP2_GMAC_CTRL_0_REG);
} }
val = readl(port->base + MVPP2_GMAC_CTRL_0_REG);
val &= ~(MVPP2_GMAC_PORT_EN_MASK);
writel(val, port->base + MVPP2_GMAC_CTRL_0_REG);
} }
/* Set IEEE 802.3x Flow Control Xon Packet Transmission Mode */ /* Set IEEE 802.3x Flow Control Xon Packet Transmission Mode */
...@@ -1369,10 +1357,10 @@ static int mvpp2_ethtool_get_sset_count(struct net_device *dev, int sset) ...@@ -1369,10 +1357,10 @@ static int mvpp2_ethtool_get_sset_count(struct net_device *dev, int sset)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static void mvpp2_port_reset(struct mvpp2_port *port) static void mvpp2_mac_reset_assert(struct mvpp2_port *port)
{ {
u32 val;
unsigned int i; unsigned int i;
u32 val;
/* Read the GOP statistics to reset the hardware counters */ /* Read the GOP statistics to reset the hardware counters */
for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++) for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
...@@ -1381,6 +1369,63 @@ static void mvpp2_port_reset(struct mvpp2_port *port) ...@@ -1381,6 +1369,63 @@ static void mvpp2_port_reset(struct mvpp2_port *port)
val = readl(port->base + MVPP2_GMAC_CTRL_2_REG) | val = readl(port->base + MVPP2_GMAC_CTRL_2_REG) |
MVPP2_GMAC_PORT_RESET_MASK; MVPP2_GMAC_PORT_RESET_MASK;
writel(val, port->base + MVPP2_GMAC_CTRL_2_REG); writel(val, port->base + MVPP2_GMAC_CTRL_2_REG);
if (port->priv->hw_version == MVPP22 && port->gop_id == 0) {
val = readl(port->base + MVPP22_XLG_CTRL0_REG) &
~MVPP22_XLG_CTRL0_MAC_RESET_DIS;
writel(val, port->base + MVPP22_XLG_CTRL0_REG);
}
}
static void mvpp22_pcs_reset_assert(struct mvpp2_port *port)
{
struct mvpp2 *priv = port->priv;
void __iomem *mpcs, *xpcs;
u32 val;
if (port->priv->hw_version != MVPP22 || port->gop_id != 0)
return;
mpcs = priv->iface_base + MVPP22_MPCS_BASE(port->gop_id);
xpcs = priv->iface_base + MVPP22_XPCS_BASE(port->gop_id);
val = readl(mpcs + MVPP22_MPCS_CLK_RESET);
val &= ~(MAC_CLK_RESET_MAC | MAC_CLK_RESET_SD_RX | MAC_CLK_RESET_SD_TX);
val |= MVPP22_MPCS_CLK_RESET_DIV_SET;
writel(val, mpcs + MVPP22_MPCS_CLK_RESET);
val = readl(xpcs + MVPP22_XPCS_CFG0);
writel(val & ~MVPP22_XPCS_CFG0_RESET_DIS, xpcs + MVPP22_XPCS_CFG0);
}
static void mvpp22_pcs_reset_deassert(struct mvpp2_port *port)
{
struct mvpp2 *priv = port->priv;
void __iomem *mpcs, *xpcs;
u32 val;
if (port->priv->hw_version != MVPP22 || port->gop_id != 0)
return;
mpcs = priv->iface_base + MVPP22_MPCS_BASE(port->gop_id);
xpcs = priv->iface_base + MVPP22_XPCS_BASE(port->gop_id);
switch (port->phy_interface) {
case PHY_INTERFACE_MODE_10GKR:
val = readl(mpcs + MVPP22_MPCS_CLK_RESET);
val |= MAC_CLK_RESET_MAC | MAC_CLK_RESET_SD_RX |
MAC_CLK_RESET_SD_TX;
val &= ~MVPP22_MPCS_CLK_RESET_DIV_SET;
writel(val, mpcs + MVPP22_MPCS_CLK_RESET);
break;
case PHY_INTERFACE_MODE_XAUI:
case PHY_INTERFACE_MODE_RXAUI:
val = readl(xpcs + MVPP22_XPCS_CFG0);
writel(val | MVPP22_XPCS_CFG0_RESET_DIS, xpcs + MVPP22_XPCS_CFG0);
break;
default:
break;
}
} }
/* Change maximum receive size of the port */ /* Change maximum receive size of the port */
...@@ -3135,12 +3180,20 @@ static void mvpp22_mode_reconfigure(struct mvpp2_port *port) ...@@ -3135,12 +3180,20 @@ static void mvpp22_mode_reconfigure(struct mvpp2_port *port)
{ {
u32 ctrl3; u32 ctrl3;
/* Set the GMAC & XLG MAC in reset */
mvpp2_mac_reset_assert(port);
/* Set the MPCS and XPCS in reset */
mvpp22_pcs_reset_assert(port);
/* comphy reconfiguration */ /* comphy reconfiguration */
mvpp22_comphy_init(port); mvpp22_comphy_init(port);
/* gop reconfiguration */ /* gop reconfiguration */
mvpp22_gop_init(port); mvpp22_gop_init(port);
mvpp22_pcs_reset_deassert(port);
/* Only GOP port 0 has an XLG MAC */ /* Only GOP port 0 has an XLG MAC */
if (port->gop_id == 0) { if (port->gop_id == 0) {
ctrl3 = readl(port->base + MVPP22_XLG_CTRL3_REG); ctrl3 = readl(port->base + MVPP22_XLG_CTRL3_REG);
...@@ -3472,6 +3525,9 @@ static int mvpp2_stop(struct net_device *dev) ...@@ -3472,6 +3525,9 @@ static int mvpp2_stop(struct net_device *dev)
cancel_delayed_work_sync(&port->stats_work); cancel_delayed_work_sync(&port->stats_work);
mvpp2_mac_reset_assert(port);
mvpp22_pcs_reset_assert(port);
return 0; return 0;
} }
...@@ -4061,8 +4117,8 @@ static int mvpp2_multi_queue_vectors_init(struct mvpp2_port *port, ...@@ -4061,8 +4117,8 @@ static int mvpp2_multi_queue_vectors_init(struct mvpp2_port *port,
snprintf(irqname, sizeof(irqname), "hif%d", i); snprintf(irqname, sizeof(irqname), "hif%d", i);
if (queue_mode == MVPP2_QDIST_MULTI_MODE) { if (queue_mode == MVPP2_QDIST_MULTI_MODE) {
v->first_rxq = i * MVPP2_DEFAULT_RXQ; v->first_rxq = i;
v->nrxqs = MVPP2_DEFAULT_RXQ; v->nrxqs = 1;
} else if (queue_mode == MVPP2_QDIST_SINGLE_MODE && } else if (queue_mode == MVPP2_QDIST_SINGLE_MODE &&
i == (port->nqvecs - 1)) { i == (port->nqvecs - 1)) {
v->first_rxq = 0; v->first_rxq = 0;
...@@ -4155,8 +4211,7 @@ static int mvpp2_port_init(struct mvpp2_port *port) ...@@ -4155,8 +4211,7 @@ static int mvpp2_port_init(struct mvpp2_port *port)
MVPP2_MAX_PORTS * priv->max_port_rxqs) MVPP2_MAX_PORTS * priv->max_port_rxqs)
return -EINVAL; return -EINVAL;
if (port->nrxqs % MVPP2_DEFAULT_RXQ || if (port->nrxqs > priv->max_port_rxqs || port->ntxqs > MVPP2_MAX_TXQ)
port->nrxqs > priv->max_port_rxqs || port->ntxqs > MVPP2_MAX_TXQ)
return -EINVAL; return -EINVAL;
/* Disable port */ /* Disable port */
...@@ -4363,7 +4418,7 @@ static void mvpp2_phylink_validate(struct net_device *dev, ...@@ -4363,7 +4418,7 @@ static void mvpp2_phylink_validate(struct net_device *dev,
case PHY_INTERFACE_MODE_RGMII_ID: case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID: case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_TXID: case PHY_INTERFACE_MODE_RGMII_TXID:
if (port->gop_id == 0) if (port->priv->hw_version == MVPP22 && port->gop_id == 0)
goto empty_set; goto empty_set;
break; break;
default: default:
...@@ -4506,10 +4561,13 @@ static void mvpp2_mac_an_restart(struct net_device *dev) ...@@ -4506,10 +4561,13 @@ static void mvpp2_mac_an_restart(struct net_device *dev)
static void mvpp2_xlg_config(struct mvpp2_port *port, unsigned int mode, static void mvpp2_xlg_config(struct mvpp2_port *port, unsigned int mode,
const struct phylink_link_state *state) const struct phylink_link_state *state)
{ {
u32 ctrl0, ctrl4; u32 old_ctrl0, ctrl0;
u32 old_ctrl4, ctrl4;
old_ctrl0 = ctrl0 = readl(port->base + MVPP22_XLG_CTRL0_REG);
old_ctrl4 = ctrl4 = readl(port->base + MVPP22_XLG_CTRL4_REG);
ctrl0 = readl(port->base + MVPP22_XLG_CTRL0_REG); ctrl0 |= MVPP22_XLG_CTRL0_MAC_RESET_DIS;
ctrl4 = readl(port->base + MVPP22_XLG_CTRL4_REG);
if (state->pause & MLO_PAUSE_TX) if (state->pause & MLO_PAUSE_TX)
ctrl0 |= MVPP22_XLG_CTRL0_TX_FLOW_CTRL_EN; ctrl0 |= MVPP22_XLG_CTRL0_TX_FLOW_CTRL_EN;
...@@ -4525,8 +4583,16 @@ static void mvpp2_xlg_config(struct mvpp2_port *port, unsigned int mode, ...@@ -4525,8 +4583,16 @@ static void mvpp2_xlg_config(struct mvpp2_port *port, unsigned int mode,
ctrl4 |= MVPP22_XLG_CTRL4_FWD_FC | MVPP22_XLG_CTRL4_FWD_PFC | ctrl4 |= MVPP22_XLG_CTRL4_FWD_FC | MVPP22_XLG_CTRL4_FWD_PFC |
MVPP22_XLG_CTRL4_EN_IDLE_CHECK; MVPP22_XLG_CTRL4_EN_IDLE_CHECK;
writel(ctrl0, port->base + MVPP22_XLG_CTRL0_REG); if (old_ctrl0 != ctrl0)
writel(ctrl4, port->base + MVPP22_XLG_CTRL4_REG); writel(ctrl0, port->base + MVPP22_XLG_CTRL0_REG);
if (old_ctrl4 != ctrl4)
writel(ctrl4, port->base + MVPP22_XLG_CTRL4_REG);
if (!(old_ctrl0 & MVPP22_XLG_CTRL0_MAC_RESET_DIS)) {
while (!(readl(port->base + MVPP22_XLG_CTRL0_REG) &
MVPP22_XLG_CTRL0_MAC_RESET_DIS))
continue;
}
} }
static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode, static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode,
...@@ -4627,9 +4693,19 @@ static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode, ...@@ -4627,9 +4693,19 @@ static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode,
} }
} }
/* Some fields of the auto-negotiation register require the port to be down when
* their value is updated.
*/
#define MVPP2_GMAC_AN_PORT_DOWN_MASK \
(MVPP2_GMAC_IN_BAND_AUTONEG | \
MVPP2_GMAC_IN_BAND_AUTONEG_BYPASS | \
MVPP2_GMAC_CONFIG_MII_SPEED | MVPP2_GMAC_CONFIG_GMII_SPEED | \
MVPP2_GMAC_AN_SPEED_EN | MVPP2_GMAC_CONFIG_FULL_DUPLEX | \
MVPP2_GMAC_AN_DUPLEX_EN)
if ((old_ctrl0 ^ ctrl0) & MVPP2_GMAC_PORT_TYPE_MASK || if ((old_ctrl0 ^ ctrl0) & MVPP2_GMAC_PORT_TYPE_MASK ||
(old_ctrl2 ^ ctrl2) & MVPP2_GMAC_INBAND_AN_MASK || (old_ctrl2 ^ ctrl2) & MVPP2_GMAC_INBAND_AN_MASK ||
(old_an ^ an) & MVPP2_GMAC_IN_BAND_AUTONEG) { (old_an ^ an) & MVPP2_GMAC_AN_PORT_DOWN_MASK) {
/* Force link down */ /* Force link down */
old_an &= ~MVPP2_GMAC_FORCE_LINK_PASS; old_an &= ~MVPP2_GMAC_FORCE_LINK_PASS;
old_an |= MVPP2_GMAC_FORCE_LINK_DOWN; old_an |= MVPP2_GMAC_FORCE_LINK_DOWN;
...@@ -4672,16 +4748,15 @@ static void mvpp2_mac_config(struct net_device *dev, unsigned int mode, ...@@ -4672,16 +4748,15 @@ static void mvpp2_mac_config(struct net_device *dev, unsigned int mode,
/* Make sure the port is disabled when reconfiguring the mode */ /* Make sure the port is disabled when reconfiguring the mode */
mvpp2_port_disable(port); mvpp2_port_disable(port);
if (change_interface) {
if (port->priv->hw_version == MVPP22 && change_interface) {
mvpp22_gop_mask_irq(port); mvpp22_gop_mask_irq(port);
if (port->priv->hw_version == MVPP22) { port->phy_interface = state->interface;
port->phy_interface = state->interface;
/* Reconfigure the serdes lanes */ /* Reconfigure the serdes lanes */
phy_power_off(port->comphy); phy_power_off(port->comphy);
mvpp22_mode_reconfigure(port); mvpp22_mode_reconfigure(port);
}
} }
/* mac (re)configuration */ /* mac (re)configuration */
...@@ -4695,7 +4770,7 @@ static void mvpp2_mac_config(struct net_device *dev, unsigned int mode, ...@@ -4695,7 +4770,7 @@ static void mvpp2_mac_config(struct net_device *dev, unsigned int mode,
if (port->priv->hw_version == MVPP21 && port->flags & MVPP2_F_LOOPBACK) if (port->priv->hw_version == MVPP21 && port->flags & MVPP2_F_LOOPBACK)
mvpp2_port_loopback_set(port, state); mvpp2_port_loopback_set(port, state);
if (change_interface) if (port->priv->hw_version == MVPP22 && change_interface)
mvpp22_gop_unmask_irq(port); mvpp22_gop_unmask_irq(port);
mvpp2_port_enable(port); mvpp2_port_enable(port);
...@@ -4707,11 +4782,18 @@ static void mvpp2_mac_link_up(struct net_device *dev, unsigned int mode, ...@@ -4707,11 +4782,18 @@ static void mvpp2_mac_link_up(struct net_device *dev, unsigned int mode,
struct mvpp2_port *port = netdev_priv(dev); struct mvpp2_port *port = netdev_priv(dev);
u32 val; u32 val;
if (!phylink_autoneg_inband(mode) && !mvpp2_is_xlg(interface)) { if (!phylink_autoneg_inband(mode)) {
val = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG); if (mvpp2_is_xlg(interface)) {
val &= ~MVPP2_GMAC_FORCE_LINK_DOWN; val = readl(port->base + MVPP22_XLG_CTRL0_REG);
val |= MVPP2_GMAC_FORCE_LINK_PASS; val &= ~MVPP22_XLG_CTRL0_FORCE_LINK_DOWN;
writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG); val |= MVPP22_XLG_CTRL0_FORCE_LINK_PASS;
writel(val, port->base + MVPP22_XLG_CTRL0_REG);
} else {
val = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG);
val &= ~MVPP2_GMAC_FORCE_LINK_DOWN;
val |= MVPP2_GMAC_FORCE_LINK_PASS;
writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
}
} }
mvpp2_port_enable(port); mvpp2_port_enable(port);
...@@ -4727,24 +4809,24 @@ static void mvpp2_mac_link_down(struct net_device *dev, unsigned int mode, ...@@ -4727,24 +4809,24 @@ static void mvpp2_mac_link_down(struct net_device *dev, unsigned int mode,
struct mvpp2_port *port = netdev_priv(dev); struct mvpp2_port *port = netdev_priv(dev);
u32 val; u32 val;
if (!phylink_autoneg_inband(mode) && !mvpp2_is_xlg(interface)) { if (!phylink_autoneg_inband(mode)) {
val = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG); if (mvpp2_is_xlg(interface)) {
val &= ~MVPP2_GMAC_FORCE_LINK_PASS; val = readl(port->base + MVPP22_XLG_CTRL0_REG);
val |= MVPP2_GMAC_FORCE_LINK_DOWN; val &= ~MVPP22_XLG_CTRL0_FORCE_LINK_PASS;
writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG); val |= MVPP22_XLG_CTRL0_FORCE_LINK_DOWN;
writel(val, port->base + MVPP22_XLG_CTRL0_REG);
} else {
val = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG);
val &= ~MVPP2_GMAC_FORCE_LINK_PASS;
val |= MVPP2_GMAC_FORCE_LINK_DOWN;
writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
}
} }
netif_tx_stop_all_queues(dev); netif_tx_stop_all_queues(dev);
mvpp2_egress_disable(port); mvpp2_egress_disable(port);
mvpp2_ingress_disable(port); mvpp2_ingress_disable(port);
/* When using link interrupts to notify phylink of a MAC state change,
* we do not want the port to be disabled (we want to receive further
* interrupts, to be notified when the port will have a link later).
*/
if (!port->has_phy)
return;
mvpp2_port_disable(port); mvpp2_port_disable(port);
} }
...@@ -4786,10 +4868,18 @@ static int mvpp2_port_probe(struct platform_device *pdev, ...@@ -4786,10 +4868,18 @@ static int mvpp2_port_probe(struct platform_device *pdev,
} }
ntxqs = MVPP2_MAX_TXQ; ntxqs = MVPP2_MAX_TXQ;
if (priv->hw_version == MVPP22 && queue_mode == MVPP2_QDIST_MULTI_MODE) if (priv->hw_version == MVPP22 && queue_mode == MVPP2_QDIST_SINGLE_MODE) {
nrxqs = MVPP2_DEFAULT_RXQ * num_possible_cpus(); nrxqs = 1;
else } else {
nrxqs = MVPP2_DEFAULT_RXQ; /* According to the PPv2.2 datasheet and our experiments on
* PPv2.1, RX queues have an allocation granularity of 4 (when
* more than a single one on PPv2.2).
* Round up to nearest multiple of 4.
*/
nrxqs = (num_possible_cpus() + 3) & ~0x3;
if (nrxqs > MVPP2_PORT_MAX_RXQ)
nrxqs = MVPP2_PORT_MAX_RXQ;
}
dev = alloc_etherdev_mqs(sizeof(*port), ntxqs, nrxqs); dev = alloc_etherdev_mqs(sizeof(*port), ntxqs, nrxqs);
if (!dev) if (!dev)
...@@ -4920,7 +5010,8 @@ static int mvpp2_port_probe(struct platform_device *pdev, ...@@ -4920,7 +5010,8 @@ static int mvpp2_port_probe(struct platform_device *pdev,
mvpp2_port_periodic_xon_disable(port); mvpp2_port_periodic_xon_disable(port);
mvpp2_port_reset(port); mvpp2_mac_reset_assert(port);
mvpp22_pcs_reset_assert(port);
port->pcpu = alloc_percpu(struct mvpp2_port_pcpu); port->pcpu = alloc_percpu(struct mvpp2_port_pcpu);
if (!port->pcpu) { if (!port->pcpu) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment