示例#1
0
文件: odp_kni.c 项目: dodng/dpdk-odp
/**
 * Interface to dequeue mbufs from tx_q and burst tx
 */
static void
kni_kni_to_eth(struct kni_port_params *p)
{
	uint8_t i, port_id;
	unsigned nb_tx, num;
	uint32_t nb_kni;
	struct rte_mbuf *pkts_burst[PKT_BURST_SZ];

	if (p == NULL)
		return;

	port_id = p->port_id;

	/* Burst rx from kni */
	num = rte_kni_rx_burst(p->kni, pkts_burst, PKT_BURST_SZ);
	if (unlikely(num > PKT_BURST_SZ)) {
		RTE_LOG(ERR, APP, "Error receiving from KNI\n");
		return;
	}
	/* Burst tx to eth */
	nb_tx = rte_eth_tx_burst(port_id, 0, pkts_burst, (uint16_t)num);
	// kni_stats[port_id].tx_packets += nb_tx;

	if (unlikely(nb_tx < num)) {
		/* Free mbufs not tx to NIC */
		kni_burst_free_mbufs(&pkts_burst[nb_tx], num - nb_tx);
		// kni_stats[port_id].tx_dropped += num - nb_tx;
	}

	return;
}
示例#2
0
/**
 * Interface to dequeue mbufs from tx_q and burst tx
 */
static void
kni_egress(struct kni_port_params* p, uint32_t lcore_id)
{
	uint8_t i, port_id;
	unsigned nb_tx, num;
	uint32_t nb_kni;
	struct rte_mbuf* pkts_burst[MAX_PKT_BURST];
	uint16_t queue_num;

	if (p == NULL)
		return;

	nb_kni = p->nb_kni;
	port_id = p->port_id;
	queue_num = p->tx_queue_id;
	for (i = 0; i < nb_kni; i++) {
		/* Burst rx from kni */
		num = rte_kni_rx_burst(p->kni[i], pkts_burst, MAX_PKT_BURST);
		if (unlikely(num > MAX_PKT_BURST)) {
			RTE_LOG(ERR, KNI, "Error receiving from KNI\n");
			return;
		}
		/* Burst tx to eth */
		nb_tx = rte_eth_tx_burst(port_id, queue_num, pkts_burst,
					 (uint16_t)num);
		rte_kni_handle_request(p->kni[i]);
		stats[lcore_id].nb_kni_rx += num;
		stats[lcore_id].nb_tx += nb_tx;
		if (unlikely(nb_tx < num)) {
			/* Free mbufs not tx to NIC */
			kni_burst_free_mbufs(&pkts_burst[nb_tx], num - nb_tx);
			stats[lcore_id].nb_kni_dropped += num - nb_tx;
		}
	}
}
示例#3
0
文件: odp_kni.c 项目: dodng/dpdk-odp
static void
kni_ring_to_kni(struct kni_port_params *p)
{
	uint8_t i, port_id;
	unsigned nb_rx, num;
	struct rte_mbuf *pkts_burst[PKT_BURST_SZ];

	if (p == NULL)
		return;

	port_id = p->port_id;

	/* Burst rx from ring */
	nb_rx = rte_ring_dequeue_burst(p->ring,(void **)&pkts_burst, PKT_BURST_SZ);

	if (unlikely(nb_rx > PKT_BURST_SZ)) {
		RTE_LOG(ERR, APP, "Error receiving from eth\n");
	return;
	}

	/* Burst tx to kni */
	num = rte_kni_tx_burst(p->kni, pkts_burst, nb_rx);
	//kni_stats[port_id].rx_packets += num;

	rte_kni_handle_request(p->kni);
	if (unlikely(num < nb_rx)) {
		/* Free mbufs not tx to kni interface */
		kni_burst_free_mbufs(&pkts_burst[num], nb_rx - num);
		//kni_stats[port_id].rx_dropped += nb_rx - num;
	}

	return;
}