perf: 减少marsio_buff_is_ctrlbuf的调用以提升性能

This commit is contained in:
luwenpeng
2023-11-22 16:33:52 +08:00
parent d981c59dba
commit 81679c4d22

View File

@@ -100,9 +100,8 @@ int mbuff_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
return -1; return -1;
} }
if (marsio_buff_is_ctrlbuf(rx_buff)) if (meta->is_ctrl_pkt)
{ {
meta->is_ctrl_pkt = 1;
if (marsio_buff_get_metadata(rx_buff, MR_BUFF_PAYLOAD_OFFSET, &(meta->l7offset), sizeof(meta->l7offset)) <= 0) if (marsio_buff_get_metadata(rx_buff, MR_BUFF_PAYLOAD_OFFSET, &(meta->l7offset), sizeof(meta->l7offset)) <= 0)
{ {
LOG_ERROR("%s: unable to get l7offset from metadata", LOG_TAG_PKTIO); LOG_ERROR("%s: unable to get l7offset from metadata", LOG_TAG_PKTIO);
@@ -111,7 +110,6 @@ int mbuff_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
} }
else else
{ {
meta->is_ctrl_pkt = 0;
uint16_t user_data = 0; uint16_t user_data = 0;
if (marsio_buff_get_metadata(rx_buff, MR_BUFF_USER_0, &user_data, sizeof(user_data)) <= 0) if (marsio_buff_get_metadata(rx_buff, MR_BUFF_USER_0, &user_data, sizeof(user_data)) <= 0)
{ {
@@ -1040,6 +1038,7 @@ static void handle_control_packet(marsio_buff_t *rx_buff, struct thread_ctx *thr
struct control_packet ctrl_pkt; struct control_packet ctrl_pkt;
memset(&meta, 0, sizeof(struct metadata)); memset(&meta, 0, sizeof(struct metadata));
meta.is_ctrl_pkt = 1;
meta.raw_len = raw_len; meta.raw_len = raw_len;
meta.raw_data = marsio_buff_mtod(rx_buff); meta.raw_data = marsio_buff_mtod(rx_buff);
if (mbuff_get_metadata(rx_buff, &meta) == -1) if (mbuff_get_metadata(rx_buff, &meta) == -1)
@@ -1099,6 +1098,7 @@ static void handle_data_packet(marsio_buff_t *rx_buff, struct thread_ctx *thread
struct selected_chaining *chaining = NULL; struct selected_chaining *chaining = NULL;
memset(&meta, 0, sizeof(struct metadata)); memset(&meta, 0, sizeof(struct metadata));
meta.is_ctrl_pkt = 0;
meta.raw_len = raw_len; meta.raw_len = raw_len;
meta.raw_data = marsio_buff_mtod(rx_buff); meta.raw_data = marsio_buff_mtod(rx_buff);
if (mbuff_get_metadata(rx_buff, &meta) == -1) if (mbuff_get_metadata(rx_buff, &meta) == -1)