for (i = 0; i < num_tuples; i++) {
pt = &pdump_t[i];
- if (pt->device_id)
- free(pt->device_id);
+ free(pt->device_id);
/* free the rings */
- if (pt->rx_ring)
- rte_ring_free(pt->rx_ring);
- if (pt->tx_ring)
- rte_ring_free(pt->tx_ring);
+ rte_ring_free(pt->rx_ring);
+ rte_ring_free(pt->tx_ring);
+ rte_mempool_free(pt->mp);
}
}
printf("Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
- port_id,
- addr.addr_bytes[0], addr.addr_bytes[1],
- addr.addr_bytes[2], addr.addr_bytes[3],
- addr.addr_bytes[4], addr.addr_bytes[5]);
+ port_id, RTE_ETHER_ADDR_BYTES(&addr));
ret = rte_eth_promiscuous_enable(port_id);
if (ret != 0) {
return 0;
}
+static unsigned int
+get_next_core(unsigned int lcore)
+{
+ lcore = rte_get_next_lcore(lcore, 1, 0);
+ if (lcore == RTE_MAX_LCORE)
+ rte_exit(EXIT_FAILURE,
+ "Max core limit %u reached for packet capture", lcore);
+ return lcore;
+}
+
static inline void
dump_packets(void)
{
int i;
- uint32_t lcore_id = 0;
+ unsigned int lcore_id = 0;
if (!multiple_core_capture) {
printf(" core (%u), capture for (%d) tuples\n",
return;
}
- lcore_id = rte_get_next_lcore(lcore_id, 1, 0);
+ lcore_id = get_next_core(lcore_id);
for (i = 0; i < num_tuples; i++) {
rte_eal_remote_launch(dump_packets_core,
&pdump_t[i], lcore_id);
- lcore_id = rte_get_next_lcore(lcore_id, 1, 0);
+ lcore_id = get_next_core(lcore_id);
if (rte_eal_wait_lcore(lcore_id) < 0)
rte_exit(EXIT_FAILURE, "failed to wait\n");