Skip to content

Commit d20a167

Browse files
Björn TöpelAlexei Starovoitov
authored andcommitted
xsk: Move xskmap.c to net/xdp/
The XSKMAP is partly implemented by net/xdp/xsk.c. Move xskmap.c from kernel/bpf/ to net/xdp/, which is the logical place for AF_XDP related code. Also, move AF_XDP struct definitions, and function declarations only used by AF_XDP internals into net/xdp/xsk.h. Signed-off-by: Björn Töpel <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 44ac082 commit d20a167

File tree

5 files changed

+19
-24
lines changed

5 files changed

+19
-24
lines changed

include/net/xdp_sock.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,12 @@ struct xdp_umem {
6565
struct list_head xsk_tx_list;
6666
};
6767

68-
/* Nodes are linked in the struct xdp_sock map_list field, and used to
69-
* track which maps a certain socket reside in.
70-
*/
71-
7268
struct xsk_map {
7369
struct bpf_map map;
7470
spinlock_t lock; /* Synchronize map updates */
7571
struct xdp_sock *xsk_map[];
7672
};
7773

78-
struct xsk_map_node {
79-
struct list_head node;
80-
struct xsk_map *map;
81-
struct xdp_sock **map_entry;
82-
};
83-
8474
struct xdp_sock {
8575
/* struct sock must be the first member of struct xdp_sock */
8676
struct sock sk;
@@ -114,7 +104,6 @@ struct xdp_sock {
114104
struct xdp_buff;
115105
#ifdef CONFIG_XDP_SOCKETS
116106
int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp);
117-
bool xsk_is_setup_for_bpf_map(struct xdp_sock *xs);
118107
/* Used from netdev driver */
119108
bool xsk_umem_has_addrs(struct xdp_umem *umem, u32 cnt);
120109
bool xsk_umem_peek_addr(struct xdp_umem *umem, u64 *addr);
@@ -133,10 +122,6 @@ void xsk_clear_rx_need_wakeup(struct xdp_umem *umem);
133122
void xsk_clear_tx_need_wakeup(struct xdp_umem *umem);
134123
bool xsk_umem_uses_need_wakeup(struct xdp_umem *umem);
135124

136-
void xsk_map_try_sock_delete(struct xsk_map *map, struct xdp_sock *xs,
137-
struct xdp_sock **map_entry);
138-
int xsk_map_inc(struct xsk_map *map);
139-
void xsk_map_put(struct xsk_map *map);
140125
int __xsk_map_redirect(struct xdp_sock *xs, struct xdp_buff *xdp);
141126
void __xsk_map_flush(void);
142127

@@ -248,11 +233,6 @@ static inline int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
248233
return -ENOTSUPP;
249234
}
250235

251-
static inline bool xsk_is_setup_for_bpf_map(struct xdp_sock *xs)
252-
{
253-
return false;
254-
}
255-
256236
static inline bool xsk_umem_has_addrs(struct xdp_umem *umem, u32 cnt)
257237
{
258238
return false;

kernel/bpf/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ obj-$(CONFIG_BPF_JIT) += dispatcher.o
1212
ifeq ($(CONFIG_NET),y)
1313
obj-$(CONFIG_BPF_SYSCALL) += devmap.o
1414
obj-$(CONFIG_BPF_SYSCALL) += cpumap.o
15-
ifeq ($(CONFIG_XDP_SOCKETS),y)
16-
obj-$(CONFIG_BPF_SYSCALL) += xskmap.o
17-
endif
1815
obj-$(CONFIG_BPF_SYSCALL) += offload.o
1916
endif
2017
ifeq ($(CONFIG_PERF_EVENTS),y)

net/xdp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
obj-$(CONFIG_XDP_SOCKETS) += xsk.o xdp_umem.o xsk_queue.o
2+
obj-$(CONFIG_XDP_SOCKETS) += xsk.o xdp_umem.o xsk_queue.o xskmap.o
33
obj-$(CONFIG_XDP_SOCKETS_DIAG) += xsk_diag.o

net/xdp/xsk.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,25 @@ struct xdp_mmap_offsets_v1 {
1717
struct xdp_ring_offset_v1 cr;
1818
};
1919

20+
/* Nodes are linked in the struct xdp_sock map_list field, and used to
21+
* track which maps a certain socket reside in.
22+
*/
23+
24+
struct xsk_map_node {
25+
struct list_head node;
26+
struct xsk_map *map;
27+
struct xdp_sock **map_entry;
28+
};
29+
2030
static inline struct xdp_sock *xdp_sk(struct sock *sk)
2131
{
2232
return (struct xdp_sock *)sk;
2333
}
2434

35+
bool xsk_is_setup_for_bpf_map(struct xdp_sock *xs);
36+
void xsk_map_try_sock_delete(struct xsk_map *map, struct xdp_sock *xs,
37+
struct xdp_sock **map_entry);
38+
int xsk_map_inc(struct xsk_map *map);
39+
void xsk_map_put(struct xsk_map *map);
40+
2541
#endif /* XSK_H_ */

kernel/bpf/xskmap.c renamed to net/xdp/xskmap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <linux/slab.h>
1010
#include <linux/sched.h>
1111

12+
#include "xsk.h"
13+
1214
int xsk_map_inc(struct xsk_map *map)
1315
{
1416
bpf_map_inc(&map->map);

0 commit comments

Comments
 (0)