Skip to contentSkip to conversation

staging: r8188eu: Add queue_index to xdp_rxq_info

PATCH In review Varshini Elangovan 3 participants 3 messages Jun 2, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: r8188eu: Add queue_index to xdp_rxq_info

Queue_index from the xdp_rxq_info is populated in cpumap file. Using the NR_CPUS, results in patch check warning, as recommended, using the num_possible_cpus() instead of NR_CPUS

---
 kernel/bpf/cpumap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/bpf/cpumap.c +3 -3
index 650e5d21f90d..756fd81f474c 100644
@@ -102,8 +102,8 @@ static struct bpf_map *cpu_map_alloc(union bpf_attr *attr)
 
 	bpf_map_init_from_attr(&cmap->map, attr);
 
-	/* Pre-limit array size based on NR_CPUS, not final CPU check */
-	if (cmap->map.max_entries > NR_CPUS) {
+	/* Pre-limit array size based on num_possible_cpus, not final CPU check */
+	if (cmap->map.max_entries > num_possible_cpus()) {
 		err = -E2BIG;
 		goto free_cmap;
 	}
@@ -227,7 +227,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
 
 		rxq.dev = xdpf->dev_rx;
 		rxq.mem = xdpf->mem;
-		/* TODO: report queue_index to xdp_rxq_info */
+		rxq.queue_index = ++i;
 
 		xdp_convert_frame_to_buff(xdpf, &xdp);
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 1 line · On Thu, 2 Jun 2022 23:06:57 +0530 Varshini Elangovan wrote:

Subject: [PATCH] staging: r8188eu: Add queue_index to xdp_rxq_info

For a second there I thought we had a wifi driver with XDP support in staging :/

#2 lore raw
In reply to Varshini Elangovan
Quoted 26 lines · Varshini Elangovan

Queue_index from the xdp_rxq_info is populated in cpumap file. Using the NR_CPUS, results in patch check warning, as recommended, using the num_possible_cpus() instead of NR_CPUS

---
kernel/bpf/cpumap.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
kernel/bpf/cpumap.c +2 -2
index 650e5d21f90d..756fd81f474c 100644
@@ -102,8 +102,8 @@ static struct bpf_map *cpu_map_alloc(union bpf_attr *attr)
 
 bpf_map_init_from_attr(&cmap->map, attr);
 
- /* Pre-limit array size based on NR_CPUS, not final CPU check */
- if (cmap->map.max_entries > NR_CPUS) {
+ /* Pre-limit array size based on num_possible_cpus, not final CPU check */
+ if (cmap->map.max_entries > num_possible_cpus()) {
 err = -E2BIG;
 goto free_cmap;
 }

kernel/bpf/cpumap.c static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu, · line 230

Quoted 5 lines
kernel/bpf/cpumap.c +1 -1
@@ -227,7 +227,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
 
 rxq.dev = xdpf->dev_rx;
 rxq.mem = xdpf->mem;
- /* TODO: report queue_index to xdp_rxq_info */
+ rxq.queue_index = ++i;

I don't think this is correct. i is the frame index, not the queue index. There is (as far as I can tell) no correlation between the two.

Additionally, i is the loop variable, and the ++ operator will change its value, causing frames to be skipped.

Quoted 7 lines
kernel/bpf/cpumap.c +0 -1
 xdp_convert_frame_to_buff(xdpf, &xdp);
 
 
--

2.25.1