summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsongyanchao <[email protected]>2022-11-22 03:31:51 +0000
committersongyanchao <[email protected]>2022-11-22 03:31:51 +0000
commit74bd5ec46ba90ca2ceb4718893b2d5389cd762b1 (patch)
tree7e3547ad9ecb190e3a6e93782fd65a269a0213d3
parent1ba7813f8db2c0ec08b6c6a26bf228668086605c (diff)
✨ feat(TSG-12799): 优化 Classifier 节点计数,支持记录全局唯一 rule id 命中数v4.6.9-20221122
优化 Classifier 节点计数,支持记录全局唯一 rule id 命中数
-rw-r--r--service/src/node_classifier.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/service/src/node_classifier.c b/service/src/node_classifier.c
index 83fb896..73f2e83 100644
--- a/service/src/node_classifier.c
+++ b/service/src/node_classifier.c
@@ -206,10 +206,11 @@
st->stat_per_graph[graph_id].counter += value; \
} while (0)
-#define CLASSIFIER_STAT_ADD_FOR_ID(st, graph_id, counter, rule_id, value) \
+#define CLASSIFIER_STAT_ADD_FOR_ID(st, graph_id, item_id, rule_id, value) \
do \
{ \
- st->stat_per_graph[graph_id].counter[rule_id] += value; \
+ st->stat_per_graph[graph_id].hits_pkts_for_rule_id.hits_pkts_for_item_id[item_id] += value; \
+ st->stat_per_graph[graph_id].hits_pkts_for_rule_id.item_id_to_rule_id[item_id] = rule_id; \
} while (0)
/* Table name flag */
@@ -465,13 +466,20 @@ struct rte_acl_field_def classifier_defs[CLASSIFIER_FIELD_NUM] = {
/* Define struct classifier_rule */
RTE_ACL_RULE_DEF(classifier_rule, RTE_DIM(classifier_defs));
+/* Classifier rule id stat */
+struct classifier_rule_id_stat
+{
+ volatile uint64_t hits_pkts_for_item_id[MAX_CLASSIFIER_RULE_NUM];
+ volatile uint64_t item_id_to_rule_id[MAX_CLASSIFIER_RULE_NUM];
+};
+
/* Classifier stat */
struct classifier_stat_per_lcore
{
volatile uint64_t total_pkts;
volatile uint64_t invalid_pkts;
volatile uint64_t hits_pkts;
- volatile uint64_t hits_pkts_for_id[MAX_CLASSIFIER_RULE_NUM];
+ struct classifier_rule_id_stat hits_pkts_for_rule_id;
volatile uint64_t miss_pkts;
volatile uint64_t no_classifier_rule_pkts;
volatile uint64_t no_support_pkts;
@@ -650,7 +658,7 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g
/* According to the results find the action */
CLASSIFIER_STAT_ADD(global_classifier_main, graph_id, hits_pkts, 1);
- CLASSIFIER_STAT_ADD_FOR_ID(global_classifier_main, graph_id, hits_pkts_for_id, action->rule_id, 1);
+ CLASSIFIER_STAT_ADD_FOR_ID(global_classifier_main, graph_id, res_array[0], action->rule_id, 1);
/* Deal action */
if (likely(action->action_type == CLASSIFIER_ACTION_NF_STEERING))
@@ -2229,12 +2237,14 @@ cJSON * classifier_node_monit_loop(struct sc_main * sc)
cJSON * rule_hits_obj = cJSON_CreateObject();
for (int index = 0; index < MAX_CLASSIFIER_RULE_NUM; index++)
{
- if (_stat_per_graph->hits_pkts_for_id[index] == 0)
+ if (_stat_per_graph->hits_pkts_for_rule_id.hits_pkts_for_item_id[index] == 0)
continue;
char str_rule_id[MR_STRING_MAX] = {};
- snprintf(str_rule_id, sizeof(str_rule_id), "rule_id_%u", index);
- cJSON_AddNumberToObject(rule_hits_obj, str_rule_id, _stat_per_graph->hits_pkts_for_id[index]);
+ snprintf(str_rule_id, sizeof(str_rule_id), "rule_id_%lu",
+ _stat_per_graph->hits_pkts_for_rule_id.item_id_to_rule_id[index]);
+ cJSON_AddNumberToObject(rule_hits_obj, str_rule_id,
+ _stat_per_graph->hits_pkts_for_rule_id.hits_pkts_for_item_id[index]);
}
cJSON_AddItemToObject(graph_obj, "rule-hits", rule_hits_obj);