summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorsongyanchao <[email protected]>2022-09-07 04:04:59 +0000
committersongyanchao <[email protected]>2022-09-07 04:04:59 +0000
commitaa4c1f9a13c4c2db968e804bf313000d99820aea (patch)
tree5f92c8ddf84856bf6c7535b1e23eda9ea0d9129d /examples
parent91ef374bf70f33fbef10341e00c277227f601acc (diff)
✨ feat(TSG-11887): 添加eth-egress节点
添加eth-egress节点
Diffstat (limited to 'examples')
-rw-r--r--examples/l2fwd.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/examples/l2fwd.c b/examples/l2fwd.c
index a1c2252..64b2ef0 100644
--- a/examples/l2fwd.c
+++ b/examples/l2fwd.c
@@ -8,16 +8,13 @@
static char appsym[64] = "mrfwd";
static char dev_1_symbol[64] = "meth0";
-static char dev_2_symbol[64] = "meth1";
uint64_t cpu_mask = 0x3c;
unsigned int nr_thread;
struct mr_instance * mr_instance = NULL;
struct mr_vdev * dev_1_handler = NULL;
-struct mr_vdev * dev_2_handler = NULL;
struct mr_sendpath * to_dev_1_sendpath = NULL;
-struct mr_sendpath * to_dev_2_sendpath = NULL;
#define BURST_MAX 64
unsigned int nr_burst = 32;
@@ -33,8 +30,6 @@ void * l2fwd_loop(void * arg)
for (;;)
{
ret = marsio_recv_burst(dev_1_handler, sid, rx_buff, nr_burst);
- marsio_send_burst(to_dev_2_sendpath, sid, rx_buff, ret);
- ret = marsio_recv_burst(dev_2_handler, sid, rx_buff, nr_burst);
marsio_send_burst(to_dev_1_sendpath, sid, rx_buff, ret);
}
@@ -48,7 +43,7 @@ int help()
}
int main(int argc, char * argv[])
-{
+{
int opt = 0;
while ((opt = getopt(argc, argv, "s:d:a:c:b:h?")) != -1)
{
@@ -66,11 +61,6 @@ int main(int argc, char * argv[])
snprintf(dev_1_symbol, sizeof(dev_1_symbol), "%s", optarg);
break;
}
- case 'd':
- {
- snprintf(dev_2_symbol, sizeof(dev_2_symbol), "%s", optarg);
- break;
- }
case 'a':
{
snprintf(appsym, sizeof(appsym), "%s", optarg);
@@ -94,7 +84,7 @@ int main(int argc, char * argv[])
break;
}
}
-
+
mr_instance = marsio_create();
if (mr_instance == NULL)
{
@@ -109,17 +99,15 @@ int main(int argc, char * argv[])
nr_thread = __builtin_popcountll(cpu_mask);
dev_1_handler = marsio_open_device(mr_instance, dev_1_symbol, nr_thread, nr_thread);
- dev_2_handler = marsio_open_device(mr_instance, dev_2_symbol, nr_thread, nr_thread);
to_dev_1_sendpath = marsio_sendpath_create_by_vdev(dev_1_handler);
- to_dev_2_sendpath = marsio_sendpath_create_by_vdev(dev_2_handler);
- fprintf(stdout, "Thread Count = %d\n", nr_thread);
+ fprintf(stdout, "Thread Count = %d\n", nr_thread);
pthread_t __tmp_pid[nr_thread];
for (int i = 0; i < nr_thread; i++)
{
pthread_create(&__tmp_pid[i], NULL, l2fwd_loop, (void *)(uintptr_t)i);
}
-
+
for (int i = 0; i < nr_thread; i++)
{
pthread_join(__tmp_pid[i], NULL);