MCPcopy Create free account
hub / github.com/F-Stack/f-stack / switch_worker

Function switch_worker

dpdk/examples/vhost/main.c:1480–1528  ·  view source on GitHub ↗

* Main function of vhost-switch. It basically does: * * for each vhost device { * - drain_eth_rx() * * Which drains the host eth Rx queue linked to the vhost device, * and deliver all of them to guest virito Rx ring associated with * this vhost device. * * - drain_virtio_tx() * * Which drains the guest virtio Tx queue and deliver all of them * to the targ

Source from the content-addressed store, hash-verified

1478 * }
1479 */
1480static int
1481switch_worker(void *arg __rte_unused)
1482{
1483 unsigned i;
1484 unsigned lcore_id = rte_lcore_id();
1485 struct vhost_dev *vdev;
1486 struct mbuf_table *tx_q;
1487
1488 RTE_LOG(INFO, VHOST_DATA, "Processing on Core %u started\n", lcore_id);
1489
1490 tx_q = &lcore_tx_queue[lcore_id];
1491 for (i = 0; i < rte_lcore_count(); i++) {
1492 if (lcore_ids[i] == lcore_id) {
1493 tx_q->txq_id = i;
1494 break;
1495 }
1496 }
1497
1498 while(1) {
1499 drain_mbuf_table(tx_q);
1500 drain_vhost_table();
1501 /*
1502 * Inform the configuration core that we have exited the
1503 * linked list and that no devices are in use if requested.
1504 */
1505 if (lcore_info[lcore_id].dev_removal_flag == REQUEST_DEV_REMOVAL)
1506 lcore_info[lcore_id].dev_removal_flag = ACK_DEV_REMOVAL;
1507
1508 /*
1509 * Process vhost devices
1510 */
1511 TAILQ_FOREACH(vdev, &lcore_info[lcore_id].vdev_list,
1512 lcore_vdev_entry) {
1513 if (unlikely(vdev->remove)) {
1514 unlink_vmdq(vdev);
1515 vdev->ready = DEVICE_SAFE_REMOVE;
1516 continue;
1517 }
1518
1519 if (likely(vdev->ready == DEVICE_RX))
1520 drain_eth_rx(vdev);
1521
1522 if (likely(!vdev->remove))
1523 drain_virtio_tx(vdev);
1524 }
1525 }
1526
1527 return 0;
1528}
1529
1530static void
1531vhost_clear_queue_thread_unsafe(struct vhost_dev *vdev, uint16_t queue_id)

Callers

nothing calls this directly

Calls 7

rte_lcore_idFunction · 0.85
rte_lcore_countFunction · 0.85
drain_mbuf_tableFunction · 0.85
drain_vhost_tableFunction · 0.85
unlink_vmdqFunction · 0.85
drain_eth_rxFunction · 0.85
drain_virtio_txFunction · 0.85

Tested by

no test coverage detected