diff options
| author | 陆秋文 <[email protected]> | 2023-03-13 10:14:25 +0000 |
|---|---|---|
| committer | 陆秋文 <[email protected]> | 2023-03-13 10:14:25 +0000 |
| commit | 21b93587d59763643e0d2333bc552927c5b913a9 (patch) | |
| tree | 091f4bf26141323aff58a3d78ee6cde857da4b55 /examples | |
| parent | 383d745322d6a421e8788e64a15ddae922827973 (diff) | |
支持多个NF运行在同一组处理器核心
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/feedback.c | 4 | ||||
| -rw-r--r-- | examples/l2fwd-nf.c | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/examples/feedback.c b/examples/feedback.c index 3b32206..e4798d7 100644 --- a/examples/feedback.c +++ b/examples/feedback.c @@ -55,8 +55,8 @@ void * feedback_loop(void * arg) memcpy(dst_data, raw_data, raw_len); /* 构建UDP头部 */ - marsio_udp_header_construct(feedback_buffs[i], sid + 8080, 8866); - marsio_ipv4_header_construct(feedback_buffs[i], 0, 0, IPPROTO_UDP); +// marsio_udp_header_construct(feedback_buffs[i], sid + 8080, 8866); +// marsio_ipv4_header_construct(feedback_buffs[i], 0, 0, IPPROTO_UDP); } marsio_send_burst(to_dev_dst_sendpath, sid, feedback_buffs, ret); diff --git a/examples/l2fwd-nf.c b/examples/l2fwd-nf.c index 271eafc..99597fd 100644 --- a/examples/l2fwd-nf.c +++ b/examples/l2fwd-nf.c @@ -35,21 +35,21 @@ void dump_packet_metadata(marsio_buff_t * buff) #endif } -__attribute__((noreturn)) void * l2fwd_loop(void * arg) +void * l2fwd_loop(void * arg) { uintptr_t sid = (uintptr_t)arg; marsio_buff_t * rx_buff[BURST_MAX]; marsio_buff_t * tx_buff[BURST_MAX]; - unsigned int ret = 0; + int ret = 0; marsio_thread_init(mr_instance); for (;;) { ret = marsio_recv_burst(dev_1_handler, sid, rx_buff, (int)nr_burst); - if (ret <= 0) + if (ret == 0) { - continue; + marsio_poll_wait(mr_instance, &dev_1_handler, 1, sid, -1); } for (int i = 0; i < ret; i++) @@ -80,11 +80,13 @@ __attribute__((noreturn)) void * l2fwd_loop(void * arg) sid_t sids[MR_SID_LIST_MAXLEN]; int nr_sids = marsio_buff_get_sid_list(orin_buff, sids, MR_SID_LIST_MAXLEN); +#if 0 struct rte_ether_hdr * ether_hdr = (struct rte_ether_hdr *)orin_pkt_ptr; if(ether_hdr->ether_type != 0xAAAA) { assert(nr_sids != 0); } +#endif /* set route ctx and sids for deep copy buff */ marsio_buff_set_metadata(deep_copy_buff, MR_BUFF_ROUTE_CTX, route_ctx, sizeof(route_ctx)); @@ -94,7 +96,7 @@ __attribute__((noreturn)) void * l2fwd_loop(void * arg) } } - if(opt_inject_by_deep_copy) + if (opt_inject_by_deep_copy) { marsio_buff_free(mr_instance, rx_buff, ret, MARSIO_SOCKET_ID_ANY, MARSIO_LCORE_ID_ANY); marsio_send_burst(to_dev_1_sendpath, sid, tx_buff, (int)ret); |
