perf: 将marsio_send_burst_with_options替换成marsio_send_burst和marsio_buff_set_metadata(MR_BUFF_REHASH_INDEX)以降低CPU

This commit is contained in:
luwenpeng
2023-11-21 19:08:30 +08:00
parent 332fe52650
commit c3bd2fb939
4 changed files with 25 additions and 11 deletions

View File

@@ -96,6 +96,12 @@ int mbuff_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
return -1;
}
if (marsio_buff_get_metadata(rx_buff, MR_BUFF_REHASH_INDEX, &(meta->rehash_index), sizeof(meta->rehash_index)) <= 0)
{
LOG_ERROR("%s: unable to get rehash_index from metadata", LOG_TAG_PKTIO);
return -1;
}
// 1: E2I
// 0: I2E
if (marsio_buff_get_metadata(rx_buff, MR_BUFF_DIR, &(meta->is_e2i_dir), sizeof(meta->is_e2i_dir)) <= 0)
@@ -512,7 +518,8 @@ static inline int send_packet_to_sf(struct session_ctx *session_ctx, marsio_buff
session_ctx->vxlan_src_port, meta->raw_len,
meta->is_e2i_dir, meta->is_decrypted, sf->sf_index);
nsend = marsio_buff_datalen(mbuff);
marsio_send_burst_with_options(packet_io->dev_endpoint_l3.mr_path, thread_ctx->thread_index, &mbuff, 1, MARSIO_SEND_OPT_REHASH);
marsio_buff_set_metadata(mbuff, MR_BUFF_REHASH_INDEX, &(session_ctx->ctrl_meta->rehash_index), sizeof(session_ctx->ctrl_meta->rehash_index));
marsio_send_burst(packet_io->dev_endpoint_l3.mr_path, thread_ctx->thread_index, &mbuff, 1);
throughput_metrics_inc(&(thread_metrics->device.endpoint_vxlan_tx), 1, nsend);
break;
case ENCAPSULATE_METHOD_LAYER2_SWITCH:
@@ -520,7 +527,8 @@ static inline int send_packet_to_sf(struct session_ctx *session_ctx, marsio_buff
meta->is_e2i_dir ? sf->sf_connectivity.ext_vlan_tag : sf->sf_connectivity.int_vlan_tag,
packet_io->config.vlan_encapsulate_replace_orig_vlan_header);
nsend = marsio_buff_datalen(mbuff);
marsio_send_burst_with_options(packet_io->dev_endpoint_l2.mr_path, thread_ctx->thread_index, &mbuff, 1, MARSIO_SEND_OPT_REHASH);
marsio_buff_set_metadata(mbuff, MR_BUFF_REHASH_INDEX, &(session_ctx->ctrl_meta->rehash_index), sizeof(session_ctx->ctrl_meta->rehash_index));
marsio_send_burst(packet_io->dev_endpoint_l2.mr_path, thread_ctx->thread_index, &mbuff, 1);
throughput_metrics_inc(&(thread_metrics->device.endpoint_vlan_tx), 1, nsend);
break;
case ENCAPSULATE_METHOD_LAYER3_SWITCH: