Introduce an eBPF hookpoint for tx queue selection in the XPS (Transmit Packet Steering) code.
Subsystems (4)
RFC 2/2 Introduce an eBPF hookpoint for tx queue selection in the XPS (Transmit Packet Steering) code.
WORK IN PROGRESS:
* bpf program loading works!
* txq steering via bpf program return code works!
* bpf program unloading not working.
* bpf program attached query not working.
--- include/bpf_api.h | 5 +++ include/uapi/linux/if_link.h | 12 ++++++ ip/Makefile | 2 +- ip/ip_common.h | 4 ++ ip/iplink.c | 7 ++++ ip/iplink_xps.c | 88 ++++++++++++++++++++++++++++++++++++++++++++ lib/bpf.c | 6 +++ 7 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 ip/iplink_xps.c
include/bpf_api.h +5 -0
@@ -78,6 +78,11 @@ __section(ELF_SECTION_PROG)#endif +#ifndef __section_xps_entry +# define __section_xps_entry \ + __section(ELF_SECTION_PROG) +#endif +#ifndef __section_cls_entry# define __section_cls_entry \ __section(ELF_SECTION_CLASSIFIER)
include/uapi/linux/if_link.h +12 -0
@@ -167,6 +167,7 @@ enum {IFLA_NEW_IFINDEX ,IFLA_MIN_MTU ,IFLA_MAX_MTU , +IFLA_XPS , __IFLA_MAX };
@@ -977,6 +978,17 @@ enum {#define IFLA_XDP_MAX (__IFLA_XDP_MAX - 1) +/* XPS section */ + +enum { +IFLA_XPS_UNSPEC , +IFLA_XPS_FD , +IFLA_XPS_ATTACHED , + __IFLA_XPS_MAX, +}; + +#define IFLA_XPS_MAX (__IFLA_XPS_MAX - 1) +enum {IFLA_EVENT_NONE ,IFLA_EVENT_REBOOT ,/* internal reset / reboot */
ip/Makefile +1 -1
@@ -5,7 +5,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \ ipxfrm.o xfrm_state.o xfrm_policy.o xfrm_monitor.o iplink_dummy.o \ iplink_ifb.o iplink_nlmon.o iplink_team.o iplink_vcan.o iplink_vxcan.o \ iplink_vlan.o link_veth.o link_gre.o iplink_can.o iplink_xdp.o \ - iplink_macvlan.o ipl2tp.o link_vti.o link_vti6.o link_xfrm.o \ + iplink_macvlan.o ipl2tp.o link_vti.o link_vti6.o link_xfrm.o iplink_xps.o \ iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \ link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o \ iplink_bridge.o iplink_bridge_slave.o ipfou.o iplink_ipvlan.o \
ip/ip_common.h +4 -0
@@ -145,6 +145,10 @@ int xdp_parse(int *argc, char ***argv, struct iplink_req *req, const char *ifnam bool generic, bool drv, bool offload);void xdp_dump (FILE *fp,struct rtattr *tb,bool link,bool details); +/* iplink_xps.c */ +int xps_parse (int *argc,char ***argv,struct iplink_req *req); +void xps_dump (FILE *fp,struct rtattr *tb); +/* iplink_vrf.c */ __u32 ipvrf_get_table (const char *name);int name_is_vrf (const char *name);
ip/iplink.c +7 -0
@@ -101,6 +101,9 @@ void iplink_usage(void)" [ { xdp | xdpgeneric | xdpdrv | xdpoffload } { off |\n" " object FILE [ section NAME ] [ verbose ] |\n" " pinned FILE } ]\n" +" [ xps { off |\n" +" object FILE [ section NAME ] [ verbose ] |\n" +" pinned FILE } ]\n" " [ master DEVICE ][ vrf NAME ]\n" " [ nomaster ]\n" " [ addrgenmode { eui64 | none | stable_secret | random } ]\n"
@@ -668,6 +671,10 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)if (offload && name == dev) dev =NULL ; + }else if (strcmp (*argv,"xps" ) ==0 ) { +NEXT_ARG (); +if (xps_parse (&argc, &argv, req)) +exit (-1 ); }else if (strcmp (*argv,"netns" ) ==0 ) {NEXT_ARG ();if (netns !=-1 )
ip/iplink_xps.c new file +88 -0
88 lines not on this page · raw message
lib/bpf.c +6 -0
@@ -60,6 +60,7 @@ static const enum bpf_prog_type __bpf_types[] = {BPF_PROG_TYPE_LWT_IN ,BPF_PROG_TYPE_LWT_OUT ,BPF_PROG_TYPE_LWT_XMIT , + BPF_PROG_TYPE_SOCKET_FILTER, }; static const struct bpf_prog_meta __bpf_prog_meta[] = {
@@ -100,6 +101,11 @@ static const struct bpf_prog_meta __bpf_prog_meta[] = { .subdir = "ip", .section = ELF_SECTION_PROG, }, + [BPF_PROG_TYPE_SOCKET_FILTER] = { + .type = "xps", + .subdir = "xps", + .section = ELF_SECTION_PROG, + }, };static const char *bpf_prog_to_subdir (enum bpf_prog_type type)
Signature · 1 line
1.8.3.1