summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2022-08-03 18:21:22 +0800
committerluwenpeng <[email protected]>2022-08-03 18:30:24 +0800
commit6cb27c307c3c22c0739c4d235a2de372b32762d2 (patch)
tree229bc6b830d88cadece196d416e7b033d0df2c12
parent3cc6d58dc55026e8877020acb758cd61a3c1d6ff (diff)
set rps use fwritev5.0.2
-rw-r--r--entry/src/kni_entry.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/entry/src/kni_entry.cpp b/entry/src/kni_entry.cpp
index 8e44711..507d883 100644
--- a/entry/src/kni_entry.cpp
+++ b/entry/src/kni_entry.cpp
@@ -20,6 +20,10 @@ bypass: drome: pme_new_fail: destroy_pme
#include <tsg/tsg_rule.h>
#include <tsg/tsg_send_log.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -2558,6 +2562,28 @@ int register_signal_handle(){
}
*/
+int set_rps(void *local_logger, const char *tap_name, int thread_num, const char *rps_mask)
+{
+ char file[1024] = {0};
+ for (int i = 0; i < thread_num; i++)
+ {
+ memset(file, 0, sizeof(file));
+ snprintf(file, sizeof(file), "/sys/class/net/%s/queues/rx-%d/rps_cpus", tap_name, i);
+
+ FILE *fp = fopen(file, "w");
+ if (fp == NULL)
+ {
+ KNI_LOG_ERROR(local_logger, TAP_RSS_LOG_TAG, "can't open %s, %s", file, strerror(errno));
+ return -1;
+ }
+
+ fwrite(rps_mask, strlen(rps_mask), 1, fp);
+ KNI_LOG_DEBUG(local_logger, TAP_RSS_LOG_TAG "set rps '%s' to %s", rps_mask, file);
+ fclose(fp);
+ }
+ return 0;
+}
+
extern "C" int kni_init(){
//register_signal_handle();
char *kni_git_verison = (char*)KNI_GIT_VERSION;
@@ -2812,6 +2838,7 @@ extern "C" int kni_init(){
if (g_kni_handle->tap_rps_enable)
{
+#if 0
char rps_cmd[2048];
for (int i = 0; i < g_kni_handle->thread_count; i++)
{
@@ -2820,6 +2847,11 @@ extern "C" int kni_init(){
system(rps_cmd);
KNI_LOG_DEBUG(local_logger, TAP_RSS_LOG_TAG "'%s'", rps_cmd);
}
+#endif
+ if (set_rps(local_logger, tap_name, g_kni_handle->thread_count, g_kni_handle->tap_rps_mask) == -1)
+ {
+ goto error_out;
+ }
}
//init ssl dynamic bypass htable