| 378 | } |
| 379 | |
| 380 | static int |
| 381 | virtio_rxq_sw_ring_alloc(struct virtqueue *vq, int numa_node) |
| 382 | { |
| 383 | void *sw_ring; |
| 384 | struct rte_mbuf *mbuf; |
| 385 | size_t size; |
| 386 | |
| 387 | /* SW ring is only used with vectorized datapath */ |
| 388 | if (!vq->hw->use_vec_rx) |
| 389 | return 0; |
| 390 | |
| 391 | size = (RTE_PMD_VIRTIO_RX_MAX_BURST + vq->vq_nentries) * sizeof(vq->rxq.sw_ring[0]); |
| 392 | |
| 393 | sw_ring = rte_zmalloc_socket("sw_ring", size, RTE_CACHE_LINE_SIZE, numa_node); |
| 394 | if (!sw_ring) { |
| 395 | PMD_INIT_LOG(ERR, "can not allocate RX soft ring"); |
| 396 | return -ENOMEM; |
| 397 | } |
| 398 | |
| 399 | mbuf = rte_zmalloc_socket("sw_ring", sizeof(*mbuf), RTE_CACHE_LINE_SIZE, numa_node); |
| 400 | if (!mbuf) { |
| 401 | PMD_INIT_LOG(ERR, "can not allocate fake mbuf"); |
| 402 | rte_free(sw_ring); |
| 403 | return -ENOMEM; |
| 404 | } |
| 405 | |
| 406 | vq->rxq.sw_ring = sw_ring; |
| 407 | vq->rxq.fake_mbuf = mbuf; |
| 408 | |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | static void |
| 413 | virtio_rxq_sw_ring_free(struct virtqueue *vq) |
no test coverage detected