onload_get_tcp_info - UG1586

Onload User Guide (UG1586)

Document ID
UG1586
Release Date
2025-11-03
Revision
1.31 English

Description

Gets a structure similar to Linux tcp_info for a file descriptor that refers to an accelerated TCP connection.

Definition

int onload_get_tcp_info(int fd, struct onload_tcp_info* info, int* len_in_out);

Formal Parameters

fd
The file descriptor for which to get information. This must refer to an accelerated TCP connection.
info
A pointer to the structure into which to get the information.
len_in_out

The size of memory available for the info pointer. The function call updates this with the size of memory that was updated.

This parameter is used for versioning, to allow the onload_tcp_info structure to be extended in future. You should set it to sizeof(onload_tcp_info) to ensure that the returned data is the version that you expect.

Return Value

0 on success.

-EINVAL for a file descriptor that does not refer to an accelerated TCP connection.

Notes

The onload_tcp_info structure has the following definition:

struct onload_tcp_info {
  /* Receive buffer and its current use */
  int so_recvbuf;
  int rcvbuf_used;
  int rcv_window;
  /* Send buffer and its current use */
  int so_sndbuf;
  int so_sndbuf_pkts;
  int sndbuf_pkts_avail;
  int snd_mss;
  /* Send windows */
  int snd_window;
  int cong_window;
};

The first set of fields give information about the receive buffer and its current use:

so_recvbuf ≅ rcvbuf_used + rcv_window

  • so_recvbuf is also available via getsockopt(SO_RCVBUF).
  • rcvbuf_used is also available via ioctl(FIONREAD), but ignoring SO_OOBINLINE complexity (so the number of bytes in the receive queue, urgent or not).
  • rcv_window is also available via getsockopt(TCP_INFO), tcpi_rcv_space.

The next set of fields give information about the send buffer and its current use:

so_sndbuf ≅ so_sndbuf_pkts × snd_mss

  • so_sndbuf is also available via getsockopt(SO_SNDBUF).
  • so_sndbuf_pkts is the packet limit used for the send queue by Onload internally, calculated from the user-supplied SO_SNDBUF value.
  • sndbuf_pkts_avail is the number of packets could currently be added to the send queue.
  • snd_mss is also available as getsockopt(TCP_INFO), tcpi_snd_mss.

The final set of fields give information about the send windows:

  • snd_window is the window size obtained from the network peer. It is the same as the send_wnd value in onload_delegated_send().
  • cong_window is the current congestion window, that is the size of data allowed to be sent to the network by the TCP congestion control protocol in use. It is the same as the cong_wnd value in onload_delegated_send().