Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
e12f065d
Commit
e12f065d
authored
Nov 01, 2023
by
Jiri Kosina
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'for-6.7/selftests' into for-linus
- HID selftests fixes and improvements (Benjamin Tissoires)
parents
eacaa65e
91939636
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
9 deletions
+81
-9
tools/testing/selftests/hid/Makefile
tools/testing/selftests/hid/Makefile
+4
-6
tools/testing/selftests/hid/progs/hid.c
tools/testing/selftests/hid/progs/hid.c
+0
-3
tools/testing/selftests/hid/progs/hid_bpf_helpers.h
tools/testing/selftests/hid/progs/hid_bpf_helpers.h
+77
-0
No files found.
tools/testing/selftests/hid/Makefile
View file @
e12f065d
...
...
@@ -21,7 +21,9 @@ CXX ?= $(CROSS_COMPILE)g++
HOSTPKG_CONFIG
:=
pkg-config
CFLAGS
+=
-g
-O0
-rdynamic
-Wall
-Werror
-I
$(KHDR_INCLUDES)
-I
$(OUTPUT)
CFLAGS
+=
-g
-O0
-rdynamic
-Wall
-Werror
-I
$(OUTPUT)
CFLAGS
+=
-I
$(OUTPUT)
/tools/include
LDLIBS
+=
-lelf
-lz
-lrt
-lpthread
# Silence some warnings when compiled with clang
...
...
@@ -65,7 +67,6 @@ BPFTOOLDIR := $(TOOLSDIR)/bpf/bpftool
SCRATCH_DIR
:=
$(OUTPUT)
/tools
BUILD_DIR
:=
$(SCRATCH_DIR)
/build
INCLUDE_DIR
:=
$(SCRATCH_DIR)
/include
KHDR_INCLUDES
:=
$(SCRATCH_DIR)
/uapi/include
BPFOBJ
:=
$(BUILD_DIR)
/libbpf/libbpf.a
ifneq
($(CROSS_COMPILE),)
HOST_BUILD_DIR
:=
$(BUILD_DIR)
/host
...
...
@@ -151,9 +152,6 @@ else
$(Q)
cp
"
$(VMLINUX_H)
"
$@
endif
$(KHDR_INCLUDES)/linux/hid.h
:
$(top_srcdir)/include/uapi/linux/hid.h
$(MAKE)
-C
$(top_srcdir)
INSTALL_HDR_PATH
=
$(SCRATCH_DIR)
/uapi headers_install
$(RESOLVE_BTFIDS)
:
$(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids
\
$(TOOLSDIR)/bpf/resolve_btfids/main.c
\
$(TOOLSDIR)/lib/rbtree.c
\
...
...
@@ -231,7 +229,7 @@ $(BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(OUTPUT)
$(Q)$(BPFTOOL)
gen object
$
(
<:.o
=
.linked1.o
)
$<
$(Q)$(BPFTOOL)
gen skeleton
$
(
<:.o
=
.linked1.o
)
name
$(
notdir
$
(
<:.bpf.o
=
))
>
$@
$(OUTPUT)/%.o
:
%.c $(BPF_SKELS)
$(KHDR_INCLUDES)/linux/hid.h
$(OUTPUT)/%.o
:
%.c $(BPF_SKELS)
$(
call
msg,CC,,
$@
)
$(Q)$(CC)
$(CFLAGS)
-c
$(
filter
%.c,
$^
)
$(LDLIBS)
-o
$@
...
...
tools/testing/selftests/hid/progs/hid.c
View file @
e12f065d
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2022 Red hat */
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include "hid_bpf_helpers.h"
char
_license
[]
SEC
(
"license"
)
=
"GPL"
;
...
...
tools/testing/selftests/hid/progs/hid_bpf_helpers.h
View file @
e12f065d
...
...
@@ -5,6 +5,83 @@
#ifndef __HID_BPF_HELPERS_H
#define __HID_BPF_HELPERS_H
/* "undefine" structs and enums in vmlinux.h, because we "override" them below */
#define hid_bpf_ctx hid_bpf_ctx___not_used
#define hid_report_type hid_report_type___not_used
#define hid_class_request hid_class_request___not_used
#define hid_bpf_attach_flags hid_bpf_attach_flags___not_used
#define HID_INPUT_REPORT HID_INPUT_REPORT___not_used
#define HID_OUTPUT_REPORT HID_OUTPUT_REPORT___not_used
#define HID_FEATURE_REPORT HID_FEATURE_REPORT___not_used
#define HID_REPORT_TYPES HID_REPORT_TYPES___not_used
#define HID_REQ_GET_REPORT HID_REQ_GET_REPORT___not_used
#define HID_REQ_GET_IDLE HID_REQ_GET_IDLE___not_used
#define HID_REQ_GET_PROTOCOL HID_REQ_GET_PROTOCOL___not_used
#define HID_REQ_SET_REPORT HID_REQ_SET_REPORT___not_used
#define HID_REQ_SET_IDLE HID_REQ_SET_IDLE___not_used
#define HID_REQ_SET_PROTOCOL HID_REQ_SET_PROTOCOL___not_used
#define HID_BPF_FLAG_NONE HID_BPF_FLAG_NONE___not_used
#define HID_BPF_FLAG_INSERT_HEAD HID_BPF_FLAG_INSERT_HEAD___not_used
#define HID_BPF_FLAG_MAX HID_BPF_FLAG_MAX___not_used
#include "vmlinux.h"
#undef hid_bpf_ctx
#undef hid_report_type
#undef hid_class_request
#undef hid_bpf_attach_flags
#undef HID_INPUT_REPORT
#undef HID_OUTPUT_REPORT
#undef HID_FEATURE_REPORT
#undef HID_REPORT_TYPES
#undef HID_REQ_GET_REPORT
#undef HID_REQ_GET_IDLE
#undef HID_REQ_GET_PROTOCOL
#undef HID_REQ_SET_REPORT
#undef HID_REQ_SET_IDLE
#undef HID_REQ_SET_PROTOCOL
#undef HID_BPF_FLAG_NONE
#undef HID_BPF_FLAG_INSERT_HEAD
#undef HID_BPF_FLAG_MAX
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <linux/const.h>
enum
hid_report_type
{
HID_INPUT_REPORT
=
0
,
HID_OUTPUT_REPORT
=
1
,
HID_FEATURE_REPORT
=
2
,
HID_REPORT_TYPES
,
};
struct
hid_bpf_ctx
{
__u32
index
;
const
struct
hid_device
*
hid
;
__u32
allocated_size
;
enum
hid_report_type
report_type
;
union
{
__s32
retval
;
__s32
size
;
};
}
__attribute__
((
preserve_access_index
));
enum
hid_class_request
{
HID_REQ_GET_REPORT
=
0x01
,
HID_REQ_GET_IDLE
=
0x02
,
HID_REQ_GET_PROTOCOL
=
0x03
,
HID_REQ_SET_REPORT
=
0x09
,
HID_REQ_SET_IDLE
=
0x0A
,
HID_REQ_SET_PROTOCOL
=
0x0B
,
};
enum
hid_bpf_attach_flags
{
HID_BPF_FLAG_NONE
=
0
,
HID_BPF_FLAG_INSERT_HEAD
=
_BITUL
(
0
),
HID_BPF_FLAG_MAX
,
};
/* following are kfuncs exported by HID for HID-BPF */
extern
__u8
*
hid_bpf_get_data
(
struct
hid_bpf_ctx
*
ctx
,
unsigned
int
offset
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment