diff options
author | Yan Markman <ymarkman@marvell.com> | 2018-03-27 10:49:05 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-03-27 13:15:36 -0400 |
commit | cdcfeb0fb473e34e012b9a78b5cb377a6ad1434d (patch) | |
tree | 9a69f96db489cdc284532df1fd14e18c79499b24 | |
parent | 5f75a1863eb737bc99e3ef3a5fbf9e7207775b97 (diff) |
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 <ymarkman@marvell.com>
[Maxime: Commit message, cosmetic changes]
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/marvell/mvpp2.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index 7075e5ab78f3..7fc1bbf51c44 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c | |||
@@ -1359,6 +1359,10 @@ static u32 mvpp2_read(struct mvpp2 *priv, u32 offset) | |||
1359 | return readl(priv->swth_base[0] + offset); | 1359 | return readl(priv->swth_base[0] + offset); |
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | static u32 mvpp2_read_relaxed(struct mvpp2 *priv, u32 offset) | ||
1363 | { | ||
1364 | return readl_relaxed(priv->swth_base[0] + offset); | ||
1365 | } | ||
1362 | /* These accessors should be used to access: | 1366 | /* These accessors should be used to access: |
1363 | * | 1367 | * |
1364 | * - per-CPU registers, where each CPU has its own copy of the | 1368 | * - 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, | |||
1407 | return readl(priv->swth_base[cpu] + offset); | 1411 | return readl(priv->swth_base[cpu] + offset); |
1408 | } | 1412 | } |
1409 | 1413 | ||
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 | |||
1410 | static dma_addr_t mvpp2_txdesc_dma_addr_get(struct mvpp2_port *port, | 1426 | static dma_addr_t mvpp2_txdesc_dma_addr_get(struct mvpp2_port *port, |
1411 | struct mvpp2_tx_desc *tx_desc) | 1427 | struct mvpp2_tx_desc *tx_desc) |
1412 | { | 1428 | { |
@@ -4442,8 +4458,8 @@ static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool, | |||
4442 | << MVPP22_BM_ADDR_HIGH_VIRT_RLS_SHIFT) & | 4458 | << MVPP22_BM_ADDR_HIGH_VIRT_RLS_SHIFT) & |
4443 | MVPP22_BM_ADDR_HIGH_VIRT_RLS_MASK; | 4459 | MVPP22_BM_ADDR_HIGH_VIRT_RLS_MASK; |
4444 | 4460 | ||
4445 | mvpp2_percpu_write(port->priv, cpu, | 4461 | mvpp2_percpu_write_relaxed(port->priv, cpu, |
4446 | MVPP22_BM_ADDR_HIGH_RLS_REG, val); | 4462 | MVPP22_BM_ADDR_HIGH_RLS_REG, val); |
4447 | } | 4463 | } |
4448 | 4464 | ||
4449 | /* MVPP2_BM_VIRT_RLS_REG is not interpreted by HW, and simply | 4465 | /* MVPP2_BM_VIRT_RLS_REG is not interpreted by HW, and simply |
@@ -4451,10 +4467,10 @@ static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool, | |||
4451 | * descriptor. Instead of storing the virtual address, we | 4467 | * descriptor. Instead of storing the virtual address, we |
4452 | * store the physical address | 4468 | * store the physical address |
4453 | */ | 4469 | */ |
4454 | mvpp2_percpu_write(port->priv, cpu, | 4470 | mvpp2_percpu_write_relaxed(port->priv, cpu, |
4455 | MVPP2_BM_VIRT_RLS_REG, buf_phys_addr); | 4471 | MVPP2_BM_VIRT_RLS_REG, buf_phys_addr); |
4456 | mvpp2_percpu_write(port->priv, cpu, | 4472 | mvpp2_percpu_write_relaxed(port->priv, cpu, |
4457 | MVPP2_BM_PHY_RLS_REG(pool), buf_dma_addr); | 4473 | MVPP2_BM_PHY_RLS_REG(pool), buf_dma_addr); |
4458 | 4474 | ||
4459 | put_cpu(); | 4475 | put_cpu(); |
4460 | } | 4476 | } |
@@ -5546,7 +5562,8 @@ static int mvpp2_aggr_desc_num_check(struct mvpp2 *priv, | |||
5546 | if ((aggr_txq->count + num) > MVPP2_AGGR_TXQ_SIZE) { | 5562 | if ((aggr_txq->count + num) > MVPP2_AGGR_TXQ_SIZE) { |
5547 | /* Update number of occupied aggregated Tx descriptors */ | 5563 | /* Update number of occupied aggregated Tx descriptors */ |
5548 | int cpu = smp_processor_id(); | 5564 | 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)); | ||
5550 | 5567 | ||
5551 | aggr_txq->count = val & MVPP2_AGGR_TXQ_PENDING_MASK; | 5568 | aggr_txq->count = val & MVPP2_AGGR_TXQ_PENDING_MASK; |
5552 | } | 5569 | } |
@@ -5570,9 +5587,9 @@ static int mvpp2_txq_alloc_reserved_desc(struct mvpp2 *priv, | |||
5570 | int cpu = smp_processor_id(); | 5587 | int cpu = smp_processor_id(); |
5571 | 5588 | ||
5572 | val = (txq->id << MVPP2_TXQ_RSVD_REQ_Q_OFFSET) | num; | 5589 | 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); |
5574 | 5591 | ||
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); |
5576 | 5593 | ||
5577 | return val & MVPP2_TXQ_RSVD_RSLT_MASK; | 5594 | return val & MVPP2_TXQ_RSVD_RSLT_MASK; |
5578 | } | 5595 | } |
@@ -5677,8 +5694,8 @@ static inline int mvpp2_txq_sent_desc_proc(struct mvpp2_port *port, | |||
5677 | u32 val; | 5694 | u32 val; |
5678 | 5695 | ||
5679 | /* Reading status reg resets transmitted descriptor counter */ | 5696 | /* Reading status reg resets transmitted descriptor counter */ |
5680 | val = mvpp2_percpu_read(port->priv, smp_processor_id(), | 5697 | val = mvpp2_percpu_read_relaxed(port->priv, smp_processor_id(), |
5681 | MVPP2_TXQ_SENT_REG(txq->id)); | 5698 | MVPP2_TXQ_SENT_REG(txq->id)); |
5682 | 5699 | ||
5683 | return (val & MVPP2_TRANSMITTED_COUNT_MASK) >> | 5700 | return (val & MVPP2_TRANSMITTED_COUNT_MASK) >> |
5684 | MVPP2_TRANSMITTED_COUNT_OFFSET; | 5701 | MVPP2_TRANSMITTED_COUNT_OFFSET; |
@@ -7044,8 +7061,8 @@ static int mvpp2_poll(struct napi_struct *napi, int budget) | |||
7044 | * | 7061 | * |
7045 | * Each CPU has its own Rx/Tx cause register | 7062 | * Each CPU has its own Rx/Tx cause register |
7046 | */ | 7063 | */ |
7047 | cause_rx_tx = mvpp2_percpu_read(port->priv, qv->sw_thread_id, | 7064 | cause_rx_tx = mvpp2_percpu_read_relaxed(port->priv, qv->sw_thread_id, |
7048 | MVPP2_ISR_RX_TX_CAUSE_REG(port->id)); | 7065 | MVPP2_ISR_RX_TX_CAUSE_REG(port->id)); |
7049 | 7066 | ||
7050 | cause_misc = cause_rx_tx & MVPP2_CAUSE_MISC_SUM_MASK; | 7067 | cause_misc = cause_rx_tx & MVPP2_CAUSE_MISC_SUM_MASK; |
7051 | if (cause_misc) { | 7068 | if (cause_misc) { |