diff options
| author | songyanchao <[email protected]> | 2022-09-05 07:21:04 +0000 |
|---|---|---|
| committer | songyanchao <[email protected]> | 2022-09-05 07:21:04 +0000 |
| commit | d4df72d27249bb34806d92745509d7b4e48b04c4 (patch) | |
| tree | 8976f3982997ad71051799247e107bf125c060de | |
| parent | 976bd3fdd8e76e1d75fd7ba4579d4931a4083bb1 (diff) | |
🎈 perf(TSG-11429): 优化eth_ingress节点处理流程
优化eth_ingress节点处理流程
| -rw-r--r-- | service/src/node_eth_ingress.c | 102 | ||||
| -rw-r--r-- | service/src/node_etherfabric.c | 4 |
2 files changed, 44 insertions, 62 deletions
diff --git a/service/src/node_eth_ingress.c b/service/src/node_eth_ingress.c index 1b26a51..b30d805 100644 --- a/service/src/node_eth_ingress.c +++ b/service/src/node_eth_ingress.c @@ -37,7 +37,7 @@ enum { /* Eth Ingress Management Struct */ struct eth_ingress_ip_listen_management { - uint16_t listen_num; + uint16_t listen_ip_num_v4; uint32_t listen_ip_v4[MR_ETH_INGRESS_MAX_LISTEN_IP]; }; @@ -70,13 +70,12 @@ void dump_ip_listen_rule(struct eth_ingress_ip_listen_management * ip_listen_man { struct in_addr listen_addr; - if (ip_listen_manage->listen_num > 0) + if (ip_listen_manage->listen_ip_num_v4 > 0) { MR_INFO(" "); MR_INFO("Eth Ingress Config:"); - MR_INFO(" Total Listen Ip Num : %u",ip_listen_manage->listen_num); - - for (int i = 0; i < ip_listen_manage->listen_num; i++) + MR_INFO(" Total Listen Ip Num : %u",ip_listen_manage->listen_ip_num_v4); + for (int i = 0; i < ip_listen_manage->listen_ip_num_v4; i++) { listen_addr.s_addr = ip_listen_manage->listen_ip_v4[i]; MR_INFO(" Listen Ip : %s",inet_ntoa(listen_addr)); @@ -85,16 +84,28 @@ void dump_ip_listen_rule(struct eth_ingress_ip_listen_management * ip_listen_man } /* Local Ip Check */ -int listen_ip_check(struct eth_ingress_ip_listen_management * ip_listen_manage,struct rte_ipv4_hdr * ipv4_hdr) +int listen_ip_check(struct node_eth_ingress_main * eth_ingress_main,struct pkt_head_info * _pkt_head_info,rte_graph_t graph_id) { - for (int i = 0; i < ip_listen_manage->listen_num; i++) + struct eth_ingress_ip_listen_management * ip_listen_manage = ð_ingress_main->ip_listen_manage; + + if (_pkt_head_info->ip_version == MR_NODE_COMMON_IP_VERSION_V4) { - if (ip_listen_manage->listen_ip_v4[i] == ipv4_hdr->dst_addr) + for (int i = 0; i < ip_listen_manage->listen_ip_num_v4; i++) { - return RT_SUCCESS; + if (ip_listen_manage->listen_ip_v4[i] == _pkt_head_info->_ipv4_hdr->dst_addr) + { + MR_ETH_INGRESS_STAT_ADD(eth_ingress_main,graph_id,hit_pkts_v4,1); + return RT_SUCCESS; + } } + MR_ETH_INGRESS_STAT_ADD(eth_ingress_main,graph_id,miss_pkts_v4,1); + } + else if (_pkt_head_info->ip_version == MR_NODE_COMMON_IP_VERSION_V6) + { + /* Check IPv6 Pkt But Current Not Support */ + MR_ETH_INGRESS_STAT_ADD(eth_ingress_main,graph_id,miss_pkts_v6,1); + return RT_ERR; } - return RT_ERR; } @@ -119,29 +130,27 @@ int eth_ingress_init(struct sc_main * sc) sc->eth_ingress_node_main = eth_ingress_main; global_eth_ingress_main = eth_ingress_main; - device_attribute_table_init(sc,eth_ingress_main); return RT_SUCCESS; } /************************************* Eth Ingress Public Func **************************************/ /* Eth Ingress Update IP Listen Number */ -int eth_ingress_update_ip_listen_num(uint16_t num,uint32_t * listen_ip) +int eth_ingress_update_ip_listen_num_v4(uint16_t num,uint32_t * listen_ip) { struct eth_ingress_ip_listen_management * ip_listen_manage = NULL; - ip_listen_manage = &global_eth_ingress_main->ip_listen_manage; for (uint16_t i = 0; i < num; i++) { - if (ip_listen_manage->listen_num >= MR_ETH_INGRESS_MAX_LISTEN_IP) + if (ip_listen_manage->listen_ip_num_v4 >= MR_ETH_INGRESS_MAX_LISTEN_IP) { return RT_ERR; } else { - ip_listen_manage->listen_ip_v4[ip_listen_manage->listen_num] = listen_ip[i]; - ip_listen_manage->listen_num ++; + ip_listen_manage->listen_ip_v4[ip_listen_manage->listen_ip_num_v4] = listen_ip[i]; + ip_listen_manage->listen_ip_num_v4 ++; } } dump_ip_listen_rule(ip_listen_manage); @@ -162,8 +171,7 @@ static __rte_always_inline uint16_t eth_ingress_node_process(struct rte_graph * rte_graph_t graph_id; struct rte_mbuf * mbuf, ** pkts; void ** batch_pkts; - struct eth_ingress_ip_listen_management * ip_listen_manage = NULL; - static struct node_eth_ingress_main * eth_ingress_main = NULL; + struct node_eth_ingress_main * eth_ingress_main = NULL; /* Get Pkts Num And Pkts Buffer */ n_left_from = cnt; @@ -171,7 +179,6 @@ static __rte_always_inline uint16_t eth_ingress_node_process(struct rte_graph * batch_pkts = objs; batch_next_node_index = ETH_INGRESS_NEXT_ETHERFABRIC_INGRESS; eth_ingress_main = global_eth_ingress_main; - ip_listen_manage = &global_eth_ingress_main->ip_listen_manage; graph_id = graph->id; /* Single Packet Processing */ @@ -201,55 +208,36 @@ static __rte_always_inline uint16_t eth_ingress_node_process(struct rte_graph * goto exception_handling; } - /* Judge IP Version */ - if (pkt_head_info_item.ip_version == MR_NODE_COMMON_IP_VERSION_V4) + /* Listen IP Check */ + if(unlikely(listen_ip_check(eth_ingress_main,&pkt_head_info_item,graph_id) != RT_SUCCESS)) { - if(unlikely(listen_ip_check(ip_listen_manage,pkt_head_info_item._ipv4_hdr) != RT_SUCCESS)) - { - /* No Match Listen Ip Pkt,Need According Ingress Port Match Rout Type, But Current Not Support,Default Drop */ - MR_ETH_INGRESS_STAT_ADD(eth_ingress_main,graph_id,miss_pkts_v4,1); - goto device_attribute_dispatch; - } - - MR_ETH_INGRESS_STAT_ADD(eth_ingress_main,graph_id,hit_pkts_v4,1); - /* Should Enter Local Deal Process,But Current Specify Next Node Is Etherfabric */ - if (unlikely((pkt_head_info_item.proto_id == IPPROTO_UDP) && (pkt_head_info_item.dst_port == ntohs(MR_ETH_INGRESS_BFD_PORT)))) + /* No Match Listen Ip Pkt,Need According Ingress Port Match Rout Type, But Current Not Support,Default Drop */ + if (eth_ingress_main->device_attribute_table[private_ctrlzone->port_ingress] == MR_DEV_ATTRIBUTE_VIRTUAL_WIRE) { - /* Bfd Pkt Should Send To Bfd Node */ - MR_ETH_INGRESS_STAT_ADD(eth_ingress_main,graph_id,bfd_pkts,1); - next_node_index = ETH_INGRESS_NEXT_BFD; - goto node_enqueue; - } - else - { - /* Current Specify Next Node Is Etherfabric */ - MR_ETH_INGRESS_STAT_ADD(eth_ingress_main,graph_id,etherfabric_pkts,1); - next_node_index = ETH_INGRESS_NEXT_ETHERFABRIC_INGRESS; + next_node_index = ETH_INGRESS_NEXT_PKT_DROP; goto node_enqueue; } } - else if (pkt_head_info_item.ip_version == MR_NODE_COMMON_IP_VERSION_V6) + + /* Check Whether Is Bfd Pkt */ + if (unlikely((pkt_head_info_item.proto_id == IPPROTO_UDP) && (pkt_head_info_item.dst_port == ntohs(MR_ETH_INGRESS_BFD_PORT)))) { - /* IPv6 Pkt,Need According Ingress Port Match Rout Type, But Current Not Support,Default Drop */ - MR_ETH_INGRESS_STAT_ADD(eth_ingress_main,graph_id,miss_pkts_v6,1); - goto device_attribute_dispatch; + /* Bfd Pkt Should Send To Bfd Node */ + MR_ETH_INGRESS_STAT_ADD(eth_ingress_main,graph_id,bfd_pkts,1); + next_node_index = ETH_INGRESS_NEXT_BFD; + goto node_enqueue; } else { - goto device_attribute_dispatch; + /* Should Enter Local Deal Process,But Current Specify Next Node Is Etherfabric */ + MR_ETH_INGRESS_STAT_ADD(eth_ingress_main,graph_id,etherfabric_pkts,1); + next_node_index = ETH_INGRESS_NEXT_ETHERFABRIC_INGRESS; + goto node_enqueue; } -device_attribute_dispatch: - if (eth_ingress_main->device_attribute_table[private_ctrlzone->port_ingress] == MR_DEV_ATTRIBUTE_VIRTUAL_WIRE) - { - next_node_index = ETH_INGRESS_NEXT_PKT_DROP; - goto node_enqueue; - } - exception_handling: next_node_index = ETH_INGRESS_NEXT_PKT_DROP; - node_enqueue: /* Judge The Next Index Whether To Change */ if (unlikely(batch_next_node_index != next_node_index)) @@ -299,7 +287,6 @@ cJSON * eth_ingress_node_monit_loop(struct sc_main * sc) cJSON * json_root = NULL,* graph_obj = NULL; struct node_eth_ingress_main * eth_ingress_main = sc->eth_ingress_node_main; unsigned int nr_io_thread = sc->nr_io_thread; - json_root = cJSON_CreateObject(); for (graph_id = 0; graph_id < nr_io_thread; graph_id++) @@ -307,9 +294,7 @@ cJSON * eth_ingress_node_monit_loop(struct sc_main * sc) char graph_index[MR_STRING_MAX]; uint64_t stats = 0; graph_obj = cJSON_CreateObject(); - struct eth_ingress_stat_per_lcore * stat_item = ð_ingress_main->graph_stat[graph_id]; - stats = stat_item->total_pkts; if (stats > 0) @@ -335,14 +320,11 @@ cJSON * eth_ingress_node_monit_loop(struct sc_main * sc) } cJSON_AddNumberToObject(graph_obj, "graph_id", graph_id); - sprintf(graph_index,"graph-%u",graph_num); cJSON_AddItemToObject(json_root,graph_index,graph_obj); - graph_num ++; } cJSON_AddNumberToObject(json_root, "total_graph_num", graph_num); - return json_root; } diff --git a/service/src/node_etherfabric.c b/service/src/node_etherfabric.c index fe52704..5504123 100644 --- a/service/src/node_etherfabric.c +++ b/service/src/node_etherfabric.c @@ -124,7 +124,7 @@ struct node_etherfabric_main /* Global Etherfabric Main */ static struct node_etherfabric_main * global_etherfabric_main = NULL; -extern int eth_ingress_update_ip_listen_num(uint16_t num,uint32_t * listen_ip); +extern int eth_ingress_update_ip_listen_num_v4(uint16_t num,uint32_t * listen_ip); struct etherfabric_fwd_table * etherfabric_get_fwd_item_for_id(uint16_t fwd_table_index) { @@ -464,7 +464,7 @@ int etherfabric_init(struct sc_main * sc) } dump_etherfabric_service_config(etherfabric_manage); - eth_ingress_update_ip_listen_num(etherfabric_manage->es_conf_num,listen_ip_v4); + eth_ingress_update_ip_listen_num_v4(etherfabric_manage->es_conf_num,listen_ip_v4); ret = parser_etherfabric_link_conf(sc,etherfabric_manage); if (ret != RT_ERR) |
