summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsongyanchao <[email protected]>2022-08-10 22:34:44 -0400
committersongyanchao <[email protected]>2022-08-10 22:34:44 -0400
commit987f8cf829398fa1b331fbf84a032dd540bf1a79 (patch)
treef48223ee4b6e4b8a0774e2017beb31d962a0ad25
parent89210d055fe38dc35addb59c1d28424d09587c44 (diff)
✨ feat(TSG-11662): 临时适配 Private Data 数据结构
临时适配 Private Data 数据结构
-rw-r--r--conf/etherfabric.conf6
-rw-r--r--service/include/node_common.h8
-rw-r--r--service/src/node_classifier.c8
-rw-r--r--service/src/node_etherfabric.c54
4 files changed, 42 insertions, 34 deletions
diff --git a/conf/etherfabric.conf b/conf/etherfabric.conf
index 6f23d3d..23ed20b 100644
--- a/conf/etherfabric.conf
+++ b/conf/etherfabric.conf
@@ -3,14 +3,14 @@
#[rule:0]
#name=etherfabric_ingress_eth0_0
-#type=ehterfabric
-#mode=virtual-wrie
+#type=etherfabric
+#mode=virtual-wire
#listen_ip=10.0.0.1
#listen_port=4789
#[rule:1]
#name=etherfabric_ingress_eth1_1
-#type=ehterfabric
+#type=etherfabric
#mode=tap
#listen_ip=10.0.0.2
#listen_port=4789 \ No newline at end of file
diff --git a/service/include/node_common.h b/service/include/node_common.h
index 0622f9c..efddab8 100644
--- a/service/include/node_common.h
+++ b/service/include/node_common.h
@@ -1,5 +1,6 @@
#pragma once
+#include <sc_etherfabric.h>
/* Mbuf Private Date */
struct private_data
{
@@ -15,4 +16,11 @@ struct private_data
uint16_t lb_group_id;
uint32_t si;
struct pkt_parser pkt_parser;
+
+ // Temporary Adaptation
+ uint8_t service_type;
+ uint8_t tag_set_flag : 4;
+ uint8_t package_type : 4;
+ struct service_tag ingress_tag;
+ struct service_tag egress_tag;
}; \ No newline at end of file
diff --git a/service/src/node_classifier.c b/service/src/node_classifier.c
index c4f1881..e3f1398 100644
--- a/service/src/node_classifier.c
+++ b/service/src/node_classifier.c
@@ -4,7 +4,6 @@
#include <sc_common.h>
#include <sc_vdev.h>
#include <sc_node.h>
-#include <sc_etherfabric.h>
#include <mrb_define.h>
#include <ldbc.h>
#include <rte_graph.h>
@@ -13,6 +12,7 @@
#include <rte_rcu_qsbr.h>
#include <cJSON.h>
#include <rpc.h>
+#include <node_common.h>
/* Global Config */
#ifndef MR_CLASSIFIER_CLASSIFIER_DEFAULT_CFG
@@ -395,7 +395,7 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g
struct pkt_parser * pkt_parser_ptr = &pkt_parser;
struct node_mbuf_shared_ctx * node_mbuf_ctx = NULL;
struct rte_acl_ctx * acx = NULL;
- struct etherfabric_tag * etag_ctrlzone = NULL;
+ struct private_data * private_ctrlzone = NULL;
const uint8_t * mf_buf[MR_CLASSIFIER_CLASSIFIER_MAX_PKT_BURST];
@@ -532,8 +532,8 @@ 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 */
- etag_ctrlzone = mrbuf_cz_data(mbuf0, 0);
- switch (etag_ctrlzone->service_type)
+ private_ctrlzone = mrbuf_cz_data(mbuf0, 0);
+ switch (private_ctrlzone->service_type)
{
case SERVICE_ETHERFABRIC:
next0 = CLASSIFIER_NEXT_ETHERFABRIC;
diff --git a/service/src/node_etherfabric.c b/service/src/node_etherfabric.c
index 93b9d8b..205cd4a 100644
--- a/service/src/node_etherfabric.c
+++ b/service/src/node_etherfabric.c
@@ -5,11 +5,11 @@
#include <sc_common.h>
#include <sc_vdev.h>
#include <sc_node.h>
-#include <sc_etherfabric.h>
#include <ldbc.h>
#include <rte_graph.h>
#include <rte_graph_worker.h>
#include <cJSON.h>
+#include <node_common.h>
#ifndef MR_ETHERFABRIC_MAX_RULE
#define MR_ETHERFABRIC_MAX_RULE 1024
@@ -82,7 +82,7 @@ enum {
/* Etherfabric Service Mode */
enum {
MODE_INVALID = 0,
- MODE_VIRTUAL_WRIE,
+ MODE_VIRTUAL_WIRE,
};
/* Service Rule Struct */
@@ -135,7 +135,7 @@ static struct node_etherfabric_main * global_etherfabric_main = NULL;
extern int eth_ingress_update_ip_listen_num(uint16_t num,uint32_t * listen_ip);
/************************************* Etherfabric Config **************************************/
-/* Parser The Eterfabric Service Rule Config */
+/* Parser The Etherfabric Service Rule Config */
int parser_etherfabric_conf(struct sc_main * sc, struct etherfabric_management * e_manage)
{
uint32_t listen_port = 0,rule_num = 0,count = 0;
@@ -152,19 +152,19 @@ int parser_etherfabric_conf(struct sc_main * sc, struct etherfabric_management *
if (ret < 0)
{
- /* No Config The Eterfabric Rule Num,Returen Error */
- MR_ERROR("No Config The Eterfabric Rule Num !!!!");
+ /* No Config The Etherfabric Rule Num,Return Error */
+ MR_ERROR("No Config The Etherfabric Rule Num !!!!");
return RT_SUCCESS;
}
- /* 2. Check The Eterfabric Rule Num */
+ /* 2. Check The Etherfabric Rule Num */
if ((rule_num == MR_ETHERFABRIC_INVALID_RULE_ARG) || (rule_num > MR_ETHERFABRIC_MAX_RULE))
{
- MR_ERROR("The Eterfabric Rule Num: %u Is Invalid,The Rule Num Range From 1 to '%d' ",rule_num,MR_ETHERFABRIC_MAX_RULE);
+ MR_ERROR("The Etherfabric Rule Num: %u Is Invalid,The Rule Num Range From 1 to '%d' ",rule_num,MR_ETHERFABRIC_MAX_RULE);
return RT_ERR;
}
- /* 3. Save The Eterfabric Rule Num */
+ /* 3. Save The Etherfabric Rule Num */
e_manage->rule_num = (uint16_t)rule_num;
/* 4. Parsing All Rule Config */
@@ -185,13 +185,13 @@ int parser_etherfabric_conf(struct sc_main * sc, struct etherfabric_management *
return RT_ERR;
}
/* Save type */
- if (strcmp(str_buf, "ehterfabric") == 0)
+ if (strcmp(str_buf, "etherfabric") == 0)
{
e_manage->sr[i].type = SERVICE_ETHERFABRIC;
}
else
{
- MR_ERROR("The Rule '%s' 'type' Invalid,Current Only Support 'ehterfabric' !!! ",rule_str_section);
+ MR_ERROR("The Rule '%s' 'type' Invalid,Current Only Support 'etherfabric' !!! ",rule_str_section);
return RT_ERR;
}
@@ -202,13 +202,13 @@ int parser_etherfabric_conf(struct sc_main * sc, struct etherfabric_management *
return RT_ERR;
}
/* Save mode */
- if (strcmp(str_buf, "virtual-wrie") == 0)
+ if (strcmp(str_buf, "virtual-wire") == 0)
{
- e_manage->sr[i].mode = MODE_VIRTUAL_WRIE;
+ e_manage->sr[i].mode = MODE_VIRTUAL_WIRE;
}
else
{
- MR_ERROR("The Rule '%s' 'mode' Invalid,Current Only Support 'virtual-wrie' !!! ",rule_str_section);
+ MR_ERROR("The Rule '%s' 'mode' Invalid,Current Only Support 'virtual-wire' !!! ",rule_str_section);
return RT_ERR;
}
@@ -301,8 +301,8 @@ void dump_etherfabric_config(struct etherfabric_management * e_manage)
switch (sr->mode)
{
- case MODE_VIRTUAL_WRIE:
- MR_INFO(" Rule Mode : virtual-wrie");
+ case MODE_VIRTUAL_WIRE:
+ MR_INFO(" Rule Mode : virtual-wire");
break;
default:
@@ -327,7 +327,7 @@ int etherfabric_init(struct sc_main * sc)
e_manage = &em->e_manage;
sc->etherfabric_node_main = em;
- /* 1. Parser The Eterfabric Service Rule Config */
+ /* 1. Parser The Etherfabric Service Rule Config */
ret = parser_etherfabric_conf(sc,e_manage);
/* 2. Dump The Config And Update Ip Listen Num */
@@ -405,16 +405,16 @@ static __rte_always_inline uint16_t etherfabric_ingress_node_process(struct rte_
struct rte_udp_hdr * udp_hdr = NULL;
struct g_vxlan_hdr * g_vxlan_hdr = NULL;
struct service_rule * sr = NULL;
- struct etherfabric_tag * etag_ctrlzone = NULL;
+ struct private_data * private_ctrlzone = NULL;
mbuf0 = pkts[0];
pkts += 1;
n_left_from -= 1;
- etag_ctrlzone = mrbuf_cz_data(mbuf0, 0);
- ingress_tag = &etag_ctrlzone->ingress_tag;
- egress_tag = &etag_ctrlzone->egress_tag;
+ private_ctrlzone = mrbuf_cz_data(mbuf0, 0);
+ ingress_tag = &private_ctrlzone->ingress_tag;
+ egress_tag = &private_ctrlzone->egress_tag;
MR_ETHERFABRIC_INGRESS_STAT_ADD(em,gid,total_pkts,1);
/* 1. Parser PKT */
@@ -436,7 +436,7 @@ static __rte_always_inline uint16_t etherfabric_ingress_node_process(struct rte_
{
ipv4_hdr = (struct rte_ipv4_hdr *)(result->data);
ingress_tag->src_addr_ipv4 = egress_tag->src_addr_ipv4 = ipv4_hdr->src_addr;
- etag_ctrlzone->package_type = IPV4_PACKAGE;
+ private_ctrlzone->package_type = IPV4_PACKAGE;
offset = sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + sizeof(struct rte_udp_hdr) + sizeof(struct g_vxlan_hdr);
ip_save_flg = ETHERFABRIC_IP_ALREADY_SAVE;
continue;
@@ -483,7 +483,7 @@ static __rte_always_inline uint16_t etherfabric_ingress_node_process(struct rte_
}
/* 4. Fill Etherfabric Tag,And Save The Etherfabric Tag Ctrlzone,Current Not Support IPv6 */
- etag_ctrlzone->service_type = sr->type;
+ private_ctrlzone->service_type = sr->type;
/* 5. Set The Pkt Date Off */
rte_pktmbuf_adj(mbuf0,offset);
@@ -652,7 +652,7 @@ 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 etherfabric_tag * etag_ctrlzone = NULL;
+ struct private_data * private_ctrlzone = NULL;
struct node_mbuf_shared_ctx * node_mbuf_ctx = NULL;
mbuf0 = pkts[0];
@@ -660,14 +660,14 @@ static __rte_always_inline uint16_t etherfabric_egress_node_process(struct rte_g
pkts += 1;
n_left_from -= 1;
- etag_ctrlzone = mrbuf_cz_data(mbuf0, 0);
+ private_ctrlzone = mrbuf_cz_data(mbuf0, 0);
node_mbuf_ctx = to_node_mbuf_shared_ctx(mbuf0);
port_ingress = node_mbuf_ctx->port_ingress;
- egress_tag = &etag_ctrlzone->egress_tag;
+ egress_tag = &private_ctrlzone->egress_tag;
MR_ETHERFABRIC_EGRESS_STAT_ADD(em,gid,total_pkts,1);
/* 1. Fill The Package */
- switch (etag_ctrlzone->package_type)
+ switch (private_ctrlzone->package_type)
{
case IPV4_PACKAGE:
{
@@ -676,7 +676,7 @@ static __rte_always_inline uint16_t etherfabric_egress_node_process(struct rte_g
rte_pktmbuf_prepend(mbuf0,offset);
/* Fill Ether IPv4 Udp Vxlan Hdr For The Pkt */
- if (likely(etag_ctrlzone->tag_set_flag == NONE_TAG_SET))
+ if (likely(private_ctrlzone->tag_set_flag == NONE_TAG_SET))
{
fill_ipv4_pkt_for_no_set_tag(mbuf0);
MR_ETHERFABRIC_EGRESS_STAT_ADD(em,gid,ipv4_no_set_tag,1);