mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-21 23:56:59 +08:00
Vectorize netconn_write for TCP
This commit adds support to the netconn write APIs to take an input of vectors instead of a single data pointer This allows vectors sent on a TCP connection via sendmsg to be treated atomically. The set of vectors is segmented into as much data as can fit into the send buffer and then the TCP output function is called Previously, each vector was passed to netconn_write_partly and tcp_write segmented it into its own packet, which was then it was sent via tcp_output (if not Nagleing) This commit adds vector support to lwip_netconn_do_writemore() which is the meat of the TCP write functionality from netconn/sockets layer. A new netconn API netconn_write_vectors_partly() takes a set of vectors as input and hooks up to do_writemore() This commit also defines IOV_MAX because we are limited to only supporting 65535 vectors due to choice of u16_t for the vector count
This commit is contained in:
@@ -267,6 +267,11 @@ struct netconn {
|
||||
netconn_callback callback;
|
||||
};
|
||||
|
||||
struct netvector {
|
||||
const void *ptr;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
/** Register an Network connection event */
|
||||
#define API_EVENT(c,e,l) if (c->callback) { \
|
||||
(*c->callback)(c, e, l); \
|
||||
@@ -319,6 +324,8 @@ err_t netconn_sendto(struct netconn *conn, struct netbuf *buf,
|
||||
err_t netconn_send(struct netconn *conn, struct netbuf *buf);
|
||||
err_t netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size,
|
||||
u8_t apiflags, size_t *bytes_written);
|
||||
err_t netconn_write_vectors_partly(struct netconn *conn, struct netvector *vectors, u16_t vectorcnt,
|
||||
u8_t apiflags, size_t *bytes_written);
|
||||
/** @ingroup netconn_tcp */
|
||||
#define netconn_write(conn, dataptr, size, apiflags) \
|
||||
netconn_write_partly(conn, dataptr, size, apiflags, NULL)
|
||||
|
||||
@@ -103,10 +103,15 @@ struct api_msg {
|
||||
} ad;
|
||||
/** used for lwip_netconn_do_write */
|
||||
struct {
|
||||
const void *dataptr;
|
||||
/** total length of dataptr */
|
||||
/** current vector to write */
|
||||
const struct netvector *vector;
|
||||
/** number of unwritten vectors */
|
||||
u16_t vector_cnt;
|
||||
/** offset into current vector */
|
||||
size_t vector_off;
|
||||
/** total length across vectors */
|
||||
size_t len;
|
||||
/** offset into dataptr/output of bytes written when err == ERR_OK */
|
||||
/** offset into total length/output of bytes written when err == ERR_OK */
|
||||
size_t offset;
|
||||
u8_t apiflags;
|
||||
#if LWIP_SO_SNDTIMEO
|
||||
|
||||
@@ -108,6 +108,12 @@ struct sockaddr_storage {
|
||||
typedef u32_t socklen_t;
|
||||
#endif
|
||||
|
||||
#if !defined IOV_MAX
|
||||
#define IOV_MAX 0xFFFF
|
||||
#elif IOV_MAX > 0xFFFF
|
||||
#error "IOV_MAX larger than supported by LwIP"
|
||||
#endif /* IOV_MAX */
|
||||
|
||||
#if !defined(iovec)
|
||||
struct iovec {
|
||||
void *iov_base;
|
||||
|
||||
Reference in New Issue
Block a user