Skip to content

Commit cdcfeb0

Browse files
yanmarkmandavem330
authored andcommitted
net: mvpp2: Use relaxed I/O in data path
Use relaxed I/O on the hot path. This achieves significant performance improvements. On a 10G link, this makes a basic iperf TCP test go from an average of 4.5 Gbits/sec to about 9.40 Gbits/sec. Signed-off-by: Yan Markman <[email protected]> [Maxime: Commit message, cosmetic changes] Signed-off-by: Maxime Chevallier <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5f75a18 commit cdcfeb0

File tree

1 file changed

+30
-13
lines changed
  • drivers/net/ethernet/marvell

1 file changed

+30
-13
lines changed

drivers/net/ethernet/marvell/mvpp2.c

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,10 @@ static u32 mvpp2_read(struct mvpp2 *priv, u32 offset)
13591359
return readl(priv->swth_base[0] + offset);
13601360
}
13611361

1362+
static u32 mvpp2_read_relaxed(struct mvpp2 *priv, u32 offset)
1363+
{
1364+
return readl_relaxed(priv->swth_base[0] + offset);
1365+
}
13621366
/* These accessors should be used to access:
13631367
*
13641368
* - per-CPU registers, where each CPU has its own copy of the
@@ -1407,6 +1411,18 @@ static u32 mvpp2_percpu_read(struct mvpp2 *priv, int cpu,
14071411
return readl(priv->swth_base[cpu] + offset);
14081412
}
14091413

1414+
static void mvpp2_percpu_write_relaxed(struct mvpp2 *priv, int cpu,
1415+
u32 offset, u32 data)
1416+
{
1417+
writel_relaxed(data, priv->swth_base[cpu] + offset);
1418+
}
1419+
1420+
static u32 mvpp2_percpu_read_relaxed(struct mvpp2 *priv, int cpu,
1421+
u32 offset)
1422+
{
1423+
return readl_relaxed(priv->swth_base[cpu] + offset);
1424+
}
1425+
14101426
static dma_addr_t mvpp2_txdesc_dma_addr_get(struct mvpp2_port *port,
14111427
struct mvpp2_tx_desc *tx_desc)
14121428
{
@@ -4442,19 +4458,19 @@ static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool,
44424458
<< MVPP22_BM_ADDR_HIGH_VIRT_RLS_SHIFT) &
44434459
MVPP22_BM_ADDR_HIGH_VIRT_RLS_MASK;
44444460

4445-
mvpp2_percpu_write(port->priv, cpu,
4446-
MVPP22_BM_ADDR_HIGH_RLS_REG, val);
4461+
mvpp2_percpu_write_relaxed(port->priv, cpu,
4462+
MVPP22_BM_ADDR_HIGH_RLS_REG, val);
44474463
}
44484464

44494465
/* MVPP2_BM_VIRT_RLS_REG is not interpreted by HW, and simply
44504466
* returned in the "cookie" field of the RX
44514467
* descriptor. Instead of storing the virtual address, we
44524468
* store the physical address
44534469
*/
4454-
mvpp2_percpu_write(port->priv, cpu,
4455-
MVPP2_BM_VIRT_RLS_REG, buf_phys_addr);
4456-
mvpp2_percpu_write(port->priv, cpu,
4457-
MVPP2_BM_PHY_RLS_REG(pool), buf_dma_addr);
4470+
mvpp2_percpu_write_relaxed(port->priv, cpu,
4471+
MVPP2_BM_VIRT_RLS_REG, buf_phys_addr);
4472+
mvpp2_percpu_write_relaxed(port->priv, cpu,
4473+
MVPP2_BM_PHY_RLS_REG(pool), buf_dma_addr);
44584474

44594475
put_cpu();
44604476
}
@@ -5546,7 +5562,8 @@ static int mvpp2_aggr_desc_num_check(struct mvpp2 *priv,
55465562
if ((aggr_txq->count + num) > MVPP2_AGGR_TXQ_SIZE) {
55475563
/* Update number of occupied aggregated Tx descriptors */
55485564
int cpu = smp_processor_id();
5549-
u32 val = mvpp2_read(priv, MVPP2_AGGR_TXQ_STATUS_REG(cpu));
5565+
u32 val = mvpp2_read_relaxed(priv,
5566+
MVPP2_AGGR_TXQ_STATUS_REG(cpu));
55505567

55515568
aggr_txq->count = val & MVPP2_AGGR_TXQ_PENDING_MASK;
55525569
}
@@ -5570,9 +5587,9 @@ static int mvpp2_txq_alloc_reserved_desc(struct mvpp2 *priv,
55705587
int cpu = smp_processor_id();
55715588

55725589
val = (txq->id << MVPP2_TXQ_RSVD_REQ_Q_OFFSET) | num;
5573-
mvpp2_percpu_write(priv, cpu, MVPP2_TXQ_RSVD_REQ_REG, val);
5590+
mvpp2_percpu_write_relaxed(priv, cpu, MVPP2_TXQ_RSVD_REQ_REG, val);
55745591

5575-
val = mvpp2_percpu_read(priv, cpu, MVPP2_TXQ_RSVD_RSLT_REG);
5592+
val = mvpp2_percpu_read_relaxed(priv, cpu, MVPP2_TXQ_RSVD_RSLT_REG);
55765593

55775594
return val & MVPP2_TXQ_RSVD_RSLT_MASK;
55785595
}
@@ -5677,8 +5694,8 @@ static inline int mvpp2_txq_sent_desc_proc(struct mvpp2_port *port,
56775694
u32 val;
56785695

56795696
/* Reading status reg resets transmitted descriptor counter */
5680-
val = mvpp2_percpu_read(port->priv, smp_processor_id(),
5681-
MVPP2_TXQ_SENT_REG(txq->id));
5697+
val = mvpp2_percpu_read_relaxed(port->priv, smp_processor_id(),
5698+
MVPP2_TXQ_SENT_REG(txq->id));
56825699

56835700
return (val & MVPP2_TRANSMITTED_COUNT_MASK) >>
56845701
MVPP2_TRANSMITTED_COUNT_OFFSET;
@@ -7044,8 +7061,8 @@ static int mvpp2_poll(struct napi_struct *napi, int budget)
70447061
*
70457062
* Each CPU has its own Rx/Tx cause register
70467063
*/
7047-
cause_rx_tx = mvpp2_percpu_read(port->priv, qv->sw_thread_id,
7048-
MVPP2_ISR_RX_TX_CAUSE_REG(port->id));
7064+
cause_rx_tx = mvpp2_percpu_read_relaxed(port->priv, qv->sw_thread_id,
7065+
MVPP2_ISR_RX_TX_CAUSE_REG(port->id));
70497066

70507067
cause_misc = cause_rx_tx & MVPP2_CAUSE_MISC_SUM_MASK;
70517068
if (cause_misc) {

0 commit comments

Comments
 (0)