Skip to content

Commit 257bb98

Browse files
committed
less arp ring
1 parent 85aab0a commit 257bb98

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

lib/ff_dpdk_if.c

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static struct lcore_conf lcore_conf;
162162

163163
static struct rte_mempool *pktmbuf_pool[NB_SOCKETS];
164164

165-
static struct rte_ring **arp_ring[RTE_MAX_LCORE];
165+
static struct rte_ring **arp_ring[RTE_MAX_ETHPORTS];
166166

167167
static uint16_t rss_reta_size[RTE_MAX_ETHPORTS];
168168

@@ -420,43 +420,40 @@ create_ring(const char *name, unsigned count, int socket_id, unsigned flags)
420420
static int
421421
init_arp_ring(void)
422422
{
423-
int i, j, ret;
423+
int j;
424424
char name_buf[RTE_RING_NAMESIZE];
425-
int nb_procs = ff_global_cfg.dpdk.nb_procs;
426-
int proc_id = ff_global_cfg.dpdk.proc_id;
427-
428-
/* Allocate arp ring ptr according to eth dev count. */
429-
int nb_dev_ports = rte_eth_dev_count();
430-
for(i = 0; i < nb_procs; ++i) {
431-
snprintf(name_buf, RTE_RING_NAMESIZE, "ring_ptr_%d_%d",
432-
proc_id, i);
433-
434-
arp_ring[i] = rte_zmalloc(name_buf,
435-
sizeof(struct rte_ring *) * nb_dev_ports,
436-
RTE_CACHE_LINE_SIZE);
437-
if (arp_ring[i] == NULL) {
438-
rte_exit(EXIT_FAILURE, "rte_zmalloc(%s (struct rte_ring*)) "
439-
"failed\n", name_buf);
440-
}
441-
}
425+
int queueid;
442426

443427
unsigned socketid = lcore_conf.socket_id;
444428

445429
/* Create ring according to ports actually being used. */
446430
int nb_ports = ff_global_cfg.dpdk.nb_ports;
447431
for (j = 0; j < nb_ports; j++) {
448-
uint16_t port_id = ff_global_cfg.dpdk.portid_list[j];
432+
uint16_t portid = ff_global_cfg.dpdk.portid_list[j];
433+
struct ff_port_cfg *pconf = &ff_global_cfg.dpdk.port_cfgs[portid];
434+
int nb_queues = pconf->nb_lcores;
435+
if (arp_ring[portid] == NULL) {
436+
snprintf(name_buf, RTE_RING_NAMESIZE, "ring_ptr_p%d", portid);
437+
438+
arp_ring[portid] = rte_zmalloc(name_buf,
439+
sizeof(struct rte_ring *) * nb_queues,
440+
RTE_CACHE_LINE_SIZE);
441+
if (arp_ring[portid] == NULL) {
442+
rte_exit(EXIT_FAILURE, "rte_zmalloc(%s (struct rte_ring*)) "
443+
"failed\n", name_buf);
444+
}
445+
}
449446

450-
for(i = 0; i < nb_procs; ++i) {
451-
snprintf(name_buf, RTE_RING_NAMESIZE, "arp_ring_%d_%d", i, port_id);
452-
arp_ring[i][port_id] = create_ring(name_buf, ARP_RING_SIZE,
447+
for(queueid = 0; queueid < nb_queues; ++queueid) {
448+
snprintf(name_buf, RTE_RING_NAMESIZE, "arp_ring_p%d_q%d", portid, queueid);
449+
arp_ring[portid][queueid] = create_ring(name_buf, ARP_RING_SIZE,
453450
socketid, RING_F_SC_DEQ);
454451

455-
if (arp_ring[i][port_id] == NULL)
452+
if (arp_ring[portid][queueid] == NULL)
456453
rte_panic("create ring:%s failed!\n", name_buf);
457454

458455
printf("create ring:%s success, %u ring entries are now free!\n",
459-
name_buf, rte_ring_free_count(arp_ring[i][port_id]));
456+
name_buf, rte_ring_free_count(arp_ring[portid][queueid]));
460457
}
461458
}
462459

@@ -931,7 +928,7 @@ process_packets(uint8_t port_id, uint16_t queue_id, struct rte_mbuf **bufs,
931928
mbuf_pool = pktmbuf_pool[socket_id];
932929
mbuf_clone = rte_pktmbuf_clone(rtem, mbuf_pool);
933930
if(mbuf_clone) {
934-
int ret = rte_ring_enqueue(arp_ring[i][port_id], mbuf_clone);
931+
int ret = rte_ring_enqueue(arp_ring[port_id][i], mbuf_clone);
935932
if (ret < 0)
936933
rte_pktmbuf_free(mbuf_clone);
937934
}
@@ -962,7 +959,7 @@ process_arp_ring(uint8_t port_id, uint16_t queue_id,
962959
{
963960
/* read packet from ring buf and to process */
964961
uint16_t nb_rb;
965-
nb_rb = rte_ring_dequeue_burst(arp_ring[queue_id][port_id],
962+
nb_rb = rte_ring_dequeue_burst(arp_ring[port_id][queue_id],
966963
(void **)pkts_burst, MAX_PKT_BURST);
967964

968965
if(nb_rb > 0) {

0 commit comments

Comments
 (0)