Skip to content

Commit

Permalink
net_sched: introduce eBPF based Qdisc
Browse files Browse the repository at this point in the history
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
  • Loading branch information
congwang authored and intel-lab-lkp committed Dec 24, 2021
1 parent 98f7877 commit 3281415
Show file tree
Hide file tree
Showing 6 changed files with 571 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/linux/bpf_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ BPF_PROG_TYPE(BPF_PROG_TYPE_SCHED_CLS, tc_cls_act,
struct __sk_buff, struct sk_buff)
BPF_PROG_TYPE(BPF_PROG_TYPE_SCHED_ACT, tc_cls_act,
struct __sk_buff, struct sk_buff)
//BPF_PROG_TYPE(BPF_PROG_TYPE_SCHED_QDISC, tc_cls_act,
// struct __sk_buff, struct sk_buff)
BPF_PROG_TYPE(BPF_PROG_TYPE_XDP, xdp,
struct xdp_md, struct xdp_buff)
#ifdef CONFIG_CGROUP_BPF
Expand Down
15 changes: 15 additions & 0 deletions include/uapi/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@ enum bpf_prog_type {
BPF_PROG_TYPE_LSM,
BPF_PROG_TYPE_SK_LOOKUP,
BPF_PROG_TYPE_SYSCALL, /* a program that can execute syscalls */
BPF_PROG_TYPE_SCHED_QDISC,
};

enum bpf_attach_type {
Expand Down Expand Up @@ -6489,4 +6490,18 @@ struct bpf_core_relo {
enum bpf_core_relo_kind kind;
};

struct sch_bpf_ctx {
struct __sk_buff *skb;
__u32 classid;
__u64 delay;
};

enum {
SCH_BPF_OK,
SCH_BPF_QUEUED,
SCH_BPF_DROP,
SCH_BPF_THROTTLE,
SCH_BPF_CONTINUE,
};

#endif /* _UAPI__LINUX_BPF_H__ */
17 changes: 17 additions & 0 deletions include/uapi/linux/pkt_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -1267,4 +1267,21 @@ enum {

#define TCA_ETS_MAX (__TCA_ETS_MAX - 1)

#define TCA_SCH_BPF_FLAG_DIRECT _BITUL(0)
enum {
TCA_SCH_BPF_UNSPEC,
TCA_SCH_BPF_FLAGS, /* u32 */
TCA_SCH_BPF_ENQUEUE_PROG_NAME, /* string */
TCA_SCH_BPF_ENQUEUE_PROG_FD, /* u32 */
TCA_SCH_BPF_ENQUEUE_PROG_ID, /* u32 */
TCA_SCH_BPF_ENQUEUE_PROG_TAG, /* data */
TCA_SCH_BPF_DEQUEUE_PROG_NAME, /* string */
TCA_SCH_BPF_DEQUEUE_PROG_FD, /* u32 */
TCA_SCH_BPF_DEQUEUE_PROG_ID, /* u32 */
TCA_SCH_BPF_DEQUEUE_PROG_TAG, /* data */
__TCA_SCH_BPF_MAX,
};

#define TCA_SCH_BPF_MAX (__TCA_SCH_BPF_MAX - 1)

#endif
15 changes: 15 additions & 0 deletions net/sched/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,21 @@ config NET_SCH_ETS

If unsure, say N.

config NET_SCH_BPF
tristate "eBPF based programmable queue discipline"
help
This eBPF based queue discipline offers a way to program your
own packet scheduling algorithm. This is a classful qdisc which
also allows you to decide the hierarchy.

Say Y here if you want to use the eBPF based programmable queue
discipline.

To compile this driver as a module, choose M here: the module
will be called sch_bpf.

If unsure, say N.

menuconfig NET_SCH_DEFAULT
bool "Allow override default queue discipline"
help
Expand Down
1 change: 1 addition & 0 deletions net/sched/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ obj-$(CONFIG_NET_SCH_FQ_PIE) += sch_fq_pie.o
obj-$(CONFIG_NET_SCH_CBS) += sch_cbs.o
obj-$(CONFIG_NET_SCH_ETF) += sch_etf.o
obj-$(CONFIG_NET_SCH_TAPRIO) += sch_taprio.o
obj-$(CONFIG_NET_SCH_BPF) += sch_bpf.o

obj-$(CONFIG_NET_CLS_U32) += cls_u32.o
obj-$(CONFIG_NET_CLS_ROUTE4) += cls_route.o
Expand Down
Loading

0 comments on commit 3281415

Please sign in to comment.