From a086214f65b4eb2b35abc6648f3960e5852536a5 Mon Sep 17 00:00:00 2001 From: Michel Machado Date: Wed, 26 Jun 2024 11:00:55 -0400 Subject: [PATCH 1/3] =?UTF-8?q?lib/fib:=20avoid=20warning:=20=E2=80=98dumm?= =?UTF-8?q?y=E2=80=99=20may=20be=20used=20uninitialized?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit avoids the following compilation warning: lib/rib.c: In function ‘rib_create’: lib/rib.c:125:15: warning: ‘dummy’ may be used uninitialized [-Wmaybe-uninitialized] 125 | ret = __read_addr(max_length, &dummy, (const uint8_t *)&dummy); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/rib.c:30:1: note: by argument 3 of type ‘const uint8_t *’ {aka ‘const unsigned char *’} to ‘__read_addr’ declared here 30 | __read_addr(uint8_t length, rib_address_t *cpu_addr, const uint8_t *address) | ^~~~~~~~~~~ lib/rib.c:109:23: note: ‘dummy’ declared here 109 | rib_address_t dummy; | ^~~~~ --- lib/rib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rib.c b/lib/rib.c index 41465688..36b7c571 100644 --- a/lib/rib.c +++ b/lib/rib.c @@ -106,7 +106,8 @@ int rib_create(struct rib_head *rib, const char *name, int socket_id, uint8_t max_length, uint32_t max_rules) { - rib_address_t dummy; + /* Initialize to avoid warning: ‘dummy’ may be used uninitialized. */ + rib_address_t dummy = 0; int ret; unsigned int n; From d1d2e15d01ca9a069c777456d87a5dcf0d4eb9dc Mon Sep 17 00:00:00 2001 From: Michel Machado Date: Wed, 26 Jun 2024 11:17:55 -0400 Subject: [PATCH 2/3] gatekeeper: replace gettid() with rte_gettid() Not only does gettid() require #define _GNU_SOURCE, but it has also presented header problems in different versions of Lib C. So this commit eases the effort to compile Gatekeeper on different distros. A small benefit gained from using rte_gettid() is that it caches the thread ID in a per-thread variable to avoid subsequent system calls. --- config/dynamic.c | 8 ++------ cps/main.c | 6 +----- ggu/main.c | 6 +----- gk/main.c | 6 +----- gt/main.c | 6 +----- lls/main.c | 6 +----- sol/main.c | 7 ++----- 7 files changed, 9 insertions(+), 36 deletions(-) diff --git a/config/dynamic.c b/config/dynamic.c index 1a7a08f8..38e69f47 100644 --- a/config/dynamic.c +++ b/config/dynamic.c @@ -16,13 +16,9 @@ * along with this program. If not, see . */ -/* For gettid(). */ -#define _GNU_SOURCE - #include #include #include -#include #include #include #include @@ -621,8 +617,8 @@ dyn_cfg_proc(void *arg) int ret = 0; struct dynamic_config *dy_conf = arg; - G_LOG(NOTICE, - "The Dynamic Config block is running at tid = %u\n", gettid()); + G_LOG(NOTICE, "The Dynamic Config block is running at tid = %u\n", + rte_gettid()); if (dy_conf->gt != NULL) { /* diff --git a/cps/main.c b/cps/main.c index 8bf8b5f4..4a0ca788 100644 --- a/cps/main.c +++ b/cps/main.c @@ -16,11 +16,7 @@ * along with this program. If not, see . */ -/* For gettid(). */ -#define _GNU_SOURCE - #include -#include #include "gatekeeper_cps.h" #include "gatekeeper_l2.h" @@ -688,7 +684,7 @@ cps_proc(void *arg) */ cap_value_t caps[] = {CAP_NET_ADMIN, CAP_SYS_MODULE}; - G_LOG(NOTICE, "The CPS block is running at tid = %u\n", gettid()); + G_LOG(NOTICE, "The CPS block is running at tid = %u\n", rte_gettid()); if (needed_caps(RTE_DIM(caps), caps) < 0) { G_LOG(ERR, "Could not set needed capabilities\n"); diff --git a/ggu/main.c b/ggu/main.c index 1ab4a82d..de2dbd02 100644 --- a/ggu/main.c +++ b/ggu/main.c @@ -16,11 +16,7 @@ * along with this program. If not, see . */ -/* For gettid(). */ -#define _GNU_SOURCE - #include -#include #include #include @@ -586,7 +582,7 @@ ggu_proc(void *arg) uint16_t rx_queue = ggu_conf->rx_queue_back; uint16_t max_pkt_burst = ggu_conf->max_pkt_burst; - G_LOG(NOTICE, "The GT-GK unit is running at tid = %u\n", gettid()); + G_LOG(NOTICE, "The GT-GK unit is running at tid = %u\n", rte_gettid()); if (needed_caps(0, NULL) < 0) { G_LOG(ERR, "Could not set needed capabilities\n"); diff --git a/gk/main.c b/gk/main.c index eadd3598..b576781e 100644 --- a/gk/main.c +++ b/gk/main.c @@ -16,15 +16,11 @@ * along with this program. If not, see . */ -/* For gettid(). */ -#define _GNU_SOURCE - #include #include #include #include #include -#include #include #include @@ -2350,7 +2346,7 @@ gk_proc(void *arg) uint32_t scan_iter = gk_conf->flow_table_scan_iter; uint32_t iter_count = 0; - G_LOG(NOTICE, "The GK block is running at tid = %u\n", gettid()); + G_LOG(NOTICE, "The GK block is running at tid = %u\n", rte_gettid()); if (needed_caps(0, NULL) < 0) { G_LOG(ERR, "Could not set needed capabilities\n"); diff --git a/gt/main.c b/gt/main.c index 335a1198..ad320f61 100644 --- a/gt/main.c +++ b/gt/main.c @@ -16,16 +16,12 @@ * along with this program. If not, see . */ -/* For gettid(). */ -#define _GNU_SOURCE - #include #include #include #include #include #include -#include #include #include @@ -1617,7 +1613,7 @@ gt_proc(void *arg) death_row.cnt = 0; gt_max_pkt_burst = gt_conf->max_pkt_burst; - G_LOG(NOTICE, "The GT block is running at tid = %u\n", gettid()); + G_LOG(NOTICE, "The GT block is running at tid = %u\n", rte_gettid()); if (needed_caps(RTE_DIM(caps), caps) < 0) { G_LOG(ERR, "Could not set needed capabilities\n"); diff --git a/lls/main.c b/lls/main.c index 9a071ad1..4e737f43 100644 --- a/lls/main.c +++ b/lls/main.c @@ -16,11 +16,7 @@ * along with this program. If not, see . */ -/* For gettid(). */ -#define _GNU_SOURCE - #include -#include #include #include @@ -681,7 +677,7 @@ lls_proc(void *arg) uint64_t timer_resolution_cycles = net_conf->rotate_log_interval_sec * cycles_per_sec; - G_LOG(NOTICE, "The LLS block is running at tid = %u\n", gettid()); + G_LOG(NOTICE, "The LLS block is running at tid = %u\n", rte_gettid()); if (needed_caps(0, NULL) < 0) { G_LOG(ERR, "Could not set needed capabilities\n"); diff --git a/sol/main.c b/sol/main.c index 88f41e10..7c1bfe79 100644 --- a/sol/main.c +++ b/sol/main.c @@ -16,11 +16,7 @@ * along with this program. If not, see . */ -/* For gettid(). */ -#define _GNU_SOURCE - #include -#include #include #include @@ -517,7 +513,8 @@ sol_proc(void *arg) struct sol_instance *instance = &sol_conf->instances[block_idx]; uint8_t tx_port_back = sol_conf->net->back.id; - G_LOG(NOTICE, "The Solicitor block is running at tid = %u\n", gettid()); + G_LOG(NOTICE, "The Solicitor block is running at tid = %u\n", + rte_gettid()); if (needed_caps(0, NULL) < 0) { G_LOG(ERR, "Could not set needed capabilities\n"); From 59d307a8ef884d922a557ebdd85ca55d48318cf0 Mon Sep 17 00:00:00 2001 From: Michel Machado Date: Wed, 26 Jun 2024 13:14:57 -0400 Subject: [PATCH 3/3] lib/net: set all RSS fields in check_if_rss() This commit centralizes all RSS fields that need to be set in check_if_rss(). --- lib/net.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/net.c b/lib/net.c index eb0412b1..44aa2846 100644 --- a/lib/net.c +++ b/lib/net.c @@ -1224,6 +1224,8 @@ check_if_rss(struct gatekeeper_if *iface, * hash functions. */ iface->rss = true; + port_conf->rx_adv_conf.rss_conf.algorithm = + RTE_ETH_HASH_FUNCTION_DEFAULT; port_conf->rx_adv_conf.rss_conf.rss_hf = 0; if (ipv4_if_configured(iface)) { port_conf->rx_adv_conf.rss_conf.rss_hf |= @@ -1345,6 +1347,7 @@ check_if_rss(struct gatekeeper_if *iface, disable_rss: iface->rss = false; + port_conf->rxmode.mq_mode = RTE_ETH_MQ_RX_NONE; port_conf->rx_adv_conf.rss_conf.rss_hf = 0; iface->num_rx_queues = 1; G_LOG(WARNING, "%s(%s): the interface does not have RSS capabilities; the GK or GT block will receive all packets and send them to the other blocks as needed. Gatekeeper or Grantor should only be run with one lcore dedicated to GK or GT in this mode; restart with only one GK or GT lcore if necessary\n", @@ -1973,12 +1976,7 @@ monitor_links(struct gatekeeper_if *iface) static int init_iface(struct gatekeeper_if *iface) { - struct rte_eth_conf port_conf = { - .rxmode = { - .mq_mode = RTE_ETH_MQ_RX_NONE, - }, - /* Other offloads configured below. */ - }; + struct rte_eth_conf port_conf = {}; unsigned int i; int ret;