Skip to content

Commit e87bdb7

Browse files
committed
issue: 1792164 Introduce flags to process zero copy send
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]>
1 parent c7722dd commit e87bdb7

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

src/vma/lwip/tcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ err_t tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx);
528528
#define TCP_WRITE_DUMMY 0x10
529529
#define TCP_WRITE_TSO 0x20
530530
#define TCP_WRITE_FILE 0x40
531+
#define TCP_WRITE_ZEROCOPY 0x80
531532

532533
err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u32_t len,
533534
u8_t apiflags);

src/vma/lwip/tcp_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ struct tcp_seg {
305305
#define TF_SEG_OPTS_WNDSCALE (u8_t)0x08U /* Include window scaling option */
306306
#define TF_SEG_OPTS_DUMMY_MSG (u8_t)TCP_WRITE_DUMMY /* Include dummy send option */
307307
#define TF_SEG_OPTS_TSO (u8_t)TCP_WRITE_TSO /* Use TSO send mode */
308+
#define TF_SEG_OPTS_ZEROCOPY (u8_t)TCP_WRITE_ZEROCOPY /* Use zerocopy send mode */
308309

309310
struct tcp_hdr *tcphdr; /* the TCP header */
310311
};

src/vma/proto/dst_entry_tcp.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ ssize_t dst_entry_tcp::fast_send(const iovec* p_iov, const ssize_t sz_iov, vma_s
8181

8282
p_tcp_iov = (tcp_iovec*)p_iov;
8383

84+
/* Suppress flags that should not be used anymore
85+
* to avoid conflicts with VMA_TX_PACKET_L3_CSUM and VMA_TX_PACKET_L4_CSUM
86+
*/
87+
attr.flags = (vma_wr_tx_packet_attr)(attr.flags & ~(VMA_TX_PACKET_ZEROCOPY | VMA_TX_FILE));
88+
8489
attr.flags = (vma_wr_tx_packet_attr)(attr.flags | VMA_TX_PACKET_L3_CSUM | VMA_TX_PACKET_L4_CSUM);
8590

8691
/* Supported scenarios:

src/vma/proto/dst_entry_udp.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@ ssize_t dst_entry_udp::fast_send(const iovec* p_iov, const ssize_t sz_iov, vma_s
308308
{
309309
// Calc user data payload size
310310
ssize_t sz_data_payload = 0;
311+
312+
/* Suppress flags that should not be used anymore
313+
* to avoid conflicts with VMA_TX_PACKET_L3_CSUM and VMA_TX_PACKET_L4_CSUM
314+
*/
315+
attr.flags = (vma_wr_tx_packet_attr)(attr.flags & ~(VMA_TX_PACKET_ZEROCOPY | VMA_TX_FILE));
316+
311317
for (ssize_t i = 0; i < sz_iov; i++)
312318
sz_data_payload += p_iov[i].iov_len;
313319

@@ -324,7 +330,7 @@ ssize_t dst_entry_udp::fast_send(const iovec* p_iov, const ssize_t sz_iov, vma_s
324330
attr.flags = (vma_wr_tx_packet_attr)(attr.flags | VMA_TX_PACKET_L3_CSUM | VMA_TX_PACKET_L4_CSUM);
325331
return fast_send_not_fragmented(p_iov, sz_iov, attr.flags, sz_udp_payload, sz_data_payload);
326332
} else {
327-
attr.flags = (vma_wr_tx_packet_attr)(attr.flags | VMA_TX_PACKET_L3_CSUM);
333+
attr.flags = (vma_wr_tx_packet_attr)(attr.flags | VMA_TX_PACKET_L3_CSUM);
328334
return fast_send_fragmented(p_iov, sz_iov, attr.flags, sz_udp_payload, sz_data_payload);
329335
}
330336
}

src/vma/proto/vma_lwip.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,25 @@ typedef enum vma_wr_tx_packet_attr {
5151
VMA_TX_PACKET_TSO = TCP_WRITE_TSO, /* 0x20 */
5252
/* sendfile operation. */
5353
VMA_TX_FILE = TCP_WRITE_FILE, /* 0x40 */
54+
/* zcopy write operation (MSG_ZEROCOPY). */
55+
VMA_TX_PACKET_ZEROCOPY = TCP_WRITE_ZEROCOPY, /* 0x80 */
5456

55-
/* MLX5_ETH_WQE_L3_CSUM offload to HW L3 (IP) header checksum */
56-
VMA_TX_PACKET_L3_CSUM = (1 << 6), /* hardcoded values. It is the same as VMA_TX_FILE but there is no conflict */
57-
/* MLX5_ETH_WQE_L4_CSUM offload to HW L4 (TCP/UDP) header checksum */
58-
VMA_TX_PACKET_L4_CSUM = (1 << 7), /* hardcoded values */
57+
/* MLX5_ETH_WQE_L3_CSUM offload to HW L3 (IP) header checksum
58+
* Important:
59+
* - hardcoded value used directly to program send to wire
60+
* - it is the same as VMA_TX_FILE but there is no conflict as far as
61+
* VMA_TX_FILE is passed into dst_entry::fast_send() operation
62+
* and it is not needed later doing send to wire
63+
*/
64+
VMA_TX_PACKET_L3_CSUM = (1 << 6),
65+
/* MLX5_ETH_WQE_L4_CSUM offload to HW L4 (TCP/UDP) header checksum
66+
* Important:
67+
* - hardcoded value used directly to program send to wire
68+
* - it is the same as TCP_WRITE_ZEROCOPY but there is no conflict as far as
69+
* TCP_WRITE_ZEROCOPY is passed into dst_entry::fast_send() operation
70+
* and it is not needed later doing send to wire
71+
*/
72+
VMA_TX_PACKET_L4_CSUM = (1 << 7),
5973
/* blocking send operation */
6074
VMA_TX_PACKET_BLOCK = (1 << 8),
6175
/* Force SW checksum */

0 commit comments

Comments
 (0)