修改packet_io API的函数命名
This commit is contained in:
@@ -59,13 +59,13 @@ void packet_io_destory(struct packet_io *handle);
|
|||||||
|
|
||||||
// return 0 for success
|
// return 0 for success
|
||||||
// return -1 for error
|
// return -1 for error
|
||||||
int packet_io_thread_init(struct packet_io *handle, struct thread_ctx *thread_ctx);
|
int packet_io_init(struct packet_io *handle, struct thread_ctx *thread_ctx);
|
||||||
void packet_io_thread_wait(struct packet_io *handle, struct thread_ctx *thread_ctx, int timeout_ms);
|
void packet_io_wait(struct packet_io *handle, struct thread_ctx *thread_ctx, int timeout_ms);
|
||||||
|
|
||||||
// return n_packet_recved
|
// return n_packet_recved
|
||||||
int packet_io_thread_polling_nf(struct packet_io *handle, struct thread_ctx *thread_ctx);
|
int packet_io_polling_nf(struct packet_io *handle, struct thread_ctx *thread_ctx);
|
||||||
int packet_io_thread_polling_endpoint_l3(struct packet_io *handle, struct thread_ctx *thread_ctx);
|
int packet_io_polling_endpoint_l3(struct packet_io *handle, struct thread_ctx *thread_ctx);
|
||||||
int packet_io_thread_polling_endpoint_l2(struct packet_io *handle, struct thread_ctx *thread_ctx);
|
int packet_io_polling_endpoint_l2(struct packet_io *handle, struct thread_ctx *thread_ctx);
|
||||||
|
|
||||||
#ifdef __cpluscplus
|
#ifdef __cpluscplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ static void *worker_thread_cycle(void *arg)
|
|||||||
snprintf(thread_name, sizeof(thread_name), "sce:worker-%d", thread_index);
|
snprintf(thread_name, sizeof(thread_name), "sce:worker-%d", thread_index);
|
||||||
prctl(PR_SET_NAME, (unsigned long long)thread_name, NULL, NULL, NULL);
|
prctl(PR_SET_NAME, (unsigned long long)thread_name, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (packet_io_thread_init(handle, thread_ctx) != 0)
|
if (packet_io_init(handle, thread_ctx) != 0)
|
||||||
{
|
{
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
@@ -90,9 +90,9 @@ static void *worker_thread_cycle(void *arg)
|
|||||||
|
|
||||||
while (!ATOMIC_READ(&is_need_stop))
|
while (!ATOMIC_READ(&is_need_stop))
|
||||||
{
|
{
|
||||||
n_packet_recved = packet_io_thread_polling_nf(handle, thread_ctx);
|
n_packet_recved = packet_io_polling_nf(handle, thread_ctx);
|
||||||
n_packet_recved += packet_io_thread_polling_endpoint_l3(handle, thread_ctx);
|
n_packet_recved += packet_io_polling_endpoint_l3(handle, thread_ctx);
|
||||||
n_packet_recved += packet_io_thread_polling_endpoint_l2(handle, thread_ctx);
|
n_packet_recved += packet_io_polling_endpoint_l2(handle, thread_ctx);
|
||||||
if (n_packet_recved == 0)
|
if (n_packet_recved == 0)
|
||||||
{
|
{
|
||||||
timeout_ms = sf_metrics_last_send_ts + sf_metrics_send_interval - timestamp_get_msec(ts);
|
timeout_ms = sf_metrics_last_send_ts + sf_metrics_send_interval - timestamp_get_msec(ts);
|
||||||
@@ -101,7 +101,7 @@ static void *worker_thread_cycle(void *arg)
|
|||||||
timeout_ms = 0;
|
timeout_ms = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet_io_thread_wait(handle, thread_ctx, timeout_ms);
|
packet_io_wait(handle, thread_ctx, timeout_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
global_metrics_update(global_metrics, thread_metrics, thread_index);
|
global_metrics_update(global_metrics, thread_metrics, thread_index);
|
||||||
|
|||||||
@@ -1461,7 +1461,7 @@ void packet_io_destory(struct packet_io *handle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int packet_io_thread_init(struct packet_io *handle, struct thread_ctx *thread_ctx)
|
int packet_io_init(struct packet_io *handle, struct thread_ctx *thread_ctx)
|
||||||
{
|
{
|
||||||
if (marsio_thread_init(handle->instance) != 0)
|
if (marsio_thread_init(handle->instance) != 0)
|
||||||
{
|
{
|
||||||
@@ -1472,7 +1472,7 @@ int packet_io_thread_init(struct packet_io *handle, struct thread_ctx *thread_ct
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet_io_thread_wait(struct packet_io *handle, struct thread_ctx *thread_ctx, int timeout_ms)
|
void packet_io_wait(struct packet_io *handle, struct thread_ctx *thread_ctx, int timeout_ms)
|
||||||
{
|
{
|
||||||
struct mr_vdev *vdevs[3] = {
|
struct mr_vdev *vdevs[3] = {
|
||||||
handle->dev_nf.mr_dev,
|
handle->dev_nf.mr_dev,
|
||||||
@@ -1491,7 +1491,7 @@ void packet_io_thread_wait(struct packet_io *handle, struct thread_ctx *thread_c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int packet_io_thread_polling_nf(struct packet_io *handle, struct thread_ctx *thread_ctx)
|
int packet_io_polling_nf(struct packet_io *handle, struct thread_ctx *thread_ctx)
|
||||||
{
|
{
|
||||||
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
||||||
int thread_index = thread_ctx->thread_index;
|
int thread_index = thread_ctx->thread_index;
|
||||||
@@ -1554,7 +1554,7 @@ int packet_io_thread_polling_nf(struct packet_io *handle, struct thread_ctx *thr
|
|||||||
return nr_recv;
|
return nr_recv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int packet_io_thread_polling_endpoint_l3(struct packet_io *handle, struct thread_ctx *thread_ctx)
|
int packet_io_polling_endpoint_l3(struct packet_io *handle, struct thread_ctx *thread_ctx)
|
||||||
{
|
{
|
||||||
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
||||||
int thread_index = thread_ctx->thread_index;
|
int thread_index = thread_ctx->thread_index;
|
||||||
@@ -1590,7 +1590,7 @@ int packet_io_thread_polling_endpoint_l3(struct packet_io *handle, struct thread
|
|||||||
return nr_recv;
|
return nr_recv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int packet_io_thread_polling_endpoint_l2(struct packet_io *handle, struct thread_ctx *thread_ctx)
|
int packet_io_polling_endpoint_l2(struct packet_io *handle, struct thread_ctx *thread_ctx)
|
||||||
{
|
{
|
||||||
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
||||||
int thread_index = thread_ctx->thread_index;
|
int thread_index = thread_ctx->thread_index;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ TEST(PACKET_IO, DATA_PKT_MIRR_FORWARD)
|
|||||||
mr_instance = packet_io_get_mr_instance(gtest_frame->sce_ctx->io);
|
mr_instance = packet_io_get_mr_instance(gtest_frame->sce_ctx->io);
|
||||||
gtest_frame_run(gtest_frame, tx_mbuf1, dup_mbuf1, 1);
|
gtest_frame_run(gtest_frame, tx_mbuf1, dup_mbuf1, 1);
|
||||||
marsio_set_recv_mbuff(mr_instance, tx_mbuf2);
|
marsio_set_recv_mbuff(mr_instance, tx_mbuf2);
|
||||||
EXPECT_TRUE(packet_io_thread_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
EXPECT_TRUE(packet_io_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
||||||
temp_mbuf = marsio_get_send_mbuff(mr_instance);
|
temp_mbuf = marsio_get_send_mbuff(mr_instance);
|
||||||
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, temp_mbuf) == 0);
|
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, temp_mbuf) == 0);
|
||||||
EXPECT_TRUE(marsio_mbuff_cmp(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0);
|
EXPECT_TRUE(marsio_mbuff_cmp(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0);
|
||||||
|
|||||||
@@ -53,14 +53,14 @@ TEST(PACKET_IO, DATA_PKT_MIRR_RX_DROP)
|
|||||||
// recv data_pkt from nf
|
// recv data_pkt from nf
|
||||||
// send vxlan_pkt to sf
|
// send vxlan_pkt to sf
|
||||||
marsio_set_recv_mbuff(mr_instance, tx_mbuf2);
|
marsio_set_recv_mbuff(mr_instance, tx_mbuf2);
|
||||||
EXPECT_TRUE(packet_io_thread_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
EXPECT_TRUE(packet_io_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
||||||
temp_mbuf = marsio_get_send_mbuff(mr_instance);
|
temp_mbuf = marsio_get_send_mbuff(mr_instance);
|
||||||
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, temp_mbuf) == 0);
|
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, temp_mbuf) == 0);
|
||||||
EXPECT_TRUE(marsio_mbuff_cmp(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0);
|
EXPECT_TRUE(marsio_mbuff_cmp(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0);
|
||||||
// recv vxlan_pkt from sf
|
// recv vxlan_pkt from sf
|
||||||
// send data_pkt to nf
|
// send data_pkt to nf
|
||||||
marsio_set_recv_mbuff(mr_instance, temp_mbuf);
|
marsio_set_recv_mbuff(mr_instance, temp_mbuf);
|
||||||
EXPECT_TRUE(packet_io_thread_polling_endpoint_l3(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
EXPECT_TRUE(packet_io_polling_endpoint_l3(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
||||||
EXPECT_TRUE(marsio_get_send_mbuff(mr_instance) == NULL);
|
EXPECT_TRUE(marsio_get_send_mbuff(mr_instance) == NULL);
|
||||||
|
|
||||||
gtest_frame_log(gtest_frame);
|
gtest_frame_log(gtest_frame);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ TEST(PACKET_IO, DATA_PKT_STEE_FORWARD)
|
|||||||
mr_instance = packet_io_get_mr_instance(gtest_frame->sce_ctx->io);
|
mr_instance = packet_io_get_mr_instance(gtest_frame->sce_ctx->io);
|
||||||
gtest_frame_run(gtest_frame, tx_mbuf1, dup_mbuf1, 1);
|
gtest_frame_run(gtest_frame, tx_mbuf1, dup_mbuf1, 1);
|
||||||
marsio_set_recv_mbuff(mr_instance, tx_mbuf2);
|
marsio_set_recv_mbuff(mr_instance, tx_mbuf2);
|
||||||
EXPECT_TRUE(packet_io_thread_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
EXPECT_TRUE(packet_io_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
||||||
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0);
|
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0);
|
||||||
|
|
||||||
gtest_frame_log(gtest_frame);
|
gtest_frame_log(gtest_frame);
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ TEST(PACKET_IO, DATA_PKT_STEE_RX_EGRESS)
|
|||||||
// recv data_pkt from nf
|
// recv data_pkt from nf
|
||||||
// send vxlan_pkt to sf
|
// send vxlan_pkt to sf
|
||||||
marsio_set_recv_mbuff(mr_instance, tx_mbuf2);
|
marsio_set_recv_mbuff(mr_instance, tx_mbuf2);
|
||||||
EXPECT_TRUE(packet_io_thread_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
EXPECT_TRUE(packet_io_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
||||||
vxlan_mbuf = marsio_get_send_mbuff(mr_instance);
|
vxlan_mbuf = marsio_get_send_mbuff(mr_instance);
|
||||||
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, vxlan_mbuf) == 0);
|
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, vxlan_mbuf) == 0);
|
||||||
// recv vxlan_pkt from sf
|
// recv vxlan_pkt from sf
|
||||||
// send data_pkt to nf
|
// send data_pkt to nf
|
||||||
marsio_set_recv_mbuff(mr_instance, vxlan_mbuf);
|
marsio_set_recv_mbuff(mr_instance, vxlan_mbuf);
|
||||||
EXPECT_TRUE(packet_io_thread_polling_endpoint_l3(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
EXPECT_TRUE(packet_io_polling_endpoint_l3(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
||||||
EXPECT_TRUE(marsio_mbuff_cmp(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0);
|
EXPECT_TRUE(marsio_mbuff_cmp(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0);
|
||||||
|
|
||||||
gtest_frame_log(gtest_frame);
|
gtest_frame_log(gtest_frame);
|
||||||
|
|||||||
@@ -97,12 +97,12 @@ TEST(PACKET_IO, MIX_PKT_STEE_FORWARD)
|
|||||||
// recv raw packet from nf
|
// recv raw packet from nf
|
||||||
// send vxlan packet to sf
|
// send vxlan packet to sf
|
||||||
marsio_set_recv_mbuff(mr_instance, tx_mbuf2);
|
marsio_set_recv_mbuff(mr_instance, tx_mbuf2);
|
||||||
EXPECT_TRUE(packet_io_thread_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
EXPECT_TRUE(packet_io_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
||||||
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0);
|
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0);
|
||||||
// recv decrypted packet from nf
|
// recv decrypted packet from nf
|
||||||
// send vxlan packet to sf
|
// send vxlan packet to sf
|
||||||
marsio_set_recv_mbuff(mr_instance, tx_mbuf4);
|
marsio_set_recv_mbuff(mr_instance, tx_mbuf4);
|
||||||
EXPECT_TRUE(packet_io_thread_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
EXPECT_TRUE(packet_io_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
||||||
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf4, marsio_get_send_mbuff(mr_instance)) == 0);
|
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf4, marsio_get_send_mbuff(mr_instance)) == 0);
|
||||||
|
|
||||||
gtest_frame_log(gtest_frame);
|
gtest_frame_log(gtest_frame);
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ inline struct gtest_frame *gtest_frame_new(const char *json_file, const char *de
|
|||||||
thread_ctx->ref_sce_ctx = sce_ctx;
|
thread_ctx->ref_sce_ctx = sce_ctx;
|
||||||
thread_ctx->session_table_need_reset = 0;
|
thread_ctx->session_table_need_reset = 0;
|
||||||
|
|
||||||
EXPECT_TRUE(packet_io_thread_init(sce_ctx->io, thread_ctx) == 0);
|
EXPECT_TRUE(packet_io_init(sce_ctx->io, thread_ctx) == 0);
|
||||||
|
|
||||||
instance->sce_ctx = sce_ctx;
|
instance->sce_ctx = sce_ctx;
|
||||||
instance->json_file = strdup(json_file);
|
instance->json_file = strdup(json_file);
|
||||||
@@ -159,11 +159,11 @@ inline void gtest_frame_run(struct gtest_frame *instance, marsio_buff_t *tx_mbuf
|
|||||||
|
|
||||||
if (is_poll_nf)
|
if (is_poll_nf)
|
||||||
{
|
{
|
||||||
EXPECT_TRUE(packet_io_thread_polling_nf(sce_ctx->io, thread_ctx) == 1);
|
EXPECT_TRUE(packet_io_polling_nf(sce_ctx->io, thread_ctx) == 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EXPECT_TRUE(packet_io_thread_polling_endpoint_l3(sce_ctx->io, thread_ctx) == 1);
|
EXPECT_TRUE(packet_io_polling_endpoint_l3(sce_ctx->io, thread_ctx) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rx_mbuf = marsio_get_send_mbuff(mr_instance);
|
rx_mbuf = marsio_get_send_mbuff(mr_instance);
|
||||||
|
|||||||
Reference in New Issue
Block a user