diff options
| author | songyanchao <[email protected]> | 2022-09-23 03:50:33 +0000 |
|---|---|---|
| committer | songyanchao <[email protected]> | 2022-09-23 06:42:49 -0400 |
| commit | 5547cb464dee8126969e09957684da94e361a68c (patch) | |
| tree | f7595a5104147f40e1e41091d3529ef51b3034e5 | |
| parent | 7f121e7b865b74a0e8eaa757242eb463a924d7cd (diff) | |
🎈 perf(TSG-12030): 修改Classifier节点数据包计数输出格式v4.6.4-20220923
修改Classifier节点数据包计数输出格式
| -rw-r--r-- | service/src/node_classifier.c | 104 |
1 files changed, 43 insertions, 61 deletions
diff --git a/service/src/node_classifier.c b/service/src/node_classifier.c index 9d4caae..081cb43 100644 --- a/service/src/node_classifier.c +++ b/service/src/node_classifier.c @@ -188,10 +188,10 @@ #define MR_CLASSIFIER_CJSON_KEY_NEXT_GROUP "NextGroup" #endif -#define CLASSIFIER_STAT_ADD(st, graph_id, si, counter, value) \ +#define CLASSIFIER_STAT_ADD(st, graph_id, counter, value) \ do \ { \ - st->stat_per_graph[graph_id].counter[si] += value; \ + st->stat_per_graph[graph_id].counter += value; \ } while (0) /* Table name flag */ @@ -360,14 +360,15 @@ RTE_ACL_RULE_DEF(classifier_rule, RTE_DIM(classifier_defs)); /* Classifier stat */ struct classifier_stat_per_lcore { - volatile uint64_t total_pkts_si[MR_CLASSIFIER_MAX_SI_NUM]; - volatile uint64_t invalid_pkts[MR_CLASSIFIER_MAX_SI_NUM]; - volatile uint64_t hits_si[MR_CLASSIFIER_MAX_SI_NUM]; - volatile uint64_t missed_si[MR_CLASSIFIER_MAX_SI_NUM]; - volatile uint64_t no_classifier_rule_si[MR_CLASSIFIER_MAX_SI_NUM]; - volatile uint64_t no_support_pkt[MR_CLASSIFIER_MAX_SI_NUM]; - volatile uint64_t to_etherfabric[MR_CLASSIFIER_MAX_SI_NUM]; - volatile uint64_t to_vwire[MR_CLASSIFIER_MAX_SI_NUM]; + volatile uint64_t total_pkts; + volatile uint64_t invalid_pkts; + volatile uint64_t hits_pkts; + volatile uint64_t miss_pkts; + volatile uint64_t no_classifier_rule_pkts; + volatile uint64_t no_support_pkts; + volatile uint64_t to_etherfabric_pkts; + volatile uint64_t to_vwire_pkts; + volatile uint64_t to_drop_pkts; } __rte_cache_aligned; /* Classifier rule action */ @@ -441,30 +442,31 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g pkts += 1; n_left_from -= 1; + /* Pkt prefetch */ + if (likely(n_left_from > 0)) + rte_prefetch0(pkts[0]); + /* Get ctrlzone */ struct private_data * private_ctrlzone = mrbuf_cz_data(mbuf, MR_NODE_CTRLZONE_ID); - struct pkt_parser * pkt_parser_ptr = &private_ctrlzone->pkt_parser; uint16_t si_id = private_ctrlzone->si_id; - /* Pkt prefetch */ - if (likely(n_left_from > 0)) - rte_prefetch0(pkts[0]); + /* Update classifier total pkts stats */ + CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, total_pkts, 1); /* Check ACX and match classifier table */ if (unlikely(acx == NULL)) { - /* Update classifier total pkts stats */ - CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, si_id, total_pkts_si, 1); - CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, si_id, no_classifier_rule_si, 1); + CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, no_classifier_rule_pkts, 1); goto no_match_process; } /* Parsed pkt head */ struct pkt_head_info pkt_head_info_item = {}; + struct pkt_parser * pkt_parser_ptr = &private_ctrlzone->pkt_parser; int ret = get_pkt_head_info(pkt_parser_ptr, &pkt_head_info_item, MR_PARSE_IP | MR_PARSE_PORT); if (unlikely(ret == RT_ERR)) { - CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, si_id, invalid_pkts, 1); + CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, invalid_pkts, 1); goto no_match_process; } @@ -482,26 +484,24 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g } else { - CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, si_id, no_support_pkt, 1); + CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, no_support_pkts, 1); goto no_match_process; } /* Match classifier table */ uint32_t res_array[MR_CLASSIFIER_MAX_PKT_BURST] = {}; - for (; si_id <= max_si_id; si_id++) + while (si_id <= max_si_id) { const uint8_t * match_field_array[MR_CLASSIFIER_MAX_PKT_BURST]; match_field_item.si = htons(si_id); match_field_array[0] = (const uint8_t *)&match_field_item; - /* Update classifier total pkts stats for this si id */ - CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, si_id, total_pkts_si, 1); rte_acl_classify(acx, match_field_array, res_array, 1, MR_CLASSIFIER_DEFAULT_MAX_CATEGORIES); if (likely(res_array[0] != 0)) { break; } - CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, si_id, missed_si, 1); + si_id++; } /* Update si id */ @@ -509,10 +509,13 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g /* Checks whether a rule is matched */ if (likely(res_array[0] == 0)) + { + CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, miss_pkts, 1); goto no_match_process; + } /* According to the results find the action */ - CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, si_id, hits_si, 1); + CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, hits_pkts, 1); struct mr_action * action = &_classifier_management->classifier_local_action[res_array[0]]; if (likely(action->action_type == CLASSIFIER_ACTION_NF_STEERING)) { @@ -532,16 +535,17 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g { case MR_NODE_COMMON_ETHERFABRIC_SERVICE: next_node_index = CLASSIFIER_NEXT_ETHERFABRIC_EGRESS; - CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, si_id, to_etherfabric, 1); + CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, to_etherfabric_pkts, 1); goto node_enqueue; case MR_NODE_COMMON_VWIRE_SERVICE: next_node_index = CLASSIFIER_NEXT_VWIRE_EGRESS; - CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, si_id, to_vwire, 1); + CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, to_vwire_pkts, 1); goto node_enqueue; default: /* Send to phydev on the basis of shared ctx,But current no support,default Drop */ + CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, to_drop_pkts, 1); next_node_index = CLASSIFIER_NEXT_PKT_DROP; break; } @@ -1869,44 +1873,22 @@ cJSON * classifier_node_monit_loop(struct sc_main * sc) for (uint32_t graph_id = 0; graph_id < nr_graph_total; graph_id++) { - uint32_t nr_si_num = 0; - cJSON * graph_obj = cJSON_CreateObject(); - - for (int si_id = 0; si_id < MR_CLASSIFIER_MAX_SI_NUM; si_id++) - { - char stat_index[MR_STRING_MAX]; - uint64_t total_pkts = classifier_main->stat_per_graph[graph_id].total_pkts_si[si_id]; - if (total_pkts == 0) - continue; - - uint64_t invalid_pkts = classifier_main->stat_per_graph[graph_id].invalid_pkts[si_id]; - uint64_t no_classifier_rule = classifier_main->stat_per_graph[graph_id].no_classifier_rule_si[si_id]; - uint64_t hits = classifier_main->stat_per_graph[graph_id].hits_si[si_id]; - uint64_t missed = classifier_main->stat_per_graph[graph_id].missed_si[si_id]; - uint64_t no_support_pkt = classifier_main->stat_per_graph[graph_id].no_support_pkt[si_id]; - uint64_t to_etherfabric = classifier_main->stat_per_graph[graph_id].to_etherfabric[si_id]; - - cJSON * si_obj = cJSON_CreateObject(); - sprintf(stat_index, "stat-%u", nr_si_num); - cJSON_AddNumberToObject(si_obj, "si_id", si_id); - cJSON_AddNumberToObject(si_obj, "total_pkts", total_pkts); - cJSON_AddNumberToObject(si_obj, "invalid_pkts", invalid_pkts); - cJSON_AddNumberToObject(si_obj, "no_classifier_rules", no_classifier_rule); - cJSON_AddNumberToObject(si_obj, "hits", hits); - cJSON_AddNumberToObject(si_obj, "missed", missed); - cJSON_AddNumberToObject(si_obj, "no_support_pkt", no_support_pkt); - cJSON_AddNumberToObject(si_obj, "to_etherfabric_service", to_etherfabric); - cJSON_AddItemToObject(graph_obj, stat_index, si_obj); - nr_si_num++; - } + struct classifier_stat_per_lcore * _stat_per_graph = &classifier_main->stat_per_graph[graph_id]; - if (nr_si_num == 0) - { - cJSON_Delete(graph_obj); + if (_stat_per_graph->total_pkts == 0) continue; - } - cJSON_AddNumberToObject(graph_obj, "si_num", nr_si_num); + cJSON * graph_obj = cJSON_CreateObject(); + cJSON_AddNumberToObject(graph_obj, "total_pkts", _stat_per_graph->total_pkts); + cJSON_AddNumberToObject(graph_obj, "invalid_pkts", _stat_per_graph->invalid_pkts); + cJSON_AddNumberToObject(graph_obj, "no_classifier_rules", _stat_per_graph->no_classifier_rule_pkts); + cJSON_AddNumberToObject(graph_obj, "hits_pkts", _stat_per_graph->hits_pkts); + cJSON_AddNumberToObject(graph_obj, "miss_pkts", _stat_per_graph->miss_pkts); + cJSON_AddNumberToObject(graph_obj, "no_support_pkts", _stat_per_graph->no_support_pkts); + cJSON_AddNumberToObject(graph_obj, "to_etherfabric_pkts", _stat_per_graph->to_etherfabric_pkts); + cJSON_AddNumberToObject(graph_obj, "to_vwire_pkts", _stat_per_graph->to_vwire_pkts); + cJSON_AddNumberToObject(graph_obj, "to_drop_pkts", _stat_per_graph->to_drop_pkts); + char graph_index[MR_STRING_MAX] = {}; snprintf(graph_index, sizeof(graph_index), "graph-%u", graph_id); cJSON_AddItemToObject(json_root, graph_index, graph_obj); |
