83 lines
3.3 KiB
Diff
83 lines
3.3 KiB
Diff
From d4d8516449ed6c8d7685cc1aaec403763a5d5afa Mon Sep 17 00:00:00 2001
|
|
From: wu-changsheng <wuchangsheng2@huawei.com>
|
|
Date: Wed, 21 Dec 2022 23:04:57 +0800
|
|
Subject: [PATCH 2/2] write support without epoll/poll
|
|
|
|
---
|
|
src/common/dpdk_common.h | 4 ++--
|
|
src/lstack/core/lstack_lwip.c | 18 ++++++++++++------
|
|
2 files changed, 14 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/common/dpdk_common.h b/src/common/dpdk_common.h
|
|
index c93f506..e4a447a 100644
|
|
--- a/src/common/dpdk_common.h
|
|
+++ b/src/common/dpdk_common.h
|
|
@@ -25,9 +25,9 @@
|
|
#define PTR_TO_PRIVATE(mbuf) RTE_PTR_ADD(mbuf, sizeof(struct rte_mbuf))
|
|
|
|
/* Layout:
|
|
- * | rte_mbuf | gazelle_prive | pbuf | custom_free_function | tcp_seg | payload |
|
|
+ * | rte_mbuf | gazelle_prive | custom_free_function | tcp_seg | payload |
|
|
+ * | 128 | 16 | 56 | 32 |
|
|
* rte_prefetch0 in lwip project,tcp_out.c,tcp_output_segment use constants
|
|
- sizeof(struct rte_mbuf) + GAZELLE_MBUFF_PRIV_SIZE = 128 + 16
|
|
**/
|
|
struct pbuf;
|
|
static inline struct rte_mbuf *pbuf_to_mbuf(struct pbuf *p)
|
|
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
|
|
index 9442d3f..018b6c6 100644
|
|
--- a/src/lstack/core/lstack_lwip.c
|
|
+++ b/src/lstack/core/lstack_lwip.c
|
|
@@ -500,8 +500,7 @@ ssize_t write_stack_data(struct lwip_sock *sock, const void *buf, size_t len)
|
|
}
|
|
|
|
struct protocol_stack *stack = sock->stack;
|
|
- struct wakeup_poll *wakeup = sock->wakeup;
|
|
- if (!stack|| len == 0 || !wakeup) {
|
|
+ if (!stack|| len == 0) {
|
|
return 0;
|
|
}
|
|
|
|
@@ -517,6 +516,7 @@ ssize_t write_stack_data(struct lwip_sock *sock, const void *buf, size_t len)
|
|
|
|
uint32_t write_num = (len - send_len + MBUF_MAX_DATA_LEN - 1) / MBUF_MAX_DATA_LEN;
|
|
uint32_t write_avail = gazelle_ring_readable_count(sock->send_ring);
|
|
+ struct wakeup_poll *wakeup = sock->wakeup;
|
|
|
|
/* send_ring is full, data attach last pbuf */
|
|
if (write_avail == 0) {
|
|
@@ -524,10 +524,14 @@ ssize_t write_stack_data(struct lwip_sock *sock, const void *buf, size_t len)
|
|
if (last_pbuf) {
|
|
send_len += app_direct_attach(stack, last_pbuf, (char *)buf + send_len, len - send_len, write_num);
|
|
gazelle_ring_lastover(last_pbuf);
|
|
- wakeup->stat.app_write_cnt += write_num;
|
|
+ if (wakeup) {
|
|
+ wakeup->stat.app_write_cnt += write_num;
|
|
+ }
|
|
} else {
|
|
(void)rpc_call_replenish(stack, sock);
|
|
- wakeup->stat.app_write_rpc++;
|
|
+ if (wakeup) {
|
|
+ wakeup->stat.app_write_rpc++;
|
|
+ }
|
|
}
|
|
sock->remain_len = 0;
|
|
return send_len;
|
|
@@ -536,9 +540,11 @@ ssize_t write_stack_data(struct lwip_sock *sock, const void *buf, size_t len)
|
|
/* send_ring have idle */
|
|
send_len += (write_num <= write_avail) ? app_buff_write(sock, (char *)buf + send_len, len - send_len, write_num) :
|
|
app_direct_write(stack, sock, (char *)buf + send_len, len - send_len, write_num);
|
|
- wakeup->stat.app_write_cnt += write_num;
|
|
+ if (wakeup) {
|
|
+ wakeup->stat.app_write_cnt += write_num;
|
|
+ }
|
|
|
|
- if (wakeup->type == WAKEUP_EPOLL && (sock->events & EPOLLOUT)) {
|
|
+ if (wakeup && wakeup->type == WAKEUP_EPOLL && (sock->events & EPOLLOUT)) {
|
|
del_data_out_event(sock);
|
|
}
|
|
|
|
--
|
|
2.23.0
|
|
|