Commit 457b1d5a authored by Lennert Buytenhek's avatar Lennert Buytenhek Committed by Lennert Buytenhek

mv643xx_eth: add support for chips without transmit bandwidth control

Add support for mv643xx_eth versions that have no transmit bandwidth
control registers at all, such as the ethernet block found in the
Marvell 88F6183 ARM SoC.
Signed-off-by: default avatarLennert Buytenhek <buytenh@marvell.com>
parent 6b8f90c2
...@@ -271,9 +271,13 @@ struct mv643xx_eth_shared_private { ...@@ -271,9 +271,13 @@ struct mv643xx_eth_shared_private {
*/ */
unsigned int t_clk; unsigned int t_clk;
int extended_rx_coal_limit; int extended_rx_coal_limit;
int tx_bw_control_moved; int tx_bw_control;
}; };
#define TX_BW_CONTROL_ABSENT 0
#define TX_BW_CONTROL_OLD_LAYOUT 1
#define TX_BW_CONTROL_NEW_LAYOUT 2
/* per-port *****************************************************************/ /* per-port *****************************************************************/
struct mib_counters { struct mib_counters {
...@@ -938,14 +942,17 @@ static void tx_set_rate(struct mv643xx_eth_private *mp, int rate, int burst) ...@@ -938,14 +942,17 @@ static void tx_set_rate(struct mv643xx_eth_private *mp, int rate, int burst)
if (bucket_size > 65535) if (bucket_size > 65535)
bucket_size = 65535; bucket_size = 65535;
if (mp->shared->tx_bw_control_moved) { switch (mp->shared->tx_bw_control) {
wrl(mp, TX_BW_RATE_MOVED(mp->port_num), token_rate); case TX_BW_CONTROL_OLD_LAYOUT:
wrl(mp, TX_BW_MTU_MOVED(mp->port_num), mtu);
wrl(mp, TX_BW_BURST_MOVED(mp->port_num), bucket_size);
} else {
wrl(mp, TX_BW_RATE(mp->port_num), token_rate); wrl(mp, TX_BW_RATE(mp->port_num), token_rate);
wrl(mp, TX_BW_MTU(mp->port_num), mtu); wrl(mp, TX_BW_MTU(mp->port_num), mtu);
wrl(mp, TX_BW_BURST(mp->port_num), bucket_size); wrl(mp, TX_BW_BURST(mp->port_num), bucket_size);
break;
case TX_BW_CONTROL_NEW_LAYOUT:
wrl(mp, TX_BW_RATE_MOVED(mp->port_num), token_rate);
wrl(mp, TX_BW_MTU_MOVED(mp->port_num), mtu);
wrl(mp, TX_BW_BURST_MOVED(mp->port_num), bucket_size);
break;
} }
} }
...@@ -977,14 +984,21 @@ static void txq_set_fixed_prio_mode(struct tx_queue *txq) ...@@ -977,14 +984,21 @@ static void txq_set_fixed_prio_mode(struct tx_queue *txq)
/* /*
* Turn on fixed priority mode. * Turn on fixed priority mode.
*/ */
if (mp->shared->tx_bw_control_moved) off = 0;
off = TXQ_FIX_PRIO_CONF_MOVED(mp->port_num); switch (mp->shared->tx_bw_control) {
else case TX_BW_CONTROL_OLD_LAYOUT:
off = TXQ_FIX_PRIO_CONF(mp->port_num); off = TXQ_FIX_PRIO_CONF(mp->port_num);
break;
case TX_BW_CONTROL_NEW_LAYOUT:
off = TXQ_FIX_PRIO_CONF_MOVED(mp->port_num);
break;
}
val = rdl(mp, off); if (off) {
val |= 1 << txq->index; val = rdl(mp, off);
wrl(mp, off, val); val |= 1 << txq->index;
wrl(mp, off, val);
}
} }
static void txq_set_wrr(struct tx_queue *txq, int weight) static void txq_set_wrr(struct tx_queue *txq, int weight)
...@@ -996,23 +1010,30 @@ static void txq_set_wrr(struct tx_queue *txq, int weight) ...@@ -996,23 +1010,30 @@ static void txq_set_wrr(struct tx_queue *txq, int weight)
/* /*
* Turn off fixed priority mode. * Turn off fixed priority mode.
*/ */
if (mp->shared->tx_bw_control_moved) off = 0;
off = TXQ_FIX_PRIO_CONF_MOVED(mp->port_num); switch (mp->shared->tx_bw_control) {
else case TX_BW_CONTROL_OLD_LAYOUT:
off = TXQ_FIX_PRIO_CONF(mp->port_num); off = TXQ_FIX_PRIO_CONF(mp->port_num);
break;
case TX_BW_CONTROL_NEW_LAYOUT:
off = TXQ_FIX_PRIO_CONF_MOVED(mp->port_num);
break;
}
val = rdl(mp, off); if (off) {
val &= ~(1 << txq->index); val = rdl(mp, off);
wrl(mp, off, val); val &= ~(1 << txq->index);
wrl(mp, off, val);
/* /*
* Configure WRR weight for this queue. * Configure WRR weight for this queue.
*/ */
off = TXQ_BW_WRR_CONF(mp->port_num, txq->index); off = TXQ_BW_WRR_CONF(mp->port_num, txq->index);
val = rdl(mp, off); val = rdl(mp, off);
val = (val & ~0xff) | (weight & 0xff); val = (val & ~0xff) | (weight & 0xff);
wrl(mp, off, val); wrl(mp, off, val);
}
} }
...@@ -2288,14 +2309,20 @@ static void infer_hw_params(struct mv643xx_eth_shared_private *msp) ...@@ -2288,14 +2309,20 @@ static void infer_hw_params(struct mv643xx_eth_shared_private *msp)
msp->extended_rx_coal_limit = 0; msp->extended_rx_coal_limit = 0;
/* /*
* Check whether the TX rate control registers are in the * Check whether the MAC supports TX rate control, and if
* old or the new place. * yes, whether its associated registers are in the old or
* the new place.
*/ */
writel(1, msp->base + TX_BW_MTU_MOVED(0)); writel(1, msp->base + TX_BW_MTU_MOVED(0));
if (readl(msp->base + TX_BW_MTU_MOVED(0)) & 1) if (readl(msp->base + TX_BW_MTU_MOVED(0)) & 1) {
msp->tx_bw_control_moved = 1; msp->tx_bw_control = TX_BW_CONTROL_NEW_LAYOUT;
else } else {
msp->tx_bw_control_moved = 0; writel(7, msp->base + TX_BW_RATE(0));
if (readl(msp->base + TX_BW_RATE(0)) & 7)
msp->tx_bw_control = TX_BW_CONTROL_OLD_LAYOUT;
else
msp->tx_bw_control = TX_BW_CONTROL_ABSENT;
}
} }
static int mv643xx_eth_shared_probe(struct platform_device *pdev) static int mv643xx_eth_shared_probe(struct platform_device *pdev)
......
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