src/dpdk/drivers/net/pcap/rte_eth_pcap.c
static uint16_t
eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
{
	unsigned int i;
	int ret;
	struct rte_mbuf *mbuf;
	struct pmd_process_private *pp;
	struct pcap_tx_queue *tx_queue = queue;
	uint16_t num_tx = 0;
	uint32_t tx_bytes = 0;
	pcap_t *pcap;
	unsigned char temp_data[RTE_ETH_PCAP_SNAPLEN];
	size_t len;

	pp = rte_eth_devices[tx_queue->port_id].process_private;
	pcap = pp->tx_pcap[tx_queue->queue_id];

	if (unlikely(nb_pkts == 0 || pcap == NULL))
		return 0;

	for (i = 0; i < nb_pkts; i++) {
		mbuf = bufs[i];
		len = rte_pktmbuf_pkt_len(mbuf);
		if (unlikely(!rte_pktmbuf_is_contiguous(mbuf) &&
				len > sizeof(temp_data))) {
			PMD_LOG(ERR,
				"Dropping multi segment PCAP packet. Size (%zd) > max size (%zd).",
				len, sizeof(temp_data));
			rte_pktmbuf_free(mbuf);
			continue;
		}

		/* rte_pktmbuf_read() returns a pointer to the data directly
		 * in the mbuf (when the mbuf is contiguous) or, otherwise,
		 * a pointer to temp_data after copying into it.
		 */
		ret = pcap_sendpacket(pcap,
			rte_pktmbuf_read(mbuf, 0, len, temp_data), len);
		if (unlikely(ret != 0))
			break;
		num_tx++;
		tx_bytes += len;
		rte_pktmbuf_free(mbuf);
	}

	tx_queue->tx_stat.pkts += num_tx;
	tx_queue->tx_stat.bytes += tx_bytes;
	tx_queue->tx_stat.err_pkts += i - num_tx;

	return i;
}
/*
 * Callback to handle sending packets through a real NIC.
 */
Callback to handle sending packets through a real NIC.
Callback to handle sending packets through a real NIC .
static uint16_t
eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
{
	unsigned int i;
	int ret;
	struct rte_mbuf *mbuf;
	struct pmd_process_private *pp;
	struct pcap_tx_queue *tx_queue = queue;
	uint16_t num_tx = 0;
	uint32_t tx_bytes = 0;
	pcap_t *pcap;
	unsigned char temp_data[RTE_ETH_PCAP_SNAPLEN];
	size_t len;
	pp = rte_eth_devices[tx_queue->port_id].process_private;
	pcap = pp->tx_pcap[tx_queue->queue_id];
	if (unlikely(nb_pkts == 0 || pcap == NULL))
		return 0;
	for (i = 0; i < nb_pkts; i++) {
		mbuf = bufs[i];
		len = rte_pktmbuf_pkt_len(mbuf);
		if (unlikely(!rte_pktmbuf_is_contiguous(mbuf) &&
				len > sizeof(temp_data))) {
			PMD_LOG(ERR,
				"Dropping multi segment PCAP packet. Size (%zd) > max size (%zd).",
				len, sizeof(temp_data));
			rte_pktmbuf_free(mbuf);
			continue;
		}
		ret = pcap_sendpacket(pcap,
			rte_pktmbuf_read(mbuf, 0, len, temp_data), len);
		if (unlikely(ret != 0))
			break;
		num_tx++;
		tx_bytes += len;
		rte_pktmbuf_free(mbuf);
	}
	tx_queue->tx_stat.pkts += num_tx;
	tx_queue->tx_stat.bytes += tx_bytes;
	tx_queue->tx_stat.err_pkts += i - num_tx;
	return i;
}
static uint16_t eth_pcap_tx ( void * queue , struct rte_mbuf * * bufs , uint16_t nb_pkts ) { unsigned int i ; int ret ; struct rte_mbuf * mbuf ; struct pmd_process_private * pp ; struct pcap_tx_queue * tx_queue = queue ; uint16_t num_tx = 0 ; uint32_t tx_bytes = 0 ; pcap_t * pcap ; unsigned char temp_data [ RTE_ETH_PCAP_SNAPLEN ] ; size_t len ; pp = rte_eth_devices [ tx_queue -> port_id ] . process_private ; pcap = pp -> tx_pcap [ tx_queue -> queue_id ] ; if ( unlikely ( nb_pkts == 0 || pcap == NULL ) ) return 0 ; for ( i = 0 ; i < nb_pkts ; i ++ ) { mbuf = bufs [ i ] ; len = rte_pktmbuf_pkt_len ( mbuf ) ; if ( unlikely ( ! rte_pktmbuf_is_contiguous ( mbuf ) && len > sizeof ( temp_data ) ) ) { PMD_LOG ( ERR , " " , len , sizeof ( temp_data ) ) ; rte_pktmbuf_free ( mbuf ) ; continue ; } ret = pcap_sendpacket ( pcap , rte_pktmbuf_read ( mbuf , 0 , len , temp_data ) , len ) ; if ( unlikely ( ret != 0 ) ) break ; num_tx ++ ; tx_bytes += len ; rte_pktmbuf_free ( mbuf ) ; } tx_queue -> tx_stat . pkts += num_tx ; tx_queue -> tx_stat . bytes += tx_bytes ; tx_queue -> tx_stat . err_pkts += i - num_tx ; return i ; }
Callback to handle sending packets through a real NIC.
Callback to handle sending packets through a real NIC .
/* rte_pktmbuf_read() returns a pointer to the data directly
		 * in the mbuf (when the mbuf is contiguous) or, otherwise,
		 * a pointer to temp_data after copying into it.
		 */