summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2023-11-21 19:08:30 +0800
committerluwenpeng <[email protected]>2023-11-21 19:08:30 +0800
commitc3bd2fb9390931fdc20431cff192bbaa8b6b3a5d (patch)
treeccfc24a66de97985ba6a429220b7b5c98bad0915 /platform
parent332fe52650778e31d797f8e4071b20d05b7544cc (diff)
perf: 将marsio_send_burst_with_options替换成marsio_send_burst和marsio_buff_set_metadata(MR_BUFF_REHASH_INDEX)以降低CPU
Diffstat (limited to 'platform')
-rw-r--r--platform/include/sce.h1
-rw-r--r--platform/src/packet_io.cpp12
-rw-r--r--platform/src/sce.cpp12
3 files changed, 14 insertions, 11 deletions
diff --git a/platform/include/sce.h b/platform/include/sce.h
index 866bfca..0eba8c1 100644
--- a/platform/include/sce.h
+++ b/platform/include/sce.h
@@ -47,6 +47,7 @@ struct metadata
{
int write_ref;
uint64_t session_id;
+ uint32_t rehash_index;
char *raw_data;
int raw_len;
diff --git a/platform/src/packet_io.cpp b/platform/src/packet_io.cpp
index 305d418..6b8326c 100644
--- a/platform/src/packet_io.cpp
+++ b/platform/src/packet_io.cpp
@@ -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:
diff --git a/platform/src/sce.cpp b/platform/src/sce.cpp
index 6950ce3..9b870ef 100644
--- a/platform/src/sce.cpp
+++ b/platform/src/sce.cpp
@@ -32,6 +32,7 @@ void metadata_shallow_copy(struct metadata *dst, struct metadata *src)
{
dst->write_ref++;
dst->session_id = src->session_id;
+ dst->rehash_index = src->rehash_index;
dst->raw_data = NULL;
dst->raw_len = 0;
dst->l7offset = src->l7offset;
@@ -45,18 +46,11 @@ void metadata_shallow_copy(struct metadata *dst, struct metadata *src)
void metadata_deep_copy(struct metadata *dst, struct metadata *src)
{
- dst->write_ref++;
- dst->session_id = src->session_id;
+ metadata_shallow_copy(dst, src);
+
dst->raw_data = (char *)calloc(src->raw_len + 1, sizeof(char));
memcpy(dst->raw_data, src->raw_data, src->raw_len);
dst->raw_len = src->raw_len;
- dst->l7offset = src->l7offset;
- dst->is_e2i_dir = src->is_e2i_dir;
- dst->is_ctrl_pkt = src->is_ctrl_pkt;
- dst->is_decrypted = src->is_decrypted;
-
- sids_copy(&dst->sids, &src->sids);
- route_ctx_copy(&dst->route_ctx, &src->route_ctx);
}
void metadata_free(struct metadata *meta)