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

Function vhost_enqueue_async_packed

dpdk/lib/vhost/virtio_net.c:1912–1974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1910
1911
1912static __rte_always_inline int
1913vhost_enqueue_async_packed(struct virtio_net *dev,
1914 struct vhost_virtqueue *vq,
1915 struct rte_mbuf *pkt,
1916 struct buf_vector *buf_vec,
1917 uint16_t *nr_descs,
1918 uint16_t *nr_buffers)
1919 __rte_exclusive_locks_required(&vq->access_lock)
1920 __rte_shared_locks_required(&vq->iotlb_lock)
1921{
1922 uint16_t nr_vec = 0;
1923 uint16_t avail_idx = vq->last_avail_idx;
1924 uint16_t max_tries, tries = 0;
1925 uint16_t buf_id = 0;
1926 uint32_t len = 0;
1927 uint16_t desc_count = 0;
1928 uint64_t size = pkt->pkt_len + sizeof(struct virtio_net_hdr_mrg_rxbuf);
1929 uint32_t buffer_len[vq->size];
1930 uint16_t buffer_buf_id[vq->size];
1931 uint16_t buffer_desc_count[vq->size];
1932
1933 if (rxvq_is_mergeable(dev))
1934 max_tries = vq->size - 1;
1935 else
1936 max_tries = 1;
1937
1938 do {
1939 /*
1940 * if we tried all available ring items, and still
1941 * can't get enough buf, it means something abnormal
1942 * happened.
1943 */
1944 if (unlikely(++tries > max_tries))
1945 return -1;
1946
1947 if (unlikely(fill_vec_buf_packed(dev, vq,
1948 avail_idx, &desc_count,
1949 buf_vec, &nr_vec,
1950 &buf_id, &len,
1951 VHOST_ACCESS_RW) < 0))
1952 return -1;
1953
1954 len = RTE_MIN(len, size);
1955 size -= len;
1956
1957 buffer_len[*nr_buffers] = len;
1958 buffer_buf_id[*nr_buffers] = buf_id;
1959 buffer_desc_count[*nr_buffers] = desc_count;
1960 *nr_buffers += 1;
1961 *nr_descs += desc_count;
1962 avail_idx += desc_count;
1963 if (avail_idx >= vq->size)
1964 avail_idx -= vq->size;
1965 } while (size > 0);
1966
1967 if (unlikely(mbuf_to_desc(dev, vq, pkt, buf_vec, nr_vec, *nr_buffers, true) < 0))
1968 return -1;
1969

Callers 1

Calls 4

rxvq_is_mergeableFunction · 0.85
fill_vec_buf_packedFunction · 0.85
mbuf_to_descFunction · 0.85

Tested by

no test coverage detected