Skip to content

Commit b3ca9af

Browse files
VSR Burrudavem330
authored andcommitted
liquidio: optimize DMA in NUMA systems
Optimize DMA in NUMA systems by allocating memory from NUMA node that NIC is plugged in to; DMA will no longer cross NUMA nodes. If NIC IRQs are pinned to a local CPU, that CPU's access to the DMA'd data is also optimized. Signed-off-by: VSR Burru <veerasenareddy.burru@cavium.com> Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com> Signed-off-by: Raghu Vatsavayi <raghu.vatsavayi@cavium.com> Signed-off-by: Satanand Burla <satananda.burla@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent de12e4f commit b3ca9af

File tree

5 files changed

+9
-22
lines changed

5 files changed

+9
-22
lines changed

drivers/net/ethernet/cavium/liquidio/lio_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ static int setup_glists(struct octeon_device *oct, struct lio *lio, int num_iqs)
782782
}
783783

784784
for (i = 0; i < num_iqs; i++) {
785-
int numa_node = cpu_to_node(i % num_online_cpus());
785+
int numa_node = dev_to_node(&oct->pci_dev->dev);
786786

787787
spin_lock_init(&lio->glist_lock[i]);
788788

drivers/net/ethernet/cavium/liquidio/octeon_device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ int octeon_setup_instr_queues(struct octeon_device *oct)
793793
u32 num_descs = 0;
794794
u32 iq_no = 0;
795795
union oct_txpciq txpciq;
796-
int numa_node = cpu_to_node(iq_no % num_online_cpus());
796+
int numa_node = dev_to_node(&oct->pci_dev->dev);
797797

798798
if (OCTEON_CN6XXX(oct))
799799
num_descs =
@@ -837,7 +837,7 @@ int octeon_setup_output_queues(struct octeon_device *oct)
837837
u32 num_descs = 0;
838838
u32 desc_size = 0;
839839
u32 oq_no = 0;
840-
int numa_node = cpu_to_node(oq_no % num_online_cpus());
840+
int numa_node = dev_to_node(&oct->pci_dev->dev);
841841

842842
if (OCTEON_CN6XXX(oct)) {
843843
num_descs =

drivers/net/ethernet/cavium/liquidio/octeon_droq.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ int octeon_init_droq(struct octeon_device *oct,
234234
struct octeon_droq *droq;
235235
u32 desc_ring_size = 0, c_num_descs = 0, c_buf_size = 0;
236236
u32 c_pkts_per_intr = 0, c_refill_threshold = 0;
237-
int orig_node = dev_to_node(&oct->pci_dev->dev);
238-
int numa_node = cpu_to_node(q_no % num_online_cpus());
237+
int numa_node = dev_to_node(&oct->pci_dev->dev);
239238

240239
dev_dbg(&oct->pci_dev->dev, "%s[%d]\n", __func__, q_no);
241240

@@ -275,13 +274,8 @@ int octeon_init_droq(struct octeon_device *oct,
275274
droq->buffer_size = c_buf_size;
276275

277276
desc_ring_size = droq->max_count * OCT_DROQ_DESC_SIZE;
278-
set_dev_node(&oct->pci_dev->dev, numa_node);
279277
droq->desc_ring = lio_dma_alloc(oct, desc_ring_size,
280278
(dma_addr_t *)&droq->desc_ring_dma);
281-
set_dev_node(&oct->pci_dev->dev, orig_node);
282-
if (!droq->desc_ring)
283-
droq->desc_ring = lio_dma_alloc(oct, desc_ring_size,
284-
(dma_addr_t *)&droq->desc_ring_dma);
285279

286280
if (!droq->desc_ring) {
287281
dev_err(&oct->pci_dev->dev,
@@ -983,7 +977,7 @@ int octeon_create_droq(struct octeon_device *oct,
983977
u32 desc_size, void *app_ctx)
984978
{
985979
struct octeon_droq *droq;
986-
int numa_node = cpu_to_node(q_no % num_online_cpus());
980+
int numa_node = dev_to_node(&oct->pci_dev->dev);
987981

988982
if (oct->droq[q_no]) {
989983
dev_dbg(&oct->pci_dev->dev, "Droq already in use. Cannot create droq %d again\n",

drivers/net/ethernet/cavium/liquidio/octeon_iq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ struct octeon_instr_queue {
152152
struct oct_iq_stats stats;
153153

154154
/** DMA mapped base address of the input descriptor ring. */
155-
u64 base_addr_dma;
155+
dma_addr_t base_addr_dma;
156156

157157
/** Application context */
158158
void *app_ctx;

drivers/net/ethernet/cavium/liquidio/request_manager.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ int octeon_init_instr_queue(struct octeon_device *oct,
6262
u32 iq_no = (u32)txpciq.s.q_no;
6363
u32 q_size;
6464
struct cavium_wq *db_wq;
65-
int orig_node = dev_to_node(&oct->pci_dev->dev);
66-
int numa_node = cpu_to_node(iq_no % num_online_cpus());
65+
int numa_node = dev_to_node(&oct->pci_dev->dev);
6766

6867
if (OCTEON_CN6XXX(oct))
6968
conf = &(CFG_GET_IQ_CFG(CHIP_CONF(oct, cn6xxx)));
@@ -91,13 +90,7 @@ int octeon_init_instr_queue(struct octeon_device *oct,
9190

9291
iq->oct_dev = oct;
9392

94-
set_dev_node(&oct->pci_dev->dev, numa_node);
95-
iq->base_addr = lio_dma_alloc(oct, q_size,
96-
(dma_addr_t *)&iq->base_addr_dma);
97-
set_dev_node(&oct->pci_dev->dev, orig_node);
98-
if (!iq->base_addr)
99-
iq->base_addr = lio_dma_alloc(oct, q_size,
100-
(dma_addr_t *)&iq->base_addr_dma);
93+
iq->base_addr = lio_dma_alloc(oct, q_size, &iq->base_addr_dma);
10194
if (!iq->base_addr) {
10295
dev_err(&oct->pci_dev->dev, "Cannot allocate memory for instr queue %d\n",
10396
iq_no);
@@ -211,7 +204,7 @@ int octeon_setup_iq(struct octeon_device *oct,
211204
void *app_ctx)
212205
{
213206
u32 iq_no = (u32)txpciq.s.q_no;
214-
int numa_node = cpu_to_node(iq_no % num_online_cpus());
207+
int numa_node = dev_to_node(&oct->pci_dev->dev);
215208

216209
if (oct->instr_queue[iq_no]) {
217210
dev_dbg(&oct->pci_dev->dev, "IQ is in use. Cannot create the IQ: %d again\n",

0 commit comments

Comments
 (0)