Zero-Copy Data Buffers

Onload User Guide (UG1586)

Document ID
UG1586
Release Date
2023-07-31
Revision
1.2 English

To avoid the copy data is passed to and from the application in special buffers described by a struct onload_zc_iovec. A message or datagram can consist of multiple iovecs using a struct onload_zc_msg. A single call to send can involve multiple messages using an array of struct onload_zc_mmsg.

Figure 1. Zero-Copy Data Buffers
/* A zc_iovec describes a single buffer */
struct onload_zc_iovec {
  void* iov_base;                /* Address within buffer */
  size_t iov_len;                /* Length of data */
  onload_zc_handle buf;          /* (opaque) buffer handle */
  unsigned iov_flags;            /* Not currently used */
};
/* A msg describes array of iovecs that make up datagram */
struct onload_zc_msg {
  struct onload_zc_iovec* iov;   /* Array of buffers */
  struct msghdr msghdr;          /* Message metadata */
};
/* An mmsg describes a message, the socket, and its result */
struct onload_zc_mmsg {
  struct onload_zc_msg msg;      /* Message */
  int rc;                        /* Result of send operation */
  int fd;                        /* socket to send on */
};