summaryrefslogtreecommitdiff
path: root/common/src/tap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/tap.cpp')
-rw-r--r--common/src/tap.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/src/tap.cpp b/common/src/tap.cpp
index cb4537e..1edeb05 100644
--- a/common/src/tap.cpp
+++ b/common/src/tap.cpp
@@ -143,4 +143,23 @@ int tap_get_mtu(const char *eth)
close(sockfd);
return ifr.ifr_mtu;
+}
+
+int tap_set_rps(const char *eth, int thread_index, const char *rps_mask)
+{
+ char file[1024] = {0};
+
+ snprintf(file, sizeof(file), "/sys/class/net/%s/queues/rx-%d/rps_cpus", eth, thread_index);
+
+ FILE *fp = fopen(file, "w");
+ if (fp == NULL)
+ {
+ TFE_LOG_ERROR(g_default_logger, "unable to set rps on %s, file %s, %s", eth, file, strerror(errno));
+ return -1;
+ }
+
+ fwrite(rps_mask, strlen(rps_mask), 1, fp);
+ TFE_LOG_DEBUG(g_default_logger, "set rps '%s' to %s", rps_mask, file);
+ fclose(fp);
+ return 0;
} \ No newline at end of file