| 279 | } |
| 280 | |
| 281 | static inline int |
| 282 | virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf **cookie, |
| 283 | uint16_t num) |
| 284 | { |
| 285 | struct vq_desc_extra *dxp; |
| 286 | struct virtio_hw *hw = vq->hw; |
| 287 | struct vring_desc *start_dp = vq->vq_split.ring.desc; |
| 288 | uint16_t idx, i; |
| 289 | |
| 290 | if (unlikely(vq->vq_free_cnt == 0)) |
| 291 | return -ENOSPC; |
| 292 | if (unlikely(vq->vq_free_cnt < num)) |
| 293 | return -EMSGSIZE; |
| 294 | |
| 295 | if (unlikely(vq->vq_desc_head_idx >= vq->vq_nentries)) |
| 296 | return -EFAULT; |
| 297 | |
| 298 | for (i = 0; i < num; i++) { |
| 299 | idx = vq->vq_desc_head_idx; |
| 300 | dxp = &vq->vq_descx[idx]; |
| 301 | dxp->cookie = (void *)cookie[i]; |
| 302 | dxp->ndescs = 1; |
| 303 | |
| 304 | start_dp[idx].addr = VIRTIO_MBUF_ADDR(cookie[i], vq) + |
| 305 | RTE_PKTMBUF_HEADROOM - hw->vtnet_hdr_size; |
| 306 | start_dp[idx].len = cookie[i]->buf_len - RTE_PKTMBUF_HEADROOM + |
| 307 | hw->vtnet_hdr_size; |
| 308 | start_dp[idx].flags = VRING_DESC_F_WRITE; |
| 309 | vq->vq_desc_head_idx = start_dp[idx].next; |
| 310 | vq_update_avail_ring(vq, idx); |
| 311 | if (vq->vq_desc_head_idx == VQ_RING_DESC_CHAIN_END) { |
| 312 | vq->vq_desc_tail_idx = vq->vq_desc_head_idx; |
| 313 | break; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | vq->vq_free_cnt = (uint16_t)(vq->vq_free_cnt - num); |
| 318 | |
| 319 | return 0; |
| 320 | } |
| 321 | |
| 322 | static inline void |
| 323 | virtqueue_refill_single_packed(struct virtqueue *vq, |
no test coverage detected