Skip to content

Commit

Permalink
issue: 1792164 Introduce flags to process zero copy send
Browse files Browse the repository at this point in the history
There flags are added:
VMA_TX_PACKET_ZEROCOPY - to use on sockinfo/dst_entry layers
TCP_WRITE_ZEROCOPY - to use inside lwip tcp_write
TF_SEG_OPTS_ZEROCOPY - to mark tcp segment with zero copy attribute

Signed-off-by: Igor Ivanov <[email protected]>
  • Loading branch information
igor-ivanov committed Jun 11, 2020
1 parent a99fbf2 commit 687271f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/vma/lwip/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ err_t tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx);
#define TCP_WRITE_DUMMY 0x10
#define TCP_WRITE_TSO 0x20
#define TCP_WRITE_FILE 0x40
#define TCP_WRITE_ZEROCOPY 0x80

err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u32_t len,
u8_t apiflags);
Expand Down
1 change: 1 addition & 0 deletions src/vma/lwip/tcp_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ struct tcp_seg {
#define TF_SEG_OPTS_WNDSCALE (u8_t)0x08U /* Include window scaling option */
#define TF_SEG_OPTS_DUMMY_MSG (u8_t)TCP_WRITE_DUMMY /* Include dummy send option */
#define TF_SEG_OPTS_TSO (u8_t)TCP_WRITE_TSO /* Use TSO send mode */
#define TF_SEG_OPTS_ZEROCOPY (u8_t)TCP_WRITE_ZEROCOPY /* Use zerocopy send mode */

struct tcp_hdr *tcphdr; /* the TCP header */
};
Expand Down
5 changes: 5 additions & 0 deletions src/vma/proto/dst_entry_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ ssize_t dst_entry_tcp::fast_send(const iovec* p_iov, const ssize_t sz_iov, vma_s

p_tcp_iov = (tcp_iovec*)p_iov;

/* Suppress flags that should not be used anymore
* to avoid conflicts with VMA_TX_PACKET_L3_CSUM and VMA_TX_PACKET_L4_CSUM
*/
attr.flags = (vma_wr_tx_packet_attr)(attr.flags & ~(VMA_TX_PACKET_ZEROCOPY | VMA_TX_FILE));

attr.flags = (vma_wr_tx_packet_attr)(attr.flags | VMA_TX_PACKET_L3_CSUM | VMA_TX_PACKET_L4_CSUM);

/* Supported scenarios:
Expand Down
8 changes: 7 additions & 1 deletion src/vma/proto/dst_entry_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ ssize_t dst_entry_udp::fast_send(const iovec* p_iov, const ssize_t sz_iov, vma_s
{
// Calc user data payload size
ssize_t sz_data_payload = 0;

/* Suppress flags that should not be used anymore
* to avoid conflicts with VMA_TX_PACKET_L3_CSUM and VMA_TX_PACKET_L4_CSUM
*/
attr.flags = (vma_wr_tx_packet_attr)(attr.flags & ~(VMA_TX_PACKET_ZEROCOPY | VMA_TX_FILE));

for (ssize_t i = 0; i < sz_iov; i++)
sz_data_payload += p_iov[i].iov_len;

Expand All @@ -324,7 +330,7 @@ ssize_t dst_entry_udp::fast_send(const iovec* p_iov, const ssize_t sz_iov, vma_s
attr.flags = (vma_wr_tx_packet_attr)(attr.flags | VMA_TX_PACKET_L3_CSUM | VMA_TX_PACKET_L4_CSUM);
return fast_send_not_fragmented(p_iov, sz_iov, attr.flags, sz_udp_payload, sz_data_payload);
} else {
attr.flags = (vma_wr_tx_packet_attr)(attr.flags | VMA_TX_PACKET_L3_CSUM);
attr.flags = (vma_wr_tx_packet_attr)(attr.flags | VMA_TX_PACKET_L3_CSUM);
return fast_send_fragmented(p_iov, sz_iov, attr.flags, sz_udp_payload, sz_data_payload);
}
}
Expand Down
22 changes: 18 additions & 4 deletions src/vma/proto/vma_lwip.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,25 @@ typedef enum vma_wr_tx_packet_attr {
VMA_TX_PACKET_TSO = TCP_WRITE_TSO, /* 0x20 */
/* sendfile operation. */
VMA_TX_FILE = TCP_WRITE_FILE, /* 0x40 */
/* zcopy write operation (MSG_ZEROCOPY). */
VMA_TX_PACKET_ZEROCOPY = TCP_WRITE_ZEROCOPY, /* 0x80 */

/* MLX5_ETH_WQE_L3_CSUM offload to HW L3 (IP) header checksum */
VMA_TX_PACKET_L3_CSUM = (1 << 6), /* hardcoded values. It is the same as VMA_TX_FILE but there is no conflict */
/* MLX5_ETH_WQE_L4_CSUM offload to HW L4 (TCP/UDP) header checksum */
VMA_TX_PACKET_L4_CSUM = (1 << 7), /* hardcoded values */
/* MLX5_ETH_WQE_L3_CSUM offload to HW L3 (IP) header checksum
* Important:
* - hardcoded value used directly to program send to wire
* - it is the same as VMA_TX_FILE but there is no conflict as far as
* VMA_TX_FILE is passed into dst_entry::fast_send() operation
* and it is not needed later doing send to wire
*/
VMA_TX_PACKET_L3_CSUM = (1 << 6),
/* MLX5_ETH_WQE_L4_CSUM offload to HW L4 (TCP/UDP) header checksum
* Important:
* - hardcoded value used directly to program send to wire
* - it is the same as TCP_WRITE_ZEROCOPY but there is no conflict as far as
* TCP_WRITE_ZEROCOPY is passed into dst_entry::fast_send() operation
* and it is not needed later doing send to wire
*/
VMA_TX_PACKET_L4_CSUM = (1 << 7),
/* blocking send operation */
VMA_TX_PACKET_BLOCK = (1 << 8),
/* Force SW checksum */
Expand Down

0 comments on commit 687271f

Please sign in to comment.