summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsongyanchao <[email protected]>2022-08-11 23:37:11 -0400
committersongyanchao <[email protected]>2022-08-11 23:37:11 -0400
commit7b81d3d4410f0c30dcb3e367ece9422dae2a4240 (patch)
treee90212e1a16e72012b8f394cdf7a61059843db83
parentb29a3c30a4d94833d72ed975f3a51f162f69f5c9 (diff)
🎈 perf(TSG-11662): 统一Mbuf私有字段的使用方式
统一Mbuf私有字段的使用方式
-rw-r--r--service/include/sc_node_common.h (renamed from service/include/node_common.h)5
-rw-r--r--service/src/node_bfd.c7
-rw-r--r--service/src/node_classifier.c17
-rw-r--r--service/src/node_eth_ingress.c2
-rw-r--r--service/src/node_etherfabric.c6
-rw-r--r--service/src/node_lb.c15
-rw-r--r--service/src/node_phydev.c19
-rw-r--r--service/src/node_shmdev.c12
8 files changed, 54 insertions, 29 deletions
diff --git a/service/include/node_common.h b/service/include/sc_node_common.h
index efddab8..37f4d25 100644
--- a/service/include/node_common.h
+++ b/service/include/sc_node_common.h
@@ -1,6 +1,11 @@
#pragma once
#include <sc_etherfabric.h>
+
+#ifndef MR_NODE_COMMON_ORIGINAL_PKT
+#define MR_NODE_COMMON_ORIGINAL_PKT 1
+#endif
+
/* Mbuf Private Date */
struct private_data
{
diff --git a/service/src/node_bfd.c b/service/src/node_bfd.c
index 3527c26..9fe2c92 100644
--- a/service/src/node_bfd.c
+++ b/service/src/node_bfd.c
@@ -9,7 +9,7 @@
#include <rte_graph.h>
#include <rte_graph_worker.h>
#include <cJSON.h>
-#include <node_common.h>
+#include <sc_node_common.h>
/* Global Config */
#ifndef MR_BFD_MAX_SESSION_NUM
@@ -248,7 +248,6 @@ static __rte_always_inline uint16_t bfd_node_process(struct rte_graph * graph, s
struct rte_ipv4_hdr * ipv4_hdr = NULL;
struct rte_udp_hdr * udp_hdr = NULL;
struct bfd_header_t * bfd_hdr = NULL;
- struct node_mbuf_shared_ctx * node_mbuf_ctx = NULL;
struct pkt_parser * pkt_parser_ptr = NULL;
mbuf0 = pkts[0];
@@ -258,9 +257,7 @@ static __rte_always_inline uint16_t bfd_node_process(struct rte_graph * graph, s
/* Get Private Data */
private_ctrlzone = mrbuf_cz_data(mbuf0, 0);
pkt_parser_ptr = &private_ctrlzone->pkt_parser;
- /* Temporary Adaptation */
- node_mbuf_ctx = to_node_mbuf_shared_ctx(mbuf0);
- ingress_port_id = node_mbuf_ctx->port_ingress;
+ ingress_port_id = private_ctrlzone->port_ingress;
/* Update Total Pkts Stat */
MR_BFD_STAT_ADD_FOR_TOTAL(bfd_main,gid,total_pkts,1);
diff --git a/service/src/node_classifier.c b/service/src/node_classifier.c
index b6cbc5a..c13cc38 100644
--- a/service/src/node_classifier.c
+++ b/service/src/node_classifier.c
@@ -12,7 +12,7 @@
#include <rte_rcu_qsbr.h>
#include <cJSON.h>
#include <rpc.h>
-#include <node_common.h>
+#include <sc_node_common.h>
/* Global Config */
#ifndef MR_CLASSIFIER_CLASSIFIER_DEFAULT_CFG
@@ -393,7 +393,6 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g
struct match_field mf;
struct pkt_parser pkt_parser;
struct pkt_parser * pkt_parser_ptr = &pkt_parser;
- struct node_mbuf_shared_ctx * node_mbuf_ctx = NULL;
struct rte_acl_ctx * acx = NULL;
struct private_data * private_ctrlzone = NULL;
const uint8_t * mf_buf[MR_CLASSIFIER_CLASSIFIER_MAX_PKT_BURST];
@@ -413,13 +412,14 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g
memset(&mf,0,sizeof(mf));
/* 2. Get And Update SI Id,Check The Si Id */
- node_mbuf_ctx = to_node_mbuf_shared_ctx(mbuf0);
- si = node_mbuf_ctx->si;
+ private_ctrlzone = mrbuf_cz_data(mbuf0, 0);
+
+ si = private_ctrlzone->si;
if (likely(si <= max_si_id))
{
mf.si = htonl(si);
- node_mbuf_ctx->si++;
+ private_ctrlzone->si++;
mf_buf[0] = (const uint8_t *)&mf;
}
else
@@ -501,7 +501,7 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g
if (likely(action->action_type == CLASSIFIER_ACTION_NF_STEERING))
{
next0 = CLASSIFIER_NEXT_LB;
- node_mbuf_ctx->lb_group_id = action->next_group_id;
+ private_ctrlzone->lb_group_id = action->next_group_id;
goto node_enqueue;
}
else if (action->action_type == CLASSIFIER_ACTION_DROP)
@@ -514,9 +514,9 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g
else
{
CLASSIFIER_STAT_ADD(global_classifier_main,gid,si,missed_si,1);
- si = node_mbuf_ctx->si;
+ si = private_ctrlzone->si;
mf.si = htonl(si);
- node_mbuf_ctx->si++;
+ private_ctrlzone->si++;
}
}
@@ -532,7 +532,6 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g
no_match_process:
/* 6. If None Rule Matched,According To The Service Type Chouse Next Node */
- private_ctrlzone = mrbuf_cz_data(mbuf0, 0);
switch (private_ctrlzone->service_type)
{
case SERVICE_ETHERFABRIC:
diff --git a/service/src/node_eth_ingress.c b/service/src/node_eth_ingress.c
index cf0b104..bcf4a22 100644
--- a/service/src/node_eth_ingress.c
+++ b/service/src/node_eth_ingress.c
@@ -9,7 +9,7 @@
#include <rte_graph.h>
#include <rte_graph_worker.h>
#include <cJSON.h>
-#include <node_common.h>
+#include <sc_node_common.h>
/* Global Config */
#ifndef MR_ETH_INGRESS_MAX_LISTEN_IP
diff --git a/service/src/node_etherfabric.c b/service/src/node_etherfabric.c
index edf95a0..4b5dc0b 100644
--- a/service/src/node_etherfabric.c
+++ b/service/src/node_etherfabric.c
@@ -9,7 +9,7 @@
#include <rte_graph.h>
#include <rte_graph_worker.h>
#include <cJSON.h>
-#include <node_common.h>
+#include <sc_node_common.h>
#ifndef MR_ETHERFABRIC_MAX_RULE
#define MR_ETHERFABRIC_MAX_RULE 1024
@@ -653,7 +653,6 @@ static __rte_always_inline uint16_t etherfabric_egress_node_process(struct rte_g
uint16_t port_ingress = 0;
struct service_tag * egress_tag = NULL;
struct private_data * private_ctrlzone = NULL;
- struct node_mbuf_shared_ctx * node_mbuf_ctx = NULL;
mbuf0 = pkts[0];
@@ -661,8 +660,7 @@ static __rte_always_inline uint16_t etherfabric_egress_node_process(struct rte_g
n_left_from -= 1;
private_ctrlzone = mrbuf_cz_data(mbuf0, 0);
- node_mbuf_ctx = to_node_mbuf_shared_ctx(mbuf0);
- port_ingress = node_mbuf_ctx->port_ingress;
+ port_ingress = private_ctrlzone->port_ingress;
egress_tag = &private_ctrlzone->egress_tag;
MR_ETHERFABRIC_EGRESS_STAT_ADD(em,gid,total_pkts,1);
diff --git a/service/src/node_lb.c b/service/src/node_lb.c
index 829611f..36a2708 100644
--- a/service/src/node_lb.c
+++ b/service/src/node_lb.c
@@ -10,6 +10,8 @@
#include <cJSON.h>
#include <rte_rcu_qsbr.h>
#include <rpc.h>
+#include <mrb_define.h>
+#include <sc_node_common.h>
/* Global Config */
#ifndef MR_LB_MAX_GROUP
@@ -161,6 +163,9 @@ enum {
DYNAMIC_LB_RULE_DEL_GROUP_ID_INVALID
};
+/* Declaration Struct */
+struct lb_group;
+
/* Dispatch Function */
typedef uint16_t (*lb_dispatch_func)(struct node_lb_main * lbm,struct lb_group * group_item,uint32_t hash_usr);
@@ -435,7 +440,7 @@ int parser_local_lb_conf(struct sc_main * sc, struct lb_management * lb_manage)
if (strcmp(str_buf, "balance_mode") == 0)
{
lb_group_item->group_mode = GROUP_MODE_BALANCE;
- lb_group_item->dispatch_func = load_balance;
+ lb_group_item->dispatch_func = (lb_dispatch_func)load_balance;
}
else
{
@@ -640,7 +645,7 @@ int parse_lb_rule_for_add(struct sc_main * sc,struct lb_management * lb_manage,c
switch ((uint8_t)j_group_mode->valuedouble)
{
case GROUP_MODE_BALANCE:
- group_item->dispatch_func = load_balance;
+ group_item->dispatch_func = (lb_dispatch_func)load_balance;
break;
default:
@@ -1007,7 +1012,7 @@ static __rte_always_inline uint16_t lb_node_process(struct rte_graph * graph, st
while (n_left_from > 0)
{
uint16_t gid = 0,group_item_id = MR_LB_GROUP_ITEM_ID_INVALID;
- struct node_mbuf_shared_ctx * node_mbuf_ctx = NULL;
+ struct private_data * private_ctrlzone = NULL;
struct lb_group * lb_group_item = NULL;
mbuf0 = pkts[0];
@@ -1015,8 +1020,8 @@ static __rte_always_inline uint16_t lb_node_process(struct rte_graph * graph, st
pkts += 1;
n_left_from -= 1;
- node_mbuf_ctx = to_node_mbuf_shared_ctx(mbuf0);
- gid = node_mbuf_ctx->lb_group_id;
+ private_ctrlzone = mrbuf_cz_data(mbuf0, 0);
+ gid = private_ctrlzone->lb_group_id;
MR_LB_STAT_ADD(lbm,graph_id,total_pkts,1);
group_item_id = get_lb_item_index_from_group_id(lbm->lb_manage,gid);
diff --git a/service/src/node_phydev.c b/service/src/node_phydev.c
index efc7ee4..e016b01 100644
--- a/service/src/node_phydev.c
+++ b/service/src/node_phydev.c
@@ -7,6 +7,8 @@
#include <sc_node.h>
#include <sc_vdev.h>
+#include <mrb_define.h>
+#include <sc_node_common.h>
struct phydev_rx_node_ctx
{
@@ -79,11 +81,18 @@ static __rte_always_inline uint16_t phydev_rx_node_process(struct rte_graph * gr
/* shared ctx */
for (unsigned int i = 0; i < node->idx; i++)
{
- struct node_mbuf_shared_ctx * node_mbuf_ctx = to_node_mbuf_shared_ctx((struct rte_mbuf *)node->objs[i]);
- node_mbuf_ctx->port_ingress = ctx->phydev->port_id;
- node_mbuf_ctx->port_egress = UINT16_MAX;
- node_mbuf_ctx->lb_group_id = 65535;
- node_mbuf_ctx->si = 0;
+ struct rte_mbuf * mbuf = (struct rte_mbuf *)node->objs[i];
+ struct private_data * private_ctrlzone = mrbuf_cz_data(mbuf, 0);
+ private_ctrlzone->original_packet_flag = MR_NODE_COMMON_ORIGINAL_PKT;
+ private_ctrlzone->port_ingress = ctx->phydev->port_id;
+ private_ctrlzone->port_egress = UINT16_MAX;
+ private_ctrlzone->lb_group_id = 65535;
+ private_ctrlzone->si = 0;
+
+ /* Parser Pkt */
+ struct pkt_parser * pkt_parser_ptr = &private_ctrlzone->pkt_parser;
+ pkt_parser_init(pkt_parser_ptr, LAYER_TYPE_ALL, MR_PKT_PARSE_RESULT_MAX);
+ complex_parser_ether(pkt_parser_ptr, rte_pktmbuf_mtod(mbuf,const char *));
}
/* move to next node */
diff --git a/service/src/node_shmdev.c b/service/src/node_shmdev.c
index 07959fd..425212c 100644
--- a/service/src/node_shmdev.c
+++ b/service/src/node_shmdev.c
@@ -7,6 +7,8 @@
#include <sc_node.h>
#include <sc_vdev.h>
+#include <mrb_define.h>
+#include <sc_node_common.h>
struct shmdev_rx_node_ctx
{
@@ -71,6 +73,16 @@ static __rte_always_inline uint16_t shmdev_rx_node_process(struct rte_graph * gr
struct rte_mbuf ** mbufs = (struct rte_mbuf **)node->objs;
for (int i = 0; i < rx_nr_mbufs; i++)
{
+
+ struct private_data * private_ctrlzone = mrbuf_cz_data(mbufs[i], 0);
+
+ if (unlikely(private_ctrlzone->original_packet_flag != MR_NODE_COMMON_ORIGINAL_PKT))
+ {
+ struct pkt_parser * pkt_parser_ptr = &private_ctrlzone->pkt_parser;
+ pkt_parser_init(pkt_parser_ptr, LAYER_TYPE_ALL, MR_PKT_PARSE_RESULT_MAX);
+ complex_parser_ether(pkt_parser_ptr, rte_pktmbuf_mtod(mbufs[i],const char *));
+ }
+
mbufs[i]->ol_flags = 0;
mbufs[i]->vlan_tci = 0;
}