diff --git a/0164-dfx-support-get-nic-bond-status.patch b/0164-dfx-support-get-nic-bond-status.patch new file mode 100644 index 0000000..af4f21a --- /dev/null +++ b/0164-dfx-support-get-nic-bond-status.patch @@ -0,0 +1,120 @@ +From 819f74f014592b8af93eb45fd13681caa2cb662a Mon Sep 17 00:00:00 2001 +From: zhangmengxuan +Date: Thu, 28 Mar 2024 21:24:05 +0800 +Subject: [PATCH] dfx: support get nic bond status + +--- + src/common/gazelle_dfx_msg.h | 9 +++++++++ + src/lstack/core/lstack_dpdk.c | 27 +++++++++++++++++++++++++++ + src/ltran/ltran_dfx.c | 14 ++++++++++++++ + 3 files changed, 50 insertions(+) + +diff --git a/src/common/gazelle_dfx_msg.h b/src/common/gazelle_dfx_msg.h +index d7ba80f..4929ae7 100644 +--- a/src/common/gazelle_dfx_msg.h ++++ b/src/common/gazelle_dfx_msg.h +@@ -256,15 +256,24 @@ struct gazelle_stat_low_power_info { + + #define RTE_ETH_XSTATS_NAME_SIZE 64 + #define RTE_ETH_XSTATS_MAX_LEN 256 ++#define RTE_MAX_ETHPORTS 32 + struct nic_eth_xstats_name { + char name[RTE_ETH_XSTATS_NAME_SIZE]; + }; + ++struct bonding { ++ int8_t mode; ++ int32_t miimon; ++ uint16_t primary_port_id; ++ uint16_t slaves[RTE_MAX_ETHPORTS]; ++}; ++ + struct nic_eth_xstats { + struct nic_eth_xstats_name xstats_name[RTE_ETH_XSTATS_MAX_LEN]; + uint64_t values[RTE_ETH_XSTATS_MAX_LEN]; + uint32_t len; + uint16_t port_id; ++ struct bonding bonding; + }; + + struct nic_eth_features { +diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c +index a774d45..cd87026 100644 +--- a/src/lstack/core/lstack_dpdk.c ++++ b/src/lstack/core/lstack_dpdk.c +@@ -870,6 +870,31 @@ static int dpdk_nic_xstats_name_get(struct nic_eth_xstats_name *names, uint16_t + return len; + } + ++void dpdk_nic_bond_xstats_get(struct gazelle_stack_dfx_data *dfx, uint16_t port_id, uint16_t *slaves, int count) ++{ ++ dfx->data.nic_xstats.bonding.mode = rte_eth_bond_mode_get(port_id); ++ if (dfx->data.nic_xstats.bonding.mode < 0) { ++ LSTACK_LOG(ERR, LSTACK, "rte_eth_bond_mode_get failed.\n"); ++ return; ++ } ++ ++ dfx->data.nic_xstats.bonding.primary_port_id = rte_eth_bond_primary_get(port_id); ++ if (dfx->data.nic_xstats.bonding.primary_port_id < 0) { ++ LSTACK_LOG(ERR, LSTACK, "rte_eth_bond_primary_get failed.\n"); ++ return; ++ } ++ ++ dfx->data.nic_xstats.bonding.miimon = rte_eth_bond_link_monitoring_get(port_id); ++ if (dfx->data.nic_xstats.bonding.miimon <= 0) { ++ LSTACK_LOG(ERR, LSTACK, "rte_eth_bond_link_monitoring_get failed.\n"); ++ return; ++ } ++ ++ for (int i = 0; i < count; i++) { ++ dfx->data.nic_xstats.bonding.slaves[i] = slaves[i]; ++ } ++} ++ + void dpdk_nic_xstats_get(struct gazelle_stack_dfx_data *dfx, uint16_t port_id) + { + struct rte_eth_dev_info dev_info; +@@ -878,6 +903,7 @@ void dpdk_nic_xstats_get(struct gazelle_stack_dfx_data *dfx, uint16_t port_id) + + dfx->data.nic_xstats.len = -1; + dfx->data.nic_xstats.port_id = port_id; ++ dfx->data.nic_xstats.bonding.mode = -1; + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret < 0) { + LSTACK_LOG(ERR, LSTACK, "rte_eth_dev_info_get failed.\n"); +@@ -904,6 +930,7 @@ void dpdk_nic_xstats_get(struct gazelle_stack_dfx_data *dfx, uint16_t port_id) + if (dpdk_nic_xstats_value_get(dfx->data.nic_xstats.values, len, slaves, slave_count) != 0) { + return; + } ++ dpdk_nic_bond_xstats_get(dfx, port_id, slaves, slave_count); + } else { + len = dpdk_nic_xstats_name_get(dfx->data.nic_xstats.xstats_name, port_id); + if (len <= 0) { +diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c +index 073dfa7..88d11bd 100644 +--- a/src/ltran/ltran_dfx.c ++++ b/src/ltran/ltran_dfx.c +@@ -200,6 +200,20 @@ static void gazelle_print_lstack_xstats(void *buf, const struct gazelle_stat_msg + struct nic_eth_xstats *xstats = &stat->data.nic_xstats; + static const char *nic_stats_border = "########################"; + ++ if (xstats->bonding.mode >= 0) { ++ printf("############# NIC bonding mode display #############\n"); ++ printf("%s############################\n", nic_stats_border); ++ printf("Bonding mode: [%d]\n", xstats->bonding.mode); ++ printf("Bonding miimon: [%d]\n", xstats->bonding.miimon); ++ printf("Slaves(%d): [", xstats->port_id); ++ for (int i = 0; i < xstats->port_id - 1; i++) { ++ printf("%d ", xstats->bonding.slaves[i]); ++ } ++ printf("%d]\n", xstats->bonding.slaves[xstats->port_id - 1]); ++ printf("Primary: [%d]\n", xstats->bonding.primary_port_id); ++ printf("%s############################\n", nic_stats_border); ++ } ++ + printf("###### NIC extended statistics for port %-2d #########\n", xstats->port_id); + printf("%s############################\n", nic_stats_border); + if (xstats->len <= 0 || xstats->len > RTE_ETH_XSTATS_MAX_LEN) { +-- +2.33.0 + diff --git a/0165-remove-dpdk_skip_nic_init-for-dpdk-23.11.patch b/0165-remove-dpdk_skip_nic_init-for-dpdk-23.11.patch new file mode 100644 index 0000000..c97b59f --- /dev/null +++ b/0165-remove-dpdk_skip_nic_init-for-dpdk-23.11.patch @@ -0,0 +1,54 @@ +From aae704235da3299fb2d6920aef46afd560ab2c01 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Tue, 9 Apr 2024 17:50:46 +0800 +Subject: [PATCH] remove dpdk_skip_nic_init for dpdk-23.11 + +--- + src/lstack/core/lstack_init.c | 4 ++++ + src/lstack/include/lstack_dpdk.h | 4 +++- + 2 files changed, 7 insertions(+), 1 deletion(-) + +diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c +index f1ef134..79b4060 100644 +--- a/src/lstack/core/lstack_init.c ++++ b/src/lstack/core/lstack_init.c +@@ -144,7 +144,9 @@ static void create_control_thread(void) + pthread_t tid; + if (use_ltran()) { + /* The function call here should be in strict order. */ ++#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + dpdk_skip_nic_init(); ++#endif + if (control_init_client(false) != 0) { + LSTACK_EXIT(1, "control_init_client failed\n"); + } +@@ -279,7 +281,9 @@ __attribute__((constructor)) void gazelle_network_init(void) + + /* Init control plane and dpdk init */ + create_control_thread(); ++#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + dpdk_restore_pci(); ++#endif + + /* cancel the core binding from DPDK initialization */ + if (!get_global_cfg_params()->main_thread_affinity) { +diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h +index c7cfbdf..fe3d07b 100644 +--- a/src/lstack/include/lstack_dpdk.h ++++ b/src/lstack/include/lstack_dpdk.h +@@ -48,9 +48,11 @@ int32_t create_shared_ring(struct protocol_stack *stack); + void lstack_log_level_init(void); + int dpdk_ethdev_init(int port_id, bool bond_port); + int dpdk_ethdev_start(void); ++#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + void dpdk_skip_nic_init(void); +-int32_t dpdk_init_lstack_kni(void); + void dpdk_restore_pci(void); ++#endif ++int32_t dpdk_init_lstack_kni(void); + bool port_in_stack_queue(gz_addr_t *src_ip, gz_addr_t *dst_ip, uint16_t src_port, uint16_t dst_port); + struct rte_mempool *create_pktmbuf_mempool(const char *name, uint32_t nb_mbuf, + uint32_t mbuf_cache_size, uint16_t queue_id, unsigned numa_id); +-- +2.33.0 + diff --git a/0166-gazellectl-add-lwip-stats_proto-print.patch b/0166-gazellectl-add-lwip-stats_proto-print.patch new file mode 100644 index 0000000..bb4c27f --- /dev/null +++ b/0166-gazellectl-add-lwip-stats_proto-print.patch @@ -0,0 +1,317 @@ +From 3beb273528f360c7d6863990a5d0cdcb5ebcb407 Mon Sep 17 00:00:00 2001 +From: ningjin +Date: Thu, 28 Mar 2024 16:05:01 +0800 +Subject: [PATCH] gazellectl add lwip stats_proto print + +--- + src/common/gazelle_dfx_msg.h | 23 ++++++++++ + src/lstack/core/lstack_control_plane.c | 2 +- + src/lstack/core/lstack_stack_stat.c | 41 +++++++++++++++-- + src/lstack/include/lstack_stack_stat.h | 3 +- + src/ltran/ltran_dfx.c | 61 +++++++++++++++++++++++++- + src/ltran/ltran_monitor.c | 1 + + 6 files changed, 124 insertions(+), 7 deletions(-) + +diff --git a/src/common/gazelle_dfx_msg.h b/src/common/gazelle_dfx_msg.h +index d7ba80f..6cd90b1 100644 +--- a/src/common/gazelle_dfx_msg.h ++++ b/src/common/gazelle_dfx_msg.h +@@ -24,6 +24,7 @@ + + #define GAZELLE_CLIENT_NUM_MIN 1 + #define GAZELLE_LOG_LEVEL_MAX 10 ++#define MAX_PROTOCOL_LENGTH 20 + #define GAZELLECTL_TIMEOUT 5000 // millisecond + /* maybe it should be consistent with MEMP_NUM_TCP_PCB */ + #define GAZELLE_LSTACK_MAX_CONN (20000 + 2000) // same as MAX_CLIENTS + RESERVED_CLIENTS in lwipopts.h +@@ -46,6 +47,7 @@ enum GAZELLE_STAT_MODE { + GAZELLE_STAT_LTRAN_SHOW_SOCKTABLE, + GAZELLE_STAT_LTRAN_SHOW_CONNTABLE, + GAZELLE_STAT_LTRAN_SHOW_LSTACK, ++ GAZELLE_STAT_LSTACK_SHOW_PROTOCOL, + + GAZELLE_STAT_LSTACK_SHOW, + GAZELLE_STAT_LSTACK_LOG_LEVEL_SET, +@@ -193,6 +195,24 @@ struct gazelle_stat_lstack_snmp { + uint32_t icmp_out_echo_reps; + }; + ++/* same as define in lwip/stats.h - struct stats_proto */ ++struct gazelle_stat_lstack_proto { ++ /* data */ ++ uint16_t xmit; /* Transmitted packets. */ ++ uint16_t recv; /* Received packets. */ ++ uint16_t fw; /* Forwarded packets. */ ++ uint16_t drop; /* Dropped packets. */ ++ uint16_t chkerr; /* Checksum error. */ ++ uint16_t lenerr; /* Invalid length error. */ ++ uint16_t memerr; /* Out of memory error. */ ++ uint16_t rterr; /* Routing error. */ ++ uint16_t proterr; /* Protocol error. */ ++ uint16_t opterr; /* Error in options. */ ++ uint16_t err; /* Misc error. */ ++ uint16_t cachehit; ++}; ++ ++ + /* same as define in lwip/tcp.h - struct tcp_pcb_dp */ + struct gazelle_stat_lstack_conn_info { + uint32_t state; +@@ -288,6 +308,8 @@ struct gazelle_stack_dfx_data { + struct gazelle_stat_lstack_snmp snmp; + struct nic_eth_xstats nic_xstats; + struct nic_eth_features nic_features; ++ struct gazelle_stat_lstack_proto proto_data; ++ + #ifdef GAZELLE_FAULT_INJECT_ENABLE + struct gazelle_fault_inject_data inject; + #endif /* GAZELLE_FAULT_INJECT_ENABLE */ +@@ -321,6 +343,7 @@ struct gazelle_stat_msg_request { + union stat_param { + char log_level[GAZELLE_LOG_LEVEL_MAX]; + uint16_t low_power_mod; ++ char protocol[MAX_PROTOCOL_LENGTH]; + #ifdef GAZELLE_FAULT_INJECT_ENABLE + struct gazelle_fault_inject_data inject; + #endif /* GAZELLE_FAULT_INJECT_ENABLE */ +diff --git a/src/lstack/core/lstack_control_plane.c b/src/lstack/core/lstack_control_plane.c +index 9f0c313..04858c7 100644 +--- a/src/lstack/core/lstack_control_plane.c ++++ b/src/lstack/core/lstack_control_plane.c +@@ -601,7 +601,7 @@ static int32_t handle_stat_request(int32_t sockfd) + msg.stat_mode == GAZELLE_STAT_LSTACK_SHOW_NIC_FEATURES) { + return handle_dpdk_cmd(sockfd, msg.stat_mode); + } else { +- ret = handle_stack_cmd(sockfd, msg.stat_mode); ++ ret = handle_stack_cmd(sockfd, &msg); + if (ret != 0) { + LSTACK_LOG(ERR, LSTACK, "get_stats failed ret=%d\n", ret); + } +diff --git a/src/lstack/core/lstack_stack_stat.c b/src/lstack/core/lstack_stack_stat.c +index 3e016b7..d439357 100644 +--- a/src/lstack/core/lstack_stack_stat.c ++++ b/src/lstack/core/lstack_stack_stat.c +@@ -210,11 +210,42 @@ static void get_stack_stats(struct gazelle_stack_dfx_data *dfx, struct protocol_ + dfx->data.pkts.conn_num = stack->conn_num; + } + ++static void get_stack_dfx_data_proto(struct gazelle_stack_dfx_data *dfx, struct protocol_stack *stack, ++ struct gazelle_stat_msg_request *msg) ++{ ++ int32_t ret = 0; ++ msg->data.protocol[MAX_PROTOCOL_LENGTH - 1] = '\0'; ++ const char* proto_mode = msg->data.protocol; ++ ++ if (strcmp(proto_mode, "UDP") == 0) { ++ ret = memcpy_s(&dfx->data.proto_data, sizeof(dfx->data.proto_data), ++ &stack->lwip_stats->udp, sizeof(stack->lwip_stats->udp)); ++ } else if (strcmp(proto_mode, "TCP") == 0) { ++ ret = memcpy_s(&dfx->data.proto_data, sizeof(dfx->data.proto_data), ++ &stack->lwip_stats->tcp, sizeof(stack->lwip_stats->tcp)); ++ } else if (strcmp(proto_mode, "IP") == 0) { ++ ret = memcpy_s(&dfx->data.proto_data, sizeof(dfx->data.proto_data), ++ &stack->lwip_stats->ip, sizeof(stack->lwip_stats->ip)); ++ } else if (strcmp(proto_mode, "ICMP") == 0) { ++ ret = memcpy_s(&dfx->data.proto_data, sizeof(dfx->data.proto_data), ++ &stack->lwip_stats->icmp, sizeof(stack->lwip_stats->icmp)); ++ } else if (strcmp(proto_mode, "ETHARP") == 0) { ++ ret = memcpy_s(&dfx->data.proto_data, sizeof(dfx->data.proto_data), ++ &stack->lwip_stats->etharp, sizeof(stack->lwip_stats->etharp)); ++ } else { ++ printf("Error: Invalid protocol\n"); ++ } ++ if (ret != EOK) { ++ LSTACK_LOG(ERR, LSTACK, "memcpy_s err ret=%d \n", ret); ++ } ++} ++ + static void get_stack_dfx_data(struct gazelle_stack_dfx_data *dfx, struct protocol_stack *stack, +- enum GAZELLE_STAT_MODE stat_mode) ++ struct gazelle_stat_msg_request *msg) + { + int32_t rpc_call_result; + int32_t ret; ++ enum GAZELLE_STAT_MODE stat_mode = msg->stat_mode; + + switch (stat_mode) { + case GAZELLE_STAT_LSTACK_SHOW: +@@ -255,6 +286,9 @@ static void get_stack_dfx_data(struct gazelle_stack_dfx_data *dfx, struct protoc + case GAZELLE_STAT_LTRAN_STOP_LATENCY: + set_latency_start_flag(false); + break; ++ case GAZELLE_STAT_LSTACK_SHOW_PROTOCOL: ++ get_stack_dfx_data_proto(dfx, stack, msg); ++ break; + default: + break; + } +@@ -298,16 +332,17 @@ int handle_dpdk_cmd(int fd, enum GAZELLE_STAT_MODE stat_mode) + return 0; + } + +-int handle_stack_cmd(int fd, enum GAZELLE_STAT_MODE stat_mode) ++int handle_stack_cmd(int fd, struct gazelle_stat_msg_request *msg) + { + struct gazelle_stack_dfx_data dfx; + struct protocol_stack_group *stack_group = get_protocol_stack_group(); ++ enum GAZELLE_STAT_MODE stat_mode = msg->stat_mode; + + for (uint32_t i = 0; i < stack_group->stack_num; i++) { + struct protocol_stack *stack = stack_group->stacks[i]; + + memset_s(&dfx, sizeof(dfx), 0, sizeof(dfx)); +- get_stack_dfx_data(&dfx, stack, stat_mode); ++ get_stack_dfx_data(&dfx, stack, msg); + + if (!use_ltran() && + (stat_mode == GAZELLE_STAT_LTRAN_START_LATENCY || stat_mode == GAZELLE_STAT_LTRAN_STOP_LATENCY)) { +diff --git a/src/lstack/include/lstack_stack_stat.h b/src/lstack/include/lstack_stack_stat.h +index 87951aa..867f35b 100644 +--- a/src/lstack/include/lstack_stack_stat.h ++++ b/src/lstack/include/lstack_stack_stat.handle +@@ -21,13 +21,14 @@ struct wakeup_poll; + struct protocol_stack; + enum GAZELLE_LATENCY_TYPE; + enum GAZELLE_STAT_MODE; ++struct gazelle_stat_msg_request; + + void calculate_lstack_latency(struct gazelle_stack_latency *stack_latency, const struct pbuf *pbuf, + enum GAZELLE_LATENCY_TYPE type, uint64_t time_record); + void calculate_rpcmsg_latency(struct gazelle_stack_latency *stack_latency, struct rpc_msg *msg, + enum GAZELLE_LATENCY_TYPE type); + void stack_stat_init(void); +-int handle_stack_cmd(int fd, enum GAZELLE_STAT_MODE stat_mode); ++int handle_stack_cmd(int fd, struct gazelle_stat_msg_request *msg); + int handle_dpdk_cmd(int fd, enum GAZELLE_STAT_MODE stat_mode); + uint64_t get_current_time(void); + void lstack_get_low_power_info(struct gazelle_stat_low_power_info *low_power_info); +diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c +index 073dfa7..717744a 100644 +--- a/src/ltran/ltran_dfx.c ++++ b/src/ltran/ltran_dfx.c +@@ -136,6 +136,7 @@ static void gazelle_print_ltran_conn(void *buf, const struct gazelle_stat_msg_re + static void gazelle_print_lstack_xstats(void *buf, const struct gazelle_stat_msg_request *req_msg); + static void gazelle_print_lstack_aggregate(void *buf, const struct gazelle_stat_msg_request *req_msg); + static void gazelle_print_lstack_nic_features(void *buf, const struct gazelle_stat_msg_request *req_msg); ++static void gazelle_print_lstack_stat_proto(void *buf, const struct gazelle_stat_msg_request *req_msg); + + #ifdef GAZELLE_FAULT_INJECT_ENABLE + static void gazelle_print_fault_inject_set_status(void *buf, const struct gazelle_stat_msg_request *req_msg); +@@ -168,7 +169,8 @@ static struct gazelle_dfx_list g_gazelle_dfx_tbl[] = { + {GAZELLE_STAT_LSTACK_SHOW_XSTATS, sizeof(struct gazelle_stack_dfx_data), gazelle_print_lstack_xstats}, + {GAZELLE_STAT_LSTACK_SHOW_AGGREGATE, sizeof(struct gazelle_stack_dfx_data), gazelle_print_lstack_aggregate}, + {GAZELLE_STAT_LSTACK_SHOW_NIC_FEATURES, sizeof(struct gazelle_stack_dfx_data), gazelle_print_lstack_nic_features}, +- ++ {GAZELLE_STAT_LSTACK_SHOW_PROTOCOL, sizeof(struct gazelle_stack_dfx_data), gazelle_print_lstack_stat_proto}, ++ + #ifdef GAZELLE_FAULT_INJECT_ENABLE + {GAZELLE_STAT_FAULT_INJECT_SET, sizeof(struct gazelle_stack_dfx_data), gazelle_print_fault_inject_set_status}, + {GAZELLE_STAT_FAULT_INJECT_UNSET, sizeof(struct gazelle_stack_dfx_data), gazelle_print_fault_inject_unset_status}, +@@ -1083,6 +1085,20 @@ static void gazelle_print_lstack_stat_snmp_core(const struct gazelle_stack_dfx_d + printf("icmp_out_echo_reps: %u\n", snmp->icmp_out_echo_reps); + } + ++static void gazelle_print_lstack_stat_proto_core(const struct gazelle_stack_dfx_data *stat, ++ const struct gazelle_stat_lstack_proto *proto) ++{ ++ printf("\n------ stack tid: %6u ------\n", stat->tid); ++ printf("xmit: %u\n", proto->xmit); ++ printf("recv: %u\n", proto->recv); ++ printf("fw: %u\n", proto->fw); ++ printf("drop: %u\n", proto->drop); ++ printf("chkerr: %u\n", proto->chkerr); ++ printf("lenerr: %u\n", proto->lenerr); ++ printf("memerr: %u\n", proto->memerr); ++ printf("rterr: %u\n", proto->rterr); ++} ++ + static void gazelle_print_lstack_stat_snmp(void *buf, const struct gazelle_stat_msg_request *req_msg) + { + int32_t ret; +@@ -1102,6 +1118,26 @@ static void gazelle_print_lstack_stat_snmp(void *buf, const struct gazelle_stat_ + } while (true); + } + ++static void gazelle_print_lstack_stat_proto(void *buf, const struct gazelle_stat_msg_request *req_msg) ++{ ++ int32_t ret; ++ struct gazelle_stack_dfx_data *stat = (struct gazelle_stack_dfx_data *)buf; ++ struct gazelle_stat_lstack_proto *proto = NULL; ++ ++ proto = &stat->data.proto_data; ++ printf("Statistics of lstack proto:\n"); ++ do { ++ gazelle_print_lstack_stat_proto_core(stat, proto); ++ if (stat->eof != 0) { ++ break; ++ } ++ ret = dfx_stat_read_from_ltran(buf, sizeof(struct gazelle_stack_dfx_data), req_msg->stat_mode); ++ if (ret != GAZELLE_OK) { ++ return; ++ } ++ } while (true); ++} ++ + static void gazelle_keepalive_string(char* str, int buff_len, struct gazelle_stat_lstack_conn_info *conn_info) + { + if (conn_info->keepalive == 0) { +@@ -1240,6 +1276,7 @@ static void show_usage(void) + " loglevel {error | info | debug} set lstack loglevel \n" + " lowpower {0 | 1} set lowpower enable \n" + " [time] measure latency time default 1S, maximum 30mins \n\n" ++ " -p, protocol {UDP | TCP | ICMP | IP | ETHARP | IP_FRAG} show lstack protocol statistics \n" + #ifdef GAZELLE_FAULT_INJECT_ENABLE + " *inject params*\n" + " |inject_type | digit_param_1 | digit_param_2 | inject_rule |\n" +@@ -1444,6 +1481,25 @@ static int parse_delay_arg(int32_t argc, char *argv[], long int delay) + return 0; + } + ++static int32_t parse_dfx_lstack_show_proto_args(int32_t argc, char *argv[], struct gazelle_stat_msg_request *req_msg) ++{ ++ int32_t cmd_index = 0; ++ int32_t ret; ++ ++ char *param = argv[GAZELLE_OPTIONS2_ARG_IDX]; ++ if (strcmp(param, "UDP") != 0 && strcmp(param, "TCP") != 0 && strcmp(param, "IP") && ++ strcmp(param, "ICMP") && strcmp(param, "ETHARP") != 0) { ++ return cmd_index; ++ } ++ ret = strncpy_s(req_msg[cmd_index].data.protocol, MAX_PROTOCOL_LENGTH, argv[GAZELLE_OPTIONS2_ARG_IDX], ++ MAX_PROTOCOL_LENGTH - 1); ++ if (ret != EOK) { ++ return -1; ++ } ++ req_msg[cmd_index++].stat_mode = GAZELLE_STAT_LSTACK_SHOW_PROTOCOL; ++ return cmd_index; ++} ++ + static int32_t parse_dfx_lstack_show_args(int32_t argc, char *argv[], struct gazelle_stat_msg_request *req_msg) + { + int32_t cmd_index = 0; +@@ -1490,8 +1546,9 @@ static int32_t parse_dfx_lstack_show_args(int32_t argc, char *argv[], struct gaz + } + } else if (strcmp(param, "-k") == 0 || strcmp(param, "nic-features") == 0) { + req_msg[cmd_index++].stat_mode = GAZELLE_STAT_LSTACK_SHOW_NIC_FEATURES; ++ } else if (strcmp(param, "protocol") == 0 || strcmp(param, "-p") == 0) { ++ cmd_index = parse_dfx_lstack_show_proto_args(argc, argv, req_msg); + } +- + return cmd_index; + } + +diff --git a/src/ltran/ltran_monitor.c b/src/ltran/ltran_monitor.c +index ea31e84..457e8c8 100644 +--- a/src/ltran/ltran_monitor.c ++++ b/src/ltran/ltran_monitor.c +@@ -347,6 +347,7 @@ static int32_t lstack_req_mode_process(int32_t fd, const struct gazelle_stat_msg + case GAZELLE_STAT_LSTACK_SHOW_CONN: + case GAZELLE_STAT_LSTACK_SHOW_LATENCY: + case GAZELLE_STAT_LSTACK_LOW_POWER_MDF: ++ case GAZELLE_STAT_LSTACK_SHOW_PROTOCOL: + handle_resp_lstack_transfer(req_msg, fd); + break; + default: +-- +2.33.0 + diff --git a/0167-fix-port-not-support-vlan-filter.patch b/0167-fix-port-not-support-vlan-filter.patch new file mode 100644 index 0000000..3083078 --- /dev/null +++ b/0167-fix-port-not-support-vlan-filter.patch @@ -0,0 +1,26 @@ +From 3171100d06146791ab9d22523805b8ed580daf3f Mon Sep 17 00:00:00 2001 +From: yinbin6 +Date: Fri, 12 Apr 2024 15:09:12 +0800 +Subject: [PATCH] fix port not support vlan filter + +--- + src/lstack/core/lstack_dpdk.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c +index a6a8a01..5d90408 100644 +--- a/src/lstack/core/lstack_dpdk.c ++++ b/src/lstack/core/lstack_dpdk.c +@@ -624,7 +624,8 @@ int32_t dpdk_ethdev_init(int port_id, bool bond_port) + } + + /* after rte_eth_dev_configure */ +- if (get_global_cfg_params()->nic.vlan_mode != -1) { ++ if ((get_global_cfg_params()->nic.vlan_mode != -1) && ++ ((stack_group->rx_offload & RTE_ETH_RX_OFFLOAD_VLAN_FILTER) == RTE_ETH_RX_OFFLOAD_VLAN_FILTER)) { + ret = rte_eth_dev_vlan_filter(port_id, get_global_cfg_params()->nic.vlan_mode, 1); + if (ret != 0) { + LSTACK_LOG(ERR, LSTACK, "dpdk add vlan filter failed ret = %d\n", ret); +-- +2.33.0 + diff --git a/0168-fix-tcp-recv-does-not-return-pkg-when-ring-buffer-is.patch b/0168-fix-tcp-recv-does-not-return-pkg-when-ring-buffer-is.patch new file mode 100644 index 0000000..01ded10 --- /dev/null +++ b/0168-fix-tcp-recv-does-not-return-pkg-when-ring-buffer-is.patch @@ -0,0 +1,27 @@ +From 5fff605ff68741482d7fff992343eaccb383115f Mon Sep 17 00:00:00 2001 +From: li_yunqing +Date: Fri, 22 Mar 2024 15:47:19 +0800 +Subject: [PATCH] fix tcp recv does not return pkg when ring buffer is empty + +--- + src/lstack/core/lstack_lwip.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c +index a604a62..51238ba 100644 +--- a/src/lstack/core/lstack_lwip.c ++++ b/src/lstack/core/lstack_lwip.c +@@ -925,7 +925,9 @@ static ssize_t recv_ring_tcp_read(struct lwip_sock *sock, void *buf, size_t len, + } + + while (recv_left > 0) { +- if (recv_ring_get_one(sock, noblock, &pbuf) != 0) { ++ if (recv_ring_get_one(sock, noblock | recvd, &pbuf) != 0) { ++ /* When the buffer is empty, it will be returned directly ++ if in non-blocking mode or if data has already been received */ + break; + } + +-- +2.33.0 + diff --git a/0169-add-tuple_fileter-error-info.patch b/0169-add-tuple_fileter-error-info.patch new file mode 100644 index 0000000..e15770e --- /dev/null +++ b/0169-add-tuple_fileter-error-info.patch @@ -0,0 +1,24 @@ +From e4d3f17fbb3efce9e29c86838a09fa1f9e224fd3 Mon Sep 17 00:00:00 2001 +From: compile_success <980965867@qq.com> +Date: Tue, 16 Apr 2024 03:46:12 +0000 +Subject: [PATCH] add tuple_fileter error info + +--- + src/lstack/core/lstack_cfg.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index b533a33..533eb6c 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -1159,6 +1159,7 @@ static int parse_tuple_filter(void) + return 0; + } + if (g_config_params.use_ltran || g_config_params.listen_shadow) { ++ LSTACK_LOG(ERR, LSTACK, "tuple filter and (ltran or listen_shadow) cannot be enabled at the same time\n"); + return -EINVAL; + } + +-- +2.33.0 + diff --git a/0170-adapt-dpdk-23.11-remove-kni.patch b/0170-adapt-dpdk-23.11-remove-kni.patch new file mode 100644 index 0000000..f264f5d --- /dev/null +++ b/0170-adapt-dpdk-23.11-remove-kni.patch @@ -0,0 +1,80 @@ +From 201e8d1e2fad0d83ea1544fd14b35492d8dd72bc Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Wed, 17 Apr 2024 15:43:07 +0800 +Subject: [PATCH] adapt dpdk-23.11 remove kni + +--- + src/lstack/core/lstack_dpdk.c | 4 +++- + src/lstack/core/lstack_init.c | 4 ++++ + 2 files changed, 7 insertions(+), 1 deletion(-) + +diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c +index 5d90408..016276a 100644 +--- a/src/lstack/core/lstack_dpdk.c ++++ b/src/lstack/core/lstack_dpdk.c +@@ -694,6 +694,7 @@ int32_t dpdk_ethdev_start(void) + return 0; + } + ++#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + int32_t dpdk_init_lstack_kni(void) + { + struct protocol_stack_group *stack_group = get_protocol_stack_group(); +@@ -712,7 +713,6 @@ int32_t dpdk_init_lstack_kni(void) + return 0; + } + +-#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + void dpdk_skip_nic_init(void) + { + /* when lstack init nic again, ltran can't read pkts from nic. unregister pci_bus to avoid init nic in lstack */ +@@ -799,12 +799,14 @@ int32_t init_dpdk_ethdev(void) + } + } + ++#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + if (get_global_cfg_params()->kni_switch && get_global_cfg_params()->is_primary) { + ret = dpdk_init_lstack_kni(); + if (ret < 0) { + return -1; + } + } ++#endif + + return 0; + } +diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c +index 79b4060..c2499d7 100644 +--- a/src/lstack/core/lstack_init.c ++++ b/src/lstack/core/lstack_init.c +@@ -183,6 +183,7 @@ static void gazelle_signal_init(void) + lstack_signal_init(); + } + ++#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + static void set_kni_ip_mac() + { + struct cfg_params *cfg = get_global_cfg_params(); +@@ -230,6 +231,7 @@ static void set_kni_ip_mac() + + posix_api->close_fn(fd); + } ++#endif + + __attribute__((constructor)) void gazelle_network_init(void) + { +@@ -315,9 +317,11 @@ __attribute__((constructor)) void gazelle_network_init(void) + /* lwip initialization */ + lwip_sock_init(); + ++#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + if (get_global_cfg_params()->kni_switch) { + set_kni_ip_mac(); + } ++#endif + + if (set_process_start_flag() != 0) { + gazelle_exit(); +-- +2.33.0 + diff --git a/0171-fix-ioctl-set-failed.patch b/0171-fix-ioctl-set-failed.patch new file mode 100644 index 0000000..e1cfefc --- /dev/null +++ b/0171-fix-ioctl-set-failed.patch @@ -0,0 +1,49 @@ +From 5924fd2879acbb52b12a61380b939cce30a133a9 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Sun, 28 Apr 2024 10:44:15 +0800 +Subject: [PATCH] fix ioctl set failed + +--- + src/lstack/api/lstack_wrap.c | 24 +++++++++++++++++++----- + 1 file changed, 19 insertions(+), 5 deletions(-) + +diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c +index c90aa04..7101d98 100644 +--- a/src/lstack/api/lstack_wrap.c ++++ b/src/lstack/api/lstack_wrap.c +@@ -690,13 +690,27 @@ static int32_t do_select(int32_t nfds, fd_set *readfds, fd_set *writefds, fd_set + if (select_posix_path() == PATH_KERNEL || \ + select_fd_posix_path(_fd, &sock) == PATH_KERNEL) \ + return _fcntl_fn(_fd, _cmd, val); \ +- int32_t ret = _fcntl_fn(_fd, _cmd, val); \ +- if (ret == -1) \ +- return ret; \ +- return _lwip_fcntl(_fd, _cmd, val); \ ++ int32_t ret1 = _fcntl_fn(_fd, _cmd, val); \ ++ if (ret1 == -1) { \ ++ LSTACK_LOG(ERR, LSTACK, "fd(%d) kernel path call failed, errno is %d, maybe not error\n", \ ++ _fd, errno); \ ++ return ret1; \ ++ } \ ++ int32_t ret2 = _lwip_fcntl(_fd, _cmd, val); \ ++ /* ++ * if function not implemented, fcntl get/set context will not be modifyed by user path, ++ * return kernel path result ++ */ \ ++ if (ret2 == -1) { \ ++ if (errno == ENOSYS) { \ ++ return ret1; \ ++ } \ ++ LSTACK_LOG(ERR, LSTACK, "fd(%d) user path call failed, errno is %d, maybe not error\n", \ ++ _fd, errno); \ ++ } \ ++ return ret2; \ + } while (0) + +- + /* -------------------------------------------------------- + * ------- LD_PRELOAD mode replacement interface -------- + * -------------------------------------------------------- +-- +2.33.0 + diff --git a/0172-ltran-memset-quintuple.patch b/0172-ltran-memset-quintuple.patch new file mode 100644 index 0000000..94a2d36 --- /dev/null +++ b/0172-ltran-memset-quintuple.patch @@ -0,0 +1,25 @@ +From 3e10c7661d412082990d88d479c02d77c14fbd8c Mon Sep 17 00:00:00 2001 +From: yinbin6 +Date: Tue, 30 Apr 2024 09:56:59 +0800 +Subject: [PATCH] ltran: memset quintuple + +--- + src/ltran/ltran_forward.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/ltran/ltran_forward.c b/src/ltran/ltran_forward.c +index a5756d7..0658b11 100644 +--- a/src/ltran/ltran_forward.c ++++ b/src/ltran/ltran_forward.c +@@ -251,7 +251,7 @@ static __rte_always_inline int32_t tcp_handle(struct rte_mbuf *m, const struct r + { + struct gazelle_tcp_conn *tcp_conn = NULL; + struct gazelle_tcp_sock *tcp_sock = NULL; +- struct gazelle_quintuple quintuple; ++ struct gazelle_quintuple quintuple = {0}; + + quintuple.dst_ip.u_addr.ip4.addr = ipv4_hdr->dst_addr; + quintuple.src_ip.u_addr.ip4.addr = ipv4_hdr->src_addr; +-- +2.33.0 + diff --git a/0173-gazellectl-add-lwip-stats_proto-print.patch b/0173-gazellectl-add-lwip-stats_proto-print.patch new file mode 100644 index 0000000..82ec1dd --- /dev/null +++ b/0173-gazellectl-add-lwip-stats_proto-print.patch @@ -0,0 +1,69 @@ +From 62297e7fb9299a75bc582b1abb4343e88e5c7c05 Mon Sep 17 00:00:00 2001 +From: ningjin +Date: Thu, 28 Mar 2024 16:05:01 +0800 +Subject: [PATCH] gazellectl add lwip stats_proto print + +--- + src/common/gazelle_dfx_msg.h | 4 ++++ + src/ltran/ltran_dfx.c | 12 +++++++----- + 2 files changed, 11 insertions(+), 5 deletions(-) + +diff --git a/src/common/gazelle_dfx_msg.h b/src/common/gazelle_dfx_msg.h +index 5d626a2..17e1662 100644 +--- a/src/common/gazelle_dfx_msg.h ++++ b/src/common/gazelle_dfx_msg.h +@@ -206,6 +206,10 @@ struct gazelle_stat_lstack_proto { + /* data */ + uint16_t xmit; /* Transmitted packets. */ + uint16_t recv; /* Received packets. */ ++ uint16_t tx_in; /* Transmitted in packets. */ ++ uint16_t tx_out; /* Transmitted out packets. */ ++ uint16_t rx_in; /* Received in packets. */ ++ uint16_t rx_out; /* Received out packets. */ + uint16_t fw; /* Forwarded packets. */ + uint16_t drop; /* Dropped packets. */ + uint16_t chkerr; /* Checksum error. */ +diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c +index c81cce2..f4e55e3 100644 +--- a/src/ltran/ltran_dfx.c ++++ b/src/ltran/ltran_dfx.c +@@ -1114,8 +1114,10 @@ static void gazelle_print_lstack_stat_proto_core(const struct gazelle_stack_dfx_ + const struct gazelle_stat_lstack_proto *proto) + { + printf("\n------ stack tid: %6u ------\n", stat->tid); +- printf("xmit: %u\n", proto->xmit); +- printf("recv: %u\n", proto->recv); ++ printf("tx_in: %u\n", proto->tx_in); ++ printf("tx_out: %u\n", proto->tx_out); ++ printf("rx_in: %u\n", proto->rx_in); ++ printf("rx_out: %u\n", proto->rx_out); + printf("fw: %u\n", proto->fw); + printf("drop: %u\n", proto->drop); + printf("chkerr: %u\n", proto->chkerr); +@@ -1297,11 +1299,11 @@ static void show_usage(void) + " -x, xstats show lstack xstats \n" + " -k, nic-features show state of protocol offload and other features \n" + " -a, aggregatin [time] show lstack send/recv aggregation \n" ++ " -p, protocol {UDP | TCP | ICMP | IP | ETHARP} show lstack protocol statistics \n" + " set: \n" + " loglevel {error | info | debug} set lstack loglevel \n" + " lowpower {0 | 1} set lowpower enable \n" + " [time] measure latency time default 1S, maximum 30mins \n\n" +- " -p, protocol {UDP | TCP | ICMP | IP | ETHARP | IP_FRAG} show lstack protocol statistics \n" + #ifdef GAZELLE_FAULT_INJECT_ENABLE + " *inject params*\n" + " |inject_type | digit_param_1 | digit_param_2 | inject_rule |\n" +@@ -1512,8 +1514,8 @@ static int32_t parse_dfx_lstack_show_proto_args(int32_t argc, char *argv[], stru + int32_t ret; + + char *param = argv[GAZELLE_OPTIONS2_ARG_IDX]; +- if (strcmp(param, "UDP") != 0 && strcmp(param, "TCP") != 0 && strcmp(param, "IP") && +- strcmp(param, "ICMP") && strcmp(param, "ETHARP") != 0) { ++ if ((param == NULL) || (strcmp(param, "UDP") != 0 && strcmp(param, "TCP") != 0 && strcmp(param, "IP") && ++ strcmp(param, "ICMP") && strcmp(param, "ETHARP") != 0)) { + return cmd_index; + } + ret = strncpy_s(req_msg[cmd_index].data.protocol, MAX_PROTOCOL_LENGTH, argv[GAZELLE_OPTIONS2_ARG_IDX], +-- +2.33.0 + diff --git a/0174-CFG-set-multicast-IP-assert.patch b/0174-CFG-set-multicast-IP-assert.patch new file mode 100644 index 0000000..0bdb20e --- /dev/null +++ b/0174-CFG-set-multicast-IP-assert.patch @@ -0,0 +1,28 @@ +From 38f5dbd34dfede9fc4a22c89903132fafc01fc6d Mon Sep 17 00:00:00 2001 +From: yinbin6 +Date: Mon, 29 Apr 2024 17:07:15 +0800 +Subject: [PATCH] CFG:set multicast IP assert + +--- + src/lstack/core/lstack_cfg.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index 533eb6c..319a720 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -244,6 +244,11 @@ static int32_t parse_host_addr(void) + if (g_config_params.host_addr.addr == INADDR_NONE) { + return -EINVAL; + } ++ ++ if (IN_MULTICAST(g_config_params.host_addr.addr)) { ++ LSTACK_PRE_LOG(LSTACK_ERR, "cfg: host_addr:%s should not be a multicast IP.", value); ++ return -EINVAL; ++ } + return 0; + } + +-- +2.33.0 + diff --git a/0175-cfg-devices-must-be-in-bond_slave_mac-for-BONDING_MO.patch b/0175-cfg-devices-must-be-in-bond_slave_mac-for-BONDING_MO.patch new file mode 100644 index 0000000..fef0c39 --- /dev/null +++ b/0175-cfg-devices-must-be-in-bond_slave_mac-for-BONDING_MO.patch @@ -0,0 +1,47 @@ +From 82ad5f93a2bd11411fec78ec7bcb26d6055fdfda Mon Sep 17 00:00:00 2001 +From: zhangmengxuan +Date: Mon, 29 Apr 2024 10:43:37 +0800 +Subject: [PATCH] cfg: devices must be in bond_slave_mac for + BONDING_MODE_ACTIVE + +--- + src/lstack/core/lstack_cfg.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index 533eb6c..8073dd4 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -1210,6 +1210,16 @@ static int32_t parse_bond_miimon(void) + return ret; + } + ++static bool validate_bond_mac(uint8_t *mac_addr, struct rte_ether_addr *bond_slave_mac, int num_slaves) ++{ ++ for (int i = 0; i < num_slaves; i++) { ++ if (memcmp(mac_addr, bond_slave_mac[i].addr_bytes, ETHER_ADDR_LEN) == 0) { ++ return true; ++ } ++ } ++ return false; ++} ++ + static int32_t parse_bond_slave_mac(void) + { + if (g_config_params.bond_mode == -1) { +@@ -1252,6 +1262,12 @@ static int32_t parse_bond_slave_mac(void) + k = k + 1; + } + free(bond_slave_mac_tmp); ++ if (g_config_params.bond_mode == BONDING_MODE_ACTIVE_BACKUP) { ++ if (!validate_bond_mac(g_config_params.mac_addr, g_config_params.bond_slave_mac_addr, GAZELLE_MAX_BOND_NUM)) { ++ LSTACK_PRE_LOG(LSTACK_ERR, "cfg: devices must be in bond_slave_mac for BONDING_MODE_ACTIVE_BACKUP.\n"); ++ return -EINVAL; ++ } ++ } + return ret; + } + +-- +2.33.0 + diff --git a/0176-CFG-fix-multicast-IP-assert-error.patch b/0176-CFG-fix-multicast-IP-assert-error.patch new file mode 100644 index 0000000..ec26a4b --- /dev/null +++ b/0176-CFG-fix-multicast-IP-assert-error.patch @@ -0,0 +1,25 @@ +From f9407c8871223cef6dfbc66afb89a3b1b13b811a Mon Sep 17 00:00:00 2001 +From: yinbin6 +Date: Wed, 8 May 2024 16:32:44 +0800 +Subject: [PATCH] CFG:fix multicast IP assert error + +--- + src/lstack/core/lstack_cfg.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index 7967bb7..9efdbaa 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -245,7 +245,7 @@ static int32_t parse_host_addr(void) + return -EINVAL; + } + +- if (IN_MULTICAST(g_config_params.host_addr.addr)) { ++ if (IN_MULTICAST(ntohl(g_config_params.host_addr.addr))) { + LSTACK_PRE_LOG(LSTACK_ERR, "cfg: host_addr:%s should not be a multicast IP.", value); + return -EINVAL; + } +-- +2.33.0 + diff --git a/0177-fix-mbuf-leak-in-dpdk-23.11-due-to-kni-removed.patch b/0177-fix-mbuf-leak-in-dpdk-23.11-due-to-kni-removed.patch new file mode 100644 index 0000000..042fd04 --- /dev/null +++ b/0177-fix-mbuf-leak-in-dpdk-23.11-due-to-kni-removed.patch @@ -0,0 +1,82 @@ +From 27af442164cce5ccb7df65435f76262ebb2d810e Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Thu, 9 May 2024 15:27:48 +0800 +Subject: [PATCH] fix mbuf leak in dpdk-23.11 due to kni removed + +--- + src/lstack/core/lstack_dpdk.c | 3 +++ + src/lstack/core/lstack_protocol_stack.c | 3 ++- + src/lstack/netif/lstack_ethdev.c | 2 ++ + src/ltran/ltran_forward.c | 5 ++++- + 4 files changed, 11 insertions(+), 2 deletions(-) + +diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c +index 016276a..ec35f9c 100644 +--- a/src/lstack/core/lstack_dpdk.c ++++ b/src/lstack/core/lstack_dpdk.c +@@ -321,6 +321,9 @@ int32_t fill_mbuf_to_ring(struct rte_mempool *mempool, struct rte_ring *ring, ui + ret = gazelle_ring_sp_enqueue(ring, (void **)free_buf, batch); + if (ret == 0) { + LSTACK_LOG(ERR, LSTACK, "cannot enqueue to ring, count: %u\n", batch); ++ for (int i = 0; i < batch; i++) { ++ rte_pktmbuf_free(free_buf[i]); ++ } + return -1; + } + +diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c +index 04d54c5..892c16d 100644 +--- a/src/lstack/core/lstack_protocol_stack.c ++++ b/src/lstack/core/lstack_protocol_stack.c +@@ -937,16 +937,17 @@ void stack_broadcast_arp(struct rte_mbuf *mbuf, struct protocol_stack *cur_stack + + ret = rpc_call_arp(&stack->rpc_queue, mbuf_copy); + if (ret != 0) { ++ rte_pktmbuf_free(mbuf_copy); + return; + } + } ++#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + ret = dpdk_alloc_pktmbuf(cur_stack->rxtx_mbuf_pool, &mbuf_copy, 1, true); + if (ret != 0) { + cur_stack->stats.rx_allocmbuf_fail++; + return; + } + copy_mbuf(mbuf_copy, mbuf); +-#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + kni_handle_tx(mbuf_copy); + #endif + return; +diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c +index 23edc19..048ea92 100644 +--- a/src/lstack/netif/lstack_ethdev.c ++++ b/src/lstack/netif/lstack_ethdev.c +@@ -173,6 +173,8 @@ int32_t eth_dev_poll(void) + } else if (transfer_type == TRANSFER_KERNEL) { + #if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + kni_handle_tx(stack->pkts[i]); ++#else ++ rte_pktmbuf_free(stack->pkts[i]); + #endif + } else { + /* transfer to other thread */ +diff --git a/src/ltran/ltran_forward.c b/src/ltran/ltran_forward.c +index a5756d7..d27f073 100644 +--- a/src/ltran/ltran_forward.c ++++ b/src/ltran/ltran_forward.c +@@ -424,8 +424,11 @@ forward_to_kni: + #if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + if (get_ltran_config()->dpdk.kni_switch == GAZELLE_ON) { + enqueue_rx_packet(get_kni_stack(), m); +- } ++ } else + #endif ++ { ++ rte_pktmbuf_free(m); ++ } + return; + } + +-- +2.33.0 + diff --git a/0178-add-riscv64-support.patch b/0178-add-riscv64-support.patch new file mode 100644 index 0000000..a1cbcb7 --- /dev/null +++ b/0178-add-riscv64-support.patch @@ -0,0 +1,48 @@ +From c17a61a4e7872af8eabdf213f71ff8aad84687ad Mon Sep 17 00:00:00 2001 +From: laokz +Date: Thu, 9 May 2024 18:44:28 +0800 +Subject: [PATCH] add riscv64 support + +--- + src/lstack/Makefile | 2 +- + src/ltran/CMakeLists.txt | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/lstack/Makefile b/src/lstack/Makefile +index d2c039d..ace33bd 100644 +--- a/src/lstack/Makefile ++++ b/src/lstack/Makefile +@@ -109,7 +109,7 @@ else + $(LIB_PATH)/librte_net_virtio.so \ + $(LIB_PATH)/librte_telemetry.so \ + $(LIB_PATH)/librte_pcapng.so +- ifneq ($(ARCH), loongarch64) ++ ifeq ($(filter loongarch64 riscv64, $(ARCH)),) + LIBRTE_LIB += $(LIB_PATH)/librte_net_i40e.so + endif + endif +diff --git a/src/ltran/CMakeLists.txt b/src/ltran/CMakeLists.txt +index 2eb7d70..fee3a94 100644 +--- a/src/ltran/CMakeLists.txt ++++ b/src/ltran/CMakeLists.txt +@@ -54,7 +54,7 @@ if (DPDK_VERSION STREQUAL "19.11") + else() + set(DPDK_LINK_FLAGS "-Wl,-lrte_net_bond -Wl,-lrte_net_hinic -Wl,-lrte_net_ixgbe \ + -Wl,-lpcap -Wl,-lrte_net_pcap -Wl,-lrte_net_virtio -Wl,-lrte_pcapng -Wl,-lrte_telemetry") +- if(NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "loongarch64") ++ if(NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "loongarch64|riscv64") + set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,-lrte_net_i40e") + endif() + endif() +@@ -82,7 +82,7 @@ target_compile_options(ltran PRIVATE -fno-strict-aliasing -D__ARM_FEATURE_CRC32= + -Wdeprecated -Wwrite-strings -Wno-implicit-fallthrough -D_FORTIFY_SOURCE=2 -Wno-error=deprecated-declarations) + + # gcc coredump in openEuler-20.03-LTS-XX aarch64 when add -march=native +-if(NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "sw_64|aarch64|ppc64le" ) ++if(NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "sw_64|aarch64|ppc64le|riscv64" ) + target_compile_options(ltran PRIVATE -march=native -Wcast-align) + endif() + +-- +2.33.0 + diff --git a/0179-dfx-fix-gazellectl-x-for-bond.patch b/0179-dfx-fix-gazellectl-x-for-bond.patch new file mode 100644 index 0000000..f9c46fe --- /dev/null +++ b/0179-dfx-fix-gazellectl-x-for-bond.patch @@ -0,0 +1,59 @@ +From 3c3f69c0ca77b3d05df27aeda2fb7daa9757f50c Mon Sep 17 00:00:00 2001 +From: zhangmengxuan +Date: Mon, 13 May 2024 14:51:18 +0800 +Subject: [PATCH] dfx: fix gazellectl -x for bond + +--- + src/common/gazelle_dfx_msg.h | 1 + + src/lstack/core/lstack_dpdk.c | 2 ++ + src/ltran/ltran_dfx.c | 7 ++++--- + 3 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/common/gazelle_dfx_msg.h b/src/common/gazelle_dfx_msg.h +index 17e1662..9f88203 100644 +--- a/src/common/gazelle_dfx_msg.h ++++ b/src/common/gazelle_dfx_msg.h +@@ -296,6 +296,7 @@ struct bonding { + int32_t miimon; + uint16_t primary_port_id; + uint16_t slaves[RTE_MAX_ETHPORTS]; ++ uint16_t slave_count; + }; + + struct nic_eth_xstats { +diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c +index ec35f9c..f1a22ea 100644 +--- a/src/lstack/core/lstack_dpdk.c ++++ b/src/lstack/core/lstack_dpdk.c +@@ -905,6 +905,8 @@ void dpdk_nic_bond_xstats_get(struct gazelle_stack_dfx_data *dfx, uint16_t port_ + return; + } + ++ dfx->data.nic_xstats.bonding.slave_count = count; ++ + for (int i = 0; i < count; i++) { + dfx->data.nic_xstats.bonding.slaves[i] = slaves[i]; + } +diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c +index f4e55e3..aa08f25 100644 +--- a/src/ltran/ltran_dfx.c ++++ b/src/ltran/ltran_dfx.c +@@ -207,11 +207,12 @@ static void gazelle_print_lstack_xstats(void *buf, const struct gazelle_stat_msg + printf("%s############################\n", nic_stats_border); + printf("Bonding mode: [%d]\n", xstats->bonding.mode); + printf("Bonding miimon: [%d]\n", xstats->bonding.miimon); +- printf("Slaves(%d): [", xstats->port_id); +- for (int i = 0; i < xstats->port_id - 1; i++) { ++ printf("Port range: 0->%d; Bonding port is %d\n", xstats->port_id, xstats->port_id); ++ printf("Slaves(%d): [", xstats->bonding.slave_count); ++ for (int i = 0; i < xstats->bonding.slave_count - 1; i++) { + printf("%d ", xstats->bonding.slaves[i]); + } +- printf("%d]\n", xstats->bonding.slaves[xstats->port_id - 1]); ++ printf("%d]\n", xstats->bonding.slaves[xstats->bonding.slave_count - 1]); + printf("Primary: [%d]\n", xstats->bonding.primary_port_id); + printf("%s############################\n", nic_stats_border); + } +-- +2.33.0 + diff --git a/0180-change-gazelle_stat_lstack_proto-from-u16-to-u64.patch b/0180-change-gazelle_stat_lstack_proto-from-u16-to-u64.patch new file mode 100644 index 0000000..bac10b5 --- /dev/null +++ b/0180-change-gazelle_stat_lstack_proto-from-u16-to-u64.patch @@ -0,0 +1,87 @@ +From f9872991239cc4ddcd9b3c706cf135cdbea28a48 Mon Sep 17 00:00:00 2001 +From: ningjin +Date: Tue, 21 May 2024 10:23:49 +0800 +Subject: [PATCH] change gazelle_stat_lstack_proto from u16 to u64 + +--- + src/common/gazelle_dfx_msg.h | 32 ++++++++++++++++---------------- + src/ltran/ltran_dfx.c | 20 ++++++++++---------- + 2 files changed, 26 insertions(+), 26 deletions(-) + +diff --git a/src/common/gazelle_dfx_msg.h b/src/common/gazelle_dfx_msg.h +index 9f88203..cad7978 100644 +--- a/src/common/gazelle_dfx_msg.h ++++ b/src/common/gazelle_dfx_msg.h +@@ -204,22 +204,22 @@ struct gazelle_stat_lstack_snmp { + /* same as define in lwip/stats.h - struct stats_proto */ + struct gazelle_stat_lstack_proto { + /* data */ +- uint16_t xmit; /* Transmitted packets. */ +- uint16_t recv; /* Received packets. */ +- uint16_t tx_in; /* Transmitted in packets. */ +- uint16_t tx_out; /* Transmitted out packets. */ +- uint16_t rx_in; /* Received in packets. */ +- uint16_t rx_out; /* Received out packets. */ +- uint16_t fw; /* Forwarded packets. */ +- uint16_t drop; /* Dropped packets. */ +- uint16_t chkerr; /* Checksum error. */ +- uint16_t lenerr; /* Invalid length error. */ +- uint16_t memerr; /* Out of memory error. */ +- uint16_t rterr; /* Routing error. */ +- uint16_t proterr; /* Protocol error. */ +- uint16_t opterr; /* Error in options. */ +- uint16_t err; /* Misc error. */ +- uint16_t cachehit; ++ uint64_t xmit; /* Transmitted packets. */ ++ uint64_t recv; /* Received packets. */ ++ uint64_t tx_in; /* Transmitted in packets. */ ++ uint64_t tx_out; /* Transmitted out packets. */ ++ uint64_t rx_in; /* Received in packets. */ ++ uint64_t rx_out; /* Received out packets. */ ++ uint64_t fw; /* Forwarded packets. */ ++ uint64_t drop; /* Dropped packets. */ ++ uint64_t chkerr; /* Checksum error. */ ++ uint64_t lenerr; /* Invalid length error. */ ++ uint64_t memerr; /* Out of memory error. */ ++ uint64_t rterr; /* Routing error. */ ++ uint64_t proterr; /* Protocol error. */ ++ uint64_t opterr; /* Error in options. */ ++ uint64_t err; /* Misc error. */ ++ uint64_t cachehit; + }; + + +diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c +index aa08f25..319f7cd 100644 +--- a/src/ltran/ltran_dfx.c ++++ b/src/ltran/ltran_dfx.c +@@ -1115,16 +1115,16 @@ static void gazelle_print_lstack_stat_proto_core(const struct gazelle_stack_dfx_ + const struct gazelle_stat_lstack_proto *proto) + { + printf("\n------ stack tid: %6u ------\n", stat->tid); +- printf("tx_in: %u\n", proto->tx_in); +- printf("tx_out: %u\n", proto->tx_out); +- printf("rx_in: %u\n", proto->rx_in); +- printf("rx_out: %u\n", proto->rx_out); +- printf("fw: %u\n", proto->fw); +- printf("drop: %u\n", proto->drop); +- printf("chkerr: %u\n", proto->chkerr); +- printf("lenerr: %u\n", proto->lenerr); +- printf("memerr: %u\n", proto->memerr); +- printf("rterr: %u\n", proto->rterr); ++ printf("tx_in: %lu\n", proto->tx_in); ++ printf("tx_out: %lu\n", proto->tx_out); ++ printf("rx_in: %lu\n", proto->rx_in); ++ printf("rx_out: %lu\n", proto->rx_out); ++ printf("fw: %lu\n", proto->fw); ++ printf("drop: %lu\n", proto->drop); ++ printf("chkerr: %lu\n", proto->chkerr); ++ printf("lenerr: %lu\n", proto->lenerr); ++ printf("memerr: %lu\n", proto->memerr); ++ printf("rterr: %lu\n", proto->rterr); + } + + static void gazelle_print_lstack_stat_snmp(void *buf, const struct gazelle_stat_msg_request *req_msg) +-- +2.33.0 + diff --git a/0181-memary-error-fix-some-memary-error.patch b/0181-memary-error-fix-some-memary-error.patch new file mode 100644 index 0000000..8c602ff --- /dev/null +++ b/0181-memary-error-fix-some-memary-error.patch @@ -0,0 +1,45 @@ +From 7b859a1e3dbb8ed719035942040a581982d71508 Mon Sep 17 00:00:00 2001 +From: yinbin6 +Date: Sat, 18 May 2024 17:27:35 +0800 +Subject: [PATCH] memary error: fix some memary error + +--- + src/lstack/core/lstack_protocol_stack.c | 3 ++- + src/lstack/netif/lstack_flow.c | 4 ++++ + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c +index 892c16d..c5a265e 100644 +--- a/src/lstack/core/lstack_protocol_stack.c ++++ b/src/lstack/core/lstack_protocol_stack.c +@@ -626,10 +626,11 @@ int32_t stack_setup_app_thread(void) + + if (stack_thread_init(t_params) == NULL) { + LSTACK_LOG(INFO, LSTACK, "stack setup failed in app thread\n"); ++ free(t_params); + return -1; + } + atomic_fetch_add(&g_stack_group.stack_num, 1); +- ++ free(t_params); + return 0; + } + +diff --git a/src/lstack/netif/lstack_flow.c b/src/lstack/netif/lstack_flow.c +index 4e04209..9e8792c 100644 +--- a/src/lstack/netif/lstack_flow.c ++++ b/src/lstack/netif/lstack_flow.c +@@ -84,6 +84,10 @@ static void add_rule(char* rule_key, struct rte_flow *flow) + HASH_FIND_STR(g_flow_rules, rule_key, rule); + if (rule == NULL) { + rule = (struct flow_rule*)malloc(sizeof(struct flow_rule)); ++ if (rule == NULL) { ++ LSTACK_LOG(ERR, LSTACK, "flow rule add failed. \n"); ++ return; ++ } + strcpy_s(rule->rule_key, RULE_KEY_LEN, rule_key); + HASH_ADD_STR(g_flow_rules, rule_key, rule); + } +-- +2.33.0 + diff --git a/0182-bond-remove-bond-initialization-code-in-dpdk_ethdev_.patch b/0182-bond-remove-bond-initialization-code-in-dpdk_ethdev_.patch new file mode 100644 index 0000000..c672328 --- /dev/null +++ b/0182-bond-remove-bond-initialization-code-in-dpdk_ethdev_.patch @@ -0,0 +1,545 @@ +From 369b298752a84df677300792174f1957fa52cd52 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Tue, 21 May 2024 22:24:39 +0800 +Subject: [PATCH] bond:remove bond initialization code in dpdk_ethdev_init + +--- + src/common/dpdk_common.c | 2 +- + src/lstack/core/lstack_dpdk.c | 364 ++++++++++----------- + src/lstack/include/lstack_dpdk.h | 2 +- + src/lstack/include/lstack_protocol_stack.h | 2 - + 4 files changed, 173 insertions(+), 197 deletions(-) + +diff --git a/src/common/dpdk_common.c b/src/common/dpdk_common.c +index c03b2ec..66ad529 100644 +--- a/src/common/dpdk_common.c ++++ b/src/common/dpdk_common.c +@@ -226,7 +226,7 @@ void eth_params_checksum(struct rte_eth_conf *conf, struct rte_eth_dev_info *dev + // rx vlan filter + if (rx_ol_capa & RTE_ETH_RX_OFFLOAD_VLAN_FILTER) { + rx_ol |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER; +- COMMON_INFO("RTE_ETH_RX_OFFLOAD_VLAN_STRIP\n"); ++ COMMON_INFO("RTE_ETH_RX_OFFLOAD_VLAN_FILTER\n"); + } + + // tx ip +diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c +index f1a22ea..07fffe9 100644 +--- a/src/lstack/core/lstack_dpdk.c ++++ b/src/lstack/core/lstack_dpdk.c +@@ -58,10 +58,14 @@ struct eth_params { + uint16_t nb_rx_desc; + uint16_t nb_tx_desc; + ++ uint32_t reta_mask; ++ + struct rte_eth_conf conf; + struct rte_eth_rxconf rx_conf; + struct rte_eth_txconf tx_conf; + }; ++ ++static struct eth_params g_eth_params; + #if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + struct rte_kni; + static struct rte_bus *g_pci_bus = NULL; +@@ -368,34 +372,6 @@ static int32_t ethdev_port_id(uint8_t *mac) + return port_id; + } + +-static struct eth_params *alloc_eth_params(uint16_t port_id, uint16_t nb_queues) +-{ +- struct eth_params *eth_params = calloc(1, sizeof(struct eth_params)); +- if (eth_params == NULL) { +- return NULL; +- } +- +- eth_params->port_id = port_id; +- eth_params->nb_queues = nb_queues; +- eth_params->nb_rx_desc = get_global_cfg_params()->nic.rxqueue_size; +- eth_params->nb_tx_desc = get_global_cfg_params()->nic.txqueue_size; +- eth_params->conf.link_speeds = RTE_ETH_LINK_SPEED_AUTONEG; +- eth_params->conf.txmode.mq_mode = RTE_ETH_MQ_TX_NONE; +- eth_params->conf.rxmode.mq_mode = RTE_ETH_MQ_RX_NONE; +- +- return eth_params; +-} +- +-uint64_t get_eth_params_rx_ol(void) +-{ +- return get_protocol_stack_group()->rx_offload; +-} +- +-uint64_t get_eth_params_tx_ol(void) +-{ +- return get_protocol_stack_group()->tx_offload; +-} +- + static int eth_params_rss(struct rte_eth_conf *conf, struct rte_eth_dev_info *dev_info) + { + int rss_enable = 0; +@@ -423,6 +399,54 @@ static int eth_params_rss(struct rte_eth_conf *conf, struct rte_eth_dev_info *de + return rss_enable; + } + ++static int eth_params_init(struct eth_params *eth_params, uint16_t port_id, uint16_t nb_queues, int *rss_enable) ++{ ++ struct rte_eth_dev_info dev_info; ++ int ret = rte_eth_dev_info_get(port_id, &dev_info); ++ if (ret != 0) { ++ LSTACK_LOG(ERR, LSTACK, "get dev info ret=%d\n", ret); ++ return ret; ++ } ++ ++ int32_t max_queues = LWIP_MIN(dev_info.max_rx_queues, dev_info.max_tx_queues); ++ if (max_queues < nb_queues) { ++ LSTACK_LOG(ERR, LSTACK, "port_id %d max_queues=%d\n", port_id, max_queues); ++ return -EINVAL; ++ } ++ ++ memset_s(eth_params, sizeof(struct eth_params), 0, sizeof(struct eth_params)); ++ ++ eth_params->port_id = port_id; ++ eth_params->nb_queues = nb_queues; ++ eth_params->nb_rx_desc = get_global_cfg_params()->nic.rxqueue_size; ++ eth_params->nb_tx_desc = get_global_cfg_params()->nic.txqueue_size; ++ eth_params->conf.link_speeds = RTE_ETH_LINK_SPEED_AUTONEG; ++ eth_params->conf.txmode.mq_mode = RTE_ETH_MQ_TX_NONE; ++ eth_params->conf.rxmode.mq_mode = RTE_ETH_MQ_RX_NONE; ++ /* used for tcp port alloc */ ++ eth_params->reta_mask = dev_info.reta_size - 1; ++ ++ eth_params_checksum(ð_params->conf, &dev_info); ++ ++ if (!get_global_cfg_params()->tuple_filter) { ++ *rss_enable = eth_params_rss(ð_params->conf, &dev_info); ++ } else { ++ *rss_enable = 0; ++ } ++ ++ return 0; ++} ++ ++uint64_t get_eth_params_rx_ol(void) ++{ ++ return get_protocol_stack_group()->rx_offload; ++} ++ ++uint64_t get_eth_params_tx_ol(void) ++{ ++ return get_protocol_stack_group()->tx_offload; ++} ++ + static void rss_setup(const int port_id, const uint16_t nb_queues) + { + int ret; +@@ -481,8 +505,10 @@ int32_t dpdk_bond_primary_set(int port_id, int slave_port_id) + return 0; + } + +-int32_t dpdk_ethdev_init(int port_id, bool bond_port) ++int32_t dpdk_ethdev_init(int port_id) + { ++ int ret; ++ int32_t rss_enable = 0; + uint16_t nb_queues = get_global_cfg_params()->num_cpu; + if (get_global_cfg_params()->seperate_send_recv) { + nb_queues = get_global_cfg_params()->num_cpu * 2; +@@ -494,145 +520,55 @@ int32_t dpdk_ethdev_init(int port_id, bool bond_port) + + struct protocol_stack_group *stack_group = get_protocol_stack_group(); + +- if (get_global_cfg_params()->bond_mode < 0) { +- port_id = ethdev_port_id(get_global_cfg_params()->mac_addr); +- if (port_id < 0) { +- LSTACK_LOG(ERR, LSTACK, "ethdev_port_id FAIL port_id=%d\n", port_id); +- return port_id; +- } +- } +- +- struct rte_eth_dev_info dev_info; +- int32_t ret = rte_eth_dev_info_get(port_id, &dev_info); ++ ret = eth_params_init(&g_eth_params, port_id, nb_queues, &rss_enable); + if (ret != 0) { +- LSTACK_LOG(ERR, LSTACK, "get dev info ret=%d\n", ret); ++ LSTACK_LOG(ERR, LSTACK, "eth_params_init failed ret=%d\n", ret); + return ret; + } + +- int32_t max_queues = LWIP_MIN(dev_info.max_rx_queues, dev_info.max_tx_queues); +- if (max_queues < nb_queues) { +- LSTACK_LOG(ERR, LSTACK, "port_id %d max_queues=%d\n", port_id, max_queues); +- return -EINVAL; +- } +- +- if (bond_port) { +- int32_t slave_port_id[GAZELLE_MAX_BOND_NUM]; +- for (int i = 0; i < GAZELLE_MAX_BOND_NUM; i++) { +- if (rte_is_zero_ether_addr(&get_global_cfg_params()->bond_slave_mac_addr[i])) { +- break; +- } +- slave_port_id[i] = ethdev_port_id(get_global_cfg_params()->bond_slave_mac_addr[i].addr_bytes); +- if (slave_port_id[i] < 0) { +- LSTACK_LOG(ERR, LSTACK, "get slave port id failed port = %d\n", slave_port_id[1]); +- return slave_port_id[i]; +- } +- ret = dpdk_ethdev_init(slave_port_id[i], 0); +- if (ret != 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk_ethdev_init failed ret = %d\n", ret); +- return -1; +- } +- ret = rte_eth_promiscuous_enable(slave_port_id[i]); +- if (ret != 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk slave enable promiscuous failed ret = %d\n", ret); +- return -1; +- } +- +- ret = rte_eth_allmulticast_enable(slave_port_id[i]); +- if (ret != 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk slave enable allmulticast failed ret = %d\n", ret); +- return -1; +- } +- +-#if RTE_VERSION >= RTE_VERSION_NUM(23, 11, 0, 0) +- ret = rte_eth_bond_member_add(port_id, slave_port_id[i]); +-#else +- ret = rte_eth_bond_slave_add(port_id, slave_port_id[i]); +-#endif +- if (ret != 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk add slave port failed ret = %d\n", ret); +- return -1; +- } +- +- if (get_global_cfg_params()->bond_mode == BONDING_MODE_ACTIVE_BACKUP) { +- dpdk_bond_primary_set(port_id, slave_port_id[i]); +- } +- +- ret = rte_eth_dev_start(slave_port_id[i]); +- if (ret != 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk start slave port failed ret = %d\n", ret); +- return -1; +- } +- } +- } +- +- struct eth_params *eth_params = alloc_eth_params(port_id, nb_queues); +- if (eth_params == NULL) { +- return -ENOMEM; +- } +- +- if (bond_port) { +- struct rte_eth_dev_info slave_dev_info; +- int slave_id = rte_eth_bond_primary_get(port_id); +- if (slave_id < 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk get bond primary port failed port = %d\n", slave_id); +- free(eth_params); +- return slave_id; +- } +- ret = rte_eth_dev_info_get(slave_id, &slave_dev_info); +- if (ret != 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk get bond dev info failed ret = %d\n", ret); +- free(eth_params); +- return ret; +- } +- dev_info.rx_offload_capa = slave_dev_info.rx_offload_capa; +- dev_info.tx_offload_capa = slave_dev_info.tx_offload_capa; +- dev_info.reta_size = slave_dev_info.reta_size; +- dev_info.flow_type_rss_offloads = slave_dev_info.flow_type_rss_offloads; +- } +- +- eth_params_checksum(ð_params->conf, &dev_info); +- int32_t rss_enable = 0; +- if (!get_global_cfg_params()->tuple_filter) { +- rss_enable = eth_params_rss(ð_params->conf, &dev_info); +- } +- stack_group->eth_params = eth_params; +- stack_group->port_id = eth_params->port_id; +- stack_group->rx_offload = eth_params->conf.rxmode.offloads; +- stack_group->tx_offload = eth_params->conf.txmode.offloads; +- /* used for tcp port alloc */ +- stack_group->reta_mask = dev_info.reta_size - 1; +- stack_group->nb_queues = nb_queues; ++ stack_group->eth_params = &g_eth_params; ++ stack_group->rx_offload = g_eth_params.conf.rxmode.offloads; ++ stack_group->tx_offload = g_eth_params.conf.txmode.offloads; ++ stack_group->port_id = port_id; + + if (get_global_cfg_params()->is_primary) { +- ret = rte_eth_dev_configure(port_id, nb_queues, nb_queues, ð_params->conf); ++ ret = rte_eth_dev_configure(port_id, nb_queues, nb_queues, &stack_group->eth_params->conf); + if (ret < 0) { + LSTACK_LOG(ERR, LSTACK, "cannot config eth dev at port %d: %s\n", port_id, rte_strerror(-ret)); +- stack_group->eth_params = NULL; +- free(eth_params); + return ret; + } + + ret = dpdk_ethdev_start(); + if (ret < 0) { + LSTACK_LOG(ERR, LSTACK, "dpdk_ethdev_start failed ret=%d\n", ret); +- stack_group->eth_params = NULL; +- free(eth_params); + return ret; + } + + if (rss_enable && !get_global_cfg_params()->tuple_filter) { + rss_setup(port_id, nb_queues); +- stack_group->reta_mask = dev_info.reta_size - 1; + } + } + + /* after rte_eth_dev_configure */ + if ((get_global_cfg_params()->nic.vlan_mode != -1) && + ((stack_group->rx_offload & RTE_ETH_RX_OFFLOAD_VLAN_FILTER) == RTE_ETH_RX_OFFLOAD_VLAN_FILTER)) { +- ret = rte_eth_dev_vlan_filter(port_id, get_global_cfg_params()->nic.vlan_mode, 1); +- if (ret != 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk add vlan filter failed ret = %d\n", ret); +- return -1; ++ /* ++ * vlan filter can be configured for switch,nic and software. ++ * bond4/6 mode need enable promiscuous mode, it conflicts with nic vlan filter. ++ * therefore, we can't use nic vlan filter in bond4/6 mode. ++ * 1. use software: need disable vlan strip in nic, the corresponding GRO becomes invalid ++ * GRO does not support vlan pakckets, which affects performance. ++ * 2. use switch: it's a good config ++ */ ++ if ((get_global_cfg_params()->bond_mode != BONDING_MODE_8023AD) && ++ (get_global_cfg_params()->bond_mode != BONDING_MODE_ALB)) { ++ ret = rte_eth_dev_vlan_filter(port_id, get_global_cfg_params()->nic.vlan_mode, 1); ++ if (ret != 0) { ++ LSTACK_LOG(ERR, LSTACK, "dpdk add vlan filter failed ret = %d\n", ret); ++ return -1; ++ } ++ } else { ++ LSTACK_LOG(ERR, LSTACK, "bond4 and bond6 not support set vlan filter in nic\n"); + } + } + +@@ -684,10 +620,6 @@ int32_t dpdk_ethdev_start(void) + } + } + +- if (get_global_cfg_params()->bond_mode >= 0) { +- return 0; +- } +- + ret = rte_eth_dev_start(stack_group->eth_params->port_id); + if (ret < 0) { + LSTACK_LOG(ERR, LSTACK, "cannot start ethdev: %d\n", (-ret)); +@@ -733,77 +665,117 @@ void dpdk_restore_pci(void) + } + #endif + +-int32_t init_dpdk_ethdev(void) ++static int dpdk_bond_create(uint8_t mode, int *slave_port_id, int count) + { +- int32_t ret; ++ int port_id = rte_eth_bond_create("net_bonding0", mode, rte_socket_id()); ++ struct cfg_params *cfg = get_global_cfg_params(); ++ int ret; + +- if (get_global_cfg_params()->bond_mode >= 0) { +- uint8_t socket_id = rte_socket_id(); +- int bond_port_id = rte_eth_bond_create("net_bonding0", get_global_cfg_params()->bond_mode, socket_id); +- if (bond_port_id < 0) { +- LSTACK_LOG(ERR, LSTACK, "get bond port id failed ret=%d\n", bond_port_id); +- return bond_port_id; +- } ++ if (port_id < 0) { ++ LSTACK_LOG(ERR, LSTACK, "get bond port id failed ret=%d\n", port_id); ++ return -1; ++ } + +- ret = dpdk_ethdev_init(bond_port_id, 1); +- if (ret != 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk_ethdev_init failed ret = %d\n", ret); ++ for (int i = 0; i < count; i++) { ++ /* rte_dev_info_get can get correct devinfo after call bond_member_add */ ++#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) ++ ret = rte_eth_bond_slave_add(port_id, slave_port_id[i]); ++#else ++ ret = rte_eth_bond_member_add(port_id, slave_port_id[i]); ++#endif ++ if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "bond add slave devices failed, ret=%d\n", ret); + return -1; + } ++ if (cfg->bond_mode == BONDING_MODE_ACTIVE_BACKUP) { ++ dpdk_bond_primary_set(port_id, slave_port_id[i]); ++ } ++ } + +- ret = rte_eth_bond_xmit_policy_set(bond_port_id, BALANCE_XMIT_POLICY_LAYER34); ++ if (get_global_cfg_params()->bond_mode == BONDING_MODE_8023AD) { ++ ret = rte_eth_bond_8023ad_dedicated_queues_enable(port_id); + if (ret < 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk set bond xmit policy failed ret = %d\n", ret); ++ LSTACK_LOG(ERR, LSTACK, "dpdk enable 8023 dedicated queues failed ret = %d\n", ret); + return -1; + } ++ } + +- if (get_global_cfg_params()->bond_mode == BONDING_MODE_8023AD) { +- ret = rte_eth_bond_8023ad_dedicated_queues_enable(bond_port_id); +- if (ret < 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk enable 8023 dedicated queues failed ret = %d\n", ret); ++ if (dpdk_ethdev_init(port_id) < 0) { ++ LSTACK_LOG(ERR, LSTACK, "dpdk_ethdev_init failed for bond port\n"); ++ return -1; ++ } ++ ++ ret = rte_eth_bond_xmit_policy_set(port_id, BALANCE_XMIT_POLICY_LAYER34); ++ if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "dpdk set bond xmit policy failed ret = %d\n", ret); ++ return -1; ++ } ++ ++ ret = rte_eth_bond_link_monitoring_set(port_id, get_global_cfg_params()->bond_miimon); ++ if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "dpdk set bond link monitoring failed ret = %d\n", ret); ++ return -1; ++ } ++ ++ if ((get_global_cfg_params()->bond_mode == BONDING_MODE_8023AD) || ++ (get_global_cfg_params()->bond_mode == BONDING_MODE_ALB)) { ++ for (int i = 0; i < count; i++) { ++ /* bond port promiscuous only enable primary port */ ++ /* we enable all ports */ ++ ret = rte_eth_promiscuous_enable(slave_port_id[i]); ++ if (ret != 0) { ++ LSTACK_LOG(ERR, LSTACK, "dpdk slave enable promiscuous failed ret = %d\n", ret); + return -1; + } +- } else { +- ret = rte_eth_bond_mode_set(bond_port_id, get_global_cfg_params()->bond_mode); +- if (ret < 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk enable mode set failed ret = %d\n", ret); +- } + } ++ } + +- ret = rte_eth_bond_link_monitoring_set(bond_port_id, get_global_cfg_params()->bond_miimon); +- if (ret < 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk set bond link monitoring failed ret = %d\n", ret); +- return -1; +- } ++ ret = rte_eth_dev_start(port_id); ++ if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "dpdk start bond port failed ret = %d\n", ret); ++ return -1; ++ } + +- ret = rte_eth_promiscuous_enable(bond_port_id); +- if (ret < 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk enable promiscuous failed ret = %d\n", ret); +- return -1; +- } ++ return 0; ++} + +- ret = rte_eth_allmulticast_enable(bond_port_id); +- if (ret < 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk enable allmulticast failed ret = %d\n", ret); +- return -1; ++int32_t init_dpdk_ethdev(void) ++{ ++ int32_t ret; ++ int slave_port_id[GAZELLE_MAX_BOND_NUM]; ++ int port_id; ++ struct cfg_params *cfg = get_global_cfg_params(); ++ int i; ++ ++ if (cfg->bond_mode >= 0) { ++ for (i = 0; i < GAZELLE_MAX_BOND_NUM; i++) { ++ if (rte_is_zero_ether_addr(&cfg->bond_slave_mac_addr[i])) { ++ break; ++ } ++ slave_port_id[i] = ethdev_port_id(cfg->bond_slave_mac_addr[i].addr_bytes); ++ ret = dpdk_ethdev_init(slave_port_id[i]); ++ if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "slave port(%d) init failed, ret=%d\n", slave_port_id[i], ret); ++ return -1; ++ } + } + +- ret = rte_eth_dev_start(bond_port_id); ++ ret = dpdk_bond_create(cfg->bond_mode, slave_port_id, i); + if (ret < 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk start bond port failed ret = %d\n", ret); ++ LSTACK_LOG(ERR, LSTACK, "bond device create failed, ret=%d\n", ret); + return -1; + } +- + } else { +- ret = dpdk_ethdev_init(0, 0); ++ port_id = ethdev_port_id(cfg->mac_addr); ++ ret = dpdk_ethdev_init(port_id); + if (ret != 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk_ethdev_init failed\n"); ++ LSTACK_LOG(ERR, LSTACK, "dpdk_ethdev_init failed, port id=%d\n", port_id); + return -1; + } + } + + #if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) +- if (get_global_cfg_params()->kni_switch && get_global_cfg_params()->is_primary) { ++ if (cfg->kni_switch && cfg->is_primary) { + ret = dpdk_init_lstack_kni(); + if (ret < 0) { + return -1; +@@ -817,7 +789,13 @@ int32_t init_dpdk_ethdev(void) + bool port_in_stack_queue(gz_addr_t *src_ip, gz_addr_t *dst_ip, uint16_t src_port, uint16_t dst_port) + { + struct protocol_stack_group *stack_group = get_protocol_stack_group(); +- if (stack_group->reta_mask == 0 || stack_group->nb_queues <= 1) { ++ ++ /* ltran mode */ ++ if (stack_group->eth_params == NULL) { ++ return true; ++ } ++ ++ if (stack_group->eth_params->reta_mask == 0 || stack_group->eth_params->nb_queues <= 1) { + return true; + } + +@@ -840,10 +818,10 @@ bool port_in_stack_queue(gz_addr_t *src_ip, gz_addr_t *dst_ip, uint16_t src_port + hash = rte_softrss((uint32_t *)&tuple, RTE_THASH_V6_L4_LEN, g_default_rss_key); + } + +- uint32_t reta_index = hash & stack_group->reta_mask; ++ uint32_t reta_index = hash & stack_group->eth_params->reta_mask; + + struct protocol_stack *stack = get_protocol_stack(); +- return (reta_index % stack_group->nb_queues) == stack->queue_id; ++ return (reta_index % stack_group->eth_params->nb_queues) == stack->queue_id; + } + + static int dpdk_nic_xstats_value_get(uint64_t *values, unsigned int len, uint16_t *ports, unsigned int count) +diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h +index fe3d07b..dff1e44 100644 +--- a/src/lstack/include/lstack_dpdk.h ++++ b/src/lstack/include/lstack_dpdk.h +@@ -46,7 +46,7 @@ struct rte_mempool *create_mempool(const char *name, uint32_t count, uint32_t si + uint32_t flags, int32_t idx); + int32_t create_shared_ring(struct protocol_stack *stack); + void lstack_log_level_init(void); +-int dpdk_ethdev_init(int port_id, bool bond_port); ++int dpdk_ethdev_init(int port_id); + int dpdk_ethdev_start(void); + #if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0) + void dpdk_skip_nic_init(void); +diff --git a/src/lstack/include/lstack_protocol_stack.h b/src/lstack/include/lstack_protocol_stack.h +index df0902d..93fa40c 100644 +--- a/src/lstack/include/lstack_protocol_stack.h ++++ b/src/lstack/include/lstack_protocol_stack.h +@@ -92,8 +92,6 @@ struct protocol_stack_group { + uint16_t port_id; + uint64_t rx_offload; + uint64_t tx_offload; +- uint32_t reta_mask; +- uint16_t nb_queues; + struct rte_mempool *kni_pktmbuf_pool; + struct eth_params *eth_params; + struct protocol_stack *stacks[PROTOCOL_STACK_MAX]; +-- +2.33.0 + diff --git a/0183-make-rpc_msg_max-recv_ring_size-configurable.patch b/0183-make-rpc_msg_max-recv_ring_size-configurable.patch new file mode 100644 index 0000000..ae786ca --- /dev/null +++ b/0183-make-rpc_msg_max-recv_ring_size-configurable.patch @@ -0,0 +1,169 @@ +From 55ed3c6aaccf320a7d3240753a5aabe400ac4bd3 Mon Sep 17 00:00:00 2001 +From: yinbin6 +Date: Fri, 7 Jun 2024 17:06:50 +0800 +Subject: [PATCH] make rpc_msg_max recv_ring_size-configurable + + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index 9efdbaa..0e5fbf3 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -68,6 +68,7 @@ static int32_t parse_nic_read_number(void); + static int32_t parse_tcp_conn_count(void); + static int32_t parse_mbuf_count_per_conn(void); + static int32_t parse_send_ring_size(void); ++static int32_t parse_recv_ring_size(void); + static int32_t parse_num_process(void); + static int32_t parse_process_numa(void); + static int32_t parse_process_index(void); +@@ -83,6 +84,7 @@ static int32_t parse_nic_txqueue_size(void); + static int32_t parse_stack_thread_mode(void); + static int32_t parse_nic_vlan_mode(void); + static int32_t parse_defaule_nonblock_mode(void); ++static int32_t parse_rpc_msg_max(void); + + #define PARSE_ARG(_arg, _arg_string, _default_val, _min_val, _max_val, _ret) \ + do { \ +@@ -132,6 +134,7 @@ static struct config_vector_t g_config_tbl[] = { + { "rpc_number", parse_rpc_number }, + { "nic_read_number", parse_nic_read_number }, + { "send_ring_size", parse_send_ring_size }, ++ { "recv_ring_size", parse_recv_ring_size }, + { "num_process", parse_num_process }, + { "process_numa", parse_process_numa }, + { "process_idx", parse_process_index }, +@@ -146,6 +149,7 @@ static struct config_vector_t g_config_tbl[] = { + { "stack_thread_mode", parse_stack_thread_mode }, + { "nic_vlan_mode", parse_nic_vlan_mode }, + { "nonblock_mode", parse_defaule_nonblock_mode }, ++ { "rpc_msg_max", parse_rpc_msg_max }, + { NULL, NULL } + }; + +@@ -908,6 +912,14 @@ static int32_t parse_send_ring_size(void) + return ret; + } + ++static int32_t parse_recv_ring_size(void) ++{ ++ int32_t ret; ++ /* recv ring size default value is 128 */ ++ PARSE_ARG(g_config_params.recv_ring_size, "recv_ring_size", 128, 1, SOCK_RECV_RING_SIZE_MAX, ret); ++ return ret; ++} ++ + static int32_t parse_mbuf_count_per_conn(void) + { + int32_t ret; +@@ -1356,3 +1368,15 @@ static int32_t parse_defaule_nonblock_mode(void) + } + return ret; + } ++ ++static int32_t parse_rpc_msg_max(void) ++{ ++ int32_t ret; ++ PARSE_ARG(g_config_params.rpc_msg_max, "rpc_msg_max", 4096, 1, 8192, ret); ++ if (ret != 0) { ++ LSTACK_PRE_LOG(LSTACK_ERR, "cfg: invalid rpc msg max value %d ret=%d. only support 1~8192\n", ++ g_config_params.rpc_msg_max, ret); ++ } ++ return ret; ++} ++ +diff --git a/src/lstack/core/lstack_thread_rpc.c b/src/lstack/core/lstack_thread_rpc.c +index 30bd827..b98ba84 100644 +--- a/src/lstack/core/lstack_thread_rpc.c ++++ b/src/lstack/core/lstack_thread_rpc.c +@@ -13,6 +13,7 @@ + #include + + #include "lstack_log.h" ++#include "lstack_cfg.h" + #include "lstack_dpdk.h" + #include "lstack_rpc_proc.h" + #include "lstack_stack_stat.h" +@@ -71,7 +72,7 @@ static struct rpc_msg *rpc_msg_alloc(rpc_msg_func func) + exit(-1); + } + +- g_rpc_pool->mempool = create_mempool("rpc_pool", RPC_MSG_MAX, sizeof(struct rpc_msg), ++ g_rpc_pool->mempool = create_mempool("rpc_pool", get_global_cfg_params()->rpc_msg_max, sizeof(struct rpc_msg), + 0, rte_gettid()); + if (g_rpc_pool->mempool == NULL) { + LSTACK_LOG(INFO, LSTACK, "rpc_pool create failed, errno is %d\n", errno); +diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h +index a00e47a..94878de 100644 +--- a/src/lstack/include/lstack_cfg.h ++++ b/src/lstack/include/lstack_cfg.h +@@ -110,6 +110,7 @@ struct cfg_params { + struct secondary_attach_arg sec_attach_arg; + char unix_socket_filename[NAME_MAX]; + uint16_t send_ring_size; ++ uint16_t recv_ring_size; + bool tuple_filter; + int8_t bond_mode; + int32_t bond_miimon; +@@ -119,6 +120,7 @@ struct cfg_params { + struct cfg_nic_params nic; + bool stack_mode_rtc; + bool nonblock_mode; ++ uint32_t rpc_msg_max; + }; + + struct cfg_params *get_global_cfg_params(void); +diff --git a/src/lstack/include/lstack_protocol_stack.h b/src/lstack/include/lstack_protocol_stack.h +index 93fa40c..c210ab9 100644 +--- a/src/lstack/include/lstack_protocol_stack.h ++++ b/src/lstack/include/lstack_protocol_stack.h +@@ -25,8 +25,9 @@ + #include "lstack_ethdev.h" + #include "gazelle_opt.h" + +-#define SOCK_RECV_RING_SIZE (128) ++#define SOCK_RECV_RING_SIZE (get_global_cfg_params()->recv_ring_size) + #define SOCK_RECV_FREE_THRES (32) ++#define SOCK_RECV_RING_SIZE_MAX (2048) + #define SOCK_SEND_RING_SIZE_MAX (2048) + #define SOCK_SEND_REPLENISH_THRES (16) + #define WAKEUP_MAX_NUM (32) +diff --git a/src/lstack/include/lstack_thread_rpc.h b/src/lstack/include/lstack_thread_rpc.h +index 8e97c11..0c51848 100644 +--- a/src/lstack/include/lstack_thread_rpc.h ++++ b/src/lstack/include/lstack_thread_rpc.h +@@ -26,8 +26,6 @@ + #define MSG_ARG_4 (4) + #define RPM_MSG_ARG_SIZE (5) + +-#define RPC_MSG_MAX 4096 +-#define RPC_MSG_MASK (RPC_MSG_MAX - 1) + typedef struct lockless_queue rpc_queue; + + struct rpc_stats { +diff --git a/src/lstack/lstack.conf b/src/lstack/lstack.conf +index a7f4e75..4c3784f 100644 +--- a/src/lstack/lstack.conf ++++ b/src/lstack/lstack.conf +@@ -22,8 +22,12 @@ tcp_conn_count = 1500 + mbuf_count_per_conn = 170 + + # send ring size, default is 32, max is 2048 ++# if udp pktlen exceeds 45952(32 * 1436)B, send_ring_size must be at least 64. + send_ring_size = 32 + ++#recv ring size, default is 128, max is 2048 ++recv_ring_size = 128 ++ + #protocol stack thread per loop params + #read data form protocol stack into recv_ring + read_connect_number = 4 +@@ -67,3 +71,6 @@ nic_vlan_mode=-1 + bond_mode=-1 + #bond slave mac, separated by ; , only support 2 slave mac + #bond_slave_mac="aa:bb:cc:dd:ee:ff;gg:hh:ii:jj:kk:ll" ++ ++#maximum number of rpc memory pools ++rpc_msg_max=4096 +-- +2.33.0 + diff --git a/0184-EPOLL-fix-coredump-while-event-count-exceed-maxevent.patch b/0184-EPOLL-fix-coredump-while-event-count-exceed-maxevent.patch new file mode 100644 index 0000000..b80b273 --- /dev/null +++ b/0184-EPOLL-fix-coredump-while-event-count-exceed-maxevent.patch @@ -0,0 +1,46 @@ +From e3c12e9d73678b3c5445f770c929e035ef1c4997 Mon Sep 17 00:00:00 2001 +From: yinbin6 +Date: Fri, 7 Jun 2024 11:13:08 +0800 +Subject: [PATCH] EPOLL: fix coredump while event count exceed maxevents + +--- + src/lstack/api/lstack_epoll.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c +index c8a2e43..28a3dd9 100644 +--- a/src/lstack/api/lstack_epoll.c ++++ b/src/lstack/api/lstack_epoll.c +@@ -488,7 +488,14 @@ int32_t epoll_lwip_event_nolock(struct wakeup_poll *wakeup, struct epoll_event * + list_del_node_null(node); + continue; + } +- ++ ++ if (event_num >= maxevents) { ++ /* move list head after the current node, and start traversing from this node next time */ ++ list_del_node_null(&wakeup->event_list); ++ list_add_node(node, &wakeup->event_list); ++ break; ++ } ++ + events[event_num].events = sock->events & sock->epoll_events; + events[event_num].data = sock->ep_data; + event_num++; +@@ -504,13 +511,6 @@ int32_t epoll_lwip_event_nolock(struct wakeup_poll *wakeup, struct epoll_event * + list_del_node_null(node); + sock->epoll_events = 0; + } +- +- if (event_num >= maxevents) { +- /* move list head after the current node, and start traversing from this node next time */ +- list_del_node_null(&wakeup->event_list); +- list_add_node(node, &wakeup->event_list); +- break; +- } + } + + return event_num; +-- +2.33.0 + diff --git a/0185-fix-fin-pack-free-coredump.patch b/0185-fix-fin-pack-free-coredump.patch new file mode 100644 index 0000000..22aa7d1 --- /dev/null +++ b/0185-fix-fin-pack-free-coredump.patch @@ -0,0 +1,25 @@ +From 8bcbc7ef61b9193da5d3deb519211a2406564298 Mon Sep 17 00:00:00 2001 +From: compile_success <980965867@qq.com> +Date: Fri, 7 Jun 2024 01:51:34 +0000 +Subject: [PATCH] fix fin pack free coredump + +--- + src/lstack/core/lstack_lwip.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c +index 667ffd7..628319c 100644 +--- a/src/lstack/core/lstack_lwip.c ++++ b/src/lstack/core/lstack_lwip.c +@@ -88,7 +88,7 @@ static void reset_sock_data(struct lwip_sock *sock) + sock->remain_len = 0; + sock->already_bind_numa = 0; + +- if (sock->recv_lastdata) { ++ if (sock->recv_lastdata && sock->recv_lastdata != (void *)&fin_packet) { + pbuf_free(sock->recv_lastdata); + } + sock->recv_lastdata = NULL; +-- +2.33.0 + diff --git a/0186-fix-MySQL-shutdown-cmd.patch b/0186-fix-MySQL-shutdown-cmd.patch new file mode 100644 index 0000000..fa2d7ee --- /dev/null +++ b/0186-fix-MySQL-shutdown-cmd.patch @@ -0,0 +1,95 @@ +From 1431fd828005acb2aa7df1844cdec62e21f50769 Mon Sep 17 00:00:00 2001 +From: yangchen +Date: Wed, 5 Jun 2024 12:56:52 +0800 +Subject: [PATCH] fix MySQL shutdown cmd + +--- + src/lstack/api/lstack_epoll.c | 14 ++++++-------- + src/lstack/include/posix/lstack_epoll.h | 4 ++-- + 2 files changed, 8 insertions(+), 10 deletions(-) + +diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c +index c8a2e43..1d6ae52 100644 +--- a/src/lstack/api/lstack_epoll.c ++++ b/src/lstack/api/lstack_epoll.c +@@ -144,7 +144,7 @@ void wakeup_stack_epoll(struct protocol_stack *stack) + if (__atomic_load_n(&wakeup->in_wait, __ATOMIC_ACQUIRE)) { + __atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE); + rte_mb(); +- pthread_mutex_unlock(&wakeup->wait); ++ sem_post(&wakeup->wait); + stack->stats.wakeup_events++; + } + +@@ -258,12 +258,11 @@ int32_t lstack_do_epoll_create(int32_t fd) + init_list_node_null(&wakeup->wakeup_list[i]); + } + +- if (pthread_mutex_init(&wakeup->wait, NULL) != 0) { ++ if (sem_init(&wakeup->wait, 0, 0) != 0) { + posix_api->close_fn(fd); + free(wakeup); + GAZELLE_RETURN(EINVAL); + } +- pthread_mutex_trylock(&wakeup->wait); + __atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE); + + struct protocol_stack_group *stack_group = get_protocol_stack_group(); +@@ -337,7 +336,7 @@ int32_t lstack_epoll_close(int32_t fd) + list_del_node_null(&wakeup->poll_list); + pthread_spin_unlock(&stack_group->poll_list_lock); + +- pthread_mutex_destroy(&wakeup->wait); ++ sem_destroy(&wakeup->wait); + + free(wakeup); + sock->wakeup = NULL; +@@ -609,9 +608,9 @@ int32_t lstack_block_wait(struct wakeup_poll *wakeup, int32_t timeout) + if (timeout > 0) { + struct timespec timespec; + ms_to_timespec(×pec, timeout); +- ret = pthread_mutex_timedlock(&wakeup->wait, ×pec); ++ ret = sem_timedwait(&wakeup->wait, ×pec); + } else { +- ret = pthread_mutex_lock(&wakeup->wait); ++ ret = sem_wait(&wakeup->wait); + } + + if (__atomic_load_n(&wakeup->in_wait, __ATOMIC_ACQUIRE)) { +@@ -714,10 +713,9 @@ int32_t lstack_rtw_epoll_wait(int32_t epfd, struct epoll_event* events, int32_t + + static int32_t init_poll_wakeup_data(struct wakeup_poll *wakeup) + { +- if (pthread_mutex_init(&wakeup->wait, NULL) != 0) { ++ if (sem_init(&wakeup->wait, 0, 0) != 0) { + GAZELLE_RETURN(EINVAL); + } +- pthread_mutex_trylock(&wakeup->wait); + __atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE); + + for (uint32_t i = 0; i < PROTOCOL_STACK_MAX; i++) { +diff --git a/src/lstack/include/posix/lstack_epoll.h b/src/lstack/include/posix/lstack_epoll.h +index 59b5ef7..a7164f4 100644 +--- a/src/lstack/include/posix/lstack_epoll.h ++++ b/src/lstack/include/posix/lstack_epoll.h +@@ -37,7 +37,7 @@ struct protocol_stack; + struct wakeup_poll { + /* stack thread read frequently */ + enum wakeup_type type; +- pthread_mutex_t wait __rte_cache_aligned; ++ sem_t wait; + bool in_wait; + struct list_node wakeup_list[PROTOCOL_STACK_MAX]; + bool have_kernel_event; +@@ -87,7 +87,7 @@ static inline void lstack_block_wakeup(struct wakeup_poll *wakeup) + if (wakeup && __atomic_load_n(&wakeup->in_wait, __ATOMIC_ACQUIRE)) { + __atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE); + rte_mb(); +- pthread_mutex_unlock(&wakeup->wait); ++ sem_post(&wakeup->wait); + } + } + +-- +2.33.0 + diff --git a/0187-cfg-remove-map-perfect-flag-in-lstack.conf.patch b/0187-cfg-remove-map-perfect-flag-in-lstack.conf.patch new file mode 100644 index 0000000..40d63be --- /dev/null +++ b/0187-cfg-remove-map-perfect-flag-in-lstack.conf.patch @@ -0,0 +1,31 @@ +From 9cd0a7ebb73b882ef3ac968795fb22ca78fb33cc Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Wed, 29 May 2024 16:20:59 +0800 +Subject: [PATCH] cfg: remove map-perfect flag in lstack.conf + +This parameter is used in ltran mode. +By defualt, ltran mode is not used, so remove it. +--- + src/lstack/lstack.conf | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/lstack/lstack.conf b/src/lstack/lstack.conf +index 07a6092..0b7dbc9 100644 +--- a/src/lstack/lstack.conf ++++ b/src/lstack/lstack.conf +@@ -8,10 +8,11 @@ + # PURPOSE. + # See the Mulan PSL v2 for more details. + +-dpdk_args=["--socket-mem", "2048,0,0,0", "--huge-dir", "/mnt/hugepages-lstack", "--proc-type", "primary", "--legacy-mem", "--map-perfect"] ++dpdk_args=["--socket-mem", "2048,0,0,0", "--huge-dir", "/mnt/hugepages-lstack", "--proc-type", "primary", "--legacy-mem"] + + stack_thread_mode="run-to-wakeup" + ++#ltran mode need add "--map-perfect" in dpdk_args + use_ltran=0 + kni_switch=0 + +-- +2.33.0 + diff --git a/gazelle.spec b/gazelle.spec index f716297..c1684d7 100644 --- a/gazelle.spec +++ b/gazelle.spec @@ -2,7 +2,7 @@ Name: gazelle Version: 1.0.2 -Release: 31 +Release: 41 Summary: gazelle is a high performance user-mode stack License: MulanPSL-2.0 URL: https://gitee.com/openeuler/gazelle @@ -180,7 +180,30 @@ Patch9160: 0160-warp-add-configuration-check-with-host_addr-and-serv.patch Patch9161: 0161-add-latency-nodes-READ_APP_CALL-WRITE_RPC_MSG.patch Patch9162: 0162-fix-vlan-filter-can-be-added-when-vlan_mode-1.patch Patch9163: 0163-Add-support-for-arch-ppc64le.patch - +Patch9164: 0164-dfx-support-get-nic-bond-status.patch +Patch9165: 0165-remove-dpdk_skip_nic_init-for-dpdk-23.11.patch +Patch9166: 0166-gazellectl-add-lwip-stats_proto-print.patch +Patch9167: 0167-fix-port-not-support-vlan-filter.patch +Patch9168: 0168-fix-tcp-recv-does-not-return-pkg-when-ring-buffer-is.patch +Patch9169: 0169-add-tuple_fileter-error-info.patch +Patch9170: 0170-adapt-dpdk-23.11-remove-kni.patch +Patch9171: 0171-fix-ioctl-set-failed.patch +Patch9172: 0172-ltran-memset-quintuple.patch +Patch9173: 0173-gazellectl-add-lwip-stats_proto-print.patch +Patch9174: 0174-CFG-set-multicast-IP-assert.patch +Patch9175: 0175-cfg-devices-must-be-in-bond_slave_mac-for-BONDING_MO.patch +Patch9176: 0176-CFG-fix-multicast-IP-assert-error.patch +Patch9177: 0177-fix-mbuf-leak-in-dpdk-23.11-due-to-kni-removed.patch +Patch9178: 0178-add-riscv64-support.patch +Patch9179: 0179-dfx-fix-gazellectl-x-for-bond.patch +Patch9180: 0180-change-gazelle_stat_lstack_proto-from-u16-to-u64.patch +Patch9181: 0181-memary-error-fix-some-memary-error.patch +Patch9182: 0182-bond-remove-bond-initialization-code-in-dpdk_ethdev_.patch +Patch9183: 0183-make-rpc_msg_max-recv_ring_size-configurable.patch +Patch9184: 0184-EPOLL-fix-coredump-while-event-count-exceed-maxevent.patch +Patch9185: 0185-fix-fin-pack-free-coredump.patch +Patch9186: 0186-fix-MySQL-shutdown-cmd.patch +Patch9187: 0187-cfg-remove-map-perfect-flag-in-lstack.conf.patch %description %{name} is a high performance user-mode stack. @@ -221,6 +244,50 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b %config(noreplace) %{conf_path}/ltran.conf %changelog +* Fri Jun 14 2024 yinbin6 - 1.0.2-41 +- cfg: remove map-perfect flag in lstack.conf +- fix MySQL shutdown cmd +- fix fin pack free coredump + +* Fri June 7 2024 yinbin6 - 1.0.2-40 +- make rpc_msg_max recv_ring_size configurable +- EPOLL: fix coredump while eventcount exceed maxevent + +* Fri May 31 2024 yinbin6 - 1.0.2-39 +- bond:remove bond initialization code in dpdk_ethdev_init + +* Fri May 24 2024 yinbin6 - 1.0.2-38 +- memary error: fix some memary error +- change gazelle_stat_lstack_proto from u16 to u64 + +* Thu May 16 2024 yinbin6 - 1.0.2-37 +- dfx: fix gazellectl -x for bond + +* Fri May 10 2024 yangchen555 - 1.0.2-36 +- add riscv64 support +- fix mbuf leak in dpdk-23.11 due to kni removed + +* Thu May 9 2024 yinbin6 - 1.0.2-35 +- CFG:fix multicast IP assert error +- cfg: devices must be in bond_slave_mac for BONDING_MODE_ACTIVE +- CFG:set multicast IP assert +- gazellectl add lwip stats_proto print +- ltran: memset quintuple + +* Sun Apr 28 2024 yinbin6 - 1.0.2-34 +- fix ioctl set failed + +* Fri Apr 19 2024 yangchen555 - 1.0.2-33 +- adapt dpdk-23.11 remove kni +- add tuple_fileter error info +- fix tcp recv does not return pkg when ring buffer is empty + +* Fri Apr 12 2024 yinbin6 - 1.0.2-32 +- fix port not support vlan filter +- gazellectl add lwip stats_proto print +- remove dpdk_skip_nic_init for dpdk-23.11 +- dfx: support get nic bond status + * Sun Apr 7 2024 yinbin6 - 1.0.2-31 - Add support for arch ppc64le