The zero-copy send API supports the sending of multiple messages to different sockets in a single call. Data buffers must be allocated in advance and for best efficiency these should be allocated in blocks and off the critical path. The user should avoid simply moving the copy from Onload into the application, but where this is unavoidable, it should also be done off the critical path.
int onload_zc_send(struct onload_zc_mmsg* msgs, int mlen, int flags);
int onload_zc_alloc_buffers(int fd,
struct onload_zc_iovec* iovecs,
int iovecs_len,
onload_zc_buffer_type_flags flags);
int onload_zc_release_buffers(int fd,
onload_zc_handle* bufs,
int bufs_len);
The onload_zc_send()
function return value identifies how many of the onload_zc_mmsg
array’s rc fields are set. Each onload_zc_mmsg.rc
returns how many bytes (or error) were sent in for that message. Refer to the table below.
rc = onload_zc_send()
|
|
rc < 0
|
application error calling onload_zc_send() . rc is set to the error code |
rc == 0
|
should not happen |
0 < rc <= n_msgs
|
|
rc = mmsg[i].rc
|
|
rc < 0
|
error sending this message. rc is set to the error
code |
rc >= 0
|
rc is set to the number of bytes that have been sent in this
message. Compare to the message length to establish which buffers
sent |
Sent buffers are owned by Onload. Unsent buffers are owned by the application and must be freed or reused to avoid leaking.