Lines Matching +full:in +full:- +full:line

2 # SPDX-License-Identifier: GPL-2.0-only
4 # Copyright (C) 2018-2019 Netronome Systems, Inc.
7 # In case user attempts to run with Python 2.
24 def __init__(self, line='<line not provided>', reader=None): argument
27 'Error at file offset %d, parsing line: %s' %
28 (reader.tell(), line))
30 BaseException.__init__(self, 'Error parsing line: %s' % line)
74 for a in args:
92 An object used to parse a file in order to extract the documentation of a
94 stored as Helper object, in the self.helpers() array.
95 @filename: name of file to parse, usually include/uapi/linux/bpf.h in the
100 self.line = ''
125 capture = p.match(self.line)
129 end = end_re.match(self.line)
132 self.line = self.reader.readline()
137 # - "void"
138 # - "type name"
139 # - "type *name"
140 # - Same as above, with "const" and/or "struct" in front of type
141 # - "..." (undefined number of arguments, for bpf_trace_printk())
144 capture = p.match(self.line)
147 self.line = self.reader.readline()
152 capture = p.match(self.line)
160 self.line = self.reader.readline()
161 if self.line == ' *\n':
165 capture = p.match(self.line)
178 capture = p.match(self.line)
186 self.line = self.reader.readline()
187 if self.line == ' *\n':
191 capture = p.match(self.line)
204 capture = p.match(self.line)
207 # Expect a single line with mnemonics for attributes separated by spaces
208 self.line = self.reader.readline()
210 capture = p.match(self.line)
214 for attr in attrs:
215 if attr not in ATTRS:
217 self.line = self.reader.readline()
218 if self.line != ' *\n':
219 raise Exception("Expecting empty line after 'Attributes' section for " + proto)
220 # Prepare a line for next self.parse_* to consume
221 self.line = self.reader.readline()
227 if offset == -1:
231 for _ in range(discard_lines):
233 self.line = self.reader.readline()
254 # not documented hence should be skipped in check to
259 capture = assign_p.match(self.line)
261 # Skip line if an enum entry is assigned to another entry
262 self.line = self.reader.readline()
264 capture = bpf_p.match(self.line)
266 bpf_cmd_str += self.line
269 self.line = self.reader.readline()
286 # Parse FN(...) in #define ___BPF_FUNC_MAPPER to compare later with the
287 # number of unique function names present in description and use the
289 # Note: seek_to(..) discards the first line below the target search text,
290 # resulting in FN(unspec, 0, ##ctx) being skipped and not added to
299 capture = p.match(self.line)
301 fn_defines_str += self.line
308 self.line = self.reader.readline()
317 for helper in self.helpers:
326 if name in seen_helpers:
334 …per %s (ID %d) comment order (#%d) must be aligned with its position (#%d) in enum bpf_func_id" % …
335 if enum_val in seen_enum_vals:
358 Helper objects, and implement a way to print them in the desired fashion.
376 for elem in self.elements:
390 The number of unique %s in description (%d) doesn\'t match the number of unique %s defined in %s (%…
404 elements in the desired fashion.
413 .. See git log include/uapi/linux/bpf.h in kernel tree for details.
415 .. SPDX-License-Identifier: Linux-man-pages-copyleft
418 .. located in file include/uapi/linux/bpf.h of the Linux kernel sources
419 .. (helpers description), and from scripts/bpf_doc.py in the same
428 # a section must be followed by a blank line.
429 for line in re.sub('\n$', '', elem.desc, count=1).split('\n'):
430 print('{}{}'.format('\t\t' if line else '', line))
434 for line in elem.ret.rstrip().split('\n'):
435 print('{}{}'.format('\t\t' if line else '', line))
446 version = subprocess.run(['make', '-s', '--no-print-directory', 'kernelversion'],
455 cmd = ['git', 'log', '-1', '--pretty=format:%cs', '--no-patch',
456 '-L',
478 BPF-HELPERS
480 -------------------------------------------------------------------------------
482 -------------------------------------------------------------------------------
491 The extended Berkeley Packet Filter (eBPF) subsystem consists in programs
492 written in a pseudo-assembly language, then attached to one of the several
493 kernel hooks and run in reaction of specific events. This framework differs
494 from the older, "classic" BPF (or "cBPF") in several aspects, one of them being
496 These functions are restricted to a white-list of helpers defined in the
500 the context in which they work. For instance, they can be used to print
503 program types, and that they do not run in the same context, each program type
509 without requiring any foreign-function interface. As a result, calling helpers
513 developers. They are sorted by chronological order (the oldest helpers in the
532 Example usage for most of the eBPF helpers listed in this manual page are
543 string is identical to the one in use for kernel modules (Dual licenses, such
547 In order to use such helpers, the eBPF program must be loaded with the correct
549 generally translates into the C source code of the program containing a line
560 But as of this writing, the BPF sub-system is under heavy development. New eBPF
562 are occasionally made available for additional program types. So in spite of
563 the efforts of the community, this page might not be up-to-date. If you want to
564 check by yourself what helper functions exist in your kernel, or what types of
566 may be interested in:
571 * *net/core/filter.c* contains the definition of most network-related helper
573 * *kernel/trace/bpf_trace.c* is the equivalent for most tracing program-related
577 * *kernel/bpf/* directory contains other files in which additional helpers are
582 **bpftool-feature**\\ (8) for details). Add the **unprivileged** keyword to
586 in the files where helper functions are defined. Look for the **struct
591 requirement for GPL license is also in those **struct bpf_func_proto**.
593 Compatibility between helper functions and map types can be found in the
594 **check_map_func_compatibility**\\ () function in file *kernel/bpf/verifier.c*.
597 pointers for network processing are listed in function
598 **bpf_helper_changes_pkt_data**\\ () in file *net/core/filter.c*.
610 **tc-bpf**\\ (8)'''
616 file less readable, but gives nice results in the manual page.
626 for a in proto['args']:
661 -------------------------------------------------------------------------------
663 -------------------------------------------------------------------------------
812 /* This is auto-generated file. See bpf_doc.py for details. */
817 for fwd in self.type_fwds:
822 for helper in self.elements:
823 for attr in helper.attrs:
825 for attr in sorted(used_attrs):
841 if t in self.known_types:
843 if t in self.mapped_types:
854 if proto['name'] in self.seen_helpers:
863 # a section must be followed by a blank line.
864 for line in re.sub('\n$', '', helper.desc, count=1).split('\n'):
865 print(' *{}{}'.format(' \t' if line else '', line))
870 for line in helper.ret.rstrip().split('\n'):
871 print(' *{}{}'.format(' \t' if line else '', line))
880 for i, a in enumerate(proto['args']):
883 if proto['name'] in self.overloaded_helpers and i == 0:
903 # otherwise the --filename argument will be required from the command line.
915 The RST-formatted output produced can be turned into a manual page with the
918 argParser.add_argument('--header', action='store_true',
921 argParser.add_argument('--filename', help='path to include/uapi/linux/bpf.h',
924 argParser.add_argument('--filename', help='path to include/uapi/linux/bpf.h')