Skip to content

Commit

Permalink
lib/virtio: change flags to match specification
Browse files Browse the repository at this point in the history
Update flags to match specification. Also change the value as an offset
in flags instead of it being an offset in second 64 bit of VirtIO
descriptor.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Change-Id: I768d0473eb98dd6524bad2b996cd93950bf42341
Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpu-offload/+/140842
Tested-by: sa_ip-toolkits-Jenkins <sa_ip-toolkits-jenkins@marvell.com>
Reviewed-by: Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>
  • Loading branch information
Akhil Goyal authored and jerinjacobk committed Dec 5, 2024
1 parent f86c6b1 commit 694aed7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions lib/virtio/spec/virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@
#define VIRTIO_F_NOTIFICATION_DATA 38

/** This marks a buffer as continuing via the next field. */
#define VRING_DESC_F_NEXT 48
#define VRING_DESC_F_NEXT 1
/** This marks a buffer as write-only (otherwise read-only). */
#define VRING_DESC_F_WRITE 50
#define VRING_DESC_F_WRITE 2
/** This means the buffer contains a list of buffer descriptors. */
#define VRING_DESC_F_INDIRECT 52
/** This flag means the descriptor was made available by the driver */
#define VIRT_PACKED_RING_DESC_F_AVAIL (1UL << 55)
/** This flag means the descriptor was used by the device */
#define VIRT_PACKED_RING_DESC_F_USED (1UL << 63)
#define VRING_DESC_F_INDIRECT 4

/* This flag means the descriptor was made available by the driver */
#define VRING_PACKED_DESC_F_AVAIL (1UL << 7)
/* This flag means the descriptor was used by the device */
#define VRING_PACKED_DESC_F_USED (1UL << 15)

/* Flags to be used when working with second uint64_t in the VirtIO descriptor. */
#define VIRT_PACKED_RING_DESC_F_AVAIL (VRING_PACKED_DESC_F_AVAIL << 48)
#define VIRT_PACKED_RING_DESC_F_USED (VRING_PACKED_DESC_F_USED << 48)
#define VIRT_PACKED_RING_DESC_F_AVAIL_USED \
(VIRT_PACKED_RING_DESC_F_AVAIL | VIRT_PACKED_RING_DESC_F_USED)

Expand Down
4 changes: 2 additions & 2 deletions lib/virtio_net/virtio_net_deq.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ post_process_pkts(struct virtio_net_queue *q, struct rte_mbuf **d_mbufs, uint16_
rte_prefetch0((uint8_t *)mbuf_arr[last_off + 1] + data_off);
mbuf0 = mbuf_arr[last_off];

dflags = (*DESC_PTR_OFF(desc_base, last_off, 8) >> VRING_DESC_F_NEXT) & 0x1;
dflags = (*DESC_PTR_OFF(desc_base, last_off, 8) >> 48) & VRING_DESC_F_NEXT;

mbuf1 = mbuf0;
off = last_off;

/* Calculate additional segments required for mbuf-chain */
while (unlikely(dflags)) {
off = (off + 1) & (q_sz - 1);
dflags = (*DESC_PTR_OFF(desc_base, off, 8) >> VRING_DESC_F_NEXT) & 0x1;
dflags = (*DESC_PTR_OFF(desc_base, off, 8) >> 48) & VRING_DESC_F_NEXT;
segs++;
}

Expand Down

0 comments on commit 694aed7

Please sign in to comment.