diff -Nru dwarves-dfsg-1.10/btfdiff dwarves-dfsg-1.21/btfdiff --- dwarves-dfsg-1.10/btfdiff 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/btfdiff 2019-05-01 18:23:10.000000000 +0000 @@ -0,0 +1,33 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only +# Copyright © 2019 Red Hat Inc, Arnaldo Carvalho de Melo +# Use pahole to produce output from BTF and from DWARF, then do a diff +# Use --flat_arrays with DWARF as BTF, like CTF, flattens arrays. +# Use --show_private_classes as BTF shows all structs, while pahole knows +# if some struct is defined only inside another struct/class or in a function, +# this information is not available when loading from BTF. + +if [ $# -eq 0 ] ; then + echo "Usage: btfdiff " + exit 1 +fi + +file=$1 +btf_output=$(mktemp /tmp/btfdiff.btf.XXXXXX) +dwarf_output=$(mktemp /tmp/btfdiff.dwarf.XXXXXX) +pahole_bin=${PAHOLE-"pahole"} + +${pahole_bin} -F dwarf \ + --flat_arrays \ + --suppress_aligned_attribute \ + --suppress_force_paddings \ + --suppress_packed \ + --show_private_classes $file > $dwarf_output +${pahole_bin} -F btf \ + --suppress_packed \ + $file > $btf_output + +diff -up $dwarf_output $btf_output + +rm -f $btf_output $dwarf_output +exit 0 diff -Nru dwarves-dfsg-1.10/btf_encoder.c dwarves-dfsg-1.21/btf_encoder.c --- dwarves-dfsg-1.10/btf_encoder.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/btf_encoder.c 2021-03-07 13:51:32.000000000 +0000 @@ -0,0 +1,911 @@ +/* + SPDX-License-Identifier: GPL-2.0-only + + Copyright (C) 2019 Facebook + + Derived from ctf_encoder.c, which is: + + Copyright (C) Arnaldo Carvalho de Melo + Copyright (C) Red Hat Inc + */ + +#include "dwarves.h" +#include "libbtf.h" +#include "lib/bpf/include/uapi/linux/btf.h" +#include "lib/bpf/src/libbpf.h" +#include "hash.h" +#include "elf_symtab.h" +#include "btf_encoder.h" + +#include /* for isalpha() and isalnum() */ +#include /* for qsort() and bsearch() */ +#include + +/* + * This corresponds to the same macro defined in + * include/linux/kallsyms.h + */ +#define KSYM_NAME_LEN 128 + +struct funcs_layout { + unsigned long mcount_start; + unsigned long mcount_stop; + unsigned long mcount_sec_idx; +}; + +struct elf_function { + const char *name; + unsigned long addr; + unsigned long size; + unsigned long sh_addr; + bool generated; +}; + +static struct elf_function *functions; +static int functions_alloc; +static int functions_cnt; + +static int functions_cmp(const void *_a, const void *_b) +{ + const struct elf_function *a = _a; + const struct elf_function *b = _b; + + return strcmp(a->name, b->name); +} + +static void delete_functions(void) +{ + free(functions); + functions_alloc = functions_cnt = 0; + functions = NULL; +} + +#ifndef max +#define max(x, y) ((x) < (y) ? (y) : (x)) +#endif + +static int collect_function(struct btf_elf *btfe, GElf_Sym *sym, + size_t sym_sec_idx) +{ + struct elf_function *new; + static GElf_Shdr sh; + static size_t last_idx; + const char *name; + + if (elf_sym__type(sym) != STT_FUNC) + return 0; + name = elf_sym__name(sym, btfe->symtab); + if (!name) + return 0; + + if (functions_cnt == functions_alloc) { + functions_alloc = max(1000, functions_alloc * 3 / 2); + new = realloc(functions, functions_alloc * sizeof(*functions)); + if (!new) { + /* + * The cleanup - delete_functions is called + * in cu__encode_btf error path. + */ + return -1; + } + functions = new; + } + + if (sym_sec_idx != last_idx) { + if (!elf_section_by_idx(btfe->elf, &sh, sym_sec_idx)) + return 0; + last_idx = sym_sec_idx; + } + + functions[functions_cnt].name = name; + functions[functions_cnt].addr = elf_sym__value(sym); + functions[functions_cnt].size = elf_sym__size(sym); + functions[functions_cnt].sh_addr = sh.sh_addr; + functions[functions_cnt].generated = false; + functions_cnt++; + return 0; +} + +static int addrs_cmp(const void *_a, const void *_b) +{ + const __u64 *a = _a; + const __u64 *b = _b; + + if (*a == *b) + return 0; + return *a < *b ? -1 : 1; +} + +static int get_vmlinux_addrs(struct btf_elf *btfe, struct funcs_layout *fl, + __u64 **paddrs, __u64 *pcount) +{ + __u64 *addrs, count, offset; + unsigned int addr_size, i; + Elf_Data *data; + GElf_Shdr shdr; + Elf_Scn *sec; + + /* Initialize for the sake of all error paths below. */ + *paddrs = NULL; + *pcount = 0; + + if (!fl->mcount_start || !fl->mcount_stop) + return 0; + + /* + * Find mcount addressed marked by __start_mcount_loc + * and __stop_mcount_loc symbols and load them into + * sorted array. + */ + sec = elf_getscn(btfe->elf, fl->mcount_sec_idx); + if (!sec || !gelf_getshdr(sec, &shdr)) { + fprintf(stderr, "Failed to get section(%lu) header.\n", + fl->mcount_sec_idx); + return -1; + } + + /* Get address size from processed file's ELF class. */ + addr_size = gelf_getclass(btfe->elf) == ELFCLASS32 ? 4 : 8; + + offset = fl->mcount_start - shdr.sh_addr; + count = (fl->mcount_stop - fl->mcount_start) / addr_size; + + data = elf_getdata(sec, 0); + if (!data) { + fprintf(stderr, "Failed to get section(%lu) data.\n", + fl->mcount_sec_idx); + return -1; + } + + addrs = malloc(count * sizeof(addrs[0])); + if (!addrs) { + fprintf(stderr, "Failed to allocate memory for ftrace addresses.\n"); + return -1; + } + + if (addr_size == sizeof(__u64)) { + memcpy(addrs, data->d_buf + offset, count * addr_size); + } else { + for (i = 0; i < count; i++) + addrs[i] = (__u64) *((__u32 *) (data->d_buf + offset + i * addr_size)); + } + + *paddrs = addrs; + *pcount = count; + return 0; +} + +static int +get_kmod_addrs(struct btf_elf *btfe, __u64 **paddrs, __u64 *pcount) +{ + __u64 *addrs, count; + unsigned int addr_size, i; + GElf_Shdr shdr_mcount; + Elf_Data *data; + Elf_Scn *sec; + + /* Initialize for the sake of all error paths below. */ + *paddrs = NULL; + *pcount = 0; + + /* get __mcount_loc */ + sec = elf_section_by_name(btfe->elf, &btfe->ehdr, &shdr_mcount, + "__mcount_loc", NULL); + if (!sec) { + if (btf_elf__verbose) { + printf("%s: '%s' doesn't have __mcount_loc section\n", __func__, + btfe->filename); + } + return 0; + } + + data = elf_getdata(sec, NULL); + if (!data) { + fprintf(stderr, "Failed to data for __mcount_loc section.\n"); + return -1; + } + + /* Get address size from processed file's ELF class. */ + addr_size = gelf_getclass(btfe->elf) == ELFCLASS32 ? 4 : 8; + + count = data->d_size / addr_size; + + addrs = malloc(count * sizeof(addrs[0])); + if (!addrs) { + fprintf(stderr, "Failed to allocate memory for ftrace addresses.\n"); + return -1; + } + + if (addr_size == sizeof(__u64)) { + memcpy(addrs, data->d_buf, count * addr_size); + } else { + for (i = 0; i < count; i++) + addrs[i] = (__u64) *((__u32 *) (data->d_buf + i * addr_size)); + } + + /* + * We get Elf object from dwfl_module_getelf function, + * which performs all possible relocations, including + * __mcount_loc section. + * + * So addrs array now contains relocated values, which + * we need take into account when we compare them to + * functions values, see comment in setup_functions + * function. + */ + *paddrs = addrs; + *pcount = count; + return 0; +} + +static int is_ftrace_func(struct elf_function *func, __u64 *addrs, __u64 count) +{ + __u64 start = func->addr; + __u64 addr, end = func->addr + func->size; + + /* + * The invariant here is addr[r] that is the smallest address + * that is >= than function start addr. Except the corner case + * where there is no such r, but for that we have a final check + * in the return. + */ + size_t l = 0, r = count - 1, m; + + /* make sure we don't use invalid r */ + if (count == 0) + return false; + + while (l < r) { + m = l + (r - l) / 2; + addr = addrs[m]; + + if (addr >= start) { + /* we satisfy invariant, so tighten r */ + r = m; + } else { + /* m is not good enough as l, maybe m + 1 will be */ + l = m + 1; + } + } + + return start <= addrs[r] && addrs[r] < end; +} + +static int setup_functions(struct btf_elf *btfe, struct funcs_layout *fl) +{ + __u64 *addrs, count, i; + int functions_valid = 0; + bool kmod = false; + + /* + * Check if we are processing vmlinux image and + * get mcount data if it's detected. + */ + if (get_vmlinux_addrs(btfe, fl, &addrs, &count)) + return -1; + + /* + * Check if we are processing kernel module and + * get mcount data if it's detected. + */ + if (!addrs) { + if (get_kmod_addrs(btfe, &addrs, &count)) + return -1; + kmod = true; + } + + if (!addrs) { + if (btf_elf__verbose) + printf("ftrace symbols not detected, falling back to DWARF data\n"); + delete_functions(); + return 0; + } + + qsort(addrs, count, sizeof(addrs[0]), addrs_cmp); + qsort(functions, functions_cnt, sizeof(functions[0]), functions_cmp); + + /* + * Let's got through all collected functions and filter + * out those that are not in ftrace. + */ + for (i = 0; i < functions_cnt; i++) { + struct elf_function *func = &functions[i]; + /* + * For vmlinux image both addrs[x] and functions[x]::addr + * values are final address and are comparable. + * + * For kernel module addrs[x] is final address, but + * functions[x]::addr is relative address within section + * and needs to be relocated by adding sh_addr. + */ + if (kmod) + func->addr += func->sh_addr; + + /* Make sure function is within ftrace addresses. */ + if (is_ftrace_func(func, addrs, count)) { + /* + * We iterate over sorted array, so we can easily skip + * not valid item and move following valid field into + * its place, and still keep the 'new' array sorted. + */ + if (i != functions_valid) + functions[functions_valid] = functions[i]; + functions_valid++; + } + } + + functions_cnt = functions_valid; + free(addrs); + + if (btf_elf__verbose) + printf("Found %d functions!\n", functions_cnt); + return 0; +} + +static struct elf_function *find_function(const struct btf_elf *btfe, + const char *name) +{ + struct elf_function key = { .name = name }; + + return bsearch(&key, functions, functions_cnt, sizeof(functions[0]), + functions_cmp); +} + +static bool btf_name_char_ok(char c, bool first) +{ + if (c == '_' || c == '.') + return true; + + return first ? isalpha(c) : isalnum(c); +} + +/* Check whether the given name is valid in vmlinux btf. */ +static bool btf_name_valid(const char *p) +{ + const char *limit; + + if (!btf_name_char_ok(*p, true)) + return false; + + /* set a limit on identifier length */ + limit = p + KSYM_NAME_LEN; + p++; + while (*p && p < limit) { + if (!btf_name_char_ok(*p, false)) + return false; + p++; + } + + return !*p; +} + +static void dump_invalid_symbol(const char *msg, const char *sym, + int verbose, bool force) +{ + if (force) { + if (verbose) + fprintf(stderr, "PAHOLE: Warning: %s, ignored (sym: '%s').\n", + msg, sym); + return; + } + + fprintf(stderr, "PAHOLE: Error: %s (sym: '%s').\n", msg, sym); + fprintf(stderr, "PAHOLE: Error: Use '--btf_encode_force' to ignore such symbols and force emit the btf.\n"); +} + +extern struct debug_fmt_ops *dwarves__active_loader; + +static int tag__check_id_drift(const struct tag *tag, + uint32_t core_id, uint32_t btf_type_id, + uint32_t type_id_off) +{ + if (btf_type_id != (core_id + type_id_off)) { + fprintf(stderr, + "%s: %s id drift, core_id: %u, btf_type_id: %u, type_id_off: %u\n", + __func__, dwarf_tag_name(tag->tag), + core_id, btf_type_id, type_id_off); + return -1; + } + + return 0; +} + +static int32_t structure_type__encode(struct btf_elf *btfe, struct cu *cu, struct tag *tag, uint32_t type_id_off) +{ + struct type *type = tag__type(tag); + struct class_member *pos; + const char *name; + int32_t type_id; + uint8_t kind; + + kind = (tag->tag == DW_TAG_union_type) ? + BTF_KIND_UNION : BTF_KIND_STRUCT; + + name = dwarves__active_loader->strings__ptr(cu, type->namespace.name); + type_id = btf_elf__add_struct(btfe, kind, name, type->size); + if (type_id < 0) + return type_id; + + type__for_each_data_member(type, pos) { + /* + * dwarf_loader uses DWARF's recommended bit offset addressing + * scheme, which conforms to BTF requirement, so no conversion + * is required. + */ + name = dwarves__active_loader->strings__ptr(cu, pos->name); + if (btf_elf__add_member(btfe, name, type_id_off + pos->tag.type, pos->bitfield_size, pos->bit_offset)) + return -1; + } + + return type_id; +} + +static uint32_t array_type__nelems(struct tag *tag) +{ + int i; + uint32_t nelem = 1; + struct array_type *array = tag__array_type(tag); + + for (i = array->dimensions - 1; i >= 0; --i) + nelem *= array->nr_entries[i]; + + return nelem; +} + +static int32_t enumeration_type__encode(struct btf_elf *btfe, struct cu *cu, struct tag *tag) +{ + struct type *etype = tag__type(tag); + struct enumerator *pos; + const char *name; + int32_t type_id; + + name = dwarves__active_loader->strings__ptr(cu, etype->namespace.name); + type_id = btf_elf__add_enum(btfe, name, etype->size); + if (type_id < 0) + return type_id; + + type__for_each_enumerator(etype, pos) { + name = dwarves__active_loader->strings__ptr(cu, pos->name); + if (btf_elf__add_enum_val(btfe, name, pos->value)) + return -1; + } + + return type_id; +} + +static bool need_index_type; + +static int tag__encode_btf(struct cu *cu, struct tag *tag, uint32_t core_id, struct btf_elf *btfe, + uint32_t array_index_id, uint32_t type_id_off) +{ + /* single out type 0 as it represents special type "void" */ + uint32_t ref_type_id = tag->type == 0 ? 0 : type_id_off + tag->type; + const char *name; + + switch (tag->tag) { + case DW_TAG_base_type: + name = dwarves__active_loader->strings__ptr(cu, tag__base_type(tag)->name); + return btf_elf__add_base_type(btfe, tag__base_type(tag), name); + case DW_TAG_const_type: + return btf_elf__add_ref_type(btfe, BTF_KIND_CONST, ref_type_id, NULL, false); + case DW_TAG_pointer_type: + return btf_elf__add_ref_type(btfe, BTF_KIND_PTR, ref_type_id, NULL, false); + case DW_TAG_restrict_type: + return btf_elf__add_ref_type(btfe, BTF_KIND_RESTRICT, ref_type_id, NULL, false); + case DW_TAG_volatile_type: + return btf_elf__add_ref_type(btfe, BTF_KIND_VOLATILE, ref_type_id, NULL, false); + case DW_TAG_typedef: + name = dwarves__active_loader->strings__ptr(cu, tag__namespace(tag)->name); + return btf_elf__add_ref_type(btfe, BTF_KIND_TYPEDEF, ref_type_id, name, false); + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_class_type: + name = dwarves__active_loader->strings__ptr(cu, tag__namespace(tag)->name); + if (tag__type(tag)->declaration) + return btf_elf__add_ref_type(btfe, BTF_KIND_FWD, 0, name, tag->tag == DW_TAG_union_type); + else + return structure_type__encode(btfe, cu, tag, type_id_off); + case DW_TAG_array_type: + /* TODO: Encode one dimension at a time. */ + need_index_type = true; + return btf_elf__add_array(btfe, ref_type_id, array_index_id, array_type__nelems(tag)); + case DW_TAG_enumeration_type: + return enumeration_type__encode(btfe, cu, tag); + case DW_TAG_subroutine_type: + return btf_elf__add_func_proto(btfe, cu, tag__ftype(tag), type_id_off); + default: + fprintf(stderr, "Unsupported DW_TAG_%s(0x%x)\n", + dwarf_tag_name(tag->tag), tag->tag); + return -1; + } +} + +static struct btf_elf *btfe; +static uint32_t array_index_id; +static bool has_index_type; + +int btf_encoder__encode() +{ + int err; + + if (gobuffer__size(&btfe->percpu_secinfo) != 0) + btf_elf__add_datasec_type(btfe, PERCPU_SECTION, &btfe->percpu_secinfo); + + err = btf_elf__encode(btfe, 0); + delete_functions(); + btf_elf__delete(btfe); + btfe = NULL; + + return err; +} + +#define MAX_PERCPU_VAR_CNT 4096 + +struct var_info { + uint64_t addr; + uint32_t sz; + const char *name; +}; + +static struct var_info percpu_vars[MAX_PERCPU_VAR_CNT]; +static int percpu_var_cnt; + +static int percpu_var_cmp(const void *_a, const void *_b) +{ + const struct var_info *a = _a; + const struct var_info *b = _b; + + if (a->addr == b->addr) + return 0; + return a->addr < b->addr ? -1 : 1; +} + +static bool percpu_var_exists(uint64_t addr, uint32_t *sz, const char **name) +{ + const struct var_info *p; + struct var_info key = { .addr = addr }; + + p = bsearch(&key, percpu_vars, percpu_var_cnt, + sizeof(percpu_vars[0]), percpu_var_cmp); + + if (!p) + return false; + + *sz = p->sz; + *name = p->name; + return true; +} + +static int collect_percpu_var(struct btf_elf *btfe, GElf_Sym *sym, + size_t sym_sec_idx) +{ + const char *sym_name; + uint64_t addr; + uint32_t size; + + /* compare a symbol's shndx to determine if it's a percpu variable */ + if (sym_sec_idx != btfe->percpu_shndx) + return 0; + if (elf_sym__type(sym) != STT_OBJECT) + return 0; + + addr = elf_sym__value(sym); + + size = elf_sym__size(sym); + if (!size) + return 0; /* ignore zero-sized symbols */ + + sym_name = elf_sym__name(sym, btfe->symtab); + if (!btf_name_valid(sym_name)) { + dump_invalid_symbol("Found symbol of invalid name when encoding btf", + sym_name, btf_elf__verbose, btf_elf__force); + if (btf_elf__force) + return 0; + return -1; + } + + if (btf_elf__verbose) + printf("Found per-CPU symbol '%s' at address 0x%" PRIx64 "\n", sym_name, addr); + + if (percpu_var_cnt == MAX_PERCPU_VAR_CNT) { + fprintf(stderr, "Reached the limit of per-CPU variables: %d\n", + MAX_PERCPU_VAR_CNT); + return -1; + } + percpu_vars[percpu_var_cnt].addr = addr; + percpu_vars[percpu_var_cnt].sz = size; + percpu_vars[percpu_var_cnt].name = sym_name; + percpu_var_cnt++; + + return 0; +} + +static void collect_symbol(GElf_Sym *sym, struct funcs_layout *fl, + size_t sym_sec_idx) +{ + if (!fl->mcount_start && + !strcmp("__start_mcount_loc", elf_sym__name(sym, btfe->symtab))) { + fl->mcount_start = sym->st_value; + fl->mcount_sec_idx = sym_sec_idx; + } + + if (!fl->mcount_stop && + !strcmp("__stop_mcount_loc", elf_sym__name(sym, btfe->symtab))) + fl->mcount_stop = sym->st_value; +} + +static int collect_symbols(struct btf_elf *btfe, bool collect_percpu_vars) +{ + struct funcs_layout fl = { }; + Elf32_Word sym_sec_idx; + uint32_t core_id; + GElf_Sym sym; + + /* cache variables' addresses, preparing for searching in symtab. */ + percpu_var_cnt = 0; + + /* search within symtab for percpu variables */ + elf_symtab__for_each_symbol_index(btfe->symtab, core_id, sym, sym_sec_idx) { + if (collect_percpu_vars && collect_percpu_var(btfe, &sym, sym_sec_idx)) + return -1; + if (collect_function(btfe, &sym, sym_sec_idx)) + return -1; + collect_symbol(&sym, &fl, sym_sec_idx); + } + + if (collect_percpu_vars) { + if (percpu_var_cnt) + qsort(percpu_vars, percpu_var_cnt, sizeof(percpu_vars[0]), percpu_var_cmp); + + if (btf_elf__verbose) + printf("Found %d per-CPU variables!\n", percpu_var_cnt); + } + + if (functions_cnt && setup_functions(btfe, &fl)) { + fprintf(stderr, "Failed to filter DWARF functions\n"); + return -1; + } + + return 0; +} + +static bool has_arg_names(struct cu *cu, struct ftype *ftype) +{ + struct parameter *param; + const char *name; + + ftype__for_each_parameter(ftype, param) { + name = dwarves__active_loader->strings__ptr(cu, param->name); + if (name == NULL) + return false; + } + return true; +} + +int cu__encode_btf(struct cu *cu, int verbose, bool force, + bool skip_encoding_vars) +{ + uint32_t type_id_off; + uint32_t core_id; + struct variable *var; + struct function *fn; + struct tag *pos; + int err = 0; + + btf_elf__verbose = verbose; + btf_elf__force = force; + + if (btfe && strcmp(btfe->filename, cu->filename)) { + err = btf_encoder__encode(); + if (err) + goto out; + + /* Finished one file, add one empty line */ + if (verbose) + printf("\n"); + } + + if (!btfe) { + btfe = btf_elf__new(cu->filename, cu->elf, base_btf); + if (!btfe) + return -1; + + err = collect_symbols(btfe, !skip_encoding_vars); + if (err) + goto out; + + has_index_type = false; + need_index_type = false; + array_index_id = 0; + + if (verbose) + printf("File %s:\n", btfe->filename); + } + + type_id_off = btf__get_nr_types(btfe->btf); + + if (!has_index_type) { + /* cu__find_base_type_by_name() takes "type_id_t *id" */ + type_id_t id; + if (cu__find_base_type_by_name(cu, "int", &id)) { + has_index_type = true; + array_index_id = type_id_off + id; + } else { + has_index_type = false; + array_index_id = type_id_off + cu->types_table.nr_entries; + } + } + + cu__for_each_type(cu, core_id, pos) { + int32_t btf_type_id = tag__encode_btf(cu, pos, core_id, btfe, array_index_id, type_id_off); + + if (btf_type_id < 0 || + tag__check_id_drift(pos, core_id, btf_type_id, type_id_off)) { + err = -1; + goto out; + } + } + + if (need_index_type && !has_index_type) { + struct base_type bt = {}; + + bt.name = 0; + bt.bit_size = 32; + btf_elf__add_base_type(btfe, &bt, "__ARRAY_SIZE_TYPE__"); + has_index_type = true; + } + + cu__for_each_function(cu, core_id, fn) { + int btf_fnproto_id, btf_fn_id; + const char *name; + + /* + * Skip functions that: + * - are marked as declarations + * - do not have full argument names + * - are not in ftrace list (if it's available) + * - are not external (in case ftrace filter is not available) + */ + if (fn->declaration) + continue; + if (!has_arg_names(cu, &fn->proto)) + continue; + if (functions_cnt) { + struct elf_function *func; + const char *name; + + name = function__name(fn, cu); + if (!name) + continue; + + func = find_function(btfe, name); + if (!func || func->generated) + continue; + func->generated = true; + } else { + if (!fn->external) + continue; + } + + btf_fnproto_id = btf_elf__add_func_proto(btfe, cu, &fn->proto, type_id_off); + name = dwarves__active_loader->strings__ptr(cu, fn->name); + btf_fn_id = btf_elf__add_ref_type(btfe, BTF_KIND_FUNC, btf_fnproto_id, name, false); + if (btf_fnproto_id < 0 || btf_fn_id < 0) { + err = -1; + printf("error: failed to encode function '%s'\n", function__name(fn, cu)); + goto out; + } + } + + if (skip_encoding_vars) + goto out; + + if (btfe->percpu_shndx == 0 || !btfe->symtab) + goto out; + + if (verbose) + printf("search cu '%s' for percpu global variables.\n", cu->name); + + cu__for_each_variable(cu, core_id, pos) { + uint32_t size, type, linkage; + const char *name, *dwarf_name; + uint64_t addr; + int id; + + var = tag__variable(pos); + if (var->declaration && !var->spec) + continue; + /* percpu variables are allocated in global space */ + if (variable__scope(var) != VSCOPE_GLOBAL && !var->spec) + continue; + + /* addr has to be recorded before we follow spec */ + addr = var->ip.addr; + + /* DWARF takes into account .data..percpu section offset + * within its segment, which for vmlinux is 0, but for kernel + * modules is >0. ELF symbols, on the other hand, don't take + * into account these offsets (as they are relative to the + * section start), so to match DWARF and ELF symbols we need + * to negate the section base address here. + */ + if (addr < btfe->percpu_base_addr || addr >= btfe->percpu_base_addr + btfe->percpu_sec_sz) + continue; + addr -= btfe->percpu_base_addr; + + if (!percpu_var_exists(addr, &size, &name)) + continue; /* not a per-CPU variable */ + + /* A lot of "special" DWARF variables (e.g, __UNIQUE_ID___xxx) + * have addr == 0, which is the same as, say, valid + * fixed_percpu_data per-CPU variable. To distinguish between + * them, additionally compare DWARF and ELF symbol names. If + * DWARF doesn't provide proper name, pessimistically assume + * bad variable. + * + * Examples of such special variables are: + * + * 1. __ADDRESSABLE(sym), which are forcely emitted as symbols. + * 2. __UNIQUE_ID(prefix), which are introduced to generate unique ids. + * 3. __exitcall(fn), functions which are labeled as exit calls. + * + * This is relevant only for vmlinux image, as for kernel + * modules per-CPU data section has non-zero offset so all + * per-CPU symbols have non-zero values. + */ + if (var->ip.addr == 0) { + dwarf_name = variable__name(var, cu); + if (!dwarf_name || strcmp(dwarf_name, name)) + continue; + } + + if (var->spec) + var = var->spec; + + if (var->ip.tag.type == 0) { + fprintf(stderr, "error: found variable '%s' in CU '%s' that has void type\n", + name, cu->name); + if (force) + continue; + err = -1; + break; + } + + type = var->ip.tag.type + type_id_off; + linkage = var->external ? BTF_VAR_GLOBAL_ALLOCATED : BTF_VAR_STATIC; + + if (btf_elf__verbose) { + printf("Variable '%s' from CU '%s' at address 0x%" PRIx64 " encoded\n", + name, cu->name, addr); + } + + /* add a BTF_KIND_VAR in btfe->types */ + id = btf_elf__add_var_type(btfe, type, name, linkage); + if (id < 0) { + err = -1; + fprintf(stderr, "error: failed to encode variable '%s' at addr 0x%" PRIx64 "\n", + name, addr); + break; + } + + /* + * add a BTF_VAR_SECINFO in btfe->percpu_secinfo, which will be added into + * btfe->types later when we add BTF_VAR_DATASEC. + */ + id = btf_elf__add_var_secinfo(&btfe->percpu_secinfo, id, addr, size); + if (id < 0) { + err = -1; + fprintf(stderr, "error: failed to encode section info for variable '%s' at addr 0x%" PRIx64 "\n", + name, addr); + break; + } + } + +out: + if (err) { + delete_functions(); + btf_elf__delete(btfe); + btfe = NULL; + } + return err; +} diff -Nru dwarves-dfsg-1.10/btf_encoder.h dwarves-dfsg-1.21/btf_encoder.h --- dwarves-dfsg-1.10/btf_encoder.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/btf_encoder.h 2021-03-07 13:51:27.000000000 +0000 @@ -0,0 +1,19 @@ +#ifndef _BTF_ENCODER_H_ +#define _BTF_ENCODER_H_ 1 +/* + SPDX-License-Identifier: GPL-2.0-only + + Copyright (C) 2019 Facebook + + Derived from ctf_encoder.h, which is: + Copyright (C) Arnaldo Carvalho de Melo + */ + +struct cu; + +int btf_encoder__encode(); + +int cu__encode_btf(struct cu *cu, int verbose, bool force, + bool skip_encoding_vars); + +#endif /* _BTF_ENCODER_H_ */ diff -Nru dwarves-dfsg-1.10/btf_loader.c dwarves-dfsg-1.21/btf_loader.c --- dwarves-dfsg-1.10/btf_loader.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/btf_loader.c 2021-03-12 17:28:52.000000000 +0000 @@ -0,0 +1,596 @@ +/* + * btf_loader.c + * + * Copyright (C) 2018 Arnaldo Carvalho de Melo + * + * Based on ctf_loader.c that, in turn, was based on ctfdump.c: CTF dumper. + * + * Copyright (C) 2008 David S. Miller + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "libbtf.h" +#include "lib/bpf/include/uapi/linux/btf.h" +#include "dutil.h" +#include "dwarves.h" + +/* + * FIXME: We should just get the table from the BTF ELF section + * and use it directly + */ +extern struct strings *strings; + +static void *tag__alloc(const size_t size) +{ + struct tag *tag = zalloc(size); + + if (tag != NULL) + tag->top_level = 1; + + return tag; +} + +static int btf_elf__load_ftype(struct btf_elf *btfe, struct ftype *proto, uint32_t tag, + const struct btf_type *tp, uint32_t id) +{ + const struct btf_param *param = btf_params(tp); + int i, vlen = btf_vlen(tp); + + proto->tag.tag = tag; + proto->tag.type = tp->type; + INIT_LIST_HEAD(&proto->parms); + + for (i = 0; i < vlen; ++i, param++) { + if (param->type == 0) + proto->unspec_parms = 1; + else { + struct parameter *p = tag__alloc(sizeof(*p)); + + if (p == NULL) + goto out_free_parameters; + p->tag.tag = DW_TAG_formal_parameter; + p->tag.type = param->type; + p->name = param->name_off; + ftype__add_parameter(proto, p); + } + } + + cu__add_tag_with_id(btfe->priv, &proto->tag, id); + + return 0; +out_free_parameters: + ftype__delete(proto, btfe->priv); + return -ENOMEM; +} + +static int create_new_function(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + struct function *func = tag__alloc(sizeof(*func)); + + if (func == NULL) + return -ENOMEM; + + // for BTF this is not really the type of the return of the function, + // but the prototype, the return type is the one in type_id + func->btf = 1; + func->proto.tag.tag = DW_TAG_subprogram; + func->proto.tag.type = tp->type; + func->name = tp->name_off; + INIT_LIST_HEAD(&func->lexblock.tags); + cu__add_tag_with_id(btfe->priv, &func->proto.tag, id); + + return 0; +} + +static struct base_type *base_type__new(strings_t name, uint32_t attrs, + uint8_t float_type, size_t size) +{ + struct base_type *bt = tag__alloc(sizeof(*bt)); + + if (bt != NULL) { + bt->name = name; + bt->bit_size = size; + bt->is_signed = attrs & BTF_INT_SIGNED; + bt->is_bool = attrs & BTF_INT_BOOL; + bt->name_has_encoding = false; + bt->float_type = float_type; + } + return bt; +} + +static void type__init(struct type *type, uint32_t tag, + strings_t name, size_t size) +{ + __type__init(type); + INIT_LIST_HEAD(&type->namespace.tags); + type->size = size; + type->namespace.tag.tag = tag; + type->namespace.name = name; + type->namespace.sname = 0; +} + +static struct type *type__new(uint16_t tag, strings_t name, size_t size) +{ + struct type *type = tag__alloc(sizeof(*type)); + + if (type != NULL) + type__init(type, tag, name, size); + + return type; +} + +static struct class *class__new(strings_t name, size_t size, bool is_union) +{ + struct class *class = tag__alloc(sizeof(*class)); + uint32_t tag = is_union ? DW_TAG_union_type : DW_TAG_structure_type; + + if (class != NULL) { + type__init(&class->type, tag, name, size); + INIT_LIST_HEAD(&class->vtable); + } + + return class; +} + +static struct variable *variable__new(strings_t name, uint32_t linkage) +{ + struct variable *var = tag__alloc(sizeof(*var)); + + if (var != NULL) { + var->external = linkage == BTF_VAR_GLOBAL_ALLOCATED; + var->name = name; + var->ip.tag.tag = DW_TAG_variable; + } + + return var; +} + +static int create_new_int_type(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + uint32_t attrs = btf_int_encoding(tp); + strings_t name = tp->name_off; + struct base_type *base = base_type__new(name, attrs, 0, btf_int_bits(tp)); + + if (base == NULL) + return -ENOMEM; + + base->tag.tag = DW_TAG_base_type; + cu__add_tag_with_id(btfe->priv, &base->tag, id); + + return 0; +} + +static int create_new_float_type(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + strings_t name = tp->name_off; + struct base_type *base = base_type__new(name, 0, BT_FP_SINGLE, tp->size * 8); + + if (base == NULL) + return -ENOMEM; + + base->tag.tag = DW_TAG_base_type; + cu__add_tag_with_id(btfe->priv, &base->tag, id); + + return 0; +} + +static int create_new_array(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + struct btf_array *ap = btf_array(tp); + struct array_type *array = tag__alloc(sizeof(*array)); + + if (array == NULL) + return -ENOMEM; + + /* FIXME: where to get the number of dimensions? + * it it flattened? */ + array->dimensions = 1; + array->nr_entries = malloc(sizeof(uint32_t)); + + if (array->nr_entries == NULL) { + free(array); + return -ENOMEM; + } + + array->nr_entries[0] = ap->nelems; + array->tag.tag = DW_TAG_array_type; + array->tag.type = ap->type; + + cu__add_tag_with_id(btfe->priv, &array->tag, id); + + return 0; +} + +static int create_members(struct btf_elf *btfe, const struct btf_type *tp, + struct type *class) +{ + struct btf_member *mp = btf_members(tp); + int i, vlen = btf_vlen(tp); + + for (i = 0; i < vlen; i++) { + struct class_member *member = zalloc(sizeof(*member)); + + if (member == NULL) + return -ENOMEM; + + member->tag.tag = DW_TAG_member; + member->tag.type = mp[i].type; + member->name = mp[i].name_off; + member->bit_offset = btf_member_bit_offset(tp, i); + member->bitfield_size = btf_member_bitfield_size(tp, i); + member->byte_offset = member->bit_offset / 8; + /* sizes and offsets will be corrected at class__fixup_btf_bitfields */ + type__add_member(class, member); + } + + return 0; +} + +static int create_new_class(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + struct class *class = class__new(tp->name_off, tp->size, false); + int member_size = create_members(btfe, tp, &class->type); + + if (member_size < 0) + goto out_free; + + cu__add_tag_with_id(btfe->priv, &class->type.namespace.tag, id); + + return 0; +out_free: + class__delete(class, btfe->priv); + return -ENOMEM; +} + +static int create_new_union(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + struct type *un = type__new(DW_TAG_union_type, tp->name_off, tp->size); + int member_size = create_members(btfe, tp, un); + + if (member_size < 0) + goto out_free; + + cu__add_tag_with_id(btfe->priv, &un->namespace.tag, id); + + return 0; +out_free: + type__delete(un, btfe->priv); + return -ENOMEM; +} + +static struct enumerator *enumerator__new(strings_t name, uint32_t value) +{ + struct enumerator *en = tag__alloc(sizeof(*en)); + + if (en != NULL) { + en->name = name; + en->value = value; + en->tag.tag = DW_TAG_enumerator; + } + + return en; +} + +static int create_new_enumeration(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + struct btf_enum *ep = btf_enum(tp); + uint16_t i, vlen = btf_vlen(tp); + struct type *enumeration = type__new(DW_TAG_enumeration_type, + tp->name_off, + tp->size ? tp->size * 8 : (sizeof(int) * 8)); + + if (enumeration == NULL) + return -ENOMEM; + + for (i = 0; i < vlen; i++) { + strings_t name = ep[i].name_off; + uint32_t value = ep[i].val; + struct enumerator *enumerator = enumerator__new(name, value); + + if (enumerator == NULL) + goto out_free; + + enumeration__add(enumeration, enumerator); + } + + cu__add_tag_with_id(btfe->priv, &enumeration->namespace.tag, id); + + return 0; +out_free: + enumeration__delete(enumeration, btfe->priv); + return -ENOMEM; +} + +static int create_new_subroutine_type(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + struct ftype *proto = tag__alloc(sizeof(*proto)); + + if (proto == NULL) + return -ENOMEM; + + return btf_elf__load_ftype(btfe, proto, DW_TAG_subroutine_type, tp, id); +} + +static int create_new_forward_decl(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + struct class *fwd = class__new(tp->name_off, 0, btf_kflag(tp)); + + if (fwd == NULL) + return -ENOMEM; + fwd->type.declaration = 1; + cu__add_tag_with_id(btfe->priv, &fwd->type.namespace.tag, id); + return 0; +} + +static int create_new_typedef(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + struct type *type = type__new(DW_TAG_typedef, tp->name_off, 0); + + if (type == NULL) + return -ENOMEM; + + type->namespace.tag.type = tp->type; + cu__add_tag_with_id(btfe->priv, &type->namespace.tag, id); + + return 0; +} + +static int create_new_variable(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + struct btf_var *bvar = btf_var(tp); + struct variable *var = variable__new(tp->name_off, bvar->linkage); + + if (var == NULL) + return -ENOMEM; + + var->ip.tag.type = tp->type; + cu__add_tag_with_id(btfe->priv, &var->ip.tag, id); + return 0; +} + +static int create_new_datasec(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id) +{ + //strings_t name = btf_elf__get32(btfe, &tp->name_off); + + //cu__add_tag_with_id(btfe->priv, &datasec->tag, id); + + /* + * FIXME: this will not be used to reconstruct some original C code, + * its about runtime placement of variables so just ignore this for now + */ + return 0; +} + +static int create_new_tag(struct btf_elf *btfe, int type, const struct btf_type *tp, uint32_t id) +{ + struct tag *tag = zalloc(sizeof(*tag)); + + if (tag == NULL) + return -ENOMEM; + + switch (type) { + case BTF_KIND_CONST: tag->tag = DW_TAG_const_type; break; + case BTF_KIND_PTR: tag->tag = DW_TAG_pointer_type; break; + case BTF_KIND_RESTRICT: tag->tag = DW_TAG_restrict_type; break; + case BTF_KIND_VOLATILE: tag->tag = DW_TAG_volatile_type; break; + default: + free(tag); + printf("%s: Unknown type %d\n\n", __func__, type); + return 0; + } + + tag->type = tp->type; + cu__add_tag_with_id(btfe->priv, tag, id); + + return 0; +} + +static int btf_elf__load_types(struct btf_elf *btfe) +{ + uint32_t type_index; + int err; + + for (type_index = 1; type_index <= btf__get_nr_types(btfe->btf); type_index++) { + const struct btf_type *type_ptr = btf__type_by_id(btfe->btf, type_index); + uint32_t type = btf_kind(type_ptr); + + switch (type) { + case BTF_KIND_INT: + err = create_new_int_type(btfe, type_ptr, type_index); + break; + case BTF_KIND_ARRAY: + err = create_new_array(btfe, type_ptr, type_index); + break; + case BTF_KIND_STRUCT: + err = create_new_class(btfe, type_ptr, type_index); + break; + case BTF_KIND_UNION: + err = create_new_union(btfe, type_ptr, type_index); + break; + case BTF_KIND_ENUM: + err = create_new_enumeration(btfe, type_ptr, type_index); + break; + case BTF_KIND_FWD: + err = create_new_forward_decl(btfe, type_ptr, type_index); + break; + case BTF_KIND_TYPEDEF: + err = create_new_typedef(btfe, type_ptr, type_index); + break; + case BTF_KIND_VAR: + err = create_new_variable(btfe, type_ptr, type_index); + break; + case BTF_KIND_DATASEC: + err = create_new_datasec(btfe, type_ptr, type_index); + break; + case BTF_KIND_VOLATILE: + case BTF_KIND_PTR: + case BTF_KIND_CONST: + case BTF_KIND_RESTRICT: + err = create_new_tag(btfe, type, type_ptr, type_index); + break; + case BTF_KIND_UNKN: + cu__table_nullify_type_entry(btfe->priv, type_index); + fprintf(stderr, "BTF: idx: %d, Unknown kind %d\n", type_index, type); + fflush(stderr); + err = 0; + break; + case BTF_KIND_FUNC_PROTO: + err = create_new_subroutine_type(btfe, type_ptr, type_index); + break; + case BTF_KIND_FUNC: + // BTF_KIND_FUNC corresponding to a defined subprogram. + err = create_new_function(btfe, type_ptr, type_index); + break; + case BTF_KIND_FLOAT: + err = create_new_float_type(btfe, type_ptr, type_index); + break; + default: + fprintf(stderr, "BTF: idx: %d, Unknown kind %d\n", type_index, type); + fflush(stderr); + err = 0; + break; + } + + if (err < 0) + return err; + } + return 0; +} + +static int btf_elf__load_sections(struct btf_elf *btfe) +{ + return btf_elf__load_types(btfe); +} + +static int class__fixup_btf_bitfields(struct tag *tag, struct cu *cu, struct btf_elf *btfe) +{ + struct class_member *pos; + struct type *tag_type = tag__type(tag); + + type__for_each_data_member(tag_type, pos) { + struct tag *type = tag__strip_typedefs_and_modifiers(&pos->tag, cu); + + if (type == NULL) /* FIXME: C++ BTF... */ + continue; + + pos->bitfield_offset = 0; + pos->byte_size = tag__size(type, cu); + pos->bit_size = pos->byte_size * 8; + + /* bitfield fixup is needed for enums and base types only */ + if (type->tag != DW_TAG_base_type && type->tag != DW_TAG_enumeration_type) + continue; + + /* if BTF data is incorrect and has size == 0, skip field, + * instead of crashing */ + if (pos->byte_size == 0) { + continue; + } + + if (pos->bitfield_size) { + /* bitfields seem to be always aligned, no matter the packing */ + pos->byte_offset = pos->bit_offset / pos->bit_size * pos->bit_size / 8; + pos->bitfield_offset = pos->bit_offset - pos->byte_offset * 8; + /* re-adjust bitfield offset if it is negative */ + if (pos->bitfield_offset < 0) { + pos->bitfield_offset += pos->bit_size; + pos->byte_offset -= pos->byte_size; + pos->bit_offset = pos->byte_offset * 8 + pos->bitfield_offset; + } + } else { + pos->byte_offset = pos->bit_offset / 8; + } + } + + return 0; +} + +static int cu__fixup_btf_bitfields(struct cu *cu, struct btf_elf *btfe) +{ + int err = 0; + struct tag *pos; + + list_for_each_entry(pos, &cu->tags, node) + if (tag__is_struct(pos) || tag__is_union(pos)) { + err = class__fixup_btf_bitfields(pos, cu, btfe); + if (err) + break; + } + + return err; +} + +static void btf_elf__cu_delete(struct cu *cu) +{ + btf_elf__delete(cu->priv); + cu->priv = NULL; +} + +static const char *btf_elf__strings_ptr(const struct cu *cu, strings_t s) +{ + return btf_elf__string(cu->priv, s); +} + +struct debug_fmt_ops btf_elf__ops; + +int btf_elf__load_file(struct cus *cus, struct conf_load *conf, const char *filename) +{ + int err; + struct btf_elf *btfe = btf_elf__new(filename, NULL, base_btf); + + if (btfe == NULL) + return -1; + + struct cu *cu = cu__new(filename, btfe->wordsize, NULL, 0, filename); + if (cu == NULL) + return -1; + + cu->language = LANG_C; + cu->uses_global_strings = false; + cu->little_endian = !btfe->is_big_endian; + cu->dfops = &btf_elf__ops; + cu->priv = btfe; + btfe->priv = cu; + if (btf_elf__load(btfe) != 0) + return -1; + + err = btf_elf__load_sections(btfe); + + if (err != 0) { + cu__delete(cu); + return err; + } + + err = cu__fixup_btf_bitfields(cu, btfe); + /* + * The app stole this cu, possibly deleting it, + * so forget about it + */ + if (conf && conf->steal && conf->steal(cu, conf)) + return 0; + + cus__add(cus, cu); + return err; +} + +struct debug_fmt_ops btf_elf__ops = { + .name = "btf", + .load_file = btf_elf__load_file, + .strings__ptr = btf_elf__strings_ptr, + .cu__delete = btf_elf__cu_delete, +}; diff -Nru dwarves-dfsg-1.10/changes-v1.13 dwarves-dfsg-1.21/changes-v1.13 --- dwarves-dfsg-1.10/changes-v1.13 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/changes-v1.13 2019-05-01 18:23:10.000000000 +0000 @@ -0,0 +1,209 @@ +Here is a summary of changes for the 1.13 version of pahole and its friends: + +- BTF + + - Use of the recently introduced BTF deduplication algorithm present in the + Linux kernel's libbpf library, which allows for all the types in a multi + compile unit binary such as vmlinux to be compactly stored, without duplicates. + + E.g.: from roughly: + + $ readelf -SW ../build/v5.1-rc4+/vmlinux | grep .debug_info.*PROGBITS + [63] .debug_info PROGBITS 0000000000000000 1d80be0 c3c18b9 00 0 0 1 + $ + 195 MiB + + to: + + $ time pahole --btf_encode ../build/v5.1-rc4+/vmlinux + real 0m19.168s + user 0m17.707s # On a Lenovo t480s (i7-8650U) SSD + sys 0m1.337s + $ + + $ readelf -SW ../build/v5.1-rc4+/vmlinux | grep .BTF.*PROGBITS + [78] .BTF PROGBITS 0000000000000000 27b49f61 1e23c3 00 0 0 1 + $ + ~2 MiB + + - Introduce a 'btfdiff' utility that prints the output from DWARF and from + BTF, comparing the pretty printed outputs, running it on various linux + kernel images, such as an allyesconfig for ppc64. + + Running it on the above 5.1-rc4+ vmlinux: + + $ btfdiff ../build/v5.1-rc4+/vmlinux + $ + + No differences from the types generated from the DWARF ELF sections to the + ones generated from the BTF ELF section. + + - Add a BTF loader, i.e. 'pahole -F btf' allows pretty printing of structs + and unions in the same fashion as with DWARF info, and since BTF is way + more compact, using it is much faster than using DWARF. + + $ cat ../build/v5.1-rc4+/vmlinux > /dev/null + $ perf stat -e cycles pahole -F btf ../build/v5.1-rc4+/vmlinux > /dev/null + + Performance counter stats for 'pahole -F btf ../build/v5.1-rc4+/vmlinux': + + 229,712,692 cycles:u + 0.063379597 seconds time elapsed + 0.056265000 seconds user + 0.006911000 seconds sys + + $ perf stat -e cycles pahole -F dwarf ../build/v5.1-rc4+/vmlinux > /dev/null + + Performance counter stats for 'pahole -F dwarf ../build/v5.1-rc4+/vmlinux': + + 49,579,679,466 cycles:u + 13.063487352 seconds time elapsed + 12.612512000 seconds user + 0.426226000 seconds sys + $ + +- Better union support: + + - Allow unions to be specified in pahole in the same fashion as structs + + $ pahole -C thread_union ../build/v5.1-rc4+/net/ipv4/tcp.o + union thread_union { + struct task_struct task __attribute__((__aligned__(64))); /* 0 11008 */ + long unsigned int stack[2048]; /* 0 16384 */ + }; + $ + +- Infer __attribute__((__packed__)) when structs have no alignment holes + and violate basic types (integer, longs, short integer) natural alignment + requirements. Several heuristics are used to infer the __packed__ + attribute, see the changeset log for descriptions. + + $ pahole -F btf -C boot_e820_entry ../build/v5.1-rc4+/vmlinux + struct boot_e820_entry { + __u64 addr; /* 0 8 */ + __u64 size; /* 8 8 */ + __u32 type; /* 16 4 */ + + /* size: 20, cachelines: 1, members: 3 */ + /* last cacheline: 20 bytes */ + } __attribute__((__packed__)); + $ + + $ pahole -F btf -C lzma_header ../build/v5.1-rc4+/vmlinux + struct lzma_header { + uint8_t pos; /* 0 1 */ + uint32_t dict_size; /* 1 4 */ + uint64_t dst_size; /* 5 8 */ + + /* size: 13, cachelines: 1, members: 3 */ + /* last cacheline: 13 bytes */ + } __attribute__((__packed__)); + +- Support DWARF5's DW_AT_alignment, which, together with the __packed__ + attribute inference algorithms produce output that, when compiled, should + produce structures with layouts that match the original source code. + + See it in action with 'struct task_struct', which will also show some of the + new information at the struct summary, at the end of the struct: + + $ pahole -C task_struct ../build/v5.1-rc4+/vmlinux | tail -19 + /* --- cacheline 103 boundary (6592 bytes) --- */ + struct vm_struct * stack_vm_area; /* 6592 8 */ + refcount_t stack_refcount; /* 6600 4 */ + + /* XXX 4 bytes hole, try to pack */ + + void * security; /* 6608 8 */ + + /* XXX 40 bytes hole, try to pack */ + + /* --- cacheline 104 boundary (6656 bytes) --- */ + struct thread_struct thread __attribute__((__aligned__(64))); /* 6656 4352 */ + + /* size: 11008, cachelines: 172, members: 207 */ + /* sum members: 10902, holes: 16, sum holes: 98 */ + /* sum bitfield members: 10 bits, bit holes: 2, sum bit holes: 54 bits */ + /* paddings: 3, sum paddings: 14 */ + /* forced alignments: 6, forced holes: 1, sum forced holes: 40 */ + } __attribute__((__aligned__(64))); + $ + +- Add a '--compile' option to 'pfunct' that produces compileable output for the + function prototypes in an object file. There are still some bugs but the vast + majority of the kernel single compilation unit files the ones produced from a + single .c file are working, see the new 'fullcircle' utility that uses this + feature. + + Example of it in action: + + $ pfunct --compile=static_key_false ../build/v5.1-rc4+/net/ipv4/tcp.o + typedef _Bool bool; + typedef struct { + int counter; /* 0 4 */ + + /* size: 4, cachelines: 1, members: 1 */ + /* last cacheline: 4 bytes */ + } atomic_t; + + struct jump_entry; + + struct static_key_mod; + + + struct static_key { + atomic_t enabled; /* 0 4 */ + + /* XXX 4 bytes hole, try to pack */ + + union { + long unsigned int type; /* 8 8 */ + struct jump_entry * entries; /* 8 8 */ + struct static_key_mod * next; /* 8 8 */ + }; /* 8 8 */ + + /* size: 16, cachelines: 1, members: 2 */ + /* sum members: 12, holes: 1, sum holes: 4 */ + /* last cacheline: 16 bytes */ + }; + + bool static_key_false(struct static_key * key) + { + return *(bool *)1; + } + + $ + +The generation of compilable code from the type information and its use in the +new tool 'fullcircle, helps validate all the parts of this codebase, finding +bugs that were lurking forever, go read the csets to find all sorts of curious +C language features that are rarely seen, like unnamed zero sized bitfields and +the way people have been using it over the years in a codebase like the linux +kernel. + +Certainly there are several other features, changes and fixes that I forgot to +mention! Now lemme release this version so that we can use it more extensively +together with a recent patch merged for 5.2: + + [PATCH bpf-next] kbuild: add ability to generate BTF type info for vmlinux + +With it BTF will be always available for all the types of the kernel, which will +open a pandora box of cool new features that are in the works, and, for people +already using pahole, will greatly speed up its usage. + +Please try to alias it to use btf, i.e. + + alias pahole='pahole -F btf' + +Please report any problems you may find with this new version or with the BTF +loader or any errors in the layout generated/pretty printed. + +Thanks to the fine BTF guys at Facebook for the patches and help in testing, +fixing bugs and getting this out of the door, the stats for this release are: + + Changesets: 157 + + 113 Arnaldo Carvalho de Melo Red Hat + 32 Andrii Nakryiko Facebook + 10 Yonghong Song Facebook + 1 Martin Lau Facebook + 1 Domenico Andreoli diff -Nru dwarves-dfsg-1.10/changes-v1.16 dwarves-dfsg-1.21/changes-v1.16 --- dwarves-dfsg-1.10/changes-v1.16 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/changes-v1.16 2019-12-16 14:43:48.000000000 +0000 @@ -0,0 +1,104 @@ +v1.16 changes: + +BTF encoder: + + Andrii Nakryiko : + + - Preserve and encode exported functions as BTF_KIND_FUNC. + + Add encoding of DWARF's DW_TAG_subprogram_type into BTF's BTF_KIND_FUNC + (plus corresponding BTF_KIND_FUNC_PROTO). Only exported functions are converted + for now. This allows to capture all the exported kernel functions, same subset + that's exposed through /proc/kallsyms. + +BTF loader: + + Arnaldo Carvalho de Melo + + - Add support for BTF_KIND_FUNC + + Some changes to the fprintf routines were needed, as BTF has as the + function type just a BTF_KIND_FUNC_PROTO, while DWARF has as the type for a + function its return value type. With a function->btf flag this was overcome and + all the other goodies in pfunct are present. + +Pretty printer: + + Arnaldo Carvalho de Melo: + + - Account inline type __aligned__ member types for spacing: + + union { + refcount_t rcu_users; /* 2568 4 */ + struct callback_head rcu __attribute__((__aligned__(8))); /* 2568 16 */ + - } __attribute__((__aligned__(8))); /* 2568 16 */ + + } __attribute__((__aligned__(8))); /* 2568 16 */ + struct pipe_inode_info * splice_pipe; /* 2584 8 */ + + - Fix alignment of class members that are structs/enums/unions + + E.g. look at that 'completion' member in this struct: + + struct cpu_stop_done { + atomic_t nr_todo; /* 0 4 */ + int ret; /* 4 4 */ + - struct completion completion; /* 8 32 */ + + struct completion completion; /* 8 32 */ + + /* size: 40, cachelines: 1, members: 3 */ + /* last cacheline: 40 bytes */ + + - Fixup handling classes with no members, solving a NULL deref. + + Gareth Lloyd : + + - Avoid infinite loop trying to determine type with static data member of its own type. + +RPM spec file. + +Jiri Olsa + + Add dwarves dependency on libdwarves1. + +pfunct: + + Arnaldo Carvalho de Melo + + - type->type == 0 is void, fix --compile for that + + We were using the fall back for that, i.e. 'return 0;' was being emitted + for a function returning void, noticed with using BTF as the format. + +pdwtags: + + - Print DW_TAG_subroutine_type as well + + So that we can see at least via pdwtags those tags, be it from DWARF of BTF. + +core: + + Arnaldo Carvalho de Melo + + Fix ptr_table__add_with_id() handling of pt->nr_entries, covering how + BTF variables IDs are encoded. + + +pglobal: + + Arnaldo Carvalho de Melo : + + - Allow passing the format path specifier, to use with BTF + + I.e. now we can, just like with pahole, use: + + pglobal -F btf --variable foo.o + + To get the global variables. + +Tree wide: + + Arnaldo Carvalho de Melo : + + - Fixup issues pointed out by various coverity reports. + +Signed-off-by: Arnaldo Carvalho de Melo diff -Nru dwarves-dfsg-1.10/changes-v1.17 dwarves-dfsg-1.21/changes-v1.17 --- dwarves-dfsg-1.10/changes-v1.17 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/changes-v1.17 2020-03-13 19:35:57.000000000 +0000 @@ -0,0 +1,540 @@ +v1.17 changes: + +tl;dr: + +BTF loader: + + - Support raw BTF as available in /sys/kernel/btf/vmlinux. + +pahole: + + - When the sole argument passed isn't a file, take it as a class name: + + $ pahole sk_buff + + - Do not require a class name to operate without a file name. + + $ pahole # is equivalent to: + $ pahole vmlinux + + - Make --find_pointers_to consider unions: + + $ pahole --find_pointers_to ehci_qh + + - Make --contains and --find_pointers_to honour --unions + + $ pahole --unions --contains inet_sock + + - Add support for finding pointers to void: + + $ pahole --find_pointers_to void + + - Make --contains and --find_pointers_to to work with base types: + + $ pahole --find_pointers_to 'short unsigned int' + + - Make --contains look for more than just unions, structs: + + $ pahole --contains raw_spinlock_t + + - Consider unions when looking for classes containing some class: + + $ pahole --contains tpacket_req + + - Introduce --unions to consider just unions: + + $ pahole --unions --sizes + $ pahole --unions --prefix tcp + $ pahole --unions --nr_members + + - Fix -m/--nr_methods - Number of functions operating on a type pointer + + $ pahole --nr_methods + +man-pages: + + - Add section about --hex + -E to locate offsets deep into sub structs. + + - Add more information about BTF. + + - Add some examples. + +---------------------------------- + +I want the details: + +btf loader: + + - Support raw BTF as available in /sys/kernel/btf/vmlinux + + Be it automatically when no -F option is passed and + /sys/kernel/btf/vmlinux is available, or when /sys/kernel/btf/vmlinux is + passed as the filename to the tool, i.e.: + + $ pahole -C list_head + struct list_head { + struct list_head * next; /* 0 8 */ + struct list_head * prev; /* 8 8 */ + + /* size: 16, cachelines: 1, members: 2 */ + /* last cacheline: 16 bytes */ + }; + $ strace -e openat pahole -C list_head |& grep /sys/kernel/btf/ + openat(AT_FDCWD, "/sys/kernel/btf/vmlinux", O_RDONLY) = 3 + $ + $ pahole -C list_head /sys/kernel/btf/vmlinux + struct list_head { + struct list_head * next; /* 0 8 */ + struct list_head * prev; /* 8 8 */ + + /* size: 16, cachelines: 1, members: 2 */ + /* last cacheline: 16 bytes */ + }; + $ + + If one wants to grab the matching vmlinux to use its DWARF info instead, + which is useful to compare the results with what we have from BTF, for + instance, its just a matter of using '-F dwarf'. + + This in turn shows something that at first came as a surprise, but then + has a simple explanation: + + For very common data structures, that will probably appear in all of the + DWARF CUs (Compilation Units), like 'struct list_head', using '-F dwarf' + is faster: + + $ perf stat -e cycles pahole -F btf -C list_head > /dev/null + + Performance counter stats for 'pahole -F btf -C list_head': + + 45,722,518 cycles:u + + 0.023717300 seconds time elapsed + + 0.016474000 seconds user + 0.007212000 seconds sys + + $ perf stat -e cycles pahole -F dwarf -C list_head > /dev/null + + Performance counter stats for 'pahole -F dwarf -C list_head': + + 14,170,321 cycles:u + + 0.006668904 seconds time elapsed + + 0.005562000 seconds user + 0.001109000 seconds sys + + $ + + But for something that is more specific to a subsystem, the DWARF loader + will have to process way more stuff till it gets to that struct: + + $ perf stat -e cycles pahole -F dwarf -C tcp_sock > /dev/null + + Performance counter stats for 'pahole -F dwarf -C tcp_sock': + + 31,579,795,238 cycles:u + + 8.332272930 seconds time elapsed + + 8.032124000 seconds user + 0.286537000 seconds sys + + $ + + While using the BTF loader the time should be constant, as it loads + everything from /sys/kernel/btf/vmlinux: + + $ perf stat -e cycles pahole -F btf -C tcp_sock > /dev/null + + Performance counter stats for 'pahole -F btf -C tcp_sock': + + 48,823,488 cycles:u + + 0.024102760 seconds time elapsed + + 0.012035000 seconds user + 0.012046000 seconds sys + + $ + + Above I used '-F btf' just to show that it can be used, but its not + really needed, i.e. those are equivalent: + + $ strace -e openat pahole -F btf -C list_head |& grep /sys/kernel/btf/vmlinux + openat(AT_FDCWD, "/sys/kernel/btf/vmlinux", O_RDONLY) = 3 + $ strace -e openat pahole -C list_head |& grep /sys/kernel/btf/vmlinux + openat(AT_FDCWD, "/sys/kernel/btf/vmlinux", O_RDONLY) = 3 + $ + + The btf_raw__load() function that ends up being grafted into the + preexisting btf_elf routines was based on libbpf's btf_load_raw(). + +pahole: + + - When the sole argument passed isn't a file, take it as a class name. + + With that it becomes as compact as it gets for kernel data structures, + just state the name of the struct and it'll try to find that as a file, + not being a file it'll use /sys/kernel/btf/vmlinux and the argument as a + list of structs, i.e.: + + $ pahole skb_ext,list_head + struct list_head { + struct list_head * next; /* 0 8 */ + struct list_head * prev; /* 8 8 */ + + /* size: 16, cachelines: 1, members: 2 */ + /* last cacheline: 16 bytes */ + }; + struct skb_ext { + refcount_t refcnt; /* 0 4 */ + u8 offset[3]; /* 4 3 */ + u8 chunks; /* 7 1 */ + char data[]; /* 8 0 */ + + /* size: 8, cachelines: 1, members: 4 */ + /* last cacheline: 8 bytes */ + }; + $ pahole hlist_node + struct hlist_node { + struct hlist_node * next; /* 0 8 */ + struct hlist_node * * pprev; /* 8 8 */ + + /* size: 16, cachelines: 1, members: 2 */ + /* last cacheline: 16 bytes */ + }; + $ + + Of course -C continues to work: + + $ pahole -C inode | tail + __u32 i_fsnotify_mask; /* 556 4 */ + struct fsnotify_mark_connector * i_fsnotify_marks; /* 560 8 */ + struct fscrypt_info * i_crypt_info; /* 568 8 */ + /* --- cacheline 9 boundary (576 bytes) --- */ + struct fsverity_info * i_verity_info; /* 576 8 */ + void * i_private; /* 584 8 */ + + /* size: 592, cachelines: 10, members: 53 */ + /* last cacheline: 16 bytes */ + }; + $ + + - Add support for finding pointers to void, e.g.: + + $ pahole --find_pointers_to void --prefix tcp + tcp_md5sig_pool: scratch + $ pahole tcp_md5sig_pool + struct tcp_md5sig_pool { + struct ahash_request * md5_req; /* 0 8 */ + void * scratch; /* 8 8 */ + + /* size: 16, cachelines: 1, members: 2 */ + /* last cacheline: 16 bytes */ + }; + $ + + - Make --contains and --find_pointers_to to work with base types + + I.e. with plain 'int', 'long', 'short int', etc: + + $ pahole --find_pointers_to 'short unsigned int' + uv_hub_info_s: socket_to_node + uv_hub_info_s: socket_to_pnode + uv_hub_info_s: pnode_to_socket + vc_data: vc_screenbuf + vc_data: vc_translate + filter_pred: ops + ext4_sb_info: s_mb_offsets + $ pahole ext4_sb_info | 'sort unsigned int' + bash: sort unsigned int: command not found... + ^[^C + $ + $ pahole ext4_sb_info | grep 'sort unsigned int' + $ pahole ext4_sb_info | grep 'short unsigned int' + short unsigned int s_mount_state; /* 160 2 */ + short unsigned int s_pad; /* 162 2 */ + short unsigned int * s_mb_offsets; /* 664 8 */ + $ pahole --contains 'short unsigned int' + apm_info + desc_ptr + thread_struct + mpc_table + mpc_intsrc + fsnotify_mark_connector + + sock_fprog + blk_mq_hw_ctx + skb_shared_info + $ + + - Make --contains look for more than just unions, structs, look for + typedefs, enums and types that descend from 'struct type': + + So now we can do more interesting queries, lets see, what are the data + structures that embed a raw spinlock in the linux kernel? + + $ pahole --contains raw_spinlock_t + task_struct + rw_semaphore + hrtimer_cpu_base + prev_cputime + percpu_counter + ratelimit_state + perf_event_context + task_delay_info + + lpm_trie + bpf_queue_stack + $ + + Look at the csets comments to see more examples. + + - Make --contains and --find_pointers_to honour --unions + + I.e. when looking for unions or structs that contains/embeds or looking + for unions/structs that have pointers to a given type. + + E.g: + + $ pahole --contains inet_sock + sctp_sock + inet_connection_sock + raw_sock + udp_sock + raw6_sock + $ pahole --unions --contains inet_sock + $ + + We have structs embedding 'struct inet_sock', but no unions doing that. + + - Make --find_pointers_to consider unions + + I.e.: + + $ pahole --find_pointers_to ehci_qh + ehci_hcd: qh_scan_next + ehci_hcd: async + ehci_hcd: dummy + $ + + Wasn't considering: + + $ pahole -C ehci_shadow + union ehci_shadow { + struct ehci_qh * qh; /* 0 8 */ + struct ehci_itd * itd; /* 0 8 */ + struct ehci_sitd * sitd; /* 0 8 */ + struct ehci_fstn * fstn; /* 0 8 */ + __le32 * hw_next; /* 0 8 */ + void * ptr; /* 0 8 */ + }; + $ + + Fix it: + + $ pahole --find_pointers_to ehci_qh + ehci_hcd: qh_scan_next + ehci_hcd: async + ehci_hcd: dummy + ehci_shadow: qh + $ + + - Consider unions when looking for classes containing some class: + + I.e.: + + $ pahole --contains tpacket_req + tpacket_req_u + $ + + Wasn't working, but should be considered with --contains/-i: + + $ pahole -C tpacket_req_u + union tpacket_req_u { + struct tpacket_req req; /* 0 16 */ + struct tpacket_req3 req3; /* 0 28 */ + }; + $ + + - Introduce --unions to consider just unions + + Most filters can be used together with it, for instance to see the + biggest unions in the kernel: + + $ pahole --unions --sizes | sort -k2 -nr | head + thread_union 16384 0 + swap_header 4096 0 + fpregs_state 4096 0 + autofs_v5_packet_union 304 0 + autofs_packet_union 272 0 + pptp_ctrl_union 208 0 + acpi_parse_object 200 0 + acpi_descriptor 200 0 + bpf_attr 120 0 + phy_configure_opts 112 0 + $ + + Or just some unions that have some specific prefix: + + $ pahole --unions --prefix tcp + union tcp_md5_addr { + struct in_addr a4; /* 0 4 */ + struct in6_addr a6; /* 0 16 */ + }; + union tcp_word_hdr { + struct tcphdr hdr; /* 0 20 */ + __be32 words[5]; /* 0 20 */ + }; + union tcp_cc_info { + struct tcpvegas_info vegas; /* 0 16 */ + struct tcp_dctcp_info dctcp; /* 0 16 */ + struct tcp_bbr_info bbr; /* 0 20 */ + }; + $ + + What are the biggest unions in terms of number of members? + + $ pahole --unions --nr_members | sort -k2 -nr | head + security_list_options 218 + aml_resource 36 + acpi_resource_data 29 + acpi_operand_object 26 + iwreq_data 18 + sctp_params 15 + ib_flow_spec 14 + ethtool_flow_union 14 + pptp_ctrl_union 13 + bpf_attr 12 + $ + + If you want to script most of the queries can change the separator: + + $ pahole --unions --nr_members -t, | sort -t, -k2 -nr | head + security_list_options,218 + aml_resource,36 + acpi_resource_data,29 + acpi_operand_object,26 + iwreq_data,18 + sctp_params,15 + ib_flow_spec,14 + ethtool_flow_union,14 + pptp_ctrl_union,13 + bpf_attr,12 + $ + + - Fix -m/--nr_methods - Number of functions operating on a type pointer + + We had to use the same hack as in pfunct, as implemented in ccf3eebfcd9c + ("btf_loader: Add support for BTF_KIND_FUNC"), will hide that 'struct + ftype' (aka function prototype) indirection behind the parameter + iterator (function__for_each_parameter). + + For now, here is the top 10 Linux kernel data structures in terms of + number of functions receiving as one of its parameters a pointer to it, + using /sys/kernel/btf/vmlinux to look at all the vmlinux types and + functions (the ones visible in kallsyms, but with the parameters and its + types): + + $ pahole -m | sort -k2 -nr | head + device 955 + sock 568 + sk_buff 541 + task_struct 437 + inode 421 + pci_dev 390 + page 351 + net_device 347 + file 315 + net 312 + $ + $ pahole --help |& grep -- -m + -m, --nr_methods show number of methods + $ + + - Do not require a class name to operate without a file name + + Since we default to operating on the running kernel data structures, we + should make the default to, with no options passed, to pretty print all + the running kernel data structures, or do what was asked in terms of + number of members, size of structs, etc, i.e.: + + # pahole --help |& head + Usage: pahole [OPTION...] FILE + + -a, --anon_include include anonymous classes + -A, --nested_anon_include include nested (inside other structs) anonymous + classes + -B, --bit_holes=NR_HOLES Show only structs at least NR_HOLES bit holes + -c, --cacheline_size=SIZE set cacheline size to SIZE + --classes_as_structs Use 'struct' when printing classes + -C, --class_name=CLASS_NAME Show just this class + -d, --recursive recursive mode, affects several other flags + # + + Continues working as before, but if you do: + + pahole + + It will work just as if you did: + + pahole vmlinux + + and that vmlinux file is the running kernel vmlinux. + + And since the default now is to read BTF info, then it will do all its + operations on /sys/kernel/btf/vmlinux, when present, i.e. want to know + what are the fattest data structures in the running kernel: + + # pahole -s | sort -k2 -nr | head + cmp_data 290904 1 + dec_data 274520 1 + cpu_entry_area 217088 0 + pglist_data 172928 4 + saved_cmdlines_buffer 131104 1 + debug_store_buffers 131072 0 + hid_parser 110848 1 + hid_local 110608 0 + zonelist 81936 0 + e820_table 64004 0 + # + + How many data structures in the running kernel vmlinux area embbed + 'struct list_head'? + + # pahole -i list_head | wc -l + 260 + # + + Lets see some of those? + + # pahole -C fsnotify_event + struct fsnotify_event { + struct list_head list; /* 0 16 */ + struct inode * inode; /* 16 8 */ + + /* size: 24, cachelines: 1, members: 2 */ + /* last cacheline: 24 bytes */ + }; + # pahole -C audit_chunk + struct audit_chunk { + struct list_head hash; /* 0 16 */ + long unsigned int key; /* 16 8 */ + struct fsnotify_mark * mark; /* 24 8 */ + struct list_head trees; /* 32 16 */ + int count; /* 48 4 */ + + /* XXX 4 bytes hole, try to pack */ + + atomic_long_t refs; /* 56 8 */ + /* --- cacheline 1 boundary (64 bytes) --- */ + struct callback_head head; /* 64 16 */ + struct node owners[]; /* 80 0 */ + + /* size: 80, cachelines: 2, members: 8 */ + /* sum members: 76, holes: 1, sum holes: 4 */ + /* last cacheline: 16 bytes */ + }; + # diff -Nru dwarves-dfsg-1.10/changes-v1.18 dwarves-dfsg-1.21/changes-v1.18 --- dwarves-dfsg-1.10/changes-v1.18 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/changes-v1.18 2021-03-07 13:51:27.000000000 +0000 @@ -0,0 +1,117 @@ +v1.18: + +- Use type information to pretty print raw data from stdin, all + documented in the man pages, further information in the csets. + + TLDRish: this almost completely deciphers a perf.data file: + + $ pahole ~/bin/perf --header=perf_file_header \ + -C 'perf_file_attr(range=attrs),perf_event_header(range=data,sizeof,type,type_enum=perf_event_type+perf_user_event_type)' < perf.data + + What the above command line does: + + This will state that a 'struct perf_file_header' is available in BTF or DWARF + in the ~/bin/perf file and that at the start of stdin it should be used to decode + sizeof(struct perf_file_header) bytes, pretty printing it according to its members. + + Furthermore, that header can be referenced later in the command line, for instance + that 'range=data' means that in the header, it expects a 'range' member in + 'struct perf_file_header' to be used: + + $ pahole ~/bin/perf --header=perf_file_header < perf.data + { + .magic = 3622385352885552464, + .size = 104, + .attr_size = 136, + .attrs = { + .offset = 296, + .size = 136, + }, + .data = { + .offset = 432, + .size = 14688, + }, + .event_types = { + .offset = 0, + .size = 0, + }, + .adds_features = { 376537084, 0, 0, 0 }, + }, + $ + + That 'range' field is expected to have 'offset' and 'size' fields, so that + it can go on decoding a number of 'struct perf_event_header' entries. + + That 'sizeof' in turn expects that in 'struct perf_event_header' there is a + 'size' field stating how long that particular record is, one can also use + 'sizeof=some_other_member_name'. + + This supports variable sized records and then the 'type' field expects there + is a 'struct perf_event_type' member named 'type' (again, type=something_else + may be used. Finally, the value in the 'type' field is used to lookup an entry + in the set formed by the two enumerations specified in the 'type_enum=' argument. + + If we look at these enums we'll see that its entries have names that can be, + when lowercased, point to structs containing the layout for the variable sized + record, which allows it to cast and produce the right pretty printed output. + + I.e. using the kernel BTF info we get: + + $ pahole perf_event_type + enum perf_event_type { + PERF_RECORD_MMAP = 1, + PERF_RECORD_LOST = 2, + PERF_RECORD_COMM = 3, + PERF_RECORD_EXIT = 4, + PERF_RECORD_THROTTLE = 5, + PERF_RECORD_UNTHROTTLE = 6, + PERF_RECORD_FORK = 7, + PERF_RECORD_READ = 8, + PERF_RECORD_SAMPLE = 9, + PERF_RECORD_MMAP2 = 10, + PERF_RECORD_AUX = 11, + PERF_RECORD_ITRACE_START = 12, + PERF_RECORD_LOST_SAMPLES = 13, + PERF_RECORD_SWITCH = 14, + PERF_RECORD_SWITCH_CPU_WIDE = 15, + PERF_RECORD_NAMESPACES = 16, + PERF_RECORD_KSYMBOL = 17, + PERF_RECORD_BPF_EVENT = 18, + PERF_RECORD_CGROUP = 19, + PERF_RECORD_TEXT_POKE = 20, + PERF_RECORD_MAX = 21, + }; + $ + + That is the same as in ~/bin/perf, and, if we get one of these and ask for + that struct: + + $ pahole -C perf_record_mmap ~/bin/perf + struct perf_record_mmap { + struct perf_event_header header; /* 0 8 */ + __u32 pid; /* 8 4 */ + __u32 tid; /* 12 4 */ + __u64 start; /* 16 8 */ + __u64 len; /* 24 8 */ + __u64 pgoff; /* 32 8 */ + char filename[4096]; /* 40 4096 */ + + /* size: 4136, cachelines: 65, members: 7 */ + /* last cacheline: 40 bytes */ + }; + $ + + Many other options were introduced to work with this, including --count, + --skip, etc, look at the man page for details. + +- Store percpu variables in vmlinux BTF. This can be disabled when debugging + kernel features being developed to use it. + +- pahole now should be segfault free when handling gdb test suit DWARF + files, including ADA, FORTRAN, rust and dwp compressed files, the + later being just flatly refused, that got left for v1.19. + +- Bail out on partial units for now, avoiding segfaults and providing warning + to user, hopefully will be addressed in v1.19. + +Signed-off-by: Arnaldo Carvalho de Melo diff -Nru dwarves-dfsg-1.10/changes-v1.19 dwarves-dfsg-1.21/changes-v1.19 --- dwarves-dfsg-1.10/changes-v1.19 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/changes-v1.19 2021-03-07 13:51:27.000000000 +0000 @@ -0,0 +1,134 @@ +v1.19: + +- Support split BTF, where a main BTF file, vmlinux, can be used to find types + and then a kernel module, for instance, can have just what is unique to it. + + For instance, looking for a type in the main vmlinux BTF info: + + $ pahole wmi_notify_handler + pahole: type 'wmi_notify_handler' not found + $ + + If we look at the 'wmi' module BTF info that is in: + + $ ls -la /sys/kernel/btf/wmi + -r--r--r--. 1 root root 2866 Nov 18 13:35 /sys/kernel/btf/wmi + $ + + $ pahole /sys/kernel/btf/wmi -C wmi_notify_handler + typedef void (*wmi_notify_handler)(u32, void *); + $ + + '--btf_base=/sys/kernel/btf/vmlinux' was automatically added in this last + example, an option that was also introduced in this version where types used in + the wmi.ko module but present in vmlinux can be found so that there is no + duplicity of types. + +- Update libbpf to get the split BTF support and use some of its functions to + load BTF and speed up DWARF loading and BTF encoding. + +- Support cross-compiled ELF binaries with different endianness + +- Support showing typedefs for anonymous types, like structs, unions and enums, + see the "Align enumerators" entry below for an example, another: + + $ pahole rwlock_t + typedef struct { + arch_rwlock_t raw_lock; /* 0 8 */ + + /* size: 8, cachelines: 1, members: 1 */ + /* last cacheline: 8 bytes */ + } rwlock_t; + $ + +- Align enumerators: + + $ pahole ZSTD_strategy + typedef enum { + ZSTD_fast = 0, + ZSTD_dfast = 1, + ZSTD_greedy = 2, + ZSTD_lazy = 3, + ZSTD_lazy2 = 4, + ZSTD_btlazy2 = 5, + ZSTD_btopt = 6, + ZSTD_btopt2 = 7, + } ZSTD_strategy; + $ + +- Workaround bugs in the generation of DWARF records for functions in some gcc + versions that were causing breakage in the encoding of BTF: + + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97060 "Missing DW_AT_declaration=1 in dwarf data" + +- Ignore zero-sized ELF symbols instead of erroring out. + +- Handle union forward declaration properly in the BTF loader. + +- Introduce --numeric_version for use in scripts and Makefiles: + + $ pahole --version + v1.19 + $ pahole --numeric_version + 119 + $ + + To avoid things like this in the kernel's scripts/link-vmlinux.sh: + + pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/') + +- Try sole pfunct argument as a function name, just like pahole with type names: + + $ pfunct tcp_v4_rcv + int tcp_v4_rcv(struct sk_buff * skb); + $ + +- Speed up pfunct using some of the load techniques used in pahole. + +- Discard CUs after BTF encoding as they're not used anymore, greatly reducing + memory usage and speeding up vmlinux BTF encoding. + +- Revamp how per-CPU variables are encoded in BTF. + +- Include BTF info for static functions. + +- Use BTF's string APIs for strings management, greatly improving performance + over the tsearch(). + +- Increase size of DWARF lookup hash table, shaving off about 1 second out of + about 20 seconds total for Linux BTF dedup. + +- Stop BTF encoding when errors are found in some DWARF CU. + +- Implement --packed, to show just packed structures, for instance, here are + the top 5 packed data structures in the Linux kernel: + + $ pahole --sizes --packed | sort -k2 -nr | head -5 + e820_table 64004 0 + boot_params 4096 0 + efi_variable 2084 0 + snd_soc_tplg_pcm 912 0 + ntb_info_regs 800 0 + $ + + And here is one of them: + + $ pahole efi_variable + struct efi_variable { + efi_char16_t VariableName[512]; /* 0 1024 */ + /* --- cacheline 16 boundary (1024 bytes) --- */ + efi_guid_t VendorGuid; /* 1024 16 */ + long unsigned int DataSize; /* 1040 8 */ + __u8 Data[1024]; /* 1048 1024 */ + /* --- cacheline 32 boundary (2048 bytes) was 24 bytes ago --- */ + efi_status_t Status; /* 2072 8 */ + __u32 Attributes; /* 2080 4 */ + + /* size: 2084, cachelines: 33, members: 6 */ + /* last cacheline: 36 bytes */ + } __attribute__((__packed__)); + $ + +- Fix bug in distros such as OpenSUSE:15.2 where DW_AT_alignment isn't defined. + +Signed-off-by: Arnaldo Carvalho de Melo diff -Nru dwarves-dfsg-1.10/changes-v1.20 dwarves-dfsg-1.21/changes-v1.20 --- dwarves-dfsg-1.10/changes-v1.20 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/changes-v1.20 2021-03-07 13:51:27.000000000 +0000 @@ -0,0 +1,66 @@ +BTF encoder: + + - Improve ELF error reporting using elf_errmsg(elf_errno()). + + - Improve objcopy error handling. + + - Fix handling of 'restrict' qualifier, that was being treated as a 'const'. + + - Support SHN_XINDEX in st_shndx symbol indexes, to handle ELF objects with + more than 65534 sections, for instance, which happens with kernels built + with 'KCFLAGS="-ffunction-sections -fdata-sections", Other cases may + include when using FG-ASLR, LTO. + + - Cope with functions without a name, as seen sometimes when building kernel + images with some versions of clang, when a SEGFAULT was taking place. + + - Fix BTF variable generation for kernel modules, not skipping variables at + offset zero. + + - Fix address size to match what is in the ELF file being processed, to fix using + a 64-bit pahole binary to generate BTF for a 32-bit vmlinux image. + + - Use kernel module ftrace addresses when finding which functions to encode, + which increases the number of functions encoded. + +libbpf: + + - Allow use of packaged version, for distros wanting to dynamically link with + the system's libbpf package instead of using the libbpf git submodule shipped + in pahole's source code. + +DWARF loader: + + - Support DW_AT_data_bit_offset + + This appeared in DWARF4 but is supported only in gcc's -gdwarf-5, + support it in a way that makes the output be the same for both cases. + + $ gcc -gdwarf-5 -c examples/dwarf5/bf.c + $ pahole bf.o + struct pea { + long int a:1; /* 0: 0 8 */ + long int b:1; /* 0: 1 8 */ + long int c:1; /* 0: 2 8 */ + + /* XXX 29 bits hole, try to pack */ + /* Bitfield combined with next fields */ + + int after_bitfield; /* 4 4 */ + + /* size: 8, cachelines: 1, members: 4 */ + /* sum members: 4 */ + /* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */ + /* last cacheline: 8 bytes */ + }; + + - DW_FORM_implicit_const in attr_numeric() and attr_offset() + + - Support DW_TAG_GNU_call_site, its the standardized rename of the previously supported + DW_TAG_GNU_call_site. + +build: + + - Fix compilation on 32-bit architectures. + +Signed-off-by: Arnaldo Carvalho de Melo diff -Nru dwarves-dfsg-1.10/changes-v1.21 dwarves-dfsg-1.21/changes-v1.21 --- dwarves-dfsg-1.10/changes-v1.21 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/changes-v1.21 2021-04-09 22:38:15.000000000 +0000 @@ -0,0 +1,70 @@ +DWARF loader: + +- Handle DWARF5 DW_OP_addrx properly + + Part of the effort to support the subset of DWARF5 that is generated when building the kernel. + +- Handle subprogram ret type with abstract_origin properly + + Adds a second pass to resolve abstract origin DWARF description of functions to aid + the BTF encoder in getting the right return type. + +- Check .notes section for LTO build info + + When LTO is used, currently only with clang, we need to do extra steps to handle references + from one object (compile unit, aka CU) to another, a way for DWARF to avoid duplicating + information. + +- Check .debug_abbrev for cross-CU references + + When the kernel build process doesn't add an ELF note in vmlinux indicating that LTO was + used and thus intra-CU references are present and thus we need to use a more expensive + way to resolve types and (again) thus to encode BTF, we need to look at DWARF's .debug_abbrev + ELF section to figure out if such intra-CU references are present. + +- Permit merging all DWARF CU's for clang LTO built binary + + Allow not trowing away previously supposedly self contained compile units + (objects, aka CU, aka Compile Units) as they have type descriptions that will + be used in later CUs. + +- Permit a flexible HASHTAGS__BITS + + So that we can use a more expensive algorithm when we need to keep previously processed + compile units that will then be referenced by later ones to resolve types. + +- Use a better hashing function, from libbpf + + Enabling patch to combine compile units when using LTO. + +BTF encoder: + +- Add --btf_gen_all flag + + A new command line to allow asking for the generation of all BTF encodings, so that we + can stop adding new command line options to enable new encodings in the kernel Makefile. + +- Match ftrace addresses within ELF functions + + To cope with differences in how DWARF and ftrace describes function boundaries. + +- Funnel ELF error reporting through a macro + + To use libelf's elf_error() function, improving error messages. + +- Sanitize non-regular int base type + + Cope with clang with dwarf5 non-regular int base types, tricky stuff, see yhs + full explanation in the relevant cset. + +- Add support for the floating-point types + + S/390 has floats'n'doubles in its arch specific linux headers, cope with that. + +Pretty printer: + +- Honour conf_fprintf.hex when printing enumerations + + If the user specifies --hex in the command line, honour it when printing enumerations. + +Signed-off-by: Arnaldo Carvalho de Melo diff -Nru dwarves-dfsg-1.10/cmake/modules/FindDWARF.cmake dwarves-dfsg-1.21/cmake/modules/FindDWARF.cmake --- dwarves-dfsg-1.10/cmake/modules/FindDWARF.cmake 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/cmake/modules/FindDWARF.cmake 2020-02-03 07:42:13.000000000 +0000 @@ -37,14 +37,9 @@ PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 ~/usr/local/lib ~/usr/local/lib64 ) -find_library(EBL_LIBRARY - NAMES ebl - PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 ~/usr/local/lib ~/usr/local/lib64 -) - -if (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY AND EBL_LIBRARY) +if (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY) set(DWARF_FOUND TRUE) - set(DWARF_LIBRARIES ${DWARF_LIBRARY} ${ELF_LIBRARY} ${EBL_LIBRARY}) + set(DWARF_LIBRARIES ${DWARF_LIBRARY} ${ELF_LIBRARY}) set(CMAKE_REQUIRED_LIBRARIES ${DWARF_LIBRARIES}) # check if libdw have the dwfl_module_build_id routine, i.e. if it supports the buildid @@ -52,10 +47,10 @@ # in distributions such as fedora). We do it against libelf because, IIRC, some distros # include libdw linked statically into libelf. check_library_exists(elf dwfl_module_build_id "" HAVE_DWFL_MODULE_BUILD_ID) -else (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY AND EBL_LIBRARY) +else (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY) set(DWARF_FOUND FALSE) set(DWARF_LIBRARIES) -endif (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY AND EBL_LIBRARY) +endif (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY) if (DWARF_FOUND) if (NOT DWARF_FIND_QUIETLY) @@ -63,7 +58,6 @@ message(STATUS "Found elfutils/libdw.h header: ${LIBDW_INCLUDE_DIR}") message(STATUS "Found libdw library: ${DWARF_LIBRARY}") message(STATUS "Found libelf library: ${ELF_LIBRARY}") - message(STATUS "Found libebl library: ${EBL_LIBRARY}") endif (NOT DWARF_FIND_QUIETLY) else (DWARF_FOUND) if (DWARF_FIND_REQUIRED) @@ -73,9 +67,9 @@ find_path(FEDORA fedora-release /etc) find_path(REDHAT redhat-release /etc) if (FEDORA OR REDHAT) - if (NOT DWARF_INCLUDE_DIR OR NOT LIBDW_INCLUDE_DIR OR NOT EBL_LIBRARY) + if (NOT DWARF_INCLUDE_DIR OR NOT LIBDW_INCLUDE_DIR) message(STATUS "Please install the elfutils-devel package") - endif (NOT DWARF_INCLUDE_DIR OR NOT LIBDW_INCLUDE_DIR OR NOT EBL_LIBRARY) + endif (NOT DWARF_INCLUDE_DIR OR NOT LIBDW_INCLUDE_DIR) if (NOT DWARF_LIBRARY) message(STATUS "Please install the elfutils-libs package") endif (NOT DWARF_LIBRARY) @@ -89,9 +83,6 @@ if (NOT LIBDW_INCLUDE_DIR) message(STATUS "Could NOT find libdw include dir") endif (NOT LIBDW_INCLUDE_DIR) - if (NOT EBL_LIBRARY) - message(STATUS "Could NOT find libebl library") - endif (NOT EBL_LIBRARY) if (NOT DWARF_LIBRARY) message(STATUS "Could NOT find libdw library") endif (NOT DWARF_LIBRARY) @@ -103,7 +94,7 @@ endif (DWARF_FIND_REQUIRED) endif (DWARF_FOUND) -mark_as_advanced(DWARF_INCLUDE_DIR LIBDW_INCLUDE_DIR DWARF_LIBRARY ELF_LIBRARY EBL_LIBRARY) +mark_as_advanced(DWARF_INCLUDE_DIR LIBDW_INCLUDE_DIR DWARF_LIBRARY ELF_LIBRARY) include_directories(${DWARF_INCLUDE_DIR} ${LIBDW_INCLUDE_DIR}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h) diff -Nru dwarves-dfsg-1.10/CMakeLists.txt dwarves-dfsg-1.21/CMakeLists.txt --- dwarves-dfsg-1.10/CMakeLists.txt 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/CMakeLists.txt 2021-04-09 19:10:33.000000000 +0000 @@ -1,8 +1,10 @@ project(pahole C) -cmake_minimum_required(VERSION 2.4.8) +cmake_minimum_required(VERSION 2.8.12) cmake_policy(SET CMP0005 NEW) -INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi) # Try to parse this later, Helio just showed me a KDE4 example to support # x86-64 builds. @@ -27,18 +29,73 @@ FORCE) endif (NOT CMAKE_BUILD_TYPE) -add_definitions(-D_GNU_SOURCE -DDWARVES_VERSION="v1.9") +set(CMAKE_C_FLAGS_DEBUG "-Wall -Werror -ggdb -O0") +set(CMAKE_C_FLAGS_RELEASE "-Wall -O2") + +# Just for grepping, DWARVES_VERSION isn't used anywhere anymore +# add_definitions(-D_GNU_SOURCE -DDWARVES_VERSION="v1.21") +add_definitions(-D_GNU_SOURCE -DDWARVES_MAJOR_VERSION=1) +add_definitions(-D_GNU_SOURCE -DDWARVES_MINOR_VERSION=21) find_package(DWARF REQUIRED) find_package(ZLIB REQUIRED) +# make sure git submodule(s) are checked out +find_package(Git QUIET) +if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + # Update submodules as needed + option(GIT_SUBMODULE "Check submodules during build" ON) + if(GIT_SUBMODULE) + message(STATUS "Submodule update") + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_SUBMOD_RESULT) + if(NOT GIT_SUBMOD_RESULT EQUAL "0") + message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") + else() + message(STATUS "Submodule update - done") + endif() + endif() +endif() +if(NOT EXISTS "${PROJECT_SOURCE_DIR}/lib/bpf/src/btf.h") + message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") +endif() + _set_fancy(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${__LIB}" "libdir") +# libbpf uses reallocarray, which is not available in all versions of glibc +# libbpf's include/tools/libc_compat.h provides implementation, but needs +# COMPACT_NEED_REALLOCARRAY to be set +INCLUDE(CheckCSourceCompiles) +CHECK_C_SOURCE_COMPILES( +" +#define _GNU_SOURCE +#include +int main(void) +{ + return !!reallocarray(NULL, 1, 1); +} +" HAVE_REALLOCARRAY_SUPPORT) +if (NOT HAVE_REALLOCARRAY_SUPPORT) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCOMPAT_NEED_REALLOCARRAY") +endif() + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64") + +file(GLOB libbpf_sources "lib/bpf/src/*.c") +add_library(bpf OBJECT ${libbpf_sources}) +set_property(TARGET bpf PROPERTY POSITION_INDEPENDENT_CODE 1) +target_include_directories(bpf PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include + ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi) + set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer strings - ctf_encoder.c ctf_loader.c libctf.c dwarf_loader.c - dutil.c elf_symtab.c rbtree.c) -add_library(dwarves SHARED ${dwarves_LIB_SRCS}) + ctf_encoder.c ctf_loader.c libctf.c btf_encoder.c btf_loader.c libbtf.c + dwarf_loader.c dutil.c elf_symtab.c rbtree.c) +add_library(dwarves SHARED ${dwarves_LIB_SRCS} $) set_target_properties(dwarves PROPERTIES VERSION 1.0.0 SOVERSION 1) -set_target_properties(dwarves PROPERTIES LINK_INTERFACE_LIBRARIES "") +set_target_properties(dwarves PROPERTIES INTERFACE_LINK_LIBRARIES "") +target_include_directories(dwarves PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi) target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES}) set(dwarves_emit_LIB_SRCS dwarves_emit.c) @@ -75,7 +132,7 @@ add_executable(pglobal ${pglobal_SRCS}) target_link_libraries(pglobal dwarves) -set(pfunct_SRCS pfunct.c ) +set(pfunct_SRCS pfunct.c) add_executable(pfunct ${pfunct_SRCS}) target_link_libraries(pfunct dwarves dwarves_emit ${ELF_LIBRARY}) @@ -97,10 +154,13 @@ install(TARGETS dwarves LIBRARY DESTINATION ${LIB_INSTALL_DIR}) install(TARGETS dwarves dwarves_emit dwarves_reorganize LIBRARY DESTINATION ${LIB_INSTALL_DIR}) install(FILES dwarves.h dwarves_emit.h dwarves_reorganize.h - dutil.h gobuffer.h list.h rbtree.h strings.h + dutil.h gobuffer.h list.h rbtree.h pahole_strings.h + btf_encoder.h config.h ctf_encoder.h ctf.h + elfcreator.h elf_symtab.h hash.h libbtf.h libctf.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dwarves/) install(FILES man-pages/pahole.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1/) install(PROGRAMS ostra/ostra-cg DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) +install(PROGRAMS btfdiff fullcircle DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) install(FILES ostra/python/ostra.py DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dwarves/runtime/python) install(FILES lib/Makefile lib/ctracer_relay.c lib/ctracer_relay.h lib/linux.blacklist.cu DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dwarves/runtime) diff -Nru dwarves-dfsg-1.10/codiff.c dwarves-dfsg-1.21/codiff.c --- dwarves-dfsg-1.10/codiff.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/codiff.c 2019-12-13 14:40:33.000000000 +0000 @@ -1,10 +1,8 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include @@ -23,6 +21,7 @@ static int show_struct_diffs; static int show_function_diffs; static int verbose; +static int quiet; static int show_terse_type_changes; static struct conf_load conf_load = { @@ -58,16 +57,16 @@ const struct cu *cu, int32_t diff) { - struct diff_info *self = malloc(sizeof(*self)); + struct diff_info *dinfo = malloc(sizeof(*dinfo)); - if (self == NULL) { + if (dinfo == NULL) { puts("out of memory!"); exit(1); } - self->tag = twin; - self->cu = cu; - self->diff = diff; - return self; + dinfo->tag = twin; + dinfo->cu = cu; + dinfo->diff = diff; + return dinfo; } static void cu__check_max_len_changed_item(struct cu *cu, const char *name, @@ -183,21 +182,42 @@ return changes; } +static struct class_member *class__find_pair_member(const struct class *structure, const struct cu *cu, + const struct class_member *pair_member, const struct cu *pair_cu, + int *nr_anonymousp) +{ + const char *member_name = class_member__name(pair_member, pair_cu); + struct class_member *member; + + if (member_name) + return class__find_member_by_name(structure, cu, member_name); + + int nr_anonymous = ++*nr_anonymousp; + + /* Unnamed struct or union, lets look for the first unammed matchin tag.type */ + + type__for_each_member(&structure->type, member) { + if (member->tag.tag == pair_member->tag.tag && /* Both are class/union/struct (unnamed) */ + class_member__name(member, cu) == member_name && /* Both are NULL? */ + --nr_anonymous == 0) + return member; + } + + return NULL; +} + static int check_print_members_changes(const struct class *structure, const struct cu *cu, const struct class *new_structure, const struct cu *new_cu, int print) { - int changes = 0; + int changes = 0, nr_anonymous = 0; struct class_member *member; uint16_t nr_twins_found = 0; type__for_each_member(&structure->type, member) { - const char *member_name = class_member__name(member, cu); - struct class_member *twin = - class__find_member_by_name(new_structure, new_cu, - member_name); + struct class_member *twin = class__find_pair_member(new_structure, new_cu, member, cu, &nr_anonymous); if (twin != NULL) { twin->tag.visited = 1; ++nr_twins_found; @@ -219,7 +239,8 @@ } } - if (nr_twins_found == new_structure->type.nr_members) + if (nr_twins_found == (new_structure->type.nr_members + + new_structure->type.nr_static_members)) goto out; changes = 1; @@ -284,9 +305,17 @@ new_cu, diff); } +static struct cu *cus__find_pair(struct cus *cus, const char *name) +{ + if (cus->nr_entries == 1) + return list_first_entry(&cus->cus, struct cu, node); + + return cus__find_cu_by_name(cus, name); +} + static int cu_find_new_tags_iterator(struct cu *new_cu, void *old_cus) { - struct cu *old_cu = cus__find_cu_by_name(old_cus, new_cu->name); + struct cu *old_cu = cus__find_pair(old_cus, new_cu->name); if (old_cu != NULL && cu__same_build_id(old_cu, new_cu)) return 0; @@ -333,7 +362,7 @@ static int cu_diff_iterator(struct cu *cu, void *new_cus) { - struct cu *new_cu = cus__find_cu_by_name(new_cus, cu->name); + struct cu *new_cu = cus__find_pair(new_cus, cu->name); if (new_cu != NULL && cu__same_build_id(cu, new_cu)) return 0; @@ -427,21 +456,19 @@ const struct cu *new_cu) { struct class_member *member; + int nr_anonymous = 0; /* Find the removed ones */ type__for_each_member(&structure->type, member) { - struct class_member *twin = - class__find_member_by_name(new_structure, new_cu, - class_member__name(member, cu)); + struct class_member *twin = class__find_pair_member(new_structure, new_cu, member, cu, &nr_anonymous); if (twin == NULL) show_changed_member('-', member, cu); } + nr_anonymous = 0; /* Find the new ones */ type__for_each_member(&new_structure->type, member) { - struct class_member *twin = - class__find_member_by_name(structure, cu, - class_member__name(member, new_cu)); + struct class_member *twin = class__find_pair_member(structure, cu, member, new_cu, &nr_anonymous); if (twin == NULL) show_changed_member('+', member, new_cu); } @@ -590,14 +617,17 @@ cu->nr_structures_changed == 0) return 0; - if (first_cu_printed) - putchar('\n'); - else + if (first_cu_printed) { + if (!quiet) + putchar('\n'); + } else { first_cu_printed = 1; + } ++total_cus_changed; - printf("%s:\n", cu->name); + if (!quiet) + printf("%s:\n", cu->name); uint32_t id; struct class *class; @@ -707,6 +737,11 @@ .doc = "show diffs details", }, { + .key = 'q', + .name = "quiet", + .doc = "Show only differences, no difference? No output", + }, + { .name = NULL, } }; @@ -720,6 +755,7 @@ case 's': show_struct_diffs = 1; break; case 't': show_terse_type_changes = 1; break; case 'V': verbose = 1; break; + case 'q': quiet = 1; break; default: return ARGP_ERR_UNKNOWN; } return 0; @@ -737,7 +773,6 @@ { int remaining, err, rc = EXIT_FAILURE; char *old_filename, *new_filename; - char *filenames[2]; struct stat st; if (argp_parse(&codiff__argp, argc, argv, 0, &remaining, NULL) || @@ -776,8 +811,6 @@ goto out_cus_delete; } - filenames[1] = NULL; - /* If old_file is a character device, leave its cus empty */ if (!S_ISCHR(st.st_mode)) { err = cus__load_file(old_cus, &conf_load, old_filename); @@ -804,7 +837,8 @@ cus__for_each_cu(old_cus, cu_diff_iterator, new_cus, NULL); cus__for_each_cu(new_cus, cu_find_new_tags_iterator, old_cus, NULL); cus__for_each_cu(old_cus, cu_show_diffs_iterator, NULL, NULL); - cus__for_each_cu(new_cus, cu_show_diffs_iterator, (void *)1, NULL); + if (new_cus->nr_entries > 1) + cus__for_each_cu(new_cus, cu_show_diffs_iterator, (void *)1, NULL); if (total_cus_changed > 1) { if (show_function_diffs) diff -Nru dwarves-dfsg-1.10/COPYING dwarves-dfsg-1.21/COPYING --- dwarves-dfsg-1.10/COPYING 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/COPYING 2016-06-30 16:10:28.000000000 +0000 @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff -Nru dwarves-dfsg-1.10/ctf_encoder.c dwarves-dfsg-1.21/ctf_encoder.c --- dwarves-dfsg-1.10/ctf_encoder.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/ctf_encoder.c 2021-03-07 13:51:27.000000000 +0000 @@ -1,10 +1,8 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2009 Red Hat Inc. Copyright (C) 2009 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include "dwarves.h" @@ -12,13 +10,14 @@ #include "ctf.h" #include "hash.h" #include "elf_symtab.h" +#include -static int tag__check_id_drift(const struct tag *self, - uint16_t core_id, uint16_t ctf_id) +static int tag__check_id_drift(const struct tag *tag, + uint32_t core_id, uint32_t ctf_id) { if (ctf_id != core_id) { fprintf(stderr, "%s: %s id drift, core: %u, libctf: %d\n", - __func__, dwarf_tag_name(self->tag), core_id, ctf_id); + __func__, dwarf_tag_name(tag->tag), core_id, ctf_id); return -1; } return 0; @@ -38,61 +37,56 @@ return 0xffff; } -static int base_type__encode(struct tag *self, uint16_t core_id, - struct ctf *ctf) +static int base_type__encode(struct tag *tag, uint32_t core_id, struct ctf *ctf) { - struct base_type *bt = tag__base_type(self); - int ctf_id = ctf__add_base_type(ctf, bt->name, bt->bit_size); + struct base_type *bt = tag__base_type(tag); + uint32_t ctf_id = ctf__add_base_type(ctf, bt->name, bt->bit_size); - if (ctf_id < 0 || tag__check_id_drift(self, core_id, ctf_id)) + if (tag__check_id_drift(tag, core_id, ctf_id)) return -1; return 0; } -static int pointer_type__encode(struct tag *self, uint16_t core_id, - struct ctf *ctf) +static int pointer_type__encode(struct tag *tag, uint32_t core_id, struct ctf *ctf) { - int ctf_id = ctf__add_short_type(ctf, dwarf_to_ctf_type(self->tag), - self->type, 0); + uint32_t ctf_id = ctf__add_short_type(ctf, dwarf_to_ctf_type(tag->tag), tag->type, 0); - if (ctf_id < 0 || tag__check_id_drift(self, core_id, ctf_id)) + if (tag__check_id_drift(tag, core_id, ctf_id)) return -1; return 0; } -static int typedef__encode(struct tag *self, uint16_t core_id, struct ctf *ctf) +static int typedef__encode(struct tag *tag, uint32_t core_id, struct ctf *ctf) { - int ctf_id = ctf__add_short_type(ctf, CTF_TYPE_KIND_TYPDEF, self->type, - tag__namespace(self)->name); + uint32_t ctf_id = ctf__add_short_type(ctf, CTF_TYPE_KIND_TYPDEF, tag->type, tag__namespace(tag)->name); - if (ctf_id < 0 || tag__check_id_drift(self, core_id, ctf_id)) + if (tag__check_id_drift(tag, core_id, ctf_id)) return -1; return 0; } -static int fwd_decl__encode(struct tag *self, uint16_t core_id, struct ctf *ctf) +static int fwd_decl__encode(struct tag *tag, uint32_t core_id, struct ctf *ctf) { - int ctf_id = ctf__add_fwd_decl(ctf, tag__namespace(self)->name); + uint32_t ctf_id = ctf__add_fwd_decl(ctf, tag__namespace(tag)->name); - if (ctf_id < 0 || tag__check_id_drift(self, core_id, ctf_id)) + if (tag__check_id_drift(tag, core_id, ctf_id)) return -1; return 0; } -static int structure_type__encode(struct tag *self, uint16_t core_id, - struct ctf *ctf) +static int structure_type__encode(struct tag *tag, uint32_t core_id, struct ctf *ctf) { - struct type *type = tag__type(self); + struct type *type = tag__type(tag); int64_t position; - int ctf_id = ctf__add_struct(ctf, dwarf_to_ctf_type(self->tag), + uint32_t ctf_id = ctf__add_struct(ctf, dwarf_to_ctf_type(tag->tag), type->namespace.name, type->size, type->nr_members, &position); - if (ctf_id < 0 || tag__check_id_drift(self, core_id, ctf_id)) + if (tag__check_id_drift(tag, core_id, ctf_id)) return -1; const bool is_short = type->size < CTF_SHORT_MEMBER_LIMIT; @@ -109,11 +103,11 @@ return 0; } -static uint32_t array_type__nelems(struct tag *self) +static uint32_t array_type__nelems(struct tag *tag) { int i; uint32_t nelem = 1; - struct array_type *array = tag__array_type(self); + struct array_type *array = tag__array_type(tag); for (i = array->dimensions - 1; i >= 0; --i) nelem *= array->nr_entries[i]; @@ -121,28 +115,25 @@ return nelem; } -static int array_type__encode(struct tag *self, uint16_t core_id, - struct ctf *ctf) +static int array_type__encode(struct tag *tag, uint32_t core_id, struct ctf *ctf) { - const uint32_t nelems = array_type__nelems(self); - int ctf_id = ctf__add_array(ctf, self->type, 0, nelems); + const uint32_t nelems = array_type__nelems(tag); + uint32_t ctf_id = ctf__add_array(ctf, tag->type, 0, nelems); - if (ctf_id < 0 || tag__check_id_drift(self, core_id, ctf_id)) + if (tag__check_id_drift(tag, core_id, ctf_id)) return -1; return 0; } -static int subroutine_type__encode(struct tag *self, uint16_t core_id, - struct ctf *ctf) +static int subroutine_type__encode(struct tag *tag, uint32_t core_id, struct ctf *ctf) { struct parameter *pos; int64_t position; - struct ftype *ftype = tag__ftype(self); - int ctf_id = ctf__add_function_type(ctf, self->type, ftype->nr_parms, - ftype->unspec_parms, &position); + struct ftype *ftype = tag__ftype(tag); + uint32_t ctf_id = ctf__add_function_type(ctf, tag->type, ftype->nr_parms, ftype->unspec_parms, &position); - if (ctf_id < 0 || tag__check_id_drift(self, core_id, ctf_id)) + if (tag__check_id_drift(tag, core_id, ctf_id)) return -1; ftype__for_each_parameter(ftype, pos) @@ -151,16 +142,15 @@ return 0; } -static int enumeration_type__encode(struct tag *self, uint16_t core_id, - struct ctf *ctf) +static int enumeration_type__encode(struct tag *tag, uint32_t core_id, struct ctf *ctf) { - struct type *etype = tag__type(self); + struct type *etype = tag__type(tag); int64_t position; - int ctf_id = ctf__add_enumeration_type(ctf, etype->namespace.name, + uint32_t ctf_id = ctf__add_enumeration_type(ctf, etype->namespace.name, etype->size, etype->nr_members, &position); - if (ctf_id < 0 || tag__check_id_drift(self, core_id, ctf_id)) + if (tag__check_id_drift(tag, core_id, ctf_id)) return -1; struct enumerator *pos; @@ -170,37 +160,37 @@ return 0; } -static void tag__encode_ctf(struct tag *self, uint16_t core_id, struct ctf *ctf) +static void tag__encode_ctf(struct tag *tag, uint32_t core_id, struct ctf *ctf) { - switch (self->tag) { + switch (tag->tag) { case DW_TAG_base_type: - base_type__encode(self, core_id, ctf); + base_type__encode(tag, core_id, ctf); break; case DW_TAG_const_type: case DW_TAG_pointer_type: case DW_TAG_restrict_type: case DW_TAG_volatile_type: - pointer_type__encode(self, core_id, ctf); + pointer_type__encode(tag, core_id, ctf); break; case DW_TAG_typedef: - typedef__encode(self, core_id, ctf); + typedef__encode(tag, core_id, ctf); break; case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_class_type: - if (tag__type(self)->declaration) - fwd_decl__encode(self, core_id, ctf); + if (tag__type(tag)->declaration) + fwd_decl__encode(tag, core_id, ctf); else - structure_type__encode(self, core_id, ctf); + structure_type__encode(tag, core_id, ctf); break; case DW_TAG_array_type: - array_type__encode(self, core_id, ctf); + array_type__encode(tag, core_id, ctf); break; case DW_TAG_subroutine_type: - subroutine_type__encode(self, core_id, ctf); + subroutine_type__encode(tag, core_id, ctf); break; case DW_TAG_enumeration_type: - enumeration_type__encode(self, core_id, ctf); + enumeration_type__encode(tag, core_id, ctf); break; } } @@ -247,22 +237,22 @@ */ extern struct strings *strings; -int cu__encode_ctf(struct cu *self, int verbose) +int cu__encode_ctf(struct cu *cu, int verbose) { int err = -1; - struct ctf *ctf = ctf__new(self->filename, self->elf); + struct ctf *ctf = ctf__new(cu->filename, cu->elf); if (ctf == NULL) goto out; - if (cu__cache_symtab(self) < 0) + if (cu__cache_symtab(cu) < 0) goto out_delete; - ctf__set_strings(ctf, &strings->gb); + ctf__set_strings(ctf, strings); uint32_t id; struct tag *pos; - cu__for_each_type(self, id, pos) + cu__for_each_type(cu, id, pos) tag__encode_ctf(pos, id, ctf); struct hlist_head hash_addr[HASHADDR__SIZE]; @@ -271,7 +261,7 @@ INIT_HLIST_HEAD(&hash_addr[id]); struct function *function; - cu__for_each_function(self, id, function) { + cu__for_each_function(cu, id, function) { uint64_t addr = function->lexblock.ip.addr; struct hlist_head *head = &hash_addr[hashaddr__fn(addr)]; hlist_add_head(&function->tool_hnode, head); @@ -280,7 +270,7 @@ uint64_t addr; GElf_Sym sym; const char *sym_name; - cu__for_each_cached_symtab_entry(self, id, sym, sym_name) { + cu__for_each_cached_symtab_entry(cu, id, sym, sym_name) { if (ctf__ignore_symtab_function(&sym, sym_name)) continue; @@ -290,7 +280,7 @@ if (function == NULL) { if (verbose) fprintf(stderr, - "function %4d: %-20s %#Lx %5u NOT FOUND!\n", + "function %4d: %-20s %#" PRIx64 " %5u NOT FOUND!\n", id, sym_name, addr, elf_sym__size(&sym)); err = ctf__add_function(ctf, 0, 0, 0, &position); @@ -316,15 +306,15 @@ INIT_HLIST_HEAD(&hash_addr[id]); struct variable *var; - cu__for_each_variable(self, id, pos) { + cu__for_each_variable(cu, id, pos) { var = tag__variable(pos); - if (var->location != LOCATION_GLOBAL) + if (variable__scope(var) != VSCOPE_GLOBAL) continue; struct hlist_head *head = &hash_addr[hashaddr__fn(var->ip.addr)]; hlist_add_head(&var->tool_hnode, head); } - cu__for_each_cached_symtab_entry(self, id, sym, sym_name) { + cu__for_each_cached_symtab_entry(cu, id, sym, sym_name) { if (ctf__ignore_symtab_object(&sym, sym_name)) continue; addr = elf_sym__value(&sym); @@ -333,7 +323,7 @@ if (var == NULL) { if (verbose) fprintf(stderr, - "variable %4d: %-20s %#Lx %5u NOT FOUND!\n", + "variable %4d: %-20s %#" PRIx64 " %5u NOT FOUND!\n", id, sym_name, addr, elf_sym__size(&sym)); err = ctf__add_object(ctf, 0); diff -Nru dwarves-dfsg-1.10/ctf_encoder.h dwarves-dfsg-1.21/ctf_encoder.h --- dwarves-dfsg-1.10/ctf_encoder.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/ctf_encoder.h 2019-05-01 15:06:45.000000000 +0000 @@ -1,16 +1,14 @@ #ifndef _CTF_ENCODER_H_ #define _CTF_ENCODER_H_ 1 /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2009 Red Hat Inc. Copyright (C) 2009 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ struct cu; -int cu__encode_ctf(struct cu *self, int verbose); +int cu__encode_ctf(struct cu *cu, int verbose); #endif /* _CTF_ENCODER_H_ */ diff -Nru dwarves-dfsg-1.10/ctf.h dwarves-dfsg-1.21/ctf.h --- dwarves-dfsg-1.10/ctf.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/ctf.h 2019-05-01 15:06:45.000000000 +0000 @@ -1,5 +1,10 @@ #ifndef _CTF_H #define _CTF_H +/* + SPDX-License-Identifier: GPL-2.0-only + + Copyright (C) 2019 Arnaldo Carvalho de Melo + */ #include diff -Nru dwarves-dfsg-1.10/ctf_loader.c dwarves-dfsg-1.21/ctf_loader.c --- dwarves-dfsg-1.10/ctf_loader.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/ctf_loader.c 2020-09-18 21:26:21.000000000 +0000 @@ -32,15 +32,15 @@ static void *tag__alloc(const size_t size) { - struct tag *self = zalloc(size); + struct tag *tag = zalloc(size); - if (self != NULL) - self->top_level = 1; + if (tag != NULL) + tag->top_level = 1; - return self; + return tag; } -static int ctf__load_ftype(struct ctf *self, struct ftype *proto, uint16_t tag, +static int ctf__load_ftype(struct ctf *ctf, struct ftype *proto, uint16_t tag, uint16_t type, uint16_t vlen, uint16_t *args, long id) { proto->tag.tag = tag; @@ -49,7 +49,7 @@ int i; for (i = 0; i < vlen; i++) { - uint16_t type = ctf__get16(self, &args[i]); + uint16_t type = ctf__get16(ctf, &args[i]); if (type == 0) proto->unspec_parms = 1; @@ -59,7 +59,7 @@ if (p == NULL) goto out_free_parameters; p->tag.tag = DW_TAG_formal_parameter; - p->tag.type = ctf__get16(self, &args[i]); + p->tag.type = ctf__get16(ctf, &args[i]); ftype__add_parameter(proto, p); } } @@ -72,28 +72,34 @@ if (vlen & 0x2) vlen += 0x2; - cu__add_tag(self->priv, &proto->tag, &id); + if (id < 0) { + uint32_t type_id; + + cu__add_tag(ctf->priv, &proto->tag, &type_id); + } else { + cu__add_tag_with_id(ctf->priv, &proto->tag, id); + } return vlen; out_free_parameters: - ftype__delete(proto, self->priv); + ftype__delete(proto, ctf->priv); return -ENOMEM; } static struct function *function__new(uint16_t **ptr, GElf_Sym *sym, struct ctf *ctf) { - struct function *self = tag__alloc(sizeof(*self)); + struct function *func = tag__alloc(sizeof(*func)); - if (self != NULL) { - self->lexblock.ip.addr = elf_sym__value(sym); - self->lexblock.size = elf_sym__size(sym); - self->name = sym->st_name; - self->vtable_entry = -1; - self->external = elf_sym__bind(sym) == STB_GLOBAL; - INIT_LIST_HEAD(&self->vtable_node); - INIT_LIST_HEAD(&self->tool_node); - INIT_LIST_HEAD(&self->lexblock.tags); + if (func != NULL) { + func->lexblock.ip.addr = elf_sym__value(sym); + func->lexblock.size = elf_sym__size(sym); + func->name = sym->st_name; + func->vtable_entry = -1; + func->external = elf_sym__bind(sym) == STB_GLOBAL; + INIT_LIST_HEAD(&func->vtable_node); + INIT_LIST_HEAD(&func->tool_node); + INIT_LIST_HEAD(&func->lexblock.tags); uint16_t val = ctf__get16(ctf, *ptr); uint16_t tag = CTF_GET_KIND(val); @@ -112,7 +118,7 @@ ++*ptr; - if (ctf__load_ftype(ctf, &self->proto, DW_TAG_subprogram, + if (ctf__load_ftype(ctf, &func->proto, DW_TAG_subprogram, type, vlen, *ptr, id) < 0) return NULL; /* @@ -123,22 +129,22 @@ *ptr += vlen; } - return self; + return func; out_delete: - free(self); + free(func); return NULL; } -static int ctf__load_funcs(struct ctf *self) +static int ctf__load_funcs(struct ctf *ctf) { - struct ctf_header *hp = ctf__get_buffer(self); - uint16_t *func_ptr = (ctf__get_buffer(self) + sizeof(*hp) + - ctf__get32(self, &hp->ctf_func_off)); + struct ctf_header *hp = ctf__get_buffer(ctf); + uint16_t *func_ptr = (ctf__get_buffer(ctf) + sizeof(*hp) + + ctf__get32(ctf, &hp->ctf_func_off)); GElf_Sym sym; uint32_t idx; - ctf__for_each_symtab_function(self, idx, sym) - if (function__new(&func_ptr, &sym, self) == NULL) + ctf__for_each_symtab_function(ctf, idx, sym) + if (function__new(&func_ptr, &sym, ctf) == NULL) return -ENOMEM; return 0; @@ -147,89 +153,89 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs, uint8_t float_type, size_t size) { - struct base_type *self = tag__alloc(sizeof(*self)); + struct base_type *bt = tag__alloc(sizeof(*bt)); - if (self != NULL) { - self->name = name; - self->bit_size = size; - self->is_signed = attrs & CTF_TYPE_INT_SIGNED; - self->is_bool = attrs & CTF_TYPE_INT_BOOL; - self->is_varargs = attrs & CTF_TYPE_INT_VARARGS; - self->name_has_encoding = false; - self->float_type = float_type; + if (bt != NULL) { + bt->name = name; + bt->bit_size = size; + bt->is_signed = attrs & CTF_TYPE_INT_SIGNED; + bt->is_bool = attrs & CTF_TYPE_INT_BOOL; + bt->is_varargs = attrs & CTF_TYPE_INT_VARARGS; + bt->name_has_encoding = false; + bt->float_type = float_type; } - return self; + return bt; } -static void type__init(struct type *self, uint16_t tag, +static void type__init(struct type *type, uint16_t tag, strings_t name, size_t size) { - INIT_LIST_HEAD(&self->node); - INIT_LIST_HEAD(&self->namespace.tags); - self->size = size; - self->namespace.tag.tag = tag; - self->namespace.name = name; - self->namespace.sname = 0; + __type__init(type); + INIT_LIST_HEAD(&type->namespace.tags); + type->size = size; + type->namespace.tag.tag = tag; + type->namespace.name = name; + type->namespace.sname = 0; } static struct type *type__new(uint16_t tag, strings_t name, size_t size) { - struct type *self = tag__alloc(sizeof(*self)); + struct type *type = tag__alloc(sizeof(*type)); - if (self != NULL) - type__init(self, tag, name, size); + if (type != NULL) + type__init(type, tag, name, size); - return self; + return type; } static struct class *class__new(strings_t name, size_t size) { - struct class *self = tag__alloc(sizeof(*self)); + struct class *class = tag__alloc(sizeof(*class)); - if (self != NULL) { - type__init(&self->type, DW_TAG_structure_type, name, size); - INIT_LIST_HEAD(&self->vtable); + if (class != NULL) { + type__init(&class->type, DW_TAG_structure_type, name, size); + INIT_LIST_HEAD(&class->vtable); } - return self; + return class; } -static int create_new_base_type(struct ctf *self, void *ptr, - struct ctf_full_type *tp, long id) +static int create_new_base_type(struct ctf *ctf, void *ptr, + struct ctf_full_type *tp, uint32_t id) { uint32_t *enc = ptr; - uint32_t eval = ctf__get32(self, enc); + uint32_t eval = ctf__get32(ctf, enc); uint32_t attrs = CTF_TYPE_INT_ATTRS(eval); - strings_t name = ctf__get32(self, &tp->base.ctf_name); + strings_t name = ctf__get32(ctf, &tp->base.ctf_name); struct base_type *base = base_type__new(name, attrs, 0, CTF_TYPE_INT_BITS(eval)); if (base == NULL) return -ENOMEM; base->tag.tag = DW_TAG_base_type; - cu__add_tag(self->priv, &base->tag, &id); + cu__add_tag_with_id(ctf->priv, &base->tag, id); return sizeof(*enc); } -static int create_new_base_type_float(struct ctf *self, void *ptr, +static int create_new_base_type_float(struct ctf *ctf, void *ptr, struct ctf_full_type *tp, - long id) + uint32_t id) { - strings_t name = ctf__get32(self, &tp->base.ctf_name); - uint32_t *enc = ptr, eval = ctf__get32(self, enc); + strings_t name = ctf__get32(ctf, &tp->base.ctf_name); + uint32_t *enc = ptr, eval = ctf__get32(ctf, enc); struct base_type *base = base_type__new(name, 0, eval, CTF_TYPE_FP_BITS(eval)); if (base == NULL) return -ENOMEM; base->tag.tag = DW_TAG_base_type; - cu__add_tag(self->priv, &base->tag, &id); + cu__add_tag_with_id(ctf->priv, &base->tag, id); return sizeof(*enc); } -static int create_new_array(struct ctf *self, void *ptr, long id) +static int create_new_array(struct ctf *ctf, void *ptr, uint32_t id) { struct ctf_array *ap = ptr; struct array_type *array = tag__alloc(sizeof(*array)); @@ -247,32 +253,32 @@ return -ENOMEM; } - array->nr_entries[0] = ctf__get32(self, &ap->ctf_array_nelems); + array->nr_entries[0] = ctf__get32(ctf, &ap->ctf_array_nelems); array->tag.tag = DW_TAG_array_type; - array->tag.type = ctf__get16(self, &ap->ctf_array_type); + array->tag.type = ctf__get16(ctf, &ap->ctf_array_type); - cu__add_tag(self->priv, &array->tag, &id); + cu__add_tag_with_id(ctf->priv, &array->tag, id); return sizeof(*ap); } -static int create_new_subroutine_type(struct ctf *self, void *ptr, +static int create_new_subroutine_type(struct ctf *ctf, void *ptr, int vlen, struct ctf_full_type *tp, - long id) + uint32_t id) { uint16_t *args = ptr; - unsigned int type = ctf__get16(self, &tp->base.ctf_type); + unsigned int type = ctf__get16(ctf, &tp->base.ctf_type); struct ftype *proto = tag__alloc(sizeof(*proto)); if (proto == NULL) return -ENOMEM; - vlen = ctf__load_ftype(self, proto, DW_TAG_subroutine_type, + vlen = ctf__load_ftype(ctf, proto, DW_TAG_subroutine_type, type, vlen, args, id); return vlen < 0 ? -ENOMEM : vlen; } -static int create_full_members(struct ctf *self, void *ptr, +static int create_full_members(struct ctf *ctf, void *ptr, int vlen, struct type *class) { struct ctf_full_member *mp = ptr; @@ -285,10 +291,10 @@ return -ENOMEM; member->tag.tag = DW_TAG_member; - member->tag.type = ctf__get16(self, &mp[i].ctf_member_type); - member->name = ctf__get32(self, &mp[i].ctf_member_name); - member->bit_offset = (ctf__get32(self, &mp[i].ctf_member_offset_high) << 16) | - ctf__get32(self, &mp[i].ctf_member_offset_low); + member->tag.type = ctf__get16(ctf, &mp[i].ctf_member_type); + member->name = ctf__get32(ctf, &mp[i].ctf_member_name); + member->bit_offset = (ctf__get32(ctf, &mp[i].ctf_member_offset_high) << 16) | + ctf__get32(ctf, &mp[i].ctf_member_offset_low); /* sizes and offsets will be corrected at class__fixup_ctf_bitfields */ type__add_member(class, member); } @@ -296,7 +302,7 @@ return sizeof(*mp); } -static int create_short_members(struct ctf *self, void *ptr, +static int create_short_members(struct ctf *ctf, void *ptr, int vlen, struct type *class) { struct ctf_short_member *mp = ptr; @@ -309,9 +315,9 @@ return -ENOMEM; member->tag.tag = DW_TAG_member; - member->tag.type = ctf__get16(self, &mp[i].ctf_member_type); - member->name = ctf__get32(self, &mp[i].ctf_member_name); - member->bit_offset = ctf__get16(self, &mp[i].ctf_member_offset); + member->tag.type = ctf__get16(ctf, &mp[i].ctf_member_type); + member->name = ctf__get32(ctf, &mp[i].ctf_member_name); + member->bit_offset = ctf__get16(ctf, &mp[i].ctf_member_offset); /* sizes and offsets will be corrected at class__fixup_ctf_bitfields */ type__add_member(class, member); @@ -320,77 +326,77 @@ return sizeof(*mp); } -static int create_new_class(struct ctf *self, void *ptr, +static int create_new_class(struct ctf *ctf, void *ptr, int vlen, struct ctf_full_type *tp, - uint64_t size, long id) + uint64_t size, uint32_t id) { int member_size; - strings_t name = ctf__get32(self, &tp->base.ctf_name); + strings_t name = ctf__get32(ctf, &tp->base.ctf_name); struct class *class = class__new(name, size); if (size >= CTF_SHORT_MEMBER_LIMIT) { - member_size = create_full_members(self, ptr, vlen, &class->type); + member_size = create_full_members(ctf, ptr, vlen, &class->type); } else { - member_size = create_short_members(self, ptr, vlen, &class->type); + member_size = create_short_members(ctf, ptr, vlen, &class->type); } if (member_size < 0) goto out_free; - cu__add_tag(self->priv, &class->type.namespace.tag, &id); + cu__add_tag_with_id(ctf->priv, &class->type.namespace.tag, id); return (vlen * member_size); out_free: - class__delete(class, self->priv); + class__delete(class, ctf->priv); return -ENOMEM; } -static int create_new_union(struct ctf *self, void *ptr, +static int create_new_union(struct ctf *ctf, void *ptr, int vlen, struct ctf_full_type *tp, - uint64_t size, long id) + uint64_t size, uint32_t id) { int member_size; - strings_t name = ctf__get32(self, &tp->base.ctf_name); + strings_t name = ctf__get32(ctf, &tp->base.ctf_name); struct type *un = type__new(DW_TAG_union_type, name, size); if (size >= CTF_SHORT_MEMBER_LIMIT) { - member_size = create_full_members(self, ptr, vlen, un); + member_size = create_full_members(ctf, ptr, vlen, un); } else { - member_size = create_short_members(self, ptr, vlen, un); + member_size = create_short_members(ctf, ptr, vlen, un); } if (member_size < 0) goto out_free; - cu__add_tag(self->priv, &un->namespace.tag, &id); + cu__add_tag_with_id(ctf->priv, &un->namespace.tag, id); return (vlen * member_size); out_free: - type__delete(un, self->priv); + type__delete(un, ctf->priv); return -ENOMEM; } static struct enumerator *enumerator__new(strings_t name, uint32_t value) { - struct enumerator *self = tag__alloc(sizeof(*self)); + struct enumerator *en = tag__alloc(sizeof(*en)); - if (self != NULL) { - self->name = name; - self->value = value; - self->tag.tag = DW_TAG_enumerator; + if (en != NULL) { + en->name = name; + en->value = value; + en->tag.tag = DW_TAG_enumerator; } - return self; + return en; } -static int create_new_enumeration(struct ctf *self, void *ptr, +static int create_new_enumeration(struct ctf *ctf, void *ptr, int vlen, struct ctf_full_type *tp, - uint16_t size, long id) + uint16_t size, uint32_t id) { struct ctf_enum *ep = ptr; uint16_t i; struct type *enumeration = type__new(DW_TAG_enumeration_type, - ctf__get32(self, + ctf__get32(ctf, &tp->base.ctf_name), size ?: (sizeof(int) * 8)); @@ -398,8 +404,8 @@ return -ENOMEM; for (i = 0; i < vlen; i++) { - strings_t name = ctf__get32(self, &ep[i].ctf_enum_name); - uint32_t value = ctf__get32(self, &ep[i].ctf_enum_val); + strings_t name = ctf__get32(ctf, &ep[i].ctf_enum_name); + uint32_t value = ctf__get32(ctf, &ep[i].ctf_enum_val); struct enumerator *enumerator = enumerator__new(name, value); if (enumerator == NULL) @@ -408,47 +414,47 @@ enumeration__add(enumeration, enumerator); } - cu__add_tag(self->priv, &enumeration->namespace.tag, &id); + cu__add_tag_with_id(ctf->priv, &enumeration->namespace.tag, id); return (vlen * sizeof(*ep)); out_free: - enumeration__delete(enumeration, self->priv); + enumeration__delete(enumeration, ctf->priv); return -ENOMEM; } -static int create_new_forward_decl(struct ctf *self, struct ctf_full_type *tp, - uint64_t size, long id) +static int create_new_forward_decl(struct ctf *ctf, struct ctf_full_type *tp, + uint64_t size, uint32_t id) { - strings_t name = ctf__get32(self, &tp->base.ctf_name); + strings_t name = ctf__get32(ctf, &tp->base.ctf_name); struct class *fwd = class__new(name, size); if (fwd == NULL) return -ENOMEM; fwd->type.declaration = 1; - cu__add_tag(self->priv, &fwd->type.namespace.tag, &id); + cu__add_tag_with_id(ctf->priv, &fwd->type.namespace.tag, id); return 0; } -static int create_new_typedef(struct ctf *self, struct ctf_full_type *tp, - uint64_t size, long id) +static int create_new_typedef(struct ctf *ctf, struct ctf_full_type *tp, + uint64_t size, uint32_t id) { - strings_t name = ctf__get32(self, &tp->base.ctf_name); - unsigned int type_id = ctf__get16(self, &tp->base.ctf_type); + strings_t name = ctf__get32(ctf, &tp->base.ctf_name); + unsigned int type_id = ctf__get16(ctf, &tp->base.ctf_type); struct type *type = type__new(DW_TAG_typedef, name, size); if (type == NULL) return -ENOMEM; type->namespace.tag.type = type_id; - cu__add_tag(self->priv, &type->namespace.tag, &id); + cu__add_tag_with_id(ctf->priv, &type->namespace.tag, id); return 0; } -static int create_new_tag(struct ctf *self, int type, - struct ctf_full_type *tp, long id) +static int create_new_tag(struct ctf *ctf, int type, + struct ctf_full_type *tp, uint32_t id) { - unsigned int type_id = ctf__get16(self, &tp->base.ctf_type); + unsigned int type_id = ctf__get16(ctf, &tp->base.ctf_type); struct tag *tag = zalloc(sizeof(*tag)); if (tag == NULL) @@ -460,76 +466,75 @@ case CTF_TYPE_KIND_RESTRICT: tag->tag = DW_TAG_restrict_type; break; case CTF_TYPE_KIND_VOLATILE: tag->tag = DW_TAG_volatile_type; break; default: - printf("%s: FOO %d\n\n", __func__, type); + free(tag); + printf("%s: unknown type %d\n\n", __func__, type); return 0; } tag->type = type_id; - cu__add_tag(self->priv, tag, &id); + cu__add_tag_with_id(ctf->priv, tag, id); return 0; } -static int ctf__load_types(struct ctf *self) +static int ctf__load_types(struct ctf *ctf) { - void *ctf_buffer = ctf__get_buffer(self); + void *ctf_buffer = ctf__get_buffer(ctf); struct ctf_header *hp = ctf_buffer; void *ctf_contents = ctf_buffer + sizeof(*hp), - *type_section = (ctf_contents + - ctf__get32(self, &hp->ctf_type_off)), - *strings_section = (ctf_contents + - ctf__get32(self, &hp->ctf_str_off)); + *type_section = (ctf_contents + ctf__get32(ctf, &hp->ctf_type_off)), + *strings_section = (ctf_contents + ctf__get32(ctf, &hp->ctf_str_off)); struct ctf_full_type *type_ptr = type_section, *end = strings_section; - unsigned int type_index = 0x0001; + uint32_t type_index = 0x0001; if (hp->ctf_parent_name || hp->ctf_parent_label) type_index += 0x8000; while (type_ptr < end) { - uint16_t val = ctf__get16(self, &type_ptr->base.ctf_info); + uint16_t val = ctf__get16(ctf, &type_ptr->base.ctf_info); uint16_t type = CTF_GET_KIND(val); int vlen = CTF_GET_VLEN(val); void *ptr = type_ptr; - uint16_t base_size = ctf__get16(self, &type_ptr->base.ctf_size); + uint16_t base_size = ctf__get16(ctf, &type_ptr->base.ctf_size); uint64_t size = base_size; if (base_size == 0xffff) { - size = ctf__get32(self, &type_ptr->ctf_size_high); + size = ctf__get32(ctf, &type_ptr->ctf_size_high); size <<= 32; - size |= ctf__get32(self, &type_ptr->ctf_size_low); + size |= ctf__get32(ctf, &type_ptr->ctf_size_low); ptr += sizeof(struct ctf_full_type); } else ptr += sizeof(struct ctf_short_type); if (type == CTF_TYPE_KIND_INT) { - vlen = create_new_base_type(self, ptr, type_ptr, type_index); + vlen = create_new_base_type(ctf, ptr, type_ptr, type_index); } else if (type == CTF_TYPE_KIND_FLT) { - vlen = create_new_base_type_float(self, ptr, type_ptr, type_index); + vlen = create_new_base_type_float(ctf, ptr, type_ptr, type_index); } else if (type == CTF_TYPE_KIND_ARR) { - vlen = create_new_array(self, ptr, type_index); + vlen = create_new_array(ctf, ptr, type_index); } else if (type == CTF_TYPE_KIND_FUNC) { - vlen = create_new_subroutine_type(self, ptr, vlen, type_ptr, type_index); + vlen = create_new_subroutine_type(ctf, ptr, vlen, type_ptr, type_index); } else if (type == CTF_TYPE_KIND_STR) { - vlen = create_new_class(self, ptr, + vlen = create_new_class(ctf, ptr, vlen, type_ptr, size, type_index); } else if (type == CTF_TYPE_KIND_UNION) { - vlen = create_new_union(self, ptr, + vlen = create_new_union(ctf, ptr, vlen, type_ptr, size, type_index); } else if (type == CTF_TYPE_KIND_ENUM) { - vlen = create_new_enumeration(self, ptr, vlen, type_ptr, + vlen = create_new_enumeration(ctf, ptr, vlen, type_ptr, size, type_index); } else if (type == CTF_TYPE_KIND_FWD) { - vlen = create_new_forward_decl(self, type_ptr, size, type_index); + vlen = create_new_forward_decl(ctf, type_ptr, size, type_index); } else if (type == CTF_TYPE_KIND_TYPDEF) { - vlen = create_new_typedef(self, type_ptr, size, type_index); + vlen = create_new_typedef(ctf, type_ptr, size, type_index); } else if (type == CTF_TYPE_KIND_VOLATILE || type == CTF_TYPE_KIND_PTR || type == CTF_TYPE_KIND_CONST || type == CTF_TYPE_KIND_RESTRICT) { - vlen = create_new_tag(self, type, type_ptr, type_index); + vlen = create_new_tag(ctf, type, type_ptr, type_index); } else if (type == CTF_TYPE_KIND_UNKN) { - cu__table_nullify_type_entry(self->priv, type_index); + cu__table_nullify_type_entry(ctf->priv, type_index); fprintf(stderr, "CTF: idx: %d, off: %zd, root: %s Unknown\n", type_index, ((void *)type_ptr) - type_section, @@ -550,37 +555,37 @@ static struct variable *variable__new(uint16_t type, GElf_Sym *sym, struct ctf *ctf) { - struct variable *self = tag__alloc(sizeof(*self)); + struct variable *var = tag__alloc(sizeof(*var)); - if (self != NULL) { - self->location = LOCATION_GLOBAL; - self->ip.addr = elf_sym__value(sym); - self->name = sym->st_name; - self->external = elf_sym__bind(sym) == STB_GLOBAL; - self->ip.tag.tag = DW_TAG_variable; - self->ip.tag.type = type; - long id = -1; /* FIXME: not needed for variables... */ - cu__add_tag(ctf->priv, &self->ip.tag, &id); + if (var != NULL) { + var->scope = VSCOPE_GLOBAL; + var->ip.addr = elf_sym__value(sym); + var->name = sym->st_name; + var->external = elf_sym__bind(sym) == STB_GLOBAL; + var->ip.tag.tag = DW_TAG_variable; + var->ip.tag.type = type; + uint32_t id; /* FIXME: not needed for variables... */ + cu__add_tag(ctf->priv, &var->ip.tag, &id); } - return self; + return var; } -static int ctf__load_objects(struct ctf *self) +static int ctf__load_objects(struct ctf *ctf) { - struct ctf_header *hp = ctf__get_buffer(self); - uint16_t *objp = (ctf__get_buffer(self) + sizeof(*hp) + - ctf__get32(self, &hp->ctf_object_off)); + struct ctf_header *hp = ctf__get_buffer(ctf); + uint16_t *objp = (ctf__get_buffer(ctf) + sizeof(*hp) + + ctf__get32(ctf, &hp->ctf_object_off)); GElf_Sym sym; uint32_t idx; - ctf__for_each_symtab_object(self, idx, sym) { + ctf__for_each_symtab_object(ctf, idx, sym) { const uint16_t type = *objp; /* * Discard void objects, probably was an object * we didn't found DWARF info for when encoding. */ - if (type && variable__new(type, &sym, self) == NULL) + if (type && variable__new(type, &sym, ctf) == NULL) return -ENOMEM; ++objp; } @@ -588,28 +593,28 @@ return 0; } -static int ctf__load_sections(struct ctf *self) +static int ctf__load_sections(struct ctf *ctf) { - int err = ctf__load_symtab(self); + int err = ctf__load_symtab(ctf); if (err != 0) goto out; - err = ctf__load_funcs(self); + err = ctf__load_funcs(ctf); if (err == 0) - err = ctf__load_types(self); + err = ctf__load_types(ctf); if (err == 0) - err = ctf__load_objects(self); + err = ctf__load_objects(ctf); out: return err; } -static int class__fixup_ctf_bitfields(struct tag *self, struct cu *cu) +static int class__fixup_ctf_bitfields(struct tag *tag, struct cu *cu) { struct class_member *pos; - struct type *type_self = tag__type(self); + struct type *tag_type = tag__type(tag); - type__for_each_data_member(type_self, pos) { - struct tag *type = tag__follow_typedef(&pos->tag, cu); + type__for_each_data_member(tag_type, pos) { + struct tag *type = tag__strip_typedefs_and_modifiers(&pos->tag, cu); if (type == NULL) /* FIXME: C++ CTF... */ continue; @@ -671,14 +676,14 @@ return 0; } -static int cu__fixup_ctf_bitfields(struct cu *self) +static int cu__fixup_ctf_bitfields(struct cu *cu) { int err = 0; struct tag *pos; - list_for_each_entry(pos, &self->tags, node) + list_for_each_entry(pos, &cu->tags, node) if (tag__is_struct(pos) || tag__is_union(pos)) { - err = class__fixup_ctf_bitfields(pos, self); + err = class__fixup_ctf_bitfields(pos, cu); if (err) break; } @@ -686,36 +691,36 @@ return err; } -static const char *ctf__function_name(struct function *self, +static const char *ctf__function_name(struct function *func, const struct cu *cu) { struct ctf *ctf = cu->priv; - return ctf->symtab->symstrs->d_buf + self->name; + return ctf->symtab->symstrs->d_buf + func->name; } -static const char *ctf__variable_name(const struct variable *self, +static const char *ctf__variable_name(const struct variable *var, const struct cu *cu) { struct ctf *ctf = cu->priv; - return ctf->symtab->symstrs->d_buf + self->name; + return ctf->symtab->symstrs->d_buf + var->name; } -static void ctf__cu_delete(struct cu *self) +static void ctf__cu_delete(struct cu *cu) { - ctf__delete(self->priv); - self->priv = NULL; + ctf__delete(cu->priv); + cu->priv = NULL; } -static const char *ctf__strings_ptr(const struct cu *self, strings_t s) +static const char *ctf__strings_ptr(const struct cu *cu, strings_t s) { - return ctf__string(self->priv, s); + return ctf__string(cu->priv, s); } struct debug_fmt_ops ctf__ops; -int ctf__load_file(struct cus *self, struct conf_load *conf, +int ctf__load_file(struct cus *cus, struct conf_load *conf, const char *filename) { int err; @@ -730,6 +735,7 @@ cu->language = LANG_C; cu->uses_global_strings = false; + cu->little_endian = state->ehdr.e_ident[EI_DATA] == ELFDATA2LSB; cu->dfops = &ctf__ops; cu->priv = state; state->priv = cu; @@ -751,7 +757,7 @@ if (conf && conf->steal && conf->steal(cu, conf)) return 0; - cus__add(self, cu); + cus__add(cus, cu); return err; } diff -Nru dwarves-dfsg-1.10/ctracer.c dwarves-dfsg-1.21/ctracer.c --- dwarves-dfsg-1.10/ctracer.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/ctracer.c 2020-06-24 17:13:40.000000000 +0000 @@ -1,10 +1,8 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include @@ -109,14 +107,14 @@ static struct structure *structure__new(struct tag *class, struct cu *cu) { - struct structure *self = malloc(sizeof(*self)); + struct structure *st = malloc(sizeof(*st)); - if (self != NULL) { - self->class = class; - self->cu = cu; + if (st != NULL) { + st->class = class; + st->cu = cu; } - return self; + return st; } /* @@ -130,9 +128,9 @@ */ static LIST_HEAD(pointers); -static const char *structure__name(const struct structure *self) +static const char *structure__name(const struct structure *st) { - return class__name(tag__class(self->class), self->cu); + return class__name(tag__class(st->class), st->cu); } static struct structure *structures__find(struct list_head *list, const char *name) @@ -194,7 +192,7 @@ * a pointer to the specified "class" (a struct, unions can be added later). */ static struct function *function__filter(struct function *function, - struct cu *cu, uint16_t target_type_id) + struct cu *cu, type_id_t target_type_id) { if (function__inlined(function) || function->abstract_origin != 0 || @@ -214,7 +212,7 @@ */ static int cu_find_methods_iterator(struct cu *cu, void *cookie) { - uint16_t target_type_id; + type_id_t target_type_id; uint32_t function_id; struct function *function; struct tag *target = cu__find_struct_by_name(cu, cookie, 0, @@ -251,7 +249,7 @@ /* * Bitfields are removed as one for simplification right now. */ -static struct class_member *class__remove_member(struct class *self, const struct cu *cu, +static struct class_member *class__remove_member(struct class *class, const struct cu *cu, struct class_member *member) { size_t size = member->byte_size; @@ -260,29 +258,29 @@ uint16_t member_hole = member->hole; if (member->bitfield_size != 0) { - bitfield_tail = class_member__bitfield_tail(member, self); + bitfield_tail = class_member__bitfield_tail(member, class); member_hole = bitfield_tail->hole; } /* * Is this the first member? */ - if (member->tag.node.prev == class__tags(self)) { - self->type.size -= size + member_hole; - class__subtract_offsets_from(self, bitfield_tail ?: member, + if (member->tag.node.prev == class__tags(class)) { + class->type.size -= size + member_hole; + class__subtract_offsets_from(class, bitfield_tail ?: member, size + member_hole); /* * Is this the last member? */ - } else if (member->tag.node.next == class__tags(self)) { - if (size + self->padding >= cu->addr_size) { - self->type.size -= size + self->padding; - self->padding = 0; + } else if (member->tag.node.next == class__tags(class)) { + if (size + class->padding >= cu->addr_size) { + class->type.size -= size + class->padding; + class->padding = 0; } else - self->padding += size; + class->padding += size; } else { if (size + member_hole >= cu->addr_size) { - self->type.size -= size + member_hole; - class__subtract_offsets_from(self, + class->type.size -= size + member_hole; + class__subtract_offsets_from(class, bitfield_tail ?: member, size + member_hole); } else { @@ -291,18 +289,18 @@ struct class_member, tag.node); if (from_prev->hole == 0) - self->nr_holes++; + class->nr_holes++; from_prev->hole += size + member_hole; } } if (member_hole != 0) - self->nr_holes--; + class->nr_holes--; if (bitfield_tail != NULL) { next = bitfield_tail->tag.node.next; list_del_range(&member->tag.node, &bitfield_tail->tag.node); if (bitfield_tail->bit_hole != 0) - self->nr_bit_holes--; + class->nr_bit_holes--; } else { next = member->tag.node.next; list_del(&member->tag.node); @@ -311,13 +309,13 @@ return list_entry(next, struct class_member, tag.node); } -static size_t class__find_biggest_member_name(const struct class *self, +static size_t class__find_biggest_member_name(const struct class *class, const struct cu *cu) { struct class_member *pos; size_t biggest_name_len = 0; - type__for_each_data_member(&self->type, pos) { + type__for_each_data_member(&class->type, pos) { const size_t len = pos->name ? strlen(class_member__name(pos, cu)) : 0; @@ -328,7 +326,7 @@ return biggest_name_len; } -static void class__emit_class_state_collector(struct class *self, +static void class__emit_class_state_collector(struct class *class, const struct cu *cu, struct class *clone) { @@ -340,7 +338,7 @@ "{\n" "\tconst struct %s *obj = from;\n" "\tstruct %s *mini_obj = to;\n\n", - class__name(self, cu), class__name(clone, cu)); + class__name(class, cu), class__name(clone, cu)); type__for_each_data_member(&clone->type, pos) fprintf(fp_collector, "\tmini_obj->%-*s = obj->%s;\n", len, class_member__name(pos, cu), @@ -348,30 +346,13 @@ fputs("}\n\n", fp_collector); } -static int tag__is_base_type(const struct tag *self, const struct cu *cu) -{ - switch (self->tag) { - case DW_TAG_base_type: - return 1; - - case DW_TAG_typedef: { - const struct tag *type = cu__type(cu, self->type); - - if (type == NULL) - return 0; - return tag__is_base_type(type, cu); - } - } - return 0; -} - -static struct class *class__clone_base_types(const struct tag *tag_self, +static struct class *class__clone_base_types(const struct tag *tag, struct cu *cu, const char *new_class_name) { - struct class *self = tag__class(tag_self); + struct class *class = tag__class(tag); struct class_member *pos, *next; - struct class *clone = class__clone(self, new_class_name, cu); + struct class *clone = class__clone(class, new_class_name, cu); if (clone == NULL) return NULL; @@ -409,10 +390,10 @@ * ostra-cg to preprocess the raw data collected from the debugfs/relay * channel. */ -static int class__emit_ostra_converter(struct tag *tag_self, +static int class__emit_ostra_converter(struct tag *tag, const struct cu *cu) { - struct class *self = tag__class(tag_self); + struct class *class = tag__class(tag); struct class_member *pos; struct type *type = &mini_class->type; int field = 0, first = 1; @@ -422,7 +403,7 @@ size_t n; size_t plen = sizeof(parm_list); FILE *fp_fields, *fp_converter; - const char *name = class__name(self, cu); + const char *name = class__name(class, cu); snprintf(filename, sizeof(filename), "%s/%s.fields", src_dir, name); fp_fields = fopen(filename, "w"); @@ -501,7 +482,7 @@ * to the target class. */ static struct tag *pointer_filter(struct tag *tag, struct cu *cu, - uint16_t target_type_id) + type_id_t target_type_id) { struct type *type; struct class_member *pos; @@ -522,8 +503,7 @@ struct tag *ctype = cu__type(cu, pos->tag.type); tag__assert_search_result(ctype); - if (ctype->tag == DW_TAG_pointer_type && - ctype->type == target_type_id) + if (tag__is_pointer_to(ctype, target_type_id)) return tag; } @@ -536,7 +516,7 @@ */ static int cu_find_pointers_iterator(struct cu *cu, void *class_name) { - uint16_t target_type_id, id; + type_id_t target_type_id, id; struct tag *target = cu__find_struct_by_name(cu, class_name, 0, &target_type_id), *pos; @@ -560,7 +540,7 @@ * a struct of type target. */ static struct tag *alias_filter(struct tag *tag, const struct cu *cu, - uint16_t target_type_id) + type_id_t target_type_id) { struct type *type; struct class_member *first_member; @@ -591,7 +571,7 @@ */ static int cu_find_aliases_iterator(struct cu *cu, void *class_name) { - uint16_t target_type_id, id; + type_id_t target_type_id, id; struct tag *target = cu__find_struct_by_name(cu, class_name, 0, &target_type_id), *pos; if (target == NULL) @@ -651,22 +631,22 @@ } } -static int class__emit_classes(struct tag *tag_self, struct cu *cu) +static int class__emit_classes(struct tag *tag, struct cu *cu) { - struct class *self = tag__class(tag_self); + struct class *class = tag__class(tag); int err = -1; char mini_class_name[128]; snprintf(mini_class_name, sizeof(mini_class_name), "ctracer__mini_%s", - class__name(self, cu)); + class__name(class, cu)); - mini_class = class__clone_base_types(tag_self, cu, mini_class_name); + mini_class = class__clone_base_types(tag, cu, mini_class_name); if (mini_class == NULL) goto out; - type__emit_definitions(tag_self, cu, &emissions, fp_classes); + type__emit_definitions(tag, cu, &emissions, fp_classes); - type__emit(tag_self, cu, NULL, NULL, fp_classes); + type__emit(tag, cu, NULL, NULL, fp_classes); fputs("\n/* class aliases */\n\n", fp_classes); emit_list_of_types(&aliases, cu); @@ -675,9 +655,9 @@ emit_list_of_types(&pointers, cu); - class__fprintf(mini_class, cu, NULL, fp_classes); + class__fprintf(mini_class, cu, fp_classes); fputs(";\n\n", fp_classes); - class__emit_class_state_collector(self, cu, mini_class); + class__emit_class_state_collector(class, cu, mini_class); err = 0; out: return err; @@ -690,13 +670,13 @@ * This marks the function entry, function__emit_kretprobes will emit the * probe for the function exit. */ -static int function__emit_probes(struct function *self, uint32_t function_id, +static int function__emit_probes(struct function *func, uint32_t function_id, const struct cu *cu, - const uint16_t target_type_id, int probe_type, + const type_id_t target_type_id, int probe_type, const char *member) { struct parameter *pos; - const char *name = function__name(self, cu); + const char *name = function__name(func, cu); fprintf(fp_methods, "probe %s%s = kernel.function(\"%s@%s\")%s\n" "{\n" @@ -710,12 +690,11 @@ name, probe_type == 0 ? "" : "__return"); - list_for_each_entry(pos, &self->proto.parms, tag.node) { + list_for_each_entry(pos, &func->proto.parms, tag.node) { struct tag *type = cu__type(cu, pos->tag.type); tag__assert_search_result(type); - if (type->tag != DW_TAG_pointer_type || - type->type != target_type_id) + if (!tag__is_pointer_to(type, target_type_id)) continue; if (member != NULL) @@ -744,7 +723,7 @@ */ static int cu_emit_probes_iterator(struct cu *cu, void *cookie) { - uint16_t target_type_id; + type_id_t target_type_id; struct tag *target = cu__find_struct_by_name(cu, cookie, 0, &target_type_id); struct function *pos; @@ -770,7 +749,7 @@ */ static int cu_emit_pointer_probes_iterator(struct cu *cu, void *cookie) { - uint16_t target_type_id, pointer_id; + type_id_t target_type_id, pointer_id; struct tag *target, *pointer; struct function *pos_tag; struct class_member *pos_member; @@ -791,7 +770,7 @@ struct tag *ctype = cu__type(cu, pos_member->tag.type); tag__assert_search_result(ctype); - if (ctype->tag == DW_TAG_pointer_type && ctype->type == target_type_id) + if (tag__is_pointer_to(ctype, target_type_id)) break; } diff -Nru dwarves-dfsg-1.10/debian/changelog dwarves-dfsg-1.21/debian/changelog --- dwarves-dfsg-1.10/debian/changelog 2018-04-03 12:20:24.000000000 +0000 +++ dwarves-dfsg-1.21/debian/changelog 2021-09-20 12:10:02.000000000 +0000 @@ -1,8 +1,263 @@ -dwarves-dfsg (1.10-2.1build1) bionic; urgency=high +dwarves-dfsg (1.21-0ubuntu1~18.04) bionic; urgency=medium - * No change rebuild to pick up -fPIE compiler default + * Backport new dwarves-dfsg to stable series without upgrading libbpf + system-wide (LP: #1912811): + + Update lib/bpf to libbpf_0.4.0-1ubuntu1. + + Disable lto, since it is disabled in libbpf. + + Build with embedded libbpf. + + Drop libbpf-dev build dependency. + + Lower debhelper-compat to 11. + + Cherrypick patch from 1.22 that fixes FTBFS with old elfutils + + -- Dimitri John Ledkov Mon, 20 Sep 2021 13:10:02 +0100 + +dwarves-dfsg (1.21-0ubuntu1) impish; urgency=medium + + * New upstream release. Remaining changes: + - pahole: cherry-pick removal of the ftrace filter and its related + functions to prevent build errors with linux 5.13. + - build with libbpf 0.4, as will be required in the next release. + + -- Dimitri John Ledkov Wed, 16 Jun 2021 09:57:20 +0100 + +dwarves-dfsg (1.20-1ubuntu1) impish; urgency=medium + + * pahole: remove the ftrace filter and its related functions to prevent + build errors with linux 5.13 (LP: #1928244) + + -- Andrea Righi Wed, 12 May 2021 18:00:27 +0200 + +dwarves-dfsg (1.20-1) unstable; urgency=medium + + * New upstream release. + Changes since 1.19: + + BTF encoder: + - Improve ELF error reporting using elf_errmsg(elf_errno()). + - Improve objcopy error handling. + - Fix handling of 'restrict' qualifier, that was being treated + as a 'const'. + - Support SHN_XINDEX in st_shndx symbol indexes, to handle ELF + objects with more than 65534 sections, for instance, which + happens with kernels built with 'KCFLAGS="-ffunction-sections + -fdata-sections", Other cases may include when using FG-ASLR, LTO. + - Cope with functions without a name, as seen sometimes when + building kernel images with some versions of clang, when a + SEGFAULT was taking place. + - Fix BTF variable generation for kernel modules, not skipping + variables at offset zero. + - Fix address size to match what is in the ELF file being + processed, to fix using a 64-bit pahole binary to generate BTF + for a 32-bit vmlinux image. + - Use kernel module ftrace addresses when finding which functions + to encode, which increases the number of functions encoded. + DWARF loader: + - Support DW_AT_data_bit_offset + - DW_FORM_implicit_const in attr_numeric() and attr_offset() + - Support DW_TAG_GNU_call_site, its the standardized rename of + the previously supported DW_TAG_GNU_call_site. + build: + - Fix compilation on 32-bit architectures. + + * Refresh patches. + * Remove ctfdwdiff and README.cross so to reuse upstream tarball as-is. + * Update Standards-Version to 4.5.1 + * Update debhelper compatibility to 13: + - install missing binaries: btfdiff and fullcircle + * Add upstream metadata file + * gbp: set upstream tarball compression to xz + * Add lintian override for orig-tarball-missing-upstream-signature, + see #882694. + + -- Domenico Andreoli Sun, 07 Feb 2021 17:59:01 +0100 + +dwarves-dfsg (1.19-1) unstable; urgency=high + + * New upstream release. Closes: #978691. + Changes since 1.18: + - Support split BTF, where a main BTF file, vmlinux, can be used + to find types and then a kernel module, for instance, can have + just what is unique to it + - Update libbpf to get the split BTF support and use some of its + functions to load BTF and speed up DWARF loading and BTF encoding + - Support cross-compiled ELF binaries with different endianness + - Support showing typedefs for anonymous types, like structs, + unions and enums + - Align enumerators + - Workaround bugs in the generation of DWARF records for functions in + some gcc versions that were causing breakage in the encoding of BTF + - Ignore zero-sized ELF symbols instead of erroring out + - Handle union forward declaration properly in the BTF loader + - Introduce --numeric_version for use in scripts and Makefiles + - Try sole pfunct argument as a function name, just like pahole + with type names + - Speed up pfunct using some of the load techniques used in pahole + - Discard CUs after BTF encoding as they're not used anymore, + greatly reducing memory usage and speeding up vmlinux BTF encoding + - Revamp how per-CPU variables are encoded in BTF + - Include BTF info for static functions + - Use BTF's string APIs for strings management, greatly improving + performance over the tsearch() + - Increase size of DWARF lookup hash table, shaving off about 1 + second out of about 20 seconds total for Linux BTF dedup + - Stop BTF encoding when errors are found in some DWARF CU + - Implement --packed, to show just packed structures, for instance, + here are the top 5 packed data structures in the Linux kernel + - Fix bug in distros such as OpenSUSE:15.2 where DW_AT_alignment + isn't defined + + * Refresh patches. + + -- Domenico Andreoli Mon, 04 Jan 2021 23:33:54 +0100 + +dwarves-dfsg (1.18-1) unstable; urgency=medium + + [ Domenico Andreoli ] + * New upstream release (changes since 1.17): + - Use type information to pretty print raw data from stdin, all + documented in the man pages, further information in the csets. + - Store percpu variables in vmlinux BTF. This can be disabled when + debugging kernel features being developed to use it. + - pahole now should be segfault free when handling gdb test suit + DWARF files, including ADA, FORTRAN, rust and dwp compressed files, + the later being just flatly refused, that got left for v1.19. + - Bail out on partial units for now, avoiding segfaults and providing + warning to user, hopefully will be addressed in v1.19. + Closes: #977715. + * Update Homepage link. Closes: #978708. + * Drop debian/compat in favor of Build-Depends: debhelper-compat. + * Fix typo in pahole manual page. + * Fix escaping in pahole manual page. + * Fix debian/copyright lintian errors. + * Revert test to a superficial pahole --version until partial units + become supported. + + [ Luca Boccassi ] + * Use packaged libbpf instead of the statically linked. Closes: #979105. + + -- Domenico Andreoli Sun, 03 Jan 2021 13:41:31 +0100 + +dwarves-dfsg (1.17-1) unstable; urgency=low + + * New upstream release (changes since 1.16): + + BTF loader: + - Support raw BTF as available in /sys/kernel/btf/vmlinux. + + pahole: + - When the sole argument passed isn't a file, take it as a class name: + - Do not require a class name to operate without a file name. + - Make --find_pointers_to consider unions: + - Make --contains and --find_pointers_to honour --unions + - Add support for finding pointers to void: + - Make --contains and --find_pointers_to to work with base types: + - Make --contains look for more than just unions, structs: + - Consider unions when looking for classes containing some class: + - Introduce --unions to consider just unions: + - Fix -m/--nr_methods - Number of functions operating on a type pointer + + man-pages: + - Add section about --hex + -E to locate offsets deep into sub structs. + - Add more information about BTF. + - Add some examples. + + * Update to Standards-Version 4.5.0: + - Drop get-orig-source rules target + - Add Rules-Requires-Root: no + * Update debhelper compat to 12. + + -- Domenico Andreoli Sun, 19 Apr 2020 20:25:33 +0200 + +dwarves-dfsg (1.16-1) unstable; urgency=low + + * New upstream release (changes since 1.15): + - Preserve and encode exported functions as BTF_KIND_FUNC + - Add support for BTF_KIND_FUNC + - Account inline type __aligned__ member types for spacing + - Fix alignment of class members that are structs/enums/unions + - Fixup handling classes with no members, solving a NULL deref + - Avoid infinite loop trying to determine type with static data + member of its own type. + - type->type == 0 is void, fix --compile for that + - Print DW_TAG_subroutine_type as well + - Fix ptr_table__add_with_id() handling of pt->nr_entries, covering + how BTF variables IDs are encoded + - Allow passing the format path specifier, to use with BTF + - Fixup issues pointed out by various coverity reports + + -- Domenico Andreoli Wed, 15 Jan 2020 18:02:11 +0100 + +dwarves-dfsg (1.15-2) unstable; urgency=low + + * Fix hardening-no-bindnow. + * Fix debian-watch-uses-insecure-uri. + * Fix debian-watch-does-not-check-gpg-signature. + * Fix priority-extra-is-replaced-by-priority-optional. + * Revert to dwarves-dbgsym for tests execution but skip the test if + it's not installable (i.e. on transition to testing). + + -- Domenico Andreoli Mon, 23 Sep 2019 18:21:35 +0200 + +dwarves-dfsg (1.15-1) unstable; urgency=medium + + [ Theodore Y. Ts'o ] + * New upstream release (changes since 1.12, closes: #931142): + - Add support for BTF encoding which is a much more compact way + of encoding C type information. It is derived from CTF (Compact + C-Type format) and is designed for use with eBPF. + - Add initial support for the DWARF DW_TAG_partial_unit + - Improve support for pretty-printing unions + - Teach pahole to show where a struct was used, via the -I option + - Use the running kernel by default when no file name is passed + - Improve man pages + - Support new BTF deduplication algorithm found the Linux kernel's + libbpf library, which allows type information for the kernel to + be stored in roughly 1% of the space. + - Add a new utility, btfdiff, which compares the pretty-printed + type information between two kernel images. + - Teach pahole to use the BTF information to pretty print structures + using the BTF information using "pahole -F btf", which is much faster + than using the Dwarf information. + - Infer the __packed__ attribute for structures without alignment holes + and which violate the natural types' alignment requirements. + - Support DWARF5's DW_AT_alignment tag + - Add a --compile option to pfunct which produces compileable + output for function prototypes in an object file. + - Miscellaneous bug fixes + + [ Domenico Andreoli ] + * Autopkgtest on libc-bin-dbgsym instead of dwarves-dbgsym. Closes: #923717. + * Fix typo in description of no_shared_no_ebl. + + -- Domenico Andreoli Tue, 30 Jul 2019 16:58:55 +0200 + +dwarves-dfsg (1.12-2) unstable; urgency=medium + + * Convert to dh. + * Fix Homepage and Vcs-Git. + * Fix depends on debhelper >= 10. + * Remove trailing spaces from the Debian changelog. + * Update copyright to copyright-format/1.0. Closes: #919356. + + -- Domenico Andreoli Wed, 27 Feb 2019 18:09:08 +0100 + +dwarves-dfsg (1.12-1) unstable; urgency=medium + + [ Domenico Andreoli ] + * New upstram release. Closes: #908563, #779809, #693096, + * Migrate to salsa.d.o and enable CI. Closes: #908564. + * Migrate to DEP-14. + * Drop patch DW_TAG_mutable_type (merged upstream). + * Refresh patch no_shared_no_ebl. + * Improve package description. Closes: #914527. + * Add test executing pahole on itself. + * Set debhelper compatibility level to 10. + * Start using dh_strip_nondeterminism. - -- Balint Reczey Tue, 03 Apr 2018 12:20:24 +0000 + [ Helmut Grohne ] + * Let dh_auto_configure pass cross flags to cmake. Closes: #903506. + + -- Domenico Andreoli Mon, 19 Nov 2018 18:11:43 +0100 dwarves-dfsg (1.10-2.1) unstable; urgency=medium @@ -65,7 +320,7 @@ dwarves-dfsg (1.3-1.1ubuntu1) maverick; urgency=low * dwarwes-dfsg-1.3/src/dwarves.c: - + Add missing headers to fix undefined reference to `S_IS*' linker + + Add missing headers to fix undefined reference to `S_IS*' linker error with gcc 4.5 LP: #602367 -- Bhavani Shankar Tue, 06 Jul 2010 22:20:38 +0530 @@ -75,7 +330,7 @@ * Non-maintainer upload. * Applied patch by Peter Green (Closes: #534084) + cmake/modules/FindDWARF.cmake: Removed libebl support. - + debian/control (Build-Depends): Removed libebl-dev. + + debian/control (Build-Depends): Removed libebl-dev. -- Michael Banck Sun, 29 Nov 2009 12:45:58 +0100 diff -Nru dwarves-dfsg-1.10/debian/compat dwarves-dfsg-1.21/debian/compat --- dwarves-dfsg-1.10/debian/compat 2012-06-07 21:35:15.000000000 +0000 +++ dwarves-dfsg-1.21/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -7 diff -Nru dwarves-dfsg-1.10/debian/control dwarves-dfsg-1.21/debian/control --- dwarves-dfsg-1.10/debian/control 2018-04-03 12:20:25.000000000 +0000 +++ dwarves-dfsg-1.21/debian/control 2021-09-20 12:10:02.000000000 +0000 @@ -1,22 +1,23 @@ Source: dwarves-dfsg -Priority: extra +Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Thomas Girard Uploaders: Domenico Andreoli -Build-Depends: debhelper (>= 7), libelf-dev, libdw-dev (>= 0.141), cmake (>= 2.4.8), zlib1g-dev -Standards-Version: 3.9.3 +Build-Depends: debhelper-compat (= 11), cmake (>= 2.4.8), zlib1g-dev, libelf-dev, libdw-dev (>= 0.141), pkg-config, +Standards-Version: 4.5.1 +Rules-Requires-Root: no Section: utils -Vcs-Git: git://git.debian.org/collab-maint/pkg-dwarves.git -Vcs-Browser: http://git.debian.org/?p=collab-maint/pkg-dwarves.git;a=summary -Homepage: http://acmel.wordpress.com +Vcs-Browser: https://salsa.debian.org/debian/dwarves +Vcs-Git: https://salsa.debian.org/debian/dwarves.git +Homepage: https://git.kernel.org/pub/scm/devel/pahole/pahole.git Package: dwarves Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: set of advanced DWARF utilities This package contains tools that use the DWARF debugging information - inserted in ELF binaries by the compiler. This information is already - used by debuggers (e.g. GDB), and more recent tools such as systemtap. + inserted in ELF binaries by the compiler. This information is used by + debuggers (e.g. GDB), and other tools such as systemtap. . Utilities in the dwarves suite include: . diff -Nru dwarves-dfsg-1.10/debian/copyright dwarves-dfsg-1.21/debian/copyright --- dwarves-dfsg-1.10/debian/copyright 2012-06-07 21:35:15.000000000 +0000 +++ dwarves-dfsg-1.21/debian/copyright 2021-02-07 16:59:01.000000000 +0000 @@ -1,24 +1,148 @@ -This package was debianized by Domenico Andreoli on -Wed, 08 Aug 2007 04:02:11 +0200. - -It was downloaded from http://fedorapeople.org/~acme/dwarves - -Upstream Author: - - Arnaldo Carvalho de Melo - -Copyright: - - Copyright (C) 2005-2009 Arnaldo Carvalho de Melo - Copyright (C) 2006 Mandriva Conectiva S.A. - Copyright (C) 2008 David S. Miller - Copyright (C) 2007-2009 Red Hat Inc. - Copyright (C) 2007 Davi E. M. Arnaut - -License: - - GNU General Public License, version 2, found in - /usr/share/common-licenses/GPL-2 on Debian systems. - -The Debian packaging is Copyright (C) 2007, Domenico Andreoli -and is licensed under the GPL, see `/usr/share/common-licenses/GPL'. +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Contact: Arnaldo Carvalho de Melo +Source: https://git.kernel.org/pub/scm/devel/pahole/pahole.git/ + +Files: * +Copyright: 2006-2019 Arnaldo Carvalho de Melo +License: GPL-2.0-only + +Files: debian/* +Copyright: 2007-2019 Domenico Andreoli +Comment: package debianized by Domenico Andreoli on Wed, 08 Aug 2007 04:02:11 +0200. +License: GPL-2.0-only + +Files: ostra/ostra-cg ostra/python/ostra.py +Copyright: 2005, 2006, 2007 Arnaldo Carvalho de Melo +License: GPL-2.0-only + +Files: dwarves.c dwarves_emit.c dwarves_reorganize.c +Copyright: 2006 Arnaldo Carvalho de Melo + 2006 Mandriva Conectiva S.A. + 2007 Arnaldo Carvalho de Melo + 2007 Red Hat Inc. +License: GPL-2.0-only + +Files: codiff.c ctracer.c dtagnames.c prefcnt.c +Copyright: 2006 Arnaldo Carvalho de Melo + 2006 Mandriva Conectiva S.A. +License: GPL-2.0-only + +Files: pfunct.c +Copyright: 2006 Arnaldo Carvalho de Melo + 2006 Mandriva Conectiva S.A. + 2007 Arnaldo Carvalho de Melo +License: GPL-2.0-only + +Files: dwarves.h +Copyright: 2006..2009 Arnaldo Carvalho de Melo + 2006 Mandriva Conectiva S.A. +License: GPL-2.0-only + +Files: dutil.c config.h.cmake lib/ctracer_relay.c lib/ctracer_relay.h +Copyright: 2007 Arnaldo Carvalho de Melo +License: GPL-2.0-only + +Files: dwarves_emit.h dwarves_reorganize.h +Copyright: 2006 Arnaldo Carvalho de Melo + 2006 Mandriva Conectiva S.A. + 2007 Arnaldo Carvalho de Melo +License: GPL-2.0-only + +Files: pglobal.c +Copyright: 2007 Davi E. M. Arnaut +License: GPL-2.0-only + +Files: pahole.c +Copyright: 2006 Arnaldo Carvalho de Melo + 2006 Mandriva Conectiva S.A. + 2007-2008 Arnaldo Carvalho de Melo +License: GPL-2.0-only + +Files: dwarves_fprintf.c +Copyright: 2006 Arnaldo Carvalho de Melo + 2006 Mandriva Conectiva S.A. + 2007..2009 Arnaldo Carvalho de Melo + 2007..2009 Red Hat Inc. +License: GPL-2.0-only + +Files: dutil.h +Copyright: 2007..2009 Arnaldo Carvalho de Melo + Cast of dozens, comes from the Linux kernel +License: GPL-2.0-only + +Files: pdwtags.c syscse.c +Copyright: 2007-2016 Arnaldo Carvalho de Melo +License: GPL-2.0-only + +Files: gobuffer.c gobuffer.h strings.c pahole_strings.h +Copyright: 2008 Arnaldo Carvalho de Melo +License: GPL-2.0-only + +Files: ctf_loader.c +Copyright: 2008 David S. Miller +License: GPL-2.0-only + +Files: ctf_encoder.c ctf_encoder.h dwarf_loader.c elf_symtab.c elf_symtab.h +Copyright: 2009 Arnaldo Carvalho de Melo + 2009 Red Hat Inc. +License: GPL-2.0-only + +Files: scncopy.c elfcreator.c elfcreator.h +Copyright: 2009 Red Hat Inc. +License: GPL-2.0-only + +Files: regtest +Copyright: 2009 Arnaldo Carvalho de Melo +License: GPL-2.0-only + +Files: list.h +Copyright: Cast of dozens, comes from the Linux kernel +License: GPL-2.0-only + +Files: btf_encoder.c btf_encoder.h libbtf.c libbtf.h +Copyright: 2019 Facebook +License: GPL-2.0-only + +Files: ctf.h libctf.c libctf.h +Copyright: 2019 Arnaldo Carvalho de Melo +License: GPL-2.0-only + +Files: rbtree.c rbtree.h +Copyright: 1999 Andrea Arcangeli + 2002 David Woodhouse +License: GPL-2.0-or-later + +License: GPL-2.0-only + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + . + On Debian systems, the full text of the GNU General Public License + version 2 can be found in the file `/usr/share/common-licenses/GPL-2'. + +License: GPL-2.0-or-later + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + . + On Debian systems, the full text of the GNU General Public License + version 2 can be found in the file `/usr/share/common-licenses/GPL-2'. diff -Nru dwarves-dfsg-1.10/debian/dwarves.install dwarves-dfsg-1.21/debian/dwarves.install --- dwarves-dfsg-1.10/debian/dwarves.install 2012-06-07 21:35:15.000000000 +0000 +++ dwarves-dfsg-1.21/debian/dwarves.install 2021-02-07 16:59:01.000000000 +0000 @@ -1,6 +1,8 @@ -usr/bin/ctracer +usr/bin/btfdiff usr/bin/codiff +usr/bin/ctracer usr/bin/dtagnames +usr/bin/fullcircle usr/bin/pahole usr/bin/pdwtags usr/bin/pfunct @@ -8,5 +10,5 @@ usr/bin/prefcnt usr/bin/scncopy usr/bin/syscse -usr/share/man/man1/pahole.1 usr/share/dwarves/runtime +usr/share/man/man1/pahole.1 diff -Nru dwarves-dfsg-1.10/debian/gbp.conf dwarves-dfsg-1.21/debian/gbp.conf --- dwarves-dfsg-1.10/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/gbp.conf 2021-02-07 16:59:01.000000000 +0000 @@ -0,0 +1,8 @@ +[DEFAULT] +debian-branch = debian/master +upstream-branch = upstream/latest +pristine-tar = False +submodules = True + +[buildpackage] +compression = xz diff -Nru dwarves-dfsg-1.10/debian/patches/c9d4c106ab95cd8c13af4d29395d86c8f5d2f9ac.patch dwarves-dfsg-1.21/debian/patches/c9d4c106ab95cd8c13af4d29395d86c8f5d2f9ac.patch --- dwarves-dfsg-1.10/debian/patches/c9d4c106ab95cd8c13af4d29395d86c8f5d2f9ac.patch 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/patches/c9d4c106ab95cd8c13af4d29395d86c8f5d2f9ac.patch 2021-09-20 12:10:02.000000000 +0000 @@ -0,0 +1,28 @@ +From c9d4c106ab95cd8c13af4d29395d86c8f5d2f9ac Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Fri, 28 May 2021 13:09:57 -0300 +Subject: [PATCH] dwarf_loader: Add define for DW_OP_addrx + +To fix the build in systems where this isn't defined. + +Reported-by: Marcos Paulo de Souza +Signed-off-by: Arnaldo Carvalho de Melo +--- + dwarf_loader.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/dwarf_loader.c b/dwarf_loader.c +index 540addd..fc3b464 100644 +--- a/dwarf_loader.c ++++ b/dwarf_loader.c +@@ -49,6 +49,10 @@ struct strings *strings; + #define DW_FORM_implicit_const 0x21 + #endif + ++#ifndef DW_OP_addrx ++#define DW_OP_addrx 0xa1 ++#endif ++ + static uint32_t hashtags__bits = 15; + static uint32_t max_hashtags__bits = 21; + diff -Nru dwarves-dfsg-1.10/debian/patches/DW_TAG_mutable_type dwarves-dfsg-1.21/debian/patches/DW_TAG_mutable_type --- dwarves-dfsg-1.10/debian/patches/DW_TAG_mutable_type 2016-03-24 13:04:12.000000000 +0000 +++ dwarves-dfsg-1.21/debian/patches/DW_TAG_mutable_type 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -From: Mark Wielaard -Date: Wed, 18 Jun 2014 11:14:07 +0200 -Subject: dwarves_fprintf: DW_TAG_mutable_type doesn't exist. - -DW_TAG_mutable_type was a mistake in an early DWARFv3 draft and was -removed in the final version. - -http://dwarfstd.org/ShowIssue.php?issue=050223.1 - -Signed-off-by: Mark Wielaard -Signed-off-by: Arnaldo Carvalho de Melo - -Origin: upstream, http://git.kernel.org/cgit/devel/pahole/pahole.git/commit/?id=943a0de0679a34b5e630f85cd01cca35c0d0e544 -Bug-Ubuntu: https://launchpad.net/bugs/1378841 -Bug-Debian: https://bugs.debian.org/764484 -Last-Update: 2016-03-24 - -diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c -index 4d8e0f4..b746864 100644 ---- a/dwarves_fprintf.c -+++ b/dwarves_fprintf.c -@@ -75,7 +75,6 @@ static const char *dwarf_tag_names[] = { - [DW_TAG_unspecified_type] = "unspecified_type", - [DW_TAG_partial_unit] = "partial_unit", - [DW_TAG_imported_unit] = "imported_unit", -- [DW_TAG_mutable_type] = "mutable_type", - [DW_TAG_condition] = "condition", - [DW_TAG_shared_type] = "shared_type", - #ifdef STB_GNU_UNIQUE --- -cgit v0.10.1 - diff -Nru dwarves-dfsg-1.10/debian/patches/fix-escaping-in-manual-page dwarves-dfsg-1.21/debian/patches/fix-escaping-in-manual-page --- dwarves-dfsg-1.10/debian/patches/fix-escaping-in-manual-page 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/patches/fix-escaping-in-manual-page 2021-02-07 16:59:01.000000000 +0000 @@ -0,0 +1,20 @@ +Description: Fix escaping in the pahole manual page +Forwarded: https://github.com/acmel/dwarves/pull/17 + +--- + man-pages/pahole.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: b/man-pages/pahole.1 +=================================================================== +--- a/man-pages/pahole.1 ++++ b/man-pages/pahole.1 +@@ -736,7 +736,7 @@ $ pahole ~/bin/perf --header=perf_file_h + .size = 88, + }, + .id = 13, +- .path = "/machine.slice/machine-qemu\x2d1\x2drhel6.sandy.scope", ++ .path = "/machine.slice/machine-qemu\\x2d1\\x2drhel6.sandy.scope", + }, + $ + .fi diff -Nru dwarves-dfsg-1.10/debian/patches/fix-typo-in-manual-page dwarves-dfsg-1.21/debian/patches/fix-typo-in-manual-page --- dwarves-dfsg-1.10/debian/patches/fix-typo-in-manual-page 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/patches/fix-typo-in-manual-page 2021-02-07 16:59:01.000000000 +0000 @@ -0,0 +1,20 @@ +Description: Fix typo in the pahole manual page +Forwarded: https://github.com/acmel/dwarves/pull/17 + +--- + man-pages/pahole.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: b/man-pages/pahole.1 +=================================================================== +--- a/man-pages/pahole.1 ++++ b/man-pages/pahole.1 +@@ -749,7 +749,7 @@ $ pahole ~/bin/perf --header=perf_file_h + .P + This uses ~/bin/perf to get the type definitions, the defines 'struct perf_file_header' as the header, + then seeks '$header.data.offset' bytes from the start of the file, and considers '$header.data.size' bytes +-worth of such records. The filter expression may omit a common prefix, in this case it could additonally be ++worth of such records. The filter expression may omit a common prefix, in this case it could additionally be + equivalently written as both 'filter=type==CGROUP' or the 'filter=' can also be omitted, getting as compact + as 'type==CGROUP': + .P diff -Nru dwarves-dfsg-1.10/debian/patches/libbpf-0.4.0.patch dwarves-dfsg-1.21/debian/patches/libbpf-0.4.0.patch --- dwarves-dfsg-1.10/debian/patches/libbpf-0.4.0.patch 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/patches/libbpf-0.4.0.patch 2021-09-20 12:10:02.000000000 +0000 @@ -0,0 +1,8911 @@ +Description: Update lib/bpf to libbpf_0.4.0-1ubuntu1. +Author: Dimitri John Ledkov +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1912811 + + +Index: dwarves-dfsg-1.21/lib/bpf/.travis.yml +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/.travis.yml ++++ dwarves-dfsg-1.21/lib/bpf/.travis.yml +@@ -1,6 +1,6 @@ + sudo: required + language: bash +-dist: bionic ++dist: focal + services: + - docker + +@@ -36,19 +36,19 @@ stages: + jobs: + include: + - stage: Builds & Tests +- name: Kernel LATEST + selftests ++ name: Kernel 5.5.0 + selftests + language: bash +- env: KERNEL=LATEST ++ env: KERNEL=5.5.0 + script: $CI_ROOT/vmtest/run_vmtest.sh || travis_terminate 1 + +- - name: Kernel 4.9.0 + selftests ++ - name: Kernel LATEST + selftests + language: bash +- env: KERNEL=4.9.0 ++ env: KERNEL=LATEST + script: $CI_ROOT/vmtest/run_vmtest.sh || travis_terminate 1 + +- - name: Kernel 5.5.0 + selftests ++ - name: Kernel 4.9.0 + selftests + language: bash +- env: KERNEL=5.5.0 ++ env: KERNEL=4.9.0 + script: $CI_ROOT/vmtest/run_vmtest.sh || travis_terminate 1 + + - name: Debian Build +@@ -87,21 +87,21 @@ jobs: + script: $CI_ROOT/managers/debian.sh RUN_GCC10_ASAN || travis_terminate 1 + after_script: $CI_ROOT/managers/debian.sh CLEANUP + +- - name: Ubuntu Bionic Build ++ - name: Ubuntu Focal Build + language: bash + script: sudo $CI_ROOT/managers/ubuntu.sh || travis_terminate 1 + +- - name: Ubuntu Bionic Build (arm) ++ - name: Ubuntu Focal Build (arm) + arch: arm64 + language: bash + script: sudo $CI_ROOT/managers/ubuntu.sh || travis_terminate 1 + +- - name: Ubuntu Bionic Build (s390x) ++ - name: Ubuntu Focal Build (s390x) + arch: s390x + language: bash + script: sudo $CI_ROOT/managers/ubuntu.sh || travis_terminate 1 + +- - name: Ubuntu Bionic Build (ppc64le) ++ - name: Ubuntu Focal Build (ppc64le) + arch: ppc64le + language: bash + script: sudo $CI_ROOT/managers/ubuntu.sh || travis_terminate 1 +@@ -120,7 +120,7 @@ jobs: + - COVERITY_SCAN_BUILD_COMMAND_PREPEND="cd src/" + - COVERITY_SCAN_BUILD_COMMAND="make" + install: +- - sudo echo 'deb-src http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse' >>/etc/apt/sources.list ++ - sudo echo 'deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse' >>/etc/apt/sources.list + - sudo apt-get update + - sudo apt-get -y build-dep libelf-dev + - sudo apt-get install -y libelf-dev pkg-config +Index: dwarves-dfsg-1.21/lib/bpf/BPF-CHECKPOINT-COMMIT +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/BPF-CHECKPOINT-COMMIT ++++ dwarves-dfsg-1.21/lib/bpf/BPF-CHECKPOINT-COMMIT +@@ -1 +1 @@ +-22541a9eeb0d968c133aaebd95fa59da3208e705 ++d0c0fe10ce6d87734b65c18dc8f4bcae3f4dbea4 +Index: dwarves-dfsg-1.21/lib/bpf/CHECKPOINT-COMMIT +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/CHECKPOINT-COMMIT ++++ dwarves-dfsg-1.21/lib/bpf/CHECKPOINT-COMMIT +@@ -1 +1 @@ +-22541a9eeb0d968c133aaebd95fa59da3208e705 ++f18ba26da88a89db9b50cb4ff47fadb159f2810b +Index: dwarves-dfsg-1.21/lib/bpf/README.md +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/README.md ++++ dwarves-dfsg-1.21/lib/bpf/README.md +@@ -64,6 +64,7 @@ Distributions packaging libbpf from this + - [Debian](https://packages.debian.org/source/sid/libbpf) + - [Arch](https://www.archlinux.org/packages/extra/x86_64/libbpf/) + - [Ubuntu](https://packages.ubuntu.com/source/groovy/libbpf) ++ - [Alpine](https://pkgs.alpinelinux.org/packages?name=libbpf) + + Benefits of packaging from the mirror over packaging from kernel sources: + - Consistent versioning across distributions. +@@ -120,13 +121,14 @@ distributions have Clang/LLVM 10+ packag + - Arch Linux + - Ubuntu 20.10 (LLVM 11) + - Debian 11 (LLVM 11) ++ - Alpine 3.13+ + + Otherwise, please make sure to update it on your system. + + The following resources are useful to understand what BPF CO-RE is and how to + use it: +-- [BPF Portability and CO-RE](https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html) +-- [HOWTO: BCC to libbpf conversion](https://facebookmicrosites.github.io/bpf/blog/2020/02/20/bcc-to-libbpf-howto-guide.html) ++- [BPF Portability and CO-RE](https://nakryiko.com/posts/bpf-portability-and-co-re/) ++- [HOWTO: BCC to libbpf conversion](https://nakryiko.com/posts/bcc-to-libbpf-howto-guide/) + - [libbpf-tools in BCC repo](https://github.com/iovisor/bcc/tree/master/libbpf-tools) + contain lots of real-world tools converted from BCC to BPF CO-RE. Consider + converting some more to both contribute to the BPF community and gain some +Index: dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/bpf.h +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/include/uapi/linux/bpf.h ++++ dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/bpf.h +@@ -93,7 +93,738 @@ union bpf_iter_link_info { + } map; + }; + +-/* BPF syscall commands, see bpf(2) man-page for details. */ ++/* BPF syscall commands, see bpf(2) man-page for more details. */ ++/** ++ * DOC: eBPF Syscall Preamble ++ * ++ * The operation to be performed by the **bpf**\ () system call is determined ++ * by the *cmd* argument. Each operation takes an accompanying argument, ++ * provided via *attr*, which is a pointer to a union of type *bpf_attr* (see ++ * below). The size argument is the size of the union pointed to by *attr*. ++ */ ++/** ++ * DOC: eBPF Syscall Commands ++ * ++ * BPF_MAP_CREATE ++ * Description ++ * Create a map and return a file descriptor that refers to the ++ * map. The close-on-exec file descriptor flag (see **fcntl**\ (2)) ++ * is automatically enabled for the new file descriptor. ++ * ++ * Applying **close**\ (2) to the file descriptor returned by ++ * **BPF_MAP_CREATE** will delete the map (but see NOTES). ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_MAP_LOOKUP_ELEM ++ * Description ++ * Look up an element with a given *key* in the map referred to ++ * by the file descriptor *map_fd*. ++ * ++ * The *flags* argument may be specified as one of the ++ * following: ++ * ++ * **BPF_F_LOCK** ++ * Look up the value of a spin-locked map without ++ * returning the lock. This must be specified if the ++ * elements contain a spinlock. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_MAP_UPDATE_ELEM ++ * Description ++ * Create or update an element (key/value pair) in a specified map. ++ * ++ * The *flags* argument should be specified as one of the ++ * following: ++ * ++ * **BPF_ANY** ++ * Create a new element or update an existing element. ++ * **BPF_NOEXIST** ++ * Create a new element only if it did not exist. ++ * **BPF_EXIST** ++ * Update an existing element. ++ * **BPF_F_LOCK** ++ * Update a spin_lock-ed map element. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * May set *errno* to **EINVAL**, **EPERM**, **ENOMEM**, ++ * **E2BIG**, **EEXIST**, or **ENOENT**. ++ * ++ * **E2BIG** ++ * The number of elements in the map reached the ++ * *max_entries* limit specified at map creation time. ++ * **EEXIST** ++ * If *flags* specifies **BPF_NOEXIST** and the element ++ * with *key* already exists in the map. ++ * **ENOENT** ++ * If *flags* specifies **BPF_EXIST** and the element with ++ * *key* does not exist in the map. ++ * ++ * BPF_MAP_DELETE_ELEM ++ * Description ++ * Look up and delete an element by key in a specified map. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_MAP_GET_NEXT_KEY ++ * Description ++ * Look up an element by key in a specified map and return the key ++ * of the next element. Can be used to iterate over all elements ++ * in the map. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * The following cases can be used to iterate over all elements of ++ * the map: ++ * ++ * * If *key* is not found, the operation returns zero and sets ++ * the *next_key* pointer to the key of the first element. ++ * * If *key* is found, the operation returns zero and sets the ++ * *next_key* pointer to the key of the next element. ++ * * If *key* is the last element, returns -1 and *errno* is set ++ * to **ENOENT**. ++ * ++ * May set *errno* to **ENOMEM**, **EFAULT**, **EPERM**, or ++ * **EINVAL** on error. ++ * ++ * BPF_PROG_LOAD ++ * Description ++ * Verify and load an eBPF program, returning a new file ++ * descriptor associated with the program. ++ * ++ * Applying **close**\ (2) to the file descriptor returned by ++ * **BPF_PROG_LOAD** will unload the eBPF program (but see NOTES). ++ * ++ * The close-on-exec file descriptor flag (see **fcntl**\ (2)) is ++ * automatically enabled for the new file descriptor. ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_OBJ_PIN ++ * Description ++ * Pin an eBPF program or map referred by the specified *bpf_fd* ++ * to the provided *pathname* on the filesystem. ++ * ++ * The *pathname* argument must not contain a dot ("."). ++ * ++ * On success, *pathname* retains a reference to the eBPF object, ++ * preventing deallocation of the object when the original ++ * *bpf_fd* is closed. This allow the eBPF object to live beyond ++ * **close**\ (\ *bpf_fd*\ ), and hence the lifetime of the parent ++ * process. ++ * ++ * Applying **unlink**\ (2) or similar calls to the *pathname* ++ * unpins the object from the filesystem, removing the reference. ++ * If no other file descriptors or filesystem nodes refer to the ++ * same object, it will be deallocated (see NOTES). ++ * ++ * The filesystem type for the parent directory of *pathname* must ++ * be **BPF_FS_MAGIC**. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_OBJ_GET ++ * Description ++ * Open a file descriptor for the eBPF object pinned to the ++ * specified *pathname*. ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_PROG_ATTACH ++ * Description ++ * Attach an eBPF program to a *target_fd* at the specified ++ * *attach_type* hook. ++ * ++ * The *attach_type* specifies the eBPF attachment point to ++ * attach the program to, and must be one of *bpf_attach_type* ++ * (see below). ++ * ++ * The *attach_bpf_fd* must be a valid file descriptor for a ++ * loaded eBPF program of a cgroup, flow dissector, LIRC, sockmap ++ * or sock_ops type corresponding to the specified *attach_type*. ++ * ++ * The *target_fd* must be a valid file descriptor for a kernel ++ * object which depends on the attach type of *attach_bpf_fd*: ++ * ++ * **BPF_PROG_TYPE_CGROUP_DEVICE**, ++ * **BPF_PROG_TYPE_CGROUP_SKB**, ++ * **BPF_PROG_TYPE_CGROUP_SOCK**, ++ * **BPF_PROG_TYPE_CGROUP_SOCK_ADDR**, ++ * **BPF_PROG_TYPE_CGROUP_SOCKOPT**, ++ * **BPF_PROG_TYPE_CGROUP_SYSCTL**, ++ * **BPF_PROG_TYPE_SOCK_OPS** ++ * ++ * Control Group v2 hierarchy with the eBPF controller ++ * enabled. Requires the kernel to be compiled with ++ * **CONFIG_CGROUP_BPF**. ++ * ++ * **BPF_PROG_TYPE_FLOW_DISSECTOR** ++ * ++ * Network namespace (eg /proc/self/ns/net). ++ * ++ * **BPF_PROG_TYPE_LIRC_MODE2** ++ * ++ * LIRC device path (eg /dev/lircN). Requires the kernel ++ * to be compiled with **CONFIG_BPF_LIRC_MODE2**. ++ * ++ * **BPF_PROG_TYPE_SK_SKB**, ++ * **BPF_PROG_TYPE_SK_MSG** ++ * ++ * eBPF map of socket type (eg **BPF_MAP_TYPE_SOCKHASH**). ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_PROG_DETACH ++ * Description ++ * Detach the eBPF program associated with the *target_fd* at the ++ * hook specified by *attach_type*. The program must have been ++ * previously attached using **BPF_PROG_ATTACH**. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_PROG_TEST_RUN ++ * Description ++ * Run the eBPF program associated with the *prog_fd* a *repeat* ++ * number of times against a provided program context *ctx_in* and ++ * data *data_in*, and return the modified program context ++ * *ctx_out*, *data_out* (for example, packet data), result of the ++ * execution *retval*, and *duration* of the test run. ++ * ++ * The sizes of the buffers provided as input and output ++ * parameters *ctx_in*, *ctx_out*, *data_in*, and *data_out* must ++ * be provided in the corresponding variables *ctx_size_in*, ++ * *ctx_size_out*, *data_size_in*, and/or *data_size_out*. If any ++ * of these parameters are not provided (ie set to NULL), the ++ * corresponding size field must be zero. ++ * ++ * Some program types have particular requirements: ++ * ++ * **BPF_PROG_TYPE_SK_LOOKUP** ++ * *data_in* and *data_out* must be NULL. ++ * ++ * **BPF_PROG_TYPE_XDP** ++ * *ctx_in* and *ctx_out* must be NULL. ++ * ++ * **BPF_PROG_TYPE_RAW_TRACEPOINT**, ++ * **BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE** ++ * ++ * *ctx_out*, *data_in* and *data_out* must be NULL. ++ * *repeat* must be zero. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * **ENOSPC** ++ * Either *data_size_out* or *ctx_size_out* is too small. ++ * **ENOTSUPP** ++ * This command is not supported by the program type of ++ * the program referred to by *prog_fd*. ++ * ++ * BPF_PROG_GET_NEXT_ID ++ * Description ++ * Fetch the next eBPF program currently loaded into the kernel. ++ * ++ * Looks for the eBPF program with an id greater than *start_id* ++ * and updates *next_id* on success. If no other eBPF programs ++ * remain with ids higher than *start_id*, returns -1 and sets ++ * *errno* to **ENOENT**. ++ * ++ * Return ++ * Returns zero on success. On error, or when no id remains, -1 ++ * is returned and *errno* is set appropriately. ++ * ++ * BPF_MAP_GET_NEXT_ID ++ * Description ++ * Fetch the next eBPF map currently loaded into the kernel. ++ * ++ * Looks for the eBPF map with an id greater than *start_id* ++ * and updates *next_id* on success. If no other eBPF maps ++ * remain with ids higher than *start_id*, returns -1 and sets ++ * *errno* to **ENOENT**. ++ * ++ * Return ++ * Returns zero on success. On error, or when no id remains, -1 ++ * is returned and *errno* is set appropriately. ++ * ++ * BPF_PROG_GET_FD_BY_ID ++ * Description ++ * Open a file descriptor for the eBPF program corresponding to ++ * *prog_id*. ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_MAP_GET_FD_BY_ID ++ * Description ++ * Open a file descriptor for the eBPF map corresponding to ++ * *map_id*. ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_OBJ_GET_INFO_BY_FD ++ * Description ++ * Obtain information about the eBPF object corresponding to ++ * *bpf_fd*. ++ * ++ * Populates up to *info_len* bytes of *info*, which will be in ++ * one of the following formats depending on the eBPF object type ++ * of *bpf_fd*: ++ * ++ * * **struct bpf_prog_info** ++ * * **struct bpf_map_info** ++ * * **struct bpf_btf_info** ++ * * **struct bpf_link_info** ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_PROG_QUERY ++ * Description ++ * Obtain information about eBPF programs associated with the ++ * specified *attach_type* hook. ++ * ++ * The *target_fd* must be a valid file descriptor for a kernel ++ * object which depends on the attach type of *attach_bpf_fd*: ++ * ++ * **BPF_PROG_TYPE_CGROUP_DEVICE**, ++ * **BPF_PROG_TYPE_CGROUP_SKB**, ++ * **BPF_PROG_TYPE_CGROUP_SOCK**, ++ * **BPF_PROG_TYPE_CGROUP_SOCK_ADDR**, ++ * **BPF_PROG_TYPE_CGROUP_SOCKOPT**, ++ * **BPF_PROG_TYPE_CGROUP_SYSCTL**, ++ * **BPF_PROG_TYPE_SOCK_OPS** ++ * ++ * Control Group v2 hierarchy with the eBPF controller ++ * enabled. Requires the kernel to be compiled with ++ * **CONFIG_CGROUP_BPF**. ++ * ++ * **BPF_PROG_TYPE_FLOW_DISSECTOR** ++ * ++ * Network namespace (eg /proc/self/ns/net). ++ * ++ * **BPF_PROG_TYPE_LIRC_MODE2** ++ * ++ * LIRC device path (eg /dev/lircN). Requires the kernel ++ * to be compiled with **CONFIG_BPF_LIRC_MODE2**. ++ * ++ * **BPF_PROG_QUERY** always fetches the number of programs ++ * attached and the *attach_flags* which were used to attach those ++ * programs. Additionally, if *prog_ids* is nonzero and the number ++ * of attached programs is less than *prog_cnt*, populates ++ * *prog_ids* with the eBPF program ids of the programs attached ++ * at *target_fd*. ++ * ++ * The following flags may alter the result: ++ * ++ * **BPF_F_QUERY_EFFECTIVE** ++ * Only return information regarding programs which are ++ * currently effective at the specified *target_fd*. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_RAW_TRACEPOINT_OPEN ++ * Description ++ * Attach an eBPF program to a tracepoint *name* to access kernel ++ * internal arguments of the tracepoint in their raw form. ++ * ++ * The *prog_fd* must be a valid file descriptor associated with ++ * a loaded eBPF program of type **BPF_PROG_TYPE_RAW_TRACEPOINT**. ++ * ++ * No ABI guarantees are made about the content of tracepoint ++ * arguments exposed to the corresponding eBPF program. ++ * ++ * Applying **close**\ (2) to the file descriptor returned by ++ * **BPF_RAW_TRACEPOINT_OPEN** will delete the map (but see NOTES). ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_BTF_LOAD ++ * Description ++ * Verify and load BPF Type Format (BTF) metadata into the kernel, ++ * returning a new file descriptor associated with the metadata. ++ * BTF is described in more detail at ++ * https://www.kernel.org/doc/html/latest/bpf/btf.html. ++ * ++ * The *btf* parameter must point to valid memory providing ++ * *btf_size* bytes of BTF binary metadata. ++ * ++ * The returned file descriptor can be passed to other **bpf**\ () ++ * subcommands such as **BPF_PROG_LOAD** or **BPF_MAP_CREATE** to ++ * associate the BTF with those objects. ++ * ++ * Similar to **BPF_PROG_LOAD**, **BPF_BTF_LOAD** has optional ++ * parameters to specify a *btf_log_buf*, *btf_log_size* and ++ * *btf_log_level* which allow the kernel to return freeform log ++ * output regarding the BTF verification process. ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_BTF_GET_FD_BY_ID ++ * Description ++ * Open a file descriptor for the BPF Type Format (BTF) ++ * corresponding to *btf_id*. ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_TASK_FD_QUERY ++ * Description ++ * Obtain information about eBPF programs associated with the ++ * target process identified by *pid* and *fd*. ++ * ++ * If the *pid* and *fd* are associated with a tracepoint, kprobe ++ * or uprobe perf event, then the *prog_id* and *fd_type* will ++ * be populated with the eBPF program id and file descriptor type ++ * of type **bpf_task_fd_type**. If associated with a kprobe or ++ * uprobe, the *probe_offset* and *probe_addr* will also be ++ * populated. Optionally, if *buf* is provided, then up to ++ * *buf_len* bytes of *buf* will be populated with the name of ++ * the tracepoint, kprobe or uprobe. ++ * ++ * The resulting *prog_id* may be introspected in deeper detail ++ * using **BPF_PROG_GET_FD_BY_ID** and **BPF_OBJ_GET_INFO_BY_FD**. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_MAP_LOOKUP_AND_DELETE_ELEM ++ * Description ++ * Look up an element with the given *key* in the map referred to ++ * by the file descriptor *fd*, and if found, delete the element. ++ * ++ * The **BPF_MAP_TYPE_QUEUE** and **BPF_MAP_TYPE_STACK** map types ++ * implement this command as a "pop" operation, deleting the top ++ * element rather than one corresponding to *key*. ++ * The *key* and *key_len* parameters should be zeroed when ++ * issuing this operation for these map types. ++ * ++ * This command is only valid for the following map types: ++ * * **BPF_MAP_TYPE_QUEUE** ++ * * **BPF_MAP_TYPE_STACK** ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_MAP_FREEZE ++ * Description ++ * Freeze the permissions of the specified map. ++ * ++ * Write permissions may be frozen by passing zero *flags*. ++ * Upon success, no future syscall invocations may alter the ++ * map state of *map_fd*. Write operations from eBPF programs ++ * are still possible for a frozen map. ++ * ++ * Not supported for maps of type **BPF_MAP_TYPE_STRUCT_OPS**. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_BTF_GET_NEXT_ID ++ * Description ++ * Fetch the next BPF Type Format (BTF) object currently loaded ++ * into the kernel. ++ * ++ * Looks for the BTF object with an id greater than *start_id* ++ * and updates *next_id* on success. If no other BTF objects ++ * remain with ids higher than *start_id*, returns -1 and sets ++ * *errno* to **ENOENT**. ++ * ++ * Return ++ * Returns zero on success. On error, or when no id remains, -1 ++ * is returned and *errno* is set appropriately. ++ * ++ * BPF_MAP_LOOKUP_BATCH ++ * Description ++ * Iterate and fetch multiple elements in a map. ++ * ++ * Two opaque values are used to manage batch operations, ++ * *in_batch* and *out_batch*. Initially, *in_batch* must be set ++ * to NULL to begin the batched operation. After each subsequent ++ * **BPF_MAP_LOOKUP_BATCH**, the caller should pass the resultant ++ * *out_batch* as the *in_batch* for the next operation to ++ * continue iteration from the current point. ++ * ++ * The *keys* and *values* are output parameters which must point ++ * to memory large enough to hold *count* items based on the key ++ * and value size of the map *map_fd*. The *keys* buffer must be ++ * of *key_size* * *count*. The *values* buffer must be of ++ * *value_size* * *count*. ++ * ++ * The *elem_flags* argument may be specified as one of the ++ * following: ++ * ++ * **BPF_F_LOCK** ++ * Look up the value of a spin-locked map without ++ * returning the lock. This must be specified if the ++ * elements contain a spinlock. ++ * ++ * On success, *count* elements from the map are copied into the ++ * user buffer, with the keys copied into *keys* and the values ++ * copied into the corresponding indices in *values*. ++ * ++ * If an error is returned and *errno* is not **EFAULT**, *count* ++ * is set to the number of successfully processed elements. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * May set *errno* to **ENOSPC** to indicate that *keys* or ++ * *values* is too small to dump an entire bucket during ++ * iteration of a hash-based map type. ++ * ++ * BPF_MAP_LOOKUP_AND_DELETE_BATCH ++ * Description ++ * Iterate and delete all elements in a map. ++ * ++ * This operation has the same behavior as ++ * **BPF_MAP_LOOKUP_BATCH** with two exceptions: ++ * ++ * * Every element that is successfully returned is also deleted ++ * from the map. This is at least *count* elements. Note that ++ * *count* is both an input and an output parameter. ++ * * Upon returning with *errno* set to **EFAULT**, up to ++ * *count* elements may be deleted without returning the keys ++ * and values of the deleted elements. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_MAP_UPDATE_BATCH ++ * Description ++ * Update multiple elements in a map by *key*. ++ * ++ * The *keys* and *values* are input parameters which must point ++ * to memory large enough to hold *count* items based on the key ++ * and value size of the map *map_fd*. The *keys* buffer must be ++ * of *key_size* * *count*. The *values* buffer must be of ++ * *value_size* * *count*. ++ * ++ * Each element specified in *keys* is sequentially updated to the ++ * value in the corresponding index in *values*. The *in_batch* ++ * and *out_batch* parameters are ignored and should be zeroed. ++ * ++ * The *elem_flags* argument should be specified as one of the ++ * following: ++ * ++ * **BPF_ANY** ++ * Create new elements or update a existing elements. ++ * **BPF_NOEXIST** ++ * Create new elements only if they do not exist. ++ * **BPF_EXIST** ++ * Update existing elements. ++ * **BPF_F_LOCK** ++ * Update spin_lock-ed map elements. This must be ++ * specified if the map value contains a spinlock. ++ * ++ * On success, *count* elements from the map are updated. ++ * ++ * If an error is returned and *errno* is not **EFAULT**, *count* ++ * is set to the number of successfully processed elements. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * May set *errno* to **EINVAL**, **EPERM**, **ENOMEM**, or ++ * **E2BIG**. **E2BIG** indicates that the number of elements in ++ * the map reached the *max_entries* limit specified at map ++ * creation time. ++ * ++ * May set *errno* to one of the following error codes under ++ * specific circumstances: ++ * ++ * **EEXIST** ++ * If *flags* specifies **BPF_NOEXIST** and the element ++ * with *key* already exists in the map. ++ * **ENOENT** ++ * If *flags* specifies **BPF_EXIST** and the element with ++ * *key* does not exist in the map. ++ * ++ * BPF_MAP_DELETE_BATCH ++ * Description ++ * Delete multiple elements in a map by *key*. ++ * ++ * The *keys* parameter is an input parameter which must point ++ * to memory large enough to hold *count* items based on the key ++ * size of the map *map_fd*, that is, *key_size* * *count*. ++ * ++ * Each element specified in *keys* is sequentially deleted. The ++ * *in_batch*, *out_batch*, and *values* parameters are ignored ++ * and should be zeroed. ++ * ++ * The *elem_flags* argument may be specified as one of the ++ * following: ++ * ++ * **BPF_F_LOCK** ++ * Look up the value of a spin-locked map without ++ * returning the lock. This must be specified if the ++ * elements contain a spinlock. ++ * ++ * On success, *count* elements from the map are updated. ++ * ++ * If an error is returned and *errno* is not **EFAULT**, *count* ++ * is set to the number of successfully processed elements. If ++ * *errno* is **EFAULT**, up to *count* elements may be been ++ * deleted. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_LINK_CREATE ++ * Description ++ * Attach an eBPF program to a *target_fd* at the specified ++ * *attach_type* hook and return a file descriptor handle for ++ * managing the link. ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_LINK_UPDATE ++ * Description ++ * Update the eBPF program in the specified *link_fd* to ++ * *new_prog_fd*. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_LINK_GET_FD_BY_ID ++ * Description ++ * Open a file descriptor for the eBPF Link corresponding to ++ * *link_id*. ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_LINK_GET_NEXT_ID ++ * Description ++ * Fetch the next eBPF link currently loaded into the kernel. ++ * ++ * Looks for the eBPF link with an id greater than *start_id* ++ * and updates *next_id* on success. If no other eBPF links ++ * remain with ids higher than *start_id*, returns -1 and sets ++ * *errno* to **ENOENT**. ++ * ++ * Return ++ * Returns zero on success. On error, or when no id remains, -1 ++ * is returned and *errno* is set appropriately. ++ * ++ * BPF_ENABLE_STATS ++ * Description ++ * Enable eBPF runtime statistics gathering. ++ * ++ * Runtime statistics gathering for the eBPF runtime is disabled ++ * by default to minimize the corresponding performance overhead. ++ * This command enables statistics globally. ++ * ++ * Multiple programs may independently enable statistics. ++ * After gathering the desired statistics, eBPF runtime statistics ++ * may be disabled again by calling **close**\ (2) for the file ++ * descriptor returned by this function. Statistics will only be ++ * disabled system-wide when all outstanding file descriptors ++ * returned by prior calls for this subcommand are closed. ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_ITER_CREATE ++ * Description ++ * Create an iterator on top of the specified *link_fd* (as ++ * previously created using **BPF_LINK_CREATE**) and return a ++ * file descriptor that can be used to trigger the iteration. ++ * ++ * If the resulting file descriptor is pinned to the filesystem ++ * using **BPF_OBJ_PIN**, then subsequent **read**\ (2) syscalls ++ * for that path will trigger the iterator to read kernel state ++ * using the eBPF program attached to *link_fd*. ++ * ++ * Return ++ * A new file descriptor (a nonnegative integer), or -1 if an ++ * error occurred (in which case, *errno* is set appropriately). ++ * ++ * BPF_LINK_DETACH ++ * Description ++ * Forcefully detach the specified *link_fd* from its ++ * corresponding attachment point. ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * BPF_PROG_BIND_MAP ++ * Description ++ * Bind a map to the lifetime of an eBPF program. ++ * ++ * The map identified by *map_fd* is bound to the program ++ * identified by *prog_fd* and only released when *prog_fd* is ++ * released. This may be used in cases where metadata should be ++ * associated with a program which otherwise does not contain any ++ * references to the map (for example, embedded in the eBPF ++ * program instructions). ++ * ++ * Return ++ * Returns zero on success. On error, -1 is returned and *errno* ++ * is set appropriately. ++ * ++ * NOTES ++ * eBPF objects (maps and programs) can be shared between processes. ++ * ++ * * After **fork**\ (2), the child inherits file descriptors ++ * referring to the same eBPF objects. ++ * * File descriptors referring to eBPF objects can be transferred over ++ * **unix**\ (7) domain sockets. ++ * * File descriptors referring to eBPF objects can be duplicated in the ++ * usual way, using **dup**\ (2) and similar calls. ++ * * File descriptors referring to eBPF objects can be pinned to the ++ * filesystem using the **BPF_OBJ_PIN** command of **bpf**\ (2). ++ * ++ * An eBPF object is deallocated only after all file descriptors referring ++ * to the object have been closed and no references remain pinned to the ++ * filesystem or attached (for example, bound to a program or device). ++ */ + enum bpf_cmd { + BPF_MAP_CREATE, + BPF_MAP_LOOKUP_ELEM, +@@ -247,6 +978,7 @@ enum bpf_attach_type { + BPF_XDP_CPUMAP, + BPF_SK_LOOKUP, + BPF_XDP, ++ BPF_SK_SKB_VERDICT, + __MAX_BPF_ATTACH_TYPE + }; + +@@ -407,6 +1139,10 @@ enum bpf_link_type { + * offset to another bpf function + */ + #define BPF_PSEUDO_CALL 1 ++/* when bpf_call->src_reg == BPF_PSEUDO_KFUNC_CALL, ++ * bpf_call->imm == btf_id of a BTF_KIND_FUNC in the running kernel ++ */ ++#define BPF_PSEUDO_KFUNC_CALL 2 + + /* flags for BPF_MAP_UPDATE_ELEM command */ + enum { +@@ -729,7 +1465,7 @@ union bpf_attr { + * parsed and used to produce a manual page. The workflow is the following, + * and requires the rst2man utility: + * +- * $ ./scripts/bpf_helpers_doc.py \ ++ * $ ./scripts/bpf_doc.py \ + * --filename include/uapi/linux/bpf.h > /tmp/bpf-helpers.rst + * $ rst2man /tmp/bpf-helpers.rst > /tmp/bpf-helpers.7 + * $ man /tmp/bpf-helpers.7 +@@ -1774,6 +2510,10 @@ union bpf_attr { + * Use with ENCAP_L3/L4 flags to further specify the tunnel + * type; *len* is the length of the inner MAC header. + * ++ * * **BPF_F_ADJ_ROOM_ENCAP_L2_ETH**: ++ * Use with BPF_F_ADJ_ROOM_ENCAP_L2 flag to further specify the ++ * L2 type as Ethernet. ++ * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be +@@ -3342,12 +4082,20 @@ union bpf_attr { + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. ++ * If **0** is specified in *flags*, an adaptive notification ++ * of new data availability is sent. ++ * ++ * An adaptive notification is a notification sent whenever the user-space ++ * process has caught up and consumed all available payloads. In case the user-space ++ * process is still processing a previous payload, then no notification is needed ++ * as it will process the newly added payload automatically. + * Return + * 0 on success, or a negative error in case of failure. + * + * void *bpf_ringbuf_reserve(void *ringbuf, u64 size, u64 flags) + * Description + * Reserve *size* bytes of payload in a ring buffer *ringbuf*. ++ * *flags* must be 0. + * Return + * Valid pointer with *size* bytes of memory available; NULL, + * otherwise. +@@ -3359,6 +4107,10 @@ union bpf_attr { + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. ++ * If **0** is specified in *flags*, an adaptive notification ++ * of new data availability is sent. ++ * ++ * See 'bpf_ringbuf_output()' for the definition of adaptive notification. + * Return + * Nothing. Always succeeds. + * +@@ -3369,6 +4121,10 @@ union bpf_attr { + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. ++ * If **0** is specified in *flags*, an adaptive notification ++ * of new data availability is sent. ++ * ++ * See 'bpf_ringbuf_output()' for the definition of adaptive notification. + * Return + * Nothing. Always succeeds. + * +@@ -3859,7 +4615,7 @@ union bpf_attr { + * + * long bpf_check_mtu(void *ctx, u32 ifindex, u32 *mtu_len, s32 len_diff, u64 flags) + * Description +- * Check ctx packet size against exceeding MTU of net device (based ++ * Check packet size against exceeding MTU of net device (based + * on *ifindex*). This helper will likely be used in combination + * with helpers that adjust/change the packet size. + * +@@ -3876,6 +4632,14 @@ union bpf_attr { + * against the current net device. This is practical if this isn't + * used prior to redirect. + * ++ * On input *mtu_len* must be a valid pointer, else verifier will ++ * reject BPF program. If the value *mtu_len* is initialized to ++ * zero then the ctx packet size is use. When value *mtu_len* is ++ * provided as input this specify the L3 length that the MTU check ++ * is done against. Remember XDP and TC length operate at L2, but ++ * this value is L3 as this correlate to MTU and IP-header tot_len ++ * values which are L3 (similar behavior as bpf_fib_lookup). ++ * + * The Linux kernel route table can configure MTUs on a more + * specific per route level, which is not provided by this helper. + * For route level MTU checks use the **bpf_fib_lookup**\ () +@@ -3900,11 +4664,9 @@ union bpf_attr { + * + * On return *mtu_len* pointer contains the MTU value of the net + * device. Remember the net device configured MTU is the L3 size, +- * which is returned here and XDP and TX length operate at L2. ++ * which is returned here and XDP and TC length operate at L2. + * Helper take this into account for you, but remember when using +- * MTU value in your BPF-code. On input *mtu_len* must be a valid +- * pointer and be initialized (to zero), else verifier will reject +- * BPF program. ++ * MTU value in your BPF-code. + * + * Return + * * 0 on success, and populate MTU value in *mtu_len* pointer. +@@ -3946,6 +4708,33 @@ union bpf_attr { + * Return + * The number of traversed map elements for success, **-EINVAL** for + * invalid **flags**. ++ * ++ * long bpf_snprintf(char *str, u32 str_size, const char *fmt, u64 *data, u32 data_len) ++ * Description ++ * Outputs a string into the **str** buffer of size **str_size** ++ * based on a format string stored in a read-only map pointed by ++ * **fmt**. ++ * ++ * Each format specifier in **fmt** corresponds to one u64 element ++ * in the **data** array. For strings and pointers where pointees ++ * are accessed, only the pointer values are stored in the *data* ++ * array. The *data_len* is the size of *data* in bytes. ++ * ++ * Formats **%s** and **%p{i,I}{4,6}** require to read kernel ++ * memory. Reading kernel memory may fail due to either invalid ++ * address or valid address but requiring a major memory fault. If ++ * reading kernel memory fails, the string for **%s** will be an ++ * empty string, and the ip address for **%p{i,I}{4,6}** will be 0. ++ * Not returning error to bpf program is consistent with what ++ * **bpf_trace_printk**\ () does for now. ++ * ++ * Return ++ * The strictly positive length of the formatted string, including ++ * the trailing zero character. If the return value is greater than ++ * **str_size**, **str** contains a truncated string, guaranteed to ++ * be zero-terminated except when **str_size** is 0. ++ * ++ * Or **-EBUSY** if the per-CPU memory copy buffer is busy. + */ + #define __BPF_FUNC_MAPPER(FN) \ + FN(unspec), \ +@@ -4113,6 +4902,7 @@ union bpf_attr { + FN(sock_from_file), \ + FN(check_mtu), \ + FN(for_each_map_elem), \ ++ FN(snprintf), \ + /* */ + + /* integer value in 'imm' field of BPF_CALL instruction selects which helper +@@ -4206,6 +4996,7 @@ enum { + BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3), + BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4), + BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5), ++ BPF_F_ADJ_ROOM_ENCAP_L2_ETH = (1ULL << 6), + }; + + enum { +@@ -4653,6 +5444,8 @@ struct bpf_link_info { + } raw_tracepoint; + struct { + __u32 attach_type; ++ __u32 target_obj_id; /* prog_id for PROG_EXT, otherwise btf object id */ ++ __u32 target_btf_id; /* BTF type id inside the object */ + } tracing; + struct { + __u64 cgroup_id; +@@ -5243,7 +6036,10 @@ struct bpf_pidns_info { + + /* User accessible data for SK_LOOKUP programs. Add new fields at the end. */ + struct bpf_sk_lookup { +- __bpf_md_ptr(struct bpf_sock *, sk); /* Selected socket */ ++ union { ++ __bpf_md_ptr(struct bpf_sock *, sk); /* Selected socket */ ++ __u64 cookie; /* Non-zero if socket was selected in PROG_TEST_RUN */ ++ }; + + __u32 family; /* Protocol family (AF_INET, AF_INET6) */ + __u32 protocol; /* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */ +Index: dwarves-dfsg-1.21/lib/bpf/scripts/sync-kernel.sh +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/scripts/sync-kernel.sh ++++ dwarves-dfsg-1.21/lib/bpf/scripts/sync-kernel.sh +@@ -266,12 +266,12 @@ for patch in $(ls -1 ${TMP_DIR}/patches + done + + # Generate bpf_helper_defs.h and commit, if anything changed +-# restore Linux tip to use bpf_helpers_doc.py ++# restore Linux tip to use bpf_doc.py + cd_to ${LINUX_REPO} + git checkout ${TIP_TAG} + # re-generate bpf_helper_defs.h + cd_to ${LIBBPF_REPO} +-"${LINUX_ABS_DIR}/scripts/bpf_helpers_doc.py" --header \ ++"${LINUX_ABS_DIR}/scripts/bpf_doc.py" --header \ + --file include/uapi/linux/bpf.h > src/bpf_helper_defs.h + # if anything changed, commit it + helpers_changes=$(git status --porcelain src/bpf_helper_defs.h | wc -l) +Index: dwarves-dfsg-1.21/lib/bpf/src/Makefile +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/Makefile ++++ dwarves-dfsg-1.21/lib/bpf/src/Makefile +@@ -36,7 +36,7 @@ SHARED_OBJDIR := $(OBJDIR)/sharedobjs + STATIC_OBJDIR := $(OBJDIR)/staticobjs + OBJS := bpf.o btf.o libbpf.o libbpf_errno.o netlink.o \ + nlattr.o str_error.o libbpf_probes.o bpf_prog_linfo.o xsk.o \ +- btf_dump.o hashmap.o ringbuf.o ++ btf_dump.o hashmap.o ringbuf.o strset.o linker.o + SHARED_OBJS := $(addprefix $(SHARED_OBJDIR)/,$(OBJS)) + STATIC_OBJS := $(addprefix $(STATIC_OBJDIR)/,$(OBJS)) + +@@ -48,7 +48,7 @@ ifndef BUILD_STATIC_ONLY + VERSION_SCRIPT := libbpf.map + endif + +-HEADERS := bpf.h libbpf.h btf.h xsk.h libbpf_util.h \ ++HEADERS := bpf.h libbpf.h btf.h xsk.h \ + bpf_helpers.h bpf_helper_defs.h bpf_tracing.h \ + bpf_endian.h bpf_core_read.h libbpf_common.h + UAPI_HEADERS := $(addprefix $(TOPDIR)/include/uapi/linux/,\ +@@ -121,7 +121,7 @@ define do_install + $(Q)if [ ! -d '$(DESTDIR)$2' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR)$2'; \ + fi; +- $(Q)$(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR)$2' ++ $(Q)$(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR)$2' + endef + + # Preserve symlinks at installation. +Index: dwarves-dfsg-1.21/lib/bpf/src/bpf_core_read.h +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/bpf_core_read.h ++++ dwarves-dfsg-1.21/lib/bpf/src/bpf_core_read.h +@@ -88,11 +88,19 @@ enum bpf_enum_value_kind { + const void *p = (const void *)s + __CORE_RELO(s, field, BYTE_OFFSET); \ + unsigned long long val; \ + \ ++ /* This is a so-called barrier_var() operation that makes specified \ ++ * variable "a black box" for optimizing compiler. \ ++ * It forces compiler to perform BYTE_OFFSET relocation on p and use \ ++ * its calculated value in the switch below, instead of applying \ ++ * the same relocation 4 times for each individual memory load. \ ++ */ \ ++ asm volatile("" : "=r"(p) : "0"(p)); \ ++ \ + switch (__CORE_RELO(s, field, BYTE_SIZE)) { \ +- case 1: val = *(const unsigned char *)p; \ +- case 2: val = *(const unsigned short *)p; \ +- case 4: val = *(const unsigned int *)p; \ +- case 8: val = *(const unsigned long long *)p; \ ++ case 1: val = *(const unsigned char *)p; break; \ ++ case 2: val = *(const unsigned short *)p; break; \ ++ case 4: val = *(const unsigned int *)p; break; \ ++ case 8: val = *(const unsigned long long *)p; break; \ + } \ + val <<= __CORE_RELO(s, field, LSHIFT_U64); \ + if (__CORE_RELO(s, field, SIGNED)) \ +Index: dwarves-dfsg-1.21/lib/bpf/src/bpf_helper_defs.h +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/bpf_helper_defs.h ++++ dwarves-dfsg-1.21/lib/bpf/src/bpf_helper_defs.h +@@ -1,4 +1,4 @@ +-/* This is auto-generated file. See bpf_helpers_doc.py for details. */ ++/* This is auto-generated file. See bpf_doc.py for details. */ + + /* Forward declarations of BPF structs */ + struct bpf_fib_lookup; +@@ -1249,6 +1249,10 @@ static long (*bpf_setsockopt)(void *bpf_ + * Use with ENCAP_L3/L4 flags to further specify the tunnel + * type; *len* is the length of the inner MAC header. + * ++ * * **BPF_F_ADJ_ROOM_ENCAP_L2_ETH**: ++ * Use with BPF_F_ADJ_ROOM_ENCAP_L2 flag to further specify the ++ * L2 type as Ethernet. ++ * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be +@@ -3088,6 +3092,13 @@ static __u64 (*bpf_sk_ancestor_cgroup_id + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. ++ * If **0** is specified in *flags*, an adaptive notification ++ * of new data availability is sent. ++ * ++ * An adaptive notification is a notification sent whenever the user-space ++ * process has caught up and consumed all available payloads. In case the user-space ++ * process is still processing a previous payload, then no notification is needed ++ * as it will process the newly added payload automatically. + * + * Returns + * 0 on success, or a negative error in case of failure. +@@ -3098,6 +3109,7 @@ static long (*bpf_ringbuf_output)(void * + * bpf_ringbuf_reserve + * + * Reserve *size* bytes of payload in a ring buffer *ringbuf*. ++ * *flags* must be 0. + * + * Returns + * Valid pointer with *size* bytes of memory available; NULL, +@@ -3113,6 +3125,10 @@ static void *(*bpf_ringbuf_reserve)(void + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. ++ * If **0** is specified in *flags*, an adaptive notification ++ * of new data availability is sent. ++ * ++ * See 'bpf_ringbuf_output()' for the definition of adaptive notification. + * + * Returns + * Nothing. Always succeeds. +@@ -3127,6 +3143,10 @@ static void (*bpf_ringbuf_submit)(void * + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. ++ * If **0** is specified in *flags*, an adaptive notification ++ * of new data availability is sent. ++ * ++ * See 'bpf_ringbuf_output()' for the definition of adaptive notification. + * + * Returns + * Nothing. Always succeeds. +@@ -3737,7 +3757,7 @@ static struct socket *(*bpf_sock_from_fi + /* + * bpf_check_mtu + * +- * Check ctx packet size against exceeding MTU of net device (based ++ * Check packet size against exceeding MTU of net device (based + * on *ifindex*). This helper will likely be used in combination + * with helpers that adjust/change the packet size. + * +@@ -3754,6 +3774,14 @@ static struct socket *(*bpf_sock_from_fi + * against the current net device. This is practical if this isn't + * used prior to redirect. + * ++ * On input *mtu_len* must be a valid pointer, else verifier will ++ * reject BPF program. If the value *mtu_len* is initialized to ++ * zero then the ctx packet size is use. When value *mtu_len* is ++ * provided as input this specify the L3 length that the MTU check ++ * is done against. Remember XDP and TC length operate at L2, but ++ * this value is L3 as this correlate to MTU and IP-header tot_len ++ * values which are L3 (similar behavior as bpf_fib_lookup). ++ * + * The Linux kernel route table can configure MTUs on a more + * specific per route level, which is not provided by this helper. + * For route level MTU checks use the **bpf_fib_lookup**\ () +@@ -3778,11 +3806,9 @@ static struct socket *(*bpf_sock_from_fi + * + * On return *mtu_len* pointer contains the MTU value of the net + * device. Remember the net device configured MTU is the L3 size, +- * which is returned here and XDP and TX length operate at L2. ++ * which is returned here and XDP and TC length operate at L2. + * Helper take this into account for you, but remember when using +- * MTU value in your BPF-code. On input *mtu_len* must be a valid +- * pointer and be initialized (to zero), else verifier will reject +- * BPF program. ++ * MTU value in your BPF-code. + * + * + * Returns +@@ -3832,4 +3858,35 @@ static long (*bpf_check_mtu)(void *ctx, + */ + static long (*bpf_for_each_map_elem)(void *map, void *callback_fn, void *callback_ctx, __u64 flags) = (void *) 164; + ++/* ++ * bpf_snprintf ++ * ++ * Outputs a string into the **str** buffer of size **str_size** ++ * based on a format string stored in a read-only map pointed by ++ * **fmt**. ++ * ++ * Each format specifier in **fmt** corresponds to one u64 element ++ * in the **data** array. For strings and pointers where pointees ++ * are accessed, only the pointer values are stored in the *data* ++ * array. The *data_len* is the size of *data* in bytes. ++ * ++ * Formats **%s** and **%p{i,I}{4,6}** require to read kernel ++ * memory. Reading kernel memory may fail due to either invalid ++ * address or valid address but requiring a major memory fault. If ++ * reading kernel memory fails, the string for **%s** will be an ++ * empty string, and the ip address for **%p{i,I}{4,6}** will be 0. ++ * Not returning error to bpf program is consistent with what ++ * **bpf_trace_printk**\ () does for now. ++ * ++ * ++ * Returns ++ * The strictly positive length of the formatted string, including ++ * the trailing zero character. If the return value is greater than ++ * **str_size**, **str** contains a truncated string, guaranteed to ++ * be zero-terminated except when **str_size** is 0. ++ * ++ * Or **-EBUSY** if the per-CPU memory copy buffer is busy. ++ */ ++static long (*bpf_snprintf)(char *str, __u32 str_size, const char *fmt, __u64 *data, __u32 data_len) = (void *) 165; ++ + +Index: dwarves-dfsg-1.21/lib/bpf/src/bpf_helpers.h +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/bpf_helpers.h ++++ dwarves-dfsg-1.21/lib/bpf/src/bpf_helpers.h +@@ -25,13 +25,21 @@ + /* + * Helper macro to place programs, maps, license in + * different sections in elf_bpf file. Section names +- * are interpreted by elf_bpf loader ++ * are interpreted by libbpf depending on the context (BPF programs, BPF maps, ++ * extern variables, etc). ++ * To allow use of SEC() with externs (e.g., for extern .maps declarations), ++ * make sure __attribute__((unused)) doesn't trigger compilation warning. + */ +-#define SEC(NAME) __attribute__((section(NAME), used)) ++#define SEC(name) \ ++ _Pragma("GCC diagnostic push") \ ++ _Pragma("GCC diagnostic ignored \"-Wignored-attributes\"") \ ++ __attribute__((section(name), used)) \ ++ _Pragma("GCC diagnostic pop") \ + +-#ifndef __always_inline ++/* Avoid 'linux/stddef.h' definition of '__always_inline'. */ ++#undef __always_inline + #define __always_inline inline __attribute__((always_inline)) +-#endif ++ + #ifndef __noinline + #define __noinline __attribute__((noinline)) + #endif +@@ -40,7 +48,29 @@ + #endif + + /* +- * Helper macro to manipulate data structures ++ * Use __hidden attribute to mark a non-static BPF subprogram effectively ++ * static for BPF verifier's verification algorithm purposes, allowing more ++ * extensive and permissive BPF verification process, taking into account ++ * subprogram's caller context. ++ */ ++#define __hidden __attribute__((visibility("hidden"))) ++ ++/* When utilizing vmlinux.h with BPF CO-RE, user BPF programs can't include ++ * any system-level headers (such as stddef.h, linux/version.h, etc), and ++ * commonly-used macros like NULL and KERNEL_VERSION aren't available through ++ * vmlinux.h. This just adds unnecessary hurdles and forces users to re-define ++ * them on their own. So as a convenience, provide such definitions here. ++ */ ++#ifndef NULL ++#define NULL ((void *)0) ++#endif ++ ++#ifndef KERNEL_VERSION ++#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c))) ++#endif ++ ++/* ++ * Helper macros to manipulate data structures + */ + #ifndef offsetof + #define offsetof(TYPE, MEMBER) ((unsigned long)&((TYPE *)0)->MEMBER) +Index: dwarves-dfsg-1.21/lib/bpf/src/bpf_tracing.h +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/bpf_tracing.h ++++ dwarves-dfsg-1.21/lib/bpf/src/bpf_tracing.h +@@ -413,20 +413,56 @@ typeof(name(0)) name(struct pt_regs *ctx + } \ + static __always_inline typeof(name(0)) ____##name(struct pt_regs *ctx, ##args) + ++#define ___bpf_fill0(arr, p, x) do {} while (0) ++#define ___bpf_fill1(arr, p, x) arr[p] = x ++#define ___bpf_fill2(arr, p, x, args...) arr[p] = x; ___bpf_fill1(arr, p + 1, args) ++#define ___bpf_fill3(arr, p, x, args...) arr[p] = x; ___bpf_fill2(arr, p + 1, args) ++#define ___bpf_fill4(arr, p, x, args...) arr[p] = x; ___bpf_fill3(arr, p + 1, args) ++#define ___bpf_fill5(arr, p, x, args...) arr[p] = x; ___bpf_fill4(arr, p + 1, args) ++#define ___bpf_fill6(arr, p, x, args...) arr[p] = x; ___bpf_fill5(arr, p + 1, args) ++#define ___bpf_fill7(arr, p, x, args...) arr[p] = x; ___bpf_fill6(arr, p + 1, args) ++#define ___bpf_fill8(arr, p, x, args...) arr[p] = x; ___bpf_fill7(arr, p + 1, args) ++#define ___bpf_fill9(arr, p, x, args...) arr[p] = x; ___bpf_fill8(arr, p + 1, args) ++#define ___bpf_fill10(arr, p, x, args...) arr[p] = x; ___bpf_fill9(arr, p + 1, args) ++#define ___bpf_fill11(arr, p, x, args...) arr[p] = x; ___bpf_fill10(arr, p + 1, args) ++#define ___bpf_fill12(arr, p, x, args...) arr[p] = x; ___bpf_fill11(arr, p + 1, args) ++#define ___bpf_fill(arr, args...) \ ++ ___bpf_apply(___bpf_fill, ___bpf_narg(args))(arr, 0, args) ++ + /* + * BPF_SEQ_PRINTF to wrap bpf_seq_printf to-be-printed values + * in a structure. + */ +-#define BPF_SEQ_PRINTF(seq, fmt, args...) \ +- ({ \ +- _Pragma("GCC diagnostic push") \ +- _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ +- static const char ___fmt[] = fmt; \ +- unsigned long long ___param[] = { args }; \ +- _Pragma("GCC diagnostic pop") \ +- int ___ret = bpf_seq_printf(seq, ___fmt, sizeof(___fmt), \ +- ___param, sizeof(___param)); \ +- ___ret; \ +- }) ++#define BPF_SEQ_PRINTF(seq, fmt, args...) \ ++({ \ ++ static const char ___fmt[] = fmt; \ ++ unsigned long long ___param[___bpf_narg(args)]; \ ++ \ ++ _Pragma("GCC diagnostic push") \ ++ _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ ++ ___bpf_fill(___param, args); \ ++ _Pragma("GCC diagnostic pop") \ ++ \ ++ bpf_seq_printf(seq, ___fmt, sizeof(___fmt), \ ++ ___param, sizeof(___param)); \ ++}) ++ ++/* ++ * BPF_SNPRINTF wraps the bpf_snprintf helper with variadic arguments instead of ++ * an array of u64. ++ */ ++#define BPF_SNPRINTF(out, out_size, fmt, args...) \ ++({ \ ++ static const char ___fmt[] = fmt; \ ++ unsigned long long ___param[___bpf_narg(args)]; \ ++ \ ++ _Pragma("GCC diagnostic push") \ ++ _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ ++ ___bpf_fill(___param, args); \ ++ _Pragma("GCC diagnostic pop") \ ++ \ ++ bpf_snprintf(out, out_size, ___fmt, \ ++ ___param, sizeof(___param)); \ ++}) + + #endif +Index: dwarves-dfsg-1.21/lib/bpf/src/btf.c +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/btf.c ++++ dwarves-dfsg-1.21/lib/bpf/src/btf.c +@@ -21,6 +21,7 @@ + #include "libbpf.h" + #include "libbpf_internal.h" + #include "hashmap.h" ++#include "strset.h" + + #define BTF_MAX_NR_TYPES 0x7fffffffU + #define BTF_MAX_STR_OFFSET 0x7fffffffU +@@ -67,7 +68,7 @@ struct btf { + * | | | + * hdr | | + * types_data----+ | +- * strs_data------------------+ ++ * strset__data(strs_set)-----+ + * + * +----------+---------+-----------+ + * | Header | Types | Strings | +@@ -105,20 +106,15 @@ struct btf { + */ + int start_str_off; + ++ /* only one of strs_data or strs_set can be non-NULL, depending on ++ * whether BTF is in a modifiable state (strs_set is used) or not ++ * (strs_data points inside raw_data) ++ */ + void *strs_data; +- size_t strs_data_cap; /* used size stored in hdr->str_len */ +- +- /* lookup index for each unique string in strings section */ +- struct hashmap *strs_hash; ++ /* a set of unique strings */ ++ struct strset *strs_set; + /* whether strings are already deduplicated */ + bool strs_deduped; +- /* extra indirection layer to make strings hashmap work with stable +- * string offsets and ability to transparently choose between +- * btf->strs_data or btf_dedup->strs_data as a source of strings. +- * This is used for BTF strings dedup to transfer deduplicated strings +- * data back to struct btf without re-building strings index. +- */ +- void **strs_data_ptr; + + /* BTF object FD, if loaded into kernel */ + int fd; +@@ -142,8 +138,8 @@ static inline __u64 ptr_to_u64(const voi + * On success, memory pointer to the beginning of unused memory is returned. + * On error, NULL is returned. + */ +-void *btf_add_mem(void **data, size_t *cap_cnt, size_t elem_sz, +- size_t cur_cnt, size_t max_cnt, size_t add_cnt) ++void *libbpf_add_mem(void **data, size_t *cap_cnt, size_t elem_sz, ++ size_t cur_cnt, size_t max_cnt, size_t add_cnt) + { + size_t new_cnt; + void *new_data; +@@ -179,14 +175,14 @@ void *btf_add_mem(void **data, size_t *c + /* Ensure given dynamically allocated memory region has enough allocated space + * to accommodate *need_cnt* elements of size *elem_sz* bytes each + */ +-int btf_ensure_mem(void **data, size_t *cap_cnt, size_t elem_sz, size_t need_cnt) ++int libbpf_ensure_mem(void **data, size_t *cap_cnt, size_t elem_sz, size_t need_cnt) + { + void *p; + + if (need_cnt <= *cap_cnt) + return 0; + +- p = btf_add_mem(data, cap_cnt, elem_sz, *cap_cnt, SIZE_MAX, need_cnt - *cap_cnt); ++ p = libbpf_add_mem(data, cap_cnt, elem_sz, *cap_cnt, SIZE_MAX, need_cnt - *cap_cnt); + if (!p) + return -ENOMEM; + +@@ -197,8 +193,8 @@ static int btf_add_type_idx_entry(struct + { + __u32 *p; + +- p = btf_add_mem((void **)&btf->type_offs, &btf->type_offs_cap, sizeof(__u32), +- btf->nr_types, BTF_MAX_NR_TYPES, 1); ++ p = libbpf_add_mem((void **)&btf->type_offs, &btf->type_offs_cap, sizeof(__u32), ++ btf->nr_types, BTF_MAX_NR_TYPES, 1); + if (!p) + return -ENOMEM; + +@@ -435,7 +431,7 @@ const struct btf *btf__base_btf(const st + } + + /* internal helper returning non-const pointer to a type */ +-static struct btf_type *btf_type_by_id(struct btf *btf, __u32 type_id) ++struct btf_type *btf_type_by_id(struct btf *btf, __u32 type_id) + { + if (type_id == 0) + return &btf_void; +@@ -738,7 +734,7 @@ void btf__free(struct btf *btf) + */ + free(btf->hdr); + free(btf->types_data); +- free(btf->strs_data); ++ strset__free(btf->strs_set); + } + free(btf->raw_data); + free(btf->raw_data_swapped); +@@ -1246,6 +1242,11 @@ void btf__set_fd(struct btf *btf, int fd + btf->fd = fd; + } + ++static const void *btf_strs_data(const struct btf *btf) ++{ ++ return btf->strs_data ? btf->strs_data : strset__data(btf->strs_set); ++} ++ + static void *btf_get_raw_data(const struct btf *btf, __u32 *size, bool swap_endian) + { + struct btf_header *hdr = btf->hdr; +@@ -1286,7 +1287,7 @@ static void *btf_get_raw_data(const stru + } + p += hdr->type_len; + +- memcpy(p, btf->strs_data, hdr->str_len); ++ memcpy(p, btf_strs_data(btf), hdr->str_len); + p += hdr->str_len; + + *size = data_sz; +@@ -1320,7 +1321,7 @@ const char *btf__str_by_offset(const str + if (offset < btf->start_str_off) + return btf__str_by_offset(btf->base_btf, offset); + else if (offset - btf->start_str_off < btf->hdr->str_len) +- return btf->strs_data + (offset - btf->start_str_off); ++ return btf_strs_data(btf) + (offset - btf->start_str_off); + else + return NULL; + } +@@ -1474,25 +1475,6 @@ int btf__get_map_kv_tids(const struct bt + return 0; + } + +-static size_t strs_hash_fn(const void *key, void *ctx) +-{ +- const struct btf *btf = ctx; +- const char *strs = *btf->strs_data_ptr; +- const char *str = strs + (long)key; +- +- return str_hash(str); +-} +- +-static bool strs_hash_equal_fn(const void *key1, const void *key2, void *ctx) +-{ +- const struct btf *btf = ctx; +- const char *strs = *btf->strs_data_ptr; +- const char *str1 = strs + (long)key1; +- const char *str2 = strs + (long)key2; +- +- return strcmp(str1, str2) == 0; +-} +- + static void btf_invalidate_raw_data(struct btf *btf) + { + if (btf->raw_data) { +@@ -1511,10 +1493,9 @@ static void btf_invalidate_raw_data(stru + */ + static int btf_ensure_modifiable(struct btf *btf) + { +- void *hdr, *types, *strs, *strs_end, *s; +- struct hashmap *hash = NULL; +- long off; +- int err; ++ void *hdr, *types; ++ struct strset *set = NULL; ++ int err = -ENOMEM; + + if (btf_is_modifiable(btf)) { + /* any BTF modification invalidates raw_data */ +@@ -1525,44 +1506,25 @@ static int btf_ensure_modifiable(struct + /* split raw data into three memory regions */ + hdr = malloc(btf->hdr->hdr_len); + types = malloc(btf->hdr->type_len); +- strs = malloc(btf->hdr->str_len); +- if (!hdr || !types || !strs) ++ if (!hdr || !types) + goto err_out; + + memcpy(hdr, btf->hdr, btf->hdr->hdr_len); + memcpy(types, btf->types_data, btf->hdr->type_len); +- memcpy(strs, btf->strs_data, btf->hdr->str_len); +- +- /* make hashmap below use btf->strs_data as a source of strings */ +- btf->strs_data_ptr = &btf->strs_data; + + /* build lookup index for all strings */ +- hash = hashmap__new(strs_hash_fn, strs_hash_equal_fn, btf); +- if (IS_ERR(hash)) { +- err = PTR_ERR(hash); +- hash = NULL; ++ set = strset__new(BTF_MAX_STR_OFFSET, btf->strs_data, btf->hdr->str_len); ++ if (IS_ERR(set)) { ++ err = PTR_ERR(set); + goto err_out; + } + +- strs_end = strs + btf->hdr->str_len; +- for (off = 0, s = strs; s < strs_end; off += strlen(s) + 1, s = strs + off) { +- /* hashmap__add() returns EEXIST if string with the same +- * content already is in the hash map +- */ +- err = hashmap__add(hash, (void *)off, (void *)off); +- if (err == -EEXIST) +- continue; /* duplicate */ +- if (err) +- goto err_out; +- } +- + /* only when everything was successful, update internal state */ + btf->hdr = hdr; + btf->types_data = types; + btf->types_data_cap = btf->hdr->type_len; +- btf->strs_data = strs; +- btf->strs_data_cap = btf->hdr->str_len; +- btf->strs_hash = hash; ++ btf->strs_data = NULL; ++ btf->strs_set = set; + /* if BTF was created from scratch, all strings are guaranteed to be + * unique and deduplicated + */ +@@ -1577,17 +1539,10 @@ static int btf_ensure_modifiable(struct + return 0; + + err_out: +- hashmap__free(hash); ++ strset__free(set); + free(hdr); + free(types); +- free(strs); +- return -ENOMEM; +-} +- +-static void *btf_add_str_mem(struct btf *btf, size_t add_sz) +-{ +- return btf_add_mem(&btf->strs_data, &btf->strs_data_cap, 1, +- btf->hdr->str_len, BTF_MAX_STR_OFFSET, add_sz); ++ return err; + } + + /* Find an offset in BTF string section that corresponds to a given string *s*. +@@ -1598,34 +1553,23 @@ static void *btf_add_str_mem(struct btf + */ + int btf__find_str(struct btf *btf, const char *s) + { +- long old_off, new_off, len; +- void *p; ++ int off; + + if (btf->base_btf) { +- int ret; +- +- ret = btf__find_str(btf->base_btf, s); +- if (ret != -ENOENT) +- return ret; ++ off = btf__find_str(btf->base_btf, s); ++ if (off != -ENOENT) ++ return off; + } + + /* BTF needs to be in a modifiable state to build string lookup index */ + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + +- /* see btf__add_str() for why we do this */ +- len = strlen(s) + 1; +- p = btf_add_str_mem(btf, len); +- if (!p) +- return -ENOMEM; +- +- new_off = btf->hdr->str_len; +- memcpy(p, s, len); ++ off = strset__find_str(btf->strs_set, s); ++ if (off < 0) ++ return off; + +- if (hashmap__find(btf->strs_hash, (void *)new_off, (void **)&old_off)) +- return btf->start_str_off + old_off; +- +- return -ENOENT; ++ return btf->start_str_off + off; + } + + /* Add a string s to the BTF string section. +@@ -1635,61 +1579,30 @@ int btf__find_str(struct btf *btf, const + */ + int btf__add_str(struct btf *btf, const char *s) + { +- long old_off, new_off, len; +- void *p; +- int err; ++ int off; + + if (btf->base_btf) { +- int ret; +- +- ret = btf__find_str(btf->base_btf, s); +- if (ret != -ENOENT) +- return ret; ++ off = btf__find_str(btf->base_btf, s); ++ if (off != -ENOENT) ++ return off; + } + + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + +- /* Hashmap keys are always offsets within btf->strs_data, so to even +- * look up some string from the "outside", we need to first append it +- * at the end, so that it can be addressed with an offset. Luckily, +- * until btf->hdr->str_len is incremented, that string is just a piece +- * of garbage for the rest of BTF code, so no harm, no foul. On the +- * other hand, if the string is unique, it's already appended and +- * ready to be used, only a simple btf->hdr->str_len increment away. +- */ +- len = strlen(s) + 1; +- p = btf_add_str_mem(btf, len); +- if (!p) +- return -ENOMEM; +- +- new_off = btf->hdr->str_len; +- memcpy(p, s, len); ++ off = strset__add_str(btf->strs_set, s); ++ if (off < 0) ++ return off; + +- /* Now attempt to add the string, but only if the string with the same +- * contents doesn't exist already (HASHMAP_ADD strategy). If such +- * string exists, we'll get its offset in old_off (that's old_key). +- */ +- err = hashmap__insert(btf->strs_hash, (void *)new_off, (void *)new_off, +- HASHMAP_ADD, (const void **)&old_off, NULL); +- if (err == -EEXIST) +- return btf->start_str_off + old_off; /* duplicated string, return existing offset */ +- if (err) +- return err; ++ btf->hdr->str_len = strset__data_size(btf->strs_set); + +- btf->hdr->str_len += len; /* new unique string, adjust data length */ +- return btf->start_str_off + new_off; ++ return btf->start_str_off + off; + } + + static void *btf_add_type_mem(struct btf *btf, size_t add_sz) + { +- return btf_add_mem(&btf->types_data, &btf->types_data_cap, 1, +- btf->hdr->type_len, UINT_MAX, add_sz); +-} +- +-static __u32 btf_type_info(int kind, int vlen, int kflag) +-{ +- return (kflag << 31) | (kind << 24) | vlen; ++ return libbpf_add_mem(&btf->types_data, &btf->types_data_cap, 1, ++ btf->hdr->type_len, UINT_MAX, add_sz); + } + + static void btf_type_inc_vlen(struct btf_type *t) +@@ -1711,6 +1624,54 @@ static int btf_commit_type(struct btf *b + return btf->start_id + btf->nr_types - 1; + } + ++struct btf_pipe { ++ const struct btf *src; ++ struct btf *dst; ++}; ++ ++static int btf_rewrite_str(__u32 *str_off, void *ctx) ++{ ++ struct btf_pipe *p = ctx; ++ int off; ++ ++ if (!*str_off) /* nothing to do for empty strings */ ++ return 0; ++ ++ off = btf__add_str(p->dst, btf__str_by_offset(p->src, *str_off)); ++ if (off < 0) ++ return off; ++ ++ *str_off = off; ++ return 0; ++} ++ ++int btf__add_type(struct btf *btf, const struct btf *src_btf, const struct btf_type *src_type) ++{ ++ struct btf_pipe p = { .src = src_btf, .dst = btf }; ++ struct btf_type *t; ++ int sz, err; ++ ++ sz = btf_type_size(src_type); ++ if (sz < 0) ++ return sz; ++ ++ /* deconstruct BTF, if necessary, and invalidate raw_data */ ++ if (btf_ensure_modifiable(btf)) ++ return -ENOMEM; ++ ++ t = btf_add_type_mem(btf, sz); ++ if (!t) ++ return -ENOMEM; ++ ++ memcpy(t, src_type, sz); ++ ++ err = btf_type_visit_str_offs(t, btf_rewrite_str, &p); ++ if (err) ++ return err; ++ ++ return btf_commit_type(btf, sz); ++} ++ + /* + * Append new BTF_KIND_INT type with: + * - *name* - non-empty, non-NULL type name; +@@ -3016,10 +2977,7 @@ struct btf_dedup { + /* Various option modifying behavior of algorithm */ + struct btf_dedup_opts opts; + /* temporary strings deduplication state */ +- void *strs_data; +- size_t strs_cap; +- size_t strs_len; +- struct hashmap* strs_hash; ++ struct strset *strs_set; + }; + + static long hash_combine(long h, long value) +@@ -3155,95 +3113,28 @@ done: + return d; + } + +-typedef int (*str_off_fn_t)(__u32 *str_off_ptr, void *ctx); +- + /* + * Iterate over all possible places in .BTF and .BTF.ext that can reference + * string and pass pointer to it to a provided callback `fn`. + */ +-static int btf_for_each_str_off(struct btf_dedup *d, str_off_fn_t fn, void *ctx) ++static int btf_for_each_str_off(struct btf_dedup *d, str_off_visit_fn fn, void *ctx) + { +- void *line_data_cur, *line_data_end; +- int i, j, r, rec_size; +- struct btf_type *t; ++ int i, r; + + for (i = 0; i < d->btf->nr_types; i++) { +- t = btf_type_by_id(d->btf, d->btf->start_id + i); +- r = fn(&t->name_off, ctx); ++ struct btf_type *t = btf_type_by_id(d->btf, d->btf->start_id + i); ++ ++ r = btf_type_visit_str_offs(t, fn, ctx); + if (r) + return r; +- +- switch (btf_kind(t)) { +- case BTF_KIND_STRUCT: +- case BTF_KIND_UNION: { +- struct btf_member *m = btf_members(t); +- __u16 vlen = btf_vlen(t); +- +- for (j = 0; j < vlen; j++) { +- r = fn(&m->name_off, ctx); +- if (r) +- return r; +- m++; +- } +- break; +- } +- case BTF_KIND_ENUM: { +- struct btf_enum *m = btf_enum(t); +- __u16 vlen = btf_vlen(t); +- +- for (j = 0; j < vlen; j++) { +- r = fn(&m->name_off, ctx); +- if (r) +- return r; +- m++; +- } +- break; +- } +- case BTF_KIND_FUNC_PROTO: { +- struct btf_param *m = btf_params(t); +- __u16 vlen = btf_vlen(t); +- +- for (j = 0; j < vlen; j++) { +- r = fn(&m->name_off, ctx); +- if (r) +- return r; +- m++; +- } +- break; +- } +- default: +- break; +- } + } + + if (!d->btf_ext) + return 0; + +- line_data_cur = d->btf_ext->line_info.info; +- line_data_end = d->btf_ext->line_info.info + d->btf_ext->line_info.len; +- rec_size = d->btf_ext->line_info.rec_size; +- +- while (line_data_cur < line_data_end) { +- struct btf_ext_info_sec *sec = line_data_cur; +- struct bpf_line_info_min *line_info; +- __u32 num_info = sec->num_info; +- +- r = fn(&sec->sec_name_off, ctx); +- if (r) +- return r; +- +- line_data_cur += sizeof(struct btf_ext_info_sec); +- for (i = 0; i < num_info; i++) { +- line_info = line_data_cur; +- r = fn(&line_info->file_name_off, ctx); +- if (r) +- return r; +- r = fn(&line_info->line_off, ctx); +- if (r) +- return r; +- line_data_cur += rec_size; +- } +- } ++ r = btf_ext_visit_str_offs(d->btf_ext, fn, ctx); ++ if (r) ++ return r; + + return 0; + } +@@ -3252,10 +3143,8 @@ static int strs_dedup_remap_str_off(__u3 + { + struct btf_dedup *d = ctx; + __u32 str_off = *str_off_ptr; +- long old_off, new_off, len; + const char *s; +- void *p; +- int err; ++ int off, err; + + /* don't touch empty string or string in main BTF */ + if (str_off == 0 || str_off < d->btf->start_str_off) +@@ -3272,29 +3161,11 @@ static int strs_dedup_remap_str_off(__u3 + return err; + } + +- len = strlen(s) + 1; +- +- new_off = d->strs_len; +- p = btf_add_mem(&d->strs_data, &d->strs_cap, 1, new_off, BTF_MAX_STR_OFFSET, len); +- if (!p) +- return -ENOMEM; +- +- memcpy(p, s, len); ++ off = strset__add_str(d->strs_set, s); ++ if (off < 0) ++ return off; + +- /* Now attempt to add the string, but only if the string with the same +- * contents doesn't exist already (HASHMAP_ADD strategy). If such +- * string exists, we'll get its offset in old_off (that's old_key). +- */ +- err = hashmap__insert(d->strs_hash, (void *)new_off, (void *)new_off, +- HASHMAP_ADD, (const void **)&old_off, NULL); +- if (err == -EEXIST) { +- *str_off_ptr = d->btf->start_str_off + old_off; +- } else if (err) { +- return err; +- } else { +- *str_off_ptr = d->btf->start_str_off + new_off; +- d->strs_len += len; +- } ++ *str_off_ptr = d->btf->start_str_off + off; + return 0; + } + +@@ -3311,39 +3182,23 @@ static int strs_dedup_remap_str_off(__u3 + */ + static int btf_dedup_strings(struct btf_dedup *d) + { +- char *s; + int err; + + if (d->btf->strs_deduped) + return 0; + +- /* temporarily switch to use btf_dedup's strs_data for strings for hash +- * functions; later we'll just transfer hashmap to struct btf as is, +- * along the strs_data +- */ +- d->btf->strs_data_ptr = &d->strs_data; +- +- d->strs_hash = hashmap__new(strs_hash_fn, strs_hash_equal_fn, d->btf); +- if (IS_ERR(d->strs_hash)) { +- err = PTR_ERR(d->strs_hash); +- d->strs_hash = NULL; ++ d->strs_set = strset__new(BTF_MAX_STR_OFFSET, NULL, 0); ++ if (IS_ERR(d->strs_set)) { ++ err = PTR_ERR(d->strs_set); + goto err_out; + } + + if (!d->btf->base_btf) { +- s = btf_add_mem(&d->strs_data, &d->strs_cap, 1, d->strs_len, BTF_MAX_STR_OFFSET, 1); +- if (!s) +- return -ENOMEM; +- /* initial empty string */ +- s[0] = 0; +- d->strs_len = 1; +- + /* insert empty string; we won't be looking it up during strings + * dedup, but it's good to have it for generic BTF string lookups + */ +- err = hashmap__insert(d->strs_hash, (void *)0, (void *)0, +- HASHMAP_ADD, NULL, NULL); +- if (err) ++ err = strset__add_str(d->strs_set, ""); ++ if (err < 0) + goto err_out; + } + +@@ -3353,28 +3208,16 @@ static int btf_dedup_strings(struct btf_ + goto err_out; + + /* replace BTF string data and hash with deduped ones */ +- free(d->btf->strs_data); +- hashmap__free(d->btf->strs_hash); +- d->btf->strs_data = d->strs_data; +- d->btf->strs_data_cap = d->strs_cap; +- d->btf->hdr->str_len = d->strs_len; +- d->btf->strs_hash = d->strs_hash; +- /* now point strs_data_ptr back to btf->strs_data */ +- d->btf->strs_data_ptr = &d->btf->strs_data; +- +- d->strs_data = d->strs_hash = NULL; +- d->strs_len = d->strs_cap = 0; ++ strset__free(d->btf->strs_set); ++ d->btf->hdr->str_len = strset__data_size(d->strs_set); ++ d->btf->strs_set = d->strs_set; ++ d->strs_set = NULL; + d->btf->strs_deduped = true; + return 0; + + err_out: +- free(d->strs_data); +- hashmap__free(d->strs_hash); +- d->strs_data = d->strs_hash = NULL; +- d->strs_len = d->strs_cap = 0; +- +- /* restore strings pointer for existing d->btf->strs_hash back */ +- d->btf->strs_data_ptr = &d->strs_data; ++ strset__free(d->strs_set); ++ d->strs_set = NULL; + + return err; + } +@@ -4498,15 +4341,18 @@ static int btf_dedup_compact_types(struc + * then mapping it to a deduplicated type ID, stored in btf_dedup->hypot_map, + * which is populated during compaction phase. + */ +-static int btf_dedup_remap_type_id(struct btf_dedup *d, __u32 type_id) ++static int btf_dedup_remap_type_id(__u32 *type_id, void *ctx) + { ++ struct btf_dedup *d = ctx; + __u32 resolved_type_id, new_type_id; + +- resolved_type_id = resolve_type_id(d, type_id); ++ resolved_type_id = resolve_type_id(d, *type_id); + new_type_id = d->hypot_map[resolved_type_id]; + if (new_type_id > BTF_MAX_NR_TYPES) + return -EINVAL; +- return new_type_id; ++ ++ *type_id = new_type_id; ++ return 0; + } + + /* +@@ -4519,109 +4365,25 @@ static int btf_dedup_remap_type_id(struc + * referenced from any BTF type (e.g., struct fields, func proto args, etc) to + * their final deduped type IDs. + */ +-static int btf_dedup_remap_type(struct btf_dedup *d, __u32 type_id) ++static int btf_dedup_remap_types(struct btf_dedup *d) + { +- struct btf_type *t = btf_type_by_id(d->btf, type_id); + int i, r; + +- switch (btf_kind(t)) { +- case BTF_KIND_INT: +- case BTF_KIND_ENUM: +- case BTF_KIND_FLOAT: +- break; +- +- case BTF_KIND_FWD: +- case BTF_KIND_CONST: +- case BTF_KIND_VOLATILE: +- case BTF_KIND_RESTRICT: +- case BTF_KIND_PTR: +- case BTF_KIND_TYPEDEF: +- case BTF_KIND_FUNC: +- case BTF_KIND_VAR: +- r = btf_dedup_remap_type_id(d, t->type); +- if (r < 0) +- return r; +- t->type = r; +- break; +- +- case BTF_KIND_ARRAY: { +- struct btf_array *arr_info = btf_array(t); +- +- r = btf_dedup_remap_type_id(d, arr_info->type); +- if (r < 0) +- return r; +- arr_info->type = r; +- r = btf_dedup_remap_type_id(d, arr_info->index_type); +- if (r < 0) +- return r; +- arr_info->index_type = r; +- break; +- } +- +- case BTF_KIND_STRUCT: +- case BTF_KIND_UNION: { +- struct btf_member *member = btf_members(t); +- __u16 vlen = btf_vlen(t); +- +- for (i = 0; i < vlen; i++) { +- r = btf_dedup_remap_type_id(d, member->type); +- if (r < 0) +- return r; +- member->type = r; +- member++; +- } +- break; +- } +- +- case BTF_KIND_FUNC_PROTO: { +- struct btf_param *param = btf_params(t); +- __u16 vlen = btf_vlen(t); ++ for (i = 0; i < d->btf->nr_types; i++) { ++ struct btf_type *t = btf_type_by_id(d->btf, d->btf->start_id + i); + +- r = btf_dedup_remap_type_id(d, t->type); +- if (r < 0) ++ r = btf_type_visit_type_ids(t, btf_dedup_remap_type_id, d); ++ if (r) + return r; +- t->type = r; +- +- for (i = 0; i < vlen; i++) { +- r = btf_dedup_remap_type_id(d, param->type); +- if (r < 0) +- return r; +- param->type = r; +- param++; +- } +- break; +- } +- +- case BTF_KIND_DATASEC: { +- struct btf_var_secinfo *var = btf_var_secinfos(t); +- __u16 vlen = btf_vlen(t); +- +- for (i = 0; i < vlen; i++) { +- r = btf_dedup_remap_type_id(d, var->type); +- if (r < 0) +- return r; +- var->type = r; +- var++; +- } +- break; + } + +- default: +- return -EINVAL; +- } +- +- return 0; +-} ++ if (!d->btf_ext) ++ return 0; + +-static int btf_dedup_remap_types(struct btf_dedup *d) +-{ +- int i, r; ++ r = btf_ext_visit_type_ids(d->btf_ext, btf_dedup_remap_type_id, d); ++ if (r) ++ return r; + +- for (i = 0; i < d->btf->nr_types; i++) { +- r = btf_dedup_remap_type(d, d->btf->start_id + i); +- if (r < 0) +- return r; +- } + return 0; + } + +@@ -4675,3 +4437,200 @@ struct btf *libbpf_find_kernel_btf(void) + pr_warn("failed to find valid kernel BTF\n"); + return ERR_PTR(-ESRCH); + } ++ ++int btf_type_visit_type_ids(struct btf_type *t, type_id_visit_fn visit, void *ctx) ++{ ++ int i, n, err; ++ ++ switch (btf_kind(t)) { ++ case BTF_KIND_INT: ++ case BTF_KIND_FLOAT: ++ case BTF_KIND_ENUM: ++ return 0; ++ ++ case BTF_KIND_FWD: ++ case BTF_KIND_CONST: ++ case BTF_KIND_VOLATILE: ++ case BTF_KIND_RESTRICT: ++ case BTF_KIND_PTR: ++ case BTF_KIND_TYPEDEF: ++ case BTF_KIND_FUNC: ++ case BTF_KIND_VAR: ++ return visit(&t->type, ctx); ++ ++ case BTF_KIND_ARRAY: { ++ struct btf_array *a = btf_array(t); ++ ++ err = visit(&a->type, ctx); ++ err = err ?: visit(&a->index_type, ctx); ++ return err; ++ } ++ ++ case BTF_KIND_STRUCT: ++ case BTF_KIND_UNION: { ++ struct btf_member *m = btf_members(t); ++ ++ for (i = 0, n = btf_vlen(t); i < n; i++, m++) { ++ err = visit(&m->type, ctx); ++ if (err) ++ return err; ++ } ++ return 0; ++ } ++ ++ case BTF_KIND_FUNC_PROTO: { ++ struct btf_param *m = btf_params(t); ++ ++ err = visit(&t->type, ctx); ++ if (err) ++ return err; ++ for (i = 0, n = btf_vlen(t); i < n; i++, m++) { ++ err = visit(&m->type, ctx); ++ if (err) ++ return err; ++ } ++ return 0; ++ } ++ ++ case BTF_KIND_DATASEC: { ++ struct btf_var_secinfo *m = btf_var_secinfos(t); ++ ++ for (i = 0, n = btf_vlen(t); i < n; i++, m++) { ++ err = visit(&m->type, ctx); ++ if (err) ++ return err; ++ } ++ return 0; ++ } ++ ++ default: ++ return -EINVAL; ++ } ++} ++ ++int btf_type_visit_str_offs(struct btf_type *t, str_off_visit_fn visit, void *ctx) ++{ ++ int i, n, err; ++ ++ err = visit(&t->name_off, ctx); ++ if (err) ++ return err; ++ ++ switch (btf_kind(t)) { ++ case BTF_KIND_STRUCT: ++ case BTF_KIND_UNION: { ++ struct btf_member *m = btf_members(t); ++ ++ for (i = 0, n = btf_vlen(t); i < n; i++, m++) { ++ err = visit(&m->name_off, ctx); ++ if (err) ++ return err; ++ } ++ break; ++ } ++ case BTF_KIND_ENUM: { ++ struct btf_enum *m = btf_enum(t); ++ ++ for (i = 0, n = btf_vlen(t); i < n; i++, m++) { ++ err = visit(&m->name_off, ctx); ++ if (err) ++ return err; ++ } ++ break; ++ } ++ case BTF_KIND_FUNC_PROTO: { ++ struct btf_param *m = btf_params(t); ++ ++ for (i = 0, n = btf_vlen(t); i < n; i++, m++) { ++ err = visit(&m->name_off, ctx); ++ if (err) ++ return err; ++ } ++ break; ++ } ++ default: ++ break; ++ } ++ ++ return 0; ++} ++ ++int btf_ext_visit_type_ids(struct btf_ext *btf_ext, type_id_visit_fn visit, void *ctx) ++{ ++ const struct btf_ext_info *seg; ++ struct btf_ext_info_sec *sec; ++ int i, err; ++ ++ seg = &btf_ext->func_info; ++ for_each_btf_ext_sec(seg, sec) { ++ struct bpf_func_info_min *rec; ++ ++ for_each_btf_ext_rec(seg, sec, i, rec) { ++ err = visit(&rec->type_id, ctx); ++ if (err < 0) ++ return err; ++ } ++ } ++ ++ seg = &btf_ext->core_relo_info; ++ for_each_btf_ext_sec(seg, sec) { ++ struct bpf_core_relo *rec; ++ ++ for_each_btf_ext_rec(seg, sec, i, rec) { ++ err = visit(&rec->type_id, ctx); ++ if (err < 0) ++ return err; ++ } ++ } ++ ++ return 0; ++} ++ ++int btf_ext_visit_str_offs(struct btf_ext *btf_ext, str_off_visit_fn visit, void *ctx) ++{ ++ const struct btf_ext_info *seg; ++ struct btf_ext_info_sec *sec; ++ int i, err; ++ ++ seg = &btf_ext->func_info; ++ for_each_btf_ext_sec(seg, sec) { ++ err = visit(&sec->sec_name_off, ctx); ++ if (err) ++ return err; ++ } ++ ++ seg = &btf_ext->line_info; ++ for_each_btf_ext_sec(seg, sec) { ++ struct bpf_line_info_min *rec; ++ ++ err = visit(&sec->sec_name_off, ctx); ++ if (err) ++ return err; ++ ++ for_each_btf_ext_rec(seg, sec, i, rec) { ++ err = visit(&rec->file_name_off, ctx); ++ if (err) ++ return err; ++ err = visit(&rec->line_off, ctx); ++ if (err) ++ return err; ++ } ++ } ++ ++ seg = &btf_ext->core_relo_info; ++ for_each_btf_ext_sec(seg, sec) { ++ struct bpf_core_relo *rec; ++ ++ err = visit(&sec->sec_name_off, ctx); ++ if (err) ++ return err; ++ ++ for_each_btf_ext_rec(seg, sec, i, rec) { ++ err = visit(&rec->access_str_off, ctx); ++ if (err) ++ return err; ++ } ++ } ++ ++ return 0; ++} +Index: dwarves-dfsg-1.21/lib/bpf/src/btf.h +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/btf.h ++++ dwarves-dfsg-1.21/lib/bpf/src/btf.h +@@ -93,6 +93,8 @@ LIBBPF_API struct btf *libbpf_find_kerne + + LIBBPF_API int btf__find_str(struct btf *btf, const char *s); + LIBBPF_API int btf__add_str(struct btf *btf, const char *s); ++LIBBPF_API int btf__add_type(struct btf *btf, const struct btf *src_btf, ++ const struct btf_type *src_type); + + LIBBPF_API int btf__add_int(struct btf *btf, const char *name, size_t byte_sz, int encoding); + LIBBPF_API int btf__add_float(struct btf *btf, const char *name, size_t byte_sz); +@@ -174,6 +176,7 @@ struct btf_dump_emit_type_decl_opts { + int indent_level; + /* strip all the const/volatile/restrict mods */ + bool strip_mods; ++ size_t :0; + }; + #define btf_dump_emit_type_decl_opts__last_field strip_mods + +Index: dwarves-dfsg-1.21/lib/bpf/src/btf_dump.c +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/btf_dump.c ++++ dwarves-dfsg-1.21/lib/bpf/src/btf_dump.c +@@ -166,11 +166,11 @@ static int btf_dump_resize(struct btf_du + if (last_id <= d->last_id) + return 0; + +- if (btf_ensure_mem((void **)&d->type_states, &d->type_states_cap, +- sizeof(*d->type_states), last_id + 1)) ++ if (libbpf_ensure_mem((void **)&d->type_states, &d->type_states_cap, ++ sizeof(*d->type_states), last_id + 1)) + return -ENOMEM; +- if (btf_ensure_mem((void **)&d->cached_names, &d->cached_names_cap, +- sizeof(*d->cached_names), last_id + 1)) ++ if (libbpf_ensure_mem((void **)&d->cached_names, &d->cached_names_cap, ++ sizeof(*d->cached_names), last_id + 1)) + return -ENOMEM; + + if (d->last_id == 0) { +@@ -464,7 +464,7 @@ static int btf_dump_order_type(struct bt + return err; + + case BTF_KIND_ARRAY: +- return btf_dump_order_type(d, btf_array(t)->type, through_ptr); ++ return btf_dump_order_type(d, btf_array(t)->type, false); + + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: { +Index: dwarves-dfsg-1.21/lib/bpf/src/libbpf.c +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/libbpf.c ++++ dwarves-dfsg-1.21/lib/bpf/src/libbpf.c +@@ -55,10 +55,6 @@ + #include "libbpf_internal.h" + #include "hashmap.h" + +-#ifndef EM_BPF +-#define EM_BPF 247 +-#endif +- + #ifndef BPF_FS_MAGIC + #define BPF_FS_MAGIC 0xcafe4a11 + #endif +@@ -73,8 +69,7 @@ + #define __printf(a, b) __attribute__((format(printf, a, b))) + + static struct bpf_map *bpf_object__add_map(struct bpf_object *obj); +-static const struct btf_type * +-skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id); ++static bool prog_is_subprog(const struct bpf_object *obj, const struct bpf_program *prog); + + static int __base_pr(enum libbpf_print_level level, const char *format, + va_list args) +@@ -189,7 +184,8 @@ enum reloc_type { + RELO_LD64, + RELO_CALL, + RELO_DATA, +- RELO_EXTERN, ++ RELO_EXTERN_VAR, ++ RELO_EXTERN_FUNC, + RELO_SUBPROG_ADDR, + }; + +@@ -198,7 +194,6 @@ struct reloc_desc { + int insn_idx; + int map_idx; + int sym_off; +- bool processed; + }; + + struct bpf_sec_def; +@@ -278,6 +273,7 @@ struct bpf_program { + bpf_program_clear_priv_t clear_priv; + + bool load; ++ bool mark_btf_static; + enum bpf_prog_type type; + enum bpf_attach_type expected_attach_type; + int prog_ifindex; +@@ -504,8 +500,6 @@ static Elf_Scn *elf_sec_by_name(const st + static int elf_sec_hdr(const struct bpf_object *obj, Elf_Scn *scn, GElf_Shdr *hdr); + static const char *elf_sec_name(const struct bpf_object *obj, Elf_Scn *scn); + static Elf_Data *elf_sec_data(const struct bpf_object *obj, Elf_Scn *scn); +-static int elf_sym_by_sec_off(const struct bpf_object *obj, size_t sec_idx, +- size_t off, __u32 sym_type, GElf_Sym *sym); + + void bpf_program__unload(struct bpf_program *prog) + { +@@ -577,14 +571,19 @@ static bool insn_is_subprog_call(const s + insn->off == 0; + } + +-static bool is_ldimm64(struct bpf_insn *insn) ++static bool is_ldimm64_insn(struct bpf_insn *insn) + { + return insn->code == (BPF_LD | BPF_IMM | BPF_DW); + } + ++static bool is_call_insn(const struct bpf_insn *insn) ++{ ++ return insn->code == (BPF_JMP | BPF_CALL); ++} ++ + static bool insn_is_pseudo_func(struct bpf_insn *insn) + { +- return is_ldimm64(insn) && insn->src_reg == BPF_PSEUDO_FUNC; ++ return is_ldimm64_insn(insn) && insn->src_reg == BPF_PSEUDO_FUNC; + } + + static int +@@ -641,25 +640,29 @@ static int + bpf_object__add_programs(struct bpf_object *obj, Elf_Data *sec_data, + const char *sec_name, int sec_idx) + { ++ Elf_Data *symbols = obj->efile.symbols; + struct bpf_program *prog, *progs; + void *data = sec_data->d_buf; +- size_t sec_sz = sec_data->d_size, sec_off, prog_sz; +- int nr_progs, err; ++ size_t sec_sz = sec_data->d_size, sec_off, prog_sz, nr_syms; ++ int nr_progs, err, i; + const char *name; + GElf_Sym sym; + + progs = obj->programs; + nr_progs = obj->nr_programs; ++ nr_syms = symbols->d_size / sizeof(GElf_Sym); + sec_off = 0; + +- while (sec_off < sec_sz) { +- if (elf_sym_by_sec_off(obj, sec_idx, sec_off, STT_FUNC, &sym)) { +- pr_warn("sec '%s': failed to find program symbol at offset %zu\n", +- sec_name, sec_off); +- return -LIBBPF_ERRNO__FORMAT; +- } ++ for (i = 0; i < nr_syms; i++) { ++ if (!gelf_getsym(symbols, i, &sym)) ++ continue; ++ if (sym.st_shndx != sec_idx) ++ continue; ++ if (GELF_ST_TYPE(sym.st_info) != STT_FUNC) ++ continue; + + prog_sz = sym.st_size; ++ sec_off = sym.st_value; + + name = elf_sym_str(obj, sym.st_name); + if (!name) { +@@ -674,6 +677,11 @@ bpf_object__add_programs(struct bpf_obje + return -LIBBPF_ERRNO__FORMAT; + } + ++ if (sec_idx != obj->efile.text_shndx && GELF_ST_BIND(sym.st_info) == STB_LOCAL) { ++ pr_warn("sec '%s': program '%s' is static and not supported\n", sec_name, name); ++ return -ENOTSUP; ++ } ++ + pr_debug("sec '%s': found program '%s' at insn offset %zu (%zu bytes), code size %zu insns (%zu bytes)\n", + sec_name, name, sec_off / BPF_INSN_SZ, sec_off, prog_sz / BPF_INSN_SZ, prog_sz); + +@@ -697,10 +705,18 @@ bpf_object__add_programs(struct bpf_obje + if (err) + return err; + ++ /* if function is a global/weak symbol, but has restricted ++ * (STV_HIDDEN or STV_INTERNAL) visibility, mark its BTF FUNC ++ * as static to enable more permissive BPF verification mode ++ * with more outside context available to BPF verifier ++ */ ++ if (GELF_ST_BIND(sym.st_info) != STB_LOCAL ++ && (GELF_ST_VISIBILITY(sym.st_other) == STV_HIDDEN ++ || GELF_ST_VISIBILITY(sym.st_other) == STV_INTERNAL)) ++ prog->mark_btf_static = true; ++ + nr_progs++; + obj->nr_programs = nr_progs; +- +- sec_off += prog_sz; + } + + return 0; +@@ -1134,11 +1150,6 @@ static void bpf_object__elf_finish(struc + obj->efile.obj_buf_sz = 0; + } + +-/* if libelf is old and doesn't support mmap(), fall back to read() */ +-#ifndef ELF_C_READ_MMAP +-#define ELF_C_READ_MMAP ELF_C_READ +-#endif +- + static int bpf_object__elf_init(struct bpf_object *obj) + { + int err = 0; +@@ -1194,7 +1205,8 @@ static int bpf_object__elf_init(struct b + if (!elf_rawdata(elf_getscn(obj->efile.elf, obj->efile.shstrndx), NULL)) { + pr_warn("elf: failed to get section names strings from %s: %s\n", + obj->path, elf_errmsg(-1)); +- return -LIBBPF_ERRNO__FORMAT; ++ err = -LIBBPF_ERRNO__FORMAT; ++ goto errout; + } + + /* Old LLVM set e_machine to EM_NONE */ +@@ -1788,7 +1800,6 @@ static int bpf_object__init_user_maps(st + if (!symbols) + return -EINVAL; + +- + scn = elf_sec_by_idx(obj, obj->efile.maps_shndx); + data = elf_sec_data(obj, scn); + if (!scn || !data) { +@@ -1848,6 +1859,12 @@ static int bpf_object__init_user_maps(st + return -LIBBPF_ERRNO__FORMAT; + } + ++ if (GELF_ST_TYPE(sym.st_info) == STT_SECTION ++ || GELF_ST_BIND(sym.st_info) == STB_LOCAL) { ++ pr_warn("map '%s' (legacy): static maps are not supported\n", map_name); ++ return -ENOTSUP; ++ } ++ + map->libbpf_type = LIBBPF_MAP_UNSPEC; + map->sec_idx = sym.st_shndx; + map->sec_offset = sym.st_value; +@@ -1898,7 +1915,7 @@ static int bpf_object__init_user_maps(st + return 0; + } + +-static const struct btf_type * ++const struct btf_type * + skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id) + { + const struct btf_type *t = btf__type_by_id(btf, id); +@@ -1929,9 +1946,9 @@ resolve_func_ptr(const struct btf *btf, + return btf_is_func_proto(t) ? t : NULL; + } + +-static const char *btf_kind_str(const struct btf_type *t) ++static const char *__btf_kind_str(__u16 kind) + { +- switch (btf_kind(t)) { ++ switch (kind) { + case BTF_KIND_UNKN: return "void"; + case BTF_KIND_INT: return "int"; + case BTF_KIND_PTR: return "ptr"; +@@ -1953,6 +1970,11 @@ static const char *btf_kind_str(const st + } + } + ++const char *btf_kind_str(const struct btf_type *t) ++{ ++ return __btf_kind_str(btf_kind(t)); ++} ++ + /* + * Fetch integer attribute of BTF map definition. Such attributes are + * represented using a pointer to an array, in which dimensionality of array +@@ -2007,254 +2029,272 @@ static int build_map_pin_path(struct bpf + return bpf_map__set_pin_path(map, buf); + } + +- +-static int parse_btf_map_def(struct bpf_object *obj, +- struct bpf_map *map, +- const struct btf_type *def, +- bool strict, bool is_inner, +- const char *pin_root_path) ++int parse_btf_map_def(const char *map_name, struct btf *btf, ++ const struct btf_type *def_t, bool strict, ++ struct btf_map_def *map_def, struct btf_map_def *inner_def) + { + const struct btf_type *t; + const struct btf_member *m; ++ bool is_inner = inner_def == NULL; + int vlen, i; + +- vlen = btf_vlen(def); +- m = btf_members(def); ++ vlen = btf_vlen(def_t); ++ m = btf_members(def_t); + for (i = 0; i < vlen; i++, m++) { +- const char *name = btf__name_by_offset(obj->btf, m->name_off); ++ const char *name = btf__name_by_offset(btf, m->name_off); + + if (!name) { +- pr_warn("map '%s': invalid field #%d.\n", map->name, i); ++ pr_warn("map '%s': invalid field #%d.\n", map_name, i); + return -EINVAL; + } + if (strcmp(name, "type") == 0) { +- if (!get_map_field_int(map->name, obj->btf, m, +- &map->def.type)) ++ if (!get_map_field_int(map_name, btf, m, &map_def->map_type)) + return -EINVAL; +- pr_debug("map '%s': found type = %u.\n", +- map->name, map->def.type); ++ map_def->parts |= MAP_DEF_MAP_TYPE; + } else if (strcmp(name, "max_entries") == 0) { +- if (!get_map_field_int(map->name, obj->btf, m, +- &map->def.max_entries)) ++ if (!get_map_field_int(map_name, btf, m, &map_def->max_entries)) + return -EINVAL; +- pr_debug("map '%s': found max_entries = %u.\n", +- map->name, map->def.max_entries); ++ map_def->parts |= MAP_DEF_MAX_ENTRIES; + } else if (strcmp(name, "map_flags") == 0) { +- if (!get_map_field_int(map->name, obj->btf, m, +- &map->def.map_flags)) ++ if (!get_map_field_int(map_name, btf, m, &map_def->map_flags)) + return -EINVAL; +- pr_debug("map '%s': found map_flags = %u.\n", +- map->name, map->def.map_flags); ++ map_def->parts |= MAP_DEF_MAP_FLAGS; + } else if (strcmp(name, "numa_node") == 0) { +- if (!get_map_field_int(map->name, obj->btf, m, &map->numa_node)) ++ if (!get_map_field_int(map_name, btf, m, &map_def->numa_node)) + return -EINVAL; +- pr_debug("map '%s': found numa_node = %u.\n", map->name, map->numa_node); ++ map_def->parts |= MAP_DEF_NUMA_NODE; + } else if (strcmp(name, "key_size") == 0) { + __u32 sz; + +- if (!get_map_field_int(map->name, obj->btf, m, &sz)) ++ if (!get_map_field_int(map_name, btf, m, &sz)) + return -EINVAL; +- pr_debug("map '%s': found key_size = %u.\n", +- map->name, sz); +- if (map->def.key_size && map->def.key_size != sz) { ++ if (map_def->key_size && map_def->key_size != sz) { + pr_warn("map '%s': conflicting key size %u != %u.\n", +- map->name, map->def.key_size, sz); ++ map_name, map_def->key_size, sz); + return -EINVAL; + } +- map->def.key_size = sz; ++ map_def->key_size = sz; ++ map_def->parts |= MAP_DEF_KEY_SIZE; + } else if (strcmp(name, "key") == 0) { + __s64 sz; + +- t = btf__type_by_id(obj->btf, m->type); ++ t = btf__type_by_id(btf, m->type); + if (!t) { + pr_warn("map '%s': key type [%d] not found.\n", +- map->name, m->type); ++ map_name, m->type); + return -EINVAL; + } + if (!btf_is_ptr(t)) { + pr_warn("map '%s': key spec is not PTR: %s.\n", +- map->name, btf_kind_str(t)); ++ map_name, btf_kind_str(t)); + return -EINVAL; + } +- sz = btf__resolve_size(obj->btf, t->type); ++ sz = btf__resolve_size(btf, t->type); + if (sz < 0) { + pr_warn("map '%s': can't determine key size for type [%u]: %zd.\n", +- map->name, t->type, (ssize_t)sz); ++ map_name, t->type, (ssize_t)sz); + return sz; + } +- pr_debug("map '%s': found key [%u], sz = %zd.\n", +- map->name, t->type, (ssize_t)sz); +- if (map->def.key_size && map->def.key_size != sz) { ++ if (map_def->key_size && map_def->key_size != sz) { + pr_warn("map '%s': conflicting key size %u != %zd.\n", +- map->name, map->def.key_size, (ssize_t)sz); ++ map_name, map_def->key_size, (ssize_t)sz); + return -EINVAL; + } +- map->def.key_size = sz; +- map->btf_key_type_id = t->type; ++ map_def->key_size = sz; ++ map_def->key_type_id = t->type; ++ map_def->parts |= MAP_DEF_KEY_SIZE | MAP_DEF_KEY_TYPE; + } else if (strcmp(name, "value_size") == 0) { + __u32 sz; + +- if (!get_map_field_int(map->name, obj->btf, m, &sz)) ++ if (!get_map_field_int(map_name, btf, m, &sz)) + return -EINVAL; +- pr_debug("map '%s': found value_size = %u.\n", +- map->name, sz); +- if (map->def.value_size && map->def.value_size != sz) { ++ if (map_def->value_size && map_def->value_size != sz) { + pr_warn("map '%s': conflicting value size %u != %u.\n", +- map->name, map->def.value_size, sz); ++ map_name, map_def->value_size, sz); + return -EINVAL; + } +- map->def.value_size = sz; ++ map_def->value_size = sz; ++ map_def->parts |= MAP_DEF_VALUE_SIZE; + } else if (strcmp(name, "value") == 0) { + __s64 sz; + +- t = btf__type_by_id(obj->btf, m->type); ++ t = btf__type_by_id(btf, m->type); + if (!t) { + pr_warn("map '%s': value type [%d] not found.\n", +- map->name, m->type); ++ map_name, m->type); + return -EINVAL; + } + if (!btf_is_ptr(t)) { + pr_warn("map '%s': value spec is not PTR: %s.\n", +- map->name, btf_kind_str(t)); ++ map_name, btf_kind_str(t)); + return -EINVAL; + } +- sz = btf__resolve_size(obj->btf, t->type); ++ sz = btf__resolve_size(btf, t->type); + if (sz < 0) { + pr_warn("map '%s': can't determine value size for type [%u]: %zd.\n", +- map->name, t->type, (ssize_t)sz); ++ map_name, t->type, (ssize_t)sz); + return sz; + } +- pr_debug("map '%s': found value [%u], sz = %zd.\n", +- map->name, t->type, (ssize_t)sz); +- if (map->def.value_size && map->def.value_size != sz) { ++ if (map_def->value_size && map_def->value_size != sz) { + pr_warn("map '%s': conflicting value size %u != %zd.\n", +- map->name, map->def.value_size, (ssize_t)sz); ++ map_name, map_def->value_size, (ssize_t)sz); + return -EINVAL; + } +- map->def.value_size = sz; +- map->btf_value_type_id = t->type; ++ map_def->value_size = sz; ++ map_def->value_type_id = t->type; ++ map_def->parts |= MAP_DEF_VALUE_SIZE | MAP_DEF_VALUE_TYPE; + } + else if (strcmp(name, "values") == 0) { ++ char inner_map_name[128]; + int err; + + if (is_inner) { + pr_warn("map '%s': multi-level inner maps not supported.\n", +- map->name); ++ map_name); + return -ENOTSUP; + } + if (i != vlen - 1) { + pr_warn("map '%s': '%s' member should be last.\n", +- map->name, name); ++ map_name, name); + return -EINVAL; + } +- if (!bpf_map_type__is_map_in_map(map->def.type)) { ++ if (!bpf_map_type__is_map_in_map(map_def->map_type)) { + pr_warn("map '%s': should be map-in-map.\n", +- map->name); ++ map_name); + return -ENOTSUP; + } +- if (map->def.value_size && map->def.value_size != 4) { ++ if (map_def->value_size && map_def->value_size != 4) { + pr_warn("map '%s': conflicting value size %u != 4.\n", +- map->name, map->def.value_size); ++ map_name, map_def->value_size); + return -EINVAL; + } +- map->def.value_size = 4; +- t = btf__type_by_id(obj->btf, m->type); ++ map_def->value_size = 4; ++ t = btf__type_by_id(btf, m->type); + if (!t) { + pr_warn("map '%s': map-in-map inner type [%d] not found.\n", +- map->name, m->type); ++ map_name, m->type); + return -EINVAL; + } + if (!btf_is_array(t) || btf_array(t)->nelems) { + pr_warn("map '%s': map-in-map inner spec is not a zero-sized array.\n", +- map->name); ++ map_name); + return -EINVAL; + } +- t = skip_mods_and_typedefs(obj->btf, btf_array(t)->type, +- NULL); ++ t = skip_mods_and_typedefs(btf, btf_array(t)->type, NULL); + if (!btf_is_ptr(t)) { + pr_warn("map '%s': map-in-map inner def is of unexpected kind %s.\n", +- map->name, btf_kind_str(t)); ++ map_name, btf_kind_str(t)); + return -EINVAL; + } +- t = skip_mods_and_typedefs(obj->btf, t->type, NULL); ++ t = skip_mods_and_typedefs(btf, t->type, NULL); + if (!btf_is_struct(t)) { + pr_warn("map '%s': map-in-map inner def is of unexpected kind %s.\n", +- map->name, btf_kind_str(t)); ++ map_name, btf_kind_str(t)); + return -EINVAL; + } + +- map->inner_map = calloc(1, sizeof(*map->inner_map)); +- if (!map->inner_map) +- return -ENOMEM; +- map->inner_map->sec_idx = obj->efile.btf_maps_shndx; +- map->inner_map->name = malloc(strlen(map->name) + +- sizeof(".inner") + 1); +- if (!map->inner_map->name) +- return -ENOMEM; +- sprintf(map->inner_map->name, "%s.inner", map->name); +- +- err = parse_btf_map_def(obj, map->inner_map, t, strict, +- true /* is_inner */, NULL); ++ snprintf(inner_map_name, sizeof(inner_map_name), "%s.inner", map_name); ++ err = parse_btf_map_def(inner_map_name, btf, t, strict, inner_def, NULL); + if (err) + return err; ++ ++ map_def->parts |= MAP_DEF_INNER_MAP; + } else if (strcmp(name, "pinning") == 0) { + __u32 val; +- int err; + + if (is_inner) { +- pr_debug("map '%s': inner def can't be pinned.\n", +- map->name); ++ pr_warn("map '%s': inner def can't be pinned.\n", map_name); + return -EINVAL; + } +- if (!get_map_field_int(map->name, obj->btf, m, &val)) ++ if (!get_map_field_int(map_name, btf, m, &val)) + return -EINVAL; +- pr_debug("map '%s': found pinning = %u.\n", +- map->name, val); +- +- if (val != LIBBPF_PIN_NONE && +- val != LIBBPF_PIN_BY_NAME) { ++ if (val != LIBBPF_PIN_NONE && val != LIBBPF_PIN_BY_NAME) { + pr_warn("map '%s': invalid pinning value %u.\n", +- map->name, val); ++ map_name, val); + return -EINVAL; + } +- if (val == LIBBPF_PIN_BY_NAME) { +- err = build_map_pin_path(map, pin_root_path); +- if (err) { +- pr_warn("map '%s': couldn't build pin path.\n", +- map->name); +- return err; +- } +- } ++ map_def->pinning = val; ++ map_def->parts |= MAP_DEF_PINNING; + } else { + if (strict) { +- pr_warn("map '%s': unknown field '%s'.\n", +- map->name, name); ++ pr_warn("map '%s': unknown field '%s'.\n", map_name, name); + return -ENOTSUP; + } +- pr_debug("map '%s': ignoring unknown field '%s'.\n", +- map->name, name); ++ pr_debug("map '%s': ignoring unknown field '%s'.\n", map_name, name); + } + } + +- if (map->def.type == BPF_MAP_TYPE_UNSPEC) { +- pr_warn("map '%s': map type isn't specified.\n", map->name); ++ if (map_def->map_type == BPF_MAP_TYPE_UNSPEC) { ++ pr_warn("map '%s': map type isn't specified.\n", map_name); + return -EINVAL; + } + + return 0; + } + ++static void fill_map_from_def(struct bpf_map *map, const struct btf_map_def *def) ++{ ++ map->def.type = def->map_type; ++ map->def.key_size = def->key_size; ++ map->def.value_size = def->value_size; ++ map->def.max_entries = def->max_entries; ++ map->def.map_flags = def->map_flags; ++ ++ map->numa_node = def->numa_node; ++ map->btf_key_type_id = def->key_type_id; ++ map->btf_value_type_id = def->value_type_id; ++ ++ if (def->parts & MAP_DEF_MAP_TYPE) ++ pr_debug("map '%s': found type = %u.\n", map->name, def->map_type); ++ ++ if (def->parts & MAP_DEF_KEY_TYPE) ++ pr_debug("map '%s': found key [%u], sz = %u.\n", ++ map->name, def->key_type_id, def->key_size); ++ else if (def->parts & MAP_DEF_KEY_SIZE) ++ pr_debug("map '%s': found key_size = %u.\n", map->name, def->key_size); ++ ++ if (def->parts & MAP_DEF_VALUE_TYPE) ++ pr_debug("map '%s': found value [%u], sz = %u.\n", ++ map->name, def->value_type_id, def->value_size); ++ else if (def->parts & MAP_DEF_VALUE_SIZE) ++ pr_debug("map '%s': found value_size = %u.\n", map->name, def->value_size); ++ ++ if (def->parts & MAP_DEF_MAX_ENTRIES) ++ pr_debug("map '%s': found max_entries = %u.\n", map->name, def->max_entries); ++ if (def->parts & MAP_DEF_MAP_FLAGS) ++ pr_debug("map '%s': found map_flags = %u.\n", map->name, def->map_flags); ++ if (def->parts & MAP_DEF_PINNING) ++ pr_debug("map '%s': found pinning = %u.\n", map->name, def->pinning); ++ if (def->parts & MAP_DEF_NUMA_NODE) ++ pr_debug("map '%s': found numa_node = %u.\n", map->name, def->numa_node); ++ ++ if (def->parts & MAP_DEF_INNER_MAP) ++ pr_debug("map '%s': found inner map definition.\n", map->name); ++} ++ ++static const char *btf_var_linkage_str(__u32 linkage) ++{ ++ switch (linkage) { ++ case BTF_VAR_STATIC: return "static"; ++ case BTF_VAR_GLOBAL_ALLOCATED: return "global"; ++ case BTF_VAR_GLOBAL_EXTERN: return "extern"; ++ default: return "unknown"; ++ } ++} ++ + static int bpf_object__init_user_btf_map(struct bpf_object *obj, + const struct btf_type *sec, + int var_idx, int sec_idx, + const Elf_Data *data, bool strict, + const char *pin_root_path) + { ++ struct btf_map_def map_def = {}, inner_def = {}; + const struct btf_type *var, *def; + const struct btf_var_secinfo *vi; + const struct btf_var *var_extra; + const char *map_name; + struct bpf_map *map; ++ int err; + + vi = btf_var_secinfos(sec) + var_idx; + var = btf__type_by_id(obj->btf, vi->type); +@@ -2274,10 +2314,9 @@ static int bpf_object__init_user_btf_map + map_name, btf_kind_str(var)); + return -EINVAL; + } +- if (var_extra->linkage != BTF_VAR_GLOBAL_ALLOCATED && +- var_extra->linkage != BTF_VAR_STATIC) { +- pr_warn("map '%s': unsupported var linkage %u.\n", +- map_name, var_extra->linkage); ++ if (var_extra->linkage != BTF_VAR_GLOBAL_ALLOCATED) { ++ pr_warn("map '%s': unsupported map linkage %s.\n", ++ map_name, btf_var_linkage_str(var_extra->linkage)); + return -EOPNOTSUPP; + } + +@@ -2308,7 +2347,35 @@ static int bpf_object__init_user_btf_map + pr_debug("map '%s': at sec_idx %d, offset %zu.\n", + map_name, map->sec_idx, map->sec_offset); + +- return parse_btf_map_def(obj, map, def, strict, false, pin_root_path); ++ err = parse_btf_map_def(map->name, obj->btf, def, strict, &map_def, &inner_def); ++ if (err) ++ return err; ++ ++ fill_map_from_def(map, &map_def); ++ ++ if (map_def.pinning == LIBBPF_PIN_BY_NAME) { ++ err = build_map_pin_path(map, pin_root_path); ++ if (err) { ++ pr_warn("map '%s': couldn't build pin path.\n", map->name); ++ return err; ++ } ++ } ++ ++ if (map_def.parts & MAP_DEF_INNER_MAP) { ++ map->inner_map = calloc(1, sizeof(*map->inner_map)); ++ if (!map->inner_map) ++ return -ENOMEM; ++ map->inner_map->fd = -1; ++ map->inner_map->sec_idx = sec_idx; ++ map->inner_map->name = malloc(strlen(map_name) + sizeof(".inner") + 1); ++ if (!map->inner_map->name) ++ return -ENOMEM; ++ sprintf(map->inner_map->name, "%s.inner", map_name); ++ ++ fill_map_from_def(map->inner_map, &inner_def); ++ } ++ ++ return 0; + } + + static int bpf_object__init_user_btf_maps(struct bpf_object *obj, bool strict, +@@ -2610,7 +2677,7 @@ static int bpf_object__sanitize_and_load + { + struct btf *kern_btf = obj->btf; + bool btf_mandatory, sanitize; +- int err = 0; ++ int i, err = 0; + + if (!obj->btf) + return 0; +@@ -2624,6 +2691,38 @@ static int bpf_object__sanitize_and_load + return 0; + } + ++ /* Even though some subprogs are global/weak, user might prefer more ++ * permissive BPF verification process that BPF verifier performs for ++ * static functions, taking into account more context from the caller ++ * functions. In such case, they need to mark such subprogs with ++ * __attribute__((visibility("hidden"))) and libbpf will adjust ++ * corresponding FUNC BTF type to be marked as static and trigger more ++ * involved BPF verification process. ++ */ ++ for (i = 0; i < obj->nr_programs; i++) { ++ struct bpf_program *prog = &obj->programs[i]; ++ struct btf_type *t; ++ const char *name; ++ int j, n; ++ ++ if (!prog->mark_btf_static || !prog_is_subprog(obj, prog)) ++ continue; ++ ++ n = btf__get_nr_types(obj->btf); ++ for (j = 1; j <= n; j++) { ++ t = btf_type_by_id(obj->btf, j); ++ if (!btf_is_func(t) || btf_func_linkage(t) != BTF_FUNC_GLOBAL) ++ continue; ++ ++ name = btf__str_by_offset(obj->btf, t->name_off); ++ if (strcmp(name, prog->name) != 0) ++ continue; ++ ++ t->info = btf_type_info(BTF_KIND_FUNC, BTF_FUNC_STATIC, 0); ++ break; ++ } ++ } ++ + sanitize = btf_needs_sanitization(obj); + if (sanitize) { + const void *raw_data; +@@ -2774,26 +2873,6 @@ static Elf_Data *elf_sec_data(const stru + return data; + } + +-static int elf_sym_by_sec_off(const struct bpf_object *obj, size_t sec_idx, +- size_t off, __u32 sym_type, GElf_Sym *sym) +-{ +- Elf_Data *symbols = obj->efile.symbols; +- size_t n = symbols->d_size / sizeof(GElf_Sym); +- int i; +- +- for (i = 0; i < n; i++) { +- if (!gelf_getsym(symbols, i, sym)) +- continue; +- if (sym->st_shndx != sec_idx || sym->st_value != off) +- continue; +- if (GELF_ST_TYPE(sym->st_info) != sym_type) +- continue; +- return 0; +- } +- +- return -ENOENT; +-} +- + static bool is_sec_name_dwarf(const char *name) + { + /* approximation, but the actual list is too long */ +@@ -2807,7 +2886,7 @@ static bool ignore_elf_section(GElf_Shdr + return true; + + /* ignore .llvm_addrsig section as well */ +- if (hdr->sh_type == 0x6FFF4C03 /* SHT_LLVM_ADDRSIG */) ++ if (hdr->sh_type == SHT_LLVM_ADDRSIG) + return true; + + /* no subprograms will lead to an empty .text section, ignore it */ +@@ -3017,7 +3096,7 @@ static bool sym_is_subprog(const GElf_Sy + static int find_extern_btf_id(const struct btf *btf, const char *ext_name) + { + const struct btf_type *t; +- const char *var_name; ++ const char *tname; + int i, n; + + if (!btf) +@@ -3027,14 +3106,18 @@ static int find_extern_btf_id(const stru + for (i = 1; i <= n; i++) { + t = btf__type_by_id(btf, i); + +- if (!btf_is_var(t)) ++ if (!btf_is_var(t) && !btf_is_func(t)) + continue; + +- var_name = btf__name_by_offset(btf, t->name_off); +- if (strcmp(var_name, ext_name)) ++ tname = btf__name_by_offset(btf, t->name_off); ++ if (strcmp(tname, ext_name)) + continue; + +- if (btf_var(t)->linkage != BTF_VAR_GLOBAL_EXTERN) ++ if (btf_is_var(t) && ++ btf_var(t)->linkage != BTF_VAR_GLOBAL_EXTERN) ++ return -EINVAL; ++ ++ if (btf_is_func(t) && btf_func_linkage(t) != BTF_FUNC_EXTERN) + return -EINVAL; + + return i; +@@ -3147,12 +3230,51 @@ static int find_int_btf_id(const struct + return 0; + } + ++static int add_dummy_ksym_var(struct btf *btf) ++{ ++ int i, int_btf_id, sec_btf_id, dummy_var_btf_id; ++ const struct btf_var_secinfo *vs; ++ const struct btf_type *sec; ++ ++ if (!btf) ++ return 0; ++ ++ sec_btf_id = btf__find_by_name_kind(btf, KSYMS_SEC, ++ BTF_KIND_DATASEC); ++ if (sec_btf_id < 0) ++ return 0; ++ ++ sec = btf__type_by_id(btf, sec_btf_id); ++ vs = btf_var_secinfos(sec); ++ for (i = 0; i < btf_vlen(sec); i++, vs++) { ++ const struct btf_type *vt; ++ ++ vt = btf__type_by_id(btf, vs->type); ++ if (btf_is_func(vt)) ++ break; ++ } ++ ++ /* No func in ksyms sec. No need to add dummy var. */ ++ if (i == btf_vlen(sec)) ++ return 0; ++ ++ int_btf_id = find_int_btf_id(btf); ++ dummy_var_btf_id = btf__add_var(btf, ++ "dummy_ksym", ++ BTF_VAR_GLOBAL_ALLOCATED, ++ int_btf_id); ++ if (dummy_var_btf_id < 0) ++ pr_warn("cannot create a dummy_ksym var\n"); ++ ++ return dummy_var_btf_id; ++} ++ + static int bpf_object__collect_externs(struct bpf_object *obj) + { + struct btf_type *sec, *kcfg_sec = NULL, *ksym_sec = NULL; + const struct btf_type *t; + struct extern_desc *ext; +- int i, n, off; ++ int i, n, off, dummy_var_btf_id; + const char *ext_name, *sec_name; + Elf_Scn *scn; + GElf_Shdr sh; +@@ -3164,6 +3286,10 @@ static int bpf_object__collect_externs(s + if (elf_sec_hdr(obj, scn, &sh)) + return -LIBBPF_ERRNO__FORMAT; + ++ dummy_var_btf_id = add_dummy_ksym_var(obj->btf); ++ if (dummy_var_btf_id < 0) ++ return dummy_var_btf_id; ++ + n = sh.sh_size / sh.sh_entsize; + pr_debug("looking for externs among %d symbols...\n", n); + +@@ -3208,6 +3334,11 @@ static int bpf_object__collect_externs(s + sec_name = btf__name_by_offset(obj->btf, sec->name_off); + + if (strcmp(sec_name, KCONFIG_SEC) == 0) { ++ if (btf_is_func(t)) { ++ pr_warn("extern function %s is unsupported under %s section\n", ++ ext->name, KCONFIG_SEC); ++ return -ENOTSUP; ++ } + kcfg_sec = sec; + ext->type = EXT_KCFG; + ext->kcfg.sz = btf__resolve_size(obj->btf, t->type); +@@ -3229,6 +3360,11 @@ static int bpf_object__collect_externs(s + return -ENOTSUP; + } + } else if (strcmp(sec_name, KSYMS_SEC) == 0) { ++ if (btf_is_func(t) && ext->is_weak) { ++ pr_warn("extern weak function %s is unsupported\n", ++ ext->name); ++ return -ENOTSUP; ++ } + ksym_sec = sec; + ext->type = EXT_KSYM; + skip_mods_and_typedefs(obj->btf, t->type, +@@ -3255,7 +3391,14 @@ static int bpf_object__collect_externs(s + * extern variables in DATASEC + */ + int int_btf_id = find_int_btf_id(obj->btf); ++ /* For extern function, a dummy_var added earlier ++ * will be used to replace the vs->type and ++ * its name string will be used to refill ++ * the missing param's name. ++ */ ++ const struct btf_type *dummy_var; + ++ dummy_var = btf__type_by_id(obj->btf, dummy_var_btf_id); + for (i = 0; i < obj->nr_extern; i++) { + ext = &obj->externs[i]; + if (ext->type != EXT_KSYM) +@@ -3274,12 +3417,32 @@ static int bpf_object__collect_externs(s + ext_name = btf__name_by_offset(obj->btf, vt->name_off); + ext = find_extern_by_name(obj, ext_name); + if (!ext) { +- pr_warn("failed to find extern definition for BTF var '%s'\n", +- ext_name); ++ pr_warn("failed to find extern definition for BTF %s '%s'\n", ++ btf_kind_str(vt), ext_name); + return -ESRCH; + } +- btf_var(vt)->linkage = BTF_VAR_GLOBAL_ALLOCATED; +- vt->type = int_btf_id; ++ if (btf_is_func(vt)) { ++ const struct btf_type *func_proto; ++ struct btf_param *param; ++ int j; ++ ++ func_proto = btf__type_by_id(obj->btf, ++ vt->type); ++ param = btf_params(func_proto); ++ /* Reuse the dummy_var string if the ++ * func proto does not have param name. ++ */ ++ for (j = 0; j < btf_vlen(func_proto); j++) ++ if (param[j].type && !param[j].name_off) ++ param[j].name_off = ++ dummy_var->name_off; ++ vs->type = dummy_var_btf_id; ++ vt->info &= ~0xffff; ++ vt->info |= BTF_FUNC_GLOBAL; ++ } else { ++ btf_var(vt)->linkage = BTF_VAR_GLOBAL_ALLOCATED; ++ vt->type = int_btf_id; ++ } + vs->offset = off; + vs->size = sizeof(int); + } +@@ -3409,33 +3572,7 @@ static int bpf_program__record_reloc(str + const char *sym_sec_name; + struct bpf_map *map; + +- reloc_desc->processed = false; +- +- /* sub-program call relocation */ +- if (insn->code == (BPF_JMP | BPF_CALL)) { +- if (insn->src_reg != BPF_PSEUDO_CALL) { +- pr_warn("prog '%s': incorrect bpf_call opcode\n", prog->name); +- return -LIBBPF_ERRNO__RELOC; +- } +- /* text_shndx can be 0, if no default "main" program exists */ +- if (!shdr_idx || shdr_idx != obj->efile.text_shndx) { +- sym_sec_name = elf_sec_name(obj, elf_sec_by_idx(obj, shdr_idx)); +- pr_warn("prog '%s': bad call relo against '%s' in section '%s'\n", +- prog->name, sym_name, sym_sec_name); +- return -LIBBPF_ERRNO__RELOC; +- } +- if (sym->st_value % BPF_INSN_SZ) { +- pr_warn("prog '%s': bad call relo against '%s' at offset %zu\n", +- prog->name, sym_name, (size_t)sym->st_value); +- return -LIBBPF_ERRNO__RELOC; +- } +- reloc_desc->type = RELO_CALL; +- reloc_desc->insn_idx = insn_idx; +- reloc_desc->sym_off = sym->st_value; +- return 0; +- } +- +- if (!is_ldimm64(insn)) { ++ if (!is_call_insn(insn) && !is_ldimm64_insn(insn)) { + pr_warn("prog '%s': invalid relo against '%s' for insns[%d].code 0x%x\n", + prog->name, sym_name, insn_idx, insn->code); + return -LIBBPF_ERRNO__RELOC; +@@ -3458,12 +3595,39 @@ static int bpf_program__record_reloc(str + } + pr_debug("prog '%s': found extern #%d '%s' (sym %d) for insn #%u\n", + prog->name, i, ext->name, ext->sym_idx, insn_idx); +- reloc_desc->type = RELO_EXTERN; ++ if (insn->code == (BPF_JMP | BPF_CALL)) ++ reloc_desc->type = RELO_EXTERN_FUNC; ++ else ++ reloc_desc->type = RELO_EXTERN_VAR; + reloc_desc->insn_idx = insn_idx; + reloc_desc->sym_off = i; /* sym_off stores extern index */ + return 0; + } + ++ /* sub-program call relocation */ ++ if (is_call_insn(insn)) { ++ if (insn->src_reg != BPF_PSEUDO_CALL) { ++ pr_warn("prog '%s': incorrect bpf_call opcode\n", prog->name); ++ return -LIBBPF_ERRNO__RELOC; ++ } ++ /* text_shndx can be 0, if no default "main" program exists */ ++ if (!shdr_idx || shdr_idx != obj->efile.text_shndx) { ++ sym_sec_name = elf_sec_name(obj, elf_sec_by_idx(obj, shdr_idx)); ++ pr_warn("prog '%s': bad call relo against '%s' in section '%s'\n", ++ prog->name, sym_name, sym_sec_name); ++ return -LIBBPF_ERRNO__RELOC; ++ } ++ if (sym->st_value % BPF_INSN_SZ) { ++ pr_warn("prog '%s': bad call relo against '%s' at offset %zu\n", ++ prog->name, sym_name, (size_t)sym->st_value); ++ return -LIBBPF_ERRNO__RELOC; ++ } ++ reloc_desc->type = RELO_CALL; ++ reloc_desc->insn_idx = insn_idx; ++ reloc_desc->sym_off = sym->st_value; ++ return 0; ++ } ++ + if (!shdr_idx || shdr_idx >= SHN_LORESERVE) { + pr_warn("prog '%s': invalid relo against '%s' in special section 0x%x; forgot to initialize global var?..\n", + prog->name, sym_name, shdr_idx); +@@ -3590,11 +3754,16 @@ bpf_object__collect_prog_relos(struct bp + int err, i, nrels; + const char *sym_name; + __u32 insn_idx; ++ Elf_Scn *scn; ++ Elf_Data *scn_data; + GElf_Sym sym; + GElf_Rel rel; + ++ scn = elf_sec_by_idx(obj, sec_idx); ++ scn_data = elf_sec_data(obj, scn); ++ + relo_sec_name = elf_sec_str(obj, shdr->sh_name); +- sec_name = elf_sec_name(obj, elf_sec_by_idx(obj, sec_idx)); ++ sec_name = elf_sec_name(obj, scn); + if (!relo_sec_name || !sec_name) + return -EINVAL; + +@@ -3612,7 +3781,8 @@ bpf_object__collect_prog_relos(struct bp + relo_sec_name, (size_t)GELF_R_SYM(rel.r_info), i); + return -LIBBPF_ERRNO__FORMAT; + } +- if (rel.r_offset % BPF_INSN_SZ) { ++ ++ if (rel.r_offset % BPF_INSN_SZ || rel.r_offset >= scn_data->d_size) { + pr_warn("sec '%s': invalid offset 0x%zx for relo #%d\n", + relo_sec_name, (size_t)GELF_R_SYM(rel.r_info), i); + return -LIBBPF_ERRNO__FORMAT; +@@ -3636,9 +3806,9 @@ bpf_object__collect_prog_relos(struct bp + + prog = find_prog_by_sec_insn(obj, sec_idx, insn_idx); + if (!prog) { +- pr_warn("sec '%s': relo #%d: program not found in section '%s' for insn #%u\n", ++ pr_debug("sec '%s': relo #%d: couldn't find program in section '%s' for insn #%u, probably overridden weak function, skipping...\n", + relo_sec_name, i, sec_name, insn_idx); +- return -LIBBPF_ERRNO__RELOC; ++ continue; + } + + relos = libbpf_reallocarray(prog->reloc_desc, +@@ -3753,6 +3923,14 @@ __u32 bpf_map__max_entries(const struct + return map->def.max_entries; + } + ++struct bpf_map *bpf_map__inner_map(struct bpf_map *map) ++{ ++ if (!bpf_map_type__is_map_in_map(map->def.type)) ++ return NULL; ++ ++ return map->inner_map; ++} ++ + int bpf_map__set_max_entries(struct bpf_map *map, __u32 max_entries) + { + if (map->fd >= 0) +@@ -4867,8 +5045,8 @@ static int load_module_btfs(struct bpf_o + goto err_out; + } + +- err = btf_ensure_mem((void **)&obj->btf_modules, &obj->btf_module_cap, +- sizeof(*obj->btf_modules), obj->btf_module_cnt + 1); ++ err = libbpf_ensure_mem((void **)&obj->btf_modules, &obj->btf_module_cap, ++ sizeof(*obj->btf_modules), obj->btf_module_cnt + 1); + if (err) + goto err_out; + +@@ -4960,6 +5138,7 @@ err_out: + * least one of enums should be anonymous; + * - for ENUMs, check sizes, names are ignored; + * - for INT, size and signedness are ignored; ++ * - any two FLOATs are always compatible; + * - for ARRAY, dimensionality is ignored, element types are checked for + * compatibility recursively; + * - everything else shouldn't be ever a target of relocation. +@@ -4986,6 +5165,7 @@ recur: + + switch (btf_kind(local_type)) { + case BTF_KIND_PTR: ++ case BTF_KIND_FLOAT: + return 1; + case BTF_KIND_FWD: + case BTF_KIND_ENUM: { +@@ -5703,7 +5883,7 @@ poison: + /* poison second part of ldimm64 to avoid confusing error from + * verifier about "unknown opcode 00" + */ +- if (is_ldimm64(insn)) ++ if (is_ldimm64_insn(insn)) + bpf_core_poison_insn(prog, relo_idx, insn_idx + 1, insn + 1); + bpf_core_poison_insn(prog, relo_idx, insn_idx, insn); + return 0; +@@ -5779,7 +5959,7 @@ poison: + case BPF_LD: { + __u64 imm; + +- if (!is_ldimm64(insn) || ++ if (!is_ldimm64_insn(insn) || + insn[0].src_reg != 0 || insn[0].off != 0 || + insn_idx + 1 >= prog->insns_cnt || + insn[1].code != 0 || insn[1].dst_reg != 0 || +@@ -6090,8 +6270,8 @@ patch_insn: + /* bpf_core_patch_insn() should know how to handle missing targ_spec */ + err = bpf_core_patch_insn(prog, relo, relo_idx, &targ_res); + if (err) { +- pr_warn("prog '%s': relo #%d: failed to patch insn at offset %d: %d\n", +- prog->name, relo_idx, relo->insn_off, err); ++ pr_warn("prog '%s': relo #%d: failed to patch insn #%zu: %d\n", ++ prog->name, relo_idx, relo->insn_off / BPF_INSN_SZ, err); + return -EINVAL; + } + +@@ -6213,15 +6393,13 @@ bpf_object__relocate_data(struct bpf_obj + case RELO_LD64: + insn[0].src_reg = BPF_PSEUDO_MAP_FD; + insn[0].imm = obj->maps[relo->map_idx].fd; +- relo->processed = true; + break; + case RELO_DATA: + insn[0].src_reg = BPF_PSEUDO_MAP_VALUE; + insn[1].imm = insn[0].imm + relo->sym_off; + insn[0].imm = obj->maps[relo->map_idx].fd; +- relo->processed = true; + break; +- case RELO_EXTERN: ++ case RELO_EXTERN_VAR: + ext = &obj->externs[relo->sym_off]; + if (ext->type == EXT_KCFG) { + insn[0].src_reg = BPF_PSEUDO_MAP_VALUE; +@@ -6237,7 +6415,11 @@ bpf_object__relocate_data(struct bpf_obj + insn[1].imm = ext->ksym.addr >> 32; + } + } +- relo->processed = true; ++ break; ++ case RELO_EXTERN_FUNC: ++ ext = &obj->externs[relo->sym_off]; ++ insn[0].src_reg = BPF_PSEUDO_KFUNC_CALL; ++ insn[0].imm = ext->ksym.kernel_btf_id; + break; + case RELO_SUBPROG_ADDR: + insn[0].src_reg = BPF_PSEUDO_FUNC; +@@ -6523,9 +6705,6 @@ bpf_object__reloc_code(struct bpf_object + * different main programs */ + insn->imm = subprog->sub_insn_off - (prog->sub_insn_off + insn_idx) - 1; + +- if (relo) +- relo->processed = true; +- + pr_debug("prog '%s': insn #%zu relocated, imm %d points to subprog '%s' (now at %zu offset)\n", + prog->name, insn_idx, insn->imm, subprog->name, subprog->sub_insn_off); + } +@@ -6618,7 +6797,7 @@ static int + bpf_object__relocate_calls(struct bpf_object *obj, struct bpf_program *prog) + { + struct bpf_program *subprog; +- int i, j, err; ++ int i, err; + + /* mark all subprogs as not relocated (yet) within the context of + * current main program +@@ -6629,9 +6808,6 @@ bpf_object__relocate_calls(struct bpf_ob + continue; + + subprog->sub_insn_off = 0; +- for (j = 0; j < subprog->nr_reloc; j++) +- if (subprog->reloc_desc[j].type == RELO_CALL) +- subprog->reloc_desc[j].processed = false; + } + + err = bpf_object__reloc_code(obj, prog, prog); +@@ -6878,7 +7054,7 @@ static bool insn_is_helper_call(struct b + return false; + } + +-static int bpf_object__sanitize_prog(struct bpf_object* obj, struct bpf_program *prog) ++static int bpf_object__sanitize_prog(struct bpf_object *obj, struct bpf_program *prog) + { + struct bpf_insn *insn = prog->insns; + enum bpf_func_id func_id; +@@ -7359,6 +7535,7 @@ static int bpf_object__read_kallsyms_fil + { + char sym_type, sym_name[500]; + unsigned long long sym_addr; ++ const struct btf_type *t; + struct extern_desc *ext; + int ret, err = 0; + FILE *f; +@@ -7385,6 +7562,10 @@ static int bpf_object__read_kallsyms_fil + if (!ext || ext->type != EXT_KSYM) + continue; + ++ t = btf__type_by_id(obj->btf, ext->btf_id); ++ if (!btf_is_var(t)) ++ continue; ++ + if (ext->is_set && ext->ksym.addr != sym_addr) { + pr_warn("extern (ksym) '%s' resolution is ambiguous: 0x%llx or 0x%llx\n", + sym_name, ext->ksym.addr, sym_addr); +@@ -7403,75 +7584,151 @@ out: + return err; + } + +-static int bpf_object__resolve_ksyms_btf_id(struct bpf_object *obj) ++static int find_ksym_btf_id(struct bpf_object *obj, const char *ksym_name, ++ __u16 kind, struct btf **res_btf, ++ int *res_btf_fd) + { +- struct extern_desc *ext; ++ int i, id, btf_fd, err; + struct btf *btf; +- int i, j, id, btf_fd, err; + +- for (i = 0; i < obj->nr_extern; i++) { +- const struct btf_type *targ_var, *targ_type; +- __u32 targ_type_id, local_type_id; +- const char *targ_var_name; +- int ret; +- +- ext = &obj->externs[i]; +- if (ext->type != EXT_KSYM || !ext->ksym.type_id) +- continue; ++ btf = obj->btf_vmlinux; ++ btf_fd = 0; ++ id = btf__find_by_name_kind(btf, ksym_name, kind); + +- btf = obj->btf_vmlinux; +- btf_fd = 0; +- id = btf__find_by_name_kind(btf, ext->name, BTF_KIND_VAR); +- if (id == -ENOENT) { +- err = load_module_btfs(obj); +- if (err) +- return err; ++ if (id == -ENOENT) { ++ err = load_module_btfs(obj); ++ if (err) ++ return err; + +- for (j = 0; j < obj->btf_module_cnt; j++) { +- btf = obj->btf_modules[j].btf; +- /* we assume module BTF FD is always >0 */ +- btf_fd = obj->btf_modules[j].fd; +- id = btf__find_by_name_kind(btf, ext->name, BTF_KIND_VAR); +- if (id != -ENOENT) +- break; +- } +- } +- if (id <= 0) { +- pr_warn("extern (ksym) '%s': failed to find BTF ID in kernel BTF(s).\n", +- ext->name); +- return -ESRCH; ++ for (i = 0; i < obj->btf_module_cnt; i++) { ++ btf = obj->btf_modules[i].btf; ++ /* we assume module BTF FD is always >0 */ ++ btf_fd = obj->btf_modules[i].fd; ++ id = btf__find_by_name_kind(btf, ksym_name, kind); ++ if (id != -ENOENT) ++ break; + } ++ } ++ if (id <= 0) { ++ pr_warn("extern (%s ksym) '%s': failed to find BTF ID in kernel BTF(s).\n", ++ __btf_kind_str(kind), ksym_name); ++ return -ESRCH; ++ } + +- /* find local type_id */ +- local_type_id = ext->ksym.type_id; ++ *res_btf = btf; ++ *res_btf_fd = btf_fd; ++ return id; ++} + +- /* find target type_id */ +- targ_var = btf__type_by_id(btf, id); +- targ_var_name = btf__name_by_offset(btf, targ_var->name_off); +- targ_type = skip_mods_and_typedefs(btf, targ_var->type, &targ_type_id); +- +- ret = bpf_core_types_are_compat(obj->btf, local_type_id, +- btf, targ_type_id); +- if (ret <= 0) { +- const struct btf_type *local_type; +- const char *targ_name, *local_name; +- +- local_type = btf__type_by_id(obj->btf, local_type_id); +- local_name = btf__name_by_offset(obj->btf, local_type->name_off); +- targ_name = btf__name_by_offset(btf, targ_type->name_off); +- +- pr_warn("extern (ksym) '%s': incompatible types, expected [%d] %s %s, but kernel has [%d] %s %s\n", +- ext->name, local_type_id, +- btf_kind_str(local_type), local_name, targ_type_id, +- btf_kind_str(targ_type), targ_name); +- return -EINVAL; +- } ++static int bpf_object__resolve_ksym_var_btf_id(struct bpf_object *obj, ++ struct extern_desc *ext) ++{ ++ const struct btf_type *targ_var, *targ_type; ++ __u32 targ_type_id, local_type_id; ++ const char *targ_var_name; ++ int id, btf_fd = 0, err; ++ struct btf *btf = NULL; ++ ++ id = find_ksym_btf_id(obj, ext->name, BTF_KIND_VAR, &btf, &btf_fd); ++ if (id < 0) ++ return id; ++ ++ /* find local type_id */ ++ local_type_id = ext->ksym.type_id; ++ ++ /* find target type_id */ ++ targ_var = btf__type_by_id(btf, id); ++ targ_var_name = btf__name_by_offset(btf, targ_var->name_off); ++ targ_type = skip_mods_and_typedefs(btf, targ_var->type, &targ_type_id); ++ ++ err = bpf_core_types_are_compat(obj->btf, local_type_id, ++ btf, targ_type_id); ++ if (err <= 0) { ++ const struct btf_type *local_type; ++ const char *targ_name, *local_name; + +- ext->is_set = true; +- ext->ksym.kernel_btf_obj_fd = btf_fd; +- ext->ksym.kernel_btf_id = id; +- pr_debug("extern (ksym) '%s': resolved to [%d] %s %s\n", +- ext->name, id, btf_kind_str(targ_var), targ_var_name); ++ local_type = btf__type_by_id(obj->btf, local_type_id); ++ local_name = btf__name_by_offset(obj->btf, local_type->name_off); ++ targ_name = btf__name_by_offset(btf, targ_type->name_off); ++ ++ pr_warn("extern (var ksym) '%s': incompatible types, expected [%d] %s %s, but kernel has [%d] %s %s\n", ++ ext->name, local_type_id, ++ btf_kind_str(local_type), local_name, targ_type_id, ++ btf_kind_str(targ_type), targ_name); ++ return -EINVAL; ++ } ++ ++ ext->is_set = true; ++ ext->ksym.kernel_btf_obj_fd = btf_fd; ++ ext->ksym.kernel_btf_id = id; ++ pr_debug("extern (var ksym) '%s': resolved to [%d] %s %s\n", ++ ext->name, id, btf_kind_str(targ_var), targ_var_name); ++ ++ return 0; ++} ++ ++static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj, ++ struct extern_desc *ext) ++{ ++ int local_func_proto_id, kfunc_proto_id, kfunc_id; ++ const struct btf_type *kern_func; ++ struct btf *kern_btf = NULL; ++ int ret, kern_btf_fd = 0; ++ ++ local_func_proto_id = ext->ksym.type_id; ++ ++ kfunc_id = find_ksym_btf_id(obj, ext->name, BTF_KIND_FUNC, ++ &kern_btf, &kern_btf_fd); ++ if (kfunc_id < 0) { ++ pr_warn("extern (func ksym) '%s': not found in kernel BTF\n", ++ ext->name); ++ return kfunc_id; ++ } ++ ++ if (kern_btf != obj->btf_vmlinux) { ++ pr_warn("extern (func ksym) '%s': function in kernel module is not supported\n", ++ ext->name); ++ return -ENOTSUP; ++ } ++ ++ kern_func = btf__type_by_id(kern_btf, kfunc_id); ++ kfunc_proto_id = kern_func->type; ++ ++ ret = bpf_core_types_are_compat(obj->btf, local_func_proto_id, ++ kern_btf, kfunc_proto_id); ++ if (ret <= 0) { ++ pr_warn("extern (func ksym) '%s': func_proto [%d] incompatible with kernel [%d]\n", ++ ext->name, local_func_proto_id, kfunc_proto_id); ++ return -EINVAL; ++ } ++ ++ ext->is_set = true; ++ ext->ksym.kernel_btf_obj_fd = kern_btf_fd; ++ ext->ksym.kernel_btf_id = kfunc_id; ++ pr_debug("extern (func ksym) '%s': resolved to kernel [%d]\n", ++ ext->name, kfunc_id); ++ ++ return 0; ++} ++ ++static int bpf_object__resolve_ksyms_btf_id(struct bpf_object *obj) ++{ ++ const struct btf_type *t; ++ struct extern_desc *ext; ++ int i, err; ++ ++ for (i = 0; i < obj->nr_extern; i++) { ++ ext = &obj->externs[i]; ++ if (ext->type != EXT_KSYM || !ext->ksym.type_id) ++ continue; ++ ++ t = btf__type_by_id(obj->btf, ext->btf_id); ++ if (btf_is_var(t)) ++ err = bpf_object__resolve_ksym_var_btf_id(obj, ext); ++ else ++ err = bpf_object__resolve_ksym_func_btf_id(obj, ext); ++ if (err) ++ return err; + } + return 0; + } +@@ -8278,6 +8535,16 @@ int bpf_object__btf_fd(const struct bpf_ + return obj->btf ? btf__fd(obj->btf) : -1; + } + ++int bpf_object__set_kversion(struct bpf_object *obj, __u32 kern_version) ++{ ++ if (obj->loaded) ++ return -EINVAL; ++ ++ obj->kern_version = kern_version; ++ ++ return 0; ++} ++ + int bpf_object__set_priv(struct bpf_object *obj, void *priv, + bpf_object_clear_priv_t clear_priv) + { +@@ -8466,7 +8733,7 @@ int bpf_program__nth_fd(const struct bpf + return fd; + } + +-enum bpf_prog_type bpf_program__get_type(struct bpf_program *prog) ++enum bpf_prog_type bpf_program__get_type(const struct bpf_program *prog) + { + return prog->type; + } +@@ -8511,7 +8778,7 @@ BPF_PROG_TYPE_FNS(extension, BPF_PROG_TY + BPF_PROG_TYPE_FNS(sk_lookup, BPF_PROG_TYPE_SK_LOOKUP); + + enum bpf_attach_type +-bpf_program__get_expected_attach_type(struct bpf_program *prog) ++bpf_program__get_expected_attach_type(const struct bpf_program *prog) + { + return prog->expected_attach_type; + } +@@ -9287,6 +9554,7 @@ int bpf_map__set_inner_map_fd(struct bpf + pr_warn("error: inner_map_fd already specified\n"); + return -EINVAL; + } ++ zfree(&map->inner_map); + map->inner_map_fd = fd; + return 0; + } +Index: dwarves-dfsg-1.21/lib/bpf/src/libbpf.h +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/libbpf.h ++++ dwarves-dfsg-1.21/lib/bpf/src/libbpf.h +@@ -143,6 +143,7 @@ LIBBPF_API int bpf_object__unload(struct + + LIBBPF_API const char *bpf_object__name(const struct bpf_object *obj); + LIBBPF_API unsigned int bpf_object__kversion(const struct bpf_object *obj); ++LIBBPF_API int bpf_object__set_kversion(struct bpf_object *obj, __u32 kern_version); + + struct btf; + LIBBPF_API struct btf *bpf_object__btf(const struct bpf_object *obj); +@@ -361,12 +362,12 @@ LIBBPF_API int bpf_program__set_struct_o + LIBBPF_API int bpf_program__set_extension(struct bpf_program *prog); + LIBBPF_API int bpf_program__set_sk_lookup(struct bpf_program *prog); + +-LIBBPF_API enum bpf_prog_type bpf_program__get_type(struct bpf_program *prog); ++LIBBPF_API enum bpf_prog_type bpf_program__get_type(const struct bpf_program *prog); + LIBBPF_API void bpf_program__set_type(struct bpf_program *prog, + enum bpf_prog_type type); + + LIBBPF_API enum bpf_attach_type +-bpf_program__get_expected_attach_type(struct bpf_program *prog); ++bpf_program__get_expected_attach_type(const struct bpf_program *prog); + LIBBPF_API void + bpf_program__set_expected_attach_type(struct bpf_program *prog, + enum bpf_attach_type type); +@@ -479,6 +480,7 @@ LIBBPF_API int bpf_map__pin(struct bpf_m + LIBBPF_API int bpf_map__unpin(struct bpf_map *map, const char *path); + + LIBBPF_API int bpf_map__set_inner_map_fd(struct bpf_map *map, int fd); ++LIBBPF_API struct bpf_map *bpf_map__inner_map(struct bpf_map *map); + + LIBBPF_API long libbpf_get_error(const void *ptr); + +@@ -496,6 +498,7 @@ LIBBPF_API int bpf_prog_load_xattr(const + LIBBPF_API int bpf_prog_load(const char *file, enum bpf_prog_type type, + struct bpf_object **pobj, int *prog_fd); + ++/* XDP related API */ + struct xdp_link_info { + __u32 prog_id; + __u32 drv_prog_id; +@@ -507,6 +510,7 @@ struct xdp_link_info { + struct bpf_xdp_set_link_opts { + size_t sz; + int old_fd; ++ size_t :0; + }; + #define bpf_xdp_set_link_opts__last_field old_fd + +@@ -517,6 +521,49 @@ LIBBPF_API int bpf_get_link_xdp_id(int i + LIBBPF_API int bpf_get_link_xdp_info(int ifindex, struct xdp_link_info *info, + size_t info_size, __u32 flags); + ++/* TC related API */ ++enum bpf_tc_attach_point { ++ BPF_TC_INGRESS = 1 << 0, ++ BPF_TC_EGRESS = 1 << 1, ++ BPF_TC_CUSTOM = 1 << 2, ++}; ++ ++#define BPF_TC_PARENT(a, b) \ ++ ((((a) << 16) & 0xFFFF0000U) | ((b) & 0x0000FFFFU)) ++ ++enum bpf_tc_flags { ++ BPF_TC_F_REPLACE = 1 << 0, ++}; ++ ++struct bpf_tc_hook { ++ size_t sz; ++ int ifindex; ++ enum bpf_tc_attach_point attach_point; ++ __u32 parent; ++ size_t :0; ++}; ++#define bpf_tc_hook__last_field parent ++ ++struct bpf_tc_opts { ++ size_t sz; ++ int prog_fd; ++ __u32 flags; ++ __u32 prog_id; ++ __u32 handle; ++ __u32 priority; ++ size_t :0; ++}; ++#define bpf_tc_opts__last_field priority ++ ++LIBBPF_API int bpf_tc_hook_create(struct bpf_tc_hook *hook); ++LIBBPF_API int bpf_tc_hook_destroy(struct bpf_tc_hook *hook); ++LIBBPF_API int bpf_tc_attach(const struct bpf_tc_hook *hook, ++ struct bpf_tc_opts *opts); ++LIBBPF_API int bpf_tc_detach(const struct bpf_tc_hook *hook, ++ const struct bpf_tc_opts *opts); ++LIBBPF_API int bpf_tc_query(const struct bpf_tc_hook *hook, ++ struct bpf_tc_opts *opts); ++ + /* Ring buffer APIs */ + struct ring_buffer; + +@@ -759,6 +806,27 @@ enum libbpf_tristate { + TRI_MODULE = 2, + }; + ++struct bpf_linker_opts { ++ /* size of this struct, for forward/backward compatiblity */ ++ size_t sz; ++}; ++#define bpf_linker_opts__last_field sz ++ ++struct bpf_linker_file_opts { ++ /* size of this struct, for forward/backward compatiblity */ ++ size_t sz; ++}; ++#define bpf_linker_file_opts__last_field sz ++ ++struct bpf_linker; ++ ++LIBBPF_API struct bpf_linker *bpf_linker__new(const char *filename, struct bpf_linker_opts *opts); ++LIBBPF_API int bpf_linker__add_file(struct bpf_linker *linker, ++ const char *filename, ++ const struct bpf_linker_file_opts *opts); ++LIBBPF_API int bpf_linker__finalize(struct bpf_linker *linker); ++LIBBPF_API void bpf_linker__free(struct bpf_linker *linker); ++ + #ifdef __cplusplus + } /* extern "C" */ + #endif +Index: dwarves-dfsg-1.21/lib/bpf/src/libbpf.map +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/libbpf.map ++++ dwarves-dfsg-1.21/lib/bpf/src/libbpf.map +@@ -354,4 +354,16 @@ LIBBPF_0.3.0 { + LIBBPF_0.4.0 { + global: + btf__add_float; ++ btf__add_type; ++ bpf_linker__add_file; ++ bpf_linker__finalize; ++ bpf_linker__free; ++ bpf_linker__new; ++ bpf_map__inner_map; ++ bpf_object__set_kversion; ++ bpf_tc_attach; ++ bpf_tc_detach; ++ bpf_tc_hook_create; ++ bpf_tc_hook_destroy; ++ bpf_tc_query; + } LIBBPF_0.3.0; +Index: dwarves-dfsg-1.21/lib/bpf/src/libbpf_internal.h +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/libbpf_internal.h ++++ dwarves-dfsg-1.21/lib/bpf/src/libbpf_internal.h +@@ -19,6 +19,38 @@ + #pragma GCC poison reallocarray + + #include "libbpf.h" ++#include "btf.h" ++ ++#ifndef EM_BPF ++#define EM_BPF 247 ++#endif ++ ++#ifndef R_BPF_64_64 ++#define R_BPF_64_64 1 ++#endif ++#ifndef R_BPF_64_ABS64 ++#define R_BPF_64_ABS64 2 ++#endif ++#ifndef R_BPF_64_ABS32 ++#define R_BPF_64_ABS32 3 ++#endif ++#ifndef R_BPF_64_32 ++#define R_BPF_64_32 10 ++#endif ++ ++#ifndef SHT_LLVM_ADDRSIG ++#define SHT_LLVM_ADDRSIG 0x6FFF4C03 ++#endif ++ ++/* if libelf is old and doesn't support mmap(), fall back to read() */ ++#ifndef ELF_C_READ_MMAP ++#define ELF_C_READ_MMAP ELF_C_READ ++#endif ++ ++/* Older libelf all end up in this expression, for both 32 and 64 bit */ ++#ifndef GELF_ST_VISIBILITY ++#define GELF_ST_VISIBILITY(o) ((o) & 0x03) ++#endif + + #define BTF_INFO_ENC(kind, kind_flag, vlen) \ + ((!!(kind_flag) << 31) | ((kind) << 24) | ((vlen) & BTF_MAX_VLEN)) +@@ -107,9 +139,58 @@ static inline void *libbpf_reallocarray( + return realloc(ptr, total); + } + +-void *btf_add_mem(void **data, size_t *cap_cnt, size_t elem_sz, +- size_t cur_cnt, size_t max_cnt, size_t add_cnt); +-int btf_ensure_mem(void **data, size_t *cap_cnt, size_t elem_sz, size_t need_cnt); ++struct btf; ++struct btf_type; ++ ++struct btf_type *btf_type_by_id(struct btf *btf, __u32 type_id); ++const char *btf_kind_str(const struct btf_type *t); ++const struct btf_type *skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id); ++ ++static inline enum btf_func_linkage btf_func_linkage(const struct btf_type *t) ++{ ++ return (enum btf_func_linkage)(int)btf_vlen(t); ++} ++ ++static inline __u32 btf_type_info(int kind, int vlen, int kflag) ++{ ++ return (kflag << 31) | (kind << 24) | vlen; ++} ++ ++enum map_def_parts { ++ MAP_DEF_MAP_TYPE = 0x001, ++ MAP_DEF_KEY_TYPE = 0x002, ++ MAP_DEF_KEY_SIZE = 0x004, ++ MAP_DEF_VALUE_TYPE = 0x008, ++ MAP_DEF_VALUE_SIZE = 0x010, ++ MAP_DEF_MAX_ENTRIES = 0x020, ++ MAP_DEF_MAP_FLAGS = 0x040, ++ MAP_DEF_NUMA_NODE = 0x080, ++ MAP_DEF_PINNING = 0x100, ++ MAP_DEF_INNER_MAP = 0x200, ++ ++ MAP_DEF_ALL = 0x3ff, /* combination of all above */ ++}; ++ ++struct btf_map_def { ++ enum map_def_parts parts; ++ __u32 map_type; ++ __u32 key_type_id; ++ __u32 key_size; ++ __u32 value_type_id; ++ __u32 value_size; ++ __u32 max_entries; ++ __u32 map_flags; ++ __u32 numa_node; ++ __u32 pinning; ++}; ++ ++int parse_btf_map_def(const char *map_name, struct btf *btf, ++ const struct btf_type *def_t, bool strict, ++ struct btf_map_def *map_def, struct btf_map_def *inner_def); ++ ++void *libbpf_add_mem(void **data, size_t *cap_cnt, size_t elem_sz, ++ size_t cur_cnt, size_t max_cnt, size_t add_cnt); ++int libbpf_ensure_mem(void **data, size_t *cap_cnt, size_t elem_sz, size_t need_cnt); + + static inline bool libbpf_validate_opts(const char *opts, + size_t opts_sz, size_t user_sz, +@@ -351,4 +432,11 @@ struct bpf_core_relo { + enum bpf_core_relo_kind kind; + }; + ++typedef int (*type_id_visit_fn)(__u32 *type_id, void *ctx); ++typedef int (*str_off_visit_fn)(__u32 *str_off, void *ctx); ++int btf_type_visit_type_ids(struct btf_type *t, type_id_visit_fn visit, void *ctx); ++int btf_type_visit_str_offs(struct btf_type *t, str_off_visit_fn visit, void *ctx); ++int btf_ext_visit_type_ids(struct btf_ext *btf_ext, type_id_visit_fn visit, void *ctx); ++int btf_ext_visit_str_offs(struct btf_ext *btf_ext, str_off_visit_fn visit, void *ctx); ++ + #endif /* __LIBBPF_LIBBPF_INTERNAL_H */ +Index: dwarves-dfsg-1.21/lib/bpf/src/linker.c +=================================================================== +--- /dev/null ++++ dwarves-dfsg-1.21/lib/bpf/src/linker.c +@@ -0,0 +1,2892 @@ ++// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) ++/* ++ * BPF static linker ++ * ++ * Copyright (c) 2021 Facebook ++ */ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "libbpf.h" ++#include "btf.h" ++#include "libbpf_internal.h" ++#include "strset.h" ++ ++#define BTF_EXTERN_SEC ".extern" ++ ++struct src_sec { ++ const char *sec_name; ++ /* positional (not necessarily ELF) index in an array of sections */ ++ int id; ++ /* positional (not necessarily ELF) index of a matching section in a final object file */ ++ int dst_id; ++ /* section data offset in a matching output section */ ++ int dst_off; ++ /* whether section is omitted from the final ELF file */ ++ bool skipped; ++ /* whether section is an ephemeral section, not mapped to an ELF section */ ++ bool ephemeral; ++ ++ /* ELF info */ ++ size_t sec_idx; ++ Elf_Scn *scn; ++ Elf64_Shdr *shdr; ++ Elf_Data *data; ++ ++ /* corresponding BTF DATASEC type ID */ ++ int sec_type_id; ++}; ++ ++struct src_obj { ++ const char *filename; ++ int fd; ++ Elf *elf; ++ /* Section header strings section index */ ++ size_t shstrs_sec_idx; ++ /* SYMTAB section index */ ++ size_t symtab_sec_idx; ++ ++ struct btf *btf; ++ struct btf_ext *btf_ext; ++ ++ /* List of sections (including ephemeral). Slot zero is unused. */ ++ struct src_sec *secs; ++ int sec_cnt; ++ ++ /* mapping of symbol indices from src to dst ELF */ ++ int *sym_map; ++ /* mapping from the src BTF type IDs to dst ones */ ++ int *btf_type_map; ++}; ++ ++/* single .BTF.ext data section */ ++struct btf_ext_sec_data { ++ size_t rec_cnt; ++ __u32 rec_sz; ++ void *recs; ++}; ++ ++struct glob_sym { ++ /* ELF symbol index */ ++ int sym_idx; ++ /* associated section id for .ksyms, .kconfig, etc, but not .extern */ ++ int sec_id; ++ /* extern name offset in STRTAB */ ++ int name_off; ++ /* optional associated BTF type ID */ ++ int btf_id; ++ /* BTF type ID to which VAR/FUNC type is pointing to; used for ++ * rewriting types when extern VAR/FUNC is resolved to a concrete ++ * definition ++ */ ++ int underlying_btf_id; ++ /* sec_var index in the corresponding dst_sec, if exists */ ++ int var_idx; ++ ++ /* extern or resolved/global symbol */ ++ bool is_extern; ++ /* weak or strong symbol, never goes back from strong to weak */ ++ bool is_weak; ++}; ++ ++struct dst_sec { ++ char *sec_name; ++ /* positional (not necessarily ELF) index in an array of sections */ ++ int id; ++ ++ bool ephemeral; ++ ++ /* ELF info */ ++ size_t sec_idx; ++ Elf_Scn *scn; ++ Elf64_Shdr *shdr; ++ Elf_Data *data; ++ ++ /* final output section size */ ++ int sec_sz; ++ /* final output contents of the section */ ++ void *raw_data; ++ ++ /* corresponding STT_SECTION symbol index in SYMTAB */ ++ int sec_sym_idx; ++ ++ /* section's DATASEC variable info, emitted on BTF finalization */ ++ bool has_btf; ++ int sec_var_cnt; ++ struct btf_var_secinfo *sec_vars; ++ ++ /* section's .BTF.ext data */ ++ struct btf_ext_sec_data func_info; ++ struct btf_ext_sec_data line_info; ++ struct btf_ext_sec_data core_relo_info; ++}; ++ ++struct bpf_linker { ++ char *filename; ++ int fd; ++ Elf *elf; ++ Elf64_Ehdr *elf_hdr; ++ ++ /* Output sections metadata */ ++ struct dst_sec *secs; ++ int sec_cnt; ++ ++ struct strset *strtab_strs; /* STRTAB unique strings */ ++ size_t strtab_sec_idx; /* STRTAB section index */ ++ size_t symtab_sec_idx; /* SYMTAB section index */ ++ ++ struct btf *btf; ++ struct btf_ext *btf_ext; ++ ++ /* global (including extern) ELF symbols */ ++ int glob_sym_cnt; ++ struct glob_sym *glob_syms; ++}; ++ ++#define pr_warn_elf(fmt, ...) \ ++ libbpf_print(LIBBPF_WARN, "libbpf: " fmt ": %s\n", ##__VA_ARGS__, elf_errmsg(-1)) ++ ++static int init_output_elf(struct bpf_linker *linker, const char *file); ++ ++static int linker_load_obj_file(struct bpf_linker *linker, const char *filename, ++ const struct bpf_linker_file_opts *opts, ++ struct src_obj *obj); ++static int linker_sanity_check_elf(struct src_obj *obj); ++static int linker_sanity_check_elf_symtab(struct src_obj *obj, struct src_sec *sec); ++static int linker_sanity_check_elf_relos(struct src_obj *obj, struct src_sec *sec); ++static int linker_sanity_check_btf(struct src_obj *obj); ++static int linker_sanity_check_btf_ext(struct src_obj *obj); ++static int linker_fixup_btf(struct src_obj *obj); ++static int linker_append_sec_data(struct bpf_linker *linker, struct src_obj *obj); ++static int linker_append_elf_syms(struct bpf_linker *linker, struct src_obj *obj); ++static int linker_append_elf_sym(struct bpf_linker *linker, struct src_obj *obj, ++ Elf64_Sym *sym, const char *sym_name, int src_sym_idx); ++static int linker_append_elf_relos(struct bpf_linker *linker, struct src_obj *obj); ++static int linker_append_btf(struct bpf_linker *linker, struct src_obj *obj); ++static int linker_append_btf_ext(struct bpf_linker *linker, struct src_obj *obj); ++ ++static int finalize_btf(struct bpf_linker *linker); ++static int finalize_btf_ext(struct bpf_linker *linker); ++ ++void bpf_linker__free(struct bpf_linker *linker) ++{ ++ int i; ++ ++ if (!linker) ++ return; ++ ++ free(linker->filename); ++ ++ if (linker->elf) ++ elf_end(linker->elf); ++ ++ if (linker->fd >= 0) ++ close(linker->fd); ++ ++ strset__free(linker->strtab_strs); ++ ++ btf__free(linker->btf); ++ btf_ext__free(linker->btf_ext); ++ ++ for (i = 1; i < linker->sec_cnt; i++) { ++ struct dst_sec *sec = &linker->secs[i]; ++ ++ free(sec->sec_name); ++ free(sec->raw_data); ++ free(sec->sec_vars); ++ ++ free(sec->func_info.recs); ++ free(sec->line_info.recs); ++ free(sec->core_relo_info.recs); ++ } ++ free(linker->secs); ++ ++ free(linker); ++} ++ ++struct bpf_linker *bpf_linker__new(const char *filename, struct bpf_linker_opts *opts) ++{ ++ struct bpf_linker *linker; ++ int err; ++ ++ if (!OPTS_VALID(opts, bpf_linker_opts)) ++ return NULL; ++ ++ if (elf_version(EV_CURRENT) == EV_NONE) { ++ pr_warn_elf("libelf initialization failed"); ++ return NULL; ++ } ++ ++ linker = calloc(1, sizeof(*linker)); ++ if (!linker) ++ return NULL; ++ ++ linker->fd = -1; ++ ++ err = init_output_elf(linker, filename); ++ if (err) ++ goto err_out; ++ ++ return linker; ++ ++err_out: ++ bpf_linker__free(linker); ++ return NULL; ++} ++ ++static struct dst_sec *add_dst_sec(struct bpf_linker *linker, const char *sec_name) ++{ ++ struct dst_sec *secs = linker->secs, *sec; ++ size_t new_cnt = linker->sec_cnt ? linker->sec_cnt + 1 : 2; ++ ++ secs = libbpf_reallocarray(secs, new_cnt, sizeof(*secs)); ++ if (!secs) ++ return NULL; ++ ++ /* zero out newly allocated memory */ ++ memset(secs + linker->sec_cnt, 0, (new_cnt - linker->sec_cnt) * sizeof(*secs)); ++ ++ linker->secs = secs; ++ linker->sec_cnt = new_cnt; ++ ++ sec = &linker->secs[new_cnt - 1]; ++ sec->id = new_cnt - 1; ++ sec->sec_name = strdup(sec_name); ++ if (!sec->sec_name) ++ return NULL; ++ ++ return sec; ++} ++ ++static Elf64_Sym *add_new_sym(struct bpf_linker *linker, size_t *sym_idx) ++{ ++ struct dst_sec *symtab = &linker->secs[linker->symtab_sec_idx]; ++ Elf64_Sym *syms, *sym; ++ size_t sym_cnt = symtab->sec_sz / sizeof(*sym); ++ ++ syms = libbpf_reallocarray(symtab->raw_data, sym_cnt + 1, sizeof(*sym)); ++ if (!syms) ++ return NULL; ++ ++ sym = &syms[sym_cnt]; ++ memset(sym, 0, sizeof(*sym)); ++ ++ symtab->raw_data = syms; ++ symtab->sec_sz += sizeof(*sym); ++ symtab->shdr->sh_size += sizeof(*sym); ++ symtab->data->d_size += sizeof(*sym); ++ ++ if (sym_idx) ++ *sym_idx = sym_cnt; ++ ++ return sym; ++} ++ ++static int init_output_elf(struct bpf_linker *linker, const char *file) ++{ ++ int err, str_off; ++ Elf64_Sym *init_sym; ++ struct dst_sec *sec; ++ ++ linker->filename = strdup(file); ++ if (!linker->filename) ++ return -ENOMEM; ++ ++ linker->fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0644); ++ if (linker->fd < 0) { ++ err = -errno; ++ pr_warn("failed to create '%s': %d\n", file, err); ++ return err; ++ } ++ ++ linker->elf = elf_begin(linker->fd, ELF_C_WRITE, NULL); ++ if (!linker->elf) { ++ pr_warn_elf("failed to create ELF object"); ++ return -EINVAL; ++ } ++ ++ /* ELF header */ ++ linker->elf_hdr = elf64_newehdr(linker->elf); ++ if (!linker->elf_hdr) { ++ pr_warn_elf("failed to create ELF header"); ++ return -EINVAL; ++ } ++ ++ linker->elf_hdr->e_machine = EM_BPF; ++ linker->elf_hdr->e_type = ET_REL; ++#if __BYTE_ORDER == __LITTLE_ENDIAN ++ linker->elf_hdr->e_ident[EI_DATA] = ELFDATA2LSB; ++#elif __BYTE_ORDER == __BIG_ENDIAN ++ linker->elf_hdr->e_ident[EI_DATA] = ELFDATA2MSB; ++#else ++#error "Unknown __BYTE_ORDER" ++#endif ++ ++ /* STRTAB */ ++ /* initialize strset with an empty string to conform to ELF */ ++ linker->strtab_strs = strset__new(INT_MAX, "", sizeof("")); ++ if (libbpf_get_error(linker->strtab_strs)) ++ return libbpf_get_error(linker->strtab_strs); ++ ++ sec = add_dst_sec(linker, ".strtab"); ++ if (!sec) ++ return -ENOMEM; ++ ++ sec->scn = elf_newscn(linker->elf); ++ if (!sec->scn) { ++ pr_warn_elf("failed to create STRTAB section"); ++ return -EINVAL; ++ } ++ ++ sec->shdr = elf64_getshdr(sec->scn); ++ if (!sec->shdr) ++ return -EINVAL; ++ ++ sec->data = elf_newdata(sec->scn); ++ if (!sec->data) { ++ pr_warn_elf("failed to create STRTAB data"); ++ return -EINVAL; ++ } ++ ++ str_off = strset__add_str(linker->strtab_strs, sec->sec_name); ++ if (str_off < 0) ++ return str_off; ++ ++ sec->sec_idx = elf_ndxscn(sec->scn); ++ linker->elf_hdr->e_shstrndx = sec->sec_idx; ++ linker->strtab_sec_idx = sec->sec_idx; ++ ++ sec->shdr->sh_name = str_off; ++ sec->shdr->sh_type = SHT_STRTAB; ++ sec->shdr->sh_flags = SHF_STRINGS; ++ sec->shdr->sh_offset = 0; ++ sec->shdr->sh_link = 0; ++ sec->shdr->sh_info = 0; ++ sec->shdr->sh_addralign = 1; ++ sec->shdr->sh_size = sec->sec_sz = 0; ++ sec->shdr->sh_entsize = 0; ++ ++ /* SYMTAB */ ++ sec = add_dst_sec(linker, ".symtab"); ++ if (!sec) ++ return -ENOMEM; ++ ++ sec->scn = elf_newscn(linker->elf); ++ if (!sec->scn) { ++ pr_warn_elf("failed to create SYMTAB section"); ++ return -EINVAL; ++ } ++ ++ sec->shdr = elf64_getshdr(sec->scn); ++ if (!sec->shdr) ++ return -EINVAL; ++ ++ sec->data = elf_newdata(sec->scn); ++ if (!sec->data) { ++ pr_warn_elf("failed to create SYMTAB data"); ++ return -EINVAL; ++ } ++ ++ str_off = strset__add_str(linker->strtab_strs, sec->sec_name); ++ if (str_off < 0) ++ return str_off; ++ ++ sec->sec_idx = elf_ndxscn(sec->scn); ++ linker->symtab_sec_idx = sec->sec_idx; ++ ++ sec->shdr->sh_name = str_off; ++ sec->shdr->sh_type = SHT_SYMTAB; ++ sec->shdr->sh_flags = 0; ++ sec->shdr->sh_offset = 0; ++ sec->shdr->sh_link = linker->strtab_sec_idx; ++ /* sh_info should be one greater than the index of the last local ++ * symbol (i.e., binding is STB_LOCAL). But why and who cares? ++ */ ++ sec->shdr->sh_info = 0; ++ sec->shdr->sh_addralign = 8; ++ sec->shdr->sh_entsize = sizeof(Elf64_Sym); ++ ++ /* .BTF */ ++ linker->btf = btf__new_empty(); ++ err = libbpf_get_error(linker->btf); ++ if (err) ++ return err; ++ ++ /* add the special all-zero symbol */ ++ init_sym = add_new_sym(linker, NULL); ++ if (!init_sym) ++ return -EINVAL; ++ ++ init_sym->st_name = 0; ++ init_sym->st_info = 0; ++ init_sym->st_other = 0; ++ init_sym->st_shndx = SHN_UNDEF; ++ init_sym->st_value = 0; ++ init_sym->st_size = 0; ++ ++ return 0; ++} ++ ++int bpf_linker__add_file(struct bpf_linker *linker, const char *filename, ++ const struct bpf_linker_file_opts *opts) ++{ ++ struct src_obj obj = {}; ++ int err = 0; ++ ++ if (!OPTS_VALID(opts, bpf_linker_file_opts)) ++ return -EINVAL; ++ ++ if (!linker->elf) ++ return -EINVAL; ++ ++ err = err ?: linker_load_obj_file(linker, filename, opts, &obj); ++ err = err ?: linker_append_sec_data(linker, &obj); ++ err = err ?: linker_append_elf_syms(linker, &obj); ++ err = err ?: linker_append_elf_relos(linker, &obj); ++ err = err ?: linker_append_btf(linker, &obj); ++ err = err ?: linker_append_btf_ext(linker, &obj); ++ ++ /* free up src_obj resources */ ++ free(obj.btf_type_map); ++ btf__free(obj.btf); ++ btf_ext__free(obj.btf_ext); ++ free(obj.secs); ++ free(obj.sym_map); ++ if (obj.elf) ++ elf_end(obj.elf); ++ if (obj.fd >= 0) ++ close(obj.fd); ++ ++ return err; ++} ++ ++static bool is_dwarf_sec_name(const char *name) ++{ ++ /* approximation, but the actual list is too long */ ++ return strncmp(name, ".debug_", sizeof(".debug_") - 1) == 0; ++} ++ ++static bool is_ignored_sec(struct src_sec *sec) ++{ ++ Elf64_Shdr *shdr = sec->shdr; ++ const char *name = sec->sec_name; ++ ++ /* no special handling of .strtab */ ++ if (shdr->sh_type == SHT_STRTAB) ++ return true; ++ ++ /* ignore .llvm_addrsig section as well */ ++ if (shdr->sh_type == SHT_LLVM_ADDRSIG) ++ return true; ++ ++ /* no subprograms will lead to an empty .text section, ignore it */ ++ if (shdr->sh_type == SHT_PROGBITS && shdr->sh_size == 0 && ++ strcmp(sec->sec_name, ".text") == 0) ++ return true; ++ ++ /* DWARF sections */ ++ if (is_dwarf_sec_name(sec->sec_name)) ++ return true; ++ ++ if (strncmp(name, ".rel", sizeof(".rel") - 1) == 0) { ++ name += sizeof(".rel") - 1; ++ /* DWARF section relocations */ ++ if (is_dwarf_sec_name(name)) ++ return true; ++ ++ /* .BTF and .BTF.ext don't need relocations */ ++ if (strcmp(name, BTF_ELF_SEC) == 0 || ++ strcmp(name, BTF_EXT_ELF_SEC) == 0) ++ return true; ++ } ++ ++ return false; ++} ++ ++static struct src_sec *add_src_sec(struct src_obj *obj, const char *sec_name) ++{ ++ struct src_sec *secs = obj->secs, *sec; ++ size_t new_cnt = obj->sec_cnt ? obj->sec_cnt + 1 : 2; ++ ++ secs = libbpf_reallocarray(secs, new_cnt, sizeof(*secs)); ++ if (!secs) ++ return NULL; ++ ++ /* zero out newly allocated memory */ ++ memset(secs + obj->sec_cnt, 0, (new_cnt - obj->sec_cnt) * sizeof(*secs)); ++ ++ obj->secs = secs; ++ obj->sec_cnt = new_cnt; ++ ++ sec = &obj->secs[new_cnt - 1]; ++ sec->id = new_cnt - 1; ++ sec->sec_name = sec_name; ++ ++ return sec; ++} ++ ++static int linker_load_obj_file(struct bpf_linker *linker, const char *filename, ++ const struct bpf_linker_file_opts *opts, ++ struct src_obj *obj) ++{ ++#if __BYTE_ORDER == __LITTLE_ENDIAN ++ const int host_endianness = ELFDATA2LSB; ++#elif __BYTE_ORDER == __BIG_ENDIAN ++ const int host_endianness = ELFDATA2MSB; ++#else ++#error "Unknown __BYTE_ORDER" ++#endif ++ int err = 0; ++ Elf_Scn *scn; ++ Elf_Data *data; ++ Elf64_Ehdr *ehdr; ++ Elf64_Shdr *shdr; ++ struct src_sec *sec; ++ ++ pr_debug("linker: adding object file '%s'...\n", filename); ++ ++ obj->filename = filename; ++ ++ obj->fd = open(filename, O_RDONLY); ++ if (obj->fd < 0) { ++ err = -errno; ++ pr_warn("failed to open file '%s': %d\n", filename, err); ++ return err; ++ } ++ obj->elf = elf_begin(obj->fd, ELF_C_READ_MMAP, NULL); ++ if (!obj->elf) { ++ err = -errno; ++ pr_warn_elf("failed to parse ELF file '%s'", filename); ++ return err; ++ } ++ ++ /* Sanity check ELF file high-level properties */ ++ ehdr = elf64_getehdr(obj->elf); ++ if (!ehdr) { ++ err = -errno; ++ pr_warn_elf("failed to get ELF header for %s", filename); ++ return err; ++ } ++ if (ehdr->e_ident[EI_DATA] != host_endianness) { ++ err = -EOPNOTSUPP; ++ pr_warn_elf("unsupported byte order of ELF file %s", filename); ++ return err; ++ } ++ if (ehdr->e_type != ET_REL ++ || ehdr->e_machine != EM_BPF ++ || ehdr->e_ident[EI_CLASS] != ELFCLASS64) { ++ err = -EOPNOTSUPP; ++ pr_warn_elf("unsupported kind of ELF file %s", filename); ++ return err; ++ } ++ ++ if (elf_getshdrstrndx(obj->elf, &obj->shstrs_sec_idx)) { ++ err = -errno; ++ pr_warn_elf("failed to get SHSTRTAB section index for %s", filename); ++ return err; ++ } ++ ++ scn = NULL; ++ while ((scn = elf_nextscn(obj->elf, scn)) != NULL) { ++ size_t sec_idx = elf_ndxscn(scn); ++ const char *sec_name; ++ ++ shdr = elf64_getshdr(scn); ++ if (!shdr) { ++ err = -errno; ++ pr_warn_elf("failed to get section #%zu header for %s", ++ sec_idx, filename); ++ return err; ++ } ++ ++ sec_name = elf_strptr(obj->elf, obj->shstrs_sec_idx, shdr->sh_name); ++ if (!sec_name) { ++ err = -errno; ++ pr_warn_elf("failed to get section #%zu name for %s", ++ sec_idx, filename); ++ return err; ++ } ++ ++ data = elf_getdata(scn, 0); ++ if (!data) { ++ err = -errno; ++ pr_warn_elf("failed to get section #%zu (%s) data from %s", ++ sec_idx, sec_name, filename); ++ return err; ++ } ++ ++ sec = add_src_sec(obj, sec_name); ++ if (!sec) ++ return -ENOMEM; ++ ++ sec->scn = scn; ++ sec->shdr = shdr; ++ sec->data = data; ++ sec->sec_idx = elf_ndxscn(scn); ++ ++ if (is_ignored_sec(sec)) { ++ sec->skipped = true; ++ continue; ++ } ++ ++ switch (shdr->sh_type) { ++ case SHT_SYMTAB: ++ if (obj->symtab_sec_idx) { ++ err = -EOPNOTSUPP; ++ pr_warn("multiple SYMTAB sections found, not supported\n"); ++ return err; ++ } ++ obj->symtab_sec_idx = sec_idx; ++ break; ++ case SHT_STRTAB: ++ /* we'll construct our own string table */ ++ break; ++ case SHT_PROGBITS: ++ if (strcmp(sec_name, BTF_ELF_SEC) == 0) { ++ obj->btf = btf__new(data->d_buf, shdr->sh_size); ++ err = libbpf_get_error(obj->btf); ++ if (err) { ++ pr_warn("failed to parse .BTF from %s: %d\n", filename, err); ++ return err; ++ } ++ sec->skipped = true; ++ continue; ++ } ++ if (strcmp(sec_name, BTF_EXT_ELF_SEC) == 0) { ++ obj->btf_ext = btf_ext__new(data->d_buf, shdr->sh_size); ++ err = libbpf_get_error(obj->btf_ext); ++ if (err) { ++ pr_warn("failed to parse .BTF.ext from '%s': %d\n", filename, err); ++ return err; ++ } ++ sec->skipped = true; ++ continue; ++ } ++ ++ /* data & code */ ++ break; ++ case SHT_NOBITS: ++ /* BSS */ ++ break; ++ case SHT_REL: ++ /* relocations */ ++ break; ++ default: ++ pr_warn("unrecognized section #%zu (%s) in %s\n", ++ sec_idx, sec_name, filename); ++ err = -EINVAL; ++ return err; ++ } ++ } ++ ++ err = err ?: linker_sanity_check_elf(obj); ++ err = err ?: linker_sanity_check_btf(obj); ++ err = err ?: linker_sanity_check_btf_ext(obj); ++ err = err ?: linker_fixup_btf(obj); ++ ++ return err; ++} ++ ++static bool is_pow_of_2(size_t x) ++{ ++ return x && (x & (x - 1)) == 0; ++} ++ ++static int linker_sanity_check_elf(struct src_obj *obj) ++{ ++ struct src_sec *sec; ++ int i, err; ++ ++ if (!obj->symtab_sec_idx) { ++ pr_warn("ELF is missing SYMTAB section in %s\n", obj->filename); ++ return -EINVAL; ++ } ++ if (!obj->shstrs_sec_idx) { ++ pr_warn("ELF is missing section headers STRTAB section in %s\n", obj->filename); ++ return -EINVAL; ++ } ++ ++ for (i = 1; i < obj->sec_cnt; i++) { ++ sec = &obj->secs[i]; ++ ++ if (sec->sec_name[0] == '\0') { ++ pr_warn("ELF section #%zu has empty name in %s\n", sec->sec_idx, obj->filename); ++ return -EINVAL; ++ } ++ ++ if (sec->shdr->sh_addralign && !is_pow_of_2(sec->shdr->sh_addralign)) ++ return -EINVAL; ++ if (sec->shdr->sh_addralign != sec->data->d_align) ++ return -EINVAL; ++ ++ if (sec->shdr->sh_size != sec->data->d_size) ++ return -EINVAL; ++ ++ switch (sec->shdr->sh_type) { ++ case SHT_SYMTAB: ++ err = linker_sanity_check_elf_symtab(obj, sec); ++ if (err) ++ return err; ++ break; ++ case SHT_STRTAB: ++ break; ++ case SHT_PROGBITS: ++ if (sec->shdr->sh_flags & SHF_EXECINSTR) { ++ if (sec->shdr->sh_size % sizeof(struct bpf_insn) != 0) ++ return -EINVAL; ++ } ++ break; ++ case SHT_NOBITS: ++ break; ++ case SHT_REL: ++ err = linker_sanity_check_elf_relos(obj, sec); ++ if (err) ++ return err; ++ break; ++ case SHT_LLVM_ADDRSIG: ++ break; ++ default: ++ pr_warn("ELF section #%zu (%s) has unrecognized type %zu in %s\n", ++ sec->sec_idx, sec->sec_name, (size_t)sec->shdr->sh_type, obj->filename); ++ return -EINVAL; ++ } ++ } ++ ++ return 0; ++} ++ ++static int linker_sanity_check_elf_symtab(struct src_obj *obj, struct src_sec *sec) ++{ ++ struct src_sec *link_sec; ++ Elf64_Sym *sym; ++ int i, n; ++ ++ if (sec->shdr->sh_entsize != sizeof(Elf64_Sym)) ++ return -EINVAL; ++ if (sec->shdr->sh_size % sec->shdr->sh_entsize != 0) ++ return -EINVAL; ++ ++ if (!sec->shdr->sh_link || sec->shdr->sh_link >= obj->sec_cnt) { ++ pr_warn("ELF SYMTAB section #%zu points to missing STRTAB section #%zu in %s\n", ++ sec->sec_idx, (size_t)sec->shdr->sh_link, obj->filename); ++ return -EINVAL; ++ } ++ link_sec = &obj->secs[sec->shdr->sh_link]; ++ if (link_sec->shdr->sh_type != SHT_STRTAB) { ++ pr_warn("ELF SYMTAB section #%zu points to invalid STRTAB section #%zu in %s\n", ++ sec->sec_idx, (size_t)sec->shdr->sh_link, obj->filename); ++ return -EINVAL; ++ } ++ ++ n = sec->shdr->sh_size / sec->shdr->sh_entsize; ++ sym = sec->data->d_buf; ++ for (i = 0; i < n; i++, sym++) { ++ int sym_type = ELF64_ST_TYPE(sym->st_info); ++ int sym_bind = ELF64_ST_BIND(sym->st_info); ++ int sym_vis = ELF64_ST_VISIBILITY(sym->st_other); ++ ++ if (i == 0) { ++ if (sym->st_name != 0 || sym->st_info != 0 ++ || sym->st_other != 0 || sym->st_shndx != 0 ++ || sym->st_value != 0 || sym->st_size != 0) { ++ pr_warn("ELF sym #0 is invalid in %s\n", obj->filename); ++ return -EINVAL; ++ } ++ continue; ++ } ++ if (sym_bind != STB_LOCAL && sym_bind != STB_GLOBAL && sym_bind != STB_WEAK) { ++ pr_warn("ELF sym #%d in section #%zu has unsupported symbol binding %d\n", ++ i, sec->sec_idx, sym_bind); ++ return -EINVAL; ++ } ++ if (sym_vis != STV_DEFAULT && sym_vis != STV_HIDDEN) { ++ pr_warn("ELF sym #%d in section #%zu has unsupported symbol visibility %d\n", ++ i, sec->sec_idx, sym_vis); ++ return -EINVAL; ++ } ++ if (sym->st_shndx == 0) { ++ if (sym_type != STT_NOTYPE || sym_bind == STB_LOCAL ++ || sym->st_value != 0 || sym->st_size != 0) { ++ pr_warn("ELF sym #%d is invalid extern symbol in %s\n", ++ i, obj->filename); ++ ++ return -EINVAL; ++ } ++ continue; ++ } ++ if (sym->st_shndx < SHN_LORESERVE && sym->st_shndx >= obj->sec_cnt) { ++ pr_warn("ELF sym #%d in section #%zu points to missing section #%zu in %s\n", ++ i, sec->sec_idx, (size_t)sym->st_shndx, obj->filename); ++ return -EINVAL; ++ } ++ if (sym_type == STT_SECTION) { ++ if (sym->st_value != 0) ++ return -EINVAL; ++ continue; ++ } ++ } ++ ++ return 0; ++} ++ ++static int linker_sanity_check_elf_relos(struct src_obj *obj, struct src_sec *sec) ++{ ++ struct src_sec *link_sec, *sym_sec; ++ Elf64_Rel *relo; ++ int i, n; ++ ++ if (sec->shdr->sh_entsize != sizeof(Elf64_Rel)) ++ return -EINVAL; ++ if (sec->shdr->sh_size % sec->shdr->sh_entsize != 0) ++ return -EINVAL; ++ ++ /* SHT_REL's sh_link should point to SYMTAB */ ++ if (sec->shdr->sh_link != obj->symtab_sec_idx) { ++ pr_warn("ELF relo section #%zu points to invalid SYMTAB section #%zu in %s\n", ++ sec->sec_idx, (size_t)sec->shdr->sh_link, obj->filename); ++ return -EINVAL; ++ } ++ ++ /* SHT_REL's sh_info points to relocated section */ ++ if (!sec->shdr->sh_info || sec->shdr->sh_info >= obj->sec_cnt) { ++ pr_warn("ELF relo section #%zu points to missing section #%zu in %s\n", ++ sec->sec_idx, (size_t)sec->shdr->sh_info, obj->filename); ++ return -EINVAL; ++ } ++ link_sec = &obj->secs[sec->shdr->sh_info]; ++ ++ /* .rel -> pattern is followed */ ++ if (strncmp(sec->sec_name, ".rel", sizeof(".rel") - 1) != 0 ++ || strcmp(sec->sec_name + sizeof(".rel") - 1, link_sec->sec_name) != 0) { ++ pr_warn("ELF relo section #%zu name has invalid name in %s\n", ++ sec->sec_idx, obj->filename); ++ return -EINVAL; ++ } ++ ++ /* don't further validate relocations for ignored sections */ ++ if (link_sec->skipped) ++ return 0; ++ ++ /* relocatable section is data or instructions */ ++ if (link_sec->shdr->sh_type != SHT_PROGBITS && link_sec->shdr->sh_type != SHT_NOBITS) { ++ pr_warn("ELF relo section #%zu points to invalid section #%zu in %s\n", ++ sec->sec_idx, (size_t)sec->shdr->sh_info, obj->filename); ++ return -EINVAL; ++ } ++ ++ /* check sanity of each relocation */ ++ n = sec->shdr->sh_size / sec->shdr->sh_entsize; ++ relo = sec->data->d_buf; ++ sym_sec = &obj->secs[obj->symtab_sec_idx]; ++ for (i = 0; i < n; i++, relo++) { ++ size_t sym_idx = ELF64_R_SYM(relo->r_info); ++ size_t sym_type = ELF64_R_TYPE(relo->r_info); ++ ++ if (sym_type != R_BPF_64_64 && sym_type != R_BPF_64_32 && ++ sym_type != R_BPF_64_ABS64 && sym_type != R_BPF_64_ABS32) { ++ pr_warn("ELF relo #%d in section #%zu has unexpected type %zu in %s\n", ++ i, sec->sec_idx, sym_type, obj->filename); ++ return -EINVAL; ++ } ++ ++ if (!sym_idx || sym_idx * sizeof(Elf64_Sym) >= sym_sec->shdr->sh_size) { ++ pr_warn("ELF relo #%d in section #%zu points to invalid symbol #%zu in %s\n", ++ i, sec->sec_idx, sym_idx, obj->filename); ++ return -EINVAL; ++ } ++ ++ if (link_sec->shdr->sh_flags & SHF_EXECINSTR) { ++ if (relo->r_offset % sizeof(struct bpf_insn) != 0) { ++ pr_warn("ELF relo #%d in section #%zu points to missing symbol #%zu in %s\n", ++ i, sec->sec_idx, sym_idx, obj->filename); ++ return -EINVAL; ++ } ++ } ++ } ++ ++ return 0; ++} ++ ++static int check_btf_type_id(__u32 *type_id, void *ctx) ++{ ++ struct btf *btf = ctx; ++ ++ if (*type_id > btf__get_nr_types(btf)) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static int check_btf_str_off(__u32 *str_off, void *ctx) ++{ ++ struct btf *btf = ctx; ++ const char *s; ++ ++ s = btf__str_by_offset(btf, *str_off); ++ ++ if (!s) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static int linker_sanity_check_btf(struct src_obj *obj) ++{ ++ struct btf_type *t; ++ int i, n, err = 0; ++ ++ if (!obj->btf) ++ return 0; ++ ++ n = btf__get_nr_types(obj->btf); ++ for (i = 1; i <= n; i++) { ++ t = btf_type_by_id(obj->btf, i); ++ ++ err = err ?: btf_type_visit_type_ids(t, check_btf_type_id, obj->btf); ++ err = err ?: btf_type_visit_str_offs(t, check_btf_str_off, obj->btf); ++ if (err) ++ return err; ++ } ++ ++ return 0; ++} ++ ++static int linker_sanity_check_btf_ext(struct src_obj *obj) ++{ ++ int err = 0; ++ ++ if (!obj->btf_ext) ++ return 0; ++ ++ /* can't use .BTF.ext without .BTF */ ++ if (!obj->btf) ++ return -EINVAL; ++ ++ err = err ?: btf_ext_visit_type_ids(obj->btf_ext, check_btf_type_id, obj->btf); ++ err = err ?: btf_ext_visit_str_offs(obj->btf_ext, check_btf_str_off, obj->btf); ++ if (err) ++ return err; ++ ++ return 0; ++} ++ ++static int init_sec(struct bpf_linker *linker, struct dst_sec *dst_sec, struct src_sec *src_sec) ++{ ++ Elf_Scn *scn; ++ Elf_Data *data; ++ Elf64_Shdr *shdr; ++ int name_off; ++ ++ dst_sec->sec_sz = 0; ++ dst_sec->sec_idx = 0; ++ dst_sec->ephemeral = src_sec->ephemeral; ++ ++ /* ephemeral sections are just thin section shells lacking most parts */ ++ if (src_sec->ephemeral) ++ return 0; ++ ++ scn = elf_newscn(linker->elf); ++ if (!scn) ++ return -ENOMEM; ++ data = elf_newdata(scn); ++ if (!data) ++ return -ENOMEM; ++ shdr = elf64_getshdr(scn); ++ if (!shdr) ++ return -ENOMEM; ++ ++ dst_sec->scn = scn; ++ dst_sec->shdr = shdr; ++ dst_sec->data = data; ++ dst_sec->sec_idx = elf_ndxscn(scn); ++ ++ name_off = strset__add_str(linker->strtab_strs, src_sec->sec_name); ++ if (name_off < 0) ++ return name_off; ++ ++ shdr->sh_name = name_off; ++ shdr->sh_type = src_sec->shdr->sh_type; ++ shdr->sh_flags = src_sec->shdr->sh_flags; ++ shdr->sh_size = 0; ++ /* sh_link and sh_info have different meaning for different types of ++ * sections, so we leave it up to the caller code to fill them in, if ++ * necessary ++ */ ++ shdr->sh_link = 0; ++ shdr->sh_info = 0; ++ shdr->sh_addralign = src_sec->shdr->sh_addralign; ++ shdr->sh_entsize = src_sec->shdr->sh_entsize; ++ ++ data->d_type = src_sec->data->d_type; ++ data->d_size = 0; ++ data->d_buf = NULL; ++ data->d_align = src_sec->data->d_align; ++ data->d_off = 0; ++ ++ return 0; ++} ++ ++static struct dst_sec *find_dst_sec_by_name(struct bpf_linker *linker, const char *sec_name) ++{ ++ struct dst_sec *sec; ++ int i; ++ ++ for (i = 1; i < linker->sec_cnt; i++) { ++ sec = &linker->secs[i]; ++ ++ if (strcmp(sec->sec_name, sec_name) == 0) ++ return sec; ++ } ++ ++ return NULL; ++} ++ ++static bool secs_match(struct dst_sec *dst, struct src_sec *src) ++{ ++ if (dst->ephemeral || src->ephemeral) ++ return true; ++ ++ if (dst->shdr->sh_type != src->shdr->sh_type) { ++ pr_warn("sec %s types mismatch\n", dst->sec_name); ++ return false; ++ } ++ if (dst->shdr->sh_flags != src->shdr->sh_flags) { ++ pr_warn("sec %s flags mismatch\n", dst->sec_name); ++ return false; ++ } ++ if (dst->shdr->sh_entsize != src->shdr->sh_entsize) { ++ pr_warn("sec %s entsize mismatch\n", dst->sec_name); ++ return false; ++ } ++ ++ return true; ++} ++ ++static bool sec_content_is_same(struct dst_sec *dst_sec, struct src_sec *src_sec) ++{ ++ if (dst_sec->sec_sz != src_sec->shdr->sh_size) ++ return false; ++ if (memcmp(dst_sec->raw_data, src_sec->data->d_buf, dst_sec->sec_sz) != 0) ++ return false; ++ return true; ++} ++ ++static int extend_sec(struct bpf_linker *linker, struct dst_sec *dst, struct src_sec *src) ++{ ++ void *tmp; ++ size_t dst_align, src_align; ++ size_t dst_align_sz, dst_final_sz; ++ int err; ++ ++ /* Ephemeral source section doesn't contribute anything to ELF ++ * section data. ++ */ ++ if (src->ephemeral) ++ return 0; ++ ++ /* Some sections (like .maps) can contain both externs (and thus be ++ * ephemeral) and non-externs (map definitions). So it's possible that ++ * it has to be "upgraded" from ephemeral to non-ephemeral when the ++ * first non-ephemeral entity appears. In such case, we add ELF ++ * section, data, etc. ++ */ ++ if (dst->ephemeral) { ++ err = init_sec(linker, dst, src); ++ if (err) ++ return err; ++ } ++ ++ dst_align = dst->shdr->sh_addralign; ++ src_align = src->shdr->sh_addralign; ++ if (dst_align == 0) ++ dst_align = 1; ++ if (dst_align < src_align) ++ dst_align = src_align; ++ ++ dst_align_sz = (dst->sec_sz + dst_align - 1) / dst_align * dst_align; ++ ++ /* no need to re-align final size */ ++ dst_final_sz = dst_align_sz + src->shdr->sh_size; ++ ++ if (src->shdr->sh_type != SHT_NOBITS) { ++ tmp = realloc(dst->raw_data, dst_final_sz); ++ if (!tmp) ++ return -ENOMEM; ++ dst->raw_data = tmp; ++ ++ /* pad dst section, if it's alignment forced size increase */ ++ memset(dst->raw_data + dst->sec_sz, 0, dst_align_sz - dst->sec_sz); ++ /* now copy src data at a properly aligned offset */ ++ memcpy(dst->raw_data + dst_align_sz, src->data->d_buf, src->shdr->sh_size); ++ } ++ ++ dst->sec_sz = dst_final_sz; ++ dst->shdr->sh_size = dst_final_sz; ++ dst->data->d_size = dst_final_sz; ++ ++ dst->shdr->sh_addralign = dst_align; ++ dst->data->d_align = dst_align; ++ ++ src->dst_off = dst_align_sz; ++ ++ return 0; ++} ++ ++static bool is_data_sec(struct src_sec *sec) ++{ ++ if (!sec || sec->skipped) ++ return false; ++ /* ephemeral sections are data sections, e.g., .kconfig, .ksyms */ ++ if (sec->ephemeral) ++ return true; ++ return sec->shdr->sh_type == SHT_PROGBITS || sec->shdr->sh_type == SHT_NOBITS; ++} ++ ++static bool is_relo_sec(struct src_sec *sec) ++{ ++ if (!sec || sec->skipped || sec->ephemeral) ++ return false; ++ return sec->shdr->sh_type == SHT_REL; ++} ++ ++static int linker_append_sec_data(struct bpf_linker *linker, struct src_obj *obj) ++{ ++ int i, err; ++ ++ for (i = 1; i < obj->sec_cnt; i++) { ++ struct src_sec *src_sec; ++ struct dst_sec *dst_sec; ++ ++ src_sec = &obj->secs[i]; ++ if (!is_data_sec(src_sec)) ++ continue; ++ ++ dst_sec = find_dst_sec_by_name(linker, src_sec->sec_name); ++ if (!dst_sec) { ++ dst_sec = add_dst_sec(linker, src_sec->sec_name); ++ if (!dst_sec) ++ return -ENOMEM; ++ err = init_sec(linker, dst_sec, src_sec); ++ if (err) { ++ pr_warn("failed to init section '%s'\n", src_sec->sec_name); ++ return err; ++ } ++ } else { ++ if (!secs_match(dst_sec, src_sec)) { ++ pr_warn("ELF sections %s are incompatible\n", src_sec->sec_name); ++ return -1; ++ } ++ ++ /* "license" and "version" sections are deduped */ ++ if (strcmp(src_sec->sec_name, "license") == 0 ++ || strcmp(src_sec->sec_name, "version") == 0) { ++ if (!sec_content_is_same(dst_sec, src_sec)) { ++ pr_warn("non-identical contents of section '%s' are not supported\n", src_sec->sec_name); ++ return -EINVAL; ++ } ++ src_sec->skipped = true; ++ src_sec->dst_id = dst_sec->id; ++ continue; ++ } ++ } ++ ++ /* record mapped section index */ ++ src_sec->dst_id = dst_sec->id; ++ ++ err = extend_sec(linker, dst_sec, src_sec); ++ if (err) ++ return err; ++ } ++ ++ return 0; ++} ++ ++static int linker_append_elf_syms(struct bpf_linker *linker, struct src_obj *obj) ++{ ++ struct src_sec *symtab = &obj->secs[obj->symtab_sec_idx]; ++ Elf64_Sym *sym = symtab->data->d_buf; ++ int i, n = symtab->shdr->sh_size / symtab->shdr->sh_entsize, err; ++ int str_sec_idx = symtab->shdr->sh_link; ++ const char *sym_name; ++ ++ obj->sym_map = calloc(n + 1, sizeof(*obj->sym_map)); ++ if (!obj->sym_map) ++ return -ENOMEM; ++ ++ for (i = 0; i < n; i++, sym++) { ++ /* We already validated all-zero symbol #0 and we already ++ * appended it preventively to the final SYMTAB, so skip it. ++ */ ++ if (i == 0) ++ continue; ++ ++ sym_name = elf_strptr(obj->elf, str_sec_idx, sym->st_name); ++ if (!sym_name) { ++ pr_warn("can't fetch symbol name for symbol #%d in '%s'\n", i, obj->filename); ++ return -EINVAL; ++ } ++ ++ err = linker_append_elf_sym(linker, obj, sym, sym_name, i); ++ if (err) ++ return err; ++ } ++ ++ return 0; ++} ++ ++static Elf64_Sym *get_sym_by_idx(struct bpf_linker *linker, size_t sym_idx) ++{ ++ struct dst_sec *symtab = &linker->secs[linker->symtab_sec_idx]; ++ Elf64_Sym *syms = symtab->raw_data; ++ ++ return &syms[sym_idx]; ++} ++ ++static struct glob_sym *find_glob_sym(struct bpf_linker *linker, const char *sym_name) ++{ ++ struct glob_sym *glob_sym; ++ const char *name; ++ int i; ++ ++ for (i = 0; i < linker->glob_sym_cnt; i++) { ++ glob_sym = &linker->glob_syms[i]; ++ name = strset__data(linker->strtab_strs) + glob_sym->name_off; ++ ++ if (strcmp(name, sym_name) == 0) ++ return glob_sym; ++ } ++ ++ return NULL; ++} ++ ++static struct glob_sym *add_glob_sym(struct bpf_linker *linker) ++{ ++ struct glob_sym *syms, *sym; ++ ++ syms = libbpf_reallocarray(linker->glob_syms, linker->glob_sym_cnt + 1, ++ sizeof(*linker->glob_syms)); ++ if (!syms) ++ return NULL; ++ ++ sym = &syms[linker->glob_sym_cnt]; ++ memset(sym, 0, sizeof(*sym)); ++ sym->var_idx = -1; ++ ++ linker->glob_syms = syms; ++ linker->glob_sym_cnt++; ++ ++ return sym; ++} ++ ++static bool glob_sym_btf_matches(const char *sym_name, bool exact, ++ const struct btf *btf1, __u32 id1, ++ const struct btf *btf2, __u32 id2) ++{ ++ const struct btf_type *t1, *t2; ++ bool is_static1, is_static2; ++ const char *n1, *n2; ++ int i, n; ++ ++recur: ++ n1 = n2 = NULL; ++ t1 = skip_mods_and_typedefs(btf1, id1, &id1); ++ t2 = skip_mods_and_typedefs(btf2, id2, &id2); ++ ++ /* check if only one side is FWD, otherwise handle with common logic */ ++ if (!exact && btf_is_fwd(t1) != btf_is_fwd(t2)) { ++ n1 = btf__str_by_offset(btf1, t1->name_off); ++ n2 = btf__str_by_offset(btf2, t2->name_off); ++ if (strcmp(n1, n2) != 0) { ++ pr_warn("global '%s': incompatible forward declaration names '%s' and '%s'\n", ++ sym_name, n1, n2); ++ return false; ++ } ++ /* validate if FWD kind matches concrete kind */ ++ if (btf_is_fwd(t1)) { ++ if (btf_kflag(t1) && btf_is_union(t2)) ++ return true; ++ if (!btf_kflag(t1) && btf_is_struct(t2)) ++ return true; ++ pr_warn("global '%s': incompatible %s forward declaration and concrete kind %s\n", ++ sym_name, btf_kflag(t1) ? "union" : "struct", btf_kind_str(t2)); ++ } else { ++ if (btf_kflag(t2) && btf_is_union(t1)) ++ return true; ++ if (!btf_kflag(t2) && btf_is_struct(t1)) ++ return true; ++ pr_warn("global '%s': incompatible %s forward declaration and concrete kind %s\n", ++ sym_name, btf_kflag(t2) ? "union" : "struct", btf_kind_str(t1)); ++ } ++ return false; ++ } ++ ++ if (btf_kind(t1) != btf_kind(t2)) { ++ pr_warn("global '%s': incompatible BTF kinds %s and %s\n", ++ sym_name, btf_kind_str(t1), btf_kind_str(t2)); ++ return false; ++ } ++ ++ switch (btf_kind(t1)) { ++ case BTF_KIND_STRUCT: ++ case BTF_KIND_UNION: ++ case BTF_KIND_ENUM: ++ case BTF_KIND_FWD: ++ case BTF_KIND_FUNC: ++ case BTF_KIND_VAR: ++ n1 = btf__str_by_offset(btf1, t1->name_off); ++ n2 = btf__str_by_offset(btf2, t2->name_off); ++ if (strcmp(n1, n2) != 0) { ++ pr_warn("global '%s': incompatible %s names '%s' and '%s'\n", ++ sym_name, btf_kind_str(t1), n1, n2); ++ return false; ++ } ++ break; ++ default: ++ break; ++ } ++ ++ switch (btf_kind(t1)) { ++ case BTF_KIND_UNKN: /* void */ ++ case BTF_KIND_FWD: ++ return true; ++ case BTF_KIND_INT: ++ case BTF_KIND_FLOAT: ++ case BTF_KIND_ENUM: ++ /* ignore encoding for int and enum values for enum */ ++ if (t1->size != t2->size) { ++ pr_warn("global '%s': incompatible %s '%s' size %u and %u\n", ++ sym_name, btf_kind_str(t1), n1, t1->size, t2->size); ++ return false; ++ } ++ return true; ++ case BTF_KIND_PTR: ++ /* just validate overall shape of the referenced type, so no ++ * contents comparison for struct/union, and allowd fwd vs ++ * struct/union ++ */ ++ exact = false; ++ id1 = t1->type; ++ id2 = t2->type; ++ goto recur; ++ case BTF_KIND_ARRAY: ++ /* ignore index type and array size */ ++ id1 = btf_array(t1)->type; ++ id2 = btf_array(t2)->type; ++ goto recur; ++ case BTF_KIND_FUNC: ++ /* extern and global linkages are compatible */ ++ is_static1 = btf_func_linkage(t1) == BTF_FUNC_STATIC; ++ is_static2 = btf_func_linkage(t2) == BTF_FUNC_STATIC; ++ if (is_static1 != is_static2) { ++ pr_warn("global '%s': incompatible func '%s' linkage\n", sym_name, n1); ++ return false; ++ } ++ ++ id1 = t1->type; ++ id2 = t2->type; ++ goto recur; ++ case BTF_KIND_VAR: ++ /* extern and global linkages are compatible */ ++ is_static1 = btf_var(t1)->linkage == BTF_VAR_STATIC; ++ is_static2 = btf_var(t2)->linkage == BTF_VAR_STATIC; ++ if (is_static1 != is_static2) { ++ pr_warn("global '%s': incompatible var '%s' linkage\n", sym_name, n1); ++ return false; ++ } ++ ++ id1 = t1->type; ++ id2 = t2->type; ++ goto recur; ++ case BTF_KIND_STRUCT: ++ case BTF_KIND_UNION: { ++ const struct btf_member *m1, *m2; ++ ++ if (!exact) ++ return true; ++ ++ if (btf_vlen(t1) != btf_vlen(t2)) { ++ pr_warn("global '%s': incompatible number of %s fields %u and %u\n", ++ sym_name, btf_kind_str(t1), btf_vlen(t1), btf_vlen(t2)); ++ return false; ++ } ++ ++ n = btf_vlen(t1); ++ m1 = btf_members(t1); ++ m2 = btf_members(t2); ++ for (i = 0; i < n; i++, m1++, m2++) { ++ n1 = btf__str_by_offset(btf1, m1->name_off); ++ n2 = btf__str_by_offset(btf2, m2->name_off); ++ if (strcmp(n1, n2) != 0) { ++ pr_warn("global '%s': incompatible field #%d names '%s' and '%s'\n", ++ sym_name, i, n1, n2); ++ return false; ++ } ++ if (m1->offset != m2->offset) { ++ pr_warn("global '%s': incompatible field #%d ('%s') offsets\n", ++ sym_name, i, n1); ++ return false; ++ } ++ if (!glob_sym_btf_matches(sym_name, exact, btf1, m1->type, btf2, m2->type)) ++ return false; ++ } ++ ++ return true; ++ } ++ case BTF_KIND_FUNC_PROTO: { ++ const struct btf_param *m1, *m2; ++ ++ if (btf_vlen(t1) != btf_vlen(t2)) { ++ pr_warn("global '%s': incompatible number of %s params %u and %u\n", ++ sym_name, btf_kind_str(t1), btf_vlen(t1), btf_vlen(t2)); ++ return false; ++ } ++ ++ n = btf_vlen(t1); ++ m1 = btf_params(t1); ++ m2 = btf_params(t2); ++ for (i = 0; i < n; i++, m1++, m2++) { ++ /* ignore func arg names */ ++ if (!glob_sym_btf_matches(sym_name, exact, btf1, m1->type, btf2, m2->type)) ++ return false; ++ } ++ ++ /* now check return type as well */ ++ id1 = t1->type; ++ id2 = t2->type; ++ goto recur; ++ } ++ ++ /* skip_mods_and_typedefs() make this impossible */ ++ case BTF_KIND_TYPEDEF: ++ case BTF_KIND_VOLATILE: ++ case BTF_KIND_CONST: ++ case BTF_KIND_RESTRICT: ++ /* DATASECs are never compared with each other */ ++ case BTF_KIND_DATASEC: ++ default: ++ pr_warn("global '%s': unsupported BTF kind %s\n", ++ sym_name, btf_kind_str(t1)); ++ return false; ++ } ++} ++ ++static bool map_defs_match(const char *sym_name, ++ const struct btf *main_btf, ++ const struct btf_map_def *main_def, ++ const struct btf_map_def *main_inner_def, ++ const struct btf *extra_btf, ++ const struct btf_map_def *extra_def, ++ const struct btf_map_def *extra_inner_def) ++{ ++ const char *reason; ++ ++ if (main_def->map_type != extra_def->map_type) { ++ reason = "type"; ++ goto mismatch; ++ } ++ ++ /* check key type/size match */ ++ if (main_def->key_size != extra_def->key_size) { ++ reason = "key_size"; ++ goto mismatch; ++ } ++ if (!!main_def->key_type_id != !!extra_def->key_type_id) { ++ reason = "key type"; ++ goto mismatch; ++ } ++ if ((main_def->parts & MAP_DEF_KEY_TYPE) ++ && !glob_sym_btf_matches(sym_name, true /*exact*/, ++ main_btf, main_def->key_type_id, ++ extra_btf, extra_def->key_type_id)) { ++ reason = "key type"; ++ goto mismatch; ++ } ++ ++ /* validate value type/size match */ ++ if (main_def->value_size != extra_def->value_size) { ++ reason = "value_size"; ++ goto mismatch; ++ } ++ if (!!main_def->value_type_id != !!extra_def->value_type_id) { ++ reason = "value type"; ++ goto mismatch; ++ } ++ if ((main_def->parts & MAP_DEF_VALUE_TYPE) ++ && !glob_sym_btf_matches(sym_name, true /*exact*/, ++ main_btf, main_def->value_type_id, ++ extra_btf, extra_def->value_type_id)) { ++ reason = "key type"; ++ goto mismatch; ++ } ++ ++ if (main_def->max_entries != extra_def->max_entries) { ++ reason = "max_entries"; ++ goto mismatch; ++ } ++ if (main_def->map_flags != extra_def->map_flags) { ++ reason = "map_flags"; ++ goto mismatch; ++ } ++ if (main_def->numa_node != extra_def->numa_node) { ++ reason = "numa_node"; ++ goto mismatch; ++ } ++ if (main_def->pinning != extra_def->pinning) { ++ reason = "pinning"; ++ goto mismatch; ++ } ++ ++ if ((main_def->parts & MAP_DEF_INNER_MAP) != (extra_def->parts & MAP_DEF_INNER_MAP)) { ++ reason = "inner map"; ++ goto mismatch; ++ } ++ ++ if (main_def->parts & MAP_DEF_INNER_MAP) { ++ char inner_map_name[128]; ++ ++ snprintf(inner_map_name, sizeof(inner_map_name), "%s.inner", sym_name); ++ ++ return map_defs_match(inner_map_name, ++ main_btf, main_inner_def, NULL, ++ extra_btf, extra_inner_def, NULL); ++ } ++ ++ return true; ++ ++mismatch: ++ pr_warn("global '%s': map %s mismatch\n", sym_name, reason); ++ return false; ++} ++ ++static bool glob_map_defs_match(const char *sym_name, ++ struct bpf_linker *linker, struct glob_sym *glob_sym, ++ struct src_obj *obj, Elf64_Sym *sym, int btf_id) ++{ ++ struct btf_map_def dst_def = {}, dst_inner_def = {}; ++ struct btf_map_def src_def = {}, src_inner_def = {}; ++ const struct btf_type *t; ++ int err; ++ ++ t = btf__type_by_id(obj->btf, btf_id); ++ if (!btf_is_var(t)) { ++ pr_warn("global '%s': invalid map definition type [%d]\n", sym_name, btf_id); ++ return false; ++ } ++ t = skip_mods_and_typedefs(obj->btf, t->type, NULL); ++ ++ err = parse_btf_map_def(sym_name, obj->btf, t, true /*strict*/, &src_def, &src_inner_def); ++ if (err) { ++ pr_warn("global '%s': invalid map definition\n", sym_name); ++ return false; ++ } ++ ++ /* re-parse existing map definition */ ++ t = btf__type_by_id(linker->btf, glob_sym->btf_id); ++ t = skip_mods_and_typedefs(linker->btf, t->type, NULL); ++ err = parse_btf_map_def(sym_name, linker->btf, t, true /*strict*/, &dst_def, &dst_inner_def); ++ if (err) { ++ /* this should not happen, because we already validated it */ ++ pr_warn("global '%s': invalid dst map definition\n", sym_name); ++ return false; ++ } ++ ++ /* Currently extern map definition has to be complete and match ++ * concrete map definition exactly. This restriction might be lifted ++ * in the future. ++ */ ++ return map_defs_match(sym_name, linker->btf, &dst_def, &dst_inner_def, ++ obj->btf, &src_def, &src_inner_def); ++} ++ ++static bool glob_syms_match(const char *sym_name, ++ struct bpf_linker *linker, struct glob_sym *glob_sym, ++ struct src_obj *obj, Elf64_Sym *sym, size_t sym_idx, int btf_id) ++{ ++ const struct btf_type *src_t; ++ ++ /* if we are dealing with externs, BTF types describing both global ++ * and extern VARs/FUNCs should be completely present in all files ++ */ ++ if (!glob_sym->btf_id || !btf_id) { ++ pr_warn("BTF info is missing for global symbol '%s'\n", sym_name); ++ return false; ++ } ++ ++ src_t = btf__type_by_id(obj->btf, btf_id); ++ if (!btf_is_var(src_t) && !btf_is_func(src_t)) { ++ pr_warn("only extern variables and functions are supported, but got '%s' for '%s'\n", ++ btf_kind_str(src_t), sym_name); ++ return false; ++ } ++ ++ /* deal with .maps definitions specially */ ++ if (glob_sym->sec_id && strcmp(linker->secs[glob_sym->sec_id].sec_name, MAPS_ELF_SEC) == 0) ++ return glob_map_defs_match(sym_name, linker, glob_sym, obj, sym, btf_id); ++ ++ if (!glob_sym_btf_matches(sym_name, true /*exact*/, ++ linker->btf, glob_sym->btf_id, obj->btf, btf_id)) ++ return false; ++ ++ return true; ++} ++ ++static bool btf_is_non_static(const struct btf_type *t) ++{ ++ return (btf_is_var(t) && btf_var(t)->linkage != BTF_VAR_STATIC) ++ || (btf_is_func(t) && btf_func_linkage(t) != BTF_FUNC_STATIC); ++} ++ ++static int find_glob_sym_btf(struct src_obj *obj, Elf64_Sym *sym, const char *sym_name, ++ int *out_btf_sec_id, int *out_btf_id) ++{ ++ int i, j, n = btf__get_nr_types(obj->btf), m, btf_id = 0; ++ const struct btf_type *t; ++ const struct btf_var_secinfo *vi; ++ const char *name; ++ ++ for (i = 1; i <= n; i++) { ++ t = btf__type_by_id(obj->btf, i); ++ ++ /* some global and extern FUNCs and VARs might not be associated with any ++ * DATASEC, so try to detect them in the same pass ++ */ ++ if (btf_is_non_static(t)) { ++ name = btf__str_by_offset(obj->btf, t->name_off); ++ if (strcmp(name, sym_name) != 0) ++ continue; ++ ++ /* remember and still try to find DATASEC */ ++ btf_id = i; ++ continue; ++ } ++ ++ if (!btf_is_datasec(t)) ++ continue; ++ ++ vi = btf_var_secinfos(t); ++ for (j = 0, m = btf_vlen(t); j < m; j++, vi++) { ++ t = btf__type_by_id(obj->btf, vi->type); ++ name = btf__str_by_offset(obj->btf, t->name_off); ++ ++ if (strcmp(name, sym_name) != 0) ++ continue; ++ if (btf_is_var(t) && btf_var(t)->linkage == BTF_VAR_STATIC) ++ continue; ++ if (btf_is_func(t) && btf_func_linkage(t) == BTF_FUNC_STATIC) ++ continue; ++ ++ if (btf_id && btf_id != vi->type) { ++ pr_warn("global/extern '%s' BTF is ambiguous: both types #%d and #%u match\n", ++ sym_name, btf_id, vi->type); ++ return -EINVAL; ++ } ++ ++ *out_btf_sec_id = i; ++ *out_btf_id = vi->type; ++ ++ return 0; ++ } ++ } ++ ++ /* free-floating extern or global FUNC */ ++ if (btf_id) { ++ *out_btf_sec_id = 0; ++ *out_btf_id = btf_id; ++ return 0; ++ } ++ ++ pr_warn("failed to find BTF info for global/extern symbol '%s'\n", sym_name); ++ return -ENOENT; ++} ++ ++static struct src_sec *find_src_sec_by_name(struct src_obj *obj, const char *sec_name) ++{ ++ struct src_sec *sec; ++ int i; ++ ++ for (i = 1; i < obj->sec_cnt; i++) { ++ sec = &obj->secs[i]; ++ ++ if (strcmp(sec->sec_name, sec_name) == 0) ++ return sec; ++ } ++ ++ return NULL; ++} ++ ++static int complete_extern_btf_info(struct btf *dst_btf, int dst_id, ++ struct btf *src_btf, int src_id) ++{ ++ struct btf_type *dst_t = btf_type_by_id(dst_btf, dst_id); ++ struct btf_type *src_t = btf_type_by_id(src_btf, src_id); ++ struct btf_param *src_p, *dst_p; ++ const char *s; ++ int i, n, off; ++ ++ /* We already made sure that source and destination types (FUNC or ++ * VAR) match in terms of types and argument names. ++ */ ++ if (btf_is_var(dst_t)) { ++ btf_var(dst_t)->linkage = BTF_VAR_GLOBAL_ALLOCATED; ++ return 0; ++ } ++ ++ dst_t->info = btf_type_info(BTF_KIND_FUNC, BTF_FUNC_GLOBAL, 0); ++ ++ /* now onto FUNC_PROTO types */ ++ src_t = btf_type_by_id(src_btf, src_t->type); ++ dst_t = btf_type_by_id(dst_btf, dst_t->type); ++ ++ /* Fill in all the argument names, which for extern FUNCs are missing. ++ * We'll end up with two copies of FUNCs/VARs for externs, but that ++ * will be taken care of by BTF dedup at the very end. ++ * It might be that BTF types for extern in one file has less/more BTF ++ * information (e.g., FWD instead of full STRUCT/UNION information), ++ * but that should be (in most cases, subject to BTF dedup rules) ++ * handled and resolved by BTF dedup algorithm as well, so we won't ++ * worry about it. Our only job is to make sure that argument names ++ * are populated on both sides, otherwise BTF dedup will pedantically ++ * consider them different. ++ */ ++ src_p = btf_params(src_t); ++ dst_p = btf_params(dst_t); ++ for (i = 0, n = btf_vlen(dst_t); i < n; i++, src_p++, dst_p++) { ++ if (!src_p->name_off) ++ continue; ++ ++ /* src_btf has more complete info, so add name to dst_btf */ ++ s = btf__str_by_offset(src_btf, src_p->name_off); ++ off = btf__add_str(dst_btf, s); ++ if (off < 0) ++ return off; ++ dst_p->name_off = off; ++ } ++ return 0; ++} ++ ++static void sym_update_bind(Elf64_Sym *sym, int sym_bind) ++{ ++ sym->st_info = ELF64_ST_INFO(sym_bind, ELF64_ST_TYPE(sym->st_info)); ++} ++ ++static void sym_update_type(Elf64_Sym *sym, int sym_type) ++{ ++ sym->st_info = ELF64_ST_INFO(ELF64_ST_BIND(sym->st_info), sym_type); ++} ++ ++static void sym_update_visibility(Elf64_Sym *sym, int sym_vis) ++{ ++ /* libelf doesn't provide setters for ST_VISIBILITY, ++ * but it is stored in the lower 2 bits of st_other ++ */ ++ sym->st_other &= ~0x03; ++ sym->st_other |= sym_vis; ++} ++ ++static int linker_append_elf_sym(struct bpf_linker *linker, struct src_obj *obj, ++ Elf64_Sym *sym, const char *sym_name, int src_sym_idx) ++{ ++ struct src_sec *src_sec = NULL; ++ struct dst_sec *dst_sec = NULL; ++ struct glob_sym *glob_sym = NULL; ++ int name_off, sym_type, sym_bind, sym_vis, err; ++ int btf_sec_id = 0, btf_id = 0; ++ size_t dst_sym_idx; ++ Elf64_Sym *dst_sym; ++ bool sym_is_extern; ++ ++ sym_type = ELF64_ST_TYPE(sym->st_info); ++ sym_bind = ELF64_ST_BIND(sym->st_info); ++ sym_vis = ELF64_ST_VISIBILITY(sym->st_other); ++ sym_is_extern = sym->st_shndx == SHN_UNDEF; ++ ++ if (sym_is_extern) { ++ if (!obj->btf) { ++ pr_warn("externs without BTF info are not supported\n"); ++ return -ENOTSUP; ++ } ++ } else if (sym->st_shndx < SHN_LORESERVE) { ++ src_sec = &obj->secs[sym->st_shndx]; ++ if (src_sec->skipped) ++ return 0; ++ dst_sec = &linker->secs[src_sec->dst_id]; ++ ++ /* allow only one STT_SECTION symbol per section */ ++ if (sym_type == STT_SECTION && dst_sec->sec_sym_idx) { ++ obj->sym_map[src_sym_idx] = dst_sec->sec_sym_idx; ++ return 0; ++ } ++ } ++ ++ if (sym_bind == STB_LOCAL) ++ goto add_sym; ++ ++ /* find matching BTF info */ ++ err = find_glob_sym_btf(obj, sym, sym_name, &btf_sec_id, &btf_id); ++ if (err) ++ return err; ++ ++ if (sym_is_extern && btf_sec_id) { ++ const char *sec_name = NULL; ++ const struct btf_type *t; ++ ++ t = btf__type_by_id(obj->btf, btf_sec_id); ++ sec_name = btf__str_by_offset(obj->btf, t->name_off); ++ ++ /* Clang puts unannotated extern vars into ++ * '.extern' BTF DATASEC. Treat them the same ++ * as unannotated extern funcs (which are ++ * currently not put into any DATASECs). ++ * Those don't have associated src_sec/dst_sec. ++ */ ++ if (strcmp(sec_name, BTF_EXTERN_SEC) != 0) { ++ src_sec = find_src_sec_by_name(obj, sec_name); ++ if (!src_sec) { ++ pr_warn("failed to find matching ELF sec '%s'\n", sec_name); ++ return -ENOENT; ++ } ++ dst_sec = &linker->secs[src_sec->dst_id]; ++ } ++ } ++ ++ glob_sym = find_glob_sym(linker, sym_name); ++ if (glob_sym) { ++ /* Preventively resolve to existing symbol. This is ++ * needed for further relocation symbol remapping in ++ * the next step of linking. ++ */ ++ obj->sym_map[src_sym_idx] = glob_sym->sym_idx; ++ ++ /* If both symbols are non-externs, at least one of ++ * them has to be STB_WEAK, otherwise they are in ++ * a conflict with each other. ++ */ ++ if (!sym_is_extern && !glob_sym->is_extern ++ && !glob_sym->is_weak && sym_bind != STB_WEAK) { ++ pr_warn("conflicting non-weak symbol #%d (%s) definition in '%s'\n", ++ src_sym_idx, sym_name, obj->filename); ++ return -EINVAL; ++ } ++ ++ if (!glob_syms_match(sym_name, linker, glob_sym, obj, sym, src_sym_idx, btf_id)) ++ return -EINVAL; ++ ++ dst_sym = get_sym_by_idx(linker, glob_sym->sym_idx); ++ ++ /* If new symbol is strong, then force dst_sym to be strong as ++ * well; this way a mix of weak and non-weak extern ++ * definitions will end up being strong. ++ */ ++ if (sym_bind == STB_GLOBAL) { ++ /* We still need to preserve type (NOTYPE or ++ * OBJECT/FUNC, depending on whether the symbol is ++ * extern or not) ++ */ ++ sym_update_bind(dst_sym, STB_GLOBAL); ++ glob_sym->is_weak = false; ++ } ++ ++ /* Non-default visibility is "contaminating", with stricter ++ * visibility overwriting more permissive ones, even if more ++ * permissive visibility comes from just an extern definition. ++ * Currently only STV_DEFAULT and STV_HIDDEN are allowed and ++ * ensured by ELF symbol sanity checks above. ++ */ ++ if (sym_vis > ELF64_ST_VISIBILITY(dst_sym->st_other)) ++ sym_update_visibility(dst_sym, sym_vis); ++ ++ /* If the new symbol is extern, then regardless if ++ * existing symbol is extern or resolved global, just ++ * keep the existing one untouched. ++ */ ++ if (sym_is_extern) ++ return 0; ++ ++ /* If existing symbol is a strong resolved symbol, bail out, ++ * because we lost resolution battle have nothing to ++ * contribute. We already checked abover that there is no ++ * strong-strong conflict. We also already tightened binding ++ * and visibility, so nothing else to contribute at that point. ++ */ ++ if (!glob_sym->is_extern && sym_bind == STB_WEAK) ++ return 0; ++ ++ /* At this point, new symbol is strong non-extern, ++ * so overwrite glob_sym with new symbol information. ++ * Preserve binding and visibility. ++ */ ++ sym_update_type(dst_sym, sym_type); ++ dst_sym->st_shndx = dst_sec->sec_idx; ++ dst_sym->st_value = src_sec->dst_off + sym->st_value; ++ dst_sym->st_size = sym->st_size; ++ ++ /* see comment below about dst_sec->id vs dst_sec->sec_idx */ ++ glob_sym->sec_id = dst_sec->id; ++ glob_sym->is_extern = false; ++ ++ if (complete_extern_btf_info(linker->btf, glob_sym->btf_id, ++ obj->btf, btf_id)) ++ return -EINVAL; ++ ++ /* request updating VAR's/FUNC's underlying BTF type when appending BTF type */ ++ glob_sym->underlying_btf_id = 0; ++ ++ obj->sym_map[src_sym_idx] = glob_sym->sym_idx; ++ return 0; ++ } ++ ++add_sym: ++ name_off = strset__add_str(linker->strtab_strs, sym_name); ++ if (name_off < 0) ++ return name_off; ++ ++ dst_sym = add_new_sym(linker, &dst_sym_idx); ++ if (!dst_sym) ++ return -ENOMEM; ++ ++ dst_sym->st_name = name_off; ++ dst_sym->st_info = sym->st_info; ++ dst_sym->st_other = sym->st_other; ++ dst_sym->st_shndx = dst_sec ? dst_sec->sec_idx : sym->st_shndx; ++ dst_sym->st_value = (src_sec ? src_sec->dst_off : 0) + sym->st_value; ++ dst_sym->st_size = sym->st_size; ++ ++ obj->sym_map[src_sym_idx] = dst_sym_idx; ++ ++ if (sym_type == STT_SECTION && dst_sym) { ++ dst_sec->sec_sym_idx = dst_sym_idx; ++ dst_sym->st_value = 0; ++ } ++ ++ if (sym_bind != STB_LOCAL) { ++ glob_sym = add_glob_sym(linker); ++ if (!glob_sym) ++ return -ENOMEM; ++ ++ glob_sym->sym_idx = dst_sym_idx; ++ /* we use dst_sec->id (and not dst_sec->sec_idx), because ++ * ephemeral sections (.kconfig, .ksyms, etc) don't have ++ * sec_idx (as they don't have corresponding ELF section), but ++ * still have id. .extern doesn't have even ephemeral section ++ * associated with it, so dst_sec->id == dst_sec->sec_idx == 0. ++ */ ++ glob_sym->sec_id = dst_sec ? dst_sec->id : 0; ++ glob_sym->name_off = name_off; ++ /* we will fill btf_id in during BTF merging step */ ++ glob_sym->btf_id = 0; ++ glob_sym->is_extern = sym_is_extern; ++ glob_sym->is_weak = sym_bind == STB_WEAK; ++ } ++ ++ return 0; ++} ++ ++static int linker_append_elf_relos(struct bpf_linker *linker, struct src_obj *obj) ++{ ++ struct src_sec *src_symtab = &obj->secs[obj->symtab_sec_idx]; ++ struct dst_sec *dst_symtab = &linker->secs[linker->symtab_sec_idx]; ++ int i, err; ++ ++ for (i = 1; i < obj->sec_cnt; i++) { ++ struct src_sec *src_sec, *src_linked_sec; ++ struct dst_sec *dst_sec, *dst_linked_sec; ++ Elf64_Rel *src_rel, *dst_rel; ++ int j, n; ++ ++ src_sec = &obj->secs[i]; ++ if (!is_relo_sec(src_sec)) ++ continue; ++ ++ /* shdr->sh_info points to relocatable section */ ++ src_linked_sec = &obj->secs[src_sec->shdr->sh_info]; ++ if (src_linked_sec->skipped) ++ continue; ++ ++ dst_sec = find_dst_sec_by_name(linker, src_sec->sec_name); ++ if (!dst_sec) { ++ dst_sec = add_dst_sec(linker, src_sec->sec_name); ++ if (!dst_sec) ++ return -ENOMEM; ++ err = init_sec(linker, dst_sec, src_sec); ++ if (err) { ++ pr_warn("failed to init section '%s'\n", src_sec->sec_name); ++ return err; ++ } ++ } else if (!secs_match(dst_sec, src_sec)) { ++ pr_warn("sections %s are not compatible\n", src_sec->sec_name); ++ return -1; ++ } ++ ++ /* shdr->sh_link points to SYMTAB */ ++ dst_sec->shdr->sh_link = linker->symtab_sec_idx; ++ ++ /* shdr->sh_info points to relocated section */ ++ dst_linked_sec = &linker->secs[src_linked_sec->dst_id]; ++ dst_sec->shdr->sh_info = dst_linked_sec->sec_idx; ++ ++ src_sec->dst_id = dst_sec->id; ++ err = extend_sec(linker, dst_sec, src_sec); ++ if (err) ++ return err; ++ ++ src_rel = src_sec->data->d_buf; ++ dst_rel = dst_sec->raw_data + src_sec->dst_off; ++ n = src_sec->shdr->sh_size / src_sec->shdr->sh_entsize; ++ for (j = 0; j < n; j++, src_rel++, dst_rel++) { ++ size_t src_sym_idx = ELF64_R_SYM(src_rel->r_info); ++ size_t sym_type = ELF64_R_TYPE(src_rel->r_info); ++ Elf64_Sym *src_sym, *dst_sym; ++ size_t dst_sym_idx; ++ ++ src_sym_idx = ELF64_R_SYM(src_rel->r_info); ++ src_sym = src_symtab->data->d_buf + sizeof(*src_sym) * src_sym_idx; ++ ++ dst_sym_idx = obj->sym_map[src_sym_idx]; ++ dst_sym = dst_symtab->raw_data + sizeof(*dst_sym) * dst_sym_idx; ++ dst_rel->r_offset += src_linked_sec->dst_off; ++ sym_type = ELF64_R_TYPE(src_rel->r_info); ++ dst_rel->r_info = ELF64_R_INFO(dst_sym_idx, sym_type); ++ ++ if (ELF64_ST_TYPE(src_sym->st_info) == STT_SECTION) { ++ struct src_sec *sec = &obj->secs[src_sym->st_shndx]; ++ struct bpf_insn *insn; ++ ++ if (src_linked_sec->shdr->sh_flags & SHF_EXECINSTR) { ++ /* calls to the very first static function inside ++ * .text section at offset 0 will ++ * reference section symbol, not the ++ * function symbol. Fix that up, ++ * otherwise it won't be possible to ++ * relocate calls to two different ++ * static functions with the same name ++ * (rom two different object files) ++ */ ++ insn = dst_linked_sec->raw_data + dst_rel->r_offset; ++ if (insn->code == (BPF_JMP | BPF_CALL)) ++ insn->imm += sec->dst_off / sizeof(struct bpf_insn); ++ else ++ insn->imm += sec->dst_off; ++ } else { ++ pr_warn("relocation against STT_SECTION in non-exec section is not supported!\n"); ++ return -EINVAL; ++ } ++ } ++ ++ } ++ } ++ ++ return 0; ++} ++ ++static Elf64_Sym *find_sym_by_name(struct src_obj *obj, size_t sec_idx, ++ int sym_type, const char *sym_name) ++{ ++ struct src_sec *symtab = &obj->secs[obj->symtab_sec_idx]; ++ Elf64_Sym *sym = symtab->data->d_buf; ++ int i, n = symtab->shdr->sh_size / symtab->shdr->sh_entsize; ++ int str_sec_idx = symtab->shdr->sh_link; ++ const char *name; ++ ++ for (i = 0; i < n; i++, sym++) { ++ if (sym->st_shndx != sec_idx) ++ continue; ++ if (ELF64_ST_TYPE(sym->st_info) != sym_type) ++ continue; ++ ++ name = elf_strptr(obj->elf, str_sec_idx, sym->st_name); ++ if (!name) ++ return NULL; ++ ++ if (strcmp(sym_name, name) != 0) ++ continue; ++ ++ return sym; ++ } ++ ++ return NULL; ++} ++ ++static int linker_fixup_btf(struct src_obj *obj) ++{ ++ const char *sec_name; ++ struct src_sec *sec; ++ int i, j, n, m; ++ ++ if (!obj->btf) ++ return 0; ++ ++ n = btf__get_nr_types(obj->btf); ++ for (i = 1; i <= n; i++) { ++ struct btf_var_secinfo *vi; ++ struct btf_type *t; ++ ++ t = btf_type_by_id(obj->btf, i); ++ if (btf_kind(t) != BTF_KIND_DATASEC) ++ continue; ++ ++ sec_name = btf__str_by_offset(obj->btf, t->name_off); ++ sec = find_src_sec_by_name(obj, sec_name); ++ if (sec) { ++ /* record actual section size, unless ephemeral */ ++ if (sec->shdr) ++ t->size = sec->shdr->sh_size; ++ } else { ++ /* BTF can have some sections that are not represented ++ * in ELF, e.g., .kconfig, .ksyms, .extern, which are used ++ * for special extern variables. ++ * ++ * For all but one such special (ephemeral) ++ * sections, we pre-create "section shells" to be able ++ * to keep track of extra per-section metadata later ++ * (e.g., those BTF extern variables). ++ * ++ * .extern is even more special, though, because it ++ * contains extern variables that need to be resolved ++ * by static linker, not libbpf and kernel. When such ++ * externs are resolved, we are going to remove them ++ * from .extern BTF section and might end up not ++ * needing it at all. Each resolved extern should have ++ * matching non-extern VAR/FUNC in other sections. ++ * ++ * We do support leaving some of the externs ++ * unresolved, though, to support cases of building ++ * libraries, which will later be linked against final ++ * BPF applications. So if at finalization we still ++ * see unresolved externs, we'll create .extern ++ * section on our own. ++ */ ++ if (strcmp(sec_name, BTF_EXTERN_SEC) == 0) ++ continue; ++ ++ sec = add_src_sec(obj, sec_name); ++ if (!sec) ++ return -ENOMEM; ++ ++ sec->ephemeral = true; ++ sec->sec_idx = 0; /* will match UNDEF shndx in ELF */ ++ } ++ ++ /* remember ELF section and its BTF type ID match */ ++ sec->sec_type_id = i; ++ ++ /* fix up variable offsets */ ++ vi = btf_var_secinfos(t); ++ for (j = 0, m = btf_vlen(t); j < m; j++, vi++) { ++ const struct btf_type *vt = btf__type_by_id(obj->btf, vi->type); ++ const char *var_name = btf__str_by_offset(obj->btf, vt->name_off); ++ int var_linkage = btf_var(vt)->linkage; ++ Elf64_Sym *sym; ++ ++ /* no need to patch up static or extern vars */ ++ if (var_linkage != BTF_VAR_GLOBAL_ALLOCATED) ++ continue; ++ ++ sym = find_sym_by_name(obj, sec->sec_idx, STT_OBJECT, var_name); ++ if (!sym) { ++ pr_warn("failed to find symbol for variable '%s' in section '%s'\n", var_name, sec_name); ++ return -ENOENT; ++ } ++ ++ vi->offset = sym->st_value; ++ } ++ } ++ ++ return 0; ++} ++ ++static int remap_type_id(__u32 *type_id, void *ctx) ++{ ++ int *id_map = ctx; ++ int new_id = id_map[*type_id]; ++ ++ /* Error out if the type wasn't remapped. Ignore VOID which stays VOID. */ ++ if (new_id == 0 && *type_id != 0) { ++ pr_warn("failed to find new ID mapping for original BTF type ID %u\n", *type_id); ++ return -EINVAL; ++ } ++ ++ *type_id = id_map[*type_id]; ++ ++ return 0; ++} ++ ++static int linker_append_btf(struct bpf_linker *linker, struct src_obj *obj) ++{ ++ const struct btf_type *t; ++ int i, j, n, start_id, id; ++ const char *name; ++ ++ if (!obj->btf) ++ return 0; ++ ++ start_id = btf__get_nr_types(linker->btf) + 1; ++ n = btf__get_nr_types(obj->btf); ++ ++ obj->btf_type_map = calloc(n + 1, sizeof(int)); ++ if (!obj->btf_type_map) ++ return -ENOMEM; ++ ++ for (i = 1; i <= n; i++) { ++ struct glob_sym *glob_sym = NULL; ++ ++ t = btf__type_by_id(obj->btf, i); ++ ++ /* DATASECs are handled specially below */ ++ if (btf_kind(t) == BTF_KIND_DATASEC) ++ continue; ++ ++ if (btf_is_non_static(t)) { ++ /* there should be glob_sym already */ ++ name = btf__str_by_offset(obj->btf, t->name_off); ++ glob_sym = find_glob_sym(linker, name); ++ ++ /* VARs without corresponding glob_sym are those that ++ * belong to skipped/deduplicated sections (i.e., ++ * license and version), so just skip them ++ */ ++ if (!glob_sym) ++ continue; ++ ++ /* linker_append_elf_sym() might have requested ++ * updating underlying type ID, if extern was resolved ++ * to strong symbol or weak got upgraded to non-weak ++ */ ++ if (glob_sym->underlying_btf_id == 0) ++ glob_sym->underlying_btf_id = -t->type; ++ ++ /* globals from previous object files that match our ++ * VAR/FUNC already have a corresponding associated ++ * BTF type, so just make sure to use it ++ */ ++ if (glob_sym->btf_id) { ++ /* reuse existing BTF type for global var/func */ ++ obj->btf_type_map[i] = glob_sym->btf_id; ++ continue; ++ } ++ } ++ ++ id = btf__add_type(linker->btf, obj->btf, t); ++ if (id < 0) { ++ pr_warn("failed to append BTF type #%d from file '%s'\n", i, obj->filename); ++ return id; ++ } ++ ++ obj->btf_type_map[i] = id; ++ ++ /* record just appended BTF type for var/func */ ++ if (glob_sym) { ++ glob_sym->btf_id = id; ++ glob_sym->underlying_btf_id = -t->type; ++ } ++ } ++ ++ /* remap all the types except DATASECs */ ++ n = btf__get_nr_types(linker->btf); ++ for (i = start_id; i <= n; i++) { ++ struct btf_type *dst_t = btf_type_by_id(linker->btf, i); ++ ++ if (btf_type_visit_type_ids(dst_t, remap_type_id, obj->btf_type_map)) ++ return -EINVAL; ++ } ++ ++ /* Rewrite VAR/FUNC underlying types (i.e., FUNC's FUNC_PROTO and VAR's ++ * actual type), if necessary ++ */ ++ for (i = 0; i < linker->glob_sym_cnt; i++) { ++ struct glob_sym *glob_sym = &linker->glob_syms[i]; ++ struct btf_type *glob_t; ++ ++ if (glob_sym->underlying_btf_id >= 0) ++ continue; ++ ++ glob_sym->underlying_btf_id = obj->btf_type_map[-glob_sym->underlying_btf_id]; ++ ++ glob_t = btf_type_by_id(linker->btf, glob_sym->btf_id); ++ glob_t->type = glob_sym->underlying_btf_id; ++ } ++ ++ /* append DATASEC info */ ++ for (i = 1; i < obj->sec_cnt; i++) { ++ struct src_sec *src_sec; ++ struct dst_sec *dst_sec; ++ const struct btf_var_secinfo *src_var; ++ struct btf_var_secinfo *dst_var; ++ ++ src_sec = &obj->secs[i]; ++ if (!src_sec->sec_type_id || src_sec->skipped) ++ continue; ++ dst_sec = &linker->secs[src_sec->dst_id]; ++ ++ /* Mark section as having BTF regardless of the presence of ++ * variables. In some cases compiler might generate empty BTF ++ * with no variables information. E.g., when promoting local ++ * array/structure variable initial values and BPF object ++ * file otherwise has no read-only static variables in ++ * .rodata. We need to preserve such empty BTF and just set ++ * correct section size. ++ */ ++ dst_sec->has_btf = true; ++ ++ t = btf__type_by_id(obj->btf, src_sec->sec_type_id); ++ src_var = btf_var_secinfos(t); ++ n = btf_vlen(t); ++ for (j = 0; j < n; j++, src_var++) { ++ void *sec_vars = dst_sec->sec_vars; ++ int new_id = obj->btf_type_map[src_var->type]; ++ struct glob_sym *glob_sym = NULL; ++ ++ t = btf_type_by_id(linker->btf, new_id); ++ if (btf_is_non_static(t)) { ++ name = btf__str_by_offset(linker->btf, t->name_off); ++ glob_sym = find_glob_sym(linker, name); ++ if (glob_sym->sec_id != dst_sec->id) { ++ pr_warn("global '%s': section mismatch %d vs %d\n", ++ name, glob_sym->sec_id, dst_sec->id); ++ return -EINVAL; ++ } ++ } ++ ++ /* If there is already a member (VAR or FUNC) mapped ++ * to the same type, don't add a duplicate entry. ++ * This will happen when multiple object files define ++ * the same extern VARs/FUNCs. ++ */ ++ if (glob_sym && glob_sym->var_idx >= 0) { ++ __s64 sz; ++ ++ dst_var = &dst_sec->sec_vars[glob_sym->var_idx]; ++ /* Because underlying BTF type might have ++ * changed, so might its size have changed, so ++ * re-calculate and update it in sec_var. ++ */ ++ sz = btf__resolve_size(linker->btf, glob_sym->underlying_btf_id); ++ if (sz < 0) { ++ pr_warn("global '%s': failed to resolve size of underlying type: %d\n", ++ name, (int)sz); ++ return -EINVAL; ++ } ++ dst_var->size = sz; ++ continue; ++ } ++ ++ sec_vars = libbpf_reallocarray(sec_vars, ++ dst_sec->sec_var_cnt + 1, ++ sizeof(*dst_sec->sec_vars)); ++ if (!sec_vars) ++ return -ENOMEM; ++ ++ dst_sec->sec_vars = sec_vars; ++ dst_sec->sec_var_cnt++; ++ ++ dst_var = &dst_sec->sec_vars[dst_sec->sec_var_cnt - 1]; ++ dst_var->type = obj->btf_type_map[src_var->type]; ++ dst_var->size = src_var->size; ++ dst_var->offset = src_sec->dst_off + src_var->offset; ++ ++ if (glob_sym) ++ glob_sym->var_idx = dst_sec->sec_var_cnt - 1; ++ } ++ } ++ ++ return 0; ++} ++ ++static void *add_btf_ext_rec(struct btf_ext_sec_data *ext_data, const void *src_rec) ++{ ++ void *tmp; ++ ++ tmp = libbpf_reallocarray(ext_data->recs, ext_data->rec_cnt + 1, ext_data->rec_sz); ++ if (!tmp) ++ return NULL; ++ ext_data->recs = tmp; ++ ++ tmp += ext_data->rec_cnt * ext_data->rec_sz; ++ memcpy(tmp, src_rec, ext_data->rec_sz); ++ ++ ext_data->rec_cnt++; ++ ++ return tmp; ++} ++ ++static int linker_append_btf_ext(struct bpf_linker *linker, struct src_obj *obj) ++{ ++ const struct btf_ext_info_sec *ext_sec; ++ const char *sec_name, *s; ++ struct src_sec *src_sec; ++ struct dst_sec *dst_sec; ++ int rec_sz, str_off, i; ++ ++ if (!obj->btf_ext) ++ return 0; ++ ++ rec_sz = obj->btf_ext->func_info.rec_size; ++ for_each_btf_ext_sec(&obj->btf_ext->func_info, ext_sec) { ++ struct bpf_func_info_min *src_rec, *dst_rec; ++ ++ sec_name = btf__name_by_offset(obj->btf, ext_sec->sec_name_off); ++ src_sec = find_src_sec_by_name(obj, sec_name); ++ if (!src_sec) { ++ pr_warn("can't find section '%s' referenced from .BTF.ext\n", sec_name); ++ return -EINVAL; ++ } ++ dst_sec = &linker->secs[src_sec->dst_id]; ++ ++ if (dst_sec->func_info.rec_sz == 0) ++ dst_sec->func_info.rec_sz = rec_sz; ++ if (dst_sec->func_info.rec_sz != rec_sz) { ++ pr_warn("incompatible .BTF.ext record sizes for section '%s'\n", sec_name); ++ return -EINVAL; ++ } ++ ++ for_each_btf_ext_rec(&obj->btf_ext->func_info, ext_sec, i, src_rec) { ++ dst_rec = add_btf_ext_rec(&dst_sec->func_info, src_rec); ++ if (!dst_rec) ++ return -ENOMEM; ++ ++ dst_rec->insn_off += src_sec->dst_off; ++ dst_rec->type_id = obj->btf_type_map[dst_rec->type_id]; ++ } ++ } ++ ++ rec_sz = obj->btf_ext->line_info.rec_size; ++ for_each_btf_ext_sec(&obj->btf_ext->line_info, ext_sec) { ++ struct bpf_line_info_min *src_rec, *dst_rec; ++ ++ sec_name = btf__name_by_offset(obj->btf, ext_sec->sec_name_off); ++ src_sec = find_src_sec_by_name(obj, sec_name); ++ if (!src_sec) { ++ pr_warn("can't find section '%s' referenced from .BTF.ext\n", sec_name); ++ return -EINVAL; ++ } ++ dst_sec = &linker->secs[src_sec->dst_id]; ++ ++ if (dst_sec->line_info.rec_sz == 0) ++ dst_sec->line_info.rec_sz = rec_sz; ++ if (dst_sec->line_info.rec_sz != rec_sz) { ++ pr_warn("incompatible .BTF.ext record sizes for section '%s'\n", sec_name); ++ return -EINVAL; ++ } ++ ++ for_each_btf_ext_rec(&obj->btf_ext->line_info, ext_sec, i, src_rec) { ++ dst_rec = add_btf_ext_rec(&dst_sec->line_info, src_rec); ++ if (!dst_rec) ++ return -ENOMEM; ++ ++ dst_rec->insn_off += src_sec->dst_off; ++ ++ s = btf__str_by_offset(obj->btf, src_rec->file_name_off); ++ str_off = btf__add_str(linker->btf, s); ++ if (str_off < 0) ++ return -ENOMEM; ++ dst_rec->file_name_off = str_off; ++ ++ s = btf__str_by_offset(obj->btf, src_rec->line_off); ++ str_off = btf__add_str(linker->btf, s); ++ if (str_off < 0) ++ return -ENOMEM; ++ dst_rec->line_off = str_off; ++ ++ /* dst_rec->line_col is fine */ ++ } ++ } ++ ++ rec_sz = obj->btf_ext->core_relo_info.rec_size; ++ for_each_btf_ext_sec(&obj->btf_ext->core_relo_info, ext_sec) { ++ struct bpf_core_relo *src_rec, *dst_rec; ++ ++ sec_name = btf__name_by_offset(obj->btf, ext_sec->sec_name_off); ++ src_sec = find_src_sec_by_name(obj, sec_name); ++ if (!src_sec) { ++ pr_warn("can't find section '%s' referenced from .BTF.ext\n", sec_name); ++ return -EINVAL; ++ } ++ dst_sec = &linker->secs[src_sec->dst_id]; ++ ++ if (dst_sec->core_relo_info.rec_sz == 0) ++ dst_sec->core_relo_info.rec_sz = rec_sz; ++ if (dst_sec->core_relo_info.rec_sz != rec_sz) { ++ pr_warn("incompatible .BTF.ext record sizes for section '%s'\n", sec_name); ++ return -EINVAL; ++ } ++ ++ for_each_btf_ext_rec(&obj->btf_ext->core_relo_info, ext_sec, i, src_rec) { ++ dst_rec = add_btf_ext_rec(&dst_sec->core_relo_info, src_rec); ++ if (!dst_rec) ++ return -ENOMEM; ++ ++ dst_rec->insn_off += src_sec->dst_off; ++ dst_rec->type_id = obj->btf_type_map[dst_rec->type_id]; ++ ++ s = btf__str_by_offset(obj->btf, src_rec->access_str_off); ++ str_off = btf__add_str(linker->btf, s); ++ if (str_off < 0) ++ return -ENOMEM; ++ dst_rec->access_str_off = str_off; ++ ++ /* dst_rec->kind is fine */ ++ } ++ } ++ ++ return 0; ++} ++ ++int bpf_linker__finalize(struct bpf_linker *linker) ++{ ++ struct dst_sec *sec; ++ size_t strs_sz; ++ const void *strs; ++ int err, i; ++ ++ if (!linker->elf) ++ return -EINVAL; ++ ++ err = finalize_btf(linker); ++ if (err) ++ return err; ++ ++ /* Finalize strings */ ++ strs_sz = strset__data_size(linker->strtab_strs); ++ strs = strset__data(linker->strtab_strs); ++ ++ sec = &linker->secs[linker->strtab_sec_idx]; ++ sec->data->d_align = 1; ++ sec->data->d_off = 0LL; ++ sec->data->d_buf = (void *)strs; ++ sec->data->d_type = ELF_T_BYTE; ++ sec->data->d_size = strs_sz; ++ sec->shdr->sh_size = strs_sz; ++ ++ for (i = 1; i < linker->sec_cnt; i++) { ++ sec = &linker->secs[i]; ++ ++ /* STRTAB is handled specially above */ ++ if (sec->sec_idx == linker->strtab_sec_idx) ++ continue; ++ ++ /* special ephemeral sections (.ksyms, .kconfig, etc) */ ++ if (!sec->scn) ++ continue; ++ ++ sec->data->d_buf = sec->raw_data; ++ } ++ ++ /* Finalize ELF layout */ ++ if (elf_update(linker->elf, ELF_C_NULL) < 0) { ++ err = -errno; ++ pr_warn_elf("failed to finalize ELF layout"); ++ return err; ++ } ++ ++ /* Write out final ELF contents */ ++ if (elf_update(linker->elf, ELF_C_WRITE) < 0) { ++ err = -errno; ++ pr_warn_elf("failed to write ELF contents"); ++ return err; ++ } ++ ++ elf_end(linker->elf); ++ close(linker->fd); ++ ++ linker->elf = NULL; ++ linker->fd = -1; ++ ++ return 0; ++} ++ ++static int emit_elf_data_sec(struct bpf_linker *linker, const char *sec_name, ++ size_t align, const void *raw_data, size_t raw_sz) ++{ ++ Elf_Scn *scn; ++ Elf_Data *data; ++ Elf64_Shdr *shdr; ++ int name_off; ++ ++ name_off = strset__add_str(linker->strtab_strs, sec_name); ++ if (name_off < 0) ++ return name_off; ++ ++ scn = elf_newscn(linker->elf); ++ if (!scn) ++ return -ENOMEM; ++ data = elf_newdata(scn); ++ if (!data) ++ return -ENOMEM; ++ shdr = elf64_getshdr(scn); ++ if (!shdr) ++ return -EINVAL; ++ ++ shdr->sh_name = name_off; ++ shdr->sh_type = SHT_PROGBITS; ++ shdr->sh_flags = 0; ++ shdr->sh_size = raw_sz; ++ shdr->sh_link = 0; ++ shdr->sh_info = 0; ++ shdr->sh_addralign = align; ++ shdr->sh_entsize = 0; ++ ++ data->d_type = ELF_T_BYTE; ++ data->d_size = raw_sz; ++ data->d_buf = (void *)raw_data; ++ data->d_align = align; ++ data->d_off = 0; ++ ++ return 0; ++} ++ ++static int finalize_btf(struct bpf_linker *linker) ++{ ++ struct btf *btf = linker->btf; ++ const void *raw_data; ++ int i, j, id, err; ++ __u32 raw_sz; ++ ++ /* bail out if no BTF data was produced */ ++ if (btf__get_nr_types(linker->btf) == 0) ++ return 0; ++ ++ for (i = 1; i < linker->sec_cnt; i++) { ++ struct dst_sec *sec = &linker->secs[i]; ++ ++ if (!sec->has_btf) ++ continue; ++ ++ id = btf__add_datasec(btf, sec->sec_name, sec->sec_sz); ++ if (id < 0) { ++ pr_warn("failed to add consolidated BTF type for datasec '%s': %d\n", ++ sec->sec_name, id); ++ return id; ++ } ++ ++ for (j = 0; j < sec->sec_var_cnt; j++) { ++ struct btf_var_secinfo *vi = &sec->sec_vars[j]; ++ ++ if (btf__add_datasec_var_info(btf, vi->type, vi->offset, vi->size)) ++ return -EINVAL; ++ } ++ } ++ ++ err = finalize_btf_ext(linker); ++ if (err) { ++ pr_warn(".BTF.ext generation failed: %d\n", err); ++ return err; ++ } ++ ++ err = btf__dedup(linker->btf, linker->btf_ext, NULL); ++ if (err) { ++ pr_warn("BTF dedup failed: %d\n", err); ++ return err; ++ } ++ ++ /* Emit .BTF section */ ++ raw_data = btf__get_raw_data(linker->btf, &raw_sz); ++ if (!raw_data) ++ return -ENOMEM; ++ ++ err = emit_elf_data_sec(linker, BTF_ELF_SEC, 8, raw_data, raw_sz); ++ if (err) { ++ pr_warn("failed to write out .BTF ELF section: %d\n", err); ++ return err; ++ } ++ ++ /* Emit .BTF.ext section */ ++ if (linker->btf_ext) { ++ raw_data = btf_ext__get_raw_data(linker->btf_ext, &raw_sz); ++ if (!raw_data) ++ return -ENOMEM; ++ ++ err = emit_elf_data_sec(linker, BTF_EXT_ELF_SEC, 8, raw_data, raw_sz); ++ if (err) { ++ pr_warn("failed to write out .BTF.ext ELF section: %d\n", err); ++ return err; ++ } ++ } ++ ++ return 0; ++} ++ ++static int emit_btf_ext_data(struct bpf_linker *linker, void *output, ++ const char *sec_name, struct btf_ext_sec_data *sec_data) ++{ ++ struct btf_ext_info_sec *sec_info; ++ void *cur = output; ++ int str_off; ++ size_t sz; ++ ++ if (!sec_data->rec_cnt) ++ return 0; ++ ++ str_off = btf__add_str(linker->btf, sec_name); ++ if (str_off < 0) ++ return -ENOMEM; ++ ++ sec_info = cur; ++ sec_info->sec_name_off = str_off; ++ sec_info->num_info = sec_data->rec_cnt; ++ cur += sizeof(struct btf_ext_info_sec); ++ ++ sz = sec_data->rec_cnt * sec_data->rec_sz; ++ memcpy(cur, sec_data->recs, sz); ++ cur += sz; ++ ++ return cur - output; ++} ++ ++static int finalize_btf_ext(struct bpf_linker *linker) ++{ ++ size_t funcs_sz = 0, lines_sz = 0, core_relos_sz = 0, total_sz = 0; ++ size_t func_rec_sz = 0, line_rec_sz = 0, core_relo_rec_sz = 0; ++ struct btf_ext_header *hdr; ++ void *data, *cur; ++ int i, err, sz; ++ ++ /* validate that all sections have the same .BTF.ext record sizes ++ * and calculate total data size for each type of data (func info, ++ * line info, core relos) ++ */ ++ for (i = 1; i < linker->sec_cnt; i++) { ++ struct dst_sec *sec = &linker->secs[i]; ++ ++ if (sec->func_info.rec_cnt) { ++ if (func_rec_sz == 0) ++ func_rec_sz = sec->func_info.rec_sz; ++ if (func_rec_sz != sec->func_info.rec_sz) { ++ pr_warn("mismatch in func_info record size %zu != %u\n", ++ func_rec_sz, sec->func_info.rec_sz); ++ return -EINVAL; ++ } ++ ++ funcs_sz += sizeof(struct btf_ext_info_sec) + func_rec_sz * sec->func_info.rec_cnt; ++ } ++ if (sec->line_info.rec_cnt) { ++ if (line_rec_sz == 0) ++ line_rec_sz = sec->line_info.rec_sz; ++ if (line_rec_sz != sec->line_info.rec_sz) { ++ pr_warn("mismatch in line_info record size %zu != %u\n", ++ line_rec_sz, sec->line_info.rec_sz); ++ return -EINVAL; ++ } ++ ++ lines_sz += sizeof(struct btf_ext_info_sec) + line_rec_sz * sec->line_info.rec_cnt; ++ } ++ if (sec->core_relo_info.rec_cnt) { ++ if (core_relo_rec_sz == 0) ++ core_relo_rec_sz = sec->core_relo_info.rec_sz; ++ if (core_relo_rec_sz != sec->core_relo_info.rec_sz) { ++ pr_warn("mismatch in core_relo_info record size %zu != %u\n", ++ core_relo_rec_sz, sec->core_relo_info.rec_sz); ++ return -EINVAL; ++ } ++ ++ core_relos_sz += sizeof(struct btf_ext_info_sec) + core_relo_rec_sz * sec->core_relo_info.rec_cnt; ++ } ++ } ++ ++ if (!funcs_sz && !lines_sz && !core_relos_sz) ++ return 0; ++ ++ total_sz += sizeof(struct btf_ext_header); ++ if (funcs_sz) { ++ funcs_sz += sizeof(__u32); /* record size prefix */ ++ total_sz += funcs_sz; ++ } ++ if (lines_sz) { ++ lines_sz += sizeof(__u32); /* record size prefix */ ++ total_sz += lines_sz; ++ } ++ if (core_relos_sz) { ++ core_relos_sz += sizeof(__u32); /* record size prefix */ ++ total_sz += core_relos_sz; ++ } ++ ++ cur = data = calloc(1, total_sz); ++ if (!data) ++ return -ENOMEM; ++ ++ hdr = cur; ++ hdr->magic = BTF_MAGIC; ++ hdr->version = BTF_VERSION; ++ hdr->flags = 0; ++ hdr->hdr_len = sizeof(struct btf_ext_header); ++ cur += sizeof(struct btf_ext_header); ++ ++ /* All offsets are in bytes relative to the end of this header */ ++ hdr->func_info_off = 0; ++ hdr->func_info_len = funcs_sz; ++ hdr->line_info_off = funcs_sz; ++ hdr->line_info_len = lines_sz; ++ hdr->core_relo_off = funcs_sz + lines_sz; ++ hdr->core_relo_len = core_relos_sz; ++ ++ if (funcs_sz) { ++ *(__u32 *)cur = func_rec_sz; ++ cur += sizeof(__u32); ++ ++ for (i = 1; i < linker->sec_cnt; i++) { ++ struct dst_sec *sec = &linker->secs[i]; ++ ++ sz = emit_btf_ext_data(linker, cur, sec->sec_name, &sec->func_info); ++ if (sz < 0) { ++ err = sz; ++ goto out; ++ } ++ ++ cur += sz; ++ } ++ } ++ ++ if (lines_sz) { ++ *(__u32 *)cur = line_rec_sz; ++ cur += sizeof(__u32); ++ ++ for (i = 1; i < linker->sec_cnt; i++) { ++ struct dst_sec *sec = &linker->secs[i]; ++ ++ sz = emit_btf_ext_data(linker, cur, sec->sec_name, &sec->line_info); ++ if (sz < 0) { ++ err = sz; ++ goto out; ++ } ++ ++ cur += sz; ++ } ++ } ++ ++ if (core_relos_sz) { ++ *(__u32 *)cur = core_relo_rec_sz; ++ cur += sizeof(__u32); ++ ++ for (i = 1; i < linker->sec_cnt; i++) { ++ struct dst_sec *sec = &linker->secs[i]; ++ ++ sz = emit_btf_ext_data(linker, cur, sec->sec_name, &sec->core_relo_info); ++ if (sz < 0) { ++ err = sz; ++ goto out; ++ } ++ ++ cur += sz; ++ } ++ } ++ ++ linker->btf_ext = btf_ext__new(data, total_sz); ++ err = libbpf_get_error(linker->btf_ext); ++ if (err) { ++ linker->btf_ext = NULL; ++ pr_warn("failed to parse final .BTF.ext data: %d\n", err); ++ goto out; ++ } ++ ++out: ++ free(data); ++ return err; ++} +Index: dwarves-dfsg-1.21/lib/bpf/src/netlink.c +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/netlink.c ++++ dwarves-dfsg-1.21/lib/bpf/src/netlink.c +@@ -4,7 +4,10 @@ + #include + #include + #include ++#include + #include ++#include ++#include + #include + #include + #include +@@ -40,7 +43,7 @@ static int libbpf_netlink_open(__u32 *nl + memset(&sa, 0, sizeof(sa)); + sa.nl_family = AF_NETLINK; + +- sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); ++ sock = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE); + if (sock < 0) + return -errno; + +@@ -73,9 +76,20 @@ cleanup: + return ret; + } + +-static int bpf_netlink_recv(int sock, __u32 nl_pid, int seq, +- __dump_nlmsg_t _fn, libbpf_dump_nlmsg_t fn, +- void *cookie) ++static void libbpf_netlink_close(int sock) ++{ ++ close(sock); ++} ++ ++enum { ++ NL_CONT, ++ NL_NEXT, ++ NL_DONE, ++}; ++ ++static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq, ++ __dump_nlmsg_t _fn, libbpf_dump_nlmsg_t fn, ++ void *cookie) + { + bool multipart = true; + struct nlmsgerr *err; +@@ -84,6 +98,7 @@ static int bpf_netlink_recv(int sock, __ + int len, ret; + + while (multipart) { ++start: + multipart = false; + len = recv(sock, buf, sizeof(buf), 0); + if (len < 0) { +@@ -121,8 +136,16 @@ static int bpf_netlink_recv(int sock, __ + } + if (_fn) { + ret = _fn(nh, fn, cookie); +- if (ret) ++ switch (ret) { ++ case NL_CONT: ++ break; ++ case NL_NEXT: ++ goto start; ++ case NL_DONE: ++ return 0; ++ default: + return ret; ++ } + } + } + } +@@ -131,72 +154,72 @@ done: + return ret; + } + ++static int libbpf_netlink_send_recv(struct nlmsghdr *nh, ++ __dump_nlmsg_t parse_msg, ++ libbpf_dump_nlmsg_t parse_attr, ++ void *cookie) ++{ ++ __u32 nl_pid = 0; ++ int sock, ret; ++ ++ sock = libbpf_netlink_open(&nl_pid); ++ if (sock < 0) ++ return sock; ++ ++ nh->nlmsg_pid = 0; ++ nh->nlmsg_seq = time(NULL); ++ ++ if (send(sock, nh, nh->nlmsg_len, 0) < 0) { ++ ret = -errno; ++ goto out; ++ } ++ ++ ret = libbpf_netlink_recv(sock, nl_pid, nh->nlmsg_seq, ++ parse_msg, parse_attr, cookie); ++out: ++ libbpf_netlink_close(sock); ++ return ret; ++} ++ + static int __bpf_set_link_xdp_fd_replace(int ifindex, int fd, int old_fd, + __u32 flags) + { +- int sock, seq = 0, ret; +- struct nlattr *nla, *nla_xdp; ++ struct nlattr *nla; ++ int ret; + struct { + struct nlmsghdr nh; + struct ifinfomsg ifinfo; + char attrbuf[64]; + } req; +- __u32 nl_pid = 0; +- +- sock = libbpf_netlink_open(&nl_pid); +- if (sock < 0) +- return sock; + + memset(&req, 0, sizeof(req)); +- req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); +- req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; +- req.nh.nlmsg_type = RTM_SETLINK; +- req.nh.nlmsg_pid = 0; +- req.nh.nlmsg_seq = ++seq; ++ req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); ++ req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; ++ req.nh.nlmsg_type = RTM_SETLINK; + req.ifinfo.ifi_family = AF_UNSPEC; +- req.ifinfo.ifi_index = ifindex; +- +- /* started nested attribute for XDP */ +- nla = (struct nlattr *)(((char *)&req) +- + NLMSG_ALIGN(req.nh.nlmsg_len)); +- nla->nla_type = NLA_F_NESTED | IFLA_XDP; +- nla->nla_len = NLA_HDRLEN; +- +- /* add XDP fd */ +- nla_xdp = (struct nlattr *)((char *)nla + nla->nla_len); +- nla_xdp->nla_type = IFLA_XDP_FD; +- nla_xdp->nla_len = NLA_HDRLEN + sizeof(int); +- memcpy((char *)nla_xdp + NLA_HDRLEN, &fd, sizeof(fd)); +- nla->nla_len += nla_xdp->nla_len; ++ req.ifinfo.ifi_index = ifindex; + +- /* if user passed in any flags, add those too */ ++ nla = nlattr_begin_nested(&req.nh, sizeof(req), IFLA_XDP); ++ if (!nla) ++ return -EMSGSIZE; ++ ret = nlattr_add(&req.nh, sizeof(req), IFLA_XDP_FD, &fd, sizeof(fd)); ++ if (ret < 0) ++ return ret; + if (flags) { +- nla_xdp = (struct nlattr *)((char *)nla + nla->nla_len); +- nla_xdp->nla_type = IFLA_XDP_FLAGS; +- nla_xdp->nla_len = NLA_HDRLEN + sizeof(flags); +- memcpy((char *)nla_xdp + NLA_HDRLEN, &flags, sizeof(flags)); +- nla->nla_len += nla_xdp->nla_len; ++ ret = nlattr_add(&req.nh, sizeof(req), IFLA_XDP_FLAGS, &flags, ++ sizeof(flags)); ++ if (ret < 0) ++ return ret; + } +- + if (flags & XDP_FLAGS_REPLACE) { +- nla_xdp = (struct nlattr *)((char *)nla + nla->nla_len); +- nla_xdp->nla_type = IFLA_XDP_EXPECTED_FD; +- nla_xdp->nla_len = NLA_HDRLEN + sizeof(old_fd); +- memcpy((char *)nla_xdp + NLA_HDRLEN, &old_fd, sizeof(old_fd)); +- nla->nla_len += nla_xdp->nla_len; ++ ret = nlattr_add(&req.nh, sizeof(req), IFLA_XDP_EXPECTED_FD, ++ &old_fd, sizeof(old_fd)); ++ if (ret < 0) ++ return ret; + } ++ nlattr_end_nested(&req.nh, nla); + +- req.nh.nlmsg_len += NLA_ALIGN(nla->nla_len); +- +- if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) { +- ret = -errno; +- goto cleanup; +- } +- ret = bpf_netlink_recv(sock, nl_pid, seq, NULL, NULL, NULL); +- +-cleanup: +- close(sock); +- return ret; ++ return libbpf_netlink_send_recv(&req.nh, NULL, NULL, NULL); + } + + int bpf_set_link_xdp_fd_opts(int ifindex, int fd, __u32 flags, +@@ -212,9 +235,7 @@ int bpf_set_link_xdp_fd_opts(int ifindex + flags |= XDP_FLAGS_REPLACE; + } + +- return __bpf_set_link_xdp_fd_replace(ifindex, fd, +- old_fd, +- flags); ++ return __bpf_set_link_xdp_fd_replace(ifindex, fd, old_fd, flags); + } + + int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags) +@@ -231,6 +252,7 @@ static int __dump_link_nlmsg(struct nlms + + len = nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*ifi)); + attr = (struct nlattr *) ((void *) ifi + NLMSG_ALIGN(sizeof(*ifi))); ++ + if (libbpf_nla_parse(tb, IFLA_MAX, attr, len, NULL) != 0) + return -LIBBPF_ERRNO__NLPARSE; + +@@ -282,16 +304,21 @@ static int get_xdp_info(void *cookie, vo + return 0; + } + +-static int libbpf_nl_get_link(int sock, unsigned int nl_pid, +- libbpf_dump_nlmsg_t dump_link_nlmsg, void *cookie); +- + int bpf_get_link_xdp_info(int ifindex, struct xdp_link_info *info, + size_t info_size, __u32 flags) + { + struct xdp_id_md xdp_id = {}; +- int sock, ret; +- __u32 nl_pid = 0; + __u32 mask; ++ int ret; ++ struct { ++ struct nlmsghdr nh; ++ struct ifinfomsg ifm; ++ } req = { ++ .nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)), ++ .nh.nlmsg_type = RTM_GETLINK, ++ .nh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST, ++ .ifm.ifi_family = AF_PACKET, ++ }; + + if (flags & ~XDP_FLAGS_MASK || !info_size) + return -EINVAL; +@@ -302,14 +329,11 @@ int bpf_get_link_xdp_info(int ifindex, s + if (flags && flags & mask) + return -EINVAL; + +- sock = libbpf_netlink_open(&nl_pid); +- if (sock < 0) +- return sock; +- + xdp_id.ifindex = ifindex; + xdp_id.flags = flags; + +- ret = libbpf_nl_get_link(sock, nl_pid, get_xdp_info, &xdp_id); ++ ret = libbpf_netlink_send_recv(&req.nh, __dump_link_nlmsg, ++ get_xdp_info, &xdp_id); + if (!ret) { + size_t sz = min(info_size, sizeof(xdp_id.info)); + +@@ -317,7 +341,6 @@ int bpf_get_link_xdp_info(int ifindex, s + memset((void *) info + sz, 0, info_size - sz); + } + +- close(sock); + return ret; + } + +@@ -349,24 +372,403 @@ int bpf_get_link_xdp_id(int ifindex, __u + return ret; + } + +-int libbpf_nl_get_link(int sock, unsigned int nl_pid, +- libbpf_dump_nlmsg_t dump_link_nlmsg, void *cookie) ++typedef int (*qdisc_config_t)(struct nlmsghdr *nh, struct tcmsg *t, ++ size_t maxsz); ++ ++static int clsact_config(struct nlmsghdr *nh, struct tcmsg *t, size_t maxsz) + { ++ t->tcm_parent = TC_H_CLSACT; ++ t->tcm_handle = TC_H_MAKE(TC_H_CLSACT, 0); ++ ++ return nlattr_add(nh, maxsz, TCA_KIND, "clsact", sizeof("clsact")); ++} ++ ++static int attach_point_to_config(struct bpf_tc_hook *hook, ++ qdisc_config_t *config) ++{ ++ switch (OPTS_GET(hook, attach_point, 0)) { ++ case BPF_TC_INGRESS: ++ case BPF_TC_EGRESS: ++ case BPF_TC_INGRESS | BPF_TC_EGRESS: ++ if (OPTS_GET(hook, parent, 0)) ++ return -EINVAL; ++ *config = &clsact_config; ++ return 0; ++ case BPF_TC_CUSTOM: ++ return -EOPNOTSUPP; ++ default: ++ return -EINVAL; ++ } ++} ++ ++static int tc_get_tcm_parent(enum bpf_tc_attach_point attach_point, ++ __u32 *parent) ++{ ++ switch (attach_point) { ++ case BPF_TC_INGRESS: ++ case BPF_TC_EGRESS: ++ if (*parent) ++ return -EINVAL; ++ *parent = TC_H_MAKE(TC_H_CLSACT, ++ attach_point == BPF_TC_INGRESS ? ++ TC_H_MIN_INGRESS : TC_H_MIN_EGRESS); ++ break; ++ case BPF_TC_CUSTOM: ++ if (!*parent) ++ return -EINVAL; ++ break; ++ default: ++ return -EINVAL; ++ } ++ return 0; ++} ++ ++static int tc_qdisc_modify(struct bpf_tc_hook *hook, int cmd, int flags) ++{ ++ qdisc_config_t config; ++ int ret; + struct { +- struct nlmsghdr nlh; +- struct ifinfomsg ifm; +- } req = { +- .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)), +- .nlh.nlmsg_type = RTM_GETLINK, +- .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST, +- .ifm.ifi_family = AF_PACKET, +- }; +- int seq = time(NULL); ++ struct nlmsghdr nh; ++ struct tcmsg tc; ++ char buf[256]; ++ } req; ++ ++ ret = attach_point_to_config(hook, &config); ++ if (ret < 0) ++ return ret; ++ ++ memset(&req, 0, sizeof(req)); ++ req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)); ++ req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; ++ req.nh.nlmsg_type = cmd; ++ req.tc.tcm_family = AF_UNSPEC; ++ req.tc.tcm_ifindex = OPTS_GET(hook, ifindex, 0); ++ ++ ret = config(&req.nh, &req.tc, sizeof(req)); ++ if (ret < 0) ++ return ret; ++ ++ return libbpf_netlink_send_recv(&req.nh, NULL, NULL, NULL); ++} ++ ++static int tc_qdisc_create_excl(struct bpf_tc_hook *hook) ++{ ++ return tc_qdisc_modify(hook, RTM_NEWQDISC, NLM_F_CREATE); ++} ++ ++static int tc_qdisc_delete(struct bpf_tc_hook *hook) ++{ ++ return tc_qdisc_modify(hook, RTM_DELQDISC, 0); ++} ++ ++int bpf_tc_hook_create(struct bpf_tc_hook *hook) ++{ ++ if (!hook || !OPTS_VALID(hook, bpf_tc_hook) || ++ OPTS_GET(hook, ifindex, 0) <= 0) ++ return -EINVAL; ++ ++ return tc_qdisc_create_excl(hook); ++} ++ ++static int __bpf_tc_detach(const struct bpf_tc_hook *hook, ++ const struct bpf_tc_opts *opts, ++ const bool flush); ++ ++int bpf_tc_hook_destroy(struct bpf_tc_hook *hook) ++{ ++ if (!hook || !OPTS_VALID(hook, bpf_tc_hook) || ++ OPTS_GET(hook, ifindex, 0) <= 0) ++ return -EINVAL; ++ ++ switch (OPTS_GET(hook, attach_point, 0)) { ++ case BPF_TC_INGRESS: ++ case BPF_TC_EGRESS: ++ return __bpf_tc_detach(hook, NULL, true); ++ case BPF_TC_INGRESS | BPF_TC_EGRESS: ++ return tc_qdisc_delete(hook); ++ case BPF_TC_CUSTOM: ++ return -EOPNOTSUPP; ++ default: ++ return -EINVAL; ++ } ++} ++ ++struct bpf_cb_ctx { ++ struct bpf_tc_opts *opts; ++ bool processed; ++}; ++ ++static int __get_tc_info(void *cookie, struct tcmsg *tc, struct nlattr **tb, ++ bool unicast) ++{ ++ struct nlattr *tbb[TCA_BPF_MAX + 1]; ++ struct bpf_cb_ctx *info = cookie; ++ ++ if (!info || !info->opts) ++ return -EINVAL; ++ if (unicast && info->processed) ++ return -EINVAL; ++ if (!tb[TCA_OPTIONS]) ++ return NL_CONT; ++ ++ libbpf_nla_parse_nested(tbb, TCA_BPF_MAX, tb[TCA_OPTIONS], NULL); ++ if (!tbb[TCA_BPF_ID]) ++ return -EINVAL; ++ ++ OPTS_SET(info->opts, prog_id, libbpf_nla_getattr_u32(tbb[TCA_BPF_ID])); ++ OPTS_SET(info->opts, handle, tc->tcm_handle); ++ OPTS_SET(info->opts, priority, TC_H_MAJ(tc->tcm_info) >> 16); ++ ++ info->processed = true; ++ return unicast ? NL_NEXT : NL_DONE; ++} ++ ++static int get_tc_info(struct nlmsghdr *nh, libbpf_dump_nlmsg_t fn, ++ void *cookie) ++{ ++ struct tcmsg *tc = NLMSG_DATA(nh); ++ struct nlattr *tb[TCA_MAX + 1]; ++ ++ libbpf_nla_parse(tb, TCA_MAX, ++ (struct nlattr *)((char *)tc + NLMSG_ALIGN(sizeof(*tc))), ++ NLMSG_PAYLOAD(nh, sizeof(*tc)), NULL); ++ if (!tb[TCA_KIND]) ++ return NL_CONT; ++ return __get_tc_info(cookie, tc, tb, nh->nlmsg_flags & NLM_F_ECHO); ++} ++ ++static int tc_add_fd_and_name(struct nlmsghdr *nh, size_t maxsz, int fd) ++{ ++ struct bpf_prog_info info = {}; ++ __u32 info_len = sizeof(info); ++ char name[256]; ++ int len, ret; + +- req.nlh.nlmsg_seq = seq; +- if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0) ++ ret = bpf_obj_get_info_by_fd(fd, &info, &info_len); ++ if (ret < 0) ++ return ret; ++ ++ ret = nlattr_add(nh, maxsz, TCA_BPF_FD, &fd, sizeof(fd)); ++ if (ret < 0) ++ return ret; ++ len = snprintf(name, sizeof(name), "%s:[%u]", info.name, info.id); ++ if (len < 0) + return -errno; ++ if (len >= sizeof(name)) ++ return -ENAMETOOLONG; ++ return nlattr_add(nh, maxsz, TCA_BPF_NAME, name, len + 1); ++} ++ ++int bpf_tc_attach(const struct bpf_tc_hook *hook, struct bpf_tc_opts *opts) ++{ ++ __u32 protocol, bpf_flags, handle, priority, parent, prog_id, flags; ++ int ret, ifindex, attach_point, prog_fd; ++ struct bpf_cb_ctx info = {}; ++ struct nlattr *nla; ++ struct { ++ struct nlmsghdr nh; ++ struct tcmsg tc; ++ char buf[256]; ++ } req; ++ ++ if (!hook || !opts || ++ !OPTS_VALID(hook, bpf_tc_hook) || ++ !OPTS_VALID(opts, bpf_tc_opts)) ++ return -EINVAL; ++ ++ ifindex = OPTS_GET(hook, ifindex, 0); ++ parent = OPTS_GET(hook, parent, 0); ++ attach_point = OPTS_GET(hook, attach_point, 0); ++ ++ handle = OPTS_GET(opts, handle, 0); ++ priority = OPTS_GET(opts, priority, 0); ++ prog_fd = OPTS_GET(opts, prog_fd, 0); ++ prog_id = OPTS_GET(opts, prog_id, 0); ++ flags = OPTS_GET(opts, flags, 0); ++ ++ if (ifindex <= 0 || !prog_fd || prog_id) ++ return -EINVAL; ++ if (priority > UINT16_MAX) ++ return -EINVAL; ++ if (flags & ~BPF_TC_F_REPLACE) ++ return -EINVAL; ++ ++ flags = (flags & BPF_TC_F_REPLACE) ? NLM_F_REPLACE : NLM_F_EXCL; ++ protocol = ETH_P_ALL; ++ ++ memset(&req, 0, sizeof(req)); ++ req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)); ++ req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE | ++ NLM_F_ECHO | flags; ++ req.nh.nlmsg_type = RTM_NEWTFILTER; ++ req.tc.tcm_family = AF_UNSPEC; ++ req.tc.tcm_ifindex = ifindex; ++ req.tc.tcm_handle = handle; ++ req.tc.tcm_info = TC_H_MAKE(priority << 16, htons(protocol)); ++ ++ ret = tc_get_tcm_parent(attach_point, &parent); ++ if (ret < 0) ++ return ret; ++ req.tc.tcm_parent = parent; ++ ++ ret = nlattr_add(&req.nh, sizeof(req), TCA_KIND, "bpf", sizeof("bpf")); ++ if (ret < 0) ++ return ret; ++ nla = nlattr_begin_nested(&req.nh, sizeof(req), TCA_OPTIONS); ++ if (!nla) ++ return -EMSGSIZE; ++ ret = tc_add_fd_and_name(&req.nh, sizeof(req), prog_fd); ++ if (ret < 0) ++ return ret; ++ bpf_flags = TCA_BPF_FLAG_ACT_DIRECT; ++ ret = nlattr_add(&req.nh, sizeof(req), TCA_BPF_FLAGS, &bpf_flags, ++ sizeof(bpf_flags)); ++ if (ret < 0) ++ return ret; ++ nlattr_end_nested(&req.nh, nla); ++ ++ info.opts = opts; + +- return bpf_netlink_recv(sock, nl_pid, seq, __dump_link_nlmsg, +- dump_link_nlmsg, cookie); ++ ret = libbpf_netlink_send_recv(&req.nh, get_tc_info, NULL, &info); ++ if (ret < 0) ++ return ret; ++ if (!info.processed) ++ return -ENOENT; ++ return ret; ++} ++ ++static int __bpf_tc_detach(const struct bpf_tc_hook *hook, ++ const struct bpf_tc_opts *opts, ++ const bool flush) ++{ ++ __u32 protocol = 0, handle, priority, parent, prog_id, flags; ++ int ret, ifindex, attach_point, prog_fd; ++ struct { ++ struct nlmsghdr nh; ++ struct tcmsg tc; ++ char buf[256]; ++ } req; ++ ++ if (!hook || ++ !OPTS_VALID(hook, bpf_tc_hook) || ++ !OPTS_VALID(opts, bpf_tc_opts)) ++ return -EINVAL; ++ ++ ifindex = OPTS_GET(hook, ifindex, 0); ++ parent = OPTS_GET(hook, parent, 0); ++ attach_point = OPTS_GET(hook, attach_point, 0); ++ ++ handle = OPTS_GET(opts, handle, 0); ++ priority = OPTS_GET(opts, priority, 0); ++ prog_fd = OPTS_GET(opts, prog_fd, 0); ++ prog_id = OPTS_GET(opts, prog_id, 0); ++ flags = OPTS_GET(opts, flags, 0); ++ ++ if (ifindex <= 0 || flags || prog_fd || prog_id) ++ return -EINVAL; ++ if (priority > UINT16_MAX) ++ return -EINVAL; ++ if (flags & ~BPF_TC_F_REPLACE) ++ return -EINVAL; ++ if (!flush) { ++ if (!handle || !priority) ++ return -EINVAL; ++ protocol = ETH_P_ALL; ++ } else { ++ if (handle || priority) ++ return -EINVAL; ++ } ++ ++ memset(&req, 0, sizeof(req)); ++ req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)); ++ req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; ++ req.nh.nlmsg_type = RTM_DELTFILTER; ++ req.tc.tcm_family = AF_UNSPEC; ++ req.tc.tcm_ifindex = ifindex; ++ if (!flush) { ++ req.tc.tcm_handle = handle; ++ req.tc.tcm_info = TC_H_MAKE(priority << 16, htons(protocol)); ++ } ++ ++ ret = tc_get_tcm_parent(attach_point, &parent); ++ if (ret < 0) ++ return ret; ++ req.tc.tcm_parent = parent; ++ ++ if (!flush) { ++ ret = nlattr_add(&req.nh, sizeof(req), TCA_KIND, ++ "bpf", sizeof("bpf")); ++ if (ret < 0) ++ return ret; ++ } ++ ++ return libbpf_netlink_send_recv(&req.nh, NULL, NULL, NULL); ++} ++ ++int bpf_tc_detach(const struct bpf_tc_hook *hook, ++ const struct bpf_tc_opts *opts) ++{ ++ return !opts ? -EINVAL : __bpf_tc_detach(hook, opts, false); ++} ++ ++int bpf_tc_query(const struct bpf_tc_hook *hook, struct bpf_tc_opts *opts) ++{ ++ __u32 protocol, handle, priority, parent, prog_id, flags; ++ int ret, ifindex, attach_point, prog_fd; ++ struct bpf_cb_ctx info = {}; ++ struct { ++ struct nlmsghdr nh; ++ struct tcmsg tc; ++ char buf[256]; ++ } req; ++ ++ if (!hook || !opts || ++ !OPTS_VALID(hook, bpf_tc_hook) || ++ !OPTS_VALID(opts, bpf_tc_opts)) ++ return -EINVAL; ++ ++ ifindex = OPTS_GET(hook, ifindex, 0); ++ parent = OPTS_GET(hook, parent, 0); ++ attach_point = OPTS_GET(hook, attach_point, 0); ++ ++ handle = OPTS_GET(opts, handle, 0); ++ priority = OPTS_GET(opts, priority, 0); ++ prog_fd = OPTS_GET(opts, prog_fd, 0); ++ prog_id = OPTS_GET(opts, prog_id, 0); ++ flags = OPTS_GET(opts, flags, 0); ++ ++ if (ifindex <= 0 || flags || prog_fd || prog_id || ++ !handle || !priority) ++ return -EINVAL; ++ if (priority > UINT16_MAX) ++ return -EINVAL; ++ ++ protocol = ETH_P_ALL; ++ ++ memset(&req, 0, sizeof(req)); ++ req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)); ++ req.nh.nlmsg_flags = NLM_F_REQUEST; ++ req.nh.nlmsg_type = RTM_GETTFILTER; ++ req.tc.tcm_family = AF_UNSPEC; ++ req.tc.tcm_ifindex = ifindex; ++ req.tc.tcm_handle = handle; ++ req.tc.tcm_info = TC_H_MAKE(priority << 16, htons(protocol)); ++ ++ ret = tc_get_tcm_parent(attach_point, &parent); ++ if (ret < 0) ++ return ret; ++ req.tc.tcm_parent = parent; ++ ++ ret = nlattr_add(&req.nh, sizeof(req), TCA_KIND, "bpf", sizeof("bpf")); ++ if (ret < 0) ++ return ret; ++ ++ info.opts = opts; ++ ++ ret = libbpf_netlink_send_recv(&req.nh, get_tc_info, NULL, &info); ++ if (ret < 0) ++ return ret; ++ if (!info.processed) ++ return -ENOENT; ++ return ret; + } +Index: dwarves-dfsg-1.21/lib/bpf/src/nlattr.h +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/nlattr.h ++++ dwarves-dfsg-1.21/lib/bpf/src/nlattr.h +@@ -10,7 +10,10 @@ + #define __LIBBPF_NLATTR_H + + #include ++#include ++#include + #include ++ + /* avoid multiple definition of netlink features */ + #define __LINUX_NETLINK_H + +@@ -103,4 +106,49 @@ int libbpf_nla_parse_nested(struct nlatt + + int libbpf_nla_dump_errormsg(struct nlmsghdr *nlh); + ++static inline struct nlattr *nla_data(struct nlattr *nla) ++{ ++ return (struct nlattr *)((char *)nla + NLA_HDRLEN); ++} ++ ++static inline struct nlattr *nh_tail(struct nlmsghdr *nh) ++{ ++ return (struct nlattr *)((char *)nh + NLMSG_ALIGN(nh->nlmsg_len)); ++} ++ ++static inline int nlattr_add(struct nlmsghdr *nh, size_t maxsz, int type, ++ const void *data, int len) ++{ ++ struct nlattr *nla; ++ ++ if (NLMSG_ALIGN(nh->nlmsg_len) + NLA_ALIGN(NLA_HDRLEN + len) > maxsz) ++ return -EMSGSIZE; ++ if (!!data != !!len) ++ return -EINVAL; ++ ++ nla = nh_tail(nh); ++ nla->nla_type = type; ++ nla->nla_len = NLA_HDRLEN + len; ++ if (data) ++ memcpy(nla_data(nla), data, len); ++ nh->nlmsg_len = NLMSG_ALIGN(nh->nlmsg_len) + NLA_ALIGN(nla->nla_len); ++ return 0; ++} ++ ++static inline struct nlattr *nlattr_begin_nested(struct nlmsghdr *nh, ++ size_t maxsz, int type) ++{ ++ struct nlattr *tail; ++ ++ tail = nh_tail(nh); ++ if (nlattr_add(nh, maxsz, type | NLA_F_NESTED, NULL, 0)) ++ return NULL; ++ return tail; ++} ++ ++static inline void nlattr_end_nested(struct nlmsghdr *nh, struct nlattr *tail) ++{ ++ tail->nla_len = (char *)nh_tail(nh) - (char *)tail; ++} ++ + #endif /* __LIBBPF_NLATTR_H */ +Index: dwarves-dfsg-1.21/lib/bpf/src/ringbuf.c +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/ringbuf.c ++++ dwarves-dfsg-1.21/lib/bpf/src/ringbuf.c +@@ -202,9 +202,11 @@ static inline int roundup_len(__u32 len) + return (len + 7) / 8 * 8; + } + +-static int ringbuf_process_ring(struct ring* r) ++static int64_t ringbuf_process_ring(struct ring* r) + { +- int *len_ptr, len, err, cnt = 0; ++ int *len_ptr, len, err; ++ /* 64-bit to avoid overflow in case of extreme application behavior */ ++ int64_t cnt = 0; + unsigned long cons_pos, prod_pos; + bool got_new_data; + void *sample; +@@ -227,7 +229,7 @@ static int ringbuf_process_ring(struct r + if ((len & BPF_RINGBUF_DISCARD_BIT) == 0) { + sample = (void *)len_ptr + BPF_RINGBUF_HDR_SZ; + err = r->sample_cb(r->ctx, sample, len); +- if (err) { ++ if (err < 0) { + /* update consumer pos and bail out */ + smp_store_release(r->consumer_pos, + cons_pos); +@@ -244,12 +246,14 @@ done: + } + + /* Consume available ring buffer(s) data without event polling. +- * Returns number of records consumed across all registered ring buffers, or +- * negative number if any of the callbacks return error. ++ * Returns number of records consumed across all registered ring buffers (or ++ * INT_MAX, whichever is less), or negative number if any of the callbacks ++ * return error. + */ + int ring_buffer__consume(struct ring_buffer *rb) + { +- int i, err, res = 0; ++ int64_t err, res = 0; ++ int i; + + for (i = 0; i < rb->ring_cnt; i++) { + struct ring *ring = &rb->rings[i]; +@@ -259,18 +263,24 @@ int ring_buffer__consume(struct ring_buf + return err; + res += err; + } ++ if (res > INT_MAX) ++ return INT_MAX; + return res; + } + + /* Poll for available data and consume records, if any are available. +- * Returns number of records consumed, or negative number, if any of the +- * registered callbacks returned error. ++ * Returns number of records consumed (or INT_MAX, whichever is less), or ++ * negative number, if any of the registered callbacks returned error. + */ + int ring_buffer__poll(struct ring_buffer *rb, int timeout_ms) + { +- int i, cnt, err, res = 0; ++ int i, cnt; ++ int64_t err, res = 0; + + cnt = epoll_wait(rb->epoll_fd, rb->events, rb->ring_cnt, timeout_ms); ++ if (cnt < 0) ++ return -errno; ++ + for (i = 0; i < cnt; i++) { + __u32 ring_id = rb->events[i].data.fd; + struct ring *ring = &rb->rings[ring_id]; +@@ -280,7 +290,9 @@ int ring_buffer__poll(struct ring_buffer + return err; + res += err; + } +- return cnt < 0 ? -errno : res; ++ if (res > INT_MAX) ++ return INT_MAX; ++ return res; + } + + /* Get an fd that can be used to sleep until data is available in the ring(s) */ +Index: dwarves-dfsg-1.21/lib/bpf/src/strset.c +=================================================================== +--- /dev/null ++++ dwarves-dfsg-1.21/lib/bpf/src/strset.c +@@ -0,0 +1,176 @@ ++// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) ++/* Copyright (c) 2021 Facebook */ ++#include ++#include ++#include ++#include ++#include ++#include "hashmap.h" ++#include "libbpf_internal.h" ++#include "strset.h" ++ ++struct strset { ++ void *strs_data; ++ size_t strs_data_len; ++ size_t strs_data_cap; ++ size_t strs_data_max_len; ++ ++ /* lookup index for each unique string in strings set */ ++ struct hashmap *strs_hash; ++}; ++ ++static size_t strset_hash_fn(const void *key, void *ctx) ++{ ++ const struct strset *s = ctx; ++ const char *str = s->strs_data + (long)key; ++ ++ return str_hash(str); ++} ++ ++static bool strset_equal_fn(const void *key1, const void *key2, void *ctx) ++{ ++ const struct strset *s = ctx; ++ const char *str1 = s->strs_data + (long)key1; ++ const char *str2 = s->strs_data + (long)key2; ++ ++ return strcmp(str1, str2) == 0; ++} ++ ++struct strset *strset__new(size_t max_data_sz, const char *init_data, size_t init_data_sz) ++{ ++ struct strset *set = calloc(1, sizeof(*set)); ++ struct hashmap *hash; ++ int err = -ENOMEM; ++ ++ if (!set) ++ return ERR_PTR(-ENOMEM); ++ ++ hash = hashmap__new(strset_hash_fn, strset_equal_fn, set); ++ if (IS_ERR(hash)) ++ goto err_out; ++ ++ set->strs_data_max_len = max_data_sz; ++ set->strs_hash = hash; ++ ++ if (init_data) { ++ long off; ++ ++ set->strs_data = malloc(init_data_sz); ++ if (!set->strs_data) ++ goto err_out; ++ ++ memcpy(set->strs_data, init_data, init_data_sz); ++ set->strs_data_len = init_data_sz; ++ set->strs_data_cap = init_data_sz; ++ ++ for (off = 0; off < set->strs_data_len; off += strlen(set->strs_data + off) + 1) { ++ /* hashmap__add() returns EEXIST if string with the same ++ * content already is in the hash map ++ */ ++ err = hashmap__add(hash, (void *)off, (void *)off); ++ if (err == -EEXIST) ++ continue; /* duplicate */ ++ if (err) ++ goto err_out; ++ } ++ } ++ ++ return set; ++err_out: ++ strset__free(set); ++ return ERR_PTR(err); ++} ++ ++void strset__free(struct strset *set) ++{ ++ if (IS_ERR_OR_NULL(set)) ++ return; ++ ++ hashmap__free(set->strs_hash); ++ free(set->strs_data); ++} ++ ++size_t strset__data_size(const struct strset *set) ++{ ++ return set->strs_data_len; ++} ++ ++const char *strset__data(const struct strset *set) ++{ ++ return set->strs_data; ++} ++ ++static void *strset_add_str_mem(struct strset *set, size_t add_sz) ++{ ++ return libbpf_add_mem(&set->strs_data, &set->strs_data_cap, 1, ++ set->strs_data_len, set->strs_data_max_len, add_sz); ++} ++ ++/* Find string offset that corresponds to a given string *s*. ++ * Returns: ++ * - >0 offset into string data, if string is found; ++ * - -ENOENT, if string is not in the string data; ++ * - <0, on any other error. ++ */ ++int strset__find_str(struct strset *set, const char *s) ++{ ++ long old_off, new_off, len; ++ void *p; ++ ++ /* see strset__add_str() for why we do this */ ++ len = strlen(s) + 1; ++ p = strset_add_str_mem(set, len); ++ if (!p) ++ return -ENOMEM; ++ ++ new_off = set->strs_data_len; ++ memcpy(p, s, len); ++ ++ if (hashmap__find(set->strs_hash, (void *)new_off, (void **)&old_off)) ++ return old_off; ++ ++ return -ENOENT; ++} ++ ++/* Add a string s to the string data. If the string already exists, return its ++ * offset within string data. ++ * Returns: ++ * - > 0 offset into string data, on success; ++ * - < 0, on error. ++ */ ++int strset__add_str(struct strset *set, const char *s) ++{ ++ long old_off, new_off, len; ++ void *p; ++ int err; ++ ++ /* Hashmap keys are always offsets within set->strs_data, so to even ++ * look up some string from the "outside", we need to first append it ++ * at the end, so that it can be addressed with an offset. Luckily, ++ * until set->strs_data_len is incremented, that string is just a piece ++ * of garbage for the rest of the code, so no harm, no foul. On the ++ * other hand, if the string is unique, it's already appended and ++ * ready to be used, only a simple set->strs_data_len increment away. ++ */ ++ len = strlen(s) + 1; ++ p = strset_add_str_mem(set, len); ++ if (!p) ++ return -ENOMEM; ++ ++ new_off = set->strs_data_len; ++ memcpy(p, s, len); ++ ++ /* Now attempt to add the string, but only if the string with the same ++ * contents doesn't exist already (HASHMAP_ADD strategy). If such ++ * string exists, we'll get its offset in old_off (that's old_key). ++ */ ++ err = hashmap__insert(set->strs_hash, (void *)new_off, (void *)new_off, ++ HASHMAP_ADD, (const void **)&old_off, NULL); ++ if (err == -EEXIST) ++ return old_off; /* duplicated string, return existing offset */ ++ if (err) ++ return err; ++ ++ set->strs_data_len += len; /* new unique string, adjust data length */ ++ return new_off; ++} +Index: dwarves-dfsg-1.21/lib/bpf/src/strset.h +=================================================================== +--- /dev/null ++++ dwarves-dfsg-1.21/lib/bpf/src/strset.h +@@ -0,0 +1,21 @@ ++/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ ++ ++/* Copyright (c) 2021 Facebook */ ++#ifndef __LIBBPF_STRSET_H ++#define __LIBBPF_STRSET_H ++ ++#include ++#include ++ ++struct strset; ++ ++struct strset *strset__new(size_t max_data_sz, const char *init_data, size_t init_data_sz); ++void strset__free(struct strset *set); ++ ++const char *strset__data(const struct strset *set); ++size_t strset__data_size(const struct strset *set); ++ ++int strset__find_str(struct strset *set, const char *s); ++int strset__add_str(struct strset *set, const char *s); ++ ++#endif /* __LIBBPF_STRSET_H */ +Index: dwarves-dfsg-1.21/lib/bpf/src/xsk.c +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/xsk.c ++++ dwarves-dfsg-1.21/lib/bpf/src/xsk.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + + #include "bpf.h" + #include "libbpf.h" +@@ -59,6 +60,8 @@ struct xsk_umem { + int fd; + int refcount; + struct list_head ctx_list; ++ bool rx_ring_setup_done; ++ bool tx_ring_setup_done; + }; + + struct xsk_ctx { +@@ -70,8 +73,10 @@ struct xsk_ctx { + int ifindex; + struct list_head list; + int prog_fd; ++ int link_fd; + int xsks_map_fd; + char ifname[IFNAMSIZ]; ++ bool has_bpf_link; + }; + + struct xsk_socket { +@@ -409,7 +414,7 @@ static int xsk_load_xdp_prog(struct xsk_ + static const int log_buf_size = 16 * 1024; + struct xsk_ctx *ctx = xsk->ctx; + char log_buf[log_buf_size]; +- int err, prog_fd; ++ int prog_fd; + + /* This is the fallback C-program: + * SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx) +@@ -499,14 +504,41 @@ static int xsk_load_xdp_prog(struct xsk_ + return prog_fd; + } + +- err = bpf_set_link_xdp_fd(xsk->ctx->ifindex, prog_fd, +- xsk->config.xdp_flags); ++ ctx->prog_fd = prog_fd; ++ return 0; ++} ++ ++static int xsk_create_bpf_link(struct xsk_socket *xsk) ++{ ++ DECLARE_LIBBPF_OPTS(bpf_link_create_opts, opts); ++ struct xsk_ctx *ctx = xsk->ctx; ++ __u32 prog_id = 0; ++ int link_fd; ++ int err; ++ ++ err = bpf_get_link_xdp_id(ctx->ifindex, &prog_id, xsk->config.xdp_flags); + if (err) { +- close(prog_fd); ++ pr_warn("getting XDP prog id failed\n"); + return err; + } + +- ctx->prog_fd = prog_fd; ++ /* if there's a netlink-based XDP prog loaded on interface, bail out ++ * and ask user to do the removal by himself ++ */ ++ if (prog_id) { ++ pr_warn("Netlink-based XDP prog detected, please unload it in order to launch AF_XDP prog\n"); ++ return -EINVAL; ++ } ++ ++ opts.flags = xsk->config.xdp_flags & ~(XDP_FLAGS_UPDATE_IF_NOEXIST | XDP_FLAGS_REPLACE); ++ ++ link_fd = bpf_link_create(ctx->prog_fd, ctx->ifindex, BPF_XDP, &opts); ++ if (link_fd < 0) { ++ pr_warn("bpf_link_create failed: %s\n", strerror(errno)); ++ return link_fd; ++ } ++ ++ ctx->link_fd = link_fd; + return 0; + } + +@@ -610,21 +642,21 @@ static int xsk_lookup_bpf_maps(struct xs + if (fd < 0) + continue; + ++ memset(&map_info, 0, map_len); + err = bpf_obj_get_info_by_fd(fd, &map_info, &map_len); + if (err) { + close(fd); + continue; + } + +- if (!strcmp(map_info.name, "xsks_map")) { ++ if (!strncmp(map_info.name, "xsks_map", sizeof(map_info.name))) { + ctx->xsks_map_fd = fd; +- continue; ++ break; + } + + close(fd); + } + +- err = 0; + if (ctx->xsks_map_fd == -1) + err = -ENOENT; + +@@ -641,6 +673,98 @@ static int xsk_set_bpf_maps(struct xsk_s + &xsk->fd, 0); + } + ++static int xsk_link_lookup(int ifindex, __u32 *prog_id, int *link_fd) ++{ ++ struct bpf_link_info link_info; ++ __u32 link_len; ++ __u32 id = 0; ++ int err; ++ int fd; ++ ++ while (true) { ++ err = bpf_link_get_next_id(id, &id); ++ if (err) { ++ if (errno == ENOENT) { ++ err = 0; ++ break; ++ } ++ pr_warn("can't get next link: %s\n", strerror(errno)); ++ break; ++ } ++ ++ fd = bpf_link_get_fd_by_id(id); ++ if (fd < 0) { ++ if (errno == ENOENT) ++ continue; ++ pr_warn("can't get link by id (%u): %s\n", id, strerror(errno)); ++ err = -errno; ++ break; ++ } ++ ++ link_len = sizeof(struct bpf_link_info); ++ memset(&link_info, 0, link_len); ++ err = bpf_obj_get_info_by_fd(fd, &link_info, &link_len); ++ if (err) { ++ pr_warn("can't get link info: %s\n", strerror(errno)); ++ close(fd); ++ break; ++ } ++ if (link_info.type == BPF_LINK_TYPE_XDP) { ++ if (link_info.xdp.ifindex == ifindex) { ++ *link_fd = fd; ++ if (prog_id) ++ *prog_id = link_info.prog_id; ++ break; ++ } ++ } ++ close(fd); ++ } ++ ++ return err; ++} ++ ++static bool xsk_probe_bpf_link(void) ++{ ++ DECLARE_LIBBPF_OPTS(bpf_link_create_opts, opts, ++ .flags = XDP_FLAGS_SKB_MODE); ++ struct bpf_load_program_attr prog_attr; ++ struct bpf_insn insns[2] = { ++ BPF_MOV64_IMM(BPF_REG_0, XDP_PASS), ++ BPF_EXIT_INSN() ++ }; ++ int prog_fd, link_fd = -1; ++ int ifindex_lo = 1; ++ bool ret = false; ++ int err; ++ ++ err = xsk_link_lookup(ifindex_lo, NULL, &link_fd); ++ if (err) ++ return ret; ++ ++ if (link_fd >= 0) ++ return true; ++ ++ memset(&prog_attr, 0, sizeof(prog_attr)); ++ prog_attr.prog_type = BPF_PROG_TYPE_XDP; ++ prog_attr.insns = insns; ++ prog_attr.insns_cnt = ARRAY_SIZE(insns); ++ prog_attr.license = "GPL"; ++ ++ prog_fd = bpf_load_program_xattr(&prog_attr, NULL, 0); ++ if (prog_fd < 0) ++ return ret; ++ ++ link_fd = bpf_link_create(prog_fd, ifindex_lo, BPF_XDP, &opts); ++ close(prog_fd); ++ ++ if (link_fd >= 0) { ++ ret = true; ++ close(link_fd); ++ } ++ ++ return ret; ++} ++ + static int xsk_create_xsk_struct(int ifindex, struct xsk_socket *xsk) + { + char ifname[IFNAMSIZ]; +@@ -662,64 +786,108 @@ static int xsk_create_xsk_struct(int ifi + ctx->ifname[IFNAMSIZ - 1] = 0; + + xsk->ctx = ctx; ++ xsk->ctx->has_bpf_link = xsk_probe_bpf_link(); + + return 0; + } + +-static int __xsk_setup_xdp_prog(struct xsk_socket *_xdp, +- int *xsks_map_fd) ++static int xsk_init_xdp_res(struct xsk_socket *xsk, ++ int *xsks_map_fd) + { +- struct xsk_socket *xsk = _xdp; + struct xsk_ctx *ctx = xsk->ctx; +- __u32 prog_id = 0; + int err; + +- err = bpf_get_link_xdp_id(ctx->ifindex, &prog_id, +- xsk->config.xdp_flags); ++ err = xsk_create_bpf_maps(xsk); + if (err) + return err; + +- if (!prog_id) { +- err = xsk_create_bpf_maps(xsk); +- if (err) +- return err; ++ err = xsk_load_xdp_prog(xsk); ++ if (err) ++ goto err_load_xdp_prog; + +- err = xsk_load_xdp_prog(xsk); +- if (err) { +- goto err_load_xdp_prog; +- } +- } else { +- ctx->prog_fd = bpf_prog_get_fd_by_id(prog_id); +- if (ctx->prog_fd < 0) +- return -errno; +- err = xsk_lookup_bpf_maps(xsk); +- if (err) { +- close(ctx->prog_fd); +- return err; +- } +- } ++ if (ctx->has_bpf_link) ++ err = xsk_create_bpf_link(xsk); ++ else ++ err = bpf_set_link_xdp_fd(xsk->ctx->ifindex, ctx->prog_fd, ++ xsk->config.xdp_flags); + +- if (xsk->rx) { +- err = xsk_set_bpf_maps(xsk); +- if (err) { +- if (!prog_id) { +- goto err_set_bpf_maps; +- } else { +- close(ctx->prog_fd); +- return err; +- } +- } +- } +- if (xsks_map_fd) +- *xsks_map_fd = ctx->xsks_map_fd; ++ if (err) ++ goto err_attach_xdp_prog; + +- return 0; ++ if (!xsk->rx) ++ return err; ++ ++ err = xsk_set_bpf_maps(xsk); ++ if (err) ++ goto err_set_bpf_maps; ++ ++ return err; + + err_set_bpf_maps: ++ if (ctx->has_bpf_link) ++ close(ctx->link_fd); ++ else ++ bpf_set_link_xdp_fd(ctx->ifindex, -1, 0); ++err_attach_xdp_prog: + close(ctx->prog_fd); +- bpf_set_link_xdp_fd(ctx->ifindex, -1, 0); + err_load_xdp_prog: + xsk_delete_bpf_maps(xsk); ++ return err; ++} ++ ++static int xsk_lookup_xdp_res(struct xsk_socket *xsk, int *xsks_map_fd, int prog_id) ++{ ++ struct xsk_ctx *ctx = xsk->ctx; ++ int err; ++ ++ ctx->prog_fd = bpf_prog_get_fd_by_id(prog_id); ++ if (ctx->prog_fd < 0) { ++ err = -errno; ++ goto err_prog_fd; ++ } ++ err = xsk_lookup_bpf_maps(xsk); ++ if (err) ++ goto err_lookup_maps; ++ ++ if (!xsk->rx) ++ return err; ++ ++ err = xsk_set_bpf_maps(xsk); ++ if (err) ++ goto err_set_maps; ++ ++ return err; ++ ++err_set_maps: ++ close(ctx->xsks_map_fd); ++err_lookup_maps: ++ close(ctx->prog_fd); ++err_prog_fd: ++ if (ctx->has_bpf_link) ++ close(ctx->link_fd); ++ return err; ++} ++ ++static int __xsk_setup_xdp_prog(struct xsk_socket *_xdp, int *xsks_map_fd) ++{ ++ struct xsk_socket *xsk = _xdp; ++ struct xsk_ctx *ctx = xsk->ctx; ++ __u32 prog_id = 0; ++ int err; ++ ++ if (ctx->has_bpf_link) ++ err = xsk_link_lookup(ctx->ifindex, &prog_id, &ctx->link_fd); ++ else ++ err = bpf_get_link_xdp_id(ctx->ifindex, &prog_id, xsk->config.xdp_flags); ++ ++ if (err) ++ return err; ++ ++ err = !prog_id ? xsk_init_xdp_res(xsk, xsks_map_fd) : ++ xsk_lookup_xdp_res(xsk, xsks_map_fd, prog_id); ++ ++ if (!err && xsks_map_fd) ++ *xsks_map_fd = ctx->xsks_map_fd; + + return err; + } +@@ -742,26 +910,30 @@ static struct xsk_ctx *xsk_get_ctx(struc + return NULL; + } + +-static void xsk_put_ctx(struct xsk_ctx *ctx) ++static void xsk_put_ctx(struct xsk_ctx *ctx, bool unmap) + { + struct xsk_umem *umem = ctx->umem; + struct xdp_mmap_offsets off; + int err; + +- if (--ctx->refcount == 0) { +- err = xsk_get_mmap_offsets(umem->fd, &off); +- if (!err) { +- munmap(ctx->fill->ring - off.fr.desc, +- off.fr.desc + umem->config.fill_size * +- sizeof(__u64)); +- munmap(ctx->comp->ring - off.cr.desc, +- off.cr.desc + umem->config.comp_size * +- sizeof(__u64)); +- } ++ if (--ctx->refcount) ++ return; + +- list_del(&ctx->list); +- free(ctx); +- } ++ if (!unmap) ++ goto out_free; ++ ++ err = xsk_get_mmap_offsets(umem->fd, &off); ++ if (err) ++ goto out_free; ++ ++ munmap(ctx->fill->ring - off.fr.desc, off.fr.desc + umem->config.fill_size * ++ sizeof(__u64)); ++ munmap(ctx->comp->ring - off.cr.desc, off.cr.desc + umem->config.comp_size * ++ sizeof(__u64)); ++ ++out_free: ++ list_del(&ctx->list); ++ free(ctx); + } + + static struct xsk_ctx *xsk_create_ctx(struct xsk_socket *xsk, +@@ -796,8 +968,6 @@ static struct xsk_ctx *xsk_create_ctx(st + memcpy(ctx->ifname, ifname, IFNAMSIZ - 1); + ctx->ifname[IFNAMSIZ - 1] = '\0'; + +- umem->fill_save = NULL; +- umem->comp_save = NULL; + ctx->fill = fill; + ctx->comp = comp; + list_add(&ctx->list, &umem->ctx_list); +@@ -847,6 +1017,7 @@ int xsk_socket__create_shared(struct xsk + struct xsk_ring_cons *comp, + const struct xsk_socket_config *usr_config) + { ++ bool unmap, rx_setup_done = false, tx_setup_done = false; + void *rx_map = NULL, *tx_map = NULL; + struct sockaddr_xdp sxdp = {}; + struct xdp_mmap_offsets off; +@@ -857,6 +1028,8 @@ int xsk_socket__create_shared(struct xsk + if (!umem || !xsk_ptr || !(rx || tx)) + return -EFAULT; + ++ unmap = umem->fill_save != fill; ++ + xsk = calloc(1, sizeof(*xsk)); + if (!xsk) + return -ENOMEM; +@@ -880,6 +1053,8 @@ int xsk_socket__create_shared(struct xsk + } + } else { + xsk->fd = umem->fd; ++ rx_setup_done = umem->rx_ring_setup_done; ++ tx_setup_done = umem->tx_ring_setup_done; + } + + ctx = xsk_get_ctx(umem, ifindex, queue_id); +@@ -897,8 +1072,9 @@ int xsk_socket__create_shared(struct xsk + } + } + xsk->ctx = ctx; ++ xsk->ctx->has_bpf_link = xsk_probe_bpf_link(); + +- if (rx) { ++ if (rx && !rx_setup_done) { + err = setsockopt(xsk->fd, SOL_XDP, XDP_RX_RING, + &xsk->config.rx_size, + sizeof(xsk->config.rx_size)); +@@ -906,8 +1082,10 @@ int xsk_socket__create_shared(struct xsk + err = -errno; + goto out_put_ctx; + } ++ if (xsk->fd == umem->fd) ++ umem->rx_ring_setup_done = true; + } +- if (tx) { ++ if (tx && !tx_setup_done) { + err = setsockopt(xsk->fd, SOL_XDP, XDP_TX_RING, + &xsk->config.tx_size, + sizeof(xsk->config.tx_size)); +@@ -915,6 +1093,8 @@ int xsk_socket__create_shared(struct xsk + err = -errno; + goto out_put_ctx; + } ++ if (xsk->fd == umem->fd) ++ umem->rx_ring_setup_done = true; + } + + err = xsk_get_mmap_offsets(xsk->fd, &off); +@@ -993,6 +1173,8 @@ int xsk_socket__create_shared(struct xsk + } + + *xsk_ptr = xsk; ++ umem->fill_save = NULL; ++ umem->comp_save = NULL; + return 0; + + out_mmap_tx: +@@ -1004,7 +1186,7 @@ out_mmap_rx: + munmap(rx_map, off.rx.desc + + xsk->config.rx_size * sizeof(struct xdp_desc)); + out_put_ctx: +- xsk_put_ctx(ctx); ++ xsk_put_ctx(ctx, unmap); + out_socket: + if (--umem->refcount) + close(xsk->fd); +@@ -1018,6 +1200,9 @@ int xsk_socket__create(struct xsk_socket + struct xsk_ring_cons *rx, struct xsk_ring_prod *tx, + const struct xsk_socket_config *usr_config) + { ++ if (!umem) ++ return -EFAULT; ++ + return xsk_socket__create_shared(xsk_ptr, ifname, queue_id, umem, + rx, tx, umem->fill_save, + umem->comp_save, usr_config); +@@ -1053,6 +1238,8 @@ void xsk_socket__delete(struct xsk_socke + if (ctx->prog_fd != -1) { + xsk_delete_bpf_maps(xsk); + close(ctx->prog_fd); ++ if (ctx->has_bpf_link) ++ close(ctx->link_fd); + } + + err = xsk_get_mmap_offsets(xsk->fd, &off); +@@ -1067,7 +1254,7 @@ void xsk_socket__delete(struct xsk_socke + } + } + +- xsk_put_ctx(ctx); ++ xsk_put_ctx(ctx, true); + + umem->refcount--; + /* Do not close an fd that also has an associated umem connected +Index: dwarves-dfsg-1.21/lib/bpf/src/xsk.h +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/src/xsk.h ++++ dwarves-dfsg-1.21/lib/bpf/src/xsk.h +@@ -3,7 +3,8 @@ + /* + * AF_XDP user-space access library. + * +- * Copyright(c) 2018 - 2019 Intel Corporation. ++ * Copyright (c) 2018 - 2019 Intel Corporation. ++ * Copyright (c) 2019 Facebook + * + * Author(s): Magnus Karlsson + */ +@@ -13,15 +14,80 @@ + + #include + #include ++#include + #include + + #include "libbpf.h" +-#include "libbpf_util.h" + + #ifdef __cplusplus + extern "C" { + #endif + ++/* Load-Acquire Store-Release barriers used by the XDP socket ++ * library. The following macros should *NOT* be considered part of ++ * the xsk.h API, and is subject to change anytime. ++ * ++ * LIBRARY INTERNAL ++ */ ++ ++#define __XSK_READ_ONCE(x) (*(volatile typeof(x) *)&x) ++#define __XSK_WRITE_ONCE(x, v) (*(volatile typeof(x) *)&x) = (v) ++ ++#if defined(__i386__) || defined(__x86_64__) ++# define libbpf_smp_store_release(p, v) \ ++ do { \ ++ asm volatile("" : : : "memory"); \ ++ __XSK_WRITE_ONCE(*p, v); \ ++ } while (0) ++# define libbpf_smp_load_acquire(p) \ ++ ({ \ ++ typeof(*p) ___p1 = __XSK_READ_ONCE(*p); \ ++ asm volatile("" : : : "memory"); \ ++ ___p1; \ ++ }) ++#elif defined(__aarch64__) ++# define libbpf_smp_store_release(p, v) \ ++ asm volatile ("stlr %w1, %0" : "=Q" (*p) : "r" (v) : "memory") ++# define libbpf_smp_load_acquire(p) \ ++ ({ \ ++ typeof(*p) ___p1; \ ++ asm volatile ("ldar %w0, %1" \ ++ : "=r" (___p1) : "Q" (*p) : "memory"); \ ++ ___p1; \ ++ }) ++#elif defined(__riscv) ++# define libbpf_smp_store_release(p, v) \ ++ do { \ ++ asm volatile ("fence rw,w" : : : "memory"); \ ++ __XSK_WRITE_ONCE(*p, v); \ ++ } while (0) ++# define libbpf_smp_load_acquire(p) \ ++ ({ \ ++ typeof(*p) ___p1 = __XSK_READ_ONCE(*p); \ ++ asm volatile ("fence r,rw" : : : "memory"); \ ++ ___p1; \ ++ }) ++#endif ++ ++#ifndef libbpf_smp_store_release ++#define libbpf_smp_store_release(p, v) \ ++ do { \ ++ __sync_synchronize(); \ ++ __XSK_WRITE_ONCE(*p, v); \ ++ } while (0) ++#endif ++ ++#ifndef libbpf_smp_load_acquire ++#define libbpf_smp_load_acquire(p) \ ++ ({ \ ++ typeof(*p) ___p1 = __XSK_READ_ONCE(*p); \ ++ __sync_synchronize(); \ ++ ___p1; \ ++ }) ++#endif ++ ++/* LIBRARY INTERNAL -- END */ ++ + /* Do not access these members directly. Use the functions below. */ + #define DEFINE_XSK_RING(name) \ + struct name { \ +@@ -96,7 +162,8 @@ static inline __u32 xsk_prod_nb_free(str + * this function. Without this optimization it whould have been + * free_entries = r->cached_prod - r->cached_cons + r->size. + */ +- r->cached_cons = *r->consumer + r->size; ++ r->cached_cons = libbpf_smp_load_acquire(r->consumer); ++ r->cached_cons += r->size; + + return r->cached_cons - r->cached_prod; + } +@@ -106,7 +173,7 @@ static inline __u32 xsk_cons_nb_avail(st + __u32 entries = r->cached_prod - r->cached_cons; + + if (entries == 0) { +- r->cached_prod = *r->producer; ++ r->cached_prod = libbpf_smp_load_acquire(r->producer); + entries = r->cached_prod - r->cached_cons; + } + +@@ -129,9 +196,7 @@ static inline void xsk_ring_prod__submit + /* Make sure everything has been written to the ring before indicating + * this to the kernel by writing the producer pointer. + */ +- libbpf_smp_wmb(); +- +- *prod->producer += nb; ++ libbpf_smp_store_release(prod->producer, *prod->producer + nb); + } + + static inline __u32 xsk_ring_cons__peek(struct xsk_ring_cons *cons, __u32 nb, __u32 *idx) +@@ -139,11 +204,6 @@ static inline __u32 xsk_ring_cons__peek( + __u32 entries = xsk_cons_nb_avail(cons, nb); + + if (entries > 0) { +- /* Make sure we do not speculatively read the data before +- * we have received the packet buffers from the ring. +- */ +- libbpf_smp_rmb(); +- + *idx = cons->cached_cons; + cons->cached_cons += entries; + } +@@ -161,9 +221,8 @@ static inline void xsk_ring_cons__releas + /* Make sure data has been read before indicating we are done + * with the entries by updating the consumer pointer. + */ +- libbpf_smp_rwmb(); ++ libbpf_smp_store_release(cons->consumer, *cons->consumer + nb); + +- *cons->consumer += nb; + } + + static inline void *xsk_umem__get_data(void *umem_area, __u64 addr) +Index: dwarves-dfsg-1.21/lib/bpf/travis-ci/managers/debian.sh +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/travis-ci/managers/debian.sh ++++ dwarves-dfsg-1.21/lib/bpf/travis-ci/managers/debian.sh +@@ -21,7 +21,7 @@ function docker_exec() { + docker exec $ENV_VARS -it $CONT_NAME "$@" + } + +-set -e ++set -eu + + source "$(dirname $0)/travis_wait.bash" + +@@ -31,7 +31,6 @@ for phase in "${PHASES[@]}"; do + info "Setup phase" + info "Using Debian $DEBIAN_RELEASE" + +- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce + docker --version + + docker pull debian:$DEBIAN_RELEASE +@@ -41,9 +40,10 @@ for phase in "${PHASES[@]}"; do + -dit --net=host debian:$DEBIAN_RELEASE /bin/bash + docker_exec bash -c "echo deb-src http://deb.debian.org/debian $DEBIAN_RELEASE main >>/etc/apt/sources.list" + docker_exec apt-get -y update +- docker_exec apt-get -y build-dep libelf-dev +- docker_exec apt-get -y install libelf-dev +- docker_exec apt-get -y install "${ADDITIONAL_DEPS[@]}" ++ docker_exec apt-get -y install aptitude ++ docker_exec aptitude -y build-dep libelf-dev ++ docker_exec aptitude -y install libelf-dev ++ docker_exec aptitude -y install "${ADDITIONAL_DEPS[@]}" + ;; + RUN|RUN_CLANG|RUN_GCC10|RUN_ASAN|RUN_CLANG_ASAN|RUN_GCC10_ASAN) + if [[ "$phase" = *"CLANG"* ]]; then +Index: dwarves-dfsg-1.21/lib/bpf/travis-ci/managers/ubuntu.sh +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/travis-ci/managers/ubuntu.sh ++++ dwarves-dfsg-1.21/lib/bpf/travis-ci/managers/ubuntu.sh +@@ -1,20 +1,16 @@ + #!/bin/bash +-set -e +-set -x ++set -eux + +-RELEASE="bionic" +- +-echo "deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse" >>/etc/apt/sources.list ++RELEASE="focal" + + apt-get update +-apt-get -y build-dep libelf-dev +-apt-get install -y libelf-dev pkg-config ++apt-get install -y pkg-config + + source "$(dirname $0)/travis_wait.bash" + + cd $REPO_ROOT + +-CFLAGS="-g -O2 -Werror -Wall -fsanitize=address,undefined" ++CFLAGS="-g -O2 -Werror -Wall -fsanitize=address,undefined -Wno-stringop-truncation" + mkdir build install + cc --version + make -j$((4*$(nproc))) CFLAGS="${CFLAGS}" -C ./src -B OBJDIR=../build +Index: dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/blacklist/BLACKLIST-5.5.0 +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/travis-ci/vmtest/configs/blacklist/BLACKLIST-5.5.0 ++++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/blacklist/BLACKLIST-5.5.0 +@@ -20,6 +20,7 @@ enable_stats # BPF_ENABLE_STATS support + fentry_fexit # bpf_prog_test_tracing missing + fentry_test # bpf_prog_test_tracing missing + fexit_bpf2bpf # freplace is missing ++fexit_sleep # relies on bpf_trampoline fix in 5.12+ + fexit_test # bpf_prog_test_tracing missing + flow_dissector # bpf_link-based flow dissector is in 5.8+ + flow_dissector_reattach +@@ -29,7 +30,9 @@ hash_large_key # v5.11+ + ima # v5.11+ + kfree_skb # 32-bit pointer arith in test_pkt_access + ksyms # __start_BTF has different name ++kfunc_call # v5.13+ + link_pinning # bpf_link is missing ++linked_vars # v5.13+ + load_bytes_relative # new functionality in 5.8 + map_init # per-CPU LRU missing + map_ptr # test uses BPF_MAP_TYPE_RINGBUF, added in 5.8 +@@ -58,12 +61,14 @@ sk_lookup # v5.9+ + sk_storage_tracing # missing bpf_sk_storage_get() helper + skb_ctx # ctx_{size, }_{in, out} in BPF_PROG_TEST_RUN is missing + skb_helpers # helpers added in 5.8+ ++snprintf # v5.13+ + snprintf_btf # v5.10+ + sock_fields # v5.10+ + socket_cookie # v5.12+ + sockmap_basic # uses new socket fields, 5.8+ + sockmap_listen # no listen socket supportin SOCKMAP + sockopt_sk ++stacktrace_build_id # v5.9+ + stack_var_off # v5.12+ + task_local_storage # v5.12+ + tcp_hdr_options # v5.10+, new TCP header options feature in BPF +Index: dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/run.sh +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/travis-ci/vmtest/run.sh ++++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/run.sh +@@ -415,8 +415,8 @@ set -eux + + echo 'Running setup commands' + %s +-%s +-echo $? > /exitstatus ++set +e; %s; exitstatus=\$?; set -e ++echo \$exitstatus > /exitstatus + chmod 644 /exitstatus" "${setup_envvars}" "${setup_cmd}") + fi + +Index: dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/run_vmtest.sh +=================================================================== +--- dwarves-dfsg-1.21.orig/lib/bpf/travis-ci/vmtest/run_vmtest.sh ++++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/run_vmtest.sh +@@ -15,9 +15,11 @@ ${VMTEST_ROOT}/build_pahole.sh travis-ci + travis_fold start install_clang "Installing Clang/LLVM" + + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - +-sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" ++sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" + sudo apt-get update +-sudo apt-get install -y clang-13 lld-13 llvm-13 ++sudo apt-get install --allow-downgrades -y libc6=2.31-0ubuntu9.2 ++sudo aptitude install -y g++ libelf-dev ++sudo aptitude install -y clang-13 lld-13 llvm-13 + + travis_fold end install_clang + diff -Nru dwarves-dfsg-1.10/debian/patches/no_shared_no_ebl dwarves-dfsg-1.21/debian/patches/no_shared_no_ebl --- dwarves-dfsg-1.10/debian/patches/no_shared_no_ebl 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/patches/no_shared_no_ebl 2021-02-07 16:59:01.000000000 +0000 @@ -0,0 +1,84 @@ +From: Thomas Girard +Date: Sat, 24 Nov 2018 10:43:57 +0100 +Subject: no_shared_no_ebl + +Description: build static libs and remove ebl dependency + + Build static libraries instead of shared libraries so that we have a single + package. + + Do not try to find and link with libebl.so as it is no longer provided by + elfutils. + +Origin: Thomas Girard +Forwarded: no +Last-Update: 2019-06-26 +--- + CMakeLists.txt | 17 +++-------------- + cmake/modules/FindDWARF.cmake | 6 ++++-- + 2 files changed, 7 insertions(+), 16 deletions(-) + +Index: b/CMakeLists.txt +=================================================================== +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -91,21 +91,17 @@ target_include_directories(bpf PRIVATE + set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer strings + ctf_encoder.c ctf_loader.c libctf.c btf_encoder.c btf_loader.c libbtf.c + dwarf_loader.c dutil.c elf_symtab.c rbtree.c) +-add_library(dwarves SHARED ${dwarves_LIB_SRCS} $) +-set_target_properties(dwarves PROPERTIES VERSION 1.0.0 SOVERSION 1) +-set_target_properties(dwarves PROPERTIES INTERFACE_LINK_LIBRARIES "") ++add_library(dwarves STATIC ${dwarves_LIB_SRCS} $) + target_include_directories(dwarves PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi) + target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES}) + + set(dwarves_emit_LIB_SRCS dwarves_emit.c) +-add_library(dwarves_emit SHARED ${dwarves_emit_LIB_SRCS}) +-set_target_properties(dwarves_emit PROPERTIES VERSION 1.0.0 SOVERSION 1) ++add_library(dwarves_emit STATIC ${dwarves_emit_LIB_SRCS}) + target_link_libraries(dwarves_emit dwarves) + + set(dwarves_reorganize_LIB_SRCS dwarves_reorganize.c) +-add_library(dwarves_reorganize SHARED ${dwarves_reorganize_LIB_SRCS}) +-set_target_properties(dwarves_reorganize PROPERTIES VERSION 1.0.0 SOVERSION 1) ++add_library(dwarves_reorganize STATIC ${dwarves_reorganize_LIB_SRCS}) + target_link_libraries(dwarves_reorganize dwarves) + + set(codiff_SRCS codiff.c) +@@ -151,13 +147,6 @@ target_link_libraries(syscse dwarves) + install(TARGETS codiff ctracer dtagnames pahole pdwtags + pfunct pglobal prefcnt scncopy syscse RUNTIME DESTINATION + ${CMAKE_INSTALL_PREFIX}/bin) +-install(TARGETS dwarves LIBRARY DESTINATION ${LIB_INSTALL_DIR}) +-install(TARGETS dwarves dwarves_emit dwarves_reorganize LIBRARY DESTINATION ${LIB_INSTALL_DIR}) +-install(FILES dwarves.h dwarves_emit.h dwarves_reorganize.h +- dutil.h gobuffer.h list.h rbtree.h pahole_strings.h +- btf_encoder.h config.h ctf_encoder.h ctf.h +- elfcreator.h elf_symtab.h hash.h libbtf.h libctf.h +- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dwarves/) + install(FILES man-pages/pahole.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1/) + install(PROGRAMS ostra/ostra-cg DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) + install(PROGRAMS btfdiff fullcircle DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) +Index: b/cmake/modules/FindDWARF.cmake +=================================================================== +--- a/cmake/modules/FindDWARF.cmake ++++ b/cmake/modules/FindDWARF.cmake +@@ -29,12 +29,14 @@ find_path(LIBDW_INCLUDE_DIR elfutils/lib + + find_library(DWARF_LIBRARY + NAMES dw dwarf +- PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 ~/usr/local/lib ~/usr/local/lib64 ++ PATHS /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} /usr/lib ++ NO_DEFAULT_PATH + ) + + find_library(ELF_LIBRARY + NAMES elf +- PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 ~/usr/local/lib ~/usr/local/lib64 ++ PATHS /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} /usr/lib ++ NO_DEFAULT_PATH + ) + + if (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY) diff -Nru dwarves-dfsg-1.10/debian/patches/no_shared_no_ebl.diff dwarves-dfsg-1.21/debian/patches/no_shared_no_ebl.diff --- dwarves-dfsg-1.10/debian/patches/no_shared_no_ebl.diff 2012-06-16 09:00:41.000000000 +0000 +++ dwarves-dfsg-1.21/debian/patches/no_shared_no_ebl.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ -Description: build static libs and remove ebl dependency - - Build static libraries instead of shared libaries so that we have a single - package. - - Do not try to find and link with libebl.so as it is no longer provided by - elfutils. - -Origin: Thomas Girard -Forwarded: no -Last-Update: 2012-06-07 - ---- dwarves-dfsg-1.10.orig/CMakeLists.txt -+++ dwarves-dfsg-1.10/CMakeLists.txt -@@ -36,19 +36,15 @@ _set_fancy(LIB_INSTALL_DIR "${EXEC_INSTA - set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer strings - ctf_encoder.c ctf_loader.c libctf.c dwarf_loader.c - dutil.c elf_symtab.c rbtree.c) --add_library(dwarves SHARED ${dwarves_LIB_SRCS}) --set_target_properties(dwarves PROPERTIES VERSION 1.0.0 SOVERSION 1) --set_target_properties(dwarves PROPERTIES LINK_INTERFACE_LIBRARIES "") -+add_library(dwarves STATIC ${dwarves_LIB_SRCS}) - target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES}) - - set(dwarves_emit_LIB_SRCS dwarves_emit.c) --add_library(dwarves_emit SHARED ${dwarves_emit_LIB_SRCS}) --set_target_properties(dwarves_emit PROPERTIES VERSION 1.0.0 SOVERSION 1) -+add_library(dwarves_emit STATIC ${dwarves_emit_LIB_SRCS}) - target_link_libraries(dwarves_emit dwarves) - - set(dwarves_reorganize_LIB_SRCS dwarves_reorganize.c) --add_library(dwarves_reorganize SHARED ${dwarves_reorganize_LIB_SRCS}) --set_target_properties(dwarves_reorganize PROPERTIES VERSION 1.0.0 SOVERSION 1) -+add_library(dwarves_reorganize STATIC ${dwarves_reorganize_LIB_SRCS}) - target_link_libraries(dwarves_reorganize dwarves) - - set(codiff_SRCS codiff.c) -@@ -94,11 +90,6 @@ target_link_libraries(syscse dwarves) - install(TARGETS codiff ctracer dtagnames pahole pdwtags - pfunct pglobal prefcnt scncopy syscse RUNTIME DESTINATION - ${CMAKE_INSTALL_PREFIX}/bin) --install(TARGETS dwarves LIBRARY DESTINATION ${LIB_INSTALL_DIR}) --install(TARGETS dwarves dwarves_emit dwarves_reorganize LIBRARY DESTINATION ${LIB_INSTALL_DIR}) --install(FILES dwarves.h dwarves_emit.h dwarves_reorganize.h -- dutil.h gobuffer.h list.h rbtree.h strings.h -- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dwarves/) - install(FILES man-pages/pahole.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1/) - install(PROGRAMS ostra/ostra-cg DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) - install(FILES ostra/python/ostra.py DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dwarves/runtime/python) ---- dwarves-dfsg-1.10.orig/cmake/modules/FindDWARF.cmake -+++ dwarves-dfsg-1.10/cmake/modules/FindDWARF.cmake -@@ -29,22 +29,19 @@ find_path(LIBDW_INCLUDE_DIR elfutils/lib - - find_library(DWARF_LIBRARY - NAMES dw dwarf -- PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 ~/usr/local/lib ~/usr/local/lib64 -+ PATHS /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} /usr/lib -+ NO_DEFAULT_PATH - ) - - find_library(ELF_LIBRARY - NAMES elf -- PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 ~/usr/local/lib ~/usr/local/lib64 -+ PATHS /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} /usr/lib -+ NO_DEFAULT_PATH - ) - --find_library(EBL_LIBRARY -- NAMES ebl -- PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 ~/usr/local/lib ~/usr/local/lib64 --) -- --if (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY AND EBL_LIBRARY) -+if (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY) - set(DWARF_FOUND TRUE) -- set(DWARF_LIBRARIES ${DWARF_LIBRARY} ${ELF_LIBRARY} ${EBL_LIBRARY}) -+ set(DWARF_LIBRARIES ${DWARF_LIBRARY} ${ELF_LIBRARY}) - - set(CMAKE_REQUIRED_LIBRARIES ${DWARF_LIBRARIES}) - # check if libdw have the dwfl_module_build_id routine, i.e. if it supports the buildid -@@ -52,10 +49,10 @@ if (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_ - # in distributions such as fedora). We do it against libelf because, IIRC, some distros - # include libdw linked statically into libelf. - check_library_exists(elf dwfl_module_build_id "" HAVE_DWFL_MODULE_BUILD_ID) --else (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY AND EBL_LIBRARY) -+else (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY) - set(DWARF_FOUND FALSE) - set(DWARF_LIBRARIES) --endif (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY AND EBL_LIBRARY) -+endif (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY) - - if (DWARF_FOUND) - if (NOT DWARF_FIND_QUIETLY) -@@ -63,7 +60,6 @@ if (DWARF_FOUND) - message(STATUS "Found elfutils/libdw.h header: ${LIBDW_INCLUDE_DIR}") - message(STATUS "Found libdw library: ${DWARF_LIBRARY}") - message(STATUS "Found libelf library: ${ELF_LIBRARY}") -- message(STATUS "Found libebl library: ${EBL_LIBRARY}") - endif (NOT DWARF_FIND_QUIETLY) - else (DWARF_FOUND) - if (DWARF_FIND_REQUIRED) -@@ -73,9 +69,9 @@ else (DWARF_FOUND) - find_path(FEDORA fedora-release /etc) - find_path(REDHAT redhat-release /etc) - if (FEDORA OR REDHAT) -- if (NOT DWARF_INCLUDE_DIR OR NOT LIBDW_INCLUDE_DIR OR NOT EBL_LIBRARY) -+ if (NOT DWARF_INCLUDE_DIR OR NOT LIBDW_INCLUDE_DIR) - message(STATUS "Please install the elfutils-devel package") -- endif (NOT DWARF_INCLUDE_DIR OR NOT LIBDW_INCLUDE_DIR OR NOT EBL_LIBRARY) -+ endif (NOT DWARF_INCLUDE_DIR OR NOT LIBDW_INCLUDE_DIR) - if (NOT DWARF_LIBRARY) - message(STATUS "Please install the elfutils-libs package") - endif (NOT DWARF_LIBRARY) -@@ -89,9 +85,6 @@ else (DWARF_FOUND) - if (NOT LIBDW_INCLUDE_DIR) - message(STATUS "Could NOT find libdw include dir") - endif (NOT LIBDW_INCLUDE_DIR) -- if (NOT EBL_LIBRARY) -- message(STATUS "Could NOT find libebl library") -- endif (NOT EBL_LIBRARY) - if (NOT DWARF_LIBRARY) - message(STATUS "Could NOT find libdw library") - endif (NOT DWARF_LIBRARY) -@@ -103,7 +96,7 @@ else (DWARF_FOUND) - endif (DWARF_FIND_REQUIRED) - endif (DWARF_FOUND) - --mark_as_advanced(DWARF_INCLUDE_DIR LIBDW_INCLUDE_DIR DWARF_LIBRARY ELF_LIBRARY EBL_LIBRARY) -+mark_as_advanced(DWARF_INCLUDE_DIR LIBDW_INCLUDE_DIR DWARF_LIBRARY ELF_LIBRARY) - include_directories(${DWARF_INCLUDE_DIR} ${LIBDW_INCLUDE_DIR}) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h) - diff -Nru dwarves-dfsg-1.10/debian/patches/packaged_libbpf.patch dwarves-dfsg-1.21/debian/patches/packaged_libbpf.patch --- dwarves-dfsg-1.10/debian/patches/packaged_libbpf.patch 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/patches/packaged_libbpf.patch 2021-02-07 16:59:01.000000000 +0000 @@ -0,0 +1,133 @@ +Author: Luca Boccassi +Description: libbpf: allow one to use packaged version + Add a new CMake option, LIBBPF_EMBEDDED, to switch between the + embedded version and the system version (searched via pkg-config) + of libbpf. Set the system version as the default. +Forwarded: https://www.spinics.net/lists/dwarves/msg00732.html +--- + CMakeLists.txt | 43 +++++++++++++++++++++++++++++++++---------- + btf_encoder.c | 5 +++++ + btf_loader.c | 4 ++++ + libbtf.c | 6 ++++++ + 4 files changed, 48 insertions(+), 10 deletions(-) + +Index: b/CMakeLists.txt +=================================================================== +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -2,6 +2,20 @@ project(pahole C) + cmake_minimum_required(VERSION 2.8.12) + cmake_policy(SET CMP0005 NEW) + ++option(LIBBPF_EMBEDDED "Use the embedded version of libbpf instead of searching it via pkg-config" OFF) ++if (NOT LIBBPF_EMBEDDED) ++ find_package(PkgConfig) ++ if(PKGCONFIG_FOUND) ++ pkg_check_modules(LIBBPF libbpf>=0.2.0) ++ endif() ++endif() ++ ++if(LIBBPF_FOUND) ++ INCLUDE_DIRECTORIES(${LIBBPF_INCLUDE_DIRS}) ++ LINK_DIRECTORIES(${LIBBPF_LIBRARY_DIRS}) ++ ADD_DEFINITIONS(-DLIBBPF_FOUND) ++endif() ++ + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi) +@@ -81,20 +95,29 @@ endif() + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64") + +-file(GLOB libbpf_sources "lib/bpf/src/*.c") +-add_library(bpf OBJECT ${libbpf_sources}) +-set_property(TARGET bpf PROPERTY POSITION_INDEPENDENT_CODE 1) +-target_include_directories(bpf PRIVATE +- ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include +- ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi) ++if (NOT LIBBPF_FOUND) ++ file(GLOB libbpf_sources "lib/bpf/src/*.c") ++ add_library(bpf OBJECT ${libbpf_sources}) ++ set_property(TARGET bpf PROPERTY POSITION_INDEPENDENT_CODE 1) ++ target_include_directories(bpf PRIVATE ++ ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include ++ ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi) ++endif() + + set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer strings + ctf_encoder.c ctf_loader.c libctf.c btf_encoder.c btf_loader.c libbtf.c + dwarf_loader.c dutil.c elf_symtab.c rbtree.c) +-add_library(dwarves STATIC ${dwarves_LIB_SRCS} $) +-target_include_directories(dwarves PRIVATE +- ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi) +-target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES}) ++if (NOT LIBBPF_FOUND) ++ list(APPEND dwarves_LIB_SRCS $) ++endif() ++add_library(dwarves STATIC ${dwarves_LIB_SRCS}) ++if (NOT LIBBPF_FOUND) ++ target_include_directories(dwarves PRIVATE ++ ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi) ++else() ++ target_include_directories(dwarves PRIVATE ${LIBBPF_INCLUDE_DIRS}) ++endif() ++target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBBPF_LIBRARIES}) + + set(dwarves_emit_LIB_SRCS dwarves_emit.c) + add_library(dwarves_emit STATIC ${dwarves_emit_LIB_SRCS}) +Index: b/btf_encoder.c +=================================================================== +--- a/btf_encoder.c ++++ b/btf_encoder.c +@@ -11,8 +11,13 @@ + + #include "dwarves.h" + #include "libbtf.h" ++#ifdef LIBBPF_FOUND ++#include ++#include ++#else + #include "lib/bpf/include/uapi/linux/btf.h" + #include "lib/bpf/src/libbpf.h" ++#endif + #include "hash.h" + #include "elf_symtab.h" + #include "btf_encoder.h" +Index: b/btf_loader.c +=================================================================== +--- a/btf_loader.c ++++ b/btf_loader.c +@@ -25,7 +25,11 @@ + #include + + #include "libbtf.h" ++#ifdef LIBBPF_FOUND ++#include ++#else + #include "lib/bpf/include/uapi/linux/btf.h" ++#endif + #include "dutil.h" + #include "dwarves.h" + +Index: b/libbtf.c +=================================================================== +--- a/libbtf.c ++++ b/libbtf.c +@@ -18,10 +18,16 @@ + #include + + #include "libbtf.h" ++#ifdef LIBBPF_FOUND ++#include ++#include ++#include ++#else + #include "lib/bpf/include/uapi/linux/btf.h" + #include "lib/bpf/include/linux/err.h" + #include "lib/bpf/src/btf.h" + #include "lib/bpf/src/libbpf.h" ++#endif + #include "dutil.h" + #include "gobuffer.h" + #include "dwarves.h" diff -Nru dwarves-dfsg-1.10/debian/patches/remove-bpf-ftrace-filter.patch dwarves-dfsg-1.21/debian/patches/remove-bpf-ftrace-filter.patch --- dwarves-dfsg-1.10/debian/patches/remove-bpf-ftrace-filter.patch 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/patches/remove-bpf-ftrace-filter.patch 2021-06-16 08:57:20.000000000 +0000 @@ -0,0 +1,392 @@ +From 58a98f76ac95b1bb11920ff2b58206b2364e6b3b Mon Sep 17 00:00:00 2001 +From: Martin KaFai Lau +Date: Thu, 6 May 2021 13:56:22 -0700 +Subject: btf: Remove ftrace filter + +BTF is currently generated for functions that are in ftrace list +or extern. + +A recent use case also needs BTF generated for functions included in +allowlist. + +In particular, the kernel commit: + + e78aea8b2170 ("bpf: tcp: Put some tcp cong functions in allowlist for bpf-tcp-cc") + +allows bpf program to directly call a few tcp cc kernel functions. Those +kernel functions are currently allowed only if CONFIG_DYNAMIC_FTRACE +is set to ensure they are in the ftrace list but this kconfig dependency +is unnecessary. + +Those kernel functions are specified under an ELF section .BTF_ids. +There was an earlier attempt [0] to add another filter for the functions in +the .BTF_ids section. That discussion concluded that the ftrace filter +should be removed instead. + +This patch is to remove the ftrace filter and its related functions. + +Number of BTF FUNC with and without is_ftrace_func(): +My kconfig in x86: 40643 vs 46225 +Jiri reported on arm: 25022 vs 55812 + +[0]: https://lore.kernel.org/dwarves/20210423213728.3538141-1-kafai@fb.com/ + +Signed-off-by: Martin KaFai Lau +Tested-by: Nathan Chancellor # build +Acked-by: Jiri Olsa +Acked-by: Jiri Slaby +Cc: Andrii Nakryiko +Cc: Jiri Olsa +Cc: kernel-team@fb.com +Signed-off-by: Arnaldo Carvalho de Melo +--- + btf_encoder.c | 285 ++-------------------------------------------------------- + 1 file changed, 7 insertions(+), 278 deletions(-) + +diff --git a/btf_encoder.c b/btf_encoder.c +index 80e8969..c711f12 100644 +--- a/btf_encoder.c ++++ b/btf_encoder.c +@@ -27,17 +27,8 @@ + */ + #define KSYM_NAME_LEN 128 + +-struct funcs_layout { +- unsigned long mcount_start; +- unsigned long mcount_stop; +- unsigned long mcount_sec_idx; +-}; +- + struct elf_function { + const char *name; +- unsigned long addr; +- unsigned long size; +- unsigned long sh_addr; + bool generated; + }; + +@@ -64,12 +55,9 @@ static void delete_functions(void) + #define max(x, y) ((x) < (y) ? (y) : (x)) + #endif + +-static int collect_function(struct btf_elf *btfe, GElf_Sym *sym, +- size_t sym_sec_idx) ++static int collect_function(struct btf_elf *btfe, GElf_Sym *sym) + { + struct elf_function *new; +- static GElf_Shdr sh; +- static size_t last_idx; + const char *name; + + if (elf_sym__type(sym) != STT_FUNC) +@@ -91,257 +79,12 @@ static int collect_function(struct btf_elf *btfe, GElf_Sym *sym, + functions = new; + } + +- if (sym_sec_idx != last_idx) { +- if (!elf_section_by_idx(btfe->elf, &sh, sym_sec_idx)) +- return 0; +- last_idx = sym_sec_idx; +- } +- + functions[functions_cnt].name = name; +- functions[functions_cnt].addr = elf_sym__value(sym); +- functions[functions_cnt].size = elf_sym__size(sym); +- functions[functions_cnt].sh_addr = sh.sh_addr; + functions[functions_cnt].generated = false; + functions_cnt++; + return 0; + } + +-static int addrs_cmp(const void *_a, const void *_b) +-{ +- const __u64 *a = _a; +- const __u64 *b = _b; +- +- if (*a == *b) +- return 0; +- return *a < *b ? -1 : 1; +-} +- +-static int get_vmlinux_addrs(struct btf_elf *btfe, struct funcs_layout *fl, +- __u64 **paddrs, __u64 *pcount) +-{ +- __u64 *addrs, count, offset; +- unsigned int addr_size, i; +- Elf_Data *data; +- GElf_Shdr shdr; +- Elf_Scn *sec; +- +- /* Initialize for the sake of all error paths below. */ +- *paddrs = NULL; +- *pcount = 0; +- +- if (!fl->mcount_start || !fl->mcount_stop) +- return 0; +- +- /* +- * Find mcount addressed marked by __start_mcount_loc +- * and __stop_mcount_loc symbols and load them into +- * sorted array. +- */ +- sec = elf_getscn(btfe->elf, fl->mcount_sec_idx); +- if (!sec || !gelf_getshdr(sec, &shdr)) { +- fprintf(stderr, "Failed to get section(%lu) header.\n", +- fl->mcount_sec_idx); +- return -1; +- } +- +- /* Get address size from processed file's ELF class. */ +- addr_size = gelf_getclass(btfe->elf) == ELFCLASS32 ? 4 : 8; +- +- offset = fl->mcount_start - shdr.sh_addr; +- count = (fl->mcount_stop - fl->mcount_start) / addr_size; +- +- data = elf_getdata(sec, 0); +- if (!data) { +- fprintf(stderr, "Failed to get section(%lu) data.\n", +- fl->mcount_sec_idx); +- return -1; +- } +- +- addrs = malloc(count * sizeof(addrs[0])); +- if (!addrs) { +- fprintf(stderr, "Failed to allocate memory for ftrace addresses.\n"); +- return -1; +- } +- +- if (addr_size == sizeof(__u64)) { +- memcpy(addrs, data->d_buf + offset, count * addr_size); +- } else { +- for (i = 0; i < count; i++) +- addrs[i] = (__u64) *((__u32 *) (data->d_buf + offset + i * addr_size)); +- } +- +- *paddrs = addrs; +- *pcount = count; +- return 0; +-} +- +-static int +-get_kmod_addrs(struct btf_elf *btfe, __u64 **paddrs, __u64 *pcount) +-{ +- __u64 *addrs, count; +- unsigned int addr_size, i; +- GElf_Shdr shdr_mcount; +- Elf_Data *data; +- Elf_Scn *sec; +- +- /* Initialize for the sake of all error paths below. */ +- *paddrs = NULL; +- *pcount = 0; +- +- /* get __mcount_loc */ +- sec = elf_section_by_name(btfe->elf, &btfe->ehdr, &shdr_mcount, +- "__mcount_loc", NULL); +- if (!sec) { +- if (btf_elf__verbose) { +- printf("%s: '%s' doesn't have __mcount_loc section\n", __func__, +- btfe->filename); +- } +- return 0; +- } +- +- data = elf_getdata(sec, NULL); +- if (!data) { +- fprintf(stderr, "Failed to data for __mcount_loc section.\n"); +- return -1; +- } +- +- /* Get address size from processed file's ELF class. */ +- addr_size = gelf_getclass(btfe->elf) == ELFCLASS32 ? 4 : 8; +- +- count = data->d_size / addr_size; +- +- addrs = malloc(count * sizeof(addrs[0])); +- if (!addrs) { +- fprintf(stderr, "Failed to allocate memory for ftrace addresses.\n"); +- return -1; +- } +- +- if (addr_size == sizeof(__u64)) { +- memcpy(addrs, data->d_buf, count * addr_size); +- } else { +- for (i = 0; i < count; i++) +- addrs[i] = (__u64) *((__u32 *) (data->d_buf + i * addr_size)); +- } +- +- /* +- * We get Elf object from dwfl_module_getelf function, +- * which performs all possible relocations, including +- * __mcount_loc section. +- * +- * So addrs array now contains relocated values, which +- * we need take into account when we compare them to +- * functions values, see comment in setup_functions +- * function. +- */ +- *paddrs = addrs; +- *pcount = count; +- return 0; +-} +- +-static int is_ftrace_func(struct elf_function *func, __u64 *addrs, __u64 count) +-{ +- __u64 start = func->addr; +- __u64 addr, end = func->addr + func->size; +- +- /* +- * The invariant here is addr[r] that is the smallest address +- * that is >= than function start addr. Except the corner case +- * where there is no such r, but for that we have a final check +- * in the return. +- */ +- size_t l = 0, r = count - 1, m; +- +- /* make sure we don't use invalid r */ +- if (count == 0) +- return false; +- +- while (l < r) { +- m = l + (r - l) / 2; +- addr = addrs[m]; +- +- if (addr >= start) { +- /* we satisfy invariant, so tighten r */ +- r = m; +- } else { +- /* m is not good enough as l, maybe m + 1 will be */ +- l = m + 1; +- } +- } +- +- return start <= addrs[r] && addrs[r] < end; +-} +- +-static int setup_functions(struct btf_elf *btfe, struct funcs_layout *fl) +-{ +- __u64 *addrs, count, i; +- int functions_valid = 0; +- bool kmod = false; +- +- /* +- * Check if we are processing vmlinux image and +- * get mcount data if it's detected. +- */ +- if (get_vmlinux_addrs(btfe, fl, &addrs, &count)) +- return -1; +- +- /* +- * Check if we are processing kernel module and +- * get mcount data if it's detected. +- */ +- if (!addrs) { +- if (get_kmod_addrs(btfe, &addrs, &count)) +- return -1; +- kmod = true; +- } +- +- if (!addrs) { +- if (btf_elf__verbose) +- printf("ftrace symbols not detected, falling back to DWARF data\n"); +- delete_functions(); +- return 0; +- } +- +- qsort(addrs, count, sizeof(addrs[0]), addrs_cmp); +- qsort(functions, functions_cnt, sizeof(functions[0]), functions_cmp); +- +- /* +- * Let's got through all collected functions and filter +- * out those that are not in ftrace. +- */ +- for (i = 0; i < functions_cnt; i++) { +- struct elf_function *func = &functions[i]; +- /* +- * For vmlinux image both addrs[x] and functions[x]::addr +- * values are final address and are comparable. +- * +- * For kernel module addrs[x] is final address, but +- * functions[x]::addr is relative address within section +- * and needs to be relocated by adding sh_addr. +- */ +- if (kmod) +- func->addr += func->sh_addr; +- +- /* Make sure function is within ftrace addresses. */ +- if (is_ftrace_func(func, addrs, count)) { +- /* +- * We iterate over sorted array, so we can easily skip +- * not valid item and move following valid field into +- * its place, and still keep the 'new' array sorted. +- */ +- if (i != functions_valid) +- functions[functions_valid] = functions[i]; +- functions_valid++; +- } +- } +- +- functions_cnt = functions_valid; +- free(addrs); +- +- if (btf_elf__verbose) +- printf("Found %d functions!\n", functions_cnt); +- return 0; +-} +- + static struct elf_function *find_function(const struct btf_elf *btfe, + const char *name) + { +@@ -620,23 +363,8 @@ static int collect_percpu_var(struct btf_elf *btfe, GElf_Sym *sym, + return 0; + } + +-static void collect_symbol(GElf_Sym *sym, struct funcs_layout *fl, +- size_t sym_sec_idx) +-{ +- if (!fl->mcount_start && +- !strcmp("__start_mcount_loc", elf_sym__name(sym, btfe->symtab))) { +- fl->mcount_start = sym->st_value; +- fl->mcount_sec_idx = sym_sec_idx; +- } +- +- if (!fl->mcount_stop && +- !strcmp("__stop_mcount_loc", elf_sym__name(sym, btfe->symtab))) +- fl->mcount_stop = sym->st_value; +-} +- + static int collect_symbols(struct btf_elf *btfe, bool collect_percpu_vars) + { +- struct funcs_layout fl = { }; + Elf32_Word sym_sec_idx; + uint32_t core_id; + GElf_Sym sym; +@@ -648,9 +376,8 @@ static int collect_symbols(struct btf_elf *btfe, bool collect_percpu_vars) + elf_symtab__for_each_symbol_index(btfe->symtab, core_id, sym, sym_sec_idx) { + if (collect_percpu_vars && collect_percpu_var(btfe, &sym, sym_sec_idx)) + return -1; +- if (collect_function(btfe, &sym, sym_sec_idx)) ++ if (collect_function(btfe, &sym)) + return -1; +- collect_symbol(&sym, &fl, sym_sec_idx); + } + + if (collect_percpu_vars) { +@@ -661,9 +388,11 @@ static int collect_symbols(struct btf_elf *btfe, bool collect_percpu_vars) + printf("Found %d per-CPU variables!\n", percpu_var_cnt); + } + +- if (functions_cnt && setup_functions(btfe, &fl)) { +- fprintf(stderr, "Failed to filter DWARF functions\n"); +- return -1; ++ if (functions_cnt) { ++ qsort(functions, functions_cnt, sizeof(functions[0]), ++ functions_cmp); ++ if (btf_elf__verbose) ++ printf("Found %d functions!\n", functions_cnt); + } + + return 0; +-- +cgit 1.2.3-1.el7 + diff -Nru dwarves-dfsg-1.10/debian/patches/series dwarves-dfsg-1.21/debian/patches/series --- dwarves-dfsg-1.10/debian/patches/series 2016-03-24 13:00:55.000000000 +0000 +++ dwarves-dfsg-1.21/debian/patches/series 2021-09-20 12:10:02.000000000 +0000 @@ -1,2 +1,7 @@ -no_shared_no_ebl.diff -DW_TAG_mutable_type +no_shared_no_ebl +fix-typo-in-manual-page +fix-escaping-in-manual-page +packaged_libbpf.patch +remove-bpf-ftrace-filter.patch +libbpf-0.4.0.patch +c9d4c106ab95cd8c13af4d29395d86c8f5d2f9ac.patch diff -Nru dwarves-dfsg-1.10/debian/rules dwarves-dfsg-1.21/debian/rules --- dwarves-dfsg-1.10/debian/rules 2012-06-08 18:51:26.000000000 +0000 +++ dwarves-dfsg-1.21/debian/rules 2021-09-20 12:10:02.000000000 +0000 @@ -1,76 +1,18 @@ #! /usr/bin/make -f +export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=-lto + # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -CFLAGS = -Wall -g -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif - -export CFLAGS - -configure: configure-stamp -configure-stamp: - dh_testdir - mkdir -p debian/build - cd debian/build && cmake -D__LIB=lib -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE="None" ../.. - touch $@ - -build: build-arch build-indep -build-arch: build-stamp -build-indep: build-stamp -build-stamp: configure-stamp - dh_testdir - $(MAKE) VERBOSE=1 -C debian/build - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - [ ! -f debian/build/Makefile ] || $(MAKE) -C debian/build clean - rm -rf debian/build config.h - dh_clean +%: + dh $@ --builddirectory=debian/build -install: build - dh_testdir - dh_testroot - dh_prep - dh_installdirs +override_dh_auto_configure: + dh_auto_configure -- -D__LIB=lib -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE="None" -DLIBBPF_EMBEDDED=on +override_dh_auto_install-arch: $(MAKE) -C debian/build install DESTDIR=$(CURDIR)/debian/tmp # remove them for now, will be included in a next upload # (requires python and matplotlib) rm -Rf debian/tmp/usr/share/dwarves/runtime/python debian/tmp/usr/bin/ostra-cg - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs - dh_installexamples - dh_install --source=debian/tmp --fail-missing - dh_installman - dh_link - dh_strip - dh_compress - dh_fixperms - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -get-orig-source: - sh debian/get-orig.sh - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure get-orig-source diff -Nru dwarves-dfsg-1.10/debian/salsa-ci.yml dwarves-dfsg-1.21/debian/salsa-ci.yml --- dwarves-dfsg-1.10/debian/salsa-ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/salsa-ci.yml 2021-02-07 16:59:01.000000000 +0000 @@ -0,0 +1,3 @@ +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml diff -Nru dwarves-dfsg-1.10/debian/source/lintian-overrides dwarves-dfsg-1.21/debian/source/lintian-overrides --- dwarves-dfsg-1.10/debian/source/lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/source/lintian-overrides 2021-02-07 16:59:01.000000000 +0000 @@ -0,0 +1 @@ +orig-tarball-missing-upstream-signature diff -Nru dwarves-dfsg-1.10/debian/tests/control dwarves-dfsg-1.21/debian/tests/control --- dwarves-dfsg-1.10/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/tests/control 2021-02-07 16:59:01.000000000 +0000 @@ -0,0 +1,2 @@ +Test-Command: pahole --version +Restrictions: superficial diff -Nru dwarves-dfsg-1.10/debian/upstream/metadata dwarves-dfsg-1.21/debian/upstream/metadata --- dwarves-dfsg-1.10/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/upstream/metadata 2021-02-07 16:59:01.000000000 +0000 @@ -0,0 +1,4 @@ +Changelog: https://git.kernel.org/pub/scm/devel/pahole/pahole.git/tree/NEWS +Contact: dwarves@vger.kernel.org +Repository-Browse: https://git.kernel.org/pub/scm/devel/pahole/pahole.git +Repository: git://git.kernel.org/pub/scm/devel/pahole/pahole.git diff -Nru dwarves-dfsg-1.10/debian/upstream/signing-key.asc dwarves-dfsg-1.21/debian/upstream/signing-key.asc --- dwarves-dfsg-1.10/debian/upstream/signing-key.asc 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/debian/upstream/signing-key.asc 2021-02-07 16:59:01.000000000 +0000 @@ -0,0 +1,102 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBE6gS9IBEAC68meGuRb+KJS7Vl3b7EP7aq/EBcJd6z2hTiY0Y3y0Er9x5lKq +/FJ6beafMb+kftnOH6oj5hlk0u8NEKUslL1y/wLm4Y1FeGDwFZDWUjKfplehN5LK +6eqgZu24z7rHHGnD20m2H6gzbnQOVgKOTlMunjyP3wSOImUCP3eI/qBpYNKAe1p6 +qOsjqigT1QK6rVMrDx1kmMy6tpZ/nkKd56UZIOeW2ZD3d+9+d1zEMHDtOJly2CGP +jp3t4wktqCV1f+0UxNSTIBamUkep36DHiFxRWO4RbHvUMvrUx+ZbaAa8+58+pNfC +1piTKzOsD8VvyTTwY+Kk5RUEJBwNP92nDFeKdAx1eNsRJVVspwquQbJzAbPsecE7 +v8Ii7UK2RZaS/82CdUbFHtW2rU6spaqn/QuNfX4+Skr+Bqh/R8d1rWtGeSR1Odfo +FjeHvFg6OpZQT0FWPw80jTM0rdCggnhjzKZk3WqD3ELGmalRfR6M87jP4QSfkQgP +a8XknI+3q9pI5z6sYeTvnbPVTCT8JmBzLcAHHeRfP+WSXBuNhocDZG0fYXmeaS3F +NUM0gNLZvbCaFP0gSrtUiiREPqEWrvgA69cnOkzCc0z/BCyhDrbfL1gXudu30jJW +4O6xuaUdqGKL1D3Hrlt9S72jFhHayu0wgrrUij70gfad3Z63DlQNhQcRywARAQAB +tCpBcm5hbGRvIENhcnZhbGhvIGRlIE1lbG8gPGFjbWVAa2VybmVsLm9yZz6JAjgE +EwECACIFAlOjRuoCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJENZQFvNT +UqpARpsP/jc2H7xPN5xFm5sVRXjVOA4r1UDUprIO4P/NwAM/1Ae7F3lRo/O7q0mg +GuMssDN1SMXmtocMopBUMKYSwKzmTDv9+YdqPqGIL7VP/JINoH8hfSdoC++NN0Ar +E9cOe9uAemx/gW3Os0u0hlNo7fQZRL0q2WoSrCYnqYaiCDFxTl0miTjgUgvYfG26 +77Q1lzvp2Zp1vebUhgnaZd/673bAI3NlVvD8D6FUzDiiXUu2h4zp3JGnUlykLDkv +d6DUZXP0haDQnjgWNMmHFQPGF2qN08nZ6t226J59+wFQ8yaX+MdTOhItHRVs+0It +IAHcPO+wedsNJwy5PQ3vvfOVlKyfinUeMjL80rLpJGsCSxRKdXHxF3aU/Yms4wzc +0cDGgltg0/V86T8nPvBattWDPtRZ4/sqm6TeDE17RZULyApPBin5zv2nqfN4LjrS +RuQhpY3xdeBRzfV37s0zWuNYERXXjBq3gfgKPbX+jLhyKwh1eV96QSL/nbjXshGE +S91Z30oocvpcOAfANpI0GudG8tAgFfl5gV4oeK7pHS4uuIJ4GSsMYl+bsmbt1mcR +7q16yvqKp6Igv2OAXD6bY8SINaEONAjC7fBgV0lheI+2W6XIwBRnZjhXqr4M0Uz/ +OkLPFP9lxzUw4VDPDqD7NmYsf+aXhvFgY/715G6UG8W68QIDT03EtDpBcm5hbGRv +IENhcnZhbGhvIGRlIE1lbG8gKGtlcm5lbC5vcmcpIDxhY21lQGluZnJhZGVhZC5v +cmc+iQI4BBMBAgAiBQJOoEvSAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK +CRDWUBbzU1KqQNhOD/0bCVA0EfYWLtBH7T+W52eU2MONA+cP/uKdBAGZbV7ycNDk +kV9nHUiuazoy7RNkro03t0CCLPtYWbePDE/uf+U2//dT+2EkUGarqv3UxrllY32e +oYk5PAYBWj2tRHFSVzz6PbZRqvI5Yw9Qao8tK9hxx+IA1azBiwyPkeapL1lp3dKQ +tWhkXWUkbFetPzErB/g3KEW6WvqPv1kNkZRdFZKF0hfPDDMAL7wZtrCRqW+cAr4I +gXNOvEEU61wElDs7S6bCLfTx+55TJSnx1/PNOAwAFwWJqC9xcT9Kr/UuV6/dzt5r +V2lBSpL/rqoZDEDr8XLIptKe5GTybpBz6s6TkZnWJcWouTd1mIyPsCXT/l3/jXZ1 +pdbtx9swce15eluLmioKV3rkT9M56eusOsk6vFs4/EnWx5VW50kZjP9/yDwGgP5z +CDJEa/C6fw/ITfLXHGqsVQfX2ALeNFnl9H6lGb07ce/XVm39YlIcEYU66SRwoF9K +EbzOBPJjmE4BokXCBrfCzh2GuyBNsi5nB/WCwcfnDbpEB0LAuSXZZR4cITWrDpZ/ +8FZOa9fueJgLu9DUrfsdufQJnipXcZ91h0LHva77pkeSLfHTslBm4jNIIX1fLlBp +c2cr7jp8cNhtPc3jX3Zfb9JzJLg9Ncp8XoYDbjL6hz4Ys2V0iqj6aDNR2g/LWbgz +BFuIRuUWCSsGAQQB2kcPAQEHQNW897GlcPJ2kHkgj6oCDpER/qKCz+dCXCtds7bW +xk9EiQKtBBgBCAAgFiEELb9bqkb7Te0zijNb1lAW81NSqkAFAluIRuUCGwIAgQkQ +1lAW81NSqkB2IAQZFggAHRYhBHYaIhRy1059faoeEbI8oumkIn4nBQJbiEblAAoJ +ELI8oumkIn4nedgBAIQNYoaqb0XiXIp87hGm+ilETcnEzy5NA/tpZb//o38mAQDB +iqV8e9DjdXwOXz0pOc453LhaS+jiQFl4bnDI13bABUCjD/9Fp8Ib7s0kmINarfUx +45vR5KIbfiBePT/MAVpCyDpxgSNy1wzkGmitC6ehkblMciBFrGPIDetBGq53PJDT +m7BVe8hcyInabSX09tXEgpR1zPiIFY0X6/URqItsCzUiydVwm5oxq+4Jl7hFCgms +Rb86b5xVeoL2uw4i6s2ZBiKkbht88KwaGTQAbRfkimiCzvvBussET3wSIprDvdiy +SAiS0G7BFd1Lj5qJQHYJLLz68CSbPx5KP11oJT3mhgrzZ8RgalKyjBt8izyE3O9P +H7ujHIbCT/XUApcQehL+loeLkWTfNFd30SfgpGV4dGE10ZHl1vVexWGXYDfSqn1r +uPYycpWEJQCTk0lSSsQyhDVJ3x3il5mqi0f7WsuePATsxTNJkYr1gq6JGJN94KFV +DQfgMxMp3ALun3QsxL9NWiyUSPhFTxrXpbyPHZuwkxcRTAqxg4sUbfARlgaUoykO +viu02FggX1rDdUCndYFKQPMzd2pg59wssLaDSX1JemksgKZUrGF/ciKtdBYzxLfS +XdhDojmk3EWrnHhV6++qks+I+psr4MzktEzp7ceW0XsrQpX3m8Y7OD6RKJUtFz/3 +yoD19Lnlpkk9d4bxSOJZ+uY6Sd6RdXTfbfFPzhewKOiMlMgRiNzVhpZf2IH9v1ik +DvwHUOwmbbcXvicOB47RYFVX6rkBDQRUSAh0AQgA7DYUSchx8AqvsSrTj1YbFxW5 +4aV1NVcjZsFT4i2aVA5qZgZDiRyO/ILz1NJHGduek6XW9uqjr2IGASta/ld6GRjJ +mHzCkJIkD1rLv14lQFnvC9wvMgtcfmg3S4AW5oEelrDPm5mr+Da66zrhwKqIEXRM +w/Yflbz5X/RKv6AOKH8lgpK58Z4R3/LNZaReFnUhnwKD6p5+uDqDYuZcu7KObg3w +oFymbYgzQGTNPdHC9ECs4b10w6UKOwpavOC6IkEBLQF88mEH9EuqonP5Yu1ojSsl +IE719efLUjyvCSggMDZNPDoFrkWKbsLKvlQhVl2VdJkrlMf2c223hluEbFsvYQAR +AQABiQNEBBgBAgAPBQJUSAh0AhsCBQkA7U4AASkJENZQFvNTUqpAwF0gBBkBAgAG +BQJUSAh0AAoJEBpxZoYYoA713X8IAIhIExi1ffcd0+9cQ6esHqZWRGZBsH2YGJex +C1EAlI567yXULZonVr4efxOqAlb2qi+q7zNjCRtfwxsUwdTiP+BUGks8OGnSO/yn +JZ+fzjmH67w7w0y8On0CLMGA7HgpzvB3m83DO3Kk59i/ViJD2sDMbqB1J7pzJunW +gv/yMggV+3L0il1R1tvCI320rJhOi2g9FODvZQ/4762VyZbhPngrryIZPB0EX/pB +xl1VuiyDipNelQxuSGgP7qnuwENBwBIcrXcCD8aFeQoRwaS1U48795eJUgjrmSMr +CguHixuxsHQFxdynfXgkJqMGOYIL+WJcTV1qWVO2d3gkxNR+DEPFsw//S5q8j+36 +w79tNVOY6FUpY9YREXvh7r8n/CE1hhVWZO3tWKh5hkJRvi1T4+LLpoD6S6pQBpv+ +Uhg/HpiW4srq66ZgmIJbSnpEA3lDrlgEw4KPTT7Kvyv9JQ5R5dgGUi23kajufXQj +41Sxyf2+0rf/G8xWF2tGzqyVdii9uHkZO8rV6elOoBnlw+nb21flr/3XgUVY7yT5 +LX6UzJOP+GrcIud6jMuWFfJqIUDC5XZefM2Bj7KTq5p4d7B2kYjv7/QjMQW/K3cu +ZUx7KkrWigab+lcyur2TZysKzAPGmBcHc7voWmARNa3iK9v8g9+8C/Po07bzK5NP +hK3eDGkQknrZ8L+0UXhQAtupwAaIN8lVm8miJwU0PZigzzarAmK3SzdezdihBgIN +0Z7aEcgPJIzjxJIbPd+wiJgCmC3BdxWohMztHMyF9hwH4XhOIEi7povZvEzxywcc +55K/mBNHG9Z0GrAGvAtNeXPXDF/BUQp3E4CmoPrx4PSEfwnjAfwijxnxBIIqChxR +7TVHbgSy70CEyxScYaaZ6sIP0pXAG8xP2K7l8fY6IvLmx6YVBWeVsASIOoEU4kW9 +Um/7MaI7ZiHeSDClizehKgUpT/34US40gbCpc+N3N3Yq909sV/oLzs1GFc0sx4fr +YpgZiE0NcEJG1D1pojkwxuZI+zcrivEAf2u5Ag0ETqBL0gEQANdPhWLUZjlwUS6C +rSJvsMBw5pQWBqd21Z8bFrKTva9Eq3YcYI+/KPbnYlkm6JeUcp76jH0gh/oG1Iu4 +6X1YZE5fOQgR8I+F8sG84LfY/79441D/JUuw0wNiZ0kXdSQmsifh0wDWaG3TI1qO +zeAd3z4P1BzFnp9w0uUFOpYxPG51kQG99WRdhdTmPRKv3WydsRdV9MInZf3vs/6n +02r+A5NIFsIvl6bwq4em96pLJCO35jCjYJfi7IHn12I4+RQJ0+V9oKhVwsvyyTMH +AlvpDNXreEhDsmlTgipuFd8MJd3MptRtH4hoyAFpRGUH3sw6clt84mOP/rHnPMKU +u6P5VdRsWnINicPVIoAgwcLGkELsDfAdFr+O8O3kZVB3CnLz2TxeF+ZzNws273iT +JTRESvRKCtcNdBQLsqfuNeQJyH0JEbg0DZhjcTV5XMI1z+HzM7hR1ClPFRC1h4yj +mBQuG2zDwUSNRENbxorusbjXft73qIV3TgNHk3gk37QZo2rG6aSsloe4cbD12W2G +4cbbWoJxDh4p+rq/xg0oEtowWJdjgaiuK18Al7XHrShLA4JJI/cD0NgUbY/kDAe8 +qBTvBmwQVzE9bwUrzB34Zxxf0CBFoUQkhxWJydQCzDwwY+c5ugTCthxG6uWF97oL +1r3Iv2KgzfXaaInaR4SxiPztSKY3ABEBAAGJAh8EGAECAAkFAk6gS9ICGwwACgkQ +1lAW81NSqkBi5g//dStcMvg5XXNGPSewSquwAvkAS9W2ALHtGQxwOKeC2BLlJt0E +2iGWvKVDBIePVlx+Ul9z9k/y1oHO8nrdObbCQPzo8xziH0v4vuYv4YoYK/sWVUWd +PyiDFQ3PswceRtfwDZ9NakxvSRXEA5DaD+FKPgPYfJJZDy3gPF23eHqMKqUBRmbC +zdXp/vFbRYhpegokpGDnIOY8rnpmjoFzwd5r//BWCOahISOJcqXS2Xq+yqfsJzC4 +wdzfpH/CGKJ6YceWIaR4SutcysbNRVnq7MEc6y55EAwWDa9e6C6I98Y6ZM+VRgbI +APT5H9gUUV7lHmb5QlR9afkohT3KyjxGXAO94+WwiOo08f/BEoPjrleVITEhlmCP +51DZu/VYe6GOn3ZrygI7sOeTidPTohfYfh+b4J1ReSs6rWnpNGKU6SQoFWEAQKgP +ewE2S/D0dbl+IrzUfW6eLwuD46oWVrT9+eL3M1AKWK9huhhj7POxidJ5k+lx7xHP +AaGU8NlAX1p87n9Or4I4/sAaKdKEpLTg+wd6WhyB0NdRvQ9BQhD0sCGSKgGTMvQi +dgVU1I6tUp7+wN/hhjTHqQ9PWRRFFGfgbl49SKH5c1D93nSgowHLN/4YDBJ/F8mc +rC1A2bWDJ4Q49Tmvw4SIdfwQnyCLj13BHImxHSD7wutNwOC0uC0OklkhEyM= +=SBg6 +-----END PGP PUBLIC KEY BLOCK----- diff -Nru dwarves-dfsg-1.10/debian/watch dwarves-dfsg-1.21/debian/watch --- dwarves-dfsg-1.10/debian/watch 2012-06-08 18:34:45.000000000 +0000 +++ dwarves-dfsg-1.21/debian/watch 2021-02-07 16:59:01.000000000 +0000 @@ -1,3 +1,4 @@ -version=3 +version=4 -http://fedorapeople.org/~acme/dwarves/dwarves-(.*)\.tar\.bz2 +opts="decompress,pgpsigurlmangle=s%@ARCHIVE_EXT@$%.tar.sign%" \ + https://fedorapeople.org/~acme/dwarves/dwarves-(.*)\.tar\.xz diff -Nru dwarves-dfsg-1.10/dtagnames.c dwarves-dfsg-1.21/dtagnames.c --- dwarves-dfsg-1.10/dtagnames.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/dtagnames.c 2021-03-07 13:51:27.000000000 +0000 @@ -1,42 +1,32 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include #include -#include #include "dwarves.h" #include "dutil.h" -static void print_malloc_stats(void) -{ - struct mallinfo m = mallinfo(); - - fprintf(stderr, "size: %u\n", m.uordblks); -} - -static int class__tag_name(struct tag *self, struct cu *cu __unused, +static int class__tag_name(struct tag *tag, struct cu *cu __unused, void *cookie __unused) { - puts(dwarf_tag_name(self->tag)); + puts(dwarf_tag_name(tag->tag)); return 0; } -static int cu__dump_class_tag_names(struct cu *self, void *cookie __unused) +static int cu__dump_class_tag_names(struct cu *cu, void *cookie __unused) { - cu__for_all_tags(self, class__tag_name, NULL); + cu__for_all_tags(cu, class__tag_name, NULL); return 0; } -static void cus__dump_class_tag_names(struct cus *self) +static void cus__dump_class_tag_names(struct cus *cus) { - cus__for_each_cu(self, cu__dump_class_tag_names, NULL, NULL); + cus__for_each_cu(cus, cu__dump_class_tag_names, NULL, NULL); } int main(int argc __unused, char *argv[]) @@ -50,11 +40,12 @@ } err = cus__load_files(cus, NULL, argv + 1); - if (err != 0) + if (err != 0) { + cus__fprintf_load_files_err(cus, "dtagnames", argv + 1, err, stderr); goto out; + } cus__dump_class_tag_names(cus); - print_malloc_stats(); rc = EXIT_SUCCESS; out: cus__delete(cus); diff -Nru dwarves-dfsg-1.10/dutil.c dwarves-dfsg-1.21/dutil.c --- dwarves-dfsg-1.10/dutil.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/dutil.c 2021-03-07 13:51:27.000000000 +0000 @@ -1,9 +1,7 @@ /* - Copyright (C) 2007 Arnaldo Carvalho de Melo + SPDX-License-Identifier: GPL-2.0-only - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. + Copyright (C) 2007 Arnaldo Carvalho de Melo */ @@ -25,34 +23,34 @@ struct str_node *str_node__new(const char *s, bool dupstr) { - struct str_node *self = malloc(sizeof(*self)); + struct str_node *snode = malloc(sizeof(*snode)); - if (self != NULL){ + if (snode != NULL){ if (dupstr) { s = strdup(s); if (s == NULL) goto out_delete; } - self->s = s; + snode->s = s; } - return self; + return snode; out_delete: - free(self); + free(snode); return NULL; } -static void str_node__delete(struct str_node *self, bool dupstr) +static void str_node__delete(struct str_node *snode, bool dupstr) { if (dupstr) - free((void *)self->s); - free(self); + free((void *)snode->s); + free(snode); } -int strlist__add(struct strlist *self, const char *new_entry) +int __strlist__add(struct strlist *slist, const char *new_entry, void *priv) { - struct rb_node **p = &self->entries.rb_node; + struct rb_node **p = &slist->entries.rb_node; struct rb_node *parent = NULL; struct str_node *sn; @@ -71,17 +69,26 @@ return -EEXIST; } - sn = str_node__new(new_entry, self->dupstr); + sn = str_node__new(new_entry, slist->dupstr); if (sn == NULL) return -ENOMEM; rb_link_node(&sn->rb_node, parent, p); - rb_insert_color(&sn->rb_node, &self->entries); + rb_insert_color(&sn->rb_node, &slist->entries); + + sn->priv = priv; + + list_add_tail(&sn->node, &slist->list_entries); return 0; } -int strlist__load(struct strlist *self, const char *filename) +int strlist__add(struct strlist *slist, const char *new_entry) +{ + return __strlist__add(slist, new_entry, NULL); +} + +int strlist__load(struct strlist *slist, const char *filename) { char entry[1024]; int err = -1; @@ -97,7 +104,7 @@ continue; entry[len - 1] = '\0'; - if (strlist__add(self, entry) != 0) + if (strlist__add(slist, entry) != 0) goto out; } @@ -109,41 +116,43 @@ struct strlist *strlist__new(bool dupstr) { - struct strlist *self = malloc(sizeof(*self)); + struct strlist *slist = malloc(sizeof(*slist)); - if (self != NULL) { - self->entries = RB_ROOT; - self->dupstr = dupstr; + if (slist != NULL) { + slist->entries = RB_ROOT; + INIT_LIST_HEAD(&slist->list_entries); + slist->dupstr = dupstr; } - return self; + return slist; } -void strlist__delete(struct strlist *self) +void strlist__delete(struct strlist *slist) { - if (self != NULL) { + if (slist != NULL) { struct str_node *pos; - struct rb_node *next = rb_first(&self->entries); + struct rb_node *next = rb_first(&slist->entries); while (next) { pos = rb_entry(next, struct str_node, rb_node); next = rb_next(&pos->rb_node); - strlist__remove(self, pos); + strlist__remove(slist, pos); } - self->entries = RB_ROOT; - free(self); + slist->entries = RB_ROOT; + free(slist); } } -void strlist__remove(struct strlist *self, struct str_node *sn) +void strlist__remove(struct strlist *slist, struct str_node *sn) { - rb_erase(&sn->rb_node, &self->entries); - str_node__delete(sn, self->dupstr); + rb_erase(&sn->rb_node, &slist->entries); + list_del_init(&sn->node); + str_node__delete(sn, slist->dupstr); } -bool strlist__has_entry(struct strlist *self, const char *entry) +bool strlist__has_entry(struct strlist *slist, const char *entry) { - struct rb_node **p = &self->entries.rb_node; + struct rb_node **p = &slist->entries.rb_node; struct rb_node *parent = NULL; while (*p != NULL) { @@ -170,12 +179,18 @@ { Elf_Scn *sec = NULL; size_t cnt = 1; + size_t str_idx; + + if (elf_getshdrstrndx(elf, &str_idx)) + return NULL; while ((sec = elf_nextscn(elf, sec)) != NULL) { char *str; gelf_getshdr(sec, shp); - str = elf_strptr(elf, ep->e_shstrndx, shp->sh_name); + str = elf_strptr(elf, str_idx, shp->sh_name); + if (!str) + return NULL; if (!strcmp(name, str)) { if (index) *index = cnt; @@ -186,3 +201,23 @@ return sec; } + +Elf_Scn *elf_section_by_idx(Elf *elf, GElf_Shdr *shp, int idx) +{ + Elf_Scn *sec; + + sec = elf_getscn(elf, idx); + if (sec) + gelf_getshdr(sec, shp); + return sec; +} + +char *strlwr(char *s) +{ + int len = strlen(s), i; + + for (i = 0; i < len; ++i) + s[i] = tolower(s[i]); + + return s; +} diff -Nru dwarves-dfsg-1.10/dutil.h dwarves-dfsg-1.21/dutil.h --- dwarves-dfsg-1.10/dutil.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/dutil.h 2021-03-07 13:51:27.000000000 +0000 @@ -1,21 +1,24 @@ #ifndef _DUTIL_H_ #define _DUTIL_H_ 1 /* + SPDX-License-Identifier: GPL-2.0-only + * Copyright (C) 2007..2009 Arnaldo Carvalho de Melo * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * * Some functions came from the Linux Kernel sources, copyrighted by a * cast of dozens, please see the Linux Kernel git history for details. */ #include #include +#include #include #include +#include #include "rbtree.h" +#include "list.h" + +#define BITS_PER_LONG __BITS_PER_LONG #ifndef __unused #define __unused __attribute__ ((unused)) @@ -32,6 +35,227 @@ return (n != 0 && ((n & (n - 1)) == 0)); } +/** + * fls - find last (most-significant) bit set + * @x: the word to search + * + * This is defined the same way as ffs. + * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. + */ +static __always_inline int fls(int x) +{ + return x ? sizeof(x) * 8 - __builtin_clz(x) : 0; +} + +/** + * fls64 - find last set bit in a 64-bit word + * @x: the word to search + * + * This is defined in a similar way as the libc and compiler builtin + * ffsll, but returns the position of the most significant set bit. + * + * fls64(value) returns 0 if value is 0 or the position of the last + * set bit if value is nonzero. The last (most significant) bit is + * at position 64. + */ +#if BITS_PER_LONG == 32 +static __always_inline int fls64(uint64_t x) +{ + uint32_t h = x >> 32; + if (h) + return fls(h) + 32; + return fls(x); +} +#elif BITS_PER_LONG == 64 +/** + * __fls - find last (most-significant) set bit in a long word + * @word: the word to search + * + * Undefined if no set bit exists, so code should check against 0 first. + */ +static __always_inline unsigned long __fls(unsigned long word) +{ + int num = BITS_PER_LONG - 1; + +#if BITS_PER_LONG == 64 + if (!(word & (~0ul << 32))) { + num -= 32; + word <<= 32; + } +#endif + if (!(word & (~0ul << (BITS_PER_LONG-16)))) { + num -= 16; + word <<= 16; + } + if (!(word & (~0ul << (BITS_PER_LONG-8)))) { + num -= 8; + word <<= 8; + } + if (!(word & (~0ul << (BITS_PER_LONG-4)))) { + num -= 4; + word <<= 4; + } + if (!(word & (~0ul << (BITS_PER_LONG-2)))) { + num -= 2; + word <<= 2; + } + if (!(word & (~0ul << (BITS_PER_LONG-1)))) + num -= 1; + return num; +} + +static __always_inline int fls64(uint64_t x) +{ + if (x == 0) + return 0; + return __fls(x) + 1; +} +#else +#error BITS_PER_LONG not 32 or 64 +#endif + +static inline unsigned fls_long(unsigned long l) +{ + if (sizeof(l) == 4) + return fls(l); + return fls64(l); +} + +/* + * round up to nearest power of two + */ +static inline __attribute__((const)) +unsigned long __roundup_pow_of_two(unsigned long n) +{ + return 1UL << fls_long(n - 1); +} + +/* + * non-constant log of base 2 calculators + * - the arch may override these in asm/bitops.h if they can be implemented + * more efficiently than using fls() and fls64() + * - the arch is not required to handle n==0 if implementing the fallback + */ +static inline __attribute__((const)) +int __ilog2_u32(uint32_t n) +{ + return fls(n) - 1; +} + +static inline __attribute__((const)) +int __ilog2_u64(uint64_t n) +{ + return fls64(n) - 1; +} + +/* + * deal with unrepresentable constant logarithms + */ +extern __attribute__((const)) +int ____ilog2_NaN(void); + +/** + * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value + * @n - parameter + * + * constant-capable log of base 2 calculation + * - this can be used to initialise global variables from constant data, hence + * the massive ternary operator construction + * + * selects the appropriately-sized optimised version depending on sizeof(n) + */ +#define ilog2(n) \ +( \ + __builtin_constant_p(n) ? ( \ + (n) < 1 ? ____ilog2_NaN() : \ + (n) & (1ULL << 63) ? 63 : \ + (n) & (1ULL << 62) ? 62 : \ + (n) & (1ULL << 61) ? 61 : \ + (n) & (1ULL << 60) ? 60 : \ + (n) & (1ULL << 59) ? 59 : \ + (n) & (1ULL << 58) ? 58 : \ + (n) & (1ULL << 57) ? 57 : \ + (n) & (1ULL << 56) ? 56 : \ + (n) & (1ULL << 55) ? 55 : \ + (n) & (1ULL << 54) ? 54 : \ + (n) & (1ULL << 53) ? 53 : \ + (n) & (1ULL << 52) ? 52 : \ + (n) & (1ULL << 51) ? 51 : \ + (n) & (1ULL << 50) ? 50 : \ + (n) & (1ULL << 49) ? 49 : \ + (n) & (1ULL << 48) ? 48 : \ + (n) & (1ULL << 47) ? 47 : \ + (n) & (1ULL << 46) ? 46 : \ + (n) & (1ULL << 45) ? 45 : \ + (n) & (1ULL << 44) ? 44 : \ + (n) & (1ULL << 43) ? 43 : \ + (n) & (1ULL << 42) ? 42 : \ + (n) & (1ULL << 41) ? 41 : \ + (n) & (1ULL << 40) ? 40 : \ + (n) & (1ULL << 39) ? 39 : \ + (n) & (1ULL << 38) ? 38 : \ + (n) & (1ULL << 37) ? 37 : \ + (n) & (1ULL << 36) ? 36 : \ + (n) & (1ULL << 35) ? 35 : \ + (n) & (1ULL << 34) ? 34 : \ + (n) & (1ULL << 33) ? 33 : \ + (n) & (1ULL << 32) ? 32 : \ + (n) & (1ULL << 31) ? 31 : \ + (n) & (1ULL << 30) ? 30 : \ + (n) & (1ULL << 29) ? 29 : \ + (n) & (1ULL << 28) ? 28 : \ + (n) & (1ULL << 27) ? 27 : \ + (n) & (1ULL << 26) ? 26 : \ + (n) & (1ULL << 25) ? 25 : \ + (n) & (1ULL << 24) ? 24 : \ + (n) & (1ULL << 23) ? 23 : \ + (n) & (1ULL << 22) ? 22 : \ + (n) & (1ULL << 21) ? 21 : \ + (n) & (1ULL << 20) ? 20 : \ + (n) & (1ULL << 19) ? 19 : \ + (n) & (1ULL << 18) ? 18 : \ + (n) & (1ULL << 17) ? 17 : \ + (n) & (1ULL << 16) ? 16 : \ + (n) & (1ULL << 15) ? 15 : \ + (n) & (1ULL << 14) ? 14 : \ + (n) & (1ULL << 13) ? 13 : \ + (n) & (1ULL << 12) ? 12 : \ + (n) & (1ULL << 11) ? 11 : \ + (n) & (1ULL << 10) ? 10 : \ + (n) & (1ULL << 9) ? 9 : \ + (n) & (1ULL << 8) ? 8 : \ + (n) & (1ULL << 7) ? 7 : \ + (n) & (1ULL << 6) ? 6 : \ + (n) & (1ULL << 5) ? 5 : \ + (n) & (1ULL << 4) ? 4 : \ + (n) & (1ULL << 3) ? 3 : \ + (n) & (1ULL << 2) ? 2 : \ + (n) & (1ULL << 1) ? 1 : \ + (n) & (1ULL << 0) ? 0 : \ + ____ilog2_NaN() \ + ) : \ + (sizeof(n) <= 4) ? \ + __ilog2_u32(n) : \ + __ilog2_u64(n) \ + ) + +/** + * roundup_pow_of_two - round the given value up to nearest power of two + * @n - parameter + * + * round the given value up to the nearest power of two + * - the result is undefined when n == 0 + * - this can be used to initialise global variables from constant data + */ +#define roundup_pow_of_two(n) \ +( \ + __builtin_constant_p(n) ? ( \ + (n == 1) ? 1 : \ + (1UL << (ilog2((n) - 1) + 1)) \ + ) : \ + __roundup_pow_of_two(n) \ + ) + /* We need define two variables, argp_program_version_hook and argp_program_bug_address, in all programs. argp.h declares these variables as non-const (which is correct in general). But we can @@ -43,28 +267,56 @@ #define ARGP_PROGRAM_BUG_ADDRESS_DEF \ const char *const apba__ __asm ("argp_program_bug_address") +// Use a list_head so that we keep the original order when iterating in +// the strlist. + struct str_node { struct rb_node rb_node; + struct list_head node; const char *s; + void *priv; }; +// list_entries to keep the original order as passed, say, in the command line + struct strlist { struct rb_root entries; + struct list_head list_entries; bool dupstr; }; struct strlist *strlist__new(bool dupstr); -void strlist__delete(struct strlist *self); +void strlist__delete(struct strlist *slist); + +void strlist__remove(struct strlist *slist, struct str_node *sn); +int strlist__load(struct strlist *slist, const char *filename); +int strlist__add(struct strlist *slist, const char *str); +int __strlist__add(struct strlist *slist, const char *str, void *priv); -void strlist__remove(struct strlist *self, struct str_node *sn); -int strlist__load(struct strlist *self, const char *filename); -int strlist__add(struct strlist *self, const char *str); +bool strlist__has_entry(struct strlist *slist, const char *entry); -bool strlist__has_entry(struct strlist *self, const char *entry); +static inline bool strlist__empty(const struct strlist *slist) +{ + return rb_first(&slist->entries) == NULL; +} + +/** + * strlist__for_each_entry_safe - iterate thru all the strings safe against removal of list entry + * @slist: struct strlist instance to iterate + * @pos: struct str_node iterator + * @n: tmp struct str_node + */ +#define strlist__for_each_entry_safe(slist, pos, n) \ + list_for_each_entry_safe(pos, n, &(slist)->list_entries, node) -static inline bool strlist__empty(const struct strlist *self) +/** + * strstarts - does @str start with @prefix? + * @str: string to examine + * @prefix: prefix to look for. + */ +static inline bool strstarts(const char *str, const char *prefix) { - return rb_first(&self->entries) == NULL; + return strncmp(str, prefix, strlen(prefix)) == 0; } void *zalloc(const size_t size); @@ -72,6 +324,8 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, GElf_Shdr *shp, const char *name, size_t *index); +Elf_Scn *elf_section_by_idx(Elf *elf, GElf_Shdr *shp, int idx); + #ifndef SHT_GNU_ATTRIBUTES /* Just a way to check if we're using an old elfutils version */ static inline int elf_getshdrstrndx(Elf *elf, size_t *dst) @@ -80,4 +334,6 @@ } #endif +char *strlwr(char *s); + #endif /* _DUTIL_H_ */ diff -Nru dwarves-dfsg-1.10/dwarf_loader.c dwarves-dfsg-1.21/dwarf_loader.c --- dwarves-dfsg-1.10/dwarf_loader.c 2012-05-15 13:46:43.000000000 +0000 +++ dwarves-dfsg-1.21/dwarf_loader.c 2021-04-06 17:20:29.000000000 +0000 @@ -1,9 +1,7 @@ /* - Copyright (C) 2008 Arnaldo Carvalho de Melo + SPDX-License-Identifier: GPL-2.0-only - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. + Copyright (C) 2008 Arnaldo Carvalho de Melo */ #include @@ -25,11 +23,15 @@ #include "list.h" #include "dwarves.h" #include "dutil.h" -#include "strings.h" +#include "pahole_strings.h" #include "hash.h" struct strings *strings; +#ifndef DW_AT_alignment +#define DW_AT_alignment 0x88 +#endif + #ifndef DW_AT_GNU_vector #define DW_AT_GNU_vector 0x2107 #endif @@ -39,32 +41,37 @@ #define DW_TAG_GNU_call_site_parameter 0x410a #endif -#define hashtags__fn(key) hash_64(key, HASHTAGS__BITS) +#ifndef DW_TAG_call_site +#define DW_TAG_call_site 0x48 +#define DW_TAG_call_site_parameter 0x49 +#endif + +#ifndef DW_FORM_implicit_const +#define DW_FORM_implicit_const 0x21 +#endif + +static uint32_t hashtags__bits = 15; +static uint32_t max_hashtags__bits = 21; + +static uint32_t hashtags__fn(Dwarf_Off key) +{ + return hash_64(key, hashtags__bits); +} + +bool no_bitfield_type_recode = true; static void __tag__print_not_supported(uint32_t tag, const char *func) { -#ifdef STB_GNU_UNIQUE - static bool dwarf_tags_warned[DW_TAG_rvalue_reference_type]; - static bool dwarf_gnu_tags_warned[DW_TAG_GNU_formal_parameter_pack - DW_TAG_MIPS_loop]; -#else - static bool dwarf_tags_warned[DW_TAG_shared_type]; - static bool dwarf_gnu_tags_warned[DW_TAG_class_template - DW_TAG_MIPS_loop]; -#endif + static bool dwarf_tags_warned[DW_TAG_GNU_call_site_parameter + 64]; - if (tag < DW_TAG_MIPS_loop) { + if (tag < sizeof(dwarf_tags_warned)) { if (dwarf_tags_warned[tag]) return; dwarf_tags_warned[tag] = true; - } else { - uint32_t t = tag - DW_TAG_MIPS_loop; - - if (dwarf_gnu_tags_warned[t]) - return; - dwarf_gnu_tags_warned[t] = true; } - fprintf(stderr, "%s: tag not supported (%s)!\n", func, - dwarf_tag_name(tag)); + fprintf(stderr, "%s: tag not supported %#x (%s)!\n", func, + tag, dwarf_tag_name(tag)); } #define tag__print_not_supported(tag) \ @@ -86,30 +93,27 @@ dwarf_off_ref containing_type; }; struct tag *tag; + uint32_t small_id; strings_t decl_file; uint16_t decl_line; - uint16_t small_id; }; -static dwarf_off_ref dwarf_tag__spec(struct dwarf_tag *self) +static dwarf_off_ref dwarf_tag__spec(struct dwarf_tag *dtag) { - return *(dwarf_off_ref *)(self + 1); + return *(dwarf_off_ref *)(dtag + 1); } -static void dwarf_tag__set_spec(struct dwarf_tag *self, dwarf_off_ref spec) +static void dwarf_tag__set_spec(struct dwarf_tag *dtag, dwarf_off_ref spec) { - *(dwarf_off_ref *)(self + 1) = spec; + *(dwarf_off_ref *)(dtag + 1) = spec; } -#define HASHTAGS__BITS 8 -#define HASHTAGS__SIZE (1UL << HASHTAGS__BITS) - #define obstack_chunk_alloc malloc #define obstack_chunk_free free -static void *obstack_zalloc(struct obstack *self, size_t size) +static void *obstack_zalloc(struct obstack *obstack, size_t size) { - void *o = obstack_alloc(self, size); + void *o = obstack_alloc(obstack, size); if (o) memset(o, 0, size); @@ -117,22 +121,57 @@ } struct dwarf_cu { - struct hlist_head hash_tags[HASHTAGS__SIZE]; - struct hlist_head hash_types[HASHTAGS__SIZE]; + struct hlist_head *hash_tags; + struct hlist_head *hash_types; struct obstack obstack; struct cu *cu; struct dwarf_cu *type_unit; }; -static void dwarf_cu__init(struct dwarf_cu *self) +static int dwarf_cu__init(struct dwarf_cu *dcu) { + uint64_t hashtags_size = 1UL << hashtags__bits; + dcu->hash_tags = malloc(sizeof(struct hlist_head) * hashtags_size); + if (!dcu->hash_tags) + return -ENOMEM; + + dcu->hash_types = malloc(sizeof(struct hlist_head) * hashtags_size); + if (!dcu->hash_types) { + free(dcu->hash_tags); + return -ENOMEM; + } + unsigned int i; - for (i = 0; i < HASHTAGS__SIZE; ++i) { - INIT_HLIST_HEAD(&self->hash_tags[i]); - INIT_HLIST_HEAD(&self->hash_types[i]); + for (i = 0; i < hashtags_size; ++i) { + INIT_HLIST_HEAD(&dcu->hash_tags[i]); + INIT_HLIST_HEAD(&dcu->hash_types[i]); + } + obstack_init(&dcu->obstack); + dcu->type_unit = NULL; + return 0; +} + +static struct dwarf_cu *dwarf_cu__new(void) +{ + struct dwarf_cu *dwarf_cu = zalloc(sizeof(*dwarf_cu)); + + if (dwarf_cu != NULL && dwarf_cu__init(dwarf_cu) != 0) { + free(dwarf_cu); + dwarf_cu = NULL; } - obstack_init(&self->obstack); - self->type_unit = NULL; + + return dwarf_cu; +} + +static void dwarf_cu__delete(struct cu *cu) +{ + struct dwarf_cu *dcu = cu->priv; + free(dcu->hash_tags); + dcu->hash_tags = NULL; + free(dcu->hash_types); + dcu->hash_types = NULL; + free(dcu); + cu->priv = NULL; } static void hashtags__hash(struct hlist_head *hashtable, @@ -150,7 +189,7 @@ struct dwarf_tag *tpos; struct hlist_node *pos; - uint16_t bucket = hashtags__fn(id); + uint32_t bucket = hashtags__fn(id); const struct hlist_head *head = hashtable + bucket; hlist_for_each_entry(tpos, pos, head, hash_node) { @@ -161,38 +200,38 @@ return NULL; } -static void cu__hash(struct cu *self, struct tag *tag) +static void cu__hash(struct cu *cu, struct tag *tag) { - struct dwarf_cu *dcu = self->priv; + struct dwarf_cu *dcu = cu->priv; struct hlist_head *hashtable = tag__is_tag_type(tag) ? dcu->hash_types : dcu->hash_tags; hashtags__hash(hashtable, tag->priv); } -static struct dwarf_tag *dwarf_cu__find_tag_by_ref(const struct dwarf_cu *self, +static struct dwarf_tag *dwarf_cu__find_tag_by_ref(const struct dwarf_cu *cu, const struct dwarf_off_ref *ref) { - if (self == NULL) + if (cu == NULL) return NULL; if (ref->from_types) { return NULL; } - return hashtags__find(self->hash_tags, ref->off); + return hashtags__find(cu->hash_tags, ref->off); } -static struct dwarf_tag *dwarf_cu__find_type_by_ref(const struct dwarf_cu *self, +static struct dwarf_tag *dwarf_cu__find_type_by_ref(const struct dwarf_cu *dcu, const struct dwarf_off_ref *ref) { - if (self == NULL) + if (dcu == NULL) return NULL; if (ref->from_types) { - self = self->type_unit; - if (self == NULL) { + dcu = dcu->type_unit; + if (dcu == NULL) { return NULL; } } - return hashtags__find(self->hash_types, ref->off); + return hashtags__find(dcu->hash_types, ref->off); } extern struct strings *strings; @@ -256,6 +295,7 @@ return addr; } break; + case DW_FORM_implicit_const: case DW_FORM_data1: case DW_FORM_data2: case DW_FORM_data4: @@ -298,32 +338,41 @@ return UINT64_MAX; } -static Dwarf_Off attr_offset(Dwarf_Die *die, const uint32_t name) +static Dwarf_Off __attr_offset(Dwarf_Attribute *attr) { - Dwarf_Attribute attr; Dwarf_Block block; - if (dwarf_attr(die, name, &attr) == NULL) - return 0; - - switch (dwarf_whatform(&attr)) { + switch (dwarf_whatform(attr)) { + case DW_FORM_implicit_const: case DW_FORM_data1: case DW_FORM_data2: + case DW_FORM_data4: + case DW_FORM_data8: case DW_FORM_sdata: case DW_FORM_udata: { Dwarf_Word value; - if (dwarf_formudata(&attr, &value) == 0) + if (dwarf_formudata(attr, &value) == 0) return value; break; } default: - if (dwarf_formblock(&attr, &block) == 0) + if (dwarf_formblock(attr, &block) == 0) return dwarf_expr(block.data, block.length); } return 0; } +static Dwarf_Off attr_offset(Dwarf_Die *die, const uint32_t name) +{ + Dwarf_Attribute attr; + + if (dwarf_attr(die, name, &attr) == NULL) + return 0; + + return __attr_offset(&attr); +} + static const char *attr_string(Dwarf_Die *die, uint32_t name) { Dwarf_Attribute attr; @@ -352,8 +401,19 @@ { Dwarf_Attribute attr; if (dwarf_attr(die, DW_AT_location, &attr) != NULL) { - if (dwarf_getlocation(&attr, expr, exprlen) == 0) + if (dwarf_getlocation(&attr, expr, exprlen) == 0) { + /* DW_OP_addrx needs additional lookup for real addr. */ + if (*exprlen != 0 && expr[0]->atom == DW_OP_addrx) { + Dwarf_Attribute addr_attr; + dwarf_getlocation_attr(&attr, expr[0], &addr_attr); + + Dwarf_Addr address; + dwarf_formaddr (&addr_attr, &address); + + expr[0]->number = address; + } return 0; + } } return 1; @@ -367,17 +427,17 @@ if (dtag == NULL) return NULL; - struct tag *self = obstack_alloc(&dcu->cu->obstack, size); + struct tag *tag = obstack_zalloc(&dcu->cu->obstack, size); - if (self == NULL) + if (tag == NULL) return NULL; - dtag->tag = self; - self->priv = dtag; - self->type = 0; - self->top_level = 0; + dtag->tag = tag; + tag->priv = dtag; + tag->type = 0; + tag->top_level = 0; - return self; + return tag; } static void *tag__alloc(struct cu *cu, size_t size) @@ -390,22 +450,22 @@ return __tag__alloc(cu->priv, size, true); } -static void tag__init(struct tag *self, struct cu *cu, Dwarf_Die *die) +static void tag__init(struct tag *tag, struct cu *cu, Dwarf_Die *die) { - struct dwarf_tag *dtag = self->priv; + struct dwarf_tag *dtag = tag->priv; - self->tag = dwarf_tag(die); + tag->tag = dwarf_tag(die); dtag->id = dwarf_dieoffset(die); - if (self->tag == DW_TAG_imported_module || - self->tag == DW_TAG_imported_declaration) + if (tag->tag == DW_TAG_imported_module || + tag->tag == DW_TAG_imported_declaration) dtag->type = attr_type(die, DW_AT_import); else dtag->type = attr_type(die, DW_AT_type); dtag->abstract_origin = attr_type(die, DW_AT_abstract_origin); - self->recursivity_level = 0; + tag->recursivity_level = 0; if (cu->extra_dbg_info) { int32_t decl_line; @@ -423,183 +483,242 @@ dtag->decl_line = decl_line; } - INIT_LIST_HEAD(&self->node); + INIT_LIST_HEAD(&tag->node); } static struct tag *tag__new(Dwarf_Die *die, struct cu *cu) { - struct tag *self = tag__alloc(cu, sizeof(*self)); + struct tag *tag = tag__alloc(cu, sizeof(*tag)); - if (self != NULL) - tag__init(self, cu, die); + if (tag != NULL) + tag__init(tag, cu, die); - return self; + return tag; } static struct ptr_to_member_type *ptr_to_member_type__new(Dwarf_Die *die, struct cu *cu) { - struct ptr_to_member_type *self = tag__alloc(cu, sizeof(*self)); + struct ptr_to_member_type *ptr = tag__alloc(cu, sizeof(*ptr)); - if (self != NULL) { - tag__init(&self->tag, cu, die); - struct dwarf_tag *dself = self->tag.priv; - dself->containing_type = attr_type(die, DW_AT_containing_type); + if (ptr != NULL) { + tag__init(&ptr->tag, cu, die); + struct dwarf_tag *dtag = ptr->tag.priv; + dtag->containing_type = attr_type(die, DW_AT_containing_type); } - return self; + return ptr; +} + +static uint8_t encoding_to_float_type(uint64_t encoding) +{ + switch (encoding) { + case DW_ATE_complex_float: return BT_FP_CMPLX; + case DW_ATE_float: return BT_FP_SINGLE; + case DW_ATE_imaginary_float: return BT_FP_IMGRY; + default: return 0; + } } static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu) { - struct base_type *self = tag__alloc(cu, sizeof(*self)); + struct base_type *bt = tag__alloc(cu, sizeof(*bt)); - if (self != NULL) { - tag__init(&self->tag, cu, die); - self->name = strings__add(strings, attr_string(die, DW_AT_name)); - self->bit_size = attr_numeric(die, DW_AT_byte_size) * 8; + if (bt != NULL) { + tag__init(&bt->tag, cu, die); + bt->name = strings__add(strings, attr_string(die, DW_AT_name)); + bt->bit_size = attr_numeric(die, DW_AT_byte_size) * 8; uint64_t encoding = attr_numeric(die, DW_AT_encoding); - self->is_bool = encoding == DW_ATE_boolean; - self->is_signed = encoding == DW_ATE_signed; - self->is_varargs = false; - self->name_has_encoding = true; + bt->is_bool = encoding == DW_ATE_boolean; + bt->is_signed = encoding == DW_ATE_signed; + bt->is_varargs = false; + bt->name_has_encoding = true; + bt->float_type = encoding_to_float_type(encoding); } - return self; + return bt; } static struct array_type *array_type__new(Dwarf_Die *die, struct cu *cu) { - struct array_type *self = tag__alloc(cu, sizeof(*self)); + struct array_type *at = tag__alloc(cu, sizeof(*at)); + + if (at != NULL) { + tag__init(&at->tag, cu, die); + at->dimensions = 0; + at->nr_entries = NULL; + at->is_vector = dwarf_hasattr(die, DW_AT_GNU_vector); + } + + return at; +} + +static struct string_type *string_type__new(Dwarf_Die *die, struct cu *cu) +{ + struct string_type *st = tag__alloc(cu, sizeof(*st)); - if (self != NULL) { - tag__init(&self->tag, cu, die); - self->dimensions = 0; - self->nr_entries = NULL; - self->is_vector = dwarf_hasattr(die, DW_AT_GNU_vector); + if (st != NULL) { + tag__init(&st->tag, cu, die); + st->nr_entries = attr_numeric(die, DW_AT_byte_size); + if (st->nr_entries == 0) + st->nr_entries = 1; } - return self; + return st; } -static void namespace__init(struct namespace *self, Dwarf_Die *die, +static void namespace__init(struct namespace *namespace, Dwarf_Die *die, struct cu *cu) { - tag__init(&self->tag, cu, die); - INIT_LIST_HEAD(&self->tags); - self->sname = 0; - self->name = strings__add(strings, attr_string(die, DW_AT_name)); - self->nr_tags = 0; - self->shared_tags = 0; + tag__init(&namespace->tag, cu, die); + INIT_LIST_HEAD(&namespace->tags); + namespace->sname = 0; + namespace->name = strings__add(strings, attr_string(die, DW_AT_name)); + namespace->nr_tags = 0; + namespace->shared_tags = 0; } static struct namespace *namespace__new(Dwarf_Die *die, struct cu *cu) { - struct namespace *self = tag__alloc(cu, sizeof(*self)); + struct namespace *namespace = tag__alloc(cu, sizeof(*namespace)); - if (self != NULL) - namespace__init(self, die, cu); + if (namespace != NULL) + namespace__init(namespace, die, cu); - return self; + return namespace; } -static void type__init(struct type *self, Dwarf_Die *die, struct cu *cu) +static void type__init(struct type *type, Dwarf_Die *die, struct cu *cu) { - namespace__init(&self->namespace, die, cu); - INIT_LIST_HEAD(&self->node); - self->size = attr_numeric(die, DW_AT_byte_size); - self->declaration = attr_numeric(die, DW_AT_declaration); - dwarf_tag__set_spec(self->namespace.tag.priv, + namespace__init(&type->namespace, die, cu); + __type__init(type); + type->size = attr_numeric(die, DW_AT_byte_size); + type->alignment = attr_numeric(die, DW_AT_alignment); + type->declaration = attr_numeric(die, DW_AT_declaration); + dwarf_tag__set_spec(type->namespace.tag.priv, attr_type(die, DW_AT_specification)); - self->definition_emitted = 0; - self->fwd_decl_emitted = 0; - self->resized = 0; - self->nr_members = 0; + type->definition_emitted = 0; + type->fwd_decl_emitted = 0; + type->resized = 0; + type->nr_members = 0; + type->nr_static_members = 0; } static struct type *type__new(Dwarf_Die *die, struct cu *cu) { - struct type *self = tag__alloc_with_spec(cu, sizeof(*self)); + struct type *type = tag__alloc_with_spec(cu, sizeof(*type)); - if (self != NULL) - type__init(self, die, cu); + if (type != NULL) + type__init(type, die, cu); - return self; + return type; } static struct enumerator *enumerator__new(Dwarf_Die *die, struct cu *cu) { - struct enumerator *self = tag__alloc(cu, sizeof(*self)); + struct enumerator *enumerator = tag__alloc(cu, sizeof(*enumerator)); - if (self != NULL) { - tag__init(&self->tag, cu, die); - self->name = strings__add(strings, attr_string(die, DW_AT_name)); - self->value = attr_numeric(die, DW_AT_const_value); + if (enumerator != NULL) { + tag__init(&enumerator->tag, cu, die); + enumerator->name = strings__add(strings, attr_string(die, DW_AT_name)); + enumerator->value = attr_numeric(die, DW_AT_const_value); } - return self; + return enumerator; } -static enum vlocation dwarf__location(Dwarf_Die *die, uint64_t *addr) +static enum vscope dwarf__location(Dwarf_Die *die, uint64_t *addr, struct location *location) { - Dwarf_Op *expr; - size_t exprlen; - enum vlocation location = LOCATION_UNKNOWN; + enum vscope scope = VSCOPE_UNKNOWN; - if (attr_location(die, &expr, &exprlen) != 0) - location = LOCATION_OPTIMIZED; - else if (exprlen != 0) + if (attr_location(die, &location->expr, &location->exprlen) != 0) + scope = VSCOPE_OPTIMIZED; + else if (location->exprlen != 0) { + Dwarf_Op *expr = location->expr; switch (expr->atom) { case DW_OP_addr: - location = LOCATION_GLOBAL; + case DW_OP_addrx: + scope = VSCOPE_GLOBAL; *addr = expr[0].number; break; case DW_OP_reg1 ... DW_OP_reg31: case DW_OP_breg0 ... DW_OP_breg31: - location = LOCATION_REGISTER; break; + scope = VSCOPE_REGISTER; break; case DW_OP_fbreg: - location = LOCATION_LOCAL; break; + scope = VSCOPE_LOCAL; break; } + } - return location; + return scope; +} + +enum vscope variable__scope(const struct variable *var) +{ + return var->scope; +} + +const char *variable__scope_str(const struct variable *var) +{ + switch (var->scope) { + case VSCOPE_LOCAL: return "local"; + case VSCOPE_GLOBAL: return "global"; + case VSCOPE_REGISTER: return "register"; + case VSCOPE_OPTIMIZED: return "optimized"; + default: break; + }; + + return "unknown"; } static struct variable *variable__new(Dwarf_Die *die, struct cu *cu) { - struct variable *self = tag__alloc(cu, sizeof(*self)); + struct variable *var; + bool has_specification; + + has_specification = dwarf_hasattr(die, DW_AT_specification); + if (has_specification) { + var = tag__alloc_with_spec(cu, sizeof(*var)); + } else { + var = tag__alloc(cu, sizeof(*var)); + } - if (self != NULL) { - tag__init(&self->ip.tag, cu, die); - self->name = strings__add(strings, attr_string(die, DW_AT_name)); + if (var != NULL) { + tag__init(&var->ip.tag, cu, die); + var->name = strings__add(strings, attr_string(die, DW_AT_name)); /* variable is visible outside of its enclosing cu */ - self->external = dwarf_hasattr(die, DW_AT_external); + var->external = dwarf_hasattr(die, DW_AT_external); /* non-defining declaration of an object */ - self->declaration = dwarf_hasattr(die, DW_AT_declaration); - self->location = LOCATION_UNKNOWN; - self->ip.addr = 0; - if (!self->declaration && cu->has_addr_info) - self->location = dwarf__location(die, &self->ip.addr); + var->declaration = dwarf_hasattr(die, DW_AT_declaration); + var->scope = VSCOPE_UNKNOWN; + var->ip.addr = 0; + if (!var->declaration && cu->has_addr_info) + var->scope = dwarf__location(die, &var->ip.addr, &var->location); + if (has_specification) { + dwarf_tag__set_spec(var->ip.tag.priv, + attr_type(die, DW_AT_specification)); + } } - return self; + return var; } -int tag__recode_dwarf_bitfield(struct tag *self, struct cu *cu, uint16_t bit_size) +static int tag__recode_dwarf_bitfield(struct tag *tag, struct cu *cu, uint16_t bit_size) { - uint16_t id; + int id; + type_id_t short_id; struct tag *recoded; /* in all the cases the name is at the same offset */ - strings_t name = tag__namespace(self)->name; + strings_t name = tag__namespace(tag)->name; - switch (self->tag) { + switch (tag->tag) { case DW_TAG_typedef: { - const struct dwarf_tag *dself = self->priv; + const struct dwarf_tag *dtag = tag->priv; struct dwarf_tag *dtype = dwarf_cu__find_type_by_ref(cu->priv, - &dself->type); + &dtag->type); struct tag *type = dtype->tag; id = tag__recode_dwarf_bitfield(type, cu, bit_size); - if (id == self->type) + if (id < 0) return id; struct type *new_typedef = obstack_zalloc(&cu->obstack, @@ -610,19 +729,18 @@ recoded = (struct tag *)new_typedef; recoded->tag = DW_TAG_typedef; recoded->type = id; - new_typedef->namespace.name = tag__namespace(self)->name; + new_typedef->namespace.name = tag__namespace(tag)->name; } break; case DW_TAG_const_type: case DW_TAG_volatile_type: { - const struct dwarf_tag *dself = self->priv; - struct dwarf_tag *dtype = dwarf_cu__find_type_by_ref(cu->priv, - &dself->type); + const struct dwarf_tag *dtag = tag->priv; + struct dwarf_tag *dtype = dwarf_cu__find_type_by_ref(cu->priv, &dtag->type); struct tag *type = dtype->tag; id = tag__recode_dwarf_bitfield(type, cu, bit_size); - if (id == self->type) + if (id == tag->type) return id; recoded = obstack_zalloc(&cu->obstack, sizeof(*recoded)); @@ -640,10 +758,9 @@ * the dwarf_cu as in dwarf there are no such things * as base_types of less than 8 bits, etc. */ - recoded = cu__find_base_type_by_sname_and_size(cu, name, bit_size, &id); + recoded = cu__find_base_type_by_sname_and_size(cu, name, bit_size, &short_id); if (recoded != NULL) - return id; - + return short_id; struct base_type *new_bt = obstack_zalloc(&cu->obstack, sizeof(*new_bt)); @@ -663,12 +780,11 @@ * the dwarf_cu as in dwarf there are no such things * as enumeration_types of less than 8 bits, etc. */ - recoded = cu__find_enumeration_by_sname_and_size(cu, name, - bit_size, &id); + recoded = cu__find_enumeration_by_sname_and_size(cu, name, bit_size, &short_id); if (recoded != NULL) - return id; + return short_id; - struct type *alias = tag__type(self); + struct type *alias = tag__type(tag); struct type *new_enum = obstack_zalloc(&cu->obstack, sizeof(*new_enum)); if (new_enum == NULL) return -ENOMEM; @@ -687,12 +803,12 @@ break; default: fprintf(stderr, "%s: tag=%s, name=%s, bit_size=%d\n", - __func__, dwarf_tag_name(self->tag), + __func__, dwarf_tag_name(tag->tag), strings__ptr(strings, name), bit_size); return -EINVAL; } - long new_id = -1; + uint32_t new_id; if (cu__add_tag(cu, recoded, &new_id) == 0) return new_id; @@ -700,218 +816,253 @@ return -ENOMEM; } -int class_member__dwarf_recode_bitfield(struct class_member *self, +int class_member__dwarf_recode_bitfield(struct class_member *member, struct cu *cu) { - struct dwarf_tag *dtag = self->tag.priv; + struct dwarf_tag *dtag = member->tag.priv; struct dwarf_tag *type = dwarf_cu__find_type_by_ref(cu->priv, &dtag->type); - int recoded_type_id = tag__recode_dwarf_bitfield(type->tag, cu, - self->bitfield_size); + int recoded_type_id; + + if (type == NULL) + return -ENOENT; + + recoded_type_id = tag__recode_dwarf_bitfield(type->tag, cu, member->bitfield_size); if (recoded_type_id < 0) return recoded_type_id; - self->tag.type = recoded_type_id; + member->tag.type = recoded_type_id; return 0; } -static struct class_member *class_member__new(Dwarf_Die *die, struct cu *cu) +static struct class_member *class_member__new(Dwarf_Die *die, struct cu *cu, + bool in_union) { - struct class_member *self = tag__alloc(cu, sizeof(*self)); + struct class_member *member = tag__alloc(cu, sizeof(*member)); + + if (member != NULL) { + tag__init(&member->tag, cu, die); + member->name = strings__add(strings, attr_string(die, DW_AT_name)); + member->const_value = attr_numeric(die, DW_AT_const_value); + member->alignment = attr_numeric(die, DW_AT_alignment); + + Dwarf_Attribute attr; + + member->has_bit_offset = dwarf_attr(die, DW_AT_data_bit_offset, &attr) != NULL; + + if (member->has_bit_offset) { + member->bit_offset = __attr_offset(&attr); + // byte_offset and bitfield_offset will be recalculated later, when + // we discover the size of this bitfield base type. + } else { + if (dwarf_attr(die, DW_AT_data_member_location, &attr) != NULL) { + member->byte_offset = __attr_offset(&attr); + } else { + member->is_static = !in_union; + } + + /* + * Bit offset calculated here is valid only for byte-aligned + * fields. For bitfields on little-endian archs we need to + * adjust them taking into account byte size of the field, + * which might not be yet known. So we'll re-calculate bit + * offset later, in class_member__cache_byte_size. + */ + member->bit_offset = member->byte_offset * 8; + member->bitfield_offset = attr_numeric(die, DW_AT_bit_offset); + } - if (self != NULL) { - tag__init(&self->tag, cu, die); - self->name = strings__add(strings, attr_string(die, DW_AT_name)); - self->byte_offset = attr_offset(die, DW_AT_data_member_location); /* - * Will be cached later, in class_member__cache_byte_size + * If DW_AT_byte_size is not present, byte size will be + * determined later in class_member__cache_byte_size using + * base integer/enum type */ - self->byte_size = 0; - self->bitfield_offset = attr_numeric(die, DW_AT_bit_offset); - self->bitfield_size = attr_numeric(die, DW_AT_bit_size); - self->bit_offset = self->byte_offset * 8 + self->bitfield_offset; - self->bit_hole = 0; - self->bitfield_end = 0; - self->visited = 0; - self->accessibility = attr_numeric(die, DW_AT_accessibility); - self->virtuality = attr_numeric(die, DW_AT_virtuality); - self->hole = 0; + member->byte_size = attr_numeric(die, DW_AT_byte_size); + member->bitfield_size = attr_numeric(die, DW_AT_bit_size); + member->bit_hole = 0; + member->bitfield_end = 0; + member->visited = 0; + member->accessibility = attr_numeric(die, DW_AT_accessibility); + member->virtuality = attr_numeric(die, DW_AT_virtuality); + member->hole = 0; } - return self; + return member; } static struct parameter *parameter__new(Dwarf_Die *die, struct cu *cu) { - struct parameter *self = tag__alloc(cu, sizeof(*self)); + struct parameter *parm = tag__alloc(cu, sizeof(*parm)); - if (self != NULL) { - tag__init(&self->tag, cu, die); - self->name = strings__add(strings, attr_string(die, DW_AT_name)); + if (parm != NULL) { + tag__init(&parm->tag, cu, die); + parm->name = strings__add(strings, attr_string(die, DW_AT_name)); } - return self; + return parm; } static struct inline_expansion *inline_expansion__new(Dwarf_Die *die, struct cu *cu) { - struct inline_expansion *self = tag__alloc(cu, sizeof(*self)); + struct inline_expansion *exp = tag__alloc(cu, sizeof(*exp)); - if (self != NULL) { - struct dwarf_tag *dtag = self->ip.tag.priv; + if (exp != NULL) { + struct dwarf_tag *dtag = exp->ip.tag.priv; - tag__init(&self->ip.tag, cu, die); + tag__init(&exp->ip.tag, cu, die); dtag->decl_file = strings__add(strings, attr_string(die, DW_AT_call_file)); dtag->decl_line = attr_numeric(die, DW_AT_call_line); dtag->type = attr_type(die, DW_AT_abstract_origin); - self->ip.addr = 0; - self->high_pc = 0; + exp->ip.addr = 0; + exp->high_pc = 0; if (!cu->has_addr_info) goto out; - if (dwarf_lowpc(die, &self->ip.addr)) - self->ip.addr = 0; - if (dwarf_lowpc(die, &self->high_pc)) - self->high_pc = 0; + if (dwarf_lowpc(die, &exp->ip.addr)) + exp->ip.addr = 0; + if (dwarf_lowpc(die, &exp->high_pc)) + exp->high_pc = 0; - self->size = self->high_pc - self->ip.addr; - if (self->size == 0) { + exp->size = exp->high_pc - exp->ip.addr; + if (exp->size == 0) { Dwarf_Addr base, start; ptrdiff_t offset = 0; while (1) { offset = dwarf_ranges(die, offset, &base, &start, - &self->high_pc); + &exp->high_pc); start = (unsigned long)start; - self->high_pc = (unsigned long)self->high_pc; + exp->high_pc = (unsigned long)exp->high_pc; if (offset <= 0) break; - self->size += self->high_pc - start; - if (self->ip.addr == 0) - self->ip.addr = start; + exp->size += exp->high_pc - start; + if (exp->ip.addr == 0) + exp->ip.addr = start; } } } out: - return self; + return exp; } static struct label *label__new(Dwarf_Die *die, struct cu *cu) { - struct label *self = tag__alloc(cu, sizeof(*self)); + struct label *label = tag__alloc(cu, sizeof(*label)); - if (self != NULL) { - tag__init(&self->ip.tag, cu, die); - self->name = strings__add(strings, attr_string(die, DW_AT_name)); - if (!cu->has_addr_info || dwarf_lowpc(die, &self->ip.addr)) - self->ip.addr = 0; + if (label != NULL) { + tag__init(&label->ip.tag, cu, die); + label->name = strings__add(strings, attr_string(die, DW_AT_name)); + if (!cu->has_addr_info || dwarf_lowpc(die, &label->ip.addr)) + label->ip.addr = 0; } - return self; + return label; } static struct class *class__new(Dwarf_Die *die, struct cu *cu) { - struct class *self = tag__alloc_with_spec(cu, sizeof(*self)); + struct class *class = tag__alloc_with_spec(cu, sizeof(*class)); - if (self != NULL) { - type__init(&self->type, die, cu); - INIT_LIST_HEAD(&self->vtable); - self->nr_vtable_entries = - self->nr_holes = - self->nr_bit_holes = - self->padding = - self->bit_padding = 0; - self->priv = NULL; + if (class != NULL) { + type__init(&class->type, die, cu); + INIT_LIST_HEAD(&class->vtable); + class->nr_vtable_entries = + class->nr_holes = + class->nr_bit_holes = + class->padding = + class->bit_padding = 0; + class->priv = NULL; } - return self; + return class; } -static void lexblock__init(struct lexblock *self, struct cu *cu, +static void lexblock__init(struct lexblock *block, struct cu *cu, Dwarf_Die *die) { Dwarf_Off high_pc; - if (!cu->has_addr_info || dwarf_lowpc(die, &self->ip.addr)) { - self->ip.addr = 0; - self->size = 0; + if (!cu->has_addr_info || dwarf_lowpc(die, &block->ip.addr)) { + block->ip.addr = 0; + block->size = 0; } else if (dwarf_highpc(die, &high_pc)) - self->size = 0; + block->size = 0; else - self->size = high_pc - self->ip.addr; + block->size = high_pc - block->ip.addr; - INIT_LIST_HEAD(&self->tags); + INIT_LIST_HEAD(&block->tags); - self->size_inline_expansions = - self->nr_inline_expansions = - self->nr_labels = - self->nr_lexblocks = - self->nr_variables = 0; + block->size_inline_expansions = + block->nr_inline_expansions = + block->nr_labels = + block->nr_lexblocks = + block->nr_variables = 0; } static struct lexblock *lexblock__new(Dwarf_Die *die, struct cu *cu) { - struct lexblock *self = tag__alloc(cu, sizeof(*self)); + struct lexblock *block = tag__alloc(cu, sizeof(*block)); - if (self != NULL) { - tag__init(&self->ip.tag, cu, die); - lexblock__init(self, cu, die); + if (block != NULL) { + tag__init(&block->ip.tag, cu, die); + lexblock__init(block, cu, die); } - return self; + return block; } -static void ftype__init(struct ftype *self, Dwarf_Die *die, struct cu *cu) +static void ftype__init(struct ftype *ftype, Dwarf_Die *die, struct cu *cu) { +#ifndef NDEBUG const uint16_t tag = dwarf_tag(die); assert(tag == DW_TAG_subprogram || tag == DW_TAG_subroutine_type); - - tag__init(&self->tag, cu, die); - INIT_LIST_HEAD(&self->parms); - self->nr_parms = 0; - self->unspec_parms = 0; +#endif + tag__init(&ftype->tag, cu, die); + INIT_LIST_HEAD(&ftype->parms); + ftype->nr_parms = 0; + ftype->unspec_parms = 0; } static struct ftype *ftype__new(Dwarf_Die *die, struct cu *cu) { - struct ftype *self = tag__alloc(cu, sizeof(*self)); + struct ftype *ftype = tag__alloc(cu, sizeof(*ftype)); - if (self != NULL) - ftype__init(self, die, cu); + if (ftype != NULL) + ftype__init(ftype, die, cu); - return self; + return ftype; } static struct function *function__new(Dwarf_Die *die, struct cu *cu) { - struct function *self = tag__alloc_with_spec(cu, sizeof(*self)); + struct function *func = tag__alloc_with_spec(cu, sizeof(*func)); - if (self != NULL) { - ftype__init(&self->proto, die, cu); - lexblock__init(&self->lexblock, cu, die); - self->name = strings__add(strings, attr_string(die, DW_AT_name)); - self->linkage_name = strings__add(strings, attr_string(die, DW_AT_MIPS_linkage_name)); - self->inlined = attr_numeric(die, DW_AT_inline); - self->external = dwarf_hasattr(die, DW_AT_external); - self->abstract_origin = dwarf_hasattr(die, DW_AT_abstract_origin); - dwarf_tag__set_spec(self->proto.tag.priv, + if (func != NULL) { + ftype__init(&func->proto, die, cu); + lexblock__init(&func->lexblock, cu, die); + func->name = strings__add(strings, attr_string(die, DW_AT_name)); + func->linkage_name = strings__add(strings, attr_string(die, DW_AT_MIPS_linkage_name)); + func->inlined = attr_numeric(die, DW_AT_inline); + func->declaration = dwarf_hasattr(die, DW_AT_declaration); + func->external = dwarf_hasattr(die, DW_AT_external); + func->abstract_origin = dwarf_hasattr(die, DW_AT_abstract_origin); + dwarf_tag__set_spec(func->proto.tag.priv, attr_type(die, DW_AT_specification)); - self->accessibility = attr_numeric(die, DW_AT_accessibility); - self->virtuality = attr_numeric(die, DW_AT_virtuality); - INIT_LIST_HEAD(&self->vtable_node); - INIT_LIST_HEAD(&self->tool_node); - self->vtable_entry = -1; + func->accessibility = attr_numeric(die, DW_AT_accessibility); + func->virtuality = attr_numeric(die, DW_AT_virtuality); + INIT_LIST_HEAD(&func->vtable_node); + INIT_LIST_HEAD(&func->tool_node); + func->vtable_entry = -1; if (dwarf_hasattr(die, DW_AT_vtable_elem_location)) - self->vtable_entry = attr_offset(die, DW_AT_vtable_elem_location); - self->cu_total_size_inline_expansions = 0; - self->cu_total_nr_inline_expansions = 0; - self->priv = NULL; + func->vtable_entry = attr_offset(die, DW_AT_vtable_elem_location); + func->cu_total_size_inline_expansions = 0; + func->cu_total_nr_inline_expansions = 0; + func->priv = NULL; } - return self; + return func; } static uint64_t attr_upper_bound(Dwarf_Die *die) @@ -924,6 +1075,12 @@ if (dwarf_formudata(&attr, &num) == 0) { return (uintmax_t)num + 1; } + } else if (dwarf_attr(die, DW_AT_count, &attr) != NULL) { + Dwarf_Word num; + + if (dwarf_formudata(&attr, &num) == 0) { + return (uintmax_t)num; + } } return 0; @@ -938,6 +1095,8 @@ (unsigned long long)dwarf_dieoffset(die)); } +static struct tag unsupported_tag; + #define cu__tag_not_handled(die) __cu__tag_not_handled(die, __FUNCTION__) static struct tag *__die__process_tag(Dwarf_Die *die, struct cu *cu, @@ -948,23 +1107,23 @@ static struct tag *die__create_new_tag(Dwarf_Die *die, struct cu *cu) { - struct tag *self = tag__new(die, cu); + struct tag *tag = tag__new(die, cu); - if (self != NULL) { + if (tag != NULL) { if (dwarf_haschildren(die)) fprintf(stderr, "%s: %s WITH children!\n", __func__, - dwarf_tag_name(self->tag)); + dwarf_tag_name(tag->tag)); } - return self; + return tag; } static struct tag *die__create_new_ptr_to_member_type(Dwarf_Die *die, struct cu *cu) { - struct ptr_to_member_type *self = ptr_to_member_type__new(die, cu); + struct ptr_to_member_type *ptr = ptr_to_member_type__new(die, cu); - return self ? &self->tag : NULL; + return ptr ? &ptr->tag : NULL; } static int die__process_class(Dwarf_Die *die, @@ -1093,6 +1252,16 @@ return NULL; } +static struct tag *die__create_new_string_type(Dwarf_Die *die, struct cu *cu) +{ + struct string_type *string = string_type__new(die, cu); + + if (string == NULL) + return NULL; + + return &string->tag; +} + static struct tag *die__create_new_parameter(Dwarf_Die *die, struct ftype *ftype, struct lexblock *lexblock, @@ -1156,9 +1325,12 @@ die = &child; do { - long id = -1; + uint32_t id; switch (dwarf_tag(die)) { + case DW_TAG_subrange_type: // ADA stuff + tag__print_not_supported(dwarf_tag(die)); + continue; case DW_TAG_formal_parameter: tag = die__create_new_parameter(die, ftype, NULL, cu); break; @@ -1170,6 +1342,11 @@ if (tag == NULL) goto out_delete; + if (tag == &unsupported_tag) { + tag__print_not_supported(dwarf_tag(die)); + continue; + } + if (cu__add_tag(cu, tag, &id) < 0) goto out_delete_tag; @@ -1238,27 +1415,37 @@ static int die__process_class(Dwarf_Die *die, struct type *class, struct cu *cu) { + const bool is_union = tag__is_union(&class->namespace.tag); + do { switch (dwarf_tag(die)) { + case DW_TAG_subrange_type: // XXX: ADA stuff, its a type tho, will have other entries referencing it... + case DW_TAG_variant_part: // XXX: Rust stuff #ifdef STB_GNU_UNIQUE - case DW_TAG_GNU_template_template_param: + case DW_TAG_GNU_formal_parameter_pack: case DW_TAG_GNU_template_parameter_pack: + case DW_TAG_GNU_template_template_param: #endif case DW_TAG_template_type_parameter: case DW_TAG_template_value_parameter: - /* FIXME: probably we'll have to attach this as a list of - * template parameters to use at class__fprintf time... */ + /* + * FIXME: probably we'll have to attach this as a list of + * template parameters to use at class__fprintf time... + * + * See: + * https://gcc.gnu.org/wiki/TemplateParmsDwarf + */ tag__print_not_supported(dwarf_tag(die)); continue; case DW_TAG_inheritance: case DW_TAG_member: { - struct class_member *member = class_member__new(die, cu); + struct class_member *member = class_member__new(die, cu, is_union); if (member == NULL) return -ENOMEM; if (cu__is_c_plus_plus(cu)) { - long id = -1; + uint32_t id; if (cu__table_add_tag(cu, &member->tag, &id) < 0) { class_member__delete(member, cu); @@ -1279,7 +1466,12 @@ if (tag == NULL) return -ENOMEM; - long id = -1; + if (tag == &unsupported_tag) { + tag__print_not_supported(dwarf_tag(die)); + continue; + } + + uint32_t id; if (cu__table_add_tag(cu, tag, &id) < 0) { tag__delete(tag, cu); @@ -1314,7 +1506,12 @@ if (tag == NULL) goto out_enomem; - long id = -1; + if (tag == &unsupported_tag) { + tag__print_not_supported(dwarf_tag(die)); + continue; + } + + uint32_t id; if (cu__table_add_tag(cu, tag, &id) < 0) goto out_delete_tag; @@ -1356,7 +1553,7 @@ struct lexblock *lexblock, struct cu *cu); -static int die__process_inline_expansion(Dwarf_Die *die, struct cu *cu) +static int die__process_inline_expansion(Dwarf_Die *die, struct lexblock *lexblock, struct cu *cu) { Dwarf_Die child; struct tag *tag; @@ -1366,19 +1563,25 @@ die = &child; do { - long id = -1; + uint32_t id; switch (dwarf_tag(die)) { + case DW_TAG_call_site: + case DW_TAG_call_site_parameter: case DW_TAG_GNU_call_site: case DW_TAG_GNU_call_site_parameter: /* * FIXME: read http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open * and write proper support. - */ - tag__print_not_supported(dwarf_tag(die)); + * + * From a quick read there is not much we can use in + * the existing dwarves tools, so just stop warning the user, + * developers will find these notes if wanting to use in a + * new tool. + */ continue; case DW_TAG_lexical_block: - if (die__create_new_lexblock(die, cu, NULL) != 0) + if (die__create_new_lexblock(die, cu, lexblock) != 0) goto out_enomem; continue; case DW_TAG_formal_parameter: @@ -1395,13 +1598,21 @@ */ continue; case DW_TAG_inlined_subroutine: - tag = die__create_new_inline_expansion(die, NULL, cu); + tag = die__create_new_inline_expansion(die, lexblock, cu); + break; + case DW_TAG_label: + tag = die__create_new_label(die, lexblock, cu); break; default: tag = die__process_tag(die, cu, 0); if (tag == NULL) goto out_enomem; + if (tag == &unsupported_tag) { + tag__print_not_supported(dwarf_tag(die)); + continue; + } + if (cu__add_tag(cu, tag, &id) < 0) goto out_delete_tag; goto hash; @@ -1434,7 +1645,7 @@ if (exp == NULL) return NULL; - if (die__process_inline_expansion(die, cu) != 0) { + if (die__process_inline_expansion(die, lexblock, cu) != 0) { obstack_free(&cu->obstack, exp); return NULL; } @@ -1455,17 +1666,33 @@ die = &child; do { - long id = -1; + uint32_t id; switch (dwarf_tag(die)) { + case DW_TAG_call_site: + case DW_TAG_call_site_parameter: case DW_TAG_GNU_call_site: case DW_TAG_GNU_call_site_parameter: /* - * FIXME: read http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open - * and write proper support. - */ - tag__print_not_supported(dwarf_tag(die)); + * XXX: read http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open + * and write proper support. + * + * From a quick read there is not much we can use in + * the existing dwarves tools, so just stop warning the user, + * developers will find these notes if wanting to use in a + * new tool. + */ + continue; + case DW_TAG_dwarf_procedure: + /* + * Ignore it, just scope expressions, that we have no use for (so far). + */ continue; +#ifdef STB_GNU_UNIQUE + case DW_TAG_GNU_formal_parameter_pack: + case DW_TAG_GNU_template_parameter_pack: + case DW_TAG_GNU_template_template_param: +#endif case DW_TAG_template_type_parameter: case DW_TAG_template_value_parameter: /* FIXME: probably we'll have to attach this as a list of @@ -1498,9 +1725,15 @@ continue; default: tag = die__process_tag(die, cu, 0); + if (tag == NULL) goto out_enomem; + if (tag == &unsupported_tag) { + tag__print_not_supported(dwarf_tag(die)); + continue; + } + if (cu__add_tag(cu, tag, &id) < 0) goto out_delete_tag; @@ -1545,8 +1778,12 @@ struct tag *tag; switch (dwarf_tag(die)) { + case DW_TAG_imported_unit: + return NULL; // We don't support imported units yet, so to avoid segfaults case DW_TAG_array_type: tag = die__create_new_array(die, cu); break; + case DW_TAG_string_type: // FORTRAN stuff, looks like an array + tag = die__create_new_string_type(die, cu); break; case DW_TAG_base_type: tag = die__create_new_base_type(die, cu); break; case DW_TAG_const_type: @@ -1554,6 +1791,8 @@ case DW_TAG_imported_module: case DW_TAG_pointer_type: case DW_TAG_reference_type: + case DW_TAG_restrict_type: + case DW_TAG_unspecified_type: case DW_TAG_volatile_type: tag = die__create_new_tag(die, cu); break; case DW_TAG_ptr_to_member_type: @@ -1570,6 +1809,7 @@ tag = die__create_new_function(die, cu); break; case DW_TAG_subroutine_type: tag = die__create_new_subroutine_type(die, cu); break; + case DW_TAG_rvalue_reference_type: case DW_TAG_typedef: tag = die__create_new_typedef(die, cu); break; case DW_TAG_union_type: @@ -1578,7 +1818,12 @@ tag = die__create_new_variable(die, cu); break; default: __cu__tag_not_handled(die, fn); - tag = NULL; + /* fall thru */ + case DW_TAG_dwarf_procedure: + /* + * Ignore it, just scope expressions, that we have no use for (so far). + */ + tag = &unsupported_tag; break; } @@ -1595,7 +1840,15 @@ if (tag == NULL) return -ENOMEM; - long id = -1; + if (tag == &unsupported_tag) { + // XXX special case DW_TAG_dwarf_procedure, appears when looking at a recent ~/bin/perf + // Investigate later how to properly support this... + if (dwarf_tag(die) != DW_TAG_dwarf_procedure) + tag__print_not_supported(dwarf_tag(die)); + continue; + } + + uint32_t id; cu__add_tag(cu, tag, &id); cu__hash(cu, tag); struct dwarf_tag *dtag = tag->priv; @@ -1605,24 +1858,24 @@ return 0; } -static void __tag__print_type_not_found(struct tag *self, const char *func) +static void __tag__print_type_not_found(struct tag *tag, const char *func) { - struct dwarf_tag *dtag = self->priv; + struct dwarf_tag *dtag = tag->priv; fprintf(stderr, "%s: couldn't find %#llx type for %#llx (%s)!\n", func, (unsigned long long)dtag->type.off, (unsigned long long)dtag->id, - dwarf_tag_name(self->tag)); + dwarf_tag_name(tag->tag)); } -#define tag__print_type_not_found(self) \ - __tag__print_type_not_found(self, __func__) +#define tag__print_type_not_found(tag) \ + __tag__print_type_not_found(tag, __func__) -static void ftype__recode_dwarf_types(struct tag *self, struct cu *cu); +static void ftype__recode_dwarf_types(struct tag *tag, struct cu *cu); -static int namespace__recode_dwarf_types(struct tag *self, struct cu *cu) +static int namespace__recode_dwarf_types(struct tag *tag, struct cu *cu) { struct tag *pos; struct dwarf_cu *dcu = cu->priv; - struct namespace *ns = tag__namespace(self); + struct namespace *ns = tag__namespace(tag); namespace__for_each_tag(ns, pos) { struct dwarf_tag *dtype; @@ -1641,7 +1894,7 @@ * We may need to recode the type, possibly creating a * suitably sized new base_type */ - if (member->bitfield_size != 0) { + if (member->bitfield_size != 0 && !no_bitfield_type_recode) { if (class_member__dwarf_recode_bitfield(member, cu)) return -1; continue; @@ -1678,11 +1931,11 @@ return 0; } -static void type__recode_dwarf_specification(struct tag *self, struct cu *cu) +static void type__recode_dwarf_specification(struct tag *tag, struct cu *cu) { struct dwarf_tag *dtype; - struct type *t = tag__type(self); - dwarf_off_ref specification = dwarf_tag__spec(self->priv); + struct type *t = tag__type(tag); + dwarf_off_ref specification = dwarf_tag__spec(tag->priv); if (t->namespace.name != 0 || specification.off == 0) return; @@ -1691,7 +1944,7 @@ if (dtype != NULL) t->namespace.name = tag__namespace(dtype->tag)->name; else { - struct dwarf_tag *dtag = self->priv; + struct dwarf_tag *dtag = tag->priv; fprintf(stderr, "%s: couldn't find name for " @@ -1701,25 +1954,25 @@ } } -static void __tag__print_abstract_origin_not_found(struct tag *self, +static void __tag__print_abstract_origin_not_found(struct tag *tag, const char *func) { - struct dwarf_tag *dtag = self->priv; + struct dwarf_tag *dtag = tag->priv; fprintf(stderr, "%s: couldn't find %#llx abstract_origin for %#llx (%s)!\n", func, (unsigned long long)dtag->abstract_origin.off, (unsigned long long)dtag->id, - dwarf_tag_name(self->tag)); + dwarf_tag_name(tag->tag)); } -#define tag__print_abstract_origin_not_found(self ) \ - __tag__print_abstract_origin_not_found(self, __func__) +#define tag__print_abstract_origin_not_found(tag ) \ + __tag__print_abstract_origin_not_found(tag, __func__) -static void ftype__recode_dwarf_types(struct tag *self, struct cu *cu) +static void ftype__recode_dwarf_types(struct tag *tag, struct cu *cu) { struct parameter *pos; struct dwarf_cu *dcu = cu->priv; - struct ftype *type = tag__ftype(self); + struct ftype *type = tag__ftype(tag); ftype__for_each_parameter(type, pos) { struct dwarf_tag *dpos = pos->tag.priv; @@ -1750,12 +2003,12 @@ } } -static void lexblock__recode_dwarf_types(struct lexblock *self, struct cu *cu) +static void lexblock__recode_dwarf_types(struct lexblock *tag, struct cu *cu) { struct tag *pos; struct dwarf_cu *dcu = cu->priv; - list_for_each_entry(pos, &self->tags, node) { + list_for_each_entry(pos, &tag->tags, node) { struct dwarf_tag *dpos = pos->priv; struct dwarf_tag *dtype; @@ -1836,24 +2089,24 @@ } } -static int tag__recode_dwarf_type(struct tag *self, struct cu *cu) +static int tag__recode_dwarf_type(struct tag *tag, struct cu *cu) { - struct dwarf_tag *dtag = self->priv; + struct dwarf_tag *dtag = tag->priv; struct dwarf_tag *dtype; /* Check if this is an already recoded bitfield */ if (dtag == NULL) return 0; - if (tag__is_type(self)) - type__recode_dwarf_specification(self, cu); + if (tag__is_type(tag)) + type__recode_dwarf_specification(tag, cu); - if (tag__has_namespace(self)) - return namespace__recode_dwarf_types(self, cu); + if (tag__has_namespace(tag)) + return namespace__recode_dwarf_types(tag, cu); - switch (self->tag) { + switch (tag->tag) { case DW_TAG_subprogram: { - struct function *fn = tag__function(self); + struct function *fn = tag__function(tag); if (fn->name == 0) { dwarf_off_ref specification = dwarf_tag__spec(dtag); @@ -1886,16 +2139,16 @@ /* Fall thru */ case DW_TAG_subroutine_type: - ftype__recode_dwarf_types(self, cu); + ftype__recode_dwarf_types(tag, cu); /* Fall thru, for the function return type */ break; case DW_TAG_lexical_block: - lexblock__recode_dwarf_types(tag__lexblock(self), cu); + lexblock__recode_dwarf_types(tag__lexblock(tag), cu); return 0; case DW_TAG_ptr_to_member_type: { - struct ptr_to_member_type *pt = tag__ptr_to_member_type(self); + struct ptr_to_member_type *pt = tag__ptr_to_member_type(tag); dtype = dwarf_cu__find_type_by_ref(cu->priv, &dtag->containing_type); if (dtype != NULL) @@ -1912,7 +2165,7 @@ break; case DW_TAG_namespace: - return namespace__recode_dwarf_types(self, cu); + return namespace__recode_dwarf_types(tag, cu); /* Damn, DW_TAG_inlined_subroutine is an special case as dwarf_tag->id is in fact an abtract origin, i.e. must be looked up in the tags_table, not in the types_table. @@ -1927,10 +2180,21 @@ if (dtype != NULL) goto out; goto find_type; + case DW_TAG_variable: { + struct variable *var = tag__variable(tag); + dwarf_off_ref specification = dwarf_tag__spec(dtag); + + if (specification.off) { + dtype = dwarf_cu__find_tag_by_ref(cu->priv, &specification); + if (dtype) + var->spec = tag__variable(dtype->tag); + } + } + } if (dtag->type.off == 0) { - self->type = 0; /* void */ + tag->type = 0; /* void */ return 0; } @@ -1938,15 +2202,43 @@ dtype = dwarf_cu__find_type_by_ref(cu->priv, &dtag->type); check_type: if (dtype == NULL) { - tag__print_type_not_found(self); + tag__print_type_not_found(tag); return 0; } out: - self->type = dtype->small_id; + tag->type = dtype->small_id; return 0; } -static int cu__recode_dwarf_types_table(struct cu *self, +static int cu__resolve_func_ret_types(struct cu *cu) +{ + struct ptr_table *pt = &cu->functions_table; + uint32_t i; + + for (i = 0; i < pt->nr_entries; ++i) { + struct tag *tag = pt->entries[i]; + + if (tag == NULL || tag->type != 0) + continue; + + struct function *fn = tag__function(tag); + if (!fn->abstract_origin) + continue; + + struct dwarf_tag *dtag = tag->priv; + struct dwarf_tag *dfunc; + dfunc = dwarf_cu__find_tag_by_ref(cu->priv, &dtag->abstract_origin); + if (dfunc == NULL) { + tag__print_abstract_origin_not_found(tag); + return -1; + } + + tag->type = dfunc->tag->type; + } + return 0; +} + +static int cu__recode_dwarf_types_table(struct cu *cu, struct ptr_table *pt, uint32_t i) { @@ -1954,47 +2246,47 @@ struct tag *tag = pt->entries[i]; if (tag != NULL) /* void, see cu__new */ - if (tag__recode_dwarf_type(tag, self)) + if (tag__recode_dwarf_type(tag, cu)) return -1; } return 0; } -static int cu__recode_dwarf_types(struct cu *self) +static int cu__recode_dwarf_types(struct cu *cu) { - if (cu__recode_dwarf_types_table(self, &self->types_table, 1) || - cu__recode_dwarf_types_table(self, &self->tags_table, 0) || - cu__recode_dwarf_types_table(self, &self->functions_table, 0)) + if (cu__recode_dwarf_types_table(cu, &cu->types_table, 1) || + cu__recode_dwarf_types_table(cu, &cu->tags_table, 0) || + cu__recode_dwarf_types_table(cu, &cu->functions_table, 0)) return -1; return 0; } -static const char *dwarf_tag__decl_file(const struct tag *self, +static const char *dwarf_tag__decl_file(const struct tag *tag, const struct cu *cu) { - struct dwarf_tag *dtag = self->priv; + struct dwarf_tag *dtag = tag->priv; return cu->extra_dbg_info ? strings__ptr(strings, dtag->decl_file) : NULL; } -static uint32_t dwarf_tag__decl_line(const struct tag *self, +static uint32_t dwarf_tag__decl_line(const struct tag *tag, const struct cu *cu) { - struct dwarf_tag *dtag = self->priv; + struct dwarf_tag *dtag = tag->priv; return cu->extra_dbg_info ? dtag->decl_line : 0; } -static unsigned long long dwarf_tag__orig_id(const struct tag *self, +static unsigned long long dwarf_tag__orig_id(const struct tag *tag, const struct cu *cu) { - struct dwarf_tag *dtag = self->priv; + struct dwarf_tag *dtag = tag->priv; return cu->extra_dbg_info ? dtag->id : 0; } static const char *dwarf__strings_ptr(const struct cu *cu __unused, strings_t s) { - return strings__ptr(strings, s); + return s ? strings__ptr(strings, s) : NULL; } struct debug_fmt_ops dwarf__ops; @@ -2004,8 +2296,20 @@ Dwarf_Die child; const uint16_t tag = dwarf_tag(die); + if (tag == DW_TAG_partial_unit) { + static bool warned; + + if (!warned) { + fprintf(stderr, "WARNING: DW_TAG_partial_unit used, some types will not be considered!\n" + " Probably this was optimized using a tool like 'dwz'\n" + " A future version of pahole will support this.\n"); + warned = true; + } + return 0; // so that other units can be processed + } + if (tag != DW_TAG_compile_unit && tag != DW_TAG_type_unit) { - fprintf(stderr, "%s: DW_TAG_compile_unit or DW_TAG_type_unit expected got %s!\n", + fprintf(stderr, "%s: DW_TAG_compile_unit, DW_TAG_type_unit or DW_TAG_partial_unit expected got %s!\n", __FUNCTION__, dwarf_tag_name(tag)); return -EINVAL; } @@ -2031,67 +2335,113 @@ int ret = die__process(die, cu); if (ret != 0) return ret; - return cu__recode_dwarf_types(cu); + ret = cu__recode_dwarf_types(cu); + if (ret != 0) + return ret; + + return cu__resolve_func_ret_types(cu); } -static int class_member__cache_byte_size(struct tag *self, struct cu *cu, +static int class_member__cache_byte_size(struct tag *tag, struct cu *cu, void *cookie) { - if (self->tag == DW_TAG_member || self->tag == DW_TAG_inheritance) { - struct conf_load *conf_load = cookie; - struct class_member *member = tag__class_member(self); - - if (member->bitfield_size != 0) { - struct tag *type = tag__follow_typedef(&member->tag, cu); -check_volatile: - if (tag__is_volatile(type) || tag__is_const(type)) { - type = tag__follow_typedef(type, cu); - goto check_volatile; - } + struct class_member *member = tag__class_member(tag); + struct conf_load *conf_load = cookie; - uint16_t type_bit_size; - size_t integral_bit_size; + if (tag__is_class_member(tag)) { + if (member->is_static) + return 0; + } else if (tag->tag != DW_TAG_inheritance) { + return 0; + } + if (member->bitfield_size == 0) { + member->byte_size = tag__size(tag, cu); + member->bit_size = member->byte_size * 8; + return 0; + } + + /* + * Try to figure out byte size, if it's not directly provided in DWARF + */ + if (member->byte_size == 0) { + struct tag *type = tag__strip_typedefs_and_modifiers(&member->tag, cu); + member->byte_size = tag__size(type, cu); + if (member->byte_size == 0) { + int bit_size; if (tag__is_enumeration(type)) { - type_bit_size = tag__type(type)->size; - integral_bit_size = sizeof(int) * 8; /* FIXME: always this size? */ + bit_size = tag__type(type)->size; } else { struct base_type *bt = tag__base_type(type); - type_bit_size = bt->bit_size; - integral_bit_size = base_type__name_to_size(bt, cu); + bit_size = bt->bit_size ? bt->bit_size : base_type__name_to_size(bt, cu); } - /* - * XXX: integral_bit_size can be zero if base_type__name_to_size doesn't - * know about the base_type name, so one has to add there when - * such base_type isn't found. pahole will put zero on the - * struct output so it should be easy to spot the name when - * such unlikely thing happens. - */ - member->byte_size = integral_bit_size / 8; + member->byte_size = (bit_size + 7) / 8 * 8; + } + } + member->bit_size = member->byte_size * 8; - if (integral_bit_size == 0) - return 0; + /* + * XXX: after all the attempts to determine byte size, we might still + * be unsuccessful, because base_type__name_to_size doesn't know about + * the base_type name, so one has to add there when such base_type + * isn't found. pahole will put zero on the struct output so it should + * be easy to spot the name when such unlikely thing happens. + */ + if (member->byte_size == 0) { + member->bitfield_offset = 0; + return 0; + } - if (type_bit_size == integral_bit_size) { - member->bit_size = integral_bit_size; - if (conf_load && conf_load->fixup_silly_bitfields) { - member->bitfield_size = 0; - member->bitfield_offset = 0; - } - return 0; - } + if (!member->has_bit_offset) { + /* + * For little-endian architectures, DWARF data emitted by gcc/clang + * specifies bitfield offset as an offset from the highest-order bit + * of an underlying integral type (e.g., int) to a highest-order bit + * of a bitfield. E.g., for bitfield taking first 5 bits of int-backed + * bitfield, bit offset will be 27 (sizeof(int) - 0 offset - 5 bit + * size), which is very counter-intuitive and isn't a natural + * extension of byte offset, which on little-endian points to + * lowest-order byte. So here we re-adjust bitfield offset to be an + * offset from lowest-order bit of underlying integral type to + * a lowest-order bit of a bitfield. This makes bitfield offset + * a natural extension of byte offset for bitfields and is uniform + * with how big-endian bit offsets work. + */ + if (cu->little_endian) + member->bitfield_offset = member->bit_size - member->bitfield_offset - member->bitfield_size; - member->bit_size = type_bit_size; - } else { - member->byte_size = tag__size(self, cu); - member->bit_size = member->byte_size * 8; - } + member->bit_offset = member->byte_offset * 8 + member->bitfield_offset; + } else { + // DWARF5 has DW_AT_data_bit_offset, offset in bits from the + // start of the container type (struct, class, etc). + member->byte_offset = member->bit_offset / 8; + member->bitfield_offset = member->bit_offset - member->byte_offset * 8; + } + + /* make sure bitfield offset is non-negative */ + if (member->bitfield_offset < 0) { + member->bitfield_offset += member->bit_size; + member->byte_offset -= member->byte_size; + member->bit_offset = member->byte_offset * 8 + member->bitfield_offset; + } + /* align on underlying base type natural alignment boundary */ + member->bitfield_offset += (member->byte_offset % member->byte_size) * 8; + member->byte_offset = member->bit_offset / member->bit_size * member->bit_size / 8; + if (member->bitfield_offset >= member->bit_size) { + member->bitfield_offset -= member->bit_size; + member->byte_offset += member->byte_size; + } + + if (conf_load && conf_load->fixup_silly_bitfields && + member->byte_size == 8 * member->bitfield_size) { + member->bitfield_size = 0; + member->bitfield_offset = 0; } return 0; } -static int finalize_cu(struct cus *self, struct cu *cu, struct dwarf_cu *dcu, +static int finalize_cu(struct cus *cus, struct cu *cu, struct dwarf_cu *dcu, struct conf_load *conf) { base_type_name_to_size_table__init(strings); @@ -2102,11 +2452,11 @@ return LSK__KEEPIT; } -static int finalize_cu_immediately(struct cus *self, struct cu *cu, +static int finalize_cu_immediately(struct cus *cus, struct cu *cu, struct dwarf_cu *dcu, struct conf_load *conf) { - int lsk = finalize_cu(self, cu, dcu, conf); + int lsk = finalize_cu(cus, cu, dcu, conf); switch (lsk) { case LSK__DELETE: cu__delete(cu); @@ -2116,13 +2466,30 @@ case LSK__KEEPIT: if (!cu->extra_dbg_info) obstack_free(&dcu->obstack, NULL); - cus__add(self, cu); + cus__add(cus, cu); break; } return lsk; } -static int cus__load_debug_types(struct cus *self, struct conf_load *conf, +static int cu__set_common(struct cu *cu, struct conf_load *conf, + Dwfl_Module *mod, Elf *elf) +{ + cu->uses_global_strings = true; + cu->elf = elf; + cu->dwfl = mod; + cu->extra_dbg_info = conf ? conf->extra_dbg_info : 0; + cu->has_addr_info = conf ? conf->get_addr_info : 0; + + GElf_Ehdr ehdr; + if (gelf_getehdr(elf, &ehdr) == NULL) + return DWARF_CB_ABORT; + + cu->little_endian = ehdr.e_ident[EI_DATA] == ELFDATA2LSB; + return 0; +} + +static int cus__load_debug_types(struct cus *cus, struct conf_load *conf, Dwfl_Module *mod, Dwarf *dw, Elf *elf, const char *filename, const unsigned char *build_id, @@ -2145,17 +2512,14 @@ cu = cu__new("", pointer_size, build_id, build_id_len, filename); - if (cu == NULL) { + if (cu == NULL || + cu__set_common(cu, conf, mod, elf) != 0) { return DWARF_CB_ABORT; } - cu->uses_global_strings = true; - cu->elf = elf; - cu->dwfl = mod; - cu->extra_dbg_info = conf ? conf->extra_dbg_info : 0; - cu->has_addr_info = conf ? conf->get_addr_info : 0; + if (dwarf_cu__init(dcup) != 0) + return DWARF_CB_ABORT; - dwarf_cu__init(dcup); dcup->cu = cu; /* Funny hack. */ dcup->type_unit = dcup; @@ -2181,17 +2545,170 @@ return 0; } -static int cus__load_module(struct cus *self, struct conf_load *conf, +/* Match the define in linux:include/linux/elfnote.h */ +#define LINUX_ELFNOTE_BUILD_LTO 0x101 + +static bool cus__merging_cu(Dwarf *dw, Elf *elf) +{ + Elf_Scn *section = NULL; + while ((section = elf_nextscn(elf, section)) != 0) { + GElf_Shdr header; + if (!gelf_getshdr(section, &header)) + continue; + + if (header.sh_type != SHT_NOTE) + continue; + + Elf_Data *data = NULL; + while ((data = elf_getdata(section, data)) != 0) { + size_t name_off, desc_off, offset = 0; + GElf_Nhdr hdr; + while ((offset = gelf_getnote(data, offset, &hdr, &name_off, &desc_off)) != 0) { + if (hdr.n_type != LINUX_ELFNOTE_BUILD_LTO) + continue; + + /* owner is Linux */ + if (strcmp((char *)data->d_buf + name_off, "Linux") != 0) + continue; + + return *(int *)(data->d_buf + desc_off) != 0; + } + } + } + + Dwarf_Off off = 0, noff; + size_t cuhl; + + while (dwarf_nextcu (dw, off, &noff, &cuhl, NULL, NULL, NULL) == 0) { + Dwarf_Die die_mem; + Dwarf_Die *cu_die = dwarf_offdie(dw, off + cuhl, &die_mem); + + if (cu_die == NULL) + break; + + Dwarf_Off offset = 0; + while (true) { + size_t length; + Dwarf_Abbrev *abbrev = dwarf_getabbrev (cu_die, offset, &length); + if (abbrev == NULL || abbrev == DWARF_END_ABBREV) + break; + + size_t attrcnt; + if (dwarf_getattrcnt (abbrev, &attrcnt) != 0) + return false; + + unsigned int attr_num, attr_form; + Dwarf_Off aboffset; + size_t j; + for (j = 0; j < attrcnt; ++j) { + if (dwarf_getabbrevattr (abbrev, j, &attr_num, &attr_form, + &aboffset)) + return false; + if (attr_form == DW_FORM_ref_addr) + return true; + } + + offset += length; + } + + off = noff; + } + + return false; +} + +static int cus__merge_and_process_cu(struct cus *cus, struct conf_load *conf, + Dwfl_Module *mod, Dwarf *dw, Elf *elf, + const char *filename, + const unsigned char *build_id, + int build_id_len, + struct dwarf_cu *type_dcu) +{ + uint8_t pointer_size, offset_size; + struct dwarf_cu *dcu = NULL; + Dwarf_Off off = 0, noff; + struct cu *cu = NULL; + size_t cuhl; + + while (dwarf_nextcu(dw, off, &noff, &cuhl, NULL, &pointer_size, + &offset_size) == 0) { + Dwarf_Die die_mem; + Dwarf_Die *cu_die = dwarf_offdie(dw, off + cuhl, &die_mem); + + if (cu_die == NULL) + break; + + if (cu == NULL) { + cu = cu__new("", pointer_size, build_id, build_id_len, + filename); + if (cu == NULL || cu__set_common(cu, conf, mod, elf) != 0) + return DWARF_CB_ABORT; + + dcu = malloc(sizeof(struct dwarf_cu)); + if (dcu == NULL) + return DWARF_CB_ABORT; + + /* Merged cu tends to need a lot more memory. + * Let us start with max_hashtags__bits and + * go down to find a proper hashtag bit value. + */ + uint32_t default_hbits = hashtags__bits; + for (hashtags__bits = max_hashtags__bits; + hashtags__bits >= default_hbits; + hashtags__bits--) { + if (dwarf_cu__init(dcu) == 0) + break; + } + if (hashtags__bits < default_hbits) + return DWARF_CB_ABORT; + + dcu->cu = cu; + dcu->type_unit = type_dcu; + cu->priv = dcu; + cu->dfops = &dwarf__ops; + cu->language = attr_numeric(cu_die, DW_AT_language); + } + + Dwarf_Die child; + if (dwarf_child(cu_die, &child) == 0) { + if (die__process_unit(&child, cu) != 0) + return DWARF_CB_ABORT; + } + + off = noff; + } + + /* process merged cu */ + if (cu__recode_dwarf_types(cu) != LSK__KEEPIT) + return DWARF_CB_ABORT; + + /* + * for lto build, the function return type may not be + * resolved due to the return type of a subprogram is + * encoded in another subprogram through abstract_origin + * tag. Let us visit all subprograms again to resolve this. + */ + if (cu__resolve_func_ret_types(cu) != LSK__KEEPIT) + return DWARF_CB_ABORT; + + if (finalize_cu_immediately(cus, cu, dcu, conf) + == LSK__STOP_LOADING) + return DWARF_CB_ABORT; + + return 0; +} + +static int cus__load_module(struct cus *cus, struct conf_load *conf, Dwfl_Module *mod, Dwarf *dw, Elf *elf, const char *filename) { Dwarf_Off off = 0, noff; size_t cuhl; - GElf_Addr vaddr; const unsigned char *build_id = NULL; uint8_t pointer_size, offset_size; #ifdef HAVE_DWFL_MODULE_BUILD_ID + GElf_Addr vaddr; int build_id_len = dwfl_module_build_id(mod, &build_id, &vaddr); #else int build_id_len = 0; @@ -2201,7 +2718,7 @@ struct dwarf_cu type_dcu; int type_lsk = LSK__KEEPIT; - int res = cus__load_debug_types(self, conf, mod, dw, elf, filename, + int res = cus__load_debug_types(cus, conf, mod, dw, elf, filename, build_id, build_id_len, &type_cu, &type_dcu); if (res != 0) { @@ -2209,17 +2726,29 @@ } if (type_cu != NULL) { - type_lsk = finalize_cu(self, type_cu, &type_dcu, conf); + type_lsk = finalize_cu(cus, type_cu, &type_dcu, conf); if (type_lsk == LSK__KEEPIT) { - cus__add(self, type_cu); + cus__add(cus, type_cu); } } + if (cus__merging_cu(dw, elf)) { + res = cus__merge_and_process_cu(cus, conf, mod, dw, elf, filename, + build_id, build_id_len, + type_cu ? &type_dcu : NULL); + if (res) + return res; + goto out; + } + while (dwarf_nextcu(dw, off, &noff, &cuhl, NULL, &pointer_size, &offset_size) == 0) { Dwarf_Die die_mem; Dwarf_Die *cu_die = dwarf_offdie(dw, off + cuhl, &die_mem); + if (cu_die == NULL) + break; + /* * DW_AT_name in DW_TAG_compile_unit can be NULL, first * seen in: @@ -2228,32 +2757,29 @@ const char *name = attr_string(cu_die, DW_AT_name); struct cu *cu = cu__new(name ?: "", pointer_size, build_id, build_id_len, filename); - if (cu == NULL) + if (cu == NULL || cu__set_common(cu, conf, mod, elf) != 0) return DWARF_CB_ABORT; - cu->uses_global_strings = true; - cu->elf = elf; - cu->dwfl = mod; - cu->extra_dbg_info = conf ? conf->extra_dbg_info : 0; - cu->has_addr_info = conf ? conf->get_addr_info : 0; - - struct dwarf_cu dcu; - - dwarf_cu__init(&dcu); - dcu.cu = cu; - dcu.type_unit = type_cu ? &type_dcu : NULL; - cu->priv = &dcu; + + struct dwarf_cu *dcu = dwarf_cu__new(); + + if (dcu == NULL) + return DWARF_CB_ABORT; + + dcu->cu = cu; + dcu->type_unit = type_cu ? &type_dcu : NULL; + cu->priv = dcu; cu->dfops = &dwarf__ops; if (die__process_and_recode(cu_die, cu) != 0) return DWARF_CB_ABORT; - if (finalize_cu_immediately(self, cu, &dcu, conf) - == LSK__STOP_LOADING) + if (finalize_cu_immediately(cus, cu, dcu, conf) == LSK__STOP_LOADING) return DWARF_CB_ABORT; off = noff; } +out: if (type_lsk == LSK__DELETE) cu__delete(type_cu); @@ -2274,7 +2800,7 @@ void *arg) { struct process_dwflmod_parms *parms = arg; - struct cus *self = parms->cus; + struct cus *cus = parms->cus; GElf_Addr dwflbias; /* @@ -2292,7 +2818,7 @@ int err = DWARF_CB_OK; if (dw != NULL) { ++parms->nr_dwarf_sections_found; - err = cus__load_module(self, parms->conf, dwflmod, dw, elf, + err = cus__load_module(cus, parms->conf, dwflmod, dw, elf, parms->filename); } /* @@ -2308,7 +2834,7 @@ return err; } -static int cus__process_file(struct cus *self, struct conf_load *conf, int fd, +static int cus__process_file(struct cus *cus, struct conf_load *conf, int fd, const char *filename) { /* Duplicate an fd for dwfl_report_offline to swallow. */ @@ -2338,7 +2864,7 @@ dwfl_report_end(dwfl, NULL, NULL); struct process_dwflmod_parms parms = { - .cus = self, + .cus = cus, .conf = conf, .filename = filename, .nr_dwarf_sections_found = 0, @@ -2350,7 +2876,7 @@ return parms.nr_dwarf_sections_found ? 0 : -1; } -static int dwarf__load_file(struct cus *self, struct conf_load *conf, +static int dwarf__load_file(struct cus *cus, struct conf_load *conf, const char *filename) { int fd, err; @@ -2362,7 +2888,7 @@ if (fd == -1) return -1; - err = cus__process_file(self, conf, fd, filename); + err = cus__process_file(cus, conf, fd, filename); close(fd); return err; @@ -2389,4 +2915,6 @@ .tag__decl_file = dwarf_tag__decl_file, .tag__decl_line = dwarf_tag__decl_line, .tag__orig_id = dwarf_tag__orig_id, + .cu__delete = dwarf_cu__delete, + .has_alignment_info = true, }; diff -Nru dwarves-dfsg-1.10/dwarves.c dwarves-dfsg-1.21/dwarves.c --- dwarves-dfsg-1.10/dwarves.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/dwarves.c 2021-03-07 13:51:27.000000000 +0000 @@ -1,12 +1,10 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo Copyright (C) 2007 Red Hat Inc. Copyright (C) 2007 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include @@ -18,34 +16,73 @@ #include #include #include +#include #include #include #include #include +#include #include "config.h" #include "list.h" #include "dwarves.h" #include "dutil.h" -#include "strings.h" +#include "pahole_strings.h" #include #define obstack_chunk_alloc malloc #define obstack_chunk_free free -const char *cu__string(const struct cu *self, strings_t s) +#define min(x, y) ((x) < (y) ? (x) : (y)) + +int tag__is_base_type(const struct tag *tag, const struct cu *cu) +{ + switch (tag->tag) { + case DW_TAG_base_type: + return 1; + + case DW_TAG_typedef: { + const struct tag *type = cu__type(cu, tag->type); + + if (type == NULL) + return 0; + return tag__is_base_type(type, cu); + } + } + return 0; +} + +bool tag__is_array(const struct tag *tag, const struct cu *cu) { - if (self->dfops && self->dfops->strings__ptr) - return self->dfops->strings__ptr(self, s); + switch (tag->tag) { + case DW_TAG_array_type: + return true; + + case DW_TAG_const_type: + case DW_TAG_typedef: { + const struct tag *type = cu__type(cu, tag->type); + + if (type == NULL) + return 0; + return tag__is_array(type, cu); + } + } + return 0; +} + +const char *cu__string(const struct cu *cu, strings_t s) +{ + if (cu->dfops && cu->dfops->strings__ptr) + return cu->dfops->strings__ptr(cu, s); return NULL; } -static inline const char *s(const struct cu *self, strings_t i) +static inline const char *s(const struct cu *cu, strings_t i) { - return cu__string(self, i); + return cu__string(cu, i); } -int __tag__has_type_loop(const struct tag *self, const struct tag *type, +int __tag__has_type_loop(const struct tag *tag, const struct tag *type, char *bf, size_t len, FILE *fp, const char *fn, int line) { @@ -54,7 +91,7 @@ if (type == NULL) return 0; - if (self->type == type->type) { + if (tag->type == type->type) { int printed; if (bf != NULL) @@ -62,7 +99,7 @@ else len = sizeof(bbf); printed = snprintf(abf, len, "", - fn, line, self->type, dwarf_tag_name(self->tag)); + fn, line, tag->type, dwarf_tag_name(tag->tag)); if (bf == NULL) printed = fprintf(fp ?: stderr, "%s\n", abf); return printed; @@ -71,50 +108,50 @@ return 0; } -static void lexblock__delete_tags(struct tag *tself, struct cu *cu) +static void lexblock__delete_tags(struct tag *tag, struct cu *cu) { - struct lexblock *self = tag__lexblock(tself); + struct lexblock *block = tag__lexblock(tag); struct tag *pos, *n; - list_for_each_entry_safe_reverse(pos, n, &self->tags, node) { + list_for_each_entry_safe_reverse(pos, n, &block->tags, node) { list_del_init(&pos->node); tag__delete(pos, cu); } } -void lexblock__delete(struct lexblock *self, struct cu *cu) +void lexblock__delete(struct lexblock *block, struct cu *cu) { - lexblock__delete_tags(&self->ip.tag, cu); - obstack_free(&cu->obstack, self); + lexblock__delete_tags(&block->ip.tag, cu); + obstack_free(&cu->obstack, block); } -void tag__delete(struct tag *self, struct cu *cu) +void tag__delete(struct tag *tag, struct cu *cu) { - assert(list_empty(&self->node)); + assert(list_empty(&tag->node)); - switch (self->tag) { + switch (tag->tag) { case DW_TAG_union_type: - type__delete(tag__type(self), cu); break; + type__delete(tag__type(tag), cu); break; case DW_TAG_class_type: case DW_TAG_structure_type: - class__delete(tag__class(self), cu); break; + class__delete(tag__class(tag), cu); break; case DW_TAG_enumeration_type: - enumeration__delete(tag__type(self), cu); break; + enumeration__delete(tag__type(tag), cu); break; case DW_TAG_subroutine_type: - ftype__delete(tag__ftype(self), cu); break; + ftype__delete(tag__ftype(tag), cu); break; case DW_TAG_subprogram: - function__delete(tag__function(self), cu); break; + function__delete(tag__function(tag), cu); break; case DW_TAG_lexical_block: - lexblock__delete(tag__lexblock(self), cu); break; + lexblock__delete(tag__lexblock(tag), cu); break; default: - obstack_free(&cu->obstack, self); + obstack_free(&cu->obstack, tag); } } void tag__not_found_die(const char *file, int line, const char *func) { fprintf(stderr, "%s::%s(%d): tag not found, please report to " - "acme@ghostprotocols.net\n", file, func, line); + "acme@kernel.org\n", file, func, line); exit(1); } @@ -128,7 +165,17 @@ return type; } -size_t __tag__id_not_found_fprintf(FILE *fp, uint16_t id, +struct tag *tag__strip_typedefs_and_modifiers(const struct tag *tag, const struct cu *cu) +{ + struct tag *type = cu__type(cu, tag->type); + + while (type != NULL && (tag__is_typedef(type) || tag__is_modifier(type))) + type = cu__type(cu, type->type); + + return type; +} + +size_t __tag__id_not_found_fprintf(FILE *fp, type_id_t id, const char *fn, int line) { return fprintf(fp, "\n", fn, line, id); @@ -147,11 +194,13 @@ { .name = "signed short", .size = 16, }, { .name = "unsigned short", .size = 16, }, { .name = "short int", .size = 16, }, + { .name = "short", .size = 16, }, { .name = "char", .size = 8, }, { .name = "signed char", .size = 8, }, { .name = "unsigned char", .size = 8, }, { .name = "signed long", .size = 0, }, { .name = "long int", .size = 0, }, + { .name = "long", .size = 0, }, { .name = "signed long", .size = 0, }, { .name = "unsigned long", .size = 0, }, { .name = "long unsigned int", .size = 0, }, @@ -159,14 +208,19 @@ { .name = "_Bool", .size = 8, }, { .name = "long long unsigned int", .size = 64, }, { .name = "long long int", .size = 64, }, + { .name = "long long", .size = 64, }, { .name = "signed long long", .size = 64, }, { .name = "unsigned long long", .size = 64, }, { .name = "double", .size = 64, }, { .name = "double double", .size = 64, }, { .name = "single float", .size = 32, }, { .name = "float", .size = 32, }, - { .name = "long double", .size = 64, }, - { .name = "long double long double", .size = 64, }, + { .name = "long double", .size = sizeof(long double) * 8, }, + { .name = "long double long double", .size = sizeof(long double) * 8, }, + { .name = "__int128", .size = 128, }, + { .name = "unsigned __int128", .size = 128, }, + { .name = "__int128 unsigned", .size = 128, }, + { .name = "_Float128", .size = 128, }, { .name = NULL }, }; @@ -183,20 +237,21 @@ } } -size_t base_type__name_to_size(struct base_type *self, struct cu *cu) +size_t base_type__name_to_size(struct base_type *bt, struct cu *cu) { int i = 0; char bf[64]; - const char *name; + const char *name, *orig_name; - if (self->name_has_encoding) - name = s(cu, self->name); + if (bt->name_has_encoding) + name = s(cu, bt->name); else - name = base_type__name(self, cu, bf, sizeof(bf)); - + name = base_type__name(bt, cu, bf, sizeof(bf)); + orig_name = name; +try_again: while (base_type_name_to_size_table[i].name != NULL) { - if (self->name_has_encoding) { - if (base_type_name_to_size_table[i].sname == self->name) { + if (bt->name_has_encoding) { + if (base_type_name_to_size_table[i].sname == bt->name) { size_t size; found: size = base_type_name_to_size_table[i].size; @@ -208,8 +263,15 @@ goto found; ++i; } + + if (strstarts(name, "signed ")) { + i = 0; + name += sizeof("signed"); + goto try_again; + } + fprintf(stderr, "%s: %s %s\n", - __func__, dwarf_tag_name(self->tag.tag), name); + __func__, dwarf_tag_name(bt->tag.tag), orig_name); return 0; } @@ -228,30 +290,29 @@ [BT_FP_IMGRY_LDBL] = "imaginary long double", }; -const char *base_type__name(const struct base_type *self, const struct cu *cu, +const char *base_type__name(const struct base_type *bt, const struct cu *cu, char *bf, size_t len) { - if (self->name_has_encoding) - return s(cu, self->name); + if (bt->name_has_encoding) + return s(cu, bt->name); - if (self->float_type) + if (bt->float_type) snprintf(bf, len, "%s %s", - base_type_fp_type_str[self->float_type], - s(cu, self->name)); + base_type_fp_type_str[bt->float_type], + s(cu, bt->name)); else - snprintf(bf, len, "%s%s%s%s", - self->is_signed ? "signed " : "", - self->is_bool ? "bool " : "", - self->is_varargs ? "... " : "", - s(cu, self->name)); + snprintf(bf, len, "%s%s%s", + bt->is_bool ? "bool " : "", + bt->is_varargs ? "... " : "", + s(cu, bt->name)); return bf; } -void namespace__delete(struct namespace *self, struct cu *cu) +void namespace__delete(struct namespace *space, struct cu *cu) { struct tag *pos, *n; - namespace__for_each_tag_safe_reverse(self, pos, n) { + namespace__for_each_tag_safe_reverse(space, pos, n) { list_del_init(&pos->node); /* Look for nested namespaces */ @@ -260,17 +321,29 @@ tag__delete(pos, cu); } - tag__delete(&self->tag, cu); + tag__delete(&space->tag, cu); +} + +void __type__init(struct type *type) +{ + INIT_LIST_HEAD(&type->node); + INIT_LIST_HEAD(&type->type_enum); + type->sizeof_member = NULL; + type->member_prefix = NULL; + type->member_prefix_len = 0; } struct class_member * - type__find_first_biggest_size_base_type_member(struct type *self, + type__find_first_biggest_size_base_type_member(struct type *type, const struct cu *cu) { struct class_member *pos, *result = NULL; size_t result_size = 0; - type__for_each_data_member(self, pos) { + type__for_each_data_member(type, pos) { + if (pos->is_static) + continue; + struct tag *type = cu__type(cu, pos->tag.type); size_t member_size = 0, power2; struct class_member *inner = NULL; @@ -299,9 +372,10 @@ case DW_TAG_array_type: case DW_TAG_const_type: case DW_TAG_typedef: + case DW_TAG_rvalue_reference_type: case DW_TAG_volatile_type: { struct tag *tag = cu__type(cu, type->type); - if (type == NULL) { + if (tag == NULL) { tag__id_not_found_fprintf(stderr, type->type); continue; } @@ -329,83 +403,90 @@ return result; } -static void cu__find_class_holes(struct cu *self) +static void cu__find_class_holes(struct cu *cu) { - uint16_t id; + uint32_t id; struct class *pos; - cu__for_each_struct(self, id, pos) + cu__for_each_struct(cu, id, pos) class__find_holes(pos); } -void cus__add(struct cus *self, struct cu *cu) +void cus__add(struct cus *cus, struct cu *cu) { - list_add_tail(&cu->node, &self->cus); + cus->nr_entries++; + list_add_tail(&cu->node, &cus->cus); cu__find_class_holes(cu); } -static void ptr_table__init(struct ptr_table *self) +static void ptr_table__init(struct ptr_table *pt) { - self->entries = NULL; - self->nr_entries = self->allocated_entries = 0; + pt->entries = NULL; + pt->nr_entries = pt->allocated_entries = 0; } -static void ptr_table__exit(struct ptr_table *self) +static void ptr_table__exit(struct ptr_table *pt) { - free(self->entries); - self->entries = NULL; + free(pt->entries); + pt->entries = NULL; } -static long ptr_table__add(struct ptr_table *self, void *ptr) +static int ptr_table__add(struct ptr_table *pt, void *ptr, uint32_t *idxp) { - const uint32_t nr_entries = self->nr_entries + 1; - const long rc = self->nr_entries; + const uint32_t nr_entries = pt->nr_entries + 1; + const uint32_t rc = pt->nr_entries; - if (nr_entries > self->allocated_entries) { - uint32_t allocated_entries = self->allocated_entries + 256; - void *entries = realloc(self->entries, + if (nr_entries > pt->allocated_entries) { + uint32_t allocated_entries = pt->allocated_entries + 256; + void *entries = realloc(pt->entries, sizeof(void *) * allocated_entries); if (entries == NULL) return -ENOMEM; - self->allocated_entries = allocated_entries; - self->entries = entries; + pt->allocated_entries = allocated_entries; + pt->entries = entries; } - self->entries[rc] = ptr; - self->nr_entries = nr_entries; - return rc; + pt->entries[rc] = ptr; + pt->nr_entries = nr_entries; + *idxp = rc; + return 0; } -static int ptr_table__add_with_id(struct ptr_table *self, void *ptr, +static int ptr_table__add_with_id(struct ptr_table *pt, void *ptr, uint32_t id) { /* Assume we won't be fed with the same id more than once */ - if (id >= self->allocated_entries) { + if (id >= pt->allocated_entries) { uint32_t allocated_entries = roundup(id + 1, 256); - void *entries = realloc(self->entries, + void *entries = realloc(pt->entries, sizeof(void *) * allocated_entries); if (entries == NULL) return -ENOMEM; - self->allocated_entries = allocated_entries; - self->entries = entries; + /* Zero out the new range */ + memset(entries + pt->allocated_entries * sizeof(void *), 0, + (allocated_entries - pt->allocated_entries) * sizeof(void *)); + + pt->allocated_entries = allocated_entries; + pt->entries = entries; } - self->entries[id] = ptr; - ++self->nr_entries; + pt->entries[id] = ptr; + if (id >= pt->nr_entries) + pt->nr_entries = id + 1; return 0; } -static void *ptr_table__entry(const struct ptr_table *self, uint32_t id) +static void *ptr_table__entry(const struct ptr_table *pt, uint32_t id) { - return id >= self->nr_entries ? NULL : self->entries[id]; + return id >= pt->nr_entries ? NULL : pt->entries[id]; } -static void cu__insert_function(struct cu *self, struct tag *tag) +static void cu__insert_function(struct cu *cu, struct tag *tag) { struct function *function = tag__function(tag); - struct rb_node **p = &self->functions.rb_node; + struct rb_node **p = &cu->functions.rb_node; struct rb_node *parent = NULL; struct function *f; @@ -418,40 +499,58 @@ p = &(*p)->rb_right; } rb_link_node(&function->rb_node, parent, p); - rb_insert_color(&function->rb_node, &self->functions); + rb_insert_color(&function->rb_node, &cu->functions); } -int cu__table_add_tag(struct cu *self, struct tag *tag, long *id) +int cu__table_add_tag(struct cu *cu, struct tag *tag, uint32_t *type_id) { - struct ptr_table *pt = &self->tags_table; + struct ptr_table *pt = &cu->tags_table; if (tag__is_tag_type(tag)) - pt = &self->types_table; + pt = &cu->types_table; else if (tag__is_function(tag)) { - pt = &self->functions_table; - cu__insert_function(self, tag); + pt = &cu->functions_table; + cu__insert_function(cu, tag); } - if (*id < 0) { - *id = ptr_table__add(pt, tag); - if (*id < 0) - return -ENOMEM; - } else if (ptr_table__add_with_id(pt, tag, *id) < 0) - return -ENOMEM; - return 0; + return ptr_table__add(pt, tag, type_id) ? -ENOMEM : 0; } -int cu__table_nullify_type_entry(struct cu *self, uint32_t id) +int cu__table_nullify_type_entry(struct cu *cu, uint32_t id) { - return ptr_table__add_with_id(&self->types_table, NULL, id); + return ptr_table__add_with_id(&cu->types_table, NULL, id); } -int cu__add_tag(struct cu *self, struct tag *tag, long *id) +int cu__add_tag(struct cu *cu, struct tag *tag, uint32_t *id) { - int err = cu__table_add_tag(self, tag, id); + int err = cu__table_add_tag(cu, tag, id); if (err == 0) - list_add_tail(&tag->node, &self->tags); + list_add_tail(&tag->node, &cu->tags); + + return err; +} + +int cu__table_add_tag_with_id(struct cu *cu, struct tag *tag, uint32_t id) +{ + struct ptr_table *pt = &cu->tags_table; + + if (tag__is_tag_type(tag)) { + pt = &cu->types_table; + } else if (tag__is_function(tag)) { + pt = &cu->functions_table; + cu__insert_function(cu, tag); + } + + return ptr_table__add_with_id(pt, tag, id); +} + +int cu__add_tag_with_id(struct cu *cu, struct tag *tag, uint32_t id) +{ + int err = cu__table_add_tag_with_id(cu, tag, id); + + if (err == 0) + list_add_tail(&tag->node, &cu->tags); return err; } @@ -460,123 +559,125 @@ const unsigned char *build_id, int build_id_len, const char *filename) { - struct cu *self = malloc(sizeof(*self) + build_id_len); + struct cu *cu = malloc(sizeof(*cu) + build_id_len); - if (self != NULL) { - self->name = strdup(name); - self->filename = strdup(filename); - if (self->name == NULL || self->filename == NULL) + if (cu != NULL) { + uint32_t void_id; + + cu->name = strdup(name); + cu->filename = strdup(filename); + if (cu->name == NULL || cu->filename == NULL) goto out_free; - obstack_init(&self->obstack); - ptr_table__init(&self->tags_table); - ptr_table__init(&self->types_table); - ptr_table__init(&self->functions_table); + obstack_init(&cu->obstack); + ptr_table__init(&cu->tags_table); + ptr_table__init(&cu->types_table); + ptr_table__init(&cu->functions_table); /* * the first entry is historically associated with void, * so make sure we don't use it */ - if (ptr_table__add(&self->types_table, NULL) < 0) + if (ptr_table__add(&cu->types_table, NULL, &void_id) < 0) goto out_free_name; - self->functions = RB_ROOT; + cu->functions = RB_ROOT; - self->dfops = NULL; - INIT_LIST_HEAD(&self->tags); - INIT_LIST_HEAD(&self->tool_list); - - self->addr_size = addr_size; - self->extra_dbg_info = 0; - - self->nr_inline_expansions = 0; - self->size_inline_expansions = 0; - self->nr_structures_changed = 0; - self->nr_functions_changed = 0; - self->max_len_changed_item = 0; - self->function_bytes_added = 0; - self->function_bytes_removed = 0; - self->build_id_len = build_id_len; + cu->dfops = NULL; + INIT_LIST_HEAD(&cu->tags); + INIT_LIST_HEAD(&cu->tool_list); + + cu->addr_size = addr_size; + cu->extra_dbg_info = 0; + + cu->nr_inline_expansions = 0; + cu->size_inline_expansions = 0; + cu->nr_structures_changed = 0; + cu->nr_functions_changed = 0; + cu->max_len_changed_item = 0; + cu->function_bytes_added = 0; + cu->function_bytes_removed = 0; + cu->build_id_len = build_id_len; if (build_id_len > 0) - memcpy(self->build_id, build_id, build_id_len); + memcpy(cu->build_id, build_id, build_id_len); } out: - return self; + return cu; out_free_name: - free(self->name); - free(self->filename); + free(cu->name); + free(cu->filename); out_free: - free(self); - self = NULL; + free(cu); + cu = NULL; goto out; } -void cu__delete(struct cu *self) +void cu__delete(struct cu *cu) { - ptr_table__exit(&self->tags_table); - ptr_table__exit(&self->types_table); - ptr_table__exit(&self->functions_table); - if (self->dfops && self->dfops->cu__delete) - self->dfops->cu__delete(self); - obstack_free(&self->obstack, NULL); - free(self->filename); - free(self->name); - free(self); + ptr_table__exit(&cu->tags_table); + ptr_table__exit(&cu->types_table); + ptr_table__exit(&cu->functions_table); + if (cu->dfops && cu->dfops->cu__delete) + cu->dfops->cu__delete(cu); + obstack_free(&cu->obstack, NULL); + free(cu->filename); + free(cu->name); + free(cu); } -bool cu__same_build_id(const struct cu *self, const struct cu *other) +bool cu__same_build_id(const struct cu *cu, const struct cu *other) { - return self->build_id_len != 0 && - self->build_id_len == other->build_id_len && - memcmp(self->build_id, other->build_id, self->build_id_len) == 0; + return cu->build_id_len != 0 && + cu->build_id_len == other->build_id_len && + memcmp(cu->build_id, other->build_id, cu->build_id_len) == 0; } -struct tag *cu__function(const struct cu *self, const uint32_t id) +struct tag *cu__function(const struct cu *cu, const uint32_t id) { - return self ? ptr_table__entry(&self->functions_table, id) : NULL; + return cu ? ptr_table__entry(&cu->functions_table, id) : NULL; } -struct tag *cu__tag(const struct cu *self, const uint32_t id) +struct tag *cu__tag(const struct cu *cu, const uint32_t id) { - return self ? ptr_table__entry(&self->tags_table, id) : NULL; + return cu ? ptr_table__entry(&cu->tags_table, id) : NULL; } -struct tag *cu__type(const struct cu *self, const uint16_t id) +struct tag *cu__type(const struct cu *cu, const type_id_t id) { - return self ? ptr_table__entry(&self->types_table, id) : NULL; + return cu ? ptr_table__entry(&cu->types_table, id) : NULL; } -struct tag *cu__find_first_typedef_of_type(const struct cu *self, - const uint16_t type) +struct tag *cu__find_first_typedef_of_type(const struct cu *cu, + const type_id_t type) { - uint16_t id; + uint32_t id; struct tag *pos; - if (self == NULL || type == 0) + if (cu == NULL || type == 0) return NULL; - cu__for_each_type(self, id, pos) + cu__for_each_type(cu, id, pos) if (tag__is_typedef(pos) && pos->type == type) return pos; return NULL; } -struct tag *cu__find_base_type_by_name(const struct cu *self, - const char *name, uint16_t *idp) +struct tag *cu__find_base_type_by_name(const struct cu *cu, + const char *name, type_id_t *idp) { - uint16_t id; + uint32_t id; struct tag *pos; - if (self == NULL || name == NULL) + if (cu == NULL || name == NULL) return NULL; - cu__for_each_type(self, id, pos) { + cu__for_each_type(cu, id, pos) { if (pos->tag != DW_TAG_base_type) continue; const struct base_type *bt = tag__base_type(pos); char bf[64]; - const char *bname = base_type__name(bt, self, bf, sizeof(bf)); + const char *bname = base_type__name(bt, cu, bf, sizeof(bf)); if (!bname || strcmp(bname, name) != 0) continue; @@ -588,18 +689,18 @@ return NULL; } -struct tag *cu__find_base_type_by_sname_and_size(const struct cu *self, +struct tag *cu__find_base_type_by_sname_and_size(const struct cu *cu, strings_t sname, uint16_t bit_size, - uint16_t *idp) + type_id_t *idp) { - uint16_t id; + uint32_t id; struct tag *pos; if (sname == 0) return NULL; - cu__for_each_type(self, id, pos) { + cu__for_each_type(cu, id, pos) { if (pos->tag == DW_TAG_base_type) { const struct base_type *bt = tag__base_type(pos); @@ -615,18 +716,18 @@ return NULL; } -struct tag *cu__find_enumeration_by_sname_and_size(const struct cu *self, +struct tag *cu__find_enumeration_by_sname_and_size(const struct cu *cu, strings_t sname, uint16_t bit_size, - uint16_t *idp) + type_id_t *idp) { - uint16_t id; + uint32_t id; struct tag *pos; if (sname == 0) return NULL; - cu__for_each_type(self, id, pos) { + cu__for_each_type(cu, id, pos) { if (pos->tag == DW_TAG_enumeration_type) { const struct type *t = tag__type(pos); @@ -642,16 +743,40 @@ return NULL; } -struct tag *cu__find_struct_by_sname(const struct cu *self, strings_t sname, - const int include_decls, uint16_t *idp) +struct tag *cu__find_enumeration_by_name(const struct cu *cu, const char *name, type_id_t *idp) { - uint16_t id; + uint32_t id; + struct tag *pos; + + if (name == NULL) + return NULL; + + cu__for_each_type(cu, id, pos) { + if (pos->tag == DW_TAG_enumeration_type) { + const struct type *type = tag__type(pos); + const char *tname = type__name(type, cu); + + if (tname && strcmp(tname, name) == 0) { + if (idp != NULL) + *idp = id; + return pos; + } + } + } + + return NULL; +} + +struct tag *cu__find_struct_by_sname(const struct cu *cu, strings_t sname, + const int include_decls, type_id_t *idp) +{ + uint32_t id; struct tag *pos; if (sname == 0) return NULL; - cu__for_each_type(self, id, pos) { + cu__for_each_type(cu, id, pos) { struct type *type; if (!tag__is_struct(pos)) @@ -675,22 +800,21 @@ } -struct tag *cu__find_struct_by_name(const struct cu *self, const char *name, - const int include_decls, uint16_t *idp) +struct tag *cu__find_type_by_name(const struct cu *cu, const char *name, const int include_decls, type_id_t *idp) { - if (self == NULL || name == NULL) + if (cu == NULL || name == NULL) return NULL; - uint16_t id; + uint32_t id; struct tag *pos; - cu__for_each_type(self, id, pos) { + cu__for_each_type(cu, id, pos) { struct type *type; - if (!tag__is_struct(pos)) + if (!tag__is_type(pos)) continue; type = tag__type(pos); - const char *tname = type__name(type, self); + const char *tname = type__name(type, cu); if (tname && strcmp(tname, name) == 0) { if (!type->declaration) goto found; @@ -707,16 +831,13 @@ return pos; } -struct tag *cus__find_struct_by_name(const struct cus *self, - struct cu **cu, const char *name, - const int include_decls, uint16_t *id) +struct tag *cus__find_type_by_name(const struct cus *cus, struct cu **cu, const char *name, + const int include_decls, type_id_t *id) { struct cu *pos; - list_for_each_entry(pos, &self->cus, node) { - struct tag *tag = cu__find_struct_by_name(pos, name, - include_decls, - id); + list_for_each_entry(pos, &cus->cus, node) { + struct tag *tag = cu__find_type_by_name(pos, name, include_decls, id); if (tag != NULL) { if (cu != NULL) *cu = pos; @@ -727,15 +848,89 @@ return NULL; } -struct function *cu__find_function_at_addr(const struct cu *self, +static struct tag *__cu__find_struct_by_name(const struct cu *cu, const char *name, + const int include_decls, bool unions, type_id_t *idp) +{ + if (cu == NULL || name == NULL) + return NULL; + + uint32_t id; + struct tag *pos; + cu__for_each_type(cu, id, pos) { + struct type *type; + + if (!(tag__is_struct(pos) || (unions && tag__is_union(pos)))) + continue; + + type = tag__type(pos); + const char *tname = type__name(type, cu); + if (tname && strcmp(tname, name) == 0) { + if (!type->declaration) + goto found; + + if (include_decls) + goto found; + } + } + + return NULL; +found: + if (idp != NULL) + *idp = id; + return pos; +} + +struct tag *cu__find_struct_by_name(const struct cu *cu, const char *name, + const int include_decls, type_id_t *idp) +{ + return __cu__find_struct_by_name(cu, name, include_decls, false, idp); +} + +struct tag *cu__find_struct_or_union_by_name(const struct cu *cu, const char *name, + const int include_decls, type_id_t *idp) +{ + return __cu__find_struct_by_name(cu, name, include_decls, true, idp); +} + +static struct tag *__cus__find_struct_by_name(const struct cus *cus, + struct cu **cu, const char *name, + const int include_decls, bool unions, type_id_t *id) +{ + struct cu *pos; + + list_for_each_entry(pos, &cus->cus, node) { + struct tag *tag = __cu__find_struct_by_name(pos, name, include_decls, unions, id); + if (tag != NULL) { + if (cu != NULL) + *cu = pos; + return tag; + } + } + + return NULL; +} + +struct tag *cus__find_struct_by_name(const struct cus *cus, struct cu **cu, const char *name, + const int include_decls, type_id_t *idp) +{ + return __cus__find_struct_by_name(cus, cu, name, include_decls, false, idp); +} + +struct tag *cus__find_struct_or_union_by_name(const struct cus *cus, struct cu **cu, const char *name, + const int include_decls, type_id_t *idp) +{ + return __cus__find_struct_by_name(cus, cu, name, include_decls, true, idp); +} + +struct function *cu__find_function_at_addr(const struct cu *cu, uint64_t addr) { struct rb_node *n; - if (self == NULL) + if (cu == NULL) return NULL; - n = self->functions.rb_node; + n = cu->functions.rb_node; while (n) { struct function *f = rb_entry(n, struct function, rb_node); @@ -752,12 +947,12 @@ } -struct function *cus__find_function_at_addr(const struct cus *self, +struct function *cus__find_function_at_addr(const struct cus *cus, uint64_t addr, struct cu **cu) { struct cu *pos; - list_for_each_entry(pos, &self->cus, node) { + list_for_each_entry(pos, &cus->cus, node) { struct function *f = cu__find_function_at_addr(pos, addr); if (f != NULL) { @@ -769,26 +964,26 @@ return NULL; } -struct cu *cus__find_cu_by_name(const struct cus *self, const char *name) +struct cu *cus__find_cu_by_name(const struct cus *cus, const char *name) { struct cu *pos; - list_for_each_entry(pos, &self->cus, node) + list_for_each_entry(pos, &cus->cus, node) if (pos->name && strcmp(pos->name, name) == 0) return pos; return NULL; } -struct tag *cu__find_function_by_name(const struct cu *self, const char *name) +struct tag *cu__find_function_by_name(const struct cu *cu, const char *name) { - if (self == NULL || name == NULL) + if (cu == NULL || name == NULL) return NULL; uint32_t id; struct function *pos; - cu__for_each_function(self, id, pos) { - const char *fname = function__name(pos, self); + cu__for_each_function(cu, id, pos) { + const char *fname = function__name(pos, cu); if (fname && strcmp(fname, name) == 0) return function__tag(pos); } @@ -796,171 +991,179 @@ return NULL; } -static size_t array_type__nr_entries(const struct array_type *self) +static size_t array_type__nr_entries(const struct array_type *at) { int i; size_t nr_entries = 1; - for (i = 0; i < self->dimensions; ++i) - nr_entries *= self->nr_entries[i]; + for (i = 0; i < at->dimensions; ++i) + nr_entries *= at->nr_entries[i]; return nr_entries; } -size_t tag__size(const struct tag *self, const struct cu *cu) +size_t tag__size(const struct tag *tag, const struct cu *cu) { size_t size; - switch (self->tag) { + switch (tag->tag) { + case DW_TAG_string_type: + return tag__string_type(tag)->nr_entries; case DW_TAG_member: { + struct class_member *member = tag__class_member(tag); + if (member->is_static) + return 0; /* Is it cached already? */ - size = tag__class_member(self)->byte_size; + size = member->byte_size; if (size != 0) return size; break; } case DW_TAG_pointer_type: case DW_TAG_reference_type: return cu->addr_size; - case DW_TAG_base_type: return base_type__size(self); - case DW_TAG_enumeration_type: return tag__type(self)->size / 8; + case DW_TAG_base_type: return base_type__size(tag); + case DW_TAG_enumeration_type: return tag__type(tag)->size / 8; } - if (self->type == 0) { /* struct class: unions, structs */ - struct type *type = tag__type(self); + if (tag->type == 0) { /* struct class: unions, structs */ + struct type *type = tag__type(tag); /* empty base optimization trick */ if (type->size == 1 && type->nr_members == 0) size = 0; else - size = tag__type(self)->size; + size = tag__type(tag)->size; } else { - const struct tag *type = cu__type(cu, self->type); + const struct tag *type = cu__type(cu, tag->type); if (type == NULL) { - tag__id_not_found_fprintf(stderr, self->type); + tag__id_not_found_fprintf(stderr, tag->type); return -1; - } else if (tag__has_type_loop(self, type, NULL, 0, NULL)) + } else if (tag__has_type_loop(tag, type, NULL, 0, NULL)) return -1; size = tag__size(type, cu); } - if (self->tag == DW_TAG_array_type) - return size * array_type__nr_entries(tag__array_type(self)); + if (tag->tag == DW_TAG_array_type) + return size * array_type__nr_entries(tag__array_type(tag)); return size; } -const char *variable__name(const struct variable *self, const struct cu *cu) +const char *variable__name(const struct variable *var, const struct cu *cu) { if (cu->dfops && cu->dfops->variable__name) - return cu->dfops->variable__name(self, cu); - return s(cu, self->name); + return cu->dfops->variable__name(var, cu); + return s(cu, var->name); } -const char *variable__type_name(const struct variable *self, +const char *variable__type_name(const struct variable *var, const struct cu *cu, char *bf, size_t len) { - const struct tag *tag = cu__type(cu, self->ip.tag.type); + const struct tag *tag = cu__type(cu, var->ip.tag.type); return tag != NULL ? tag__name(tag, cu, bf, len, NULL) : NULL; } -void class_member__delete(struct class_member *self, struct cu *cu) +void class_member__delete(struct class_member *member, struct cu *cu) { - obstack_free(&cu->obstack, self); + obstack_free(&cu->obstack, member); } static struct class_member *class_member__clone(const struct class_member *from, struct cu *cu) { - struct class_member *self = obstack_alloc(&cu->obstack, sizeof(*self)); + struct class_member *member = obstack_alloc(&cu->obstack, sizeof(*member)); - if (self != NULL) - memcpy(self, from, sizeof(*self)); + if (member != NULL) + memcpy(member, from, sizeof(*member)); - return self; + return member; } -static void type__delete_class_members(struct type *self, struct cu *cu) +static void type__delete_class_members(struct type *type, struct cu *cu) { struct class_member *pos, *next; - type__for_each_tag_safe_reverse(self, pos, next) { + type__for_each_tag_safe_reverse(type, pos, next) { list_del_init(&pos->tag.node); class_member__delete(pos, cu); } } -void class__delete(struct class *self, struct cu *cu) +void class__delete(struct class *class, struct cu *cu) { - if (self->type.namespace.sname != NULL) - free(self->type.namespace.sname); - type__delete_class_members(&self->type, cu); - obstack_free(&cu->obstack, self); + if (class->type.namespace.sname != NULL) + free(class->type.namespace.sname); + type__delete_class_members(&class->type, cu); + obstack_free(&cu->obstack, class); } -void type__delete(struct type *self, struct cu *cu) +void type__delete(struct type *type, struct cu *cu) { - type__delete_class_members(self, cu); - obstack_free(&cu->obstack, self); + type__delete_class_members(type, cu); + obstack_free(&cu->obstack, type); } -static void enumerator__delete(struct enumerator *self, struct cu *cu) +static void enumerator__delete(struct enumerator *enumerator, struct cu *cu) { - obstack_free(&cu->obstack, self); + obstack_free(&cu->obstack, enumerator); } -void enumeration__delete(struct type *self, struct cu *cu) +void enumeration__delete(struct type *type, struct cu *cu) { struct enumerator *pos, *n; - type__for_each_enumerator_safe_reverse(self, pos, n) { + type__for_each_enumerator_safe_reverse(type, pos, n) { list_del_init(&pos->tag.node); enumerator__delete(pos, cu); } } -void class__add_vtable_entry(struct class *self, struct function *vtable_entry) +void class__add_vtable_entry(struct class *class, struct function *vtable_entry) { - ++self->nr_vtable_entries; - list_add_tail(&vtable_entry->vtable_node, &self->vtable); + ++class->nr_vtable_entries; + list_add_tail(&vtable_entry->vtable_node, &class->vtable); } -void namespace__add_tag(struct namespace *self, struct tag *tag) +void namespace__add_tag(struct namespace *space, struct tag *tag) { - ++self->nr_tags; - list_add_tail(&tag->node, &self->tags); + ++space->nr_tags; + list_add_tail(&tag->node, &space->tags); } -void type__add_member(struct type *self, struct class_member *member) +void type__add_member(struct type *type, struct class_member *member) { - ++self->nr_members; - namespace__add_tag(&self->namespace, &member->tag); + if (member->is_static) + ++type->nr_static_members; + else + ++type->nr_members; + namespace__add_tag(&type->namespace, &member->tag); } -struct class_member *type__last_member(struct type *self) +struct class_member *type__last_member(struct type *type) { struct class_member *pos; - list_for_each_entry_reverse(pos, &self->namespace.tags, tag.node) + list_for_each_entry_reverse(pos, &type->namespace.tags, tag.node) if (pos->tag.tag == DW_TAG_member) return pos; return NULL; } -static int type__clone_members(struct type *self, const struct type *from, +static int type__clone_members(struct type *type, const struct type *from, struct cu *cu) { struct class_member *pos; - self->nr_members = 0; - INIT_LIST_HEAD(&self->namespace.tags); + type->nr_members = type->nr_static_members = 0; + INIT_LIST_HEAD(&type->namespace.tags); type__for_each_member(from, pos) { struct class_member *clone = class_member__clone(pos, cu); if (clone == NULL) return -1; - type__add_member(self, clone); + type__add_member(type, clone); } return 0; @@ -969,80 +1172,87 @@ struct class *class__clone(const struct class *from, const char *new_class_name, struct cu *cu) { - struct class *self = obstack_alloc(&cu->obstack, sizeof(*self)); + struct class *class = obstack_alloc(&cu->obstack, sizeof(*class)); - if (self != NULL) { - memcpy(self, from, sizeof(*self)); + if (class != NULL) { + memcpy(class, from, sizeof(*class)); if (new_class_name != NULL) { - self->type.namespace.name = 0; - self->type.namespace.sname = strdup(new_class_name); - if (self->type.namespace.sname == NULL) { - free(self); + class->type.namespace.name = 0; + class->type.namespace.sname = strdup(new_class_name); + if (class->type.namespace.sname == NULL) { + free(class); return NULL; } } - if (type__clone_members(&self->type, &from->type, cu) != 0) { - class__delete(self, cu); - self = NULL; + if (type__clone_members(&class->type, &from->type, cu) != 0) { + class__delete(class, cu); + class = NULL; } } - return self; + return class; } -void enumeration__add(struct type *self, struct enumerator *enumerator) +void enumeration__add(struct type *type, struct enumerator *enumerator) { - ++self->nr_members; - namespace__add_tag(&self->namespace, &enumerator->tag); + ++type->nr_members; + namespace__add_tag(&type->namespace, &enumerator->tag); } -void lexblock__add_lexblock(struct lexblock *self, struct lexblock *child) +void lexblock__add_lexblock(struct lexblock *block, struct lexblock *child) { - ++self->nr_lexblocks; - list_add_tail(&child->ip.tag.node, &self->tags); + ++block->nr_lexblocks; + list_add_tail(&child->ip.tag.node, &block->tags); } -const char *function__name(struct function *self, const struct cu *cu) +const char *function__name(struct function *func, const struct cu *cu) { if (cu->dfops && cu->dfops->function__name) - return cu->dfops->function__name(self, cu); - return s(cu, self->name); + return cu->dfops->function__name(func, cu); + return s(cu, func->name); } -static void parameter__delete(struct parameter *self, struct cu *cu) +static void parameter__delete(struct parameter *parm, struct cu *cu) { - obstack_free(&cu->obstack, self); + obstack_free(&cu->obstack, parm); } -void ftype__delete(struct ftype *self, struct cu *cu) +void ftype__delete(struct ftype *type, struct cu *cu) { struct parameter *pos, *n; - if (self == NULL) + if (type == NULL) return; - ftype__for_each_parameter_safe_reverse(self, pos, n) { + ftype__for_each_parameter_safe_reverse(type, pos, n) { list_del_init(&pos->tag.node); parameter__delete(pos, cu); } - obstack_free(&cu->obstack, self); + obstack_free(&cu->obstack, type); } -void function__delete(struct function *self, struct cu *cu) +void function__delete(struct function *func, struct cu *cu) { - lexblock__delete_tags(&self->lexblock.ip.tag, cu); - ftype__delete(&self->proto, cu); + lexblock__delete_tags(&func->lexblock.ip.tag, cu); + ftype__delete(&func->proto, cu); } -int ftype__has_parm_of_type(const struct ftype *self, const uint16_t target, +int ftype__has_parm_of_type(const struct ftype *ftype, const type_id_t target, const struct cu *cu) { struct parameter *pos; - ftype__for_each_parameter(self, pos) { + if (ftype->tag.tag == DW_TAG_subprogram) { + struct function *func = (struct function *)ftype; + + if (func->btf) + ftype = tag__ftype(cu__type(cu, ftype->tag.type)); + } + + ftype__for_each_parameter(ftype, pos) { struct tag *type = cu__type(cu, pos->tag.type); - if (type != NULL && type->tag == DW_TAG_pointer_type) { + if (type != NULL && tag__is_pointer(type)) { if (type->type == target) return 1; } @@ -1050,45 +1260,45 @@ return 0; } -void ftype__add_parameter(struct ftype *self, struct parameter *parm) +void ftype__add_parameter(struct ftype *ftype, struct parameter *parm) { - ++self->nr_parms; - list_add_tail(&parm->tag.node, &self->parms); + ++ftype->nr_parms; + list_add_tail(&parm->tag.node, &ftype->parms); } -void lexblock__add_tag(struct lexblock *self, struct tag *tag) +void lexblock__add_tag(struct lexblock *block, struct tag *tag) { - list_add_tail(&tag->node, &self->tags); + list_add_tail(&tag->node, &block->tags); } -void lexblock__add_inline_expansion(struct lexblock *self, +void lexblock__add_inline_expansion(struct lexblock *block, struct inline_expansion *exp) { - ++self->nr_inline_expansions; - self->size_inline_expansions += exp->size; - lexblock__add_tag(self, &exp->ip.tag); + ++block->nr_inline_expansions; + block->size_inline_expansions += exp->size; + lexblock__add_tag(block, &exp->ip.tag); } -void lexblock__add_variable(struct lexblock *self, struct variable *var) +void lexblock__add_variable(struct lexblock *block, struct variable *var) { - ++self->nr_variables; - lexblock__add_tag(self, &var->ip.tag); + ++block->nr_variables; + lexblock__add_tag(block, &var->ip.tag); } -void lexblock__add_label(struct lexblock *self, struct label *label) +void lexblock__add_label(struct lexblock *block, struct label *label) { - ++self->nr_labels; - lexblock__add_tag(self, &label->ip.tag); + ++block->nr_labels; + lexblock__add_tag(block, &label->ip.tag); } -const struct class_member *class__find_bit_hole(const struct class *self, +const struct class_member *class__find_bit_hole(const struct class *class, const struct class_member *trailer, const uint16_t bit_hole_size) { struct class_member *pos; const size_t byte_hole_size = bit_hole_size / 8; - type__for_each_data_member(&self->type, pos) + type__for_each_data_member(&class->type, pos) if (pos == trailer) break; else if (pos->hole >= byte_hole_size || @@ -1098,16 +1308,24 @@ return NULL; } -void class__find_holes(struct class *self) +void class__find_holes(struct class *class) { - const struct type *ctype = &self->type; + const struct type *ctype = &class->type; struct class_member *pos, *last = NULL; - size_t last_size = 0; - uint32_t bit_sum = 0; - uint32_t bitfield_real_offset = 0; + int cur_bitfield_end = ctype->size * 8, cur_bitfield_size = 0; + int bit_holes = 0, byte_holes = 0; + int bit_start, bit_end; + int last_seen_bit = 0; + bool in_bitfield = false; - self->nr_holes = 0; - self->nr_bit_holes = 0; + if (!tag__is_struct(class__tag(class))) + return; + + if (class->holes_searched) + return; + + class->nr_holes = 0; + class->nr_bit_holes = 0; type__for_each_member(ctype, pos) { /* XXX for now just skip these */ @@ -1115,99 +1333,302 @@ pos->virtuality == DW_VIRTUALITY_virtual) continue; - if (last != NULL) { - /* - * We have to cast both offsets to int64_t because - * the current offset can be before the last offset - * when we are starting a bitfield that combines with - * the previous, small size fields. - */ - const ssize_t cc_last_size = ((int64_t)pos->byte_offset - - (int64_t)last->byte_offset); + if (pos->is_static) + continue; - /* - * If the offset is the same this better be a bitfield - * or an empty struct (see rwlock_t in the Linux kernel - * sources when compiled for UP) or... - */ - if (cc_last_size > 0) { - /* - * Check if the DWARF byte_size info is smaller - * than the size used by the compiler, i.e. - * when combining small bitfields with the next - * member. - */ - if ((size_t)cc_last_size < last_size) - last_size = cc_last_size; - - last->hole = cc_last_size - last_size; - if (last->hole > 0) - ++self->nr_holes; - - if (bit_sum != 0) { - if (bitfield_real_offset != 0) { - last_size = bitfield_real_offset - last->byte_offset; - bitfield_real_offset = 0; - } - - last->bit_hole = (last_size * 8) - - bit_sum; - if (last->bit_hole != 0) - ++self->nr_bit_holes; + pos->bit_hole = 0; + pos->hole = 0; - last->bitfield_end = 1; - bit_sum = 0; - } - } else if (cc_last_size < 0 && bit_sum == 0) - bitfield_real_offset = last->byte_offset + last_size; + bit_start = pos->bit_offset; + if (pos->bitfield_size) { + bit_end = bit_start + pos->bitfield_size; + } else { + bit_end = bit_start + pos->byte_size * 8; } - bit_sum += pos->bitfield_size; + bit_holes = 0; + byte_holes = 0; + if (in_bitfield) { + /* check if we have some trailing bitfield bits left */ + int bitfield_end = min(bit_start, cur_bitfield_end); + bit_holes = bitfield_end - last_seen_bit; + last_seen_bit = bitfield_end; + } + if (pos->bitfield_size) { + int aligned_start = pos->byte_offset * 8; + /* we can have some alignment byte padding left, + * but we need to be careful about bitfield spanning + * multiple aligned boundaries */ + if (last_seen_bit < aligned_start && aligned_start <= bit_start) { + byte_holes = pos->byte_offset - last_seen_bit / 8; + last_seen_bit = aligned_start; + } + bit_holes += bit_start - last_seen_bit; + } else { + byte_holes = bit_start/8 - last_seen_bit/8; + } + last_seen_bit = bit_end; - /* - * check for bitfields, accounting for only the biggest of the - * byte_size in the fields in each bitfield set. - */ + if (pos->bitfield_size) { + in_bitfield = true; + /* if it's a new bitfield set or same, but with + * bigger-sized type, readjust size and end bit */ + if (bit_end > cur_bitfield_end || pos->bit_size > cur_bitfield_size) { + cur_bitfield_size = pos->bit_size; + cur_bitfield_end = pos->byte_offset * 8 + cur_bitfield_size; + /* + * if current bitfield "borrowed" bits from + * previous bitfield, it will have byte_offset + * of previous bitfield's backing integral + * type, but its end bit will be in a new + * bitfield "area", so we need to adjust + * bitfield end appropriately + */ + if (bit_end > cur_bitfield_end) { + cur_bitfield_end += cur_bitfield_size; + } + } + } else { + in_bitfield = false; + cur_bitfield_size = 0; + cur_bitfield_end = bit_end; + } - if (last == NULL || last->byte_offset != pos->byte_offset || - pos->bitfield_size == 0 || last->bitfield_size == 0) { - last_size = pos->byte_size; - } else if (pos->byte_size > last_size) - last_size = pos->byte_size; + if (last) { + last->hole = byte_holes; + last->bit_hole = bit_holes; + } else { + class->pre_hole = byte_holes; + class->pre_bit_hole = bit_holes; + } + if (bit_holes) + class->nr_bit_holes++; + if (byte_holes) + class->nr_holes++; last = pos; } - if (last != NULL) { - if (last->byte_offset + last_size != ctype->size) - self->padding = ctype->size - - (last->byte_offset + last_size); - if (last->bitfield_size != 0) - self->bit_padding = (last_size * 8) - bit_sum; - } else - /* No members? Zero sized C++ class */ - self->padding = 0; + if (in_bitfield) { + int bitfield_end = min(ctype->size * 8, cur_bitfield_end); + class->bit_padding = bitfield_end - last_seen_bit; + last_seen_bit = bitfield_end; + } else { + class->bit_padding = 0; + } + class->padding = ctype->size - last_seen_bit / 8; + + class->holes_searched = true; +} + +static size_t type__natural_alignment(struct type *type, const struct cu *cu); + +static size_t tag__natural_alignment(struct tag *tag, const struct cu *cu) +{ + size_t natural_alignment = 1; + + if (tag == NULL) // Maybe its a non supported type, like DW_TAG_subrange_type, ADA stuff + return natural_alignment; + + if (tag__is_pointer(tag)) { + natural_alignment = cu->addr_size; + } else if (tag->tag == DW_TAG_base_type) { + natural_alignment = base_type__size(tag); + } else if (tag__is_enumeration(tag)) { + natural_alignment = tag__type(tag)->size / 8; + } else if (tag__is_struct(tag) || tag__is_union(tag)) { + natural_alignment = type__natural_alignment(tag__type(tag), cu); + } else if (tag->tag == DW_TAG_array_type) { + tag = tag__strip_typedefs_and_modifiers(tag, cu); + if (tag != NULL) // Maybe its a non supported type, like DW_TAG_subrange_type, ADA stuff + natural_alignment = tag__natural_alignment(tag, cu); + } + + /* + * Cope with zero sized types, like: + * + * struct u64_stats_sync { + * #if BITS_PER_LONG==32 && defined(CONFIG_SMP) + * seqcount_t seq; + * #endif + * }; + * + */ + return natural_alignment ?: 1; +} + +static size_t type__natural_alignment(struct type *type, const struct cu *cu) +{ + struct class_member *member; + + if (type->natural_alignment != 0) + return type->natural_alignment; + + type__for_each_member(type, member) { + /* XXX for now just skip these */ + if (member->tag.tag == DW_TAG_inheritance && + member->virtuality == DW_VIRTUALITY_virtual) + continue; + if (member->is_static) continue; + + struct tag *member_type = tag__strip_typedefs_and_modifiers(&member->tag, cu); + + if (member_type == NULL) // Maybe its a DW_TAG_subrange_type, ADA stuff still not supported + continue; + + size_t member_natural_alignment = tag__natural_alignment(member_type, cu); + + if (type->natural_alignment < member_natural_alignment) + type->natural_alignment = member_natural_alignment; + } + + return type->natural_alignment; +} + +/* + * Sometimes the only indication that a struct is __packed__ is for it to + * appear embedded in another and at an offset that is not natural for it, + * so, in !__packed__ parked struct, check for that and mark the types of + * members at unnatural alignments. + */ +void type__check_structs_at_unnatural_alignments(struct type *type, const struct cu *cu) +{ + struct class_member *member; + + type__for_each_member(type, member) { + struct tag *member_type = tag__strip_typedefs_and_modifiers(&member->tag, cu); + + if (member_type == NULL) { + // just be conservative and ignore + // Found first when a FORTRAN95 DWARF file was processed + // and the DW_TAG_string_type wasn't yet supported + continue; + } + + if (!tag__is_struct(member_type)) + continue; + + size_t natural_alignment = tag__natural_alignment(member_type, cu); + + /* Would this break the natural alignment */ + if ((member->byte_offset % natural_alignment) != 0) { + struct class *cls = tag__class(member_type); + + cls->is_packed = true; + cls->type.packed_attributes_inferred = true; + } + } +} + +bool class__infer_packed_attributes(struct class *cls, const struct cu *cu) +{ + struct type *ctype = &cls->type; + struct class_member *pos; + uint16_t max_natural_alignment = 1; + + if (!tag__is_struct(class__tag(cls))) + return false; + + if (ctype->packed_attributes_inferred) + return cls->is_packed; + + class__find_holes(cls); + + if (cls->padding != 0 || cls->nr_holes != 0) { + type__check_structs_at_unnatural_alignments(ctype, cu); + cls->is_packed = false; + goto out; + } + + type__for_each_member(ctype, pos) { + /* XXX for now just skip these */ + if (pos->tag.tag == DW_TAG_inheritance && + pos->virtuality == DW_VIRTUALITY_virtual) + continue; + + if (pos->is_static) + continue; + + struct tag *member_type = tag__strip_typedefs_and_modifiers(&pos->tag, cu); + size_t natural_alignment = tag__natural_alignment(member_type, cu); + + /* Always aligned: */ + if (natural_alignment == sizeof(char)) + continue; + + if (max_natural_alignment < natural_alignment) + max_natural_alignment = natural_alignment; + + if ((pos->byte_offset % natural_alignment) == 0) + continue; + + cls->is_packed = true; + goto out; + } + + if ((max_natural_alignment != 1 && ctype->alignment == 1) || + (class__size(cls) % max_natural_alignment) != 0) + cls->is_packed = true; + +out: + ctype->packed_attributes_inferred = true; + + return cls->is_packed; +} + +/* + * If structs embedded in unions, nameless or not, have a size which isn't + * isn't a multiple of the union size, then it must be packed, even if + * it has no holes nor padding, as an array of such unions would have the + * natural alignments of non-multiple structs inside it broken. + */ +void union__infer_packed_attributes(struct type *type, const struct cu *cu) +{ + const uint32_t union_size = type->size; + struct class_member *member; + + if (type->packed_attributes_inferred) + return; + + type__for_each_member(type, member) { + struct tag *member_type = tag__strip_typedefs_and_modifiers(&member->tag, cu); + + if (!tag__is_struct(member_type)) + continue; + + size_t natural_alignment = tag__natural_alignment(member_type, cu); + + /* Would this break the natural alignment */ + if ((union_size % natural_alignment) != 0) { + struct class *cls = tag__class(member_type); + + cls->is_packed = true; + cls->type.packed_attributes_inferred = true; + } + } + + type->packed_attributes_inferred = true; } /** class__has_hole_ge - check if class has a hole greater or equal to @size - * @self - class instance + * @class - class instance * @size - hole size to check */ -int class__has_hole_ge(const struct class *self, const uint16_t size) +int class__has_hole_ge(const struct class *class, const uint16_t size) { struct class_member *pos; - if (self->nr_holes == 0) + if (class->nr_holes == 0) return 0; - type__for_each_data_member(&self->type, pos) + type__for_each_data_member(&class->type, pos) if (pos->hole >= size) return 1; return 0; } -struct class_member *type__find_member_by_name(const struct type *self, +struct class_member *type__find_member_by_name(const struct type *type, const struct cu *cu, const char *name) { @@ -1215,7 +1636,7 @@ return NULL; struct class_member *pos; - type__for_each_data_member(self, pos) { + type__for_each_data_member(type, pos) { const char *curr_name = class_member__name(pos, cu); if (curr_name && strcmp(curr_name, name) == 0) return pos; @@ -1224,27 +1645,97 @@ return NULL; } -uint32_t type__nr_members_of_type(const struct type *self, const uint16_t type) +static int strcommon(const char *a, const char *b) +{ + int i = 0; + + while (*a != '\0' && *a == *b) { + ++a; + ++b; + ++i; + } + + return i; +} + +void enumeration__calc_prefix(struct type *enumeration, const struct cu *cu) +{ + if (enumeration->member_prefix) + return; + + const char *previous_name = NULL, *curr_name = ""; + int common_part = INT32_MAX; + struct enumerator *entry; + + type__for_each_enumerator(enumeration, entry) { + const char *curr_name = enumerator__name(entry, cu); + + if (previous_name) { + int curr_common_part = strcommon(curr_name, previous_name); + if (common_part > curr_common_part) + common_part = curr_common_part; + + } + + previous_name = curr_name; + } + + enumeration->member_prefix = NULL; + enumeration->member_prefix_len = 0; + + if (common_part != INT32_MAX) { + enumeration->member_prefix = strndup(curr_name, common_part); + if (enumeration->member_prefix != NULL) + enumeration->member_prefix_len = common_part; + } +} + +void enumerations__calc_prefix(struct list_head *enumerations) +{ + struct tag_cu_node *pos; + + list_for_each_entry(pos, enumerations, node) + enumeration__calc_prefix(tag__type(pos->tc.tag), pos->tc.cu); +} + +const char *enumeration__prefix(struct type *enumeration, const struct cu *cu) +{ + if (!enumeration->member_prefix) + enumeration__calc_prefix(enumeration, cu); + + return enumeration->member_prefix; +} + +uint16_t enumeration__prefix_len(struct type *enumeration, const struct cu *cu) +{ + if (!enumeration->member_prefix) + enumeration__calc_prefix(enumeration, cu); + + return enumeration->member_prefix_len; +} + + +uint32_t type__nr_members_of_type(const struct type *type, const type_id_t type_id) { struct class_member *pos; uint32_t nr_members_of_type = 0; - type__for_each_member(self, pos) - if (pos->tag.type == type) + type__for_each_member(type, pos) + if (pos->tag.type == type_id) ++nr_members_of_type; return nr_members_of_type; } -static void lexblock__account_inline_expansions(struct lexblock *self, +static void lexblock__account_inline_expansions(struct lexblock *block, const struct cu *cu) { struct tag *pos, *type; - if (self->nr_inline_expansions == 0) + if (block->nr_inline_expansions == 0) return; - list_for_each_entry(pos, &self->tags, node) { + list_for_each_entry(pos, &block->tags, node) { if (pos->tag == DW_TAG_lexical_block) { lexblock__account_inline_expansions(tag__lexblock(pos), cu); @@ -1264,29 +1755,32 @@ } } -void cu__account_inline_expansions(struct cu *self) +void cu__account_inline_expansions(struct cu *cu) { struct tag *pos; struct function *fpos; - list_for_each_entry(pos, &self->tags, node) { + list_for_each_entry(pos, &cu->tags, node) { if (!tag__is_function(pos)) continue; fpos = tag__function(pos); - lexblock__account_inline_expansions(&fpos->lexblock, self); - self->nr_inline_expansions += fpos->lexblock.nr_inline_expansions; - self->size_inline_expansions += fpos->lexblock.size_inline_expansions; + lexblock__account_inline_expansions(&fpos->lexblock, cu); + cu->nr_inline_expansions += fpos->lexblock.nr_inline_expansions; + cu->size_inline_expansions += fpos->lexblock.size_inline_expansions; } } -static int list__for_all_tags(struct list_head *self, struct cu *cu, +static int list__for_all_tags(struct list_head *list, struct cu *cu, int (*iterator)(struct tag *tag, struct cu *cu, void *cookie), void *cookie) { struct tag *pos, *n; - list_for_each_entry_safe_reverse(pos, n, self, node) { + if (list_empty(list) || !list->next) + return 0; + + list_for_each_entry_safe_reverse(pos, n, list, node) { if (tag__has_namespace(pos)) { struct namespace *space = tag__namespace(pos); @@ -1325,22 +1819,22 @@ return 0; } -int cu__for_all_tags(struct cu *self, +int cu__for_all_tags(struct cu *cu, int (*iterator)(struct tag *tag, struct cu *cu, void *cookie), void *cookie) { - return list__for_all_tags(&self->tags, self, iterator, cookie); + return list__for_all_tags(&cu->tags, cu, iterator, cookie); } -void cus__for_each_cu(struct cus *self, +void cus__for_each_cu(struct cus *cus, int (*iterator)(struct cu *cu, void *cookie), void *cookie, struct cu *(*filter)(struct cu *cu)) { struct cu *pos; - list_for_each_entry(pos, &self->cus, node) { + list_for_each_entry(pos, &cus->cus, node) { struct cu *cu = pos; if (filter != NULL) { cu = filter(pos); @@ -1352,7 +1846,7 @@ } } -int cus__load_dir(struct cus *self, struct conf_load *conf, +int cus__load_dir(struct cus *cus, struct conf_load *conf, const char *dirname, const char *filename_mask, const int recursive) { @@ -1372,8 +1866,8 @@ strcmp(entry->d_name, "..") == 0) continue; - snprintf(pathname, sizeof(pathname), "%s/%s", - dirname, entry->d_name); + snprintf(pathname, sizeof(pathname), "%.*s/%s", + (int)(sizeof(pathname) - sizeof(entry->d_name) - 1), dirname, entry->d_name); err = lstat(pathname, &st); if (err != 0) @@ -1383,12 +1877,12 @@ if (!recursive) continue; - err = cus__load_dir(self, conf, pathname, + err = cus__load_dir(cus, conf, pathname, filename_mask, recursive); if (err != 0) break; } else if (fnmatch(filename_mask, entry->d_name, 0) == 0) { - err = cus__load_file(self, conf, pathname); + err = cus__load_file(cus, conf, pathname); if (err != 0) break; } @@ -1404,14 +1898,17 @@ /* * This should really do demand loading of DSOs, STABS anyone? 8-) */ -extern struct debug_fmt_ops dwarf__ops, ctf__ops; +extern struct debug_fmt_ops dwarf__ops, ctf__ops, btf_elf__ops; static struct debug_fmt_ops *debug_fmt_table[] = { &dwarf__ops, + &btf_elf__ops, &ctf__ops, NULL, }; +struct debug_fmt_ops *dwarves__active_loader; + static int debugging_formats__loader(const char *name) { int i = 0; @@ -1423,7 +1920,7 @@ return -1; } -int cus__load_file(struct cus *self, struct conf_load *conf, +int cus__load_file(struct cus *cus, struct conf_load *conf, const char *filename) { int i = 0, err = 0; @@ -1445,8 +1942,12 @@ if (loader == -1) break; + if (conf->conf_fprintf) + conf->conf_fprintf->has_alignment_info = debug_fmt_table[loader]->has_alignment_info; + err = 0; - if (debug_fmt_table[loader]->load_file(self, conf, + dwarves__active_loader = debug_fmt_table[loader]; + if (debug_fmt_table[loader]->load_file(cus, conf, filename) == 0) break; @@ -1457,55 +1958,415 @@ fp = sep + 1; } free(fpath); + dwarves__active_loader = NULL; return err; } while (debug_fmt_table[i] != NULL) { - if (debug_fmt_table[i]->load_file(self, conf, filename) == 0) + if (conf && conf->conf_fprintf) + conf->conf_fprintf->has_alignment_info = debug_fmt_table[i]->has_alignment_info; + dwarves__active_loader = debug_fmt_table[i]; + if (debug_fmt_table[i]->load_file(cus, conf, filename) == 0) return 0; ++i; } + dwarves__active_loader = NULL; return -EINVAL; } -int cus__load_files(struct cus *self, struct conf_load *conf, +#define BUILD_ID_SIZE 20 +#define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1) + +#define NOTE_ALIGN(sz) (((sz) + 3) & ~3) + +#define NT_GNU_BUILD_ID 3 + +#ifndef min +#define min(x, y) ({ \ + typeof(x) _min1 = (x); \ + typeof(y) _min2 = (y); \ + (void) (&_min1 == &_min2); \ + _min1 < _min2 ? _min1 : _min2; }) +#endif + +/* Force a compilation error if condition is true, but also produce a + result (of value 0 and type size_t), so the expression can be used + e.g. in a structure initializer (or where-ever else comma expressions + aren't permitted). */ +#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) + +/* Are two types/vars the same type (ignoring qualifiers)? */ +#ifndef __same_type +# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) +#endif + +/* &a[0] degrades to a pointer: a different type from an array */ +#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) + +static int sysfs__read_build_id(const char *filename, void *build_id, size_t size) +{ + int fd, err = -1; + + if (size < BUILD_ID_SIZE) + goto out; + + fd = open(filename, O_RDONLY); + if (fd < 0) + goto out; + + while (1) { + char bf[BUFSIZ]; + GElf_Nhdr nhdr; + size_t namesz, descsz; + + if (read(fd, &nhdr, sizeof(nhdr)) != sizeof(nhdr)) + break; + + namesz = NOTE_ALIGN(nhdr.n_namesz); + descsz = NOTE_ALIGN(nhdr.n_descsz); + if (nhdr.n_type == NT_GNU_BUILD_ID && + nhdr.n_namesz == sizeof("GNU")) { + if (read(fd, bf, namesz) != (ssize_t)namesz) + break; + if (memcmp(bf, "GNU", sizeof("GNU")) == 0) { + size_t sz = min(descsz, size); + if (read(fd, build_id, sz) == (ssize_t)sz) { + memset(build_id + sz, 0, size - sz); + err = 0; + break; + } + } else if (read(fd, bf, descsz) != (ssize_t)descsz) + break; + } else { + int n = namesz + descsz; + + if (n > (int)sizeof(bf)) { + n = sizeof(bf); + fprintf(stderr, "%s: truncating reading of build id in sysfs file %s: n_namesz=%u, n_descsz=%u.\n", + __func__, filename, nhdr.n_namesz, nhdr.n_descsz); + } + if (read(fd, bf, n) != n) + break; + } + } + close(fd); +out: + return err; +} + +static int elf_read_build_id(Elf *elf, void *bf, size_t size) +{ + int err = -1; + GElf_Ehdr ehdr; + GElf_Shdr shdr; + Elf_Data *data; + Elf_Scn *sec; + Elf_Kind ek; + void *ptr; + + if (size < BUILD_ID_SIZE) + goto out; + + ek = elf_kind(elf); + if (ek != ELF_K_ELF) + goto out; + + if (gelf_getehdr(elf, &ehdr) == NULL) { + fprintf(stderr, "%s: cannot get elf header.\n", __func__); + goto out; + } + + /* + * Check following sections for notes: + * '.note.gnu.build-id' + * '.notes' + * '.note' (VDSO specific) + */ + do { + sec = elf_section_by_name(elf, &ehdr, &shdr, + ".note.gnu.build-id", NULL); + if (sec) + break; + + sec = elf_section_by_name(elf, &ehdr, &shdr, + ".notes", NULL); + if (sec) + break; + + sec = elf_section_by_name(elf, &ehdr, &shdr, + ".note", NULL); + if (sec) + break; + + return err; + + } while (0); + + data = elf_getdata(sec, NULL); + if (data == NULL) + goto out; + + ptr = data->d_buf; + while (ptr < (data->d_buf + data->d_size)) { + GElf_Nhdr *nhdr = ptr; + size_t namesz = NOTE_ALIGN(nhdr->n_namesz), + descsz = NOTE_ALIGN(nhdr->n_descsz); + const char *name; + + ptr += sizeof(*nhdr); + name = ptr; + ptr += namesz; + if (nhdr->n_type == NT_GNU_BUILD_ID && + nhdr->n_namesz == sizeof("GNU")) { + if (memcmp(name, "GNU", sizeof("GNU")) == 0) { + size_t sz = min(size, descsz); + memcpy(bf, ptr, sz); + memset(bf + sz, 0, size - sz); + err = descsz; + break; + } + } + ptr += descsz; + } + +out: + return err; +} + +static int filename__read_build_id(const char *filename, void *bf, size_t size) +{ + int fd, err = -1; + Elf *elf; + + if (size < BUILD_ID_SIZE) + goto out; + + fd = open(filename, O_RDONLY); + if (fd < 0) + goto out; + + elf = elf_begin(fd, ELF_C_READ, NULL); + if (elf == NULL) { + fprintf(stderr, "%s: cannot read %s ELF file.\n", __func__, filename); + goto out_close; + } + + err = elf_read_build_id(elf, bf, size); + + elf_end(elf); +out_close: + close(fd); +out: + return err; +} + +static int build_id__sprintf(const unsigned char *build_id, int len, char *bf) +{ + char *bid = bf; + const unsigned char *raw = build_id; + int i; + + for (i = 0; i < len; ++i) { + sprintf(bid, "%02x", *raw); + ++raw; + bid += 2; + } + + return (bid - bf) + 1; +} + +static int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id) +{ + char notes[PATH_MAX]; + unsigned char build_id[BUILD_ID_SIZE]; + int ret; + + if (!root_dir) + root_dir = ""; + + snprintf(notes, sizeof(notes), "%s/sys/kernel/notes", root_dir); + + ret = sysfs__read_build_id(notes, build_id, sizeof(build_id)); + if (ret < 0) + return ret; + + return build_id__sprintf(build_id, sizeof(build_id), sbuild_id); +} + +static int filename__sprintf_build_id(const char *pathname, char *sbuild_id) +{ + unsigned char build_id[BUILD_ID_SIZE]; + int ret; + + ret = filename__read_build_id(pathname, build_id, sizeof(build_id)); + if (ret < 0) + return ret; + else if (ret != sizeof(build_id)) + return -EINVAL; + + return build_id__sprintf(build_id, sizeof(build_id), sbuild_id); +} + +#define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) + +static int vmlinux_path__nr_entries; +static char **vmlinux_path; + +static void vmlinux_path__exit(void) +{ + while (--vmlinux_path__nr_entries >= 0) + zfree(&vmlinux_path[vmlinux_path__nr_entries]); + vmlinux_path__nr_entries = 0; + + zfree(&vmlinux_path); +} + +static const char * const vmlinux_paths[] = { + "vmlinux", + "/boot/vmlinux" +}; + +static const char * const vmlinux_paths_upd[] = { + "/boot/vmlinux-%s", + "/usr/lib/debug/boot/vmlinux-%s", + "/lib/modules/%s/build/vmlinux", + "/usr/lib/debug/lib/modules/%s/vmlinux", + "/usr/lib/debug/boot/vmlinux-%s.debug" +}; + +static int vmlinux_path__add(const char *new_entry) +{ + vmlinux_path[vmlinux_path__nr_entries] = strdup(new_entry); + if (vmlinux_path[vmlinux_path__nr_entries] == NULL) + return -1; + ++vmlinux_path__nr_entries; + + return 0; +} + +static int vmlinux_path__init(void) +{ + struct utsname uts; + char bf[PATH_MAX]; + char *kernel_version; + unsigned int i; + + vmlinux_path = malloc(sizeof(char *) * (ARRAY_SIZE(vmlinux_paths) + + ARRAY_SIZE(vmlinux_paths_upd))); + if (vmlinux_path == NULL) + return -1; + + for (i = 0; i < ARRAY_SIZE(vmlinux_paths); i++) + if (vmlinux_path__add(vmlinux_paths[i]) < 0) + goto out_fail; + + if (uname(&uts) < 0) + goto out_fail; + + kernel_version = uts.release; + + for (i = 0; i < ARRAY_SIZE(vmlinux_paths_upd); i++) { + snprintf(bf, sizeof(bf), vmlinux_paths_upd[i], kernel_version); + if (vmlinux_path__add(bf) < 0) + goto out_fail; + } + + return 0; + +out_fail: + vmlinux_path__exit(); + return -1; +} + +static int cus__load_running_kernel(struct cus *cus, struct conf_load *conf) +{ + int i, err = 0; + char running_sbuild_id[SBUILD_ID_SIZE]; + + if ((!conf || conf->format_path == NULL || strncmp(conf->format_path, "btf", 3) == 0) && + access("/sys/kernel/btf/vmlinux", R_OK) == 0) { + int loader = debugging_formats__loader("btf"); + if (loader == -1) + goto try_elf; + + if (conf && conf->conf_fprintf) + conf->conf_fprintf->has_alignment_info = debug_fmt_table[loader]->has_alignment_info; + + dwarves__active_loader = debug_fmt_table[loader]; + if (debug_fmt_table[loader]->load_file(cus, conf, "/sys/kernel/btf/vmlinux") == 0) + return 0; + dwarves__active_loader = NULL; + } +try_elf: + elf_version(EV_CURRENT); + vmlinux_path__init(); + + sysfs__sprintf_build_id(NULL, running_sbuild_id); + + for (i = 0; i < vmlinux_path__nr_entries; ++i) { + char sbuild_id[SBUILD_ID_SIZE]; + + if (filename__sprintf_build_id(vmlinux_path[i], sbuild_id) > 0 && + strcmp(sbuild_id, running_sbuild_id) == 0) { + err = cus__load_file(cus, conf, vmlinux_path[i]); + break; + } + } + + vmlinux_path__exit(); + + return err; +} + +int cus__load_files(struct cus *cus, struct conf_load *conf, char *filenames[]) { int i = 0; while (filenames[i] != NULL) { - if (cus__load_file(self, conf, filenames[i])) - return -i; + if (cus__load_file(cus, conf, filenames[i])) + return -++i; ++i; } - return 0; + return i ? 0 : cus__load_running_kernel(cus, conf); +} + +int cus__fprintf_load_files_err(struct cus *cus, const char *tool, char *argv[], int err, FILE *output) +{ + /* errno is not properly preserved in some cases, sigh */ + return fprintf(output, "%s: %s: %s\n", tool, argv[-err - 1], + errno ? strerror(errno) : "No debugging information found"); } struct cus *cus__new(void) { - struct cus *self = malloc(sizeof(*self)); + struct cus *cus = malloc(sizeof(*cus)); - if (self != NULL) - INIT_LIST_HEAD(&self->cus); + if (cus != NULL) { + cus->nr_entries = 0; + INIT_LIST_HEAD(&cus->cus); + } - return self; + return cus; } -void cus__delete(struct cus *self) +void cus__delete(struct cus *cus) { struct cu *pos, *n; - if (self == NULL) + if (cus == NULL) return; - list_for_each_entry_safe(pos, n, &self->cus, node) { + list_for_each_entry_safe(pos, n, &cus->cus, node) { list_del_init(&pos->node); cu__delete(pos); } - free(self); + free(cus); } void dwarves__fprintf_init(uint16_t user_cacheline_size); @@ -1549,5 +2410,12 @@ void dwarves_print_version(FILE *fp, struct argp_state *state __unused) { - fprintf(fp, "%s\n", DWARVES_VERSION); + fprintf(fp, "v%u.%u\n", DWARVES_MAJOR_VERSION, DWARVES_MINOR_VERSION); +} + +bool print_numeric_version; + +void dwarves_print_numeric_version(FILE *fp) +{ + fprintf(fp, "%u%u\n", DWARVES_MAJOR_VERSION, DWARVES_MINOR_VERSION); } diff -Nru dwarves-dfsg-1.10/dwarves_emit.c dwarves-dfsg-1.21/dwarves_emit.c --- dwarves-dfsg-1.10/dwarves_emit.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/dwarves_emit.c 2019-12-13 14:40:33.000000000 +0000 @@ -1,12 +1,10 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo Copyright (C) 2007 Red Hat Inc. Copyright (C) 2007 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include @@ -15,30 +13,30 @@ #include "dwarves_emit.h" #include "dwarves.h" -void type_emissions__init(struct type_emissions *self) +void type_emissions__init(struct type_emissions *emissions) { - INIT_LIST_HEAD(&self->definitions); - INIT_LIST_HEAD(&self->fwd_decls); + INIT_LIST_HEAD(&emissions->definitions); + INIT_LIST_HEAD(&emissions->fwd_decls); } -static void type_emissions__add_definition(struct type_emissions *self, +static void type_emissions__add_definition(struct type_emissions *emissions, struct type *type) { type->definition_emitted = 1; if (!list_empty(&type->node)) list_del(&type->node); - list_add_tail(&type->node, &self->definitions); + list_add_tail(&type->node, &emissions->definitions); } -static void type_emissions__add_fwd_decl(struct type_emissions *self, +static void type_emissions__add_fwd_decl(struct type_emissions *emissions, struct type *type) { type->fwd_decl_emitted = 1; if (list_empty(&type->node)) - list_add_tail(&type->node, &self->fwd_decls); + list_add_tail(&type->node, &emissions->fwd_decls); } -struct type *type_emissions__find_definition(const struct type_emissions *self, +struct type *type_emissions__find_definition(const struct type_emissions *emissions, const struct cu *cu, const char *name) { @@ -47,7 +45,7 @@ if (name == NULL) return NULL; - list_for_each_entry(pos, &self->definitions, node) + list_for_each_entry(pos, &emissions->definitions, node) if (type__name(pos, cu) != NULL && strcmp(type__name(pos, cu), name) == 0) return pos; @@ -55,25 +53,31 @@ return NULL; } -static struct type *type_emissions__find_fwd_decl(const struct type_emissions *self, +static struct type *type_emissions__find_fwd_decl(const struct type_emissions *emissions, const struct cu *cu, const char *name) { struct type *pos; - list_for_each_entry(pos, &self->fwd_decls, node) - if (strcmp(type__name(pos, cu), name) == 0) + if (name == NULL) + return NULL; + + list_for_each_entry(pos, &emissions->fwd_decls, node) { + const char *curr_name = type__name(pos, cu); + + if (curr_name && strcmp(curr_name, name) == 0) return pos; + } return NULL; } -static int enumeration__emit_definitions(struct tag *self, struct cu *cu, +static int enumeration__emit_definitions(struct tag *tag, struct cu *cu, struct type_emissions *emissions, const struct conf_fprintf *conf, FILE *fp) { - struct type *etype = tag__type(self); + struct type *etype = tag__type(tag); /* Have we already emitted this in this CU? */ if (etype->definition_emitted) @@ -90,7 +94,7 @@ return 0; } - enumeration__fprintf(self, cu, conf, fp); + enumeration__fprintf(tag, cu, conf, fp); fputs(";\n", fp); type_emissions__add_definition(emissions, etype); return 1; @@ -104,7 +108,6 @@ { struct type *def = tag__type(tdef); struct tag *type, *ptr_type; - int is_pointer = 0; /* Have we already emitted this in this CU? */ if (def->definition_emitted) @@ -133,11 +136,15 @@ break; case DW_TAG_pointer_type: ptr_type = cu__type(cu, type->type); - tag__assert_search_result(ptr_type); - if (ptr_type->tag != DW_TAG_subroutine_type) + /* void ** can make ptr_type be NULL */ + if (ptr_type == NULL) + break; + if (ptr_type->tag == DW_TAG_typedef) { + typedef__emit_definitions(ptr_type, cu, emissions, fp); + break; + } else if (ptr_type->tag != DW_TAG_subroutine_type) break; type = ptr_type; - is_pointer = 1; /* Fall thru */ case DW_TAG_subroutine_type: ftype__emit_definitions(tag__ftype(type), cu, emissions, fp); @@ -197,9 +204,12 @@ if (ctype->fwd_decl_emitted) return 0; + const char *name = type__name(ctype, cu); + if (name == NULL) + return 0; + /* Ok, lets look at the previous CUs: */ - if (type_emissions__find_fwd_decl(emissions, cu, - type__name(ctype, cu)) != NULL) { + if (type_emissions__find_fwd_decl(emissions, cu, name) != NULL) { /* * Yes, so lets mark it visited on this CU too, * to speed up the lookup. @@ -215,10 +225,10 @@ return 1; } -static int tag__emit_definitions(struct tag *self, struct cu *cu, +static int tag__emit_definitions(struct tag *tag, struct cu *cu, struct type_emissions *emissions, FILE *fp) { - struct tag *type = cu__type(cu, self->type); + struct tag *type = cu__type(cu, tag->type); int pointer = 0; if (type == NULL) @@ -249,9 +259,17 @@ break; case DW_TAG_structure_type: case DW_TAG_union_type: - if (pointer) + if (pointer) { + /* + * Struct defined inline, no name, need to have its + * members types emitted. + */ + if (type__name(tag__type(type), cu) == NULL) + type__emit_definitions(type, cu, emissions, fp); + return type__emit_fwd_decl(tag__type(type), cu, emissions, fp); + } if (type__emit_definitions(type, cu, emissions, fp)) type__emit(type, cu, NULL, NULL, fp); return 1; @@ -263,15 +281,15 @@ return 0; } -int ftype__emit_definitions(struct ftype *self, struct cu *cu, +int ftype__emit_definitions(struct ftype *ftype, struct cu *cu, struct type_emissions *emissions, FILE *fp) { struct parameter *pos; /* First check the function return type */ - int printed = tag__emit_definitions(&self->tag, cu, emissions, fp); + int printed = tag__emit_definitions(&ftype->tag, cu, emissions, fp); /* Then its parameters */ - list_for_each_entry(pos, &self->parms, tag.node) + list_for_each_entry(pos, &ftype->parms, tag.node) if (tag__emit_definitions(&pos->tag, cu, emissions, fp)) printed = 1; @@ -280,10 +298,10 @@ return printed; } -int type__emit_definitions(struct tag *self, struct cu *cu, +int type__emit_definitions(struct tag *tag, struct cu *cu, struct type_emissions *emissions, FILE *fp) { - struct type *ctype = tag__type(self); + struct type *ctype = tag__type(tag); struct class_member *pos; if (ctype->definition_emitted) @@ -296,8 +314,13 @@ return 0; } + if (tag__is_typedef(tag)) + return typedef__emit_definitions(tag, cu, emissions, fp); + type_emissions__add_definition(emissions, ctype); + type__check_structs_at_unnatural_alignments(ctype, cu); + type__for_each_member(ctype, pos) if (tag__emit_definitions(&pos->tag, cu, emissions, fp)) fputc('\n', fp); @@ -305,10 +328,10 @@ return 1; } -void type__emit(struct tag *tag_self, struct cu *cu, +void type__emit(struct tag *tag, struct cu *cu, const char *prefix, const char *suffix, FILE *fp) { - struct type *ctype = tag__type(tag_self); + struct type *ctype = tag__type(tag); if (type__name(ctype, cu) != NULL || suffix != NULL || prefix != NULL) { @@ -317,7 +340,7 @@ .suffix = suffix, .emit_stats = 1, }; - tag__fprintf(tag_self, cu, &conf, fp); + tag__fprintf(tag, cu, &conf, fp); fputc('\n', fp); } } diff -Nru dwarves-dfsg-1.10/dwarves_emit.h dwarves-dfsg-1.21/dwarves_emit.h --- dwarves-dfsg-1.10/dwarves_emit.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/dwarves_emit.h 2019-05-01 15:06:45.000000000 +0000 @@ -1,13 +1,11 @@ #ifndef _DWARVES_EMIT_H_ #define _DWARVES_EMIT_H_ 1 /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo Copyright (C) 2007 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include @@ -23,17 +21,17 @@ struct list_head fwd_decls; /* struct class entries */ }; -void type_emissions__init(struct type_emissions *self); +void type_emissions__init(struct type_emissions *temissions); -int ftype__emit_definitions(struct ftype *self, struct cu *cu, +int ftype__emit_definitions(struct ftype *ftype, struct cu *cu, struct type_emissions *emissions, FILE *fp); -int type__emit_definitions(struct tag *self, struct cu *cu, +int type__emit_definitions(struct tag *tag, struct cu *cu, struct type_emissions *emissions, FILE *fp); int type__emit_fwd_decl(struct type *ctype, const struct cu *cu, struct type_emissions *emissions, FILE *fp); -void type__emit(struct tag *tag_self, struct cu *cu, +void type__emit(struct tag *tag_type, struct cu *cu, const char *prefix, const char *suffix, FILE *fp); -struct type *type_emissions__find_definition(const struct type_emissions *self, +struct type *type_emissions__find_definition(const struct type_emissions *temissions, const struct cu *cu, const char *name); diff -Nru dwarves-dfsg-1.10/dwarves_fprintf.c dwarves-dfsg-1.21/dwarves_fprintf.c --- dwarves-dfsg-1.10/dwarves_fprintf.c 2012-03-20 16:18:48.000000000 +0000 +++ dwarves-dfsg-1.21/dwarves_fprintf.c 2021-03-07 13:51:32.000000000 +0000 @@ -1,12 +1,10 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo Copyright (C) 2007..2009 Red Hat Inc. Copyright (C) 2007..2009 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include @@ -14,6 +12,8 @@ #include #include #include +#include +#include #include "config.h" #include "dwarves.h" @@ -74,7 +74,6 @@ [DW_TAG_unspecified_type] = "unspecified_type", [DW_TAG_partial_unit] = "partial_unit", [DW_TAG_imported_unit] = "imported_unit", - [DW_TAG_mutable_type] = "mutable_type", [DW_TAG_condition] = "condition", [DW_TAG_shared_type] = "shared_type", #ifdef STB_GNU_UNIQUE @@ -89,11 +88,15 @@ [DW_TAG_function_template - DW_TAG_MIPS_loop] = "function_template", [DW_TAG_class_template - DW_TAG_MIPS_loop] = "class_template", #ifdef STB_GNU_UNIQUE - [DW_TAG_GNU_BINCL - DW_TAG_MIPS_loop] = "BINCL", - [DW_TAG_GNU_EINCL - DW_TAG_MIPS_loop] = "EINCL", - [DW_TAG_GNU_template_template_param - DW_TAG_MIPS_loop] = "template_template_param", - [DW_TAG_GNU_template_parameter_pack - DW_TAG_MIPS_loop] = "template_parameter_pack", - [DW_TAG_GNU_formal_parameter_pack - DW_TAG_MIPS_loop] = "formal_parameter_pack", + [DW_TAG_GNU_BINCL - DW_TAG_MIPS_loop] = "GNU_BINCL", + [DW_TAG_GNU_EINCL - DW_TAG_MIPS_loop] = "GNU_EINCL", + [DW_TAG_GNU_template_template_param - DW_TAG_MIPS_loop] = "GNU_template_template_param", + [DW_TAG_GNU_template_parameter_pack - DW_TAG_MIPS_loop] = "GNU_template_parameter_pack", + [DW_TAG_GNU_formal_parameter_pack - DW_TAG_MIPS_loop] = "GNU_formal_parameter_pack", +#endif +#if _ELFUTILS_PREREQ(0, 153) + [DW_TAG_GNU_call_site - DW_TAG_MIPS_loop] = "GNU_call_site", + [DW_TAG_GNU_call_site_parameter - DW_TAG_MIPS_loop] = "GNU_call_site_parameter", #endif }; @@ -108,7 +111,9 @@ ) return dwarf_tag_names[tag]; else if (tag >= DW_TAG_MIPS_loop && tag <= -#ifdef STB_GNU_UNIQUE +#if _ELFUTILS_PREREQ(0, 153) + DW_TAG_GNU_call_site_parameter +#elif STB_GNU_UNIQUE DW_TAG_GNU_formal_parameter_pack #else DW_TAG_class_template @@ -124,26 +129,26 @@ .emit_stats = 1, }; -static const char tabs[] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; +const char tabs[] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; static size_t cacheline_size; -size_t tag__nr_cachelines(const struct tag *self, const struct cu *cu) +size_t tag__nr_cachelines(const struct tag *tag, const struct cu *cu) { - return (tag__size(self, cu) + cacheline_size - 1) / cacheline_size; + return (tag__size(tag, cu) + cacheline_size - 1) / cacheline_size; } -static const char *tag__accessibility(const struct tag *self) +static const char *tag__accessibility(const struct tag *tag) { int a; - switch (self->tag) { + switch (tag->tag) { case DW_TAG_inheritance: case DW_TAG_member: - a = tag__class_member(self)->accessibility; + a = tag__class_member(tag)->accessibility; break; case DW_TAG_subprogram: - a = tag__function(self)->accessibility; + a = tag__function(tag)->accessibility; break; default: return NULL; @@ -158,7 +163,7 @@ return NULL; } -static size_t __tag__id_not_found_snprintf(char *bf, size_t len, uint16_t id, +static size_t __tag__id_not_found_snprintf(char *bf, size_t len, uint32_t id, const char *fn, int line) { return snprintf(bf, len, "", fn, line, @@ -168,69 +173,97 @@ #define tag__id_not_found_snprintf(bf, len, id) \ __tag__id_not_found_snprintf(bf, len, id, __func__, __LINE__) -size_t tag__fprintf_decl_info(const struct tag *self, +size_t tag__fprintf_decl_info(const struct tag *tag, const struct cu *cu, FILE *fp) { - return fprintf(fp, "/* <%llx> %s:%u */\n", tag__orig_id(self, cu), - tag__decl_file(self, cu), tag__decl_line(self, cu)); + return fprintf(fp, "/* <%llx> %s:%u */\n", tag__orig_id(tag, cu), + tag__decl_file(tag, cu), tag__decl_line(tag, cu)); return 0; } +static size_t __class__fprintf(struct class *class, const struct cu *cu, + const struct conf_fprintf *conf, FILE *fp); static size_t type__fprintf(struct tag *type, const struct cu *cu, const char *name, const struct conf_fprintf *conf, FILE *fp); -static size_t array_type__fprintf(const struct tag *tag_self, +static size_t array_type__fprintf(const struct tag *tag, const struct cu *cu, const char *name, const struct conf_fprintf *conf, FILE *fp) { - struct array_type *self = tag__array_type(tag_self); - struct tag *type = cu__type(cu, tag_self->type); + struct array_type *at = tag__array_type(tag); + struct tag *type = cu__type(cu, tag->type); size_t printed; unsigned long long flat_dimensions = 0; int i; if (type == NULL) - return tag__id_not_found_fprintf(fp, tag_self->type); + return tag__id_not_found_fprintf(fp, tag->type); + + /* Zero sized arrays? */ + if (at->dimensions >= 1 && at->nr_entries[0] == 0 && tag__is_const(type)) + type = cu__type(cu, type->type); printed = type__fprintf(type, cu, name, conf, fp); - for (i = 0; i < self->dimensions; ++i) { - if (conf->flat_arrays || self->is_vector) { + for (i = 0; i < at->dimensions; ++i) { + if (conf->flat_arrays || at->is_vector) { /* * Seen on the Linux kernel on tun_filter: * * __u8 addr[0][ETH_ALEN]; */ - if (self->nr_entries[i] == 0 && i == 0) + if (at->nr_entries[i] == 0 && i == 0) break; if (!flat_dimensions) - flat_dimensions = self->nr_entries[i]; + flat_dimensions = at->nr_entries[i]; else - flat_dimensions *= self->nr_entries[i]; - } else - printed += fprintf(fp, "[%u]", self->nr_entries[i]); + flat_dimensions *= at->nr_entries[i]; + } else { + bool single_member = conf->last_member && conf->first_member; + + if (at->nr_entries[i] != 0 || !conf->last_member || single_member || conf->union_member) + printed += fprintf(fp, "[%u]", at->nr_entries[i]); + else + printed += fprintf(fp, "[]"); + } } - if (self->is_vector) { - type = tag__follow_typedef(tag_self, cu); + if (at->is_vector) { + type = tag__follow_typedef(tag, cu); if (flat_dimensions == 0) flat_dimensions = 1; printed += fprintf(fp, " __attribute__ ((__vector_size__ (%llu)))", flat_dimensions * tag__size(type, cu)); - } else if (conf->flat_arrays) - printed += fprintf(fp, "[%llu]", flat_dimensions); + } else if (conf->flat_arrays) { + bool single_member = conf->last_member && conf->first_member; + + if (flat_dimensions != 0 || !conf->last_member || single_member || conf->union_member) + printed += fprintf(fp, "[%llu]", flat_dimensions); + else + printed += fprintf(fp, "[]"); + } return printed; } -size_t typedef__fprintf(const struct tag *tag_self, const struct cu *cu, +static size_t string_type__fprintf(const struct tag *tag, + const struct cu *cu, const char *name, + const struct conf_fprintf *conf, + FILE *fp) +{ + struct string_type *st = tag__string_type(tag); + + return fprintf(fp, "string %*s[%u]", conf->type_spacing - 5, name, st->nr_entries); +} + +size_t typedef__fprintf(const struct tag *tag, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp) { - struct type *self = tag__type(tag_self); + struct type *type = tag__type(tag); const struct conf_fprintf *pconf = conf ?: &conf_fprintf__defaults; - const struct tag *type; + const struct tag *tag_type; const struct tag *ptr_type; char bf[512]; int is_pointer = 0; @@ -240,79 +273,95 @@ * Check for void (humm, perhaps we should have a fake void tag instance * to avoid all these checks? */ - if (tag_self->type == 0) - return fprintf(fp, "typedef void %s", type__name(self, cu)); + if (tag->type == 0) + return fprintf(fp, "typedef void %s", type__name(type, cu)); - type = cu__type(cu, tag_self->type); - if (type == NULL) { + tag_type = cu__type(cu, tag->type); + if (tag_type == NULL) { printed = fprintf(fp, "typedef "); - printed += tag__id_not_found_fprintf(fp, tag_self->type); - return printed + fprintf(fp, " %s", type__name(self, cu)); + printed += tag__id_not_found_fprintf(fp, tag->type); + return printed + fprintf(fp, " %s", type__name(type, cu)); } - switch (type->tag) { + switch (tag_type->tag) { case DW_TAG_array_type: printed = fprintf(fp, "typedef "); - return printed + array_type__fprintf(type, cu, - type__name(self, cu), + return printed + array_type__fprintf(tag_type, cu, + type__name(type, cu), pconf, fp); case DW_TAG_pointer_type: - if (type->type == 0) /* void pointer */ + if (tag_type->type == 0) /* void pointer */ break; - ptr_type = cu__type(cu, type->type); + ptr_type = cu__type(cu, tag_type->type); if (ptr_type == NULL) { printed = fprintf(fp, "typedef "); - printed += tag__id_not_found_fprintf(fp, type->type); + printed += tag__id_not_found_fprintf(fp, tag_type->type); return printed + fprintf(fp, " *%s", - type__name(self, cu)); + type__name(type, cu)); } if (ptr_type->tag != DW_TAG_subroutine_type) break; - type = ptr_type; + tag_type = ptr_type; is_pointer = 1; /* Fall thru */ case DW_TAG_subroutine_type: printed = fprintf(fp, "typedef "); - return printed + ftype__fprintf(tag__ftype(type), cu, - type__name(self, cu), + return printed + ftype__fprintf(tag__ftype(tag_type), cu, + type__name(type, cu), 0, is_pointer, 0, - pconf, fp); + true, pconf, fp); case DW_TAG_class_type: case DW_TAG_structure_type: { - struct type *ctype = tag__type(type); + struct type *ctype = tag__type(tag_type); if (type__name(ctype, cu) != NULL) return fprintf(fp, "typedef struct %s %s", type__name(ctype, cu), - type__name(self, cu)); + type__name(type, cu)); + + struct conf_fprintf tconf = *pconf; + + tconf.suffix = type__name(type, cu); + return fprintf(fp, "typedef ") + __class__fprintf(tag__class(tag_type), cu, &tconf, fp); + } + case DW_TAG_enumeration_type: { + struct type *ctype = tag__type(tag_type); + + if (type__name(ctype, cu) != NULL) + return fprintf(fp, "typedef enum %s %s", type__name(ctype, cu), type__name(type, cu)); + + struct conf_fprintf tconf = *pconf; + + tconf.suffix = type__name(type, cu); + return fprintf(fp, "typedef ") + enumeration__fprintf(tag_type, cu, &tconf, fp); } } return fprintf(fp, "typedef %s %s", - tag__name(type, cu, bf, sizeof(bf), pconf), - type__name(self, cu)); + tag__name(tag_type, cu, bf, sizeof(bf), pconf), + type__name(type, cu)); } -static size_t imported_declaration__fprintf(const struct tag *self, +static size_t imported_declaration__fprintf(const struct tag *tag, const struct cu *cu, FILE *fp) { char bf[BUFSIZ]; size_t printed = fprintf(fp, "using ::"); - const struct tag *decl = cu__function(cu, self->type); + const struct tag *decl = cu__function(cu, tag->type); if (decl == NULL) { - decl = cu__tag(cu, self->type); + decl = cu__tag(cu, tag->type); if (decl == NULL) - return printed + tag__id_not_found_fprintf(fp, self->type); + return printed + tag__id_not_found_fprintf(fp, tag->type); } return printed + fprintf(fp, "%s", tag__name(decl, cu, bf, sizeof(bf), NULL)); } -static size_t imported_module__fprintf(const struct tag *self, +static size_t imported_module__fprintf(const struct tag *tag, const struct cu *cu, FILE *fp) { - const struct tag *module = cu__tag(cu, self->type); + const struct tag *module = cu__tag(cu, tag->type); const char *name = ""; if (tag__is_namespace(module)) @@ -321,25 +370,57 @@ return fprintf(fp, "using namespace %s", name); } -size_t enumeration__fprintf(const struct tag *tag_self, const struct cu *cu, +int enumeration__max_entry_name_len(struct type *type, const struct cu *cu) +{ + if (type->max_tag_name_len) + goto out; + + struct enumerator *pos; + + type__for_each_enumerator(type, pos) { + int len = strlen(enumerator__name(pos, cu)); + + if (type->max_tag_name_len < len) + type->max_tag_name_len = len; + } +out: + return type->max_tag_name_len; +} + +size_t enumeration__fprintf(const struct tag *tag, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp) { - struct type *self = tag__type(tag_self); + struct type *type = tag__type(tag); struct enumerator *pos; + int max_entry_name_len = enumeration__max_entry_name_len(type, cu); size_t printed = fprintf(fp, "enum%s%s {\n", - type__name(self, cu) ? " " : "", - type__name(self, cu) ?: ""); + type__name(type, cu) ? " " : "", + type__name(type, cu) ?: ""); int indent = conf->indent; if (indent >= (int)sizeof(tabs)) indent = sizeof(tabs) - 1; - type__for_each_enumerator(self, pos) - printed += fprintf(fp, "%.*s\t%s = %u,\n", indent, tabs, - enumerator__name(pos, cu), pos->value); + type__for_each_enumerator(type, pos) { + printed += fprintf(fp, "%.*s\t%-*s = ", indent, tabs, + max_entry_name_len, enumerator__name(pos, cu)); + printed += fprintf(fp, conf->hex_fmt ? "%#x" : "%u", pos->value); + printed += fprintf(fp, ",\n"); + } - return printed + fprintf(fp, "%.*s}%s%s", indent, tabs, - conf->suffix ? " " : "", conf->suffix ?: ""); + printed += fprintf(fp, "%.*s}", indent, tabs); + + /* + * XXX: find out how to precisely determine the max size for an + * enumeration, use sizeof(int) for now. + */ + if (type->size / 8 != sizeof(int)) + printed += fprintf(fp, " %s", "__attribute__((__packed__))"); + + if (conf->suffix) + printed += fprintf(fp, " %s", conf->suffix); + + return printed; } static const char *tag__prefix(const struct cu *cu, const uint32_t tag, @@ -361,28 +442,38 @@ return ""; } -static const char *__tag__name(const struct tag *self, const struct cu *cu, +static const char *__tag__name(const struct tag *tag, const struct cu *cu, char *bf, size_t len, const struct conf_fprintf *conf); -static const char *tag__ptr_name(const struct tag *self, const struct cu *cu, +static const char *tag__ptr_name(const struct tag *tag, const struct cu *cu, char *bf, size_t len, const char *ptr_suffix) { - if (self->type == 0) /* No type == void */ + if (tag->type == 0) /* No type == void */ snprintf(bf, len, "void %s", ptr_suffix); else { - const struct tag *type = cu__type(cu, self->type); + const struct tag *type = cu__type(cu, tag->type); if (type == NULL) { - size_t l = tag__id_not_found_snprintf(bf, len, - self->type); + size_t l = tag__id_not_found_snprintf(bf, len, tag->type); snprintf(bf + l, len - l, " %s", ptr_suffix); - } else if (!tag__has_type_loop(self, type, bf, len, NULL)) { + } else if (!tag__has_type_loop(tag, type, bf, len, NULL)) { char tmpbf[1024]; + const char *const_pointer = ""; - snprintf(bf, len, "%s %s", + if (tag__is_const(type)) { + struct tag *next_type = cu__type(cu, type->type); + + if (next_type && tag__is_pointer(next_type)) { + const_pointer = "const "; + type = next_type; + } + } + + snprintf(bf, len, "%s %s%s", __tag__name(type, cu, tmpbf, sizeof(tmpbf), NULL), + const_pointer, ptr_suffix); } } @@ -390,38 +481,38 @@ return bf; } -static const char *__tag__name(const struct tag *self, const struct cu *cu, +static const char *__tag__name(const struct tag *tag, const struct cu *cu, char *bf, size_t len, const struct conf_fprintf *conf) { struct tag *type; const struct conf_fprintf *pconf = conf ?: &conf_fprintf__defaults; - if (self == NULL) + if (tag == NULL) strncpy(bf, "void", len); - else switch (self->tag) { + else switch (tag->tag) { case DW_TAG_base_type: { - const struct base_type *bt = tag__base_type(self); + const struct base_type *bt = tag__base_type(tag); const char *name = "nameless base type!"; char bf2[64]; if (bt->name) - name = base_type__name(tag__base_type(self), cu, + name = base_type__name(tag__base_type(tag), cu, bf2, sizeof(bf2)); strncpy(bf, name, len); } break; case DW_TAG_subprogram: - strncpy(bf, function__name(tag__function(self), cu), len); + strncpy(bf, function__name(tag__function(tag), cu), len); break; case DW_TAG_pointer_type: - return tag__ptr_name(self, cu, bf, len, "*"); + return tag__ptr_name(tag, cu, bf, len, "*"); case DW_TAG_reference_type: - return tag__ptr_name(self, cu, bf, len, "&"); + return tag__ptr_name(tag, cu, bf, len, "&"); case DW_TAG_ptr_to_member_type: { char suffix[512]; - uint16_t id = tag__ptr_to_member_type(self)->containing_type; + type_id_t id = tag__ptr_to_member_type(tag)->containing_type; type = cu__type(cu, id); if (type != NULL) @@ -434,37 +525,41 @@ snprintf(suffix + l, sizeof(suffix) - l, "::*"); } - return tag__ptr_name(self, cu, bf, len, suffix); + return tag__ptr_name(tag, cu, bf, len, suffix); } case DW_TAG_volatile_type: case DW_TAG_const_type: - type = cu__type(cu, self->type); - if (type == NULL && self->type != 0) - tag__id_not_found_snprintf(bf, len, self->type); - else if (!tag__has_type_loop(self, type, bf, len, NULL)) { + case DW_TAG_restrict_type: + case DW_TAG_unspecified_type: + type = cu__type(cu, tag->type); + if (type == NULL && tag->type != 0) + tag__id_not_found_snprintf(bf, len, tag->type); + else if (!tag__has_type_loop(tag, type, bf, len, NULL)) { char tmpbf[128]; - const char *prefix = "const", + const char *prefix = "", *suffix = "", *type_str = __tag__name(type, cu, tmpbf, sizeof(tmpbf), pconf); - if (self->tag == DW_TAG_volatile_type) - prefix = "volatile"; - snprintf(bf, len, "%s %s ", prefix, type_str); + switch (tag->tag) { + case DW_TAG_volatile_type: prefix = "volatile "; break; + case DW_TAG_const_type: prefix = "const "; break; + case DW_TAG_restrict_type: suffix = " restrict"; break; + } + snprintf(bf, len, "%s%s%s ", prefix, type_str, suffix); } break; case DW_TAG_array_type: - type = cu__type(cu, self->type); + type = cu__type(cu, tag->type); if (type == NULL) - tag__id_not_found_snprintf(bf, len, self->type); - else if (!tag__has_type_loop(self, type, bf, len, NULL)) + tag__id_not_found_snprintf(bf, len, tag->type); + else if (!tag__has_type_loop(tag, type, bf, len, NULL)) return __tag__name(type, cu, bf, len, pconf); break; case DW_TAG_subroutine_type: { FILE *bfp = fmemopen(bf, len, "w"); if (bfp != NULL) { - ftype__fprintf(tag__ftype(self), cu, NULL, 0, 0, 0, - pconf, bfp); + ftype__fprintf(tag__ftype(tag), cu, NULL, 0, 0, 0, true, pconf, bfp); fclose(bfp); } else snprintf(bf, len, "", @@ -472,64 +567,71 @@ } break; case DW_TAG_member: - snprintf(bf, len, "%s", class_member__name(tag__class_member(self), cu)); + snprintf(bf, len, "%s", class_member__name(tag__class_member(tag), cu)); break; case DW_TAG_variable: - snprintf(bf, len, "%s", variable__name(tag__variable(self), cu)); + snprintf(bf, len, "%s", variable__name(tag__variable(tag), cu)); break; default: - snprintf(bf, len, "%s%s", tag__prefix(cu, self->tag, pconf), - type__name(tag__type(self), cu) ?: ""); + snprintf(bf, len, "%s%s", tag__prefix(cu, tag->tag, pconf), + type__name(tag__type(tag), cu) ?: ""); break; } return bf; } -const char *tag__name(const struct tag *self, const struct cu *cu, +const char *tag__name(const struct tag *tag, const struct cu *cu, char *bf, size_t len, const struct conf_fprintf *conf) { - bool starts_with_const = false; + int printed = 0; - if (self == NULL) { + if (tag == NULL) { strncpy(bf, "void", len); return bf; } - if (self->tag == DW_TAG_const_type) { - starts_with_const = true; - self = cu__type(cu, self->type); - } - - __tag__name(self, cu, bf, len, conf); - - if (starts_with_const) - strncat(bf, "const", len); + __tag__name(tag, cu, bf + printed, len - printed, conf); return bf; } static const char *variable__prefix(const struct variable *var) { - switch (var->location) { - case LOCATION_REGISTER: + switch (variable__scope(var)) { + case VSCOPE_REGISTER: return "register "; - case LOCATION_UNKNOWN: + case VSCOPE_UNKNOWN: if (var->external && var->declaration) return "extern "; break; - case LOCATION_GLOBAL: + case VSCOPE_GLOBAL: if (!var->external) return "static "; break; - case LOCATION_LOCAL: - case LOCATION_OPTIMIZED: + case VSCOPE_LOCAL: + case VSCOPE_OPTIMIZED: break; } return NULL; } -static size_t union__fprintf(struct type *self, const struct cu *cu, +static size_t type__fprintf_stats(struct type *type, const struct cu *cu, + const struct conf_fprintf *conf, FILE *fp) +{ + size_t printed = fprintf(fp, "\n%.*s/* size: %d, cachelines: %zd, members: %u", + conf->indent, tabs, type->size, + tag__nr_cachelines(type__tag(type), cu), type->nr_members); + + if (type->nr_static_members != 0) + printed += fprintf(fp, ", static members: %u */\n", type->nr_static_members); + else + printed += fprintf(fp, " */\n"); + + return printed; +} + +static size_t union__fprintf(struct type *type, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp); static size_t type__fprintf(struct tag *type, const struct cu *cu, @@ -538,8 +640,12 @@ { char tbf[128]; char namebf[256]; + char namebfptr[258]; struct type *ctype; - struct conf_fprintf tconf; + struct tag *type_expanded = NULL; + struct conf_fprintf tconf = { + .type_spacing = conf->type_spacing, + }; size_t printed = 0; int expand_types = conf->expand_types; int suppress_offset_comment = conf->suppress_offset_comment; @@ -550,7 +656,7 @@ if (conf->expand_pointers) { int nr_indirections = 0; - while (type->tag == DW_TAG_pointer_type && type->type != 0) { + while (tag__is_pointer(type) && type->type != 0) { struct tag *ttype = cu__type(cu, type->type); if (ttype == NULL) goto out_type_not_found; @@ -582,6 +688,7 @@ if (type->recursivity_level != 0) expand_types = 0; ++type->recursivity_level; + type_expanded = type; } if (expand_types) { @@ -612,16 +719,18 @@ printed += fprintf(fp, " */ "); } + tconf = *conf; + if (tag__is_struct(type) || tag__is_union(type) || tag__is_enumeration(type)) { - tconf = *conf; - tconf.type_spacing -= 8; +inner_struct: tconf.prefix = NULL; tconf.suffix = name; tconf.emit_stats = 0; tconf.suppress_offset_comment = suppress_offset_comment; } +next_type: switch (type->tag) { case DW_TAG_pointer_type: if (type->type != 0) { @@ -635,117 +744,199 @@ if (ptype->tag == DW_TAG_subroutine_type) { printed += ftype__fprintf(tag__ftype(ptype), cu, name, 0, 1, - conf->type_spacing, - conf, fp); + tconf.type_spacing, true, + &tconf, fp); break; } + if ((tag__is_struct(ptype) || tag__is_union(ptype) || + tag__is_enumeration(ptype)) && type__name(tag__type(ptype), cu) == NULL) { + if (name == namebfptr) + goto out_type_not_found; + snprintf(namebfptr, sizeof(namebfptr), "* %.*s", (int)sizeof(namebfptr) - 3, name); + tconf.rel_offset = 1; + name = namebfptr; + type = ptype; + tconf.type_spacing -= 8; + goto inner_struct; + } } /* Fall Thru */ default: - printed += fprintf(fp, "%-*s %s", conf->type_spacing, - tag__name(type, cu, tbf, sizeof(tbf), conf), +print_default: + printed += fprintf(fp, "%-*s %s", tconf.type_spacing, + tag__name(type, cu, tbf, sizeof(tbf), &tconf), name); break; case DW_TAG_subroutine_type: printed += ftype__fprintf(tag__ftype(type), cu, name, 0, 0, - conf->type_spacing, conf, fp); + tconf.type_spacing, true, &tconf, fp); break; + case DW_TAG_const_type: { + size_t const_printed = fprintf(fp, "%s ", "const"); + tconf.type_spacing -= const_printed; + printed += const_printed; + + struct tag *ttype = cu__type(cu, type->type); + if (ttype) { + type = ttype; + goto next_type; + } + } + goto print_default; + case DW_TAG_array_type: - printed += array_type__fprintf(type, cu, name, conf, fp); + printed += array_type__fprintf(type, cu, name, &tconf, fp); + break; + case DW_TAG_string_type: + printed += string_type__fprintf(type, cu, name, &tconf, fp); break; case DW_TAG_class_type: case DW_TAG_structure_type: ctype = tag__type(type); - if (type__name(ctype, cu) != NULL && !expand_types) + if (type__name(ctype, cu) != NULL && !expand_types) { printed += fprintf(fp, "%s %-*s %s", (type->tag == DW_TAG_class_type && - !conf->classes_as_structs) ? "class" : "struct", - conf->type_spacing - 7, + !tconf.classes_as_structs) ? "class" : "struct", + tconf.type_spacing - 7, type__name(ctype, cu), name); - else - printed += class__fprintf(tag__class(type), - cu, &tconf, fp); + } else { + struct class *cclass = tag__class(type); + + if (!tconf.suppress_comments) + class__find_holes(cclass); + + tconf.type_spacing -= 8; + printed += __class__fprintf(cclass, cu, &tconf, fp); + } break; case DW_TAG_union_type: ctype = tag__type(type); - if (type__name(ctype, cu) != NULL && !expand_types) + if (type__name(ctype, cu) != NULL && !expand_types) { printed += fprintf(fp, "union %-*s %s", - conf->type_spacing - 6, + tconf.type_spacing - 6, type__name(ctype, cu), name); - else + } else { + tconf.type_spacing -= 8; printed += union__fprintf(ctype, cu, &tconf, fp); + } break; case DW_TAG_enumeration_type: ctype = tag__type(type); if (type__name(ctype, cu) != NULL) printed += fprintf(fp, "enum %-*s %s", - conf->type_spacing - 5, + tconf.type_spacing - 5, type__name(ctype, cu), name); else printed += enumeration__fprintf(type, cu, &tconf, fp); break; } out: - if (conf->expand_types) - --type->recursivity_level; + if (type_expanded) + --type_expanded->recursivity_level; return printed; out_type_not_found: - printed = fprintf(fp, "%-*s %s", conf->type_spacing, "", name); + printed = fprintf(fp, "%-*s%s> %s", tconf.type_spacing, "byte_size; + const int size = member->byte_size; struct conf_fprintf sconf = *conf; - uint32_t offset = self->byte_offset; - size_t printed = 0; - const char *cm_name = class_member__name(self, cu), + uint32_t offset = member->byte_offset; + size_t printed = 0, printed_cacheline = 0; + const char *cm_name = class_member__name(member, cu), *name = cm_name; if (!sconf.rel_offset) { - sconf.base_offset += self->byte_offset; - offset = sconf.base_offset; + offset += sconf.base_offset; + if (!union_member) + sconf.base_offset = offset; } - if (self->tag.tag == DW_TAG_inheritance) { + if (member->bitfield_offset < 0) + offset += member->byte_size; + + if (!conf->suppress_comments) + printed_cacheline = class__fprintf_cacheline_boundary(conf, offset, fp); + + if (member->tag.tag == DW_TAG_inheritance) { name = ""; printed += fprintf(fp, "/* "); } + if (member->is_static) + printed += fprintf(fp, "static "); + printed += type__fprintf(type, cu, name, &sconf, fp); - if (self->bitfield_size != 0) - printed += fprintf(fp, ":%u;", self->bitfield_size); - else { - fputc(';', fp); - ++printed; + if (member->is_static) { + if (member->const_value != 0) + printed += fprintf(fp, " = %" PRIu64, member->const_value); + } else if (member->bitfield_size != 0) { + printed += fprintf(fp, ":%u", member->bitfield_size); } + if (!sconf.suppress_aligned_attribute && member->alignment != 0) + printed += fprintf(fp, " __attribute__((__aligned__(%u)))", member->alignment); + + fputc(';', fp); + ++printed; + if ((tag__is_union(type) || tag__is_struct(type) || tag__is_enumeration(type)) && /* Look if is a type defined inline */ type__name(tag__type(type), cu) == NULL) { if (!sconf.suppress_offset_comment) { /* Check if this is a anonymous union */ - const int slen = cm_name ? (int)strlen(cm_name) : -1; + int slen = cm_name ? (int)strlen(cm_name) : -1; + int size_spacing = 5; + + if (tag__is_struct(type) && tag__class(type)->is_packed && !conf->suppress_packed) { + int packed_len = sizeof("__attribute__((__packed__))"); + slen += packed_len; + } + + if (tag__type(type)->alignment != 0 && !conf->suppress_aligned_attribute) { + char bftmp[64]; + int aligned_len = snprintf(bftmp, sizeof(bftmp), " __attribute__((__aligned__(%u)))", tag__type(type)->alignment); + slen += aligned_len; + } + printed += fprintf(fp, sconf.hex_fmt ? - "%*s/* %#5x %#5x */" : - "%*s/* %5u %5u */", + "%*s/* %#5x" : + "%*s/* %5u", (sconf.type_spacing + sconf.name_spacing - slen - 3), - " ", offset, size); + " ", offset); + + if (member->bitfield_size != 0) { + unsigned int bitfield_offset = member->bitfield_offset; + + if (member->bitfield_offset < 0) + bitfield_offset = member->byte_size * 8 + member->bitfield_offset; + + printed += fprintf(fp, sconf.hex_fmt ? ":%#2x" : ":%2u", bitfield_offset); + size_spacing -= 3; + } + + printed += fprintf(fp, sconf.hex_fmt ? " %#*x */" : " %*u */", size_spacing, size); } } else { int spacing = sconf.type_spacing + sconf.name_spacing - printed; - if (self->tag.tag == DW_TAG_inheritance) { + if (member->tag.tag == DW_TAG_inheritance) { const size_t p = fprintf(fp, " */"); printed += p; spacing -= p; @@ -758,10 +949,15 @@ spacing > 0 ? spacing : 0, " ", offset); - if (self->bitfield_size != 0) { + if (member->bitfield_size != 0) { + unsigned int bitfield_offset = member->bitfield_offset; + + if (member->bitfield_offset < 0) + bitfield_offset = member->byte_size * 8 + member->bitfield_offset; + printed += fprintf(fp, sconf.hex_fmt ? ":%#2x" : ":%2u", - self->bitfield_offset); + bitfield_offset); size_spacing -= 3; } @@ -770,94 +966,96 @@ size_spacing, size); } } - return printed; + return printed + printed_cacheline; } -static size_t union_member__fprintf(struct class_member *self, - struct tag *type, const struct cu *cu, - const struct conf_fprintf *conf, FILE *fp) +static size_t struct_member__fprintf(struct class_member *member, + struct tag *type, const struct cu *cu, + struct conf_fprintf *conf, FILE *fp) { - const size_t size = self->byte_size; - const char *name = class_member__name(self, cu); - size_t printed = type__fprintf(type, cu, name, conf, fp); - - if ((tag__is_union(type) || tag__is_struct(type) || - tag__is_enumeration(type)) && - /* Look if is a type defined inline */ - type__name(tag__type(type), cu) == NULL) { - if (!conf->suppress_offset_comment) { - /* Check if this is a anonymous union */ - const int slen = name ? (int)strlen(name) : -1; - /* - * Add the comment with the union size after padding the - * '} member_name;' last line of the type printed in the - * above call to type__fprintf. - */ - printed += fprintf(fp, conf->hex_fmt ? - ";%*s/* %#11zx */" : - ";%*s/* %11zd */", - (conf->type_spacing + - conf->name_spacing - slen - 3), " ", size); - } - } else { - printed += fprintf(fp, ";"); - - if (!conf->suppress_offset_comment) { - const int spacing = conf->type_spacing + conf->name_spacing - printed; - printed += fprintf(fp, conf->hex_fmt ? - "%*s/* %#11zx */" : - "%*s/* %11zd */", - spacing > 0 ? spacing : 0, " ", size); - } - } + return class_member__fprintf(member, false, type, cu, conf, fp); +} - return printed; +static size_t union_member__fprintf(struct class_member *member, + struct tag *type, const struct cu *cu, + struct conf_fprintf *conf, FILE *fp) +{ + return class_member__fprintf(member, true, type, cu, conf, fp); } -static size_t union__fprintf(struct type *self, const struct cu *cu, +static size_t union__fprintf(struct type *type, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp) { struct class_member *pos; size_t printed = 0; int indent = conf->indent; struct conf_fprintf uconf; + uint32_t initial_union_cacheline; + uint32_t cacheline = 0; /* This will only be used if this is the outermost union */ if (indent >= (int)sizeof(tabs)) indent = sizeof(tabs) - 1; if (conf->prefix != NULL) printed += fprintf(fp, "%s ", conf->prefix); - printed += fprintf(fp, "union%s%s {\n", type__name(self, cu) ? " " : "", - type__name(self, cu) ?: ""); + printed += fprintf(fp, "union%s%s {\n", type__name(type, cu) ? " " : "", + type__name(type, cu) ?: ""); uconf = *conf; uconf.indent = indent + 1; - type__for_each_member(self, pos) { - struct tag *type = cu__type(cu, pos->tag.type); - if (type == NULL) { + /* + * If structs embedded in unions, nameless or not, have a size which isn't + * isn't a multiple of the union size, then it must be packed, even if + * it has no holes nor padding, as an array of such unions would have the + * natural alignments of non-multiple structs inside it broken. + */ + union__infer_packed_attributes(type, cu); + + /* + * We may be called directly or from tag__fprintf, so keep sure + * we keep track of the cacheline we're in. + * + * If we're being called from an outer structure, i.e. union within + * struct, class or another union, then this will already have a + * value and we'll continue to use it. + */ + if (uconf.cachelinep == NULL) + uconf.cachelinep = &cacheline; + /* + * Save the cacheline we're in, then, after each union member, get + * back to it. Else we'll end up showing cacheline boundaries in + * just the first of a multi struct union, for instance. + */ + initial_union_cacheline = *uconf.cachelinep; + type__for_each_member(type, pos) { + struct tag *pos_type = cu__type(cu, pos->tag.type); + + if (pos_type == NULL) { printed += fprintf(fp, "%.*s", uconf.indent, tabs); printed += tag__id_not_found_fprintf(fp, pos->tag.type); continue; } + uconf.union_member = 1; printed += fprintf(fp, "%.*s", uconf.indent, tabs); - printed += union_member__fprintf(pos, type, cu, &uconf, fp); + printed += union_member__fprintf(pos, pos_type, cu, &uconf, fp); fputc('\n', fp); ++printed; + *uconf.cachelinep = initial_union_cacheline; } return printed + fprintf(fp, "%.*s}%s%s", indent, tabs, conf->suffix ? " " : "", conf->suffix ?: ""); } -const char *function__prototype(const struct function *self, +const char *function__prototype(const struct function *func, const struct cu *cu, char *bf, size_t len) { FILE *bfp = fmemopen(bf, len, "w"); if (bfp != NULL) { - ftype__fprintf(&self->proto, cu, NULL, 0, 0, 0, + ftype__fprintf(&func->proto, cu, NULL, 0, 0, 0, true, &conf_fprintf__defaults, bfp); fclose(bfp); } else @@ -866,7 +1064,7 @@ return bf; } -size_t ftype__fprintf_parms(const struct ftype *self, +size_t ftype__fprintf_parms(const struct ftype *ftype, const struct cu *cu, int indent, const struct conf_fprintf *conf, FILE *fp) { @@ -877,7 +1075,7 @@ const char *name, *stype; size_t printed = fprintf(fp, "("); - ftype__for_each_parameter(self, pos) { + ftype__for_each_parameter(ftype, pos) { if (!first_parm) { if (indent == 0) printed += fprintf(fp, ", "); @@ -894,7 +1092,7 @@ stype = sbf; goto print_it; } - if (type->tag == DW_TAG_pointer_type) { + if (tag__is_pointer(type)) { if (type->type != 0) { int n; struct tag *ptype = cu__type(cu, type->type); @@ -910,13 +1108,13 @@ printed += ftype__fprintf(tag__ftype(ptype), cu, name, 0, 1, 0, - conf, fp); + true, conf, fp); continue; } } } else if (type->tag == DW_TAG_subroutine_type) { printed += ftype__fprintf(tag__ftype(type), cu, name, - 0, 0, 0, conf, fp); + true, 0, 0, 0, conf, fp); continue; } stype = tag__name(type, cu, sbf, sizeof(sbf), conf); @@ -928,7 +1126,7 @@ /* No parameters? */ if (first_parm) printed += fprintf(fp, "void)"); - else if (self->unspec_parms) + else if (ftype->unspec_parms) printed += fprintf(fp, ", ...)"); else printed += fprintf(fp, ")"); @@ -981,9 +1179,10 @@ break; case DW_TAG_variable: printed = fprintf(fp, "%.*s", indent, tabs); - n = fprintf(fp, "%s %s;", + n = fprintf(fp, "%s %s; /* scope: %s */", variable__type_name(vtag, cu, bf, sizeof(bf)), - variable__name(vtag, cu)); + variable__name(vtag, cu), + variable__scope_str(vtag)); c += n; printed += n; break; @@ -1013,7 +1212,7 @@ tag__decl_line(tag, cu)); } -size_t lexblock__fprintf(const struct lexblock *self, const struct cu *cu, +size_t lexblock__fprintf(const struct lexblock *block, const struct cu *cu, struct function *function, uint16_t indent, const struct conf_fprintf *conf, FILE *fp) { @@ -1023,142 +1222,130 @@ if (indent >= sizeof(tabs)) indent = sizeof(tabs) - 1; printed = fprintf(fp, "%.*s{", indent, tabs); - if (self->ip.addr != 0) { - uint64_t offset = self->ip.addr - function->lexblock.ip.addr; + if (block->ip.addr != 0) { + uint64_t offset = block->ip.addr - function->lexblock.ip.addr; if (offset == 0) printed += fprintf(fp, " /* low_pc=%#llx */", - (unsigned long long)self->ip.addr); + (unsigned long long)block->ip.addr); else printed += fprintf(fp, " /* %s+%#llx */", function__name(function, cu), (unsigned long long)offset); } printed += fprintf(fp, "\n"); - list_for_each_entry(pos, &self->tags, node) + list_for_each_entry(pos, &block->tags, node) printed += function__tag_fprintf(pos, cu, function, indent + 1, conf, fp); printed += fprintf(fp, "%.*s}", indent, tabs); - if (function->lexblock.ip.addr != self->ip.addr) - printed += fprintf(fp, " /* lexblock size=%d */", self->size); + if (function->lexblock.ip.addr != block->ip.addr) + printed += fprintf(fp, " /* lexblock size=%d */", block->size); return printed; } -size_t ftype__fprintf(const struct ftype *self, const struct cu *cu, +size_t ftype__fprintf(const struct ftype *ftype, const struct cu *cu, const char *name, const int inlined, - const int is_pointer, int type_spacing, + const int is_pointer, int type_spacing, bool is_prototype, const struct conf_fprintf *conf, FILE *fp) { - struct tag *type = cu__type(cu, self->tag.type); + struct tag *type = cu__type(cu, ftype->tag.type); char sbf[128]; const char *stype = tag__name(type, cu, sbf, sizeof(sbf), conf); size_t printed = fprintf(fp, "%s%-*s %s%s%s%s", inlined ? "inline " : "", type_spacing, stype, - self->tag.tag == DW_TAG_subroutine_type ? - "(" : "", + is_prototype ? "(" : "", is_pointer ? "*" : "", name ?: "", - self->tag.tag == DW_TAG_subroutine_type ? - ")" : ""); + is_prototype ? ")" : ""); - return printed + ftype__fprintf_parms(self, cu, 0, conf, fp); + return printed + ftype__fprintf_parms(ftype, cu, 0, conf, fp); } -static size_t function__fprintf(const struct tag *tag_self, - const struct cu *cu, - const struct conf_fprintf *conf, - FILE *fp) +static size_t function__fprintf(const struct tag *tag, const struct cu *cu, + const struct conf_fprintf *conf, FILE *fp) { - struct function *self = tag__function(tag_self); + struct function *func = tag__function(tag); + struct ftype *ftype = func->btf ? tag__ftype(cu__type(cu, func->proto.tag.type)) : &func->proto; size_t printed = 0; + bool inlined = !conf->strip_inline && function__declared_inline(func); - if (self->virtuality == DW_VIRTUALITY_virtual || - self->virtuality == DW_VIRTUALITY_pure_virtual) + if (func->virtuality == DW_VIRTUALITY_virtual || + func->virtuality == DW_VIRTUALITY_pure_virtual) printed += fprintf(fp, "virtual "); - printed += ftype__fprintf(&self->proto, cu, function__name(self, cu), - function__declared_inline(self), 0, 0, - conf, fp); + printed += ftype__fprintf(ftype, cu, function__name(func, cu), + inlined, 0, 0, false, conf, fp); - if (self->virtuality == DW_VIRTUALITY_pure_virtual) + if (func->virtuality == DW_VIRTUALITY_pure_virtual) printed += fprintf(fp, " = 0"); return printed; } -size_t function__fprintf_stats(const struct tag *tag_self, - const struct cu *cu, - const struct conf_fprintf *conf, - FILE *fp) +size_t function__fprintf_stats(const struct tag *tag, const struct cu *cu, + const struct conf_fprintf *conf, FILE *fp) { - struct function *self = tag__function(tag_self); - size_t printed = lexblock__fprintf(&self->lexblock, cu, self, 0, conf, fp); + struct function *func = tag__function(tag); + size_t printed = lexblock__fprintf(&func->lexblock, cu, func, 0, conf, fp); - printed += fprintf(fp, "/* size: %d", function__size(self)); - if (self->lexblock.nr_variables > 0) + printed += fprintf(fp, "/* size: %d", function__size(func)); + if (func->lexblock.nr_variables > 0) printed += fprintf(fp, ", variables: %u", - self->lexblock.nr_variables); - if (self->lexblock.nr_labels > 0) + func->lexblock.nr_variables); + if (func->lexblock.nr_labels > 0) printed += fprintf(fp, ", goto labels: %u", - self->lexblock.nr_labels); - if (self->lexblock.nr_inline_expansions > 0) + func->lexblock.nr_labels); + if (func->lexblock.nr_inline_expansions > 0) printed += fprintf(fp, ", inline expansions: %u (%d bytes)", - self->lexblock.nr_inline_expansions, - self->lexblock.size_inline_expansions); + func->lexblock.nr_inline_expansions, + func->lexblock.size_inline_expansions); return printed + fprintf(fp, " */\n"); } -static size_t class__fprintf_cacheline_boundary(uint32_t last_cacheline, - size_t sum, size_t sum_holes, - uint8_t *newline, - uint32_t *cacheline, - int indent, FILE *fp) +static size_t class__fprintf_cacheline_boundary(struct conf_fprintf *conf, + uint32_t offset, + FILE *fp) { - const size_t real_sum = sum + sum_holes; + int indent = conf->indent; + uint32_t cacheline = offset / cacheline_size; size_t printed = 0; - *cacheline = real_sum / cacheline_size; - - if (*cacheline > last_cacheline) { - const uint32_t cacheline_pos = real_sum % cacheline_size; - const uint32_t cacheline_in_bytes = real_sum - cacheline_pos; - - if (*newline) { - fputc('\n', fp); - *newline = 0; - ++printed; - } - - printed += fprintf(fp, "%.*s", indent, tabs); + if (cacheline > *conf->cachelinep) { + const uint32_t cacheline_pos = offset % cacheline_size; + const uint32_t cacheline_in_bytes = offset - cacheline_pos; if (cacheline_pos == 0) printed += fprintf(fp, "/* --- cacheline %u boundary " - "(%u bytes) --- */\n", *cacheline, + "(%u bytes) --- */\n", cacheline, cacheline_in_bytes); else printed += fprintf(fp, "/* --- cacheline %u boundary " "(%u bytes) was %u bytes ago --- " - "*/\n", *cacheline, + "*/\n", cacheline, cacheline_in_bytes, cacheline_pos); + + printed += fprintf(fp, "%.*s", indent, tabs); + + *conf->cachelinep = cacheline; } return printed; } -static size_t class__vtable_fprintf(struct class *self, const struct cu *cu, +static size_t class__vtable_fprintf(struct class *class, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp) { struct function *pos; size_t printed = 0; - if (self->nr_vtable_entries == 0) + if (class->nr_vtable_entries == 0) goto out; printed += fprintf(fp, "%.*s/* vtable has %u entries: {\n", - conf->indent, tabs, self->nr_vtable_entries); + conf->indent, tabs, class->nr_vtable_entries); - list_for_each_entry(pos, &self->vtable, vtable_node) { + list_for_each_entry(pos, &class->vtable, vtable_node) { printed += fprintf(fp, "%.*s [%d] = %s(%s), \n", conf->indent, tabs, pos->vtable_entry, function__name(pos, cu), @@ -1170,44 +1357,50 @@ return printed; } -size_t class__fprintf(struct class *self, const struct cu *cu, - const struct conf_fprintf *conf, FILE *fp) +static size_t __class__fprintf(struct class *class, const struct cu *cu, + const struct conf_fprintf *conf, FILE *fp) { - struct type *tself = &self->type; + struct type *type = &class->type; size_t last_size = 0, size; uint8_t newline = 0; uint16_t nr_paddings = 0; - uint32_t sum = 0; + uint16_t nr_forced_alignments = 0, nr_forced_alignment_holes = 0; + uint32_t sum_forced_alignment_holes = 0; + uint32_t sum_bytes = 0, sum_bits = 0; uint32_t sum_holes = 0; uint32_t sum_paddings = 0; uint32_t sum_bit_holes = 0; - uint32_t last_cacheline = 0; - uint32_t bitfield_real_offset = 0; + uint32_t cacheline = 0; + int size_diff = 0; int first = 1; struct class_member *pos, *last = NULL; struct tag *tag_pos; const char *current_accessibility = NULL; struct conf_fprintf cconf = conf ? *conf : conf_fprintf__defaults; - const uint16_t t = tself->namespace.tag.tag; + const uint16_t t = type->namespace.tag.tag; size_t printed = fprintf(fp, "%s%s%s%s%s", cconf.prefix ?: "", cconf.prefix ? " " : "", ((cconf.classes_as_structs || t == DW_TAG_structure_type) ? "struct" : t == DW_TAG_class_type ? "class" : "interface"), - type__name(tself, cu) ? " " : "", - type__name(tself, cu) ?: ""); + type__name(type, cu) ? " " : "", + type__name(type, cu) ?: ""); int indent = cconf.indent; if (indent >= (int)sizeof(tabs)) indent = sizeof(tabs) - 1; + if (cconf.cachelinep == NULL) + cconf.cachelinep = &cacheline; + cconf.indent = indent + 1; cconf.no_semicolon = 0; + class__infer_packed_attributes(class, cu); + /* First look if we have DW_TAG_inheritance */ - type__for_each_tag(tself, tag_pos) { - struct tag *type; + type__for_each_tag(type, tag_pos) { const char *accessibility; if (tag_pos->tag != DW_TAG_inheritance) @@ -1228,18 +1421,41 @@ if (accessibility != NULL) printed += fprintf(fp, " %s", accessibility); - type = cu__type(cu, tag_pos->type); - if (type != NULL) + struct tag *pos_type = cu__type(cu, tag_pos->type); + if (pos_type != NULL) printed += fprintf(fp, " %s", - type__name(tag__type(type), cu)); + type__name(tag__type(pos_type), cu)); else printed += tag__id_not_found_fprintf(fp, tag_pos->type); } printed += fprintf(fp, " {\n"); - type__for_each_tag(tself, tag_pos) { - struct tag *type; + if (class->pre_bit_hole > 0 && !cconf.suppress_comments) { + if (!newline++) { + fputc('\n', fp); + ++printed; + } + printed += fprintf(fp, "%.*s/* XXX %d bit%s hole, " + "try to pack */\n", cconf.indent, tabs, + class->pre_bit_hole, + class->pre_bit_hole != 1 ? "s" : ""); + sum_bit_holes += class->pre_bit_hole; + } + + if (class->pre_hole > 0 && !cconf.suppress_comments) { + if (!newline++) { + fputc('\n', fp); + ++printed; + } + printed += fprintf(fp, "%.*s/* XXX %d byte%s hole, " + "try to pack */\n", + cconf.indent, tabs, class->pre_hole, + class->pre_hole != 1 ? "s" : ""); + sum_holes += class->pre_hole; + } + + type__for_each_tag(type, tag_pos) { const char *accessibility = tag__accessibility(tag_pos); if (accessibility != NULL && @@ -1260,16 +1476,15 @@ } pos = tag__class_member(tag_pos); - if (last != NULL && - pos->byte_offset != last->byte_offset && - !cconf.suppress_comments) - printed += - class__fprintf_cacheline_boundary(last_cacheline, - sum, sum_holes, - &newline, - &last_cacheline, - cconf.indent, - fp); + if (!cconf.suppress_aligned_attribute && pos->alignment != 0) { + uint32_t forced_alignment_hole = last ? last->hole : class->pre_hole; + + if (forced_alignment_hole != 0) { + ++nr_forced_alignment_holes; + sum_forced_alignment_holes += forced_alignment_hole; + } + ++nr_forced_alignments; + } /* * These paranoid checks doesn't make much sense on * DW_TAG_inheritance, have to understand why virtual public @@ -1281,6 +1496,29 @@ * all over the place. */ last_size != 0) { + if (last->bit_hole != 0 && pos->bitfield_size) { + uint8_t bitfield_size = last->bit_hole; + struct tag *pos_type = cu__type(cu, pos->tag.type); + + if (pos_type == NULL) { + printed += fprintf(fp, "%.*s", cconf.indent, tabs); + printed += tag__id_not_found_fprintf(fp, pos->tag.type); + continue; + } + /* + * Now check if this isn't something like 'unsigned :N' with N > 0, + * i.e. _explicitely_ adding a bit hole. + */ + if (last->byte_offset != pos->byte_offset) { + printed += fprintf(fp, "\n%.*s/* Force alignment to the next boundary: */\n", cconf.indent, tabs); + bitfield_size = 0; + } + + printed += fprintf(fp, "%.*s", cconf.indent, tabs); + printed += type__fprintf(pos_type, cu, "", &cconf, fp); + printed += fprintf(fp, ":%u;\n", bitfield_size); + } + if (pos->byte_offset < last->byte_offset || (pos->byte_offset == last->byte_offset && last->bitfield_size == 0 && @@ -1299,8 +1537,6 @@ " with previous fields */\n", cconf.indent, tabs); } - if (pos->byte_offset != last->byte_offset) - bitfield_real_offset = last->byte_offset + last_size; } else { const ssize_t cc_last_size = ((ssize_t)pos->byte_offset - (ssize_t)last->byte_offset); @@ -1316,8 +1552,6 @@ " with next fields */\n", cconf.indent, tabs); } - sum -= last_size; - sum += cc_last_size; } } } @@ -1328,19 +1562,31 @@ ++printed; } - type = cu__type(cu, pos->tag.type); - if (type == NULL) { + struct tag *pos_type = cu__type(cu, pos->tag.type); + if (pos_type == NULL) { printed += fprintf(fp, "%.*s", cconf.indent, tabs); printed += tag__id_not_found_fprintf(fp, pos->tag.type); continue; } + cconf.last_member = list_is_last(&tag_pos->node, &type->namespace.tags); + cconf.first_member = last == NULL; + size = pos->byte_size; printed += fprintf(fp, "%.*s", cconf.indent, tabs); - printed += struct_member__fprintf(pos, type, cu, &cconf, fp); + printed += struct_member__fprintf(pos, pos_type, cu, &cconf, fp); + + if (tag__is_struct(pos_type) && !cconf.suppress_comments) { + struct class *tclass = tag__class(pos_type); + uint16_t padding; + /* + * We may not yet have looked for holes and paddings + * in this member's struct type. + */ + class__find_holes(tclass); + class__infer_packed_attributes(tclass, cu); - if (tag__is_struct(type) && !cconf.suppress_comments) { - const uint16_t padding = tag__class(type)->padding; + padding = tclass->padding; if (padding > 0) { ++nr_paddings; sum_paddings += padding; @@ -1385,19 +1631,22 @@ ++printed; /* XXX for now just skip these */ - if (tag_pos->tag == DW_TAG_inheritance && - pos->virtuality == DW_VIRTUALITY_virtual) + if (tag_pos->tag == DW_TAG_inheritance) continue; - +#if 0 /* - * Check if we have to adjust size because bitfields were - * combined with previous fields. - */ - if (bitfield_real_offset != 0 && last->bitfield_end) { - size_t real_last_size = pos->byte_offset - bitfield_real_offset; - sum -= last_size; - sum += real_last_size; - bitfield_real_offset = 0; + * This one was being skipped but caused problems with: + * http://article.gmane.org/gmane.comp.debugging.dwarves/185 + * http://www.spinics.net/lists/dwarves/msg00119.html + */ + if (pos->virtuality == DW_VIRTUALITY_virtual) + continue; +#endif + + if (pos->bitfield_size) { + sum_bits += pos->bitfield_size; + } else { + sum_bytes += pos->byte_size; } if (last == NULL || /* First member */ @@ -1409,7 +1658,6 @@ * We moved to a new offset */ last->byte_offset != pos->byte_offset) { - sum += size; last_size = size; } else if (last->bitfield_size == 0 && pos->bitfield_size != 0) { /* @@ -1427,7 +1675,6 @@ * int b:1; / 0:23 4 / * } */ - sum += size - last_size; last_size = size; } @@ -1435,83 +1682,127 @@ } /* - * Check if we have to adjust size because bitfields were - * combined with previous fields and were the last fields - * in the struct. + * BTF doesn't have alignment info, for now use this infor from the loader + * to avoid adding the forced bitfield paddings and have btfdiff happy. */ - if (bitfield_real_offset != 0) { - size_t real_last_size = tself->size - bitfield_real_offset; - sum -= last_size; - sum += real_last_size; - bitfield_real_offset = 0; + if (class->padding != 0 && type->alignment == 0 && cconf.has_alignment_info && + !cconf.suppress_force_paddings && last != NULL) { + tag_pos = cu__type(cu, last->tag.type); + size = tag__size(tag_pos, cu); + + if (is_power_of_2(size) && class->padding > cu->addr_size) { + int added_padding; + int bit_size = size * 8; + + printed += fprintf(fp, "\n%.*s/* Force padding: */\n", cconf.indent, tabs); + + for (added_padding = 0; added_padding < class->padding; added_padding += size) { + printed += fprintf(fp, "%.*s", cconf.indent, tabs); + printed += type__fprintf(tag_pos, cu, "", &cconf, fp); + printed += fprintf(fp, ":%u;\n", bit_size); + } + } } - if (!cconf.suppress_comments) - printed += class__fprintf_cacheline_boundary(last_cacheline, - sum, sum_holes, - &newline, - &last_cacheline, - cconf.indent, fp); if (!cconf.show_only_data_members) - class__vtable_fprintf(self, cu, &cconf, fp); + class__vtable_fprintf(class, cu, &cconf, fp); if (!cconf.emit_stats) goto out; - printed += fprintf(fp, "\n%.*s/* size: %zd, cachelines: %zd, members: %u */", - cconf.indent, tabs, - tag__size(class__tag(self), cu), - tag__nr_cachelines(class__tag(self), cu), - tself->nr_members); - if (sum_holes > 0) - printed += fprintf(fp, "\n%.*s/* sum members: %u, holes: %d, " - "sum holes: %u */", - cconf.indent, tabs, - sum, self->nr_holes, sum_holes); - if (sum_bit_holes > 0) - printed += fprintf(fp, "\n%.*s/* bit holes: %d, sum bit " - "holes: %u bits */", - cconf.indent, tabs, - self->nr_bit_holes, sum_bit_holes); - if (self->padding > 0) - printed += fprintf(fp, "\n%.*s/* padding: %u */", + printed += type__fprintf_stats(type, cu, &cconf, fp); + + if (sum_holes > 0 || sum_bit_holes > 0) { + if (sum_bytes > 0) { + printed += fprintf(fp, "%.*s/* sum members: %u", + cconf.indent, tabs, sum_bytes); + if (sum_holes > 0) + printed += fprintf(fp, ", holes: %d, sum holes: %u", + class->nr_holes, sum_holes); + printed += fprintf(fp, " */\n"); + } + if (sum_bits > 0) { + printed += fprintf(fp, "%.*s/* sum bitfield members: %u bits", + cconf.indent, tabs, sum_bits); + if (sum_bit_holes > 0) + printed += fprintf(fp, ", bit holes: %d, sum bit holes: %u bits", + class->nr_bit_holes, sum_bit_holes); + else + printed += fprintf(fp, " (%u bytes)", sum_bits / 8); + printed += fprintf(fp, " */\n"); + } + } + if (class->padding > 0) + printed += fprintf(fp, "%.*s/* padding: %u */\n", cconf.indent, - tabs, self->padding); + tabs, class->padding); if (nr_paddings > 0) - printed += fprintf(fp, "\n%.*s/* paddings: %u, sum paddings: " - "%u */", + printed += fprintf(fp, "%.*s/* paddings: %u, sum paddings: " + "%u */\n", cconf.indent, tabs, nr_paddings, sum_paddings); - if (self->bit_padding > 0) - printed += fprintf(fp, "\n%.*s/* bit_padding: %u bits */", + if (class->bit_padding > 0) + printed += fprintf(fp, "%.*s/* bit_padding: %u bits */\n", + cconf.indent, tabs, + class->bit_padding); + if (!cconf.suppress_aligned_attribute && nr_forced_alignments != 0) { + printed += fprintf(fp, "%.*s/* forced alignments: %u", cconf.indent, tabs, - self->bit_padding); - last_cacheline = tself->size % cacheline_size; - if (last_cacheline != 0) - printed += fprintf(fp, "\n%.*s/* last cacheline: %u bytes */", + nr_forced_alignments); + if (nr_forced_alignment_holes != 0) { + printed += fprintf(fp, ", forced holes: %u, sum forced holes: %u", + nr_forced_alignment_holes, + sum_forced_alignment_holes); + } + printed += fprintf(fp, " */\n"); + } + cacheline = (cconf.base_offset + type->size) % cacheline_size; + if (cacheline != 0) + printed += fprintf(fp, "%.*s/* last cacheline: %u bytes */\n", cconf.indent, tabs, - last_cacheline); + cacheline); if (cconf.show_first_biggest_size_base_type_member && - tself->nr_members != 0) { - struct class_member *m = type__find_first_biggest_size_base_type_member(tself, cu); + type->nr_members != 0) { + struct class_member *m = type__find_first_biggest_size_base_type_member(type, cu); - printed += fprintf(fp, "\n%.*s/* first biggest size base type member: %s %u %zd */", + printed += fprintf(fp, "%.*s/* first biggest size base type member: %s %u %zd */\n", cconf.indent, tabs, class_member__name(m, cu), m->byte_offset, m->byte_size); } - if (sum + sum_holes != tself->size - self->padding && - tself->nr_members != 0) - printed += fprintf(fp, "\n\n%.*s/* BRAIN FART ALERT! %d != %u " - "+ %u(holes), diff = %d */\n", + size_diff = type->size * 8 - (sum_bytes * 8 + sum_bits + sum_holes * 8 + sum_bit_holes + + class->padding * 8 + class->bit_padding); + if (size_diff && type->nr_members != 0) + printed += fprintf(fp, "\n%.*s/* BRAIN FART ALERT! %d bytes != " + "%u (member bytes) + %u (member bits) " + "+ %u (byte holes) + %u (bit holes), diff = %d bits */\n", cconf.indent, tabs, - tself->size, sum, sum_holes, - tself->size - (sum + sum_holes)); - fputc('\n', fp); + type->size, sum_bytes, sum_bits, sum_holes, sum_bit_holes, size_diff); out: - return printed + fprintf(fp, "%.*s}%s%s", indent, tabs, - cconf.suffix ? " ": "", cconf.suffix ?: ""); + printed += fprintf(fp, "%.*s}", indent, tabs); + + if (class->is_packed && !cconf.suppress_packed) + printed += fprintf(fp, " __attribute__((__packed__))"); + + if (cconf.suffix) + printed += fprintf(fp, " %s", cconf.suffix); + + /* + * A class that was marked packed by class__infer_packed_attributes + * because it has an alignment that is different than its natural + * alignment, should not print the __alignment__ here, just the + * __packed__ attribute. + */ + if (!cconf.suppress_aligned_attribute && type->alignment != 0 && !class->is_packed) + printed += fprintf(fp, " __attribute__((__aligned__(%u)))", type->alignment); + + return printed; +} + +size_t class__fprintf(struct class *class, const struct cu *cu, FILE *fp) +{ + return __class__fprintf(class, cu, NULL, fp); } static size_t variable__fprintf(const struct tag *tag, const struct cu *cu, @@ -1534,19 +1825,19 @@ return printed; } -static size_t namespace__fprintf(const struct tag *tself, const struct cu *cu, +static size_t namespace__fprintf(const struct tag *tag, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp) { - struct namespace *self = tag__namespace(tself); + struct namespace *space = tag__namespace(tag); struct conf_fprintf cconf = *conf; size_t printed = fprintf(fp, "namespace %s {\n", - namespace__name(self, cu)); + namespace__name(space, cu)); struct tag *pos; ++cconf.indent; cconf.no_semicolon = 0; - namespace__for_each_tag(self, pos) { + namespace__for_each_tag(space, pos) { printed += tag__fprintf(pos, cu, &cconf, fp); printed += fprintf(fp, "\n\n"); } @@ -1554,7 +1845,7 @@ return printed + fprintf(fp, "}"); } -size_t tag__fprintf(struct tag *self, const struct cu *cu, +size_t tag__fprintf(struct tag *tag, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp) { size_t printed = 0; @@ -1567,7 +1858,7 @@ if (tconf.expand_types) tconf.name_spacing = 55; - else if (tag__is_union(self)) + else if (tag__is_union(tag)) tconf.name_spacing = 21; } else if (conf->name_spacing == 0 || conf->type_spacing == 0) { tconf = *conf; @@ -1577,58 +1868,62 @@ if (tconf.expand_types) tconf.name_spacing = 55; else - tconf.name_spacing = - tag__is_union(self) ? 21 : 23; + tconf.name_spacing = tag__is_union(tag) ? 21 : 23; } if (tconf.type_spacing == 0) tconf.type_spacing = 26; } if (pconf->expand_types) - ++self->recursivity_level; + ++tag->recursivity_level; if (pconf->show_decl_info) { printed += fprintf(fp, "%.*s", pconf->indent, tabs); - printed += tag__fprintf_decl_info(self, cu, fp); + printed += fprintf(fp, "/* Used at: %s */\n", cu->name); + printed += fprintf(fp, "%.*s", pconf->indent, tabs); + printed += tag__fprintf_decl_info(tag, cu, fp); } printed += fprintf(fp, "%.*s", pconf->indent, tabs); - switch (self->tag) { + switch (tag->tag) { case DW_TAG_array_type: - printed += array_type__fprintf(self, cu, "array", pconf, fp); + printed += array_type__fprintf(tag, cu, "array", pconf, fp); break; case DW_TAG_enumeration_type: - printed += enumeration__fprintf(self, cu, pconf, fp); + printed += enumeration__fprintf(tag, cu, pconf, fp); break; case DW_TAG_typedef: - printed += typedef__fprintf(self, cu, pconf, fp); + printed += typedef__fprintf(tag, cu, pconf, fp); break; case DW_TAG_class_type: case DW_TAG_interface_type: case DW_TAG_structure_type: - printed += class__fprintf(tag__class(self), cu, pconf, fp); + printed += __class__fprintf(tag__class(tag), cu, pconf, fp); + break; + case DW_TAG_subroutine_type: + printed += ftype__fprintf(tag__ftype(tag), cu, NULL, false, false, 0, true, pconf, fp); break; case DW_TAG_namespace: - printed += namespace__fprintf(self, cu, pconf, fp); + printed += namespace__fprintf(tag, cu, pconf, fp); break; case DW_TAG_subprogram: - printed += function__fprintf(self, cu, pconf, fp); + printed += function__fprintf(tag, cu, pconf, fp); break; case DW_TAG_union_type: - printed += union__fprintf(tag__type(self), cu, pconf, fp); + printed += union__fprintf(tag__type(tag), cu, pconf, fp); break; case DW_TAG_variable: - printed += variable__fprintf(self, cu, pconf, fp); + printed += variable__fprintf(tag, cu, pconf, fp); break; case DW_TAG_imported_declaration: - printed += imported_declaration__fprintf(self, cu, fp); + printed += imported_declaration__fprintf(tag, cu, fp); break; case DW_TAG_imported_module: - printed += imported_module__fprintf(self, cu, fp); + printed += imported_module__fprintf(tag, cu, fp); break; default: printed += fprintf(fp, "/* %s: %s tag not supported! */", - __func__, dwarf_tag_name(self->tag)); + __func__, dwarf_tag_name(tag->tag)); break; } @@ -1637,16 +1932,16 @@ ++printed; } - if (tag__is_function(self) && !pconf->suppress_comments) { - const struct function *fself = tag__function(self); + if (tag__is_function(tag) && !pconf->suppress_comments) { + const struct function *func = tag__function(tag); - if (fself->linkage_name) + if (func->linkage_name) printed += fprintf(fp, " /* linkage=%s */", - function__linkage_name(fself, cu)); + function__linkage_name(func, cu)); } if (pconf->expand_types) - --self->recursivity_level; + --tag->recursivity_level; return printed; } diff -Nru dwarves-dfsg-1.10/dwarves.h dwarves-dfsg-1.21/dwarves.h --- dwarves-dfsg-1.10/dwarves.h 2012-05-14 22:41:11.000000000 +0000 +++ dwarves-dfsg-1.21/dwarves.h 2021-03-07 13:51:27.000000000 +0000 @@ -1,12 +1,10 @@ #ifndef _DWARVES_H_ #define _DWARVES_H_ 1 /* - Copyright (C) 2006 Mandriva Conectiva S.A. - Copyright (C) 2006..2009 Arnaldo Carvalho de Melo + SPDX-License-Identifier: GPL-2.0-only - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. + Copyright (C) 2006 Mandriva Conectiva S.A. + Copyright (C) 2006..2019 Arnaldo Carvalho de Melo */ @@ -15,11 +13,12 @@ #include #include #include +#include #include "dutil.h" #include "list.h" #include "rbtree.h" -#include "strings.h" +#include "pahole_strings.h" struct cu; @@ -29,6 +28,14 @@ LSK__STOP_LOADING, }; +/* + * BTF combines all the types into one big CU using btf_dedup(), so for something + * like a allyesconfig vmlinux kernel we can get over 65535 types. + */ +typedef uint32_t type_id_t; + +struct conf_fprintf; + /** struct conf_load - load configuration * @extra_dbg_info - keep original debugging format extra info * (e.g. DWARF's decl_{line,file}, id, etc) @@ -36,19 +43,31 @@ * @get_addr_info - wheter to load DW_AT_location and other addr info */ struct conf_load { - enum load_steal_kind (*steal)(struct cu *self, + enum load_steal_kind (*steal)(struct cu *cu, struct conf_load *conf); void *cookie; char *format_path; bool extra_dbg_info; bool fixup_silly_bitfields; bool get_addr_info; + struct conf_fprintf *conf_fprintf; }; /** struct conf_fprintf - hints to the __fprintf routines * + * @count - Just like 'dd', stop pretty printing input after 'count' records + * @skip - Just like 'dd', skip 'count' records when pretty printing input + * @seek_bytes - Number of bytes to seek, if stdin only from start, when we have --pretty FILE, then from the end as well with negative numbers, + * may be of the form $header.MEMBER_NAME when using with --header. + * @size_bytes - Number of bytes to read, similar to seek_bytes, and when both are in place, first seek seek_bytes then read size_bytes + * @range - data structure field in --header to determine --seek_bytes and --size_bytes, must have 'offset' and 'size' fields * @flat_arrays - a->foo[10][2] becomes a->foo[20] * @classes_as_structs - class f becomes struct f, CTF doesn't have a "class" + * @cachelinep - pointer to current cacheline, so that when expanding types we keep track of it, + * needs to be "global", i.e. not set at each recursion. + * @suppress_force_paddings: This makes sense only if the debugging format has struct alignment information, + * So allow for it to be disabled and disable it automatically for things like BTF, + * that don't have such info. */ struct conf_fprintf { const char *prefix; @@ -56,48 +75,70 @@ int32_t type_spacing; int32_t name_spacing; uint32_t base_offset; + uint32_t count; + uint32_t *cachelinep; + const char *seek_bytes; + const char *size_bytes; + const char *header_type; + const char *range; + uint32_t skip; uint8_t indent; uint8_t expand_types:1; uint8_t expand_pointers:1; uint8_t rel_offset:1; uint8_t emit_stats:1; uint8_t suppress_comments:1; + uint8_t has_alignment_info:1; + uint8_t suppress_aligned_attribute:1; uint8_t suppress_offset_comment:1; + uint8_t suppress_force_paddings:1; + uint8_t suppress_packed:1; uint8_t show_decl_info:1; uint8_t show_only_data_members:1; uint8_t no_semicolon:1; uint8_t show_first_biggest_size_base_type_member:1; uint8_t flat_arrays:1; + uint8_t first_member:1; + uint8_t last_member:1; + uint8_t union_member:1; uint8_t no_parm_names:1; uint8_t classes_as_structs:1; uint8_t hex_fmt:1; + uint8_t strip_inline:1; }; struct cus { + uint32_t nr_entries; struct list_head cus; }; struct cus *cus__new(void); -void cus__delete(struct cus *self); +void cus__delete(struct cus *cus); -int cus__load_file(struct cus *self, struct conf_load *conf, +int cus__load_file(struct cus *cus, struct conf_load *conf, const char *filename); -int cus__load_files(struct cus *self, struct conf_load *conf, +int cus__load_files(struct cus *cus, struct conf_load *conf, char *filenames[]); -int cus__load_dir(struct cus *self, struct conf_load *conf, +int cus__fprintf_load_files_err(struct cus *cus, const char *tool, + char *argv[], int err, FILE *output); +int cus__load_dir(struct cus *cus, struct conf_load *conf, const char *dirname, const char *filename_mask, const int recursive); -void cus__add(struct cus *self, struct cu *cu); +void cus__add(struct cus *cus, struct cu *cu); void cus__print_error_msg(const char *progname, const struct cus *cus, const char *filename, const int err); -struct cu *cus__find_cu_by_name(const struct cus *self, const char *name); -struct tag *cus__find_struct_by_name(const struct cus *self, struct cu **cu, +struct cu *cus__find_cu_by_name(const struct cus *cus, const char *name); +struct tag *cus__find_struct_by_name(const struct cus *cus, struct cu **cu, const char *name, const int include_decls, - uint16_t *id); -struct function *cus__find_function_at_addr(const struct cus *self, + type_id_t *id); +struct tag *cus__find_struct_or_union_by_name(const struct cus *cus, struct cu **cu, + const char *name, const int include_decls, type_id_t *id); +struct tag *cu__find_type_by_name(const struct cu *cu, const char *name, const int include_decls, type_id_t *idp); +struct tag *cus__find_type_by_name(const struct cus *cus, struct cu **cu, const char *name, + const int include_decls, type_id_t *id); +struct function *cus__find_function_at_addr(const struct cus *cus, uint64_t addr, struct cu **cu); -void cus__for_each_cu(struct cus *self, int (*iterator)(struct cu *cu, - void *cookie), +void cus__for_each_cu(struct cus *cus, int (*iterator)(struct cu *cu, void *cookie), void *cookie, struct cu *(*filter)(struct cu *cu)); @@ -151,25 +192,28 @@ const char *name; int (*init)(void); void (*exit)(void); - int (*load_file)(struct cus *self, + int (*load_file)(struct cus *cus, struct conf_load *conf, const char *filename); - const char *(*tag__decl_file)(const struct tag *self, + const char *(*tag__decl_file)(const struct tag *tag, const struct cu *cu); - uint32_t (*tag__decl_line)(const struct tag *self, + uint32_t (*tag__decl_line)(const struct tag *tag, const struct cu *cu); - unsigned long long (*tag__orig_id)(const struct tag *self, + unsigned long long (*tag__orig_id)(const struct tag *tag, const struct cu *cu); - void (*tag__free_orig_info)(struct tag *self, + void (*tag__free_orig_info)(struct tag *tag, struct cu *cu); - const char *(*function__name)(struct function *self, + const char *(*function__name)(struct function *tag, const struct cu *cu); - const char *(*variable__name)(const struct variable *self, + const char *(*variable__name)(const struct variable *var, const struct cu *cu); - const char *(*strings__ptr)(const struct cu *self, strings_t s); - void (*cu__delete)(struct cu *self); + const char *(*strings__ptr)(const struct cu *cu, strings_t s); + void (*cu__delete)(struct cu *cu); + bool has_alignment_info; }; +extern struct debug_fmt_ops *dwarves__active_loader; + struct cu { struct list_head node; struct list_head tags; @@ -190,6 +234,7 @@ uint8_t extra_dbg_info:1; uint8_t has_addr_info:1; uint8_t uses_global_strings:1; + uint8_t little_endian:1; uint16_t language; unsigned long nr_inline_expansions; size_t size_inline_expansions; @@ -205,21 +250,21 @@ struct cu *cu__new(const char *name, uint8_t addr_size, const unsigned char *build_id, int build_id_len, const char *filename); -void cu__delete(struct cu *self); +void cu__delete(struct cu *cu); -const char *cu__string(const struct cu *self, strings_t s); +const char *cu__string(const struct cu *cu, strings_t s); -static inline int cu__cache_symtab(struct cu *self) +static inline int cu__cache_symtab(struct cu *cu) { - int err = dwfl_module_getsymtab(self->dwfl); + int err = dwfl_module_getsymtab(cu->dwfl); if (err > 0) - self->cached_symtab_nr_entries = dwfl_module_getsymtab(self->dwfl); + cu->cached_symtab_nr_entries = dwfl_module_getsymtab(cu->dwfl); return err; } -static inline __pure bool cu__is_c_plus_plus(const struct cu *self) +static inline __pure bool cu__is_c_plus_plus(const struct cu *cu) { - return self->language == LANG_C_plus_plus; + return cu->language == LANG_C_plus_plus; } /** @@ -238,7 +283,7 @@ /** * cu__for_each_type - iterate thru all the type tags * @cu: struct cu instance to iterate - * @id: uint16_t tag id + * @id: type_id_t id * @pos: struct tag iterator * * See cu__table_nullify_type_entry and users for the reason for @@ -254,7 +299,7 @@ * cu__for_each_struct - iterate thru all the struct tags * @cu: struct cu instance to iterate * @pos: struct class iterator - * @id: uint16_t tag id + * @id: type_id_t id */ #define cu__for_each_struct(cu, id, pos) \ for (id = 1; id < cu->types_table.nr_entries; ++id) \ @@ -264,6 +309,20 @@ else /** + * cu__for_each_struct_or_union - iterate thru all the struct and union tags + * @cu: struct cu instance to iterate + * @pos: struct class iterator + * @id: type_id_t tag id + */ +#define cu__for_each_struct_or_union(cu, id, pos) \ + for (id = 1; id < cu->types_table.nr_entries; ++id) \ + if (!(pos = tag__class(cu->types_table.entries[id])) || \ + !(tag__is_struct(class__tag(pos)) || \ + tag__is_union(class__tag(pos)))) \ + continue; \ + else + +/** * cu__for_each_function - iterate thru all the function tags * @cu: struct cu instance to iterate * @pos: struct function iterator @@ -288,34 +347,39 @@ continue; \ else -int cu__add_tag(struct cu *self, struct tag *tag, long *id); -int cu__table_add_tag(struct cu *self, struct tag *tag, long *id); -int cu__table_nullify_type_entry(struct cu *self, uint32_t id); -struct tag *cu__find_base_type_by_name(const struct cu *self, const char *name, - uint16_t *id); -struct tag *cu__find_base_type_by_sname_and_size(const struct cu *self, +int cu__add_tag(struct cu *cu, struct tag *tag, uint32_t *id); +int cu__add_tag_with_id(struct cu *cu, struct tag *tag, uint32_t id); +int cu__table_add_tag(struct cu *cu, struct tag *tag, uint32_t *id); +int cu__table_add_tag_with_id(struct cu *cu, struct tag *tag, uint32_t id); +int cu__table_nullify_type_entry(struct cu *cu, uint32_t id); +struct tag *cu__find_base_type_by_name(const struct cu *cu, const char *name, + type_id_t *id); +struct tag *cu__find_base_type_by_sname_and_size(const struct cu *cu, strings_t name, uint16_t bit_size, - uint16_t *idp); -struct tag *cu__find_enumeration_by_sname_and_size(const struct cu *self, + type_id_t *idp); +struct tag *cu__find_enumeration_by_name(const struct cu *cu, const char *name, type_id_t *idp); +struct tag *cu__find_enumeration_by_sname_and_size(const struct cu *cu, strings_t sname, uint16_t bit_size, - uint16_t *idp); -struct tag *cu__find_first_typedef_of_type(const struct cu *self, - const uint16_t type); + type_id_t *idp); +struct tag *cu__find_first_typedef_of_type(const struct cu *cu, + const type_id_t type); struct tag *cu__find_function_by_name(const struct cu *cu, const char *name); -struct tag *cu__find_struct_by_sname(const struct cu *self, strings_t sname, - const int include_decls, uint16_t *idp); -struct function *cu__find_function_at_addr(const struct cu *self, +struct tag *cu__find_struct_by_sname(const struct cu *cu, strings_t sname, + const int include_decls, type_id_t *idp); +struct function *cu__find_function_at_addr(const struct cu *cu, uint64_t addr); -struct tag *cu__function(const struct cu *self, const uint32_t id); -struct tag *cu__tag(const struct cu *self, const uint32_t id); -struct tag *cu__type(const struct cu *self, const uint16_t id); +struct tag *cu__function(const struct cu *cu, const uint32_t id); +struct tag *cu__tag(const struct cu *cu, const uint32_t id); +struct tag *cu__type(const struct cu *cu, const type_id_t id); struct tag *cu__find_struct_by_name(const struct cu *cu, const char *name, - const int include_decls, uint16_t *id); -bool cu__same_build_id(const struct cu *self, const struct cu *other); -void cu__account_inline_expansions(struct cu *self); -int cu__for_all_tags(struct cu *self, + const int include_decls, type_id_t *id); +struct tag *cu__find_struct_or_union_by_name(const struct cu *cu, const char *name, + const int include_decls, type_id_t *id); +bool cu__same_build_id(const struct cu *cu, const struct cu *other); +void cu__account_inline_expansions(struct cu *cu); +int cu__for_all_tags(struct cu *cu, int (*iterator)(struct tag *tag, struct cu *cu, void *cookie), void *cookie); @@ -326,7 +390,7 @@ */ struct tag { struct list_head node; - uint16_t type; + type_id_t type; uint16_t tag; bool visited; bool top_level; @@ -334,123 +398,161 @@ void *priv; }; -void tag__delete(struct tag *self, struct cu *cu); +// To use with things like type->type_enum == perf_event_type+perf_user_event_type +struct tag_cu { + struct tag *tag; + struct cu *cu; +}; + +void tag__delete(struct tag *tag, struct cu *cu); -static inline int tag__is_enumeration(const struct tag *self) +static inline int tag__is_enumeration(const struct tag *tag) { - return self->tag == DW_TAG_enumeration_type; + return tag->tag == DW_TAG_enumeration_type; } -static inline int tag__is_namespace(const struct tag *self) +static inline int tag__is_namespace(const struct tag *tag) { - return self->tag == DW_TAG_namespace; + return tag->tag == DW_TAG_namespace; } -static inline int tag__is_struct(const struct tag *self) +static inline int tag__is_struct(const struct tag *tag) { - return self->tag == DW_TAG_structure_type || - self->tag == DW_TAG_interface_type || - self->tag == DW_TAG_class_type; + return tag->tag == DW_TAG_structure_type || + tag->tag == DW_TAG_interface_type || + tag->tag == DW_TAG_class_type; } -static inline int tag__is_typedef(const struct tag *self) +static inline int tag__is_typedef(const struct tag *tag) { - return self->tag == DW_TAG_typedef; + return tag->tag == DW_TAG_typedef; } -static inline int tag__is_union(const struct tag *self) +static inline int tag__is_rvalue_reference_type(const struct tag *tag) { - return self->tag == DW_TAG_union_type; + return tag->tag == DW_TAG_rvalue_reference_type; } -static inline int tag__is_const(const struct tag *self) +static inline int tag__is_union(const struct tag *tag) { - return self->tag == DW_TAG_const_type; + return tag->tag == DW_TAG_union_type; } -static inline bool tag__is_variable(const struct tag *self) +static inline int tag__is_const(const struct tag *tag) { - return self->tag == DW_TAG_variable; + return tag->tag == DW_TAG_const_type; } -static inline bool tag__is_volatile(const struct tag *self) +static inline int tag__is_pointer(const struct tag *tag) { - return self->tag == DW_TAG_volatile_type; + return tag->tag == DW_TAG_pointer_type; } -static inline bool tag__has_namespace(const struct tag *self) +static inline int tag__is_pointer_to(const struct tag *tag, type_id_t type) { - return tag__is_struct(self) || - tag__is_union(self) || - tag__is_namespace(self) || - tag__is_enumeration(self); + return tag__is_pointer(tag) && tag->type == type; +} + +static inline bool tag__is_variable(const struct tag *tag) +{ + return tag->tag == DW_TAG_variable; +} + +static inline bool tag__is_volatile(const struct tag *tag) +{ + return tag->tag == DW_TAG_volatile_type; +} + +static inline bool tag__is_restrict(const struct tag *tag) +{ + return tag->tag == DW_TAG_restrict_type; +} + +static inline int tag__is_modifier(const struct tag *tag) +{ + return tag__is_const(tag) || + tag__is_volatile(tag) || + tag__is_restrict(tag); +} + +static inline bool tag__has_namespace(const struct tag *tag) +{ + return tag__is_struct(tag) || + tag__is_union(tag) || + tag__is_namespace(tag) || + tag__is_enumeration(tag); } /** * tag__is_tag_type - is this tag derived from the 'type' class? * @tag - tag queried */ -static inline int tag__is_type(const struct tag *self) +static inline int tag__is_type(const struct tag *tag) { - return tag__is_union(self) || - tag__is_struct(self) || - tag__is_typedef(self) || - tag__is_enumeration(self); + return tag__is_union(tag) || + tag__is_struct(tag) || + tag__is_typedef(tag) || + tag__is_rvalue_reference_type(tag) || + tag__is_enumeration(tag); } /** * tag__is_tag_type - is this one of the possible types for a tag? * @tag - tag queried */ -static inline int tag__is_tag_type(const struct tag *self) +static inline int tag__is_tag_type(const struct tag *tag) { - return tag__is_type(self) || - self->tag == DW_TAG_array_type || - self->tag == DW_TAG_base_type || - self->tag == DW_TAG_const_type || - self->tag == DW_TAG_pointer_type || - self->tag == DW_TAG_ptr_to_member_type || - self->tag == DW_TAG_reference_type || - self->tag == DW_TAG_subroutine_type || - self->tag == DW_TAG_volatile_type; + return tag__is_type(tag) || + tag->tag == DW_TAG_array_type || + tag->tag == DW_TAG_string_type || + tag->tag == DW_TAG_base_type || + tag->tag == DW_TAG_const_type || + tag->tag == DW_TAG_pointer_type || + tag->tag == DW_TAG_rvalue_reference_type || + tag->tag == DW_TAG_ptr_to_member_type || + tag->tag == DW_TAG_reference_type || + tag->tag == DW_TAG_restrict_type || + tag->tag == DW_TAG_subroutine_type || + tag->tag == DW_TAG_unspecified_type || + tag->tag == DW_TAG_volatile_type; } -static inline const char *tag__decl_file(const struct tag *self, +static inline const char *tag__decl_file(const struct tag *tag, const struct cu *cu) { if (cu->dfops && cu->dfops->tag__decl_file) - return cu->dfops->tag__decl_file(self, cu); + return cu->dfops->tag__decl_file(tag, cu); return NULL; } -static inline uint32_t tag__decl_line(const struct tag *self, +static inline uint32_t tag__decl_line(const struct tag *tag, const struct cu *cu) { if (cu->dfops && cu->dfops->tag__decl_line) - return cu->dfops->tag__decl_line(self, cu); + return cu->dfops->tag__decl_line(tag, cu); return 0; } -static inline unsigned long long tag__orig_id(const struct tag *self, +static inline unsigned long long tag__orig_id(const struct tag *tag, const struct cu *cu) { if (cu->dfops && cu->dfops->tag__orig_id) - return cu->dfops->tag__orig_id(self, cu); + return cu->dfops->tag__orig_id(tag, cu); return 0; } -static inline void tag__free_orig_info(struct tag *self, struct cu *cu) +static inline void tag__free_orig_info(struct tag *tag, struct cu *cu) { if (cu->dfops && cu->dfops->tag__free_orig_info) - cu->dfops->tag__free_orig_info(self, cu); + cu->dfops->tag__free_orig_info(tag, cu); } -size_t tag__fprintf_decl_info(const struct tag *self, +size_t tag__fprintf_decl_info(const struct tag *tag, const struct cu *cu, FILE *fp); -size_t tag__fprintf(struct tag *self, const struct cu *cu, +size_t tag__fprintf(struct tag *tag, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp); -const char *tag__name(const struct tag *self, const struct cu *cu, +const char *tag__name(const struct tag *tag, const struct cu *cu, char *bf, size_t len, const struct conf_fprintf *conf); void tag__not_found_die(const char *file, int line, const char *func); @@ -458,30 +560,31 @@ do { if (!tag) tag__not_found_die(__FILE__,\ __LINE__, __func__); } while (0) -size_t tag__size(const struct tag *self, const struct cu *cu); -size_t tag__nr_cachelines(const struct tag *self, const struct cu *cu); +size_t tag__size(const struct tag *tag, const struct cu *cu); +size_t tag__nr_cachelines(const struct tag *tag, const struct cu *cu); struct tag *tag__follow_typedef(const struct tag *tag, const struct cu *cu); +struct tag *tag__strip_typedefs_and_modifiers(const struct tag *tag, const struct cu *cu); -size_t __tag__id_not_found_fprintf(FILE *fp, uint16_t id, +size_t __tag__id_not_found_fprintf(FILE *fp, type_id_t id, const char *fn, int line); #define tag__id_not_found_fprintf(fp, id) \ __tag__id_not_found_fprintf(fp, id, __func__, __LINE__) -int __tag__has_type_loop(const struct tag *self, const struct tag *type, +int __tag__has_type_loop(const struct tag *tag, const struct tag *type, char *bf, size_t len, FILE *fp, const char *fn, int line); -#define tag__has_type_loop(self, type, bf, len, fp) \ - __tag__has_type_loop(self, type, bf, len, fp, __func__, __LINE__) +#define tag__has_type_loop(tag, type, bf, len, fp) \ + __tag__has_type_loop(tag, type, bf, len, fp, __func__, __LINE__) struct ptr_to_member_type { struct tag tag; - uint16_t containing_type; + type_id_t containing_type; }; static inline struct ptr_to_member_type * - tag__ptr_to_member_type(const struct tag *self) + tag__ptr_to_member_type(const struct tag *tag) { - return (struct ptr_to_member_type *)self; + return (struct ptr_to_member_type *)tag; } /** struct namespace - base class for enums, structs, unions, typedefs, etc @@ -499,31 +602,31 @@ struct list_head tags; }; -static inline struct namespace *tag__namespace(const struct tag *self) +static inline struct namespace *tag__namespace(const struct tag *tag) { - return (struct namespace *)self; + return (struct namespace *)tag; } -void namespace__delete(struct namespace *self, struct cu *cu); +void namespace__delete(struct namespace *nspace, struct cu *cu); /** * namespace__for_each_tag - iterate thru all the tags - * @self: struct namespace instance to iterate + * @nspace: struct namespace instance to iterate * @pos: struct tag iterator */ -#define namespace__for_each_tag(self, pos) \ - list_for_each_entry(pos, &(self)->tags, node) +#define namespace__for_each_tag(nspace, pos) \ + list_for_each_entry(pos, &(nspace)->tags, node) /** * namespace__for_each_tag_safe_reverse - safely iterate thru all the tags, in reverse order - * @self: struct namespace instance to iterate + * @nspace: struct namespace instance to iterate * @pos: struct tag iterator * @n: struct class_member temp iterator */ -#define namespace__for_each_tag_safe_reverse(self, pos, n) \ - list_for_each_entry_safe_reverse(pos, n, &(self)->tags, node) +#define namespace__for_each_tag_safe_reverse(nspace, pos, n) \ + list_for_each_entry_safe_reverse(pos, n, &(nspace)->tags, node) -void namespace__add_tag(struct namespace *self, struct tag *tag); +void namespace__add_tag(struct namespace *nspace, struct tag *tag); struct ip_tag { struct tag tag; @@ -537,9 +640,9 @@ }; static inline struct inline_expansion * - tag__inline_expansion(const struct tag *self) + tag__inline_expansion(const struct tag *tag) { - return (struct inline_expansion *)self; + return (struct inline_expansion *)tag; } struct label { @@ -547,42 +650,52 @@ strings_t name; }; -static inline struct label *tag__label(const struct tag *self) +static inline struct label *tag__label(const struct tag *tag) { - return (struct label *)self; + return (struct label *)tag; } -static inline const char *label__name(const struct label *self, +static inline const char *label__name(const struct label *label, const struct cu *cu) { - return cu__string(cu, self->name); + return cu__string(cu, label->name); } -enum vlocation { - LOCATION_UNKNOWN, - LOCATION_LOCAL, - LOCATION_GLOBAL, - LOCATION_REGISTER, - LOCATION_OPTIMIZED +enum vscope { + VSCOPE_UNKNOWN, + VSCOPE_LOCAL, + VSCOPE_GLOBAL, + VSCOPE_REGISTER, + VSCOPE_OPTIMIZED } __attribute__((packed)); +struct location { + Dwarf_Op *expr; + size_t exprlen; +}; + struct variable { struct ip_tag ip; strings_t name; uint8_t external:1; uint8_t declaration:1; - enum vlocation location; + enum vscope scope; + struct location location; struct hlist_node tool_hnode; + struct variable *spec; }; -static inline struct variable *tag__variable(const struct tag *self) +static inline struct variable *tag__variable(const struct tag *tag) { - return (struct variable *)self; + return (struct variable *)tag; } -const char *variable__name(const struct variable *self, const struct cu *cu); +enum vscope variable__scope(const struct variable *var); +const char *variable__scope_str(const struct variable *var); + +const char *variable__name(const struct variable *var, const struct cu *cu); -const char *variable__type_name(const struct variable *self, +const char *variable__type_name(const struct variable *var, const struct cu *cu, char *bf, size_t len); struct lexblock { @@ -596,22 +709,22 @@ uint32_t size_inline_expansions; }; -static inline struct lexblock *tag__lexblock(const struct tag *self) +static inline struct lexblock *tag__lexblock(const struct tag *tag) { - return (struct lexblock *)self; + return (struct lexblock *)tag; } -void lexblock__delete(struct lexblock *self, struct cu *cu); +void lexblock__delete(struct lexblock *lexblock, struct cu *cu); struct function; -void lexblock__add_inline_expansion(struct lexblock *self, +void lexblock__add_inline_expansion(struct lexblock *lexblock, struct inline_expansion *exp); -void lexblock__add_label(struct lexblock *self, struct label *label); -void lexblock__add_lexblock(struct lexblock *self, struct lexblock *child); -void lexblock__add_tag(struct lexblock *self, struct tag *tag); -void lexblock__add_variable(struct lexblock *self, struct variable *var); -size_t lexblock__fprintf(const struct lexblock *self, const struct cu *cu, +void lexblock__add_label(struct lexblock *lexblock, struct label *label); +void lexblock__add_lexblock(struct lexblock *lexblock, struct lexblock *child); +void lexblock__add_tag(struct lexblock *lexblock, struct tag *tag); +void lexblock__add_variable(struct lexblock *lexblock, struct variable *var); +size_t lexblock__fprintf(const struct lexblock *lexblock, const struct cu *cu, struct function *function, uint16_t indent, const struct conf_fprintf *conf, FILE *fp); @@ -620,15 +733,15 @@ strings_t name; }; -static inline struct parameter *tag__parameter(const struct tag *self) +static inline struct parameter *tag__parameter(const struct tag *tag) { - return (struct parameter *)self; + return (struct parameter *)tag; } -static inline const char *parameter__name(const struct parameter *self, +static inline const char *parameter__name(const struct parameter *parm, const struct cu *cu) { - return cu__string(cu, self->name); + return cu__string(cu, parm->name); } /* @@ -641,48 +754,48 @@ uint8_t unspec_parms; /* just one bit is needed */ }; -static inline struct ftype *tag__ftype(const struct tag *self) +static inline struct ftype *tag__ftype(const struct tag *tag) { - return (struct ftype *)self; + return (struct ftype *)tag; } -void ftype__delete(struct ftype *self, struct cu *cu); +void ftype__delete(struct ftype *ftype, struct cu *cu); /** * ftype__for_each_parameter - iterate thru all the parameters - * @self: struct ftype instance to iterate + * @ftype: struct ftype instance to iterate * @pos: struct parameter iterator */ -#define ftype__for_each_parameter(self, pos) \ - list_for_each_entry(pos, &(self)->parms, tag.node) +#define ftype__for_each_parameter(ftype, pos) \ + list_for_each_entry(pos, &(ftype)->parms, tag.node) /** * ftype__for_each_parameter_safe - safely iterate thru all the parameters - * @self: struct ftype instance to iterate + * @ftype: struct ftype instance to iterate * @pos: struct parameter iterator * @n: struct parameter temp iterator */ -#define ftype__for_each_parameter_safe(self, pos, n) \ - list_for_each_entry_safe(pos, n, &(self)->parms, tag.node) +#define ftype__for_each_parameter_safe(ftype, pos, n) \ + list_for_each_entry_safe(pos, n, &(ftype)->parms, tag.node) /** * ftype__for_each_parameter_safe_reverse - safely iterate thru all the parameters, in reverse order - * @self: struct ftype instance to iterate + * @ftype: struct ftype instance to iterate * @pos: struct parameter iterator * @n: struct parameter temp iterator */ -#define ftype__for_each_parameter_safe_reverse(self, pos, n) \ - list_for_each_entry_safe_reverse(pos, n, &(self)->parms, tag.node) +#define ftype__for_each_parameter_safe_reverse(ftype, pos, n) \ + list_for_each_entry_safe_reverse(pos, n, &(ftype)->parms, tag.node) -void ftype__add_parameter(struct ftype *self, struct parameter *parm); -size_t ftype__fprintf(const struct ftype *self, const struct cu *cu, +void ftype__add_parameter(struct ftype *ftype, struct parameter *parm); +size_t ftype__fprintf(const struct ftype *ftype, const struct cu *cu, const char *name, const int inlined, - const int is_pointer, const int type_spacing, + const int is_pointer, const int type_spacing, bool is_prototype, const struct conf_fprintf *conf, FILE *fp); -size_t ftype__fprintf_parms(const struct ftype *self, +size_t ftype__fprintf_parms(const struct ftype *ftype, const struct cu *cu, int indent, const struct conf_fprintf *conf, FILE *fp); -int ftype__has_parm_of_type(const struct ftype *self, const uint16_t target, +int ftype__has_parm_of_type(const struct ftype *ftype, const type_id_t target, const struct cu *cu); struct function { @@ -698,6 +811,8 @@ uint8_t external:1; uint8_t accessibility:2; /* DW_ACCESS_{public,protected,private} */ uint8_t virtuality:2; /* DW_VIRTUALITY_{none,virtual,pure_virtual} */ + uint8_t declaration:1; + uint8_t btf:1; int32_t vtable_entry; struct list_head vtable_node; /* fields used by tools */ @@ -708,66 +823,66 @@ void *priv; }; -static inline struct function *tag__function(const struct tag *self) +static inline struct function *tag__function(const struct tag *tag) { - return (struct function *)self; + return (struct function *)tag; } -static inline struct tag *function__tag(const struct function *self) +static inline struct tag *function__tag(const struct function *func) { - return (struct tag *)self; + return (struct tag *)func; } -void function__delete(struct function *self, struct cu *cu); +void function__delete(struct function *func, struct cu *cu); -static __pure inline int tag__is_function(const struct tag *self) +static __pure inline int tag__is_function(const struct tag *tag) { - return self->tag == DW_TAG_subprogram; + return tag->tag == DW_TAG_subprogram; } /** * function__for_each_parameter - iterate thru all the parameters - * @self: struct function instance to iterate + * @func: struct function instance to iterate * @pos: struct parameter iterator */ -#define function__for_each_parameter(self, pos) \ - ftype__for_each_parameter(&self->proto, pos) +#define function__for_each_parameter(func, cu, pos) \ + ftype__for_each_parameter(func->btf ? tag__ftype(cu__type(cu, func->proto.tag.type)) : &func->proto, pos) -const char *function__name(struct function *self, const struct cu *cu); +const char *function__name(struct function *func, const struct cu *cu); -static inline const char *function__linkage_name(const struct function *self, +static inline const char *function__linkage_name(const struct function *func, const struct cu *cu) { - return cu__string(cu, self->linkage_name); + return cu__string(cu, func->linkage_name); } -size_t function__fprintf_stats(const struct tag *tag_self, +size_t function__fprintf_stats(const struct tag *tag_func, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp); -const char *function__prototype(const struct function *self, +const char *function__prototype(const struct function *func, const struct cu *cu, char *bf, size_t len); -static __pure inline uint64_t function__addr(const struct function *self) +static __pure inline uint64_t function__addr(const struct function *func) { - return self->lexblock.ip.addr; + return func->lexblock.ip.addr; } -static __pure inline uint32_t function__size(const struct function *self) +static __pure inline uint32_t function__size(const struct function *func) { - return self->lexblock.size; + return func->lexblock.size; } -static inline int function__declared_inline(const struct function *self) +static inline int function__declared_inline(const struct function *func) { - return (self->inlined == DW_INL_declared_inlined || - self->inlined == DW_INL_declared_not_inlined); + return (func->inlined == DW_INL_declared_inlined || + func->inlined == DW_INL_declared_not_inlined); } -static inline int function__inlined(const struct function *self) +static inline int function__inlined(const struct function *func) { - return (self->inlined == DW_INL_inlined || - self->inlined == DW_INL_declared_inlined); + return (func->inlined == DW_INL_inlined || + func->inlined == DW_INL_declared_inlined); } /* struct class_member - struct, union, class member @@ -777,12 +892,14 @@ * @byte_offset - offset in bytes from the start of the struct * @byte_size - cached byte size, integral type byte size for bitfields * @bitfield_offset - offset in the current bitfield - * @bitfield_offset - size in the current bitfield + * @bitfield_size - size in the current bitfield * @bit_hole - If there is a bit hole before the next one (or the end of the struct) * @bitfield_end - Is this the last entry in a bitfield? + * @alignment - DW_AT_alignement, zero if not present, gcc emits since circa 7.3.1 * @accessibility - DW_ACCESS_{public,protected,private} * @virtuality - DW_VIRTUALITY_{none,virtual,pure_virtual} * @hole - If there is a hole before the next one (or the end of the struct) + * @has_bit_offset: Don't recalcule this, it came from the debug info (DWARF5's DW_AT_data_bit_offset) */ struct class_member { struct tag tag; @@ -791,97 +908,138 @@ uint32_t bit_size; uint32_t byte_offset; size_t byte_size; - uint8_t bitfield_offset; + int8_t bitfield_offset; uint8_t bitfield_size; uint8_t bit_hole; uint8_t bitfield_end:1; + uint64_t const_value; + uint32_t alignment; uint8_t visited:1; + uint8_t is_static:1; + uint8_t has_bit_offset:1; uint8_t accessibility:2; uint8_t virtuality:2; uint16_t hole; }; -void class_member__delete(struct class_member *self, struct cu *cu); +void class_member__delete(struct class_member *member, struct cu *cu); -static inline struct class_member *tag__class_member(const struct tag *self) +static inline struct class_member *tag__class_member(const struct tag *tag) { - return (struct class_member *)self; + return (struct class_member *)tag; } -static inline const char *class_member__name(const struct class_member *self, +static inline const char *class_member__name(const struct class_member *member, const struct cu *cu) { - return cu__string(cu, self->name); + return cu__string(cu, member->name); } -static __pure inline int tag__is_class_member(const struct tag *self) +static __pure inline int tag__is_class_member(const struct tag *tag) { - return self->tag == DW_TAG_member; + return tag->tag == DW_TAG_member; } +int tag__is_base_type(const struct tag *tag, const struct cu *cu); +bool tag__is_array(const struct tag *tag, const struct cu *cu); + +struct class_member_filter; + +struct tag_cu_node { + struct list_head node; + struct tag_cu tc; +}; + /** * struct type - base type for enumerations, structs and unions * - * @nr_members: number of DW_TAG_member entries + * @nnr_members: number of non static DW_TAG_member entries + * @nr_static_members: number of static DW_TAG_member entries * @nr_tags: number of tags + * @alignment: DW_AT_alignement, zero if not present, gcc emits since circa 7.3.1 + * @natural_alignment: For inferring __packed__, normally the widest scalar in it, recursively + * @sizeof_member: Use this to find the size of the record + * @type_member: Use this to select a member from where to get an id on an enum to find a type + * to cast for, needs to be used with the upcoming type_enum. + * @type_enum: enumeration(s) to use together with type_member to find a type to cast + * @member_prefix: the common prefix for all members, say in an enum, this should be calculated on demand + * @member_prefix_len: the lenght of the common prefix for all members */ struct type { struct namespace namespace; struct list_head node; uint32_t size; int32_t size_diff; + uint16_t nr_static_members; uint16_t nr_members; + uint32_t alignment; + struct class_member *sizeof_member; + struct class_member *type_member; + struct class_member_filter *filter; + struct list_head type_enum; + char *member_prefix; + uint16_t member_prefix_len; + uint16_t max_tag_name_len; + uint16_t natural_alignment; + bool packed_attributes_inferred; uint8_t declaration; /* only one bit used */ uint8_t definition_emitted:1; uint8_t fwd_decl_emitted:1; uint8_t resized:1; }; -static inline struct class *type__class(const struct type *self) +void __type__init(struct type *type); + +static inline struct class *type__class(const struct type *type) +{ + return (struct class *)type; +} + +static inline struct tag *type__tag(const struct type *type) { - return (struct class *)self; + return (struct tag *)type; } -void type__delete(struct type *self, struct cu *cu); +void type__delete(struct type *type, struct cu *cu); /** * type__for_each_tag - iterate thru all the tags - * @self: struct type instance to iterate + * @type: struct type instance to iterate * @pos: struct tag iterator */ -#define type__for_each_tag(self, pos) \ - list_for_each_entry(pos, &(self)->namespace.tags, node) +#define type__for_each_tag(type, pos) \ + list_for_each_entry(pos, &(type)->namespace.tags, node) /** * type__for_each_enumerator - iterate thru the enumerator entries - * @self: struct type instance to iterate + * @type: struct type instance to iterate * @pos: struct enumerator iterator */ -#define type__for_each_enumerator(self, pos) \ +#define type__for_each_enumerator(type, pos) \ struct list_head *__type__for_each_enumerator_head = \ - (self)->namespace.shared_tags ? \ - (self)->namespace.tags.next : \ - &(self)->namespace.tags; \ + (type)->namespace.shared_tags ? \ + (type)->namespace.tags.next : \ + &(type)->namespace.tags; \ list_for_each_entry(pos, __type__for_each_enumerator_head, tag.node) /** * type__for_each_enumerator_safe_reverse - safely iterate thru the enumerator entries, in reverse order - * @self: struct type instance to iterate + * @type: struct type instance to iterate * @pos: struct enumerator iterator * @n: struct enumerator temp iterator */ -#define type__for_each_enumerator_safe_reverse(self, pos, n) \ - if ((self)->namespace.shared_tags) /* Do nothing */ ; else \ - list_for_each_entry_safe_reverse(pos, n, &(self)->namespace.tags, tag.node) +#define type__for_each_enumerator_safe_reverse(type, pos, n) \ + if ((type)->namespace.shared_tags) /* Do nothing */ ; else \ + list_for_each_entry_safe_reverse(pos, n, &(type)->namespace.tags, tag.node) /** * type__for_each_member - iterate thru the entries that use space * (data members and inheritance entries) - * @self: struct type instance to iterate + * @type: struct type instance to iterate * @pos: struct class_member iterator */ -#define type__for_each_member(self, pos) \ - list_for_each_entry(pos, &(self)->namespace.tags, tag.node) \ +#define type__for_each_member(type, pos) \ + list_for_each_entry(pos, &(type)->namespace.tags, tag.node) \ if (!(pos->tag.tag == DW_TAG_member || \ pos->tag.tag == DW_TAG_inheritance)) \ continue; \ @@ -889,11 +1047,11 @@ /** * type__for_each_data_member - iterate thru the data member entries - * @self: struct type instance to iterate + * @type: struct type instance to iterate * @pos: struct class_member iterator */ -#define type__for_each_data_member(self, pos) \ - list_for_each_entry(pos, &(self)->namespace.tags, tag.node) \ +#define type__for_each_data_member(type, pos) \ + list_for_each_entry(pos, &(type)->namespace.tags, tag.node) \ if (pos->tag.tag != DW_TAG_member) \ continue; \ else @@ -901,54 +1059,61 @@ /** * type__for_each_member_safe - safely iterate thru the entries that use space * (data members and inheritance entries) - * @self: struct type instance to iterate + * @type: struct type instance to iterate * @pos: struct class_member iterator * @n: struct class_member temp iterator */ -#define type__for_each_member_safe(self, pos, n) \ - list_for_each_entry_safe(pos, n, &(self)->namespace.tags, tag.node) \ +#define type__for_each_member_safe(type, pos, n) \ + list_for_each_entry_safe(pos, n, &(type)->namespace.tags, tag.node) \ if (pos->tag.tag != DW_TAG_member) \ continue; \ else /** * type__for_each_data_member_safe - safely iterate thru the data member entries - * @self: struct type instance to iterate + * @type: struct type instance to iterate * @pos: struct class_member iterator * @n: struct class_member temp iterator */ -#define type__for_each_data_member_safe(self, pos, n) \ - list_for_each_entry_safe(pos, n, &(self)->namespace.tags, tag.node) \ +#define type__for_each_data_member_safe(type, pos, n) \ + list_for_each_entry_safe(pos, n, &(type)->namespace.tags, tag.node) \ if (pos->tag.tag != DW_TAG_member) \ continue; \ else /** * type__for_each_tag_safe_reverse - safely iterate thru all tags in a type, in reverse order - * @self: struct type instance to iterate + * @type: struct type instance to iterate * @pos: struct class_member iterator * @n: struct class_member temp iterator */ -#define type__for_each_tag_safe_reverse(self, pos, n) \ - list_for_each_entry_safe_reverse(pos, n, &(self)->namespace.tags, tag.node) +#define type__for_each_tag_safe_reverse(type, pos, n) \ + list_for_each_entry_safe_reverse(pos, n, &(type)->namespace.tags, tag.node) -void type__add_member(struct type *self, struct class_member *member); +void type__add_member(struct type *type, struct class_member *member); struct class_member * - type__find_first_biggest_size_base_type_member(struct type *self, + type__find_first_biggest_size_base_type_member(struct type *type, const struct cu *cu); -struct class_member *type__find_member_by_name(const struct type *self, +struct class_member *type__find_member_by_name(const struct type *type, const struct cu *cu, const char *name); -uint32_t type__nr_members_of_type(const struct type *self, const uint16_t type); -struct class_member *type__last_member(struct type *self); +uint32_t type__nr_members_of_type(const struct type *type, const type_id_t oftype); +struct class_member *type__last_member(struct type *type); + +void enumeration__calc_prefix(struct type *type, const struct cu *cu); +const char *enumeration__prefix(struct type *type, const struct cu *cu); +uint16_t enumeration__prefix_len(struct type *type, const struct cu *cu); +int enumeration__max_entry_name_len(struct type *type, const struct cu *cu); + +void enumerations__calc_prefix(struct list_head *enumerations); -size_t typedef__fprintf(const struct tag *tag_self, const struct cu *cu, +size_t typedef__fprintf(const struct tag *tag_type, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp); -static inline struct type *tag__type(const struct tag *self) +static inline struct type *tag__type(const struct tag *tag) { - return (struct type *)self; + return (struct type *)tag; } struct class { @@ -957,85 +1122,122 @@ uint16_t nr_vtable_entries; uint8_t nr_holes; uint8_t nr_bit_holes; + uint16_t pre_hole; uint16_t padding; + uint8_t pre_bit_hole; uint8_t bit_padding; + bool holes_searched; + bool is_packed; void *priv; }; -static inline struct class *tag__class(const struct tag *self) +static inline struct class *tag__class(const struct tag *tag) { - return (struct class *)self; + return (struct class *)tag; } -static inline struct tag *class__tag(const struct class *self) +static inline struct tag *class__tag(const struct class *cls) { - return (struct tag *)self; + return (struct tag *)cls; } struct class *class__clone(const struct class *from, const char *new_class_name, struct cu *cu); -void class__delete(struct class *self, struct cu *cu); +void class__delete(struct class *cls, struct cu *cu); -static inline struct list_head *class__tags(struct class *self) +static inline struct list_head *class__tags(struct class *cls) { - return &self->type.namespace.tags; + return &cls->type.namespace.tags; } -static __pure inline const char *namespace__name(const struct namespace *self, +static __pure inline const char *namespace__name(const struct namespace *nspace, const struct cu *cu) { - return self->sname ?: cu__string(cu, self->name); + return nspace->sname ?: cu__string(cu, nspace->name); } -static __pure inline const char *type__name(const struct type *self, +static __pure inline const char *type__name(const struct type *type, const struct cu *cu) { - return namespace__name(&self->namespace, cu); + return namespace__name(&type->namespace, cu); } -static __pure inline const char *class__name(struct class *self, +static __pure inline const char *class__name(struct class *cls, const struct cu *cu) { - return type__name(&self->type, cu); + return type__name(&cls->type, cu); } -static inline int class__is_struct(const struct class *self) +static inline int class__is_struct(const struct class *cls) { - return tag__is_struct(&self->type.namespace.tag); + return tag__is_struct(&cls->type.namespace.tag); } -void class__find_holes(struct class *self); -int class__has_hole_ge(const struct class *self, const uint16_t size); -size_t class__fprintf(struct class *self, const struct cu *cu, - const struct conf_fprintf *conf, FILE *fp); +void class__find_holes(struct class *cls); +int class__has_hole_ge(const struct class *cls, const uint16_t size); + +bool class__infer_packed_attributes(struct class *cls, const struct cu *cu); -void class__add_vtable_entry(struct class *self, struct function *vtable_entry); +void union__infer_packed_attributes(struct type *type, const struct cu *cu); + +void type__check_structs_at_unnatural_alignments(struct type *type, const struct cu *cu); + +size_t class__fprintf(struct class *cls, const struct cu *cu, FILE *fp); + +void class__add_vtable_entry(struct class *cls, struct function *vtable_entry); static inline struct class_member * - class__find_member_by_name(const struct class *self, + class__find_member_by_name(const struct class *cls, const struct cu *cu, const char *name) { - return type__find_member_by_name(&self->type, cu, name); + return type__find_member_by_name(&cls->type, cu, name); } -static inline uint16_t class__nr_members(const struct class *self) +static inline uint16_t class__nr_members(const struct class *cls) { - return self->type.nr_members; + return cls->type.nr_members; } -static inline uint32_t class__size(const struct class *self) +static inline uint32_t class__size(const struct class *cls) { - return self->type.size; + return cls->type.size; } -static inline int class__is_declaration(const struct class *self) +static inline int class__is_declaration(const struct class *cls) { - return self->type.declaration; + return cls->type.declaration; } -const struct class_member *class__find_bit_hole(const struct class *self, +const struct class_member *class__find_bit_hole(const struct class *cls, const struct class_member *trailer, const uint16_t bit_hole_size); +#define class__for_each_member_from(cls, from, pos) \ + pos = list_prepare_entry(from, class__tags(cls), tag.node); \ + list_for_each_entry_from(pos, class__tags(cls), tag.node) \ + if (!tag__is_class_member(&pos->tag)) \ + continue; \ + else + +#define class__for_each_member_safe_from(cls, from, pos, tmp) \ + pos = list_prepare_entry(from, class__tags(cls), tag.node); \ + list_for_each_entry_safe_from(pos, tmp, class__tags(cls), tag.node) \ + if (!tag__is_class_member(&pos->tag)) \ + continue; \ + else + +#define class__for_each_member_continue(cls, from, pos) \ + pos = list_prepare_entry(from, class__tags(cls), tag.node); \ + list_for_each_entry_continue(pos, class__tags(cls), tag.node) \ + if (!tag__is_class_member(&pos->tag)) \ + continue; \ + else + +#define class__for_each_member_reverse(cls, member) \ + list_for_each_entry_reverse(member, class__tags(cls), tag.node) \ + if (member->tag.tag != DW_TAG_member) \ + continue; \ + else + enum base_type_float_type { BT_FP_SINGLE = 1, BT_FP_DOUBLE, @@ -1062,21 +1264,21 @@ uint8_t float_type:4; }; -static inline struct base_type *tag__base_type(const struct tag *self) +static inline struct base_type *tag__base_type(const struct tag *tag) { - return (struct base_type *)self; + return (struct base_type *)tag; } -static inline uint16_t base_type__size(const struct tag *self) +static inline uint16_t base_type__size(const struct tag *tag) { - return tag__base_type(self)->bit_size / 8; + return tag__base_type(tag)->bit_size / 8; } -const char *base_type__name(const struct base_type *self, const struct cu *cu, +const char *base_type__name(const struct base_type *btype, const struct cu *cu, char *bf, size_t len); void base_type_name_to_size_table__init(struct strings *strings); -size_t base_type__name_to_size(struct base_type *self, struct cu *cu); +size_t base_type__name_to_size(struct base_type *btype, struct cu *cu); struct array_type { struct tag tag; @@ -1085,26 +1287,37 @@ bool is_vector; }; -static inline struct array_type *tag__array_type(const struct tag *self) +static inline struct array_type *tag__array_type(const struct tag *tag) { - return (struct array_type *)self; + return (struct array_type *)tag; +} + +struct string_type { + struct tag tag; + uint32_t nr_entries; +}; + +static inline struct string_type *tag__string_type(const struct tag *tag) +{ + return (struct string_type *)tag; } struct enumerator { struct tag tag; strings_t name; uint32_t value; + struct tag_cu type_enum; // To cache the type_enum searches }; -static inline const char *enumerator__name(const struct enumerator *self, +static inline const char *enumerator__name(const struct enumerator *enumerator, const struct cu *cu) { - return cu__string(cu, self->name); + return cu__string(cu, enumerator->name); } -void enumeration__delete(struct type *self, struct cu *cu); -void enumeration__add(struct type *self, struct enumerator *enumerator); -size_t enumeration__fprintf(const struct tag *tag_self, const struct cu *cu, +void enumeration__delete(struct type *type, struct cu *cu); +void enumeration__add(struct type *type, struct enumerator *enumerator); +size_t enumeration__fprintf(const struct tag *tag_enum, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp); int dwarves__init(uint16_t user_cacheline_size); @@ -1115,5 +1328,12 @@ struct argp_state; void dwarves_print_version(FILE *fp, struct argp_state *state); +void dwarves_print_numeric_version(FILE *fp); + +extern bool print_numeric_version;; + +extern bool no_bitfield_type_recode; + +extern const char tabs[]; #endif /* _DWARVES_H_ */ diff -Nru dwarves-dfsg-1.10/dwarves_reorganize.c dwarves-dfsg-1.21/dwarves_reorganize.c --- dwarves-dfsg-1.10/dwarves_reorganize.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/dwarves_reorganize.c 2019-12-13 14:40:33.000000000 +0000 @@ -1,51 +1,55 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo Copyright (C) 2007 Red Hat Inc. Copyright (C) 2007 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include "list.h" #include "dwarves_reorganize.h" #include "dwarves.h" -void class__subtract_offsets_from(struct class *self, +static void class__recalc_holes(struct class *class) +{ + class->holes_searched = 0; + class__find_holes(class); +} + +void class__subtract_offsets_from(struct class *class, struct class_member *from, const uint16_t size) { - struct class_member *member = - list_prepare_entry(from, class__tags(self), tag.node); + struct class_member *member; - list_for_each_entry_continue(member, class__tags(self), tag.node) - if (member->tag.tag == DW_TAG_member) - member->byte_offset -= size; + class__for_each_member_continue(class, from, member) { + member->byte_offset -= size; + member->bit_offset -= size * 8; + } - if (self->padding != 0) { + if (class->padding != 0) { struct class_member *last_member = - type__last_member(&self->type); - const ssize_t new_padding = (class__size(self) - + type__last_member(&class->type); + const ssize_t new_padding = (class__size(class) - (last_member->byte_offset + last_member->byte_size)); if (new_padding > 0) - self->padding = new_padding; + class->padding = new_padding; else - self->padding = 0; + class->padding = 0; } } -void class__add_offsets_from(struct class *self, struct class_member *from, +void class__add_offsets_from(struct class *class, struct class_member *from, const uint16_t size) { - struct class_member *member = - list_prepare_entry(from, class__tags(self), tag.node); + struct class_member *member; - list_for_each_entry_continue(member, class__tags(self), tag.node) - if (member->tag.tag == DW_TAG_member) - member->byte_offset += size; + class__for_each_member_continue(class, from, member) { + member->byte_offset += size; + member->bit_offset += size * 8; + } } /* @@ -53,17 +57,18 @@ * to lazy to do class__remove_member properly, adjusting alignments and * holes as we go removing fields. Ditto for class__add_offsets_from. */ -void class__fixup_alignment(struct class *self, const struct cu *cu) +void class__fixup_alignment(struct class *class, const struct cu *cu) { struct class_member *pos, *last_member = NULL; size_t power2; - type__for_each_data_member(&self->type, pos) { + type__for_each_data_member(&class->type, pos) { if (last_member == NULL && pos->byte_offset != 0) { /* paranoid! */ - class__subtract_offsets_from(self, pos, + class__subtract_offsets_from(class, pos, (pos->byte_offset - pos->byte_size)); pos->byte_offset = 0; + pos->bit_offset = 0; } else if (last_member != NULL && last_member->hole >= cu->addr_size) { size_t dec = (last_member->hole / cu->addr_size) * @@ -71,10 +76,11 @@ last_member->hole -= dec; if (last_member->hole == 0) - --self->nr_holes; + --class->nr_holes; pos->byte_offset -= dec; - self->type.size -= dec; - class__subtract_offsets_from(self, pos, dec); + pos->bit_offset -= dec * 8; + class->type.size -= dec; + class__subtract_offsets_from(class, pos, dec); } else for (power2 = cu->addr_size; power2 >= 2; power2 /= 2) { const size_t remainder = pos->byte_offset % power2; @@ -84,18 +90,20 @@ if (last_member->hole >= remainder) { last_member->hole -= remainder; if (last_member->hole == 0) - --self->nr_holes; + --class->nr_holes; pos->byte_offset -= remainder; - class__subtract_offsets_from(self, pos, remainder); + pos->bit_offset -= remainder * 8; + class__subtract_offsets_from(class, pos, remainder); } else { const size_t inc = power2 - remainder; if (last_member->hole == 0) - ++self->nr_holes; + ++class->nr_holes; last_member->hole += inc; pos->byte_offset += inc; - self->type.size += inc; - class__add_offsets_from(self, pos, inc); + pos->bit_offset += inc * 8; + class->type.size += inc; + class__add_offsets_from(class, pos, inc); } } } @@ -105,7 +113,7 @@ if (last_member != NULL) { struct class_member *m = - type__find_first_biggest_size_base_type_member(&self->type, cu); + type__find_first_biggest_size_base_type_member(&class->type, cu); size_t unpadded_size = last_member->byte_offset + last_member->byte_size; size_t m_size = m->byte_size, remainder; @@ -115,8 +123,8 @@ remainder = unpadded_size % m_size; if (remainder != 0) { - self->padding = m_size - remainder; - self->type.size = unpadded_size + self->padding; + class->padding = m_size - remainder; + class->type.size = unpadded_size + class->padding; } } } @@ -125,13 +133,10 @@ class__find_next_hole_of_size(struct class *class, struct class_member *from, size_t size) { - struct class_member *member = - list_prepare_entry(from, class__tags(class), tag.node); struct class_member *bitfield_head = NULL; + struct class_member *member; - list_for_each_entry_continue(member, class__tags(class), tag.node) { - if (member->tag.tag != DW_TAG_member) - continue; + class__for_each_member_continue(class, from, member) { if (member->bitfield_size != 0) { if (bitfield_head == NULL) bitfield_head = member; @@ -152,7 +157,7 @@ { struct class_member *member; - list_for_each_entry_reverse(member, class__tags(class), tag.node) { + class__for_each_member_reverse(class, member) { if (member->tag.tag != DW_TAG_member) continue; @@ -180,46 +185,20 @@ return NULL; } -static struct class_member * - class__find_next_bit_hole_of_size(struct class *class, - struct class_member *from, - size_t size) +static bool class__move_member(struct class *class, struct class_member *dest, + struct class_member *from, const struct cu *cu, + int from_padding, const int verbose, FILE *fp) { - struct class_member *member = - list_prepare_entry(from, class__tags(class), tag.node); + const size_t from_size = from->byte_size; + const size_t dest_size = dest->byte_size; - list_for_each_entry_continue(member, class__tags(class), tag.node) { - if (member->tag.tag != DW_TAG_member) - continue; - if (member->bit_hole != 0 && - member->bitfield_size <= size) - return member; - } -#if 0 +#ifndef BITFIELD_REORG_ALGORITHMS_ENABLED /* - * FIXME: Handle the case where the bit padding is on the same bitfield - * that we're looking, i.e. we can't combine a bitfield with itself, - * perhaps we should tag bitfields with a sequential, clearly marking - * each of the bitfields in advance, so that all the algoriths that - * have to deal with bitfields, moving them around, demoting, etc, can - * be simplified. + * For now refuse to move a bitfield, we need to first fixup some BRAIN FARTs */ - /* - * Now look if the last member is a one member bitfield, - * i.e. if we have bit_padding - */ - if (class->bit_padding != 0) - return type__last_member(&class->type); + if (from->bitfield_size != 0) + return false; #endif - return NULL; -} - -static void class__move_member(struct class *class, struct class_member *dest, - struct class_member *from, const struct cu *cu, - int from_padding, const int verbose, FILE *fp) -{ - const size_t from_size = from->byte_size; - const size_t dest_size = dest->byte_size; const bool from_was_last = from->tag.node.next == class__tags(class); struct class_member *tail_from = from; struct class_member *from_prev = list_entry(from->tag.node.prev, @@ -241,20 +220,13 @@ fputs("/* Moving", fp); if (from->bitfield_size != 0) { - struct class_member *pos = - list_prepare_entry(from, class__tags(class), - tag.node); - struct class_member *tmp; - uint8_t orig_tail_from_bit_hole = 0; + struct class_member *pos, *tmp; LIST_HEAD(from_list); if (verbose) fprintf(fp, " bitfield('%s' ... ", class_member__name(from, cu)); - list_for_each_entry_safe_from(pos, tmp, class__tags(class), - tag.node) { - if (pos->tag.tag != DW_TAG_member) - continue; + class__for_each_member_safe_from(class, from, pos, tmp) { /* * Have we reached the end of the bitfield? */ @@ -262,13 +234,10 @@ break; tail_from = pos; orig_tail_from_hole = tail_from->hole; - orig_tail_from_bit_hole = tail_from->bit_hole; pos->byte_offset = new_from_offset; - pos->hole = 0; - pos->bit_hole = 0; + pos->bit_offset = new_from_offset * 8 + pos->bitfield_offset; list_move_tail(&pos->tag.node, &from_list); } - tail_from->bit_hole = orig_tail_from_bit_hole; list_splice(&from_list, &dest->tag.node); if (verbose) fprintf(fp, "'%s')", @@ -286,6 +255,7 @@ __list_add(&from->tag.node, &dest->tag.node, dest->tag.node.next); from->byte_offset = new_from_offset; + from->bit_offset = new_from_offset * 8 + from->bitfield_offset; } if (verbose) @@ -302,12 +272,10 @@ * Good, no need for padding anymore: */ class->type.size -= from_size + class->padding; - class->padding = 0; } else { /* * No, so just add from_size to the padding: */ - class->padding += from_size; if (verbose) fprintf(fp, "/* adding %zd bytes from %s to " "the padding */\n", @@ -315,7 +283,6 @@ } } else if (from_was_last) { class->type.size -= from_size + class->padding; - class->padding = 0; } else { /* * See if we are adding a new hole that is bigger than @@ -332,28 +299,51 @@ class->type.size -= cu->addr_size; class__subtract_offsets_from(class, from_prev, cu->addr_size); - } else { - /* - * Add the hole after 'from' + its size to the member - * before it: - */ - from_prev->hole += orig_tail_from_hole + from_size; } - /* - * Check if we have eliminated a hole - */ - if (dest->hole == from_size) - class->nr_holes--; } - tail_from->hole = dest->hole - (from_size + offset); - dest->hole = offset; + class__recalc_holes(class); if (verbose > 1) { - class__find_holes(class); - class__fprintf(class, cu, NULL, fp); + class__fprintf(class, cu, fp); fputc('\n', fp); } + + return true; +} + +#ifdef BITFIELD_REORG_ALGORITHMS_ENABLED +static struct class_member * + class__find_next_bit_hole_of_size(struct class *class, + struct class_member *from, + size_t size) +{ + struct class_member *member; + + class__for_each_member_continue(class, from, member) { + if (member->tag.tag != DW_TAG_member) + continue; + if (member->bit_hole != 0 && + member->bitfield_size <= size) + return member; + } +#if 0 + /* + * FIXME: Handle the case where the bit padding is on the same bitfield + * that we're looking, i.e. we can't combine a bitfield with itclass, + * perhaps we should tag bitfields with a sequential, clearly marking + * each of the bitfields in advance, so that all the algoriths that + * have to deal with bitfields, moving them around, demoting, etc, can + * be simplified. + */ + /* + * Now look if the last member is a one member bitfield, + * i.e. if we have bit_padding + */ + if (class->bit_padding != 0) + return type__last_member(&class->type); +#endif + return NULL; } static void class__move_bit_member(struct class *class, const struct cu *cu, @@ -364,8 +354,6 @@ struct class_member *from_prev = list_entry(from->tag.node.prev, struct class_member, tag.node); - const uint8_t is_last_member = (from->tag.node.next == - class__tags(class)); if (verbose) fprintf(fp, "/* Moving '%s:%u' from after '%s' to " @@ -394,41 +382,23 @@ class->type.size -= from_size + from->hole; class__subtract_offsets_from(class, from_prev, from_size + from->hole); - } else if (is_last_member) - class->padding += from_size; - else - from_prev->hole += from_size + from->hole; - if (is_last_member) { - /* - * Now we don't have bit_padding anymore - */ - class->bit_padding = 0; - } else - class->nr_bit_holes--; - } else { - /* - * Add add the holes after from + its size to the member - * before it: - */ - from_prev->bit_hole += from->bit_hole + from->bitfield_size; - from_prev->hole = from->hole; + } } - from->bit_hole = dest->bit_hole - from->bitfield_size; /* * Tricky, what are the rules for bitfield layouts on this arch? * Assume its IA32 */ from->bitfield_offset = dest->bitfield_offset + dest->bitfield_size; /* - * Now both have the some offset: + * Now both have the same offset: */ from->byte_offset = dest->byte_offset; - dest->bit_hole = 0; - from->hole = dest->hole; - dest->hole = 0; + from->bit_offset = dest->byte_offset * 8 + from->bitfield_offset; + + class__recalc_holes(class); + if (verbose > 1) { - class__find_holes(class); - class__fprintf(class, cu, NULL, fp); + class__fprintf(class, cu, fp); fputc('\n', fp); } } @@ -438,29 +408,20 @@ struct class_member *to, const struct base_type *old_type, const struct base_type *new_type, - uint16_t new_type_id) + type_id_t new_type_id) { - const uint8_t bit_diff = old_type->bit_size - new_type->bit_size; - struct class_member *member = - list_prepare_entry(from, class__tags(class), tag.node); + struct class_member *member; - list_for_each_entry_from(member, class__tags(class), tag.node) { - if (member->tag.tag != DW_TAG_member) - continue; - /* - * Assume IA32 bitfield layout - */ - member->bitfield_offset -= bit_diff; + class__for_each_member_from(class, from, member) { member->byte_size = new_type->bit_size / 8; member->tag.type = new_type_id; if (member == to) break; - member->bit_hole = 0; } } static struct tag *cu__find_base_type_of_size(const struct cu *cu, - const size_t size, uint16_t *id) + const size_t size, type_id_t *id) { const char *type_name, *type_name_alt = NULL; @@ -496,7 +457,7 @@ struct class_member *member; struct class_member *bitfield_head = NULL; const struct tag *old_type_tag, *new_type_tag; - size_t current_bitfield_size = 0, size, bytes_needed, new_size; + size_t current_bitfield_size = 0, size, bytes_needed; int some_was_demoted = 0; type__for_each_data_member(&class->type, member) { @@ -533,11 +494,11 @@ size = member->byte_size; bytes_needed = (current_bitfield_size + 7) / 8; - bytes_needed = roundup(bytes_needed, 2); + bytes_needed = roundup_pow_of_two(bytes_needed); if (bytes_needed == size) continue; - uint16_t new_type_id; + type_id_t new_type_id; old_type_tag = cu__type(cu, member->tag.type); new_type_tag = cu__find_base_type_of_size(cu, bytes_needed, &new_type_id); @@ -564,20 +525,11 @@ tag__base_type(old_type_tag), tag__base_type(new_type_tag), new_type_id); - new_size = member->byte_size; - member->hole = size - new_size; - if (member->hole != 0) - ++class->nr_holes; - member->bit_hole = new_size * 8 - current_bitfield_size; + class__recalc_holes(class); some_was_demoted = 1; - /* - * Have we packed it so that there are no hole now? - */ - if (member->bit_hole == 0) - --class->nr_bit_holes; + if (verbose > 1) { - class__find_holes(class); - class__fprintf(class, cu, NULL, fp); + class__fprintf(class, cu, fp); fputc('\n', fp); } } @@ -593,7 +545,7 @@ bytes_needed = (member->bitfield_size + 7) / 8; if (bytes_needed < size) { old_type_tag = cu__type(cu, member->tag.type); - uint16_t new_type_id; + type_id_t new_type_id; new_type_tag = cu__find_base_type_of_size(cu, bytes_needed, &new_type_id); @@ -613,30 +565,14 @@ } class__demote_bitfield_members(class, member, member, - tag__base_type(old_type_tag), - tag__base_type(new_type_tag), + tag__base_type(old_type_tag), + tag__base_type(new_type_tag), new_type_id); - new_size = member->byte_size; - member->hole = 0; - /* - * Do we need byte padding? - */ - if (member->byte_offset + new_size < class__size(class)) { - class->padding = (class__size(class) - - (member->byte_offset + new_size)); - class->bit_padding = 0; - member->bit_hole = (new_size * 8 - - member->bitfield_size); - } else { - class->padding = 0; - class->bit_padding = (new_size * 8 - - member->bitfield_size); - member->bit_hole = 0; - } + class__recalc_holes(class); some_was_demoted = 1; + if (verbose > 1) { - class__find_holes(class); - class__fprintf(class, cu, NULL, fp); + class__fprintf(class, cu, fp); fputc('\n', fp); } } @@ -671,17 +607,14 @@ } } -static void class__fixup_bitfield_types(struct class *self, +static void class__fixup_bitfield_types(struct class *class, struct class_member *from, struct class_member *to_before, - uint16_t type) + type_id_t type) { - struct class_member *member = - list_prepare_entry(from, class__tags(self), tag.node); + struct class_member *member; - list_for_each_entry_from(member, class__tags(self), tag.node) { - if (member->tag.tag != DW_TAG_member) - continue; + class__for_each_member_from(class, from, member) { if (member == to_before) break; member->tag.type = type; @@ -712,13 +645,13 @@ * the reorganizing routines we just do the demotion ourselves, fixing up the * sizes. */ -static void class__fixup_member_types(struct class *self, const struct cu *cu, +static void class__fixup_member_types(struct class *class, const struct cu *cu, const uint8_t verbose, FILE *fp) { struct class_member *pos, *bitfield_head = NULL; uint8_t fixup_was_done = 0; - type__for_each_data_member(&self->type, pos) { + type__for_each_data_member(&class->type, pos) { /* * Is this bitfield member? */ @@ -738,8 +671,30 @@ const uint16_t real_size = (pos->byte_offset - bitfield_head->byte_offset); const size_t size = bitfield_head->byte_size; - if (real_size != size) { - uint16_t new_type_id; + /* + * Another case: +struct irq_cfg { + struct irq_pin_list * irq_2_pin; / * 0 8 * / + cpumask_var_t domain; / * 8 16 * / + cpumask_var_t old_domain; / * 24 16 * / + u8 vector; / * 40 1 * / + u8 move_in_progress:1; / * 41: 7 1 * / + u8 remapped:1; / * 41: 6 1 * / + + / * XXX 6 bits hole, try to pack * / + / * XXX 6 bytes hole, try to pack * / + + union { + struct irq_2_iommu irq_2_iommu; / * 16 * / + struct irq_2_irte irq_2_irte; / * 4 * / + }; / * 48 16 * / + / * --- cacheline 1 boundary (64 bytes) --- * / + + * So just fix it up if the byte_size of the bitfield is + * greater than what it really uses. + */ + if (real_size < size) { + type_id_t new_type_id; struct tag *new_type_tag = cu__find_base_type_of_size(cu, real_size, @@ -750,7 +705,7 @@ __func__, real_size); continue; } - class__fixup_bitfield_types(self, + class__fixup_bitfield_types(class, bitfield_head, pos, new_type_id); fixup_was_done = 1; @@ -758,40 +713,43 @@ } bitfield_head = NULL; } + if (fixup_was_done) { + class__recalc_holes(class); + } if (verbose && fixup_was_done) { fprintf(fp, "/* bitfield types were fixed */\n"); if (verbose > 1) { - class__find_holes(self); - class__fprintf(self, cu, NULL, fp); + class__fprintf(class, cu, fp); fputc('\n', fp); } } } +#endif // BITFIELD_REORG_ALGORITHMS_ENABLED -void class__reorganize(struct class *self, const struct cu *cu, +void class__reorganize(struct class *class, const struct cu *cu, const int verbose, FILE *fp) { struct class_member *member, *brother, *last_member; size_t alignment_size; - class__fixup_member_types(self, cu, verbose, fp); - - while (class__demote_bitfields(self, cu, verbose, fp)) - class__reorganize_bitfields(self, cu, verbose, fp); - + class__find_holes(class); +#ifdef BITFIELD_REORG_ALGORITHMS_ENABLED + class__fixup_member_types(class, cu, verbose, fp); + while (class__demote_bitfields(class, cu, verbose, fp)) + class__reorganize_bitfields(class, cu, verbose, fp); +#endif /* Now try to combine holes */ restart: alignment_size = 0; - class__find_holes(self); /* * It can be NULL if this class doesn't have any data members, * just inheritance entries */ - last_member = type__last_member(&self->type); + last_member = type__last_member(&class->type); if (last_member == NULL) return; - type__for_each_data_member(&self->type, member) { + type__for_each_data_member(&class->type, member) { const size_t aligned_size = member->byte_size + member->hole; if (aligned_size <= cu->addr_size && aligned_size > alignment_size) @@ -811,21 +769,21 @@ else new_padding = 0; - if (new_padding != self->padding) { - self->padding = new_padding; - self->type.size = (last_member->byte_offset + + if (new_padding != class->padding) { + class->padding = new_padding; + class->type.size = (last_member->byte_offset + last_member->byte_size + new_padding); } } - type__for_each_data_member(&self->type, member) { + type__for_each_data_member(&class->type, member) { /* See if we have a hole after this member */ if (member->hole != 0) { /* * OK, try to find a member that has a hole after it * and that has a size that fits the current hole: */ - brother = class__find_next_hole_of_size(self, member, + brother = class__find_next_hole_of_size(class, member, member->hole); if (brother != NULL) { struct class_member *brother_prev = @@ -839,10 +797,8 @@ * kernel. */ if (brother_prev != member) { - class__move_member(self, member, - brother, cu, 0, - verbose, fp); - goto restart; + if (class__move_member(class, member, brother, cu, 0, verbose, fp)) + goto restart; } } /* @@ -852,25 +808,24 @@ * we can move it after the current member, reducing * the padding or eliminating it altogether. */ - if (self->padding > 0 && + if (class->padding > 0 && member != last_member && last_member->byte_size != 0 && last_member->byte_size <= member->hole) { - class__move_member(self, member, last_member, - cu, 1, verbose, fp); - goto restart; + if (class__move_member(class, member, last_member, cu, 1, verbose, fp)) + goto restart; } } } /* Now try to move members at the tail to after holes */ - if (self->nr_holes == 0) + if (class->nr_holes == 0) return; - type__for_each_data_member(&self->type, member) { + type__for_each_data_member(&class->type, member) { /* See if we have a hole after this member */ if (member->hole != 0) { - brother = class__find_last_member_of_size(self, member, + brother = class__find_last_member_of_size(class, member, member->hole); if (brother != NULL) { struct class_member *brother_prev = @@ -884,10 +839,8 @@ * kernel. */ if (brother_prev != member) { - class__move_member(self, member, - brother, cu, 0, - verbose, fp); - goto restart; + if (class__move_member(class, member, brother, cu, 0, verbose, fp)) + goto restart; } } } diff -Nru dwarves-dfsg-1.10/dwarves_reorganize.h dwarves-dfsg-1.21/dwarves_reorganize.h --- dwarves-dfsg-1.10/dwarves_reorganize.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/dwarves_reorganize.h 2019-05-01 15:06:45.000000000 +0000 @@ -1,13 +1,11 @@ #ifndef _DWARVES_REORGANIZE_H_ #define _DWARVES_REORGANIZE_H_ 1 /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo Copyright (C) 2007 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ @@ -18,15 +16,15 @@ struct cu; struct class_member; -void class__subtract_offsets_from(struct class *self, struct class_member *from, +void class__subtract_offsets_from(struct class *cls, struct class_member *from, const uint16_t size); -void class__add_offsets_from(struct class *self, struct class_member *from, +void class__add_offsets_from(struct class *cls, struct class_member *from, const uint16_t size); -void class__fixup_alignment(struct class *self, const struct cu *cu); +void class__fixup_alignment(struct class *cls, const struct cu *cu); -void class__reorganize(struct class *self, const struct cu *cu, +void class__reorganize(struct class *cls, const struct cu *cu, const int verbose, FILE *fp); #endif /* _DWARVES_REORGANIZE_H_ */ diff -Nru dwarves-dfsg-1.10/elfcreator.c dwarves-dfsg-1.21/elfcreator.c --- dwarves-dfsg-1.10/elfcreator.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/elfcreator.c 2019-12-16 14:19:47.000000000 +0000 @@ -1,9 +1,7 @@ /* - * Copyright 2009 Red Hat, Inc. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. + * Copyright 2009 Red Hat, Inc. * * Author: Peter Jones */ @@ -56,7 +54,6 @@ ElfCreator *elfcreator_begin(char *path, Elf *elf) { ElfCreator *ctor = NULL; GElf_Ehdr ehdr_mem, *ehdr; - GElf_Half machine; if (!(ctor = calloc(1, sizeof(*ctor)))) return NULL; @@ -67,7 +64,6 @@ ctor->oldelf = elf; ehdr = gelf_getehdr(elf, &ehdr_mem); - machine = ehdr->e_machine; if ((ctor->fd = open(path, O_RDWR|O_CREAT|O_TRUNC, 0755)) < 0) { err: @@ -187,7 +183,7 @@ { GElf_Shdr *shdr, shdr_mem; GElf_Dyn *dyn, dyn_mem; - size_t idx; + size_t idx = 0; dyn = get_dyn_by_tag(ctor, d_tag, &dyn_mem, &idx); shdr = gelf_getshdr(scn, &shdr_mem); @@ -203,7 +199,7 @@ { GElf_Shdr *shdr, shdr_mem; GElf_Dyn *dyn, dyn_mem; - size_t idx; + size_t idx = 0; dyn = get_dyn_by_tag(ctor, d_tag, &dyn_mem, &idx); shdr = gelf_getshdr(scn, &shdr_mem); @@ -224,7 +220,7 @@ { GElf_Shdr *shdr, shdr_mem; GElf_Dyn *dyn, dyn_mem; - size_t idx; + size_t idx = 0; dyn = get_dyn_by_tag(ctor, d_tag, &dyn_mem, &idx); shdr = gelf_getshdr(scn, &shdr_mem); diff -Nru dwarves-dfsg-1.10/elfcreator.h dwarves-dfsg-1.21/elfcreator.h --- dwarves-dfsg-1.10/elfcreator.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/elfcreator.h 2019-05-01 15:06:45.000000000 +0000 @@ -1,9 +1,7 @@ /* - * Copyright 2009 Red Hat, Inc. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. + * Copyright 2009 Red Hat, Inc. * * Author: Peter Jones */ diff -Nru dwarves-dfsg-1.10/elf_symtab.c dwarves-dfsg-1.21/elf_symtab.c --- dwarves-dfsg-1.10/elf_symtab.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/elf_symtab.c 2021-03-07 13:51:27.000000000 +0000 @@ -1,10 +1,8 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2009 Red Hat Inc. Copyright (C) 2009 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include @@ -19,11 +17,13 @@ struct elf_symtab *elf_symtab__new(const char *name, Elf *elf, GElf_Ehdr *ehdr) { + size_t symtab_index; + if (name == NULL) name = ".symtab"; GElf_Shdr shdr; - Elf_Scn *sec = elf_section_by_name(elf, ehdr, &shdr, name, NULL); + Elf_Scn *sec = elf_section_by_name(elf, ehdr, &shdr, name, &symtab_index); if (sec == NULL) return NULL; @@ -31,40 +31,75 @@ if (gelf_getshdr(sec, &shdr) == NULL) return NULL; - struct elf_symtab *self = malloc(sizeof(*self)); - if (self == NULL) + struct elf_symtab *symtab = zalloc(sizeof(*symtab)); + if (symtab == NULL) return NULL; - self->name = strdup(name); - if (self->name == NULL) + symtab->name = strdup(name); + if (symtab->name == NULL) goto out_delete; - self->syms = elf_getdata(sec, NULL); - if (self->syms == NULL) + symtab->syms = elf_getdata(sec, NULL); + if (symtab->syms == NULL) goto out_free_name; + /* + * This returns extended section index table's + * section index, if it exists. + */ + int symtab_xindex = elf_scnshndx(sec); + sec = elf_getscn(elf, shdr.sh_link); if (sec == NULL) goto out_free_name; - self->symstrs = elf_getdata(sec, NULL); - if (self->symstrs == NULL) + symtab->symstrs = elf_getdata(sec, NULL); + if (symtab->symstrs == NULL) goto out_free_name; - self->nr_syms = shdr.sh_size / shdr.sh_entsize; + /* + * The .symtab section has optional extended section index + * table, load its data so it can be used to resolve symbol's + * section index. + **/ + if (symtab_xindex > 0) { + GElf_Shdr shdr_xindex; + Elf_Scn *sec_xindex; + + sec_xindex = elf_getscn(elf, symtab_xindex); + if (sec_xindex == NULL) + goto out_free_name; + + if (gelf_getshdr(sec_xindex, &shdr_xindex) == NULL) + goto out_free_name; + + /* Extra check to verify it's correct type */ + if (shdr_xindex.sh_type != SHT_SYMTAB_SHNDX) + goto out_free_name; + + /* Extra check to verify it belongs to the .symtab */ + if (symtab_index != shdr_xindex.sh_link) + goto out_free_name; + + symtab->syms_sec_idx_table = elf_getdata(elf_getscn(elf, symtab_xindex), NULL); + if (symtab->syms_sec_idx_table == NULL) + goto out_free_name; + } + + symtab->nr_syms = shdr.sh_size / shdr.sh_entsize; - return self; + return symtab; out_free_name: - free(self->name); + free(symtab->name); out_delete: - free(self); + free(symtab); return NULL; } -void elf_symtab__delete(struct elf_symtab *self) +void elf_symtab__delete(struct elf_symtab *symtab) { - if (self == NULL) + if (symtab == NULL) return; - free(self->name); - free(self); + free(symtab->name); + free(symtab); } diff -Nru dwarves-dfsg-1.10/elf_symtab.h dwarves-dfsg-1.21/elf_symtab.h --- dwarves-dfsg-1.10/elf_symtab.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/elf_symtab.h 2021-03-07 13:51:27.000000000 +0000 @@ -1,12 +1,10 @@ #ifndef _ELF_SYMTAB_H_ #define _ELF_SYMTAB_H_ 1 /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2009 Red Hat Inc. Copyright (C) 2009 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include @@ -18,15 +16,17 @@ uint32_t nr_syms; Elf_Data *syms; Elf_Data *symstrs; + /* Data of SHT_SYMTAB_SHNDX section. */ + Elf_Data *syms_sec_idx_table; char *name; }; struct elf_symtab *elf_symtab__new(const char *name, Elf *elf, GElf_Ehdr *ehdr); -void elf_symtab__delete(struct elf_symtab *self); +void elf_symtab__delete(struct elf_symtab *symtab); -static inline uint32_t elf_symtab__nr_symbols(const struct elf_symtab *self) +static inline uint32_t elf_symtab__nr_symbols(const struct elf_symtab *symtab) { - return self->nr_syms; + return symtab->nr_syms; } static inline const char *elf_sym__name(const GElf_Sym *sym, @@ -79,16 +79,43 @@ sym->st_shndx != SHN_UNDEF; } +static inline bool +elf_sym__get(Elf_Data *syms, Elf_Data *syms_sec_idx_table, + int id, GElf_Sym *sym, Elf32_Word *sym_sec_idx) +{ + if (!gelf_getsymshndx(syms, syms_sec_idx_table, id, sym, sym_sec_idx)) + return false; + + if (sym->st_shndx != SHN_XINDEX) + *sym_sec_idx = sym->st_shndx; + + return true; +} + /** * elf_symtab__for_each_symbol - iterate thru all the symbols * - * @self: struct elf_symtab instance to iterate + * @symtab: struct elf_symtab instance to iterate + * @index: uint32_t index + * @sym: GElf_Sym iterator + */ +#define elf_symtab__for_each_symbol(symtab, index, sym) \ + for (index = 0, gelf_getsym(symtab->syms, index, &sym);\ + index < symtab->nr_syms; \ + index++, gelf_getsym(symtab->syms, index, &sym)) + +/** + * elf_symtab__for_each_symbol_index - iterate through all the symbols, + * that takes extended symbols indexes into account + * + * @symtab: struct elf_symtab instance to iterate * @index: uint32_t index * @sym: GElf_Sym iterator + * @sym_sec_idx: symbol's index */ -#define elf_symtab__for_each_symbol(self, index, sym) \ - for (index = 0, gelf_getsym(self->syms, index, &sym);\ - index < self->nr_syms; \ - index++, gelf_getsym(self->syms, index, &sym)) +#define elf_symtab__for_each_symbol_index(symtab, id, sym, sym_sec_idx) \ + for (id = 0; id < symtab->nr_syms; id++) \ + if (elf_sym__get(symtab->syms, symtab->syms_sec_idx_table, \ + id, &sym, &sym_sec_idx)) #endif /* _ELF_SYMTAB_H_ */ diff -Nru dwarves-dfsg-1.10/fullcircle dwarves-dfsg-1.21/fullcircle --- dwarves-dfsg-1.10/fullcircle 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/fullcircle 2019-05-01 18:23:10.000000000 +0000 @@ -0,0 +1,43 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only +# Copyright © 2019 Red Hat Inc, Arnaldo Carvalho de Melo +# Use pfunct to produce compilable output from a object, then do a codiff -s +# To see if the type information generated from source code generated +# from type information in a file compiled from the original source code matches. + +if [ $# -eq 0 ] ; then + echo "Usage: fullcircle " + exit 1 +fi + +file=$1 + +nr_cus=$(readelf -wi ${file} | grep DW_TAG_compile_unit | wc -l) +if [ $nr_cus -gt 1 ]; then + exit 0 +fi + +c_output=$(mktemp /tmp/fullcircle.XXXXXX.c) +o_output=$(mktemp /tmp/fullcircle.XXXXXX.o) +pfunct_bin=${PFUNCT-"pfunct"} +codiff_bin=${CODIFF-"codiff"} + +# See how your DW_AT_producer looks like and find the +# right regexp to get after the GCC version string, this one +# seems good enough for Red Hat/Fedora/CentOS that look like: +# +# DW_AT_producer : (indirect string, offset: 0x3583): GNU C89 8.2.1 20181215 (Red Hat 8.2.1-6) -mno-sse -mno-mmx +# +# So we need from -mno-sse onwards + +CFLAGS=$(readelf -wi $file | grep -w DW_AT_producer | sed -r 's/.*\)( -[[:alnum:]]+.*)+/\1/g') + +# Check if we managed to do the sed or if this is something like GNU AS +[ "${CFLAGS/DW_AT_producer/}" != "${CFLAGS}" ] && exit + +${pfunct_bin} --compile $file > $c_output +gcc $CFLAGS -c -g $c_output -o $o_output +${codiff_bin} -q -s $file $o_output + +rm -f $c_output $o_output +exit 0 diff -Nru dwarves-dfsg-1.10/gobuffer.c dwarves-dfsg-1.21/gobuffer.c --- dwarves-dfsg-1.10/gobuffer.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/gobuffer.c 2020-02-21 13:45:08.000000000 +0000 @@ -1,11 +1,9 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2008 Arnaldo Carvalho de Melo Grow only buffer, add entries but never delete - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include "gobuffer.h" @@ -23,87 +21,92 @@ #define GOBUFFER__BCHUNK (8 * 1024) #define GOBUFFER__ZCHUNK (8 * 1024) -void gobuffer__init(struct gobuffer *self) +void gobuffer__init(struct gobuffer *gb) { - self->entries = NULL; - self->nr_entries = self->allocated_size = 0; + gb->entries = NULL; + gb->nr_entries = gb->allocated_size = 0; /* 0 == NULL */ - self->index = 1; + gb->index = 1; } struct gobuffer *gobuffer__new(void) { - struct gobuffer *self = malloc(sizeof(*self)); + struct gobuffer *gb = malloc(sizeof(*gb)); - if (self != NULL) - gobuffer__init(self); + if (gb != NULL) + gobuffer__init(gb); - return self; + return gb; } -void __gobuffer__delete(struct gobuffer *self) +void __gobuffer__delete(struct gobuffer *gb) { - free(self->entries); + free(gb->entries); } -void gobuffer__delete(struct gobuffer *self) +void gobuffer__delete(struct gobuffer *gb) { - __gobuffer__delete(self); - free(self); + __gobuffer__delete(gb); + free(gb); } -void *gobuffer__ptr(const struct gobuffer *self, unsigned int s) +void *gobuffer__ptr(const struct gobuffer *gb, unsigned int s) { - return s ? self->entries + s : NULL; + return s ? gb->entries + s : NULL; } -int gobuffer__allocate(struct gobuffer *self, unsigned int len) +int gobuffer__allocate(struct gobuffer *gb, unsigned int len) { - const unsigned int rc = self->index; - const unsigned int index = self->index + len; + const unsigned int rc = gb->index; + const unsigned int index = gb->index + len; - if (index >= self->allocated_size) { - unsigned int allocated_size = (self->allocated_size + + if (index >= gb->allocated_size) { + unsigned int allocated_size = (gb->allocated_size + GOBUFFER__BCHUNK); if (allocated_size < index) allocated_size = index + GOBUFFER__BCHUNK; - char *entries = realloc(self->entries, allocated_size); + char *entries = realloc(gb->entries, allocated_size); if (entries == NULL) return -ENOMEM; - self->allocated_size = allocated_size; - self->entries = entries; + gb->allocated_size = allocated_size; + gb->entries = entries; } - self->index = index; + gb->index = index; return rc; } -int gobuffer__add(struct gobuffer *self, const void *s, unsigned int len) +int gobuffer__add(struct gobuffer *gb, const void *s, unsigned int len) { - const int rc = gobuffer__allocate(self, len); + const int rc = gobuffer__allocate(gb, len); if (rc >= 0) { - ++self->nr_entries; - memcpy(self->entries + rc, s, len); + ++gb->nr_entries; + memcpy(gb->entries + rc, s, len); } return rc; } -void gobuffer__copy(const struct gobuffer *self, void *dest) +void gobuffer__copy(const struct gobuffer *gb, void *dest) { - memcpy(dest, self->entries, gobuffer__size(self)); + if (gb->entries) { + memcpy(dest, gb->entries, gobuffer__size(gb)); + } else { + /* gobuffer__size will be 0 or 1. */ + memcpy(dest, "", gobuffer__size(gb)); + } } -const void *gobuffer__compress(struct gobuffer *self, unsigned int *size) +const void *gobuffer__compress(struct gobuffer *gb, unsigned int *size) { z_stream z = { .zalloc = Z_NULL, .zfree = Z_NULL, .opaque = Z_NULL, - .avail_in = gobuffer__size(self), - .next_in = (Bytef *)gobuffer__entries(self), + .avail_in = gobuffer__size(gb), + .next_in = (Bytef *)(gobuffer__entries(gb) ? : ""), }; void *bf = NULL; unsigned int bf_size = 0; diff -Nru dwarves-dfsg-1.10/gobuffer.h dwarves-dfsg-1.21/gobuffer.h --- dwarves-dfsg-1.10/gobuffer.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/gobuffer.h 2019-05-01 15:06:45.000000000 +0000 @@ -1,11 +1,9 @@ #ifndef _GOBUFFER_H_ #define _GOBUFFER_H_ 1 /* - Copyright (C) 2008 Arnaldo Carvalho de Melo + SPDX-License-Identifier: GPL-2.0-only - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. + Copyright (C) 2008 Arnaldo Carvalho de Melo */ struct gobuffer { @@ -17,32 +15,32 @@ struct gobuffer *gobuffer__new(void); -void gobuffer__init(struct gobuffer *self); -void gobuffer__delete(struct gobuffer *self); -void __gobuffer__delete(struct gobuffer *self); +void gobuffer__init(struct gobuffer *gb); +void gobuffer__delete(struct gobuffer *gb); +void __gobuffer__delete(struct gobuffer *gb); -void gobuffer__copy(const struct gobuffer *self, void *dest); +void gobuffer__copy(const struct gobuffer *gb, void *dest); -int gobuffer__add(struct gobuffer *self, const void *s, unsigned int len); -int gobuffer__allocate(struct gobuffer *self, unsigned int len); +int gobuffer__add(struct gobuffer *gb, const void *s, unsigned int len); +int gobuffer__allocate(struct gobuffer *gb, unsigned int len); -static inline const void *gobuffer__entries(const struct gobuffer *self) +static inline const void *gobuffer__entries(const struct gobuffer *gb) { - return self->entries; + return gb->entries; } -static inline unsigned int gobuffer__nr_entries(const struct gobuffer *self) +static inline unsigned int gobuffer__nr_entries(const struct gobuffer *gb) { - return self->nr_entries; + return gb->nr_entries; } -static inline unsigned int gobuffer__size(const struct gobuffer *self) +static inline unsigned int gobuffer__size(const struct gobuffer *gb) { - return self->index; + return gb->index; } -void *gobuffer__ptr(const struct gobuffer *self, unsigned int s); +void *gobuffer__ptr(const struct gobuffer *gb, unsigned int s); -const void *gobuffer__compress(struct gobuffer *self, unsigned int *size); +const void *gobuffer__compress(struct gobuffer *gb, unsigned int *size); #endif /* _GOBUFFER_H_ */ diff -Nru dwarves-dfsg-1.10/hash.h dwarves-dfsg-1.21/hash.h --- dwarves-dfsg-1.10/hash.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/hash.h 2021-03-07 13:51:32.000000000 +0000 @@ -33,25 +33,7 @@ static inline uint64_t hash_64(const uint64_t val, const unsigned int bits) { - uint64_t hash = val; - - /* Sigh, gcc can't optimise this alone like it does for 32 bits. */ - uint64_t n = hash; - n <<= 18; - hash -= n; - n <<= 33; - hash -= n; - n <<= 3; - hash += n; - n <<= 3; - hash -= n; - n <<= 4; - hash += n; - n <<= 2; - hash += n; - - /* High bits are more random, so use them. */ - return hash >> (64 - bits); + return (val * 11400714819323198485LLU) >> (64 - bits); } static inline uint32_t hash_32(uint32_t val, unsigned int bits) diff -Nru dwarves-dfsg-1.10/lib/bpf/BPF-CHECKPOINT-COMMIT dwarves-dfsg-1.21/lib/bpf/BPF-CHECKPOINT-COMMIT --- dwarves-dfsg-1.10/lib/bpf/BPF-CHECKPOINT-COMMIT 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/BPF-CHECKPOINT-COMMIT 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1 @@ +22541a9eeb0d968c133aaebd95fa59da3208e705 diff -Nru dwarves-dfsg-1.10/lib/bpf/CHECKPOINT-COMMIT dwarves-dfsg-1.21/lib/bpf/CHECKPOINT-COMMIT --- dwarves-dfsg-1.10/lib/bpf/CHECKPOINT-COMMIT 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/CHECKPOINT-COMMIT 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1 @@ +22541a9eeb0d968c133aaebd95fa59da3208e705 diff -Nru dwarves-dfsg-1.10/lib/bpf/.git dwarves-dfsg-1.21/lib/bpf/.git --- dwarves-dfsg-1.10/lib/bpf/.git 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/.git 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1 @@ +gitdir: ../../.git/modules/lib/bpf diff -Nru dwarves-dfsg-1.10/lib/bpf/include/asm/barrier.h dwarves-dfsg-1.21/lib/bpf/include/asm/barrier.h --- dwarves-dfsg-1.10/lib/bpf/include/asm/barrier.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/asm/barrier.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ +#ifndef __ASM_BARRIER_H +#define __ASM_BARRIER_H + +#include + +#endif diff -Nru dwarves-dfsg-1.10/lib/bpf/include/linux/compiler.h dwarves-dfsg-1.21/lib/bpf/include/linux/compiler.h --- dwarves-dfsg-1.10/lib/bpf/include/linux/compiler.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/linux/compiler.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +#ifndef __LINUX_COMPILER_H +#define __LINUX_COMPILER_H + +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) + +#define READ_ONCE(x) (*(volatile typeof(x) *)&x) +#define WRITE_ONCE(x, v) (*(volatile typeof(x) *)&x) = (v) + +#define barrier() asm volatile("" ::: "memory") + +#if defined(__x86_64__) + +# define smp_rmb() barrier() +# define smp_wmb() barrier() +# define smp_mb() asm volatile("lock; addl $0,-132(%%rsp)" ::: "memory", "cc") + +# define smp_store_release(p, v) \ +do { \ + barrier(); \ + WRITE_ONCE(*p, v); \ +} while (0) + +# define smp_load_acquire(p) \ +({ \ + typeof(*p) ___p = READ_ONCE(*p); \ + barrier(); \ + ___p; \ +}) + +#elif defined(__aarch64__) + +# define smp_rmb() asm volatile("dmb ishld" ::: "memory") +# define smp_wmb() asm volatile("dmb ishst" ::: "memory") +# define smp_mb() asm volatile("dmb ish" ::: "memory") + +#endif + +#ifndef smp_mb +# define smp_mb() __sync_synchronize() +#endif + +#ifndef smp_rmb +# define smp_rmb() smp_mb() +#endif + +#ifndef smp_wmb +# define smp_wmb() smp_mb() +#endif + +#ifndef smp_store_release +# define smp_store_release(p, v) \ +do { \ + smp_mb(); \ + WRITE_ONCE(*p, v); \ +} while (0) +#endif + +#ifndef smp_load_acquire +# define smp_load_acquire(p) \ +({ \ + typeof(*p) ___p = READ_ONCE(*p); \ + smp_mb(); \ + ___p; \ +}) +#endif + +#endif /* __LINUX_COMPILER_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/include/linux/err.h dwarves-dfsg-1.21/lib/bpf/include/linux/err.h --- dwarves-dfsg-1.10/lib/bpf/include/linux/err.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/linux/err.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +#ifndef __LINUX_ERR_H +#define __LINUX_ERR_H + +#include +#include + +#define MAX_ERRNO 4095 + +#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO) + +static inline void * ERR_PTR(long error_) +{ + return (void *) error_; +} + +static inline long PTR_ERR(const void *ptr) +{ + return (long) ptr; +} + +static inline bool IS_ERR(const void *ptr) +{ + return IS_ERR_VALUE((unsigned long)ptr); +} + +static inline bool IS_ERR_OR_NULL(const void *ptr) +{ + return (!ptr) || IS_ERR_VALUE((unsigned long)ptr); +} + +static inline long PTR_ERR_OR_ZERO(const void *ptr) +{ + return IS_ERR(ptr) ? PTR_ERR(ptr) : 0; +} + +#endif diff -Nru dwarves-dfsg-1.10/lib/bpf/include/linux/filter.h dwarves-dfsg-1.21/lib/bpf/include/linux/filter.h --- dwarves-dfsg-1.10/lib/bpf/include/linux/filter.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/linux/filter.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,126 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +#ifndef __LINUX_FILTER_H +#define __LINUX_FILTER_H + +#include + +#define BPF_RAW_INSN(CODE, DST, SRC, OFF, IMM) \ + ((struct bpf_insn) { \ + .code = CODE, \ + .dst_reg = DST, \ + .src_reg = SRC, \ + .off = OFF, \ + .imm = IMM }) + +#define BPF_ALU64_IMM(OP, DST, IMM) \ + ((struct bpf_insn) { \ + .code = BPF_ALU64 | BPF_OP(OP) | BPF_K, \ + .dst_reg = DST, \ + .src_reg = 0, \ + .off = 0, \ + .imm = IMM }) + +#define BPF_MOV64_IMM(DST, IMM) \ + ((struct bpf_insn) { \ + .code = BPF_ALU64 | BPF_MOV | BPF_K, \ + .dst_reg = DST, \ + .src_reg = 0, \ + .off = 0, \ + .imm = IMM }) + +#define BPF_EXIT_INSN() \ + ((struct bpf_insn) { \ + .code = BPF_JMP | BPF_EXIT, \ + .dst_reg = 0, \ + .src_reg = 0, \ + .off = 0, \ + .imm = 0 }) + +#define BPF_EMIT_CALL(FUNC) \ + ((struct bpf_insn) { \ + .code = BPF_JMP | BPF_CALL, \ + .dst_reg = 0, \ + .src_reg = 0, \ + .off = 0, \ + .imm = ((FUNC) - BPF_FUNC_unspec) }) + +#define BPF_LDX_MEM(SIZE, DST, SRC, OFF) \ + ((struct bpf_insn) { \ + .code = BPF_LDX | BPF_SIZE(SIZE) | BPF_MEM, \ + .dst_reg = DST, \ + .src_reg = SRC, \ + .off = OFF, \ + .imm = 0 }) + +#define BPF_STX_MEM(SIZE, DST, SRC, OFF) \ + ((struct bpf_insn) { \ + .code = BPF_STX | BPF_SIZE(SIZE) | BPF_MEM, \ + .dst_reg = DST, \ + .src_reg = SRC, \ + .off = OFF, \ + .imm = 0 }) + +#define BPF_ST_MEM(SIZE, DST, OFF, IMM) \ + ((struct bpf_insn) { \ + .code = BPF_ST | BPF_SIZE(SIZE) | BPF_MEM, \ + .dst_reg = DST, \ + .src_reg = 0, \ + .off = OFF, \ + .imm = IMM }) + +#define BPF_MOV64_REG(DST, SRC) \ + ((struct bpf_insn) { \ + .code = BPF_ALU64 | BPF_MOV | BPF_X, \ + .dst_reg = DST, \ + .src_reg = SRC, \ + .off = 0, \ + .imm = 0 }) + +#define BPF_MOV32_IMM(DST, IMM) \ + ((struct bpf_insn) { \ + .code = BPF_ALU | BPF_MOV | BPF_K, \ + .dst_reg = DST, \ + .src_reg = 0, \ + .off = 0, \ + .imm = IMM }) + +#define BPF_LD_IMM64_RAW_FULL(DST, SRC, OFF1, OFF2, IMM1, IMM2) \ + ((struct bpf_insn) { \ + .code = BPF_LD | BPF_DW | BPF_IMM, \ + .dst_reg = DST, \ + .src_reg = SRC, \ + .off = OFF1, \ + .imm = IMM1 }), \ + ((struct bpf_insn) { \ + .code = 0, \ + .dst_reg = 0, \ + .src_reg = 0, \ + .off = OFF2, \ + .imm = IMM2 }) + +#define BPF_LD_MAP_FD(DST, MAP_FD) \ + BPF_LD_IMM64_RAW_FULL(DST, BPF_PSEUDO_MAP_FD, 0, 0, \ + MAP_FD, 0) + +#define BPF_LD_MAP_VALUE(DST, MAP_FD, VALUE_OFF) \ + BPF_LD_IMM64_RAW_FULL(DST, BPF_PSEUDO_MAP_VALUE, 0, 0, \ + MAP_FD, VALUE_OFF) + +#define BPF_JMP_IMM(OP, DST, IMM, OFF) \ + ((struct bpf_insn) { \ + .code = BPF_JMP | BPF_OP(OP) | BPF_K, \ + .dst_reg = DST, \ + .src_reg = 0, \ + .off = OFF, \ + .imm = IMM }) + +#define BPF_JMP32_IMM(OP, DST, IMM, OFF) \ + ((struct bpf_insn) { \ + .code = BPF_JMP32 | BPF_OP(OP) | BPF_K, \ + .dst_reg = DST, \ + .src_reg = 0, \ + .off = OFF, \ + .imm = IMM }) + +#endif diff -Nru dwarves-dfsg-1.10/lib/bpf/include/linux/kernel.h dwarves-dfsg-1.21/lib/bpf/include/linux/kernel.h --- dwarves-dfsg-1.10/lib/bpf/include/linux/kernel.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/linux/kernel.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +#ifndef __LINUX_KERNEL_H +#define __LINUX_KERNEL_H + +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#ifndef container_of +#define container_of(ptr, type, member) ({ \ + const typeof(((type *)0)->member) * __mptr = (ptr); \ + (type *)((char *)__mptr - offsetof(type, member)); }) +#endif + +#ifndef max +#define max(x, y) ({ \ + typeof(x) _max1 = (x); \ + typeof(y) _max2 = (y); \ + (void) (&_max1 == &_max2); \ + _max1 > _max2 ? _max1 : _max2; }) +#endif + +#ifndef min +#define min(x, y) ({ \ + typeof(x) _min1 = (x); \ + typeof(y) _min2 = (y); \ + (void) (&_min1 == &_min2); \ + _min1 < _min2 ? _min1 : _min2; }) +#endif + +#ifndef roundup +#define roundup(x, y) ( \ +{ \ + const typeof(y) __y = y; \ + (((x) + (__y - 1)) / __y) * __y; \ +} \ +) +#endif + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) + +#endif diff -Nru dwarves-dfsg-1.10/lib/bpf/include/linux/list.h dwarves-dfsg-1.21/lib/bpf/include/linux/list.h --- dwarves-dfsg-1.10/lib/bpf/include/linux/list.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/linux/list.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +#ifndef __LINUX_LIST_H +#define __LINUX_LIST_H + +#define LIST_HEAD_INIT(name) { &(name), &(name) } +#define LIST_HEAD(name) \ + struct list_head name = LIST_HEAD_INIT(name) + +#define POISON_POINTER_DELTA 0 +#define LIST_POISON1 ((void *) 0x100 + POISON_POINTER_DELTA) +#define LIST_POISON2 ((void *) 0x200 + POISON_POINTER_DELTA) + + +static inline void INIT_LIST_HEAD(struct list_head *list) +{ + list->next = list; + list->prev = list; +} + +static inline void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) +{ + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; +} + +/** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ +static inline void list_add(struct list_head *new, struct list_head *head) +{ + __list_add(new, head, head->next); +} + +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_del(struct list_head * prev, struct list_head * next) +{ + next->prev = prev; + prev->next = next; +} + +/** + * list_del - deletes entry from list. + * @entry: the element to delete from the list. + * Note: list_empty() on entry does not return true after this, the entry is + * in an undefined state. + */ +static inline void __list_del_entry(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); +} + +static inline void list_del(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); + entry->next = LIST_POISON1; + entry->prev = LIST_POISON2; +} + +static inline int list_empty(const struct list_head *head) +{ + return head->next == head; +} + +#define list_entry(ptr, type, member) \ + container_of(ptr, type, member) +#define list_first_entry(ptr, type, member) \ + list_entry((ptr)->next, type, member) +#define list_next_entry(pos, member) \ + list_entry((pos)->member.next, typeof(*(pos)), member) +#define list_for_each_entry(pos, head, member) \ + for (pos = list_first_entry(head, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_next_entry(pos, member)) + +#endif diff -Nru dwarves-dfsg-1.10/lib/bpf/include/linux/overflow.h dwarves-dfsg-1.21/lib/bpf/include/linux/overflow.h --- dwarves-dfsg-1.10/lib/bpf/include/linux/overflow.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/linux/overflow.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,90 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +#ifndef __LINUX_OVERFLOW_H +#define __LINUX_OVERFLOW_H + +#define is_signed_type(type) (((type)(-1)) < (type)1) +#define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type))) +#define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) +#define type_min(T) ((T)((T)-type_max(T)-(T)1)) + +#ifndef unlikely +#define unlikely(x) __builtin_expect(!!(x), 0) +#endif + +#ifdef __GNUC__ +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) +#if GCC_VERSION >= 50100 +#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 +#endif +#endif + +#ifdef COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW + +#define check_mul_overflow(a, b, d) ({ \ + typeof(a) __a = (a); \ + typeof(b) __b = (b); \ + typeof(d) __d = (d); \ + (void) (&__a == &__b); \ + (void) (&__a == __d); \ + __builtin_mul_overflow(__a, __b, __d); \ +}) + +#else + +/* + * If one of a or b is a compile-time constant, this avoids a division. + */ +#define __unsigned_mul_overflow(a, b, d) ({ \ + typeof(a) __a = (a); \ + typeof(b) __b = (b); \ + typeof(d) __d = (d); \ + (void) (&__a == &__b); \ + (void) (&__a == __d); \ + *__d = __a * __b; \ + __builtin_constant_p(__b) ? \ + __b > 0 && __a > type_max(typeof(__a)) / __b : \ + __a > 0 && __b > type_max(typeof(__b)) / __a; \ +}) + +/* + * Signed multiplication is rather hard. gcc always follows C99, so + * division is truncated towards 0. This means that we can write the + * overflow check like this: + * + * (a > 0 && (b > MAX/a || b < MIN/a)) || + * (a < -1 && (b > MIN/a || b < MAX/a) || + * (a == -1 && b == MIN) + * + * The redundant casts of -1 are to silence an annoying -Wtype-limits + * (included in -Wextra) warning: When the type is u8 or u16, the + * __b_c_e in check_mul_overflow obviously selects + * __unsigned_mul_overflow, but unfortunately gcc still parses this + * code and warns about the limited range of __b. + */ + +#define __signed_mul_overflow(a, b, d) ({ \ + typeof(a) __a = (a); \ + typeof(b) __b = (b); \ + typeof(d) __d = (d); \ + typeof(a) __tmax = type_max(typeof(a)); \ + typeof(a) __tmin = type_min(typeof(a)); \ + (void) (&__a == &__b); \ + (void) (&__a == __d); \ + *__d = (__u64)__a * (__u64)__b; \ + (__b > 0 && (__a > __tmax/__b || __a < __tmin/__b)) || \ + (__b < (typeof(__b))-1 && (__a > __tmin/__b || __a < __tmax/__b)) || \ + (__b == (typeof(__b))-1 && __a == __tmin); \ +}) + +#define check_mul_overflow(a, b, d) \ + __builtin_choose_expr(is_signed_type(typeof(a)), \ + __signed_mul_overflow(a, b, d), \ + __unsigned_mul_overflow(a, b, d)) + + +#endif /* COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW */ + +#endif diff -Nru dwarves-dfsg-1.10/lib/bpf/include/linux/ring_buffer.h dwarves-dfsg-1.21/lib/bpf/include/linux/ring_buffer.h --- dwarves-dfsg-1.10/lib/bpf/include/linux/ring_buffer.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/linux/ring_buffer.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ +#ifndef _TOOLS_LINUX_RING_BUFFER_H_ +#define _TOOLS_LINUX_RING_BUFFER_H_ + +#include + +static inline __u64 ring_buffer_read_head(struct perf_event_mmap_page *base) +{ + return smp_load_acquire(&base->data_head); +} + +static inline void ring_buffer_write_tail(struct perf_event_mmap_page *base, + __u64 tail) +{ + smp_store_release(&base->data_tail, tail); +} + +#endif /* _TOOLS_LINUX_RING_BUFFER_H_ */ diff -Nru dwarves-dfsg-1.10/lib/bpf/include/linux/types.h dwarves-dfsg-1.21/lib/bpf/include/linux/types.h --- dwarves-dfsg-1.10/lib/bpf/include/linux/types.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/linux/types.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +#ifndef __LINUX_TYPES_H +#define __LINUX_TYPES_H + +#include +#include +#include + +#include +#include + +#define __bitwise__ +#define __bitwise __bitwise__ + +typedef __u16 __bitwise __le16; +typedef __u16 __bitwise __be16; +typedef __u32 __bitwise __le32; +typedef __u32 __bitwise __be32; +typedef __u64 __bitwise __le64; +typedef __u64 __bitwise __be64; + +#ifndef __aligned_u64 +# define __aligned_u64 __u64 __attribute__((aligned(8))) +#endif + +struct list_head { + struct list_head *next, *prev; +}; + +#endif diff -Nru dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/bpf_common.h dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/bpf_common.h --- dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/bpf_common.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/bpf_common.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI__LINUX_BPF_COMMON_H__ +#define _UAPI__LINUX_BPF_COMMON_H__ + +/* Instruction classes */ +#define BPF_CLASS(code) ((code) & 0x07) +#define BPF_LD 0x00 +#define BPF_LDX 0x01 +#define BPF_ST 0x02 +#define BPF_STX 0x03 +#define BPF_ALU 0x04 +#define BPF_JMP 0x05 +#define BPF_RET 0x06 +#define BPF_MISC 0x07 + +/* ld/ldx fields */ +#define BPF_SIZE(code) ((code) & 0x18) +#define BPF_W 0x00 /* 32-bit */ +#define BPF_H 0x08 /* 16-bit */ +#define BPF_B 0x10 /* 8-bit */ +/* eBPF BPF_DW 0x18 64-bit */ +#define BPF_MODE(code) ((code) & 0xe0) +#define BPF_IMM 0x00 +#define BPF_ABS 0x20 +#define BPF_IND 0x40 +#define BPF_MEM 0x60 +#define BPF_LEN 0x80 +#define BPF_MSH 0xa0 + +/* alu/jmp fields */ +#define BPF_OP(code) ((code) & 0xf0) +#define BPF_ADD 0x00 +#define BPF_SUB 0x10 +#define BPF_MUL 0x20 +#define BPF_DIV 0x30 +#define BPF_OR 0x40 +#define BPF_AND 0x50 +#define BPF_LSH 0x60 +#define BPF_RSH 0x70 +#define BPF_NEG 0x80 +#define BPF_MOD 0x90 +#define BPF_XOR 0xa0 + +#define BPF_JA 0x00 +#define BPF_JEQ 0x10 +#define BPF_JGT 0x20 +#define BPF_JGE 0x30 +#define BPF_JSET 0x40 +#define BPF_SRC(code) ((code) & 0x08) +#define BPF_K 0x00 +#define BPF_X 0x08 + +#ifndef BPF_MAXINSNS +#define BPF_MAXINSNS 4096 +#endif + +#endif /* _UAPI__LINUX_BPF_COMMON_H__ */ diff -Nru dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/bpf.h dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/bpf.h --- dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/bpf.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/bpf.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,5288 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + */ +#ifndef _UAPI__LINUX_BPF_H__ +#define _UAPI__LINUX_BPF_H__ + +#include +#include + +/* Extended instruction set based on top of classic BPF */ + +/* instruction classes */ +#define BPF_JMP32 0x06 /* jmp mode in word width */ +#define BPF_ALU64 0x07 /* alu mode in double word width */ + +/* ld/ldx fields */ +#define BPF_DW 0x18 /* double word (64-bit) */ +#define BPF_ATOMIC 0xc0 /* atomic memory ops - op type in immediate */ +#define BPF_XADD 0xc0 /* exclusive add - legacy name */ + +/* alu/jmp fields */ +#define BPF_MOV 0xb0 /* mov reg to reg */ +#define BPF_ARSH 0xc0 /* sign extending arithmetic shift right */ + +/* change endianness of a register */ +#define BPF_END 0xd0 /* flags for endianness conversion: */ +#define BPF_TO_LE 0x00 /* convert to little-endian */ +#define BPF_TO_BE 0x08 /* convert to big-endian */ +#define BPF_FROM_LE BPF_TO_LE +#define BPF_FROM_BE BPF_TO_BE + +/* jmp encodings */ +#define BPF_JNE 0x50 /* jump != */ +#define BPF_JLT 0xa0 /* LT is unsigned, '<' */ +#define BPF_JLE 0xb0 /* LE is unsigned, '<=' */ +#define BPF_JSGT 0x60 /* SGT is signed '>', GT in x86 */ +#define BPF_JSGE 0x70 /* SGE is signed '>=', GE in x86 */ +#define BPF_JSLT 0xc0 /* SLT is signed, '<' */ +#define BPF_JSLE 0xd0 /* SLE is signed, '<=' */ +#define BPF_CALL 0x80 /* function call */ +#define BPF_EXIT 0x90 /* function return */ + +/* atomic op type fields (stored in immediate) */ +#define BPF_FETCH 0x01 /* not an opcode on its own, used to build others */ +#define BPF_XCHG (0xe0 | BPF_FETCH) /* atomic exchange */ +#define BPF_CMPXCHG (0xf0 | BPF_FETCH) /* atomic compare-and-write */ + +/* Register numbers */ +enum { + BPF_REG_0 = 0, + BPF_REG_1, + BPF_REG_2, + BPF_REG_3, + BPF_REG_4, + BPF_REG_5, + BPF_REG_6, + BPF_REG_7, + BPF_REG_8, + BPF_REG_9, + BPF_REG_10, + __MAX_BPF_REG, +}; + +/* BPF has 10 general purpose 64-bit registers and stack frame. */ +#define MAX_BPF_REG __MAX_BPF_REG + +struct bpf_insn { + __u8 code; /* opcode */ + __u8 dst_reg:4; /* dest register */ + __u8 src_reg:4; /* source register */ + __s16 off; /* signed offset */ + __s32 imm; /* signed immediate constant */ +}; + +/* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */ +struct bpf_lpm_trie_key { + __u32 prefixlen; /* up to 32 for AF_INET, 128 for AF_INET6 */ + __u8 data[0]; /* Arbitrary size */ +}; + +struct bpf_cgroup_storage_key { + __u64 cgroup_inode_id; /* cgroup inode id */ + __u32 attach_type; /* program attach type */ +}; + +union bpf_iter_link_info { + struct { + __u32 map_fd; + } map; +}; + +/* BPF syscall commands, see bpf(2) man-page for details. */ +enum bpf_cmd { + BPF_MAP_CREATE, + BPF_MAP_LOOKUP_ELEM, + BPF_MAP_UPDATE_ELEM, + BPF_MAP_DELETE_ELEM, + BPF_MAP_GET_NEXT_KEY, + BPF_PROG_LOAD, + BPF_OBJ_PIN, + BPF_OBJ_GET, + BPF_PROG_ATTACH, + BPF_PROG_DETACH, + BPF_PROG_TEST_RUN, + BPF_PROG_GET_NEXT_ID, + BPF_MAP_GET_NEXT_ID, + BPF_PROG_GET_FD_BY_ID, + BPF_MAP_GET_FD_BY_ID, + BPF_OBJ_GET_INFO_BY_FD, + BPF_PROG_QUERY, + BPF_RAW_TRACEPOINT_OPEN, + BPF_BTF_LOAD, + BPF_BTF_GET_FD_BY_ID, + BPF_TASK_FD_QUERY, + BPF_MAP_LOOKUP_AND_DELETE_ELEM, + BPF_MAP_FREEZE, + BPF_BTF_GET_NEXT_ID, + BPF_MAP_LOOKUP_BATCH, + BPF_MAP_LOOKUP_AND_DELETE_BATCH, + BPF_MAP_UPDATE_BATCH, + BPF_MAP_DELETE_BATCH, + BPF_LINK_CREATE, + BPF_LINK_UPDATE, + BPF_LINK_GET_FD_BY_ID, + BPF_LINK_GET_NEXT_ID, + BPF_ENABLE_STATS, + BPF_ITER_CREATE, + BPF_LINK_DETACH, + BPF_PROG_BIND_MAP, +}; + +enum bpf_map_type { + BPF_MAP_TYPE_UNSPEC, + BPF_MAP_TYPE_HASH, + BPF_MAP_TYPE_ARRAY, + BPF_MAP_TYPE_PROG_ARRAY, + BPF_MAP_TYPE_PERF_EVENT_ARRAY, + BPF_MAP_TYPE_PERCPU_HASH, + BPF_MAP_TYPE_PERCPU_ARRAY, + BPF_MAP_TYPE_STACK_TRACE, + BPF_MAP_TYPE_CGROUP_ARRAY, + BPF_MAP_TYPE_LRU_HASH, + BPF_MAP_TYPE_LRU_PERCPU_HASH, + BPF_MAP_TYPE_LPM_TRIE, + BPF_MAP_TYPE_ARRAY_OF_MAPS, + BPF_MAP_TYPE_HASH_OF_MAPS, + BPF_MAP_TYPE_DEVMAP, + BPF_MAP_TYPE_SOCKMAP, + BPF_MAP_TYPE_CPUMAP, + BPF_MAP_TYPE_XSKMAP, + BPF_MAP_TYPE_SOCKHASH, + BPF_MAP_TYPE_CGROUP_STORAGE, + BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, + BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE, + BPF_MAP_TYPE_QUEUE, + BPF_MAP_TYPE_STACK, + BPF_MAP_TYPE_SK_STORAGE, + BPF_MAP_TYPE_DEVMAP_HASH, + BPF_MAP_TYPE_STRUCT_OPS, + BPF_MAP_TYPE_RINGBUF, + BPF_MAP_TYPE_INODE_STORAGE, + BPF_MAP_TYPE_TASK_STORAGE, +}; + +/* Note that tracing related programs such as + * BPF_PROG_TYPE_{KPROBE,TRACEPOINT,PERF_EVENT,RAW_TRACEPOINT} + * are not subject to a stable API since kernel internal data + * structures can change from release to release and may + * therefore break existing tracing BPF programs. Tracing BPF + * programs correspond to /a/ specific kernel which is to be + * analyzed, and not /a/ specific kernel /and/ all future ones. + */ +enum bpf_prog_type { + BPF_PROG_TYPE_UNSPEC, + BPF_PROG_TYPE_SOCKET_FILTER, + BPF_PROG_TYPE_KPROBE, + BPF_PROG_TYPE_SCHED_CLS, + BPF_PROG_TYPE_SCHED_ACT, + BPF_PROG_TYPE_TRACEPOINT, + BPF_PROG_TYPE_XDP, + BPF_PROG_TYPE_PERF_EVENT, + BPF_PROG_TYPE_CGROUP_SKB, + BPF_PROG_TYPE_CGROUP_SOCK, + BPF_PROG_TYPE_LWT_IN, + BPF_PROG_TYPE_LWT_OUT, + BPF_PROG_TYPE_LWT_XMIT, + BPF_PROG_TYPE_SOCK_OPS, + BPF_PROG_TYPE_SK_SKB, + BPF_PROG_TYPE_CGROUP_DEVICE, + BPF_PROG_TYPE_SK_MSG, + BPF_PROG_TYPE_RAW_TRACEPOINT, + BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_PROG_TYPE_LWT_SEG6LOCAL, + BPF_PROG_TYPE_LIRC_MODE2, + BPF_PROG_TYPE_SK_REUSEPORT, + BPF_PROG_TYPE_FLOW_DISSECTOR, + BPF_PROG_TYPE_CGROUP_SYSCTL, + BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE, + BPF_PROG_TYPE_CGROUP_SOCKOPT, + BPF_PROG_TYPE_TRACING, + BPF_PROG_TYPE_STRUCT_OPS, + BPF_PROG_TYPE_EXT, + BPF_PROG_TYPE_LSM, + BPF_PROG_TYPE_SK_LOOKUP, +}; + +enum bpf_attach_type { + BPF_CGROUP_INET_INGRESS, + BPF_CGROUP_INET_EGRESS, + BPF_CGROUP_INET_SOCK_CREATE, + BPF_CGROUP_SOCK_OPS, + BPF_SK_SKB_STREAM_PARSER, + BPF_SK_SKB_STREAM_VERDICT, + BPF_CGROUP_DEVICE, + BPF_SK_MSG_VERDICT, + BPF_CGROUP_INET4_BIND, + BPF_CGROUP_INET6_BIND, + BPF_CGROUP_INET4_CONNECT, + BPF_CGROUP_INET6_CONNECT, + BPF_CGROUP_INET4_POST_BIND, + BPF_CGROUP_INET6_POST_BIND, + BPF_CGROUP_UDP4_SENDMSG, + BPF_CGROUP_UDP6_SENDMSG, + BPF_LIRC_MODE2, + BPF_FLOW_DISSECTOR, + BPF_CGROUP_SYSCTL, + BPF_CGROUP_UDP4_RECVMSG, + BPF_CGROUP_UDP6_RECVMSG, + BPF_CGROUP_GETSOCKOPT, + BPF_CGROUP_SETSOCKOPT, + BPF_TRACE_RAW_TP, + BPF_TRACE_FENTRY, + BPF_TRACE_FEXIT, + BPF_MODIFY_RETURN, + BPF_LSM_MAC, + BPF_TRACE_ITER, + BPF_CGROUP_INET4_GETPEERNAME, + BPF_CGROUP_INET6_GETPEERNAME, + BPF_CGROUP_INET4_GETSOCKNAME, + BPF_CGROUP_INET6_GETSOCKNAME, + BPF_XDP_DEVMAP, + BPF_CGROUP_INET_SOCK_RELEASE, + BPF_XDP_CPUMAP, + BPF_SK_LOOKUP, + BPF_XDP, + __MAX_BPF_ATTACH_TYPE +}; + +#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE + +enum bpf_link_type { + BPF_LINK_TYPE_UNSPEC = 0, + BPF_LINK_TYPE_RAW_TRACEPOINT = 1, + BPF_LINK_TYPE_TRACING = 2, + BPF_LINK_TYPE_CGROUP = 3, + BPF_LINK_TYPE_ITER = 4, + BPF_LINK_TYPE_NETNS = 5, + BPF_LINK_TYPE_XDP = 6, + + MAX_BPF_LINK_TYPE, +}; + +/* cgroup-bpf attach flags used in BPF_PROG_ATTACH command + * + * NONE(default): No further bpf programs allowed in the subtree. + * + * BPF_F_ALLOW_OVERRIDE: If a sub-cgroup installs some bpf program, + * the program in this cgroup yields to sub-cgroup program. + * + * BPF_F_ALLOW_MULTI: If a sub-cgroup installs some bpf program, + * that cgroup program gets run in addition to the program in this cgroup. + * + * Only one program is allowed to be attached to a cgroup with + * NONE or BPF_F_ALLOW_OVERRIDE flag. + * Attaching another program on top of NONE or BPF_F_ALLOW_OVERRIDE will + * release old program and attach the new one. Attach flags has to match. + * + * Multiple programs are allowed to be attached to a cgroup with + * BPF_F_ALLOW_MULTI flag. They are executed in FIFO order + * (those that were attached first, run first) + * The programs of sub-cgroup are executed first, then programs of + * this cgroup and then programs of parent cgroup. + * When children program makes decision (like picking TCP CA or sock bind) + * parent program has a chance to override it. + * + * With BPF_F_ALLOW_MULTI a new program is added to the end of the list of + * programs for a cgroup. Though it's possible to replace an old program at + * any position by also specifying BPF_F_REPLACE flag and position itself in + * replace_bpf_fd attribute. Old program at this position will be released. + * + * A cgroup with MULTI or OVERRIDE flag allows any attach flags in sub-cgroups. + * A cgroup with NONE doesn't allow any programs in sub-cgroups. + * Ex1: + * cgrp1 (MULTI progs A, B) -> + * cgrp2 (OVERRIDE prog C) -> + * cgrp3 (MULTI prog D) -> + * cgrp4 (OVERRIDE prog E) -> + * cgrp5 (NONE prog F) + * the event in cgrp5 triggers execution of F,D,A,B in that order. + * if prog F is detached, the execution is E,D,A,B + * if prog F and D are detached, the execution is E,A,B + * if prog F, E and D are detached, the execution is C,A,B + * + * All eligible programs are executed regardless of return code from + * earlier programs. + */ +#define BPF_F_ALLOW_OVERRIDE (1U << 0) +#define BPF_F_ALLOW_MULTI (1U << 1) +#define BPF_F_REPLACE (1U << 2) + +/* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the + * verifier will perform strict alignment checking as if the kernel + * has been built with CONFIG_EFFICIENT_UNALIGNED_ACCESS not set, + * and NET_IP_ALIGN defined to 2. + */ +#define BPF_F_STRICT_ALIGNMENT (1U << 0) + +/* If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the + * verifier will allow any alignment whatsoever. On platforms + * with strict alignment requirements for loads ands stores (such + * as sparc and mips) the verifier validates that all loads and + * stores provably follow this requirement. This flag turns that + * checking and enforcement off. + * + * It is mostly used for testing when we want to validate the + * context and memory access aspects of the verifier, but because + * of an unaligned access the alignment check would trigger before + * the one we are interested in. + */ +#define BPF_F_ANY_ALIGNMENT (1U << 1) + +/* BPF_F_TEST_RND_HI32 is used in BPF_PROG_LOAD command for testing purpose. + * Verifier does sub-register def/use analysis and identifies instructions whose + * def only matters for low 32-bit, high 32-bit is never referenced later + * through implicit zero extension. Therefore verifier notifies JIT back-ends + * that it is safe to ignore clearing high 32-bit for these instructions. This + * saves some back-ends a lot of code-gen. However such optimization is not + * necessary on some arches, for example x86_64, arm64 etc, whose JIT back-ends + * hence hasn't used verifier's analysis result. But, we really want to have a + * way to be able to verify the correctness of the described optimization on + * x86_64 on which testsuites are frequently exercised. + * + * So, this flag is introduced. Once it is set, verifier will randomize high + * 32-bit for those instructions who has been identified as safe to ignore them. + * Then, if verifier is not doing correct analysis, such randomization will + * regress tests to expose bugs. + */ +#define BPF_F_TEST_RND_HI32 (1U << 2) + +/* The verifier internal test flag. Behavior is undefined */ +#define BPF_F_TEST_STATE_FREQ (1U << 3) + +/* If BPF_F_SLEEPABLE is used in BPF_PROG_LOAD command, the verifier will + * restrict map and helper usage for such programs. Sleepable BPF programs can + * only be attached to hooks where kernel execution context allows sleeping. + * Such programs are allowed to use helpers that may sleep like + * bpf_copy_from_user(). + */ +#define BPF_F_SLEEPABLE (1U << 4) + +/* When BPF ldimm64's insn[0].src_reg != 0 then this can have + * the following extensions: + * + * insn[0].src_reg: BPF_PSEUDO_MAP_FD + * insn[0].imm: map fd + * insn[1].imm: 0 + * insn[0].off: 0 + * insn[1].off: 0 + * ldimm64 rewrite: address of map + * verifier type: CONST_PTR_TO_MAP + */ +#define BPF_PSEUDO_MAP_FD 1 +/* insn[0].src_reg: BPF_PSEUDO_MAP_VALUE + * insn[0].imm: map fd + * insn[1].imm: offset into value + * insn[0].off: 0 + * insn[1].off: 0 + * ldimm64 rewrite: address of map[0]+offset + * verifier type: PTR_TO_MAP_VALUE + */ +#define BPF_PSEUDO_MAP_VALUE 2 +/* insn[0].src_reg: BPF_PSEUDO_BTF_ID + * insn[0].imm: kernel btd id of VAR + * insn[1].imm: 0 + * insn[0].off: 0 + * insn[1].off: 0 + * ldimm64 rewrite: address of the kernel variable + * verifier type: PTR_TO_BTF_ID or PTR_TO_MEM, depending on whether the var + * is struct/union. + */ +#define BPF_PSEUDO_BTF_ID 3 +/* insn[0].src_reg: BPF_PSEUDO_FUNC + * insn[0].imm: insn offset to the func + * insn[1].imm: 0 + * insn[0].off: 0 + * insn[1].off: 0 + * ldimm64 rewrite: address of the function + * verifier type: PTR_TO_FUNC. + */ +#define BPF_PSEUDO_FUNC 4 + +/* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative + * offset to another bpf function + */ +#define BPF_PSEUDO_CALL 1 + +/* flags for BPF_MAP_UPDATE_ELEM command */ +enum { + BPF_ANY = 0, /* create new element or update existing */ + BPF_NOEXIST = 1, /* create new element if it didn't exist */ + BPF_EXIST = 2, /* update existing element */ + BPF_F_LOCK = 4, /* spin_lock-ed map_lookup/map_update */ +}; + +/* flags for BPF_MAP_CREATE command */ +enum { + BPF_F_NO_PREALLOC = (1U << 0), +/* Instead of having one common LRU list in the + * BPF_MAP_TYPE_LRU_[PERCPU_]HASH map, use a percpu LRU list + * which can scale and perform better. + * Note, the LRU nodes (including free nodes) cannot be moved + * across different LRU lists. + */ + BPF_F_NO_COMMON_LRU = (1U << 1), +/* Specify numa node during map creation */ + BPF_F_NUMA_NODE = (1U << 2), + +/* Flags for accessing BPF object from syscall side. */ + BPF_F_RDONLY = (1U << 3), + BPF_F_WRONLY = (1U << 4), + +/* Flag for stack_map, store build_id+offset instead of pointer */ + BPF_F_STACK_BUILD_ID = (1U << 5), + +/* Zero-initialize hash function seed. This should only be used for testing. */ + BPF_F_ZERO_SEED = (1U << 6), + +/* Flags for accessing BPF object from program side. */ + BPF_F_RDONLY_PROG = (1U << 7), + BPF_F_WRONLY_PROG = (1U << 8), + +/* Clone map from listener for newly accepted socket */ + BPF_F_CLONE = (1U << 9), + +/* Enable memory-mapping BPF map */ + BPF_F_MMAPABLE = (1U << 10), + +/* Share perf_event among processes */ + BPF_F_PRESERVE_ELEMS = (1U << 11), + +/* Create a map that is suitable to be an inner map with dynamic max entries */ + BPF_F_INNER_MAP = (1U << 12), +}; + +/* Flags for BPF_PROG_QUERY. */ + +/* Query effective (directly attached + inherited from ancestor cgroups) + * programs that will be executed for events within a cgroup. + * attach_flags with this flag are returned only for directly attached programs. + */ +#define BPF_F_QUERY_EFFECTIVE (1U << 0) + +/* Flags for BPF_PROG_TEST_RUN */ + +/* If set, run the test on the cpu specified by bpf_attr.test.cpu */ +#define BPF_F_TEST_RUN_ON_CPU (1U << 0) + +/* type for BPF_ENABLE_STATS */ +enum bpf_stats_type { + /* enabled run_time_ns and run_cnt */ + BPF_STATS_RUN_TIME = 0, +}; + +enum bpf_stack_build_id_status { + /* user space need an empty entry to identify end of a trace */ + BPF_STACK_BUILD_ID_EMPTY = 0, + /* with valid build_id and offset */ + BPF_STACK_BUILD_ID_VALID = 1, + /* couldn't get build_id, fallback to ip */ + BPF_STACK_BUILD_ID_IP = 2, +}; + +#define BPF_BUILD_ID_SIZE 20 +struct bpf_stack_build_id { + __s32 status; + unsigned char build_id[BPF_BUILD_ID_SIZE]; + union { + __u64 offset; + __u64 ip; + }; +}; + +#define BPF_OBJ_NAME_LEN 16U + +union bpf_attr { + struct { /* anonymous struct used by BPF_MAP_CREATE command */ + __u32 map_type; /* one of enum bpf_map_type */ + __u32 key_size; /* size of key in bytes */ + __u32 value_size; /* size of value in bytes */ + __u32 max_entries; /* max number of entries in a map */ + __u32 map_flags; /* BPF_MAP_CREATE related + * flags defined above. + */ + __u32 inner_map_fd; /* fd pointing to the inner map */ + __u32 numa_node; /* numa node (effective only if + * BPF_F_NUMA_NODE is set). + */ + char map_name[BPF_OBJ_NAME_LEN]; + __u32 map_ifindex; /* ifindex of netdev to create on */ + __u32 btf_fd; /* fd pointing to a BTF type data */ + __u32 btf_key_type_id; /* BTF type_id of the key */ + __u32 btf_value_type_id; /* BTF type_id of the value */ + __u32 btf_vmlinux_value_type_id;/* BTF type_id of a kernel- + * struct stored as the + * map value + */ + }; + + struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */ + __u32 map_fd; + __aligned_u64 key; + union { + __aligned_u64 value; + __aligned_u64 next_key; + }; + __u64 flags; + }; + + struct { /* struct used by BPF_MAP_*_BATCH commands */ + __aligned_u64 in_batch; /* start batch, + * NULL to start from beginning + */ + __aligned_u64 out_batch; /* output: next start batch */ + __aligned_u64 keys; + __aligned_u64 values; + __u32 count; /* input/output: + * input: # of key/value + * elements + * output: # of filled elements + */ + __u32 map_fd; + __u64 elem_flags; + __u64 flags; + } batch; + + struct { /* anonymous struct used by BPF_PROG_LOAD command */ + __u32 prog_type; /* one of enum bpf_prog_type */ + __u32 insn_cnt; + __aligned_u64 insns; + __aligned_u64 license; + __u32 log_level; /* verbosity level of verifier */ + __u32 log_size; /* size of user buffer */ + __aligned_u64 log_buf; /* user supplied buffer */ + __u32 kern_version; /* not used */ + __u32 prog_flags; + char prog_name[BPF_OBJ_NAME_LEN]; + __u32 prog_ifindex; /* ifindex of netdev to prep for */ + /* For some prog types expected attach type must be known at + * load time to verify attach type specific parts of prog + * (context accesses, allowed helpers, etc). + */ + __u32 expected_attach_type; + __u32 prog_btf_fd; /* fd pointing to BTF type data */ + __u32 func_info_rec_size; /* userspace bpf_func_info size */ + __aligned_u64 func_info; /* func info */ + __u32 func_info_cnt; /* number of bpf_func_info records */ + __u32 line_info_rec_size; /* userspace bpf_line_info size */ + __aligned_u64 line_info; /* line info */ + __u32 line_info_cnt; /* number of bpf_line_info records */ + __u32 attach_btf_id; /* in-kernel BTF type id to attach to */ + union { + /* valid prog_fd to attach to bpf prog */ + __u32 attach_prog_fd; + /* or valid module BTF object fd or 0 to attach to vmlinux */ + __u32 attach_btf_obj_fd; + }; + }; + + struct { /* anonymous struct used by BPF_OBJ_* commands */ + __aligned_u64 pathname; + __u32 bpf_fd; + __u32 file_flags; + }; + + struct { /* anonymous struct used by BPF_PROG_ATTACH/DETACH commands */ + __u32 target_fd; /* container object to attach to */ + __u32 attach_bpf_fd; /* eBPF program to attach */ + __u32 attach_type; + __u32 attach_flags; + __u32 replace_bpf_fd; /* previously attached eBPF + * program to replace if + * BPF_F_REPLACE is used + */ + }; + + struct { /* anonymous struct used by BPF_PROG_TEST_RUN command */ + __u32 prog_fd; + __u32 retval; + __u32 data_size_in; /* input: len of data_in */ + __u32 data_size_out; /* input/output: len of data_out + * returns ENOSPC if data_out + * is too small. + */ + __aligned_u64 data_in; + __aligned_u64 data_out; + __u32 repeat; + __u32 duration; + __u32 ctx_size_in; /* input: len of ctx_in */ + __u32 ctx_size_out; /* input/output: len of ctx_out + * returns ENOSPC if ctx_out + * is too small. + */ + __aligned_u64 ctx_in; + __aligned_u64 ctx_out; + __u32 flags; + __u32 cpu; + } test; + + struct { /* anonymous struct used by BPF_*_GET_*_ID */ + union { + __u32 start_id; + __u32 prog_id; + __u32 map_id; + __u32 btf_id; + __u32 link_id; + }; + __u32 next_id; + __u32 open_flags; + }; + + struct { /* anonymous struct used by BPF_OBJ_GET_INFO_BY_FD */ + __u32 bpf_fd; + __u32 info_len; + __aligned_u64 info; + } info; + + struct { /* anonymous struct used by BPF_PROG_QUERY command */ + __u32 target_fd; /* container object to query */ + __u32 attach_type; + __u32 query_flags; + __u32 attach_flags; + __aligned_u64 prog_ids; + __u32 prog_cnt; + } query; + + struct { /* anonymous struct used by BPF_RAW_TRACEPOINT_OPEN command */ + __u64 name; + __u32 prog_fd; + } raw_tracepoint; + + struct { /* anonymous struct for BPF_BTF_LOAD */ + __aligned_u64 btf; + __aligned_u64 btf_log_buf; + __u32 btf_size; + __u32 btf_log_size; + __u32 btf_log_level; + }; + + struct { + __u32 pid; /* input: pid */ + __u32 fd; /* input: fd */ + __u32 flags; /* input: flags */ + __u32 buf_len; /* input/output: buf len */ + __aligned_u64 buf; /* input/output: + * tp_name for tracepoint + * symbol for kprobe + * filename for uprobe + */ + __u32 prog_id; /* output: prod_id */ + __u32 fd_type; /* output: BPF_FD_TYPE_* */ + __u64 probe_offset; /* output: probe_offset */ + __u64 probe_addr; /* output: probe_addr */ + } task_fd_query; + + struct { /* struct used by BPF_LINK_CREATE command */ + __u32 prog_fd; /* eBPF program to attach */ + union { + __u32 target_fd; /* object to attach to */ + __u32 target_ifindex; /* target ifindex */ + }; + __u32 attach_type; /* attach type */ + __u32 flags; /* extra flags */ + union { + __u32 target_btf_id; /* btf_id of target to attach to */ + struct { + __aligned_u64 iter_info; /* extra bpf_iter_link_info */ + __u32 iter_info_len; /* iter_info length */ + }; + }; + } link_create; + + struct { /* struct used by BPF_LINK_UPDATE command */ + __u32 link_fd; /* link fd */ + /* new program fd to update link with */ + __u32 new_prog_fd; + __u32 flags; /* extra flags */ + /* expected link's program fd; is specified only if + * BPF_F_REPLACE flag is set in flags */ + __u32 old_prog_fd; + } link_update; + + struct { + __u32 link_fd; + } link_detach; + + struct { /* struct used by BPF_ENABLE_STATS command */ + __u32 type; + } enable_stats; + + struct { /* struct used by BPF_ITER_CREATE command */ + __u32 link_fd; + __u32 flags; + } iter_create; + + struct { /* struct used by BPF_PROG_BIND_MAP command */ + __u32 prog_fd; + __u32 map_fd; + __u32 flags; /* extra flags */ + } prog_bind_map; + +} __attribute__((aligned(8))); + +/* The description below is an attempt at providing documentation to eBPF + * developers about the multiple available eBPF helper functions. It can be + * parsed and used to produce a manual page. The workflow is the following, + * and requires the rst2man utility: + * + * $ ./scripts/bpf_helpers_doc.py \ + * --filename include/uapi/linux/bpf.h > /tmp/bpf-helpers.rst + * $ rst2man /tmp/bpf-helpers.rst > /tmp/bpf-helpers.7 + * $ man /tmp/bpf-helpers.7 + * + * Note that in order to produce this external documentation, some RST + * formatting is used in the descriptions to get "bold" and "italics" in + * manual pages. Also note that the few trailing white spaces are + * intentional, removing them would break paragraphs for rst2man. + * + * Start of BPF helper function descriptions: + * + * void *bpf_map_lookup_elem(struct bpf_map *map, const void *key) + * Description + * Perform a lookup in *map* for an entry associated to *key*. + * Return + * Map value associated to *key*, or **NULL** if no entry was + * found. + * + * long bpf_map_update_elem(struct bpf_map *map, const void *key, const void *value, u64 flags) + * Description + * Add or update the value of the entry associated to *key* in + * *map* with *value*. *flags* is one of: + * + * **BPF_NOEXIST** + * The entry for *key* must not exist in the map. + * **BPF_EXIST** + * The entry for *key* must already exist in the map. + * **BPF_ANY** + * No condition on the existence of the entry for *key*. + * + * Flag value **BPF_NOEXIST** cannot be used for maps of types + * **BPF_MAP_TYPE_ARRAY** or **BPF_MAP_TYPE_PERCPU_ARRAY** (all + * elements always exist), the helper would return an error. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_map_delete_elem(struct bpf_map *map, const void *key) + * Description + * Delete entry with *key* from *map*. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_probe_read(void *dst, u32 size, const void *unsafe_ptr) + * Description + * For tracing programs, safely attempt to read *size* bytes from + * kernel space address *unsafe_ptr* and store the data in *dst*. + * + * Generally, use **bpf_probe_read_user**\ () or + * **bpf_probe_read_kernel**\ () instead. + * Return + * 0 on success, or a negative error in case of failure. + * + * u64 bpf_ktime_get_ns(void) + * Description + * Return the time elapsed since system boot, in nanoseconds. + * Does not include time the system was suspended. + * See: **clock_gettime**\ (**CLOCK_MONOTONIC**) + * Return + * Current *ktime*. + * + * long bpf_trace_printk(const char *fmt, u32 fmt_size, ...) + * Description + * This helper is a "printk()-like" facility for debugging. It + * prints a message defined by format *fmt* (of size *fmt_size*) + * to file *\/sys/kernel/debug/tracing/trace* from DebugFS, if + * available. It can take up to three additional **u64** + * arguments (as an eBPF helpers, the total number of arguments is + * limited to five). + * + * Each time the helper is called, it appends a line to the trace. + * Lines are discarded while *\/sys/kernel/debug/tracing/trace* is + * open, use *\/sys/kernel/debug/tracing/trace_pipe* to avoid this. + * The format of the trace is customizable, and the exact output + * one will get depends on the options set in + * *\/sys/kernel/debug/tracing/trace_options* (see also the + * *README* file under the same directory). However, it usually + * defaults to something like: + * + * :: + * + * telnet-470 [001] .N.. 419421.045894: 0x00000001: + * + * In the above: + * + * * ``telnet`` is the name of the current task. + * * ``470`` is the PID of the current task. + * * ``001`` is the CPU number on which the task is + * running. + * * In ``.N..``, each character refers to a set of + * options (whether irqs are enabled, scheduling + * options, whether hard/softirqs are running, level of + * preempt_disabled respectively). **N** means that + * **TIF_NEED_RESCHED** and **PREEMPT_NEED_RESCHED** + * are set. + * * ``419421.045894`` is a timestamp. + * * ``0x00000001`` is a fake value used by BPF for the + * instruction pointer register. + * * ```` is the message formatted with + * *fmt*. + * + * The conversion specifiers supported by *fmt* are similar, but + * more limited than for printk(). They are **%d**, **%i**, + * **%u**, **%x**, **%ld**, **%li**, **%lu**, **%lx**, **%lld**, + * **%lli**, **%llu**, **%llx**, **%p**, **%s**. No modifier (size + * of field, padding with zeroes, etc.) is available, and the + * helper will return **-EINVAL** (but print nothing) if it + * encounters an unknown specifier. + * + * Also, note that **bpf_trace_printk**\ () is slow, and should + * only be used for debugging purposes. For this reason, a notice + * block (spanning several lines) is printed to kernel logs and + * states that the helper should not be used "for production use" + * the first time this helper is used (or more precisely, when + * **trace_printk**\ () buffers are allocated). For passing values + * to user space, perf events should be preferred. + * Return + * The number of bytes written to the buffer, or a negative error + * in case of failure. + * + * u32 bpf_get_prandom_u32(void) + * Description + * Get a pseudo-random number. + * + * From a security point of view, this helper uses its own + * pseudo-random internal state, and cannot be used to infer the + * seed of other random functions in the kernel. However, it is + * essential to note that the generator used by the helper is not + * cryptographically secure. + * Return + * A random 32-bit unsigned value. + * + * u32 bpf_get_smp_processor_id(void) + * Description + * Get the SMP (symmetric multiprocessing) processor id. Note that + * all programs run with preemption disabled, which means that the + * SMP processor id is stable during all the execution of the + * program. + * Return + * The SMP id of the processor running the program. + * + * long bpf_skb_store_bytes(struct sk_buff *skb, u32 offset, const void *from, u32 len, u64 flags) + * Description + * Store *len* bytes from address *from* into the packet + * associated to *skb*, at *offset*. *flags* are a combination of + * **BPF_F_RECOMPUTE_CSUM** (automatically recompute the + * checksum for the packet after storing the bytes) and + * **BPF_F_INVALIDATE_HASH** (set *skb*\ **->hash**, *skb*\ + * **->swhash** and *skb*\ **->l4hash** to 0). + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_l3_csum_replace(struct sk_buff *skb, u32 offset, u64 from, u64 to, u64 size) + * Description + * Recompute the layer 3 (e.g. IP) checksum for the packet + * associated to *skb*. Computation is incremental, so the helper + * must know the former value of the header field that was + * modified (*from*), the new value of this field (*to*), and the + * number of bytes (2 or 4) for this field, stored in *size*. + * Alternatively, it is possible to store the difference between + * the previous and the new values of the header field in *to*, by + * setting *from* and *size* to 0. For both methods, *offset* + * indicates the location of the IP checksum within the packet. + * + * This helper works in combination with **bpf_csum_diff**\ (), + * which does not update the checksum in-place, but offers more + * flexibility and can handle sizes larger than 2 or 4 for the + * checksum to update. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_l4_csum_replace(struct sk_buff *skb, u32 offset, u64 from, u64 to, u64 flags) + * Description + * Recompute the layer 4 (e.g. TCP, UDP or ICMP) checksum for the + * packet associated to *skb*. Computation is incremental, so the + * helper must know the former value of the header field that was + * modified (*from*), the new value of this field (*to*), and the + * number of bytes (2 or 4) for this field, stored on the lowest + * four bits of *flags*. Alternatively, it is possible to store + * the difference between the previous and the new values of the + * header field in *to*, by setting *from* and the four lowest + * bits of *flags* to 0. For both methods, *offset* indicates the + * location of the IP checksum within the packet. In addition to + * the size of the field, *flags* can be added (bitwise OR) actual + * flags. With **BPF_F_MARK_MANGLED_0**, a null checksum is left + * untouched (unless **BPF_F_MARK_ENFORCE** is added as well), and + * for updates resulting in a null checksum the value is set to + * **CSUM_MANGLED_0** instead. Flag **BPF_F_PSEUDO_HDR** indicates + * the checksum is to be computed against a pseudo-header. + * + * This helper works in combination with **bpf_csum_diff**\ (), + * which does not update the checksum in-place, but offers more + * flexibility and can handle sizes larger than 2 or 4 for the + * checksum to update. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_tail_call(void *ctx, struct bpf_map *prog_array_map, u32 index) + * Description + * This special helper is used to trigger a "tail call", or in + * other words, to jump into another eBPF program. The same stack + * frame is used (but values on stack and in registers for the + * caller are not accessible to the callee). This mechanism allows + * for program chaining, either for raising the maximum number of + * available eBPF instructions, or to execute given programs in + * conditional blocks. For security reasons, there is an upper + * limit to the number of successive tail calls that can be + * performed. + * + * Upon call of this helper, the program attempts to jump into a + * program referenced at index *index* in *prog_array_map*, a + * special map of type **BPF_MAP_TYPE_PROG_ARRAY**, and passes + * *ctx*, a pointer to the context. + * + * If the call succeeds, the kernel immediately runs the first + * instruction of the new program. This is not a function call, + * and it never returns to the previous program. If the call + * fails, then the helper has no effect, and the caller continues + * to run its subsequent instructions. A call can fail if the + * destination program for the jump does not exist (i.e. *index* + * is superior to the number of entries in *prog_array_map*), or + * if the maximum number of tail calls has been reached for this + * chain of programs. This limit is defined in the kernel by the + * macro **MAX_TAIL_CALL_CNT** (not accessible to user space), + * which is currently set to 32. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_clone_redirect(struct sk_buff *skb, u32 ifindex, u64 flags) + * Description + * Clone and redirect the packet associated to *skb* to another + * net device of index *ifindex*. Both ingress and egress + * interfaces can be used for redirection. The **BPF_F_INGRESS** + * value in *flags* is used to make the distinction (ingress path + * is selected if the flag is present, egress path otherwise). + * This is the only flag supported for now. + * + * In comparison with **bpf_redirect**\ () helper, + * **bpf_clone_redirect**\ () has the associated cost of + * duplicating the packet buffer, but this can be executed out of + * the eBPF program. Conversely, **bpf_redirect**\ () is more + * efficient, but it is handled through an action code where the + * redirection happens only after the eBPF program has returned. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * u64 bpf_get_current_pid_tgid(void) + * Return + * A 64-bit integer containing the current tgid and pid, and + * created as such: + * *current_task*\ **->tgid << 32 \|** + * *current_task*\ **->pid**. + * + * u64 bpf_get_current_uid_gid(void) + * Return + * A 64-bit integer containing the current GID and UID, and + * created as such: *current_gid* **<< 32 \|** *current_uid*. + * + * long bpf_get_current_comm(void *buf, u32 size_of_buf) + * Description + * Copy the **comm** attribute of the current task into *buf* of + * *size_of_buf*. The **comm** attribute contains the name of + * the executable (excluding the path) for the current task. The + * *size_of_buf* must be strictly positive. On success, the + * helper makes sure that the *buf* is NUL-terminated. On failure, + * it is filled with zeroes. + * Return + * 0 on success, or a negative error in case of failure. + * + * u32 bpf_get_cgroup_classid(struct sk_buff *skb) + * Description + * Retrieve the classid for the current task, i.e. for the net_cls + * cgroup to which *skb* belongs. + * + * This helper can be used on TC egress path, but not on ingress. + * + * The net_cls cgroup provides an interface to tag network packets + * based on a user-provided identifier for all traffic coming from + * the tasks belonging to the related cgroup. See also the related + * kernel documentation, available from the Linux sources in file + * *Documentation/admin-guide/cgroup-v1/net_cls.rst*. + * + * The Linux kernel has two versions for cgroups: there are + * cgroups v1 and cgroups v2. Both are available to users, who can + * use a mixture of them, but note that the net_cls cgroup is for + * cgroup v1 only. This makes it incompatible with BPF programs + * run on cgroups, which is a cgroup-v2-only feature (a socket can + * only hold data for one version of cgroups at a time). + * + * This helper is only available is the kernel was compiled with + * the **CONFIG_CGROUP_NET_CLASSID** configuration option set to + * "**y**" or to "**m**". + * Return + * The classid, or 0 for the default unconfigured classid. + * + * long bpf_skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci) + * Description + * Push a *vlan_tci* (VLAN tag control information) of protocol + * *vlan_proto* to the packet associated to *skb*, then update + * the checksum. Note that if *vlan_proto* is different from + * **ETH_P_8021Q** and **ETH_P_8021AD**, it is considered to + * be **ETH_P_8021Q**. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_skb_vlan_pop(struct sk_buff *skb) + * Description + * Pop a VLAN header from the packet associated to *skb*. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_skb_get_tunnel_key(struct sk_buff *skb, struct bpf_tunnel_key *key, u32 size, u64 flags) + * Description + * Get tunnel metadata. This helper takes a pointer *key* to an + * empty **struct bpf_tunnel_key** of **size**, that will be + * filled with tunnel metadata for the packet associated to *skb*. + * The *flags* can be set to **BPF_F_TUNINFO_IPV6**, which + * indicates that the tunnel is based on IPv6 protocol instead of + * IPv4. + * + * The **struct bpf_tunnel_key** is an object that generalizes the + * principal parameters used by various tunneling protocols into a + * single struct. This way, it can be used to easily make a + * decision based on the contents of the encapsulation header, + * "summarized" in this struct. In particular, it holds the IP + * address of the remote end (IPv4 or IPv6, depending on the case) + * in *key*\ **->remote_ipv4** or *key*\ **->remote_ipv6**. Also, + * this struct exposes the *key*\ **->tunnel_id**, which is + * generally mapped to a VNI (Virtual Network Identifier), making + * it programmable together with the **bpf_skb_set_tunnel_key**\ + * () helper. + * + * Let's imagine that the following code is part of a program + * attached to the TC ingress interface, on one end of a GRE + * tunnel, and is supposed to filter out all messages coming from + * remote ends with IPv4 address other than 10.0.0.1: + * + * :: + * + * int ret; + * struct bpf_tunnel_key key = {}; + * + * ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0); + * if (ret < 0) + * return TC_ACT_SHOT; // drop packet + * + * if (key.remote_ipv4 != 0x0a000001) + * return TC_ACT_SHOT; // drop packet + * + * return TC_ACT_OK; // accept packet + * + * This interface can also be used with all encapsulation devices + * that can operate in "collect metadata" mode: instead of having + * one network device per specific configuration, the "collect + * metadata" mode only requires a single device where the + * configuration can be extracted from this helper. + * + * This can be used together with various tunnels such as VXLan, + * Geneve, GRE or IP in IP (IPIP). + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_skb_set_tunnel_key(struct sk_buff *skb, struct bpf_tunnel_key *key, u32 size, u64 flags) + * Description + * Populate tunnel metadata for packet associated to *skb.* The + * tunnel metadata is set to the contents of *key*, of *size*. The + * *flags* can be set to a combination of the following values: + * + * **BPF_F_TUNINFO_IPV6** + * Indicate that the tunnel is based on IPv6 protocol + * instead of IPv4. + * **BPF_F_ZERO_CSUM_TX** + * For IPv4 packets, add a flag to tunnel metadata + * indicating that checksum computation should be skipped + * and checksum set to zeroes. + * **BPF_F_DONT_FRAGMENT** + * Add a flag to tunnel metadata indicating that the + * packet should not be fragmented. + * **BPF_F_SEQ_NUMBER** + * Add a flag to tunnel metadata indicating that a + * sequence number should be added to tunnel header before + * sending the packet. This flag was added for GRE + * encapsulation, but might be used with other protocols + * as well in the future. + * + * Here is a typical usage on the transmit path: + * + * :: + * + * struct bpf_tunnel_key key; + * populate key ... + * bpf_skb_set_tunnel_key(skb, &key, sizeof(key), 0); + * bpf_clone_redirect(skb, vxlan_dev_ifindex, 0); + * + * See also the description of the **bpf_skb_get_tunnel_key**\ () + * helper for additional information. + * Return + * 0 on success, or a negative error in case of failure. + * + * u64 bpf_perf_event_read(struct bpf_map *map, u64 flags) + * Description + * Read the value of a perf event counter. This helper relies on a + * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. The nature of + * the perf event counter is selected when *map* is updated with + * perf event file descriptors. The *map* is an array whose size + * is the number of available CPUs, and each cell contains a value + * relative to one CPU. The value to retrieve is indicated by + * *flags*, that contains the index of the CPU to look up, masked + * with **BPF_F_INDEX_MASK**. Alternatively, *flags* can be set to + * **BPF_F_CURRENT_CPU** to indicate that the value for the + * current CPU should be retrieved. + * + * Note that before Linux 4.13, only hardware perf event can be + * retrieved. + * + * Also, be aware that the newer helper + * **bpf_perf_event_read_value**\ () is recommended over + * **bpf_perf_event_read**\ () in general. The latter has some ABI + * quirks where error and counter value are used as a return code + * (which is wrong to do since ranges may overlap). This issue is + * fixed with **bpf_perf_event_read_value**\ (), which at the same + * time provides more features over the **bpf_perf_event_read**\ + * () interface. Please refer to the description of + * **bpf_perf_event_read_value**\ () for details. + * Return + * The value of the perf event counter read from the map, or a + * negative error code in case of failure. + * + * long bpf_redirect(u32 ifindex, u64 flags) + * Description + * Redirect the packet to another net device of index *ifindex*. + * This helper is somewhat similar to **bpf_clone_redirect**\ + * (), except that the packet is not cloned, which provides + * increased performance. + * + * Except for XDP, both ingress and egress interfaces can be used + * for redirection. The **BPF_F_INGRESS** value in *flags* is used + * to make the distinction (ingress path is selected if the flag + * is present, egress path otherwise). Currently, XDP only + * supports redirection to the egress interface, and accepts no + * flag at all. + * + * The same effect can also be attained with the more generic + * **bpf_redirect_map**\ (), which uses a BPF map to store the + * redirect target instead of providing it directly to the helper. + * Return + * For XDP, the helper returns **XDP_REDIRECT** on success or + * **XDP_ABORTED** on error. For other program types, the values + * are **TC_ACT_REDIRECT** on success or **TC_ACT_SHOT** on + * error. + * + * u32 bpf_get_route_realm(struct sk_buff *skb) + * Description + * Retrieve the realm or the route, that is to say the + * **tclassid** field of the destination for the *skb*. The + * identifier retrieved is a user-provided tag, similar to the + * one used with the net_cls cgroup (see description for + * **bpf_get_cgroup_classid**\ () helper), but here this tag is + * held by a route (a destination entry), not by a task. + * + * Retrieving this identifier works with the clsact TC egress hook + * (see also **tc-bpf(8)**), or alternatively on conventional + * classful egress qdiscs, but not on TC ingress path. In case of + * clsact TC egress hook, this has the advantage that, internally, + * the destination entry has not been dropped yet in the transmit + * path. Therefore, the destination entry does not need to be + * artificially held via **netif_keep_dst**\ () for a classful + * qdisc until the *skb* is freed. + * + * This helper is available only if the kernel was compiled with + * **CONFIG_IP_ROUTE_CLASSID** configuration option. + * Return + * The realm of the route for the packet associated to *skb*, or 0 + * if none was found. + * + * long bpf_perf_event_output(void *ctx, struct bpf_map *map, u64 flags, void *data, u64 size) + * Description + * Write raw *data* blob into a special BPF perf event held by + * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. This perf + * event must have the following attributes: **PERF_SAMPLE_RAW** + * as **sample_type**, **PERF_TYPE_SOFTWARE** as **type**, and + * **PERF_COUNT_SW_BPF_OUTPUT** as **config**. + * + * The *flags* are used to indicate the index in *map* for which + * the value must be put, masked with **BPF_F_INDEX_MASK**. + * Alternatively, *flags* can be set to **BPF_F_CURRENT_CPU** + * to indicate that the index of the current CPU core should be + * used. + * + * The value to write, of *size*, is passed through eBPF stack and + * pointed by *data*. + * + * The context of the program *ctx* needs also be passed to the + * helper. + * + * On user space, a program willing to read the values needs to + * call **perf_event_open**\ () on the perf event (either for + * one or for all CPUs) and to store the file descriptor into the + * *map*. This must be done before the eBPF program can send data + * into it. An example is available in file + * *samples/bpf/trace_output_user.c* in the Linux kernel source + * tree (the eBPF program counterpart is in + * *samples/bpf/trace_output_kern.c*). + * + * **bpf_perf_event_output**\ () achieves better performance + * than **bpf_trace_printk**\ () for sharing data with user + * space, and is much better suitable for streaming data from eBPF + * programs. + * + * Note that this helper is not restricted to tracing use cases + * and can be used with programs attached to TC or XDP as well, + * where it allows for passing data to user space listeners. Data + * can be: + * + * * Only custom structs, + * * Only the packet payload, or + * * A combination of both. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_skb_load_bytes(const void *skb, u32 offset, void *to, u32 len) + * Description + * This helper was provided as an easy way to load data from a + * packet. It can be used to load *len* bytes from *offset* from + * the packet associated to *skb*, into the buffer pointed by + * *to*. + * + * Since Linux 4.7, usage of this helper has mostly been replaced + * by "direct packet access", enabling packet data to be + * manipulated with *skb*\ **->data** and *skb*\ **->data_end** + * pointing respectively to the first byte of packet data and to + * the byte after the last byte of packet data. However, it + * remains useful if one wishes to read large quantities of data + * at once from a packet into the eBPF stack. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_get_stackid(void *ctx, struct bpf_map *map, u64 flags) + * Description + * Walk a user or a kernel stack and return its id. To achieve + * this, the helper needs *ctx*, which is a pointer to the context + * on which the tracing program is executed, and a pointer to a + * *map* of type **BPF_MAP_TYPE_STACK_TRACE**. + * + * The last argument, *flags*, holds the number of stack frames to + * skip (from 0 to 255), masked with + * **BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set + * a combination of the following flags: + * + * **BPF_F_USER_STACK** + * Collect a user space stack instead of a kernel stack. + * **BPF_F_FAST_STACK_CMP** + * Compare stacks by hash only. + * **BPF_F_REUSE_STACKID** + * If two different stacks hash into the same *stackid*, + * discard the old one. + * + * The stack id retrieved is a 32 bit long integer handle which + * can be further combined with other data (including other stack + * ids) and used as a key into maps. This can be useful for + * generating a variety of graphs (such as flame graphs or off-cpu + * graphs). + * + * For walking a stack, this helper is an improvement over + * **bpf_probe_read**\ (), which can be used with unrolled loops + * but is not efficient and consumes a lot of eBPF instructions. + * Instead, **bpf_get_stackid**\ () can collect up to + * **PERF_MAX_STACK_DEPTH** both kernel and user frames. Note that + * this limit can be controlled with the **sysctl** program, and + * that it should be manually increased in order to profile long + * user stacks (such as stacks for Java programs). To do so, use: + * + * :: + * + * # sysctl kernel.perf_event_max_stack= + * Return + * The positive or null stack id on success, or a negative error + * in case of failure. + * + * s64 bpf_csum_diff(__be32 *from, u32 from_size, __be32 *to, u32 to_size, __wsum seed) + * Description + * Compute a checksum difference, from the raw buffer pointed by + * *from*, of length *from_size* (that must be a multiple of 4), + * towards the raw buffer pointed by *to*, of size *to_size* + * (same remark). An optional *seed* can be added to the value + * (this can be cascaded, the seed may come from a previous call + * to the helper). + * + * This is flexible enough to be used in several ways: + * + * * With *from_size* == 0, *to_size* > 0 and *seed* set to + * checksum, it can be used when pushing new data. + * * With *from_size* > 0, *to_size* == 0 and *seed* set to + * checksum, it can be used when removing data from a packet. + * * With *from_size* > 0, *to_size* > 0 and *seed* set to 0, it + * can be used to compute a diff. Note that *from_size* and + * *to_size* do not need to be equal. + * + * This helper can be used in combination with + * **bpf_l3_csum_replace**\ () and **bpf_l4_csum_replace**\ (), to + * which one can feed in the difference computed with + * **bpf_csum_diff**\ (). + * Return + * The checksum result, or a negative error code in case of + * failure. + * + * long bpf_skb_get_tunnel_opt(struct sk_buff *skb, void *opt, u32 size) + * Description + * Retrieve tunnel options metadata for the packet associated to + * *skb*, and store the raw tunnel option data to the buffer *opt* + * of *size*. + * + * This helper can be used with encapsulation devices that can + * operate in "collect metadata" mode (please refer to the related + * note in the description of **bpf_skb_get_tunnel_key**\ () for + * more details). A particular example where this can be used is + * in combination with the Geneve encapsulation protocol, where it + * allows for pushing (with **bpf_skb_get_tunnel_opt**\ () helper) + * and retrieving arbitrary TLVs (Type-Length-Value headers) from + * the eBPF program. This allows for full customization of these + * headers. + * Return + * The size of the option data retrieved. + * + * long bpf_skb_set_tunnel_opt(struct sk_buff *skb, void *opt, u32 size) + * Description + * Set tunnel options metadata for the packet associated to *skb* + * to the option data contained in the raw buffer *opt* of *size*. + * + * See also the description of the **bpf_skb_get_tunnel_opt**\ () + * helper for additional information. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_skb_change_proto(struct sk_buff *skb, __be16 proto, u64 flags) + * Description + * Change the protocol of the *skb* to *proto*. Currently + * supported are transition from IPv4 to IPv6, and from IPv6 to + * IPv4. The helper takes care of the groundwork for the + * transition, including resizing the socket buffer. The eBPF + * program is expected to fill the new headers, if any, via + * **skb_store_bytes**\ () and to recompute the checksums with + * **bpf_l3_csum_replace**\ () and **bpf_l4_csum_replace**\ + * (). The main case for this helper is to perform NAT64 + * operations out of an eBPF program. + * + * Internally, the GSO type is marked as dodgy so that headers are + * checked and segments are recalculated by the GSO/GRO engine. + * The size for GSO target is adapted as well. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_skb_change_type(struct sk_buff *skb, u32 type) + * Description + * Change the packet type for the packet associated to *skb*. This + * comes down to setting *skb*\ **->pkt_type** to *type*, except + * the eBPF program does not have a write access to *skb*\ + * **->pkt_type** beside this helper. Using a helper here allows + * for graceful handling of errors. + * + * The major use case is to change incoming *skb*s to + * **PACKET_HOST** in a programmatic way instead of having to + * recirculate via **redirect**\ (..., **BPF_F_INGRESS**), for + * example. + * + * Note that *type* only allows certain values. At this time, they + * are: + * + * **PACKET_HOST** + * Packet is for us. + * **PACKET_BROADCAST** + * Send packet to all. + * **PACKET_MULTICAST** + * Send packet to group. + * **PACKET_OTHERHOST** + * Send packet to someone else. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_skb_under_cgroup(struct sk_buff *skb, struct bpf_map *map, u32 index) + * Description + * Check whether *skb* is a descendant of the cgroup2 held by + * *map* of type **BPF_MAP_TYPE_CGROUP_ARRAY**, at *index*. + * Return + * The return value depends on the result of the test, and can be: + * + * * 0, if the *skb* failed the cgroup2 descendant test. + * * 1, if the *skb* succeeded the cgroup2 descendant test. + * * A negative error code, if an error occurred. + * + * u32 bpf_get_hash_recalc(struct sk_buff *skb) + * Description + * Retrieve the hash of the packet, *skb*\ **->hash**. If it is + * not set, in particular if the hash was cleared due to mangling, + * recompute this hash. Later accesses to the hash can be done + * directly with *skb*\ **->hash**. + * + * Calling **bpf_set_hash_invalid**\ (), changing a packet + * prototype with **bpf_skb_change_proto**\ (), or calling + * **bpf_skb_store_bytes**\ () with the + * **BPF_F_INVALIDATE_HASH** are actions susceptible to clear + * the hash and to trigger a new computation for the next call to + * **bpf_get_hash_recalc**\ (). + * Return + * The 32-bit hash. + * + * u64 bpf_get_current_task(void) + * Return + * A pointer to the current task struct. + * + * long bpf_probe_write_user(void *dst, const void *src, u32 len) + * Description + * Attempt in a safe way to write *len* bytes from the buffer + * *src* to *dst* in memory. It only works for threads that are in + * user context, and *dst* must be a valid user space address. + * + * This helper should not be used to implement any kind of + * security mechanism because of TOC-TOU attacks, but rather to + * debug, divert, and manipulate execution of semi-cooperative + * processes. + * + * Keep in mind that this feature is meant for experiments, and it + * has a risk of crashing the system and running programs. + * Therefore, when an eBPF program using this helper is attached, + * a warning including PID and process name is printed to kernel + * logs. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_current_task_under_cgroup(struct bpf_map *map, u32 index) + * Description + * Check whether the probe is being run is the context of a given + * subset of the cgroup2 hierarchy. The cgroup2 to test is held by + * *map* of type **BPF_MAP_TYPE_CGROUP_ARRAY**, at *index*. + * Return + * The return value depends on the result of the test, and can be: + * + * * 0, if current task belongs to the cgroup2. + * * 1, if current task does not belong to the cgroup2. + * * A negative error code, if an error occurred. + * + * long bpf_skb_change_tail(struct sk_buff *skb, u32 len, u64 flags) + * Description + * Resize (trim or grow) the packet associated to *skb* to the + * new *len*. The *flags* are reserved for future usage, and must + * be left at zero. + * + * The basic idea is that the helper performs the needed work to + * change the size of the packet, then the eBPF program rewrites + * the rest via helpers like **bpf_skb_store_bytes**\ (), + * **bpf_l3_csum_replace**\ (), **bpf_l3_csum_replace**\ () + * and others. This helper is a slow path utility intended for + * replies with control messages. And because it is targeted for + * slow path, the helper itself can afford to be slow: it + * implicitly linearizes, unclones and drops offloads from the + * *skb*. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_skb_pull_data(struct sk_buff *skb, u32 len) + * Description + * Pull in non-linear data in case the *skb* is non-linear and not + * all of *len* are part of the linear section. Make *len* bytes + * from *skb* readable and writable. If a zero value is passed for + * *len*, then the whole length of the *skb* is pulled. + * + * This helper is only needed for reading and writing with direct + * packet access. + * + * For direct packet access, testing that offsets to access + * are within packet boundaries (test on *skb*\ **->data_end**) is + * susceptible to fail if offsets are invalid, or if the requested + * data is in non-linear parts of the *skb*. On failure the + * program can just bail out, or in the case of a non-linear + * buffer, use a helper to make the data available. The + * **bpf_skb_load_bytes**\ () helper is a first solution to access + * the data. Another one consists in using **bpf_skb_pull_data** + * to pull in once the non-linear parts, then retesting and + * eventually access the data. + * + * At the same time, this also makes sure the *skb* is uncloned, + * which is a necessary condition for direct write. As this needs + * to be an invariant for the write part only, the verifier + * detects writes and adds a prologue that is calling + * **bpf_skb_pull_data()** to effectively unclone the *skb* from + * the very beginning in case it is indeed cloned. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * s64 bpf_csum_update(struct sk_buff *skb, __wsum csum) + * Description + * Add the checksum *csum* into *skb*\ **->csum** in case the + * driver has supplied a checksum for the entire packet into that + * field. Return an error otherwise. This helper is intended to be + * used in combination with **bpf_csum_diff**\ (), in particular + * when the checksum needs to be updated after data has been + * written into the packet through direct packet access. + * Return + * The checksum on success, or a negative error code in case of + * failure. + * + * void bpf_set_hash_invalid(struct sk_buff *skb) + * Description + * Invalidate the current *skb*\ **->hash**. It can be used after + * mangling on headers through direct packet access, in order to + * indicate that the hash is outdated and to trigger a + * recalculation the next time the kernel tries to access this + * hash or when the **bpf_get_hash_recalc**\ () helper is called. + * + * long bpf_get_numa_node_id(void) + * Description + * Return the id of the current NUMA node. The primary use case + * for this helper is the selection of sockets for the local NUMA + * node, when the program is attached to sockets using the + * **SO_ATTACH_REUSEPORT_EBPF** option (see also **socket(7)**), + * but the helper is also available to other eBPF program types, + * similarly to **bpf_get_smp_processor_id**\ (). + * Return + * The id of current NUMA node. + * + * long bpf_skb_change_head(struct sk_buff *skb, u32 len, u64 flags) + * Description + * Grows headroom of packet associated to *skb* and adjusts the + * offset of the MAC header accordingly, adding *len* bytes of + * space. It automatically extends and reallocates memory as + * required. + * + * This helper can be used on a layer 3 *skb* to push a MAC header + * for redirection into a layer 2 device. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_xdp_adjust_head(struct xdp_buff *xdp_md, int delta) + * Description + * Adjust (move) *xdp_md*\ **->data** by *delta* bytes. Note that + * it is possible to use a negative value for *delta*. This helper + * can be used to prepare the packet for pushing or popping + * headers. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_probe_read_str(void *dst, u32 size, const void *unsafe_ptr) + * Description + * Copy a NUL terminated string from an unsafe kernel address + * *unsafe_ptr* to *dst*. See **bpf_probe_read_kernel_str**\ () for + * more details. + * + * Generally, use **bpf_probe_read_user_str**\ () or + * **bpf_probe_read_kernel_str**\ () instead. + * Return + * On success, the strictly positive length of the string, + * including the trailing NUL character. On error, a negative + * value. + * + * u64 bpf_get_socket_cookie(struct sk_buff *skb) + * Description + * If the **struct sk_buff** pointed by *skb* has a known socket, + * retrieve the cookie (generated by the kernel) of this socket. + * If no cookie has been set yet, generate a new cookie. Once + * generated, the socket cookie remains stable for the life of the + * socket. This helper can be useful for monitoring per socket + * networking traffic statistics as it provides a global socket + * identifier that can be assumed unique. + * Return + * A 8-byte long unique number on success, or 0 if the socket + * field is missing inside *skb*. + * + * u64 bpf_get_socket_cookie(struct bpf_sock_addr *ctx) + * Description + * Equivalent to bpf_get_socket_cookie() helper that accepts + * *skb*, but gets socket from **struct bpf_sock_addr** context. + * Return + * A 8-byte long unique number. + * + * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx) + * Description + * Equivalent to **bpf_get_socket_cookie**\ () helper that accepts + * *skb*, but gets socket from **struct bpf_sock_ops** context. + * Return + * A 8-byte long unique number. + * + * u64 bpf_get_socket_cookie(struct sock *sk) + * Description + * Equivalent to **bpf_get_socket_cookie**\ () helper that accepts + * *sk*, but gets socket from a BTF **struct sock**. This helper + * also works for sleepable programs. + * Return + * A 8-byte long unique number or 0 if *sk* is NULL. + * + * u32 bpf_get_socket_uid(struct sk_buff *skb) + * Return + * The owner UID of the socket associated to *skb*. If the socket + * is **NULL**, or if it is not a full socket (i.e. if it is a + * time-wait or a request socket instead), **overflowuid** value + * is returned (note that **overflowuid** might also be the actual + * UID value for the socket). + * + * long bpf_set_hash(struct sk_buff *skb, u32 hash) + * Description + * Set the full hash for *skb* (set the field *skb*\ **->hash**) + * to value *hash*. + * Return + * 0 + * + * long bpf_setsockopt(void *bpf_socket, int level, int optname, void *optval, int optlen) + * Description + * Emulate a call to **setsockopt()** on the socket associated to + * *bpf_socket*, which must be a full socket. The *level* at + * which the option resides and the name *optname* of the option + * must be specified, see **setsockopt(2)** for more information. + * The option value of length *optlen* is pointed by *optval*. + * + * *bpf_socket* should be one of the following: + * + * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**. + * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT** + * and **BPF_CGROUP_INET6_CONNECT**. + * + * This helper actually implements a subset of **setsockopt()**. + * It supports the following *level*\ s: + * + * * **SOL_SOCKET**, which supports the following *optname*\ s: + * **SO_RCVBUF**, **SO_SNDBUF**, **SO_MAX_PACING_RATE**, + * **SO_PRIORITY**, **SO_RCVLOWAT**, **SO_MARK**, + * **SO_BINDTODEVICE**, **SO_KEEPALIVE**. + * * **IPPROTO_TCP**, which supports the following *optname*\ s: + * **TCP_CONGESTION**, **TCP_BPF_IW**, + * **TCP_BPF_SNDCWND_CLAMP**, **TCP_SAVE_SYN**, + * **TCP_KEEPIDLE**, **TCP_KEEPINTVL**, **TCP_KEEPCNT**, + * **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT**. + * * **IPPROTO_IP**, which supports *optname* **IP_TOS**. + * * **IPPROTO_IPV6**, which supports *optname* **IPV6_TCLASS**. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_skb_adjust_room(struct sk_buff *skb, s32 len_diff, u32 mode, u64 flags) + * Description + * Grow or shrink the room for data in the packet associated to + * *skb* by *len_diff*, and according to the selected *mode*. + * + * By default, the helper will reset any offloaded checksum + * indicator of the skb to CHECKSUM_NONE. This can be avoided + * by the following flag: + * + * * **BPF_F_ADJ_ROOM_NO_CSUM_RESET**: Do not reset offloaded + * checksum data of the skb to CHECKSUM_NONE. + * + * There are two supported modes at this time: + * + * * **BPF_ADJ_ROOM_MAC**: Adjust room at the mac layer + * (room space is added or removed below the layer 2 header). + * + * * **BPF_ADJ_ROOM_NET**: Adjust room at the network layer + * (room space is added or removed below the layer 3 header). + * + * The following flags are supported at this time: + * + * * **BPF_F_ADJ_ROOM_FIXED_GSO**: Do not adjust gso_size. + * Adjusting mss in this way is not allowed for datagrams. + * + * * **BPF_F_ADJ_ROOM_ENCAP_L3_IPV4**, + * **BPF_F_ADJ_ROOM_ENCAP_L3_IPV6**: + * Any new space is reserved to hold a tunnel header. + * Configure skb offsets and other fields accordingly. + * + * * **BPF_F_ADJ_ROOM_ENCAP_L4_GRE**, + * **BPF_F_ADJ_ROOM_ENCAP_L4_UDP**: + * Use with ENCAP_L3 flags to further specify the tunnel type. + * + * * **BPF_F_ADJ_ROOM_ENCAP_L2**\ (*len*): + * Use with ENCAP_L3/L4 flags to further specify the tunnel + * type; *len* is the length of the inner MAC header. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_redirect_map(struct bpf_map *map, u32 key, u64 flags) + * Description + * Redirect the packet to the endpoint referenced by *map* at + * index *key*. Depending on its type, this *map* can contain + * references to net devices (for forwarding packets through other + * ports), or to CPUs (for redirecting XDP frames to another CPU; + * but this is only implemented for native XDP (with driver + * support) as of this writing). + * + * The lower two bits of *flags* are used as the return code if + * the map lookup fails. This is so that the return value can be + * one of the XDP program return codes up to **XDP_TX**, as chosen + * by the caller. Any higher bits in the *flags* argument must be + * unset. + * + * See also **bpf_redirect**\ (), which only supports redirecting + * to an ifindex, but doesn't require a map to do so. + * Return + * **XDP_REDIRECT** on success, or the value of the two lower bits + * of the *flags* argument on error. + * + * long bpf_sk_redirect_map(struct sk_buff *skb, struct bpf_map *map, u32 key, u64 flags) + * Description + * Redirect the packet to the socket referenced by *map* (of type + * **BPF_MAP_TYPE_SOCKMAP**) at index *key*. Both ingress and + * egress interfaces can be used for redirection. The + * **BPF_F_INGRESS** value in *flags* is used to make the + * distinction (ingress path is selected if the flag is present, + * egress path otherwise). This is the only flag supported for now. + * Return + * **SK_PASS** on success, or **SK_DROP** on error. + * + * long bpf_sock_map_update(struct bpf_sock_ops *skops, struct bpf_map *map, void *key, u64 flags) + * Description + * Add an entry to, or update a *map* referencing sockets. The + * *skops* is used as a new value for the entry associated to + * *key*. *flags* is one of: + * + * **BPF_NOEXIST** + * The entry for *key* must not exist in the map. + * **BPF_EXIST** + * The entry for *key* must already exist in the map. + * **BPF_ANY** + * No condition on the existence of the entry for *key*. + * + * If the *map* has eBPF programs (parser and verdict), those will + * be inherited by the socket being added. If the socket is + * already attached to eBPF programs, this results in an error. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_xdp_adjust_meta(struct xdp_buff *xdp_md, int delta) + * Description + * Adjust the address pointed by *xdp_md*\ **->data_meta** by + * *delta* (which can be positive or negative). Note that this + * operation modifies the address stored in *xdp_md*\ **->data**, + * so the latter must be loaded only after the helper has been + * called. + * + * The use of *xdp_md*\ **->data_meta** is optional and programs + * are not required to use it. The rationale is that when the + * packet is processed with XDP (e.g. as DoS filter), it is + * possible to push further meta data along with it before passing + * to the stack, and to give the guarantee that an ingress eBPF + * program attached as a TC classifier on the same device can pick + * this up for further post-processing. Since TC works with socket + * buffers, it remains possible to set from XDP the **mark** or + * **priority** pointers, or other pointers for the socket buffer. + * Having this scratch space generic and programmable allows for + * more flexibility as the user is free to store whatever meta + * data they need. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_perf_event_read_value(struct bpf_map *map, u64 flags, struct bpf_perf_event_value *buf, u32 buf_size) + * Description + * Read the value of a perf event counter, and store it into *buf* + * of size *buf_size*. This helper relies on a *map* of type + * **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. The nature of the perf event + * counter is selected when *map* is updated with perf event file + * descriptors. The *map* is an array whose size is the number of + * available CPUs, and each cell contains a value relative to one + * CPU. The value to retrieve is indicated by *flags*, that + * contains the index of the CPU to look up, masked with + * **BPF_F_INDEX_MASK**. Alternatively, *flags* can be set to + * **BPF_F_CURRENT_CPU** to indicate that the value for the + * current CPU should be retrieved. + * + * This helper behaves in a way close to + * **bpf_perf_event_read**\ () helper, save that instead of + * just returning the value observed, it fills the *buf* + * structure. This allows for additional data to be retrieved: in + * particular, the enabled and running times (in *buf*\ + * **->enabled** and *buf*\ **->running**, respectively) are + * copied. In general, **bpf_perf_event_read_value**\ () is + * recommended over **bpf_perf_event_read**\ (), which has some + * ABI issues and provides fewer functionalities. + * + * These values are interesting, because hardware PMU (Performance + * Monitoring Unit) counters are limited resources. When there are + * more PMU based perf events opened than available counters, + * kernel will multiplex these events so each event gets certain + * percentage (but not all) of the PMU time. In case that + * multiplexing happens, the number of samples or counter value + * will not reflect the case compared to when no multiplexing + * occurs. This makes comparison between different runs difficult. + * Typically, the counter value should be normalized before + * comparing to other experiments. The usual normalization is done + * as follows. + * + * :: + * + * normalized_counter = counter * t_enabled / t_running + * + * Where t_enabled is the time enabled for event and t_running is + * the time running for event since last normalization. The + * enabled and running times are accumulated since the perf event + * open. To achieve scaling factor between two invocations of an + * eBPF program, users can use CPU id as the key (which is + * typical for perf array usage model) to remember the previous + * value and do the calculation inside the eBPF program. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_perf_prog_read_value(struct bpf_perf_event_data *ctx, struct bpf_perf_event_value *buf, u32 buf_size) + * Description + * For en eBPF program attached to a perf event, retrieve the + * value of the event counter associated to *ctx* and store it in + * the structure pointed by *buf* and of size *buf_size*. Enabled + * and running times are also stored in the structure (see + * description of helper **bpf_perf_event_read_value**\ () for + * more details). + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_getsockopt(void *bpf_socket, int level, int optname, void *optval, int optlen) + * Description + * Emulate a call to **getsockopt()** on the socket associated to + * *bpf_socket*, which must be a full socket. The *level* at + * which the option resides and the name *optname* of the option + * must be specified, see **getsockopt(2)** for more information. + * The retrieved value is stored in the structure pointed by + * *opval* and of length *optlen*. + * + * *bpf_socket* should be one of the following: + * + * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**. + * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT** + * and **BPF_CGROUP_INET6_CONNECT**. + * + * This helper actually implements a subset of **getsockopt()**. + * It supports the following *level*\ s: + * + * * **IPPROTO_TCP**, which supports *optname* + * **TCP_CONGESTION**. + * * **IPPROTO_IP**, which supports *optname* **IP_TOS**. + * * **IPPROTO_IPV6**, which supports *optname* **IPV6_TCLASS**. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_override_return(struct pt_regs *regs, u64 rc) + * Description + * Used for error injection, this helper uses kprobes to override + * the return value of the probed function, and to set it to *rc*. + * The first argument is the context *regs* on which the kprobe + * works. + * + * This helper works by setting the PC (program counter) + * to an override function which is run in place of the original + * probed function. This means the probed function is not run at + * all. The replacement function just returns with the required + * value. + * + * This helper has security implications, and thus is subject to + * restrictions. It is only available if the kernel was compiled + * with the **CONFIG_BPF_KPROBE_OVERRIDE** configuration + * option, and in this case it only works on functions tagged with + * **ALLOW_ERROR_INJECTION** in the kernel code. + * + * Also, the helper is only available for the architectures having + * the CONFIG_FUNCTION_ERROR_INJECTION option. As of this writing, + * x86 architecture is the only one to support this feature. + * Return + * 0 + * + * long bpf_sock_ops_cb_flags_set(struct bpf_sock_ops *bpf_sock, int argval) + * Description + * Attempt to set the value of the **bpf_sock_ops_cb_flags** field + * for the full TCP socket associated to *bpf_sock_ops* to + * *argval*. + * + * The primary use of this field is to determine if there should + * be calls to eBPF programs of type + * **BPF_PROG_TYPE_SOCK_OPS** at various points in the TCP + * code. A program of the same type can change its value, per + * connection and as necessary, when the connection is + * established. This field is directly accessible for reading, but + * this helper must be used for updates in order to return an + * error if an eBPF program tries to set a callback that is not + * supported in the current kernel. + * + * *argval* is a flag array which can combine these flags: + * + * * **BPF_SOCK_OPS_RTO_CB_FLAG** (retransmission time out) + * * **BPF_SOCK_OPS_RETRANS_CB_FLAG** (retransmission) + * * **BPF_SOCK_OPS_STATE_CB_FLAG** (TCP state change) + * * **BPF_SOCK_OPS_RTT_CB_FLAG** (every RTT) + * + * Therefore, this function can be used to clear a callback flag by + * setting the appropriate bit to zero. e.g. to disable the RTO + * callback: + * + * **bpf_sock_ops_cb_flags_set(bpf_sock,** + * **bpf_sock->bpf_sock_ops_cb_flags & ~BPF_SOCK_OPS_RTO_CB_FLAG)** + * + * Here are some examples of where one could call such eBPF + * program: + * + * * When RTO fires. + * * When a packet is retransmitted. + * * When the connection terminates. + * * When a packet is sent. + * * When a packet is received. + * Return + * Code **-EINVAL** if the socket is not a full TCP socket; + * otherwise, a positive number containing the bits that could not + * be set is returned (which comes down to 0 if all bits were set + * as required). + * + * long bpf_msg_redirect_map(struct sk_msg_buff *msg, struct bpf_map *map, u32 key, u64 flags) + * Description + * This helper is used in programs implementing policies at the + * socket level. If the message *msg* is allowed to pass (i.e. if + * the verdict eBPF program returns **SK_PASS**), redirect it to + * the socket referenced by *map* (of type + * **BPF_MAP_TYPE_SOCKMAP**) at index *key*. Both ingress and + * egress interfaces can be used for redirection. The + * **BPF_F_INGRESS** value in *flags* is used to make the + * distinction (ingress path is selected if the flag is present, + * egress path otherwise). This is the only flag supported for now. + * Return + * **SK_PASS** on success, or **SK_DROP** on error. + * + * long bpf_msg_apply_bytes(struct sk_msg_buff *msg, u32 bytes) + * Description + * For socket policies, apply the verdict of the eBPF program to + * the next *bytes* (number of bytes) of message *msg*. + * + * For example, this helper can be used in the following cases: + * + * * A single **sendmsg**\ () or **sendfile**\ () system call + * contains multiple logical messages that the eBPF program is + * supposed to read and for which it should apply a verdict. + * * An eBPF program only cares to read the first *bytes* of a + * *msg*. If the message has a large payload, then setting up + * and calling the eBPF program repeatedly for all bytes, even + * though the verdict is already known, would create unnecessary + * overhead. + * + * When called from within an eBPF program, the helper sets a + * counter internal to the BPF infrastructure, that is used to + * apply the last verdict to the next *bytes*. If *bytes* is + * smaller than the current data being processed from a + * **sendmsg**\ () or **sendfile**\ () system call, the first + * *bytes* will be sent and the eBPF program will be re-run with + * the pointer for start of data pointing to byte number *bytes* + * **+ 1**. If *bytes* is larger than the current data being + * processed, then the eBPF verdict will be applied to multiple + * **sendmsg**\ () or **sendfile**\ () calls until *bytes* are + * consumed. + * + * Note that if a socket closes with the internal counter holding + * a non-zero value, this is not a problem because data is not + * being buffered for *bytes* and is sent as it is received. + * Return + * 0 + * + * long bpf_msg_cork_bytes(struct sk_msg_buff *msg, u32 bytes) + * Description + * For socket policies, prevent the execution of the verdict eBPF + * program for message *msg* until *bytes* (byte number) have been + * accumulated. + * + * This can be used when one needs a specific number of bytes + * before a verdict can be assigned, even if the data spans + * multiple **sendmsg**\ () or **sendfile**\ () calls. The extreme + * case would be a user calling **sendmsg**\ () repeatedly with + * 1-byte long message segments. Obviously, this is bad for + * performance, but it is still valid. If the eBPF program needs + * *bytes* bytes to validate a header, this helper can be used to + * prevent the eBPF program to be called again until *bytes* have + * been accumulated. + * Return + * 0 + * + * long bpf_msg_pull_data(struct sk_msg_buff *msg, u32 start, u32 end, u64 flags) + * Description + * For socket policies, pull in non-linear data from user space + * for *msg* and set pointers *msg*\ **->data** and *msg*\ + * **->data_end** to *start* and *end* bytes offsets into *msg*, + * respectively. + * + * If a program of type **BPF_PROG_TYPE_SK_MSG** is run on a + * *msg* it can only parse data that the (**data**, **data_end**) + * pointers have already consumed. For **sendmsg**\ () hooks this + * is likely the first scatterlist element. But for calls relying + * on the **sendpage** handler (e.g. **sendfile**\ ()) this will + * be the range (**0**, **0**) because the data is shared with + * user space and by default the objective is to avoid allowing + * user space to modify data while (or after) eBPF verdict is + * being decided. This helper can be used to pull in data and to + * set the start and end pointer to given values. Data will be + * copied if necessary (i.e. if data was not linear and if start + * and end pointers do not point to the same chunk). + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_bind(struct bpf_sock_addr *ctx, struct sockaddr *addr, int addr_len) + * Description + * Bind the socket associated to *ctx* to the address pointed by + * *addr*, of length *addr_len*. This allows for making outgoing + * connection from the desired IP address, which can be useful for + * example when all processes inside a cgroup should use one + * single IP address on a host that has multiple IP configured. + * + * This helper works for IPv4 and IPv6, TCP and UDP sockets. The + * domain (*addr*\ **->sa_family**) must be **AF_INET** (or + * **AF_INET6**). It's advised to pass zero port (**sin_port** + * or **sin6_port**) which triggers IP_BIND_ADDRESS_NO_PORT-like + * behavior and lets the kernel efficiently pick up an unused + * port as long as 4-tuple is unique. Passing non-zero port might + * lead to degraded performance. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_xdp_adjust_tail(struct xdp_buff *xdp_md, int delta) + * Description + * Adjust (move) *xdp_md*\ **->data_end** by *delta* bytes. It is + * possible to both shrink and grow the packet tail. + * Shrink done via *delta* being a negative integer. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_skb_get_xfrm_state(struct sk_buff *skb, u32 index, struct bpf_xfrm_state *xfrm_state, u32 size, u64 flags) + * Description + * Retrieve the XFRM state (IP transform framework, see also + * **ip-xfrm(8)**) at *index* in XFRM "security path" for *skb*. + * + * The retrieved value is stored in the **struct bpf_xfrm_state** + * pointed by *xfrm_state* and of length *size*. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * + * This helper is available only if the kernel was compiled with + * **CONFIG_XFRM** configuration option. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_get_stack(void *ctx, void *buf, u32 size, u64 flags) + * Description + * Return a user or a kernel stack in bpf program provided buffer. + * To achieve this, the helper needs *ctx*, which is a pointer + * to the context on which the tracing program is executed. + * To store the stacktrace, the bpf program provides *buf* with + * a nonnegative *size*. + * + * The last argument, *flags*, holds the number of stack frames to + * skip (from 0 to 255), masked with + * **BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set + * the following flags: + * + * **BPF_F_USER_STACK** + * Collect a user space stack instead of a kernel stack. + * **BPF_F_USER_BUILD_ID** + * Collect buildid+offset instead of ips for user stack, + * only valid if **BPF_F_USER_STACK** is also specified. + * + * **bpf_get_stack**\ () can collect up to + * **PERF_MAX_STACK_DEPTH** both kernel and user frames, subject + * to sufficient large buffer size. Note that + * this limit can be controlled with the **sysctl** program, and + * that it should be manually increased in order to profile long + * user stacks (such as stacks for Java programs). To do so, use: + * + * :: + * + * # sysctl kernel.perf_event_max_stack= + * Return + * A non-negative value equal to or less than *size* on success, + * or a negative error in case of failure. + * + * long bpf_skb_load_bytes_relative(const void *skb, u32 offset, void *to, u32 len, u32 start_header) + * Description + * This helper is similar to **bpf_skb_load_bytes**\ () in that + * it provides an easy way to load *len* bytes from *offset* + * from the packet associated to *skb*, into the buffer pointed + * by *to*. The difference to **bpf_skb_load_bytes**\ () is that + * a fifth argument *start_header* exists in order to select a + * base offset to start from. *start_header* can be one of: + * + * **BPF_HDR_START_MAC** + * Base offset to load data from is *skb*'s mac header. + * **BPF_HDR_START_NET** + * Base offset to load data from is *skb*'s network header. + * + * In general, "direct packet access" is the preferred method to + * access packet data, however, this helper is in particular useful + * in socket filters where *skb*\ **->data** does not always point + * to the start of the mac header and where "direct packet access" + * is not available. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_fib_lookup(void *ctx, struct bpf_fib_lookup *params, int plen, u32 flags) + * Description + * Do FIB lookup in kernel tables using parameters in *params*. + * If lookup is successful and result shows packet is to be + * forwarded, the neighbor tables are searched for the nexthop. + * If successful (ie., FIB lookup shows forwarding and nexthop + * is resolved), the nexthop address is returned in ipv4_dst + * or ipv6_dst based on family, smac is set to mac address of + * egress device, dmac is set to nexthop mac address, rt_metric + * is set to metric from route (IPv4/IPv6 only), and ifindex + * is set to the device index of the nexthop from the FIB lookup. + * + * *plen* argument is the size of the passed in struct. + * *flags* argument can be a combination of one or more of the + * following values: + * + * **BPF_FIB_LOOKUP_DIRECT** + * Do a direct table lookup vs full lookup using FIB + * rules. + * **BPF_FIB_LOOKUP_OUTPUT** + * Perform lookup from an egress perspective (default is + * ingress). + * + * *ctx* is either **struct xdp_md** for XDP programs or + * **struct sk_buff** tc cls_act programs. + * Return + * * < 0 if any input argument is invalid + * * 0 on success (packet is forwarded, nexthop neighbor exists) + * * > 0 one of **BPF_FIB_LKUP_RET_** codes explaining why the + * packet is not forwarded or needs assist from full stack + * + * If lookup fails with BPF_FIB_LKUP_RET_FRAG_NEEDED, then the MTU + * was exceeded and output params->mtu_result contains the MTU. + * + * long bpf_sock_hash_update(struct bpf_sock_ops *skops, struct bpf_map *map, void *key, u64 flags) + * Description + * Add an entry to, or update a sockhash *map* referencing sockets. + * The *skops* is used as a new value for the entry associated to + * *key*. *flags* is one of: + * + * **BPF_NOEXIST** + * The entry for *key* must not exist in the map. + * **BPF_EXIST** + * The entry for *key* must already exist in the map. + * **BPF_ANY** + * No condition on the existence of the entry for *key*. + * + * If the *map* has eBPF programs (parser and verdict), those will + * be inherited by the socket being added. If the socket is + * already attached to eBPF programs, this results in an error. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_msg_redirect_hash(struct sk_msg_buff *msg, struct bpf_map *map, void *key, u64 flags) + * Description + * This helper is used in programs implementing policies at the + * socket level. If the message *msg* is allowed to pass (i.e. if + * the verdict eBPF program returns **SK_PASS**), redirect it to + * the socket referenced by *map* (of type + * **BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and + * egress interfaces can be used for redirection. The + * **BPF_F_INGRESS** value in *flags* is used to make the + * distinction (ingress path is selected if the flag is present, + * egress path otherwise). This is the only flag supported for now. + * Return + * **SK_PASS** on success, or **SK_DROP** on error. + * + * long bpf_sk_redirect_hash(struct sk_buff *skb, struct bpf_map *map, void *key, u64 flags) + * Description + * This helper is used in programs implementing policies at the + * skb socket level. If the sk_buff *skb* is allowed to pass (i.e. + * if the verdict eBPF program returns **SK_PASS**), redirect it + * to the socket referenced by *map* (of type + * **BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and + * egress interfaces can be used for redirection. The + * **BPF_F_INGRESS** value in *flags* is used to make the + * distinction (ingress path is selected if the flag is present, + * egress otherwise). This is the only flag supported for now. + * Return + * **SK_PASS** on success, or **SK_DROP** on error. + * + * long bpf_lwt_push_encap(struct sk_buff *skb, u32 type, void *hdr, u32 len) + * Description + * Encapsulate the packet associated to *skb* within a Layer 3 + * protocol header. This header is provided in the buffer at + * address *hdr*, with *len* its size in bytes. *type* indicates + * the protocol of the header and can be one of: + * + * **BPF_LWT_ENCAP_SEG6** + * IPv6 encapsulation with Segment Routing Header + * (**struct ipv6_sr_hdr**). *hdr* only contains the SRH, + * the IPv6 header is computed by the kernel. + * **BPF_LWT_ENCAP_SEG6_INLINE** + * Only works if *skb* contains an IPv6 packet. Insert a + * Segment Routing Header (**struct ipv6_sr_hdr**) inside + * the IPv6 header. + * **BPF_LWT_ENCAP_IP** + * IP encapsulation (GRE/GUE/IPIP/etc). The outer header + * must be IPv4 or IPv6, followed by zero or more + * additional headers, up to **LWT_BPF_MAX_HEADROOM** + * total bytes in all prepended headers. Please note that + * if **skb_is_gso**\ (*skb*) is true, no more than two + * headers can be prepended, and the inner header, if + * present, should be either GRE or UDP/GUE. + * + * **BPF_LWT_ENCAP_SEG6**\ \* types can be called by BPF programs + * of type **BPF_PROG_TYPE_LWT_IN**; **BPF_LWT_ENCAP_IP** type can + * be called by bpf programs of types **BPF_PROG_TYPE_LWT_IN** and + * **BPF_PROG_TYPE_LWT_XMIT**. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_lwt_seg6_store_bytes(struct sk_buff *skb, u32 offset, const void *from, u32 len) + * Description + * Store *len* bytes from address *from* into the packet + * associated to *skb*, at *offset*. Only the flags, tag and TLVs + * inside the outermost IPv6 Segment Routing Header can be + * modified through this helper. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_lwt_seg6_adjust_srh(struct sk_buff *skb, u32 offset, s32 delta) + * Description + * Adjust the size allocated to TLVs in the outermost IPv6 + * Segment Routing Header contained in the packet associated to + * *skb*, at position *offset* by *delta* bytes. Only offsets + * after the segments are accepted. *delta* can be as well + * positive (growing) as negative (shrinking). + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_lwt_seg6_action(struct sk_buff *skb, u32 action, void *param, u32 param_len) + * Description + * Apply an IPv6 Segment Routing action of type *action* to the + * packet associated to *skb*. Each action takes a parameter + * contained at address *param*, and of length *param_len* bytes. + * *action* can be one of: + * + * **SEG6_LOCAL_ACTION_END_X** + * End.X action: Endpoint with Layer-3 cross-connect. + * Type of *param*: **struct in6_addr**. + * **SEG6_LOCAL_ACTION_END_T** + * End.T action: Endpoint with specific IPv6 table lookup. + * Type of *param*: **int**. + * **SEG6_LOCAL_ACTION_END_B6** + * End.B6 action: Endpoint bound to an SRv6 policy. + * Type of *param*: **struct ipv6_sr_hdr**. + * **SEG6_LOCAL_ACTION_END_B6_ENCAP** + * End.B6.Encap action: Endpoint bound to an SRv6 + * encapsulation policy. + * Type of *param*: **struct ipv6_sr_hdr**. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_rc_repeat(void *ctx) + * Description + * This helper is used in programs implementing IR decoding, to + * report a successfully decoded repeat key message. This delays + * the generation of a key up event for previously generated + * key down event. + * + * Some IR protocols like NEC have a special IR message for + * repeating last button, for when a button is held down. + * + * The *ctx* should point to the lirc sample as passed into + * the program. + * + * This helper is only available is the kernel was compiled with + * the **CONFIG_BPF_LIRC_MODE2** configuration option set to + * "**y**". + * Return + * 0 + * + * long bpf_rc_keydown(void *ctx, u32 protocol, u64 scancode, u32 toggle) + * Description + * This helper is used in programs implementing IR decoding, to + * report a successfully decoded key press with *scancode*, + * *toggle* value in the given *protocol*. The scancode will be + * translated to a keycode using the rc keymap, and reported as + * an input key down event. After a period a key up event is + * generated. This period can be extended by calling either + * **bpf_rc_keydown**\ () again with the same values, or calling + * **bpf_rc_repeat**\ (). + * + * Some protocols include a toggle bit, in case the button was + * released and pressed again between consecutive scancodes. + * + * The *ctx* should point to the lirc sample as passed into + * the program. + * + * The *protocol* is the decoded protocol number (see + * **enum rc_proto** for some predefined values). + * + * This helper is only available is the kernel was compiled with + * the **CONFIG_BPF_LIRC_MODE2** configuration option set to + * "**y**". + * Return + * 0 + * + * u64 bpf_skb_cgroup_id(struct sk_buff *skb) + * Description + * Return the cgroup v2 id of the socket associated with the *skb*. + * This is roughly similar to the **bpf_get_cgroup_classid**\ () + * helper for cgroup v1 by providing a tag resp. identifier that + * can be matched on or used for map lookups e.g. to implement + * policy. The cgroup v2 id of a given path in the hierarchy is + * exposed in user space through the f_handle API in order to get + * to the same 64-bit id. + * + * This helper can be used on TC egress path, but not on ingress, + * and is available only if the kernel was compiled with the + * **CONFIG_SOCK_CGROUP_DATA** configuration option. + * Return + * The id is returned or 0 in case the id could not be retrieved. + * + * u64 bpf_get_current_cgroup_id(void) + * Return + * A 64-bit integer containing the current cgroup id based + * on the cgroup within which the current task is running. + * + * void *bpf_get_local_storage(void *map, u64 flags) + * Description + * Get the pointer to the local storage area. + * The type and the size of the local storage is defined + * by the *map* argument. + * The *flags* meaning is specific for each map type, + * and has to be 0 for cgroup local storage. + * + * Depending on the BPF program type, a local storage area + * can be shared between multiple instances of the BPF program, + * running simultaneously. + * + * A user should care about the synchronization by himself. + * For example, by using the **BPF_ATOMIC** instructions to alter + * the shared data. + * Return + * A pointer to the local storage area. + * + * long bpf_sk_select_reuseport(struct sk_reuseport_md *reuse, struct bpf_map *map, void *key, u64 flags) + * Description + * Select a **SO_REUSEPORT** socket from a + * **BPF_MAP_TYPE_REUSEPORT_ARRAY** *map*. + * It checks the selected socket is matching the incoming + * request in the socket buffer. + * Return + * 0 on success, or a negative error in case of failure. + * + * u64 bpf_skb_ancestor_cgroup_id(struct sk_buff *skb, int ancestor_level) + * Description + * Return id of cgroup v2 that is ancestor of cgroup associated + * with the *skb* at the *ancestor_level*. The root cgroup is at + * *ancestor_level* zero and each step down the hierarchy + * increments the level. If *ancestor_level* == level of cgroup + * associated with *skb*, then return value will be same as that + * of **bpf_skb_cgroup_id**\ (). + * + * The helper is useful to implement policies based on cgroups + * that are upper in hierarchy than immediate cgroup associated + * with *skb*. + * + * The format of returned id and helper limitations are same as in + * **bpf_skb_cgroup_id**\ (). + * Return + * The id is returned or 0 in case the id could not be retrieved. + * + * struct bpf_sock *bpf_sk_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags) + * Description + * Look for TCP socket matching *tuple*, optionally in a child + * network namespace *netns*. The return value must be checked, + * and if non-**NULL**, released via **bpf_sk_release**\ (). + * + * The *ctx* should point to the context of the program, such as + * the skb or socket (depending on the hook in use). This is used + * to determine the base network namespace for the lookup. + * + * *tuple_size* must be one of: + * + * **sizeof**\ (*tuple*\ **->ipv4**) + * Look for an IPv4 socket. + * **sizeof**\ (*tuple*\ **->ipv6**) + * Look for an IPv6 socket. + * + * If the *netns* is a negative signed 32-bit integer, then the + * socket lookup table in the netns associated with the *ctx* + * will be used. For the TC hooks, this is the netns of the device + * in the skb. For socket hooks, this is the netns of the socket. + * If *netns* is any other signed 32-bit value greater than or + * equal to zero then it specifies the ID of the netns relative to + * the netns associated with the *ctx*. *netns* values beyond the + * range of 32-bit integers are reserved for future use. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * + * This helper is available only if the kernel was compiled with + * **CONFIG_NET** configuration option. + * Return + * Pointer to **struct bpf_sock**, or **NULL** in case of failure. + * For sockets with reuseport option, the **struct bpf_sock** + * result is from *reuse*\ **->socks**\ [] using the hash of the + * tuple. + * + * struct bpf_sock *bpf_sk_lookup_udp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags) + * Description + * Look for UDP socket matching *tuple*, optionally in a child + * network namespace *netns*. The return value must be checked, + * and if non-**NULL**, released via **bpf_sk_release**\ (). + * + * The *ctx* should point to the context of the program, such as + * the skb or socket (depending on the hook in use). This is used + * to determine the base network namespace for the lookup. + * + * *tuple_size* must be one of: + * + * **sizeof**\ (*tuple*\ **->ipv4**) + * Look for an IPv4 socket. + * **sizeof**\ (*tuple*\ **->ipv6**) + * Look for an IPv6 socket. + * + * If the *netns* is a negative signed 32-bit integer, then the + * socket lookup table in the netns associated with the *ctx* + * will be used. For the TC hooks, this is the netns of the device + * in the skb. For socket hooks, this is the netns of the socket. + * If *netns* is any other signed 32-bit value greater than or + * equal to zero then it specifies the ID of the netns relative to + * the netns associated with the *ctx*. *netns* values beyond the + * range of 32-bit integers are reserved for future use. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * + * This helper is available only if the kernel was compiled with + * **CONFIG_NET** configuration option. + * Return + * Pointer to **struct bpf_sock**, or **NULL** in case of failure. + * For sockets with reuseport option, the **struct bpf_sock** + * result is from *reuse*\ **->socks**\ [] using the hash of the + * tuple. + * + * long bpf_sk_release(void *sock) + * Description + * Release the reference held by *sock*. *sock* must be a + * non-**NULL** pointer that was returned from + * **bpf_sk_lookup_xxx**\ (). + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_map_push_elem(struct bpf_map *map, const void *value, u64 flags) + * Description + * Push an element *value* in *map*. *flags* is one of: + * + * **BPF_EXIST** + * If the queue/stack is full, the oldest element is + * removed to make room for this. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_map_pop_elem(struct bpf_map *map, void *value) + * Description + * Pop an element from *map*. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_map_peek_elem(struct bpf_map *map, void *value) + * Description + * Get an element from *map* without removing it. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_msg_push_data(struct sk_msg_buff *msg, u32 start, u32 len, u64 flags) + * Description + * For socket policies, insert *len* bytes into *msg* at offset + * *start*. + * + * If a program of type **BPF_PROG_TYPE_SK_MSG** is run on a + * *msg* it may want to insert metadata or options into the *msg*. + * This can later be read and used by any of the lower layer BPF + * hooks. + * + * This helper may fail if under memory pressure (a malloc + * fails) in these cases BPF programs will get an appropriate + * error and BPF programs will need to handle them. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_msg_pop_data(struct sk_msg_buff *msg, u32 start, u32 len, u64 flags) + * Description + * Will remove *len* bytes from a *msg* starting at byte *start*. + * This may result in **ENOMEM** errors under certain situations if + * an allocation and copy are required due to a full ring buffer. + * However, the helper will try to avoid doing the allocation + * if possible. Other errors can occur if input parameters are + * invalid either due to *start* byte not being valid part of *msg* + * payload and/or *pop* value being to large. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_rc_pointer_rel(void *ctx, s32 rel_x, s32 rel_y) + * Description + * This helper is used in programs implementing IR decoding, to + * report a successfully decoded pointer movement. + * + * The *ctx* should point to the lirc sample as passed into + * the program. + * + * This helper is only available is the kernel was compiled with + * the **CONFIG_BPF_LIRC_MODE2** configuration option set to + * "**y**". + * Return + * 0 + * + * long bpf_spin_lock(struct bpf_spin_lock *lock) + * Description + * Acquire a spinlock represented by the pointer *lock*, which is + * stored as part of a value of a map. Taking the lock allows to + * safely update the rest of the fields in that value. The + * spinlock can (and must) later be released with a call to + * **bpf_spin_unlock**\ (\ *lock*\ ). + * + * Spinlocks in BPF programs come with a number of restrictions + * and constraints: + * + * * **bpf_spin_lock** objects are only allowed inside maps of + * types **BPF_MAP_TYPE_HASH** and **BPF_MAP_TYPE_ARRAY** (this + * list could be extended in the future). + * * BTF description of the map is mandatory. + * * The BPF program can take ONE lock at a time, since taking two + * or more could cause dead locks. + * * Only one **struct bpf_spin_lock** is allowed per map element. + * * When the lock is taken, calls (either BPF to BPF or helpers) + * are not allowed. + * * The **BPF_LD_ABS** and **BPF_LD_IND** instructions are not + * allowed inside a spinlock-ed region. + * * The BPF program MUST call **bpf_spin_unlock**\ () to release + * the lock, on all execution paths, before it returns. + * * The BPF program can access **struct bpf_spin_lock** only via + * the **bpf_spin_lock**\ () and **bpf_spin_unlock**\ () + * helpers. Loading or storing data into the **struct + * bpf_spin_lock** *lock*\ **;** field of a map is not allowed. + * * To use the **bpf_spin_lock**\ () helper, the BTF description + * of the map value must be a struct and have **struct + * bpf_spin_lock** *anyname*\ **;** field at the top level. + * Nested lock inside another struct is not allowed. + * * The **struct bpf_spin_lock** *lock* field in a map value must + * be aligned on a multiple of 4 bytes in that value. + * * Syscall with command **BPF_MAP_LOOKUP_ELEM** does not copy + * the **bpf_spin_lock** field to user space. + * * Syscall with command **BPF_MAP_UPDATE_ELEM**, or update from + * a BPF program, do not update the **bpf_spin_lock** field. + * * **bpf_spin_lock** cannot be on the stack or inside a + * networking packet (it can only be inside of a map values). + * * **bpf_spin_lock** is available to root only. + * * Tracing programs and socket filter programs cannot use + * **bpf_spin_lock**\ () due to insufficient preemption checks + * (but this may change in the future). + * * **bpf_spin_lock** is not allowed in inner maps of map-in-map. + * Return + * 0 + * + * long bpf_spin_unlock(struct bpf_spin_lock *lock) + * Description + * Release the *lock* previously locked by a call to + * **bpf_spin_lock**\ (\ *lock*\ ). + * Return + * 0 + * + * struct bpf_sock *bpf_sk_fullsock(struct bpf_sock *sk) + * Description + * This helper gets a **struct bpf_sock** pointer such + * that all the fields in this **bpf_sock** can be accessed. + * Return + * A **struct bpf_sock** pointer on success, or **NULL** in + * case of failure. + * + * struct bpf_tcp_sock *bpf_tcp_sock(struct bpf_sock *sk) + * Description + * This helper gets a **struct bpf_tcp_sock** pointer from a + * **struct bpf_sock** pointer. + * Return + * A **struct bpf_tcp_sock** pointer on success, or **NULL** in + * case of failure. + * + * long bpf_skb_ecn_set_ce(struct sk_buff *skb) + * Description + * Set ECN (Explicit Congestion Notification) field of IP header + * to **CE** (Congestion Encountered) if current value is **ECT** + * (ECN Capable Transport). Otherwise, do nothing. Works with IPv6 + * and IPv4. + * Return + * 1 if the **CE** flag is set (either by the current helper call + * or because it was already present), 0 if it is not set. + * + * struct bpf_sock *bpf_get_listener_sock(struct bpf_sock *sk) + * Description + * Return a **struct bpf_sock** pointer in **TCP_LISTEN** state. + * **bpf_sk_release**\ () is unnecessary and not allowed. + * Return + * A **struct bpf_sock** pointer on success, or **NULL** in + * case of failure. + * + * struct bpf_sock *bpf_skc_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags) + * Description + * Look for TCP socket matching *tuple*, optionally in a child + * network namespace *netns*. The return value must be checked, + * and if non-**NULL**, released via **bpf_sk_release**\ (). + * + * This function is identical to **bpf_sk_lookup_tcp**\ (), except + * that it also returns timewait or request sockets. Use + * **bpf_sk_fullsock**\ () or **bpf_tcp_sock**\ () to access the + * full structure. + * + * This helper is available only if the kernel was compiled with + * **CONFIG_NET** configuration option. + * Return + * Pointer to **struct bpf_sock**, or **NULL** in case of failure. + * For sockets with reuseport option, the **struct bpf_sock** + * result is from *reuse*\ **->socks**\ [] using the hash of the + * tuple. + * + * long bpf_tcp_check_syncookie(void *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len) + * Description + * Check whether *iph* and *th* contain a valid SYN cookie ACK for + * the listening socket in *sk*. + * + * *iph* points to the start of the IPv4 or IPv6 header, while + * *iph_len* contains **sizeof**\ (**struct iphdr**) or + * **sizeof**\ (**struct ip6hdr**). + * + * *th* points to the start of the TCP header, while *th_len* + * contains **sizeof**\ (**struct tcphdr**). + * Return + * 0 if *iph* and *th* are a valid SYN cookie ACK, or a negative + * error otherwise. + * + * long bpf_sysctl_get_name(struct bpf_sysctl *ctx, char *buf, size_t buf_len, u64 flags) + * Description + * Get name of sysctl in /proc/sys/ and copy it into provided by + * program buffer *buf* of size *buf_len*. + * + * The buffer is always NUL terminated, unless it's zero-sized. + * + * If *flags* is zero, full name (e.g. "net/ipv4/tcp_mem") is + * copied. Use **BPF_F_SYSCTL_BASE_NAME** flag to copy base name + * only (e.g. "tcp_mem"). + * Return + * Number of character copied (not including the trailing NUL). + * + * **-E2BIG** if the buffer wasn't big enough (*buf* will contain + * truncated name in this case). + * + * long bpf_sysctl_get_current_value(struct bpf_sysctl *ctx, char *buf, size_t buf_len) + * Description + * Get current value of sysctl as it is presented in /proc/sys + * (incl. newline, etc), and copy it as a string into provided + * by program buffer *buf* of size *buf_len*. + * + * The whole value is copied, no matter what file position user + * space issued e.g. sys_read at. + * + * The buffer is always NUL terminated, unless it's zero-sized. + * Return + * Number of character copied (not including the trailing NUL). + * + * **-E2BIG** if the buffer wasn't big enough (*buf* will contain + * truncated name in this case). + * + * **-EINVAL** if current value was unavailable, e.g. because + * sysctl is uninitialized and read returns -EIO for it. + * + * long bpf_sysctl_get_new_value(struct bpf_sysctl *ctx, char *buf, size_t buf_len) + * Description + * Get new value being written by user space to sysctl (before + * the actual write happens) and copy it as a string into + * provided by program buffer *buf* of size *buf_len*. + * + * User space may write new value at file position > 0. + * + * The buffer is always NUL terminated, unless it's zero-sized. + * Return + * Number of character copied (not including the trailing NUL). + * + * **-E2BIG** if the buffer wasn't big enough (*buf* will contain + * truncated name in this case). + * + * **-EINVAL** if sysctl is being read. + * + * long bpf_sysctl_set_new_value(struct bpf_sysctl *ctx, const char *buf, size_t buf_len) + * Description + * Override new value being written by user space to sysctl with + * value provided by program in buffer *buf* of size *buf_len*. + * + * *buf* should contain a string in same form as provided by user + * space on sysctl write. + * + * User space may write new value at file position > 0. To override + * the whole sysctl value file position should be set to zero. + * Return + * 0 on success. + * + * **-E2BIG** if the *buf_len* is too big. + * + * **-EINVAL** if sysctl is being read. + * + * long bpf_strtol(const char *buf, size_t buf_len, u64 flags, long *res) + * Description + * Convert the initial part of the string from buffer *buf* of + * size *buf_len* to a long integer according to the given base + * and save the result in *res*. + * + * The string may begin with an arbitrary amount of white space + * (as determined by **isspace**\ (3)) followed by a single + * optional '**-**' sign. + * + * Five least significant bits of *flags* encode base, other bits + * are currently unused. + * + * Base must be either 8, 10, 16 or 0 to detect it automatically + * similar to user space **strtol**\ (3). + * Return + * Number of characters consumed on success. Must be positive but + * no more than *buf_len*. + * + * **-EINVAL** if no valid digits were found or unsupported base + * was provided. + * + * **-ERANGE** if resulting value was out of range. + * + * long bpf_strtoul(const char *buf, size_t buf_len, u64 flags, unsigned long *res) + * Description + * Convert the initial part of the string from buffer *buf* of + * size *buf_len* to an unsigned long integer according to the + * given base and save the result in *res*. + * + * The string may begin with an arbitrary amount of white space + * (as determined by **isspace**\ (3)). + * + * Five least significant bits of *flags* encode base, other bits + * are currently unused. + * + * Base must be either 8, 10, 16 or 0 to detect it automatically + * similar to user space **strtoul**\ (3). + * Return + * Number of characters consumed on success. Must be positive but + * no more than *buf_len*. + * + * **-EINVAL** if no valid digits were found or unsupported base + * was provided. + * + * **-ERANGE** if resulting value was out of range. + * + * void *bpf_sk_storage_get(struct bpf_map *map, void *sk, void *value, u64 flags) + * Description + * Get a bpf-local-storage from a *sk*. + * + * Logically, it could be thought of getting the value from + * a *map* with *sk* as the **key**. From this + * perspective, the usage is not much different from + * **bpf_map_lookup_elem**\ (*map*, **&**\ *sk*) except this + * helper enforces the key must be a full socket and the map must + * be a **BPF_MAP_TYPE_SK_STORAGE** also. + * + * Underneath, the value is stored locally at *sk* instead of + * the *map*. The *map* is used as the bpf-local-storage + * "type". The bpf-local-storage "type" (i.e. the *map*) is + * searched against all bpf-local-storages residing at *sk*. + * + * *sk* is a kernel **struct sock** pointer for LSM program. + * *sk* is a **struct bpf_sock** pointer for other program types. + * + * An optional *flags* (**BPF_SK_STORAGE_GET_F_CREATE**) can be + * used such that a new bpf-local-storage will be + * created if one does not exist. *value* can be used + * together with **BPF_SK_STORAGE_GET_F_CREATE** to specify + * the initial value of a bpf-local-storage. If *value* is + * **NULL**, the new bpf-local-storage will be zero initialized. + * Return + * A bpf-local-storage pointer is returned on success. + * + * **NULL** if not found or there was an error in adding + * a new bpf-local-storage. + * + * long bpf_sk_storage_delete(struct bpf_map *map, void *sk) + * Description + * Delete a bpf-local-storage from a *sk*. + * Return + * 0 on success. + * + * **-ENOENT** if the bpf-local-storage cannot be found. + * **-EINVAL** if sk is not a fullsock (e.g. a request_sock). + * + * long bpf_send_signal(u32 sig) + * Description + * Send signal *sig* to the process of the current task. + * The signal may be delivered to any of this process's threads. + * Return + * 0 on success or successfully queued. + * + * **-EBUSY** if work queue under nmi is full. + * + * **-EINVAL** if *sig* is invalid. + * + * **-EPERM** if no permission to send the *sig*. + * + * **-EAGAIN** if bpf program can try again. + * + * s64 bpf_tcp_gen_syncookie(void *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len) + * Description + * Try to issue a SYN cookie for the packet with corresponding + * IP/TCP headers, *iph* and *th*, on the listening socket in *sk*. + * + * *iph* points to the start of the IPv4 or IPv6 header, while + * *iph_len* contains **sizeof**\ (**struct iphdr**) or + * **sizeof**\ (**struct ip6hdr**). + * + * *th* points to the start of the TCP header, while *th_len* + * contains the length of the TCP header. + * Return + * On success, lower 32 bits hold the generated SYN cookie in + * followed by 16 bits which hold the MSS value for that cookie, + * and the top 16 bits are unused. + * + * On failure, the returned value is one of the following: + * + * **-EINVAL** SYN cookie cannot be issued due to error + * + * **-ENOENT** SYN cookie should not be issued (no SYN flood) + * + * **-EOPNOTSUPP** kernel configuration does not enable SYN cookies + * + * **-EPROTONOSUPPORT** IP packet version is not 4 or 6 + * + * long bpf_skb_output(void *ctx, struct bpf_map *map, u64 flags, void *data, u64 size) + * Description + * Write raw *data* blob into a special BPF perf event held by + * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. This perf + * event must have the following attributes: **PERF_SAMPLE_RAW** + * as **sample_type**, **PERF_TYPE_SOFTWARE** as **type**, and + * **PERF_COUNT_SW_BPF_OUTPUT** as **config**. + * + * The *flags* are used to indicate the index in *map* for which + * the value must be put, masked with **BPF_F_INDEX_MASK**. + * Alternatively, *flags* can be set to **BPF_F_CURRENT_CPU** + * to indicate that the index of the current CPU core should be + * used. + * + * The value to write, of *size*, is passed through eBPF stack and + * pointed by *data*. + * + * *ctx* is a pointer to in-kernel struct sk_buff. + * + * This helper is similar to **bpf_perf_event_output**\ () but + * restricted to raw_tracepoint bpf programs. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_probe_read_user(void *dst, u32 size, const void *unsafe_ptr) + * Description + * Safely attempt to read *size* bytes from user space address + * *unsafe_ptr* and store the data in *dst*. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_probe_read_kernel(void *dst, u32 size, const void *unsafe_ptr) + * Description + * Safely attempt to read *size* bytes from kernel space address + * *unsafe_ptr* and store the data in *dst*. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_probe_read_user_str(void *dst, u32 size, const void *unsafe_ptr) + * Description + * Copy a NUL terminated string from an unsafe user address + * *unsafe_ptr* to *dst*. The *size* should include the + * terminating NUL byte. In case the string length is smaller than + * *size*, the target is not padded with further NUL bytes. If the + * string length is larger than *size*, just *size*-1 bytes are + * copied and the last byte is set to NUL. + * + * On success, returns the number of bytes that were written, + * including the terminal NUL. This makes this helper useful in + * tracing programs for reading strings, and more importantly to + * get its length at runtime. See the following snippet: + * + * :: + * + * SEC("kprobe/sys_open") + * void bpf_sys_open(struct pt_regs *ctx) + * { + * char buf[PATHLEN]; // PATHLEN is defined to 256 + * int res = bpf_probe_read_user_str(buf, sizeof(buf), + * ctx->di); + * + * // Consume buf, for example push it to + * // userspace via bpf_perf_event_output(); we + * // can use res (the string length) as event + * // size, after checking its boundaries. + * } + * + * In comparison, using **bpf_probe_read_user**\ () helper here + * instead to read the string would require to estimate the length + * at compile time, and would often result in copying more memory + * than necessary. + * + * Another useful use case is when parsing individual process + * arguments or individual environment variables navigating + * *current*\ **->mm->arg_start** and *current*\ + * **->mm->env_start**: using this helper and the return value, + * one can quickly iterate at the right offset of the memory area. + * Return + * On success, the strictly positive length of the output string, + * including the trailing NUL character. On error, a negative + * value. + * + * long bpf_probe_read_kernel_str(void *dst, u32 size, const void *unsafe_ptr) + * Description + * Copy a NUL terminated string from an unsafe kernel address *unsafe_ptr* + * to *dst*. Same semantics as with **bpf_probe_read_user_str**\ () apply. + * Return + * On success, the strictly positive length of the string, including + * the trailing NUL character. On error, a negative value. + * + * long bpf_tcp_send_ack(void *tp, u32 rcv_nxt) + * Description + * Send out a tcp-ack. *tp* is the in-kernel struct **tcp_sock**. + * *rcv_nxt* is the ack_seq to be sent out. + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_send_signal_thread(u32 sig) + * Description + * Send signal *sig* to the thread corresponding to the current task. + * Return + * 0 on success or successfully queued. + * + * **-EBUSY** if work queue under nmi is full. + * + * **-EINVAL** if *sig* is invalid. + * + * **-EPERM** if no permission to send the *sig*. + * + * **-EAGAIN** if bpf program can try again. + * + * u64 bpf_jiffies64(void) + * Description + * Obtain the 64bit jiffies + * Return + * The 64 bit jiffies + * + * long bpf_read_branch_records(struct bpf_perf_event_data *ctx, void *buf, u32 size, u64 flags) + * Description + * For an eBPF program attached to a perf event, retrieve the + * branch records (**struct perf_branch_entry**) associated to *ctx* + * and store it in the buffer pointed by *buf* up to size + * *size* bytes. + * Return + * On success, number of bytes written to *buf*. On error, a + * negative value. + * + * The *flags* can be set to **BPF_F_GET_BRANCH_RECORDS_SIZE** to + * instead return the number of bytes required to store all the + * branch entries. If this flag is set, *buf* may be NULL. + * + * **-EINVAL** if arguments invalid or **size** not a multiple + * of **sizeof**\ (**struct perf_branch_entry**\ ). + * + * **-ENOENT** if architecture does not support branch records. + * + * long bpf_get_ns_current_pid_tgid(u64 dev, u64 ino, struct bpf_pidns_info *nsdata, u32 size) + * Description + * Returns 0 on success, values for *pid* and *tgid* as seen from the current + * *namespace* will be returned in *nsdata*. + * Return + * 0 on success, or one of the following in case of failure: + * + * **-EINVAL** if dev and inum supplied don't match dev_t and inode number + * with nsfs of current task, or if dev conversion to dev_t lost high bits. + * + * **-ENOENT** if pidns does not exists for the current task. + * + * long bpf_xdp_output(void *ctx, struct bpf_map *map, u64 flags, void *data, u64 size) + * Description + * Write raw *data* blob into a special BPF perf event held by + * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. This perf + * event must have the following attributes: **PERF_SAMPLE_RAW** + * as **sample_type**, **PERF_TYPE_SOFTWARE** as **type**, and + * **PERF_COUNT_SW_BPF_OUTPUT** as **config**. + * + * The *flags* are used to indicate the index in *map* for which + * the value must be put, masked with **BPF_F_INDEX_MASK**. + * Alternatively, *flags* can be set to **BPF_F_CURRENT_CPU** + * to indicate that the index of the current CPU core should be + * used. + * + * The value to write, of *size*, is passed through eBPF stack and + * pointed by *data*. + * + * *ctx* is a pointer to in-kernel struct xdp_buff. + * + * This helper is similar to **bpf_perf_eventoutput**\ () but + * restricted to raw_tracepoint bpf programs. + * Return + * 0 on success, or a negative error in case of failure. + * + * u64 bpf_get_netns_cookie(void *ctx) + * Description + * Retrieve the cookie (generated by the kernel) of the network + * namespace the input *ctx* is associated with. The network + * namespace cookie remains stable for its lifetime and provides + * a global identifier that can be assumed unique. If *ctx* is + * NULL, then the helper returns the cookie for the initial + * network namespace. The cookie itself is very similar to that + * of **bpf_get_socket_cookie**\ () helper, but for network + * namespaces instead of sockets. + * Return + * A 8-byte long opaque number. + * + * u64 bpf_get_current_ancestor_cgroup_id(int ancestor_level) + * Description + * Return id of cgroup v2 that is ancestor of the cgroup associated + * with the current task at the *ancestor_level*. The root cgroup + * is at *ancestor_level* zero and each step down the hierarchy + * increments the level. If *ancestor_level* == level of cgroup + * associated with the current task, then return value will be the + * same as that of **bpf_get_current_cgroup_id**\ (). + * + * The helper is useful to implement policies based on cgroups + * that are upper in hierarchy than immediate cgroup associated + * with the current task. + * + * The format of returned id and helper limitations are same as in + * **bpf_get_current_cgroup_id**\ (). + * Return + * The id is returned or 0 in case the id could not be retrieved. + * + * long bpf_sk_assign(struct sk_buff *skb, void *sk, u64 flags) + * Description + * Helper is overloaded depending on BPF program type. This + * description applies to **BPF_PROG_TYPE_SCHED_CLS** and + * **BPF_PROG_TYPE_SCHED_ACT** programs. + * + * Assign the *sk* to the *skb*. When combined with appropriate + * routing configuration to receive the packet towards the socket, + * will cause *skb* to be delivered to the specified socket. + * Subsequent redirection of *skb* via **bpf_redirect**\ (), + * **bpf_clone_redirect**\ () or other methods outside of BPF may + * interfere with successful delivery to the socket. + * + * This operation is only valid from TC ingress path. + * + * The *flags* argument must be zero. + * Return + * 0 on success, or a negative error in case of failure: + * + * **-EINVAL** if specified *flags* are not supported. + * + * **-ENOENT** if the socket is unavailable for assignment. + * + * **-ENETUNREACH** if the socket is unreachable (wrong netns). + * + * **-EOPNOTSUPP** if the operation is not supported, for example + * a call from outside of TC ingress. + * + * **-ESOCKTNOSUPPORT** if the socket type is not supported + * (reuseport). + * + * long bpf_sk_assign(struct bpf_sk_lookup *ctx, struct bpf_sock *sk, u64 flags) + * Description + * Helper is overloaded depending on BPF program type. This + * description applies to **BPF_PROG_TYPE_SK_LOOKUP** programs. + * + * Select the *sk* as a result of a socket lookup. + * + * For the operation to succeed passed socket must be compatible + * with the packet description provided by the *ctx* object. + * + * L4 protocol (**IPPROTO_TCP** or **IPPROTO_UDP**) must + * be an exact match. While IP family (**AF_INET** or + * **AF_INET6**) must be compatible, that is IPv6 sockets + * that are not v6-only can be selected for IPv4 packets. + * + * Only TCP listeners and UDP unconnected sockets can be + * selected. *sk* can also be NULL to reset any previous + * selection. + * + * *flags* argument can combination of following values: + * + * * **BPF_SK_LOOKUP_F_REPLACE** to override the previous + * socket selection, potentially done by a BPF program + * that ran before us. + * + * * **BPF_SK_LOOKUP_F_NO_REUSEPORT** to skip + * load-balancing within reuseport group for the socket + * being selected. + * + * On success *ctx->sk* will point to the selected socket. + * + * Return + * 0 on success, or a negative errno in case of failure. + * + * * **-EAFNOSUPPORT** if socket family (*sk->family*) is + * not compatible with packet family (*ctx->family*). + * + * * **-EEXIST** if socket has been already selected, + * potentially by another program, and + * **BPF_SK_LOOKUP_F_REPLACE** flag was not specified. + * + * * **-EINVAL** if unsupported flags were specified. + * + * * **-EPROTOTYPE** if socket L4 protocol + * (*sk->protocol*) doesn't match packet protocol + * (*ctx->protocol*). + * + * * **-ESOCKTNOSUPPORT** if socket is not in allowed + * state (TCP listening or UDP unconnected). + * + * u64 bpf_ktime_get_boot_ns(void) + * Description + * Return the time elapsed since system boot, in nanoseconds. + * Does include the time the system was suspended. + * See: **clock_gettime**\ (**CLOCK_BOOTTIME**) + * Return + * Current *ktime*. + * + * long bpf_seq_printf(struct seq_file *m, const char *fmt, u32 fmt_size, const void *data, u32 data_len) + * Description + * **bpf_seq_printf**\ () uses seq_file **seq_printf**\ () to print + * out the format string. + * The *m* represents the seq_file. The *fmt* and *fmt_size* are for + * the format string itself. The *data* and *data_len* are format string + * arguments. The *data* are a **u64** array and corresponding format string + * values are stored in the array. For strings and pointers where pointees + * are accessed, only the pointer values are stored in the *data* array. + * The *data_len* is the size of *data* in bytes. + * + * Formats **%s**, **%p{i,I}{4,6}** requires to read kernel memory. + * Reading kernel memory may fail due to either invalid address or + * valid address but requiring a major memory fault. If reading kernel memory + * fails, the string for **%s** will be an empty string, and the ip + * address for **%p{i,I}{4,6}** will be 0. Not returning error to + * bpf program is consistent with what **bpf_trace_printk**\ () does for now. + * Return + * 0 on success, or a negative error in case of failure: + * + * **-EBUSY** if per-CPU memory copy buffer is busy, can try again + * by returning 1 from bpf program. + * + * **-EINVAL** if arguments are invalid, or if *fmt* is invalid/unsupported. + * + * **-E2BIG** if *fmt* contains too many format specifiers. + * + * **-EOVERFLOW** if an overflow happened: The same object will be tried again. + * + * long bpf_seq_write(struct seq_file *m, const void *data, u32 len) + * Description + * **bpf_seq_write**\ () uses seq_file **seq_write**\ () to write the data. + * The *m* represents the seq_file. The *data* and *len* represent the + * data to write in bytes. + * Return + * 0 on success, or a negative error in case of failure: + * + * **-EOVERFLOW** if an overflow happened: The same object will be tried again. + * + * u64 bpf_sk_cgroup_id(void *sk) + * Description + * Return the cgroup v2 id of the socket *sk*. + * + * *sk* must be a non-**NULL** pointer to a socket, e.g. one + * returned from **bpf_sk_lookup_xxx**\ (), + * **bpf_sk_fullsock**\ (), etc. The format of returned id is + * same as in **bpf_skb_cgroup_id**\ (). + * + * This helper is available only if the kernel was compiled with + * the **CONFIG_SOCK_CGROUP_DATA** configuration option. + * Return + * The id is returned or 0 in case the id could not be retrieved. + * + * u64 bpf_sk_ancestor_cgroup_id(void *sk, int ancestor_level) + * Description + * Return id of cgroup v2 that is ancestor of cgroup associated + * with the *sk* at the *ancestor_level*. The root cgroup is at + * *ancestor_level* zero and each step down the hierarchy + * increments the level. If *ancestor_level* == level of cgroup + * associated with *sk*, then return value will be same as that + * of **bpf_sk_cgroup_id**\ (). + * + * The helper is useful to implement policies based on cgroups + * that are upper in hierarchy than immediate cgroup associated + * with *sk*. + * + * The format of returned id and helper limitations are same as in + * **bpf_sk_cgroup_id**\ (). + * Return + * The id is returned or 0 in case the id could not be retrieved. + * + * long bpf_ringbuf_output(void *ringbuf, void *data, u64 size, u64 flags) + * Description + * Copy *size* bytes from *data* into a ring buffer *ringbuf*. + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. + * Return + * 0 on success, or a negative error in case of failure. + * + * void *bpf_ringbuf_reserve(void *ringbuf, u64 size, u64 flags) + * Description + * Reserve *size* bytes of payload in a ring buffer *ringbuf*. + * Return + * Valid pointer with *size* bytes of memory available; NULL, + * otherwise. + * + * void bpf_ringbuf_submit(void *data, u64 flags) + * Description + * Submit reserved ring buffer sample, pointed to by *data*. + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. + * Return + * Nothing. Always succeeds. + * + * void bpf_ringbuf_discard(void *data, u64 flags) + * Description + * Discard reserved ring buffer sample, pointed to by *data*. + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. + * Return + * Nothing. Always succeeds. + * + * u64 bpf_ringbuf_query(void *ringbuf, u64 flags) + * Description + * Query various characteristics of provided ring buffer. What + * exactly is queries is determined by *flags*: + * + * * **BPF_RB_AVAIL_DATA**: Amount of data not yet consumed. + * * **BPF_RB_RING_SIZE**: The size of ring buffer. + * * **BPF_RB_CONS_POS**: Consumer position (can wrap around). + * * **BPF_RB_PROD_POS**: Producer(s) position (can wrap around). + * + * Data returned is just a momentary snapshot of actual values + * and could be inaccurate, so this facility should be used to + * power heuristics and for reporting, not to make 100% correct + * calculation. + * Return + * Requested value, or 0, if *flags* are not recognized. + * + * long bpf_csum_level(struct sk_buff *skb, u64 level) + * Description + * Change the skbs checksum level by one layer up or down, or + * reset it entirely to none in order to have the stack perform + * checksum validation. The level is applicable to the following + * protocols: TCP, UDP, GRE, SCTP, FCOE. For example, a decap of + * | ETH | IP | UDP | GUE | IP | TCP | into | ETH | IP | TCP | + * through **bpf_skb_adjust_room**\ () helper with passing in + * **BPF_F_ADJ_ROOM_NO_CSUM_RESET** flag would require one call + * to **bpf_csum_level**\ () with **BPF_CSUM_LEVEL_DEC** since + * the UDP header is removed. Similarly, an encap of the latter + * into the former could be accompanied by a helper call to + * **bpf_csum_level**\ () with **BPF_CSUM_LEVEL_INC** if the + * skb is still intended to be processed in higher layers of the + * stack instead of just egressing at tc. + * + * There are three supported level settings at this time: + * + * * **BPF_CSUM_LEVEL_INC**: Increases skb->csum_level for skbs + * with CHECKSUM_UNNECESSARY. + * * **BPF_CSUM_LEVEL_DEC**: Decreases skb->csum_level for skbs + * with CHECKSUM_UNNECESSARY. + * * **BPF_CSUM_LEVEL_RESET**: Resets skb->csum_level to 0 and + * sets CHECKSUM_NONE to force checksum validation by the stack. + * * **BPF_CSUM_LEVEL_QUERY**: No-op, returns the current + * skb->csum_level. + * Return + * 0 on success, or a negative error in case of failure. In the + * case of **BPF_CSUM_LEVEL_QUERY**, the current skb->csum_level + * is returned or the error code -EACCES in case the skb is not + * subject to CHECKSUM_UNNECESSARY. + * + * struct tcp6_sock *bpf_skc_to_tcp6_sock(void *sk) + * Description + * Dynamically cast a *sk* pointer to a *tcp6_sock* pointer. + * Return + * *sk* if casting is valid, or **NULL** otherwise. + * + * struct tcp_sock *bpf_skc_to_tcp_sock(void *sk) + * Description + * Dynamically cast a *sk* pointer to a *tcp_sock* pointer. + * Return + * *sk* if casting is valid, or **NULL** otherwise. + * + * struct tcp_timewait_sock *bpf_skc_to_tcp_timewait_sock(void *sk) + * Description + * Dynamically cast a *sk* pointer to a *tcp_timewait_sock* pointer. + * Return + * *sk* if casting is valid, or **NULL** otherwise. + * + * struct tcp_request_sock *bpf_skc_to_tcp_request_sock(void *sk) + * Description + * Dynamically cast a *sk* pointer to a *tcp_request_sock* pointer. + * Return + * *sk* if casting is valid, or **NULL** otherwise. + * + * struct udp6_sock *bpf_skc_to_udp6_sock(void *sk) + * Description + * Dynamically cast a *sk* pointer to a *udp6_sock* pointer. + * Return + * *sk* if casting is valid, or **NULL** otherwise. + * + * long bpf_get_task_stack(struct task_struct *task, void *buf, u32 size, u64 flags) + * Description + * Return a user or a kernel stack in bpf program provided buffer. + * To achieve this, the helper needs *task*, which is a valid + * pointer to **struct task_struct**. To store the stacktrace, the + * bpf program provides *buf* with a nonnegative *size*. + * + * The last argument, *flags*, holds the number of stack frames to + * skip (from 0 to 255), masked with + * **BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set + * the following flags: + * + * **BPF_F_USER_STACK** + * Collect a user space stack instead of a kernel stack. + * **BPF_F_USER_BUILD_ID** + * Collect buildid+offset instead of ips for user stack, + * only valid if **BPF_F_USER_STACK** is also specified. + * + * **bpf_get_task_stack**\ () can collect up to + * **PERF_MAX_STACK_DEPTH** both kernel and user frames, subject + * to sufficient large buffer size. Note that + * this limit can be controlled with the **sysctl** program, and + * that it should be manually increased in order to profile long + * user stacks (such as stacks for Java programs). To do so, use: + * + * :: + * + * # sysctl kernel.perf_event_max_stack= + * Return + * A non-negative value equal to or less than *size* on success, + * or a negative error in case of failure. + * + * long bpf_load_hdr_opt(struct bpf_sock_ops *skops, void *searchby_res, u32 len, u64 flags) + * Description + * Load header option. Support reading a particular TCP header + * option for bpf program (**BPF_PROG_TYPE_SOCK_OPS**). + * + * If *flags* is 0, it will search the option from the + * *skops*\ **->skb_data**. The comment in **struct bpf_sock_ops** + * has details on what skb_data contains under different + * *skops*\ **->op**. + * + * The first byte of the *searchby_res* specifies the + * kind that it wants to search. + * + * If the searching kind is an experimental kind + * (i.e. 253 or 254 according to RFC6994). It also + * needs to specify the "magic" which is either + * 2 bytes or 4 bytes. It then also needs to + * specify the size of the magic by using + * the 2nd byte which is "kind-length" of a TCP + * header option and the "kind-length" also + * includes the first 2 bytes "kind" and "kind-length" + * itself as a normal TCP header option also does. + * + * For example, to search experimental kind 254 with + * 2 byte magic 0xeB9F, the searchby_res should be + * [ 254, 4, 0xeB, 0x9F, 0, 0, .... 0 ]. + * + * To search for the standard window scale option (3), + * the *searchby_res* should be [ 3, 0, 0, .... 0 ]. + * Note, kind-length must be 0 for regular option. + * + * Searching for No-Op (0) and End-of-Option-List (1) are + * not supported. + * + * *len* must be at least 2 bytes which is the minimal size + * of a header option. + * + * Supported flags: + * + * * **BPF_LOAD_HDR_OPT_TCP_SYN** to search from the + * saved_syn packet or the just-received syn packet. + * + * Return + * > 0 when found, the header option is copied to *searchby_res*. + * The return value is the total length copied. On failure, a + * negative error code is returned: + * + * **-EINVAL** if a parameter is invalid. + * + * **-ENOMSG** if the option is not found. + * + * **-ENOENT** if no syn packet is available when + * **BPF_LOAD_HDR_OPT_TCP_SYN** is used. + * + * **-ENOSPC** if there is not enough space. Only *len* number of + * bytes are copied. + * + * **-EFAULT** on failure to parse the header options in the + * packet. + * + * **-EPERM** if the helper cannot be used under the current + * *skops*\ **->op**. + * + * long bpf_store_hdr_opt(struct bpf_sock_ops *skops, const void *from, u32 len, u64 flags) + * Description + * Store header option. The data will be copied + * from buffer *from* with length *len* to the TCP header. + * + * The buffer *from* should have the whole option that + * includes the kind, kind-length, and the actual + * option data. The *len* must be at least kind-length + * long. The kind-length does not have to be 4 byte + * aligned. The kernel will take care of the padding + * and setting the 4 bytes aligned value to th->doff. + * + * This helper will check for duplicated option + * by searching the same option in the outgoing skb. + * + * This helper can only be called during + * **BPF_SOCK_OPS_WRITE_HDR_OPT_CB**. + * + * Return + * 0 on success, or negative error in case of failure: + * + * **-EINVAL** If param is invalid. + * + * **-ENOSPC** if there is not enough space in the header. + * Nothing has been written + * + * **-EEXIST** if the option already exists. + * + * **-EFAULT** on failrue to parse the existing header options. + * + * **-EPERM** if the helper cannot be used under the current + * *skops*\ **->op**. + * + * long bpf_reserve_hdr_opt(struct bpf_sock_ops *skops, u32 len, u64 flags) + * Description + * Reserve *len* bytes for the bpf header option. The + * space will be used by **bpf_store_hdr_opt**\ () later in + * **BPF_SOCK_OPS_WRITE_HDR_OPT_CB**. + * + * If **bpf_reserve_hdr_opt**\ () is called multiple times, + * the total number of bytes will be reserved. + * + * This helper can only be called during + * **BPF_SOCK_OPS_HDR_OPT_LEN_CB**. + * + * Return + * 0 on success, or negative error in case of failure: + * + * **-EINVAL** if a parameter is invalid. + * + * **-ENOSPC** if there is not enough space in the header. + * + * **-EPERM** if the helper cannot be used under the current + * *skops*\ **->op**. + * + * void *bpf_inode_storage_get(struct bpf_map *map, void *inode, void *value, u64 flags) + * Description + * Get a bpf_local_storage from an *inode*. + * + * Logically, it could be thought of as getting the value from + * a *map* with *inode* as the **key**. From this + * perspective, the usage is not much different from + * **bpf_map_lookup_elem**\ (*map*, **&**\ *inode*) except this + * helper enforces the key must be an inode and the map must also + * be a **BPF_MAP_TYPE_INODE_STORAGE**. + * + * Underneath, the value is stored locally at *inode* instead of + * the *map*. The *map* is used as the bpf-local-storage + * "type". The bpf-local-storage "type" (i.e. the *map*) is + * searched against all bpf_local_storage residing at *inode*. + * + * An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be + * used such that a new bpf_local_storage will be + * created if one does not exist. *value* can be used + * together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify + * the initial value of a bpf_local_storage. If *value* is + * **NULL**, the new bpf_local_storage will be zero initialized. + * Return + * A bpf_local_storage pointer is returned on success. + * + * **NULL** if not found or there was an error in adding + * a new bpf_local_storage. + * + * int bpf_inode_storage_delete(struct bpf_map *map, void *inode) + * Description + * Delete a bpf_local_storage from an *inode*. + * Return + * 0 on success. + * + * **-ENOENT** if the bpf_local_storage cannot be found. + * + * long bpf_d_path(struct path *path, char *buf, u32 sz) + * Description + * Return full path for given **struct path** object, which + * needs to be the kernel BTF *path* object. The path is + * returned in the provided buffer *buf* of size *sz* and + * is zero terminated. + * + * Return + * On success, the strictly positive length of the string, + * including the trailing NUL character. On error, a negative + * value. + * + * long bpf_copy_from_user(void *dst, u32 size, const void *user_ptr) + * Description + * Read *size* bytes from user space address *user_ptr* and store + * the data in *dst*. This is a wrapper of **copy_from_user**\ (). + * Return + * 0 on success, or a negative error in case of failure. + * + * long bpf_snprintf_btf(char *str, u32 str_size, struct btf_ptr *ptr, u32 btf_ptr_size, u64 flags) + * Description + * Use BTF to store a string representation of *ptr*->ptr in *str*, + * using *ptr*->type_id. This value should specify the type + * that *ptr*->ptr points to. LLVM __builtin_btf_type_id(type, 1) + * can be used to look up vmlinux BTF type ids. Traversing the + * data structure using BTF, the type information and values are + * stored in the first *str_size* - 1 bytes of *str*. Safe copy of + * the pointer data is carried out to avoid kernel crashes during + * operation. Smaller types can use string space on the stack; + * larger programs can use map data to store the string + * representation. + * + * The string can be subsequently shared with userspace via + * bpf_perf_event_output() or ring buffer interfaces. + * bpf_trace_printk() is to be avoided as it places too small + * a limit on string size to be useful. + * + * *flags* is a combination of + * + * **BTF_F_COMPACT** + * no formatting around type information + * **BTF_F_NONAME** + * no struct/union member names/types + * **BTF_F_PTR_RAW** + * show raw (unobfuscated) pointer values; + * equivalent to printk specifier %px. + * **BTF_F_ZERO** + * show zero-valued struct/union members; they + * are not displayed by default + * + * Return + * The number of bytes that were written (or would have been + * written if output had to be truncated due to string size), + * or a negative error in cases of failure. + * + * long bpf_seq_printf_btf(struct seq_file *m, struct btf_ptr *ptr, u32 ptr_size, u64 flags) + * Description + * Use BTF to write to seq_write a string representation of + * *ptr*->ptr, using *ptr*->type_id as per bpf_snprintf_btf(). + * *flags* are identical to those used for bpf_snprintf_btf. + * Return + * 0 on success or a negative error in case of failure. + * + * u64 bpf_skb_cgroup_classid(struct sk_buff *skb) + * Description + * See **bpf_get_cgroup_classid**\ () for the main description. + * This helper differs from **bpf_get_cgroup_classid**\ () in that + * the cgroup v1 net_cls class is retrieved only from the *skb*'s + * associated socket instead of the current process. + * Return + * The id is returned or 0 in case the id could not be retrieved. + * + * long bpf_redirect_neigh(u32 ifindex, struct bpf_redir_neigh *params, int plen, u64 flags) + * Description + * Redirect the packet to another net device of index *ifindex* + * and fill in L2 addresses from neighboring subsystem. This helper + * is somewhat similar to **bpf_redirect**\ (), except that it + * populates L2 addresses as well, meaning, internally, the helper + * relies on the neighbor lookup for the L2 address of the nexthop. + * + * The helper will perform a FIB lookup based on the skb's + * networking header to get the address of the next hop, unless + * this is supplied by the caller in the *params* argument. The + * *plen* argument indicates the len of *params* and should be set + * to 0 if *params* is NULL. + * + * The *flags* argument is reserved and must be 0. The helper is + * currently only supported for tc BPF program types, and enabled + * for IPv4 and IPv6 protocols. + * Return + * The helper returns **TC_ACT_REDIRECT** on success or + * **TC_ACT_SHOT** on error. + * + * void *bpf_per_cpu_ptr(const void *percpu_ptr, u32 cpu) + * Description + * Take a pointer to a percpu ksym, *percpu_ptr*, and return a + * pointer to the percpu kernel variable on *cpu*. A ksym is an + * extern variable decorated with '__ksym'. For ksym, there is a + * global var (either static or global) defined of the same name + * in the kernel. The ksym is percpu if the global var is percpu. + * The returned pointer points to the global percpu var on *cpu*. + * + * bpf_per_cpu_ptr() has the same semantic as per_cpu_ptr() in the + * kernel, except that bpf_per_cpu_ptr() may return NULL. This + * happens if *cpu* is larger than nr_cpu_ids. The caller of + * bpf_per_cpu_ptr() must check the returned value. + * Return + * A pointer pointing to the kernel percpu variable on *cpu*, or + * NULL, if *cpu* is invalid. + * + * void *bpf_this_cpu_ptr(const void *percpu_ptr) + * Description + * Take a pointer to a percpu ksym, *percpu_ptr*, and return a + * pointer to the percpu kernel variable on this cpu. See the + * description of 'ksym' in **bpf_per_cpu_ptr**\ (). + * + * bpf_this_cpu_ptr() has the same semantic as this_cpu_ptr() in + * the kernel. Different from **bpf_per_cpu_ptr**\ (), it would + * never return NULL. + * Return + * A pointer pointing to the kernel percpu variable on this cpu. + * + * long bpf_redirect_peer(u32 ifindex, u64 flags) + * Description + * Redirect the packet to another net device of index *ifindex*. + * This helper is somewhat similar to **bpf_redirect**\ (), except + * that the redirection happens to the *ifindex*' peer device and + * the netns switch takes place from ingress to ingress without + * going through the CPU's backlog queue. + * + * The *flags* argument is reserved and must be 0. The helper is + * currently only supported for tc BPF program types at the ingress + * hook and for veth device types. The peer device must reside in a + * different network namespace. + * Return + * The helper returns **TC_ACT_REDIRECT** on success or + * **TC_ACT_SHOT** on error. + * + * void *bpf_task_storage_get(struct bpf_map *map, struct task_struct *task, void *value, u64 flags) + * Description + * Get a bpf_local_storage from the *task*. + * + * Logically, it could be thought of as getting the value from + * a *map* with *task* as the **key**. From this + * perspective, the usage is not much different from + * **bpf_map_lookup_elem**\ (*map*, **&**\ *task*) except this + * helper enforces the key must be an task_struct and the map must also + * be a **BPF_MAP_TYPE_TASK_STORAGE**. + * + * Underneath, the value is stored locally at *task* instead of + * the *map*. The *map* is used as the bpf-local-storage + * "type". The bpf-local-storage "type" (i.e. the *map*) is + * searched against all bpf_local_storage residing at *task*. + * + * An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be + * used such that a new bpf_local_storage will be + * created if one does not exist. *value* can be used + * together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify + * the initial value of a bpf_local_storage. If *value* is + * **NULL**, the new bpf_local_storage will be zero initialized. + * Return + * A bpf_local_storage pointer is returned on success. + * + * **NULL** if not found or there was an error in adding + * a new bpf_local_storage. + * + * long bpf_task_storage_delete(struct bpf_map *map, struct task_struct *task) + * Description + * Delete a bpf_local_storage from a *task*. + * Return + * 0 on success. + * + * **-ENOENT** if the bpf_local_storage cannot be found. + * + * struct task_struct *bpf_get_current_task_btf(void) + * Description + * Return a BTF pointer to the "current" task. + * This pointer can also be used in helpers that accept an + * *ARG_PTR_TO_BTF_ID* of type *task_struct*. + * Return + * Pointer to the current task. + * + * long bpf_bprm_opts_set(struct linux_binprm *bprm, u64 flags) + * Description + * Set or clear certain options on *bprm*: + * + * **BPF_F_BPRM_SECUREEXEC** Set the secureexec bit + * which sets the **AT_SECURE** auxv for glibc. The bit + * is cleared if the flag is not specified. + * Return + * **-EINVAL** if invalid *flags* are passed, zero otherwise. + * + * u64 bpf_ktime_get_coarse_ns(void) + * Description + * Return a coarse-grained version of the time elapsed since + * system boot, in nanoseconds. Does not include time the system + * was suspended. + * + * See: **clock_gettime**\ (**CLOCK_MONOTONIC_COARSE**) + * Return + * Current *ktime*. + * + * long bpf_ima_inode_hash(struct inode *inode, void *dst, u32 size) + * Description + * Returns the stored IMA hash of the *inode* (if it's avaialable). + * If the hash is larger than *size*, then only *size* + * bytes will be copied to *dst* + * Return + * The **hash_algo** is returned on success, + * **-EOPNOTSUP** if IMA is disabled or **-EINVAL** if + * invalid arguments are passed. + * + * struct socket *bpf_sock_from_file(struct file *file) + * Description + * If the given file represents a socket, returns the associated + * socket. + * Return + * A pointer to a struct socket on success or NULL if the file is + * not a socket. + * + * long bpf_check_mtu(void *ctx, u32 ifindex, u32 *mtu_len, s32 len_diff, u64 flags) + * Description + * Check ctx packet size against exceeding MTU of net device (based + * on *ifindex*). This helper will likely be used in combination + * with helpers that adjust/change the packet size. + * + * The argument *len_diff* can be used for querying with a planned + * size change. This allows to check MTU prior to changing packet + * ctx. Providing an *len_diff* adjustment that is larger than the + * actual packet size (resulting in negative packet size) will in + * principle not exceed the MTU, why it is not considered a + * failure. Other BPF-helpers are needed for performing the + * planned size change, why the responsability for catch a negative + * packet size belong in those helpers. + * + * Specifying *ifindex* zero means the MTU check is performed + * against the current net device. This is practical if this isn't + * used prior to redirect. + * + * The Linux kernel route table can configure MTUs on a more + * specific per route level, which is not provided by this helper. + * For route level MTU checks use the **bpf_fib_lookup**\ () + * helper. + * + * *ctx* is either **struct xdp_md** for XDP programs or + * **struct sk_buff** for tc cls_act programs. + * + * The *flags* argument can be a combination of one or more of the + * following values: + * + * **BPF_MTU_CHK_SEGS** + * This flag will only works for *ctx* **struct sk_buff**. + * If packet context contains extra packet segment buffers + * (often knows as GSO skb), then MTU check is harder to + * check at this point, because in transmit path it is + * possible for the skb packet to get re-segmented + * (depending on net device features). This could still be + * a MTU violation, so this flag enables performing MTU + * check against segments, with a different violation + * return code to tell it apart. Check cannot use len_diff. + * + * On return *mtu_len* pointer contains the MTU value of the net + * device. Remember the net device configured MTU is the L3 size, + * which is returned here and XDP and TX length operate at L2. + * Helper take this into account for you, but remember when using + * MTU value in your BPF-code. On input *mtu_len* must be a valid + * pointer and be initialized (to zero), else verifier will reject + * BPF program. + * + * Return + * * 0 on success, and populate MTU value in *mtu_len* pointer. + * + * * < 0 if any input argument is invalid (*mtu_len* not updated) + * + * MTU violations return positive values, but also populate MTU + * value in *mtu_len* pointer, as this can be needed for + * implementing PMTU handing: + * + * * **BPF_MTU_CHK_RET_FRAG_NEEDED** + * * **BPF_MTU_CHK_RET_SEGS_TOOBIG** + * + * long bpf_for_each_map_elem(struct bpf_map *map, void *callback_fn, void *callback_ctx, u64 flags) + * Description + * For each element in **map**, call **callback_fn** function with + * **map**, **callback_ctx** and other map-specific parameters. + * The **callback_fn** should be a static function and + * the **callback_ctx** should be a pointer to the stack. + * The **flags** is used to control certain aspects of the helper. + * Currently, the **flags** must be 0. + * + * The following are a list of supported map types and their + * respective expected callback signatures: + * + * BPF_MAP_TYPE_HASH, BPF_MAP_TYPE_PERCPU_HASH, + * BPF_MAP_TYPE_LRU_HASH, BPF_MAP_TYPE_LRU_PERCPU_HASH, + * BPF_MAP_TYPE_ARRAY, BPF_MAP_TYPE_PERCPU_ARRAY + * + * long (\*callback_fn)(struct bpf_map \*map, const void \*key, void \*value, void \*ctx); + * + * For per_cpu maps, the map_value is the value on the cpu where the + * bpf_prog is running. + * + * If **callback_fn** return 0, the helper will continue to the next + * element. If return value is 1, the helper will skip the rest of + * elements and return. Other return values are not used now. + * + * Return + * The number of traversed map elements for success, **-EINVAL** for + * invalid **flags**. + */ +#define __BPF_FUNC_MAPPER(FN) \ + FN(unspec), \ + FN(map_lookup_elem), \ + FN(map_update_elem), \ + FN(map_delete_elem), \ + FN(probe_read), \ + FN(ktime_get_ns), \ + FN(trace_printk), \ + FN(get_prandom_u32), \ + FN(get_smp_processor_id), \ + FN(skb_store_bytes), \ + FN(l3_csum_replace), \ + FN(l4_csum_replace), \ + FN(tail_call), \ + FN(clone_redirect), \ + FN(get_current_pid_tgid), \ + FN(get_current_uid_gid), \ + FN(get_current_comm), \ + FN(get_cgroup_classid), \ + FN(skb_vlan_push), \ + FN(skb_vlan_pop), \ + FN(skb_get_tunnel_key), \ + FN(skb_set_tunnel_key), \ + FN(perf_event_read), \ + FN(redirect), \ + FN(get_route_realm), \ + FN(perf_event_output), \ + FN(skb_load_bytes), \ + FN(get_stackid), \ + FN(csum_diff), \ + FN(skb_get_tunnel_opt), \ + FN(skb_set_tunnel_opt), \ + FN(skb_change_proto), \ + FN(skb_change_type), \ + FN(skb_under_cgroup), \ + FN(get_hash_recalc), \ + FN(get_current_task), \ + FN(probe_write_user), \ + FN(current_task_under_cgroup), \ + FN(skb_change_tail), \ + FN(skb_pull_data), \ + FN(csum_update), \ + FN(set_hash_invalid), \ + FN(get_numa_node_id), \ + FN(skb_change_head), \ + FN(xdp_adjust_head), \ + FN(probe_read_str), \ + FN(get_socket_cookie), \ + FN(get_socket_uid), \ + FN(set_hash), \ + FN(setsockopt), \ + FN(skb_adjust_room), \ + FN(redirect_map), \ + FN(sk_redirect_map), \ + FN(sock_map_update), \ + FN(xdp_adjust_meta), \ + FN(perf_event_read_value), \ + FN(perf_prog_read_value), \ + FN(getsockopt), \ + FN(override_return), \ + FN(sock_ops_cb_flags_set), \ + FN(msg_redirect_map), \ + FN(msg_apply_bytes), \ + FN(msg_cork_bytes), \ + FN(msg_pull_data), \ + FN(bind), \ + FN(xdp_adjust_tail), \ + FN(skb_get_xfrm_state), \ + FN(get_stack), \ + FN(skb_load_bytes_relative), \ + FN(fib_lookup), \ + FN(sock_hash_update), \ + FN(msg_redirect_hash), \ + FN(sk_redirect_hash), \ + FN(lwt_push_encap), \ + FN(lwt_seg6_store_bytes), \ + FN(lwt_seg6_adjust_srh), \ + FN(lwt_seg6_action), \ + FN(rc_repeat), \ + FN(rc_keydown), \ + FN(skb_cgroup_id), \ + FN(get_current_cgroup_id), \ + FN(get_local_storage), \ + FN(sk_select_reuseport), \ + FN(skb_ancestor_cgroup_id), \ + FN(sk_lookup_tcp), \ + FN(sk_lookup_udp), \ + FN(sk_release), \ + FN(map_push_elem), \ + FN(map_pop_elem), \ + FN(map_peek_elem), \ + FN(msg_push_data), \ + FN(msg_pop_data), \ + FN(rc_pointer_rel), \ + FN(spin_lock), \ + FN(spin_unlock), \ + FN(sk_fullsock), \ + FN(tcp_sock), \ + FN(skb_ecn_set_ce), \ + FN(get_listener_sock), \ + FN(skc_lookup_tcp), \ + FN(tcp_check_syncookie), \ + FN(sysctl_get_name), \ + FN(sysctl_get_current_value), \ + FN(sysctl_get_new_value), \ + FN(sysctl_set_new_value), \ + FN(strtol), \ + FN(strtoul), \ + FN(sk_storage_get), \ + FN(sk_storage_delete), \ + FN(send_signal), \ + FN(tcp_gen_syncookie), \ + FN(skb_output), \ + FN(probe_read_user), \ + FN(probe_read_kernel), \ + FN(probe_read_user_str), \ + FN(probe_read_kernel_str), \ + FN(tcp_send_ack), \ + FN(send_signal_thread), \ + FN(jiffies64), \ + FN(read_branch_records), \ + FN(get_ns_current_pid_tgid), \ + FN(xdp_output), \ + FN(get_netns_cookie), \ + FN(get_current_ancestor_cgroup_id), \ + FN(sk_assign), \ + FN(ktime_get_boot_ns), \ + FN(seq_printf), \ + FN(seq_write), \ + FN(sk_cgroup_id), \ + FN(sk_ancestor_cgroup_id), \ + FN(ringbuf_output), \ + FN(ringbuf_reserve), \ + FN(ringbuf_submit), \ + FN(ringbuf_discard), \ + FN(ringbuf_query), \ + FN(csum_level), \ + FN(skc_to_tcp6_sock), \ + FN(skc_to_tcp_sock), \ + FN(skc_to_tcp_timewait_sock), \ + FN(skc_to_tcp_request_sock), \ + FN(skc_to_udp6_sock), \ + FN(get_task_stack), \ + FN(load_hdr_opt), \ + FN(store_hdr_opt), \ + FN(reserve_hdr_opt), \ + FN(inode_storage_get), \ + FN(inode_storage_delete), \ + FN(d_path), \ + FN(copy_from_user), \ + FN(snprintf_btf), \ + FN(seq_printf_btf), \ + FN(skb_cgroup_classid), \ + FN(redirect_neigh), \ + FN(per_cpu_ptr), \ + FN(this_cpu_ptr), \ + FN(redirect_peer), \ + FN(task_storage_get), \ + FN(task_storage_delete), \ + FN(get_current_task_btf), \ + FN(bprm_opts_set), \ + FN(ktime_get_coarse_ns), \ + FN(ima_inode_hash), \ + FN(sock_from_file), \ + FN(check_mtu), \ + FN(for_each_map_elem), \ + /* */ + +/* integer value in 'imm' field of BPF_CALL instruction selects which helper + * function eBPF program intends to call + */ +#define __BPF_ENUM_FN(x) BPF_FUNC_ ## x +enum bpf_func_id { + __BPF_FUNC_MAPPER(__BPF_ENUM_FN) + __BPF_FUNC_MAX_ID, +}; +#undef __BPF_ENUM_FN + +/* All flags used by eBPF helper functions, placed here. */ + +/* BPF_FUNC_skb_store_bytes flags. */ +enum { + BPF_F_RECOMPUTE_CSUM = (1ULL << 0), + BPF_F_INVALIDATE_HASH = (1ULL << 1), +}; + +/* BPF_FUNC_l3_csum_replace and BPF_FUNC_l4_csum_replace flags. + * First 4 bits are for passing the header field size. + */ +enum { + BPF_F_HDR_FIELD_MASK = 0xfULL, +}; + +/* BPF_FUNC_l4_csum_replace flags. */ +enum { + BPF_F_PSEUDO_HDR = (1ULL << 4), + BPF_F_MARK_MANGLED_0 = (1ULL << 5), + BPF_F_MARK_ENFORCE = (1ULL << 6), +}; + +/* BPF_FUNC_clone_redirect and BPF_FUNC_redirect flags. */ +enum { + BPF_F_INGRESS = (1ULL << 0), +}; + +/* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */ +enum { + BPF_F_TUNINFO_IPV6 = (1ULL << 0), +}; + +/* flags for both BPF_FUNC_get_stackid and BPF_FUNC_get_stack. */ +enum { + BPF_F_SKIP_FIELD_MASK = 0xffULL, + BPF_F_USER_STACK = (1ULL << 8), +/* flags used by BPF_FUNC_get_stackid only. */ + BPF_F_FAST_STACK_CMP = (1ULL << 9), + BPF_F_REUSE_STACKID = (1ULL << 10), +/* flags used by BPF_FUNC_get_stack only. */ + BPF_F_USER_BUILD_ID = (1ULL << 11), +}; + +/* BPF_FUNC_skb_set_tunnel_key flags. */ +enum { + BPF_F_ZERO_CSUM_TX = (1ULL << 1), + BPF_F_DONT_FRAGMENT = (1ULL << 2), + BPF_F_SEQ_NUMBER = (1ULL << 3), +}; + +/* BPF_FUNC_perf_event_output, BPF_FUNC_perf_event_read and + * BPF_FUNC_perf_event_read_value flags. + */ +enum { + BPF_F_INDEX_MASK = 0xffffffffULL, + BPF_F_CURRENT_CPU = BPF_F_INDEX_MASK, +/* BPF_FUNC_perf_event_output for sk_buff input context. */ + BPF_F_CTXLEN_MASK = (0xfffffULL << 32), +}; + +/* Current network namespace */ +enum { + BPF_F_CURRENT_NETNS = (-1L), +}; + +/* BPF_FUNC_csum_level level values. */ +enum { + BPF_CSUM_LEVEL_QUERY, + BPF_CSUM_LEVEL_INC, + BPF_CSUM_LEVEL_DEC, + BPF_CSUM_LEVEL_RESET, +}; + +/* BPF_FUNC_skb_adjust_room flags. */ +enum { + BPF_F_ADJ_ROOM_FIXED_GSO = (1ULL << 0), + BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = (1ULL << 1), + BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = (1ULL << 2), + BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3), + BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4), + BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5), +}; + +enum { + BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff, + BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 56, +}; + +#define BPF_F_ADJ_ROOM_ENCAP_L2(len) (((__u64)len & \ + BPF_ADJ_ROOM_ENCAP_L2_MASK) \ + << BPF_ADJ_ROOM_ENCAP_L2_SHIFT) + +/* BPF_FUNC_sysctl_get_name flags. */ +enum { + BPF_F_SYSCTL_BASE_NAME = (1ULL << 0), +}; + +/* BPF_FUNC__storage_get flags */ +enum { + BPF_LOCAL_STORAGE_GET_F_CREATE = (1ULL << 0), + /* BPF_SK_STORAGE_GET_F_CREATE is only kept for backward compatibility + * and BPF_LOCAL_STORAGE_GET_F_CREATE must be used instead. + */ + BPF_SK_STORAGE_GET_F_CREATE = BPF_LOCAL_STORAGE_GET_F_CREATE, +}; + +/* BPF_FUNC_read_branch_records flags. */ +enum { + BPF_F_GET_BRANCH_RECORDS_SIZE = (1ULL << 0), +}; + +/* BPF_FUNC_bpf_ringbuf_commit, BPF_FUNC_bpf_ringbuf_discard, and + * BPF_FUNC_bpf_ringbuf_output flags. + */ +enum { + BPF_RB_NO_WAKEUP = (1ULL << 0), + BPF_RB_FORCE_WAKEUP = (1ULL << 1), +}; + +/* BPF_FUNC_bpf_ringbuf_query flags */ +enum { + BPF_RB_AVAIL_DATA = 0, + BPF_RB_RING_SIZE = 1, + BPF_RB_CONS_POS = 2, + BPF_RB_PROD_POS = 3, +}; + +/* BPF ring buffer constants */ +enum { + BPF_RINGBUF_BUSY_BIT = (1U << 31), + BPF_RINGBUF_DISCARD_BIT = (1U << 30), + BPF_RINGBUF_HDR_SZ = 8, +}; + +/* BPF_FUNC_sk_assign flags in bpf_sk_lookup context. */ +enum { + BPF_SK_LOOKUP_F_REPLACE = (1ULL << 0), + BPF_SK_LOOKUP_F_NO_REUSEPORT = (1ULL << 1), +}; + +/* Mode for BPF_FUNC_skb_adjust_room helper. */ +enum bpf_adj_room_mode { + BPF_ADJ_ROOM_NET, + BPF_ADJ_ROOM_MAC, +}; + +/* Mode for BPF_FUNC_skb_load_bytes_relative helper. */ +enum bpf_hdr_start_off { + BPF_HDR_START_MAC, + BPF_HDR_START_NET, +}; + +/* Encapsulation type for BPF_FUNC_lwt_push_encap helper. */ +enum bpf_lwt_encap_mode { + BPF_LWT_ENCAP_SEG6, + BPF_LWT_ENCAP_SEG6_INLINE, + BPF_LWT_ENCAP_IP, +}; + +/* Flags for bpf_bprm_opts_set helper */ +enum { + BPF_F_BPRM_SECUREEXEC = (1ULL << 0), +}; + +#define __bpf_md_ptr(type, name) \ +union { \ + type name; \ + __u64 :64; \ +} __attribute__((aligned(8))) + +/* user accessible mirror of in-kernel sk_buff. + * new fields can only be added to the end of this structure + */ +struct __sk_buff { + __u32 len; + __u32 pkt_type; + __u32 mark; + __u32 queue_mapping; + __u32 protocol; + __u32 vlan_present; + __u32 vlan_tci; + __u32 vlan_proto; + __u32 priority; + __u32 ingress_ifindex; + __u32 ifindex; + __u32 tc_index; + __u32 cb[5]; + __u32 hash; + __u32 tc_classid; + __u32 data; + __u32 data_end; + __u32 napi_id; + + /* Accessed by BPF_PROG_TYPE_sk_skb types from here to ... */ + __u32 family; + __u32 remote_ip4; /* Stored in network byte order */ + __u32 local_ip4; /* Stored in network byte order */ + __u32 remote_ip6[4]; /* Stored in network byte order */ + __u32 local_ip6[4]; /* Stored in network byte order */ + __u32 remote_port; /* Stored in network byte order */ + __u32 local_port; /* stored in host byte order */ + /* ... here. */ + + __u32 data_meta; + __bpf_md_ptr(struct bpf_flow_keys *, flow_keys); + __u64 tstamp; + __u32 wire_len; + __u32 gso_segs; + __bpf_md_ptr(struct bpf_sock *, sk); + __u32 gso_size; +}; + +struct bpf_tunnel_key { + __u32 tunnel_id; + union { + __u32 remote_ipv4; + __u32 remote_ipv6[4]; + }; + __u8 tunnel_tos; + __u8 tunnel_ttl; + __u16 tunnel_ext; /* Padding, future use. */ + __u32 tunnel_label; +}; + +/* user accessible mirror of in-kernel xfrm_state. + * new fields can only be added to the end of this structure + */ +struct bpf_xfrm_state { + __u32 reqid; + __u32 spi; /* Stored in network byte order */ + __u16 family; + __u16 ext; /* Padding, future use. */ + union { + __u32 remote_ipv4; /* Stored in network byte order */ + __u32 remote_ipv6[4]; /* Stored in network byte order */ + }; +}; + +/* Generic BPF return codes which all BPF program types may support. + * The values are binary compatible with their TC_ACT_* counter-part to + * provide backwards compatibility with existing SCHED_CLS and SCHED_ACT + * programs. + * + * XDP is handled seprately, see XDP_*. + */ +enum bpf_ret_code { + BPF_OK = 0, + /* 1 reserved */ + BPF_DROP = 2, + /* 3-6 reserved */ + BPF_REDIRECT = 7, + /* >127 are reserved for prog type specific return codes. + * + * BPF_LWT_REROUTE: used by BPF_PROG_TYPE_LWT_IN and + * BPF_PROG_TYPE_LWT_XMIT to indicate that skb had been + * changed and should be routed based on its new L3 header. + * (This is an L3 redirect, as opposed to L2 redirect + * represented by BPF_REDIRECT above). + */ + BPF_LWT_REROUTE = 128, +}; + +struct bpf_sock { + __u32 bound_dev_if; + __u32 family; + __u32 type; + __u32 protocol; + __u32 mark; + __u32 priority; + /* IP address also allows 1 and 2 bytes access */ + __u32 src_ip4; + __u32 src_ip6[4]; + __u32 src_port; /* host byte order */ + __u32 dst_port; /* network byte order */ + __u32 dst_ip4; + __u32 dst_ip6[4]; + __u32 state; + __s32 rx_queue_mapping; +}; + +struct bpf_tcp_sock { + __u32 snd_cwnd; /* Sending congestion window */ + __u32 srtt_us; /* smoothed round trip time << 3 in usecs */ + __u32 rtt_min; + __u32 snd_ssthresh; /* Slow start size threshold */ + __u32 rcv_nxt; /* What we want to receive next */ + __u32 snd_nxt; /* Next sequence we send */ + __u32 snd_una; /* First byte we want an ack for */ + __u32 mss_cache; /* Cached effective mss, not including SACKS */ + __u32 ecn_flags; /* ECN status bits. */ + __u32 rate_delivered; /* saved rate sample: packets delivered */ + __u32 rate_interval_us; /* saved rate sample: time elapsed */ + __u32 packets_out; /* Packets which are "in flight" */ + __u32 retrans_out; /* Retransmitted packets out */ + __u32 total_retrans; /* Total retransmits for entire connection */ + __u32 segs_in; /* RFC4898 tcpEStatsPerfSegsIn + * total number of segments in. + */ + __u32 data_segs_in; /* RFC4898 tcpEStatsPerfDataSegsIn + * total number of data segments in. + */ + __u32 segs_out; /* RFC4898 tcpEStatsPerfSegsOut + * The total number of segments sent. + */ + __u32 data_segs_out; /* RFC4898 tcpEStatsPerfDataSegsOut + * total number of data segments sent. + */ + __u32 lost_out; /* Lost packets */ + __u32 sacked_out; /* SACK'd packets */ + __u64 bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived + * sum(delta(rcv_nxt)), or how many bytes + * were acked. + */ + __u64 bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked + * sum(delta(snd_una)), or how many bytes + * were acked. + */ + __u32 dsack_dups; /* RFC4898 tcpEStatsStackDSACKDups + * total number of DSACK blocks received + */ + __u32 delivered; /* Total data packets delivered incl. rexmits */ + __u32 delivered_ce; /* Like the above but only ECE marked packets */ + __u32 icsk_retransmits; /* Number of unrecovered [RTO] timeouts */ +}; + +struct bpf_sock_tuple { + union { + struct { + __be32 saddr; + __be32 daddr; + __be16 sport; + __be16 dport; + } ipv4; + struct { + __be32 saddr[4]; + __be32 daddr[4]; + __be16 sport; + __be16 dport; + } ipv6; + }; +}; + +struct bpf_xdp_sock { + __u32 queue_id; +}; + +#define XDP_PACKET_HEADROOM 256 + +/* User return codes for XDP prog type. + * A valid XDP program must return one of these defined values. All other + * return codes are reserved for future use. Unknown return codes will + * result in packet drops and a warning via bpf_warn_invalid_xdp_action(). + */ +enum xdp_action { + XDP_ABORTED = 0, + XDP_DROP, + XDP_PASS, + XDP_TX, + XDP_REDIRECT, +}; + +/* user accessible metadata for XDP packet hook + * new fields must be added to the end of this structure + */ +struct xdp_md { + __u32 data; + __u32 data_end; + __u32 data_meta; + /* Below access go through struct xdp_rxq_info */ + __u32 ingress_ifindex; /* rxq->dev->ifindex */ + __u32 rx_queue_index; /* rxq->queue_index */ + + __u32 egress_ifindex; /* txq->dev->ifindex */ +}; + +/* DEVMAP map-value layout + * + * The struct data-layout of map-value is a configuration interface. + * New members can only be added to the end of this structure. + */ +struct bpf_devmap_val { + __u32 ifindex; /* device index */ + union { + int fd; /* prog fd on map write */ + __u32 id; /* prog id on map read */ + } bpf_prog; +}; + +/* CPUMAP map-value layout + * + * The struct data-layout of map-value is a configuration interface. + * New members can only be added to the end of this structure. + */ +struct bpf_cpumap_val { + __u32 qsize; /* queue size to remote target CPU */ + union { + int fd; /* prog fd on map write */ + __u32 id; /* prog id on map read */ + } bpf_prog; +}; + +enum sk_action { + SK_DROP = 0, + SK_PASS, +}; + +/* user accessible metadata for SK_MSG packet hook, new fields must + * be added to the end of this structure + */ +struct sk_msg_md { + __bpf_md_ptr(void *, data); + __bpf_md_ptr(void *, data_end); + + __u32 family; + __u32 remote_ip4; /* Stored in network byte order */ + __u32 local_ip4; /* Stored in network byte order */ + __u32 remote_ip6[4]; /* Stored in network byte order */ + __u32 local_ip6[4]; /* Stored in network byte order */ + __u32 remote_port; /* Stored in network byte order */ + __u32 local_port; /* stored in host byte order */ + __u32 size; /* Total size of sk_msg */ + + __bpf_md_ptr(struct bpf_sock *, sk); /* current socket */ +}; + +struct sk_reuseport_md { + /* + * Start of directly accessible data. It begins from + * the tcp/udp header. + */ + __bpf_md_ptr(void *, data); + /* End of directly accessible data */ + __bpf_md_ptr(void *, data_end); + /* + * Total length of packet (starting from the tcp/udp header). + * Note that the directly accessible bytes (data_end - data) + * could be less than this "len". Those bytes could be + * indirectly read by a helper "bpf_skb_load_bytes()". + */ + __u32 len; + /* + * Eth protocol in the mac header (network byte order). e.g. + * ETH_P_IP(0x0800) and ETH_P_IPV6(0x86DD) + */ + __u32 eth_protocol; + __u32 ip_protocol; /* IP protocol. e.g. IPPROTO_TCP, IPPROTO_UDP */ + __u32 bind_inany; /* Is sock bound to an INANY address? */ + __u32 hash; /* A hash of the packet 4 tuples */ +}; + +#define BPF_TAG_SIZE 8 + +struct bpf_prog_info { + __u32 type; + __u32 id; + __u8 tag[BPF_TAG_SIZE]; + __u32 jited_prog_len; + __u32 xlated_prog_len; + __aligned_u64 jited_prog_insns; + __aligned_u64 xlated_prog_insns; + __u64 load_time; /* ns since boottime */ + __u32 created_by_uid; + __u32 nr_map_ids; + __aligned_u64 map_ids; + char name[BPF_OBJ_NAME_LEN]; + __u32 ifindex; + __u32 gpl_compatible:1; + __u32 :31; /* alignment pad */ + __u64 netns_dev; + __u64 netns_ino; + __u32 nr_jited_ksyms; + __u32 nr_jited_func_lens; + __aligned_u64 jited_ksyms; + __aligned_u64 jited_func_lens; + __u32 btf_id; + __u32 func_info_rec_size; + __aligned_u64 func_info; + __u32 nr_func_info; + __u32 nr_line_info; + __aligned_u64 line_info; + __aligned_u64 jited_line_info; + __u32 nr_jited_line_info; + __u32 line_info_rec_size; + __u32 jited_line_info_rec_size; + __u32 nr_prog_tags; + __aligned_u64 prog_tags; + __u64 run_time_ns; + __u64 run_cnt; + __u64 recursion_misses; +} __attribute__((aligned(8))); + +struct bpf_map_info { + __u32 type; + __u32 id; + __u32 key_size; + __u32 value_size; + __u32 max_entries; + __u32 map_flags; + char name[BPF_OBJ_NAME_LEN]; + __u32 ifindex; + __u32 btf_vmlinux_value_type_id; + __u64 netns_dev; + __u64 netns_ino; + __u32 btf_id; + __u32 btf_key_type_id; + __u32 btf_value_type_id; +} __attribute__((aligned(8))); + +struct bpf_btf_info { + __aligned_u64 btf; + __u32 btf_size; + __u32 id; + __aligned_u64 name; + __u32 name_len; + __u32 kernel_btf; +} __attribute__((aligned(8))); + +struct bpf_link_info { + __u32 type; + __u32 id; + __u32 prog_id; + union { + struct { + __aligned_u64 tp_name; /* in/out: tp_name buffer ptr */ + __u32 tp_name_len; /* in/out: tp_name buffer len */ + } raw_tracepoint; + struct { + __u32 attach_type; + } tracing; + struct { + __u64 cgroup_id; + __u32 attach_type; + } cgroup; + struct { + __aligned_u64 target_name; /* in/out: target_name buffer ptr */ + __u32 target_name_len; /* in/out: target_name buffer len */ + union { + struct { + __u32 map_id; + } map; + }; + } iter; + struct { + __u32 netns_ino; + __u32 attach_type; + } netns; + struct { + __u32 ifindex; + } xdp; + }; +} __attribute__((aligned(8))); + +/* User bpf_sock_addr struct to access socket fields and sockaddr struct passed + * by user and intended to be used by socket (e.g. to bind to, depends on + * attach type). + */ +struct bpf_sock_addr { + __u32 user_family; /* Allows 4-byte read, but no write. */ + __u32 user_ip4; /* Allows 1,2,4-byte read and 4-byte write. + * Stored in network byte order. + */ + __u32 user_ip6[4]; /* Allows 1,2,4,8-byte read and 4,8-byte write. + * Stored in network byte order. + */ + __u32 user_port; /* Allows 1,2,4-byte read and 4-byte write. + * Stored in network byte order + */ + __u32 family; /* Allows 4-byte read, but no write */ + __u32 type; /* Allows 4-byte read, but no write */ + __u32 protocol; /* Allows 4-byte read, but no write */ + __u32 msg_src_ip4; /* Allows 1,2,4-byte read and 4-byte write. + * Stored in network byte order. + */ + __u32 msg_src_ip6[4]; /* Allows 1,2,4,8-byte read and 4,8-byte write. + * Stored in network byte order. + */ + __bpf_md_ptr(struct bpf_sock *, sk); +}; + +/* User bpf_sock_ops struct to access socket values and specify request ops + * and their replies. + * Some of this fields are in network (bigendian) byte order and may need + * to be converted before use (bpf_ntohl() defined in samples/bpf/bpf_endian.h). + * New fields can only be added at the end of this structure + */ +struct bpf_sock_ops { + __u32 op; + union { + __u32 args[4]; /* Optionally passed to bpf program */ + __u32 reply; /* Returned by bpf program */ + __u32 replylong[4]; /* Optionally returned by bpf prog */ + }; + __u32 family; + __u32 remote_ip4; /* Stored in network byte order */ + __u32 local_ip4; /* Stored in network byte order */ + __u32 remote_ip6[4]; /* Stored in network byte order */ + __u32 local_ip6[4]; /* Stored in network byte order */ + __u32 remote_port; /* Stored in network byte order */ + __u32 local_port; /* stored in host byte order */ + __u32 is_fullsock; /* Some TCP fields are only valid if + * there is a full socket. If not, the + * fields read as zero. + */ + __u32 snd_cwnd; + __u32 srtt_us; /* Averaged RTT << 3 in usecs */ + __u32 bpf_sock_ops_cb_flags; /* flags defined in uapi/linux/tcp.h */ + __u32 state; + __u32 rtt_min; + __u32 snd_ssthresh; + __u32 rcv_nxt; + __u32 snd_nxt; + __u32 snd_una; + __u32 mss_cache; + __u32 ecn_flags; + __u32 rate_delivered; + __u32 rate_interval_us; + __u32 packets_out; + __u32 retrans_out; + __u32 total_retrans; + __u32 segs_in; + __u32 data_segs_in; + __u32 segs_out; + __u32 data_segs_out; + __u32 lost_out; + __u32 sacked_out; + __u32 sk_txhash; + __u64 bytes_received; + __u64 bytes_acked; + __bpf_md_ptr(struct bpf_sock *, sk); + /* [skb_data, skb_data_end) covers the whole TCP header. + * + * BPF_SOCK_OPS_PARSE_HDR_OPT_CB: The packet received + * BPF_SOCK_OPS_HDR_OPT_LEN_CB: Not useful because the + * header has not been written. + * BPF_SOCK_OPS_WRITE_HDR_OPT_CB: The header and options have + * been written so far. + * BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: The SYNACK that concludes + * the 3WHS. + * BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: The ACK that concludes + * the 3WHS. + * + * bpf_load_hdr_opt() can also be used to read a particular option. + */ + __bpf_md_ptr(void *, skb_data); + __bpf_md_ptr(void *, skb_data_end); + __u32 skb_len; /* The total length of a packet. + * It includes the header, options, + * and payload. + */ + __u32 skb_tcp_flags; /* tcp_flags of the header. It provides + * an easy way to check for tcp_flags + * without parsing skb_data. + * + * In particular, the skb_tcp_flags + * will still be available in + * BPF_SOCK_OPS_HDR_OPT_LEN even though + * the outgoing header has not + * been written yet. + */ +}; + +/* Definitions for bpf_sock_ops_cb_flags */ +enum { + BPF_SOCK_OPS_RTO_CB_FLAG = (1<<0), + BPF_SOCK_OPS_RETRANS_CB_FLAG = (1<<1), + BPF_SOCK_OPS_STATE_CB_FLAG = (1<<2), + BPF_SOCK_OPS_RTT_CB_FLAG = (1<<3), + /* Call bpf for all received TCP headers. The bpf prog will be + * called under sock_ops->op == BPF_SOCK_OPS_PARSE_HDR_OPT_CB + * + * Please refer to the comment in BPF_SOCK_OPS_PARSE_HDR_OPT_CB + * for the header option related helpers that will be useful + * to the bpf programs. + * + * It could be used at the client/active side (i.e. connect() side) + * when the server told it that the server was in syncookie + * mode and required the active side to resend the bpf-written + * options. The active side can keep writing the bpf-options until + * it received a valid packet from the server side to confirm + * the earlier packet (and options) has been received. The later + * example patch is using it like this at the active side when the + * server is in syncookie mode. + * + * The bpf prog will usually turn this off in the common cases. + */ + BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG = (1<<4), + /* Call bpf when kernel has received a header option that + * the kernel cannot handle. The bpf prog will be called under + * sock_ops->op == BPF_SOCK_OPS_PARSE_HDR_OPT_CB. + * + * Please refer to the comment in BPF_SOCK_OPS_PARSE_HDR_OPT_CB + * for the header option related helpers that will be useful + * to the bpf programs. + */ + BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG = (1<<5), + /* Call bpf when the kernel is writing header options for the + * outgoing packet. The bpf prog will first be called + * to reserve space in a skb under + * sock_ops->op == BPF_SOCK_OPS_HDR_OPT_LEN_CB. Then + * the bpf prog will be called to write the header option(s) + * under sock_ops->op == BPF_SOCK_OPS_WRITE_HDR_OPT_CB. + * + * Please refer to the comment in BPF_SOCK_OPS_HDR_OPT_LEN_CB + * and BPF_SOCK_OPS_WRITE_HDR_OPT_CB for the header option + * related helpers that will be useful to the bpf programs. + * + * The kernel gets its chance to reserve space and write + * options first before the BPF program does. + */ + BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1<<6), +/* Mask of all currently supported cb flags */ + BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F, +}; + +/* List of known BPF sock_ops operators. + * New entries can only be added at the end + */ +enum { + BPF_SOCK_OPS_VOID, + BPF_SOCK_OPS_TIMEOUT_INIT, /* Should return SYN-RTO value to use or + * -1 if default value should be used + */ + BPF_SOCK_OPS_RWND_INIT, /* Should return initial advertized + * window (in packets) or -1 if default + * value should be used + */ + BPF_SOCK_OPS_TCP_CONNECT_CB, /* Calls BPF program right before an + * active connection is initialized + */ + BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB, /* Calls BPF program when an + * active connection is + * established + */ + BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB, /* Calls BPF program when a + * passive connection is + * established + */ + BPF_SOCK_OPS_NEEDS_ECN, /* If connection's congestion control + * needs ECN + */ + BPF_SOCK_OPS_BASE_RTT, /* Get base RTT. The correct value is + * based on the path and may be + * dependent on the congestion control + * algorithm. In general it indicates + * a congestion threshold. RTTs above + * this indicate congestion + */ + BPF_SOCK_OPS_RTO_CB, /* Called when an RTO has triggered. + * Arg1: value of icsk_retransmits + * Arg2: value of icsk_rto + * Arg3: whether RTO has expired + */ + BPF_SOCK_OPS_RETRANS_CB, /* Called when skb is retransmitted. + * Arg1: sequence number of 1st byte + * Arg2: # segments + * Arg3: return value of + * tcp_transmit_skb (0 => success) + */ + BPF_SOCK_OPS_STATE_CB, /* Called when TCP changes state. + * Arg1: old_state + * Arg2: new_state + */ + BPF_SOCK_OPS_TCP_LISTEN_CB, /* Called on listen(2), right after + * socket transition to LISTEN state. + */ + BPF_SOCK_OPS_RTT_CB, /* Called on every RTT. + */ + BPF_SOCK_OPS_PARSE_HDR_OPT_CB, /* Parse the header option. + * It will be called to handle + * the packets received at + * an already established + * connection. + * + * sock_ops->skb_data: + * Referring to the received skb. + * It covers the TCP header only. + * + * bpf_load_hdr_opt() can also + * be used to search for a + * particular option. + */ + BPF_SOCK_OPS_HDR_OPT_LEN_CB, /* Reserve space for writing the + * header option later in + * BPF_SOCK_OPS_WRITE_HDR_OPT_CB. + * Arg1: bool want_cookie. (in + * writing SYNACK only) + * + * sock_ops->skb_data: + * Not available because no header has + * been written yet. + * + * sock_ops->skb_tcp_flags: + * The tcp_flags of the + * outgoing skb. (e.g. SYN, ACK, FIN). + * + * bpf_reserve_hdr_opt() should + * be used to reserve space. + */ + BPF_SOCK_OPS_WRITE_HDR_OPT_CB, /* Write the header options + * Arg1: bool want_cookie. (in + * writing SYNACK only) + * + * sock_ops->skb_data: + * Referring to the outgoing skb. + * It covers the TCP header + * that has already been written + * by the kernel and the + * earlier bpf-progs. + * + * sock_ops->skb_tcp_flags: + * The tcp_flags of the outgoing + * skb. (e.g. SYN, ACK, FIN). + * + * bpf_store_hdr_opt() should + * be used to write the + * option. + * + * bpf_load_hdr_opt() can also + * be used to search for a + * particular option that + * has already been written + * by the kernel or the + * earlier bpf-progs. + */ +}; + +/* List of TCP states. There is a build check in net/ipv4/tcp.c to detect + * changes between the TCP and BPF versions. Ideally this should never happen. + * If it does, we need to add code to convert them before calling + * the BPF sock_ops function. + */ +enum { + BPF_TCP_ESTABLISHED = 1, + BPF_TCP_SYN_SENT, + BPF_TCP_SYN_RECV, + BPF_TCP_FIN_WAIT1, + BPF_TCP_FIN_WAIT2, + BPF_TCP_TIME_WAIT, + BPF_TCP_CLOSE, + BPF_TCP_CLOSE_WAIT, + BPF_TCP_LAST_ACK, + BPF_TCP_LISTEN, + BPF_TCP_CLOSING, /* Now a valid state */ + BPF_TCP_NEW_SYN_RECV, + + BPF_TCP_MAX_STATES /* Leave at the end! */ +}; + +enum { + TCP_BPF_IW = 1001, /* Set TCP initial congestion window */ + TCP_BPF_SNDCWND_CLAMP = 1002, /* Set sndcwnd_clamp */ + TCP_BPF_DELACK_MAX = 1003, /* Max delay ack in usecs */ + TCP_BPF_RTO_MIN = 1004, /* Min delay ack in usecs */ + /* Copy the SYN pkt to optval + * + * BPF_PROG_TYPE_SOCK_OPS only. It is similar to the + * bpf_getsockopt(TCP_SAVED_SYN) but it does not limit + * to only getting from the saved_syn. It can either get the + * syn packet from: + * + * 1. the just-received SYN packet (only available when writing the + * SYNACK). It will be useful when it is not necessary to + * save the SYN packet for latter use. It is also the only way + * to get the SYN during syncookie mode because the syn + * packet cannot be saved during syncookie. + * + * OR + * + * 2. the earlier saved syn which was done by + * bpf_setsockopt(TCP_SAVE_SYN). + * + * The bpf_getsockopt(TCP_BPF_SYN*) option will hide where the + * SYN packet is obtained. + * + * If the bpf-prog does not need the IP[46] header, the + * bpf-prog can avoid parsing the IP header by using + * TCP_BPF_SYN. Otherwise, the bpf-prog can get both + * IP[46] and TCP header by using TCP_BPF_SYN_IP. + * + * >0: Total number of bytes copied + * -ENOSPC: Not enough space in optval. Only optlen number of + * bytes is copied. + * -ENOENT: The SYN skb is not available now and the earlier SYN pkt + * is not saved by setsockopt(TCP_SAVE_SYN). + */ + TCP_BPF_SYN = 1005, /* Copy the TCP header */ + TCP_BPF_SYN_IP = 1006, /* Copy the IP[46] and TCP header */ + TCP_BPF_SYN_MAC = 1007, /* Copy the MAC, IP[46], and TCP header */ +}; + +enum { + BPF_LOAD_HDR_OPT_TCP_SYN = (1ULL << 0), +}; + +/* args[0] value during BPF_SOCK_OPS_HDR_OPT_LEN_CB and + * BPF_SOCK_OPS_WRITE_HDR_OPT_CB. + */ +enum { + BPF_WRITE_HDR_TCP_CURRENT_MSS = 1, /* Kernel is finding the + * total option spaces + * required for an established + * sk in order to calculate the + * MSS. No skb is actually + * sent. + */ + BPF_WRITE_HDR_TCP_SYNACK_COOKIE = 2, /* Kernel is in syncookie mode + * when sending a SYN. + */ +}; + +struct bpf_perf_event_value { + __u64 counter; + __u64 enabled; + __u64 running; +}; + +enum { + BPF_DEVCG_ACC_MKNOD = (1ULL << 0), + BPF_DEVCG_ACC_READ = (1ULL << 1), + BPF_DEVCG_ACC_WRITE = (1ULL << 2), +}; + +enum { + BPF_DEVCG_DEV_BLOCK = (1ULL << 0), + BPF_DEVCG_DEV_CHAR = (1ULL << 1), +}; + +struct bpf_cgroup_dev_ctx { + /* access_type encoded as (BPF_DEVCG_ACC_* << 16) | BPF_DEVCG_DEV_* */ + __u32 access_type; + __u32 major; + __u32 minor; +}; + +struct bpf_raw_tracepoint_args { + __u64 args[0]; +}; + +/* DIRECT: Skip the FIB rules and go to FIB table associated with device + * OUTPUT: Do lookup from egress perspective; default is ingress + */ +enum { + BPF_FIB_LOOKUP_DIRECT = (1U << 0), + BPF_FIB_LOOKUP_OUTPUT = (1U << 1), +}; + +enum { + BPF_FIB_LKUP_RET_SUCCESS, /* lookup successful */ + BPF_FIB_LKUP_RET_BLACKHOLE, /* dest is blackholed; can be dropped */ + BPF_FIB_LKUP_RET_UNREACHABLE, /* dest is unreachable; can be dropped */ + BPF_FIB_LKUP_RET_PROHIBIT, /* dest not allowed; can be dropped */ + BPF_FIB_LKUP_RET_NOT_FWDED, /* packet is not forwarded */ + BPF_FIB_LKUP_RET_FWD_DISABLED, /* fwding is not enabled on ingress */ + BPF_FIB_LKUP_RET_UNSUPP_LWT, /* fwd requires encapsulation */ + BPF_FIB_LKUP_RET_NO_NEIGH, /* no neighbor entry for nh */ + BPF_FIB_LKUP_RET_FRAG_NEEDED, /* fragmentation required to fwd */ +}; + +struct bpf_fib_lookup { + /* input: network family for lookup (AF_INET, AF_INET6) + * output: network family of egress nexthop + */ + __u8 family; + + /* set if lookup is to consider L4 data - e.g., FIB rules */ + __u8 l4_protocol; + __be16 sport; + __be16 dport; + + union { /* used for MTU check */ + /* input to lookup */ + __u16 tot_len; /* L3 length from network hdr (iph->tot_len) */ + + /* output: MTU value */ + __u16 mtu_result; + }; + /* input: L3 device index for lookup + * output: device index from FIB lookup + */ + __u32 ifindex; + + union { + /* inputs to lookup */ + __u8 tos; /* AF_INET */ + __be32 flowinfo; /* AF_INET6, flow_label + priority */ + + /* output: metric of fib result (IPv4/IPv6 only) */ + __u32 rt_metric; + }; + + union { + __be32 ipv4_src; + __u32 ipv6_src[4]; /* in6_addr; network order */ + }; + + /* input to bpf_fib_lookup, ipv{4,6}_dst is destination address in + * network header. output: bpf_fib_lookup sets to gateway address + * if FIB lookup returns gateway route + */ + union { + __be32 ipv4_dst; + __u32 ipv6_dst[4]; /* in6_addr; network order */ + }; + + /* output */ + __be16 h_vlan_proto; + __be16 h_vlan_TCI; + __u8 smac[6]; /* ETH_ALEN */ + __u8 dmac[6]; /* ETH_ALEN */ +}; + +struct bpf_redir_neigh { + /* network family for lookup (AF_INET, AF_INET6) */ + __u32 nh_family; + /* network address of nexthop; skips fib lookup to find gateway */ + union { + __be32 ipv4_nh; + __u32 ipv6_nh[4]; /* in6_addr; network order */ + }; +}; + +/* bpf_check_mtu flags*/ +enum bpf_check_mtu_flags { + BPF_MTU_CHK_SEGS = (1U << 0), +}; + +enum bpf_check_mtu_ret { + BPF_MTU_CHK_RET_SUCCESS, /* check and lookup successful */ + BPF_MTU_CHK_RET_FRAG_NEEDED, /* fragmentation required to fwd */ + BPF_MTU_CHK_RET_SEGS_TOOBIG, /* GSO re-segmentation needed to fwd */ +}; + +enum bpf_task_fd_type { + BPF_FD_TYPE_RAW_TRACEPOINT, /* tp name */ + BPF_FD_TYPE_TRACEPOINT, /* tp name */ + BPF_FD_TYPE_KPROBE, /* (symbol + offset) or addr */ + BPF_FD_TYPE_KRETPROBE, /* (symbol + offset) or addr */ + BPF_FD_TYPE_UPROBE, /* filename + offset */ + BPF_FD_TYPE_URETPROBE, /* filename + offset */ +}; + +enum { + BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = (1U << 0), + BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = (1U << 1), + BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = (1U << 2), +}; + +struct bpf_flow_keys { + __u16 nhoff; + __u16 thoff; + __u16 addr_proto; /* ETH_P_* of valid addrs */ + __u8 is_frag; + __u8 is_first_frag; + __u8 is_encap; + __u8 ip_proto; + __be16 n_proto; + __be16 sport; + __be16 dport; + union { + struct { + __be32 ipv4_src; + __be32 ipv4_dst; + }; + struct { + __u32 ipv6_src[4]; /* in6_addr; network order */ + __u32 ipv6_dst[4]; /* in6_addr; network order */ + }; + }; + __u32 flags; + __be32 flow_label; +}; + +struct bpf_func_info { + __u32 insn_off; + __u32 type_id; +}; + +#define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10) +#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff) + +struct bpf_line_info { + __u32 insn_off; + __u32 file_name_off; + __u32 line_off; + __u32 line_col; +}; + +struct bpf_spin_lock { + __u32 val; +}; + +struct bpf_sysctl { + __u32 write; /* Sysctl is being read (= 0) or written (= 1). + * Allows 1,2,4-byte read, but no write. + */ + __u32 file_pos; /* Sysctl file position to read from, write to. + * Allows 1,2,4-byte read an 4-byte write. + */ +}; + +struct bpf_sockopt { + __bpf_md_ptr(struct bpf_sock *, sk); + __bpf_md_ptr(void *, optval); + __bpf_md_ptr(void *, optval_end); + + __s32 level; + __s32 optname; + __s32 optlen; + __s32 retval; +}; + +struct bpf_pidns_info { + __u32 pid; + __u32 tgid; +}; + +/* User accessible data for SK_LOOKUP programs. Add new fields at the end. */ +struct bpf_sk_lookup { + __bpf_md_ptr(struct bpf_sock *, sk); /* Selected socket */ + + __u32 family; /* Protocol family (AF_INET, AF_INET6) */ + __u32 protocol; /* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */ + __u32 remote_ip4; /* Network byte order */ + __u32 remote_ip6[4]; /* Network byte order */ + __u32 remote_port; /* Network byte order */ + __u32 local_ip4; /* Network byte order */ + __u32 local_ip6[4]; /* Network byte order */ + __u32 local_port; /* Host byte order */ +}; + +/* + * struct btf_ptr is used for typed pointer representation; the + * type id is used to render the pointer data as the appropriate type + * via the bpf_snprintf_btf() helper described above. A flags field - + * potentially to specify additional details about the BTF pointer + * (rather than its mode of display) - is included for future use. + * Display flags - BTF_F_* - are passed to bpf_snprintf_btf separately. + */ +struct btf_ptr { + void *ptr; + __u32 type_id; + __u32 flags; /* BTF ptr flags; unused at present. */ +}; + +/* + * Flags to control bpf_snprintf_btf() behaviour. + * - BTF_F_COMPACT: no formatting around type information + * - BTF_F_NONAME: no struct/union member names/types + * - BTF_F_PTR_RAW: show raw (unobfuscated) pointer values; + * equivalent to %px. + * - BTF_F_ZERO: show zero-valued struct/union members; they + * are not displayed by default + */ +enum { + BTF_F_COMPACT = (1ULL << 0), + BTF_F_NONAME = (1ULL << 1), + BTF_F_PTR_RAW = (1ULL << 2), + BTF_F_ZERO = (1ULL << 3), +}; + +#endif /* _UAPI__LINUX_BPF_H__ */ diff -Nru dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/btf.h dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/btf.h --- dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/btf.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/btf.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,173 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* Copyright (c) 2018 Facebook */ +#ifndef _UAPI__LINUX_BTF_H__ +#define _UAPI__LINUX_BTF_H__ + +#include + +#define BTF_MAGIC 0xeB9F +#define BTF_VERSION 1 + +struct btf_header { + __u16 magic; + __u8 version; + __u8 flags; + __u32 hdr_len; + + /* All offsets are in bytes relative to the end of this header */ + __u32 type_off; /* offset of type section */ + __u32 type_len; /* length of type section */ + __u32 str_off; /* offset of string section */ + __u32 str_len; /* length of string section */ +}; + +/* Max # of type identifier */ +#define BTF_MAX_TYPE 0x000fffff +/* Max offset into the string section */ +#define BTF_MAX_NAME_OFFSET 0x00ffffff +/* Max # of struct/union/enum members or func args */ +#define BTF_MAX_VLEN 0xffff + +struct btf_type { + __u32 name_off; + /* "info" bits arrangement + * bits 0-15: vlen (e.g. # of struct's members) + * bits 16-23: unused + * bits 24-27: kind (e.g. int, ptr, array...etc) + * bits 28-30: unused + * bit 31: kind_flag, currently used by + * struct, union and fwd + */ + __u32 info; + /* "size" is used by INT, ENUM, STRUCT, UNION and DATASEC. + * "size" tells the size of the type it is describing. + * + * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT, + * FUNC, FUNC_PROTO and VAR. + * "type" is a type_id referring to another type. + */ + union { + __u32 size; + __u32 type; + }; +}; + +#define BTF_INFO_KIND(info) (((info) >> 24) & 0x1f) +#define BTF_INFO_VLEN(info) ((info) & 0xffff) +#define BTF_INFO_KFLAG(info) ((info) >> 31) + +#define BTF_KIND_UNKN 0 /* Unknown */ +#define BTF_KIND_INT 1 /* Integer */ +#define BTF_KIND_PTR 2 /* Pointer */ +#define BTF_KIND_ARRAY 3 /* Array */ +#define BTF_KIND_STRUCT 4 /* Struct */ +#define BTF_KIND_UNION 5 /* Union */ +#define BTF_KIND_ENUM 6 /* Enumeration */ +#define BTF_KIND_FWD 7 /* Forward */ +#define BTF_KIND_TYPEDEF 8 /* Typedef */ +#define BTF_KIND_VOLATILE 9 /* Volatile */ +#define BTF_KIND_CONST 10 /* Const */ +#define BTF_KIND_RESTRICT 11 /* Restrict */ +#define BTF_KIND_FUNC 12 /* Function */ +#define BTF_KIND_FUNC_PROTO 13 /* Function Proto */ +#define BTF_KIND_VAR 14 /* Variable */ +#define BTF_KIND_DATASEC 15 /* Section */ +#define BTF_KIND_FLOAT 16 /* Floating point */ +#define BTF_KIND_MAX BTF_KIND_FLOAT +#define NR_BTF_KINDS (BTF_KIND_MAX + 1) + +/* For some specific BTF_KIND, "struct btf_type" is immediately + * followed by extra data. + */ + +/* BTF_KIND_INT is followed by a u32 and the following + * is the 32 bits arrangement: + */ +#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) +#define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16) +#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff) + +/* Attributes stored in the BTF_INT_ENCODING */ +#define BTF_INT_SIGNED (1 << 0) +#define BTF_INT_CHAR (1 << 1) +#define BTF_INT_BOOL (1 << 2) + +/* BTF_KIND_ENUM is followed by multiple "struct btf_enum". + * The exact number of btf_enum is stored in the vlen (of the + * info in "struct btf_type"). + */ +struct btf_enum { + __u32 name_off; + __s32 val; +}; + +/* BTF_KIND_ARRAY is followed by one "struct btf_array" */ +struct btf_array { + __u32 type; + __u32 index_type; + __u32 nelems; +}; + +/* BTF_KIND_STRUCT and BTF_KIND_UNION are followed + * by multiple "struct btf_member". The exact number + * of btf_member is stored in the vlen (of the info in + * "struct btf_type"). + */ +struct btf_member { + __u32 name_off; + __u32 type; + /* If the type info kind_flag is set, the btf_member offset + * contains both member bitfield size and bit offset. The + * bitfield size is set for bitfield members. If the type + * info kind_flag is not set, the offset contains only bit + * offset. + */ + __u32 offset; +}; + +/* If the struct/union type info kind_flag is set, the + * following two macros are used to access bitfield_size + * and bit_offset from btf_member.offset. + */ +#define BTF_MEMBER_BITFIELD_SIZE(val) ((val) >> 24) +#define BTF_MEMBER_BIT_OFFSET(val) ((val) & 0xffffff) + +/* BTF_KIND_FUNC_PROTO is followed by multiple "struct btf_param". + * The exact number of btf_param is stored in the vlen (of the + * info in "struct btf_type"). + */ +struct btf_param { + __u32 name_off; + __u32 type; +}; + +enum { + BTF_VAR_STATIC = 0, + BTF_VAR_GLOBAL_ALLOCATED = 1, + BTF_VAR_GLOBAL_EXTERN = 2, +}; + +enum btf_func_linkage { + BTF_FUNC_STATIC = 0, + BTF_FUNC_GLOBAL = 1, + BTF_FUNC_EXTERN = 2, +}; + +/* BTF_KIND_VAR is followed by a single "struct btf_var" to describe + * additional information related to the variable such as its linkage. + */ +struct btf_var { + __u32 linkage; +}; + +/* BTF_KIND_DATASEC is followed by multiple "struct btf_var_secinfo" + * to describe all BTF_KIND_VAR types it contains along with it's + * in-section offset as well as size. + */ +struct btf_var_secinfo { + __u32 type; + __u32 offset; + __u32 size; +}; + +#endif /* _UAPI__LINUX_BTF_H__ */ diff -Nru dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/if_link.h dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/if_link.h --- dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/if_link.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/if_link.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,1049 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_IF_LINK_H +#define _UAPI_LINUX_IF_LINK_H + +#include +#include + +/* This struct should be in sync with struct rtnl_link_stats64 */ +struct rtnl_link_stats { + __u32 rx_packets; /* total packets received */ + __u32 tx_packets; /* total packets transmitted */ + __u32 rx_bytes; /* total bytes received */ + __u32 tx_bytes; /* total bytes transmitted */ + __u32 rx_errors; /* bad packets received */ + __u32 tx_errors; /* packet transmit problems */ + __u32 rx_dropped; /* no space in linux buffers */ + __u32 tx_dropped; /* no space available in linux */ + __u32 multicast; /* multicast packets received */ + __u32 collisions; + + /* detailed rx_errors: */ + __u32 rx_length_errors; + __u32 rx_over_errors; /* receiver ring buff overflow */ + __u32 rx_crc_errors; /* recved pkt with crc error */ + __u32 rx_frame_errors; /* recv'd frame alignment error */ + __u32 rx_fifo_errors; /* recv'r fifo overrun */ + __u32 rx_missed_errors; /* receiver missed packet */ + + /* detailed tx_errors */ + __u32 tx_aborted_errors; + __u32 tx_carrier_errors; + __u32 tx_fifo_errors; + __u32 tx_heartbeat_errors; + __u32 tx_window_errors; + + /* for cslip etc */ + __u32 rx_compressed; + __u32 tx_compressed; + + __u32 rx_nohandler; /* dropped, no handler found */ +}; + +/* The main device statistics structure */ +struct rtnl_link_stats64 { + __u64 rx_packets; /* total packets received */ + __u64 tx_packets; /* total packets transmitted */ + __u64 rx_bytes; /* total bytes received */ + __u64 tx_bytes; /* total bytes transmitted */ + __u64 rx_errors; /* bad packets received */ + __u64 tx_errors; /* packet transmit problems */ + __u64 rx_dropped; /* no space in linux buffers */ + __u64 tx_dropped; /* no space available in linux */ + __u64 multicast; /* multicast packets received */ + __u64 collisions; + + /* detailed rx_errors: */ + __u64 rx_length_errors; + __u64 rx_over_errors; /* receiver ring buff overflow */ + __u64 rx_crc_errors; /* recved pkt with crc error */ + __u64 rx_frame_errors; /* recv'd frame alignment error */ + __u64 rx_fifo_errors; /* recv'r fifo overrun */ + __u64 rx_missed_errors; /* receiver missed packet */ + + /* detailed tx_errors */ + __u64 tx_aborted_errors; + __u64 tx_carrier_errors; + __u64 tx_fifo_errors; + __u64 tx_heartbeat_errors; + __u64 tx_window_errors; + + /* for cslip etc */ + __u64 rx_compressed; + __u64 tx_compressed; + + __u64 rx_nohandler; /* dropped, no handler found */ +}; + +/* The struct should be in sync with struct ifmap */ +struct rtnl_link_ifmap { + __u64 mem_start; + __u64 mem_end; + __u64 base_addr; + __u16 irq; + __u8 dma; + __u8 port; +}; + +/* + * IFLA_AF_SPEC + * Contains nested attributes for address family specific attributes. + * Each address family may create a attribute with the address family + * number as type and create its own attribute structure in it. + * + * Example: + * [IFLA_AF_SPEC] = { + * [AF_INET] = { + * [IFLA_INET_CONF] = ..., + * }, + * [AF_INET6] = { + * [IFLA_INET6_FLAGS] = ..., + * [IFLA_INET6_CONF] = ..., + * } + * } + */ + +enum { + IFLA_UNSPEC, + IFLA_ADDRESS, + IFLA_BROADCAST, + IFLA_IFNAME, + IFLA_MTU, + IFLA_LINK, + IFLA_QDISC, + IFLA_STATS, + IFLA_COST, +#define IFLA_COST IFLA_COST + IFLA_PRIORITY, +#define IFLA_PRIORITY IFLA_PRIORITY + IFLA_MASTER, +#define IFLA_MASTER IFLA_MASTER + IFLA_WIRELESS, /* Wireless Extension event - see wireless.h */ +#define IFLA_WIRELESS IFLA_WIRELESS + IFLA_PROTINFO, /* Protocol specific information for a link */ +#define IFLA_PROTINFO IFLA_PROTINFO + IFLA_TXQLEN, +#define IFLA_TXQLEN IFLA_TXQLEN + IFLA_MAP, +#define IFLA_MAP IFLA_MAP + IFLA_WEIGHT, +#define IFLA_WEIGHT IFLA_WEIGHT + IFLA_OPERSTATE, + IFLA_LINKMODE, + IFLA_LINKINFO, +#define IFLA_LINKINFO IFLA_LINKINFO + IFLA_NET_NS_PID, + IFLA_IFALIAS, + IFLA_NUM_VF, /* Number of VFs if device is SR-IOV PF */ + IFLA_VFINFO_LIST, + IFLA_STATS64, + IFLA_VF_PORTS, + IFLA_PORT_SELF, + IFLA_AF_SPEC, + IFLA_GROUP, /* Group the device belongs to */ + IFLA_NET_NS_FD, + IFLA_EXT_MASK, /* Extended info mask, VFs, etc */ + IFLA_PROMISCUITY, /* Promiscuity count: > 0 means acts PROMISC */ +#define IFLA_PROMISCUITY IFLA_PROMISCUITY + IFLA_NUM_TX_QUEUES, + IFLA_NUM_RX_QUEUES, + IFLA_CARRIER, + IFLA_PHYS_PORT_ID, + IFLA_CARRIER_CHANGES, + IFLA_PHYS_SWITCH_ID, + IFLA_LINK_NETNSID, + IFLA_PHYS_PORT_NAME, + IFLA_PROTO_DOWN, + IFLA_GSO_MAX_SEGS, + IFLA_GSO_MAX_SIZE, + IFLA_PAD, + IFLA_XDP, + IFLA_EVENT, + IFLA_NEW_NETNSID, + IFLA_IF_NETNSID, + IFLA_TARGET_NETNSID = IFLA_IF_NETNSID, /* new alias */ + IFLA_CARRIER_UP_COUNT, + IFLA_CARRIER_DOWN_COUNT, + IFLA_NEW_IFINDEX, + IFLA_MIN_MTU, + IFLA_MAX_MTU, + IFLA_PROP_LIST, + IFLA_ALT_IFNAME, /* Alternative ifname */ + IFLA_PERM_ADDRESS, + __IFLA_MAX +}; + + +#define IFLA_MAX (__IFLA_MAX - 1) + +/* backwards compatibility for userspace */ +#ifndef __KERNEL__ +#define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) +#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg)) +#endif + +enum { + IFLA_INET_UNSPEC, + IFLA_INET_CONF, + __IFLA_INET_MAX, +}; + +#define IFLA_INET_MAX (__IFLA_INET_MAX - 1) + +/* ifi_flags. + + IFF_* flags. + + The only change is: + IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are + more not changeable by user. They describe link media + characteristics and set by device driver. + + Comments: + - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid + - If neither of these three flags are set; + the interface is NBMA. + + - IFF_MULTICAST does not mean anything special: + multicasts can be used on all not-NBMA links. + IFF_MULTICAST means that this media uses special encapsulation + for multicast frames. Apparently, all IFF_POINTOPOINT and + IFF_BROADCAST devices are able to use multicasts too. + */ + +/* IFLA_LINK. + For usual devices it is equal ifi_index. + If it is a "virtual interface" (f.e. tunnel), ifi_link + can point to real physical interface (f.e. for bandwidth calculations), + or maybe 0, what means, that real media is unknown (usual + for IPIP tunnels, when route to endpoint is allowed to change) + */ + +/* Subtype attributes for IFLA_PROTINFO */ +enum { + IFLA_INET6_UNSPEC, + IFLA_INET6_FLAGS, /* link flags */ + IFLA_INET6_CONF, /* sysctl parameters */ + IFLA_INET6_STATS, /* statistics */ + IFLA_INET6_MCAST, /* MC things. What of them? */ + IFLA_INET6_CACHEINFO, /* time values and max reasm size */ + IFLA_INET6_ICMP6STATS, /* statistics (icmpv6) */ + IFLA_INET6_TOKEN, /* device token */ + IFLA_INET6_ADDR_GEN_MODE, /* implicit address generator mode */ + __IFLA_INET6_MAX +}; + +#define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1) + +enum in6_addr_gen_mode { + IN6_ADDR_GEN_MODE_EUI64, + IN6_ADDR_GEN_MODE_NONE, + IN6_ADDR_GEN_MODE_STABLE_PRIVACY, + IN6_ADDR_GEN_MODE_RANDOM, +}; + +/* Bridge section */ + +enum { + IFLA_BR_UNSPEC, + IFLA_BR_FORWARD_DELAY, + IFLA_BR_HELLO_TIME, + IFLA_BR_MAX_AGE, + IFLA_BR_AGEING_TIME, + IFLA_BR_STP_STATE, + IFLA_BR_PRIORITY, + IFLA_BR_VLAN_FILTERING, + IFLA_BR_VLAN_PROTOCOL, + IFLA_BR_GROUP_FWD_MASK, + IFLA_BR_ROOT_ID, + IFLA_BR_BRIDGE_ID, + IFLA_BR_ROOT_PORT, + IFLA_BR_ROOT_PATH_COST, + IFLA_BR_TOPOLOGY_CHANGE, + IFLA_BR_TOPOLOGY_CHANGE_DETECTED, + IFLA_BR_HELLO_TIMER, + IFLA_BR_TCN_TIMER, + IFLA_BR_TOPOLOGY_CHANGE_TIMER, + IFLA_BR_GC_TIMER, + IFLA_BR_GROUP_ADDR, + IFLA_BR_FDB_FLUSH, + IFLA_BR_MCAST_ROUTER, + IFLA_BR_MCAST_SNOOPING, + IFLA_BR_MCAST_QUERY_USE_IFADDR, + IFLA_BR_MCAST_QUERIER, + IFLA_BR_MCAST_HASH_ELASTICITY, + IFLA_BR_MCAST_HASH_MAX, + IFLA_BR_MCAST_LAST_MEMBER_CNT, + IFLA_BR_MCAST_STARTUP_QUERY_CNT, + IFLA_BR_MCAST_LAST_MEMBER_INTVL, + IFLA_BR_MCAST_MEMBERSHIP_INTVL, + IFLA_BR_MCAST_QUERIER_INTVL, + IFLA_BR_MCAST_QUERY_INTVL, + IFLA_BR_MCAST_QUERY_RESPONSE_INTVL, + IFLA_BR_MCAST_STARTUP_QUERY_INTVL, + IFLA_BR_NF_CALL_IPTABLES, + IFLA_BR_NF_CALL_IP6TABLES, + IFLA_BR_NF_CALL_ARPTABLES, + IFLA_BR_VLAN_DEFAULT_PVID, + IFLA_BR_PAD, + IFLA_BR_VLAN_STATS_ENABLED, + IFLA_BR_MCAST_STATS_ENABLED, + IFLA_BR_MCAST_IGMP_VERSION, + IFLA_BR_MCAST_MLD_VERSION, + IFLA_BR_VLAN_STATS_PER_PORT, + IFLA_BR_MULTI_BOOLOPT, + __IFLA_BR_MAX, +}; + +#define IFLA_BR_MAX (__IFLA_BR_MAX - 1) + +struct ifla_bridge_id { + __u8 prio[2]; + __u8 addr[6]; /* ETH_ALEN */ +}; + +enum { + BRIDGE_MODE_UNSPEC, + BRIDGE_MODE_HAIRPIN, +}; + +enum { + IFLA_BRPORT_UNSPEC, + IFLA_BRPORT_STATE, /* Spanning tree state */ + IFLA_BRPORT_PRIORITY, /* " priority */ + IFLA_BRPORT_COST, /* " cost */ + IFLA_BRPORT_MODE, /* mode (hairpin) */ + IFLA_BRPORT_GUARD, /* bpdu guard */ + IFLA_BRPORT_PROTECT, /* root port protection */ + IFLA_BRPORT_FAST_LEAVE, /* multicast fast leave */ + IFLA_BRPORT_LEARNING, /* mac learning */ + IFLA_BRPORT_UNICAST_FLOOD, /* flood unicast traffic */ + IFLA_BRPORT_PROXYARP, /* proxy ARP */ + IFLA_BRPORT_LEARNING_SYNC, /* mac learning sync from device */ + IFLA_BRPORT_PROXYARP_WIFI, /* proxy ARP for Wi-Fi */ + IFLA_BRPORT_ROOT_ID, /* designated root */ + IFLA_BRPORT_BRIDGE_ID, /* designated bridge */ + IFLA_BRPORT_DESIGNATED_PORT, + IFLA_BRPORT_DESIGNATED_COST, + IFLA_BRPORT_ID, + IFLA_BRPORT_NO, + IFLA_BRPORT_TOPOLOGY_CHANGE_ACK, + IFLA_BRPORT_CONFIG_PENDING, + IFLA_BRPORT_MESSAGE_AGE_TIMER, + IFLA_BRPORT_FORWARD_DELAY_TIMER, + IFLA_BRPORT_HOLD_TIMER, + IFLA_BRPORT_FLUSH, + IFLA_BRPORT_MULTICAST_ROUTER, + IFLA_BRPORT_PAD, + IFLA_BRPORT_MCAST_FLOOD, + IFLA_BRPORT_MCAST_TO_UCAST, + IFLA_BRPORT_VLAN_TUNNEL, + IFLA_BRPORT_BCAST_FLOOD, + IFLA_BRPORT_GROUP_FWD_MASK, + IFLA_BRPORT_NEIGH_SUPPRESS, + IFLA_BRPORT_ISOLATED, + IFLA_BRPORT_BACKUP_PORT, + IFLA_BRPORT_MRP_RING_OPEN, + IFLA_BRPORT_MRP_IN_OPEN, + __IFLA_BRPORT_MAX +}; +#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) + +struct ifla_cacheinfo { + __u32 max_reasm_len; + __u32 tstamp; /* ipv6InterfaceTable updated timestamp */ + __u32 reachable_time; + __u32 retrans_time; +}; + +enum { + IFLA_INFO_UNSPEC, + IFLA_INFO_KIND, + IFLA_INFO_DATA, + IFLA_INFO_XSTATS, + IFLA_INFO_SLAVE_KIND, + IFLA_INFO_SLAVE_DATA, + __IFLA_INFO_MAX, +}; + +#define IFLA_INFO_MAX (__IFLA_INFO_MAX - 1) + +/* VLAN section */ + +enum { + IFLA_VLAN_UNSPEC, + IFLA_VLAN_ID, + IFLA_VLAN_FLAGS, + IFLA_VLAN_EGRESS_QOS, + IFLA_VLAN_INGRESS_QOS, + IFLA_VLAN_PROTOCOL, + __IFLA_VLAN_MAX, +}; + +#define IFLA_VLAN_MAX (__IFLA_VLAN_MAX - 1) + +struct ifla_vlan_flags { + __u32 flags; + __u32 mask; +}; + +enum { + IFLA_VLAN_QOS_UNSPEC, + IFLA_VLAN_QOS_MAPPING, + __IFLA_VLAN_QOS_MAX +}; + +#define IFLA_VLAN_QOS_MAX (__IFLA_VLAN_QOS_MAX - 1) + +struct ifla_vlan_qos_mapping { + __u32 from; + __u32 to; +}; + +/* MACVLAN section */ +enum { + IFLA_MACVLAN_UNSPEC, + IFLA_MACVLAN_MODE, + IFLA_MACVLAN_FLAGS, + IFLA_MACVLAN_MACADDR_MODE, + IFLA_MACVLAN_MACADDR, + IFLA_MACVLAN_MACADDR_DATA, + IFLA_MACVLAN_MACADDR_COUNT, + IFLA_MACVLAN_BC_QUEUE_LEN, + IFLA_MACVLAN_BC_QUEUE_LEN_USED, + __IFLA_MACVLAN_MAX, +}; + +#define IFLA_MACVLAN_MAX (__IFLA_MACVLAN_MAX - 1) + +enum macvlan_mode { + MACVLAN_MODE_PRIVATE = 1, /* don't talk to other macvlans */ + MACVLAN_MODE_VEPA = 2, /* talk to other ports through ext bridge */ + MACVLAN_MODE_BRIDGE = 4, /* talk to bridge ports directly */ + MACVLAN_MODE_PASSTHRU = 8,/* take over the underlying device */ + MACVLAN_MODE_SOURCE = 16,/* use source MAC address list to assign */ +}; + +enum macvlan_macaddr_mode { + MACVLAN_MACADDR_ADD, + MACVLAN_MACADDR_DEL, + MACVLAN_MACADDR_FLUSH, + MACVLAN_MACADDR_SET, +}; + +#define MACVLAN_FLAG_NOPROMISC 1 + +/* VRF section */ +enum { + IFLA_VRF_UNSPEC, + IFLA_VRF_TABLE, + __IFLA_VRF_MAX +}; + +#define IFLA_VRF_MAX (__IFLA_VRF_MAX - 1) + +enum { + IFLA_VRF_PORT_UNSPEC, + IFLA_VRF_PORT_TABLE, + __IFLA_VRF_PORT_MAX +}; + +#define IFLA_VRF_PORT_MAX (__IFLA_VRF_PORT_MAX - 1) + +/* MACSEC section */ +enum { + IFLA_MACSEC_UNSPEC, + IFLA_MACSEC_SCI, + IFLA_MACSEC_PORT, + IFLA_MACSEC_ICV_LEN, + IFLA_MACSEC_CIPHER_SUITE, + IFLA_MACSEC_WINDOW, + IFLA_MACSEC_ENCODING_SA, + IFLA_MACSEC_ENCRYPT, + IFLA_MACSEC_PROTECT, + IFLA_MACSEC_INC_SCI, + IFLA_MACSEC_ES, + IFLA_MACSEC_SCB, + IFLA_MACSEC_REPLAY_PROTECT, + IFLA_MACSEC_VALIDATION, + IFLA_MACSEC_PAD, + IFLA_MACSEC_OFFLOAD, + __IFLA_MACSEC_MAX, +}; + +#define IFLA_MACSEC_MAX (__IFLA_MACSEC_MAX - 1) + +/* XFRM section */ +enum { + IFLA_XFRM_UNSPEC, + IFLA_XFRM_LINK, + IFLA_XFRM_IF_ID, + __IFLA_XFRM_MAX +}; + +#define IFLA_XFRM_MAX (__IFLA_XFRM_MAX - 1) + +enum macsec_validation_type { + MACSEC_VALIDATE_DISABLED = 0, + MACSEC_VALIDATE_CHECK = 1, + MACSEC_VALIDATE_STRICT = 2, + __MACSEC_VALIDATE_END, + MACSEC_VALIDATE_MAX = __MACSEC_VALIDATE_END - 1, +}; + +enum macsec_offload { + MACSEC_OFFLOAD_OFF = 0, + MACSEC_OFFLOAD_PHY = 1, + MACSEC_OFFLOAD_MAC = 2, + __MACSEC_OFFLOAD_END, + MACSEC_OFFLOAD_MAX = __MACSEC_OFFLOAD_END - 1, +}; + +/* IPVLAN section */ +enum { + IFLA_IPVLAN_UNSPEC, + IFLA_IPVLAN_MODE, + IFLA_IPVLAN_FLAGS, + __IFLA_IPVLAN_MAX +}; + +#define IFLA_IPVLAN_MAX (__IFLA_IPVLAN_MAX - 1) + +enum ipvlan_mode { + IPVLAN_MODE_L2 = 0, + IPVLAN_MODE_L3, + IPVLAN_MODE_L3S, + IPVLAN_MODE_MAX +}; + +#define IPVLAN_F_PRIVATE 0x01 +#define IPVLAN_F_VEPA 0x02 + +/* VXLAN section */ +enum { + IFLA_VXLAN_UNSPEC, + IFLA_VXLAN_ID, + IFLA_VXLAN_GROUP, /* group or remote address */ + IFLA_VXLAN_LINK, + IFLA_VXLAN_LOCAL, + IFLA_VXLAN_TTL, + IFLA_VXLAN_TOS, + IFLA_VXLAN_LEARNING, + IFLA_VXLAN_AGEING, + IFLA_VXLAN_LIMIT, + IFLA_VXLAN_PORT_RANGE, /* source port */ + IFLA_VXLAN_PROXY, + IFLA_VXLAN_RSC, + IFLA_VXLAN_L2MISS, + IFLA_VXLAN_L3MISS, + IFLA_VXLAN_PORT, /* destination port */ + IFLA_VXLAN_GROUP6, + IFLA_VXLAN_LOCAL6, + IFLA_VXLAN_UDP_CSUM, + IFLA_VXLAN_UDP_ZERO_CSUM6_TX, + IFLA_VXLAN_UDP_ZERO_CSUM6_RX, + IFLA_VXLAN_REMCSUM_TX, + IFLA_VXLAN_REMCSUM_RX, + IFLA_VXLAN_GBP, + IFLA_VXLAN_REMCSUM_NOPARTIAL, + IFLA_VXLAN_COLLECT_METADATA, + IFLA_VXLAN_LABEL, + IFLA_VXLAN_GPE, + IFLA_VXLAN_TTL_INHERIT, + IFLA_VXLAN_DF, + __IFLA_VXLAN_MAX +}; +#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1) + +struct ifla_vxlan_port_range { + __be16 low; + __be16 high; +}; + +enum ifla_vxlan_df { + VXLAN_DF_UNSET = 0, + VXLAN_DF_SET, + VXLAN_DF_INHERIT, + __VXLAN_DF_END, + VXLAN_DF_MAX = __VXLAN_DF_END - 1, +}; + +/* GENEVE section */ +enum { + IFLA_GENEVE_UNSPEC, + IFLA_GENEVE_ID, + IFLA_GENEVE_REMOTE, + IFLA_GENEVE_TTL, + IFLA_GENEVE_TOS, + IFLA_GENEVE_PORT, /* destination port */ + IFLA_GENEVE_COLLECT_METADATA, + IFLA_GENEVE_REMOTE6, + IFLA_GENEVE_UDP_CSUM, + IFLA_GENEVE_UDP_ZERO_CSUM6_TX, + IFLA_GENEVE_UDP_ZERO_CSUM6_RX, + IFLA_GENEVE_LABEL, + IFLA_GENEVE_TTL_INHERIT, + IFLA_GENEVE_DF, + __IFLA_GENEVE_MAX +}; +#define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1) + +enum ifla_geneve_df { + GENEVE_DF_UNSET = 0, + GENEVE_DF_SET, + GENEVE_DF_INHERIT, + __GENEVE_DF_END, + GENEVE_DF_MAX = __GENEVE_DF_END - 1, +}; + +/* PPP section */ +enum { + IFLA_PPP_UNSPEC, + IFLA_PPP_DEV_FD, + __IFLA_PPP_MAX +}; +#define IFLA_PPP_MAX (__IFLA_PPP_MAX - 1) + +/* GTP section */ + +enum ifla_gtp_role { + GTP_ROLE_GGSN = 0, + GTP_ROLE_SGSN, +}; + +enum { + IFLA_GTP_UNSPEC, + IFLA_GTP_FD0, + IFLA_GTP_FD1, + IFLA_GTP_PDP_HASHSIZE, + IFLA_GTP_ROLE, + __IFLA_GTP_MAX, +}; +#define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1) + +/* Bonding section */ + +enum { + IFLA_BOND_UNSPEC, + IFLA_BOND_MODE, + IFLA_BOND_ACTIVE_SLAVE, + IFLA_BOND_MIIMON, + IFLA_BOND_UPDELAY, + IFLA_BOND_DOWNDELAY, + IFLA_BOND_USE_CARRIER, + IFLA_BOND_ARP_INTERVAL, + IFLA_BOND_ARP_IP_TARGET, + IFLA_BOND_ARP_VALIDATE, + IFLA_BOND_ARP_ALL_TARGETS, + IFLA_BOND_PRIMARY, + IFLA_BOND_PRIMARY_RESELECT, + IFLA_BOND_FAIL_OVER_MAC, + IFLA_BOND_XMIT_HASH_POLICY, + IFLA_BOND_RESEND_IGMP, + IFLA_BOND_NUM_PEER_NOTIF, + IFLA_BOND_ALL_SLAVES_ACTIVE, + IFLA_BOND_MIN_LINKS, + IFLA_BOND_LP_INTERVAL, + IFLA_BOND_PACKETS_PER_SLAVE, + IFLA_BOND_AD_LACP_RATE, + IFLA_BOND_AD_SELECT, + IFLA_BOND_AD_INFO, + IFLA_BOND_AD_ACTOR_SYS_PRIO, + IFLA_BOND_AD_USER_PORT_KEY, + IFLA_BOND_AD_ACTOR_SYSTEM, + IFLA_BOND_TLB_DYNAMIC_LB, + IFLA_BOND_PEER_NOTIF_DELAY, + __IFLA_BOND_MAX, +}; + +#define IFLA_BOND_MAX (__IFLA_BOND_MAX - 1) + +enum { + IFLA_BOND_AD_INFO_UNSPEC, + IFLA_BOND_AD_INFO_AGGREGATOR, + IFLA_BOND_AD_INFO_NUM_PORTS, + IFLA_BOND_AD_INFO_ACTOR_KEY, + IFLA_BOND_AD_INFO_PARTNER_KEY, + IFLA_BOND_AD_INFO_PARTNER_MAC, + __IFLA_BOND_AD_INFO_MAX, +}; + +#define IFLA_BOND_AD_INFO_MAX (__IFLA_BOND_AD_INFO_MAX - 1) + +enum { + IFLA_BOND_SLAVE_UNSPEC, + IFLA_BOND_SLAVE_STATE, + IFLA_BOND_SLAVE_MII_STATUS, + IFLA_BOND_SLAVE_LINK_FAILURE_COUNT, + IFLA_BOND_SLAVE_PERM_HWADDR, + IFLA_BOND_SLAVE_QUEUE_ID, + IFLA_BOND_SLAVE_AD_AGGREGATOR_ID, + IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE, + IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE, + __IFLA_BOND_SLAVE_MAX, +}; + +#define IFLA_BOND_SLAVE_MAX (__IFLA_BOND_SLAVE_MAX - 1) + +/* SR-IOV virtual function management section */ + +enum { + IFLA_VF_INFO_UNSPEC, + IFLA_VF_INFO, + __IFLA_VF_INFO_MAX, +}; + +#define IFLA_VF_INFO_MAX (__IFLA_VF_INFO_MAX - 1) + +enum { + IFLA_VF_UNSPEC, + IFLA_VF_MAC, /* Hardware queue specific attributes */ + IFLA_VF_VLAN, /* VLAN ID and QoS */ + IFLA_VF_TX_RATE, /* Max TX Bandwidth Allocation */ + IFLA_VF_SPOOFCHK, /* Spoof Checking on/off switch */ + IFLA_VF_LINK_STATE, /* link state enable/disable/auto switch */ + IFLA_VF_RATE, /* Min and Max TX Bandwidth Allocation */ + IFLA_VF_RSS_QUERY_EN, /* RSS Redirection Table and Hash Key query + * on/off switch + */ + IFLA_VF_STATS, /* network device statistics */ + IFLA_VF_TRUST, /* Trust VF */ + IFLA_VF_IB_NODE_GUID, /* VF Infiniband node GUID */ + IFLA_VF_IB_PORT_GUID, /* VF Infiniband port GUID */ + IFLA_VF_VLAN_LIST, /* nested list of vlans, option for QinQ */ + IFLA_VF_BROADCAST, /* VF broadcast */ + __IFLA_VF_MAX, +}; + +#define IFLA_VF_MAX (__IFLA_VF_MAX - 1) + +struct ifla_vf_mac { + __u32 vf; + __u8 mac[32]; /* MAX_ADDR_LEN */ +}; + +struct ifla_vf_broadcast { + __u8 broadcast[32]; +}; + +struct ifla_vf_vlan { + __u32 vf; + __u32 vlan; /* 0 - 4095, 0 disables VLAN filter */ + __u32 qos; +}; + +enum { + IFLA_VF_VLAN_INFO_UNSPEC, + IFLA_VF_VLAN_INFO, /* VLAN ID, QoS and VLAN protocol */ + __IFLA_VF_VLAN_INFO_MAX, +}; + +#define IFLA_VF_VLAN_INFO_MAX (__IFLA_VF_VLAN_INFO_MAX - 1) +#define MAX_VLAN_LIST_LEN 1 + +struct ifla_vf_vlan_info { + __u32 vf; + __u32 vlan; /* 0 - 4095, 0 disables VLAN filter */ + __u32 qos; + __be16 vlan_proto; /* VLAN protocol either 802.1Q or 802.1ad */ +}; + +struct ifla_vf_tx_rate { + __u32 vf; + __u32 rate; /* Max TX bandwidth in Mbps, 0 disables throttling */ +}; + +struct ifla_vf_rate { + __u32 vf; + __u32 min_tx_rate; /* Min Bandwidth in Mbps */ + __u32 max_tx_rate; /* Max Bandwidth in Mbps */ +}; + +struct ifla_vf_spoofchk { + __u32 vf; + __u32 setting; +}; + +struct ifla_vf_guid { + __u32 vf; + __u64 guid; +}; + +enum { + IFLA_VF_LINK_STATE_AUTO, /* link state of the uplink */ + IFLA_VF_LINK_STATE_ENABLE, /* link always up */ + IFLA_VF_LINK_STATE_DISABLE, /* link always down */ + __IFLA_VF_LINK_STATE_MAX, +}; + +struct ifla_vf_link_state { + __u32 vf; + __u32 link_state; +}; + +struct ifla_vf_rss_query_en { + __u32 vf; + __u32 setting; +}; + +enum { + IFLA_VF_STATS_RX_PACKETS, + IFLA_VF_STATS_TX_PACKETS, + IFLA_VF_STATS_RX_BYTES, + IFLA_VF_STATS_TX_BYTES, + IFLA_VF_STATS_BROADCAST, + IFLA_VF_STATS_MULTICAST, + IFLA_VF_STATS_PAD, + IFLA_VF_STATS_RX_DROPPED, + IFLA_VF_STATS_TX_DROPPED, + __IFLA_VF_STATS_MAX, +}; + +#define IFLA_VF_STATS_MAX (__IFLA_VF_STATS_MAX - 1) + +struct ifla_vf_trust { + __u32 vf; + __u32 setting; +}; + +/* VF ports management section + * + * Nested layout of set/get msg is: + * + * [IFLA_NUM_VF] + * [IFLA_VF_PORTS] + * [IFLA_VF_PORT] + * [IFLA_PORT_*], ... + * [IFLA_VF_PORT] + * [IFLA_PORT_*], ... + * ... + * [IFLA_PORT_SELF] + * [IFLA_PORT_*], ... + */ + +enum { + IFLA_VF_PORT_UNSPEC, + IFLA_VF_PORT, /* nest */ + __IFLA_VF_PORT_MAX, +}; + +#define IFLA_VF_PORT_MAX (__IFLA_VF_PORT_MAX - 1) + +enum { + IFLA_PORT_UNSPEC, + IFLA_PORT_VF, /* __u32 */ + IFLA_PORT_PROFILE, /* string */ + IFLA_PORT_VSI_TYPE, /* 802.1Qbg (pre-)standard VDP */ + IFLA_PORT_INSTANCE_UUID, /* binary UUID */ + IFLA_PORT_HOST_UUID, /* binary UUID */ + IFLA_PORT_REQUEST, /* __u8 */ + IFLA_PORT_RESPONSE, /* __u16, output only */ + __IFLA_PORT_MAX, +}; + +#define IFLA_PORT_MAX (__IFLA_PORT_MAX - 1) + +#define PORT_PROFILE_MAX 40 +#define PORT_UUID_MAX 16 +#define PORT_SELF_VF -1 + +enum { + PORT_REQUEST_PREASSOCIATE = 0, + PORT_REQUEST_PREASSOCIATE_RR, + PORT_REQUEST_ASSOCIATE, + PORT_REQUEST_DISASSOCIATE, +}; + +enum { + PORT_VDP_RESPONSE_SUCCESS = 0, + PORT_VDP_RESPONSE_INVALID_FORMAT, + PORT_VDP_RESPONSE_INSUFFICIENT_RESOURCES, + PORT_VDP_RESPONSE_UNUSED_VTID, + PORT_VDP_RESPONSE_VTID_VIOLATION, + PORT_VDP_RESPONSE_VTID_VERSION_VIOALTION, + PORT_VDP_RESPONSE_OUT_OF_SYNC, + /* 0x08-0xFF reserved for future VDP use */ + PORT_PROFILE_RESPONSE_SUCCESS = 0x100, + PORT_PROFILE_RESPONSE_INPROGRESS, + PORT_PROFILE_RESPONSE_INVALID, + PORT_PROFILE_RESPONSE_BADSTATE, + PORT_PROFILE_RESPONSE_INSUFFICIENT_RESOURCES, + PORT_PROFILE_RESPONSE_ERROR, +}; + +struct ifla_port_vsi { + __u8 vsi_mgr_id; + __u8 vsi_type_id[3]; + __u8 vsi_type_version; + __u8 pad[3]; +}; + + +/* IPoIB section */ + +enum { + IFLA_IPOIB_UNSPEC, + IFLA_IPOIB_PKEY, + IFLA_IPOIB_MODE, + IFLA_IPOIB_UMCAST, + __IFLA_IPOIB_MAX +}; + +enum { + IPOIB_MODE_DATAGRAM = 0, /* using unreliable datagram QPs */ + IPOIB_MODE_CONNECTED = 1, /* using connected QPs */ +}; + +#define IFLA_IPOIB_MAX (__IFLA_IPOIB_MAX - 1) + + +/* HSR section */ + +enum { + IFLA_HSR_UNSPEC, + IFLA_HSR_SLAVE1, + IFLA_HSR_SLAVE2, + IFLA_HSR_MULTICAST_SPEC, /* Last byte of supervision addr */ + IFLA_HSR_SUPERVISION_ADDR, /* Supervision frame multicast addr */ + IFLA_HSR_SEQ_NR, + IFLA_HSR_VERSION, /* HSR version */ + __IFLA_HSR_MAX, +}; + +#define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1) + +/* STATS section */ + +struct if_stats_msg { + __u8 family; + __u8 pad1; + __u16 pad2; + __u32 ifindex; + __u32 filter_mask; +}; + +/* A stats attribute can be netdev specific or a global stat. + * For netdev stats, lets use the prefix IFLA_STATS_LINK_* + */ +enum { + IFLA_STATS_UNSPEC, /* also used as 64bit pad attribute */ + IFLA_STATS_LINK_64, + IFLA_STATS_LINK_XSTATS, + IFLA_STATS_LINK_XSTATS_SLAVE, + IFLA_STATS_LINK_OFFLOAD_XSTATS, + IFLA_STATS_AF_SPEC, + __IFLA_STATS_MAX, +}; + +#define IFLA_STATS_MAX (__IFLA_STATS_MAX - 1) + +#define IFLA_STATS_FILTER_BIT(ATTR) (1 << (ATTR - 1)) + +/* These are embedded into IFLA_STATS_LINK_XSTATS: + * [IFLA_STATS_LINK_XSTATS] + * -> [LINK_XSTATS_TYPE_xxx] + * -> [rtnl link type specific attributes] + */ +enum { + LINK_XSTATS_TYPE_UNSPEC, + LINK_XSTATS_TYPE_BRIDGE, + LINK_XSTATS_TYPE_BOND, + __LINK_XSTATS_TYPE_MAX +}; +#define LINK_XSTATS_TYPE_MAX (__LINK_XSTATS_TYPE_MAX - 1) + +/* These are stats embedded into IFLA_STATS_LINK_OFFLOAD_XSTATS */ +enum { + IFLA_OFFLOAD_XSTATS_UNSPEC, + IFLA_OFFLOAD_XSTATS_CPU_HIT, /* struct rtnl_link_stats64 */ + __IFLA_OFFLOAD_XSTATS_MAX +}; +#define IFLA_OFFLOAD_XSTATS_MAX (__IFLA_OFFLOAD_XSTATS_MAX - 1) + +/* XDP section */ + +#define XDP_FLAGS_UPDATE_IF_NOEXIST (1U << 0) +#define XDP_FLAGS_SKB_MODE (1U << 1) +#define XDP_FLAGS_DRV_MODE (1U << 2) +#define XDP_FLAGS_HW_MODE (1U << 3) +#define XDP_FLAGS_REPLACE (1U << 4) +#define XDP_FLAGS_MODES (XDP_FLAGS_SKB_MODE | \ + XDP_FLAGS_DRV_MODE | \ + XDP_FLAGS_HW_MODE) +#define XDP_FLAGS_MASK (XDP_FLAGS_UPDATE_IF_NOEXIST | \ + XDP_FLAGS_MODES | XDP_FLAGS_REPLACE) + +/* These are stored into IFLA_XDP_ATTACHED on dump. */ +enum { + XDP_ATTACHED_NONE = 0, + XDP_ATTACHED_DRV, + XDP_ATTACHED_SKB, + XDP_ATTACHED_HW, + XDP_ATTACHED_MULTI, +}; + +enum { + IFLA_XDP_UNSPEC, + IFLA_XDP_FD, + IFLA_XDP_ATTACHED, + IFLA_XDP_FLAGS, + IFLA_XDP_PROG_ID, + IFLA_XDP_DRV_PROG_ID, + IFLA_XDP_SKB_PROG_ID, + IFLA_XDP_HW_PROG_ID, + IFLA_XDP_EXPECTED_FD, + __IFLA_XDP_MAX, +}; + +#define IFLA_XDP_MAX (__IFLA_XDP_MAX - 1) + +enum { + IFLA_EVENT_NONE, + IFLA_EVENT_REBOOT, /* internal reset / reboot */ + IFLA_EVENT_FEATURES, /* change in offload features */ + IFLA_EVENT_BONDING_FAILOVER, /* change in active slave */ + IFLA_EVENT_NOTIFY_PEERS, /* re-sent grat. arp/ndisc */ + IFLA_EVENT_IGMP_RESEND, /* re-sent IGMP JOIN */ + IFLA_EVENT_BONDING_OPTIONS, /* change in bonding options */ +}; + +/* tun section */ + +enum { + IFLA_TUN_UNSPEC, + IFLA_TUN_OWNER, + IFLA_TUN_GROUP, + IFLA_TUN_TYPE, + IFLA_TUN_PI, + IFLA_TUN_VNET_HDR, + IFLA_TUN_PERSIST, + IFLA_TUN_MULTI_QUEUE, + IFLA_TUN_NUM_QUEUES, + IFLA_TUN_NUM_DISABLED_QUEUES, + __IFLA_TUN_MAX, +}; + +#define IFLA_TUN_MAX (__IFLA_TUN_MAX - 1) + +/* rmnet section */ + +#define RMNET_FLAGS_INGRESS_DEAGGREGATION (1U << 0) +#define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1) +#define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2) +#define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3) + +enum { + IFLA_RMNET_UNSPEC, + IFLA_RMNET_MUX_ID, + IFLA_RMNET_FLAGS, + __IFLA_RMNET_MAX, +}; + +#define IFLA_RMNET_MAX (__IFLA_RMNET_MAX - 1) + +struct ifla_rmnet_flags { + __u32 flags; + __u32 mask; +}; + +#endif /* _UAPI_LINUX_IF_LINK_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/if_xdp.h dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/if_xdp.h --- dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/if_xdp.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/if_xdp.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,111 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * if_xdp: XDP socket user-space interface + * Copyright(c) 2018 Intel Corporation. + * + * Author(s): Björn Töpel + * Magnus Karlsson + */ + +#ifndef _LINUX_IF_XDP_H +#define _LINUX_IF_XDP_H + +#include + +/* Options for the sxdp_flags field */ +#define XDP_SHARED_UMEM (1 << 0) +#define XDP_COPY (1 << 1) /* Force copy-mode */ +#define XDP_ZEROCOPY (1 << 2) /* Force zero-copy mode */ +/* If this option is set, the driver might go sleep and in that case + * the XDP_RING_NEED_WAKEUP flag in the fill and/or Tx rings will be + * set. If it is set, the application need to explicitly wake up the + * driver with a poll() (Rx and Tx) or sendto() (Tx only). If you are + * running the driver and the application on the same core, you should + * use this option so that the kernel will yield to the user space + * application. + */ +#define XDP_USE_NEED_WAKEUP (1 << 3) + +/* Flags for xsk_umem_config flags */ +#define XDP_UMEM_UNALIGNED_CHUNK_FLAG (1 << 0) + +struct sockaddr_xdp { + __u16 sxdp_family; + __u16 sxdp_flags; + __u32 sxdp_ifindex; + __u32 sxdp_queue_id; + __u32 sxdp_shared_umem_fd; +}; + +/* XDP_RING flags */ +#define XDP_RING_NEED_WAKEUP (1 << 0) + +struct xdp_ring_offset { + __u64 producer; + __u64 consumer; + __u64 desc; + __u64 flags; +}; + +struct xdp_mmap_offsets { + struct xdp_ring_offset rx; + struct xdp_ring_offset tx; + struct xdp_ring_offset fr; /* Fill */ + struct xdp_ring_offset cr; /* Completion */ +}; + +/* XDP socket options */ +#define XDP_MMAP_OFFSETS 1 +#define XDP_RX_RING 2 +#define XDP_TX_RING 3 +#define XDP_UMEM_REG 4 +#define XDP_UMEM_FILL_RING 5 +#define XDP_UMEM_COMPLETION_RING 6 +#define XDP_STATISTICS 7 +#define XDP_OPTIONS 8 + +struct xdp_umem_reg { + __u64 addr; /* Start of packet data area */ + __u64 len; /* Length of packet data area */ + __u32 chunk_size; + __u32 headroom; + __u32 flags; +}; + +struct xdp_statistics { + __u64 rx_dropped; /* Dropped for other reasons */ + __u64 rx_invalid_descs; /* Dropped due to invalid descriptor */ + __u64 tx_invalid_descs; /* Dropped due to invalid descriptor */ + __u64 rx_ring_full; /* Dropped due to rx ring being full */ + __u64 rx_fill_ring_empty_descs; /* Failed to retrieve item from fill ring */ + __u64 tx_ring_empty_descs; /* Failed to retrieve item from tx ring */ +}; + +struct xdp_options { + __u32 flags; +}; + +/* Flags for the flags field of struct xdp_options */ +#define XDP_OPTIONS_ZEROCOPY (1 << 0) + +/* Pgoff for mmaping the rings */ +#define XDP_PGOFF_RX_RING 0 +#define XDP_PGOFF_TX_RING 0x80000000 +#define XDP_UMEM_PGOFF_FILL_RING 0x100000000ULL +#define XDP_UMEM_PGOFF_COMPLETION_RING 0x180000000ULL + +/* Masks for unaligned chunks mode */ +#define XSK_UNALIGNED_BUF_OFFSET_SHIFT 48 +#define XSK_UNALIGNED_BUF_ADDR_MASK \ + ((1ULL << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1) + +/* Rx/Tx descriptor */ +struct xdp_desc { + __u64 addr; + __u32 len; + __u32 options; +}; + +/* UMEM descriptor is __u64 */ + +#endif /* _LINUX_IF_XDP_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/netlink.h dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/netlink.h --- dwarves-dfsg-1.10/lib/bpf/include/uapi/linux/netlink.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/include/uapi/linux/netlink.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,252 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI__LINUX_NETLINK_H +#define _UAPI__LINUX_NETLINK_H + +#include +#include /* for __kernel_sa_family_t */ +#include + +#define NETLINK_ROUTE 0 /* Routing/device hook */ +#define NETLINK_UNUSED 1 /* Unused number */ +#define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */ +#define NETLINK_FIREWALL 3 /* Unused number, formerly ip_queue */ +#define NETLINK_SOCK_DIAG 4 /* socket monitoring */ +#define NETLINK_NFLOG 5 /* netfilter/iptables ULOG */ +#define NETLINK_XFRM 6 /* ipsec */ +#define NETLINK_SELINUX 7 /* SELinux event notifications */ +#define NETLINK_ISCSI 8 /* Open-iSCSI */ +#define NETLINK_AUDIT 9 /* auditing */ +#define NETLINK_FIB_LOOKUP 10 +#define NETLINK_CONNECTOR 11 +#define NETLINK_NETFILTER 12 /* netfilter subsystem */ +#define NETLINK_IP6_FW 13 +#define NETLINK_DNRTMSG 14 /* DECnet routing messages */ +#define NETLINK_KOBJECT_UEVENT 15 /* Kernel messages to userspace */ +#define NETLINK_GENERIC 16 +/* leave room for NETLINK_DM (DM Events) */ +#define NETLINK_SCSITRANSPORT 18 /* SCSI Transports */ +#define NETLINK_ECRYPTFS 19 +#define NETLINK_RDMA 20 +#define NETLINK_CRYPTO 21 /* Crypto layer */ +#define NETLINK_SMC 22 /* SMC monitoring */ + +#define NETLINK_INET_DIAG NETLINK_SOCK_DIAG + +#define MAX_LINKS 32 + +struct sockaddr_nl { + __kernel_sa_family_t nl_family; /* AF_NETLINK */ + unsigned short nl_pad; /* zero */ + __u32 nl_pid; /* port ID */ + __u32 nl_groups; /* multicast groups mask */ +}; + +struct nlmsghdr { + __u32 nlmsg_len; /* Length of message including header */ + __u16 nlmsg_type; /* Message content */ + __u16 nlmsg_flags; /* Additional flags */ + __u32 nlmsg_seq; /* Sequence number */ + __u32 nlmsg_pid; /* Sending process port ID */ +}; + +/* Flags values */ + +#define NLM_F_REQUEST 0x01 /* It is request message. */ +#define NLM_F_MULTI 0x02 /* Multipart message, terminated by NLMSG_DONE */ +#define NLM_F_ACK 0x04 /* Reply with ack, with zero or error code */ +#define NLM_F_ECHO 0x08 /* Echo this request */ +#define NLM_F_DUMP_INTR 0x10 /* Dump was inconsistent due to sequence change */ +#define NLM_F_DUMP_FILTERED 0x20 /* Dump was filtered as requested */ + +/* Modifiers to GET request */ +#define NLM_F_ROOT 0x100 /* specify tree root */ +#define NLM_F_MATCH 0x200 /* return all matching */ +#define NLM_F_ATOMIC 0x400 /* atomic GET */ +#define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH) + +/* Modifiers to NEW request */ +#define NLM_F_REPLACE 0x100 /* Override existing */ +#define NLM_F_EXCL 0x200 /* Do not touch, if it exists */ +#define NLM_F_CREATE 0x400 /* Create, if it does not exist */ +#define NLM_F_APPEND 0x800 /* Add to end of list */ + +/* Modifiers to DELETE request */ +#define NLM_F_NONREC 0x100 /* Do not delete recursively */ + +/* Flags for ACK message */ +#define NLM_F_CAPPED 0x100 /* request was capped */ +#define NLM_F_ACK_TLVS 0x200 /* extended ACK TVLs were included */ + +/* + 4.4BSD ADD NLM_F_CREATE|NLM_F_EXCL + 4.4BSD CHANGE NLM_F_REPLACE + + True CHANGE NLM_F_CREATE|NLM_F_REPLACE + Append NLM_F_CREATE + Check NLM_F_EXCL + */ + +#define NLMSG_ALIGNTO 4U +#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) ) +#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr))) +#define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN) +#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len)) +#define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0))) +#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \ + (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) +#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \ + (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ + (nlh)->nlmsg_len <= (len)) +#define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len))) + +#define NLMSG_NOOP 0x1 /* Nothing. */ +#define NLMSG_ERROR 0x2 /* Error */ +#define NLMSG_DONE 0x3 /* End of a dump */ +#define NLMSG_OVERRUN 0x4 /* Data lost */ + +#define NLMSG_MIN_TYPE 0x10 /* < 0x10: reserved control messages */ + +struct nlmsgerr { + int error; + struct nlmsghdr msg; + /* + * followed by the message contents unless NETLINK_CAP_ACK was set + * or the ACK indicates success (error == 0) + * message length is aligned with NLMSG_ALIGN() + */ + /* + * followed by TLVs defined in enum nlmsgerr_attrs + * if NETLINK_EXT_ACK was set + */ +}; + +/** + * enum nlmsgerr_attrs - nlmsgerr attributes + * @NLMSGERR_ATTR_UNUSED: unused + * @NLMSGERR_ATTR_MSG: error message string (string) + * @NLMSGERR_ATTR_OFFS: offset of the invalid attribute in the original + * message, counting from the beginning of the header (u32) + * @NLMSGERR_ATTR_COOKIE: arbitrary subsystem specific cookie to + * be used - in the success case - to identify a created + * object or operation or similar (binary) + * @__NLMSGERR_ATTR_MAX: number of attributes + * @NLMSGERR_ATTR_MAX: highest attribute number + */ +enum nlmsgerr_attrs { + NLMSGERR_ATTR_UNUSED, + NLMSGERR_ATTR_MSG, + NLMSGERR_ATTR_OFFS, + NLMSGERR_ATTR_COOKIE, + + __NLMSGERR_ATTR_MAX, + NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1 +}; + +#define NETLINK_ADD_MEMBERSHIP 1 +#define NETLINK_DROP_MEMBERSHIP 2 +#define NETLINK_PKTINFO 3 +#define NETLINK_BROADCAST_ERROR 4 +#define NETLINK_NO_ENOBUFS 5 +#ifndef __KERNEL__ +#define NETLINK_RX_RING 6 +#define NETLINK_TX_RING 7 +#endif +#define NETLINK_LISTEN_ALL_NSID 8 +#define NETLINK_LIST_MEMBERSHIPS 9 +#define NETLINK_CAP_ACK 10 +#define NETLINK_EXT_ACK 11 +#define NETLINK_GET_STRICT_CHK 12 + +struct nl_pktinfo { + __u32 group; +}; + +struct nl_mmap_req { + unsigned int nm_block_size; + unsigned int nm_block_nr; + unsigned int nm_frame_size; + unsigned int nm_frame_nr; +}; + +struct nl_mmap_hdr { + unsigned int nm_status; + unsigned int nm_len; + __u32 nm_group; + /* credentials */ + __u32 nm_pid; + __u32 nm_uid; + __u32 nm_gid; +}; + +#ifndef __KERNEL__ +enum nl_mmap_status { + NL_MMAP_STATUS_UNUSED, + NL_MMAP_STATUS_RESERVED, + NL_MMAP_STATUS_VALID, + NL_MMAP_STATUS_COPY, + NL_MMAP_STATUS_SKIP, +}; + +#define NL_MMAP_MSG_ALIGNMENT NLMSG_ALIGNTO +#define NL_MMAP_MSG_ALIGN(sz) __ALIGN_KERNEL(sz, NL_MMAP_MSG_ALIGNMENT) +#define NL_MMAP_HDRLEN NL_MMAP_MSG_ALIGN(sizeof(struct nl_mmap_hdr)) +#endif + +#define NET_MAJOR 36 /* Major 36 is reserved for networking */ + +enum { + NETLINK_UNCONNECTED = 0, + NETLINK_CONNECTED, +}; + +/* + * <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)--> + * +---------------------+- - -+- - - - - - - - - -+- - -+ + * | Header | Pad | Payload | Pad | + * | (struct nlattr) | ing | | ing | + * +---------------------+- - -+- - - - - - - - - -+- - -+ + * <-------------- nlattr->nla_len --------------> + */ + +struct nlattr { + __u16 nla_len; + __u16 nla_type; +}; + +/* + * nla_type (16 bits) + * +---+---+-------------------------------+ + * | N | O | Attribute Type | + * +---+---+-------------------------------+ + * N := Carries nested attributes + * O := Payload stored in network byte order + * + * Note: The N and O flag are mutually exclusive. + */ +#define NLA_F_NESTED (1 << 15) +#define NLA_F_NET_BYTEORDER (1 << 14) +#define NLA_TYPE_MASK ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER) + +#define NLA_ALIGNTO 4 +#define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1)) +#define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr))) + +/* Generic 32 bitflags attribute content sent to the kernel. + * + * The value is a bitmap that defines the values being set + * The selector is a bitmask that defines which value is legit + * + * Examples: + * value = 0x0, and selector = 0x1 + * implies we are selecting bit 1 and we want to set its value to 0. + * + * value = 0x2, and selector = 0x2 + * implies we are selecting bit 2 and we want to set its value to 1. + * + */ +struct nla_bitfield32 { + __u32 value; + __u32 selector; +}; + +#endif /* _UAPI__LINUX_NETLINK_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/.lgtm.yml dwarves-dfsg-1.21/lib/bpf/.lgtm.yml --- dwarves-dfsg-1.10/lib/bpf/.lgtm.yml 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/.lgtm.yml 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,14 @@ +# vi: set ts=2 sw=2: +extraction: + cpp: + prepare: + packages: + - libelf-dev + - pkg-config + after_prepare: + # As the buildsystem detection by LGTM is performed _only_ during the + # 'configure' phase, we need to trick LGTM we use a supported build + # system (configure, meson, cmake, etc.). This way LGTM correctly detects + # that our sources are in the src/ subfolder. + - touch src/configure + - chmod +x src/configure diff -Nru dwarves-dfsg-1.10/lib/bpf/LICENSE dwarves-dfsg-1.21/lib/bpf/LICENSE --- dwarves-dfsg-1.10/lib/bpf/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/LICENSE 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1 @@ +LGPL-2.1 OR BSD-2-Clause diff -Nru dwarves-dfsg-1.10/lib/bpf/LICENSE.BSD-2-Clause dwarves-dfsg-1.21/lib/bpf/LICENSE.BSD-2-Clause --- dwarves-dfsg-1.10/lib/bpf/LICENSE.BSD-2-Clause 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/LICENSE.BSD-2-Clause 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,32 @@ +Valid-License-Identifier: BSD-2-Clause +SPDX-URL: https://spdx.org/licenses/BSD-2-Clause.html +Usage-Guide: + To use the BSD 2-clause "Simplified" License put the following SPDX + tag/value pair into a comment according to the placement guidelines in + the licensing rules documentation: + SPDX-License-Identifier: BSD-2-Clause +License-Text: + +Copyright (c) . All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff -Nru dwarves-dfsg-1.10/lib/bpf/LICENSE.LGPL-2.1 dwarves-dfsg-1.21/lib/bpf/LICENSE.LGPL-2.1 --- dwarves-dfsg-1.10/lib/bpf/LICENSE.LGPL-2.1 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/LICENSE.LGPL-2.1 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,503 @@ +Valid-License-Identifier: LGPL-2.1 +Valid-License-Identifier: LGPL-2.1+ +SPDX-URL: https://spdx.org/licenses/LGPL-2.1.html +Usage-Guide: + To use this license in source code, put one of the following SPDX + tag/value pairs into a comment according to the placement + guidelines in the licensing rules documentation. + For 'GNU Lesser General Public License (LGPL) version 2.1 only' use: + SPDX-License-Identifier: LGPL-2.1 + For 'GNU Lesser General Public License (LGPL) version 2.1 or any later + version' use: + SPDX-License-Identifier: LGPL-2.1+ +License-Text: + +GNU LESSER GENERAL PUBLIC LICENSE +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as +the successor of the GNU Library Public License, version 2, hence the +version number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to +share and change it. By contrast, the GNU General Public Licenses are +intended to guarantee your freedom to share and change free software--to +make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some specially +designated software packages--typically libraries--of the Free Software +Foundation and other authors who decide to use it. You can use it too, but +we suggest you first think carefully about whether this license or the +ordinary General Public License is the better strategy to use in any +particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not +price. Our General Public Licenses are designed to make sure that you have +the freedom to distribute copies of free software (and charge for this +service if you wish); that you receive source code or can get it if you +want it; that you can change the software and use pieces of it in new free +programs; and that you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for you if +you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for +a fee, you must give the recipients all the rights that we gave you. You +must make sure that they, too, receive or can get the source code. If you +link other code with the library, you must provide complete object files to +the recipients, so that they can relink them with the library after making +changes to the library and recompiling it. And you must show them these +terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no +warranty for the free library. Also, if the library is modified by someone +else and passed on, the recipients should know that what they have is not +the original version, so that the original author's reputation will not be +affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any +free program. We wish to make sure that a company cannot effectively +restrict the users of a free program by obtaining a restrictive license +from a patent holder. Therefore, we insist that any patent license obtained +for a version of the library must be consistent with the full freedom of +use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary GNU +General Public License. This license, the GNU Lesser General Public +License, applies to certain designated libraries, and is quite different +from the ordinary General Public License. We use this license for certain +libraries in order to permit linking those libraries into non-free +programs. + +When a program is linked with a library, whether statically or using a +shared library, the combination of the two is legally speaking a combined +work, a derivative of the original library. The ordinary General Public +License therefore permits such linking only if the entire combination fits +its criteria of freedom. The Lesser General Public License permits more lax +criteria for linking other code with the library. + +We call this license the "Lesser" General Public License because it does +Less to protect the user's freedom than the ordinary General Public +License. It also provides other free software developers Less of an +advantage over competing non-free programs. These disadvantages are the +reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + +For example, on rare occasions, there may be a special need to encourage +the widest possible use of a certain library, so that it becomes a de-facto +standard. To achieve this, non-free programs must be allowed to use the +library. A more frequent case is that a free library does the same job as +widely used non-free libraries. In this case, there is little to gain by +limiting the free library to free software only, so we use the Lesser +General Public License. + +In other cases, permission to use a particular library in non-free programs +enables a greater number of people to use a large body of free +software. For example, permission to use the GNU C Library in non-free +programs enables many more people to use the whole GNU operating system, as +well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' +freedom, it does ensure that the user of a program that is linked with the +Library has the freedom and the wherewithal to run that program using a +modified version of the Library. + +The precise terms and conditions for copying, distribution and modification +follow. Pay close attention to the difference between a "work based on the +library" and a "work that uses the library". The former contains code +derived from the library, whereas the latter must be combined with the +library in order to run. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program + which contains a notice placed by the copyright holder or other + authorized party saying it may be distributed under the terms of this + Lesser General Public License (also called "this License"). Each + licensee is addressed as "you". + + A "library" means a collection of software functions and/or data + prepared so as to be conveniently linked with application programs + (which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work which + has been distributed under these terms. A "work based on the Library" + means either the Library or any derivative work under copyright law: + that is to say, a work containing the Library or a portion of it, either + verbatim or with modifications and/or translated straightforwardly into + another language. (Hereinafter, translation is included without + limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for making + modifications to it. For a library, complete source code means all the + source code for all modules it contains, plus any associated interface + definition files, plus the scripts used to control compilation and + installation of the library. + + Activities other than copying, distribution and modification are not + covered by this License; they are outside its scope. The act of running + a program using the Library is not restricted, and output from such a + program is covered only if its contents constitute a work based on the + Library (independent of the use of the Library in a tool for writing + it). Whether that is true depends on what the Library does and what the + program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete + source code as you receive it, in any medium, provided that you + conspicuously and appropriately publish on each copy an appropriate + copyright notice and disclaimer of warranty; keep intact all the notices + that refer to this License and to the absence of any warranty; and + distribute a copy of this License along with the Library. + + You may charge a fee for the physical act of transferring a copy, and + you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, + thus forming a work based on the Library, and copy and distribute such + modifications or work under the terms of Section 1 above, provided that + you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices stating + that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no charge to + all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a table + of data to be supplied by an application program that uses the + facility, other than as an argument passed when the facility is + invoked, then you must make a good faith effort to ensure that, in + the event an application does not supply such function or table, the + facility still operates, and performs whatever part of its purpose + remains meaningful. + + (For example, a function in a library to compute square roots has a + purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must be + optional: if the application does not supply it, the square root + function must still compute square roots.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Library, and + can be reasonably considered independent and separate works in + themselves, then this License, and its terms, do not apply to those + sections when you distribute them as separate works. But when you + distribute the same sections as part of a whole which is a work based on + the Library, the distribution of the whole must be on the terms of this + License, whose permissions for other licensees extend to the entire + whole, and thus to each and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or contest + your rights to work written entirely by you; rather, the intent is to + exercise the right to control the distribution of derivative or + collective works based on the Library. + + In addition, mere aggregation of another work not based on the Library + with the Library (or with a work based on the Library) on a volume of a + storage or distribution medium does not bring the other work under the + scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public + License instead of this License to a given copy of the Library. To do + this, you must alter all the notices that refer to this License, so that + they refer to the ordinary GNU General Public License, version 2, + instead of to this License. (If a newer version than version 2 of the + ordinary GNU General Public License has appeared, then you can specify + that version instead if you wish.) Do not make any other change in these + notices. + + Once this change is made in a given copy, it is irreversible for that + copy, so the ordinary GNU General Public License applies to all + subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of the + Library into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of + it, under Section 2) in object code or executable form under the terms + of Sections 1 and 2 above provided that you accompany it with the + complete corresponding machine-readable source code, which must be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange. + + If distribution of object code is made by offering access to copy from a + designated place, then offering equivalent access to copy the source + code from the same place satisfies the requirement to distribute the + source code, even though third parties are not compelled to copy the + source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but + is designed to work with the Library by being compiled or linked with + it, is called a "work that uses the Library". Such a work, in isolation, + is not a derivative work of the Library, and therefore falls outside the + scope of this License. + + However, linking a "work that uses the Library" with the Library creates + an executable that is a derivative of the Library (because it contains + portions of the Library), rather than a "work that uses the + library". The executable is therefore covered by this License. Section 6 + states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file + that is part of the Library, the object code for the work may be a + derivative work of the Library even though the source code is + not. Whether this is true is especially significant if the work can be + linked without the Library, or if the work is itself a library. The + threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data structure + layouts and accessors, and small macros and small inline functions (ten + lines or less in length), then the use of the object file is + unrestricted, regardless of whether it is legally a derivative + work. (Executables containing this object code plus portions of the + Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may + distribute the object code for the work under the terms of Section + 6. Any executables containing that work also fall under Section 6, + whether or not they are linked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a + "work that uses the Library" with the Library to produce a work + containing portions of the Library, and distribute that work under terms + of your choice, provided that the terms permit modification of the work + for the customer's own use and reverse engineering for debugging such + modifications. + + You must give prominent notice with each copy of the work that the + Library is used in it and that the Library and its use are covered by + this License. You must supply a copy of this License. If the work during + execution displays copyright notices, you must include the copyright + notice for the Library among them, as well as a reference directing the + user to the copy of this License. Also, you must do one of these things: + + a) Accompany the work with the complete corresponding machine-readable + source code for the Library including whatever changes were used in + the work (which must be distributed under Sections 1 and 2 above); + and, if the work is an executable linked with the Library, with the + complete machine-readable "work that uses the Library", as object + code and/or source code, so that the user can modify the Library and + then relink to produce a modified executable containing the modified + Library. (It is understood that the user who changes the contents of + definitions files in the Library will not necessarily be able to + recompile the application to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a copy + of the library already present on the user's computer system, rather + than copying library functions into the executable, and (2) will + operate properly with a modified version of the library, if the user + installs one, as long as the modified version is interface-compatible + with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least three + years, to give the same user the materials specified in Subsection + 6a, above, for a charge no more than the cost of performing this + distribution. + + d) If distribution of the work is made by offering access to copy from a + designated place, offer equivalent access to copy the above specified + materials from the same place. + + e) Verify that the user has already received a copy of these materials + or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the Library" + must include any data and utility programs needed for reproducing the + executable from it. However, as a special exception, the materials to be + distributed need not include anything that is normally distributed (in + either source or binary form) with the major components (compiler, + kernel, and so on) of the operating system on which the executable runs, + unless that component itself accompanies the executable. + + It may happen that this requirement contradicts the license restrictions + of other proprietary libraries that do not normally accompany the + operating system. Such a contradiction means you cannot use both them + and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library + side-by-side in a single library together with other library facilities + not covered by this License, and distribute such a combined library, + provided that the separate distribution of the work based on the Library + and of the other library facilities is otherwise permitted, and provided + that you do these two things: + + a) Accompany the combined library with a copy of the same work based on + the Library, uncombined with any other library facilities. This must + be distributed under the terms of the Sections above. + + b) Give prominent notice with the combined library of the fact that part + of it is a work based on the Library, and explaining where to find + the accompanying uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the + Library except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense, link with, or distribute the + Library is void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, from you + under this License will not have their licenses terminated so long as + such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed + it. However, nothing else grants you permission to modify or distribute + the Library or its derivative works. These actions are prohibited by law + if you do not accept this License. Therefore, by modifying or + distributing the Library (or any work based on the Library), you + indicate your acceptance of this License to do so, and all its terms and + conditions for copying, distributing or modifying the Library or works + based on it. + +10. Each time you redistribute the Library (or any work based on the + Library), the recipient automatically receives a license from the + original licensor to copy, distribute, link with or modify the Library + subject to these terms and conditions. You may not impose any further + restrictions on the recipients' exercise of the rights granted + herein. You are not responsible for enforcing compliance by third + parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent issues), + conditions are imposed on you (whether by court order, agreement or + otherwise) that contradict the conditions of this License, they do not + excuse you from the conditions of this License. If you cannot + distribute so as to satisfy simultaneously your obligations under this + License and any other pertinent obligations, then as a consequence you + may not distribute the Library at all. For example, if a patent license + would not permit royalty-free redistribution of the Library by all + those who receive copies directly or indirectly through you, then the + only way you could satisfy both it and this License would be to refrain + entirely from distribution of the Library. + + If any portion of this section is held invalid or unenforceable under + any particular circumstance, the balance of the section is intended to + apply, and the section as a whole is intended to apply in other + circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of any + such claims; this section has the sole purpose of protecting the + integrity of the free software distribution system which is implemented + by public license practices. Many people have made generous + contributions to the wide range of software distributed through that + system in reliance on consistent application of that system; it is up + to the author/donor to decide if he or she is willing to distribute + software through any other system and a licensee cannot impose that + choice. + + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain + countries either by patents or by copyrighted interfaces, the original + copyright holder who places the Library under this License may add an + explicit geographical distribution limitation excluding those + countries, so that distribution is permitted only in or among countries + not thus excluded. In such case, this License incorporates the + limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of + the Lesser General Public License from time to time. Such new versions + will be similar in spirit to the present version, but may differ in + detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the Library + specifies a version number of this License which applies to it and "any + later version", you have the option of following the terms and + conditions either of that version or of any later version published by + the Free Software Foundation. If the Library does not specify a license + version number, you may choose any version ever published by the Free + Software Foundation. + +14. If you wish to incorporate parts of the Library into other free + programs whose distribution conditions are incompatible with these, + write to the author to ask for permission. For software which is + copyrighted by the Free Software Foundation, write to the Free Software + Foundation; we sometimes make exceptions for this. Our decision will be + guided by the two goals of preserving the free status of all + derivatives of our free software and of promoting the sharing and reuse + of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY + FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN + OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES + PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER + EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE + ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH + YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL + NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING + WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR + REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR + DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL + DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY + (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED + INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF + THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR + OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + +To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + +one line to give the library's name and an idea of what it does. +Copyright (C) year name of author + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License +for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add +information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice +That's all there is to it! diff -Nru dwarves-dfsg-1.10/lib/bpf/README.md dwarves-dfsg-1.21/lib/bpf/README.md --- dwarves-dfsg-1.10/lib/bpf/README.md 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/README.md 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,155 @@ +BPF/libbpf usage and questions +============================== + +Please check out [libbpf-bootstrap](https://github.com/libbpf/libbpf-bootstrap) +and [the companion blog post](https://nakryiko.com/posts/libbpf-bootstrap/) for +the examples of building BPF applications with libbpf. +[libbpf-tools](https://github.com/iovisor/bcc/tree/master/libbpf-tools) are also +a good source of the real-world libbpf-based tracing tools. + +All general BPF questions, including kernel functionality, libbpf APIs and +their application, should be sent to bpf@vger.kernel.org mailing list. You can +subscribe to it [here](http://vger.kernel.org/vger-lists.html#bpf) and search +its archive [here](https://lore.kernel.org/bpf/). Please search the archive +before asking new questions. It very well might be that this was already +addressed or answered before. + +bpf@vger.kernel.org is monitored by many more people and they will happily try +to help you with whatever issue you have. This repository's PRs and issues +should be opened only for dealing with issues pertaining to specific way this +libbpf mirror repo is set up and organized. + +Build +[![Build Status](https://travis-ci.com/libbpf/libbpf.svg?branch=master)](https://travis-ci.com/github/libbpf/libbpf) +[![Total alerts](https://img.shields.io/lgtm/alerts/g/libbpf/libbpf.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/libbpf/libbpf/alerts/) +[![Coverity](https://img.shields.io/coverity/scan/18195.svg)](https://scan.coverity.com/projects/libbpf) +===== +libelf is an internal dependency of libbpf and thus it is required to link +against and must be installed on the system for applications to work. +pkg-config is used by default to find libelf, and the program called can be +overridden with `PKG_CONFIG`. + +If using `pkg-config` at build time is not desired, it can be disabled by +setting `NO_PKG_CONFIG=1` when calling make. + +To build both static libbpf.a and shared libbpf.so: +```bash +$ cd src +$ make +``` + +To build only static libbpf.a library in directory +build/ and install them together with libbpf headers in a staging directory +root/: +```bash +$ cd src +$ mkdir build root +$ BUILD_STATIC_ONLY=y OBJDIR=build DESTDIR=root make install +``` + +To build both static libbpf.a and shared libbpf.so against a custom libelf +dependency installed in /build/root/ and install them together with libbpf +headers in a build directory /build/root/: +```bash +$ cd src +$ PKG_CONFIG_PATH=/build/root/lib64/pkgconfig DESTDIR=/build/root make install +``` + +Distributions +============= + +Distributions packaging libbpf from this mirror: + - [Fedora](https://src.fedoraproject.org/rpms/libbpf) + - [Gentoo](https://packages.gentoo.org/packages/dev-libs/libbpf) + - [Debian](https://packages.debian.org/source/sid/libbpf) + - [Arch](https://www.archlinux.org/packages/extra/x86_64/libbpf/) + - [Ubuntu](https://packages.ubuntu.com/source/groovy/libbpf) + +Benefits of packaging from the mirror over packaging from kernel sources: + - Consistent versioning across distributions. + - No ties to any specific kernel, transparent handling of older kernels. + Libbpf is designed to be kernel-agnostic and work across multitude of + kernel versions. It has built-in mechanisms to gracefully handle older + kernels, that are missing some of the features, by working around or + gracefully degrading functionality. Thus libbpf is not tied to a specific + kernel version and can/should be packaged and versioned independently. + - Continuous integration testing via + [TravisCI](https://travis-ci.org/libbpf/libbpf). + - Static code analysis via [LGTM](https://lgtm.com/projects/g/libbpf/libbpf) + and [Coverity](https://scan.coverity.com/projects/libbpf). + +Package dependencies of libbpf, package names may vary across distros: + - zlib + - libelf + +BPF CO-RE (Compile Once – Run Everywhere) +========================================= + +Libbpf supports building BPF CO-RE-enabled applications, which, in contrast to +[BCC](https://github.com/iovisor/bcc/), do not require Clang/LLVM runtime +being deployed to target servers and doesn't rely on kernel-devel headers +being available. + +It does rely on kernel to be built with [BTF type +information](https://www.kernel.org/doc/html/latest/bpf/btf.html), though. +Some major Linux distributions come with kernel BTF already built in: + - Fedora 31+ + - RHEL 8.2+ + - OpenSUSE Tumbleweed (in the next release, as of 2020-06-04) + - Arch Linux (from kernel 5.7.1.arch1-1) + - Ubuntu 20.10 + - Debian 11 (amd64/arm64) + +If your kernel doesn't come with BTF built-in, you'll need to build custom +kernel. You'll need: + - `pahole` 1.16+ tool (part of `dwarves` package), which performs DWARF to + BTF conversion; + - kernel built with `CONFIG_DEBUG_INFO_BTF=y` option; + - you can check if your kernel has BTF built-in by looking for + `/sys/kernel/btf/vmlinux` file: + +```shell +$ ls -la /sys/kernel/btf/vmlinux +-r--r--r--. 1 root root 3541561 Jun 2 18:16 /sys/kernel/btf/vmlinux +``` + +To develop and build BPF programs, you'll need Clang/LLVM 10+. The following +distributions have Clang/LLVM 10+ packaged by default: + - Fedora 32+ + - Ubuntu 20.04+ + - Arch Linux + - Ubuntu 20.10 (LLVM 11) + - Debian 11 (LLVM 11) + +Otherwise, please make sure to update it on your system. + +The following resources are useful to understand what BPF CO-RE is and how to +use it: +- [BPF Portability and CO-RE](https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html) +- [HOWTO: BCC to libbpf conversion](https://facebookmicrosites.github.io/bpf/blog/2020/02/20/bcc-to-libbpf-howto-guide.html) +- [libbpf-tools in BCC repo](https://github.com/iovisor/bcc/tree/master/libbpf-tools) + contain lots of real-world tools converted from BCC to BPF CO-RE. Consider + converting some more to both contribute to the BPF community and gain some + more experience with it. + +Details +======= +This is a mirror of [bpf-next Linux source +tree](https://kernel.googlesource.com/pub/scm/linux/kernel/git/bpf/bpf-next)'s +`tools/lib/bpf` directory plus its supporting header files. + +All the gory details of syncing can be found in `scripts/sync-kernel.sh` +script. + +Some header files in this repo (`include/linux/*.h`) are reduced versions of +their counterpart files at +[bpf-next](https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/)'s +`tools/include/linux/*.h` to make compilation successful. + +License +======= + +This work is dual-licensed under BSD 2-clause license and GNU LGPL v2.1 license. +You can choose between one of them if you use this work. + +`SPDX-License-Identifier: BSD-2-Clause OR LGPL-2.1` diff -Nru dwarves-dfsg-1.10/lib/bpf/scripts/coverity.sh dwarves-dfsg-1.21/lib/bpf/scripts/coverity.sh --- dwarves-dfsg-1.10/lib/bpf/scripts/coverity.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/scripts/coverity.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,105 @@ +#!/bin/bash +# Taken from: https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh +# Local changes are annotated with "#[local]" + +set -e + +# Environment check +echo -e "\033[33;1mNote: COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN are available on Project Settings page on scan.coverity.com\033[0m" +[ -z "$COVERITY_SCAN_PROJECT_NAME" ] && echo "ERROR: COVERITY_SCAN_PROJECT_NAME must be set" && exit 1 +[ -z "$COVERITY_SCAN_NOTIFICATION_EMAIL" ] && echo "ERROR: COVERITY_SCAN_NOTIFICATION_EMAIL must be set" && exit 1 +[ -z "$COVERITY_SCAN_BRANCH_PATTERN" ] && echo "ERROR: COVERITY_SCAN_BRANCH_PATTERN must be set" && exit 1 +[ -z "$COVERITY_SCAN_BUILD_COMMAND" ] && echo "ERROR: COVERITY_SCAN_BUILD_COMMAND must be set" && exit 1 +[ -z "$COVERITY_SCAN_TOKEN" ] && echo "ERROR: COVERITY_SCAN_TOKEN must be set" && exit 1 + +PLATFORM=`uname` +#[local] Use /var/tmp for TOOL_ARCHIVE and TOOL_BASE, as on certain systems +# /tmp is tmpfs and is sometimes too small to handle all necessary tooling +TOOL_ARCHIVE=/var//tmp/cov-analysis-${PLATFORM}.tgz +TOOL_URL=https://scan.coverity.com/download/${PLATFORM} +TOOL_BASE=/var/tmp/coverity-scan-analysis +UPLOAD_URL="https://scan.coverity.com/builds" +SCAN_URL="https://scan.coverity.com" + +# Do not run on pull requests +if [ "${TRAVIS_PULL_REQUEST}" = "true" ]; then + echo -e "\033[33;1mINFO: Skipping Coverity Analysis: branch is a pull request.\033[0m" + exit 0 +fi + +# Verify this branch should run +IS_COVERITY_SCAN_BRANCH=`ruby -e "puts '${TRAVIS_BRANCH}' =~ /\\A$COVERITY_SCAN_BRANCH_PATTERN\\z/ ? 1 : 0"` +if [ "$IS_COVERITY_SCAN_BRANCH" = "1" ]; then + echo -e "\033[33;1mCoverity Scan configured to run on branch ${TRAVIS_BRANCH}\033[0m" +else + echo -e "\033[33;1mCoverity Scan NOT configured to run on branch ${TRAVIS_BRANCH}\033[0m" + exit 1 +fi + +# Verify upload is permitted +AUTH_RES=`curl -s --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_permitted` +if [ "$AUTH_RES" = "Access denied" ]; then + echo -e "\033[33;1mCoverity Scan API access denied. Check COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN.\033[0m" + exit 1 +else + AUTH=`echo $AUTH_RES | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['upload_permitted']"` + if [ "$AUTH" = "true" ]; then + echo -e "\033[33;1mCoverity Scan analysis authorized per quota.\033[0m" + else + WHEN=`echo $AUTH_RES | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['next_upload_permitted_at']"` + echo -e "\033[33;1mCoverity Scan analysis NOT authorized until $WHEN.\033[0m" + exit 0 + fi +fi + +if [ ! -d $TOOL_BASE ]; then + # Download Coverity Scan Analysis Tool + if [ ! -e $TOOL_ARCHIVE ]; then + echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m" + wget -nv -O $TOOL_ARCHIVE $TOOL_URL --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN" + fi + + # Extract Coverity Scan Analysis Tool + echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m" + mkdir -p $TOOL_BASE + pushd $TOOL_BASE + tar xzf $TOOL_ARCHIVE + popd +fi + +TOOL_DIR=`find $TOOL_BASE -type d -name 'cov-analysis*'` +export PATH=$TOOL_DIR/bin:$PATH + +# Build +echo -e "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m" +COV_BUILD_OPTIONS="" +#COV_BUILD_OPTIONS="--return-emit-failures 8 --parse-error-threshold 85" +RESULTS_DIR="cov-int" +eval "${COVERITY_SCAN_BUILD_COMMAND_PREPEND}" +COVERITY_UNSUPPORTED=1 cov-build --dir $RESULTS_DIR $COV_BUILD_OPTIONS $COVERITY_SCAN_BUILD_COMMAND +cov-import-scm --dir $RESULTS_DIR --scm git --log $RESULTS_DIR/scm_log.txt 2>&1 + +# Upload results +echo -e "\033[33;1mTarring Coverity Scan Analysis results...\033[0m" +RESULTS_ARCHIVE=analysis-results.tgz +tar czf $RESULTS_ARCHIVE $RESULTS_DIR +SHA=`git rev-parse --short HEAD` + +echo -e "\033[33;1mUploading Coverity Scan Analysis results...\033[0m" +response=$(curl \ + --silent --write-out "\n%{http_code}\n" \ + --form project=$COVERITY_SCAN_PROJECT_NAME \ + --form token=$COVERITY_SCAN_TOKEN \ + --form email=$COVERITY_SCAN_NOTIFICATION_EMAIL \ + --form file=@$RESULTS_ARCHIVE \ + --form version=$SHA \ + --form description="Travis CI build" \ + $UPLOAD_URL) +status_code=$(echo "$response" | sed -n '$p') +#[local] Coverity used to return 201 on success, but it's 200 now +# See https://github.com/systemd/systemd/blob/master/tools/coverity.sh#L145 +if [ "$status_code" != "200" ]; then + TEXT=$(echo "$response" | sed '$d') + echo -e "\033[33;1mCoverity Scan upload failed: $TEXT.\033[0m" + exit 1 +fi diff -Nru dwarves-dfsg-1.10/lib/bpf/scripts/sync-kernel.sh dwarves-dfsg-1.21/lib/bpf/scripts/sync-kernel.sh --- dwarves-dfsg-1.10/lib/bpf/scripts/sync-kernel.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/scripts/sync-kernel.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,343 @@ +#!/bin/bash + +usage () { + echo "USAGE: ./sync-kernel.sh " + echo "" + echo "Set BPF_NEXT_BASELINE to override bpf-next tree commit, otherwise read from /CHECKPOINT-COMMIT." + echo "Set BPF_BASELINE to override bpf tree commit, otherwise read from /BPF-CHECKPOINT-COMMIT." + echo "Set MANUAL_MODE to 1 to manually control every cherry-picked commits." + exit 1 +} + +set -eu + +LIBBPF_REPO=${1-""} +LINUX_REPO=${2-""} +BPF_BRANCH=${3-""} +BASELINE_COMMIT=${BPF_NEXT_BASELINE:-$(cat ${LIBBPF_REPO}/CHECKPOINT-COMMIT)} +BPF_BASELINE_COMMIT=${BPF_BASELINE:-$(cat ${LIBBPF_REPO}/BPF-CHECKPOINT-COMMIT)} + +if [ -z "${LIBBPF_REPO}" ] || [ -z "${LINUX_REPO}" ] || [ -z "${BPF_BRANCH}" ]; then + echo "Error: libbpf or linux repos are not specified" + usage +fi +if [ -z "${BPF_BRANCH}" ]; then + echo "Error: linux's bpf tree branch is not specified" + usage +fi +if [ -z "${BASELINE_COMMIT}" ] || [ -z "${BPF_BASELINE_COMMIT}" ]; then + echo "Error: bpf or bpf-next baseline commits are not provided" + usage +fi + +SUFFIX=$(date --utc +%Y-%m-%dT%H-%M-%S.%3NZ) +WORKDIR=$(pwd) +TMP_DIR=$(mktemp -d) + +trap "cd ${WORKDIR}; exit" INT TERM EXIT + +declare -A PATH_MAP +PATH_MAP=( \ + [tools/lib/bpf]=src \ + [tools/include/uapi/linux/bpf_common.h]=include/uapi/linux/bpf_common.h \ + [tools/include/uapi/linux/bpf.h]=include/uapi/linux/bpf.h \ + [tools/include/uapi/linux/btf.h]=include/uapi/linux/btf.h \ + [tools/include/uapi/linux/if_link.h]=include/uapi/linux/if_link.h \ + [tools/include/uapi/linux/if_xdp.h]=include/uapi/linux/if_xdp.h \ + [tools/include/uapi/linux/netlink.h]=include/uapi/linux/netlink.h \ +) + +LIBBPF_PATHS="${!PATH_MAP[@]} :^tools/lib/bpf/Makefile :^tools/lib/bpf/Build :^tools/lib/bpf/.gitignore :^tools/include/tools/libc_compat.h" +LIBBPF_VIEW_PATHS="${PATH_MAP[@]}" +LIBBPF_VIEW_EXCLUDE_REGEX='^src/(Makefile|Build|test_libbpf\.c|bpf_helper_defs\.h|\.gitignore)$' +LINUX_VIEW_EXCLUDE_REGEX='^include/tools/libc_compat.h$' + +LIBBPF_TREE_FILTER="mkdir -p __libbpf/include/uapi/linux __libbpf/include/tools && "$'\\\n' +for p in "${!PATH_MAP[@]}"; do + LIBBPF_TREE_FILTER+="git mv -kf ${p} __libbpf/${PATH_MAP[${p}]} && "$'\\\n' +done +LIBBPF_TREE_FILTER+="git rm --ignore-unmatch -f __libbpf/src/{Makefile,Build,test_libbpf.c,.gitignore} >/dev/null" + +cd_to() +{ + cd ${WORKDIR} && cd "$1" +} + +# Output brief single-line commit description +# $1 - commit ref +commit_desc() +{ + git log -n1 --pretty='%h ("%s")' $1 +} + +# Create commit single-line signature, which consists of: +# - full commit hash +# - author date in ISO8601 format +# - full commit body with newlines replaced with vertical bars (|) +# - shortstat appended at the end +# The idea is that this single-line signature is good enough to make final +# decision about whether two commits are the same, across different repos. +# $1 - commit ref +# $2 - paths filter +commit_signature() +{ + git show --pretty='("%s")|%aI|%b' --shortstat $1 -- ${2-.} | tr '\n' '|' +} + +# Cherry-pick commits touching libbpf-related files +# $1 - baseline_tag +# $2 - tip_tag +cherry_pick_commits() +{ + local manual_mode=${MANUAL_MODE:-0} + local baseline_tag=$1 + local tip_tag=$2 + local new_commits + local signature + local should_skip + local synced_cnt + local manual_check + local libbpf_conflict_cnt + local desc + + new_commits=$(git rev-list --no-merges --topo-order --reverse ${baseline_tag}..${tip_tag} ${LIBBPF_PATHS[@]}) + for new_commit in ${new_commits}; do + desc="$(commit_desc ${new_commit})" + signature="$(commit_signature ${new_commit} "${LIBBPF_PATHS[@]}")" + synced_cnt=$(grep -F "${signature}" ${TMP_DIR}/libbpf_commits.txt | wc -l) + manual_check=0 + if ((${synced_cnt} > 0)); then + # commit with the same subject is already in libbpf, but it's + # not 100% the same commit, so check with user + echo "Commit '${desc}' is synced into libbpf as:" + grep -F "${signature}" ${TMP_DIR}/libbpf_commits.txt | \ + cut -d'|' -f1 | sed -e 's/^/- /' + if ((${manual_mode} != 1 && ${synced_cnt} == 1)); then + echo "Skipping '${desc}' due to unique match..." + continue + fi + if ((${synced_cnt} > 1)); then + echo "'${desc} matches multiple commits, please, double-check!" + manual_check=1 + fi + fi + if ((${manual_mode} == 1 || ${manual_check} == 1)); then + read -p "Do you want to skip '${desc}'? [y/N]: " should_skip + case "${should_skip}" in + "y" | "Y") + echo "Skipping '${desc}'..." + continue + ;; + esac + fi + # commit hasn't been synced into libbpf yet + echo "Picking '${desc}'..." + if ! git cherry-pick ${new_commit} &>/dev/null; then + echo "Warning! Cherry-picking '${desc} failed, checking if it's non-libbpf files causing problems..." + libbpf_conflict_cnt=$(git diff --name-only --diff-filter=U -- ${LIBBPF_PATHS[@]} | wc -l) + conflict_cnt=$(git diff --name-only | wc -l) + prompt_resolution=1 + + if ((${libbpf_conflict_cnt} == 0)); then + echo "Looks like only non-libbpf files have conflicts, ignoring..." + if ((${conflict_cnt} == 0)); then + echo "Empty cherry-pick, skipping it..." + git cherry-pick --abort + continue + fi + + git add . + # GIT_EDITOR=true to avoid editor popping up to edit commit message + if ! GIT_EDITOR=true git cherry-pick --continue &>/dev/null; then + echo "Error! That still failed! Please resolve manually." + else + echo "Success! All cherry-pick conflicts were resolved for '${desc}'!" + prompt_resolution=0 + fi + fi + + if ((${prompt_resolution} == 1)); then + read -p "Error! Cherry-picking '${desc}' failed, please fix manually and press to proceed..." + fi + fi + # Append signature of just cherry-picked commit to avoid + # potentially cherry-picking the same commit twice later when + # processing bpf tree commits. At this point we don't know yet + # the final commit sha in libbpf repo, so we record Linux SHA + # instead as LINUX_. + echo LINUX_$(git log --pretty='%h' -n1) "${signature}" >> ${TMP_DIR}/libbpf_commits.txt + done +} + +cleanup() +{ + echo "Cleaning up..." + rm -r ${TMP_DIR} + cd_to ${LINUX_REPO} + git checkout ${TIP_SYM_REF} + git branch -D ${BASELINE_TAG} ${TIP_TAG} ${BPF_BASELINE_TAG} ${BPF_TIP_TAG} \ + ${SQUASH_BASE_TAG} ${SQUASH_TIP_TAG} ${VIEW_TAG} || true + + cd_to . + echo "DONE." +} + + +cd_to ${LIBBPF_REPO} +GITHUB_ABS_DIR=$(pwd) +echo "Dumping existing libbpf commit signatures..." +for h in $(git log --pretty='%h' -n500); do + echo $h "$(commit_signature $h)" >> ${TMP_DIR}/libbpf_commits.txt +done + +# Use current kernel repo HEAD as a source of patches +cd_to ${LINUX_REPO} +LINUX_ABS_DIR=$(pwd) +TIP_SYM_REF=$(git symbolic-ref -q --short HEAD || git rev-parse HEAD) +TIP_COMMIT=$(git rev-parse HEAD) +BPF_TIP_COMMIT=$(git rev-parse ${BPF_BRANCH}) +BASELINE_TAG=libbpf-baseline-${SUFFIX} +TIP_TAG=libbpf-tip-${SUFFIX} +BPF_BASELINE_TAG=libbpf-bpf-baseline-${SUFFIX} +BPF_TIP_TAG=libbpf-bpf-tip-${SUFFIX} +VIEW_TAG=libbpf-view-${SUFFIX} +LIBBPF_SYNC_TAG=libbpf-sync-${SUFFIX} + +# Squash state of kernel repo at baseline into single commit +SQUASH_BASE_TAG=libbpf-squash-base-${SUFFIX} +SQUASH_TIP_TAG=libbpf-squash-tip-${SUFFIX} +SQUASH_COMMIT=$(git commit-tree ${BASELINE_COMMIT}^{tree} -m "BASELINE SQUASH ${BASELINE_COMMIT}") + +echo "WORKDIR: ${WORKDIR}" +echo "LINUX REPO: ${LINUX_REPO}" +echo "LIBBPF REPO: ${LIBBPF_REPO}" +echo "TEMP DIR: ${TMP_DIR}" +echo "SUFFIX: ${SUFFIX}" +echo "BASE COMMIT: '$(commit_desc ${BASELINE_COMMIT})'" +echo "TIP COMMIT: '$(commit_desc ${TIP_COMMIT})'" +echo "BPF BASE COMMIT: '$(commit_desc ${BPF_BASELINE_COMMIT})'" +echo "BPF TIP COMMIT: '$(commit_desc ${BPF_TIP_COMMIT})'" +echo "SQUASH COMMIT: ${SQUASH_COMMIT}" +echo "BASELINE TAG: ${BASELINE_TAG}" +echo "TIP TAG: ${TIP_TAG}" +echo "BPF BASELINE TAG: ${BPF_BASELINE_TAG}" +echo "BPF TIP TAG: ${BPF_TIP_TAG}" +echo "SQUASH BASE TAG: ${SQUASH_BASE_TAG}" +echo "SQUASH TIP TAG: ${SQUASH_TIP_TAG}" +echo "VIEW TAG: ${VIEW_TAG}" +echo "LIBBPF SYNC TAG: ${LIBBPF_SYNC_TAG}" +echo "PATCHES: ${TMP_DIR}/patches" + +git branch ${BASELINE_TAG} ${BASELINE_COMMIT} +git branch ${TIP_TAG} ${TIP_COMMIT} +git branch ${BPF_BASELINE_TAG} ${BPF_BASELINE_COMMIT} +git branch ${BPF_TIP_TAG} ${BPF_TIP_COMMIT} +git branch ${SQUASH_BASE_TAG} ${SQUASH_COMMIT} +git checkout -b ${SQUASH_TIP_TAG} ${SQUASH_COMMIT} + +# Cherry-pick new commits onto squashed baseline commit +cherry_pick_commits ${BASELINE_TAG} ${TIP_TAG} +cherry_pick_commits ${BPF_BASELINE_TAG} ${BPF_TIP_TAG} + +# Move all libbpf files into __libbpf directory. +FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --prune-empty -f --tree-filter "${LIBBPF_TREE_FILTER}" ${SQUASH_TIP_TAG} ${SQUASH_BASE_TAG} +# Make __libbpf a new root directory +FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --prune-empty -f --subdirectory-filter __libbpf ${SQUASH_TIP_TAG} ${SQUASH_BASE_TAG} + +# If there are no new commits with libbpf-related changes, bail out +COMMIT_CNT=$(git rev-list --count ${SQUASH_BASE_TAG}..${SQUASH_TIP_TAG}) +if ((${COMMIT_CNT} <= 0)); then + echo "No new changes to apply, we are done!" + cleanup + exit 2 +fi + +# Exclude baseline commit and generate nice cover letter with summary +git format-patch ${SQUASH_BASE_TAG}..${SQUASH_TIP_TAG} --cover-letter -o ${TMP_DIR}/patches + +# Now is time to re-apply libbpf-related linux patches to libbpf repo +cd_to ${LIBBPF_REPO} +git checkout -b ${LIBBPF_SYNC_TAG} + +for patch in $(ls -1 ${TMP_DIR}/patches | tail -n +2); do + if ! git am --3way --committer-date-is-author-date "${TMP_DIR}/patches/${patch}"; then + read -p "Applying ${TMP_DIR}/patches/${patch} failed, please resolve manually and press to proceed..." + fi +done + +# Generate bpf_helper_defs.h and commit, if anything changed +# restore Linux tip to use bpf_helpers_doc.py +cd_to ${LINUX_REPO} +git checkout ${TIP_TAG} +# re-generate bpf_helper_defs.h +cd_to ${LIBBPF_REPO} +"${LINUX_ABS_DIR}/scripts/bpf_helpers_doc.py" --header \ + --file include/uapi/linux/bpf.h > src/bpf_helper_defs.h +# if anything changed, commit it +helpers_changes=$(git status --porcelain src/bpf_helper_defs.h | wc -l) +if ((${helpers_changes} == 1)); then + git add src/bpf_helper_defs.h + git commit -m "sync: auto-generate latest BPF helpers + +Latest changes to BPF helper definitions. +" -- src/bpf_helper_defs.h +fi + +# Use generated cover-letter as a template for "sync commit" with +# baseline and checkpoint commits from kernel repo (and leave summary +# from cover letter intact, of course) +echo ${TIP_COMMIT} > CHECKPOINT-COMMIT && \ +echo ${BPF_TIP_COMMIT} > BPF-CHECKPOINT-COMMIT && \ +git add CHECKPOINT-COMMIT && \ +git add BPF-CHECKPOINT-COMMIT && \ +awk '/\*\*\* BLURB HERE \*\*\*/ {p=1} p' ${TMP_DIR}/patches/0000-cover-letter.patch | \ +sed "s/\*\*\* BLURB HERE \*\*\*/\ +sync: latest libbpf changes from kernel\n\ +\n\ +Syncing latest libbpf commits from kernel repository.\n\ +Baseline bpf-next commit: ${BASELINE_COMMIT}\n\ +Checkpoint bpf-next commit: ${TIP_COMMIT}\n\ +Baseline bpf commit: ${BPF_BASELINE_COMMIT}\n\ +Checkpoint bpf commit: ${BPF_TIP_COMMIT}/" | \ +git commit --file=- + +echo "SUCCESS! ${COMMIT_CNT} commits synced." + +echo "Verifying Linux's and Github's libbpf state" + +cd_to ${LINUX_REPO} +git checkout -b ${VIEW_TAG} ${TIP_COMMIT} +FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --tree-filter "${LIBBPF_TREE_FILTER}" ${VIEW_TAG}^..${VIEW_TAG} +FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --subdirectory-filter __libbpf ${VIEW_TAG}^..${VIEW_TAG} +git ls-files -- ${LIBBPF_VIEW_PATHS[@]} | grep -v -E "${LINUX_VIEW_EXCLUDE_REGEX}" > ${TMP_DIR}/linux-view.ls + +cd_to ${LIBBPF_REPO} +git ls-files -- ${LIBBPF_VIEW_PATHS[@]} | grep -v -E "${LIBBPF_VIEW_EXCLUDE_REGEX}" > ${TMP_DIR}/github-view.ls + +echo "Comparing list of files..." +diff -u ${TMP_DIR}/linux-view.ls ${TMP_DIR}/github-view.ls +echo "Comparing file contents..." +CONSISTENT=1 +for F in $(cat ${TMP_DIR}/linux-view.ls); do + if ! diff -u "${LINUX_ABS_DIR}/${F}" "${GITHUB_ABS_DIR}/${F}"; then + echo "${LINUX_ABS_DIR}/${F} and ${GITHUB_ABS_DIR}/${F} are different!" + CONSISTENT=0 + fi +done +if ((${CONSISTENT} == 1)); then + echo "Great! Content is identical!" +else + ignore_inconsistency=n + echo "Unfortunately, there are some inconsistencies, please double check." + read -p "Does everything look good? [y/N]: " ignore_inconsistency + case "${ignore_inconsistency}" in + "y" | "Y") + echo "Ok, proceeding..." + ;; + *) + echo "Oops, exiting with error..." + exit 4 + esac +fi + +cleanup diff -Nru dwarves-dfsg-1.10/lib/bpf/src/bpf.c dwarves-dfsg-1.21/lib/bpf/src/bpf.c --- dwarves-dfsg-1.10/lib/bpf/src/bpf.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/bpf.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,973 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +/* + * common eBPF ELF operations. + * + * Copyright (C) 2013-2015 Alexei Starovoitov + * Copyright (C) 2015 Wang Nan + * Copyright (C) 2015 Huawei Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License (not later!) + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see + */ + +#include +#include +#include +#include +#include +#include +#include +#include "bpf.h" +#include "libbpf.h" +#include "libbpf_internal.h" + +/* + * When building perf, unistd.h is overridden. __NR_bpf is + * required to be defined explicitly. + */ +#ifndef __NR_bpf +# if defined(__i386__) +# define __NR_bpf 357 +# elif defined(__x86_64__) +# define __NR_bpf 321 +# elif defined(__aarch64__) +# define __NR_bpf 280 +# elif defined(__sparc__) +# define __NR_bpf 349 +# elif defined(__s390__) +# define __NR_bpf 351 +# elif defined(__arc__) +# define __NR_bpf 280 +# else +# error __NR_bpf not defined. libbpf does not support your arch. +# endif +#endif + +static inline __u64 ptr_to_u64(const void *ptr) +{ + return (__u64) (unsigned long) ptr; +} + +static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr, + unsigned int size) +{ + return syscall(__NR_bpf, cmd, attr, size); +} + +static inline int sys_bpf_prog_load(union bpf_attr *attr, unsigned int size) +{ + int retries = 5; + int fd; + + do { + fd = sys_bpf(BPF_PROG_LOAD, attr, size); + } while (fd < 0 && errno == EAGAIN && retries-- > 0); + + return fd; +} + +int bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr) +{ + union bpf_attr attr; + + memset(&attr, '\0', sizeof(attr)); + + attr.map_type = create_attr->map_type; + attr.key_size = create_attr->key_size; + attr.value_size = create_attr->value_size; + attr.max_entries = create_attr->max_entries; + attr.map_flags = create_attr->map_flags; + if (create_attr->name) + memcpy(attr.map_name, create_attr->name, + min(strlen(create_attr->name), BPF_OBJ_NAME_LEN - 1)); + attr.numa_node = create_attr->numa_node; + attr.btf_fd = create_attr->btf_fd; + attr.btf_key_type_id = create_attr->btf_key_type_id; + attr.btf_value_type_id = create_attr->btf_value_type_id; + attr.map_ifindex = create_attr->map_ifindex; + if (attr.map_type == BPF_MAP_TYPE_STRUCT_OPS) + attr.btf_vmlinux_value_type_id = + create_attr->btf_vmlinux_value_type_id; + else + attr.inner_map_fd = create_attr->inner_map_fd; + + return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr)); +} + +int bpf_create_map_node(enum bpf_map_type map_type, const char *name, + int key_size, int value_size, int max_entries, + __u32 map_flags, int node) +{ + struct bpf_create_map_attr map_attr = {}; + + map_attr.name = name; + map_attr.map_type = map_type; + map_attr.map_flags = map_flags; + map_attr.key_size = key_size; + map_attr.value_size = value_size; + map_attr.max_entries = max_entries; + if (node >= 0) { + map_attr.numa_node = node; + map_attr.map_flags |= BPF_F_NUMA_NODE; + } + + return bpf_create_map_xattr(&map_attr); +} + +int bpf_create_map(enum bpf_map_type map_type, int key_size, + int value_size, int max_entries, __u32 map_flags) +{ + struct bpf_create_map_attr map_attr = {}; + + map_attr.map_type = map_type; + map_attr.map_flags = map_flags; + map_attr.key_size = key_size; + map_attr.value_size = value_size; + map_attr.max_entries = max_entries; + + return bpf_create_map_xattr(&map_attr); +} + +int bpf_create_map_name(enum bpf_map_type map_type, const char *name, + int key_size, int value_size, int max_entries, + __u32 map_flags) +{ + struct bpf_create_map_attr map_attr = {}; + + map_attr.name = name; + map_attr.map_type = map_type; + map_attr.map_flags = map_flags; + map_attr.key_size = key_size; + map_attr.value_size = value_size; + map_attr.max_entries = max_entries; + + return bpf_create_map_xattr(&map_attr); +} + +int bpf_create_map_in_map_node(enum bpf_map_type map_type, const char *name, + int key_size, int inner_map_fd, int max_entries, + __u32 map_flags, int node) +{ + union bpf_attr attr; + + memset(&attr, '\0', sizeof(attr)); + + attr.map_type = map_type; + attr.key_size = key_size; + attr.value_size = 4; + attr.inner_map_fd = inner_map_fd; + attr.max_entries = max_entries; + attr.map_flags = map_flags; + if (name) + memcpy(attr.map_name, name, + min(strlen(name), BPF_OBJ_NAME_LEN - 1)); + + if (node >= 0) { + attr.map_flags |= BPF_F_NUMA_NODE; + attr.numa_node = node; + } + + return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr)); +} + +int bpf_create_map_in_map(enum bpf_map_type map_type, const char *name, + int key_size, int inner_map_fd, int max_entries, + __u32 map_flags) +{ + return bpf_create_map_in_map_node(map_type, name, key_size, + inner_map_fd, max_entries, map_flags, + -1); +} + +static void * +alloc_zero_tailing_info(const void *orecord, __u32 cnt, + __u32 actual_rec_size, __u32 expected_rec_size) +{ + __u64 info_len = (__u64)actual_rec_size * cnt; + void *info, *nrecord; + int i; + + info = malloc(info_len); + if (!info) + return NULL; + + /* zero out bytes kernel does not understand */ + nrecord = info; + for (i = 0; i < cnt; i++) { + memcpy(nrecord, orecord, expected_rec_size); + memset(nrecord + expected_rec_size, 0, + actual_rec_size - expected_rec_size); + orecord += actual_rec_size; + nrecord += actual_rec_size; + } + + return info; +} + +int libbpf__bpf_prog_load(const struct bpf_prog_load_params *load_attr) +{ + void *finfo = NULL, *linfo = NULL; + union bpf_attr attr; + int fd; + + if (!load_attr->log_buf != !load_attr->log_buf_sz) + return -EINVAL; + + if (load_attr->log_level > (4 | 2 | 1) || (load_attr->log_level && !load_attr->log_buf)) + return -EINVAL; + + memset(&attr, 0, sizeof(attr)); + attr.prog_type = load_attr->prog_type; + attr.expected_attach_type = load_attr->expected_attach_type; + + if (load_attr->attach_prog_fd) + attr.attach_prog_fd = load_attr->attach_prog_fd; + else + attr.attach_btf_obj_fd = load_attr->attach_btf_obj_fd; + attr.attach_btf_id = load_attr->attach_btf_id; + + attr.prog_ifindex = load_attr->prog_ifindex; + attr.kern_version = load_attr->kern_version; + + attr.insn_cnt = (__u32)load_attr->insn_cnt; + attr.insns = ptr_to_u64(load_attr->insns); + attr.license = ptr_to_u64(load_attr->license); + + attr.log_level = load_attr->log_level; + if (attr.log_level) { + attr.log_buf = ptr_to_u64(load_attr->log_buf); + attr.log_size = load_attr->log_buf_sz; + } + + attr.prog_btf_fd = load_attr->prog_btf_fd; + attr.prog_flags = load_attr->prog_flags; + + attr.func_info_rec_size = load_attr->func_info_rec_size; + attr.func_info_cnt = load_attr->func_info_cnt; + attr.func_info = ptr_to_u64(load_attr->func_info); + + attr.line_info_rec_size = load_attr->line_info_rec_size; + attr.line_info_cnt = load_attr->line_info_cnt; + attr.line_info = ptr_to_u64(load_attr->line_info); + + if (load_attr->name) + memcpy(attr.prog_name, load_attr->name, + min(strlen(load_attr->name), (size_t)BPF_OBJ_NAME_LEN - 1)); + + fd = sys_bpf_prog_load(&attr, sizeof(attr)); + if (fd >= 0) + return fd; + + /* After bpf_prog_load, the kernel may modify certain attributes + * to give user space a hint how to deal with loading failure. + * Check to see whether we can make some changes and load again. + */ + while (errno == E2BIG && (!finfo || !linfo)) { + if (!finfo && attr.func_info_cnt && + attr.func_info_rec_size < load_attr->func_info_rec_size) { + /* try with corrected func info records */ + finfo = alloc_zero_tailing_info(load_attr->func_info, + load_attr->func_info_cnt, + load_attr->func_info_rec_size, + attr.func_info_rec_size); + if (!finfo) + goto done; + + attr.func_info = ptr_to_u64(finfo); + attr.func_info_rec_size = load_attr->func_info_rec_size; + } else if (!linfo && attr.line_info_cnt && + attr.line_info_rec_size < + load_attr->line_info_rec_size) { + linfo = alloc_zero_tailing_info(load_attr->line_info, + load_attr->line_info_cnt, + load_attr->line_info_rec_size, + attr.line_info_rec_size); + if (!linfo) + goto done; + + attr.line_info = ptr_to_u64(linfo); + attr.line_info_rec_size = load_attr->line_info_rec_size; + } else { + break; + } + + fd = sys_bpf_prog_load(&attr, sizeof(attr)); + if (fd >= 0) + goto done; + } + + if (load_attr->log_level || !load_attr->log_buf) + goto done; + + /* Try again with log */ + attr.log_buf = ptr_to_u64(load_attr->log_buf); + attr.log_size = load_attr->log_buf_sz; + attr.log_level = 1; + load_attr->log_buf[0] = 0; + + fd = sys_bpf_prog_load(&attr, sizeof(attr)); +done: + free(finfo); + free(linfo); + return fd; +} + +int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr, + char *log_buf, size_t log_buf_sz) +{ + struct bpf_prog_load_params p = {}; + + if (!load_attr || !log_buf != !log_buf_sz) + return -EINVAL; + + p.prog_type = load_attr->prog_type; + p.expected_attach_type = load_attr->expected_attach_type; + switch (p.prog_type) { + case BPF_PROG_TYPE_STRUCT_OPS: + case BPF_PROG_TYPE_LSM: + p.attach_btf_id = load_attr->attach_btf_id; + break; + case BPF_PROG_TYPE_TRACING: + case BPF_PROG_TYPE_EXT: + p.attach_btf_id = load_attr->attach_btf_id; + p.attach_prog_fd = load_attr->attach_prog_fd; + break; + default: + p.prog_ifindex = load_attr->prog_ifindex; + p.kern_version = load_attr->kern_version; + } + p.insn_cnt = load_attr->insns_cnt; + p.insns = load_attr->insns; + p.license = load_attr->license; + p.log_level = load_attr->log_level; + p.log_buf = log_buf; + p.log_buf_sz = log_buf_sz; + p.prog_btf_fd = load_attr->prog_btf_fd; + p.func_info_rec_size = load_attr->func_info_rec_size; + p.func_info_cnt = load_attr->func_info_cnt; + p.func_info = load_attr->func_info; + p.line_info_rec_size = load_attr->line_info_rec_size; + p.line_info_cnt = load_attr->line_info_cnt; + p.line_info = load_attr->line_info; + p.name = load_attr->name; + p.prog_flags = load_attr->prog_flags; + + return libbpf__bpf_prog_load(&p); +} + +int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, + size_t insns_cnt, const char *license, + __u32 kern_version, char *log_buf, + size_t log_buf_sz) +{ + struct bpf_load_program_attr load_attr; + + memset(&load_attr, 0, sizeof(struct bpf_load_program_attr)); + load_attr.prog_type = type; + load_attr.expected_attach_type = 0; + load_attr.name = NULL; + load_attr.insns = insns; + load_attr.insns_cnt = insns_cnt; + load_attr.license = license; + load_attr.kern_version = kern_version; + + return bpf_load_program_xattr(&load_attr, log_buf, log_buf_sz); +} + +int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, + size_t insns_cnt, __u32 prog_flags, const char *license, + __u32 kern_version, char *log_buf, size_t log_buf_sz, + int log_level) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.prog_type = type; + attr.insn_cnt = (__u32)insns_cnt; + attr.insns = ptr_to_u64(insns); + attr.license = ptr_to_u64(license); + attr.log_buf = ptr_to_u64(log_buf); + attr.log_size = log_buf_sz; + attr.log_level = log_level; + log_buf[0] = 0; + attr.kern_version = kern_version; + attr.prog_flags = prog_flags; + + return sys_bpf_prog_load(&attr, sizeof(attr)); +} + +int bpf_map_update_elem(int fd, const void *key, const void *value, + __u64 flags) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.map_fd = fd; + attr.key = ptr_to_u64(key); + attr.value = ptr_to_u64(value); + attr.flags = flags; + + return sys_bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr)); +} + +int bpf_map_lookup_elem(int fd, const void *key, void *value) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.map_fd = fd; + attr.key = ptr_to_u64(key); + attr.value = ptr_to_u64(value); + + return sys_bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr)); +} + +int bpf_map_lookup_elem_flags(int fd, const void *key, void *value, __u64 flags) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.map_fd = fd; + attr.key = ptr_to_u64(key); + attr.value = ptr_to_u64(value); + attr.flags = flags; + + return sys_bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr)); +} + +int bpf_map_lookup_and_delete_elem(int fd, const void *key, void *value) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.map_fd = fd; + attr.key = ptr_to_u64(key); + attr.value = ptr_to_u64(value); + + return sys_bpf(BPF_MAP_LOOKUP_AND_DELETE_ELEM, &attr, sizeof(attr)); +} + +int bpf_map_delete_elem(int fd, const void *key) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.map_fd = fd; + attr.key = ptr_to_u64(key); + + return sys_bpf(BPF_MAP_DELETE_ELEM, &attr, sizeof(attr)); +} + +int bpf_map_get_next_key(int fd, const void *key, void *next_key) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.map_fd = fd; + attr.key = ptr_to_u64(key); + attr.next_key = ptr_to_u64(next_key); + + return sys_bpf(BPF_MAP_GET_NEXT_KEY, &attr, sizeof(attr)); +} + +int bpf_map_freeze(int fd) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.map_fd = fd; + + return sys_bpf(BPF_MAP_FREEZE, &attr, sizeof(attr)); +} + +static int bpf_map_batch_common(int cmd, int fd, void *in_batch, + void *out_batch, void *keys, void *values, + __u32 *count, + const struct bpf_map_batch_opts *opts) +{ + union bpf_attr attr; + int ret; + + if (!OPTS_VALID(opts, bpf_map_batch_opts)) + return -EINVAL; + + memset(&attr, 0, sizeof(attr)); + attr.batch.map_fd = fd; + attr.batch.in_batch = ptr_to_u64(in_batch); + attr.batch.out_batch = ptr_to_u64(out_batch); + attr.batch.keys = ptr_to_u64(keys); + attr.batch.values = ptr_to_u64(values); + attr.batch.count = *count; + attr.batch.elem_flags = OPTS_GET(opts, elem_flags, 0); + attr.batch.flags = OPTS_GET(opts, flags, 0); + + ret = sys_bpf(cmd, &attr, sizeof(attr)); + *count = attr.batch.count; + + return ret; +} + +int bpf_map_delete_batch(int fd, void *keys, __u32 *count, + const struct bpf_map_batch_opts *opts) +{ + return bpf_map_batch_common(BPF_MAP_DELETE_BATCH, fd, NULL, + NULL, keys, NULL, count, opts); +} + +int bpf_map_lookup_batch(int fd, void *in_batch, void *out_batch, void *keys, + void *values, __u32 *count, + const struct bpf_map_batch_opts *opts) +{ + return bpf_map_batch_common(BPF_MAP_LOOKUP_BATCH, fd, in_batch, + out_batch, keys, values, count, opts); +} + +int bpf_map_lookup_and_delete_batch(int fd, void *in_batch, void *out_batch, + void *keys, void *values, __u32 *count, + const struct bpf_map_batch_opts *opts) +{ + return bpf_map_batch_common(BPF_MAP_LOOKUP_AND_DELETE_BATCH, + fd, in_batch, out_batch, keys, values, + count, opts); +} + +int bpf_map_update_batch(int fd, void *keys, void *values, __u32 *count, + const struct bpf_map_batch_opts *opts) +{ + return bpf_map_batch_common(BPF_MAP_UPDATE_BATCH, fd, NULL, NULL, + keys, values, count, opts); +} + +int bpf_obj_pin(int fd, const char *pathname) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.pathname = ptr_to_u64((void *)pathname); + attr.bpf_fd = fd; + + return sys_bpf(BPF_OBJ_PIN, &attr, sizeof(attr)); +} + +int bpf_obj_get(const char *pathname) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.pathname = ptr_to_u64((void *)pathname); + + return sys_bpf(BPF_OBJ_GET, &attr, sizeof(attr)); +} + +int bpf_prog_attach(int prog_fd, int target_fd, enum bpf_attach_type type, + unsigned int flags) +{ + DECLARE_LIBBPF_OPTS(bpf_prog_attach_opts, opts, + .flags = flags, + ); + + return bpf_prog_attach_xattr(prog_fd, target_fd, type, &opts); +} + +int bpf_prog_attach_xattr(int prog_fd, int target_fd, + enum bpf_attach_type type, + const struct bpf_prog_attach_opts *opts) +{ + union bpf_attr attr; + + if (!OPTS_VALID(opts, bpf_prog_attach_opts)) + return -EINVAL; + + memset(&attr, 0, sizeof(attr)); + attr.target_fd = target_fd; + attr.attach_bpf_fd = prog_fd; + attr.attach_type = type; + attr.attach_flags = OPTS_GET(opts, flags, 0); + attr.replace_bpf_fd = OPTS_GET(opts, replace_prog_fd, 0); + + return sys_bpf(BPF_PROG_ATTACH, &attr, sizeof(attr)); +} + +int bpf_prog_detach(int target_fd, enum bpf_attach_type type) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.target_fd = target_fd; + attr.attach_type = type; + + return sys_bpf(BPF_PROG_DETACH, &attr, sizeof(attr)); +} + +int bpf_prog_detach2(int prog_fd, int target_fd, enum bpf_attach_type type) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.target_fd = target_fd; + attr.attach_bpf_fd = prog_fd; + attr.attach_type = type; + + return sys_bpf(BPF_PROG_DETACH, &attr, sizeof(attr)); +} + +int bpf_link_create(int prog_fd, int target_fd, + enum bpf_attach_type attach_type, + const struct bpf_link_create_opts *opts) +{ + __u32 target_btf_id, iter_info_len; + union bpf_attr attr; + + if (!OPTS_VALID(opts, bpf_link_create_opts)) + return -EINVAL; + + iter_info_len = OPTS_GET(opts, iter_info_len, 0); + target_btf_id = OPTS_GET(opts, target_btf_id, 0); + + if (iter_info_len && target_btf_id) + return -EINVAL; + + memset(&attr, 0, sizeof(attr)); + attr.link_create.prog_fd = prog_fd; + attr.link_create.target_fd = target_fd; + attr.link_create.attach_type = attach_type; + attr.link_create.flags = OPTS_GET(opts, flags, 0); + + if (iter_info_len) { + attr.link_create.iter_info = + ptr_to_u64(OPTS_GET(opts, iter_info, (void *)0)); + attr.link_create.iter_info_len = iter_info_len; + } else if (target_btf_id) { + attr.link_create.target_btf_id = target_btf_id; + } + + return sys_bpf(BPF_LINK_CREATE, &attr, sizeof(attr)); +} + +int bpf_link_detach(int link_fd) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.link_detach.link_fd = link_fd; + + return sys_bpf(BPF_LINK_DETACH, &attr, sizeof(attr)); +} + +int bpf_link_update(int link_fd, int new_prog_fd, + const struct bpf_link_update_opts *opts) +{ + union bpf_attr attr; + + if (!OPTS_VALID(opts, bpf_link_update_opts)) + return -EINVAL; + + memset(&attr, 0, sizeof(attr)); + attr.link_update.link_fd = link_fd; + attr.link_update.new_prog_fd = new_prog_fd; + attr.link_update.flags = OPTS_GET(opts, flags, 0); + attr.link_update.old_prog_fd = OPTS_GET(opts, old_prog_fd, 0); + + return sys_bpf(BPF_LINK_UPDATE, &attr, sizeof(attr)); +} + +int bpf_iter_create(int link_fd) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.iter_create.link_fd = link_fd; + + return sys_bpf(BPF_ITER_CREATE, &attr, sizeof(attr)); +} + +int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags, + __u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt) +{ + union bpf_attr attr; + int ret; + + memset(&attr, 0, sizeof(attr)); + attr.query.target_fd = target_fd; + attr.query.attach_type = type; + attr.query.query_flags = query_flags; + attr.query.prog_cnt = *prog_cnt; + attr.query.prog_ids = ptr_to_u64(prog_ids); + + ret = sys_bpf(BPF_PROG_QUERY, &attr, sizeof(attr)); + if (attach_flags) + *attach_flags = attr.query.attach_flags; + *prog_cnt = attr.query.prog_cnt; + return ret; +} + +int bpf_prog_test_run(int prog_fd, int repeat, void *data, __u32 size, + void *data_out, __u32 *size_out, __u32 *retval, + __u32 *duration) +{ + union bpf_attr attr; + int ret; + + memset(&attr, 0, sizeof(attr)); + attr.test.prog_fd = prog_fd; + attr.test.data_in = ptr_to_u64(data); + attr.test.data_out = ptr_to_u64(data_out); + attr.test.data_size_in = size; + attr.test.repeat = repeat; + + ret = sys_bpf(BPF_PROG_TEST_RUN, &attr, sizeof(attr)); + if (size_out) + *size_out = attr.test.data_size_out; + if (retval) + *retval = attr.test.retval; + if (duration) + *duration = attr.test.duration; + return ret; +} + +int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr) +{ + union bpf_attr attr; + int ret; + + if (!test_attr->data_out && test_attr->data_size_out > 0) + return -EINVAL; + + memset(&attr, 0, sizeof(attr)); + attr.test.prog_fd = test_attr->prog_fd; + attr.test.data_in = ptr_to_u64(test_attr->data_in); + attr.test.data_out = ptr_to_u64(test_attr->data_out); + attr.test.data_size_in = test_attr->data_size_in; + attr.test.data_size_out = test_attr->data_size_out; + attr.test.ctx_in = ptr_to_u64(test_attr->ctx_in); + attr.test.ctx_out = ptr_to_u64(test_attr->ctx_out); + attr.test.ctx_size_in = test_attr->ctx_size_in; + attr.test.ctx_size_out = test_attr->ctx_size_out; + attr.test.repeat = test_attr->repeat; + + ret = sys_bpf(BPF_PROG_TEST_RUN, &attr, sizeof(attr)); + test_attr->data_size_out = attr.test.data_size_out; + test_attr->ctx_size_out = attr.test.ctx_size_out; + test_attr->retval = attr.test.retval; + test_attr->duration = attr.test.duration; + return ret; +} + +int bpf_prog_test_run_opts(int prog_fd, struct bpf_test_run_opts *opts) +{ + union bpf_attr attr; + int ret; + + if (!OPTS_VALID(opts, bpf_test_run_opts)) + return -EINVAL; + + memset(&attr, 0, sizeof(attr)); + attr.test.prog_fd = prog_fd; + attr.test.cpu = OPTS_GET(opts, cpu, 0); + attr.test.flags = OPTS_GET(opts, flags, 0); + attr.test.repeat = OPTS_GET(opts, repeat, 0); + attr.test.duration = OPTS_GET(opts, duration, 0); + attr.test.ctx_size_in = OPTS_GET(opts, ctx_size_in, 0); + attr.test.ctx_size_out = OPTS_GET(opts, ctx_size_out, 0); + attr.test.data_size_in = OPTS_GET(opts, data_size_in, 0); + attr.test.data_size_out = OPTS_GET(opts, data_size_out, 0); + attr.test.ctx_in = ptr_to_u64(OPTS_GET(opts, ctx_in, NULL)); + attr.test.ctx_out = ptr_to_u64(OPTS_GET(opts, ctx_out, NULL)); + attr.test.data_in = ptr_to_u64(OPTS_GET(opts, data_in, NULL)); + attr.test.data_out = ptr_to_u64(OPTS_GET(opts, data_out, NULL)); + + ret = sys_bpf(BPF_PROG_TEST_RUN, &attr, sizeof(attr)); + OPTS_SET(opts, data_size_out, attr.test.data_size_out); + OPTS_SET(opts, ctx_size_out, attr.test.ctx_size_out); + OPTS_SET(opts, duration, attr.test.duration); + OPTS_SET(opts, retval, attr.test.retval); + return ret; +} + +static int bpf_obj_get_next_id(__u32 start_id, __u32 *next_id, int cmd) +{ + union bpf_attr attr; + int err; + + memset(&attr, 0, sizeof(attr)); + attr.start_id = start_id; + + err = sys_bpf(cmd, &attr, sizeof(attr)); + if (!err) + *next_id = attr.next_id; + + return err; +} + +int bpf_prog_get_next_id(__u32 start_id, __u32 *next_id) +{ + return bpf_obj_get_next_id(start_id, next_id, BPF_PROG_GET_NEXT_ID); +} + +int bpf_map_get_next_id(__u32 start_id, __u32 *next_id) +{ + return bpf_obj_get_next_id(start_id, next_id, BPF_MAP_GET_NEXT_ID); +} + +int bpf_btf_get_next_id(__u32 start_id, __u32 *next_id) +{ + return bpf_obj_get_next_id(start_id, next_id, BPF_BTF_GET_NEXT_ID); +} + +int bpf_link_get_next_id(__u32 start_id, __u32 *next_id) +{ + return bpf_obj_get_next_id(start_id, next_id, BPF_LINK_GET_NEXT_ID); +} + +int bpf_prog_get_fd_by_id(__u32 id) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.prog_id = id; + + return sys_bpf(BPF_PROG_GET_FD_BY_ID, &attr, sizeof(attr)); +} + +int bpf_map_get_fd_by_id(__u32 id) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.map_id = id; + + return sys_bpf(BPF_MAP_GET_FD_BY_ID, &attr, sizeof(attr)); +} + +int bpf_btf_get_fd_by_id(__u32 id) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.btf_id = id; + + return sys_bpf(BPF_BTF_GET_FD_BY_ID, &attr, sizeof(attr)); +} + +int bpf_link_get_fd_by_id(__u32 id) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.link_id = id; + + return sys_bpf(BPF_LINK_GET_FD_BY_ID, &attr, sizeof(attr)); +} + +int bpf_obj_get_info_by_fd(int bpf_fd, void *info, __u32 *info_len) +{ + union bpf_attr attr; + int err; + + memset(&attr, 0, sizeof(attr)); + attr.info.bpf_fd = bpf_fd; + attr.info.info_len = *info_len; + attr.info.info = ptr_to_u64(info); + + err = sys_bpf(BPF_OBJ_GET_INFO_BY_FD, &attr, sizeof(attr)); + if (!err) + *info_len = attr.info.info_len; + + return err; +} + +int bpf_raw_tracepoint_open(const char *name, int prog_fd) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.raw_tracepoint.name = ptr_to_u64(name); + attr.raw_tracepoint.prog_fd = prog_fd; + + return sys_bpf(BPF_RAW_TRACEPOINT_OPEN, &attr, sizeof(attr)); +} + +int bpf_load_btf(const void *btf, __u32 btf_size, char *log_buf, __u32 log_buf_size, + bool do_log) +{ + union bpf_attr attr = {}; + int fd; + + attr.btf = ptr_to_u64(btf); + attr.btf_size = btf_size; + +retry: + if (do_log && log_buf && log_buf_size) { + attr.btf_log_level = 1; + attr.btf_log_size = log_buf_size; + attr.btf_log_buf = ptr_to_u64(log_buf); + } + + fd = sys_bpf(BPF_BTF_LOAD, &attr, sizeof(attr)); + if (fd == -1 && !do_log && log_buf && log_buf_size) { + do_log = true; + goto retry; + } + + return fd; +} + +int bpf_task_fd_query(int pid, int fd, __u32 flags, char *buf, __u32 *buf_len, + __u32 *prog_id, __u32 *fd_type, __u64 *probe_offset, + __u64 *probe_addr) +{ + union bpf_attr attr = {}; + int err; + + attr.task_fd_query.pid = pid; + attr.task_fd_query.fd = fd; + attr.task_fd_query.flags = flags; + attr.task_fd_query.buf = ptr_to_u64(buf); + attr.task_fd_query.buf_len = *buf_len; + + err = sys_bpf(BPF_TASK_FD_QUERY, &attr, sizeof(attr)); + *buf_len = attr.task_fd_query.buf_len; + *prog_id = attr.task_fd_query.prog_id; + *fd_type = attr.task_fd_query.fd_type; + *probe_offset = attr.task_fd_query.probe_offset; + *probe_addr = attr.task_fd_query.probe_addr; + + return err; +} + +int bpf_enable_stats(enum bpf_stats_type type) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.enable_stats.type = type; + + return sys_bpf(BPF_ENABLE_STATS, &attr, sizeof(attr)); +} + +int bpf_prog_bind_map(int prog_fd, int map_fd, + const struct bpf_prog_bind_opts *opts) +{ + union bpf_attr attr; + + if (!OPTS_VALID(opts, bpf_prog_bind_opts)) + return -EINVAL; + + memset(&attr, 0, sizeof(attr)); + attr.prog_bind_map.prog_fd = prog_fd; + attr.prog_bind_map.map_fd = map_fd; + attr.prog_bind_map.flags = OPTS_GET(opts, flags, 0); + + return sys_bpf(BPF_PROG_BIND_MAP, &attr, sizeof(attr)); +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/bpf_core_read.h dwarves-dfsg-1.21/lib/bpf/src/bpf_core_read.h --- dwarves-dfsg-1.10/lib/bpf/src/bpf_core_read.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/bpf_core_read.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,436 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ +#ifndef __BPF_CORE_READ_H__ +#define __BPF_CORE_READ_H__ + +/* + * enum bpf_field_info_kind is passed as a second argument into + * __builtin_preserve_field_info() built-in to get a specific aspect of + * a field, captured as a first argument. __builtin_preserve_field_info(field, + * info_kind) returns __u32 integer and produces BTF field relocation, which + * is understood and processed by libbpf during BPF object loading. See + * selftests/bpf for examples. + */ +enum bpf_field_info_kind { + BPF_FIELD_BYTE_OFFSET = 0, /* field byte offset */ + BPF_FIELD_BYTE_SIZE = 1, + BPF_FIELD_EXISTS = 2, /* field existence in target kernel */ + BPF_FIELD_SIGNED = 3, + BPF_FIELD_LSHIFT_U64 = 4, + BPF_FIELD_RSHIFT_U64 = 5, +}; + +/* second argument to __builtin_btf_type_id() built-in */ +enum bpf_type_id_kind { + BPF_TYPE_ID_LOCAL = 0, /* BTF type ID in local program */ + BPF_TYPE_ID_TARGET = 1, /* BTF type ID in target kernel */ +}; + +/* second argument to __builtin_preserve_type_info() built-in */ +enum bpf_type_info_kind { + BPF_TYPE_EXISTS = 0, /* type existence in target kernel */ + BPF_TYPE_SIZE = 1, /* type size in target kernel */ +}; + +/* second argument to __builtin_preserve_enum_value() built-in */ +enum bpf_enum_value_kind { + BPF_ENUMVAL_EXISTS = 0, /* enum value existence in kernel */ + BPF_ENUMVAL_VALUE = 1, /* enum value value relocation */ +}; + +#define __CORE_RELO(src, field, info) \ + __builtin_preserve_field_info((src)->field, BPF_FIELD_##info) + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define __CORE_BITFIELD_PROBE_READ(dst, src, fld) \ + bpf_probe_read_kernel( \ + (void *)dst, \ + __CORE_RELO(src, fld, BYTE_SIZE), \ + (const void *)src + __CORE_RELO(src, fld, BYTE_OFFSET)) +#else +/* semantics of LSHIFT_64 assumes loading values into low-ordered bytes, so + * for big-endian we need to adjust destination pointer accordingly, based on + * field byte size + */ +#define __CORE_BITFIELD_PROBE_READ(dst, src, fld) \ + bpf_probe_read_kernel( \ + (void *)dst + (8 - __CORE_RELO(src, fld, BYTE_SIZE)), \ + __CORE_RELO(src, fld, BYTE_SIZE), \ + (const void *)src + __CORE_RELO(src, fld, BYTE_OFFSET)) +#endif + +/* + * Extract bitfield, identified by s->field, and return its value as u64. + * All this is done in relocatable manner, so bitfield changes such as + * signedness, bit size, offset changes, this will be handled automatically. + * This version of macro is using bpf_probe_read_kernel() to read underlying + * integer storage. Macro functions as an expression and its return type is + * bpf_probe_read_kernel()'s return value: 0, on success, <0 on error. + */ +#define BPF_CORE_READ_BITFIELD_PROBED(s, field) ({ \ + unsigned long long val = 0; \ + \ + __CORE_BITFIELD_PROBE_READ(&val, s, field); \ + val <<= __CORE_RELO(s, field, LSHIFT_U64); \ + if (__CORE_RELO(s, field, SIGNED)) \ + val = ((long long)val) >> __CORE_RELO(s, field, RSHIFT_U64); \ + else \ + val = val >> __CORE_RELO(s, field, RSHIFT_U64); \ + val; \ +}) + +/* + * Extract bitfield, identified by s->field, and return its value as u64. + * This version of macro is using direct memory reads and should be used from + * BPF program types that support such functionality (e.g., typed raw + * tracepoints). + */ +#define BPF_CORE_READ_BITFIELD(s, field) ({ \ + const void *p = (const void *)s + __CORE_RELO(s, field, BYTE_OFFSET); \ + unsigned long long val; \ + \ + switch (__CORE_RELO(s, field, BYTE_SIZE)) { \ + case 1: val = *(const unsigned char *)p; \ + case 2: val = *(const unsigned short *)p; \ + case 4: val = *(const unsigned int *)p; \ + case 8: val = *(const unsigned long long *)p; \ + } \ + val <<= __CORE_RELO(s, field, LSHIFT_U64); \ + if (__CORE_RELO(s, field, SIGNED)) \ + val = ((long long)val) >> __CORE_RELO(s, field, RSHIFT_U64); \ + else \ + val = val >> __CORE_RELO(s, field, RSHIFT_U64); \ + val; \ +}) + +/* + * Convenience macro to check that field actually exists in target kernel's. + * Returns: + * 1, if matching field is present in target kernel; + * 0, if no matching field found. + */ +#define bpf_core_field_exists(field) \ + __builtin_preserve_field_info(field, BPF_FIELD_EXISTS) + +/* + * Convenience macro to get the byte size of a field. Works for integers, + * struct/unions, pointers, arrays, and enums. + */ +#define bpf_core_field_size(field) \ + __builtin_preserve_field_info(field, BPF_FIELD_BYTE_SIZE) + +/* + * Convenience macro to get BTF type ID of a specified type, using a local BTF + * information. Return 32-bit unsigned integer with type ID from program's own + * BTF. Always succeeds. + */ +#define bpf_core_type_id_local(type) \ + __builtin_btf_type_id(*(typeof(type) *)0, BPF_TYPE_ID_LOCAL) + +/* + * Convenience macro to get BTF type ID of a target kernel's type that matches + * specified local type. + * Returns: + * - valid 32-bit unsigned type ID in kernel BTF; + * - 0, if no matching type was found in a target kernel BTF. + */ +#define bpf_core_type_id_kernel(type) \ + __builtin_btf_type_id(*(typeof(type) *)0, BPF_TYPE_ID_TARGET) + +/* + * Convenience macro to check that provided named type + * (struct/union/enum/typedef) exists in a target kernel. + * Returns: + * 1, if such type is present in target kernel's BTF; + * 0, if no matching type is found. + */ +#define bpf_core_type_exists(type) \ + __builtin_preserve_type_info(*(typeof(type) *)0, BPF_TYPE_EXISTS) + +/* + * Convenience macro to get the byte size of a provided named type + * (struct/union/enum/typedef) in a target kernel. + * Returns: + * >= 0 size (in bytes), if type is present in target kernel's BTF; + * 0, if no matching type is found. + */ +#define bpf_core_type_size(type) \ + __builtin_preserve_type_info(*(typeof(type) *)0, BPF_TYPE_SIZE) + +/* + * Convenience macro to check that provided enumerator value is defined in + * a target kernel. + * Returns: + * 1, if specified enum type and its enumerator value are present in target + * kernel's BTF; + * 0, if no matching enum and/or enum value within that enum is found. + */ +#define bpf_core_enum_value_exists(enum_type, enum_value) \ + __builtin_preserve_enum_value(*(typeof(enum_type) *)enum_value, BPF_ENUMVAL_EXISTS) + +/* + * Convenience macro to get the integer value of an enumerator value in + * a target kernel. + * Returns: + * 64-bit value, if specified enum type and its enumerator value are + * present in target kernel's BTF; + * 0, if no matching enum and/or enum value within that enum is found. + */ +#define bpf_core_enum_value(enum_type, enum_value) \ + __builtin_preserve_enum_value(*(typeof(enum_type) *)enum_value, BPF_ENUMVAL_VALUE) + +/* + * bpf_core_read() abstracts away bpf_probe_read_kernel() call and captures + * offset relocation for source address using __builtin_preserve_access_index() + * built-in, provided by Clang. + * + * __builtin_preserve_access_index() takes as an argument an expression of + * taking an address of a field within struct/union. It makes compiler emit + * a relocation, which records BTF type ID describing root struct/union and an + * accessor string which describes exact embedded field that was used to take + * an address. See detailed description of this relocation format and + * semantics in comments to struct bpf_field_reloc in libbpf_internal.h. + * + * This relocation allows libbpf to adjust BPF instruction to use correct + * actual field offset, based on target kernel BTF type that matches original + * (local) BTF, used to record relocation. + */ +#define bpf_core_read(dst, sz, src) \ + bpf_probe_read_kernel(dst, sz, (const void *)__builtin_preserve_access_index(src)) + +/* NOTE: see comments for BPF_CORE_READ_USER() about the proper types use. */ +#define bpf_core_read_user(dst, sz, src) \ + bpf_probe_read_user(dst, sz, (const void *)__builtin_preserve_access_index(src)) +/* + * bpf_core_read_str() is a thin wrapper around bpf_probe_read_str() + * additionally emitting BPF CO-RE field relocation for specified source + * argument. + */ +#define bpf_core_read_str(dst, sz, src) \ + bpf_probe_read_kernel_str(dst, sz, (const void *)__builtin_preserve_access_index(src)) + +/* NOTE: see comments for BPF_CORE_READ_USER() about the proper types use. */ +#define bpf_core_read_user_str(dst, sz, src) \ + bpf_probe_read_user_str(dst, sz, (const void *)__builtin_preserve_access_index(src)) + +#define ___concat(a, b) a ## b +#define ___apply(fn, n) ___concat(fn, n) +#define ___nth(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, __11, N, ...) N + +/* + * return number of provided arguments; used for switch-based variadic macro + * definitions (see ___last, ___arrow, etc below) + */ +#define ___narg(...) ___nth(_, ##__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) +/* + * return 0 if no arguments are passed, N - otherwise; used for + * recursively-defined macros to specify termination (0) case, and generic + * (N) case (e.g., ___read_ptrs, ___core_read) + */ +#define ___empty(...) ___nth(_, ##__VA_ARGS__, N, N, N, N, N, N, N, N, N, N, 0) + +#define ___last1(x) x +#define ___last2(a, x) x +#define ___last3(a, b, x) x +#define ___last4(a, b, c, x) x +#define ___last5(a, b, c, d, x) x +#define ___last6(a, b, c, d, e, x) x +#define ___last7(a, b, c, d, e, f, x) x +#define ___last8(a, b, c, d, e, f, g, x) x +#define ___last9(a, b, c, d, e, f, g, h, x) x +#define ___last10(a, b, c, d, e, f, g, h, i, x) x +#define ___last(...) ___apply(___last, ___narg(__VA_ARGS__))(__VA_ARGS__) + +#define ___nolast2(a, _) a +#define ___nolast3(a, b, _) a, b +#define ___nolast4(a, b, c, _) a, b, c +#define ___nolast5(a, b, c, d, _) a, b, c, d +#define ___nolast6(a, b, c, d, e, _) a, b, c, d, e +#define ___nolast7(a, b, c, d, e, f, _) a, b, c, d, e, f +#define ___nolast8(a, b, c, d, e, f, g, _) a, b, c, d, e, f, g +#define ___nolast9(a, b, c, d, e, f, g, h, _) a, b, c, d, e, f, g, h +#define ___nolast10(a, b, c, d, e, f, g, h, i, _) a, b, c, d, e, f, g, h, i +#define ___nolast(...) ___apply(___nolast, ___narg(__VA_ARGS__))(__VA_ARGS__) + +#define ___arrow1(a) a +#define ___arrow2(a, b) a->b +#define ___arrow3(a, b, c) a->b->c +#define ___arrow4(a, b, c, d) a->b->c->d +#define ___arrow5(a, b, c, d, e) a->b->c->d->e +#define ___arrow6(a, b, c, d, e, f) a->b->c->d->e->f +#define ___arrow7(a, b, c, d, e, f, g) a->b->c->d->e->f->g +#define ___arrow8(a, b, c, d, e, f, g, h) a->b->c->d->e->f->g->h +#define ___arrow9(a, b, c, d, e, f, g, h, i) a->b->c->d->e->f->g->h->i +#define ___arrow10(a, b, c, d, e, f, g, h, i, j) a->b->c->d->e->f->g->h->i->j +#define ___arrow(...) ___apply(___arrow, ___narg(__VA_ARGS__))(__VA_ARGS__) + +#define ___type(...) typeof(___arrow(__VA_ARGS__)) + +#define ___read(read_fn, dst, src_type, src, accessor) \ + read_fn((void *)(dst), sizeof(*(dst)), &((src_type)(src))->accessor) + +/* "recursively" read a sequence of inner pointers using local __t var */ +#define ___rd_first(fn, src, a) ___read(fn, &__t, ___type(src), src, a); +#define ___rd_last(fn, ...) \ + ___read(fn, &__t, ___type(___nolast(__VA_ARGS__)), __t, ___last(__VA_ARGS__)); +#define ___rd_p1(fn, ...) const void *__t; ___rd_first(fn, __VA_ARGS__) +#define ___rd_p2(fn, ...) ___rd_p1(fn, ___nolast(__VA_ARGS__)) ___rd_last(fn, __VA_ARGS__) +#define ___rd_p3(fn, ...) ___rd_p2(fn, ___nolast(__VA_ARGS__)) ___rd_last(fn, __VA_ARGS__) +#define ___rd_p4(fn, ...) ___rd_p3(fn, ___nolast(__VA_ARGS__)) ___rd_last(fn, __VA_ARGS__) +#define ___rd_p5(fn, ...) ___rd_p4(fn, ___nolast(__VA_ARGS__)) ___rd_last(fn, __VA_ARGS__) +#define ___rd_p6(fn, ...) ___rd_p5(fn, ___nolast(__VA_ARGS__)) ___rd_last(fn, __VA_ARGS__) +#define ___rd_p7(fn, ...) ___rd_p6(fn, ___nolast(__VA_ARGS__)) ___rd_last(fn, __VA_ARGS__) +#define ___rd_p8(fn, ...) ___rd_p7(fn, ___nolast(__VA_ARGS__)) ___rd_last(fn, __VA_ARGS__) +#define ___rd_p9(fn, ...) ___rd_p8(fn, ___nolast(__VA_ARGS__)) ___rd_last(fn, __VA_ARGS__) +#define ___read_ptrs(fn, src, ...) \ + ___apply(___rd_p, ___narg(__VA_ARGS__))(fn, src, __VA_ARGS__) + +#define ___core_read0(fn, fn_ptr, dst, src, a) \ + ___read(fn, dst, ___type(src), src, a); +#define ___core_readN(fn, fn_ptr, dst, src, ...) \ + ___read_ptrs(fn_ptr, src, ___nolast(__VA_ARGS__)) \ + ___read(fn, dst, ___type(src, ___nolast(__VA_ARGS__)), __t, \ + ___last(__VA_ARGS__)); +#define ___core_read(fn, fn_ptr, dst, src, a, ...) \ + ___apply(___core_read, ___empty(__VA_ARGS__))(fn, fn_ptr, dst, \ + src, a, ##__VA_ARGS__) + +/* + * BPF_CORE_READ_INTO() is a more performance-conscious variant of + * BPF_CORE_READ(), in which final field is read into user-provided storage. + * See BPF_CORE_READ() below for more details on general usage. + */ +#define BPF_CORE_READ_INTO(dst, src, a, ...) ({ \ + ___core_read(bpf_core_read, bpf_core_read, \ + dst, (src), a, ##__VA_ARGS__) \ +}) + +/* + * Variant of BPF_CORE_READ_INTO() for reading from user-space memory. + * + * NOTE: see comments for BPF_CORE_READ_USER() about the proper types use. + */ +#define BPF_CORE_READ_USER_INTO(dst, src, a, ...) ({ \ + ___core_read(bpf_core_read_user, bpf_core_read_user, \ + dst, (src), a, ##__VA_ARGS__) \ +}) + +/* Non-CO-RE variant of BPF_CORE_READ_INTO() */ +#define BPF_PROBE_READ_INTO(dst, src, a, ...) ({ \ + ___core_read(bpf_probe_read, bpf_probe_read, \ + dst, (src), a, ##__VA_ARGS__) \ +}) + +/* Non-CO-RE variant of BPF_CORE_READ_USER_INTO(). + * + * As no CO-RE relocations are emitted, source types can be arbitrary and are + * not restricted to kernel types only. + */ +#define BPF_PROBE_READ_USER_INTO(dst, src, a, ...) ({ \ + ___core_read(bpf_probe_read_user, bpf_probe_read_user, \ + dst, (src), a, ##__VA_ARGS__) \ +}) + +/* + * BPF_CORE_READ_STR_INTO() does same "pointer chasing" as + * BPF_CORE_READ() for intermediate pointers, but then executes (and returns + * corresponding error code) bpf_core_read_str() for final string read. + */ +#define BPF_CORE_READ_STR_INTO(dst, src, a, ...) ({ \ + ___core_read(bpf_core_read_str, bpf_core_read, \ + dst, (src), a, ##__VA_ARGS__) \ +}) + +/* + * Variant of BPF_CORE_READ_STR_INTO() for reading from user-space memory. + * + * NOTE: see comments for BPF_CORE_READ_USER() about the proper types use. + */ +#define BPF_CORE_READ_USER_STR_INTO(dst, src, a, ...) ({ \ + ___core_read(bpf_core_read_user_str, bpf_core_read_user, \ + dst, (src), a, ##__VA_ARGS__) \ +}) + +/* Non-CO-RE variant of BPF_CORE_READ_STR_INTO() */ +#define BPF_PROBE_READ_STR_INTO(dst, src, a, ...) ({ \ + ___core_read(bpf_probe_read_str, bpf_probe_read, \ + dst, (src), a, ##__VA_ARGS__) \ +}) + +/* + * Non-CO-RE variant of BPF_CORE_READ_USER_STR_INTO(). + * + * As no CO-RE relocations are emitted, source types can be arbitrary and are + * not restricted to kernel types only. + */ +#define BPF_PROBE_READ_USER_STR_INTO(dst, src, a, ...) ({ \ + ___core_read(bpf_probe_read_user_str, bpf_probe_read_user, \ + dst, (src), a, ##__VA_ARGS__) \ +}) + +/* + * BPF_CORE_READ() is used to simplify BPF CO-RE relocatable read, especially + * when there are few pointer chasing steps. + * E.g., what in non-BPF world (or in BPF w/ BCC) would be something like: + * int x = s->a.b.c->d.e->f->g; + * can be succinctly achieved using BPF_CORE_READ as: + * int x = BPF_CORE_READ(s, a.b.c, d.e, f, g); + * + * BPF_CORE_READ will decompose above statement into 4 bpf_core_read (BPF + * CO-RE relocatable bpf_probe_read_kernel() wrapper) calls, logically + * equivalent to: + * 1. const void *__t = s->a.b.c; + * 2. __t = __t->d.e; + * 3. __t = __t->f; + * 4. return __t->g; + * + * Equivalence is logical, because there is a heavy type casting/preservation + * involved, as well as all the reads are happening through + * bpf_probe_read_kernel() calls using __builtin_preserve_access_index() to + * emit CO-RE relocations. + * + * N.B. Only up to 9 "field accessors" are supported, which should be more + * than enough for any practical purpose. + */ +#define BPF_CORE_READ(src, a, ...) ({ \ + ___type((src), a, ##__VA_ARGS__) __r; \ + BPF_CORE_READ_INTO(&__r, (src), a, ##__VA_ARGS__); \ + __r; \ +}) + +/* + * Variant of BPF_CORE_READ() for reading from user-space memory. + * + * NOTE: all the source types involved are still *kernel types* and need to + * exist in kernel (or kernel module) BTF, otherwise CO-RE relocation will + * fail. Custom user types are not relocatable with CO-RE. + * The typical situation in which BPF_CORE_READ_USER() might be used is to + * read kernel UAPI types from the user-space memory passed in as a syscall + * input argument. + */ +#define BPF_CORE_READ_USER(src, a, ...) ({ \ + ___type((src), a, ##__VA_ARGS__) __r; \ + BPF_CORE_READ_USER_INTO(&__r, (src), a, ##__VA_ARGS__); \ + __r; \ +}) + +/* Non-CO-RE variant of BPF_CORE_READ() */ +#define BPF_PROBE_READ(src, a, ...) ({ \ + ___type((src), a, ##__VA_ARGS__) __r; \ + BPF_PROBE_READ_INTO(&__r, (src), a, ##__VA_ARGS__); \ + __r; \ +}) + +/* + * Non-CO-RE variant of BPF_CORE_READ_USER(). + * + * As no CO-RE relocations are emitted, source types can be arbitrary and are + * not restricted to kernel types only. + */ +#define BPF_PROBE_READ_USER(src, a, ...) ({ \ + ___type((src), a, ##__VA_ARGS__) __r; \ + BPF_PROBE_READ_USER_INTO(&__r, (src), a, ##__VA_ARGS__); \ + __r; \ +}) + +#endif + diff -Nru dwarves-dfsg-1.10/lib/bpf/src/bpf_endian.h dwarves-dfsg-1.21/lib/bpf/src/bpf_endian.h --- dwarves-dfsg-1.10/lib/bpf/src/bpf_endian.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/bpf_endian.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ +#ifndef __BPF_ENDIAN__ +#define __BPF_ENDIAN__ + +/* + * Isolate byte #n and put it into byte #m, for __u##b type. + * E.g., moving byte #6 (nnnnnnnn) into byte #1 (mmmmmmmm) for __u64: + * 1) xxxxxxxx nnnnnnnn xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx mmmmmmmm xxxxxxxx + * 2) nnnnnnnn xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx mmmmmmmm xxxxxxxx 00000000 + * 3) 00000000 00000000 00000000 00000000 00000000 00000000 00000000 nnnnnnnn + * 4) 00000000 00000000 00000000 00000000 00000000 00000000 nnnnnnnn 00000000 + */ +#define ___bpf_mvb(x, b, n, m) ((__u##b)(x) << (b-(n+1)*8) >> (b-8) << (m*8)) + +#define ___bpf_swab16(x) ((__u16)( \ + ___bpf_mvb(x, 16, 0, 1) | \ + ___bpf_mvb(x, 16, 1, 0))) + +#define ___bpf_swab32(x) ((__u32)( \ + ___bpf_mvb(x, 32, 0, 3) | \ + ___bpf_mvb(x, 32, 1, 2) | \ + ___bpf_mvb(x, 32, 2, 1) | \ + ___bpf_mvb(x, 32, 3, 0))) + +#define ___bpf_swab64(x) ((__u64)( \ + ___bpf_mvb(x, 64, 0, 7) | \ + ___bpf_mvb(x, 64, 1, 6) | \ + ___bpf_mvb(x, 64, 2, 5) | \ + ___bpf_mvb(x, 64, 3, 4) | \ + ___bpf_mvb(x, 64, 4, 3) | \ + ___bpf_mvb(x, 64, 5, 2) | \ + ___bpf_mvb(x, 64, 6, 1) | \ + ___bpf_mvb(x, 64, 7, 0))) + +/* LLVM's BPF target selects the endianness of the CPU + * it compiles on, or the user specifies (bpfel/bpfeb), + * respectively. The used __BYTE_ORDER__ is defined by + * the compiler, we cannot rely on __BYTE_ORDER from + * libc headers, since it doesn't reflect the actual + * requested byte order. + * + * Note, LLVM's BPF target has different __builtin_bswapX() + * semantics. It does map to BPF_ALU | BPF_END | BPF_TO_BE + * in bpfel and bpfeb case, which means below, that we map + * to cpu_to_be16(). We could use it unconditionally in BPF + * case, but better not rely on it, so that this header here + * can be used from application and BPF program side, which + * use different targets. + */ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# define __bpf_ntohs(x) __builtin_bswap16(x) +# define __bpf_htons(x) __builtin_bswap16(x) +# define __bpf_constant_ntohs(x) ___bpf_swab16(x) +# define __bpf_constant_htons(x) ___bpf_swab16(x) +# define __bpf_ntohl(x) __builtin_bswap32(x) +# define __bpf_htonl(x) __builtin_bswap32(x) +# define __bpf_constant_ntohl(x) ___bpf_swab32(x) +# define __bpf_constant_htonl(x) ___bpf_swab32(x) +# define __bpf_be64_to_cpu(x) __builtin_bswap64(x) +# define __bpf_cpu_to_be64(x) __builtin_bswap64(x) +# define __bpf_constant_be64_to_cpu(x) ___bpf_swab64(x) +# define __bpf_constant_cpu_to_be64(x) ___bpf_swab64(x) +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# define __bpf_ntohs(x) (x) +# define __bpf_htons(x) (x) +# define __bpf_constant_ntohs(x) (x) +# define __bpf_constant_htons(x) (x) +# define __bpf_ntohl(x) (x) +# define __bpf_htonl(x) (x) +# define __bpf_constant_ntohl(x) (x) +# define __bpf_constant_htonl(x) (x) +# define __bpf_be64_to_cpu(x) (x) +# define __bpf_cpu_to_be64(x) (x) +# define __bpf_constant_be64_to_cpu(x) (x) +# define __bpf_constant_cpu_to_be64(x) (x) +#else +# error "Fix your compiler's __BYTE_ORDER__?!" +#endif + +#define bpf_htons(x) \ + (__builtin_constant_p(x) ? \ + __bpf_constant_htons(x) : __bpf_htons(x)) +#define bpf_ntohs(x) \ + (__builtin_constant_p(x) ? \ + __bpf_constant_ntohs(x) : __bpf_ntohs(x)) +#define bpf_htonl(x) \ + (__builtin_constant_p(x) ? \ + __bpf_constant_htonl(x) : __bpf_htonl(x)) +#define bpf_ntohl(x) \ + (__builtin_constant_p(x) ? \ + __bpf_constant_ntohl(x) : __bpf_ntohl(x)) +#define bpf_cpu_to_be64(x) \ + (__builtin_constant_p(x) ? \ + __bpf_constant_cpu_to_be64(x) : __bpf_cpu_to_be64(x)) +#define bpf_be64_to_cpu(x) \ + (__builtin_constant_p(x) ? \ + __bpf_constant_be64_to_cpu(x) : __bpf_be64_to_cpu(x)) + +#endif /* __BPF_ENDIAN__ */ diff -Nru dwarves-dfsg-1.10/lib/bpf/src/bpf.h dwarves-dfsg-1.21/lib/bpf/src/bpf.h --- dwarves-dfsg-1.10/lib/bpf/src/bpf.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/bpf.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,285 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +/* + * common eBPF ELF operations. + * + * Copyright (C) 2013-2015 Alexei Starovoitov + * Copyright (C) 2015 Wang Nan + * Copyright (C) 2015 Huawei Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License (not later!) + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see + */ +#ifndef __LIBBPF_BPF_H +#define __LIBBPF_BPF_H + +#include +#include +#include +#include + +#include "libbpf_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct bpf_create_map_attr { + const char *name; + enum bpf_map_type map_type; + __u32 map_flags; + __u32 key_size; + __u32 value_size; + __u32 max_entries; + __u32 numa_node; + __u32 btf_fd; + __u32 btf_key_type_id; + __u32 btf_value_type_id; + __u32 map_ifindex; + union { + __u32 inner_map_fd; + __u32 btf_vmlinux_value_type_id; + }; +}; + +LIBBPF_API int +bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr); +LIBBPF_API int bpf_create_map_node(enum bpf_map_type map_type, const char *name, + int key_size, int value_size, + int max_entries, __u32 map_flags, int node); +LIBBPF_API int bpf_create_map_name(enum bpf_map_type map_type, const char *name, + int key_size, int value_size, + int max_entries, __u32 map_flags); +LIBBPF_API int bpf_create_map(enum bpf_map_type map_type, int key_size, + int value_size, int max_entries, __u32 map_flags); +LIBBPF_API int bpf_create_map_in_map_node(enum bpf_map_type map_type, + const char *name, int key_size, + int inner_map_fd, int max_entries, + __u32 map_flags, int node); +LIBBPF_API int bpf_create_map_in_map(enum bpf_map_type map_type, + const char *name, int key_size, + int inner_map_fd, int max_entries, + __u32 map_flags); + +struct bpf_load_program_attr { + enum bpf_prog_type prog_type; + enum bpf_attach_type expected_attach_type; + const char *name; + const struct bpf_insn *insns; + size_t insns_cnt; + const char *license; + union { + __u32 kern_version; + __u32 attach_prog_fd; + }; + union { + __u32 prog_ifindex; + __u32 attach_btf_id; + }; + __u32 prog_btf_fd; + __u32 func_info_rec_size; + const void *func_info; + __u32 func_info_cnt; + __u32 line_info_rec_size; + const void *line_info; + __u32 line_info_cnt; + __u32 log_level; + __u32 prog_flags; +}; + +/* Flags to direct loading requirements */ +#define MAPS_RELAX_COMPAT 0x01 + +/* Recommend log buffer size */ +#define BPF_LOG_BUF_SIZE (UINT32_MAX >> 8) /* verifier maximum in kernels <= 5.1 */ +LIBBPF_API int +bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr, + char *log_buf, size_t log_buf_sz); +LIBBPF_API int bpf_load_program(enum bpf_prog_type type, + const struct bpf_insn *insns, size_t insns_cnt, + const char *license, __u32 kern_version, + char *log_buf, size_t log_buf_sz); +LIBBPF_API int bpf_verify_program(enum bpf_prog_type type, + const struct bpf_insn *insns, + size_t insns_cnt, __u32 prog_flags, + const char *license, __u32 kern_version, + char *log_buf, size_t log_buf_sz, + int log_level); + +LIBBPF_API int bpf_map_update_elem(int fd, const void *key, const void *value, + __u64 flags); + +LIBBPF_API int bpf_map_lookup_elem(int fd, const void *key, void *value); +LIBBPF_API int bpf_map_lookup_elem_flags(int fd, const void *key, void *value, + __u64 flags); +LIBBPF_API int bpf_map_lookup_and_delete_elem(int fd, const void *key, + void *value); +LIBBPF_API int bpf_map_delete_elem(int fd, const void *key); +LIBBPF_API int bpf_map_get_next_key(int fd, const void *key, void *next_key); +LIBBPF_API int bpf_map_freeze(int fd); + +struct bpf_map_batch_opts { + size_t sz; /* size of this struct for forward/backward compatibility */ + __u64 elem_flags; + __u64 flags; +}; +#define bpf_map_batch_opts__last_field flags + +LIBBPF_API int bpf_map_delete_batch(int fd, void *keys, + __u32 *count, + const struct bpf_map_batch_opts *opts); +LIBBPF_API int bpf_map_lookup_batch(int fd, void *in_batch, void *out_batch, + void *keys, void *values, __u32 *count, + const struct bpf_map_batch_opts *opts); +LIBBPF_API int bpf_map_lookup_and_delete_batch(int fd, void *in_batch, + void *out_batch, void *keys, + void *values, __u32 *count, + const struct bpf_map_batch_opts *opts); +LIBBPF_API int bpf_map_update_batch(int fd, void *keys, void *values, + __u32 *count, + const struct bpf_map_batch_opts *opts); + +LIBBPF_API int bpf_obj_pin(int fd, const char *pathname); +LIBBPF_API int bpf_obj_get(const char *pathname); + +struct bpf_prog_attach_opts { + size_t sz; /* size of this struct for forward/backward compatibility */ + unsigned int flags; + int replace_prog_fd; +}; +#define bpf_prog_attach_opts__last_field replace_prog_fd + +LIBBPF_API int bpf_prog_attach(int prog_fd, int attachable_fd, + enum bpf_attach_type type, unsigned int flags); +LIBBPF_API int bpf_prog_attach_xattr(int prog_fd, int attachable_fd, + enum bpf_attach_type type, + const struct bpf_prog_attach_opts *opts); +LIBBPF_API int bpf_prog_detach(int attachable_fd, enum bpf_attach_type type); +LIBBPF_API int bpf_prog_detach2(int prog_fd, int attachable_fd, + enum bpf_attach_type type); + +union bpf_iter_link_info; /* defined in up-to-date linux/bpf.h */ +struct bpf_link_create_opts { + size_t sz; /* size of this struct for forward/backward compatibility */ + __u32 flags; + union bpf_iter_link_info *iter_info; + __u32 iter_info_len; + __u32 target_btf_id; +}; +#define bpf_link_create_opts__last_field target_btf_id + +LIBBPF_API int bpf_link_create(int prog_fd, int target_fd, + enum bpf_attach_type attach_type, + const struct bpf_link_create_opts *opts); + +LIBBPF_API int bpf_link_detach(int link_fd); + +struct bpf_link_update_opts { + size_t sz; /* size of this struct for forward/backward compatibility */ + __u32 flags; /* extra flags */ + __u32 old_prog_fd; /* expected old program FD */ +}; +#define bpf_link_update_opts__last_field old_prog_fd + +LIBBPF_API int bpf_link_update(int link_fd, int new_prog_fd, + const struct bpf_link_update_opts *opts); + +LIBBPF_API int bpf_iter_create(int link_fd); + +struct bpf_prog_test_run_attr { + int prog_fd; + int repeat; + const void *data_in; + __u32 data_size_in; + void *data_out; /* optional */ + __u32 data_size_out; /* in: max length of data_out + * out: length of data_out */ + __u32 retval; /* out: return code of the BPF program */ + __u32 duration; /* out: average per repetition in ns */ + const void *ctx_in; /* optional */ + __u32 ctx_size_in; + void *ctx_out; /* optional */ + __u32 ctx_size_out; /* in: max length of ctx_out + * out: length of cxt_out */ +}; + +LIBBPF_API int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr); + +/* + * bpf_prog_test_run does not check that data_out is large enough. Consider + * using bpf_prog_test_run_xattr instead. + */ +LIBBPF_API int bpf_prog_test_run(int prog_fd, int repeat, void *data, + __u32 size, void *data_out, __u32 *size_out, + __u32 *retval, __u32 *duration); +LIBBPF_API int bpf_prog_get_next_id(__u32 start_id, __u32 *next_id); +LIBBPF_API int bpf_map_get_next_id(__u32 start_id, __u32 *next_id); +LIBBPF_API int bpf_btf_get_next_id(__u32 start_id, __u32 *next_id); +LIBBPF_API int bpf_link_get_next_id(__u32 start_id, __u32 *next_id); +LIBBPF_API int bpf_prog_get_fd_by_id(__u32 id); +LIBBPF_API int bpf_map_get_fd_by_id(__u32 id); +LIBBPF_API int bpf_btf_get_fd_by_id(__u32 id); +LIBBPF_API int bpf_link_get_fd_by_id(__u32 id); +LIBBPF_API int bpf_obj_get_info_by_fd(int bpf_fd, void *info, __u32 *info_len); +LIBBPF_API int bpf_prog_query(int target_fd, enum bpf_attach_type type, + __u32 query_flags, __u32 *attach_flags, + __u32 *prog_ids, __u32 *prog_cnt); +LIBBPF_API int bpf_raw_tracepoint_open(const char *name, int prog_fd); +LIBBPF_API int bpf_load_btf(const void *btf, __u32 btf_size, char *log_buf, + __u32 log_buf_size, bool do_log); +LIBBPF_API int bpf_task_fd_query(int pid, int fd, __u32 flags, char *buf, + __u32 *buf_len, __u32 *prog_id, __u32 *fd_type, + __u64 *probe_offset, __u64 *probe_addr); + +enum bpf_stats_type; /* defined in up-to-date linux/bpf.h */ +LIBBPF_API int bpf_enable_stats(enum bpf_stats_type type); + +struct bpf_prog_bind_opts { + size_t sz; /* size of this struct for forward/backward compatibility */ + __u32 flags; +}; +#define bpf_prog_bind_opts__last_field flags + +LIBBPF_API int bpf_prog_bind_map(int prog_fd, int map_fd, + const struct bpf_prog_bind_opts *opts); + +struct bpf_test_run_opts { + size_t sz; /* size of this struct for forward/backward compatibility */ + const void *data_in; /* optional */ + void *data_out; /* optional */ + __u32 data_size_in; + __u32 data_size_out; /* in: max length of data_out + * out: length of data_out + */ + const void *ctx_in; /* optional */ + void *ctx_out; /* optional */ + __u32 ctx_size_in; + __u32 ctx_size_out; /* in: max length of ctx_out + * out: length of cxt_out + */ + __u32 retval; /* out: return code of the BPF program */ + int repeat; + __u32 duration; /* out: average per repetition in ns */ + __u32 flags; + __u32 cpu; +}; +#define bpf_test_run_opts__last_field cpu + +LIBBPF_API int bpf_prog_test_run_opts(int prog_fd, + struct bpf_test_run_opts *opts); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __LIBBPF_BPF_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/src/bpf_helper_defs.h dwarves-dfsg-1.21/lib/bpf/src/bpf_helper_defs.h --- dwarves-dfsg-1.10/lib/bpf/src/bpf_helper_defs.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/bpf_helper_defs.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,3835 @@ +/* This is auto-generated file. See bpf_helpers_doc.py for details. */ + +/* Forward declarations of BPF structs */ +struct bpf_fib_lookup; +struct bpf_sk_lookup; +struct bpf_perf_event_data; +struct bpf_perf_event_value; +struct bpf_pidns_info; +struct bpf_redir_neigh; +struct bpf_sock; +struct bpf_sock_addr; +struct bpf_sock_ops; +struct bpf_sock_tuple; +struct bpf_spin_lock; +struct bpf_sysctl; +struct bpf_tcp_sock; +struct bpf_tunnel_key; +struct bpf_xfrm_state; +struct linux_binprm; +struct pt_regs; +struct sk_reuseport_md; +struct sockaddr; +struct tcphdr; +struct seq_file; +struct tcp6_sock; +struct tcp_sock; +struct tcp_timewait_sock; +struct tcp_request_sock; +struct udp6_sock; +struct task_struct; +struct __sk_buff; +struct sk_msg_md; +struct xdp_md; +struct path; +struct btf_ptr; +struct inode; +struct socket; +struct file; + +/* + * bpf_map_lookup_elem + * + * Perform a lookup in *map* for an entry associated to *key*. + * + * Returns + * Map value associated to *key*, or **NULL** if no entry was + * found. + */ +static void *(*bpf_map_lookup_elem)(void *map, const void *key) = (void *) 1; + +/* + * bpf_map_update_elem + * + * Add or update the value of the entry associated to *key* in + * *map* with *value*. *flags* is one of: + * + * **BPF_NOEXIST** + * The entry for *key* must not exist in the map. + * **BPF_EXIST** + * The entry for *key* must already exist in the map. + * **BPF_ANY** + * No condition on the existence of the entry for *key*. + * + * Flag value **BPF_NOEXIST** cannot be used for maps of types + * **BPF_MAP_TYPE_ARRAY** or **BPF_MAP_TYPE_PERCPU_ARRAY** (all + * elements always exist), the helper would return an error. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_map_update_elem)(void *map, const void *key, const void *value, __u64 flags) = (void *) 2; + +/* + * bpf_map_delete_elem + * + * Delete entry with *key* from *map*. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_map_delete_elem)(void *map, const void *key) = (void *) 3; + +/* + * bpf_probe_read + * + * For tracing programs, safely attempt to read *size* bytes from + * kernel space address *unsafe_ptr* and store the data in *dst*. + * + * Generally, use **bpf_probe_read_user**\ () or + * **bpf_probe_read_kernel**\ () instead. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_probe_read)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 4; + +/* + * bpf_ktime_get_ns + * + * Return the time elapsed since system boot, in nanoseconds. + * Does not include time the system was suspended. + * See: **clock_gettime**\ (**CLOCK_MONOTONIC**) + * + * Returns + * Current *ktime*. + */ +static __u64 (*bpf_ktime_get_ns)(void) = (void *) 5; + +/* + * bpf_trace_printk + * + * This helper is a "printk()-like" facility for debugging. It + * prints a message defined by format *fmt* (of size *fmt_size*) + * to file *\/sys/kernel/debug/tracing/trace* from DebugFS, if + * available. It can take up to three additional **u64** + * arguments (as an eBPF helpers, the total number of arguments is + * limited to five). + * + * Each time the helper is called, it appends a line to the trace. + * Lines are discarded while *\/sys/kernel/debug/tracing/trace* is + * open, use *\/sys/kernel/debug/tracing/trace_pipe* to avoid this. + * The format of the trace is customizable, and the exact output + * one will get depends on the options set in + * *\/sys/kernel/debug/tracing/trace_options* (see also the + * *README* file under the same directory). However, it usually + * defaults to something like: + * + * :: + * + * telnet-470 [001] .N.. 419421.045894: 0x00000001: + * + * In the above: + * + * * ``telnet`` is the name of the current task. + * * ``470`` is the PID of the current task. + * * ``001`` is the CPU number on which the task is + * running. + * * In ``.N..``, each character refers to a set of + * options (whether irqs are enabled, scheduling + * options, whether hard/softirqs are running, level of + * preempt_disabled respectively). **N** means that + * **TIF_NEED_RESCHED** and **PREEMPT_NEED_RESCHED** + * are set. + * * ``419421.045894`` is a timestamp. + * * ``0x00000001`` is a fake value used by BPF for the + * instruction pointer register. + * * ```` is the message formatted with + * *fmt*. + * + * The conversion specifiers supported by *fmt* are similar, but + * more limited than for printk(). They are **%d**, **%i**, + * **%u**, **%x**, **%ld**, **%li**, **%lu**, **%lx**, **%lld**, + * **%lli**, **%llu**, **%llx**, **%p**, **%s**. No modifier (size + * of field, padding with zeroes, etc.) is available, and the + * helper will return **-EINVAL** (but print nothing) if it + * encounters an unknown specifier. + * + * Also, note that **bpf_trace_printk**\ () is slow, and should + * only be used for debugging purposes. For this reason, a notice + * block (spanning several lines) is printed to kernel logs and + * states that the helper should not be used "for production use" + * the first time this helper is used (or more precisely, when + * **trace_printk**\ () buffers are allocated). For passing values + * to user space, perf events should be preferred. + * + * Returns + * The number of bytes written to the buffer, or a negative error + * in case of failure. + */ +static long (*bpf_trace_printk)(const char *fmt, __u32 fmt_size, ...) = (void *) 6; + +/* + * bpf_get_prandom_u32 + * + * Get a pseudo-random number. + * + * From a security point of view, this helper uses its own + * pseudo-random internal state, and cannot be used to infer the + * seed of other random functions in the kernel. However, it is + * essential to note that the generator used by the helper is not + * cryptographically secure. + * + * Returns + * A random 32-bit unsigned value. + */ +static __u32 (*bpf_get_prandom_u32)(void) = (void *) 7; + +/* + * bpf_get_smp_processor_id + * + * Get the SMP (symmetric multiprocessing) processor id. Note that + * all programs run with preemption disabled, which means that the + * SMP processor id is stable during all the execution of the + * program. + * + * Returns + * The SMP id of the processor running the program. + */ +static __u32 (*bpf_get_smp_processor_id)(void) = (void *) 8; + +/* + * bpf_skb_store_bytes + * + * Store *len* bytes from address *from* into the packet + * associated to *skb*, at *offset*. *flags* are a combination of + * **BPF_F_RECOMPUTE_CSUM** (automatically recompute the + * checksum for the packet after storing the bytes) and + * **BPF_F_INVALIDATE_HASH** (set *skb*\ **->hash**, *skb*\ + * **->swhash** and *skb*\ **->l4hash** to 0). + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_store_bytes)(struct __sk_buff *skb, __u32 offset, const void *from, __u32 len, __u64 flags) = (void *) 9; + +/* + * bpf_l3_csum_replace + * + * Recompute the layer 3 (e.g. IP) checksum for the packet + * associated to *skb*. Computation is incremental, so the helper + * must know the former value of the header field that was + * modified (*from*), the new value of this field (*to*), and the + * number of bytes (2 or 4) for this field, stored in *size*. + * Alternatively, it is possible to store the difference between + * the previous and the new values of the header field in *to*, by + * setting *from* and *size* to 0. For both methods, *offset* + * indicates the location of the IP checksum within the packet. + * + * This helper works in combination with **bpf_csum_diff**\ (), + * which does not update the checksum in-place, but offers more + * flexibility and can handle sizes larger than 2 or 4 for the + * checksum to update. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_l3_csum_replace)(struct __sk_buff *skb, __u32 offset, __u64 from, __u64 to, __u64 size) = (void *) 10; + +/* + * bpf_l4_csum_replace + * + * Recompute the layer 4 (e.g. TCP, UDP or ICMP) checksum for the + * packet associated to *skb*. Computation is incremental, so the + * helper must know the former value of the header field that was + * modified (*from*), the new value of this field (*to*), and the + * number of bytes (2 or 4) for this field, stored on the lowest + * four bits of *flags*. Alternatively, it is possible to store + * the difference between the previous and the new values of the + * header field in *to*, by setting *from* and the four lowest + * bits of *flags* to 0. For both methods, *offset* indicates the + * location of the IP checksum within the packet. In addition to + * the size of the field, *flags* can be added (bitwise OR) actual + * flags. With **BPF_F_MARK_MANGLED_0**, a null checksum is left + * untouched (unless **BPF_F_MARK_ENFORCE** is added as well), and + * for updates resulting in a null checksum the value is set to + * **CSUM_MANGLED_0** instead. Flag **BPF_F_PSEUDO_HDR** indicates + * the checksum is to be computed against a pseudo-header. + * + * This helper works in combination with **bpf_csum_diff**\ (), + * which does not update the checksum in-place, but offers more + * flexibility and can handle sizes larger than 2 or 4 for the + * checksum to update. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_l4_csum_replace)(struct __sk_buff *skb, __u32 offset, __u64 from, __u64 to, __u64 flags) = (void *) 11; + +/* + * bpf_tail_call + * + * This special helper is used to trigger a "tail call", or in + * other words, to jump into another eBPF program. The same stack + * frame is used (but values on stack and in registers for the + * caller are not accessible to the callee). This mechanism allows + * for program chaining, either for raising the maximum number of + * available eBPF instructions, or to execute given programs in + * conditional blocks. For security reasons, there is an upper + * limit to the number of successive tail calls that can be + * performed. + * + * Upon call of this helper, the program attempts to jump into a + * program referenced at index *index* in *prog_array_map*, a + * special map of type **BPF_MAP_TYPE_PROG_ARRAY**, and passes + * *ctx*, a pointer to the context. + * + * If the call succeeds, the kernel immediately runs the first + * instruction of the new program. This is not a function call, + * and it never returns to the previous program. If the call + * fails, then the helper has no effect, and the caller continues + * to run its subsequent instructions. A call can fail if the + * destination program for the jump does not exist (i.e. *index* + * is superior to the number of entries in *prog_array_map*), or + * if the maximum number of tail calls has been reached for this + * chain of programs. This limit is defined in the kernel by the + * macro **MAX_TAIL_CALL_CNT** (not accessible to user space), + * which is currently set to 32. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_tail_call)(void *ctx, void *prog_array_map, __u32 index) = (void *) 12; + +/* + * bpf_clone_redirect + * + * Clone and redirect the packet associated to *skb* to another + * net device of index *ifindex*. Both ingress and egress + * interfaces can be used for redirection. The **BPF_F_INGRESS** + * value in *flags* is used to make the distinction (ingress path + * is selected if the flag is present, egress path otherwise). + * This is the only flag supported for now. + * + * In comparison with **bpf_redirect**\ () helper, + * **bpf_clone_redirect**\ () has the associated cost of + * duplicating the packet buffer, but this can be executed out of + * the eBPF program. Conversely, **bpf_redirect**\ () is more + * efficient, but it is handled through an action code where the + * redirection happens only after the eBPF program has returned. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_clone_redirect)(struct __sk_buff *skb, __u32 ifindex, __u64 flags) = (void *) 13; + +/* + * bpf_get_current_pid_tgid + * + * + * Returns + * A 64-bit integer containing the current tgid and pid, and + * created as such: + * *current_task*\ **->tgid << 32 \|** + * *current_task*\ **->pid**. + */ +static __u64 (*bpf_get_current_pid_tgid)(void) = (void *) 14; + +/* + * bpf_get_current_uid_gid + * + * + * Returns + * A 64-bit integer containing the current GID and UID, and + * created as such: *current_gid* **<< 32 \|** *current_uid*. + */ +static __u64 (*bpf_get_current_uid_gid)(void) = (void *) 15; + +/* + * bpf_get_current_comm + * + * Copy the **comm** attribute of the current task into *buf* of + * *size_of_buf*. The **comm** attribute contains the name of + * the executable (excluding the path) for the current task. The + * *size_of_buf* must be strictly positive. On success, the + * helper makes sure that the *buf* is NUL-terminated. On failure, + * it is filled with zeroes. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_get_current_comm)(void *buf, __u32 size_of_buf) = (void *) 16; + +/* + * bpf_get_cgroup_classid + * + * Retrieve the classid for the current task, i.e. for the net_cls + * cgroup to which *skb* belongs. + * + * This helper can be used on TC egress path, but not on ingress. + * + * The net_cls cgroup provides an interface to tag network packets + * based on a user-provided identifier for all traffic coming from + * the tasks belonging to the related cgroup. See also the related + * kernel documentation, available from the Linux sources in file + * *Documentation/admin-guide/cgroup-v1/net_cls.rst*. + * + * The Linux kernel has two versions for cgroups: there are + * cgroups v1 and cgroups v2. Both are available to users, who can + * use a mixture of them, but note that the net_cls cgroup is for + * cgroup v1 only. This makes it incompatible with BPF programs + * run on cgroups, which is a cgroup-v2-only feature (a socket can + * only hold data for one version of cgroups at a time). + * + * This helper is only available is the kernel was compiled with + * the **CONFIG_CGROUP_NET_CLASSID** configuration option set to + * "**y**" or to "**m**". + * + * Returns + * The classid, or 0 for the default unconfigured classid. + */ +static __u32 (*bpf_get_cgroup_classid)(struct __sk_buff *skb) = (void *) 17; + +/* + * bpf_skb_vlan_push + * + * Push a *vlan_tci* (VLAN tag control information) of protocol + * *vlan_proto* to the packet associated to *skb*, then update + * the checksum. Note that if *vlan_proto* is different from + * **ETH_P_8021Q** and **ETH_P_8021AD**, it is considered to + * be **ETH_P_8021Q**. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_vlan_push)(struct __sk_buff *skb, __be16 vlan_proto, __u16 vlan_tci) = (void *) 18; + +/* + * bpf_skb_vlan_pop + * + * Pop a VLAN header from the packet associated to *skb*. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_vlan_pop)(struct __sk_buff *skb) = (void *) 19; + +/* + * bpf_skb_get_tunnel_key + * + * Get tunnel metadata. This helper takes a pointer *key* to an + * empty **struct bpf_tunnel_key** of **size**, that will be + * filled with tunnel metadata for the packet associated to *skb*. + * The *flags* can be set to **BPF_F_TUNINFO_IPV6**, which + * indicates that the tunnel is based on IPv6 protocol instead of + * IPv4. + * + * The **struct bpf_tunnel_key** is an object that generalizes the + * principal parameters used by various tunneling protocols into a + * single struct. This way, it can be used to easily make a + * decision based on the contents of the encapsulation header, + * "summarized" in this struct. In particular, it holds the IP + * address of the remote end (IPv4 or IPv6, depending on the case) + * in *key*\ **->remote_ipv4** or *key*\ **->remote_ipv6**. Also, + * this struct exposes the *key*\ **->tunnel_id**, which is + * generally mapped to a VNI (Virtual Network Identifier), making + * it programmable together with the **bpf_skb_set_tunnel_key**\ + * () helper. + * + * Let's imagine that the following code is part of a program + * attached to the TC ingress interface, on one end of a GRE + * tunnel, and is supposed to filter out all messages coming from + * remote ends with IPv4 address other than 10.0.0.1: + * + * :: + * + * int ret; + * struct bpf_tunnel_key key = {}; + * + * ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0); + * if (ret < 0) + * return TC_ACT_SHOT; // drop packet + * + * if (key.remote_ipv4 != 0x0a000001) + * return TC_ACT_SHOT; // drop packet + * + * return TC_ACT_OK; // accept packet + * + * This interface can also be used with all encapsulation devices + * that can operate in "collect metadata" mode: instead of having + * one network device per specific configuration, the "collect + * metadata" mode only requires a single device where the + * configuration can be extracted from this helper. + * + * This can be used together with various tunnels such as VXLan, + * Geneve, GRE or IP in IP (IPIP). + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_get_tunnel_key)(struct __sk_buff *skb, struct bpf_tunnel_key *key, __u32 size, __u64 flags) = (void *) 20; + +/* + * bpf_skb_set_tunnel_key + * + * Populate tunnel metadata for packet associated to *skb.* The + * tunnel metadata is set to the contents of *key*, of *size*. The + * *flags* can be set to a combination of the following values: + * + * **BPF_F_TUNINFO_IPV6** + * Indicate that the tunnel is based on IPv6 protocol + * instead of IPv4. + * **BPF_F_ZERO_CSUM_TX** + * For IPv4 packets, add a flag to tunnel metadata + * indicating that checksum computation should be skipped + * and checksum set to zeroes. + * **BPF_F_DONT_FRAGMENT** + * Add a flag to tunnel metadata indicating that the + * packet should not be fragmented. + * **BPF_F_SEQ_NUMBER** + * Add a flag to tunnel metadata indicating that a + * sequence number should be added to tunnel header before + * sending the packet. This flag was added for GRE + * encapsulation, but might be used with other protocols + * as well in the future. + * + * Here is a typical usage on the transmit path: + * + * :: + * + * struct bpf_tunnel_key key; + * populate key ... + * bpf_skb_set_tunnel_key(skb, &key, sizeof(key), 0); + * bpf_clone_redirect(skb, vxlan_dev_ifindex, 0); + * + * See also the description of the **bpf_skb_get_tunnel_key**\ () + * helper for additional information. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_set_tunnel_key)(struct __sk_buff *skb, struct bpf_tunnel_key *key, __u32 size, __u64 flags) = (void *) 21; + +/* + * bpf_perf_event_read + * + * Read the value of a perf event counter. This helper relies on a + * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. The nature of + * the perf event counter is selected when *map* is updated with + * perf event file descriptors. The *map* is an array whose size + * is the number of available CPUs, and each cell contains a value + * relative to one CPU. The value to retrieve is indicated by + * *flags*, that contains the index of the CPU to look up, masked + * with **BPF_F_INDEX_MASK**. Alternatively, *flags* can be set to + * **BPF_F_CURRENT_CPU** to indicate that the value for the + * current CPU should be retrieved. + * + * Note that before Linux 4.13, only hardware perf event can be + * retrieved. + * + * Also, be aware that the newer helper + * **bpf_perf_event_read_value**\ () is recommended over + * **bpf_perf_event_read**\ () in general. The latter has some ABI + * quirks where error and counter value are used as a return code + * (which is wrong to do since ranges may overlap). This issue is + * fixed with **bpf_perf_event_read_value**\ (), which at the same + * time provides more features over the **bpf_perf_event_read**\ + * () interface. Please refer to the description of + * **bpf_perf_event_read_value**\ () for details. + * + * Returns + * The value of the perf event counter read from the map, or a + * negative error code in case of failure. + */ +static __u64 (*bpf_perf_event_read)(void *map, __u64 flags) = (void *) 22; + +/* + * bpf_redirect + * + * Redirect the packet to another net device of index *ifindex*. + * This helper is somewhat similar to **bpf_clone_redirect**\ + * (), except that the packet is not cloned, which provides + * increased performance. + * + * Except for XDP, both ingress and egress interfaces can be used + * for redirection. The **BPF_F_INGRESS** value in *flags* is used + * to make the distinction (ingress path is selected if the flag + * is present, egress path otherwise). Currently, XDP only + * supports redirection to the egress interface, and accepts no + * flag at all. + * + * The same effect can also be attained with the more generic + * **bpf_redirect_map**\ (), which uses a BPF map to store the + * redirect target instead of providing it directly to the helper. + * + * Returns + * For XDP, the helper returns **XDP_REDIRECT** on success or + * **XDP_ABORTED** on error. For other program types, the values + * are **TC_ACT_REDIRECT** on success or **TC_ACT_SHOT** on + * error. + */ +static long (*bpf_redirect)(__u32 ifindex, __u64 flags) = (void *) 23; + +/* + * bpf_get_route_realm + * + * Retrieve the realm or the route, that is to say the + * **tclassid** field of the destination for the *skb*. The + * identifier retrieved is a user-provided tag, similar to the + * one used with the net_cls cgroup (see description for + * **bpf_get_cgroup_classid**\ () helper), but here this tag is + * held by a route (a destination entry), not by a task. + * + * Retrieving this identifier works with the clsact TC egress hook + * (see also **tc-bpf(8)**), or alternatively on conventional + * classful egress qdiscs, but not on TC ingress path. In case of + * clsact TC egress hook, this has the advantage that, internally, + * the destination entry has not been dropped yet in the transmit + * path. Therefore, the destination entry does not need to be + * artificially held via **netif_keep_dst**\ () for a classful + * qdisc until the *skb* is freed. + * + * This helper is available only if the kernel was compiled with + * **CONFIG_IP_ROUTE_CLASSID** configuration option. + * + * Returns + * The realm of the route for the packet associated to *skb*, or 0 + * if none was found. + */ +static __u32 (*bpf_get_route_realm)(struct __sk_buff *skb) = (void *) 24; + +/* + * bpf_perf_event_output + * + * Write raw *data* blob into a special BPF perf event held by + * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. This perf + * event must have the following attributes: **PERF_SAMPLE_RAW** + * as **sample_type**, **PERF_TYPE_SOFTWARE** as **type**, and + * **PERF_COUNT_SW_BPF_OUTPUT** as **config**. + * + * The *flags* are used to indicate the index in *map* for which + * the value must be put, masked with **BPF_F_INDEX_MASK**. + * Alternatively, *flags* can be set to **BPF_F_CURRENT_CPU** + * to indicate that the index of the current CPU core should be + * used. + * + * The value to write, of *size*, is passed through eBPF stack and + * pointed by *data*. + * + * The context of the program *ctx* needs also be passed to the + * helper. + * + * On user space, a program willing to read the values needs to + * call **perf_event_open**\ () on the perf event (either for + * one or for all CPUs) and to store the file descriptor into the + * *map*. This must be done before the eBPF program can send data + * into it. An example is available in file + * *samples/bpf/trace_output_user.c* in the Linux kernel source + * tree (the eBPF program counterpart is in + * *samples/bpf/trace_output_kern.c*). + * + * **bpf_perf_event_output**\ () achieves better performance + * than **bpf_trace_printk**\ () for sharing data with user + * space, and is much better suitable for streaming data from eBPF + * programs. + * + * Note that this helper is not restricted to tracing use cases + * and can be used with programs attached to TC or XDP as well, + * where it allows for passing data to user space listeners. Data + * can be: + * + * * Only custom structs, + * * Only the packet payload, or + * * A combination of both. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_perf_event_output)(void *ctx, void *map, __u64 flags, void *data, __u64 size) = (void *) 25; + +/* + * bpf_skb_load_bytes + * + * This helper was provided as an easy way to load data from a + * packet. It can be used to load *len* bytes from *offset* from + * the packet associated to *skb*, into the buffer pointed by + * *to*. + * + * Since Linux 4.7, usage of this helper has mostly been replaced + * by "direct packet access", enabling packet data to be + * manipulated with *skb*\ **->data** and *skb*\ **->data_end** + * pointing respectively to the first byte of packet data and to + * the byte after the last byte of packet data. However, it + * remains useful if one wishes to read large quantities of data + * at once from a packet into the eBPF stack. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_load_bytes)(const void *skb, __u32 offset, void *to, __u32 len) = (void *) 26; + +/* + * bpf_get_stackid + * + * Walk a user or a kernel stack and return its id. To achieve + * this, the helper needs *ctx*, which is a pointer to the context + * on which the tracing program is executed, and a pointer to a + * *map* of type **BPF_MAP_TYPE_STACK_TRACE**. + * + * The last argument, *flags*, holds the number of stack frames to + * skip (from 0 to 255), masked with + * **BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set + * a combination of the following flags: + * + * **BPF_F_USER_STACK** + * Collect a user space stack instead of a kernel stack. + * **BPF_F_FAST_STACK_CMP** + * Compare stacks by hash only. + * **BPF_F_REUSE_STACKID** + * If two different stacks hash into the same *stackid*, + * discard the old one. + * + * The stack id retrieved is a 32 bit long integer handle which + * can be further combined with other data (including other stack + * ids) and used as a key into maps. This can be useful for + * generating a variety of graphs (such as flame graphs or off-cpu + * graphs). + * + * For walking a stack, this helper is an improvement over + * **bpf_probe_read**\ (), which can be used with unrolled loops + * but is not efficient and consumes a lot of eBPF instructions. + * Instead, **bpf_get_stackid**\ () can collect up to + * **PERF_MAX_STACK_DEPTH** both kernel and user frames. Note that + * this limit can be controlled with the **sysctl** program, and + * that it should be manually increased in order to profile long + * user stacks (such as stacks for Java programs). To do so, use: + * + * :: + * + * # sysctl kernel.perf_event_max_stack= + * + * Returns + * The positive or null stack id on success, or a negative error + * in case of failure. + */ +static long (*bpf_get_stackid)(void *ctx, void *map, __u64 flags) = (void *) 27; + +/* + * bpf_csum_diff + * + * Compute a checksum difference, from the raw buffer pointed by + * *from*, of length *from_size* (that must be a multiple of 4), + * towards the raw buffer pointed by *to*, of size *to_size* + * (same remark). An optional *seed* can be added to the value + * (this can be cascaded, the seed may come from a previous call + * to the helper). + * + * This is flexible enough to be used in several ways: + * + * * With *from_size* == 0, *to_size* > 0 and *seed* set to + * checksum, it can be used when pushing new data. + * * With *from_size* > 0, *to_size* == 0 and *seed* set to + * checksum, it can be used when removing data from a packet. + * * With *from_size* > 0, *to_size* > 0 and *seed* set to 0, it + * can be used to compute a diff. Note that *from_size* and + * *to_size* do not need to be equal. + * + * This helper can be used in combination with + * **bpf_l3_csum_replace**\ () and **bpf_l4_csum_replace**\ (), to + * which one can feed in the difference computed with + * **bpf_csum_diff**\ (). + * + * Returns + * The checksum result, or a negative error code in case of + * failure. + */ +static __s64 (*bpf_csum_diff)(__be32 *from, __u32 from_size, __be32 *to, __u32 to_size, __wsum seed) = (void *) 28; + +/* + * bpf_skb_get_tunnel_opt + * + * Retrieve tunnel options metadata for the packet associated to + * *skb*, and store the raw tunnel option data to the buffer *opt* + * of *size*. + * + * This helper can be used with encapsulation devices that can + * operate in "collect metadata" mode (please refer to the related + * note in the description of **bpf_skb_get_tunnel_key**\ () for + * more details). A particular example where this can be used is + * in combination with the Geneve encapsulation protocol, where it + * allows for pushing (with **bpf_skb_get_tunnel_opt**\ () helper) + * and retrieving arbitrary TLVs (Type-Length-Value headers) from + * the eBPF program. This allows for full customization of these + * headers. + * + * Returns + * The size of the option data retrieved. + */ +static long (*bpf_skb_get_tunnel_opt)(struct __sk_buff *skb, void *opt, __u32 size) = (void *) 29; + +/* + * bpf_skb_set_tunnel_opt + * + * Set tunnel options metadata for the packet associated to *skb* + * to the option data contained in the raw buffer *opt* of *size*. + * + * See also the description of the **bpf_skb_get_tunnel_opt**\ () + * helper for additional information. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_set_tunnel_opt)(struct __sk_buff *skb, void *opt, __u32 size) = (void *) 30; + +/* + * bpf_skb_change_proto + * + * Change the protocol of the *skb* to *proto*. Currently + * supported are transition from IPv4 to IPv6, and from IPv6 to + * IPv4. The helper takes care of the groundwork for the + * transition, including resizing the socket buffer. The eBPF + * program is expected to fill the new headers, if any, via + * **skb_store_bytes**\ () and to recompute the checksums with + * **bpf_l3_csum_replace**\ () and **bpf_l4_csum_replace**\ + * (). The main case for this helper is to perform NAT64 + * operations out of an eBPF program. + * + * Internally, the GSO type is marked as dodgy so that headers are + * checked and segments are recalculated by the GSO/GRO engine. + * The size for GSO target is adapted as well. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_change_proto)(struct __sk_buff *skb, __be16 proto, __u64 flags) = (void *) 31; + +/* + * bpf_skb_change_type + * + * Change the packet type for the packet associated to *skb*. This + * comes down to setting *skb*\ **->pkt_type** to *type*, except + * the eBPF program does not have a write access to *skb*\ + * **->pkt_type** beside this helper. Using a helper here allows + * for graceful handling of errors. + * + * The major use case is to change incoming *skb*s to + * **PACKET_HOST** in a programmatic way instead of having to + * recirculate via **redirect**\ (..., **BPF_F_INGRESS**), for + * example. + * + * Note that *type* only allows certain values. At this time, they + * are: + * + * **PACKET_HOST** + * Packet is for us. + * **PACKET_BROADCAST** + * Send packet to all. + * **PACKET_MULTICAST** + * Send packet to group. + * **PACKET_OTHERHOST** + * Send packet to someone else. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_change_type)(struct __sk_buff *skb, __u32 type) = (void *) 32; + +/* + * bpf_skb_under_cgroup + * + * Check whether *skb* is a descendant of the cgroup2 held by + * *map* of type **BPF_MAP_TYPE_CGROUP_ARRAY**, at *index*. + * + * Returns + * The return value depends on the result of the test, and can be: + * + * * 0, if the *skb* failed the cgroup2 descendant test. + * * 1, if the *skb* succeeded the cgroup2 descendant test. + * * A negative error code, if an error occurred. + */ +static long (*bpf_skb_under_cgroup)(struct __sk_buff *skb, void *map, __u32 index) = (void *) 33; + +/* + * bpf_get_hash_recalc + * + * Retrieve the hash of the packet, *skb*\ **->hash**. If it is + * not set, in particular if the hash was cleared due to mangling, + * recompute this hash. Later accesses to the hash can be done + * directly with *skb*\ **->hash**. + * + * Calling **bpf_set_hash_invalid**\ (), changing a packet + * prototype with **bpf_skb_change_proto**\ (), or calling + * **bpf_skb_store_bytes**\ () with the + * **BPF_F_INVALIDATE_HASH** are actions susceptible to clear + * the hash and to trigger a new computation for the next call to + * **bpf_get_hash_recalc**\ (). + * + * Returns + * The 32-bit hash. + */ +static __u32 (*bpf_get_hash_recalc)(struct __sk_buff *skb) = (void *) 34; + +/* + * bpf_get_current_task + * + * + * Returns + * A pointer to the current task struct. + */ +static __u64 (*bpf_get_current_task)(void) = (void *) 35; + +/* + * bpf_probe_write_user + * + * Attempt in a safe way to write *len* bytes from the buffer + * *src* to *dst* in memory. It only works for threads that are in + * user context, and *dst* must be a valid user space address. + * + * This helper should not be used to implement any kind of + * security mechanism because of TOC-TOU attacks, but rather to + * debug, divert, and manipulate execution of semi-cooperative + * processes. + * + * Keep in mind that this feature is meant for experiments, and it + * has a risk of crashing the system and running programs. + * Therefore, when an eBPF program using this helper is attached, + * a warning including PID and process name is printed to kernel + * logs. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_probe_write_user)(void *dst, const void *src, __u32 len) = (void *) 36; + +/* + * bpf_current_task_under_cgroup + * + * Check whether the probe is being run is the context of a given + * subset of the cgroup2 hierarchy. The cgroup2 to test is held by + * *map* of type **BPF_MAP_TYPE_CGROUP_ARRAY**, at *index*. + * + * Returns + * The return value depends on the result of the test, and can be: + * + * * 0, if current task belongs to the cgroup2. + * * 1, if current task does not belong to the cgroup2. + * * A negative error code, if an error occurred. + */ +static long (*bpf_current_task_under_cgroup)(void *map, __u32 index) = (void *) 37; + +/* + * bpf_skb_change_tail + * + * Resize (trim or grow) the packet associated to *skb* to the + * new *len*. The *flags* are reserved for future usage, and must + * be left at zero. + * + * The basic idea is that the helper performs the needed work to + * change the size of the packet, then the eBPF program rewrites + * the rest via helpers like **bpf_skb_store_bytes**\ (), + * **bpf_l3_csum_replace**\ (), **bpf_l3_csum_replace**\ () + * and others. This helper is a slow path utility intended for + * replies with control messages. And because it is targeted for + * slow path, the helper itself can afford to be slow: it + * implicitly linearizes, unclones and drops offloads from the + * *skb*. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_change_tail)(struct __sk_buff *skb, __u32 len, __u64 flags) = (void *) 38; + +/* + * bpf_skb_pull_data + * + * Pull in non-linear data in case the *skb* is non-linear and not + * all of *len* are part of the linear section. Make *len* bytes + * from *skb* readable and writable. If a zero value is passed for + * *len*, then the whole length of the *skb* is pulled. + * + * This helper is only needed for reading and writing with direct + * packet access. + * + * For direct packet access, testing that offsets to access + * are within packet boundaries (test on *skb*\ **->data_end**) is + * susceptible to fail if offsets are invalid, or if the requested + * data is in non-linear parts of the *skb*. On failure the + * program can just bail out, or in the case of a non-linear + * buffer, use a helper to make the data available. The + * **bpf_skb_load_bytes**\ () helper is a first solution to access + * the data. Another one consists in using **bpf_skb_pull_data** + * to pull in once the non-linear parts, then retesting and + * eventually access the data. + * + * At the same time, this also makes sure the *skb* is uncloned, + * which is a necessary condition for direct write. As this needs + * to be an invariant for the write part only, the verifier + * detects writes and adds a prologue that is calling + * **bpf_skb_pull_data()** to effectively unclone the *skb* from + * the very beginning in case it is indeed cloned. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_pull_data)(struct __sk_buff *skb, __u32 len) = (void *) 39; + +/* + * bpf_csum_update + * + * Add the checksum *csum* into *skb*\ **->csum** in case the + * driver has supplied a checksum for the entire packet into that + * field. Return an error otherwise. This helper is intended to be + * used in combination with **bpf_csum_diff**\ (), in particular + * when the checksum needs to be updated after data has been + * written into the packet through direct packet access. + * + * Returns + * The checksum on success, or a negative error code in case of + * failure. + */ +static __s64 (*bpf_csum_update)(struct __sk_buff *skb, __wsum csum) = (void *) 40; + +/* + * bpf_set_hash_invalid + * + * Invalidate the current *skb*\ **->hash**. It can be used after + * mangling on headers through direct packet access, in order to + * indicate that the hash is outdated and to trigger a + * recalculation the next time the kernel tries to access this + * hash or when the **bpf_get_hash_recalc**\ () helper is called. + * + */ +static void (*bpf_set_hash_invalid)(struct __sk_buff *skb) = (void *) 41; + +/* + * bpf_get_numa_node_id + * + * Return the id of the current NUMA node. The primary use case + * for this helper is the selection of sockets for the local NUMA + * node, when the program is attached to sockets using the + * **SO_ATTACH_REUSEPORT_EBPF** option (see also **socket(7)**), + * but the helper is also available to other eBPF program types, + * similarly to **bpf_get_smp_processor_id**\ (). + * + * Returns + * The id of current NUMA node. + */ +static long (*bpf_get_numa_node_id)(void) = (void *) 42; + +/* + * bpf_skb_change_head + * + * Grows headroom of packet associated to *skb* and adjusts the + * offset of the MAC header accordingly, adding *len* bytes of + * space. It automatically extends and reallocates memory as + * required. + * + * This helper can be used on a layer 3 *skb* to push a MAC header + * for redirection into a layer 2 device. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_change_head)(struct __sk_buff *skb, __u32 len, __u64 flags) = (void *) 43; + +/* + * bpf_xdp_adjust_head + * + * Adjust (move) *xdp_md*\ **->data** by *delta* bytes. Note that + * it is possible to use a negative value for *delta*. This helper + * can be used to prepare the packet for pushing or popping + * headers. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_xdp_adjust_head)(struct xdp_md *xdp_md, int delta) = (void *) 44; + +/* + * bpf_probe_read_str + * + * Copy a NUL terminated string from an unsafe kernel address + * *unsafe_ptr* to *dst*. See **bpf_probe_read_kernel_str**\ () for + * more details. + * + * Generally, use **bpf_probe_read_user_str**\ () or + * **bpf_probe_read_kernel_str**\ () instead. + * + * Returns + * On success, the strictly positive length of the string, + * including the trailing NUL character. On error, a negative + * value. + */ +static long (*bpf_probe_read_str)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 45; + +/* + * bpf_get_socket_cookie + * + * If the **struct sk_buff** pointed by *skb* has a known socket, + * retrieve the cookie (generated by the kernel) of this socket. + * If no cookie has been set yet, generate a new cookie. Once + * generated, the socket cookie remains stable for the life of the + * socket. This helper can be useful for monitoring per socket + * networking traffic statistics as it provides a global socket + * identifier that can be assumed unique. + * + * Returns + * A 8-byte long unique number on success, or 0 if the socket + * field is missing inside *skb*. + */ +static __u64 (*bpf_get_socket_cookie)(void *ctx) = (void *) 46; + +/* + * bpf_get_socket_uid + * + * + * Returns + * The owner UID of the socket associated to *skb*. If the socket + * is **NULL**, or if it is not a full socket (i.e. if it is a + * time-wait or a request socket instead), **overflowuid** value + * is returned (note that **overflowuid** might also be the actual + * UID value for the socket). + */ +static __u32 (*bpf_get_socket_uid)(struct __sk_buff *skb) = (void *) 47; + +/* + * bpf_set_hash + * + * Set the full hash for *skb* (set the field *skb*\ **->hash**) + * to value *hash*. + * + * Returns + * 0 + */ +static long (*bpf_set_hash)(struct __sk_buff *skb, __u32 hash) = (void *) 48; + +/* + * bpf_setsockopt + * + * Emulate a call to **setsockopt()** on the socket associated to + * *bpf_socket*, which must be a full socket. The *level* at + * which the option resides and the name *optname* of the option + * must be specified, see **setsockopt(2)** for more information. + * The option value of length *optlen* is pointed by *optval*. + * + * *bpf_socket* should be one of the following: + * + * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**. + * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT** + * and **BPF_CGROUP_INET6_CONNECT**. + * + * This helper actually implements a subset of **setsockopt()**. + * It supports the following *level*\ s: + * + * * **SOL_SOCKET**, which supports the following *optname*\ s: + * **SO_RCVBUF**, **SO_SNDBUF**, **SO_MAX_PACING_RATE**, + * **SO_PRIORITY**, **SO_RCVLOWAT**, **SO_MARK**, + * **SO_BINDTODEVICE**, **SO_KEEPALIVE**. + * * **IPPROTO_TCP**, which supports the following *optname*\ s: + * **TCP_CONGESTION**, **TCP_BPF_IW**, + * **TCP_BPF_SNDCWND_CLAMP**, **TCP_SAVE_SYN**, + * **TCP_KEEPIDLE**, **TCP_KEEPINTVL**, **TCP_KEEPCNT**, + * **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT**. + * * **IPPROTO_IP**, which supports *optname* **IP_TOS**. + * * **IPPROTO_IPV6**, which supports *optname* **IPV6_TCLASS**. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_setsockopt)(void *bpf_socket, int level, int optname, void *optval, int optlen) = (void *) 49; + +/* + * bpf_skb_adjust_room + * + * Grow or shrink the room for data in the packet associated to + * *skb* by *len_diff*, and according to the selected *mode*. + * + * By default, the helper will reset any offloaded checksum + * indicator of the skb to CHECKSUM_NONE. This can be avoided + * by the following flag: + * + * * **BPF_F_ADJ_ROOM_NO_CSUM_RESET**: Do not reset offloaded + * checksum data of the skb to CHECKSUM_NONE. + * + * There are two supported modes at this time: + * + * * **BPF_ADJ_ROOM_MAC**: Adjust room at the mac layer + * (room space is added or removed below the layer 2 header). + * + * * **BPF_ADJ_ROOM_NET**: Adjust room at the network layer + * (room space is added or removed below the layer 3 header). + * + * The following flags are supported at this time: + * + * * **BPF_F_ADJ_ROOM_FIXED_GSO**: Do not adjust gso_size. + * Adjusting mss in this way is not allowed for datagrams. + * + * * **BPF_F_ADJ_ROOM_ENCAP_L3_IPV4**, + * **BPF_F_ADJ_ROOM_ENCAP_L3_IPV6**: + * Any new space is reserved to hold a tunnel header. + * Configure skb offsets and other fields accordingly. + * + * * **BPF_F_ADJ_ROOM_ENCAP_L4_GRE**, + * **BPF_F_ADJ_ROOM_ENCAP_L4_UDP**: + * Use with ENCAP_L3 flags to further specify the tunnel type. + * + * * **BPF_F_ADJ_ROOM_ENCAP_L2**\ (*len*): + * Use with ENCAP_L3/L4 flags to further specify the tunnel + * type; *len* is the length of the inner MAC header. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_adjust_room)(struct __sk_buff *skb, __s32 len_diff, __u32 mode, __u64 flags) = (void *) 50; + +/* + * bpf_redirect_map + * + * Redirect the packet to the endpoint referenced by *map* at + * index *key*. Depending on its type, this *map* can contain + * references to net devices (for forwarding packets through other + * ports), or to CPUs (for redirecting XDP frames to another CPU; + * but this is only implemented for native XDP (with driver + * support) as of this writing). + * + * The lower two bits of *flags* are used as the return code if + * the map lookup fails. This is so that the return value can be + * one of the XDP program return codes up to **XDP_TX**, as chosen + * by the caller. Any higher bits in the *flags* argument must be + * unset. + * + * See also **bpf_redirect**\ (), which only supports redirecting + * to an ifindex, but doesn't require a map to do so. + * + * Returns + * **XDP_REDIRECT** on success, or the value of the two lower bits + * of the *flags* argument on error. + */ +static long (*bpf_redirect_map)(void *map, __u32 key, __u64 flags) = (void *) 51; + +/* + * bpf_sk_redirect_map + * + * Redirect the packet to the socket referenced by *map* (of type + * **BPF_MAP_TYPE_SOCKMAP**) at index *key*. Both ingress and + * egress interfaces can be used for redirection. The + * **BPF_F_INGRESS** value in *flags* is used to make the + * distinction (ingress path is selected if the flag is present, + * egress path otherwise). This is the only flag supported for now. + * + * Returns + * **SK_PASS** on success, or **SK_DROP** on error. + */ +static long (*bpf_sk_redirect_map)(struct __sk_buff *skb, void *map, __u32 key, __u64 flags) = (void *) 52; + +/* + * bpf_sock_map_update + * + * Add an entry to, or update a *map* referencing sockets. The + * *skops* is used as a new value for the entry associated to + * *key*. *flags* is one of: + * + * **BPF_NOEXIST** + * The entry for *key* must not exist in the map. + * **BPF_EXIST** + * The entry for *key* must already exist in the map. + * **BPF_ANY** + * No condition on the existence of the entry for *key*. + * + * If the *map* has eBPF programs (parser and verdict), those will + * be inherited by the socket being added. If the socket is + * already attached to eBPF programs, this results in an error. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_sock_map_update)(struct bpf_sock_ops *skops, void *map, void *key, __u64 flags) = (void *) 53; + +/* + * bpf_xdp_adjust_meta + * + * Adjust the address pointed by *xdp_md*\ **->data_meta** by + * *delta* (which can be positive or negative). Note that this + * operation modifies the address stored in *xdp_md*\ **->data**, + * so the latter must be loaded only after the helper has been + * called. + * + * The use of *xdp_md*\ **->data_meta** is optional and programs + * are not required to use it. The rationale is that when the + * packet is processed with XDP (e.g. as DoS filter), it is + * possible to push further meta data along with it before passing + * to the stack, and to give the guarantee that an ingress eBPF + * program attached as a TC classifier on the same device can pick + * this up for further post-processing. Since TC works with socket + * buffers, it remains possible to set from XDP the **mark** or + * **priority** pointers, or other pointers for the socket buffer. + * Having this scratch space generic and programmable allows for + * more flexibility as the user is free to store whatever meta + * data they need. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_xdp_adjust_meta)(struct xdp_md *xdp_md, int delta) = (void *) 54; + +/* + * bpf_perf_event_read_value + * + * Read the value of a perf event counter, and store it into *buf* + * of size *buf_size*. This helper relies on a *map* of type + * **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. The nature of the perf event + * counter is selected when *map* is updated with perf event file + * descriptors. The *map* is an array whose size is the number of + * available CPUs, and each cell contains a value relative to one + * CPU. The value to retrieve is indicated by *flags*, that + * contains the index of the CPU to look up, masked with + * **BPF_F_INDEX_MASK**. Alternatively, *flags* can be set to + * **BPF_F_CURRENT_CPU** to indicate that the value for the + * current CPU should be retrieved. + * + * This helper behaves in a way close to + * **bpf_perf_event_read**\ () helper, save that instead of + * just returning the value observed, it fills the *buf* + * structure. This allows for additional data to be retrieved: in + * particular, the enabled and running times (in *buf*\ + * **->enabled** and *buf*\ **->running**, respectively) are + * copied. In general, **bpf_perf_event_read_value**\ () is + * recommended over **bpf_perf_event_read**\ (), which has some + * ABI issues and provides fewer functionalities. + * + * These values are interesting, because hardware PMU (Performance + * Monitoring Unit) counters are limited resources. When there are + * more PMU based perf events opened than available counters, + * kernel will multiplex these events so each event gets certain + * percentage (but not all) of the PMU time. In case that + * multiplexing happens, the number of samples or counter value + * will not reflect the case compared to when no multiplexing + * occurs. This makes comparison between different runs difficult. + * Typically, the counter value should be normalized before + * comparing to other experiments. The usual normalization is done + * as follows. + * + * :: + * + * normalized_counter = counter * t_enabled / t_running + * + * Where t_enabled is the time enabled for event and t_running is + * the time running for event since last normalization. The + * enabled and running times are accumulated since the perf event + * open. To achieve scaling factor between two invocations of an + * eBPF program, users can use CPU id as the key (which is + * typical for perf array usage model) to remember the previous + * value and do the calculation inside the eBPF program. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_perf_event_read_value)(void *map, __u64 flags, struct bpf_perf_event_value *buf, __u32 buf_size) = (void *) 55; + +/* + * bpf_perf_prog_read_value + * + * For en eBPF program attached to a perf event, retrieve the + * value of the event counter associated to *ctx* and store it in + * the structure pointed by *buf* and of size *buf_size*. Enabled + * and running times are also stored in the structure (see + * description of helper **bpf_perf_event_read_value**\ () for + * more details). + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_perf_prog_read_value)(struct bpf_perf_event_data *ctx, struct bpf_perf_event_value *buf, __u32 buf_size) = (void *) 56; + +/* + * bpf_getsockopt + * + * Emulate a call to **getsockopt()** on the socket associated to + * *bpf_socket*, which must be a full socket. The *level* at + * which the option resides and the name *optname* of the option + * must be specified, see **getsockopt(2)** for more information. + * The retrieved value is stored in the structure pointed by + * *opval* and of length *optlen*. + * + * *bpf_socket* should be one of the following: + * + * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**. + * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT** + * and **BPF_CGROUP_INET6_CONNECT**. + * + * This helper actually implements a subset of **getsockopt()**. + * It supports the following *level*\ s: + * + * * **IPPROTO_TCP**, which supports *optname* + * **TCP_CONGESTION**. + * * **IPPROTO_IP**, which supports *optname* **IP_TOS**. + * * **IPPROTO_IPV6**, which supports *optname* **IPV6_TCLASS**. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_getsockopt)(void *bpf_socket, int level, int optname, void *optval, int optlen) = (void *) 57; + +/* + * bpf_override_return + * + * Used for error injection, this helper uses kprobes to override + * the return value of the probed function, and to set it to *rc*. + * The first argument is the context *regs* on which the kprobe + * works. + * + * This helper works by setting the PC (program counter) + * to an override function which is run in place of the original + * probed function. This means the probed function is not run at + * all. The replacement function just returns with the required + * value. + * + * This helper has security implications, and thus is subject to + * restrictions. It is only available if the kernel was compiled + * with the **CONFIG_BPF_KPROBE_OVERRIDE** configuration + * option, and in this case it only works on functions tagged with + * **ALLOW_ERROR_INJECTION** in the kernel code. + * + * Also, the helper is only available for the architectures having + * the CONFIG_FUNCTION_ERROR_INJECTION option. As of this writing, + * x86 architecture is the only one to support this feature. + * + * Returns + * 0 + */ +static long (*bpf_override_return)(struct pt_regs *regs, __u64 rc) = (void *) 58; + +/* + * bpf_sock_ops_cb_flags_set + * + * Attempt to set the value of the **bpf_sock_ops_cb_flags** field + * for the full TCP socket associated to *bpf_sock_ops* to + * *argval*. + * + * The primary use of this field is to determine if there should + * be calls to eBPF programs of type + * **BPF_PROG_TYPE_SOCK_OPS** at various points in the TCP + * code. A program of the same type can change its value, per + * connection and as necessary, when the connection is + * established. This field is directly accessible for reading, but + * this helper must be used for updates in order to return an + * error if an eBPF program tries to set a callback that is not + * supported in the current kernel. + * + * *argval* is a flag array which can combine these flags: + * + * * **BPF_SOCK_OPS_RTO_CB_FLAG** (retransmission time out) + * * **BPF_SOCK_OPS_RETRANS_CB_FLAG** (retransmission) + * * **BPF_SOCK_OPS_STATE_CB_FLAG** (TCP state change) + * * **BPF_SOCK_OPS_RTT_CB_FLAG** (every RTT) + * + * Therefore, this function can be used to clear a callback flag by + * setting the appropriate bit to zero. e.g. to disable the RTO + * callback: + * + * **bpf_sock_ops_cb_flags_set(bpf_sock,** + * **bpf_sock->bpf_sock_ops_cb_flags & ~BPF_SOCK_OPS_RTO_CB_FLAG)** + * + * Here are some examples of where one could call such eBPF + * program: + * + * * When RTO fires. + * * When a packet is retransmitted. + * * When the connection terminates. + * * When a packet is sent. + * * When a packet is received. + * + * Returns + * Code **-EINVAL** if the socket is not a full TCP socket; + * otherwise, a positive number containing the bits that could not + * be set is returned (which comes down to 0 if all bits were set + * as required). + */ +static long (*bpf_sock_ops_cb_flags_set)(struct bpf_sock_ops *bpf_sock, int argval) = (void *) 59; + +/* + * bpf_msg_redirect_map + * + * This helper is used in programs implementing policies at the + * socket level. If the message *msg* is allowed to pass (i.e. if + * the verdict eBPF program returns **SK_PASS**), redirect it to + * the socket referenced by *map* (of type + * **BPF_MAP_TYPE_SOCKMAP**) at index *key*. Both ingress and + * egress interfaces can be used for redirection. The + * **BPF_F_INGRESS** value in *flags* is used to make the + * distinction (ingress path is selected if the flag is present, + * egress path otherwise). This is the only flag supported for now. + * + * Returns + * **SK_PASS** on success, or **SK_DROP** on error. + */ +static long (*bpf_msg_redirect_map)(struct sk_msg_md *msg, void *map, __u32 key, __u64 flags) = (void *) 60; + +/* + * bpf_msg_apply_bytes + * + * For socket policies, apply the verdict of the eBPF program to + * the next *bytes* (number of bytes) of message *msg*. + * + * For example, this helper can be used in the following cases: + * + * * A single **sendmsg**\ () or **sendfile**\ () system call + * contains multiple logical messages that the eBPF program is + * supposed to read and for which it should apply a verdict. + * * An eBPF program only cares to read the first *bytes* of a + * *msg*. If the message has a large payload, then setting up + * and calling the eBPF program repeatedly for all bytes, even + * though the verdict is already known, would create unnecessary + * overhead. + * + * When called from within an eBPF program, the helper sets a + * counter internal to the BPF infrastructure, that is used to + * apply the last verdict to the next *bytes*. If *bytes* is + * smaller than the current data being processed from a + * **sendmsg**\ () or **sendfile**\ () system call, the first + * *bytes* will be sent and the eBPF program will be re-run with + * the pointer for start of data pointing to byte number *bytes* + * **+ 1**. If *bytes* is larger than the current data being + * processed, then the eBPF verdict will be applied to multiple + * **sendmsg**\ () or **sendfile**\ () calls until *bytes* are + * consumed. + * + * Note that if a socket closes with the internal counter holding + * a non-zero value, this is not a problem because data is not + * being buffered for *bytes* and is sent as it is received. + * + * Returns + * 0 + */ +static long (*bpf_msg_apply_bytes)(struct sk_msg_md *msg, __u32 bytes) = (void *) 61; + +/* + * bpf_msg_cork_bytes + * + * For socket policies, prevent the execution of the verdict eBPF + * program for message *msg* until *bytes* (byte number) have been + * accumulated. + * + * This can be used when one needs a specific number of bytes + * before a verdict can be assigned, even if the data spans + * multiple **sendmsg**\ () or **sendfile**\ () calls. The extreme + * case would be a user calling **sendmsg**\ () repeatedly with + * 1-byte long message segments. Obviously, this is bad for + * performance, but it is still valid. If the eBPF program needs + * *bytes* bytes to validate a header, this helper can be used to + * prevent the eBPF program to be called again until *bytes* have + * been accumulated. + * + * Returns + * 0 + */ +static long (*bpf_msg_cork_bytes)(struct sk_msg_md *msg, __u32 bytes) = (void *) 62; + +/* + * bpf_msg_pull_data + * + * For socket policies, pull in non-linear data from user space + * for *msg* and set pointers *msg*\ **->data** and *msg*\ + * **->data_end** to *start* and *end* bytes offsets into *msg*, + * respectively. + * + * If a program of type **BPF_PROG_TYPE_SK_MSG** is run on a + * *msg* it can only parse data that the (**data**, **data_end**) + * pointers have already consumed. For **sendmsg**\ () hooks this + * is likely the first scatterlist element. But for calls relying + * on the **sendpage** handler (e.g. **sendfile**\ ()) this will + * be the range (**0**, **0**) because the data is shared with + * user space and by default the objective is to avoid allowing + * user space to modify data while (or after) eBPF verdict is + * being decided. This helper can be used to pull in data and to + * set the start and end pointer to given values. Data will be + * copied if necessary (i.e. if data was not linear and if start + * and end pointers do not point to the same chunk). + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_msg_pull_data)(struct sk_msg_md *msg, __u32 start, __u32 end, __u64 flags) = (void *) 63; + +/* + * bpf_bind + * + * Bind the socket associated to *ctx* to the address pointed by + * *addr*, of length *addr_len*. This allows for making outgoing + * connection from the desired IP address, which can be useful for + * example when all processes inside a cgroup should use one + * single IP address on a host that has multiple IP configured. + * + * This helper works for IPv4 and IPv6, TCP and UDP sockets. The + * domain (*addr*\ **->sa_family**) must be **AF_INET** (or + * **AF_INET6**). It's advised to pass zero port (**sin_port** + * or **sin6_port**) which triggers IP_BIND_ADDRESS_NO_PORT-like + * behavior and lets the kernel efficiently pick up an unused + * port as long as 4-tuple is unique. Passing non-zero port might + * lead to degraded performance. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_bind)(struct bpf_sock_addr *ctx, struct sockaddr *addr, int addr_len) = (void *) 64; + +/* + * bpf_xdp_adjust_tail + * + * Adjust (move) *xdp_md*\ **->data_end** by *delta* bytes. It is + * possible to both shrink and grow the packet tail. + * Shrink done via *delta* being a negative integer. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_xdp_adjust_tail)(struct xdp_md *xdp_md, int delta) = (void *) 65; + +/* + * bpf_skb_get_xfrm_state + * + * Retrieve the XFRM state (IP transform framework, see also + * **ip-xfrm(8)**) at *index* in XFRM "security path" for *skb*. + * + * The retrieved value is stored in the **struct bpf_xfrm_state** + * pointed by *xfrm_state* and of length *size*. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * + * This helper is available only if the kernel was compiled with + * **CONFIG_XFRM** configuration option. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_get_xfrm_state)(struct __sk_buff *skb, __u32 index, struct bpf_xfrm_state *xfrm_state, __u32 size, __u64 flags) = (void *) 66; + +/* + * bpf_get_stack + * + * Return a user or a kernel stack in bpf program provided buffer. + * To achieve this, the helper needs *ctx*, which is a pointer + * to the context on which the tracing program is executed. + * To store the stacktrace, the bpf program provides *buf* with + * a nonnegative *size*. + * + * The last argument, *flags*, holds the number of stack frames to + * skip (from 0 to 255), masked with + * **BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set + * the following flags: + * + * **BPF_F_USER_STACK** + * Collect a user space stack instead of a kernel stack. + * **BPF_F_USER_BUILD_ID** + * Collect buildid+offset instead of ips for user stack, + * only valid if **BPF_F_USER_STACK** is also specified. + * + * **bpf_get_stack**\ () can collect up to + * **PERF_MAX_STACK_DEPTH** both kernel and user frames, subject + * to sufficient large buffer size. Note that + * this limit can be controlled with the **sysctl** program, and + * that it should be manually increased in order to profile long + * user stacks (such as stacks for Java programs). To do so, use: + * + * :: + * + * # sysctl kernel.perf_event_max_stack= + * + * Returns + * A non-negative value equal to or less than *size* on success, + * or a negative error in case of failure. + */ +static long (*bpf_get_stack)(void *ctx, void *buf, __u32 size, __u64 flags) = (void *) 67; + +/* + * bpf_skb_load_bytes_relative + * + * This helper is similar to **bpf_skb_load_bytes**\ () in that + * it provides an easy way to load *len* bytes from *offset* + * from the packet associated to *skb*, into the buffer pointed + * by *to*. The difference to **bpf_skb_load_bytes**\ () is that + * a fifth argument *start_header* exists in order to select a + * base offset to start from. *start_header* can be one of: + * + * **BPF_HDR_START_MAC** + * Base offset to load data from is *skb*'s mac header. + * **BPF_HDR_START_NET** + * Base offset to load data from is *skb*'s network header. + * + * In general, "direct packet access" is the preferred method to + * access packet data, however, this helper is in particular useful + * in socket filters where *skb*\ **->data** does not always point + * to the start of the mac header and where "direct packet access" + * is not available. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_load_bytes_relative)(const void *skb, __u32 offset, void *to, __u32 len, __u32 start_header) = (void *) 68; + +/* + * bpf_fib_lookup + * + * Do FIB lookup in kernel tables using parameters in *params*. + * If lookup is successful and result shows packet is to be + * forwarded, the neighbor tables are searched for the nexthop. + * If successful (ie., FIB lookup shows forwarding and nexthop + * is resolved), the nexthop address is returned in ipv4_dst + * or ipv6_dst based on family, smac is set to mac address of + * egress device, dmac is set to nexthop mac address, rt_metric + * is set to metric from route (IPv4/IPv6 only), and ifindex + * is set to the device index of the nexthop from the FIB lookup. + * + * *plen* argument is the size of the passed in struct. + * *flags* argument can be a combination of one or more of the + * following values: + * + * **BPF_FIB_LOOKUP_DIRECT** + * Do a direct table lookup vs full lookup using FIB + * rules. + * **BPF_FIB_LOOKUP_OUTPUT** + * Perform lookup from an egress perspective (default is + * ingress). + * + * *ctx* is either **struct xdp_md** for XDP programs or + * **struct sk_buff** tc cls_act programs. + * + * Returns + * * < 0 if any input argument is invalid + * * 0 on success (packet is forwarded, nexthop neighbor exists) + * * > 0 one of **BPF_FIB_LKUP_RET_** codes explaining why the + * packet is not forwarded or needs assist from full stack + * + * If lookup fails with BPF_FIB_LKUP_RET_FRAG_NEEDED, then the MTU + * was exceeded and output params->mtu_result contains the MTU. + */ +static long (*bpf_fib_lookup)(void *ctx, struct bpf_fib_lookup *params, int plen, __u32 flags) = (void *) 69; + +/* + * bpf_sock_hash_update + * + * Add an entry to, or update a sockhash *map* referencing sockets. + * The *skops* is used as a new value for the entry associated to + * *key*. *flags* is one of: + * + * **BPF_NOEXIST** + * The entry for *key* must not exist in the map. + * **BPF_EXIST** + * The entry for *key* must already exist in the map. + * **BPF_ANY** + * No condition on the existence of the entry for *key*. + * + * If the *map* has eBPF programs (parser and verdict), those will + * be inherited by the socket being added. If the socket is + * already attached to eBPF programs, this results in an error. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_sock_hash_update)(struct bpf_sock_ops *skops, void *map, void *key, __u64 flags) = (void *) 70; + +/* + * bpf_msg_redirect_hash + * + * This helper is used in programs implementing policies at the + * socket level. If the message *msg* is allowed to pass (i.e. if + * the verdict eBPF program returns **SK_PASS**), redirect it to + * the socket referenced by *map* (of type + * **BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and + * egress interfaces can be used for redirection. The + * **BPF_F_INGRESS** value in *flags* is used to make the + * distinction (ingress path is selected if the flag is present, + * egress path otherwise). This is the only flag supported for now. + * + * Returns + * **SK_PASS** on success, or **SK_DROP** on error. + */ +static long (*bpf_msg_redirect_hash)(struct sk_msg_md *msg, void *map, void *key, __u64 flags) = (void *) 71; + +/* + * bpf_sk_redirect_hash + * + * This helper is used in programs implementing policies at the + * skb socket level. If the sk_buff *skb* is allowed to pass (i.e. + * if the verdict eBPF program returns **SK_PASS**), redirect it + * to the socket referenced by *map* (of type + * **BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and + * egress interfaces can be used for redirection. The + * **BPF_F_INGRESS** value in *flags* is used to make the + * distinction (ingress path is selected if the flag is present, + * egress otherwise). This is the only flag supported for now. + * + * Returns + * **SK_PASS** on success, or **SK_DROP** on error. + */ +static long (*bpf_sk_redirect_hash)(struct __sk_buff *skb, void *map, void *key, __u64 flags) = (void *) 72; + +/* + * bpf_lwt_push_encap + * + * Encapsulate the packet associated to *skb* within a Layer 3 + * protocol header. This header is provided in the buffer at + * address *hdr*, with *len* its size in bytes. *type* indicates + * the protocol of the header and can be one of: + * + * **BPF_LWT_ENCAP_SEG6** + * IPv6 encapsulation with Segment Routing Header + * (**struct ipv6_sr_hdr**). *hdr* only contains the SRH, + * the IPv6 header is computed by the kernel. + * **BPF_LWT_ENCAP_SEG6_INLINE** + * Only works if *skb* contains an IPv6 packet. Insert a + * Segment Routing Header (**struct ipv6_sr_hdr**) inside + * the IPv6 header. + * **BPF_LWT_ENCAP_IP** + * IP encapsulation (GRE/GUE/IPIP/etc). The outer header + * must be IPv4 or IPv6, followed by zero or more + * additional headers, up to **LWT_BPF_MAX_HEADROOM** + * total bytes in all prepended headers. Please note that + * if **skb_is_gso**\ (*skb*) is true, no more than two + * headers can be prepended, and the inner header, if + * present, should be either GRE or UDP/GUE. + * + * **BPF_LWT_ENCAP_SEG6**\ \* types can be called by BPF programs + * of type **BPF_PROG_TYPE_LWT_IN**; **BPF_LWT_ENCAP_IP** type can + * be called by bpf programs of types **BPF_PROG_TYPE_LWT_IN** and + * **BPF_PROG_TYPE_LWT_XMIT**. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_lwt_push_encap)(struct __sk_buff *skb, __u32 type, void *hdr, __u32 len) = (void *) 73; + +/* + * bpf_lwt_seg6_store_bytes + * + * Store *len* bytes from address *from* into the packet + * associated to *skb*, at *offset*. Only the flags, tag and TLVs + * inside the outermost IPv6 Segment Routing Header can be + * modified through this helper. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_lwt_seg6_store_bytes)(struct __sk_buff *skb, __u32 offset, const void *from, __u32 len) = (void *) 74; + +/* + * bpf_lwt_seg6_adjust_srh + * + * Adjust the size allocated to TLVs in the outermost IPv6 + * Segment Routing Header contained in the packet associated to + * *skb*, at position *offset* by *delta* bytes. Only offsets + * after the segments are accepted. *delta* can be as well + * positive (growing) as negative (shrinking). + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_lwt_seg6_adjust_srh)(struct __sk_buff *skb, __u32 offset, __s32 delta) = (void *) 75; + +/* + * bpf_lwt_seg6_action + * + * Apply an IPv6 Segment Routing action of type *action* to the + * packet associated to *skb*. Each action takes a parameter + * contained at address *param*, and of length *param_len* bytes. + * *action* can be one of: + * + * **SEG6_LOCAL_ACTION_END_X** + * End.X action: Endpoint with Layer-3 cross-connect. + * Type of *param*: **struct in6_addr**. + * **SEG6_LOCAL_ACTION_END_T** + * End.T action: Endpoint with specific IPv6 table lookup. + * Type of *param*: **int**. + * **SEG6_LOCAL_ACTION_END_B6** + * End.B6 action: Endpoint bound to an SRv6 policy. + * Type of *param*: **struct ipv6_sr_hdr**. + * **SEG6_LOCAL_ACTION_END_B6_ENCAP** + * End.B6.Encap action: Endpoint bound to an SRv6 + * encapsulation policy. + * Type of *param*: **struct ipv6_sr_hdr**. + * + * A call to this helper is susceptible to change the underlying + * packet buffer. Therefore, at load time, all checks on pointers + * previously done by the verifier are invalidated and must be + * performed again, if the helper is used in combination with + * direct packet access. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_lwt_seg6_action)(struct __sk_buff *skb, __u32 action, void *param, __u32 param_len) = (void *) 76; + +/* + * bpf_rc_repeat + * + * This helper is used in programs implementing IR decoding, to + * report a successfully decoded repeat key message. This delays + * the generation of a key up event for previously generated + * key down event. + * + * Some IR protocols like NEC have a special IR message for + * repeating last button, for when a button is held down. + * + * The *ctx* should point to the lirc sample as passed into + * the program. + * + * This helper is only available is the kernel was compiled with + * the **CONFIG_BPF_LIRC_MODE2** configuration option set to + * "**y**". + * + * Returns + * 0 + */ +static long (*bpf_rc_repeat)(void *ctx) = (void *) 77; + +/* + * bpf_rc_keydown + * + * This helper is used in programs implementing IR decoding, to + * report a successfully decoded key press with *scancode*, + * *toggle* value in the given *protocol*. The scancode will be + * translated to a keycode using the rc keymap, and reported as + * an input key down event. After a period a key up event is + * generated. This period can be extended by calling either + * **bpf_rc_keydown**\ () again with the same values, or calling + * **bpf_rc_repeat**\ (). + * + * Some protocols include a toggle bit, in case the button was + * released and pressed again between consecutive scancodes. + * + * The *ctx* should point to the lirc sample as passed into + * the program. + * + * The *protocol* is the decoded protocol number (see + * **enum rc_proto** for some predefined values). + * + * This helper is only available is the kernel was compiled with + * the **CONFIG_BPF_LIRC_MODE2** configuration option set to + * "**y**". + * + * Returns + * 0 + */ +static long (*bpf_rc_keydown)(void *ctx, __u32 protocol, __u64 scancode, __u32 toggle) = (void *) 78; + +/* + * bpf_skb_cgroup_id + * + * Return the cgroup v2 id of the socket associated with the *skb*. + * This is roughly similar to the **bpf_get_cgroup_classid**\ () + * helper for cgroup v1 by providing a tag resp. identifier that + * can be matched on or used for map lookups e.g. to implement + * policy. The cgroup v2 id of a given path in the hierarchy is + * exposed in user space through the f_handle API in order to get + * to the same 64-bit id. + * + * This helper can be used on TC egress path, but not on ingress, + * and is available only if the kernel was compiled with the + * **CONFIG_SOCK_CGROUP_DATA** configuration option. + * + * Returns + * The id is returned or 0 in case the id could not be retrieved. + */ +static __u64 (*bpf_skb_cgroup_id)(struct __sk_buff *skb) = (void *) 79; + +/* + * bpf_get_current_cgroup_id + * + * + * Returns + * A 64-bit integer containing the current cgroup id based + * on the cgroup within which the current task is running. + */ +static __u64 (*bpf_get_current_cgroup_id)(void) = (void *) 80; + +/* + * bpf_get_local_storage + * + * Get the pointer to the local storage area. + * The type and the size of the local storage is defined + * by the *map* argument. + * The *flags* meaning is specific for each map type, + * and has to be 0 for cgroup local storage. + * + * Depending on the BPF program type, a local storage area + * can be shared between multiple instances of the BPF program, + * running simultaneously. + * + * A user should care about the synchronization by himself. + * For example, by using the **BPF_ATOMIC** instructions to alter + * the shared data. + * + * Returns + * A pointer to the local storage area. + */ +static void *(*bpf_get_local_storage)(void *map, __u64 flags) = (void *) 81; + +/* + * bpf_sk_select_reuseport + * + * Select a **SO_REUSEPORT** socket from a + * **BPF_MAP_TYPE_REUSEPORT_ARRAY** *map*. + * It checks the selected socket is matching the incoming + * request in the socket buffer. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_sk_select_reuseport)(struct sk_reuseport_md *reuse, void *map, void *key, __u64 flags) = (void *) 82; + +/* + * bpf_skb_ancestor_cgroup_id + * + * Return id of cgroup v2 that is ancestor of cgroup associated + * with the *skb* at the *ancestor_level*. The root cgroup is at + * *ancestor_level* zero and each step down the hierarchy + * increments the level. If *ancestor_level* == level of cgroup + * associated with *skb*, then return value will be same as that + * of **bpf_skb_cgroup_id**\ (). + * + * The helper is useful to implement policies based on cgroups + * that are upper in hierarchy than immediate cgroup associated + * with *skb*. + * + * The format of returned id and helper limitations are same as in + * **bpf_skb_cgroup_id**\ (). + * + * Returns + * The id is returned or 0 in case the id could not be retrieved. + */ +static __u64 (*bpf_skb_ancestor_cgroup_id)(struct __sk_buff *skb, int ancestor_level) = (void *) 83; + +/* + * bpf_sk_lookup_tcp + * + * Look for TCP socket matching *tuple*, optionally in a child + * network namespace *netns*. The return value must be checked, + * and if non-**NULL**, released via **bpf_sk_release**\ (). + * + * The *ctx* should point to the context of the program, such as + * the skb or socket (depending on the hook in use). This is used + * to determine the base network namespace for the lookup. + * + * *tuple_size* must be one of: + * + * **sizeof**\ (*tuple*\ **->ipv4**) + * Look for an IPv4 socket. + * **sizeof**\ (*tuple*\ **->ipv6**) + * Look for an IPv6 socket. + * + * If the *netns* is a negative signed 32-bit integer, then the + * socket lookup table in the netns associated with the *ctx* + * will be used. For the TC hooks, this is the netns of the device + * in the skb. For socket hooks, this is the netns of the socket. + * If *netns* is any other signed 32-bit value greater than or + * equal to zero then it specifies the ID of the netns relative to + * the netns associated with the *ctx*. *netns* values beyond the + * range of 32-bit integers are reserved for future use. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * + * This helper is available only if the kernel was compiled with + * **CONFIG_NET** configuration option. + * + * Returns + * Pointer to **struct bpf_sock**, or **NULL** in case of failure. + * For sockets with reuseport option, the **struct bpf_sock** + * result is from *reuse*\ **->socks**\ [] using the hash of the + * tuple. + */ +static struct bpf_sock *(*bpf_sk_lookup_tcp)(void *ctx, struct bpf_sock_tuple *tuple, __u32 tuple_size, __u64 netns, __u64 flags) = (void *) 84; + +/* + * bpf_sk_lookup_udp + * + * Look for UDP socket matching *tuple*, optionally in a child + * network namespace *netns*. The return value must be checked, + * and if non-**NULL**, released via **bpf_sk_release**\ (). + * + * The *ctx* should point to the context of the program, such as + * the skb or socket (depending on the hook in use). This is used + * to determine the base network namespace for the lookup. + * + * *tuple_size* must be one of: + * + * **sizeof**\ (*tuple*\ **->ipv4**) + * Look for an IPv4 socket. + * **sizeof**\ (*tuple*\ **->ipv6**) + * Look for an IPv6 socket. + * + * If the *netns* is a negative signed 32-bit integer, then the + * socket lookup table in the netns associated with the *ctx* + * will be used. For the TC hooks, this is the netns of the device + * in the skb. For socket hooks, this is the netns of the socket. + * If *netns* is any other signed 32-bit value greater than or + * equal to zero then it specifies the ID of the netns relative to + * the netns associated with the *ctx*. *netns* values beyond the + * range of 32-bit integers are reserved for future use. + * + * All values for *flags* are reserved for future usage, and must + * be left at zero. + * + * This helper is available only if the kernel was compiled with + * **CONFIG_NET** configuration option. + * + * Returns + * Pointer to **struct bpf_sock**, or **NULL** in case of failure. + * For sockets with reuseport option, the **struct bpf_sock** + * result is from *reuse*\ **->socks**\ [] using the hash of the + * tuple. + */ +static struct bpf_sock *(*bpf_sk_lookup_udp)(void *ctx, struct bpf_sock_tuple *tuple, __u32 tuple_size, __u64 netns, __u64 flags) = (void *) 85; + +/* + * bpf_sk_release + * + * Release the reference held by *sock*. *sock* must be a + * non-**NULL** pointer that was returned from + * **bpf_sk_lookup_xxx**\ (). + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_sk_release)(void *sock) = (void *) 86; + +/* + * bpf_map_push_elem + * + * Push an element *value* in *map*. *flags* is one of: + * + * **BPF_EXIST** + * If the queue/stack is full, the oldest element is + * removed to make room for this. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_map_push_elem)(void *map, const void *value, __u64 flags) = (void *) 87; + +/* + * bpf_map_pop_elem + * + * Pop an element from *map*. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_map_pop_elem)(void *map, void *value) = (void *) 88; + +/* + * bpf_map_peek_elem + * + * Get an element from *map* without removing it. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_map_peek_elem)(void *map, void *value) = (void *) 89; + +/* + * bpf_msg_push_data + * + * For socket policies, insert *len* bytes into *msg* at offset + * *start*. + * + * If a program of type **BPF_PROG_TYPE_SK_MSG** is run on a + * *msg* it may want to insert metadata or options into the *msg*. + * This can later be read and used by any of the lower layer BPF + * hooks. + * + * This helper may fail if under memory pressure (a malloc + * fails) in these cases BPF programs will get an appropriate + * error and BPF programs will need to handle them. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_msg_push_data)(struct sk_msg_md *msg, __u32 start, __u32 len, __u64 flags) = (void *) 90; + +/* + * bpf_msg_pop_data + * + * Will remove *len* bytes from a *msg* starting at byte *start*. + * This may result in **ENOMEM** errors under certain situations if + * an allocation and copy are required due to a full ring buffer. + * However, the helper will try to avoid doing the allocation + * if possible. Other errors can occur if input parameters are + * invalid either due to *start* byte not being valid part of *msg* + * payload and/or *pop* value being to large. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_msg_pop_data)(struct sk_msg_md *msg, __u32 start, __u32 len, __u64 flags) = (void *) 91; + +/* + * bpf_rc_pointer_rel + * + * This helper is used in programs implementing IR decoding, to + * report a successfully decoded pointer movement. + * + * The *ctx* should point to the lirc sample as passed into + * the program. + * + * This helper is only available is the kernel was compiled with + * the **CONFIG_BPF_LIRC_MODE2** configuration option set to + * "**y**". + * + * Returns + * 0 + */ +static long (*bpf_rc_pointer_rel)(void *ctx, __s32 rel_x, __s32 rel_y) = (void *) 92; + +/* + * bpf_spin_lock + * + * Acquire a spinlock represented by the pointer *lock*, which is + * stored as part of a value of a map. Taking the lock allows to + * safely update the rest of the fields in that value. The + * spinlock can (and must) later be released with a call to + * **bpf_spin_unlock**\ (\ *lock*\ ). + * + * Spinlocks in BPF programs come with a number of restrictions + * and constraints: + * + * * **bpf_spin_lock** objects are only allowed inside maps of + * types **BPF_MAP_TYPE_HASH** and **BPF_MAP_TYPE_ARRAY** (this + * list could be extended in the future). + * * BTF description of the map is mandatory. + * * The BPF program can take ONE lock at a time, since taking two + * or more could cause dead locks. + * * Only one **struct bpf_spin_lock** is allowed per map element. + * * When the lock is taken, calls (either BPF to BPF or helpers) + * are not allowed. + * * The **BPF_LD_ABS** and **BPF_LD_IND** instructions are not + * allowed inside a spinlock-ed region. + * * The BPF program MUST call **bpf_spin_unlock**\ () to release + * the lock, on all execution paths, before it returns. + * * The BPF program can access **struct bpf_spin_lock** only via + * the **bpf_spin_lock**\ () and **bpf_spin_unlock**\ () + * helpers. Loading or storing data into the **struct + * bpf_spin_lock** *lock*\ **;** field of a map is not allowed. + * * To use the **bpf_spin_lock**\ () helper, the BTF description + * of the map value must be a struct and have **struct + * bpf_spin_lock** *anyname*\ **;** field at the top level. + * Nested lock inside another struct is not allowed. + * * The **struct bpf_spin_lock** *lock* field in a map value must + * be aligned on a multiple of 4 bytes in that value. + * * Syscall with command **BPF_MAP_LOOKUP_ELEM** does not copy + * the **bpf_spin_lock** field to user space. + * * Syscall with command **BPF_MAP_UPDATE_ELEM**, or update from + * a BPF program, do not update the **bpf_spin_lock** field. + * * **bpf_spin_lock** cannot be on the stack or inside a + * networking packet (it can only be inside of a map values). + * * **bpf_spin_lock** is available to root only. + * * Tracing programs and socket filter programs cannot use + * **bpf_spin_lock**\ () due to insufficient preemption checks + * (but this may change in the future). + * * **bpf_spin_lock** is not allowed in inner maps of map-in-map. + * + * Returns + * 0 + */ +static long (*bpf_spin_lock)(struct bpf_spin_lock *lock) = (void *) 93; + +/* + * bpf_spin_unlock + * + * Release the *lock* previously locked by a call to + * **bpf_spin_lock**\ (\ *lock*\ ). + * + * Returns + * 0 + */ +static long (*bpf_spin_unlock)(struct bpf_spin_lock *lock) = (void *) 94; + +/* + * bpf_sk_fullsock + * + * This helper gets a **struct bpf_sock** pointer such + * that all the fields in this **bpf_sock** can be accessed. + * + * Returns + * A **struct bpf_sock** pointer on success, or **NULL** in + * case of failure. + */ +static struct bpf_sock *(*bpf_sk_fullsock)(struct bpf_sock *sk) = (void *) 95; + +/* + * bpf_tcp_sock + * + * This helper gets a **struct bpf_tcp_sock** pointer from a + * **struct bpf_sock** pointer. + * + * Returns + * A **struct bpf_tcp_sock** pointer on success, or **NULL** in + * case of failure. + */ +static struct bpf_tcp_sock *(*bpf_tcp_sock)(struct bpf_sock *sk) = (void *) 96; + +/* + * bpf_skb_ecn_set_ce + * + * Set ECN (Explicit Congestion Notification) field of IP header + * to **CE** (Congestion Encountered) if current value is **ECT** + * (ECN Capable Transport). Otherwise, do nothing. Works with IPv6 + * and IPv4. + * + * Returns + * 1 if the **CE** flag is set (either by the current helper call + * or because it was already present), 0 if it is not set. + */ +static long (*bpf_skb_ecn_set_ce)(struct __sk_buff *skb) = (void *) 97; + +/* + * bpf_get_listener_sock + * + * Return a **struct bpf_sock** pointer in **TCP_LISTEN** state. + * **bpf_sk_release**\ () is unnecessary and not allowed. + * + * Returns + * A **struct bpf_sock** pointer on success, or **NULL** in + * case of failure. + */ +static struct bpf_sock *(*bpf_get_listener_sock)(struct bpf_sock *sk) = (void *) 98; + +/* + * bpf_skc_lookup_tcp + * + * Look for TCP socket matching *tuple*, optionally in a child + * network namespace *netns*. The return value must be checked, + * and if non-**NULL**, released via **bpf_sk_release**\ (). + * + * This function is identical to **bpf_sk_lookup_tcp**\ (), except + * that it also returns timewait or request sockets. Use + * **bpf_sk_fullsock**\ () or **bpf_tcp_sock**\ () to access the + * full structure. + * + * This helper is available only if the kernel was compiled with + * **CONFIG_NET** configuration option. + * + * Returns + * Pointer to **struct bpf_sock**, or **NULL** in case of failure. + * For sockets with reuseport option, the **struct bpf_sock** + * result is from *reuse*\ **->socks**\ [] using the hash of the + * tuple. + */ +static struct bpf_sock *(*bpf_skc_lookup_tcp)(void *ctx, struct bpf_sock_tuple *tuple, __u32 tuple_size, __u64 netns, __u64 flags) = (void *) 99; + +/* + * bpf_tcp_check_syncookie + * + * Check whether *iph* and *th* contain a valid SYN cookie ACK for + * the listening socket in *sk*. + * + * *iph* points to the start of the IPv4 or IPv6 header, while + * *iph_len* contains **sizeof**\ (**struct iphdr**) or + * **sizeof**\ (**struct ip6hdr**). + * + * *th* points to the start of the TCP header, while *th_len* + * contains **sizeof**\ (**struct tcphdr**). + * + * Returns + * 0 if *iph* and *th* are a valid SYN cookie ACK, or a negative + * error otherwise. + */ +static long (*bpf_tcp_check_syncookie)(void *sk, void *iph, __u32 iph_len, struct tcphdr *th, __u32 th_len) = (void *) 100; + +/* + * bpf_sysctl_get_name + * + * Get name of sysctl in /proc/sys/ and copy it into provided by + * program buffer *buf* of size *buf_len*. + * + * The buffer is always NUL terminated, unless it's zero-sized. + * + * If *flags* is zero, full name (e.g. "net/ipv4/tcp_mem") is + * copied. Use **BPF_F_SYSCTL_BASE_NAME** flag to copy base name + * only (e.g. "tcp_mem"). + * + * Returns + * Number of character copied (not including the trailing NUL). + * + * **-E2BIG** if the buffer wasn't big enough (*buf* will contain + * truncated name in this case). + */ +static long (*bpf_sysctl_get_name)(struct bpf_sysctl *ctx, char *buf, unsigned long buf_len, __u64 flags) = (void *) 101; + +/* + * bpf_sysctl_get_current_value + * + * Get current value of sysctl as it is presented in /proc/sys + * (incl. newline, etc), and copy it as a string into provided + * by program buffer *buf* of size *buf_len*. + * + * The whole value is copied, no matter what file position user + * space issued e.g. sys_read at. + * + * The buffer is always NUL terminated, unless it's zero-sized. + * + * Returns + * Number of character copied (not including the trailing NUL). + * + * **-E2BIG** if the buffer wasn't big enough (*buf* will contain + * truncated name in this case). + * + * **-EINVAL** if current value was unavailable, e.g. because + * sysctl is uninitialized and read returns -EIO for it. + */ +static long (*bpf_sysctl_get_current_value)(struct bpf_sysctl *ctx, char *buf, unsigned long buf_len) = (void *) 102; + +/* + * bpf_sysctl_get_new_value + * + * Get new value being written by user space to sysctl (before + * the actual write happens) and copy it as a string into + * provided by program buffer *buf* of size *buf_len*. + * + * User space may write new value at file position > 0. + * + * The buffer is always NUL terminated, unless it's zero-sized. + * + * Returns + * Number of character copied (not including the trailing NUL). + * + * **-E2BIG** if the buffer wasn't big enough (*buf* will contain + * truncated name in this case). + * + * **-EINVAL** if sysctl is being read. + */ +static long (*bpf_sysctl_get_new_value)(struct bpf_sysctl *ctx, char *buf, unsigned long buf_len) = (void *) 103; + +/* + * bpf_sysctl_set_new_value + * + * Override new value being written by user space to sysctl with + * value provided by program in buffer *buf* of size *buf_len*. + * + * *buf* should contain a string in same form as provided by user + * space on sysctl write. + * + * User space may write new value at file position > 0. To override + * the whole sysctl value file position should be set to zero. + * + * Returns + * 0 on success. + * + * **-E2BIG** if the *buf_len* is too big. + * + * **-EINVAL** if sysctl is being read. + */ +static long (*bpf_sysctl_set_new_value)(struct bpf_sysctl *ctx, const char *buf, unsigned long buf_len) = (void *) 104; + +/* + * bpf_strtol + * + * Convert the initial part of the string from buffer *buf* of + * size *buf_len* to a long integer according to the given base + * and save the result in *res*. + * + * The string may begin with an arbitrary amount of white space + * (as determined by **isspace**\ (3)) followed by a single + * optional '**-**' sign. + * + * Five least significant bits of *flags* encode base, other bits + * are currently unused. + * + * Base must be either 8, 10, 16 or 0 to detect it automatically + * similar to user space **strtol**\ (3). + * + * Returns + * Number of characters consumed on success. Must be positive but + * no more than *buf_len*. + * + * **-EINVAL** if no valid digits were found or unsupported base + * was provided. + * + * **-ERANGE** if resulting value was out of range. + */ +static long (*bpf_strtol)(const char *buf, unsigned long buf_len, __u64 flags, long *res) = (void *) 105; + +/* + * bpf_strtoul + * + * Convert the initial part of the string from buffer *buf* of + * size *buf_len* to an unsigned long integer according to the + * given base and save the result in *res*. + * + * The string may begin with an arbitrary amount of white space + * (as determined by **isspace**\ (3)). + * + * Five least significant bits of *flags* encode base, other bits + * are currently unused. + * + * Base must be either 8, 10, 16 or 0 to detect it automatically + * similar to user space **strtoul**\ (3). + * + * Returns + * Number of characters consumed on success. Must be positive but + * no more than *buf_len*. + * + * **-EINVAL** if no valid digits were found or unsupported base + * was provided. + * + * **-ERANGE** if resulting value was out of range. + */ +static long (*bpf_strtoul)(const char *buf, unsigned long buf_len, __u64 flags, unsigned long *res) = (void *) 106; + +/* + * bpf_sk_storage_get + * + * Get a bpf-local-storage from a *sk*. + * + * Logically, it could be thought of getting the value from + * a *map* with *sk* as the **key**. From this + * perspective, the usage is not much different from + * **bpf_map_lookup_elem**\ (*map*, **&**\ *sk*) except this + * helper enforces the key must be a full socket and the map must + * be a **BPF_MAP_TYPE_SK_STORAGE** also. + * + * Underneath, the value is stored locally at *sk* instead of + * the *map*. The *map* is used as the bpf-local-storage + * "type". The bpf-local-storage "type" (i.e. the *map*) is + * searched against all bpf-local-storages residing at *sk*. + * + * *sk* is a kernel **struct sock** pointer for LSM program. + * *sk* is a **struct bpf_sock** pointer for other program types. + * + * An optional *flags* (**BPF_SK_STORAGE_GET_F_CREATE**) can be + * used such that a new bpf-local-storage will be + * created if one does not exist. *value* can be used + * together with **BPF_SK_STORAGE_GET_F_CREATE** to specify + * the initial value of a bpf-local-storage. If *value* is + * **NULL**, the new bpf-local-storage will be zero initialized. + * + * Returns + * A bpf-local-storage pointer is returned on success. + * + * **NULL** if not found or there was an error in adding + * a new bpf-local-storage. + */ +static void *(*bpf_sk_storage_get)(void *map, void *sk, void *value, __u64 flags) = (void *) 107; + +/* + * bpf_sk_storage_delete + * + * Delete a bpf-local-storage from a *sk*. + * + * Returns + * 0 on success. + * + * **-ENOENT** if the bpf-local-storage cannot be found. + * **-EINVAL** if sk is not a fullsock (e.g. a request_sock). + */ +static long (*bpf_sk_storage_delete)(void *map, void *sk) = (void *) 108; + +/* + * bpf_send_signal + * + * Send signal *sig* to the process of the current task. + * The signal may be delivered to any of this process's threads. + * + * Returns + * 0 on success or successfully queued. + * + * **-EBUSY** if work queue under nmi is full. + * + * **-EINVAL** if *sig* is invalid. + * + * **-EPERM** if no permission to send the *sig*. + * + * **-EAGAIN** if bpf program can try again. + */ +static long (*bpf_send_signal)(__u32 sig) = (void *) 109; + +/* + * bpf_tcp_gen_syncookie + * + * Try to issue a SYN cookie for the packet with corresponding + * IP/TCP headers, *iph* and *th*, on the listening socket in *sk*. + * + * *iph* points to the start of the IPv4 or IPv6 header, while + * *iph_len* contains **sizeof**\ (**struct iphdr**) or + * **sizeof**\ (**struct ip6hdr**). + * + * *th* points to the start of the TCP header, while *th_len* + * contains the length of the TCP header. + * + * Returns + * On success, lower 32 bits hold the generated SYN cookie in + * followed by 16 bits which hold the MSS value for that cookie, + * and the top 16 bits are unused. + * + * On failure, the returned value is one of the following: + * + * **-EINVAL** SYN cookie cannot be issued due to error + * + * **-ENOENT** SYN cookie should not be issued (no SYN flood) + * + * **-EOPNOTSUPP** kernel configuration does not enable SYN cookies + * + * **-EPROTONOSUPPORT** IP packet version is not 4 or 6 + */ +static __s64 (*bpf_tcp_gen_syncookie)(void *sk, void *iph, __u32 iph_len, struct tcphdr *th, __u32 th_len) = (void *) 110; + +/* + * bpf_skb_output + * + * Write raw *data* blob into a special BPF perf event held by + * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. This perf + * event must have the following attributes: **PERF_SAMPLE_RAW** + * as **sample_type**, **PERF_TYPE_SOFTWARE** as **type**, and + * **PERF_COUNT_SW_BPF_OUTPUT** as **config**. + * + * The *flags* are used to indicate the index in *map* for which + * the value must be put, masked with **BPF_F_INDEX_MASK**. + * Alternatively, *flags* can be set to **BPF_F_CURRENT_CPU** + * to indicate that the index of the current CPU core should be + * used. + * + * The value to write, of *size*, is passed through eBPF stack and + * pointed by *data*. + * + * *ctx* is a pointer to in-kernel struct sk_buff. + * + * This helper is similar to **bpf_perf_event_output**\ () but + * restricted to raw_tracepoint bpf programs. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_skb_output)(void *ctx, void *map, __u64 flags, void *data, __u64 size) = (void *) 111; + +/* + * bpf_probe_read_user + * + * Safely attempt to read *size* bytes from user space address + * *unsafe_ptr* and store the data in *dst*. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_probe_read_user)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 112; + +/* + * bpf_probe_read_kernel + * + * Safely attempt to read *size* bytes from kernel space address + * *unsafe_ptr* and store the data in *dst*. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_probe_read_kernel)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 113; + +/* + * bpf_probe_read_user_str + * + * Copy a NUL terminated string from an unsafe user address + * *unsafe_ptr* to *dst*. The *size* should include the + * terminating NUL byte. In case the string length is smaller than + * *size*, the target is not padded with further NUL bytes. If the + * string length is larger than *size*, just *size*-1 bytes are + * copied and the last byte is set to NUL. + * + * On success, returns the number of bytes that were written, + * including the terminal NUL. This makes this helper useful in + * tracing programs for reading strings, and more importantly to + * get its length at runtime. See the following snippet: + * + * :: + * + * SEC("kprobe/sys_open") + * void bpf_sys_open(struct pt_regs *ctx) + * { + * char buf[PATHLEN]; // PATHLEN is defined to 256 + * int res = bpf_probe_read_user_str(buf, sizeof(buf), + * ctx->di); + * + * // Consume buf, for example push it to + * // userspace via bpf_perf_event_output(); we + * // can use res (the string length) as event + * // size, after checking its boundaries. + * } + * + * In comparison, using **bpf_probe_read_user**\ () helper here + * instead to read the string would require to estimate the length + * at compile time, and would often result in copying more memory + * than necessary. + * + * Another useful use case is when parsing individual process + * arguments or individual environment variables navigating + * *current*\ **->mm->arg_start** and *current*\ + * **->mm->env_start**: using this helper and the return value, + * one can quickly iterate at the right offset of the memory area. + * + * Returns + * On success, the strictly positive length of the output string, + * including the trailing NUL character. On error, a negative + * value. + */ +static long (*bpf_probe_read_user_str)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 114; + +/* + * bpf_probe_read_kernel_str + * + * Copy a NUL terminated string from an unsafe kernel address *unsafe_ptr* + * to *dst*. Same semantics as with **bpf_probe_read_user_str**\ () apply. + * + * Returns + * On success, the strictly positive length of the string, including + * the trailing NUL character. On error, a negative value. + */ +static long (*bpf_probe_read_kernel_str)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 115; + +/* + * bpf_tcp_send_ack + * + * Send out a tcp-ack. *tp* is the in-kernel struct **tcp_sock**. + * *rcv_nxt* is the ack_seq to be sent out. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_tcp_send_ack)(void *tp, __u32 rcv_nxt) = (void *) 116; + +/* + * bpf_send_signal_thread + * + * Send signal *sig* to the thread corresponding to the current task. + * + * Returns + * 0 on success or successfully queued. + * + * **-EBUSY** if work queue under nmi is full. + * + * **-EINVAL** if *sig* is invalid. + * + * **-EPERM** if no permission to send the *sig*. + * + * **-EAGAIN** if bpf program can try again. + */ +static long (*bpf_send_signal_thread)(__u32 sig) = (void *) 117; + +/* + * bpf_jiffies64 + * + * Obtain the 64bit jiffies + * + * Returns + * The 64 bit jiffies + */ +static __u64 (*bpf_jiffies64)(void) = (void *) 118; + +/* + * bpf_read_branch_records + * + * For an eBPF program attached to a perf event, retrieve the + * branch records (**struct perf_branch_entry**) associated to *ctx* + * and store it in the buffer pointed by *buf* up to size + * *size* bytes. + * + * Returns + * On success, number of bytes written to *buf*. On error, a + * negative value. + * + * The *flags* can be set to **BPF_F_GET_BRANCH_RECORDS_SIZE** to + * instead return the number of bytes required to store all the + * branch entries. If this flag is set, *buf* may be NULL. + * + * **-EINVAL** if arguments invalid or **size** not a multiple + * of **sizeof**\ (**struct perf_branch_entry**\ ). + * + * **-ENOENT** if architecture does not support branch records. + */ +static long (*bpf_read_branch_records)(struct bpf_perf_event_data *ctx, void *buf, __u32 size, __u64 flags) = (void *) 119; + +/* + * bpf_get_ns_current_pid_tgid + * + * Returns 0 on success, values for *pid* and *tgid* as seen from the current + * *namespace* will be returned in *nsdata*. + * + * Returns + * 0 on success, or one of the following in case of failure: + * + * **-EINVAL** if dev and inum supplied don't match dev_t and inode number + * with nsfs of current task, or if dev conversion to dev_t lost high bits. + * + * **-ENOENT** if pidns does not exists for the current task. + */ +static long (*bpf_get_ns_current_pid_tgid)(__u64 dev, __u64 ino, struct bpf_pidns_info *nsdata, __u32 size) = (void *) 120; + +/* + * bpf_xdp_output + * + * Write raw *data* blob into a special BPF perf event held by + * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. This perf + * event must have the following attributes: **PERF_SAMPLE_RAW** + * as **sample_type**, **PERF_TYPE_SOFTWARE** as **type**, and + * **PERF_COUNT_SW_BPF_OUTPUT** as **config**. + * + * The *flags* are used to indicate the index in *map* for which + * the value must be put, masked with **BPF_F_INDEX_MASK**. + * Alternatively, *flags* can be set to **BPF_F_CURRENT_CPU** + * to indicate that the index of the current CPU core should be + * used. + * + * The value to write, of *size*, is passed through eBPF stack and + * pointed by *data*. + * + * *ctx* is a pointer to in-kernel struct xdp_buff. + * + * This helper is similar to **bpf_perf_eventoutput**\ () but + * restricted to raw_tracepoint bpf programs. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_xdp_output)(void *ctx, void *map, __u64 flags, void *data, __u64 size) = (void *) 121; + +/* + * bpf_get_netns_cookie + * + * Retrieve the cookie (generated by the kernel) of the network + * namespace the input *ctx* is associated with. The network + * namespace cookie remains stable for its lifetime and provides + * a global identifier that can be assumed unique. If *ctx* is + * NULL, then the helper returns the cookie for the initial + * network namespace. The cookie itself is very similar to that + * of **bpf_get_socket_cookie**\ () helper, but for network + * namespaces instead of sockets. + * + * Returns + * A 8-byte long opaque number. + */ +static __u64 (*bpf_get_netns_cookie)(void *ctx) = (void *) 122; + +/* + * bpf_get_current_ancestor_cgroup_id + * + * Return id of cgroup v2 that is ancestor of the cgroup associated + * with the current task at the *ancestor_level*. The root cgroup + * is at *ancestor_level* zero and each step down the hierarchy + * increments the level. If *ancestor_level* == level of cgroup + * associated with the current task, then return value will be the + * same as that of **bpf_get_current_cgroup_id**\ (). + * + * The helper is useful to implement policies based on cgroups + * that are upper in hierarchy than immediate cgroup associated + * with the current task. + * + * The format of returned id and helper limitations are same as in + * **bpf_get_current_cgroup_id**\ (). + * + * Returns + * The id is returned or 0 in case the id could not be retrieved. + */ +static __u64 (*bpf_get_current_ancestor_cgroup_id)(int ancestor_level) = (void *) 123; + +/* + * bpf_sk_assign + * + * Helper is overloaded depending on BPF program type. This + * description applies to **BPF_PROG_TYPE_SCHED_CLS** and + * **BPF_PROG_TYPE_SCHED_ACT** programs. + * + * Assign the *sk* to the *skb*. When combined with appropriate + * routing configuration to receive the packet towards the socket, + * will cause *skb* to be delivered to the specified socket. + * Subsequent redirection of *skb* via **bpf_redirect**\ (), + * **bpf_clone_redirect**\ () or other methods outside of BPF may + * interfere with successful delivery to the socket. + * + * This operation is only valid from TC ingress path. + * + * The *flags* argument must be zero. + * + * Returns + * 0 on success, or a negative error in case of failure: + * + * **-EINVAL** if specified *flags* are not supported. + * + * **-ENOENT** if the socket is unavailable for assignment. + * + * **-ENETUNREACH** if the socket is unreachable (wrong netns). + * + * **-EOPNOTSUPP** if the operation is not supported, for example + * a call from outside of TC ingress. + * + * **-ESOCKTNOSUPPORT** if the socket type is not supported + * (reuseport). + */ +static long (*bpf_sk_assign)(void *ctx, void *sk, __u64 flags) = (void *) 124; + +/* + * bpf_ktime_get_boot_ns + * + * Return the time elapsed since system boot, in nanoseconds. + * Does include the time the system was suspended. + * See: **clock_gettime**\ (**CLOCK_BOOTTIME**) + * + * Returns + * Current *ktime*. + */ +static __u64 (*bpf_ktime_get_boot_ns)(void) = (void *) 125; + +/* + * bpf_seq_printf + * + * **bpf_seq_printf**\ () uses seq_file **seq_printf**\ () to print + * out the format string. + * The *m* represents the seq_file. The *fmt* and *fmt_size* are for + * the format string itself. The *data* and *data_len* are format string + * arguments. The *data* are a **u64** array and corresponding format string + * values are stored in the array. For strings and pointers where pointees + * are accessed, only the pointer values are stored in the *data* array. + * The *data_len* is the size of *data* in bytes. + * + * Formats **%s**, **%p{i,I}{4,6}** requires to read kernel memory. + * Reading kernel memory may fail due to either invalid address or + * valid address but requiring a major memory fault. If reading kernel memory + * fails, the string for **%s** will be an empty string, and the ip + * address for **%p{i,I}{4,6}** will be 0. Not returning error to + * bpf program is consistent with what **bpf_trace_printk**\ () does for now. + * + * Returns + * 0 on success, or a negative error in case of failure: + * + * **-EBUSY** if per-CPU memory copy buffer is busy, can try again + * by returning 1 from bpf program. + * + * **-EINVAL** if arguments are invalid, or if *fmt* is invalid/unsupported. + * + * **-E2BIG** if *fmt* contains too many format specifiers. + * + * **-EOVERFLOW** if an overflow happened: The same object will be tried again. + */ +static long (*bpf_seq_printf)(struct seq_file *m, const char *fmt, __u32 fmt_size, const void *data, __u32 data_len) = (void *) 126; + +/* + * bpf_seq_write + * + * **bpf_seq_write**\ () uses seq_file **seq_write**\ () to write the data. + * The *m* represents the seq_file. The *data* and *len* represent the + * data to write in bytes. + * + * Returns + * 0 on success, or a negative error in case of failure: + * + * **-EOVERFLOW** if an overflow happened: The same object will be tried again. + */ +static long (*bpf_seq_write)(struct seq_file *m, const void *data, __u32 len) = (void *) 127; + +/* + * bpf_sk_cgroup_id + * + * Return the cgroup v2 id of the socket *sk*. + * + * *sk* must be a non-**NULL** pointer to a socket, e.g. one + * returned from **bpf_sk_lookup_xxx**\ (), + * **bpf_sk_fullsock**\ (), etc. The format of returned id is + * same as in **bpf_skb_cgroup_id**\ (). + * + * This helper is available only if the kernel was compiled with + * the **CONFIG_SOCK_CGROUP_DATA** configuration option. + * + * Returns + * The id is returned or 0 in case the id could not be retrieved. + */ +static __u64 (*bpf_sk_cgroup_id)(void *sk) = (void *) 128; + +/* + * bpf_sk_ancestor_cgroup_id + * + * Return id of cgroup v2 that is ancestor of cgroup associated + * with the *sk* at the *ancestor_level*. The root cgroup is at + * *ancestor_level* zero and each step down the hierarchy + * increments the level. If *ancestor_level* == level of cgroup + * associated with *sk*, then return value will be same as that + * of **bpf_sk_cgroup_id**\ (). + * + * The helper is useful to implement policies based on cgroups + * that are upper in hierarchy than immediate cgroup associated + * with *sk*. + * + * The format of returned id and helper limitations are same as in + * **bpf_sk_cgroup_id**\ (). + * + * Returns + * The id is returned or 0 in case the id could not be retrieved. + */ +static __u64 (*bpf_sk_ancestor_cgroup_id)(void *sk, int ancestor_level) = (void *) 129; + +/* + * bpf_ringbuf_output + * + * Copy *size* bytes from *data* into a ring buffer *ringbuf*. + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_ringbuf_output)(void *ringbuf, void *data, __u64 size, __u64 flags) = (void *) 130; + +/* + * bpf_ringbuf_reserve + * + * Reserve *size* bytes of payload in a ring buffer *ringbuf*. + * + * Returns + * Valid pointer with *size* bytes of memory available; NULL, + * otherwise. + */ +static void *(*bpf_ringbuf_reserve)(void *ringbuf, __u64 size, __u64 flags) = (void *) 131; + +/* + * bpf_ringbuf_submit + * + * Submit reserved ring buffer sample, pointed to by *data*. + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. + * + * Returns + * Nothing. Always succeeds. + */ +static void (*bpf_ringbuf_submit)(void *data, __u64 flags) = (void *) 132; + +/* + * bpf_ringbuf_discard + * + * Discard reserved ring buffer sample, pointed to by *data*. + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification + * of new data availability is sent. + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification + * of new data availability is sent unconditionally. + * + * Returns + * Nothing. Always succeeds. + */ +static void (*bpf_ringbuf_discard)(void *data, __u64 flags) = (void *) 133; + +/* + * bpf_ringbuf_query + * + * Query various characteristics of provided ring buffer. What + * exactly is queries is determined by *flags*: + * + * * **BPF_RB_AVAIL_DATA**: Amount of data not yet consumed. + * * **BPF_RB_RING_SIZE**: The size of ring buffer. + * * **BPF_RB_CONS_POS**: Consumer position (can wrap around). + * * **BPF_RB_PROD_POS**: Producer(s) position (can wrap around). + * + * Data returned is just a momentary snapshot of actual values + * and could be inaccurate, so this facility should be used to + * power heuristics and for reporting, not to make 100% correct + * calculation. + * + * Returns + * Requested value, or 0, if *flags* are not recognized. + */ +static __u64 (*bpf_ringbuf_query)(void *ringbuf, __u64 flags) = (void *) 134; + +/* + * bpf_csum_level + * + * Change the skbs checksum level by one layer up or down, or + * reset it entirely to none in order to have the stack perform + * checksum validation. The level is applicable to the following + * protocols: TCP, UDP, GRE, SCTP, FCOE. For example, a decap of + * | ETH | IP | UDP | GUE | IP | TCP | into | ETH | IP | TCP | + * through **bpf_skb_adjust_room**\ () helper with passing in + * **BPF_F_ADJ_ROOM_NO_CSUM_RESET** flag would require one call + * to **bpf_csum_level**\ () with **BPF_CSUM_LEVEL_DEC** since + * the UDP header is removed. Similarly, an encap of the latter + * into the former could be accompanied by a helper call to + * **bpf_csum_level**\ () with **BPF_CSUM_LEVEL_INC** if the + * skb is still intended to be processed in higher layers of the + * stack instead of just egressing at tc. + * + * There are three supported level settings at this time: + * + * * **BPF_CSUM_LEVEL_INC**: Increases skb->csum_level for skbs + * with CHECKSUM_UNNECESSARY. + * * **BPF_CSUM_LEVEL_DEC**: Decreases skb->csum_level for skbs + * with CHECKSUM_UNNECESSARY. + * * **BPF_CSUM_LEVEL_RESET**: Resets skb->csum_level to 0 and + * sets CHECKSUM_NONE to force checksum validation by the stack. + * * **BPF_CSUM_LEVEL_QUERY**: No-op, returns the current + * skb->csum_level. + * + * Returns + * 0 on success, or a negative error in case of failure. In the + * case of **BPF_CSUM_LEVEL_QUERY**, the current skb->csum_level + * is returned or the error code -EACCES in case the skb is not + * subject to CHECKSUM_UNNECESSARY. + */ +static long (*bpf_csum_level)(struct __sk_buff *skb, __u64 level) = (void *) 135; + +/* + * bpf_skc_to_tcp6_sock + * + * Dynamically cast a *sk* pointer to a *tcp6_sock* pointer. + * + * Returns + * *sk* if casting is valid, or **NULL** otherwise. + */ +static struct tcp6_sock *(*bpf_skc_to_tcp6_sock)(void *sk) = (void *) 136; + +/* + * bpf_skc_to_tcp_sock + * + * Dynamically cast a *sk* pointer to a *tcp_sock* pointer. + * + * Returns + * *sk* if casting is valid, or **NULL** otherwise. + */ +static struct tcp_sock *(*bpf_skc_to_tcp_sock)(void *sk) = (void *) 137; + +/* + * bpf_skc_to_tcp_timewait_sock + * + * Dynamically cast a *sk* pointer to a *tcp_timewait_sock* pointer. + * + * Returns + * *sk* if casting is valid, or **NULL** otherwise. + */ +static struct tcp_timewait_sock *(*bpf_skc_to_tcp_timewait_sock)(void *sk) = (void *) 138; + +/* + * bpf_skc_to_tcp_request_sock + * + * Dynamically cast a *sk* pointer to a *tcp_request_sock* pointer. + * + * Returns + * *sk* if casting is valid, or **NULL** otherwise. + */ +static struct tcp_request_sock *(*bpf_skc_to_tcp_request_sock)(void *sk) = (void *) 139; + +/* + * bpf_skc_to_udp6_sock + * + * Dynamically cast a *sk* pointer to a *udp6_sock* pointer. + * + * Returns + * *sk* if casting is valid, or **NULL** otherwise. + */ +static struct udp6_sock *(*bpf_skc_to_udp6_sock)(void *sk) = (void *) 140; + +/* + * bpf_get_task_stack + * + * Return a user or a kernel stack in bpf program provided buffer. + * To achieve this, the helper needs *task*, which is a valid + * pointer to **struct task_struct**. To store the stacktrace, the + * bpf program provides *buf* with a nonnegative *size*. + * + * The last argument, *flags*, holds the number of stack frames to + * skip (from 0 to 255), masked with + * **BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set + * the following flags: + * + * **BPF_F_USER_STACK** + * Collect a user space stack instead of a kernel stack. + * **BPF_F_USER_BUILD_ID** + * Collect buildid+offset instead of ips for user stack, + * only valid if **BPF_F_USER_STACK** is also specified. + * + * **bpf_get_task_stack**\ () can collect up to + * **PERF_MAX_STACK_DEPTH** both kernel and user frames, subject + * to sufficient large buffer size. Note that + * this limit can be controlled with the **sysctl** program, and + * that it should be manually increased in order to profile long + * user stacks (such as stacks for Java programs). To do so, use: + * + * :: + * + * # sysctl kernel.perf_event_max_stack= + * + * Returns + * A non-negative value equal to or less than *size* on success, + * or a negative error in case of failure. + */ +static long (*bpf_get_task_stack)(struct task_struct *task, void *buf, __u32 size, __u64 flags) = (void *) 141; + +/* + * bpf_load_hdr_opt + * + * Load header option. Support reading a particular TCP header + * option for bpf program (**BPF_PROG_TYPE_SOCK_OPS**). + * + * If *flags* is 0, it will search the option from the + * *skops*\ **->skb_data**. The comment in **struct bpf_sock_ops** + * has details on what skb_data contains under different + * *skops*\ **->op**. + * + * The first byte of the *searchby_res* specifies the + * kind that it wants to search. + * + * If the searching kind is an experimental kind + * (i.e. 253 or 254 according to RFC6994). It also + * needs to specify the "magic" which is either + * 2 bytes or 4 bytes. It then also needs to + * specify the size of the magic by using + * the 2nd byte which is "kind-length" of a TCP + * header option and the "kind-length" also + * includes the first 2 bytes "kind" and "kind-length" + * itself as a normal TCP header option also does. + * + * For example, to search experimental kind 254 with + * 2 byte magic 0xeB9F, the searchby_res should be + * [ 254, 4, 0xeB, 0x9F, 0, 0, .... 0 ]. + * + * To search for the standard window scale option (3), + * the *searchby_res* should be [ 3, 0, 0, .... 0 ]. + * Note, kind-length must be 0 for regular option. + * + * Searching for No-Op (0) and End-of-Option-List (1) are + * not supported. + * + * *len* must be at least 2 bytes which is the minimal size + * of a header option. + * + * Supported flags: + * + * * **BPF_LOAD_HDR_OPT_TCP_SYN** to search from the + * saved_syn packet or the just-received syn packet. + * + * + * Returns + * > 0 when found, the header option is copied to *searchby_res*. + * The return value is the total length copied. On failure, a + * negative error code is returned: + * + * **-EINVAL** if a parameter is invalid. + * + * **-ENOMSG** if the option is not found. + * + * **-ENOENT** if no syn packet is available when + * **BPF_LOAD_HDR_OPT_TCP_SYN** is used. + * + * **-ENOSPC** if there is not enough space. Only *len* number of + * bytes are copied. + * + * **-EFAULT** on failure to parse the header options in the + * packet. + * + * **-EPERM** if the helper cannot be used under the current + * *skops*\ **->op**. + */ +static long (*bpf_load_hdr_opt)(struct bpf_sock_ops *skops, void *searchby_res, __u32 len, __u64 flags) = (void *) 142; + +/* + * bpf_store_hdr_opt + * + * Store header option. The data will be copied + * from buffer *from* with length *len* to the TCP header. + * + * The buffer *from* should have the whole option that + * includes the kind, kind-length, and the actual + * option data. The *len* must be at least kind-length + * long. The kind-length does not have to be 4 byte + * aligned. The kernel will take care of the padding + * and setting the 4 bytes aligned value to th->doff. + * + * This helper will check for duplicated option + * by searching the same option in the outgoing skb. + * + * This helper can only be called during + * **BPF_SOCK_OPS_WRITE_HDR_OPT_CB**. + * + * + * Returns + * 0 on success, or negative error in case of failure: + * + * **-EINVAL** If param is invalid. + * + * **-ENOSPC** if there is not enough space in the header. + * Nothing has been written + * + * **-EEXIST** if the option already exists. + * + * **-EFAULT** on failrue to parse the existing header options. + * + * **-EPERM** if the helper cannot be used under the current + * *skops*\ **->op**. + */ +static long (*bpf_store_hdr_opt)(struct bpf_sock_ops *skops, const void *from, __u32 len, __u64 flags) = (void *) 143; + +/* + * bpf_reserve_hdr_opt + * + * Reserve *len* bytes for the bpf header option. The + * space will be used by **bpf_store_hdr_opt**\ () later in + * **BPF_SOCK_OPS_WRITE_HDR_OPT_CB**. + * + * If **bpf_reserve_hdr_opt**\ () is called multiple times, + * the total number of bytes will be reserved. + * + * This helper can only be called during + * **BPF_SOCK_OPS_HDR_OPT_LEN_CB**. + * + * + * Returns + * 0 on success, or negative error in case of failure: + * + * **-EINVAL** if a parameter is invalid. + * + * **-ENOSPC** if there is not enough space in the header. + * + * **-EPERM** if the helper cannot be used under the current + * *skops*\ **->op**. + */ +static long (*bpf_reserve_hdr_opt)(struct bpf_sock_ops *skops, __u32 len, __u64 flags) = (void *) 144; + +/* + * bpf_inode_storage_get + * + * Get a bpf_local_storage from an *inode*. + * + * Logically, it could be thought of as getting the value from + * a *map* with *inode* as the **key**. From this + * perspective, the usage is not much different from + * **bpf_map_lookup_elem**\ (*map*, **&**\ *inode*) except this + * helper enforces the key must be an inode and the map must also + * be a **BPF_MAP_TYPE_INODE_STORAGE**. + * + * Underneath, the value is stored locally at *inode* instead of + * the *map*. The *map* is used as the bpf-local-storage + * "type". The bpf-local-storage "type" (i.e. the *map*) is + * searched against all bpf_local_storage residing at *inode*. + * + * An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be + * used such that a new bpf_local_storage will be + * created if one does not exist. *value* can be used + * together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify + * the initial value of a bpf_local_storage. If *value* is + * **NULL**, the new bpf_local_storage will be zero initialized. + * + * Returns + * A bpf_local_storage pointer is returned on success. + * + * **NULL** if not found or there was an error in adding + * a new bpf_local_storage. + */ +static void *(*bpf_inode_storage_get)(void *map, void *inode, void *value, __u64 flags) = (void *) 145; + +/* + * bpf_inode_storage_delete + * + * Delete a bpf_local_storage from an *inode*. + * + * Returns + * 0 on success. + * + * **-ENOENT** if the bpf_local_storage cannot be found. + */ +static int (*bpf_inode_storage_delete)(void *map, void *inode) = (void *) 146; + +/* + * bpf_d_path + * + * Return full path for given **struct path** object, which + * needs to be the kernel BTF *path* object. The path is + * returned in the provided buffer *buf* of size *sz* and + * is zero terminated. + * + * + * Returns + * On success, the strictly positive length of the string, + * including the trailing NUL character. On error, a negative + * value. + */ +static long (*bpf_d_path)(struct path *path, char *buf, __u32 sz) = (void *) 147; + +/* + * bpf_copy_from_user + * + * Read *size* bytes from user space address *user_ptr* and store + * the data in *dst*. This is a wrapper of **copy_from_user**\ (). + * + * Returns + * 0 on success, or a negative error in case of failure. + */ +static long (*bpf_copy_from_user)(void *dst, __u32 size, const void *user_ptr) = (void *) 148; + +/* + * bpf_snprintf_btf + * + * Use BTF to store a string representation of *ptr*->ptr in *str*, + * using *ptr*->type_id. This value should specify the type + * that *ptr*->ptr points to. LLVM __builtin_btf_type_id(type, 1) + * can be used to look up vmlinux BTF type ids. Traversing the + * data structure using BTF, the type information and values are + * stored in the first *str_size* - 1 bytes of *str*. Safe copy of + * the pointer data is carried out to avoid kernel crashes during + * operation. Smaller types can use string space on the stack; + * larger programs can use map data to store the string + * representation. + * + * The string can be subsequently shared with userspace via + * bpf_perf_event_output() or ring buffer interfaces. + * bpf_trace_printk() is to be avoided as it places too small + * a limit on string size to be useful. + * + * *flags* is a combination of + * + * **BTF_F_COMPACT** + * no formatting around type information + * **BTF_F_NONAME** + * no struct/union member names/types + * **BTF_F_PTR_RAW** + * show raw (unobfuscated) pointer values; + * equivalent to printk specifier %px. + * **BTF_F_ZERO** + * show zero-valued struct/union members; they + * are not displayed by default + * + * + * Returns + * The number of bytes that were written (or would have been + * written if output had to be truncated due to string size), + * or a negative error in cases of failure. + */ +static long (*bpf_snprintf_btf)(char *str, __u32 str_size, struct btf_ptr *ptr, __u32 btf_ptr_size, __u64 flags) = (void *) 149; + +/* + * bpf_seq_printf_btf + * + * Use BTF to write to seq_write a string representation of + * *ptr*->ptr, using *ptr*->type_id as per bpf_snprintf_btf(). + * *flags* are identical to those used for bpf_snprintf_btf. + * + * Returns + * 0 on success or a negative error in case of failure. + */ +static long (*bpf_seq_printf_btf)(struct seq_file *m, struct btf_ptr *ptr, __u32 ptr_size, __u64 flags) = (void *) 150; + +/* + * bpf_skb_cgroup_classid + * + * See **bpf_get_cgroup_classid**\ () for the main description. + * This helper differs from **bpf_get_cgroup_classid**\ () in that + * the cgroup v1 net_cls class is retrieved only from the *skb*'s + * associated socket instead of the current process. + * + * Returns + * The id is returned or 0 in case the id could not be retrieved. + */ +static __u64 (*bpf_skb_cgroup_classid)(struct __sk_buff *skb) = (void *) 151; + +/* + * bpf_redirect_neigh + * + * Redirect the packet to another net device of index *ifindex* + * and fill in L2 addresses from neighboring subsystem. This helper + * is somewhat similar to **bpf_redirect**\ (), except that it + * populates L2 addresses as well, meaning, internally, the helper + * relies on the neighbor lookup for the L2 address of the nexthop. + * + * The helper will perform a FIB lookup based on the skb's + * networking header to get the address of the next hop, unless + * this is supplied by the caller in the *params* argument. The + * *plen* argument indicates the len of *params* and should be set + * to 0 if *params* is NULL. + * + * The *flags* argument is reserved and must be 0. The helper is + * currently only supported for tc BPF program types, and enabled + * for IPv4 and IPv6 protocols. + * + * Returns + * The helper returns **TC_ACT_REDIRECT** on success or + * **TC_ACT_SHOT** on error. + */ +static long (*bpf_redirect_neigh)(__u32 ifindex, struct bpf_redir_neigh *params, int plen, __u64 flags) = (void *) 152; + +/* + * bpf_per_cpu_ptr + * + * Take a pointer to a percpu ksym, *percpu_ptr*, and return a + * pointer to the percpu kernel variable on *cpu*. A ksym is an + * extern variable decorated with '__ksym'. For ksym, there is a + * global var (either static or global) defined of the same name + * in the kernel. The ksym is percpu if the global var is percpu. + * The returned pointer points to the global percpu var on *cpu*. + * + * bpf_per_cpu_ptr() has the same semantic as per_cpu_ptr() in the + * kernel, except that bpf_per_cpu_ptr() may return NULL. This + * happens if *cpu* is larger than nr_cpu_ids. The caller of + * bpf_per_cpu_ptr() must check the returned value. + * + * Returns + * A pointer pointing to the kernel percpu variable on *cpu*, or + * NULL, if *cpu* is invalid. + */ +static void *(*bpf_per_cpu_ptr)(const void *percpu_ptr, __u32 cpu) = (void *) 153; + +/* + * bpf_this_cpu_ptr + * + * Take a pointer to a percpu ksym, *percpu_ptr*, and return a + * pointer to the percpu kernel variable on this cpu. See the + * description of 'ksym' in **bpf_per_cpu_ptr**\ (). + * + * bpf_this_cpu_ptr() has the same semantic as this_cpu_ptr() in + * the kernel. Different from **bpf_per_cpu_ptr**\ (), it would + * never return NULL. + * + * Returns + * A pointer pointing to the kernel percpu variable on this cpu. + */ +static void *(*bpf_this_cpu_ptr)(const void *percpu_ptr) = (void *) 154; + +/* + * bpf_redirect_peer + * + * Redirect the packet to another net device of index *ifindex*. + * This helper is somewhat similar to **bpf_redirect**\ (), except + * that the redirection happens to the *ifindex*' peer device and + * the netns switch takes place from ingress to ingress without + * going through the CPU's backlog queue. + * + * The *flags* argument is reserved and must be 0. The helper is + * currently only supported for tc BPF program types at the ingress + * hook and for veth device types. The peer device must reside in a + * different network namespace. + * + * Returns + * The helper returns **TC_ACT_REDIRECT** on success or + * **TC_ACT_SHOT** on error. + */ +static long (*bpf_redirect_peer)(__u32 ifindex, __u64 flags) = (void *) 155; + +/* + * bpf_task_storage_get + * + * Get a bpf_local_storage from the *task*. + * + * Logically, it could be thought of as getting the value from + * a *map* with *task* as the **key**. From this + * perspective, the usage is not much different from + * **bpf_map_lookup_elem**\ (*map*, **&**\ *task*) except this + * helper enforces the key must be an task_struct and the map must also + * be a **BPF_MAP_TYPE_TASK_STORAGE**. + * + * Underneath, the value is stored locally at *task* instead of + * the *map*. The *map* is used as the bpf-local-storage + * "type". The bpf-local-storage "type" (i.e. the *map*) is + * searched against all bpf_local_storage residing at *task*. + * + * An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be + * used such that a new bpf_local_storage will be + * created if one does not exist. *value* can be used + * together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify + * the initial value of a bpf_local_storage. If *value* is + * **NULL**, the new bpf_local_storage will be zero initialized. + * + * Returns + * A bpf_local_storage pointer is returned on success. + * + * **NULL** if not found or there was an error in adding + * a new bpf_local_storage. + */ +static void *(*bpf_task_storage_get)(void *map, struct task_struct *task, void *value, __u64 flags) = (void *) 156; + +/* + * bpf_task_storage_delete + * + * Delete a bpf_local_storage from a *task*. + * + * Returns + * 0 on success. + * + * **-ENOENT** if the bpf_local_storage cannot be found. + */ +static long (*bpf_task_storage_delete)(void *map, struct task_struct *task) = (void *) 157; + +/* + * bpf_get_current_task_btf + * + * Return a BTF pointer to the "current" task. + * This pointer can also be used in helpers that accept an + * *ARG_PTR_TO_BTF_ID* of type *task_struct*. + * + * Returns + * Pointer to the current task. + */ +static struct task_struct *(*bpf_get_current_task_btf)(void) = (void *) 158; + +/* + * bpf_bprm_opts_set + * + * Set or clear certain options on *bprm*: + * + * **BPF_F_BPRM_SECUREEXEC** Set the secureexec bit + * which sets the **AT_SECURE** auxv for glibc. The bit + * is cleared if the flag is not specified. + * + * Returns + * **-EINVAL** if invalid *flags* are passed, zero otherwise. + */ +static long (*bpf_bprm_opts_set)(struct linux_binprm *bprm, __u64 flags) = (void *) 159; + +/* + * bpf_ktime_get_coarse_ns + * + * Return a coarse-grained version of the time elapsed since + * system boot, in nanoseconds. Does not include time the system + * was suspended. + * + * See: **clock_gettime**\ (**CLOCK_MONOTONIC_COARSE**) + * + * Returns + * Current *ktime*. + */ +static __u64 (*bpf_ktime_get_coarse_ns)(void) = (void *) 160; + +/* + * bpf_ima_inode_hash + * + * Returns the stored IMA hash of the *inode* (if it's avaialable). + * If the hash is larger than *size*, then only *size* + * bytes will be copied to *dst* + * + * Returns + * The **hash_algo** is returned on success, + * **-EOPNOTSUP** if IMA is disabled or **-EINVAL** if + * invalid arguments are passed. + */ +static long (*bpf_ima_inode_hash)(struct inode *inode, void *dst, __u32 size) = (void *) 161; + +/* + * bpf_sock_from_file + * + * If the given file represents a socket, returns the associated + * socket. + * + * Returns + * A pointer to a struct socket on success or NULL if the file is + * not a socket. + */ +static struct socket *(*bpf_sock_from_file)(struct file *file) = (void *) 162; + +/* + * bpf_check_mtu + * + * Check ctx packet size against exceeding MTU of net device (based + * on *ifindex*). This helper will likely be used in combination + * with helpers that adjust/change the packet size. + * + * The argument *len_diff* can be used for querying with a planned + * size change. This allows to check MTU prior to changing packet + * ctx. Providing an *len_diff* adjustment that is larger than the + * actual packet size (resulting in negative packet size) will in + * principle not exceed the MTU, why it is not considered a + * failure. Other BPF-helpers are needed for performing the + * planned size change, why the responsability for catch a negative + * packet size belong in those helpers. + * + * Specifying *ifindex* zero means the MTU check is performed + * against the current net device. This is practical if this isn't + * used prior to redirect. + * + * The Linux kernel route table can configure MTUs on a more + * specific per route level, which is not provided by this helper. + * For route level MTU checks use the **bpf_fib_lookup**\ () + * helper. + * + * *ctx* is either **struct xdp_md** for XDP programs or + * **struct sk_buff** for tc cls_act programs. + * + * The *flags* argument can be a combination of one or more of the + * following values: + * + * **BPF_MTU_CHK_SEGS** + * This flag will only works for *ctx* **struct sk_buff**. + * If packet context contains extra packet segment buffers + * (often knows as GSO skb), then MTU check is harder to + * check at this point, because in transmit path it is + * possible for the skb packet to get re-segmented + * (depending on net device features). This could still be + * a MTU violation, so this flag enables performing MTU + * check against segments, with a different violation + * return code to tell it apart. Check cannot use len_diff. + * + * On return *mtu_len* pointer contains the MTU value of the net + * device. Remember the net device configured MTU is the L3 size, + * which is returned here and XDP and TX length operate at L2. + * Helper take this into account for you, but remember when using + * MTU value in your BPF-code. On input *mtu_len* must be a valid + * pointer and be initialized (to zero), else verifier will reject + * BPF program. + * + * + * Returns + * * 0 on success, and populate MTU value in *mtu_len* pointer. + * + * * < 0 if any input argument is invalid (*mtu_len* not updated) + * + * MTU violations return positive values, but also populate MTU + * value in *mtu_len* pointer, as this can be needed for + * implementing PMTU handing: + * + * * **BPF_MTU_CHK_RET_FRAG_NEEDED** + * * **BPF_MTU_CHK_RET_SEGS_TOOBIG** + */ +static long (*bpf_check_mtu)(void *ctx, __u32 ifindex, __u32 *mtu_len, __s32 len_diff, __u64 flags) = (void *) 163; + +/* + * bpf_for_each_map_elem + * + * For each element in **map**, call **callback_fn** function with + * **map**, **callback_ctx** and other map-specific parameters. + * The **callback_fn** should be a static function and + * the **callback_ctx** should be a pointer to the stack. + * The **flags** is used to control certain aspects of the helper. + * Currently, the **flags** must be 0. + * + * The following are a list of supported map types and their + * respective expected callback signatures: + * + * BPF_MAP_TYPE_HASH, BPF_MAP_TYPE_PERCPU_HASH, + * BPF_MAP_TYPE_LRU_HASH, BPF_MAP_TYPE_LRU_PERCPU_HASH, + * BPF_MAP_TYPE_ARRAY, BPF_MAP_TYPE_PERCPU_ARRAY + * + * long (\*callback_fn)(struct bpf_map \*map, const void \*key, void \*value, void \*ctx); + * + * For per_cpu maps, the map_value is the value on the cpu where the + * bpf_prog is running. + * + * If **callback_fn** return 0, the helper will continue to the next + * element. If return value is 1, the helper will skip the rest of + * elements and return. Other return values are not used now. + * + * + * Returns + * The number of traversed map elements for success, **-EINVAL** for + * invalid **flags**. + */ +static long (*bpf_for_each_map_elem)(void *map, void *callback_fn, void *callback_ctx, __u64 flags) = (void *) 164; + + diff -Nru dwarves-dfsg-1.10/lib/bpf/src/bpf_helpers.h dwarves-dfsg-1.21/lib/bpf/src/bpf_helpers.h --- dwarves-dfsg-1.10/lib/bpf/src/bpf_helpers.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/bpf_helpers.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,131 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ +#ifndef __BPF_HELPERS__ +#define __BPF_HELPERS__ + +/* + * Note that bpf programs need to include either + * vmlinux.h (auto-generated from BTF) or linux/types.h + * in advance since bpf_helper_defs.h uses such types + * as __u64. + */ +#include "bpf_helper_defs.h" + +#define __uint(name, val) int (*name)[val] +#define __type(name, val) typeof(val) *name +#define __array(name, val) typeof(val) *name[] + +/* Helper macro to print out debug messages */ +#define bpf_printk(fmt, ...) \ +({ \ + char ____fmt[] = fmt; \ + bpf_trace_printk(____fmt, sizeof(____fmt), \ + ##__VA_ARGS__); \ +}) + +/* + * Helper macro to place programs, maps, license in + * different sections in elf_bpf file. Section names + * are interpreted by elf_bpf loader + */ +#define SEC(NAME) __attribute__((section(NAME), used)) + +#ifndef __always_inline +#define __always_inline inline __attribute__((always_inline)) +#endif +#ifndef __noinline +#define __noinline __attribute__((noinline)) +#endif +#ifndef __weak +#define __weak __attribute__((weak)) +#endif + +/* + * Helper macro to manipulate data structures + */ +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((unsigned long)&((TYPE *)0)->MEMBER) +#endif +#ifndef container_of +#define container_of(ptr, type, member) \ + ({ \ + void *__mptr = (void *)(ptr); \ + ((type *)(__mptr - offsetof(type, member))); \ + }) +#endif + +/* + * Helper macro to throw a compilation error if __bpf_unreachable() gets + * built into the resulting code. This works given BPF back end does not + * implement __builtin_trap(). This is useful to assert that certain paths + * of the program code are never used and hence eliminated by the compiler. + * + * For example, consider a switch statement that covers known cases used by + * the program. __bpf_unreachable() can then reside in the default case. If + * the program gets extended such that a case is not covered in the switch + * statement, then it will throw a build error due to the default case not + * being compiled out. + */ +#ifndef __bpf_unreachable +# define __bpf_unreachable() __builtin_trap() +#endif + +/* + * Helper function to perform a tail call with a constant/immediate map slot. + */ +#if __clang_major__ >= 8 && defined(__bpf__) +static __always_inline void +bpf_tail_call_static(void *ctx, const void *map, const __u32 slot) +{ + if (!__builtin_constant_p(slot)) + __bpf_unreachable(); + + /* + * Provide a hard guarantee that LLVM won't optimize setting r2 (map + * pointer) and r3 (constant map index) from _different paths_ ending + * up at the _same_ call insn as otherwise we won't be able to use the + * jmpq/nopl retpoline-free patching by the x86-64 JIT in the kernel + * given they mismatch. See also d2e4c1e6c294 ("bpf: Constant map key + * tracking for prog array pokes") for details on verifier tracking. + * + * Note on clobber list: we need to stay in-line with BPF calling + * convention, so even if we don't end up using r0, r4, r5, we need + * to mark them as clobber so that LLVM doesn't end up using them + * before / after the call. + */ + asm volatile("r1 = %[ctx]\n\t" + "r2 = %[map]\n\t" + "r3 = %[slot]\n\t" + "call 12" + :: [ctx]"r"(ctx), [map]"r"(map), [slot]"i"(slot) + : "r0", "r1", "r2", "r3", "r4", "r5"); +} +#endif + +/* + * Helper structure used by eBPF C program + * to describe BPF map attributes to libbpf loader + */ +struct bpf_map_def { + unsigned int type; + unsigned int key_size; + unsigned int value_size; + unsigned int max_entries; + unsigned int map_flags; +}; + +enum libbpf_pin_type { + LIBBPF_PIN_NONE, + /* PIN_BY_NAME: pin maps by name (in /sys/fs/bpf by default) */ + LIBBPF_PIN_BY_NAME, +}; + +enum libbpf_tristate { + TRI_NO = 0, + TRI_YES = 1, + TRI_MODULE = 2, +}; + +#define __kconfig __attribute__((section(".kconfig"))) +#define __ksym __attribute__((section(".ksyms"))) + +#endif diff -Nru dwarves-dfsg-1.10/lib/bpf/src/bpf_prog_linfo.c dwarves-dfsg-1.21/lib/bpf/src/bpf_prog_linfo.c --- dwarves-dfsg-1.10/lib/bpf/src/bpf_prog_linfo.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/bpf_prog_linfo.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,246 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +/* Copyright (c) 2018 Facebook */ + +#include +#include +#include +#include +#include "libbpf.h" +#include "libbpf_internal.h" + +struct bpf_prog_linfo { + void *raw_linfo; + void *raw_jited_linfo; + __u32 *nr_jited_linfo_per_func; + __u32 *jited_linfo_func_idx; + __u32 nr_linfo; + __u32 nr_jited_func; + __u32 rec_size; + __u32 jited_rec_size; +}; + +static int dissect_jited_func(struct bpf_prog_linfo *prog_linfo, + const __u64 *ksym_func, const __u32 *ksym_len) +{ + __u32 nr_jited_func, nr_linfo; + const void *raw_jited_linfo; + const __u64 *jited_linfo; + __u64 last_jited_linfo; + /* + * Index to raw_jited_linfo: + * i: Index for searching the next ksym_func + * prev_i: Index to the last found ksym_func + */ + __u32 i, prev_i; + __u32 f; /* Index to ksym_func */ + + raw_jited_linfo = prog_linfo->raw_jited_linfo; + jited_linfo = raw_jited_linfo; + if (ksym_func[0] != *jited_linfo) + goto errout; + + prog_linfo->jited_linfo_func_idx[0] = 0; + nr_jited_func = prog_linfo->nr_jited_func; + nr_linfo = prog_linfo->nr_linfo; + + for (prev_i = 0, i = 1, f = 1; + i < nr_linfo && f < nr_jited_func; + i++) { + raw_jited_linfo += prog_linfo->jited_rec_size; + last_jited_linfo = *jited_linfo; + jited_linfo = raw_jited_linfo; + + if (ksym_func[f] == *jited_linfo) { + prog_linfo->jited_linfo_func_idx[f] = i; + + /* Sanity check */ + if (last_jited_linfo - ksym_func[f - 1] + 1 > + ksym_len[f - 1]) + goto errout; + + prog_linfo->nr_jited_linfo_per_func[f - 1] = + i - prev_i; + prev_i = i; + + /* + * The ksym_func[f] is found in jited_linfo. + * Look for the next one. + */ + f++; + } else if (*jited_linfo <= last_jited_linfo) { + /* Ensure the addr is increasing _within_ a func */ + goto errout; + } + } + + if (f != nr_jited_func) + goto errout; + + prog_linfo->nr_jited_linfo_per_func[nr_jited_func - 1] = + nr_linfo - prev_i; + + return 0; + +errout: + return -EINVAL; +} + +void bpf_prog_linfo__free(struct bpf_prog_linfo *prog_linfo) +{ + if (!prog_linfo) + return; + + free(prog_linfo->raw_linfo); + free(prog_linfo->raw_jited_linfo); + free(prog_linfo->nr_jited_linfo_per_func); + free(prog_linfo->jited_linfo_func_idx); + free(prog_linfo); +} + +struct bpf_prog_linfo *bpf_prog_linfo__new(const struct bpf_prog_info *info) +{ + struct bpf_prog_linfo *prog_linfo; + __u32 nr_linfo, nr_jited_func; + __u64 data_sz; + + nr_linfo = info->nr_line_info; + + if (!nr_linfo) + return NULL; + + /* + * The min size that bpf_prog_linfo has to access for + * searching purpose. + */ + if (info->line_info_rec_size < + offsetof(struct bpf_line_info, file_name_off)) + return NULL; + + prog_linfo = calloc(1, sizeof(*prog_linfo)); + if (!prog_linfo) + return NULL; + + /* Copy xlated line_info */ + prog_linfo->nr_linfo = nr_linfo; + prog_linfo->rec_size = info->line_info_rec_size; + data_sz = (__u64)nr_linfo * prog_linfo->rec_size; + prog_linfo->raw_linfo = malloc(data_sz); + if (!prog_linfo->raw_linfo) + goto err_free; + memcpy(prog_linfo->raw_linfo, (void *)(long)info->line_info, data_sz); + + nr_jited_func = info->nr_jited_ksyms; + if (!nr_jited_func || + !info->jited_line_info || + info->nr_jited_line_info != nr_linfo || + info->jited_line_info_rec_size < sizeof(__u64) || + info->nr_jited_func_lens != nr_jited_func || + !info->jited_ksyms || + !info->jited_func_lens) + /* Not enough info to provide jited_line_info */ + return prog_linfo; + + /* Copy jited_line_info */ + prog_linfo->nr_jited_func = nr_jited_func; + prog_linfo->jited_rec_size = info->jited_line_info_rec_size; + data_sz = (__u64)nr_linfo * prog_linfo->jited_rec_size; + prog_linfo->raw_jited_linfo = malloc(data_sz); + if (!prog_linfo->raw_jited_linfo) + goto err_free; + memcpy(prog_linfo->raw_jited_linfo, + (void *)(long)info->jited_line_info, data_sz); + + /* Number of jited_line_info per jited func */ + prog_linfo->nr_jited_linfo_per_func = malloc(nr_jited_func * + sizeof(__u32)); + if (!prog_linfo->nr_jited_linfo_per_func) + goto err_free; + + /* + * For each jited func, + * the start idx to the "linfo" and "jited_linfo" array, + */ + prog_linfo->jited_linfo_func_idx = malloc(nr_jited_func * + sizeof(__u32)); + if (!prog_linfo->jited_linfo_func_idx) + goto err_free; + + if (dissect_jited_func(prog_linfo, + (__u64 *)(long)info->jited_ksyms, + (__u32 *)(long)info->jited_func_lens)) + goto err_free; + + return prog_linfo; + +err_free: + bpf_prog_linfo__free(prog_linfo); + return NULL; +} + +const struct bpf_line_info * +bpf_prog_linfo__lfind_addr_func(const struct bpf_prog_linfo *prog_linfo, + __u64 addr, __u32 func_idx, __u32 nr_skip) +{ + __u32 jited_rec_size, rec_size, nr_linfo, start, i; + const void *raw_jited_linfo, *raw_linfo; + const __u64 *jited_linfo; + + if (func_idx >= prog_linfo->nr_jited_func) + return NULL; + + nr_linfo = prog_linfo->nr_jited_linfo_per_func[func_idx]; + if (nr_skip >= nr_linfo) + return NULL; + + start = prog_linfo->jited_linfo_func_idx[func_idx] + nr_skip; + jited_rec_size = prog_linfo->jited_rec_size; + raw_jited_linfo = prog_linfo->raw_jited_linfo + + (start * jited_rec_size); + jited_linfo = raw_jited_linfo; + if (addr < *jited_linfo) + return NULL; + + nr_linfo -= nr_skip; + rec_size = prog_linfo->rec_size; + raw_linfo = prog_linfo->raw_linfo + (start * rec_size); + for (i = 0; i < nr_linfo; i++) { + if (addr < *jited_linfo) + break; + + raw_linfo += rec_size; + raw_jited_linfo += jited_rec_size; + jited_linfo = raw_jited_linfo; + } + + return raw_linfo - rec_size; +} + +const struct bpf_line_info * +bpf_prog_linfo__lfind(const struct bpf_prog_linfo *prog_linfo, + __u32 insn_off, __u32 nr_skip) +{ + const struct bpf_line_info *linfo; + __u32 rec_size, nr_linfo, i; + const void *raw_linfo; + + nr_linfo = prog_linfo->nr_linfo; + if (nr_skip >= nr_linfo) + return NULL; + + rec_size = prog_linfo->rec_size; + raw_linfo = prog_linfo->raw_linfo + (nr_skip * rec_size); + linfo = raw_linfo; + if (insn_off < linfo->insn_off) + return NULL; + + nr_linfo -= nr_skip; + for (i = 0; i < nr_linfo; i++) { + if (insn_off < linfo->insn_off) + break; + + raw_linfo += rec_size; + linfo = raw_linfo; + } + + return raw_linfo - rec_size; +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/bpf_tracing.h dwarves-dfsg-1.21/lib/bpf/src/bpf_tracing.h --- dwarves-dfsg-1.10/lib/bpf/src/bpf_tracing.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/bpf_tracing.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,432 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ +#ifndef __BPF_TRACING_H__ +#define __BPF_TRACING_H__ + +/* Scan the ARCH passed in from ARCH env variable (see Makefile) */ +#if defined(__TARGET_ARCH_x86) + #define bpf_target_x86 + #define bpf_target_defined +#elif defined(__TARGET_ARCH_s390) + #define bpf_target_s390 + #define bpf_target_defined +#elif defined(__TARGET_ARCH_arm) + #define bpf_target_arm + #define bpf_target_defined +#elif defined(__TARGET_ARCH_arm64) + #define bpf_target_arm64 + #define bpf_target_defined +#elif defined(__TARGET_ARCH_mips) + #define bpf_target_mips + #define bpf_target_defined +#elif defined(__TARGET_ARCH_powerpc) + #define bpf_target_powerpc + #define bpf_target_defined +#elif defined(__TARGET_ARCH_sparc) + #define bpf_target_sparc + #define bpf_target_defined +#else + #undef bpf_target_defined +#endif + +/* Fall back to what the compiler says */ +#ifndef bpf_target_defined +#if defined(__x86_64__) + #define bpf_target_x86 +#elif defined(__s390__) + #define bpf_target_s390 +#elif defined(__arm__) + #define bpf_target_arm +#elif defined(__aarch64__) + #define bpf_target_arm64 +#elif defined(__mips__) + #define bpf_target_mips +#elif defined(__powerpc__) + #define bpf_target_powerpc +#elif defined(__sparc__) + #define bpf_target_sparc +#endif +#endif + +#if defined(bpf_target_x86) + +#if defined(__KERNEL__) || defined(__VMLINUX_H__) + +#define PT_REGS_PARM1(x) ((x)->di) +#define PT_REGS_PARM2(x) ((x)->si) +#define PT_REGS_PARM3(x) ((x)->dx) +#define PT_REGS_PARM4(x) ((x)->cx) +#define PT_REGS_PARM5(x) ((x)->r8) +#define PT_REGS_RET(x) ((x)->sp) +#define PT_REGS_FP(x) ((x)->bp) +#define PT_REGS_RC(x) ((x)->ax) +#define PT_REGS_SP(x) ((x)->sp) +#define PT_REGS_IP(x) ((x)->ip) + +#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((x), di) +#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((x), si) +#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((x), dx) +#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((x), cx) +#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((x), r8) +#define PT_REGS_RET_CORE(x) BPF_CORE_READ((x), sp) +#define PT_REGS_FP_CORE(x) BPF_CORE_READ((x), bp) +#define PT_REGS_RC_CORE(x) BPF_CORE_READ((x), ax) +#define PT_REGS_SP_CORE(x) BPF_CORE_READ((x), sp) +#define PT_REGS_IP_CORE(x) BPF_CORE_READ((x), ip) + +#else + +#ifdef __i386__ +/* i386 kernel is built with -mregparm=3 */ +#define PT_REGS_PARM1(x) ((x)->eax) +#define PT_REGS_PARM2(x) ((x)->edx) +#define PT_REGS_PARM3(x) ((x)->ecx) +#define PT_REGS_PARM4(x) 0 +#define PT_REGS_PARM5(x) 0 +#define PT_REGS_RET(x) ((x)->esp) +#define PT_REGS_FP(x) ((x)->ebp) +#define PT_REGS_RC(x) ((x)->eax) +#define PT_REGS_SP(x) ((x)->esp) +#define PT_REGS_IP(x) ((x)->eip) + +#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((x), eax) +#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((x), edx) +#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((x), ecx) +#define PT_REGS_PARM4_CORE(x) 0 +#define PT_REGS_PARM5_CORE(x) 0 +#define PT_REGS_RET_CORE(x) BPF_CORE_READ((x), esp) +#define PT_REGS_FP_CORE(x) BPF_CORE_READ((x), ebp) +#define PT_REGS_RC_CORE(x) BPF_CORE_READ((x), eax) +#define PT_REGS_SP_CORE(x) BPF_CORE_READ((x), esp) +#define PT_REGS_IP_CORE(x) BPF_CORE_READ((x), eip) + +#else + +#define PT_REGS_PARM1(x) ((x)->rdi) +#define PT_REGS_PARM2(x) ((x)->rsi) +#define PT_REGS_PARM3(x) ((x)->rdx) +#define PT_REGS_PARM4(x) ((x)->rcx) +#define PT_REGS_PARM5(x) ((x)->r8) +#define PT_REGS_RET(x) ((x)->rsp) +#define PT_REGS_FP(x) ((x)->rbp) +#define PT_REGS_RC(x) ((x)->rax) +#define PT_REGS_SP(x) ((x)->rsp) +#define PT_REGS_IP(x) ((x)->rip) + +#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((x), rdi) +#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((x), rsi) +#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((x), rdx) +#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((x), rcx) +#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((x), r8) +#define PT_REGS_RET_CORE(x) BPF_CORE_READ((x), rsp) +#define PT_REGS_FP_CORE(x) BPF_CORE_READ((x), rbp) +#define PT_REGS_RC_CORE(x) BPF_CORE_READ((x), rax) +#define PT_REGS_SP_CORE(x) BPF_CORE_READ((x), rsp) +#define PT_REGS_IP_CORE(x) BPF_CORE_READ((x), rip) + +#endif +#endif + +#elif defined(bpf_target_s390) + +/* s390 provides user_pt_regs instead of struct pt_regs to userspace */ +struct pt_regs; +#define PT_REGS_S390 const volatile user_pt_regs +#define PT_REGS_PARM1(x) (((PT_REGS_S390 *)(x))->gprs[2]) +#define PT_REGS_PARM2(x) (((PT_REGS_S390 *)(x))->gprs[3]) +#define PT_REGS_PARM3(x) (((PT_REGS_S390 *)(x))->gprs[4]) +#define PT_REGS_PARM4(x) (((PT_REGS_S390 *)(x))->gprs[5]) +#define PT_REGS_PARM5(x) (((PT_REGS_S390 *)(x))->gprs[6]) +#define PT_REGS_RET(x) (((PT_REGS_S390 *)(x))->gprs[14]) +/* Works only with CONFIG_FRAME_POINTER */ +#define PT_REGS_FP(x) (((PT_REGS_S390 *)(x))->gprs[11]) +#define PT_REGS_RC(x) (((PT_REGS_S390 *)(x))->gprs[2]) +#define PT_REGS_SP(x) (((PT_REGS_S390 *)(x))->gprs[15]) +#define PT_REGS_IP(x) (((PT_REGS_S390 *)(x))->psw.addr) + +#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[2]) +#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[3]) +#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[4]) +#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[5]) +#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[6]) +#define PT_REGS_RET_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[14]) +#define PT_REGS_FP_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[11]) +#define PT_REGS_RC_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[2]) +#define PT_REGS_SP_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[15]) +#define PT_REGS_IP_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), psw.addr) + +#elif defined(bpf_target_arm) + +#define PT_REGS_PARM1(x) ((x)->uregs[0]) +#define PT_REGS_PARM2(x) ((x)->uregs[1]) +#define PT_REGS_PARM3(x) ((x)->uregs[2]) +#define PT_REGS_PARM4(x) ((x)->uregs[3]) +#define PT_REGS_PARM5(x) ((x)->uregs[4]) +#define PT_REGS_RET(x) ((x)->uregs[14]) +#define PT_REGS_FP(x) ((x)->uregs[11]) /* Works only with CONFIG_FRAME_POINTER */ +#define PT_REGS_RC(x) ((x)->uregs[0]) +#define PT_REGS_SP(x) ((x)->uregs[13]) +#define PT_REGS_IP(x) ((x)->uregs[12]) + +#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((x), uregs[0]) +#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((x), uregs[1]) +#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((x), uregs[2]) +#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((x), uregs[3]) +#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((x), uregs[4]) +#define PT_REGS_RET_CORE(x) BPF_CORE_READ((x), uregs[14]) +#define PT_REGS_FP_CORE(x) BPF_CORE_READ((x), uregs[11]) +#define PT_REGS_RC_CORE(x) BPF_CORE_READ((x), uregs[0]) +#define PT_REGS_SP_CORE(x) BPF_CORE_READ((x), uregs[13]) +#define PT_REGS_IP_CORE(x) BPF_CORE_READ((x), uregs[12]) + +#elif defined(bpf_target_arm64) + +/* arm64 provides struct user_pt_regs instead of struct pt_regs to userspace */ +struct pt_regs; +#define PT_REGS_ARM64 const volatile struct user_pt_regs +#define PT_REGS_PARM1(x) (((PT_REGS_ARM64 *)(x))->regs[0]) +#define PT_REGS_PARM2(x) (((PT_REGS_ARM64 *)(x))->regs[1]) +#define PT_REGS_PARM3(x) (((PT_REGS_ARM64 *)(x))->regs[2]) +#define PT_REGS_PARM4(x) (((PT_REGS_ARM64 *)(x))->regs[3]) +#define PT_REGS_PARM5(x) (((PT_REGS_ARM64 *)(x))->regs[4]) +#define PT_REGS_RET(x) (((PT_REGS_ARM64 *)(x))->regs[30]) +/* Works only with CONFIG_FRAME_POINTER */ +#define PT_REGS_FP(x) (((PT_REGS_ARM64 *)(x))->regs[29]) +#define PT_REGS_RC(x) (((PT_REGS_ARM64 *)(x))->regs[0]) +#define PT_REGS_SP(x) (((PT_REGS_ARM64 *)(x))->sp) +#define PT_REGS_IP(x) (((PT_REGS_ARM64 *)(x))->pc) + +#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((PT_REGS_ARM64 *)(x), regs[0]) +#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((PT_REGS_ARM64 *)(x), regs[1]) +#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((PT_REGS_ARM64 *)(x), regs[2]) +#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((PT_REGS_ARM64 *)(x), regs[3]) +#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((PT_REGS_ARM64 *)(x), regs[4]) +#define PT_REGS_RET_CORE(x) BPF_CORE_READ((PT_REGS_ARM64 *)(x), regs[30]) +#define PT_REGS_FP_CORE(x) BPF_CORE_READ((PT_REGS_ARM64 *)(x), regs[29]) +#define PT_REGS_RC_CORE(x) BPF_CORE_READ((PT_REGS_ARM64 *)(x), regs[0]) +#define PT_REGS_SP_CORE(x) BPF_CORE_READ((PT_REGS_ARM64 *)(x), sp) +#define PT_REGS_IP_CORE(x) BPF_CORE_READ((PT_REGS_ARM64 *)(x), pc) + +#elif defined(bpf_target_mips) + +#define PT_REGS_PARM1(x) ((x)->regs[4]) +#define PT_REGS_PARM2(x) ((x)->regs[5]) +#define PT_REGS_PARM3(x) ((x)->regs[6]) +#define PT_REGS_PARM4(x) ((x)->regs[7]) +#define PT_REGS_PARM5(x) ((x)->regs[8]) +#define PT_REGS_RET(x) ((x)->regs[31]) +#define PT_REGS_FP(x) ((x)->regs[30]) /* Works only with CONFIG_FRAME_POINTER */ +#define PT_REGS_RC(x) ((x)->regs[2]) +#define PT_REGS_SP(x) ((x)->regs[29]) +#define PT_REGS_IP(x) ((x)->cp0_epc) + +#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((x), regs[4]) +#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((x), regs[5]) +#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((x), regs[6]) +#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((x), regs[7]) +#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((x), regs[8]) +#define PT_REGS_RET_CORE(x) BPF_CORE_READ((x), regs[31]) +#define PT_REGS_FP_CORE(x) BPF_CORE_READ((x), regs[30]) +#define PT_REGS_RC_CORE(x) BPF_CORE_READ((x), regs[2]) +#define PT_REGS_SP_CORE(x) BPF_CORE_READ((x), regs[29]) +#define PT_REGS_IP_CORE(x) BPF_CORE_READ((x), cp0_epc) + +#elif defined(bpf_target_powerpc) + +#define PT_REGS_PARM1(x) ((x)->gpr[3]) +#define PT_REGS_PARM2(x) ((x)->gpr[4]) +#define PT_REGS_PARM3(x) ((x)->gpr[5]) +#define PT_REGS_PARM4(x) ((x)->gpr[6]) +#define PT_REGS_PARM5(x) ((x)->gpr[7]) +#define PT_REGS_RC(x) ((x)->gpr[3]) +#define PT_REGS_SP(x) ((x)->sp) +#define PT_REGS_IP(x) ((x)->nip) + +#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((x), gpr[3]) +#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((x), gpr[4]) +#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((x), gpr[5]) +#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((x), gpr[6]) +#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((x), gpr[7]) +#define PT_REGS_RC_CORE(x) BPF_CORE_READ((x), gpr[3]) +#define PT_REGS_SP_CORE(x) BPF_CORE_READ((x), sp) +#define PT_REGS_IP_CORE(x) BPF_CORE_READ((x), nip) + +#elif defined(bpf_target_sparc) + +#define PT_REGS_PARM1(x) ((x)->u_regs[UREG_I0]) +#define PT_REGS_PARM2(x) ((x)->u_regs[UREG_I1]) +#define PT_REGS_PARM3(x) ((x)->u_regs[UREG_I2]) +#define PT_REGS_PARM4(x) ((x)->u_regs[UREG_I3]) +#define PT_REGS_PARM5(x) ((x)->u_regs[UREG_I4]) +#define PT_REGS_RET(x) ((x)->u_regs[UREG_I7]) +#define PT_REGS_RC(x) ((x)->u_regs[UREG_I0]) +#define PT_REGS_SP(x) ((x)->u_regs[UREG_FP]) + +#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((x), u_regs[UREG_I0]) +#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((x), u_regs[UREG_I1]) +#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((x), u_regs[UREG_I2]) +#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((x), u_regs[UREG_I3]) +#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((x), u_regs[UREG_I4]) +#define PT_REGS_RET_CORE(x) BPF_CORE_READ((x), u_regs[UREG_I7]) +#define PT_REGS_RC_CORE(x) BPF_CORE_READ((x), u_regs[UREG_I0]) +#define PT_REGS_SP_CORE(x) BPF_CORE_READ((x), u_regs[UREG_FP]) + +/* Should this also be a bpf_target check for the sparc case? */ +#if defined(__arch64__) +#define PT_REGS_IP(x) ((x)->tpc) +#define PT_REGS_IP_CORE(x) BPF_CORE_READ((x), tpc) +#else +#define PT_REGS_IP(x) ((x)->pc) +#define PT_REGS_IP_CORE(x) BPF_CORE_READ((x), pc) +#endif + +#endif + +#if defined(bpf_target_powerpc) +#define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ (ip) = (ctx)->link; }) +#define BPF_KRETPROBE_READ_RET_IP BPF_KPROBE_READ_RET_IP +#elif defined(bpf_target_sparc) +#define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ (ip) = PT_REGS_RET(ctx); }) +#define BPF_KRETPROBE_READ_RET_IP BPF_KPROBE_READ_RET_IP +#else +#define BPF_KPROBE_READ_RET_IP(ip, ctx) \ + ({ bpf_probe_read_kernel(&(ip), sizeof(ip), (void *)PT_REGS_RET(ctx)); }) +#define BPF_KRETPROBE_READ_RET_IP(ip, ctx) \ + ({ bpf_probe_read_kernel(&(ip), sizeof(ip), \ + (void *)(PT_REGS_FP(ctx) + sizeof(ip))); }) +#endif + +#define ___bpf_concat(a, b) a ## b +#define ___bpf_apply(fn, n) ___bpf_concat(fn, n) +#define ___bpf_nth(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _a, _b, _c, N, ...) N +#define ___bpf_narg(...) \ + ___bpf_nth(_, ##__VA_ARGS__, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) +#define ___bpf_empty(...) \ + ___bpf_nth(_, ##__VA_ARGS__, N, N, N, N, N, N, N, N, N, N, 0) + +#define ___bpf_ctx_cast0() ctx +#define ___bpf_ctx_cast1(x) ___bpf_ctx_cast0(), (void *)ctx[0] +#define ___bpf_ctx_cast2(x, args...) ___bpf_ctx_cast1(args), (void *)ctx[1] +#define ___bpf_ctx_cast3(x, args...) ___bpf_ctx_cast2(args), (void *)ctx[2] +#define ___bpf_ctx_cast4(x, args...) ___bpf_ctx_cast3(args), (void *)ctx[3] +#define ___bpf_ctx_cast5(x, args...) ___bpf_ctx_cast4(args), (void *)ctx[4] +#define ___bpf_ctx_cast6(x, args...) ___bpf_ctx_cast5(args), (void *)ctx[5] +#define ___bpf_ctx_cast7(x, args...) ___bpf_ctx_cast6(args), (void *)ctx[6] +#define ___bpf_ctx_cast8(x, args...) ___bpf_ctx_cast7(args), (void *)ctx[7] +#define ___bpf_ctx_cast9(x, args...) ___bpf_ctx_cast8(args), (void *)ctx[8] +#define ___bpf_ctx_cast10(x, args...) ___bpf_ctx_cast9(args), (void *)ctx[9] +#define ___bpf_ctx_cast11(x, args...) ___bpf_ctx_cast10(args), (void *)ctx[10] +#define ___bpf_ctx_cast12(x, args...) ___bpf_ctx_cast11(args), (void *)ctx[11] +#define ___bpf_ctx_cast(args...) \ + ___bpf_apply(___bpf_ctx_cast, ___bpf_narg(args))(args) + +/* + * BPF_PROG is a convenience wrapper for generic tp_btf/fentry/fexit and + * similar kinds of BPF programs, that accept input arguments as a single + * pointer to untyped u64 array, where each u64 can actually be a typed + * pointer or integer of different size. Instead of requring user to write + * manual casts and work with array elements by index, BPF_PROG macro + * allows user to declare a list of named and typed input arguments in the + * same syntax as for normal C function. All the casting is hidden and + * performed transparently, while user code can just assume working with + * function arguments of specified type and name. + * + * Original raw context argument is preserved as well as 'ctx' argument. + * This is useful when using BPF helpers that expect original context + * as one of the parameters (e.g., for bpf_perf_event_output()). + */ +#define BPF_PROG(name, args...) \ +name(unsigned long long *ctx); \ +static __attribute__((always_inline)) typeof(name(0)) \ +____##name(unsigned long long *ctx, ##args); \ +typeof(name(0)) name(unsigned long long *ctx) \ +{ \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ + return ____##name(___bpf_ctx_cast(args)); \ + _Pragma("GCC diagnostic pop") \ +} \ +static __attribute__((always_inline)) typeof(name(0)) \ +____##name(unsigned long long *ctx, ##args) + +struct pt_regs; + +#define ___bpf_kprobe_args0() ctx +#define ___bpf_kprobe_args1(x) \ + ___bpf_kprobe_args0(), (void *)PT_REGS_PARM1(ctx) +#define ___bpf_kprobe_args2(x, args...) \ + ___bpf_kprobe_args1(args), (void *)PT_REGS_PARM2(ctx) +#define ___bpf_kprobe_args3(x, args...) \ + ___bpf_kprobe_args2(args), (void *)PT_REGS_PARM3(ctx) +#define ___bpf_kprobe_args4(x, args...) \ + ___bpf_kprobe_args3(args), (void *)PT_REGS_PARM4(ctx) +#define ___bpf_kprobe_args5(x, args...) \ + ___bpf_kprobe_args4(args), (void *)PT_REGS_PARM5(ctx) +#define ___bpf_kprobe_args(args...) \ + ___bpf_apply(___bpf_kprobe_args, ___bpf_narg(args))(args) + +/* + * BPF_KPROBE serves the same purpose for kprobes as BPF_PROG for + * tp_btf/fentry/fexit BPF programs. It hides the underlying platform-specific + * low-level way of getting kprobe input arguments from struct pt_regs, and + * provides a familiar typed and named function arguments syntax and + * semantics of accessing kprobe input paremeters. + * + * Original struct pt_regs* context is preserved as 'ctx' argument. This might + * be necessary when using BPF helpers like bpf_perf_event_output(). + */ +#define BPF_KPROBE(name, args...) \ +name(struct pt_regs *ctx); \ +static __attribute__((always_inline)) typeof(name(0)) \ +____##name(struct pt_regs *ctx, ##args); \ +typeof(name(0)) name(struct pt_regs *ctx) \ +{ \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ + return ____##name(___bpf_kprobe_args(args)); \ + _Pragma("GCC diagnostic pop") \ +} \ +static __attribute__((always_inline)) typeof(name(0)) \ +____##name(struct pt_regs *ctx, ##args) + +#define ___bpf_kretprobe_args0() ctx +#define ___bpf_kretprobe_args1(x) \ + ___bpf_kretprobe_args0(), (void *)PT_REGS_RC(ctx) +#define ___bpf_kretprobe_args(args...) \ + ___bpf_apply(___bpf_kretprobe_args, ___bpf_narg(args))(args) + +/* + * BPF_KRETPROBE is similar to BPF_KPROBE, except, it only provides optional + * return value (in addition to `struct pt_regs *ctx`), but no input + * arguments, because they will be clobbered by the time probed function + * returns. + */ +#define BPF_KRETPROBE(name, args...) \ +name(struct pt_regs *ctx); \ +static __attribute__((always_inline)) typeof(name(0)) \ +____##name(struct pt_regs *ctx, ##args); \ +typeof(name(0)) name(struct pt_regs *ctx) \ +{ \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ + return ____##name(___bpf_kretprobe_args(args)); \ + _Pragma("GCC diagnostic pop") \ +} \ +static __always_inline typeof(name(0)) ____##name(struct pt_regs *ctx, ##args) + +/* + * BPF_SEQ_PRINTF to wrap bpf_seq_printf to-be-printed values + * in a structure. + */ +#define BPF_SEQ_PRINTF(seq, fmt, args...) \ + ({ \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ + static const char ___fmt[] = fmt; \ + unsigned long long ___param[] = { args }; \ + _Pragma("GCC diagnostic pop") \ + int ___ret = bpf_seq_printf(seq, ___fmt, sizeof(___fmt), \ + ___param, sizeof(___param)); \ + ___ret; \ + }) + +#endif diff -Nru dwarves-dfsg-1.10/lib/bpf/src/btf.c dwarves-dfsg-1.21/lib/bpf/src/btf.c --- dwarves-dfsg-1.10/lib/bpf/src/btf.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/btf.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,4677 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +/* Copyright (c) 2018 Facebook */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "btf.h" +#include "bpf.h" +#include "libbpf.h" +#include "libbpf_internal.h" +#include "hashmap.h" + +#define BTF_MAX_NR_TYPES 0x7fffffffU +#define BTF_MAX_STR_OFFSET 0x7fffffffU + +static struct btf_type btf_void; + +struct btf { + /* raw BTF data in native endianness */ + void *raw_data; + /* raw BTF data in non-native endianness */ + void *raw_data_swapped; + __u32 raw_size; + /* whether target endianness differs from the native one */ + bool swapped_endian; + + /* + * When BTF is loaded from an ELF or raw memory it is stored + * in a contiguous memory block. The hdr, type_data, and, strs_data + * point inside that memory region to their respective parts of BTF + * representation: + * + * +--------------------------------+ + * | Header | Types | Strings | + * +--------------------------------+ + * ^ ^ ^ + * | | | + * hdr | | + * types_data-+ | + * strs_data------------+ + * + * If BTF data is later modified, e.g., due to types added or + * removed, BTF deduplication performed, etc, this contiguous + * representation is broken up into three independently allocated + * memory regions to be able to modify them independently. + * raw_data is nulled out at that point, but can be later allocated + * and cached again if user calls btf__get_raw_data(), at which point + * raw_data will contain a contiguous copy of header, types, and + * strings: + * + * +----------+ +---------+ +-----------+ + * | Header | | Types | | Strings | + * +----------+ +---------+ +-----------+ + * ^ ^ ^ + * | | | + * hdr | | + * types_data----+ | + * strs_data------------------+ + * + * +----------+---------+-----------+ + * | Header | Types | Strings | + * raw_data----->+----------+---------+-----------+ + */ + struct btf_header *hdr; + + void *types_data; + size_t types_data_cap; /* used size stored in hdr->type_len */ + + /* type ID to `struct btf_type *` lookup index + * type_offs[0] corresponds to the first non-VOID type: + * - for base BTF it's type [1]; + * - for split BTF it's the first non-base BTF type. + */ + __u32 *type_offs; + size_t type_offs_cap; + /* number of types in this BTF instance: + * - doesn't include special [0] void type; + * - for split BTF counts number of types added on top of base BTF. + */ + __u32 nr_types; + /* if not NULL, points to the base BTF on top of which the current + * split BTF is based + */ + struct btf *base_btf; + /* BTF type ID of the first type in this BTF instance: + * - for base BTF it's equal to 1; + * - for split BTF it's equal to biggest type ID of base BTF plus 1. + */ + int start_id; + /* logical string offset of this BTF instance: + * - for base BTF it's equal to 0; + * - for split BTF it's equal to total size of base BTF's string section size. + */ + int start_str_off; + + void *strs_data; + size_t strs_data_cap; /* used size stored in hdr->str_len */ + + /* lookup index for each unique string in strings section */ + struct hashmap *strs_hash; + /* whether strings are already deduplicated */ + bool strs_deduped; + /* extra indirection layer to make strings hashmap work with stable + * string offsets and ability to transparently choose between + * btf->strs_data or btf_dedup->strs_data as a source of strings. + * This is used for BTF strings dedup to transfer deduplicated strings + * data back to struct btf without re-building strings index. + */ + void **strs_data_ptr; + + /* BTF object FD, if loaded into kernel */ + int fd; + + /* Pointer size (in bytes) for a target architecture of this BTF */ + int ptr_sz; +}; + +static inline __u64 ptr_to_u64(const void *ptr) +{ + return (__u64) (unsigned long) ptr; +} + +/* Ensure given dynamically allocated memory region pointed to by *data* with + * capacity of *cap_cnt* elements each taking *elem_sz* bytes has enough + * memory to accomodate *add_cnt* new elements, assuming *cur_cnt* elements + * are already used. At most *max_cnt* elements can be ever allocated. + * If necessary, memory is reallocated and all existing data is copied over, + * new pointer to the memory region is stored at *data, new memory region + * capacity (in number of elements) is stored in *cap. + * On success, memory pointer to the beginning of unused memory is returned. + * On error, NULL is returned. + */ +void *btf_add_mem(void **data, size_t *cap_cnt, size_t elem_sz, + size_t cur_cnt, size_t max_cnt, size_t add_cnt) +{ + size_t new_cnt; + void *new_data; + + if (cur_cnt + add_cnt <= *cap_cnt) + return *data + cur_cnt * elem_sz; + + /* requested more than the set limit */ + if (cur_cnt + add_cnt > max_cnt) + return NULL; + + new_cnt = *cap_cnt; + new_cnt += new_cnt / 4; /* expand by 25% */ + if (new_cnt < 16) /* but at least 16 elements */ + new_cnt = 16; + if (new_cnt > max_cnt) /* but not exceeding a set limit */ + new_cnt = max_cnt; + if (new_cnt < cur_cnt + add_cnt) /* also ensure we have enough memory */ + new_cnt = cur_cnt + add_cnt; + + new_data = libbpf_reallocarray(*data, new_cnt, elem_sz); + if (!new_data) + return NULL; + + /* zero out newly allocated portion of memory */ + memset(new_data + (*cap_cnt) * elem_sz, 0, (new_cnt - *cap_cnt) * elem_sz); + + *data = new_data; + *cap_cnt = new_cnt; + return new_data + cur_cnt * elem_sz; +} + +/* Ensure given dynamically allocated memory region has enough allocated space + * to accommodate *need_cnt* elements of size *elem_sz* bytes each + */ +int btf_ensure_mem(void **data, size_t *cap_cnt, size_t elem_sz, size_t need_cnt) +{ + void *p; + + if (need_cnt <= *cap_cnt) + return 0; + + p = btf_add_mem(data, cap_cnt, elem_sz, *cap_cnt, SIZE_MAX, need_cnt - *cap_cnt); + if (!p) + return -ENOMEM; + + return 0; +} + +static int btf_add_type_idx_entry(struct btf *btf, __u32 type_off) +{ + __u32 *p; + + p = btf_add_mem((void **)&btf->type_offs, &btf->type_offs_cap, sizeof(__u32), + btf->nr_types, BTF_MAX_NR_TYPES, 1); + if (!p) + return -ENOMEM; + + *p = type_off; + return 0; +} + +static void btf_bswap_hdr(struct btf_header *h) +{ + h->magic = bswap_16(h->magic); + h->hdr_len = bswap_32(h->hdr_len); + h->type_off = bswap_32(h->type_off); + h->type_len = bswap_32(h->type_len); + h->str_off = bswap_32(h->str_off); + h->str_len = bswap_32(h->str_len); +} + +static int btf_parse_hdr(struct btf *btf) +{ + struct btf_header *hdr = btf->hdr; + __u32 meta_left; + + if (btf->raw_size < sizeof(struct btf_header)) { + pr_debug("BTF header not found\n"); + return -EINVAL; + } + + if (hdr->magic == bswap_16(BTF_MAGIC)) { + btf->swapped_endian = true; + if (bswap_32(hdr->hdr_len) != sizeof(struct btf_header)) { + pr_warn("Can't load BTF with non-native endianness due to unsupported header length %u\n", + bswap_32(hdr->hdr_len)); + return -ENOTSUP; + } + btf_bswap_hdr(hdr); + } else if (hdr->magic != BTF_MAGIC) { + pr_debug("Invalid BTF magic:%x\n", hdr->magic); + return -EINVAL; + } + + meta_left = btf->raw_size - sizeof(*hdr); + if (meta_left < hdr->str_off + hdr->str_len) { + pr_debug("Invalid BTF total size:%u\n", btf->raw_size); + return -EINVAL; + } + + if (hdr->type_off + hdr->type_len > hdr->str_off) { + pr_debug("Invalid BTF data sections layout: type data at %u + %u, strings data at %u + %u\n", + hdr->type_off, hdr->type_len, hdr->str_off, hdr->str_len); + return -EINVAL; + } + + if (hdr->type_off % 4) { + pr_debug("BTF type section is not aligned to 4 bytes\n"); + return -EINVAL; + } + + return 0; +} + +static int btf_parse_str_sec(struct btf *btf) +{ + const struct btf_header *hdr = btf->hdr; + const char *start = btf->strs_data; + const char *end = start + btf->hdr->str_len; + + if (btf->base_btf && hdr->str_len == 0) + return 0; + if (!hdr->str_len || hdr->str_len - 1 > BTF_MAX_STR_OFFSET || end[-1]) { + pr_debug("Invalid BTF string section\n"); + return -EINVAL; + } + if (!btf->base_btf && start[0]) { + pr_debug("Invalid BTF string section\n"); + return -EINVAL; + } + return 0; +} + +static int btf_type_size(const struct btf_type *t) +{ + const int base_size = sizeof(struct btf_type); + __u16 vlen = btf_vlen(t); + + switch (btf_kind(t)) { + case BTF_KIND_FWD: + case BTF_KIND_CONST: + case BTF_KIND_VOLATILE: + case BTF_KIND_RESTRICT: + case BTF_KIND_PTR: + case BTF_KIND_TYPEDEF: + case BTF_KIND_FUNC: + case BTF_KIND_FLOAT: + return base_size; + case BTF_KIND_INT: + return base_size + sizeof(__u32); + case BTF_KIND_ENUM: + return base_size + vlen * sizeof(struct btf_enum); + case BTF_KIND_ARRAY: + return base_size + sizeof(struct btf_array); + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: + return base_size + vlen * sizeof(struct btf_member); + case BTF_KIND_FUNC_PROTO: + return base_size + vlen * sizeof(struct btf_param); + case BTF_KIND_VAR: + return base_size + sizeof(struct btf_var); + case BTF_KIND_DATASEC: + return base_size + vlen * sizeof(struct btf_var_secinfo); + default: + pr_debug("Unsupported BTF_KIND:%u\n", btf_kind(t)); + return -EINVAL; + } +} + +static void btf_bswap_type_base(struct btf_type *t) +{ + t->name_off = bswap_32(t->name_off); + t->info = bswap_32(t->info); + t->type = bswap_32(t->type); +} + +static int btf_bswap_type_rest(struct btf_type *t) +{ + struct btf_var_secinfo *v; + struct btf_member *m; + struct btf_array *a; + struct btf_param *p; + struct btf_enum *e; + __u16 vlen = btf_vlen(t); + int i; + + switch (btf_kind(t)) { + case BTF_KIND_FWD: + case BTF_KIND_CONST: + case BTF_KIND_VOLATILE: + case BTF_KIND_RESTRICT: + case BTF_KIND_PTR: + case BTF_KIND_TYPEDEF: + case BTF_KIND_FUNC: + case BTF_KIND_FLOAT: + return 0; + case BTF_KIND_INT: + *(__u32 *)(t + 1) = bswap_32(*(__u32 *)(t + 1)); + return 0; + case BTF_KIND_ENUM: + for (i = 0, e = btf_enum(t); i < vlen; i++, e++) { + e->name_off = bswap_32(e->name_off); + e->val = bswap_32(e->val); + } + return 0; + case BTF_KIND_ARRAY: + a = btf_array(t); + a->type = bswap_32(a->type); + a->index_type = bswap_32(a->index_type); + a->nelems = bswap_32(a->nelems); + return 0; + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: + for (i = 0, m = btf_members(t); i < vlen; i++, m++) { + m->name_off = bswap_32(m->name_off); + m->type = bswap_32(m->type); + m->offset = bswap_32(m->offset); + } + return 0; + case BTF_KIND_FUNC_PROTO: + for (i = 0, p = btf_params(t); i < vlen; i++, p++) { + p->name_off = bswap_32(p->name_off); + p->type = bswap_32(p->type); + } + return 0; + case BTF_KIND_VAR: + btf_var(t)->linkage = bswap_32(btf_var(t)->linkage); + return 0; + case BTF_KIND_DATASEC: + for (i = 0, v = btf_var_secinfos(t); i < vlen; i++, v++) { + v->type = bswap_32(v->type); + v->offset = bswap_32(v->offset); + v->size = bswap_32(v->size); + } + return 0; + default: + pr_debug("Unsupported BTF_KIND:%u\n", btf_kind(t)); + return -EINVAL; + } +} + +static int btf_parse_type_sec(struct btf *btf) +{ + struct btf_header *hdr = btf->hdr; + void *next_type = btf->types_data; + void *end_type = next_type + hdr->type_len; + int err, type_size; + + while (next_type + sizeof(struct btf_type) <= end_type) { + if (btf->swapped_endian) + btf_bswap_type_base(next_type); + + type_size = btf_type_size(next_type); + if (type_size < 0) + return type_size; + if (next_type + type_size > end_type) { + pr_warn("BTF type [%d] is malformed\n", btf->start_id + btf->nr_types); + return -EINVAL; + } + + if (btf->swapped_endian && btf_bswap_type_rest(next_type)) + return -EINVAL; + + err = btf_add_type_idx_entry(btf, next_type - btf->types_data); + if (err) + return err; + + next_type += type_size; + btf->nr_types++; + } + + if (next_type != end_type) { + pr_warn("BTF types data is malformed\n"); + return -EINVAL; + } + + return 0; +} + +__u32 btf__get_nr_types(const struct btf *btf) +{ + return btf->start_id + btf->nr_types - 1; +} + +const struct btf *btf__base_btf(const struct btf *btf) +{ + return btf->base_btf; +} + +/* internal helper returning non-const pointer to a type */ +static struct btf_type *btf_type_by_id(struct btf *btf, __u32 type_id) +{ + if (type_id == 0) + return &btf_void; + if (type_id < btf->start_id) + return btf_type_by_id(btf->base_btf, type_id); + return btf->types_data + btf->type_offs[type_id - btf->start_id]; +} + +const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 type_id) +{ + if (type_id >= btf->start_id + btf->nr_types) + return NULL; + return btf_type_by_id((struct btf *)btf, type_id); +} + +static int determine_ptr_size(const struct btf *btf) +{ + const struct btf_type *t; + const char *name; + int i, n; + + if (btf->base_btf && btf->base_btf->ptr_sz > 0) + return btf->base_btf->ptr_sz; + + n = btf__get_nr_types(btf); + for (i = 1; i <= n; i++) { + t = btf__type_by_id(btf, i); + if (!btf_is_int(t)) + continue; + + name = btf__name_by_offset(btf, t->name_off); + if (!name) + continue; + + if (strcmp(name, "long int") == 0 || + strcmp(name, "long unsigned int") == 0) { + if (t->size != 4 && t->size != 8) + continue; + return t->size; + } + } + + return -1; +} + +static size_t btf_ptr_sz(const struct btf *btf) +{ + if (!btf->ptr_sz) + ((struct btf *)btf)->ptr_sz = determine_ptr_size(btf); + return btf->ptr_sz < 0 ? sizeof(void *) : btf->ptr_sz; +} + +/* Return pointer size this BTF instance assumes. The size is heuristically + * determined by looking for 'long' or 'unsigned long' integer type and + * recording its size in bytes. If BTF type information doesn't have any such + * type, this function returns 0. In the latter case, native architecture's + * pointer size is assumed, so will be either 4 or 8, depending on + * architecture that libbpf was compiled for. It's possible to override + * guessed value by using btf__set_pointer_size() API. + */ +size_t btf__pointer_size(const struct btf *btf) +{ + if (!btf->ptr_sz) + ((struct btf *)btf)->ptr_sz = determine_ptr_size(btf); + + if (btf->ptr_sz < 0) + /* not enough BTF type info to guess */ + return 0; + + return btf->ptr_sz; +} + +/* Override or set pointer size in bytes. Only values of 4 and 8 are + * supported. + */ +int btf__set_pointer_size(struct btf *btf, size_t ptr_sz) +{ + if (ptr_sz != 4 && ptr_sz != 8) + return -EINVAL; + btf->ptr_sz = ptr_sz; + return 0; +} + +static bool is_host_big_endian(void) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + return false; +#elif __BYTE_ORDER == __BIG_ENDIAN + return true; +#else +# error "Unrecognized __BYTE_ORDER__" +#endif +} + +enum btf_endianness btf__endianness(const struct btf *btf) +{ + if (is_host_big_endian()) + return btf->swapped_endian ? BTF_LITTLE_ENDIAN : BTF_BIG_ENDIAN; + else + return btf->swapped_endian ? BTF_BIG_ENDIAN : BTF_LITTLE_ENDIAN; +} + +int btf__set_endianness(struct btf *btf, enum btf_endianness endian) +{ + if (endian != BTF_LITTLE_ENDIAN && endian != BTF_BIG_ENDIAN) + return -EINVAL; + + btf->swapped_endian = is_host_big_endian() != (endian == BTF_BIG_ENDIAN); + if (!btf->swapped_endian) { + free(btf->raw_data_swapped); + btf->raw_data_swapped = NULL; + } + return 0; +} + +static bool btf_type_is_void(const struct btf_type *t) +{ + return t == &btf_void || btf_is_fwd(t); +} + +static bool btf_type_is_void_or_null(const struct btf_type *t) +{ + return !t || btf_type_is_void(t); +} + +#define MAX_RESOLVE_DEPTH 32 + +__s64 btf__resolve_size(const struct btf *btf, __u32 type_id) +{ + const struct btf_array *array; + const struct btf_type *t; + __u32 nelems = 1; + __s64 size = -1; + int i; + + t = btf__type_by_id(btf, type_id); + for (i = 0; i < MAX_RESOLVE_DEPTH && !btf_type_is_void_or_null(t); + i++) { + switch (btf_kind(t)) { + case BTF_KIND_INT: + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: + case BTF_KIND_ENUM: + case BTF_KIND_DATASEC: + case BTF_KIND_FLOAT: + size = t->size; + goto done; + case BTF_KIND_PTR: + size = btf_ptr_sz(btf); + goto done; + case BTF_KIND_TYPEDEF: + case BTF_KIND_VOLATILE: + case BTF_KIND_CONST: + case BTF_KIND_RESTRICT: + case BTF_KIND_VAR: + type_id = t->type; + break; + case BTF_KIND_ARRAY: + array = btf_array(t); + if (nelems && array->nelems > UINT32_MAX / nelems) + return -E2BIG; + nelems *= array->nelems; + type_id = array->type; + break; + default: + return -EINVAL; + } + + t = btf__type_by_id(btf, type_id); + } + +done: + if (size < 0) + return -EINVAL; + if (nelems && size > UINT32_MAX / nelems) + return -E2BIG; + + return nelems * size; +} + +int btf__align_of(const struct btf *btf, __u32 id) +{ + const struct btf_type *t = btf__type_by_id(btf, id); + __u16 kind = btf_kind(t); + + switch (kind) { + case BTF_KIND_INT: + case BTF_KIND_ENUM: + case BTF_KIND_FLOAT: + return min(btf_ptr_sz(btf), (size_t)t->size); + case BTF_KIND_PTR: + return btf_ptr_sz(btf); + case BTF_KIND_TYPEDEF: + case BTF_KIND_VOLATILE: + case BTF_KIND_CONST: + case BTF_KIND_RESTRICT: + return btf__align_of(btf, t->type); + case BTF_KIND_ARRAY: + return btf__align_of(btf, btf_array(t)->type); + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: { + const struct btf_member *m = btf_members(t); + __u16 vlen = btf_vlen(t); + int i, max_align = 1, align; + + for (i = 0; i < vlen; i++, m++) { + align = btf__align_of(btf, m->type); + if (align <= 0) + return align; + max_align = max(max_align, align); + } + + return max_align; + } + default: + pr_warn("unsupported BTF_KIND:%u\n", btf_kind(t)); + return 0; + } +} + +int btf__resolve_type(const struct btf *btf, __u32 type_id) +{ + const struct btf_type *t; + int depth = 0; + + t = btf__type_by_id(btf, type_id); + while (depth < MAX_RESOLVE_DEPTH && + !btf_type_is_void_or_null(t) && + (btf_is_mod(t) || btf_is_typedef(t) || btf_is_var(t))) { + type_id = t->type; + t = btf__type_by_id(btf, type_id); + depth++; + } + + if (depth == MAX_RESOLVE_DEPTH || btf_type_is_void_or_null(t)) + return -EINVAL; + + return type_id; +} + +__s32 btf__find_by_name(const struct btf *btf, const char *type_name) +{ + __u32 i, nr_types = btf__get_nr_types(btf); + + if (!strcmp(type_name, "void")) + return 0; + + for (i = 1; i <= nr_types; i++) { + const struct btf_type *t = btf__type_by_id(btf, i); + const char *name = btf__name_by_offset(btf, t->name_off); + + if (name && !strcmp(type_name, name)) + return i; + } + + return -ENOENT; +} + +__s32 btf__find_by_name_kind(const struct btf *btf, const char *type_name, + __u32 kind) +{ + __u32 i, nr_types = btf__get_nr_types(btf); + + if (kind == BTF_KIND_UNKN || !strcmp(type_name, "void")) + return 0; + + for (i = 1; i <= nr_types; i++) { + const struct btf_type *t = btf__type_by_id(btf, i); + const char *name; + + if (btf_kind(t) != kind) + continue; + name = btf__name_by_offset(btf, t->name_off); + if (name && !strcmp(type_name, name)) + return i; + } + + return -ENOENT; +} + +static bool btf_is_modifiable(const struct btf *btf) +{ + return (void *)btf->hdr != btf->raw_data; +} + +void btf__free(struct btf *btf) +{ + if (IS_ERR_OR_NULL(btf)) + return; + + if (btf->fd >= 0) + close(btf->fd); + + if (btf_is_modifiable(btf)) { + /* if BTF was modified after loading, it will have a split + * in-memory representation for header, types, and strings + * sections, so we need to free all of them individually. It + * might still have a cached contiguous raw data present, + * which will be unconditionally freed below. + */ + free(btf->hdr); + free(btf->types_data); + free(btf->strs_data); + } + free(btf->raw_data); + free(btf->raw_data_swapped); + free(btf->type_offs); + free(btf); +} + +static struct btf *btf_new_empty(struct btf *base_btf) +{ + struct btf *btf; + + btf = calloc(1, sizeof(*btf)); + if (!btf) + return ERR_PTR(-ENOMEM); + + btf->nr_types = 0; + btf->start_id = 1; + btf->start_str_off = 0; + btf->fd = -1; + btf->ptr_sz = sizeof(void *); + btf->swapped_endian = false; + + if (base_btf) { + btf->base_btf = base_btf; + btf->start_id = btf__get_nr_types(base_btf) + 1; + btf->start_str_off = base_btf->hdr->str_len; + } + + /* +1 for empty string at offset 0 */ + btf->raw_size = sizeof(struct btf_header) + (base_btf ? 0 : 1); + btf->raw_data = calloc(1, btf->raw_size); + if (!btf->raw_data) { + free(btf); + return ERR_PTR(-ENOMEM); + } + + btf->hdr = btf->raw_data; + btf->hdr->hdr_len = sizeof(struct btf_header); + btf->hdr->magic = BTF_MAGIC; + btf->hdr->version = BTF_VERSION; + + btf->types_data = btf->raw_data + btf->hdr->hdr_len; + btf->strs_data = btf->raw_data + btf->hdr->hdr_len; + btf->hdr->str_len = base_btf ? 0 : 1; /* empty string at offset 0 */ + + return btf; +} + +struct btf *btf__new_empty(void) +{ + return btf_new_empty(NULL); +} + +struct btf *btf__new_empty_split(struct btf *base_btf) +{ + return btf_new_empty(base_btf); +} + +static struct btf *btf_new(const void *data, __u32 size, struct btf *base_btf) +{ + struct btf *btf; + int err; + + btf = calloc(1, sizeof(struct btf)); + if (!btf) + return ERR_PTR(-ENOMEM); + + btf->nr_types = 0; + btf->start_id = 1; + btf->start_str_off = 0; + + if (base_btf) { + btf->base_btf = base_btf; + btf->start_id = btf__get_nr_types(base_btf) + 1; + btf->start_str_off = base_btf->hdr->str_len; + } + + btf->raw_data = malloc(size); + if (!btf->raw_data) { + err = -ENOMEM; + goto done; + } + memcpy(btf->raw_data, data, size); + btf->raw_size = size; + + btf->hdr = btf->raw_data; + err = btf_parse_hdr(btf); + if (err) + goto done; + + btf->strs_data = btf->raw_data + btf->hdr->hdr_len + btf->hdr->str_off; + btf->types_data = btf->raw_data + btf->hdr->hdr_len + btf->hdr->type_off; + + err = btf_parse_str_sec(btf); + err = err ?: btf_parse_type_sec(btf); + if (err) + goto done; + + btf->fd = -1; + +done: + if (err) { + btf__free(btf); + return ERR_PTR(err); + } + + return btf; +} + +struct btf *btf__new(const void *data, __u32 size) +{ + return btf_new(data, size, NULL); +} + +static struct btf *btf_parse_elf(const char *path, struct btf *base_btf, + struct btf_ext **btf_ext) +{ + Elf_Data *btf_data = NULL, *btf_ext_data = NULL; + int err = 0, fd = -1, idx = 0; + struct btf *btf = NULL; + Elf_Scn *scn = NULL; + Elf *elf = NULL; + GElf_Ehdr ehdr; + size_t shstrndx; + + if (elf_version(EV_CURRENT) == EV_NONE) { + pr_warn("failed to init libelf for %s\n", path); + return ERR_PTR(-LIBBPF_ERRNO__LIBELF); + } + + fd = open(path, O_RDONLY); + if (fd < 0) { + err = -errno; + pr_warn("failed to open %s: %s\n", path, strerror(errno)); + return ERR_PTR(err); + } + + err = -LIBBPF_ERRNO__FORMAT; + + elf = elf_begin(fd, ELF_C_READ, NULL); + if (!elf) { + pr_warn("failed to open %s as ELF file\n", path); + goto done; + } + if (!gelf_getehdr(elf, &ehdr)) { + pr_warn("failed to get EHDR from %s\n", path); + goto done; + } + + if (elf_getshdrstrndx(elf, &shstrndx)) { + pr_warn("failed to get section names section index for %s\n", + path); + goto done; + } + + if (!elf_rawdata(elf_getscn(elf, shstrndx), NULL)) { + pr_warn("failed to get e_shstrndx from %s\n", path); + goto done; + } + + while ((scn = elf_nextscn(elf, scn)) != NULL) { + GElf_Shdr sh; + char *name; + + idx++; + if (gelf_getshdr(scn, &sh) != &sh) { + pr_warn("failed to get section(%d) header from %s\n", + idx, path); + goto done; + } + name = elf_strptr(elf, shstrndx, sh.sh_name); + if (!name) { + pr_warn("failed to get section(%d) name from %s\n", + idx, path); + goto done; + } + if (strcmp(name, BTF_ELF_SEC) == 0) { + btf_data = elf_getdata(scn, 0); + if (!btf_data) { + pr_warn("failed to get section(%d, %s) data from %s\n", + idx, name, path); + goto done; + } + continue; + } else if (btf_ext && strcmp(name, BTF_EXT_ELF_SEC) == 0) { + btf_ext_data = elf_getdata(scn, 0); + if (!btf_ext_data) { + pr_warn("failed to get section(%d, %s) data from %s\n", + idx, name, path); + goto done; + } + continue; + } + } + + err = 0; + + if (!btf_data) { + err = -ENOENT; + goto done; + } + btf = btf_new(btf_data->d_buf, btf_data->d_size, base_btf); + if (IS_ERR(btf)) + goto done; + + switch (gelf_getclass(elf)) { + case ELFCLASS32: + btf__set_pointer_size(btf, 4); + break; + case ELFCLASS64: + btf__set_pointer_size(btf, 8); + break; + default: + pr_warn("failed to get ELF class (bitness) for %s\n", path); + break; + } + + if (btf_ext && btf_ext_data) { + *btf_ext = btf_ext__new(btf_ext_data->d_buf, + btf_ext_data->d_size); + if (IS_ERR(*btf_ext)) + goto done; + } else if (btf_ext) { + *btf_ext = NULL; + } +done: + if (elf) + elf_end(elf); + close(fd); + + if (err) + return ERR_PTR(err); + /* + * btf is always parsed before btf_ext, so no need to clean up + * btf_ext, if btf loading failed + */ + if (IS_ERR(btf)) + return btf; + if (btf_ext && IS_ERR(*btf_ext)) { + btf__free(btf); + err = PTR_ERR(*btf_ext); + return ERR_PTR(err); + } + return btf; +} + +struct btf *btf__parse_elf(const char *path, struct btf_ext **btf_ext) +{ + return btf_parse_elf(path, NULL, btf_ext); +} + +struct btf *btf__parse_elf_split(const char *path, struct btf *base_btf) +{ + return btf_parse_elf(path, base_btf, NULL); +} + +static struct btf *btf_parse_raw(const char *path, struct btf *base_btf) +{ + struct btf *btf = NULL; + void *data = NULL; + FILE *f = NULL; + __u16 magic; + int err = 0; + long sz; + + f = fopen(path, "rb"); + if (!f) { + err = -errno; + goto err_out; + } + + /* check BTF magic */ + if (fread(&magic, 1, sizeof(magic), f) < sizeof(magic)) { + err = -EIO; + goto err_out; + } + if (magic != BTF_MAGIC && magic != bswap_16(BTF_MAGIC)) { + /* definitely not a raw BTF */ + err = -EPROTO; + goto err_out; + } + + /* get file size */ + if (fseek(f, 0, SEEK_END)) { + err = -errno; + goto err_out; + } + sz = ftell(f); + if (sz < 0) { + err = -errno; + goto err_out; + } + /* rewind to the start */ + if (fseek(f, 0, SEEK_SET)) { + err = -errno; + goto err_out; + } + + /* pre-alloc memory and read all of BTF data */ + data = malloc(sz); + if (!data) { + err = -ENOMEM; + goto err_out; + } + if (fread(data, 1, sz, f) < sz) { + err = -EIO; + goto err_out; + } + + /* finally parse BTF data */ + btf = btf_new(data, sz, base_btf); + +err_out: + free(data); + if (f) + fclose(f); + return err ? ERR_PTR(err) : btf; +} + +struct btf *btf__parse_raw(const char *path) +{ + return btf_parse_raw(path, NULL); +} + +struct btf *btf__parse_raw_split(const char *path, struct btf *base_btf) +{ + return btf_parse_raw(path, base_btf); +} + +static struct btf *btf_parse(const char *path, struct btf *base_btf, struct btf_ext **btf_ext) +{ + struct btf *btf; + + if (btf_ext) + *btf_ext = NULL; + + btf = btf_parse_raw(path, base_btf); + if (!IS_ERR(btf) || PTR_ERR(btf) != -EPROTO) + return btf; + + return btf_parse_elf(path, base_btf, btf_ext); +} + +struct btf *btf__parse(const char *path, struct btf_ext **btf_ext) +{ + return btf_parse(path, NULL, btf_ext); +} + +struct btf *btf__parse_split(const char *path, struct btf *base_btf) +{ + return btf_parse(path, base_btf, NULL); +} + +static int compare_vsi_off(const void *_a, const void *_b) +{ + const struct btf_var_secinfo *a = _a; + const struct btf_var_secinfo *b = _b; + + return a->offset - b->offset; +} + +static int btf_fixup_datasec(struct bpf_object *obj, struct btf *btf, + struct btf_type *t) +{ + __u32 size = 0, off = 0, i, vars = btf_vlen(t); + const char *name = btf__name_by_offset(btf, t->name_off); + const struct btf_type *t_var; + struct btf_var_secinfo *vsi; + const struct btf_var *var; + int ret; + + if (!name) { + pr_debug("No name found in string section for DATASEC kind.\n"); + return -ENOENT; + } + + /* .extern datasec size and var offsets were set correctly during + * extern collection step, so just skip straight to sorting variables + */ + if (t->size) + goto sort_vars; + + ret = bpf_object__section_size(obj, name, &size); + if (ret || !size || (t->size && t->size != size)) { + pr_debug("Invalid size for section %s: %u bytes\n", name, size); + return -ENOENT; + } + + t->size = size; + + for (i = 0, vsi = btf_var_secinfos(t); i < vars; i++, vsi++) { + t_var = btf__type_by_id(btf, vsi->type); + var = btf_var(t_var); + + if (!btf_is_var(t_var)) { + pr_debug("Non-VAR type seen in section %s\n", name); + return -EINVAL; + } + + if (var->linkage == BTF_VAR_STATIC) + continue; + + name = btf__name_by_offset(btf, t_var->name_off); + if (!name) { + pr_debug("No name found in string section for VAR kind\n"); + return -ENOENT; + } + + ret = bpf_object__variable_offset(obj, name, &off); + if (ret) { + pr_debug("No offset found in symbol table for VAR %s\n", + name); + return -ENOENT; + } + + vsi->offset = off; + } + +sort_vars: + qsort(btf_var_secinfos(t), vars, sizeof(*vsi), compare_vsi_off); + return 0; +} + +int btf__finalize_data(struct bpf_object *obj, struct btf *btf) +{ + int err = 0; + __u32 i; + + for (i = 1; i <= btf->nr_types; i++) { + struct btf_type *t = btf_type_by_id(btf, i); + + /* Loader needs to fix up some of the things compiler + * couldn't get its hands on while emitting BTF. This + * is section size and global variable offset. We use + * the info from the ELF itself for this purpose. + */ + if (btf_is_datasec(t)) { + err = btf_fixup_datasec(obj, btf, t); + if (err) + break; + } + } + + return err; +} + +static void *btf_get_raw_data(const struct btf *btf, __u32 *size, bool swap_endian); + +int btf__load(struct btf *btf) +{ + __u32 log_buf_size = 0, raw_size; + char *log_buf = NULL; + void *raw_data; + int err = 0; + + if (btf->fd >= 0) + return -EEXIST; + +retry_load: + if (log_buf_size) { + log_buf = malloc(log_buf_size); + if (!log_buf) + return -ENOMEM; + + *log_buf = 0; + } + + raw_data = btf_get_raw_data(btf, &raw_size, false); + if (!raw_data) { + err = -ENOMEM; + goto done; + } + /* cache native raw data representation */ + btf->raw_size = raw_size; + btf->raw_data = raw_data; + + btf->fd = bpf_load_btf(raw_data, raw_size, log_buf, log_buf_size, false); + if (btf->fd < 0) { + if (!log_buf || errno == ENOSPC) { + log_buf_size = max((__u32)BPF_LOG_BUF_SIZE, + log_buf_size << 1); + free(log_buf); + goto retry_load; + } + + err = -errno; + pr_warn("Error loading BTF: %s(%d)\n", strerror(errno), errno); + if (*log_buf) + pr_warn("%s\n", log_buf); + goto done; + } + +done: + free(log_buf); + return err; +} + +int btf__fd(const struct btf *btf) +{ + return btf->fd; +} + +void btf__set_fd(struct btf *btf, int fd) +{ + btf->fd = fd; +} + +static void *btf_get_raw_data(const struct btf *btf, __u32 *size, bool swap_endian) +{ + struct btf_header *hdr = btf->hdr; + struct btf_type *t; + void *data, *p; + __u32 data_sz; + int i; + + data = swap_endian ? btf->raw_data_swapped : btf->raw_data; + if (data) { + *size = btf->raw_size; + return data; + } + + data_sz = hdr->hdr_len + hdr->type_len + hdr->str_len; + data = calloc(1, data_sz); + if (!data) + return NULL; + p = data; + + memcpy(p, hdr, hdr->hdr_len); + if (swap_endian) + btf_bswap_hdr(p); + p += hdr->hdr_len; + + memcpy(p, btf->types_data, hdr->type_len); + if (swap_endian) { + for (i = 0; i < btf->nr_types; i++) { + t = p + btf->type_offs[i]; + /* btf_bswap_type_rest() relies on native t->info, so + * we swap base type info after we swapped all the + * additional information + */ + if (btf_bswap_type_rest(t)) + goto err_out; + btf_bswap_type_base(t); + } + } + p += hdr->type_len; + + memcpy(p, btf->strs_data, hdr->str_len); + p += hdr->str_len; + + *size = data_sz; + return data; +err_out: + free(data); + return NULL; +} + +const void *btf__get_raw_data(const struct btf *btf_ro, __u32 *size) +{ + struct btf *btf = (struct btf *)btf_ro; + __u32 data_sz; + void *data; + + data = btf_get_raw_data(btf, &data_sz, btf->swapped_endian); + if (!data) + return NULL; + + btf->raw_size = data_sz; + if (btf->swapped_endian) + btf->raw_data_swapped = data; + else + btf->raw_data = data; + *size = data_sz; + return data; +} + +const char *btf__str_by_offset(const struct btf *btf, __u32 offset) +{ + if (offset < btf->start_str_off) + return btf__str_by_offset(btf->base_btf, offset); + else if (offset - btf->start_str_off < btf->hdr->str_len) + return btf->strs_data + (offset - btf->start_str_off); + else + return NULL; +} + +const char *btf__name_by_offset(const struct btf *btf, __u32 offset) +{ + return btf__str_by_offset(btf, offset); +} + +struct btf *btf_get_from_fd(int btf_fd, struct btf *base_btf) +{ + struct bpf_btf_info btf_info; + __u32 len = sizeof(btf_info); + __u32 last_size; + struct btf *btf; + void *ptr; + int err; + + /* we won't know btf_size until we call bpf_obj_get_info_by_fd(). so + * let's start with a sane default - 4KiB here - and resize it only if + * bpf_obj_get_info_by_fd() needs a bigger buffer. + */ + last_size = 4096; + ptr = malloc(last_size); + if (!ptr) + return ERR_PTR(-ENOMEM); + + memset(&btf_info, 0, sizeof(btf_info)); + btf_info.btf = ptr_to_u64(ptr); + btf_info.btf_size = last_size; + err = bpf_obj_get_info_by_fd(btf_fd, &btf_info, &len); + + if (!err && btf_info.btf_size > last_size) { + void *temp_ptr; + + last_size = btf_info.btf_size; + temp_ptr = realloc(ptr, last_size); + if (!temp_ptr) { + btf = ERR_PTR(-ENOMEM); + goto exit_free; + } + ptr = temp_ptr; + + len = sizeof(btf_info); + memset(&btf_info, 0, sizeof(btf_info)); + btf_info.btf = ptr_to_u64(ptr); + btf_info.btf_size = last_size; + + err = bpf_obj_get_info_by_fd(btf_fd, &btf_info, &len); + } + + if (err || btf_info.btf_size > last_size) { + btf = err ? ERR_PTR(-errno) : ERR_PTR(-E2BIG); + goto exit_free; + } + + btf = btf_new(ptr, btf_info.btf_size, base_btf); + +exit_free: + free(ptr); + return btf; +} + +int btf__get_from_id(__u32 id, struct btf **btf) +{ + struct btf *res; + int btf_fd; + + *btf = NULL; + btf_fd = bpf_btf_get_fd_by_id(id); + if (btf_fd < 0) + return -errno; + + res = btf_get_from_fd(btf_fd, NULL); + close(btf_fd); + if (IS_ERR(res)) + return PTR_ERR(res); + + *btf = res; + return 0; +} + +int btf__get_map_kv_tids(const struct btf *btf, const char *map_name, + __u32 expected_key_size, __u32 expected_value_size, + __u32 *key_type_id, __u32 *value_type_id) +{ + const struct btf_type *container_type; + const struct btf_member *key, *value; + const size_t max_name = 256; + char container_name[max_name]; + __s64 key_size, value_size; + __s32 container_id; + + if (snprintf(container_name, max_name, "____btf_map_%s", map_name) == + max_name) { + pr_warn("map:%s length of '____btf_map_%s' is too long\n", + map_name, map_name); + return -EINVAL; + } + + container_id = btf__find_by_name(btf, container_name); + if (container_id < 0) { + pr_debug("map:%s container_name:%s cannot be found in BTF. Missing BPF_ANNOTATE_KV_PAIR?\n", + map_name, container_name); + return container_id; + } + + container_type = btf__type_by_id(btf, container_id); + if (!container_type) { + pr_warn("map:%s cannot find BTF type for container_id:%u\n", + map_name, container_id); + return -EINVAL; + } + + if (!btf_is_struct(container_type) || btf_vlen(container_type) < 2) { + pr_warn("map:%s container_name:%s is an invalid container struct\n", + map_name, container_name); + return -EINVAL; + } + + key = btf_members(container_type); + value = key + 1; + + key_size = btf__resolve_size(btf, key->type); + if (key_size < 0) { + pr_warn("map:%s invalid BTF key_type_size\n", map_name); + return key_size; + } + + if (expected_key_size != key_size) { + pr_warn("map:%s btf_key_type_size:%u != map_def_key_size:%u\n", + map_name, (__u32)key_size, expected_key_size); + return -EINVAL; + } + + value_size = btf__resolve_size(btf, value->type); + if (value_size < 0) { + pr_warn("map:%s invalid BTF value_type_size\n", map_name); + return value_size; + } + + if (expected_value_size != value_size) { + pr_warn("map:%s btf_value_type_size:%u != map_def_value_size:%u\n", + map_name, (__u32)value_size, expected_value_size); + return -EINVAL; + } + + *key_type_id = key->type; + *value_type_id = value->type; + + return 0; +} + +static size_t strs_hash_fn(const void *key, void *ctx) +{ + const struct btf *btf = ctx; + const char *strs = *btf->strs_data_ptr; + const char *str = strs + (long)key; + + return str_hash(str); +} + +static bool strs_hash_equal_fn(const void *key1, const void *key2, void *ctx) +{ + const struct btf *btf = ctx; + const char *strs = *btf->strs_data_ptr; + const char *str1 = strs + (long)key1; + const char *str2 = strs + (long)key2; + + return strcmp(str1, str2) == 0; +} + +static void btf_invalidate_raw_data(struct btf *btf) +{ + if (btf->raw_data) { + free(btf->raw_data); + btf->raw_data = NULL; + } + if (btf->raw_data_swapped) { + free(btf->raw_data_swapped); + btf->raw_data_swapped = NULL; + } +} + +/* Ensure BTF is ready to be modified (by splitting into a three memory + * regions for header, types, and strings). Also invalidate cached + * raw_data, if any. + */ +static int btf_ensure_modifiable(struct btf *btf) +{ + void *hdr, *types, *strs, *strs_end, *s; + struct hashmap *hash = NULL; + long off; + int err; + + if (btf_is_modifiable(btf)) { + /* any BTF modification invalidates raw_data */ + btf_invalidate_raw_data(btf); + return 0; + } + + /* split raw data into three memory regions */ + hdr = malloc(btf->hdr->hdr_len); + types = malloc(btf->hdr->type_len); + strs = malloc(btf->hdr->str_len); + if (!hdr || !types || !strs) + goto err_out; + + memcpy(hdr, btf->hdr, btf->hdr->hdr_len); + memcpy(types, btf->types_data, btf->hdr->type_len); + memcpy(strs, btf->strs_data, btf->hdr->str_len); + + /* make hashmap below use btf->strs_data as a source of strings */ + btf->strs_data_ptr = &btf->strs_data; + + /* build lookup index for all strings */ + hash = hashmap__new(strs_hash_fn, strs_hash_equal_fn, btf); + if (IS_ERR(hash)) { + err = PTR_ERR(hash); + hash = NULL; + goto err_out; + } + + strs_end = strs + btf->hdr->str_len; + for (off = 0, s = strs; s < strs_end; off += strlen(s) + 1, s = strs + off) { + /* hashmap__add() returns EEXIST if string with the same + * content already is in the hash map + */ + err = hashmap__add(hash, (void *)off, (void *)off); + if (err == -EEXIST) + continue; /* duplicate */ + if (err) + goto err_out; + } + + /* only when everything was successful, update internal state */ + btf->hdr = hdr; + btf->types_data = types; + btf->types_data_cap = btf->hdr->type_len; + btf->strs_data = strs; + btf->strs_data_cap = btf->hdr->str_len; + btf->strs_hash = hash; + /* if BTF was created from scratch, all strings are guaranteed to be + * unique and deduplicated + */ + if (btf->hdr->str_len == 0) + btf->strs_deduped = true; + if (!btf->base_btf && btf->hdr->str_len == 1) + btf->strs_deduped = true; + + /* invalidate raw_data representation */ + btf_invalidate_raw_data(btf); + + return 0; + +err_out: + hashmap__free(hash); + free(hdr); + free(types); + free(strs); + return -ENOMEM; +} + +static void *btf_add_str_mem(struct btf *btf, size_t add_sz) +{ + return btf_add_mem(&btf->strs_data, &btf->strs_data_cap, 1, + btf->hdr->str_len, BTF_MAX_STR_OFFSET, add_sz); +} + +/* Find an offset in BTF string section that corresponds to a given string *s*. + * Returns: + * - >0 offset into string section, if string is found; + * - -ENOENT, if string is not in the string section; + * - <0, on any other error. + */ +int btf__find_str(struct btf *btf, const char *s) +{ + long old_off, new_off, len; + void *p; + + if (btf->base_btf) { + int ret; + + ret = btf__find_str(btf->base_btf, s); + if (ret != -ENOENT) + return ret; + } + + /* BTF needs to be in a modifiable state to build string lookup index */ + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + /* see btf__add_str() for why we do this */ + len = strlen(s) + 1; + p = btf_add_str_mem(btf, len); + if (!p) + return -ENOMEM; + + new_off = btf->hdr->str_len; + memcpy(p, s, len); + + if (hashmap__find(btf->strs_hash, (void *)new_off, (void **)&old_off)) + return btf->start_str_off + old_off; + + return -ENOENT; +} + +/* Add a string s to the BTF string section. + * Returns: + * - > 0 offset into string section, on success; + * - < 0, on error. + */ +int btf__add_str(struct btf *btf, const char *s) +{ + long old_off, new_off, len; + void *p; + int err; + + if (btf->base_btf) { + int ret; + + ret = btf__find_str(btf->base_btf, s); + if (ret != -ENOENT) + return ret; + } + + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + /* Hashmap keys are always offsets within btf->strs_data, so to even + * look up some string from the "outside", we need to first append it + * at the end, so that it can be addressed with an offset. Luckily, + * until btf->hdr->str_len is incremented, that string is just a piece + * of garbage for the rest of BTF code, so no harm, no foul. On the + * other hand, if the string is unique, it's already appended and + * ready to be used, only a simple btf->hdr->str_len increment away. + */ + len = strlen(s) + 1; + p = btf_add_str_mem(btf, len); + if (!p) + return -ENOMEM; + + new_off = btf->hdr->str_len; + memcpy(p, s, len); + + /* Now attempt to add the string, but only if the string with the same + * contents doesn't exist already (HASHMAP_ADD strategy). If such + * string exists, we'll get its offset in old_off (that's old_key). + */ + err = hashmap__insert(btf->strs_hash, (void *)new_off, (void *)new_off, + HASHMAP_ADD, (const void **)&old_off, NULL); + if (err == -EEXIST) + return btf->start_str_off + old_off; /* duplicated string, return existing offset */ + if (err) + return err; + + btf->hdr->str_len += len; /* new unique string, adjust data length */ + return btf->start_str_off + new_off; +} + +static void *btf_add_type_mem(struct btf *btf, size_t add_sz) +{ + return btf_add_mem(&btf->types_data, &btf->types_data_cap, 1, + btf->hdr->type_len, UINT_MAX, add_sz); +} + +static __u32 btf_type_info(int kind, int vlen, int kflag) +{ + return (kflag << 31) | (kind << 24) | vlen; +} + +static void btf_type_inc_vlen(struct btf_type *t) +{ + t->info = btf_type_info(btf_kind(t), btf_vlen(t) + 1, btf_kflag(t)); +} + +static int btf_commit_type(struct btf *btf, int data_sz) +{ + int err; + + err = btf_add_type_idx_entry(btf, btf->hdr->type_len); + if (err) + return err; + + btf->hdr->type_len += data_sz; + btf->hdr->str_off += data_sz; + btf->nr_types++; + return btf->start_id + btf->nr_types - 1; +} + +/* + * Append new BTF_KIND_INT type with: + * - *name* - non-empty, non-NULL type name; + * - *sz* - power-of-2 (1, 2, 4, ..) size of the type, in bytes; + * - encoding is a combination of BTF_INT_SIGNED, BTF_INT_CHAR, BTF_INT_BOOL. + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_int(struct btf *btf, const char *name, size_t byte_sz, int encoding) +{ + struct btf_type *t; + int sz, name_off; + + /* non-empty name */ + if (!name || !name[0]) + return -EINVAL; + /* byte_sz must be power of 2 */ + if (!byte_sz || (byte_sz & (byte_sz - 1)) || byte_sz > 16) + return -EINVAL; + if (encoding & ~(BTF_INT_SIGNED | BTF_INT_CHAR | BTF_INT_BOOL)) + return -EINVAL; + + /* deconstruct BTF, if necessary, and invalidate raw_data */ + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_type) + sizeof(int); + t = btf_add_type_mem(btf, sz); + if (!t) + return -ENOMEM; + + /* if something goes wrong later, we might end up with an extra string, + * but that shouldn't be a problem, because BTF can't be constructed + * completely anyway and will most probably be just discarded + */ + name_off = btf__add_str(btf, name); + if (name_off < 0) + return name_off; + + t->name_off = name_off; + t->info = btf_type_info(BTF_KIND_INT, 0, 0); + t->size = byte_sz; + /* set INT info, we don't allow setting legacy bit offset/size */ + *(__u32 *)(t + 1) = (encoding << 24) | (byte_sz * 8); + + return btf_commit_type(btf, sz); +} + +/* + * Append new BTF_KIND_FLOAT type with: + * - *name* - non-empty, non-NULL type name; + * - *sz* - size of the type, in bytes; + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_float(struct btf *btf, const char *name, size_t byte_sz) +{ + struct btf_type *t; + int sz, name_off; + + /* non-empty name */ + if (!name || !name[0]) + return -EINVAL; + + /* byte_sz must be one of the explicitly allowed values */ + if (byte_sz != 2 && byte_sz != 4 && byte_sz != 8 && byte_sz != 12 && + byte_sz != 16) + return -EINVAL; + + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_type); + t = btf_add_type_mem(btf, sz); + if (!t) + return -ENOMEM; + + name_off = btf__add_str(btf, name); + if (name_off < 0) + return name_off; + + t->name_off = name_off; + t->info = btf_type_info(BTF_KIND_FLOAT, 0, 0); + t->size = byte_sz; + + return btf_commit_type(btf, sz); +} + +/* it's completely legal to append BTF types with type IDs pointing forward to + * types that haven't been appended yet, so we only make sure that id looks + * sane, we can't guarantee that ID will always be valid + */ +static int validate_type_id(int id) +{ + if (id < 0 || id > BTF_MAX_NR_TYPES) + return -EINVAL; + return 0; +} + +/* generic append function for PTR, TYPEDEF, CONST/VOLATILE/RESTRICT */ +static int btf_add_ref_kind(struct btf *btf, int kind, const char *name, int ref_type_id) +{ + struct btf_type *t; + int sz, name_off = 0; + + if (validate_type_id(ref_type_id)) + return -EINVAL; + + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_type); + t = btf_add_type_mem(btf, sz); + if (!t) + return -ENOMEM; + + if (name && name[0]) { + name_off = btf__add_str(btf, name); + if (name_off < 0) + return name_off; + } + + t->name_off = name_off; + t->info = btf_type_info(kind, 0, 0); + t->type = ref_type_id; + + return btf_commit_type(btf, sz); +} + +/* + * Append new BTF_KIND_PTR type with: + * - *ref_type_id* - referenced type ID, it might not exist yet; + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_ptr(struct btf *btf, int ref_type_id) +{ + return btf_add_ref_kind(btf, BTF_KIND_PTR, NULL, ref_type_id); +} + +/* + * Append new BTF_KIND_ARRAY type with: + * - *index_type_id* - type ID of the type describing array index; + * - *elem_type_id* - type ID of the type describing array element; + * - *nr_elems* - the size of the array; + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_array(struct btf *btf, int index_type_id, int elem_type_id, __u32 nr_elems) +{ + struct btf_type *t; + struct btf_array *a; + int sz; + + if (validate_type_id(index_type_id) || validate_type_id(elem_type_id)) + return -EINVAL; + + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_type) + sizeof(struct btf_array); + t = btf_add_type_mem(btf, sz); + if (!t) + return -ENOMEM; + + t->name_off = 0; + t->info = btf_type_info(BTF_KIND_ARRAY, 0, 0); + t->size = 0; + + a = btf_array(t); + a->type = elem_type_id; + a->index_type = index_type_id; + a->nelems = nr_elems; + + return btf_commit_type(btf, sz); +} + +/* generic STRUCT/UNION append function */ +static int btf_add_composite(struct btf *btf, int kind, const char *name, __u32 bytes_sz) +{ + struct btf_type *t; + int sz, name_off = 0; + + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_type); + t = btf_add_type_mem(btf, sz); + if (!t) + return -ENOMEM; + + if (name && name[0]) { + name_off = btf__add_str(btf, name); + if (name_off < 0) + return name_off; + } + + /* start out with vlen=0 and no kflag; this will be adjusted when + * adding each member + */ + t->name_off = name_off; + t->info = btf_type_info(kind, 0, 0); + t->size = bytes_sz; + + return btf_commit_type(btf, sz); +} + +/* + * Append new BTF_KIND_STRUCT type with: + * - *name* - name of the struct, can be NULL or empty for anonymous structs; + * - *byte_sz* - size of the struct, in bytes; + * + * Struct initially has no fields in it. Fields can be added by + * btf__add_field() right after btf__add_struct() succeeds. + * + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_struct(struct btf *btf, const char *name, __u32 byte_sz) +{ + return btf_add_composite(btf, BTF_KIND_STRUCT, name, byte_sz); +} + +/* + * Append new BTF_KIND_UNION type with: + * - *name* - name of the union, can be NULL or empty for anonymous union; + * - *byte_sz* - size of the union, in bytes; + * + * Union initially has no fields in it. Fields can be added by + * btf__add_field() right after btf__add_union() succeeds. All fields + * should have *bit_offset* of 0. + * + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_union(struct btf *btf, const char *name, __u32 byte_sz) +{ + return btf_add_composite(btf, BTF_KIND_UNION, name, byte_sz); +} + +static struct btf_type *btf_last_type(struct btf *btf) +{ + return btf_type_by_id(btf, btf__get_nr_types(btf)); +} + +/* + * Append new field for the current STRUCT/UNION type with: + * - *name* - name of the field, can be NULL or empty for anonymous field; + * - *type_id* - type ID for the type describing field type; + * - *bit_offset* - bit offset of the start of the field within struct/union; + * - *bit_size* - bit size of a bitfield, 0 for non-bitfield fields; + * Returns: + * - 0, on success; + * - <0, on error. + */ +int btf__add_field(struct btf *btf, const char *name, int type_id, + __u32 bit_offset, __u32 bit_size) +{ + struct btf_type *t; + struct btf_member *m; + bool is_bitfield; + int sz, name_off = 0; + + /* last type should be union/struct */ + if (btf->nr_types == 0) + return -EINVAL; + t = btf_last_type(btf); + if (!btf_is_composite(t)) + return -EINVAL; + + if (validate_type_id(type_id)) + return -EINVAL; + /* best-effort bit field offset/size enforcement */ + is_bitfield = bit_size || (bit_offset % 8 != 0); + if (is_bitfield && (bit_size == 0 || bit_size > 255 || bit_offset > 0xffffff)) + return -EINVAL; + + /* only offset 0 is allowed for unions */ + if (btf_is_union(t) && bit_offset) + return -EINVAL; + + /* decompose and invalidate raw data */ + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_member); + m = btf_add_type_mem(btf, sz); + if (!m) + return -ENOMEM; + + if (name && name[0]) { + name_off = btf__add_str(btf, name); + if (name_off < 0) + return name_off; + } + + m->name_off = name_off; + m->type = type_id; + m->offset = bit_offset | (bit_size << 24); + + /* btf_add_type_mem can invalidate t pointer */ + t = btf_last_type(btf); + /* update parent type's vlen and kflag */ + t->info = btf_type_info(btf_kind(t), btf_vlen(t) + 1, is_bitfield || btf_kflag(t)); + + btf->hdr->type_len += sz; + btf->hdr->str_off += sz; + return 0; +} + +/* + * Append new BTF_KIND_ENUM type with: + * - *name* - name of the enum, can be NULL or empty for anonymous enums; + * - *byte_sz* - size of the enum, in bytes. + * + * Enum initially has no enum values in it (and corresponds to enum forward + * declaration). Enumerator values can be added by btf__add_enum_value() + * immediately after btf__add_enum() succeeds. + * + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_enum(struct btf *btf, const char *name, __u32 byte_sz) +{ + struct btf_type *t; + int sz, name_off = 0; + + /* byte_sz must be power of 2 */ + if (!byte_sz || (byte_sz & (byte_sz - 1)) || byte_sz > 8) + return -EINVAL; + + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_type); + t = btf_add_type_mem(btf, sz); + if (!t) + return -ENOMEM; + + if (name && name[0]) { + name_off = btf__add_str(btf, name); + if (name_off < 0) + return name_off; + } + + /* start out with vlen=0; it will be adjusted when adding enum values */ + t->name_off = name_off; + t->info = btf_type_info(BTF_KIND_ENUM, 0, 0); + t->size = byte_sz; + + return btf_commit_type(btf, sz); +} + +/* + * Append new enum value for the current ENUM type with: + * - *name* - name of the enumerator value, can't be NULL or empty; + * - *value* - integer value corresponding to enum value *name*; + * Returns: + * - 0, on success; + * - <0, on error. + */ +int btf__add_enum_value(struct btf *btf, const char *name, __s64 value) +{ + struct btf_type *t; + struct btf_enum *v; + int sz, name_off; + + /* last type should be BTF_KIND_ENUM */ + if (btf->nr_types == 0) + return -EINVAL; + t = btf_last_type(btf); + if (!btf_is_enum(t)) + return -EINVAL; + + /* non-empty name */ + if (!name || !name[0]) + return -EINVAL; + if (value < INT_MIN || value > UINT_MAX) + return -E2BIG; + + /* decompose and invalidate raw data */ + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_enum); + v = btf_add_type_mem(btf, sz); + if (!v) + return -ENOMEM; + + name_off = btf__add_str(btf, name); + if (name_off < 0) + return name_off; + + v->name_off = name_off; + v->val = value; + + /* update parent type's vlen */ + t = btf_last_type(btf); + btf_type_inc_vlen(t); + + btf->hdr->type_len += sz; + btf->hdr->str_off += sz; + return 0; +} + +/* + * Append new BTF_KIND_FWD type with: + * - *name*, non-empty/non-NULL name; + * - *fwd_kind*, kind of forward declaration, one of BTF_FWD_STRUCT, + * BTF_FWD_UNION, or BTF_FWD_ENUM; + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_fwd(struct btf *btf, const char *name, enum btf_fwd_kind fwd_kind) +{ + if (!name || !name[0]) + return -EINVAL; + + switch (fwd_kind) { + case BTF_FWD_STRUCT: + case BTF_FWD_UNION: { + struct btf_type *t; + int id; + + id = btf_add_ref_kind(btf, BTF_KIND_FWD, name, 0); + if (id <= 0) + return id; + t = btf_type_by_id(btf, id); + t->info = btf_type_info(BTF_KIND_FWD, 0, fwd_kind == BTF_FWD_UNION); + return id; + } + case BTF_FWD_ENUM: + /* enum forward in BTF currently is just an enum with no enum + * values; we also assume a standard 4-byte size for it + */ + return btf__add_enum(btf, name, sizeof(int)); + default: + return -EINVAL; + } +} + +/* + * Append new BTF_KING_TYPEDEF type with: + * - *name*, non-empty/non-NULL name; + * - *ref_type_id* - referenced type ID, it might not exist yet; + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_typedef(struct btf *btf, const char *name, int ref_type_id) +{ + if (!name || !name[0]) + return -EINVAL; + + return btf_add_ref_kind(btf, BTF_KIND_TYPEDEF, name, ref_type_id); +} + +/* + * Append new BTF_KIND_VOLATILE type with: + * - *ref_type_id* - referenced type ID, it might not exist yet; + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_volatile(struct btf *btf, int ref_type_id) +{ + return btf_add_ref_kind(btf, BTF_KIND_VOLATILE, NULL, ref_type_id); +} + +/* + * Append new BTF_KIND_CONST type with: + * - *ref_type_id* - referenced type ID, it might not exist yet; + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_const(struct btf *btf, int ref_type_id) +{ + return btf_add_ref_kind(btf, BTF_KIND_CONST, NULL, ref_type_id); +} + +/* + * Append new BTF_KIND_RESTRICT type with: + * - *ref_type_id* - referenced type ID, it might not exist yet; + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_restrict(struct btf *btf, int ref_type_id) +{ + return btf_add_ref_kind(btf, BTF_KIND_RESTRICT, NULL, ref_type_id); +} + +/* + * Append new BTF_KIND_FUNC type with: + * - *name*, non-empty/non-NULL name; + * - *proto_type_id* - FUNC_PROTO's type ID, it might not exist yet; + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_func(struct btf *btf, const char *name, + enum btf_func_linkage linkage, int proto_type_id) +{ + int id; + + if (!name || !name[0]) + return -EINVAL; + if (linkage != BTF_FUNC_STATIC && linkage != BTF_FUNC_GLOBAL && + linkage != BTF_FUNC_EXTERN) + return -EINVAL; + + id = btf_add_ref_kind(btf, BTF_KIND_FUNC, name, proto_type_id); + if (id > 0) { + struct btf_type *t = btf_type_by_id(btf, id); + + t->info = btf_type_info(BTF_KIND_FUNC, linkage, 0); + } + return id; +} + +/* + * Append new BTF_KIND_FUNC_PROTO with: + * - *ret_type_id* - type ID for return result of a function. + * + * Function prototype initially has no arguments, but they can be added by + * btf__add_func_param() one by one, immediately after + * btf__add_func_proto() succeeded. + * + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_func_proto(struct btf *btf, int ret_type_id) +{ + struct btf_type *t; + int sz; + + if (validate_type_id(ret_type_id)) + return -EINVAL; + + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_type); + t = btf_add_type_mem(btf, sz); + if (!t) + return -ENOMEM; + + /* start out with vlen=0; this will be adjusted when adding enum + * values, if necessary + */ + t->name_off = 0; + t->info = btf_type_info(BTF_KIND_FUNC_PROTO, 0, 0); + t->type = ret_type_id; + + return btf_commit_type(btf, sz); +} + +/* + * Append new function parameter for current FUNC_PROTO type with: + * - *name* - parameter name, can be NULL or empty; + * - *type_id* - type ID describing the type of the parameter. + * Returns: + * - 0, on success; + * - <0, on error. + */ +int btf__add_func_param(struct btf *btf, const char *name, int type_id) +{ + struct btf_type *t; + struct btf_param *p; + int sz, name_off = 0; + + if (validate_type_id(type_id)) + return -EINVAL; + + /* last type should be BTF_KIND_FUNC_PROTO */ + if (btf->nr_types == 0) + return -EINVAL; + t = btf_last_type(btf); + if (!btf_is_func_proto(t)) + return -EINVAL; + + /* decompose and invalidate raw data */ + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_param); + p = btf_add_type_mem(btf, sz); + if (!p) + return -ENOMEM; + + if (name && name[0]) { + name_off = btf__add_str(btf, name); + if (name_off < 0) + return name_off; + } + + p->name_off = name_off; + p->type = type_id; + + /* update parent type's vlen */ + t = btf_last_type(btf); + btf_type_inc_vlen(t); + + btf->hdr->type_len += sz; + btf->hdr->str_off += sz; + return 0; +} + +/* + * Append new BTF_KIND_VAR type with: + * - *name* - non-empty/non-NULL name; + * - *linkage* - variable linkage, one of BTF_VAR_STATIC, + * BTF_VAR_GLOBAL_ALLOCATED, or BTF_VAR_GLOBAL_EXTERN; + * - *type_id* - type ID of the type describing the type of the variable. + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_var(struct btf *btf, const char *name, int linkage, int type_id) +{ + struct btf_type *t; + struct btf_var *v; + int sz, name_off; + + /* non-empty name */ + if (!name || !name[0]) + return -EINVAL; + if (linkage != BTF_VAR_STATIC && linkage != BTF_VAR_GLOBAL_ALLOCATED && + linkage != BTF_VAR_GLOBAL_EXTERN) + return -EINVAL; + if (validate_type_id(type_id)) + return -EINVAL; + + /* deconstruct BTF, if necessary, and invalidate raw_data */ + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_type) + sizeof(struct btf_var); + t = btf_add_type_mem(btf, sz); + if (!t) + return -ENOMEM; + + name_off = btf__add_str(btf, name); + if (name_off < 0) + return name_off; + + t->name_off = name_off; + t->info = btf_type_info(BTF_KIND_VAR, 0, 0); + t->type = type_id; + + v = btf_var(t); + v->linkage = linkage; + + return btf_commit_type(btf, sz); +} + +/* + * Append new BTF_KIND_DATASEC type with: + * - *name* - non-empty/non-NULL name; + * - *byte_sz* - data section size, in bytes. + * + * Data section is initially empty. Variables info can be added with + * btf__add_datasec_var_info() calls, after btf__add_datasec() succeeds. + * + * Returns: + * - >0, type ID of newly added BTF type; + * - <0, on error. + */ +int btf__add_datasec(struct btf *btf, const char *name, __u32 byte_sz) +{ + struct btf_type *t; + int sz, name_off; + + /* non-empty name */ + if (!name || !name[0]) + return -EINVAL; + + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_type); + t = btf_add_type_mem(btf, sz); + if (!t) + return -ENOMEM; + + name_off = btf__add_str(btf, name); + if (name_off < 0) + return name_off; + + /* start with vlen=0, which will be update as var_secinfos are added */ + t->name_off = name_off; + t->info = btf_type_info(BTF_KIND_DATASEC, 0, 0); + t->size = byte_sz; + + return btf_commit_type(btf, sz); +} + +/* + * Append new data section variable information entry for current DATASEC type: + * - *var_type_id* - type ID, describing type of the variable; + * - *offset* - variable offset within data section, in bytes; + * - *byte_sz* - variable size, in bytes. + * + * Returns: + * - 0, on success; + * - <0, on error. + */ +int btf__add_datasec_var_info(struct btf *btf, int var_type_id, __u32 offset, __u32 byte_sz) +{ + struct btf_type *t; + struct btf_var_secinfo *v; + int sz; + + /* last type should be BTF_KIND_DATASEC */ + if (btf->nr_types == 0) + return -EINVAL; + t = btf_last_type(btf); + if (!btf_is_datasec(t)) + return -EINVAL; + + if (validate_type_id(var_type_id)) + return -EINVAL; + + /* decompose and invalidate raw data */ + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + sz = sizeof(struct btf_var_secinfo); + v = btf_add_type_mem(btf, sz); + if (!v) + return -ENOMEM; + + v->type = var_type_id; + v->offset = offset; + v->size = byte_sz; + + /* update parent type's vlen */ + t = btf_last_type(btf); + btf_type_inc_vlen(t); + + btf->hdr->type_len += sz; + btf->hdr->str_off += sz; + return 0; +} + +struct btf_ext_sec_setup_param { + __u32 off; + __u32 len; + __u32 min_rec_size; + struct btf_ext_info *ext_info; + const char *desc; +}; + +static int btf_ext_setup_info(struct btf_ext *btf_ext, + struct btf_ext_sec_setup_param *ext_sec) +{ + const struct btf_ext_info_sec *sinfo; + struct btf_ext_info *ext_info; + __u32 info_left, record_size; + /* The start of the info sec (including the __u32 record_size). */ + void *info; + + if (ext_sec->len == 0) + return 0; + + if (ext_sec->off & 0x03) { + pr_debug(".BTF.ext %s section is not aligned to 4 bytes\n", + ext_sec->desc); + return -EINVAL; + } + + info = btf_ext->data + btf_ext->hdr->hdr_len + ext_sec->off; + info_left = ext_sec->len; + + if (btf_ext->data + btf_ext->data_size < info + ext_sec->len) { + pr_debug("%s section (off:%u len:%u) is beyond the end of the ELF section .BTF.ext\n", + ext_sec->desc, ext_sec->off, ext_sec->len); + return -EINVAL; + } + + /* At least a record size */ + if (info_left < sizeof(__u32)) { + pr_debug(".BTF.ext %s record size not found\n", ext_sec->desc); + return -EINVAL; + } + + /* The record size needs to meet the minimum standard */ + record_size = *(__u32 *)info; + if (record_size < ext_sec->min_rec_size || + record_size & 0x03) { + pr_debug("%s section in .BTF.ext has invalid record size %u\n", + ext_sec->desc, record_size); + return -EINVAL; + } + + sinfo = info + sizeof(__u32); + info_left -= sizeof(__u32); + + /* If no records, return failure now so .BTF.ext won't be used. */ + if (!info_left) { + pr_debug("%s section in .BTF.ext has no records", ext_sec->desc); + return -EINVAL; + } + + while (info_left) { + unsigned int sec_hdrlen = sizeof(struct btf_ext_info_sec); + __u64 total_record_size; + __u32 num_records; + + if (info_left < sec_hdrlen) { + pr_debug("%s section header is not found in .BTF.ext\n", + ext_sec->desc); + return -EINVAL; + } + + num_records = sinfo->num_info; + if (num_records == 0) { + pr_debug("%s section has incorrect num_records in .BTF.ext\n", + ext_sec->desc); + return -EINVAL; + } + + total_record_size = sec_hdrlen + + (__u64)num_records * record_size; + if (info_left < total_record_size) { + pr_debug("%s section has incorrect num_records in .BTF.ext\n", + ext_sec->desc); + return -EINVAL; + } + + info_left -= total_record_size; + sinfo = (void *)sinfo + total_record_size; + } + + ext_info = ext_sec->ext_info; + ext_info->len = ext_sec->len - sizeof(__u32); + ext_info->rec_size = record_size; + ext_info->info = info + sizeof(__u32); + + return 0; +} + +static int btf_ext_setup_func_info(struct btf_ext *btf_ext) +{ + struct btf_ext_sec_setup_param param = { + .off = btf_ext->hdr->func_info_off, + .len = btf_ext->hdr->func_info_len, + .min_rec_size = sizeof(struct bpf_func_info_min), + .ext_info = &btf_ext->func_info, + .desc = "func_info" + }; + + return btf_ext_setup_info(btf_ext, ¶m); +} + +static int btf_ext_setup_line_info(struct btf_ext *btf_ext) +{ + struct btf_ext_sec_setup_param param = { + .off = btf_ext->hdr->line_info_off, + .len = btf_ext->hdr->line_info_len, + .min_rec_size = sizeof(struct bpf_line_info_min), + .ext_info = &btf_ext->line_info, + .desc = "line_info", + }; + + return btf_ext_setup_info(btf_ext, ¶m); +} + +static int btf_ext_setup_core_relos(struct btf_ext *btf_ext) +{ + struct btf_ext_sec_setup_param param = { + .off = btf_ext->hdr->core_relo_off, + .len = btf_ext->hdr->core_relo_len, + .min_rec_size = sizeof(struct bpf_core_relo), + .ext_info = &btf_ext->core_relo_info, + .desc = "core_relo", + }; + + return btf_ext_setup_info(btf_ext, ¶m); +} + +static int btf_ext_parse_hdr(__u8 *data, __u32 data_size) +{ + const struct btf_ext_header *hdr = (struct btf_ext_header *)data; + + if (data_size < offsetofend(struct btf_ext_header, hdr_len) || + data_size < hdr->hdr_len) { + pr_debug("BTF.ext header not found"); + return -EINVAL; + } + + if (hdr->magic == bswap_16(BTF_MAGIC)) { + pr_warn("BTF.ext in non-native endianness is not supported\n"); + return -ENOTSUP; + } else if (hdr->magic != BTF_MAGIC) { + pr_debug("Invalid BTF.ext magic:%x\n", hdr->magic); + return -EINVAL; + } + + if (hdr->version != BTF_VERSION) { + pr_debug("Unsupported BTF.ext version:%u\n", hdr->version); + return -ENOTSUP; + } + + if (hdr->flags) { + pr_debug("Unsupported BTF.ext flags:%x\n", hdr->flags); + return -ENOTSUP; + } + + if (data_size == hdr->hdr_len) { + pr_debug("BTF.ext has no data\n"); + return -EINVAL; + } + + return 0; +} + +void btf_ext__free(struct btf_ext *btf_ext) +{ + if (IS_ERR_OR_NULL(btf_ext)) + return; + free(btf_ext->data); + free(btf_ext); +} + +struct btf_ext *btf_ext__new(__u8 *data, __u32 size) +{ + struct btf_ext *btf_ext; + int err; + + err = btf_ext_parse_hdr(data, size); + if (err) + return ERR_PTR(err); + + btf_ext = calloc(1, sizeof(struct btf_ext)); + if (!btf_ext) + return ERR_PTR(-ENOMEM); + + btf_ext->data_size = size; + btf_ext->data = malloc(size); + if (!btf_ext->data) { + err = -ENOMEM; + goto done; + } + memcpy(btf_ext->data, data, size); + + if (btf_ext->hdr->hdr_len < + offsetofend(struct btf_ext_header, line_info_len)) + goto done; + err = btf_ext_setup_func_info(btf_ext); + if (err) + goto done; + + err = btf_ext_setup_line_info(btf_ext); + if (err) + goto done; + + if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, core_relo_len)) + goto done; + err = btf_ext_setup_core_relos(btf_ext); + if (err) + goto done; + +done: + if (err) { + btf_ext__free(btf_ext); + return ERR_PTR(err); + } + + return btf_ext; +} + +const void *btf_ext__get_raw_data(const struct btf_ext *btf_ext, __u32 *size) +{ + *size = btf_ext->data_size; + return btf_ext->data; +} + +static int btf_ext_reloc_info(const struct btf *btf, + const struct btf_ext_info *ext_info, + const char *sec_name, __u32 insns_cnt, + void **info, __u32 *cnt) +{ + __u32 sec_hdrlen = sizeof(struct btf_ext_info_sec); + __u32 i, record_size, existing_len, records_len; + struct btf_ext_info_sec *sinfo; + const char *info_sec_name; + __u64 remain_len; + void *data; + + record_size = ext_info->rec_size; + sinfo = ext_info->info; + remain_len = ext_info->len; + while (remain_len > 0) { + records_len = sinfo->num_info * record_size; + info_sec_name = btf__name_by_offset(btf, sinfo->sec_name_off); + if (strcmp(info_sec_name, sec_name)) { + remain_len -= sec_hdrlen + records_len; + sinfo = (void *)sinfo + sec_hdrlen + records_len; + continue; + } + + existing_len = (*cnt) * record_size; + data = realloc(*info, existing_len + records_len); + if (!data) + return -ENOMEM; + + memcpy(data + existing_len, sinfo->data, records_len); + /* adjust insn_off only, the rest data will be passed + * to the kernel. + */ + for (i = 0; i < sinfo->num_info; i++) { + __u32 *insn_off; + + insn_off = data + existing_len + (i * record_size); + *insn_off = *insn_off / sizeof(struct bpf_insn) + + insns_cnt; + } + *info = data; + *cnt += sinfo->num_info; + return 0; + } + + return -ENOENT; +} + +int btf_ext__reloc_func_info(const struct btf *btf, + const struct btf_ext *btf_ext, + const char *sec_name, __u32 insns_cnt, + void **func_info, __u32 *cnt) +{ + return btf_ext_reloc_info(btf, &btf_ext->func_info, sec_name, + insns_cnt, func_info, cnt); +} + +int btf_ext__reloc_line_info(const struct btf *btf, + const struct btf_ext *btf_ext, + const char *sec_name, __u32 insns_cnt, + void **line_info, __u32 *cnt) +{ + return btf_ext_reloc_info(btf, &btf_ext->line_info, sec_name, + insns_cnt, line_info, cnt); +} + +__u32 btf_ext__func_info_rec_size(const struct btf_ext *btf_ext) +{ + return btf_ext->func_info.rec_size; +} + +__u32 btf_ext__line_info_rec_size(const struct btf_ext *btf_ext) +{ + return btf_ext->line_info.rec_size; +} + +struct btf_dedup; + +static struct btf_dedup *btf_dedup_new(struct btf *btf, struct btf_ext *btf_ext, + const struct btf_dedup_opts *opts); +static void btf_dedup_free(struct btf_dedup *d); +static int btf_dedup_prep(struct btf_dedup *d); +static int btf_dedup_strings(struct btf_dedup *d); +static int btf_dedup_prim_types(struct btf_dedup *d); +static int btf_dedup_struct_types(struct btf_dedup *d); +static int btf_dedup_ref_types(struct btf_dedup *d); +static int btf_dedup_compact_types(struct btf_dedup *d); +static int btf_dedup_remap_types(struct btf_dedup *d); + +/* + * Deduplicate BTF types and strings. + * + * BTF dedup algorithm takes as an input `struct btf` representing `.BTF` ELF + * section with all BTF type descriptors and string data. It overwrites that + * memory in-place with deduplicated types and strings without any loss of + * information. If optional `struct btf_ext` representing '.BTF.ext' ELF section + * is provided, all the strings referenced from .BTF.ext section are honored + * and updated to point to the right offsets after deduplication. + * + * If function returns with error, type/string data might be garbled and should + * be discarded. + * + * More verbose and detailed description of both problem btf_dedup is solving, + * as well as solution could be found at: + * https://facebookmicrosites.github.io/bpf/blog/2018/11/14/btf-enhancement.html + * + * Problem description and justification + * ===================================== + * + * BTF type information is typically emitted either as a result of conversion + * from DWARF to BTF or directly by compiler. In both cases, each compilation + * unit contains information about a subset of all the types that are used + * in an application. These subsets are frequently overlapping and contain a lot + * of duplicated information when later concatenated together into a single + * binary. This algorithm ensures that each unique type is represented by single + * BTF type descriptor, greatly reducing resulting size of BTF data. + * + * Compilation unit isolation and subsequent duplication of data is not the only + * problem. The same type hierarchy (e.g., struct and all the type that struct + * references) in different compilation units can be represented in BTF to + * various degrees of completeness (or, rather, incompleteness) due to + * struct/union forward declarations. + * + * Let's take a look at an example, that we'll use to better understand the + * problem (and solution). Suppose we have two compilation units, each using + * same `struct S`, but each of them having incomplete type information about + * struct's fields: + * + * // CU #1: + * struct S; + * struct A { + * int a; + * struct A* self; + * struct S* parent; + * }; + * struct B; + * struct S { + * struct A* a_ptr; + * struct B* b_ptr; + * }; + * + * // CU #2: + * struct S; + * struct A; + * struct B { + * int b; + * struct B* self; + * struct S* parent; + * }; + * struct S { + * struct A* a_ptr; + * struct B* b_ptr; + * }; + * + * In case of CU #1, BTF data will know only that `struct B` exist (but no + * more), but will know the complete type information about `struct A`. While + * for CU #2, it will know full type information about `struct B`, but will + * only know about forward declaration of `struct A` (in BTF terms, it will + * have `BTF_KIND_FWD` type descriptor with name `B`). + * + * This compilation unit isolation means that it's possible that there is no + * single CU with complete type information describing structs `S`, `A`, and + * `B`. Also, we might get tons of duplicated and redundant type information. + * + * Additional complication we need to keep in mind comes from the fact that + * types, in general, can form graphs containing cycles, not just DAGs. + * + * While algorithm does deduplication, it also merges and resolves type + * information (unless disabled throught `struct btf_opts`), whenever possible. + * E.g., in the example above with two compilation units having partial type + * information for structs `A` and `B`, the output of algorithm will emit + * a single copy of each BTF type that describes structs `A`, `B`, and `S` + * (as well as type information for `int` and pointers), as if they were defined + * in a single compilation unit as: + * + * struct A { + * int a; + * struct A* self; + * struct S* parent; + * }; + * struct B { + * int b; + * struct B* self; + * struct S* parent; + * }; + * struct S { + * struct A* a_ptr; + * struct B* b_ptr; + * }; + * + * Algorithm summary + * ================= + * + * Algorithm completes its work in 6 separate passes: + * + * 1. Strings deduplication. + * 2. Primitive types deduplication (int, enum, fwd). + * 3. Struct/union types deduplication. + * 4. Reference types deduplication (pointers, typedefs, arrays, funcs, func + * protos, and const/volatile/restrict modifiers). + * 5. Types compaction. + * 6. Types remapping. + * + * Algorithm determines canonical type descriptor, which is a single + * representative type for each truly unique type. This canonical type is the + * one that will go into final deduplicated BTF type information. For + * struct/unions, it is also the type that algorithm will merge additional type + * information into (while resolving FWDs), as it discovers it from data in + * other CUs. Each input BTF type eventually gets either mapped to itself, if + * that type is canonical, or to some other type, if that type is equivalent + * and was chosen as canonical representative. This mapping is stored in + * `btf_dedup->map` array. This map is also used to record STRUCT/UNION that + * FWD type got resolved to. + * + * To facilitate fast discovery of canonical types, we also maintain canonical + * index (`btf_dedup->dedup_table`), which maps type descriptor's signature hash + * (i.e., hashed kind, name, size, fields, etc) into a list of canonical types + * that match that signature. With sufficiently good choice of type signature + * hashing function, we can limit number of canonical types for each unique type + * signature to a very small number, allowing to find canonical type for any + * duplicated type very quickly. + * + * Struct/union deduplication is the most critical part and algorithm for + * deduplicating structs/unions is described in greater details in comments for + * `btf_dedup_is_equiv` function. + */ +int btf__dedup(struct btf *btf, struct btf_ext *btf_ext, + const struct btf_dedup_opts *opts) +{ + struct btf_dedup *d = btf_dedup_new(btf, btf_ext, opts); + int err; + + if (IS_ERR(d)) { + pr_debug("btf_dedup_new failed: %ld", PTR_ERR(d)); + return -EINVAL; + } + + if (btf_ensure_modifiable(btf)) + return -ENOMEM; + + err = btf_dedup_prep(d); + if (err) { + pr_debug("btf_dedup_prep failed:%d\n", err); + goto done; + } + err = btf_dedup_strings(d); + if (err < 0) { + pr_debug("btf_dedup_strings failed:%d\n", err); + goto done; + } + err = btf_dedup_prim_types(d); + if (err < 0) { + pr_debug("btf_dedup_prim_types failed:%d\n", err); + goto done; + } + err = btf_dedup_struct_types(d); + if (err < 0) { + pr_debug("btf_dedup_struct_types failed:%d\n", err); + goto done; + } + err = btf_dedup_ref_types(d); + if (err < 0) { + pr_debug("btf_dedup_ref_types failed:%d\n", err); + goto done; + } + err = btf_dedup_compact_types(d); + if (err < 0) { + pr_debug("btf_dedup_compact_types failed:%d\n", err); + goto done; + } + err = btf_dedup_remap_types(d); + if (err < 0) { + pr_debug("btf_dedup_remap_types failed:%d\n", err); + goto done; + } + +done: + btf_dedup_free(d); + return err; +} + +#define BTF_UNPROCESSED_ID ((__u32)-1) +#define BTF_IN_PROGRESS_ID ((__u32)-2) + +struct btf_dedup { + /* .BTF section to be deduped in-place */ + struct btf *btf; + /* + * Optional .BTF.ext section. When provided, any strings referenced + * from it will be taken into account when deduping strings + */ + struct btf_ext *btf_ext; + /* + * This is a map from any type's signature hash to a list of possible + * canonical representative type candidates. Hash collisions are + * ignored, so even types of various kinds can share same list of + * candidates, which is fine because we rely on subsequent + * btf_xxx_equal() checks to authoritatively verify type equality. + */ + struct hashmap *dedup_table; + /* Canonical types map */ + __u32 *map; + /* Hypothetical mapping, used during type graph equivalence checks */ + __u32 *hypot_map; + __u32 *hypot_list; + size_t hypot_cnt; + size_t hypot_cap; + /* Whether hypothetical mapping, if successful, would need to adjust + * already canonicalized types (due to a new forward declaration to + * concrete type resolution). In such case, during split BTF dedup + * candidate type would still be considered as different, because base + * BTF is considered to be immutable. + */ + bool hypot_adjust_canon; + /* Various option modifying behavior of algorithm */ + struct btf_dedup_opts opts; + /* temporary strings deduplication state */ + void *strs_data; + size_t strs_cap; + size_t strs_len; + struct hashmap* strs_hash; +}; + +static long hash_combine(long h, long value) +{ + return h * 31 + value; +} + +#define for_each_dedup_cand(d, node, hash) \ + hashmap__for_each_key_entry(d->dedup_table, node, (void *)hash) + +static int btf_dedup_table_add(struct btf_dedup *d, long hash, __u32 type_id) +{ + return hashmap__append(d->dedup_table, + (void *)hash, (void *)(long)type_id); +} + +static int btf_dedup_hypot_map_add(struct btf_dedup *d, + __u32 from_id, __u32 to_id) +{ + if (d->hypot_cnt == d->hypot_cap) { + __u32 *new_list; + + d->hypot_cap += max((size_t)16, d->hypot_cap / 2); + new_list = libbpf_reallocarray(d->hypot_list, d->hypot_cap, sizeof(__u32)); + if (!new_list) + return -ENOMEM; + d->hypot_list = new_list; + } + d->hypot_list[d->hypot_cnt++] = from_id; + d->hypot_map[from_id] = to_id; + return 0; +} + +static void btf_dedup_clear_hypot_map(struct btf_dedup *d) +{ + int i; + + for (i = 0; i < d->hypot_cnt; i++) + d->hypot_map[d->hypot_list[i]] = BTF_UNPROCESSED_ID; + d->hypot_cnt = 0; + d->hypot_adjust_canon = false; +} + +static void btf_dedup_free(struct btf_dedup *d) +{ + hashmap__free(d->dedup_table); + d->dedup_table = NULL; + + free(d->map); + d->map = NULL; + + free(d->hypot_map); + d->hypot_map = NULL; + + free(d->hypot_list); + d->hypot_list = NULL; + + free(d); +} + +static size_t btf_dedup_identity_hash_fn(const void *key, void *ctx) +{ + return (size_t)key; +} + +static size_t btf_dedup_collision_hash_fn(const void *key, void *ctx) +{ + return 0; +} + +static bool btf_dedup_equal_fn(const void *k1, const void *k2, void *ctx) +{ + return k1 == k2; +} + +static struct btf_dedup *btf_dedup_new(struct btf *btf, struct btf_ext *btf_ext, + const struct btf_dedup_opts *opts) +{ + struct btf_dedup *d = calloc(1, sizeof(struct btf_dedup)); + hashmap_hash_fn hash_fn = btf_dedup_identity_hash_fn; + int i, err = 0, type_cnt; + + if (!d) + return ERR_PTR(-ENOMEM); + + d->opts.dont_resolve_fwds = opts && opts->dont_resolve_fwds; + /* dedup_table_size is now used only to force collisions in tests */ + if (opts && opts->dedup_table_size == 1) + hash_fn = btf_dedup_collision_hash_fn; + + d->btf = btf; + d->btf_ext = btf_ext; + + d->dedup_table = hashmap__new(hash_fn, btf_dedup_equal_fn, NULL); + if (IS_ERR(d->dedup_table)) { + err = PTR_ERR(d->dedup_table); + d->dedup_table = NULL; + goto done; + } + + type_cnt = btf__get_nr_types(btf) + 1; + d->map = malloc(sizeof(__u32) * type_cnt); + if (!d->map) { + err = -ENOMEM; + goto done; + } + /* special BTF "void" type is made canonical immediately */ + d->map[0] = 0; + for (i = 1; i < type_cnt; i++) { + struct btf_type *t = btf_type_by_id(d->btf, i); + + /* VAR and DATASEC are never deduped and are self-canonical */ + if (btf_is_var(t) || btf_is_datasec(t)) + d->map[i] = i; + else + d->map[i] = BTF_UNPROCESSED_ID; + } + + d->hypot_map = malloc(sizeof(__u32) * type_cnt); + if (!d->hypot_map) { + err = -ENOMEM; + goto done; + } + for (i = 0; i < type_cnt; i++) + d->hypot_map[i] = BTF_UNPROCESSED_ID; + +done: + if (err) { + btf_dedup_free(d); + return ERR_PTR(err); + } + + return d; +} + +typedef int (*str_off_fn_t)(__u32 *str_off_ptr, void *ctx); + +/* + * Iterate over all possible places in .BTF and .BTF.ext that can reference + * string and pass pointer to it to a provided callback `fn`. + */ +static int btf_for_each_str_off(struct btf_dedup *d, str_off_fn_t fn, void *ctx) +{ + void *line_data_cur, *line_data_end; + int i, j, r, rec_size; + struct btf_type *t; + + for (i = 0; i < d->btf->nr_types; i++) { + t = btf_type_by_id(d->btf, d->btf->start_id + i); + r = fn(&t->name_off, ctx); + if (r) + return r; + + switch (btf_kind(t)) { + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: { + struct btf_member *m = btf_members(t); + __u16 vlen = btf_vlen(t); + + for (j = 0; j < vlen; j++) { + r = fn(&m->name_off, ctx); + if (r) + return r; + m++; + } + break; + } + case BTF_KIND_ENUM: { + struct btf_enum *m = btf_enum(t); + __u16 vlen = btf_vlen(t); + + for (j = 0; j < vlen; j++) { + r = fn(&m->name_off, ctx); + if (r) + return r; + m++; + } + break; + } + case BTF_KIND_FUNC_PROTO: { + struct btf_param *m = btf_params(t); + __u16 vlen = btf_vlen(t); + + for (j = 0; j < vlen; j++) { + r = fn(&m->name_off, ctx); + if (r) + return r; + m++; + } + break; + } + default: + break; + } + } + + if (!d->btf_ext) + return 0; + + line_data_cur = d->btf_ext->line_info.info; + line_data_end = d->btf_ext->line_info.info + d->btf_ext->line_info.len; + rec_size = d->btf_ext->line_info.rec_size; + + while (line_data_cur < line_data_end) { + struct btf_ext_info_sec *sec = line_data_cur; + struct bpf_line_info_min *line_info; + __u32 num_info = sec->num_info; + + r = fn(&sec->sec_name_off, ctx); + if (r) + return r; + + line_data_cur += sizeof(struct btf_ext_info_sec); + for (i = 0; i < num_info; i++) { + line_info = line_data_cur; + r = fn(&line_info->file_name_off, ctx); + if (r) + return r; + r = fn(&line_info->line_off, ctx); + if (r) + return r; + line_data_cur += rec_size; + } + } + + return 0; +} + +static int strs_dedup_remap_str_off(__u32 *str_off_ptr, void *ctx) +{ + struct btf_dedup *d = ctx; + __u32 str_off = *str_off_ptr; + long old_off, new_off, len; + const char *s; + void *p; + int err; + + /* don't touch empty string or string in main BTF */ + if (str_off == 0 || str_off < d->btf->start_str_off) + return 0; + + s = btf__str_by_offset(d->btf, str_off); + if (d->btf->base_btf) { + err = btf__find_str(d->btf->base_btf, s); + if (err >= 0) { + *str_off_ptr = err; + return 0; + } + if (err != -ENOENT) + return err; + } + + len = strlen(s) + 1; + + new_off = d->strs_len; + p = btf_add_mem(&d->strs_data, &d->strs_cap, 1, new_off, BTF_MAX_STR_OFFSET, len); + if (!p) + return -ENOMEM; + + memcpy(p, s, len); + + /* Now attempt to add the string, but only if the string with the same + * contents doesn't exist already (HASHMAP_ADD strategy). If such + * string exists, we'll get its offset in old_off (that's old_key). + */ + err = hashmap__insert(d->strs_hash, (void *)new_off, (void *)new_off, + HASHMAP_ADD, (const void **)&old_off, NULL); + if (err == -EEXIST) { + *str_off_ptr = d->btf->start_str_off + old_off; + } else if (err) { + return err; + } else { + *str_off_ptr = d->btf->start_str_off + new_off; + d->strs_len += len; + } + return 0; +} + +/* + * Dedup string and filter out those that are not referenced from either .BTF + * or .BTF.ext (if provided) sections. + * + * This is done by building index of all strings in BTF's string section, + * then iterating over all entities that can reference strings (e.g., type + * names, struct field names, .BTF.ext line info, etc) and marking corresponding + * strings as used. After that all used strings are deduped and compacted into + * sequential blob of memory and new offsets are calculated. Then all the string + * references are iterated again and rewritten using new offsets. + */ +static int btf_dedup_strings(struct btf_dedup *d) +{ + char *s; + int err; + + if (d->btf->strs_deduped) + return 0; + + /* temporarily switch to use btf_dedup's strs_data for strings for hash + * functions; later we'll just transfer hashmap to struct btf as is, + * along the strs_data + */ + d->btf->strs_data_ptr = &d->strs_data; + + d->strs_hash = hashmap__new(strs_hash_fn, strs_hash_equal_fn, d->btf); + if (IS_ERR(d->strs_hash)) { + err = PTR_ERR(d->strs_hash); + d->strs_hash = NULL; + goto err_out; + } + + if (!d->btf->base_btf) { + s = btf_add_mem(&d->strs_data, &d->strs_cap, 1, d->strs_len, BTF_MAX_STR_OFFSET, 1); + if (!s) + return -ENOMEM; + /* initial empty string */ + s[0] = 0; + d->strs_len = 1; + + /* insert empty string; we won't be looking it up during strings + * dedup, but it's good to have it for generic BTF string lookups + */ + err = hashmap__insert(d->strs_hash, (void *)0, (void *)0, + HASHMAP_ADD, NULL, NULL); + if (err) + goto err_out; + } + + /* remap string offsets */ + err = btf_for_each_str_off(d, strs_dedup_remap_str_off, d); + if (err) + goto err_out; + + /* replace BTF string data and hash with deduped ones */ + free(d->btf->strs_data); + hashmap__free(d->btf->strs_hash); + d->btf->strs_data = d->strs_data; + d->btf->strs_data_cap = d->strs_cap; + d->btf->hdr->str_len = d->strs_len; + d->btf->strs_hash = d->strs_hash; + /* now point strs_data_ptr back to btf->strs_data */ + d->btf->strs_data_ptr = &d->btf->strs_data; + + d->strs_data = d->strs_hash = NULL; + d->strs_len = d->strs_cap = 0; + d->btf->strs_deduped = true; + return 0; + +err_out: + free(d->strs_data); + hashmap__free(d->strs_hash); + d->strs_data = d->strs_hash = NULL; + d->strs_len = d->strs_cap = 0; + + /* restore strings pointer for existing d->btf->strs_hash back */ + d->btf->strs_data_ptr = &d->strs_data; + + return err; +} + +static long btf_hash_common(struct btf_type *t) +{ + long h; + + h = hash_combine(0, t->name_off); + h = hash_combine(h, t->info); + h = hash_combine(h, t->size); + return h; +} + +static bool btf_equal_common(struct btf_type *t1, struct btf_type *t2) +{ + return t1->name_off == t2->name_off && + t1->info == t2->info && + t1->size == t2->size; +} + +/* Calculate type signature hash of INT. */ +static long btf_hash_int(struct btf_type *t) +{ + __u32 info = *(__u32 *)(t + 1); + long h; + + h = btf_hash_common(t); + h = hash_combine(h, info); + return h; +} + +/* Check structural equality of two INTs. */ +static bool btf_equal_int(struct btf_type *t1, struct btf_type *t2) +{ + __u32 info1, info2; + + if (!btf_equal_common(t1, t2)) + return false; + info1 = *(__u32 *)(t1 + 1); + info2 = *(__u32 *)(t2 + 1); + return info1 == info2; +} + +/* Calculate type signature hash of ENUM. */ +static long btf_hash_enum(struct btf_type *t) +{ + long h; + + /* don't hash vlen and enum members to support enum fwd resolving */ + h = hash_combine(0, t->name_off); + h = hash_combine(h, t->info & ~0xffff); + h = hash_combine(h, t->size); + return h; +} + +/* Check structural equality of two ENUMs. */ +static bool btf_equal_enum(struct btf_type *t1, struct btf_type *t2) +{ + const struct btf_enum *m1, *m2; + __u16 vlen; + int i; + + if (!btf_equal_common(t1, t2)) + return false; + + vlen = btf_vlen(t1); + m1 = btf_enum(t1); + m2 = btf_enum(t2); + for (i = 0; i < vlen; i++) { + if (m1->name_off != m2->name_off || m1->val != m2->val) + return false; + m1++; + m2++; + } + return true; +} + +static inline bool btf_is_enum_fwd(struct btf_type *t) +{ + return btf_is_enum(t) && btf_vlen(t) == 0; +} + +static bool btf_compat_enum(struct btf_type *t1, struct btf_type *t2) +{ + if (!btf_is_enum_fwd(t1) && !btf_is_enum_fwd(t2)) + return btf_equal_enum(t1, t2); + /* ignore vlen when comparing */ + return t1->name_off == t2->name_off && + (t1->info & ~0xffff) == (t2->info & ~0xffff) && + t1->size == t2->size; +} + +/* + * Calculate type signature hash of STRUCT/UNION, ignoring referenced type IDs, + * as referenced type IDs equivalence is established separately during type + * graph equivalence check algorithm. + */ +static long btf_hash_struct(struct btf_type *t) +{ + const struct btf_member *member = btf_members(t); + __u32 vlen = btf_vlen(t); + long h = btf_hash_common(t); + int i; + + for (i = 0; i < vlen; i++) { + h = hash_combine(h, member->name_off); + h = hash_combine(h, member->offset); + /* no hashing of referenced type ID, it can be unresolved yet */ + member++; + } + return h; +} + +/* + * Check structural compatibility of two FUNC_PROTOs, ignoring referenced type + * IDs. This check is performed during type graph equivalence check and + * referenced types equivalence is checked separately. + */ +static bool btf_shallow_equal_struct(struct btf_type *t1, struct btf_type *t2) +{ + const struct btf_member *m1, *m2; + __u16 vlen; + int i; + + if (!btf_equal_common(t1, t2)) + return false; + + vlen = btf_vlen(t1); + m1 = btf_members(t1); + m2 = btf_members(t2); + for (i = 0; i < vlen; i++) { + if (m1->name_off != m2->name_off || m1->offset != m2->offset) + return false; + m1++; + m2++; + } + return true; +} + +/* + * Calculate type signature hash of ARRAY, including referenced type IDs, + * under assumption that they were already resolved to canonical type IDs and + * are not going to change. + */ +static long btf_hash_array(struct btf_type *t) +{ + const struct btf_array *info = btf_array(t); + long h = btf_hash_common(t); + + h = hash_combine(h, info->type); + h = hash_combine(h, info->index_type); + h = hash_combine(h, info->nelems); + return h; +} + +/* + * Check exact equality of two ARRAYs, taking into account referenced + * type IDs, under assumption that they were already resolved to canonical + * type IDs and are not going to change. + * This function is called during reference types deduplication to compare + * ARRAY to potential canonical representative. + */ +static bool btf_equal_array(struct btf_type *t1, struct btf_type *t2) +{ + const struct btf_array *info1, *info2; + + if (!btf_equal_common(t1, t2)) + return false; + + info1 = btf_array(t1); + info2 = btf_array(t2); + return info1->type == info2->type && + info1->index_type == info2->index_type && + info1->nelems == info2->nelems; +} + +/* + * Check structural compatibility of two ARRAYs, ignoring referenced type + * IDs. This check is performed during type graph equivalence check and + * referenced types equivalence is checked separately. + */ +static bool btf_compat_array(struct btf_type *t1, struct btf_type *t2) +{ + if (!btf_equal_common(t1, t2)) + return false; + + return btf_array(t1)->nelems == btf_array(t2)->nelems; +} + +/* + * Calculate type signature hash of FUNC_PROTO, including referenced type IDs, + * under assumption that they were already resolved to canonical type IDs and + * are not going to change. + */ +static long btf_hash_fnproto(struct btf_type *t) +{ + const struct btf_param *member = btf_params(t); + __u16 vlen = btf_vlen(t); + long h = btf_hash_common(t); + int i; + + for (i = 0; i < vlen; i++) { + h = hash_combine(h, member->name_off); + h = hash_combine(h, member->type); + member++; + } + return h; +} + +/* + * Check exact equality of two FUNC_PROTOs, taking into account referenced + * type IDs, under assumption that they were already resolved to canonical + * type IDs and are not going to change. + * This function is called during reference types deduplication to compare + * FUNC_PROTO to potential canonical representative. + */ +static bool btf_equal_fnproto(struct btf_type *t1, struct btf_type *t2) +{ + const struct btf_param *m1, *m2; + __u16 vlen; + int i; + + if (!btf_equal_common(t1, t2)) + return false; + + vlen = btf_vlen(t1); + m1 = btf_params(t1); + m2 = btf_params(t2); + for (i = 0; i < vlen; i++) { + if (m1->name_off != m2->name_off || m1->type != m2->type) + return false; + m1++; + m2++; + } + return true; +} + +/* + * Check structural compatibility of two FUNC_PROTOs, ignoring referenced type + * IDs. This check is performed during type graph equivalence check and + * referenced types equivalence is checked separately. + */ +static bool btf_compat_fnproto(struct btf_type *t1, struct btf_type *t2) +{ + const struct btf_param *m1, *m2; + __u16 vlen; + int i; + + /* skip return type ID */ + if (t1->name_off != t2->name_off || t1->info != t2->info) + return false; + + vlen = btf_vlen(t1); + m1 = btf_params(t1); + m2 = btf_params(t2); + for (i = 0; i < vlen; i++) { + if (m1->name_off != m2->name_off) + return false; + m1++; + m2++; + } + return true; +} + +/* Prepare split BTF for deduplication by calculating hashes of base BTF's + * types and initializing the rest of the state (canonical type mapping) for + * the fixed base BTF part. + */ +static int btf_dedup_prep(struct btf_dedup *d) +{ + struct btf_type *t; + int type_id; + long h; + + if (!d->btf->base_btf) + return 0; + + for (type_id = 1; type_id < d->btf->start_id; type_id++) { + t = btf_type_by_id(d->btf, type_id); + + /* all base BTF types are self-canonical by definition */ + d->map[type_id] = type_id; + + switch (btf_kind(t)) { + case BTF_KIND_VAR: + case BTF_KIND_DATASEC: + /* VAR and DATASEC are never hash/deduplicated */ + continue; + case BTF_KIND_CONST: + case BTF_KIND_VOLATILE: + case BTF_KIND_RESTRICT: + case BTF_KIND_PTR: + case BTF_KIND_FWD: + case BTF_KIND_TYPEDEF: + case BTF_KIND_FUNC: + case BTF_KIND_FLOAT: + h = btf_hash_common(t); + break; + case BTF_KIND_INT: + h = btf_hash_int(t); + break; + case BTF_KIND_ENUM: + h = btf_hash_enum(t); + break; + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: + h = btf_hash_struct(t); + break; + case BTF_KIND_ARRAY: + h = btf_hash_array(t); + break; + case BTF_KIND_FUNC_PROTO: + h = btf_hash_fnproto(t); + break; + default: + pr_debug("unknown kind %d for type [%d]\n", btf_kind(t), type_id); + return -EINVAL; + } + if (btf_dedup_table_add(d, h, type_id)) + return -ENOMEM; + } + + return 0; +} + +/* + * Deduplicate primitive types, that can't reference other types, by calculating + * their type signature hash and comparing them with any possible canonical + * candidate. If no canonical candidate matches, type itself is marked as + * canonical and is added into `btf_dedup->dedup_table` as another candidate. + */ +static int btf_dedup_prim_type(struct btf_dedup *d, __u32 type_id) +{ + struct btf_type *t = btf_type_by_id(d->btf, type_id); + struct hashmap_entry *hash_entry; + struct btf_type *cand; + /* if we don't find equivalent type, then we are canonical */ + __u32 new_id = type_id; + __u32 cand_id; + long h; + + switch (btf_kind(t)) { + case BTF_KIND_CONST: + case BTF_KIND_VOLATILE: + case BTF_KIND_RESTRICT: + case BTF_KIND_PTR: + case BTF_KIND_TYPEDEF: + case BTF_KIND_ARRAY: + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: + case BTF_KIND_FUNC: + case BTF_KIND_FUNC_PROTO: + case BTF_KIND_VAR: + case BTF_KIND_DATASEC: + return 0; + + case BTF_KIND_INT: + h = btf_hash_int(t); + for_each_dedup_cand(d, hash_entry, h) { + cand_id = (__u32)(long)hash_entry->value; + cand = btf_type_by_id(d->btf, cand_id); + if (btf_equal_int(t, cand)) { + new_id = cand_id; + break; + } + } + break; + + case BTF_KIND_ENUM: + h = btf_hash_enum(t); + for_each_dedup_cand(d, hash_entry, h) { + cand_id = (__u32)(long)hash_entry->value; + cand = btf_type_by_id(d->btf, cand_id); + if (btf_equal_enum(t, cand)) { + new_id = cand_id; + break; + } + if (d->opts.dont_resolve_fwds) + continue; + if (btf_compat_enum(t, cand)) { + if (btf_is_enum_fwd(t)) { + /* resolve fwd to full enum */ + new_id = cand_id; + break; + } + /* resolve canonical enum fwd to full enum */ + d->map[cand_id] = type_id; + } + } + break; + + case BTF_KIND_FWD: + case BTF_KIND_FLOAT: + h = btf_hash_common(t); + for_each_dedup_cand(d, hash_entry, h) { + cand_id = (__u32)(long)hash_entry->value; + cand = btf_type_by_id(d->btf, cand_id); + if (btf_equal_common(t, cand)) { + new_id = cand_id; + break; + } + } + break; + + default: + return -EINVAL; + } + + d->map[type_id] = new_id; + if (type_id == new_id && btf_dedup_table_add(d, h, type_id)) + return -ENOMEM; + + return 0; +} + +static int btf_dedup_prim_types(struct btf_dedup *d) +{ + int i, err; + + for (i = 0; i < d->btf->nr_types; i++) { + err = btf_dedup_prim_type(d, d->btf->start_id + i); + if (err) + return err; + } + return 0; +} + +/* + * Check whether type is already mapped into canonical one (could be to itself). + */ +static inline bool is_type_mapped(struct btf_dedup *d, uint32_t type_id) +{ + return d->map[type_id] <= BTF_MAX_NR_TYPES; +} + +/* + * Resolve type ID into its canonical type ID, if any; otherwise return original + * type ID. If type is FWD and is resolved into STRUCT/UNION already, follow + * STRUCT/UNION link and resolve it into canonical type ID as well. + */ +static inline __u32 resolve_type_id(struct btf_dedup *d, __u32 type_id) +{ + while (is_type_mapped(d, type_id) && d->map[type_id] != type_id) + type_id = d->map[type_id]; + return type_id; +} + +/* + * Resolve FWD to underlying STRUCT/UNION, if any; otherwise return original + * type ID. + */ +static uint32_t resolve_fwd_id(struct btf_dedup *d, uint32_t type_id) +{ + __u32 orig_type_id = type_id; + + if (!btf_is_fwd(btf__type_by_id(d->btf, type_id))) + return type_id; + + while (is_type_mapped(d, type_id) && d->map[type_id] != type_id) + type_id = d->map[type_id]; + + if (!btf_is_fwd(btf__type_by_id(d->btf, type_id))) + return type_id; + + return orig_type_id; +} + + +static inline __u16 btf_fwd_kind(struct btf_type *t) +{ + return btf_kflag(t) ? BTF_KIND_UNION : BTF_KIND_STRUCT; +} + +/* Check if given two types are identical ARRAY definitions */ +static int btf_dedup_identical_arrays(struct btf_dedup *d, __u32 id1, __u32 id2) +{ + struct btf_type *t1, *t2; + + t1 = btf_type_by_id(d->btf, id1); + t2 = btf_type_by_id(d->btf, id2); + if (!btf_is_array(t1) || !btf_is_array(t2)) + return 0; + + return btf_equal_array(t1, t2); +} + +/* + * Check equivalence of BTF type graph formed by candidate struct/union (we'll + * call it "candidate graph" in this description for brevity) to a type graph + * formed by (potential) canonical struct/union ("canonical graph" for brevity + * here, though keep in mind that not all types in canonical graph are + * necessarily canonical representatives themselves, some of them might be + * duplicates or its uniqueness might not have been established yet). + * Returns: + * - >0, if type graphs are equivalent; + * - 0, if not equivalent; + * - <0, on error. + * + * Algorithm performs side-by-side DFS traversal of both type graphs and checks + * equivalence of BTF types at each step. If at any point BTF types in candidate + * and canonical graphs are not compatible structurally, whole graphs are + * incompatible. If types are structurally equivalent (i.e., all information + * except referenced type IDs is exactly the same), a mapping from `canon_id` to + * a `cand_id` is recored in hypothetical mapping (`btf_dedup->hypot_map`). + * If a type references other types, then those referenced types are checked + * for equivalence recursively. + * + * During DFS traversal, if we find that for current `canon_id` type we + * already have some mapping in hypothetical map, we check for two possible + * situations: + * - `canon_id` is mapped to exactly the same type as `cand_id`. This will + * happen when type graphs have cycles. In this case we assume those two + * types are equivalent. + * - `canon_id` is mapped to different type. This is contradiction in our + * hypothetical mapping, because same graph in canonical graph corresponds + * to two different types in candidate graph, which for equivalent type + * graphs shouldn't happen. This condition terminates equivalence check + * with negative result. + * + * If type graphs traversal exhausts types to check and find no contradiction, + * then type graphs are equivalent. + * + * When checking types for equivalence, there is one special case: FWD types. + * If FWD type resolution is allowed and one of the types (either from canonical + * or candidate graph) is FWD and other is STRUCT/UNION (depending on FWD's kind + * flag) and their names match, hypothetical mapping is updated to point from + * FWD to STRUCT/UNION. If graphs will be determined as equivalent successfully, + * this mapping will be used to record FWD -> STRUCT/UNION mapping permanently. + * + * Technically, this could lead to incorrect FWD to STRUCT/UNION resolution, + * if there are two exactly named (or anonymous) structs/unions that are + * compatible structurally, one of which has FWD field, while other is concrete + * STRUCT/UNION, but according to C sources they are different structs/unions + * that are referencing different types with the same name. This is extremely + * unlikely to happen, but btf_dedup API allows to disable FWD resolution if + * this logic is causing problems. + * + * Doing FWD resolution means that both candidate and/or canonical graphs can + * consists of portions of the graph that come from multiple compilation units. + * This is due to the fact that types within single compilation unit are always + * deduplicated and FWDs are already resolved, if referenced struct/union + * definiton is available. So, if we had unresolved FWD and found corresponding + * STRUCT/UNION, they will be from different compilation units. This + * consequently means that when we "link" FWD to corresponding STRUCT/UNION, + * type graph will likely have at least two different BTF types that describe + * same type (e.g., most probably there will be two different BTF types for the + * same 'int' primitive type) and could even have "overlapping" parts of type + * graph that describe same subset of types. + * + * This in turn means that our assumption that each type in canonical graph + * must correspond to exactly one type in candidate graph might not hold + * anymore and will make it harder to detect contradictions using hypothetical + * map. To handle this problem, we allow to follow FWD -> STRUCT/UNION + * resolution only in canonical graph. FWDs in candidate graphs are never + * resolved. To see why it's OK, let's check all possible situations w.r.t. FWDs + * that can occur: + * - Both types in canonical and candidate graphs are FWDs. If they are + * structurally equivalent, then they can either be both resolved to the + * same STRUCT/UNION or not resolved at all. In both cases they are + * equivalent and there is no need to resolve FWD on candidate side. + * - Both types in canonical and candidate graphs are concrete STRUCT/UNION, + * so nothing to resolve as well, algorithm will check equivalence anyway. + * - Type in canonical graph is FWD, while type in candidate is concrete + * STRUCT/UNION. In this case candidate graph comes from single compilation + * unit, so there is exactly one BTF type for each unique C type. After + * resolving FWD into STRUCT/UNION, there might be more than one BTF type + * in canonical graph mapping to single BTF type in candidate graph, but + * because hypothetical mapping maps from canonical to candidate types, it's + * alright, and we still maintain the property of having single `canon_id` + * mapping to single `cand_id` (there could be two different `canon_id` + * mapped to the same `cand_id`, but it's not contradictory). + * - Type in canonical graph is concrete STRUCT/UNION, while type in candidate + * graph is FWD. In this case we are just going to check compatibility of + * STRUCT/UNION and corresponding FWD, and if they are compatible, we'll + * assume that whatever STRUCT/UNION FWD resolves to must be equivalent to + * a concrete STRUCT/UNION from canonical graph. If the rest of type graphs + * turn out equivalent, we'll re-resolve FWD to concrete STRUCT/UNION from + * canonical graph. + */ +static int btf_dedup_is_equiv(struct btf_dedup *d, __u32 cand_id, + __u32 canon_id) +{ + struct btf_type *cand_type; + struct btf_type *canon_type; + __u32 hypot_type_id; + __u16 cand_kind; + __u16 canon_kind; + int i, eq; + + /* if both resolve to the same canonical, they must be equivalent */ + if (resolve_type_id(d, cand_id) == resolve_type_id(d, canon_id)) + return 1; + + canon_id = resolve_fwd_id(d, canon_id); + + hypot_type_id = d->hypot_map[canon_id]; + if (hypot_type_id <= BTF_MAX_NR_TYPES) { + /* In some cases compiler will generate different DWARF types + * for *identical* array type definitions and use them for + * different fields within the *same* struct. This breaks type + * equivalence check, which makes an assumption that candidate + * types sub-graph has a consistent and deduped-by-compiler + * types within a single CU. So work around that by explicitly + * allowing identical array types here. + */ + return hypot_type_id == cand_id || + btf_dedup_identical_arrays(d, hypot_type_id, cand_id); + } + + if (btf_dedup_hypot_map_add(d, canon_id, cand_id)) + return -ENOMEM; + + cand_type = btf_type_by_id(d->btf, cand_id); + canon_type = btf_type_by_id(d->btf, canon_id); + cand_kind = btf_kind(cand_type); + canon_kind = btf_kind(canon_type); + + if (cand_type->name_off != canon_type->name_off) + return 0; + + /* FWD <--> STRUCT/UNION equivalence check, if enabled */ + if (!d->opts.dont_resolve_fwds + && (cand_kind == BTF_KIND_FWD || canon_kind == BTF_KIND_FWD) + && cand_kind != canon_kind) { + __u16 real_kind; + __u16 fwd_kind; + + if (cand_kind == BTF_KIND_FWD) { + real_kind = canon_kind; + fwd_kind = btf_fwd_kind(cand_type); + } else { + real_kind = cand_kind; + fwd_kind = btf_fwd_kind(canon_type); + /* we'd need to resolve base FWD to STRUCT/UNION */ + if (fwd_kind == real_kind && canon_id < d->btf->start_id) + d->hypot_adjust_canon = true; + } + return fwd_kind == real_kind; + } + + if (cand_kind != canon_kind) + return 0; + + switch (cand_kind) { + case BTF_KIND_INT: + return btf_equal_int(cand_type, canon_type); + + case BTF_KIND_ENUM: + if (d->opts.dont_resolve_fwds) + return btf_equal_enum(cand_type, canon_type); + else + return btf_compat_enum(cand_type, canon_type); + + case BTF_KIND_FWD: + case BTF_KIND_FLOAT: + return btf_equal_common(cand_type, canon_type); + + case BTF_KIND_CONST: + case BTF_KIND_VOLATILE: + case BTF_KIND_RESTRICT: + case BTF_KIND_PTR: + case BTF_KIND_TYPEDEF: + case BTF_KIND_FUNC: + if (cand_type->info != canon_type->info) + return 0; + return btf_dedup_is_equiv(d, cand_type->type, canon_type->type); + + case BTF_KIND_ARRAY: { + const struct btf_array *cand_arr, *canon_arr; + + if (!btf_compat_array(cand_type, canon_type)) + return 0; + cand_arr = btf_array(cand_type); + canon_arr = btf_array(canon_type); + eq = btf_dedup_is_equiv(d, cand_arr->index_type, canon_arr->index_type); + if (eq <= 0) + return eq; + return btf_dedup_is_equiv(d, cand_arr->type, canon_arr->type); + } + + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: { + const struct btf_member *cand_m, *canon_m; + __u16 vlen; + + if (!btf_shallow_equal_struct(cand_type, canon_type)) + return 0; + vlen = btf_vlen(cand_type); + cand_m = btf_members(cand_type); + canon_m = btf_members(canon_type); + for (i = 0; i < vlen; i++) { + eq = btf_dedup_is_equiv(d, cand_m->type, canon_m->type); + if (eq <= 0) + return eq; + cand_m++; + canon_m++; + } + + return 1; + } + + case BTF_KIND_FUNC_PROTO: { + const struct btf_param *cand_p, *canon_p; + __u16 vlen; + + if (!btf_compat_fnproto(cand_type, canon_type)) + return 0; + eq = btf_dedup_is_equiv(d, cand_type->type, canon_type->type); + if (eq <= 0) + return eq; + vlen = btf_vlen(cand_type); + cand_p = btf_params(cand_type); + canon_p = btf_params(canon_type); + for (i = 0; i < vlen; i++) { + eq = btf_dedup_is_equiv(d, cand_p->type, canon_p->type); + if (eq <= 0) + return eq; + cand_p++; + canon_p++; + } + return 1; + } + + default: + return -EINVAL; + } + return 0; +} + +/* + * Use hypothetical mapping, produced by successful type graph equivalence + * check, to augment existing struct/union canonical mapping, where possible. + * + * If BTF_KIND_FWD resolution is allowed, this mapping is also used to record + * FWD -> STRUCT/UNION correspondence as well. FWD resolution is bidirectional: + * it doesn't matter if FWD type was part of canonical graph or candidate one, + * we are recording the mapping anyway. As opposed to carefulness required + * for struct/union correspondence mapping (described below), for FWD resolution + * it's not important, as by the time that FWD type (reference type) will be + * deduplicated all structs/unions will be deduped already anyway. + * + * Recording STRUCT/UNION mapping is purely a performance optimization and is + * not required for correctness. It needs to be done carefully to ensure that + * struct/union from candidate's type graph is not mapped into corresponding + * struct/union from canonical type graph that itself hasn't been resolved into + * canonical representative. The only guarantee we have is that canonical + * struct/union was determined as canonical and that won't change. But any + * types referenced through that struct/union fields could have been not yet + * resolved, so in case like that it's too early to establish any kind of + * correspondence between structs/unions. + * + * No canonical correspondence is derived for primitive types (they are already + * deduplicated completely already anyway) or reference types (they rely on + * stability of struct/union canonical relationship for equivalence checks). + */ +static void btf_dedup_merge_hypot_map(struct btf_dedup *d) +{ + __u32 canon_type_id, targ_type_id; + __u16 t_kind, c_kind; + __u32 t_id, c_id; + int i; + + for (i = 0; i < d->hypot_cnt; i++) { + canon_type_id = d->hypot_list[i]; + targ_type_id = d->hypot_map[canon_type_id]; + t_id = resolve_type_id(d, targ_type_id); + c_id = resolve_type_id(d, canon_type_id); + t_kind = btf_kind(btf__type_by_id(d->btf, t_id)); + c_kind = btf_kind(btf__type_by_id(d->btf, c_id)); + /* + * Resolve FWD into STRUCT/UNION. + * It's ok to resolve FWD into STRUCT/UNION that's not yet + * mapped to canonical representative (as opposed to + * STRUCT/UNION <--> STRUCT/UNION mapping logic below), because + * eventually that struct is going to be mapped and all resolved + * FWDs will automatically resolve to correct canonical + * representative. This will happen before ref type deduping, + * which critically depends on stability of these mapping. This + * stability is not a requirement for STRUCT/UNION equivalence + * checks, though. + */ + + /* if it's the split BTF case, we still need to point base FWD + * to STRUCT/UNION in a split BTF, because FWDs from split BTF + * will be resolved against base FWD. If we don't point base + * canonical FWD to the resolved STRUCT/UNION, then all the + * FWDs in split BTF won't be correctly resolved to a proper + * STRUCT/UNION. + */ + if (t_kind != BTF_KIND_FWD && c_kind == BTF_KIND_FWD) + d->map[c_id] = t_id; + + /* if graph equivalence determined that we'd need to adjust + * base canonical types, then we need to only point base FWDs + * to STRUCTs/UNIONs and do no more modifications. For all + * other purposes the type graphs were not equivalent. + */ + if (d->hypot_adjust_canon) + continue; + + if (t_kind == BTF_KIND_FWD && c_kind != BTF_KIND_FWD) + d->map[t_id] = c_id; + + if ((t_kind == BTF_KIND_STRUCT || t_kind == BTF_KIND_UNION) && + c_kind != BTF_KIND_FWD && + is_type_mapped(d, c_id) && + !is_type_mapped(d, t_id)) { + /* + * as a perf optimization, we can map struct/union + * that's part of type graph we just verified for + * equivalence. We can do that for struct/union that has + * canonical representative only, though. + */ + d->map[t_id] = c_id; + } + } +} + +/* + * Deduplicate struct/union types. + * + * For each struct/union type its type signature hash is calculated, taking + * into account type's name, size, number, order and names of fields, but + * ignoring type ID's referenced from fields, because they might not be deduped + * completely until after reference types deduplication phase. This type hash + * is used to iterate over all potential canonical types, sharing same hash. + * For each canonical candidate we check whether type graphs that they form + * (through referenced types in fields and so on) are equivalent using algorithm + * implemented in `btf_dedup_is_equiv`. If such equivalence is found and + * BTF_KIND_FWD resolution is allowed, then hypothetical mapping + * (btf_dedup->hypot_map) produced by aforementioned type graph equivalence + * algorithm is used to record FWD -> STRUCT/UNION mapping. It's also used to + * potentially map other structs/unions to their canonical representatives, + * if such relationship hasn't yet been established. This speeds up algorithm + * by eliminating some of the duplicate work. + * + * If no matching canonical representative was found, struct/union is marked + * as canonical for itself and is added into btf_dedup->dedup_table hash map + * for further look ups. + */ +static int btf_dedup_struct_type(struct btf_dedup *d, __u32 type_id) +{ + struct btf_type *cand_type, *t; + struct hashmap_entry *hash_entry; + /* if we don't find equivalent type, then we are canonical */ + __u32 new_id = type_id; + __u16 kind; + long h; + + /* already deduped or is in process of deduping (loop detected) */ + if (d->map[type_id] <= BTF_MAX_NR_TYPES) + return 0; + + t = btf_type_by_id(d->btf, type_id); + kind = btf_kind(t); + + if (kind != BTF_KIND_STRUCT && kind != BTF_KIND_UNION) + return 0; + + h = btf_hash_struct(t); + for_each_dedup_cand(d, hash_entry, h) { + __u32 cand_id = (__u32)(long)hash_entry->value; + int eq; + + /* + * Even though btf_dedup_is_equiv() checks for + * btf_shallow_equal_struct() internally when checking two + * structs (unions) for equivalence, we need to guard here + * from picking matching FWD type as a dedup candidate. + * This can happen due to hash collision. In such case just + * relying on btf_dedup_is_equiv() would lead to potentially + * creating a loop (FWD -> STRUCT and STRUCT -> FWD), because + * FWD and compatible STRUCT/UNION are considered equivalent. + */ + cand_type = btf_type_by_id(d->btf, cand_id); + if (!btf_shallow_equal_struct(t, cand_type)) + continue; + + btf_dedup_clear_hypot_map(d); + eq = btf_dedup_is_equiv(d, type_id, cand_id); + if (eq < 0) + return eq; + if (!eq) + continue; + btf_dedup_merge_hypot_map(d); + if (d->hypot_adjust_canon) /* not really equivalent */ + continue; + new_id = cand_id; + break; + } + + d->map[type_id] = new_id; + if (type_id == new_id && btf_dedup_table_add(d, h, type_id)) + return -ENOMEM; + + return 0; +} + +static int btf_dedup_struct_types(struct btf_dedup *d) +{ + int i, err; + + for (i = 0; i < d->btf->nr_types; i++) { + err = btf_dedup_struct_type(d, d->btf->start_id + i); + if (err) + return err; + } + return 0; +} + +/* + * Deduplicate reference type. + * + * Once all primitive and struct/union types got deduplicated, we can easily + * deduplicate all other (reference) BTF types. This is done in two steps: + * + * 1. Resolve all referenced type IDs into their canonical type IDs. This + * resolution can be done either immediately for primitive or struct/union types + * (because they were deduped in previous two phases) or recursively for + * reference types. Recursion will always terminate at either primitive or + * struct/union type, at which point we can "unwind" chain of reference types + * one by one. There is no danger of encountering cycles because in C type + * system the only way to form type cycle is through struct/union, so any chain + * of reference types, even those taking part in a type cycle, will inevitably + * reach struct/union at some point. + * + * 2. Once all referenced type IDs are resolved into canonical ones, BTF type + * becomes "stable", in the sense that no further deduplication will cause + * any changes to it. With that, it's now possible to calculate type's signature + * hash (this time taking into account referenced type IDs) and loop over all + * potential canonical representatives. If no match was found, current type + * will become canonical representative of itself and will be added into + * btf_dedup->dedup_table as another possible canonical representative. + */ +static int btf_dedup_ref_type(struct btf_dedup *d, __u32 type_id) +{ + struct hashmap_entry *hash_entry; + __u32 new_id = type_id, cand_id; + struct btf_type *t, *cand; + /* if we don't find equivalent type, then we are representative type */ + int ref_type_id; + long h; + + if (d->map[type_id] == BTF_IN_PROGRESS_ID) + return -ELOOP; + if (d->map[type_id] <= BTF_MAX_NR_TYPES) + return resolve_type_id(d, type_id); + + t = btf_type_by_id(d->btf, type_id); + d->map[type_id] = BTF_IN_PROGRESS_ID; + + switch (btf_kind(t)) { + case BTF_KIND_CONST: + case BTF_KIND_VOLATILE: + case BTF_KIND_RESTRICT: + case BTF_KIND_PTR: + case BTF_KIND_TYPEDEF: + case BTF_KIND_FUNC: + ref_type_id = btf_dedup_ref_type(d, t->type); + if (ref_type_id < 0) + return ref_type_id; + t->type = ref_type_id; + + h = btf_hash_common(t); + for_each_dedup_cand(d, hash_entry, h) { + cand_id = (__u32)(long)hash_entry->value; + cand = btf_type_by_id(d->btf, cand_id); + if (btf_equal_common(t, cand)) { + new_id = cand_id; + break; + } + } + break; + + case BTF_KIND_ARRAY: { + struct btf_array *info = btf_array(t); + + ref_type_id = btf_dedup_ref_type(d, info->type); + if (ref_type_id < 0) + return ref_type_id; + info->type = ref_type_id; + + ref_type_id = btf_dedup_ref_type(d, info->index_type); + if (ref_type_id < 0) + return ref_type_id; + info->index_type = ref_type_id; + + h = btf_hash_array(t); + for_each_dedup_cand(d, hash_entry, h) { + cand_id = (__u32)(long)hash_entry->value; + cand = btf_type_by_id(d->btf, cand_id); + if (btf_equal_array(t, cand)) { + new_id = cand_id; + break; + } + } + break; + } + + case BTF_KIND_FUNC_PROTO: { + struct btf_param *param; + __u16 vlen; + int i; + + ref_type_id = btf_dedup_ref_type(d, t->type); + if (ref_type_id < 0) + return ref_type_id; + t->type = ref_type_id; + + vlen = btf_vlen(t); + param = btf_params(t); + for (i = 0; i < vlen; i++) { + ref_type_id = btf_dedup_ref_type(d, param->type); + if (ref_type_id < 0) + return ref_type_id; + param->type = ref_type_id; + param++; + } + + h = btf_hash_fnproto(t); + for_each_dedup_cand(d, hash_entry, h) { + cand_id = (__u32)(long)hash_entry->value; + cand = btf_type_by_id(d->btf, cand_id); + if (btf_equal_fnproto(t, cand)) { + new_id = cand_id; + break; + } + } + break; + } + + default: + return -EINVAL; + } + + d->map[type_id] = new_id; + if (type_id == new_id && btf_dedup_table_add(d, h, type_id)) + return -ENOMEM; + + return new_id; +} + +static int btf_dedup_ref_types(struct btf_dedup *d) +{ + int i, err; + + for (i = 0; i < d->btf->nr_types; i++) { + err = btf_dedup_ref_type(d, d->btf->start_id + i); + if (err < 0) + return err; + } + /* we won't need d->dedup_table anymore */ + hashmap__free(d->dedup_table); + d->dedup_table = NULL; + return 0; +} + +/* + * Compact types. + * + * After we established for each type its corresponding canonical representative + * type, we now can eliminate types that are not canonical and leave only + * canonical ones layed out sequentially in memory by copying them over + * duplicates. During compaction btf_dedup->hypot_map array is reused to store + * a map from original type ID to a new compacted type ID, which will be used + * during next phase to "fix up" type IDs, referenced from struct/union and + * reference types. + */ +static int btf_dedup_compact_types(struct btf_dedup *d) +{ + __u32 *new_offs; + __u32 next_type_id = d->btf->start_id; + const struct btf_type *t; + void *p; + int i, id, len; + + /* we are going to reuse hypot_map to store compaction remapping */ + d->hypot_map[0] = 0; + /* base BTF types are not renumbered */ + for (id = 1; id < d->btf->start_id; id++) + d->hypot_map[id] = id; + for (i = 0, id = d->btf->start_id; i < d->btf->nr_types; i++, id++) + d->hypot_map[id] = BTF_UNPROCESSED_ID; + + p = d->btf->types_data; + + for (i = 0, id = d->btf->start_id; i < d->btf->nr_types; i++, id++) { + if (d->map[id] != id) + continue; + + t = btf__type_by_id(d->btf, id); + len = btf_type_size(t); + if (len < 0) + return len; + + memmove(p, t, len); + d->hypot_map[id] = next_type_id; + d->btf->type_offs[next_type_id - d->btf->start_id] = p - d->btf->types_data; + p += len; + next_type_id++; + } + + /* shrink struct btf's internal types index and update btf_header */ + d->btf->nr_types = next_type_id - d->btf->start_id; + d->btf->type_offs_cap = d->btf->nr_types; + d->btf->hdr->type_len = p - d->btf->types_data; + new_offs = libbpf_reallocarray(d->btf->type_offs, d->btf->type_offs_cap, + sizeof(*new_offs)); + if (d->btf->type_offs_cap && !new_offs) + return -ENOMEM; + d->btf->type_offs = new_offs; + d->btf->hdr->str_off = d->btf->hdr->type_len; + d->btf->raw_size = d->btf->hdr->hdr_len + d->btf->hdr->type_len + d->btf->hdr->str_len; + return 0; +} + +/* + * Figure out final (deduplicated and compacted) type ID for provided original + * `type_id` by first resolving it into corresponding canonical type ID and + * then mapping it to a deduplicated type ID, stored in btf_dedup->hypot_map, + * which is populated during compaction phase. + */ +static int btf_dedup_remap_type_id(struct btf_dedup *d, __u32 type_id) +{ + __u32 resolved_type_id, new_type_id; + + resolved_type_id = resolve_type_id(d, type_id); + new_type_id = d->hypot_map[resolved_type_id]; + if (new_type_id > BTF_MAX_NR_TYPES) + return -EINVAL; + return new_type_id; +} + +/* + * Remap referenced type IDs into deduped type IDs. + * + * After BTF types are deduplicated and compacted, their final type IDs may + * differ from original ones. The map from original to a corresponding + * deduped type ID is stored in btf_dedup->hypot_map and is populated during + * compaction phase. During remapping phase we are rewriting all type IDs + * referenced from any BTF type (e.g., struct fields, func proto args, etc) to + * their final deduped type IDs. + */ +static int btf_dedup_remap_type(struct btf_dedup *d, __u32 type_id) +{ + struct btf_type *t = btf_type_by_id(d->btf, type_id); + int i, r; + + switch (btf_kind(t)) { + case BTF_KIND_INT: + case BTF_KIND_ENUM: + case BTF_KIND_FLOAT: + break; + + case BTF_KIND_FWD: + case BTF_KIND_CONST: + case BTF_KIND_VOLATILE: + case BTF_KIND_RESTRICT: + case BTF_KIND_PTR: + case BTF_KIND_TYPEDEF: + case BTF_KIND_FUNC: + case BTF_KIND_VAR: + r = btf_dedup_remap_type_id(d, t->type); + if (r < 0) + return r; + t->type = r; + break; + + case BTF_KIND_ARRAY: { + struct btf_array *arr_info = btf_array(t); + + r = btf_dedup_remap_type_id(d, arr_info->type); + if (r < 0) + return r; + arr_info->type = r; + r = btf_dedup_remap_type_id(d, arr_info->index_type); + if (r < 0) + return r; + arr_info->index_type = r; + break; + } + + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: { + struct btf_member *member = btf_members(t); + __u16 vlen = btf_vlen(t); + + for (i = 0; i < vlen; i++) { + r = btf_dedup_remap_type_id(d, member->type); + if (r < 0) + return r; + member->type = r; + member++; + } + break; + } + + case BTF_KIND_FUNC_PROTO: { + struct btf_param *param = btf_params(t); + __u16 vlen = btf_vlen(t); + + r = btf_dedup_remap_type_id(d, t->type); + if (r < 0) + return r; + t->type = r; + + for (i = 0; i < vlen; i++) { + r = btf_dedup_remap_type_id(d, param->type); + if (r < 0) + return r; + param->type = r; + param++; + } + break; + } + + case BTF_KIND_DATASEC: { + struct btf_var_secinfo *var = btf_var_secinfos(t); + __u16 vlen = btf_vlen(t); + + for (i = 0; i < vlen; i++) { + r = btf_dedup_remap_type_id(d, var->type); + if (r < 0) + return r; + var->type = r; + var++; + } + break; + } + + default: + return -EINVAL; + } + + return 0; +} + +static int btf_dedup_remap_types(struct btf_dedup *d) +{ + int i, r; + + for (i = 0; i < d->btf->nr_types; i++) { + r = btf_dedup_remap_type(d, d->btf->start_id + i); + if (r < 0) + return r; + } + return 0; +} + +/* + * Probe few well-known locations for vmlinux kernel image and try to load BTF + * data out of it to use for target BTF. + */ +struct btf *libbpf_find_kernel_btf(void) +{ + struct { + const char *path_fmt; + bool raw_btf; + } locations[] = { + /* try canonical vmlinux BTF through sysfs first */ + { "/sys/kernel/btf/vmlinux", true /* raw BTF */ }, + /* fall back to trying to find vmlinux ELF on disk otherwise */ + { "/boot/vmlinux-%1$s" }, + { "/lib/modules/%1$s/vmlinux-%1$s" }, + { "/lib/modules/%1$s/build/vmlinux" }, + { "/usr/lib/modules/%1$s/kernel/vmlinux" }, + { "/usr/lib/debug/boot/vmlinux-%1$s" }, + { "/usr/lib/debug/boot/vmlinux-%1$s.debug" }, + { "/usr/lib/debug/lib/modules/%1$s/vmlinux" }, + }; + char path[PATH_MAX + 1]; + struct utsname buf; + struct btf *btf; + int i; + + uname(&buf); + + for (i = 0; i < ARRAY_SIZE(locations); i++) { + snprintf(path, PATH_MAX, locations[i].path_fmt, buf.release); + + if (access(path, R_OK)) + continue; + + if (locations[i].raw_btf) + btf = btf__parse_raw(path); + else + btf = btf__parse_elf(path, NULL); + + pr_debug("loading kernel BTF '%s': %ld\n", + path, IS_ERR(btf) ? PTR_ERR(btf) : 0); + if (IS_ERR(btf)) + continue; + + return btf; + } + + pr_warn("failed to find valid kernel BTF\n"); + return ERR_PTR(-ESRCH); +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/btf_dump.c dwarves-dfsg-1.21/lib/bpf/src/btf_dump.c --- dwarves-dfsg-1.10/lib/bpf/src/btf_dump.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/btf_dump.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,1444 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +/* + * BTF-to-C type converter. + * + * Copyright (c) 2019 Facebook + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "btf.h" +#include "hashmap.h" +#include "libbpf.h" +#include "libbpf_internal.h" + +static const char PREFIXES[] = "\t\t\t\t\t\t\t\t\t\t\t\t\t"; +static const size_t PREFIX_CNT = sizeof(PREFIXES) - 1; + +static const char *pfx(int lvl) +{ + return lvl >= PREFIX_CNT ? PREFIXES : &PREFIXES[PREFIX_CNT - lvl]; +} + +enum btf_dump_type_order_state { + NOT_ORDERED, + ORDERING, + ORDERED, +}; + +enum btf_dump_type_emit_state { + NOT_EMITTED, + EMITTING, + EMITTED, +}; + +/* per-type auxiliary state */ +struct btf_dump_type_aux_state { + /* topological sorting state */ + enum btf_dump_type_order_state order_state: 2; + /* emitting state used to determine the need for forward declaration */ + enum btf_dump_type_emit_state emit_state: 2; + /* whether forward declaration was already emitted */ + __u8 fwd_emitted: 1; + /* whether unique non-duplicate name was already assigned */ + __u8 name_resolved: 1; + /* whether type is referenced from any other type */ + __u8 referenced: 1; +}; + +struct btf_dump { + const struct btf *btf; + const struct btf_ext *btf_ext; + btf_dump_printf_fn_t printf_fn; + struct btf_dump_opts opts; + int ptr_sz; + bool strip_mods; + int last_id; + + /* per-type auxiliary state */ + struct btf_dump_type_aux_state *type_states; + size_t type_states_cap; + /* per-type optional cached unique name, must be freed, if present */ + const char **cached_names; + size_t cached_names_cap; + + /* topo-sorted list of dependent type definitions */ + __u32 *emit_queue; + int emit_queue_cap; + int emit_queue_cnt; + + /* + * stack of type declarations (e.g., chain of modifiers, arrays, + * funcs, etc) + */ + __u32 *decl_stack; + int decl_stack_cap; + int decl_stack_cnt; + + /* maps struct/union/enum name to a number of name occurrences */ + struct hashmap *type_names; + /* + * maps typedef identifiers and enum value names to a number of such + * name occurrences + */ + struct hashmap *ident_names; +}; + +static size_t str_hash_fn(const void *key, void *ctx) +{ + return str_hash(key); +} + +static bool str_equal_fn(const void *a, const void *b, void *ctx) +{ + return strcmp(a, b) == 0; +} + +static const char *btf_name_of(const struct btf_dump *d, __u32 name_off) +{ + return btf__name_by_offset(d->btf, name_off); +} + +static void btf_dump_printf(const struct btf_dump *d, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + d->printf_fn(d->opts.ctx, fmt, args); + va_end(args); +} + +static int btf_dump_mark_referenced(struct btf_dump *d); +static int btf_dump_resize(struct btf_dump *d); + +struct btf_dump *btf_dump__new(const struct btf *btf, + const struct btf_ext *btf_ext, + const struct btf_dump_opts *opts, + btf_dump_printf_fn_t printf_fn) +{ + struct btf_dump *d; + int err; + + d = calloc(1, sizeof(struct btf_dump)); + if (!d) + return ERR_PTR(-ENOMEM); + + d->btf = btf; + d->btf_ext = btf_ext; + d->printf_fn = printf_fn; + d->opts.ctx = opts ? opts->ctx : NULL; + d->ptr_sz = btf__pointer_size(btf) ? : sizeof(void *); + + d->type_names = hashmap__new(str_hash_fn, str_equal_fn, NULL); + if (IS_ERR(d->type_names)) { + err = PTR_ERR(d->type_names); + d->type_names = NULL; + goto err; + } + d->ident_names = hashmap__new(str_hash_fn, str_equal_fn, NULL); + if (IS_ERR(d->ident_names)) { + err = PTR_ERR(d->ident_names); + d->ident_names = NULL; + goto err; + } + + err = btf_dump_resize(d); + if (err) + goto err; + + return d; +err: + btf_dump__free(d); + return ERR_PTR(err); +} + +static int btf_dump_resize(struct btf_dump *d) +{ + int err, last_id = btf__get_nr_types(d->btf); + + if (last_id <= d->last_id) + return 0; + + if (btf_ensure_mem((void **)&d->type_states, &d->type_states_cap, + sizeof(*d->type_states), last_id + 1)) + return -ENOMEM; + if (btf_ensure_mem((void **)&d->cached_names, &d->cached_names_cap, + sizeof(*d->cached_names), last_id + 1)) + return -ENOMEM; + + if (d->last_id == 0) { + /* VOID is special */ + d->type_states[0].order_state = ORDERED; + d->type_states[0].emit_state = EMITTED; + } + + /* eagerly determine referenced types for anon enums */ + err = btf_dump_mark_referenced(d); + if (err) + return err; + + d->last_id = last_id; + return 0; +} + +void btf_dump__free(struct btf_dump *d) +{ + int i; + + if (IS_ERR_OR_NULL(d)) + return; + + free(d->type_states); + if (d->cached_names) { + /* any set cached name is owned by us and should be freed */ + for (i = 0; i <= d->last_id; i++) { + if (d->cached_names[i]) + free((void *)d->cached_names[i]); + } + } + free(d->cached_names); + free(d->emit_queue); + free(d->decl_stack); + hashmap__free(d->type_names); + hashmap__free(d->ident_names); + + free(d); +} + +static int btf_dump_order_type(struct btf_dump *d, __u32 id, bool through_ptr); +static void btf_dump_emit_type(struct btf_dump *d, __u32 id, __u32 cont_id); + +/* + * Dump BTF type in a compilable C syntax, including all the necessary + * dependent types, necessary for compilation. If some of the dependent types + * were already emitted as part of previous btf_dump__dump_type() invocation + * for another type, they won't be emitted again. This API allows callers to + * filter out BTF types according to user-defined criterias and emitted only + * minimal subset of types, necessary to compile everything. Full struct/union + * definitions will still be emitted, even if the only usage is through + * pointer and could be satisfied with just a forward declaration. + * + * Dumping is done in two high-level passes: + * 1. Topologically sort type definitions to satisfy C rules of compilation. + * 2. Emit type definitions in C syntax. + * + * Returns 0 on success; <0, otherwise. + */ +int btf_dump__dump_type(struct btf_dump *d, __u32 id) +{ + int err, i; + + if (id > btf__get_nr_types(d->btf)) + return -EINVAL; + + err = btf_dump_resize(d); + if (err) + return err; + + d->emit_queue_cnt = 0; + err = btf_dump_order_type(d, id, false); + if (err < 0) + return err; + + for (i = 0; i < d->emit_queue_cnt; i++) + btf_dump_emit_type(d, d->emit_queue[i], 0 /*top-level*/); + + return 0; +} + +/* + * Mark all types that are referenced from any other type. This is used to + * determine top-level anonymous enums that need to be emitted as an + * independent type declarations. + * Anonymous enums come in two flavors: either embedded in a struct's field + * definition, in which case they have to be declared inline as part of field + * type declaration; or as a top-level anonymous enum, typically used for + * declaring global constants. It's impossible to distinguish between two + * without knowning whether given enum type was referenced from other type: + * top-level anonymous enum won't be referenced by anything, while embedded + * one will. + */ +static int btf_dump_mark_referenced(struct btf_dump *d) +{ + int i, j, n = btf__get_nr_types(d->btf); + const struct btf_type *t; + __u16 vlen; + + for (i = d->last_id + 1; i <= n; i++) { + t = btf__type_by_id(d->btf, i); + vlen = btf_vlen(t); + + switch (btf_kind(t)) { + case BTF_KIND_INT: + case BTF_KIND_ENUM: + case BTF_KIND_FWD: + case BTF_KIND_FLOAT: + break; + + case BTF_KIND_VOLATILE: + case BTF_KIND_CONST: + case BTF_KIND_RESTRICT: + case BTF_KIND_PTR: + case BTF_KIND_TYPEDEF: + case BTF_KIND_FUNC: + case BTF_KIND_VAR: + d->type_states[t->type].referenced = 1; + break; + + case BTF_KIND_ARRAY: { + const struct btf_array *a = btf_array(t); + + d->type_states[a->index_type].referenced = 1; + d->type_states[a->type].referenced = 1; + break; + } + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: { + const struct btf_member *m = btf_members(t); + + for (j = 0; j < vlen; j++, m++) + d->type_states[m->type].referenced = 1; + break; + } + case BTF_KIND_FUNC_PROTO: { + const struct btf_param *p = btf_params(t); + + for (j = 0; j < vlen; j++, p++) + d->type_states[p->type].referenced = 1; + break; + } + case BTF_KIND_DATASEC: { + const struct btf_var_secinfo *v = btf_var_secinfos(t); + + for (j = 0; j < vlen; j++, v++) + d->type_states[v->type].referenced = 1; + break; + } + default: + return -EINVAL; + } + } + return 0; +} + +static int btf_dump_add_emit_queue_id(struct btf_dump *d, __u32 id) +{ + __u32 *new_queue; + size_t new_cap; + + if (d->emit_queue_cnt >= d->emit_queue_cap) { + new_cap = max(16, d->emit_queue_cap * 3 / 2); + new_queue = libbpf_reallocarray(d->emit_queue, new_cap, sizeof(new_queue[0])); + if (!new_queue) + return -ENOMEM; + d->emit_queue = new_queue; + d->emit_queue_cap = new_cap; + } + + d->emit_queue[d->emit_queue_cnt++] = id; + return 0; +} + +/* + * Determine order of emitting dependent types and specified type to satisfy + * C compilation rules. This is done through topological sorting with an + * additional complication which comes from C rules. The main idea for C is + * that if some type is "embedded" into a struct/union, it's size needs to be + * known at the time of definition of containing type. E.g., for: + * + * struct A {}; + * struct B { struct A x; } + * + * struct A *HAS* to be defined before struct B, because it's "embedded", + * i.e., it is part of struct B layout. But in the following case: + * + * struct A; + * struct B { struct A *x; } + * struct A {}; + * + * it's enough to just have a forward declaration of struct A at the time of + * struct B definition, as struct B has a pointer to struct A, so the size of + * field x is known without knowing struct A size: it's sizeof(void *). + * + * Unfortunately, there are some trickier cases we need to handle, e.g.: + * + * struct A {}; // if this was forward-declaration: compilation error + * struct B { + * struct { // anonymous struct + * struct A y; + * } *x; + * }; + * + * In this case, struct B's field x is a pointer, so it's size is known + * regardless of the size of (anonymous) struct it points to. But because this + * struct is anonymous and thus defined inline inside struct B, *and* it + * embeds struct A, compiler requires full definition of struct A to be known + * before struct B can be defined. This creates a transitive dependency + * between struct A and struct B. If struct A was forward-declared before + * struct B definition and fully defined after struct B definition, that would + * trigger compilation error. + * + * All this means that while we are doing topological sorting on BTF type + * graph, we need to determine relationships between different types (graph + * nodes): + * - weak link (relationship) between X and Y, if Y *CAN* be + * forward-declared at the point of X definition; + * - strong link, if Y *HAS* to be fully-defined before X can be defined. + * + * The rule is as follows. Given a chain of BTF types from X to Y, if there is + * BTF_KIND_PTR type in the chain and at least one non-anonymous type + * Z (excluding X, including Y), then link is weak. Otherwise, it's strong. + * Weak/strong relationship is determined recursively during DFS traversal and + * is returned as a result from btf_dump_order_type(). + * + * btf_dump_order_type() is trying to avoid unnecessary forward declarations, + * but it is not guaranteeing that no extraneous forward declarations will be + * emitted. + * + * To avoid extra work, algorithm marks some of BTF types as ORDERED, when + * it's done with them, but not for all (e.g., VOLATILE, CONST, RESTRICT, + * ARRAY, FUNC_PROTO), as weak/strong semantics for those depends on the + * entire graph path, so depending where from one came to that BTF type, it + * might cause weak or strong ordering. For types like STRUCT/UNION/INT/ENUM, + * once they are processed, there is no need to do it again, so they are + * marked as ORDERED. We can mark PTR as ORDERED as well, as it semi-forces + * weak link, unless subsequent referenced STRUCT/UNION/ENUM is anonymous. But + * in any case, once those are processed, no need to do it again, as the + * result won't change. + * + * Returns: + * - 1, if type is part of strong link (so there is strong topological + * ordering requirements); + * - 0, if type is part of weak link (so can be satisfied through forward + * declaration); + * - <0, on error (e.g., unsatisfiable type loop detected). + */ +static int btf_dump_order_type(struct btf_dump *d, __u32 id, bool through_ptr) +{ + /* + * Order state is used to detect strong link cycles, but only for BTF + * kinds that are or could be an independent definition (i.e., + * stand-alone fwd decl, enum, typedef, struct, union). Ptrs, arrays, + * func_protos, modifiers are just means to get to these definitions. + * Int/void don't need definitions, they are assumed to be always + * properly defined. We also ignore datasec, var, and funcs for now. + * So for all non-defining kinds, we never even set ordering state, + * for defining kinds we set ORDERING and subsequently ORDERED if it + * forms a strong link. + */ + struct btf_dump_type_aux_state *tstate = &d->type_states[id]; + const struct btf_type *t; + __u16 vlen; + int err, i; + + /* return true, letting typedefs know that it's ok to be emitted */ + if (tstate->order_state == ORDERED) + return 1; + + t = btf__type_by_id(d->btf, id); + + if (tstate->order_state == ORDERING) { + /* type loop, but resolvable through fwd declaration */ + if (btf_is_composite(t) && through_ptr && t->name_off != 0) + return 0; + pr_warn("unsatisfiable type cycle, id:[%u]\n", id); + return -ELOOP; + } + + switch (btf_kind(t)) { + case BTF_KIND_INT: + case BTF_KIND_FLOAT: + tstate->order_state = ORDERED; + return 0; + + case BTF_KIND_PTR: + err = btf_dump_order_type(d, t->type, true); + tstate->order_state = ORDERED; + return err; + + case BTF_KIND_ARRAY: + return btf_dump_order_type(d, btf_array(t)->type, through_ptr); + + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: { + const struct btf_member *m = btf_members(t); + /* + * struct/union is part of strong link, only if it's embedded + * (so no ptr in a path) or it's anonymous (so has to be + * defined inline, even if declared through ptr) + */ + if (through_ptr && t->name_off != 0) + return 0; + + tstate->order_state = ORDERING; + + vlen = btf_vlen(t); + for (i = 0; i < vlen; i++, m++) { + err = btf_dump_order_type(d, m->type, false); + if (err < 0) + return err; + } + + if (t->name_off != 0) { + err = btf_dump_add_emit_queue_id(d, id); + if (err < 0) + return err; + } + + tstate->order_state = ORDERED; + return 1; + } + case BTF_KIND_ENUM: + case BTF_KIND_FWD: + /* + * non-anonymous or non-referenced enums are top-level + * declarations and should be emitted. Same logic can be + * applied to FWDs, it won't hurt anyways. + */ + if (t->name_off != 0 || !tstate->referenced) { + err = btf_dump_add_emit_queue_id(d, id); + if (err) + return err; + } + tstate->order_state = ORDERED; + return 1; + + case BTF_KIND_TYPEDEF: { + int is_strong; + + is_strong = btf_dump_order_type(d, t->type, through_ptr); + if (is_strong < 0) + return is_strong; + + /* typedef is similar to struct/union w.r.t. fwd-decls */ + if (through_ptr && !is_strong) + return 0; + + /* typedef is always a named definition */ + err = btf_dump_add_emit_queue_id(d, id); + if (err) + return err; + + d->type_states[id].order_state = ORDERED; + return 1; + } + case BTF_KIND_VOLATILE: + case BTF_KIND_CONST: + case BTF_KIND_RESTRICT: + return btf_dump_order_type(d, t->type, through_ptr); + + case BTF_KIND_FUNC_PROTO: { + const struct btf_param *p = btf_params(t); + bool is_strong; + + err = btf_dump_order_type(d, t->type, through_ptr); + if (err < 0) + return err; + is_strong = err > 0; + + vlen = btf_vlen(t); + for (i = 0; i < vlen; i++, p++) { + err = btf_dump_order_type(d, p->type, through_ptr); + if (err < 0) + return err; + if (err > 0) + is_strong = true; + } + return is_strong; + } + case BTF_KIND_FUNC: + case BTF_KIND_VAR: + case BTF_KIND_DATASEC: + d->type_states[id].order_state = ORDERED; + return 0; + + default: + return -EINVAL; + } +} + +static void btf_dump_emit_missing_aliases(struct btf_dump *d, __u32 id, + const struct btf_type *t); + +static void btf_dump_emit_struct_fwd(struct btf_dump *d, __u32 id, + const struct btf_type *t); +static void btf_dump_emit_struct_def(struct btf_dump *d, __u32 id, + const struct btf_type *t, int lvl); + +static void btf_dump_emit_enum_fwd(struct btf_dump *d, __u32 id, + const struct btf_type *t); +static void btf_dump_emit_enum_def(struct btf_dump *d, __u32 id, + const struct btf_type *t, int lvl); + +static void btf_dump_emit_fwd_def(struct btf_dump *d, __u32 id, + const struct btf_type *t); + +static void btf_dump_emit_typedef_def(struct btf_dump *d, __u32 id, + const struct btf_type *t, int lvl); + +/* a local view into a shared stack */ +struct id_stack { + const __u32 *ids; + int cnt; +}; + +static void btf_dump_emit_type_decl(struct btf_dump *d, __u32 id, + const char *fname, int lvl); +static void btf_dump_emit_type_chain(struct btf_dump *d, + struct id_stack *decl_stack, + const char *fname, int lvl); + +static const char *btf_dump_type_name(struct btf_dump *d, __u32 id); +static const char *btf_dump_ident_name(struct btf_dump *d, __u32 id); +static size_t btf_dump_name_dups(struct btf_dump *d, struct hashmap *name_map, + const char *orig_name); + +static bool btf_dump_is_blacklisted(struct btf_dump *d, __u32 id) +{ + const struct btf_type *t = btf__type_by_id(d->btf, id); + + /* __builtin_va_list is a compiler built-in, which causes compilation + * errors, when compiling w/ different compiler, then used to compile + * original code (e.g., GCC to compile kernel, Clang to use generated + * C header from BTF). As it is built-in, it should be already defined + * properly internally in compiler. + */ + if (t->name_off == 0) + return false; + return strcmp(btf_name_of(d, t->name_off), "__builtin_va_list") == 0; +} + +/* + * Emit C-syntax definitions of types from chains of BTF types. + * + * High-level handling of determining necessary forward declarations are handled + * by btf_dump_emit_type() itself, but all nitty-gritty details of emitting type + * declarations/definitions in C syntax are handled by a combo of + * btf_dump_emit_type_decl()/btf_dump_emit_type_chain() w/ delegation to + * corresponding btf_dump_emit_*_{def,fwd}() functions. + * + * We also keep track of "containing struct/union type ID" to determine when + * we reference it from inside and thus can avoid emitting unnecessary forward + * declaration. + * + * This algorithm is designed in such a way, that even if some error occurs + * (either technical, e.g., out of memory, or logical, i.e., malformed BTF + * that doesn't comply to C rules completely), algorithm will try to proceed + * and produce as much meaningful output as possible. + */ +static void btf_dump_emit_type(struct btf_dump *d, __u32 id, __u32 cont_id) +{ + struct btf_dump_type_aux_state *tstate = &d->type_states[id]; + bool top_level_def = cont_id == 0; + const struct btf_type *t; + __u16 kind; + + if (tstate->emit_state == EMITTED) + return; + + t = btf__type_by_id(d->btf, id); + kind = btf_kind(t); + + if (tstate->emit_state == EMITTING) { + if (tstate->fwd_emitted) + return; + + switch (kind) { + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: + /* + * if we are referencing a struct/union that we are + * part of - then no need for fwd declaration + */ + if (id == cont_id) + return; + if (t->name_off == 0) { + pr_warn("anonymous struct/union loop, id:[%u]\n", + id); + return; + } + btf_dump_emit_struct_fwd(d, id, t); + btf_dump_printf(d, ";\n\n"); + tstate->fwd_emitted = 1; + break; + case BTF_KIND_TYPEDEF: + /* + * for typedef fwd_emitted means typedef definition + * was emitted, but it can be used only for "weak" + * references through pointer only, not for embedding + */ + if (!btf_dump_is_blacklisted(d, id)) { + btf_dump_emit_typedef_def(d, id, t, 0); + btf_dump_printf(d, ";\n\n"); + } + tstate->fwd_emitted = 1; + break; + default: + break; + } + + return; + } + + switch (kind) { + case BTF_KIND_INT: + /* Emit type alias definitions if necessary */ + btf_dump_emit_missing_aliases(d, id, t); + + tstate->emit_state = EMITTED; + break; + case BTF_KIND_ENUM: + if (top_level_def) { + btf_dump_emit_enum_def(d, id, t, 0); + btf_dump_printf(d, ";\n\n"); + } + tstate->emit_state = EMITTED; + break; + case BTF_KIND_PTR: + case BTF_KIND_VOLATILE: + case BTF_KIND_CONST: + case BTF_KIND_RESTRICT: + btf_dump_emit_type(d, t->type, cont_id); + break; + case BTF_KIND_ARRAY: + btf_dump_emit_type(d, btf_array(t)->type, cont_id); + break; + case BTF_KIND_FWD: + btf_dump_emit_fwd_def(d, id, t); + btf_dump_printf(d, ";\n\n"); + tstate->emit_state = EMITTED; + break; + case BTF_KIND_TYPEDEF: + tstate->emit_state = EMITTING; + btf_dump_emit_type(d, t->type, id); + /* + * typedef can server as both definition and forward + * declaration; at this stage someone depends on + * typedef as a forward declaration (refers to it + * through pointer), so unless we already did it, + * emit typedef as a forward declaration + */ + if (!tstate->fwd_emitted && !btf_dump_is_blacklisted(d, id)) { + btf_dump_emit_typedef_def(d, id, t, 0); + btf_dump_printf(d, ";\n\n"); + } + tstate->emit_state = EMITTED; + break; + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: + tstate->emit_state = EMITTING; + /* if it's a top-level struct/union definition or struct/union + * is anonymous, then in C we'll be emitting all fields and + * their types (as opposed to just `struct X`), so we need to + * make sure that all types, referenced from struct/union + * members have necessary forward-declarations, where + * applicable + */ + if (top_level_def || t->name_off == 0) { + const struct btf_member *m = btf_members(t); + __u16 vlen = btf_vlen(t); + int i, new_cont_id; + + new_cont_id = t->name_off == 0 ? cont_id : id; + for (i = 0; i < vlen; i++, m++) + btf_dump_emit_type(d, m->type, new_cont_id); + } else if (!tstate->fwd_emitted && id != cont_id) { + btf_dump_emit_struct_fwd(d, id, t); + btf_dump_printf(d, ";\n\n"); + tstate->fwd_emitted = 1; + } + + if (top_level_def) { + btf_dump_emit_struct_def(d, id, t, 0); + btf_dump_printf(d, ";\n\n"); + tstate->emit_state = EMITTED; + } else { + tstate->emit_state = NOT_EMITTED; + } + break; + case BTF_KIND_FUNC_PROTO: { + const struct btf_param *p = btf_params(t); + __u16 vlen = btf_vlen(t); + int i; + + btf_dump_emit_type(d, t->type, cont_id); + for (i = 0; i < vlen; i++, p++) + btf_dump_emit_type(d, p->type, cont_id); + + break; + } + default: + break; + } +} + +static bool btf_is_struct_packed(const struct btf *btf, __u32 id, + const struct btf_type *t) +{ + const struct btf_member *m; + int align, i, bit_sz; + __u16 vlen; + + align = btf__align_of(btf, id); + /* size of a non-packed struct has to be a multiple of its alignment*/ + if (align && t->size % align) + return true; + + m = btf_members(t); + vlen = btf_vlen(t); + /* all non-bitfield fields have to be naturally aligned */ + for (i = 0; i < vlen; i++, m++) { + align = btf__align_of(btf, m->type); + bit_sz = btf_member_bitfield_size(t, i); + if (align && bit_sz == 0 && m->offset % (8 * align) != 0) + return true; + } + + /* + * if original struct was marked as packed, but its layout is + * naturally aligned, we'll detect that it's not packed + */ + return false; +} + +static int chip_away_bits(int total, int at_most) +{ + return total % at_most ? : at_most; +} + +static void btf_dump_emit_bit_padding(const struct btf_dump *d, + int cur_off, int m_off, int m_bit_sz, + int align, int lvl) +{ + int off_diff = m_off - cur_off; + int ptr_bits = d->ptr_sz * 8; + + if (off_diff <= 0) + /* no gap */ + return; + if (m_bit_sz == 0 && off_diff < align * 8) + /* natural padding will take care of a gap */ + return; + + while (off_diff > 0) { + const char *pad_type; + int pad_bits; + + if (ptr_bits > 32 && off_diff > 32) { + pad_type = "long"; + pad_bits = chip_away_bits(off_diff, ptr_bits); + } else if (off_diff > 16) { + pad_type = "int"; + pad_bits = chip_away_bits(off_diff, 32); + } else if (off_diff > 8) { + pad_type = "short"; + pad_bits = chip_away_bits(off_diff, 16); + } else { + pad_type = "char"; + pad_bits = chip_away_bits(off_diff, 8); + } + btf_dump_printf(d, "\n%s%s: %d;", pfx(lvl), pad_type, pad_bits); + off_diff -= pad_bits; + } +} + +static void btf_dump_emit_struct_fwd(struct btf_dump *d, __u32 id, + const struct btf_type *t) +{ + btf_dump_printf(d, "%s %s", + btf_is_struct(t) ? "struct" : "union", + btf_dump_type_name(d, id)); +} + +static void btf_dump_emit_struct_def(struct btf_dump *d, + __u32 id, + const struct btf_type *t, + int lvl) +{ + const struct btf_member *m = btf_members(t); + bool is_struct = btf_is_struct(t); + int align, i, packed, off = 0; + __u16 vlen = btf_vlen(t); + + packed = is_struct ? btf_is_struct_packed(d->btf, id, t) : 0; + + btf_dump_printf(d, "%s%s%s {", + is_struct ? "struct" : "union", + t->name_off ? " " : "", + btf_dump_type_name(d, id)); + + for (i = 0; i < vlen; i++, m++) { + const char *fname; + int m_off, m_sz; + + fname = btf_name_of(d, m->name_off); + m_sz = btf_member_bitfield_size(t, i); + m_off = btf_member_bit_offset(t, i); + align = packed ? 1 : btf__align_of(d->btf, m->type); + + btf_dump_emit_bit_padding(d, off, m_off, m_sz, align, lvl + 1); + btf_dump_printf(d, "\n%s", pfx(lvl + 1)); + btf_dump_emit_type_decl(d, m->type, fname, lvl + 1); + + if (m_sz) { + btf_dump_printf(d, ": %d", m_sz); + off = m_off + m_sz; + } else { + m_sz = max((__s64)0, btf__resolve_size(d->btf, m->type)); + off = m_off + m_sz * 8; + } + btf_dump_printf(d, ";"); + } + + /* pad at the end, if necessary */ + if (is_struct) { + align = packed ? 1 : btf__align_of(d->btf, id); + btf_dump_emit_bit_padding(d, off, t->size * 8, 0, align, + lvl + 1); + } + + if (vlen) + btf_dump_printf(d, "\n"); + btf_dump_printf(d, "%s}", pfx(lvl)); + if (packed) + btf_dump_printf(d, " __attribute__((packed))"); +} + +static const char *missing_base_types[][2] = { + /* + * GCC emits typedefs to its internal __PolyX_t types when compiling Arm + * SIMD intrinsics. Alias them to standard base types. + */ + { "__Poly8_t", "unsigned char" }, + { "__Poly16_t", "unsigned short" }, + { "__Poly64_t", "unsigned long long" }, + { "__Poly128_t", "unsigned __int128" }, +}; + +static void btf_dump_emit_missing_aliases(struct btf_dump *d, __u32 id, + const struct btf_type *t) +{ + const char *name = btf_dump_type_name(d, id); + int i; + + for (i = 0; i < ARRAY_SIZE(missing_base_types); i++) { + if (strcmp(name, missing_base_types[i][0]) == 0) { + btf_dump_printf(d, "typedef %s %s;\n\n", + missing_base_types[i][1], name); + break; + } + } +} + +static void btf_dump_emit_enum_fwd(struct btf_dump *d, __u32 id, + const struct btf_type *t) +{ + btf_dump_printf(d, "enum %s", btf_dump_type_name(d, id)); +} + +static void btf_dump_emit_enum_def(struct btf_dump *d, __u32 id, + const struct btf_type *t, + int lvl) +{ + const struct btf_enum *v = btf_enum(t); + __u16 vlen = btf_vlen(t); + const char *name; + size_t dup_cnt; + int i; + + btf_dump_printf(d, "enum%s%s", + t->name_off ? " " : "", + btf_dump_type_name(d, id)); + + if (vlen) { + btf_dump_printf(d, " {"); + for (i = 0; i < vlen; i++, v++) { + name = btf_name_of(d, v->name_off); + /* enumerators share namespace with typedef idents */ + dup_cnt = btf_dump_name_dups(d, d->ident_names, name); + if (dup_cnt > 1) { + btf_dump_printf(d, "\n%s%s___%zu = %u,", + pfx(lvl + 1), name, dup_cnt, + (__u32)v->val); + } else { + btf_dump_printf(d, "\n%s%s = %u,", + pfx(lvl + 1), name, + (__u32)v->val); + } + } + btf_dump_printf(d, "\n%s}", pfx(lvl)); + } +} + +static void btf_dump_emit_fwd_def(struct btf_dump *d, __u32 id, + const struct btf_type *t) +{ + const char *name = btf_dump_type_name(d, id); + + if (btf_kflag(t)) + btf_dump_printf(d, "union %s", name); + else + btf_dump_printf(d, "struct %s", name); +} + +static void btf_dump_emit_typedef_def(struct btf_dump *d, __u32 id, + const struct btf_type *t, int lvl) +{ + const char *name = btf_dump_ident_name(d, id); + + /* + * Old GCC versions are emitting invalid typedef for __gnuc_va_list + * pointing to VOID. This generates warnings from btf_dump() and + * results in uncompilable header file, so we are fixing it up here + * with valid typedef into __builtin_va_list. + */ + if (t->type == 0 && strcmp(name, "__gnuc_va_list") == 0) { + btf_dump_printf(d, "typedef __builtin_va_list __gnuc_va_list"); + return; + } + + btf_dump_printf(d, "typedef "); + btf_dump_emit_type_decl(d, t->type, name, lvl); +} + +static int btf_dump_push_decl_stack_id(struct btf_dump *d, __u32 id) +{ + __u32 *new_stack; + size_t new_cap; + + if (d->decl_stack_cnt >= d->decl_stack_cap) { + new_cap = max(16, d->decl_stack_cap * 3 / 2); + new_stack = libbpf_reallocarray(d->decl_stack, new_cap, sizeof(new_stack[0])); + if (!new_stack) + return -ENOMEM; + d->decl_stack = new_stack; + d->decl_stack_cap = new_cap; + } + + d->decl_stack[d->decl_stack_cnt++] = id; + + return 0; +} + +/* + * Emit type declaration (e.g., field type declaration in a struct or argument + * declaration in function prototype) in correct C syntax. + * + * For most types it's trivial, but there are few quirky type declaration + * cases worth mentioning: + * - function prototypes (especially nesting of function prototypes); + * - arrays; + * - const/volatile/restrict for pointers vs other types. + * + * For a good discussion of *PARSING* C syntax (as a human), see + * Peter van der Linden's "Expert C Programming: Deep C Secrets", + * Ch.3 "Unscrambling Declarations in C". + * + * It won't help with BTF to C conversion much, though, as it's an opposite + * problem. So we came up with this algorithm in reverse to van der Linden's + * parsing algorithm. It goes from structured BTF representation of type + * declaration to a valid compilable C syntax. + * + * For instance, consider this C typedef: + * typedef const int * const * arr[10] arr_t; + * It will be represented in BTF with this chain of BTF types: + * [typedef] -> [array] -> [ptr] -> [const] -> [ptr] -> [const] -> [int] + * + * Notice how [const] modifier always goes before type it modifies in BTF type + * graph, but in C syntax, const/volatile/restrict modifiers are written to + * the right of pointers, but to the left of other types. There are also other + * quirks, like function pointers, arrays of them, functions returning other + * functions, etc. + * + * We handle that by pushing all the types to a stack, until we hit "terminal" + * type (int/enum/struct/union/fwd). Then depending on the kind of a type on + * top of a stack, modifiers are handled differently. Array/function pointers + * have also wildly different syntax and how nesting of them are done. See + * code for authoritative definition. + * + * To avoid allocating new stack for each independent chain of BTF types, we + * share one bigger stack, with each chain working only on its own local view + * of a stack frame. Some care is required to "pop" stack frames after + * processing type declaration chain. + */ +int btf_dump__emit_type_decl(struct btf_dump *d, __u32 id, + const struct btf_dump_emit_type_decl_opts *opts) +{ + const char *fname; + int lvl, err; + + if (!OPTS_VALID(opts, btf_dump_emit_type_decl_opts)) + return -EINVAL; + + err = btf_dump_resize(d); + if (err) + return -EINVAL; + + fname = OPTS_GET(opts, field_name, ""); + lvl = OPTS_GET(opts, indent_level, 0); + d->strip_mods = OPTS_GET(opts, strip_mods, false); + btf_dump_emit_type_decl(d, id, fname, lvl); + d->strip_mods = false; + return 0; +} + +static void btf_dump_emit_type_decl(struct btf_dump *d, __u32 id, + const char *fname, int lvl) +{ + struct id_stack decl_stack; + const struct btf_type *t; + int err, stack_start; + + stack_start = d->decl_stack_cnt; + for (;;) { + t = btf__type_by_id(d->btf, id); + if (d->strip_mods && btf_is_mod(t)) + goto skip_mod; + + err = btf_dump_push_decl_stack_id(d, id); + if (err < 0) { + /* + * if we don't have enough memory for entire type decl + * chain, restore stack, emit warning, and try to + * proceed nevertheless + */ + pr_warn("not enough memory for decl stack:%d", err); + d->decl_stack_cnt = stack_start; + return; + } +skip_mod: + /* VOID */ + if (id == 0) + break; + + switch (btf_kind(t)) { + case BTF_KIND_PTR: + case BTF_KIND_VOLATILE: + case BTF_KIND_CONST: + case BTF_KIND_RESTRICT: + case BTF_KIND_FUNC_PROTO: + id = t->type; + break; + case BTF_KIND_ARRAY: + id = btf_array(t)->type; + break; + case BTF_KIND_INT: + case BTF_KIND_ENUM: + case BTF_KIND_FWD: + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: + case BTF_KIND_TYPEDEF: + case BTF_KIND_FLOAT: + goto done; + default: + pr_warn("unexpected type in decl chain, kind:%u, id:[%u]\n", + btf_kind(t), id); + goto done; + } + } +done: + /* + * We might be inside a chain of declarations (e.g., array of function + * pointers returning anonymous (so inlined) structs, having another + * array field). Each of those needs its own "stack frame" to handle + * emitting of declarations. Those stack frames are non-overlapping + * portions of shared btf_dump->decl_stack. To make it a bit nicer to + * handle this set of nested stacks, we create a view corresponding to + * our own "stack frame" and work with it as an independent stack. + * We'll need to clean up after emit_type_chain() returns, though. + */ + decl_stack.ids = d->decl_stack + stack_start; + decl_stack.cnt = d->decl_stack_cnt - stack_start; + btf_dump_emit_type_chain(d, &decl_stack, fname, lvl); + /* + * emit_type_chain() guarantees that it will pop its entire decl_stack + * frame before returning. But it works with a read-only view into + * decl_stack, so it doesn't actually pop anything from the + * perspective of shared btf_dump->decl_stack, per se. We need to + * reset decl_stack state to how it was before us to avoid it growing + * all the time. + */ + d->decl_stack_cnt = stack_start; +} + +static void btf_dump_emit_mods(struct btf_dump *d, struct id_stack *decl_stack) +{ + const struct btf_type *t; + __u32 id; + + while (decl_stack->cnt) { + id = decl_stack->ids[decl_stack->cnt - 1]; + t = btf__type_by_id(d->btf, id); + + switch (btf_kind(t)) { + case BTF_KIND_VOLATILE: + btf_dump_printf(d, "volatile "); + break; + case BTF_KIND_CONST: + btf_dump_printf(d, "const "); + break; + case BTF_KIND_RESTRICT: + btf_dump_printf(d, "restrict "); + break; + default: + return; + } + decl_stack->cnt--; + } +} + +static void btf_dump_drop_mods(struct btf_dump *d, struct id_stack *decl_stack) +{ + const struct btf_type *t; + __u32 id; + + while (decl_stack->cnt) { + id = decl_stack->ids[decl_stack->cnt - 1]; + t = btf__type_by_id(d->btf, id); + if (!btf_is_mod(t)) + return; + decl_stack->cnt--; + } +} + +static void btf_dump_emit_name(const struct btf_dump *d, + const char *name, bool last_was_ptr) +{ + bool separate = name[0] && !last_was_ptr; + + btf_dump_printf(d, "%s%s", separate ? " " : "", name); +} + +static void btf_dump_emit_type_chain(struct btf_dump *d, + struct id_stack *decls, + const char *fname, int lvl) +{ + /* + * last_was_ptr is used to determine if we need to separate pointer + * asterisk (*) from previous part of type signature with space, so + * that we get `int ***`, instead of `int * * *`. We default to true + * for cases where we have single pointer in a chain. E.g., in ptr -> + * func_proto case. func_proto will start a new emit_type_chain call + * with just ptr, which should be emitted as (*) or (*), so we + * don't want to prepend space for that last pointer. + */ + bool last_was_ptr = true; + const struct btf_type *t; + const char *name; + __u16 kind; + __u32 id; + + while (decls->cnt) { + id = decls->ids[--decls->cnt]; + if (id == 0) { + /* VOID is a special snowflake */ + btf_dump_emit_mods(d, decls); + btf_dump_printf(d, "void"); + last_was_ptr = false; + continue; + } + + t = btf__type_by_id(d->btf, id); + kind = btf_kind(t); + + switch (kind) { + case BTF_KIND_INT: + case BTF_KIND_FLOAT: + btf_dump_emit_mods(d, decls); + name = btf_name_of(d, t->name_off); + btf_dump_printf(d, "%s", name); + break; + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: + btf_dump_emit_mods(d, decls); + /* inline anonymous struct/union */ + if (t->name_off == 0) + btf_dump_emit_struct_def(d, id, t, lvl); + else + btf_dump_emit_struct_fwd(d, id, t); + break; + case BTF_KIND_ENUM: + btf_dump_emit_mods(d, decls); + /* inline anonymous enum */ + if (t->name_off == 0) + btf_dump_emit_enum_def(d, id, t, lvl); + else + btf_dump_emit_enum_fwd(d, id, t); + break; + case BTF_KIND_FWD: + btf_dump_emit_mods(d, decls); + btf_dump_emit_fwd_def(d, id, t); + break; + case BTF_KIND_TYPEDEF: + btf_dump_emit_mods(d, decls); + btf_dump_printf(d, "%s", btf_dump_ident_name(d, id)); + break; + case BTF_KIND_PTR: + btf_dump_printf(d, "%s", last_was_ptr ? "*" : " *"); + break; + case BTF_KIND_VOLATILE: + btf_dump_printf(d, " volatile"); + break; + case BTF_KIND_CONST: + btf_dump_printf(d, " const"); + break; + case BTF_KIND_RESTRICT: + btf_dump_printf(d, " restrict"); + break; + case BTF_KIND_ARRAY: { + const struct btf_array *a = btf_array(t); + const struct btf_type *next_t; + __u32 next_id; + bool multidim; + /* + * GCC has a bug + * (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=8354) + * which causes it to emit extra const/volatile + * modifiers for an array, if array's element type has + * const/volatile modifiers. Clang doesn't do that. + * In general, it doesn't seem very meaningful to have + * a const/volatile modifier for array, so we are + * going to silently skip them here. + */ + btf_dump_drop_mods(d, decls); + + if (decls->cnt == 0) { + btf_dump_emit_name(d, fname, last_was_ptr); + btf_dump_printf(d, "[%u]", a->nelems); + return; + } + + next_id = decls->ids[decls->cnt - 1]; + next_t = btf__type_by_id(d->btf, next_id); + multidim = btf_is_array(next_t); + /* we need space if we have named non-pointer */ + if (fname[0] && !last_was_ptr) + btf_dump_printf(d, " "); + /* no parentheses for multi-dimensional array */ + if (!multidim) + btf_dump_printf(d, "("); + btf_dump_emit_type_chain(d, decls, fname, lvl); + if (!multidim) + btf_dump_printf(d, ")"); + btf_dump_printf(d, "[%u]", a->nelems); + return; + } + case BTF_KIND_FUNC_PROTO: { + const struct btf_param *p = btf_params(t); + __u16 vlen = btf_vlen(t); + int i; + + /* + * GCC emits extra volatile qualifier for + * __attribute__((noreturn)) function pointers. Clang + * doesn't do it. It's a GCC quirk for backwards + * compatibility with code written for GCC <2.5. So, + * similarly to extra qualifiers for array, just drop + * them, instead of handling them. + */ + btf_dump_drop_mods(d, decls); + if (decls->cnt) { + btf_dump_printf(d, " ("); + btf_dump_emit_type_chain(d, decls, fname, lvl); + btf_dump_printf(d, ")"); + } else { + btf_dump_emit_name(d, fname, last_was_ptr); + } + btf_dump_printf(d, "("); + /* + * Clang for BPF target generates func_proto with no + * args as a func_proto with a single void arg (e.g., + * `int (*f)(void)` vs just `int (*f)()`). We are + * going to pretend there are no args for such case. + */ + if (vlen == 1 && p->type == 0) { + btf_dump_printf(d, ")"); + return; + } + + for (i = 0; i < vlen; i++, p++) { + if (i > 0) + btf_dump_printf(d, ", "); + + /* last arg of type void is vararg */ + if (i == vlen - 1 && p->type == 0) { + btf_dump_printf(d, "..."); + break; + } + + name = btf_name_of(d, p->name_off); + btf_dump_emit_type_decl(d, p->type, name, lvl); + } + + btf_dump_printf(d, ")"); + return; + } + default: + pr_warn("unexpected type in decl chain, kind:%u, id:[%u]\n", + kind, id); + return; + } + + last_was_ptr = kind == BTF_KIND_PTR; + } + + btf_dump_emit_name(d, fname, last_was_ptr); +} + +/* return number of duplicates (occurrences) of a given name */ +static size_t btf_dump_name_dups(struct btf_dump *d, struct hashmap *name_map, + const char *orig_name) +{ + size_t dup_cnt = 0; + + hashmap__find(name_map, orig_name, (void **)&dup_cnt); + dup_cnt++; + hashmap__set(name_map, orig_name, (void *)dup_cnt, NULL, NULL); + + return dup_cnt; +} + +static const char *btf_dump_resolve_name(struct btf_dump *d, __u32 id, + struct hashmap *name_map) +{ + struct btf_dump_type_aux_state *s = &d->type_states[id]; + const struct btf_type *t = btf__type_by_id(d->btf, id); + const char *orig_name = btf_name_of(d, t->name_off); + const char **cached_name = &d->cached_names[id]; + size_t dup_cnt; + + if (t->name_off == 0) + return ""; + + if (s->name_resolved) + return *cached_name ? *cached_name : orig_name; + + dup_cnt = btf_dump_name_dups(d, name_map, orig_name); + if (dup_cnt > 1) { + const size_t max_len = 256; + char new_name[max_len]; + + snprintf(new_name, max_len, "%s___%zu", orig_name, dup_cnt); + *cached_name = strdup(new_name); + } + + s->name_resolved = 1; + return *cached_name ? *cached_name : orig_name; +} + +static const char *btf_dump_type_name(struct btf_dump *d, __u32 id) +{ + return btf_dump_resolve_name(d, id, d->type_names); +} + +static const char *btf_dump_ident_name(struct btf_dump *d, __u32 id) +{ + return btf_dump_resolve_name(d, id, d->ident_names); +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/btf.h dwarves-dfsg-1.21/lib/bpf/src/btf.h --- dwarves-dfsg-1.10/lib/bpf/src/btf.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/btf.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,375 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ +/* Copyright (c) 2018 Facebook */ + +#ifndef __LIBBPF_BTF_H +#define __LIBBPF_BTF_H + +#include +#include +#include +#include + +#include "libbpf_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BTF_ELF_SEC ".BTF" +#define BTF_EXT_ELF_SEC ".BTF.ext" +#define MAPS_ELF_SEC ".maps" + +struct btf; +struct btf_ext; +struct btf_type; + +struct bpf_object; + +enum btf_endianness { + BTF_LITTLE_ENDIAN = 0, + BTF_BIG_ENDIAN = 1, +}; + +LIBBPF_API void btf__free(struct btf *btf); + +LIBBPF_API struct btf *btf__new(const void *data, __u32 size); +LIBBPF_API struct btf *btf__new_split(const void *data, __u32 size, struct btf *base_btf); +LIBBPF_API struct btf *btf__new_empty(void); +LIBBPF_API struct btf *btf__new_empty_split(struct btf *base_btf); + +LIBBPF_API struct btf *btf__parse(const char *path, struct btf_ext **btf_ext); +LIBBPF_API struct btf *btf__parse_split(const char *path, struct btf *base_btf); +LIBBPF_API struct btf *btf__parse_elf(const char *path, struct btf_ext **btf_ext); +LIBBPF_API struct btf *btf__parse_elf_split(const char *path, struct btf *base_btf); +LIBBPF_API struct btf *btf__parse_raw(const char *path); +LIBBPF_API struct btf *btf__parse_raw_split(const char *path, struct btf *base_btf); + +LIBBPF_API int btf__finalize_data(struct bpf_object *obj, struct btf *btf); +LIBBPF_API int btf__load(struct btf *btf); +LIBBPF_API __s32 btf__find_by_name(const struct btf *btf, + const char *type_name); +LIBBPF_API __s32 btf__find_by_name_kind(const struct btf *btf, + const char *type_name, __u32 kind); +LIBBPF_API __u32 btf__get_nr_types(const struct btf *btf); +LIBBPF_API const struct btf *btf__base_btf(const struct btf *btf); +LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf, + __u32 id); +LIBBPF_API size_t btf__pointer_size(const struct btf *btf); +LIBBPF_API int btf__set_pointer_size(struct btf *btf, size_t ptr_sz); +LIBBPF_API enum btf_endianness btf__endianness(const struct btf *btf); +LIBBPF_API int btf__set_endianness(struct btf *btf, enum btf_endianness endian); +LIBBPF_API __s64 btf__resolve_size(const struct btf *btf, __u32 type_id); +LIBBPF_API int btf__resolve_type(const struct btf *btf, __u32 type_id); +LIBBPF_API int btf__align_of(const struct btf *btf, __u32 id); +LIBBPF_API int btf__fd(const struct btf *btf); +LIBBPF_API void btf__set_fd(struct btf *btf, int fd); +LIBBPF_API const void *btf__get_raw_data(const struct btf *btf, __u32 *size); +LIBBPF_API const char *btf__name_by_offset(const struct btf *btf, __u32 offset); +LIBBPF_API const char *btf__str_by_offset(const struct btf *btf, __u32 offset); +LIBBPF_API int btf__get_from_id(__u32 id, struct btf **btf); +LIBBPF_API int btf__get_map_kv_tids(const struct btf *btf, const char *map_name, + __u32 expected_key_size, + __u32 expected_value_size, + __u32 *key_type_id, __u32 *value_type_id); + +LIBBPF_API struct btf_ext *btf_ext__new(__u8 *data, __u32 size); +LIBBPF_API void btf_ext__free(struct btf_ext *btf_ext); +LIBBPF_API const void *btf_ext__get_raw_data(const struct btf_ext *btf_ext, + __u32 *size); +LIBBPF_API LIBBPF_DEPRECATED("btf_ext__reloc_func_info was never meant as a public API and has wrong assumptions embedded in it; it will be removed in the future libbpf versions") +int btf_ext__reloc_func_info(const struct btf *btf, + const struct btf_ext *btf_ext, + const char *sec_name, __u32 insns_cnt, + void **func_info, __u32 *cnt); +LIBBPF_API LIBBPF_DEPRECATED("btf_ext__reloc_line_info was never meant as a public API and has wrong assumptions embedded in it; it will be removed in the future libbpf versions") +int btf_ext__reloc_line_info(const struct btf *btf, + const struct btf_ext *btf_ext, + const char *sec_name, __u32 insns_cnt, + void **line_info, __u32 *cnt); +LIBBPF_API __u32 btf_ext__func_info_rec_size(const struct btf_ext *btf_ext); +LIBBPF_API __u32 btf_ext__line_info_rec_size(const struct btf_ext *btf_ext); + +LIBBPF_API struct btf *libbpf_find_kernel_btf(void); + +LIBBPF_API int btf__find_str(struct btf *btf, const char *s); +LIBBPF_API int btf__add_str(struct btf *btf, const char *s); + +LIBBPF_API int btf__add_int(struct btf *btf, const char *name, size_t byte_sz, int encoding); +LIBBPF_API int btf__add_float(struct btf *btf, const char *name, size_t byte_sz); +LIBBPF_API int btf__add_ptr(struct btf *btf, int ref_type_id); +LIBBPF_API int btf__add_array(struct btf *btf, + int index_type_id, int elem_type_id, __u32 nr_elems); +/* struct/union construction APIs */ +LIBBPF_API int btf__add_struct(struct btf *btf, const char *name, __u32 sz); +LIBBPF_API int btf__add_union(struct btf *btf, const char *name, __u32 sz); +LIBBPF_API int btf__add_field(struct btf *btf, const char *name, int field_type_id, + __u32 bit_offset, __u32 bit_size); + +/* enum construction APIs */ +LIBBPF_API int btf__add_enum(struct btf *btf, const char *name, __u32 bytes_sz); +LIBBPF_API int btf__add_enum_value(struct btf *btf, const char *name, __s64 value); + +enum btf_fwd_kind { + BTF_FWD_STRUCT = 0, + BTF_FWD_UNION = 1, + BTF_FWD_ENUM = 2, +}; + +LIBBPF_API int btf__add_fwd(struct btf *btf, const char *name, enum btf_fwd_kind fwd_kind); +LIBBPF_API int btf__add_typedef(struct btf *btf, const char *name, int ref_type_id); +LIBBPF_API int btf__add_volatile(struct btf *btf, int ref_type_id); +LIBBPF_API int btf__add_const(struct btf *btf, int ref_type_id); +LIBBPF_API int btf__add_restrict(struct btf *btf, int ref_type_id); + +/* func and func_proto construction APIs */ +LIBBPF_API int btf__add_func(struct btf *btf, const char *name, + enum btf_func_linkage linkage, int proto_type_id); +LIBBPF_API int btf__add_func_proto(struct btf *btf, int ret_type_id); +LIBBPF_API int btf__add_func_param(struct btf *btf, const char *name, int type_id); + +/* var & datasec construction APIs */ +LIBBPF_API int btf__add_var(struct btf *btf, const char *name, int linkage, int type_id); +LIBBPF_API int btf__add_datasec(struct btf *btf, const char *name, __u32 byte_sz); +LIBBPF_API int btf__add_datasec_var_info(struct btf *btf, int var_type_id, + __u32 offset, __u32 byte_sz); + +struct btf_dedup_opts { + unsigned int dedup_table_size; + bool dont_resolve_fwds; +}; + +LIBBPF_API int btf__dedup(struct btf *btf, struct btf_ext *btf_ext, + const struct btf_dedup_opts *opts); + +struct btf_dump; + +struct btf_dump_opts { + void *ctx; +}; + +typedef void (*btf_dump_printf_fn_t)(void *ctx, const char *fmt, va_list args); + +LIBBPF_API struct btf_dump *btf_dump__new(const struct btf *btf, + const struct btf_ext *btf_ext, + const struct btf_dump_opts *opts, + btf_dump_printf_fn_t printf_fn); +LIBBPF_API void btf_dump__free(struct btf_dump *d); + +LIBBPF_API int btf_dump__dump_type(struct btf_dump *d, __u32 id); + +struct btf_dump_emit_type_decl_opts { + /* size of this struct, for forward/backward compatiblity */ + size_t sz; + /* optional field name for type declaration, e.g.: + * - struct my_struct + * - void (*)(int) + * - char (*)[123] + */ + const char *field_name; + /* extra indentation level (in number of tabs) to emit for multi-line + * type declarations (e.g., anonymous struct); applies for lines + * starting from the second one (first line is assumed to have + * necessary indentation already + */ + int indent_level; + /* strip all the const/volatile/restrict mods */ + bool strip_mods; +}; +#define btf_dump_emit_type_decl_opts__last_field strip_mods + +LIBBPF_API int +btf_dump__emit_type_decl(struct btf_dump *d, __u32 id, + const struct btf_dump_emit_type_decl_opts *opts); + +/* + * A set of helpers for easier BTF types handling + */ +static inline __u16 btf_kind(const struct btf_type *t) +{ + return BTF_INFO_KIND(t->info); +} + +static inline __u16 btf_vlen(const struct btf_type *t) +{ + return BTF_INFO_VLEN(t->info); +} + +static inline bool btf_kflag(const struct btf_type *t) +{ + return BTF_INFO_KFLAG(t->info); +} + +static inline bool btf_is_void(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_UNKN; +} + +static inline bool btf_is_int(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_INT; +} + +static inline bool btf_is_ptr(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_PTR; +} + +static inline bool btf_is_array(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_ARRAY; +} + +static inline bool btf_is_struct(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_STRUCT; +} + +static inline bool btf_is_union(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_UNION; +} + +static inline bool btf_is_composite(const struct btf_type *t) +{ + __u16 kind = btf_kind(t); + + return kind == BTF_KIND_STRUCT || kind == BTF_KIND_UNION; +} + +static inline bool btf_is_enum(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_ENUM; +} + +static inline bool btf_is_fwd(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_FWD; +} + +static inline bool btf_is_typedef(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_TYPEDEF; +} + +static inline bool btf_is_volatile(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_VOLATILE; +} + +static inline bool btf_is_const(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_CONST; +} + +static inline bool btf_is_restrict(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_RESTRICT; +} + +static inline bool btf_is_mod(const struct btf_type *t) +{ + __u16 kind = btf_kind(t); + + return kind == BTF_KIND_VOLATILE || + kind == BTF_KIND_CONST || + kind == BTF_KIND_RESTRICT; +} + +static inline bool btf_is_func(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_FUNC; +} + +static inline bool btf_is_func_proto(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_FUNC_PROTO; +} + +static inline bool btf_is_var(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_VAR; +} + +static inline bool btf_is_datasec(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_DATASEC; +} + +static inline bool btf_is_float(const struct btf_type *t) +{ + return btf_kind(t) == BTF_KIND_FLOAT; +} + +static inline __u8 btf_int_encoding(const struct btf_type *t) +{ + return BTF_INT_ENCODING(*(__u32 *)(t + 1)); +} + +static inline __u8 btf_int_offset(const struct btf_type *t) +{ + return BTF_INT_OFFSET(*(__u32 *)(t + 1)); +} + +static inline __u8 btf_int_bits(const struct btf_type *t) +{ + return BTF_INT_BITS(*(__u32 *)(t + 1)); +} + +static inline struct btf_array *btf_array(const struct btf_type *t) +{ + return (struct btf_array *)(t + 1); +} + +static inline struct btf_enum *btf_enum(const struct btf_type *t) +{ + return (struct btf_enum *)(t + 1); +} + +static inline struct btf_member *btf_members(const struct btf_type *t) +{ + return (struct btf_member *)(t + 1); +} + +/* Get bit offset of a member with specified index. */ +static inline __u32 btf_member_bit_offset(const struct btf_type *t, + __u32 member_idx) +{ + const struct btf_member *m = btf_members(t) + member_idx; + bool kflag = btf_kflag(t); + + return kflag ? BTF_MEMBER_BIT_OFFSET(m->offset) : m->offset; +} +/* + * Get bitfield size of a member, assuming t is BTF_KIND_STRUCT or + * BTF_KIND_UNION. If member is not a bitfield, zero is returned. + */ +static inline __u32 btf_member_bitfield_size(const struct btf_type *t, + __u32 member_idx) +{ + const struct btf_member *m = btf_members(t) + member_idx; + bool kflag = btf_kflag(t); + + return kflag ? BTF_MEMBER_BITFIELD_SIZE(m->offset) : 0; +} + +static inline struct btf_param *btf_params(const struct btf_type *t) +{ + return (struct btf_param *)(t + 1); +} + +static inline struct btf_var *btf_var(const struct btf_type *t) +{ + return (struct btf_var *)(t + 1); +} + +static inline struct btf_var_secinfo * +btf_var_secinfos(const struct btf_type *t) +{ + return (struct btf_var_secinfo *)(t + 1); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __LIBBPF_BTF_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/src/.gitignore dwarves-dfsg-1.21/lib/bpf/src/.gitignore --- dwarves-dfsg-1.10/lib/bpf/src/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/.gitignore 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,6 @@ +*.o +*.a +/libbpf.pc +/libbpf.so* +/staticobjs +/sharedobjs diff -Nru dwarves-dfsg-1.10/lib/bpf/src/hashmap.c dwarves-dfsg-1.21/lib/bpf/src/hashmap.c --- dwarves-dfsg-1.10/lib/bpf/src/hashmap.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/hashmap.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,241 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +/* + * Generic non-thread safe hash map implementation. + * + * Copyright (c) 2019 Facebook + */ +#include +#include +#include +#include +#include +#include "hashmap.h" + +/* make sure libbpf doesn't use kernel-only integer typedefs */ +#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64 + +/* prevent accidental re-addition of reallocarray() */ +#pragma GCC poison reallocarray + +/* start with 4 buckets */ +#define HASHMAP_MIN_CAP_BITS 2 + +static void hashmap_add_entry(struct hashmap_entry **pprev, + struct hashmap_entry *entry) +{ + entry->next = *pprev; + *pprev = entry; +} + +static void hashmap_del_entry(struct hashmap_entry **pprev, + struct hashmap_entry *entry) +{ + *pprev = entry->next; + entry->next = NULL; +} + +void hashmap__init(struct hashmap *map, hashmap_hash_fn hash_fn, + hashmap_equal_fn equal_fn, void *ctx) +{ + map->hash_fn = hash_fn; + map->equal_fn = equal_fn; + map->ctx = ctx; + + map->buckets = NULL; + map->cap = 0; + map->cap_bits = 0; + map->sz = 0; +} + +struct hashmap *hashmap__new(hashmap_hash_fn hash_fn, + hashmap_equal_fn equal_fn, + void *ctx) +{ + struct hashmap *map = malloc(sizeof(struct hashmap)); + + if (!map) + return ERR_PTR(-ENOMEM); + hashmap__init(map, hash_fn, equal_fn, ctx); + return map; +} + +void hashmap__clear(struct hashmap *map) +{ + struct hashmap_entry *cur, *tmp; + size_t bkt; + + hashmap__for_each_entry_safe(map, cur, tmp, bkt) { + free(cur); + } + free(map->buckets); + map->buckets = NULL; + map->cap = map->cap_bits = map->sz = 0; +} + +void hashmap__free(struct hashmap *map) +{ + if (!map) + return; + + hashmap__clear(map); + free(map); +} + +size_t hashmap__size(const struct hashmap *map) +{ + return map->sz; +} + +size_t hashmap__capacity(const struct hashmap *map) +{ + return map->cap; +} + +static bool hashmap_needs_to_grow(struct hashmap *map) +{ + /* grow if empty or more than 75% filled */ + return (map->cap == 0) || ((map->sz + 1) * 4 / 3 > map->cap); +} + +static int hashmap_grow(struct hashmap *map) +{ + struct hashmap_entry **new_buckets; + struct hashmap_entry *cur, *tmp; + size_t new_cap_bits, new_cap; + size_t h, bkt; + + new_cap_bits = map->cap_bits + 1; + if (new_cap_bits < HASHMAP_MIN_CAP_BITS) + new_cap_bits = HASHMAP_MIN_CAP_BITS; + + new_cap = 1UL << new_cap_bits; + new_buckets = calloc(new_cap, sizeof(new_buckets[0])); + if (!new_buckets) + return -ENOMEM; + + hashmap__for_each_entry_safe(map, cur, tmp, bkt) { + h = hash_bits(map->hash_fn(cur->key, map->ctx), new_cap_bits); + hashmap_add_entry(&new_buckets[h], cur); + } + + map->cap = new_cap; + map->cap_bits = new_cap_bits; + free(map->buckets); + map->buckets = new_buckets; + + return 0; +} + +static bool hashmap_find_entry(const struct hashmap *map, + const void *key, size_t hash, + struct hashmap_entry ***pprev, + struct hashmap_entry **entry) +{ + struct hashmap_entry *cur, **prev_ptr; + + if (!map->buckets) + return false; + + for (prev_ptr = &map->buckets[hash], cur = *prev_ptr; + cur; + prev_ptr = &cur->next, cur = cur->next) { + if (map->equal_fn(cur->key, key, map->ctx)) { + if (pprev) + *pprev = prev_ptr; + *entry = cur; + return true; + } + } + + return false; +} + +int hashmap__insert(struct hashmap *map, const void *key, void *value, + enum hashmap_insert_strategy strategy, + const void **old_key, void **old_value) +{ + struct hashmap_entry *entry; + size_t h; + int err; + + if (old_key) + *old_key = NULL; + if (old_value) + *old_value = NULL; + + h = hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + if (strategy != HASHMAP_APPEND && + hashmap_find_entry(map, key, h, NULL, &entry)) { + if (old_key) + *old_key = entry->key; + if (old_value) + *old_value = entry->value; + + if (strategy == HASHMAP_SET || strategy == HASHMAP_UPDATE) { + entry->key = key; + entry->value = value; + return 0; + } else if (strategy == HASHMAP_ADD) { + return -EEXIST; + } + } + + if (strategy == HASHMAP_UPDATE) + return -ENOENT; + + if (hashmap_needs_to_grow(map)) { + err = hashmap_grow(map); + if (err) + return err; + h = hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + } + + entry = malloc(sizeof(struct hashmap_entry)); + if (!entry) + return -ENOMEM; + + entry->key = key; + entry->value = value; + hashmap_add_entry(&map->buckets[h], entry); + map->sz++; + + return 0; +} + +bool hashmap__find(const struct hashmap *map, const void *key, void **value) +{ + struct hashmap_entry *entry; + size_t h; + + h = hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + if (!hashmap_find_entry(map, key, h, NULL, &entry)) + return false; + + if (value) + *value = entry->value; + return true; +} + +bool hashmap__delete(struct hashmap *map, const void *key, + const void **old_key, void **old_value) +{ + struct hashmap_entry **pprev, *entry; + size_t h; + + h = hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + if (!hashmap_find_entry(map, key, h, &pprev, &entry)) + return false; + + if (old_key) + *old_key = entry->key; + if (old_value) + *old_value = entry->value; + + hashmap_del_entry(pprev, entry); + free(entry); + map->sz--; + + return true; +} + diff -Nru dwarves-dfsg-1.10/lib/bpf/src/hashmap.h dwarves-dfsg-1.21/lib/bpf/src/hashmap.h --- dwarves-dfsg-1.10/lib/bpf/src/hashmap.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/hashmap.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,195 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +/* + * Generic non-thread safe hash map implementation. + * + * Copyright (c) 2019 Facebook + */ +#ifndef __LIBBPF_HASHMAP_H +#define __LIBBPF_HASHMAP_H + +#include +#include +#include + +static inline size_t hash_bits(size_t h, int bits) +{ + /* shuffle bits and return requested number of upper bits */ + if (bits == 0) + return 0; + +#if (__SIZEOF_SIZE_T__ == __SIZEOF_LONG_LONG__) + /* LP64 case */ + return (h * 11400714819323198485llu) >> (__SIZEOF_LONG_LONG__ * 8 - bits); +#elif (__SIZEOF_SIZE_T__ <= __SIZEOF_LONG__) + return (h * 2654435769lu) >> (__SIZEOF_LONG__ * 8 - bits); +#else +# error "Unsupported size_t size" +#endif +} + +/* generic C-string hashing function */ +static inline size_t str_hash(const char *s) +{ + size_t h = 0; + + while (*s) { + h = h * 31 + *s; + s++; + } + return h; +} + +typedef size_t (*hashmap_hash_fn)(const void *key, void *ctx); +typedef bool (*hashmap_equal_fn)(const void *key1, const void *key2, void *ctx); + +struct hashmap_entry { + const void *key; + void *value; + struct hashmap_entry *next; +}; + +struct hashmap { + hashmap_hash_fn hash_fn; + hashmap_equal_fn equal_fn; + void *ctx; + + struct hashmap_entry **buckets; + size_t cap; + size_t cap_bits; + size_t sz; +}; + +#define HASHMAP_INIT(hash_fn, equal_fn, ctx) { \ + .hash_fn = (hash_fn), \ + .equal_fn = (equal_fn), \ + .ctx = (ctx), \ + .buckets = NULL, \ + .cap = 0, \ + .cap_bits = 0, \ + .sz = 0, \ +} + +void hashmap__init(struct hashmap *map, hashmap_hash_fn hash_fn, + hashmap_equal_fn equal_fn, void *ctx); +struct hashmap *hashmap__new(hashmap_hash_fn hash_fn, + hashmap_equal_fn equal_fn, + void *ctx); +void hashmap__clear(struct hashmap *map); +void hashmap__free(struct hashmap *map); + +size_t hashmap__size(const struct hashmap *map); +size_t hashmap__capacity(const struct hashmap *map); + +/* + * Hashmap insertion strategy: + * - HASHMAP_ADD - only add key/value if key doesn't exist yet; + * - HASHMAP_SET - add key/value pair if key doesn't exist yet; otherwise, + * update value; + * - HASHMAP_UPDATE - update value, if key already exists; otherwise, do + * nothing and return -ENOENT; + * - HASHMAP_APPEND - always add key/value pair, even if key already exists. + * This turns hashmap into a multimap by allowing multiple values to be + * associated with the same key. Most useful read API for such hashmap is + * hashmap__for_each_key_entry() iteration. If hashmap__find() is still + * used, it will return last inserted key/value entry (first in a bucket + * chain). + */ +enum hashmap_insert_strategy { + HASHMAP_ADD, + HASHMAP_SET, + HASHMAP_UPDATE, + HASHMAP_APPEND, +}; + +/* + * hashmap__insert() adds key/value entry w/ various semantics, depending on + * provided strategy value. If a given key/value pair replaced already + * existing key/value pair, both old key and old value will be returned + * through old_key and old_value to allow calling code do proper memory + * management. + */ +int hashmap__insert(struct hashmap *map, const void *key, void *value, + enum hashmap_insert_strategy strategy, + const void **old_key, void **old_value); + +static inline int hashmap__add(struct hashmap *map, + const void *key, void *value) +{ + return hashmap__insert(map, key, value, HASHMAP_ADD, NULL, NULL); +} + +static inline int hashmap__set(struct hashmap *map, + const void *key, void *value, + const void **old_key, void **old_value) +{ + return hashmap__insert(map, key, value, HASHMAP_SET, + old_key, old_value); +} + +static inline int hashmap__update(struct hashmap *map, + const void *key, void *value, + const void **old_key, void **old_value) +{ + return hashmap__insert(map, key, value, HASHMAP_UPDATE, + old_key, old_value); +} + +static inline int hashmap__append(struct hashmap *map, + const void *key, void *value) +{ + return hashmap__insert(map, key, value, HASHMAP_APPEND, NULL, NULL); +} + +bool hashmap__delete(struct hashmap *map, const void *key, + const void **old_key, void **old_value); + +bool hashmap__find(const struct hashmap *map, const void *key, void **value); + +/* + * hashmap__for_each_entry - iterate over all entries in hashmap + * @map: hashmap to iterate + * @cur: struct hashmap_entry * used as a loop cursor + * @bkt: integer used as a bucket loop cursor + */ +#define hashmap__for_each_entry(map, cur, bkt) \ + for (bkt = 0; bkt < map->cap; bkt++) \ + for (cur = map->buckets[bkt]; cur; cur = cur->next) + +/* + * hashmap__for_each_entry_safe - iterate over all entries in hashmap, safe + * against removals + * @map: hashmap to iterate + * @cur: struct hashmap_entry * used as a loop cursor + * @tmp: struct hashmap_entry * used as a temporary next cursor storage + * @bkt: integer used as a bucket loop cursor + */ +#define hashmap__for_each_entry_safe(map, cur, tmp, bkt) \ + for (bkt = 0; bkt < map->cap; bkt++) \ + for (cur = map->buckets[bkt]; \ + cur && ({tmp = cur->next; true; }); \ + cur = tmp) + +/* + * hashmap__for_each_key_entry - iterate over entries associated with given key + * @map: hashmap to iterate + * @cur: struct hashmap_entry * used as a loop cursor + * @key: key to iterate entries for + */ +#define hashmap__for_each_key_entry(map, cur, _key) \ + for (cur = map->buckets \ + ? map->buckets[hash_bits(map->hash_fn((_key), map->ctx), map->cap_bits)] \ + : NULL; \ + cur; \ + cur = cur->next) \ + if (map->equal_fn(cur->key, (_key), map->ctx)) + +#define hashmap__for_each_key_entry_safe(map, cur, tmp, _key) \ + for (cur = map->buckets \ + ? map->buckets[hash_bits(map->hash_fn((_key), map->ctx), map->cap_bits)] \ + : NULL; \ + cur && ({ tmp = cur->next; true; }); \ + cur = tmp) \ + if (map->equal_fn(cur->key, (_key), map->ctx)) + +#endif /* __LIBBPF_HASHMAP_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/src/libbpf.c dwarves-dfsg-1.21/lib/bpf/src/libbpf.c --- dwarves-dfsg-1.10/lib/bpf/src/libbpf.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/libbpf.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,11273 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +/* + * Common eBPF ELF object loading operations. + * + * Copyright (C) 2013-2015 Alexei Starovoitov + * Copyright (C) 2015 Wang Nan + * Copyright (C) 2015 Huawei Inc. + * Copyright (C) 2017 Nicira, Inc. + * Copyright (C) 2019 Isovalent, Inc. + */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libbpf.h" +#include "bpf.h" +#include "btf.h" +#include "str_error.h" +#include "libbpf_internal.h" +#include "hashmap.h" + +#ifndef EM_BPF +#define EM_BPF 247 +#endif + +#ifndef BPF_FS_MAGIC +#define BPF_FS_MAGIC 0xcafe4a11 +#endif + +#define BPF_INSN_SZ (sizeof(struct bpf_insn)) + +/* vsprintf() in __base_pr() uses nonliteral format string. It may break + * compilation if user enables corresponding warning. Disable it explicitly. + */ +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + +#define __printf(a, b) __attribute__((format(printf, a, b))) + +static struct bpf_map *bpf_object__add_map(struct bpf_object *obj); +static const struct btf_type * +skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id); + +static int __base_pr(enum libbpf_print_level level, const char *format, + va_list args) +{ + if (level == LIBBPF_DEBUG) + return 0; + + return vfprintf(stderr, format, args); +} + +static libbpf_print_fn_t __libbpf_pr = __base_pr; + +libbpf_print_fn_t libbpf_set_print(libbpf_print_fn_t fn) +{ + libbpf_print_fn_t old_print_fn = __libbpf_pr; + + __libbpf_pr = fn; + return old_print_fn; +} + +__printf(2, 3) +void libbpf_print(enum libbpf_print_level level, const char *format, ...) +{ + va_list args; + + if (!__libbpf_pr) + return; + + va_start(args, format); + __libbpf_pr(level, format, args); + va_end(args); +} + +static void pr_perm_msg(int err) +{ + struct rlimit limit; + char buf[100]; + + if (err != -EPERM || geteuid() != 0) + return; + + err = getrlimit(RLIMIT_MEMLOCK, &limit); + if (err) + return; + + if (limit.rlim_cur == RLIM_INFINITY) + return; + + if (limit.rlim_cur < 1024) + snprintf(buf, sizeof(buf), "%zu bytes", (size_t)limit.rlim_cur); + else if (limit.rlim_cur < 1024*1024) + snprintf(buf, sizeof(buf), "%.1f KiB", (double)limit.rlim_cur / 1024); + else + snprintf(buf, sizeof(buf), "%.1f MiB", (double)limit.rlim_cur / (1024*1024)); + + pr_warn("permission error while running as root; try raising 'ulimit -l'? current value: %s\n", + buf); +} + +#define STRERR_BUFSIZE 128 + +/* Copied from tools/perf/util/util.h */ +#ifndef zfree +# define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) +#endif + +#ifndef zclose +# define zclose(fd) ({ \ + int ___err = 0; \ + if ((fd) >= 0) \ + ___err = close((fd)); \ + fd = -1; \ + ___err; }) +#endif + +static inline __u64 ptr_to_u64(const void *ptr) +{ + return (__u64) (unsigned long) ptr; +} + +enum kern_feature_id { + /* v4.14: kernel support for program & map names. */ + FEAT_PROG_NAME, + /* v5.2: kernel support for global data sections. */ + FEAT_GLOBAL_DATA, + /* BTF support */ + FEAT_BTF, + /* BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO support */ + FEAT_BTF_FUNC, + /* BTF_KIND_VAR and BTF_KIND_DATASEC support */ + FEAT_BTF_DATASEC, + /* BTF_FUNC_GLOBAL is supported */ + FEAT_BTF_GLOBAL_FUNC, + /* BPF_F_MMAPABLE is supported for arrays */ + FEAT_ARRAY_MMAP, + /* kernel support for expected_attach_type in BPF_PROG_LOAD */ + FEAT_EXP_ATTACH_TYPE, + /* bpf_probe_read_{kernel,user}[_str] helpers */ + FEAT_PROBE_READ_KERN, + /* BPF_PROG_BIND_MAP is supported */ + FEAT_PROG_BIND_MAP, + /* Kernel support for module BTFs */ + FEAT_MODULE_BTF, + /* BTF_KIND_FLOAT support */ + FEAT_BTF_FLOAT, + __FEAT_CNT, +}; + +static bool kernel_supports(enum kern_feature_id feat_id); + +enum reloc_type { + RELO_LD64, + RELO_CALL, + RELO_DATA, + RELO_EXTERN, + RELO_SUBPROG_ADDR, +}; + +struct reloc_desc { + enum reloc_type type; + int insn_idx; + int map_idx; + int sym_off; + bool processed; +}; + +struct bpf_sec_def; + +typedef struct bpf_link *(*attach_fn_t)(const struct bpf_sec_def *sec, + struct bpf_program *prog); + +struct bpf_sec_def { + const char *sec; + size_t len; + enum bpf_prog_type prog_type; + enum bpf_attach_type expected_attach_type; + bool is_exp_attach_type_optional; + bool is_attachable; + bool is_attach_btf; + bool is_sleepable; + attach_fn_t attach_fn; +}; + +/* + * bpf_prog should be a better name but it has been used in + * linux/filter.h. + */ +struct bpf_program { + const struct bpf_sec_def *sec_def; + char *sec_name; + size_t sec_idx; + /* this program's instruction offset (in number of instructions) + * within its containing ELF section + */ + size_t sec_insn_off; + /* number of original instructions in ELF section belonging to this + * program, not taking into account subprogram instructions possible + * appended later during relocation + */ + size_t sec_insn_cnt; + /* Offset (in number of instructions) of the start of instruction + * belonging to this BPF program within its containing main BPF + * program. For the entry-point (main) BPF program, this is always + * zero. For a sub-program, this gets reset before each of main BPF + * programs are processed and relocated and is used to determined + * whether sub-program was already appended to the main program, and + * if yes, at which instruction offset. + */ + size_t sub_insn_off; + + char *name; + /* sec_name with / replaced by _; makes recursive pinning + * in bpf_object__pin_programs easier + */ + char *pin_name; + + /* instructions that belong to BPF program; insns[0] is located at + * sec_insn_off instruction within its ELF section in ELF file, so + * when mapping ELF file instruction index to the local instruction, + * one needs to subtract sec_insn_off; and vice versa. + */ + struct bpf_insn *insns; + /* actual number of instruction in this BPF program's image; for + * entry-point BPF programs this includes the size of main program + * itself plus all the used sub-programs, appended at the end + */ + size_t insns_cnt; + + struct reloc_desc *reloc_desc; + int nr_reloc; + int log_level; + + struct { + int nr; + int *fds; + } instances; + bpf_program_prep_t preprocessor; + + struct bpf_object *obj; + void *priv; + bpf_program_clear_priv_t clear_priv; + + bool load; + enum bpf_prog_type type; + enum bpf_attach_type expected_attach_type; + int prog_ifindex; + __u32 attach_btf_obj_fd; + __u32 attach_btf_id; + __u32 attach_prog_fd; + void *func_info; + __u32 func_info_rec_size; + __u32 func_info_cnt; + + void *line_info; + __u32 line_info_rec_size; + __u32 line_info_cnt; + __u32 prog_flags; +}; + +struct bpf_struct_ops { + const char *tname; + const struct btf_type *type; + struct bpf_program **progs; + __u32 *kern_func_off; + /* e.g. struct tcp_congestion_ops in bpf_prog's btf format */ + void *data; + /* e.g. struct bpf_struct_ops_tcp_congestion_ops in + * btf_vmlinux's format. + * struct bpf_struct_ops_tcp_congestion_ops { + * [... some other kernel fields ...] + * struct tcp_congestion_ops data; + * } + * kern_vdata-size == sizeof(struct bpf_struct_ops_tcp_congestion_ops) + * bpf_map__init_kern_struct_ops() will populate the "kern_vdata" + * from "data". + */ + void *kern_vdata; + __u32 type_id; +}; + +#define DATA_SEC ".data" +#define BSS_SEC ".bss" +#define RODATA_SEC ".rodata" +#define KCONFIG_SEC ".kconfig" +#define KSYMS_SEC ".ksyms" +#define STRUCT_OPS_SEC ".struct_ops" + +enum libbpf_map_type { + LIBBPF_MAP_UNSPEC, + LIBBPF_MAP_DATA, + LIBBPF_MAP_BSS, + LIBBPF_MAP_RODATA, + LIBBPF_MAP_KCONFIG, +}; + +static const char * const libbpf_type_to_btf_name[] = { + [LIBBPF_MAP_DATA] = DATA_SEC, + [LIBBPF_MAP_BSS] = BSS_SEC, + [LIBBPF_MAP_RODATA] = RODATA_SEC, + [LIBBPF_MAP_KCONFIG] = KCONFIG_SEC, +}; + +struct bpf_map { + char *name; + int fd; + int sec_idx; + size_t sec_offset; + int map_ifindex; + int inner_map_fd; + struct bpf_map_def def; + __u32 numa_node; + __u32 btf_var_idx; + __u32 btf_key_type_id; + __u32 btf_value_type_id; + __u32 btf_vmlinux_value_type_id; + void *priv; + bpf_map_clear_priv_t clear_priv; + enum libbpf_map_type libbpf_type; + void *mmaped; + struct bpf_struct_ops *st_ops; + struct bpf_map *inner_map; + void **init_slots; + int init_slots_sz; + char *pin_path; + bool pinned; + bool reused; +}; + +enum extern_type { + EXT_UNKNOWN, + EXT_KCFG, + EXT_KSYM, +}; + +enum kcfg_type { + KCFG_UNKNOWN, + KCFG_CHAR, + KCFG_BOOL, + KCFG_INT, + KCFG_TRISTATE, + KCFG_CHAR_ARR, +}; + +struct extern_desc { + enum extern_type type; + int sym_idx; + int btf_id; + int sec_btf_id; + const char *name; + bool is_set; + bool is_weak; + union { + struct { + enum kcfg_type type; + int sz; + int align; + int data_off; + bool is_signed; + } kcfg; + struct { + unsigned long long addr; + + /* target btf_id of the corresponding kernel var. */ + int kernel_btf_obj_fd; + int kernel_btf_id; + + /* local btf_id of the ksym extern's type. */ + __u32 type_id; + } ksym; + }; +}; + +static LIST_HEAD(bpf_objects_list); + +struct module_btf { + struct btf *btf; + char *name; + __u32 id; + int fd; +}; + +struct bpf_object { + char name[BPF_OBJ_NAME_LEN]; + char license[64]; + __u32 kern_version; + + struct bpf_program *programs; + size_t nr_programs; + struct bpf_map *maps; + size_t nr_maps; + size_t maps_cap; + + char *kconfig; + struct extern_desc *externs; + int nr_extern; + int kconfig_map_idx; + int rodata_map_idx; + + bool loaded; + bool has_subcalls; + + /* + * Information when doing elf related work. Only valid if fd + * is valid. + */ + struct { + int fd; + const void *obj_buf; + size_t obj_buf_sz; + Elf *elf; + GElf_Ehdr ehdr; + Elf_Data *symbols; + Elf_Data *data; + Elf_Data *rodata; + Elf_Data *bss; + Elf_Data *st_ops_data; + size_t shstrndx; /* section index for section name strings */ + size_t strtabidx; + struct { + GElf_Shdr shdr; + Elf_Data *data; + } *reloc_sects; + int nr_reloc_sects; + int maps_shndx; + int btf_maps_shndx; + __u32 btf_maps_sec_btf_id; + int text_shndx; + int symbols_shndx; + int data_shndx; + int rodata_shndx; + int bss_shndx; + int st_ops_shndx; + } efile; + /* + * All loaded bpf_object is linked in a list, which is + * hidden to caller. bpf_objects__ handlers deal with + * all objects. + */ + struct list_head list; + + struct btf *btf; + struct btf_ext *btf_ext; + + /* Parse and load BTF vmlinux if any of the programs in the object need + * it at load time. + */ + struct btf *btf_vmlinux; + /* vmlinux BTF override for CO-RE relocations */ + struct btf *btf_vmlinux_override; + /* Lazily initialized kernel module BTFs */ + struct module_btf *btf_modules; + bool btf_modules_loaded; + size_t btf_module_cnt; + size_t btf_module_cap; + + void *priv; + bpf_object_clear_priv_t clear_priv; + + char path[]; +}; +#define obj_elf_valid(o) ((o)->efile.elf) + +static const char *elf_sym_str(const struct bpf_object *obj, size_t off); +static const char *elf_sec_str(const struct bpf_object *obj, size_t off); +static Elf_Scn *elf_sec_by_idx(const struct bpf_object *obj, size_t idx); +static Elf_Scn *elf_sec_by_name(const struct bpf_object *obj, const char *name); +static int elf_sec_hdr(const struct bpf_object *obj, Elf_Scn *scn, GElf_Shdr *hdr); +static const char *elf_sec_name(const struct bpf_object *obj, Elf_Scn *scn); +static Elf_Data *elf_sec_data(const struct bpf_object *obj, Elf_Scn *scn); +static int elf_sym_by_sec_off(const struct bpf_object *obj, size_t sec_idx, + size_t off, __u32 sym_type, GElf_Sym *sym); + +void bpf_program__unload(struct bpf_program *prog) +{ + int i; + + if (!prog) + return; + + /* + * If the object is opened but the program was never loaded, + * it is possible that prog->instances.nr == -1. + */ + if (prog->instances.nr > 0) { + for (i = 0; i < prog->instances.nr; i++) + zclose(prog->instances.fds[i]); + } else if (prog->instances.nr != -1) { + pr_warn("Internal error: instances.nr is %d\n", + prog->instances.nr); + } + + prog->instances.nr = -1; + zfree(&prog->instances.fds); + + zfree(&prog->func_info); + zfree(&prog->line_info); +} + +static void bpf_program__exit(struct bpf_program *prog) +{ + if (!prog) + return; + + if (prog->clear_priv) + prog->clear_priv(prog, prog->priv); + + prog->priv = NULL; + prog->clear_priv = NULL; + + bpf_program__unload(prog); + zfree(&prog->name); + zfree(&prog->sec_name); + zfree(&prog->pin_name); + zfree(&prog->insns); + zfree(&prog->reloc_desc); + + prog->nr_reloc = 0; + prog->insns_cnt = 0; + prog->sec_idx = -1; +} + +static char *__bpf_program__pin_name(struct bpf_program *prog) +{ + char *name, *p; + + name = p = strdup(prog->sec_name); + while ((p = strchr(p, '/'))) + *p = '_'; + + return name; +} + +static bool insn_is_subprog_call(const struct bpf_insn *insn) +{ + return BPF_CLASS(insn->code) == BPF_JMP && + BPF_OP(insn->code) == BPF_CALL && + BPF_SRC(insn->code) == BPF_K && + insn->src_reg == BPF_PSEUDO_CALL && + insn->dst_reg == 0 && + insn->off == 0; +} + +static bool is_ldimm64(struct bpf_insn *insn) +{ + return insn->code == (BPF_LD | BPF_IMM | BPF_DW); +} + +static bool insn_is_pseudo_func(struct bpf_insn *insn) +{ + return is_ldimm64(insn) && insn->src_reg == BPF_PSEUDO_FUNC; +} + +static int +bpf_object__init_prog(struct bpf_object *obj, struct bpf_program *prog, + const char *name, size_t sec_idx, const char *sec_name, + size_t sec_off, void *insn_data, size_t insn_data_sz) +{ + if (insn_data_sz == 0 || insn_data_sz % BPF_INSN_SZ || sec_off % BPF_INSN_SZ) { + pr_warn("sec '%s': corrupted program '%s', offset %zu, size %zu\n", + sec_name, name, sec_off, insn_data_sz); + return -EINVAL; + } + + memset(prog, 0, sizeof(*prog)); + prog->obj = obj; + + prog->sec_idx = sec_idx; + prog->sec_insn_off = sec_off / BPF_INSN_SZ; + prog->sec_insn_cnt = insn_data_sz / BPF_INSN_SZ; + /* insns_cnt can later be increased by appending used subprograms */ + prog->insns_cnt = prog->sec_insn_cnt; + + prog->type = BPF_PROG_TYPE_UNSPEC; + prog->load = true; + + prog->instances.fds = NULL; + prog->instances.nr = -1; + + prog->sec_name = strdup(sec_name); + if (!prog->sec_name) + goto errout; + + prog->name = strdup(name); + if (!prog->name) + goto errout; + + prog->pin_name = __bpf_program__pin_name(prog); + if (!prog->pin_name) + goto errout; + + prog->insns = malloc(insn_data_sz); + if (!prog->insns) + goto errout; + memcpy(prog->insns, insn_data, insn_data_sz); + + return 0; +errout: + pr_warn("sec '%s': failed to allocate memory for prog '%s'\n", sec_name, name); + bpf_program__exit(prog); + return -ENOMEM; +} + +static int +bpf_object__add_programs(struct bpf_object *obj, Elf_Data *sec_data, + const char *sec_name, int sec_idx) +{ + struct bpf_program *prog, *progs; + void *data = sec_data->d_buf; + size_t sec_sz = sec_data->d_size, sec_off, prog_sz; + int nr_progs, err; + const char *name; + GElf_Sym sym; + + progs = obj->programs; + nr_progs = obj->nr_programs; + sec_off = 0; + + while (sec_off < sec_sz) { + if (elf_sym_by_sec_off(obj, sec_idx, sec_off, STT_FUNC, &sym)) { + pr_warn("sec '%s': failed to find program symbol at offset %zu\n", + sec_name, sec_off); + return -LIBBPF_ERRNO__FORMAT; + } + + prog_sz = sym.st_size; + + name = elf_sym_str(obj, sym.st_name); + if (!name) { + pr_warn("sec '%s': failed to get symbol name for offset %zu\n", + sec_name, sec_off); + return -LIBBPF_ERRNO__FORMAT; + } + + if (sec_off + prog_sz > sec_sz) { + pr_warn("sec '%s': program at offset %zu crosses section boundary\n", + sec_name, sec_off); + return -LIBBPF_ERRNO__FORMAT; + } + + pr_debug("sec '%s': found program '%s' at insn offset %zu (%zu bytes), code size %zu insns (%zu bytes)\n", + sec_name, name, sec_off / BPF_INSN_SZ, sec_off, prog_sz / BPF_INSN_SZ, prog_sz); + + progs = libbpf_reallocarray(progs, nr_progs + 1, sizeof(*progs)); + if (!progs) { + /* + * In this case the original obj->programs + * is still valid, so don't need special treat for + * bpf_close_object(). + */ + pr_warn("sec '%s': failed to alloc memory for new program '%s'\n", + sec_name, name); + return -ENOMEM; + } + obj->programs = progs; + + prog = &progs[nr_progs]; + + err = bpf_object__init_prog(obj, prog, name, sec_idx, sec_name, + sec_off, data + sec_off, prog_sz); + if (err) + return err; + + nr_progs++; + obj->nr_programs = nr_progs; + + sec_off += prog_sz; + } + + return 0; +} + +static __u32 get_kernel_version(void) +{ + __u32 major, minor, patch; + struct utsname info; + + uname(&info); + if (sscanf(info.release, "%u.%u.%u", &major, &minor, &patch) != 3) + return 0; + return KERNEL_VERSION(major, minor, patch); +} + +static const struct btf_member * +find_member_by_offset(const struct btf_type *t, __u32 bit_offset) +{ + struct btf_member *m; + int i; + + for (i = 0, m = btf_members(t); i < btf_vlen(t); i++, m++) { + if (btf_member_bit_offset(t, i) == bit_offset) + return m; + } + + return NULL; +} + +static const struct btf_member * +find_member_by_name(const struct btf *btf, const struct btf_type *t, + const char *name) +{ + struct btf_member *m; + int i; + + for (i = 0, m = btf_members(t); i < btf_vlen(t); i++, m++) { + if (!strcmp(btf__name_by_offset(btf, m->name_off), name)) + return m; + } + + return NULL; +} + +#define STRUCT_OPS_VALUE_PREFIX "bpf_struct_ops_" +static int find_btf_by_prefix_kind(const struct btf *btf, const char *prefix, + const char *name, __u32 kind); + +static int +find_struct_ops_kern_types(const struct btf *btf, const char *tname, + const struct btf_type **type, __u32 *type_id, + const struct btf_type **vtype, __u32 *vtype_id, + const struct btf_member **data_member) +{ + const struct btf_type *kern_type, *kern_vtype; + const struct btf_member *kern_data_member; + __s32 kern_vtype_id, kern_type_id; + __u32 i; + + kern_type_id = btf__find_by_name_kind(btf, tname, BTF_KIND_STRUCT); + if (kern_type_id < 0) { + pr_warn("struct_ops init_kern: struct %s is not found in kernel BTF\n", + tname); + return kern_type_id; + } + kern_type = btf__type_by_id(btf, kern_type_id); + + /* Find the corresponding "map_value" type that will be used + * in map_update(BPF_MAP_TYPE_STRUCT_OPS). For example, + * find "struct bpf_struct_ops_tcp_congestion_ops" from the + * btf_vmlinux. + */ + kern_vtype_id = find_btf_by_prefix_kind(btf, STRUCT_OPS_VALUE_PREFIX, + tname, BTF_KIND_STRUCT); + if (kern_vtype_id < 0) { + pr_warn("struct_ops init_kern: struct %s%s is not found in kernel BTF\n", + STRUCT_OPS_VALUE_PREFIX, tname); + return kern_vtype_id; + } + kern_vtype = btf__type_by_id(btf, kern_vtype_id); + + /* Find "struct tcp_congestion_ops" from + * struct bpf_struct_ops_tcp_congestion_ops { + * [ ... ] + * struct tcp_congestion_ops data; + * } + */ + kern_data_member = btf_members(kern_vtype); + for (i = 0; i < btf_vlen(kern_vtype); i++, kern_data_member++) { + if (kern_data_member->type == kern_type_id) + break; + } + if (i == btf_vlen(kern_vtype)) { + pr_warn("struct_ops init_kern: struct %s data is not found in struct %s%s\n", + tname, STRUCT_OPS_VALUE_PREFIX, tname); + return -EINVAL; + } + + *type = kern_type; + *type_id = kern_type_id; + *vtype = kern_vtype; + *vtype_id = kern_vtype_id; + *data_member = kern_data_member; + + return 0; +} + +static bool bpf_map__is_struct_ops(const struct bpf_map *map) +{ + return map->def.type == BPF_MAP_TYPE_STRUCT_OPS; +} + +/* Init the map's fields that depend on kern_btf */ +static int bpf_map__init_kern_struct_ops(struct bpf_map *map, + const struct btf *btf, + const struct btf *kern_btf) +{ + const struct btf_member *member, *kern_member, *kern_data_member; + const struct btf_type *type, *kern_type, *kern_vtype; + __u32 i, kern_type_id, kern_vtype_id, kern_data_off; + struct bpf_struct_ops *st_ops; + void *data, *kern_data; + const char *tname; + int err; + + st_ops = map->st_ops; + type = st_ops->type; + tname = st_ops->tname; + err = find_struct_ops_kern_types(kern_btf, tname, + &kern_type, &kern_type_id, + &kern_vtype, &kern_vtype_id, + &kern_data_member); + if (err) + return err; + + pr_debug("struct_ops init_kern %s: type_id:%u kern_type_id:%u kern_vtype_id:%u\n", + map->name, st_ops->type_id, kern_type_id, kern_vtype_id); + + map->def.value_size = kern_vtype->size; + map->btf_vmlinux_value_type_id = kern_vtype_id; + + st_ops->kern_vdata = calloc(1, kern_vtype->size); + if (!st_ops->kern_vdata) + return -ENOMEM; + + data = st_ops->data; + kern_data_off = kern_data_member->offset / 8; + kern_data = st_ops->kern_vdata + kern_data_off; + + member = btf_members(type); + for (i = 0; i < btf_vlen(type); i++, member++) { + const struct btf_type *mtype, *kern_mtype; + __u32 mtype_id, kern_mtype_id; + void *mdata, *kern_mdata; + __s64 msize, kern_msize; + __u32 moff, kern_moff; + __u32 kern_member_idx; + const char *mname; + + mname = btf__name_by_offset(btf, member->name_off); + kern_member = find_member_by_name(kern_btf, kern_type, mname); + if (!kern_member) { + pr_warn("struct_ops init_kern %s: Cannot find member %s in kernel BTF\n", + map->name, mname); + return -ENOTSUP; + } + + kern_member_idx = kern_member - btf_members(kern_type); + if (btf_member_bitfield_size(type, i) || + btf_member_bitfield_size(kern_type, kern_member_idx)) { + pr_warn("struct_ops init_kern %s: bitfield %s is not supported\n", + map->name, mname); + return -ENOTSUP; + } + + moff = member->offset / 8; + kern_moff = kern_member->offset / 8; + + mdata = data + moff; + kern_mdata = kern_data + kern_moff; + + mtype = skip_mods_and_typedefs(btf, member->type, &mtype_id); + kern_mtype = skip_mods_and_typedefs(kern_btf, kern_member->type, + &kern_mtype_id); + if (BTF_INFO_KIND(mtype->info) != + BTF_INFO_KIND(kern_mtype->info)) { + pr_warn("struct_ops init_kern %s: Unmatched member type %s %u != %u(kernel)\n", + map->name, mname, BTF_INFO_KIND(mtype->info), + BTF_INFO_KIND(kern_mtype->info)); + return -ENOTSUP; + } + + if (btf_is_ptr(mtype)) { + struct bpf_program *prog; + + prog = st_ops->progs[i]; + if (!prog) + continue; + + kern_mtype = skip_mods_and_typedefs(kern_btf, + kern_mtype->type, + &kern_mtype_id); + + /* mtype->type must be a func_proto which was + * guaranteed in bpf_object__collect_st_ops_relos(), + * so only check kern_mtype for func_proto here. + */ + if (!btf_is_func_proto(kern_mtype)) { + pr_warn("struct_ops init_kern %s: kernel member %s is not a func ptr\n", + map->name, mname); + return -ENOTSUP; + } + + prog->attach_btf_id = kern_type_id; + prog->expected_attach_type = kern_member_idx; + + st_ops->kern_func_off[i] = kern_data_off + kern_moff; + + pr_debug("struct_ops init_kern %s: func ptr %s is set to prog %s from data(+%u) to kern_data(+%u)\n", + map->name, mname, prog->name, moff, + kern_moff); + + continue; + } + + msize = btf__resolve_size(btf, mtype_id); + kern_msize = btf__resolve_size(kern_btf, kern_mtype_id); + if (msize < 0 || kern_msize < 0 || msize != kern_msize) { + pr_warn("struct_ops init_kern %s: Error in size of member %s: %zd != %zd(kernel)\n", + map->name, mname, (ssize_t)msize, + (ssize_t)kern_msize); + return -ENOTSUP; + } + + pr_debug("struct_ops init_kern %s: copy %s %u bytes from data(+%u) to kern_data(+%u)\n", + map->name, mname, (unsigned int)msize, + moff, kern_moff); + memcpy(kern_mdata, mdata, msize); + } + + return 0; +} + +static int bpf_object__init_kern_struct_ops_maps(struct bpf_object *obj) +{ + struct bpf_map *map; + size_t i; + int err; + + for (i = 0; i < obj->nr_maps; i++) { + map = &obj->maps[i]; + + if (!bpf_map__is_struct_ops(map)) + continue; + + err = bpf_map__init_kern_struct_ops(map, obj->btf, + obj->btf_vmlinux); + if (err) + return err; + } + + return 0; +} + +static int bpf_object__init_struct_ops_maps(struct bpf_object *obj) +{ + const struct btf_type *type, *datasec; + const struct btf_var_secinfo *vsi; + struct bpf_struct_ops *st_ops; + const char *tname, *var_name; + __s32 type_id, datasec_id; + const struct btf *btf; + struct bpf_map *map; + __u32 i; + + if (obj->efile.st_ops_shndx == -1) + return 0; + + btf = obj->btf; + datasec_id = btf__find_by_name_kind(btf, STRUCT_OPS_SEC, + BTF_KIND_DATASEC); + if (datasec_id < 0) { + pr_warn("struct_ops init: DATASEC %s not found\n", + STRUCT_OPS_SEC); + return -EINVAL; + } + + datasec = btf__type_by_id(btf, datasec_id); + vsi = btf_var_secinfos(datasec); + for (i = 0; i < btf_vlen(datasec); i++, vsi++) { + type = btf__type_by_id(obj->btf, vsi->type); + var_name = btf__name_by_offset(obj->btf, type->name_off); + + type_id = btf__resolve_type(obj->btf, vsi->type); + if (type_id < 0) { + pr_warn("struct_ops init: Cannot resolve var type_id %u in DATASEC %s\n", + vsi->type, STRUCT_OPS_SEC); + return -EINVAL; + } + + type = btf__type_by_id(obj->btf, type_id); + tname = btf__name_by_offset(obj->btf, type->name_off); + if (!tname[0]) { + pr_warn("struct_ops init: anonymous type is not supported\n"); + return -ENOTSUP; + } + if (!btf_is_struct(type)) { + pr_warn("struct_ops init: %s is not a struct\n", tname); + return -EINVAL; + } + + map = bpf_object__add_map(obj); + if (IS_ERR(map)) + return PTR_ERR(map); + + map->sec_idx = obj->efile.st_ops_shndx; + map->sec_offset = vsi->offset; + map->name = strdup(var_name); + if (!map->name) + return -ENOMEM; + + map->def.type = BPF_MAP_TYPE_STRUCT_OPS; + map->def.key_size = sizeof(int); + map->def.value_size = type->size; + map->def.max_entries = 1; + + map->st_ops = calloc(1, sizeof(*map->st_ops)); + if (!map->st_ops) + return -ENOMEM; + st_ops = map->st_ops; + st_ops->data = malloc(type->size); + st_ops->progs = calloc(btf_vlen(type), sizeof(*st_ops->progs)); + st_ops->kern_func_off = malloc(btf_vlen(type) * + sizeof(*st_ops->kern_func_off)); + if (!st_ops->data || !st_ops->progs || !st_ops->kern_func_off) + return -ENOMEM; + + if (vsi->offset + type->size > obj->efile.st_ops_data->d_size) { + pr_warn("struct_ops init: var %s is beyond the end of DATASEC %s\n", + var_name, STRUCT_OPS_SEC); + return -EINVAL; + } + + memcpy(st_ops->data, + obj->efile.st_ops_data->d_buf + vsi->offset, + type->size); + st_ops->tname = tname; + st_ops->type = type; + st_ops->type_id = type_id; + + pr_debug("struct_ops init: struct %s(type_id=%u) %s found at offset %u\n", + tname, type_id, var_name, vsi->offset); + } + + return 0; +} + +static struct bpf_object *bpf_object__new(const char *path, + const void *obj_buf, + size_t obj_buf_sz, + const char *obj_name) +{ + struct bpf_object *obj; + char *end; + + obj = calloc(1, sizeof(struct bpf_object) + strlen(path) + 1); + if (!obj) { + pr_warn("alloc memory failed for %s\n", path); + return ERR_PTR(-ENOMEM); + } + + strcpy(obj->path, path); + if (obj_name) { + strncpy(obj->name, obj_name, sizeof(obj->name) - 1); + obj->name[sizeof(obj->name) - 1] = 0; + } else { + /* Using basename() GNU version which doesn't modify arg. */ + strncpy(obj->name, basename((void *)path), + sizeof(obj->name) - 1); + end = strchr(obj->name, '.'); + if (end) + *end = 0; + } + + obj->efile.fd = -1; + /* + * Caller of this function should also call + * bpf_object__elf_finish() after data collection to return + * obj_buf to user. If not, we should duplicate the buffer to + * avoid user freeing them before elf finish. + */ + obj->efile.obj_buf = obj_buf; + obj->efile.obj_buf_sz = obj_buf_sz; + obj->efile.maps_shndx = -1; + obj->efile.btf_maps_shndx = -1; + obj->efile.data_shndx = -1; + obj->efile.rodata_shndx = -1; + obj->efile.bss_shndx = -1; + obj->efile.st_ops_shndx = -1; + obj->kconfig_map_idx = -1; + obj->rodata_map_idx = -1; + + obj->kern_version = get_kernel_version(); + obj->loaded = false; + + INIT_LIST_HEAD(&obj->list); + list_add(&obj->list, &bpf_objects_list); + return obj; +} + +static void bpf_object__elf_finish(struct bpf_object *obj) +{ + if (!obj_elf_valid(obj)) + return; + + if (obj->efile.elf) { + elf_end(obj->efile.elf); + obj->efile.elf = NULL; + } + obj->efile.symbols = NULL; + obj->efile.data = NULL; + obj->efile.rodata = NULL; + obj->efile.bss = NULL; + obj->efile.st_ops_data = NULL; + + zfree(&obj->efile.reloc_sects); + obj->efile.nr_reloc_sects = 0; + zclose(obj->efile.fd); + obj->efile.obj_buf = NULL; + obj->efile.obj_buf_sz = 0; +} + +/* if libelf is old and doesn't support mmap(), fall back to read() */ +#ifndef ELF_C_READ_MMAP +#define ELF_C_READ_MMAP ELF_C_READ +#endif + +static int bpf_object__elf_init(struct bpf_object *obj) +{ + int err = 0; + GElf_Ehdr *ep; + + if (obj_elf_valid(obj)) { + pr_warn("elf: init internal error\n"); + return -LIBBPF_ERRNO__LIBELF; + } + + if (obj->efile.obj_buf_sz > 0) { + /* + * obj_buf should have been validated by + * bpf_object__open_buffer(). + */ + obj->efile.elf = elf_memory((char *)obj->efile.obj_buf, + obj->efile.obj_buf_sz); + } else { + obj->efile.fd = open(obj->path, O_RDONLY); + if (obj->efile.fd < 0) { + char errmsg[STRERR_BUFSIZE], *cp; + + err = -errno; + cp = libbpf_strerror_r(err, errmsg, sizeof(errmsg)); + pr_warn("elf: failed to open %s: %s\n", obj->path, cp); + return err; + } + + obj->efile.elf = elf_begin(obj->efile.fd, ELF_C_READ_MMAP, NULL); + } + + if (!obj->efile.elf) { + pr_warn("elf: failed to open %s as ELF file: %s\n", obj->path, elf_errmsg(-1)); + err = -LIBBPF_ERRNO__LIBELF; + goto errout; + } + + if (!gelf_getehdr(obj->efile.elf, &obj->efile.ehdr)) { + pr_warn("elf: failed to get ELF header from %s: %s\n", obj->path, elf_errmsg(-1)); + err = -LIBBPF_ERRNO__FORMAT; + goto errout; + } + ep = &obj->efile.ehdr; + + if (elf_getshdrstrndx(obj->efile.elf, &obj->efile.shstrndx)) { + pr_warn("elf: failed to get section names section index for %s: %s\n", + obj->path, elf_errmsg(-1)); + err = -LIBBPF_ERRNO__FORMAT; + goto errout; + } + + /* Elf is corrupted/truncated, avoid calling elf_strptr. */ + if (!elf_rawdata(elf_getscn(obj->efile.elf, obj->efile.shstrndx), NULL)) { + pr_warn("elf: failed to get section names strings from %s: %s\n", + obj->path, elf_errmsg(-1)); + return -LIBBPF_ERRNO__FORMAT; + } + + /* Old LLVM set e_machine to EM_NONE */ + if (ep->e_type != ET_REL || + (ep->e_machine && ep->e_machine != EM_BPF)) { + pr_warn("elf: %s is not a valid eBPF object file\n", obj->path); + err = -LIBBPF_ERRNO__FORMAT; + goto errout; + } + + return 0; +errout: + bpf_object__elf_finish(obj); + return err; +} + +static int bpf_object__check_endianness(struct bpf_object *obj) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + if (obj->efile.ehdr.e_ident[EI_DATA] == ELFDATA2LSB) + return 0; +#elif __BYTE_ORDER == __BIG_ENDIAN + if (obj->efile.ehdr.e_ident[EI_DATA] == ELFDATA2MSB) + return 0; +#else +# error "Unrecognized __BYTE_ORDER__" +#endif + pr_warn("elf: endianness mismatch in %s.\n", obj->path); + return -LIBBPF_ERRNO__ENDIAN; +} + +static int +bpf_object__init_license(struct bpf_object *obj, void *data, size_t size) +{ + memcpy(obj->license, data, min(size, sizeof(obj->license) - 1)); + pr_debug("license of %s is %s\n", obj->path, obj->license); + return 0; +} + +static int +bpf_object__init_kversion(struct bpf_object *obj, void *data, size_t size) +{ + __u32 kver; + + if (size != sizeof(kver)) { + pr_warn("invalid kver section in %s\n", obj->path); + return -LIBBPF_ERRNO__FORMAT; + } + memcpy(&kver, data, sizeof(kver)); + obj->kern_version = kver; + pr_debug("kernel version of %s is %x\n", obj->path, obj->kern_version); + return 0; +} + +static bool bpf_map_type__is_map_in_map(enum bpf_map_type type) +{ + if (type == BPF_MAP_TYPE_ARRAY_OF_MAPS || + type == BPF_MAP_TYPE_HASH_OF_MAPS) + return true; + return false; +} + +int bpf_object__section_size(const struct bpf_object *obj, const char *name, + __u32 *size) +{ + int ret = -ENOENT; + + *size = 0; + if (!name) { + return -EINVAL; + } else if (!strcmp(name, DATA_SEC)) { + if (obj->efile.data) + *size = obj->efile.data->d_size; + } else if (!strcmp(name, BSS_SEC)) { + if (obj->efile.bss) + *size = obj->efile.bss->d_size; + } else if (!strcmp(name, RODATA_SEC)) { + if (obj->efile.rodata) + *size = obj->efile.rodata->d_size; + } else if (!strcmp(name, STRUCT_OPS_SEC)) { + if (obj->efile.st_ops_data) + *size = obj->efile.st_ops_data->d_size; + } else { + Elf_Scn *scn = elf_sec_by_name(obj, name); + Elf_Data *data = elf_sec_data(obj, scn); + + if (data) { + ret = 0; /* found it */ + *size = data->d_size; + } + } + + return *size ? 0 : ret; +} + +int bpf_object__variable_offset(const struct bpf_object *obj, const char *name, + __u32 *off) +{ + Elf_Data *symbols = obj->efile.symbols; + const char *sname; + size_t si; + + if (!name || !off) + return -EINVAL; + + for (si = 0; si < symbols->d_size / sizeof(GElf_Sym); si++) { + GElf_Sym sym; + + if (!gelf_getsym(symbols, si, &sym)) + continue; + if (GELF_ST_BIND(sym.st_info) != STB_GLOBAL || + GELF_ST_TYPE(sym.st_info) != STT_OBJECT) + continue; + + sname = elf_sym_str(obj, sym.st_name); + if (!sname) { + pr_warn("failed to get sym name string for var %s\n", + name); + return -EIO; + } + if (strcmp(name, sname) == 0) { + *off = sym.st_value; + return 0; + } + } + + return -ENOENT; +} + +static struct bpf_map *bpf_object__add_map(struct bpf_object *obj) +{ + struct bpf_map *new_maps; + size_t new_cap; + int i; + + if (obj->nr_maps < obj->maps_cap) + return &obj->maps[obj->nr_maps++]; + + new_cap = max((size_t)4, obj->maps_cap * 3 / 2); + new_maps = libbpf_reallocarray(obj->maps, new_cap, sizeof(*obj->maps)); + if (!new_maps) { + pr_warn("alloc maps for object failed\n"); + return ERR_PTR(-ENOMEM); + } + + obj->maps_cap = new_cap; + obj->maps = new_maps; + + /* zero out new maps */ + memset(obj->maps + obj->nr_maps, 0, + (obj->maps_cap - obj->nr_maps) * sizeof(*obj->maps)); + /* + * fill all fd with -1 so won't close incorrect fd (fd=0 is stdin) + * when failure (zclose won't close negative fd)). + */ + for (i = obj->nr_maps; i < obj->maps_cap; i++) { + obj->maps[i].fd = -1; + obj->maps[i].inner_map_fd = -1; + } + + return &obj->maps[obj->nr_maps++]; +} + +static size_t bpf_map_mmap_sz(const struct bpf_map *map) +{ + long page_sz = sysconf(_SC_PAGE_SIZE); + size_t map_sz; + + map_sz = (size_t)roundup(map->def.value_size, 8) * map->def.max_entries; + map_sz = roundup(map_sz, page_sz); + return map_sz; +} + +static char *internal_map_name(struct bpf_object *obj, + enum libbpf_map_type type) +{ + char map_name[BPF_OBJ_NAME_LEN], *p; + const char *sfx = libbpf_type_to_btf_name[type]; + int sfx_len = max((size_t)7, strlen(sfx)); + int pfx_len = min((size_t)BPF_OBJ_NAME_LEN - sfx_len - 1, + strlen(obj->name)); + + snprintf(map_name, sizeof(map_name), "%.*s%.*s", pfx_len, obj->name, + sfx_len, libbpf_type_to_btf_name[type]); + + /* sanitise map name to characters allowed by kernel */ + for (p = map_name; *p && p < map_name + sizeof(map_name); p++) + if (!isalnum(*p) && *p != '_' && *p != '.') + *p = '_'; + + return strdup(map_name); +} + +static int +bpf_object__init_internal_map(struct bpf_object *obj, enum libbpf_map_type type, + int sec_idx, void *data, size_t data_sz) +{ + struct bpf_map_def *def; + struct bpf_map *map; + int err; + + map = bpf_object__add_map(obj); + if (IS_ERR(map)) + return PTR_ERR(map); + + map->libbpf_type = type; + map->sec_idx = sec_idx; + map->sec_offset = 0; + map->name = internal_map_name(obj, type); + if (!map->name) { + pr_warn("failed to alloc map name\n"); + return -ENOMEM; + } + + def = &map->def; + def->type = BPF_MAP_TYPE_ARRAY; + def->key_size = sizeof(int); + def->value_size = data_sz; + def->max_entries = 1; + def->map_flags = type == LIBBPF_MAP_RODATA || type == LIBBPF_MAP_KCONFIG + ? BPF_F_RDONLY_PROG : 0; + def->map_flags |= BPF_F_MMAPABLE; + + pr_debug("map '%s' (global data): at sec_idx %d, offset %zu, flags %x.\n", + map->name, map->sec_idx, map->sec_offset, def->map_flags); + + map->mmaped = mmap(NULL, bpf_map_mmap_sz(map), PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_ANONYMOUS, -1, 0); + if (map->mmaped == MAP_FAILED) { + err = -errno; + map->mmaped = NULL; + pr_warn("failed to alloc map '%s' content buffer: %d\n", + map->name, err); + zfree(&map->name); + return err; + } + + if (data) + memcpy(map->mmaped, data, data_sz); + + pr_debug("map %td is \"%s\"\n", map - obj->maps, map->name); + return 0; +} + +static int bpf_object__init_global_data_maps(struct bpf_object *obj) +{ + int err; + + /* + * Populate obj->maps with libbpf internal maps. + */ + if (obj->efile.data_shndx >= 0) { + err = bpf_object__init_internal_map(obj, LIBBPF_MAP_DATA, + obj->efile.data_shndx, + obj->efile.data->d_buf, + obj->efile.data->d_size); + if (err) + return err; + } + if (obj->efile.rodata_shndx >= 0) { + err = bpf_object__init_internal_map(obj, LIBBPF_MAP_RODATA, + obj->efile.rodata_shndx, + obj->efile.rodata->d_buf, + obj->efile.rodata->d_size); + if (err) + return err; + + obj->rodata_map_idx = obj->nr_maps - 1; + } + if (obj->efile.bss_shndx >= 0) { + err = bpf_object__init_internal_map(obj, LIBBPF_MAP_BSS, + obj->efile.bss_shndx, + NULL, + obj->efile.bss->d_size); + if (err) + return err; + } + return 0; +} + + +static struct extern_desc *find_extern_by_name(const struct bpf_object *obj, + const void *name) +{ + int i; + + for (i = 0; i < obj->nr_extern; i++) { + if (strcmp(obj->externs[i].name, name) == 0) + return &obj->externs[i]; + } + return NULL; +} + +static int set_kcfg_value_tri(struct extern_desc *ext, void *ext_val, + char value) +{ + switch (ext->kcfg.type) { + case KCFG_BOOL: + if (value == 'm') { + pr_warn("extern (kcfg) %s=%c should be tristate or char\n", + ext->name, value); + return -EINVAL; + } + *(bool *)ext_val = value == 'y' ? true : false; + break; + case KCFG_TRISTATE: + if (value == 'y') + *(enum libbpf_tristate *)ext_val = TRI_YES; + else if (value == 'm') + *(enum libbpf_tristate *)ext_val = TRI_MODULE; + else /* value == 'n' */ + *(enum libbpf_tristate *)ext_val = TRI_NO; + break; + case KCFG_CHAR: + *(char *)ext_val = value; + break; + case KCFG_UNKNOWN: + case KCFG_INT: + case KCFG_CHAR_ARR: + default: + pr_warn("extern (kcfg) %s=%c should be bool, tristate, or char\n", + ext->name, value); + return -EINVAL; + } + ext->is_set = true; + return 0; +} + +static int set_kcfg_value_str(struct extern_desc *ext, char *ext_val, + const char *value) +{ + size_t len; + + if (ext->kcfg.type != KCFG_CHAR_ARR) { + pr_warn("extern (kcfg) %s=%s should be char array\n", ext->name, value); + return -EINVAL; + } + + len = strlen(value); + if (value[len - 1] != '"') { + pr_warn("extern (kcfg) '%s': invalid string config '%s'\n", + ext->name, value); + return -EINVAL; + } + + /* strip quotes */ + len -= 2; + if (len >= ext->kcfg.sz) { + pr_warn("extern (kcfg) '%s': long string config %s of (%zu bytes) truncated to %d bytes\n", + ext->name, value, len, ext->kcfg.sz - 1); + len = ext->kcfg.sz - 1; + } + memcpy(ext_val, value + 1, len); + ext_val[len] = '\0'; + ext->is_set = true; + return 0; +} + +static int parse_u64(const char *value, __u64 *res) +{ + char *value_end; + int err; + + errno = 0; + *res = strtoull(value, &value_end, 0); + if (errno) { + err = -errno; + pr_warn("failed to parse '%s' as integer: %d\n", value, err); + return err; + } + if (*value_end) { + pr_warn("failed to parse '%s' as integer completely\n", value); + return -EINVAL; + } + return 0; +} + +static bool is_kcfg_value_in_range(const struct extern_desc *ext, __u64 v) +{ + int bit_sz = ext->kcfg.sz * 8; + + if (ext->kcfg.sz == 8) + return true; + + /* Validate that value stored in u64 fits in integer of `ext->sz` + * bytes size without any loss of information. If the target integer + * is signed, we rely on the following limits of integer type of + * Y bits and subsequent transformation: + * + * -2^(Y-1) <= X <= 2^(Y-1) - 1 + * 0 <= X + 2^(Y-1) <= 2^Y - 1 + * 0 <= X + 2^(Y-1) < 2^Y + * + * For unsigned target integer, check that all the (64 - Y) bits are + * zero. + */ + if (ext->kcfg.is_signed) + return v + (1ULL << (bit_sz - 1)) < (1ULL << bit_sz); + else + return (v >> bit_sz) == 0; +} + +static int set_kcfg_value_num(struct extern_desc *ext, void *ext_val, + __u64 value) +{ + if (ext->kcfg.type != KCFG_INT && ext->kcfg.type != KCFG_CHAR) { + pr_warn("extern (kcfg) %s=%llu should be integer\n", + ext->name, (unsigned long long)value); + return -EINVAL; + } + if (!is_kcfg_value_in_range(ext, value)) { + pr_warn("extern (kcfg) %s=%llu value doesn't fit in %d bytes\n", + ext->name, (unsigned long long)value, ext->kcfg.sz); + return -ERANGE; + } + switch (ext->kcfg.sz) { + case 1: *(__u8 *)ext_val = value; break; + case 2: *(__u16 *)ext_val = value; break; + case 4: *(__u32 *)ext_val = value; break; + case 8: *(__u64 *)ext_val = value; break; + default: + return -EINVAL; + } + ext->is_set = true; + return 0; +} + +static int bpf_object__process_kconfig_line(struct bpf_object *obj, + char *buf, void *data) +{ + struct extern_desc *ext; + char *sep, *value; + int len, err = 0; + void *ext_val; + __u64 num; + + if (strncmp(buf, "CONFIG_", 7)) + return 0; + + sep = strchr(buf, '='); + if (!sep) { + pr_warn("failed to parse '%s': no separator\n", buf); + return -EINVAL; + } + + /* Trim ending '\n' */ + len = strlen(buf); + if (buf[len - 1] == '\n') + buf[len - 1] = '\0'; + /* Split on '=' and ensure that a value is present. */ + *sep = '\0'; + if (!sep[1]) { + *sep = '='; + pr_warn("failed to parse '%s': no value\n", buf); + return -EINVAL; + } + + ext = find_extern_by_name(obj, buf); + if (!ext || ext->is_set) + return 0; + + ext_val = data + ext->kcfg.data_off; + value = sep + 1; + + switch (*value) { + case 'y': case 'n': case 'm': + err = set_kcfg_value_tri(ext, ext_val, *value); + break; + case '"': + err = set_kcfg_value_str(ext, ext_val, value); + break; + default: + /* assume integer */ + err = parse_u64(value, &num); + if (err) { + pr_warn("extern (kcfg) %s=%s should be integer\n", + ext->name, value); + return err; + } + err = set_kcfg_value_num(ext, ext_val, num); + break; + } + if (err) + return err; + pr_debug("extern (kcfg) %s=%s\n", ext->name, value); + return 0; +} + +static int bpf_object__read_kconfig_file(struct bpf_object *obj, void *data) +{ + char buf[PATH_MAX]; + struct utsname uts; + int len, err = 0; + gzFile file; + + uname(&uts); + len = snprintf(buf, PATH_MAX, "/boot/config-%s", uts.release); + if (len < 0) + return -EINVAL; + else if (len >= PATH_MAX) + return -ENAMETOOLONG; + + /* gzopen also accepts uncompressed files. */ + file = gzopen(buf, "r"); + if (!file) + file = gzopen("/proc/config.gz", "r"); + + if (!file) { + pr_warn("failed to open system Kconfig\n"); + return -ENOENT; + } + + while (gzgets(file, buf, sizeof(buf))) { + err = bpf_object__process_kconfig_line(obj, buf, data); + if (err) { + pr_warn("error parsing system Kconfig line '%s': %d\n", + buf, err); + goto out; + } + } + +out: + gzclose(file); + return err; +} + +static int bpf_object__read_kconfig_mem(struct bpf_object *obj, + const char *config, void *data) +{ + char buf[PATH_MAX]; + int err = 0; + FILE *file; + + file = fmemopen((void *)config, strlen(config), "r"); + if (!file) { + err = -errno; + pr_warn("failed to open in-memory Kconfig: %d\n", err); + return err; + } + + while (fgets(buf, sizeof(buf), file)) { + err = bpf_object__process_kconfig_line(obj, buf, data); + if (err) { + pr_warn("error parsing in-memory Kconfig line '%s': %d\n", + buf, err); + break; + } + } + + fclose(file); + return err; +} + +static int bpf_object__init_kconfig_map(struct bpf_object *obj) +{ + struct extern_desc *last_ext = NULL, *ext; + size_t map_sz; + int i, err; + + for (i = 0; i < obj->nr_extern; i++) { + ext = &obj->externs[i]; + if (ext->type == EXT_KCFG) + last_ext = ext; + } + + if (!last_ext) + return 0; + + map_sz = last_ext->kcfg.data_off + last_ext->kcfg.sz; + err = bpf_object__init_internal_map(obj, LIBBPF_MAP_KCONFIG, + obj->efile.symbols_shndx, + NULL, map_sz); + if (err) + return err; + + obj->kconfig_map_idx = obj->nr_maps - 1; + + return 0; +} + +static int bpf_object__init_user_maps(struct bpf_object *obj, bool strict) +{ + Elf_Data *symbols = obj->efile.symbols; + int i, map_def_sz = 0, nr_maps = 0, nr_syms; + Elf_Data *data = NULL; + Elf_Scn *scn; + + if (obj->efile.maps_shndx < 0) + return 0; + + if (!symbols) + return -EINVAL; + + + scn = elf_sec_by_idx(obj, obj->efile.maps_shndx); + data = elf_sec_data(obj, scn); + if (!scn || !data) { + pr_warn("elf: failed to get legacy map definitions for %s\n", + obj->path); + return -EINVAL; + } + + /* + * Count number of maps. Each map has a name. + * Array of maps is not supported: only the first element is + * considered. + * + * TODO: Detect array of map and report error. + */ + nr_syms = symbols->d_size / sizeof(GElf_Sym); + for (i = 0; i < nr_syms; i++) { + GElf_Sym sym; + + if (!gelf_getsym(symbols, i, &sym)) + continue; + if (sym.st_shndx != obj->efile.maps_shndx) + continue; + nr_maps++; + } + /* Assume equally sized map definitions */ + pr_debug("elf: found %d legacy map definitions (%zd bytes) in %s\n", + nr_maps, data->d_size, obj->path); + + if (!data->d_size || nr_maps == 0 || (data->d_size % nr_maps) != 0) { + pr_warn("elf: unable to determine legacy map definition size in %s\n", + obj->path); + return -EINVAL; + } + map_def_sz = data->d_size / nr_maps; + + /* Fill obj->maps using data in "maps" section. */ + for (i = 0; i < nr_syms; i++) { + GElf_Sym sym; + const char *map_name; + struct bpf_map_def *def; + struct bpf_map *map; + + if (!gelf_getsym(symbols, i, &sym)) + continue; + if (sym.st_shndx != obj->efile.maps_shndx) + continue; + + map = bpf_object__add_map(obj); + if (IS_ERR(map)) + return PTR_ERR(map); + + map_name = elf_sym_str(obj, sym.st_name); + if (!map_name) { + pr_warn("failed to get map #%d name sym string for obj %s\n", + i, obj->path); + return -LIBBPF_ERRNO__FORMAT; + } + + map->libbpf_type = LIBBPF_MAP_UNSPEC; + map->sec_idx = sym.st_shndx; + map->sec_offset = sym.st_value; + pr_debug("map '%s' (legacy): at sec_idx %d, offset %zu.\n", + map_name, map->sec_idx, map->sec_offset); + if (sym.st_value + map_def_sz > data->d_size) { + pr_warn("corrupted maps section in %s: last map \"%s\" too small\n", + obj->path, map_name); + return -EINVAL; + } + + map->name = strdup(map_name); + if (!map->name) { + pr_warn("failed to alloc map name\n"); + return -ENOMEM; + } + pr_debug("map %d is \"%s\"\n", i, map->name); + def = (struct bpf_map_def *)(data->d_buf + sym.st_value); + /* + * If the definition of the map in the object file fits in + * bpf_map_def, copy it. Any extra fields in our version + * of bpf_map_def will default to zero as a result of the + * calloc above. + */ + if (map_def_sz <= sizeof(struct bpf_map_def)) { + memcpy(&map->def, def, map_def_sz); + } else { + /* + * Here the map structure being read is bigger than what + * we expect, truncate if the excess bits are all zero. + * If they are not zero, reject this map as + * incompatible. + */ + char *b; + + for (b = ((char *)def) + sizeof(struct bpf_map_def); + b < ((char *)def) + map_def_sz; b++) { + if (*b != 0) { + pr_warn("maps section in %s: \"%s\" has unrecognized, non-zero options\n", + obj->path, map_name); + if (strict) + return -EINVAL; + } + } + memcpy(&map->def, def, sizeof(struct bpf_map_def)); + } + } + return 0; +} + +static const struct btf_type * +skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id) +{ + const struct btf_type *t = btf__type_by_id(btf, id); + + if (res_id) + *res_id = id; + + while (btf_is_mod(t) || btf_is_typedef(t)) { + if (res_id) + *res_id = t->type; + t = btf__type_by_id(btf, t->type); + } + + return t; +} + +static const struct btf_type * +resolve_func_ptr(const struct btf *btf, __u32 id, __u32 *res_id) +{ + const struct btf_type *t; + + t = skip_mods_and_typedefs(btf, id, NULL); + if (!btf_is_ptr(t)) + return NULL; + + t = skip_mods_and_typedefs(btf, t->type, res_id); + + return btf_is_func_proto(t) ? t : NULL; +} + +static const char *btf_kind_str(const struct btf_type *t) +{ + switch (btf_kind(t)) { + case BTF_KIND_UNKN: return "void"; + case BTF_KIND_INT: return "int"; + case BTF_KIND_PTR: return "ptr"; + case BTF_KIND_ARRAY: return "array"; + case BTF_KIND_STRUCT: return "struct"; + case BTF_KIND_UNION: return "union"; + case BTF_KIND_ENUM: return "enum"; + case BTF_KIND_FWD: return "fwd"; + case BTF_KIND_TYPEDEF: return "typedef"; + case BTF_KIND_VOLATILE: return "volatile"; + case BTF_KIND_CONST: return "const"; + case BTF_KIND_RESTRICT: return "restrict"; + case BTF_KIND_FUNC: return "func"; + case BTF_KIND_FUNC_PROTO: return "func_proto"; + case BTF_KIND_VAR: return "var"; + case BTF_KIND_DATASEC: return "datasec"; + case BTF_KIND_FLOAT: return "float"; + default: return "unknown"; + } +} + +/* + * Fetch integer attribute of BTF map definition. Such attributes are + * represented using a pointer to an array, in which dimensionality of array + * encodes specified integer value. E.g., int (*type)[BPF_MAP_TYPE_ARRAY]; + * encodes `type => BPF_MAP_TYPE_ARRAY` key/value pair completely using BTF + * type definition, while using only sizeof(void *) space in ELF data section. + */ +static bool get_map_field_int(const char *map_name, const struct btf *btf, + const struct btf_member *m, __u32 *res) +{ + const struct btf_type *t = skip_mods_and_typedefs(btf, m->type, NULL); + const char *name = btf__name_by_offset(btf, m->name_off); + const struct btf_array *arr_info; + const struct btf_type *arr_t; + + if (!btf_is_ptr(t)) { + pr_warn("map '%s': attr '%s': expected PTR, got %s.\n", + map_name, name, btf_kind_str(t)); + return false; + } + + arr_t = btf__type_by_id(btf, t->type); + if (!arr_t) { + pr_warn("map '%s': attr '%s': type [%u] not found.\n", + map_name, name, t->type); + return false; + } + if (!btf_is_array(arr_t)) { + pr_warn("map '%s': attr '%s': expected ARRAY, got %s.\n", + map_name, name, btf_kind_str(arr_t)); + return false; + } + arr_info = btf_array(arr_t); + *res = arr_info->nelems; + return true; +} + +static int build_map_pin_path(struct bpf_map *map, const char *path) +{ + char buf[PATH_MAX]; + int len; + + if (!path) + path = "/sys/fs/bpf"; + + len = snprintf(buf, PATH_MAX, "%s/%s", path, bpf_map__name(map)); + if (len < 0) + return -EINVAL; + else if (len >= PATH_MAX) + return -ENAMETOOLONG; + + return bpf_map__set_pin_path(map, buf); +} + + +static int parse_btf_map_def(struct bpf_object *obj, + struct bpf_map *map, + const struct btf_type *def, + bool strict, bool is_inner, + const char *pin_root_path) +{ + const struct btf_type *t; + const struct btf_member *m; + int vlen, i; + + vlen = btf_vlen(def); + m = btf_members(def); + for (i = 0; i < vlen; i++, m++) { + const char *name = btf__name_by_offset(obj->btf, m->name_off); + + if (!name) { + pr_warn("map '%s': invalid field #%d.\n", map->name, i); + return -EINVAL; + } + if (strcmp(name, "type") == 0) { + if (!get_map_field_int(map->name, obj->btf, m, + &map->def.type)) + return -EINVAL; + pr_debug("map '%s': found type = %u.\n", + map->name, map->def.type); + } else if (strcmp(name, "max_entries") == 0) { + if (!get_map_field_int(map->name, obj->btf, m, + &map->def.max_entries)) + return -EINVAL; + pr_debug("map '%s': found max_entries = %u.\n", + map->name, map->def.max_entries); + } else if (strcmp(name, "map_flags") == 0) { + if (!get_map_field_int(map->name, obj->btf, m, + &map->def.map_flags)) + return -EINVAL; + pr_debug("map '%s': found map_flags = %u.\n", + map->name, map->def.map_flags); + } else if (strcmp(name, "numa_node") == 0) { + if (!get_map_field_int(map->name, obj->btf, m, &map->numa_node)) + return -EINVAL; + pr_debug("map '%s': found numa_node = %u.\n", map->name, map->numa_node); + } else if (strcmp(name, "key_size") == 0) { + __u32 sz; + + if (!get_map_field_int(map->name, obj->btf, m, &sz)) + return -EINVAL; + pr_debug("map '%s': found key_size = %u.\n", + map->name, sz); + if (map->def.key_size && map->def.key_size != sz) { + pr_warn("map '%s': conflicting key size %u != %u.\n", + map->name, map->def.key_size, sz); + return -EINVAL; + } + map->def.key_size = sz; + } else if (strcmp(name, "key") == 0) { + __s64 sz; + + t = btf__type_by_id(obj->btf, m->type); + if (!t) { + pr_warn("map '%s': key type [%d] not found.\n", + map->name, m->type); + return -EINVAL; + } + if (!btf_is_ptr(t)) { + pr_warn("map '%s': key spec is not PTR: %s.\n", + map->name, btf_kind_str(t)); + return -EINVAL; + } + sz = btf__resolve_size(obj->btf, t->type); + if (sz < 0) { + pr_warn("map '%s': can't determine key size for type [%u]: %zd.\n", + map->name, t->type, (ssize_t)sz); + return sz; + } + pr_debug("map '%s': found key [%u], sz = %zd.\n", + map->name, t->type, (ssize_t)sz); + if (map->def.key_size && map->def.key_size != sz) { + pr_warn("map '%s': conflicting key size %u != %zd.\n", + map->name, map->def.key_size, (ssize_t)sz); + return -EINVAL; + } + map->def.key_size = sz; + map->btf_key_type_id = t->type; + } else if (strcmp(name, "value_size") == 0) { + __u32 sz; + + if (!get_map_field_int(map->name, obj->btf, m, &sz)) + return -EINVAL; + pr_debug("map '%s': found value_size = %u.\n", + map->name, sz); + if (map->def.value_size && map->def.value_size != sz) { + pr_warn("map '%s': conflicting value size %u != %u.\n", + map->name, map->def.value_size, sz); + return -EINVAL; + } + map->def.value_size = sz; + } else if (strcmp(name, "value") == 0) { + __s64 sz; + + t = btf__type_by_id(obj->btf, m->type); + if (!t) { + pr_warn("map '%s': value type [%d] not found.\n", + map->name, m->type); + return -EINVAL; + } + if (!btf_is_ptr(t)) { + pr_warn("map '%s': value spec is not PTR: %s.\n", + map->name, btf_kind_str(t)); + return -EINVAL; + } + sz = btf__resolve_size(obj->btf, t->type); + if (sz < 0) { + pr_warn("map '%s': can't determine value size for type [%u]: %zd.\n", + map->name, t->type, (ssize_t)sz); + return sz; + } + pr_debug("map '%s': found value [%u], sz = %zd.\n", + map->name, t->type, (ssize_t)sz); + if (map->def.value_size && map->def.value_size != sz) { + pr_warn("map '%s': conflicting value size %u != %zd.\n", + map->name, map->def.value_size, (ssize_t)sz); + return -EINVAL; + } + map->def.value_size = sz; + map->btf_value_type_id = t->type; + } + else if (strcmp(name, "values") == 0) { + int err; + + if (is_inner) { + pr_warn("map '%s': multi-level inner maps not supported.\n", + map->name); + return -ENOTSUP; + } + if (i != vlen - 1) { + pr_warn("map '%s': '%s' member should be last.\n", + map->name, name); + return -EINVAL; + } + if (!bpf_map_type__is_map_in_map(map->def.type)) { + pr_warn("map '%s': should be map-in-map.\n", + map->name); + return -ENOTSUP; + } + if (map->def.value_size && map->def.value_size != 4) { + pr_warn("map '%s': conflicting value size %u != 4.\n", + map->name, map->def.value_size); + return -EINVAL; + } + map->def.value_size = 4; + t = btf__type_by_id(obj->btf, m->type); + if (!t) { + pr_warn("map '%s': map-in-map inner type [%d] not found.\n", + map->name, m->type); + return -EINVAL; + } + if (!btf_is_array(t) || btf_array(t)->nelems) { + pr_warn("map '%s': map-in-map inner spec is not a zero-sized array.\n", + map->name); + return -EINVAL; + } + t = skip_mods_and_typedefs(obj->btf, btf_array(t)->type, + NULL); + if (!btf_is_ptr(t)) { + pr_warn("map '%s': map-in-map inner def is of unexpected kind %s.\n", + map->name, btf_kind_str(t)); + return -EINVAL; + } + t = skip_mods_and_typedefs(obj->btf, t->type, NULL); + if (!btf_is_struct(t)) { + pr_warn("map '%s': map-in-map inner def is of unexpected kind %s.\n", + map->name, btf_kind_str(t)); + return -EINVAL; + } + + map->inner_map = calloc(1, sizeof(*map->inner_map)); + if (!map->inner_map) + return -ENOMEM; + map->inner_map->sec_idx = obj->efile.btf_maps_shndx; + map->inner_map->name = malloc(strlen(map->name) + + sizeof(".inner") + 1); + if (!map->inner_map->name) + return -ENOMEM; + sprintf(map->inner_map->name, "%s.inner", map->name); + + err = parse_btf_map_def(obj, map->inner_map, t, strict, + true /* is_inner */, NULL); + if (err) + return err; + } else if (strcmp(name, "pinning") == 0) { + __u32 val; + int err; + + if (is_inner) { + pr_debug("map '%s': inner def can't be pinned.\n", + map->name); + return -EINVAL; + } + if (!get_map_field_int(map->name, obj->btf, m, &val)) + return -EINVAL; + pr_debug("map '%s': found pinning = %u.\n", + map->name, val); + + if (val != LIBBPF_PIN_NONE && + val != LIBBPF_PIN_BY_NAME) { + pr_warn("map '%s': invalid pinning value %u.\n", + map->name, val); + return -EINVAL; + } + if (val == LIBBPF_PIN_BY_NAME) { + err = build_map_pin_path(map, pin_root_path); + if (err) { + pr_warn("map '%s': couldn't build pin path.\n", + map->name); + return err; + } + } + } else { + if (strict) { + pr_warn("map '%s': unknown field '%s'.\n", + map->name, name); + return -ENOTSUP; + } + pr_debug("map '%s': ignoring unknown field '%s'.\n", + map->name, name); + } + } + + if (map->def.type == BPF_MAP_TYPE_UNSPEC) { + pr_warn("map '%s': map type isn't specified.\n", map->name); + return -EINVAL; + } + + return 0; +} + +static int bpf_object__init_user_btf_map(struct bpf_object *obj, + const struct btf_type *sec, + int var_idx, int sec_idx, + const Elf_Data *data, bool strict, + const char *pin_root_path) +{ + const struct btf_type *var, *def; + const struct btf_var_secinfo *vi; + const struct btf_var *var_extra; + const char *map_name; + struct bpf_map *map; + + vi = btf_var_secinfos(sec) + var_idx; + var = btf__type_by_id(obj->btf, vi->type); + var_extra = btf_var(var); + map_name = btf__name_by_offset(obj->btf, var->name_off); + + if (map_name == NULL || map_name[0] == '\0') { + pr_warn("map #%d: empty name.\n", var_idx); + return -EINVAL; + } + if ((__u64)vi->offset + vi->size > data->d_size) { + pr_warn("map '%s' BTF data is corrupted.\n", map_name); + return -EINVAL; + } + if (!btf_is_var(var)) { + pr_warn("map '%s': unexpected var kind %s.\n", + map_name, btf_kind_str(var)); + return -EINVAL; + } + if (var_extra->linkage != BTF_VAR_GLOBAL_ALLOCATED && + var_extra->linkage != BTF_VAR_STATIC) { + pr_warn("map '%s': unsupported var linkage %u.\n", + map_name, var_extra->linkage); + return -EOPNOTSUPP; + } + + def = skip_mods_and_typedefs(obj->btf, var->type, NULL); + if (!btf_is_struct(def)) { + pr_warn("map '%s': unexpected def kind %s.\n", + map_name, btf_kind_str(var)); + return -EINVAL; + } + if (def->size > vi->size) { + pr_warn("map '%s': invalid def size.\n", map_name); + return -EINVAL; + } + + map = bpf_object__add_map(obj); + if (IS_ERR(map)) + return PTR_ERR(map); + map->name = strdup(map_name); + if (!map->name) { + pr_warn("map '%s': failed to alloc map name.\n", map_name); + return -ENOMEM; + } + map->libbpf_type = LIBBPF_MAP_UNSPEC; + map->def.type = BPF_MAP_TYPE_UNSPEC; + map->sec_idx = sec_idx; + map->sec_offset = vi->offset; + map->btf_var_idx = var_idx; + pr_debug("map '%s': at sec_idx %d, offset %zu.\n", + map_name, map->sec_idx, map->sec_offset); + + return parse_btf_map_def(obj, map, def, strict, false, pin_root_path); +} + +static int bpf_object__init_user_btf_maps(struct bpf_object *obj, bool strict, + const char *pin_root_path) +{ + const struct btf_type *sec = NULL; + int nr_types, i, vlen, err; + const struct btf_type *t; + const char *name; + Elf_Data *data; + Elf_Scn *scn; + + if (obj->efile.btf_maps_shndx < 0) + return 0; + + scn = elf_sec_by_idx(obj, obj->efile.btf_maps_shndx); + data = elf_sec_data(obj, scn); + if (!scn || !data) { + pr_warn("elf: failed to get %s map definitions for %s\n", + MAPS_ELF_SEC, obj->path); + return -EINVAL; + } + + nr_types = btf__get_nr_types(obj->btf); + for (i = 1; i <= nr_types; i++) { + t = btf__type_by_id(obj->btf, i); + if (!btf_is_datasec(t)) + continue; + name = btf__name_by_offset(obj->btf, t->name_off); + if (strcmp(name, MAPS_ELF_SEC) == 0) { + sec = t; + obj->efile.btf_maps_sec_btf_id = i; + break; + } + } + + if (!sec) { + pr_warn("DATASEC '%s' not found.\n", MAPS_ELF_SEC); + return -ENOENT; + } + + vlen = btf_vlen(sec); + for (i = 0; i < vlen; i++) { + err = bpf_object__init_user_btf_map(obj, sec, i, + obj->efile.btf_maps_shndx, + data, strict, + pin_root_path); + if (err) + return err; + } + + return 0; +} + +static int bpf_object__init_maps(struct bpf_object *obj, + const struct bpf_object_open_opts *opts) +{ + const char *pin_root_path; + bool strict; + int err; + + strict = !OPTS_GET(opts, relaxed_maps, false); + pin_root_path = OPTS_GET(opts, pin_root_path, NULL); + + err = bpf_object__init_user_maps(obj, strict); + err = err ?: bpf_object__init_user_btf_maps(obj, strict, pin_root_path); + err = err ?: bpf_object__init_global_data_maps(obj); + err = err ?: bpf_object__init_kconfig_map(obj); + err = err ?: bpf_object__init_struct_ops_maps(obj); + if (err) + return err; + + return 0; +} + +static bool section_have_execinstr(struct bpf_object *obj, int idx) +{ + GElf_Shdr sh; + + if (elf_sec_hdr(obj, elf_sec_by_idx(obj, idx), &sh)) + return false; + + return sh.sh_flags & SHF_EXECINSTR; +} + +static bool btf_needs_sanitization(struct bpf_object *obj) +{ + bool has_func_global = kernel_supports(FEAT_BTF_GLOBAL_FUNC); + bool has_datasec = kernel_supports(FEAT_BTF_DATASEC); + bool has_float = kernel_supports(FEAT_BTF_FLOAT); + bool has_func = kernel_supports(FEAT_BTF_FUNC); + + return !has_func || !has_datasec || !has_func_global || !has_float; +} + +static void bpf_object__sanitize_btf(struct bpf_object *obj, struct btf *btf) +{ + bool has_func_global = kernel_supports(FEAT_BTF_GLOBAL_FUNC); + bool has_datasec = kernel_supports(FEAT_BTF_DATASEC); + bool has_float = kernel_supports(FEAT_BTF_FLOAT); + bool has_func = kernel_supports(FEAT_BTF_FUNC); + struct btf_type *t; + int i, j, vlen; + + for (i = 1; i <= btf__get_nr_types(btf); i++) { + t = (struct btf_type *)btf__type_by_id(btf, i); + + if (!has_datasec && btf_is_var(t)) { + /* replace VAR with INT */ + t->info = BTF_INFO_ENC(BTF_KIND_INT, 0, 0); + /* + * using size = 1 is the safest choice, 4 will be too + * big and cause kernel BTF validation failure if + * original variable took less than 4 bytes + */ + t->size = 1; + *(int *)(t + 1) = BTF_INT_ENC(0, 0, 8); + } else if (!has_datasec && btf_is_datasec(t)) { + /* replace DATASEC with STRUCT */ + const struct btf_var_secinfo *v = btf_var_secinfos(t); + struct btf_member *m = btf_members(t); + struct btf_type *vt; + char *name; + + name = (char *)btf__name_by_offset(btf, t->name_off); + while (*name) { + if (*name == '.') + *name = '_'; + name++; + } + + vlen = btf_vlen(t); + t->info = BTF_INFO_ENC(BTF_KIND_STRUCT, 0, vlen); + for (j = 0; j < vlen; j++, v++, m++) { + /* order of field assignments is important */ + m->offset = v->offset * 8; + m->type = v->type; + /* preserve variable name as member name */ + vt = (void *)btf__type_by_id(btf, v->type); + m->name_off = vt->name_off; + } + } else if (!has_func && btf_is_func_proto(t)) { + /* replace FUNC_PROTO with ENUM */ + vlen = btf_vlen(t); + t->info = BTF_INFO_ENC(BTF_KIND_ENUM, 0, vlen); + t->size = sizeof(__u32); /* kernel enforced */ + } else if (!has_func && btf_is_func(t)) { + /* replace FUNC with TYPEDEF */ + t->info = BTF_INFO_ENC(BTF_KIND_TYPEDEF, 0, 0); + } else if (!has_func_global && btf_is_func(t)) { + /* replace BTF_FUNC_GLOBAL with BTF_FUNC_STATIC */ + t->info = BTF_INFO_ENC(BTF_KIND_FUNC, 0, 0); + } else if (!has_float && btf_is_float(t)) { + /* replace FLOAT with an equally-sized empty STRUCT; + * since C compilers do not accept e.g. "float" as a + * valid struct name, make it anonymous + */ + t->name_off = 0; + t->info = BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 0); + } + } +} + +static bool libbpf_needs_btf(const struct bpf_object *obj) +{ + return obj->efile.btf_maps_shndx >= 0 || + obj->efile.st_ops_shndx >= 0 || + obj->nr_extern > 0; +} + +static bool kernel_needs_btf(const struct bpf_object *obj) +{ + return obj->efile.st_ops_shndx >= 0; +} + +static int bpf_object__init_btf(struct bpf_object *obj, + Elf_Data *btf_data, + Elf_Data *btf_ext_data) +{ + int err = -ENOENT; + + if (btf_data) { + obj->btf = btf__new(btf_data->d_buf, btf_data->d_size); + if (IS_ERR(obj->btf)) { + err = PTR_ERR(obj->btf); + obj->btf = NULL; + pr_warn("Error loading ELF section %s: %d.\n", + BTF_ELF_SEC, err); + goto out; + } + /* enforce 8-byte pointers for BPF-targeted BTFs */ + btf__set_pointer_size(obj->btf, 8); + err = 0; + } + if (btf_ext_data) { + if (!obj->btf) { + pr_debug("Ignore ELF section %s because its depending ELF section %s is not found.\n", + BTF_EXT_ELF_SEC, BTF_ELF_SEC); + goto out; + } + obj->btf_ext = btf_ext__new(btf_ext_data->d_buf, + btf_ext_data->d_size); + if (IS_ERR(obj->btf_ext)) { + pr_warn("Error loading ELF section %s: %ld. Ignored and continue.\n", + BTF_EXT_ELF_SEC, PTR_ERR(obj->btf_ext)); + obj->btf_ext = NULL; + goto out; + } + } +out: + if (err && libbpf_needs_btf(obj)) { + pr_warn("BTF is required, but is missing or corrupted.\n"); + return err; + } + return 0; +} + +static int bpf_object__finalize_btf(struct bpf_object *obj) +{ + int err; + + if (!obj->btf) + return 0; + + err = btf__finalize_data(obj, obj->btf); + if (err) { + pr_warn("Error finalizing %s: %d.\n", BTF_ELF_SEC, err); + return err; + } + + return 0; +} + +static bool prog_needs_vmlinux_btf(struct bpf_program *prog) +{ + if (prog->type == BPF_PROG_TYPE_STRUCT_OPS || + prog->type == BPF_PROG_TYPE_LSM) + return true; + + /* BPF_PROG_TYPE_TRACING programs which do not attach to other programs + * also need vmlinux BTF + */ + if (prog->type == BPF_PROG_TYPE_TRACING && !prog->attach_prog_fd) + return true; + + return false; +} + +static bool obj_needs_vmlinux_btf(const struct bpf_object *obj) +{ + struct bpf_program *prog; + int i; + + /* CO-RE relocations need kernel BTF */ + if (obj->btf_ext && obj->btf_ext->core_relo_info.len) + return true; + + /* Support for typed ksyms needs kernel BTF */ + for (i = 0; i < obj->nr_extern; i++) { + const struct extern_desc *ext; + + ext = &obj->externs[i]; + if (ext->type == EXT_KSYM && ext->ksym.type_id) + return true; + } + + bpf_object__for_each_program(prog, obj) { + if (!prog->load) + continue; + if (prog_needs_vmlinux_btf(prog)) + return true; + } + + return false; +} + +static int bpf_object__load_vmlinux_btf(struct bpf_object *obj, bool force) +{ + int err; + + /* btf_vmlinux could be loaded earlier */ + if (obj->btf_vmlinux) + return 0; + + if (!force && !obj_needs_vmlinux_btf(obj)) + return 0; + + obj->btf_vmlinux = libbpf_find_kernel_btf(); + if (IS_ERR(obj->btf_vmlinux)) { + err = PTR_ERR(obj->btf_vmlinux); + pr_warn("Error loading vmlinux BTF: %d\n", err); + obj->btf_vmlinux = NULL; + return err; + } + return 0; +} + +static int bpf_object__sanitize_and_load_btf(struct bpf_object *obj) +{ + struct btf *kern_btf = obj->btf; + bool btf_mandatory, sanitize; + int err = 0; + + if (!obj->btf) + return 0; + + if (!kernel_supports(FEAT_BTF)) { + if (kernel_needs_btf(obj)) { + err = -EOPNOTSUPP; + goto report; + } + pr_debug("Kernel doesn't support BTF, skipping uploading it.\n"); + return 0; + } + + sanitize = btf_needs_sanitization(obj); + if (sanitize) { + const void *raw_data; + __u32 sz; + + /* clone BTF to sanitize a copy and leave the original intact */ + raw_data = btf__get_raw_data(obj->btf, &sz); + kern_btf = btf__new(raw_data, sz); + if (IS_ERR(kern_btf)) + return PTR_ERR(kern_btf); + + /* enforce 8-byte pointers for BPF-targeted BTFs */ + btf__set_pointer_size(obj->btf, 8); + bpf_object__sanitize_btf(obj, kern_btf); + } + + err = btf__load(kern_btf); + if (sanitize) { + if (!err) { + /* move fd to libbpf's BTF */ + btf__set_fd(obj->btf, btf__fd(kern_btf)); + btf__set_fd(kern_btf, -1); + } + btf__free(kern_btf); + } +report: + if (err) { + btf_mandatory = kernel_needs_btf(obj); + pr_warn("Error loading .BTF into kernel: %d. %s\n", err, + btf_mandatory ? "BTF is mandatory, can't proceed." + : "BTF is optional, ignoring."); + if (!btf_mandatory) + err = 0; + } + return err; +} + +static const char *elf_sym_str(const struct bpf_object *obj, size_t off) +{ + const char *name; + + name = elf_strptr(obj->efile.elf, obj->efile.strtabidx, off); + if (!name) { + pr_warn("elf: failed to get section name string at offset %zu from %s: %s\n", + off, obj->path, elf_errmsg(-1)); + return NULL; + } + + return name; +} + +static const char *elf_sec_str(const struct bpf_object *obj, size_t off) +{ + const char *name; + + name = elf_strptr(obj->efile.elf, obj->efile.shstrndx, off); + if (!name) { + pr_warn("elf: failed to get section name string at offset %zu from %s: %s\n", + off, obj->path, elf_errmsg(-1)); + return NULL; + } + + return name; +} + +static Elf_Scn *elf_sec_by_idx(const struct bpf_object *obj, size_t idx) +{ + Elf_Scn *scn; + + scn = elf_getscn(obj->efile.elf, idx); + if (!scn) { + pr_warn("elf: failed to get section(%zu) from %s: %s\n", + idx, obj->path, elf_errmsg(-1)); + return NULL; + } + return scn; +} + +static Elf_Scn *elf_sec_by_name(const struct bpf_object *obj, const char *name) +{ + Elf_Scn *scn = NULL; + Elf *elf = obj->efile.elf; + const char *sec_name; + + while ((scn = elf_nextscn(elf, scn)) != NULL) { + sec_name = elf_sec_name(obj, scn); + if (!sec_name) + return NULL; + + if (strcmp(sec_name, name) != 0) + continue; + + return scn; + } + return NULL; +} + +static int elf_sec_hdr(const struct bpf_object *obj, Elf_Scn *scn, GElf_Shdr *hdr) +{ + if (!scn) + return -EINVAL; + + if (gelf_getshdr(scn, hdr) != hdr) { + pr_warn("elf: failed to get section(%zu) header from %s: %s\n", + elf_ndxscn(scn), obj->path, elf_errmsg(-1)); + return -EINVAL; + } + + return 0; +} + +static const char *elf_sec_name(const struct bpf_object *obj, Elf_Scn *scn) +{ + const char *name; + GElf_Shdr sh; + + if (!scn) + return NULL; + + if (elf_sec_hdr(obj, scn, &sh)) + return NULL; + + name = elf_sec_str(obj, sh.sh_name); + if (!name) { + pr_warn("elf: failed to get section(%zu) name from %s: %s\n", + elf_ndxscn(scn), obj->path, elf_errmsg(-1)); + return NULL; + } + + return name; +} + +static Elf_Data *elf_sec_data(const struct bpf_object *obj, Elf_Scn *scn) +{ + Elf_Data *data; + + if (!scn) + return NULL; + + data = elf_getdata(scn, 0); + if (!data) { + pr_warn("elf: failed to get section(%zu) %s data from %s: %s\n", + elf_ndxscn(scn), elf_sec_name(obj, scn) ?: "", + obj->path, elf_errmsg(-1)); + return NULL; + } + + return data; +} + +static int elf_sym_by_sec_off(const struct bpf_object *obj, size_t sec_idx, + size_t off, __u32 sym_type, GElf_Sym *sym) +{ + Elf_Data *symbols = obj->efile.symbols; + size_t n = symbols->d_size / sizeof(GElf_Sym); + int i; + + for (i = 0; i < n; i++) { + if (!gelf_getsym(symbols, i, sym)) + continue; + if (sym->st_shndx != sec_idx || sym->st_value != off) + continue; + if (GELF_ST_TYPE(sym->st_info) != sym_type) + continue; + return 0; + } + + return -ENOENT; +} + +static bool is_sec_name_dwarf(const char *name) +{ + /* approximation, but the actual list is too long */ + return strncmp(name, ".debug_", sizeof(".debug_") - 1) == 0; +} + +static bool ignore_elf_section(GElf_Shdr *hdr, const char *name) +{ + /* no special handling of .strtab */ + if (hdr->sh_type == SHT_STRTAB) + return true; + + /* ignore .llvm_addrsig section as well */ + if (hdr->sh_type == 0x6FFF4C03 /* SHT_LLVM_ADDRSIG */) + return true; + + /* no subprograms will lead to an empty .text section, ignore it */ + if (hdr->sh_type == SHT_PROGBITS && hdr->sh_size == 0 && + strcmp(name, ".text") == 0) + return true; + + /* DWARF sections */ + if (is_sec_name_dwarf(name)) + return true; + + if (strncmp(name, ".rel", sizeof(".rel") - 1) == 0) { + name += sizeof(".rel") - 1; + /* DWARF section relocations */ + if (is_sec_name_dwarf(name)) + return true; + + /* .BTF and .BTF.ext don't need relocations */ + if (strcmp(name, BTF_ELF_SEC) == 0 || + strcmp(name, BTF_EXT_ELF_SEC) == 0) + return true; + } + + return false; +} + +static int cmp_progs(const void *_a, const void *_b) +{ + const struct bpf_program *a = _a; + const struct bpf_program *b = _b; + + if (a->sec_idx != b->sec_idx) + return a->sec_idx < b->sec_idx ? -1 : 1; + + /* sec_insn_off can't be the same within the section */ + return a->sec_insn_off < b->sec_insn_off ? -1 : 1; +} + +static int bpf_object__elf_collect(struct bpf_object *obj) +{ + Elf *elf = obj->efile.elf; + Elf_Data *btf_ext_data = NULL; + Elf_Data *btf_data = NULL; + int idx = 0, err = 0; + const char *name; + Elf_Data *data; + Elf_Scn *scn; + GElf_Shdr sh; + + /* a bunch of ELF parsing functionality depends on processing symbols, + * so do the first pass and find the symbol table + */ + scn = NULL; + while ((scn = elf_nextscn(elf, scn)) != NULL) { + if (elf_sec_hdr(obj, scn, &sh)) + return -LIBBPF_ERRNO__FORMAT; + + if (sh.sh_type == SHT_SYMTAB) { + if (obj->efile.symbols) { + pr_warn("elf: multiple symbol tables in %s\n", obj->path); + return -LIBBPF_ERRNO__FORMAT; + } + + data = elf_sec_data(obj, scn); + if (!data) + return -LIBBPF_ERRNO__FORMAT; + + obj->efile.symbols = data; + obj->efile.symbols_shndx = elf_ndxscn(scn); + obj->efile.strtabidx = sh.sh_link; + } + } + + scn = NULL; + while ((scn = elf_nextscn(elf, scn)) != NULL) { + idx++; + + if (elf_sec_hdr(obj, scn, &sh)) + return -LIBBPF_ERRNO__FORMAT; + + name = elf_sec_str(obj, sh.sh_name); + if (!name) + return -LIBBPF_ERRNO__FORMAT; + + if (ignore_elf_section(&sh, name)) + continue; + + data = elf_sec_data(obj, scn); + if (!data) + return -LIBBPF_ERRNO__FORMAT; + + pr_debug("elf: section(%d) %s, size %ld, link %d, flags %lx, type=%d\n", + idx, name, (unsigned long)data->d_size, + (int)sh.sh_link, (unsigned long)sh.sh_flags, + (int)sh.sh_type); + + if (strcmp(name, "license") == 0) { + err = bpf_object__init_license(obj, data->d_buf, data->d_size); + if (err) + return err; + } else if (strcmp(name, "version") == 0) { + err = bpf_object__init_kversion(obj, data->d_buf, data->d_size); + if (err) + return err; + } else if (strcmp(name, "maps") == 0) { + obj->efile.maps_shndx = idx; + } else if (strcmp(name, MAPS_ELF_SEC) == 0) { + obj->efile.btf_maps_shndx = idx; + } else if (strcmp(name, BTF_ELF_SEC) == 0) { + btf_data = data; + } else if (strcmp(name, BTF_EXT_ELF_SEC) == 0) { + btf_ext_data = data; + } else if (sh.sh_type == SHT_SYMTAB) { + /* already processed during the first pass above */ + } else if (sh.sh_type == SHT_PROGBITS && data->d_size > 0) { + if (sh.sh_flags & SHF_EXECINSTR) { + if (strcmp(name, ".text") == 0) + obj->efile.text_shndx = idx; + err = bpf_object__add_programs(obj, data, name, idx); + if (err) + return err; + } else if (strcmp(name, DATA_SEC) == 0) { + obj->efile.data = data; + obj->efile.data_shndx = idx; + } else if (strcmp(name, RODATA_SEC) == 0) { + obj->efile.rodata = data; + obj->efile.rodata_shndx = idx; + } else if (strcmp(name, STRUCT_OPS_SEC) == 0) { + obj->efile.st_ops_data = data; + obj->efile.st_ops_shndx = idx; + } else { + pr_info("elf: skipping unrecognized data section(%d) %s\n", + idx, name); + } + } else if (sh.sh_type == SHT_REL) { + int nr_sects = obj->efile.nr_reloc_sects; + void *sects = obj->efile.reloc_sects; + int sec = sh.sh_info; /* points to other section */ + + /* Only do relo for section with exec instructions */ + if (!section_have_execinstr(obj, sec) && + strcmp(name, ".rel" STRUCT_OPS_SEC) && + strcmp(name, ".rel" MAPS_ELF_SEC)) { + pr_info("elf: skipping relo section(%d) %s for section(%d) %s\n", + idx, name, sec, + elf_sec_name(obj, elf_sec_by_idx(obj, sec)) ?: ""); + continue; + } + + sects = libbpf_reallocarray(sects, nr_sects + 1, + sizeof(*obj->efile.reloc_sects)); + if (!sects) + return -ENOMEM; + + obj->efile.reloc_sects = sects; + obj->efile.nr_reloc_sects++; + + obj->efile.reloc_sects[nr_sects].shdr = sh; + obj->efile.reloc_sects[nr_sects].data = data; + } else if (sh.sh_type == SHT_NOBITS && strcmp(name, BSS_SEC) == 0) { + obj->efile.bss = data; + obj->efile.bss_shndx = idx; + } else { + pr_info("elf: skipping section(%d) %s (size %zu)\n", idx, name, + (size_t)sh.sh_size); + } + } + + if (!obj->efile.strtabidx || obj->efile.strtabidx > idx) { + pr_warn("elf: symbol strings section missing or invalid in %s\n", obj->path); + return -LIBBPF_ERRNO__FORMAT; + } + + /* sort BPF programs by section name and in-section instruction offset + * for faster search */ + qsort(obj->programs, obj->nr_programs, sizeof(*obj->programs), cmp_progs); + + return bpf_object__init_btf(obj, btf_data, btf_ext_data); +} + +static bool sym_is_extern(const GElf_Sym *sym) +{ + int bind = GELF_ST_BIND(sym->st_info); + /* externs are symbols w/ type=NOTYPE, bind=GLOBAL|WEAK, section=UND */ + return sym->st_shndx == SHN_UNDEF && + (bind == STB_GLOBAL || bind == STB_WEAK) && + GELF_ST_TYPE(sym->st_info) == STT_NOTYPE; +} + +static bool sym_is_subprog(const GElf_Sym *sym, int text_shndx) +{ + int bind = GELF_ST_BIND(sym->st_info); + int type = GELF_ST_TYPE(sym->st_info); + + /* in .text section */ + if (sym->st_shndx != text_shndx) + return false; + + /* local function */ + if (bind == STB_LOCAL && type == STT_SECTION) + return true; + + /* global function */ + return bind == STB_GLOBAL && type == STT_FUNC; +} + +static int find_extern_btf_id(const struct btf *btf, const char *ext_name) +{ + const struct btf_type *t; + const char *var_name; + int i, n; + + if (!btf) + return -ESRCH; + + n = btf__get_nr_types(btf); + for (i = 1; i <= n; i++) { + t = btf__type_by_id(btf, i); + + if (!btf_is_var(t)) + continue; + + var_name = btf__name_by_offset(btf, t->name_off); + if (strcmp(var_name, ext_name)) + continue; + + if (btf_var(t)->linkage != BTF_VAR_GLOBAL_EXTERN) + return -EINVAL; + + return i; + } + + return -ENOENT; +} + +static int find_extern_sec_btf_id(struct btf *btf, int ext_btf_id) { + const struct btf_var_secinfo *vs; + const struct btf_type *t; + int i, j, n; + + if (!btf) + return -ESRCH; + + n = btf__get_nr_types(btf); + for (i = 1; i <= n; i++) { + t = btf__type_by_id(btf, i); + + if (!btf_is_datasec(t)) + continue; + + vs = btf_var_secinfos(t); + for (j = 0; j < btf_vlen(t); j++, vs++) { + if (vs->type == ext_btf_id) + return i; + } + } + + return -ENOENT; +} + +static enum kcfg_type find_kcfg_type(const struct btf *btf, int id, + bool *is_signed) +{ + const struct btf_type *t; + const char *name; + + t = skip_mods_and_typedefs(btf, id, NULL); + name = btf__name_by_offset(btf, t->name_off); + + if (is_signed) + *is_signed = false; + switch (btf_kind(t)) { + case BTF_KIND_INT: { + int enc = btf_int_encoding(t); + + if (enc & BTF_INT_BOOL) + return t->size == 1 ? KCFG_BOOL : KCFG_UNKNOWN; + if (is_signed) + *is_signed = enc & BTF_INT_SIGNED; + if (t->size == 1) + return KCFG_CHAR; + if (t->size < 1 || t->size > 8 || (t->size & (t->size - 1))) + return KCFG_UNKNOWN; + return KCFG_INT; + } + case BTF_KIND_ENUM: + if (t->size != 4) + return KCFG_UNKNOWN; + if (strcmp(name, "libbpf_tristate")) + return KCFG_UNKNOWN; + return KCFG_TRISTATE; + case BTF_KIND_ARRAY: + if (btf_array(t)->nelems == 0) + return KCFG_UNKNOWN; + if (find_kcfg_type(btf, btf_array(t)->type, NULL) != KCFG_CHAR) + return KCFG_UNKNOWN; + return KCFG_CHAR_ARR; + default: + return KCFG_UNKNOWN; + } +} + +static int cmp_externs(const void *_a, const void *_b) +{ + const struct extern_desc *a = _a; + const struct extern_desc *b = _b; + + if (a->type != b->type) + return a->type < b->type ? -1 : 1; + + if (a->type == EXT_KCFG) { + /* descending order by alignment requirements */ + if (a->kcfg.align != b->kcfg.align) + return a->kcfg.align > b->kcfg.align ? -1 : 1; + /* ascending order by size, within same alignment class */ + if (a->kcfg.sz != b->kcfg.sz) + return a->kcfg.sz < b->kcfg.sz ? -1 : 1; + } + + /* resolve ties by name */ + return strcmp(a->name, b->name); +} + +static int find_int_btf_id(const struct btf *btf) +{ + const struct btf_type *t; + int i, n; + + n = btf__get_nr_types(btf); + for (i = 1; i <= n; i++) { + t = btf__type_by_id(btf, i); + + if (btf_is_int(t) && btf_int_bits(t) == 32) + return i; + } + + return 0; +} + +static int bpf_object__collect_externs(struct bpf_object *obj) +{ + struct btf_type *sec, *kcfg_sec = NULL, *ksym_sec = NULL; + const struct btf_type *t; + struct extern_desc *ext; + int i, n, off; + const char *ext_name, *sec_name; + Elf_Scn *scn; + GElf_Shdr sh; + + if (!obj->efile.symbols) + return 0; + + scn = elf_sec_by_idx(obj, obj->efile.symbols_shndx); + if (elf_sec_hdr(obj, scn, &sh)) + return -LIBBPF_ERRNO__FORMAT; + + n = sh.sh_size / sh.sh_entsize; + pr_debug("looking for externs among %d symbols...\n", n); + + for (i = 0; i < n; i++) { + GElf_Sym sym; + + if (!gelf_getsym(obj->efile.symbols, i, &sym)) + return -LIBBPF_ERRNO__FORMAT; + if (!sym_is_extern(&sym)) + continue; + ext_name = elf_sym_str(obj, sym.st_name); + if (!ext_name || !ext_name[0]) + continue; + + ext = obj->externs; + ext = libbpf_reallocarray(ext, obj->nr_extern + 1, sizeof(*ext)); + if (!ext) + return -ENOMEM; + obj->externs = ext; + ext = &ext[obj->nr_extern]; + memset(ext, 0, sizeof(*ext)); + obj->nr_extern++; + + ext->btf_id = find_extern_btf_id(obj->btf, ext_name); + if (ext->btf_id <= 0) { + pr_warn("failed to find BTF for extern '%s': %d\n", + ext_name, ext->btf_id); + return ext->btf_id; + } + t = btf__type_by_id(obj->btf, ext->btf_id); + ext->name = btf__name_by_offset(obj->btf, t->name_off); + ext->sym_idx = i; + ext->is_weak = GELF_ST_BIND(sym.st_info) == STB_WEAK; + + ext->sec_btf_id = find_extern_sec_btf_id(obj->btf, ext->btf_id); + if (ext->sec_btf_id <= 0) { + pr_warn("failed to find BTF for extern '%s' [%d] section: %d\n", + ext_name, ext->btf_id, ext->sec_btf_id); + return ext->sec_btf_id; + } + sec = (void *)btf__type_by_id(obj->btf, ext->sec_btf_id); + sec_name = btf__name_by_offset(obj->btf, sec->name_off); + + if (strcmp(sec_name, KCONFIG_SEC) == 0) { + kcfg_sec = sec; + ext->type = EXT_KCFG; + ext->kcfg.sz = btf__resolve_size(obj->btf, t->type); + if (ext->kcfg.sz <= 0) { + pr_warn("failed to resolve size of extern (kcfg) '%s': %d\n", + ext_name, ext->kcfg.sz); + return ext->kcfg.sz; + } + ext->kcfg.align = btf__align_of(obj->btf, t->type); + if (ext->kcfg.align <= 0) { + pr_warn("failed to determine alignment of extern (kcfg) '%s': %d\n", + ext_name, ext->kcfg.align); + return -EINVAL; + } + ext->kcfg.type = find_kcfg_type(obj->btf, t->type, + &ext->kcfg.is_signed); + if (ext->kcfg.type == KCFG_UNKNOWN) { + pr_warn("extern (kcfg) '%s' type is unsupported\n", ext_name); + return -ENOTSUP; + } + } else if (strcmp(sec_name, KSYMS_SEC) == 0) { + ksym_sec = sec; + ext->type = EXT_KSYM; + skip_mods_and_typedefs(obj->btf, t->type, + &ext->ksym.type_id); + } else { + pr_warn("unrecognized extern section '%s'\n", sec_name); + return -ENOTSUP; + } + } + pr_debug("collected %d externs total\n", obj->nr_extern); + + if (!obj->nr_extern) + return 0; + + /* sort externs by type, for kcfg ones also by (align, size, name) */ + qsort(obj->externs, obj->nr_extern, sizeof(*ext), cmp_externs); + + /* for .ksyms section, we need to turn all externs into allocated + * variables in BTF to pass kernel verification; we do this by + * pretending that each extern is a 8-byte variable + */ + if (ksym_sec) { + /* find existing 4-byte integer type in BTF to use for fake + * extern variables in DATASEC + */ + int int_btf_id = find_int_btf_id(obj->btf); + + for (i = 0; i < obj->nr_extern; i++) { + ext = &obj->externs[i]; + if (ext->type != EXT_KSYM) + continue; + pr_debug("extern (ksym) #%d: symbol %d, name %s\n", + i, ext->sym_idx, ext->name); + } + + sec = ksym_sec; + n = btf_vlen(sec); + for (i = 0, off = 0; i < n; i++, off += sizeof(int)) { + struct btf_var_secinfo *vs = btf_var_secinfos(sec) + i; + struct btf_type *vt; + + vt = (void *)btf__type_by_id(obj->btf, vs->type); + ext_name = btf__name_by_offset(obj->btf, vt->name_off); + ext = find_extern_by_name(obj, ext_name); + if (!ext) { + pr_warn("failed to find extern definition for BTF var '%s'\n", + ext_name); + return -ESRCH; + } + btf_var(vt)->linkage = BTF_VAR_GLOBAL_ALLOCATED; + vt->type = int_btf_id; + vs->offset = off; + vs->size = sizeof(int); + } + sec->size = off; + } + + if (kcfg_sec) { + sec = kcfg_sec; + /* for kcfg externs calculate their offsets within a .kconfig map */ + off = 0; + for (i = 0; i < obj->nr_extern; i++) { + ext = &obj->externs[i]; + if (ext->type != EXT_KCFG) + continue; + + ext->kcfg.data_off = roundup(off, ext->kcfg.align); + off = ext->kcfg.data_off + ext->kcfg.sz; + pr_debug("extern (kcfg) #%d: symbol %d, off %u, name %s\n", + i, ext->sym_idx, ext->kcfg.data_off, ext->name); + } + sec->size = off; + n = btf_vlen(sec); + for (i = 0; i < n; i++) { + struct btf_var_secinfo *vs = btf_var_secinfos(sec) + i; + + t = btf__type_by_id(obj->btf, vs->type); + ext_name = btf__name_by_offset(obj->btf, t->name_off); + ext = find_extern_by_name(obj, ext_name); + if (!ext) { + pr_warn("failed to find extern definition for BTF var '%s'\n", + ext_name); + return -ESRCH; + } + btf_var(t)->linkage = BTF_VAR_GLOBAL_ALLOCATED; + vs->offset = ext->kcfg.data_off; + } + } + return 0; +} + +struct bpf_program * +bpf_object__find_program_by_title(const struct bpf_object *obj, + const char *title) +{ + struct bpf_program *pos; + + bpf_object__for_each_program(pos, obj) { + if (pos->sec_name && !strcmp(pos->sec_name, title)) + return pos; + } + return NULL; +} + +static bool prog_is_subprog(const struct bpf_object *obj, + const struct bpf_program *prog) +{ + /* For legacy reasons, libbpf supports an entry-point BPF programs + * without SEC() attribute, i.e., those in the .text section. But if + * there are 2 or more such programs in the .text section, they all + * must be subprograms called from entry-point BPF programs in + * designated SEC()'tions, otherwise there is no way to distinguish + * which of those programs should be loaded vs which are a subprogram. + * Similarly, if there is a function/program in .text and at least one + * other BPF program with custom SEC() attribute, then we just assume + * .text programs are subprograms (even if they are not called from + * other programs), because libbpf never explicitly supported mixing + * SEC()-designated BPF programs and .text entry-point BPF programs. + */ + return prog->sec_idx == obj->efile.text_shndx && obj->nr_programs > 1; +} + +struct bpf_program * +bpf_object__find_program_by_name(const struct bpf_object *obj, + const char *name) +{ + struct bpf_program *prog; + + bpf_object__for_each_program(prog, obj) { + if (prog_is_subprog(obj, prog)) + continue; + if (!strcmp(prog->name, name)) + return prog; + } + return NULL; +} + +static bool bpf_object__shndx_is_data(const struct bpf_object *obj, + int shndx) +{ + return shndx == obj->efile.data_shndx || + shndx == obj->efile.bss_shndx || + shndx == obj->efile.rodata_shndx; +} + +static bool bpf_object__shndx_is_maps(const struct bpf_object *obj, + int shndx) +{ + return shndx == obj->efile.maps_shndx || + shndx == obj->efile.btf_maps_shndx; +} + +static enum libbpf_map_type +bpf_object__section_to_libbpf_map_type(const struct bpf_object *obj, int shndx) +{ + if (shndx == obj->efile.data_shndx) + return LIBBPF_MAP_DATA; + else if (shndx == obj->efile.bss_shndx) + return LIBBPF_MAP_BSS; + else if (shndx == obj->efile.rodata_shndx) + return LIBBPF_MAP_RODATA; + else if (shndx == obj->efile.symbols_shndx) + return LIBBPF_MAP_KCONFIG; + else + return LIBBPF_MAP_UNSPEC; +} + +static int bpf_program__record_reloc(struct bpf_program *prog, + struct reloc_desc *reloc_desc, + __u32 insn_idx, const char *sym_name, + const GElf_Sym *sym, const GElf_Rel *rel) +{ + struct bpf_insn *insn = &prog->insns[insn_idx]; + size_t map_idx, nr_maps = prog->obj->nr_maps; + struct bpf_object *obj = prog->obj; + __u32 shdr_idx = sym->st_shndx; + enum libbpf_map_type type; + const char *sym_sec_name; + struct bpf_map *map; + + reloc_desc->processed = false; + + /* sub-program call relocation */ + if (insn->code == (BPF_JMP | BPF_CALL)) { + if (insn->src_reg != BPF_PSEUDO_CALL) { + pr_warn("prog '%s': incorrect bpf_call opcode\n", prog->name); + return -LIBBPF_ERRNO__RELOC; + } + /* text_shndx can be 0, if no default "main" program exists */ + if (!shdr_idx || shdr_idx != obj->efile.text_shndx) { + sym_sec_name = elf_sec_name(obj, elf_sec_by_idx(obj, shdr_idx)); + pr_warn("prog '%s': bad call relo against '%s' in section '%s'\n", + prog->name, sym_name, sym_sec_name); + return -LIBBPF_ERRNO__RELOC; + } + if (sym->st_value % BPF_INSN_SZ) { + pr_warn("prog '%s': bad call relo against '%s' at offset %zu\n", + prog->name, sym_name, (size_t)sym->st_value); + return -LIBBPF_ERRNO__RELOC; + } + reloc_desc->type = RELO_CALL; + reloc_desc->insn_idx = insn_idx; + reloc_desc->sym_off = sym->st_value; + return 0; + } + + if (!is_ldimm64(insn)) { + pr_warn("prog '%s': invalid relo against '%s' for insns[%d].code 0x%x\n", + prog->name, sym_name, insn_idx, insn->code); + return -LIBBPF_ERRNO__RELOC; + } + + if (sym_is_extern(sym)) { + int sym_idx = GELF_R_SYM(rel->r_info); + int i, n = obj->nr_extern; + struct extern_desc *ext; + + for (i = 0; i < n; i++) { + ext = &obj->externs[i]; + if (ext->sym_idx == sym_idx) + break; + } + if (i >= n) { + pr_warn("prog '%s': extern relo failed to find extern for '%s' (%d)\n", + prog->name, sym_name, sym_idx); + return -LIBBPF_ERRNO__RELOC; + } + pr_debug("prog '%s': found extern #%d '%s' (sym %d) for insn #%u\n", + prog->name, i, ext->name, ext->sym_idx, insn_idx); + reloc_desc->type = RELO_EXTERN; + reloc_desc->insn_idx = insn_idx; + reloc_desc->sym_off = i; /* sym_off stores extern index */ + return 0; + } + + if (!shdr_idx || shdr_idx >= SHN_LORESERVE) { + pr_warn("prog '%s': invalid relo against '%s' in special section 0x%x; forgot to initialize global var?..\n", + prog->name, sym_name, shdr_idx); + return -LIBBPF_ERRNO__RELOC; + } + + /* loading subprog addresses */ + if (sym_is_subprog(sym, obj->efile.text_shndx)) { + /* global_func: sym->st_value = offset in the section, insn->imm = 0. + * local_func: sym->st_value = 0, insn->imm = offset in the section. + */ + if ((sym->st_value % BPF_INSN_SZ) || (insn->imm % BPF_INSN_SZ)) { + pr_warn("prog '%s': bad subprog addr relo against '%s' at offset %zu+%d\n", + prog->name, sym_name, (size_t)sym->st_value, insn->imm); + return -LIBBPF_ERRNO__RELOC; + } + + reloc_desc->type = RELO_SUBPROG_ADDR; + reloc_desc->insn_idx = insn_idx; + reloc_desc->sym_off = sym->st_value; + return 0; + } + + type = bpf_object__section_to_libbpf_map_type(obj, shdr_idx); + sym_sec_name = elf_sec_name(obj, elf_sec_by_idx(obj, shdr_idx)); + + /* generic map reference relocation */ + if (type == LIBBPF_MAP_UNSPEC) { + if (!bpf_object__shndx_is_maps(obj, shdr_idx)) { + pr_warn("prog '%s': bad map relo against '%s' in section '%s'\n", + prog->name, sym_name, sym_sec_name); + return -LIBBPF_ERRNO__RELOC; + } + for (map_idx = 0; map_idx < nr_maps; map_idx++) { + map = &obj->maps[map_idx]; + if (map->libbpf_type != type || + map->sec_idx != sym->st_shndx || + map->sec_offset != sym->st_value) + continue; + pr_debug("prog '%s': found map %zd (%s, sec %d, off %zu) for insn #%u\n", + prog->name, map_idx, map->name, map->sec_idx, + map->sec_offset, insn_idx); + break; + } + if (map_idx >= nr_maps) { + pr_warn("prog '%s': map relo failed to find map for section '%s', off %zu\n", + prog->name, sym_sec_name, (size_t)sym->st_value); + return -LIBBPF_ERRNO__RELOC; + } + reloc_desc->type = RELO_LD64; + reloc_desc->insn_idx = insn_idx; + reloc_desc->map_idx = map_idx; + reloc_desc->sym_off = 0; /* sym->st_value determines map_idx */ + return 0; + } + + /* global data map relocation */ + if (!bpf_object__shndx_is_data(obj, shdr_idx)) { + pr_warn("prog '%s': bad data relo against section '%s'\n", + prog->name, sym_sec_name); + return -LIBBPF_ERRNO__RELOC; + } + for (map_idx = 0; map_idx < nr_maps; map_idx++) { + map = &obj->maps[map_idx]; + if (map->libbpf_type != type) + continue; + pr_debug("prog '%s': found data map %zd (%s, sec %d, off %zu) for insn %u\n", + prog->name, map_idx, map->name, map->sec_idx, + map->sec_offset, insn_idx); + break; + } + if (map_idx >= nr_maps) { + pr_warn("prog '%s': data relo failed to find map for section '%s'\n", + prog->name, sym_sec_name); + return -LIBBPF_ERRNO__RELOC; + } + + reloc_desc->type = RELO_DATA; + reloc_desc->insn_idx = insn_idx; + reloc_desc->map_idx = map_idx; + reloc_desc->sym_off = sym->st_value; + return 0; +} + +static bool prog_contains_insn(const struct bpf_program *prog, size_t insn_idx) +{ + return insn_idx >= prog->sec_insn_off && + insn_idx < prog->sec_insn_off + prog->sec_insn_cnt; +} + +static struct bpf_program *find_prog_by_sec_insn(const struct bpf_object *obj, + size_t sec_idx, size_t insn_idx) +{ + int l = 0, r = obj->nr_programs - 1, m; + struct bpf_program *prog; + + while (l < r) { + m = l + (r - l + 1) / 2; + prog = &obj->programs[m]; + + if (prog->sec_idx < sec_idx || + (prog->sec_idx == sec_idx && prog->sec_insn_off <= insn_idx)) + l = m; + else + r = m - 1; + } + /* matching program could be at index l, but it still might be the + * wrong one, so we need to double check conditions for the last time + */ + prog = &obj->programs[l]; + if (prog->sec_idx == sec_idx && prog_contains_insn(prog, insn_idx)) + return prog; + return NULL; +} + +static int +bpf_object__collect_prog_relos(struct bpf_object *obj, GElf_Shdr *shdr, Elf_Data *data) +{ + Elf_Data *symbols = obj->efile.symbols; + const char *relo_sec_name, *sec_name; + size_t sec_idx = shdr->sh_info; + struct bpf_program *prog; + struct reloc_desc *relos; + int err, i, nrels; + const char *sym_name; + __u32 insn_idx; + GElf_Sym sym; + GElf_Rel rel; + + relo_sec_name = elf_sec_str(obj, shdr->sh_name); + sec_name = elf_sec_name(obj, elf_sec_by_idx(obj, sec_idx)); + if (!relo_sec_name || !sec_name) + return -EINVAL; + + pr_debug("sec '%s': collecting relocation for section(%zu) '%s'\n", + relo_sec_name, sec_idx, sec_name); + nrels = shdr->sh_size / shdr->sh_entsize; + + for (i = 0; i < nrels; i++) { + if (!gelf_getrel(data, i, &rel)) { + pr_warn("sec '%s': failed to get relo #%d\n", relo_sec_name, i); + return -LIBBPF_ERRNO__FORMAT; + } + if (!gelf_getsym(symbols, GELF_R_SYM(rel.r_info), &sym)) { + pr_warn("sec '%s': symbol 0x%zx not found for relo #%d\n", + relo_sec_name, (size_t)GELF_R_SYM(rel.r_info), i); + return -LIBBPF_ERRNO__FORMAT; + } + if (rel.r_offset % BPF_INSN_SZ) { + pr_warn("sec '%s': invalid offset 0x%zx for relo #%d\n", + relo_sec_name, (size_t)GELF_R_SYM(rel.r_info), i); + return -LIBBPF_ERRNO__FORMAT; + } + + insn_idx = rel.r_offset / BPF_INSN_SZ; + /* relocations against static functions are recorded as + * relocations against the section that contains a function; + * in such case, symbol will be STT_SECTION and sym.st_name + * will point to empty string (0), so fetch section name + * instead + */ + if (GELF_ST_TYPE(sym.st_info) == STT_SECTION && sym.st_name == 0) + sym_name = elf_sec_name(obj, elf_sec_by_idx(obj, sym.st_shndx)); + else + sym_name = elf_sym_str(obj, sym.st_name); + sym_name = sym_name ?: "reloc_desc, + prog->nr_reloc + 1, sizeof(*relos)); + if (!relos) + return -ENOMEM; + prog->reloc_desc = relos; + + /* adjust insn_idx to local BPF program frame of reference */ + insn_idx -= prog->sec_insn_off; + err = bpf_program__record_reloc(prog, &relos[prog->nr_reloc], + insn_idx, sym_name, &sym, &rel); + if (err) + return err; + + prog->nr_reloc++; + } + return 0; +} + +static int bpf_map_find_btf_info(struct bpf_object *obj, struct bpf_map *map) +{ + struct bpf_map_def *def = &map->def; + __u32 key_type_id = 0, value_type_id = 0; + int ret; + + /* if it's BTF-defined map, we don't need to search for type IDs. + * For struct_ops map, it does not need btf_key_type_id and + * btf_value_type_id. + */ + if (map->sec_idx == obj->efile.btf_maps_shndx || + bpf_map__is_struct_ops(map)) + return 0; + + if (!bpf_map__is_internal(map)) { + ret = btf__get_map_kv_tids(obj->btf, map->name, def->key_size, + def->value_size, &key_type_id, + &value_type_id); + } else { + /* + * LLVM annotates global data differently in BTF, that is, + * only as '.data', '.bss' or '.rodata'. + */ + ret = btf__find_by_name(obj->btf, + libbpf_type_to_btf_name[map->libbpf_type]); + } + if (ret < 0) + return ret; + + map->btf_key_type_id = key_type_id; + map->btf_value_type_id = bpf_map__is_internal(map) ? + ret : value_type_id; + return 0; +} + +int bpf_map__reuse_fd(struct bpf_map *map, int fd) +{ + struct bpf_map_info info = {}; + __u32 len = sizeof(info); + int new_fd, err; + char *new_name; + + err = bpf_obj_get_info_by_fd(fd, &info, &len); + if (err) + return err; + + new_name = strdup(info.name); + if (!new_name) + return -errno; + + new_fd = open("/", O_RDONLY | O_CLOEXEC); + if (new_fd < 0) { + err = -errno; + goto err_free_new_name; + } + + new_fd = dup3(fd, new_fd, O_CLOEXEC); + if (new_fd < 0) { + err = -errno; + goto err_close_new_fd; + } + + err = zclose(map->fd); + if (err) { + err = -errno; + goto err_close_new_fd; + } + free(map->name); + + map->fd = new_fd; + map->name = new_name; + map->def.type = info.type; + map->def.key_size = info.key_size; + map->def.value_size = info.value_size; + map->def.max_entries = info.max_entries; + map->def.map_flags = info.map_flags; + map->btf_key_type_id = info.btf_key_type_id; + map->btf_value_type_id = info.btf_value_type_id; + map->reused = true; + + return 0; + +err_close_new_fd: + close(new_fd); +err_free_new_name: + free(new_name); + return err; +} + +__u32 bpf_map__max_entries(const struct bpf_map *map) +{ + return map->def.max_entries; +} + +int bpf_map__set_max_entries(struct bpf_map *map, __u32 max_entries) +{ + if (map->fd >= 0) + return -EBUSY; + map->def.max_entries = max_entries; + return 0; +} + +int bpf_map__resize(struct bpf_map *map, __u32 max_entries) +{ + if (!map || !max_entries) + return -EINVAL; + + return bpf_map__set_max_entries(map, max_entries); +} + +static int +bpf_object__probe_loading(struct bpf_object *obj) +{ + struct bpf_load_program_attr attr; + char *cp, errmsg[STRERR_BUFSIZE]; + struct bpf_insn insns[] = { + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }; + int ret; + + /* make sure basic loading works */ + + memset(&attr, 0, sizeof(attr)); + attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER; + attr.insns = insns; + attr.insns_cnt = ARRAY_SIZE(insns); + attr.license = "GPL"; + + ret = bpf_load_program_xattr(&attr, NULL, 0); + if (ret < 0) { + ret = errno; + cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg)); + pr_warn("Error in %s():%s(%d). Couldn't load trivial BPF " + "program. Make sure your kernel supports BPF " + "(CONFIG_BPF_SYSCALL=y) and/or that RLIMIT_MEMLOCK is " + "set to big enough value.\n", __func__, cp, ret); + return -ret; + } + close(ret); + + return 0; +} + +static int probe_fd(int fd) +{ + if (fd >= 0) + close(fd); + return fd >= 0; +} + +static int probe_kern_prog_name(void) +{ + struct bpf_load_program_attr attr; + struct bpf_insn insns[] = { + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }; + int ret; + + /* make sure loading with name works */ + + memset(&attr, 0, sizeof(attr)); + attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER; + attr.insns = insns; + attr.insns_cnt = ARRAY_SIZE(insns); + attr.license = "GPL"; + attr.name = "test"; + ret = bpf_load_program_xattr(&attr, NULL, 0); + return probe_fd(ret); +} + +static int probe_kern_global_data(void) +{ + struct bpf_load_program_attr prg_attr; + struct bpf_create_map_attr map_attr; + char *cp, errmsg[STRERR_BUFSIZE]; + struct bpf_insn insns[] = { + BPF_LD_MAP_VALUE(BPF_REG_1, 0, 16), + BPF_ST_MEM(BPF_DW, BPF_REG_1, 0, 42), + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }; + int ret, map; + + memset(&map_attr, 0, sizeof(map_attr)); + map_attr.map_type = BPF_MAP_TYPE_ARRAY; + map_attr.key_size = sizeof(int); + map_attr.value_size = 32; + map_attr.max_entries = 1; + + map = bpf_create_map_xattr(&map_attr); + if (map < 0) { + ret = -errno; + cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg)); + pr_warn("Error in %s():%s(%d). Couldn't create simple array map.\n", + __func__, cp, -ret); + return ret; + } + + insns[0].imm = map; + + memset(&prg_attr, 0, sizeof(prg_attr)); + prg_attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER; + prg_attr.insns = insns; + prg_attr.insns_cnt = ARRAY_SIZE(insns); + prg_attr.license = "GPL"; + + ret = bpf_load_program_xattr(&prg_attr, NULL, 0); + close(map); + return probe_fd(ret); +} + +static int probe_kern_btf(void) +{ + static const char strs[] = "\0int"; + __u32 types[] = { + /* int */ + BTF_TYPE_INT_ENC(1, BTF_INT_SIGNED, 0, 32, 4), + }; + + return probe_fd(libbpf__load_raw_btf((char *)types, sizeof(types), + strs, sizeof(strs))); +} + +static int probe_kern_btf_func(void) +{ + static const char strs[] = "\0int\0x\0a"; + /* void x(int a) {} */ + __u32 types[] = { + /* int */ + BTF_TYPE_INT_ENC(1, BTF_INT_SIGNED, 0, 32, 4), /* [1] */ + /* FUNC_PROTO */ /* [2] */ + BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_FUNC_PROTO, 0, 1), 0), + BTF_PARAM_ENC(7, 1), + /* FUNC x */ /* [3] */ + BTF_TYPE_ENC(5, BTF_INFO_ENC(BTF_KIND_FUNC, 0, 0), 2), + }; + + return probe_fd(libbpf__load_raw_btf((char *)types, sizeof(types), + strs, sizeof(strs))); +} + +static int probe_kern_btf_func_global(void) +{ + static const char strs[] = "\0int\0x\0a"; + /* static void x(int a) {} */ + __u32 types[] = { + /* int */ + BTF_TYPE_INT_ENC(1, BTF_INT_SIGNED, 0, 32, 4), /* [1] */ + /* FUNC_PROTO */ /* [2] */ + BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_FUNC_PROTO, 0, 1), 0), + BTF_PARAM_ENC(7, 1), + /* FUNC x BTF_FUNC_GLOBAL */ /* [3] */ + BTF_TYPE_ENC(5, BTF_INFO_ENC(BTF_KIND_FUNC, 0, BTF_FUNC_GLOBAL), 2), + }; + + return probe_fd(libbpf__load_raw_btf((char *)types, sizeof(types), + strs, sizeof(strs))); +} + +static int probe_kern_btf_datasec(void) +{ + static const char strs[] = "\0x\0.data"; + /* static int a; */ + __u32 types[] = { + /* int */ + BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */ + /* VAR x */ /* [2] */ + BTF_TYPE_ENC(1, BTF_INFO_ENC(BTF_KIND_VAR, 0, 0), 1), + BTF_VAR_STATIC, + /* DATASEC val */ /* [3] */ + BTF_TYPE_ENC(3, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 4), + BTF_VAR_SECINFO_ENC(2, 0, 4), + }; + + return probe_fd(libbpf__load_raw_btf((char *)types, sizeof(types), + strs, sizeof(strs))); +} + +static int probe_kern_btf_float(void) +{ + static const char strs[] = "\0float"; + __u32 types[] = { + /* float */ + BTF_TYPE_FLOAT_ENC(1, 4), + }; + + return probe_fd(libbpf__load_raw_btf((char *)types, sizeof(types), + strs, sizeof(strs))); +} + +static int probe_kern_array_mmap(void) +{ + struct bpf_create_map_attr attr = { + .map_type = BPF_MAP_TYPE_ARRAY, + .map_flags = BPF_F_MMAPABLE, + .key_size = sizeof(int), + .value_size = sizeof(int), + .max_entries = 1, + }; + + return probe_fd(bpf_create_map_xattr(&attr)); +} + +static int probe_kern_exp_attach_type(void) +{ + struct bpf_load_program_attr attr; + struct bpf_insn insns[] = { + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }; + + memset(&attr, 0, sizeof(attr)); + /* use any valid combination of program type and (optional) + * non-zero expected attach type (i.e., not a BPF_CGROUP_INET_INGRESS) + * to see if kernel supports expected_attach_type field for + * BPF_PROG_LOAD command + */ + attr.prog_type = BPF_PROG_TYPE_CGROUP_SOCK; + attr.expected_attach_type = BPF_CGROUP_INET_SOCK_CREATE; + attr.insns = insns; + attr.insns_cnt = ARRAY_SIZE(insns); + attr.license = "GPL"; + + return probe_fd(bpf_load_program_xattr(&attr, NULL, 0)); +} + +static int probe_kern_probe_read_kernel(void) +{ + struct bpf_load_program_attr attr; + struct bpf_insn insns[] = { + BPF_MOV64_REG(BPF_REG_1, BPF_REG_10), /* r1 = r10 (fp) */ + BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -8), /* r1 += -8 */ + BPF_MOV64_IMM(BPF_REG_2, 8), /* r2 = 8 */ + BPF_MOV64_IMM(BPF_REG_3, 0), /* r3 = 0 */ + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_probe_read_kernel), + BPF_EXIT_INSN(), + }; + + memset(&attr, 0, sizeof(attr)); + attr.prog_type = BPF_PROG_TYPE_KPROBE; + attr.insns = insns; + attr.insns_cnt = ARRAY_SIZE(insns); + attr.license = "GPL"; + + return probe_fd(bpf_load_program_xattr(&attr, NULL, 0)); +} + +static int probe_prog_bind_map(void) +{ + struct bpf_load_program_attr prg_attr; + struct bpf_create_map_attr map_attr; + char *cp, errmsg[STRERR_BUFSIZE]; + struct bpf_insn insns[] = { + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }; + int ret, map, prog; + + memset(&map_attr, 0, sizeof(map_attr)); + map_attr.map_type = BPF_MAP_TYPE_ARRAY; + map_attr.key_size = sizeof(int); + map_attr.value_size = 32; + map_attr.max_entries = 1; + + map = bpf_create_map_xattr(&map_attr); + if (map < 0) { + ret = -errno; + cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg)); + pr_warn("Error in %s():%s(%d). Couldn't create simple array map.\n", + __func__, cp, -ret); + return ret; + } + + memset(&prg_attr, 0, sizeof(prg_attr)); + prg_attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER; + prg_attr.insns = insns; + prg_attr.insns_cnt = ARRAY_SIZE(insns); + prg_attr.license = "GPL"; + + prog = bpf_load_program_xattr(&prg_attr, NULL, 0); + if (prog < 0) { + close(map); + return 0; + } + + ret = bpf_prog_bind_map(prog, map, NULL); + + close(map); + close(prog); + + return ret >= 0; +} + +static int probe_module_btf(void) +{ + static const char strs[] = "\0int"; + __u32 types[] = { + /* int */ + BTF_TYPE_INT_ENC(1, BTF_INT_SIGNED, 0, 32, 4), + }; + struct bpf_btf_info info; + __u32 len = sizeof(info); + char name[16]; + int fd, err; + + fd = libbpf__load_raw_btf((char *)types, sizeof(types), strs, sizeof(strs)); + if (fd < 0) + return 0; /* BTF not supported at all */ + + memset(&info, 0, sizeof(info)); + info.name = ptr_to_u64(name); + info.name_len = sizeof(name); + + /* check that BPF_OBJ_GET_INFO_BY_FD supports specifying name pointer; + * kernel's module BTF support coincides with support for + * name/name_len fields in struct bpf_btf_info. + */ + err = bpf_obj_get_info_by_fd(fd, &info, &len); + close(fd); + return !err; +} + +enum kern_feature_result { + FEAT_UNKNOWN = 0, + FEAT_SUPPORTED = 1, + FEAT_MISSING = 2, +}; + +typedef int (*feature_probe_fn)(void); + +static struct kern_feature_desc { + const char *desc; + feature_probe_fn probe; + enum kern_feature_result res; +} feature_probes[__FEAT_CNT] = { + [FEAT_PROG_NAME] = { + "BPF program name", probe_kern_prog_name, + }, + [FEAT_GLOBAL_DATA] = { + "global variables", probe_kern_global_data, + }, + [FEAT_BTF] = { + "minimal BTF", probe_kern_btf, + }, + [FEAT_BTF_FUNC] = { + "BTF functions", probe_kern_btf_func, + }, + [FEAT_BTF_GLOBAL_FUNC] = { + "BTF global function", probe_kern_btf_func_global, + }, + [FEAT_BTF_DATASEC] = { + "BTF data section and variable", probe_kern_btf_datasec, + }, + [FEAT_ARRAY_MMAP] = { + "ARRAY map mmap()", probe_kern_array_mmap, + }, + [FEAT_EXP_ATTACH_TYPE] = { + "BPF_PROG_LOAD expected_attach_type attribute", + probe_kern_exp_attach_type, + }, + [FEAT_PROBE_READ_KERN] = { + "bpf_probe_read_kernel() helper", probe_kern_probe_read_kernel, + }, + [FEAT_PROG_BIND_MAP] = { + "BPF_PROG_BIND_MAP support", probe_prog_bind_map, + }, + [FEAT_MODULE_BTF] = { + "module BTF support", probe_module_btf, + }, + [FEAT_BTF_FLOAT] = { + "BTF_KIND_FLOAT support", probe_kern_btf_float, + }, +}; + +static bool kernel_supports(enum kern_feature_id feat_id) +{ + struct kern_feature_desc *feat = &feature_probes[feat_id]; + int ret; + + if (READ_ONCE(feat->res) == FEAT_UNKNOWN) { + ret = feat->probe(); + if (ret > 0) { + WRITE_ONCE(feat->res, FEAT_SUPPORTED); + } else if (ret == 0) { + WRITE_ONCE(feat->res, FEAT_MISSING); + } else { + pr_warn("Detection of kernel %s support failed: %d\n", feat->desc, ret); + WRITE_ONCE(feat->res, FEAT_MISSING); + } + } + + return READ_ONCE(feat->res) == FEAT_SUPPORTED; +} + +static bool map_is_reuse_compat(const struct bpf_map *map, int map_fd) +{ + struct bpf_map_info map_info = {}; + char msg[STRERR_BUFSIZE]; + __u32 map_info_len; + + map_info_len = sizeof(map_info); + + if (bpf_obj_get_info_by_fd(map_fd, &map_info, &map_info_len)) { + pr_warn("failed to get map info for map FD %d: %s\n", + map_fd, libbpf_strerror_r(errno, msg, sizeof(msg))); + return false; + } + + return (map_info.type == map->def.type && + map_info.key_size == map->def.key_size && + map_info.value_size == map->def.value_size && + map_info.max_entries == map->def.max_entries && + map_info.map_flags == map->def.map_flags); +} + +static int +bpf_object__reuse_map(struct bpf_map *map) +{ + char *cp, errmsg[STRERR_BUFSIZE]; + int err, pin_fd; + + pin_fd = bpf_obj_get(map->pin_path); + if (pin_fd < 0) { + err = -errno; + if (err == -ENOENT) { + pr_debug("found no pinned map to reuse at '%s'\n", + map->pin_path); + return 0; + } + + cp = libbpf_strerror_r(-err, errmsg, sizeof(errmsg)); + pr_warn("couldn't retrieve pinned map '%s': %s\n", + map->pin_path, cp); + return err; + } + + if (!map_is_reuse_compat(map, pin_fd)) { + pr_warn("couldn't reuse pinned map at '%s': parameter mismatch\n", + map->pin_path); + close(pin_fd); + return -EINVAL; + } + + err = bpf_map__reuse_fd(map, pin_fd); + if (err) { + close(pin_fd); + return err; + } + map->pinned = true; + pr_debug("reused pinned map at '%s'\n", map->pin_path); + + return 0; +} + +static int +bpf_object__populate_internal_map(struct bpf_object *obj, struct bpf_map *map) +{ + enum libbpf_map_type map_type = map->libbpf_type; + char *cp, errmsg[STRERR_BUFSIZE]; + int err, zero = 0; + + err = bpf_map_update_elem(map->fd, &zero, map->mmaped, 0); + if (err) { + err = -errno; + cp = libbpf_strerror_r(err, errmsg, sizeof(errmsg)); + pr_warn("Error setting initial map(%s) contents: %s\n", + map->name, cp); + return err; + } + + /* Freeze .rodata and .kconfig map as read-only from syscall side. */ + if (map_type == LIBBPF_MAP_RODATA || map_type == LIBBPF_MAP_KCONFIG) { + err = bpf_map_freeze(map->fd); + if (err) { + err = -errno; + cp = libbpf_strerror_r(err, errmsg, sizeof(errmsg)); + pr_warn("Error freezing map(%s) as read-only: %s\n", + map->name, cp); + return err; + } + } + return 0; +} + +static void bpf_map__destroy(struct bpf_map *map); + +static int bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map) +{ + struct bpf_create_map_attr create_attr; + struct bpf_map_def *def = &map->def; + + memset(&create_attr, 0, sizeof(create_attr)); + + if (kernel_supports(FEAT_PROG_NAME)) + create_attr.name = map->name; + create_attr.map_ifindex = map->map_ifindex; + create_attr.map_type = def->type; + create_attr.map_flags = def->map_flags; + create_attr.key_size = def->key_size; + create_attr.value_size = def->value_size; + create_attr.numa_node = map->numa_node; + + if (def->type == BPF_MAP_TYPE_PERF_EVENT_ARRAY && !def->max_entries) { + int nr_cpus; + + nr_cpus = libbpf_num_possible_cpus(); + if (nr_cpus < 0) { + pr_warn("map '%s': failed to determine number of system CPUs: %d\n", + map->name, nr_cpus); + return nr_cpus; + } + pr_debug("map '%s': setting size to %d\n", map->name, nr_cpus); + create_attr.max_entries = nr_cpus; + } else { + create_attr.max_entries = def->max_entries; + } + + if (bpf_map__is_struct_ops(map)) + create_attr.btf_vmlinux_value_type_id = + map->btf_vmlinux_value_type_id; + + create_attr.btf_fd = 0; + create_attr.btf_key_type_id = 0; + create_attr.btf_value_type_id = 0; + if (obj->btf && btf__fd(obj->btf) >= 0 && !bpf_map_find_btf_info(obj, map)) { + create_attr.btf_fd = btf__fd(obj->btf); + create_attr.btf_key_type_id = map->btf_key_type_id; + create_attr.btf_value_type_id = map->btf_value_type_id; + } + + if (bpf_map_type__is_map_in_map(def->type)) { + if (map->inner_map) { + int err; + + err = bpf_object__create_map(obj, map->inner_map); + if (err) { + pr_warn("map '%s': failed to create inner map: %d\n", + map->name, err); + return err; + } + map->inner_map_fd = bpf_map__fd(map->inner_map); + } + if (map->inner_map_fd >= 0) + create_attr.inner_map_fd = map->inner_map_fd; + } + + map->fd = bpf_create_map_xattr(&create_attr); + if (map->fd < 0 && (create_attr.btf_key_type_id || + create_attr.btf_value_type_id)) { + char *cp, errmsg[STRERR_BUFSIZE]; + int err = -errno; + + cp = libbpf_strerror_r(err, errmsg, sizeof(errmsg)); + pr_warn("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n", + map->name, cp, err); + create_attr.btf_fd = 0; + create_attr.btf_key_type_id = 0; + create_attr.btf_value_type_id = 0; + map->btf_key_type_id = 0; + map->btf_value_type_id = 0; + map->fd = bpf_create_map_xattr(&create_attr); + } + + if (map->fd < 0) + return -errno; + + if (bpf_map_type__is_map_in_map(def->type) && map->inner_map) { + bpf_map__destroy(map->inner_map); + zfree(&map->inner_map); + } + + return 0; +} + +static int init_map_slots(struct bpf_map *map) +{ + const struct bpf_map *targ_map; + unsigned int i; + int fd, err; + + for (i = 0; i < map->init_slots_sz; i++) { + if (!map->init_slots[i]) + continue; + + targ_map = map->init_slots[i]; + fd = bpf_map__fd(targ_map); + err = bpf_map_update_elem(map->fd, &i, &fd, 0); + if (err) { + err = -errno; + pr_warn("map '%s': failed to initialize slot [%d] to map '%s' fd=%d: %d\n", + map->name, i, targ_map->name, + fd, err); + return err; + } + pr_debug("map '%s': slot [%d] set to map '%s' fd=%d\n", + map->name, i, targ_map->name, fd); + } + + zfree(&map->init_slots); + map->init_slots_sz = 0; + + return 0; +} + +static int +bpf_object__create_maps(struct bpf_object *obj) +{ + struct bpf_map *map; + char *cp, errmsg[STRERR_BUFSIZE]; + unsigned int i, j; + int err; + + for (i = 0; i < obj->nr_maps; i++) { + map = &obj->maps[i]; + + if (map->pin_path) { + err = bpf_object__reuse_map(map); + if (err) { + pr_warn("map '%s': error reusing pinned map\n", + map->name); + goto err_out; + } + } + + if (map->fd >= 0) { + pr_debug("map '%s': skipping creation (preset fd=%d)\n", + map->name, map->fd); + } else { + err = bpf_object__create_map(obj, map); + if (err) + goto err_out; + + pr_debug("map '%s': created successfully, fd=%d\n", + map->name, map->fd); + + if (bpf_map__is_internal(map)) { + err = bpf_object__populate_internal_map(obj, map); + if (err < 0) { + zclose(map->fd); + goto err_out; + } + } + + if (map->init_slots_sz) { + err = init_map_slots(map); + if (err < 0) { + zclose(map->fd); + goto err_out; + } + } + } + + if (map->pin_path && !map->pinned) { + err = bpf_map__pin(map, NULL); + if (err) { + pr_warn("map '%s': failed to auto-pin at '%s': %d\n", + map->name, map->pin_path, err); + zclose(map->fd); + goto err_out; + } + } + } + + return 0; + +err_out: + cp = libbpf_strerror_r(err, errmsg, sizeof(errmsg)); + pr_warn("map '%s': failed to create: %s(%d)\n", map->name, cp, err); + pr_perm_msg(err); + for (j = 0; j < i; j++) + zclose(obj->maps[j].fd); + return err; +} + +#define BPF_CORE_SPEC_MAX_LEN 64 + +/* represents BPF CO-RE field or array element accessor */ +struct bpf_core_accessor { + __u32 type_id; /* struct/union type or array element type */ + __u32 idx; /* field index or array index */ + const char *name; /* field name or NULL for array accessor */ +}; + +struct bpf_core_spec { + const struct btf *btf; + /* high-level spec: named fields and array indices only */ + struct bpf_core_accessor spec[BPF_CORE_SPEC_MAX_LEN]; + /* original unresolved (no skip_mods_or_typedefs) root type ID */ + __u32 root_type_id; + /* CO-RE relocation kind */ + enum bpf_core_relo_kind relo_kind; + /* high-level spec length */ + int len; + /* raw, low-level spec: 1-to-1 with accessor spec string */ + int raw_spec[BPF_CORE_SPEC_MAX_LEN]; + /* raw spec length */ + int raw_len; + /* field bit offset represented by spec */ + __u32 bit_offset; +}; + +static bool str_is_empty(const char *s) +{ + return !s || !s[0]; +} + +static bool is_flex_arr(const struct btf *btf, + const struct bpf_core_accessor *acc, + const struct btf_array *arr) +{ + const struct btf_type *t; + + /* not a flexible array, if not inside a struct or has non-zero size */ + if (!acc->name || arr->nelems > 0) + return false; + + /* has to be the last member of enclosing struct */ + t = btf__type_by_id(btf, acc->type_id); + return acc->idx == btf_vlen(t) - 1; +} + +static const char *core_relo_kind_str(enum bpf_core_relo_kind kind) +{ + switch (kind) { + case BPF_FIELD_BYTE_OFFSET: return "byte_off"; + case BPF_FIELD_BYTE_SIZE: return "byte_sz"; + case BPF_FIELD_EXISTS: return "field_exists"; + case BPF_FIELD_SIGNED: return "signed"; + case BPF_FIELD_LSHIFT_U64: return "lshift_u64"; + case BPF_FIELD_RSHIFT_U64: return "rshift_u64"; + case BPF_TYPE_ID_LOCAL: return "local_type_id"; + case BPF_TYPE_ID_TARGET: return "target_type_id"; + case BPF_TYPE_EXISTS: return "type_exists"; + case BPF_TYPE_SIZE: return "type_size"; + case BPF_ENUMVAL_EXISTS: return "enumval_exists"; + case BPF_ENUMVAL_VALUE: return "enumval_value"; + default: return "unknown"; + } +} + +static bool core_relo_is_field_based(enum bpf_core_relo_kind kind) +{ + switch (kind) { + case BPF_FIELD_BYTE_OFFSET: + case BPF_FIELD_BYTE_SIZE: + case BPF_FIELD_EXISTS: + case BPF_FIELD_SIGNED: + case BPF_FIELD_LSHIFT_U64: + case BPF_FIELD_RSHIFT_U64: + return true; + default: + return false; + } +} + +static bool core_relo_is_type_based(enum bpf_core_relo_kind kind) +{ + switch (kind) { + case BPF_TYPE_ID_LOCAL: + case BPF_TYPE_ID_TARGET: + case BPF_TYPE_EXISTS: + case BPF_TYPE_SIZE: + return true; + default: + return false; + } +} + +static bool core_relo_is_enumval_based(enum bpf_core_relo_kind kind) +{ + switch (kind) { + case BPF_ENUMVAL_EXISTS: + case BPF_ENUMVAL_VALUE: + return true; + default: + return false; + } +} + +/* + * Turn bpf_core_relo into a low- and high-level spec representation, + * validating correctness along the way, as well as calculating resulting + * field bit offset, specified by accessor string. Low-level spec captures + * every single level of nestedness, including traversing anonymous + * struct/union members. High-level one only captures semantically meaningful + * "turning points": named fields and array indicies. + * E.g., for this case: + * + * struct sample { + * int __unimportant; + * struct { + * int __1; + * int __2; + * int a[7]; + * }; + * }; + * + * struct sample *s = ...; + * + * int x = &s->a[3]; // access string = '0:1:2:3' + * + * Low-level spec has 1:1 mapping with each element of access string (it's + * just a parsed access string representation): [0, 1, 2, 3]. + * + * High-level spec will capture only 3 points: + * - intial zero-index access by pointer (&s->... is the same as &s[0]...); + * - field 'a' access (corresponds to '2' in low-level spec); + * - array element #3 access (corresponds to '3' in low-level spec). + * + * Type-based relocations (TYPE_EXISTS/TYPE_SIZE, + * TYPE_ID_LOCAL/TYPE_ID_TARGET) don't capture any field information. Their + * spec and raw_spec are kept empty. + * + * Enum value-based relocations (ENUMVAL_EXISTS/ENUMVAL_VALUE) use access + * string to specify enumerator's value index that need to be relocated. + */ +static int bpf_core_parse_spec(const struct btf *btf, + __u32 type_id, + const char *spec_str, + enum bpf_core_relo_kind relo_kind, + struct bpf_core_spec *spec) +{ + int access_idx, parsed_len, i; + struct bpf_core_accessor *acc; + const struct btf_type *t; + const char *name; + __u32 id; + __s64 sz; + + if (str_is_empty(spec_str) || *spec_str == ':') + return -EINVAL; + + memset(spec, 0, sizeof(*spec)); + spec->btf = btf; + spec->root_type_id = type_id; + spec->relo_kind = relo_kind; + + /* type-based relocations don't have a field access string */ + if (core_relo_is_type_based(relo_kind)) { + if (strcmp(spec_str, "0")) + return -EINVAL; + return 0; + } + + /* parse spec_str="0:1:2:3:4" into array raw_spec=[0, 1, 2, 3, 4] */ + while (*spec_str) { + if (*spec_str == ':') + ++spec_str; + if (sscanf(spec_str, "%d%n", &access_idx, &parsed_len) != 1) + return -EINVAL; + if (spec->raw_len == BPF_CORE_SPEC_MAX_LEN) + return -E2BIG; + spec_str += parsed_len; + spec->raw_spec[spec->raw_len++] = access_idx; + } + + if (spec->raw_len == 0) + return -EINVAL; + + t = skip_mods_and_typedefs(btf, type_id, &id); + if (!t) + return -EINVAL; + + access_idx = spec->raw_spec[0]; + acc = &spec->spec[0]; + acc->type_id = id; + acc->idx = access_idx; + spec->len++; + + if (core_relo_is_enumval_based(relo_kind)) { + if (!btf_is_enum(t) || spec->raw_len > 1 || access_idx >= btf_vlen(t)) + return -EINVAL; + + /* record enumerator name in a first accessor */ + acc->name = btf__name_by_offset(btf, btf_enum(t)[access_idx].name_off); + return 0; + } + + if (!core_relo_is_field_based(relo_kind)) + return -EINVAL; + + sz = btf__resolve_size(btf, id); + if (sz < 0) + return sz; + spec->bit_offset = access_idx * sz * 8; + + for (i = 1; i < spec->raw_len; i++) { + t = skip_mods_and_typedefs(btf, id, &id); + if (!t) + return -EINVAL; + + access_idx = spec->raw_spec[i]; + acc = &spec->spec[spec->len]; + + if (btf_is_composite(t)) { + const struct btf_member *m; + __u32 bit_offset; + + if (access_idx >= btf_vlen(t)) + return -EINVAL; + + bit_offset = btf_member_bit_offset(t, access_idx); + spec->bit_offset += bit_offset; + + m = btf_members(t) + access_idx; + if (m->name_off) { + name = btf__name_by_offset(btf, m->name_off); + if (str_is_empty(name)) + return -EINVAL; + + acc->type_id = id; + acc->idx = access_idx; + acc->name = name; + spec->len++; + } + + id = m->type; + } else if (btf_is_array(t)) { + const struct btf_array *a = btf_array(t); + bool flex; + + t = skip_mods_and_typedefs(btf, a->type, &id); + if (!t) + return -EINVAL; + + flex = is_flex_arr(btf, acc - 1, a); + if (!flex && access_idx >= a->nelems) + return -EINVAL; + + spec->spec[spec->len].type_id = id; + spec->spec[spec->len].idx = access_idx; + spec->len++; + + sz = btf__resolve_size(btf, id); + if (sz < 0) + return sz; + spec->bit_offset += access_idx * sz * 8; + } else { + pr_warn("relo for [%u] %s (at idx %d) captures type [%d] of unexpected kind %s\n", + type_id, spec_str, i, id, btf_kind_str(t)); + return -EINVAL; + } + } + + return 0; +} + +static bool bpf_core_is_flavor_sep(const char *s) +{ + /* check X___Y name pattern, where X and Y are not underscores */ + return s[0] != '_' && /* X */ + s[1] == '_' && s[2] == '_' && s[3] == '_' && /* ___ */ + s[4] != '_'; /* Y */ +} + +/* Given 'some_struct_name___with_flavor' return the length of a name prefix + * before last triple underscore. Struct name part after last triple + * underscore is ignored by BPF CO-RE relocation during relocation matching. + */ +static size_t bpf_core_essential_name_len(const char *name) +{ + size_t n = strlen(name); + int i; + + for (i = n - 5; i >= 0; i--) { + if (bpf_core_is_flavor_sep(name + i)) + return i + 1; + } + return n; +} + +struct core_cand +{ + const struct btf *btf; + const struct btf_type *t; + const char *name; + __u32 id; +}; + +/* dynamically sized list of type IDs and its associated struct btf */ +struct core_cand_list { + struct core_cand *cands; + int len; +}; + +static void bpf_core_free_cands(struct core_cand_list *cands) +{ + free(cands->cands); + free(cands); +} + +static int bpf_core_add_cands(struct core_cand *local_cand, + size_t local_essent_len, + const struct btf *targ_btf, + const char *targ_btf_name, + int targ_start_id, + struct core_cand_list *cands) +{ + struct core_cand *new_cands, *cand; + const struct btf_type *t; + const char *targ_name; + size_t targ_essent_len; + int n, i; + + n = btf__get_nr_types(targ_btf); + for (i = targ_start_id; i <= n; i++) { + t = btf__type_by_id(targ_btf, i); + if (btf_kind(t) != btf_kind(local_cand->t)) + continue; + + targ_name = btf__name_by_offset(targ_btf, t->name_off); + if (str_is_empty(targ_name)) + continue; + + targ_essent_len = bpf_core_essential_name_len(targ_name); + if (targ_essent_len != local_essent_len) + continue; + + if (strncmp(local_cand->name, targ_name, local_essent_len) != 0) + continue; + + pr_debug("CO-RE relocating [%d] %s %s: found target candidate [%d] %s %s in [%s]\n", + local_cand->id, btf_kind_str(local_cand->t), + local_cand->name, i, btf_kind_str(t), targ_name, + targ_btf_name); + new_cands = libbpf_reallocarray(cands->cands, cands->len + 1, + sizeof(*cands->cands)); + if (!new_cands) + return -ENOMEM; + + cand = &new_cands[cands->len]; + cand->btf = targ_btf; + cand->t = t; + cand->name = targ_name; + cand->id = i; + + cands->cands = new_cands; + cands->len++; + } + return 0; +} + +static int load_module_btfs(struct bpf_object *obj) +{ + struct bpf_btf_info info; + struct module_btf *mod_btf; + struct btf *btf; + char name[64]; + __u32 id = 0, len; + int err, fd; + + if (obj->btf_modules_loaded) + return 0; + + /* don't do this again, even if we find no module BTFs */ + obj->btf_modules_loaded = true; + + /* kernel too old to support module BTFs */ + if (!kernel_supports(FEAT_MODULE_BTF)) + return 0; + + while (true) { + err = bpf_btf_get_next_id(id, &id); + if (err && errno == ENOENT) + return 0; + if (err) { + err = -errno; + pr_warn("failed to iterate BTF objects: %d\n", err); + return err; + } + + fd = bpf_btf_get_fd_by_id(id); + if (fd < 0) { + if (errno == ENOENT) + continue; /* expected race: BTF was unloaded */ + err = -errno; + pr_warn("failed to get BTF object #%d FD: %d\n", id, err); + return err; + } + + len = sizeof(info); + memset(&info, 0, sizeof(info)); + info.name = ptr_to_u64(name); + info.name_len = sizeof(name); + + err = bpf_obj_get_info_by_fd(fd, &info, &len); + if (err) { + err = -errno; + pr_warn("failed to get BTF object #%d info: %d\n", id, err); + goto err_out; + } + + /* ignore non-module BTFs */ + if (!info.kernel_btf || strcmp(name, "vmlinux") == 0) { + close(fd); + continue; + } + + btf = btf_get_from_fd(fd, obj->btf_vmlinux); + if (IS_ERR(btf)) { + pr_warn("failed to load module [%s]'s BTF object #%d: %ld\n", + name, id, PTR_ERR(btf)); + err = PTR_ERR(btf); + goto err_out; + } + + err = btf_ensure_mem((void **)&obj->btf_modules, &obj->btf_module_cap, + sizeof(*obj->btf_modules), obj->btf_module_cnt + 1); + if (err) + goto err_out; + + mod_btf = &obj->btf_modules[obj->btf_module_cnt++]; + + mod_btf->btf = btf; + mod_btf->id = id; + mod_btf->fd = fd; + mod_btf->name = strdup(name); + if (!mod_btf->name) { + err = -ENOMEM; + goto err_out; + } + continue; + +err_out: + close(fd); + return err; + } + + return 0; +} + +static struct core_cand_list * +bpf_core_find_cands(struct bpf_object *obj, const struct btf *local_btf, __u32 local_type_id) +{ + struct core_cand local_cand = {}; + struct core_cand_list *cands; + const struct btf *main_btf; + size_t local_essent_len; + int err, i; + + local_cand.btf = local_btf; + local_cand.t = btf__type_by_id(local_btf, local_type_id); + if (!local_cand.t) + return ERR_PTR(-EINVAL); + + local_cand.name = btf__name_by_offset(local_btf, local_cand.t->name_off); + if (str_is_empty(local_cand.name)) + return ERR_PTR(-EINVAL); + local_essent_len = bpf_core_essential_name_len(local_cand.name); + + cands = calloc(1, sizeof(*cands)); + if (!cands) + return ERR_PTR(-ENOMEM); + + /* Attempt to find target candidates in vmlinux BTF first */ + main_btf = obj->btf_vmlinux_override ?: obj->btf_vmlinux; + err = bpf_core_add_cands(&local_cand, local_essent_len, main_btf, "vmlinux", 1, cands); + if (err) + goto err_out; + + /* if vmlinux BTF has any candidate, don't got for module BTFs */ + if (cands->len) + return cands; + + /* if vmlinux BTF was overridden, don't attempt to load module BTFs */ + if (obj->btf_vmlinux_override) + return cands; + + /* now look through module BTFs, trying to still find candidates */ + err = load_module_btfs(obj); + if (err) + goto err_out; + + for (i = 0; i < obj->btf_module_cnt; i++) { + err = bpf_core_add_cands(&local_cand, local_essent_len, + obj->btf_modules[i].btf, + obj->btf_modules[i].name, + btf__get_nr_types(obj->btf_vmlinux) + 1, + cands); + if (err) + goto err_out; + } + + return cands; +err_out: + bpf_core_free_cands(cands); + return ERR_PTR(err); +} + +/* Check two types for compatibility for the purpose of field access + * relocation. const/volatile/restrict and typedefs are skipped to ensure we + * are relocating semantically compatible entities: + * - any two STRUCTs/UNIONs are compatible and can be mixed; + * - any two FWDs are compatible, if their names match (modulo flavor suffix); + * - any two PTRs are always compatible; + * - for ENUMs, names should be the same (ignoring flavor suffix) or at + * least one of enums should be anonymous; + * - for ENUMs, check sizes, names are ignored; + * - for INT, size and signedness are ignored; + * - for ARRAY, dimensionality is ignored, element types are checked for + * compatibility recursively; + * - everything else shouldn't be ever a target of relocation. + * These rules are not set in stone and probably will be adjusted as we get + * more experience with using BPF CO-RE relocations. + */ +static int bpf_core_fields_are_compat(const struct btf *local_btf, + __u32 local_id, + const struct btf *targ_btf, + __u32 targ_id) +{ + const struct btf_type *local_type, *targ_type; + +recur: + local_type = skip_mods_and_typedefs(local_btf, local_id, &local_id); + targ_type = skip_mods_and_typedefs(targ_btf, targ_id, &targ_id); + if (!local_type || !targ_type) + return -EINVAL; + + if (btf_is_composite(local_type) && btf_is_composite(targ_type)) + return 1; + if (btf_kind(local_type) != btf_kind(targ_type)) + return 0; + + switch (btf_kind(local_type)) { + case BTF_KIND_PTR: + return 1; + case BTF_KIND_FWD: + case BTF_KIND_ENUM: { + const char *local_name, *targ_name; + size_t local_len, targ_len; + + local_name = btf__name_by_offset(local_btf, + local_type->name_off); + targ_name = btf__name_by_offset(targ_btf, targ_type->name_off); + local_len = bpf_core_essential_name_len(local_name); + targ_len = bpf_core_essential_name_len(targ_name); + /* one of them is anonymous or both w/ same flavor-less names */ + return local_len == 0 || targ_len == 0 || + (local_len == targ_len && + strncmp(local_name, targ_name, local_len) == 0); + } + case BTF_KIND_INT: + /* just reject deprecated bitfield-like integers; all other + * integers are by default compatible between each other + */ + return btf_int_offset(local_type) == 0 && + btf_int_offset(targ_type) == 0; + case BTF_KIND_ARRAY: + local_id = btf_array(local_type)->type; + targ_id = btf_array(targ_type)->type; + goto recur; + default: + pr_warn("unexpected kind %d relocated, local [%d], target [%d]\n", + btf_kind(local_type), local_id, targ_id); + return 0; + } +} + +/* + * Given single high-level named field accessor in local type, find + * corresponding high-level accessor for a target type. Along the way, + * maintain low-level spec for target as well. Also keep updating target + * bit offset. + * + * Searching is performed through recursive exhaustive enumeration of all + * fields of a struct/union. If there are any anonymous (embedded) + * structs/unions, they are recursively searched as well. If field with + * desired name is found, check compatibility between local and target types, + * before returning result. + * + * 1 is returned, if field is found. + * 0 is returned if no compatible field is found. + * <0 is returned on error. + */ +static int bpf_core_match_member(const struct btf *local_btf, + const struct bpf_core_accessor *local_acc, + const struct btf *targ_btf, + __u32 targ_id, + struct bpf_core_spec *spec, + __u32 *next_targ_id) +{ + const struct btf_type *local_type, *targ_type; + const struct btf_member *local_member, *m; + const char *local_name, *targ_name; + __u32 local_id; + int i, n, found; + + targ_type = skip_mods_and_typedefs(targ_btf, targ_id, &targ_id); + if (!targ_type) + return -EINVAL; + if (!btf_is_composite(targ_type)) + return 0; + + local_id = local_acc->type_id; + local_type = btf__type_by_id(local_btf, local_id); + local_member = btf_members(local_type) + local_acc->idx; + local_name = btf__name_by_offset(local_btf, local_member->name_off); + + n = btf_vlen(targ_type); + m = btf_members(targ_type); + for (i = 0; i < n; i++, m++) { + __u32 bit_offset; + + bit_offset = btf_member_bit_offset(targ_type, i); + + /* too deep struct/union/array nesting */ + if (spec->raw_len == BPF_CORE_SPEC_MAX_LEN) + return -E2BIG; + + /* speculate this member will be the good one */ + spec->bit_offset += bit_offset; + spec->raw_spec[spec->raw_len++] = i; + + targ_name = btf__name_by_offset(targ_btf, m->name_off); + if (str_is_empty(targ_name)) { + /* embedded struct/union, we need to go deeper */ + found = bpf_core_match_member(local_btf, local_acc, + targ_btf, m->type, + spec, next_targ_id); + if (found) /* either found or error */ + return found; + } else if (strcmp(local_name, targ_name) == 0) { + /* matching named field */ + struct bpf_core_accessor *targ_acc; + + targ_acc = &spec->spec[spec->len++]; + targ_acc->type_id = targ_id; + targ_acc->idx = i; + targ_acc->name = targ_name; + + *next_targ_id = m->type; + found = bpf_core_fields_are_compat(local_btf, + local_member->type, + targ_btf, m->type); + if (!found) + spec->len--; /* pop accessor */ + return found; + } + /* member turned out not to be what we looked for */ + spec->bit_offset -= bit_offset; + spec->raw_len--; + } + + return 0; +} + +/* Check local and target types for compatibility. This check is used for + * type-based CO-RE relocations and follow slightly different rules than + * field-based relocations. This function assumes that root types were already + * checked for name match. Beyond that initial root-level name check, names + * are completely ignored. Compatibility rules are as follows: + * - any two STRUCTs/UNIONs/FWDs/ENUMs/INTs are considered compatible, but + * kind should match for local and target types (i.e., STRUCT is not + * compatible with UNION); + * - for ENUMs, the size is ignored; + * - for INT, size and signedness are ignored; + * - for ARRAY, dimensionality is ignored, element types are checked for + * compatibility recursively; + * - CONST/VOLATILE/RESTRICT modifiers are ignored; + * - TYPEDEFs/PTRs are compatible if types they pointing to are compatible; + * - FUNC_PROTOs are compatible if they have compatible signature: same + * number of input args and compatible return and argument types. + * These rules are not set in stone and probably will be adjusted as we get + * more experience with using BPF CO-RE relocations. + */ +static int bpf_core_types_are_compat(const struct btf *local_btf, __u32 local_id, + const struct btf *targ_btf, __u32 targ_id) +{ + const struct btf_type *local_type, *targ_type; + int depth = 32; /* max recursion depth */ + + /* caller made sure that names match (ignoring flavor suffix) */ + local_type = btf__type_by_id(local_btf, local_id); + targ_type = btf__type_by_id(targ_btf, targ_id); + if (btf_kind(local_type) != btf_kind(targ_type)) + return 0; + +recur: + depth--; + if (depth < 0) + return -EINVAL; + + local_type = skip_mods_and_typedefs(local_btf, local_id, &local_id); + targ_type = skip_mods_and_typedefs(targ_btf, targ_id, &targ_id); + if (!local_type || !targ_type) + return -EINVAL; + + if (btf_kind(local_type) != btf_kind(targ_type)) + return 0; + + switch (btf_kind(local_type)) { + case BTF_KIND_UNKN: + case BTF_KIND_STRUCT: + case BTF_KIND_UNION: + case BTF_KIND_ENUM: + case BTF_KIND_FWD: + return 1; + case BTF_KIND_INT: + /* just reject deprecated bitfield-like integers; all other + * integers are by default compatible between each other + */ + return btf_int_offset(local_type) == 0 && btf_int_offset(targ_type) == 0; + case BTF_KIND_PTR: + local_id = local_type->type; + targ_id = targ_type->type; + goto recur; + case BTF_KIND_ARRAY: + local_id = btf_array(local_type)->type; + targ_id = btf_array(targ_type)->type; + goto recur; + case BTF_KIND_FUNC_PROTO: { + struct btf_param *local_p = btf_params(local_type); + struct btf_param *targ_p = btf_params(targ_type); + __u16 local_vlen = btf_vlen(local_type); + __u16 targ_vlen = btf_vlen(targ_type); + int i, err; + + if (local_vlen != targ_vlen) + return 0; + + for (i = 0; i < local_vlen; i++, local_p++, targ_p++) { + skip_mods_and_typedefs(local_btf, local_p->type, &local_id); + skip_mods_and_typedefs(targ_btf, targ_p->type, &targ_id); + err = bpf_core_types_are_compat(local_btf, local_id, targ_btf, targ_id); + if (err <= 0) + return err; + } + + /* tail recurse for return type check */ + skip_mods_and_typedefs(local_btf, local_type->type, &local_id); + skip_mods_and_typedefs(targ_btf, targ_type->type, &targ_id); + goto recur; + } + default: + pr_warn("unexpected kind %s relocated, local [%d], target [%d]\n", + btf_kind_str(local_type), local_id, targ_id); + return 0; + } +} + +/* + * Try to match local spec to a target type and, if successful, produce full + * target spec (high-level, low-level + bit offset). + */ +static int bpf_core_spec_match(struct bpf_core_spec *local_spec, + const struct btf *targ_btf, __u32 targ_id, + struct bpf_core_spec *targ_spec) +{ + const struct btf_type *targ_type; + const struct bpf_core_accessor *local_acc; + struct bpf_core_accessor *targ_acc; + int i, sz, matched; + + memset(targ_spec, 0, sizeof(*targ_spec)); + targ_spec->btf = targ_btf; + targ_spec->root_type_id = targ_id; + targ_spec->relo_kind = local_spec->relo_kind; + + if (core_relo_is_type_based(local_spec->relo_kind)) { + return bpf_core_types_are_compat(local_spec->btf, + local_spec->root_type_id, + targ_btf, targ_id); + } + + local_acc = &local_spec->spec[0]; + targ_acc = &targ_spec->spec[0]; + + if (core_relo_is_enumval_based(local_spec->relo_kind)) { + size_t local_essent_len, targ_essent_len; + const struct btf_enum *e; + const char *targ_name; + + /* has to resolve to an enum */ + targ_type = skip_mods_and_typedefs(targ_spec->btf, targ_id, &targ_id); + if (!btf_is_enum(targ_type)) + return 0; + + local_essent_len = bpf_core_essential_name_len(local_acc->name); + + for (i = 0, e = btf_enum(targ_type); i < btf_vlen(targ_type); i++, e++) { + targ_name = btf__name_by_offset(targ_spec->btf, e->name_off); + targ_essent_len = bpf_core_essential_name_len(targ_name); + if (targ_essent_len != local_essent_len) + continue; + if (strncmp(local_acc->name, targ_name, local_essent_len) == 0) { + targ_acc->type_id = targ_id; + targ_acc->idx = i; + targ_acc->name = targ_name; + targ_spec->len++; + targ_spec->raw_spec[targ_spec->raw_len] = targ_acc->idx; + targ_spec->raw_len++; + return 1; + } + } + return 0; + } + + if (!core_relo_is_field_based(local_spec->relo_kind)) + return -EINVAL; + + for (i = 0; i < local_spec->len; i++, local_acc++, targ_acc++) { + targ_type = skip_mods_and_typedefs(targ_spec->btf, targ_id, + &targ_id); + if (!targ_type) + return -EINVAL; + + if (local_acc->name) { + matched = bpf_core_match_member(local_spec->btf, + local_acc, + targ_btf, targ_id, + targ_spec, &targ_id); + if (matched <= 0) + return matched; + } else { + /* for i=0, targ_id is already treated as array element + * type (because it's the original struct), for others + * we should find array element type first + */ + if (i > 0) { + const struct btf_array *a; + bool flex; + + if (!btf_is_array(targ_type)) + return 0; + + a = btf_array(targ_type); + flex = is_flex_arr(targ_btf, targ_acc - 1, a); + if (!flex && local_acc->idx >= a->nelems) + return 0; + if (!skip_mods_and_typedefs(targ_btf, a->type, + &targ_id)) + return -EINVAL; + } + + /* too deep struct/union/array nesting */ + if (targ_spec->raw_len == BPF_CORE_SPEC_MAX_LEN) + return -E2BIG; + + targ_acc->type_id = targ_id; + targ_acc->idx = local_acc->idx; + targ_acc->name = NULL; + targ_spec->len++; + targ_spec->raw_spec[targ_spec->raw_len] = targ_acc->idx; + targ_spec->raw_len++; + + sz = btf__resolve_size(targ_btf, targ_id); + if (sz < 0) + return sz; + targ_spec->bit_offset += local_acc->idx * sz * 8; + } + } + + return 1; +} + +static int bpf_core_calc_field_relo(const struct bpf_program *prog, + const struct bpf_core_relo *relo, + const struct bpf_core_spec *spec, + __u32 *val, __u32 *field_sz, __u32 *type_id, + bool *validate) +{ + const struct bpf_core_accessor *acc; + const struct btf_type *t; + __u32 byte_off, byte_sz, bit_off, bit_sz, field_type_id; + const struct btf_member *m; + const struct btf_type *mt; + bool bitfield; + __s64 sz; + + *field_sz = 0; + + if (relo->kind == BPF_FIELD_EXISTS) { + *val = spec ? 1 : 0; + return 0; + } + + if (!spec) + return -EUCLEAN; /* request instruction poisoning */ + + acc = &spec->spec[spec->len - 1]; + t = btf__type_by_id(spec->btf, acc->type_id); + + /* a[n] accessor needs special handling */ + if (!acc->name) { + if (relo->kind == BPF_FIELD_BYTE_OFFSET) { + *val = spec->bit_offset / 8; + /* remember field size for load/store mem size */ + sz = btf__resolve_size(spec->btf, acc->type_id); + if (sz < 0) + return -EINVAL; + *field_sz = sz; + *type_id = acc->type_id; + } else if (relo->kind == BPF_FIELD_BYTE_SIZE) { + sz = btf__resolve_size(spec->btf, acc->type_id); + if (sz < 0) + return -EINVAL; + *val = sz; + } else { + pr_warn("prog '%s': relo %d at insn #%d can't be applied to array access\n", + prog->name, relo->kind, relo->insn_off / 8); + return -EINVAL; + } + if (validate) + *validate = true; + return 0; + } + + m = btf_members(t) + acc->idx; + mt = skip_mods_and_typedefs(spec->btf, m->type, &field_type_id); + bit_off = spec->bit_offset; + bit_sz = btf_member_bitfield_size(t, acc->idx); + + bitfield = bit_sz > 0; + if (bitfield) { + byte_sz = mt->size; + byte_off = bit_off / 8 / byte_sz * byte_sz; + /* figure out smallest int size necessary for bitfield load */ + while (bit_off + bit_sz - byte_off * 8 > byte_sz * 8) { + if (byte_sz >= 8) { + /* bitfield can't be read with 64-bit read */ + pr_warn("prog '%s': relo %d at insn #%d can't be satisfied for bitfield\n", + prog->name, relo->kind, relo->insn_off / 8); + return -E2BIG; + } + byte_sz *= 2; + byte_off = bit_off / 8 / byte_sz * byte_sz; + } + } else { + sz = btf__resolve_size(spec->btf, field_type_id); + if (sz < 0) + return -EINVAL; + byte_sz = sz; + byte_off = spec->bit_offset / 8; + bit_sz = byte_sz * 8; + } + + /* for bitfields, all the relocatable aspects are ambiguous and we + * might disagree with compiler, so turn off validation of expected + * value, except for signedness + */ + if (validate) + *validate = !bitfield; + + switch (relo->kind) { + case BPF_FIELD_BYTE_OFFSET: + *val = byte_off; + if (!bitfield) { + *field_sz = byte_sz; + *type_id = field_type_id; + } + break; + case BPF_FIELD_BYTE_SIZE: + *val = byte_sz; + break; + case BPF_FIELD_SIGNED: + /* enums will be assumed unsigned */ + *val = btf_is_enum(mt) || + (btf_int_encoding(mt) & BTF_INT_SIGNED); + if (validate) + *validate = true; /* signedness is never ambiguous */ + break; + case BPF_FIELD_LSHIFT_U64: +#if __BYTE_ORDER == __LITTLE_ENDIAN + *val = 64 - (bit_off + bit_sz - byte_off * 8); +#else + *val = (8 - byte_sz) * 8 + (bit_off - byte_off * 8); +#endif + break; + case BPF_FIELD_RSHIFT_U64: + *val = 64 - bit_sz; + if (validate) + *validate = true; /* right shift is never ambiguous */ + break; + case BPF_FIELD_EXISTS: + default: + return -EOPNOTSUPP; + } + + return 0; +} + +static int bpf_core_calc_type_relo(const struct bpf_core_relo *relo, + const struct bpf_core_spec *spec, + __u32 *val) +{ + __s64 sz; + + /* type-based relos return zero when target type is not found */ + if (!spec) { + *val = 0; + return 0; + } + + switch (relo->kind) { + case BPF_TYPE_ID_TARGET: + *val = spec->root_type_id; + break; + case BPF_TYPE_EXISTS: + *val = 1; + break; + case BPF_TYPE_SIZE: + sz = btf__resolve_size(spec->btf, spec->root_type_id); + if (sz < 0) + return -EINVAL; + *val = sz; + break; + case BPF_TYPE_ID_LOCAL: + /* BPF_TYPE_ID_LOCAL is handled specially and shouldn't get here */ + default: + return -EOPNOTSUPP; + } + + return 0; +} + +static int bpf_core_calc_enumval_relo(const struct bpf_core_relo *relo, + const struct bpf_core_spec *spec, + __u32 *val) +{ + const struct btf_type *t; + const struct btf_enum *e; + + switch (relo->kind) { + case BPF_ENUMVAL_EXISTS: + *val = spec ? 1 : 0; + break; + case BPF_ENUMVAL_VALUE: + if (!spec) + return -EUCLEAN; /* request instruction poisoning */ + t = btf__type_by_id(spec->btf, spec->spec[0].type_id); + e = btf_enum(t) + spec->spec[0].idx; + *val = e->val; + break; + default: + return -EOPNOTSUPP; + } + + return 0; +} + +struct bpf_core_relo_res +{ + /* expected value in the instruction, unless validate == false */ + __u32 orig_val; + /* new value that needs to be patched up to */ + __u32 new_val; + /* relocation unsuccessful, poison instruction, but don't fail load */ + bool poison; + /* some relocations can't be validated against orig_val */ + bool validate; + /* for field byte offset relocations or the forms: + * *(T *)(rX + ) = rY + * rX = *(T *)(rY + ), + * we remember original and resolved field size to adjust direct + * memory loads of pointers and integers; this is necessary for 32-bit + * host kernel architectures, but also allows to automatically + * relocate fields that were resized from, e.g., u32 to u64, etc. + */ + bool fail_memsz_adjust; + __u32 orig_sz; + __u32 orig_type_id; + __u32 new_sz; + __u32 new_type_id; +}; + +/* Calculate original and target relocation values, given local and target + * specs and relocation kind. These values are calculated for each candidate. + * If there are multiple candidates, resulting values should all be consistent + * with each other. Otherwise, libbpf will refuse to proceed due to ambiguity. + * If instruction has to be poisoned, *poison will be set to true. + */ +static int bpf_core_calc_relo(const struct bpf_program *prog, + const struct bpf_core_relo *relo, + int relo_idx, + const struct bpf_core_spec *local_spec, + const struct bpf_core_spec *targ_spec, + struct bpf_core_relo_res *res) +{ + int err = -EOPNOTSUPP; + + res->orig_val = 0; + res->new_val = 0; + res->poison = false; + res->validate = true; + res->fail_memsz_adjust = false; + res->orig_sz = res->new_sz = 0; + res->orig_type_id = res->new_type_id = 0; + + if (core_relo_is_field_based(relo->kind)) { + err = bpf_core_calc_field_relo(prog, relo, local_spec, + &res->orig_val, &res->orig_sz, + &res->orig_type_id, &res->validate); + err = err ?: bpf_core_calc_field_relo(prog, relo, targ_spec, + &res->new_val, &res->new_sz, + &res->new_type_id, NULL); + if (err) + goto done; + /* Validate if it's safe to adjust load/store memory size. + * Adjustments are performed only if original and new memory + * sizes differ. + */ + res->fail_memsz_adjust = false; + if (res->orig_sz != res->new_sz) { + const struct btf_type *orig_t, *new_t; + + orig_t = btf__type_by_id(local_spec->btf, res->orig_type_id); + new_t = btf__type_by_id(targ_spec->btf, res->new_type_id); + + /* There are two use cases in which it's safe to + * adjust load/store's mem size: + * - reading a 32-bit kernel pointer, while on BPF + * size pointers are always 64-bit; in this case + * it's safe to "downsize" instruction size due to + * pointer being treated as unsigned integer with + * zero-extended upper 32-bits; + * - reading unsigned integers, again due to + * zero-extension is preserving the value correctly. + * + * In all other cases it's incorrect to attempt to + * load/store field because read value will be + * incorrect, so we poison relocated instruction. + */ + if (btf_is_ptr(orig_t) && btf_is_ptr(new_t)) + goto done; + if (btf_is_int(orig_t) && btf_is_int(new_t) && + btf_int_encoding(orig_t) != BTF_INT_SIGNED && + btf_int_encoding(new_t) != BTF_INT_SIGNED) + goto done; + + /* mark as invalid mem size adjustment, but this will + * only be checked for LDX/STX/ST insns + */ + res->fail_memsz_adjust = true; + } + } else if (core_relo_is_type_based(relo->kind)) { + err = bpf_core_calc_type_relo(relo, local_spec, &res->orig_val); + err = err ?: bpf_core_calc_type_relo(relo, targ_spec, &res->new_val); + } else if (core_relo_is_enumval_based(relo->kind)) { + err = bpf_core_calc_enumval_relo(relo, local_spec, &res->orig_val); + err = err ?: bpf_core_calc_enumval_relo(relo, targ_spec, &res->new_val); + } + +done: + if (err == -EUCLEAN) { + /* EUCLEAN is used to signal instruction poisoning request */ + res->poison = true; + err = 0; + } else if (err == -EOPNOTSUPP) { + /* EOPNOTSUPP means unknown/unsupported relocation */ + pr_warn("prog '%s': relo #%d: unrecognized CO-RE relocation %s (%d) at insn #%d\n", + prog->name, relo_idx, core_relo_kind_str(relo->kind), + relo->kind, relo->insn_off / 8); + } + + return err; +} + +/* + * Turn instruction for which CO_RE relocation failed into invalid one with + * distinct signature. + */ +static void bpf_core_poison_insn(struct bpf_program *prog, int relo_idx, + int insn_idx, struct bpf_insn *insn) +{ + pr_debug("prog '%s': relo #%d: substituting insn #%d w/ invalid insn\n", + prog->name, relo_idx, insn_idx); + insn->code = BPF_JMP | BPF_CALL; + insn->dst_reg = 0; + insn->src_reg = 0; + insn->off = 0; + /* if this instruction is reachable (not a dead code), + * verifier will complain with the following message: + * invalid func unknown#195896080 + */ + insn->imm = 195896080; /* => 0xbad2310 => "bad relo" */ +} + +static int insn_bpf_size_to_bytes(struct bpf_insn *insn) +{ + switch (BPF_SIZE(insn->code)) { + case BPF_DW: return 8; + case BPF_W: return 4; + case BPF_H: return 2; + case BPF_B: return 1; + default: return -1; + } +} + +static int insn_bytes_to_bpf_size(__u32 sz) +{ + switch (sz) { + case 8: return BPF_DW; + case 4: return BPF_W; + case 2: return BPF_H; + case 1: return BPF_B; + default: return -1; + } +} + +/* + * Patch relocatable BPF instruction. + * + * Patched value is determined by relocation kind and target specification. + * For existence relocations target spec will be NULL if field/type is not found. + * Expected insn->imm value is determined using relocation kind and local + * spec, and is checked before patching instruction. If actual insn->imm value + * is wrong, bail out with error. + * + * Currently supported classes of BPF instruction are: + * 1. rX = (assignment with immediate operand); + * 2. rX += (arithmetic operations with immediate operand); + * 3. rX = (load with 64-bit immediate value); + * 4. rX = *(T *)(rY + ), where T is one of {u8, u16, u32, u64}; + * 5. *(T *)(rX + ) = rY, where T is one of {u8, u16, u32, u64}; + * 6. *(T *)(rX + ) = , where T is one of {u8, u16, u32, u64}. + */ +static int bpf_core_patch_insn(struct bpf_program *prog, + const struct bpf_core_relo *relo, + int relo_idx, + const struct bpf_core_relo_res *res) +{ + __u32 orig_val, new_val; + struct bpf_insn *insn; + int insn_idx; + __u8 class; + + if (relo->insn_off % BPF_INSN_SZ) + return -EINVAL; + insn_idx = relo->insn_off / BPF_INSN_SZ; + /* adjust insn_idx from section frame of reference to the local + * program's frame of reference; (sub-)program code is not yet + * relocated, so it's enough to just subtract in-section offset + */ + insn_idx = insn_idx - prog->sec_insn_off; + insn = &prog->insns[insn_idx]; + class = BPF_CLASS(insn->code); + + if (res->poison) { +poison: + /* poison second part of ldimm64 to avoid confusing error from + * verifier about "unknown opcode 00" + */ + if (is_ldimm64(insn)) + bpf_core_poison_insn(prog, relo_idx, insn_idx + 1, insn + 1); + bpf_core_poison_insn(prog, relo_idx, insn_idx, insn); + return 0; + } + + orig_val = res->orig_val; + new_val = res->new_val; + + switch (class) { + case BPF_ALU: + case BPF_ALU64: + if (BPF_SRC(insn->code) != BPF_K) + return -EINVAL; + if (res->validate && insn->imm != orig_val) { + pr_warn("prog '%s': relo #%d: unexpected insn #%d (ALU/ALU64) value: got %u, exp %u -> %u\n", + prog->name, relo_idx, + insn_idx, insn->imm, orig_val, new_val); + return -EINVAL; + } + orig_val = insn->imm; + insn->imm = new_val; + pr_debug("prog '%s': relo #%d: patched insn #%d (ALU/ALU64) imm %u -> %u\n", + prog->name, relo_idx, insn_idx, + orig_val, new_val); + break; + case BPF_LDX: + case BPF_ST: + case BPF_STX: + if (res->validate && insn->off != orig_val) { + pr_warn("prog '%s': relo #%d: unexpected insn #%d (LDX/ST/STX) value: got %u, exp %u -> %u\n", + prog->name, relo_idx, insn_idx, insn->off, orig_val, new_val); + return -EINVAL; + } + if (new_val > SHRT_MAX) { + pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) value too big: %u\n", + prog->name, relo_idx, insn_idx, new_val); + return -ERANGE; + } + if (res->fail_memsz_adjust) { + pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) accesses field incorrectly. " + "Make sure you are accessing pointers, unsigned integers, or fields of matching type and size.\n", + prog->name, relo_idx, insn_idx); + goto poison; + } + + orig_val = insn->off; + insn->off = new_val; + pr_debug("prog '%s': relo #%d: patched insn #%d (LDX/ST/STX) off %u -> %u\n", + prog->name, relo_idx, insn_idx, orig_val, new_val); + + if (res->new_sz != res->orig_sz) { + int insn_bytes_sz, insn_bpf_sz; + + insn_bytes_sz = insn_bpf_size_to_bytes(insn); + if (insn_bytes_sz != res->orig_sz) { + pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) unexpected mem size: got %d, exp %u\n", + prog->name, relo_idx, insn_idx, insn_bytes_sz, res->orig_sz); + return -EINVAL; + } + + insn_bpf_sz = insn_bytes_to_bpf_size(res->new_sz); + if (insn_bpf_sz < 0) { + pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) invalid new mem size: %u\n", + prog->name, relo_idx, insn_idx, res->new_sz); + return -EINVAL; + } + + insn->code = BPF_MODE(insn->code) | insn_bpf_sz | BPF_CLASS(insn->code); + pr_debug("prog '%s': relo #%d: patched insn #%d (LDX/ST/STX) mem_sz %u -> %u\n", + prog->name, relo_idx, insn_idx, res->orig_sz, res->new_sz); + } + break; + case BPF_LD: { + __u64 imm; + + if (!is_ldimm64(insn) || + insn[0].src_reg != 0 || insn[0].off != 0 || + insn_idx + 1 >= prog->insns_cnt || + insn[1].code != 0 || insn[1].dst_reg != 0 || + insn[1].src_reg != 0 || insn[1].off != 0) { + pr_warn("prog '%s': relo #%d: insn #%d (LDIMM64) has unexpected form\n", + prog->name, relo_idx, insn_idx); + return -EINVAL; + } + + imm = insn[0].imm + ((__u64)insn[1].imm << 32); + if (res->validate && imm != orig_val) { + pr_warn("prog '%s': relo #%d: unexpected insn #%d (LDIMM64) value: got %llu, exp %u -> %u\n", + prog->name, relo_idx, + insn_idx, (unsigned long long)imm, + orig_val, new_val); + return -EINVAL; + } + + insn[0].imm = new_val; + insn[1].imm = 0; /* currently only 32-bit values are supported */ + pr_debug("prog '%s': relo #%d: patched insn #%d (LDIMM64) imm64 %llu -> %u\n", + prog->name, relo_idx, insn_idx, + (unsigned long long)imm, new_val); + break; + } + default: + pr_warn("prog '%s': relo #%d: trying to relocate unrecognized insn #%d, code:0x%x, src:0x%x, dst:0x%x, off:0x%x, imm:0x%x\n", + prog->name, relo_idx, insn_idx, insn->code, + insn->src_reg, insn->dst_reg, insn->off, insn->imm); + return -EINVAL; + } + + return 0; +} + +/* Output spec definition in the format: + * [] () + => @, + * where is a C-syntax view of recorded field access, e.g.: x.a[3].b + */ +static void bpf_core_dump_spec(int level, const struct bpf_core_spec *spec) +{ + const struct btf_type *t; + const struct btf_enum *e; + const char *s; + __u32 type_id; + int i; + + type_id = spec->root_type_id; + t = btf__type_by_id(spec->btf, type_id); + s = btf__name_by_offset(spec->btf, t->name_off); + + libbpf_print(level, "[%u] %s %s", type_id, btf_kind_str(t), str_is_empty(s) ? "" : s); + + if (core_relo_is_type_based(spec->relo_kind)) + return; + + if (core_relo_is_enumval_based(spec->relo_kind)) { + t = skip_mods_and_typedefs(spec->btf, type_id, NULL); + e = btf_enum(t) + spec->raw_spec[0]; + s = btf__name_by_offset(spec->btf, e->name_off); + + libbpf_print(level, "::%s = %u", s, e->val); + return; + } + + if (core_relo_is_field_based(spec->relo_kind)) { + for (i = 0; i < spec->len; i++) { + if (spec->spec[i].name) + libbpf_print(level, ".%s", spec->spec[i].name); + else if (i > 0 || spec->spec[i].idx > 0) + libbpf_print(level, "[%u]", spec->spec[i].idx); + } + + libbpf_print(level, " ("); + for (i = 0; i < spec->raw_len; i++) + libbpf_print(level, "%s%d", i == 0 ? "" : ":", spec->raw_spec[i]); + + if (spec->bit_offset % 8) + libbpf_print(level, " @ offset %u.%u)", + spec->bit_offset / 8, spec->bit_offset % 8); + else + libbpf_print(level, " @ offset %u)", spec->bit_offset / 8); + return; + } +} + +static size_t bpf_core_hash_fn(const void *key, void *ctx) +{ + return (size_t)key; +} + +static bool bpf_core_equal_fn(const void *k1, const void *k2, void *ctx) +{ + return k1 == k2; +} + +static void *u32_as_hash_key(__u32 x) +{ + return (void *)(uintptr_t)x; +} + +/* + * CO-RE relocate single instruction. + * + * The outline and important points of the algorithm: + * 1. For given local type, find corresponding candidate target types. + * Candidate type is a type with the same "essential" name, ignoring + * everything after last triple underscore (___). E.g., `sample`, + * `sample___flavor_one`, `sample___flavor_another_one`, are all candidates + * for each other. Names with triple underscore are referred to as + * "flavors" and are useful, among other things, to allow to + * specify/support incompatible variations of the same kernel struct, which + * might differ between different kernel versions and/or build + * configurations. + * + * N.B. Struct "flavors" could be generated by bpftool's BTF-to-C + * converter, when deduplicated BTF of a kernel still contains more than + * one different types with the same name. In that case, ___2, ___3, etc + * are appended starting from second name conflict. But start flavors are + * also useful to be defined "locally", in BPF program, to extract same + * data from incompatible changes between different kernel + * versions/configurations. For instance, to handle field renames between + * kernel versions, one can use two flavors of the struct name with the + * same common name and use conditional relocations to extract that field, + * depending on target kernel version. + * 2. For each candidate type, try to match local specification to this + * candidate target type. Matching involves finding corresponding + * high-level spec accessors, meaning that all named fields should match, + * as well as all array accesses should be within the actual bounds. Also, + * types should be compatible (see bpf_core_fields_are_compat for details). + * 3. It is supported and expected that there might be multiple flavors + * matching the spec. As long as all the specs resolve to the same set of + * offsets across all candidates, there is no error. If there is any + * ambiguity, CO-RE relocation will fail. This is necessary to accomodate + * imprefection of BTF deduplication, which can cause slight duplication of + * the same BTF type, if some directly or indirectly referenced (by + * pointer) type gets resolved to different actual types in different + * object files. If such situation occurs, deduplicated BTF will end up + * with two (or more) structurally identical types, which differ only in + * types they refer to through pointer. This should be OK in most cases and + * is not an error. + * 4. Candidate types search is performed by linearly scanning through all + * types in target BTF. It is anticipated that this is overall more + * efficient memory-wise and not significantly worse (if not better) + * CPU-wise compared to prebuilding a map from all local type names to + * a list of candidate type names. It's also sped up by caching resolved + * list of matching candidates per each local "root" type ID, that has at + * least one bpf_core_relo associated with it. This list is shared + * between multiple relocations for the same type ID and is updated as some + * of the candidates are pruned due to structural incompatibility. + */ +static int bpf_core_apply_relo(struct bpf_program *prog, + const struct bpf_core_relo *relo, + int relo_idx, + const struct btf *local_btf, + struct hashmap *cand_cache) +{ + struct bpf_core_spec local_spec, cand_spec, targ_spec = {}; + const void *type_key = u32_as_hash_key(relo->type_id); + struct bpf_core_relo_res cand_res, targ_res; + const struct btf_type *local_type; + const char *local_name; + struct core_cand_list *cands = NULL; + __u32 local_id; + const char *spec_str; + int i, j, err; + + local_id = relo->type_id; + local_type = btf__type_by_id(local_btf, local_id); + if (!local_type) + return -EINVAL; + + local_name = btf__name_by_offset(local_btf, local_type->name_off); + if (!local_name) + return -EINVAL; + + spec_str = btf__name_by_offset(local_btf, relo->access_str_off); + if (str_is_empty(spec_str)) + return -EINVAL; + + err = bpf_core_parse_spec(local_btf, local_id, spec_str, relo->kind, &local_spec); + if (err) { + pr_warn("prog '%s': relo #%d: parsing [%d] %s %s + %s failed: %d\n", + prog->name, relo_idx, local_id, btf_kind_str(local_type), + str_is_empty(local_name) ? "" : local_name, + spec_str, err); + return -EINVAL; + } + + pr_debug("prog '%s': relo #%d: kind <%s> (%d), spec is ", prog->name, + relo_idx, core_relo_kind_str(relo->kind), relo->kind); + bpf_core_dump_spec(LIBBPF_DEBUG, &local_spec); + libbpf_print(LIBBPF_DEBUG, "\n"); + + /* TYPE_ID_LOCAL relo is special and doesn't need candidate search */ + if (relo->kind == BPF_TYPE_ID_LOCAL) { + targ_res.validate = true; + targ_res.poison = false; + targ_res.orig_val = local_spec.root_type_id; + targ_res.new_val = local_spec.root_type_id; + goto patch_insn; + } + + /* libbpf doesn't support candidate search for anonymous types */ + if (str_is_empty(spec_str)) { + pr_warn("prog '%s': relo #%d: <%s> (%d) relocation doesn't support anonymous types\n", + prog->name, relo_idx, core_relo_kind_str(relo->kind), relo->kind); + return -EOPNOTSUPP; + } + + if (!hashmap__find(cand_cache, type_key, (void **)&cands)) { + cands = bpf_core_find_cands(prog->obj, local_btf, local_id); + if (IS_ERR(cands)) { + pr_warn("prog '%s': relo #%d: target candidate search failed for [%d] %s %s: %ld\n", + prog->name, relo_idx, local_id, btf_kind_str(local_type), + local_name, PTR_ERR(cands)); + return PTR_ERR(cands); + } + err = hashmap__set(cand_cache, type_key, cands, NULL, NULL); + if (err) { + bpf_core_free_cands(cands); + return err; + } + } + + for (i = 0, j = 0; i < cands->len; i++) { + err = bpf_core_spec_match(&local_spec, cands->cands[i].btf, + cands->cands[i].id, &cand_spec); + if (err < 0) { + pr_warn("prog '%s': relo #%d: error matching candidate #%d ", + prog->name, relo_idx, i); + bpf_core_dump_spec(LIBBPF_WARN, &cand_spec); + libbpf_print(LIBBPF_WARN, ": %d\n", err); + return err; + } + + pr_debug("prog '%s': relo #%d: %s candidate #%d ", prog->name, + relo_idx, err == 0 ? "non-matching" : "matching", i); + bpf_core_dump_spec(LIBBPF_DEBUG, &cand_spec); + libbpf_print(LIBBPF_DEBUG, "\n"); + + if (err == 0) + continue; + + err = bpf_core_calc_relo(prog, relo, relo_idx, &local_spec, &cand_spec, &cand_res); + if (err) + return err; + + if (j == 0) { + targ_res = cand_res; + targ_spec = cand_spec; + } else if (cand_spec.bit_offset != targ_spec.bit_offset) { + /* if there are many field relo candidates, they + * should all resolve to the same bit offset + */ + pr_warn("prog '%s': relo #%d: field offset ambiguity: %u != %u\n", + prog->name, relo_idx, cand_spec.bit_offset, + targ_spec.bit_offset); + return -EINVAL; + } else if (cand_res.poison != targ_res.poison || cand_res.new_val != targ_res.new_val) { + /* all candidates should result in the same relocation + * decision and value, otherwise it's dangerous to + * proceed due to ambiguity + */ + pr_warn("prog '%s': relo #%d: relocation decision ambiguity: %s %u != %s %u\n", + prog->name, relo_idx, + cand_res.poison ? "failure" : "success", cand_res.new_val, + targ_res.poison ? "failure" : "success", targ_res.new_val); + return -EINVAL; + } + + cands->cands[j++] = cands->cands[i]; + } + + /* + * For BPF_FIELD_EXISTS relo or when used BPF program has field + * existence checks or kernel version/config checks, it's expected + * that we might not find any candidates. In this case, if field + * wasn't found in any candidate, the list of candidates shouldn't + * change at all, we'll just handle relocating appropriately, + * depending on relo's kind. + */ + if (j > 0) + cands->len = j; + + /* + * If no candidates were found, it might be both a programmer error, + * as well as expected case, depending whether instruction w/ + * relocation is guarded in some way that makes it unreachable (dead + * code) if relocation can't be resolved. This is handled in + * bpf_core_patch_insn() uniformly by replacing that instruction with + * BPF helper call insn (using invalid helper ID). If that instruction + * is indeed unreachable, then it will be ignored and eliminated by + * verifier. If it was an error, then verifier will complain and point + * to a specific instruction number in its log. + */ + if (j == 0) { + pr_debug("prog '%s': relo #%d: no matching targets found\n", + prog->name, relo_idx); + + /* calculate single target relo result explicitly */ + err = bpf_core_calc_relo(prog, relo, relo_idx, &local_spec, NULL, &targ_res); + if (err) + return err; + } + +patch_insn: + /* bpf_core_patch_insn() should know how to handle missing targ_spec */ + err = bpf_core_patch_insn(prog, relo, relo_idx, &targ_res); + if (err) { + pr_warn("prog '%s': relo #%d: failed to patch insn at offset %d: %d\n", + prog->name, relo_idx, relo->insn_off, err); + return -EINVAL; + } + + return 0; +} + +static int +bpf_object__relocate_core(struct bpf_object *obj, const char *targ_btf_path) +{ + const struct btf_ext_info_sec *sec; + const struct bpf_core_relo *rec; + const struct btf_ext_info *seg; + struct hashmap_entry *entry; + struct hashmap *cand_cache = NULL; + struct bpf_program *prog; + const char *sec_name; + int i, err = 0, insn_idx, sec_idx; + + if (obj->btf_ext->core_relo_info.len == 0) + return 0; + + if (targ_btf_path) { + obj->btf_vmlinux_override = btf__parse(targ_btf_path, NULL); + if (IS_ERR_OR_NULL(obj->btf_vmlinux_override)) { + err = PTR_ERR(obj->btf_vmlinux_override); + pr_warn("failed to parse target BTF: %d\n", err); + return err; + } + } + + cand_cache = hashmap__new(bpf_core_hash_fn, bpf_core_equal_fn, NULL); + if (IS_ERR(cand_cache)) { + err = PTR_ERR(cand_cache); + goto out; + } + + seg = &obj->btf_ext->core_relo_info; + for_each_btf_ext_sec(seg, sec) { + sec_name = btf__name_by_offset(obj->btf, sec->sec_name_off); + if (str_is_empty(sec_name)) { + err = -EINVAL; + goto out; + } + /* bpf_object's ELF is gone by now so it's not easy to find + * section index by section name, but we can find *any* + * bpf_program within desired section name and use it's + * prog->sec_idx to do a proper search by section index and + * instruction offset + */ + prog = NULL; + for (i = 0; i < obj->nr_programs; i++) { + prog = &obj->programs[i]; + if (strcmp(prog->sec_name, sec_name) == 0) + break; + } + if (!prog) { + pr_warn("sec '%s': failed to find a BPF program\n", sec_name); + return -ENOENT; + } + sec_idx = prog->sec_idx; + + pr_debug("sec '%s': found %d CO-RE relocations\n", + sec_name, sec->num_info); + + for_each_btf_ext_rec(seg, sec, i, rec) { + insn_idx = rec->insn_off / BPF_INSN_SZ; + prog = find_prog_by_sec_insn(obj, sec_idx, insn_idx); + if (!prog) { + pr_warn("sec '%s': failed to find program at insn #%d for CO-RE offset relocation #%d\n", + sec_name, insn_idx, i); + err = -EINVAL; + goto out; + } + /* no need to apply CO-RE relocation if the program is + * not going to be loaded + */ + if (!prog->load) + continue; + + err = bpf_core_apply_relo(prog, rec, i, obj->btf, cand_cache); + if (err) { + pr_warn("prog '%s': relo #%d: failed to relocate: %d\n", + prog->name, i, err); + goto out; + } + } + } + +out: + /* obj->btf_vmlinux and module BTFs are freed after object load */ + btf__free(obj->btf_vmlinux_override); + obj->btf_vmlinux_override = NULL; + + if (!IS_ERR_OR_NULL(cand_cache)) { + hashmap__for_each_entry(cand_cache, entry, i) { + bpf_core_free_cands(entry->value); + } + hashmap__free(cand_cache); + } + return err; +} + +/* Relocate data references within program code: + * - map references; + * - global variable references; + * - extern references. + */ +static int +bpf_object__relocate_data(struct bpf_object *obj, struct bpf_program *prog) +{ + int i; + + for (i = 0; i < prog->nr_reloc; i++) { + struct reloc_desc *relo = &prog->reloc_desc[i]; + struct bpf_insn *insn = &prog->insns[relo->insn_idx]; + struct extern_desc *ext; + + switch (relo->type) { + case RELO_LD64: + insn[0].src_reg = BPF_PSEUDO_MAP_FD; + insn[0].imm = obj->maps[relo->map_idx].fd; + relo->processed = true; + break; + case RELO_DATA: + insn[0].src_reg = BPF_PSEUDO_MAP_VALUE; + insn[1].imm = insn[0].imm + relo->sym_off; + insn[0].imm = obj->maps[relo->map_idx].fd; + relo->processed = true; + break; + case RELO_EXTERN: + ext = &obj->externs[relo->sym_off]; + if (ext->type == EXT_KCFG) { + insn[0].src_reg = BPF_PSEUDO_MAP_VALUE; + insn[0].imm = obj->maps[obj->kconfig_map_idx].fd; + insn[1].imm = ext->kcfg.data_off; + } else /* EXT_KSYM */ { + if (ext->ksym.type_id) { /* typed ksyms */ + insn[0].src_reg = BPF_PSEUDO_BTF_ID; + insn[0].imm = ext->ksym.kernel_btf_id; + insn[1].imm = ext->ksym.kernel_btf_obj_fd; + } else { /* typeless ksyms */ + insn[0].imm = (__u32)ext->ksym.addr; + insn[1].imm = ext->ksym.addr >> 32; + } + } + relo->processed = true; + break; + case RELO_SUBPROG_ADDR: + insn[0].src_reg = BPF_PSEUDO_FUNC; + /* will be handled as a follow up pass */ + break; + case RELO_CALL: + /* will be handled as a follow up pass */ + break; + default: + pr_warn("prog '%s': relo #%d: bad relo type %d\n", + prog->name, i, relo->type); + return -EINVAL; + } + } + + return 0; +} + +static int adjust_prog_btf_ext_info(const struct bpf_object *obj, + const struct bpf_program *prog, + const struct btf_ext_info *ext_info, + void **prog_info, __u32 *prog_rec_cnt, + __u32 *prog_rec_sz) +{ + void *copy_start = NULL, *copy_end = NULL; + void *rec, *rec_end, *new_prog_info; + const struct btf_ext_info_sec *sec; + size_t old_sz, new_sz; + const char *sec_name; + int i, off_adj; + + for_each_btf_ext_sec(ext_info, sec) { + sec_name = btf__name_by_offset(obj->btf, sec->sec_name_off); + if (!sec_name) + return -EINVAL; + if (strcmp(sec_name, prog->sec_name) != 0) + continue; + + for_each_btf_ext_rec(ext_info, sec, i, rec) { + __u32 insn_off = *(__u32 *)rec / BPF_INSN_SZ; + + if (insn_off < prog->sec_insn_off) + continue; + if (insn_off >= prog->sec_insn_off + prog->sec_insn_cnt) + break; + + if (!copy_start) + copy_start = rec; + copy_end = rec + ext_info->rec_size; + } + + if (!copy_start) + return -ENOENT; + + /* append func/line info of a given (sub-)program to the main + * program func/line info + */ + old_sz = (size_t)(*prog_rec_cnt) * ext_info->rec_size; + new_sz = old_sz + (copy_end - copy_start); + new_prog_info = realloc(*prog_info, new_sz); + if (!new_prog_info) + return -ENOMEM; + *prog_info = new_prog_info; + *prog_rec_cnt = new_sz / ext_info->rec_size; + memcpy(new_prog_info + old_sz, copy_start, copy_end - copy_start); + + /* Kernel instruction offsets are in units of 8-byte + * instructions, while .BTF.ext instruction offsets generated + * by Clang are in units of bytes. So convert Clang offsets + * into kernel offsets and adjust offset according to program + * relocated position. + */ + off_adj = prog->sub_insn_off - prog->sec_insn_off; + rec = new_prog_info + old_sz; + rec_end = new_prog_info + new_sz; + for (; rec < rec_end; rec += ext_info->rec_size) { + __u32 *insn_off = rec; + + *insn_off = *insn_off / BPF_INSN_SZ + off_adj; + } + *prog_rec_sz = ext_info->rec_size; + return 0; + } + + return -ENOENT; +} + +static int +reloc_prog_func_and_line_info(const struct bpf_object *obj, + struct bpf_program *main_prog, + const struct bpf_program *prog) +{ + int err; + + /* no .BTF.ext relocation if .BTF.ext is missing or kernel doesn't + * supprot func/line info + */ + if (!obj->btf_ext || !kernel_supports(FEAT_BTF_FUNC)) + return 0; + + /* only attempt func info relocation if main program's func_info + * relocation was successful + */ + if (main_prog != prog && !main_prog->func_info) + goto line_info; + + err = adjust_prog_btf_ext_info(obj, prog, &obj->btf_ext->func_info, + &main_prog->func_info, + &main_prog->func_info_cnt, + &main_prog->func_info_rec_size); + if (err) { + if (err != -ENOENT) { + pr_warn("prog '%s': error relocating .BTF.ext function info: %d\n", + prog->name, err); + return err; + } + if (main_prog->func_info) { + /* + * Some info has already been found but has problem + * in the last btf_ext reloc. Must have to error out. + */ + pr_warn("prog '%s': missing .BTF.ext function info.\n", prog->name); + return err; + } + /* Have problem loading the very first info. Ignore the rest. */ + pr_warn("prog '%s': missing .BTF.ext function info for the main program, skipping all of .BTF.ext func info.\n", + prog->name); + } + +line_info: + /* don't relocate line info if main program's relocation failed */ + if (main_prog != prog && !main_prog->line_info) + return 0; + + err = adjust_prog_btf_ext_info(obj, prog, &obj->btf_ext->line_info, + &main_prog->line_info, + &main_prog->line_info_cnt, + &main_prog->line_info_rec_size); + if (err) { + if (err != -ENOENT) { + pr_warn("prog '%s': error relocating .BTF.ext line info: %d\n", + prog->name, err); + return err; + } + if (main_prog->line_info) { + /* + * Some info has already been found but has problem + * in the last btf_ext reloc. Must have to error out. + */ + pr_warn("prog '%s': missing .BTF.ext line info.\n", prog->name); + return err; + } + /* Have problem loading the very first info. Ignore the rest. */ + pr_warn("prog '%s': missing .BTF.ext line info for the main program, skipping all of .BTF.ext line info.\n", + prog->name); + } + return 0; +} + +static int cmp_relo_by_insn_idx(const void *key, const void *elem) +{ + size_t insn_idx = *(const size_t *)key; + const struct reloc_desc *relo = elem; + + if (insn_idx == relo->insn_idx) + return 0; + return insn_idx < relo->insn_idx ? -1 : 1; +} + +static struct reloc_desc *find_prog_insn_relo(const struct bpf_program *prog, size_t insn_idx) +{ + return bsearch(&insn_idx, prog->reloc_desc, prog->nr_reloc, + sizeof(*prog->reloc_desc), cmp_relo_by_insn_idx); +} + +static int +bpf_object__reloc_code(struct bpf_object *obj, struct bpf_program *main_prog, + struct bpf_program *prog) +{ + size_t sub_insn_idx, insn_idx, new_cnt; + struct bpf_program *subprog; + struct bpf_insn *insns, *insn; + struct reloc_desc *relo; + int err; + + err = reloc_prog_func_and_line_info(obj, main_prog, prog); + if (err) + return err; + + for (insn_idx = 0; insn_idx < prog->sec_insn_cnt; insn_idx++) { + insn = &main_prog->insns[prog->sub_insn_off + insn_idx]; + if (!insn_is_subprog_call(insn) && !insn_is_pseudo_func(insn)) + continue; + + relo = find_prog_insn_relo(prog, insn_idx); + if (relo && relo->type != RELO_CALL && relo->type != RELO_SUBPROG_ADDR) { + pr_warn("prog '%s': unexpected relo for insn #%zu, type %d\n", + prog->name, insn_idx, relo->type); + return -LIBBPF_ERRNO__RELOC; + } + if (relo) { + /* sub-program instruction index is a combination of + * an offset of a symbol pointed to by relocation and + * call instruction's imm field; for global functions, + * call always has imm = -1, but for static functions + * relocation is against STT_SECTION and insn->imm + * points to a start of a static function + * + * for subprog addr relocation, the relo->sym_off + insn->imm is + * the byte offset in the corresponding section. + */ + if (relo->type == RELO_CALL) + sub_insn_idx = relo->sym_off / BPF_INSN_SZ + insn->imm + 1; + else + sub_insn_idx = (relo->sym_off + insn->imm) / BPF_INSN_SZ; + } else if (insn_is_pseudo_func(insn)) { + /* + * RELO_SUBPROG_ADDR relo is always emitted even if both + * functions are in the same section, so it shouldn't reach here. + */ + pr_warn("prog '%s': missing subprog addr relo for insn #%zu\n", + prog->name, insn_idx); + return -LIBBPF_ERRNO__RELOC; + } else { + /* if subprogram call is to a static function within + * the same ELF section, there won't be any relocation + * emitted, but it also means there is no additional + * offset necessary, insns->imm is relative to + * instruction's original position within the section + */ + sub_insn_idx = prog->sec_insn_off + insn_idx + insn->imm + 1; + } + + /* we enforce that sub-programs should be in .text section */ + subprog = find_prog_by_sec_insn(obj, obj->efile.text_shndx, sub_insn_idx); + if (!subprog) { + pr_warn("prog '%s': no .text section found yet sub-program call exists\n", + prog->name); + return -LIBBPF_ERRNO__RELOC; + } + + /* if it's the first call instruction calling into this + * subprogram (meaning this subprog hasn't been processed + * yet) within the context of current main program: + * - append it at the end of main program's instructions blog; + * - process is recursively, while current program is put on hold; + * - if that subprogram calls some other not yet processes + * subprogram, same thing will happen recursively until + * there are no more unprocesses subprograms left to append + * and relocate. + */ + if (subprog->sub_insn_off == 0) { + subprog->sub_insn_off = main_prog->insns_cnt; + + new_cnt = main_prog->insns_cnt + subprog->insns_cnt; + insns = libbpf_reallocarray(main_prog->insns, new_cnt, sizeof(*insns)); + if (!insns) { + pr_warn("prog '%s': failed to realloc prog code\n", main_prog->name); + return -ENOMEM; + } + main_prog->insns = insns; + main_prog->insns_cnt = new_cnt; + + memcpy(main_prog->insns + subprog->sub_insn_off, subprog->insns, + subprog->insns_cnt * sizeof(*insns)); + + pr_debug("prog '%s': added %zu insns from sub-prog '%s'\n", + main_prog->name, subprog->insns_cnt, subprog->name); + + err = bpf_object__reloc_code(obj, main_prog, subprog); + if (err) + return err; + } + + /* main_prog->insns memory could have been re-allocated, so + * calculate pointer again + */ + insn = &main_prog->insns[prog->sub_insn_off + insn_idx]; + /* calculate correct instruction position within current main + * prog; each main prog can have a different set of + * subprograms appended (potentially in different order as + * well), so position of any subprog can be different for + * different main programs */ + insn->imm = subprog->sub_insn_off - (prog->sub_insn_off + insn_idx) - 1; + + if (relo) + relo->processed = true; + + pr_debug("prog '%s': insn #%zu relocated, imm %d points to subprog '%s' (now at %zu offset)\n", + prog->name, insn_idx, insn->imm, subprog->name, subprog->sub_insn_off); + } + + return 0; +} + +/* + * Relocate sub-program calls. + * + * Algorithm operates as follows. Each entry-point BPF program (referred to as + * main prog) is processed separately. For each subprog (non-entry functions, + * that can be called from either entry progs or other subprogs) gets their + * sub_insn_off reset to zero. This serves as indicator that this subprogram + * hasn't been yet appended and relocated within current main prog. Once its + * relocated, sub_insn_off will point at the position within current main prog + * where given subprog was appended. This will further be used to relocate all + * the call instructions jumping into this subprog. + * + * We start with main program and process all call instructions. If the call + * is into a subprog that hasn't been processed (i.e., subprog->sub_insn_off + * is zero), subprog instructions are appended at the end of main program's + * instruction array. Then main program is "put on hold" while we recursively + * process newly appended subprogram. If that subprogram calls into another + * subprogram that hasn't been appended, new subprogram is appended again to + * the *main* prog's instructions (subprog's instructions are always left + * untouched, as they need to be in unmodified state for subsequent main progs + * and subprog instructions are always sent only as part of a main prog) and + * the process continues recursively. Once all the subprogs called from a main + * prog or any of its subprogs are appended (and relocated), all their + * positions within finalized instructions array are known, so it's easy to + * rewrite call instructions with correct relative offsets, corresponding to + * desired target subprog. + * + * Its important to realize that some subprogs might not be called from some + * main prog and any of its called/used subprogs. Those will keep their + * subprog->sub_insn_off as zero at all times and won't be appended to current + * main prog and won't be relocated within the context of current main prog. + * They might still be used from other main progs later. + * + * Visually this process can be shown as below. Suppose we have two main + * programs mainA and mainB and BPF object contains three subprogs: subA, + * subB, and subC. mainA calls only subA, mainB calls only subC, but subA and + * subC both call subB: + * + * +--------+ +-------+ + * | v v | + * +--+---+ +--+-+-+ +---+--+ + * | subA | | subB | | subC | + * +--+---+ +------+ +---+--+ + * ^ ^ + * | | + * +---+-------+ +------+----+ + * | mainA | | mainB | + * +-----------+ +-----------+ + * + * We'll start relocating mainA, will find subA, append it and start + * processing sub A recursively: + * + * +-----------+------+ + * | mainA | subA | + * +-----------+------+ + * + * At this point we notice that subB is used from subA, so we append it and + * relocate (there are no further subcalls from subB): + * + * +-----------+------+------+ + * | mainA | subA | subB | + * +-----------+------+------+ + * + * At this point, we relocate subA calls, then go one level up and finish with + * relocatin mainA calls. mainA is done. + * + * For mainB process is similar but results in different order. We start with + * mainB and skip subA and subB, as mainB never calls them (at least + * directly), but we see subC is needed, so we append and start processing it: + * + * +-----------+------+ + * | mainB | subC | + * +-----------+------+ + * Now we see subC needs subB, so we go back to it, append and relocate it: + * + * +-----------+------+------+ + * | mainB | subC | subB | + * +-----------+------+------+ + * + * At this point we unwind recursion, relocate calls in subC, then in mainB. + */ +static int +bpf_object__relocate_calls(struct bpf_object *obj, struct bpf_program *prog) +{ + struct bpf_program *subprog; + int i, j, err; + + /* mark all subprogs as not relocated (yet) within the context of + * current main program + */ + for (i = 0; i < obj->nr_programs; i++) { + subprog = &obj->programs[i]; + if (!prog_is_subprog(obj, subprog)) + continue; + + subprog->sub_insn_off = 0; + for (j = 0; j < subprog->nr_reloc; j++) + if (subprog->reloc_desc[j].type == RELO_CALL) + subprog->reloc_desc[j].processed = false; + } + + err = bpf_object__reloc_code(obj, prog, prog); + if (err) + return err; + + + return 0; +} + +static int +bpf_object__relocate(struct bpf_object *obj, const char *targ_btf_path) +{ + struct bpf_program *prog; + size_t i; + int err; + + if (obj->btf_ext) { + err = bpf_object__relocate_core(obj, targ_btf_path); + if (err) { + pr_warn("failed to perform CO-RE relocations: %d\n", + err); + return err; + } + } + /* relocate data references first for all programs and sub-programs, + * as they don't change relative to code locations, so subsequent + * subprogram processing won't need to re-calculate any of them + */ + for (i = 0; i < obj->nr_programs; i++) { + prog = &obj->programs[i]; + err = bpf_object__relocate_data(obj, prog); + if (err) { + pr_warn("prog '%s': failed to relocate data references: %d\n", + prog->name, err); + return err; + } + } + /* now relocate subprogram calls and append used subprograms to main + * programs; each copy of subprogram code needs to be relocated + * differently for each main program, because its code location might + * have changed + */ + for (i = 0; i < obj->nr_programs; i++) { + prog = &obj->programs[i]; + /* sub-program's sub-calls are relocated within the context of + * its main program only + */ + if (prog_is_subprog(obj, prog)) + continue; + + err = bpf_object__relocate_calls(obj, prog); + if (err) { + pr_warn("prog '%s': failed to relocate calls: %d\n", + prog->name, err); + return err; + } + } + /* free up relocation descriptors */ + for (i = 0; i < obj->nr_programs; i++) { + prog = &obj->programs[i]; + zfree(&prog->reloc_desc); + prog->nr_reloc = 0; + } + return 0; +} + +static int bpf_object__collect_st_ops_relos(struct bpf_object *obj, + GElf_Shdr *shdr, Elf_Data *data); + +static int bpf_object__collect_map_relos(struct bpf_object *obj, + GElf_Shdr *shdr, Elf_Data *data) +{ + const int bpf_ptr_sz = 8, host_ptr_sz = sizeof(void *); + int i, j, nrels, new_sz; + const struct btf_var_secinfo *vi = NULL; + const struct btf_type *sec, *var, *def; + struct bpf_map *map = NULL, *targ_map; + const struct btf_member *member; + const char *name, *mname; + Elf_Data *symbols; + unsigned int moff; + GElf_Sym sym; + GElf_Rel rel; + void *tmp; + + if (!obj->efile.btf_maps_sec_btf_id || !obj->btf) + return -EINVAL; + sec = btf__type_by_id(obj->btf, obj->efile.btf_maps_sec_btf_id); + if (!sec) + return -EINVAL; + + symbols = obj->efile.symbols; + nrels = shdr->sh_size / shdr->sh_entsize; + for (i = 0; i < nrels; i++) { + if (!gelf_getrel(data, i, &rel)) { + pr_warn(".maps relo #%d: failed to get ELF relo\n", i); + return -LIBBPF_ERRNO__FORMAT; + } + if (!gelf_getsym(symbols, GELF_R_SYM(rel.r_info), &sym)) { + pr_warn(".maps relo #%d: symbol %zx not found\n", + i, (size_t)GELF_R_SYM(rel.r_info)); + return -LIBBPF_ERRNO__FORMAT; + } + name = elf_sym_str(obj, sym.st_name) ?: ""; + if (sym.st_shndx != obj->efile.btf_maps_shndx) { + pr_warn(".maps relo #%d: '%s' isn't a BTF-defined map\n", + i, name); + return -LIBBPF_ERRNO__RELOC; + } + + pr_debug(".maps relo #%d: for %zd value %zd rel.r_offset %zu name %d ('%s')\n", + i, (ssize_t)(rel.r_info >> 32), (size_t)sym.st_value, + (size_t)rel.r_offset, sym.st_name, name); + + for (j = 0; j < obj->nr_maps; j++) { + map = &obj->maps[j]; + if (map->sec_idx != obj->efile.btf_maps_shndx) + continue; + + vi = btf_var_secinfos(sec) + map->btf_var_idx; + if (vi->offset <= rel.r_offset && + rel.r_offset + bpf_ptr_sz <= vi->offset + vi->size) + break; + } + if (j == obj->nr_maps) { + pr_warn(".maps relo #%d: cannot find map '%s' at rel.r_offset %zu\n", + i, name, (size_t)rel.r_offset); + return -EINVAL; + } + + if (!bpf_map_type__is_map_in_map(map->def.type)) + return -EINVAL; + if (map->def.type == BPF_MAP_TYPE_HASH_OF_MAPS && + map->def.key_size != sizeof(int)) { + pr_warn(".maps relo #%d: hash-of-maps '%s' should have key size %zu.\n", + i, map->name, sizeof(int)); + return -EINVAL; + } + + targ_map = bpf_object__find_map_by_name(obj, name); + if (!targ_map) + return -ESRCH; + + var = btf__type_by_id(obj->btf, vi->type); + def = skip_mods_and_typedefs(obj->btf, var->type, NULL); + if (btf_vlen(def) == 0) + return -EINVAL; + member = btf_members(def) + btf_vlen(def) - 1; + mname = btf__name_by_offset(obj->btf, member->name_off); + if (strcmp(mname, "values")) + return -EINVAL; + + moff = btf_member_bit_offset(def, btf_vlen(def) - 1) / 8; + if (rel.r_offset - vi->offset < moff) + return -EINVAL; + + moff = rel.r_offset - vi->offset - moff; + /* here we use BPF pointer size, which is always 64 bit, as we + * are parsing ELF that was built for BPF target + */ + if (moff % bpf_ptr_sz) + return -EINVAL; + moff /= bpf_ptr_sz; + if (moff >= map->init_slots_sz) { + new_sz = moff + 1; + tmp = libbpf_reallocarray(map->init_slots, new_sz, host_ptr_sz); + if (!tmp) + return -ENOMEM; + map->init_slots = tmp; + memset(map->init_slots + map->init_slots_sz, 0, + (new_sz - map->init_slots_sz) * host_ptr_sz); + map->init_slots_sz = new_sz; + } + map->init_slots[moff] = targ_map; + + pr_debug(".maps relo #%d: map '%s' slot [%d] points to map '%s'\n", + i, map->name, moff, name); + } + + return 0; +} + +static int cmp_relocs(const void *_a, const void *_b) +{ + const struct reloc_desc *a = _a; + const struct reloc_desc *b = _b; + + if (a->insn_idx != b->insn_idx) + return a->insn_idx < b->insn_idx ? -1 : 1; + + /* no two relocations should have the same insn_idx, but ... */ + if (a->type != b->type) + return a->type < b->type ? -1 : 1; + + return 0; +} + +static int bpf_object__collect_relos(struct bpf_object *obj) +{ + int i, err; + + for (i = 0; i < obj->efile.nr_reloc_sects; i++) { + GElf_Shdr *shdr = &obj->efile.reloc_sects[i].shdr; + Elf_Data *data = obj->efile.reloc_sects[i].data; + int idx = shdr->sh_info; + + if (shdr->sh_type != SHT_REL) { + pr_warn("internal error at %d\n", __LINE__); + return -LIBBPF_ERRNO__INTERNAL; + } + + if (idx == obj->efile.st_ops_shndx) + err = bpf_object__collect_st_ops_relos(obj, shdr, data); + else if (idx == obj->efile.btf_maps_shndx) + err = bpf_object__collect_map_relos(obj, shdr, data); + else + err = bpf_object__collect_prog_relos(obj, shdr, data); + if (err) + return err; + } + + for (i = 0; i < obj->nr_programs; i++) { + struct bpf_program *p = &obj->programs[i]; + + if (!p->nr_reloc) + continue; + + qsort(p->reloc_desc, p->nr_reloc, sizeof(*p->reloc_desc), cmp_relocs); + } + return 0; +} + +static bool insn_is_helper_call(struct bpf_insn *insn, enum bpf_func_id *func_id) +{ + if (BPF_CLASS(insn->code) == BPF_JMP && + BPF_OP(insn->code) == BPF_CALL && + BPF_SRC(insn->code) == BPF_K && + insn->src_reg == 0 && + insn->dst_reg == 0) { + *func_id = insn->imm; + return true; + } + return false; +} + +static int bpf_object__sanitize_prog(struct bpf_object* obj, struct bpf_program *prog) +{ + struct bpf_insn *insn = prog->insns; + enum bpf_func_id func_id; + int i; + + for (i = 0; i < prog->insns_cnt; i++, insn++) { + if (!insn_is_helper_call(insn, &func_id)) + continue; + + /* on kernels that don't yet support + * bpf_probe_read_{kernel,user}[_str] helpers, fall back + * to bpf_probe_read() which works well for old kernels + */ + switch (func_id) { + case BPF_FUNC_probe_read_kernel: + case BPF_FUNC_probe_read_user: + if (!kernel_supports(FEAT_PROBE_READ_KERN)) + insn->imm = BPF_FUNC_probe_read; + break; + case BPF_FUNC_probe_read_kernel_str: + case BPF_FUNC_probe_read_user_str: + if (!kernel_supports(FEAT_PROBE_READ_KERN)) + insn->imm = BPF_FUNC_probe_read_str; + break; + default: + break; + } + } + return 0; +} + +static int +load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt, + char *license, __u32 kern_version, int *pfd) +{ + struct bpf_prog_load_params load_attr = {}; + char *cp, errmsg[STRERR_BUFSIZE]; + size_t log_buf_size = 0; + char *log_buf = NULL; + int btf_fd, ret; + + if (prog->type == BPF_PROG_TYPE_UNSPEC) { + /* + * The program type must be set. Most likely we couldn't find a proper + * section definition at load time, and thus we didn't infer the type. + */ + pr_warn("prog '%s': missing BPF prog type, check ELF section name '%s'\n", + prog->name, prog->sec_name); + return -EINVAL; + } + + if (!insns || !insns_cnt) + return -EINVAL; + + load_attr.prog_type = prog->type; + /* old kernels might not support specifying expected_attach_type */ + if (!kernel_supports(FEAT_EXP_ATTACH_TYPE) && prog->sec_def && + prog->sec_def->is_exp_attach_type_optional) + load_attr.expected_attach_type = 0; + else + load_attr.expected_attach_type = prog->expected_attach_type; + if (kernel_supports(FEAT_PROG_NAME)) + load_attr.name = prog->name; + load_attr.insns = insns; + load_attr.insn_cnt = insns_cnt; + load_attr.license = license; + load_attr.attach_btf_id = prog->attach_btf_id; + if (prog->attach_prog_fd) + load_attr.attach_prog_fd = prog->attach_prog_fd; + else + load_attr.attach_btf_obj_fd = prog->attach_btf_obj_fd; + load_attr.attach_btf_id = prog->attach_btf_id; + load_attr.kern_version = kern_version; + load_attr.prog_ifindex = prog->prog_ifindex; + + /* specify func_info/line_info only if kernel supports them */ + btf_fd = bpf_object__btf_fd(prog->obj); + if (btf_fd >= 0 && kernel_supports(FEAT_BTF_FUNC)) { + load_attr.prog_btf_fd = btf_fd; + load_attr.func_info = prog->func_info; + load_attr.func_info_rec_size = prog->func_info_rec_size; + load_attr.func_info_cnt = prog->func_info_cnt; + load_attr.line_info = prog->line_info; + load_attr.line_info_rec_size = prog->line_info_rec_size; + load_attr.line_info_cnt = prog->line_info_cnt; + } + load_attr.log_level = prog->log_level; + load_attr.prog_flags = prog->prog_flags; + +retry_load: + if (log_buf_size) { + log_buf = malloc(log_buf_size); + if (!log_buf) + return -ENOMEM; + + *log_buf = 0; + } + + load_attr.log_buf = log_buf; + load_attr.log_buf_sz = log_buf_size; + ret = libbpf__bpf_prog_load(&load_attr); + + if (ret >= 0) { + if (log_buf && load_attr.log_level) + pr_debug("verifier log:\n%s", log_buf); + + if (prog->obj->rodata_map_idx >= 0 && + kernel_supports(FEAT_PROG_BIND_MAP)) { + struct bpf_map *rodata_map = + &prog->obj->maps[prog->obj->rodata_map_idx]; + + if (bpf_prog_bind_map(ret, bpf_map__fd(rodata_map), NULL)) { + cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg)); + pr_warn("prog '%s': failed to bind .rodata map: %s\n", + prog->name, cp); + /* Don't fail hard if can't bind rodata. */ + } + } + + *pfd = ret; + ret = 0; + goto out; + } + + if (!log_buf || errno == ENOSPC) { + log_buf_size = max((size_t)BPF_LOG_BUF_SIZE, + log_buf_size << 1); + + free(log_buf); + goto retry_load; + } + ret = errno ? -errno : -LIBBPF_ERRNO__LOAD; + cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg)); + pr_warn("load bpf program failed: %s\n", cp); + pr_perm_msg(ret); + + if (log_buf && log_buf[0] != '\0') { + ret = -LIBBPF_ERRNO__VERIFY; + pr_warn("-- BEGIN DUMP LOG ---\n"); + pr_warn("\n%s\n", log_buf); + pr_warn("-- END LOG --\n"); + } else if (load_attr.insn_cnt >= BPF_MAXINSNS) { + pr_warn("Program too large (%zu insns), at most %d insns\n", + load_attr.insn_cnt, BPF_MAXINSNS); + ret = -LIBBPF_ERRNO__PROG2BIG; + } else if (load_attr.prog_type != BPF_PROG_TYPE_KPROBE) { + /* Wrong program type? */ + int fd; + + load_attr.prog_type = BPF_PROG_TYPE_KPROBE; + load_attr.expected_attach_type = 0; + load_attr.log_buf = NULL; + load_attr.log_buf_sz = 0; + fd = libbpf__bpf_prog_load(&load_attr); + if (fd >= 0) { + close(fd); + ret = -LIBBPF_ERRNO__PROGTYPE; + goto out; + } + } + +out: + free(log_buf); + return ret; +} + +static int libbpf_find_attach_btf_id(struct bpf_program *prog, int *btf_obj_fd, int *btf_type_id); + +int bpf_program__load(struct bpf_program *prog, char *license, __u32 kern_ver) +{ + int err = 0, fd, i; + + if (prog->obj->loaded) { + pr_warn("prog '%s': can't load after object was loaded\n", prog->name); + return -EINVAL; + } + + if ((prog->type == BPF_PROG_TYPE_TRACING || + prog->type == BPF_PROG_TYPE_LSM || + prog->type == BPF_PROG_TYPE_EXT) && !prog->attach_btf_id) { + int btf_obj_fd = 0, btf_type_id = 0; + + err = libbpf_find_attach_btf_id(prog, &btf_obj_fd, &btf_type_id); + if (err) + return err; + + prog->attach_btf_obj_fd = btf_obj_fd; + prog->attach_btf_id = btf_type_id; + } + + if (prog->instances.nr < 0 || !prog->instances.fds) { + if (prog->preprocessor) { + pr_warn("Internal error: can't load program '%s'\n", + prog->name); + return -LIBBPF_ERRNO__INTERNAL; + } + + prog->instances.fds = malloc(sizeof(int)); + if (!prog->instances.fds) { + pr_warn("Not enough memory for BPF fds\n"); + return -ENOMEM; + } + prog->instances.nr = 1; + prog->instances.fds[0] = -1; + } + + if (!prog->preprocessor) { + if (prog->instances.nr != 1) { + pr_warn("prog '%s': inconsistent nr(%d) != 1\n", + prog->name, prog->instances.nr); + } + err = load_program(prog, prog->insns, prog->insns_cnt, + license, kern_ver, &fd); + if (!err) + prog->instances.fds[0] = fd; + goto out; + } + + for (i = 0; i < prog->instances.nr; i++) { + struct bpf_prog_prep_result result; + bpf_program_prep_t preprocessor = prog->preprocessor; + + memset(&result, 0, sizeof(result)); + err = preprocessor(prog, i, prog->insns, + prog->insns_cnt, &result); + if (err) { + pr_warn("Preprocessing the %dth instance of program '%s' failed\n", + i, prog->name); + goto out; + } + + if (!result.new_insn_ptr || !result.new_insn_cnt) { + pr_debug("Skip loading the %dth instance of program '%s'\n", + i, prog->name); + prog->instances.fds[i] = -1; + if (result.pfd) + *result.pfd = -1; + continue; + } + + err = load_program(prog, result.new_insn_ptr, + result.new_insn_cnt, license, kern_ver, &fd); + if (err) { + pr_warn("Loading the %dth instance of program '%s' failed\n", + i, prog->name); + goto out; + } + + if (result.pfd) + *result.pfd = fd; + prog->instances.fds[i] = fd; + } +out: + if (err) + pr_warn("failed to load program '%s'\n", prog->name); + zfree(&prog->insns); + prog->insns_cnt = 0; + return err; +} + +static int +bpf_object__load_progs(struct bpf_object *obj, int log_level) +{ + struct bpf_program *prog; + size_t i; + int err; + + for (i = 0; i < obj->nr_programs; i++) { + prog = &obj->programs[i]; + err = bpf_object__sanitize_prog(obj, prog); + if (err) + return err; + } + + for (i = 0; i < obj->nr_programs; i++) { + prog = &obj->programs[i]; + if (prog_is_subprog(obj, prog)) + continue; + if (!prog->load) { + pr_debug("prog '%s': skipped loading\n", prog->name); + continue; + } + prog->log_level |= log_level; + err = bpf_program__load(prog, obj->license, obj->kern_version); + if (err) + return err; + } + return 0; +} + +static const struct bpf_sec_def *find_sec_def(const char *sec_name); + +static struct bpf_object * +__bpf_object__open(const char *path, const void *obj_buf, size_t obj_buf_sz, + const struct bpf_object_open_opts *opts) +{ + const char *obj_name, *kconfig; + struct bpf_program *prog; + struct bpf_object *obj; + char tmp_name[64]; + int err; + + if (elf_version(EV_CURRENT) == EV_NONE) { + pr_warn("failed to init libelf for %s\n", + path ? : "(mem buf)"); + return ERR_PTR(-LIBBPF_ERRNO__LIBELF); + } + + if (!OPTS_VALID(opts, bpf_object_open_opts)) + return ERR_PTR(-EINVAL); + + obj_name = OPTS_GET(opts, object_name, NULL); + if (obj_buf) { + if (!obj_name) { + snprintf(tmp_name, sizeof(tmp_name), "%lx-%lx", + (unsigned long)obj_buf, + (unsigned long)obj_buf_sz); + obj_name = tmp_name; + } + path = obj_name; + pr_debug("loading object '%s' from buffer\n", obj_name); + } + + obj = bpf_object__new(path, obj_buf, obj_buf_sz, obj_name); + if (IS_ERR(obj)) + return obj; + + kconfig = OPTS_GET(opts, kconfig, NULL); + if (kconfig) { + obj->kconfig = strdup(kconfig); + if (!obj->kconfig) + return ERR_PTR(-ENOMEM); + } + + err = bpf_object__elf_init(obj); + err = err ? : bpf_object__check_endianness(obj); + err = err ? : bpf_object__elf_collect(obj); + err = err ? : bpf_object__collect_externs(obj); + err = err ? : bpf_object__finalize_btf(obj); + err = err ? : bpf_object__init_maps(obj, opts); + err = err ? : bpf_object__collect_relos(obj); + if (err) + goto out; + bpf_object__elf_finish(obj); + + bpf_object__for_each_program(prog, obj) { + prog->sec_def = find_sec_def(prog->sec_name); + if (!prog->sec_def) { + /* couldn't guess, but user might manually specify */ + pr_debug("prog '%s': unrecognized ELF section name '%s'\n", + prog->name, prog->sec_name); + continue; + } + + if (prog->sec_def->is_sleepable) + prog->prog_flags |= BPF_F_SLEEPABLE; + bpf_program__set_type(prog, prog->sec_def->prog_type); + bpf_program__set_expected_attach_type(prog, + prog->sec_def->expected_attach_type); + + if (prog->sec_def->prog_type == BPF_PROG_TYPE_TRACING || + prog->sec_def->prog_type == BPF_PROG_TYPE_EXT) + prog->attach_prog_fd = OPTS_GET(opts, attach_prog_fd, 0); + } + + return obj; +out: + bpf_object__close(obj); + return ERR_PTR(err); +} + +static struct bpf_object * +__bpf_object__open_xattr(struct bpf_object_open_attr *attr, int flags) +{ + DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts, + .relaxed_maps = flags & MAPS_RELAX_COMPAT, + ); + + /* param validation */ + if (!attr->file) + return NULL; + + pr_debug("loading %s\n", attr->file); + return __bpf_object__open(attr->file, NULL, 0, &opts); +} + +struct bpf_object *bpf_object__open_xattr(struct bpf_object_open_attr *attr) +{ + return __bpf_object__open_xattr(attr, 0); +} + +struct bpf_object *bpf_object__open(const char *path) +{ + struct bpf_object_open_attr attr = { + .file = path, + .prog_type = BPF_PROG_TYPE_UNSPEC, + }; + + return bpf_object__open_xattr(&attr); +} + +struct bpf_object * +bpf_object__open_file(const char *path, const struct bpf_object_open_opts *opts) +{ + if (!path) + return ERR_PTR(-EINVAL); + + pr_debug("loading %s\n", path); + + return __bpf_object__open(path, NULL, 0, opts); +} + +struct bpf_object * +bpf_object__open_mem(const void *obj_buf, size_t obj_buf_sz, + const struct bpf_object_open_opts *opts) +{ + if (!obj_buf || obj_buf_sz == 0) + return ERR_PTR(-EINVAL); + + return __bpf_object__open(NULL, obj_buf, obj_buf_sz, opts); +} + +struct bpf_object * +bpf_object__open_buffer(const void *obj_buf, size_t obj_buf_sz, + const char *name) +{ + DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts, + .object_name = name, + /* wrong default, but backwards-compatible */ + .relaxed_maps = true, + ); + + /* returning NULL is wrong, but backwards-compatible */ + if (!obj_buf || obj_buf_sz == 0) + return NULL; + + return bpf_object__open_mem(obj_buf, obj_buf_sz, &opts); +} + +int bpf_object__unload(struct bpf_object *obj) +{ + size_t i; + + if (!obj) + return -EINVAL; + + for (i = 0; i < obj->nr_maps; i++) { + zclose(obj->maps[i].fd); + if (obj->maps[i].st_ops) + zfree(&obj->maps[i].st_ops->kern_vdata); + } + + for (i = 0; i < obj->nr_programs; i++) + bpf_program__unload(&obj->programs[i]); + + return 0; +} + +static int bpf_object__sanitize_maps(struct bpf_object *obj) +{ + struct bpf_map *m; + + bpf_object__for_each_map(m, obj) { + if (!bpf_map__is_internal(m)) + continue; + if (!kernel_supports(FEAT_GLOBAL_DATA)) { + pr_warn("kernel doesn't support global data\n"); + return -ENOTSUP; + } + if (!kernel_supports(FEAT_ARRAY_MMAP)) + m->def.map_flags ^= BPF_F_MMAPABLE; + } + + return 0; +} + +static int bpf_object__read_kallsyms_file(struct bpf_object *obj) +{ + char sym_type, sym_name[500]; + unsigned long long sym_addr; + struct extern_desc *ext; + int ret, err = 0; + FILE *f; + + f = fopen("/proc/kallsyms", "r"); + if (!f) { + err = -errno; + pr_warn("failed to open /proc/kallsyms: %d\n", err); + return err; + } + + while (true) { + ret = fscanf(f, "%llx %c %499s%*[^\n]\n", + &sym_addr, &sym_type, sym_name); + if (ret == EOF && feof(f)) + break; + if (ret != 3) { + pr_warn("failed to read kallsyms entry: %d\n", ret); + err = -EINVAL; + goto out; + } + + ext = find_extern_by_name(obj, sym_name); + if (!ext || ext->type != EXT_KSYM) + continue; + + if (ext->is_set && ext->ksym.addr != sym_addr) { + pr_warn("extern (ksym) '%s' resolution is ambiguous: 0x%llx or 0x%llx\n", + sym_name, ext->ksym.addr, sym_addr); + err = -EINVAL; + goto out; + } + if (!ext->is_set) { + ext->is_set = true; + ext->ksym.addr = sym_addr; + pr_debug("extern (ksym) %s=0x%llx\n", sym_name, sym_addr); + } + } + +out: + fclose(f); + return err; +} + +static int bpf_object__resolve_ksyms_btf_id(struct bpf_object *obj) +{ + struct extern_desc *ext; + struct btf *btf; + int i, j, id, btf_fd, err; + + for (i = 0; i < obj->nr_extern; i++) { + const struct btf_type *targ_var, *targ_type; + __u32 targ_type_id, local_type_id; + const char *targ_var_name; + int ret; + + ext = &obj->externs[i]; + if (ext->type != EXT_KSYM || !ext->ksym.type_id) + continue; + + btf = obj->btf_vmlinux; + btf_fd = 0; + id = btf__find_by_name_kind(btf, ext->name, BTF_KIND_VAR); + if (id == -ENOENT) { + err = load_module_btfs(obj); + if (err) + return err; + + for (j = 0; j < obj->btf_module_cnt; j++) { + btf = obj->btf_modules[j].btf; + /* we assume module BTF FD is always >0 */ + btf_fd = obj->btf_modules[j].fd; + id = btf__find_by_name_kind(btf, ext->name, BTF_KIND_VAR); + if (id != -ENOENT) + break; + } + } + if (id <= 0) { + pr_warn("extern (ksym) '%s': failed to find BTF ID in kernel BTF(s).\n", + ext->name); + return -ESRCH; + } + + /* find local type_id */ + local_type_id = ext->ksym.type_id; + + /* find target type_id */ + targ_var = btf__type_by_id(btf, id); + targ_var_name = btf__name_by_offset(btf, targ_var->name_off); + targ_type = skip_mods_and_typedefs(btf, targ_var->type, &targ_type_id); + + ret = bpf_core_types_are_compat(obj->btf, local_type_id, + btf, targ_type_id); + if (ret <= 0) { + const struct btf_type *local_type; + const char *targ_name, *local_name; + + local_type = btf__type_by_id(obj->btf, local_type_id); + local_name = btf__name_by_offset(obj->btf, local_type->name_off); + targ_name = btf__name_by_offset(btf, targ_type->name_off); + + pr_warn("extern (ksym) '%s': incompatible types, expected [%d] %s %s, but kernel has [%d] %s %s\n", + ext->name, local_type_id, + btf_kind_str(local_type), local_name, targ_type_id, + btf_kind_str(targ_type), targ_name); + return -EINVAL; + } + + ext->is_set = true; + ext->ksym.kernel_btf_obj_fd = btf_fd; + ext->ksym.kernel_btf_id = id; + pr_debug("extern (ksym) '%s': resolved to [%d] %s %s\n", + ext->name, id, btf_kind_str(targ_var), targ_var_name); + } + return 0; +} + +static int bpf_object__resolve_externs(struct bpf_object *obj, + const char *extra_kconfig) +{ + bool need_config = false, need_kallsyms = false; + bool need_vmlinux_btf = false; + struct extern_desc *ext; + void *kcfg_data = NULL; + int err, i; + + if (obj->nr_extern == 0) + return 0; + + if (obj->kconfig_map_idx >= 0) + kcfg_data = obj->maps[obj->kconfig_map_idx].mmaped; + + for (i = 0; i < obj->nr_extern; i++) { + ext = &obj->externs[i]; + + if (ext->type == EXT_KCFG && + strcmp(ext->name, "LINUX_KERNEL_VERSION") == 0) { + void *ext_val = kcfg_data + ext->kcfg.data_off; + __u32 kver = get_kernel_version(); + + if (!kver) { + pr_warn("failed to get kernel version\n"); + return -EINVAL; + } + err = set_kcfg_value_num(ext, ext_val, kver); + if (err) + return err; + pr_debug("extern (kcfg) %s=0x%x\n", ext->name, kver); + } else if (ext->type == EXT_KCFG && + strncmp(ext->name, "CONFIG_", 7) == 0) { + need_config = true; + } else if (ext->type == EXT_KSYM) { + if (ext->ksym.type_id) + need_vmlinux_btf = true; + else + need_kallsyms = true; + } else { + pr_warn("unrecognized extern '%s'\n", ext->name); + return -EINVAL; + } + } + if (need_config && extra_kconfig) { + err = bpf_object__read_kconfig_mem(obj, extra_kconfig, kcfg_data); + if (err) + return -EINVAL; + need_config = false; + for (i = 0; i < obj->nr_extern; i++) { + ext = &obj->externs[i]; + if (ext->type == EXT_KCFG && !ext->is_set) { + need_config = true; + break; + } + } + } + if (need_config) { + err = bpf_object__read_kconfig_file(obj, kcfg_data); + if (err) + return -EINVAL; + } + if (need_kallsyms) { + err = bpf_object__read_kallsyms_file(obj); + if (err) + return -EINVAL; + } + if (need_vmlinux_btf) { + err = bpf_object__resolve_ksyms_btf_id(obj); + if (err) + return -EINVAL; + } + for (i = 0; i < obj->nr_extern; i++) { + ext = &obj->externs[i]; + + if (!ext->is_set && !ext->is_weak) { + pr_warn("extern %s (strong) not resolved\n", ext->name); + return -ESRCH; + } else if (!ext->is_set) { + pr_debug("extern %s (weak) not resolved, defaulting to zero\n", + ext->name); + } + } + + return 0; +} + +int bpf_object__load_xattr(struct bpf_object_load_attr *attr) +{ + struct bpf_object *obj; + int err, i; + + if (!attr) + return -EINVAL; + obj = attr->obj; + if (!obj) + return -EINVAL; + + if (obj->loaded) { + pr_warn("object '%s': load can't be attempted twice\n", obj->name); + return -EINVAL; + } + + err = bpf_object__probe_loading(obj); + err = err ? : bpf_object__load_vmlinux_btf(obj, false); + err = err ? : bpf_object__resolve_externs(obj, obj->kconfig); + err = err ? : bpf_object__sanitize_and_load_btf(obj); + err = err ? : bpf_object__sanitize_maps(obj); + err = err ? : bpf_object__init_kern_struct_ops_maps(obj); + err = err ? : bpf_object__create_maps(obj); + err = err ? : bpf_object__relocate(obj, attr->target_btf_path); + err = err ? : bpf_object__load_progs(obj, attr->log_level); + + /* clean up module BTFs */ + for (i = 0; i < obj->btf_module_cnt; i++) { + close(obj->btf_modules[i].fd); + btf__free(obj->btf_modules[i].btf); + free(obj->btf_modules[i].name); + } + free(obj->btf_modules); + + /* clean up vmlinux BTF */ + btf__free(obj->btf_vmlinux); + obj->btf_vmlinux = NULL; + + obj->loaded = true; /* doesn't matter if successfully or not */ + + if (err) + goto out; + + return 0; +out: + /* unpin any maps that were auto-pinned during load */ + for (i = 0; i < obj->nr_maps; i++) + if (obj->maps[i].pinned && !obj->maps[i].reused) + bpf_map__unpin(&obj->maps[i], NULL); + + bpf_object__unload(obj); + pr_warn("failed to load object '%s'\n", obj->path); + return err; +} + +int bpf_object__load(struct bpf_object *obj) +{ + struct bpf_object_load_attr attr = { + .obj = obj, + }; + + return bpf_object__load_xattr(&attr); +} + +static int make_parent_dir(const char *path) +{ + char *cp, errmsg[STRERR_BUFSIZE]; + char *dname, *dir; + int err = 0; + + dname = strdup(path); + if (dname == NULL) + return -ENOMEM; + + dir = dirname(dname); + if (mkdir(dir, 0700) && errno != EEXIST) + err = -errno; + + free(dname); + if (err) { + cp = libbpf_strerror_r(-err, errmsg, sizeof(errmsg)); + pr_warn("failed to mkdir %s: %s\n", path, cp); + } + return err; +} + +static int check_path(const char *path) +{ + char *cp, errmsg[STRERR_BUFSIZE]; + struct statfs st_fs; + char *dname, *dir; + int err = 0; + + if (path == NULL) + return -EINVAL; + + dname = strdup(path); + if (dname == NULL) + return -ENOMEM; + + dir = dirname(dname); + if (statfs(dir, &st_fs)) { + cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg)); + pr_warn("failed to statfs %s: %s\n", dir, cp); + err = -errno; + } + free(dname); + + if (!err && st_fs.f_type != BPF_FS_MAGIC) { + pr_warn("specified path %s is not on BPF FS\n", path); + err = -EINVAL; + } + + return err; +} + +int bpf_program__pin_instance(struct bpf_program *prog, const char *path, + int instance) +{ + char *cp, errmsg[STRERR_BUFSIZE]; + int err; + + err = make_parent_dir(path); + if (err) + return err; + + err = check_path(path); + if (err) + return err; + + if (prog == NULL) { + pr_warn("invalid program pointer\n"); + return -EINVAL; + } + + if (instance < 0 || instance >= prog->instances.nr) { + pr_warn("invalid prog instance %d of prog %s (max %d)\n", + instance, prog->name, prog->instances.nr); + return -EINVAL; + } + + if (bpf_obj_pin(prog->instances.fds[instance], path)) { + err = -errno; + cp = libbpf_strerror_r(err, errmsg, sizeof(errmsg)); + pr_warn("failed to pin program: %s\n", cp); + return err; + } + pr_debug("pinned program '%s'\n", path); + + return 0; +} + +int bpf_program__unpin_instance(struct bpf_program *prog, const char *path, + int instance) +{ + int err; + + err = check_path(path); + if (err) + return err; + + if (prog == NULL) { + pr_warn("invalid program pointer\n"); + return -EINVAL; + } + + if (instance < 0 || instance >= prog->instances.nr) { + pr_warn("invalid prog instance %d of prog %s (max %d)\n", + instance, prog->name, prog->instances.nr); + return -EINVAL; + } + + err = unlink(path); + if (err != 0) + return -errno; + pr_debug("unpinned program '%s'\n", path); + + return 0; +} + +int bpf_program__pin(struct bpf_program *prog, const char *path) +{ + int i, err; + + err = make_parent_dir(path); + if (err) + return err; + + err = check_path(path); + if (err) + return err; + + if (prog == NULL) { + pr_warn("invalid program pointer\n"); + return -EINVAL; + } + + if (prog->instances.nr <= 0) { + pr_warn("no instances of prog %s to pin\n", prog->name); + return -EINVAL; + } + + if (prog->instances.nr == 1) { + /* don't create subdirs when pinning single instance */ + return bpf_program__pin_instance(prog, path, 0); + } + + for (i = 0; i < prog->instances.nr; i++) { + char buf[PATH_MAX]; + int len; + + len = snprintf(buf, PATH_MAX, "%s/%d", path, i); + if (len < 0) { + err = -EINVAL; + goto err_unpin; + } else if (len >= PATH_MAX) { + err = -ENAMETOOLONG; + goto err_unpin; + } + + err = bpf_program__pin_instance(prog, buf, i); + if (err) + goto err_unpin; + } + + return 0; + +err_unpin: + for (i = i - 1; i >= 0; i--) { + char buf[PATH_MAX]; + int len; + + len = snprintf(buf, PATH_MAX, "%s/%d", path, i); + if (len < 0) + continue; + else if (len >= PATH_MAX) + continue; + + bpf_program__unpin_instance(prog, buf, i); + } + + rmdir(path); + + return err; +} + +int bpf_program__unpin(struct bpf_program *prog, const char *path) +{ + int i, err; + + err = check_path(path); + if (err) + return err; + + if (prog == NULL) { + pr_warn("invalid program pointer\n"); + return -EINVAL; + } + + if (prog->instances.nr <= 0) { + pr_warn("no instances of prog %s to pin\n", prog->name); + return -EINVAL; + } + + if (prog->instances.nr == 1) { + /* don't create subdirs when pinning single instance */ + return bpf_program__unpin_instance(prog, path, 0); + } + + for (i = 0; i < prog->instances.nr; i++) { + char buf[PATH_MAX]; + int len; + + len = snprintf(buf, PATH_MAX, "%s/%d", path, i); + if (len < 0) + return -EINVAL; + else if (len >= PATH_MAX) + return -ENAMETOOLONG; + + err = bpf_program__unpin_instance(prog, buf, i); + if (err) + return err; + } + + err = rmdir(path); + if (err) + return -errno; + + return 0; +} + +int bpf_map__pin(struct bpf_map *map, const char *path) +{ + char *cp, errmsg[STRERR_BUFSIZE]; + int err; + + if (map == NULL) { + pr_warn("invalid map pointer\n"); + return -EINVAL; + } + + if (map->pin_path) { + if (path && strcmp(path, map->pin_path)) { + pr_warn("map '%s' already has pin path '%s' different from '%s'\n", + bpf_map__name(map), map->pin_path, path); + return -EINVAL; + } else if (map->pinned) { + pr_debug("map '%s' already pinned at '%s'; not re-pinning\n", + bpf_map__name(map), map->pin_path); + return 0; + } + } else { + if (!path) { + pr_warn("missing a path to pin map '%s' at\n", + bpf_map__name(map)); + return -EINVAL; + } else if (map->pinned) { + pr_warn("map '%s' already pinned\n", bpf_map__name(map)); + return -EEXIST; + } + + map->pin_path = strdup(path); + if (!map->pin_path) { + err = -errno; + goto out_err; + } + } + + err = make_parent_dir(map->pin_path); + if (err) + return err; + + err = check_path(map->pin_path); + if (err) + return err; + + if (bpf_obj_pin(map->fd, map->pin_path)) { + err = -errno; + goto out_err; + } + + map->pinned = true; + pr_debug("pinned map '%s'\n", map->pin_path); + + return 0; + +out_err: + cp = libbpf_strerror_r(-err, errmsg, sizeof(errmsg)); + pr_warn("failed to pin map: %s\n", cp); + return err; +} + +int bpf_map__unpin(struct bpf_map *map, const char *path) +{ + int err; + + if (map == NULL) { + pr_warn("invalid map pointer\n"); + return -EINVAL; + } + + if (map->pin_path) { + if (path && strcmp(path, map->pin_path)) { + pr_warn("map '%s' already has pin path '%s' different from '%s'\n", + bpf_map__name(map), map->pin_path, path); + return -EINVAL; + } + path = map->pin_path; + } else if (!path) { + pr_warn("no path to unpin map '%s' from\n", + bpf_map__name(map)); + return -EINVAL; + } + + err = check_path(path); + if (err) + return err; + + err = unlink(path); + if (err != 0) + return -errno; + + map->pinned = false; + pr_debug("unpinned map '%s' from '%s'\n", bpf_map__name(map), path); + + return 0; +} + +int bpf_map__set_pin_path(struct bpf_map *map, const char *path) +{ + char *new = NULL; + + if (path) { + new = strdup(path); + if (!new) + return -errno; + } + + free(map->pin_path); + map->pin_path = new; + return 0; +} + +const char *bpf_map__get_pin_path(const struct bpf_map *map) +{ + return map->pin_path; +} + +bool bpf_map__is_pinned(const struct bpf_map *map) +{ + return map->pinned; +} + +static void sanitize_pin_path(char *s) +{ + /* bpffs disallows periods in path names */ + while (*s) { + if (*s == '.') + *s = '_'; + s++; + } +} + +int bpf_object__pin_maps(struct bpf_object *obj, const char *path) +{ + struct bpf_map *map; + int err; + + if (!obj) + return -ENOENT; + + if (!obj->loaded) { + pr_warn("object not yet loaded; load it first\n"); + return -ENOENT; + } + + bpf_object__for_each_map(map, obj) { + char *pin_path = NULL; + char buf[PATH_MAX]; + + if (path) { + int len; + + len = snprintf(buf, PATH_MAX, "%s/%s", path, + bpf_map__name(map)); + if (len < 0) { + err = -EINVAL; + goto err_unpin_maps; + } else if (len >= PATH_MAX) { + err = -ENAMETOOLONG; + goto err_unpin_maps; + } + sanitize_pin_path(buf); + pin_path = buf; + } else if (!map->pin_path) { + continue; + } + + err = bpf_map__pin(map, pin_path); + if (err) + goto err_unpin_maps; + } + + return 0; + +err_unpin_maps: + while ((map = bpf_map__prev(map, obj))) { + if (!map->pin_path) + continue; + + bpf_map__unpin(map, NULL); + } + + return err; +} + +int bpf_object__unpin_maps(struct bpf_object *obj, const char *path) +{ + struct bpf_map *map; + int err; + + if (!obj) + return -ENOENT; + + bpf_object__for_each_map(map, obj) { + char *pin_path = NULL; + char buf[PATH_MAX]; + + if (path) { + int len; + + len = snprintf(buf, PATH_MAX, "%s/%s", path, + bpf_map__name(map)); + if (len < 0) + return -EINVAL; + else if (len >= PATH_MAX) + return -ENAMETOOLONG; + sanitize_pin_path(buf); + pin_path = buf; + } else if (!map->pin_path) { + continue; + } + + err = bpf_map__unpin(map, pin_path); + if (err) + return err; + } + + return 0; +} + +int bpf_object__pin_programs(struct bpf_object *obj, const char *path) +{ + struct bpf_program *prog; + int err; + + if (!obj) + return -ENOENT; + + if (!obj->loaded) { + pr_warn("object not yet loaded; load it first\n"); + return -ENOENT; + } + + bpf_object__for_each_program(prog, obj) { + char buf[PATH_MAX]; + int len; + + len = snprintf(buf, PATH_MAX, "%s/%s", path, + prog->pin_name); + if (len < 0) { + err = -EINVAL; + goto err_unpin_programs; + } else if (len >= PATH_MAX) { + err = -ENAMETOOLONG; + goto err_unpin_programs; + } + + err = bpf_program__pin(prog, buf); + if (err) + goto err_unpin_programs; + } + + return 0; + +err_unpin_programs: + while ((prog = bpf_program__prev(prog, obj))) { + char buf[PATH_MAX]; + int len; + + len = snprintf(buf, PATH_MAX, "%s/%s", path, + prog->pin_name); + if (len < 0) + continue; + else if (len >= PATH_MAX) + continue; + + bpf_program__unpin(prog, buf); + } + + return err; +} + +int bpf_object__unpin_programs(struct bpf_object *obj, const char *path) +{ + struct bpf_program *prog; + int err; + + if (!obj) + return -ENOENT; + + bpf_object__for_each_program(prog, obj) { + char buf[PATH_MAX]; + int len; + + len = snprintf(buf, PATH_MAX, "%s/%s", path, + prog->pin_name); + if (len < 0) + return -EINVAL; + else if (len >= PATH_MAX) + return -ENAMETOOLONG; + + err = bpf_program__unpin(prog, buf); + if (err) + return err; + } + + return 0; +} + +int bpf_object__pin(struct bpf_object *obj, const char *path) +{ + int err; + + err = bpf_object__pin_maps(obj, path); + if (err) + return err; + + err = bpf_object__pin_programs(obj, path); + if (err) { + bpf_object__unpin_maps(obj, path); + return err; + } + + return 0; +} + +static void bpf_map__destroy(struct bpf_map *map) +{ + if (map->clear_priv) + map->clear_priv(map, map->priv); + map->priv = NULL; + map->clear_priv = NULL; + + if (map->inner_map) { + bpf_map__destroy(map->inner_map); + zfree(&map->inner_map); + } + + zfree(&map->init_slots); + map->init_slots_sz = 0; + + if (map->mmaped) { + munmap(map->mmaped, bpf_map_mmap_sz(map)); + map->mmaped = NULL; + } + + if (map->st_ops) { + zfree(&map->st_ops->data); + zfree(&map->st_ops->progs); + zfree(&map->st_ops->kern_func_off); + zfree(&map->st_ops); + } + + zfree(&map->name); + zfree(&map->pin_path); + + if (map->fd >= 0) + zclose(map->fd); +} + +void bpf_object__close(struct bpf_object *obj) +{ + size_t i; + + if (IS_ERR_OR_NULL(obj)) + return; + + if (obj->clear_priv) + obj->clear_priv(obj, obj->priv); + + bpf_object__elf_finish(obj); + bpf_object__unload(obj); + btf__free(obj->btf); + btf_ext__free(obj->btf_ext); + + for (i = 0; i < obj->nr_maps; i++) + bpf_map__destroy(&obj->maps[i]); + + zfree(&obj->kconfig); + zfree(&obj->externs); + obj->nr_extern = 0; + + zfree(&obj->maps); + obj->nr_maps = 0; + + if (obj->programs && obj->nr_programs) { + for (i = 0; i < obj->nr_programs; i++) + bpf_program__exit(&obj->programs[i]); + } + zfree(&obj->programs); + + list_del(&obj->list); + free(obj); +} + +struct bpf_object * +bpf_object__next(struct bpf_object *prev) +{ + struct bpf_object *next; + + if (!prev) + next = list_first_entry(&bpf_objects_list, + struct bpf_object, + list); + else + next = list_next_entry(prev, list); + + /* Empty list is noticed here so don't need checking on entry. */ + if (&next->list == &bpf_objects_list) + return NULL; + + return next; +} + +const char *bpf_object__name(const struct bpf_object *obj) +{ + return obj ? obj->name : ERR_PTR(-EINVAL); +} + +unsigned int bpf_object__kversion(const struct bpf_object *obj) +{ + return obj ? obj->kern_version : 0; +} + +struct btf *bpf_object__btf(const struct bpf_object *obj) +{ + return obj ? obj->btf : NULL; +} + +int bpf_object__btf_fd(const struct bpf_object *obj) +{ + return obj->btf ? btf__fd(obj->btf) : -1; +} + +int bpf_object__set_priv(struct bpf_object *obj, void *priv, + bpf_object_clear_priv_t clear_priv) +{ + if (obj->priv && obj->clear_priv) + obj->clear_priv(obj, obj->priv); + + obj->priv = priv; + obj->clear_priv = clear_priv; + return 0; +} + +void *bpf_object__priv(const struct bpf_object *obj) +{ + return obj ? obj->priv : ERR_PTR(-EINVAL); +} + +static struct bpf_program * +__bpf_program__iter(const struct bpf_program *p, const struct bpf_object *obj, + bool forward) +{ + size_t nr_programs = obj->nr_programs; + ssize_t idx; + + if (!nr_programs) + return NULL; + + if (!p) + /* Iter from the beginning */ + return forward ? &obj->programs[0] : + &obj->programs[nr_programs - 1]; + + if (p->obj != obj) { + pr_warn("error: program handler doesn't match object\n"); + return NULL; + } + + idx = (p - obj->programs) + (forward ? 1 : -1); + if (idx >= obj->nr_programs || idx < 0) + return NULL; + return &obj->programs[idx]; +} + +struct bpf_program * +bpf_program__next(struct bpf_program *prev, const struct bpf_object *obj) +{ + struct bpf_program *prog = prev; + + do { + prog = __bpf_program__iter(prog, obj, true); + } while (prog && prog_is_subprog(obj, prog)); + + return prog; +} + +struct bpf_program * +bpf_program__prev(struct bpf_program *next, const struct bpf_object *obj) +{ + struct bpf_program *prog = next; + + do { + prog = __bpf_program__iter(prog, obj, false); + } while (prog && prog_is_subprog(obj, prog)); + + return prog; +} + +int bpf_program__set_priv(struct bpf_program *prog, void *priv, + bpf_program_clear_priv_t clear_priv) +{ + if (prog->priv && prog->clear_priv) + prog->clear_priv(prog, prog->priv); + + prog->priv = priv; + prog->clear_priv = clear_priv; + return 0; +} + +void *bpf_program__priv(const struct bpf_program *prog) +{ + return prog ? prog->priv : ERR_PTR(-EINVAL); +} + +void bpf_program__set_ifindex(struct bpf_program *prog, __u32 ifindex) +{ + prog->prog_ifindex = ifindex; +} + +const char *bpf_program__name(const struct bpf_program *prog) +{ + return prog->name; +} + +const char *bpf_program__section_name(const struct bpf_program *prog) +{ + return prog->sec_name; +} + +const char *bpf_program__title(const struct bpf_program *prog, bool needs_copy) +{ + const char *title; + + title = prog->sec_name; + if (needs_copy) { + title = strdup(title); + if (!title) { + pr_warn("failed to strdup program title\n"); + return ERR_PTR(-ENOMEM); + } + } + + return title; +} + +bool bpf_program__autoload(const struct bpf_program *prog) +{ + return prog->load; +} + +int bpf_program__set_autoload(struct bpf_program *prog, bool autoload) +{ + if (prog->obj->loaded) + return -EINVAL; + + prog->load = autoload; + return 0; +} + +int bpf_program__fd(const struct bpf_program *prog) +{ + return bpf_program__nth_fd(prog, 0); +} + +size_t bpf_program__size(const struct bpf_program *prog) +{ + return prog->insns_cnt * BPF_INSN_SZ; +} + +int bpf_program__set_prep(struct bpf_program *prog, int nr_instances, + bpf_program_prep_t prep) +{ + int *instances_fds; + + if (nr_instances <= 0 || !prep) + return -EINVAL; + + if (prog->instances.nr > 0 || prog->instances.fds) { + pr_warn("Can't set pre-processor after loading\n"); + return -EINVAL; + } + + instances_fds = malloc(sizeof(int) * nr_instances); + if (!instances_fds) { + pr_warn("alloc memory failed for fds\n"); + return -ENOMEM; + } + + /* fill all fd with -1 */ + memset(instances_fds, -1, sizeof(int) * nr_instances); + + prog->instances.nr = nr_instances; + prog->instances.fds = instances_fds; + prog->preprocessor = prep; + return 0; +} + +int bpf_program__nth_fd(const struct bpf_program *prog, int n) +{ + int fd; + + if (!prog) + return -EINVAL; + + if (n >= prog->instances.nr || n < 0) { + pr_warn("Can't get the %dth fd from program %s: only %d instances\n", + n, prog->name, prog->instances.nr); + return -EINVAL; + } + + fd = prog->instances.fds[n]; + if (fd < 0) { + pr_warn("%dth instance of program '%s' is invalid\n", + n, prog->name); + return -ENOENT; + } + + return fd; +} + +enum bpf_prog_type bpf_program__get_type(struct bpf_program *prog) +{ + return prog->type; +} + +void bpf_program__set_type(struct bpf_program *prog, enum bpf_prog_type type) +{ + prog->type = type; +} + +static bool bpf_program__is_type(const struct bpf_program *prog, + enum bpf_prog_type type) +{ + return prog ? (prog->type == type) : false; +} + +#define BPF_PROG_TYPE_FNS(NAME, TYPE) \ +int bpf_program__set_##NAME(struct bpf_program *prog) \ +{ \ + if (!prog) \ + return -EINVAL; \ + bpf_program__set_type(prog, TYPE); \ + return 0; \ +} \ + \ +bool bpf_program__is_##NAME(const struct bpf_program *prog) \ +{ \ + return bpf_program__is_type(prog, TYPE); \ +} \ + +BPF_PROG_TYPE_FNS(socket_filter, BPF_PROG_TYPE_SOCKET_FILTER); +BPF_PROG_TYPE_FNS(lsm, BPF_PROG_TYPE_LSM); +BPF_PROG_TYPE_FNS(kprobe, BPF_PROG_TYPE_KPROBE); +BPF_PROG_TYPE_FNS(sched_cls, BPF_PROG_TYPE_SCHED_CLS); +BPF_PROG_TYPE_FNS(sched_act, BPF_PROG_TYPE_SCHED_ACT); +BPF_PROG_TYPE_FNS(tracepoint, BPF_PROG_TYPE_TRACEPOINT); +BPF_PROG_TYPE_FNS(raw_tracepoint, BPF_PROG_TYPE_RAW_TRACEPOINT); +BPF_PROG_TYPE_FNS(xdp, BPF_PROG_TYPE_XDP); +BPF_PROG_TYPE_FNS(perf_event, BPF_PROG_TYPE_PERF_EVENT); +BPF_PROG_TYPE_FNS(tracing, BPF_PROG_TYPE_TRACING); +BPF_PROG_TYPE_FNS(struct_ops, BPF_PROG_TYPE_STRUCT_OPS); +BPF_PROG_TYPE_FNS(extension, BPF_PROG_TYPE_EXT); +BPF_PROG_TYPE_FNS(sk_lookup, BPF_PROG_TYPE_SK_LOOKUP); + +enum bpf_attach_type +bpf_program__get_expected_attach_type(struct bpf_program *prog) +{ + return prog->expected_attach_type; +} + +void bpf_program__set_expected_attach_type(struct bpf_program *prog, + enum bpf_attach_type type) +{ + prog->expected_attach_type = type; +} + +#define BPF_PROG_SEC_IMPL(string, ptype, eatype, eatype_optional, \ + attachable, attach_btf) \ + { \ + .sec = string, \ + .len = sizeof(string) - 1, \ + .prog_type = ptype, \ + .expected_attach_type = eatype, \ + .is_exp_attach_type_optional = eatype_optional, \ + .is_attachable = attachable, \ + .is_attach_btf = attach_btf, \ + } + +/* Programs that can NOT be attached. */ +#define BPF_PROG_SEC(string, ptype) BPF_PROG_SEC_IMPL(string, ptype, 0, 0, 0, 0) + +/* Programs that can be attached. */ +#define BPF_APROG_SEC(string, ptype, atype) \ + BPF_PROG_SEC_IMPL(string, ptype, atype, true, 1, 0) + +/* Programs that must specify expected attach type at load time. */ +#define BPF_EAPROG_SEC(string, ptype, eatype) \ + BPF_PROG_SEC_IMPL(string, ptype, eatype, false, 1, 0) + +/* Programs that use BTF to identify attach point */ +#define BPF_PROG_BTF(string, ptype, eatype) \ + BPF_PROG_SEC_IMPL(string, ptype, eatype, false, 0, 1) + +/* Programs that can be attached but attach type can't be identified by section + * name. Kept for backward compatibility. + */ +#define BPF_APROG_COMPAT(string, ptype) BPF_PROG_SEC(string, ptype) + +#define SEC_DEF(sec_pfx, ptype, ...) { \ + .sec = sec_pfx, \ + .len = sizeof(sec_pfx) - 1, \ + .prog_type = BPF_PROG_TYPE_##ptype, \ + __VA_ARGS__ \ +} + +static struct bpf_link *attach_kprobe(const struct bpf_sec_def *sec, + struct bpf_program *prog); +static struct bpf_link *attach_tp(const struct bpf_sec_def *sec, + struct bpf_program *prog); +static struct bpf_link *attach_raw_tp(const struct bpf_sec_def *sec, + struct bpf_program *prog); +static struct bpf_link *attach_trace(const struct bpf_sec_def *sec, + struct bpf_program *prog); +static struct bpf_link *attach_lsm(const struct bpf_sec_def *sec, + struct bpf_program *prog); +static struct bpf_link *attach_iter(const struct bpf_sec_def *sec, + struct bpf_program *prog); + +static const struct bpf_sec_def section_defs[] = { + BPF_PROG_SEC("socket", BPF_PROG_TYPE_SOCKET_FILTER), + BPF_PROG_SEC("sk_reuseport", BPF_PROG_TYPE_SK_REUSEPORT), + SEC_DEF("kprobe/", KPROBE, + .attach_fn = attach_kprobe), + BPF_PROG_SEC("uprobe/", BPF_PROG_TYPE_KPROBE), + SEC_DEF("kretprobe/", KPROBE, + .attach_fn = attach_kprobe), + BPF_PROG_SEC("uretprobe/", BPF_PROG_TYPE_KPROBE), + BPF_PROG_SEC("classifier", BPF_PROG_TYPE_SCHED_CLS), + BPF_PROG_SEC("action", BPF_PROG_TYPE_SCHED_ACT), + SEC_DEF("tracepoint/", TRACEPOINT, + .attach_fn = attach_tp), + SEC_DEF("tp/", TRACEPOINT, + .attach_fn = attach_tp), + SEC_DEF("raw_tracepoint/", RAW_TRACEPOINT, + .attach_fn = attach_raw_tp), + SEC_DEF("raw_tp/", RAW_TRACEPOINT, + .attach_fn = attach_raw_tp), + SEC_DEF("tp_btf/", TRACING, + .expected_attach_type = BPF_TRACE_RAW_TP, + .is_attach_btf = true, + .attach_fn = attach_trace), + SEC_DEF("fentry/", TRACING, + .expected_attach_type = BPF_TRACE_FENTRY, + .is_attach_btf = true, + .attach_fn = attach_trace), + SEC_DEF("fmod_ret/", TRACING, + .expected_attach_type = BPF_MODIFY_RETURN, + .is_attach_btf = true, + .attach_fn = attach_trace), + SEC_DEF("fexit/", TRACING, + .expected_attach_type = BPF_TRACE_FEXIT, + .is_attach_btf = true, + .attach_fn = attach_trace), + SEC_DEF("fentry.s/", TRACING, + .expected_attach_type = BPF_TRACE_FENTRY, + .is_attach_btf = true, + .is_sleepable = true, + .attach_fn = attach_trace), + SEC_DEF("fmod_ret.s/", TRACING, + .expected_attach_type = BPF_MODIFY_RETURN, + .is_attach_btf = true, + .is_sleepable = true, + .attach_fn = attach_trace), + SEC_DEF("fexit.s/", TRACING, + .expected_attach_type = BPF_TRACE_FEXIT, + .is_attach_btf = true, + .is_sleepable = true, + .attach_fn = attach_trace), + SEC_DEF("freplace/", EXT, + .is_attach_btf = true, + .attach_fn = attach_trace), + SEC_DEF("lsm/", LSM, + .is_attach_btf = true, + .expected_attach_type = BPF_LSM_MAC, + .attach_fn = attach_lsm), + SEC_DEF("lsm.s/", LSM, + .is_attach_btf = true, + .is_sleepable = true, + .expected_attach_type = BPF_LSM_MAC, + .attach_fn = attach_lsm), + SEC_DEF("iter/", TRACING, + .expected_attach_type = BPF_TRACE_ITER, + .is_attach_btf = true, + .attach_fn = attach_iter), + BPF_EAPROG_SEC("xdp_devmap/", BPF_PROG_TYPE_XDP, + BPF_XDP_DEVMAP), + BPF_EAPROG_SEC("xdp_cpumap/", BPF_PROG_TYPE_XDP, + BPF_XDP_CPUMAP), + BPF_APROG_SEC("xdp", BPF_PROG_TYPE_XDP, + BPF_XDP), + BPF_PROG_SEC("perf_event", BPF_PROG_TYPE_PERF_EVENT), + BPF_PROG_SEC("lwt_in", BPF_PROG_TYPE_LWT_IN), + BPF_PROG_SEC("lwt_out", BPF_PROG_TYPE_LWT_OUT), + BPF_PROG_SEC("lwt_xmit", BPF_PROG_TYPE_LWT_XMIT), + BPF_PROG_SEC("lwt_seg6local", BPF_PROG_TYPE_LWT_SEG6LOCAL), + BPF_APROG_SEC("cgroup_skb/ingress", BPF_PROG_TYPE_CGROUP_SKB, + BPF_CGROUP_INET_INGRESS), + BPF_APROG_SEC("cgroup_skb/egress", BPF_PROG_TYPE_CGROUP_SKB, + BPF_CGROUP_INET_EGRESS), + BPF_APROG_COMPAT("cgroup/skb", BPF_PROG_TYPE_CGROUP_SKB), + BPF_EAPROG_SEC("cgroup/sock_create", BPF_PROG_TYPE_CGROUP_SOCK, + BPF_CGROUP_INET_SOCK_CREATE), + BPF_EAPROG_SEC("cgroup/sock_release", BPF_PROG_TYPE_CGROUP_SOCK, + BPF_CGROUP_INET_SOCK_RELEASE), + BPF_APROG_SEC("cgroup/sock", BPF_PROG_TYPE_CGROUP_SOCK, + BPF_CGROUP_INET_SOCK_CREATE), + BPF_EAPROG_SEC("cgroup/post_bind4", BPF_PROG_TYPE_CGROUP_SOCK, + BPF_CGROUP_INET4_POST_BIND), + BPF_EAPROG_SEC("cgroup/post_bind6", BPF_PROG_TYPE_CGROUP_SOCK, + BPF_CGROUP_INET6_POST_BIND), + BPF_APROG_SEC("cgroup/dev", BPF_PROG_TYPE_CGROUP_DEVICE, + BPF_CGROUP_DEVICE), + BPF_APROG_SEC("sockops", BPF_PROG_TYPE_SOCK_OPS, + BPF_CGROUP_SOCK_OPS), + BPF_APROG_SEC("sk_skb/stream_parser", BPF_PROG_TYPE_SK_SKB, + BPF_SK_SKB_STREAM_PARSER), + BPF_APROG_SEC("sk_skb/stream_verdict", BPF_PROG_TYPE_SK_SKB, + BPF_SK_SKB_STREAM_VERDICT), + BPF_APROG_COMPAT("sk_skb", BPF_PROG_TYPE_SK_SKB), + BPF_APROG_SEC("sk_msg", BPF_PROG_TYPE_SK_MSG, + BPF_SK_MSG_VERDICT), + BPF_APROG_SEC("lirc_mode2", BPF_PROG_TYPE_LIRC_MODE2, + BPF_LIRC_MODE2), + BPF_APROG_SEC("flow_dissector", BPF_PROG_TYPE_FLOW_DISSECTOR, + BPF_FLOW_DISSECTOR), + BPF_EAPROG_SEC("cgroup/bind4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_INET4_BIND), + BPF_EAPROG_SEC("cgroup/bind6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_INET6_BIND), + BPF_EAPROG_SEC("cgroup/connect4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_INET4_CONNECT), + BPF_EAPROG_SEC("cgroup/connect6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_INET6_CONNECT), + BPF_EAPROG_SEC("cgroup/sendmsg4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_UDP4_SENDMSG), + BPF_EAPROG_SEC("cgroup/sendmsg6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_UDP6_SENDMSG), + BPF_EAPROG_SEC("cgroup/recvmsg4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_UDP4_RECVMSG), + BPF_EAPROG_SEC("cgroup/recvmsg6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_UDP6_RECVMSG), + BPF_EAPROG_SEC("cgroup/getpeername4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_INET4_GETPEERNAME), + BPF_EAPROG_SEC("cgroup/getpeername6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_INET6_GETPEERNAME), + BPF_EAPROG_SEC("cgroup/getsockname4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_INET4_GETSOCKNAME), + BPF_EAPROG_SEC("cgroup/getsockname6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, + BPF_CGROUP_INET6_GETSOCKNAME), + BPF_EAPROG_SEC("cgroup/sysctl", BPF_PROG_TYPE_CGROUP_SYSCTL, + BPF_CGROUP_SYSCTL), + BPF_EAPROG_SEC("cgroup/getsockopt", BPF_PROG_TYPE_CGROUP_SOCKOPT, + BPF_CGROUP_GETSOCKOPT), + BPF_EAPROG_SEC("cgroup/setsockopt", BPF_PROG_TYPE_CGROUP_SOCKOPT, + BPF_CGROUP_SETSOCKOPT), + BPF_PROG_SEC("struct_ops", BPF_PROG_TYPE_STRUCT_OPS), + BPF_EAPROG_SEC("sk_lookup/", BPF_PROG_TYPE_SK_LOOKUP, + BPF_SK_LOOKUP), +}; + +#undef BPF_PROG_SEC_IMPL +#undef BPF_PROG_SEC +#undef BPF_APROG_SEC +#undef BPF_EAPROG_SEC +#undef BPF_APROG_COMPAT +#undef SEC_DEF + +#define MAX_TYPE_NAME_SIZE 32 + +static const struct bpf_sec_def *find_sec_def(const char *sec_name) +{ + int i, n = ARRAY_SIZE(section_defs); + + for (i = 0; i < n; i++) { + if (strncmp(sec_name, + section_defs[i].sec, section_defs[i].len)) + continue; + return §ion_defs[i]; + } + return NULL; +} + +static char *libbpf_get_type_names(bool attach_type) +{ + int i, len = ARRAY_SIZE(section_defs) * MAX_TYPE_NAME_SIZE; + char *buf; + + buf = malloc(len); + if (!buf) + return NULL; + + buf[0] = '\0'; + /* Forge string buf with all available names */ + for (i = 0; i < ARRAY_SIZE(section_defs); i++) { + if (attach_type && !section_defs[i].is_attachable) + continue; + + if (strlen(buf) + strlen(section_defs[i].sec) + 2 > len) { + free(buf); + return NULL; + } + strcat(buf, " "); + strcat(buf, section_defs[i].sec); + } + + return buf; +} + +int libbpf_prog_type_by_name(const char *name, enum bpf_prog_type *prog_type, + enum bpf_attach_type *expected_attach_type) +{ + const struct bpf_sec_def *sec_def; + char *type_names; + + if (!name) + return -EINVAL; + + sec_def = find_sec_def(name); + if (sec_def) { + *prog_type = sec_def->prog_type; + *expected_attach_type = sec_def->expected_attach_type; + return 0; + } + + pr_debug("failed to guess program type from ELF section '%s'\n", name); + type_names = libbpf_get_type_names(false); + if (type_names != NULL) { + pr_debug("supported section(type) names are:%s\n", type_names); + free(type_names); + } + + return -ESRCH; +} + +static struct bpf_map *find_struct_ops_map_by_offset(struct bpf_object *obj, + size_t offset) +{ + struct bpf_map *map; + size_t i; + + for (i = 0; i < obj->nr_maps; i++) { + map = &obj->maps[i]; + if (!bpf_map__is_struct_ops(map)) + continue; + if (map->sec_offset <= offset && + offset - map->sec_offset < map->def.value_size) + return map; + } + + return NULL; +} + +/* Collect the reloc from ELF and populate the st_ops->progs[] */ +static int bpf_object__collect_st_ops_relos(struct bpf_object *obj, + GElf_Shdr *shdr, Elf_Data *data) +{ + const struct btf_member *member; + struct bpf_struct_ops *st_ops; + struct bpf_program *prog; + unsigned int shdr_idx; + const struct btf *btf; + struct bpf_map *map; + Elf_Data *symbols; + unsigned int moff, insn_idx; + const char *name; + __u32 member_idx; + GElf_Sym sym; + GElf_Rel rel; + int i, nrels; + + symbols = obj->efile.symbols; + btf = obj->btf; + nrels = shdr->sh_size / shdr->sh_entsize; + for (i = 0; i < nrels; i++) { + if (!gelf_getrel(data, i, &rel)) { + pr_warn("struct_ops reloc: failed to get %d reloc\n", i); + return -LIBBPF_ERRNO__FORMAT; + } + + if (!gelf_getsym(symbols, GELF_R_SYM(rel.r_info), &sym)) { + pr_warn("struct_ops reloc: symbol %zx not found\n", + (size_t)GELF_R_SYM(rel.r_info)); + return -LIBBPF_ERRNO__FORMAT; + } + + name = elf_sym_str(obj, sym.st_name) ?: ""; + map = find_struct_ops_map_by_offset(obj, rel.r_offset); + if (!map) { + pr_warn("struct_ops reloc: cannot find map at rel.r_offset %zu\n", + (size_t)rel.r_offset); + return -EINVAL; + } + + moff = rel.r_offset - map->sec_offset; + shdr_idx = sym.st_shndx; + st_ops = map->st_ops; + pr_debug("struct_ops reloc %s: for %lld value %lld shdr_idx %u rel.r_offset %zu map->sec_offset %zu name %d (\'%s\')\n", + map->name, + (long long)(rel.r_info >> 32), + (long long)sym.st_value, + shdr_idx, (size_t)rel.r_offset, + map->sec_offset, sym.st_name, name); + + if (shdr_idx >= SHN_LORESERVE) { + pr_warn("struct_ops reloc %s: rel.r_offset %zu shdr_idx %u unsupported non-static function\n", + map->name, (size_t)rel.r_offset, shdr_idx); + return -LIBBPF_ERRNO__RELOC; + } + if (sym.st_value % BPF_INSN_SZ) { + pr_warn("struct_ops reloc %s: invalid target program offset %llu\n", + map->name, (unsigned long long)sym.st_value); + return -LIBBPF_ERRNO__FORMAT; + } + insn_idx = sym.st_value / BPF_INSN_SZ; + + member = find_member_by_offset(st_ops->type, moff * 8); + if (!member) { + pr_warn("struct_ops reloc %s: cannot find member at moff %u\n", + map->name, moff); + return -EINVAL; + } + member_idx = member - btf_members(st_ops->type); + name = btf__name_by_offset(btf, member->name_off); + + if (!resolve_func_ptr(btf, member->type, NULL)) { + pr_warn("struct_ops reloc %s: cannot relocate non func ptr %s\n", + map->name, name); + return -EINVAL; + } + + prog = find_prog_by_sec_insn(obj, shdr_idx, insn_idx); + if (!prog) { + pr_warn("struct_ops reloc %s: cannot find prog at shdr_idx %u to relocate func ptr %s\n", + map->name, shdr_idx, name); + return -EINVAL; + } + + if (prog->type == BPF_PROG_TYPE_UNSPEC) { + const struct bpf_sec_def *sec_def; + + sec_def = find_sec_def(prog->sec_name); + if (sec_def && + sec_def->prog_type != BPF_PROG_TYPE_STRUCT_OPS) { + /* for pr_warn */ + prog->type = sec_def->prog_type; + goto invalid_prog; + } + + prog->type = BPF_PROG_TYPE_STRUCT_OPS; + prog->attach_btf_id = st_ops->type_id; + prog->expected_attach_type = member_idx; + } else if (prog->type != BPF_PROG_TYPE_STRUCT_OPS || + prog->attach_btf_id != st_ops->type_id || + prog->expected_attach_type != member_idx) { + goto invalid_prog; + } + st_ops->progs[member_idx] = prog; + } + + return 0; + +invalid_prog: + pr_warn("struct_ops reloc %s: cannot use prog %s in sec %s with type %u attach_btf_id %u expected_attach_type %u for func ptr %s\n", + map->name, prog->name, prog->sec_name, prog->type, + prog->attach_btf_id, prog->expected_attach_type, name); + return -EINVAL; +} + +#define BTF_TRACE_PREFIX "btf_trace_" +#define BTF_LSM_PREFIX "bpf_lsm_" +#define BTF_ITER_PREFIX "bpf_iter_" +#define BTF_MAX_NAME_SIZE 128 + +static int find_btf_by_prefix_kind(const struct btf *btf, const char *prefix, + const char *name, __u32 kind) +{ + char btf_type_name[BTF_MAX_NAME_SIZE]; + int ret; + + ret = snprintf(btf_type_name, sizeof(btf_type_name), + "%s%s", prefix, name); + /* snprintf returns the number of characters written excluding the + * the terminating null. So, if >= BTF_MAX_NAME_SIZE are written, it + * indicates truncation. + */ + if (ret < 0 || ret >= sizeof(btf_type_name)) + return -ENAMETOOLONG; + return btf__find_by_name_kind(btf, btf_type_name, kind); +} + +static inline int find_attach_btf_id(struct btf *btf, const char *name, + enum bpf_attach_type attach_type) +{ + int err; + + if (attach_type == BPF_TRACE_RAW_TP) + err = find_btf_by_prefix_kind(btf, BTF_TRACE_PREFIX, name, + BTF_KIND_TYPEDEF); + else if (attach_type == BPF_LSM_MAC) + err = find_btf_by_prefix_kind(btf, BTF_LSM_PREFIX, name, + BTF_KIND_FUNC); + else if (attach_type == BPF_TRACE_ITER) + err = find_btf_by_prefix_kind(btf, BTF_ITER_PREFIX, name, + BTF_KIND_FUNC); + else + err = btf__find_by_name_kind(btf, name, BTF_KIND_FUNC); + + return err; +} + +int libbpf_find_vmlinux_btf_id(const char *name, + enum bpf_attach_type attach_type) +{ + struct btf *btf; + int err; + + btf = libbpf_find_kernel_btf(); + if (IS_ERR(btf)) { + pr_warn("vmlinux BTF is not found\n"); + return -EINVAL; + } + + err = find_attach_btf_id(btf, name, attach_type); + if (err <= 0) + pr_warn("%s is not found in vmlinux BTF\n", name); + + btf__free(btf); + return err; +} + +static int libbpf_find_prog_btf_id(const char *name, __u32 attach_prog_fd) +{ + struct bpf_prog_info_linear *info_linear; + struct bpf_prog_info *info; + struct btf *btf = NULL; + int err = -EINVAL; + + info_linear = bpf_program__get_prog_info_linear(attach_prog_fd, 0); + if (IS_ERR_OR_NULL(info_linear)) { + pr_warn("failed get_prog_info_linear for FD %d\n", + attach_prog_fd); + return -EINVAL; + } + info = &info_linear->info; + if (!info->btf_id) { + pr_warn("The target program doesn't have BTF\n"); + goto out; + } + if (btf__get_from_id(info->btf_id, &btf)) { + pr_warn("Failed to get BTF of the program\n"); + goto out; + } + err = btf__find_by_name_kind(btf, name, BTF_KIND_FUNC); + btf__free(btf); + if (err <= 0) { + pr_warn("%s is not found in prog's BTF\n", name); + goto out; + } +out: + free(info_linear); + return err; +} + +static int find_kernel_btf_id(struct bpf_object *obj, const char *attach_name, + enum bpf_attach_type attach_type, + int *btf_obj_fd, int *btf_type_id) +{ + int ret, i; + + ret = find_attach_btf_id(obj->btf_vmlinux, attach_name, attach_type); + if (ret > 0) { + *btf_obj_fd = 0; /* vmlinux BTF */ + *btf_type_id = ret; + return 0; + } + if (ret != -ENOENT) + return ret; + + ret = load_module_btfs(obj); + if (ret) + return ret; + + for (i = 0; i < obj->btf_module_cnt; i++) { + const struct module_btf *mod = &obj->btf_modules[i]; + + ret = find_attach_btf_id(mod->btf, attach_name, attach_type); + if (ret > 0) { + *btf_obj_fd = mod->fd; + *btf_type_id = ret; + return 0; + } + if (ret == -ENOENT) + continue; + + return ret; + } + + return -ESRCH; +} + +static int libbpf_find_attach_btf_id(struct bpf_program *prog, int *btf_obj_fd, int *btf_type_id) +{ + enum bpf_attach_type attach_type = prog->expected_attach_type; + __u32 attach_prog_fd = prog->attach_prog_fd; + const char *name = prog->sec_name, *attach_name; + const struct bpf_sec_def *sec = NULL; + int i, err; + + if (!name) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(section_defs); i++) { + if (!section_defs[i].is_attach_btf) + continue; + if (strncmp(name, section_defs[i].sec, section_defs[i].len)) + continue; + + sec = §ion_defs[i]; + break; + } + + if (!sec) { + pr_warn("failed to identify BTF ID based on ELF section name '%s'\n", name); + return -ESRCH; + } + attach_name = name + sec->len; + + /* BPF program's BTF ID */ + if (attach_prog_fd) { + err = libbpf_find_prog_btf_id(attach_name, attach_prog_fd); + if (err < 0) { + pr_warn("failed to find BPF program (FD %d) BTF ID for '%s': %d\n", + attach_prog_fd, attach_name, err); + return err; + } + *btf_obj_fd = 0; + *btf_type_id = err; + return 0; + } + + /* kernel/module BTF ID */ + err = find_kernel_btf_id(prog->obj, attach_name, attach_type, btf_obj_fd, btf_type_id); + if (err) { + pr_warn("failed to find kernel BTF type ID of '%s': %d\n", attach_name, err); + return err; + } + return 0; +} + +int libbpf_attach_type_by_name(const char *name, + enum bpf_attach_type *attach_type) +{ + char *type_names; + int i; + + if (!name) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(section_defs); i++) { + if (strncmp(name, section_defs[i].sec, section_defs[i].len)) + continue; + if (!section_defs[i].is_attachable) + return -EINVAL; + *attach_type = section_defs[i].expected_attach_type; + return 0; + } + pr_debug("failed to guess attach type based on ELF section name '%s'\n", name); + type_names = libbpf_get_type_names(true); + if (type_names != NULL) { + pr_debug("attachable section(type) names are:%s\n", type_names); + free(type_names); + } + + return -EINVAL; +} + +int bpf_map__fd(const struct bpf_map *map) +{ + return map ? map->fd : -EINVAL; +} + +const struct bpf_map_def *bpf_map__def(const struct bpf_map *map) +{ + return map ? &map->def : ERR_PTR(-EINVAL); +} + +const char *bpf_map__name(const struct bpf_map *map) +{ + return map ? map->name : NULL; +} + +enum bpf_map_type bpf_map__type(const struct bpf_map *map) +{ + return map->def.type; +} + +int bpf_map__set_type(struct bpf_map *map, enum bpf_map_type type) +{ + if (map->fd >= 0) + return -EBUSY; + map->def.type = type; + return 0; +} + +__u32 bpf_map__map_flags(const struct bpf_map *map) +{ + return map->def.map_flags; +} + +int bpf_map__set_map_flags(struct bpf_map *map, __u32 flags) +{ + if (map->fd >= 0) + return -EBUSY; + map->def.map_flags = flags; + return 0; +} + +__u32 bpf_map__numa_node(const struct bpf_map *map) +{ + return map->numa_node; +} + +int bpf_map__set_numa_node(struct bpf_map *map, __u32 numa_node) +{ + if (map->fd >= 0) + return -EBUSY; + map->numa_node = numa_node; + return 0; +} + +__u32 bpf_map__key_size(const struct bpf_map *map) +{ + return map->def.key_size; +} + +int bpf_map__set_key_size(struct bpf_map *map, __u32 size) +{ + if (map->fd >= 0) + return -EBUSY; + map->def.key_size = size; + return 0; +} + +__u32 bpf_map__value_size(const struct bpf_map *map) +{ + return map->def.value_size; +} + +int bpf_map__set_value_size(struct bpf_map *map, __u32 size) +{ + if (map->fd >= 0) + return -EBUSY; + map->def.value_size = size; + return 0; +} + +__u32 bpf_map__btf_key_type_id(const struct bpf_map *map) +{ + return map ? map->btf_key_type_id : 0; +} + +__u32 bpf_map__btf_value_type_id(const struct bpf_map *map) +{ + return map ? map->btf_value_type_id : 0; +} + +int bpf_map__set_priv(struct bpf_map *map, void *priv, + bpf_map_clear_priv_t clear_priv) +{ + if (!map) + return -EINVAL; + + if (map->priv) { + if (map->clear_priv) + map->clear_priv(map, map->priv); + } + + map->priv = priv; + map->clear_priv = clear_priv; + return 0; +} + +void *bpf_map__priv(const struct bpf_map *map) +{ + return map ? map->priv : ERR_PTR(-EINVAL); +} + +int bpf_map__set_initial_value(struct bpf_map *map, + const void *data, size_t size) +{ + if (!map->mmaped || map->libbpf_type == LIBBPF_MAP_KCONFIG || + size != map->def.value_size || map->fd >= 0) + return -EINVAL; + + memcpy(map->mmaped, data, size); + return 0; +} + +bool bpf_map__is_offload_neutral(const struct bpf_map *map) +{ + return map->def.type == BPF_MAP_TYPE_PERF_EVENT_ARRAY; +} + +bool bpf_map__is_internal(const struct bpf_map *map) +{ + return map->libbpf_type != LIBBPF_MAP_UNSPEC; +} + +__u32 bpf_map__ifindex(const struct bpf_map *map) +{ + return map->map_ifindex; +} + +int bpf_map__set_ifindex(struct bpf_map *map, __u32 ifindex) +{ + if (map->fd >= 0) + return -EBUSY; + map->map_ifindex = ifindex; + return 0; +} + +int bpf_map__set_inner_map_fd(struct bpf_map *map, int fd) +{ + if (!bpf_map_type__is_map_in_map(map->def.type)) { + pr_warn("error: unsupported map type\n"); + return -EINVAL; + } + if (map->inner_map_fd != -1) { + pr_warn("error: inner_map_fd already specified\n"); + return -EINVAL; + } + map->inner_map_fd = fd; + return 0; +} + +static struct bpf_map * +__bpf_map__iter(const struct bpf_map *m, const struct bpf_object *obj, int i) +{ + ssize_t idx; + struct bpf_map *s, *e; + + if (!obj || !obj->maps) + return NULL; + + s = obj->maps; + e = obj->maps + obj->nr_maps; + + if ((m < s) || (m >= e)) { + pr_warn("error in %s: map handler doesn't belong to object\n", + __func__); + return NULL; + } + + idx = (m - obj->maps) + i; + if (idx >= obj->nr_maps || idx < 0) + return NULL; + return &obj->maps[idx]; +} + +struct bpf_map * +bpf_map__next(const struct bpf_map *prev, const struct bpf_object *obj) +{ + if (prev == NULL) + return obj->maps; + + return __bpf_map__iter(prev, obj, 1); +} + +struct bpf_map * +bpf_map__prev(const struct bpf_map *next, const struct bpf_object *obj) +{ + if (next == NULL) { + if (!obj->nr_maps) + return NULL; + return obj->maps + obj->nr_maps - 1; + } + + return __bpf_map__iter(next, obj, -1); +} + +struct bpf_map * +bpf_object__find_map_by_name(const struct bpf_object *obj, const char *name) +{ + struct bpf_map *pos; + + bpf_object__for_each_map(pos, obj) { + if (pos->name && !strcmp(pos->name, name)) + return pos; + } + return NULL; +} + +int +bpf_object__find_map_fd_by_name(const struct bpf_object *obj, const char *name) +{ + return bpf_map__fd(bpf_object__find_map_by_name(obj, name)); +} + +struct bpf_map * +bpf_object__find_map_by_offset(struct bpf_object *obj, size_t offset) +{ + return ERR_PTR(-ENOTSUP); +} + +long libbpf_get_error(const void *ptr) +{ + return PTR_ERR_OR_ZERO(ptr); +} + +int bpf_prog_load(const char *file, enum bpf_prog_type type, + struct bpf_object **pobj, int *prog_fd) +{ + struct bpf_prog_load_attr attr; + + memset(&attr, 0, sizeof(struct bpf_prog_load_attr)); + attr.file = file; + attr.prog_type = type; + attr.expected_attach_type = 0; + + return bpf_prog_load_xattr(&attr, pobj, prog_fd); +} + +int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr, + struct bpf_object **pobj, int *prog_fd) +{ + struct bpf_object_open_attr open_attr = {}; + struct bpf_program *prog, *first_prog = NULL; + struct bpf_object *obj; + struct bpf_map *map; + int err; + + if (!attr) + return -EINVAL; + if (!attr->file) + return -EINVAL; + + open_attr.file = attr->file; + open_attr.prog_type = attr->prog_type; + + obj = bpf_object__open_xattr(&open_attr); + if (IS_ERR_OR_NULL(obj)) + return -ENOENT; + + bpf_object__for_each_program(prog, obj) { + enum bpf_attach_type attach_type = attr->expected_attach_type; + /* + * to preserve backwards compatibility, bpf_prog_load treats + * attr->prog_type, if specified, as an override to whatever + * bpf_object__open guessed + */ + if (attr->prog_type != BPF_PROG_TYPE_UNSPEC) { + bpf_program__set_type(prog, attr->prog_type); + bpf_program__set_expected_attach_type(prog, + attach_type); + } + if (bpf_program__get_type(prog) == BPF_PROG_TYPE_UNSPEC) { + /* + * we haven't guessed from section name and user + * didn't provide a fallback type, too bad... + */ + bpf_object__close(obj); + return -EINVAL; + } + + prog->prog_ifindex = attr->ifindex; + prog->log_level = attr->log_level; + prog->prog_flags |= attr->prog_flags; + if (!first_prog) + first_prog = prog; + } + + bpf_object__for_each_map(map, obj) { + if (!bpf_map__is_offload_neutral(map)) + map->map_ifindex = attr->ifindex; + } + + if (!first_prog) { + pr_warn("object file doesn't contain bpf program\n"); + bpf_object__close(obj); + return -ENOENT; + } + + err = bpf_object__load(obj); + if (err) { + bpf_object__close(obj); + return err; + } + + *pobj = obj; + *prog_fd = bpf_program__fd(first_prog); + return 0; +} + +struct bpf_link { + int (*detach)(struct bpf_link *link); + int (*destroy)(struct bpf_link *link); + char *pin_path; /* NULL, if not pinned */ + int fd; /* hook FD, -1 if not applicable */ + bool disconnected; +}; + +/* Replace link's underlying BPF program with the new one */ +int bpf_link__update_program(struct bpf_link *link, struct bpf_program *prog) +{ + return bpf_link_update(bpf_link__fd(link), bpf_program__fd(prog), NULL); +} + +/* Release "ownership" of underlying BPF resource (typically, BPF program + * attached to some BPF hook, e.g., tracepoint, kprobe, etc). Disconnected + * link, when destructed through bpf_link__destroy() call won't attempt to + * detach/unregisted that BPF resource. This is useful in situations where, + * say, attached BPF program has to outlive userspace program that attached it + * in the system. Depending on type of BPF program, though, there might be + * additional steps (like pinning BPF program in BPF FS) necessary to ensure + * exit of userspace program doesn't trigger automatic detachment and clean up + * inside the kernel. + */ +void bpf_link__disconnect(struct bpf_link *link) +{ + link->disconnected = true; +} + +int bpf_link__destroy(struct bpf_link *link) +{ + int err = 0; + + if (IS_ERR_OR_NULL(link)) + return 0; + + if (!link->disconnected && link->detach) + err = link->detach(link); + if (link->destroy) + link->destroy(link); + if (link->pin_path) + free(link->pin_path); + free(link); + + return err; +} + +int bpf_link__fd(const struct bpf_link *link) +{ + return link->fd; +} + +const char *bpf_link__pin_path(const struct bpf_link *link) +{ + return link->pin_path; +} + +static int bpf_link__detach_fd(struct bpf_link *link) +{ + return close(link->fd); +} + +struct bpf_link *bpf_link__open(const char *path) +{ + struct bpf_link *link; + int fd; + + fd = bpf_obj_get(path); + if (fd < 0) { + fd = -errno; + pr_warn("failed to open link at %s: %d\n", path, fd); + return ERR_PTR(fd); + } + + link = calloc(1, sizeof(*link)); + if (!link) { + close(fd); + return ERR_PTR(-ENOMEM); + } + link->detach = &bpf_link__detach_fd; + link->fd = fd; + + link->pin_path = strdup(path); + if (!link->pin_path) { + bpf_link__destroy(link); + return ERR_PTR(-ENOMEM); + } + + return link; +} + +int bpf_link__detach(struct bpf_link *link) +{ + return bpf_link_detach(link->fd) ? -errno : 0; +} + +int bpf_link__pin(struct bpf_link *link, const char *path) +{ + int err; + + if (link->pin_path) + return -EBUSY; + err = make_parent_dir(path); + if (err) + return err; + err = check_path(path); + if (err) + return err; + + link->pin_path = strdup(path); + if (!link->pin_path) + return -ENOMEM; + + if (bpf_obj_pin(link->fd, link->pin_path)) { + err = -errno; + zfree(&link->pin_path); + return err; + } + + pr_debug("link fd=%d: pinned at %s\n", link->fd, link->pin_path); + return 0; +} + +int bpf_link__unpin(struct bpf_link *link) +{ + int err; + + if (!link->pin_path) + return -EINVAL; + + err = unlink(link->pin_path); + if (err != 0) + return -errno; + + pr_debug("link fd=%d: unpinned from %s\n", link->fd, link->pin_path); + zfree(&link->pin_path); + return 0; +} + +static int bpf_link__detach_perf_event(struct bpf_link *link) +{ + int err; + + err = ioctl(link->fd, PERF_EVENT_IOC_DISABLE, 0); + if (err) + err = -errno; + + close(link->fd); + return err; +} + +struct bpf_link *bpf_program__attach_perf_event(struct bpf_program *prog, + int pfd) +{ + char errmsg[STRERR_BUFSIZE]; + struct bpf_link *link; + int prog_fd, err; + + if (pfd < 0) { + pr_warn("prog '%s': invalid perf event FD %d\n", + prog->name, pfd); + return ERR_PTR(-EINVAL); + } + prog_fd = bpf_program__fd(prog); + if (prog_fd < 0) { + pr_warn("prog '%s': can't attach BPF program w/o FD (did you load it?)\n", + prog->name); + return ERR_PTR(-EINVAL); + } + + link = calloc(1, sizeof(*link)); + if (!link) + return ERR_PTR(-ENOMEM); + link->detach = &bpf_link__detach_perf_event; + link->fd = pfd; + + if (ioctl(pfd, PERF_EVENT_IOC_SET_BPF, prog_fd) < 0) { + err = -errno; + free(link); + pr_warn("prog '%s': failed to attach to pfd %d: %s\n", + prog->name, pfd, libbpf_strerror_r(err, errmsg, sizeof(errmsg))); + if (err == -EPROTO) + pr_warn("prog '%s': try add PERF_SAMPLE_CALLCHAIN to or remove exclude_callchain_[kernel|user] from pfd %d\n", + prog->name, pfd); + return ERR_PTR(err); + } + if (ioctl(pfd, PERF_EVENT_IOC_ENABLE, 0) < 0) { + err = -errno; + free(link); + pr_warn("prog '%s': failed to enable pfd %d: %s\n", + prog->name, pfd, libbpf_strerror_r(err, errmsg, sizeof(errmsg))); + return ERR_PTR(err); + } + return link; +} + +/* + * this function is expected to parse integer in the range of [0, 2^31-1] from + * given file using scanf format string fmt. If actual parsed value is + * negative, the result might be indistinguishable from error + */ +static int parse_uint_from_file(const char *file, const char *fmt) +{ + char buf[STRERR_BUFSIZE]; + int err, ret; + FILE *f; + + f = fopen(file, "r"); + if (!f) { + err = -errno; + pr_debug("failed to open '%s': %s\n", file, + libbpf_strerror_r(err, buf, sizeof(buf))); + return err; + } + err = fscanf(f, fmt, &ret); + if (err != 1) { + err = err == EOF ? -EIO : -errno; + pr_debug("failed to parse '%s': %s\n", file, + libbpf_strerror_r(err, buf, sizeof(buf))); + fclose(f); + return err; + } + fclose(f); + return ret; +} + +static int determine_kprobe_perf_type(void) +{ + const char *file = "/sys/bus/event_source/devices/kprobe/type"; + + return parse_uint_from_file(file, "%d\n"); +} + +static int determine_uprobe_perf_type(void) +{ + const char *file = "/sys/bus/event_source/devices/uprobe/type"; + + return parse_uint_from_file(file, "%d\n"); +} + +static int determine_kprobe_retprobe_bit(void) +{ + const char *file = "/sys/bus/event_source/devices/kprobe/format/retprobe"; + + return parse_uint_from_file(file, "config:%d\n"); +} + +static int determine_uprobe_retprobe_bit(void) +{ + const char *file = "/sys/bus/event_source/devices/uprobe/format/retprobe"; + + return parse_uint_from_file(file, "config:%d\n"); +} + +static int perf_event_open_probe(bool uprobe, bool retprobe, const char *name, + uint64_t offset, int pid) +{ + struct perf_event_attr attr = {}; + char errmsg[STRERR_BUFSIZE]; + int type, pfd, err; + + type = uprobe ? determine_uprobe_perf_type() + : determine_kprobe_perf_type(); + if (type < 0) { + pr_warn("failed to determine %s perf type: %s\n", + uprobe ? "uprobe" : "kprobe", + libbpf_strerror_r(type, errmsg, sizeof(errmsg))); + return type; + } + if (retprobe) { + int bit = uprobe ? determine_uprobe_retprobe_bit() + : determine_kprobe_retprobe_bit(); + + if (bit < 0) { + pr_warn("failed to determine %s retprobe bit: %s\n", + uprobe ? "uprobe" : "kprobe", + libbpf_strerror_r(bit, errmsg, sizeof(errmsg))); + return bit; + } + attr.config |= 1 << bit; + } + attr.size = sizeof(attr); + attr.type = type; + attr.config1 = ptr_to_u64(name); /* kprobe_func or uprobe_path */ + attr.config2 = offset; /* kprobe_addr or probe_offset */ + + /* pid filter is meaningful only for uprobes */ + pfd = syscall(__NR_perf_event_open, &attr, + pid < 0 ? -1 : pid /* pid */, + pid == -1 ? 0 : -1 /* cpu */, + -1 /* group_fd */, PERF_FLAG_FD_CLOEXEC); + if (pfd < 0) { + err = -errno; + pr_warn("%s perf_event_open() failed: %s\n", + uprobe ? "uprobe" : "kprobe", + libbpf_strerror_r(err, errmsg, sizeof(errmsg))); + return err; + } + return pfd; +} + +struct bpf_link *bpf_program__attach_kprobe(struct bpf_program *prog, + bool retprobe, + const char *func_name) +{ + char errmsg[STRERR_BUFSIZE]; + struct bpf_link *link; + int pfd, err; + + pfd = perf_event_open_probe(false /* uprobe */, retprobe, func_name, + 0 /* offset */, -1 /* pid */); + if (pfd < 0) { + pr_warn("prog '%s': failed to create %s '%s' perf event: %s\n", + prog->name, retprobe ? "kretprobe" : "kprobe", func_name, + libbpf_strerror_r(pfd, errmsg, sizeof(errmsg))); + return ERR_PTR(pfd); + } + link = bpf_program__attach_perf_event(prog, pfd); + if (IS_ERR(link)) { + close(pfd); + err = PTR_ERR(link); + pr_warn("prog '%s': failed to attach to %s '%s': %s\n", + prog->name, retprobe ? "kretprobe" : "kprobe", func_name, + libbpf_strerror_r(err, errmsg, sizeof(errmsg))); + return link; + } + return link; +} + +static struct bpf_link *attach_kprobe(const struct bpf_sec_def *sec, + struct bpf_program *prog) +{ + const char *func_name; + bool retprobe; + + func_name = prog->sec_name + sec->len; + retprobe = strcmp(sec->sec, "kretprobe/") == 0; + + return bpf_program__attach_kprobe(prog, retprobe, func_name); +} + +struct bpf_link *bpf_program__attach_uprobe(struct bpf_program *prog, + bool retprobe, pid_t pid, + const char *binary_path, + size_t func_offset) +{ + char errmsg[STRERR_BUFSIZE]; + struct bpf_link *link; + int pfd, err; + + pfd = perf_event_open_probe(true /* uprobe */, retprobe, + binary_path, func_offset, pid); + if (pfd < 0) { + pr_warn("prog '%s': failed to create %s '%s:0x%zx' perf event: %s\n", + prog->name, retprobe ? "uretprobe" : "uprobe", + binary_path, func_offset, + libbpf_strerror_r(pfd, errmsg, sizeof(errmsg))); + return ERR_PTR(pfd); + } + link = bpf_program__attach_perf_event(prog, pfd); + if (IS_ERR(link)) { + close(pfd); + err = PTR_ERR(link); + pr_warn("prog '%s': failed to attach to %s '%s:0x%zx': %s\n", + prog->name, retprobe ? "uretprobe" : "uprobe", + binary_path, func_offset, + libbpf_strerror_r(err, errmsg, sizeof(errmsg))); + return link; + } + return link; +} + +static int determine_tracepoint_id(const char *tp_category, + const char *tp_name) +{ + char file[PATH_MAX]; + int ret; + + ret = snprintf(file, sizeof(file), + "/sys/kernel/debug/tracing/events/%s/%s/id", + tp_category, tp_name); + if (ret < 0) + return -errno; + if (ret >= sizeof(file)) { + pr_debug("tracepoint %s/%s path is too long\n", + tp_category, tp_name); + return -E2BIG; + } + return parse_uint_from_file(file, "%d\n"); +} + +static int perf_event_open_tracepoint(const char *tp_category, + const char *tp_name) +{ + struct perf_event_attr attr = {}; + char errmsg[STRERR_BUFSIZE]; + int tp_id, pfd, err; + + tp_id = determine_tracepoint_id(tp_category, tp_name); + if (tp_id < 0) { + pr_warn("failed to determine tracepoint '%s/%s' perf event ID: %s\n", + tp_category, tp_name, + libbpf_strerror_r(tp_id, errmsg, sizeof(errmsg))); + return tp_id; + } + + attr.type = PERF_TYPE_TRACEPOINT; + attr.size = sizeof(attr); + attr.config = tp_id; + + pfd = syscall(__NR_perf_event_open, &attr, -1 /* pid */, 0 /* cpu */, + -1 /* group_fd */, PERF_FLAG_FD_CLOEXEC); + if (pfd < 0) { + err = -errno; + pr_warn("tracepoint '%s/%s' perf_event_open() failed: %s\n", + tp_category, tp_name, + libbpf_strerror_r(err, errmsg, sizeof(errmsg))); + return err; + } + return pfd; +} + +struct bpf_link *bpf_program__attach_tracepoint(struct bpf_program *prog, + const char *tp_category, + const char *tp_name) +{ + char errmsg[STRERR_BUFSIZE]; + struct bpf_link *link; + int pfd, err; + + pfd = perf_event_open_tracepoint(tp_category, tp_name); + if (pfd < 0) { + pr_warn("prog '%s': failed to create tracepoint '%s/%s' perf event: %s\n", + prog->name, tp_category, tp_name, + libbpf_strerror_r(pfd, errmsg, sizeof(errmsg))); + return ERR_PTR(pfd); + } + link = bpf_program__attach_perf_event(prog, pfd); + if (IS_ERR(link)) { + close(pfd); + err = PTR_ERR(link); + pr_warn("prog '%s': failed to attach to tracepoint '%s/%s': %s\n", + prog->name, tp_category, tp_name, + libbpf_strerror_r(err, errmsg, sizeof(errmsg))); + return link; + } + return link; +} + +static struct bpf_link *attach_tp(const struct bpf_sec_def *sec, + struct bpf_program *prog) +{ + char *sec_name, *tp_cat, *tp_name; + struct bpf_link *link; + + sec_name = strdup(prog->sec_name); + if (!sec_name) + return ERR_PTR(-ENOMEM); + + /* extract "tp//" */ + tp_cat = sec_name + sec->len; + tp_name = strchr(tp_cat, '/'); + if (!tp_name) { + link = ERR_PTR(-EINVAL); + goto out; + } + *tp_name = '\0'; + tp_name++; + + link = bpf_program__attach_tracepoint(prog, tp_cat, tp_name); +out: + free(sec_name); + return link; +} + +struct bpf_link *bpf_program__attach_raw_tracepoint(struct bpf_program *prog, + const char *tp_name) +{ + char errmsg[STRERR_BUFSIZE]; + struct bpf_link *link; + int prog_fd, pfd; + + prog_fd = bpf_program__fd(prog); + if (prog_fd < 0) { + pr_warn("prog '%s': can't attach before loaded\n", prog->name); + return ERR_PTR(-EINVAL); + } + + link = calloc(1, sizeof(*link)); + if (!link) + return ERR_PTR(-ENOMEM); + link->detach = &bpf_link__detach_fd; + + pfd = bpf_raw_tracepoint_open(tp_name, prog_fd); + if (pfd < 0) { + pfd = -errno; + free(link); + pr_warn("prog '%s': failed to attach to raw tracepoint '%s': %s\n", + prog->name, tp_name, libbpf_strerror_r(pfd, errmsg, sizeof(errmsg))); + return ERR_PTR(pfd); + } + link->fd = pfd; + return link; +} + +static struct bpf_link *attach_raw_tp(const struct bpf_sec_def *sec, + struct bpf_program *prog) +{ + const char *tp_name = prog->sec_name + sec->len; + + return bpf_program__attach_raw_tracepoint(prog, tp_name); +} + +/* Common logic for all BPF program types that attach to a btf_id */ +static struct bpf_link *bpf_program__attach_btf_id(struct bpf_program *prog) +{ + char errmsg[STRERR_BUFSIZE]; + struct bpf_link *link; + int prog_fd, pfd; + + prog_fd = bpf_program__fd(prog); + if (prog_fd < 0) { + pr_warn("prog '%s': can't attach before loaded\n", prog->name); + return ERR_PTR(-EINVAL); + } + + link = calloc(1, sizeof(*link)); + if (!link) + return ERR_PTR(-ENOMEM); + link->detach = &bpf_link__detach_fd; + + pfd = bpf_raw_tracepoint_open(NULL, prog_fd); + if (pfd < 0) { + pfd = -errno; + free(link); + pr_warn("prog '%s': failed to attach: %s\n", + prog->name, libbpf_strerror_r(pfd, errmsg, sizeof(errmsg))); + return ERR_PTR(pfd); + } + link->fd = pfd; + return (struct bpf_link *)link; +} + +struct bpf_link *bpf_program__attach_trace(struct bpf_program *prog) +{ + return bpf_program__attach_btf_id(prog); +} + +struct bpf_link *bpf_program__attach_lsm(struct bpf_program *prog) +{ + return bpf_program__attach_btf_id(prog); +} + +static struct bpf_link *attach_trace(const struct bpf_sec_def *sec, + struct bpf_program *prog) +{ + return bpf_program__attach_trace(prog); +} + +static struct bpf_link *attach_lsm(const struct bpf_sec_def *sec, + struct bpf_program *prog) +{ + return bpf_program__attach_lsm(prog); +} + +static struct bpf_link *attach_iter(const struct bpf_sec_def *sec, + struct bpf_program *prog) +{ + return bpf_program__attach_iter(prog, NULL); +} + +static struct bpf_link * +bpf_program__attach_fd(struct bpf_program *prog, int target_fd, int btf_id, + const char *target_name) +{ + DECLARE_LIBBPF_OPTS(bpf_link_create_opts, opts, + .target_btf_id = btf_id); + enum bpf_attach_type attach_type; + char errmsg[STRERR_BUFSIZE]; + struct bpf_link *link; + int prog_fd, link_fd; + + prog_fd = bpf_program__fd(prog); + if (prog_fd < 0) { + pr_warn("prog '%s': can't attach before loaded\n", prog->name); + return ERR_PTR(-EINVAL); + } + + link = calloc(1, sizeof(*link)); + if (!link) + return ERR_PTR(-ENOMEM); + link->detach = &bpf_link__detach_fd; + + attach_type = bpf_program__get_expected_attach_type(prog); + link_fd = bpf_link_create(prog_fd, target_fd, attach_type, &opts); + if (link_fd < 0) { + link_fd = -errno; + free(link); + pr_warn("prog '%s': failed to attach to %s: %s\n", + prog->name, target_name, + libbpf_strerror_r(link_fd, errmsg, sizeof(errmsg))); + return ERR_PTR(link_fd); + } + link->fd = link_fd; + return link; +} + +struct bpf_link * +bpf_program__attach_cgroup(struct bpf_program *prog, int cgroup_fd) +{ + return bpf_program__attach_fd(prog, cgroup_fd, 0, "cgroup"); +} + +struct bpf_link * +bpf_program__attach_netns(struct bpf_program *prog, int netns_fd) +{ + return bpf_program__attach_fd(prog, netns_fd, 0, "netns"); +} + +struct bpf_link *bpf_program__attach_xdp(struct bpf_program *prog, int ifindex) +{ + /* target_fd/target_ifindex use the same field in LINK_CREATE */ + return bpf_program__attach_fd(prog, ifindex, 0, "xdp"); +} + +struct bpf_link *bpf_program__attach_freplace(struct bpf_program *prog, + int target_fd, + const char *attach_func_name) +{ + int btf_id; + + if (!!target_fd != !!attach_func_name) { + pr_warn("prog '%s': supply none or both of target_fd and attach_func_name\n", + prog->name); + return ERR_PTR(-EINVAL); + } + + if (prog->type != BPF_PROG_TYPE_EXT) { + pr_warn("prog '%s': only BPF_PROG_TYPE_EXT can attach as freplace", + prog->name); + return ERR_PTR(-EINVAL); + } + + if (target_fd) { + btf_id = libbpf_find_prog_btf_id(attach_func_name, target_fd); + if (btf_id < 0) + return ERR_PTR(btf_id); + + return bpf_program__attach_fd(prog, target_fd, btf_id, "freplace"); + } else { + /* no target, so use raw_tracepoint_open for compatibility + * with old kernels + */ + return bpf_program__attach_trace(prog); + } +} + +struct bpf_link * +bpf_program__attach_iter(struct bpf_program *prog, + const struct bpf_iter_attach_opts *opts) +{ + DECLARE_LIBBPF_OPTS(bpf_link_create_opts, link_create_opts); + char errmsg[STRERR_BUFSIZE]; + struct bpf_link *link; + int prog_fd, link_fd; + __u32 target_fd = 0; + + if (!OPTS_VALID(opts, bpf_iter_attach_opts)) + return ERR_PTR(-EINVAL); + + link_create_opts.iter_info = OPTS_GET(opts, link_info, (void *)0); + link_create_opts.iter_info_len = OPTS_GET(opts, link_info_len, 0); + + prog_fd = bpf_program__fd(prog); + if (prog_fd < 0) { + pr_warn("prog '%s': can't attach before loaded\n", prog->name); + return ERR_PTR(-EINVAL); + } + + link = calloc(1, sizeof(*link)); + if (!link) + return ERR_PTR(-ENOMEM); + link->detach = &bpf_link__detach_fd; + + link_fd = bpf_link_create(prog_fd, target_fd, BPF_TRACE_ITER, + &link_create_opts); + if (link_fd < 0) { + link_fd = -errno; + free(link); + pr_warn("prog '%s': failed to attach to iterator: %s\n", + prog->name, libbpf_strerror_r(link_fd, errmsg, sizeof(errmsg))); + return ERR_PTR(link_fd); + } + link->fd = link_fd; + return link; +} + +struct bpf_link *bpf_program__attach(struct bpf_program *prog) +{ + const struct bpf_sec_def *sec_def; + + sec_def = find_sec_def(prog->sec_name); + if (!sec_def || !sec_def->attach_fn) + return ERR_PTR(-ESRCH); + + return sec_def->attach_fn(sec_def, prog); +} + +static int bpf_link__detach_struct_ops(struct bpf_link *link) +{ + __u32 zero = 0; + + if (bpf_map_delete_elem(link->fd, &zero)) + return -errno; + + return 0; +} + +struct bpf_link *bpf_map__attach_struct_ops(struct bpf_map *map) +{ + struct bpf_struct_ops *st_ops; + struct bpf_link *link; + __u32 i, zero = 0; + int err; + + if (!bpf_map__is_struct_ops(map) || map->fd == -1) + return ERR_PTR(-EINVAL); + + link = calloc(1, sizeof(*link)); + if (!link) + return ERR_PTR(-EINVAL); + + st_ops = map->st_ops; + for (i = 0; i < btf_vlen(st_ops->type); i++) { + struct bpf_program *prog = st_ops->progs[i]; + void *kern_data; + int prog_fd; + + if (!prog) + continue; + + prog_fd = bpf_program__fd(prog); + kern_data = st_ops->kern_vdata + st_ops->kern_func_off[i]; + *(unsigned long *)kern_data = prog_fd; + } + + err = bpf_map_update_elem(map->fd, &zero, st_ops->kern_vdata, 0); + if (err) { + err = -errno; + free(link); + return ERR_PTR(err); + } + + link->detach = bpf_link__detach_struct_ops; + link->fd = map->fd; + + return link; +} + +enum bpf_perf_event_ret +bpf_perf_event_read_simple(void *mmap_mem, size_t mmap_size, size_t page_size, + void **copy_mem, size_t *copy_size, + bpf_perf_event_print_t fn, void *private_data) +{ + struct perf_event_mmap_page *header = mmap_mem; + __u64 data_head = ring_buffer_read_head(header); + __u64 data_tail = header->data_tail; + void *base = ((__u8 *)header) + page_size; + int ret = LIBBPF_PERF_EVENT_CONT; + struct perf_event_header *ehdr; + size_t ehdr_size; + + while (data_head != data_tail) { + ehdr = base + (data_tail & (mmap_size - 1)); + ehdr_size = ehdr->size; + + if (((void *)ehdr) + ehdr_size > base + mmap_size) { + void *copy_start = ehdr; + size_t len_first = base + mmap_size - copy_start; + size_t len_secnd = ehdr_size - len_first; + + if (*copy_size < ehdr_size) { + free(*copy_mem); + *copy_mem = malloc(ehdr_size); + if (!*copy_mem) { + *copy_size = 0; + ret = LIBBPF_PERF_EVENT_ERROR; + break; + } + *copy_size = ehdr_size; + } + + memcpy(*copy_mem, copy_start, len_first); + memcpy(*copy_mem + len_first, base, len_secnd); + ehdr = *copy_mem; + } + + ret = fn(ehdr, private_data); + data_tail += ehdr_size; + if (ret != LIBBPF_PERF_EVENT_CONT) + break; + } + + ring_buffer_write_tail(header, data_tail); + return ret; +} + +struct perf_buffer; + +struct perf_buffer_params { + struct perf_event_attr *attr; + /* if event_cb is specified, it takes precendence */ + perf_buffer_event_fn event_cb; + /* sample_cb and lost_cb are higher-level common-case callbacks */ + perf_buffer_sample_fn sample_cb; + perf_buffer_lost_fn lost_cb; + void *ctx; + int cpu_cnt; + int *cpus; + int *map_keys; +}; + +struct perf_cpu_buf { + struct perf_buffer *pb; + void *base; /* mmap()'ed memory */ + void *buf; /* for reconstructing segmented data */ + size_t buf_size; + int fd; + int cpu; + int map_key; +}; + +struct perf_buffer { + perf_buffer_event_fn event_cb; + perf_buffer_sample_fn sample_cb; + perf_buffer_lost_fn lost_cb; + void *ctx; /* passed into callbacks */ + + size_t page_size; + size_t mmap_size; + struct perf_cpu_buf **cpu_bufs; + struct epoll_event *events; + int cpu_cnt; /* number of allocated CPU buffers */ + int epoll_fd; /* perf event FD */ + int map_fd; /* BPF_MAP_TYPE_PERF_EVENT_ARRAY BPF map FD */ +}; + +static void perf_buffer__free_cpu_buf(struct perf_buffer *pb, + struct perf_cpu_buf *cpu_buf) +{ + if (!cpu_buf) + return; + if (cpu_buf->base && + munmap(cpu_buf->base, pb->mmap_size + pb->page_size)) + pr_warn("failed to munmap cpu_buf #%d\n", cpu_buf->cpu); + if (cpu_buf->fd >= 0) { + ioctl(cpu_buf->fd, PERF_EVENT_IOC_DISABLE, 0); + close(cpu_buf->fd); + } + free(cpu_buf->buf); + free(cpu_buf); +} + +void perf_buffer__free(struct perf_buffer *pb) +{ + int i; + + if (IS_ERR_OR_NULL(pb)) + return; + if (pb->cpu_bufs) { + for (i = 0; i < pb->cpu_cnt; i++) { + struct perf_cpu_buf *cpu_buf = pb->cpu_bufs[i]; + + if (!cpu_buf) + continue; + + bpf_map_delete_elem(pb->map_fd, &cpu_buf->map_key); + perf_buffer__free_cpu_buf(pb, cpu_buf); + } + free(pb->cpu_bufs); + } + if (pb->epoll_fd >= 0) + close(pb->epoll_fd); + free(pb->events); + free(pb); +} + +static struct perf_cpu_buf * +perf_buffer__open_cpu_buf(struct perf_buffer *pb, struct perf_event_attr *attr, + int cpu, int map_key) +{ + struct perf_cpu_buf *cpu_buf; + char msg[STRERR_BUFSIZE]; + int err; + + cpu_buf = calloc(1, sizeof(*cpu_buf)); + if (!cpu_buf) + return ERR_PTR(-ENOMEM); + + cpu_buf->pb = pb; + cpu_buf->cpu = cpu; + cpu_buf->map_key = map_key; + + cpu_buf->fd = syscall(__NR_perf_event_open, attr, -1 /* pid */, cpu, + -1, PERF_FLAG_FD_CLOEXEC); + if (cpu_buf->fd < 0) { + err = -errno; + pr_warn("failed to open perf buffer event on cpu #%d: %s\n", + cpu, libbpf_strerror_r(err, msg, sizeof(msg))); + goto error; + } + + cpu_buf->base = mmap(NULL, pb->mmap_size + pb->page_size, + PROT_READ | PROT_WRITE, MAP_SHARED, + cpu_buf->fd, 0); + if (cpu_buf->base == MAP_FAILED) { + cpu_buf->base = NULL; + err = -errno; + pr_warn("failed to mmap perf buffer on cpu #%d: %s\n", + cpu, libbpf_strerror_r(err, msg, sizeof(msg))); + goto error; + } + + if (ioctl(cpu_buf->fd, PERF_EVENT_IOC_ENABLE, 0) < 0) { + err = -errno; + pr_warn("failed to enable perf buffer event on cpu #%d: %s\n", + cpu, libbpf_strerror_r(err, msg, sizeof(msg))); + goto error; + } + + return cpu_buf; + +error: + perf_buffer__free_cpu_buf(pb, cpu_buf); + return (struct perf_cpu_buf *)ERR_PTR(err); +} + +static struct perf_buffer *__perf_buffer__new(int map_fd, size_t page_cnt, + struct perf_buffer_params *p); + +struct perf_buffer *perf_buffer__new(int map_fd, size_t page_cnt, + const struct perf_buffer_opts *opts) +{ + struct perf_buffer_params p = {}; + struct perf_event_attr attr = { 0, }; + + attr.config = PERF_COUNT_SW_BPF_OUTPUT; + attr.type = PERF_TYPE_SOFTWARE; + attr.sample_type = PERF_SAMPLE_RAW; + attr.sample_period = 1; + attr.wakeup_events = 1; + + p.attr = &attr; + p.sample_cb = opts ? opts->sample_cb : NULL; + p.lost_cb = opts ? opts->lost_cb : NULL; + p.ctx = opts ? opts->ctx : NULL; + + return __perf_buffer__new(map_fd, page_cnt, &p); +} + +struct perf_buffer * +perf_buffer__new_raw(int map_fd, size_t page_cnt, + const struct perf_buffer_raw_opts *opts) +{ + struct perf_buffer_params p = {}; + + p.attr = opts->attr; + p.event_cb = opts->event_cb; + p.ctx = opts->ctx; + p.cpu_cnt = opts->cpu_cnt; + p.cpus = opts->cpus; + p.map_keys = opts->map_keys; + + return __perf_buffer__new(map_fd, page_cnt, &p); +} + +static struct perf_buffer *__perf_buffer__new(int map_fd, size_t page_cnt, + struct perf_buffer_params *p) +{ + const char *online_cpus_file = "/sys/devices/system/cpu/online"; + struct bpf_map_info map; + char msg[STRERR_BUFSIZE]; + struct perf_buffer *pb; + bool *online = NULL; + __u32 map_info_len; + int err, i, j, n; + + if (page_cnt & (page_cnt - 1)) { + pr_warn("page count should be power of two, but is %zu\n", + page_cnt); + return ERR_PTR(-EINVAL); + } + + /* best-effort sanity checks */ + memset(&map, 0, sizeof(map)); + map_info_len = sizeof(map); + err = bpf_obj_get_info_by_fd(map_fd, &map, &map_info_len); + if (err) { + err = -errno; + /* if BPF_OBJ_GET_INFO_BY_FD is supported, will return + * -EBADFD, -EFAULT, or -E2BIG on real error + */ + if (err != -EINVAL) { + pr_warn("failed to get map info for map FD %d: %s\n", + map_fd, libbpf_strerror_r(err, msg, sizeof(msg))); + return ERR_PTR(err); + } + pr_debug("failed to get map info for FD %d; API not supported? Ignoring...\n", + map_fd); + } else { + if (map.type != BPF_MAP_TYPE_PERF_EVENT_ARRAY) { + pr_warn("map '%s' should be BPF_MAP_TYPE_PERF_EVENT_ARRAY\n", + map.name); + return ERR_PTR(-EINVAL); + } + } + + pb = calloc(1, sizeof(*pb)); + if (!pb) + return ERR_PTR(-ENOMEM); + + pb->event_cb = p->event_cb; + pb->sample_cb = p->sample_cb; + pb->lost_cb = p->lost_cb; + pb->ctx = p->ctx; + + pb->page_size = getpagesize(); + pb->mmap_size = pb->page_size * page_cnt; + pb->map_fd = map_fd; + + pb->epoll_fd = epoll_create1(EPOLL_CLOEXEC); + if (pb->epoll_fd < 0) { + err = -errno; + pr_warn("failed to create epoll instance: %s\n", + libbpf_strerror_r(err, msg, sizeof(msg))); + goto error; + } + + if (p->cpu_cnt > 0) { + pb->cpu_cnt = p->cpu_cnt; + } else { + pb->cpu_cnt = libbpf_num_possible_cpus(); + if (pb->cpu_cnt < 0) { + err = pb->cpu_cnt; + goto error; + } + if (map.max_entries && map.max_entries < pb->cpu_cnt) + pb->cpu_cnt = map.max_entries; + } + + pb->events = calloc(pb->cpu_cnt, sizeof(*pb->events)); + if (!pb->events) { + err = -ENOMEM; + pr_warn("failed to allocate events: out of memory\n"); + goto error; + } + pb->cpu_bufs = calloc(pb->cpu_cnt, sizeof(*pb->cpu_bufs)); + if (!pb->cpu_bufs) { + err = -ENOMEM; + pr_warn("failed to allocate buffers: out of memory\n"); + goto error; + } + + err = parse_cpu_mask_file(online_cpus_file, &online, &n); + if (err) { + pr_warn("failed to get online CPU mask: %d\n", err); + goto error; + } + + for (i = 0, j = 0; i < pb->cpu_cnt; i++) { + struct perf_cpu_buf *cpu_buf; + int cpu, map_key; + + cpu = p->cpu_cnt > 0 ? p->cpus[i] : i; + map_key = p->cpu_cnt > 0 ? p->map_keys[i] : i; + + /* in case user didn't explicitly requested particular CPUs to + * be attached to, skip offline/not present CPUs + */ + if (p->cpu_cnt <= 0 && (cpu >= n || !online[cpu])) + continue; + + cpu_buf = perf_buffer__open_cpu_buf(pb, p->attr, cpu, map_key); + if (IS_ERR(cpu_buf)) { + err = PTR_ERR(cpu_buf); + goto error; + } + + pb->cpu_bufs[j] = cpu_buf; + + err = bpf_map_update_elem(pb->map_fd, &map_key, + &cpu_buf->fd, 0); + if (err) { + err = -errno; + pr_warn("failed to set cpu #%d, key %d -> perf FD %d: %s\n", + cpu, map_key, cpu_buf->fd, + libbpf_strerror_r(err, msg, sizeof(msg))); + goto error; + } + + pb->events[j].events = EPOLLIN; + pb->events[j].data.ptr = cpu_buf; + if (epoll_ctl(pb->epoll_fd, EPOLL_CTL_ADD, cpu_buf->fd, + &pb->events[j]) < 0) { + err = -errno; + pr_warn("failed to epoll_ctl cpu #%d perf FD %d: %s\n", + cpu, cpu_buf->fd, + libbpf_strerror_r(err, msg, sizeof(msg))); + goto error; + } + j++; + } + pb->cpu_cnt = j; + free(online); + + return pb; + +error: + free(online); + if (pb) + perf_buffer__free(pb); + return ERR_PTR(err); +} + +struct perf_sample_raw { + struct perf_event_header header; + uint32_t size; + char data[]; +}; + +struct perf_sample_lost { + struct perf_event_header header; + uint64_t id; + uint64_t lost; + uint64_t sample_id; +}; + +static enum bpf_perf_event_ret +perf_buffer__process_record(struct perf_event_header *e, void *ctx) +{ + struct perf_cpu_buf *cpu_buf = ctx; + struct perf_buffer *pb = cpu_buf->pb; + void *data = e; + + /* user wants full control over parsing perf event */ + if (pb->event_cb) + return pb->event_cb(pb->ctx, cpu_buf->cpu, e); + + switch (e->type) { + case PERF_RECORD_SAMPLE: { + struct perf_sample_raw *s = data; + + if (pb->sample_cb) + pb->sample_cb(pb->ctx, cpu_buf->cpu, s->data, s->size); + break; + } + case PERF_RECORD_LOST: { + struct perf_sample_lost *s = data; + + if (pb->lost_cb) + pb->lost_cb(pb->ctx, cpu_buf->cpu, s->lost); + break; + } + default: + pr_warn("unknown perf sample type %d\n", e->type); + return LIBBPF_PERF_EVENT_ERROR; + } + return LIBBPF_PERF_EVENT_CONT; +} + +static int perf_buffer__process_records(struct perf_buffer *pb, + struct perf_cpu_buf *cpu_buf) +{ + enum bpf_perf_event_ret ret; + + ret = bpf_perf_event_read_simple(cpu_buf->base, pb->mmap_size, + pb->page_size, &cpu_buf->buf, + &cpu_buf->buf_size, + perf_buffer__process_record, cpu_buf); + if (ret != LIBBPF_PERF_EVENT_CONT) + return ret; + return 0; +} + +int perf_buffer__epoll_fd(const struct perf_buffer *pb) +{ + return pb->epoll_fd; +} + +int perf_buffer__poll(struct perf_buffer *pb, int timeout_ms) +{ + int i, cnt, err; + + cnt = epoll_wait(pb->epoll_fd, pb->events, pb->cpu_cnt, timeout_ms); + for (i = 0; i < cnt; i++) { + struct perf_cpu_buf *cpu_buf = pb->events[i].data.ptr; + + err = perf_buffer__process_records(pb, cpu_buf); + if (err) { + pr_warn("error while processing records: %d\n", err); + return err; + } + } + return cnt < 0 ? -errno : cnt; +} + +/* Return number of PERF_EVENT_ARRAY map slots set up by this perf_buffer + * manager. + */ +size_t perf_buffer__buffer_cnt(const struct perf_buffer *pb) +{ + return pb->cpu_cnt; +} + +/* + * Return perf_event FD of a ring buffer in *buf_idx* slot of + * PERF_EVENT_ARRAY BPF map. This FD can be polled for new data using + * select()/poll()/epoll() Linux syscalls. + */ +int perf_buffer__buffer_fd(const struct perf_buffer *pb, size_t buf_idx) +{ + struct perf_cpu_buf *cpu_buf; + + if (buf_idx >= pb->cpu_cnt) + return -EINVAL; + + cpu_buf = pb->cpu_bufs[buf_idx]; + if (!cpu_buf) + return -ENOENT; + + return cpu_buf->fd; +} + +/* + * Consume data from perf ring buffer corresponding to slot *buf_idx* in + * PERF_EVENT_ARRAY BPF map without waiting/polling. If there is no data to + * consume, do nothing and return success. + * Returns: + * - 0 on success; + * - <0 on failure. + */ +int perf_buffer__consume_buffer(struct perf_buffer *pb, size_t buf_idx) +{ + struct perf_cpu_buf *cpu_buf; + + if (buf_idx >= pb->cpu_cnt) + return -EINVAL; + + cpu_buf = pb->cpu_bufs[buf_idx]; + if (!cpu_buf) + return -ENOENT; + + return perf_buffer__process_records(pb, cpu_buf); +} + +int perf_buffer__consume(struct perf_buffer *pb) +{ + int i, err; + + for (i = 0; i < pb->cpu_cnt; i++) { + struct perf_cpu_buf *cpu_buf = pb->cpu_bufs[i]; + + if (!cpu_buf) + continue; + + err = perf_buffer__process_records(pb, cpu_buf); + if (err) { + pr_warn("perf_buffer: failed to process records in buffer #%d: %d\n", i, err); + return err; + } + } + return 0; +} + +struct bpf_prog_info_array_desc { + int array_offset; /* e.g. offset of jited_prog_insns */ + int count_offset; /* e.g. offset of jited_prog_len */ + int size_offset; /* > 0: offset of rec size, + * < 0: fix size of -size_offset + */ +}; + +static struct bpf_prog_info_array_desc bpf_prog_info_array_desc[] = { + [BPF_PROG_INFO_JITED_INSNS] = { + offsetof(struct bpf_prog_info, jited_prog_insns), + offsetof(struct bpf_prog_info, jited_prog_len), + -1, + }, + [BPF_PROG_INFO_XLATED_INSNS] = { + offsetof(struct bpf_prog_info, xlated_prog_insns), + offsetof(struct bpf_prog_info, xlated_prog_len), + -1, + }, + [BPF_PROG_INFO_MAP_IDS] = { + offsetof(struct bpf_prog_info, map_ids), + offsetof(struct bpf_prog_info, nr_map_ids), + -(int)sizeof(__u32), + }, + [BPF_PROG_INFO_JITED_KSYMS] = { + offsetof(struct bpf_prog_info, jited_ksyms), + offsetof(struct bpf_prog_info, nr_jited_ksyms), + -(int)sizeof(__u64), + }, + [BPF_PROG_INFO_JITED_FUNC_LENS] = { + offsetof(struct bpf_prog_info, jited_func_lens), + offsetof(struct bpf_prog_info, nr_jited_func_lens), + -(int)sizeof(__u32), + }, + [BPF_PROG_INFO_FUNC_INFO] = { + offsetof(struct bpf_prog_info, func_info), + offsetof(struct bpf_prog_info, nr_func_info), + offsetof(struct bpf_prog_info, func_info_rec_size), + }, + [BPF_PROG_INFO_LINE_INFO] = { + offsetof(struct bpf_prog_info, line_info), + offsetof(struct bpf_prog_info, nr_line_info), + offsetof(struct bpf_prog_info, line_info_rec_size), + }, + [BPF_PROG_INFO_JITED_LINE_INFO] = { + offsetof(struct bpf_prog_info, jited_line_info), + offsetof(struct bpf_prog_info, nr_jited_line_info), + offsetof(struct bpf_prog_info, jited_line_info_rec_size), + }, + [BPF_PROG_INFO_PROG_TAGS] = { + offsetof(struct bpf_prog_info, prog_tags), + offsetof(struct bpf_prog_info, nr_prog_tags), + -(int)sizeof(__u8) * BPF_TAG_SIZE, + }, + +}; + +static __u32 bpf_prog_info_read_offset_u32(struct bpf_prog_info *info, + int offset) +{ + __u32 *array = (__u32 *)info; + + if (offset >= 0) + return array[offset / sizeof(__u32)]; + return -(int)offset; +} + +static __u64 bpf_prog_info_read_offset_u64(struct bpf_prog_info *info, + int offset) +{ + __u64 *array = (__u64 *)info; + + if (offset >= 0) + return array[offset / sizeof(__u64)]; + return -(int)offset; +} + +static void bpf_prog_info_set_offset_u32(struct bpf_prog_info *info, int offset, + __u32 val) +{ + __u32 *array = (__u32 *)info; + + if (offset >= 0) + array[offset / sizeof(__u32)] = val; +} + +static void bpf_prog_info_set_offset_u64(struct bpf_prog_info *info, int offset, + __u64 val) +{ + __u64 *array = (__u64 *)info; + + if (offset >= 0) + array[offset / sizeof(__u64)] = val; +} + +struct bpf_prog_info_linear * +bpf_program__get_prog_info_linear(int fd, __u64 arrays) +{ + struct bpf_prog_info_linear *info_linear; + struct bpf_prog_info info = {}; + __u32 info_len = sizeof(info); + __u32 data_len = 0; + int i, err; + void *ptr; + + if (arrays >> BPF_PROG_INFO_LAST_ARRAY) + return ERR_PTR(-EINVAL); + + /* step 1: get array dimensions */ + err = bpf_obj_get_info_by_fd(fd, &info, &info_len); + if (err) { + pr_debug("can't get prog info: %s", strerror(errno)); + return ERR_PTR(-EFAULT); + } + + /* step 2: calculate total size of all arrays */ + for (i = BPF_PROG_INFO_FIRST_ARRAY; i < BPF_PROG_INFO_LAST_ARRAY; ++i) { + bool include_array = (arrays & (1UL << i)) > 0; + struct bpf_prog_info_array_desc *desc; + __u32 count, size; + + desc = bpf_prog_info_array_desc + i; + + /* kernel is too old to support this field */ + if (info_len < desc->array_offset + sizeof(__u32) || + info_len < desc->count_offset + sizeof(__u32) || + (desc->size_offset > 0 && info_len < desc->size_offset)) + include_array = false; + + if (!include_array) { + arrays &= ~(1UL << i); /* clear the bit */ + continue; + } + + count = bpf_prog_info_read_offset_u32(&info, desc->count_offset); + size = bpf_prog_info_read_offset_u32(&info, desc->size_offset); + + data_len += count * size; + } + + /* step 3: allocate continuous memory */ + data_len = roundup(data_len, sizeof(__u64)); + info_linear = malloc(sizeof(struct bpf_prog_info_linear) + data_len); + if (!info_linear) + return ERR_PTR(-ENOMEM); + + /* step 4: fill data to info_linear->info */ + info_linear->arrays = arrays; + memset(&info_linear->info, 0, sizeof(info)); + ptr = info_linear->data; + + for (i = BPF_PROG_INFO_FIRST_ARRAY; i < BPF_PROG_INFO_LAST_ARRAY; ++i) { + struct bpf_prog_info_array_desc *desc; + __u32 count, size; + + if ((arrays & (1UL << i)) == 0) + continue; + + desc = bpf_prog_info_array_desc + i; + count = bpf_prog_info_read_offset_u32(&info, desc->count_offset); + size = bpf_prog_info_read_offset_u32(&info, desc->size_offset); + bpf_prog_info_set_offset_u32(&info_linear->info, + desc->count_offset, count); + bpf_prog_info_set_offset_u32(&info_linear->info, + desc->size_offset, size); + bpf_prog_info_set_offset_u64(&info_linear->info, + desc->array_offset, + ptr_to_u64(ptr)); + ptr += count * size; + } + + /* step 5: call syscall again to get required arrays */ + err = bpf_obj_get_info_by_fd(fd, &info_linear->info, &info_len); + if (err) { + pr_debug("can't get prog info: %s", strerror(errno)); + free(info_linear); + return ERR_PTR(-EFAULT); + } + + /* step 6: verify the data */ + for (i = BPF_PROG_INFO_FIRST_ARRAY; i < BPF_PROG_INFO_LAST_ARRAY; ++i) { + struct bpf_prog_info_array_desc *desc; + __u32 v1, v2; + + if ((arrays & (1UL << i)) == 0) + continue; + + desc = bpf_prog_info_array_desc + i; + v1 = bpf_prog_info_read_offset_u32(&info, desc->count_offset); + v2 = bpf_prog_info_read_offset_u32(&info_linear->info, + desc->count_offset); + if (v1 != v2) + pr_warn("%s: mismatch in element count\n", __func__); + + v1 = bpf_prog_info_read_offset_u32(&info, desc->size_offset); + v2 = bpf_prog_info_read_offset_u32(&info_linear->info, + desc->size_offset); + if (v1 != v2) + pr_warn("%s: mismatch in rec size\n", __func__); + } + + /* step 7: update info_len and data_len */ + info_linear->info_len = sizeof(struct bpf_prog_info); + info_linear->data_len = data_len; + + return info_linear; +} + +void bpf_program__bpil_addr_to_offs(struct bpf_prog_info_linear *info_linear) +{ + int i; + + for (i = BPF_PROG_INFO_FIRST_ARRAY; i < BPF_PROG_INFO_LAST_ARRAY; ++i) { + struct bpf_prog_info_array_desc *desc; + __u64 addr, offs; + + if ((info_linear->arrays & (1UL << i)) == 0) + continue; + + desc = bpf_prog_info_array_desc + i; + addr = bpf_prog_info_read_offset_u64(&info_linear->info, + desc->array_offset); + offs = addr - ptr_to_u64(info_linear->data); + bpf_prog_info_set_offset_u64(&info_linear->info, + desc->array_offset, offs); + } +} + +void bpf_program__bpil_offs_to_addr(struct bpf_prog_info_linear *info_linear) +{ + int i; + + for (i = BPF_PROG_INFO_FIRST_ARRAY; i < BPF_PROG_INFO_LAST_ARRAY; ++i) { + struct bpf_prog_info_array_desc *desc; + __u64 addr, offs; + + if ((info_linear->arrays & (1UL << i)) == 0) + continue; + + desc = bpf_prog_info_array_desc + i; + offs = bpf_prog_info_read_offset_u64(&info_linear->info, + desc->array_offset); + addr = offs + ptr_to_u64(info_linear->data); + bpf_prog_info_set_offset_u64(&info_linear->info, + desc->array_offset, addr); + } +} + +int bpf_program__set_attach_target(struct bpf_program *prog, + int attach_prog_fd, + const char *attach_func_name) +{ + int btf_obj_fd = 0, btf_id = 0, err; + + if (!prog || attach_prog_fd < 0 || !attach_func_name) + return -EINVAL; + + if (prog->obj->loaded) + return -EINVAL; + + if (attach_prog_fd) { + btf_id = libbpf_find_prog_btf_id(attach_func_name, + attach_prog_fd); + if (btf_id < 0) + return btf_id; + } else { + /* load btf_vmlinux, if not yet */ + err = bpf_object__load_vmlinux_btf(prog->obj, true); + if (err) + return err; + err = find_kernel_btf_id(prog->obj, attach_func_name, + prog->expected_attach_type, + &btf_obj_fd, &btf_id); + if (err) + return err; + } + + prog->attach_btf_id = btf_id; + prog->attach_btf_obj_fd = btf_obj_fd; + prog->attach_prog_fd = attach_prog_fd; + return 0; +} + +int parse_cpu_mask_str(const char *s, bool **mask, int *mask_sz) +{ + int err = 0, n, len, start, end = -1; + bool *tmp; + + *mask = NULL; + *mask_sz = 0; + + /* Each sub string separated by ',' has format \d+-\d+ or \d+ */ + while (*s) { + if (*s == ',' || *s == '\n') { + s++; + continue; + } + n = sscanf(s, "%d%n-%d%n", &start, &len, &end, &len); + if (n <= 0 || n > 2) { + pr_warn("Failed to get CPU range %s: %d\n", s, n); + err = -EINVAL; + goto cleanup; + } else if (n == 1) { + end = start; + } + if (start < 0 || start > end) { + pr_warn("Invalid CPU range [%d,%d] in %s\n", + start, end, s); + err = -EINVAL; + goto cleanup; + } + tmp = realloc(*mask, end + 1); + if (!tmp) { + err = -ENOMEM; + goto cleanup; + } + *mask = tmp; + memset(tmp + *mask_sz, 0, start - *mask_sz); + memset(tmp + start, 1, end - start + 1); + *mask_sz = end + 1; + s += len; + } + if (!*mask_sz) { + pr_warn("Empty CPU range\n"); + return -EINVAL; + } + return 0; +cleanup: + free(*mask); + *mask = NULL; + return err; +} + +int parse_cpu_mask_file(const char *fcpu, bool **mask, int *mask_sz) +{ + int fd, err = 0, len; + char buf[128]; + + fd = open(fcpu, O_RDONLY); + if (fd < 0) { + err = -errno; + pr_warn("Failed to open cpu mask file %s: %d\n", fcpu, err); + return err; + } + len = read(fd, buf, sizeof(buf)); + close(fd); + if (len <= 0) { + err = len ? -errno : -EINVAL; + pr_warn("Failed to read cpu mask from %s: %d\n", fcpu, err); + return err; + } + if (len >= sizeof(buf)) { + pr_warn("CPU mask is too big in file %s\n", fcpu); + return -E2BIG; + } + buf[len] = '\0'; + + return parse_cpu_mask_str(buf, mask, mask_sz); +} + +int libbpf_num_possible_cpus(void) +{ + static const char *fcpu = "/sys/devices/system/cpu/possible"; + static int cpus; + int err, n, i, tmp_cpus; + bool *mask; + + tmp_cpus = READ_ONCE(cpus); + if (tmp_cpus > 0) + return tmp_cpus; + + err = parse_cpu_mask_file(fcpu, &mask, &n); + if (err) + return err; + + tmp_cpus = 0; + for (i = 0; i < n; i++) { + if (mask[i]) + tmp_cpus++; + } + free(mask); + + WRITE_ONCE(cpus, tmp_cpus); + return tmp_cpus; +} + +int bpf_object__open_skeleton(struct bpf_object_skeleton *s, + const struct bpf_object_open_opts *opts) +{ + DECLARE_LIBBPF_OPTS(bpf_object_open_opts, skel_opts, + .object_name = s->name, + ); + struct bpf_object *obj; + int i; + + /* Attempt to preserve opts->object_name, unless overriden by user + * explicitly. Overwriting object name for skeletons is discouraged, + * as it breaks global data maps, because they contain object name + * prefix as their own map name prefix. When skeleton is generated, + * bpftool is making an assumption that this name will stay the same. + */ + if (opts) { + memcpy(&skel_opts, opts, sizeof(*opts)); + if (!opts->object_name) + skel_opts.object_name = s->name; + } + + obj = bpf_object__open_mem(s->data, s->data_sz, &skel_opts); + if (IS_ERR(obj)) { + pr_warn("failed to initialize skeleton BPF object '%s': %ld\n", + s->name, PTR_ERR(obj)); + return PTR_ERR(obj); + } + + *s->obj = obj; + + for (i = 0; i < s->map_cnt; i++) { + struct bpf_map **map = s->maps[i].map; + const char *name = s->maps[i].name; + void **mmaped = s->maps[i].mmaped; + + *map = bpf_object__find_map_by_name(obj, name); + if (!*map) { + pr_warn("failed to find skeleton map '%s'\n", name); + return -ESRCH; + } + + /* externs shouldn't be pre-setup from user code */ + if (mmaped && (*map)->libbpf_type != LIBBPF_MAP_KCONFIG) + *mmaped = (*map)->mmaped; + } + + for (i = 0; i < s->prog_cnt; i++) { + struct bpf_program **prog = s->progs[i].prog; + const char *name = s->progs[i].name; + + *prog = bpf_object__find_program_by_name(obj, name); + if (!*prog) { + pr_warn("failed to find skeleton program '%s'\n", name); + return -ESRCH; + } + } + + return 0; +} + +int bpf_object__load_skeleton(struct bpf_object_skeleton *s) +{ + int i, err; + + err = bpf_object__load(*s->obj); + if (err) { + pr_warn("failed to load BPF skeleton '%s': %d\n", s->name, err); + return err; + } + + for (i = 0; i < s->map_cnt; i++) { + struct bpf_map *map = *s->maps[i].map; + size_t mmap_sz = bpf_map_mmap_sz(map); + int prot, map_fd = bpf_map__fd(map); + void **mmaped = s->maps[i].mmaped; + + if (!mmaped) + continue; + + if (!(map->def.map_flags & BPF_F_MMAPABLE)) { + *mmaped = NULL; + continue; + } + + if (map->def.map_flags & BPF_F_RDONLY_PROG) + prot = PROT_READ; + else + prot = PROT_READ | PROT_WRITE; + + /* Remap anonymous mmap()-ed "map initialization image" as + * a BPF map-backed mmap()-ed memory, but preserving the same + * memory address. This will cause kernel to change process' + * page table to point to a different piece of kernel memory, + * but from userspace point of view memory address (and its + * contents, being identical at this point) will stay the + * same. This mapping will be released by bpf_object__close() + * as per normal clean up procedure, so we don't need to worry + * about it from skeleton's clean up perspective. + */ + *mmaped = mmap(map->mmaped, mmap_sz, prot, + MAP_SHARED | MAP_FIXED, map_fd, 0); + if (*mmaped == MAP_FAILED) { + err = -errno; + *mmaped = NULL; + pr_warn("failed to re-mmap() map '%s': %d\n", + bpf_map__name(map), err); + return err; + } + } + + return 0; +} + +int bpf_object__attach_skeleton(struct bpf_object_skeleton *s) +{ + int i; + + for (i = 0; i < s->prog_cnt; i++) { + struct bpf_program *prog = *s->progs[i].prog; + struct bpf_link **link = s->progs[i].link; + const struct bpf_sec_def *sec_def; + + if (!prog->load) + continue; + + sec_def = find_sec_def(prog->sec_name); + if (!sec_def || !sec_def->attach_fn) + continue; + + *link = sec_def->attach_fn(sec_def, prog); + if (IS_ERR(*link)) { + pr_warn("failed to auto-attach program '%s': %ld\n", + bpf_program__name(prog), PTR_ERR(*link)); + return PTR_ERR(*link); + } + } + + return 0; +} + +void bpf_object__detach_skeleton(struct bpf_object_skeleton *s) +{ + int i; + + for (i = 0; i < s->prog_cnt; i++) { + struct bpf_link **link = s->progs[i].link; + + bpf_link__destroy(*link); + *link = NULL; + } +} + +void bpf_object__destroy_skeleton(struct bpf_object_skeleton *s) +{ + if (s->progs) + bpf_object__detach_skeleton(s); + if (s->obj) + bpf_object__close(*s->obj); + free(s->maps); + free(s->progs); + free(s); +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/libbpf_common.h dwarves-dfsg-1.21/lib/bpf/src/libbpf_common.h --- dwarves-dfsg-1.10/lib/bpf/src/libbpf_common.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/libbpf_common.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +/* + * Common user-facing libbpf helpers. + * + * Copyright (c) 2019 Facebook + */ + +#ifndef __LIBBPF_LIBBPF_COMMON_H +#define __LIBBPF_LIBBPF_COMMON_H + +#include + +#ifndef LIBBPF_API +#define LIBBPF_API __attribute__((visibility("default"))) +#endif + +#define LIBBPF_DEPRECATED(msg) __attribute__((deprecated(msg))) + +/* Helper macro to declare and initialize libbpf options struct + * + * This dance with uninitialized declaration, followed by memset to zero, + * followed by assignment using compound literal syntax is done to preserve + * ability to use a nice struct field initialization syntax and **hopefully** + * have all the padding bytes initialized to zero. It's not guaranteed though, + * when copying literal, that compiler won't copy garbage in literal's padding + * bytes, but that's the best way I've found and it seems to work in practice. + * + * Macro declares opts struct of given type and name, zero-initializes, + * including any extra padding, it with memset() and then assigns initial + * values provided by users in struct initializer-syntax as varargs. + */ +#define DECLARE_LIBBPF_OPTS(TYPE, NAME, ...) \ + struct TYPE NAME = ({ \ + memset(&NAME, 0, sizeof(struct TYPE)); \ + (struct TYPE) { \ + .sz = sizeof(struct TYPE), \ + __VA_ARGS__ \ + }; \ + }) + +#endif /* __LIBBPF_LIBBPF_COMMON_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/src/libbpf_errno.c dwarves-dfsg-1.21/lib/bpf/src/libbpf_errno.c --- dwarves-dfsg-1.10/lib/bpf/src/libbpf_errno.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/libbpf_errno.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +/* + * Copyright (C) 2013-2015 Alexei Starovoitov + * Copyright (C) 2015 Wang Nan + * Copyright (C) 2015 Huawei Inc. + * Copyright (C) 2017 Nicira, Inc. + */ + +#undef _GNU_SOURCE +#include +#include + +#include "libbpf.h" + +/* make sure libbpf doesn't use kernel-only integer typedefs */ +#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64 + +#define ERRNO_OFFSET(e) ((e) - __LIBBPF_ERRNO__START) +#define ERRCODE_OFFSET(c) ERRNO_OFFSET(LIBBPF_ERRNO__##c) +#define NR_ERRNO (__LIBBPF_ERRNO__END - __LIBBPF_ERRNO__START) + +static const char *libbpf_strerror_table[NR_ERRNO] = { + [ERRCODE_OFFSET(LIBELF)] = "Something wrong in libelf", + [ERRCODE_OFFSET(FORMAT)] = "BPF object format invalid", + [ERRCODE_OFFSET(KVERSION)] = "'version' section incorrect or lost", + [ERRCODE_OFFSET(ENDIAN)] = "Endian mismatch", + [ERRCODE_OFFSET(INTERNAL)] = "Internal error in libbpf", + [ERRCODE_OFFSET(RELOC)] = "Relocation failed", + [ERRCODE_OFFSET(VERIFY)] = "Kernel verifier blocks program loading", + [ERRCODE_OFFSET(PROG2BIG)] = "Program too big", + [ERRCODE_OFFSET(KVER)] = "Incorrect kernel version", + [ERRCODE_OFFSET(PROGTYPE)] = "Kernel doesn't support this program type", + [ERRCODE_OFFSET(WRNGPID)] = "Wrong pid in netlink message", + [ERRCODE_OFFSET(INVSEQ)] = "Invalid netlink sequence", + [ERRCODE_OFFSET(NLPARSE)] = "Incorrect netlink message parsing", +}; + +int libbpf_strerror(int err, char *buf, size_t size) +{ + if (!buf || !size) + return -1; + + err = err > 0 ? err : -err; + + if (err < __LIBBPF_ERRNO__START) { + int ret; + + ret = strerror_r(err, buf, size); + buf[size - 1] = '\0'; + return ret; + } + + if (err < __LIBBPF_ERRNO__END) { + const char *msg; + + msg = libbpf_strerror_table[ERRNO_OFFSET(err)]; + snprintf(buf, size, "%s", msg); + buf[size - 1] = '\0'; + return 0; + } + + snprintf(buf, size, "Unknown libbpf error %d", err); + buf[size - 1] = '\0'; + return -1; +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/libbpf.h dwarves-dfsg-1.21/lib/bpf/src/libbpf.h --- dwarves-dfsg-1.10/lib/bpf/src/libbpf.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/libbpf.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,766 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +/* + * Common eBPF ELF object loading operations. + * + * Copyright (C) 2013-2015 Alexei Starovoitov + * Copyright (C) 2015 Wang Nan + * Copyright (C) 2015 Huawei Inc. + */ +#ifndef __LIBBPF_LIBBPF_H +#define __LIBBPF_LIBBPF_H + +#include +#include +#include +#include +#include // for size_t +#include + +#include "libbpf_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum libbpf_errno { + __LIBBPF_ERRNO__START = 4000, + + /* Something wrong in libelf */ + LIBBPF_ERRNO__LIBELF = __LIBBPF_ERRNO__START, + LIBBPF_ERRNO__FORMAT, /* BPF object format invalid */ + LIBBPF_ERRNO__KVERSION, /* Incorrect or no 'version' section */ + LIBBPF_ERRNO__ENDIAN, /* Endian mismatch */ + LIBBPF_ERRNO__INTERNAL, /* Internal error in libbpf */ + LIBBPF_ERRNO__RELOC, /* Relocation failed */ + LIBBPF_ERRNO__LOAD, /* Load program failure for unknown reason */ + LIBBPF_ERRNO__VERIFY, /* Kernel verifier blocks program loading */ + LIBBPF_ERRNO__PROG2BIG, /* Program too big */ + LIBBPF_ERRNO__KVER, /* Incorrect kernel version */ + LIBBPF_ERRNO__PROGTYPE, /* Kernel doesn't support this program type */ + LIBBPF_ERRNO__WRNGPID, /* Wrong pid in netlink message */ + LIBBPF_ERRNO__INVSEQ, /* Invalid netlink sequence */ + LIBBPF_ERRNO__NLPARSE, /* netlink parsing error */ + __LIBBPF_ERRNO__END, +}; + +LIBBPF_API int libbpf_strerror(int err, char *buf, size_t size); + +enum libbpf_print_level { + LIBBPF_WARN, + LIBBPF_INFO, + LIBBPF_DEBUG, +}; + +typedef int (*libbpf_print_fn_t)(enum libbpf_print_level level, + const char *, va_list ap); + +LIBBPF_API libbpf_print_fn_t libbpf_set_print(libbpf_print_fn_t fn); + +/* Hide internal to user */ +struct bpf_object; + +struct bpf_object_open_attr { + const char *file; + enum bpf_prog_type prog_type; +}; + +struct bpf_object_open_opts { + /* size of this struct, for forward/backward compatiblity */ + size_t sz; + /* object name override, if provided: + * - for object open from file, this will override setting object + * name from file path's base name; + * - for object open from memory buffer, this will specify an object + * name and will override default "-" name; + */ + const char *object_name; + /* parse map definitions non-strictly, allowing extra attributes/data */ + bool relaxed_maps; + /* DEPRECATED: handle CO-RE relocations non-strictly, allowing failures. + * Value is ignored. Relocations always are processed non-strictly. + * Non-relocatable instructions are replaced with invalid ones to + * prevent accidental errors. + * */ + bool relaxed_core_relocs; + /* maps that set the 'pinning' attribute in their definition will have + * their pin_path attribute set to a file in this directory, and be + * auto-pinned to that path on load; defaults to "/sys/fs/bpf". + */ + const char *pin_root_path; + __u32 attach_prog_fd; + /* Additional kernel config content that augments and overrides + * system Kconfig for CONFIG_xxx externs. + */ + const char *kconfig; +}; +#define bpf_object_open_opts__last_field kconfig + +LIBBPF_API struct bpf_object *bpf_object__open(const char *path); +LIBBPF_API struct bpf_object * +bpf_object__open_file(const char *path, const struct bpf_object_open_opts *opts); +LIBBPF_API struct bpf_object * +bpf_object__open_mem(const void *obj_buf, size_t obj_buf_sz, + const struct bpf_object_open_opts *opts); + +/* deprecated bpf_object__open variants */ +LIBBPF_API struct bpf_object * +bpf_object__open_buffer(const void *obj_buf, size_t obj_buf_sz, + const char *name); +LIBBPF_API struct bpf_object * +bpf_object__open_xattr(struct bpf_object_open_attr *attr); + +enum libbpf_pin_type { + LIBBPF_PIN_NONE, + /* PIN_BY_NAME: pin maps by name (in /sys/fs/bpf by default) */ + LIBBPF_PIN_BY_NAME, +}; + +/* pin_maps and unpin_maps can both be called with a NULL path, in which case + * they will use the pin_path attribute of each map (and ignore all maps that + * don't have a pin_path set). + */ +LIBBPF_API int bpf_object__pin_maps(struct bpf_object *obj, const char *path); +LIBBPF_API int bpf_object__unpin_maps(struct bpf_object *obj, + const char *path); +LIBBPF_API int bpf_object__pin_programs(struct bpf_object *obj, + const char *path); +LIBBPF_API int bpf_object__unpin_programs(struct bpf_object *obj, + const char *path); +LIBBPF_API int bpf_object__pin(struct bpf_object *object, const char *path); +LIBBPF_API void bpf_object__close(struct bpf_object *object); + +struct bpf_object_load_attr { + struct bpf_object *obj; + int log_level; + const char *target_btf_path; +}; + +/* Load/unload object into/from kernel */ +LIBBPF_API int bpf_object__load(struct bpf_object *obj); +LIBBPF_API int bpf_object__load_xattr(struct bpf_object_load_attr *attr); +LIBBPF_API int bpf_object__unload(struct bpf_object *obj); + +LIBBPF_API const char *bpf_object__name(const struct bpf_object *obj); +LIBBPF_API unsigned int bpf_object__kversion(const struct bpf_object *obj); + +struct btf; +LIBBPF_API struct btf *bpf_object__btf(const struct bpf_object *obj); +LIBBPF_API int bpf_object__btf_fd(const struct bpf_object *obj); + +LIBBPF_API struct bpf_program * +bpf_object__find_program_by_title(const struct bpf_object *obj, + const char *title); +LIBBPF_API struct bpf_program * +bpf_object__find_program_by_name(const struct bpf_object *obj, + const char *name); + +LIBBPF_API struct bpf_object *bpf_object__next(struct bpf_object *prev); +#define bpf_object__for_each_safe(pos, tmp) \ + for ((pos) = bpf_object__next(NULL), \ + (tmp) = bpf_object__next(pos); \ + (pos) != NULL; \ + (pos) = (tmp), (tmp) = bpf_object__next(tmp)) + +typedef void (*bpf_object_clear_priv_t)(struct bpf_object *, void *); +LIBBPF_API int bpf_object__set_priv(struct bpf_object *obj, void *priv, + bpf_object_clear_priv_t clear_priv); +LIBBPF_API void *bpf_object__priv(const struct bpf_object *prog); + +LIBBPF_API int +libbpf_prog_type_by_name(const char *name, enum bpf_prog_type *prog_type, + enum bpf_attach_type *expected_attach_type); +LIBBPF_API int libbpf_attach_type_by_name(const char *name, + enum bpf_attach_type *attach_type); +LIBBPF_API int libbpf_find_vmlinux_btf_id(const char *name, + enum bpf_attach_type attach_type); + +/* Accessors of bpf_program */ +struct bpf_program; +LIBBPF_API struct bpf_program *bpf_program__next(struct bpf_program *prog, + const struct bpf_object *obj); + +#define bpf_object__for_each_program(pos, obj) \ + for ((pos) = bpf_program__next(NULL, (obj)); \ + (pos) != NULL; \ + (pos) = bpf_program__next((pos), (obj))) + +LIBBPF_API struct bpf_program *bpf_program__prev(struct bpf_program *prog, + const struct bpf_object *obj); + +typedef void (*bpf_program_clear_priv_t)(struct bpf_program *, void *); + +LIBBPF_API int bpf_program__set_priv(struct bpf_program *prog, void *priv, + bpf_program_clear_priv_t clear_priv); + +LIBBPF_API void *bpf_program__priv(const struct bpf_program *prog); +LIBBPF_API void bpf_program__set_ifindex(struct bpf_program *prog, + __u32 ifindex); + +LIBBPF_API const char *bpf_program__name(const struct bpf_program *prog); +LIBBPF_API const char *bpf_program__section_name(const struct bpf_program *prog); +LIBBPF_API LIBBPF_DEPRECATED("BPF program title is confusing term; please use bpf_program__section_name() instead") +const char *bpf_program__title(const struct bpf_program *prog, bool needs_copy); +LIBBPF_API bool bpf_program__autoload(const struct bpf_program *prog); +LIBBPF_API int bpf_program__set_autoload(struct bpf_program *prog, bool autoload); + +/* returns program size in bytes */ +LIBBPF_API size_t bpf_program__size(const struct bpf_program *prog); + +LIBBPF_API int bpf_program__load(struct bpf_program *prog, char *license, + __u32 kern_version); +LIBBPF_API int bpf_program__fd(const struct bpf_program *prog); +LIBBPF_API int bpf_program__pin_instance(struct bpf_program *prog, + const char *path, + int instance); +LIBBPF_API int bpf_program__unpin_instance(struct bpf_program *prog, + const char *path, + int instance); +LIBBPF_API int bpf_program__pin(struct bpf_program *prog, const char *path); +LIBBPF_API int bpf_program__unpin(struct bpf_program *prog, const char *path); +LIBBPF_API void bpf_program__unload(struct bpf_program *prog); + +struct bpf_link; + +LIBBPF_API struct bpf_link *bpf_link__open(const char *path); +LIBBPF_API int bpf_link__fd(const struct bpf_link *link); +LIBBPF_API const char *bpf_link__pin_path(const struct bpf_link *link); +LIBBPF_API int bpf_link__pin(struct bpf_link *link, const char *path); +LIBBPF_API int bpf_link__unpin(struct bpf_link *link); +LIBBPF_API int bpf_link__update_program(struct bpf_link *link, + struct bpf_program *prog); +LIBBPF_API void bpf_link__disconnect(struct bpf_link *link); +LIBBPF_API int bpf_link__detach(struct bpf_link *link); +LIBBPF_API int bpf_link__destroy(struct bpf_link *link); + +LIBBPF_API struct bpf_link * +bpf_program__attach(struct bpf_program *prog); +LIBBPF_API struct bpf_link * +bpf_program__attach_perf_event(struct bpf_program *prog, int pfd); +LIBBPF_API struct bpf_link * +bpf_program__attach_kprobe(struct bpf_program *prog, bool retprobe, + const char *func_name); +LIBBPF_API struct bpf_link * +bpf_program__attach_uprobe(struct bpf_program *prog, bool retprobe, + pid_t pid, const char *binary_path, + size_t func_offset); +LIBBPF_API struct bpf_link * +bpf_program__attach_tracepoint(struct bpf_program *prog, + const char *tp_category, + const char *tp_name); +LIBBPF_API struct bpf_link * +bpf_program__attach_raw_tracepoint(struct bpf_program *prog, + const char *tp_name); +LIBBPF_API struct bpf_link * +bpf_program__attach_trace(struct bpf_program *prog); +LIBBPF_API struct bpf_link * +bpf_program__attach_lsm(struct bpf_program *prog); +LIBBPF_API struct bpf_link * +bpf_program__attach_cgroup(struct bpf_program *prog, int cgroup_fd); +LIBBPF_API struct bpf_link * +bpf_program__attach_netns(struct bpf_program *prog, int netns_fd); +LIBBPF_API struct bpf_link * +bpf_program__attach_xdp(struct bpf_program *prog, int ifindex); +LIBBPF_API struct bpf_link * +bpf_program__attach_freplace(struct bpf_program *prog, + int target_fd, const char *attach_func_name); + +struct bpf_map; + +LIBBPF_API struct bpf_link *bpf_map__attach_struct_ops(struct bpf_map *map); + +struct bpf_iter_attach_opts { + size_t sz; /* size of this struct for forward/backward compatibility */ + union bpf_iter_link_info *link_info; + __u32 link_info_len; +}; +#define bpf_iter_attach_opts__last_field link_info_len + +LIBBPF_API struct bpf_link * +bpf_program__attach_iter(struct bpf_program *prog, + const struct bpf_iter_attach_opts *opts); + +struct bpf_insn; + +/* + * Libbpf allows callers to adjust BPF programs before being loaded + * into kernel. One program in an object file can be transformed into + * multiple variants to be attached to different hooks. + * + * bpf_program_prep_t, bpf_program__set_prep and bpf_program__nth_fd + * form an API for this purpose. + * + * - bpf_program_prep_t: + * Defines a 'preprocessor', which is a caller defined function + * passed to libbpf through bpf_program__set_prep(), and will be + * called before program is loaded. The processor should adjust + * the program one time for each instance according to the instance id + * passed to it. + * + * - bpf_program__set_prep: + * Attaches a preprocessor to a BPF program. The number of instances + * that should be created is also passed through this function. + * + * - bpf_program__nth_fd: + * After the program is loaded, get resulting FD of a given instance + * of the BPF program. + * + * If bpf_program__set_prep() is not used, the program would be loaded + * without adjustment during bpf_object__load(). The program has only + * one instance. In this case bpf_program__fd(prog) is equal to + * bpf_program__nth_fd(prog, 0). + */ + +struct bpf_prog_prep_result { + /* + * If not NULL, load new instruction array. + * If set to NULL, don't load this instance. + */ + struct bpf_insn *new_insn_ptr; + int new_insn_cnt; + + /* If not NULL, result FD is written to it. */ + int *pfd; +}; + +/* + * Parameters of bpf_program_prep_t: + * - prog: The bpf_program being loaded. + * - n: Index of instance being generated. + * - insns: BPF instructions array. + * - insns_cnt:Number of instructions in insns. + * - res: Output parameter, result of transformation. + * + * Return value: + * - Zero: pre-processing success. + * - Non-zero: pre-processing error, stop loading. + */ +typedef int (*bpf_program_prep_t)(struct bpf_program *prog, int n, + struct bpf_insn *insns, int insns_cnt, + struct bpf_prog_prep_result *res); + +LIBBPF_API int bpf_program__set_prep(struct bpf_program *prog, int nr_instance, + bpf_program_prep_t prep); + +LIBBPF_API int bpf_program__nth_fd(const struct bpf_program *prog, int n); + +/* + * Adjust type of BPF program. Default is kprobe. + */ +LIBBPF_API int bpf_program__set_socket_filter(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_tracepoint(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_raw_tracepoint(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_kprobe(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_lsm(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_sched_cls(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_sched_act(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_xdp(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_perf_event(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_tracing(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_struct_ops(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_extension(struct bpf_program *prog); +LIBBPF_API int bpf_program__set_sk_lookup(struct bpf_program *prog); + +LIBBPF_API enum bpf_prog_type bpf_program__get_type(struct bpf_program *prog); +LIBBPF_API void bpf_program__set_type(struct bpf_program *prog, + enum bpf_prog_type type); + +LIBBPF_API enum bpf_attach_type +bpf_program__get_expected_attach_type(struct bpf_program *prog); +LIBBPF_API void +bpf_program__set_expected_attach_type(struct bpf_program *prog, + enum bpf_attach_type type); + +LIBBPF_API int +bpf_program__set_attach_target(struct bpf_program *prog, int attach_prog_fd, + const char *attach_func_name); + +LIBBPF_API bool bpf_program__is_socket_filter(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_tracepoint(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_raw_tracepoint(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_kprobe(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_lsm(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_sched_cls(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_sched_act(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_xdp(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_perf_event(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_tracing(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_struct_ops(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_extension(const struct bpf_program *prog); +LIBBPF_API bool bpf_program__is_sk_lookup(const struct bpf_program *prog); + +/* + * No need for __attribute__((packed)), all members of 'bpf_map_def' + * are all aligned. In addition, using __attribute__((packed)) + * would trigger a -Wpacked warning message, and lead to an error + * if -Werror is set. + */ +struct bpf_map_def { + unsigned int type; + unsigned int key_size; + unsigned int value_size; + unsigned int max_entries; + unsigned int map_flags; +}; + +/* + * The 'struct bpf_map' in include/linux/bpf.h is internal to the kernel, + * so no need to worry about a name clash. + */ +LIBBPF_API struct bpf_map * +bpf_object__find_map_by_name(const struct bpf_object *obj, const char *name); + +LIBBPF_API int +bpf_object__find_map_fd_by_name(const struct bpf_object *obj, const char *name); + +/* + * Get bpf_map through the offset of corresponding struct bpf_map_def + * in the BPF object file. + */ +LIBBPF_API struct bpf_map * +bpf_object__find_map_by_offset(struct bpf_object *obj, size_t offset); + +LIBBPF_API struct bpf_map * +bpf_map__next(const struct bpf_map *map, const struct bpf_object *obj); +#define bpf_object__for_each_map(pos, obj) \ + for ((pos) = bpf_map__next(NULL, (obj)); \ + (pos) != NULL; \ + (pos) = bpf_map__next((pos), (obj))) +#define bpf_map__for_each bpf_object__for_each_map + +LIBBPF_API struct bpf_map * +bpf_map__prev(const struct bpf_map *map, const struct bpf_object *obj); + +/* get/set map FD */ +LIBBPF_API int bpf_map__fd(const struct bpf_map *map); +LIBBPF_API int bpf_map__reuse_fd(struct bpf_map *map, int fd); +/* get map definition */ +LIBBPF_API const struct bpf_map_def *bpf_map__def(const struct bpf_map *map); +/* get map name */ +LIBBPF_API const char *bpf_map__name(const struct bpf_map *map); +/* get/set map type */ +LIBBPF_API enum bpf_map_type bpf_map__type(const struct bpf_map *map); +LIBBPF_API int bpf_map__set_type(struct bpf_map *map, enum bpf_map_type type); +/* get/set map size (max_entries) */ +LIBBPF_API __u32 bpf_map__max_entries(const struct bpf_map *map); +LIBBPF_API int bpf_map__set_max_entries(struct bpf_map *map, __u32 max_entries); +LIBBPF_API int bpf_map__resize(struct bpf_map *map, __u32 max_entries); +/* get/set map flags */ +LIBBPF_API __u32 bpf_map__map_flags(const struct bpf_map *map); +LIBBPF_API int bpf_map__set_map_flags(struct bpf_map *map, __u32 flags); +/* get/set map NUMA node */ +LIBBPF_API __u32 bpf_map__numa_node(const struct bpf_map *map); +LIBBPF_API int bpf_map__set_numa_node(struct bpf_map *map, __u32 numa_node); +/* get/set map key size */ +LIBBPF_API __u32 bpf_map__key_size(const struct bpf_map *map); +LIBBPF_API int bpf_map__set_key_size(struct bpf_map *map, __u32 size); +/* get/set map value size */ +LIBBPF_API __u32 bpf_map__value_size(const struct bpf_map *map); +LIBBPF_API int bpf_map__set_value_size(struct bpf_map *map, __u32 size); +/* get map key/value BTF type IDs */ +LIBBPF_API __u32 bpf_map__btf_key_type_id(const struct bpf_map *map); +LIBBPF_API __u32 bpf_map__btf_value_type_id(const struct bpf_map *map); +/* get/set map if_index */ +LIBBPF_API __u32 bpf_map__ifindex(const struct bpf_map *map); +LIBBPF_API int bpf_map__set_ifindex(struct bpf_map *map, __u32 ifindex); + +typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *); +LIBBPF_API int bpf_map__set_priv(struct bpf_map *map, void *priv, + bpf_map_clear_priv_t clear_priv); +LIBBPF_API void *bpf_map__priv(const struct bpf_map *map); +LIBBPF_API int bpf_map__set_initial_value(struct bpf_map *map, + const void *data, size_t size); +LIBBPF_API bool bpf_map__is_offload_neutral(const struct bpf_map *map); +LIBBPF_API bool bpf_map__is_internal(const struct bpf_map *map); +LIBBPF_API int bpf_map__set_pin_path(struct bpf_map *map, const char *path); +LIBBPF_API const char *bpf_map__get_pin_path(const struct bpf_map *map); +LIBBPF_API bool bpf_map__is_pinned(const struct bpf_map *map); +LIBBPF_API int bpf_map__pin(struct bpf_map *map, const char *path); +LIBBPF_API int bpf_map__unpin(struct bpf_map *map, const char *path); + +LIBBPF_API int bpf_map__set_inner_map_fd(struct bpf_map *map, int fd); + +LIBBPF_API long libbpf_get_error(const void *ptr); + +struct bpf_prog_load_attr { + const char *file; + enum bpf_prog_type prog_type; + enum bpf_attach_type expected_attach_type; + int ifindex; + int log_level; + int prog_flags; +}; + +LIBBPF_API int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr, + struct bpf_object **pobj, int *prog_fd); +LIBBPF_API int bpf_prog_load(const char *file, enum bpf_prog_type type, + struct bpf_object **pobj, int *prog_fd); + +struct xdp_link_info { + __u32 prog_id; + __u32 drv_prog_id; + __u32 hw_prog_id; + __u32 skb_prog_id; + __u8 attach_mode; +}; + +struct bpf_xdp_set_link_opts { + size_t sz; + int old_fd; +}; +#define bpf_xdp_set_link_opts__last_field old_fd + +LIBBPF_API int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags); +LIBBPF_API int bpf_set_link_xdp_fd_opts(int ifindex, int fd, __u32 flags, + const struct bpf_xdp_set_link_opts *opts); +LIBBPF_API int bpf_get_link_xdp_id(int ifindex, __u32 *prog_id, __u32 flags); +LIBBPF_API int bpf_get_link_xdp_info(int ifindex, struct xdp_link_info *info, + size_t info_size, __u32 flags); + +/* Ring buffer APIs */ +struct ring_buffer; + +typedef int (*ring_buffer_sample_fn)(void *ctx, void *data, size_t size); + +struct ring_buffer_opts { + size_t sz; /* size of this struct, for forward/backward compatiblity */ +}; + +#define ring_buffer_opts__last_field sz + +LIBBPF_API struct ring_buffer * +ring_buffer__new(int map_fd, ring_buffer_sample_fn sample_cb, void *ctx, + const struct ring_buffer_opts *opts); +LIBBPF_API void ring_buffer__free(struct ring_buffer *rb); +LIBBPF_API int ring_buffer__add(struct ring_buffer *rb, int map_fd, + ring_buffer_sample_fn sample_cb, void *ctx); +LIBBPF_API int ring_buffer__poll(struct ring_buffer *rb, int timeout_ms); +LIBBPF_API int ring_buffer__consume(struct ring_buffer *rb); +LIBBPF_API int ring_buffer__epoll_fd(const struct ring_buffer *rb); + +/* Perf buffer APIs */ +struct perf_buffer; + +typedef void (*perf_buffer_sample_fn)(void *ctx, int cpu, + void *data, __u32 size); +typedef void (*perf_buffer_lost_fn)(void *ctx, int cpu, __u64 cnt); + +/* common use perf buffer options */ +struct perf_buffer_opts { + /* if specified, sample_cb is called for each sample */ + perf_buffer_sample_fn sample_cb; + /* if specified, lost_cb is called for each batch of lost samples */ + perf_buffer_lost_fn lost_cb; + /* ctx is provided to sample_cb and lost_cb */ + void *ctx; +}; + +LIBBPF_API struct perf_buffer * +perf_buffer__new(int map_fd, size_t page_cnt, + const struct perf_buffer_opts *opts); + +enum bpf_perf_event_ret { + LIBBPF_PERF_EVENT_DONE = 0, + LIBBPF_PERF_EVENT_ERROR = -1, + LIBBPF_PERF_EVENT_CONT = -2, +}; + +struct perf_event_header; + +typedef enum bpf_perf_event_ret +(*perf_buffer_event_fn)(void *ctx, int cpu, struct perf_event_header *event); + +/* raw perf buffer options, giving most power and control */ +struct perf_buffer_raw_opts { + /* perf event attrs passed directly into perf_event_open() */ + struct perf_event_attr *attr; + /* raw event callback */ + perf_buffer_event_fn event_cb; + /* ctx is provided to event_cb */ + void *ctx; + /* if cpu_cnt == 0, open all on all possible CPUs (up to the number of + * max_entries of given PERF_EVENT_ARRAY map) + */ + int cpu_cnt; + /* if cpu_cnt > 0, cpus is an array of CPUs to open ring buffers on */ + int *cpus; + /* if cpu_cnt > 0, map_keys specify map keys to set per-CPU FDs for */ + int *map_keys; +}; + +LIBBPF_API struct perf_buffer * +perf_buffer__new_raw(int map_fd, size_t page_cnt, + const struct perf_buffer_raw_opts *opts); + +LIBBPF_API void perf_buffer__free(struct perf_buffer *pb); +LIBBPF_API int perf_buffer__epoll_fd(const struct perf_buffer *pb); +LIBBPF_API int perf_buffer__poll(struct perf_buffer *pb, int timeout_ms); +LIBBPF_API int perf_buffer__consume(struct perf_buffer *pb); +LIBBPF_API int perf_buffer__consume_buffer(struct perf_buffer *pb, size_t buf_idx); +LIBBPF_API size_t perf_buffer__buffer_cnt(const struct perf_buffer *pb); +LIBBPF_API int perf_buffer__buffer_fd(const struct perf_buffer *pb, size_t buf_idx); + +typedef enum bpf_perf_event_ret + (*bpf_perf_event_print_t)(struct perf_event_header *hdr, + void *private_data); +LIBBPF_API enum bpf_perf_event_ret +bpf_perf_event_read_simple(void *mmap_mem, size_t mmap_size, size_t page_size, + void **copy_mem, size_t *copy_size, + bpf_perf_event_print_t fn, void *private_data); + +struct bpf_prog_linfo; +struct bpf_prog_info; + +LIBBPF_API void bpf_prog_linfo__free(struct bpf_prog_linfo *prog_linfo); +LIBBPF_API struct bpf_prog_linfo * +bpf_prog_linfo__new(const struct bpf_prog_info *info); +LIBBPF_API const struct bpf_line_info * +bpf_prog_linfo__lfind_addr_func(const struct bpf_prog_linfo *prog_linfo, + __u64 addr, __u32 func_idx, __u32 nr_skip); +LIBBPF_API const struct bpf_line_info * +bpf_prog_linfo__lfind(const struct bpf_prog_linfo *prog_linfo, + __u32 insn_off, __u32 nr_skip); + +/* + * Probe for supported system features + * + * Note that running many of these probes in a short amount of time can cause + * the kernel to reach the maximal size of lockable memory allowed for the + * user, causing subsequent probes to fail. In this case, the caller may want + * to adjust that limit with setrlimit(). + */ +LIBBPF_API bool bpf_probe_prog_type(enum bpf_prog_type prog_type, + __u32 ifindex); +LIBBPF_API bool bpf_probe_map_type(enum bpf_map_type map_type, __u32 ifindex); +LIBBPF_API bool bpf_probe_helper(enum bpf_func_id id, + enum bpf_prog_type prog_type, __u32 ifindex); +LIBBPF_API bool bpf_probe_large_insn_limit(__u32 ifindex); + +/* + * Get bpf_prog_info in continuous memory + * + * struct bpf_prog_info has multiple arrays. The user has option to choose + * arrays to fetch from kernel. The following APIs provide an uniform way to + * fetch these data. All arrays in bpf_prog_info are stored in a single + * continuous memory region. This makes it easy to store the info in a + * file. + * + * Before writing bpf_prog_info_linear to files, it is necessary to + * translate pointers in bpf_prog_info to offsets. Helper functions + * bpf_program__bpil_addr_to_offs() and bpf_program__bpil_offs_to_addr() + * are introduced to switch between pointers and offsets. + * + * Examples: + * # To fetch map_ids and prog_tags: + * __u64 arrays = (1UL << BPF_PROG_INFO_MAP_IDS) | + * (1UL << BPF_PROG_INFO_PROG_TAGS); + * struct bpf_prog_info_linear *info_linear = + * bpf_program__get_prog_info_linear(fd, arrays); + * + * # To save data in file + * bpf_program__bpil_addr_to_offs(info_linear); + * write(f, info_linear, sizeof(*info_linear) + info_linear->data_len); + * + * # To read data from file + * read(f, info_linear, ); + * bpf_program__bpil_offs_to_addr(info_linear); + */ +enum bpf_prog_info_array { + BPF_PROG_INFO_FIRST_ARRAY = 0, + BPF_PROG_INFO_JITED_INSNS = 0, + BPF_PROG_INFO_XLATED_INSNS, + BPF_PROG_INFO_MAP_IDS, + BPF_PROG_INFO_JITED_KSYMS, + BPF_PROG_INFO_JITED_FUNC_LENS, + BPF_PROG_INFO_FUNC_INFO, + BPF_PROG_INFO_LINE_INFO, + BPF_PROG_INFO_JITED_LINE_INFO, + BPF_PROG_INFO_PROG_TAGS, + BPF_PROG_INFO_LAST_ARRAY, +}; + +struct bpf_prog_info_linear { + /* size of struct bpf_prog_info, when the tool is compiled */ + __u32 info_len; + /* total bytes allocated for data, round up to 8 bytes */ + __u32 data_len; + /* which arrays are included in data */ + __u64 arrays; + struct bpf_prog_info info; + __u8 data[]; +}; + +LIBBPF_API struct bpf_prog_info_linear * +bpf_program__get_prog_info_linear(int fd, __u64 arrays); + +LIBBPF_API void +bpf_program__bpil_addr_to_offs(struct bpf_prog_info_linear *info_linear); + +LIBBPF_API void +bpf_program__bpil_offs_to_addr(struct bpf_prog_info_linear *info_linear); + +/* + * A helper function to get the number of possible CPUs before looking up + * per-CPU maps. Negative errno is returned on failure. + * + * Example usage: + * + * int ncpus = libbpf_num_possible_cpus(); + * if (ncpus < 0) { + * // error handling + * } + * long values[ncpus]; + * bpf_map_lookup_elem(per_cpu_map_fd, key, values); + * + */ +LIBBPF_API int libbpf_num_possible_cpus(void); + +struct bpf_map_skeleton { + const char *name; + struct bpf_map **map; + void **mmaped; +}; + +struct bpf_prog_skeleton { + const char *name; + struct bpf_program **prog; + struct bpf_link **link; +}; + +struct bpf_object_skeleton { + size_t sz; /* size of this struct, for forward/backward compatibility */ + + const char *name; + void *data; + size_t data_sz; + + struct bpf_object **obj; + + int map_cnt; + int map_skel_sz; /* sizeof(struct bpf_skeleton_map) */ + struct bpf_map_skeleton *maps; + + int prog_cnt; + int prog_skel_sz; /* sizeof(struct bpf_skeleton_prog) */ + struct bpf_prog_skeleton *progs; +}; + +LIBBPF_API int +bpf_object__open_skeleton(struct bpf_object_skeleton *s, + const struct bpf_object_open_opts *opts); +LIBBPF_API int bpf_object__load_skeleton(struct bpf_object_skeleton *s); +LIBBPF_API int bpf_object__attach_skeleton(struct bpf_object_skeleton *s); +LIBBPF_API void bpf_object__detach_skeleton(struct bpf_object_skeleton *s); +LIBBPF_API void bpf_object__destroy_skeleton(struct bpf_object_skeleton *s); + +enum libbpf_tristate { + TRI_NO = 0, + TRI_YES = 1, + TRI_MODULE = 2, +}; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __LIBBPF_LIBBPF_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/src/libbpf_internal.h dwarves-dfsg-1.21/lib/bpf/src/libbpf_internal.h --- dwarves-dfsg-1.10/lib/bpf/src/libbpf_internal.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/libbpf_internal.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,354 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +/* + * Internal libbpf helpers. + * + * Copyright (c) 2019 Facebook + */ + +#ifndef __LIBBPF_LIBBPF_INTERNAL_H +#define __LIBBPF_LIBBPF_INTERNAL_H + +#include +#include + +/* make sure libbpf doesn't use kernel-only integer typedefs */ +#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64 + +/* prevent accidental re-addition of reallocarray() */ +#pragma GCC poison reallocarray + +#include "libbpf.h" + +#define BTF_INFO_ENC(kind, kind_flag, vlen) \ + ((!!(kind_flag) << 31) | ((kind) << 24) | ((vlen) & BTF_MAX_VLEN)) +#define BTF_TYPE_ENC(name, info, size_or_type) (name), (info), (size_or_type) +#define BTF_INT_ENC(encoding, bits_offset, nr_bits) \ + ((encoding) << 24 | (bits_offset) << 16 | (nr_bits)) +#define BTF_TYPE_INT_ENC(name, encoding, bits_offset, bits, sz) \ + BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_INT, 0, 0), sz), \ + BTF_INT_ENC(encoding, bits_offset, bits) +#define BTF_MEMBER_ENC(name, type, bits_offset) (name), (type), (bits_offset) +#define BTF_PARAM_ENC(name, type) (name), (type) +#define BTF_VAR_SECINFO_ENC(type, offset, size) (type), (offset), (size) +#define BTF_TYPE_FLOAT_ENC(name, sz) \ + BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_FLOAT, 0, 0), sz) + +#ifndef likely +#define likely(x) __builtin_expect(!!(x), 1) +#endif +#ifndef unlikely +#define unlikely(x) __builtin_expect(!!(x), 0) +#endif +#ifndef min +# define min(x, y) ((x) < (y) ? (x) : (y)) +#endif +#ifndef max +# define max(x, y) ((x) < (y) ? (y) : (x)) +#endif +#ifndef offsetofend +# define offsetofend(TYPE, FIELD) \ + (offsetof(TYPE, FIELD) + sizeof(((TYPE *)0)->FIELD)) +#endif + +/* Symbol versioning is different between static and shared library. + * Properly versioned symbols are needed for shared library, but + * only the symbol of the new version is needed for static library. + */ +#ifdef SHARED +# define COMPAT_VERSION(internal_name, api_name, version) \ + asm(".symver " #internal_name "," #api_name "@" #version); +# define DEFAULT_VERSION(internal_name, api_name, version) \ + asm(".symver " #internal_name "," #api_name "@@" #version); +#else +# define COMPAT_VERSION(internal_name, api_name, version) +# define DEFAULT_VERSION(internal_name, api_name, version) \ + extern typeof(internal_name) api_name \ + __attribute__((alias(#internal_name))); +#endif + +extern void libbpf_print(enum libbpf_print_level level, + const char *format, ...) + __attribute__((format(printf, 2, 3))); + +#define __pr(level, fmt, ...) \ +do { \ + libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \ +} while (0) + +#define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__) +#define pr_info(fmt, ...) __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__) +#define pr_debug(fmt, ...) __pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__) + +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif +/* + * Re-implement glibc's reallocarray() for libbpf internal-only use. + * reallocarray(), unfortunately, is not available in all versions of glibc, + * so requires extra feature detection and using reallocarray() stub from + * and COMPAT_NEED_REALLOCARRAY. All this complicates + * build of libbpf unnecessarily and is just a maintenance burden. Instead, + * it's trivial to implement libbpf-specific internal version and use it + * throughout libbpf. + */ +static inline void *libbpf_reallocarray(void *ptr, size_t nmemb, size_t size) +{ + size_t total; + +#if __has_builtin(__builtin_mul_overflow) + if (unlikely(__builtin_mul_overflow(nmemb, size, &total))) + return NULL; +#else + if (size == 0 || nmemb > ULONG_MAX / size) + return NULL; + total = nmemb * size; +#endif + return realloc(ptr, total); +} + +void *btf_add_mem(void **data, size_t *cap_cnt, size_t elem_sz, + size_t cur_cnt, size_t max_cnt, size_t add_cnt); +int btf_ensure_mem(void **data, size_t *cap_cnt, size_t elem_sz, size_t need_cnt); + +static inline bool libbpf_validate_opts(const char *opts, + size_t opts_sz, size_t user_sz, + const char *type_name) +{ + if (user_sz < sizeof(size_t)) { + pr_warn("%s size (%zu) is too small\n", type_name, user_sz); + return false; + } + if (user_sz > opts_sz) { + size_t i; + + for (i = opts_sz; i < user_sz; i++) { + if (opts[i]) { + pr_warn("%s has non-zero extra bytes\n", + type_name); + return false; + } + } + } + return true; +} + +#define OPTS_VALID(opts, type) \ + (!(opts) || libbpf_validate_opts((const char *)opts, \ + offsetofend(struct type, \ + type##__last_field), \ + (opts)->sz, #type)) +#define OPTS_HAS(opts, field) \ + ((opts) && opts->sz >= offsetofend(typeof(*(opts)), field)) +#define OPTS_GET(opts, field, fallback_value) \ + (OPTS_HAS(opts, field) ? (opts)->field : fallback_value) +#define OPTS_SET(opts, field, value) \ + do { \ + if (OPTS_HAS(opts, field)) \ + (opts)->field = value; \ + } while (0) + +int parse_cpu_mask_str(const char *s, bool **mask, int *mask_sz); +int parse_cpu_mask_file(const char *fcpu, bool **mask, int *mask_sz); +int libbpf__load_raw_btf(const char *raw_types, size_t types_len, + const char *str_sec, size_t str_len); + +struct bpf_prog_load_params { + enum bpf_prog_type prog_type; + enum bpf_attach_type expected_attach_type; + const char *name; + const struct bpf_insn *insns; + size_t insn_cnt; + const char *license; + __u32 kern_version; + __u32 attach_prog_fd; + __u32 attach_btf_obj_fd; + __u32 attach_btf_id; + __u32 prog_ifindex; + __u32 prog_btf_fd; + __u32 prog_flags; + + __u32 func_info_rec_size; + const void *func_info; + __u32 func_info_cnt; + + __u32 line_info_rec_size; + const void *line_info; + __u32 line_info_cnt; + + __u32 log_level; + char *log_buf; + size_t log_buf_sz; +}; + +int libbpf__bpf_prog_load(const struct bpf_prog_load_params *load_attr); + +int bpf_object__section_size(const struct bpf_object *obj, const char *name, + __u32 *size); +int bpf_object__variable_offset(const struct bpf_object *obj, const char *name, + __u32 *off); +struct btf *btf_get_from_fd(int btf_fd, struct btf *base_btf); + +struct btf_ext_info { + /* + * info points to the individual info section (e.g. func_info and + * line_info) from the .BTF.ext. It does not include the __u32 rec_size. + */ + void *info; + __u32 rec_size; + __u32 len; +}; + +#define for_each_btf_ext_sec(seg, sec) \ + for (sec = (seg)->info; \ + (void *)sec < (seg)->info + (seg)->len; \ + sec = (void *)sec + sizeof(struct btf_ext_info_sec) + \ + (seg)->rec_size * sec->num_info) + +#define for_each_btf_ext_rec(seg, sec, i, rec) \ + for (i = 0, rec = (void *)&(sec)->data; \ + i < (sec)->num_info; \ + i++, rec = (void *)rec + (seg)->rec_size) + +/* + * The .BTF.ext ELF section layout defined as + * struct btf_ext_header + * func_info subsection + * + * The func_info subsection layout: + * record size for struct bpf_func_info in the func_info subsection + * struct btf_sec_func_info for section #1 + * a list of bpf_func_info records for section #1 + * where struct bpf_func_info mimics one in include/uapi/linux/bpf.h + * but may not be identical + * struct btf_sec_func_info for section #2 + * a list of bpf_func_info records for section #2 + * ...... + * + * Note that the bpf_func_info record size in .BTF.ext may not + * be the same as the one defined in include/uapi/linux/bpf.h. + * The loader should ensure that record_size meets minimum + * requirement and pass the record as is to the kernel. The + * kernel will handle the func_info properly based on its contents. + */ +struct btf_ext_header { + __u16 magic; + __u8 version; + __u8 flags; + __u32 hdr_len; + + /* All offsets are in bytes relative to the end of this header */ + __u32 func_info_off; + __u32 func_info_len; + __u32 line_info_off; + __u32 line_info_len; + + /* optional part of .BTF.ext header */ + __u32 core_relo_off; + __u32 core_relo_len; +}; + +struct btf_ext { + union { + struct btf_ext_header *hdr; + void *data; + }; + struct btf_ext_info func_info; + struct btf_ext_info line_info; + struct btf_ext_info core_relo_info; + __u32 data_size; +}; + +struct btf_ext_info_sec { + __u32 sec_name_off; + __u32 num_info; + /* Followed by num_info * record_size number of bytes */ + __u8 data[]; +}; + +/* The minimum bpf_func_info checked by the loader */ +struct bpf_func_info_min { + __u32 insn_off; + __u32 type_id; +}; + +/* The minimum bpf_line_info checked by the loader */ +struct bpf_line_info_min { + __u32 insn_off; + __u32 file_name_off; + __u32 line_off; + __u32 line_col; +}; + +/* bpf_core_relo_kind encodes which aspect of captured field/type/enum value + * has to be adjusted by relocations. + */ +enum bpf_core_relo_kind { + BPF_FIELD_BYTE_OFFSET = 0, /* field byte offset */ + BPF_FIELD_BYTE_SIZE = 1, /* field size in bytes */ + BPF_FIELD_EXISTS = 2, /* field existence in target kernel */ + BPF_FIELD_SIGNED = 3, /* field signedness (0 - unsigned, 1 - signed) */ + BPF_FIELD_LSHIFT_U64 = 4, /* bitfield-specific left bitshift */ + BPF_FIELD_RSHIFT_U64 = 5, /* bitfield-specific right bitshift */ + BPF_TYPE_ID_LOCAL = 6, /* type ID in local BPF object */ + BPF_TYPE_ID_TARGET = 7, /* type ID in target kernel */ + BPF_TYPE_EXISTS = 8, /* type existence in target kernel */ + BPF_TYPE_SIZE = 9, /* type size in bytes */ + BPF_ENUMVAL_EXISTS = 10, /* enum value existence in target kernel */ + BPF_ENUMVAL_VALUE = 11, /* enum value integer value */ +}; + +/* The minimum bpf_core_relo checked by the loader + * + * CO-RE relocation captures the following data: + * - insn_off - instruction offset (in bytes) within a BPF program that needs + * its insn->imm field to be relocated with actual field info; + * - type_id - BTF type ID of the "root" (containing) entity of a relocatable + * type or field; + * - access_str_off - offset into corresponding .BTF string section. String + * interpretation depends on specific relocation kind: + * - for field-based relocations, string encodes an accessed field using + * a sequence of field and array indices, separated by colon (:). It's + * conceptually very close to LLVM's getelementptr ([0]) instruction's + * arguments for identifying offset to a field. + * - for type-based relocations, strings is expected to be just "0"; + * - for enum value-based relocations, string contains an index of enum + * value within its enum type; + * + * Example to provide a better feel. + * + * struct sample { + * int a; + * struct { + * int b[10]; + * }; + * }; + * + * struct sample *s = ...; + * int x = &s->a; // encoded as "0:0" (a is field #0) + * int y = &s->b[5]; // encoded as "0:1:0:5" (anon struct is field #1, + * // b is field #0 inside anon struct, accessing elem #5) + * int z = &s[10]->b; // encoded as "10:1" (ptr is used as an array) + * + * type_id for all relocs in this example will capture BTF type id of + * `struct sample`. + * + * Such relocation is emitted when using __builtin_preserve_access_index() + * Clang built-in, passing expression that captures field address, e.g.: + * + * bpf_probe_read(&dst, sizeof(dst), + * __builtin_preserve_access_index(&src->a.b.c)); + * + * In this case Clang will emit field relocation recording necessary data to + * be able to find offset of embedded `a.b.c` field within `src` struct. + * + * [0] https://llvm.org/docs/LangRef.html#getelementptr-instruction + */ +struct bpf_core_relo { + __u32 insn_off; + __u32 type_id; + __u32 access_str_off; + enum bpf_core_relo_kind kind; +}; + +#endif /* __LIBBPF_LIBBPF_INTERNAL_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/src/libbpf.map dwarves-dfsg-1.21/lib/bpf/src/libbpf.map --- dwarves-dfsg-1.10/lib/bpf/src/libbpf.map 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/libbpf.map 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,357 @@ +LIBBPF_0.0.1 { + global: + bpf_btf_get_fd_by_id; + bpf_create_map; + bpf_create_map_in_map; + bpf_create_map_in_map_node; + bpf_create_map_name; + bpf_create_map_node; + bpf_create_map_xattr; + bpf_load_btf; + bpf_load_program; + bpf_load_program_xattr; + bpf_map__btf_key_type_id; + bpf_map__btf_value_type_id; + bpf_map__def; + bpf_map__fd; + bpf_map__is_offload_neutral; + bpf_map__name; + bpf_map__next; + bpf_map__pin; + bpf_map__prev; + bpf_map__priv; + bpf_map__reuse_fd; + bpf_map__set_ifindex; + bpf_map__set_inner_map_fd; + bpf_map__set_priv; + bpf_map__unpin; + bpf_map_delete_elem; + bpf_map_get_fd_by_id; + bpf_map_get_next_id; + bpf_map_get_next_key; + bpf_map_lookup_and_delete_elem; + bpf_map_lookup_elem; + bpf_map_update_elem; + bpf_obj_get; + bpf_obj_get_info_by_fd; + bpf_obj_pin; + bpf_object__btf_fd; + bpf_object__close; + bpf_object__find_map_by_name; + bpf_object__find_map_by_offset; + bpf_object__find_program_by_title; + bpf_object__kversion; + bpf_object__load; + bpf_object__name; + bpf_object__next; + bpf_object__open; + bpf_object__open_buffer; + bpf_object__open_xattr; + bpf_object__pin; + bpf_object__pin_maps; + bpf_object__pin_programs; + bpf_object__priv; + bpf_object__set_priv; + bpf_object__unload; + bpf_object__unpin_maps; + bpf_object__unpin_programs; + bpf_perf_event_read_simple; + bpf_prog_attach; + bpf_prog_detach; + bpf_prog_detach2; + bpf_prog_get_fd_by_id; + bpf_prog_get_next_id; + bpf_prog_load; + bpf_prog_load_xattr; + bpf_prog_query; + bpf_prog_test_run; + bpf_prog_test_run_xattr; + bpf_program__fd; + bpf_program__is_kprobe; + bpf_program__is_perf_event; + bpf_program__is_raw_tracepoint; + bpf_program__is_sched_act; + bpf_program__is_sched_cls; + bpf_program__is_socket_filter; + bpf_program__is_tracepoint; + bpf_program__is_xdp; + bpf_program__load; + bpf_program__next; + bpf_program__nth_fd; + bpf_program__pin; + bpf_program__pin_instance; + bpf_program__prev; + bpf_program__priv; + bpf_program__set_expected_attach_type; + bpf_program__set_ifindex; + bpf_program__set_kprobe; + bpf_program__set_perf_event; + bpf_program__set_prep; + bpf_program__set_priv; + bpf_program__set_raw_tracepoint; + bpf_program__set_sched_act; + bpf_program__set_sched_cls; + bpf_program__set_socket_filter; + bpf_program__set_tracepoint; + bpf_program__set_type; + bpf_program__set_xdp; + bpf_program__title; + bpf_program__unload; + bpf_program__unpin; + bpf_program__unpin_instance; + bpf_prog_linfo__free; + bpf_prog_linfo__new; + bpf_prog_linfo__lfind_addr_func; + bpf_prog_linfo__lfind; + bpf_raw_tracepoint_open; + bpf_set_link_xdp_fd; + bpf_task_fd_query; + bpf_verify_program; + btf__fd; + btf__find_by_name; + btf__free; + btf__get_from_id; + btf__name_by_offset; + btf__new; + btf__resolve_size; + btf__resolve_type; + btf__type_by_id; + libbpf_attach_type_by_name; + libbpf_get_error; + libbpf_prog_type_by_name; + libbpf_set_print; + libbpf_strerror; + local: + *; +}; + +LIBBPF_0.0.2 { + global: + bpf_probe_helper; + bpf_probe_map_type; + bpf_probe_prog_type; + bpf_map__resize; + bpf_map_lookup_elem_flags; + bpf_object__btf; + bpf_object__find_map_fd_by_name; + bpf_get_link_xdp_id; + btf__dedup; + btf__get_map_kv_tids; + btf__get_nr_types; + btf__get_raw_data; + btf__load; + btf_ext__free; + btf_ext__func_info_rec_size; + btf_ext__get_raw_data; + btf_ext__line_info_rec_size; + btf_ext__new; + btf_ext__reloc_func_info; + btf_ext__reloc_line_info; + xsk_umem__create; + xsk_socket__create; + xsk_umem__delete; + xsk_socket__delete; + xsk_umem__fd; + xsk_socket__fd; + bpf_program__get_prog_info_linear; + bpf_program__bpil_addr_to_offs; + bpf_program__bpil_offs_to_addr; +} LIBBPF_0.0.1; + +LIBBPF_0.0.3 { + global: + bpf_map__is_internal; + bpf_map_freeze; + btf__finalize_data; +} LIBBPF_0.0.2; + +LIBBPF_0.0.4 { + global: + bpf_link__destroy; + bpf_object__load_xattr; + bpf_program__attach_kprobe; + bpf_program__attach_perf_event; + bpf_program__attach_raw_tracepoint; + bpf_program__attach_tracepoint; + bpf_program__attach_uprobe; + btf_dump__dump_type; + btf_dump__free; + btf_dump__new; + btf__parse_elf; + libbpf_num_possible_cpus; + perf_buffer__free; + perf_buffer__new; + perf_buffer__new_raw; + perf_buffer__poll; + xsk_umem__create; +} LIBBPF_0.0.3; + +LIBBPF_0.0.5 { + global: + bpf_btf_get_next_id; +} LIBBPF_0.0.4; + +LIBBPF_0.0.6 { + global: + bpf_get_link_xdp_info; + bpf_map__get_pin_path; + bpf_map__is_pinned; + bpf_map__set_pin_path; + bpf_object__open_file; + bpf_object__open_mem; + bpf_program__attach_trace; + bpf_program__get_expected_attach_type; + bpf_program__get_type; + bpf_program__is_tracing; + bpf_program__set_tracing; + bpf_program__size; + btf__find_by_name_kind; + libbpf_find_vmlinux_btf_id; +} LIBBPF_0.0.5; + +LIBBPF_0.0.7 { + global: + btf_dump__emit_type_decl; + bpf_link__disconnect; + bpf_map__attach_struct_ops; + bpf_map_delete_batch; + bpf_map_lookup_and_delete_batch; + bpf_map_lookup_batch; + bpf_map_update_batch; + bpf_object__find_program_by_name; + bpf_object__attach_skeleton; + bpf_object__destroy_skeleton; + bpf_object__detach_skeleton; + bpf_object__load_skeleton; + bpf_object__open_skeleton; + bpf_probe_large_insn_limit; + bpf_prog_attach_xattr; + bpf_program__attach; + bpf_program__name; + bpf_program__is_extension; + bpf_program__is_struct_ops; + bpf_program__set_extension; + bpf_program__set_struct_ops; + btf__align_of; + libbpf_find_kernel_btf; +} LIBBPF_0.0.6; + +LIBBPF_0.0.8 { + global: + bpf_link__fd; + bpf_link__open; + bpf_link__pin; + bpf_link__pin_path; + bpf_link__unpin; + bpf_link__update_program; + bpf_link_create; + bpf_link_update; + bpf_map__set_initial_value; + bpf_program__attach_cgroup; + bpf_program__attach_lsm; + bpf_program__is_lsm; + bpf_program__set_attach_target; + bpf_program__set_lsm; + bpf_set_link_xdp_fd_opts; +} LIBBPF_0.0.7; + +LIBBPF_0.0.9 { + global: + bpf_enable_stats; + bpf_iter_create; + bpf_link_get_fd_by_id; + bpf_link_get_next_id; + bpf_program__attach_iter; + bpf_program__attach_netns; + perf_buffer__consume; + ring_buffer__add; + ring_buffer__consume; + ring_buffer__free; + ring_buffer__new; + ring_buffer__poll; +} LIBBPF_0.0.8; + +LIBBPF_0.1.0 { + global: + bpf_link__detach; + bpf_link_detach; + bpf_map__ifindex; + bpf_map__key_size; + bpf_map__map_flags; + bpf_map__max_entries; + bpf_map__numa_node; + bpf_map__set_key_size; + bpf_map__set_map_flags; + bpf_map__set_max_entries; + bpf_map__set_numa_node; + bpf_map__set_type; + bpf_map__set_value_size; + bpf_map__type; + bpf_map__value_size; + bpf_program__attach_xdp; + bpf_program__autoload; + bpf_program__is_sk_lookup; + bpf_program__set_autoload; + bpf_program__set_sk_lookup; + btf__parse; + btf__parse_raw; + btf__pointer_size; + btf__set_fd; + btf__set_pointer_size; +} LIBBPF_0.0.9; + +LIBBPF_0.2.0 { + global: + bpf_prog_bind_map; + bpf_prog_test_run_opts; + bpf_program__attach_freplace; + bpf_program__section_name; + btf__add_array; + btf__add_const; + btf__add_enum; + btf__add_enum_value; + btf__add_datasec; + btf__add_datasec_var_info; + btf__add_field; + btf__add_func; + btf__add_func_param; + btf__add_func_proto; + btf__add_fwd; + btf__add_int; + btf__add_ptr; + btf__add_restrict; + btf__add_str; + btf__add_struct; + btf__add_typedef; + btf__add_union; + btf__add_var; + btf__add_volatile; + btf__endianness; + btf__find_str; + btf__new_empty; + btf__set_endianness; + btf__str_by_offset; + perf_buffer__buffer_cnt; + perf_buffer__buffer_fd; + perf_buffer__epoll_fd; + perf_buffer__consume_buffer; + xsk_socket__create_shared; +} LIBBPF_0.1.0; + +LIBBPF_0.3.0 { + global: + btf__base_btf; + btf__parse_elf_split; + btf__parse_raw_split; + btf__parse_split; + btf__new_empty_split; + btf__new_split; + ring_buffer__epoll_fd; + xsk_setup_xdp_prog; + xsk_socket__update_xskmap; +} LIBBPF_0.2.0; + +LIBBPF_0.4.0 { + global: + btf__add_float; +} LIBBPF_0.3.0; diff -Nru dwarves-dfsg-1.10/lib/bpf/src/libbpf.pc.template dwarves-dfsg-1.21/lib/bpf/src/libbpf.pc.template --- dwarves-dfsg-1.10/lib/bpf/src/libbpf.pc.template 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/libbpf.pc.template 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +prefix=@PREFIX@ +libdir=@LIBDIR@ +includedir=${prefix}/include + +Name: libbpf +Description: BPF library +Version: @VERSION@ +Libs: -L${libdir} -lbpf +Requires.private: libelf zlib +Cflags: -I${includedir} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/libbpf_probes.c dwarves-dfsg-1.21/lib/bpf/src/libbpf_probes.c --- dwarves-dfsg-1.10/lib/bpf/src/libbpf_probes.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/libbpf_probes.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,358 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +/* Copyright (c) 2019 Netronome Systems, Inc. */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "bpf.h" +#include "libbpf.h" +#include "libbpf_internal.h" + +static bool grep(const char *buffer, const char *pattern) +{ + return !!strstr(buffer, pattern); +} + +static int get_vendor_id(int ifindex) +{ + char ifname[IF_NAMESIZE], path[64], buf[8]; + ssize_t len; + int fd; + + if (!if_indextoname(ifindex, ifname)) + return -1; + + snprintf(path, sizeof(path), "/sys/class/net/%s/device/vendor", ifname); + + fd = open(path, O_RDONLY); + if (fd < 0) + return -1; + + len = read(fd, buf, sizeof(buf)); + close(fd); + if (len < 0) + return -1; + if (len >= (ssize_t)sizeof(buf)) + return -1; + buf[len] = '\0'; + + return strtol(buf, NULL, 0); +} + +static int get_kernel_version(void) +{ + int version, subversion, patchlevel; + struct utsname utsn; + + /* Return 0 on failure, and attempt to probe with empty kversion */ + if (uname(&utsn)) + return 0; + + if (sscanf(utsn.release, "%d.%d.%d", + &version, &subversion, &patchlevel) != 3) + return 0; + + return (version << 16) + (subversion << 8) + patchlevel; +} + +static void +probe_load(enum bpf_prog_type prog_type, const struct bpf_insn *insns, + size_t insns_cnt, char *buf, size_t buf_len, __u32 ifindex) +{ + struct bpf_load_program_attr xattr = {}; + int fd; + + switch (prog_type) { + case BPF_PROG_TYPE_CGROUP_SOCK_ADDR: + xattr.expected_attach_type = BPF_CGROUP_INET4_CONNECT; + break; + case BPF_PROG_TYPE_SK_LOOKUP: + xattr.expected_attach_type = BPF_SK_LOOKUP; + break; + case BPF_PROG_TYPE_KPROBE: + xattr.kern_version = get_kernel_version(); + break; + case BPF_PROG_TYPE_UNSPEC: + case BPF_PROG_TYPE_SOCKET_FILTER: + case BPF_PROG_TYPE_SCHED_CLS: + case BPF_PROG_TYPE_SCHED_ACT: + case BPF_PROG_TYPE_TRACEPOINT: + case BPF_PROG_TYPE_XDP: + case BPF_PROG_TYPE_PERF_EVENT: + case BPF_PROG_TYPE_CGROUP_SKB: + case BPF_PROG_TYPE_CGROUP_SOCK: + case BPF_PROG_TYPE_LWT_IN: + case BPF_PROG_TYPE_LWT_OUT: + case BPF_PROG_TYPE_LWT_XMIT: + case BPF_PROG_TYPE_SOCK_OPS: + case BPF_PROG_TYPE_SK_SKB: + case BPF_PROG_TYPE_CGROUP_DEVICE: + case BPF_PROG_TYPE_SK_MSG: + case BPF_PROG_TYPE_RAW_TRACEPOINT: + case BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE: + case BPF_PROG_TYPE_LWT_SEG6LOCAL: + case BPF_PROG_TYPE_LIRC_MODE2: + case BPF_PROG_TYPE_SK_REUSEPORT: + case BPF_PROG_TYPE_FLOW_DISSECTOR: + case BPF_PROG_TYPE_CGROUP_SYSCTL: + case BPF_PROG_TYPE_CGROUP_SOCKOPT: + case BPF_PROG_TYPE_TRACING: + case BPF_PROG_TYPE_STRUCT_OPS: + case BPF_PROG_TYPE_EXT: + case BPF_PROG_TYPE_LSM: + default: + break; + } + + xattr.prog_type = prog_type; + xattr.insns = insns; + xattr.insns_cnt = insns_cnt; + xattr.license = "GPL"; + xattr.prog_ifindex = ifindex; + + fd = bpf_load_program_xattr(&xattr, buf, buf_len); + if (fd >= 0) + close(fd); +} + +bool bpf_probe_prog_type(enum bpf_prog_type prog_type, __u32 ifindex) +{ + struct bpf_insn insns[2] = { + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN() + }; + + if (ifindex && prog_type == BPF_PROG_TYPE_SCHED_CLS) + /* nfp returns -EINVAL on exit(0) with TC offload */ + insns[0].imm = 2; + + errno = 0; + probe_load(prog_type, insns, ARRAY_SIZE(insns), NULL, 0, ifindex); + + return errno != EINVAL && errno != EOPNOTSUPP; +} + +int libbpf__load_raw_btf(const char *raw_types, size_t types_len, + const char *str_sec, size_t str_len) +{ + struct btf_header hdr = { + .magic = BTF_MAGIC, + .version = BTF_VERSION, + .hdr_len = sizeof(struct btf_header), + .type_len = types_len, + .str_off = types_len, + .str_len = str_len, + }; + int btf_fd, btf_len; + __u8 *raw_btf; + + btf_len = hdr.hdr_len + hdr.type_len + hdr.str_len; + raw_btf = malloc(btf_len); + if (!raw_btf) + return -ENOMEM; + + memcpy(raw_btf, &hdr, sizeof(hdr)); + memcpy(raw_btf + hdr.hdr_len, raw_types, hdr.type_len); + memcpy(raw_btf + hdr.hdr_len + hdr.type_len, str_sec, hdr.str_len); + + btf_fd = bpf_load_btf(raw_btf, btf_len, NULL, 0, false); + + free(raw_btf); + return btf_fd; +} + +static int load_local_storage_btf(void) +{ + const char strs[] = "\0bpf_spin_lock\0val\0cnt\0l"; + /* struct bpf_spin_lock { + * int val; + * }; + * struct val { + * int cnt; + * struct bpf_spin_lock l; + * }; + */ + __u32 types[] = { + /* int */ + BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */ + /* struct bpf_spin_lock */ /* [2] */ + BTF_TYPE_ENC(1, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 1), 4), + BTF_MEMBER_ENC(15, 1, 0), /* int val; */ + /* struct val */ /* [3] */ + BTF_TYPE_ENC(15, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), 8), + BTF_MEMBER_ENC(19, 1, 0), /* int cnt; */ + BTF_MEMBER_ENC(23, 2, 32),/* struct bpf_spin_lock l; */ + }; + + return libbpf__load_raw_btf((char *)types, sizeof(types), + strs, sizeof(strs)); +} + +bool bpf_probe_map_type(enum bpf_map_type map_type, __u32 ifindex) +{ + int key_size, value_size, max_entries, map_flags; + __u32 btf_key_type_id = 0, btf_value_type_id = 0; + struct bpf_create_map_attr attr = {}; + int fd = -1, btf_fd = -1, fd_inner; + + key_size = sizeof(__u32); + value_size = sizeof(__u32); + max_entries = 1; + map_flags = 0; + + switch (map_type) { + case BPF_MAP_TYPE_STACK_TRACE: + value_size = sizeof(__u64); + break; + case BPF_MAP_TYPE_LPM_TRIE: + key_size = sizeof(__u64); + value_size = sizeof(__u64); + map_flags = BPF_F_NO_PREALLOC; + break; + case BPF_MAP_TYPE_CGROUP_STORAGE: + case BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE: + key_size = sizeof(struct bpf_cgroup_storage_key); + value_size = sizeof(__u64); + max_entries = 0; + break; + case BPF_MAP_TYPE_QUEUE: + case BPF_MAP_TYPE_STACK: + key_size = 0; + break; + case BPF_MAP_TYPE_SK_STORAGE: + case BPF_MAP_TYPE_INODE_STORAGE: + case BPF_MAP_TYPE_TASK_STORAGE: + btf_key_type_id = 1; + btf_value_type_id = 3; + value_size = 8; + max_entries = 0; + map_flags = BPF_F_NO_PREALLOC; + btf_fd = load_local_storage_btf(); + if (btf_fd < 0) + return false; + break; + case BPF_MAP_TYPE_RINGBUF: + key_size = 0; + value_size = 0; + max_entries = 4096; + break; + case BPF_MAP_TYPE_UNSPEC: + case BPF_MAP_TYPE_HASH: + case BPF_MAP_TYPE_ARRAY: + case BPF_MAP_TYPE_PROG_ARRAY: + case BPF_MAP_TYPE_PERF_EVENT_ARRAY: + case BPF_MAP_TYPE_PERCPU_HASH: + case BPF_MAP_TYPE_PERCPU_ARRAY: + case BPF_MAP_TYPE_CGROUP_ARRAY: + case BPF_MAP_TYPE_LRU_HASH: + case BPF_MAP_TYPE_LRU_PERCPU_HASH: + case BPF_MAP_TYPE_ARRAY_OF_MAPS: + case BPF_MAP_TYPE_HASH_OF_MAPS: + case BPF_MAP_TYPE_DEVMAP: + case BPF_MAP_TYPE_DEVMAP_HASH: + case BPF_MAP_TYPE_SOCKMAP: + case BPF_MAP_TYPE_CPUMAP: + case BPF_MAP_TYPE_XSKMAP: + case BPF_MAP_TYPE_SOCKHASH: + case BPF_MAP_TYPE_REUSEPORT_SOCKARRAY: + case BPF_MAP_TYPE_STRUCT_OPS: + default: + break; + } + + if (map_type == BPF_MAP_TYPE_ARRAY_OF_MAPS || + map_type == BPF_MAP_TYPE_HASH_OF_MAPS) { + /* TODO: probe for device, once libbpf has a function to create + * map-in-map for offload + */ + if (ifindex) + return false; + + fd_inner = bpf_create_map(BPF_MAP_TYPE_HASH, + sizeof(__u32), sizeof(__u32), 1, 0); + if (fd_inner < 0) + return false; + fd = bpf_create_map_in_map(map_type, NULL, sizeof(__u32), + fd_inner, 1, 0); + close(fd_inner); + } else { + /* Note: No other restriction on map type probes for offload */ + attr.map_type = map_type; + attr.key_size = key_size; + attr.value_size = value_size; + attr.max_entries = max_entries; + attr.map_flags = map_flags; + attr.map_ifindex = ifindex; + if (btf_fd >= 0) { + attr.btf_fd = btf_fd; + attr.btf_key_type_id = btf_key_type_id; + attr.btf_value_type_id = btf_value_type_id; + } + + fd = bpf_create_map_xattr(&attr); + } + if (fd >= 0) + close(fd); + if (btf_fd >= 0) + close(btf_fd); + + return fd >= 0; +} + +bool bpf_probe_helper(enum bpf_func_id id, enum bpf_prog_type prog_type, + __u32 ifindex) +{ + struct bpf_insn insns[2] = { + BPF_EMIT_CALL(id), + BPF_EXIT_INSN() + }; + char buf[4096] = {}; + bool res; + + probe_load(prog_type, insns, ARRAY_SIZE(insns), buf, sizeof(buf), + ifindex); + res = !grep(buf, "invalid func ") && !grep(buf, "unknown func "); + + if (ifindex) { + switch (get_vendor_id(ifindex)) { + case 0x19ee: /* Netronome specific */ + res = res && !grep(buf, "not supported by FW") && + !grep(buf, "unsupported function id"); + break; + default: + break; + } + } + + return res; +} + +/* + * Probe for availability of kernel commit (5.3): + * + * c04c0d2b968a ("bpf: increase complexity limit and maximum program size") + */ +bool bpf_probe_large_insn_limit(__u32 ifindex) +{ + struct bpf_insn insns[BPF_MAXINSNS + 1]; + int i; + + for (i = 0; i < BPF_MAXINSNS; i++) + insns[i] = BPF_MOV64_IMM(BPF_REG_0, 1); + insns[BPF_MAXINSNS] = BPF_EXIT_INSN(); + + errno = 0; + probe_load(BPF_PROG_TYPE_SCHED_CLS, insns, ARRAY_SIZE(insns), NULL, 0, + ifindex); + + return errno != E2BIG && errno != EINVAL; +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/libbpf_util.h dwarves-dfsg-1.21/lib/bpf/src/libbpf_util.h --- dwarves-dfsg-1.10/lib/bpf/src/libbpf_util.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/libbpf_util.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ +/* Copyright (c) 2019 Facebook */ + +#ifndef __LIBBPF_LIBBPF_UTIL_H +#define __LIBBPF_LIBBPF_UTIL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Use these barrier functions instead of smp_[rw]mb() when they are + * used in a libbpf header file. That way they can be built into the + * application that uses libbpf. + */ +#if defined(__i386__) || defined(__x86_64__) +# define libbpf_smp_rmb() asm volatile("" : : : "memory") +# define libbpf_smp_wmb() asm volatile("" : : : "memory") +# define libbpf_smp_mb() \ + asm volatile("lock; addl $0,-4(%%rsp)" : : : "memory", "cc") +/* Hinders stores to be observed before older loads. */ +# define libbpf_smp_rwmb() asm volatile("" : : : "memory") +#elif defined(__aarch64__) +# define libbpf_smp_rmb() asm volatile("dmb ishld" : : : "memory") +# define libbpf_smp_wmb() asm volatile("dmb ishst" : : : "memory") +# define libbpf_smp_mb() asm volatile("dmb ish" : : : "memory") +# define libbpf_smp_rwmb() libbpf_smp_mb() +#elif defined(__arm__) +/* These are only valid for armv7 and above */ +# define libbpf_smp_rmb() asm volatile("dmb ish" : : : "memory") +# define libbpf_smp_wmb() asm volatile("dmb ishst" : : : "memory") +# define libbpf_smp_mb() asm volatile("dmb ish" : : : "memory") +# define libbpf_smp_rwmb() libbpf_smp_mb() +#else +/* Architecture missing native barrier functions. */ +# define libbpf_smp_rmb() __sync_synchronize() +# define libbpf_smp_wmb() __sync_synchronize() +# define libbpf_smp_mb() __sync_synchronize() +# define libbpf_smp_rwmb() __sync_synchronize() +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff -Nru dwarves-dfsg-1.10/lib/bpf/src/Makefile dwarves-dfsg-1.21/lib/bpf/src/Makefile --- dwarves-dfsg-1.10/lib/bpf/src/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/Makefile 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,163 @@ +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +ifeq ($(V),1) + Q = + msg = +else + Q = @ + msg = @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))"; +endif + +LIBBPF_VERSION := $(shell \ + grep -oE '^LIBBPF_([0-9.]+)' libbpf.map | \ + sort -rV | head -n1 | cut -d'_' -f2) +LIBBPF_MAJOR_VERSION := $(firstword $(subst ., ,$(LIBBPF_VERSION))) + +TOPDIR = .. + +INCLUDES := -I. -I$(TOPDIR)/include -I$(TOPDIR)/include/uapi +ALL_CFLAGS := $(INCLUDES) + +SHARED_CFLAGS += -fPIC -fvisibility=hidden -DSHARED + +CFLAGS ?= -g -O2 -Werror -Wall +ALL_CFLAGS += $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +ALL_LDFLAGS += $(LDFLAGS) +ifdef NO_PKG_CONFIG + ALL_LDFLAGS += -lelf -lz +else + PKG_CONFIG ?= pkg-config + ALL_CFLAGS += $(shell $(PKG_CONFIG) --cflags libelf zlib) + ALL_LDFLAGS += $(shell $(PKG_CONFIG) --libs libelf zlib) +endif + +OBJDIR ?= . +SHARED_OBJDIR := $(OBJDIR)/sharedobjs +STATIC_OBJDIR := $(OBJDIR)/staticobjs +OBJS := bpf.o btf.o libbpf.o libbpf_errno.o netlink.o \ + nlattr.o str_error.o libbpf_probes.o bpf_prog_linfo.o xsk.o \ + btf_dump.o hashmap.o ringbuf.o +SHARED_OBJS := $(addprefix $(SHARED_OBJDIR)/,$(OBJS)) +STATIC_OBJS := $(addprefix $(STATIC_OBJDIR)/,$(OBJS)) + +STATIC_LIBS := $(OBJDIR)/libbpf.a +ifndef BUILD_STATIC_ONLY + SHARED_LIBS := $(OBJDIR)/libbpf.so \ + $(OBJDIR)/libbpf.so.$(LIBBPF_MAJOR_VERSION) \ + $(OBJDIR)/libbpf.so.$(LIBBPF_VERSION) + VERSION_SCRIPT := libbpf.map +endif + +HEADERS := bpf.h libbpf.h btf.h xsk.h libbpf_util.h \ + bpf_helpers.h bpf_helper_defs.h bpf_tracing.h \ + bpf_endian.h bpf_core_read.h libbpf_common.h +UAPI_HEADERS := $(addprefix $(TOPDIR)/include/uapi/linux/,\ + bpf.h bpf_common.h btf.h) + +PC_FILE := $(OBJDIR)/libbpf.pc + +INSTALL = install + +DESTDIR ?= + +ifeq ($(shell uname -m),x86_64) + LIBSUBDIR := lib64 +else + LIBSUBDIR := lib +endif + +# By default let the pc file itself use ${prefix} in includedir/libdir so that +# the prefix can be overridden at runtime (eg: --define-prefix) +ifndef LIBDIR + LIBDIR_PC := $$\{prefix\}/$(LIBSUBDIR) +else + LIBDIR_PC := $(LIBDIR) +endif +PREFIX ?= /usr +LIBDIR ?= $(PREFIX)/$(LIBSUBDIR) +INCLUDEDIR ?= $(PREFIX)/include +UAPIDIR ?= $(PREFIX)/include + +TAGS_PROG := $(if $(shell which etags 2>/dev/null),etags,ctags) + +all: $(STATIC_LIBS) $(SHARED_LIBS) $(PC_FILE) + +$(OBJDIR)/libbpf.a: $(STATIC_OBJS) + $(call msg,AR,$@) + $(Q)$(AR) rcs $@ $^ + +$(OBJDIR)/libbpf.so: $(OBJDIR)/libbpf.so.$(LIBBPF_MAJOR_VERSION) + $(Q)ln -sf $(^F) $@ + +$(OBJDIR)/libbpf.so.$(LIBBPF_MAJOR_VERSION): $(OBJDIR)/libbpf.so.$(LIBBPF_VERSION) + $(Q)ln -sf $(^F) $@ + +$(OBJDIR)/libbpf.so.$(LIBBPF_VERSION): $(SHARED_OBJS) + $(call msg,CC,$@) + $(Q)$(CC) -shared -Wl,--version-script=$(VERSION_SCRIPT) \ + -Wl,-soname,libbpf.so.$(LIBBPF_MAJOR_VERSION) \ + $^ $(ALL_LDFLAGS) -o $@ + +$(OBJDIR)/libbpf.pc: + $(Q)sed -e "s|@PREFIX@|$(PREFIX)|" \ + -e "s|@LIBDIR@|$(LIBDIR_PC)|" \ + -e "s|@VERSION@|$(LIBBPF_VERSION)|" \ + < libbpf.pc.template > $@ + +$(STATIC_OBJDIR) $(SHARED_OBJDIR): + $(call msg,MKDIR,$@) + $(Q)mkdir -p $@ + +$(STATIC_OBJDIR)/%.o: %.c | $(STATIC_OBJDIR) + $(call msg,CC,$@) + $(Q)$(CC) $(ALL_CFLAGS) $(CPPFLAGS) -c $< -o $@ + +$(SHARED_OBJDIR)/%.o: %.c | $(SHARED_OBJDIR) + $(call msg,CC,$@) + $(Q)$(CC) $(ALL_CFLAGS) $(SHARED_CFLAGS) $(CPPFLAGS) -c $< -o $@ + +define do_install + $(call msg,INSTALL,$1) + $(Q)if [ ! -d '$(DESTDIR)$2' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR)$2'; \ + fi; + $(Q)$(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR)$2' +endef + +# Preserve symlinks at installation. +define do_s_install + $(call msg,INSTALL,$1) + $(Q)if [ ! -d '$(DESTDIR)$2' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR)$2'; \ + fi; + $(Q)cp -fR $1 '$(DESTDIR)$2' +endef + +install: all install_headers install_pkgconfig + $(call do_s_install,$(STATIC_LIBS) $(SHARED_LIBS),$(LIBDIR)) + +install_headers: + $(call do_install,$(HEADERS),$(INCLUDEDIR)/bpf,644) + +# UAPI headers can be installed by a different package so they're not installed +# in by install rule. +install_uapi_headers: + $(call do_install,$(UAPI_HEADERS),$(UAPIDIR)/linux,644) + +install_pkgconfig: $(PC_FILE) + $(call do_install,$(PC_FILE),$(LIBDIR)/pkgconfig,644) + +clean: + $(call msg,CLEAN) + $(Q)rm -rf *.o *.a *.so *.so.* *.pc $(SHARED_OBJDIR) $(STATIC_OBJDIR) + +.PHONY: cscope tags +cscope: + $(call msg,CSCOPE) + $(Q)ls *.c *.h > cscope.files + $(Q)cscope -b -q -f cscope.out + +tags: + $(call msg,CTAGS) + $(Q)rm -f TAGS tags + $(Q)ls *.c *.h | xargs $(TAGS_PROG) -a diff -Nru dwarves-dfsg-1.10/lib/bpf/src/netlink.c dwarves-dfsg-1.21/lib/bpf/src/netlink.c --- dwarves-dfsg-1.10/lib/bpf/src/netlink.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/netlink.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,372 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +/* Copyright (c) 2018 Facebook */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bpf.h" +#include "libbpf.h" +#include "libbpf_internal.h" +#include "nlattr.h" + +#ifndef SOL_NETLINK +#define SOL_NETLINK 270 +#endif + +typedef int (*libbpf_dump_nlmsg_t)(void *cookie, void *msg, struct nlattr **tb); + +typedef int (*__dump_nlmsg_t)(struct nlmsghdr *nlmsg, libbpf_dump_nlmsg_t, + void *cookie); + +struct xdp_id_md { + int ifindex; + __u32 flags; + struct xdp_link_info info; +}; + +static int libbpf_netlink_open(__u32 *nl_pid) +{ + struct sockaddr_nl sa; + socklen_t addrlen; + int one = 1, ret; + int sock; + + memset(&sa, 0, sizeof(sa)); + sa.nl_family = AF_NETLINK; + + sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); + if (sock < 0) + return -errno; + + if (setsockopt(sock, SOL_NETLINK, NETLINK_EXT_ACK, + &one, sizeof(one)) < 0) { + pr_warn("Netlink error reporting not supported\n"); + } + + if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0) { + ret = -errno; + goto cleanup; + } + + addrlen = sizeof(sa); + if (getsockname(sock, (struct sockaddr *)&sa, &addrlen) < 0) { + ret = -errno; + goto cleanup; + } + + if (addrlen != sizeof(sa)) { + ret = -LIBBPF_ERRNO__INTERNAL; + goto cleanup; + } + + *nl_pid = sa.nl_pid; + return sock; + +cleanup: + close(sock); + return ret; +} + +static int bpf_netlink_recv(int sock, __u32 nl_pid, int seq, + __dump_nlmsg_t _fn, libbpf_dump_nlmsg_t fn, + void *cookie) +{ + bool multipart = true; + struct nlmsgerr *err; + struct nlmsghdr *nh; + char buf[4096]; + int len, ret; + + while (multipart) { + multipart = false; + len = recv(sock, buf, sizeof(buf), 0); + if (len < 0) { + ret = -errno; + goto done; + } + + if (len == 0) + break; + + for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); + nh = NLMSG_NEXT(nh, len)) { + if (nh->nlmsg_pid != nl_pid) { + ret = -LIBBPF_ERRNO__WRNGPID; + goto done; + } + if (nh->nlmsg_seq != seq) { + ret = -LIBBPF_ERRNO__INVSEQ; + goto done; + } + if (nh->nlmsg_flags & NLM_F_MULTI) + multipart = true; + switch (nh->nlmsg_type) { + case NLMSG_ERROR: + err = (struct nlmsgerr *)NLMSG_DATA(nh); + if (!err->error) + continue; + ret = err->error; + libbpf_nla_dump_errormsg(nh); + goto done; + case NLMSG_DONE: + return 0; + default: + break; + } + if (_fn) { + ret = _fn(nh, fn, cookie); + if (ret) + return ret; + } + } + } + ret = 0; +done: + return ret; +} + +static int __bpf_set_link_xdp_fd_replace(int ifindex, int fd, int old_fd, + __u32 flags) +{ + int sock, seq = 0, ret; + struct nlattr *nla, *nla_xdp; + struct { + struct nlmsghdr nh; + struct ifinfomsg ifinfo; + char attrbuf[64]; + } req; + __u32 nl_pid = 0; + + sock = libbpf_netlink_open(&nl_pid); + if (sock < 0) + return sock; + + memset(&req, 0, sizeof(req)); + req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); + req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; + req.nh.nlmsg_type = RTM_SETLINK; + req.nh.nlmsg_pid = 0; + req.nh.nlmsg_seq = ++seq; + req.ifinfo.ifi_family = AF_UNSPEC; + req.ifinfo.ifi_index = ifindex; + + /* started nested attribute for XDP */ + nla = (struct nlattr *)(((char *)&req) + + NLMSG_ALIGN(req.nh.nlmsg_len)); + nla->nla_type = NLA_F_NESTED | IFLA_XDP; + nla->nla_len = NLA_HDRLEN; + + /* add XDP fd */ + nla_xdp = (struct nlattr *)((char *)nla + nla->nla_len); + nla_xdp->nla_type = IFLA_XDP_FD; + nla_xdp->nla_len = NLA_HDRLEN + sizeof(int); + memcpy((char *)nla_xdp + NLA_HDRLEN, &fd, sizeof(fd)); + nla->nla_len += nla_xdp->nla_len; + + /* if user passed in any flags, add those too */ + if (flags) { + nla_xdp = (struct nlattr *)((char *)nla + nla->nla_len); + nla_xdp->nla_type = IFLA_XDP_FLAGS; + nla_xdp->nla_len = NLA_HDRLEN + sizeof(flags); + memcpy((char *)nla_xdp + NLA_HDRLEN, &flags, sizeof(flags)); + nla->nla_len += nla_xdp->nla_len; + } + + if (flags & XDP_FLAGS_REPLACE) { + nla_xdp = (struct nlattr *)((char *)nla + nla->nla_len); + nla_xdp->nla_type = IFLA_XDP_EXPECTED_FD; + nla_xdp->nla_len = NLA_HDRLEN + sizeof(old_fd); + memcpy((char *)nla_xdp + NLA_HDRLEN, &old_fd, sizeof(old_fd)); + nla->nla_len += nla_xdp->nla_len; + } + + req.nh.nlmsg_len += NLA_ALIGN(nla->nla_len); + + if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) { + ret = -errno; + goto cleanup; + } + ret = bpf_netlink_recv(sock, nl_pid, seq, NULL, NULL, NULL); + +cleanup: + close(sock); + return ret; +} + +int bpf_set_link_xdp_fd_opts(int ifindex, int fd, __u32 flags, + const struct bpf_xdp_set_link_opts *opts) +{ + int old_fd = -1; + + if (!OPTS_VALID(opts, bpf_xdp_set_link_opts)) + return -EINVAL; + + if (OPTS_HAS(opts, old_fd)) { + old_fd = OPTS_GET(opts, old_fd, -1); + flags |= XDP_FLAGS_REPLACE; + } + + return __bpf_set_link_xdp_fd_replace(ifindex, fd, + old_fd, + flags); +} + +int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags) +{ + return __bpf_set_link_xdp_fd_replace(ifindex, fd, 0, flags); +} + +static int __dump_link_nlmsg(struct nlmsghdr *nlh, + libbpf_dump_nlmsg_t dump_link_nlmsg, void *cookie) +{ + struct nlattr *tb[IFLA_MAX + 1], *attr; + struct ifinfomsg *ifi = NLMSG_DATA(nlh); + int len; + + len = nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*ifi)); + attr = (struct nlattr *) ((void *) ifi + NLMSG_ALIGN(sizeof(*ifi))); + if (libbpf_nla_parse(tb, IFLA_MAX, attr, len, NULL) != 0) + return -LIBBPF_ERRNO__NLPARSE; + + return dump_link_nlmsg(cookie, ifi, tb); +} + +static int get_xdp_info(void *cookie, void *msg, struct nlattr **tb) +{ + struct nlattr *xdp_tb[IFLA_XDP_MAX + 1]; + struct xdp_id_md *xdp_id = cookie; + struct ifinfomsg *ifinfo = msg; + int ret; + + if (xdp_id->ifindex && xdp_id->ifindex != ifinfo->ifi_index) + return 0; + + if (!tb[IFLA_XDP]) + return 0; + + ret = libbpf_nla_parse_nested(xdp_tb, IFLA_XDP_MAX, tb[IFLA_XDP], NULL); + if (ret) + return ret; + + if (!xdp_tb[IFLA_XDP_ATTACHED]) + return 0; + + xdp_id->info.attach_mode = libbpf_nla_getattr_u8( + xdp_tb[IFLA_XDP_ATTACHED]); + + if (xdp_id->info.attach_mode == XDP_ATTACHED_NONE) + return 0; + + if (xdp_tb[IFLA_XDP_PROG_ID]) + xdp_id->info.prog_id = libbpf_nla_getattr_u32( + xdp_tb[IFLA_XDP_PROG_ID]); + + if (xdp_tb[IFLA_XDP_SKB_PROG_ID]) + xdp_id->info.skb_prog_id = libbpf_nla_getattr_u32( + xdp_tb[IFLA_XDP_SKB_PROG_ID]); + + if (xdp_tb[IFLA_XDP_DRV_PROG_ID]) + xdp_id->info.drv_prog_id = libbpf_nla_getattr_u32( + xdp_tb[IFLA_XDP_DRV_PROG_ID]); + + if (xdp_tb[IFLA_XDP_HW_PROG_ID]) + xdp_id->info.hw_prog_id = libbpf_nla_getattr_u32( + xdp_tb[IFLA_XDP_HW_PROG_ID]); + + return 0; +} + +static int libbpf_nl_get_link(int sock, unsigned int nl_pid, + libbpf_dump_nlmsg_t dump_link_nlmsg, void *cookie); + +int bpf_get_link_xdp_info(int ifindex, struct xdp_link_info *info, + size_t info_size, __u32 flags) +{ + struct xdp_id_md xdp_id = {}; + int sock, ret; + __u32 nl_pid = 0; + __u32 mask; + + if (flags & ~XDP_FLAGS_MASK || !info_size) + return -EINVAL; + + /* Check whether the single {HW,DRV,SKB} mode is set */ + flags &= (XDP_FLAGS_SKB_MODE | XDP_FLAGS_DRV_MODE | XDP_FLAGS_HW_MODE); + mask = flags - 1; + if (flags && flags & mask) + return -EINVAL; + + sock = libbpf_netlink_open(&nl_pid); + if (sock < 0) + return sock; + + xdp_id.ifindex = ifindex; + xdp_id.flags = flags; + + ret = libbpf_nl_get_link(sock, nl_pid, get_xdp_info, &xdp_id); + if (!ret) { + size_t sz = min(info_size, sizeof(xdp_id.info)); + + memcpy(info, &xdp_id.info, sz); + memset((void *) info + sz, 0, info_size - sz); + } + + close(sock); + return ret; +} + +static __u32 get_xdp_id(struct xdp_link_info *info, __u32 flags) +{ + flags &= XDP_FLAGS_MODES; + + if (info->attach_mode != XDP_ATTACHED_MULTI && !flags) + return info->prog_id; + if (flags & XDP_FLAGS_DRV_MODE) + return info->drv_prog_id; + if (flags & XDP_FLAGS_HW_MODE) + return info->hw_prog_id; + if (flags & XDP_FLAGS_SKB_MODE) + return info->skb_prog_id; + + return 0; +} + +int bpf_get_link_xdp_id(int ifindex, __u32 *prog_id, __u32 flags) +{ + struct xdp_link_info info; + int ret; + + ret = bpf_get_link_xdp_info(ifindex, &info, sizeof(info), flags); + if (!ret) + *prog_id = get_xdp_id(&info, flags); + + return ret; +} + +int libbpf_nl_get_link(int sock, unsigned int nl_pid, + libbpf_dump_nlmsg_t dump_link_nlmsg, void *cookie) +{ + struct { + struct nlmsghdr nlh; + struct ifinfomsg ifm; + } req = { + .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)), + .nlh.nlmsg_type = RTM_GETLINK, + .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST, + .ifm.ifi_family = AF_PACKET, + }; + int seq = time(NULL); + + req.nlh.nlmsg_seq = seq; + if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0) + return -errno; + + return bpf_netlink_recv(sock, nl_pid, seq, __dump_link_nlmsg, + dump_link_nlmsg, cookie); +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/nlattr.c dwarves-dfsg-1.21/lib/bpf/src/nlattr.c --- dwarves-dfsg-1.10/lib/bpf/src/nlattr.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/nlattr.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,195 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +/* + * NETLINK Netlink attributes + * + * Copyright (c) 2003-2013 Thomas Graf + */ + +#include +#include +#include +#include +#include "nlattr.h" +#include "libbpf_internal.h" + +static uint16_t nla_attr_minlen[LIBBPF_NLA_TYPE_MAX+1] = { + [LIBBPF_NLA_U8] = sizeof(uint8_t), + [LIBBPF_NLA_U16] = sizeof(uint16_t), + [LIBBPF_NLA_U32] = sizeof(uint32_t), + [LIBBPF_NLA_U64] = sizeof(uint64_t), + [LIBBPF_NLA_STRING] = 1, + [LIBBPF_NLA_FLAG] = 0, +}; + +static struct nlattr *nla_next(const struct nlattr *nla, int *remaining) +{ + int totlen = NLA_ALIGN(nla->nla_len); + + *remaining -= totlen; + return (struct nlattr *) ((char *) nla + totlen); +} + +static int nla_ok(const struct nlattr *nla, int remaining) +{ + return remaining >= sizeof(*nla) && + nla->nla_len >= sizeof(*nla) && + nla->nla_len <= remaining; +} + +static int nla_type(const struct nlattr *nla) +{ + return nla->nla_type & NLA_TYPE_MASK; +} + +static int validate_nla(struct nlattr *nla, int maxtype, + struct libbpf_nla_policy *policy) +{ + struct libbpf_nla_policy *pt; + unsigned int minlen = 0; + int type = nla_type(nla); + + if (type < 0 || type > maxtype) + return 0; + + pt = &policy[type]; + + if (pt->type > LIBBPF_NLA_TYPE_MAX) + return 0; + + if (pt->minlen) + minlen = pt->minlen; + else if (pt->type != LIBBPF_NLA_UNSPEC) + minlen = nla_attr_minlen[pt->type]; + + if (libbpf_nla_len(nla) < minlen) + return -1; + + if (pt->maxlen && libbpf_nla_len(nla) > pt->maxlen) + return -1; + + if (pt->type == LIBBPF_NLA_STRING) { + char *data = libbpf_nla_data(nla); + + if (data[libbpf_nla_len(nla) - 1] != '\0') + return -1; + } + + return 0; +} + +static inline int nlmsg_len(const struct nlmsghdr *nlh) +{ + return nlh->nlmsg_len - NLMSG_HDRLEN; +} + +/** + * Create attribute index based on a stream of attributes. + * @arg tb Index array to be filled (maxtype+1 elements). + * @arg maxtype Maximum attribute type expected and accepted. + * @arg head Head of attribute stream. + * @arg len Length of attribute stream. + * @arg policy Attribute validation policy. + * + * Iterates over the stream of attributes and stores a pointer to each + * attribute in the index array using the attribute type as index to + * the array. Attribute with a type greater than the maximum type + * specified will be silently ignored in order to maintain backwards + * compatibility. If \a policy is not NULL, the attribute will be + * validated using the specified policy. + * + * @see nla_validate + * @return 0 on success or a negative error code. + */ +int libbpf_nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, + int len, struct libbpf_nla_policy *policy) +{ + struct nlattr *nla; + int rem, err; + + memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); + + libbpf_nla_for_each_attr(nla, head, len, rem) { + int type = nla_type(nla); + + if (type > maxtype) + continue; + + if (policy) { + err = validate_nla(nla, maxtype, policy); + if (err < 0) + goto errout; + } + + if (tb[type]) + pr_warn("Attribute of type %#x found multiple times in message, " + "previous attribute is being ignored.\n", type); + + tb[type] = nla; + } + + err = 0; +errout: + return err; +} + +/** + * Create attribute index based on nested attribute + * @arg tb Index array to be filled (maxtype+1 elements). + * @arg maxtype Maximum attribute type expected and accepted. + * @arg nla Nested Attribute. + * @arg policy Attribute validation policy. + * + * Feeds the stream of attributes nested into the specified attribute + * to libbpf_nla_parse(). + * + * @see libbpf_nla_parse + * @return 0 on success or a negative error code. + */ +int libbpf_nla_parse_nested(struct nlattr *tb[], int maxtype, + struct nlattr *nla, + struct libbpf_nla_policy *policy) +{ + return libbpf_nla_parse(tb, maxtype, libbpf_nla_data(nla), + libbpf_nla_len(nla), policy); +} + +/* dump netlink extended ack error message */ +int libbpf_nla_dump_errormsg(struct nlmsghdr *nlh) +{ + struct libbpf_nla_policy extack_policy[NLMSGERR_ATTR_MAX + 1] = { + [NLMSGERR_ATTR_MSG] = { .type = LIBBPF_NLA_STRING }, + [NLMSGERR_ATTR_OFFS] = { .type = LIBBPF_NLA_U32 }, + }; + struct nlattr *tb[NLMSGERR_ATTR_MAX + 1], *attr; + struct nlmsgerr *err; + char *errmsg = NULL; + int hlen, alen; + + /* no TLVs, nothing to do here */ + if (!(nlh->nlmsg_flags & NLM_F_ACK_TLVS)) + return 0; + + err = (struct nlmsgerr *)NLMSG_DATA(nlh); + hlen = sizeof(*err); + + /* if NLM_F_CAPPED is set then the inner err msg was capped */ + if (!(nlh->nlmsg_flags & NLM_F_CAPPED)) + hlen += nlmsg_len(&err->msg); + + attr = (struct nlattr *) ((void *) err + hlen); + alen = nlh->nlmsg_len - hlen; + + if (libbpf_nla_parse(tb, NLMSGERR_ATTR_MAX, attr, alen, + extack_policy) != 0) { + pr_warn("Failed to parse extended error attributes\n"); + return 0; + } + + if (tb[NLMSGERR_ATTR_MSG]) + errmsg = (char *) libbpf_nla_data(tb[NLMSGERR_ATTR_MSG]); + + pr_warn("Kernel error message: %s\n", errmsg); + + return 0; +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/nlattr.h dwarves-dfsg-1.21/lib/bpf/src/nlattr.h --- dwarves-dfsg-1.10/lib/bpf/src/nlattr.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/nlattr.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +/* + * NETLINK Netlink attributes + * + * Copyright (c) 2003-2013 Thomas Graf + */ + +#ifndef __LIBBPF_NLATTR_H +#define __LIBBPF_NLATTR_H + +#include +#include +/* avoid multiple definition of netlink features */ +#define __LINUX_NETLINK_H + +/** + * Standard attribute types to specify validation policy + */ +enum { + LIBBPF_NLA_UNSPEC, /**< Unspecified type, binary data chunk */ + LIBBPF_NLA_U8, /**< 8 bit integer */ + LIBBPF_NLA_U16, /**< 16 bit integer */ + LIBBPF_NLA_U32, /**< 32 bit integer */ + LIBBPF_NLA_U64, /**< 64 bit integer */ + LIBBPF_NLA_STRING, /**< NUL terminated character string */ + LIBBPF_NLA_FLAG, /**< Flag */ + LIBBPF_NLA_MSECS, /**< Micro seconds (64bit) */ + LIBBPF_NLA_NESTED, /**< Nested attributes */ + __LIBBPF_NLA_TYPE_MAX, +}; + +#define LIBBPF_NLA_TYPE_MAX (__LIBBPF_NLA_TYPE_MAX - 1) + +/** + * @ingroup attr + * Attribute validation policy. + * + * See section @core_doc{core_attr_parse,Attribute Parsing} for more details. + */ +struct libbpf_nla_policy { + /** Type of attribute or LIBBPF_NLA_UNSPEC */ + uint16_t type; + + /** Minimal length of payload required */ + uint16_t minlen; + + /** Maximal length of payload allowed */ + uint16_t maxlen; +}; + +/** + * @ingroup attr + * Iterate over a stream of attributes + * @arg pos loop counter, set to current attribute + * @arg head head of attribute stream + * @arg len length of attribute stream + * @arg rem initialized to len, holds bytes currently remaining in stream + */ +#define libbpf_nla_for_each_attr(pos, head, len, rem) \ + for (pos = head, rem = len; \ + nla_ok(pos, rem); \ + pos = nla_next(pos, &(rem))) + +/** + * libbpf_nla_data - head of payload + * @nla: netlink attribute + */ +static inline void *libbpf_nla_data(const struct nlattr *nla) +{ + return (char *) nla + NLA_HDRLEN; +} + +static inline uint8_t libbpf_nla_getattr_u8(const struct nlattr *nla) +{ + return *(uint8_t *)libbpf_nla_data(nla); +} + +static inline uint32_t libbpf_nla_getattr_u32(const struct nlattr *nla) +{ + return *(uint32_t *)libbpf_nla_data(nla); +} + +static inline const char *libbpf_nla_getattr_str(const struct nlattr *nla) +{ + return (const char *)libbpf_nla_data(nla); +} + +/** + * libbpf_nla_len - length of payload + * @nla: netlink attribute + */ +static inline int libbpf_nla_len(const struct nlattr *nla) +{ + return nla->nla_len - NLA_HDRLEN; +} + +int libbpf_nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, + int len, struct libbpf_nla_policy *policy); +int libbpf_nla_parse_nested(struct nlattr *tb[], int maxtype, + struct nlattr *nla, + struct libbpf_nla_policy *policy); + +int libbpf_nla_dump_errormsg(struct nlmsghdr *nlh); + +#endif /* __LIBBPF_NLATTR_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/src/README.rst dwarves-dfsg-1.21/lib/bpf/src/README.rst --- dwarves-dfsg-1.10/lib/bpf/src/README.rst 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/README.rst 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,168 @@ +.. SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +libbpf API naming convention +============================ + +libbpf API provides access to a few logically separated groups of +functions and types. Every group has its own naming convention +described here. It's recommended to follow these conventions whenever a +new function or type is added to keep libbpf API clean and consistent. + +All types and functions provided by libbpf API should have one of the +following prefixes: ``bpf_``, ``btf_``, ``libbpf_``, ``xsk_``, +``perf_buffer_``. + +System call wrappers +-------------------- + +System call wrappers are simple wrappers for commands supported by +sys_bpf system call. These wrappers should go to ``bpf.h`` header file +and map one-on-one to corresponding commands. + +For example ``bpf_map_lookup_elem`` wraps ``BPF_MAP_LOOKUP_ELEM`` +command of sys_bpf, ``bpf_prog_attach`` wraps ``BPF_PROG_ATTACH``, etc. + +Objects +------- + +Another class of types and functions provided by libbpf API is "objects" +and functions to work with them. Objects are high-level abstractions +such as BPF program or BPF map. They're represented by corresponding +structures such as ``struct bpf_object``, ``struct bpf_program``, +``struct bpf_map``, etc. + +Structures are forward declared and access to their fields should be +provided via corresponding getters and setters rather than directly. + +These objects are associated with corresponding parts of ELF object that +contains compiled BPF programs. + +For example ``struct bpf_object`` represents ELF object itself created +from an ELF file or from a buffer, ``struct bpf_program`` represents a +program in ELF object and ``struct bpf_map`` is a map. + +Functions that work with an object have names built from object name, +double underscore and part that describes function purpose. + +For example ``bpf_object__open`` consists of the name of corresponding +object, ``bpf_object``, double underscore and ``open`` that defines the +purpose of the function to open ELF file and create ``bpf_object`` from +it. + +Another example: ``bpf_program__load`` is named for corresponding +object, ``bpf_program``, that is separated from other part of the name +by double underscore. + +All objects and corresponding functions other than BTF related should go +to ``libbpf.h``. BTF types and functions should go to ``btf.h``. + +Auxiliary functions +------------------- + +Auxiliary functions and types that don't fit well in any of categories +described above should have ``libbpf_`` prefix, e.g. +``libbpf_get_error`` or ``libbpf_prog_type_by_name``. + +AF_XDP functions +------------------- + +AF_XDP functions should have an ``xsk_`` prefix, e.g. +``xsk_umem__get_data`` or ``xsk_umem__create``. The interface consists +of both low-level ring access functions and high-level configuration +functions. These can be mixed and matched. Note that these functions +are not reentrant for performance reasons. + +Please take a look at Documentation/networking/af_xdp.rst in the Linux +kernel source tree on how to use XDP sockets and for some common +mistakes in case you do not get any traffic up to user space. + +libbpf ABI +========== + +libbpf can be both linked statically or used as DSO. To avoid possible +conflicts with other libraries an application is linked with, all +non-static libbpf symbols should have one of the prefixes mentioned in +API documentation above. See API naming convention to choose the right +name for a new symbol. + +Symbol visibility +----------------- + +libbpf follow the model when all global symbols have visibility "hidden" +by default and to make a symbol visible it has to be explicitly +attributed with ``LIBBPF_API`` macro. For example: + +.. code-block:: c + + LIBBPF_API int bpf_prog_get_fd_by_id(__u32 id); + +This prevents from accidentally exporting a symbol, that is not supposed +to be a part of ABI what, in turn, improves both libbpf developer- and +user-experiences. + +ABI versionning +--------------- + +To make future ABI extensions possible libbpf ABI is versioned. +Versioning is implemented by ``libbpf.map`` version script that is +passed to linker. + +Version name is ``LIBBPF_`` prefix + three-component numeric version, +starting from ``0.0.1``. + +Every time ABI is being changed, e.g. because a new symbol is added or +semantic of existing symbol is changed, ABI version should be bumped. +This bump in ABI version is at most once per kernel development cycle. + +For example, if current state of ``libbpf.map`` is: + +.. code-block:: + LIBBPF_0.0.1 { + global: + bpf_func_a; + bpf_func_b; + local: + \*; + }; + +, and a new symbol ``bpf_func_c`` is being introduced, then +``libbpf.map`` should be changed like this: + +.. code-block:: + LIBBPF_0.0.1 { + global: + bpf_func_a; + bpf_func_b; + local: + \*; + }; + LIBBPF_0.0.2 { + global: + bpf_func_c; + } LIBBPF_0.0.1; + +, where new version ``LIBBPF_0.0.2`` depends on the previous +``LIBBPF_0.0.1``. + +Format of version script and ways to handle ABI changes, including +incompatible ones, described in details in [1]. + +Stand-alone build +================= + +Under https://github.com/libbpf/libbpf there is a (semi-)automated +mirror of the mainline's version of libbpf for a stand-alone build. + +However, all changes to libbpf's code base must be upstreamed through +the mainline kernel tree. + +License +======= + +libbpf is dual-licensed under LGPL 2.1 and BSD 2-Clause. + +Links +===== + +[1] https://www.akkadia.org/drepper/dsohowto.pdf + (Chapter 3. Maintaining APIs and ABIs). diff -Nru dwarves-dfsg-1.10/lib/bpf/src/ringbuf.c dwarves-dfsg-1.21/lib/bpf/src/ringbuf.c --- dwarves-dfsg-1.10/lib/bpf/src/ringbuf.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/ringbuf.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,290 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +/* + * Ring buffer operations. + * + * Copyright (C) 2020 Facebook, Inc. + */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libbpf.h" +#include "libbpf_internal.h" +#include "bpf.h" + +struct ring { + ring_buffer_sample_fn sample_cb; + void *ctx; + void *data; + unsigned long *consumer_pos; + unsigned long *producer_pos; + unsigned long mask; + int map_fd; +}; + +struct ring_buffer { + struct epoll_event *events; + struct ring *rings; + size_t page_size; + int epoll_fd; + int ring_cnt; +}; + +static void ringbuf_unmap_ring(struct ring_buffer *rb, struct ring *r) +{ + if (r->consumer_pos) { + munmap(r->consumer_pos, rb->page_size); + r->consumer_pos = NULL; + } + if (r->producer_pos) { + munmap(r->producer_pos, rb->page_size + 2 * (r->mask + 1)); + r->producer_pos = NULL; + } +} + +/* Add extra RINGBUF maps to this ring buffer manager */ +int ring_buffer__add(struct ring_buffer *rb, int map_fd, + ring_buffer_sample_fn sample_cb, void *ctx) +{ + struct bpf_map_info info; + __u32 len = sizeof(info); + struct epoll_event *e; + struct ring *r; + void *tmp; + int err; + + memset(&info, 0, sizeof(info)); + + err = bpf_obj_get_info_by_fd(map_fd, &info, &len); + if (err) { + err = -errno; + pr_warn("ringbuf: failed to get map info for fd=%d: %d\n", + map_fd, err); + return err; + } + + if (info.type != BPF_MAP_TYPE_RINGBUF) { + pr_warn("ringbuf: map fd=%d is not BPF_MAP_TYPE_RINGBUF\n", + map_fd); + return -EINVAL; + } + + tmp = libbpf_reallocarray(rb->rings, rb->ring_cnt + 1, sizeof(*rb->rings)); + if (!tmp) + return -ENOMEM; + rb->rings = tmp; + + tmp = libbpf_reallocarray(rb->events, rb->ring_cnt + 1, sizeof(*rb->events)); + if (!tmp) + return -ENOMEM; + rb->events = tmp; + + r = &rb->rings[rb->ring_cnt]; + memset(r, 0, sizeof(*r)); + + r->map_fd = map_fd; + r->sample_cb = sample_cb; + r->ctx = ctx; + r->mask = info.max_entries - 1; + + /* Map writable consumer page */ + tmp = mmap(NULL, rb->page_size, PROT_READ | PROT_WRITE, MAP_SHARED, + map_fd, 0); + if (tmp == MAP_FAILED) { + err = -errno; + pr_warn("ringbuf: failed to mmap consumer page for map fd=%d: %d\n", + map_fd, err); + return err; + } + r->consumer_pos = tmp; + + /* Map read-only producer page and data pages. We map twice as big + * data size to allow simple reading of samples that wrap around the + * end of a ring buffer. See kernel implementation for details. + * */ + tmp = mmap(NULL, rb->page_size + 2 * info.max_entries, PROT_READ, + MAP_SHARED, map_fd, rb->page_size); + if (tmp == MAP_FAILED) { + err = -errno; + ringbuf_unmap_ring(rb, r); + pr_warn("ringbuf: failed to mmap data pages for map fd=%d: %d\n", + map_fd, err); + return err; + } + r->producer_pos = tmp; + r->data = tmp + rb->page_size; + + e = &rb->events[rb->ring_cnt]; + memset(e, 0, sizeof(*e)); + + e->events = EPOLLIN; + e->data.fd = rb->ring_cnt; + if (epoll_ctl(rb->epoll_fd, EPOLL_CTL_ADD, map_fd, e) < 0) { + err = -errno; + ringbuf_unmap_ring(rb, r); + pr_warn("ringbuf: failed to epoll add map fd=%d: %d\n", + map_fd, err); + return err; + } + + rb->ring_cnt++; + return 0; +} + +void ring_buffer__free(struct ring_buffer *rb) +{ + int i; + + if (!rb) + return; + + for (i = 0; i < rb->ring_cnt; ++i) + ringbuf_unmap_ring(rb, &rb->rings[i]); + if (rb->epoll_fd >= 0) + close(rb->epoll_fd); + + free(rb->events); + free(rb->rings); + free(rb); +} + +struct ring_buffer * +ring_buffer__new(int map_fd, ring_buffer_sample_fn sample_cb, void *ctx, + const struct ring_buffer_opts *opts) +{ + struct ring_buffer *rb; + int err; + + if (!OPTS_VALID(opts, ring_buffer_opts)) + return NULL; + + rb = calloc(1, sizeof(*rb)); + if (!rb) + return NULL; + + rb->page_size = getpagesize(); + + rb->epoll_fd = epoll_create1(EPOLL_CLOEXEC); + if (rb->epoll_fd < 0) { + err = -errno; + pr_warn("ringbuf: failed to create epoll instance: %d\n", err); + goto err_out; + } + + err = ring_buffer__add(rb, map_fd, sample_cb, ctx); + if (err) + goto err_out; + + return rb; + +err_out: + ring_buffer__free(rb); + return NULL; +} + +static inline int roundup_len(__u32 len) +{ + /* clear out top 2 bits (discard and busy, if set) */ + len <<= 2; + len >>= 2; + /* add length prefix */ + len += BPF_RINGBUF_HDR_SZ; + /* round up to 8 byte alignment */ + return (len + 7) / 8 * 8; +} + +static int ringbuf_process_ring(struct ring* r) +{ + int *len_ptr, len, err, cnt = 0; + unsigned long cons_pos, prod_pos; + bool got_new_data; + void *sample; + + cons_pos = smp_load_acquire(r->consumer_pos); + do { + got_new_data = false; + prod_pos = smp_load_acquire(r->producer_pos); + while (cons_pos < prod_pos) { + len_ptr = r->data + (cons_pos & r->mask); + len = smp_load_acquire(len_ptr); + + /* sample not committed yet, bail out for now */ + if (len & BPF_RINGBUF_BUSY_BIT) + goto done; + + got_new_data = true; + cons_pos += roundup_len(len); + + if ((len & BPF_RINGBUF_DISCARD_BIT) == 0) { + sample = (void *)len_ptr + BPF_RINGBUF_HDR_SZ; + err = r->sample_cb(r->ctx, sample, len); + if (err) { + /* update consumer pos and bail out */ + smp_store_release(r->consumer_pos, + cons_pos); + return err; + } + cnt++; + } + + smp_store_release(r->consumer_pos, cons_pos); + } + } while (got_new_data); +done: + return cnt; +} + +/* Consume available ring buffer(s) data without event polling. + * Returns number of records consumed across all registered ring buffers, or + * negative number if any of the callbacks return error. + */ +int ring_buffer__consume(struct ring_buffer *rb) +{ + int i, err, res = 0; + + for (i = 0; i < rb->ring_cnt; i++) { + struct ring *ring = &rb->rings[i]; + + err = ringbuf_process_ring(ring); + if (err < 0) + return err; + res += err; + } + return res; +} + +/* Poll for available data and consume records, if any are available. + * Returns number of records consumed, or negative number, if any of the + * registered callbacks returned error. + */ +int ring_buffer__poll(struct ring_buffer *rb, int timeout_ms) +{ + int i, cnt, err, res = 0; + + cnt = epoll_wait(rb->epoll_fd, rb->events, rb->ring_cnt, timeout_ms); + for (i = 0; i < cnt; i++) { + __u32 ring_id = rb->events[i].data.fd; + struct ring *ring = &rb->rings[ring_id]; + + err = ringbuf_process_ring(ring); + if (err < 0) + return err; + res += err; + } + return cnt < 0 ? -errno : res; +} + +/* Get an fd that can be used to sleep until data is available in the ring(s) */ +int ring_buffer__epoll_fd(const struct ring_buffer *rb) +{ + return rb->epoll_fd; +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/str_error.c dwarves-dfsg-1.21/lib/bpf/src/str_error.c --- dwarves-dfsg-1.10/lib/bpf/src/str_error.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/str_error.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +#undef _GNU_SOURCE +#include +#include +#include "str_error.h" + +/* make sure libbpf doesn't use kernel-only integer typedefs */ +#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64 + +/* + * Wrapper to allow for building in non-GNU systems such as Alpine Linux's musl + * libc, while checking strerror_r() return to avoid having to check this in + * all places calling it. + */ +char *libbpf_strerror_r(int err, char *dst, int len) +{ + int ret = strerror_r(err < 0 ? -err : err, dst, len); + if (ret) + snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret); + return dst; +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/str_error.h dwarves-dfsg-1.21/lib/bpf/src/str_error.h --- dwarves-dfsg-1.10/lib/bpf/src/str_error.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/str_error.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ +#ifndef __LIBBPF_STR_ERROR_H +#define __LIBBPF_STR_ERROR_H + +char *libbpf_strerror_r(int err, char *dst, int len); +#endif /* __LIBBPF_STR_ERROR_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/src/xsk.c dwarves-dfsg-1.21/lib/bpf/src/xsk.c --- dwarves-dfsg-1.10/lib/bpf/src/xsk.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/xsk.c 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,1079 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +/* + * AF_XDP user-space access library. + * + * Copyright(c) 2018 - 2019 Intel Corporation. + * + * Author(s): Magnus Karlsson + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bpf.h" +#include "libbpf.h" +#include "libbpf_internal.h" +#include "xsk.h" + +#ifndef SOL_XDP + #define SOL_XDP 283 +#endif + +#ifndef AF_XDP + #define AF_XDP 44 +#endif + +#ifndef PF_XDP + #define PF_XDP AF_XDP +#endif + +enum xsk_prog { + XSK_PROG_FALLBACK, + XSK_PROG_REDIRECT_FLAGS, +}; + +struct xsk_umem { + struct xsk_ring_prod *fill_save; + struct xsk_ring_cons *comp_save; + char *umem_area; + struct xsk_umem_config config; + int fd; + int refcount; + struct list_head ctx_list; +}; + +struct xsk_ctx { + struct xsk_ring_prod *fill; + struct xsk_ring_cons *comp; + __u32 queue_id; + struct xsk_umem *umem; + int refcount; + int ifindex; + struct list_head list; + int prog_fd; + int xsks_map_fd; + char ifname[IFNAMSIZ]; +}; + +struct xsk_socket { + struct xsk_ring_cons *rx; + struct xsk_ring_prod *tx; + __u64 outstanding_tx; + struct xsk_ctx *ctx; + struct xsk_socket_config config; + int fd; +}; + +struct xsk_nl_info { + bool xdp_prog_attached; + int ifindex; + int fd; +}; + +/* Up until and including Linux 5.3 */ +struct xdp_ring_offset_v1 { + __u64 producer; + __u64 consumer; + __u64 desc; +}; + +/* Up until and including Linux 5.3 */ +struct xdp_mmap_offsets_v1 { + struct xdp_ring_offset_v1 rx; + struct xdp_ring_offset_v1 tx; + struct xdp_ring_offset_v1 fr; + struct xdp_ring_offset_v1 cr; +}; + +int xsk_umem__fd(const struct xsk_umem *umem) +{ + return umem ? umem->fd : -EINVAL; +} + +int xsk_socket__fd(const struct xsk_socket *xsk) +{ + return xsk ? xsk->fd : -EINVAL; +} + +static bool xsk_page_aligned(void *buffer) +{ + unsigned long addr = (unsigned long)buffer; + + return !(addr & (getpagesize() - 1)); +} + +static void xsk_set_umem_config(struct xsk_umem_config *cfg, + const struct xsk_umem_config *usr_cfg) +{ + if (!usr_cfg) { + cfg->fill_size = XSK_RING_PROD__DEFAULT_NUM_DESCS; + cfg->comp_size = XSK_RING_CONS__DEFAULT_NUM_DESCS; + cfg->frame_size = XSK_UMEM__DEFAULT_FRAME_SIZE; + cfg->frame_headroom = XSK_UMEM__DEFAULT_FRAME_HEADROOM; + cfg->flags = XSK_UMEM__DEFAULT_FLAGS; + return; + } + + cfg->fill_size = usr_cfg->fill_size; + cfg->comp_size = usr_cfg->comp_size; + cfg->frame_size = usr_cfg->frame_size; + cfg->frame_headroom = usr_cfg->frame_headroom; + cfg->flags = usr_cfg->flags; +} + +static int xsk_set_xdp_socket_config(struct xsk_socket_config *cfg, + const struct xsk_socket_config *usr_cfg) +{ + if (!usr_cfg) { + cfg->rx_size = XSK_RING_CONS__DEFAULT_NUM_DESCS; + cfg->tx_size = XSK_RING_PROD__DEFAULT_NUM_DESCS; + cfg->libbpf_flags = 0; + cfg->xdp_flags = 0; + cfg->bind_flags = 0; + return 0; + } + + if (usr_cfg->libbpf_flags & ~XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD) + return -EINVAL; + + cfg->rx_size = usr_cfg->rx_size; + cfg->tx_size = usr_cfg->tx_size; + cfg->libbpf_flags = usr_cfg->libbpf_flags; + cfg->xdp_flags = usr_cfg->xdp_flags; + cfg->bind_flags = usr_cfg->bind_flags; + + return 0; +} + +static void xsk_mmap_offsets_v1(struct xdp_mmap_offsets *off) +{ + struct xdp_mmap_offsets_v1 off_v1; + + /* getsockopt on a kernel <= 5.3 has no flags fields. + * Copy over the offsets to the correct places in the >=5.4 format + * and put the flags where they would have been on that kernel. + */ + memcpy(&off_v1, off, sizeof(off_v1)); + + off->rx.producer = off_v1.rx.producer; + off->rx.consumer = off_v1.rx.consumer; + off->rx.desc = off_v1.rx.desc; + off->rx.flags = off_v1.rx.consumer + sizeof(__u32); + + off->tx.producer = off_v1.tx.producer; + off->tx.consumer = off_v1.tx.consumer; + off->tx.desc = off_v1.tx.desc; + off->tx.flags = off_v1.tx.consumer + sizeof(__u32); + + off->fr.producer = off_v1.fr.producer; + off->fr.consumer = off_v1.fr.consumer; + off->fr.desc = off_v1.fr.desc; + off->fr.flags = off_v1.fr.consumer + sizeof(__u32); + + off->cr.producer = off_v1.cr.producer; + off->cr.consumer = off_v1.cr.consumer; + off->cr.desc = off_v1.cr.desc; + off->cr.flags = off_v1.cr.consumer + sizeof(__u32); +} + +static int xsk_get_mmap_offsets(int fd, struct xdp_mmap_offsets *off) +{ + socklen_t optlen; + int err; + + optlen = sizeof(*off); + err = getsockopt(fd, SOL_XDP, XDP_MMAP_OFFSETS, off, &optlen); + if (err) + return err; + + if (optlen == sizeof(*off)) + return 0; + + if (optlen == sizeof(struct xdp_mmap_offsets_v1)) { + xsk_mmap_offsets_v1(off); + return 0; + } + + return -EINVAL; +} + +static int xsk_create_umem_rings(struct xsk_umem *umem, int fd, + struct xsk_ring_prod *fill, + struct xsk_ring_cons *comp) +{ + struct xdp_mmap_offsets off; + void *map; + int err; + + err = setsockopt(fd, SOL_XDP, XDP_UMEM_FILL_RING, + &umem->config.fill_size, + sizeof(umem->config.fill_size)); + if (err) + return -errno; + + err = setsockopt(fd, SOL_XDP, XDP_UMEM_COMPLETION_RING, + &umem->config.comp_size, + sizeof(umem->config.comp_size)); + if (err) + return -errno; + + err = xsk_get_mmap_offsets(fd, &off); + if (err) + return -errno; + + map = mmap(NULL, off.fr.desc + umem->config.fill_size * sizeof(__u64), + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd, + XDP_UMEM_PGOFF_FILL_RING); + if (map == MAP_FAILED) + return -errno; + + fill->mask = umem->config.fill_size - 1; + fill->size = umem->config.fill_size; + fill->producer = map + off.fr.producer; + fill->consumer = map + off.fr.consumer; + fill->flags = map + off.fr.flags; + fill->ring = map + off.fr.desc; + fill->cached_cons = umem->config.fill_size; + + map = mmap(NULL, off.cr.desc + umem->config.comp_size * sizeof(__u64), + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd, + XDP_UMEM_PGOFF_COMPLETION_RING); + if (map == MAP_FAILED) { + err = -errno; + goto out_mmap; + } + + comp->mask = umem->config.comp_size - 1; + comp->size = umem->config.comp_size; + comp->producer = map + off.cr.producer; + comp->consumer = map + off.cr.consumer; + comp->flags = map + off.cr.flags; + comp->ring = map + off.cr.desc; + + return 0; + +out_mmap: + munmap(map, off.fr.desc + umem->config.fill_size * sizeof(__u64)); + return err; +} + +int xsk_umem__create_v0_0_4(struct xsk_umem **umem_ptr, void *umem_area, + __u64 size, struct xsk_ring_prod *fill, + struct xsk_ring_cons *comp, + const struct xsk_umem_config *usr_config) +{ + struct xdp_umem_reg mr; + struct xsk_umem *umem; + int err; + + if (!umem_area || !umem_ptr || !fill || !comp) + return -EFAULT; + if (!size && !xsk_page_aligned(umem_area)) + return -EINVAL; + + umem = calloc(1, sizeof(*umem)); + if (!umem) + return -ENOMEM; + + umem->fd = socket(AF_XDP, SOCK_RAW, 0); + if (umem->fd < 0) { + err = -errno; + goto out_umem_alloc; + } + + umem->umem_area = umem_area; + INIT_LIST_HEAD(&umem->ctx_list); + xsk_set_umem_config(&umem->config, usr_config); + + memset(&mr, 0, sizeof(mr)); + mr.addr = (uintptr_t)umem_area; + mr.len = size; + mr.chunk_size = umem->config.frame_size; + mr.headroom = umem->config.frame_headroom; + mr.flags = umem->config.flags; + + err = setsockopt(umem->fd, SOL_XDP, XDP_UMEM_REG, &mr, sizeof(mr)); + if (err) { + err = -errno; + goto out_socket; + } + + err = xsk_create_umem_rings(umem, umem->fd, fill, comp); + if (err) + goto out_socket; + + umem->fill_save = fill; + umem->comp_save = comp; + *umem_ptr = umem; + return 0; + +out_socket: + close(umem->fd); +out_umem_alloc: + free(umem); + return err; +} + +struct xsk_umem_config_v1 { + __u32 fill_size; + __u32 comp_size; + __u32 frame_size; + __u32 frame_headroom; +}; + +int xsk_umem__create_v0_0_2(struct xsk_umem **umem_ptr, void *umem_area, + __u64 size, struct xsk_ring_prod *fill, + struct xsk_ring_cons *comp, + const struct xsk_umem_config *usr_config) +{ + struct xsk_umem_config config; + + memcpy(&config, usr_config, sizeof(struct xsk_umem_config_v1)); + config.flags = 0; + + return xsk_umem__create_v0_0_4(umem_ptr, umem_area, size, fill, comp, + &config); +} +COMPAT_VERSION(xsk_umem__create_v0_0_2, xsk_umem__create, LIBBPF_0.0.2) +DEFAULT_VERSION(xsk_umem__create_v0_0_4, xsk_umem__create, LIBBPF_0.0.4) + +static enum xsk_prog get_xsk_prog(void) +{ + enum xsk_prog detected = XSK_PROG_FALLBACK; + struct bpf_load_program_attr prog_attr; + struct bpf_create_map_attr map_attr; + __u32 size_out, retval, duration; + char data_in = 0, data_out; + struct bpf_insn insns[] = { + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_MOV64_IMM(BPF_REG_2, 0), + BPF_MOV64_IMM(BPF_REG_3, XDP_PASS), + BPF_EMIT_CALL(BPF_FUNC_redirect_map), + BPF_EXIT_INSN(), + }; + int prog_fd, map_fd, ret; + + memset(&map_attr, 0, sizeof(map_attr)); + map_attr.map_type = BPF_MAP_TYPE_XSKMAP; + map_attr.key_size = sizeof(int); + map_attr.value_size = sizeof(int); + map_attr.max_entries = 1; + + map_fd = bpf_create_map_xattr(&map_attr); + if (map_fd < 0) + return detected; + + insns[0].imm = map_fd; + + memset(&prog_attr, 0, sizeof(prog_attr)); + prog_attr.prog_type = BPF_PROG_TYPE_XDP; + prog_attr.insns = insns; + prog_attr.insns_cnt = ARRAY_SIZE(insns); + prog_attr.license = "GPL"; + + prog_fd = bpf_load_program_xattr(&prog_attr, NULL, 0); + if (prog_fd < 0) { + close(map_fd); + return detected; + } + + ret = bpf_prog_test_run(prog_fd, 0, &data_in, 1, &data_out, &size_out, &retval, &duration); + if (!ret && retval == XDP_PASS) + detected = XSK_PROG_REDIRECT_FLAGS; + close(prog_fd); + close(map_fd); + return detected; +} + +static int xsk_load_xdp_prog(struct xsk_socket *xsk) +{ + static const int log_buf_size = 16 * 1024; + struct xsk_ctx *ctx = xsk->ctx; + char log_buf[log_buf_size]; + int err, prog_fd; + + /* This is the fallback C-program: + * SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx) + * { + * int ret, index = ctx->rx_queue_index; + * + * // A set entry here means that the correspnding queue_id + * // has an active AF_XDP socket bound to it. + * ret = bpf_redirect_map(&xsks_map, index, XDP_PASS); + * if (ret > 0) + * return ret; + * + * // Fallback for pre-5.3 kernels, not supporting default + * // action in the flags parameter. + * if (bpf_map_lookup_elem(&xsks_map, &index)) + * return bpf_redirect_map(&xsks_map, index, 0); + * return XDP_PASS; + * } + */ + struct bpf_insn prog[] = { + /* r2 = *(u32 *)(r1 + 16) */ + BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, 16), + /* *(u32 *)(r10 - 4) = r2 */ + BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_2, -4), + /* r1 = xskmap[] */ + BPF_LD_MAP_FD(BPF_REG_1, ctx->xsks_map_fd), + /* r3 = XDP_PASS */ + BPF_MOV64_IMM(BPF_REG_3, 2), + /* call bpf_redirect_map */ + BPF_EMIT_CALL(BPF_FUNC_redirect_map), + /* if w0 != 0 goto pc+13 */ + BPF_JMP32_IMM(BPF_JSGT, BPF_REG_0, 0, 13), + /* r2 = r10 */ + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + /* r2 += -4 */ + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), + /* r1 = xskmap[] */ + BPF_LD_MAP_FD(BPF_REG_1, ctx->xsks_map_fd), + /* call bpf_map_lookup_elem */ + BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), + /* r1 = r0 */ + BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), + /* r0 = XDP_PASS */ + BPF_MOV64_IMM(BPF_REG_0, 2), + /* if r1 == 0 goto pc+5 */ + BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 5), + /* r2 = *(u32 *)(r10 - 4) */ + BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_10, -4), + /* r1 = xskmap[] */ + BPF_LD_MAP_FD(BPF_REG_1, ctx->xsks_map_fd), + /* r3 = 0 */ + BPF_MOV64_IMM(BPF_REG_3, 0), + /* call bpf_redirect_map */ + BPF_EMIT_CALL(BPF_FUNC_redirect_map), + /* The jumps are to this instruction */ + BPF_EXIT_INSN(), + }; + + /* This is the post-5.3 kernel C-program: + * SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx) + * { + * return bpf_redirect_map(&xsks_map, ctx->rx_queue_index, XDP_PASS); + * } + */ + struct bpf_insn prog_redirect_flags[] = { + /* r2 = *(u32 *)(r1 + 16) */ + BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, 16), + /* r1 = xskmap[] */ + BPF_LD_MAP_FD(BPF_REG_1, ctx->xsks_map_fd), + /* r3 = XDP_PASS */ + BPF_MOV64_IMM(BPF_REG_3, 2), + /* call bpf_redirect_map */ + BPF_EMIT_CALL(BPF_FUNC_redirect_map), + BPF_EXIT_INSN(), + }; + size_t insns_cnt[] = {sizeof(prog) / sizeof(struct bpf_insn), + sizeof(prog_redirect_flags) / sizeof(struct bpf_insn), + }; + struct bpf_insn *progs[] = {prog, prog_redirect_flags}; + enum xsk_prog option = get_xsk_prog(); + + prog_fd = bpf_load_program(BPF_PROG_TYPE_XDP, progs[option], insns_cnt[option], + "LGPL-2.1 or BSD-2-Clause", 0, log_buf, + log_buf_size); + if (prog_fd < 0) { + pr_warn("BPF log buffer:\n%s", log_buf); + return prog_fd; + } + + err = bpf_set_link_xdp_fd(xsk->ctx->ifindex, prog_fd, + xsk->config.xdp_flags); + if (err) { + close(prog_fd); + return err; + } + + ctx->prog_fd = prog_fd; + return 0; +} + +static int xsk_get_max_queues(struct xsk_socket *xsk) +{ + struct ethtool_channels channels = { .cmd = ETHTOOL_GCHANNELS }; + struct xsk_ctx *ctx = xsk->ctx; + struct ifreq ifr = {}; + int fd, err, ret; + + fd = socket(AF_LOCAL, SOCK_DGRAM, 0); + if (fd < 0) + return -errno; + + ifr.ifr_data = (void *)&channels; + memcpy(ifr.ifr_name, ctx->ifname, IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = '\0'; + err = ioctl(fd, SIOCETHTOOL, &ifr); + if (err && errno != EOPNOTSUPP) { + ret = -errno; + goto out; + } + + if (err) { + /* If the device says it has no channels, then all traffic + * is sent to a single stream, so max queues = 1. + */ + ret = 1; + } else { + /* Take the max of rx, tx, combined. Drivers return + * the number of channels in different ways. + */ + ret = max(channels.max_rx, channels.max_tx); + ret = max(ret, (int)channels.max_combined); + } + +out: + close(fd); + return ret; +} + +static int xsk_create_bpf_maps(struct xsk_socket *xsk) +{ + struct xsk_ctx *ctx = xsk->ctx; + int max_queues; + int fd; + + max_queues = xsk_get_max_queues(xsk); + if (max_queues < 0) + return max_queues; + + fd = bpf_create_map_name(BPF_MAP_TYPE_XSKMAP, "xsks_map", + sizeof(int), sizeof(int), max_queues, 0); + if (fd < 0) + return fd; + + ctx->xsks_map_fd = fd; + + return 0; +} + +static void xsk_delete_bpf_maps(struct xsk_socket *xsk) +{ + struct xsk_ctx *ctx = xsk->ctx; + + bpf_map_delete_elem(ctx->xsks_map_fd, &ctx->queue_id); + close(ctx->xsks_map_fd); +} + +static int xsk_lookup_bpf_maps(struct xsk_socket *xsk) +{ + __u32 i, *map_ids, num_maps, prog_len = sizeof(struct bpf_prog_info); + __u32 map_len = sizeof(struct bpf_map_info); + struct bpf_prog_info prog_info = {}; + struct xsk_ctx *ctx = xsk->ctx; + struct bpf_map_info map_info; + int fd, err; + + err = bpf_obj_get_info_by_fd(ctx->prog_fd, &prog_info, &prog_len); + if (err) + return err; + + num_maps = prog_info.nr_map_ids; + + map_ids = calloc(prog_info.nr_map_ids, sizeof(*map_ids)); + if (!map_ids) + return -ENOMEM; + + memset(&prog_info, 0, prog_len); + prog_info.nr_map_ids = num_maps; + prog_info.map_ids = (__u64)(unsigned long)map_ids; + + err = bpf_obj_get_info_by_fd(ctx->prog_fd, &prog_info, &prog_len); + if (err) + goto out_map_ids; + + ctx->xsks_map_fd = -1; + + for (i = 0; i < prog_info.nr_map_ids; i++) { + fd = bpf_map_get_fd_by_id(map_ids[i]); + if (fd < 0) + continue; + + err = bpf_obj_get_info_by_fd(fd, &map_info, &map_len); + if (err) { + close(fd); + continue; + } + + if (!strcmp(map_info.name, "xsks_map")) { + ctx->xsks_map_fd = fd; + continue; + } + + close(fd); + } + + err = 0; + if (ctx->xsks_map_fd == -1) + err = -ENOENT; + +out_map_ids: + free(map_ids); + return err; +} + +static int xsk_set_bpf_maps(struct xsk_socket *xsk) +{ + struct xsk_ctx *ctx = xsk->ctx; + + return bpf_map_update_elem(ctx->xsks_map_fd, &ctx->queue_id, + &xsk->fd, 0); +} + +static int xsk_create_xsk_struct(int ifindex, struct xsk_socket *xsk) +{ + char ifname[IFNAMSIZ]; + struct xsk_ctx *ctx; + char *interface; + + ctx = calloc(1, sizeof(*ctx)); + if (!ctx) + return -ENOMEM; + + interface = if_indextoname(ifindex, &ifname[0]); + if (!interface) { + free(ctx); + return -errno; + } + + ctx->ifindex = ifindex; + memcpy(ctx->ifname, ifname, IFNAMSIZ -1); + ctx->ifname[IFNAMSIZ - 1] = 0; + + xsk->ctx = ctx; + + return 0; +} + +static int __xsk_setup_xdp_prog(struct xsk_socket *_xdp, + int *xsks_map_fd) +{ + struct xsk_socket *xsk = _xdp; + struct xsk_ctx *ctx = xsk->ctx; + __u32 prog_id = 0; + int err; + + err = bpf_get_link_xdp_id(ctx->ifindex, &prog_id, + xsk->config.xdp_flags); + if (err) + return err; + + if (!prog_id) { + err = xsk_create_bpf_maps(xsk); + if (err) + return err; + + err = xsk_load_xdp_prog(xsk); + if (err) { + goto err_load_xdp_prog; + } + } else { + ctx->prog_fd = bpf_prog_get_fd_by_id(prog_id); + if (ctx->prog_fd < 0) + return -errno; + err = xsk_lookup_bpf_maps(xsk); + if (err) { + close(ctx->prog_fd); + return err; + } + } + + if (xsk->rx) { + err = xsk_set_bpf_maps(xsk); + if (err) { + if (!prog_id) { + goto err_set_bpf_maps; + } else { + close(ctx->prog_fd); + return err; + } + } + } + if (xsks_map_fd) + *xsks_map_fd = ctx->xsks_map_fd; + + return 0; + +err_set_bpf_maps: + close(ctx->prog_fd); + bpf_set_link_xdp_fd(ctx->ifindex, -1, 0); +err_load_xdp_prog: + xsk_delete_bpf_maps(xsk); + + return err; +} + +static struct xsk_ctx *xsk_get_ctx(struct xsk_umem *umem, int ifindex, + __u32 queue_id) +{ + struct xsk_ctx *ctx; + + if (list_empty(&umem->ctx_list)) + return NULL; + + list_for_each_entry(ctx, &umem->ctx_list, list) { + if (ctx->ifindex == ifindex && ctx->queue_id == queue_id) { + ctx->refcount++; + return ctx; + } + } + + return NULL; +} + +static void xsk_put_ctx(struct xsk_ctx *ctx) +{ + struct xsk_umem *umem = ctx->umem; + struct xdp_mmap_offsets off; + int err; + + if (--ctx->refcount == 0) { + err = xsk_get_mmap_offsets(umem->fd, &off); + if (!err) { + munmap(ctx->fill->ring - off.fr.desc, + off.fr.desc + umem->config.fill_size * + sizeof(__u64)); + munmap(ctx->comp->ring - off.cr.desc, + off.cr.desc + umem->config.comp_size * + sizeof(__u64)); + } + + list_del(&ctx->list); + free(ctx); + } +} + +static struct xsk_ctx *xsk_create_ctx(struct xsk_socket *xsk, + struct xsk_umem *umem, int ifindex, + const char *ifname, __u32 queue_id, + struct xsk_ring_prod *fill, + struct xsk_ring_cons *comp) +{ + struct xsk_ctx *ctx; + int err; + + ctx = calloc(1, sizeof(*ctx)); + if (!ctx) + return NULL; + + if (!umem->fill_save) { + err = xsk_create_umem_rings(umem, xsk->fd, fill, comp); + if (err) { + free(ctx); + return NULL; + } + } else if (umem->fill_save != fill || umem->comp_save != comp) { + /* Copy over rings to new structs. */ + memcpy(fill, umem->fill_save, sizeof(*fill)); + memcpy(comp, umem->comp_save, sizeof(*comp)); + } + + ctx->ifindex = ifindex; + ctx->refcount = 1; + ctx->umem = umem; + ctx->queue_id = queue_id; + memcpy(ctx->ifname, ifname, IFNAMSIZ - 1); + ctx->ifname[IFNAMSIZ - 1] = '\0'; + + umem->fill_save = NULL; + umem->comp_save = NULL; + ctx->fill = fill; + ctx->comp = comp; + list_add(&ctx->list, &umem->ctx_list); + return ctx; +} + +static void xsk_destroy_xsk_struct(struct xsk_socket *xsk) +{ + free(xsk->ctx); + free(xsk); +} + +int xsk_socket__update_xskmap(struct xsk_socket *xsk, int fd) +{ + xsk->ctx->xsks_map_fd = fd; + return xsk_set_bpf_maps(xsk); +} + +int xsk_setup_xdp_prog(int ifindex, int *xsks_map_fd) +{ + struct xsk_socket *xsk; + int res; + + xsk = calloc(1, sizeof(*xsk)); + if (!xsk) + return -ENOMEM; + + res = xsk_create_xsk_struct(ifindex, xsk); + if (res) { + free(xsk); + return -EINVAL; + } + + res = __xsk_setup_xdp_prog(xsk, xsks_map_fd); + + xsk_destroy_xsk_struct(xsk); + + return res; +} + +int xsk_socket__create_shared(struct xsk_socket **xsk_ptr, + const char *ifname, + __u32 queue_id, struct xsk_umem *umem, + struct xsk_ring_cons *rx, + struct xsk_ring_prod *tx, + struct xsk_ring_prod *fill, + struct xsk_ring_cons *comp, + const struct xsk_socket_config *usr_config) +{ + void *rx_map = NULL, *tx_map = NULL; + struct sockaddr_xdp sxdp = {}; + struct xdp_mmap_offsets off; + struct xsk_socket *xsk; + struct xsk_ctx *ctx; + int err, ifindex; + + if (!umem || !xsk_ptr || !(rx || tx)) + return -EFAULT; + + xsk = calloc(1, sizeof(*xsk)); + if (!xsk) + return -ENOMEM; + + err = xsk_set_xdp_socket_config(&xsk->config, usr_config); + if (err) + goto out_xsk_alloc; + + xsk->outstanding_tx = 0; + ifindex = if_nametoindex(ifname); + if (!ifindex) { + err = -errno; + goto out_xsk_alloc; + } + + if (umem->refcount++ > 0) { + xsk->fd = socket(AF_XDP, SOCK_RAW, 0); + if (xsk->fd < 0) { + err = -errno; + goto out_xsk_alloc; + } + } else { + xsk->fd = umem->fd; + } + + ctx = xsk_get_ctx(umem, ifindex, queue_id); + if (!ctx) { + if (!fill || !comp) { + err = -EFAULT; + goto out_socket; + } + + ctx = xsk_create_ctx(xsk, umem, ifindex, ifname, queue_id, + fill, comp); + if (!ctx) { + err = -ENOMEM; + goto out_socket; + } + } + xsk->ctx = ctx; + + if (rx) { + err = setsockopt(xsk->fd, SOL_XDP, XDP_RX_RING, + &xsk->config.rx_size, + sizeof(xsk->config.rx_size)); + if (err) { + err = -errno; + goto out_put_ctx; + } + } + if (tx) { + err = setsockopt(xsk->fd, SOL_XDP, XDP_TX_RING, + &xsk->config.tx_size, + sizeof(xsk->config.tx_size)); + if (err) { + err = -errno; + goto out_put_ctx; + } + } + + err = xsk_get_mmap_offsets(xsk->fd, &off); + if (err) { + err = -errno; + goto out_put_ctx; + } + + if (rx) { + rx_map = mmap(NULL, off.rx.desc + + xsk->config.rx_size * sizeof(struct xdp_desc), + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, + xsk->fd, XDP_PGOFF_RX_RING); + if (rx_map == MAP_FAILED) { + err = -errno; + goto out_put_ctx; + } + + rx->mask = xsk->config.rx_size - 1; + rx->size = xsk->config.rx_size; + rx->producer = rx_map + off.rx.producer; + rx->consumer = rx_map + off.rx.consumer; + rx->flags = rx_map + off.rx.flags; + rx->ring = rx_map + off.rx.desc; + rx->cached_prod = *rx->producer; + rx->cached_cons = *rx->consumer; + } + xsk->rx = rx; + + if (tx) { + tx_map = mmap(NULL, off.tx.desc + + xsk->config.tx_size * sizeof(struct xdp_desc), + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, + xsk->fd, XDP_PGOFF_TX_RING); + if (tx_map == MAP_FAILED) { + err = -errno; + goto out_mmap_rx; + } + + tx->mask = xsk->config.tx_size - 1; + tx->size = xsk->config.tx_size; + tx->producer = tx_map + off.tx.producer; + tx->consumer = tx_map + off.tx.consumer; + tx->flags = tx_map + off.tx.flags; + tx->ring = tx_map + off.tx.desc; + tx->cached_prod = *tx->producer; + /* cached_cons is r->size bigger than the real consumer pointer + * See xsk_prod_nb_free + */ + tx->cached_cons = *tx->consumer + xsk->config.tx_size; + } + xsk->tx = tx; + + sxdp.sxdp_family = PF_XDP; + sxdp.sxdp_ifindex = ctx->ifindex; + sxdp.sxdp_queue_id = ctx->queue_id; + if (umem->refcount > 1) { + sxdp.sxdp_flags |= XDP_SHARED_UMEM; + sxdp.sxdp_shared_umem_fd = umem->fd; + } else { + sxdp.sxdp_flags = xsk->config.bind_flags; + } + + err = bind(xsk->fd, (struct sockaddr *)&sxdp, sizeof(sxdp)); + if (err) { + err = -errno; + goto out_mmap_tx; + } + + ctx->prog_fd = -1; + + if (!(xsk->config.libbpf_flags & XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD)) { + err = __xsk_setup_xdp_prog(xsk, NULL); + if (err) + goto out_mmap_tx; + } + + *xsk_ptr = xsk; + return 0; + +out_mmap_tx: + if (tx) + munmap(tx_map, off.tx.desc + + xsk->config.tx_size * sizeof(struct xdp_desc)); +out_mmap_rx: + if (rx) + munmap(rx_map, off.rx.desc + + xsk->config.rx_size * sizeof(struct xdp_desc)); +out_put_ctx: + xsk_put_ctx(ctx); +out_socket: + if (--umem->refcount) + close(xsk->fd); +out_xsk_alloc: + free(xsk); + return err; +} + +int xsk_socket__create(struct xsk_socket **xsk_ptr, const char *ifname, + __u32 queue_id, struct xsk_umem *umem, + struct xsk_ring_cons *rx, struct xsk_ring_prod *tx, + const struct xsk_socket_config *usr_config) +{ + return xsk_socket__create_shared(xsk_ptr, ifname, queue_id, umem, + rx, tx, umem->fill_save, + umem->comp_save, usr_config); +} + +int xsk_umem__delete(struct xsk_umem *umem) +{ + if (!umem) + return 0; + + if (umem->refcount) + return -EBUSY; + + close(umem->fd); + free(umem); + + return 0; +} + +void xsk_socket__delete(struct xsk_socket *xsk) +{ + size_t desc_sz = sizeof(struct xdp_desc); + struct xdp_mmap_offsets off; + struct xsk_umem *umem; + struct xsk_ctx *ctx; + int err; + + if (!xsk) + return; + + ctx = xsk->ctx; + umem = ctx->umem; + if (ctx->prog_fd != -1) { + xsk_delete_bpf_maps(xsk); + close(ctx->prog_fd); + } + + err = xsk_get_mmap_offsets(xsk->fd, &off); + if (!err) { + if (xsk->rx) { + munmap(xsk->rx->ring - off.rx.desc, + off.rx.desc + xsk->config.rx_size * desc_sz); + } + if (xsk->tx) { + munmap(xsk->tx->ring - off.tx.desc, + off.tx.desc + xsk->config.tx_size * desc_sz); + } + } + + xsk_put_ctx(ctx); + + umem->refcount--; + /* Do not close an fd that also has an associated umem connected + * to it. + */ + if (xsk->fd != umem->fd) + close(xsk->fd); + free(xsk); +} diff -Nru dwarves-dfsg-1.10/lib/bpf/src/xsk.h dwarves-dfsg-1.21/lib/bpf/src/xsk.h --- dwarves-dfsg-1.10/lib/bpf/src/xsk.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/src/xsk.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,263 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +/* + * AF_XDP user-space access library. + * + * Copyright(c) 2018 - 2019 Intel Corporation. + * + * Author(s): Magnus Karlsson + */ + +#ifndef __LIBBPF_XSK_H +#define __LIBBPF_XSK_H + +#include +#include +#include + +#include "libbpf.h" +#include "libbpf_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Do not access these members directly. Use the functions below. */ +#define DEFINE_XSK_RING(name) \ +struct name { \ + __u32 cached_prod; \ + __u32 cached_cons; \ + __u32 mask; \ + __u32 size; \ + __u32 *producer; \ + __u32 *consumer; \ + void *ring; \ + __u32 *flags; \ +} + +DEFINE_XSK_RING(xsk_ring_prod); +DEFINE_XSK_RING(xsk_ring_cons); + +/* For a detailed explanation on the memory barriers associated with the + * ring, please take a look at net/xdp/xsk_queue.h. + */ + +struct xsk_umem; +struct xsk_socket; + +static inline __u64 *xsk_ring_prod__fill_addr(struct xsk_ring_prod *fill, + __u32 idx) +{ + __u64 *addrs = (__u64 *)fill->ring; + + return &addrs[idx & fill->mask]; +} + +static inline const __u64 * +xsk_ring_cons__comp_addr(const struct xsk_ring_cons *comp, __u32 idx) +{ + const __u64 *addrs = (const __u64 *)comp->ring; + + return &addrs[idx & comp->mask]; +} + +static inline struct xdp_desc *xsk_ring_prod__tx_desc(struct xsk_ring_prod *tx, + __u32 idx) +{ + struct xdp_desc *descs = (struct xdp_desc *)tx->ring; + + return &descs[idx & tx->mask]; +} + +static inline const struct xdp_desc * +xsk_ring_cons__rx_desc(const struct xsk_ring_cons *rx, __u32 idx) +{ + const struct xdp_desc *descs = (const struct xdp_desc *)rx->ring; + + return &descs[idx & rx->mask]; +} + +static inline int xsk_ring_prod__needs_wakeup(const struct xsk_ring_prod *r) +{ + return *r->flags & XDP_RING_NEED_WAKEUP; +} + +static inline __u32 xsk_prod_nb_free(struct xsk_ring_prod *r, __u32 nb) +{ + __u32 free_entries = r->cached_cons - r->cached_prod; + + if (free_entries >= nb) + return free_entries; + + /* Refresh the local tail pointer. + * cached_cons is r->size bigger than the real consumer pointer so + * that this addition can be avoided in the more frequently + * executed code that computs free_entries in the beginning of + * this function. Without this optimization it whould have been + * free_entries = r->cached_prod - r->cached_cons + r->size. + */ + r->cached_cons = *r->consumer + r->size; + + return r->cached_cons - r->cached_prod; +} + +static inline __u32 xsk_cons_nb_avail(struct xsk_ring_cons *r, __u32 nb) +{ + __u32 entries = r->cached_prod - r->cached_cons; + + if (entries == 0) { + r->cached_prod = *r->producer; + entries = r->cached_prod - r->cached_cons; + } + + return (entries > nb) ? nb : entries; +} + +static inline __u32 xsk_ring_prod__reserve(struct xsk_ring_prod *prod, __u32 nb, __u32 *idx) +{ + if (xsk_prod_nb_free(prod, nb) < nb) + return 0; + + *idx = prod->cached_prod; + prod->cached_prod += nb; + + return nb; +} + +static inline void xsk_ring_prod__submit(struct xsk_ring_prod *prod, __u32 nb) +{ + /* Make sure everything has been written to the ring before indicating + * this to the kernel by writing the producer pointer. + */ + libbpf_smp_wmb(); + + *prod->producer += nb; +} + +static inline __u32 xsk_ring_cons__peek(struct xsk_ring_cons *cons, __u32 nb, __u32 *idx) +{ + __u32 entries = xsk_cons_nb_avail(cons, nb); + + if (entries > 0) { + /* Make sure we do not speculatively read the data before + * we have received the packet buffers from the ring. + */ + libbpf_smp_rmb(); + + *idx = cons->cached_cons; + cons->cached_cons += entries; + } + + return entries; +} + +static inline void xsk_ring_cons__cancel(struct xsk_ring_cons *cons, __u32 nb) +{ + cons->cached_cons -= nb; +} + +static inline void xsk_ring_cons__release(struct xsk_ring_cons *cons, __u32 nb) +{ + /* Make sure data has been read before indicating we are done + * with the entries by updating the consumer pointer. + */ + libbpf_smp_rwmb(); + + *cons->consumer += nb; +} + +static inline void *xsk_umem__get_data(void *umem_area, __u64 addr) +{ + return &((char *)umem_area)[addr]; +} + +static inline __u64 xsk_umem__extract_addr(__u64 addr) +{ + return addr & XSK_UNALIGNED_BUF_ADDR_MASK; +} + +static inline __u64 xsk_umem__extract_offset(__u64 addr) +{ + return addr >> XSK_UNALIGNED_BUF_OFFSET_SHIFT; +} + +static inline __u64 xsk_umem__add_offset_to_addr(__u64 addr) +{ + return xsk_umem__extract_addr(addr) + xsk_umem__extract_offset(addr); +} + +LIBBPF_API int xsk_umem__fd(const struct xsk_umem *umem); +LIBBPF_API int xsk_socket__fd(const struct xsk_socket *xsk); + +#define XSK_RING_CONS__DEFAULT_NUM_DESCS 2048 +#define XSK_RING_PROD__DEFAULT_NUM_DESCS 2048 +#define XSK_UMEM__DEFAULT_FRAME_SHIFT 12 /* 4096 bytes */ +#define XSK_UMEM__DEFAULT_FRAME_SIZE (1 << XSK_UMEM__DEFAULT_FRAME_SHIFT) +#define XSK_UMEM__DEFAULT_FRAME_HEADROOM 0 +#define XSK_UMEM__DEFAULT_FLAGS 0 + +struct xsk_umem_config { + __u32 fill_size; + __u32 comp_size; + __u32 frame_size; + __u32 frame_headroom; + __u32 flags; +}; + +LIBBPF_API int xsk_setup_xdp_prog(int ifindex, + int *xsks_map_fd); +LIBBPF_API int xsk_socket__update_xskmap(struct xsk_socket *xsk, + int xsks_map_fd); + +/* Flags for the libbpf_flags field. */ +#define XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD (1 << 0) + +struct xsk_socket_config { + __u32 rx_size; + __u32 tx_size; + __u32 libbpf_flags; + __u32 xdp_flags; + __u16 bind_flags; +}; + +/* Set config to NULL to get the default configuration. */ +LIBBPF_API int xsk_umem__create(struct xsk_umem **umem, + void *umem_area, __u64 size, + struct xsk_ring_prod *fill, + struct xsk_ring_cons *comp, + const struct xsk_umem_config *config); +LIBBPF_API int xsk_umem__create_v0_0_2(struct xsk_umem **umem, + void *umem_area, __u64 size, + struct xsk_ring_prod *fill, + struct xsk_ring_cons *comp, + const struct xsk_umem_config *config); +LIBBPF_API int xsk_umem__create_v0_0_4(struct xsk_umem **umem, + void *umem_area, __u64 size, + struct xsk_ring_prod *fill, + struct xsk_ring_cons *comp, + const struct xsk_umem_config *config); +LIBBPF_API int xsk_socket__create(struct xsk_socket **xsk, + const char *ifname, __u32 queue_id, + struct xsk_umem *umem, + struct xsk_ring_cons *rx, + struct xsk_ring_prod *tx, + const struct xsk_socket_config *config); +LIBBPF_API int +xsk_socket__create_shared(struct xsk_socket **xsk_ptr, + const char *ifname, + __u32 queue_id, struct xsk_umem *umem, + struct xsk_ring_cons *rx, + struct xsk_ring_prod *tx, + struct xsk_ring_prod *fill, + struct xsk_ring_cons *comp, + const struct xsk_socket_config *config); + +/* Returns 0 for success and -EBUSY if the umem is still in use. */ +LIBBPF_API int xsk_umem__delete(struct xsk_umem *umem); +LIBBPF_API void xsk_socket__delete(struct xsk_socket *xsk); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __LIBBPF_XSK_H */ diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/managers/debian.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/managers/debian.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/managers/debian.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/managers/debian.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,84 @@ +#!/bin/bash + +PHASES=(${@:-SETUP RUN RUN_ASAN CLEANUP}) +DEBIAN_RELEASE="${DEBIAN_RELEASE:-testing}" +CONT_NAME="${CONT_NAME:-libbpf-debian-$DEBIAN_RELEASE}" +ENV_VARS="${ENV_VARS:-}" +DOCKER_RUN="${DOCKER_RUN:-docker run}" +REPO_ROOT="${REPO_ROOT:-$PWD}" +ADDITIONAL_DEPS=(clang pkg-config gcc-10) +CFLAGS="-g -O2 -Werror -Wall" + +function info() { + echo -e "\033[33;1m$1\033[0m" +} + +function error() { + echo -e "\033[31;1m$1\033[0m" +} + +function docker_exec() { + docker exec $ENV_VARS -it $CONT_NAME "$@" +} + +set -e + +source "$(dirname $0)/travis_wait.bash" + +for phase in "${PHASES[@]}"; do + case $phase in + SETUP) + info "Setup phase" + info "Using Debian $DEBIAN_RELEASE" + + sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce + docker --version + + docker pull debian:$DEBIAN_RELEASE + info "Starting container $CONT_NAME" + $DOCKER_RUN -v $REPO_ROOT:/build:rw \ + -w /build --privileged=true --name $CONT_NAME \ + -dit --net=host debian:$DEBIAN_RELEASE /bin/bash + docker_exec bash -c "echo deb-src http://deb.debian.org/debian $DEBIAN_RELEASE main >>/etc/apt/sources.list" + docker_exec apt-get -y update + docker_exec apt-get -y build-dep libelf-dev + docker_exec apt-get -y install libelf-dev + docker_exec apt-get -y install "${ADDITIONAL_DEPS[@]}" + ;; + RUN|RUN_CLANG|RUN_GCC10|RUN_ASAN|RUN_CLANG_ASAN|RUN_GCC10_ASAN) + if [[ "$phase" = *"CLANG"* ]]; then + ENV_VARS="-e CC=clang -e CXX=clang++" + CC="clang" + elif [[ "$phase" = *"GCC10"* ]]; then + ENV_VARS="-e CC=gcc-10 -e CXX=g++-10" + CC="gcc-10" + else + CFLAGS="${CFLAGS} -Wno-stringop-truncation" + fi + if [[ "$phase" = *"ASAN"* ]]; then + CFLAGS="${CFLAGS} -fsanitize=address,undefined" + fi + docker_exec mkdir build install + docker_exec ${CC:-cc} --version + info "build" + docker_exec make -j$((4*$(nproc))) CFLAGS="${CFLAGS}" -C ./src -B OBJDIR=../build + info "ldd build/libbpf.so:" + docker_exec ldd build/libbpf.so + if ! docker_exec ldd build/libbpf.so | grep -q libelf; then + error "No reference to libelf.so in libbpf.so!" + exit 1 + fi + info "install" + docker_exec make -j$((4*$(nproc))) -C src OBJDIR=../build DESTDIR=../install install + docker_exec rm -rf build install + ;; + CLEANUP) + info "Cleanup phase" + docker stop $CONT_NAME + docker rm -f $CONT_NAME + ;; + *) + echo >&2 "Unknown phase '$phase'" + exit 1 + esac +done diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/managers/travis_wait.bash dwarves-dfsg-1.21/lib/bpf/travis-ci/managers/travis_wait.bash --- dwarves-dfsg-1.10/lib/bpf/travis-ci/managers/travis_wait.bash 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/managers/travis_wait.bash 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,61 @@ +# This was borrowed from https://github.com/travis-ci/travis-build/tree/master/lib/travis/build/bash +# to get around https://github.com/travis-ci/travis-ci/issues/9979. It should probably be removed +# as soon as Travis CI has started to provide an easy way to export the functions to bash scripts. + +travis_jigger() { + local cmd_pid="${1}" + shift + local timeout="${1}" + shift + local count=0 + + echo -e "\\n" + + while [[ "${count}" -lt "${timeout}" ]]; do + count="$((count + 1))" + echo -ne "Still running (${count} of ${timeout}): ${*}\\r" + sleep 60 + done + + echo -e "\\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"${*}\"${ANSI_RESET}\\n" + kill -9 "${cmd_pid}" +} + +travis_wait() { + local timeout="${1}" + + if [[ "${timeout}" =~ ^[0-9]+$ ]]; then + shift + else + timeout=20 + fi + + local cmd=("${@}") + local log_file="travis_wait_${$}.log" + + "${cmd[@]}" &>"${log_file}" & + local cmd_pid="${!}" + + travis_jigger "${!}" "${timeout}" "${cmd[@]}" & + local jigger_pid="${!}" + local result + + { + set +e + wait "${cmd_pid}" 2>/dev/null + result="${?}" + ps -p"${jigger_pid}" &>/dev/null && kill "${jigger_pid}" + set -e + } + + if [[ "${result}" -eq 0 ]]; then + echo -e "\\n${ANSI_GREEN}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" + else + echo -e "\\n${ANSI_RED}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" + fi + + echo -e "\\n${ANSI_GREEN}Log:${ANSI_RESET}\\n" + cat "${log_file}" + + return "${result}" +} diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/managers/ubuntu.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/managers/ubuntu.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/managers/ubuntu.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/managers/ubuntu.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,27 @@ +#!/bin/bash +set -e +set -x + +RELEASE="bionic" + +echo "deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse" >>/etc/apt/sources.list + +apt-get update +apt-get -y build-dep libelf-dev +apt-get install -y libelf-dev pkg-config + +source "$(dirname $0)/travis_wait.bash" + +cd $REPO_ROOT + +CFLAGS="-g -O2 -Werror -Wall -fsanitize=address,undefined" +mkdir build install +cc --version +make -j$((4*$(nproc))) CFLAGS="${CFLAGS}" -C ./src -B OBJDIR=../build +ldd build/libbpf.so +if ! ldd build/libbpf.so | grep -q libelf; then + echo "FAIL: No reference to libelf.so in libbpf.so!" + exit 1 +fi +make -j$((4*$(nproc))) -C src OBJDIR=../build DESTDIR=../install install +rm -rf build install diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/build_pahole.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/build_pahole.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/build_pahole.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/build_pahole.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,30 @@ +#!/bin/bash + +set -eu + +source $(cd $(dirname $0) && pwd)/helpers.sh + +travis_fold start build_pahole "Building pahole" + +CWD=$(pwd) +REPO_PATH=$1 +PAHOLE_ORIGIN=https://git.kernel.org/pub/scm/devel/pahole/pahole.git + +mkdir -p ${REPO_PATH} +cd ${REPO_PATH} +git init +git remote add origin ${PAHOLE_ORIGIN} +git fetch origin +git checkout master + +mkdir -p build +cd build +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -D__LIB=lib .. +make -j$((4*$(nproc))) all +sudo make install + +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:/usr/local/lib +ldd $(which pahole) +pahole --version + +travis_fold end build_pahole diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/build_selftests.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/build_selftests.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/build_selftests.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/build_selftests.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,43 @@ +#!/bin/bash + +set -euo pipefail + +source $(cd $(dirname $0) && pwd)/helpers.sh + +travis_fold start prepare_selftests "Building selftests" + +sudo apt-get -y install python-docutils # for rst2man + +LLVM_VER=13 +LIBBPF_PATH="${REPO_ROOT}" +REPO_PATH="travis-ci/vmtest/bpf-next" + +PREPARE_SELFTESTS_SCRIPT=${VMTEST_ROOT}/prepare_selftests-${KERNEL}.sh +if [ -f "${PREPARE_SELFTESTS_SCRIPT}" ]; then + (cd "${REPO_ROOT}/${REPO_PATH}/tools/testing/selftests/bpf" && ${PREPARE_SELFTESTS_SCRIPT}) +fi + +if [[ "${KERNEL}" = 'LATEST' ]]; then + VMLINUX_H= +else + VMLINUX_H=${VMTEST_ROOT}/vmlinux.h +fi + +make \ + CLANG=clang-${LLVM_VER} \ + LLC=llc-${LLVM_VER} \ + LLVM_STRIP=llvm-strip-${LLVM_VER} \ + VMLINUX_BTF="${VMLINUX_BTF}" \ + VMLINUX_H=${VMLINUX_H} \ + -C "${REPO_ROOT}/${REPO_PATH}/tools/testing/selftests/bpf" \ + -j $((4*$(nproc))) +mkdir ${LIBBPF_PATH}/selftests +cp -R "${REPO_ROOT}/${REPO_PATH}/tools/testing/selftests/bpf" \ + ${LIBBPF_PATH}/selftests +cd ${LIBBPF_PATH} +rm selftests/bpf/.gitignore +git add selftests + +git add "${VMTEST_ROOT}/configs/blacklist" + +travis_fold end prepare_selftests diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/checkout_latest_kernel.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/checkout_latest_kernel.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/checkout_latest_kernel.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/checkout_latest_kernel.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,44 @@ +#!/bin/bash + +set -eu + +source $(cd $(dirname $0) && pwd)/helpers.sh + +CWD=$(pwd) +LIBBPF_PATH=$(pwd) +REPO_PATH=$1 + +BPF_NEXT_ORIGIN=https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git +LINUX_SHA=$(cat ${LIBBPF_PATH}/CHECKPOINT-COMMIT) +SNAPSHOT_URL=https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/snapshot/bpf-next-${LINUX_SHA}.tar.gz + +echo REPO_PATH = ${REPO_PATH} +echo LINUX_SHA = ${LINUX_SHA} + +if [ ! -d "${REPO_PATH}" ]; then + echo + travis_fold start pull_kernel_srcs "Fetching kernel sources" + + mkdir -p $(dirname "${REPO_PATH}") + cd $(dirname "${REPO_PATH}") + # attempt to fetch desired bpf-next repo snapshot + if wget ${SNAPSHOT_URL} && tar xf bpf-next-${LINUX_SHA}.tar.gz ; then + mv bpf-next-${LINUX_SHA} $(basename ${REPO_PATH}) + else + # but fallback to git fetch approach if that fails + mkdir -p $(basename ${REPO_PATH}) + cd $(basename ${REPO_PATH}) + git init + git remote add bpf-next ${BPF_NEXT_ORIGIN} + # try shallow clone first + git fetch --depth 32 bpf-next + # check if desired SHA exists + if ! git cat-file -e ${LINUX_SHA}^{commit} ; then + # if not, fetch all of bpf-next; slow and painful + git fetch bpf-next + fi + git reset --hard ${LINUX_SHA} + fi + + travis_fold end pull_kernel_srcs +fi diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/configs/blacklist/BLACKLIST-5.5.0 dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/blacklist/BLACKLIST-5.5.0 --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/configs/blacklist/BLACKLIST-5.5.0 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/blacklist/BLACKLIST-5.5.0 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,93 @@ +# PERMANENTLY DISABLED +align # verifier output format changed +atomics # new atomic operations (v5.12+) +atomic_bounds # new atomic operations (v5.12+) +bind_perm # changed semantics of return values (v5.12+) +bpf_iter # bpf_iter support is missing +bpf_obj_id # bpf_link support missing for GET_OBJ_INFO, GET_FD_BY_ID, etc +bpf_tcp_ca # STRUCT_OPS is missing +btf_map_in_map # inner map leak fixed in 5.8 +btf_skc_cls_ingress # v5.10+ functionality +cg_storage_multi # v5.9+ functionality +cgroup_attach_multi # BPF_F_REPLACE_PROG missing +cgroup_link # LINK_CREATE is missing +cgroup_skb_sk_lookup # bpf_sk_lookup_tcp() helper is missing +check_mtu # missing BPF helper (v5.12+) +cls_redirect # bpf_csum_level() helper is missing +connect_force_port # cgroup/get{peer,sock}name{4,6} support is missing +d_path # v5.10+ feature +enable_stats # BPF_ENABLE_STATS support is missing +fentry_fexit # bpf_prog_test_tracing missing +fentry_test # bpf_prog_test_tracing missing +fexit_bpf2bpf # freplace is missing +fexit_test # bpf_prog_test_tracing missing +flow_dissector # bpf_link-based flow dissector is in 5.8+ +flow_dissector_reattach +for_each # v5.12+ +get_stack_raw_tp # exercising BPF verifier bug causing infinite loop +hash_large_key # v5.11+ +ima # v5.11+ +kfree_skb # 32-bit pointer arith in test_pkt_access +ksyms # __start_BTF has different name +link_pinning # bpf_link is missing +load_bytes_relative # new functionality in 5.8 +map_init # per-CPU LRU missing +map_ptr # test uses BPF_MAP_TYPE_RINGBUF, added in 5.8 +metadata # v5.10+ +mmap # 5.5 kernel is too permissive with re-mmaping +modify_return # fmod_ret support is missing +module_attach # module BTF support missing (v5.11+) +ns_current_pid_tgid # bpf_get_ns_current_pid_tgid() helper is missing +pe_preserve_elems # v5.10+ +perf_branches # bpf_read_branch_records() helper is missing +pkt_access # 32-bit pointer arith in test_pkt_access +probe_read_user_str # kernel bug with garbage bytes at the end +prog_run_xattr # 32-bit pointer arith in test_pkt_access +raw_tp_test_run # v5.10+ +recursion # v5.12+ +ringbuf # BPF_MAP_TYPE_RINGBUF is supported in 5.8+ + +# bug in verifier w/ tracking references +#reference_tracking/classifier/sk_lookup_success +reference_tracking + +select_reuseport # UDP support is missing +send_signal # bpf_send_signal_thread() helper is missing +sk_assign # bpf_sk_assign helper missing +sk_lookup # v5.9+ +sk_storage_tracing # missing bpf_sk_storage_get() helper +skb_ctx # ctx_{size, }_{in, out} in BPF_PROG_TEST_RUN is missing +skb_helpers # helpers added in 5.8+ +snprintf_btf # v5.10+ +sock_fields # v5.10+ +socket_cookie # v5.12+ +sockmap_basic # uses new socket fields, 5.8+ +sockmap_listen # no listen socket supportin SOCKMAP +sockopt_sk +stack_var_off # v5.12+ +task_local_storage # v5.12+ +tcp_hdr_options # v5.10+, new TCP header options feature in BPF +tcpbpf_user # LINK_CREATE is missing +test_bpffs # v5.10+, new CONFIG_BPF_PRELOAD=y and CONFIG_BPF_PRELOAD_UMG=y|m +test_bprm_opts # v5.11+ +test_global_funcs # kernel doesn't support BTF linkage=global on FUNCs +test_local_storage # v5.10+ feature +test_lsm # no BPF_LSM support +test_overhead # no fmod_ret support +test_profiler # needs verifier logic improvements from v5.10+ +test_skb_pkt_end # v5.11+ +trace_ext # v5.10+ +trampoline_count # v5.12+ have lower allowed limits +udp_limit # no cgroup/sock_release BPF program type (5.9+) +varlen # verifier bug fixed in later kernels +vmlinux # hrtimer_nanosleep() signature changed incompatibly +xdp_adjust_tail # new XDP functionality added in 5.8 +xdp_attach # IFLA_XDP_EXPECTED_FD support is missing +xdp_bpf2bpf # freplace is missing +xdp_cpumap_attach # v5.9+ +xdp_devmap_attach # new feature in 5.8 +xdp_link # v5.9+ + +# SUBTESTS FAILING (block entire test until blocking subtests works properly) +btf # "size check test", "func (Non zero vlen)" +tailcalls # tailcall_bpf2bpf_1, tailcall_bpf2bpf_2, tailcall_bpf2bpf_3 diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/configs/blacklist/BLACKLIST-latest dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/blacklist/BLACKLIST-latest --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/configs/blacklist/BLACKLIST-latest 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/blacklist/BLACKLIST-latest 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1 @@ +# TEMPORARY diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/configs/INDEX dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/INDEX --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/configs/INDEX 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/INDEX 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,8 @@ +INDEX https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/INDEX +libbpf-vmtest-rootfs-2020.09.27.tar.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/libbpf-vmtest-rootfs-2020.09.27.tar.zst +vmlinux-4.9.0.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinux-4.9.0.zst +vmlinux-5.5.0-rc6.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinux-5.5.0-rc6.zst +vmlinux-5.5.0.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinux-5.5.0.zst +vmlinuz-5.5.0-rc6 https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinuz-5.5.0-rc6 +vmlinuz-5.5.0 https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinuz-5.5.0 +vmlinuz-4.9.0 https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinuz-4.9.0 diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/configs/latest.config dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/latest.config --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/configs/latest.config 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/latest.config 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,3054 @@ +# +# Automatically generated file; DO NOT EDIT. +# Linux/x86 5.9.0-rc1 Kernel Configuration +# +CONFIG_CC_VERSION_TEXT="gcc (GCC) 8.2.1 20180801 (Red Hat 8.2.1-2)" +CONFIG_CC_IS_GCC=y +CONFIG_GCC_VERSION=80201 +CONFIG_LD_VERSION=230000000 +CONFIG_CLANG_VERSION=0 +CONFIG_CC_CAN_LINK=y +CONFIG_CC_CAN_LINK_STATIC=y +CONFIG_CC_HAS_ASM_GOTO=y +CONFIG_IRQ_WORK=y +CONFIG_BUILDTIME_TABLE_SORT=y +CONFIG_THREAD_INFO_IN_TASK=y + +# +# General setup +# +CONFIG_INIT_ENV_ARG_LIMIT=32 +# CONFIG_COMPILE_TEST is not set +CONFIG_LOCALVERSION="" +CONFIG_LOCALVERSION_AUTO=y +CONFIG_BUILD_SALT="" +CONFIG_HAVE_KERNEL_GZIP=y +CONFIG_HAVE_KERNEL_BZIP2=y +CONFIG_HAVE_KERNEL_LZMA=y +CONFIG_HAVE_KERNEL_XZ=y +CONFIG_HAVE_KERNEL_LZO=y +CONFIG_HAVE_KERNEL_LZ4=y +CONFIG_HAVE_KERNEL_ZSTD=y +CONFIG_KERNEL_GZIP=y +# CONFIG_KERNEL_BZIP2 is not set +# CONFIG_KERNEL_LZMA is not set +# CONFIG_KERNEL_XZ is not set +# CONFIG_KERNEL_LZO is not set +# CONFIG_KERNEL_LZ4 is not set +# CONFIG_KERNEL_ZSTD is not set +CONFIG_DEFAULT_INIT="" +CONFIG_DEFAULT_HOSTNAME="(none)" +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_SYSVIPC_SYSCTL=y +CONFIG_POSIX_MQUEUE=y +CONFIG_POSIX_MQUEUE_SYSCTL=y +# CONFIG_WATCH_QUEUE is not set +CONFIG_CROSS_MEMORY_ATTACH=y +# CONFIG_USELIB is not set +CONFIG_AUDIT=y +CONFIG_HAVE_ARCH_AUDITSYSCALL=y +CONFIG_AUDITSYSCALL=y + +# +# IRQ subsystem +# +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y +CONFIG_GENERIC_PENDING_IRQ=y +CONFIG_GENERIC_IRQ_MIGRATION=y +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_DOMAIN_HIERARCHY=y +CONFIG_GENERIC_MSI_IRQ=y +CONFIG_GENERIC_MSI_IRQ_DOMAIN=y +CONFIG_GENERIC_IRQ_MATRIX_ALLOCATOR=y +CONFIG_GENERIC_IRQ_RESERVATION_MODE=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_SPARSE_IRQ=y +# CONFIG_GENERIC_IRQ_DEBUGFS is not set +# end of IRQ subsystem + +CONFIG_CLOCKSOURCE_WATCHDOG=y +CONFIG_ARCH_CLOCKSOURCE_INIT=y +CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y +CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST=y +CONFIG_GENERIC_CMOS_UPDATE=y +CONFIG_HAVE_POSIX_CPU_TIMERS_TASK_WORK=y +CONFIG_POSIX_CPU_TIMERS_TASK_WORK=y + +# +# Timers subsystem +# +CONFIG_TICK_ONESHOT=y +CONFIG_NO_HZ_COMMON=y +# CONFIG_HZ_PERIODIC is not set +CONFIG_NO_HZ_IDLE=y +# CONFIG_NO_HZ_FULL is not set +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y +# end of Timers subsystem + +# CONFIG_PREEMPT_NONE is not set +# CONFIG_PREEMPT_VOLUNTARY is not set +CONFIG_PREEMPT=y +CONFIG_PREEMPT_COUNT=y +CONFIG_PREEMPTION=y + +# +# CPU/Task time and stats accounting +# +CONFIG_TICK_CPU_ACCOUNTING=y +# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set +# CONFIG_IRQ_TIME_ACCOUNTING is not set +CONFIG_BSD_PROCESS_ACCT=y +# CONFIG_BSD_PROCESS_ACCT_V3 is not set +CONFIG_TASKSTATS=y +CONFIG_TASK_DELAY_ACCT=y +CONFIG_TASK_XACCT=y +CONFIG_TASK_IO_ACCOUNTING=y +# CONFIG_PSI is not set +# end of CPU/Task time and stats accounting + +# CONFIG_CPU_ISOLATION is not set + +# +# RCU Subsystem +# +CONFIG_TREE_RCU=y +CONFIG_PREEMPT_RCU=y +# CONFIG_RCU_EXPERT is not set +CONFIG_SRCU=y +CONFIG_TREE_SRCU=y +CONFIG_TASKS_RCU_GENERIC=y +CONFIG_TASKS_RCU=y +CONFIG_TASKS_RUDE_RCU=y +CONFIG_RCU_STALL_COMMON=y +CONFIG_RCU_NEED_SEGCBLIST=y +# end of RCU Subsystem + +CONFIG_IKCONFIG=y +CONFIG_IKCONFIG_PROC=y +# CONFIG_IKHEADERS is not set +CONFIG_LOG_BUF_SHIFT=21 +CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 +CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=13 +CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y + +# +# Scheduler features +# +# CONFIG_UCLAMP_TASK is not set +# end of Scheduler features + +CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y +CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y +CONFIG_CC_HAS_INT128=y +CONFIG_ARCH_SUPPORTS_INT128=y +CONFIG_NUMA_BALANCING=y +# CONFIG_NUMA_BALANCING_DEFAULT_ENABLED is not set +CONFIG_CGROUPS=y +CONFIG_PAGE_COUNTER=y +CONFIG_MEMCG=y +CONFIG_MEMCG_SWAP=y +CONFIG_MEMCG_KMEM=y +CONFIG_BLK_CGROUP=y +CONFIG_CGROUP_WRITEBACK=y +CONFIG_CGROUP_SCHED=y +CONFIG_FAIR_GROUP_SCHED=y +CONFIG_CFS_BANDWIDTH=y +# CONFIG_RT_GROUP_SCHED is not set +# CONFIG_CGROUP_PIDS is not set +# CONFIG_CGROUP_RDMA is not set +CONFIG_CGROUP_FREEZER=y +CONFIG_CGROUP_HUGETLB=y +CONFIG_CPUSETS=y +CONFIG_PROC_PID_CPUSET=y +CONFIG_CGROUP_DEVICE=y +CONFIG_CGROUP_CPUACCT=y +CONFIG_CGROUP_PERF=y +CONFIG_CGROUP_BPF=y +# CONFIG_CGROUP_DEBUG is not set +CONFIG_SOCK_CGROUP_DATA=y +CONFIG_NAMESPACES=y +CONFIG_UTS_NS=y +CONFIG_TIME_NS=y +CONFIG_IPC_NS=y +CONFIG_USER_NS=y +CONFIG_PID_NS=y +CONFIG_NET_NS=y +# CONFIG_CHECKPOINT_RESTORE is not set +# CONFIG_SCHED_AUTOGROUP is not set +# CONFIG_SYSFS_DEPRECATED is not set +CONFIG_RELAY=y +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_RD_GZIP=y +CONFIG_RD_BZIP2=y +CONFIG_RD_LZMA=y +CONFIG_RD_XZ=y +CONFIG_RD_LZO=y +CONFIG_RD_LZ4=y +CONFIG_RD_ZSTD=y +CONFIG_BOOT_CONFIG=y +CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set +CONFIG_SYSCTL=y +CONFIG_SYSCTL_EXCEPTION_TRACE=y +CONFIG_HAVE_PCSPKR_PLATFORM=y +CONFIG_BPF=y +CONFIG_EXPERT=y +CONFIG_MULTIUSER=y +CONFIG_SGETMASK_SYSCALL=y +# CONFIG_SYSFS_SYSCALL is not set +CONFIG_FHANDLE=y +CONFIG_POSIX_TIMERS=y +CONFIG_PRINTK=y +CONFIG_PRINTK_NMI=y +CONFIG_BUG=y +CONFIG_ELF_CORE=y +CONFIG_PCSPKR_PLATFORM=y +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_FUTEX_PI=y +CONFIG_EPOLL=y +CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y +CONFIG_EVENTFD=y +CONFIG_SHMEM=y +CONFIG_AIO=y +CONFIG_IO_URING=y +CONFIG_ADVISE_SYSCALLS=y +CONFIG_MEMBARRIER=y +CONFIG_KALLSYMS=y +CONFIG_KALLSYMS_ALL=y +CONFIG_KALLSYMS_ABSOLUTE_PERCPU=y +CONFIG_KALLSYMS_BASE_RELATIVE=y +CONFIG_BPF_LSM=y +CONFIG_BPF_SYSCALL=y +CONFIG_ARCH_WANT_DEFAULT_BPF_JIT=y +CONFIG_BPF_JIT_ALWAYS_ON=y +CONFIG_BPF_JIT_DEFAULT_ON=y +CONFIG_USERMODE_DRIVER=y +CONFIG_BPF_PRELOAD=y +CONFIG_BPF_PRELOAD_UMD=y +# CONFIG_USERFAULTFD is not set +CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE=y +CONFIG_RSEQ=y +# CONFIG_DEBUG_RSEQ is not set +# CONFIG_EMBEDDED is not set +CONFIG_HAVE_PERF_EVENTS=y +# CONFIG_PC104 is not set + +# +# Kernel Performance Events And Counters +# +CONFIG_PERF_EVENTS=y +# CONFIG_DEBUG_PERF_USE_VMALLOC is not set +# end of Kernel Performance Events And Counters + +CONFIG_VM_EVENT_COUNTERS=y +CONFIG_SLUB_DEBUG=y +# CONFIG_SLUB_MEMCG_SYSFS_ON is not set +CONFIG_COMPAT_BRK=y +# CONFIG_SLAB is not set +CONFIG_SLUB=y +# CONFIG_SLOB is not set +CONFIG_SLAB_MERGE_DEFAULT=y +# CONFIG_SLAB_FREELIST_RANDOM is not set +# CONFIG_SLAB_FREELIST_HARDENED is not set +# CONFIG_SHUFFLE_PAGE_ALLOCATOR is not set +CONFIG_SLUB_CPU_PARTIAL=y +CONFIG_PROFILING=y +CONFIG_TRACEPOINTS=y +# end of General setup + +CONFIG_64BIT=y +CONFIG_X86_64=y +CONFIG_X86=y +CONFIG_INSTRUCTION_DECODER=y +CONFIG_OUTPUT_FORMAT="elf64-x86-64" +CONFIG_LOCKDEP_SUPPORT=y +CONFIG_STACKTRACE_SUPPORT=y +CONFIG_MMU=y +CONFIG_ARCH_MMAP_RND_BITS_MIN=28 +CONFIG_ARCH_MMAP_RND_BITS_MAX=32 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16 +CONFIG_GENERIC_ISA_DMA=y +CONFIG_GENERIC_BUG=y +CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y +CONFIG_ARCH_MAY_HAVE_PC_FDC=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_ARCH_HAS_CPU_RELAX=y +CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y +CONFIG_ARCH_HAS_FILTER_PGPROT=y +CONFIG_HAVE_SETUP_PER_CPU_AREA=y +CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y +CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_ARCH_WANT_GENERAL_HUGETLB=y +CONFIG_ZONE_DMA32=y +CONFIG_AUDIT_ARCH=y +CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y +CONFIG_X86_64_SMP=y +CONFIG_ARCH_SUPPORTS_UPROBES=y +CONFIG_FIX_EARLYCON_MEM=y +CONFIG_PGTABLE_LEVELS=4 +CONFIG_CC_HAS_SANE_STACKPROTECTOR=y + +# +# Processor type and features +# +CONFIG_ZONE_DMA=y +CONFIG_SMP=y +CONFIG_X86_FEATURE_NAMES=y +CONFIG_X86_MPPARSE=y +# CONFIG_GOLDFISH is not set +# CONFIG_RETPOLINE is not set +# CONFIG_X86_CPU_RESCTRL is not set +CONFIG_X86_EXTENDED_PLATFORM=y +# CONFIG_X86_VSMP is not set +# CONFIG_X86_GOLDFISH is not set +# CONFIG_X86_INTEL_LPSS is not set +# CONFIG_X86_AMD_PLATFORM_DEVICE is not set +# CONFIG_IOSF_MBI is not set +CONFIG_X86_SUPPORTS_MEMORY_FAILURE=y +CONFIG_SCHED_OMIT_FRAME_POINTER=y +# CONFIG_HYPERVISOR_GUEST is not set +# CONFIG_MK8 is not set +# CONFIG_MPSC is not set +CONFIG_MCORE2=y +# CONFIG_MATOM is not set +# CONFIG_GENERIC_CPU is not set +CONFIG_X86_INTERNODE_CACHE_SHIFT=6 +CONFIG_X86_L1_CACHE_SHIFT=6 +CONFIG_X86_INTEL_USERCOPY=y +CONFIG_X86_USE_PPRO_CHECKSUM=y +CONFIG_X86_P6_NOP=y +CONFIG_X86_TSC=y +CONFIG_X86_CMPXCHG64=y +CONFIG_X86_CMOV=y +CONFIG_X86_MINIMUM_CPU_FAMILY=64 +CONFIG_X86_DEBUGCTLMSR=y +CONFIG_IA32_FEAT_CTL=y +CONFIG_X86_VMX_FEATURE_NAMES=y +# CONFIG_PROCESSOR_SELECT is not set +CONFIG_CPU_SUP_INTEL=y +CONFIG_CPU_SUP_AMD=y +CONFIG_CPU_SUP_HYGON=y +CONFIG_CPU_SUP_CENTAUR=y +CONFIG_CPU_SUP_ZHAOXIN=y +CONFIG_HPET_TIMER=y +CONFIG_DMI=y +CONFIG_GART_IOMMU=y +# CONFIG_MAXSMP is not set +CONFIG_NR_CPUS_RANGE_BEGIN=2 +CONFIG_NR_CPUS_RANGE_END=512 +CONFIG_NR_CPUS_DEFAULT=64 +CONFIG_NR_CPUS=128 +CONFIG_SCHED_SMT=y +CONFIG_SCHED_MC=y +CONFIG_SCHED_MC_PRIO=y +CONFIG_X86_LOCAL_APIC=y +CONFIG_X86_IO_APIC=y +# CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS is not set +CONFIG_X86_MCE=y +# CONFIG_X86_MCELOG_LEGACY is not set +CONFIG_X86_MCE_INTEL=y +CONFIG_X86_MCE_AMD=y +CONFIG_X86_MCE_THRESHOLD=y +# CONFIG_X86_MCE_INJECT is not set +CONFIG_X86_THERMAL_VECTOR=y + +# +# Performance monitoring +# +CONFIG_PERF_EVENTS_INTEL_UNCORE=y +# CONFIG_PERF_EVENTS_INTEL_RAPL is not set +# CONFIG_PERF_EVENTS_INTEL_CSTATE is not set +# CONFIG_PERF_EVENTS_AMD_POWER is not set +# end of Performance monitoring + +# CONFIG_X86_16BIT is not set +CONFIG_X86_VSYSCALL_EMULATION=y +CONFIG_X86_IOPL_IOPERM=y +# CONFIG_I8K is not set +# CONFIG_MICROCODE is not set +CONFIG_X86_MSR=y +CONFIG_X86_CPUID=y +# CONFIG_X86_5LEVEL is not set +CONFIG_X86_DIRECT_GBPAGES=y +# CONFIG_X86_CPA_STATISTICS is not set +# CONFIG_AMD_MEM_ENCRYPT is not set +CONFIG_NUMA=y +CONFIG_AMD_NUMA=y +CONFIG_X86_64_ACPI_NUMA=y +# CONFIG_NUMA_EMU is not set +CONFIG_NODES_SHIFT=6 +CONFIG_ARCH_SPARSEMEM_ENABLE=y +CONFIG_ARCH_SPARSEMEM_DEFAULT=y +CONFIG_ARCH_SELECT_MEMORY_MODEL=y +CONFIG_ARCH_PROC_KCORE_TEXT=y +CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000 +# CONFIG_X86_PMEM_LEGACY is not set +# CONFIG_X86_CHECK_BIOS_CORRUPTION is not set +CONFIG_X86_RESERVE_LOW=64 +CONFIG_MTRR=y +# CONFIG_MTRR_SANITIZER is not set +CONFIG_X86_PAT=y +CONFIG_ARCH_USES_PG_UNCACHED=y +CONFIG_ARCH_RANDOM=y +CONFIG_X86_SMAP=y +CONFIG_X86_UMIP=y +# CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS is not set +CONFIG_X86_INTEL_TSX_MODE_OFF=y +# CONFIG_X86_INTEL_TSX_MODE_ON is not set +# CONFIG_X86_INTEL_TSX_MODE_AUTO is not set +CONFIG_EFI=y +CONFIG_EFI_STUB=y +# CONFIG_EFI_MIXED is not set +CONFIG_SECCOMP=y +# CONFIG_HZ_100 is not set +# CONFIG_HZ_250 is not set +# CONFIG_HZ_300 is not set +CONFIG_HZ_1000=y +CONFIG_HZ=1000 +CONFIG_SCHED_HRTICK=y +CONFIG_KEXEC=y +# CONFIG_KEXEC_FILE is not set +# CONFIG_CRASH_DUMP is not set +CONFIG_PHYSICAL_START=0x1000000 +CONFIG_RELOCATABLE=y +# CONFIG_RANDOMIZE_BASE is not set +CONFIG_PHYSICAL_ALIGN=0x1000000 +CONFIG_HOTPLUG_CPU=y +# CONFIG_BOOTPARAM_HOTPLUG_CPU0 is not set +# CONFIG_DEBUG_HOTPLUG_CPU0 is not set +# CONFIG_LEGACY_VSYSCALL_EMULATE is not set +# CONFIG_LEGACY_VSYSCALL_XONLY is not set +CONFIG_LEGACY_VSYSCALL_NONE=y +# CONFIG_CMDLINE_BOOL is not set +CONFIG_MODIFY_LDT_SYSCALL=y +CONFIG_HAVE_LIVEPATCH=y +# CONFIG_LIVEPATCH is not set +# end of Processor type and features + +CONFIG_ARCH_HAS_ADD_PAGES=y +CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y +CONFIG_USE_PERCPU_NUMA_NODE_ID=y +CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK=y +CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION=y +CONFIG_ARCH_ENABLE_THP_MIGRATION=y + +# +# Power management and ACPI options +# +# CONFIG_SUSPEND is not set +# CONFIG_HIBERNATION is not set +# CONFIG_PM is not set +# CONFIG_ENERGY_MODEL is not set +CONFIG_ARCH_SUPPORTS_ACPI=y +CONFIG_ACPI=y +CONFIG_ACPI_LEGACY_TABLES_LOOKUP=y +CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC=y +CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT=y +# CONFIG_ACPI_DEBUGGER is not set +# CONFIG_ACPI_SPCR_TABLE is not set +CONFIG_ACPI_LPIT=y +# CONFIG_ACPI_REV_OVERRIDE_POSSIBLE is not set +# CONFIG_ACPI_EC_DEBUGFS is not set +# CONFIG_ACPI_AC is not set +# CONFIG_ACPI_BATTERY is not set +# CONFIG_ACPI_BUTTON is not set +# CONFIG_ACPI_TINY_POWER_BUTTON is not set +# CONFIG_ACPI_VIDEO is not set +# CONFIG_ACPI_FAN is not set +# CONFIG_ACPI_DOCK is not set +CONFIG_ACPI_CPU_FREQ_PSS=y +CONFIG_ACPI_PROCESSOR_CSTATE=y +CONFIG_ACPI_PROCESSOR_IDLE=y +CONFIG_ACPI_CPPC_LIB=y +CONFIG_ACPI_PROCESSOR=y +CONFIG_ACPI_HOTPLUG_CPU=y +# CONFIG_ACPI_PROCESSOR_AGGREGATOR is not set +# CONFIG_ACPI_THERMAL is not set +CONFIG_ARCH_HAS_ACPI_TABLE_UPGRADE=y +# CONFIG_ACPI_TABLE_UPGRADE is not set +# CONFIG_ACPI_DEBUG is not set +# CONFIG_ACPI_PCI_SLOT is not set +CONFIG_ACPI_CONTAINER=y +CONFIG_ACPI_HOTPLUG_IOAPIC=y +# CONFIG_ACPI_SBS is not set +# CONFIG_ACPI_HED is not set +# CONFIG_ACPI_CUSTOM_METHOD is not set +# CONFIG_ACPI_BGRT is not set +# CONFIG_ACPI_REDUCED_HARDWARE_ONLY is not set +# CONFIG_ACPI_NFIT is not set +CONFIG_ACPI_NUMA=y +# CONFIG_ACPI_HMAT is not set +CONFIG_HAVE_ACPI_APEI=y +CONFIG_HAVE_ACPI_APEI_NMI=y +# CONFIG_ACPI_APEI is not set +# CONFIG_DPTF_POWER is not set +# CONFIG_PMIC_OPREGION is not set +# CONFIG_ACPI_CONFIGFS is not set +# CONFIG_X86_PM_TIMER is not set +# CONFIG_SFI is not set + +# +# CPU Frequency scaling +# +CONFIG_CPU_FREQ=y +CONFIG_CPU_FREQ_GOV_ATTR_SET=y +CONFIG_CPU_FREQ_GOV_COMMON=y +CONFIG_CPU_FREQ_STAT=y +CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y +# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y +# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set +CONFIG_CPU_FREQ_GOV_USERSPACE=y +CONFIG_CPU_FREQ_GOV_ONDEMAND=y +CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y +CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y + +# +# CPU frequency scaling drivers +# +CONFIG_X86_INTEL_PSTATE=y +# CONFIG_X86_PCC_CPUFREQ is not set +CONFIG_X86_ACPI_CPUFREQ=y +CONFIG_X86_ACPI_CPUFREQ_CPB=y +CONFIG_X86_POWERNOW_K8=y +# CONFIG_X86_AMD_FREQ_SENSITIVITY is not set +# CONFIG_X86_SPEEDSTEP_CENTRINO is not set +# CONFIG_X86_P4_CLOCKMOD is not set + +# +# shared options +# +# end of CPU Frequency scaling + +# +# CPU Idle +# +CONFIG_CPU_IDLE=y +CONFIG_CPU_IDLE_GOV_LADDER=y +CONFIG_CPU_IDLE_GOV_MENU=y +# CONFIG_CPU_IDLE_GOV_TEO is not set +# end of CPU Idle + +# CONFIG_INTEL_IDLE is not set +# end of Power management and ACPI options + +# +# Bus options (PCI etc.) +# +CONFIG_PCI_DIRECT=y +CONFIG_PCI_MMCONFIG=y +CONFIG_MMCONF_FAM10H=y +# CONFIG_PCI_CNB20LE_QUIRK is not set +# CONFIG_ISA_BUS is not set +CONFIG_ISA_DMA_API=y +CONFIG_AMD_NB=y +# CONFIG_X86_SYSFB is not set +# end of Bus options (PCI etc.) + +# +# Binary Emulations +# +# CONFIG_IA32_EMULATION is not set +# CONFIG_X86_X32 is not set +# end of Binary Emulations + +# +# Firmware Drivers +# +# CONFIG_EDD is not set +CONFIG_FIRMWARE_MEMMAP=y +CONFIG_DMIID=y +# CONFIG_DMI_SYSFS is not set +CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK=y +# CONFIG_FW_CFG_SYSFS is not set +# CONFIG_GOOGLE_FIRMWARE is not set + +# +# EFI (Extensible Firmware Interface) Support +# +# CONFIG_EFI_VARS is not set +CONFIG_EFI_ESRT=y +CONFIG_EFI_RUNTIME_MAP=y +# CONFIG_EFI_FAKE_MEMMAP is not set +CONFIG_EFI_RUNTIME_WRAPPERS=y +CONFIG_EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER=y +# CONFIG_EFI_CAPSULE_LOADER is not set +# CONFIG_EFI_TEST is not set +# CONFIG_APPLE_PROPERTIES is not set +# CONFIG_RESET_ATTACK_MITIGATION is not set +# CONFIG_EFI_RCI2_TABLE is not set +# CONFIG_EFI_DISABLE_PCI_DMA is not set +# end of EFI (Extensible Firmware Interface) Support + +CONFIG_EFI_EARLYCON=y + +# +# Tegra firmware driver +# +# end of Tegra firmware driver +# end of Firmware Drivers + +CONFIG_HAVE_KVM=y +CONFIG_VIRTUALIZATION=y +# CONFIG_KVM is not set +CONFIG_KVM_WERROR=y +CONFIG_AS_AVX512=y +CONFIG_AS_SHA1_NI=y +CONFIG_AS_SHA256_NI=y + +# +# General architecture-dependent options +# +CONFIG_CRASH_CORE=y +CONFIG_KEXEC_CORE=y +CONFIG_HOTPLUG_SMT=y +CONFIG_GENERIC_ENTRY=y +# CONFIG_OPROFILE is not set +CONFIG_HAVE_OPROFILE=y +CONFIG_OPROFILE_NMI_TIMER=y +CONFIG_KPROBES=y +CONFIG_JUMP_LABEL=y +# CONFIG_STATIC_KEYS_SELFTEST is not set +CONFIG_OPTPROBES=y +CONFIG_KPROBES_ON_FTRACE=y +CONFIG_UPROBES=y +CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y +CONFIG_ARCH_USE_BUILTIN_BSWAP=y +CONFIG_KRETPROBES=y +CONFIG_HAVE_IOREMAP_PROT=y +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_OPTPROBES=y +CONFIG_HAVE_KPROBES_ON_FTRACE=y +CONFIG_HAVE_FUNCTION_ERROR_INJECTION=y +CONFIG_HAVE_NMI=y +CONFIG_HAVE_ARCH_TRACEHOOK=y +CONFIG_HAVE_DMA_CONTIGUOUS=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_ARCH_HAS_FORTIFY_SOURCE=y +CONFIG_ARCH_HAS_SET_MEMORY=y +CONFIG_ARCH_HAS_SET_DIRECT_MAP=y +CONFIG_HAVE_ARCH_THREAD_STRUCT_WHITELIST=y +CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT=y +CONFIG_HAVE_ASM_MODVERSIONS=y +CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y +CONFIG_HAVE_RSEQ=y +CONFIG_HAVE_FUNCTION_ARG_ACCESS_API=y +CONFIG_HAVE_HW_BREAKPOINT=y +CONFIG_HAVE_MIXED_BREAKPOINTS_REGS=y +CONFIG_HAVE_USER_RETURN_NOTIFIER=y +CONFIG_HAVE_PERF_EVENTS_NMI=y +CONFIG_HAVE_HARDLOCKUP_DETECTOR_PERF=y +CONFIG_HAVE_PERF_REGS=y +CONFIG_HAVE_PERF_USER_STACK_DUMP=y +CONFIG_HAVE_ARCH_JUMP_LABEL=y +CONFIG_HAVE_ARCH_JUMP_LABEL_RELATIVE=y +CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG=y +CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y +CONFIG_HAVE_CMPXCHG_LOCAL=y +CONFIG_HAVE_CMPXCHG_DOUBLE=y +CONFIG_HAVE_ARCH_SECCOMP_FILTER=y +CONFIG_SECCOMP_FILTER=y +CONFIG_HAVE_ARCH_STACKLEAK=y +CONFIG_HAVE_STACKPROTECTOR=y +# CONFIG_STACKPROTECTOR is not set +CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES=y +CONFIG_HAVE_CONTEXT_TRACKING=y +CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y +CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y +CONFIG_HAVE_MOVE_PMD=y +CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y +CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD=y +CONFIG_HAVE_ARCH_HUGE_VMAP=y +CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y +CONFIG_HAVE_ARCH_SOFT_DIRTY=y +CONFIG_HAVE_MOD_ARCH_SPECIFIC=y +CONFIG_MODULES_USE_ELF_RELA=y +CONFIG_ARCH_HAS_ELF_RANDOMIZE=y +CONFIG_HAVE_ARCH_MMAP_RND_BITS=y +CONFIG_HAVE_EXIT_THREAD=y +CONFIG_ARCH_MMAP_RND_BITS=28 +CONFIG_HAVE_STACK_VALIDATION=y +CONFIG_HAVE_RELIABLE_STACKTRACE=y +CONFIG_COMPAT_32BIT_TIME=y +CONFIG_HAVE_ARCH_VMAP_STACK=y +CONFIG_VMAP_STACK=y +CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y +CONFIG_STRICT_KERNEL_RWX=y +CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y +CONFIG_STRICT_MODULE_RWX=y +CONFIG_HAVE_ARCH_PREL32_RELOCATIONS=y +CONFIG_ARCH_USE_MEMREMAP_PROT=y +# CONFIG_LOCK_EVENT_COUNTS is not set +CONFIG_ARCH_HAS_MEM_ENCRYPT=y + +# +# GCOV-based kernel profiling +# +# CONFIG_GCOV_KERNEL is not set +CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y +# end of GCOV-based kernel profiling + +CONFIG_HAVE_GCC_PLUGINS=y +# end of General architecture-dependent options + +CONFIG_RT_MUTEXES=y +CONFIG_BASE_SMALL=0 +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +CONFIG_MODVERSIONS=y +CONFIG_ASM_MODVERSIONS=y +CONFIG_MODULE_SRCVERSION_ALL=y +# CONFIG_MODULE_SIG is not set +# CONFIG_MODULE_COMPRESS is not set +# CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS is not set +# CONFIG_UNUSED_SYMBOLS is not set +# CONFIG_TRIM_UNUSED_KSYMS is not set +CONFIG_MODULES_TREE_LOOKUP=y +CONFIG_BLOCK=y +CONFIG_BLK_SCSI_REQUEST=y +CONFIG_BLK_CGROUP_RWSTAT=y +CONFIG_BLK_DEV_BSG=y +CONFIG_BLK_DEV_BSGLIB=y +# CONFIG_BLK_DEV_INTEGRITY is not set +# CONFIG_BLK_DEV_ZONED is not set +CONFIG_BLK_DEV_THROTTLING=y +# CONFIG_BLK_DEV_THROTTLING_LOW is not set +# CONFIG_BLK_CMDLINE_PARSER is not set +# CONFIG_BLK_WBT is not set +CONFIG_BLK_CGROUP_IOLATENCY=y +# CONFIG_BLK_CGROUP_IOCOST is not set +CONFIG_BLK_DEBUG_FS=y +# CONFIG_BLK_SED_OPAL is not set +# CONFIG_BLK_INLINE_ENCRYPTION is not set + +# +# Partition Types +# +CONFIG_PARTITION_ADVANCED=y +# CONFIG_ACORN_PARTITION is not set +# CONFIG_AIX_PARTITION is not set +CONFIG_OSF_PARTITION=y +CONFIG_AMIGA_PARTITION=y +# CONFIG_ATARI_PARTITION is not set +CONFIG_MAC_PARTITION=y +CONFIG_MSDOS_PARTITION=y +CONFIG_BSD_DISKLABEL=y +CONFIG_MINIX_SUBPARTITION=y +CONFIG_SOLARIS_X86_PARTITION=y +CONFIG_UNIXWARE_DISKLABEL=y +# CONFIG_LDM_PARTITION is not set +CONFIG_SGI_PARTITION=y +# CONFIG_ULTRIX_PARTITION is not set +CONFIG_SUN_PARTITION=y +CONFIG_KARMA_PARTITION=y +CONFIG_EFI_PARTITION=y +# CONFIG_SYSV68_PARTITION is not set +# CONFIG_CMDLINE_PARTITION is not set +# end of Partition Types + +CONFIG_BLK_MQ_PCI=y +CONFIG_BLK_MQ_VIRTIO=y + +# +# IO Schedulers +# +CONFIG_MQ_IOSCHED_DEADLINE=y +CONFIG_MQ_IOSCHED_KYBER=y +# CONFIG_IOSCHED_BFQ is not set +# end of IO Schedulers + +CONFIG_ASN1=y +CONFIG_UNINLINE_SPIN_UNLOCK=y +CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y +CONFIG_MUTEX_SPIN_ON_OWNER=y +CONFIG_RWSEM_SPIN_ON_OWNER=y +CONFIG_LOCK_SPIN_ON_OWNER=y +CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y +CONFIG_QUEUED_SPINLOCKS=y +CONFIG_ARCH_USE_QUEUED_RWLOCKS=y +CONFIG_QUEUED_RWLOCKS=y +CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE=y +CONFIG_ARCH_HAS_SYNC_CORE_BEFORE_USERMODE=y +CONFIG_ARCH_HAS_SYSCALL_WRAPPER=y +CONFIG_FREEZER=y + +# +# Executable file formats +# +CONFIG_BINFMT_ELF=y +CONFIG_ELFCORE=y +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set +CONFIG_BINFMT_SCRIPT=y +CONFIG_BINFMT_MISC=y +CONFIG_COREDUMP=y +# end of Executable file formats + +# +# Memory Management options +# +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_SPARSEMEM_MANUAL=y +CONFIG_SPARSEMEM=y +CONFIG_NEED_MULTIPLE_NODES=y +CONFIG_SPARSEMEM_EXTREME=y +CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y +CONFIG_SPARSEMEM_VMEMMAP=y +CONFIG_HAVE_FAST_GUP=y +CONFIG_MEMORY_ISOLATION=y +# CONFIG_MEMORY_HOTPLUG is not set +CONFIG_SPLIT_PTLOCK_CPUS=4 +CONFIG_MEMORY_BALLOON=y +CONFIG_BALLOON_COMPACTION=y +CONFIG_COMPACTION=y +CONFIG_PAGE_REPORTING=y +CONFIG_MIGRATION=y +CONFIG_CONTIG_ALLOC=y +CONFIG_PHYS_ADDR_T_64BIT=y +CONFIG_BOUNCE=y +CONFIG_VIRT_TO_BUS=y +CONFIG_KSM=y +CONFIG_DEFAULT_MMAP_MIN_ADDR=4096 +CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y +CONFIG_MEMORY_FAILURE=y +CONFIG_HWPOISON_INJECT=y +CONFIG_TRANSPARENT_HUGEPAGE=y +# CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS is not set +CONFIG_TRANSPARENT_HUGEPAGE_MADVISE=y +CONFIG_ARCH_WANTS_THP_SWAP=y +CONFIG_THP_SWAP=y +# CONFIG_CLEANCACHE is not set +# CONFIG_FRONTSWAP is not set +CONFIG_CMA=y +# CONFIG_CMA_DEBUG is not set +# CONFIG_CMA_DEBUGFS is not set +CONFIG_CMA_AREAS=7 +# CONFIG_ZPOOL is not set +# CONFIG_ZBUD is not set +# CONFIG_ZSMALLOC is not set +CONFIG_GENERIC_EARLY_IOREMAP=y +# CONFIG_DEFERRED_STRUCT_PAGE_INIT is not set +# CONFIG_IDLE_PAGE_TRACKING is not set +CONFIG_ARCH_HAS_PTE_DEVMAP=y +# CONFIG_PERCPU_STATS is not set +# CONFIG_GUP_BENCHMARK is not set +# CONFIG_READ_ONLY_THP_FOR_FS is not set +CONFIG_ARCH_HAS_PTE_SPECIAL=y +# end of Memory Management options + +CONFIG_NET=y +CONFIG_NET_INGRESS=y +CONFIG_NET_EGRESS=y +CONFIG_SKB_EXTENSIONS=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_DIAG is not set +CONFIG_UNIX=y +CONFIG_UNIX_SCM=y +# CONFIG_UNIX_DIAG is not set +CONFIG_TLS=y +# CONFIG_TLS_DEVICE is not set +# CONFIG_TLS_TOE is not set +CONFIG_XFRM=y +CONFIG_XFRM_ALGO=y +CONFIG_XFRM_USER=y +# CONFIG_XFRM_INTERFACE is not set +CONFIG_XFRM_SUB_POLICY=y +# CONFIG_XFRM_MIGRATE is not set +# CONFIG_XFRM_STATISTICS is not set +# CONFIG_NET_KEY is not set +CONFIG_XDP_SOCKETS=y +CONFIG_XDP_SOCKETS_DIAG=y +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +# CONFIG_IP_FIB_TRIE_STATS is not set +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_ROUTE_MULTIPATH=y +CONFIG_IP_ROUTE_VERBOSE=y +# CONFIG_IP_PNP is not set +CONFIG_NET_IPIP=y +CONFIG_NET_IPGRE_DEMUX=y +CONFIG_NET_IP_TUNNEL=y +CONFIG_NET_IPGRE=y +CONFIG_NET_IPGRE_BROADCAST=y +CONFIG_IP_MROUTE_COMMON=y +CONFIG_IP_MROUTE=y +# CONFIG_IP_MROUTE_MULTIPLE_TABLES is not set +CONFIG_IP_PIMSM_V1=y +CONFIG_IP_PIMSM_V2=y +CONFIG_SYN_COOKIES=y +# CONFIG_NET_IPVTI is not set +CONFIG_NET_UDP_TUNNEL=y +# CONFIG_NET_FOU is not set +# CONFIG_NET_FOU_IP_TUNNELS is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +CONFIG_INET_TUNNEL=y +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +# CONFIG_INET_UDP_DIAG is not set +# CONFIG_INET_RAW_DIAG is not set +# CONFIG_INET_DIAG_DESTROY is not set +CONFIG_TCP_CONG_ADVANCED=y +CONFIG_TCP_CONG_BIC=m +CONFIG_TCP_CONG_CUBIC=y +CONFIG_TCP_CONG_WESTWOOD=m +CONFIG_TCP_CONG_HTCP=m +# CONFIG_TCP_CONG_HSTCP is not set +# CONFIG_TCP_CONG_HYBLA is not set +# CONFIG_TCP_CONG_VEGAS is not set +# CONFIG_TCP_CONG_NV is not set +# CONFIG_TCP_CONG_SCALABLE is not set +# CONFIG_TCP_CONG_LP is not set +# CONFIG_TCP_CONG_VENO is not set +# CONFIG_TCP_CONG_YEAH is not set +# CONFIG_TCP_CONG_ILLINOIS is not set +# CONFIG_TCP_CONG_DCTCP is not set +# CONFIG_TCP_CONG_CDG is not set +# CONFIG_TCP_CONG_BBR is not set +# CONFIG_DEFAULT_CUBIC is not set +CONFIG_DEFAULT_RENO=y +CONFIG_DEFAULT_TCP_CONG="reno" +CONFIG_TCP_MD5SIG=y +CONFIG_IPV6=y +CONFIG_IPV6_ROUTER_PREF=y +CONFIG_IPV6_ROUTE_INFO=y +# CONFIG_IPV6_OPTIMISTIC_DAD is not set +# CONFIG_INET6_AH is not set +# CONFIG_INET6_ESP is not set +# CONFIG_INET6_IPCOMP is not set +CONFIG_IPV6_MIP6=y +# CONFIG_IPV6_ILA is not set +CONFIG_INET6_TUNNEL=y +# CONFIG_IPV6_VTI is not set +CONFIG_IPV6_SIT=y +# CONFIG_IPV6_SIT_6RD is not set +CONFIG_IPV6_NDISC_NODETYPE=y +CONFIG_IPV6_TUNNEL=y +CONFIG_IPV6_GRE=y +CONFIG_IPV6_MULTIPLE_TABLES=y +CONFIG_IPV6_SUBTREES=y +# CONFIG_IPV6_MROUTE is not set +CONFIG_IPV6_SEG6_LWTUNNEL=y +# CONFIG_IPV6_SEG6_HMAC is not set +CONFIG_IPV6_SEG6_BPF=y +# CONFIG_IPV6_RPL_LWTUNNEL is not set +CONFIG_NETLABEL=y +# CONFIG_MPTCP is not set +CONFIG_NETWORK_SECMARK=y +CONFIG_NET_PTP_CLASSIFY=y +# CONFIG_NETWORK_PHY_TIMESTAMPING is not set +CONFIG_NETFILTER=y +CONFIG_NETFILTER_ADVANCED=y + +# +# Core Netfilter Configuration +# +CONFIG_NETFILTER_INGRESS=y +CONFIG_NETFILTER_NETLINK=y +# CONFIG_NETFILTER_NETLINK_ACCT is not set +CONFIG_NETFILTER_NETLINK_QUEUE=y +CONFIG_NETFILTER_NETLINK_LOG=y +# CONFIG_NETFILTER_NETLINK_OSF is not set +# CONFIG_NF_CONNTRACK is not set +# CONFIG_NF_LOG_NETDEV is not set +# CONFIG_NF_TABLES is not set +CONFIG_NETFILTER_XTABLES=y + +# +# Xtables combined modules +# +# CONFIG_NETFILTER_XT_MARK is not set + +# +# Xtables targets +# +# CONFIG_NETFILTER_XT_TARGET_AUDIT is not set +# CONFIG_NETFILTER_XT_TARGET_CLASSIFY is not set +# CONFIG_NETFILTER_XT_TARGET_HMARK is not set +# CONFIG_NETFILTER_XT_TARGET_IDLETIMER is not set +# CONFIG_NETFILTER_XT_TARGET_LOG is not set +# CONFIG_NETFILTER_XT_TARGET_MARK is not set +# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set +# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set +# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set +# CONFIG_NETFILTER_XT_TARGET_TEE is not set +# CONFIG_NETFILTER_XT_TARGET_SECMARK is not set +# CONFIG_NETFILTER_XT_TARGET_TCPMSS is not set + +# +# Xtables matches +# +# CONFIG_NETFILTER_XT_MATCH_ADDRTYPE is not set +CONFIG_NETFILTER_XT_MATCH_BPF=y +# CONFIG_NETFILTER_XT_MATCH_CGROUP is not set +# CONFIG_NETFILTER_XT_MATCH_COMMENT is not set +# CONFIG_NETFILTER_XT_MATCH_CPU is not set +# CONFIG_NETFILTER_XT_MATCH_DCCP is not set +# CONFIG_NETFILTER_XT_MATCH_DEVGROUP is not set +# CONFIG_NETFILTER_XT_MATCH_DSCP is not set +# CONFIG_NETFILTER_XT_MATCH_ECN is not set +# CONFIG_NETFILTER_XT_MATCH_ESP is not set +# CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is not set +# CONFIG_NETFILTER_XT_MATCH_HL is not set +# CONFIG_NETFILTER_XT_MATCH_IPCOMP is not set +# CONFIG_NETFILTER_XT_MATCH_IPRANGE is not set +# CONFIG_NETFILTER_XT_MATCH_L2TP is not set +# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set +# CONFIG_NETFILTER_XT_MATCH_LIMIT is not set +# CONFIG_NETFILTER_XT_MATCH_MAC is not set +# CONFIG_NETFILTER_XT_MATCH_MARK is not set +# CONFIG_NETFILTER_XT_MATCH_MULTIPORT is not set +# CONFIG_NETFILTER_XT_MATCH_NFACCT is not set +# CONFIG_NETFILTER_XT_MATCH_OSF is not set +# CONFIG_NETFILTER_XT_MATCH_OWNER is not set +# CONFIG_NETFILTER_XT_MATCH_POLICY is not set +# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set +# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set +# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set +# CONFIG_NETFILTER_XT_MATCH_REALM is not set +# CONFIG_NETFILTER_XT_MATCH_RECENT is not set +# CONFIG_NETFILTER_XT_MATCH_SCTP is not set +# CONFIG_NETFILTER_XT_MATCH_SOCKET is not set +CONFIG_NETFILTER_XT_MATCH_STATISTIC=y +# CONFIG_NETFILTER_XT_MATCH_STRING is not set +# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set +# CONFIG_NETFILTER_XT_MATCH_TIME is not set +# CONFIG_NETFILTER_XT_MATCH_U32 is not set +# end of Core Netfilter Configuration + +# CONFIG_IP_SET is not set +# CONFIG_IP_VS is not set + +# +# IP: Netfilter Configuration +# +# CONFIG_NF_SOCKET_IPV4 is not set +# CONFIG_NF_TPROXY_IPV4 is not set +# CONFIG_NF_DUP_IPV4 is not set +# CONFIG_NF_LOG_ARP is not set +# CONFIG_NF_LOG_IPV4 is not set +# CONFIG_NF_REJECT_IPV4 is not set +CONFIG_IP_NF_IPTABLES=y +# CONFIG_IP_NF_MATCH_AH is not set +# CONFIG_IP_NF_MATCH_ECN is not set +# CONFIG_IP_NF_MATCH_TTL is not set +# CONFIG_IP_NF_FILTER is not set +# CONFIG_IP_NF_MANGLE is not set +# CONFIG_IP_NF_RAW is not set +# CONFIG_IP_NF_SECURITY is not set +# CONFIG_IP_NF_ARPTABLES is not set +# end of IP: Netfilter Configuration + +# +# IPv6: Netfilter Configuration +# +# CONFIG_NF_SOCKET_IPV6 is not set +# CONFIG_NF_TPROXY_IPV6 is not set +# CONFIG_NF_DUP_IPV6 is not set +# CONFIG_NF_REJECT_IPV6 is not set +# CONFIG_NF_LOG_IPV6 is not set +CONFIG_IP6_NF_IPTABLES=y +# CONFIG_IP6_NF_MATCH_AH is not set +# CONFIG_IP6_NF_MATCH_EUI64 is not set +# CONFIG_IP6_NF_MATCH_FRAG is not set +# CONFIG_IP6_NF_MATCH_OPTS is not set +# CONFIG_IP6_NF_MATCH_HL is not set +# CONFIG_IP6_NF_MATCH_IPV6HEADER is not set +# CONFIG_IP6_NF_MATCH_MH is not set +# CONFIG_IP6_NF_MATCH_RT is not set +# CONFIG_IP6_NF_MATCH_SRH is not set +# CONFIG_IP6_NF_FILTER is not set +# CONFIG_IP6_NF_MANGLE is not set +# CONFIG_IP6_NF_RAW is not set +# CONFIG_IP6_NF_SECURITY is not set +# end of IPv6: Netfilter Configuration + +CONFIG_BPFILTER=y +CONFIG_BPFILTER_UMH=m +# CONFIG_IP_DCCP is not set +# CONFIG_IP_SCTP is not set +# CONFIG_RDS is not set +# CONFIG_TIPC is not set +# CONFIG_ATM is not set +# CONFIG_L2TP is not set +# CONFIG_BRIDGE is not set +CONFIG_HAVE_NET_DSA=y +# CONFIG_NET_DSA is not set +CONFIG_VLAN_8021Q=y +# CONFIG_VLAN_8021Q_GVRP is not set +# CONFIG_VLAN_8021Q_MVRP is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_PHONET is not set +# CONFIG_6LOWPAN is not set +# CONFIG_IEEE802154 is not set +CONFIG_NET_SCHED=y + +# +# Queueing/Scheduling +# +# CONFIG_NET_SCH_CBQ is not set +# CONFIG_NET_SCH_HTB is not set +# CONFIG_NET_SCH_HFSC is not set +# CONFIG_NET_SCH_PRIO is not set +# CONFIG_NET_SCH_MULTIQ is not set +# CONFIG_NET_SCH_RED is not set +# CONFIG_NET_SCH_SFB is not set +# CONFIG_NET_SCH_SFQ is not set +# CONFIG_NET_SCH_TEQL is not set +# CONFIG_NET_SCH_TBF is not set +# CONFIG_NET_SCH_CBS is not set +# CONFIG_NET_SCH_ETF is not set +# CONFIG_NET_SCH_TAPRIO is not set +# CONFIG_NET_SCH_GRED is not set +# CONFIG_NET_SCH_DSMARK is not set +# CONFIG_NET_SCH_NETEM is not set +# CONFIG_NET_SCH_DRR is not set +# CONFIG_NET_SCH_MQPRIO is not set +# CONFIG_NET_SCH_SKBPRIO is not set +# CONFIG_NET_SCH_CHOKE is not set +# CONFIG_NET_SCH_QFQ is not set +# CONFIG_NET_SCH_CODEL is not set +CONFIG_NET_SCH_FQ_CODEL=y +# CONFIG_NET_SCH_CAKE is not set +# CONFIG_NET_SCH_FQ is not set +# CONFIG_NET_SCH_HHF is not set +# CONFIG_NET_SCH_PIE is not set +CONFIG_NET_SCH_INGRESS=y +# CONFIG_NET_SCH_PLUG is not set +# CONFIG_NET_SCH_ETS is not set +CONFIG_NET_SCH_DEFAULT=y +CONFIG_DEFAULT_FQ_CODEL=y +# CONFIG_DEFAULT_PFIFO_FAST is not set +CONFIG_DEFAULT_NET_SCH="fq_codel" + +# +# Classification +# +CONFIG_NET_CLS=y +# CONFIG_NET_CLS_BASIC is not set +# CONFIG_NET_CLS_TCINDEX is not set +# CONFIG_NET_CLS_ROUTE4 is not set +# CONFIG_NET_CLS_FW is not set +# CONFIG_NET_CLS_U32 is not set +# CONFIG_NET_CLS_RSVP is not set +# CONFIG_NET_CLS_RSVP6 is not set +# CONFIG_NET_CLS_FLOW is not set +CONFIG_NET_CLS_CGROUP=y +CONFIG_NET_CLS_BPF=y +# CONFIG_NET_CLS_FLOWER is not set +# CONFIG_NET_CLS_MATCHALL is not set +CONFIG_NET_EMATCH=y +CONFIG_NET_EMATCH_STACK=32 +# CONFIG_NET_EMATCH_CMP is not set +# CONFIG_NET_EMATCH_NBYTE is not set +# CONFIG_NET_EMATCH_U32 is not set +# CONFIG_NET_EMATCH_META is not set +# CONFIG_NET_EMATCH_TEXT is not set +# CONFIG_NET_EMATCH_IPT is not set +CONFIG_NET_CLS_ACT=y +# CONFIG_NET_ACT_POLICE is not set +# CONFIG_NET_ACT_GACT is not set +# CONFIG_NET_ACT_MIRRED is not set +# CONFIG_NET_ACT_SAMPLE is not set +# CONFIG_NET_ACT_IPT is not set +# CONFIG_NET_ACT_NAT is not set +# CONFIG_NET_ACT_PEDIT is not set +# CONFIG_NET_ACT_SIMP is not set +# CONFIG_NET_ACT_SKBEDIT is not set +# CONFIG_NET_ACT_CSUM is not set +# CONFIG_NET_ACT_MPLS is not set +# CONFIG_NET_ACT_VLAN is not set +CONFIG_NET_ACT_BPF=y +# CONFIG_NET_ACT_SKBMOD is not set +# CONFIG_NET_ACT_IFE is not set +# CONFIG_NET_ACT_TUNNEL_KEY is not set +# CONFIG_NET_ACT_GATE is not set +CONFIG_NET_TC_SKB_EXT=y +CONFIG_NET_SCH_FIFO=y +CONFIG_DCB=y +CONFIG_DNS_RESOLVER=y +# CONFIG_BATMAN_ADV is not set +# CONFIG_OPENVSWITCH is not set +# CONFIG_VSOCKETS is not set +# CONFIG_NETLINK_DIAG is not set +CONFIG_MPLS=y +# CONFIG_NET_MPLS_GSO is not set +# CONFIG_MPLS_ROUTING is not set +# CONFIG_NET_NSH is not set +# CONFIG_HSR is not set +# CONFIG_NET_SWITCHDEV is not set +# CONFIG_NET_L3_MASTER_DEV is not set +# CONFIG_QRTR is not set +# CONFIG_NET_NCSI is not set +CONFIG_RPS=y +CONFIG_RFS_ACCEL=y +CONFIG_XPS=y +# CONFIG_CGROUP_NET_PRIO is not set +CONFIG_CGROUP_NET_CLASSID=y +CONFIG_NET_RX_BUSY_POLL=y +CONFIG_BQL=y +CONFIG_BPF_JIT=y +CONFIG_BPF_STREAM_PARSER=y +CONFIG_NET_FLOW_LIMIT=y + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_NET_DROP_MONITOR is not set +# end of Network testing +# end of Networking options + +# CONFIG_HAMRADIO is not set +# CONFIG_CAN is not set +# CONFIG_BT is not set +# CONFIG_AF_RXRPC is not set +# CONFIG_AF_KCM is not set +CONFIG_STREAM_PARSER=y +CONFIG_FIB_RULES=y +CONFIG_WIRELESS=y +# CONFIG_CFG80211 is not set + +# +# CFG80211 needs to be enabled for MAC80211 +# +CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 +# CONFIG_WIMAX is not set +# CONFIG_RFKILL is not set +CONFIG_NET_9P=y +CONFIG_NET_9P_VIRTIO=y +# CONFIG_NET_9P_DEBUG is not set +# CONFIG_CAIF is not set +# CONFIG_CEPH_LIB is not set +# CONFIG_NFC is not set +# CONFIG_PSAMPLE is not set +# CONFIG_NET_IFE is not set +CONFIG_LWTUNNEL=y +CONFIG_LWTUNNEL_BPF=y +CONFIG_DST_CACHE=y +CONFIG_GRO_CELLS=y +CONFIG_NET_SOCK_MSG=y +CONFIG_NET_DEVLINK=y +CONFIG_FAILOVER=y +CONFIG_ETHTOOL_NETLINK=y +CONFIG_HAVE_EBPF_JIT=y + +# +# Device Drivers +# +CONFIG_HAVE_EISA=y +# CONFIG_EISA is not set +CONFIG_HAVE_PCI=y +CONFIG_PCI=y +CONFIG_PCI_DOMAINS=y +CONFIG_PCIEPORTBUS=y +# CONFIG_PCIEAER is not set +CONFIG_PCIEASPM=y +CONFIG_PCIEASPM_DEFAULT=y +# CONFIG_PCIEASPM_POWERSAVE is not set +# CONFIG_PCIEASPM_POWER_SUPERSAVE is not set +# CONFIG_PCIEASPM_PERFORMANCE is not set +# CONFIG_PCIE_PTM is not set +# CONFIG_PCIE_BW is not set +CONFIG_PCI_MSI=y +CONFIG_PCI_MSI_IRQ_DOMAIN=y +CONFIG_PCI_QUIRKS=y +# CONFIG_PCI_DEBUG is not set +# CONFIG_PCI_REALLOC_ENABLE_AUTO is not set +# CONFIG_PCI_STUB is not set +# CONFIG_PCI_PF_STUB is not set +CONFIG_PCI_ATS=y +CONFIG_PCI_LOCKLESS_CONFIG=y +CONFIG_PCI_IOV=y +# CONFIG_PCI_PRI is not set +# CONFIG_PCI_PASID is not set +CONFIG_PCI_LABEL=y +# CONFIG_HOTPLUG_PCI is not set + +# +# PCI controller drivers +# +# CONFIG_VMD is not set + +# +# DesignWare PCI Core Support +# +# CONFIG_PCIE_DW_PLAT_HOST is not set +# CONFIG_PCI_MESON is not set +# end of DesignWare PCI Core Support + +# +# Mobiveil PCIe Core Support +# +# end of Mobiveil PCIe Core Support + +# +# Cadence PCIe controllers support +# +# end of Cadence PCIe controllers support +# end of PCI controller drivers + +# +# PCI Endpoint +# +# CONFIG_PCI_ENDPOINT is not set +# end of PCI Endpoint + +# +# PCI switch controller drivers +# +# CONFIG_PCI_SW_SWITCHTEC is not set +# end of PCI switch controller drivers + +# CONFIG_PCCARD is not set +# CONFIG_RAPIDIO is not set + +# +# Generic Driver Options +# +# CONFIG_UEVENT_HELPER is not set +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +CONFIG_STANDALONE=y +# CONFIG_PREVENT_FIRMWARE_BUILD is not set + +# +# Firmware loader +# +CONFIG_FW_LOADER=y +CONFIG_FW_LOADER_PAGED_BUF=y +CONFIG_EXTRA_FIRMWARE="" +CONFIG_FW_LOADER_USER_HELPER=y +# CONFIG_FW_LOADER_USER_HELPER_FALLBACK is not set +# CONFIG_FW_LOADER_COMPRESS is not set +# end of Firmware loader + +CONFIG_ALLOW_DEV_COREDUMP=y +# CONFIG_DEBUG_DRIVER is not set +# CONFIG_DEBUG_DEVRES is not set +# CONFIG_DEBUG_TEST_DRIVER_REMOVE is not set +# CONFIG_TEST_ASYNC_DRIVER_PROBE is not set +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_CPU_VULNERABILITIES=y +CONFIG_DMA_SHARED_BUFFER=y +# CONFIG_DMA_FENCE_TRACE is not set +# end of Generic Driver Options + +# +# Bus devices +# +# CONFIG_MHI_BUS is not set +# end of Bus devices + +# CONFIG_CONNECTOR is not set +# CONFIG_GNSS is not set +# CONFIG_MTD is not set +# CONFIG_OF is not set +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y +# CONFIG_PARPORT is not set +CONFIG_PNP=y +# CONFIG_PNP_DEBUG_MESSAGES is not set + +# +# Protocols +# +CONFIG_PNPACPI=y +CONFIG_BLK_DEV=y +# CONFIG_BLK_DEV_NULL_BLK is not set +# CONFIG_BLK_DEV_FD is not set +# CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set +# CONFIG_BLK_DEV_UMEM is not set +CONFIG_BLK_DEV_LOOP=y +# CONFIG_BLK_DEV_DRBD is not set +# CONFIG_BLK_DEV_NBD is not set +# CONFIG_BLK_DEV_SKD is not set +# CONFIG_BLK_DEV_SX8 is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=16384 +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_ATA_OVER_ETH is not set +CONFIG_VIRTIO_BLK=y +# CONFIG_BLK_DEV_RBD is not set +# CONFIG_BLK_DEV_RSXX is not set + +# +# NVME Support +# +# CONFIG_BLK_DEV_NVME is not set +# CONFIG_NVME_FC is not set +# end of NVME Support + +# +# Misc devices +# +# CONFIG_DUMMY_IRQ is not set +# CONFIG_IBM_ASM is not set +# CONFIG_PHANTOM is not set +# CONFIG_TIFM_CORE is not set +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_HP_ILO is not set +# CONFIG_SRAM is not set +# CONFIG_PCI_ENDPOINT_TEST is not set +# CONFIG_XILINX_SDFEC is not set +# CONFIG_PVPANIC is not set +# CONFIG_C2PORT is not set + +# +# EEPROM support +# +# CONFIG_EEPROM_93CX6 is not set +# end of EEPROM support + +# CONFIG_CB710_CORE is not set + +# +# Texas Instruments shared transport line discipline +# +# end of Texas Instruments shared transport line discipline + +# +# Altera FPGA firmware download module (requires I2C) +# +# CONFIG_INTEL_MEI is not set +# CONFIG_INTEL_MEI_ME is not set +# CONFIG_INTEL_MEI_TXE is not set +# CONFIG_VMWARE_VMCI is not set + +# +# Intel MIC & related support +# +# CONFIG_INTEL_MIC_BUS is not set +# CONFIG_SCIF_BUS is not set +# CONFIG_VOP_BUS is not set +# end of Intel MIC & related support + +# CONFIG_GENWQE is not set +# CONFIG_ECHO is not set +# CONFIG_MISC_ALCOR_PCI is not set +# CONFIG_MISC_RTSX_PCI is not set +# CONFIG_HABANA_AI is not set +# end of Misc devices + +CONFIG_HAVE_IDE=y +# CONFIG_IDE is not set + +# +# SCSI device support +# +CONFIG_SCSI_MOD=y +# CONFIG_RAID_ATTRS is not set +# CONFIG_SCSI is not set +# end of SCSI device support + +# CONFIG_ATA is not set +# CONFIG_MD is not set +# CONFIG_TARGET_CORE is not set +# CONFIG_FUSION is not set + +# +# IEEE 1394 (FireWire) support +# +# CONFIG_FIREWIRE is not set +# CONFIG_FIREWIRE_NOSY is not set +# end of IEEE 1394 (FireWire) support + +# CONFIG_MACINTOSH_DRIVERS is not set +CONFIG_NETDEVICES=y +CONFIG_NET_CORE=y +# CONFIG_BONDING is not set +# CONFIG_DUMMY is not set +# CONFIG_WIREGUARD is not set +# CONFIG_EQUALIZER is not set +# CONFIG_IFB is not set +# CONFIG_NET_TEAM is not set +# CONFIG_MACVLAN is not set +# CONFIG_IPVLAN is not set +CONFIG_VXLAN=y +# CONFIG_GENEVE is not set +# CONFIG_BAREUDP is not set +# CONFIG_GTP is not set +# CONFIG_MACSEC is not set +# CONFIG_NETCONSOLE is not set +CONFIG_TUN=y +# CONFIG_TUN_VNET_CROSS_LE is not set +CONFIG_VETH=y +CONFIG_VIRTIO_NET=y +# CONFIG_NLMON is not set +# CONFIG_ARCNET is not set + +# +# Distributed Switch Architecture drivers +# +# end of Distributed Switch Architecture drivers + +# CONFIG_ETHERNET is not set +# CONFIG_FDDI is not set +# CONFIG_HIPPI is not set +# CONFIG_NET_SB1000 is not set +# CONFIG_MDIO_DEVICE is not set +# CONFIG_PHYLIB is not set +# CONFIG_PPP is not set +# CONFIG_SLIP is not set + +# +# Host-side USB support is needed for USB Network Adapter support +# +# CONFIG_WLAN is not set + +# +# Enable WiMAX (Networking options) to see the WiMAX drivers +# +# CONFIG_WAN is not set +# CONFIG_VMXNET3 is not set +# CONFIG_FUJITSU_ES is not set +CONFIG_NETDEVSIM=y +CONFIG_NET_FAILOVER=y +# CONFIG_ISDN is not set +# CONFIG_NVM is not set + +# +# Input device support +# +CONFIG_INPUT=y +CONFIG_INPUT_FF_MEMLESS=y +# CONFIG_INPUT_POLLDEV is not set +# CONFIG_INPUT_SPARSEKMAP is not set +# CONFIG_INPUT_MATRIXKMAP is not set + +# +# Userland interfaces +# +# CONFIG_INPUT_MOUSEDEV is not set +# CONFIG_INPUT_JOYDEV is not set +CONFIG_INPUT_EVDEV=y +# CONFIG_INPUT_EVBUG is not set + +# +# Input Device Drivers +# +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_TABLET is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_MISC is not set +# CONFIG_RMI4_CORE is not set + +# +# Hardware I/O ports +# +CONFIG_SERIO=y +CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y +CONFIG_SERIO_I8042=y +CONFIG_SERIO_SERPORT=y +# CONFIG_SERIO_CT82C710 is not set +# CONFIG_SERIO_PCIPS2 is not set +CONFIG_SERIO_LIBPS2=y +# CONFIG_SERIO_RAW is not set +# CONFIG_SERIO_ALTERA_PS2 is not set +# CONFIG_SERIO_PS2MULT is not set +# CONFIG_SERIO_ARC_PS2 is not set +# CONFIG_USERIO is not set +# CONFIG_GAMEPORT is not set +# end of Hardware I/O ports +# end of Input device support + +# +# Character devices +# +CONFIG_TTY=y +CONFIG_VT=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +CONFIG_VT_HW_CONSOLE_BINDING=y +CONFIG_UNIX98_PTYS=y +# CONFIG_LEGACY_PTYS is not set +CONFIG_LDISC_AUTOLOAD=y + +# +# Serial drivers +# +CONFIG_SERIAL_EARLYCON=y +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_DEPRECATED_OPTIONS=y +CONFIG_SERIAL_8250_PNP=y +# CONFIG_SERIAL_8250_16550A_VARIANTS is not set +# CONFIG_SERIAL_8250_FINTEK is not set +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_PCI=y +CONFIG_SERIAL_8250_EXAR=y +CONFIG_SERIAL_8250_NR_UARTS=32 +CONFIG_SERIAL_8250_RUNTIME_UARTS=4 +CONFIG_SERIAL_8250_EXTENDED=y +CONFIG_SERIAL_8250_MANY_PORTS=y +CONFIG_SERIAL_8250_SHARE_IRQ=y +CONFIG_SERIAL_8250_DETECT_IRQ=y +CONFIG_SERIAL_8250_RSA=y +# CONFIG_SERIAL_8250_DW is not set +# CONFIG_SERIAL_8250_RT288X is not set +# CONFIG_SERIAL_8250_LPSS is not set +# CONFIG_SERIAL_8250_MID is not set + +# +# Non-8250 serial port support +# +# CONFIG_SERIAL_UARTLITE is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +# CONFIG_SERIAL_JSM is not set +# CONFIG_SERIAL_LANTIQ is not set +# CONFIG_SERIAL_SCCNXP is not set +# CONFIG_SERIAL_ALTERA_JTAGUART is not set +# CONFIG_SERIAL_ALTERA_UART is not set +# CONFIG_SERIAL_ARC is not set +# CONFIG_SERIAL_RP2 is not set +# CONFIG_SERIAL_FSL_LPUART is not set +# CONFIG_SERIAL_FSL_LINFLEXUART is not set +# CONFIG_SERIAL_SPRD is not set +# end of Serial drivers + +CONFIG_SERIAL_NONSTANDARD=y +# CONFIG_ROCKETPORT is not set +# CONFIG_CYCLADES is not set +# CONFIG_MOXA_INTELLIO is not set +# CONFIG_MOXA_SMARTIO is not set +# CONFIG_SYNCLINK is not set +# CONFIG_SYNCLINKMP is not set +# CONFIG_SYNCLINK_GT is not set +# CONFIG_ISI is not set +# CONFIG_N_HDLC is not set +# CONFIG_N_GSM is not set +# CONFIG_NOZOMI is not set +# CONFIG_NULL_TTY is not set +# CONFIG_TRACE_SINK is not set +CONFIG_HVC_DRIVER=y +# CONFIG_SERIAL_DEV_BUS is not set +# CONFIG_TTY_PRINTK is not set +CONFIG_VIRTIO_CONSOLE=y +# CONFIG_IPMI_HANDLER is not set +# CONFIG_HW_RANDOM is not set +# CONFIG_APPLICOM is not set +# CONFIG_MWAVE is not set +CONFIG_DEVMEM=y +CONFIG_DEVKMEM=y +# CONFIG_NVRAM is not set +# CONFIG_RAW_DRIVER is not set +CONFIG_DEVPORT=y +CONFIG_HPET=y +# CONFIG_HPET_MMAP is not set +# CONFIG_HANGCHECK_TIMER is not set +CONFIG_TCG_TPM=y +CONFIG_TCG_TIS_CORE=y +CONFIG_TCG_TIS=y +# CONFIG_TCG_NSC is not set +# CONFIG_TCG_ATMEL is not set +# CONFIG_TCG_INFINEON is not set +CONFIG_TCG_CRB=y +# CONFIG_TCG_VTPM_PROXY is not set +# CONFIG_TELCLOCK is not set +# CONFIG_XILLYBUS is not set +# end of Character devices + +# CONFIG_RANDOM_TRUST_CPU is not set +# CONFIG_RANDOM_TRUST_BOOTLOADER is not set + +# +# I2C support +# +# CONFIG_I2C is not set +# end of I2C support + +# CONFIG_I3C is not set +# CONFIG_SPI is not set +# CONFIG_SPMI is not set +# CONFIG_HSI is not set +CONFIG_PPS=y +# CONFIG_PPS_DEBUG is not set + +# +# PPS clients support +# +# CONFIG_PPS_CLIENT_KTIMER is not set +# CONFIG_PPS_CLIENT_LDISC is not set +# CONFIG_PPS_CLIENT_GPIO is not set + +# +# PPS generators support +# + +# +# PTP clock support +# +CONFIG_PTP_1588_CLOCK=y + +# +# Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks. +# +# end of PTP clock support + +# CONFIG_PINCTRL is not set +# CONFIG_GPIOLIB is not set +# CONFIG_W1 is not set +# CONFIG_POWER_AVS is not set +# CONFIG_POWER_RESET is not set +CONFIG_POWER_SUPPLY=y +# CONFIG_POWER_SUPPLY_DEBUG is not set +# CONFIG_PDA_POWER is not set +# CONFIG_TEST_POWER is not set +# CONFIG_BATTERY_DS2780 is not set +# CONFIG_BATTERY_DS2781 is not set +# CONFIG_BATTERY_BQ27XXX is not set +# CONFIG_CHARGER_MAX8903 is not set +# CONFIG_HWMON is not set +CONFIG_THERMAL=y +# CONFIG_THERMAL_NETLINK is not set +# CONFIG_THERMAL_STATISTICS is not set +CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 +CONFIG_THERMAL_WRITABLE_TRIPS=y +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set +# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set +# CONFIG_THERMAL_GOV_FAIR_SHARE is not set +CONFIG_THERMAL_GOV_STEP_WISE=y +# CONFIG_THERMAL_GOV_BANG_BANG is not set +CONFIG_THERMAL_GOV_USER_SPACE=y +# CONFIG_THERMAL_EMULATION is not set + +# +# Intel thermal drivers +# +CONFIG_INTEL_POWERCLAMP=y +CONFIG_X86_PKG_TEMP_THERMAL=m +# CONFIG_INTEL_SOC_DTS_THERMAL is not set + +# +# ACPI INT340X thermal drivers +# +# CONFIG_INT340X_THERMAL is not set +# end of ACPI INT340X thermal drivers + +# CONFIG_INTEL_PCH_THERMAL is not set +# end of Intel thermal drivers + +# CONFIG_WATCHDOG is not set +CONFIG_SSB_POSSIBLE=y +# CONFIG_SSB is not set +CONFIG_BCMA_POSSIBLE=y +# CONFIG_BCMA is not set + +# +# Multifunction device drivers +# +# CONFIG_MFD_MADERA is not set +# CONFIG_HTC_PASIC3 is not set +# CONFIG_MFD_INTEL_QUARK_I2C_GPIO is not set +# CONFIG_LPC_ICH is not set +# CONFIG_LPC_SCH is not set +# CONFIG_MFD_INTEL_LPSS_ACPI is not set +# CONFIG_MFD_INTEL_LPSS_PCI is not set +# CONFIG_MFD_JANZ_CMODIO is not set +# CONFIG_MFD_KEMPLD is not set +# CONFIG_MFD_MT6397 is not set +# CONFIG_MFD_RDC321X is not set +# CONFIG_MFD_SM501 is not set +# CONFIG_ABX500_CORE is not set +# CONFIG_MFD_SYSCON is not set +# CONFIG_MFD_TI_AM335X_TSCADC is not set +# CONFIG_MFD_TQMX86 is not set +# CONFIG_MFD_VX855 is not set +# end of Multifunction device drivers + +# CONFIG_REGULATOR is not set +# CONFIG_RC_CORE is not set +# CONFIG_MEDIA_CEC_SUPPORT is not set +# CONFIG_MEDIA_SUPPORT is not set + +# +# Graphics support +# +CONFIG_AGP=y +CONFIG_AGP_AMD64=y +CONFIG_AGP_INTEL=y +CONFIG_AGP_SIS=y +CONFIG_AGP_VIA=y +CONFIG_INTEL_GTT=y +CONFIG_VGA_ARB=y +CONFIG_VGA_ARB_MAX_GPUS=16 +# CONFIG_VGA_SWITCHEROO is not set +# CONFIG_DRM is not set + +# +# ARM devices +# +# end of ARM devices + +# +# Frame buffer Devices +# +CONFIG_FB_CMDLINE=y +CONFIG_FB_NOTIFY=y +CONFIG_FB=y +# CONFIG_FIRMWARE_EDID is not set +CONFIG_FB_BOOT_VESA_SUPPORT=y +CONFIG_FB_CFB_FILLRECT=y +CONFIG_FB_CFB_COPYAREA=y +CONFIG_FB_CFB_IMAGEBLIT=y +# CONFIG_FB_FOREIGN_ENDIAN is not set +CONFIG_FB_MODE_HELPERS=y +CONFIG_FB_TILEBLITTING=y + +# +# Frame buffer hardware drivers +# +# CONFIG_FB_CIRRUS is not set +# CONFIG_FB_PM2 is not set +# CONFIG_FB_CYBER2000 is not set +# CONFIG_FB_ARC is not set +# CONFIG_FB_ASILIANT is not set +# CONFIG_FB_IMSTT is not set +# CONFIG_FB_VGA16 is not set +CONFIG_FB_VESA=y +# CONFIG_FB_EFI is not set +# CONFIG_FB_N411 is not set +# CONFIG_FB_HGA is not set +# CONFIG_FB_OPENCORES is not set +# CONFIG_FB_S1D13XXX is not set +# CONFIG_FB_NVIDIA is not set +# CONFIG_FB_RIVA is not set +# CONFIG_FB_I740 is not set +# CONFIG_FB_LE80578 is not set +# CONFIG_FB_INTEL is not set +# CONFIG_FB_MATROX is not set +# CONFIG_FB_RADEON is not set +# CONFIG_FB_ATY128 is not set +# CONFIG_FB_ATY is not set +# CONFIG_FB_S3 is not set +# CONFIG_FB_SAVAGE is not set +# CONFIG_FB_SIS is not set +# CONFIG_FB_NEOMAGIC is not set +# CONFIG_FB_KYRO is not set +# CONFIG_FB_3DFX is not set +# CONFIG_FB_VOODOO1 is not set +# CONFIG_FB_VT8623 is not set +# CONFIG_FB_TRIDENT is not set +# CONFIG_FB_ARK is not set +# CONFIG_FB_PM3 is not set +# CONFIG_FB_CARMINE is not set +# CONFIG_FB_IBM_GXT4500 is not set +# CONFIG_FB_VIRTUAL is not set +# CONFIG_FB_METRONOME is not set +# CONFIG_FB_MB862XX is not set +# CONFIG_FB_SIMPLE is not set +# CONFIG_FB_SM712 is not set +# end of Frame buffer Devices + +# +# Backlight & LCD device support +# +# CONFIG_LCD_CLASS_DEVICE is not set +CONFIG_BACKLIGHT_CLASS_DEVICE=y +# CONFIG_BACKLIGHT_APPLE is not set +# CONFIG_BACKLIGHT_QCOM_WLED is not set +# CONFIG_BACKLIGHT_SAHARA is not set +# end of Backlight & LCD device support + +# +# Console display driver support +# +CONFIG_VGA_CONSOLE=y +CONFIG_VGACON_SOFT_SCROLLBACK=y +CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64 +# CONFIG_VGACON_SOFT_SCROLLBACK_PERSISTENT_ENABLE_BY_DEFAULT is not set +CONFIG_DUMMY_CONSOLE=y +CONFIG_DUMMY_CONSOLE_COLUMNS=80 +CONFIG_DUMMY_CONSOLE_ROWS=25 +CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y +CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y +# CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER is not set +# end of Console display driver support + +CONFIG_LOGO=y +# CONFIG_LOGO_LINUX_MONO is not set +# CONFIG_LOGO_LINUX_VGA16 is not set +CONFIG_LOGO_LINUX_CLUT224=y +# end of Graphics support + +# CONFIG_SOUND is not set + +# +# HID support +# +CONFIG_HID=y +# CONFIG_HID_BATTERY_STRENGTH is not set +# CONFIG_HIDRAW is not set +# CONFIG_UHID is not set +CONFIG_HID_GENERIC=y + +# +# Special HID drivers +# +CONFIG_HID_A4TECH=y +# CONFIG_HID_ACRUX is not set +CONFIG_HID_APPLE=y +# CONFIG_HID_AUREAL is not set +CONFIG_HID_BELKIN=y +CONFIG_HID_CHERRY=y +CONFIG_HID_CHICONY=y +# CONFIG_HID_COUGAR is not set +# CONFIG_HID_MACALLY is not set +# CONFIG_HID_CMEDIA is not set +CONFIG_HID_CYPRESS=y +CONFIG_HID_DRAGONRISE=y +# CONFIG_DRAGONRISE_FF is not set +# CONFIG_HID_EMS_FF is not set +# CONFIG_HID_ELECOM is not set +CONFIG_HID_EZKEY=y +# CONFIG_HID_GEMBIRD is not set +# CONFIG_HID_GFRM is not set +# CONFIG_HID_GLORIOUS is not set +# CONFIG_HID_KEYTOUCH is not set +CONFIG_HID_KYE=y +# CONFIG_HID_WALTOP is not set +# CONFIG_HID_VIEWSONIC is not set +CONFIG_HID_GYRATION=y +# CONFIG_HID_ICADE is not set +# CONFIG_HID_ITE is not set +# CONFIG_HID_JABRA is not set +CONFIG_HID_TWINHAN=y +CONFIG_HID_KENSINGTON=y +# CONFIG_HID_LCPOWER is not set +# CONFIG_HID_LENOVO is not set +# CONFIG_HID_MAGICMOUSE is not set +# CONFIG_HID_MALTRON is not set +# CONFIG_HID_MAYFLASH is not set +# CONFIG_HID_REDRAGON is not set +CONFIG_HID_MICROSOFT=y +CONFIG_HID_MONTEREY=y +# CONFIG_HID_MULTITOUCH is not set +# CONFIG_HID_NTI is not set +# CONFIG_HID_ORTEK is not set +CONFIG_HID_PANTHERLORD=y +# CONFIG_PANTHERLORD_FF is not set +CONFIG_HID_PETALYNX=y +# CONFIG_HID_PICOLCD is not set +# CONFIG_HID_PLANTRONICS is not set +# CONFIG_HID_PRIMAX is not set +# CONFIG_HID_SAITEK is not set +CONFIG_HID_SAMSUNG=y +# CONFIG_HID_SPEEDLINK is not set +# CONFIG_HID_STEAM is not set +# CONFIG_HID_STEELSERIES is not set +CONFIG_HID_SUNPLUS=y +# CONFIG_HID_RMI is not set +CONFIG_HID_GREENASIA=y +# CONFIG_GREENASIA_FF is not set +CONFIG_HID_SMARTJOYPLUS=y +# CONFIG_SMARTJOYPLUS_FF is not set +# CONFIG_HID_TIVO is not set +CONFIG_HID_TOPSEED=y +CONFIG_HID_THRUSTMASTER=y +CONFIG_THRUSTMASTER_FF=y +# CONFIG_HID_UDRAW_PS3 is not set +# CONFIG_HID_XINMO is not set +CONFIG_HID_ZEROPLUS=y +CONFIG_ZEROPLUS_FF=y +# CONFIG_HID_ZYDACRON is not set +# CONFIG_HID_SENSOR_HUB is not set +# CONFIG_HID_ALPS is not set +# end of Special HID drivers + +# +# Intel ISH HID support +# +# CONFIG_INTEL_ISH_HID is not set +# end of Intel ISH HID support +# end of HID support + +CONFIG_USB_OHCI_LITTLE_ENDIAN=y +# CONFIG_USB_SUPPORT is not set +# CONFIG_MMC is not set +# CONFIG_MEMSTICK is not set +# CONFIG_NEW_LEDS is not set +# CONFIG_ACCESSIBILITY is not set +# CONFIG_INFINIBAND is not set +CONFIG_EDAC_ATOMIC_SCRUB=y +CONFIG_EDAC_SUPPORT=y +# CONFIG_EDAC is not set +CONFIG_RTC_LIB=y +CONFIG_RTC_MC146818_LIB=y +# CONFIG_RTC_CLASS is not set +# CONFIG_DMADEVICES is not set + +# +# DMABUF options +# +CONFIG_SYNC_FILE=y +# CONFIG_SW_SYNC is not set +# CONFIG_UDMABUF is not set +# CONFIG_DMABUF_MOVE_NOTIFY is not set +# CONFIG_DMABUF_SELFTESTS is not set +# CONFIG_DMABUF_HEAPS is not set +# end of DMABUF options + +# CONFIG_AUXDISPLAY is not set +# CONFIG_UIO is not set +CONFIG_VIRT_DRIVERS=y +# CONFIG_VBOXGUEST is not set +CONFIG_VIRTIO=y +CONFIG_VIRTIO_MENU=y +CONFIG_VIRTIO_PCI=y +CONFIG_VIRTIO_PCI_LEGACY=y +CONFIG_VIRTIO_BALLOON=y +# CONFIG_VIRTIO_INPUT is not set +# CONFIG_VIRTIO_MMIO is not set +# CONFIG_VDPA is not set +CONFIG_VHOST_MENU=y +# CONFIG_VHOST_NET is not set +# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set + +# +# Microsoft Hyper-V guest support +# +# end of Microsoft Hyper-V guest support + +# CONFIG_GREYBUS is not set +# CONFIG_STAGING is not set +# CONFIG_X86_PLATFORM_DEVICES is not set +CONFIG_PMC_ATOM=y +# CONFIG_MFD_CROS_EC is not set +# CONFIG_CHROME_PLATFORMS is not set +# CONFIG_MELLANOX_PLATFORM is not set +CONFIG_HAVE_CLK=y +CONFIG_CLKDEV_LOOKUP=y +CONFIG_HAVE_CLK_PREPARE=y +CONFIG_COMMON_CLK=y +# CONFIG_HWSPINLOCK is not set + +# +# Clock Source drivers +# +CONFIG_CLKEVT_I8253=y +CONFIG_I8253_LOCK=y +CONFIG_CLKBLD_I8253=y +# end of Clock Source drivers + +CONFIG_MAILBOX=y +CONFIG_PCC=y +# CONFIG_ALTERA_MBOX is not set +# CONFIG_IOMMU_SUPPORT is not set + +# +# Remoteproc drivers +# +# CONFIG_REMOTEPROC is not set +# end of Remoteproc drivers + +# +# Rpmsg drivers +# +# CONFIG_RPMSG_QCOM_GLINK_RPM is not set +# CONFIG_RPMSG_VIRTIO is not set +# end of Rpmsg drivers + +# CONFIG_SOUNDWIRE is not set + +# +# SOC (System On Chip) specific Drivers +# + +# +# Amlogic SoC drivers +# +# end of Amlogic SoC drivers + +# +# Aspeed SoC drivers +# +# end of Aspeed SoC drivers + +# +# Broadcom SoC drivers +# +# end of Broadcom SoC drivers + +# +# NXP/Freescale QorIQ SoC drivers +# +# end of NXP/Freescale QorIQ SoC drivers + +# +# i.MX SoC drivers +# +# end of i.MX SoC drivers + +# +# Qualcomm SoC drivers +# +# end of Qualcomm SoC drivers + +# CONFIG_SOC_TI is not set + +# +# Xilinx SoC drivers +# +# CONFIG_XILINX_VCU is not set +# end of Xilinx SoC drivers +# end of SOC (System On Chip) specific Drivers + +# CONFIG_PM_DEVFREQ is not set +# CONFIG_EXTCON is not set +# CONFIG_MEMORY is not set +# CONFIG_IIO is not set +# CONFIG_NTB is not set +# CONFIG_VME_BUS is not set +# CONFIG_PWM is not set + +# +# IRQ chip support +# +# end of IRQ chip support + +# CONFIG_IPACK_BUS is not set +# CONFIG_RESET_CONTROLLER is not set + +# +# PHY Subsystem +# +CONFIG_GENERIC_PHY=y +# CONFIG_BCM_KONA_USB2_PHY is not set +# CONFIG_PHY_PXA_28NM_HSIC is not set +# CONFIG_PHY_PXA_28NM_USB2 is not set +# CONFIG_PHY_INTEL_EMMC is not set +# end of PHY Subsystem + +# CONFIG_POWERCAP is not set +# CONFIG_MCB is not set + +# +# Performance monitor support +# +# end of Performance monitor support + +CONFIG_RAS=y +# CONFIG_RAS_CEC is not set +# CONFIG_USB4 is not set + +# +# Android +# +# CONFIG_ANDROID is not set +# end of Android + +# CONFIG_LIBNVDIMM is not set +# CONFIG_DAX is not set +CONFIG_NVMEM=y +# CONFIG_NVMEM_SYSFS is not set + +# +# HW tracing support +# +# CONFIG_STM is not set +# CONFIG_INTEL_TH is not set +# end of HW tracing support + +# CONFIG_FPGA is not set +# CONFIG_TEE is not set +# CONFIG_UNISYS_VISORBUS is not set +# CONFIG_SIOX is not set +# CONFIG_SLIMBUS is not set +# CONFIG_INTERCONNECT is not set +# CONFIG_COUNTER is not set +# end of Device Drivers + +# +# File systems +# +CONFIG_DCACHE_WORD_ACCESS=y +CONFIG_VALIDATE_FS_PARSER=y +CONFIG_FS_IOMAP=y +# CONFIG_EXT2_FS is not set +# CONFIG_EXT3_FS is not set +CONFIG_EXT4_FS=y +CONFIG_EXT4_USE_FOR_EXT2=y +CONFIG_EXT4_FS_POSIX_ACL=y +CONFIG_EXT4_FS_SECURITY=y +# CONFIG_EXT4_DEBUG is not set +CONFIG_JBD2=y +# CONFIG_JBD2_DEBUG is not set +CONFIG_FS_MBCACHE=y +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +# CONFIG_XFS_FS is not set +# CONFIG_GFS2_FS is not set +# CONFIG_BTRFS_FS is not set +# CONFIG_NILFS2_FS is not set +# CONFIG_F2FS_FS is not set +# CONFIG_FS_DAX is not set +CONFIG_FS_POSIX_ACL=y +CONFIG_EXPORTFS=y +# CONFIG_EXPORTFS_BLOCK_OPS is not set +CONFIG_FILE_LOCKING=y +CONFIG_MANDATORY_FILE_LOCKING=y +# CONFIG_FS_ENCRYPTION is not set +# CONFIG_FS_VERITY is not set +CONFIG_FSNOTIFY=y +CONFIG_DNOTIFY=y +CONFIG_INOTIFY_USER=y +# CONFIG_FANOTIFY is not set +# CONFIG_QUOTA is not set +# CONFIG_AUTOFS4_FS is not set +# CONFIG_AUTOFS_FS is not set +# CONFIG_FUSE_FS is not set +# CONFIG_OVERLAY_FS is not set + +# +# Caches +# +# CONFIG_FSCACHE is not set +# end of Caches + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set +# end of CD-ROM/DVD Filesystems + +# +# DOS/FAT/EXFAT/NT Filesystems +# +# CONFIG_MSDOS_FS is not set +# CONFIG_VFAT_FS is not set +# CONFIG_EXFAT_FS is not set +# CONFIG_NTFS_FS is not set +# end of DOS/FAT/EXFAT/NT Filesystems + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_KCORE=y +CONFIG_PROC_SYSCTL=y +CONFIG_PROC_PAGE_MONITOR=y +# CONFIG_PROC_CHILDREN is not set +CONFIG_PROC_PID_ARCH_STATUS=y +CONFIG_KERNFS=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +CONFIG_TMPFS_XATTR=y +# CONFIG_TMPFS_INODE64 is not set +CONFIG_HUGETLBFS=y +CONFIG_HUGETLB_PAGE=y +CONFIG_MEMFD_CREATE=y +CONFIG_ARCH_HAS_GIGANTIC_PAGE=y +# CONFIG_CONFIGFS_FS is not set +# CONFIG_EFIVAR_FS is not set +# end of Pseudo filesystems + +# CONFIG_MISC_FILESYSTEMS is not set +CONFIG_NETWORK_FILESYSTEMS=y +# CONFIG_NFS_FS is not set +# CONFIG_NFSD is not set +# CONFIG_CEPH_FS is not set +# CONFIG_CIFS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set +CONFIG_9P_FS=y +CONFIG_9P_FS_POSIX_ACL=y +CONFIG_9P_FS_SECURITY=y +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NLS_CODEPAGE_437=y +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +# CONFIG_NLS_CODEPAGE_850 is not set +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +# CONFIG_NLS_CODEPAGE_936 is not set +# CONFIG_NLS_CODEPAGE_950 is not set +# CONFIG_NLS_CODEPAGE_932 is not set +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_ISO8859_8 is not set +# CONFIG_NLS_CODEPAGE_1250 is not set +# CONFIG_NLS_CODEPAGE_1251 is not set +CONFIG_NLS_ASCII=y +# CONFIG_NLS_ISO8859_1 is not set +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +# CONFIG_NLS_ISO8859_15 is not set +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +# CONFIG_NLS_MAC_ROMAN is not set +# CONFIG_NLS_MAC_CELTIC is not set +# CONFIG_NLS_MAC_CENTEURO is not set +# CONFIG_NLS_MAC_CROATIAN is not set +# CONFIG_NLS_MAC_CYRILLIC is not set +# CONFIG_NLS_MAC_GAELIC is not set +# CONFIG_NLS_MAC_GREEK is not set +# CONFIG_NLS_MAC_ICELAND is not set +# CONFIG_NLS_MAC_INUIT is not set +# CONFIG_NLS_MAC_ROMANIAN is not set +# CONFIG_NLS_MAC_TURKISH is not set +# CONFIG_NLS_UTF8 is not set +# CONFIG_UNICODE is not set +CONFIG_IO_WQ=y +# end of File systems + +# +# Security options +# +CONFIG_KEYS=y +# CONFIG_KEYS_REQUEST_CACHE is not set +# CONFIG_PERSISTENT_KEYRINGS is not set +# CONFIG_TRUSTED_KEYS is not set +# CONFIG_ENCRYPTED_KEYS is not set +# CONFIG_KEY_DH_OPERATIONS is not set +# CONFIG_SECURITY_DMESG_RESTRICT is not set +CONFIG_SECURITY=y +CONFIG_SECURITYFS=y +CONFIG_SECURITY_NETWORK=y +CONFIG_PAGE_TABLE_ISOLATION=y +# CONFIG_SECURITY_NETWORK_XFRM is not set +# CONFIG_SECURITY_PATH is not set +CONFIG_LSM_MMAP_MIN_ADDR=65536 +CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR=y +# CONFIG_HARDENED_USERCOPY is not set +# CONFIG_FORTIFY_SOURCE is not set +# CONFIG_STATIC_USERMODEHELPER is not set +CONFIG_SECURITY_SELINUX=y +# CONFIG_SECURITY_SELINUX_BOOTPARAM is not set +# CONFIG_SECURITY_SELINUX_DISABLE is not set +CONFIG_SECURITY_SELINUX_DEVELOP=y +CONFIG_SECURITY_SELINUX_AVC_STATS=y +CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=0 +CONFIG_SECURITY_SELINUX_SIDTAB_HASH_BITS=9 +CONFIG_SECURITY_SELINUX_SID2STR_CACHE_SIZE=256 +# CONFIG_SECURITY_SMACK is not set +# CONFIG_SECURITY_TOMOYO is not set +# CONFIG_SECURITY_APPARMOR is not set +# CONFIG_SECURITY_LOADPIN is not set +# CONFIG_SECURITY_YAMA is not set +# CONFIG_SECURITY_SAFESETID is not set +# CONFIG_SECURITY_LOCKDOWN_LSM is not set +CONFIG_INTEGRITY=y +# CONFIG_INTEGRITY_SIGNATURE is not set +CONFIG_INTEGRITY_AUDIT=y +CONFIG_IMA=y +CONFIG_IMA_MEASURE_PCR_IDX=10 +CONFIG_IMA_LSM_RULES=y +# CONFIG_IMA_TEMPLATE is not set +CONFIG_IMA_NG_TEMPLATE=y +# CONFIG_IMA_SIG_TEMPLATE is not set +CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng" +CONFIG_IMA_DEFAULT_HASH_SHA1=y +# CONFIG_IMA_DEFAULT_HASH_SHA256 is not set +CONFIG_IMA_DEFAULT_HASH="sha1" +CONFIG_IMA_WRITE_POLICY=y +CONFIG_IMA_READ_POLICY=y +# CONFIG_IMA_APPRAISE is not set +CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=y +CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=y +# CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT is not set +# CONFIG_EVM is not set +# CONFIG_DEFAULT_SECURITY_SELINUX is not set +CONFIG_DEFAULT_SECURITY_DAC=y +CONFIG_LSM="selinux,bpf,integrity" + +# +# Kernel hardening options +# + +# +# Memory initialization +# +CONFIG_INIT_STACK_NONE=y +# CONFIG_INIT_ON_ALLOC_DEFAULT_ON is not set +# CONFIG_INIT_ON_FREE_DEFAULT_ON is not set +# end of Memory initialization +# end of Kernel hardening options +# end of Security options + +CONFIG_CRYPTO=y + +# +# Crypto core or helper +# +CONFIG_CRYPTO_ALGAPI=y +CONFIG_CRYPTO_ALGAPI2=y +CONFIG_CRYPTO_AEAD=y +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_SKCIPHER=y +CONFIG_CRYPTO_SKCIPHER2=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_RNG=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_RNG_DEFAULT=y +CONFIG_CRYPTO_AKCIPHER2=y +CONFIG_CRYPTO_AKCIPHER=y +CONFIG_CRYPTO_KPP2=y +CONFIG_CRYPTO_ACOMP2=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +# CONFIG_CRYPTO_USER is not set +CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y +CONFIG_CRYPTO_GF128MUL=y +CONFIG_CRYPTO_NULL=y +CONFIG_CRYPTO_NULL2=y +# CONFIG_CRYPTO_PCRYPT is not set +# CONFIG_CRYPTO_CRYPTD is not set +# CONFIG_CRYPTO_AUTHENC is not set +# CONFIG_CRYPTO_TEST is not set +CONFIG_CRYPTO_ENGINE=m + +# +# Public-key cryptography +# +CONFIG_CRYPTO_RSA=y +# CONFIG_CRYPTO_DH is not set +# CONFIG_CRYPTO_ECDH is not set +# CONFIG_CRYPTO_ECRDSA is not set +# CONFIG_CRYPTO_CURVE25519 is not set +# CONFIG_CRYPTO_CURVE25519_X86 is not set + +# +# Authenticated Encryption with Associated Data +# +# CONFIG_CRYPTO_CCM is not set +CONFIG_CRYPTO_GCM=y +# CONFIG_CRYPTO_CHACHA20POLY1305 is not set +# CONFIG_CRYPTO_AEGIS128 is not set +# CONFIG_CRYPTO_AEGIS128_AESNI_SSE2 is not set +CONFIG_CRYPTO_SEQIV=y +# CONFIG_CRYPTO_ECHAINIV is not set + +# +# Block modes +# +# CONFIG_CRYPTO_CBC is not set +# CONFIG_CRYPTO_CFB is not set +CONFIG_CRYPTO_CTR=y +# CONFIG_CRYPTO_CTS is not set +# CONFIG_CRYPTO_ECB is not set +# CONFIG_CRYPTO_LRW is not set +# CONFIG_CRYPTO_OFB is not set +# CONFIG_CRYPTO_PCBC is not set +# CONFIG_CRYPTO_XTS is not set +# CONFIG_CRYPTO_KEYWRAP is not set +# CONFIG_CRYPTO_NHPOLY1305_SSE2 is not set +# CONFIG_CRYPTO_NHPOLY1305_AVX2 is not set +# CONFIG_CRYPTO_ADIANTUM is not set +# CONFIG_CRYPTO_ESSIV is not set + +# +# Hash modes +# +# CONFIG_CRYPTO_CMAC is not set +CONFIG_CRYPTO_HMAC=y +# CONFIG_CRYPTO_XCBC is not set +# CONFIG_CRYPTO_VMAC is not set + +# +# Digest +# +CONFIG_CRYPTO_CRC32C=y +# CONFIG_CRYPTO_CRC32C_INTEL is not set +# CONFIG_CRYPTO_CRC32 is not set +# CONFIG_CRYPTO_CRC32_PCLMUL is not set +CONFIG_CRYPTO_XXHASH=y +CONFIG_CRYPTO_BLAKE2B=y +# CONFIG_CRYPTO_BLAKE2S is not set +# CONFIG_CRYPTO_BLAKE2S_X86 is not set +CONFIG_CRYPTO_CRCT10DIF=y +# CONFIG_CRYPTO_CRCT10DIF_PCLMUL is not set +CONFIG_CRYPTO_GHASH=y +# CONFIG_CRYPTO_POLY1305 is not set +# CONFIG_CRYPTO_POLY1305_X86_64 is not set +# CONFIG_CRYPTO_MD4 is not set +CONFIG_CRYPTO_MD5=y +# CONFIG_CRYPTO_MICHAEL_MIC is not set +# CONFIG_CRYPTO_RMD128 is not set +# CONFIG_CRYPTO_RMD160 is not set +# CONFIG_CRYPTO_RMD256 is not set +# CONFIG_CRYPTO_RMD320 is not set +CONFIG_CRYPTO_SHA1=y +# CONFIG_CRYPTO_SHA1_SSSE3 is not set +# CONFIG_CRYPTO_SHA256_SSSE3 is not set +# CONFIG_CRYPTO_SHA512_SSSE3 is not set +CONFIG_CRYPTO_SHA256=y +# CONFIG_CRYPTO_SHA512 is not set +# CONFIG_CRYPTO_SHA3 is not set +# CONFIG_CRYPTO_SM3 is not set +# CONFIG_CRYPTO_STREEBOG is not set +# CONFIG_CRYPTO_TGR192 is not set +# CONFIG_CRYPTO_WP512 is not set +# CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL is not set + +# +# Ciphers +# +CONFIG_CRYPTO_AES=y +# CONFIG_CRYPTO_AES_TI is not set +# CONFIG_CRYPTO_AES_NI_INTEL is not set +# CONFIG_CRYPTO_ANUBIS is not set +# CONFIG_CRYPTO_ARC4 is not set +# CONFIG_CRYPTO_BLOWFISH is not set +# CONFIG_CRYPTO_BLOWFISH_X86_64 is not set +# CONFIG_CRYPTO_CAMELLIA is not set +# CONFIG_CRYPTO_CAMELLIA_X86_64 is not set +# CONFIG_CRYPTO_CAMELLIA_AESNI_AVX_X86_64 is not set +# CONFIG_CRYPTO_CAMELLIA_AESNI_AVX2_X86_64 is not set +# CONFIG_CRYPTO_CAST5 is not set +# CONFIG_CRYPTO_CAST5_AVX_X86_64 is not set +# CONFIG_CRYPTO_CAST6 is not set +# CONFIG_CRYPTO_CAST6_AVX_X86_64 is not set +# CONFIG_CRYPTO_DES is not set +# CONFIG_CRYPTO_DES3_EDE_X86_64 is not set +# CONFIG_CRYPTO_FCRYPT is not set +# CONFIG_CRYPTO_KHAZAD is not set +# CONFIG_CRYPTO_SALSA20 is not set +# CONFIG_CRYPTO_CHACHA20 is not set +# CONFIG_CRYPTO_CHACHA20_X86_64 is not set +# CONFIG_CRYPTO_SEED is not set +# CONFIG_CRYPTO_SERPENT is not set +# CONFIG_CRYPTO_SERPENT_SSE2_X86_64 is not set +# CONFIG_CRYPTO_SERPENT_AVX_X86_64 is not set +# CONFIG_CRYPTO_SERPENT_AVX2_X86_64 is not set +# CONFIG_CRYPTO_SM4 is not set +# CONFIG_CRYPTO_TEA is not set +# CONFIG_CRYPTO_TWOFISH is not set +# CONFIG_CRYPTO_TWOFISH_X86_64 is not set +# CONFIG_CRYPTO_TWOFISH_X86_64_3WAY is not set +# CONFIG_CRYPTO_TWOFISH_AVX_X86_64 is not set + +# +# Compression +# +# CONFIG_CRYPTO_DEFLATE is not set +# CONFIG_CRYPTO_LZO is not set +# CONFIG_CRYPTO_842 is not set +# CONFIG_CRYPTO_LZ4 is not set +# CONFIG_CRYPTO_LZ4HC is not set +# CONFIG_CRYPTO_ZSTD is not set + +# +# Random Number Generation +# +# CONFIG_CRYPTO_ANSI_CPRNG is not set +CONFIG_CRYPTO_DRBG_MENU=y +CONFIG_CRYPTO_DRBG_HMAC=y +# CONFIG_CRYPTO_DRBG_HASH is not set +# CONFIG_CRYPTO_DRBG_CTR is not set +CONFIG_CRYPTO_DRBG=y +CONFIG_CRYPTO_JITTERENTROPY=y +CONFIG_CRYPTO_USER_API=y +CONFIG_CRYPTO_USER_API_HASH=y +# CONFIG_CRYPTO_USER_API_SKCIPHER is not set +# CONFIG_CRYPTO_USER_API_RNG is not set +# CONFIG_CRYPTO_USER_API_AEAD is not set +CONFIG_CRYPTO_HASH_INFO=y + +# +# Crypto library routines +# +CONFIG_CRYPTO_LIB_AES=y +# CONFIG_CRYPTO_LIB_BLAKE2S is not set +# CONFIG_CRYPTO_LIB_CHACHA is not set +# CONFIG_CRYPTO_LIB_CURVE25519 is not set +CONFIG_CRYPTO_LIB_POLY1305_RSIZE=11 +# CONFIG_CRYPTO_LIB_POLY1305 is not set +# CONFIG_CRYPTO_LIB_CHACHA20POLY1305 is not set +CONFIG_CRYPTO_LIB_SHA256=y +CONFIG_CRYPTO_HW=y +# CONFIG_CRYPTO_DEV_PADLOCK is not set +# CONFIG_CRYPTO_DEV_CCP is not set +# CONFIG_CRYPTO_DEV_QAT_DH895xCC is not set +# CONFIG_CRYPTO_DEV_QAT_C3XXX is not set +# CONFIG_CRYPTO_DEV_QAT_C62X is not set +# CONFIG_CRYPTO_DEV_QAT_DH895xCCVF is not set +# CONFIG_CRYPTO_DEV_QAT_C3XXXVF is not set +# CONFIG_CRYPTO_DEV_QAT_C62XVF is not set +# CONFIG_CRYPTO_DEV_NITROX_CNN55XX is not set +CONFIG_CRYPTO_DEV_VIRTIO=m +# CONFIG_CRYPTO_DEV_SAFEXCEL is not set +# CONFIG_CRYPTO_DEV_AMLOGIC_GXL is not set +CONFIG_ASYMMETRIC_KEY_TYPE=y +CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y +CONFIG_X509_CERTIFICATE_PARSER=y +# CONFIG_PKCS8_PRIVATE_KEY_PARSER is not set +CONFIG_PKCS7_MESSAGE_PARSER=y + +# +# Certificates for signature checking +# +CONFIG_SYSTEM_TRUSTED_KEYRING=y +CONFIG_SYSTEM_TRUSTED_KEYS="" +# CONFIG_SYSTEM_EXTRA_CERTIFICATE is not set +# CONFIG_SECONDARY_TRUSTED_KEYRING is not set +# CONFIG_SYSTEM_BLACKLIST_KEYRING is not set +# end of Certificates for signature checking + +CONFIG_BINARY_PRINTF=y + +# +# Library routines +# +# CONFIG_PACKING is not set +CONFIG_BITREVERSE=y +CONFIG_GENERIC_STRNCPY_FROM_USER=y +CONFIG_GENERIC_STRNLEN_USER=y +CONFIG_GENERIC_NET_UTILS=y +CONFIG_GENERIC_FIND_FIRST_BIT=y +# CONFIG_CORDIC is not set +# CONFIG_PRIME_NUMBERS is not set +CONFIG_RATIONAL=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_IOMAP=y +CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y +CONFIG_ARCH_HAS_FAST_MULTIPLIER=y +CONFIG_ARCH_USE_SYM_ANNOTATIONS=y +CONFIG_CRC_CCITT=y +CONFIG_CRC16=y +CONFIG_CRC_T10DIF=y +# CONFIG_CRC_ITU_T is not set +CONFIG_CRC32=y +# CONFIG_CRC32_SELFTEST is not set +CONFIG_CRC32_SLICEBY8=y +# CONFIG_CRC32_SLICEBY4 is not set +# CONFIG_CRC32_SARWATE is not set +# CONFIG_CRC32_BIT is not set +# CONFIG_CRC64 is not set +# CONFIG_CRC4 is not set +# CONFIG_CRC7 is not set +CONFIG_LIBCRC32C=y +# CONFIG_CRC8 is not set +CONFIG_XXHASH=y +# CONFIG_RANDOM32_SELFTEST is not set +CONFIG_ZLIB_INFLATE=y +CONFIG_LZO_DECOMPRESS=y +CONFIG_LZ4_DECOMPRESS=y +CONFIG_ZSTD_DECOMPRESS=y +CONFIG_XZ_DEC=y +CONFIG_XZ_DEC_X86=y +# CONFIG_XZ_DEC_POWERPC is not set +# CONFIG_XZ_DEC_IA64 is not set +# CONFIG_XZ_DEC_ARM is not set +# CONFIG_XZ_DEC_ARMTHUMB is not set +# CONFIG_XZ_DEC_SPARC is not set +CONFIG_XZ_DEC_BCJ=y +# CONFIG_XZ_DEC_TEST is not set +CONFIG_DECOMPRESS_GZIP=y +CONFIG_DECOMPRESS_BZIP2=y +CONFIG_DECOMPRESS_LZMA=y +CONFIG_DECOMPRESS_XZ=y +CONFIG_DECOMPRESS_LZO=y +CONFIG_DECOMPRESS_LZ4=y +CONFIG_DECOMPRESS_ZSTD=y +CONFIG_GENERIC_ALLOCATOR=y +CONFIG_XARRAY_MULTI=y +CONFIG_ASSOCIATIVE_ARRAY=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HAS_DMA=y +CONFIG_DMA_OPS=y +CONFIG_NEED_SG_DMA_LENGTH=y +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_ARCH_DMA_ADDR_T_64BIT=y +CONFIG_SWIOTLB=y +CONFIG_DMA_CMA=y + +# +# Default contiguous memory area size: +# +CONFIG_CMA_SIZE_MBYTES=0 +CONFIG_CMA_SIZE_SEL_MBYTES=y +# CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set +# CONFIG_CMA_SIZE_SEL_MIN is not set +# CONFIG_CMA_SIZE_SEL_MAX is not set +CONFIG_CMA_ALIGNMENT=8 +# CONFIG_DMA_API_DEBUG is not set +CONFIG_SGL_ALLOC=y +CONFIG_IOMMU_HELPER=y +CONFIG_CPU_RMAP=y +CONFIG_DQL=y +CONFIG_GLOB=y +# CONFIG_GLOB_SELFTEST is not set +CONFIG_NLATTR=y +CONFIG_CLZ_TAB=y +CONFIG_IRQ_POLL=y +CONFIG_MPILIB=y +CONFIG_OID_REGISTRY=y +CONFIG_UCS2_STRING=y +CONFIG_HAVE_GENERIC_VDSO=y +CONFIG_GENERIC_GETTIMEOFDAY=y +CONFIG_GENERIC_VDSO_TIME_NS=y +CONFIG_FONT_SUPPORT=y +CONFIG_FONTS=y +# CONFIG_FONT_8x8 is not set +CONFIG_FONT_8x16=y +# CONFIG_FONT_6x11 is not set +# CONFIG_FONT_7x14 is not set +# CONFIG_FONT_PEARL_8x8 is not set +# CONFIG_FONT_ACORN_8x8 is not set +CONFIG_FONT_MINI_4x6=y +# CONFIG_FONT_6x10 is not set +# CONFIG_FONT_10x18 is not set +# CONFIG_FONT_SUN8x16 is not set +# CONFIG_FONT_SUN12x22 is not set +# CONFIG_FONT_TER16x32 is not set +CONFIG_ARCH_HAS_PMEM_API=y +CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE=y +CONFIG_ARCH_HAS_UACCESS_MCSAFE=y +CONFIG_ARCH_STACKWALK=y +CONFIG_SBITMAP=y +# CONFIG_STRING_SELFTEST is not set +# end of Library routines + +# +# Kernel hacking +# + +# +# printk and dmesg options +# +CONFIG_PRINTK_TIME=y +# CONFIG_PRINTK_CALLER is not set +CONFIG_CONSOLE_LOGLEVEL_DEFAULT=7 +CONFIG_CONSOLE_LOGLEVEL_QUIET=4 +CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4 +# CONFIG_BOOT_PRINTK_DELAY is not set +# CONFIG_DYNAMIC_DEBUG is not set +# CONFIG_DYNAMIC_DEBUG_CORE is not set +CONFIG_SYMBOLIC_ERRNAME=y +CONFIG_DEBUG_BUGVERBOSE=y +# end of printk and dmesg options + +# +# Compile-time checks and compiler options +# +CONFIG_DEBUG_INFO=y +# CONFIG_DEBUG_INFO_REDUCED is not set +# CONFIG_DEBUG_INFO_COMPRESSED is not set +# CONFIG_DEBUG_INFO_SPLIT is not set +# CONFIG_DEBUG_INFO_DWARF4 is not set +CONFIG_DEBUG_INFO_BTF=y +# CONFIG_GDB_SCRIPTS is not set +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_FRAME_WARN=2048 +# CONFIG_STRIP_ASM_SYMS is not set +# CONFIG_READABLE_ASM is not set +# CONFIG_HEADERS_INSTALL is not set +# CONFIG_DEBUG_SECTION_MISMATCH is not set +CONFIG_SECTION_MISMATCH_WARN_ONLY=y +# CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_32B is not set +CONFIG_STACK_VALIDATION=y +# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set +# end of Compile-time checks and compiler options + +# +# Generic Kernel Debugging Instruments +# +CONFIG_MAGIC_SYSRQ=y +CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1 +CONFIG_MAGIC_SYSRQ_SERIAL=y +CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE="" +CONFIG_DEBUG_FS=y +CONFIG_DEBUG_FS_ALLOW_ALL=y +# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set +# CONFIG_DEBUG_FS_ALLOW_NONE is not set +CONFIG_HAVE_ARCH_KGDB=y +# CONFIG_KGDB is not set +CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y +# CONFIG_UBSAN is not set +# end of Generic Kernel Debugging Instruments + +CONFIG_DEBUG_KERNEL=y +CONFIG_DEBUG_MISC=y + +# +# Memory Debugging +# +# CONFIG_PAGE_EXTENSION is not set +# CONFIG_DEBUG_PAGEALLOC is not set +# CONFIG_PAGE_OWNER is not set +# CONFIG_PAGE_POISONING is not set +# CONFIG_DEBUG_PAGE_REF is not set +# CONFIG_DEBUG_RODATA_TEST is not set +CONFIG_ARCH_HAS_DEBUG_WX=y +# CONFIG_DEBUG_WX is not set +CONFIG_GENERIC_PTDUMP=y +# CONFIG_PTDUMP_DEBUGFS is not set +# CONFIG_DEBUG_OBJECTS is not set +# CONFIG_SLUB_DEBUG_ON is not set +# CONFIG_SLUB_STATS is not set +CONFIG_HAVE_DEBUG_KMEMLEAK=y +# CONFIG_DEBUG_KMEMLEAK is not set +# CONFIG_DEBUG_STACK_USAGE is not set +CONFIG_SCHED_STACK_END_CHECK=y +CONFIG_ARCH_HAS_DEBUG_VM_PGTABLE=y +# CONFIG_DEBUG_VM is not set +# CONFIG_DEBUG_VM_PGTABLE is not set +CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y +# CONFIG_DEBUG_VIRTUAL is not set +CONFIG_DEBUG_MEMORY_INIT=y +# CONFIG_DEBUG_PER_CPU_MAPS is not set +CONFIG_HAVE_ARCH_KASAN=y +CONFIG_HAVE_ARCH_KASAN_VMALLOC=y +CONFIG_CC_HAS_KASAN_GENERIC=y +# end of Memory Debugging + +# CONFIG_DEBUG_SHIRQ is not set + +# +# Debug Oops, Lockups and Hangs +# +CONFIG_PANIC_ON_OOPS=y +CONFIG_PANIC_ON_OOPS_VALUE=1 +CONFIG_PANIC_TIMEOUT=0 +CONFIG_LOCKUP_DETECTOR=y +CONFIG_SOFTLOCKUP_DETECTOR=y +# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set +CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0 +CONFIG_HARDLOCKUP_DETECTOR_PERF=y +CONFIG_HARDLOCKUP_CHECK_TIMESTAMP=y +CONFIG_HARDLOCKUP_DETECTOR=y +CONFIG_BOOTPARAM_HARDLOCKUP_PANIC=y +CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE=1 +CONFIG_DETECT_HUNG_TASK=y +CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120 +# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set +CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0 +# CONFIG_WQ_WATCHDOG is not set +# CONFIG_TEST_LOCKUP is not set +# end of Debug Oops, Lockups and Hangs + +# +# Scheduler Debugging +# +CONFIG_SCHED_DEBUG=y +CONFIG_SCHED_INFO=y +CONFIG_SCHEDSTATS=y +# end of Scheduler Debugging + +# CONFIG_DEBUG_TIMEKEEPING is not set +CONFIG_DEBUG_PREEMPT=y + +# +# Lock Debugging (spinlocks, mutexes, etc...) +# +CONFIG_LOCK_DEBUGGING_SUPPORT=y +CONFIG_PROVE_LOCKING=y +# CONFIG_PROVE_RAW_LOCK_NESTING is not set +# CONFIG_LOCK_STAT is not set +CONFIG_DEBUG_RT_MUTEXES=y +CONFIG_DEBUG_SPINLOCK=y +CONFIG_DEBUG_MUTEXES=y +CONFIG_DEBUG_WW_MUTEX_SLOWPATH=y +CONFIG_DEBUG_RWSEMS=y +CONFIG_DEBUG_LOCK_ALLOC=y +CONFIG_LOCKDEP=y +# CONFIG_DEBUG_LOCKDEP is not set +CONFIG_DEBUG_ATOMIC_SLEEP=y +# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set +# CONFIG_LOCK_TORTURE_TEST is not set +# CONFIG_WW_MUTEX_SELFTEST is not set +# end of Lock Debugging (spinlocks, mutexes, etc...) + +CONFIG_TRACE_IRQFLAGS=y +CONFIG_TRACE_IRQFLAGS_NMI=y +CONFIG_STACKTRACE=y +# CONFIG_WARN_ALL_UNSEEDED_RANDOM is not set +# CONFIG_DEBUG_KOBJECT is not set + +# +# Debug kernel data structures +# +# CONFIG_DEBUG_LIST is not set +# CONFIG_DEBUG_PLIST is not set +# CONFIG_DEBUG_SG is not set +# CONFIG_DEBUG_NOTIFIERS is not set +# CONFIG_BUG_ON_DATA_CORRUPTION is not set +# end of Debug kernel data structures + +CONFIG_DEBUG_CREDENTIALS=y + +# +# RCU Debugging +# +CONFIG_PROVE_RCU=y +# CONFIG_RCU_PERF_TEST is not set +# CONFIG_RCU_TORTURE_TEST is not set +# CONFIG_RCU_REF_SCALE_TEST is not set +CONFIG_RCU_CPU_STALL_TIMEOUT=60 +# CONFIG_RCU_TRACE is not set +# CONFIG_RCU_EQS_DEBUG is not set +# end of RCU Debugging + +# CONFIG_DEBUG_WQ_FORCE_RR_CPU is not set +# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set +# CONFIG_CPU_HOTPLUG_STATE_CONTROL is not set +# CONFIG_LATENCYTOP is not set +CONFIG_USER_STACKTRACE_SUPPORT=y +CONFIG_NOP_TRACER=y +CONFIG_HAVE_FUNCTION_TRACER=y +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y +CONFIG_HAVE_DYNAMIC_FTRACE=y +CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y +CONFIG_HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=y +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y +CONFIG_HAVE_SYSCALL_TRACEPOINTS=y +CONFIG_HAVE_FENTRY=y +CONFIG_HAVE_C_RECORDMCOUNT=y +CONFIG_TRACE_CLOCK=y +CONFIG_RING_BUFFER=y +CONFIG_EVENT_TRACING=y +CONFIG_CONTEXT_SWITCH_TRACER=y +CONFIG_PREEMPTIRQ_TRACEPOINTS=y +CONFIG_TRACING=y +CONFIG_GENERIC_TRACER=y +CONFIG_TRACING_SUPPORT=y +CONFIG_FTRACE=y +CONFIG_BOOTTIME_TRACING=y +CONFIG_FUNCTION_TRACER=y +CONFIG_FUNCTION_GRAPH_TRACER=y +CONFIG_DYNAMIC_FTRACE=y +CONFIG_DYNAMIC_FTRACE_WITH_REGS=y +CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=y +# CONFIG_FUNCTION_PROFILER is not set +# CONFIG_STACK_TRACER is not set +# CONFIG_IRQSOFF_TRACER is not set +# CONFIG_PREEMPT_TRACER is not set +# CONFIG_SCHED_TRACER is not set +# CONFIG_HWLAT_TRACER is not set +# CONFIG_MMIOTRACE is not set +CONFIG_FTRACE_SYSCALLS=y +# CONFIG_TRACER_SNAPSHOT is not set +CONFIG_BRANCH_PROFILE_NONE=y +# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set +# CONFIG_PROFILE_ALL_BRANCHES is not set +CONFIG_BLK_DEV_IO_TRACE=y +CONFIG_KPROBE_EVENTS=y +# CONFIG_KPROBE_EVENTS_ON_NOTRACE is not set +CONFIG_UPROBE_EVENTS=y +CONFIG_BPF_EVENTS=y +CONFIG_DYNAMIC_EVENTS=y +CONFIG_PROBE_EVENTS=y +CONFIG_BPF_KPROBE_OVERRIDE=y +CONFIG_FTRACE_MCOUNT_RECORD=y +# CONFIG_SYNTH_EVENTS is not set +# CONFIG_HIST_TRIGGERS is not set +# CONFIG_TRACE_EVENT_INJECT is not set +# CONFIG_TRACEPOINT_BENCHMARK is not set +# CONFIG_RING_BUFFER_BENCHMARK is not set +# CONFIG_TRACE_EVAL_MAP_FILE is not set +# CONFIG_FTRACE_STARTUP_TEST is not set +# CONFIG_RING_BUFFER_STARTUP_TEST is not set +# CONFIG_PREEMPTIRQ_DELAY_TEST is not set +# CONFIG_KPROBE_EVENT_GEN_TEST is not set +# CONFIG_PROVIDE_OHCI1394_DMA_INIT is not set +# CONFIG_SAMPLES is not set +CONFIG_HAVE_ARCH_KCSAN=y +CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y +# CONFIG_STRICT_DEVMEM is not set + +# +# x86 Debugging +# +CONFIG_TRACE_IRQFLAGS_SUPPORT=y +CONFIG_TRACE_IRQFLAGS_NMI_SUPPORT=y +CONFIG_X86_VERBOSE_BOOTUP=y +CONFIG_EARLY_PRINTK=y +# CONFIG_EARLY_PRINTK_DBGP is not set +# CONFIG_EARLY_PRINTK_USB_XDBC is not set +# CONFIG_EFI_PGT_DUMP is not set +# CONFIG_DEBUG_TLBFLUSH is not set +# CONFIG_IOMMU_DEBUG is not set +CONFIG_HAVE_MMIOTRACE_SUPPORT=y +# CONFIG_X86_DECODER_SELFTEST is not set +CONFIG_IO_DELAY_0X80=y +# CONFIG_IO_DELAY_0XED is not set +# CONFIG_IO_DELAY_UDELAY is not set +# CONFIG_IO_DELAY_NONE is not set +# CONFIG_DEBUG_BOOT_PARAMS is not set +# CONFIG_CPA_DEBUG is not set +# CONFIG_DEBUG_ENTRY is not set +# CONFIG_DEBUG_NMI_SELFTEST is not set +CONFIG_X86_DEBUG_FPU=y +# CONFIG_PUNIT_ATOM_DEBUG is not set +CONFIG_UNWINDER_ORC=y +# CONFIG_UNWINDER_FRAME_POINTER is not set +# CONFIG_UNWINDER_GUESS is not set +# end of x86 Debugging + +# +# Kernel Testing and Coverage +# +# CONFIG_KUNIT is not set +# CONFIG_NOTIFIER_ERROR_INJECTION is not set +CONFIG_FUNCTION_ERROR_INJECTION=y +CONFIG_FAULT_INJECTION=y +# CONFIG_FAILSLAB is not set +# CONFIG_FAIL_PAGE_ALLOC is not set +# CONFIG_FAIL_MAKE_REQUEST is not set +# CONFIG_FAIL_IO_TIMEOUT is not set +# CONFIG_FAIL_FUTEX is not set +CONFIG_FAULT_INJECTION_DEBUG_FS=y +CONFIG_FAIL_FUNCTION=y +CONFIG_ARCH_HAS_KCOV=y +CONFIG_CC_HAS_SANCOV_TRACE_PC=y +# CONFIG_KCOV is not set +# CONFIG_RUNTIME_TESTING_MENU is not set +# CONFIG_MEMTEST is not set +# end of Kernel Testing and Coverage +# end of Kernel hacking diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/configs/whitelist/WHITELIST-4.9.0 dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/whitelist/WHITELIST-4.9.0 --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/configs/whitelist/WHITELIST-4.9.0 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/configs/whitelist/WHITELIST-4.9.0 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,7 @@ +btf_dump +core_retro +cpu_mask +hashmap +perf_buffer +section_names + diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/helpers.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/helpers.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/helpers.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/helpers.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,12 @@ +# $1 - start or end +# $2 - fold identifier, no spaces +# $3 - fold section description +travis_fold() { + local YELLOW='\033[1;33m' + local NOCOLOR='\033[0m' + echo travis_fold:$1:$2 + if [ ! -z "${3:-}" ]; then + echo -e "${YELLOW}$3${NOCOLOR}" + fi + echo +} diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/mkrootfs.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/mkrootfs.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/mkrootfs.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/mkrootfs.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,158 @@ +#!/bin/bash + +# This script is based on drgn script for generating Arch Linux bootstrap +# images. +# https://github.com/osandov/drgn/blob/master/scripts/vmtest/mkrootfs.sh + +set -euo pipefail + +usage () { + USAGE_STRING="usage: $0 [NAME] + $0 -h + +Build an Arch Linux root filesystem image for testing libbpf in a virtual +machine. + +The image is generated as a zstd-compressed tarball. + +This must be run as root, as most of the installation is done in a chroot. + +Arguments: + NAME name of generated image file (default: + libbpf-vmtest-rootfs-\$DATE.tar.zst) + +Options: + -h display this help message and exit" + + case "$1" in + out) + echo "$USAGE_STRING" + exit 0 + ;; + err) + echo "$USAGE_STRING" >&2 + exit 1 + ;; + esac +} + +while getopts "h" OPT; do + case "$OPT" in + h) + usage out + ;; + *) + usage err + ;; + esac +done +if [[ $OPTIND -eq $# ]]; then + NAME="${!OPTIND}" +elif [[ $OPTIND -gt $# ]]; then + NAME="libbpf-vmtest-rootfs-$(date +%Y.%m.%d).tar.zst" +else + usage err +fi + +pacman_conf= +root= +trap 'rm -rf "$pacman_conf" "$root"' EXIT +pacman_conf="$(mktemp -p "$PWD")" +cat > "$pacman_conf" << "EOF" +[options] +Architecture = x86_64 +CheckSpace +SigLevel = Required DatabaseOptional +[core] +Include = /etc/pacman.d/mirrorlist +[extra] +Include = /etc/pacman.d/mirrorlist +[community] +Include = /etc/pacman.d/mirrorlist +EOF +root="$(mktemp -d -p "$PWD")" + +packages=( + busybox + # libbpf dependencies. + libelf + zlib + # selftests test_progs dependencies. + binutils + elfutils + glibc + iproute2 + # selftests test_verifier dependencies. + libcap +) + +pacstrap -C "$pacman_conf" -cGM "$root" "${packages[@]}" + +# Remove unnecessary files from the chroot. + +# We don't need the pacman databases anymore. +rm -rf "$root/var/lib/pacman/sync/" +# We don't need D, Fortran, or Go. + rm -f "$root/usr/lib/libgdruntime."* \ + "$root/usr/lib/libgphobos."* \ + "$root/usr/lib/libgfortran."* \ + "$root/usr/lib/libgo."* +# We don't need any documentation. +rm -rf "$root/usr/share/{doc,help,man,texinfo}" + +chroot "${root}" /bin/busybox --install + +cat > "$root/etc/inittab" << "EOF" +::sysinit:/etc/init.d/rcS +::ctrlaltdel:/sbin/reboot +::shutdown:/sbin/swapoff -a +::shutdown:/bin/umount -a -r +::restart:/sbin/init +EOF +chmod 644 "$root/etc/inittab" + +mkdir -m 755 "$root/etc/init.d" "$root/etc/rcS.d" +cat > "$root/etc/rcS.d/S10-mount" << "EOF" +#!/bin/sh + +set -eux + +/bin/mount proc /proc -t proc + +# Mount devtmpfs if not mounted +if [[ -z $(/bin/mount -l -t devtmpfs) ]]; then + /bin/mount devtmpfs /dev -t devtmpfs +fi + +/bin/mount sysfs /sys -t sysfs +/bin/mount bpffs /sys/fs/bpf -t bpf +/bin/mount debugfs /sys/kernel/debug -t debugfs + +echo 'Listing currently mounted file systems' +/bin/mount +EOF +chmod 755 "$root/etc/rcS.d/S10-mount" + +cat > "$root/etc/rcS.d/S40-network" << "EOF" +#!/bin/sh + +set -eux + +ip link set lo up +EOF +chmod 755 "$root/etc/rcS.d/S40-network" + +cat > "$root/etc/init.d/rcS" << "EOF" +#!/bin/sh + +set -eux + +for path in /etc/rcS.d/S*; do + [ -x "$path" ] && "$path" +done +EOF +chmod 755 "$root/etc/init.d/rcS" + +chmod 755 "$root" +tar -C "$root" -c . | zstd -T0 -19 -o "$NAME" +chmod 644 "$NAME" diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/prepare_selftests-4.9.0.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/prepare_selftests-4.9.0.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/prepare_selftests-4.9.0.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/prepare_selftests-4.9.0.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,3 @@ +#!/bin/bash + +printf "all:\n\ttouch bpf_testmod.ko\n\nclean:\n" > bpf_testmod/Makefile diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/prepare_selftests-5.5.0.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/prepare_selftests-5.5.0.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/prepare_selftests-5.5.0.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/prepare_selftests-5.5.0.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,3 @@ +#!/bin/bash + +printf "all:\n\ttouch bpf_testmod.ko\n\nclean:\n" > bpf_testmod/Makefile diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/prepare_selftests.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/prepare_selftests.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/prepare_selftests.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/prepare_selftests.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,20 @@ +#!/bin/bash + +set -eu + +source $(cd $(dirname $0) && pwd)/helpers.sh + +REPO_PATH=$1 + +${VMTEST_ROOT}/checkout_latest_kernel.sh ${REPO_PATH} +cd ${REPO_PATH} + +if [[ "${KERNEL}" = 'LATEST' ]]; then + travis_fold start build_kernel "Kernel build" + + cp ${VMTEST_ROOT}/configs/latest.config .config + make -j $((4*$(nproc))) olddefconfig all + + travis_fold end build_kernel +fi + diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/run_selftests.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/run_selftests.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/run_selftests.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/run_selftests.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,51 @@ +#!/bin/bash + +set -euo pipefail + +source $(cd $(dirname $0) && pwd)/helpers.sh + +test_progs() { + if [[ "${KERNEL}" != '4.9.0' ]]; then + travis_fold start test_progs "Testing test_progs" + ./test_progs ${BLACKLIST:+-b$BLACKLIST} ${WHITELIST:+-t$WHITELIST} + travis_fold end test_progs + fi + + travis_fold start test_progs-no_alu32 "Testing test_progs-no_alu32" + ./test_progs-no_alu32 ${BLACKLIST:+-b$BLACKLIST} ${WHITELIST:+-t$WHITELIST} + travis_fold end test_progs-no_alu32 +} + +test_maps() { + travis_fold start test_maps "Testing test_maps" + ./test_maps + travis_fold end test_maps +} + +test_verifier() { + travis_fold start test_verifier "Testing test_verifier" + ./test_verifier + travis_fold end test_verifier +} + +travis_fold end vm_init + +configs_path='libbpf/travis-ci/vmtest/configs' +blacklist_path="$configs_path/blacklist/BLACKLIST-${KERNEL}" +if [[ -s "${blacklist_path}" ]]; then + BLACKLIST=$(cat "${blacklist_path}" | cut -d'#' -f1 | tr -s '[:space:]' ',') +fi + +whitelist_path="$configs_path/whitelist/WHITELIST-${KERNEL}" +if [[ -s "${whitelist_path}" ]]; then + WHITELIST=$(cat "${whitelist_path}" | cut -d'#' -f1 | tr -s '[:space:]' ',') +fi + +cd libbpf/selftests/bpf + +test_progs + +if [[ "${KERNEL}" == 'latest' ]]; then + #test_maps + test_verifier +fi diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/run.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/run.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/run.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/run.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,455 @@ +#!/bin/bash + +set -uo pipefail +trap 'exit 2' ERR + +source $(cd $(dirname $0) && pwd)/helpers.sh + +usage () { + USAGE_STRING="usage: $0 [-k KERNELRELEASE|-b DIR] [[-r ROOTFSVERSION] [-fo]|-I] [-Si] [-d DIR] IMG + $0 [-k KERNELRELEASE] -l + $0 -h + +Run "${PROJECT_NAME}" tests in a virtual machine. + +This exits with status 0 on success, 1 if the virtual machine ran successfully +but tests failed, and 2 if we encountered a fatal error. + +This script uses sudo to mount and modify the disk image. + +Arguments: + IMG path of virtual machine disk image to create + +Versions: + -k, --kernel=KERNELRELEASE + kernel release to test. This is a glob pattern; the + newest (sorted by version number) release that matches + the pattern is used (default: newest available release) + + -b, --build DIR use the kernel built in the given directory. This option + cannot be combined with -k + + -r, --rootfs=ROOTFSVERSION + version of root filesystem to use (default: newest + available version) + +Setup: + -f, --force overwrite IMG if it already exists + + -o, --one-shot one-shot mode. By default, this script saves a clean copy + of the downloaded root filesystem image and vmlinux and + makes a copy (reflinked, when possible) for executing the + virtual machine. This allows subsequent runs to skip + downloading these files. If this option is given, the + root filesystem image and vmlinux are always + re-downloaded and are not saved. This option implies -f + + -s, --setup-cmd setup commands run on VM boot. Whitespace characters + should be escaped with preceding '\'. + + -I, --skip-image skip creating the disk image; use the existing one at + IMG. This option cannot be combined with -r, -f, or -o + + -S, --skip-source skip copying the source files and init scripts + +Miscellaneous: + -i, --interactive interactive mode. Boot the virtual machine into an + interactive shell instead of automatically running tests + + -d, --dir=DIR working directory to use for downloading and caching + files (default: current working directory) + + -l, --list list available kernel releases instead of running tests. + The list may be filtered with -k + + -h, --help display this help message and exit" + + case "$1" in + out) + echo "$USAGE_STRING" + exit 0 + ;; + err) + echo "$USAGE_STRING" >&2 + exit 2 + ;; + esac +} + +TEMP=$(getopt -o 'k:b:r:fos:ISid:lh' --long 'kernel:,build:,rootfs:,force,one-shot,setup-cmd,skip-image,skip-source:,interactive,dir:,list,help' -n "$0" -- "$@") +eval set -- "$TEMP" +unset TEMP + +unset KERNELRELEASE +unset BUILDDIR +unset ROOTFSVERSION +unset IMG +unset SETUPCMD +FORCE=0 +ONESHOT=0 +SKIPIMG=0 +SKIPSOURCE=0 +APPEND="" +DIR="$PWD" +LIST=0 +while true; do + case "$1" in + -k|--kernel) + KERNELRELEASE="$2" + shift 2 + ;; + -b|--build) + BUILDDIR="$2" + shift 2 + ;; + -r|--rootfs) + ROOTFSVERSION="$2" + shift 2 + ;; + -f|--force) + FORCE=1 + shift + ;; + -o|--one-shot) + ONESHOT=1 + FORCE=1 + shift + ;; + -s|--setup-cmd) + SETUPCMD="$2" + shift 2 + ;; + -I|--skip-image) + SKIPIMG=1 + shift + ;; + -S|--skip-source) + SKIPSOURCE=1 + shift + ;; + -i|--interactive) + APPEND=" single" + shift + ;; + -d|--dir) + DIR="$2" + shift 2 + ;; + -l|--list) + LIST=1 + ;; + -h|--help) + usage out + ;; + --) + shift + break + ;; + *) + usage err + ;; + esac +done +if [[ -v BUILDDIR ]]; then + if [[ -v KERNELRELEASE ]]; then + usage err + fi +elif [[ ! -v KERNELRELEASE ]]; then + KERNELRELEASE='*' +fi +if [[ $SKIPIMG -ne 0 && ( -v ROOTFSVERSION || $FORCE -ne 0 ) ]]; then + usage err +fi +if (( LIST )); then + if [[ $# -ne 0 || -v BUILDDIR || -v ROOTFSVERSION || $FORCE -ne 0 || + $SKIPIMG -ne 0 || $SKIPSOURCE -ne 0 || -n $APPEND ]]; then + usage err + fi +else + if [[ $# -ne 1 ]]; then + usage err + fi + IMG="${!OPTIND}" +fi + +unset URLS +cache_urls() { + if ! declare -p URLS &> /dev/null; then + # This URL contains a mapping from file names to URLs where + # those files can be downloaded. + declare -gA URLS + while IFS=$'\t' read -r name url; do + URLS["$name"]="$url" + done < <(cat "${VMTEST_ROOT}/configs/INDEX") + fi +} + +matching_kernel_releases() { + local pattern="$1" + { + for file in "${!URLS[@]}"; do + if [[ $file =~ ^vmlinux-(.*).zst$ ]]; then + release="${BASH_REMATCH[1]}" + case "$release" in + $pattern) + # sort -V handles rc versions properly + # if we use "~" instead of "-". + echo "${release//-rc/~rc}" + ;; + esac + fi + done + } | sort -rV | sed 's/~rc/-rc/g' +} + +newest_rootfs_version() { + { + for file in "${!URLS[@]}"; do + if [[ $file =~ ^${PROJECT_NAME}-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then + echo "${BASH_REMATCH[1]}" + fi + done + } | sort -rV | head -1 +} + +download() { + local file="$1" + cache_urls + if [[ ! -v URLS[$file] ]]; then + echo "$file not found" >&2 + return 1 + fi + echo "Downloading $file..." >&2 + curl -Lf "${URLS[$file]}" "${@:2}" +} + +set_nocow() { + touch "$@" + chattr +C "$@" >/dev/null 2>&1 || true +} + +cp_img() { + set_nocow "$2" + cp --reflink=auto "$1" "$2" +} + +create_rootfs_img() { + local path="$1" + set_nocow "$path" + truncate -s 2G "$path" + mkfs.ext4 -q "$path" +} + +download_rootfs() { + local rootfsversion="$1" + local dir="$2" + download "${PROJECT_NAME}-vmtest-rootfs-$rootfsversion.tar.zst" | + zstd -d | sudo tar -C "$dir" -x +} + +if (( LIST )); then + cache_urls + matching_kernel_releases "$KERNELRELEASE" + exit 0 +fi + +if [[ $FORCE -eq 0 && $SKIPIMG -eq 0 && -e $IMG ]]; then + echo "$IMG already exists; use -f to overwrite it or -I to reuse it" >&2 + exit 1 +fi + +# Only go to the network if it's actually a glob pattern. +if [[ -v BUILDDIR ]]; then + KERNELRELEASE="$(make -C "$BUILDDIR" -s kernelrelease)" +elif [[ ! $KERNELRELEASE =~ ^([^\\*?[]|\\[*?[])*\\?$ ]]; then + # We need to cache the list of URLs outside of the command + # substitution, which happens in a subshell. + cache_urls + KERNELRELEASE="$(matching_kernel_releases "$KERNELRELEASE" | head -1)" + if [[ -z $KERNELRELEASE ]]; then + echo "No matching kernel release found" >&2 + exit 1 + fi +fi +if [[ $SKIPIMG -eq 0 && ! -v ROOTFSVERSION ]]; then + cache_urls + ROOTFSVERSION="$(newest_rootfs_version)" +fi + +echo "Kernel release: $KERNELRELEASE" >&2 +echo + +travis_fold start vmlinux_setup "Preparing Linux image" + +if (( SKIPIMG )); then + echo "Not extracting root filesystem" >&2 +else + echo "Root filesystem version: $ROOTFSVERSION" >&2 +fi +echo "Disk image: $IMG" >&2 + +tmp= +ARCH_DIR="$DIR/x86_64" +mkdir -p "$ARCH_DIR" +mnt="$(mktemp -d -p "$DIR" mnt.XXXXXXXXXX)" + +cleanup() { + if [[ -n $tmp ]]; then + rm -f "$tmp" || true + fi + if mountpoint -q "$mnt"; then + sudo umount "$mnt" || true + fi + if [[ -d "$mnt" ]]; then + rmdir "$mnt" || true + fi +} +trap cleanup EXIT + +if [[ -v BUILDDIR ]]; then + vmlinuz="$BUILDDIR/$(make -C "$BUILDDIR" -s image_name)" +else + vmlinuz="${ARCH_DIR}/vmlinuz-${KERNELRELEASE}" + if [[ ! -e $vmlinuz ]]; then + tmp="$(mktemp "$vmlinuz.XXX.part")" + download "vmlinuz-${KERNELRELEASE}" -o "$tmp" + mv "$tmp" "$vmlinuz" + tmp= + fi +fi + +# Mount and set up the rootfs image. +if (( ONESHOT )); then + rm -f "$IMG" + create_rootfs_img "$IMG" + sudo mount -o loop "$IMG" "$mnt" + download_rootfs "$ROOTFSVERSION" "$mnt" +else + if (( ! SKIPIMG )); then + rootfs_img="${ARCH_DIR}/${PROJECT_NAME}-vmtest-rootfs-${ROOTFSVERSION}.img" + + if [[ ! -e $rootfs_img ]]; then + tmp="$(mktemp "$rootfs_img.XXX.part")" + set_nocow "$tmp" + truncate -s 2G "$tmp" + mkfs.ext4 -q "$tmp" + sudo mount -o loop "$tmp" "$mnt" + + download_rootfs "$ROOTFSVERSION" "$mnt" + + sudo umount "$mnt" + mv "$tmp" "$rootfs_img" + tmp= + fi + + rm -f "$IMG" + cp_img "$rootfs_img" "$IMG" + fi + sudo mount -o loop "$IMG" "$mnt" +fi + +# Install vmlinux. +vmlinux="$mnt/boot/vmlinux-${KERNELRELEASE}" +if [[ -v BUILDDIR || $ONESHOT -eq 0 ]]; then + if [[ -v BUILDDIR ]]; then + source_vmlinux="${BUILDDIR}/vmlinux" + else + source_vmlinux="${ARCH_DIR}/vmlinux-${KERNELRELEASE}" + if [[ ! -e $source_vmlinux ]]; then + tmp="$(mktemp "$source_vmlinux.XXX.part")" + download "vmlinux-${KERNELRELEASE}.zst" | zstd -dfo "$tmp" + mv "$tmp" "$source_vmlinux" + tmp= + fi + fi + echo "Copying vmlinux..." >&2 + sudo rsync -cp --chmod 0644 "$source_vmlinux" "$vmlinux" +else + # We could use "sudo zstd -o", but let's not run zstd as root with + # input from the internet. + download "vmlinux-${KERNELRELEASE}.zst" | + zstd -d | sudo tee "$vmlinux" > /dev/null + sudo chmod 644 "$vmlinux" +fi + +travis_fold end vmlinux_setup + +LIBBPF_PATH="${REPO_ROOT}" \ + REPO_PATH="travis-ci/vmtest/bpf-next" \ + VMTEST_ROOT="${VMTEST_ROOT}" \ + VMLINUX_BTF=${vmlinux} ${VMTEST_ROOT}/build_selftests.sh + +travis_fold start vm_init "Starting virtual machine..." + +if (( SKIPSOURCE )); then + echo "Not copying source files..." >&2 +else + echo "Copying source files..." >&2 + + # Copy the source files in. + sudo mkdir -p -m 0755 "$mnt/${PROJECT_NAME}" + { + if [[ -e .git ]]; then + git ls-files -z + else + tr '\n' '\0' < "${PROJECT_NAME}.egg-info/SOURCES.txt" + fi + } | sudo rsync --files-from=- -0cpt . "$mnt/${PROJECT_NAME}" +fi + +setup_script="#!/bin/sh + +echo 'Skipping setup commands' +echo 0 > /exitstatus +chmod 644 /exitstatus" + +# Create the init scripts. +if [[ ! -z SETUPCMD ]]; then + # Unescape whitespace characters. + setup_cmd=$(sed 's/\(\\\)\([[:space:]]\)/\2/g' <<< "${SETUPCMD}") + kernel="${KERNELRELEASE}" + if [[ -v BUILDDIR ]]; then kernel='latest'; fi + setup_envvars="export KERNEL=${kernel}" + setup_script=$(printf "#!/bin/sh +set -eux + +echo 'Running setup commands' +%s +%s +echo $? > /exitstatus +chmod 644 /exitstatus" "${setup_envvars}" "${setup_cmd}") +fi + +echo "${setup_script}" | sudo tee "$mnt/etc/rcS.d/S50-run-tests" > /dev/null +sudo chmod 755 "$mnt/etc/rcS.d/S50-run-tests" + +poweroff_script="#!/bin/sh + +echo travis_fold:start:shutdown +echo -e '\033[1;33mShutdown\033[0m\n' + +poweroff" +echo "${poweroff_script}" | sudo tee "$mnt/etc/rcS.d/S99-poweroff" > /dev/null +sudo chmod 755 "$mnt/etc/rcS.d/S99-poweroff" + +sudo umount "$mnt" + +echo "Starting VM with $(nproc) CPUs..." + +qemu-system-x86_64 -nodefaults -display none -serial mon:stdio \ + -cpu kvm64 -enable-kvm -smp "$(nproc)" -m 4G \ + -drive file="$IMG",format=raw,index=1,media=disk,if=virtio,cache=none \ + -kernel "$vmlinuz" -append "root=/dev/vda rw console=ttyS0,115200$APPEND" + +sudo mount -o loop "$IMG" "$mnt" +if exitstatus="$(cat "$mnt/exitstatus" 2>/dev/null)"; then + printf '\nTests exit status: %s\n' "$exitstatus" >&2 +else + printf '\nCould not read tests exit status\n' >&2 + exitstatus=1 +fi +sudo umount "$mnt" + +travis_fold end shutdown + +exit "$exitstatus" diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/run_vmtest.sh dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/run_vmtest.sh --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/run_vmtest.sh 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/run_vmtest.sh 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,36 @@ +#!/bin/bash + +set -eu + +source $(cd $(dirname $0) && pwd)/helpers.sh + +VMTEST_SETUPCMD="PROJECT_NAME=${PROJECT_NAME} ./${PROJECT_NAME}/travis-ci/vmtest/run_selftests.sh" + +echo "KERNEL: $KERNEL" +echo + +# Build latest pahole +${VMTEST_ROOT}/build_pahole.sh travis-ci/vmtest/pahole + +travis_fold start install_clang "Installing Clang/LLVM" + +wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - +sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" +sudo apt-get update +sudo apt-get install -y clang-13 lld-13 llvm-13 + +travis_fold end install_clang + +# Build selftests (and latest kernel, if necessary) +KERNEL="${KERNEL}" ${VMTEST_ROOT}/prepare_selftests.sh travis-ci/vmtest/bpf-next + +# Escape whitespace characters. +setup_cmd=$(sed 's/\([[:space:]]\)/\\\1/g' <<< "${VMTEST_SETUPCMD}") + +sudo adduser "${USER}" kvm + +if [[ "${KERNEL}" = 'LATEST' ]]; then + sudo -E sudo -E -u "${USER}" "${VMTEST_ROOT}/run.sh" -b travis-ci/vmtest/bpf-next -o -d ~ -s "${setup_cmd}" ~/root.img; +else + sudo -E sudo -E -u "${USER}" "${VMTEST_ROOT}/run.sh" -k "${KERNEL}*" -o -d ~ -s "${setup_cmd}" ~/root.img; +fi diff -Nru dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/vmlinux.h dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/vmlinux.h --- dwarves-dfsg-1.10/lib/bpf/travis-ci/vmtest/vmlinux.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/travis-ci/vmtest/vmlinux.h 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,138018 @@ +#ifndef __VMLINUX_H__ +#define __VMLINUX_H__ + +#ifndef BPF_NO_PRESERVE_ACCESS_INDEX +#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record) +#endif + +typedef unsigned char __u8; + +typedef short unsigned int __u16; + +typedef int __s32; + +typedef unsigned int __u32; + +typedef long long int __s64; + +typedef long long unsigned int __u64; + +typedef __u8 u8; + +typedef __u16 u16; + +typedef __s32 s32; + +typedef __u32 u32; + +typedef __s64 s64; + +typedef __u64 u64; + +enum { + false = 0, + true = 1, +}; + +typedef long int __kernel_long_t; + +typedef long unsigned int __kernel_ulong_t; + +typedef int __kernel_pid_t; + +typedef unsigned int __kernel_uid32_t; + +typedef unsigned int __kernel_gid32_t; + +typedef __kernel_ulong_t __kernel_size_t; + +typedef __kernel_long_t __kernel_ssize_t; + +typedef long long int __kernel_loff_t; + +typedef long long int __kernel_time64_t; + +typedef __kernel_long_t __kernel_clock_t; + +typedef int __kernel_timer_t; + +typedef int __kernel_clockid_t; + +typedef unsigned int __poll_t; + +typedef u32 __kernel_dev_t; + +typedef __kernel_dev_t dev_t; + +typedef short unsigned int umode_t; + +typedef __kernel_pid_t pid_t; + +typedef __kernel_clockid_t clockid_t; + +typedef _Bool bool; + +typedef __kernel_uid32_t uid_t; + +typedef __kernel_gid32_t gid_t; + +typedef __kernel_loff_t loff_t; + +typedef __kernel_size_t size_t; + +typedef __kernel_ssize_t ssize_t; + +typedef s32 int32_t; + +typedef u32 uint32_t; + +typedef u64 sector_t; + +typedef u64 blkcnt_t; + +typedef u64 dma_addr_t; + +typedef unsigned int gfp_t; + +typedef unsigned int fmode_t; + +typedef u64 phys_addr_t; + +typedef struct { + int counter; +} atomic_t; + +typedef struct { + s64 counter; +} atomic64_t; + +struct list_head { + struct list_head *next; + struct list_head *prev; +}; + +struct hlist_node; + +struct hlist_head { + struct hlist_node *first; +}; + +struct hlist_node { + struct hlist_node *next; + struct hlist_node **pprev; +}; + +struct callback_head { + struct callback_head *next; + void (*func)(struct callback_head *); +}; + +struct lock_class_key {}; + +struct fs_context; + +struct fs_parameter_spec; + +struct dentry; + +struct super_block; + +struct module; + +struct file_system_type { + const char *name; + int fs_flags; + int (*init_fs_context)(struct fs_context *); + const struct fs_parameter_spec *parameters; + struct dentry * (*mount)(struct file_system_type *, int, const char *, void *); + void (*kill_sb)(struct super_block *); + struct module *owner; + struct file_system_type *next; + struct hlist_head fs_supers; + struct lock_class_key s_lock_key; + struct lock_class_key s_umount_key; + struct lock_class_key s_vfs_rename_key; + struct lock_class_key s_writers_key[3]; + struct lock_class_key i_lock_key; + struct lock_class_key i_mutex_key; + struct lock_class_key i_mutex_dir_key; +}; + +struct qspinlock { + union { + atomic_t val; + struct { + u8 locked; + u8 pending; + }; + struct { + u16 locked_pending; + u16 tail; + }; + }; +}; + +typedef struct qspinlock arch_spinlock_t; + +struct qrwlock { + union { + atomic_t cnts; + struct { + u8 wlocked; + u8 __lstate[3]; + }; + }; + arch_spinlock_t wait_lock; +}; + +typedef struct qrwlock arch_rwlock_t; + +struct raw_spinlock { + arch_spinlock_t raw_lock; + unsigned int magic; + unsigned int owner_cpu; + void *owner; +}; + +typedef struct raw_spinlock raw_spinlock_t; + +struct spinlock { + union { + struct raw_spinlock rlock; + }; +}; + +typedef struct spinlock spinlock_t; + +typedef struct { + arch_rwlock_t raw_lock; + unsigned int magic; + unsigned int owner_cpu; + void *owner; +} rwlock_t; + +struct ratelimit_state { + raw_spinlock_t lock; + int interval; + int burst; + int printed; + int missed; + long unsigned int begin; + long unsigned int flags; +}; + +typedef void *fl_owner_t; + +struct file; + +struct kiocb; + +struct iov_iter; + +struct dir_context; + +struct poll_table_struct; + +struct vm_area_struct; + +struct inode; + +struct file_lock; + +struct page; + +struct pipe_inode_info; + +struct seq_file; + +struct file_operations { + struct module *owner; + loff_t (*llseek)(struct file *, loff_t, int); + ssize_t (*read)(struct file *, char *, size_t, loff_t *); + ssize_t (*write)(struct file *, const char *, size_t, loff_t *); + ssize_t (*read_iter)(struct kiocb *, struct iov_iter *); + ssize_t (*write_iter)(struct kiocb *, struct iov_iter *); + int (*iopoll)(struct kiocb *, bool); + int (*iterate)(struct file *, struct dir_context *); + int (*iterate_shared)(struct file *, struct dir_context *); + __poll_t (*poll)(struct file *, struct poll_table_struct *); + long int (*unlocked_ioctl)(struct file *, unsigned int, long unsigned int); + long int (*compat_ioctl)(struct file *, unsigned int, long unsigned int); + int (*mmap)(struct file *, struct vm_area_struct *); + long unsigned int mmap_supported_flags; + int (*open)(struct inode *, struct file *); + int (*flush)(struct file *, fl_owner_t); + int (*release)(struct inode *, struct file *); + int (*fsync)(struct file *, loff_t, loff_t, int); + int (*fasync)(int, struct file *, int); + int (*lock)(struct file *, int, struct file_lock *); + ssize_t (*sendpage)(struct file *, struct page *, int, size_t, loff_t *, int); + long unsigned int (*get_unmapped_area)(struct file *, long unsigned int, long unsigned int, long unsigned int, long unsigned int); + int (*check_flags)(int); + int (*flock)(struct file *, int, struct file_lock *); + ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); + ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); + int (*setlease)(struct file *, long int, struct file_lock **, void **); + long int (*fallocate)(struct file *, int, loff_t, loff_t); + void (*show_fdinfo)(struct seq_file *, struct file *); + ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, loff_t, size_t, unsigned int); + loff_t (*remap_file_range)(struct file *, loff_t, struct file *, loff_t, loff_t, unsigned int); + int (*fadvise)(struct file *, loff_t, loff_t, int); +}; + +typedef __s64 time64_t; + +struct __kernel_timespec { + __kernel_time64_t tv_sec; + long long int tv_nsec; +}; + +struct timespec64 { + time64_t tv_sec; + long int tv_nsec; +}; + +enum timespec_type { + TT_NONE = 0, + TT_NATIVE = 1, + TT_COMPAT = 2, +}; + +typedef s32 old_time32_t; + +struct old_timespec32 { + old_time32_t tv_sec; + s32 tv_nsec; +}; + +struct pollfd; + +struct restart_block { + long int (*fn)(struct restart_block *); + union { + struct { + u32 *uaddr; + u32 val; + u32 flags; + u32 bitset; + u64 time; + u32 *uaddr2; + } futex; + struct { + clockid_t clockid; + enum timespec_type type; + union { + struct __kernel_timespec *rmtp; + struct old_timespec32 *compat_rmtp; + }; + u64 expires; + } nanosleep; + struct { + struct pollfd *ufds; + int nfds; + int has_timeout; + long unsigned int tv_sec; + long unsigned int tv_nsec; + } poll; + }; +}; + +struct thread_info { + long unsigned int flags; + u32 status; +}; + +struct refcount_struct { + atomic_t refs; +}; + +typedef struct refcount_struct refcount_t; + +struct llist_node { + struct llist_node *next; +}; + +struct __call_single_node { + struct llist_node llist; + union { + unsigned int u_flags; + atomic_t a_flags; + }; + u16 src; + u16 dst; +}; + +struct load_weight { + long unsigned int weight; + u32 inv_weight; +}; + +struct rb_node { + long unsigned int __rb_parent_color; + struct rb_node *rb_right; + struct rb_node *rb_left; +}; + +struct sched_statistics { + u64 wait_start; + u64 wait_max; + u64 wait_count; + u64 wait_sum; + u64 iowait_count; + u64 iowait_sum; + u64 sleep_start; + u64 sleep_max; + s64 sum_sleep_runtime; + u64 block_start; + u64 block_max; + u64 exec_max; + u64 slice_max; + u64 nr_migrations_cold; + u64 nr_failed_migrations_affine; + u64 nr_failed_migrations_running; + u64 nr_failed_migrations_hot; + u64 nr_forced_migrations; + u64 nr_wakeups; + u64 nr_wakeups_sync; + u64 nr_wakeups_migrate; + u64 nr_wakeups_local; + u64 nr_wakeups_remote; + u64 nr_wakeups_affine; + u64 nr_wakeups_affine_attempts; + u64 nr_wakeups_passive; + u64 nr_wakeups_idle; +}; + +struct util_est { + unsigned int enqueued; + unsigned int ewma; +}; + +struct sched_avg { + u64 last_update_time; + u64 load_sum; + u64 runnable_sum; + u32 util_sum; + u32 period_contrib; + long unsigned int load_avg; + long unsigned int runnable_avg; + long unsigned int util_avg; + struct util_est util_est; +}; + +struct cfs_rq; + +struct sched_entity { + struct load_weight load; + struct rb_node run_node; + struct list_head group_node; + unsigned int on_rq; + u64 exec_start; + u64 sum_exec_runtime; + u64 vruntime; + u64 prev_sum_exec_runtime; + u64 nr_migrations; + struct sched_statistics statistics; + int depth; + struct sched_entity *parent; + struct cfs_rq *cfs_rq; + struct cfs_rq *my_q; + long unsigned int runnable_weight; + long: 64; + long: 64; + long: 64; + struct sched_avg avg; +}; + +struct sched_rt_entity { + struct list_head run_list; + long unsigned int timeout; + long unsigned int watchdog_stamp; + unsigned int time_slice; + short unsigned int on_rq; + short unsigned int on_list; + struct sched_rt_entity *back; +}; + +typedef s64 ktime_t; + +struct timerqueue_node { + struct rb_node node; + ktime_t expires; +}; + +enum hrtimer_restart { + HRTIMER_NORESTART = 0, + HRTIMER_RESTART = 1, +}; + +struct hrtimer_clock_base; + +struct hrtimer { + struct timerqueue_node node; + ktime_t _softexpires; + enum hrtimer_restart (*function)(struct hrtimer *); + struct hrtimer_clock_base *base; + u8 state; + u8 is_rel; + u8 is_soft; + u8 is_hard; +}; + +struct sched_dl_entity { + struct rb_node rb_node; + u64 dl_runtime; + u64 dl_deadline; + u64 dl_period; + u64 dl_bw; + u64 dl_density; + s64 runtime; + u64 deadline; + unsigned int flags; + unsigned int dl_throttled: 1; + unsigned int dl_boosted: 1; + unsigned int dl_yielded: 1; + unsigned int dl_non_contending: 1; + unsigned int dl_overrun: 1; + struct hrtimer dl_timer; + struct hrtimer inactive_timer; +}; + +struct cpumask { + long unsigned int bits[2]; +}; + +typedef struct cpumask cpumask_t; + +union rcu_special { + struct { + u8 blocked; + u8 need_qs; + u8 exp_hint; + u8 need_mb; + } b; + u32 s; +}; + +struct sched_info { + long unsigned int pcount; + long long unsigned int run_delay; + long long unsigned int last_arrival; + long long unsigned int last_queued; +}; + +struct plist_node { + int prio; + struct list_head prio_list; + struct list_head node_list; +}; + +struct vmacache { + u64 seqnum; + struct vm_area_struct *vmas[4]; +}; + +struct task_rss_stat { + int events; + int count[4]; +}; + +struct prev_cputime { + u64 utime; + u64 stime; + raw_spinlock_t lock; +}; + +struct rb_root { + struct rb_node *rb_node; +}; + +struct rb_root_cached { + struct rb_root rb_root; + struct rb_node *rb_leftmost; +}; + +struct timerqueue_head { + struct rb_root_cached rb_root; +}; + +struct posix_cputimer_base { + u64 nextevt; + struct timerqueue_head tqhead; +}; + +struct posix_cputimers { + struct posix_cputimer_base bases[3]; + unsigned int timers_active; + unsigned int expiry_active; +}; + +struct posix_cputimers_work { + struct callback_head work; + unsigned int scheduled; +}; + +struct sem_undo_list; + +struct sysv_sem { + struct sem_undo_list *undo_list; +}; + +struct sysv_shm { + struct list_head shm_clist; +}; + +typedef struct { + long unsigned int sig[1]; +} sigset_t; + +struct sigpending { + struct list_head list; + sigset_t signal; +}; + +typedef struct { + uid_t val; +} kuid_t; + +struct seccomp_filter; + +struct seccomp { + int mode; + atomic_t filter_count; + struct seccomp_filter *filter; +}; + +struct wake_q_node { + struct wake_q_node *next; +}; + +struct task_io_accounting { + u64 rchar; + u64 wchar; + u64 syscr; + u64 syscw; + u64 read_bytes; + u64 write_bytes; + u64 cancelled_write_bytes; +}; + +typedef struct { + long unsigned int bits[1]; +} nodemask_t; + +struct seqcount { + unsigned int sequence; +}; + +typedef struct seqcount seqcount_t; + +struct seqcount_spinlock { + seqcount_t seqcount; +}; + +typedef struct seqcount_spinlock seqcount_spinlock_t; + +typedef atomic64_t atomic_long_t; + +struct optimistic_spin_queue { + atomic_t tail; +}; + +struct mutex { + atomic_long_t owner; + spinlock_t wait_lock; + struct optimistic_spin_queue osq; + struct list_head wait_list; + void *magic; +}; + +struct arch_tlbflush_unmap_batch { + struct cpumask cpumask; +}; + +struct tlbflush_unmap_batch { + struct arch_tlbflush_unmap_batch arch; + bool flush_required; + bool writable; +}; + +struct page_frag { + struct page *page; + __u32 offset; + __u32 size; +}; + +struct desc_struct { + u16 limit0; + u16 base0; + u16 base1: 8; + u16 type: 4; + u16 s: 1; + u16 dpl: 2; + u16 p: 1; + u16 limit1: 4; + u16 avl: 1; + u16 l: 1; + u16 d: 1; + u16 g: 1; + u16 base2: 8; +}; + +struct fregs_state { + u32 cwd; + u32 swd; + u32 twd; + u32 fip; + u32 fcs; + u32 foo; + u32 fos; + u32 st_space[20]; + u32 status; +}; + +struct fxregs_state { + u16 cwd; + u16 swd; + u16 twd; + u16 fop; + union { + struct { + u64 rip; + u64 rdp; + }; + struct { + u32 fip; + u32 fcs; + u32 foo; + u32 fos; + }; + }; + u32 mxcsr; + u32 mxcsr_mask; + u32 st_space[32]; + u32 xmm_space[64]; + u32 padding[12]; + union { + u32 padding1[12]; + u32 sw_reserved[12]; + }; +}; + +struct math_emu_info; + +struct swregs_state { + u32 cwd; + u32 swd; + u32 twd; + u32 fip; + u32 fcs; + u32 foo; + u32 fos; + u32 st_space[20]; + u8 ftop; + u8 changed; + u8 lookahead; + u8 no_update; + u8 rm; + u8 alimit; + struct math_emu_info *info; + u32 entry_eip; +}; + +struct xstate_header { + u64 xfeatures; + u64 xcomp_bv; + u64 reserved[6]; +}; + +struct xregs_state { + struct fxregs_state i387; + struct xstate_header header; + u8 extended_state_area[0]; +}; + +union fpregs_state { + struct fregs_state fsave; + struct fxregs_state fxsave; + struct swregs_state soft; + struct xregs_state xsave; + u8 __padding[4096]; +}; + +struct fpu { + unsigned int last_cpu; + long unsigned int avx512_timestamp; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + union fpregs_state state; +}; + +struct perf_event; + +struct io_bitmap; + +struct thread_struct { + struct desc_struct tls_array[3]; + long unsigned int sp; + short unsigned int es; + short unsigned int ds; + short unsigned int fsindex; + short unsigned int gsindex; + long unsigned int fsbase; + long unsigned int gsbase; + struct perf_event *ptrace_bps[4]; + long unsigned int virtual_dr6; + long unsigned int ptrace_dr7; + long unsigned int cr2; + long unsigned int trap_nr; + long unsigned int error_code; + struct io_bitmap *io_bitmap; + long unsigned int iopl_emul; + unsigned int sig_on_uaccess_err: 1; + long: 63; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct fpu fpu; +}; + +struct sched_class; + +struct task_group; + +struct mm_struct; + +struct pid; + +struct completion; + +struct cred; + +struct key; + +struct nameidata; + +struct fs_struct; + +struct files_struct; + +struct io_uring_task; + +struct nsproxy; + +struct signal_struct; + +struct sighand_struct; + +struct audit_context; + +struct rt_mutex_waiter; + +struct mutex_waiter; + +struct bio_list; + +struct blk_plug; + +struct reclaim_state; + +struct backing_dev_info; + +struct io_context; + +struct capture_control; + +struct kernel_siginfo; + +typedef struct kernel_siginfo kernel_siginfo_t; + +struct css_set; + +struct robust_list_head; + +struct compat_robust_list_head; + +struct futex_pi_state; + +struct perf_event_context; + +struct mempolicy; + +struct numa_group; + +struct rseq; + +struct task_delay_info; + +struct ftrace_ret_stack; + +struct mem_cgroup; + +struct request_queue; + +struct uprobe_task; + +struct vm_struct; + +struct task_struct { + struct thread_info thread_info; + volatile long int state; + void *stack; + refcount_t usage; + unsigned int flags; + unsigned int ptrace; + int on_cpu; + struct __call_single_node wake_entry; + unsigned int cpu; + unsigned int wakee_flips; + long unsigned int wakee_flip_decay_ts; + struct task_struct *last_wakee; + int recent_used_cpu; + int wake_cpu; + int on_rq; + int prio; + int static_prio; + int normal_prio; + unsigned int rt_priority; + const struct sched_class *sched_class; + struct sched_entity se; + struct sched_rt_entity rt; + struct task_group *sched_task_group; + struct sched_dl_entity dl; + struct hlist_head preempt_notifiers; + unsigned int btrace_seq; + unsigned int policy; + int nr_cpus_allowed; + const cpumask_t *cpus_ptr; + cpumask_t cpus_mask; + int trc_reader_nesting; + int trc_ipi_to_cpu; + union rcu_special trc_reader_special; + bool trc_reader_checked; + struct list_head trc_holdout_list; + struct sched_info sched_info; + struct list_head tasks; + struct plist_node pushable_tasks; + struct rb_node pushable_dl_tasks; + struct mm_struct *mm; + struct mm_struct *active_mm; + struct vmacache vmacache; + struct task_rss_stat rss_stat; + int exit_state; + int exit_code; + int exit_signal; + int pdeath_signal; + long unsigned int jobctl; + unsigned int personality; + unsigned int sched_reset_on_fork: 1; + unsigned int sched_contributes_to_load: 1; + unsigned int sched_migrated: 1; + unsigned int sched_remote_wakeup: 1; + unsigned int sched_psi_wake_requeue: 1; + int: 27; + unsigned int in_execve: 1; + unsigned int in_iowait: 1; + unsigned int restore_sigmask: 1; + unsigned int in_user_fault: 1; + unsigned int brk_randomized: 1; + unsigned int no_cgroup_migration: 1; + unsigned int frozen: 1; + unsigned int use_memdelay: 1; + unsigned int in_memstall: 1; + long unsigned int atomic_flags; + struct restart_block restart_block; + pid_t pid; + pid_t tgid; + struct task_struct *real_parent; + struct task_struct *parent; + struct list_head children; + struct list_head sibling; + struct task_struct *group_leader; + struct list_head ptraced; + struct list_head ptrace_entry; + struct pid *thread_pid; + struct hlist_node pid_links[4]; + struct list_head thread_group; + struct list_head thread_node; + struct completion *vfork_done; + int *set_child_tid; + int *clear_child_tid; + u64 utime; + u64 stime; + u64 gtime; + struct prev_cputime prev_cputime; + long unsigned int nvcsw; + long unsigned int nivcsw; + u64 start_time; + u64 start_boottime; + long unsigned int min_flt; + long unsigned int maj_flt; + struct posix_cputimers posix_cputimers; + struct posix_cputimers_work posix_cputimers_work; + const struct cred *ptracer_cred; + const struct cred *real_cred; + const struct cred *cred; + struct key *cached_requested_key; + char comm[16]; + struct nameidata *nameidata; + struct sysv_sem sysvsem; + struct sysv_shm sysvshm; + long unsigned int last_switch_count; + long unsigned int last_switch_time; + struct fs_struct *fs; + struct files_struct *files; + struct io_uring_task *io_uring; + struct nsproxy *nsproxy; + struct signal_struct *signal; + struct sighand_struct *sighand; + sigset_t blocked; + sigset_t real_blocked; + sigset_t saved_sigmask; + struct sigpending pending; + long unsigned int sas_ss_sp; + size_t sas_ss_size; + unsigned int sas_ss_flags; + struct callback_head *task_works; + struct audit_context *audit_context; + kuid_t loginuid; + unsigned int sessionid; + struct seccomp seccomp; + u64 parent_exec_id; + u64 self_exec_id; + spinlock_t alloc_lock; + raw_spinlock_t pi_lock; + struct wake_q_node wake_q; + struct rb_root_cached pi_waiters; + struct task_struct *pi_top_task; + struct rt_mutex_waiter *pi_blocked_on; + struct mutex_waiter *blocked_on; + int non_block_count; + void *journal_info; + struct bio_list *bio_list; + struct blk_plug *plug; + struct reclaim_state *reclaim_state; + struct backing_dev_info *backing_dev_info; + struct io_context *io_context; + struct capture_control *capture_control; + long unsigned int ptrace_message; + kernel_siginfo_t *last_siginfo; + struct task_io_accounting ioac; + unsigned int psi_flags; + u64 acct_rss_mem1; + u64 acct_vm_mem1; + u64 acct_timexpd; + nodemask_t mems_allowed; + seqcount_spinlock_t mems_allowed_seq; + int cpuset_mem_spread_rotor; + int cpuset_slab_spread_rotor; + struct css_set *cgroups; + struct list_head cg_list; + struct robust_list_head *robust_list; + struct compat_robust_list_head *compat_robust_list; + struct list_head pi_state_list; + struct futex_pi_state *pi_state_cache; + struct mutex futex_exit_mutex; + unsigned int futex_state; + struct perf_event_context *perf_event_ctxp[2]; + struct mutex perf_event_mutex; + struct list_head perf_event_list; + struct mempolicy *mempolicy; + short int il_prev; + short int pref_node_fork; + int numa_scan_seq; + unsigned int numa_scan_period; + unsigned int numa_scan_period_max; + int numa_preferred_nid; + long unsigned int numa_migrate_retry; + u64 node_stamp; + u64 last_task_numa_placement; + u64 last_sum_exec_runtime; + struct callback_head numa_work; + struct numa_group *numa_group; + long unsigned int *numa_faults; + long unsigned int total_numa_faults; + long unsigned int numa_faults_locality[3]; + long unsigned int numa_pages_migrated; + struct rseq *rseq; + u32 rseq_sig; + long unsigned int rseq_event_mask; + struct tlbflush_unmap_batch tlb_ubc; + union { + refcount_t rcu_users; + struct callback_head rcu; + }; + struct pipe_inode_info *splice_pipe; + struct page_frag task_frag; + struct task_delay_info *delays; + int make_it_fail; + unsigned int fail_nth; + int nr_dirtied; + int nr_dirtied_pause; + long unsigned int dirty_paused_when; + u64 timer_slack_ns; + u64 default_timer_slack_ns; + int curr_ret_stack; + int curr_ret_depth; + struct ftrace_ret_stack *ret_stack; + long long unsigned int ftrace_timestamp; + atomic_t trace_overrun; + atomic_t tracing_graph_pause; + long unsigned int trace; + long unsigned int trace_recursion; + struct mem_cgroup *memcg_in_oom; + gfp_t memcg_oom_gfp_mask; + int memcg_oom_order; + unsigned int memcg_nr_pages_over_high; + struct mem_cgroup *active_memcg; + struct request_queue *throttle_queue; + struct uprobe_task *utask; + unsigned int sequential_io; + unsigned int sequential_io_avg; + long unsigned int task_state_change; + int pagefault_disabled; + struct task_struct *oom_reaper_list; + struct vm_struct *stack_vm_area; + refcount_t stack_refcount; + void *security; + void *mce_vaddr; + __u64 mce_kflags; + u64 mce_addr; + __u64 mce_ripv: 1; + __u64 mce_whole_page: 1; + __u64 __mce_reserved: 62; + struct callback_head mce_kill_me; + long: 64; + long: 64; + long: 64; + struct thread_struct thread; +}; + +struct screen_info { + __u8 orig_x; + __u8 orig_y; + __u16 ext_mem_k; + __u16 orig_video_page; + __u8 orig_video_mode; + __u8 orig_video_cols; + __u8 flags; + __u8 unused2; + __u16 orig_video_ega_bx; + __u16 unused3; + __u8 orig_video_lines; + __u8 orig_video_isVGA; + __u16 orig_video_points; + __u16 lfb_width; + __u16 lfb_height; + __u16 lfb_depth; + __u32 lfb_base; + __u32 lfb_size; + __u16 cl_magic; + __u16 cl_offset; + __u16 lfb_linelength; + __u8 red_size; + __u8 red_pos; + __u8 green_size; + __u8 green_pos; + __u8 blue_size; + __u8 blue_pos; + __u8 rsvd_size; + __u8 rsvd_pos; + __u16 vesapm_seg; + __u16 vesapm_off; + __u16 pages; + __u16 vesa_attributes; + __u32 capabilities; + __u32 ext_lfb_base; + __u8 _reserved[2]; +} __attribute__((packed)); + +struct apm_bios_info { + __u16 version; + __u16 cseg; + __u32 offset; + __u16 cseg_16; + __u16 dseg; + __u16 flags; + __u16 cseg_len; + __u16 cseg_16_len; + __u16 dseg_len; +}; + +struct edd_device_params { + __u16 length; + __u16 info_flags; + __u32 num_default_cylinders; + __u32 num_default_heads; + __u32 sectors_per_track; + __u64 number_of_sectors; + __u16 bytes_per_sector; + __u32 dpte_ptr; + __u16 key; + __u8 device_path_info_length; + __u8 reserved2; + __u16 reserved3; + __u8 host_bus_type[4]; + __u8 interface_type[8]; + union { + struct { + __u16 base_address; + __u16 reserved1; + __u32 reserved2; + } isa; + struct { + __u8 bus; + __u8 slot; + __u8 function; + __u8 channel; + __u32 reserved; + } pci; + struct { + __u64 reserved; + } ibnd; + struct { + __u64 reserved; + } xprs; + struct { + __u64 reserved; + } htpt; + struct { + __u64 reserved; + } unknown; + } interface_path; + union { + struct { + __u8 device; + __u8 reserved1; + __u16 reserved2; + __u32 reserved3; + __u64 reserved4; + } ata; + struct { + __u8 device; + __u8 lun; + __u8 reserved1; + __u8 reserved2; + __u32 reserved3; + __u64 reserved4; + } atapi; + struct { + __u16 id; + __u64 lun; + __u16 reserved1; + __u32 reserved2; + } __attribute__((packed)) scsi; + struct { + __u64 serial_number; + __u64 reserved; + } usb; + struct { + __u64 eui; + __u64 reserved; + } i1394; + struct { + __u64 wwid; + __u64 lun; + } fibre; + struct { + __u64 identity_tag; + __u64 reserved; + } i2o; + struct { + __u32 array_number; + __u32 reserved1; + __u64 reserved2; + } raid; + struct { + __u8 device; + __u8 reserved1; + __u16 reserved2; + __u32 reserved3; + __u64 reserved4; + } sata; + struct { + __u64 reserved1; + __u64 reserved2; + } unknown; + } device_path; + __u8 reserved4; + __u8 checksum; +} __attribute__((packed)); + +struct edd_info { + __u8 device; + __u8 version; + __u16 interface_support; + __u16 legacy_max_cylinder; + __u8 legacy_max_head; + __u8 legacy_sectors_per_track; + struct edd_device_params params; +} __attribute__((packed)); + +struct ist_info { + __u32 signature; + __u32 command; + __u32 event; + __u32 perf_level; +}; + +struct edid_info { + unsigned char dummy[128]; +}; + +struct setup_header { + __u8 setup_sects; + __u16 root_flags; + __u32 syssize; + __u16 ram_size; + __u16 vid_mode; + __u16 root_dev; + __u16 boot_flag; + __u16 jump; + __u32 header; + __u16 version; + __u32 realmode_swtch; + __u16 start_sys_seg; + __u16 kernel_version; + __u8 type_of_loader; + __u8 loadflags; + __u16 setup_move_size; + __u32 code32_start; + __u32 ramdisk_image; + __u32 ramdisk_size; + __u32 bootsect_kludge; + __u16 heap_end_ptr; + __u8 ext_loader_ver; + __u8 ext_loader_type; + __u32 cmd_line_ptr; + __u32 initrd_addr_max; + __u32 kernel_alignment; + __u8 relocatable_kernel; + __u8 min_alignment; + __u16 xloadflags; + __u32 cmdline_size; + __u32 hardware_subarch; + __u64 hardware_subarch_data; + __u32 payload_offset; + __u32 payload_length; + __u64 setup_data; + __u64 pref_address; + __u32 init_size; + __u32 handover_offset; + __u32 kernel_info_offset; +} __attribute__((packed)); + +struct sys_desc_table { + __u16 length; + __u8 table[14]; +}; + +struct olpc_ofw_header { + __u32 ofw_magic; + __u32 ofw_version; + __u32 cif_handler; + __u32 irq_desc_table; +}; + +struct efi_info { + __u32 efi_loader_signature; + __u32 efi_systab; + __u32 efi_memdesc_size; + __u32 efi_memdesc_version; + __u32 efi_memmap; + __u32 efi_memmap_size; + __u32 efi_systab_hi; + __u32 efi_memmap_hi; +}; + +struct boot_e820_entry { + __u64 addr; + __u64 size; + __u32 type; +} __attribute__((packed)); + +struct boot_params { + struct screen_info screen_info; + struct apm_bios_info apm_bios_info; + __u8 _pad2[4]; + __u64 tboot_addr; + struct ist_info ist_info; + __u64 acpi_rsdp_addr; + __u8 _pad3[8]; + __u8 hd0_info[16]; + __u8 hd1_info[16]; + struct sys_desc_table sys_desc_table; + struct olpc_ofw_header olpc_ofw_header; + __u32 ext_ramdisk_image; + __u32 ext_ramdisk_size; + __u32 ext_cmd_line_ptr; + __u8 _pad4[116]; + struct edid_info edid_info; + struct efi_info efi_info; + __u32 alt_mem_k; + __u32 scratch; + __u8 e820_entries; + __u8 eddbuf_entries; + __u8 edd_mbr_sig_buf_entries; + __u8 kbd_status; + __u8 secure_boot; + __u8 _pad5[2]; + __u8 sentinel; + __u8 _pad6[1]; + struct setup_header hdr; + __u8 _pad7[36]; + __u32 edd_mbr_sig_buffer[16]; + struct boot_e820_entry e820_table[128]; + __u8 _pad8[48]; + struct edd_info eddbuf[6]; + __u8 _pad9[276]; +} __attribute__((packed)); + +enum x86_hardware_subarch { + X86_SUBARCH_PC = 0, + X86_SUBARCH_LGUEST = 1, + X86_SUBARCH_XEN = 2, + X86_SUBARCH_INTEL_MID = 3, + X86_SUBARCH_CE4100 = 4, + X86_NR_SUBARCHS = 5, +}; + +struct range { + u64 start; + u64 end; +}; + +struct pt_regs { + long unsigned int r15; + long unsigned int r14; + long unsigned int r13; + long unsigned int r12; + long unsigned int bp; + long unsigned int bx; + long unsigned int r11; + long unsigned int r10; + long unsigned int r9; + long unsigned int r8; + long unsigned int ax; + long unsigned int cx; + long unsigned int dx; + long unsigned int si; + long unsigned int di; + long unsigned int orig_ax; + long unsigned int ip; + long unsigned int cs; + long unsigned int flags; + long unsigned int sp; + long unsigned int ss; +}; + +struct math_emu_info { + long int ___orig_eip; + struct pt_regs *regs; +}; + +typedef long unsigned int pteval_t; + +typedef long unsigned int pmdval_t; + +typedef long unsigned int pudval_t; + +typedef long unsigned int p4dval_t; + +typedef long unsigned int pgdval_t; + +typedef long unsigned int pgprotval_t; + +typedef struct { + pteval_t pte; +} pte_t; + +struct pgprot { + pgprotval_t pgprot; +}; + +typedef struct pgprot pgprot_t; + +typedef struct { + pgdval_t pgd; +} pgd_t; + +typedef struct { + pgd_t pgd; +} p4d_t; + +typedef struct { + pudval_t pud; +} pud_t; + +typedef struct { + pmdval_t pmd; +} pmd_t; + +typedef struct page *pgtable_t; + +struct address_space; + +struct kmem_cache; + +struct dev_pagemap; + +struct page { + long unsigned int flags; + union { + struct { + struct list_head lru; + struct address_space *mapping; + long unsigned int index; + long unsigned int private; + }; + struct { + dma_addr_t dma_addr; + }; + struct { + union { + struct list_head slab_list; + struct { + struct page *next; + int pages; + int pobjects; + }; + }; + struct kmem_cache *slab_cache; + void *freelist; + union { + void *s_mem; + long unsigned int counters; + struct { + unsigned int inuse: 16; + unsigned int objects: 15; + unsigned int frozen: 1; + }; + }; + }; + struct { + long unsigned int compound_head; + unsigned char compound_dtor; + unsigned char compound_order; + atomic_t compound_mapcount; + unsigned int compound_nr; + }; + struct { + long unsigned int _compound_pad_1; + atomic_t hpage_pinned_refcount; + struct list_head deferred_list; + }; + struct { + long unsigned int _pt_pad_1; + pgtable_t pmd_huge_pte; + long unsigned int _pt_pad_2; + union { + struct mm_struct *pt_mm; + atomic_t pt_frag_refcount; + }; + spinlock_t *ptl; + }; + struct { + struct dev_pagemap *pgmap; + void *zone_device_data; + }; + struct callback_head callback_head; + }; + union { + atomic_t _mapcount; + unsigned int page_type; + unsigned int active; + int units; + }; + atomic_t _refcount; + long unsigned int memcg_data; +}; + +struct idt_bits { + u16 ist: 3; + u16 zero: 5; + u16 type: 5; + u16 dpl: 2; + u16 p: 1; +}; + +struct gate_struct { + u16 offset_low; + u16 segment; + struct idt_bits bits; + u16 offset_middle; + u32 offset_high; + u32 reserved; +}; + +typedef struct gate_struct gate_desc; + +struct desc_ptr { + short unsigned int size; + long unsigned int address; +} __attribute__((packed)); + +enum { + UNAME26 = 131072, + ADDR_NO_RANDOMIZE = 262144, + FDPIC_FUNCPTRS = 524288, + MMAP_PAGE_ZERO = 1048576, + ADDR_COMPAT_LAYOUT = 2097152, + READ_IMPLIES_EXEC = 4194304, + ADDR_LIMIT_32BIT = 8388608, + SHORT_INODE = 16777216, + WHOLE_SECONDS = 33554432, + STICKY_TIMEOUTS = 67108864, + ADDR_LIMIT_3GB = 134217728, +}; + +enum tlb_infos { + ENTRIES = 0, + NR_INFO = 1, +}; + +enum pcpu_fc { + PCPU_FC_AUTO = 0, + PCPU_FC_EMBED = 1, + PCPU_FC_PAGE = 2, + PCPU_FC_NR = 3, +}; + +struct vm_struct { + struct vm_struct *next; + void *addr; + long unsigned int size; + long unsigned int flags; + struct page **pages; + unsigned int nr_pages; + phys_addr_t phys_addr; + const void *caller; +}; + +struct wait_queue_head { + spinlock_t lock; + struct list_head head; +}; + +typedef struct wait_queue_head wait_queue_head_t; + +struct ww_acquire_ctx; + +struct ww_class; + +struct ww_mutex { + struct mutex base; + struct ww_acquire_ctx *ctx; + struct ww_class *ww_class; +}; + +struct ww_acquire_ctx { + struct task_struct *task; + long unsigned int stamp; + unsigned int acquired; + short unsigned int wounded; + short unsigned int is_wait_die; + unsigned int done_acquire; + struct ww_class *ww_class; + struct ww_mutex *contending_lock; +}; + +struct ww_class { + atomic_long_t stamp; + struct lock_class_key acquire_key; + struct lock_class_key mutex_key; + const char *acquire_name; + const char *mutex_name; + unsigned int is_wait_die; +}; + +struct mutex_waiter { + struct list_head list; + struct task_struct *task; + struct ww_acquire_ctx *ww_ctx; + void *magic; +}; + +struct seqcount_raw_spinlock { + seqcount_t seqcount; +}; + +typedef struct seqcount_raw_spinlock seqcount_raw_spinlock_t; + +typedef struct { + seqcount_spinlock_t seqcount; + spinlock_t lock; +} seqlock_t; + +enum node_states { + N_POSSIBLE = 0, + N_ONLINE = 1, + N_NORMAL_MEMORY = 2, + N_HIGH_MEMORY = 2, + N_MEMORY = 3, + N_CPU = 4, + N_GENERIC_INITIATOR = 5, + NR_NODE_STATES = 6, +}; + +struct vm_userfaultfd_ctx {}; + +struct anon_vma; + +struct vm_operations_struct; + +struct vm_area_struct { + long unsigned int vm_start; + long unsigned int vm_end; + struct vm_area_struct *vm_next; + struct vm_area_struct *vm_prev; + struct rb_node vm_rb; + long unsigned int rb_subtree_gap; + struct mm_struct *vm_mm; + pgprot_t vm_page_prot; + long unsigned int vm_flags; + struct { + struct rb_node rb; + long unsigned int rb_subtree_last; + } shared; + struct list_head anon_vma_chain; + struct anon_vma *anon_vma; + const struct vm_operations_struct *vm_ops; + long unsigned int vm_pgoff; + struct file *vm_file; + void *vm_private_data; + atomic_long_t swap_readahead_info; + struct mempolicy *vm_policy; + struct vm_userfaultfd_ctx vm_userfaultfd_ctx; +}; + +enum { + MM_FILEPAGES = 0, + MM_ANONPAGES = 1, + MM_SWAPENTS = 2, + MM_SHMEMPAGES = 3, + NR_MM_COUNTERS = 4, +}; + +struct mm_rss_stat { + atomic_long_t count[4]; +}; + +struct rw_semaphore { + atomic_long_t count; + atomic_long_t owner; + struct optimistic_spin_queue osq; + raw_spinlock_t wait_lock; + struct list_head wait_list; +}; + +struct swait_queue_head { + raw_spinlock_t lock; + struct list_head task_list; +}; + +struct completion { + unsigned int done; + struct swait_queue_head wait; +}; + +struct ldt_struct; + +struct vdso_image; + +typedef struct { + u64 ctx_id; + atomic64_t tlb_gen; + struct rw_semaphore ldt_usr_sem; + struct ldt_struct *ldt; + short unsigned int ia32_compat; + struct mutex lock; + void *vdso; + const struct vdso_image *vdso_image; + atomic_t perf_rdpmc_allowed; +} mm_context_t; + +struct xol_area; + +struct uprobes_state { + struct xol_area *xol_area; +}; + +struct work_struct; + +typedef void (*work_func_t)(struct work_struct *); + +struct work_struct { + atomic_long_t data; + struct list_head entry; + work_func_t func; +}; + +struct linux_binfmt; + +struct core_state; + +struct kioctx_table; + +struct user_namespace; + +struct mmu_notifier_subscriptions; + +struct mm_struct { + struct { + struct vm_area_struct *mmap; + struct rb_root mm_rb; + u64 vmacache_seqnum; + long unsigned int (*get_unmapped_area)(struct file *, long unsigned int, long unsigned int, long unsigned int, long unsigned int); + long unsigned int mmap_base; + long unsigned int mmap_legacy_base; + long unsigned int mmap_compat_base; + long unsigned int mmap_compat_legacy_base; + long unsigned int task_size; + long unsigned int highest_vm_end; + pgd_t *pgd; + atomic_t membarrier_state; + atomic_t mm_users; + atomic_t mm_count; + atomic_t has_pinned; + atomic_long_t pgtables_bytes; + int map_count; + spinlock_t page_table_lock; + struct rw_semaphore mmap_lock; + struct list_head mmlist; + long unsigned int hiwater_rss; + long unsigned int hiwater_vm; + long unsigned int total_vm; + long unsigned int locked_vm; + atomic64_t pinned_vm; + long unsigned int data_vm; + long unsigned int exec_vm; + long unsigned int stack_vm; + long unsigned int def_flags; + spinlock_t arg_lock; + long unsigned int start_code; + long unsigned int end_code; + long unsigned int start_data; + long unsigned int end_data; + long unsigned int start_brk; + long unsigned int brk; + long unsigned int start_stack; + long unsigned int arg_start; + long unsigned int arg_end; + long unsigned int env_start; + long unsigned int env_end; + long unsigned int saved_auxv[46]; + struct mm_rss_stat rss_stat; + struct linux_binfmt *binfmt; + mm_context_t context; + long unsigned int flags; + struct core_state *core_state; + spinlock_t ioctx_lock; + struct kioctx_table *ioctx_table; + struct task_struct *owner; + struct user_namespace *user_ns; + struct file *exe_file; + struct mmu_notifier_subscriptions *notifier_subscriptions; + long unsigned int numa_next_scan; + long unsigned int numa_scan_offset; + int numa_scan_seq; + atomic_t tlb_flush_pending; + bool tlb_flush_batched; + struct uprobes_state uprobes_state; + atomic_long_t hugetlb_usage; + struct work_struct async_put_work; + u32 pasid; + }; + long unsigned int cpu_bitmap[0]; +}; + +struct arch_uprobe_task { + long unsigned int saved_scratch_register; + unsigned int saved_trap_nr; + unsigned int saved_tf; +}; + +enum uprobe_task_state { + UTASK_RUNNING = 0, + UTASK_SSTEP = 1, + UTASK_SSTEP_ACK = 2, + UTASK_SSTEP_TRAPPED = 3, +}; + +struct uprobe; + +struct return_instance; + +struct uprobe_task { + enum uprobe_task_state state; + union { + struct { + struct arch_uprobe_task autask; + long unsigned int vaddr; + }; + struct { + struct callback_head dup_xol_work; + long unsigned int dup_xol_addr; + }; + }; + struct uprobe *active_uprobe; + long unsigned int xol_vaddr; + struct return_instance *return_instances; + unsigned int depth; +}; + +struct return_instance { + struct uprobe *uprobe; + long unsigned int func; + long unsigned int stack; + long unsigned int orig_ret_vaddr; + bool chained; + struct return_instance *next; +}; + +struct vdso_image { + void *data; + long unsigned int size; + long unsigned int alt; + long unsigned int alt_len; + long int sym_vvar_start; + long int sym_vvar_page; + long int sym_pvclock_page; + long int sym_hvclock_page; + long int sym_timens_page; + long int sym_VDSO32_NOTE_MASK; + long int sym___kernel_sigreturn; + long int sym___kernel_rt_sigreturn; + long int sym___kernel_vsyscall; + long int sym_int80_landing_pad; +}; + +struct xarray { + spinlock_t xa_lock; + gfp_t xa_flags; + void *xa_head; +}; + +typedef u32 errseq_t; + +struct address_space_operations; + +struct address_space { + struct inode *host; + struct xarray i_pages; + gfp_t gfp_mask; + atomic_t i_mmap_writable; + struct rb_root_cached i_mmap; + struct rw_semaphore i_mmap_rwsem; + long unsigned int nrpages; + long unsigned int nrexceptional; + long unsigned int writeback_index; + const struct address_space_operations *a_ops; + long unsigned int flags; + errseq_t wb_err; + spinlock_t private_lock; + struct list_head private_list; + void *private_data; +}; + +struct vmem_altmap { + const long unsigned int base_pfn; + const long unsigned int end_pfn; + const long unsigned int reserve; + long unsigned int free; + long unsigned int align; + long unsigned int alloc; +}; + +struct percpu_ref_data; + +struct percpu_ref { + long unsigned int percpu_count_ptr; + struct percpu_ref_data *data; +}; + +enum memory_type { + MEMORY_DEVICE_PRIVATE = 1, + MEMORY_DEVICE_FS_DAX = 2, + MEMORY_DEVICE_GENERIC = 3, + MEMORY_DEVICE_PCI_P2PDMA = 4, +}; + +struct dev_pagemap_ops; + +struct dev_pagemap { + struct vmem_altmap altmap; + struct percpu_ref *ref; + struct percpu_ref internal_ref; + struct completion done; + enum memory_type type; + unsigned int flags; + const struct dev_pagemap_ops *ops; + void *owner; + int nr_range; + union { + struct range range; + struct range ranges[0]; + }; +}; + +struct vfsmount; + +struct path { + struct vfsmount *mnt; + struct dentry *dentry; +}; + +enum rw_hint { + WRITE_LIFE_NOT_SET = 0, + WRITE_LIFE_NONE = 1, + WRITE_LIFE_SHORT = 2, + WRITE_LIFE_MEDIUM = 3, + WRITE_LIFE_LONG = 4, + WRITE_LIFE_EXTREME = 5, +}; + +enum pid_type { + PIDTYPE_PID = 0, + PIDTYPE_TGID = 1, + PIDTYPE_PGID = 2, + PIDTYPE_SID = 3, + PIDTYPE_MAX = 4, +}; + +struct fown_struct { + rwlock_t lock; + struct pid *pid; + enum pid_type pid_type; + kuid_t uid; + kuid_t euid; + int signum; +}; + +struct file_ra_state { + long unsigned int start; + unsigned int size; + unsigned int async_size; + unsigned int ra_pages; + unsigned int mmap_miss; + loff_t prev_pos; +}; + +struct file { + union { + struct llist_node fu_llist; + struct callback_head fu_rcuhead; + } f_u; + struct path f_path; + struct inode *f_inode; + const struct file_operations *f_op; + spinlock_t f_lock; + enum rw_hint f_write_hint; + atomic_long_t f_count; + unsigned int f_flags; + fmode_t f_mode; + struct mutex f_pos_lock; + loff_t f_pos; + struct fown_struct f_owner; + const struct cred *f_cred; + struct file_ra_state f_ra; + u64 f_version; + void *f_security; + void *private_data; + struct list_head f_ep_links; + struct list_head f_tfile_llink; + struct address_space *f_mapping; + errseq_t f_wb_err; + errseq_t f_sb_err; +}; + +typedef unsigned int vm_fault_t; + +enum page_entry_size { + PE_SIZE_PTE = 0, + PE_SIZE_PMD = 1, + PE_SIZE_PUD = 2, +}; + +struct vm_fault; + +struct vm_operations_struct { + void (*open)(struct vm_area_struct *); + void (*close)(struct vm_area_struct *); + int (*split)(struct vm_area_struct *, long unsigned int); + int (*mremap)(struct vm_area_struct *); + vm_fault_t (*fault)(struct vm_fault *); + vm_fault_t (*huge_fault)(struct vm_fault *, enum page_entry_size); + void (*map_pages)(struct vm_fault *, long unsigned int, long unsigned int); + long unsigned int (*pagesize)(struct vm_area_struct *); + vm_fault_t (*page_mkwrite)(struct vm_fault *); + vm_fault_t (*pfn_mkwrite)(struct vm_fault *); + int (*access)(struct vm_area_struct *, long unsigned int, void *, int, int); + const char * (*name)(struct vm_area_struct *); + int (*set_policy)(struct vm_area_struct *, struct mempolicy *); + struct mempolicy * (*get_policy)(struct vm_area_struct *, long unsigned int); + struct page * (*find_special_page)(struct vm_area_struct *, long unsigned int); +}; + +struct core_thread { + struct task_struct *task; + struct core_thread *next; +}; + +struct core_state { + atomic_t nr_threads; + struct core_thread dumper; + struct completion startup; +}; + +struct vm_fault { + struct vm_area_struct *vma; + unsigned int flags; + gfp_t gfp_mask; + long unsigned int pgoff; + long unsigned int address; + pmd_t *pmd; + pud_t *pud; + pte_t orig_pte; + struct page *cow_page; + struct page *page; + pte_t *pte; + spinlock_t *ptl; + pgtable_t prealloc_pte; +}; + +enum migratetype { + MIGRATE_UNMOVABLE = 0, + MIGRATE_MOVABLE = 1, + MIGRATE_RECLAIMABLE = 2, + MIGRATE_PCPTYPES = 3, + MIGRATE_HIGHATOMIC = 3, + MIGRATE_CMA = 4, + MIGRATE_ISOLATE = 5, + MIGRATE_TYPES = 6, +}; + +enum numa_stat_item { + NUMA_HIT = 0, + NUMA_MISS = 1, + NUMA_FOREIGN = 2, + NUMA_INTERLEAVE_HIT = 3, + NUMA_LOCAL = 4, + NUMA_OTHER = 5, + NR_VM_NUMA_STAT_ITEMS = 6, +}; + +enum zone_stat_item { + NR_FREE_PAGES = 0, + NR_ZONE_LRU_BASE = 1, + NR_ZONE_INACTIVE_ANON = 1, + NR_ZONE_ACTIVE_ANON = 2, + NR_ZONE_INACTIVE_FILE = 3, + NR_ZONE_ACTIVE_FILE = 4, + NR_ZONE_UNEVICTABLE = 5, + NR_ZONE_WRITE_PENDING = 6, + NR_MLOCK = 7, + NR_PAGETABLE = 8, + NR_BOUNCE = 9, + NR_FREE_CMA_PAGES = 10, + NR_VM_ZONE_STAT_ITEMS = 11, +}; + +enum node_stat_item { + NR_LRU_BASE = 0, + NR_INACTIVE_ANON = 0, + NR_ACTIVE_ANON = 1, + NR_INACTIVE_FILE = 2, + NR_ACTIVE_FILE = 3, + NR_UNEVICTABLE = 4, + NR_SLAB_RECLAIMABLE_B = 5, + NR_SLAB_UNRECLAIMABLE_B = 6, + NR_ISOLATED_ANON = 7, + NR_ISOLATED_FILE = 8, + WORKINGSET_NODES = 9, + WORKINGSET_REFAULT_BASE = 10, + WORKINGSET_REFAULT_ANON = 10, + WORKINGSET_REFAULT_FILE = 11, + WORKINGSET_ACTIVATE_BASE = 12, + WORKINGSET_ACTIVATE_ANON = 12, + WORKINGSET_ACTIVATE_FILE = 13, + WORKINGSET_RESTORE_BASE = 14, + WORKINGSET_RESTORE_ANON = 14, + WORKINGSET_RESTORE_FILE = 15, + WORKINGSET_NODERECLAIM = 16, + NR_ANON_MAPPED = 17, + NR_FILE_MAPPED = 18, + NR_FILE_PAGES = 19, + NR_FILE_DIRTY = 20, + NR_WRITEBACK = 21, + NR_WRITEBACK_TEMP = 22, + NR_SHMEM = 23, + NR_SHMEM_THPS = 24, + NR_SHMEM_PMDMAPPED = 25, + NR_FILE_THPS = 26, + NR_FILE_PMDMAPPED = 27, + NR_ANON_THPS = 28, + NR_VMSCAN_WRITE = 29, + NR_VMSCAN_IMMEDIATE = 30, + NR_DIRTIED = 31, + NR_WRITTEN = 32, + NR_KERNEL_MISC_RECLAIMABLE = 33, + NR_FOLL_PIN_ACQUIRED = 34, + NR_FOLL_PIN_RELEASED = 35, + NR_KERNEL_STACK_KB = 36, + NR_VM_NODE_STAT_ITEMS = 37, +}; + +enum lru_list { + LRU_INACTIVE_ANON = 0, + LRU_ACTIVE_ANON = 1, + LRU_INACTIVE_FILE = 2, + LRU_ACTIVE_FILE = 3, + LRU_UNEVICTABLE = 4, + NR_LRU_LISTS = 5, +}; + +typedef unsigned int isolate_mode_t; + +enum zone_watermarks { + WMARK_MIN = 0, + WMARK_LOW = 1, + WMARK_HIGH = 2, + NR_WMARK = 3, +}; + +enum { + ZONELIST_FALLBACK = 0, + ZONELIST_NOFALLBACK = 1, + MAX_ZONELISTS = 2, +}; + +typedef void percpu_ref_func_t(struct percpu_ref *); + +struct percpu_ref_data { + atomic_long_t count; + percpu_ref_func_t *release; + percpu_ref_func_t *confirm_switch; + bool force_atomic: 1; + bool allow_reinit: 1; + struct callback_head rcu; + struct percpu_ref *ref; +}; + +struct shrink_control { + gfp_t gfp_mask; + int nid; + long unsigned int nr_to_scan; + long unsigned int nr_scanned; + struct mem_cgroup *memcg; +}; + +struct shrinker { + long unsigned int (*count_objects)(struct shrinker *, struct shrink_control *); + long unsigned int (*scan_objects)(struct shrinker *, struct shrink_control *); + long int batch; + int seeks; + unsigned int flags; + struct list_head list; + int id; + atomic_long_t *nr_deferred; +}; + +struct rlimit { + __kernel_ulong_t rlim_cur; + __kernel_ulong_t rlim_max; +}; + +struct dev_pagemap_ops { + void (*page_free)(struct page *); + void (*kill)(struct dev_pagemap *); + void (*cleanup)(struct dev_pagemap *); + vm_fault_t (*migrate_to_ram)(struct vm_fault *); +}; + +struct pid_namespace; + +struct upid { + int nr; + struct pid_namespace *ns; +}; + +struct pid { + refcount_t count; + unsigned int level; + spinlock_t lock; + struct hlist_head tasks[4]; + struct hlist_head inodes; + wait_queue_head_t wait_pidfd; + struct callback_head rcu; + struct upid numbers[1]; +}; + +typedef struct { + gid_t val; +} kgid_t; + +struct hrtimer_cpu_base; + +struct hrtimer_clock_base { + struct hrtimer_cpu_base *cpu_base; + unsigned int index; + clockid_t clockid; + seqcount_raw_spinlock_t seq; + struct hrtimer *running; + struct timerqueue_head active; + ktime_t (*get_time)(); + ktime_t offset; +}; + +struct hrtimer_cpu_base { + raw_spinlock_t lock; + unsigned int cpu; + unsigned int active_bases; + unsigned int clock_was_set_seq; + unsigned int hres_active: 1; + unsigned int in_hrtirq: 1; + unsigned int hang_detected: 1; + unsigned int softirq_activated: 1; + unsigned int nr_events; + short unsigned int nr_retries; + short unsigned int nr_hangs; + unsigned int max_hang_time; + ktime_t expires_next; + struct hrtimer *next_timer; + ktime_t softirq_expires_next; + struct hrtimer *softirq_next_timer; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct hrtimer_clock_base clock_base[8]; +}; + +enum hrtimer_base_type { + HRTIMER_BASE_MONOTONIC = 0, + HRTIMER_BASE_REALTIME = 1, + HRTIMER_BASE_BOOTTIME = 2, + HRTIMER_BASE_TAI = 3, + HRTIMER_BASE_MONOTONIC_SOFT = 4, + HRTIMER_BASE_REALTIME_SOFT = 5, + HRTIMER_BASE_BOOTTIME_SOFT = 6, + HRTIMER_BASE_TAI_SOFT = 7, + HRTIMER_MAX_CLOCK_BASES = 8, +}; + +typedef void __signalfn_t(int); + +typedef __signalfn_t *__sighandler_t; + +typedef void __restorefn_t(); + +typedef __restorefn_t *__sigrestore_t; + +union sigval { + int sival_int; + void *sival_ptr; +}; + +typedef union sigval sigval_t; + +union __sifields { + struct { + __kernel_pid_t _pid; + __kernel_uid32_t _uid; + } _kill; + struct { + __kernel_timer_t _tid; + int _overrun; + sigval_t _sigval; + int _sys_private; + } _timer; + struct { + __kernel_pid_t _pid; + __kernel_uid32_t _uid; + sigval_t _sigval; + } _rt; + struct { + __kernel_pid_t _pid; + __kernel_uid32_t _uid; + int _status; + __kernel_clock_t _utime; + __kernel_clock_t _stime; + } _sigchld; + struct { + void *_addr; + union { + short int _addr_lsb; + struct { + char _dummy_bnd[8]; + void *_lower; + void *_upper; + } _addr_bnd; + struct { + char _dummy_pkey[8]; + __u32 _pkey; + } _addr_pkey; + }; + } _sigfault; + struct { + long int _band; + int _fd; + } _sigpoll; + struct { + void *_call_addr; + int _syscall; + unsigned int _arch; + } _sigsys; +}; + +struct kernel_siginfo { + struct { + int si_signo; + int si_errno; + int si_code; + union __sifields _sifields; + }; +}; + +struct user_struct { + refcount_t __count; + atomic_t processes; + atomic_t sigpending; + atomic_long_t epoll_watches; + long unsigned int mq_bytes; + long unsigned int locked_shm; + long unsigned int unix_inflight; + atomic_long_t pipe_bufs; + struct hlist_node uidhash_node; + kuid_t uid; + atomic_long_t locked_vm; + struct ratelimit_state ratelimit; +}; + +struct sigaction { + __sighandler_t sa_handler; + long unsigned int sa_flags; + __sigrestore_t sa_restorer; + sigset_t sa_mask; +}; + +struct k_sigaction { + struct sigaction sa; +}; + +struct cpu_itimer { + u64 expires; + u64 incr; +}; + +struct task_cputime_atomic { + atomic64_t utime; + atomic64_t stime; + atomic64_t sum_exec_runtime; +}; + +struct thread_group_cputimer { + struct task_cputime_atomic cputime_atomic; +}; + +struct pacct_struct { + int ac_flag; + long int ac_exitcode; + long unsigned int ac_mem; + u64 ac_utime; + u64 ac_stime; + long unsigned int ac_minflt; + long unsigned int ac_majflt; +}; + +struct tty_struct; + +struct taskstats; + +struct tty_audit_buf; + +struct signal_struct { + refcount_t sigcnt; + atomic_t live; + int nr_threads; + struct list_head thread_head; + wait_queue_head_t wait_chldexit; + struct task_struct *curr_target; + struct sigpending shared_pending; + struct hlist_head multiprocess; + int group_exit_code; + int notify_count; + struct task_struct *group_exit_task; + int group_stop_count; + unsigned int flags; + unsigned int is_child_subreaper: 1; + unsigned int has_child_subreaper: 1; + int posix_timer_id; + struct list_head posix_timers; + struct hrtimer real_timer; + ktime_t it_real_incr; + struct cpu_itimer it[2]; + struct thread_group_cputimer cputimer; + struct posix_cputimers posix_cputimers; + struct pid *pids[4]; + struct pid *tty_old_pgrp; + int leader; + struct tty_struct *tty; + seqlock_t stats_lock; + u64 utime; + u64 stime; + u64 cutime; + u64 cstime; + u64 gtime; + u64 cgtime; + struct prev_cputime prev_cputime; + long unsigned int nvcsw; + long unsigned int nivcsw; + long unsigned int cnvcsw; + long unsigned int cnivcsw; + long unsigned int min_flt; + long unsigned int maj_flt; + long unsigned int cmin_flt; + long unsigned int cmaj_flt; + long unsigned int inblock; + long unsigned int oublock; + long unsigned int cinblock; + long unsigned int coublock; + long unsigned int maxrss; + long unsigned int cmaxrss; + struct task_io_accounting ioac; + long long unsigned int sum_sched_runtime; + struct rlimit rlim[16]; + struct pacct_struct pacct; + struct taskstats *stats; + unsigned int audit_tty; + struct tty_audit_buf *tty_audit_buf; + bool oom_flag_origin; + short int oom_score_adj; + short int oom_score_adj_min; + struct mm_struct *oom_mm; + struct mutex cred_guard_mutex; + struct mutex exec_update_mutex; +}; + +enum rseq_cs_flags_bit { + RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT_BIT = 0, + RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL_BIT = 1, + RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT = 2, +}; + +struct rseq { + __u32 cpu_id_start; + __u32 cpu_id; + union { + __u64 ptr64; + __u64 ptr; + } rseq_cs; + __u32 flags; + long: 32; + long: 64; +}; + +enum perf_event_task_context { + perf_invalid_context = 4294967295, + perf_hw_context = 0, + perf_sw_context = 1, + perf_nr_task_contexts = 2, +}; + +struct rq; + +struct rq_flags; + +struct sched_class { + void (*enqueue_task)(struct rq *, struct task_struct *, int); + void (*dequeue_task)(struct rq *, struct task_struct *, int); + void (*yield_task)(struct rq *); + bool (*yield_to_task)(struct rq *, struct task_struct *); + void (*check_preempt_curr)(struct rq *, struct task_struct *, int); + struct task_struct * (*pick_next_task)(struct rq *); + void (*put_prev_task)(struct rq *, struct task_struct *); + void (*set_next_task)(struct rq *, struct task_struct *, bool); + int (*balance)(struct rq *, struct task_struct *, struct rq_flags *); + int (*select_task_rq)(struct task_struct *, int, int, int); + void (*migrate_task_rq)(struct task_struct *, int); + void (*task_woken)(struct rq *, struct task_struct *); + void (*set_cpus_allowed)(struct task_struct *, const struct cpumask *); + void (*rq_online)(struct rq *); + void (*rq_offline)(struct rq *); + void (*task_tick)(struct rq *, struct task_struct *, int); + void (*task_fork)(struct task_struct *); + void (*task_dead)(struct task_struct *); + void (*switched_from)(struct rq *, struct task_struct *); + void (*switched_to)(struct rq *, struct task_struct *); + void (*prio_changed)(struct rq *, struct task_struct *, int); + unsigned int (*get_rr_interval)(struct rq *, struct task_struct *); + void (*update_curr)(struct rq *); + void (*task_change_group)(struct task_struct *, int); +}; + +struct kernel_cap_struct { + __u32 cap[2]; +}; + +typedef struct kernel_cap_struct kernel_cap_t; + +struct group_info; + +struct cred { + atomic_t usage; + atomic_t subscribers; + void *put_addr; + unsigned int magic; + kuid_t uid; + kgid_t gid; + kuid_t suid; + kgid_t sgid; + kuid_t euid; + kgid_t egid; + kuid_t fsuid; + kgid_t fsgid; + unsigned int securebits; + kernel_cap_t cap_inheritable; + kernel_cap_t cap_permitted; + kernel_cap_t cap_effective; + kernel_cap_t cap_bset; + kernel_cap_t cap_ambient; + unsigned char jit_keyring; + struct key *session_keyring; + struct key *process_keyring; + struct key *thread_keyring; + struct key *request_key_auth; + void *security; + struct user_struct *user; + struct user_namespace *user_ns; + struct group_info *group_info; + union { + int non_rcu; + struct callback_head rcu; + }; +}; + +typedef int32_t key_serial_t; + +typedef uint32_t key_perm_t; + +struct key_type; + +struct key_tag; + +struct keyring_index_key { + long unsigned int hash; + union { + struct { + u16 desc_len; + char desc[6]; + }; + long unsigned int x; + }; + struct key_type *type; + struct key_tag *domain_tag; + const char *description; +}; + +union key_payload { + void *rcu_data0; + void *data[4]; +}; + +struct assoc_array_ptr; + +struct assoc_array { + struct assoc_array_ptr *root; + long unsigned int nr_leaves_on_tree; +}; + +struct key_user; + +struct key_restriction; + +struct key { + refcount_t usage; + key_serial_t serial; + union { + struct list_head graveyard_link; + struct rb_node serial_node; + }; + struct rw_semaphore sem; + struct key_user *user; + void *security; + union { + time64_t expiry; + time64_t revoked_at; + }; + time64_t last_used_at; + kuid_t uid; + kgid_t gid; + key_perm_t perm; + short unsigned int quotalen; + short unsigned int datalen; + short int state; + long unsigned int flags; + union { + struct keyring_index_key index_key; + struct { + long unsigned int hash; + long unsigned int len_desc; + struct key_type *type; + struct key_tag *domain_tag; + char *description; + }; + }; + union { + union key_payload payload; + struct { + struct list_head name_link; + struct assoc_array keys; + }; + }; + struct key_restriction *restrict_link; +}; + +struct sighand_struct { + spinlock_t siglock; + refcount_t count; + wait_queue_head_t signalfd_wqh; + struct k_sigaction action[64]; +}; + +struct io_cq; + +struct io_context { + atomic_long_t refcount; + atomic_t active_ref; + atomic_t nr_tasks; + spinlock_t lock; + short unsigned int ioprio; + struct xarray icq_tree; + struct io_cq *icq_hint; + struct hlist_head icq_list; + struct work_struct release_work; +}; + +enum rseq_event_mask_bits { + RSEQ_EVENT_PREEMPT_BIT = 0, + RSEQ_EVENT_SIGNAL_BIT = 1, + RSEQ_EVENT_MIGRATE_BIT = 2, +}; + +enum fixed_addresses { + VSYSCALL_PAGE = 511, + FIX_DBGP_BASE = 512, + FIX_EARLYCON_MEM_BASE = 513, + FIX_APIC_BASE = 514, + FIX_IO_APIC_BASE_0 = 515, + FIX_IO_APIC_BASE_END = 642, + __end_of_permanent_fixed_addresses = 643, + FIX_BTMAP_END = 1024, + FIX_BTMAP_BEGIN = 1535, + FIX_TBOOT_BASE = 1536, + __end_of_fixed_addresses = 1537, +}; + +struct hlist_bl_node; + +struct hlist_bl_head { + struct hlist_bl_node *first; +}; + +struct hlist_bl_node { + struct hlist_bl_node *next; + struct hlist_bl_node **pprev; +}; + +struct lockref { + union { + struct { + spinlock_t lock; + int count; + }; + }; +}; + +struct qstr { + union { + struct { + u32 hash; + u32 len; + }; + u64 hash_len; + }; + const unsigned char *name; +}; + +struct dentry_operations; + +struct dentry { + unsigned int d_flags; + seqcount_spinlock_t d_seq; + struct hlist_bl_node d_hash; + struct dentry *d_parent; + struct qstr d_name; + struct inode *d_inode; + unsigned char d_iname[32]; + struct lockref d_lockref; + const struct dentry_operations *d_op; + struct super_block *d_sb; + long unsigned int d_time; + void *d_fsdata; + union { + struct list_head d_lru; + wait_queue_head_t *d_wait; + }; + struct list_head d_child; + struct list_head d_subdirs; + union { + struct hlist_node d_alias; + struct hlist_bl_node d_in_lookup_hash; + struct callback_head d_rcu; + } d_u; +}; + +struct posix_acl; + +struct inode_operations; + +struct bdi_writeback; + +struct file_lock_context; + +struct block_device; + +struct cdev; + +struct fsnotify_mark_connector; + +struct inode { + umode_t i_mode; + short unsigned int i_opflags; + kuid_t i_uid; + kgid_t i_gid; + unsigned int i_flags; + struct posix_acl *i_acl; + struct posix_acl *i_default_acl; + const struct inode_operations *i_op; + struct super_block *i_sb; + struct address_space *i_mapping; + void *i_security; + long unsigned int i_ino; + union { + const unsigned int i_nlink; + unsigned int __i_nlink; + }; + dev_t i_rdev; + loff_t i_size; + struct timespec64 i_atime; + struct timespec64 i_mtime; + struct timespec64 i_ctime; + spinlock_t i_lock; + short unsigned int i_bytes; + u8 i_blkbits; + u8 i_write_hint; + blkcnt_t i_blocks; + long unsigned int i_state; + struct rw_semaphore i_rwsem; + long unsigned int dirtied_when; + long unsigned int dirtied_time_when; + struct hlist_node i_hash; + struct list_head i_io_list; + struct bdi_writeback *i_wb; + int i_wb_frn_winner; + u16 i_wb_frn_avg_time; + u16 i_wb_frn_history; + struct list_head i_lru; + struct list_head i_sb_list; + struct list_head i_wb_list; + union { + struct hlist_head i_dentry; + struct callback_head i_rcu; + }; + atomic64_t i_version; + atomic64_t i_sequence; + atomic_t i_count; + atomic_t i_dio_count; + atomic_t i_writecount; + atomic_t i_readcount; + union { + const struct file_operations *i_fop; + void (*free_inode)(struct inode *); + }; + struct file_lock_context *i_flctx; + struct address_space i_data; + struct list_head i_devices; + union { + struct pipe_inode_info *i_pipe; + struct block_device *i_bdev; + struct cdev *i_cdev; + char *i_link; + unsigned int i_dir_seq; + }; + __u32 i_generation; + __u32 i_fsnotify_mask; + struct fsnotify_mark_connector *i_fsnotify_marks; + void *i_private; +}; + +struct dentry_operations { + int (*d_revalidate)(struct dentry *, unsigned int); + int (*d_weak_revalidate)(struct dentry *, unsigned int); + int (*d_hash)(const struct dentry *, struct qstr *); + int (*d_compare)(const struct dentry *, unsigned int, const char *, const struct qstr *); + int (*d_delete)(const struct dentry *); + int (*d_init)(struct dentry *); + void (*d_release)(struct dentry *); + void (*d_prune)(struct dentry *); + void (*d_iput)(struct dentry *, struct inode *); + char * (*d_dname)(struct dentry *, char *, int); + struct vfsmount * (*d_automount)(struct path *); + int (*d_manage)(const struct path *, bool); + struct dentry * (*d_real)(struct dentry *, const struct inode *); + long: 64; + long: 64; + long: 64; +}; + +struct mtd_info; + +typedef long long int qsize_t; + +struct quota_format_type; + +struct mem_dqinfo { + struct quota_format_type *dqi_format; + int dqi_fmt_id; + struct list_head dqi_dirty_list; + long unsigned int dqi_flags; + unsigned int dqi_bgrace; + unsigned int dqi_igrace; + qsize_t dqi_max_spc_limit; + qsize_t dqi_max_ino_limit; + void *dqi_priv; +}; + +struct quota_format_ops; + +struct quota_info { + unsigned int flags; + struct rw_semaphore dqio_sem; + struct inode *files[3]; + struct mem_dqinfo info[3]; + const struct quota_format_ops *ops[3]; +}; + +struct rcu_sync { + int gp_state; + int gp_count; + wait_queue_head_t gp_wait; + struct callback_head cb_head; +}; + +struct rcuwait { + struct task_struct *task; +}; + +struct percpu_rw_semaphore { + struct rcu_sync rss; + unsigned int *read_count; + struct rcuwait writer; + wait_queue_head_t waiters; + atomic_t block; +}; + +struct sb_writers { + int frozen; + wait_queue_head_t wait_unfrozen; + struct percpu_rw_semaphore rw_sem[3]; +}; + +typedef struct { + __u8 b[16]; +} uuid_t; + +struct list_lru_node; + +struct list_lru { + struct list_lru_node *node; + struct list_head list; + int shrinker_id; + bool memcg_aware; +}; + +struct super_operations; + +struct dquot_operations; + +struct quotactl_ops; + +struct export_operations; + +struct xattr_handler; + +struct workqueue_struct; + +struct super_block { + struct list_head s_list; + dev_t s_dev; + unsigned char s_blocksize_bits; + long unsigned int s_blocksize; + loff_t s_maxbytes; + struct file_system_type *s_type; + const struct super_operations *s_op; + const struct dquot_operations *dq_op; + const struct quotactl_ops *s_qcop; + const struct export_operations *s_export_op; + long unsigned int s_flags; + long unsigned int s_iflags; + long unsigned int s_magic; + struct dentry *s_root; + struct rw_semaphore s_umount; + int s_count; + atomic_t s_active; + void *s_security; + const struct xattr_handler **s_xattr; + struct hlist_bl_head s_roots; + struct list_head s_mounts; + struct block_device *s_bdev; + struct backing_dev_info *s_bdi; + struct mtd_info *s_mtd; + struct hlist_node s_instances; + unsigned int s_quota_types; + struct quota_info s_dquot; + struct sb_writers s_writers; + void *s_fs_info; + u32 s_time_gran; + time64_t s_time_min; + time64_t s_time_max; + __u32 s_fsnotify_mask; + struct fsnotify_mark_connector *s_fsnotify_marks; + char s_id[32]; + uuid_t s_uuid; + unsigned int s_max_links; + fmode_t s_mode; + struct mutex s_vfs_rename_mutex; + const char *s_subtype; + const struct dentry_operations *s_d_op; + int cleancache_poolid; + struct shrinker s_shrink; + atomic_long_t s_remove_count; + atomic_long_t s_fsnotify_inode_refs; + int s_readonly_remount; + errseq_t s_wb_err; + struct workqueue_struct *s_dio_done_wq; + struct hlist_head s_pins; + struct user_namespace *s_user_ns; + struct list_lru s_dentry_lru; + struct list_lru s_inode_lru; + struct callback_head rcu; + struct work_struct destroy_work; + struct mutex s_sync_lock; + int s_stack_depth; + long: 32; + long: 64; + spinlock_t s_inode_list_lock; + struct list_head s_inodes; + spinlock_t s_inode_wblist_lock; + struct list_head s_inodes_wb; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct kstat { + u32 result_mask; + umode_t mode; + unsigned int nlink; + uint32_t blksize; + u64 attributes; + u64 attributes_mask; + u64 ino; + dev_t dev; + dev_t rdev; + kuid_t uid; + kgid_t gid; + loff_t size; + struct timespec64 atime; + struct timespec64 mtime; + struct timespec64 ctime; + struct timespec64 btime; + u64 blocks; + u64 mnt_id; +}; + +struct list_lru_one { + struct list_head list; + long int nr_items; +}; + +struct list_lru_memcg { + struct callback_head rcu; + struct list_lru_one *lru[0]; +}; + +struct list_lru_node { + spinlock_t lock; + struct list_lru_one lru; + struct list_lru_memcg *memcg_lrus; + long int nr_items; +}; + +enum migrate_mode { + MIGRATE_ASYNC = 0, + MIGRATE_SYNC_LIGHT = 1, + MIGRATE_SYNC = 2, + MIGRATE_SYNC_NO_COPY = 3, +}; + +struct key_tag { + struct callback_head rcu; + refcount_t usage; + bool removed; +}; + +typedef int (*request_key_actor_t)(struct key *, void *); + +struct key_preparsed_payload; + +struct key_match_data; + +struct kernel_pkey_params; + +struct kernel_pkey_query; + +struct key_type { + const char *name; + size_t def_datalen; + unsigned int flags; + int (*vet_description)(const char *); + int (*preparse)(struct key_preparsed_payload *); + void (*free_preparse)(struct key_preparsed_payload *); + int (*instantiate)(struct key *, struct key_preparsed_payload *); + int (*update)(struct key *, struct key_preparsed_payload *); + int (*match_preparse)(struct key_match_data *); + void (*match_free)(struct key_match_data *); + void (*revoke)(struct key *); + void (*destroy)(struct key *); + void (*describe)(const struct key *, struct seq_file *); + long int (*read)(const struct key *, char *, size_t); + request_key_actor_t request_key; + struct key_restriction * (*lookup_restriction)(const char *); + int (*asym_query)(const struct kernel_pkey_params *, struct kernel_pkey_query *); + int (*asym_eds_op)(struct kernel_pkey_params *, const void *, void *); + int (*asym_verify_signature)(struct kernel_pkey_params *, const void *, const void *); + struct list_head link; + struct lock_class_key lock_class; +}; + +typedef int (*key_restrict_link_func_t)(struct key *, const struct key_type *, const union key_payload *, struct key *); + +struct key_restriction { + key_restrict_link_func_t check; + struct key *key; + struct key_type *keytype; +}; + +struct group_info { + atomic_t usage; + int ngroups; + kgid_t gid[0]; +}; + +struct delayed_call { + void (*fn)(void *); + void *arg; +}; + +struct io_cq { + struct request_queue *q; + struct io_context *ioc; + union { + struct list_head q_node; + struct kmem_cache *__rcu_icq_cache; + }; + union { + struct hlist_node ioc_node; + struct callback_head __rcu_head; + }; + unsigned int flags; +}; + +struct wait_page_queue; + +struct kiocb { + struct file *ki_filp; + loff_t ki_pos; + void (*ki_complete)(struct kiocb *, long int, long int); + void *private; + int ki_flags; + u16 ki_hint; + u16 ki_ioprio; + union { + unsigned int ki_cookie; + struct wait_page_queue *ki_waitq; + }; +}; + +struct iattr { + unsigned int ia_valid; + umode_t ia_mode; + kuid_t ia_uid; + kgid_t ia_gid; + loff_t ia_size; + struct timespec64 ia_atime; + struct timespec64 ia_mtime; + struct timespec64 ia_ctime; + struct file *ia_file; +}; + +typedef __kernel_uid32_t projid_t; + +typedef struct { + projid_t val; +} kprojid_t; + +enum quota_type { + USRQUOTA = 0, + GRPQUOTA = 1, + PRJQUOTA = 2, +}; + +struct kqid { + union { + kuid_t uid; + kgid_t gid; + kprojid_t projid; + }; + enum quota_type type; +}; + +struct mem_dqblk { + qsize_t dqb_bhardlimit; + qsize_t dqb_bsoftlimit; + qsize_t dqb_curspace; + qsize_t dqb_rsvspace; + qsize_t dqb_ihardlimit; + qsize_t dqb_isoftlimit; + qsize_t dqb_curinodes; + time64_t dqb_btime; + time64_t dqb_itime; +}; + +struct dquot { + struct hlist_node dq_hash; + struct list_head dq_inuse; + struct list_head dq_free; + struct list_head dq_dirty; + struct mutex dq_lock; + spinlock_t dq_dqb_lock; + atomic_t dq_count; + struct super_block *dq_sb; + struct kqid dq_id; + loff_t dq_off; + long unsigned int dq_flags; + struct mem_dqblk dq_dqb; +}; + +enum { + DQF_ROOT_SQUASH_B = 0, + DQF_SYS_FILE_B = 16, + DQF_PRIVATE = 17, +}; + +struct quota_format_type { + int qf_fmt_id; + const struct quota_format_ops *qf_ops; + struct module *qf_owner; + struct quota_format_type *qf_next; +}; + +enum { + DQST_LOOKUPS = 0, + DQST_DROPS = 1, + DQST_READS = 2, + DQST_WRITES = 3, + DQST_CACHE_HITS = 4, + DQST_ALLOC_DQUOTS = 5, + DQST_FREE_DQUOTS = 6, + DQST_SYNCS = 7, + _DQST_DQSTAT_LAST = 8, +}; + +struct quota_format_ops { + int (*check_quota_file)(struct super_block *, int); + int (*read_file_info)(struct super_block *, int); + int (*write_file_info)(struct super_block *, int); + int (*free_file_info)(struct super_block *, int); + int (*read_dqblk)(struct dquot *); + int (*commit_dqblk)(struct dquot *); + int (*release_dqblk)(struct dquot *); + int (*get_next_id)(struct super_block *, struct kqid *); +}; + +struct dquot_operations { + int (*write_dquot)(struct dquot *); + struct dquot * (*alloc_dquot)(struct super_block *, int); + void (*destroy_dquot)(struct dquot *); + int (*acquire_dquot)(struct dquot *); + int (*release_dquot)(struct dquot *); + int (*mark_dirty)(struct dquot *); + int (*write_info)(struct super_block *, int); + qsize_t * (*get_reserved_space)(struct inode *); + int (*get_projid)(struct inode *, kprojid_t *); + int (*get_inode_usage)(struct inode *, qsize_t *); + int (*get_next_id)(struct super_block *, struct kqid *); +}; + +struct qc_dqblk { + int d_fieldmask; + u64 d_spc_hardlimit; + u64 d_spc_softlimit; + u64 d_ino_hardlimit; + u64 d_ino_softlimit; + u64 d_space; + u64 d_ino_count; + s64 d_ino_timer; + s64 d_spc_timer; + int d_ino_warns; + int d_spc_warns; + u64 d_rt_spc_hardlimit; + u64 d_rt_spc_softlimit; + u64 d_rt_space; + s64 d_rt_spc_timer; + int d_rt_spc_warns; +}; + +struct qc_type_state { + unsigned int flags; + unsigned int spc_timelimit; + unsigned int ino_timelimit; + unsigned int rt_spc_timelimit; + unsigned int spc_warnlimit; + unsigned int ino_warnlimit; + unsigned int rt_spc_warnlimit; + long long unsigned int ino; + blkcnt_t blocks; + blkcnt_t nextents; +}; + +struct qc_state { + unsigned int s_incoredqs; + struct qc_type_state s_state[3]; +}; + +struct qc_info { + int i_fieldmask; + unsigned int i_flags; + unsigned int i_spc_timelimit; + unsigned int i_ino_timelimit; + unsigned int i_rt_spc_timelimit; + unsigned int i_spc_warnlimit; + unsigned int i_ino_warnlimit; + unsigned int i_rt_spc_warnlimit; +}; + +struct quotactl_ops { + int (*quota_on)(struct super_block *, int, int, const struct path *); + int (*quota_off)(struct super_block *, int); + int (*quota_enable)(struct super_block *, unsigned int); + int (*quota_disable)(struct super_block *, unsigned int); + int (*quota_sync)(struct super_block *, int); + int (*set_info)(struct super_block *, int, struct qc_info *); + int (*get_dqblk)(struct super_block *, struct kqid, struct qc_dqblk *); + int (*get_nextdqblk)(struct super_block *, struct kqid *, struct qc_dqblk *); + int (*set_dqblk)(struct super_block *, struct kqid, struct qc_dqblk *); + int (*get_state)(struct super_block *, struct qc_state *); + int (*rm_xquota)(struct super_block *, unsigned int); +}; + +struct writeback_control; + +struct readahead_control; + +struct swap_info_struct; + +struct address_space_operations { + int (*writepage)(struct page *, struct writeback_control *); + int (*readpage)(struct file *, struct page *); + int (*writepages)(struct address_space *, struct writeback_control *); + int (*set_page_dirty)(struct page *); + int (*readpages)(struct file *, struct address_space *, struct list_head *, unsigned int); + void (*readahead)(struct readahead_control *); + int (*write_begin)(struct file *, struct address_space *, loff_t, unsigned int, unsigned int, struct page **, void **); + int (*write_end)(struct file *, struct address_space *, loff_t, unsigned int, unsigned int, struct page *, void *); + sector_t (*bmap)(struct address_space *, sector_t); + void (*invalidatepage)(struct page *, unsigned int, unsigned int); + int (*releasepage)(struct page *, gfp_t); + void (*freepage)(struct page *); + ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *); + int (*migratepage)(struct address_space *, struct page *, struct page *, enum migrate_mode); + bool (*isolate_page)(struct page *, isolate_mode_t); + void (*putback_page)(struct page *); + int (*launder_page)(struct page *); + int (*is_partially_uptodate)(struct page *, long unsigned int, long unsigned int); + void (*is_dirty_writeback)(struct page *, bool *, bool *); + int (*error_remove_page)(struct address_space *, struct page *); + int (*swap_activate)(struct swap_info_struct *, struct file *, sector_t *); + void (*swap_deactivate)(struct file *); +}; + +struct fiemap_extent_info; + +struct inode_operations { + struct dentry * (*lookup)(struct inode *, struct dentry *, unsigned int); + const char * (*get_link)(struct dentry *, struct inode *, struct delayed_call *); + int (*permission)(struct inode *, int); + struct posix_acl * (*get_acl)(struct inode *, int); + int (*readlink)(struct dentry *, char *, int); + int (*create)(struct inode *, struct dentry *, umode_t, bool); + int (*link)(struct dentry *, struct inode *, struct dentry *); + int (*unlink)(struct inode *, struct dentry *); + int (*symlink)(struct inode *, struct dentry *, const char *); + int (*mkdir)(struct inode *, struct dentry *, umode_t); + int (*rmdir)(struct inode *, struct dentry *); + int (*mknod)(struct inode *, struct dentry *, umode_t, dev_t); + int (*rename)(struct inode *, struct dentry *, struct inode *, struct dentry *, unsigned int); + int (*setattr)(struct dentry *, struct iattr *); + int (*getattr)(const struct path *, struct kstat *, u32, unsigned int); + ssize_t (*listxattr)(struct dentry *, char *, size_t); + int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64, u64); + int (*update_time)(struct inode *, struct timespec64 *, int); + int (*atomic_open)(struct inode *, struct dentry *, struct file *, unsigned int, umode_t); + int (*tmpfile)(struct inode *, struct dentry *, umode_t); + int (*set_acl)(struct inode *, struct posix_acl *, int); + long: 64; + long: 64; + long: 64; +}; + +struct file_lock_context { + spinlock_t flc_lock; + struct list_head flc_flock; + struct list_head flc_posix; + struct list_head flc_lease; +}; + +struct file_lock_operations { + void (*fl_copy_lock)(struct file_lock *, struct file_lock *); + void (*fl_release_private)(struct file_lock *); +}; + +struct nlm_lockowner; + +struct nfs_lock_info { + u32 state; + struct nlm_lockowner *owner; + struct list_head list; +}; + +struct nfs4_lock_state; + +struct nfs4_lock_info { + struct nfs4_lock_state *owner; +}; + +struct fasync_struct; + +struct lock_manager_operations; + +struct file_lock { + struct file_lock *fl_blocker; + struct list_head fl_list; + struct hlist_node fl_link; + struct list_head fl_blocked_requests; + struct list_head fl_blocked_member; + fl_owner_t fl_owner; + unsigned int fl_flags; + unsigned char fl_type; + unsigned int fl_pid; + int fl_link_cpu; + wait_queue_head_t fl_wait; + struct file *fl_file; + loff_t fl_start; + loff_t fl_end; + struct fasync_struct *fl_fasync; + long unsigned int fl_break_time; + long unsigned int fl_downgrade_time; + const struct file_lock_operations *fl_ops; + const struct lock_manager_operations *fl_lmops; + union { + struct nfs_lock_info nfs_fl; + struct nfs4_lock_info nfs4_fl; + struct { + struct list_head link; + int state; + unsigned int debug_id; + } afs; + } fl_u; +}; + +struct lock_manager_operations { + fl_owner_t (*lm_get_owner)(fl_owner_t); + void (*lm_put_owner)(fl_owner_t); + void (*lm_notify)(struct file_lock *); + int (*lm_grant)(struct file_lock *, int); + bool (*lm_break)(struct file_lock *); + int (*lm_change)(struct file_lock *, int, struct list_head *); + void (*lm_setup)(struct file_lock *, void **); + bool (*lm_breaker_owns_lease)(struct file_lock *); +}; + +struct fasync_struct { + rwlock_t fa_lock; + int magic; + int fa_fd; + struct fasync_struct *fa_next; + struct file *fa_file; + struct callback_head fa_rcu; +}; + +enum { + SB_UNFROZEN = 0, + SB_FREEZE_WRITE = 1, + SB_FREEZE_PAGEFAULT = 2, + SB_FREEZE_FS = 3, + SB_FREEZE_COMPLETE = 4, +}; + +struct kstatfs; + +struct super_operations { + struct inode * (*alloc_inode)(struct super_block *); + void (*destroy_inode)(struct inode *); + void (*free_inode)(struct inode *); + void (*dirty_inode)(struct inode *, int); + int (*write_inode)(struct inode *, struct writeback_control *); + int (*drop_inode)(struct inode *); + void (*evict_inode)(struct inode *); + void (*put_super)(struct super_block *); + int (*sync_fs)(struct super_block *, int); + int (*freeze_super)(struct super_block *); + int (*freeze_fs)(struct super_block *); + int (*thaw_super)(struct super_block *); + int (*unfreeze_fs)(struct super_block *); + int (*statfs)(struct dentry *, struct kstatfs *); + int (*remount_fs)(struct super_block *, int *, char *); + void (*umount_begin)(struct super_block *); + int (*show_options)(struct seq_file *, struct dentry *); + int (*show_devname)(struct seq_file *, struct dentry *); + int (*show_path)(struct seq_file *, struct dentry *); + int (*show_stats)(struct seq_file *, struct dentry *); + ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); + ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); + struct dquot ** (*get_dquots)(struct inode *); + int (*bdev_try_to_free_page)(struct super_block *, struct page *, gfp_t); + long int (*nr_cached_objects)(struct super_block *, struct shrink_control *); + long int (*free_cached_objects)(struct super_block *, struct shrink_control *); +}; + +struct iomap; + +struct fid; + +struct export_operations { + int (*encode_fh)(struct inode *, __u32 *, int *, struct inode *); + struct dentry * (*fh_to_dentry)(struct super_block *, struct fid *, int, int); + struct dentry * (*fh_to_parent)(struct super_block *, struct fid *, int, int); + int (*get_name)(struct dentry *, char *, struct dentry *); + struct dentry * (*get_parent)(struct dentry *); + int (*commit_metadata)(struct inode *); + int (*get_uuid)(struct super_block *, u8 *, u32 *, u64 *); + int (*map_blocks)(struct inode *, loff_t, u64, struct iomap *, bool, u32 *); + int (*commit_blocks)(struct inode *, struct iomap *, int, struct iattr *); +}; + +struct xattr_handler { + const char *name; + const char *prefix; + int flags; + bool (*list)(struct dentry *); + int (*get)(const struct xattr_handler *, struct dentry *, struct inode *, const char *, void *, size_t); + int (*set)(const struct xattr_handler *, struct dentry *, struct inode *, const char *, const void *, size_t, int); +}; + +typedef int (*filldir_t)(struct dir_context *, const char *, int, loff_t, u64, unsigned int); + +struct dir_context { + filldir_t actor; + loff_t pos; +}; + +struct p_log; + +struct fs_parameter; + +struct fs_parse_result; + +typedef int fs_param_type(struct p_log *, const struct fs_parameter_spec *, struct fs_parameter *, struct fs_parse_result *); + +struct fs_parameter_spec { + const char *name; + fs_param_type *type; + u8 opt; + short unsigned int flags; + const void *data; +}; + +enum compound_dtor_id { + NULL_COMPOUND_DTOR = 0, + COMPOUND_PAGE_DTOR = 1, + HUGETLB_PAGE_DTOR = 2, + TRANSHUGE_PAGE_DTOR = 3, + NR_COMPOUND_DTORS = 4, +}; + +enum vm_event_item { + PGPGIN = 0, + PGPGOUT = 1, + PSWPIN = 2, + PSWPOUT = 3, + PGALLOC_DMA = 4, + PGALLOC_DMA32 = 5, + PGALLOC_NORMAL = 6, + PGALLOC_MOVABLE = 7, + ALLOCSTALL_DMA = 8, + ALLOCSTALL_DMA32 = 9, + ALLOCSTALL_NORMAL = 10, + ALLOCSTALL_MOVABLE = 11, + PGSCAN_SKIP_DMA = 12, + PGSCAN_SKIP_DMA32 = 13, + PGSCAN_SKIP_NORMAL = 14, + PGSCAN_SKIP_MOVABLE = 15, + PGFREE = 16, + PGACTIVATE = 17, + PGDEACTIVATE = 18, + PGLAZYFREE = 19, + PGFAULT = 20, + PGMAJFAULT = 21, + PGLAZYFREED = 22, + PGREFILL = 23, + PGREUSE = 24, + PGSTEAL_KSWAPD = 25, + PGSTEAL_DIRECT = 26, + PGSCAN_KSWAPD = 27, + PGSCAN_DIRECT = 28, + PGSCAN_DIRECT_THROTTLE = 29, + PGSCAN_ANON = 30, + PGSCAN_FILE = 31, + PGSTEAL_ANON = 32, + PGSTEAL_FILE = 33, + PGSCAN_ZONE_RECLAIM_FAILED = 34, + PGINODESTEAL = 35, + SLABS_SCANNED = 36, + KSWAPD_INODESTEAL = 37, + KSWAPD_LOW_WMARK_HIT_QUICKLY = 38, + KSWAPD_HIGH_WMARK_HIT_QUICKLY = 39, + PAGEOUTRUN = 40, + PGROTATED = 41, + DROP_PAGECACHE = 42, + DROP_SLAB = 43, + OOM_KILL = 44, + NUMA_PTE_UPDATES = 45, + NUMA_HUGE_PTE_UPDATES = 46, + NUMA_HINT_FAULTS = 47, + NUMA_HINT_FAULTS_LOCAL = 48, + NUMA_PAGE_MIGRATE = 49, + PGMIGRATE_SUCCESS = 50, + PGMIGRATE_FAIL = 51, + THP_MIGRATION_SUCCESS = 52, + THP_MIGRATION_FAIL = 53, + THP_MIGRATION_SPLIT = 54, + COMPACTMIGRATE_SCANNED = 55, + COMPACTFREE_SCANNED = 56, + COMPACTISOLATED = 57, + COMPACTSTALL = 58, + COMPACTFAIL = 59, + COMPACTSUCCESS = 60, + KCOMPACTD_WAKE = 61, + KCOMPACTD_MIGRATE_SCANNED = 62, + KCOMPACTD_FREE_SCANNED = 63, + HTLB_BUDDY_PGALLOC = 64, + HTLB_BUDDY_PGALLOC_FAIL = 65, + UNEVICTABLE_PGCULLED = 66, + UNEVICTABLE_PGSCANNED = 67, + UNEVICTABLE_PGRESCUED = 68, + UNEVICTABLE_PGMLOCKED = 69, + UNEVICTABLE_PGMUNLOCKED = 70, + UNEVICTABLE_PGCLEARED = 71, + UNEVICTABLE_PGSTRANDED = 72, + THP_FAULT_ALLOC = 73, + THP_FAULT_FALLBACK = 74, + THP_FAULT_FALLBACK_CHARGE = 75, + THP_COLLAPSE_ALLOC = 76, + THP_COLLAPSE_ALLOC_FAILED = 77, + THP_FILE_ALLOC = 78, + THP_FILE_FALLBACK = 79, + THP_FILE_FALLBACK_CHARGE = 80, + THP_FILE_MAPPED = 81, + THP_SPLIT_PAGE = 82, + THP_SPLIT_PAGE_FAILED = 83, + THP_DEFERRED_SPLIT_PAGE = 84, + THP_SPLIT_PMD = 85, + THP_SPLIT_PUD = 86, + THP_ZERO_PAGE_ALLOC = 87, + THP_ZERO_PAGE_ALLOC_FAILED = 88, + THP_SWPOUT = 89, + THP_SWPOUT_FALLBACK = 90, + BALLOON_INFLATE = 91, + BALLOON_DEFLATE = 92, + BALLOON_MIGRATE = 93, + SWAP_RA = 94, + SWAP_RA_HIT = 95, + NR_VM_EVENT_ITEMS = 96, +}; + +struct tlb_context { + u64 ctx_id; + u64 tlb_gen; +}; + +struct tlb_state { + struct mm_struct *loaded_mm; + union { + struct mm_struct *last_user_mm; + long unsigned int last_user_mm_ibpb; + }; + u16 loaded_mm_asid; + u16 next_asid; + bool is_lazy; + bool invalidate_other; + short unsigned int user_pcid_flush_mask; + long unsigned int cr4; + struct tlb_context ctxs[6]; +}; + +struct boot_params_to_save { + unsigned int start; + unsigned int len; +}; + +enum cpu_idle_type { + CPU_IDLE = 0, + CPU_NOT_IDLE = 1, + CPU_NEWLY_IDLE = 2, + CPU_MAX_IDLE_TYPES = 3, +}; + +enum { + __SD_BALANCE_NEWIDLE = 0, + __SD_BALANCE_EXEC = 1, + __SD_BALANCE_FORK = 2, + __SD_BALANCE_WAKE = 3, + __SD_WAKE_AFFINE = 4, + __SD_ASYM_CPUCAPACITY = 5, + __SD_SHARE_CPUCAPACITY = 6, + __SD_SHARE_PKG_RESOURCES = 7, + __SD_SERIALIZE = 8, + __SD_ASYM_PACKING = 9, + __SD_PREFER_SIBLING = 10, + __SD_OVERLAP = 11, + __SD_NUMA = 12, + __SD_FLAG_CNT = 13, +}; + +struct x86_legacy_devices { + int pnpbios; +}; + +enum x86_legacy_i8042_state { + X86_LEGACY_I8042_PLATFORM_ABSENT = 0, + X86_LEGACY_I8042_FIRMWARE_ABSENT = 1, + X86_LEGACY_I8042_EXPECTED_PRESENT = 2, +}; + +struct x86_legacy_features { + enum x86_legacy_i8042_state i8042; + int rtc; + int warm_reset; + int no_vga; + int reserve_bios_regions; + struct x86_legacy_devices devices; +}; + +struct ghcb; + +struct x86_hyper_runtime { + void (*pin_vcpu)(int); + void (*sev_es_hcall_prepare)(struct ghcb *, struct pt_regs *); + bool (*sev_es_hcall_finish)(struct ghcb *, struct pt_regs *); +}; + +struct x86_platform_ops { + long unsigned int (*calibrate_cpu)(); + long unsigned int (*calibrate_tsc)(); + void (*get_wallclock)(struct timespec64 *); + int (*set_wallclock)(const struct timespec64 *); + void (*iommu_shutdown)(); + bool (*is_untracked_pat_range)(u64, u64); + void (*nmi_init)(); + unsigned char (*get_nmi_reason)(); + void (*save_sched_clock_state)(); + void (*restore_sched_clock_state)(); + void (*apic_post_init)(); + struct x86_legacy_features legacy; + void (*set_legacy_features)(); + struct x86_hyper_runtime hyper; +}; + +typedef signed char __s8; + +typedef short int __s16; + +typedef __s8 s8; + +typedef __s16 s16; + +typedef long unsigned int irq_hw_number_t; + +struct kernel_symbol { + int value_offset; + int name_offset; + int namespace_offset; +}; + +typedef int (*initcall_t)(); + +typedef int initcall_entry_t; + +struct obs_kernel_param { + const char *str; + int (*setup_func)(char *); + int early; +}; + +struct lockdep_map {}; + +enum system_states { + SYSTEM_BOOTING = 0, + SYSTEM_SCHEDULING = 1, + SYSTEM_RUNNING = 2, + SYSTEM_HALT = 3, + SYSTEM_POWER_OFF = 4, + SYSTEM_RESTART = 5, + SYSTEM_SUSPEND = 6, +}; + +struct jump_entry { + s32 code; + s32 target; + long int key; +}; + +struct static_key_mod; + +struct static_key { + atomic_t enabled; + union { + long unsigned int type; + struct jump_entry *entries; + struct static_key_mod *next; + }; +}; + +struct static_key_false { + struct static_key key; +}; + +struct bug_entry { + int bug_addr_disp; + int file_disp; + short unsigned int line; + short unsigned int flags; +}; + +typedef struct cpumask cpumask_var_t[1]; + +struct tracepoint_func { + void *func; + void *data; + int prio; +}; + +struct static_call_key; + +struct tracepoint { + const char *name; + struct static_key key; + struct static_call_key *static_call_key; + void *static_call_tramp; + void *iterator; + int (*regfunc)(); + void (*unregfunc)(); + struct tracepoint_func *funcs; +}; + +struct static_call_mod; + +struct static_call_site; + +struct static_call_key { + void *func; + union { + long unsigned int type; + struct static_call_mod *mods; + struct static_call_site *sites; + }; +}; + +typedef const int tracepoint_ptr_t; + +struct bpf_raw_event_map { + struct tracepoint *tp; + void *bpf_func; + u32 num_args; + u32 writable_size; + long: 64; +}; + +struct orc_entry { + s16 sp_offset; + s16 bp_offset; + unsigned int sp_reg: 4; + unsigned int bp_reg: 4; + unsigned int type: 2; + unsigned int end: 1; +} __attribute__((packed)); + +struct seq_operations { + void * (*start)(struct seq_file *, loff_t *); + void (*stop)(struct seq_file *, void *); + void * (*next)(struct seq_file *, void *, loff_t *); + int (*show)(struct seq_file *, void *); +}; + +enum perf_event_state { + PERF_EVENT_STATE_DEAD = 4294967292, + PERF_EVENT_STATE_EXIT = 4294967293, + PERF_EVENT_STATE_ERROR = 4294967294, + PERF_EVENT_STATE_OFF = 4294967295, + PERF_EVENT_STATE_INACTIVE = 0, + PERF_EVENT_STATE_ACTIVE = 1, +}; + +typedef struct { + atomic_long_t a; +} local_t; + +typedef struct { + local_t a; +} local64_t; + +struct perf_event_attr { + __u32 type; + __u32 size; + __u64 config; + union { + __u64 sample_period; + __u64 sample_freq; + }; + __u64 sample_type; + __u64 read_format; + __u64 disabled: 1; + __u64 inherit: 1; + __u64 pinned: 1; + __u64 exclusive: 1; + __u64 exclude_user: 1; + __u64 exclude_kernel: 1; + __u64 exclude_hv: 1; + __u64 exclude_idle: 1; + __u64 mmap: 1; + __u64 comm: 1; + __u64 freq: 1; + __u64 inherit_stat: 1; + __u64 enable_on_exec: 1; + __u64 task: 1; + __u64 watermark: 1; + __u64 precise_ip: 2; + __u64 mmap_data: 1; + __u64 sample_id_all: 1; + __u64 exclude_host: 1; + __u64 exclude_guest: 1; + __u64 exclude_callchain_kernel: 1; + __u64 exclude_callchain_user: 1; + __u64 mmap2: 1; + __u64 comm_exec: 1; + __u64 use_clockid: 1; + __u64 context_switch: 1; + __u64 write_backward: 1; + __u64 namespaces: 1; + __u64 ksymbol: 1; + __u64 bpf_event: 1; + __u64 aux_output: 1; + __u64 cgroup: 1; + __u64 text_poke: 1; + __u64 __reserved_1: 30; + union { + __u32 wakeup_events; + __u32 wakeup_watermark; + }; + __u32 bp_type; + union { + __u64 bp_addr; + __u64 kprobe_func; + __u64 uprobe_path; + __u64 config1; + }; + union { + __u64 bp_len; + __u64 kprobe_addr; + __u64 probe_offset; + __u64 config2; + }; + __u64 branch_sample_type; + __u64 sample_regs_user; + __u32 sample_stack_user; + __s32 clockid; + __u64 sample_regs_intr; + __u32 aux_watermark; + __u16 sample_max_stack; + __u16 __reserved_2; + __u32 aux_sample_size; + __u32 __reserved_3; +}; + +struct hw_perf_event_extra { + u64 config; + unsigned int reg; + int alloc; + int idx; +}; + +struct arch_hw_breakpoint { + long unsigned int address; + long unsigned int mask; + u8 len; + u8 type; +}; + +struct hw_perf_event { + union { + struct { + u64 config; + u64 last_tag; + long unsigned int config_base; + long unsigned int event_base; + int event_base_rdpmc; + int idx; + int last_cpu; + int flags; + struct hw_perf_event_extra extra_reg; + struct hw_perf_event_extra branch_reg; + }; + struct { + struct hrtimer hrtimer; + }; + struct { + struct list_head tp_list; + }; + struct { + u64 pwr_acc; + u64 ptsc; + }; + struct { + struct arch_hw_breakpoint info; + struct list_head bp_list; + }; + struct { + u8 iommu_bank; + u8 iommu_cntr; + u16 padding; + u64 conf; + u64 conf1; + }; + }; + struct task_struct *target; + void *addr_filters; + long unsigned int addr_filters_gen; + int state; + local64_t prev_count; + u64 sample_period; + union { + struct { + u64 last_period; + local64_t period_left; + }; + struct { + u64 saved_metric; + u64 saved_slots; + }; + }; + u64 interrupts_seq; + u64 interrupts; + u64 freq_time_stamp; + u64 freq_count_stamp; +}; + +struct irq_work { + union { + struct __call_single_node node; + struct { + struct llist_node llnode; + atomic_t flags; + }; + }; + void (*func)(struct irq_work *); +}; + +struct perf_addr_filters_head { + struct list_head list; + raw_spinlock_t lock; + unsigned int nr_file_filters; +}; + +struct perf_sample_data; + +typedef void (*perf_overflow_handler_t)(struct perf_event *, struct perf_sample_data *, struct pt_regs *); + +struct ftrace_ops; + +typedef void (*ftrace_func_t)(long unsigned int, long unsigned int, struct ftrace_ops *, struct pt_regs *); + +struct ftrace_hash; + +struct ftrace_ops_hash { + struct ftrace_hash *notrace_hash; + struct ftrace_hash *filter_hash; + struct mutex regex_lock; +}; + +struct ftrace_ops { + ftrace_func_t func; + struct ftrace_ops *next; + long unsigned int flags; + void *private; + ftrace_func_t saved_func; + struct ftrace_ops_hash local_hash; + struct ftrace_ops_hash *func_hash; + struct ftrace_ops_hash old_hash; + long unsigned int trampoline; + long unsigned int trampoline_size; + struct list_head list; +}; + +struct pmu; + +struct perf_buffer; + +struct perf_addr_filter_range; + +struct bpf_prog; + +struct trace_event_call; + +struct event_filter; + +struct perf_cgroup; + +struct perf_event { + struct list_head event_entry; + struct list_head sibling_list; + struct list_head active_list; + struct rb_node group_node; + u64 group_index; + struct list_head migrate_entry; + struct hlist_node hlist_entry; + struct list_head active_entry; + int nr_siblings; + int event_caps; + int group_caps; + struct perf_event *group_leader; + struct pmu *pmu; + void *pmu_private; + enum perf_event_state state; + unsigned int attach_state; + local64_t count; + atomic64_t child_count; + u64 total_time_enabled; + u64 total_time_running; + u64 tstamp; + u64 shadow_ctx_time; + struct perf_event_attr attr; + u16 header_size; + u16 id_header_size; + u16 read_size; + struct hw_perf_event hw; + struct perf_event_context *ctx; + atomic_long_t refcount; + atomic64_t child_total_time_enabled; + atomic64_t child_total_time_running; + struct mutex child_mutex; + struct list_head child_list; + struct perf_event *parent; + int oncpu; + int cpu; + struct list_head owner_entry; + struct task_struct *owner; + struct mutex mmap_mutex; + atomic_t mmap_count; + struct perf_buffer *rb; + struct list_head rb_entry; + long unsigned int rcu_batches; + int rcu_pending; + wait_queue_head_t waitq; + struct fasync_struct *fasync; + int pending_wakeup; + int pending_kill; + int pending_disable; + struct irq_work pending; + atomic_t event_limit; + struct perf_addr_filters_head addr_filters; + struct perf_addr_filter_range *addr_filter_ranges; + long unsigned int addr_filters_gen; + struct perf_event *aux_event; + void (*destroy)(struct perf_event *); + struct callback_head callback_head; + struct pid_namespace *ns; + u64 id; + u64 (*clock)(); + perf_overflow_handler_t overflow_handler; + void *overflow_handler_context; + perf_overflow_handler_t orig_overflow_handler; + struct bpf_prog *prog; + struct trace_event_call *tp_event; + struct event_filter *filter; + struct ftrace_ops ftrace_ops; + struct perf_cgroup *cgrp; + void *security; + struct list_head sb_list; +}; + +struct uid_gid_extent { + u32 first; + u32 lower_first; + u32 count; +}; + +struct uid_gid_map { + u32 nr_extents; + union { + struct uid_gid_extent extent[5]; + struct { + struct uid_gid_extent *forward; + struct uid_gid_extent *reverse; + }; + }; +}; + +struct proc_ns_operations; + +struct ns_common { + atomic_long_t stashed; + const struct proc_ns_operations *ops; + unsigned int inum; +}; + +struct ctl_table; + +struct ctl_table_root; + +struct ctl_table_set; + +struct ctl_dir; + +struct ctl_node; + +struct ctl_table_header { + union { + struct { + struct ctl_table *ctl_table; + int used; + int count; + int nreg; + }; + struct callback_head rcu; + }; + struct completion *unregistering; + struct ctl_table *ctl_table_arg; + struct ctl_table_root *root; + struct ctl_table_set *set; + struct ctl_dir *parent; + struct ctl_node *node; + struct hlist_head inodes; +}; + +struct ctl_dir { + struct ctl_table_header header; + struct rb_root root; +}; + +struct ctl_table_set { + int (*is_seen)(struct ctl_table_set *); + struct ctl_dir dir; +}; + +struct ucounts; + +struct user_namespace { + struct uid_gid_map uid_map; + struct uid_gid_map gid_map; + struct uid_gid_map projid_map; + atomic_t count; + struct user_namespace *parent; + int level; + kuid_t owner; + kgid_t group; + struct ns_common ns; + long unsigned int flags; + struct list_head keyring_name_list; + struct key *user_keyring_register; + struct rw_semaphore keyring_sem; + struct work_struct work; + struct ctl_table_set set; + struct ctl_table_header *sysctls; + struct ucounts *ucounts; + int ucount_max[10]; +}; + +struct pollfd { + int fd; + short int events; + short int revents; +}; + +typedef void (*smp_call_func_t)(void *); + +struct __call_single_data { + union { + struct __call_single_node node; + struct { + struct llist_node llist; + unsigned int flags; + u16 src; + u16 dst; + }; + }; + smp_call_func_t func; + void *info; +}; + +struct smp_ops { + void (*smp_prepare_boot_cpu)(); + void (*smp_prepare_cpus)(unsigned int); + void (*smp_cpus_done)(unsigned int); + void (*stop_other_cpus)(int); + void (*crash_stop_other_cpus)(); + void (*smp_send_reschedule)(int); + int (*cpu_up)(unsigned int, struct task_struct *); + int (*cpu_disable)(); + void (*cpu_die)(unsigned int); + void (*play_dead)(); + void (*send_call_func_ipi)(const struct cpumask *); + void (*send_call_func_single_ipi)(int); +}; + +struct wait_queue_entry; + +typedef int (*wait_queue_func_t)(struct wait_queue_entry *, unsigned int, int, void *); + +struct wait_queue_entry { + unsigned int flags; + void *private; + wait_queue_func_t func; + struct list_head entry; +}; + +typedef struct wait_queue_entry wait_queue_entry_t; + +struct timer_list { + struct hlist_node entry; + long unsigned int expires; + void (*function)(struct timer_list *); + u32 flags; +}; + +struct delayed_work { + struct work_struct work; + struct timer_list timer; + struct workqueue_struct *wq; + int cpu; +}; + +struct rcu_work { + struct work_struct work; + struct callback_head rcu; + struct workqueue_struct *wq; +}; + +struct rcu_segcblist { + struct callback_head *head; + struct callback_head **tails[4]; + long unsigned int gp_seq[4]; + long int len; + u8 enabled; + u8 offloaded; +}; + +struct srcu_node; + +struct srcu_struct; + +struct srcu_data { + long unsigned int srcu_lock_count[2]; + long unsigned int srcu_unlock_count[2]; + long: 64; + long: 64; + long: 64; + long: 64; + spinlock_t lock; + struct rcu_segcblist srcu_cblist; + long unsigned int srcu_gp_seq_needed; + long unsigned int srcu_gp_seq_needed_exp; + bool srcu_cblist_invoking; + struct timer_list delay_work; + struct work_struct work; + struct callback_head srcu_barrier_head; + struct srcu_node *mynode; + long unsigned int grpmask; + int cpu; + struct srcu_struct *ssp; +}; + +struct srcu_node { + spinlock_t lock; + long unsigned int srcu_have_cbs[4]; + long unsigned int srcu_data_have_cbs[4]; + long unsigned int srcu_gp_seq_needed_exp; + struct srcu_node *srcu_parent; + int grplo; + int grphi; +}; + +struct srcu_struct { + struct srcu_node node[9]; + struct srcu_node *level[3]; + struct mutex srcu_cb_mutex; + spinlock_t lock; + struct mutex srcu_gp_mutex; + unsigned int srcu_idx; + long unsigned int srcu_gp_seq; + long unsigned int srcu_gp_seq_needed; + long unsigned int srcu_gp_seq_needed_exp; + long unsigned int srcu_last_gp_end; + struct srcu_data *sda; + long unsigned int srcu_barrier_seq; + struct mutex srcu_barrier_mutex; + struct completion srcu_barrier_completion; + atomic_t srcu_barrier_cpu_cnt; + struct delayed_work work; +}; + +struct anon_vma { + struct anon_vma *root; + struct rw_semaphore rwsem; + atomic_t refcount; + unsigned int degree; + struct anon_vma *parent; + struct rb_root_cached rb_root; +}; + +struct mempolicy { + atomic_t refcnt; + short unsigned int mode; + short unsigned int flags; + union { + short int preferred_node; + nodemask_t nodes; + } v; + union { + nodemask_t cpuset_mems_allowed; + nodemask_t user_nodemask; + } w; +}; + +struct linux_binprm; + +struct coredump_params; + +struct linux_binfmt { + struct list_head lh; + struct module *module; + int (*load_binary)(struct linux_binprm *); + int (*load_shlib)(struct file *); + int (*core_dump)(struct coredump_params *); + long unsigned int min_coredump; +}; + +struct free_area { + struct list_head free_list[6]; + long unsigned int nr_free; +}; + +struct zone_padding { + char x[0]; +}; + +struct pglist_data; + +struct lruvec { + struct list_head lists[5]; + long unsigned int anon_cost; + long unsigned int file_cost; + atomic_long_t nonresident_age; + long unsigned int refaults[2]; + long unsigned int flags; + struct pglist_data *pgdat; +}; + +struct per_cpu_pageset; + +struct zone { + long unsigned int _watermark[3]; + long unsigned int watermark_boost; + long unsigned int nr_reserved_highatomic; + long int lowmem_reserve[4]; + int node; + struct pglist_data *zone_pgdat; + struct per_cpu_pageset *pageset; + long unsigned int zone_start_pfn; + atomic_long_t managed_pages; + long unsigned int spanned_pages; + long unsigned int present_pages; + const char *name; + long unsigned int nr_isolate_pageblock; + int initialized; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct zone_padding _pad1_; + struct free_area free_area[11]; + long unsigned int flags; + spinlock_t lock; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct zone_padding _pad2_; + long unsigned int percpu_drift_mark; + long unsigned int compact_cached_free_pfn; + long unsigned int compact_cached_migrate_pfn[2]; + long unsigned int compact_init_migrate_pfn; + long unsigned int compact_init_free_pfn; + unsigned int compact_considered; + unsigned int compact_defer_shift; + int compact_order_failed; + bool compact_blockskip_flush; + bool contiguous; + short: 16; + struct zone_padding _pad3_; + atomic_long_t vm_stat[11]; + atomic_long_t vm_numa_stat[6]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct zoneref { + struct zone *zone; + int zone_idx; +}; + +struct zonelist { + struct zoneref _zonerefs[257]; +}; + +enum zone_type { + ZONE_DMA = 0, + ZONE_DMA32 = 1, + ZONE_NORMAL = 2, + ZONE_MOVABLE = 3, + __MAX_NR_ZONES = 4, +}; + +struct deferred_split { + spinlock_t split_queue_lock; + struct list_head split_queue; + long unsigned int split_queue_len; +}; + +struct per_cpu_nodestat; + +struct pglist_data { + struct zone node_zones[4]; + struct zonelist node_zonelists[2]; + int nr_zones; + long unsigned int node_start_pfn; + long unsigned int node_present_pages; + long unsigned int node_spanned_pages; + int node_id; + wait_queue_head_t kswapd_wait; + wait_queue_head_t pfmemalloc_wait; + struct task_struct *kswapd; + int kswapd_order; + enum zone_type kswapd_highest_zoneidx; + int kswapd_failures; + int kcompactd_max_order; + enum zone_type kcompactd_highest_zoneidx; + wait_queue_head_t kcompactd_wait; + struct task_struct *kcompactd; + long unsigned int totalreserve_pages; + long unsigned int min_unmapped_pages; + long unsigned int min_slab_pages; + struct zone_padding _pad1_; + spinlock_t lru_lock; + struct deferred_split deferred_split_queue; + struct lruvec __lruvec; + long unsigned int flags; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct zone_padding _pad2_; + struct per_cpu_nodestat *per_cpu_nodestats; + atomic_long_t vm_stat[37]; + long: 64; + long: 64; +}; + +struct per_cpu_pages { + int count; + int high; + int batch; + struct list_head lists[3]; +}; + +struct per_cpu_pageset { + struct per_cpu_pages pcp; + s8 expire; + u16 vm_numa_stat_diff[6]; + s8 stat_threshold; + s8 vm_stat_diff[11]; +}; + +struct per_cpu_nodestat { + s8 stat_threshold; + s8 vm_node_stat_diff[37]; +}; + +enum irq_domain_bus_token { + DOMAIN_BUS_ANY = 0, + DOMAIN_BUS_WIRED = 1, + DOMAIN_BUS_GENERIC_MSI = 2, + DOMAIN_BUS_PCI_MSI = 3, + DOMAIN_BUS_PLATFORM_MSI = 4, + DOMAIN_BUS_NEXUS = 5, + DOMAIN_BUS_IPI = 6, + DOMAIN_BUS_FSL_MC_MSI = 7, + DOMAIN_BUS_TI_SCI_INTA_MSI = 8, + DOMAIN_BUS_WAKEUP = 9, + DOMAIN_BUS_VMD_MSI = 10, +}; + +struct irq_domain_ops; + +struct fwnode_handle; + +struct irq_domain_chip_generic; + +struct irq_domain { + struct list_head link; + const char *name; + const struct irq_domain_ops *ops; + void *host_data; + unsigned int flags; + unsigned int mapcount; + struct fwnode_handle *fwnode; + enum irq_domain_bus_token bus_token; + struct irq_domain_chip_generic *gc; + struct irq_domain *parent; + irq_hw_number_t hwirq_max; + unsigned int revmap_direct_max_irq; + unsigned int revmap_size; + struct xarray revmap_tree; + struct mutex revmap_tree_mutex; + unsigned int linear_revmap[0]; +}; + +typedef int proc_handler(struct ctl_table *, int, void *, size_t *, loff_t *); + +struct ctl_table_poll; + +struct ctl_table { + const char *procname; + void *data; + int maxlen; + umode_t mode; + struct ctl_table *child; + proc_handler *proc_handler; + struct ctl_table_poll *poll; + void *extra1; + void *extra2; +}; + +struct ctl_table_poll { + atomic_t event; + wait_queue_head_t wait; +}; + +struct ctl_node { + struct rb_node node; + struct ctl_table_header *header; +}; + +struct ctl_table_root { + struct ctl_table_set default_set; + struct ctl_table_set * (*lookup)(struct ctl_table_root *); + void (*set_ownership)(struct ctl_table_header *, struct ctl_table *, kuid_t *, kgid_t *); + int (*permissions)(struct ctl_table_header *, struct ctl_table *); +}; + +enum umh_disable_depth { + UMH_ENABLED = 0, + UMH_FREEZING = 1, + UMH_DISABLED = 2, +}; + +typedef __u64 Elf64_Addr; + +typedef __u16 Elf64_Half; + +typedef __u32 Elf64_Word; + +typedef __u64 Elf64_Xword; + +struct elf64_sym { + Elf64_Word st_name; + unsigned char st_info; + unsigned char st_other; + Elf64_Half st_shndx; + Elf64_Addr st_value; + Elf64_Xword st_size; +}; + +typedef struct elf64_sym Elf64_Sym; + +struct idr { + struct xarray idr_rt; + unsigned int idr_base; + unsigned int idr_next; +}; + +struct kernfs_root; + +struct kernfs_elem_dir { + long unsigned int subdirs; + struct rb_root children; + struct kernfs_root *root; +}; + +struct kernfs_node; + +struct kernfs_syscall_ops; + +struct kernfs_root { + struct kernfs_node *kn; + unsigned int flags; + struct idr ino_idr; + u32 last_id_lowbits; + u32 id_highbits; + struct kernfs_syscall_ops *syscall_ops; + struct list_head supers; + wait_queue_head_t deactivate_waitq; +}; + +struct kernfs_elem_symlink { + struct kernfs_node *target_kn; +}; + +struct kernfs_ops; + +struct kernfs_open_node; + +struct kernfs_elem_attr { + const struct kernfs_ops *ops; + struct kernfs_open_node *open; + loff_t size; + struct kernfs_node *notify_next; +}; + +struct kernfs_iattrs; + +struct kernfs_node { + atomic_t count; + atomic_t active; + struct kernfs_node *parent; + const char *name; + struct rb_node rb; + const void *ns; + unsigned int hash; + union { + struct kernfs_elem_dir dir; + struct kernfs_elem_symlink symlink; + struct kernfs_elem_attr attr; + }; + void *priv; + u64 id; + short unsigned int flags; + umode_t mode; + struct kernfs_iattrs *iattr; +}; + +struct kernfs_open_file; + +struct kernfs_ops { + int (*open)(struct kernfs_open_file *); + void (*release)(struct kernfs_open_file *); + int (*seq_show)(struct seq_file *, void *); + void * (*seq_start)(struct seq_file *, loff_t *); + void * (*seq_next)(struct seq_file *, void *, loff_t *); + void (*seq_stop)(struct seq_file *, void *); + ssize_t (*read)(struct kernfs_open_file *, char *, size_t, loff_t); + size_t atomic_write_len; + bool prealloc; + ssize_t (*write)(struct kernfs_open_file *, char *, size_t, loff_t); + __poll_t (*poll)(struct kernfs_open_file *, struct poll_table_struct *); + int (*mmap)(struct kernfs_open_file *, struct vm_area_struct *); +}; + +struct kernfs_syscall_ops { + int (*show_options)(struct seq_file *, struct kernfs_root *); + int (*mkdir)(struct kernfs_node *, const char *, umode_t); + int (*rmdir)(struct kernfs_node *); + int (*rename)(struct kernfs_node *, struct kernfs_node *, const char *); + int (*show_path)(struct seq_file *, struct kernfs_node *, struct kernfs_root *); +}; + +struct seq_file { + char *buf; + size_t size; + size_t from; + size_t count; + size_t pad_until; + loff_t index; + loff_t read_pos; + struct mutex lock; + const struct seq_operations *op; + int poll_event; + const struct file *file; + void *private; +}; + +struct kernfs_open_file { + struct kernfs_node *kn; + struct file *file; + struct seq_file *seq_file; + void *priv; + struct mutex mutex; + struct mutex prealloc_mutex; + int event; + struct list_head list; + char *prealloc_buf; + size_t atomic_write_len; + bool mmapped: 1; + bool released: 1; + const struct vm_operations_struct *vm_ops; +}; + +typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *); + +struct poll_table_struct { + poll_queue_proc _qproc; + __poll_t _key; +}; + +enum kobj_ns_type { + KOBJ_NS_TYPE_NONE = 0, + KOBJ_NS_TYPE_NET = 1, + KOBJ_NS_TYPES = 2, +}; + +struct sock; + +struct kobj_ns_type_operations { + enum kobj_ns_type type; + bool (*current_may_mount)(); + void * (*grab_current_ns)(); + const void * (*netlink_ns)(struct sock *); + const void * (*initial_ns)(); + void (*drop_ns)(void *); +}; + +struct attribute { + const char *name; + umode_t mode; +}; + +struct kobject; + +struct bin_attribute; + +struct attribute_group { + const char *name; + umode_t (*is_visible)(struct kobject *, struct attribute *, int); + umode_t (*is_bin_visible)(struct kobject *, struct bin_attribute *, int); + struct attribute **attrs; + struct bin_attribute **bin_attrs; +}; + +struct kref { + refcount_t refcount; +}; + +struct kset; + +struct kobj_type; + +struct kobject { + const char *name; + struct list_head entry; + struct kobject *parent; + struct kset *kset; + struct kobj_type *ktype; + struct kernfs_node *sd; + struct kref kref; + unsigned int state_initialized: 1; + unsigned int state_in_sysfs: 1; + unsigned int state_add_uevent_sent: 1; + unsigned int state_remove_uevent_sent: 1; + unsigned int uevent_suppress: 1; +}; + +struct bin_attribute { + struct attribute attr; + size_t size; + void *private; + ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *, char *, loff_t, size_t); + ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *, char *, loff_t, size_t); + int (*mmap)(struct file *, struct kobject *, struct bin_attribute *, struct vm_area_struct *); +}; + +struct sysfs_ops { + ssize_t (*show)(struct kobject *, struct attribute *, char *); + ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t); +}; + +struct kset_uevent_ops; + +struct kset { + struct list_head list; + spinlock_t list_lock; + struct kobject kobj; + const struct kset_uevent_ops *uevent_ops; +}; + +struct kobj_type { + void (*release)(struct kobject *); + const struct sysfs_ops *sysfs_ops; + struct attribute **default_attrs; + const struct attribute_group **default_groups; + const struct kobj_ns_type_operations * (*child_ns_type)(struct kobject *); + const void * (*namespace)(struct kobject *); + void (*get_ownership)(struct kobject *, kuid_t *, kgid_t *); +}; + +struct kobj_uevent_env { + char *argv[3]; + char *envp[64]; + int envp_idx; + char buf[2048]; + int buflen; +}; + +struct kset_uevent_ops { + int (* const filter)(struct kset *, struct kobject *); + const char * (* const name)(struct kset *, struct kobject *); + int (* const uevent)(struct kset *, struct kobject *, struct kobj_uevent_env *); +}; + +struct kernel_param; + +struct kernel_param_ops { + unsigned int flags; + int (*set)(const char *, const struct kernel_param *); + int (*get)(char *, const struct kernel_param *); + void (*free)(void *); +}; + +struct kparam_string; + +struct kparam_array; + +struct kernel_param { + const char *name; + struct module *mod; + const struct kernel_param_ops *ops; + const u16 perm; + s8 level; + u8 flags; + union { + void *arg; + const struct kparam_string *str; + const struct kparam_array *arr; + }; +}; + +struct kparam_string { + unsigned int maxlen; + char *string; +}; + +struct kparam_array { + unsigned int max; + unsigned int elemsize; + unsigned int *num; + const struct kernel_param_ops *ops; + void *elem; +}; + +enum module_state { + MODULE_STATE_LIVE = 0, + MODULE_STATE_COMING = 1, + MODULE_STATE_GOING = 2, + MODULE_STATE_UNFORMED = 3, +}; + +struct module_param_attrs; + +struct module_kobject { + struct kobject kobj; + struct module *mod; + struct kobject *drivers_dir; + struct module_param_attrs *mp; + struct completion *kobj_completion; +}; + +struct latch_tree_node { + struct rb_node node[2]; +}; + +struct mod_tree_node { + struct module *mod; + struct latch_tree_node node; +}; + +struct module_layout { + void *base; + unsigned int size; + unsigned int text_size; + unsigned int ro_size; + unsigned int ro_after_init_size; + struct mod_tree_node mtn; +}; + +struct mod_arch_specific { + unsigned int num_orcs; + int *orc_unwind_ip; + struct orc_entry *orc_unwind; +}; + +struct mod_kallsyms { + Elf64_Sym *symtab; + unsigned int num_symtab; + char *strtab; + char *typetab; +}; + +struct module_attribute; + +struct exception_table_entry; + +struct module_sect_attrs; + +struct module_notes_attrs; + +struct trace_eval_map; + +struct error_injection_entry; + +struct module { + enum module_state state; + struct list_head list; + char name[56]; + struct module_kobject mkobj; + struct module_attribute *modinfo_attrs; + const char *version; + const char *srcversion; + struct kobject *holders_dir; + const struct kernel_symbol *syms; + const s32 *crcs; + unsigned int num_syms; + struct mutex param_lock; + struct kernel_param *kp; + unsigned int num_kp; + unsigned int num_gpl_syms; + const struct kernel_symbol *gpl_syms; + const s32 *gpl_crcs; + bool using_gplonly_symbols; + bool sig_ok; + bool async_probe_requested; + const struct kernel_symbol *gpl_future_syms; + const s32 *gpl_future_crcs; + unsigned int num_gpl_future_syms; + unsigned int num_exentries; + struct exception_table_entry *extable; + int (*init)(); + long: 64; + struct module_layout core_layout; + struct module_layout init_layout; + struct mod_arch_specific arch; + long unsigned int taints; + unsigned int num_bugs; + struct list_head bug_list; + struct bug_entry *bug_table; + struct mod_kallsyms *kallsyms; + struct mod_kallsyms core_kallsyms; + struct module_sect_attrs *sect_attrs; + struct module_notes_attrs *notes_attrs; + char *args; + void *percpu; + unsigned int percpu_size; + void *noinstr_text_start; + unsigned int noinstr_text_size; + unsigned int num_tracepoints; + tracepoint_ptr_t *tracepoints_ptrs; + unsigned int num_srcu_structs; + struct srcu_struct **srcu_struct_ptrs; + unsigned int num_bpf_raw_events; + struct bpf_raw_event_map *bpf_raw_events; + unsigned int btf_data_size; + void *btf_data; + struct jump_entry *jump_entries; + unsigned int num_jump_entries; + unsigned int num_trace_bprintk_fmt; + const char **trace_bprintk_fmt_start; + struct trace_event_call **trace_events; + unsigned int num_trace_events; + struct trace_eval_map **trace_evals; + unsigned int num_trace_evals; + unsigned int num_ftrace_callsites; + long unsigned int *ftrace_callsites; + void *kprobes_text_start; + unsigned int kprobes_text_size; + long unsigned int *kprobe_blacklist; + unsigned int num_kprobe_blacklist; + int num_static_call_sites; + struct static_call_site *static_call_sites; + struct list_head source_list; + struct list_head target_list; + void (*exit)(); + atomic_t refcnt; + struct error_injection_entry *ei_funcs; + unsigned int num_ei_funcs; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct error_injection_entry { + long unsigned int addr; + int etype; +}; + +struct static_call_site { + s32 addr; + s32 key; +}; + +struct module_attribute { + struct attribute attr; + ssize_t (*show)(struct module_attribute *, struct module_kobject *, char *); + ssize_t (*store)(struct module_attribute *, struct module_kobject *, const char *, size_t); + void (*setup)(struct module *, const char *); + int (*test)(struct module *); + void (*free)(struct module *); +}; + +struct exception_table_entry { + int insn; + int fixup; + int handler; +}; + +struct trace_event_functions; + +struct trace_event { + struct hlist_node node; + struct list_head list; + int type; + struct trace_event_functions *funcs; +}; + +struct trace_event_class; + +struct bpf_prog_array; + +struct trace_event_call { + struct list_head list; + struct trace_event_class *class; + union { + char *name; + struct tracepoint *tp; + }; + struct trace_event event; + char *print_fmt; + struct event_filter *filter; + void *mod; + void *data; + int flags; + int perf_refcount; + struct hlist_head *perf_events; + struct bpf_prog_array *prog_array; + int (*perf_perm)(struct trace_event_call *, struct perf_event *); +}; + +struct trace_eval_map { + const char *system; + const char *eval_string; + long unsigned int eval_value; +}; + +struct cgroup; + +struct cgroup_subsys; + +struct cgroup_subsys_state { + struct cgroup *cgroup; + struct cgroup_subsys *ss; + struct percpu_ref refcnt; + struct list_head sibling; + struct list_head children; + struct list_head rstat_css_node; + int id; + unsigned int flags; + u64 serial_nr; + atomic_t online_cnt; + struct work_struct destroy_work; + struct rcu_work destroy_rwork; + struct cgroup_subsys_state *parent; +}; + +struct mem_cgroup_id { + int id; + refcount_t ref; +}; + +struct page_counter { + atomic_long_t usage; + long unsigned int min; + long unsigned int low; + long unsigned int high; + long unsigned int max; + struct page_counter *parent; + long unsigned int emin; + atomic_long_t min_usage; + atomic_long_t children_min_usage; + long unsigned int elow; + atomic_long_t low_usage; + atomic_long_t children_low_usage; + long unsigned int watermark; + long unsigned int failcnt; +}; + +struct vmpressure { + long unsigned int scanned; + long unsigned int reclaimed; + long unsigned int tree_scanned; + long unsigned int tree_reclaimed; + spinlock_t sr_lock; + struct list_head events; + struct mutex events_lock; + struct work_struct work; +}; + +struct cgroup_file { + struct kernfs_node *kn; + long unsigned int notified_at; + struct timer_list notify_timer; +}; + +struct mem_cgroup_threshold_ary; + +struct mem_cgroup_thresholds { + struct mem_cgroup_threshold_ary *primary; + struct mem_cgroup_threshold_ary *spare; +}; + +struct memcg_padding { + char x[0]; +}; + +enum memcg_kmem_state { + KMEM_NONE = 0, + KMEM_ALLOCATED = 1, + KMEM_ONLINE = 2, +}; + +struct percpu_counter { + raw_spinlock_t lock; + s64 count; + struct list_head list; + s32 *counters; +}; + +struct fprop_global { + struct percpu_counter events; + unsigned int period; + seqcount_t sequence; +}; + +struct wb_domain { + spinlock_t lock; + struct fprop_global completions; + struct timer_list period_timer; + long unsigned int period_time; + long unsigned int dirty_limit_tstamp; + long unsigned int dirty_limit; +}; + +struct wb_completion { + atomic_t cnt; + wait_queue_head_t *waitq; +}; + +struct memcg_cgwb_frn { + u64 bdi_id; + int memcg_id; + u64 at; + struct wb_completion done; +}; + +struct memcg_vmstats_percpu; + +struct obj_cgroup; + +struct mem_cgroup_per_node; + +struct mem_cgroup { + struct cgroup_subsys_state css; + struct mem_cgroup_id id; + struct page_counter memory; + union { + struct page_counter swap; + struct page_counter memsw; + }; + struct page_counter kmem; + struct page_counter tcpmem; + struct work_struct high_work; + long unsigned int soft_limit; + struct vmpressure vmpressure; + bool use_hierarchy; + bool oom_group; + bool oom_lock; + int under_oom; + int swappiness; + int oom_kill_disable; + struct cgroup_file events_file; + struct cgroup_file events_local_file; + struct cgroup_file swap_events_file; + struct mutex thresholds_lock; + struct mem_cgroup_thresholds thresholds; + struct mem_cgroup_thresholds memsw_thresholds; + struct list_head oom_notify; + long unsigned int move_charge_at_immigrate; + spinlock_t move_lock; + long unsigned int move_lock_flags; + long: 64; + long: 64; + struct memcg_padding _pad1_; + atomic_t moving_account; + struct task_struct *move_lock_task; + struct memcg_vmstats_percpu *vmstats_local; + struct memcg_vmstats_percpu *vmstats_percpu; + long: 64; + long: 64; + long: 64; + long: 64; + struct memcg_padding _pad2_; + atomic_long_t vmstats[40]; + atomic_long_t vmevents[96]; + atomic_long_t memory_events[8]; + atomic_long_t memory_events_local[8]; + long unsigned int socket_pressure; + bool tcpmem_active; + int tcpmem_pressure; + int kmemcg_id; + enum memcg_kmem_state kmem_state; + struct obj_cgroup *objcg; + struct list_head objcg_list; + struct list_head cgwb_list; + struct wb_domain cgwb_domain; + struct memcg_cgwb_frn cgwb_frn[4]; + struct list_head event_list; + spinlock_t event_list_lock; + struct deferred_split deferred_split_queue; + struct mem_cgroup_per_node *nodeinfo[0]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct fs_pin; + +struct pid_namespace { + struct kref kref; + struct idr idr; + struct callback_head rcu; + unsigned int pid_allocated; + struct task_struct *child_reaper; + struct kmem_cache *pid_cachep; + unsigned int level; + struct pid_namespace *parent; + struct fs_pin *bacct; + struct user_namespace *user_ns; + struct ucounts *ucounts; + int reboot; + struct ns_common ns; +}; + +struct task_cputime { + u64 stime; + u64 utime; + long long unsigned int sum_exec_runtime; +}; + +struct uts_namespace; + +struct ipc_namespace; + +struct mnt_namespace; + +struct net; + +struct time_namespace; + +struct cgroup_namespace; + +struct nsproxy { + atomic_t count; + struct uts_namespace *uts_ns; + struct ipc_namespace *ipc_ns; + struct mnt_namespace *mnt_ns; + struct pid_namespace *pid_ns_for_children; + struct net *net_ns; + struct time_namespace *time_ns; + struct time_namespace *time_ns_for_children; + struct cgroup_namespace *cgroup_ns; +}; + +struct bio; + +struct bio_list { + struct bio *head; + struct bio *tail; +}; + +struct blk_plug { + struct list_head mq_list; + struct list_head cb_list; + short unsigned int rq_count; + bool multiple_queues; + bool nowait; +}; + +struct reclaim_state { + long unsigned int reclaimed_slab; +}; + +struct fprop_local_percpu { + struct percpu_counter events; + unsigned int period; + raw_spinlock_t lock; +}; + +enum wb_reason { + WB_REASON_BACKGROUND = 0, + WB_REASON_VMSCAN = 1, + WB_REASON_SYNC = 2, + WB_REASON_PERIODIC = 3, + WB_REASON_LAPTOP_TIMER = 4, + WB_REASON_FS_FREE_SPACE = 5, + WB_REASON_FORKER_THREAD = 6, + WB_REASON_FOREIGN_FLUSH = 7, + WB_REASON_MAX = 8, +}; + +struct bdi_writeback { + struct backing_dev_info *bdi; + long unsigned int state; + long unsigned int last_old_flush; + struct list_head b_dirty; + struct list_head b_io; + struct list_head b_more_io; + struct list_head b_dirty_time; + spinlock_t list_lock; + struct percpu_counter stat[4]; + long unsigned int congested; + long unsigned int bw_time_stamp; + long unsigned int dirtied_stamp; + long unsigned int written_stamp; + long unsigned int write_bandwidth; + long unsigned int avg_write_bandwidth; + long unsigned int dirty_ratelimit; + long unsigned int balanced_dirty_ratelimit; + struct fprop_local_percpu completions; + int dirty_exceeded; + enum wb_reason start_all_reason; + spinlock_t work_lock; + struct list_head work_list; + struct delayed_work dwork; + long unsigned int dirty_sleep; + struct list_head bdi_node; + struct percpu_ref refcnt; + struct fprop_local_percpu memcg_completions; + struct cgroup_subsys_state *memcg_css; + struct cgroup_subsys_state *blkcg_css; + struct list_head memcg_node; + struct list_head blkcg_node; + union { + struct work_struct release_work; + struct callback_head rcu; + }; +}; + +struct device; + +struct backing_dev_info { + u64 id; + struct rb_node rb_node; + struct list_head bdi_list; + long unsigned int ra_pages; + long unsigned int io_pages; + struct kref refcnt; + unsigned int capabilities; + unsigned int min_ratio; + unsigned int max_ratio; + unsigned int max_prop_frac; + atomic_long_t tot_write_bandwidth; + struct bdi_writeback wb; + struct list_head wb_list; + struct xarray cgwb_tree; + struct mutex cgwb_release_mutex; + struct rw_semaphore wb_switch_rwsem; + wait_queue_head_t wb_waitq; + struct device *dev; + char dev_name[64]; + struct device *owner; + struct timer_list laptop_mode_wb_timer; + struct dentry *debug_dir; +}; + +struct css_set { + struct cgroup_subsys_state *subsys[10]; + refcount_t refcount; + struct css_set *dom_cset; + struct cgroup *dfl_cgrp; + int nr_tasks; + struct list_head tasks; + struct list_head mg_tasks; + struct list_head dying_tasks; + struct list_head task_iters; + struct list_head e_cset_node[10]; + struct list_head threaded_csets; + struct list_head threaded_csets_node; + struct hlist_node hlist; + struct list_head cgrp_links; + struct list_head mg_preload_node; + struct list_head mg_node; + struct cgroup *mg_src_cgrp; + struct cgroup *mg_dst_cgrp; + struct css_set *mg_dst_cset; + bool dead; + struct callback_head callback_head; +}; + +typedef u32 compat_uptr_t; + +struct compat_robust_list { + compat_uptr_t next; +}; + +typedef s32 compat_long_t; + +struct compat_robust_list_head { + struct compat_robust_list list; + compat_long_t futex_offset; + compat_uptr_t list_op_pending; +}; + +struct perf_event_groups { + struct rb_root tree; + u64 index; +}; + +struct perf_event_context { + struct pmu *pmu; + raw_spinlock_t lock; + struct mutex mutex; + struct list_head active_ctx_list; + struct perf_event_groups pinned_groups; + struct perf_event_groups flexible_groups; + struct list_head event_list; + struct list_head pinned_active; + struct list_head flexible_active; + int nr_events; + int nr_active; + int is_active; + int nr_stat; + int nr_freq; + int rotate_disable; + int rotate_necessary; + refcount_t refcount; + struct task_struct *task; + u64 time; + u64 timestamp; + struct perf_event_context *parent_ctx; + u64 parent_gen; + u64 generation; + int pin_count; + int nr_cgroups; + void *task_ctx_data; + struct callback_head callback_head; +}; + +struct task_delay_info { + raw_spinlock_t lock; + unsigned int flags; + u64 blkio_start; + u64 blkio_delay; + u64 swapin_delay; + u32 blkio_count; + u32 swapin_count; + u64 freepages_start; + u64 freepages_delay; + u64 thrashing_start; + u64 thrashing_delay; + u32 freepages_count; + u32 thrashing_count; +}; + +struct ftrace_ret_stack { + long unsigned int ret; + long unsigned int func; + long long unsigned int calltime; + long unsigned int *retp; +}; + +enum rpm_status { + RPM_ACTIVE = 0, + RPM_RESUMING = 1, + RPM_SUSPENDED = 2, + RPM_SUSPENDING = 3, +}; + +struct blk_rq_stat { + u64 mean; + u64 min; + u64 max; + u32 nr_samples; + u64 batch; +}; + +enum blk_zoned_model { + BLK_ZONED_NONE = 0, + BLK_ZONED_HA = 1, + BLK_ZONED_HM = 2, +}; + +struct queue_limits { + long unsigned int bounce_pfn; + long unsigned int seg_boundary_mask; + long unsigned int virt_boundary_mask; + unsigned int max_hw_sectors; + unsigned int max_dev_sectors; + unsigned int chunk_sectors; + unsigned int max_sectors; + unsigned int max_segment_size; + unsigned int physical_block_size; + unsigned int logical_block_size; + unsigned int alignment_offset; + unsigned int io_min; + unsigned int io_opt; + unsigned int max_discard_sectors; + unsigned int max_hw_discard_sectors; + unsigned int max_write_same_sectors; + unsigned int max_write_zeroes_sectors; + unsigned int max_zone_append_sectors; + unsigned int discard_granularity; + unsigned int discard_alignment; + short unsigned int max_segments; + short unsigned int max_integrity_segments; + short unsigned int max_discard_segments; + unsigned char misaligned; + unsigned char discard_misaligned; + unsigned char raid_partial_stripes_expensive; + enum blk_zoned_model zoned; +}; + +struct bsg_ops; + +struct bsg_class_device { + struct device *class_dev; + int minor; + struct request_queue *queue; + const struct bsg_ops *ops; +}; + +typedef void *mempool_alloc_t(gfp_t, void *); + +typedef void mempool_free_t(void *, void *); + +struct mempool_s { + spinlock_t lock; + int min_nr; + int curr_nr; + void **elements; + void *pool_data; + mempool_alloc_t *alloc; + mempool_free_t *free; + wait_queue_head_t wait; +}; + +typedef struct mempool_s mempool_t; + +struct bio_set { + struct kmem_cache *bio_slab; + unsigned int front_pad; + mempool_t bio_pool; + mempool_t bvec_pool; + spinlock_t rescue_lock; + struct bio_list rescue_list; + struct work_struct rescue_work; + struct workqueue_struct *rescue_workqueue; +}; + +struct request; + +struct elevator_queue; + +struct blk_queue_stats; + +struct rq_qos; + +struct blk_mq_ops; + +struct blk_mq_ctx; + +struct blk_mq_hw_ctx; + +struct blk_stat_callback; + +struct blkcg_gq; + +struct blk_trace; + +struct blk_flush_queue; + +struct throtl_data; + +struct blk_mq_tag_set; + +struct request_queue { + struct request *last_merge; + struct elevator_queue *elevator; + struct percpu_ref q_usage_counter; + struct blk_queue_stats *stats; + struct rq_qos *rq_qos; + const struct blk_mq_ops *mq_ops; + struct blk_mq_ctx *queue_ctx; + unsigned int queue_depth; + struct blk_mq_hw_ctx **queue_hw_ctx; + unsigned int nr_hw_queues; + struct backing_dev_info *backing_dev_info; + void *queuedata; + long unsigned int queue_flags; + atomic_t pm_only; + int id; + gfp_t bounce_gfp; + spinlock_t queue_lock; + struct kobject kobj; + struct kobject *mq_kobj; + struct device *dev; + enum rpm_status rpm_status; + unsigned int nr_pending; + long unsigned int nr_requests; + unsigned int dma_pad_mask; + unsigned int dma_alignment; + unsigned int rq_timeout; + int poll_nsec; + struct blk_stat_callback *poll_cb; + struct blk_rq_stat poll_stat[16]; + struct timer_list timeout; + struct work_struct timeout_work; + atomic_t nr_active_requests_shared_sbitmap; + struct list_head icq_list; + long unsigned int blkcg_pols[1]; + struct blkcg_gq *root_blkg; + struct list_head blkg_list; + struct queue_limits limits; + unsigned int required_elevator_features; + unsigned int sg_timeout; + unsigned int sg_reserved_size; + int node; + struct mutex debugfs_mutex; + struct blk_trace *blk_trace; + struct blk_flush_queue *fq; + struct list_head requeue_list; + spinlock_t requeue_lock; + struct delayed_work requeue_work; + struct mutex sysfs_lock; + struct mutex sysfs_dir_lock; + struct list_head unused_hctx_list; + spinlock_t unused_hctx_lock; + int mq_freeze_depth; + struct bsg_class_device bsg_dev; + struct throtl_data *td; + struct callback_head callback_head; + wait_queue_head_t mq_freeze_wq; + struct mutex mq_freeze_lock; + struct blk_mq_tag_set *tag_set; + struct list_head tag_set_list; + struct bio_set bio_split; + struct dentry *debugfs_dir; + struct dentry *sched_debugfs_dir; + struct dentry *rqos_debugfs_dir; + bool mq_sysfs_init_done; + size_t cmd_size; + u64 write_hints[5]; +}; + +struct cgroup_base_stat { + struct task_cputime cputime; +}; + +struct psi_group_cpu; + +struct psi_group { + struct mutex avgs_lock; + struct psi_group_cpu *pcpu; + u64 avg_total[5]; + u64 avg_last_update; + u64 avg_next_update; + struct delayed_work avgs_work; + u64 total[10]; + long unsigned int avg[15]; + struct task_struct *poll_task; + struct timer_list poll_timer; + wait_queue_head_t poll_wait; + atomic_t poll_wakeup; + struct mutex trigger_lock; + struct list_head triggers; + u32 nr_triggers[5]; + u32 poll_states; + u64 poll_min_period; + u64 polling_total[5]; + u64 polling_next_update; + u64 polling_until; +}; + +struct cgroup_bpf { + struct bpf_prog_array *effective[38]; + struct list_head progs[38]; + u32 flags[38]; + struct list_head storages; + struct bpf_prog_array *inactive; + struct percpu_ref refcnt; + struct work_struct release_work; +}; + +struct cgroup_freezer_state { + bool freeze; + int e_freeze; + int nr_frozen_descendants; + int nr_frozen_tasks; +}; + +struct cgroup_root; + +struct cgroup_rstat_cpu; + +struct cgroup { + struct cgroup_subsys_state self; + long unsigned int flags; + int level; + int max_depth; + int nr_descendants; + int nr_dying_descendants; + int max_descendants; + int nr_populated_csets; + int nr_populated_domain_children; + int nr_populated_threaded_children; + int nr_threaded_children; + struct kernfs_node *kn; + struct cgroup_file procs_file; + struct cgroup_file events_file; + u16 subtree_control; + u16 subtree_ss_mask; + u16 old_subtree_control; + u16 old_subtree_ss_mask; + struct cgroup_subsys_state *subsys[10]; + struct cgroup_root *root; + struct list_head cset_links; + struct list_head e_csets[10]; + struct cgroup *dom_cgrp; + struct cgroup *old_dom_cgrp; + struct cgroup_rstat_cpu *rstat_cpu; + struct list_head rstat_css_list; + struct cgroup_base_stat last_bstat; + struct cgroup_base_stat bstat; + struct prev_cputime prev_cputime; + struct list_head pidlists; + struct mutex pidlist_mutex; + wait_queue_head_t offline_waitq; + struct work_struct release_agent_work; + struct psi_group psi; + struct cgroup_bpf bpf; + atomic_t congestion_count; + struct cgroup_freezer_state freezer; + u64 ancestor_ids[0]; +}; + +struct taskstats { + __u16 version; + __u32 ac_exitcode; + __u8 ac_flag; + __u8 ac_nice; + __u64 cpu_count; + __u64 cpu_delay_total; + __u64 blkio_count; + __u64 blkio_delay_total; + __u64 swapin_count; + __u64 swapin_delay_total; + __u64 cpu_run_real_total; + __u64 cpu_run_virtual_total; + char ac_comm[32]; + __u8 ac_sched; + __u8 ac_pad[3]; + int: 32; + __u32 ac_uid; + __u32 ac_gid; + __u32 ac_pid; + __u32 ac_ppid; + __u32 ac_btime; + __u64 ac_etime; + __u64 ac_utime; + __u64 ac_stime; + __u64 ac_minflt; + __u64 ac_majflt; + __u64 coremem; + __u64 virtmem; + __u64 hiwater_rss; + __u64 hiwater_vm; + __u64 read_char; + __u64 write_char; + __u64 read_syscalls; + __u64 write_syscalls; + __u64 read_bytes; + __u64 write_bytes; + __u64 cancelled_write_bytes; + __u64 nvcsw; + __u64 nivcsw; + __u64 ac_utimescaled; + __u64 ac_stimescaled; + __u64 cpu_scaled_run_real_total; + __u64 freepages_count; + __u64 freepages_delay_total; + __u64 thrashing_count; + __u64 thrashing_delay_total; + __u64 ac_btime64; +}; + +typedef struct { + __u8 b[16]; +} guid_t; + +struct wait_page_queue { + struct page *page; + int bit_nr; + wait_queue_entry_t wait; +}; + +enum writeback_sync_modes { + WB_SYNC_NONE = 0, + WB_SYNC_ALL = 1, +}; + +struct writeback_control { + long int nr_to_write; + long int pages_skipped; + loff_t range_start; + loff_t range_end; + enum writeback_sync_modes sync_mode; + unsigned int for_kupdate: 1; + unsigned int for_background: 1; + unsigned int tagged_writepages: 1; + unsigned int for_reclaim: 1; + unsigned int range_cyclic: 1; + unsigned int for_sync: 1; + unsigned int no_cgroup_owner: 1; + unsigned int punt_to_cgroup: 1; + struct bdi_writeback *wb; + struct inode *inode; + int wb_id; + int wb_lcand_id; + int wb_tcand_id; + size_t wb_bytes; + size_t wb_lcand_bytes; + size_t wb_tcand_bytes; +}; + +struct readahead_control { + struct file *file; + struct address_space *mapping; + long unsigned int _index; + unsigned int _nr_pages; + unsigned int _batch_count; +}; + +struct iovec; + +struct kvec; + +struct bio_vec; + +struct iov_iter { + unsigned int type; + size_t iov_offset; + size_t count; + union { + const struct iovec *iov; + const struct kvec *kvec; + const struct bio_vec *bvec; + struct pipe_inode_info *pipe; + }; + union { + long unsigned int nr_segs; + struct { + unsigned int head; + unsigned int start_head; + }; + }; +}; + +struct swap_cluster_info { + spinlock_t lock; + unsigned int data: 24; + unsigned int flags: 8; +}; + +struct swap_cluster_list { + struct swap_cluster_info head; + struct swap_cluster_info tail; +}; + +struct percpu_cluster; + +struct swap_info_struct { + long unsigned int flags; + short int prio; + struct plist_node list; + signed char type; + unsigned int max; + unsigned char *swap_map; + struct swap_cluster_info *cluster_info; + struct swap_cluster_list free_clusters; + unsigned int lowest_bit; + unsigned int highest_bit; + unsigned int pages; + unsigned int inuse_pages; + unsigned int cluster_next; + unsigned int cluster_nr; + unsigned int *cluster_next_cpu; + struct percpu_cluster *percpu_cluster; + struct rb_root swap_extent_root; + struct block_device *bdev; + struct file *swap_file; + unsigned int old_block_size; + spinlock_t lock; + spinlock_t cont_lock; + struct work_struct discard_work; + struct swap_cluster_list discard_clusters; + struct plist_node avail_lists[0]; +}; + +struct hd_struct; + +struct gendisk; + +struct block_device { + dev_t bd_dev; + int bd_openers; + struct inode *bd_inode; + struct super_block *bd_super; + struct mutex bd_mutex; + void *bd_claiming; + void *bd_holder; + int bd_holders; + bool bd_write_holder; + struct list_head bd_holder_disks; + struct block_device *bd_contains; + u8 bd_partno; + struct hd_struct *bd_part; + unsigned int bd_part_count; + spinlock_t bd_size_lock; + struct gendisk *bd_disk; + struct backing_dev_info *bd_bdi; + int bd_fsfreeze_count; + struct mutex bd_fsfreeze_mutex; +}; + +struct cdev { + struct kobject kobj; + struct module *owner; + const struct file_operations *ops; + struct list_head list; + dev_t dev; + unsigned int count; +}; + +struct fc_log; + +struct p_log { + const char *prefix; + struct fc_log *log; +}; + +enum fs_context_purpose { + FS_CONTEXT_FOR_MOUNT = 0, + FS_CONTEXT_FOR_SUBMOUNT = 1, + FS_CONTEXT_FOR_RECONFIGURE = 2, +}; + +enum fs_context_phase { + FS_CONTEXT_CREATE_PARAMS = 0, + FS_CONTEXT_CREATING = 1, + FS_CONTEXT_AWAITING_MOUNT = 2, + FS_CONTEXT_AWAITING_RECONF = 3, + FS_CONTEXT_RECONF_PARAMS = 4, + FS_CONTEXT_RECONFIGURING = 5, + FS_CONTEXT_FAILED = 6, +}; + +struct fs_context_operations; + +struct fs_context { + const struct fs_context_operations *ops; + struct mutex uapi_mutex; + struct file_system_type *fs_type; + void *fs_private; + void *sget_key; + struct dentry *root; + struct user_namespace *user_ns; + struct net *net_ns; + const struct cred *cred; + struct p_log log; + const char *source; + void *security; + void *s_fs_info; + unsigned int sb_flags; + unsigned int sb_flags_mask; + unsigned int s_iflags; + unsigned int lsm_flags; + enum fs_context_purpose purpose: 8; + enum fs_context_phase phase: 8; + bool need_free: 1; + bool global: 1; + bool oldapi: 1; +}; + +struct audit_names; + +struct filename { + const char *name; + const char *uptr; + int refcnt; + struct audit_names *aname; + const char iname[0]; +}; + +typedef u8 blk_status_t; + +struct bvec_iter { + sector_t bi_sector; + unsigned int bi_size; + unsigned int bi_idx; + unsigned int bi_bvec_done; +}; + +typedef void bio_end_io_t(struct bio *); + +struct bio_issue { + u64 value; +}; + +struct bio_vec { + struct page *bv_page; + unsigned int bv_len; + unsigned int bv_offset; +}; + +struct bio { + struct bio *bi_next; + struct gendisk *bi_disk; + unsigned int bi_opf; + short unsigned int bi_flags; + short unsigned int bi_ioprio; + short unsigned int bi_write_hint; + blk_status_t bi_status; + u8 bi_partno; + atomic_t __bi_remaining; + struct bvec_iter bi_iter; + bio_end_io_t *bi_end_io; + void *bi_private; + struct blkcg_gq *bi_blkg; + struct bio_issue bi_issue; + union { }; + short unsigned int bi_vcnt; + short unsigned int bi_max_vecs; + atomic_t __bi_cnt; + struct bio_vec *bi_io_vec; + struct bio_set *bi_pool; + struct bio_vec bi_inline_vecs[0]; +}; + +struct linux_binprm { + struct vm_area_struct *vma; + long unsigned int vma_pages; + struct mm_struct *mm; + long unsigned int p; + long unsigned int argmin; + unsigned int have_execfd: 1; + unsigned int execfd_creds: 1; + unsigned int secureexec: 1; + unsigned int point_of_no_return: 1; + struct file *executable; + struct file *interpreter; + struct file *file; + struct cred *cred; + int unsafe; + unsigned int per_clear; + int argc; + int envc; + const char *filename; + const char *interp; + const char *fdpath; + unsigned int interp_flags; + int execfd; + long unsigned int loader; + long unsigned int exec; + struct rlimit rlim_stack; + char buf[256]; +}; + +struct coredump_params { + const kernel_siginfo_t *siginfo; + struct pt_regs *regs; + struct file *file; + long unsigned int limit; + long unsigned int mm_flags; + loff_t written; + loff_t pos; +}; + +struct pm_message { + int event; +}; + +typedef struct pm_message pm_message_t; + +struct dev_pm_ops { + int (*prepare)(struct device *); + void (*complete)(struct device *); + int (*suspend)(struct device *); + int (*resume)(struct device *); + int (*freeze)(struct device *); + int (*thaw)(struct device *); + int (*poweroff)(struct device *); + int (*restore)(struct device *); + int (*suspend_late)(struct device *); + int (*resume_early)(struct device *); + int (*freeze_late)(struct device *); + int (*thaw_early)(struct device *); + int (*poweroff_late)(struct device *); + int (*restore_early)(struct device *); + int (*suspend_noirq)(struct device *); + int (*resume_noirq)(struct device *); + int (*freeze_noirq)(struct device *); + int (*thaw_noirq)(struct device *); + int (*poweroff_noirq)(struct device *); + int (*restore_noirq)(struct device *); + int (*runtime_suspend)(struct device *); + int (*runtime_resume)(struct device *); + int (*runtime_idle)(struct device *); +}; + +enum dl_dev_state { + DL_DEV_NO_DRIVER = 0, + DL_DEV_PROBING = 1, + DL_DEV_DRIVER_BOUND = 2, + DL_DEV_UNBINDING = 3, +}; + +struct dev_links_info { + struct list_head suppliers; + struct list_head consumers; + struct list_head needs_suppliers; + struct list_head defer_hook; + bool need_for_probe; + enum dl_dev_state status; +}; + +enum rpm_request { + RPM_REQ_NONE = 0, + RPM_REQ_IDLE = 1, + RPM_REQ_SUSPEND = 2, + RPM_REQ_AUTOSUSPEND = 3, + RPM_REQ_RESUME = 4, +}; + +struct wakeup_source; + +struct wake_irq; + +struct pm_subsys_data; + +struct dev_pm_qos; + +struct dev_pm_info { + pm_message_t power_state; + unsigned int can_wakeup: 1; + unsigned int async_suspend: 1; + bool in_dpm_list: 1; + bool is_prepared: 1; + bool is_suspended: 1; + bool is_noirq_suspended: 1; + bool is_late_suspended: 1; + bool no_pm: 1; + bool early_init: 1; + bool direct_complete: 1; + u32 driver_flags; + spinlock_t lock; + struct list_head entry; + struct completion completion; + struct wakeup_source *wakeup; + bool wakeup_path: 1; + bool syscore: 1; + bool no_pm_callbacks: 1; + unsigned int must_resume: 1; + unsigned int may_skip_resume: 1; + struct hrtimer suspend_timer; + u64 timer_expires; + struct work_struct work; + wait_queue_head_t wait_queue; + struct wake_irq *wakeirq; + atomic_t usage_count; + atomic_t child_count; + unsigned int disable_depth: 3; + unsigned int idle_notification: 1; + unsigned int request_pending: 1; + unsigned int deferred_resume: 1; + unsigned int runtime_auto: 1; + bool ignore_children: 1; + unsigned int no_callbacks: 1; + unsigned int irq_safe: 1; + unsigned int use_autosuspend: 1; + unsigned int timer_autosuspends: 1; + unsigned int memalloc_noio: 1; + unsigned int links_count; + enum rpm_request request; + enum rpm_status runtime_status; + int runtime_error; + int autosuspend_delay; + u64 last_busy; + u64 active_time; + u64 suspended_time; + u64 accounting_timestamp; + struct pm_subsys_data *subsys_data; + void (*set_latency_tolerance)(struct device *, s32); + struct dev_pm_qos *qos; +}; + +struct dev_archdata {}; + +struct device_private; + +struct device_type; + +struct bus_type; + +struct device_driver; + +struct dev_pm_domain; + +struct dma_map_ops; + +struct bus_dma_region; + +struct device_dma_parameters; + +struct cma; + +struct device_node; + +struct class; + +struct iommu_group; + +struct dev_iommu; + +struct device { + struct kobject kobj; + struct device *parent; + struct device_private *p; + const char *init_name; + const struct device_type *type; + struct bus_type *bus; + struct device_driver *driver; + void *platform_data; + void *driver_data; + struct mutex mutex; + struct dev_links_info links; + struct dev_pm_info power; + struct dev_pm_domain *pm_domain; + struct irq_domain *msi_domain; + struct list_head msi_list; + const struct dma_map_ops *dma_ops; + u64 *dma_mask; + u64 coherent_dma_mask; + u64 bus_dma_limit; + const struct bus_dma_region *dma_range_map; + struct device_dma_parameters *dma_parms; + struct list_head dma_pools; + struct cma *cma_area; + struct dev_archdata archdata; + struct device_node *of_node; + struct fwnode_handle *fwnode; + int numa_node; + dev_t devt; + u32 id; + spinlock_t devres_lock; + struct list_head devres_head; + struct class *class; + const struct attribute_group **groups; + void (*release)(struct device *); + struct iommu_group *iommu_group; + struct dev_iommu *iommu; + bool offline_disabled: 1; + bool offline: 1; + bool of_node_reused: 1; + bool state_synced: 1; +}; + +struct pm_subsys_data { + spinlock_t lock; + unsigned int refcount; + struct list_head clock_list; +}; + +struct wakeup_source { + const char *name; + int id; + struct list_head entry; + spinlock_t lock; + struct wake_irq *wakeirq; + struct timer_list timer; + long unsigned int timer_expires; + ktime_t total_time; + ktime_t max_time; + ktime_t last_time; + ktime_t start_prevent_time; + ktime_t prevent_sleep_time; + long unsigned int event_count; + long unsigned int active_count; + long unsigned int relax_count; + long unsigned int expire_count; + long unsigned int wakeup_count; + struct device *dev; + bool active: 1; + bool autosleep_enabled: 1; +}; + +struct dev_pm_domain { + struct dev_pm_ops ops; + int (*start)(struct device *); + void (*detach)(struct device *, bool); + int (*activate)(struct device *); + void (*sync)(struct device *); + void (*dismiss)(struct device *); +}; + +struct iommu_ops; + +struct subsys_private; + +struct bus_type { + const char *name; + const char *dev_name; + struct device *dev_root; + const struct attribute_group **bus_groups; + const struct attribute_group **dev_groups; + const struct attribute_group **drv_groups; + int (*match)(struct device *, struct device_driver *); + int (*uevent)(struct device *, struct kobj_uevent_env *); + int (*probe)(struct device *); + void (*sync_state)(struct device *); + int (*remove)(struct device *); + void (*shutdown)(struct device *); + int (*online)(struct device *); + int (*offline)(struct device *); + int (*suspend)(struct device *, pm_message_t); + int (*resume)(struct device *); + int (*num_vf)(struct device *); + int (*dma_configure)(struct device *); + const struct dev_pm_ops *pm; + const struct iommu_ops *iommu_ops; + struct subsys_private *p; + struct lock_class_key lock_key; + bool need_parent_lock; +}; + +enum probe_type { + PROBE_DEFAULT_STRATEGY = 0, + PROBE_PREFER_ASYNCHRONOUS = 1, + PROBE_FORCE_SYNCHRONOUS = 2, +}; + +struct of_device_id; + +struct acpi_device_id; + +struct driver_private; + +struct device_driver { + const char *name; + struct bus_type *bus; + struct module *owner; + const char *mod_name; + bool suppress_bind_attrs; + enum probe_type probe_type; + const struct of_device_id *of_match_table; + const struct acpi_device_id *acpi_match_table; + int (*probe)(struct device *); + void (*sync_state)(struct device *); + int (*remove)(struct device *); + void (*shutdown)(struct device *); + int (*suspend)(struct device *, pm_message_t); + int (*resume)(struct device *); + const struct attribute_group **groups; + const struct attribute_group **dev_groups; + const struct dev_pm_ops *pm; + void (*coredump)(struct device *); + struct driver_private *p; +}; + +enum iommu_cap { + IOMMU_CAP_CACHE_COHERENCY = 0, + IOMMU_CAP_INTR_REMAP = 1, + IOMMU_CAP_NOEXEC = 2, +}; + +enum iommu_attr { + DOMAIN_ATTR_GEOMETRY = 0, + DOMAIN_ATTR_PAGING = 1, + DOMAIN_ATTR_WINDOWS = 2, + DOMAIN_ATTR_FSL_PAMU_STASH = 3, + DOMAIN_ATTR_FSL_PAMU_ENABLE = 4, + DOMAIN_ATTR_FSL_PAMUV1 = 5, + DOMAIN_ATTR_NESTING = 6, + DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE = 7, + DOMAIN_ATTR_MAX = 8, +}; + +enum iommu_dev_features { + IOMMU_DEV_FEAT_AUX = 0, + IOMMU_DEV_FEAT_SVA = 1, +}; + +struct iommu_domain; + +struct iommu_iotlb_gather; + +struct iommu_device; + +struct iommu_resv_region; + +struct of_phandle_args; + +struct iommu_sva; + +struct iommu_fault_event; + +struct iommu_page_response; + +struct iommu_cache_invalidate_info; + +struct iommu_gpasid_bind_data; + +struct iommu_ops { + bool (*capable)(enum iommu_cap); + struct iommu_domain * (*domain_alloc)(unsigned int); + void (*domain_free)(struct iommu_domain *); + int (*attach_dev)(struct iommu_domain *, struct device *); + void (*detach_dev)(struct iommu_domain *, struct device *); + int (*map)(struct iommu_domain *, long unsigned int, phys_addr_t, size_t, int, gfp_t); + size_t (*unmap)(struct iommu_domain *, long unsigned int, size_t, struct iommu_iotlb_gather *); + void (*flush_iotlb_all)(struct iommu_domain *); + void (*iotlb_sync_map)(struct iommu_domain *); + void (*iotlb_sync)(struct iommu_domain *, struct iommu_iotlb_gather *); + phys_addr_t (*iova_to_phys)(struct iommu_domain *, dma_addr_t); + struct iommu_device * (*probe_device)(struct device *); + void (*release_device)(struct device *); + void (*probe_finalize)(struct device *); + struct iommu_group * (*device_group)(struct device *); + int (*domain_get_attr)(struct iommu_domain *, enum iommu_attr, void *); + int (*domain_set_attr)(struct iommu_domain *, enum iommu_attr, void *); + void (*get_resv_regions)(struct device *, struct list_head *); + void (*put_resv_regions)(struct device *, struct list_head *); + void (*apply_resv_region)(struct device *, struct iommu_domain *, struct iommu_resv_region *); + int (*domain_window_enable)(struct iommu_domain *, u32, phys_addr_t, u64, int); + void (*domain_window_disable)(struct iommu_domain *, u32); + int (*of_xlate)(struct device *, struct of_phandle_args *); + bool (*is_attach_deferred)(struct iommu_domain *, struct device *); + bool (*dev_has_feat)(struct device *, enum iommu_dev_features); + bool (*dev_feat_enabled)(struct device *, enum iommu_dev_features); + int (*dev_enable_feat)(struct device *, enum iommu_dev_features); + int (*dev_disable_feat)(struct device *, enum iommu_dev_features); + int (*aux_attach_dev)(struct iommu_domain *, struct device *); + void (*aux_detach_dev)(struct iommu_domain *, struct device *); + int (*aux_get_pasid)(struct iommu_domain *, struct device *); + struct iommu_sva * (*sva_bind)(struct device *, struct mm_struct *, void *); + void (*sva_unbind)(struct iommu_sva *); + u32 (*sva_get_pasid)(struct iommu_sva *); + int (*page_response)(struct device *, struct iommu_fault_event *, struct iommu_page_response *); + int (*cache_invalidate)(struct iommu_domain *, struct device *, struct iommu_cache_invalidate_info *); + int (*sva_bind_gpasid)(struct iommu_domain *, struct device *, struct iommu_gpasid_bind_data *); + int (*sva_unbind_gpasid)(struct device *, u32); + int (*def_domain_type)(struct device *); + long unsigned int pgsize_bitmap; + struct module *owner; +}; + +struct device_type { + const char *name; + const struct attribute_group **groups; + int (*uevent)(struct device *, struct kobj_uevent_env *); + char * (*devnode)(struct device *, umode_t *, kuid_t *, kgid_t *); + void (*release)(struct device *); + const struct dev_pm_ops *pm; +}; + +struct class { + const char *name; + struct module *owner; + const struct attribute_group **class_groups; + const struct attribute_group **dev_groups; + struct kobject *dev_kobj; + int (*dev_uevent)(struct device *, struct kobj_uevent_env *); + char * (*devnode)(struct device *, umode_t *); + void (*class_release)(struct class *); + void (*dev_release)(struct device *); + int (*shutdown_pre)(struct device *); + const struct kobj_ns_type_operations *ns_type; + const void * (*namespace)(struct device *); + void (*get_ownership)(struct device *, kuid_t *, kgid_t *); + const struct dev_pm_ops *pm; + struct subsys_private *p; +}; + +struct of_device_id { + char name[32]; + char type[32]; + char compatible[128]; + const void *data; +}; + +typedef long unsigned int kernel_ulong_t; + +struct acpi_device_id { + __u8 id[9]; + kernel_ulong_t driver_data; + __u32 cls; + __u32 cls_msk; +}; + +struct device_dma_parameters { + unsigned int max_segment_size; + long unsigned int segment_boundary_mask; +}; + +enum dma_data_direction { + DMA_BIDIRECTIONAL = 0, + DMA_TO_DEVICE = 1, + DMA_FROM_DEVICE = 2, + DMA_NONE = 3, +}; + +struct sg_table; + +struct scatterlist; + +struct dma_map_ops { + void * (*alloc)(struct device *, size_t, dma_addr_t *, gfp_t, long unsigned int); + void (*free)(struct device *, size_t, void *, dma_addr_t, long unsigned int); + struct page * (*alloc_pages)(struct device *, size_t, dma_addr_t *, enum dma_data_direction, gfp_t); + void (*free_pages)(struct device *, size_t, struct page *, dma_addr_t, enum dma_data_direction); + void * (*alloc_noncoherent)(struct device *, size_t, dma_addr_t *, enum dma_data_direction, gfp_t); + void (*free_noncoherent)(struct device *, size_t, void *, dma_addr_t, enum dma_data_direction); + int (*mmap)(struct device *, struct vm_area_struct *, void *, dma_addr_t, size_t, long unsigned int); + int (*get_sgtable)(struct device *, struct sg_table *, void *, dma_addr_t, size_t, long unsigned int); + dma_addr_t (*map_page)(struct device *, struct page *, long unsigned int, size_t, enum dma_data_direction, long unsigned int); + void (*unmap_page)(struct device *, dma_addr_t, size_t, enum dma_data_direction, long unsigned int); + int (*map_sg)(struct device *, struct scatterlist *, int, enum dma_data_direction, long unsigned int); + void (*unmap_sg)(struct device *, struct scatterlist *, int, enum dma_data_direction, long unsigned int); + dma_addr_t (*map_resource)(struct device *, phys_addr_t, size_t, enum dma_data_direction, long unsigned int); + void (*unmap_resource)(struct device *, dma_addr_t, size_t, enum dma_data_direction, long unsigned int); + void (*sync_single_for_cpu)(struct device *, dma_addr_t, size_t, enum dma_data_direction); + void (*sync_single_for_device)(struct device *, dma_addr_t, size_t, enum dma_data_direction); + void (*sync_sg_for_cpu)(struct device *, struct scatterlist *, int, enum dma_data_direction); + void (*sync_sg_for_device)(struct device *, struct scatterlist *, int, enum dma_data_direction); + void (*cache_sync)(struct device *, void *, size_t, enum dma_data_direction); + int (*dma_supported)(struct device *, u64); + u64 (*get_required_mask)(struct device *); + size_t (*max_mapping_size)(struct device *); + long unsigned int (*get_merge_boundary)(struct device *); +}; + +struct bus_dma_region { + phys_addr_t cpu_start; + dma_addr_t dma_start; + u64 size; + u64 offset; +}; + +typedef u32 phandle; + +struct fwnode_operations; + +struct fwnode_handle { + struct fwnode_handle *secondary; + const struct fwnode_operations *ops; + struct device *dev; +}; + +struct property; + +struct device_node { + const char *name; + phandle phandle; + const char *full_name; + struct fwnode_handle fwnode; + struct property *properties; + struct property *deadprops; + struct device_node *parent; + struct device_node *child; + struct device_node *sibling; + long unsigned int _flags; + void *data; +}; + +enum cpuhp_state { + CPUHP_INVALID = 4294967295, + CPUHP_OFFLINE = 0, + CPUHP_CREATE_THREADS = 1, + CPUHP_PERF_PREPARE = 2, + CPUHP_PERF_X86_PREPARE = 3, + CPUHP_PERF_X86_AMD_UNCORE_PREP = 4, + CPUHP_PERF_POWER = 5, + CPUHP_PERF_SUPERH = 6, + CPUHP_X86_HPET_DEAD = 7, + CPUHP_X86_APB_DEAD = 8, + CPUHP_X86_MCE_DEAD = 9, + CPUHP_VIRT_NET_DEAD = 10, + CPUHP_SLUB_DEAD = 11, + CPUHP_DEBUG_OBJ_DEAD = 12, + CPUHP_MM_WRITEBACK_DEAD = 13, + CPUHP_MM_VMSTAT_DEAD = 14, + CPUHP_SOFTIRQ_DEAD = 15, + CPUHP_NET_MVNETA_DEAD = 16, + CPUHP_CPUIDLE_DEAD = 17, + CPUHP_ARM64_FPSIMD_DEAD = 18, + CPUHP_ARM_OMAP_WAKE_DEAD = 19, + CPUHP_IRQ_POLL_DEAD = 20, + CPUHP_BLOCK_SOFTIRQ_DEAD = 21, + CPUHP_ACPI_CPUDRV_DEAD = 22, + CPUHP_S390_PFAULT_DEAD = 23, + CPUHP_BLK_MQ_DEAD = 24, + CPUHP_FS_BUFF_DEAD = 25, + CPUHP_PRINTK_DEAD = 26, + CPUHP_MM_MEMCQ_DEAD = 27, + CPUHP_PERCPU_CNT_DEAD = 28, + CPUHP_RADIX_DEAD = 29, + CPUHP_PAGE_ALLOC_DEAD = 30, + CPUHP_NET_DEV_DEAD = 31, + CPUHP_PCI_XGENE_DEAD = 32, + CPUHP_IOMMU_INTEL_DEAD = 33, + CPUHP_LUSTRE_CFS_DEAD = 34, + CPUHP_AP_ARM_CACHE_B15_RAC_DEAD = 35, + CPUHP_PADATA_DEAD = 36, + CPUHP_WORKQUEUE_PREP = 37, + CPUHP_POWER_NUMA_PREPARE = 38, + CPUHP_HRTIMERS_PREPARE = 39, + CPUHP_PROFILE_PREPARE = 40, + CPUHP_X2APIC_PREPARE = 41, + CPUHP_SMPCFD_PREPARE = 42, + CPUHP_RELAY_PREPARE = 43, + CPUHP_SLAB_PREPARE = 44, + CPUHP_MD_RAID5_PREPARE = 45, + CPUHP_RCUTREE_PREP = 46, + CPUHP_CPUIDLE_COUPLED_PREPARE = 47, + CPUHP_POWERPC_PMAC_PREPARE = 48, + CPUHP_POWERPC_MMU_CTX_PREPARE = 49, + CPUHP_XEN_PREPARE = 50, + CPUHP_XEN_EVTCHN_PREPARE = 51, + CPUHP_ARM_SHMOBILE_SCU_PREPARE = 52, + CPUHP_SH_SH3X_PREPARE = 53, + CPUHP_NET_FLOW_PREPARE = 54, + CPUHP_TOPOLOGY_PREPARE = 55, + CPUHP_NET_IUCV_PREPARE = 56, + CPUHP_ARM_BL_PREPARE = 57, + CPUHP_TRACE_RB_PREPARE = 58, + CPUHP_MM_ZS_PREPARE = 59, + CPUHP_MM_ZSWP_MEM_PREPARE = 60, + CPUHP_MM_ZSWP_POOL_PREPARE = 61, + CPUHP_KVM_PPC_BOOK3S_PREPARE = 62, + CPUHP_ZCOMP_PREPARE = 63, + CPUHP_TIMERS_PREPARE = 64, + CPUHP_MIPS_SOC_PREPARE = 65, + CPUHP_BP_PREPARE_DYN = 66, + CPUHP_BP_PREPARE_DYN_END = 86, + CPUHP_BRINGUP_CPU = 87, + CPUHP_AP_IDLE_DEAD = 88, + CPUHP_AP_OFFLINE = 89, + CPUHP_AP_SCHED_STARTING = 90, + CPUHP_AP_RCUTREE_DYING = 91, + CPUHP_AP_CPU_PM_STARTING = 92, + CPUHP_AP_IRQ_GIC_STARTING = 93, + CPUHP_AP_IRQ_HIP04_STARTING = 94, + CPUHP_AP_IRQ_ARMADA_XP_STARTING = 95, + CPUHP_AP_IRQ_BCM2836_STARTING = 96, + CPUHP_AP_IRQ_MIPS_GIC_STARTING = 97, + CPUHP_AP_IRQ_RISCV_STARTING = 98, + CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING = 99, + CPUHP_AP_ARM_MVEBU_COHERENCY = 100, + CPUHP_AP_MICROCODE_LOADER = 101, + CPUHP_AP_PERF_X86_AMD_UNCORE_STARTING = 102, + CPUHP_AP_PERF_X86_STARTING = 103, + CPUHP_AP_PERF_X86_AMD_IBS_STARTING = 104, + CPUHP_AP_PERF_X86_CQM_STARTING = 105, + CPUHP_AP_PERF_X86_CSTATE_STARTING = 106, + CPUHP_AP_PERF_XTENSA_STARTING = 107, + CPUHP_AP_MIPS_OP_LOONGSON3_STARTING = 108, + CPUHP_AP_ARM_SDEI_STARTING = 109, + CPUHP_AP_ARM_VFP_STARTING = 110, + CPUHP_AP_ARM64_DEBUG_MONITORS_STARTING = 111, + CPUHP_AP_PERF_ARM_HW_BREAKPOINT_STARTING = 112, + CPUHP_AP_PERF_ARM_ACPI_STARTING = 113, + CPUHP_AP_PERF_ARM_STARTING = 114, + CPUHP_AP_ARM_L2X0_STARTING = 115, + CPUHP_AP_EXYNOS4_MCT_TIMER_STARTING = 116, + CPUHP_AP_ARM_ARCH_TIMER_STARTING = 117, + CPUHP_AP_ARM_GLOBAL_TIMER_STARTING = 118, + CPUHP_AP_JCORE_TIMER_STARTING = 119, + CPUHP_AP_ARM_TWD_STARTING = 120, + CPUHP_AP_QCOM_TIMER_STARTING = 121, + CPUHP_AP_TEGRA_TIMER_STARTING = 122, + CPUHP_AP_ARMADA_TIMER_STARTING = 123, + CPUHP_AP_MARCO_TIMER_STARTING = 124, + CPUHP_AP_MIPS_GIC_TIMER_STARTING = 125, + CPUHP_AP_ARC_TIMER_STARTING = 126, + CPUHP_AP_RISCV_TIMER_STARTING = 127, + CPUHP_AP_CLINT_TIMER_STARTING = 128, + CPUHP_AP_CSKY_TIMER_STARTING = 129, + CPUHP_AP_HYPERV_TIMER_STARTING = 130, + CPUHP_AP_KVM_STARTING = 131, + CPUHP_AP_KVM_ARM_VGIC_INIT_STARTING = 132, + CPUHP_AP_KVM_ARM_VGIC_STARTING = 133, + CPUHP_AP_KVM_ARM_TIMER_STARTING = 134, + CPUHP_AP_DUMMY_TIMER_STARTING = 135, + CPUHP_AP_ARM_XEN_STARTING = 136, + CPUHP_AP_ARM_CORESIGHT_STARTING = 137, + CPUHP_AP_ARM_CORESIGHT_CTI_STARTING = 138, + CPUHP_AP_ARM64_ISNDEP_STARTING = 139, + CPUHP_AP_SMPCFD_DYING = 140, + CPUHP_AP_X86_TBOOT_DYING = 141, + CPUHP_AP_ARM_CACHE_B15_RAC_DYING = 142, + CPUHP_AP_ONLINE = 143, + CPUHP_TEARDOWN_CPU = 144, + CPUHP_AP_ONLINE_IDLE = 145, + CPUHP_AP_SMPBOOT_THREADS = 146, + CPUHP_AP_X86_VDSO_VMA_ONLINE = 147, + CPUHP_AP_IRQ_AFFINITY_ONLINE = 148, + CPUHP_AP_BLK_MQ_ONLINE = 149, + CPUHP_AP_ARM_MVEBU_SYNC_CLOCKS = 150, + CPUHP_AP_X86_INTEL_EPB_ONLINE = 151, + CPUHP_AP_PERF_ONLINE = 152, + CPUHP_AP_PERF_X86_ONLINE = 153, + CPUHP_AP_PERF_X86_UNCORE_ONLINE = 154, + CPUHP_AP_PERF_X86_AMD_UNCORE_ONLINE = 155, + CPUHP_AP_PERF_X86_AMD_POWER_ONLINE = 156, + CPUHP_AP_PERF_X86_RAPL_ONLINE = 157, + CPUHP_AP_PERF_X86_CQM_ONLINE = 158, + CPUHP_AP_PERF_X86_CSTATE_ONLINE = 159, + CPUHP_AP_PERF_S390_CF_ONLINE = 160, + CPUHP_AP_PERF_S390_SF_ONLINE = 161, + CPUHP_AP_PERF_ARM_CCI_ONLINE = 162, + CPUHP_AP_PERF_ARM_CCN_ONLINE = 163, + CPUHP_AP_PERF_ARM_HISI_DDRC_ONLINE = 164, + CPUHP_AP_PERF_ARM_HISI_HHA_ONLINE = 165, + CPUHP_AP_PERF_ARM_HISI_L3_ONLINE = 166, + CPUHP_AP_PERF_ARM_L2X0_ONLINE = 167, + CPUHP_AP_PERF_ARM_QCOM_L2_ONLINE = 168, + CPUHP_AP_PERF_ARM_QCOM_L3_ONLINE = 169, + CPUHP_AP_PERF_ARM_APM_XGENE_ONLINE = 170, + CPUHP_AP_PERF_ARM_CAVIUM_TX2_UNCORE_ONLINE = 171, + CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE = 172, + CPUHP_AP_PERF_POWERPC_CORE_IMC_ONLINE = 173, + CPUHP_AP_PERF_POWERPC_THREAD_IMC_ONLINE = 174, + CPUHP_AP_PERF_POWERPC_TRACE_IMC_ONLINE = 175, + CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE = 176, + CPUHP_AP_PERF_POWERPC_HV_GPCI_ONLINE = 177, + CPUHP_AP_WATCHDOG_ONLINE = 178, + CPUHP_AP_WORKQUEUE_ONLINE = 179, + CPUHP_AP_RCUTREE_ONLINE = 180, + CPUHP_AP_BASE_CACHEINFO_ONLINE = 181, + CPUHP_AP_ONLINE_DYN = 182, + CPUHP_AP_ONLINE_DYN_END = 212, + CPUHP_AP_X86_HPET_ONLINE = 213, + CPUHP_AP_X86_KVM_CLK_ONLINE = 214, + CPUHP_AP_ACTIVE = 215, + CPUHP_ONLINE = 216, +}; + +struct static_call_mod { + struct static_call_mod *next; + struct module *mod; + struct static_call_site *sites; +}; + +struct ring_buffer_event { + u32 type_len: 5; + u32 time_delta: 27; + u32 array[0]; +}; + +struct seq_buf { + char *buffer; + size_t size; + size_t len; + loff_t readpos; +}; + +struct trace_seq { + unsigned char buffer[4096]; + struct seq_buf seq; + int full; +}; + +enum perf_sw_ids { + PERF_COUNT_SW_CPU_CLOCK = 0, + PERF_COUNT_SW_TASK_CLOCK = 1, + PERF_COUNT_SW_PAGE_FAULTS = 2, + PERF_COUNT_SW_CONTEXT_SWITCHES = 3, + PERF_COUNT_SW_CPU_MIGRATIONS = 4, + PERF_COUNT_SW_PAGE_FAULTS_MIN = 5, + PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6, + PERF_COUNT_SW_ALIGNMENT_FAULTS = 7, + PERF_COUNT_SW_EMULATION_FAULTS = 8, + PERF_COUNT_SW_DUMMY = 9, + PERF_COUNT_SW_BPF_OUTPUT = 10, + PERF_COUNT_SW_MAX = 11, +}; + +union perf_mem_data_src { + __u64 val; + struct { + __u64 mem_op: 5; + __u64 mem_lvl: 14; + __u64 mem_snoop: 5; + __u64 mem_lock: 2; + __u64 mem_dtlb: 7; + __u64 mem_lvl_num: 4; + __u64 mem_remote: 1; + __u64 mem_snoopx: 2; + __u64 mem_rsvd: 24; + }; +}; + +struct perf_branch_entry { + __u64 from; + __u64 to; + __u64 mispred: 1; + __u64 predicted: 1; + __u64 in_tx: 1; + __u64 abort: 1; + __u64 cycles: 16; + __u64 type: 4; + __u64 reserved: 40; +}; + +struct new_utsname { + char sysname[65]; + char nodename[65]; + char release[65]; + char version[65]; + char machine[65]; + char domainname[65]; +}; + +struct uts_namespace { + struct kref kref; + struct new_utsname name; + struct user_namespace *user_ns; + struct ucounts *ucounts; + struct ns_common ns; +}; + +struct cgroup_namespace { + refcount_t count; + struct ns_common ns; + struct user_namespace *user_ns; + struct ucounts *ucounts; + struct css_set *root_cset; +}; + +struct nsset { + unsigned int flags; + struct nsproxy *nsproxy; + struct fs_struct *fs; + const struct cred *cred; +}; + +struct proc_ns_operations { + const char *name; + const char *real_ns_name; + int type; + struct ns_common * (*get)(struct task_struct *); + void (*put)(struct ns_common *); + int (*install)(struct nsset *, struct ns_common *); + struct user_namespace * (*owner)(struct ns_common *); + struct ns_common * (*get_parent)(struct ns_common *); +}; + +struct ucounts { + struct hlist_node node; + struct user_namespace *ns; + kuid_t uid; + int count; + atomic_t ucount[10]; +}; + +struct perf_cpu_context; + +struct perf_output_handle; + +struct pmu { + struct list_head entry; + struct module *module; + struct device *dev; + const struct attribute_group **attr_groups; + const struct attribute_group **attr_update; + const char *name; + int type; + int capabilities; + int *pmu_disable_count; + struct perf_cpu_context *pmu_cpu_context; + atomic_t exclusive_cnt; + int task_ctx_nr; + int hrtimer_interval_ms; + unsigned int nr_addr_filters; + void (*pmu_enable)(struct pmu *); + void (*pmu_disable)(struct pmu *); + int (*event_init)(struct perf_event *); + void (*event_mapped)(struct perf_event *, struct mm_struct *); + void (*event_unmapped)(struct perf_event *, struct mm_struct *); + int (*add)(struct perf_event *, int); + void (*del)(struct perf_event *, int); + void (*start)(struct perf_event *, int); + void (*stop)(struct perf_event *, int); + void (*read)(struct perf_event *); + void (*start_txn)(struct pmu *, unsigned int); + int (*commit_txn)(struct pmu *); + void (*cancel_txn)(struct pmu *); + int (*event_idx)(struct perf_event *); + void (*sched_task)(struct perf_event_context *, bool); + struct kmem_cache *task_ctx_cache; + void (*swap_task_ctx)(struct perf_event_context *, struct perf_event_context *); + void * (*setup_aux)(struct perf_event *, void **, int, bool); + void (*free_aux)(void *); + long int (*snapshot_aux)(struct perf_event *, struct perf_output_handle *, long unsigned int); + int (*addr_filters_validate)(struct list_head *); + void (*addr_filters_sync)(struct perf_event *); + int (*aux_output_match)(struct perf_event *); + int (*filter_match)(struct perf_event *); + int (*check_period)(struct perf_event *, u64); +}; + +struct iovec { + void *iov_base; + __kernel_size_t iov_len; +}; + +struct kvec { + void *iov_base; + size_t iov_len; +}; + +struct perf_regs { + __u64 abi; + struct pt_regs *regs; +}; + +struct u64_stats_sync {}; + +struct bpf_cgroup_storage_key { + __u64 cgroup_inode_id; + __u32 attach_type; +}; + +enum kmalloc_cache_type { + KMALLOC_NORMAL = 0, + KMALLOC_RECLAIM = 1, + KMALLOC_DMA = 2, + NR_KMALLOC_TYPES = 3, +}; + +struct bpf_cgroup_storage; + +struct bpf_prog_array_item { + struct bpf_prog *prog; + struct bpf_cgroup_storage *cgroup_storage[2]; +}; + +struct bpf_storage_buffer; + +struct bpf_cgroup_storage_map; + +struct bpf_cgroup_storage { + union { + struct bpf_storage_buffer *buf; + void *percpu_buf; + }; + struct bpf_cgroup_storage_map *map; + struct bpf_cgroup_storage_key key; + struct list_head list_map; + struct list_head list_cg; + struct rb_node node; + struct callback_head rcu; +}; + +struct bpf_prog_array { + struct callback_head rcu; + struct bpf_prog_array_item items[0]; +}; + +struct bpf_storage_buffer { + struct callback_head rcu; + char data[0]; +}; + +struct psi_group_cpu { + seqcount_t seq; + unsigned int tasks[4]; + u32 state_mask; + u32 times[6]; + u64 state_start; + long: 64; + u32 times_prev[12]; + long: 64; + long: 64; +}; + +struct cgroup_taskset; + +struct cftype; + +struct cgroup_subsys { + struct cgroup_subsys_state * (*css_alloc)(struct cgroup_subsys_state *); + int (*css_online)(struct cgroup_subsys_state *); + void (*css_offline)(struct cgroup_subsys_state *); + void (*css_released)(struct cgroup_subsys_state *); + void (*css_free)(struct cgroup_subsys_state *); + void (*css_reset)(struct cgroup_subsys_state *); + void (*css_rstat_flush)(struct cgroup_subsys_state *, int); + int (*css_extra_stat_show)(struct seq_file *, struct cgroup_subsys_state *); + int (*can_attach)(struct cgroup_taskset *); + void (*cancel_attach)(struct cgroup_taskset *); + void (*attach)(struct cgroup_taskset *); + void (*post_attach)(); + int (*can_fork)(struct task_struct *, struct css_set *); + void (*cancel_fork)(struct task_struct *, struct css_set *); + void (*fork)(struct task_struct *); + void (*exit)(struct task_struct *); + void (*release)(struct task_struct *); + void (*bind)(struct cgroup_subsys_state *); + bool early_init: 1; + bool implicit_on_dfl: 1; + bool threaded: 1; + bool broken_hierarchy: 1; + bool warned_broken_hierarchy: 1; + int id; + const char *name; + const char *legacy_name; + struct cgroup_root *root; + struct idr css_idr; + struct list_head cfts; + struct cftype *dfl_cftypes; + struct cftype *legacy_cftypes; + unsigned int depends_on; +}; + +struct cgroup_rstat_cpu { + struct u64_stats_sync bsync; + struct cgroup_base_stat bstat; + struct cgroup_base_stat last_bstat; + struct cgroup *updated_children; + struct cgroup *updated_next; +}; + +struct cgroup_root { + struct kernfs_root *kf_root; + unsigned int subsys_mask; + int hierarchy_id; + struct cgroup cgrp; + u64 cgrp_ancestor_id_storage; + atomic_t nr_cgrps; + struct list_head root_list; + unsigned int flags; + char release_agent_path[4096]; + char name[64]; +}; + +struct cftype { + char name[64]; + long unsigned int private; + size_t max_write_len; + unsigned int flags; + unsigned int file_offset; + struct cgroup_subsys *ss; + struct list_head node; + struct kernfs_ops *kf_ops; + int (*open)(struct kernfs_open_file *); + void (*release)(struct kernfs_open_file *); + u64 (*read_u64)(struct cgroup_subsys_state *, struct cftype *); + s64 (*read_s64)(struct cgroup_subsys_state *, struct cftype *); + int (*seq_show)(struct seq_file *, void *); + void * (*seq_start)(struct seq_file *, loff_t *); + void * (*seq_next)(struct seq_file *, void *, loff_t *); + void (*seq_stop)(struct seq_file *, void *); + int (*write_u64)(struct cgroup_subsys_state *, struct cftype *, u64); + int (*write_s64)(struct cgroup_subsys_state *, struct cftype *, s64); + ssize_t (*write)(struct kernfs_open_file *, char *, size_t, loff_t); + __poll_t (*poll)(struct kernfs_open_file *, struct poll_table_struct *); +}; + +struct perf_callchain_entry { + __u64 nr; + __u64 ip[0]; +}; + +typedef long unsigned int (*perf_copy_f)(void *, const void *, long unsigned int, long unsigned int); + +struct perf_raw_frag { + union { + struct perf_raw_frag *next; + long unsigned int pad; + }; + perf_copy_f copy; + void *data; + u32 size; +} __attribute__((packed)); + +struct perf_raw_record { + struct perf_raw_frag frag; + u32 size; +}; + +struct perf_branch_stack { + __u64 nr; + __u64 hw_idx; + struct perf_branch_entry entries[0]; +}; + +struct perf_cpu_context { + struct perf_event_context ctx; + struct perf_event_context *task_ctx; + int active_oncpu; + int exclusive; + raw_spinlock_t hrtimer_lock; + struct hrtimer hrtimer; + ktime_t hrtimer_interval; + unsigned int hrtimer_active; + struct perf_cgroup *cgrp; + struct list_head cgrp_cpuctx_entry; + int sched_cb_usage; + int online; + int heap_size; + struct perf_event **heap; + struct perf_event *heap_default[2]; +}; + +struct perf_output_handle { + struct perf_event *event; + struct perf_buffer *rb; + long unsigned int wakeup; + long unsigned int size; + u64 aux_flags; + union { + void *addr; + long unsigned int head; + }; + int page; +}; + +struct perf_addr_filter_range { + long unsigned int start; + long unsigned int size; +}; + +struct perf_sample_data { + u64 addr; + struct perf_raw_record *raw; + struct perf_branch_stack *br_stack; + u64 period; + u64 weight; + u64 txn; + union perf_mem_data_src data_src; + u64 type; + u64 ip; + struct { + u32 pid; + u32 tid; + } tid_entry; + u64 time; + u64 id; + u64 stream_id; + struct { + u32 cpu; + u32 reserved; + } cpu_entry; + struct perf_callchain_entry *callchain; + u64 aux_size; + struct perf_regs regs_user; + struct pt_regs regs_user_copy; + struct perf_regs regs_intr; + u64 stack_user_size; + u64 phys_addr; + u64 cgroup; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct perf_cgroup_info; + +struct perf_cgroup { + struct cgroup_subsys_state css; + struct perf_cgroup_info *info; +}; + +struct perf_cgroup_info { + u64 time; + u64 timestamp; +}; + +struct trace_entry { + short unsigned int type; + unsigned char flags; + unsigned char preempt_count; + int pid; +}; + +struct trace_array; + +struct tracer; + +struct array_buffer; + +struct ring_buffer_iter; + +struct trace_iterator { + struct trace_array *tr; + struct tracer *trace; + struct array_buffer *array_buffer; + void *private; + int cpu_file; + struct mutex mutex; + struct ring_buffer_iter **buffer_iter; + long unsigned int iter_flags; + void *temp; + unsigned int temp_size; + struct trace_seq tmp_seq; + cpumask_var_t started; + bool snapshot; + struct trace_seq seq; + struct trace_entry *ent; + long unsigned int lost_events; + int leftover; + int ent_size; + int cpu; + u64 ts; + loff_t pos; + long int idx; +}; + +enum print_line_t { + TRACE_TYPE_PARTIAL_LINE = 0, + TRACE_TYPE_HANDLED = 1, + TRACE_TYPE_UNHANDLED = 2, + TRACE_TYPE_NO_CONSUME = 3, +}; + +typedef enum print_line_t (*trace_print_func)(struct trace_iterator *, int, struct trace_event *); + +struct trace_event_functions { + trace_print_func trace; + trace_print_func raw; + trace_print_func hex; + trace_print_func binary; +}; + +enum trace_reg { + TRACE_REG_REGISTER = 0, + TRACE_REG_UNREGISTER = 1, + TRACE_REG_PERF_REGISTER = 2, + TRACE_REG_PERF_UNREGISTER = 3, + TRACE_REG_PERF_OPEN = 4, + TRACE_REG_PERF_CLOSE = 5, + TRACE_REG_PERF_ADD = 6, + TRACE_REG_PERF_DEL = 7, +}; + +struct trace_event_fields { + const char *type; + union { + struct { + const char *name; + const int size; + const int align; + const int is_signed; + const int filter_type; + }; + int (*define_fields)(struct trace_event_call *); + }; +}; + +struct trace_event_class { + const char *system; + void *probe; + void *perf_probe; + int (*reg)(struct trace_event_call *, enum trace_reg, void *); + struct trace_event_fields *fields_array; + struct list_head * (*get_fields)(struct trace_event_call *); + struct list_head fields; + int (*raw_init)(struct trace_event_call *); +}; + +struct trace_buffer; + +struct trace_event_file; + +struct trace_event_buffer { + struct trace_buffer *buffer; + struct ring_buffer_event *event; + struct trace_event_file *trace_file; + void *entry; + long unsigned int flags; + int pc; + struct pt_regs *regs; +}; + +struct trace_subsystem_dir; + +struct trace_event_file { + struct list_head list; + struct trace_event_call *event_call; + struct event_filter *filter; + struct dentry *dir; + struct trace_array *tr; + struct trace_subsystem_dir *system; + struct list_head triggers; + long unsigned int flags; + atomic_t sm_ref; + atomic_t tm_ref; +}; + +enum { + TRACE_EVENT_FL_FILTERED_BIT = 0, + TRACE_EVENT_FL_CAP_ANY_BIT = 1, + TRACE_EVENT_FL_NO_SET_FILTER_BIT = 2, + TRACE_EVENT_FL_IGNORE_ENABLE_BIT = 3, + TRACE_EVENT_FL_TRACEPOINT_BIT = 4, + TRACE_EVENT_FL_KPROBE_BIT = 5, + TRACE_EVENT_FL_UPROBE_BIT = 6, +}; + +enum { + TRACE_EVENT_FL_FILTERED = 1, + TRACE_EVENT_FL_CAP_ANY = 2, + TRACE_EVENT_FL_NO_SET_FILTER = 4, + TRACE_EVENT_FL_IGNORE_ENABLE = 8, + TRACE_EVENT_FL_TRACEPOINT = 16, + TRACE_EVENT_FL_KPROBE = 32, + TRACE_EVENT_FL_UPROBE = 64, +}; + +enum { + EVENT_FILE_FL_ENABLED_BIT = 0, + EVENT_FILE_FL_RECORDED_CMD_BIT = 1, + EVENT_FILE_FL_RECORDED_TGID_BIT = 2, + EVENT_FILE_FL_FILTERED_BIT = 3, + EVENT_FILE_FL_NO_SET_FILTER_BIT = 4, + EVENT_FILE_FL_SOFT_MODE_BIT = 5, + EVENT_FILE_FL_SOFT_DISABLED_BIT = 6, + EVENT_FILE_FL_TRIGGER_MODE_BIT = 7, + EVENT_FILE_FL_TRIGGER_COND_BIT = 8, + EVENT_FILE_FL_PID_FILTER_BIT = 9, + EVENT_FILE_FL_WAS_ENABLED_BIT = 10, +}; + +enum { + EVENT_FILE_FL_ENABLED = 1, + EVENT_FILE_FL_RECORDED_CMD = 2, + EVENT_FILE_FL_RECORDED_TGID = 4, + EVENT_FILE_FL_FILTERED = 8, + EVENT_FILE_FL_NO_SET_FILTER = 16, + EVENT_FILE_FL_SOFT_MODE = 32, + EVENT_FILE_FL_SOFT_DISABLED = 64, + EVENT_FILE_FL_TRIGGER_MODE = 128, + EVENT_FILE_FL_TRIGGER_COND = 256, + EVENT_FILE_FL_PID_FILTER = 512, + EVENT_FILE_FL_WAS_ENABLED = 1024, +}; + +enum { + FILTER_OTHER = 0, + FILTER_STATIC_STRING = 1, + FILTER_DYN_STRING = 2, + FILTER_PTR_STRING = 3, + FILTER_TRACE_FN = 4, + FILTER_COMM = 5, + FILTER_CPU = 6, +}; + +struct fwnode_reference_args; + +struct fwnode_endpoint; + +struct fwnode_operations { + struct fwnode_handle * (*get)(struct fwnode_handle *); + void (*put)(struct fwnode_handle *); + bool (*device_is_available)(const struct fwnode_handle *); + const void * (*device_get_match_data)(const struct fwnode_handle *, const struct device *); + bool (*property_present)(const struct fwnode_handle *, const char *); + int (*property_read_int_array)(const struct fwnode_handle *, const char *, unsigned int, void *, size_t); + int (*property_read_string_array)(const struct fwnode_handle *, const char *, const char **, size_t); + const char * (*get_name)(const struct fwnode_handle *); + const char * (*get_name_prefix)(const struct fwnode_handle *); + struct fwnode_handle * (*get_parent)(const struct fwnode_handle *); + struct fwnode_handle * (*get_next_child_node)(const struct fwnode_handle *, struct fwnode_handle *); + struct fwnode_handle * (*get_named_child_node)(const struct fwnode_handle *, const char *); + int (*get_reference_args)(const struct fwnode_handle *, const char *, const char *, unsigned int, unsigned int, struct fwnode_reference_args *); + struct fwnode_handle * (*graph_get_next_endpoint)(const struct fwnode_handle *, struct fwnode_handle *); + struct fwnode_handle * (*graph_get_remote_endpoint)(const struct fwnode_handle *); + struct fwnode_handle * (*graph_get_port_parent)(struct fwnode_handle *); + int (*graph_parse_endpoint)(const struct fwnode_handle *, struct fwnode_endpoint *); + int (*add_links)(const struct fwnode_handle *, struct device *); +}; + +struct fwnode_endpoint { + unsigned int port; + unsigned int id; + const struct fwnode_handle *local_fwnode; +}; + +struct fwnode_reference_args { + struct fwnode_handle *fwnode; + unsigned int nargs; + u64 args[8]; +}; + +struct property { + char *name; + int length; + void *value; + struct property *next; +}; + +struct irq_fwspec { + struct fwnode_handle *fwnode; + int param_count; + u32 param[16]; +}; + +struct irq_data; + +struct irq_domain_ops { + int (*match)(struct irq_domain *, struct device_node *, enum irq_domain_bus_token); + int (*select)(struct irq_domain *, struct irq_fwspec *, enum irq_domain_bus_token); + int (*map)(struct irq_domain *, unsigned int, irq_hw_number_t); + void (*unmap)(struct irq_domain *, unsigned int); + int (*xlate)(struct irq_domain *, struct device_node *, const u32 *, unsigned int, long unsigned int *, unsigned int *); + int (*alloc)(struct irq_domain *, unsigned int, unsigned int, void *); + void (*free)(struct irq_domain *, unsigned int, unsigned int); + int (*activate)(struct irq_domain *, struct irq_data *, bool); + void (*deactivate)(struct irq_domain *, struct irq_data *); + int (*translate)(struct irq_domain *, struct irq_fwspec *, long unsigned int *, unsigned int *); +}; + +enum wb_stat_item { + WB_RECLAIMABLE = 0, + WB_WRITEBACK = 1, + WB_DIRTIED = 2, + WB_WRITTEN = 3, + NR_WB_STAT_ITEMS = 4, +}; + +struct disk_stats; + +struct partition_meta_info; + +struct hd_struct { + sector_t start_sect; + sector_t nr_sects; + long unsigned int stamp; + struct disk_stats *dkstats; + struct percpu_ref ref; + struct device __dev; + struct kobject *holder_dir; + int policy; + int partno; + struct partition_meta_info *info; + struct rcu_work rcu_work; +}; + +struct disk_part_tbl; + +struct block_device_operations; + +struct timer_rand_state; + +struct disk_events; + +struct cdrom_device_info; + +struct badblocks; + +struct gendisk { + int major; + int first_minor; + int minors; + char disk_name[32]; + short unsigned int events; + short unsigned int event_flags; + struct disk_part_tbl *part_tbl; + struct hd_struct part0; + const struct block_device_operations *fops; + struct request_queue *queue; + void *private_data; + int flags; + long unsigned int state; + struct rw_semaphore lookup_sem; + struct kobject *slave_dir; + struct timer_rand_state *random; + atomic_t sync_io; + struct disk_events *ev; + struct cdrom_device_info *cdi; + int node_id; + struct badblocks *bb; + struct lockdep_map lockdep_map; +}; + +struct blkg_iostat { + u64 bytes[3]; + u64 ios[3]; +}; + +struct blkg_iostat_set { + struct u64_stats_sync sync; + struct blkg_iostat cur; + struct blkg_iostat last; +}; + +struct blkcg; + +struct blkg_policy_data; + +struct blkcg_gq { + struct request_queue *q; + struct list_head q_node; + struct hlist_node blkcg_node; + struct blkcg *blkcg; + struct blkcg_gq *parent; + struct percpu_ref refcnt; + bool online; + struct blkg_iostat_set *iostat_cpu; + struct blkg_iostat_set iostat; + struct blkg_policy_data *pd[5]; + spinlock_t async_bio_lock; + struct bio_list async_bios; + struct work_struct async_bio_work; + atomic_t use_delay; + atomic64_t delay_nsec; + atomic64_t delay_start; + u64 last_delay; + int last_use; + struct callback_head callback_head; +}; + +typedef unsigned int blk_qc_t; + +struct partition_meta_info { + char uuid[37]; + u8 volname[64]; +}; + +struct disk_part_tbl { + struct callback_head callback_head; + int len; + struct hd_struct *last_lookup; + struct hd_struct *part[0]; +}; + +struct blk_zone; + +typedef int (*report_zones_cb)(struct blk_zone *, unsigned int, void *); + +struct hd_geometry; + +struct pr_ops; + +struct block_device_operations { + blk_qc_t (*submit_bio)(struct bio *); + int (*open)(struct block_device *, fmode_t); + void (*release)(struct gendisk *, fmode_t); + int (*rw_page)(struct block_device *, sector_t, struct page *, unsigned int); + int (*ioctl)(struct block_device *, fmode_t, unsigned int, long unsigned int); + int (*compat_ioctl)(struct block_device *, fmode_t, unsigned int, long unsigned int); + unsigned int (*check_events)(struct gendisk *, unsigned int); + void (*unlock_native_capacity)(struct gendisk *); + int (*revalidate_disk)(struct gendisk *); + int (*getgeo)(struct block_device *, struct hd_geometry *); + void (*swap_slot_free_notify)(struct block_device *, long unsigned int); + int (*report_zones)(struct gendisk *, sector_t, unsigned int, report_zones_cb, void *); + char * (*devnode)(struct gendisk *, umode_t *); + struct module *owner; + const struct pr_ops *pr_ops; +}; + +struct sg_io_v4 { + __s32 guard; + __u32 protocol; + __u32 subprotocol; + __u32 request_len; + __u64 request; + __u64 request_tag; + __u32 request_attr; + __u32 request_priority; + __u32 request_extra; + __u32 max_response_len; + __u64 response; + __u32 dout_iovec_count; + __u32 dout_xfer_len; + __u32 din_iovec_count; + __u32 din_xfer_len; + __u64 dout_xferp; + __u64 din_xferp; + __u32 timeout; + __u32 flags; + __u64 usr_ptr; + __u32 spare_in; + __u32 driver_status; + __u32 transport_status; + __u32 device_status; + __u32 retry_delay; + __u32 info; + __u32 duration; + __u32 response_len; + __s32 din_resid; + __s32 dout_resid; + __u64 generated_tag; + __u32 spare_out; + __u32 padding; +}; + +struct bsg_ops { + int (*check_proto)(struct sg_io_v4 *); + int (*fill_hdr)(struct request *, struct sg_io_v4 *, fmode_t); + int (*complete_rq)(struct request *, struct sg_io_v4 *); + void (*free_rq)(struct request *); +}; + +typedef __u32 req_flags_t; + +typedef void rq_end_io_fn(struct request *, blk_status_t); + +enum mq_rq_state { + MQ_RQ_IDLE = 0, + MQ_RQ_IN_FLIGHT = 1, + MQ_RQ_COMPLETE = 2, +}; + +struct request { + struct request_queue *q; + struct blk_mq_ctx *mq_ctx; + struct blk_mq_hw_ctx *mq_hctx; + unsigned int cmd_flags; + req_flags_t rq_flags; + int tag; + int internal_tag; + unsigned int __data_len; + sector_t __sector; + struct bio *bio; + struct bio *biotail; + struct list_head queuelist; + union { + struct hlist_node hash; + struct list_head ipi_list; + }; + union { + struct rb_node rb_node; + struct bio_vec special_vec; + void *completion_data; + int error_count; + }; + union { + struct { + struct io_cq *icq; + void *priv[2]; + } elv; + struct { + unsigned int seq; + struct list_head list; + rq_end_io_fn *saved_end_io; + } flush; + }; + struct gendisk *rq_disk; + struct hd_struct *part; + u64 start_time_ns; + u64 io_start_time_ns; + short unsigned int stats_sectors; + short unsigned int nr_phys_segments; + short unsigned int write_hint; + short unsigned int ioprio; + enum mq_rq_state state; + refcount_t ref; + unsigned int timeout; + long unsigned int deadline; + union { + struct __call_single_data csd; + u64 fifo_time; + }; + rq_end_io_fn *end_io; + void *end_io_data; +}; + +struct blk_zone { + __u64 start; + __u64 len; + __u64 wp; + __u8 type; + __u8 cond; + __u8 non_seq; + __u8 reset; + __u8 resv[4]; + __u64 capacity; + __u8 reserved[24]; +}; + +enum elv_merge { + ELEVATOR_NO_MERGE = 0, + ELEVATOR_FRONT_MERGE = 1, + ELEVATOR_BACK_MERGE = 2, + ELEVATOR_DISCARD_MERGE = 3, +}; + +struct elevator_type; + +struct blk_mq_alloc_data; + +struct elevator_mq_ops { + int (*init_sched)(struct request_queue *, struct elevator_type *); + void (*exit_sched)(struct elevator_queue *); + int (*init_hctx)(struct blk_mq_hw_ctx *, unsigned int); + void (*exit_hctx)(struct blk_mq_hw_ctx *, unsigned int); + void (*depth_updated)(struct blk_mq_hw_ctx *); + bool (*allow_merge)(struct request_queue *, struct request *, struct bio *); + bool (*bio_merge)(struct blk_mq_hw_ctx *, struct bio *, unsigned int); + int (*request_merge)(struct request_queue *, struct request **, struct bio *); + void (*request_merged)(struct request_queue *, struct request *, enum elv_merge); + void (*requests_merged)(struct request_queue *, struct request *, struct request *); + void (*limit_depth)(unsigned int, struct blk_mq_alloc_data *); + void (*prepare_request)(struct request *); + void (*finish_request)(struct request *); + void (*insert_requests)(struct blk_mq_hw_ctx *, struct list_head *, bool); + struct request * (*dispatch_request)(struct blk_mq_hw_ctx *); + bool (*has_work)(struct blk_mq_hw_ctx *); + void (*completed_request)(struct request *, u64); + void (*requeue_request)(struct request *); + struct request * (*former_request)(struct request_queue *, struct request *); + struct request * (*next_request)(struct request_queue *, struct request *); + void (*init_icq)(struct io_cq *); + void (*exit_icq)(struct io_cq *); +}; + +struct elv_fs_entry; + +struct blk_mq_debugfs_attr; + +struct elevator_type { + struct kmem_cache *icq_cache; + struct elevator_mq_ops ops; + size_t icq_size; + size_t icq_align; + struct elv_fs_entry *elevator_attrs; + const char *elevator_name; + const char *elevator_alias; + const unsigned int elevator_features; + struct module *elevator_owner; + const struct blk_mq_debugfs_attr *queue_debugfs_attrs; + const struct blk_mq_debugfs_attr *hctx_debugfs_attrs; + char icq_cache_name[22]; + struct list_head list; +}; + +struct elevator_queue { + struct elevator_type *type; + void *elevator_data; + struct kobject kobj; + struct mutex sysfs_lock; + unsigned int registered: 1; + struct hlist_head hash[64]; +}; + +struct elv_fs_entry { + struct attribute attr; + ssize_t (*show)(struct elevator_queue *, char *); + ssize_t (*store)(struct elevator_queue *, const char *, size_t); +}; + +struct blk_mq_debugfs_attr { + const char *name; + umode_t mode; + int (*show)(void *, struct seq_file *); + ssize_t (*write)(void *, const char *, size_t, loff_t *); + const struct seq_operations *seq_ops; +}; + +enum blk_eh_timer_return { + BLK_EH_DONE = 0, + BLK_EH_RESET_TIMER = 1, +}; + +struct blk_mq_queue_data; + +struct blk_mq_ops { + blk_status_t (*queue_rq)(struct blk_mq_hw_ctx *, const struct blk_mq_queue_data *); + void (*commit_rqs)(struct blk_mq_hw_ctx *); + bool (*get_budget)(struct request_queue *); + void (*put_budget)(struct request_queue *); + enum blk_eh_timer_return (*timeout)(struct request *, bool); + int (*poll)(struct blk_mq_hw_ctx *); + void (*complete)(struct request *); + int (*init_hctx)(struct blk_mq_hw_ctx *, void *, unsigned int); + void (*exit_hctx)(struct blk_mq_hw_ctx *, unsigned int); + int (*init_request)(struct blk_mq_tag_set *, struct request *, unsigned int, unsigned int); + void (*exit_request)(struct blk_mq_tag_set *, struct request *, unsigned int); + void (*initialize_rq_fn)(struct request *); + void (*cleanup_rq)(struct request *); + bool (*busy)(struct request_queue *); + int (*map_queues)(struct blk_mq_tag_set *); + void (*show_rq)(struct seq_file *, struct request *); +}; + +enum pr_type { + PR_WRITE_EXCLUSIVE = 1, + PR_EXCLUSIVE_ACCESS = 2, + PR_WRITE_EXCLUSIVE_REG_ONLY = 3, + PR_EXCLUSIVE_ACCESS_REG_ONLY = 4, + PR_WRITE_EXCLUSIVE_ALL_REGS = 5, + PR_EXCLUSIVE_ACCESS_ALL_REGS = 6, +}; + +struct pr_ops { + int (*pr_register)(struct block_device *, u64, u64, u32); + int (*pr_reserve)(struct block_device *, u64, enum pr_type, u32); + int (*pr_release)(struct block_device *, u64, enum pr_type); + int (*pr_preempt)(struct block_device *, u64, u64, enum pr_type, bool); + int (*pr_clear)(struct block_device *, u64); +}; + +enum blkg_iostat_type { + BLKG_IOSTAT_READ = 0, + BLKG_IOSTAT_WRITE = 1, + BLKG_IOSTAT_DISCARD = 2, + BLKG_IOSTAT_NR = 3, +}; + +struct blkcg_policy_data; + +struct blkcg { + struct cgroup_subsys_state css; + spinlock_t lock; + refcount_t online_pin; + struct xarray blkg_tree; + struct blkcg_gq *blkg_hint; + struct hlist_head blkg_list; + struct blkcg_policy_data *cpd[5]; + struct list_head all_blkcgs_node; + struct list_head cgwb_list; +}; + +struct blkcg_policy_data { + struct blkcg *blkcg; + int plid; +}; + +struct blkg_policy_data { + struct blkcg_gq *blkg; + int plid; +}; + +typedef long unsigned int efi_status_t; + +typedef u8 efi_bool_t; + +typedef u16 efi_char16_t; + +typedef guid_t efi_guid_t; + +typedef struct { + u64 signature; + u32 revision; + u32 headersize; + u32 crc32; + u32 reserved; +} efi_table_hdr_t; + +typedef struct { + u32 type; + u32 pad; + u64 phys_addr; + u64 virt_addr; + u64 num_pages; + u64 attribute; +} efi_memory_desc_t; + +typedef struct { + efi_guid_t guid; + u32 headersize; + u32 flags; + u32 imagesize; +} efi_capsule_header_t; + +typedef struct { + u16 year; + u8 month; + u8 day; + u8 hour; + u8 minute; + u8 second; + u8 pad1; + u32 nanosecond; + s16 timezone; + u8 daylight; + u8 pad2; +} efi_time_t; + +typedef struct { + u32 resolution; + u32 accuracy; + u8 sets_to_zero; +} efi_time_cap_t; + +typedef struct { + efi_table_hdr_t hdr; + u32 get_time; + u32 set_time; + u32 get_wakeup_time; + u32 set_wakeup_time; + u32 set_virtual_address_map; + u32 convert_pointer; + u32 get_variable; + u32 get_next_variable; + u32 set_variable; + u32 get_next_high_mono_count; + u32 reset_system; + u32 update_capsule; + u32 query_capsule_caps; + u32 query_variable_info; +} efi_runtime_services_32_t; + +typedef efi_status_t efi_get_time_t(efi_time_t *, efi_time_cap_t *); + +typedef efi_status_t efi_set_time_t(efi_time_t *); + +typedef efi_status_t efi_get_wakeup_time_t(efi_bool_t *, efi_bool_t *, efi_time_t *); + +typedef efi_status_t efi_set_wakeup_time_t(efi_bool_t, efi_time_t *); + +typedef efi_status_t efi_get_variable_t(efi_char16_t *, efi_guid_t *, u32 *, long unsigned int *, void *); + +typedef efi_status_t efi_get_next_variable_t(long unsigned int *, efi_char16_t *, efi_guid_t *); + +typedef efi_status_t efi_set_variable_t(efi_char16_t *, efi_guid_t *, u32, long unsigned int, void *); + +typedef efi_status_t efi_get_next_high_mono_count_t(u32 *); + +typedef void efi_reset_system_t(int, efi_status_t, long unsigned int, efi_char16_t *); + +typedef efi_status_t efi_query_variable_info_t(u32, u64 *, u64 *, u64 *); + +typedef efi_status_t efi_update_capsule_t(efi_capsule_header_t **, long unsigned int, long unsigned int); + +typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **, long unsigned int, u64 *, int *); + +typedef union { + struct { + efi_table_hdr_t hdr; + efi_status_t (*get_time)(efi_time_t *, efi_time_cap_t *); + efi_status_t (*set_time)(efi_time_t *); + efi_status_t (*get_wakeup_time)(efi_bool_t *, efi_bool_t *, efi_time_t *); + efi_status_t (*set_wakeup_time)(efi_bool_t, efi_time_t *); + efi_status_t (*set_virtual_address_map)(long unsigned int, long unsigned int, u32, efi_memory_desc_t *); + void *convert_pointer; + efi_status_t (*get_variable)(efi_char16_t *, efi_guid_t *, u32 *, long unsigned int *, void *); + efi_status_t (*get_next_variable)(long unsigned int *, efi_char16_t *, efi_guid_t *); + efi_status_t (*set_variable)(efi_char16_t *, efi_guid_t *, u32, long unsigned int, void *); + efi_status_t (*get_next_high_mono_count)(u32 *); + void (*reset_system)(int, efi_status_t, long unsigned int, efi_char16_t *); + efi_status_t (*update_capsule)(efi_capsule_header_t **, long unsigned int, long unsigned int); + efi_status_t (*query_capsule_caps)(efi_capsule_header_t **, long unsigned int, u64 *, int *); + efi_status_t (*query_variable_info)(u32, u64 *, u64 *, u64 *); + }; + efi_runtime_services_32_t mixed_mode; +} efi_runtime_services_t; + +struct efi_memory_map { + phys_addr_t phys_map; + void *map; + void *map_end; + int nr_map; + long unsigned int desc_version; + long unsigned int desc_size; + long unsigned int flags; +}; + +struct efi { + const efi_runtime_services_t *runtime; + unsigned int runtime_version; + unsigned int runtime_supported_mask; + long unsigned int acpi; + long unsigned int acpi20; + long unsigned int smbios; + long unsigned int smbios3; + long unsigned int esrt; + long unsigned int tpm_log; + long unsigned int tpm_final_log; + long unsigned int mokvar_table; + efi_get_time_t *get_time; + efi_set_time_t *set_time; + efi_get_wakeup_time_t *get_wakeup_time; + efi_set_wakeup_time_t *set_wakeup_time; + efi_get_variable_t *get_variable; + efi_get_next_variable_t *get_next_variable; + efi_set_variable_t *set_variable; + efi_set_variable_t *set_variable_nonblocking; + efi_query_variable_info_t *query_variable_info; + efi_query_variable_info_t *query_variable_info_nonblocking; + efi_update_capsule_t *update_capsule; + efi_query_capsule_caps_t *query_capsule_caps; + efi_get_next_high_mono_count_t *get_next_high_mono_count; + efi_reset_system_t *reset_system; + struct efi_memory_map memmap; + long unsigned int flags; +}; + +enum memcg_stat_item { + MEMCG_SWAP = 37, + MEMCG_SOCK = 38, + MEMCG_PERCPU_B = 39, + MEMCG_NR_STAT = 40, +}; + +enum memcg_memory_event { + MEMCG_LOW = 0, + MEMCG_HIGH = 1, + MEMCG_MAX = 2, + MEMCG_OOM = 3, + MEMCG_OOM_KILL = 4, + MEMCG_SWAP_HIGH = 5, + MEMCG_SWAP_MAX = 6, + MEMCG_SWAP_FAIL = 7, + MEMCG_NR_MEMORY_EVENTS = 8, +}; + +enum mem_cgroup_events_target { + MEM_CGROUP_TARGET_THRESH = 0, + MEM_CGROUP_TARGET_SOFTLIMIT = 1, + MEM_CGROUP_NTARGETS = 2, +}; + +struct memcg_vmstats_percpu { + long int stat[40]; + long unsigned int events[96]; + long unsigned int nr_page_events; + long unsigned int targets[2]; +}; + +struct mem_cgroup_reclaim_iter { + struct mem_cgroup *position; + unsigned int generation; +}; + +struct lruvec_stat { + long int count[37]; +}; + +struct memcg_shrinker_map { + struct callback_head rcu; + long unsigned int map[0]; +}; + +struct mem_cgroup_per_node { + struct lruvec lruvec; + struct lruvec_stat *lruvec_stat_local; + struct lruvec_stat *lruvec_stat_cpu; + atomic_long_t lruvec_stat[37]; + long unsigned int lru_zone_size[20]; + struct mem_cgroup_reclaim_iter iter; + struct memcg_shrinker_map *shrinker_map; + struct rb_node tree_node; + long unsigned int usage_in_excess; + bool on_tree; + struct mem_cgroup *memcg; +}; + +struct eventfd_ctx; + +struct mem_cgroup_threshold { + struct eventfd_ctx *eventfd; + long unsigned int threshold; +}; + +struct mem_cgroup_threshold_ary { + int current_threshold; + unsigned int size; + struct mem_cgroup_threshold entries[0]; +}; + +struct obj_cgroup { + struct percpu_ref refcnt; + struct mem_cgroup *memcg; + atomic_t nr_charged_bytes; + union { + struct list_head list; + struct callback_head rcu; + }; +}; + +struct percpu_cluster { + struct swap_cluster_info index; + unsigned int next; +}; + +enum fs_value_type { + fs_value_is_undefined = 0, + fs_value_is_flag = 1, + fs_value_is_string = 2, + fs_value_is_blob = 3, + fs_value_is_filename = 4, + fs_value_is_file = 5, +}; + +struct fs_parameter { + const char *key; + enum fs_value_type type: 8; + union { + char *string; + void *blob; + struct filename *name; + struct file *file; + }; + size_t size; + int dirfd; +}; + +struct fc_log { + refcount_t usage; + u8 head; + u8 tail; + u8 need_free; + struct module *owner; + char *buffer[8]; +}; + +struct fs_context_operations { + void (*free)(struct fs_context *); + int (*dup)(struct fs_context *, struct fs_context *); + int (*parse_param)(struct fs_context *, struct fs_parameter *); + int (*parse_monolithic)(struct fs_context *, void *); + int (*get_tree)(struct fs_context *); + int (*reconfigure)(struct fs_context *); +}; + +struct fs_parse_result { + bool negated; + union { + bool boolean; + int int_32; + unsigned int uint_32; + u64 uint_64; + }; +}; + +struct trace_event_raw_initcall_level { + struct trace_entry ent; + u32 __data_loc_level; + char __data[0]; +}; + +struct trace_event_raw_initcall_start { + struct trace_entry ent; + initcall_t func; + char __data[0]; +}; + +struct trace_event_raw_initcall_finish { + struct trace_entry ent; + initcall_t func; + int ret; + char __data[0]; +}; + +struct trace_event_data_offsets_initcall_level { + u32 level; +}; + +struct trace_event_data_offsets_initcall_start {}; + +struct trace_event_data_offsets_initcall_finish {}; + +typedef void (*btf_trace_initcall_level)(void *, const char *); + +typedef void (*btf_trace_initcall_start)(void *, initcall_t); + +typedef void (*btf_trace_initcall_finish)(void *, initcall_t, int); + +struct blacklist_entry { + struct list_head next; + char *buf; +}; + +typedef __u32 Elf32_Word; + +struct elf32_note { + Elf32_Word n_namesz; + Elf32_Word n_descsz; + Elf32_Word n_type; +}; + +enum { + PROC_ROOT_INO = 1, + PROC_IPC_INIT_INO = 4026531839, + PROC_UTS_INIT_INO = 4026531838, + PROC_USER_INIT_INO = 4026531837, + PROC_PID_INIT_INO = 4026531836, + PROC_CGROUP_INIT_INO = 4026531835, + PROC_TIME_INIT_INO = 4026531834, +}; + +typedef __u16 __le16; + +typedef __u16 __be16; + +typedef __u32 __be32; + +typedef __u64 __be64; + +typedef __u32 __wsum; + +typedef unsigned int slab_flags_t; + +struct llist_head { + struct llist_node *first; +}; + +struct notifier_block; + +typedef int (*notifier_fn_t)(struct notifier_block *, long unsigned int, void *); + +struct notifier_block { + notifier_fn_t notifier_call; + struct notifier_block *next; + int priority; +}; + +struct blocking_notifier_head { + struct rw_semaphore rwsem; + struct notifier_block *head; +}; + +struct raw_notifier_head { + struct notifier_block *head; +}; + +typedef __u64 __addrpair; + +typedef __u32 __portpair; + +typedef struct { + struct net *net; +} possible_net_t; + +struct in6_addr { + union { + __u8 u6_addr8[16]; + __be16 u6_addr16[8]; + __be32 u6_addr32[4]; + } in6_u; +}; + +struct hlist_nulls_node { + struct hlist_nulls_node *next; + struct hlist_nulls_node **pprev; +}; + +struct proto; + +struct inet_timewait_death_row; + +struct sock_common { + union { + __addrpair skc_addrpair; + struct { + __be32 skc_daddr; + __be32 skc_rcv_saddr; + }; + }; + union { + unsigned int skc_hash; + __u16 skc_u16hashes[2]; + }; + union { + __portpair skc_portpair; + struct { + __be16 skc_dport; + __u16 skc_num; + }; + }; + short unsigned int skc_family; + volatile unsigned char skc_state; + unsigned char skc_reuse: 4; + unsigned char skc_reuseport: 1; + unsigned char skc_ipv6only: 1; + unsigned char skc_net_refcnt: 1; + int skc_bound_dev_if; + union { + struct hlist_node skc_bind_node; + struct hlist_node skc_portaddr_node; + }; + struct proto *skc_prot; + possible_net_t skc_net; + struct in6_addr skc_v6_daddr; + struct in6_addr skc_v6_rcv_saddr; + atomic64_t skc_cookie; + union { + long unsigned int skc_flags; + struct sock *skc_listener; + struct inet_timewait_death_row *skc_tw_dr; + }; + int skc_dontcopy_begin[0]; + union { + struct hlist_node skc_node; + struct hlist_nulls_node skc_nulls_node; + }; + short unsigned int skc_tx_queue_mapping; + short unsigned int skc_rx_queue_mapping; + union { + int skc_incoming_cpu; + u32 skc_rcv_wnd; + u32 skc_tw_rcv_nxt; + }; + refcount_t skc_refcnt; + int skc_dontcopy_end[0]; + union { + u32 skc_rxhash; + u32 skc_window_clamp; + u32 skc_tw_snd_nxt; + }; +}; + +typedef struct { + spinlock_t slock; + int owned; + wait_queue_head_t wq; +} socket_lock_t; + +struct sk_buff; + +struct sk_buff_head { + struct sk_buff *next; + struct sk_buff *prev; + __u32 qlen; + spinlock_t lock; +}; + +typedef u64 netdev_features_t; + +struct sock_cgroup_data { + union { + struct { + u8 is_data: 1; + u8 no_refcnt: 1; + u8 unused: 6; + u8 padding; + u16 prioidx; + u32 classid; + }; + u64 val; + }; +}; + +struct sk_filter; + +struct socket_wq; + +struct xfrm_policy; + +struct dst_entry; + +struct socket; + +struct sock_reuseport; + +struct bpf_local_storage; + +struct sock { + struct sock_common __sk_common; + socket_lock_t sk_lock; + atomic_t sk_drops; + int sk_rcvlowat; + struct sk_buff_head sk_error_queue; + struct sk_buff *sk_rx_skb_cache; + struct sk_buff_head sk_receive_queue; + struct { + atomic_t rmem_alloc; + int len; + struct sk_buff *head; + struct sk_buff *tail; + } sk_backlog; + int sk_forward_alloc; + unsigned int sk_ll_usec; + unsigned int sk_napi_id; + int sk_rcvbuf; + struct sk_filter *sk_filter; + union { + struct socket_wq *sk_wq; + struct socket_wq *sk_wq_raw; + }; + struct xfrm_policy *sk_policy[2]; + struct dst_entry *sk_rx_dst; + struct dst_entry *sk_dst_cache; + atomic_t sk_omem_alloc; + int sk_sndbuf; + int sk_wmem_queued; + refcount_t sk_wmem_alloc; + long unsigned int sk_tsq_flags; + union { + struct sk_buff *sk_send_head; + struct rb_root tcp_rtx_queue; + }; + struct sk_buff *sk_tx_skb_cache; + struct sk_buff_head sk_write_queue; + __s32 sk_peek_off; + int sk_write_pending; + __u32 sk_dst_pending_confirm; + u32 sk_pacing_status; + long int sk_sndtimeo; + struct timer_list sk_timer; + __u32 sk_priority; + __u32 sk_mark; + long unsigned int sk_pacing_rate; + long unsigned int sk_max_pacing_rate; + struct page_frag sk_frag; + netdev_features_t sk_route_caps; + netdev_features_t sk_route_nocaps; + netdev_features_t sk_route_forced_caps; + int sk_gso_type; + unsigned int sk_gso_max_size; + gfp_t sk_allocation; + __u32 sk_txhash; + u8 sk_padding: 1; + u8 sk_kern_sock: 1; + u8 sk_no_check_tx: 1; + u8 sk_no_check_rx: 1; + u8 sk_userlocks: 4; + u8 sk_pacing_shift; + u16 sk_type; + u16 sk_protocol; + u16 sk_gso_max_segs; + long unsigned int sk_lingertime; + struct proto *sk_prot_creator; + rwlock_t sk_callback_lock; + int sk_err; + int sk_err_soft; + u32 sk_ack_backlog; + u32 sk_max_ack_backlog; + kuid_t sk_uid; + u8 sk_prefer_busy_poll; + u16 sk_busy_poll_budget; + struct pid *sk_peer_pid; + const struct cred *sk_peer_cred; + long int sk_rcvtimeo; + ktime_t sk_stamp; + u16 sk_tsflags; + u8 sk_shutdown; + u32 sk_tskey; + atomic_t sk_zckey; + u8 sk_clockid; + u8 sk_txtime_deadline_mode: 1; + u8 sk_txtime_report_errors: 1; + u8 sk_txtime_unused: 6; + struct socket *sk_socket; + void *sk_user_data; + void *sk_security; + struct sock_cgroup_data sk_cgrp_data; + struct mem_cgroup *sk_memcg; + void (*sk_state_change)(struct sock *); + void (*sk_data_ready)(struct sock *); + void (*sk_write_space)(struct sock *); + void (*sk_error_report)(struct sock *); + int (*sk_backlog_rcv)(struct sock *, struct sk_buff *); + void (*sk_destruct)(struct sock *); + struct sock_reuseport *sk_reuseport_cb; + struct bpf_local_storage *sk_bpf_storage; + struct callback_head sk_rcu; +}; + +struct rhash_head { + struct rhash_head *next; +}; + +struct rhashtable; + +struct rhashtable_compare_arg { + struct rhashtable *ht; + const void *key; +}; + +typedef u32 (*rht_hashfn_t)(const void *, u32, u32); + +typedef u32 (*rht_obj_hashfn_t)(const void *, u32, u32); + +typedef int (*rht_obj_cmpfn_t)(struct rhashtable_compare_arg *, const void *); + +struct rhashtable_params { + u16 nelem_hint; + u16 key_len; + u16 key_offset; + u16 head_offset; + unsigned int max_size; + u16 min_size; + bool automatic_shrinking; + rht_hashfn_t hashfn; + rht_obj_hashfn_t obj_hashfn; + rht_obj_cmpfn_t obj_cmpfn; +}; + +struct bucket_table; + +struct rhashtable { + struct bucket_table *tbl; + unsigned int key_len; + unsigned int max_elems; + struct rhashtable_params p; + bool rhlist; + struct work_struct run_work; + struct mutex mutex; + spinlock_t lock; + atomic_t nelems; +}; + +struct fs_struct { + int users; + spinlock_t lock; + seqcount_spinlock_t seq; + int umask; + int in_exec; + struct path root; + struct path pwd; +}; + +struct pipe_buffer; + +struct pipe_inode_info { + struct mutex mutex; + wait_queue_head_t rd_wait; + wait_queue_head_t wr_wait; + unsigned int head; + unsigned int tail; + unsigned int max_usage; + unsigned int ring_size; + unsigned int nr_accounted; + unsigned int readers; + unsigned int writers; + unsigned int files; + unsigned int r_counter; + unsigned int w_counter; + struct page *tmp_page; + struct fasync_struct *fasync_readers; + struct fasync_struct *fasync_writers; + struct pipe_buffer *bufs; + struct user_struct *user; +}; + +typedef short unsigned int __kernel_sa_family_t; + +typedef __kernel_sa_family_t sa_family_t; + +struct sockaddr { + sa_family_t sa_family; + char sa_data[14]; +}; + +struct msghdr { + void *msg_name; + int msg_namelen; + struct iov_iter msg_iter; + union { + void *msg_control; + void *msg_control_user; + }; + bool msg_control_is_user: 1; + __kernel_size_t msg_controllen; + unsigned int msg_flags; + struct kiocb *msg_iocb; +}; + +typedef struct { + unsigned int clock_rate; + unsigned int clock_type; + short unsigned int loopback; +} sync_serial_settings; + +typedef struct { + unsigned int clock_rate; + unsigned int clock_type; + short unsigned int loopback; + unsigned int slot_map; +} te1_settings; + +typedef struct { + short unsigned int encoding; + short unsigned int parity; +} raw_hdlc_proto; + +typedef struct { + unsigned int t391; + unsigned int t392; + unsigned int n391; + unsigned int n392; + unsigned int n393; + short unsigned int lmi; + short unsigned int dce; +} fr_proto; + +typedef struct { + unsigned int dlci; +} fr_proto_pvc; + +typedef struct { + unsigned int dlci; + char master[16]; +} fr_proto_pvc_info; + +typedef struct { + unsigned int interval; + unsigned int timeout; +} cisco_proto; + +typedef struct { + short unsigned int dce; + unsigned int modulo; + unsigned int window; + unsigned int t1; + unsigned int t2; + unsigned int n2; +} x25_hdlc_proto; + +struct ifmap { + long unsigned int mem_start; + long unsigned int mem_end; + short unsigned int base_addr; + unsigned char irq; + unsigned char dma; + unsigned char port; +}; + +struct if_settings { + unsigned int type; + unsigned int size; + union { + raw_hdlc_proto *raw_hdlc; + cisco_proto *cisco; + fr_proto *fr; + fr_proto_pvc *fr_pvc; + fr_proto_pvc_info *fr_pvc_info; + x25_hdlc_proto *x25; + sync_serial_settings *sync; + te1_settings *te1; + } ifs_ifsu; +}; + +struct ifreq { + union { + char ifrn_name[16]; + } ifr_ifrn; + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_dstaddr; + struct sockaddr ifru_broadaddr; + struct sockaddr ifru_netmask; + struct sockaddr ifru_hwaddr; + short int ifru_flags; + int ifru_ivalue; + int ifru_mtu; + struct ifmap ifru_map; + char ifru_slave[16]; + char ifru_newname[16]; + void *ifru_data; + struct if_settings ifru_settings; + } ifr_ifru; +}; + +struct vfsmount { + struct dentry *mnt_root; + struct super_block *mnt_sb; + int mnt_flags; +}; + +struct ld_semaphore { + atomic_long_t count; + raw_spinlock_t wait_lock; + unsigned int wait_readers; + struct list_head read_wait; + struct list_head write_wait; +}; + +typedef unsigned int tcflag_t; + +typedef unsigned char cc_t; + +typedef unsigned int speed_t; + +struct ktermios { + tcflag_t c_iflag; + tcflag_t c_oflag; + tcflag_t c_cflag; + tcflag_t c_lflag; + cc_t c_line; + cc_t c_cc[19]; + speed_t c_ispeed; + speed_t c_ospeed; +}; + +struct winsize { + short unsigned int ws_row; + short unsigned int ws_col; + short unsigned int ws_xpixel; + short unsigned int ws_ypixel; +}; + +struct tty_driver; + +struct tty_operations; + +struct tty_ldisc; + +struct termiox; + +struct tty_port; + +struct tty_struct { + int magic; + struct kref kref; + struct device *dev; + struct tty_driver *driver; + const struct tty_operations *ops; + int index; + struct ld_semaphore ldisc_sem; + struct tty_ldisc *ldisc; + struct mutex atomic_write_lock; + struct mutex legacy_mutex; + struct mutex throttle_mutex; + struct rw_semaphore termios_rwsem; + struct mutex winsize_mutex; + spinlock_t ctrl_lock; + spinlock_t flow_lock; + struct ktermios termios; + struct ktermios termios_locked; + struct termiox *termiox; + char name[64]; + struct pid *pgrp; + struct pid *session; + long unsigned int flags; + int count; + struct winsize winsize; + long unsigned int stopped: 1; + long unsigned int flow_stopped: 1; + int: 30; + long unsigned int unused: 62; + int hw_stopped; + long unsigned int ctrl_status: 8; + long unsigned int packet: 1; + int: 23; + long unsigned int unused_ctrl: 55; + unsigned int receive_room; + int flow_change; + struct tty_struct *link; + struct fasync_struct *fasync; + wait_queue_head_t write_wait; + wait_queue_head_t read_wait; + struct work_struct hangup_work; + void *disc_data; + void *driver_data; + spinlock_t files_lock; + struct list_head tty_files; + int closing; + unsigned char *write_buf; + int write_cnt; + struct work_struct SAK_work; + struct tty_port *port; +}; + +typedef struct { + size_t written; + size_t count; + union { + char *buf; + void *data; + } arg; + int error; +} read_descriptor_t; + +struct posix_acl_entry { + short int e_tag; + short unsigned int e_perm; + union { + kuid_t e_uid; + kgid_t e_gid; + }; +}; + +struct posix_acl { + refcount_t a_refcount; + struct callback_head a_rcu; + unsigned int a_count; + struct posix_acl_entry a_entries[0]; +}; + +struct termiox { + __u16 x_hflag; + __u16 x_cflag; + __u16 x_rflag[5]; + __u16 x_sflag; +}; + +struct serial_icounter_struct; + +struct serial_struct; + +struct tty_operations { + struct tty_struct * (*lookup)(struct tty_driver *, struct file *, int); + int (*install)(struct tty_driver *, struct tty_struct *); + void (*remove)(struct tty_driver *, struct tty_struct *); + int (*open)(struct tty_struct *, struct file *); + void (*close)(struct tty_struct *, struct file *); + void (*shutdown)(struct tty_struct *); + void (*cleanup)(struct tty_struct *); + int (*write)(struct tty_struct *, const unsigned char *, int); + int (*put_char)(struct tty_struct *, unsigned char); + void (*flush_chars)(struct tty_struct *); + int (*write_room)(struct tty_struct *); + int (*chars_in_buffer)(struct tty_struct *); + int (*ioctl)(struct tty_struct *, unsigned int, long unsigned int); + long int (*compat_ioctl)(struct tty_struct *, unsigned int, long unsigned int); + void (*set_termios)(struct tty_struct *, struct ktermios *); + void (*throttle)(struct tty_struct *); + void (*unthrottle)(struct tty_struct *); + void (*stop)(struct tty_struct *); + void (*start)(struct tty_struct *); + void (*hangup)(struct tty_struct *); + int (*break_ctl)(struct tty_struct *, int); + void (*flush_buffer)(struct tty_struct *); + void (*set_ldisc)(struct tty_struct *); + void (*wait_until_sent)(struct tty_struct *, int); + void (*send_xchar)(struct tty_struct *, char); + int (*tiocmget)(struct tty_struct *); + int (*tiocmset)(struct tty_struct *, unsigned int, unsigned int); + int (*resize)(struct tty_struct *, struct winsize *); + int (*set_termiox)(struct tty_struct *, struct termiox *); + int (*get_icount)(struct tty_struct *, struct serial_icounter_struct *); + int (*get_serial)(struct tty_struct *, struct serial_struct *); + int (*set_serial)(struct tty_struct *, struct serial_struct *); + void (*show_fdinfo)(struct tty_struct *, struct seq_file *); + int (*proc_show)(struct seq_file *, void *); +}; + +struct proc_dir_entry; + +struct tty_driver { + int magic; + struct kref kref; + struct cdev **cdevs; + struct module *owner; + const char *driver_name; + const char *name; + int name_base; + int major; + int minor_start; + unsigned int num; + short int type; + short int subtype; + struct ktermios init_termios; + long unsigned int flags; + struct proc_dir_entry *proc_entry; + struct tty_driver *other; + struct tty_struct **ttys; + struct tty_port **ports; + struct ktermios **termios; + void *driver_state; + const struct tty_operations *ops; + struct list_head tty_drivers; +}; + +struct tty_buffer { + union { + struct tty_buffer *next; + struct llist_node free; + }; + int used; + int size; + int commit; + int read; + int flags; + long unsigned int data[0]; +}; + +struct tty_bufhead { + struct tty_buffer *head; + struct work_struct work; + struct mutex lock; + atomic_t priority; + struct tty_buffer sentinel; + struct llist_head free; + atomic_t mem_used; + int mem_limit; + struct tty_buffer *tail; +}; + +struct tty_port_operations; + +struct tty_port_client_operations; + +struct tty_port { + struct tty_bufhead buf; + struct tty_struct *tty; + struct tty_struct *itty; + const struct tty_port_operations *ops; + const struct tty_port_client_operations *client_ops; + spinlock_t lock; + int blocked_open; + int count; + wait_queue_head_t open_wait; + wait_queue_head_t delta_msr_wait; + long unsigned int flags; + long unsigned int iflags; + unsigned char console: 1; + unsigned char low_latency: 1; + struct mutex mutex; + struct mutex buf_mutex; + unsigned char *xmit_buf; + unsigned int close_delay; + unsigned int closing_wait; + int drain_delay; + struct kref kref; + void *client_data; +}; + +struct tty_ldisc_ops { + int magic; + char *name; + int num; + int flags; + int (*open)(struct tty_struct *); + void (*close)(struct tty_struct *); + void (*flush_buffer)(struct tty_struct *); + ssize_t (*read)(struct tty_struct *, struct file *, unsigned char *, size_t); + ssize_t (*write)(struct tty_struct *, struct file *, const unsigned char *, size_t); + int (*ioctl)(struct tty_struct *, struct file *, unsigned int, long unsigned int); + int (*compat_ioctl)(struct tty_struct *, struct file *, unsigned int, long unsigned int); + void (*set_termios)(struct tty_struct *, struct ktermios *); + __poll_t (*poll)(struct tty_struct *, struct file *, struct poll_table_struct *); + int (*hangup)(struct tty_struct *); + void (*receive_buf)(struct tty_struct *, const unsigned char *, char *, int); + void (*write_wakeup)(struct tty_struct *); + void (*dcd_change)(struct tty_struct *, unsigned int); + int (*receive_buf2)(struct tty_struct *, const unsigned char *, char *, int); + struct module *owner; + int refcount; +}; + +struct tty_ldisc { + struct tty_ldisc_ops *ops; + struct tty_struct *tty; +}; + +struct tty_port_operations { + int (*carrier_raised)(struct tty_port *); + void (*dtr_rts)(struct tty_port *, int); + void (*shutdown)(struct tty_port *); + int (*activate)(struct tty_port *, struct tty_struct *); + void (*destruct)(struct tty_port *); +}; + +struct tty_port_client_operations { + int (*receive_buf)(struct tty_port *, const unsigned char *, const unsigned char *, size_t); + void (*write_wakeup)(struct tty_port *); +}; + +struct prot_inuse; + +struct netns_core { + struct ctl_table_header *sysctl_hdr; + int sysctl_somaxconn; + int *sock_inuse; + struct prot_inuse *prot_inuse; +}; + +struct tcp_mib; + +struct ipstats_mib; + +struct linux_mib; + +struct udp_mib; + +struct icmp_mib; + +struct icmpmsg_mib; + +struct icmpv6_mib; + +struct icmpv6msg_mib; + +struct linux_tls_mib; + +struct netns_mib { + struct tcp_mib *tcp_statistics; + struct ipstats_mib *ip_statistics; + struct linux_mib *net_statistics; + struct udp_mib *udp_statistics; + struct udp_mib *udplite_statistics; + struct icmp_mib *icmp_statistics; + struct icmpmsg_mib *icmpmsg_statistics; + struct proc_dir_entry *proc_net_devsnmp6; + struct udp_mib *udp_stats_in6; + struct udp_mib *udplite_stats_in6; + struct ipstats_mib *ipv6_statistics; + struct icmpv6_mib *icmpv6_statistics; + struct icmpv6msg_mib *icmpv6msg_statistics; + struct linux_tls_mib *tls_statistics; +}; + +struct netns_packet { + struct mutex sklist_lock; + struct hlist_head sklist; +}; + +struct netns_unix { + int sysctl_max_dgram_qlen; + struct ctl_table_header *ctl; +}; + +struct netns_nexthop { + struct rb_root rb_root; + struct hlist_head *devhash; + unsigned int seq; + u32 last_id_allocated; + struct blocking_notifier_head notifier_chain; +}; + +struct local_ports { + seqlock_t lock; + int range[2]; + bool warned; +}; + +struct inet_hashinfo; + +struct inet_timewait_death_row { + atomic_t tw_count; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct inet_hashinfo *hashinfo; + int sysctl_max_tw_buckets; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct ping_group_range { + seqlock_t lock; + kgid_t range[2]; +}; + +typedef struct { + u64 key[2]; +} siphash_key_t; + +struct ipv4_devconf; + +struct ip_ra_chain; + +struct fib_rules_ops; + +struct fib_table; + +struct inet_peer_base; + +struct fqdir; + +struct xt_table; + +struct tcp_congestion_ops; + +struct tcp_fastopen_context; + +struct mr_table; + +struct fib_notifier_ops; + +struct netns_ipv4 { + struct ctl_table_header *forw_hdr; + struct ctl_table_header *frags_hdr; + struct ctl_table_header *ipv4_hdr; + struct ctl_table_header *route_hdr; + struct ctl_table_header *xfrm4_hdr; + struct ipv4_devconf *devconf_all; + struct ipv4_devconf *devconf_dflt; + struct ip_ra_chain *ra_chain; + struct mutex ra_mutex; + struct fib_rules_ops *rules_ops; + bool fib_has_custom_rules; + unsigned int fib_rules_require_fldissect; + struct fib_table *fib_main; + struct fib_table *fib_default; + bool fib_has_custom_local_routes; + int fib_num_tclassid_users; + struct hlist_head *fib_table_hash; + bool fib_offload_disabled; + struct sock *fibnl; + struct sock **icmp_sk; + struct sock *mc_autojoin_sk; + struct inet_peer_base *peers; + struct sock **tcp_sk; + struct fqdir *fqdir; + struct xt_table *iptable_filter; + struct xt_table *iptable_mangle; + struct xt_table *iptable_raw; + struct xt_table *arptable_filter; + struct xt_table *iptable_security; + struct xt_table *nat_table; + int sysctl_icmp_echo_ignore_all; + int sysctl_icmp_echo_ignore_broadcasts; + int sysctl_icmp_ignore_bogus_error_responses; + int sysctl_icmp_ratelimit; + int sysctl_icmp_ratemask; + int sysctl_icmp_errors_use_inbound_ifaddr; + struct local_ports ip_local_ports; + int sysctl_tcp_ecn; + int sysctl_tcp_ecn_fallback; + int sysctl_ip_default_ttl; + int sysctl_ip_no_pmtu_disc; + int sysctl_ip_fwd_use_pmtu; + int sysctl_ip_fwd_update_priority; + int sysctl_ip_nonlocal_bind; + int sysctl_ip_autobind_reuse; + int sysctl_ip_dynaddr; + int sysctl_ip_early_demux; + int sysctl_tcp_early_demux; + int sysctl_udp_early_demux; + int sysctl_nexthop_compat_mode; + int sysctl_fwmark_reflect; + int sysctl_tcp_fwmark_accept; + int sysctl_tcp_mtu_probing; + int sysctl_tcp_mtu_probe_floor; + int sysctl_tcp_base_mss; + int sysctl_tcp_min_snd_mss; + int sysctl_tcp_probe_threshold; + u32 sysctl_tcp_probe_interval; + int sysctl_tcp_keepalive_time; + int sysctl_tcp_keepalive_probes; + int sysctl_tcp_keepalive_intvl; + int sysctl_tcp_syn_retries; + int sysctl_tcp_synack_retries; + int sysctl_tcp_syncookies; + int sysctl_tcp_reordering; + int sysctl_tcp_retries1; + int sysctl_tcp_retries2; + int sysctl_tcp_orphan_retries; + int sysctl_tcp_fin_timeout; + unsigned int sysctl_tcp_notsent_lowat; + int sysctl_tcp_tw_reuse; + int sysctl_tcp_sack; + int sysctl_tcp_window_scaling; + int sysctl_tcp_timestamps; + int sysctl_tcp_early_retrans; + int sysctl_tcp_recovery; + int sysctl_tcp_thin_linear_timeouts; + int sysctl_tcp_slow_start_after_idle; + int sysctl_tcp_retrans_collapse; + int sysctl_tcp_stdurg; + int sysctl_tcp_rfc1337; + int sysctl_tcp_abort_on_overflow; + int sysctl_tcp_fack; + int sysctl_tcp_max_reordering; + int sysctl_tcp_dsack; + int sysctl_tcp_app_win; + int sysctl_tcp_adv_win_scale; + int sysctl_tcp_frto; + int sysctl_tcp_nometrics_save; + int sysctl_tcp_no_ssthresh_metrics_save; + int sysctl_tcp_moderate_rcvbuf; + int sysctl_tcp_tso_win_divisor; + int sysctl_tcp_workaround_signed_windows; + int sysctl_tcp_limit_output_bytes; + int sysctl_tcp_challenge_ack_limit; + int sysctl_tcp_min_tso_segs; + int sysctl_tcp_min_rtt_wlen; + int sysctl_tcp_autocorking; + int sysctl_tcp_invalid_ratelimit; + int sysctl_tcp_pacing_ss_ratio; + int sysctl_tcp_pacing_ca_ratio; + int sysctl_tcp_wmem[3]; + int sysctl_tcp_rmem[3]; + int sysctl_tcp_comp_sack_nr; + long unsigned int sysctl_tcp_comp_sack_delay_ns; + long unsigned int sysctl_tcp_comp_sack_slack_ns; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct inet_timewait_death_row tcp_death_row; + int sysctl_max_syn_backlog; + int sysctl_tcp_fastopen; + const struct tcp_congestion_ops *tcp_congestion_control; + struct tcp_fastopen_context *tcp_fastopen_ctx; + spinlock_t tcp_fastopen_ctx_lock; + unsigned int sysctl_tcp_fastopen_blackhole_timeout; + atomic_t tfo_active_disable_times; + long unsigned int tfo_active_disable_stamp; + int sysctl_tcp_reflect_tos; + int sysctl_udp_wmem_min; + int sysctl_udp_rmem_min; + int sysctl_igmp_max_memberships; + int sysctl_igmp_max_msf; + int sysctl_igmp_llm_reports; + int sysctl_igmp_qrv; + struct ping_group_range ping_group_range; + atomic_t dev_addr_genid; + long unsigned int *sysctl_local_reserved_ports; + int sysctl_ip_prot_sock; + struct mr_table *mrt; + int sysctl_fib_multipath_use_neigh; + int sysctl_fib_multipath_hash_policy; + struct fib_notifier_ops *notifier_ops; + unsigned int fib_seq; + struct fib_notifier_ops *ipmr_notifier_ops; + unsigned int ipmr_seq; + atomic_t rt_genid; + siphash_key_t ip_id_key; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct netns_sysctl_ipv6 { + struct ctl_table_header *hdr; + struct ctl_table_header *route_hdr; + struct ctl_table_header *icmp_hdr; + struct ctl_table_header *frags_hdr; + struct ctl_table_header *xfrm6_hdr; + int bindv6only; + int flush_delay; + int ip6_rt_max_size; + int ip6_rt_gc_min_interval; + int ip6_rt_gc_timeout; + int ip6_rt_gc_interval; + int ip6_rt_gc_elasticity; + int ip6_rt_mtu_expires; + int ip6_rt_min_advmss; + int multipath_hash_policy; + int flowlabel_consistency; + int auto_flowlabels; + int icmpv6_time; + int icmpv6_echo_ignore_all; + int icmpv6_echo_ignore_multicast; + int icmpv6_echo_ignore_anycast; + long unsigned int icmpv6_ratemask[4]; + long unsigned int *icmpv6_ratemask_ptr; + int anycast_src_echo_reply; + int ip_nonlocal_bind; + int fwmark_reflect; + int idgen_retries; + int idgen_delay; + int flowlabel_state_ranges; + int flowlabel_reflect; + int max_dst_opts_cnt; + int max_hbh_opts_cnt; + int max_dst_opts_len; + int max_hbh_opts_len; + int seg6_flowlabel; + bool skip_notify_on_dev_down; +}; + +struct net_device; + +struct neighbour; + +struct dst_ops { + short unsigned int family; + unsigned int gc_thresh; + int (*gc)(struct dst_ops *); + struct dst_entry * (*check)(struct dst_entry *, __u32); + unsigned int (*default_advmss)(const struct dst_entry *); + unsigned int (*mtu)(const struct dst_entry *); + u32 * (*cow_metrics)(struct dst_entry *, long unsigned int); + void (*destroy)(struct dst_entry *); + void (*ifdown)(struct dst_entry *, struct net_device *, int); + struct dst_entry * (*negative_advice)(struct dst_entry *); + void (*link_failure)(struct sk_buff *); + void (*update_pmtu)(struct dst_entry *, struct sock *, struct sk_buff *, u32, bool); + void (*redirect)(struct dst_entry *, struct sock *, struct sk_buff *); + int (*local_out)(struct net *, struct sock *, struct sk_buff *); + struct neighbour * (*neigh_lookup)(const struct dst_entry *, struct sk_buff *, const void *); + void (*confirm_neigh)(const struct dst_entry *, const void *); + struct kmem_cache *kmem_cachep; + struct percpu_counter pcpuc_entries; + long: 64; +}; + +struct ipv6_devconf; + +struct fib6_info; + +struct rt6_info; + +struct rt6_statistics; + +struct fib6_table; + +struct seg6_pernet_data; + +struct netns_ipv6 { + struct netns_sysctl_ipv6 sysctl; + struct ipv6_devconf *devconf_all; + struct ipv6_devconf *devconf_dflt; + struct inet_peer_base *peers; + struct fqdir *fqdir; + struct xt_table *ip6table_filter; + struct xt_table *ip6table_mangle; + struct xt_table *ip6table_raw; + struct xt_table *ip6table_security; + struct xt_table *ip6table_nat; + struct fib6_info *fib6_null_entry; + struct rt6_info *ip6_null_entry; + struct rt6_statistics *rt6_stats; + struct timer_list ip6_fib_timer; + struct hlist_head *fib_table_hash; + struct fib6_table *fib6_main_tbl; + struct list_head fib6_walkers; + long: 64; + long: 64; + struct dst_ops ip6_dst_ops; + rwlock_t fib6_walker_lock; + spinlock_t fib6_gc_lock; + unsigned int ip6_rt_gc_expire; + long unsigned int ip6_rt_last_gc; + unsigned int fib6_rules_require_fldissect; + bool fib6_has_custom_rules; + unsigned int fib6_routes_require_src; + struct rt6_info *ip6_prohibit_entry; + struct rt6_info *ip6_blk_hole_entry; + struct fib6_table *fib6_local_tbl; + struct fib_rules_ops *fib6_rules_ops; + struct sock **icmp_sk; + struct sock *ndisc_sk; + struct sock *tcp_sk; + struct sock *igmp_sk; + struct sock *mc_autojoin_sk; + atomic_t dev_addr_genid; + atomic_t fib6_sernum; + struct seg6_pernet_data *seg6_data; + struct fib_notifier_ops *notifier_ops; + struct fib_notifier_ops *ip6mr_notifier_ops; + unsigned int ipmr_seq; + struct { + struct hlist_head head; + spinlock_t lock; + u32 seq; + } ip6addrlbl_table; + long: 64; + long: 64; + long: 64; +}; + +struct sctp_mib; + +struct netns_sctp { + struct sctp_mib *sctp_statistics; + struct proc_dir_entry *proc_net_sctp; + struct ctl_table_header *sysctl_header; + struct sock *ctl_sock; + struct sock *udp4_sock; + struct sock *udp6_sock; + int udp_port; + int encap_port; + struct list_head local_addr_list; + struct list_head addr_waitq; + struct timer_list addr_wq_timer; + struct list_head auto_asconf_splist; + spinlock_t addr_wq_lock; + spinlock_t local_addr_lock; + unsigned int rto_initial; + unsigned int rto_min; + unsigned int rto_max; + int rto_alpha; + int rto_beta; + int max_burst; + int cookie_preserve_enable; + char *sctp_hmac_alg; + unsigned int valid_cookie_life; + unsigned int sack_timeout; + unsigned int hb_interval; + int max_retrans_association; + int max_retrans_path; + int max_retrans_init; + int pf_retrans; + int ps_retrans; + int pf_enable; + int pf_expose; + int sndbuf_policy; + int rcvbuf_policy; + int default_auto_asconf; + int addip_enable; + int addip_noauth; + int prsctp_enable; + int reconf_enable; + int auth_enable; + int intl_enable; + int ecn_enable; + int scope_policy; + int rwnd_upd_shift; + long unsigned int max_autoclose; +}; + +struct netns_dccp { + struct sock *v4_ctl_sk; + struct sock *v6_ctl_sk; +}; + +struct nf_queue_handler; + +struct nf_logger; + +struct nf_hook_entries; + +struct netns_nf { + struct proc_dir_entry *proc_netfilter; + const struct nf_queue_handler *queue_handler; + const struct nf_logger *nf_loggers[13]; + struct ctl_table_header *nf_log_dir_header; + struct nf_hook_entries *hooks_ipv4[5]; + struct nf_hook_entries *hooks_ipv6[5]; + struct nf_hook_entries *hooks_arp[3]; + struct nf_hook_entries *hooks_bridge[5]; + struct nf_hook_entries *hooks_decnet[7]; + bool defrag_ipv6; +}; + +struct ebt_table; + +struct netns_xt { + struct list_head tables[13]; + bool notrack_deprecated_warning; + bool clusterip_deprecated_warning; + struct ebt_table *broute_table; + struct ebt_table *frame_filter; + struct ebt_table *frame_nat; +}; + +struct netns_nf_frag { + struct fqdir *fqdir; +}; + +struct netns_bpf { + struct bpf_prog_array *run_array[2]; + struct bpf_prog *progs[2]; + struct list_head links[2]; +}; + +struct xfrm_policy_hash { + struct hlist_head *table; + unsigned int hmask; + u8 dbits4; + u8 sbits4; + u8 dbits6; + u8 sbits6; +}; + +struct xfrm_policy_hthresh { + struct work_struct work; + seqlock_t lock; + u8 lbits4; + u8 rbits4; + u8 lbits6; + u8 rbits6; +}; + +struct netns_xfrm { + struct list_head state_all; + struct hlist_head *state_bydst; + struct hlist_head *state_bysrc; + struct hlist_head *state_byspi; + unsigned int state_hmask; + unsigned int state_num; + struct work_struct state_hash_work; + struct list_head policy_all; + struct hlist_head *policy_byidx; + unsigned int policy_idx_hmask; + struct hlist_head policy_inexact[3]; + struct xfrm_policy_hash policy_bydst[3]; + unsigned int policy_count[6]; + struct work_struct policy_hash_work; + struct xfrm_policy_hthresh policy_hthresh; + struct list_head inexact_bins; + struct sock *nlsk; + struct sock *nlsk_stash; + u32 sysctl_aevent_etime; + u32 sysctl_aevent_rseqth; + int sysctl_larval_drop; + u32 sysctl_acq_expires; + struct ctl_table_header *sysctl_hdr; + long: 64; + long: 64; + struct dst_ops xfrm4_dst_ops; + struct dst_ops xfrm6_dst_ops; + spinlock_t xfrm_state_lock; + spinlock_t xfrm_policy_lock; + struct mutex xfrm_cfg_mutex; + long: 64; + long: 64; +}; + +struct netns_ipvs; + +struct mpls_route; + +struct netns_mpls { + int ip_ttl_propagate; + int default_ttl; + size_t platform_labels; + struct mpls_route **platform_label; + struct ctl_table_header *ctl; +}; + +struct netns_xdp { + struct mutex lock; + struct hlist_head list; +}; + +struct uevent_sock; + +struct net_generic; + +struct net { + refcount_t passive; + refcount_t count; + spinlock_t rules_mod_lock; + unsigned int dev_unreg_count; + unsigned int dev_base_seq; + int ifindex; + spinlock_t nsid_lock; + atomic_t fnhe_genid; + struct list_head list; + struct list_head exit_list; + struct llist_node cleanup_list; + struct key_tag *key_domain; + struct user_namespace *user_ns; + struct ucounts *ucounts; + struct idr netns_ids; + struct ns_common ns; + struct list_head dev_base_head; + struct proc_dir_entry *proc_net; + struct proc_dir_entry *proc_net_stat; + struct ctl_table_set sysctls; + struct sock *rtnl; + struct sock *genl_sock; + struct uevent_sock *uevent_sock; + struct hlist_head *dev_name_head; + struct hlist_head *dev_index_head; + struct raw_notifier_head netdev_chain; + u32 hash_mix; + struct net_device *loopback_dev; + struct list_head rules_ops; + struct netns_core core; + struct netns_mib mib; + struct netns_packet packet; + struct netns_unix unx; + struct netns_nexthop nexthop; + long: 64; + long: 64; + struct netns_ipv4 ipv4; + struct netns_ipv6 ipv6; + struct netns_sctp sctp; + struct netns_dccp dccp; + struct netns_nf nf; + struct netns_xt xt; + struct netns_nf_frag nf_frag; + struct ctl_table_header *nf_frag_frags_hdr; + struct sock *nfnl; + struct sock *nfnl_stash; + struct net_generic *gen; + struct netns_bpf bpf; + struct netns_xfrm xfrm; + atomic64_t net_cookie; + struct netns_ipvs *ipvs; + struct netns_mpls mpls; + struct netns_xdp xdp; + struct sock *diag_nlsk; +}; + +typedef struct { + local64_t v; +} u64_stats_t; + +struct bpf_insn { + __u8 code; + __u8 dst_reg: 4; + __u8 src_reg: 4; + __s16 off; + __s32 imm; +}; + +enum bpf_map_type { + BPF_MAP_TYPE_UNSPEC = 0, + BPF_MAP_TYPE_HASH = 1, + BPF_MAP_TYPE_ARRAY = 2, + BPF_MAP_TYPE_PROG_ARRAY = 3, + BPF_MAP_TYPE_PERF_EVENT_ARRAY = 4, + BPF_MAP_TYPE_PERCPU_HASH = 5, + BPF_MAP_TYPE_PERCPU_ARRAY = 6, + BPF_MAP_TYPE_STACK_TRACE = 7, + BPF_MAP_TYPE_CGROUP_ARRAY = 8, + BPF_MAP_TYPE_LRU_HASH = 9, + BPF_MAP_TYPE_LRU_PERCPU_HASH = 10, + BPF_MAP_TYPE_LPM_TRIE = 11, + BPF_MAP_TYPE_ARRAY_OF_MAPS = 12, + BPF_MAP_TYPE_HASH_OF_MAPS = 13, + BPF_MAP_TYPE_DEVMAP = 14, + BPF_MAP_TYPE_SOCKMAP = 15, + BPF_MAP_TYPE_CPUMAP = 16, + BPF_MAP_TYPE_XSKMAP = 17, + BPF_MAP_TYPE_SOCKHASH = 18, + BPF_MAP_TYPE_CGROUP_STORAGE = 19, + BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 20, + BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 21, + BPF_MAP_TYPE_QUEUE = 22, + BPF_MAP_TYPE_STACK = 23, + BPF_MAP_TYPE_SK_STORAGE = 24, + BPF_MAP_TYPE_DEVMAP_HASH = 25, + BPF_MAP_TYPE_STRUCT_OPS = 26, + BPF_MAP_TYPE_RINGBUF = 27, + BPF_MAP_TYPE_INODE_STORAGE = 28, + BPF_MAP_TYPE_TASK_STORAGE = 29, +}; + +enum bpf_prog_type { + BPF_PROG_TYPE_UNSPEC = 0, + BPF_PROG_TYPE_SOCKET_FILTER = 1, + BPF_PROG_TYPE_KPROBE = 2, + BPF_PROG_TYPE_SCHED_CLS = 3, + BPF_PROG_TYPE_SCHED_ACT = 4, + BPF_PROG_TYPE_TRACEPOINT = 5, + BPF_PROG_TYPE_XDP = 6, + BPF_PROG_TYPE_PERF_EVENT = 7, + BPF_PROG_TYPE_CGROUP_SKB = 8, + BPF_PROG_TYPE_CGROUP_SOCK = 9, + BPF_PROG_TYPE_LWT_IN = 10, + BPF_PROG_TYPE_LWT_OUT = 11, + BPF_PROG_TYPE_LWT_XMIT = 12, + BPF_PROG_TYPE_SOCK_OPS = 13, + BPF_PROG_TYPE_SK_SKB = 14, + BPF_PROG_TYPE_CGROUP_DEVICE = 15, + BPF_PROG_TYPE_SK_MSG = 16, + BPF_PROG_TYPE_RAW_TRACEPOINT = 17, + BPF_PROG_TYPE_CGROUP_SOCK_ADDR = 18, + BPF_PROG_TYPE_LWT_SEG6LOCAL = 19, + BPF_PROG_TYPE_LIRC_MODE2 = 20, + BPF_PROG_TYPE_SK_REUSEPORT = 21, + BPF_PROG_TYPE_FLOW_DISSECTOR = 22, + BPF_PROG_TYPE_CGROUP_SYSCTL = 23, + BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE = 24, + BPF_PROG_TYPE_CGROUP_SOCKOPT = 25, + BPF_PROG_TYPE_TRACING = 26, + BPF_PROG_TYPE_STRUCT_OPS = 27, + BPF_PROG_TYPE_EXT = 28, + BPF_PROG_TYPE_LSM = 29, + BPF_PROG_TYPE_SK_LOOKUP = 30, +}; + +enum bpf_attach_type { + BPF_CGROUP_INET_INGRESS = 0, + BPF_CGROUP_INET_EGRESS = 1, + BPF_CGROUP_INET_SOCK_CREATE = 2, + BPF_CGROUP_SOCK_OPS = 3, + BPF_SK_SKB_STREAM_PARSER = 4, + BPF_SK_SKB_STREAM_VERDICT = 5, + BPF_CGROUP_DEVICE = 6, + BPF_SK_MSG_VERDICT = 7, + BPF_CGROUP_INET4_BIND = 8, + BPF_CGROUP_INET6_BIND = 9, + BPF_CGROUP_INET4_CONNECT = 10, + BPF_CGROUP_INET6_CONNECT = 11, + BPF_CGROUP_INET4_POST_BIND = 12, + BPF_CGROUP_INET6_POST_BIND = 13, + BPF_CGROUP_UDP4_SENDMSG = 14, + BPF_CGROUP_UDP6_SENDMSG = 15, + BPF_LIRC_MODE2 = 16, + BPF_FLOW_DISSECTOR = 17, + BPF_CGROUP_SYSCTL = 18, + BPF_CGROUP_UDP4_RECVMSG = 19, + BPF_CGROUP_UDP6_RECVMSG = 20, + BPF_CGROUP_GETSOCKOPT = 21, + BPF_CGROUP_SETSOCKOPT = 22, + BPF_TRACE_RAW_TP = 23, + BPF_TRACE_FENTRY = 24, + BPF_TRACE_FEXIT = 25, + BPF_MODIFY_RETURN = 26, + BPF_LSM_MAC = 27, + BPF_TRACE_ITER = 28, + BPF_CGROUP_INET4_GETPEERNAME = 29, + BPF_CGROUP_INET6_GETPEERNAME = 30, + BPF_CGROUP_INET4_GETSOCKNAME = 31, + BPF_CGROUP_INET6_GETSOCKNAME = 32, + BPF_XDP_DEVMAP = 33, + BPF_CGROUP_INET_SOCK_RELEASE = 34, + BPF_XDP_CPUMAP = 35, + BPF_SK_LOOKUP = 36, + BPF_XDP = 37, + __MAX_BPF_ATTACH_TYPE = 38, +}; + +union bpf_attr { + struct { + __u32 map_type; + __u32 key_size; + __u32 value_size; + __u32 max_entries; + __u32 map_flags; + __u32 inner_map_fd; + __u32 numa_node; + char map_name[16]; + __u32 map_ifindex; + __u32 btf_fd; + __u32 btf_key_type_id; + __u32 btf_value_type_id; + __u32 btf_vmlinux_value_type_id; + }; + struct { + __u32 map_fd; + __u64 key; + union { + __u64 value; + __u64 next_key; + }; + __u64 flags; + }; + struct { + __u64 in_batch; + __u64 out_batch; + __u64 keys; + __u64 values; + __u32 count; + __u32 map_fd; + __u64 elem_flags; + __u64 flags; + } batch; + struct { + __u32 prog_type; + __u32 insn_cnt; + __u64 insns; + __u64 license; + __u32 log_level; + __u32 log_size; + __u64 log_buf; + __u32 kern_version; + __u32 prog_flags; + char prog_name[16]; + __u32 prog_ifindex; + __u32 expected_attach_type; + __u32 prog_btf_fd; + __u32 func_info_rec_size; + __u64 func_info; + __u32 func_info_cnt; + __u32 line_info_rec_size; + __u64 line_info; + __u32 line_info_cnt; + __u32 attach_btf_id; + union { + __u32 attach_prog_fd; + __u32 attach_btf_obj_fd; + }; + }; + struct { + __u64 pathname; + __u32 bpf_fd; + __u32 file_flags; + }; + struct { + __u32 target_fd; + __u32 attach_bpf_fd; + __u32 attach_type; + __u32 attach_flags; + __u32 replace_bpf_fd; + }; + struct { + __u32 prog_fd; + __u32 retval; + __u32 data_size_in; + __u32 data_size_out; + __u64 data_in; + __u64 data_out; + __u32 repeat; + __u32 duration; + __u32 ctx_size_in; + __u32 ctx_size_out; + __u64 ctx_in; + __u64 ctx_out; + __u32 flags; + __u32 cpu; + } test; + struct { + union { + __u32 start_id; + __u32 prog_id; + __u32 map_id; + __u32 btf_id; + __u32 link_id; + }; + __u32 next_id; + __u32 open_flags; + }; + struct { + __u32 bpf_fd; + __u32 info_len; + __u64 info; + } info; + struct { + __u32 target_fd; + __u32 attach_type; + __u32 query_flags; + __u32 attach_flags; + __u64 prog_ids; + __u32 prog_cnt; + } query; + struct { + __u64 name; + __u32 prog_fd; + } raw_tracepoint; + struct { + __u64 btf; + __u64 btf_log_buf; + __u32 btf_size; + __u32 btf_log_size; + __u32 btf_log_level; + }; + struct { + __u32 pid; + __u32 fd; + __u32 flags; + __u32 buf_len; + __u64 buf; + __u32 prog_id; + __u32 fd_type; + __u64 probe_offset; + __u64 probe_addr; + } task_fd_query; + struct { + __u32 prog_fd; + union { + __u32 target_fd; + __u32 target_ifindex; + }; + __u32 attach_type; + __u32 flags; + union { + __u32 target_btf_id; + struct { + __u64 iter_info; + __u32 iter_info_len; + }; + }; + } link_create; + struct { + __u32 link_fd; + __u32 new_prog_fd; + __u32 flags; + __u32 old_prog_fd; + } link_update; + struct { + __u32 link_fd; + } link_detach; + struct { + __u32 type; + } enable_stats; + struct { + __u32 link_fd; + __u32 flags; + } iter_create; + struct { + __u32 prog_fd; + __u32 map_fd; + __u32 flags; + } prog_bind_map; +}; + +struct bpf_func_info { + __u32 insn_off; + __u32 type_id; +}; + +struct bpf_line_info { + __u32 insn_off; + __u32 file_name_off; + __u32 line_off; + __u32 line_col; +}; + +struct bpf_iter_aux_info; + +typedef int (*bpf_iter_init_seq_priv_t)(void *, struct bpf_iter_aux_info *); + +struct bpf_map; + +struct bpf_iter_aux_info { + struct bpf_map *map; +}; + +typedef void (*bpf_iter_fini_seq_priv_t)(void *); + +struct bpf_iter_seq_info { + const struct seq_operations *seq_ops; + bpf_iter_init_seq_priv_t init_seq_private; + bpf_iter_fini_seq_priv_t fini_seq_private; + u32 seq_priv_size; +}; + +struct btf; + +struct btf_type; + +struct bpf_prog_aux; + +struct bpf_local_storage_map; + +struct bpf_map_ops { + int (*map_alloc_check)(union bpf_attr *); + struct bpf_map * (*map_alloc)(union bpf_attr *); + void (*map_release)(struct bpf_map *, struct file *); + void (*map_free)(struct bpf_map *); + int (*map_get_next_key)(struct bpf_map *, void *, void *); + void (*map_release_uref)(struct bpf_map *); + void * (*map_lookup_elem_sys_only)(struct bpf_map *, void *); + int (*map_lookup_batch)(struct bpf_map *, const union bpf_attr *, union bpf_attr *); + int (*map_lookup_and_delete_batch)(struct bpf_map *, const union bpf_attr *, union bpf_attr *); + int (*map_update_batch)(struct bpf_map *, const union bpf_attr *, union bpf_attr *); + int (*map_delete_batch)(struct bpf_map *, const union bpf_attr *, union bpf_attr *); + void * (*map_lookup_elem)(struct bpf_map *, void *); + int (*map_update_elem)(struct bpf_map *, void *, void *, u64); + int (*map_delete_elem)(struct bpf_map *, void *); + int (*map_push_elem)(struct bpf_map *, void *, u64); + int (*map_pop_elem)(struct bpf_map *, void *); + int (*map_peek_elem)(struct bpf_map *, void *); + void * (*map_fd_get_ptr)(struct bpf_map *, struct file *, int); + void (*map_fd_put_ptr)(void *); + int (*map_gen_lookup)(struct bpf_map *, struct bpf_insn *); + u32 (*map_fd_sys_lookup_elem)(void *); + void (*map_seq_show_elem)(struct bpf_map *, void *, struct seq_file *); + int (*map_check_btf)(const struct bpf_map *, const struct btf *, const struct btf_type *, const struct btf_type *); + int (*map_poke_track)(struct bpf_map *, struct bpf_prog_aux *); + void (*map_poke_untrack)(struct bpf_map *, struct bpf_prog_aux *); + void (*map_poke_run)(struct bpf_map *, u32, struct bpf_prog *, struct bpf_prog *); + int (*map_direct_value_addr)(const struct bpf_map *, u64 *, u32); + int (*map_direct_value_meta)(const struct bpf_map *, u64, u32 *); + int (*map_mmap)(struct bpf_map *, struct vm_area_struct *); + __poll_t (*map_poll)(struct bpf_map *, struct file *, struct poll_table_struct *); + int (*map_local_storage_charge)(struct bpf_local_storage_map *, void *, u32); + void (*map_local_storage_uncharge)(struct bpf_local_storage_map *, void *, u32); + struct bpf_local_storage ** (*map_owner_storage_ptr)(void *); + bool (*map_meta_equal)(const struct bpf_map *, const struct bpf_map *); + const char * const map_btf_name; + int *map_btf_id; + const struct bpf_iter_seq_info *iter_seq_info; +}; + +struct bpf_map { + const struct bpf_map_ops *ops; + struct bpf_map *inner_map_meta; + void *security; + enum bpf_map_type map_type; + u32 key_size; + u32 value_size; + u32 max_entries; + u32 map_flags; + int spin_lock_off; + u32 id; + int numa_node; + u32 btf_key_type_id; + u32 btf_value_type_id; + struct btf *btf; + struct mem_cgroup *memcg; + char name[16]; + u32 btf_vmlinux_value_type_id; + bool bypass_spec_v1; + bool frozen; + long: 16; + long: 64; + long: 64; + long: 64; + atomic64_t refcnt; + atomic64_t usercnt; + struct work_struct work; + struct mutex freeze_mutex; + u64 writecnt; + long: 64; +}; + +struct btf_header { + __u16 magic; + __u8 version; + __u8 flags; + __u32 hdr_len; + __u32 type_off; + __u32 type_len; + __u32 str_off; + __u32 str_len; +}; + +struct btf { + void *data; + struct btf_type **types; + u32 *resolved_ids; + u32 *resolved_sizes; + const char *strings; + void *nohdr_data; + struct btf_header hdr; + u32 nr_types; + u32 types_size; + u32 data_size; + refcount_t refcnt; + u32 id; + struct callback_head rcu; + struct btf *base_btf; + u32 start_id; + u32 start_str_off; + char name[56]; + bool kernel_btf; +}; + +struct btf_type { + __u32 name_off; + __u32 info; + union { + __u32 size; + __u32 type; + }; +}; + +enum bpf_tramp_prog_type { + BPF_TRAMP_FENTRY = 0, + BPF_TRAMP_FEXIT = 1, + BPF_TRAMP_MODIFY_RETURN = 2, + BPF_TRAMP_MAX = 3, + BPF_TRAMP_REPLACE = 4, +}; + +struct bpf_ksym { + long unsigned int start; + long unsigned int end; + char name[128]; + struct list_head lnode; + struct latch_tree_node tnode; + bool prog; +}; + +struct bpf_ctx_arg_aux; + +struct bpf_trampoline; + +struct bpf_jit_poke_descriptor; + +struct bpf_prog_ops; + +struct bpf_prog_offload; + +struct bpf_func_info_aux; + +struct bpf_prog_stats; + +struct bpf_prog_aux { + atomic64_t refcnt; + u32 used_map_cnt; + u32 max_ctx_offset; + u32 max_pkt_offset; + u32 max_tp_access; + u32 stack_depth; + u32 id; + u32 func_cnt; + u32 func_idx; + u32 attach_btf_id; + u32 ctx_arg_info_size; + u32 max_rdonly_access; + u32 max_rdwr_access; + struct btf *attach_btf; + const struct bpf_ctx_arg_aux *ctx_arg_info; + struct mutex dst_mutex; + struct bpf_prog *dst_prog; + struct bpf_trampoline *dst_trampoline; + enum bpf_prog_type saved_dst_prog_type; + enum bpf_attach_type saved_dst_attach_type; + bool verifier_zext; + bool offload_requested; + bool attach_btf_trace; + bool func_proto_unreliable; + bool sleepable; + bool tail_call_reachable; + enum bpf_tramp_prog_type trampoline_prog_type; + struct hlist_node tramp_hlist; + const struct btf_type *attach_func_proto; + const char *attach_func_name; + struct bpf_prog **func; + void *jit_data; + struct bpf_jit_poke_descriptor *poke_tab; + u32 size_poke_tab; + struct bpf_ksym ksym; + const struct bpf_prog_ops *ops; + struct bpf_map **used_maps; + struct mutex used_maps_mutex; + struct bpf_prog *prog; + struct user_struct *user; + u64 load_time; + struct bpf_map *cgroup_storage[2]; + char name[16]; + void *security; + struct bpf_prog_offload *offload; + struct btf *btf; + struct bpf_func_info *func_info; + struct bpf_func_info_aux *func_info_aux; + struct bpf_line_info *linfo; + void **jited_linfo; + u32 func_info_cnt; + u32 nr_linfo; + u32 linfo_idx; + u32 num_exentries; + struct exception_table_entry *extable; + struct bpf_prog_stats *stats; + union { + struct work_struct work; + struct callback_head rcu; + }; +}; + +struct sock_filter { + __u16 code; + __u8 jt; + __u8 jf; + __u32 k; +}; + +struct sock_fprog_kern; + +struct bpf_prog { + u16 pages; + u16 jited: 1; + u16 jit_requested: 1; + u16 gpl_compatible: 1; + u16 cb_access: 1; + u16 dst_needed: 1; + u16 blinded: 1; + u16 is_func: 1; + u16 kprobe_override: 1; + u16 has_callchain_buf: 1; + u16 enforce_expected_attach_type: 1; + u16 call_get_stack: 1; + enum bpf_prog_type type; + enum bpf_attach_type expected_attach_type; + u32 len; + u32 jited_len; + u8 tag[8]; + struct bpf_prog_aux *aux; + struct sock_fprog_kern *orig_prog; + unsigned int (*bpf_func)(const void *, const struct bpf_insn *); + struct sock_filter insns[0]; + struct bpf_insn insnsi[0]; +}; + +struct bpf_offloaded_map; + +struct bpf_map_dev_ops { + int (*map_get_next_key)(struct bpf_offloaded_map *, void *, void *); + int (*map_lookup_elem)(struct bpf_offloaded_map *, void *, void *); + int (*map_update_elem)(struct bpf_offloaded_map *, void *, void *, u64); + int (*map_delete_elem)(struct bpf_offloaded_map *, void *); +}; + +struct bpf_offloaded_map { + struct bpf_map map; + struct net_device *netdev; + const struct bpf_map_dev_ops *dev_ops; + void *dev_priv; + struct list_head offloads; + long: 64; + long: 64; + long: 64; +}; + +struct net_device_stats { + long unsigned int rx_packets; + long unsigned int tx_packets; + long unsigned int rx_bytes; + long unsigned int tx_bytes; + long unsigned int rx_errors; + long unsigned int tx_errors; + long unsigned int rx_dropped; + long unsigned int tx_dropped; + long unsigned int multicast; + long unsigned int collisions; + long unsigned int rx_length_errors; + long unsigned int rx_over_errors; + long unsigned int rx_crc_errors; + long unsigned int rx_frame_errors; + long unsigned int rx_fifo_errors; + long unsigned int rx_missed_errors; + long unsigned int tx_aborted_errors; + long unsigned int tx_carrier_errors; + long unsigned int tx_fifo_errors; + long unsigned int tx_heartbeat_errors; + long unsigned int tx_window_errors; + long unsigned int rx_compressed; + long unsigned int tx_compressed; +}; + +struct netdev_hw_addr_list { + struct list_head list; + int count; +}; + +struct tipc_bearer; + +struct dn_dev; + +enum rx_handler_result { + RX_HANDLER_CONSUMED = 0, + RX_HANDLER_ANOTHER = 1, + RX_HANDLER_EXACT = 2, + RX_HANDLER_PASS = 3, +}; + +typedef enum rx_handler_result rx_handler_result_t; + +typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **); + +struct pcpu_dstats; + +struct netdev_tc_txq { + u16 count; + u16 offset; +}; + +struct sfp_bus; + +struct bpf_xdp_link; + +struct bpf_xdp_entity { + struct bpf_prog *prog; + struct bpf_xdp_link *link; +}; + +struct netdev_name_node; + +struct dev_ifalias; + +struct net_device_ops; + +struct ethtool_ops; + +struct ndisc_ops; + +struct header_ops; + +struct vlan_info; + +struct in_device; + +struct inet6_dev; + +struct wireless_dev; + +struct wpan_dev; + +struct netdev_rx_queue; + +struct mini_Qdisc; + +struct netdev_queue; + +struct cpu_rmap; + +struct Qdisc; + +struct xdp_dev_bulk_queue; + +struct xps_dev_maps; + +struct netpoll_info; + +struct pcpu_lstats; + +struct pcpu_sw_netstats; + +struct rtnl_link_ops; + +struct dcbnl_rtnl_ops; + +struct phy_device; + +struct udp_tunnel_nic_info; + +struct udp_tunnel_nic; + +struct net_device { + char name[16]; + struct netdev_name_node *name_node; + struct dev_ifalias *ifalias; + long unsigned int mem_end; + long unsigned int mem_start; + long unsigned int base_addr; + int irq; + long unsigned int state; + struct list_head dev_list; + struct list_head napi_list; + struct list_head unreg_list; + struct list_head close_list; + struct list_head ptype_all; + struct list_head ptype_specific; + struct { + struct list_head upper; + struct list_head lower; + } adj_list; + netdev_features_t features; + netdev_features_t hw_features; + netdev_features_t wanted_features; + netdev_features_t vlan_features; + netdev_features_t hw_enc_features; + netdev_features_t mpls_features; + netdev_features_t gso_partial_features; + int ifindex; + int group; + struct net_device_stats stats; + atomic_long_t rx_dropped; + atomic_long_t tx_dropped; + atomic_long_t rx_nohandler; + atomic_t carrier_up_count; + atomic_t carrier_down_count; + const struct net_device_ops *netdev_ops; + const struct ethtool_ops *ethtool_ops; + const struct ndisc_ops *ndisc_ops; + const struct header_ops *header_ops; + unsigned int flags; + unsigned int priv_flags; + short unsigned int gflags; + short unsigned int padded; + unsigned char operstate; + unsigned char link_mode; + unsigned char if_port; + unsigned char dma; + unsigned int mtu; + unsigned int min_mtu; + unsigned int max_mtu; + short unsigned int type; + short unsigned int hard_header_len; + unsigned char min_header_len; + unsigned char name_assign_type; + short unsigned int needed_headroom; + short unsigned int needed_tailroom; + unsigned char perm_addr[32]; + unsigned char addr_assign_type; + unsigned char addr_len; + unsigned char upper_level; + unsigned char lower_level; + short unsigned int neigh_priv_len; + short unsigned int dev_id; + short unsigned int dev_port; + spinlock_t addr_list_lock; + struct netdev_hw_addr_list uc; + struct netdev_hw_addr_list mc; + struct netdev_hw_addr_list dev_addrs; + struct kset *queues_kset; + unsigned int promiscuity; + unsigned int allmulti; + bool uc_promisc; + struct vlan_info *vlan_info; + struct tipc_bearer *tipc_ptr; + void *atalk_ptr; + struct in_device *ip_ptr; + struct dn_dev *dn_ptr; + struct inet6_dev *ip6_ptr; + struct wireless_dev *ieee80211_ptr; + struct wpan_dev *ieee802154_ptr; + unsigned char *dev_addr; + struct netdev_rx_queue *_rx; + unsigned int num_rx_queues; + unsigned int real_num_rx_queues; + struct bpf_prog *xdp_prog; + long unsigned int gro_flush_timeout; + int napi_defer_hard_irqs; + rx_handler_func_t *rx_handler; + void *rx_handler_data; + struct mini_Qdisc *miniq_ingress; + struct netdev_queue *ingress_queue; + struct nf_hook_entries *nf_hooks_ingress; + unsigned char broadcast[32]; + struct cpu_rmap *rx_cpu_rmap; + struct hlist_node index_hlist; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct netdev_queue *_tx; + unsigned int num_tx_queues; + unsigned int real_num_tx_queues; + struct Qdisc *qdisc; + unsigned int tx_queue_len; + spinlock_t tx_global_lock; + struct xdp_dev_bulk_queue *xdp_bulkq; + struct xps_dev_maps *xps_cpus_map; + struct xps_dev_maps *xps_rxqs_map; + struct mini_Qdisc *miniq_egress; + struct hlist_head qdisc_hash[16]; + struct timer_list watchdog_timer; + int watchdog_timeo; + u32 proto_down_reason; + struct list_head todo_list; + int *pcpu_refcnt; + struct list_head link_watch_list; + enum { + NETREG_UNINITIALIZED = 0, + NETREG_REGISTERED = 1, + NETREG_UNREGISTERING = 2, + NETREG_UNREGISTERED = 3, + NETREG_RELEASED = 4, + NETREG_DUMMY = 5, + } reg_state: 8; + bool dismantle; + enum { + RTNL_LINK_INITIALIZED = 0, + RTNL_LINK_INITIALIZING = 1, + } rtnl_link_state: 16; + bool needs_free_netdev; + void (*priv_destructor)(struct net_device *); + struct netpoll_info *npinfo; + possible_net_t nd_net; + union { + void *ml_priv; + struct pcpu_lstats *lstats; + struct pcpu_sw_netstats *tstats; + struct pcpu_dstats *dstats; + }; + struct device dev; + const struct attribute_group *sysfs_groups[4]; + const struct attribute_group *sysfs_rx_queue_group; + const struct rtnl_link_ops *rtnl_link_ops; + unsigned int gso_max_size; + u16 gso_max_segs; + const struct dcbnl_rtnl_ops *dcbnl_ops; + s16 num_tc; + struct netdev_tc_txq tc_to_txq[16]; + u8 prio_tc_map[16]; + struct phy_device *phydev; + struct sfp_bus *sfp_bus; + struct lock_class_key *qdisc_tx_busylock; + struct lock_class_key *qdisc_running_key; + bool proto_down; + unsigned int wol_enabled: 1; + struct list_head net_notifier_list; + const struct udp_tunnel_nic_info *udp_tunnel_nic_info; + struct udp_tunnel_nic *udp_tunnel_nic; + struct bpf_xdp_entity xdp_state[3]; + long: 64; +}; + +enum bpf_reg_type { + NOT_INIT = 0, + SCALAR_VALUE = 1, + PTR_TO_CTX = 2, + CONST_PTR_TO_MAP = 3, + PTR_TO_MAP_VALUE = 4, + PTR_TO_MAP_VALUE_OR_NULL = 5, + PTR_TO_STACK = 6, + PTR_TO_PACKET_META = 7, + PTR_TO_PACKET = 8, + PTR_TO_PACKET_END = 9, + PTR_TO_FLOW_KEYS = 10, + PTR_TO_SOCKET = 11, + PTR_TO_SOCKET_OR_NULL = 12, + PTR_TO_SOCK_COMMON = 13, + PTR_TO_SOCK_COMMON_OR_NULL = 14, + PTR_TO_TCP_SOCK = 15, + PTR_TO_TCP_SOCK_OR_NULL = 16, + PTR_TO_TP_BUFFER = 17, + PTR_TO_XDP_SOCK = 18, + PTR_TO_BTF_ID = 19, + PTR_TO_BTF_ID_OR_NULL = 20, + PTR_TO_MEM = 21, + PTR_TO_MEM_OR_NULL = 22, + PTR_TO_RDONLY_BUF = 23, + PTR_TO_RDONLY_BUF_OR_NULL = 24, + PTR_TO_RDWR_BUF = 25, + PTR_TO_RDWR_BUF_OR_NULL = 26, + PTR_TO_PERCPU_BTF_ID = 27, +}; + +struct bpf_prog_ops { + int (*test_run)(struct bpf_prog *, const union bpf_attr *, union bpf_attr *); +}; + +struct bpf_offload_dev; + +struct bpf_prog_offload { + struct bpf_prog *prog; + struct net_device *netdev; + struct bpf_offload_dev *offdev; + void *dev_priv; + struct list_head offloads; + bool dev_state; + bool opt_failed; + void *jited_image; + u32 jited_len; +}; + +struct bpf_prog_stats { + u64 cnt; + u64 nsecs; + struct u64_stats_sync syncp; +}; + +struct btf_func_model { + u8 ret_size; + u8 nr_args; + u8 arg_size[12]; +}; + +struct bpf_trampoline { + struct hlist_node hlist; + struct mutex mutex; + refcount_t refcnt; + u64 key; + struct { + struct btf_func_model model; + void *addr; + bool ftrace_managed; + } func; + struct bpf_prog *extension_prog; + struct hlist_head progs_hlist[3]; + int progs_cnt[3]; + void *image; + u64 selector; + struct bpf_ksym ksym; +}; + +struct bpf_func_info_aux { + u16 linkage; + bool unreliable; +}; + +struct bpf_jit_poke_descriptor { + void *tailcall_target; + void *tailcall_bypass; + void *bypass_addr; + union { + struct { + struct bpf_map *map; + u32 key; + } tail_call; + }; + bool tailcall_target_stable; + u8 adj_off; + u16 reason; + u32 insn_idx; +}; + +struct bpf_ctx_arg_aux { + u32 offset; + enum bpf_reg_type reg_type; + u32 btf_id; +}; + +typedef unsigned int sk_buff_data_t; + +struct skb_ext; + +struct sk_buff { + union { + struct { + struct sk_buff *next; + struct sk_buff *prev; + union { + struct net_device *dev; + long unsigned int dev_scratch; + }; + }; + struct rb_node rbnode; + struct list_head list; + }; + union { + struct sock *sk; + int ip_defrag_offset; + }; + union { + ktime_t tstamp; + u64 skb_mstamp_ns; + }; + char cb[48]; + union { + struct { + long unsigned int _skb_refdst; + void (*destructor)(struct sk_buff *); + }; + struct list_head tcp_tsorted_anchor; + }; + unsigned int len; + unsigned int data_len; + __u16 mac_len; + __u16 hdr_len; + __u16 queue_mapping; + __u8 __cloned_offset[0]; + __u8 cloned: 1; + __u8 nohdr: 1; + __u8 fclone: 2; + __u8 peeked: 1; + __u8 head_frag: 1; + __u8 pfmemalloc: 1; + __u8 active_extensions; + __u32 headers_start[0]; + __u8 __pkt_type_offset[0]; + __u8 pkt_type: 3; + __u8 ignore_df: 1; + __u8 nf_trace: 1; + __u8 ip_summed: 2; + __u8 ooo_okay: 1; + __u8 l4_hash: 1; + __u8 sw_hash: 1; + __u8 wifi_acked_valid: 1; + __u8 wifi_acked: 1; + __u8 no_fcs: 1; + __u8 encapsulation: 1; + __u8 encap_hdr_csum: 1; + __u8 csum_valid: 1; + __u8 __pkt_vlan_present_offset[0]; + __u8 vlan_present: 1; + __u8 csum_complete_sw: 1; + __u8 csum_level: 2; + __u8 csum_not_inet: 1; + __u8 dst_pending_confirm: 1; + __u8 ndisc_nodetype: 2; + __u8 ipvs_property: 1; + __u8 inner_protocol_type: 1; + __u8 remcsum_offload: 1; + __u8 tc_skip_classify: 1; + __u8 tc_at_ingress: 1; + __u8 redirected: 1; + __u8 from_ingress: 1; + __u16 tc_index; + union { + __wsum csum; + struct { + __u16 csum_start; + __u16 csum_offset; + }; + }; + __u32 priority; + int skb_iif; + __u32 hash; + __be16 vlan_proto; + __u16 vlan_tci; + union { + unsigned int napi_id; + unsigned int sender_cpu; + }; + __u32 secmark; + union { + __u32 mark; + __u32 reserved_tailroom; + }; + union { + __be16 inner_protocol; + __u8 inner_ipproto; + }; + __u16 inner_transport_header; + __u16 inner_network_header; + __u16 inner_mac_header; + __be16 protocol; + __u16 transport_header; + __u16 network_header; + __u16 mac_header; + __u32 headers_end[0]; + sk_buff_data_t tail; + sk_buff_data_t end; + unsigned char *head; + unsigned char *data; + unsigned int truesize; + refcount_t users; + struct skb_ext *extensions; +}; + +enum { + Root_NFS = 255, + Root_CIFS = 254, + Root_RAM0 = 1048576, + Root_RAM1 = 1048577, + Root_FD0 = 2097152, + Root_HDA1 = 3145729, + Root_HDA2 = 3145730, + Root_SDA1 = 8388609, + Root_SDA2 = 8388610, + Root_HDC1 = 23068673, + Root_SR0 = 11534336, +}; + +struct ethhdr { + unsigned char h_dest[6]; + unsigned char h_source[6]; + __be16 h_proto; +}; + +struct flowi_tunnel { + __be64 tun_id; +}; + +struct flowi_common { + int flowic_oif; + int flowic_iif; + __u32 flowic_mark; + __u8 flowic_tos; + __u8 flowic_scope; + __u8 flowic_proto; + __u8 flowic_flags; + __u32 flowic_secid; + kuid_t flowic_uid; + struct flowi_tunnel flowic_tun_key; + __u32 flowic_multipath_hash; +}; + +union flowi_uli { + struct { + __be16 dport; + __be16 sport; + } ports; + struct { + __u8 type; + __u8 code; + } icmpt; + struct { + __le16 dport; + __le16 sport; + } dnports; + __be32 spi; + __be32 gre_key; + struct { + __u8 type; + } mht; +}; + +struct flowi4 { + struct flowi_common __fl_common; + __be32 saddr; + __be32 daddr; + union flowi_uli uli; +}; + +struct flowi6 { + struct flowi_common __fl_common; + struct in6_addr daddr; + struct in6_addr saddr; + __be32 flowlabel; + union flowi_uli uli; + __u32 mp_hash; +}; + +struct flowidn { + struct flowi_common __fl_common; + __le16 daddr; + __le16 saddr; + union flowi_uli uli; +}; + +struct flowi { + union { + struct flowi_common __fl_common; + struct flowi4 ip4; + struct flowi6 ip6; + struct flowidn dn; + } u; +}; + +struct ipstats_mib { + u64 mibs[37]; + struct u64_stats_sync syncp; +}; + +struct icmp_mib { + long unsigned int mibs[28]; +}; + +struct icmpmsg_mib { + atomic_long_t mibs[512]; +}; + +struct icmpv6_mib { + long unsigned int mibs[6]; +}; + +struct icmpv6_mib_device { + atomic_long_t mibs[6]; +}; + +struct icmpv6msg_mib { + atomic_long_t mibs[512]; +}; + +struct icmpv6msg_mib_device { + atomic_long_t mibs[512]; +}; + +struct tcp_mib { + long unsigned int mibs[16]; +}; + +struct udp_mib { + long unsigned int mibs[10]; +}; + +struct linux_mib { + long unsigned int mibs[124]; +}; + +struct linux_tls_mib { + long unsigned int mibs[11]; +}; + +struct inet_frags; + +struct fqdir { + long int high_thresh; + long int low_thresh; + int timeout; + int max_dist; + struct inet_frags *f; + struct net *net; + bool dead; + long: 56; + long: 64; + long: 64; + struct rhashtable rhashtable; + atomic_long_t mem; + struct work_struct destroy_work; + long: 64; + long: 64; + long: 64; +}; + +struct inet_frag_queue; + +struct inet_frags { + unsigned int qsize; + void (*constructor)(struct inet_frag_queue *, const void *); + void (*destructor)(struct inet_frag_queue *); + void (*frag_expire)(struct timer_list *); + struct kmem_cache *frags_cachep; + const char *frags_cache_name; + struct rhashtable_params rhash_params; + refcount_t refcnt; + struct completion completion; +}; + +struct frag_v4_compare_key { + __be32 saddr; + __be32 daddr; + u32 user; + u32 vif; + __be16 id; + u16 protocol; +}; + +struct frag_v6_compare_key { + struct in6_addr saddr; + struct in6_addr daddr; + u32 user; + __be32 id; + u32 iif; +}; + +struct inet_frag_queue { + struct rhash_head node; + union { + struct frag_v4_compare_key v4; + struct frag_v6_compare_key v6; + } key; + struct timer_list timer; + spinlock_t lock; + refcount_t refcnt; + struct rb_root rb_fragments; + struct sk_buff *fragments_tail; + struct sk_buff *last_run_head; + ktime_t stamp; + int len; + int meat; + __u8 flags; + u16 max_size; + struct fqdir *fqdir; + struct callback_head rcu; +}; + +struct fib_rule; + +struct fib_lookup_arg; + +struct fib_rule_hdr; + +struct nlattr; + +struct netlink_ext_ack; + +struct nla_policy; + +struct fib_rules_ops { + int family; + struct list_head list; + int rule_size; + int addr_size; + int unresolved_rules; + int nr_goto_rules; + unsigned int fib_rules_seq; + int (*action)(struct fib_rule *, struct flowi *, int, struct fib_lookup_arg *); + bool (*suppress)(struct fib_rule *, struct fib_lookup_arg *); + int (*match)(struct fib_rule *, struct flowi *, int); + int (*configure)(struct fib_rule *, struct sk_buff *, struct fib_rule_hdr *, struct nlattr **, struct netlink_ext_ack *); + int (*delete)(struct fib_rule *); + int (*compare)(struct fib_rule *, struct fib_rule_hdr *, struct nlattr **); + int (*fill)(struct fib_rule *, struct sk_buff *, struct fib_rule_hdr *); + size_t (*nlmsg_payload)(struct fib_rule *); + void (*flush_cache)(struct fib_rules_ops *); + int nlgroup; + const struct nla_policy *policy; + struct list_head rules_list; + struct module *owner; + struct net *fro_net; + struct callback_head rcu; +}; + +enum tcp_ca_event { + CA_EVENT_TX_START = 0, + CA_EVENT_CWND_RESTART = 1, + CA_EVENT_COMPLETE_CWR = 2, + CA_EVENT_LOSS = 3, + CA_EVENT_ECN_NO_CE = 4, + CA_EVENT_ECN_IS_CE = 5, +}; + +struct ack_sample; + +struct rate_sample; + +union tcp_cc_info; + +struct tcp_congestion_ops { + struct list_head list; + u32 key; + u32 flags; + void (*init)(struct sock *); + void (*release)(struct sock *); + u32 (*ssthresh)(struct sock *); + void (*cong_avoid)(struct sock *, u32, u32); + void (*set_state)(struct sock *, u8); + void (*cwnd_event)(struct sock *, enum tcp_ca_event); + void (*in_ack_event)(struct sock *, u32); + u32 (*undo_cwnd)(struct sock *); + void (*pkts_acked)(struct sock *, const struct ack_sample *); + u32 (*min_tso_segs)(struct sock *); + u32 (*sndbuf_expand)(struct sock *); + void (*cong_control)(struct sock *, const struct rate_sample *); + size_t (*get_info)(struct sock *, u32, int *, union tcp_cc_info *); + char name[16]; + struct module *owner; +}; + +struct fib_notifier_ops { + int family; + struct list_head list; + unsigned int (*fib_seq_read)(struct net *); + int (*fib_dump)(struct net *, struct notifier_block *, struct netlink_ext_ack *); + struct module *owner; + struct callback_head rcu; +}; + +struct xfrm_state; + +struct lwtunnel_state; + +struct dst_entry { + struct net_device *dev; + struct dst_ops *ops; + long unsigned int _metrics; + long unsigned int expires; + struct xfrm_state *xfrm; + int (*input)(struct sk_buff *); + int (*output)(struct net *, struct sock *, struct sk_buff *); + short unsigned int flags; + short int obsolete; + short unsigned int header_len; + short unsigned int trailer_len; + atomic_t __refcnt; + int __use; + long unsigned int lastuse; + struct lwtunnel_state *lwtstate; + struct callback_head callback_head; + short int error; + short int __pad; + __u32 tclassid; +}; + +struct hh_cache { + unsigned int hh_len; + seqlock_t hh_lock; + long unsigned int hh_data[12]; +}; + +struct neigh_table; + +struct neigh_parms; + +struct neigh_ops; + +struct neighbour { + struct neighbour *next; + struct neigh_table *tbl; + struct neigh_parms *parms; + long unsigned int confirmed; + long unsigned int updated; + rwlock_t lock; + refcount_t refcnt; + unsigned int arp_queue_len_bytes; + struct sk_buff_head arp_queue; + struct timer_list timer; + long unsigned int used; + atomic_t probes; + __u8 flags; + __u8 nud_state; + __u8 type; + __u8 dead; + u8 protocol; + seqlock_t ha_lock; + unsigned char ha[32]; + struct hh_cache hh; + int (*output)(struct neighbour *, struct sk_buff *); + const struct neigh_ops *ops; + struct list_head gc_list; + struct callback_head rcu; + struct net_device *dev; + u8 primary_key[0]; +}; + +struct ipv6_stable_secret { + bool initialized; + struct in6_addr secret; +}; + +struct ipv6_devconf { + __s32 forwarding; + __s32 hop_limit; + __s32 mtu6; + __s32 accept_ra; + __s32 accept_redirects; + __s32 autoconf; + __s32 dad_transmits; + __s32 rtr_solicits; + __s32 rtr_solicit_interval; + __s32 rtr_solicit_max_interval; + __s32 rtr_solicit_delay; + __s32 force_mld_version; + __s32 mldv1_unsolicited_report_interval; + __s32 mldv2_unsolicited_report_interval; + __s32 use_tempaddr; + __s32 temp_valid_lft; + __s32 temp_prefered_lft; + __s32 regen_max_retry; + __s32 max_desync_factor; + __s32 max_addresses; + __s32 accept_ra_defrtr; + __s32 accept_ra_min_hop_limit; + __s32 accept_ra_pinfo; + __s32 ignore_routes_with_linkdown; + __s32 accept_ra_rtr_pref; + __s32 rtr_probe_interval; + __s32 accept_ra_rt_info_min_plen; + __s32 accept_ra_rt_info_max_plen; + __s32 proxy_ndp; + __s32 accept_source_route; + __s32 accept_ra_from_local; + __s32 disable_ipv6; + __s32 drop_unicast_in_l2_multicast; + __s32 accept_dad; + __s32 force_tllao; + __s32 ndisc_notify; + __s32 suppress_frag_ndisc; + __s32 accept_ra_mtu; + __s32 drop_unsolicited_na; + struct ipv6_stable_secret stable_secret; + __s32 use_oif_addrs_only; + __s32 keep_addr_on_down; + __s32 seg6_enabled; + __u32 enhanced_dad; + __u32 addr_gen_mode; + __s32 disable_policy; + __s32 ndisc_tclass; + __s32 rpl_seg_enabled; + struct ctl_table_header *sysctl_header; +}; + +struct nf_queue_entry; + +struct nf_queue_handler { + int (*outfn)(struct nf_queue_entry *, unsigned int); + void (*nf_hook_drop)(struct net *); +}; + +enum nf_log_type { + NF_LOG_TYPE_LOG = 0, + NF_LOG_TYPE_ULOG = 1, + NF_LOG_TYPE_MAX = 2, +}; + +typedef u8 u_int8_t; + +struct nf_loginfo; + +typedef void nf_logfn(struct net *, u_int8_t, unsigned int, const struct sk_buff *, const struct net_device *, const struct net_device *, const struct nf_loginfo *, const char *); + +struct nf_logger { + char *name; + enum nf_log_type type; + nf_logfn *logfn; + struct module *me; +}; + +typedef struct { + union { + void *kernel; + void *user; + }; + bool is_kernel: 1; +} sockptr_t; + +typedef enum { + SS_FREE = 0, + SS_UNCONNECTED = 1, + SS_CONNECTING = 2, + SS_CONNECTED = 3, + SS_DISCONNECTING = 4, +} socket_state; + +struct socket_wq { + wait_queue_head_t wait; + struct fasync_struct *fasync_list; + long unsigned int flags; + struct callback_head rcu; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct proto_ops; + +struct socket { + socket_state state; + short int type; + long unsigned int flags; + struct file *file; + struct sock *sk; + const struct proto_ops *ops; + long: 64; + long: 64; + long: 64; + struct socket_wq wq; +}; + +typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, unsigned int, size_t); + +struct proto_ops { + int family; + unsigned int flags; + struct module *owner; + int (*release)(struct socket *); + int (*bind)(struct socket *, struct sockaddr *, int); + int (*connect)(struct socket *, struct sockaddr *, int, int); + int (*socketpair)(struct socket *, struct socket *); + int (*accept)(struct socket *, struct socket *, int, bool); + int (*getname)(struct socket *, struct sockaddr *, int); + __poll_t (*poll)(struct file *, struct socket *, struct poll_table_struct *); + int (*ioctl)(struct socket *, unsigned int, long unsigned int); + int (*compat_ioctl)(struct socket *, unsigned int, long unsigned int); + int (*gettstamp)(struct socket *, void *, bool, bool); + int (*listen)(struct socket *, int); + int (*shutdown)(struct socket *, int); + int (*setsockopt)(struct socket *, int, int, sockptr_t, unsigned int); + int (*getsockopt)(struct socket *, int, int, char *, int *); + void (*show_fdinfo)(struct seq_file *, struct socket *); + int (*sendmsg)(struct socket *, struct msghdr *, size_t); + int (*recvmsg)(struct socket *, struct msghdr *, size_t, int); + int (*mmap)(struct file *, struct socket *, struct vm_area_struct *); + ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int); + ssize_t (*splice_read)(struct socket *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); + int (*set_peek_off)(struct sock *, int); + int (*peek_len)(struct socket *); + int (*read_sock)(struct sock *, read_descriptor_t *, sk_read_actor_t); + int (*sendpage_locked)(struct sock *, struct page *, int, size_t, int); + int (*sendmsg_locked)(struct sock *, struct msghdr *, size_t); + int (*set_rcvlowat)(struct sock *, int); +}; + +struct pipe_buf_operations; + +struct pipe_buffer { + struct page *page; + unsigned int offset; + unsigned int len; + const struct pipe_buf_operations *ops; + unsigned int flags; + long unsigned int private; +}; + +struct pipe_buf_operations { + int (*confirm)(struct pipe_inode_info *, struct pipe_buffer *); + void (*release)(struct pipe_inode_info *, struct pipe_buffer *); + bool (*try_steal)(struct pipe_inode_info *, struct pipe_buffer *); + bool (*get)(struct pipe_inode_info *, struct pipe_buffer *); +}; + +struct skb_ext { + refcount_t refcnt; + u8 offset[2]; + u8 chunks; + char: 8; + char data[0]; +}; + +struct dql { + unsigned int num_queued; + unsigned int adj_limit; + unsigned int last_obj_cnt; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + unsigned int limit; + unsigned int num_completed; + unsigned int prev_ovlimit; + unsigned int prev_num_queued; + unsigned int prev_last_obj_cnt; + unsigned int lowest_slack; + long unsigned int slack_start_time; + unsigned int max_limit; + unsigned int min_limit; + unsigned int slack_hold_time; + long: 32; + long: 64; + long: 64; +}; + +struct ethtool_drvinfo { + __u32 cmd; + char driver[32]; + char version[32]; + char fw_version[32]; + char bus_info[32]; + char erom_version[32]; + char reserved2[12]; + __u32 n_priv_flags; + __u32 n_stats; + __u32 testinfo_len; + __u32 eedump_len; + __u32 regdump_len; +}; + +struct ethtool_wolinfo { + __u32 cmd; + __u32 supported; + __u32 wolopts; + __u8 sopass[6]; +}; + +struct ethtool_tunable { + __u32 cmd; + __u32 id; + __u32 type_id; + __u32 len; + void *data[0]; +}; + +struct ethtool_regs { + __u32 cmd; + __u32 version; + __u32 len; + __u8 data[0]; +}; + +struct ethtool_eeprom { + __u32 cmd; + __u32 magic; + __u32 offset; + __u32 len; + __u8 data[0]; +}; + +struct ethtool_eee { + __u32 cmd; + __u32 supported; + __u32 advertised; + __u32 lp_advertised; + __u32 eee_active; + __u32 eee_enabled; + __u32 tx_lpi_enabled; + __u32 tx_lpi_timer; + __u32 reserved[2]; +}; + +struct ethtool_modinfo { + __u32 cmd; + __u32 type; + __u32 eeprom_len; + __u32 reserved[8]; +}; + +struct ethtool_coalesce { + __u32 cmd; + __u32 rx_coalesce_usecs; + __u32 rx_max_coalesced_frames; + __u32 rx_coalesce_usecs_irq; + __u32 rx_max_coalesced_frames_irq; + __u32 tx_coalesce_usecs; + __u32 tx_max_coalesced_frames; + __u32 tx_coalesce_usecs_irq; + __u32 tx_max_coalesced_frames_irq; + __u32 stats_block_coalesce_usecs; + __u32 use_adaptive_rx_coalesce; + __u32 use_adaptive_tx_coalesce; + __u32 pkt_rate_low; + __u32 rx_coalesce_usecs_low; + __u32 rx_max_coalesced_frames_low; + __u32 tx_coalesce_usecs_low; + __u32 tx_max_coalesced_frames_low; + __u32 pkt_rate_high; + __u32 rx_coalesce_usecs_high; + __u32 rx_max_coalesced_frames_high; + __u32 tx_coalesce_usecs_high; + __u32 tx_max_coalesced_frames_high; + __u32 rate_sample_interval; +}; + +struct ethtool_ringparam { + __u32 cmd; + __u32 rx_max_pending; + __u32 rx_mini_max_pending; + __u32 rx_jumbo_max_pending; + __u32 tx_max_pending; + __u32 rx_pending; + __u32 rx_mini_pending; + __u32 rx_jumbo_pending; + __u32 tx_pending; +}; + +struct ethtool_channels { + __u32 cmd; + __u32 max_rx; + __u32 max_tx; + __u32 max_other; + __u32 max_combined; + __u32 rx_count; + __u32 tx_count; + __u32 other_count; + __u32 combined_count; +}; + +struct ethtool_pauseparam { + __u32 cmd; + __u32 autoneg; + __u32 rx_pause; + __u32 tx_pause; +}; + +enum ethtool_link_ext_state { + ETHTOOL_LINK_EXT_STATE_AUTONEG = 0, + ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE = 1, + ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH = 2, + ETHTOOL_LINK_EXT_STATE_BAD_SIGNAL_INTEGRITY = 3, + ETHTOOL_LINK_EXT_STATE_NO_CABLE = 4, + ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE = 5, + ETHTOOL_LINK_EXT_STATE_EEPROM_ISSUE = 6, + ETHTOOL_LINK_EXT_STATE_CALIBRATION_FAILURE = 7, + ETHTOOL_LINK_EXT_STATE_POWER_BUDGET_EXCEEDED = 8, + ETHTOOL_LINK_EXT_STATE_OVERHEAT = 9, +}; + +enum ethtool_link_ext_substate_autoneg { + ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED = 1, + ETHTOOL_LINK_EXT_SUBSTATE_AN_ACK_NOT_RECEIVED = 2, + ETHTOOL_LINK_EXT_SUBSTATE_AN_NEXT_PAGE_EXCHANGE_FAILED = 3, + ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED_FORCE_MODE = 4, + ETHTOOL_LINK_EXT_SUBSTATE_AN_FEC_MISMATCH_DURING_OVERRIDE = 5, + ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_HCD = 6, +}; + +enum ethtool_link_ext_substate_link_training { + ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_FRAME_LOCK_NOT_ACQUIRED = 1, + ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_LINK_INHIBIT_TIMEOUT = 2, + ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_LINK_PARTNER_DID_NOT_SET_RECEIVER_READY = 3, + ETHTOOL_LINK_EXT_SUBSTATE_LT_REMOTE_FAULT = 4, +}; + +enum ethtool_link_ext_substate_link_logical_mismatch { + ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_BLOCK_LOCK = 1, + ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_AM_LOCK = 2, + ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_GET_ALIGN_STATUS = 3, + ETHTOOL_LINK_EXT_SUBSTATE_LLM_FC_FEC_IS_NOT_LOCKED = 4, + ETHTOOL_LINK_EXT_SUBSTATE_LLM_RS_FEC_IS_NOT_LOCKED = 5, +}; + +enum ethtool_link_ext_substate_bad_signal_integrity { + ETHTOOL_LINK_EXT_SUBSTATE_BSI_LARGE_NUMBER_OF_PHYSICAL_ERRORS = 1, + ETHTOOL_LINK_EXT_SUBSTATE_BSI_UNSUPPORTED_RATE = 2, +}; + +enum ethtool_link_ext_substate_cable_issue { + ETHTOOL_LINK_EXT_SUBSTATE_CI_UNSUPPORTED_CABLE = 1, + ETHTOOL_LINK_EXT_SUBSTATE_CI_CABLE_TEST_FAILURE = 2, +}; + +struct ethtool_test { + __u32 cmd; + __u32 flags; + __u32 reserved; + __u32 len; + __u64 data[0]; +}; + +struct ethtool_stats { + __u32 cmd; + __u32 n_stats; + __u64 data[0]; +}; + +struct ethtool_tcpip4_spec { + __be32 ip4src; + __be32 ip4dst; + __be16 psrc; + __be16 pdst; + __u8 tos; +}; + +struct ethtool_ah_espip4_spec { + __be32 ip4src; + __be32 ip4dst; + __be32 spi; + __u8 tos; +}; + +struct ethtool_usrip4_spec { + __be32 ip4src; + __be32 ip4dst; + __be32 l4_4_bytes; + __u8 tos; + __u8 ip_ver; + __u8 proto; +}; + +struct ethtool_tcpip6_spec { + __be32 ip6src[4]; + __be32 ip6dst[4]; + __be16 psrc; + __be16 pdst; + __u8 tclass; +}; + +struct ethtool_ah_espip6_spec { + __be32 ip6src[4]; + __be32 ip6dst[4]; + __be32 spi; + __u8 tclass; +}; + +struct ethtool_usrip6_spec { + __be32 ip6src[4]; + __be32 ip6dst[4]; + __be32 l4_4_bytes; + __u8 tclass; + __u8 l4_proto; +}; + +union ethtool_flow_union { + struct ethtool_tcpip4_spec tcp_ip4_spec; + struct ethtool_tcpip4_spec udp_ip4_spec; + struct ethtool_tcpip4_spec sctp_ip4_spec; + struct ethtool_ah_espip4_spec ah_ip4_spec; + struct ethtool_ah_espip4_spec esp_ip4_spec; + struct ethtool_usrip4_spec usr_ip4_spec; + struct ethtool_tcpip6_spec tcp_ip6_spec; + struct ethtool_tcpip6_spec udp_ip6_spec; + struct ethtool_tcpip6_spec sctp_ip6_spec; + struct ethtool_ah_espip6_spec ah_ip6_spec; + struct ethtool_ah_espip6_spec esp_ip6_spec; + struct ethtool_usrip6_spec usr_ip6_spec; + struct ethhdr ether_spec; + __u8 hdata[52]; +}; + +struct ethtool_flow_ext { + __u8 padding[2]; + unsigned char h_dest[6]; + __be16 vlan_etype; + __be16 vlan_tci; + __be32 data[2]; +}; + +struct ethtool_rx_flow_spec { + __u32 flow_type; + union ethtool_flow_union h_u; + struct ethtool_flow_ext h_ext; + union ethtool_flow_union m_u; + struct ethtool_flow_ext m_ext; + __u64 ring_cookie; + __u32 location; +}; + +struct ethtool_rxnfc { + __u32 cmd; + __u32 flow_type; + __u64 data; + struct ethtool_rx_flow_spec fs; + union { + __u32 rule_cnt; + __u32 rss_context; + }; + __u32 rule_locs[0]; +}; + +struct ethtool_flash { + __u32 cmd; + __u32 region; + char data[128]; +}; + +struct ethtool_dump { + __u32 cmd; + __u32 version; + __u32 flag; + __u32 len; + __u8 data[0]; +}; + +struct ethtool_ts_info { + __u32 cmd; + __u32 so_timestamping; + __s32 phc_index; + __u32 tx_types; + __u32 tx_reserved[3]; + __u32 rx_filters; + __u32 rx_reserved[3]; +}; + +struct ethtool_fecparam { + __u32 cmd; + __u32 active_fec; + __u32 fec; + __u32 reserved; +}; + +struct ethtool_link_settings { + __u32 cmd; + __u32 speed; + __u8 duplex; + __u8 port; + __u8 phy_address; + __u8 autoneg; + __u8 mdio_support; + __u8 eth_tp_mdix; + __u8 eth_tp_mdix_ctrl; + __s8 link_mode_masks_nwords; + __u8 transceiver; + __u8 master_slave_cfg; + __u8 master_slave_state; + __u8 reserved1[1]; + __u32 reserved[7]; + __u32 link_mode_masks[0]; +}; + +enum ethtool_phys_id_state { + ETHTOOL_ID_INACTIVE = 0, + ETHTOOL_ID_ACTIVE = 1, + ETHTOOL_ID_ON = 2, + ETHTOOL_ID_OFF = 3, +}; + +struct ethtool_link_ext_state_info { + enum ethtool_link_ext_state link_ext_state; + union { + enum ethtool_link_ext_substate_autoneg autoneg; + enum ethtool_link_ext_substate_link_training link_training; + enum ethtool_link_ext_substate_link_logical_mismatch link_logical_mismatch; + enum ethtool_link_ext_substate_bad_signal_integrity bad_signal_integrity; + enum ethtool_link_ext_substate_cable_issue cable_issue; + u8 __link_ext_substate; + }; +}; + +struct ethtool_link_ksettings { + struct ethtool_link_settings base; + struct { + long unsigned int supported[2]; + long unsigned int advertising[2]; + long unsigned int lp_advertising[2]; + } link_modes; +}; + +struct ethtool_pause_stats { + u64 tx_pause_frames; + u64 rx_pause_frames; +}; + +struct ethtool_ops { + u32 supported_coalesce_params; + void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *); + int (*get_regs_len)(struct net_device *); + void (*get_regs)(struct net_device *, struct ethtool_regs *, void *); + void (*get_wol)(struct net_device *, struct ethtool_wolinfo *); + int (*set_wol)(struct net_device *, struct ethtool_wolinfo *); + u32 (*get_msglevel)(struct net_device *); + void (*set_msglevel)(struct net_device *, u32); + int (*nway_reset)(struct net_device *); + u32 (*get_link)(struct net_device *); + int (*get_link_ext_state)(struct net_device *, struct ethtool_link_ext_state_info *); + int (*get_eeprom_len)(struct net_device *); + int (*get_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *); + int (*set_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *); + int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *); + int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *); + void (*get_ringparam)(struct net_device *, struct ethtool_ringparam *); + int (*set_ringparam)(struct net_device *, struct ethtool_ringparam *); + void (*get_pause_stats)(struct net_device *, struct ethtool_pause_stats *); + void (*get_pauseparam)(struct net_device *, struct ethtool_pauseparam *); + int (*set_pauseparam)(struct net_device *, struct ethtool_pauseparam *); + void (*self_test)(struct net_device *, struct ethtool_test *, u64 *); + void (*get_strings)(struct net_device *, u32, u8 *); + int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state); + void (*get_ethtool_stats)(struct net_device *, struct ethtool_stats *, u64 *); + int (*begin)(struct net_device *); + void (*complete)(struct net_device *); + u32 (*get_priv_flags)(struct net_device *); + int (*set_priv_flags)(struct net_device *, u32); + int (*get_sset_count)(struct net_device *, int); + int (*get_rxnfc)(struct net_device *, struct ethtool_rxnfc *, u32 *); + int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *); + int (*flash_device)(struct net_device *, struct ethtool_flash *); + int (*reset)(struct net_device *, u32 *); + u32 (*get_rxfh_key_size)(struct net_device *); + u32 (*get_rxfh_indir_size)(struct net_device *); + int (*get_rxfh)(struct net_device *, u32 *, u8 *, u8 *); + int (*set_rxfh)(struct net_device *, const u32 *, const u8 *, const u8); + int (*get_rxfh_context)(struct net_device *, u32 *, u8 *, u8 *, u32); + int (*set_rxfh_context)(struct net_device *, const u32 *, const u8 *, const u8, u32 *, bool); + void (*get_channels)(struct net_device *, struct ethtool_channels *); + int (*set_channels)(struct net_device *, struct ethtool_channels *); + int (*get_dump_flag)(struct net_device *, struct ethtool_dump *); + int (*get_dump_data)(struct net_device *, struct ethtool_dump *, void *); + int (*set_dump)(struct net_device *, struct ethtool_dump *); + int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *); + int (*get_module_info)(struct net_device *, struct ethtool_modinfo *); + int (*get_module_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *); + int (*get_eee)(struct net_device *, struct ethtool_eee *); + int (*set_eee)(struct net_device *, struct ethtool_eee *); + int (*get_tunable)(struct net_device *, const struct ethtool_tunable *, void *); + int (*set_tunable)(struct net_device *, const struct ethtool_tunable *, const void *); + int (*get_per_queue_coalesce)(struct net_device *, u32, struct ethtool_coalesce *); + int (*set_per_queue_coalesce)(struct net_device *, u32, struct ethtool_coalesce *); + int (*get_link_ksettings)(struct net_device *, struct ethtool_link_ksettings *); + int (*set_link_ksettings)(struct net_device *, const struct ethtool_link_ksettings *); + int (*get_fecparam)(struct net_device *, struct ethtool_fecparam *); + int (*set_fecparam)(struct net_device *, struct ethtool_fecparam *); + void (*get_ethtool_phy_stats)(struct net_device *, struct ethtool_stats *, u64 *); + int (*get_phy_tunable)(struct net_device *, const struct ethtool_tunable *, void *); + int (*set_phy_tunable)(struct net_device *, const struct ethtool_tunable *, const void *); +}; + +struct netlink_ext_ack { + const char *_msg; + const struct nlattr *bad_attr; + const struct nla_policy *policy; + u8 cookie[20]; + u8 cookie_len; +}; + +struct ieee_ets { + __u8 willing; + __u8 ets_cap; + __u8 cbs; + __u8 tc_tx_bw[8]; + __u8 tc_rx_bw[8]; + __u8 tc_tsa[8]; + __u8 prio_tc[8]; + __u8 tc_reco_bw[8]; + __u8 tc_reco_tsa[8]; + __u8 reco_prio_tc[8]; +}; + +struct ieee_maxrate { + __u64 tc_maxrate[8]; +}; + +struct ieee_qcn { + __u8 rpg_enable[8]; + __u32 rppp_max_rps[8]; + __u32 rpg_time_reset[8]; + __u32 rpg_byte_reset[8]; + __u32 rpg_threshold[8]; + __u32 rpg_max_rate[8]; + __u32 rpg_ai_rate[8]; + __u32 rpg_hai_rate[8]; + __u32 rpg_gd[8]; + __u32 rpg_min_dec_fac[8]; + __u32 rpg_min_rate[8]; + __u32 cndd_state_machine[8]; +}; + +struct ieee_qcn_stats { + __u64 rppp_rp_centiseconds[8]; + __u32 rppp_created_rps[8]; +}; + +struct ieee_pfc { + __u8 pfc_cap; + __u8 pfc_en; + __u8 mbc; + __u16 delay; + __u64 requests[8]; + __u64 indications[8]; +}; + +struct dcbnl_buffer { + __u8 prio2buffer[8]; + __u32 buffer_size[8]; + __u32 total_size; +}; + +struct cee_pg { + __u8 willing; + __u8 error; + __u8 pg_en; + __u8 tcs_supported; + __u8 pg_bw[8]; + __u8 prio_pg[8]; +}; + +struct cee_pfc { + __u8 willing; + __u8 error; + __u8 pfc_en; + __u8 tcs_supported; +}; + +struct dcb_app { + __u8 selector; + __u8 priority; + __u16 protocol; +}; + +struct dcb_peer_app_info { + __u8 willing; + __u8 error; +}; + +struct dcbnl_rtnl_ops { + int (*ieee_getets)(struct net_device *, struct ieee_ets *); + int (*ieee_setets)(struct net_device *, struct ieee_ets *); + int (*ieee_getmaxrate)(struct net_device *, struct ieee_maxrate *); + int (*ieee_setmaxrate)(struct net_device *, struct ieee_maxrate *); + int (*ieee_getqcn)(struct net_device *, struct ieee_qcn *); + int (*ieee_setqcn)(struct net_device *, struct ieee_qcn *); + int (*ieee_getqcnstats)(struct net_device *, struct ieee_qcn_stats *); + int (*ieee_getpfc)(struct net_device *, struct ieee_pfc *); + int (*ieee_setpfc)(struct net_device *, struct ieee_pfc *); + int (*ieee_getapp)(struct net_device *, struct dcb_app *); + int (*ieee_setapp)(struct net_device *, struct dcb_app *); + int (*ieee_delapp)(struct net_device *, struct dcb_app *); + int (*ieee_peer_getets)(struct net_device *, struct ieee_ets *); + int (*ieee_peer_getpfc)(struct net_device *, struct ieee_pfc *); + u8 (*getstate)(struct net_device *); + u8 (*setstate)(struct net_device *, u8); + void (*getpermhwaddr)(struct net_device *, u8 *); + void (*setpgtccfgtx)(struct net_device *, int, u8, u8, u8, u8); + void (*setpgbwgcfgtx)(struct net_device *, int, u8); + void (*setpgtccfgrx)(struct net_device *, int, u8, u8, u8, u8); + void (*setpgbwgcfgrx)(struct net_device *, int, u8); + void (*getpgtccfgtx)(struct net_device *, int, u8 *, u8 *, u8 *, u8 *); + void (*getpgbwgcfgtx)(struct net_device *, int, u8 *); + void (*getpgtccfgrx)(struct net_device *, int, u8 *, u8 *, u8 *, u8 *); + void (*getpgbwgcfgrx)(struct net_device *, int, u8 *); + void (*setpfccfg)(struct net_device *, int, u8); + void (*getpfccfg)(struct net_device *, int, u8 *); + u8 (*setall)(struct net_device *); + u8 (*getcap)(struct net_device *, int, u8 *); + int (*getnumtcs)(struct net_device *, int, u8 *); + int (*setnumtcs)(struct net_device *, int, u8); + u8 (*getpfcstate)(struct net_device *); + void (*setpfcstate)(struct net_device *, u8); + void (*getbcncfg)(struct net_device *, int, u32 *); + void (*setbcncfg)(struct net_device *, int, u32); + void (*getbcnrp)(struct net_device *, int, u8 *); + void (*setbcnrp)(struct net_device *, int, u8); + int (*setapp)(struct net_device *, u8, u16, u8); + int (*getapp)(struct net_device *, u8, u16); + u8 (*getfeatcfg)(struct net_device *, int, u8 *); + u8 (*setfeatcfg)(struct net_device *, int, u8); + u8 (*getdcbx)(struct net_device *); + u8 (*setdcbx)(struct net_device *, u8); + int (*peer_getappinfo)(struct net_device *, struct dcb_peer_app_info *, u16 *); + int (*peer_getapptable)(struct net_device *, struct dcb_app *); + int (*cee_peer_getpg)(struct net_device *, struct cee_pg *); + int (*cee_peer_getpfc)(struct net_device *, struct cee_pfc *); + int (*dcbnl_getbuffer)(struct net_device *, struct dcbnl_buffer *); + int (*dcbnl_setbuffer)(struct net_device *, struct dcbnl_buffer *); +}; + +struct xdp_mem_info { + u32 type; + u32 id; +}; + +struct xdp_rxq_info { + struct net_device *dev; + u32 queue_index; + u32 reg_state; + struct xdp_mem_info mem; + unsigned int napi_id; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct xdp_frame { + void *data; + u16 len; + u16 headroom; + u32 metasize: 8; + u32 frame_sz: 24; + struct xdp_mem_info mem; + struct net_device *dev_rx; +}; + +struct nlmsghdr { + __u32 nlmsg_len; + __u16 nlmsg_type; + __u16 nlmsg_flags; + __u32 nlmsg_seq; + __u32 nlmsg_pid; +}; + +struct nlattr { + __u16 nla_len; + __u16 nla_type; +}; + +struct netlink_range_validation; + +struct netlink_range_validation_signed; + +struct nla_policy { + u8 type; + u8 validation_type; + u16 len; + union { + const u32 bitfield32_valid; + const u32 mask; + const char *reject_message; + const struct nla_policy *nested_policy; + struct netlink_range_validation *range; + struct netlink_range_validation_signed *range_signed; + struct { + s16 min; + s16 max; + }; + int (*validate)(const struct nlattr *, struct netlink_ext_ack *); + u16 strict_start_type; + }; +}; + +struct netlink_callback { + struct sk_buff *skb; + const struct nlmsghdr *nlh; + int (*dump)(struct sk_buff *, struct netlink_callback *); + int (*done)(struct netlink_callback *); + void *data; + struct module *module; + struct netlink_ext_ack *extack; + u16 family; + u16 answer_flags; + u32 min_dump_alloc; + unsigned int prev_seq; + unsigned int seq; + bool strict_check; + union { + u8 ctx[48]; + long int args[6]; + }; +}; + +struct ndmsg { + __u8 ndm_family; + __u8 ndm_pad1; + __u16 ndm_pad2; + __s32 ndm_ifindex; + __u16 ndm_state; + __u8 ndm_flags; + __u8 ndm_type; +}; + +struct rtnl_link_stats64 { + __u64 rx_packets; + __u64 tx_packets; + __u64 rx_bytes; + __u64 tx_bytes; + __u64 rx_errors; + __u64 tx_errors; + __u64 rx_dropped; + __u64 tx_dropped; + __u64 multicast; + __u64 collisions; + __u64 rx_length_errors; + __u64 rx_over_errors; + __u64 rx_crc_errors; + __u64 rx_frame_errors; + __u64 rx_fifo_errors; + __u64 rx_missed_errors; + __u64 tx_aborted_errors; + __u64 tx_carrier_errors; + __u64 tx_fifo_errors; + __u64 tx_heartbeat_errors; + __u64 tx_window_errors; + __u64 rx_compressed; + __u64 tx_compressed; + __u64 rx_nohandler; +}; + +struct ifla_vf_guid { + __u32 vf; + __u64 guid; +}; + +struct ifla_vf_stats { + __u64 rx_packets; + __u64 tx_packets; + __u64 rx_bytes; + __u64 tx_bytes; + __u64 broadcast; + __u64 multicast; + __u64 rx_dropped; + __u64 tx_dropped; +}; + +struct ifla_vf_info { + __u32 vf; + __u8 mac[32]; + __u32 vlan; + __u32 qos; + __u32 spoofchk; + __u32 linkstate; + __u32 min_tx_rate; + __u32 max_tx_rate; + __u32 rss_query_en; + __u32 trusted; + __be16 vlan_proto; +}; + +struct tc_stats { + __u64 bytes; + __u32 packets; + __u32 drops; + __u32 overlimits; + __u32 bps; + __u32 pps; + __u32 qlen; + __u32 backlog; +}; + +struct tc_sizespec { + unsigned char cell_log; + unsigned char size_log; + short int cell_align; + int overhead; + unsigned int linklayer; + unsigned int mpu; + unsigned int mtu; + unsigned int tsize; +}; + +enum netdev_tx { + __NETDEV_TX_MIN = 2147483648, + NETDEV_TX_OK = 0, + NETDEV_TX_BUSY = 16, +}; + +typedef enum netdev_tx netdev_tx_t; + +struct header_ops { + int (*create)(struct sk_buff *, struct net_device *, short unsigned int, const void *, const void *, unsigned int); + int (*parse)(const struct sk_buff *, unsigned char *); + int (*cache)(const struct neighbour *, struct hh_cache *, __be16); + void (*cache_update)(struct hh_cache *, const struct net_device *, const unsigned char *); + bool (*validate)(const char *, unsigned int); + __be16 (*parse_protocol)(const struct sk_buff *); +}; + +struct xsk_buff_pool; + +struct netdev_queue { + struct net_device *dev; + struct Qdisc *qdisc; + struct Qdisc *qdisc_sleeping; + struct kobject kobj; + int numa_node; + long unsigned int tx_maxrate; + long unsigned int trans_timeout; + struct net_device *sb_dev; + struct xsk_buff_pool *pool; + spinlock_t _xmit_lock; + int xmit_lock_owner; + long unsigned int trans_start; + long unsigned int state; + long: 64; + long: 64; + struct dql dql; +}; + +struct net_rate_estimator; + +struct qdisc_skb_head { + struct sk_buff *head; + struct sk_buff *tail; + __u32 qlen; + spinlock_t lock; +}; + +struct gnet_stats_basic_packed { + __u64 bytes; + __u64 packets; +}; + +struct gnet_stats_queue { + __u32 qlen; + __u32 backlog; + __u32 drops; + __u32 requeues; + __u32 overlimits; +}; + +struct Qdisc_ops; + +struct qdisc_size_table; + +struct gnet_stats_basic_cpu; + +struct Qdisc { + int (*enqueue)(struct sk_buff *, struct Qdisc *, struct sk_buff **); + struct sk_buff * (*dequeue)(struct Qdisc *); + unsigned int flags; + u32 limit; + const struct Qdisc_ops *ops; + struct qdisc_size_table *stab; + struct hlist_node hash; + u32 handle; + u32 parent; + struct netdev_queue *dev_queue; + struct net_rate_estimator *rate_est; + struct gnet_stats_basic_cpu *cpu_bstats; + struct gnet_stats_queue *cpu_qstats; + int pad; + refcount_t refcnt; + long: 64; + long: 64; + long: 64; + struct sk_buff_head gso_skb; + struct qdisc_skb_head q; + struct gnet_stats_basic_packed bstats; + seqcount_t running; + struct gnet_stats_queue qstats; + long unsigned int state; + struct Qdisc *next_sched; + struct sk_buff_head skb_bad_txq; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + spinlock_t busylock; + spinlock_t seqlock; + bool empty; + struct callback_head rcu; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long int privdata[0]; +}; + +struct rps_map { + unsigned int len; + struct callback_head rcu; + u16 cpus[0]; +}; + +struct rps_dev_flow { + u16 cpu; + u16 filter; + unsigned int last_qtail; +}; + +struct rps_dev_flow_table { + unsigned int mask; + struct callback_head rcu; + struct rps_dev_flow flows[0]; +}; + +struct netdev_rx_queue { + struct rps_map *rps_map; + struct rps_dev_flow_table *rps_flow_table; + struct kobject kobj; + struct net_device *dev; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct xdp_rxq_info xdp_rxq; + struct xsk_buff_pool *pool; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct xps_map { + unsigned int len; + unsigned int alloc_len; + struct callback_head rcu; + u16 queues[0]; +}; + +struct xps_dev_maps { + struct callback_head rcu; + struct xps_map *attr_map[0]; +}; + +struct netdev_phys_item_id { + unsigned char id[32]; + unsigned char id_len; +}; + +enum tc_setup_type { + TC_SETUP_QDISC_MQPRIO = 0, + TC_SETUP_CLSU32 = 1, + TC_SETUP_CLSFLOWER = 2, + TC_SETUP_CLSMATCHALL = 3, + TC_SETUP_CLSBPF = 4, + TC_SETUP_BLOCK = 5, + TC_SETUP_QDISC_CBS = 6, + TC_SETUP_QDISC_RED = 7, + TC_SETUP_QDISC_PRIO = 8, + TC_SETUP_QDISC_MQ = 9, + TC_SETUP_QDISC_ETF = 10, + TC_SETUP_ROOT_QDISC = 11, + TC_SETUP_QDISC_GRED = 12, + TC_SETUP_QDISC_TAPRIO = 13, + TC_SETUP_FT = 14, + TC_SETUP_QDISC_ETS = 15, + TC_SETUP_QDISC_TBF = 16, + TC_SETUP_QDISC_FIFO = 17, +}; + +enum bpf_netdev_command { + XDP_SETUP_PROG = 0, + XDP_SETUP_PROG_HW = 1, + BPF_OFFLOAD_MAP_ALLOC = 2, + BPF_OFFLOAD_MAP_FREE = 3, + XDP_SETUP_XSK_POOL = 4, +}; + +struct netdev_bpf { + enum bpf_netdev_command command; + union { + struct { + u32 flags; + struct bpf_prog *prog; + struct netlink_ext_ack *extack; + }; + struct { + struct bpf_offloaded_map *offmap; + }; + struct { + struct xsk_buff_pool *pool; + u16 queue_id; + } xsk; + }; +}; + +struct dev_ifalias { + struct callback_head rcuhead; + char ifalias[0]; +}; + +struct netdev_name_node { + struct hlist_node hlist; + struct list_head list; + struct net_device *dev; + const char *name; +}; + +struct udp_tunnel_info; + +struct devlink_port; + +struct ip_tunnel_parm; + +struct net_device_ops { + int (*ndo_init)(struct net_device *); + void (*ndo_uninit)(struct net_device *); + int (*ndo_open)(struct net_device *); + int (*ndo_stop)(struct net_device *); + netdev_tx_t (*ndo_start_xmit)(struct sk_buff *, struct net_device *); + netdev_features_t (*ndo_features_check)(struct sk_buff *, struct net_device *, netdev_features_t); + u16 (*ndo_select_queue)(struct net_device *, struct sk_buff *, struct net_device *); + void (*ndo_change_rx_flags)(struct net_device *, int); + void (*ndo_set_rx_mode)(struct net_device *); + int (*ndo_set_mac_address)(struct net_device *, void *); + int (*ndo_validate_addr)(struct net_device *); + int (*ndo_do_ioctl)(struct net_device *, struct ifreq *, int); + int (*ndo_set_config)(struct net_device *, struct ifmap *); + int (*ndo_change_mtu)(struct net_device *, int); + int (*ndo_neigh_setup)(struct net_device *, struct neigh_parms *); + void (*ndo_tx_timeout)(struct net_device *, unsigned int); + void (*ndo_get_stats64)(struct net_device *, struct rtnl_link_stats64 *); + bool (*ndo_has_offload_stats)(const struct net_device *, int); + int (*ndo_get_offload_stats)(int, const struct net_device *, void *); + struct net_device_stats * (*ndo_get_stats)(struct net_device *); + int (*ndo_vlan_rx_add_vid)(struct net_device *, __be16, u16); + int (*ndo_vlan_rx_kill_vid)(struct net_device *, __be16, u16); + void (*ndo_poll_controller)(struct net_device *); + int (*ndo_netpoll_setup)(struct net_device *, struct netpoll_info *); + void (*ndo_netpoll_cleanup)(struct net_device *); + int (*ndo_set_vf_mac)(struct net_device *, int, u8 *); + int (*ndo_set_vf_vlan)(struct net_device *, int, u16, u8, __be16); + int (*ndo_set_vf_rate)(struct net_device *, int, int, int); + int (*ndo_set_vf_spoofchk)(struct net_device *, int, bool); + int (*ndo_set_vf_trust)(struct net_device *, int, bool); + int (*ndo_get_vf_config)(struct net_device *, int, struct ifla_vf_info *); + int (*ndo_set_vf_link_state)(struct net_device *, int, int); + int (*ndo_get_vf_stats)(struct net_device *, int, struct ifla_vf_stats *); + int (*ndo_set_vf_port)(struct net_device *, int, struct nlattr **); + int (*ndo_get_vf_port)(struct net_device *, int, struct sk_buff *); + int (*ndo_get_vf_guid)(struct net_device *, int, struct ifla_vf_guid *, struct ifla_vf_guid *); + int (*ndo_set_vf_guid)(struct net_device *, int, u64, int); + int (*ndo_set_vf_rss_query_en)(struct net_device *, int, bool); + int (*ndo_setup_tc)(struct net_device *, enum tc_setup_type, void *); + int (*ndo_rx_flow_steer)(struct net_device *, const struct sk_buff *, u16, u32); + int (*ndo_add_slave)(struct net_device *, struct net_device *, struct netlink_ext_ack *); + int (*ndo_del_slave)(struct net_device *, struct net_device *); + struct net_device * (*ndo_get_xmit_slave)(struct net_device *, struct sk_buff *, bool); + netdev_features_t (*ndo_fix_features)(struct net_device *, netdev_features_t); + int (*ndo_set_features)(struct net_device *, netdev_features_t); + int (*ndo_neigh_construct)(struct net_device *, struct neighbour *); + void (*ndo_neigh_destroy)(struct net_device *, struct neighbour *); + int (*ndo_fdb_add)(struct ndmsg *, struct nlattr **, struct net_device *, const unsigned char *, u16, u16, struct netlink_ext_ack *); + int (*ndo_fdb_del)(struct ndmsg *, struct nlattr **, struct net_device *, const unsigned char *, u16); + int (*ndo_fdb_dump)(struct sk_buff *, struct netlink_callback *, struct net_device *, struct net_device *, int *); + int (*ndo_fdb_get)(struct sk_buff *, struct nlattr **, struct net_device *, const unsigned char *, u16, u32, u32, struct netlink_ext_ack *); + int (*ndo_bridge_setlink)(struct net_device *, struct nlmsghdr *, u16, struct netlink_ext_ack *); + int (*ndo_bridge_getlink)(struct sk_buff *, u32, u32, struct net_device *, u32, int); + int (*ndo_bridge_dellink)(struct net_device *, struct nlmsghdr *, u16); + int (*ndo_change_carrier)(struct net_device *, bool); + int (*ndo_get_phys_port_id)(struct net_device *, struct netdev_phys_item_id *); + int (*ndo_get_port_parent_id)(struct net_device *, struct netdev_phys_item_id *); + int (*ndo_get_phys_port_name)(struct net_device *, char *, size_t); + void (*ndo_udp_tunnel_add)(struct net_device *, struct udp_tunnel_info *); + void (*ndo_udp_tunnel_del)(struct net_device *, struct udp_tunnel_info *); + void * (*ndo_dfwd_add_station)(struct net_device *, struct net_device *); + void (*ndo_dfwd_del_station)(struct net_device *, void *); + int (*ndo_set_tx_maxrate)(struct net_device *, int, u32); + int (*ndo_get_iflink)(const struct net_device *); + int (*ndo_change_proto_down)(struct net_device *, bool); + int (*ndo_fill_metadata_dst)(struct net_device *, struct sk_buff *); + void (*ndo_set_rx_headroom)(struct net_device *, int); + int (*ndo_bpf)(struct net_device *, struct netdev_bpf *); + int (*ndo_xdp_xmit)(struct net_device *, int, struct xdp_frame **, u32); + int (*ndo_xsk_wakeup)(struct net_device *, u32, u32); + struct devlink_port * (*ndo_get_devlink_port)(struct net_device *); + int (*ndo_tunnel_ctl)(struct net_device *, struct ip_tunnel_parm *, int); + struct net_device * (*ndo_get_peer_dev)(struct net_device *); +}; + +struct neigh_parms { + possible_net_t net; + struct net_device *dev; + struct list_head list; + int (*neigh_setup)(struct neighbour *); + struct neigh_table *tbl; + void *sysctl_table; + int dead; + refcount_t refcnt; + struct callback_head callback_head; + int reachable_time; + int data[13]; + long unsigned int data_state[1]; +}; + +struct pcpu_lstats { + u64_stats_t packets; + u64_stats_t bytes; + struct u64_stats_sync syncp; +}; + +struct pcpu_sw_netstats { + u64 rx_packets; + u64 rx_bytes; + u64 tx_packets; + u64 tx_bytes; + struct u64_stats_sync syncp; +}; + +struct nd_opt_hdr; + +struct ndisc_options; + +struct prefix_info; + +struct ndisc_ops { + int (*is_useropt)(u8); + int (*parse_options)(const struct net_device *, struct nd_opt_hdr *, struct ndisc_options *); + void (*update)(const struct net_device *, struct neighbour *, u32, u8, const struct ndisc_options *); + int (*opt_addr_space)(const struct net_device *, u8, struct neighbour *, u8 *, u8 **); + void (*fill_addr_option)(const struct net_device *, struct sk_buff *, u8, const u8 *); + void (*prefix_rcv_add_addr)(struct net *, struct net_device *, const struct prefix_info *, struct inet6_dev *, struct in6_addr *, int, u32, bool, bool, __u32, u32, bool); +}; + +struct ipv6_devstat { + struct proc_dir_entry *proc_dir_entry; + struct ipstats_mib *ipv6; + struct icmpv6_mib_device *icmpv6dev; + struct icmpv6msg_mib_device *icmpv6msgdev; +}; + +struct ifmcaddr6; + +struct ifacaddr6; + +struct inet6_dev { + struct net_device *dev; + struct list_head addr_list; + struct ifmcaddr6 *mc_list; + struct ifmcaddr6 *mc_tomb; + spinlock_t mc_lock; + unsigned char mc_qrv; + unsigned char mc_gq_running; + unsigned char mc_ifc_count; + unsigned char mc_dad_count; + long unsigned int mc_v1_seen; + long unsigned int mc_qi; + long unsigned int mc_qri; + long unsigned int mc_maxdelay; + struct timer_list mc_gq_timer; + struct timer_list mc_ifc_timer; + struct timer_list mc_dad_timer; + struct ifacaddr6 *ac_list; + rwlock_t lock; + refcount_t refcnt; + __u32 if_flags; + int dead; + u32 desync_factor; + struct list_head tempaddr_list; + struct in6_addr token; + struct neigh_parms *nd_parms; + struct ipv6_devconf cnf; + struct ipv6_devstat stats; + struct timer_list rs_timer; + __s32 rs_interval; + __u8 rs_probes; + long unsigned int tstamp; + struct callback_head rcu; +}; + +struct tcf_proto; + +struct tcf_block; + +struct mini_Qdisc { + struct tcf_proto *filter_list; + struct tcf_block *block; + struct gnet_stats_basic_cpu *cpu_bstats; + struct gnet_stats_queue *cpu_qstats; + struct callback_head rcu; +}; + +struct rtnl_link_ops { + struct list_head list; + const char *kind; + size_t priv_size; + void (*setup)(struct net_device *); + unsigned int maxtype; + const struct nla_policy *policy; + int (*validate)(struct nlattr **, struct nlattr **, struct netlink_ext_ack *); + int (*newlink)(struct net *, struct net_device *, struct nlattr **, struct nlattr **, struct netlink_ext_ack *); + int (*changelink)(struct net_device *, struct nlattr **, struct nlattr **, struct netlink_ext_ack *); + void (*dellink)(struct net_device *, struct list_head *); + size_t (*get_size)(const struct net_device *); + int (*fill_info)(struct sk_buff *, const struct net_device *); + size_t (*get_xstats_size)(const struct net_device *); + int (*fill_xstats)(struct sk_buff *, const struct net_device *); + unsigned int (*get_num_tx_queues)(); + unsigned int (*get_num_rx_queues)(); + unsigned int slave_maxtype; + const struct nla_policy *slave_policy; + int (*slave_changelink)(struct net_device *, struct net_device *, struct nlattr **, struct nlattr **, struct netlink_ext_ack *); + size_t (*get_slave_size)(const struct net_device *, const struct net_device *); + int (*fill_slave_info)(struct sk_buff *, const struct net_device *, const struct net_device *); + struct net * (*get_link_net)(const struct net_device *); + size_t (*get_linkxstats_size)(const struct net_device *, int); + int (*fill_linkxstats)(struct sk_buff *, const struct net_device *, int *, int); +}; + +struct udp_tunnel_nic_table_info { + unsigned int n_entries; + unsigned int tunnel_types; +}; + +struct udp_tunnel_nic_shared; + +struct udp_tunnel_nic_info { + int (*set_port)(struct net_device *, unsigned int, unsigned int, struct udp_tunnel_info *); + int (*unset_port)(struct net_device *, unsigned int, unsigned int, struct udp_tunnel_info *); + int (*sync_table)(struct net_device *, unsigned int); + struct udp_tunnel_nic_shared *shared; + unsigned int flags; + struct udp_tunnel_nic_table_info tables[4]; +}; + +enum { + RTAX_UNSPEC = 0, + RTAX_LOCK = 1, + RTAX_MTU = 2, + RTAX_WINDOW = 3, + RTAX_RTT = 4, + RTAX_RTTVAR = 5, + RTAX_SSTHRESH = 6, + RTAX_CWND = 7, + RTAX_ADVMSS = 8, + RTAX_REORDERING = 9, + RTAX_HOPLIMIT = 10, + RTAX_INITCWND = 11, + RTAX_FEATURES = 12, + RTAX_RTO_MIN = 13, + RTAX_INITRWND = 14, + RTAX_QUICKACK = 15, + RTAX_CC_ALGO = 16, + RTAX_FASTOPEN_NO_COOKIE = 17, + __RTAX_MAX = 18, +}; + +struct tcmsg { + unsigned char tcm_family; + unsigned char tcm__pad1; + short unsigned int tcm__pad2; + int tcm_ifindex; + __u32 tcm_handle; + __u32 tcm_parent; + __u32 tcm_info; +}; + +struct gnet_stats_basic_cpu { + struct gnet_stats_basic_packed bstats; + struct u64_stats_sync syncp; +}; + +struct gnet_dump { + spinlock_t *lock; + struct sk_buff *skb; + struct nlattr *tail; + int compat_tc_stats; + int compat_xstats; + int padattr; + void *xstats; + int xstats_len; + struct tc_stats tc_stats; +}; + +struct netlink_range_validation { + u64 min; + u64 max; +}; + +struct netlink_range_validation_signed { + s64 min; + s64 max; +}; + +enum flow_action_hw_stats_bit { + FLOW_ACTION_HW_STATS_IMMEDIATE_BIT = 0, + FLOW_ACTION_HW_STATS_DELAYED_BIT = 1, + FLOW_ACTION_HW_STATS_DISABLED_BIT = 2, + FLOW_ACTION_HW_STATS_NUM_BITS = 3, +}; + +struct flow_block { + struct list_head cb_list; +}; + +typedef int flow_setup_cb_t(enum tc_setup_type, void *, void *); + +struct qdisc_size_table { + struct callback_head rcu; + struct list_head list; + struct tc_sizespec szopts; + int refcnt; + u16 data[0]; +}; + +struct Qdisc_class_ops; + +struct Qdisc_ops { + struct Qdisc_ops *next; + const struct Qdisc_class_ops *cl_ops; + char id[16]; + int priv_size; + unsigned int static_flags; + int (*enqueue)(struct sk_buff *, struct Qdisc *, struct sk_buff **); + struct sk_buff * (*dequeue)(struct Qdisc *); + struct sk_buff * (*peek)(struct Qdisc *); + int (*init)(struct Qdisc *, struct nlattr *, struct netlink_ext_ack *); + void (*reset)(struct Qdisc *); + void (*destroy)(struct Qdisc *); + int (*change)(struct Qdisc *, struct nlattr *, struct netlink_ext_ack *); + void (*attach)(struct Qdisc *); + int (*change_tx_queue_len)(struct Qdisc *, unsigned int); + int (*dump)(struct Qdisc *, struct sk_buff *); + int (*dump_stats)(struct Qdisc *, struct gnet_dump *); + void (*ingress_block_set)(struct Qdisc *, u32); + void (*egress_block_set)(struct Qdisc *, u32); + u32 (*ingress_block_get)(struct Qdisc *); + u32 (*egress_block_get)(struct Qdisc *); + struct module *owner; +}; + +struct qdisc_walker; + +struct Qdisc_class_ops { + unsigned int flags; + struct netdev_queue * (*select_queue)(struct Qdisc *, struct tcmsg *); + int (*graft)(struct Qdisc *, long unsigned int, struct Qdisc *, struct Qdisc **, struct netlink_ext_ack *); + struct Qdisc * (*leaf)(struct Qdisc *, long unsigned int); + void (*qlen_notify)(struct Qdisc *, long unsigned int); + long unsigned int (*find)(struct Qdisc *, u32); + int (*change)(struct Qdisc *, u32, u32, struct nlattr **, long unsigned int *, struct netlink_ext_ack *); + int (*delete)(struct Qdisc *, long unsigned int); + void (*walk)(struct Qdisc *, struct qdisc_walker *); + struct tcf_block * (*tcf_block)(struct Qdisc *, long unsigned int, struct netlink_ext_ack *); + long unsigned int (*bind_tcf)(struct Qdisc *, long unsigned int, u32); + void (*unbind_tcf)(struct Qdisc *, long unsigned int); + int (*dump)(struct Qdisc *, long unsigned int, struct sk_buff *, struct tcmsg *); + int (*dump_stats)(struct Qdisc *, long unsigned int, struct gnet_dump *); +}; + +struct tcf_chain; + +struct tcf_block { + struct mutex lock; + struct list_head chain_list; + u32 index; + u32 classid; + refcount_t refcnt; + struct net *net; + struct Qdisc *q; + struct rw_semaphore cb_lock; + struct flow_block flow_block; + struct list_head owner_list; + bool keep_dst; + atomic_t offloadcnt; + unsigned int nooffloaddevcnt; + unsigned int lockeddevcnt; + struct { + struct tcf_chain *chain; + struct list_head filter_chain_list; + } chain0; + struct callback_head rcu; + struct hlist_head proto_destroy_ht[128]; + struct mutex proto_destroy_lock; +}; + +struct tcf_result; + +struct tcf_proto_ops; + +struct tcf_proto { + struct tcf_proto *next; + void *root; + int (*classify)(struct sk_buff *, const struct tcf_proto *, struct tcf_result *); + __be16 protocol; + u32 prio; + void *data; + const struct tcf_proto_ops *ops; + struct tcf_chain *chain; + spinlock_t lock; + bool deleting; + refcount_t refcnt; + struct callback_head rcu; + struct hlist_node destroy_ht_node; +}; + +struct tcf_result { + union { + struct { + long unsigned int class; + u32 classid; + }; + const struct tcf_proto *goto_tp; + struct { + bool ingress; + struct gnet_stats_queue *qstats; + }; + }; +}; + +struct tcf_walker; + +struct tcf_proto_ops { + struct list_head head; + char kind[16]; + int (*classify)(struct sk_buff *, const struct tcf_proto *, struct tcf_result *); + int (*init)(struct tcf_proto *); + void (*destroy)(struct tcf_proto *, bool, struct netlink_ext_ack *); + void * (*get)(struct tcf_proto *, u32); + void (*put)(struct tcf_proto *, void *); + int (*change)(struct net *, struct sk_buff *, struct tcf_proto *, long unsigned int, u32, struct nlattr **, void **, bool, bool, struct netlink_ext_ack *); + int (*delete)(struct tcf_proto *, void *, bool *, bool, struct netlink_ext_ack *); + bool (*delete_empty)(struct tcf_proto *); + void (*walk)(struct tcf_proto *, struct tcf_walker *, bool); + int (*reoffload)(struct tcf_proto *, bool, flow_setup_cb_t *, void *, struct netlink_ext_ack *); + void (*hw_add)(struct tcf_proto *, void *); + void (*hw_del)(struct tcf_proto *, void *); + void (*bind_class)(void *, u32, long unsigned int, void *, long unsigned int); + void * (*tmplt_create)(struct net *, struct tcf_chain *, struct nlattr **, struct netlink_ext_ack *); + void (*tmplt_destroy)(void *); + int (*dump)(struct net *, struct tcf_proto *, void *, struct sk_buff *, struct tcmsg *, bool); + int (*terse_dump)(struct net *, struct tcf_proto *, void *, struct sk_buff *, struct tcmsg *, bool); + int (*tmplt_dump)(struct sk_buff *, struct net *, void *); + struct module *owner; + int flags; +}; + +struct tcf_chain { + struct mutex filter_chain_lock; + struct tcf_proto *filter_chain; + struct list_head list; + struct tcf_block *block; + u32 index; + unsigned int refcnt; + unsigned int action_refcnt; + bool explicitly_created; + bool flushing; + const struct tcf_proto_ops *tmplt_ops; + void *tmplt_priv; + struct callback_head rcu; +}; + +struct sock_fprog_kern { + u16 len; + struct sock_filter *filter; +}; + +struct sk_filter { + refcount_t refcnt; + struct callback_head rcu; + struct bpf_prog *prog; +}; + +enum { + NEIGH_VAR_MCAST_PROBES = 0, + NEIGH_VAR_UCAST_PROBES = 1, + NEIGH_VAR_APP_PROBES = 2, + NEIGH_VAR_MCAST_REPROBES = 3, + NEIGH_VAR_RETRANS_TIME = 4, + NEIGH_VAR_BASE_REACHABLE_TIME = 5, + NEIGH_VAR_DELAY_PROBE_TIME = 6, + NEIGH_VAR_GC_STALETIME = 7, + NEIGH_VAR_QUEUE_LEN_BYTES = 8, + NEIGH_VAR_PROXY_QLEN = 9, + NEIGH_VAR_ANYCAST_DELAY = 10, + NEIGH_VAR_PROXY_DELAY = 11, + NEIGH_VAR_LOCKTIME = 12, + NEIGH_VAR_QUEUE_LEN = 13, + NEIGH_VAR_RETRANS_TIME_MS = 14, + NEIGH_VAR_BASE_REACHABLE_TIME_MS = 15, + NEIGH_VAR_GC_INTERVAL = 16, + NEIGH_VAR_GC_THRESH1 = 17, + NEIGH_VAR_GC_THRESH2 = 18, + NEIGH_VAR_GC_THRESH3 = 19, + NEIGH_VAR_MAX = 20, +}; + +struct pneigh_entry; + +struct neigh_statistics; + +struct neigh_hash_table; + +struct neigh_table { + int family; + unsigned int entry_size; + unsigned int key_len; + __be16 protocol; + __u32 (*hash)(const void *, const struct net_device *, __u32 *); + bool (*key_eq)(const struct neighbour *, const void *); + int (*constructor)(struct neighbour *); + int (*pconstructor)(struct pneigh_entry *); + void (*pdestructor)(struct pneigh_entry *); + void (*proxy_redo)(struct sk_buff *); + bool (*allow_add)(const struct net_device *, struct netlink_ext_ack *); + char *id; + struct neigh_parms parms; + struct list_head parms_list; + int gc_interval; + int gc_thresh1; + int gc_thresh2; + int gc_thresh3; + long unsigned int last_flush; + struct delayed_work gc_work; + struct timer_list proxy_timer; + struct sk_buff_head proxy_queue; + atomic_t entries; + atomic_t gc_entries; + struct list_head gc_list; + rwlock_t lock; + long unsigned int last_rand; + struct neigh_statistics *stats; + struct neigh_hash_table *nht; + struct pneigh_entry **phash_buckets; +}; + +struct neigh_statistics { + long unsigned int allocs; + long unsigned int destroys; + long unsigned int hash_grows; + long unsigned int res_failed; + long unsigned int lookups; + long unsigned int hits; + long unsigned int rcv_probes_mcast; + long unsigned int rcv_probes_ucast; + long unsigned int periodic_gc_runs; + long unsigned int forced_gc_runs; + long unsigned int unres_discards; + long unsigned int table_fulls; +}; + +struct neigh_ops { + int family; + void (*solicit)(struct neighbour *, struct sk_buff *); + void (*error_report)(struct neighbour *, struct sk_buff *); + int (*output)(struct neighbour *, struct sk_buff *); + int (*connected_output)(struct neighbour *, struct sk_buff *); +}; + +struct pneigh_entry { + struct pneigh_entry *next; + possible_net_t net; + struct net_device *dev; + u8 flags; + u8 protocol; + u8 key[0]; +}; + +struct neigh_hash_table { + struct neighbour **hash_buckets; + unsigned int hash_shift; + __u32 hash_rnd[4]; + struct callback_head rcu; +}; + +enum { + TCP_ESTABLISHED = 1, + TCP_SYN_SENT = 2, + TCP_SYN_RECV = 3, + TCP_FIN_WAIT1 = 4, + TCP_FIN_WAIT2 = 5, + TCP_TIME_WAIT = 6, + TCP_CLOSE = 7, + TCP_CLOSE_WAIT = 8, + TCP_LAST_ACK = 9, + TCP_LISTEN = 10, + TCP_CLOSING = 11, + TCP_NEW_SYN_RECV = 12, + TCP_MAX_STATES = 13, +}; + +struct fib_rule_hdr { + __u8 family; + __u8 dst_len; + __u8 src_len; + __u8 tos; + __u8 table; + __u8 res1; + __u8 res2; + __u8 action; + __u32 flags; +}; + +struct fib_rule_port_range { + __u16 start; + __u16 end; +}; + +struct fib_kuid_range { + kuid_t start; + kuid_t end; +}; + +struct fib_rule { + struct list_head list; + int iifindex; + int oifindex; + u32 mark; + u32 mark_mask; + u32 flags; + u32 table; + u8 action; + u8 l3mdev; + u8 proto; + u8 ip_proto; + u32 target; + __be64 tun_id; + struct fib_rule *ctarget; + struct net *fr_net; + refcount_t refcnt; + u32 pref; + int suppress_ifgroup; + int suppress_prefixlen; + char iifname[16]; + char oifname[16]; + struct fib_kuid_range uid_range; + struct fib_rule_port_range sport_range; + struct fib_rule_port_range dport_range; + struct callback_head rcu; +}; + +struct fib_lookup_arg { + void *lookup_ptr; + const void *lookup_data; + void *result; + struct fib_rule *rule; + u32 table; + int flags; +}; + +struct smc_hashinfo; + +struct request_sock_ops; + +struct timewait_sock_ops; + +struct udp_table; + +struct raw_hashinfo; + +struct proto { + void (*close)(struct sock *, long int); + int (*pre_connect)(struct sock *, struct sockaddr *, int); + int (*connect)(struct sock *, struct sockaddr *, int); + int (*disconnect)(struct sock *, int); + struct sock * (*accept)(struct sock *, int, int *, bool); + int (*ioctl)(struct sock *, int, long unsigned int); + int (*init)(struct sock *); + void (*destroy)(struct sock *); + void (*shutdown)(struct sock *, int); + int (*setsockopt)(struct sock *, int, int, sockptr_t, unsigned int); + int (*getsockopt)(struct sock *, int, int, char *, int *); + void (*keepalive)(struct sock *, int); + int (*compat_ioctl)(struct sock *, unsigned int, long unsigned int); + int (*sendmsg)(struct sock *, struct msghdr *, size_t); + int (*recvmsg)(struct sock *, struct msghdr *, size_t, int, int, int *); + int (*sendpage)(struct sock *, struct page *, int, size_t, int); + int (*bind)(struct sock *, struct sockaddr *, int); + int (*bind_add)(struct sock *, struct sockaddr *, int); + int (*backlog_rcv)(struct sock *, struct sk_buff *); + void (*release_cb)(struct sock *); + int (*hash)(struct sock *); + void (*unhash)(struct sock *); + void (*rehash)(struct sock *); + int (*get_port)(struct sock *, short unsigned int); + unsigned int inuse_idx; + bool (*stream_memory_free)(const struct sock *, int); + bool (*stream_memory_read)(const struct sock *); + void (*enter_memory_pressure)(struct sock *); + void (*leave_memory_pressure)(struct sock *); + atomic_long_t *memory_allocated; + struct percpu_counter *sockets_allocated; + long unsigned int *memory_pressure; + long int *sysctl_mem; + int *sysctl_wmem; + int *sysctl_rmem; + u32 sysctl_wmem_offset; + u32 sysctl_rmem_offset; + int max_header; + bool no_autobind; + struct kmem_cache *slab; + unsigned int obj_size; + slab_flags_t slab_flags; + unsigned int useroffset; + unsigned int usersize; + struct percpu_counter *orphan_count; + struct request_sock_ops *rsk_prot; + struct timewait_sock_ops *twsk_prot; + union { + struct inet_hashinfo *hashinfo; + struct udp_table *udp_table; + struct raw_hashinfo *raw_hash; + struct smc_hashinfo *smc_hash; + } h; + struct module *owner; + char name[32]; + struct list_head node; + int (*diag_destroy)(struct sock *, int); +}; + +struct request_sock; + +struct request_sock_ops { + int family; + unsigned int obj_size; + struct kmem_cache *slab; + char *slab_name; + int (*rtx_syn_ack)(const struct sock *, struct request_sock *); + void (*send_ack)(const struct sock *, struct sk_buff *, struct request_sock *); + void (*send_reset)(const struct sock *, struct sk_buff *); + void (*destructor)(struct request_sock *); + void (*syn_ack_timeout)(const struct request_sock *); +}; + +struct timewait_sock_ops { + struct kmem_cache *twsk_slab; + char *twsk_slab_name; + unsigned int twsk_obj_size; + int (*twsk_unique)(struct sock *, struct sock *, void *); + void (*twsk_destructor)(struct sock *); +}; + +struct saved_syn; + +struct request_sock { + struct sock_common __req_common; + struct request_sock *dl_next; + u16 mss; + u8 num_retrans; + u8 syncookie: 1; + u8 num_timeout: 7; + u32 ts_recent; + struct timer_list rsk_timer; + const struct request_sock_ops *rsk_ops; + struct sock *sk; + struct saved_syn *saved_syn; + u32 secid; + u32 peer_secid; +}; + +struct saved_syn { + u32 mac_hdrlen; + u32 network_hdrlen; + u32 tcp_hdrlen; + u8 data[0]; +}; + +enum tsq_enum { + TSQ_THROTTLED = 0, + TSQ_QUEUED = 1, + TCP_TSQ_DEFERRED = 2, + TCP_WRITE_TIMER_DEFERRED = 3, + TCP_DELACK_TIMER_DEFERRED = 4, + TCP_MTU_REDUCED_DEFERRED = 5, +}; + +struct ip6_sf_list { + struct ip6_sf_list *sf_next; + struct in6_addr sf_addr; + long unsigned int sf_count[2]; + unsigned char sf_gsresp; + unsigned char sf_oldin; + unsigned char sf_crcount; +}; + +struct ifmcaddr6 { + struct in6_addr mca_addr; + struct inet6_dev *idev; + struct ifmcaddr6 *next; + struct ip6_sf_list *mca_sources; + struct ip6_sf_list *mca_tomb; + unsigned int mca_sfmode; + unsigned char mca_crcount; + long unsigned int mca_sfcount[2]; + struct timer_list mca_timer; + unsigned int mca_flags; + int mca_users; + refcount_t mca_refcnt; + spinlock_t mca_lock; + long unsigned int mca_cstamp; + long unsigned int mca_tstamp; +}; + +struct ifacaddr6 { + struct in6_addr aca_addr; + struct fib6_info *aca_rt; + struct ifacaddr6 *aca_next; + struct hlist_node aca_addr_lst; + int aca_users; + refcount_t aca_refcnt; + long unsigned int aca_cstamp; + long unsigned int aca_tstamp; + struct callback_head rcu; +}; + +enum { + __ND_OPT_PREFIX_INFO_END = 0, + ND_OPT_SOURCE_LL_ADDR = 1, + ND_OPT_TARGET_LL_ADDR = 2, + ND_OPT_PREFIX_INFO = 3, + ND_OPT_REDIRECT_HDR = 4, + ND_OPT_MTU = 5, + ND_OPT_NONCE = 14, + __ND_OPT_ARRAY_MAX = 15, + ND_OPT_ROUTE_INFO = 24, + ND_OPT_RDNSS = 25, + ND_OPT_DNSSL = 31, + ND_OPT_6CO = 34, + ND_OPT_CAPTIVE_PORTAL = 37, + ND_OPT_PREF64 = 38, + __ND_OPT_MAX = 39, +}; + +struct nd_opt_hdr { + __u8 nd_opt_type; + __u8 nd_opt_len; +}; + +struct ndisc_options { + struct nd_opt_hdr *nd_opt_array[15]; + struct nd_opt_hdr *nd_opts_ri; + struct nd_opt_hdr *nd_opts_ri_end; + struct nd_opt_hdr *nd_useropts; + struct nd_opt_hdr *nd_useropts_end; +}; + +struct prefix_info { + __u8 type; + __u8 length; + __u8 prefix_len; + __u8 reserved: 6; + __u8 autoconf: 1; + __u8 onlink: 1; + __be32 valid; + __be32 prefered; + __be32 reserved2; + struct in6_addr prefix; +}; + +enum nfs_opnum4 { + OP_ACCESS = 3, + OP_CLOSE = 4, + OP_COMMIT = 5, + OP_CREATE = 6, + OP_DELEGPURGE = 7, + OP_DELEGRETURN = 8, + OP_GETATTR = 9, + OP_GETFH = 10, + OP_LINK = 11, + OP_LOCK = 12, + OP_LOCKT = 13, + OP_LOCKU = 14, + OP_LOOKUP = 15, + OP_LOOKUPP = 16, + OP_NVERIFY = 17, + OP_OPEN = 18, + OP_OPENATTR = 19, + OP_OPEN_CONFIRM = 20, + OP_OPEN_DOWNGRADE = 21, + OP_PUTFH = 22, + OP_PUTPUBFH = 23, + OP_PUTROOTFH = 24, + OP_READ = 25, + OP_READDIR = 26, + OP_READLINK = 27, + OP_REMOVE = 28, + OP_RENAME = 29, + OP_RENEW = 30, + OP_RESTOREFH = 31, + OP_SAVEFH = 32, + OP_SECINFO = 33, + OP_SETATTR = 34, + OP_SETCLIENTID = 35, + OP_SETCLIENTID_CONFIRM = 36, + OP_VERIFY = 37, + OP_WRITE = 38, + OP_RELEASE_LOCKOWNER = 39, + OP_BACKCHANNEL_CTL = 40, + OP_BIND_CONN_TO_SESSION = 41, + OP_EXCHANGE_ID = 42, + OP_CREATE_SESSION = 43, + OP_DESTROY_SESSION = 44, + OP_FREE_STATEID = 45, + OP_GET_DIR_DELEGATION = 46, + OP_GETDEVICEINFO = 47, + OP_GETDEVICELIST = 48, + OP_LAYOUTCOMMIT = 49, + OP_LAYOUTGET = 50, + OP_LAYOUTRETURN = 51, + OP_SECINFO_NO_NAME = 52, + OP_SEQUENCE = 53, + OP_SET_SSV = 54, + OP_TEST_STATEID = 55, + OP_WANT_DELEGATION = 56, + OP_DESTROY_CLIENTID = 57, + OP_RECLAIM_COMPLETE = 58, + OP_ALLOCATE = 59, + OP_COPY = 60, + OP_COPY_NOTIFY = 61, + OP_DEALLOCATE = 62, + OP_IO_ADVISE = 63, + OP_LAYOUTERROR = 64, + OP_LAYOUTSTATS = 65, + OP_OFFLOAD_CANCEL = 66, + OP_OFFLOAD_STATUS = 67, + OP_READ_PLUS = 68, + OP_SEEK = 69, + OP_WRITE_SAME = 70, + OP_CLONE = 71, + OP_GETXATTR = 72, + OP_SETXATTR = 73, + OP_LISTXATTRS = 74, + OP_REMOVEXATTR = 75, + OP_ILLEGAL = 10044, +}; + +enum perf_branch_sample_type_shift { + PERF_SAMPLE_BRANCH_USER_SHIFT = 0, + PERF_SAMPLE_BRANCH_KERNEL_SHIFT = 1, + PERF_SAMPLE_BRANCH_HV_SHIFT = 2, + PERF_SAMPLE_BRANCH_ANY_SHIFT = 3, + PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT = 4, + PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT = 5, + PERF_SAMPLE_BRANCH_IND_CALL_SHIFT = 6, + PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT = 7, + PERF_SAMPLE_BRANCH_IN_TX_SHIFT = 8, + PERF_SAMPLE_BRANCH_NO_TX_SHIFT = 9, + PERF_SAMPLE_BRANCH_COND_SHIFT = 10, + PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT = 11, + PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT = 12, + PERF_SAMPLE_BRANCH_CALL_SHIFT = 13, + PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT = 14, + PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT = 15, + PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT = 16, + PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT = 17, + PERF_SAMPLE_BRANCH_MAX_SHIFT = 18, +}; + +enum exception_stack_ordering { + ESTACK_DF = 0, + ESTACK_NMI = 1, + ESTACK_DB = 2, + ESTACK_MCE = 3, + ESTACK_VC = 4, + ESTACK_VC2 = 5, + N_EXCEPTION_STACKS = 6, +}; + +enum { + TSK_TRACE_FL_TRACE_BIT = 0, + TSK_TRACE_FL_GRAPH_BIT = 1, +}; + +struct uuidcmp { + const char *uuid; + int len; +}; + +typedef __u32 __le32; + +typedef __u64 __le64; + +struct minix_super_block { + __u16 s_ninodes; + __u16 s_nzones; + __u16 s_imap_blocks; + __u16 s_zmap_blocks; + __u16 s_firstdatazone; + __u16 s_log_zone_size; + __u32 s_max_size; + __u16 s_magic; + __u16 s_state; + __u32 s_zones; +}; + +struct romfs_super_block { + __be32 word0; + __be32 word1; + __be32 size; + __be32 checksum; + char name[0]; +}; + +struct cramfs_inode { + __u32 mode: 16; + __u32 uid: 16; + __u32 size: 24; + __u32 gid: 8; + __u32 namelen: 6; + __u32 offset: 26; +}; + +struct cramfs_info { + __u32 crc; + __u32 edition; + __u32 blocks; + __u32 files; +}; + +struct cramfs_super { + __u32 magic; + __u32 size; + __u32 flags; + __u32 future; + __u8 signature[16]; + struct cramfs_info fsid; + __u8 name[16]; + struct cramfs_inode root; +}; + +struct squashfs_super_block { + __le32 s_magic; + __le32 inodes; + __le32 mkfs_time; + __le32 block_size; + __le32 fragments; + __le16 compression; + __le16 block_log; + __le16 flags; + __le16 no_ids; + __le16 s_major; + __le16 s_minor; + __le64 root_inode; + __le64 bytes_used; + __le64 id_table_start; + __le64 xattr_id_table_start; + __le64 inode_table_start; + __le64 directory_table_start; + __le64 fragment_table_start; + __le64 lookup_table_start; +}; + +typedef int (*decompress_fn)(unsigned char *, long int, long int (*)(void *, long unsigned int), long int (*)(void *, long unsigned int), unsigned char *, long int *, void (*)(char *)); + +struct subprocess_info { + struct work_struct work; + struct completion *complete; + const char *path; + char **argv; + char **envp; + int wait; + int retval; + int (*init)(struct subprocess_info *, struct cred *); + void (*cleanup)(struct subprocess_info *); + void *data; +}; + +typedef phys_addr_t resource_size_t; + +struct resource { + resource_size_t start; + resource_size_t end; + const char *name; + long unsigned int flags; + long unsigned int desc; + struct resource *parent; + struct resource *sibling; + struct resource *child; +}; + +struct hash { + int ino; + int minor; + int major; + umode_t mode; + struct hash *next; + char name[4098]; +}; + +struct dir_entry { + struct list_head list; + char *name; + time64_t mtime; +}; + +enum state { + Start = 0, + Collect = 1, + GotHeader = 2, + SkipIt = 3, + GotName = 4, + CopyFile = 5, + GotSymlink = 6, + Reset = 7, +}; + +enum ucount_type { + UCOUNT_USER_NAMESPACES = 0, + UCOUNT_PID_NAMESPACES = 1, + UCOUNT_UTS_NAMESPACES = 2, + UCOUNT_IPC_NAMESPACES = 3, + UCOUNT_NET_NAMESPACES = 4, + UCOUNT_MNT_NAMESPACES = 5, + UCOUNT_CGROUP_NAMESPACES = 6, + UCOUNT_TIME_NAMESPACES = 7, + UCOUNT_INOTIFY_INSTANCES = 8, + UCOUNT_INOTIFY_WATCHES = 9, + UCOUNT_COUNTS = 10, +}; + +enum flow_dissector_key_id { + FLOW_DISSECTOR_KEY_CONTROL = 0, + FLOW_DISSECTOR_KEY_BASIC = 1, + FLOW_DISSECTOR_KEY_IPV4_ADDRS = 2, + FLOW_DISSECTOR_KEY_IPV6_ADDRS = 3, + FLOW_DISSECTOR_KEY_PORTS = 4, + FLOW_DISSECTOR_KEY_PORTS_RANGE = 5, + FLOW_DISSECTOR_KEY_ICMP = 6, + FLOW_DISSECTOR_KEY_ETH_ADDRS = 7, + FLOW_DISSECTOR_KEY_TIPC = 8, + FLOW_DISSECTOR_KEY_ARP = 9, + FLOW_DISSECTOR_KEY_VLAN = 10, + FLOW_DISSECTOR_KEY_FLOW_LABEL = 11, + FLOW_DISSECTOR_KEY_GRE_KEYID = 12, + FLOW_DISSECTOR_KEY_MPLS_ENTROPY = 13, + FLOW_DISSECTOR_KEY_ENC_KEYID = 14, + FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS = 15, + FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS = 16, + FLOW_DISSECTOR_KEY_ENC_CONTROL = 17, + FLOW_DISSECTOR_KEY_ENC_PORTS = 18, + FLOW_DISSECTOR_KEY_MPLS = 19, + FLOW_DISSECTOR_KEY_TCP = 20, + FLOW_DISSECTOR_KEY_IP = 21, + FLOW_DISSECTOR_KEY_CVLAN = 22, + FLOW_DISSECTOR_KEY_ENC_IP = 23, + FLOW_DISSECTOR_KEY_ENC_OPTS = 24, + FLOW_DISSECTOR_KEY_META = 25, + FLOW_DISSECTOR_KEY_CT = 26, + FLOW_DISSECTOR_KEY_HASH = 27, + FLOW_DISSECTOR_KEY_MAX = 28, +}; + +enum { + IPSTATS_MIB_NUM = 0, + IPSTATS_MIB_INPKTS = 1, + IPSTATS_MIB_INOCTETS = 2, + IPSTATS_MIB_INDELIVERS = 3, + IPSTATS_MIB_OUTFORWDATAGRAMS = 4, + IPSTATS_MIB_OUTPKTS = 5, + IPSTATS_MIB_OUTOCTETS = 6, + IPSTATS_MIB_INHDRERRORS = 7, + IPSTATS_MIB_INTOOBIGERRORS = 8, + IPSTATS_MIB_INNOROUTES = 9, + IPSTATS_MIB_INADDRERRORS = 10, + IPSTATS_MIB_INUNKNOWNPROTOS = 11, + IPSTATS_MIB_INTRUNCATEDPKTS = 12, + IPSTATS_MIB_INDISCARDS = 13, + IPSTATS_MIB_OUTDISCARDS = 14, + IPSTATS_MIB_OUTNOROUTES = 15, + IPSTATS_MIB_REASMTIMEOUT = 16, + IPSTATS_MIB_REASMREQDS = 17, + IPSTATS_MIB_REASMOKS = 18, + IPSTATS_MIB_REASMFAILS = 19, + IPSTATS_MIB_FRAGOKS = 20, + IPSTATS_MIB_FRAGFAILS = 21, + IPSTATS_MIB_FRAGCREATES = 22, + IPSTATS_MIB_INMCASTPKTS = 23, + IPSTATS_MIB_OUTMCASTPKTS = 24, + IPSTATS_MIB_INBCASTPKTS = 25, + IPSTATS_MIB_OUTBCASTPKTS = 26, + IPSTATS_MIB_INMCASTOCTETS = 27, + IPSTATS_MIB_OUTMCASTOCTETS = 28, + IPSTATS_MIB_INBCASTOCTETS = 29, + IPSTATS_MIB_OUTBCASTOCTETS = 30, + IPSTATS_MIB_CSUMERRORS = 31, + IPSTATS_MIB_NOECTPKTS = 32, + IPSTATS_MIB_ECT1PKTS = 33, + IPSTATS_MIB_ECT0PKTS = 34, + IPSTATS_MIB_CEPKTS = 35, + IPSTATS_MIB_REASM_OVERLAPS = 36, + __IPSTATS_MIB_MAX = 37, +}; + +enum { + ICMP_MIB_NUM = 0, + ICMP_MIB_INMSGS = 1, + ICMP_MIB_INERRORS = 2, + ICMP_MIB_INDESTUNREACHS = 3, + ICMP_MIB_INTIMEEXCDS = 4, + ICMP_MIB_INPARMPROBS = 5, + ICMP_MIB_INSRCQUENCHS = 6, + ICMP_MIB_INREDIRECTS = 7, + ICMP_MIB_INECHOS = 8, + ICMP_MIB_INECHOREPS = 9, + ICMP_MIB_INTIMESTAMPS = 10, + ICMP_MIB_INTIMESTAMPREPS = 11, + ICMP_MIB_INADDRMASKS = 12, + ICMP_MIB_INADDRMASKREPS = 13, + ICMP_MIB_OUTMSGS = 14, + ICMP_MIB_OUTERRORS = 15, + ICMP_MIB_OUTDESTUNREACHS = 16, + ICMP_MIB_OUTTIMEEXCDS = 17, + ICMP_MIB_OUTPARMPROBS = 18, + ICMP_MIB_OUTSRCQUENCHS = 19, + ICMP_MIB_OUTREDIRECTS = 20, + ICMP_MIB_OUTECHOS = 21, + ICMP_MIB_OUTECHOREPS = 22, + ICMP_MIB_OUTTIMESTAMPS = 23, + ICMP_MIB_OUTTIMESTAMPREPS = 24, + ICMP_MIB_OUTADDRMASKS = 25, + ICMP_MIB_OUTADDRMASKREPS = 26, + ICMP_MIB_CSUMERRORS = 27, + __ICMP_MIB_MAX = 28, +}; + +enum { + ICMP6_MIB_NUM = 0, + ICMP6_MIB_INMSGS = 1, + ICMP6_MIB_INERRORS = 2, + ICMP6_MIB_OUTMSGS = 3, + ICMP6_MIB_OUTERRORS = 4, + ICMP6_MIB_CSUMERRORS = 5, + __ICMP6_MIB_MAX = 6, +}; + +enum { + TCP_MIB_NUM = 0, + TCP_MIB_RTOALGORITHM = 1, + TCP_MIB_RTOMIN = 2, + TCP_MIB_RTOMAX = 3, + TCP_MIB_MAXCONN = 4, + TCP_MIB_ACTIVEOPENS = 5, + TCP_MIB_PASSIVEOPENS = 6, + TCP_MIB_ATTEMPTFAILS = 7, + TCP_MIB_ESTABRESETS = 8, + TCP_MIB_CURRESTAB = 9, + TCP_MIB_INSEGS = 10, + TCP_MIB_OUTSEGS = 11, + TCP_MIB_RETRANSSEGS = 12, + TCP_MIB_INERRS = 13, + TCP_MIB_OUTRSTS = 14, + TCP_MIB_CSUMERRORS = 15, + __TCP_MIB_MAX = 16, +}; + +enum { + UDP_MIB_NUM = 0, + UDP_MIB_INDATAGRAMS = 1, + UDP_MIB_NOPORTS = 2, + UDP_MIB_INERRORS = 3, + UDP_MIB_OUTDATAGRAMS = 4, + UDP_MIB_RCVBUFERRORS = 5, + UDP_MIB_SNDBUFERRORS = 6, + UDP_MIB_CSUMERRORS = 7, + UDP_MIB_IGNOREDMULTI = 8, + UDP_MIB_MEMERRORS = 9, + __UDP_MIB_MAX = 10, +}; + +enum { + LINUX_MIB_NUM = 0, + LINUX_MIB_SYNCOOKIESSENT = 1, + LINUX_MIB_SYNCOOKIESRECV = 2, + LINUX_MIB_SYNCOOKIESFAILED = 3, + LINUX_MIB_EMBRYONICRSTS = 4, + LINUX_MIB_PRUNECALLED = 5, + LINUX_MIB_RCVPRUNED = 6, + LINUX_MIB_OFOPRUNED = 7, + LINUX_MIB_OUTOFWINDOWICMPS = 8, + LINUX_MIB_LOCKDROPPEDICMPS = 9, + LINUX_MIB_ARPFILTER = 10, + LINUX_MIB_TIMEWAITED = 11, + LINUX_MIB_TIMEWAITRECYCLED = 12, + LINUX_MIB_TIMEWAITKILLED = 13, + LINUX_MIB_PAWSACTIVEREJECTED = 14, + LINUX_MIB_PAWSESTABREJECTED = 15, + LINUX_MIB_DELAYEDACKS = 16, + LINUX_MIB_DELAYEDACKLOCKED = 17, + LINUX_MIB_DELAYEDACKLOST = 18, + LINUX_MIB_LISTENOVERFLOWS = 19, + LINUX_MIB_LISTENDROPS = 20, + LINUX_MIB_TCPHPHITS = 21, + LINUX_MIB_TCPPUREACKS = 22, + LINUX_MIB_TCPHPACKS = 23, + LINUX_MIB_TCPRENORECOVERY = 24, + LINUX_MIB_TCPSACKRECOVERY = 25, + LINUX_MIB_TCPSACKRENEGING = 26, + LINUX_MIB_TCPSACKREORDER = 27, + LINUX_MIB_TCPRENOREORDER = 28, + LINUX_MIB_TCPTSREORDER = 29, + LINUX_MIB_TCPFULLUNDO = 30, + LINUX_MIB_TCPPARTIALUNDO = 31, + LINUX_MIB_TCPDSACKUNDO = 32, + LINUX_MIB_TCPLOSSUNDO = 33, + LINUX_MIB_TCPLOSTRETRANSMIT = 34, + LINUX_MIB_TCPRENOFAILURES = 35, + LINUX_MIB_TCPSACKFAILURES = 36, + LINUX_MIB_TCPLOSSFAILURES = 37, + LINUX_MIB_TCPFASTRETRANS = 38, + LINUX_MIB_TCPSLOWSTARTRETRANS = 39, + LINUX_MIB_TCPTIMEOUTS = 40, + LINUX_MIB_TCPLOSSPROBES = 41, + LINUX_MIB_TCPLOSSPROBERECOVERY = 42, + LINUX_MIB_TCPRENORECOVERYFAIL = 43, + LINUX_MIB_TCPSACKRECOVERYFAIL = 44, + LINUX_MIB_TCPRCVCOLLAPSED = 45, + LINUX_MIB_TCPDSACKOLDSENT = 46, + LINUX_MIB_TCPDSACKOFOSENT = 47, + LINUX_MIB_TCPDSACKRECV = 48, + LINUX_MIB_TCPDSACKOFORECV = 49, + LINUX_MIB_TCPABORTONDATA = 50, + LINUX_MIB_TCPABORTONCLOSE = 51, + LINUX_MIB_TCPABORTONMEMORY = 52, + LINUX_MIB_TCPABORTONTIMEOUT = 53, + LINUX_MIB_TCPABORTONLINGER = 54, + LINUX_MIB_TCPABORTFAILED = 55, + LINUX_MIB_TCPMEMORYPRESSURES = 56, + LINUX_MIB_TCPMEMORYPRESSURESCHRONO = 57, + LINUX_MIB_TCPSACKDISCARD = 58, + LINUX_MIB_TCPDSACKIGNOREDOLD = 59, + LINUX_MIB_TCPDSACKIGNOREDNOUNDO = 60, + LINUX_MIB_TCPSPURIOUSRTOS = 61, + LINUX_MIB_TCPMD5NOTFOUND = 62, + LINUX_MIB_TCPMD5UNEXPECTED = 63, + LINUX_MIB_TCPMD5FAILURE = 64, + LINUX_MIB_SACKSHIFTED = 65, + LINUX_MIB_SACKMERGED = 66, + LINUX_MIB_SACKSHIFTFALLBACK = 67, + LINUX_MIB_TCPBACKLOGDROP = 68, + LINUX_MIB_PFMEMALLOCDROP = 69, + LINUX_MIB_TCPMINTTLDROP = 70, + LINUX_MIB_TCPDEFERACCEPTDROP = 71, + LINUX_MIB_IPRPFILTER = 72, + LINUX_MIB_TCPTIMEWAITOVERFLOW = 73, + LINUX_MIB_TCPREQQFULLDOCOOKIES = 74, + LINUX_MIB_TCPREQQFULLDROP = 75, + LINUX_MIB_TCPRETRANSFAIL = 76, + LINUX_MIB_TCPRCVCOALESCE = 77, + LINUX_MIB_TCPBACKLOGCOALESCE = 78, + LINUX_MIB_TCPOFOQUEUE = 79, + LINUX_MIB_TCPOFODROP = 80, + LINUX_MIB_TCPOFOMERGE = 81, + LINUX_MIB_TCPCHALLENGEACK = 82, + LINUX_MIB_TCPSYNCHALLENGE = 83, + LINUX_MIB_TCPFASTOPENACTIVE = 84, + LINUX_MIB_TCPFASTOPENACTIVEFAIL = 85, + LINUX_MIB_TCPFASTOPENPASSIVE = 86, + LINUX_MIB_TCPFASTOPENPASSIVEFAIL = 87, + LINUX_MIB_TCPFASTOPENLISTENOVERFLOW = 88, + LINUX_MIB_TCPFASTOPENCOOKIEREQD = 89, + LINUX_MIB_TCPFASTOPENBLACKHOLE = 90, + LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES = 91, + LINUX_MIB_BUSYPOLLRXPACKETS = 92, + LINUX_MIB_TCPAUTOCORKING = 93, + LINUX_MIB_TCPFROMZEROWINDOWADV = 94, + LINUX_MIB_TCPTOZEROWINDOWADV = 95, + LINUX_MIB_TCPWANTZEROWINDOWADV = 96, + LINUX_MIB_TCPSYNRETRANS = 97, + LINUX_MIB_TCPORIGDATASENT = 98, + LINUX_MIB_TCPHYSTARTTRAINDETECT = 99, + LINUX_MIB_TCPHYSTARTTRAINCWND = 100, + LINUX_MIB_TCPHYSTARTDELAYDETECT = 101, + LINUX_MIB_TCPHYSTARTDELAYCWND = 102, + LINUX_MIB_TCPACKSKIPPEDSYNRECV = 103, + LINUX_MIB_TCPACKSKIPPEDPAWS = 104, + LINUX_MIB_TCPACKSKIPPEDSEQ = 105, + LINUX_MIB_TCPACKSKIPPEDFINWAIT2 = 106, + LINUX_MIB_TCPACKSKIPPEDTIMEWAIT = 107, + LINUX_MIB_TCPACKSKIPPEDCHALLENGE = 108, + LINUX_MIB_TCPWINPROBE = 109, + LINUX_MIB_TCPKEEPALIVE = 110, + LINUX_MIB_TCPMTUPFAIL = 111, + LINUX_MIB_TCPMTUPSUCCESS = 112, + LINUX_MIB_TCPDELIVERED = 113, + LINUX_MIB_TCPDELIVEREDCE = 114, + LINUX_MIB_TCPACKCOMPRESSED = 115, + LINUX_MIB_TCPZEROWINDOWDROP = 116, + LINUX_MIB_TCPRCVQDROP = 117, + LINUX_MIB_TCPWQUEUETOOBIG = 118, + LINUX_MIB_TCPFASTOPENPASSIVEALTKEY = 119, + LINUX_MIB_TCPTIMEOUTREHASH = 120, + LINUX_MIB_TCPDUPLICATEDATAREHASH = 121, + LINUX_MIB_TCPDSACKRECVSEGS = 122, + LINUX_MIB_TCPDSACKIGNOREDDUBIOUS = 123, + __LINUX_MIB_MAX = 124, +}; + +enum { + LINUX_MIB_XFRMNUM = 0, + LINUX_MIB_XFRMINERROR = 1, + LINUX_MIB_XFRMINBUFFERERROR = 2, + LINUX_MIB_XFRMINHDRERROR = 3, + LINUX_MIB_XFRMINNOSTATES = 4, + LINUX_MIB_XFRMINSTATEPROTOERROR = 5, + LINUX_MIB_XFRMINSTATEMODEERROR = 6, + LINUX_MIB_XFRMINSTATESEQERROR = 7, + LINUX_MIB_XFRMINSTATEEXPIRED = 8, + LINUX_MIB_XFRMINSTATEMISMATCH = 9, + LINUX_MIB_XFRMINSTATEINVALID = 10, + LINUX_MIB_XFRMINTMPLMISMATCH = 11, + LINUX_MIB_XFRMINNOPOLS = 12, + LINUX_MIB_XFRMINPOLBLOCK = 13, + LINUX_MIB_XFRMINPOLERROR = 14, + LINUX_MIB_XFRMOUTERROR = 15, + LINUX_MIB_XFRMOUTBUNDLEGENERROR = 16, + LINUX_MIB_XFRMOUTBUNDLECHECKERROR = 17, + LINUX_MIB_XFRMOUTNOSTATES = 18, + LINUX_MIB_XFRMOUTSTATEPROTOERROR = 19, + LINUX_MIB_XFRMOUTSTATEMODEERROR = 20, + LINUX_MIB_XFRMOUTSTATESEQERROR = 21, + LINUX_MIB_XFRMOUTSTATEEXPIRED = 22, + LINUX_MIB_XFRMOUTPOLBLOCK = 23, + LINUX_MIB_XFRMOUTPOLDEAD = 24, + LINUX_MIB_XFRMOUTPOLERROR = 25, + LINUX_MIB_XFRMFWDHDRERROR = 26, + LINUX_MIB_XFRMOUTSTATEINVALID = 27, + LINUX_MIB_XFRMACQUIREERROR = 28, + __LINUX_MIB_XFRMMAX = 29, +}; + +enum { + LINUX_MIB_TLSNUM = 0, + LINUX_MIB_TLSCURRTXSW = 1, + LINUX_MIB_TLSCURRRXSW = 2, + LINUX_MIB_TLSCURRTXDEVICE = 3, + LINUX_MIB_TLSCURRRXDEVICE = 4, + LINUX_MIB_TLSTXSW = 5, + LINUX_MIB_TLSRXSW = 6, + LINUX_MIB_TLSTXDEVICE = 7, + LINUX_MIB_TLSRXDEVICE = 8, + LINUX_MIB_TLSDECRYPTERROR = 9, + LINUX_MIB_TLSRXDEVICERESYNC = 10, + __LINUX_MIB_TLSMAX = 11, +}; + +enum nf_inet_hooks { + NF_INET_PRE_ROUTING = 0, + NF_INET_LOCAL_IN = 1, + NF_INET_FORWARD = 2, + NF_INET_LOCAL_OUT = 3, + NF_INET_POST_ROUTING = 4, + NF_INET_NUMHOOKS = 5, + NF_INET_INGRESS = 5, +}; + +enum { + NFPROTO_UNSPEC = 0, + NFPROTO_INET = 1, + NFPROTO_IPV4 = 2, + NFPROTO_ARP = 3, + NFPROTO_NETDEV = 5, + NFPROTO_BRIDGE = 7, + NFPROTO_IPV6 = 10, + NFPROTO_DECNET = 12, + NFPROTO_NUMPROTO = 13, +}; + +enum { + XFRM_POLICY_IN = 0, + XFRM_POLICY_OUT = 1, + XFRM_POLICY_FWD = 2, + XFRM_POLICY_MASK = 3, + XFRM_POLICY_MAX = 3, +}; + +enum netns_bpf_attach_type { + NETNS_BPF_INVALID = 4294967295, + NETNS_BPF_FLOW_DISSECTOR = 0, + NETNS_BPF_SK_LOOKUP = 1, + MAX_NETNS_BPF_ATTACH_TYPE = 2, +}; + +enum skb_ext_id { + SKB_EXT_BRIDGE_NF = 0, + SKB_EXT_SEC_PATH = 1, + SKB_EXT_NUM = 2, +}; + +enum audit_ntp_type { + AUDIT_NTP_OFFSET = 0, + AUDIT_NTP_FREQ = 1, + AUDIT_NTP_STATUS = 2, + AUDIT_NTP_TAI = 3, + AUDIT_NTP_TICK = 4, + AUDIT_NTP_ADJUST = 5, + AUDIT_NTP_NVALS = 6, +}; + +typedef long int (*sys_call_ptr_t)(const struct pt_regs *); + +struct io_bitmap { + u64 sequence; + refcount_t refcnt; + unsigned int max; + long unsigned int bitmap[1024]; +}; + +enum { + EI_ETYPE_NONE = 0, + EI_ETYPE_NULL = 1, + EI_ETYPE_ERRNO = 2, + EI_ETYPE_ERRNO_NULL = 3, + EI_ETYPE_TRUE = 4, +}; + +struct syscall_metadata { + const char *name; + int syscall_nr; + int nb_args; + const char **types; + const char **args; + struct list_head enter_fields; + struct trace_event_call *enter_event; + struct trace_event_call *exit_event; +}; + +struct alt_instr { + s32 instr_offset; + s32 repl_offset; + u16 cpuid; + u8 instrlen; + u8 replacementlen; + u8 padlen; +} __attribute__((packed)); + +struct timens_offset { + s64 sec; + u64 nsec; +}; + +enum vm_fault_reason { + VM_FAULT_OOM = 1, + VM_FAULT_SIGBUS = 2, + VM_FAULT_MAJOR = 4, + VM_FAULT_WRITE = 8, + VM_FAULT_HWPOISON = 16, + VM_FAULT_HWPOISON_LARGE = 32, + VM_FAULT_SIGSEGV = 64, + VM_FAULT_NOPAGE = 256, + VM_FAULT_LOCKED = 512, + VM_FAULT_RETRY = 1024, + VM_FAULT_FALLBACK = 2048, + VM_FAULT_DONE_COW = 4096, + VM_FAULT_NEEDDSYNC = 8192, + VM_FAULT_HINDEX_MASK = 983040, +}; + +struct vm_special_mapping { + const char *name; + struct page **pages; + vm_fault_t (*fault)(const struct vm_special_mapping *, struct vm_area_struct *, struct vm_fault *); + int (*mremap)(const struct vm_special_mapping *, struct vm_area_struct *); +}; + +struct timens_offsets { + struct timespec64 monotonic; + struct timespec64 boottime; +}; + +struct time_namespace { + struct kref kref; + struct user_namespace *user_ns; + struct ucounts *ucounts; + struct ns_common ns; + struct timens_offsets offsets; + struct page *vvar_page; + bool frozen_offsets; +}; + +struct pvclock_vcpu_time_info { + u32 version; + u32 pad0; + u64 tsc_timestamp; + u64 system_time; + u32 tsc_to_system_mul; + s8 tsc_shift; + u8 flags; + u8 pad[2]; +}; + +struct pvclock_vsyscall_time_info { + struct pvclock_vcpu_time_info pvti; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +enum vdso_clock_mode { + VDSO_CLOCKMODE_NONE = 0, + VDSO_CLOCKMODE_TSC = 1, + VDSO_CLOCKMODE_PVCLOCK = 2, + VDSO_CLOCKMODE_HVCLOCK = 3, + VDSO_CLOCKMODE_MAX = 4, + VDSO_CLOCKMODE_TIMENS = 2147483647, +}; + +struct arch_vdso_data {}; + +struct vdso_timestamp { + u64 sec; + u64 nsec; +}; + +struct vdso_data { + u32 seq; + s32 clock_mode; + u64 cycle_last; + u64 mask; + u32 mult; + u32 shift; + union { + struct vdso_timestamp basetime[12]; + struct timens_offset offset[12]; + }; + s32 tz_minuteswest; + s32 tz_dsttime; + u32 hrtimer_res; + u32 __unused; + struct arch_vdso_data arch_data; +}; + +struct ms_hyperv_tsc_page { + volatile u32 tsc_sequence; + u32 reserved1; + volatile u64 tsc_scale; + volatile s64 tsc_offset; +}; + +enum { + TASKSTATS_CMD_UNSPEC = 0, + TASKSTATS_CMD_GET = 1, + TASKSTATS_CMD_NEW = 2, + __TASKSTATS_CMD_MAX = 3, +}; + +enum { + HI_SOFTIRQ = 0, + TIMER_SOFTIRQ = 1, + NET_TX_SOFTIRQ = 2, + NET_RX_SOFTIRQ = 3, + BLOCK_SOFTIRQ = 4, + IRQ_POLL_SOFTIRQ = 5, + TASKLET_SOFTIRQ = 6, + SCHED_SOFTIRQ = 7, + HRTIMER_SOFTIRQ = 8, + RCU_SOFTIRQ = 9, + NR_SOFTIRQS = 10, +}; + +enum cpu_usage_stat { + CPUTIME_USER = 0, + CPUTIME_NICE = 1, + CPUTIME_SYSTEM = 2, + CPUTIME_SOFTIRQ = 3, + CPUTIME_IRQ = 4, + CPUTIME_IDLE = 5, + CPUTIME_IOWAIT = 6, + CPUTIME_STEAL = 7, + CPUTIME_GUEST = 8, + CPUTIME_GUEST_NICE = 9, + NR_STATS = 10, +}; + +enum bpf_cgroup_storage_type { + BPF_CGROUP_STORAGE_SHARED = 0, + BPF_CGROUP_STORAGE_PERCPU = 1, + __BPF_CGROUP_STORAGE_MAX = 2, +}; + +enum psi_task_count { + NR_IOWAIT = 0, + NR_MEMSTALL = 1, + NR_RUNNING = 2, + NR_ONCPU = 3, + NR_PSI_TASK_COUNTS = 4, +}; + +enum psi_states { + PSI_IO_SOME = 0, + PSI_IO_FULL = 1, + PSI_MEM_SOME = 2, + PSI_MEM_FULL = 3, + PSI_CPU_SOME = 4, + PSI_NONIDLE = 5, + NR_PSI_STATES = 6, +}; + +enum psi_aggregators { + PSI_AVGS = 0, + PSI_POLL = 1, + NR_PSI_AGGREGATORS = 2, +}; + +enum cgroup_subsys_id { + cpuset_cgrp_id = 0, + cpu_cgrp_id = 1, + cpuacct_cgrp_id = 2, + io_cgrp_id = 3, + memory_cgrp_id = 4, + devices_cgrp_id = 5, + freezer_cgrp_id = 6, + net_cls_cgrp_id = 7, + perf_event_cgrp_id = 8, + hugetlb_cgrp_id = 9, + CGROUP_SUBSYS_COUNT = 10, +}; + +struct cpuinfo_x86 { + __u8 x86; + __u8 x86_vendor; + __u8 x86_model; + __u8 x86_stepping; + int x86_tlbsize; + __u32 vmx_capability[3]; + __u8 x86_virt_bits; + __u8 x86_phys_bits; + __u8 x86_coreid_bits; + __u8 cu_id; + __u32 extended_cpuid_level; + int cpuid_level; + union { + __u32 x86_capability[20]; + long unsigned int x86_capability_alignment; + }; + char x86_vendor_id[16]; + char x86_model_id[64]; + unsigned int x86_cache_size; + int x86_cache_alignment; + int x86_cache_max_rmid; + int x86_cache_occ_scale; + int x86_cache_mbm_width_offset; + int x86_power; + long unsigned int loops_per_jiffy; + u16 x86_max_cores; + u16 apicid; + u16 initial_apicid; + u16 x86_clflush_size; + u16 booted_cores; + u16 phys_proc_id; + u16 logical_proc_id; + u16 cpu_core_id; + u16 cpu_die_id; + u16 logical_die_id; + u16 cpu_index; + u32 microcode; + u8 x86_cache_bits; + unsigned int initialized: 1; +}; + +enum x86_pf_error_code { + X86_PF_PROT = 1, + X86_PF_WRITE = 2, + X86_PF_USER = 4, + X86_PF_RSVD = 8, + X86_PF_INSTR = 16, + X86_PF_PK = 32, +}; + +struct trace_event_raw_emulate_vsyscall { + struct trace_entry ent; + int nr; + char __data[0]; +}; + +struct trace_event_data_offsets_emulate_vsyscall {}; + +typedef void (*btf_trace_emulate_vsyscall)(void *, int); + +enum { + EMULATE = 0, + XONLY = 1, + NONE = 2, +}; + +enum perf_type_id { + PERF_TYPE_HARDWARE = 0, + PERF_TYPE_SOFTWARE = 1, + PERF_TYPE_TRACEPOINT = 2, + PERF_TYPE_HW_CACHE = 3, + PERF_TYPE_RAW = 4, + PERF_TYPE_BREAKPOINT = 5, + PERF_TYPE_MAX = 6, +}; + +enum perf_hw_id { + PERF_COUNT_HW_CPU_CYCLES = 0, + PERF_COUNT_HW_INSTRUCTIONS = 1, + PERF_COUNT_HW_CACHE_REFERENCES = 2, + PERF_COUNT_HW_CACHE_MISSES = 3, + PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 4, + PERF_COUNT_HW_BRANCH_MISSES = 5, + PERF_COUNT_HW_BUS_CYCLES = 6, + PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 7, + PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 8, + PERF_COUNT_HW_REF_CPU_CYCLES = 9, + PERF_COUNT_HW_MAX = 10, +}; + +enum perf_hw_cache_id { + PERF_COUNT_HW_CACHE_L1D = 0, + PERF_COUNT_HW_CACHE_L1I = 1, + PERF_COUNT_HW_CACHE_LL = 2, + PERF_COUNT_HW_CACHE_DTLB = 3, + PERF_COUNT_HW_CACHE_ITLB = 4, + PERF_COUNT_HW_CACHE_BPU = 5, + PERF_COUNT_HW_CACHE_NODE = 6, + PERF_COUNT_HW_CACHE_MAX = 7, +}; + +enum perf_hw_cache_op_id { + PERF_COUNT_HW_CACHE_OP_READ = 0, + PERF_COUNT_HW_CACHE_OP_WRITE = 1, + PERF_COUNT_HW_CACHE_OP_PREFETCH = 2, + PERF_COUNT_HW_CACHE_OP_MAX = 3, +}; + +enum perf_hw_cache_op_result_id { + PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0, + PERF_COUNT_HW_CACHE_RESULT_MISS = 1, + PERF_COUNT_HW_CACHE_RESULT_MAX = 2, +}; + +enum perf_event_sample_format { + PERF_SAMPLE_IP = 1, + PERF_SAMPLE_TID = 2, + PERF_SAMPLE_TIME = 4, + PERF_SAMPLE_ADDR = 8, + PERF_SAMPLE_READ = 16, + PERF_SAMPLE_CALLCHAIN = 32, + PERF_SAMPLE_ID = 64, + PERF_SAMPLE_CPU = 128, + PERF_SAMPLE_PERIOD = 256, + PERF_SAMPLE_STREAM_ID = 512, + PERF_SAMPLE_RAW = 1024, + PERF_SAMPLE_BRANCH_STACK = 2048, + PERF_SAMPLE_REGS_USER = 4096, + PERF_SAMPLE_STACK_USER = 8192, + PERF_SAMPLE_WEIGHT = 16384, + PERF_SAMPLE_DATA_SRC = 32768, + PERF_SAMPLE_IDENTIFIER = 65536, + PERF_SAMPLE_TRANSACTION = 131072, + PERF_SAMPLE_REGS_INTR = 262144, + PERF_SAMPLE_PHYS_ADDR = 524288, + PERF_SAMPLE_AUX = 1048576, + PERF_SAMPLE_CGROUP = 2097152, + PERF_SAMPLE_MAX = 4194304, + __PERF_SAMPLE_CALLCHAIN_EARLY = 0, +}; + +enum perf_branch_sample_type { + PERF_SAMPLE_BRANCH_USER = 1, + PERF_SAMPLE_BRANCH_KERNEL = 2, + PERF_SAMPLE_BRANCH_HV = 4, + PERF_SAMPLE_BRANCH_ANY = 8, + PERF_SAMPLE_BRANCH_ANY_CALL = 16, + PERF_SAMPLE_BRANCH_ANY_RETURN = 32, + PERF_SAMPLE_BRANCH_IND_CALL = 64, + PERF_SAMPLE_BRANCH_ABORT_TX = 128, + PERF_SAMPLE_BRANCH_IN_TX = 256, + PERF_SAMPLE_BRANCH_NO_TX = 512, + PERF_SAMPLE_BRANCH_COND = 1024, + PERF_SAMPLE_BRANCH_CALL_STACK = 2048, + PERF_SAMPLE_BRANCH_IND_JUMP = 4096, + PERF_SAMPLE_BRANCH_CALL = 8192, + PERF_SAMPLE_BRANCH_NO_FLAGS = 16384, + PERF_SAMPLE_BRANCH_NO_CYCLES = 32768, + PERF_SAMPLE_BRANCH_TYPE_SAVE = 65536, + PERF_SAMPLE_BRANCH_HW_INDEX = 131072, + PERF_SAMPLE_BRANCH_MAX = 262144, +}; + +struct perf_event_mmap_page { + __u32 version; + __u32 compat_version; + __u32 lock; + __u32 index; + __s64 offset; + __u64 time_enabled; + __u64 time_running; + union { + __u64 capabilities; + struct { + __u64 cap_bit0: 1; + __u64 cap_bit0_is_deprecated: 1; + __u64 cap_user_rdpmc: 1; + __u64 cap_user_time: 1; + __u64 cap_user_time_zero: 1; + __u64 cap_user_time_short: 1; + __u64 cap_____res: 58; + }; + }; + __u16 pmc_width; + __u16 time_shift; + __u32 time_mult; + __u64 time_offset; + __u64 time_zero; + __u32 size; + __u32 __reserved_1; + __u64 time_cycles; + __u64 time_mask; + __u8 __reserved[928]; + __u64 data_head; + __u64 data_tail; + __u64 data_offset; + __u64 data_size; + __u64 aux_head; + __u64 aux_tail; + __u64 aux_offset; + __u64 aux_size; +}; + +struct ldt_struct { + struct desc_struct *entries; + unsigned int nr_entries; + int slot; +}; + +struct physid_mask { + long unsigned int mask[512]; +}; + +typedef struct physid_mask physid_mask_t; + +struct x86_pmu_capability { + int version; + int num_counters_gp; + int num_counters_fixed; + int bit_width_gp; + int bit_width_fixed; + unsigned int events_mask; + int events_mask_len; +}; + +struct debug_store { + u64 bts_buffer_base; + u64 bts_index; + u64 bts_absolute_maximum; + u64 bts_interrupt_threshold; + u64 pebs_buffer_base; + u64 pebs_index; + u64 pebs_absolute_maximum; + u64 pebs_interrupt_threshold; + u64 pebs_event_reset[12]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +enum stack_type { + STACK_TYPE_UNKNOWN = 0, + STACK_TYPE_TASK = 1, + STACK_TYPE_IRQ = 2, + STACK_TYPE_SOFTIRQ = 3, + STACK_TYPE_ENTRY = 4, + STACK_TYPE_EXCEPTION = 5, + STACK_TYPE_EXCEPTION_LAST = 10, +}; + +struct stack_info { + enum stack_type type; + long unsigned int *begin; + long unsigned int *end; + long unsigned int *next_sp; +}; + +struct stack_frame { + struct stack_frame *next_frame; + long unsigned int return_address; +}; + +struct stack_frame_ia32 { + u32 next_frame; + u32 return_address; +}; + +struct perf_guest_switch_msr { + unsigned int msr; + u64 host; + u64 guest; +}; + +struct perf_guest_info_callbacks { + int (*is_in_guest)(); + int (*is_user_mode)(); + long unsigned int (*get_guest_ip)(); + void (*handle_intel_pt_intr)(); +}; + +struct device_attribute { + struct attribute attr; + ssize_t (*show)(struct device *, struct device_attribute *, char *); + ssize_t (*store)(struct device *, struct device_attribute *, const char *, size_t); +}; + +enum perf_event_x86_regs { + PERF_REG_X86_AX = 0, + PERF_REG_X86_BX = 1, + PERF_REG_X86_CX = 2, + PERF_REG_X86_DX = 3, + PERF_REG_X86_SI = 4, + PERF_REG_X86_DI = 5, + PERF_REG_X86_BP = 6, + PERF_REG_X86_SP = 7, + PERF_REG_X86_IP = 8, + PERF_REG_X86_FLAGS = 9, + PERF_REG_X86_CS = 10, + PERF_REG_X86_SS = 11, + PERF_REG_X86_DS = 12, + PERF_REG_X86_ES = 13, + PERF_REG_X86_FS = 14, + PERF_REG_X86_GS = 15, + PERF_REG_X86_R8 = 16, + PERF_REG_X86_R9 = 17, + PERF_REG_X86_R10 = 18, + PERF_REG_X86_R11 = 19, + PERF_REG_X86_R12 = 20, + PERF_REG_X86_R13 = 21, + PERF_REG_X86_R14 = 22, + PERF_REG_X86_R15 = 23, + PERF_REG_X86_32_MAX = 16, + PERF_REG_X86_64_MAX = 24, + PERF_REG_X86_XMM0 = 32, + PERF_REG_X86_XMM1 = 34, + PERF_REG_X86_XMM2 = 36, + PERF_REG_X86_XMM3 = 38, + PERF_REG_X86_XMM4 = 40, + PERF_REG_X86_XMM5 = 42, + PERF_REG_X86_XMM6 = 44, + PERF_REG_X86_XMM7 = 46, + PERF_REG_X86_XMM8 = 48, + PERF_REG_X86_XMM9 = 50, + PERF_REG_X86_XMM10 = 52, + PERF_REG_X86_XMM11 = 54, + PERF_REG_X86_XMM12 = 56, + PERF_REG_X86_XMM13 = 58, + PERF_REG_X86_XMM14 = 60, + PERF_REG_X86_XMM15 = 62, + PERF_REG_X86_XMM_MAX = 64, +}; + +typedef struct { + u16 __softirq_pending; + u8 kvm_cpu_l1tf_flush_l1d; + unsigned int __nmi_count; + unsigned int apic_timer_irqs; + unsigned int irq_spurious_count; + unsigned int icr_read_retry_count; + unsigned int kvm_posted_intr_ipis; + unsigned int kvm_posted_intr_wakeup_ipis; + unsigned int kvm_posted_intr_nested_ipis; + unsigned int x86_platform_ipis; + unsigned int apic_perf_irqs; + unsigned int apic_irq_work_irqs; + unsigned int irq_resched_count; + unsigned int irq_call_count; + unsigned int irq_tlb_count; + unsigned int irq_thermal_count; + unsigned int irq_threshold_count; + unsigned int irq_deferred_error_count; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +} irq_cpustat_t; + +struct perf_callchain_entry_ctx { + struct perf_callchain_entry *entry; + u32 max_stack; + u32 nr; + short int contexts; + bool contexts_maxed; +}; + +struct perf_pmu_events_attr { + struct device_attribute attr; + u64 id; + const char *event_str; +}; + +struct perf_pmu_events_ht_attr { + struct device_attribute attr; + u64 id; + const char *event_str_ht; + const char *event_str_noht; +}; + +struct apic { + void (*eoi_write)(u32, u32); + void (*native_eoi_write)(u32, u32); + void (*write)(u32, u32); + u32 (*read)(u32); + void (*wait_icr_idle)(); + u32 (*safe_wait_icr_idle)(); + void (*send_IPI)(int, int); + void (*send_IPI_mask)(const struct cpumask *, int); + void (*send_IPI_mask_allbutself)(const struct cpumask *, int); + void (*send_IPI_allbutself)(int); + void (*send_IPI_all)(int); + void (*send_IPI_self)(int); + u32 dest_logical; + u32 disable_esr; + u32 irq_delivery_mode; + u32 irq_dest_mode; + u32 (*calc_dest_apicid)(unsigned int); + u64 (*icr_read)(); + void (*icr_write)(u32, u32); + int (*probe)(); + int (*acpi_madt_oem_check)(char *, char *); + int (*apic_id_valid)(u32); + int (*apic_id_registered)(); + bool (*check_apicid_used)(physid_mask_t *, int); + void (*init_apic_ldr)(); + void (*ioapic_phys_id_map)(physid_mask_t *, physid_mask_t *); + void (*setup_apic_routing)(); + int (*cpu_present_to_apicid)(int); + void (*apicid_to_cpu_present)(int, physid_mask_t *); + int (*check_phys_apicid_present)(int); + int (*phys_pkg_id)(int, int); + u32 (*get_apic_id)(long unsigned int); + u32 (*set_apic_id)(unsigned int); + int (*wakeup_secondary_cpu)(int, long unsigned int); + void (*inquire_remote_apic)(int); + char *name; +}; + +enum { + NMI_LOCAL = 0, + NMI_UNKNOWN = 1, + NMI_SERR = 2, + NMI_IO_CHECK = 3, + NMI_MAX = 4, +}; + +typedef int (*nmi_handler_t)(unsigned int, struct pt_regs *); + +struct nmiaction { + struct list_head list; + nmi_handler_t handler; + u64 max_duration; + long unsigned int flags; + const char *name; +}; + +struct gdt_page { + struct desc_struct gdt[16]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct cyc2ns_data { + u32 cyc2ns_mul; + u32 cyc2ns_shift; + u64 cyc2ns_offset; +}; + +struct unwind_state { + struct stack_info stack_info; + long unsigned int stack_mask; + struct task_struct *task; + int graph_idx; + bool error; + bool signal; + bool full_regs; + long unsigned int sp; + long unsigned int bp; + long unsigned int ip; + struct pt_regs *regs; + struct pt_regs *prev_regs; +}; + +enum extra_reg_type { + EXTRA_REG_NONE = 4294967295, + EXTRA_REG_RSP_0 = 0, + EXTRA_REG_RSP_1 = 1, + EXTRA_REG_LBR = 2, + EXTRA_REG_LDLAT = 3, + EXTRA_REG_FE = 4, + EXTRA_REG_MAX = 5, +}; + +struct event_constraint { + union { + long unsigned int idxmsk[1]; + u64 idxmsk64; + }; + u64 code; + u64 cmask; + int weight; + int overlap; + int flags; + unsigned int size; +}; + +struct amd_nb { + int nb_id; + int refcnt; + struct perf_event *owners[64]; + struct event_constraint event_constraints[64]; +}; + +struct er_account { + raw_spinlock_t lock; + u64 config; + u64 reg; + atomic_t ref; +}; + +struct intel_shared_regs { + struct er_account regs[5]; + int refcnt; + unsigned int core_id; +}; + +enum intel_excl_state_type { + INTEL_EXCL_UNUSED = 0, + INTEL_EXCL_SHARED = 1, + INTEL_EXCL_EXCLUSIVE = 2, +}; + +struct intel_excl_states { + enum intel_excl_state_type state[64]; + bool sched_started; +}; + +struct intel_excl_cntrs { + raw_spinlock_t lock; + struct intel_excl_states states[2]; + union { + u16 has_exclusive[2]; + u32 exclusive_present; + }; + int refcnt; + unsigned int core_id; +}; + +enum { + X86_PERF_KFREE_SHARED = 0, + X86_PERF_KFREE_EXCL = 1, + X86_PERF_KFREE_MAX = 2, +}; + +struct cpu_hw_events { + struct perf_event *events[64]; + long unsigned int active_mask[1]; + long unsigned int running[1]; + int enabled; + int n_events; + int n_added; + int n_txn; + int n_txn_pair; + int n_txn_metric; + int assign[64]; + u64 tags[64]; + struct perf_event *event_list[64]; + struct event_constraint *event_constraint[64]; + int n_excl; + unsigned int txn_flags; + int is_fake; + struct debug_store *ds; + void *ds_pebs_vaddr; + void *ds_bts_vaddr; + u64 pebs_enabled; + int n_pebs; + int n_large_pebs; + int n_pebs_via_pt; + int pebs_output; + u64 pebs_data_cfg; + u64 active_pebs_data_cfg; + int pebs_record_size; + int lbr_users; + int lbr_pebs_users; + struct perf_branch_stack lbr_stack; + struct perf_branch_entry lbr_entries[32]; + union { + struct er_account *lbr_sel; + struct er_account *lbr_ctl; + }; + u64 br_sel; + void *last_task_ctx; + int last_log_id; + int lbr_select; + void *lbr_xsave; + u64 intel_ctrl_guest_mask; + u64 intel_ctrl_host_mask; + struct perf_guest_switch_msr guest_switch_msrs[64]; + u64 intel_cp_status; + struct intel_shared_regs *shared_regs; + struct event_constraint *constraint_list; + struct intel_excl_cntrs *excl_cntrs; + int excl_thread_id; + u64 tfa_shadow; + int n_metric; + struct amd_nb *amd_nb; + u64 perf_ctr_virt_mask; + int n_pair; + void *kfree_on_online[2]; +}; + +struct extra_reg { + unsigned int event; + unsigned int msr; + u64 config_mask; + u64 valid_mask; + int idx; + bool extra_msr_access; +}; + +union perf_capabilities { + struct { + u64 lbr_format: 6; + u64 pebs_trap: 1; + u64 pebs_arch_reg: 1; + u64 pebs_format: 4; + u64 smm_freeze: 1; + u64 full_width_write: 1; + u64 pebs_baseline: 1; + u64 perf_metrics: 1; + u64 pebs_output_pt_available: 1; + }; + u64 capabilities; +}; + +struct x86_pmu_quirk { + struct x86_pmu_quirk *next; + void (*func)(); +}; + +enum { + x86_lbr_exclusive_lbr = 0, + x86_lbr_exclusive_bts = 1, + x86_lbr_exclusive_pt = 2, + x86_lbr_exclusive_max = 3, +}; + +struct x86_pmu { + const char *name; + int version; + int (*handle_irq)(struct pt_regs *); + void (*disable_all)(); + void (*enable_all)(int); + void (*enable)(struct perf_event *); + void (*disable)(struct perf_event *); + void (*add)(struct perf_event *); + void (*del)(struct perf_event *); + void (*read)(struct perf_event *); + int (*hw_config)(struct perf_event *); + int (*schedule_events)(struct cpu_hw_events *, int, int *); + unsigned int eventsel; + unsigned int perfctr; + int (*addr_offset)(int, bool); + int (*rdpmc_index)(int); + u64 (*event_map)(int); + int max_events; + int num_counters; + int num_counters_fixed; + int cntval_bits; + u64 cntval_mask; + union { + long unsigned int events_maskl; + long unsigned int events_mask[1]; + }; + int events_mask_len; + int apic; + u64 max_period; + struct event_constraint * (*get_event_constraints)(struct cpu_hw_events *, int, struct perf_event *); + void (*put_event_constraints)(struct cpu_hw_events *, struct perf_event *); + void (*start_scheduling)(struct cpu_hw_events *); + void (*commit_scheduling)(struct cpu_hw_events *, int, int); + void (*stop_scheduling)(struct cpu_hw_events *); + struct event_constraint *event_constraints; + struct x86_pmu_quirk *quirks; + int perfctr_second_write; + u64 (*limit_period)(struct perf_event *, u64); + unsigned int late_ack: 1; + unsigned int enabled_ack: 1; + unsigned int counter_freezing: 1; + int attr_rdpmc_broken; + int attr_rdpmc; + struct attribute **format_attrs; + ssize_t (*events_sysfs_show)(char *, u64); + const struct attribute_group **attr_update; + long unsigned int attr_freeze_on_smi; + int (*cpu_prepare)(int); + void (*cpu_starting)(int); + void (*cpu_dying)(int); + void (*cpu_dead)(int); + void (*check_microcode)(); + void (*sched_task)(struct perf_event_context *, bool); + u64 intel_ctrl; + union perf_capabilities intel_cap; + unsigned int bts: 1; + unsigned int bts_active: 1; + unsigned int pebs: 1; + unsigned int pebs_active: 1; + unsigned int pebs_broken: 1; + unsigned int pebs_prec_dist: 1; + unsigned int pebs_no_tlb: 1; + unsigned int pebs_no_isolation: 1; + int pebs_record_size; + int pebs_buffer_size; + int max_pebs_events; + void (*drain_pebs)(struct pt_regs *); + struct event_constraint *pebs_constraints; + void (*pebs_aliases)(struct perf_event *); + long unsigned int large_pebs_flags; + u64 rtm_abort_event; + unsigned int lbr_tos; + unsigned int lbr_from; + unsigned int lbr_to; + unsigned int lbr_info; + unsigned int lbr_nr; + union { + u64 lbr_sel_mask; + u64 lbr_ctl_mask; + }; + union { + const int *lbr_sel_map; + int *lbr_ctl_map; + }; + bool lbr_double_abort; + bool lbr_pt_coexist; + unsigned int lbr_depth_mask: 8; + unsigned int lbr_deep_c_reset: 1; + unsigned int lbr_lip: 1; + unsigned int lbr_cpl: 1; + unsigned int lbr_filter: 1; + unsigned int lbr_call_stack: 1; + unsigned int lbr_mispred: 1; + unsigned int lbr_timed_lbr: 1; + unsigned int lbr_br_type: 1; + void (*lbr_reset)(); + void (*lbr_read)(struct cpu_hw_events *); + void (*lbr_save)(void *); + void (*lbr_restore)(void *); + atomic_t lbr_exclusive[3]; + u64 (*update_topdown_event)(struct perf_event *); + int (*set_topdown_event_period)(struct perf_event *); + void (*swap_task_ctx)(struct perf_event_context *, struct perf_event_context *); + unsigned int amd_nb_constraints: 1; + u64 perf_ctr_pair_en; + struct extra_reg *extra_regs; + unsigned int flags; + struct perf_guest_switch_msr * (*guest_get_msrs)(int *); + int (*check_period)(struct perf_event *, u64); + int (*aux_output_match)(struct perf_event *); +}; + +struct sched_state { + int weight; + int event; + int counter; + int unassigned; + int nr_gp; + u64 used; +}; + +struct perf_sched { + int max_weight; + int max_events; + int max_gp; + int saved_states; + struct event_constraint **constraints; + struct sched_state state; + struct sched_state saved[2]; +}; + +struct perf_msr { + u64 msr; + struct attribute_group *grp; + bool (*test)(int, void *); + bool no_check; +}; + +struct kobj_attribute { + struct attribute attr; + ssize_t (*show)(struct kobject *, struct kobj_attribute *, char *); + ssize_t (*store)(struct kobject *, struct kobj_attribute *, const char *, size_t); +}; + +struct amd_uncore { + int id; + int refcnt; + int cpu; + int num_counters; + int rdpmc_base; + u32 msr_base; + cpumask_t *active_mask; + struct pmu *pmu; + struct perf_event *events[6]; + struct hlist_node node; +}; + +typedef int pci_power_t; + +typedef unsigned int pci_channel_state_t; + +typedef short unsigned int pci_dev_flags_t; + +struct pci_bus; + +struct pci_slot; + +struct pci_driver; + +struct pcie_link_state; + +struct pci_vpd; + +struct pci_sriov; + +struct pci_dev { + struct list_head bus_list; + struct pci_bus *bus; + struct pci_bus *subordinate; + void *sysdata; + struct proc_dir_entry *procent; + struct pci_slot *slot; + unsigned int devfn; + short unsigned int vendor; + short unsigned int device; + short unsigned int subsystem_vendor; + short unsigned int subsystem_device; + unsigned int class; + u8 revision; + u8 hdr_type; + u8 pcie_cap; + u8 msi_cap; + u8 msix_cap; + u8 pcie_mpss: 3; + u8 rom_base_reg; + u8 pin; + u16 pcie_flags_reg; + long unsigned int *dma_alias_mask; + struct pci_driver *driver; + u64 dma_mask; + struct device_dma_parameters dma_parms; + pci_power_t current_state; + unsigned int imm_ready: 1; + u8 pm_cap; + unsigned int pme_support: 5; + unsigned int pme_poll: 1; + unsigned int d1_support: 1; + unsigned int d2_support: 1; + unsigned int no_d1d2: 1; + unsigned int no_d3cold: 1; + unsigned int bridge_d3: 1; + unsigned int d3cold_allowed: 1; + unsigned int mmio_always_on: 1; + unsigned int wakeup_prepared: 1; + unsigned int runtime_d3cold: 1; + unsigned int skip_bus_pm: 1; + unsigned int ignore_hotplug: 1; + unsigned int hotplug_user_indicators: 1; + unsigned int clear_retrain_link: 1; + unsigned int d3hot_delay; + unsigned int d3cold_delay; + struct pcie_link_state *link_state; + unsigned int ltr_path: 1; + int l1ss; + unsigned int eetlp_prefix_path: 1; + pci_channel_state_t error_state; + struct device dev; + int cfg_size; + unsigned int irq; + struct resource resource[17]; + bool match_driver; + unsigned int transparent: 1; + unsigned int io_window: 1; + unsigned int pref_window: 1; + unsigned int pref_64_window: 1; + unsigned int multifunction: 1; + unsigned int is_busmaster: 1; + unsigned int no_msi: 1; + unsigned int no_64bit_msi: 1; + unsigned int block_cfg_access: 1; + unsigned int broken_parity_status: 1; + unsigned int irq_reroute_variant: 2; + unsigned int msi_enabled: 1; + unsigned int msix_enabled: 1; + unsigned int ari_enabled: 1; + unsigned int ats_enabled: 1; + unsigned int pasid_enabled: 1; + unsigned int pri_enabled: 1; + unsigned int is_managed: 1; + unsigned int needs_freset: 1; + unsigned int state_saved: 1; + unsigned int is_physfn: 1; + unsigned int is_virtfn: 1; + unsigned int reset_fn: 1; + unsigned int is_hotplug_bridge: 1; + unsigned int shpc_managed: 1; + unsigned int is_thunderbolt: 1; + unsigned int untrusted: 1; + unsigned int external_facing: 1; + unsigned int broken_intx_masking: 1; + unsigned int io_window_1k: 1; + unsigned int irq_managed: 1; + unsigned int non_compliant_bars: 1; + unsigned int is_probed: 1; + unsigned int link_active_reporting: 1; + unsigned int no_vf_scan: 1; + unsigned int no_command_memory: 1; + pci_dev_flags_t dev_flags; + atomic_t enable_cnt; + u32 saved_config_space[16]; + struct hlist_head saved_cap_space; + struct bin_attribute *rom_attr; + int rom_attr_enabled; + struct bin_attribute *res_attr[17]; + struct bin_attribute *res_attr_wc[17]; + const struct attribute_group **msi_irq_groups; + struct pci_vpd *vpd; + union { + struct pci_sriov *sriov; + struct pci_dev *physfn; + }; + u16 ats_cap; + u8 ats_stu; + u16 acs_cap; + phys_addr_t rom; + size_t romlen; + char *driver_override; + long unsigned int priv_flags; +}; + +struct pci_device_id { + __u32 vendor; + __u32 device; + __u32 subvendor; + __u32 subdevice; + __u32 class; + __u32 class_mask; + kernel_ulong_t driver_data; +}; + +struct hotplug_slot; + +struct pci_slot { + struct pci_bus *bus; + struct list_head list; + struct hotplug_slot *hotplug; + unsigned char number; + struct kobject kobj; +}; + +typedef short unsigned int pci_bus_flags_t; + +struct pci_ops; + +struct msi_controller; + +struct pci_bus { + struct list_head node; + struct pci_bus *parent; + struct list_head children; + struct list_head devices; + struct pci_dev *self; + struct list_head slots; + struct resource *resource[4]; + struct list_head resources; + struct resource busn_res; + struct pci_ops *ops; + struct msi_controller *msi; + void *sysdata; + struct proc_dir_entry *procdir; + unsigned char number; + unsigned char primary; + unsigned char max_bus_speed; + unsigned char cur_bus_speed; + char name[48]; + short unsigned int bridge_ctl; + pci_bus_flags_t bus_flags; + struct device *bridge; + struct device dev; + struct bin_attribute *legacy_io; + struct bin_attribute *legacy_mem; + unsigned int is_added: 1; +}; + +enum { + PCI_STD_RESOURCES = 0, + PCI_STD_RESOURCE_END = 5, + PCI_ROM_RESOURCE = 6, + PCI_IOV_RESOURCES = 7, + PCI_IOV_RESOURCE_END = 12, + PCI_BRIDGE_RESOURCES = 13, + PCI_BRIDGE_RESOURCE_END = 16, + PCI_NUM_RESOURCES = 17, + DEVICE_COUNT_RESOURCE = 17, +}; + +typedef unsigned int pcie_reset_state_t; + +struct pci_dynids { + spinlock_t lock; + struct list_head list; +}; + +struct pci_error_handlers; + +struct pci_driver { + struct list_head node; + const char *name; + const struct pci_device_id *id_table; + int (*probe)(struct pci_dev *, const struct pci_device_id *); + void (*remove)(struct pci_dev *); + int (*suspend)(struct pci_dev *, pm_message_t); + int (*resume)(struct pci_dev *); + void (*shutdown)(struct pci_dev *); + int (*sriov_configure)(struct pci_dev *, int); + const struct pci_error_handlers *err_handler; + const struct attribute_group **groups; + struct device_driver driver; + struct pci_dynids dynids; +}; + +struct pci_ops { + int (*add_bus)(struct pci_bus *); + void (*remove_bus)(struct pci_bus *); + void * (*map_bus)(struct pci_bus *, unsigned int, int); + int (*read)(struct pci_bus *, unsigned int, int, int, u32 *); + int (*write)(struct pci_bus *, unsigned int, int, int, u32); +}; + +typedef unsigned int pci_ers_result_t; + +struct pci_error_handlers { + pci_ers_result_t (*error_detected)(struct pci_dev *, pci_channel_state_t); + pci_ers_result_t (*mmio_enabled)(struct pci_dev *); + pci_ers_result_t (*slot_reset)(struct pci_dev *); + void (*reset_prepare)(struct pci_dev *); + void (*reset_done)(struct pci_dev *); + void (*resume)(struct pci_dev *); +}; + +struct syscore_ops { + struct list_head node; + int (*suspend)(); + void (*resume)(); + void (*shutdown)(); +}; + +enum ibs_states { + IBS_ENABLED = 0, + IBS_STARTED = 1, + IBS_STOPPING = 2, + IBS_STOPPED = 3, + IBS_MAX_STATES = 4, +}; + +struct cpu_perf_ibs { + struct perf_event *event; + long unsigned int state[1]; +}; + +struct perf_ibs { + struct pmu pmu; + unsigned int msr; + u64 config_mask; + u64 cnt_mask; + u64 enable_mask; + u64 valid_mask; + u64 max_period; + long unsigned int offset_mask[1]; + int offset_max; + unsigned int fetch_count_reset_broken: 1; + struct cpu_perf_ibs *pcpu; + struct attribute **format_attrs; + struct attribute_group format_group; + const struct attribute_group *attr_groups[2]; + u64 (*get_count)(u64); +}; + +struct perf_ibs_data { + u32 size; + union { + u32 data[0]; + u32 caps; + }; + u64 regs[8]; +}; + +enum perf_msr_id { + PERF_MSR_TSC = 0, + PERF_MSR_APERF = 1, + PERF_MSR_MPERF = 2, + PERF_MSR_PPERF = 3, + PERF_MSR_SMI = 4, + PERF_MSR_PTSC = 5, + PERF_MSR_IRPERF = 6, + PERF_MSR_THERM = 7, + PERF_MSR_EVENT_MAX = 8, +}; + +enum lockdep_wait_type { + LD_WAIT_INV = 0, + LD_WAIT_FREE = 1, + LD_WAIT_SPIN = 2, + LD_WAIT_CONFIG = 2, + LD_WAIT_SLEEP = 3, + LD_WAIT_MAX = 4, +}; + +struct x86_cpu_desc { + u8 x86_family; + u8 x86_vendor; + u8 x86_model; + u8 x86_stepping; + u32 x86_microcode_rev; +}; + +union cpuid10_eax { + struct { + unsigned int version_id: 8; + unsigned int num_counters: 8; + unsigned int bit_width: 8; + unsigned int mask_length: 8; + } split; + unsigned int full; +}; + +union cpuid10_ebx { + struct { + unsigned int no_unhalted_core_cycles: 1; + unsigned int no_instructions_retired: 1; + unsigned int no_unhalted_reference_cycles: 1; + unsigned int no_llc_reference: 1; + unsigned int no_llc_misses: 1; + unsigned int no_branch_instruction_retired: 1; + unsigned int no_branch_misses_retired: 1; + } split; + unsigned int full; +}; + +union cpuid10_edx { + struct { + unsigned int num_counters_fixed: 5; + unsigned int bit_width_fixed: 8; + unsigned int reserved: 19; + } split; + unsigned int full; +}; + +enum { + LBR_FORMAT_32 = 0, + LBR_FORMAT_LIP = 1, + LBR_FORMAT_EIP = 2, + LBR_FORMAT_EIP_FLAGS = 3, + LBR_FORMAT_EIP_FLAGS2 = 4, + LBR_FORMAT_INFO = 5, + LBR_FORMAT_TIME = 6, + LBR_FORMAT_MAX_KNOWN = 6, +}; + +union x86_pmu_config { + struct { + u64 event: 8; + u64 umask: 8; + u64 usr: 1; + u64 os: 1; + u64 edge: 1; + u64 pc: 1; + u64 interrupt: 1; + u64 __reserved1: 1; + u64 en: 1; + u64 inv: 1; + u64 cmask: 8; + u64 event2: 4; + u64 __reserved2: 4; + u64 go: 1; + u64 ho: 1; + } bits; + u64 value; +}; + +enum pageflags { + PG_locked = 0, + PG_referenced = 1, + PG_uptodate = 2, + PG_dirty = 3, + PG_lru = 4, + PG_active = 5, + PG_workingset = 6, + PG_waiters = 7, + PG_error = 8, + PG_slab = 9, + PG_owner_priv_1 = 10, + PG_arch_1 = 11, + PG_reserved = 12, + PG_private = 13, + PG_private_2 = 14, + PG_writeback = 15, + PG_head = 16, + PG_mappedtodisk = 17, + PG_reclaim = 18, + PG_swapbacked = 19, + PG_unevictable = 20, + PG_mlocked = 21, + PG_uncached = 22, + PG_hwpoison = 23, + PG_arch_2 = 24, + __NR_PAGEFLAGS = 25, + PG_checked = 10, + PG_swapcache = 10, + PG_fscache = 14, + PG_pinned = 10, + PG_savepinned = 3, + PG_foreign = 10, + PG_xen_remapped = 10, + PG_slob_free = 13, + PG_double_map = 6, + PG_isolated = 18, + PG_reported = 2, +}; + +struct bts_ctx { + struct perf_output_handle handle; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct debug_store ds_back; + int state; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +enum { + BTS_STATE_STOPPED = 0, + BTS_STATE_INACTIVE = 1, + BTS_STATE_ACTIVE = 2, +}; + +struct bts_phys { + struct page *page; + long unsigned int size; + long unsigned int offset; + long unsigned int displacement; +}; + +struct bts_buffer { + size_t real_size; + unsigned int nr_pages; + unsigned int nr_bufs; + unsigned int cur_buf; + bool snapshot; + local_t data_size; + local_t head; + long unsigned int end; + void **data_pages; + struct bts_phys buf[0]; +}; + +struct lbr_entry { + u64 from; + u64 to; + u64 info; +}; + +struct pebs_basic { + u64 format_size; + u64 ip; + u64 applicable_counters; + u64 tsc; +}; + +struct pebs_meminfo { + u64 address; + u64 aux; + u64 latency; + u64 tsx_tuning; +}; + +struct pebs_gprs { + u64 flags; + u64 ip; + u64 ax; + u64 cx; + u64 dx; + u64 bx; + u64 sp; + u64 bp; + u64 si; + u64 di; + u64 r8; + u64 r9; + u64 r10; + u64 r11; + u64 r12; + u64 r13; + u64 r14; + u64 r15; +}; + +struct pebs_xmm { + u64 xmm[32]; +}; + +struct x86_perf_regs { + struct pt_regs regs; + u64 *xmm_regs; +}; + +typedef unsigned int insn_attr_t; + +typedef unsigned char insn_byte_t; + +typedef int insn_value_t; + +struct insn_field { + union { + insn_value_t value; + insn_byte_t bytes[4]; + }; + unsigned char got; + unsigned char nbytes; +}; + +struct insn { + struct insn_field prefixes; + struct insn_field rex_prefix; + struct insn_field vex_prefix; + struct insn_field opcode; + struct insn_field modrm; + struct insn_field sib; + struct insn_field displacement; + union { + struct insn_field immediate; + struct insn_field moffset1; + struct insn_field immediate1; + }; + union { + struct insn_field moffset2; + struct insn_field immediate2; + }; + int emulate_prefix_size; + insn_attr_t attr; + unsigned char opnd_bytes; + unsigned char addr_bytes; + unsigned char length; + unsigned char x86_64; + const insn_byte_t *kaddr; + const insn_byte_t *end_kaddr; + const insn_byte_t *next_byte; +}; + +enum { + PERF_TXN_ELISION = 1, + PERF_TXN_TRANSACTION = 2, + PERF_TXN_SYNC = 4, + PERF_TXN_ASYNC = 8, + PERF_TXN_RETRY = 16, + PERF_TXN_CONFLICT = 32, + PERF_TXN_CAPACITY_WRITE = 64, + PERF_TXN_CAPACITY_READ = 128, + PERF_TXN_MAX = 256, + PERF_TXN_ABORT_MASK = 0, + PERF_TXN_ABORT_SHIFT = 32, +}; + +struct perf_event_header { + __u32 type; + __u16 misc; + __u16 size; +}; + +union intel_x86_pebs_dse { + u64 val; + struct { + unsigned int ld_dse: 4; + unsigned int ld_stlb_miss: 1; + unsigned int ld_locked: 1; + unsigned int ld_reserved: 26; + }; + struct { + unsigned int st_l1d_hit: 1; + unsigned int st_reserved1: 3; + unsigned int st_stlb_miss: 1; + unsigned int st_locked: 1; + unsigned int st_reserved2: 26; + }; +}; + +struct pebs_record_core { + u64 flags; + u64 ip; + u64 ax; + u64 bx; + u64 cx; + u64 dx; + u64 si; + u64 di; + u64 bp; + u64 sp; + u64 r8; + u64 r9; + u64 r10; + u64 r11; + u64 r12; + u64 r13; + u64 r14; + u64 r15; +}; + +struct pebs_record_nhm { + u64 flags; + u64 ip; + u64 ax; + u64 bx; + u64 cx; + u64 dx; + u64 si; + u64 di; + u64 bp; + u64 sp; + u64 r8; + u64 r9; + u64 r10; + u64 r11; + u64 r12; + u64 r13; + u64 r14; + u64 r15; + u64 status; + u64 dla; + u64 dse; + u64 lat; +}; + +union hsw_tsx_tuning { + struct { + u32 cycles_last_block: 32; + u32 hle_abort: 1; + u32 rtm_abort: 1; + u32 instruction_abort: 1; + u32 non_instruction_abort: 1; + u32 retry: 1; + u32 data_conflict: 1; + u32 capacity_writes: 1; + u32 capacity_reads: 1; + }; + u64 value; +}; + +struct pebs_record_skl { + u64 flags; + u64 ip; + u64 ax; + u64 bx; + u64 cx; + u64 dx; + u64 si; + u64 di; + u64 bp; + u64 sp; + u64 r8; + u64 r9; + u64 r10; + u64 r11; + u64 r12; + u64 r13; + u64 r14; + u64 r15; + u64 status; + u64 dla; + u64 dse; + u64 lat; + u64 real_ip; + u64 tsx_tuning; + u64 tsc; +}; + +struct bts_record { + u64 from; + u64 to; + u64 flags; +}; + +enum { + PERF_BR_UNKNOWN = 0, + PERF_BR_COND = 1, + PERF_BR_UNCOND = 2, + PERF_BR_IND = 3, + PERF_BR_CALL = 4, + PERF_BR_IND_CALL = 5, + PERF_BR_RET = 6, + PERF_BR_SYSCALL = 7, + PERF_BR_SYSRET = 8, + PERF_BR_COND_CALL = 9, + PERF_BR_COND_RET = 10, + PERF_BR_MAX = 11, +}; + +enum xfeature { + XFEATURE_FP = 0, + XFEATURE_SSE = 1, + XFEATURE_YMM = 2, + XFEATURE_BNDREGS = 3, + XFEATURE_BNDCSR = 4, + XFEATURE_OPMASK = 5, + XFEATURE_ZMM_Hi256 = 6, + XFEATURE_Hi16_ZMM = 7, + XFEATURE_PT_UNIMPLEMENTED_SO_FAR = 8, + XFEATURE_PKRU = 9, + XFEATURE_PASID = 10, + XFEATURE_RSRVD_COMP_11 = 11, + XFEATURE_RSRVD_COMP_12 = 12, + XFEATURE_RSRVD_COMP_13 = 13, + XFEATURE_RSRVD_COMP_14 = 14, + XFEATURE_LBR = 15, + XFEATURE_MAX = 16, +}; + +struct arch_lbr_state { + u64 lbr_ctl; + u64 lbr_depth; + u64 ler_from; + u64 ler_to; + u64 ler_info; + struct lbr_entry entries[0]; +}; + +union cpuid28_eax { + struct { + unsigned int lbr_depth_mask: 8; + unsigned int reserved: 22; + unsigned int lbr_deep_c_reset: 1; + unsigned int lbr_lip: 1; + } split; + unsigned int full; +}; + +union cpuid28_ebx { + struct { + unsigned int lbr_cpl: 1; + unsigned int lbr_filter: 1; + unsigned int lbr_call_stack: 1; + } split; + unsigned int full; +}; + +union cpuid28_ecx { + struct { + unsigned int lbr_mispred: 1; + unsigned int lbr_timed_lbr: 1; + unsigned int lbr_br_type: 1; + } split; + unsigned int full; +}; + +struct x86_pmu_lbr { + unsigned int nr; + unsigned int from; + unsigned int to; + unsigned int info; +}; + +struct x86_perf_task_context_opt { + int lbr_callstack_users; + int lbr_stack_state; + int log_id; +}; + +struct x86_perf_task_context { + u64 lbr_sel; + int tos; + int valid_lbrs; + struct x86_perf_task_context_opt opt; + struct lbr_entry lbr[32]; +}; + +struct x86_perf_task_context_arch_lbr { + struct x86_perf_task_context_opt opt; + struct lbr_entry entries[0]; +}; + +struct x86_perf_task_context_arch_lbr_xsave { + struct x86_perf_task_context_opt opt; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + union { + struct xregs_state xsave; + struct { + struct fxregs_state i387; + struct xstate_header header; + struct arch_lbr_state lbr; + long: 64; + long: 64; + long: 64; + }; + }; +}; + +enum { + X86_BR_NONE = 0, + X86_BR_USER = 1, + X86_BR_KERNEL = 2, + X86_BR_CALL = 4, + X86_BR_RET = 8, + X86_BR_SYSCALL = 16, + X86_BR_SYSRET = 32, + X86_BR_INT = 64, + X86_BR_IRET = 128, + X86_BR_JCC = 256, + X86_BR_JMP = 512, + X86_BR_IRQ = 1024, + X86_BR_IND_CALL = 2048, + X86_BR_ABORT = 4096, + X86_BR_IN_TX = 8192, + X86_BR_NO_TX = 16384, + X86_BR_ZERO_CALL = 32768, + X86_BR_CALL_STACK = 65536, + X86_BR_IND_JMP = 131072, + X86_BR_TYPE_SAVE = 262144, +}; + +enum { + LBR_NONE = 0, + LBR_VALID = 1, +}; + +enum { + ARCH_LBR_BR_TYPE_JCC = 0, + ARCH_LBR_BR_TYPE_NEAR_IND_JMP = 1, + ARCH_LBR_BR_TYPE_NEAR_REL_JMP = 2, + ARCH_LBR_BR_TYPE_NEAR_IND_CALL = 3, + ARCH_LBR_BR_TYPE_NEAR_REL_CALL = 4, + ARCH_LBR_BR_TYPE_NEAR_RET = 5, + ARCH_LBR_BR_TYPE_KNOWN_MAX = 5, + ARCH_LBR_BR_TYPE_MAP_MAX = 16, +}; + +enum P4_EVENTS { + P4_EVENT_TC_DELIVER_MODE = 0, + P4_EVENT_BPU_FETCH_REQUEST = 1, + P4_EVENT_ITLB_REFERENCE = 2, + P4_EVENT_MEMORY_CANCEL = 3, + P4_EVENT_MEMORY_COMPLETE = 4, + P4_EVENT_LOAD_PORT_REPLAY = 5, + P4_EVENT_STORE_PORT_REPLAY = 6, + P4_EVENT_MOB_LOAD_REPLAY = 7, + P4_EVENT_PAGE_WALK_TYPE = 8, + P4_EVENT_BSQ_CACHE_REFERENCE = 9, + P4_EVENT_IOQ_ALLOCATION = 10, + P4_EVENT_IOQ_ACTIVE_ENTRIES = 11, + P4_EVENT_FSB_DATA_ACTIVITY = 12, + P4_EVENT_BSQ_ALLOCATION = 13, + P4_EVENT_BSQ_ACTIVE_ENTRIES = 14, + P4_EVENT_SSE_INPUT_ASSIST = 15, + P4_EVENT_PACKED_SP_UOP = 16, + P4_EVENT_PACKED_DP_UOP = 17, + P4_EVENT_SCALAR_SP_UOP = 18, + P4_EVENT_SCALAR_DP_UOP = 19, + P4_EVENT_64BIT_MMX_UOP = 20, + P4_EVENT_128BIT_MMX_UOP = 21, + P4_EVENT_X87_FP_UOP = 22, + P4_EVENT_TC_MISC = 23, + P4_EVENT_GLOBAL_POWER_EVENTS = 24, + P4_EVENT_TC_MS_XFER = 25, + P4_EVENT_UOP_QUEUE_WRITES = 26, + P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE = 27, + P4_EVENT_RETIRED_BRANCH_TYPE = 28, + P4_EVENT_RESOURCE_STALL = 29, + P4_EVENT_WC_BUFFER = 30, + P4_EVENT_B2B_CYCLES = 31, + P4_EVENT_BNR = 32, + P4_EVENT_SNOOP = 33, + P4_EVENT_RESPONSE = 34, + P4_EVENT_FRONT_END_EVENT = 35, + P4_EVENT_EXECUTION_EVENT = 36, + P4_EVENT_REPLAY_EVENT = 37, + P4_EVENT_INSTR_RETIRED = 38, + P4_EVENT_UOPS_RETIRED = 39, + P4_EVENT_UOP_TYPE = 40, + P4_EVENT_BRANCH_RETIRED = 41, + P4_EVENT_MISPRED_BRANCH_RETIRED = 42, + P4_EVENT_X87_ASSIST = 43, + P4_EVENT_MACHINE_CLEAR = 44, + P4_EVENT_INSTR_COMPLETED = 45, +}; + +enum P4_EVENT_OPCODES { + P4_EVENT_TC_DELIVER_MODE_OPCODE = 257, + P4_EVENT_BPU_FETCH_REQUEST_OPCODE = 768, + P4_EVENT_ITLB_REFERENCE_OPCODE = 6147, + P4_EVENT_MEMORY_CANCEL_OPCODE = 517, + P4_EVENT_MEMORY_COMPLETE_OPCODE = 2050, + P4_EVENT_LOAD_PORT_REPLAY_OPCODE = 1026, + P4_EVENT_STORE_PORT_REPLAY_OPCODE = 1282, + P4_EVENT_MOB_LOAD_REPLAY_OPCODE = 770, + P4_EVENT_PAGE_WALK_TYPE_OPCODE = 260, + P4_EVENT_BSQ_CACHE_REFERENCE_OPCODE = 3079, + P4_EVENT_IOQ_ALLOCATION_OPCODE = 774, + P4_EVENT_IOQ_ACTIVE_ENTRIES_OPCODE = 6662, + P4_EVENT_FSB_DATA_ACTIVITY_OPCODE = 5894, + P4_EVENT_BSQ_ALLOCATION_OPCODE = 1287, + P4_EVENT_BSQ_ACTIVE_ENTRIES_OPCODE = 1543, + P4_EVENT_SSE_INPUT_ASSIST_OPCODE = 13313, + P4_EVENT_PACKED_SP_UOP_OPCODE = 2049, + P4_EVENT_PACKED_DP_UOP_OPCODE = 3073, + P4_EVENT_SCALAR_SP_UOP_OPCODE = 2561, + P4_EVENT_SCALAR_DP_UOP_OPCODE = 3585, + P4_EVENT_64BIT_MMX_UOP_OPCODE = 513, + P4_EVENT_128BIT_MMX_UOP_OPCODE = 6657, + P4_EVENT_X87_FP_UOP_OPCODE = 1025, + P4_EVENT_TC_MISC_OPCODE = 1537, + P4_EVENT_GLOBAL_POWER_EVENTS_OPCODE = 4870, + P4_EVENT_TC_MS_XFER_OPCODE = 1280, + P4_EVENT_UOP_QUEUE_WRITES_OPCODE = 2304, + P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE_OPCODE = 1282, + P4_EVENT_RETIRED_BRANCH_TYPE_OPCODE = 1026, + P4_EVENT_RESOURCE_STALL_OPCODE = 257, + P4_EVENT_WC_BUFFER_OPCODE = 1285, + P4_EVENT_B2B_CYCLES_OPCODE = 5635, + P4_EVENT_BNR_OPCODE = 2051, + P4_EVENT_SNOOP_OPCODE = 1539, + P4_EVENT_RESPONSE_OPCODE = 1027, + P4_EVENT_FRONT_END_EVENT_OPCODE = 2053, + P4_EVENT_EXECUTION_EVENT_OPCODE = 3077, + P4_EVENT_REPLAY_EVENT_OPCODE = 2309, + P4_EVENT_INSTR_RETIRED_OPCODE = 516, + P4_EVENT_UOPS_RETIRED_OPCODE = 260, + P4_EVENT_UOP_TYPE_OPCODE = 514, + P4_EVENT_BRANCH_RETIRED_OPCODE = 1541, + P4_EVENT_MISPRED_BRANCH_RETIRED_OPCODE = 772, + P4_EVENT_X87_ASSIST_OPCODE = 773, + P4_EVENT_MACHINE_CLEAR_OPCODE = 517, + P4_EVENT_INSTR_COMPLETED_OPCODE = 1796, +}; + +enum P4_ESCR_EMASKS { + P4_EVENT_TC_DELIVER_MODE__DD = 512, + P4_EVENT_TC_DELIVER_MODE__DB = 1024, + P4_EVENT_TC_DELIVER_MODE__DI = 2048, + P4_EVENT_TC_DELIVER_MODE__BD = 4096, + P4_EVENT_TC_DELIVER_MODE__BB = 8192, + P4_EVENT_TC_DELIVER_MODE__BI = 16384, + P4_EVENT_TC_DELIVER_MODE__ID = 32768, + P4_EVENT_BPU_FETCH_REQUEST__TCMISS = 512, + P4_EVENT_ITLB_REFERENCE__HIT = 512, + P4_EVENT_ITLB_REFERENCE__MISS = 1024, + P4_EVENT_ITLB_REFERENCE__HIT_UK = 2048, + P4_EVENT_MEMORY_CANCEL__ST_RB_FULL = 2048, + P4_EVENT_MEMORY_CANCEL__64K_CONF = 4096, + P4_EVENT_MEMORY_COMPLETE__LSC = 512, + P4_EVENT_MEMORY_COMPLETE__SSC = 1024, + P4_EVENT_LOAD_PORT_REPLAY__SPLIT_LD = 1024, + P4_EVENT_STORE_PORT_REPLAY__SPLIT_ST = 1024, + P4_EVENT_MOB_LOAD_REPLAY__NO_STA = 1024, + P4_EVENT_MOB_LOAD_REPLAY__NO_STD = 4096, + P4_EVENT_MOB_LOAD_REPLAY__PARTIAL_DATA = 8192, + P4_EVENT_MOB_LOAD_REPLAY__UNALGN_ADDR = 16384, + P4_EVENT_PAGE_WALK_TYPE__DTMISS = 512, + P4_EVENT_PAGE_WALK_TYPE__ITMISS = 1024, + P4_EVENT_BSQ_CACHE_REFERENCE__RD_2ndL_HITS = 512, + P4_EVENT_BSQ_CACHE_REFERENCE__RD_2ndL_HITE = 1024, + P4_EVENT_BSQ_CACHE_REFERENCE__RD_2ndL_HITM = 2048, + P4_EVENT_BSQ_CACHE_REFERENCE__RD_3rdL_HITS = 4096, + P4_EVENT_BSQ_CACHE_REFERENCE__RD_3rdL_HITE = 8192, + P4_EVENT_BSQ_CACHE_REFERENCE__RD_3rdL_HITM = 16384, + P4_EVENT_BSQ_CACHE_REFERENCE__RD_2ndL_MISS = 131072, + P4_EVENT_BSQ_CACHE_REFERENCE__RD_3rdL_MISS = 262144, + P4_EVENT_BSQ_CACHE_REFERENCE__WR_2ndL_MISS = 524288, + P4_EVENT_IOQ_ALLOCATION__DEFAULT = 512, + P4_EVENT_IOQ_ALLOCATION__ALL_READ = 16384, + P4_EVENT_IOQ_ALLOCATION__ALL_WRITE = 32768, + P4_EVENT_IOQ_ALLOCATION__MEM_UC = 65536, + P4_EVENT_IOQ_ALLOCATION__MEM_WC = 131072, + P4_EVENT_IOQ_ALLOCATION__MEM_WT = 262144, + P4_EVENT_IOQ_ALLOCATION__MEM_WP = 524288, + P4_EVENT_IOQ_ALLOCATION__MEM_WB = 1048576, + P4_EVENT_IOQ_ALLOCATION__OWN = 4194304, + P4_EVENT_IOQ_ALLOCATION__OTHER = 8388608, + P4_EVENT_IOQ_ALLOCATION__PREFETCH = 16777216, + P4_EVENT_IOQ_ACTIVE_ENTRIES__DEFAULT = 512, + P4_EVENT_IOQ_ACTIVE_ENTRIES__ALL_READ = 16384, + P4_EVENT_IOQ_ACTIVE_ENTRIES__ALL_WRITE = 32768, + P4_EVENT_IOQ_ACTIVE_ENTRIES__MEM_UC = 65536, + P4_EVENT_IOQ_ACTIVE_ENTRIES__MEM_WC = 131072, + P4_EVENT_IOQ_ACTIVE_ENTRIES__MEM_WT = 262144, + P4_EVENT_IOQ_ACTIVE_ENTRIES__MEM_WP = 524288, + P4_EVENT_IOQ_ACTIVE_ENTRIES__MEM_WB = 1048576, + P4_EVENT_IOQ_ACTIVE_ENTRIES__OWN = 4194304, + P4_EVENT_IOQ_ACTIVE_ENTRIES__OTHER = 8388608, + P4_EVENT_IOQ_ACTIVE_ENTRIES__PREFETCH = 16777216, + P4_EVENT_FSB_DATA_ACTIVITY__DRDY_DRV = 512, + P4_EVENT_FSB_DATA_ACTIVITY__DRDY_OWN = 1024, + P4_EVENT_FSB_DATA_ACTIVITY__DRDY_OTHER = 2048, + P4_EVENT_FSB_DATA_ACTIVITY__DBSY_DRV = 4096, + P4_EVENT_FSB_DATA_ACTIVITY__DBSY_OWN = 8192, + P4_EVENT_FSB_DATA_ACTIVITY__DBSY_OTHER = 16384, + P4_EVENT_BSQ_ALLOCATION__REQ_TYPE0 = 512, + P4_EVENT_BSQ_ALLOCATION__REQ_TYPE1 = 1024, + P4_EVENT_BSQ_ALLOCATION__REQ_LEN0 = 2048, + P4_EVENT_BSQ_ALLOCATION__REQ_LEN1 = 4096, + P4_EVENT_BSQ_ALLOCATION__REQ_IO_TYPE = 16384, + P4_EVENT_BSQ_ALLOCATION__REQ_LOCK_TYPE = 32768, + P4_EVENT_BSQ_ALLOCATION__REQ_CACHE_TYPE = 65536, + P4_EVENT_BSQ_ALLOCATION__REQ_SPLIT_TYPE = 131072, + P4_EVENT_BSQ_ALLOCATION__REQ_DEM_TYPE = 262144, + P4_EVENT_BSQ_ALLOCATION__REQ_ORD_TYPE = 524288, + P4_EVENT_BSQ_ALLOCATION__MEM_TYPE0 = 1048576, + P4_EVENT_BSQ_ALLOCATION__MEM_TYPE1 = 2097152, + P4_EVENT_BSQ_ALLOCATION__MEM_TYPE2 = 4194304, + P4_EVENT_BSQ_ACTIVE_ENTRIES__REQ_TYPE0 = 512, + P4_EVENT_BSQ_ACTIVE_ENTRIES__REQ_TYPE1 = 1024, + P4_EVENT_BSQ_ACTIVE_ENTRIES__REQ_LEN0 = 2048, + P4_EVENT_BSQ_ACTIVE_ENTRIES__REQ_LEN1 = 4096, + P4_EVENT_BSQ_ACTIVE_ENTRIES__REQ_IO_TYPE = 16384, + P4_EVENT_BSQ_ACTIVE_ENTRIES__REQ_LOCK_TYPE = 32768, + P4_EVENT_BSQ_ACTIVE_ENTRIES__REQ_CACHE_TYPE = 65536, + P4_EVENT_BSQ_ACTIVE_ENTRIES__REQ_SPLIT_TYPE = 131072, + P4_EVENT_BSQ_ACTIVE_ENTRIES__REQ_DEM_TYPE = 262144, + P4_EVENT_BSQ_ACTIVE_ENTRIES__REQ_ORD_TYPE = 524288, + P4_EVENT_BSQ_ACTIVE_ENTRIES__MEM_TYPE0 = 1048576, + P4_EVENT_BSQ_ACTIVE_ENTRIES__MEM_TYPE1 = 2097152, + P4_EVENT_BSQ_ACTIVE_ENTRIES__MEM_TYPE2 = 4194304, + P4_EVENT_SSE_INPUT_ASSIST__ALL = 16777216, + P4_EVENT_PACKED_SP_UOP__ALL = 16777216, + P4_EVENT_PACKED_DP_UOP__ALL = 16777216, + P4_EVENT_SCALAR_SP_UOP__ALL = 16777216, + P4_EVENT_SCALAR_DP_UOP__ALL = 16777216, + P4_EVENT_64BIT_MMX_UOP__ALL = 16777216, + P4_EVENT_128BIT_MMX_UOP__ALL = 16777216, + P4_EVENT_X87_FP_UOP__ALL = 16777216, + P4_EVENT_TC_MISC__FLUSH = 8192, + P4_EVENT_GLOBAL_POWER_EVENTS__RUNNING = 512, + P4_EVENT_TC_MS_XFER__CISC = 512, + P4_EVENT_UOP_QUEUE_WRITES__FROM_TC_BUILD = 512, + P4_EVENT_UOP_QUEUE_WRITES__FROM_TC_DELIVER = 1024, + P4_EVENT_UOP_QUEUE_WRITES__FROM_ROM = 2048, + P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE__CONDITIONAL = 1024, + P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE__CALL = 2048, + P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE__RETURN = 4096, + P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE__INDIRECT = 8192, + P4_EVENT_RETIRED_BRANCH_TYPE__CONDITIONAL = 1024, + P4_EVENT_RETIRED_BRANCH_TYPE__CALL = 2048, + P4_EVENT_RETIRED_BRANCH_TYPE__RETURN = 4096, + P4_EVENT_RETIRED_BRANCH_TYPE__INDIRECT = 8192, + P4_EVENT_RESOURCE_STALL__SBFULL = 16384, + P4_EVENT_WC_BUFFER__WCB_EVICTS = 512, + P4_EVENT_WC_BUFFER__WCB_FULL_EVICTS = 1024, + P4_EVENT_FRONT_END_EVENT__NBOGUS = 512, + P4_EVENT_FRONT_END_EVENT__BOGUS = 1024, + P4_EVENT_EXECUTION_EVENT__NBOGUS0 = 512, + P4_EVENT_EXECUTION_EVENT__NBOGUS1 = 1024, + P4_EVENT_EXECUTION_EVENT__NBOGUS2 = 2048, + P4_EVENT_EXECUTION_EVENT__NBOGUS3 = 4096, + P4_EVENT_EXECUTION_EVENT__BOGUS0 = 8192, + P4_EVENT_EXECUTION_EVENT__BOGUS1 = 16384, + P4_EVENT_EXECUTION_EVENT__BOGUS2 = 32768, + P4_EVENT_EXECUTION_EVENT__BOGUS3 = 65536, + P4_EVENT_REPLAY_EVENT__NBOGUS = 512, + P4_EVENT_REPLAY_EVENT__BOGUS = 1024, + P4_EVENT_INSTR_RETIRED__NBOGUSNTAG = 512, + P4_EVENT_INSTR_RETIRED__NBOGUSTAG = 1024, + P4_EVENT_INSTR_RETIRED__BOGUSNTAG = 2048, + P4_EVENT_INSTR_RETIRED__BOGUSTAG = 4096, + P4_EVENT_UOPS_RETIRED__NBOGUS = 512, + P4_EVENT_UOPS_RETIRED__BOGUS = 1024, + P4_EVENT_UOP_TYPE__TAGLOADS = 1024, + P4_EVENT_UOP_TYPE__TAGSTORES = 2048, + P4_EVENT_BRANCH_RETIRED__MMNP = 512, + P4_EVENT_BRANCH_RETIRED__MMNM = 1024, + P4_EVENT_BRANCH_RETIRED__MMTP = 2048, + P4_EVENT_BRANCH_RETIRED__MMTM = 4096, + P4_EVENT_MISPRED_BRANCH_RETIRED__NBOGUS = 512, + P4_EVENT_X87_ASSIST__FPSU = 512, + P4_EVENT_X87_ASSIST__FPSO = 1024, + P4_EVENT_X87_ASSIST__POAO = 2048, + P4_EVENT_X87_ASSIST__POAU = 4096, + P4_EVENT_X87_ASSIST__PREA = 8192, + P4_EVENT_MACHINE_CLEAR__CLEAR = 512, + P4_EVENT_MACHINE_CLEAR__MOCLEAR = 1024, + P4_EVENT_MACHINE_CLEAR__SMCLEAR = 2048, + P4_EVENT_INSTR_COMPLETED__NBOGUS = 512, + P4_EVENT_INSTR_COMPLETED__BOGUS = 1024, +}; + +enum P4_PEBS_METRIC { + P4_PEBS_METRIC__none = 0, + P4_PEBS_METRIC__1stl_cache_load_miss_retired = 1, + P4_PEBS_METRIC__2ndl_cache_load_miss_retired = 2, + P4_PEBS_METRIC__dtlb_load_miss_retired = 3, + P4_PEBS_METRIC__dtlb_store_miss_retired = 4, + P4_PEBS_METRIC__dtlb_all_miss_retired = 5, + P4_PEBS_METRIC__tagged_mispred_branch = 6, + P4_PEBS_METRIC__mob_load_replay_retired = 7, + P4_PEBS_METRIC__split_load_retired = 8, + P4_PEBS_METRIC__split_store_retired = 9, + P4_PEBS_METRIC__max = 10, +}; + +struct p4_event_bind { + unsigned int opcode; + unsigned int escr_msr[2]; + unsigned int escr_emask; + unsigned int shared; + char cntr[6]; +}; + +struct p4_pebs_bind { + unsigned int metric_pebs; + unsigned int metric_vert; +}; + +struct p4_event_alias { + u64 original; + u64 alternative; +}; + +enum cpuid_regs_idx { + CPUID_EAX = 0, + CPUID_EBX = 1, + CPUID_ECX = 2, + CPUID_EDX = 3, +}; + +struct dev_ext_attribute { + struct device_attribute attr; + void *var; +}; + +enum pt_capabilities { + PT_CAP_max_subleaf = 0, + PT_CAP_cr3_filtering = 1, + PT_CAP_psb_cyc = 2, + PT_CAP_ip_filtering = 3, + PT_CAP_mtc = 4, + PT_CAP_ptwrite = 5, + PT_CAP_power_event_trace = 6, + PT_CAP_topa_output = 7, + PT_CAP_topa_multiple_entries = 8, + PT_CAP_single_range_output = 9, + PT_CAP_output_subsys = 10, + PT_CAP_payloads_lip = 11, + PT_CAP_num_address_ranges = 12, + PT_CAP_mtc_periods = 13, + PT_CAP_cycle_thresholds = 14, + PT_CAP_psb_periods = 15, +}; + +enum perf_addr_filter_action_t { + PERF_ADDR_FILTER_ACTION_STOP = 0, + PERF_ADDR_FILTER_ACTION_START = 1, + PERF_ADDR_FILTER_ACTION_FILTER = 2, +}; + +struct perf_addr_filter { + struct list_head entry; + struct path path; + long unsigned int offset; + long unsigned int size; + enum perf_addr_filter_action_t action; +}; + +struct topa_entry { + u64 end: 1; + u64 rsvd0: 1; + u64 intr: 1; + u64 rsvd1: 1; + u64 stop: 1; + u64 rsvd2: 1; + u64 size: 4; + u64 rsvd3: 2; + u64 base: 36; + u64 rsvd4: 16; +}; + +struct pt_pmu { + struct pmu pmu; + u32 caps[8]; + bool vmx; + bool branch_en_always_on; + long unsigned int max_nonturbo_ratio; + unsigned int tsc_art_num; + unsigned int tsc_art_den; +}; + +struct topa; + +struct pt_buffer { + struct list_head tables; + struct topa *first; + struct topa *last; + struct topa *cur; + unsigned int cur_idx; + size_t output_off; + long unsigned int nr_pages; + local_t data_size; + local64_t head; + bool snapshot; + bool single; + long int stop_pos; + long int intr_pos; + struct topa_entry *stop_te; + struct topa_entry *intr_te; + void **data_pages; +}; + +struct topa { + struct list_head list; + u64 offset; + size_t size; + int last; + unsigned int z_count; +}; + +struct pt_filter { + long unsigned int msr_a; + long unsigned int msr_b; + long unsigned int config; +}; + +struct pt_filters { + struct pt_filter filter[4]; + unsigned int nr_filters; +}; + +struct pt { + struct perf_output_handle handle; + struct pt_filters filters; + int handle_nmi; + int vmx_on; + u64 output_base; + u64 output_mask; +}; + +struct pt_cap_desc { + const char *name; + u32 leaf; + u8 reg; + u32 mask; +}; + +struct pt_address_range { + long unsigned int msr_a; + long unsigned int msr_b; + unsigned int reg_off; +}; + +struct topa_page { + struct topa_entry table[507]; + struct topa topa; +}; + +typedef void (*exitcall_t)(); + +struct x86_cpu_id { + __u16 vendor; + __u16 family; + __u16 model; + __u16 steppings; + __u16 feature; + kernel_ulong_t driver_data; +}; + +enum hrtimer_mode { + HRTIMER_MODE_ABS = 0, + HRTIMER_MODE_REL = 1, + HRTIMER_MODE_PINNED = 2, + HRTIMER_MODE_SOFT = 4, + HRTIMER_MODE_HARD = 8, + HRTIMER_MODE_ABS_PINNED = 2, + HRTIMER_MODE_REL_PINNED = 3, + HRTIMER_MODE_ABS_SOFT = 4, + HRTIMER_MODE_REL_SOFT = 5, + HRTIMER_MODE_ABS_PINNED_SOFT = 6, + HRTIMER_MODE_REL_PINNED_SOFT = 7, + HRTIMER_MODE_ABS_HARD = 8, + HRTIMER_MODE_REL_HARD = 9, + HRTIMER_MODE_ABS_PINNED_HARD = 10, + HRTIMER_MODE_REL_PINNED_HARD = 11, +}; + +struct acpi_device; + +struct pci_sysdata { + int domain; + int node; + struct acpi_device *companion; + void *iommu; + void *fwnode; +}; + +struct pci_extra_dev { + struct pci_dev *dev[4]; +}; + +struct intel_uncore_pmu; + +struct intel_uncore_ops; + +struct uncore_event_desc; + +struct freerunning_counters; + +struct intel_uncore_type { + const char *name; + int num_counters; + int num_boxes; + int perf_ctr_bits; + int fixed_ctr_bits; + int num_freerunning_types; + unsigned int perf_ctr; + unsigned int event_ctl; + unsigned int event_mask; + unsigned int event_mask_ext; + unsigned int fixed_ctr; + unsigned int fixed_ctl; + unsigned int box_ctl; + union { + unsigned int msr_offset; + unsigned int mmio_offset; + }; + unsigned int mmio_map_size; + unsigned int num_shared_regs: 8; + unsigned int single_fixed: 1; + unsigned int pair_ctr_ctl: 1; + unsigned int *msr_offsets; + struct event_constraint unconstrainted; + struct event_constraint *constraints; + struct intel_uncore_pmu *pmus; + struct intel_uncore_ops *ops; + struct uncore_event_desc *event_descs; + struct freerunning_counters *freerunning; + const struct attribute_group *attr_groups[4]; + const struct attribute_group **attr_update; + struct pmu *pmu; + u64 *topology; + int (*set_mapping)(struct intel_uncore_type *); + void (*cleanup_mapping)(struct intel_uncore_type *); +}; + +struct intel_uncore_box; + +struct intel_uncore_pmu { + struct pmu pmu; + char name[32]; + int pmu_idx; + int func_id; + bool registered; + atomic_t activeboxes; + struct intel_uncore_type *type; + struct intel_uncore_box **boxes; +}; + +struct intel_uncore_ops { + void (*init_box)(struct intel_uncore_box *); + void (*exit_box)(struct intel_uncore_box *); + void (*disable_box)(struct intel_uncore_box *); + void (*enable_box)(struct intel_uncore_box *); + void (*disable_event)(struct intel_uncore_box *, struct perf_event *); + void (*enable_event)(struct intel_uncore_box *, struct perf_event *); + u64 (*read_counter)(struct intel_uncore_box *, struct perf_event *); + int (*hw_config)(struct intel_uncore_box *, struct perf_event *); + struct event_constraint * (*get_constraint)(struct intel_uncore_box *, struct perf_event *); + void (*put_constraint)(struct intel_uncore_box *, struct perf_event *); +}; + +struct uncore_event_desc { + struct kobj_attribute attr; + const char *config; +}; + +struct freerunning_counters { + unsigned int counter_base; + unsigned int counter_offset; + unsigned int box_offset; + unsigned int num_counters; + unsigned int bits; + unsigned int *box_offsets; +}; + +struct intel_uncore_extra_reg { + raw_spinlock_t lock; + u64 config; + u64 config1; + u64 config2; + atomic_t ref; +}; + +struct intel_uncore_box { + int pci_phys_id; + int dieid; + int n_active; + int n_events; + int cpu; + long unsigned int flags; + atomic_t refcnt; + struct perf_event *events[10]; + struct perf_event *event_list[10]; + struct event_constraint *event_constraint[10]; + long unsigned int active_mask[1]; + u64 tags[10]; + struct pci_dev *pci_dev; + struct intel_uncore_pmu *pmu; + u64 hrtimer_duration; + struct hrtimer hrtimer; + struct list_head list; + struct list_head active_list; + void *io_addr; + struct intel_uncore_extra_reg shared_regs[0]; +}; + +struct pci2phy_map { + struct list_head list; + int segment; + int pbus_to_physid[256]; +}; + +struct intel_uncore_init_fun { + void (*cpu_init)(); + int (*pci_init)(); + void (*mmio_init)(); +}; + +enum { + EXTRA_REG_NHMEX_M_FILTER = 0, + EXTRA_REG_NHMEX_M_DSP = 1, + EXTRA_REG_NHMEX_M_ISS = 2, + EXTRA_REG_NHMEX_M_MAP = 3, + EXTRA_REG_NHMEX_M_MSC_THR = 4, + EXTRA_REG_NHMEX_M_PGT = 5, + EXTRA_REG_NHMEX_M_PLD = 6, + EXTRA_REG_NHMEX_M_ZDP_CTL_FVC = 7, +}; + +enum { + SNB_PCI_UNCORE_IMC = 0, +}; + +enum perf_snb_uncore_imc_freerunning_types { + SNB_PCI_UNCORE_IMC_DATA_READS = 0, + SNB_PCI_UNCORE_IMC_DATA_WRITES = 1, + SNB_PCI_UNCORE_IMC_GT_REQUESTS = 2, + SNB_PCI_UNCORE_IMC_IA_REQUESTS = 3, + SNB_PCI_UNCORE_IMC_IO_REQUESTS = 4, + SNB_PCI_UNCORE_IMC_FREERUNNING_TYPE_MAX = 5, +}; + +struct imc_uncore_pci_dev { + __u32 pci_id; + struct pci_driver *driver; +}; + +enum perf_tgl_uncore_imc_freerunning_types { + TGL_MMIO_UNCORE_IMC_DATA_TOTAL = 0, + TGL_MMIO_UNCORE_IMC_DATA_READ = 1, + TGL_MMIO_UNCORE_IMC_DATA_WRITE = 2, + TGL_MMIO_UNCORE_IMC_FREERUNNING_TYPE_MAX = 3, +}; + +enum { + SNBEP_PCI_QPI_PORT0_FILTER = 0, + SNBEP_PCI_QPI_PORT1_FILTER = 1, + BDX_PCI_QPI_PORT2_FILTER = 2, + HSWEP_PCI_PCU_3 = 3, +}; + +enum { + SNBEP_PCI_UNCORE_HA = 0, + SNBEP_PCI_UNCORE_IMC = 1, + SNBEP_PCI_UNCORE_QPI = 2, + SNBEP_PCI_UNCORE_R2PCIE = 3, + SNBEP_PCI_UNCORE_R3QPI = 4, +}; + +enum { + IVBEP_PCI_UNCORE_HA = 0, + IVBEP_PCI_UNCORE_IMC = 1, + IVBEP_PCI_UNCORE_IRP = 2, + IVBEP_PCI_UNCORE_QPI = 3, + IVBEP_PCI_UNCORE_R2PCIE = 4, + IVBEP_PCI_UNCORE_R3QPI = 5, +}; + +enum { + KNL_PCI_UNCORE_MC_UCLK = 0, + KNL_PCI_UNCORE_MC_DCLK = 1, + KNL_PCI_UNCORE_EDC_UCLK = 2, + KNL_PCI_UNCORE_EDC_ECLK = 3, + KNL_PCI_UNCORE_M2PCIE = 4, + KNL_PCI_UNCORE_IRP = 5, +}; + +enum { + HSWEP_PCI_UNCORE_HA = 0, + HSWEP_PCI_UNCORE_IMC = 1, + HSWEP_PCI_UNCORE_IRP = 2, + HSWEP_PCI_UNCORE_QPI = 3, + HSWEP_PCI_UNCORE_R2PCIE = 4, + HSWEP_PCI_UNCORE_R3QPI = 5, +}; + +enum { + BDX_PCI_UNCORE_HA = 0, + BDX_PCI_UNCORE_IMC = 1, + BDX_PCI_UNCORE_IRP = 2, + BDX_PCI_UNCORE_QPI = 3, + BDX_PCI_UNCORE_R2PCIE = 4, + BDX_PCI_UNCORE_R3QPI = 5, +}; + +enum perf_uncore_iio_freerunning_type_id { + SKX_IIO_MSR_IOCLK = 0, + SKX_IIO_MSR_BW = 1, + SKX_IIO_MSR_UTIL = 2, + SKX_IIO_FREERUNNING_TYPE_MAX = 3, +}; + +enum { + SKX_PCI_UNCORE_IMC = 0, + SKX_PCI_UNCORE_M2M = 1, + SKX_PCI_UNCORE_UPI = 2, + SKX_PCI_UNCORE_M2PCIE = 3, + SKX_PCI_UNCORE_M3UPI = 4, +}; + +enum perf_uncore_snr_iio_freerunning_type_id { + SNR_IIO_MSR_IOCLK = 0, + SNR_IIO_MSR_BW_IN = 1, + SNR_IIO_FREERUNNING_TYPE_MAX = 2, +}; + +enum { + SNR_PCI_UNCORE_M2M = 0, + SNR_PCI_UNCORE_PCIE3 = 1, +}; + +enum perf_uncore_snr_imc_freerunning_type_id { + SNR_IMC_DCLK = 0, + SNR_IMC_DDR = 1, + SNR_IMC_FREERUNNING_TYPE_MAX = 2, +}; + +enum perf_uncore_icx_iio_freerunning_type_id { + ICX_IIO_MSR_IOCLK = 0, + ICX_IIO_MSR_BW_IN = 1, + ICX_IIO_FREERUNNING_TYPE_MAX = 2, +}; + +enum { + ICX_PCI_UNCORE_M2M = 0, + ICX_PCI_UNCORE_UPI = 1, + ICX_PCI_UNCORE_M3UPI = 2, +}; + +enum perf_uncore_icx_imc_freerunning_type_id { + ICX_IMC_DCLK = 0, + ICX_IMC_DDR = 1, + ICX_IMC_DDRT = 2, + ICX_IMC_FREERUNNING_TYPE_MAX = 3, +}; + +struct real_mode_header { + u32 text_start; + u32 ro_end; + u32 trampoline_start; + u32 trampoline_header; + u32 trampoline_pgd; + u32 wakeup_start; + u32 wakeup_header; + u32 machine_real_restart_asm; + u32 machine_real_restart_seg; +}; + +struct trampoline_header { + u64 start; + u64 efer; + u32 cr4; + u32 flags; +}; + +struct pkru_state { + u32 pkru; + u32 pad; +}; + +struct x86_hw_tss { + u32 reserved1; + u64 sp0; + u64 sp1; + u64 sp2; + u64 reserved2; + u64 ist[7]; + u32 reserved3; + u32 reserved4; + u16 reserved5; + u16 io_bitmap_base; +} __attribute__((packed)); + +struct x86_io_bitmap { + u64 prev_sequence; + unsigned int prev_max; + long unsigned int bitmap[1025]; + long unsigned int mapall[1025]; +}; + +struct tss_struct { + struct x86_hw_tss x86_tss; + struct x86_io_bitmap io_bitmap; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +enum show_regs_mode { + SHOW_REGS_SHORT = 0, + SHOW_REGS_USER = 1, + SHOW_REGS_ALL = 2, +}; + +enum which_selector { + FS = 0, + GS = 1, +}; + +struct sigcontext_64 { + __u64 r8; + __u64 r9; + __u64 r10; + __u64 r11; + __u64 r12; + __u64 r13; + __u64 r14; + __u64 r15; + __u64 di; + __u64 si; + __u64 bp; + __u64 bx; + __u64 dx; + __u64 ax; + __u64 cx; + __u64 sp; + __u64 ip; + __u64 flags; + __u16 cs; + __u16 gs; + __u16 fs; + __u16 ss; + __u64 err; + __u64 trapno; + __u64 oldmask; + __u64 cr2; + __u64 fpstate; + __u64 reserved1[8]; +}; + +struct sigaltstack { + void *ss_sp; + int ss_flags; + size_t ss_size; +}; + +typedef struct sigaltstack stack_t; + +struct siginfo { + union { + struct { + int si_signo; + int si_errno; + int si_code; + union __sifields _sifields; + }; + int _si_pad[32]; + }; +}; + +struct ksignal { + struct k_sigaction ka; + kernel_siginfo_t info; + int sig; +}; + +struct __large_struct { + long unsigned int buf[100]; +}; + +typedef u32 compat_sigset_word; + +typedef struct { + compat_sigset_word sig[2]; +} compat_sigset_t; + +struct ucontext { + long unsigned int uc_flags; + struct ucontext *uc_link; + stack_t uc_stack; + struct sigcontext_64 uc_mcontext; + sigset_t uc_sigmask; +}; + +struct kernel_vm86_regs { + struct pt_regs pt; + short unsigned int es; + short unsigned int __esh; + short unsigned int ds; + short unsigned int __dsh; + short unsigned int fs; + short unsigned int __fsh; + short unsigned int gs; + short unsigned int __gsh; +}; + +struct rt_sigframe { + char *pretcode; + struct ucontext uc; + struct siginfo info; +}; + +typedef struct siginfo siginfo_t; + +typedef s32 compat_clock_t; + +typedef s32 compat_pid_t; + +typedef s32 compat_timer_t; + +typedef s32 compat_int_t; + +typedef u32 __compat_uid32_t; + +union compat_sigval { + compat_int_t sival_int; + compat_uptr_t sival_ptr; +}; + +typedef union compat_sigval compat_sigval_t; + +struct compat_siginfo { + int si_signo; + int si_errno; + int si_code; + union { + int _pad[29]; + struct { + compat_pid_t _pid; + __compat_uid32_t _uid; + } _kill; + struct { + compat_timer_t _tid; + int _overrun; + compat_sigval_t _sigval; + } _timer; + struct { + compat_pid_t _pid; + __compat_uid32_t _uid; + compat_sigval_t _sigval; + } _rt; + struct { + compat_pid_t _pid; + __compat_uid32_t _uid; + int _status; + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + struct { + compat_uptr_t _addr; + union { + short int _addr_lsb; + struct { + char _dummy_bnd[4]; + compat_uptr_t _lower; + compat_uptr_t _upper; + } _addr_bnd; + struct { + char _dummy_pkey[4]; + u32 _pkey; + } _addr_pkey; + }; + } _sigfault; + struct { + compat_long_t _band; + int _fd; + } _sigpoll; + struct { + compat_uptr_t _call_addr; + int _syscall; + unsigned int _arch; + } _sigsys; + } _sifields; +}; + +typedef struct compat_siginfo compat_siginfo_t; + +enum bug_trap_type { + BUG_TRAP_TYPE_NONE = 0, + BUG_TRAP_TYPE_WARN = 1, + BUG_TRAP_TYPE_BUG = 2, +}; + +typedef u8 kprobe_opcode_t; + +struct arch_specific_insn { + kprobe_opcode_t *insn; + bool boostable; + bool if_modifier; + int tp_len; +}; + +struct kprobe; + +typedef int (*kprobe_pre_handler_t)(struct kprobe *, struct pt_regs *); + +typedef void (*kprobe_post_handler_t)(struct kprobe *, struct pt_regs *, long unsigned int); + +typedef int (*kprobe_fault_handler_t)(struct kprobe *, struct pt_regs *, int); + +struct kprobe { + struct hlist_node hlist; + struct list_head list; + long unsigned int nmissed; + kprobe_opcode_t *addr; + const char *symbol_name; + unsigned int offset; + kprobe_pre_handler_t pre_handler; + kprobe_post_handler_t post_handler; + kprobe_fault_handler_t fault_handler; + kprobe_opcode_t opcode; + struct arch_specific_insn ainsn; + u32 flags; +}; + +enum die_val { + DIE_OOPS = 1, + DIE_INT3 = 2, + DIE_DEBUG = 3, + DIE_PANIC = 4, + DIE_NMI = 5, + DIE_DIE = 6, + DIE_KERNELDEBUG = 7, + DIE_TRAP = 8, + DIE_GPF = 9, + DIE_CALL = 10, + DIE_PAGE_FAULT = 11, + DIE_NMIUNKNOWN = 12, +}; + +struct irqentry_state { + bool exit_rcu; +}; + +typedef struct irqentry_state irqentry_state_t; + +enum kernel_gp_hint { + GP_NO_HINT = 0, + GP_NON_CANONICAL = 1, + GP_CANONICAL = 2, +}; + +struct bad_iret_stack { + void *error_entry_ret; + struct pt_regs regs; +}; + +enum { + GATE_INTERRUPT = 14, + GATE_TRAP = 15, + GATE_CALL = 12, + GATE_TASK = 5, +}; + +struct idt_data { + unsigned int vector; + unsigned int segment; + struct idt_bits bits; + const void *addr; +}; + +struct irq_stack { + char stack[16384]; +}; + +enum irqreturn { + IRQ_NONE = 0, + IRQ_HANDLED = 1, + IRQ_WAKE_THREAD = 2, +}; + +typedef enum irqreturn irqreturn_t; + +typedef irqreturn_t (*irq_handler_t)(int, void *); + +struct irqaction { + irq_handler_t handler; + void *dev_id; + void *percpu_dev_id; + struct irqaction *next; + irq_handler_t thread_fn; + struct task_struct *thread; + struct irqaction *secondary; + unsigned int irq; + unsigned int flags; + long unsigned int thread_flags; + long unsigned int thread_mask; + const char *name; + struct proc_dir_entry *dir; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct irq_affinity_notify { + unsigned int irq; + struct kref kref; + struct work_struct work; + void (*notify)(struct irq_affinity_notify *, const cpumask_t *); + void (*release)(struct kref *); +}; + +enum irqchip_irq_state { + IRQCHIP_STATE_PENDING = 0, + IRQCHIP_STATE_ACTIVE = 1, + IRQCHIP_STATE_MASKED = 2, + IRQCHIP_STATE_LINE_LEVEL = 3, +}; + +struct irq_desc; + +typedef void (*irq_flow_handler_t)(struct irq_desc *); + +struct msi_desc; + +struct irq_common_data { + unsigned int state_use_accessors; + unsigned int node; + void *handler_data; + struct msi_desc *msi_desc; + cpumask_var_t affinity; + cpumask_var_t effective_affinity; +}; + +struct irq_chip; + +struct irq_data { + u32 mask; + unsigned int irq; + long unsigned int hwirq; + struct irq_common_data *common; + struct irq_chip *chip; + struct irq_domain *domain; + struct irq_data *parent_data; + void *chip_data; +}; + +struct irq_desc { + struct irq_common_data irq_common_data; + struct irq_data irq_data; + unsigned int *kstat_irqs; + irq_flow_handler_t handle_irq; + struct irqaction *action; + unsigned int status_use_accessors; + unsigned int core_internal_state__do_not_mess_with_it; + unsigned int depth; + unsigned int wake_depth; + unsigned int tot_count; + unsigned int irq_count; + long unsigned int last_unhandled; + unsigned int irqs_unhandled; + atomic_t threads_handled; + int threads_handled_last; + raw_spinlock_t lock; + struct cpumask *percpu_enabled; + const struct cpumask *percpu_affinity; + const struct cpumask *affinity_hint; + struct irq_affinity_notify *affinity_notify; + cpumask_var_t pending_mask; + long unsigned int threads_oneshot; + atomic_t threads_active; + wait_queue_head_t wait_for_threads; + unsigned int nr_actions; + unsigned int no_suspend_depth; + unsigned int cond_suspend_depth; + unsigned int force_resume_depth; + struct proc_dir_entry *dir; + struct callback_head rcu; + struct kobject kobj; + struct mutex request_mutex; + int parent_irq; + struct module *owner; + const char *name; + long: 64; +}; + +struct msi_msg; + +struct irq_chip { + struct device *parent_device; + const char *name; + unsigned int (*irq_startup)(struct irq_data *); + void (*irq_shutdown)(struct irq_data *); + void (*irq_enable)(struct irq_data *); + void (*irq_disable)(struct irq_data *); + void (*irq_ack)(struct irq_data *); + void (*irq_mask)(struct irq_data *); + void (*irq_mask_ack)(struct irq_data *); + void (*irq_unmask)(struct irq_data *); + void (*irq_eoi)(struct irq_data *); + int (*irq_set_affinity)(struct irq_data *, const struct cpumask *, bool); + int (*irq_retrigger)(struct irq_data *); + int (*irq_set_type)(struct irq_data *, unsigned int); + int (*irq_set_wake)(struct irq_data *, unsigned int); + void (*irq_bus_lock)(struct irq_data *); + void (*irq_bus_sync_unlock)(struct irq_data *); + void (*irq_cpu_online)(struct irq_data *); + void (*irq_cpu_offline)(struct irq_data *); + void (*irq_suspend)(struct irq_data *); + void (*irq_resume)(struct irq_data *); + void (*irq_pm_shutdown)(struct irq_data *); + void (*irq_calc_mask)(struct irq_data *); + void (*irq_print_chip)(struct irq_data *, struct seq_file *); + int (*irq_request_resources)(struct irq_data *); + void (*irq_release_resources)(struct irq_data *); + void (*irq_compose_msi_msg)(struct irq_data *, struct msi_msg *); + void (*irq_write_msi_msg)(struct irq_data *, struct msi_msg *); + int (*irq_get_irqchip_state)(struct irq_data *, enum irqchip_irq_state, bool *); + int (*irq_set_irqchip_state)(struct irq_data *, enum irqchip_irq_state, bool); + int (*irq_set_vcpu_affinity)(struct irq_data *, void *); + void (*ipi_send_single)(struct irq_data *, unsigned int); + void (*ipi_send_mask)(struct irq_data *, const struct cpumask *); + int (*irq_nmi_setup)(struct irq_data *); + void (*irq_nmi_teardown)(struct irq_data *); + long unsigned int flags; +}; + +typedef struct irq_desc *vector_irq_t[256]; + +struct trace_event_raw_x86_irq_vector { + struct trace_entry ent; + int vector; + char __data[0]; +}; + +struct trace_event_raw_vector_config { + struct trace_entry ent; + unsigned int irq; + unsigned int vector; + unsigned int cpu; + unsigned int apicdest; + char __data[0]; +}; + +struct trace_event_raw_vector_mod { + struct trace_entry ent; + unsigned int irq; + unsigned int vector; + unsigned int cpu; + unsigned int prev_vector; + unsigned int prev_cpu; + char __data[0]; +}; + +struct trace_event_raw_vector_reserve { + struct trace_entry ent; + unsigned int irq; + int ret; + char __data[0]; +}; + +struct trace_event_raw_vector_alloc { + struct trace_entry ent; + unsigned int irq; + unsigned int vector; + bool reserved; + int ret; + char __data[0]; +}; + +struct trace_event_raw_vector_alloc_managed { + struct trace_entry ent; + unsigned int irq; + unsigned int vector; + int ret; + char __data[0]; +}; + +struct trace_event_raw_vector_activate { + struct trace_entry ent; + unsigned int irq; + bool is_managed; + bool can_reserve; + bool reserve; + char __data[0]; +}; + +struct trace_event_raw_vector_teardown { + struct trace_entry ent; + unsigned int irq; + bool is_managed; + bool has_reserved; + char __data[0]; +}; + +struct trace_event_raw_vector_setup { + struct trace_entry ent; + unsigned int irq; + bool is_legacy; + int ret; + char __data[0]; +}; + +struct trace_event_raw_vector_free_moved { + struct trace_entry ent; + unsigned int irq; + unsigned int cpu; + unsigned int vector; + bool is_managed; + char __data[0]; +}; + +struct trace_event_data_offsets_x86_irq_vector {}; + +struct trace_event_data_offsets_vector_config {}; + +struct trace_event_data_offsets_vector_mod {}; + +struct trace_event_data_offsets_vector_reserve {}; + +struct trace_event_data_offsets_vector_alloc {}; + +struct trace_event_data_offsets_vector_alloc_managed {}; + +struct trace_event_data_offsets_vector_activate {}; + +struct trace_event_data_offsets_vector_teardown {}; + +struct trace_event_data_offsets_vector_setup {}; + +struct trace_event_data_offsets_vector_free_moved {}; + +typedef void (*btf_trace_local_timer_entry)(void *, int); + +typedef void (*btf_trace_local_timer_exit)(void *, int); + +typedef void (*btf_trace_spurious_apic_entry)(void *, int); + +typedef void (*btf_trace_spurious_apic_exit)(void *, int); + +typedef void (*btf_trace_error_apic_entry)(void *, int); + +typedef void (*btf_trace_error_apic_exit)(void *, int); + +typedef void (*btf_trace_x86_platform_ipi_entry)(void *, int); + +typedef void (*btf_trace_x86_platform_ipi_exit)(void *, int); + +typedef void (*btf_trace_irq_work_entry)(void *, int); + +typedef void (*btf_trace_irq_work_exit)(void *, int); + +typedef void (*btf_trace_reschedule_entry)(void *, int); + +typedef void (*btf_trace_reschedule_exit)(void *, int); + +typedef void (*btf_trace_call_function_entry)(void *, int); + +typedef void (*btf_trace_call_function_exit)(void *, int); + +typedef void (*btf_trace_call_function_single_entry)(void *, int); + +typedef void (*btf_trace_call_function_single_exit)(void *, int); + +typedef void (*btf_trace_threshold_apic_entry)(void *, int); + +typedef void (*btf_trace_threshold_apic_exit)(void *, int); + +typedef void (*btf_trace_deferred_error_apic_entry)(void *, int); + +typedef void (*btf_trace_deferred_error_apic_exit)(void *, int); + +typedef void (*btf_trace_thermal_apic_entry)(void *, int); + +typedef void (*btf_trace_thermal_apic_exit)(void *, int); + +typedef void (*btf_trace_vector_config)(void *, unsigned int, unsigned int, unsigned int, unsigned int); + +typedef void (*btf_trace_vector_update)(void *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); + +typedef void (*btf_trace_vector_clear)(void *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); + +typedef void (*btf_trace_vector_reserve_managed)(void *, unsigned int, int); + +typedef void (*btf_trace_vector_reserve)(void *, unsigned int, int); + +typedef void (*btf_trace_vector_alloc)(void *, unsigned int, unsigned int, bool, int); + +typedef void (*btf_trace_vector_alloc_managed)(void *, unsigned int, unsigned int, int); + +typedef void (*btf_trace_vector_activate)(void *, unsigned int, bool, bool, bool); + +typedef void (*btf_trace_vector_deactivate)(void *, unsigned int, bool, bool, bool); + +typedef void (*btf_trace_vector_teardown)(void *, unsigned int, bool, bool); + +typedef void (*btf_trace_vector_setup)(void *, unsigned int, bool, int); + +typedef void (*btf_trace_vector_free_moved)(void *, unsigned int, unsigned int, unsigned int, bool); + +struct cea_exception_stacks { + char DF_stack_guard[4096]; + char DF_stack[4096]; + char NMI_stack_guard[4096]; + char NMI_stack[4096]; + char DB_stack_guard[4096]; + char DB_stack[4096]; + char MCE_stack_guard[4096]; + char MCE_stack[4096]; + char VC_stack_guard[4096]; + char VC_stack[4096]; + char VC2_stack_guard[4096]; + char VC2_stack[4096]; + char IST_top_guard[4096]; +}; + +struct estack_pages { + u32 offs; + u16 size; + u16 type; +}; + +struct clocksource { + u64 (*read)(struct clocksource *); + u64 mask; + u32 mult; + u32 shift; + u64 max_idle_ns; + u32 maxadj; + u64 max_cycles; + const char *name; + struct list_head list; + int rating; + enum vdso_clock_mode vdso_clock_mode; + long unsigned int flags; + int (*enable)(struct clocksource *); + void (*disable)(struct clocksource *); + void (*suspend)(struct clocksource *); + void (*resume)(struct clocksource *); + void (*mark_unstable)(struct clocksource *); + void (*tick_stable)(struct clocksource *); + struct list_head wd_list; + u64 cs_last; + u64 wd_last; + struct module *owner; +}; + +struct x86_init_mpparse { + void (*setup_ioapic_ids)(); + void (*find_smp_config)(); + void (*get_smp_config)(unsigned int); +}; + +struct x86_init_resources { + void (*probe_roms)(); + void (*reserve_resources)(); + char * (*memory_setup)(); +}; + +struct x86_init_irqs { + void (*pre_vector_init)(); + void (*intr_init)(); + void (*intr_mode_select)(); + void (*intr_mode_init)(); + struct irq_domain * (*create_pci_msi_domain)(); +}; + +struct x86_init_oem { + void (*arch_setup)(); + void (*banner)(); +}; + +struct x86_init_paging { + void (*pagetable_init)(); +}; + +struct x86_init_timers { + void (*setup_percpu_clockev)(); + void (*timer_init)(); + void (*wallclock_init)(); +}; + +struct x86_init_iommu { + int (*iommu_init)(); +}; + +struct x86_init_pci { + int (*arch_init)(); + int (*init)(); + void (*init_irq)(); + void (*fixup_irqs)(); +}; + +struct x86_hyper_init { + void (*init_platform)(); + void (*guest_late_init)(); + bool (*x2apic_available)(); + void (*init_mem_mapping)(); + void (*init_after_bootmem)(); +}; + +struct x86_init_acpi { + void (*set_root_pointer)(u64); + u64 (*get_root_pointer)(); + void (*reduced_hw_early_init)(); +}; + +struct x86_init_ops { + struct x86_init_resources resources; + struct x86_init_mpparse mpparse; + struct x86_init_irqs irqs; + struct x86_init_oem oem; + struct x86_init_paging paging; + struct x86_init_timers timers; + struct x86_init_iommu iommu; + struct x86_init_pci pci; + struct x86_hyper_init hyper; + struct x86_init_acpi acpi; +}; + +enum clock_event_state { + CLOCK_EVT_STATE_DETACHED = 0, + CLOCK_EVT_STATE_SHUTDOWN = 1, + CLOCK_EVT_STATE_PERIODIC = 2, + CLOCK_EVT_STATE_ONESHOT = 3, + CLOCK_EVT_STATE_ONESHOT_STOPPED = 4, +}; + +struct clock_event_device { + void (*event_handler)(struct clock_event_device *); + int (*set_next_event)(long unsigned int, struct clock_event_device *); + int (*set_next_ktime)(ktime_t, struct clock_event_device *); + ktime_t next_event; + u64 max_delta_ns; + u64 min_delta_ns; + u32 mult; + u32 shift; + enum clock_event_state state_use_accessors; + unsigned int features; + long unsigned int retries; + int (*set_state_periodic)(struct clock_event_device *); + int (*set_state_oneshot)(struct clock_event_device *); + int (*set_state_oneshot_stopped)(struct clock_event_device *); + int (*set_state_shutdown)(struct clock_event_device *); + int (*tick_resume)(struct clock_event_device *); + void (*broadcast)(const struct cpumask *); + void (*suspend)(struct clock_event_device *); + void (*resume)(struct clock_event_device *); + long unsigned int min_delta_ticks; + long unsigned int max_delta_ticks; + const char *name; + int rating; + int irq; + int bound_on; + const struct cpumask *cpumask; + struct list_head list; + struct module *owner; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct irq_affinity_desc { + struct cpumask mask; + unsigned int is_managed: 1; +}; + +struct msi_msg { + u32 address_lo; + u32 address_hi; + u32 data; +}; + +struct platform_msi_priv_data; + +struct platform_msi_desc { + struct platform_msi_priv_data *msi_priv_data; + u16 msi_index; +}; + +struct fsl_mc_msi_desc { + u16 msi_index; +}; + +struct ti_sci_inta_msi_desc { + u16 dev_index; +}; + +struct msi_desc { + struct list_head list; + unsigned int irq; + unsigned int nvec_used; + struct device *dev; + struct msi_msg msg; + struct irq_affinity_desc *affinity; + void (*write_msi_msg)(struct msi_desc *, void *); + void *write_msi_msg_data; + union { + struct { + u32 masked; + struct { + u8 is_msix: 1; + u8 multiple: 3; + u8 multi_cap: 3; + u8 maskbit: 1; + u8 is_64: 1; + u8 is_virtual: 1; + u16 entry_nr; + unsigned int default_irq; + } msi_attrib; + union { + u8 mask_pos; + void *mask_base; + }; + }; + struct platform_msi_desc platform; + struct fsl_mc_msi_desc fsl_mc; + struct ti_sci_inta_msi_desc inta; + }; +}; + +struct irq_chip_regs { + long unsigned int enable; + long unsigned int disable; + long unsigned int mask; + long unsigned int ack; + long unsigned int eoi; + long unsigned int type; + long unsigned int polarity; +}; + +struct irq_chip_type { + struct irq_chip chip; + struct irq_chip_regs regs; + irq_flow_handler_t handler; + u32 type; + u32 mask_cache_priv; + u32 *mask_cache; +}; + +struct irq_chip_generic { + raw_spinlock_t lock; + void *reg_base; + u32 (*reg_readl)(void *); + void (*reg_writel)(u32, void *); + void (*suspend)(struct irq_chip_generic *); + void (*resume)(struct irq_chip_generic *); + unsigned int irq_base; + unsigned int irq_cnt; + u32 mask_cache; + u32 type_cache; + u32 polarity_cache; + u32 wake_enabled; + u32 wake_active; + unsigned int num_ct; + void *private; + long unsigned int installed; + long unsigned int unused; + struct irq_domain *domain; + struct list_head list; + struct irq_chip_type chip_types[0]; +}; + +enum irq_gc_flags { + IRQ_GC_INIT_MASK_CACHE = 1, + IRQ_GC_INIT_NESTED_LOCK = 2, + IRQ_GC_MASK_CACHE_PER_TYPE = 4, + IRQ_GC_NO_MASK = 8, + IRQ_GC_BE_IO = 16, +}; + +struct irq_domain_chip_generic { + unsigned int irqs_per_chip; + unsigned int num_chips; + unsigned int irq_flags_to_clear; + unsigned int irq_flags_to_set; + enum irq_gc_flags gc_flags; + struct irq_chip_generic *gc[0]; +}; + +enum refcount_saturation_type { + REFCOUNT_ADD_NOT_ZERO_OVF = 0, + REFCOUNT_ADD_OVF = 1, + REFCOUNT_ADD_UAF = 2, + REFCOUNT_SUB_UAF = 3, + REFCOUNT_DEC_LEAK = 4, +}; + +enum lockdown_reason { + LOCKDOWN_NONE = 0, + LOCKDOWN_MODULE_SIGNATURE = 1, + LOCKDOWN_DEV_MEM = 2, + LOCKDOWN_EFI_TEST = 3, + LOCKDOWN_KEXEC = 4, + LOCKDOWN_HIBERNATION = 5, + LOCKDOWN_PCI_ACCESS = 6, + LOCKDOWN_IOPORT = 7, + LOCKDOWN_MSR = 8, + LOCKDOWN_ACPI_TABLES = 9, + LOCKDOWN_PCMCIA_CIS = 10, + LOCKDOWN_TIOCSSERIAL = 11, + LOCKDOWN_MODULE_PARAMETERS = 12, + LOCKDOWN_MMIOTRACE = 13, + LOCKDOWN_DEBUGFS = 14, + LOCKDOWN_XMON_WR = 15, + LOCKDOWN_INTEGRITY_MAX = 16, + LOCKDOWN_KCORE = 17, + LOCKDOWN_KPROBES = 18, + LOCKDOWN_BPF_READ = 19, + LOCKDOWN_PERF = 20, + LOCKDOWN_TRACEFS = 21, + LOCKDOWN_XMON_RW = 22, + LOCKDOWN_CONFIDENTIALITY_MAX = 23, +}; + +enum lockdep_ok { + LOCKDEP_STILL_OK = 0, + LOCKDEP_NOW_UNRELIABLE = 1, +}; + +struct entry_stack { + char stack[4096]; +}; + +typedef long unsigned int uintptr_t; + +typedef u64 uint64_t; + +struct trace_event_raw_nmi_handler { + struct trace_entry ent; + void *handler; + s64 delta_ns; + int handled; + char __data[0]; +}; + +struct trace_event_data_offsets_nmi_handler {}; + +typedef void (*btf_trace_nmi_handler)(void *, void *, s64, int); + +struct nmi_desc { + raw_spinlock_t lock; + struct list_head head; +}; + +struct nmi_stats { + unsigned int normal; + unsigned int unknown; + unsigned int external; + unsigned int swallow; +}; + +enum nmi_states { + NMI_NOT_RUNNING = 0, + NMI_EXECUTING = 1, + NMI_LATCHED = 2, +}; + +enum { + DESC_TSS = 9, + DESC_LDT = 2, + DESCTYPE_S = 16, +}; + +struct ldttss_desc { + u16 limit0; + u16 base0; + u16 base1: 8; + u16 type: 5; + u16 dpl: 2; + u16 p: 1; + u16 limit1: 4; + u16 zero0: 3; + u16 g: 1; + u16 base2: 8; + u32 base3; + u32 zero1; +}; + +typedef struct ldttss_desc ldt_desc; + +struct user_desc { + unsigned int entry_number; + unsigned int base_addr; + unsigned int limit; + unsigned int seg_32bit: 1; + unsigned int contents: 2; + unsigned int read_exec_only: 1; + unsigned int limit_in_pages: 1; + unsigned int seg_not_present: 1; + unsigned int useable: 1; + unsigned int lm: 1; +}; + +struct mmu_gather_batch { + struct mmu_gather_batch *next; + unsigned int nr; + unsigned int max; + struct page *pages[0]; +}; + +struct mmu_gather { + struct mm_struct *mm; + long unsigned int start; + long unsigned int end; + unsigned int fullmm: 1; + unsigned int need_flush_all: 1; + unsigned int freed_tables: 1; + unsigned int cleared_ptes: 1; + unsigned int cleared_pmds: 1; + unsigned int cleared_puds: 1; + unsigned int cleared_p4ds: 1; + unsigned int vma_exec: 1; + unsigned int vma_huge: 1; + unsigned int batch_count; + struct mmu_gather_batch *active; + struct mmu_gather_batch local; + struct page *__pages[8]; +}; + +enum con_scroll { + SM_UP = 0, + SM_DOWN = 1, +}; + +enum vc_intensity { + VCI_HALF_BRIGHT = 0, + VCI_NORMAL = 1, + VCI_BOLD = 2, + VCI_MASK = 3, +}; + +struct vc_data; + +struct console_font; + +struct consw { + struct module *owner; + const char * (*con_startup)(); + void (*con_init)(struct vc_data *, int); + void (*con_deinit)(struct vc_data *); + void (*con_clear)(struct vc_data *, int, int, int, int); + void (*con_putc)(struct vc_data *, int, int, int); + void (*con_putcs)(struct vc_data *, const short unsigned int *, int, int, int); + void (*con_cursor)(struct vc_data *, int); + bool (*con_scroll)(struct vc_data *, unsigned int, unsigned int, enum con_scroll, unsigned int); + int (*con_switch)(struct vc_data *); + int (*con_blank)(struct vc_data *, int, int); + int (*con_font_set)(struct vc_data *, struct console_font *, unsigned int); + int (*con_font_get)(struct vc_data *, struct console_font *); + int (*con_font_default)(struct vc_data *, struct console_font *, char *); + int (*con_font_copy)(struct vc_data *, int); + int (*con_resize)(struct vc_data *, unsigned int, unsigned int, unsigned int); + void (*con_set_palette)(struct vc_data *, const unsigned char *); + void (*con_scrolldelta)(struct vc_data *, int); + int (*con_set_origin)(struct vc_data *); + void (*con_save_screen)(struct vc_data *); + u8 (*con_build_attr)(struct vc_data *, u8, enum vc_intensity, bool, bool, bool, bool); + void (*con_invert_region)(struct vc_data *, u16 *, int); + u16 * (*con_screen_pos)(const struct vc_data *, int); + long unsigned int (*con_getxy)(struct vc_data *, long unsigned int, int *, int *); + void (*con_flush_scrollback)(struct vc_data *); + int (*con_debug_enter)(struct vc_data *); + int (*con_debug_leave)(struct vc_data *); +}; + +struct vc_state { + unsigned int x; + unsigned int y; + unsigned char color; + unsigned char Gx_charset[2]; + unsigned int charset: 1; + enum vc_intensity intensity; + bool italic; + bool underline; + bool blink; + bool reverse; +}; + +struct console_font { + unsigned int width; + unsigned int height; + unsigned int charcount; + unsigned char *data; +}; + +struct vt_mode { + char mode; + char waitv; + short int relsig; + short int acqsig; + short int frsig; +}; + +struct uni_pagedir; + +struct uni_screen; + +struct vc_data { + struct tty_port port; + struct vc_state state; + struct vc_state saved_state; + short unsigned int vc_num; + unsigned int vc_cols; + unsigned int vc_rows; + unsigned int vc_size_row; + unsigned int vc_scan_lines; + long unsigned int vc_origin; + long unsigned int vc_scr_end; + long unsigned int vc_visible_origin; + unsigned int vc_top; + unsigned int vc_bottom; + const struct consw *vc_sw; + short unsigned int *vc_screenbuf; + unsigned int vc_screenbuf_size; + unsigned char vc_mode; + unsigned char vc_attr; + unsigned char vc_def_color; + unsigned char vc_ulcolor; + unsigned char vc_itcolor; + unsigned char vc_halfcolor; + unsigned int vc_cursor_type; + short unsigned int vc_complement_mask; + short unsigned int vc_s_complement_mask; + long unsigned int vc_pos; + short unsigned int vc_hi_font_mask; + struct console_font vc_font; + short unsigned int vc_video_erase_char; + unsigned int vc_state; + unsigned int vc_npar; + unsigned int vc_par[16]; + struct vt_mode vt_mode; + struct pid *vt_pid; + int vt_newvt; + wait_queue_head_t paste_wait; + unsigned int vc_disp_ctrl: 1; + unsigned int vc_toggle_meta: 1; + unsigned int vc_decscnm: 1; + unsigned int vc_decom: 1; + unsigned int vc_decawm: 1; + unsigned int vc_deccm: 1; + unsigned int vc_decim: 1; + unsigned int vc_priv: 3; + unsigned int vc_need_wrap: 1; + unsigned int vc_can_do_color: 1; + unsigned int vc_report_mouse: 2; + unsigned char vc_utf: 1; + unsigned char vc_utf_count; + int vc_utf_char; + long unsigned int vc_tab_stop[4]; + unsigned char vc_palette[48]; + short unsigned int *vc_translate; + unsigned int vc_resize_user; + unsigned int vc_bell_pitch; + unsigned int vc_bell_duration; + short unsigned int vc_cur_blink_ms; + struct vc_data **vc_display_fg; + struct uni_pagedir *vc_uni_pagedir; + struct uni_pagedir **vc_uni_pagedir_loc; + struct uni_screen *vc_uni_screen; +}; + +struct edd { + unsigned int mbr_signature[16]; + struct edd_info edd_info[6]; + unsigned char mbr_signature_nr; + unsigned char edd_info_nr; +}; + +struct setup_data { + __u64 next; + __u32 type; + __u32 len; + __u8 data[0]; +}; + +struct setup_indirect { + __u32 type; + __u32 reserved; + __u64 len; + __u64 addr; +}; + +struct atomic_notifier_head { + spinlock_t lock; + struct notifier_block *head; +}; + +struct scatterlist { + long unsigned int page_link; + unsigned int offset; + unsigned int length; + dma_addr_t dma_address; + unsigned int dma_length; +}; + +struct sg_table { + struct scatterlist *sgl; + unsigned int nents; + unsigned int orig_nents; +}; + +enum efi_secureboot_mode { + efi_secureboot_mode_unset = 0, + efi_secureboot_mode_unknown = 1, + efi_secureboot_mode_disabled = 2, + efi_secureboot_mode_enabled = 3, +}; + +enum xen_domain_type { + XEN_NATIVE = 0, + XEN_PV_DOMAIN = 1, + XEN_HVM_DOMAIN = 2, +}; + +enum e820_type { + E820_TYPE_RAM = 1, + E820_TYPE_RESERVED = 2, + E820_TYPE_ACPI = 3, + E820_TYPE_NVS = 4, + E820_TYPE_UNUSABLE = 5, + E820_TYPE_PMEM = 7, + E820_TYPE_PRAM = 12, + E820_TYPE_SOFT_RESERVED = 4026531839, + E820_TYPE_RESERVED_KERN = 128, +}; + +struct e820_entry { + u64 addr; + u64 size; + enum e820_type type; +} __attribute__((packed)); + +struct e820_table { + __u32 nr_entries; + struct e820_entry entries[320]; +} __attribute__((packed)); + +struct x86_cpuinit_ops { + void (*setup_percpu_clockev)(); + void (*early_percpu_clock_init)(); + void (*fixup_cpu_id)(struct cpuinfo_x86 *, int); +}; + +struct x86_msi_ops { + void (*restore_msi_irqs)(struct pci_dev *); +}; + +struct x86_apic_ops { + unsigned int (*io_apic_read)(unsigned int, unsigned int); + void (*restore)(); +}; + +struct msi_controller { + struct module *owner; + struct device *dev; + struct device_node *of_node; + struct list_head list; + int (*setup_irq)(struct msi_controller *, struct pci_dev *, struct msi_desc *); + int (*setup_irqs)(struct msi_controller *, struct pci_dev *, int, int); + void (*teardown_irq)(struct msi_controller *, unsigned int); +}; + +struct legacy_pic { + int nr_legacy_irqs; + struct irq_chip *chip; + void (*mask)(unsigned int); + void (*unmask)(unsigned int); + void (*mask_all)(); + void (*restore_mask)(); + void (*init)(int); + int (*probe)(); + int (*irq_pending)(unsigned int); + void (*make_irq)(unsigned int); +}; + +enum jump_label_type { + JUMP_LABEL_NOP = 0, + JUMP_LABEL_JMP = 1, +}; + +union text_poke_insn { + u8 text[5]; + struct { + u8 opcode; + s32 disp; + } __attribute__((packed)); +}; + +enum { + JL_STATE_START = 0, + JL_STATE_NO_UPDATE = 1, + JL_STATE_UPDATE = 2, +}; + +typedef short unsigned int __kernel_old_uid_t; + +typedef short unsigned int __kernel_old_gid_t; + +typedef struct { + int val[2]; +} __kernel_fsid_t; + +typedef __kernel_old_uid_t old_uid_t; + +typedef __kernel_old_gid_t old_gid_t; + +struct kernel_clone_args { + u64 flags; + int *pidfd; + int *child_tid; + int *parent_tid; + int exit_signal; + long unsigned int stack; + long unsigned int stack_size; + long unsigned int tls; + pid_t *set_tid; + size_t set_tid_size; + int cgroup; + struct cgroup *cgrp; + struct css_set *cset; +}; + +struct kstatfs { + long int f_type; + long int f_bsize; + u64 f_blocks; + u64 f_bfree; + u64 f_bavail; + u64 f_files; + u64 f_ffree; + __kernel_fsid_t f_fsid; + long int f_namelen; + long int f_frsize; + long int f_flags; + long int f_spare[4]; +}; + +struct stat64 { + long long unsigned int st_dev; + unsigned char __pad0[4]; + unsigned int __st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned int st_uid; + unsigned int st_gid; + long long unsigned int st_rdev; + unsigned char __pad3[4]; + long long int st_size; + unsigned int st_blksize; + long long int st_blocks; + unsigned int st_atime; + unsigned int st_atime_nsec; + unsigned int st_mtime; + unsigned int st_mtime_nsec; + unsigned int st_ctime; + unsigned int st_ctime_nsec; + long long unsigned int st_ino; +} __attribute__((packed)); + +struct mmap_arg_struct32 { + unsigned int addr; + unsigned int len; + unsigned int prot; + unsigned int flags; + unsigned int fd; + unsigned int offset; +}; + +struct vm_unmapped_area_info { + long unsigned int flags; + long unsigned int length; + long unsigned int low_limit; + long unsigned int high_limit; + long unsigned int align_mask; + long unsigned int align_offset; +}; + +enum align_flags { + ALIGN_VA_32 = 1, + ALIGN_VA_64 = 2, +}; + +struct va_alignment { + int flags; + long unsigned int mask; + long unsigned int bits; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +enum { + MEMREMAP_WB = 1, + MEMREMAP_WT = 2, + MEMREMAP_WC = 4, + MEMREMAP_ENC = 8, + MEMREMAP_DEC = 16, +}; + +enum { + IORES_DESC_NONE = 0, + IORES_DESC_CRASH_KERNEL = 1, + IORES_DESC_ACPI_TABLES = 2, + IORES_DESC_ACPI_NV_STORAGE = 3, + IORES_DESC_PERSISTENT_MEMORY = 4, + IORES_DESC_PERSISTENT_MEMORY_LEGACY = 5, + IORES_DESC_DEVICE_PRIVATE_MEMORY = 6, + IORES_DESC_RESERVED = 7, + IORES_DESC_SOFT_RESERVED = 8, +}; + +struct change_member { + struct e820_entry *entry; + long long unsigned int addr; +}; + +struct iommu_fault_param; + +struct iommu_fwspec; + +struct dev_iommu { + struct mutex lock; + struct iommu_fault_param *fault_param; + struct iommu_fwspec *fwspec; + struct iommu_device *iommu_dev; + void *priv; +}; + +struct of_phandle_args { + struct device_node *np; + int args_count; + uint32_t args[16]; +}; + +struct iommu_fault_unrecoverable { + __u32 reason; + __u32 flags; + __u32 pasid; + __u32 perm; + __u64 addr; + __u64 fetch_addr; +}; + +struct iommu_fault_page_request { + __u32 flags; + __u32 pasid; + __u32 grpid; + __u32 perm; + __u64 addr; + __u64 private_data[2]; +}; + +struct iommu_fault { + __u32 type; + __u32 padding; + union { + struct iommu_fault_unrecoverable event; + struct iommu_fault_page_request prm; + __u8 padding2[56]; + }; +}; + +struct iommu_page_response { + __u32 argsz; + __u32 version; + __u32 flags; + __u32 pasid; + __u32 grpid; + __u32 code; +}; + +struct iommu_inv_addr_info { + __u32 flags; + __u32 archid; + __u64 pasid; + __u64 addr; + __u64 granule_size; + __u64 nb_granules; +}; + +struct iommu_inv_pasid_info { + __u32 flags; + __u32 archid; + __u64 pasid; +}; + +struct iommu_cache_invalidate_info { + __u32 argsz; + __u32 version; + __u8 cache; + __u8 granularity; + __u8 padding[6]; + union { + struct iommu_inv_pasid_info pasid_info; + struct iommu_inv_addr_info addr_info; + } granu; +}; + +struct iommu_gpasid_bind_data_vtd { + __u64 flags; + __u32 pat; + __u32 emt; +}; + +struct iommu_gpasid_bind_data { + __u32 argsz; + __u32 version; + __u32 format; + __u32 addr_width; + __u64 flags; + __u64 gpgd; + __u64 hpasid; + __u64 gpasid; + __u8 padding[8]; + union { + struct iommu_gpasid_bind_data_vtd vtd; + } vendor; +}; + +typedef int (*iommu_fault_handler_t)(struct iommu_domain *, struct device *, long unsigned int, int, void *); + +struct iommu_domain_geometry { + dma_addr_t aperture_start; + dma_addr_t aperture_end; + bool force_aperture; +}; + +struct iommu_domain { + unsigned int type; + const struct iommu_ops *ops; + long unsigned int pgsize_bitmap; + iommu_fault_handler_t handler; + void *handler_token; + struct iommu_domain_geometry geometry; + void *iova_cookie; +}; + +typedef int (*iommu_dev_fault_handler_t)(struct iommu_fault *, void *); + +enum iommu_resv_type { + IOMMU_RESV_DIRECT = 0, + IOMMU_RESV_DIRECT_RELAXABLE = 1, + IOMMU_RESV_RESERVED = 2, + IOMMU_RESV_MSI = 3, + IOMMU_RESV_SW_MSI = 4, +}; + +struct iommu_resv_region { + struct list_head list; + phys_addr_t start; + size_t length; + int prot; + enum iommu_resv_type type; +}; + +struct iommu_iotlb_gather { + long unsigned int start; + long unsigned int end; + size_t pgsize; +}; + +struct iommu_device { + struct list_head list; + const struct iommu_ops *ops; + struct fwnode_handle *fwnode; + struct device *dev; +}; + +struct iommu_sva { + struct device *dev; +}; + +struct iommu_fault_event { + struct iommu_fault fault; + struct list_head list; +}; + +struct iommu_fault_param { + iommu_dev_fault_handler_t handler; + void *data; + struct list_head faults; + struct mutex lock; +}; + +struct iommu_fwspec { + const struct iommu_ops *ops; + struct fwnode_handle *iommu_fwnode; + u32 flags; + u32 num_pasid_bits; + unsigned int num_ids; + u32 ids[0]; +}; + +struct iommu_table_entry { + initcall_t detect; + initcall_t depend; + void (*early_init)(); + void (*late_init)(); + int flags; +}; + +enum dmi_field { + DMI_NONE = 0, + DMI_BIOS_VENDOR = 1, + DMI_BIOS_VERSION = 2, + DMI_BIOS_DATE = 3, + DMI_BIOS_RELEASE = 4, + DMI_EC_FIRMWARE_RELEASE = 5, + DMI_SYS_VENDOR = 6, + DMI_PRODUCT_NAME = 7, + DMI_PRODUCT_VERSION = 8, + DMI_PRODUCT_SERIAL = 9, + DMI_PRODUCT_UUID = 10, + DMI_PRODUCT_SKU = 11, + DMI_PRODUCT_FAMILY = 12, + DMI_BOARD_VENDOR = 13, + DMI_BOARD_NAME = 14, + DMI_BOARD_VERSION = 15, + DMI_BOARD_SERIAL = 16, + DMI_BOARD_ASSET_TAG = 17, + DMI_CHASSIS_VENDOR = 18, + DMI_CHASSIS_TYPE = 19, + DMI_CHASSIS_VERSION = 20, + DMI_CHASSIS_SERIAL = 21, + DMI_CHASSIS_ASSET_TAG = 22, + DMI_STRING_MAX = 23, + DMI_OEM_STRING = 24, +}; + +enum { + NONE_FORCE_HPET_RESUME = 0, + OLD_ICH_FORCE_HPET_RESUME = 1, + ICH_FORCE_HPET_RESUME = 2, + VT8237_FORCE_HPET_RESUME = 3, + NVIDIA_FORCE_HPET_RESUME = 4, + ATI_FORCE_HPET_RESUME = 5, +}; + +enum meminit_context { + MEMINIT_EARLY = 0, + MEMINIT_HOTPLUG = 1, +}; + +struct cpu { + int node_id; + int hotpluggable; + struct device dev; +}; + +struct x86_cpu { + struct cpu cpu; +}; + +typedef int (*cmp_func_t)(const void *, const void *); + +struct die_args { + struct pt_regs *regs; + const char *str; + long int err; + int trapnr; + int signr; +}; + +struct smp_alt_module { + struct module *mod; + char *name; + const s32 *locks; + const s32 *locks_end; + u8 *text; + u8 *text_end; + struct list_head next; +}; + +typedef struct { + struct mm_struct *mm; +} temp_mm_state_t; + +struct text_poke_loc { + s32 rel_addr; + s32 rel32; + u8 opcode; + const u8 text[5]; + u8 old; +}; + +struct bp_patching_desc { + struct text_poke_loc *vec; + int nr_entries; + atomic_t refs; +}; + +struct paravirt_patch_site; + +enum { + HW_BREAKPOINT_LEN_1 = 1, + HW_BREAKPOINT_LEN_2 = 2, + HW_BREAKPOINT_LEN_3 = 3, + HW_BREAKPOINT_LEN_4 = 4, + HW_BREAKPOINT_LEN_5 = 5, + HW_BREAKPOINT_LEN_6 = 6, + HW_BREAKPOINT_LEN_7 = 7, + HW_BREAKPOINT_LEN_8 = 8, +}; + +enum { + HW_BREAKPOINT_EMPTY = 0, + HW_BREAKPOINT_R = 1, + HW_BREAKPOINT_W = 2, + HW_BREAKPOINT_RW = 3, + HW_BREAKPOINT_X = 4, + HW_BREAKPOINT_INVALID = 7, +}; + +typedef unsigned int u_int; + +typedef long long unsigned int cycles_t; + +struct system_counterval_t { + u64 cycles; + struct clocksource *cs; +}; + +enum { + WORK_STRUCT_PENDING_BIT = 0, + WORK_STRUCT_DELAYED_BIT = 1, + WORK_STRUCT_PWQ_BIT = 2, + WORK_STRUCT_LINKED_BIT = 3, + WORK_STRUCT_COLOR_SHIFT = 4, + WORK_STRUCT_COLOR_BITS = 4, + WORK_STRUCT_PENDING = 1, + WORK_STRUCT_DELAYED = 2, + WORK_STRUCT_PWQ = 4, + WORK_STRUCT_LINKED = 8, + WORK_STRUCT_STATIC = 0, + WORK_NR_COLORS = 15, + WORK_NO_COLOR = 15, + WORK_CPU_UNBOUND = 128, + WORK_STRUCT_FLAG_BITS = 8, + WORK_OFFQ_FLAG_BASE = 4, + __WORK_OFFQ_CANCELING = 4, + WORK_OFFQ_CANCELING = 16, + WORK_OFFQ_FLAG_BITS = 1, + WORK_OFFQ_POOL_SHIFT = 5, + WORK_OFFQ_LEFT = 59, + WORK_OFFQ_POOL_BITS = 31, + WORK_OFFQ_POOL_NONE = 2147483647, + WORK_STRUCT_FLAG_MASK = 255, + WORK_STRUCT_WQ_DATA_MASK = 4294967040, + WORK_STRUCT_NO_POOL = 4294967264, + WORK_BUSY_PENDING = 1, + WORK_BUSY_RUNNING = 2, + WORKER_DESC_LEN = 24, +}; + +struct plist_head { + struct list_head node_list; +}; + +typedef struct { + seqcount_t seqcount; +} seqcount_latch_t; + +enum pm_qos_type { + PM_QOS_UNITIALIZED = 0, + PM_QOS_MAX = 1, + PM_QOS_MIN = 2, +}; + +struct pm_qos_constraints { + struct plist_head list; + s32 target_value; + s32 default_value; + s32 no_constraint_value; + enum pm_qos_type type; + struct blocking_notifier_head *notifiers; +}; + +enum freq_qos_req_type { + FREQ_QOS_MIN = 1, + FREQ_QOS_MAX = 2, +}; + +struct freq_constraints { + struct pm_qos_constraints min_freq; + struct blocking_notifier_head min_freq_notifiers; + struct pm_qos_constraints max_freq; + struct blocking_notifier_head max_freq_notifiers; +}; + +struct freq_qos_request { + enum freq_qos_req_type type; + struct plist_node pnode; + struct freq_constraints *qos; +}; + +enum cpufreq_table_sorting { + CPUFREQ_TABLE_UNSORTED = 0, + CPUFREQ_TABLE_SORTED_ASCENDING = 1, + CPUFREQ_TABLE_SORTED_DESCENDING = 2, +}; + +struct cpufreq_cpuinfo { + unsigned int max_freq; + unsigned int min_freq; + unsigned int transition_latency; +}; + +struct clk; + +struct cpufreq_governor; + +struct cpufreq_frequency_table; + +struct cpufreq_stats; + +struct thermal_cooling_device; + +struct cpufreq_policy { + cpumask_var_t cpus; + cpumask_var_t related_cpus; + cpumask_var_t real_cpus; + unsigned int shared_type; + unsigned int cpu; + struct clk *clk; + struct cpufreq_cpuinfo cpuinfo; + unsigned int min; + unsigned int max; + unsigned int cur; + unsigned int restore_freq; + unsigned int suspend_freq; + unsigned int policy; + unsigned int last_policy; + struct cpufreq_governor *governor; + void *governor_data; + char last_governor[16]; + struct work_struct update; + struct freq_constraints constraints; + struct freq_qos_request *min_freq_req; + struct freq_qos_request *max_freq_req; + struct cpufreq_frequency_table *freq_table; + enum cpufreq_table_sorting freq_table_sorted; + struct list_head policy_list; + struct kobject kobj; + struct completion kobj_unregister; + struct rw_semaphore rwsem; + bool fast_switch_possible; + bool fast_switch_enabled; + bool strict_target; + unsigned int transition_delay_us; + bool dvfs_possible_from_any_cpu; + unsigned int cached_target_freq; + unsigned int cached_resolved_idx; + bool transition_ongoing; + spinlock_t transition_lock; + wait_queue_head_t transition_wait; + struct task_struct *transition_task; + struct cpufreq_stats *stats; + void *driver_data; + struct thermal_cooling_device *cdev; + struct notifier_block nb_min; + struct notifier_block nb_max; +}; + +struct cpufreq_governor { + char name[16]; + int (*init)(struct cpufreq_policy *); + void (*exit)(struct cpufreq_policy *); + int (*start)(struct cpufreq_policy *); + void (*stop)(struct cpufreq_policy *); + void (*limits)(struct cpufreq_policy *); + ssize_t (*show_setspeed)(struct cpufreq_policy *, char *); + int (*store_setspeed)(struct cpufreq_policy *, unsigned int); + struct list_head governor_list; + struct module *owner; + u8 flags; +}; + +struct cpufreq_frequency_table { + unsigned int flags; + unsigned int driver_data; + unsigned int frequency; +}; + +struct cpufreq_freqs { + struct cpufreq_policy *policy; + unsigned int old; + unsigned int new; + u8 flags; +}; + +struct cyc2ns { + struct cyc2ns_data data[2]; + seqcount_latch_t seq; +}; + +struct muldiv { + u32 multiplier; + u32 divider; +}; + +struct freq_desc { + bool use_msr_plat; + struct muldiv muldiv[16]; + u32 freqs[16]; + u32 mask; +}; + +struct dmi_strmatch { + unsigned char slot: 7; + unsigned char exact_match: 1; + char substr[79]; +}; + +struct dmi_system_id { + int (*callback)(const struct dmi_system_id *); + const char *ident; + struct dmi_strmatch matches[4]; + void *driver_data; +}; + +struct pdev_archdata {}; + +struct mfd_cell; + +struct platform_device_id; + +struct platform_device { + const char *name; + int id; + bool id_auto; + struct device dev; + u64 platform_dma_mask; + struct device_dma_parameters dma_parms; + u32 num_resources; + struct resource *resource; + const struct platform_device_id *id_entry; + char *driver_override; + struct mfd_cell *mfd_cell; + struct pdev_archdata archdata; +}; + +struct platform_device_id { + char name[20]; + kernel_ulong_t driver_data; +}; + +struct rtc_time { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + +struct pnp_device_id { + __u8 id[8]; + kernel_ulong_t driver_data; +}; + +struct pnp_card_device_id { + __u8 id[8]; + kernel_ulong_t driver_data; + struct { + __u8 id[8]; + } devs[8]; +}; + +struct acpi_table_header { + char signature[4]; + u32 length; + u8 revision; + u8 checksum; + char oem_id[6]; + char oem_table_id[8]; + u32 oem_revision; + char asl_compiler_id[4]; + u32 asl_compiler_revision; +}; + +struct acpi_generic_address { + u8 space_id; + u8 bit_width; + u8 bit_offset; + u8 access_width; + u64 address; +} __attribute__((packed)); + +struct acpi_table_fadt { + struct acpi_table_header header; + u32 facs; + u32 dsdt; + u8 model; + u8 preferred_profile; + u16 sci_interrupt; + u32 smi_command; + u8 acpi_enable; + u8 acpi_disable; + u8 s4_bios_request; + u8 pstate_control; + u32 pm1a_event_block; + u32 pm1b_event_block; + u32 pm1a_control_block; + u32 pm1b_control_block; + u32 pm2_control_block; + u32 pm_timer_block; + u32 gpe0_block; + u32 gpe1_block; + u8 pm1_event_length; + u8 pm1_control_length; + u8 pm2_control_length; + u8 pm_timer_length; + u8 gpe0_block_length; + u8 gpe1_block_length; + u8 gpe1_base; + u8 cst_control; + u16 c2_latency; + u16 c3_latency; + u16 flush_size; + u16 flush_stride; + u8 duty_offset; + u8 duty_width; + u8 day_alarm; + u8 month_alarm; + u8 century; + u16 boot_flags; + u8 reserved; + u32 flags; + struct acpi_generic_address reset_register; + u8 reset_value; + u16 arm_boot_flags; + u8 minor_revision; + u64 Xfacs; + u64 Xdsdt; + struct acpi_generic_address xpm1a_event_block; + struct acpi_generic_address xpm1b_event_block; + struct acpi_generic_address xpm1a_control_block; + struct acpi_generic_address xpm1b_control_block; + struct acpi_generic_address xpm2_control_block; + struct acpi_generic_address xpm_timer_block; + struct acpi_generic_address xgpe0_block; + struct acpi_generic_address xgpe1_block; + struct acpi_generic_address sleep_control; + struct acpi_generic_address sleep_status; + u64 hypervisor_id; +} __attribute__((packed)); + +struct pnp_protocol; + +struct pnp_id; + +struct pnp_card { + struct device dev; + unsigned char number; + struct list_head global_list; + struct list_head protocol_list; + struct list_head devices; + struct pnp_protocol *protocol; + struct pnp_id *id; + char name[50]; + unsigned char pnpver; + unsigned char productver; + unsigned int serial; + unsigned char checksum; + struct proc_dir_entry *procdir; +}; + +struct pnp_dev; + +struct pnp_protocol { + struct list_head protocol_list; + char *name; + int (*get)(struct pnp_dev *); + int (*set)(struct pnp_dev *); + int (*disable)(struct pnp_dev *); + bool (*can_wakeup)(struct pnp_dev *); + int (*suspend)(struct pnp_dev *, pm_message_t); + int (*resume)(struct pnp_dev *); + unsigned char number; + struct device dev; + struct list_head cards; + struct list_head devices; +}; + +struct pnp_id { + char id[8]; + struct pnp_id *next; +}; + +struct pnp_card_driver; + +struct pnp_card_link { + struct pnp_card *card; + struct pnp_card_driver *driver; + void *driver_data; + pm_message_t pm_state; +}; + +struct pnp_driver { + const char *name; + const struct pnp_device_id *id_table; + unsigned int flags; + int (*probe)(struct pnp_dev *, const struct pnp_device_id *); + void (*remove)(struct pnp_dev *); + void (*shutdown)(struct pnp_dev *); + int (*suspend)(struct pnp_dev *, pm_message_t); + int (*resume)(struct pnp_dev *); + struct device_driver driver; +}; + +struct pnp_card_driver { + struct list_head global_list; + char *name; + const struct pnp_card_device_id *id_table; + unsigned int flags; + int (*probe)(struct pnp_card_link *, const struct pnp_card_device_id *); + void (*remove)(struct pnp_card_link *); + int (*suspend)(struct pnp_card_link *, pm_message_t); + int (*resume)(struct pnp_card_link *); + struct pnp_driver link; +}; + +struct pnp_dev { + struct device dev; + u64 dma_mask; + unsigned int number; + int status; + struct list_head global_list; + struct list_head protocol_list; + struct list_head card_list; + struct list_head rdev_list; + struct pnp_protocol *protocol; + struct pnp_card *card; + struct pnp_driver *driver; + struct pnp_card_link *card_link; + struct pnp_id *id; + int active; + int capabilities; + unsigned int num_dependent_sets; + struct list_head resources; + struct list_head options; + char name[50]; + int flags; + struct proc_dir_entry *procent; + void *data; +}; + +enum insn_type { + CALL = 0, + NOP = 1, + JMP = 2, + RET = 3, +}; + +typedef struct ldttss_desc tss_desc; + +enum idle_boot_override { + IDLE_NO_OVERRIDE = 0, + IDLE_HALT = 1, + IDLE_NOMWAIT = 2, + IDLE_POLL = 3, +}; + +struct pm_qos_flags { + struct list_head list; + s32 effective_flags; +}; + +struct dev_pm_qos_request; + +struct dev_pm_qos { + struct pm_qos_constraints resume_latency; + struct pm_qos_constraints latency_tolerance; + struct freq_constraints freq; + struct pm_qos_flags flags; + struct dev_pm_qos_request *resume_latency_req; + struct dev_pm_qos_request *latency_tolerance_req; + struct dev_pm_qos_request *flags_req; +}; + +enum tick_broadcast_mode { + TICK_BROADCAST_OFF = 0, + TICK_BROADCAST_ON = 1, + TICK_BROADCAST_FORCE = 2, +}; + +enum tick_broadcast_state { + TICK_BROADCAST_EXIT = 0, + TICK_BROADCAST_ENTER = 1, +}; + +struct pm_qos_flags_request { + struct list_head node; + s32 flags; +}; + +enum dev_pm_qos_req_type { + DEV_PM_QOS_RESUME_LATENCY = 1, + DEV_PM_QOS_LATENCY_TOLERANCE = 2, + DEV_PM_QOS_MIN_FREQUENCY = 3, + DEV_PM_QOS_MAX_FREQUENCY = 4, + DEV_PM_QOS_FLAGS = 5, +}; + +struct dev_pm_qos_request { + enum dev_pm_qos_req_type type; + union { + struct plist_node pnode; + struct pm_qos_flags_request flr; + struct freq_qos_request freq; + } data; + struct device *dev; +}; + +struct inactive_task_frame { + long unsigned int r15; + long unsigned int r14; + long unsigned int r13; + long unsigned int r12; + long unsigned int bx; + long unsigned int bp; + long unsigned int ret_addr; +}; + +struct fork_frame { + struct inactive_task_frame frame; + struct pt_regs regs; +}; + +struct ssb_state { + struct ssb_state *shared_state; + raw_spinlock_t lock; + unsigned int disable_state; + long unsigned int local_state; +}; + +struct trace_event_raw_x86_fpu { + struct trace_entry ent; + struct fpu *fpu; + bool load_fpu; + u64 xfeatures; + u64 xcomp_bv; + char __data[0]; +}; + +struct trace_event_data_offsets_x86_fpu {}; + +typedef void (*btf_trace_x86_fpu_before_save)(void *, struct fpu *); + +typedef void (*btf_trace_x86_fpu_after_save)(void *, struct fpu *); + +typedef void (*btf_trace_x86_fpu_before_restore)(void *, struct fpu *); + +typedef void (*btf_trace_x86_fpu_after_restore)(void *, struct fpu *); + +typedef void (*btf_trace_x86_fpu_regs_activated)(void *, struct fpu *); + +typedef void (*btf_trace_x86_fpu_regs_deactivated)(void *, struct fpu *); + +typedef void (*btf_trace_x86_fpu_init_state)(void *, struct fpu *); + +typedef void (*btf_trace_x86_fpu_dropped)(void *, struct fpu *); + +typedef void (*btf_trace_x86_fpu_copy_src)(void *, struct fpu *); + +typedef void (*btf_trace_x86_fpu_copy_dst)(void *, struct fpu *); + +typedef void (*btf_trace_x86_fpu_xstate_check_failed)(void *, struct fpu *); + +struct _fpreg { + __u16 significand[4]; + __u16 exponent; +}; + +struct _fpxreg { + __u16 significand[4]; + __u16 exponent; + __u16 padding[3]; +}; + +struct user_i387_ia32_struct { + u32 cwd; + u32 swd; + u32 twd; + u32 fip; + u32 fcs; + u32 foo; + u32 fos; + u32 st_space[20]; +}; + +struct membuf { + void *p; + size_t left; +}; + +struct user_regset; + +typedef int user_regset_active_fn(struct task_struct *, const struct user_regset *); + +typedef int user_regset_get2_fn(struct task_struct *, const struct user_regset *, struct membuf); + +typedef int user_regset_set_fn(struct task_struct *, const struct user_regset *, unsigned int, unsigned int, const void *, const void *); + +typedef int user_regset_writeback_fn(struct task_struct *, const struct user_regset *, int); + +struct user_regset { + user_regset_get2_fn *regset_get; + user_regset_set_fn *set; + user_regset_active_fn *active; + user_regset_writeback_fn *writeback; + unsigned int n; + unsigned int size; + unsigned int align; + unsigned int bias; + unsigned int core_note_type; +}; + +struct _fpx_sw_bytes { + __u32 magic1; + __u32 extended_size; + __u64 xfeatures; + __u32 xstate_size; + __u32 padding[7]; +}; + +struct _xmmreg { + __u32 element[4]; +}; + +struct _fpstate_32 { + __u32 cw; + __u32 sw; + __u32 tag; + __u32 ipoff; + __u32 cssel; + __u32 dataoff; + __u32 datasel; + struct _fpreg _st[8]; + __u16 status; + __u16 magic; + __u32 _fxsr_env[6]; + __u32 mxcsr; + __u32 reserved; + struct _fpxreg _fxsr_st[8]; + struct _xmmreg _xmm[8]; + union { + __u32 padding1[44]; + __u32 padding[44]; + }; + union { + __u32 padding2[12]; + struct _fpx_sw_bytes sw_reserved; + }; +}; + +struct ia32_pasid_state { + u64 pasid; +}; + +typedef u32 compat_ulong_t; + +struct user_regset_view { + const char *name; + const struct user_regset *regsets; + unsigned int n; + u32 e_flags; + u16 e_machine; + u8 ei_osabi; +}; + +enum x86_regset { + REGSET_GENERAL = 0, + REGSET_FP = 1, + REGSET_XFP = 2, + REGSET_IOPERM64 = 2, + REGSET_XSTATE = 3, + REGSET_TLS = 4, + REGSET_IOPERM32 = 5, +}; + +struct pt_regs_offset { + const char *name; + int offset; +}; + +typedef u8 uint8_t; + +enum { + TB_SHUTDOWN_REBOOT = 0, + TB_SHUTDOWN_S5 = 1, + TB_SHUTDOWN_S4 = 2, + TB_SHUTDOWN_S3 = 3, + TB_SHUTDOWN_HALT = 4, + TB_SHUTDOWN_WFS = 5, +}; + +struct tboot_mac_region { + u64 start; + u32 size; +} __attribute__((packed)); + +struct tboot_acpi_generic_address { + u8 space_id; + u8 bit_width; + u8 bit_offset; + u8 access_width; + u64 address; +} __attribute__((packed)); + +struct tboot_acpi_sleep_info { + struct tboot_acpi_generic_address pm1a_cnt_blk; + struct tboot_acpi_generic_address pm1b_cnt_blk; + struct tboot_acpi_generic_address pm1a_evt_blk; + struct tboot_acpi_generic_address pm1b_evt_blk; + u16 pm1a_cnt_val; + u16 pm1b_cnt_val; + u64 wakeup_vector; + u32 vector_width; + u64 kernel_s3_resume_vector; +} __attribute__((packed)); + +struct tboot { + u8 uuid[16]; + u32 version; + u32 log_addr; + u32 shutdown_entry; + u32 shutdown_type; + struct tboot_acpi_sleep_info acpi_sinfo; + u32 tboot_base; + u32 tboot_size; + u8 num_mac_regions; + struct tboot_mac_region mac_regions[32]; + u8 s3_key[64]; + u8 reserved_align[3]; + u32 num_in_wfs; +} __attribute__((packed)); + +struct sha1_hash { + u8 hash[20]; +}; + +struct sinit_mle_data { + u32 version; + struct sha1_hash bios_acm_id; + u32 edx_senter_flags; + u64 mseg_valid; + struct sha1_hash sinit_hash; + struct sha1_hash mle_hash; + struct sha1_hash stm_hash; + struct sha1_hash lcp_policy_hash; + u32 lcp_policy_control; + u32 rlp_wakeup_addr; + u32 reserved; + u32 num_mdrs; + u32 mdrs_off; + u32 num_vtd_dmars; + u32 vtd_dmars_off; +} __attribute__((packed)); + +typedef bool (*stack_trace_consume_fn)(void *, long unsigned int); + +struct stack_frame_user { + const void *next_fp; + long unsigned int ret_addr; +}; + +enum cache_type { + CACHE_TYPE_NOCACHE = 0, + CACHE_TYPE_INST = 1, + CACHE_TYPE_DATA = 2, + CACHE_TYPE_SEPARATE = 3, + CACHE_TYPE_UNIFIED = 4, +}; + +struct cacheinfo { + unsigned int id; + enum cache_type type; + unsigned int level; + unsigned int coherency_line_size; + unsigned int number_of_sets; + unsigned int ways_of_associativity; + unsigned int physical_line_partition; + unsigned int size; + cpumask_t shared_cpu_map; + unsigned int attributes; + void *fw_token; + bool disable_sysfs; + void *priv; +}; + +struct cpu_cacheinfo { + struct cacheinfo *info_list; + unsigned int num_levels; + unsigned int num_leaves; + bool cpu_map_populated; +}; + +struct amd_l3_cache { + unsigned int indices; + u8 subcaches[4]; +}; + +struct threshold_block { + unsigned int block; + unsigned int bank; + unsigned int cpu; + u32 address; + u16 interrupt_enable; + bool interrupt_capable; + u16 threshold_limit; + struct kobject kobj; + struct list_head miscj; +}; + +struct threshold_bank { + struct kobject *kobj; + struct threshold_block *blocks; + refcount_t cpus; + unsigned int shared; +}; + +struct amd_northbridge { + struct pci_dev *root; + struct pci_dev *misc; + struct pci_dev *link; + struct amd_l3_cache l3_cache; + struct threshold_bank *bank4; +}; + +struct _cache_table { + unsigned char descriptor; + char cache_type; + short int size; +}; + +enum _cache_type { + CTYPE_NULL = 0, + CTYPE_DATA = 1, + CTYPE_INST = 2, + CTYPE_UNIFIED = 3, +}; + +union _cpuid4_leaf_eax { + struct { + enum _cache_type type: 5; + unsigned int level: 3; + unsigned int is_self_initializing: 1; + unsigned int is_fully_associative: 1; + unsigned int reserved: 4; + unsigned int num_threads_sharing: 12; + unsigned int num_cores_on_die: 6; + } split; + u32 full; +}; + +union _cpuid4_leaf_ebx { + struct { + unsigned int coherency_line_size: 12; + unsigned int physical_line_partition: 10; + unsigned int ways_of_associativity: 10; + } split; + u32 full; +}; + +union _cpuid4_leaf_ecx { + struct { + unsigned int number_of_sets: 32; + } split; + u32 full; +}; + +struct _cpuid4_info_regs { + union _cpuid4_leaf_eax eax; + union _cpuid4_leaf_ebx ebx; + union _cpuid4_leaf_ecx ecx; + unsigned int id; + long unsigned int size; + struct amd_northbridge *nb; +}; + +union l1_cache { + struct { + unsigned int line_size: 8; + unsigned int lines_per_tag: 8; + unsigned int assoc: 8; + unsigned int size_in_kb: 8; + }; + unsigned int val; +}; + +union l2_cache { + struct { + unsigned int line_size: 8; + unsigned int lines_per_tag: 4; + unsigned int assoc: 4; + unsigned int size_in_kb: 16; + }; + unsigned int val; +}; + +union l3_cache { + struct { + unsigned int line_size: 8; + unsigned int lines_per_tag: 4; + unsigned int assoc: 4; + unsigned int res: 2; + unsigned int size_encoded: 14; + }; + unsigned int val; +}; + +struct cpuid_bit { + u16 feature; + u8 reg; + u8 bit; + u32 level; + u32 sub_leaf; +}; + +struct fixed_percpu_data { + char gs_base[40]; + long unsigned int stack_canary; +}; + +enum cpuid_leafs { + CPUID_1_EDX = 0, + CPUID_8000_0001_EDX = 1, + CPUID_8086_0001_EDX = 2, + CPUID_LNX_1 = 3, + CPUID_1_ECX = 4, + CPUID_C000_0001_EDX = 5, + CPUID_8000_0001_ECX = 6, + CPUID_LNX_2 = 7, + CPUID_LNX_3 = 8, + CPUID_7_0_EBX = 9, + CPUID_D_1_EAX = 10, + CPUID_LNX_4 = 11, + CPUID_7_1_EAX = 12, + CPUID_8000_0008_EBX = 13, + CPUID_6_EAX = 14, + CPUID_8000_000A_EDX = 15, + CPUID_7_ECX = 16, + CPUID_8000_0007_EBX = 17, + CPUID_7_EDX = 18, +}; + +struct cpu_dev { + const char *c_vendor; + const char *c_ident[2]; + void (*c_early_init)(struct cpuinfo_x86 *); + void (*c_bsp_init)(struct cpuinfo_x86 *); + void (*c_init)(struct cpuinfo_x86 *); + void (*c_identify)(struct cpuinfo_x86 *); + void (*c_detect_tlb)(struct cpuinfo_x86 *); + int c_x86_vendor; +}; + +struct cpuid_dependent_feature { + u32 feature; + u32 level; +}; + +enum spectre_v2_mitigation { + SPECTRE_V2_NONE = 0, + SPECTRE_V2_RETPOLINE_GENERIC = 1, + SPECTRE_V2_RETPOLINE_AMD = 2, + SPECTRE_V2_IBRS_ENHANCED = 3, +}; + +enum spectre_v2_user_mitigation { + SPECTRE_V2_USER_NONE = 0, + SPECTRE_V2_USER_STRICT = 1, + SPECTRE_V2_USER_STRICT_PREFERRED = 2, + SPECTRE_V2_USER_PRCTL = 3, + SPECTRE_V2_USER_SECCOMP = 4, +}; + +enum ssb_mitigation { + SPEC_STORE_BYPASS_NONE = 0, + SPEC_STORE_BYPASS_DISABLE = 1, + SPEC_STORE_BYPASS_PRCTL = 2, + SPEC_STORE_BYPASS_SECCOMP = 3, +}; + +enum l1tf_mitigations { + L1TF_MITIGATION_OFF = 0, + L1TF_MITIGATION_FLUSH_NOWARN = 1, + L1TF_MITIGATION_FLUSH = 2, + L1TF_MITIGATION_FLUSH_NOSMT = 3, + L1TF_MITIGATION_FULL = 4, + L1TF_MITIGATION_FULL_FORCE = 5, +}; + +enum mds_mitigations { + MDS_MITIGATION_OFF = 0, + MDS_MITIGATION_FULL = 1, + MDS_MITIGATION_VMWERV = 2, +}; + +enum cpuhp_smt_control { + CPU_SMT_ENABLED = 0, + CPU_SMT_DISABLED = 1, + CPU_SMT_FORCE_DISABLED = 2, + CPU_SMT_NOT_SUPPORTED = 3, + CPU_SMT_NOT_IMPLEMENTED = 4, +}; + +enum vmx_l1d_flush_state { + VMENTER_L1D_FLUSH_AUTO = 0, + VMENTER_L1D_FLUSH_NEVER = 1, + VMENTER_L1D_FLUSH_COND = 2, + VMENTER_L1D_FLUSH_ALWAYS = 3, + VMENTER_L1D_FLUSH_EPT_DISABLED = 4, + VMENTER_L1D_FLUSH_NOT_REQUIRED = 5, +}; + +enum x86_hypervisor_type { + X86_HYPER_NATIVE = 0, + X86_HYPER_VMWARE = 1, + X86_HYPER_MS_HYPERV = 2, + X86_HYPER_XEN_PV = 3, + X86_HYPER_XEN_HVM = 4, + X86_HYPER_KVM = 5, + X86_HYPER_JAILHOUSE = 6, + X86_HYPER_ACRN = 7, +}; + +enum taa_mitigations { + TAA_MITIGATION_OFF = 0, + TAA_MITIGATION_UCODE_NEEDED = 1, + TAA_MITIGATION_VERW = 2, + TAA_MITIGATION_TSX_DISABLED = 3, +}; + +enum srbds_mitigations { + SRBDS_MITIGATION_OFF = 0, + SRBDS_MITIGATION_UCODE_NEEDED = 1, + SRBDS_MITIGATION_FULL = 2, + SRBDS_MITIGATION_TSX_OFF = 3, + SRBDS_MITIGATION_HYPERVISOR = 4, +}; + +enum spectre_v1_mitigation { + SPECTRE_V1_MITIGATION_NONE = 0, + SPECTRE_V1_MITIGATION_AUTO = 1, +}; + +enum spectre_v2_mitigation_cmd { + SPECTRE_V2_CMD_NONE = 0, + SPECTRE_V2_CMD_AUTO = 1, + SPECTRE_V2_CMD_FORCE = 2, + SPECTRE_V2_CMD_RETPOLINE = 3, + SPECTRE_V2_CMD_RETPOLINE_GENERIC = 4, + SPECTRE_V2_CMD_RETPOLINE_AMD = 5, +}; + +enum spectre_v2_user_cmd { + SPECTRE_V2_USER_CMD_NONE = 0, + SPECTRE_V2_USER_CMD_AUTO = 1, + SPECTRE_V2_USER_CMD_FORCE = 2, + SPECTRE_V2_USER_CMD_PRCTL = 3, + SPECTRE_V2_USER_CMD_PRCTL_IBPB = 4, + SPECTRE_V2_USER_CMD_SECCOMP = 5, + SPECTRE_V2_USER_CMD_SECCOMP_IBPB = 6, +}; + +enum ssb_mitigation_cmd { + SPEC_STORE_BYPASS_CMD_NONE = 0, + SPEC_STORE_BYPASS_CMD_AUTO = 1, + SPEC_STORE_BYPASS_CMD_ON = 2, + SPEC_STORE_BYPASS_CMD_PRCTL = 3, + SPEC_STORE_BYPASS_CMD_SECCOMP = 4, +}; + +enum hk_flags { + HK_FLAG_TIMER = 1, + HK_FLAG_RCU = 2, + HK_FLAG_MISC = 4, + HK_FLAG_SCHED = 8, + HK_FLAG_TICK = 16, + HK_FLAG_DOMAIN = 32, + HK_FLAG_WQ = 64, + HK_FLAG_MANAGED_IRQ = 128, + HK_FLAG_KTHREAD = 256, +}; + +struct aperfmperf_sample { + unsigned int khz; + ktime_t time; + u64 aperf; + u64 mperf; +}; + +struct cpuid_dep { + unsigned int feature; + unsigned int depends; +}; + +enum vmx_feature_leafs { + MISC_FEATURES = 0, + PRIMARY_CTLS = 1, + SECONDARY_CTLS = 2, + NR_VMX_FEATURE_WORDS = 3, +}; + +struct _tlb_table { + unsigned char descriptor; + char tlb_type; + unsigned int entries; + char info[128]; +}; + +enum tsx_ctrl_states { + TSX_CTRL_ENABLE = 0, + TSX_CTRL_DISABLE = 1, + TSX_CTRL_NOT_SUPPORTED = 2, +}; + +enum split_lock_detect_state { + sld_off = 0, + sld_warn = 1, + sld_fatal = 2, +}; + +struct sku_microcode { + u8 model; + u8 stepping; + u32 microcode; +}; + +struct cpuid_regs { + u32 eax; + u32 ebx; + u32 ecx; + u32 edx; +}; + +enum pconfig_target { + INVALID_TARGET = 0, + MKTME_TARGET = 1, + PCONFIG_TARGET_NR = 2, +}; + +enum { + PCONFIG_CPUID_SUBLEAF_INVALID = 0, + PCONFIG_CPUID_SUBLEAF_TARGETID = 1, +}; + +enum task_work_notify_mode { + TWA_NONE = 0, + TWA_RESUME = 1, + TWA_SIGNAL = 2, +}; + +enum mf_flags { + MF_COUNT_INCREASED = 1, + MF_ACTION_REQUIRED = 2, + MF_MUST_KILL = 4, + MF_SOFT_OFFLINE = 8, +}; + +struct mce { + __u64 status; + __u64 misc; + __u64 addr; + __u64 mcgstatus; + __u64 ip; + __u64 tsc; + __u64 time; + __u8 cpuvendor; + __u8 inject_flags; + __u8 severity; + __u8 pad; + __u32 cpuid; + __u8 cs; + __u8 bank; + __u8 cpu; + __u8 finished; + __u32 extcpu; + __u32 socketid; + __u32 apicid; + __u64 mcgcap; + __u64 synd; + __u64 ipid; + __u64 ppin; + __u32 microcode; + __u64 kflags; +}; + +enum mce_notifier_prios { + MCE_PRIO_LOWEST = 0, + MCE_PRIO_MCELOG = 1, + MCE_PRIO_EDAC = 2, + MCE_PRIO_NFIT = 3, + MCE_PRIO_EXTLOG = 4, + MCE_PRIO_UC = 5, + MCE_PRIO_EARLY = 6, + MCE_PRIO_CEC = 7, +}; + +typedef long unsigned int mce_banks_t[1]; + +enum mcp_flags { + MCP_TIMESTAMP = 1, + MCP_UC = 2, + MCP_DONTLOG = 4, +}; + +enum severity_level { + MCE_NO_SEVERITY = 0, + MCE_DEFERRED_SEVERITY = 1, + MCE_UCNA_SEVERITY = 1, + MCE_KEEP_SEVERITY = 2, + MCE_SOME_SEVERITY = 3, + MCE_AO_SEVERITY = 4, + MCE_UC_SEVERITY = 5, + MCE_AR_SEVERITY = 6, + MCE_PANIC_SEVERITY = 7, +}; + +struct mce_evt_llist { + struct llist_node llnode; + struct mce mce; +}; + +struct mca_config { + bool dont_log_ce; + bool cmci_disabled; + bool ignore_ce; + bool print_all; + __u64 lmce_disabled: 1; + __u64 disabled: 1; + __u64 ser: 1; + __u64 recovery: 1; + __u64 bios_cmci_threshold: 1; + int: 27; + __u64 __reserved: 59; + s8 bootlog; + int tolerant; + int monarch_timeout; + int panic_timeout; + u32 rip_msr; +}; + +struct mce_vendor_flags { + __u64 overflow_recov: 1; + __u64 succor: 1; + __u64 smca: 1; + __u64 amd_threshold: 1; + __u64 __reserved_0: 60; +}; + +struct mca_msr_regs { + u32 (*ctl)(int); + u32 (*status)(int); + u32 (*addr)(int); + u32 (*misc)(int); +}; + +struct trace_event_raw_mce_record { + struct trace_entry ent; + u64 mcgcap; + u64 mcgstatus; + u64 status; + u64 addr; + u64 misc; + u64 synd; + u64 ipid; + u64 ip; + u64 tsc; + u64 walltime; + u32 cpu; + u32 cpuid; + u32 apicid; + u32 socketid; + u8 cs; + u8 bank; + u8 cpuvendor; + char __data[0]; +}; + +struct trace_event_data_offsets_mce_record {}; + +typedef void (*btf_trace_mce_record)(void *, struct mce *); + +struct mce_bank { + u64 ctl; + bool init; +}; + +struct mce_bank_dev { + struct device_attribute attr; + char attrname[16]; + u8 bank; +}; + +enum handler_type { + EX_HANDLER_NONE = 0, + EX_HANDLER_FAULT = 1, + EX_HANDLER_UACCESS = 2, + EX_HANDLER_OTHER = 3, +}; + +enum context { + IN_KERNEL = 1, + IN_USER = 2, + IN_KERNEL_RECOV = 3, +}; + +enum ser { + SER_REQUIRED = 1, + NO_SER = 2, +}; + +enum exception { + EXCP_CONTEXT = 1, + NO_EXCP = 2, +}; + +struct severity { + u64 mask; + u64 result; + unsigned char sev; + unsigned char mcgmask; + unsigned char mcgres; + unsigned char ser; + unsigned char context; + unsigned char excp; + unsigned char covered; + unsigned char cpu_model; + unsigned char cpu_minstepping; + unsigned char bank_lo; + unsigned char bank_hi; + char *msg; +}; + +struct gen_pool; + +typedef long unsigned int (*genpool_algo_t)(long unsigned int *, long unsigned int, long unsigned int, unsigned int, void *, struct gen_pool *, long unsigned int); + +struct gen_pool { + spinlock_t lock; + struct list_head chunks; + int min_alloc_order; + genpool_algo_t algo; + void *data; + const char *name; +}; + +enum { + CMCI_STORM_NONE = 0, + CMCI_STORM_ACTIVE = 1, + CMCI_STORM_SUBSIDED = 2, +}; + +enum kobject_action { + KOBJ_ADD = 0, + KOBJ_REMOVE = 1, + KOBJ_CHANGE = 2, + KOBJ_MOVE = 3, + KOBJ_ONLINE = 4, + KOBJ_OFFLINE = 5, + KOBJ_BIND = 6, + KOBJ_UNBIND = 7, +}; + +enum smca_bank_types { + SMCA_LS = 0, + SMCA_LS_V2 = 1, + SMCA_IF = 2, + SMCA_L2_CACHE = 3, + SMCA_DE = 4, + SMCA_RESERVED = 5, + SMCA_EX = 6, + SMCA_FP = 7, + SMCA_L3_CACHE = 8, + SMCA_CS = 9, + SMCA_CS_V2 = 10, + SMCA_PIE = 11, + SMCA_UMC = 12, + SMCA_PB = 13, + SMCA_PSP = 14, + SMCA_PSP_V2 = 15, + SMCA_SMU = 16, + SMCA_SMU_V2 = 17, + SMCA_MP5 = 18, + SMCA_NBIO = 19, + SMCA_PCIE = 20, + N_SMCA_BANK_TYPES = 21, +}; + +struct smca_hwid { + unsigned int bank_type; + u32 hwid_mcatype; + u8 count; +}; + +struct smca_bank { + struct smca_hwid *hwid; + u32 id; + u8 sysfs_id; +}; + +struct smca_bank_name { + const char *name; + const char *long_name; +}; + +struct thresh_restart { + struct threshold_block *b; + int reset; + int set_lvt_off; + int lvt_off; + u16 old_limit; +}; + +struct threshold_attr { + struct attribute attr; + ssize_t (*show)(struct threshold_block *, char *); + ssize_t (*store)(struct threshold_block *, const char *, size_t); +}; + +struct _thermal_state { + u64 next_check; + u64 last_interrupt_time; + struct delayed_work therm_work; + long unsigned int count; + long unsigned int last_count; + long unsigned int max_time_ms; + long unsigned int total_time_ms; + bool rate_control_active; + bool new_event; + u8 level; + u8 sample_index; + u8 sample_count; + u8 average; + u8 baseline_temp; + u8 temp_samples[3]; +}; + +struct thermal_state { + struct _thermal_state core_throttle; + struct _thermal_state core_power_limit; + struct _thermal_state package_throttle; + struct _thermal_state package_power_limit; + struct _thermal_state core_thresh0; + struct _thermal_state core_thresh1; + struct _thermal_state pkg_thresh0; + struct _thermal_state pkg_thresh1; +}; + +typedef __u8 mtrr_type; + +struct mtrr_ops { + u32 vendor; + u32 use_intel_if; + void (*set)(unsigned int, long unsigned int, long unsigned int, mtrr_type); + void (*set_all)(); + void (*get)(unsigned int, long unsigned int *, long unsigned int *, mtrr_type *); + int (*get_free_region)(long unsigned int, long unsigned int, int); + int (*validate_add_page)(long unsigned int, long unsigned int, unsigned int); + int (*have_wrcomb)(); +}; + +struct set_mtrr_data { + long unsigned int smp_base; + long unsigned int smp_size; + unsigned int smp_reg; + mtrr_type smp_type; +}; + +struct mtrr_value { + mtrr_type ltype; + long unsigned int lbase; + long unsigned int lsize; +}; + +struct proc_ops { + unsigned int proc_flags; + int (*proc_open)(struct inode *, struct file *); + ssize_t (*proc_read)(struct file *, char *, size_t, loff_t *); + ssize_t (*proc_read_iter)(struct kiocb *, struct iov_iter *); + ssize_t (*proc_write)(struct file *, const char *, size_t, loff_t *); + loff_t (*proc_lseek)(struct file *, loff_t, int); + int (*proc_release)(struct inode *, struct file *); + __poll_t (*proc_poll)(struct file *, struct poll_table_struct *); + long int (*proc_ioctl)(struct file *, unsigned int, long unsigned int); + long int (*proc_compat_ioctl)(struct file *, unsigned int, long unsigned int); + int (*proc_mmap)(struct file *, struct vm_area_struct *); + long unsigned int (*proc_get_unmapped_area)(struct file *, long unsigned int, long unsigned int, long unsigned int, long unsigned int); +}; + +struct mtrr_sentry { + __u64 base; + __u32 size; + __u32 type; +}; + +struct mtrr_gentry { + __u64 base; + __u32 size; + __u32 regnum; + __u32 type; + __u32 _pad; +}; + +typedef u32 compat_uint_t; + +struct mtrr_sentry32 { + compat_ulong_t base; + compat_uint_t size; + compat_uint_t type; +}; + +struct mtrr_gentry32 { + compat_ulong_t regnum; + compat_uint_t base; + compat_uint_t size; + compat_uint_t type; +}; + +struct mtrr_var_range { + __u32 base_lo; + __u32 base_hi; + __u32 mask_lo; + __u32 mask_hi; +}; + +struct mtrr_state_type { + struct mtrr_var_range var_ranges[256]; + mtrr_type fixed_ranges[88]; + unsigned char enabled; + unsigned char have_fixed; + mtrr_type def_type; +}; + +struct fixed_range_block { + int base_msr; + int ranges; +}; + +struct var_mtrr_range_state { + long unsigned int base_pfn; + long unsigned int size_pfn; + mtrr_type type; +}; + +struct mpc_intsrc { + unsigned char type; + unsigned char irqtype; + short unsigned int irqflag; + unsigned char srcbus; + unsigned char srcbusirq; + unsigned char dstapic; + unsigned char dstirq; +}; + +enum mp_irq_source_types { + mp_INT = 0, + mp_NMI = 1, + mp_SMI = 2, + mp_ExtINT = 3, +}; + +typedef u64 acpi_physical_address; + +typedef u32 acpi_status; + +typedef void *acpi_handle; + +typedef u8 acpi_adr_space_type; + +struct acpi_subtable_header { + u8 type; + u8 length; +}; + +struct acpi_table_boot { + struct acpi_table_header header; + u8 cmos_index; + u8 reserved[3]; +}; + +struct acpi_hmat_structure { + u16 type; + u16 reserved; + u32 length; +}; + +struct acpi_table_hpet { + struct acpi_table_header header; + u32 id; + struct acpi_generic_address address; + u8 sequence; + u16 minimum_tick; + u8 flags; +} __attribute__((packed)); + +struct acpi_table_madt { + struct acpi_table_header header; + u32 address; + u32 flags; +}; + +enum acpi_madt_type { + ACPI_MADT_TYPE_LOCAL_APIC = 0, + ACPI_MADT_TYPE_IO_APIC = 1, + ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2, + ACPI_MADT_TYPE_NMI_SOURCE = 3, + ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4, + ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5, + ACPI_MADT_TYPE_IO_SAPIC = 6, + ACPI_MADT_TYPE_LOCAL_SAPIC = 7, + ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, + ACPI_MADT_TYPE_LOCAL_X2APIC = 9, + ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10, + ACPI_MADT_TYPE_GENERIC_INTERRUPT = 11, + ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12, + ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13, + ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14, + ACPI_MADT_TYPE_GENERIC_TRANSLATOR = 15, + ACPI_MADT_TYPE_RESERVED = 16, +}; + +struct acpi_madt_local_apic { + struct acpi_subtable_header header; + u8 processor_id; + u8 id; + u32 lapic_flags; +}; + +struct acpi_madt_io_apic { + struct acpi_subtable_header header; + u8 id; + u8 reserved; + u32 address; + u32 global_irq_base; +}; + +struct acpi_madt_interrupt_override { + struct acpi_subtable_header header; + u8 bus; + u8 source_irq; + u32 global_irq; + u16 inti_flags; +} __attribute__((packed)); + +struct acpi_madt_nmi_source { + struct acpi_subtable_header header; + u16 inti_flags; + u32 global_irq; +}; + +struct acpi_madt_local_apic_nmi { + struct acpi_subtable_header header; + u8 processor_id; + u16 inti_flags; + u8 lint; +} __attribute__((packed)); + +struct acpi_madt_local_apic_override { + struct acpi_subtable_header header; + u16 reserved; + u64 address; +} __attribute__((packed)); + +struct acpi_madt_local_sapic { + struct acpi_subtable_header header; + u8 processor_id; + u8 id; + u8 eid; + u8 reserved[3]; + u32 lapic_flags; + u32 uid; + char uid_string[1]; +} __attribute__((packed)); + +struct acpi_madt_local_x2apic { + struct acpi_subtable_header header; + u16 reserved; + u32 local_apic_id; + u32 lapic_flags; + u32 uid; +}; + +struct acpi_madt_local_x2apic_nmi { + struct acpi_subtable_header header; + u16 inti_flags; + u32 uid; + u8 lint; + u8 reserved[3]; +}; + +enum acpi_irq_model_id { + ACPI_IRQ_MODEL_PIC = 0, + ACPI_IRQ_MODEL_IOAPIC = 1, + ACPI_IRQ_MODEL_IOSAPIC = 2, + ACPI_IRQ_MODEL_PLATFORM = 3, + ACPI_IRQ_MODEL_GIC = 4, + ACPI_IRQ_MODEL_COUNT = 5, +}; + +union acpi_subtable_headers { + struct acpi_subtable_header common; + struct acpi_hmat_structure hmat; +}; + +typedef int (*acpi_tbl_entry_handler)(union acpi_subtable_headers *, const long unsigned int); + +struct acpi_subtable_proc { + int id; + acpi_tbl_entry_handler handler; + int count; +}; + +typedef u32 phys_cpuid_t; + +enum irq_alloc_type { + X86_IRQ_ALLOC_TYPE_IOAPIC = 1, + X86_IRQ_ALLOC_TYPE_HPET = 2, + X86_IRQ_ALLOC_TYPE_PCI_MSI = 3, + X86_IRQ_ALLOC_TYPE_PCI_MSIX = 4, + X86_IRQ_ALLOC_TYPE_DMAR = 5, + X86_IRQ_ALLOC_TYPE_UV = 6, + X86_IRQ_ALLOC_TYPE_IOAPIC_GET_PARENT = 7, + X86_IRQ_ALLOC_TYPE_HPET_GET_PARENT = 8, +}; + +struct IO_APIC_route_entry; + +struct ioapic_alloc_info { + int pin; + int node; + u32 trigger: 1; + u32 polarity: 1; + u32 valid: 1; + struct IO_APIC_route_entry *entry; +}; + +struct IO_APIC_route_entry { + __u32 vector: 8; + __u32 delivery_mode: 3; + __u32 dest_mode: 1; + __u32 delivery_status: 1; + __u32 polarity: 1; + __u32 irr: 1; + __u32 trigger: 1; + __u32 mask: 1; + __u32 __reserved_2: 15; + __u32 __reserved_3: 24; + __u32 dest: 8; +}; + +struct uv_alloc_info { + int limit; + int blade; + long unsigned int offset; + char *name; +}; + +struct irq_alloc_info { + enum irq_alloc_type type; + u32 flags; + u32 devid; + irq_hw_number_t hwirq; + const struct cpumask *mask; + struct msi_desc *desc; + void *data; + union { + struct ioapic_alloc_info ioapic; + struct uv_alloc_info uv; + }; +}; + +struct serial_icounter_struct { + int cts; + int dsr; + int rng; + int dcd; + int rx; + int tx; + int frame; + int overrun; + int parity; + int brk; + int buf_overrun; + int reserved[9]; +}; + +struct serial_struct { + int type; + int line; + unsigned int port; + int irq; + int flags; + int xmit_fifo_size; + int custom_divisor; + int baud_base; + short unsigned int close_delay; + char io_type; + char reserved_char[1]; + int hub6; + short unsigned int closing_wait; + short unsigned int closing_wait2; + unsigned char *iomem_base; + short unsigned int iomem_reg_shift; + unsigned int port_high; + long unsigned int iomap_base; +}; + +enum ioapic_domain_type { + IOAPIC_DOMAIN_INVALID = 0, + IOAPIC_DOMAIN_LEGACY = 1, + IOAPIC_DOMAIN_STRICT = 2, + IOAPIC_DOMAIN_DYNAMIC = 3, +}; + +struct ioapic_domain_cfg { + enum ioapic_domain_type type; + const struct irq_domain_ops *ops; + struct device_node *dev; +}; + +struct wakeup_header { + u16 video_mode; + u32 pmode_entry; + u16 pmode_cs; + u32 pmode_cr0; + u32 pmode_cr3; + u32 pmode_cr4; + u32 pmode_efer_low; + u32 pmode_efer_high; + u64 pmode_gdt; + u32 pmode_misc_en_low; + u32 pmode_misc_en_high; + u32 pmode_behavior; + u32 realmode_flags; + u32 real_magic; + u32 signature; +} __attribute__((packed)); + +struct cpc_reg { + u8 descriptor; + u16 length; + u8 space_id; + u8 bit_width; + u8 bit_offset; + u8 access_width; + u64 address; +} __attribute__((packed)); + +struct acpi_power_register { + u8 descriptor; + u16 length; + u8 space_id; + u8 bit_width; + u8 bit_offset; + u8 access_size; + u64 address; +} __attribute__((packed)); + +struct acpi_processor_cx { + u8 valid; + u8 type; + u32 address; + u8 entry_method; + u8 index; + u32 latency; + u8 bm_sts_skip; + char desc[32]; +}; + +struct acpi_processor_flags { + u8 power: 1; + u8 performance: 1; + u8 throttling: 1; + u8 limit: 1; + u8 bm_control: 1; + u8 bm_check: 1; + u8 has_cst: 1; + u8 has_lpi: 1; + u8 power_setup_done: 1; + u8 bm_rld_set: 1; + u8 need_hotplug_init: 1; +}; + +struct cstate_entry { + struct { + unsigned int eax; + unsigned int ecx; + } states[8]; +}; + +enum reboot_mode { + REBOOT_UNDEFINED = 4294967295, + REBOOT_COLD = 0, + REBOOT_WARM = 1, + REBOOT_HARD = 2, + REBOOT_SOFT = 3, + REBOOT_GPIO = 4, +}; + +enum reboot_type { + BOOT_TRIPLE = 116, + BOOT_KBD = 107, + BOOT_BIOS = 98, + BOOT_ACPI = 97, + BOOT_EFI = 101, + BOOT_CF9_FORCE = 112, + BOOT_CF9_SAFE = 113, +}; + +struct vmcb_seg { + u16 selector; + u16 attrib; + u32 limit; + u64 base; +}; + +struct vmcb_save_area { + struct vmcb_seg es; + struct vmcb_seg cs; + struct vmcb_seg ss; + struct vmcb_seg ds; + struct vmcb_seg fs; + struct vmcb_seg gs; + struct vmcb_seg gdtr; + struct vmcb_seg ldtr; + struct vmcb_seg idtr; + struct vmcb_seg tr; + u8 reserved_1[43]; + u8 cpl; + u8 reserved_2[4]; + u64 efer; + u8 reserved_3[112]; + u64 cr4; + u64 cr3; + u64 cr0; + u64 dr7; + u64 dr6; + u64 rflags; + u64 rip; + u8 reserved_4[88]; + u64 rsp; + u8 reserved_5[24]; + u64 rax; + u64 star; + u64 lstar; + u64 cstar; + u64 sfmask; + u64 kernel_gs_base; + u64 sysenter_cs; + u64 sysenter_esp; + u64 sysenter_eip; + u64 cr2; + u8 reserved_6[32]; + u64 g_pat; + u64 dbgctl; + u64 br_from; + u64 br_to; + u64 last_excp_from; + u64 last_excp_to; + u8 reserved_7[104]; + u64 reserved_8; + u64 rcx; + u64 rdx; + u64 rbx; + u64 reserved_9; + u64 rbp; + u64 rsi; + u64 rdi; + u64 r8; + u64 r9; + u64 r10; + u64 r11; + u64 r12; + u64 r13; + u64 r14; + u64 r15; + u8 reserved_10[16]; + u64 sw_exit_code; + u64 sw_exit_info_1; + u64 sw_exit_info_2; + u64 sw_scratch; + u8 reserved_11[56]; + u64 xcr0; + u8 valid_bitmap[16]; + u64 x87_state_gpa; +}; + +struct ghcb { + struct vmcb_save_area save; + u8 reserved_save[1016]; + u8 shared_buffer[2032]; + u8 reserved_1[10]; + u16 protocol_version; + u32 ghcb_usage; +}; + +struct machine_ops { + void (*restart)(char *); + void (*halt)(); + void (*power_off)(); + void (*shutdown)(); + void (*crash_shutdown)(struct pt_regs *); + void (*emergency_restart)(); +}; + +typedef void (*nmi_shootdown_cb)(int, struct pt_regs *); + +enum intercept_words { + INTERCEPT_CR = 0, + INTERCEPT_DR = 1, + INTERCEPT_EXCEPTION = 2, + INTERCEPT_WORD3 = 3, + INTERCEPT_WORD4 = 4, + INTERCEPT_WORD5 = 5, + MAX_INTERCEPT = 6, +}; + +enum allow_write_msrs { + MSR_WRITES_ON = 0, + MSR_WRITES_OFF = 1, + MSR_WRITES_DEFAULT = 2, +}; + +typedef struct __call_single_data call_single_data_t; + +struct cpuid_regs_done { + struct cpuid_regs regs; + struct completion done; +}; + +struct intel_early_ops { + resource_size_t (*stolen_size)(int, int, int); + resource_size_t (*stolen_base)(int, int, int, resource_size_t); +}; + +struct chipset { + u32 vendor; + u32 device; + u32 class; + u32 class_mask; + u32 flags; + void (*f)(int, int, int); +}; + +enum { + SD_BALANCE_NEWIDLE = 1, + SD_BALANCE_EXEC = 2, + SD_BALANCE_FORK = 4, + SD_BALANCE_WAKE = 8, + SD_WAKE_AFFINE = 16, + SD_ASYM_CPUCAPACITY = 32, + SD_SHARE_CPUCAPACITY = 64, + SD_SHARE_PKG_RESOURCES = 128, + SD_SERIALIZE = 256, + SD_ASYM_PACKING = 512, + SD_PREFER_SIBLING = 1024, + SD_OVERLAP = 2048, + SD_NUMA = 4096, +}; + +struct sched_domain_shared { + atomic_t ref; + atomic_t nr_busy_cpus; + int has_idle_cores; +}; + +struct sched_group; + +struct sched_domain { + struct sched_domain *parent; + struct sched_domain *child; + struct sched_group *groups; + long unsigned int min_interval; + long unsigned int max_interval; + unsigned int busy_factor; + unsigned int imbalance_pct; + unsigned int cache_nice_tries; + int nohz_idle; + int flags; + int level; + long unsigned int last_balance; + unsigned int balance_interval; + unsigned int nr_balance_failed; + u64 max_newidle_lb_cost; + long unsigned int next_decay_max_lb_cost; + u64 avg_scan_cost; + unsigned int lb_count[3]; + unsigned int lb_failed[3]; + unsigned int lb_balanced[3]; + unsigned int lb_imbalance[3]; + unsigned int lb_gained[3]; + unsigned int lb_hot_gained[3]; + unsigned int lb_nobusyg[3]; + unsigned int lb_nobusyq[3]; + unsigned int alb_count; + unsigned int alb_failed; + unsigned int alb_pushed; + unsigned int sbe_count; + unsigned int sbe_balanced; + unsigned int sbe_pushed; + unsigned int sbf_count; + unsigned int sbf_balanced; + unsigned int sbf_pushed; + unsigned int ttwu_wake_remote; + unsigned int ttwu_move_affine; + unsigned int ttwu_move_balance; + char *name; + union { + void *private; + struct callback_head rcu; + }; + struct sched_domain_shared *shared; + unsigned int span_weight; + long unsigned int span[0]; +}; + +typedef const struct cpumask * (*sched_domain_mask_f)(int); + +typedef int (*sched_domain_flags_f)(); + +struct sched_group_capacity; + +struct sd_data { + struct sched_domain **sd; + struct sched_domain_shared **sds; + struct sched_group **sg; + struct sched_group_capacity **sgc; +}; + +struct sched_domain_topology_level { + sched_domain_mask_f mask; + sched_domain_flags_f sd_flags; + int flags; + int numa_level; + struct sd_data data; + char *name; +}; + +enum apic_intr_mode_id { + APIC_PIC = 0, + APIC_VIRTUAL_WIRE = 1, + APIC_VIRTUAL_WIRE_NO_CONFIG = 2, + APIC_SYMMETRIC_IO = 3, + APIC_SYMMETRIC_IO_NO_ROUTING = 4, +}; + +struct tsc_adjust { + s64 bootval; + s64 adjusted; + long unsigned int nextcheck; + bool warned; +}; + +enum { + DUMP_PREFIX_NONE = 0, + DUMP_PREFIX_ADDRESS = 1, + DUMP_PREFIX_OFFSET = 2, +}; + +struct mpf_intel { + char signature[4]; + unsigned int physptr; + unsigned char length; + unsigned char specification; + unsigned char checksum; + unsigned char feature1; + unsigned char feature2; + unsigned char feature3; + unsigned char feature4; + unsigned char feature5; +}; + +struct mpc_table { + char signature[4]; + short unsigned int length; + char spec; + char checksum; + char oem[8]; + char productid[12]; + unsigned int oemptr; + short unsigned int oemsize; + short unsigned int oemcount; + unsigned int lapic; + unsigned int reserved; +}; + +struct mpc_cpu { + unsigned char type; + unsigned char apicid; + unsigned char apicver; + unsigned char cpuflag; + unsigned int cpufeature; + unsigned int featureflag; + unsigned int reserved[2]; +}; + +struct mpc_bus { + unsigned char type; + unsigned char busid; + unsigned char bustype[6]; +}; + +struct mpc_ioapic { + unsigned char type; + unsigned char apicid; + unsigned char apicver; + unsigned char flags; + unsigned int apicaddr; +}; + +struct mpc_lintsrc { + unsigned char type; + unsigned char irqtype; + short unsigned int irqflag; + unsigned char srcbusid; + unsigned char srcbusirq; + unsigned char destapic; + unsigned char destapiclint; +}; + +enum page_cache_mode { + _PAGE_CACHE_MODE_WB = 0, + _PAGE_CACHE_MODE_WC = 1, + _PAGE_CACHE_MODE_UC_MINUS = 2, + _PAGE_CACHE_MODE_UC = 3, + _PAGE_CACHE_MODE_WT = 4, + _PAGE_CACHE_MODE_WP = 5, + _PAGE_CACHE_MODE_NUM = 8, +}; + +enum { + IRQ_REMAP_XAPIC_MODE = 0, + IRQ_REMAP_X2APIC_MODE = 1, +}; + +union apic_ir { + long unsigned int map[4]; + u32 regs[8]; +}; + +enum { + X2APIC_OFF = 0, + X2APIC_ON = 1, + X2APIC_DISABLED = 2, +}; + +enum ioapic_irq_destination_types { + dest_Fixed = 0, + dest_LowestPrio = 1, + dest_SMI = 2, + dest__reserved_1 = 3, + dest_NMI = 4, + dest_INIT = 5, + dest__reserved_2 = 6, + dest_ExtINT = 7, +}; + +enum { + IRQ_SET_MASK_OK = 0, + IRQ_SET_MASK_OK_NOCOPY = 1, + IRQ_SET_MASK_OK_DONE = 2, +}; + +enum { + IRQD_TRIGGER_MASK = 15, + IRQD_SETAFFINITY_PENDING = 256, + IRQD_ACTIVATED = 512, + IRQD_NO_BALANCING = 1024, + IRQD_PER_CPU = 2048, + IRQD_AFFINITY_SET = 4096, + IRQD_LEVEL = 8192, + IRQD_WAKEUP_STATE = 16384, + IRQD_MOVE_PCNTXT = 32768, + IRQD_IRQ_DISABLED = 65536, + IRQD_IRQ_MASKED = 131072, + IRQD_IRQ_INPROGRESS = 262144, + IRQD_WAKEUP_ARMED = 524288, + IRQD_FORWARDED_TO_VCPU = 1048576, + IRQD_AFFINITY_MANAGED = 2097152, + IRQD_IRQ_STARTED = 4194304, + IRQD_MANAGED_SHUTDOWN = 8388608, + IRQD_SINGLE_TARGET = 16777216, + IRQD_DEFAULT_TRIGGER_SET = 33554432, + IRQD_CAN_RESERVE = 67108864, + IRQD_MSI_NOMASK_QUIRK = 134217728, + IRQD_HANDLE_ENFORCE_IRQCTX = 268435456, + IRQD_AFFINITY_ON_ACTIVATE = 536870912, + IRQD_IRQ_ENABLED_ON_SUSPEND = 1073741824, +}; + +struct irq_cfg { + unsigned int dest_apicid; + unsigned int vector; +}; + +enum { + IRQCHIP_FWNODE_REAL = 0, + IRQCHIP_FWNODE_NAMED = 1, + IRQCHIP_FWNODE_NAMED_ID = 2, +}; + +enum { + X86_IRQ_ALLOC_CONTIGUOUS_VECTORS = 1, + X86_IRQ_ALLOC_LEGACY = 2, +}; + +struct apic_chip_data { + struct irq_cfg hw_irq_cfg; + unsigned int vector; + unsigned int prev_vector; + unsigned int cpu; + unsigned int prev_cpu; + unsigned int irq; + struct hlist_node clist; + unsigned int move_in_progress: 1; + unsigned int is_managed: 1; + unsigned int can_reserve: 1; + unsigned int has_reserved: 1; +}; + +struct irq_matrix; + +enum { + IRQ_TYPE_NONE = 0, + IRQ_TYPE_EDGE_RISING = 1, + IRQ_TYPE_EDGE_FALLING = 2, + IRQ_TYPE_EDGE_BOTH = 3, + IRQ_TYPE_LEVEL_HIGH = 4, + IRQ_TYPE_LEVEL_LOW = 8, + IRQ_TYPE_LEVEL_MASK = 12, + IRQ_TYPE_SENSE_MASK = 15, + IRQ_TYPE_DEFAULT = 15, + IRQ_TYPE_PROBE = 16, + IRQ_LEVEL = 256, + IRQ_PER_CPU = 512, + IRQ_NOPROBE = 1024, + IRQ_NOREQUEST = 2048, + IRQ_NOAUTOEN = 4096, + IRQ_NO_BALANCING = 8192, + IRQ_MOVE_PCNTXT = 16384, + IRQ_NESTED_THREAD = 32768, + IRQ_NOTHREAD = 65536, + IRQ_PER_CPU_DEVID = 131072, + IRQ_IS_POLLED = 262144, + IRQ_DISABLE_UNLAZY = 524288, + IRQ_HIDDEN = 1048576, +}; + +enum { + IRQCHIP_SET_TYPE_MASKED = 1, + IRQCHIP_EOI_IF_HANDLED = 2, + IRQCHIP_MASK_ON_SUSPEND = 4, + IRQCHIP_ONOFFLINE_ENABLED = 8, + IRQCHIP_SKIP_SET_WAKE = 16, + IRQCHIP_ONESHOT_SAFE = 32, + IRQCHIP_EOI_THREADED = 64, + IRQCHIP_SUPPORTS_LEVEL_MSI = 128, + IRQCHIP_SUPPORTS_NMI = 256, + IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND = 512, +}; + +struct clock_event_device___2; + +union IO_APIC_reg_00 { + u32 raw; + struct { + u32 __reserved_2: 14; + u32 LTS: 1; + u32 delivery_type: 1; + u32 __reserved_1: 8; + u32 ID: 8; + } bits; +}; + +union IO_APIC_reg_01 { + u32 raw; + struct { + u32 version: 8; + u32 __reserved_2: 7; + u32 PRQ: 1; + u32 entries: 8; + u32 __reserved_1: 8; + } bits; +}; + +union IO_APIC_reg_02 { + u32 raw; + struct { + u32 __reserved_2: 24; + u32 arbitration: 4; + u32 __reserved_1: 4; + } bits; +}; + +union IO_APIC_reg_03 { + u32 raw; + struct { + u32 boot_DT: 1; + u32 __reserved_1: 31; + } bits; +}; + +struct IR_IO_APIC_route_entry { + __u64 vector: 8; + __u64 zero: 3; + __u64 index2: 1; + __u64 delivery_status: 1; + __u64 polarity: 1; + __u64 irr: 1; + __u64 trigger: 1; + __u64 mask: 1; + __u64 reserved: 31; + __u64 format: 1; + __u64 index: 15; +}; + +struct irq_pin_list { + struct list_head list; + int apic; + int pin; +}; + +struct mp_chip_data { + struct list_head irq_2_pin; + struct IO_APIC_route_entry entry; + int trigger; + int polarity; + u32 count; + bool isa_irq; +}; + +struct mp_ioapic_gsi { + u32 gsi_base; + u32 gsi_end; +}; + +struct ioapic { + int nr_registers; + struct IO_APIC_route_entry *saved_registers; + struct mpc_ioapic mp_config; + struct mp_ioapic_gsi gsi_config; + struct ioapic_domain_cfg irqdomain_cfg; + struct irq_domain *irqdomain; + struct resource *iomem_res; +}; + +struct io_apic { + unsigned int index; + unsigned int unused[3]; + unsigned int data; + unsigned int unused2[11]; + unsigned int eoi; +}; + +union entry_union { + struct { + u32 w1; + u32 w2; + }; + struct IO_APIC_route_entry entry; +}; + +enum { + IRQ_DOMAIN_FLAG_HIERARCHY = 1, + IRQ_DOMAIN_NAME_ALLOCATED = 2, + IRQ_DOMAIN_FLAG_IPI_PER_CPU = 4, + IRQ_DOMAIN_FLAG_IPI_SINGLE = 8, + IRQ_DOMAIN_FLAG_MSI = 16, + IRQ_DOMAIN_FLAG_MSI_REMAP = 32, + IRQ_DOMAIN_MSI_NOMASK_QUIRK = 64, + IRQ_DOMAIN_FLAG_NONCORE = 65536, +}; + +typedef struct irq_alloc_info msi_alloc_info_t; + +struct msi_domain_info; + +struct msi_domain_ops { + irq_hw_number_t (*get_hwirq)(struct msi_domain_info *, msi_alloc_info_t *); + int (*msi_init)(struct irq_domain *, struct msi_domain_info *, unsigned int, irq_hw_number_t, msi_alloc_info_t *); + void (*msi_free)(struct irq_domain *, struct msi_domain_info *, unsigned int); + int (*msi_check)(struct irq_domain *, struct msi_domain_info *, struct device *); + int (*msi_prepare)(struct irq_domain *, struct device *, int, msi_alloc_info_t *); + void (*msi_finish)(msi_alloc_info_t *, int); + void (*set_desc)(msi_alloc_info_t *, struct msi_desc *); + int (*handle_error)(struct irq_domain *, struct msi_desc *, int); + int (*domain_alloc_irqs)(struct irq_domain *, struct device *, int); + void (*domain_free_irqs)(struct irq_domain *, struct device *); +}; + +struct msi_domain_info { + u32 flags; + struct msi_domain_ops *ops; + struct irq_chip *chip; + void *chip_data; + irq_flow_handler_t handler; + void *handler_data; + const char *handler_name; + void *data; +}; + +enum { + MSI_FLAG_USE_DEF_DOM_OPS = 1, + MSI_FLAG_USE_DEF_CHIP_OPS = 2, + MSI_FLAG_MULTI_PCI_MSI = 4, + MSI_FLAG_PCI_MSIX = 8, + MSI_FLAG_ACTIVATE_EARLY = 16, + MSI_FLAG_MUST_REACTIVATE = 32, + MSI_FLAG_LEVEL_CAPABLE = 64, +}; + +struct hpet_channel; + +struct cluster_mask { + unsigned int clusterid; + int node; + struct cpumask mask; +}; + +struct dyn_arch_ftrace {}; + +enum { + FTRACE_OPS_FL_ENABLED = 1, + FTRACE_OPS_FL_DYNAMIC = 2, + FTRACE_OPS_FL_SAVE_REGS = 4, + FTRACE_OPS_FL_SAVE_REGS_IF_SUPPORTED = 8, + FTRACE_OPS_FL_RECURSION_SAFE = 16, + FTRACE_OPS_FL_STUB = 32, + FTRACE_OPS_FL_INITIALIZED = 64, + FTRACE_OPS_FL_DELETED = 128, + FTRACE_OPS_FL_ADDING = 256, + FTRACE_OPS_FL_REMOVING = 512, + FTRACE_OPS_FL_MODIFYING = 1024, + FTRACE_OPS_FL_ALLOC_TRAMP = 2048, + FTRACE_OPS_FL_IPMODIFY = 4096, + FTRACE_OPS_FL_PID = 8192, + FTRACE_OPS_FL_RCU = 16384, + FTRACE_OPS_FL_TRACE_ARRAY = 32768, + FTRACE_OPS_FL_PERMANENT = 65536, + FTRACE_OPS_FL_DIRECT = 131072, +}; + +enum { + FTRACE_FL_ENABLED = 2147483648, + FTRACE_FL_REGS = 1073741824, + FTRACE_FL_REGS_EN = 536870912, + FTRACE_FL_TRAMP = 268435456, + FTRACE_FL_TRAMP_EN = 134217728, + FTRACE_FL_IPMODIFY = 67108864, + FTRACE_FL_DISABLED = 33554432, + FTRACE_FL_DIRECT = 16777216, + FTRACE_FL_DIRECT_EN = 8388608, +}; + +struct dyn_ftrace { + long unsigned int ip; + long unsigned int flags; + struct dyn_arch_ftrace arch; +}; + +enum { + FTRACE_UPDATE_IGNORE = 0, + FTRACE_UPDATE_MAKE_CALL = 1, + FTRACE_UPDATE_MODIFY_CALL = 2, + FTRACE_UPDATE_MAKE_NOP = 3, +}; + +union ftrace_op_code_union { + char code[7]; + struct { + char op[3]; + int offset; + } __attribute__((packed)); +}; + +struct ftrace_rec_iter; + +struct kimage_arch { + p4d_t *p4d; + pud_t *pud; + pmd_t *pmd; + pte_t *pte; + void *elf_headers; + long unsigned int elf_headers_sz; + long unsigned int elf_load_addr; +}; + +typedef long unsigned int kimage_entry_t; + +struct kexec_segment { + union { + void *buf; + void *kbuf; + }; + size_t bufsz; + long unsigned int mem; + size_t memsz; +}; + +struct kimage { + kimage_entry_t head; + kimage_entry_t *entry; + kimage_entry_t *last_entry; + long unsigned int start; + struct page *control_code_page; + struct page *swap_page; + void *vmcoreinfo_data_copy; + long unsigned int nr_segments; + struct kexec_segment segment[16]; + struct list_head control_pages; + struct list_head dest_pages; + struct list_head unusable_pages; + long unsigned int control_page; + unsigned int type: 1; + unsigned int preserve_context: 1; + unsigned int file_mode: 1; + struct kimage_arch arch; +}; + +struct x86_mapping_info { + void * (*alloc_pgt_page)(void *); + void *context; + long unsigned int page_flag; + long unsigned int offset; + bool direct_gbpages; + long unsigned int kernpg_flag; +}; + +struct init_pgtable_data { + struct x86_mapping_info *info; + pgd_t *level4p; +}; + +typedef void crash_vmclear_fn(); + +struct prev_kprobe { + struct kprobe *kp; + long unsigned int status; + long unsigned int old_flags; + long unsigned int saved_flags; +}; + +struct kprobe_ctlblk { + long unsigned int kprobe_status; + long unsigned int kprobe_old_flags; + long unsigned int kprobe_saved_flags; + struct prev_kprobe prev_kprobe; +}; + +struct kretprobe_instance; + +typedef int (*kretprobe_handler_t)(struct kretprobe_instance *, struct pt_regs *); + +struct kretprobe; + +struct kretprobe_instance { + union { + struct hlist_node hlist; + struct callback_head rcu; + }; + struct kretprobe *rp; + kprobe_opcode_t *ret_addr; + struct task_struct *task; + void *fp; + char data[0]; +}; + +struct kretprobe { + struct kprobe kp; + kretprobe_handler_t handler; + kretprobe_handler_t entry_handler; + int maxactive; + int nmissed; + size_t data_size; + struct hlist_head free_instances; + raw_spinlock_t lock; +}; + +struct kretprobe_blackpoint { + const char *name; + void *addr; +}; + +struct kprobe_insn_cache { + struct mutex mutex; + void * (*alloc)(); + void (*free)(void *); + const char *sym; + struct list_head pages; + size_t insn_size; + int nr_garbage; +}; + +struct __arch_relative_insn { + u8 op; + s32 raddr; +} __attribute__((packed)); + +struct arch_optimized_insn { + kprobe_opcode_t copied_insn[4]; + kprobe_opcode_t *insn; + size_t size; +}; + +struct optimized_kprobe { + struct kprobe kp; + struct list_head list; + struct arch_optimized_insn optinsn; +}; + +typedef __u64 Elf64_Off; + +typedef __s64 Elf64_Sxword; + +struct elf64_rela { + Elf64_Addr r_offset; + Elf64_Xword r_info; + Elf64_Sxword r_addend; +}; + +typedef struct elf64_rela Elf64_Rela; + +struct elf64_hdr { + unsigned char e_ident[16]; + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; + Elf64_Off e_phoff; + Elf64_Off e_shoff; + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; +}; + +typedef struct elf64_hdr Elf64_Ehdr; + +struct elf64_shdr { + Elf64_Word sh_name; + Elf64_Word sh_type; + Elf64_Xword sh_flags; + Elf64_Addr sh_addr; + Elf64_Off sh_offset; + Elf64_Xword sh_size; + Elf64_Word sh_link; + Elf64_Word sh_info; + Elf64_Xword sh_addralign; + Elf64_Xword sh_entsize; +}; + +typedef struct elf64_shdr Elf64_Shdr; + +struct console { + char name[16]; + void (*write)(struct console *, const char *, unsigned int); + int (*read)(struct console *, char *, unsigned int); + struct tty_driver * (*device)(struct console *, int *); + void (*unblank)(); + int (*setup)(struct console *, char *); + int (*exit)(struct console *); + int (*match)(struct console *, char *, int, char *); + short int flags; + short int index; + int cflag; + void *data; + struct console *next; +}; + +struct hpet_data { + long unsigned int hd_phys_address; + void *hd_address; + short unsigned int hd_nirqs; + unsigned int hd_state; + unsigned int hd_irq[32]; +}; + +typedef irqreturn_t (*rtc_irq_handler)(int, void *); + +enum hpet_mode { + HPET_MODE_UNUSED = 0, + HPET_MODE_LEGACY = 1, + HPET_MODE_CLOCKEVT = 2, + HPET_MODE_DEVICE = 3, +}; + +struct hpet_channel___2 { + struct clock_event_device evt; + unsigned int num; + unsigned int cpu; + unsigned int irq; + unsigned int in_use; + enum hpet_mode mode; + unsigned int boot_cfg; + char name[10]; + long: 48; + long: 64; + long: 64; + long: 64; +}; + +struct hpet_base { + unsigned int nr_channels; + unsigned int nr_clockevents; + unsigned int boot_cfg; + struct hpet_channel___2 *channels; +}; + +union hpet_lock { + struct { + arch_spinlock_t lock; + u32 value; + }; + u64 lockval; +}; + +struct amd_nb_bus_dev_range { + u8 bus; + u8 dev_base; + u8 dev_limit; +}; + +struct amd_northbridge_info { + u16 num; + u64 flags; + struct amd_northbridge *nb; +}; + +struct property_entry; + +struct platform_device_info { + struct device *parent; + struct fwnode_handle *fwnode; + bool of_node_reused; + const char *name; + int id; + const struct resource *res; + unsigned int num_res; + const void *data; + size_t size_data; + u64 dma_mask; + const struct property_entry *properties; +}; + +enum dev_prop_type { + DEV_PROP_U8 = 0, + DEV_PROP_U16 = 1, + DEV_PROP_U32 = 2, + DEV_PROP_U64 = 3, + DEV_PROP_STRING = 4, + DEV_PROP_REF = 5, +}; + +struct property_entry { + const char *name; + size_t length; + bool is_inline; + enum dev_prop_type type; + union { + const void *pointer; + union { + u8 u8_data[8]; + u16 u16_data[4]; + u32 u32_data[2]; + u64 u64_data[1]; + const char *str[1]; + } value; + }; +}; + +enum swiotlb_force { + SWIOTLB_NORMAL = 0, + SWIOTLB_FORCE = 1, + SWIOTLB_NO_FORCE = 2, +}; + +struct uprobe_xol_ops; + +struct arch_uprobe { + union { + u8 insn[16]; + u8 ixol[16]; + }; + const struct uprobe_xol_ops *ops; + union { + struct { + s32 offs; + u8 ilen; + u8 opc1; + } branch; + struct { + u8 fixups; + u8 ilen; + } defparam; + struct { + u8 reg_offset; + u8 ilen; + } push; + }; +}; + +struct uprobe_xol_ops { + bool (*emulate)(struct arch_uprobe *, struct pt_regs *); + int (*pre_xol)(struct arch_uprobe *, struct pt_regs *); + int (*post_xol)(struct arch_uprobe *, struct pt_regs *); + void (*abort)(struct arch_uprobe *, struct pt_regs *); +}; + +enum rp_check { + RP_CHECK_CALL = 0, + RP_CHECK_CHAIN_CALL = 1, + RP_CHECK_RET = 2, +}; + +struct simplefb_platform_data { + u32 width; + u32 height; + u32 stride; + const char *format; +}; + +enum { + M_I17 = 0, + M_I20 = 1, + M_I20_SR = 2, + M_I24 = 3, + M_I24_8_1 = 4, + M_I24_10_1 = 5, + M_I27_11_1 = 6, + M_MINI = 7, + M_MINI_3_1 = 8, + M_MINI_4_1 = 9, + M_MB = 10, + M_MB_2 = 11, + M_MB_3 = 12, + M_MB_5_1 = 13, + M_MB_6_1 = 14, + M_MB_7_1 = 15, + M_MB_SR = 16, + M_MBA = 17, + M_MBA_3 = 18, + M_MBP = 19, + M_MBP_2 = 20, + M_MBP_2_2 = 21, + M_MBP_SR = 22, + M_MBP_4 = 23, + M_MBP_5_1 = 24, + M_MBP_5_2 = 25, + M_MBP_5_3 = 26, + M_MBP_6_1 = 27, + M_MBP_6_2 = 28, + M_MBP_7_1 = 29, + M_MBP_8_2 = 30, + M_UNKNOWN = 31, +}; + +struct efifb_dmi_info { + char *optname; + long unsigned int base; + int stride; + int width; + int height; + int flags; +}; + +enum { + OVERRIDE_NONE = 0, + OVERRIDE_BASE = 1, + OVERRIDE_STRIDE = 2, + OVERRIDE_HEIGHT = 4, + OVERRIDE_WIDTH = 8, +}; + +enum perf_sample_regs_abi { + PERF_SAMPLE_REGS_ABI_NONE = 0, + PERF_SAMPLE_REGS_ABI_32 = 1, + PERF_SAMPLE_REGS_ABI_64 = 2, +}; + +struct __va_list_tag { + unsigned int gp_offset; + unsigned int fp_offset; + void *overflow_arg_area; + void *reg_save_area; +}; + +typedef __builtin_va_list __gnuc_va_list; + +typedef __gnuc_va_list va_list; + +struct va_format { + const char *fmt; + va_list *va; +}; + +enum chipset_type { + NOT_SUPPORTED = 0, + SUPPORTED = 1, +}; + +struct agp_version { + u16 major; + u16 minor; +}; + +struct agp_kern_info { + struct agp_version version; + struct pci_dev *device; + enum chipset_type chipset; + long unsigned int mode; + long unsigned int aper_base; + size_t aper_size; + int max_memory; + int current_memory; + bool cant_use_aperture; + long unsigned int page_mask; + const struct vm_operations_struct *vm_ops; +}; + +struct agp_bridge_data; + +struct pci_hostbridge_probe { + u32 bus; + u32 slot; + u32 vendor; + u32 device; +}; + +typedef u16 uint16_t; + +enum pg_level { + PG_LEVEL_NONE = 0, + PG_LEVEL_4K = 1, + PG_LEVEL_2M = 2, + PG_LEVEL_1G = 3, + PG_LEVEL_512G = 4, + PG_LEVEL_NUM = 5, +}; + +struct trace_print_flags { + long unsigned int mask; + const char *name; +}; + +enum tlb_flush_reason { + TLB_FLUSH_ON_TASK_SWITCH = 0, + TLB_REMOTE_SHOOTDOWN = 1, + TLB_LOCAL_SHOOTDOWN = 2, + TLB_LOCAL_MM_SHOOTDOWN = 3, + TLB_REMOTE_SEND_IPI = 4, + NR_TLB_FLUSH_REASONS = 5, +}; + +enum { + REGION_INTERSECTS = 0, + REGION_DISJOINT = 1, + REGION_MIXED = 2, +}; + +enum memblock_flags { + MEMBLOCK_NONE = 0, + MEMBLOCK_HOTPLUG = 1, + MEMBLOCK_MIRROR = 2, + MEMBLOCK_NOMAP = 4, +}; + +struct memblock_region { + phys_addr_t base; + phys_addr_t size; + enum memblock_flags flags; + int nid; +}; + +struct memblock_type { + long unsigned int cnt; + long unsigned int max; + phys_addr_t total_size; + struct memblock_region *regions; + char *name; +}; + +struct memblock { + bool bottom_up; + phys_addr_t current_limit; + struct memblock_type memory; + struct memblock_type reserved; +}; + +struct trace_event_raw_tlb_flush { + struct trace_entry ent; + int reason; + long unsigned int pages; + char __data[0]; +}; + +struct trace_event_data_offsets_tlb_flush {}; + +typedef void (*btf_trace_tlb_flush)(void *, int, long unsigned int); + +struct map_range { + long unsigned int start; + long unsigned int end; + unsigned int page_size_mask; +}; + +struct mem_section_usage { + long unsigned int subsection_map[1]; + long unsigned int pageblock_flags[0]; +}; + +struct mem_section { + long unsigned int section_mem_map; + struct mem_section_usage *usage; +}; + +enum kcore_type { + KCORE_TEXT = 0, + KCORE_VMALLOC = 1, + KCORE_RAM = 2, + KCORE_VMEMMAP = 3, + KCORE_USER = 4, + KCORE_OTHER = 5, + KCORE_REMAP = 6, +}; + +struct kcore_list { + struct list_head list; + long unsigned int addr; + long unsigned int vaddr; + size_t size; + int type; +}; + +struct hstate { + int next_nid_to_alloc; + int next_nid_to_free; + unsigned int order; + long unsigned int mask; + long unsigned int max_huge_pages; + long unsigned int nr_huge_pages; + long unsigned int free_huge_pages; + long unsigned int resv_huge_pages; + long unsigned int surplus_huge_pages; + long unsigned int nr_overcommit_huge_pages; + struct list_head hugepage_activelist; + struct list_head hugepage_freelists[64]; + unsigned int nr_huge_pages_node[64]; + unsigned int free_huge_pages_node[64]; + unsigned int surplus_huge_pages_node[64]; + struct cftype cgroup_files_dfl[7]; + struct cftype cgroup_files_legacy[9]; + char name[32]; +}; + +struct trace_event_raw_x86_exceptions { + struct trace_entry ent; + long unsigned int address; + long unsigned int ip; + long unsigned int error_code; + char __data[0]; +}; + +struct trace_event_data_offsets_x86_exceptions {}; + +typedef void (*btf_trace_page_fault_user)(void *, long unsigned int, struct pt_regs *, long unsigned int); + +typedef void (*btf_trace_page_fault_kernel)(void *, long unsigned int, struct pt_regs *, long unsigned int); + +enum { + IORES_MAP_SYSTEM_RAM = 1, + IORES_MAP_ENCRYPTED = 2, +}; + +struct ioremap_desc { + unsigned int flags; +}; + +typedef bool (*ex_handler_t)(const struct exception_table_entry *, struct pt_regs *, int, long unsigned int, long unsigned int); + +struct hugepage_subpool { + spinlock_t lock; + long int count; + long int max_hpages; + long int used_hpages; + struct hstate *hstate; + long int min_hpages; + long int rsv_hpages; +}; + +struct hugetlbfs_sb_info { + long int max_inodes; + long int free_inodes; + spinlock_t stat_lock; + struct hstate *hstate; + struct hugepage_subpool *spool; + kuid_t uid; + kgid_t gid; + umode_t mode; +}; + +struct flush_tlb_info { + struct mm_struct *mm; + long unsigned int start; + long unsigned int end; + u64 new_tlb_gen; + unsigned int stride_shift; + bool freed_tables; +}; + +struct entry_stack_page { + struct entry_stack stack; +}; + +struct debug_store_buffers { + char bts_buffer[65536]; + char pebs_buffer[65536]; +}; + +struct exception_stacks { + char DF_stack_guard[0]; + char DF_stack[4096]; + char NMI_stack_guard[0]; + char NMI_stack[4096]; + char DB_stack_guard[0]; + char DB_stack[4096]; + char MCE_stack_guard[0]; + char MCE_stack[4096]; + char VC_stack_guard[0]; + char VC_stack[0]; + char VC2_stack_guard[0]; + char VC2_stack[0]; + char IST_top_guard[0]; +}; + +struct cpu_entry_area { + char gdt[4096]; + struct entry_stack_page entry_stack_page; + struct tss_struct tss; + struct cea_exception_stacks estacks; + struct debug_store cpu_debug_store; + struct debug_store_buffers cpu_debug_buffers; +}; + +struct cpa_data { + long unsigned int *vaddr; + pgd_t *pgd; + pgprot_t mask_set; + pgprot_t mask_clr; + long unsigned int numpages; + long unsigned int curpage; + long unsigned int pfn; + unsigned int flags; + unsigned int force_split: 1; + unsigned int force_static_prot: 1; + unsigned int force_flush_all: 1; + struct page **pages; +}; + +enum cpa_warn { + CPA_CONFLICT = 0, + CPA_PROTECT = 1, + CPA_DETECT = 2, +}; + +typedef struct { + u64 val; +} pfn_t; + +struct memtype { + u64 start; + u64 end; + u64 subtree_max_end; + enum page_cache_mode type; + struct rb_node rb; +}; + +enum { + PAT_UC = 0, + PAT_WC = 1, + PAT_WT = 4, + PAT_WP = 5, + PAT_WB = 6, + PAT_UC_MINUS = 7, +}; + +struct pagerange_state { + long unsigned int cur_pfn; + int ram; + int not_ram; +}; + +struct rb_augment_callbacks { + void (*propagate)(struct rb_node *, struct rb_node *); + void (*copy)(struct rb_node *, struct rb_node *); + void (*rotate)(struct rb_node *, struct rb_node *); +}; + +enum { + MEMTYPE_EXACT_MATCH = 0, + MEMTYPE_END_MATCH = 1, +}; + +struct numa_memblk { + u64 start; + u64 end; + int nid; +}; + +struct numa_meminfo { + int nr_blks; + struct numa_memblk blk[128]; +}; + +struct acpi_srat_cpu_affinity { + struct acpi_subtable_header header; + u8 proximity_domain_lo; + u8 apic_id; + u32 flags; + u8 local_sapic_eid; + u8 proximity_domain_hi[3]; + u32 clock_domain; +}; + +struct acpi_srat_x2apic_cpu_affinity { + struct acpi_subtable_header header; + u16 reserved; + u32 proximity_domain; + u32 apic_id; + u32 flags; + u32 clock_domain; + u32 reserved2; +}; + +enum uv_system_type { + UV_NONE = 0, + UV_LEGACY_APIC = 1, + UV_X2APIC = 2, +}; + +enum pti_mode { + PTI_AUTO = 0, + PTI_FORCE_OFF = 1, + PTI_FORCE_ON = 2, +}; + +enum pti_clone_level { + PTI_CLONE_PMD = 0, + PTI_CLONE_PTE = 1, +}; + +struct sigcontext_32 { + __u16 gs; + __u16 __gsh; + __u16 fs; + __u16 __fsh; + __u16 es; + __u16 __esh; + __u16 ds; + __u16 __dsh; + __u32 di; + __u32 si; + __u32 bp; + __u32 sp; + __u32 bx; + __u32 dx; + __u32 cx; + __u32 ax; + __u32 trapno; + __u32 err; + __u32 ip; + __u16 cs; + __u16 __csh; + __u32 flags; + __u32 sp_at_signal; + __u16 ss; + __u16 __ssh; + __u32 fpstate; + __u32 oldmask; + __u32 cr2; +}; + +typedef u32 compat_size_t; + +struct compat_sigaltstack { + compat_uptr_t ss_sp; + int ss_flags; + compat_size_t ss_size; +}; + +typedef struct compat_sigaltstack compat_stack_t; + +struct ucontext_ia32 { + unsigned int uc_flags; + unsigned int uc_link; + compat_stack_t uc_stack; + struct sigcontext_32 uc_mcontext; + compat_sigset_t uc_sigmask; +}; + +struct sigframe_ia32 { + u32 pretcode; + int sig; + struct sigcontext_32 sc; + struct _fpstate_32 fpstate_unused; + unsigned int extramask[1]; + char retcode[8]; +}; + +struct rt_sigframe_ia32 { + u32 pretcode; + int sig; + u32 pinfo; + u32 puc; + compat_siginfo_t info; + struct ucontext_ia32 uc; + char retcode[8]; +}; + +typedef struct { + efi_guid_t guid; + u64 table; +} efi_config_table_64_t; + +struct efi_memory_map_data { + phys_addr_t phys_map; + long unsigned int size; + long unsigned int desc_version; + long unsigned int desc_size; + long unsigned int flags; +}; + +struct efi_mem_range { + struct range range; + u64 attribute; +}; + +enum efi_rts_ids { + EFI_NONE = 0, + EFI_GET_TIME = 1, + EFI_SET_TIME = 2, + EFI_GET_WAKEUP_TIME = 3, + EFI_SET_WAKEUP_TIME = 4, + EFI_GET_VARIABLE = 5, + EFI_GET_NEXT_VARIABLE = 6, + EFI_SET_VARIABLE = 7, + EFI_QUERY_VARIABLE_INFO = 8, + EFI_GET_NEXT_HIGH_MONO_COUNT = 9, + EFI_RESET_SYSTEM = 10, + EFI_UPDATE_CAPSULE = 11, + EFI_QUERY_CAPSULE_CAPS = 12, +}; + +struct efi_runtime_work { + void *arg1; + void *arg2; + void *arg3; + void *arg4; + void *arg5; + efi_status_t status; + struct work_struct work; + enum efi_rts_ids efi_rts_id; + struct completion efi_rts_comp; +}; + +struct efi_scratch { + u64 phys_stack; + struct mm_struct *prev_mm; +}; + +struct efi_setup_data { + u64 fw_vendor; + u64 __unused; + u64 tables; + u64 smbios; + u64 reserved[8]; +}; + +typedef struct { + efi_guid_t guid; + long unsigned int *ptr; + const char name[16]; +} efi_config_table_type_t; + +typedef struct { + efi_table_hdr_t hdr; + u64 fw_vendor; + u32 fw_revision; + u32 __pad1; + u64 con_in_handle; + u64 con_in; + u64 con_out_handle; + u64 con_out; + u64 stderr_handle; + u64 stderr; + u64 runtime; + u64 boottime; + u32 nr_tables; + u32 __pad2; + u64 tables; +} efi_system_table_64_t; + +typedef struct { + efi_table_hdr_t hdr; + u32 fw_vendor; + u32 fw_revision; + u32 con_in_handle; + u32 con_in; + u32 con_out_handle; + u32 con_out; + u32 stderr_handle; + u32 stderr; + u32 runtime; + u32 boottime; + u32 nr_tables; + u32 tables; +} efi_system_table_32_t; + +typedef struct { + u32 version; + u32 length; + u64 memory_protection_attribute; +} efi_properties_table_t; + +union efi_boot_services; + +typedef union efi_boot_services efi_boot_services_t; + +union efi_simple_text_input_protocol; + +typedef union efi_simple_text_input_protocol efi_simple_text_input_protocol_t; + +union efi_simple_text_output_protocol; + +typedef union efi_simple_text_output_protocol efi_simple_text_output_protocol_t; + +typedef union { + struct { + efi_table_hdr_t hdr; + long unsigned int fw_vendor; + u32 fw_revision; + long unsigned int con_in_handle; + efi_simple_text_input_protocol_t *con_in; + long unsigned int con_out_handle; + efi_simple_text_output_protocol_t *con_out; + long unsigned int stderr_handle; + long unsigned int stderr; + efi_runtime_services_t *runtime; + efi_boot_services_t *boottime; + long unsigned int nr_tables; + long unsigned int tables; + }; + efi_system_table_32_t mixed_mode; +} efi_system_table_t; + +enum { + BPF_REG_0 = 0, + BPF_REG_1 = 1, + BPF_REG_2 = 2, + BPF_REG_3 = 3, + BPF_REG_4 = 4, + BPF_REG_5 = 5, + BPF_REG_6 = 6, + BPF_REG_7 = 7, + BPF_REG_8 = 8, + BPF_REG_9 = 9, + BPF_REG_10 = 10, + __MAX_BPF_REG = 11, +}; + +struct bpf_tramp_progs { + struct bpf_prog *progs[40]; + int nr_progs; +}; + +enum bpf_jit_poke_reason { + BPF_POKE_REASON_TAIL_CALL = 0, +}; + +struct bpf_array_aux { + enum bpf_prog_type type; + bool jited; + struct list_head poke_progs; + struct bpf_map *map; + struct mutex poke_mutex; + struct work_struct work; +}; + +struct bpf_array { + struct bpf_map map; + u32 elem_size; + u32 index_mask; + struct bpf_array_aux *aux; + union { + char value[0]; + void *ptrs[0]; + void *pptrs[0]; + }; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +enum bpf_text_poke_type { + BPF_MOD_CALL = 0, + BPF_MOD_JUMP = 1, +}; + +struct bpf_binary_header { + u32 pages; + int: 32; + u8 image[0]; +}; + +struct jit_context { + int cleanup_addr; +}; + +struct x64_jit_data { + struct bpf_binary_header *header; + int *addrs; + u8 *image; + int proglen; + struct jit_context ctx; +}; + +struct static_key_true { + struct static_key key; +}; + +enum tk_offsets { + TK_OFFS_REAL = 0, + TK_OFFS_BOOT = 1, + TK_OFFS_TAI = 2, + TK_OFFS_MAX = 3, +}; + +typedef struct pglist_data pg_data_t; + +struct clone_args { + __u64 flags; + __u64 pidfd; + __u64 child_tid; + __u64 parent_tid; + __u64 exit_signal; + __u64 stack; + __u64 stack_size; + __u64 tls; + __u64 set_tid; + __u64 set_tid_size; + __u64 cgroup; +}; + +struct fdtable { + unsigned int max_fds; + struct file **fd; + long unsigned int *close_on_exec; + long unsigned int *open_fds; + long unsigned int *full_fds_bits; + struct callback_head rcu; +}; + +struct files_struct { + atomic_t count; + bool resize_in_progress; + wait_queue_head_t resize_wait; + struct fdtable *fdt; + struct fdtable fdtab; + long: 64; + long: 64; + spinlock_t file_lock; + unsigned int next_fd; + long unsigned int close_on_exec_init[1]; + long unsigned int open_fds_init[1]; + long unsigned int full_fds_bits_init[1]; + struct file *fd_array[64]; + long: 64; +}; + +struct io_identity { + struct files_struct *files; + struct mm_struct *mm; + struct cgroup_subsys_state *blkcg_css; + const struct cred *creds; + struct nsproxy *nsproxy; + struct fs_struct *fs; + long unsigned int fsize; + kuid_t loginuid; + unsigned int sessionid; + refcount_t count; +}; + +struct io_uring_task { + struct xarray xa; + struct wait_queue_head wait; + struct file *last; + struct percpu_counter inflight; + struct io_identity __identity; + struct io_identity *identity; + atomic_t in_idle; + bool sqpoll; +}; + +struct robust_list { + struct robust_list *next; +}; + +struct robust_list_head { + struct robust_list list; + long int futex_offset; + struct robust_list *list_op_pending; +}; + +struct multiprocess_signals { + sigset_t signal; + struct hlist_node node; +}; + +typedef int (*proc_visitor)(struct task_struct *, void *); + +enum { + IOPRIO_CLASS_NONE = 0, + IOPRIO_CLASS_RT = 1, + IOPRIO_CLASS_BE = 2, + IOPRIO_CLASS_IDLE = 3, +}; + +enum page_memcg_data_flags { + MEMCG_DATA_OBJCGS = 1, + MEMCG_DATA_KMEM = 2, + __NR_MEMCG_DATA_FLAGS = 4, +}; + +typedef struct poll_table_struct poll_table; + +enum { + FUTEX_STATE_OK = 0, + FUTEX_STATE_EXITING = 1, + FUTEX_STATE_DEAD = 2, +}; + +enum proc_hidepid { + HIDEPID_OFF = 0, + HIDEPID_NO_ACCESS = 1, + HIDEPID_INVISIBLE = 2, + HIDEPID_NOT_PTRACEABLE = 4, +}; + +enum proc_pidonly { + PROC_PIDONLY_OFF = 0, + PROC_PIDONLY_ON = 1, +}; + +struct proc_fs_info { + struct pid_namespace *pid_ns; + struct dentry *proc_self; + struct dentry *proc_thread_self; + kgid_t pid_gid; + enum proc_hidepid hide_pid; + enum proc_pidonly pidonly; +}; + +struct trace_event_raw_task_newtask { + struct trace_entry ent; + pid_t pid; + char comm[16]; + long unsigned int clone_flags; + short int oom_score_adj; + char __data[0]; +}; + +struct trace_event_raw_task_rename { + struct trace_entry ent; + pid_t pid; + char oldcomm[16]; + char newcomm[16]; + short int oom_score_adj; + char __data[0]; +}; + +struct trace_event_data_offsets_task_newtask {}; + +struct trace_event_data_offsets_task_rename {}; + +typedef void (*btf_trace_task_newtask)(void *, struct task_struct *, long unsigned int); + +typedef void (*btf_trace_task_rename)(void *, struct task_struct *, const char *); + +struct taint_flag { + char c_true; + char c_false; + bool module; +}; + +enum ftrace_dump_mode { + DUMP_NONE = 0, + DUMP_ALL = 1, + DUMP_ORIG = 2, +}; + +enum kmsg_dump_reason { + KMSG_DUMP_UNDEF = 0, + KMSG_DUMP_PANIC = 1, + KMSG_DUMP_OOPS = 2, + KMSG_DUMP_EMERG = 3, + KMSG_DUMP_SHUTDOWN = 4, + KMSG_DUMP_MAX = 5, +}; + +enum con_flush_mode { + CONSOLE_FLUSH_PENDING = 0, + CONSOLE_REPLAY_ALL = 1, +}; + +struct warn_args { + const char *fmt; + va_list args; +}; + +struct smp_hotplug_thread { + struct task_struct **store; + struct list_head list; + int (*thread_should_run)(unsigned int); + void (*thread_fn)(unsigned int); + void (*create)(unsigned int); + void (*setup)(unsigned int); + void (*cleanup)(unsigned int, bool); + void (*park)(unsigned int); + void (*unpark)(unsigned int); + bool selfparking; + const char *thread_comm; +}; + +struct trace_event_raw_cpuhp_enter { + struct trace_entry ent; + unsigned int cpu; + int target; + int idx; + void *fun; + char __data[0]; +}; + +struct trace_event_raw_cpuhp_multi_enter { + struct trace_entry ent; + unsigned int cpu; + int target; + int idx; + void *fun; + char __data[0]; +}; + +struct trace_event_raw_cpuhp_exit { + struct trace_entry ent; + unsigned int cpu; + int state; + int idx; + int ret; + char __data[0]; +}; + +struct trace_event_data_offsets_cpuhp_enter {}; + +struct trace_event_data_offsets_cpuhp_multi_enter {}; + +struct trace_event_data_offsets_cpuhp_exit {}; + +typedef void (*btf_trace_cpuhp_enter)(void *, unsigned int, int, int, int (*)(unsigned int)); + +typedef void (*btf_trace_cpuhp_multi_enter)(void *, unsigned int, int, int, int (*)(unsigned int, struct hlist_node *), struct hlist_node *); + +typedef void (*btf_trace_cpuhp_exit)(void *, unsigned int, int, int, int); + +struct cpuhp_cpu_state { + enum cpuhp_state state; + enum cpuhp_state target; + enum cpuhp_state fail; + struct task_struct *thread; + bool should_run; + bool rollback; + bool single; + bool bringup; + struct hlist_node *node; + struct hlist_node *last; + enum cpuhp_state cb_state; + int result; + struct completion done_up; + struct completion done_down; +}; + +struct cpuhp_step { + const char *name; + union { + int (*single)(unsigned int); + int (*multi)(unsigned int, struct hlist_node *); + } startup; + union { + int (*single)(unsigned int); + int (*multi)(unsigned int, struct hlist_node *); + } teardown; + struct hlist_head list; + bool cant_stop; + bool multi_instance; +}; + +enum cpu_mitigations { + CPU_MITIGATIONS_OFF = 0, + CPU_MITIGATIONS_AUTO = 1, + CPU_MITIGATIONS_AUTO_NOSMT = 2, +}; + +struct __kernel_old_timeval { + __kernel_long_t tv_sec; + __kernel_long_t tv_usec; +}; + +struct old_timeval32 { + old_time32_t tv_sec; + s32 tv_usec; +}; + +struct rusage { + struct __kernel_old_timeval ru_utime; + struct __kernel_old_timeval ru_stime; + __kernel_long_t ru_maxrss; + __kernel_long_t ru_ixrss; + __kernel_long_t ru_idrss; + __kernel_long_t ru_isrss; + __kernel_long_t ru_minflt; + __kernel_long_t ru_majflt; + __kernel_long_t ru_nswap; + __kernel_long_t ru_inblock; + __kernel_long_t ru_oublock; + __kernel_long_t ru_msgsnd; + __kernel_long_t ru_msgrcv; + __kernel_long_t ru_nsignals; + __kernel_long_t ru_nvcsw; + __kernel_long_t ru_nivcsw; +}; + +typedef struct {} mm_segment_t; + +struct compat_rusage { + struct old_timeval32 ru_utime; + struct old_timeval32 ru_stime; + compat_long_t ru_maxrss; + compat_long_t ru_ixrss; + compat_long_t ru_idrss; + compat_long_t ru_isrss; + compat_long_t ru_minflt; + compat_long_t ru_majflt; + compat_long_t ru_nswap; + compat_long_t ru_inblock; + compat_long_t ru_oublock; + compat_long_t ru_msgsnd; + compat_long_t ru_msgrcv; + compat_long_t ru_nsignals; + compat_long_t ru_nvcsw; + compat_long_t ru_nivcsw; +}; + +struct waitid_info { + pid_t pid; + uid_t uid; + int status; + int cause; +}; + +struct wait_opts { + enum pid_type wo_type; + int wo_flags; + struct pid *wo_pid; + struct waitid_info *wo_info; + int wo_stat; + struct rusage *wo_rusage; + wait_queue_entry_t child_wait; + int notask_error; +}; + +struct softirq_action { + void (*action)(struct softirq_action *); +}; + +struct tasklet_struct { + struct tasklet_struct *next; + long unsigned int state; + atomic_t count; + bool use_callback; + union { + void (*func)(long unsigned int); + void (*callback)(struct tasklet_struct *); + }; + long unsigned int data; +}; + +enum { + TASKLET_STATE_SCHED = 0, + TASKLET_STATE_RUN = 1, +}; + +struct kernel_stat { + long unsigned int irqs_sum; + unsigned int softirqs[10]; +}; + +struct trace_event_raw_irq_handler_entry { + struct trace_entry ent; + int irq; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_irq_handler_exit { + struct trace_entry ent; + int irq; + int ret; + char __data[0]; +}; + +struct trace_event_raw_softirq { + struct trace_entry ent; + unsigned int vec; + char __data[0]; +}; + +struct trace_event_data_offsets_irq_handler_entry { + u32 name; +}; + +struct trace_event_data_offsets_irq_handler_exit {}; + +struct trace_event_data_offsets_softirq {}; + +typedef void (*btf_trace_irq_handler_entry)(void *, int, struct irqaction *); + +typedef void (*btf_trace_irq_handler_exit)(void *, int, struct irqaction *, int); + +typedef void (*btf_trace_softirq_entry)(void *, unsigned int); + +typedef void (*btf_trace_softirq_exit)(void *, unsigned int); + +typedef void (*btf_trace_softirq_raise)(void *, unsigned int); + +struct tasklet_head { + struct tasklet_struct *head; + struct tasklet_struct **tail; +}; + +typedef void (*dr_release_t)(struct device *, void *); + +struct resource_entry { + struct list_head node; + struct resource *res; + resource_size_t offset; + struct resource __res; +}; + +struct resource_constraint { + resource_size_t min; + resource_size_t max; + resource_size_t align; + resource_size_t (*alignf)(void *, const struct resource *, resource_size_t, resource_size_t); + void *alignf_data; +}; + +enum { + MAX_IORES_LEVEL = 5, +}; + +struct region_devres { + struct resource *parent; + resource_size_t start; + resource_size_t n; +}; + +struct dentry_stat_t { + long int nr_dentry; + long int nr_unused; + long int age_limit; + long int want_pages; + long int nr_negative; + long int dummy; +}; + +struct files_stat_struct { + long unsigned int nr_files; + long unsigned int nr_free_files; + long unsigned int max_files; +}; + +struct inodes_stat_t { + long int nr_inodes; + long int nr_unused; + long int dummy[5]; +}; + +enum sched_tunable_scaling { + SCHED_TUNABLESCALING_NONE = 0, + SCHED_TUNABLESCALING_LOG = 1, + SCHED_TUNABLESCALING_LINEAR = 2, + SCHED_TUNABLESCALING_END = 3, +}; + +enum sysctl_writes_mode { + SYSCTL_WRITES_LEGACY = 4294967295, + SYSCTL_WRITES_WARN = 0, + SYSCTL_WRITES_STRICT = 1, +}; + +struct do_proc_dointvec_minmax_conv_param { + int *min; + int *max; +}; + +struct do_proc_douintvec_minmax_conv_param { + unsigned int *min; + unsigned int *max; +}; + +struct __user_cap_header_struct { + __u32 version; + int pid; +}; + +typedef struct __user_cap_header_struct *cap_user_header_t; + +struct __user_cap_data_struct { + __u32 effective; + __u32 permitted; + __u32 inheritable; +}; + +typedef struct __user_cap_data_struct *cap_user_data_t; + +struct sigqueue { + struct list_head list; + int flags; + kernel_siginfo_t info; + struct user_struct *user; +}; + +struct ptrace_peeksiginfo_args { + __u64 off; + __u32 flags; + __s32 nr; +}; + +struct ptrace_syscall_info { + __u8 op; + __u32 arch; + __u64 instruction_pointer; + __u64 stack_pointer; + union { + struct { + __u64 nr; + __u64 args[6]; + } entry; + struct { + __s64 rval; + __u8 is_error; + } exit; + struct { + __u64 nr; + __u64 args[6]; + __u32 ret_data; + } seccomp; + }; +}; + +struct compat_iovec { + compat_uptr_t iov_base; + compat_size_t iov_len; +}; + +typedef long unsigned int old_sigset_t; + +enum siginfo_layout { + SIL_KILL = 0, + SIL_TIMER = 1, + SIL_POLL = 2, + SIL_FAULT = 3, + SIL_FAULT_MCEERR = 4, + SIL_FAULT_BNDERR = 5, + SIL_FAULT_PKUERR = 6, + SIL_CHLD = 7, + SIL_RT = 8, + SIL_SYS = 9, +}; + +struct fd { + struct file *file; + unsigned int flags; +}; + +typedef u32 compat_old_sigset_t; + +struct compat_sigaction { + compat_uptr_t sa_handler; + compat_ulong_t sa_flags; + compat_uptr_t sa_restorer; + compat_sigset_t sa_mask; +}; + +struct compat_old_sigaction { + compat_uptr_t sa_handler; + compat_old_sigset_t sa_mask; + compat_ulong_t sa_flags; + compat_uptr_t sa_restorer; +}; + +enum { + TRACE_SIGNAL_DELIVERED = 0, + TRACE_SIGNAL_IGNORED = 1, + TRACE_SIGNAL_ALREADY_PENDING = 2, + TRACE_SIGNAL_OVERFLOW_FAIL = 3, + TRACE_SIGNAL_LOSE_INFO = 4, +}; + +struct trace_event_raw_signal_generate { + struct trace_entry ent; + int sig; + int errno; + int code; + char comm[16]; + pid_t pid; + int group; + int result; + char __data[0]; +}; + +struct trace_event_raw_signal_deliver { + struct trace_entry ent; + int sig; + int errno; + int code; + long unsigned int sa_handler; + long unsigned int sa_flags; + char __data[0]; +}; + +struct trace_event_data_offsets_signal_generate {}; + +struct trace_event_data_offsets_signal_deliver {}; + +typedef void (*btf_trace_signal_generate)(void *, int, struct kernel_siginfo *, struct task_struct *, int, int); + +typedef void (*btf_trace_signal_deliver)(void *, int, struct kernel_siginfo *, struct k_sigaction *); + +typedef __kernel_clock_t clock_t; + +struct sysinfo { + __kernel_long_t uptime; + __kernel_ulong_t loads[3]; + __kernel_ulong_t totalram; + __kernel_ulong_t freeram; + __kernel_ulong_t sharedram; + __kernel_ulong_t bufferram; + __kernel_ulong_t totalswap; + __kernel_ulong_t freeswap; + __u16 procs; + __u16 pad; + __kernel_ulong_t totalhigh; + __kernel_ulong_t freehigh; + __u32 mem_unit; + char _f[0]; +}; + +enum { + PER_LINUX = 0, + PER_LINUX_32BIT = 8388608, + PER_LINUX_FDPIC = 524288, + PER_SVR4 = 68157441, + PER_SVR3 = 83886082, + PER_SCOSVR3 = 117440515, + PER_OSR5 = 100663299, + PER_WYSEV386 = 83886084, + PER_ISCR4 = 67108869, + PER_BSD = 6, + PER_SUNOS = 67108870, + PER_XENIX = 83886087, + PER_LINUX32 = 8, + PER_LINUX32_3GB = 134217736, + PER_IRIX32 = 67108873, + PER_IRIXN32 = 67108874, + PER_IRIX64 = 67108875, + PER_RISCOS = 12, + PER_SOLARIS = 67108877, + PER_UW7 = 68157454, + PER_OSF4 = 15, + PER_HPUX = 16, + PER_MASK = 255, +}; + +struct rlimit64 { + __u64 rlim_cur; + __u64 rlim_max; +}; + +struct oldold_utsname { + char sysname[9]; + char nodename[9]; + char release[9]; + char version[9]; + char machine[9]; +}; + +struct old_utsname { + char sysname[65]; + char nodename[65]; + char release[65]; + char version[65]; + char machine[65]; +}; + +enum uts_proc { + UTS_PROC_OSTYPE = 0, + UTS_PROC_OSRELEASE = 1, + UTS_PROC_VERSION = 2, + UTS_PROC_HOSTNAME = 3, + UTS_PROC_DOMAINNAME = 4, +}; + +struct prctl_mm_map { + __u64 start_code; + __u64 end_code; + __u64 start_data; + __u64 end_data; + __u64 start_brk; + __u64 brk; + __u64 start_stack; + __u64 arg_start; + __u64 arg_end; + __u64 env_start; + __u64 env_end; + __u64 *auxv; + __u32 auxv_size; + __u32 exe_fd; +}; + +struct compat_tms { + compat_clock_t tms_utime; + compat_clock_t tms_stime; + compat_clock_t tms_cutime; + compat_clock_t tms_cstime; +}; + +struct compat_rlimit { + compat_ulong_t rlim_cur; + compat_ulong_t rlim_max; +}; + +struct tms { + __kernel_clock_t tms_utime; + __kernel_clock_t tms_stime; + __kernel_clock_t tms_cutime; + __kernel_clock_t tms_cstime; +}; + +struct getcpu_cache { + long unsigned int blob[16]; +}; + +struct compat_sysinfo { + s32 uptime; + u32 loads[3]; + u32 totalram; + u32 freeram; + u32 sharedram; + u32 bufferram; + u32 totalswap; + u32 freeswap; + u16 procs; + u16 pad; + u32 totalhigh; + u32 freehigh; + u32 mem_unit; + char _f[8]; +}; + +struct wq_flusher; + +struct worker; + +struct workqueue_attrs; + +struct pool_workqueue; + +struct wq_device; + +struct workqueue_struct { + struct list_head pwqs; + struct list_head list; + struct mutex mutex; + int work_color; + int flush_color; + atomic_t nr_pwqs_to_flush; + struct wq_flusher *first_flusher; + struct list_head flusher_queue; + struct list_head flusher_overflow; + struct list_head maydays; + struct worker *rescuer; + int nr_drainers; + int saved_max_active; + struct workqueue_attrs *unbound_attrs; + struct pool_workqueue *dfl_pwq; + struct wq_device *wq_dev; + char name[24]; + struct callback_head rcu; + long: 64; + unsigned int flags; + struct pool_workqueue *cpu_pwqs; + struct pool_workqueue *numa_pwq_tbl[0]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct workqueue_attrs { + int nice; + cpumask_var_t cpumask; + bool no_numa; +}; + +struct execute_work { + struct work_struct work; +}; + +enum { + WQ_UNBOUND = 2, + WQ_FREEZABLE = 4, + WQ_MEM_RECLAIM = 8, + WQ_HIGHPRI = 16, + WQ_CPU_INTENSIVE = 32, + WQ_SYSFS = 64, + WQ_POWER_EFFICIENT = 128, + __WQ_DRAINING = 65536, + __WQ_ORDERED = 131072, + __WQ_LEGACY = 262144, + __WQ_ORDERED_EXPLICIT = 524288, + WQ_MAX_ACTIVE = 512, + WQ_MAX_UNBOUND_PER_CPU = 4, + WQ_DFL_ACTIVE = 256, +}; + +typedef unsigned int xa_mark_t; + +enum xa_lock_type { + XA_LOCK_IRQ = 1, + XA_LOCK_BH = 2, +}; + +struct ida { + struct xarray xa; +}; + +struct __una_u32 { + u32 x; +}; + +struct worker_pool; + +struct worker { + union { + struct list_head entry; + struct hlist_node hentry; + }; + struct work_struct *current_work; + work_func_t current_func; + struct pool_workqueue *current_pwq; + struct list_head scheduled; + struct task_struct *task; + struct worker_pool *pool; + struct list_head node; + long unsigned int last_active; + unsigned int flags; + int id; + int sleeping; + char desc[24]; + struct workqueue_struct *rescue_wq; + work_func_t last_func; +}; + +struct pool_workqueue { + struct worker_pool *pool; + struct workqueue_struct *wq; + int work_color; + int flush_color; + int refcnt; + int nr_in_flight[15]; + int nr_active; + int max_active; + struct list_head delayed_works; + struct list_head pwqs_node; + struct list_head mayday_node; + struct work_struct unbound_release_work; + struct callback_head rcu; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct worker_pool { + raw_spinlock_t lock; + int cpu; + int node; + int id; + unsigned int flags; + long unsigned int watchdog_ts; + struct list_head worklist; + int nr_workers; + int nr_idle; + struct list_head idle_list; + struct timer_list idle_timer; + struct timer_list mayday_timer; + struct hlist_head busy_hash[64]; + struct worker *manager; + struct list_head workers; + struct completion *detach_completion; + struct ida worker_ida; + struct workqueue_attrs *attrs; + struct hlist_node hash_node; + int refcnt; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + atomic_t nr_running; + struct callback_head rcu; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +enum { + POOL_MANAGER_ACTIVE = 1, + POOL_DISASSOCIATED = 4, + WORKER_DIE = 2, + WORKER_IDLE = 4, + WORKER_PREP = 8, + WORKER_CPU_INTENSIVE = 64, + WORKER_UNBOUND = 128, + WORKER_REBOUND = 256, + WORKER_NOT_RUNNING = 456, + NR_STD_WORKER_POOLS = 2, + UNBOUND_POOL_HASH_ORDER = 6, + BUSY_WORKER_HASH_ORDER = 6, + MAX_IDLE_WORKERS_RATIO = 4, + IDLE_WORKER_TIMEOUT = 300000, + MAYDAY_INITIAL_TIMEOUT = 10, + MAYDAY_INTERVAL = 100, + CREATE_COOLDOWN = 1000, + RESCUER_NICE_LEVEL = 4294967276, + HIGHPRI_NICE_LEVEL = 4294967276, + WQ_NAME_LEN = 24, +}; + +struct wq_flusher { + struct list_head list; + int flush_color; + struct completion done; +}; + +struct wq_device { + struct workqueue_struct *wq; + struct device dev; +}; + +struct trace_event_raw_workqueue_queue_work { + struct trace_entry ent; + void *work; + void *function; + void *workqueue; + unsigned int req_cpu; + unsigned int cpu; + char __data[0]; +}; + +struct trace_event_raw_workqueue_activate_work { + struct trace_entry ent; + void *work; + char __data[0]; +}; + +struct trace_event_raw_workqueue_execute_start { + struct trace_entry ent; + void *work; + void *function; + char __data[0]; +}; + +struct trace_event_raw_workqueue_execute_end { + struct trace_entry ent; + void *work; + void *function; + char __data[0]; +}; + +struct trace_event_data_offsets_workqueue_queue_work {}; + +struct trace_event_data_offsets_workqueue_activate_work {}; + +struct trace_event_data_offsets_workqueue_execute_start {}; + +struct trace_event_data_offsets_workqueue_execute_end {}; + +typedef void (*btf_trace_workqueue_queue_work)(void *, unsigned int, struct pool_workqueue *, struct work_struct *); + +typedef void (*btf_trace_workqueue_activate_work)(void *, struct work_struct *); + +typedef void (*btf_trace_workqueue_execute_start)(void *, struct work_struct *); + +typedef void (*btf_trace_workqueue_execute_end)(void *, struct work_struct *, work_func_t); + +struct wq_barrier { + struct work_struct work; + struct completion done; + struct task_struct *task; +}; + +struct cwt_wait { + wait_queue_entry_t wait; + struct work_struct *work; +}; + +struct apply_wqattrs_ctx { + struct workqueue_struct *wq; + struct workqueue_attrs *attrs; + struct list_head list; + struct pool_workqueue *dfl_pwq; + struct pool_workqueue *pwq_tbl[0]; +}; + +struct work_for_cpu { + struct work_struct work; + long int (*fn)(void *); + void *arg; + long int ret; +}; + +struct xa_node { + unsigned char shift; + unsigned char offset; + unsigned char count; + unsigned char nr_values; + struct xa_node *parent; + struct xarray *array; + union { + struct list_head private_list; + struct callback_head callback_head; + }; + void *slots[64]; + union { + long unsigned int tags[3]; + long unsigned int marks[3]; + }; +}; + +typedef struct {} local_lock_t; + +struct radix_tree_preload { + local_lock_t lock; + unsigned int nr; + struct xa_node *nodes; +}; + +typedef void (*task_work_func_t)(struct callback_head *); + +enum { + KERNEL_PARAM_OPS_FL_NOARG = 1, +}; + +enum { + KERNEL_PARAM_FL_UNSAFE = 1, + KERNEL_PARAM_FL_HWPARAM = 2, +}; + +struct param_attribute { + struct module_attribute mattr; + const struct kernel_param *param; +}; + +struct module_param_attrs { + unsigned int num; + struct attribute_group grp; + struct param_attribute attrs[0]; +}; + +struct module_version_attribute { + struct module_attribute mattr; + const char *module_name; + const char *version; +}; + +struct kmalloced_param { + struct list_head list; + char val[0]; +}; + +struct sched_param { + int sched_priority; +}; + +enum { + __PERCPU_REF_ATOMIC = 1, + __PERCPU_REF_DEAD = 2, + __PERCPU_REF_ATOMIC_DEAD = 3, + __PERCPU_REF_FLAG_BITS = 2, +}; + +struct kthread_work; + +typedef void (*kthread_work_func_t)(struct kthread_work *); + +struct kthread_worker; + +struct kthread_work { + struct list_head node; + kthread_work_func_t func; + struct kthread_worker *worker; + int canceling; +}; + +enum { + KTW_FREEZABLE = 1, +}; + +struct kthread_worker { + unsigned int flags; + raw_spinlock_t lock; + struct list_head work_list; + struct list_head delayed_work_list; + struct task_struct *task; + struct kthread_work *current_work; +}; + +struct kthread_delayed_work { + struct kthread_work work; + struct timer_list timer; +}; + +enum { + CSS_NO_REF = 1, + CSS_ONLINE = 2, + CSS_RELEASED = 4, + CSS_VISIBLE = 8, + CSS_DYING = 16, +}; + +struct kthread_create_info { + int (*threadfn)(void *); + void *data; + int node; + struct task_struct *result; + struct completion *done; + struct list_head list; +}; + +struct kthread { + long unsigned int flags; + unsigned int cpu; + int (*threadfn)(void *); + void *data; + mm_segment_t oldfs; + struct completion parked; + struct completion exited; + struct cgroup_subsys_state *blkcg_css; +}; + +enum KTHREAD_BITS { + KTHREAD_IS_PER_CPU = 0, + KTHREAD_SHOULD_STOP = 1, + KTHREAD_SHOULD_PARK = 2, +}; + +struct kthread_flush_work { + struct kthread_work work; + struct completion done; +}; + +struct pt_regs___2; + +struct ipc_ids { + int in_use; + short unsigned int seq; + struct rw_semaphore rwsem; + struct idr ipcs_idr; + int max_idx; + int last_idx; + struct rhashtable key_ht; +}; + +struct ipc_namespace { + refcount_t count; + struct ipc_ids ids[3]; + int sem_ctls[4]; + int used_sems; + unsigned int msg_ctlmax; + unsigned int msg_ctlmnb; + unsigned int msg_ctlmni; + atomic_t msg_bytes; + atomic_t msg_hdrs; + size_t shm_ctlmax; + size_t shm_ctlall; + long unsigned int shm_tot; + int shm_ctlmni; + int shm_rmid_forced; + struct notifier_block ipcns_nb; + struct vfsmount *mq_mnt; + unsigned int mq_queues_count; + unsigned int mq_queues_max; + unsigned int mq_msg_max; + unsigned int mq_msgsize_max; + unsigned int mq_msg_default; + unsigned int mq_msgsize_default; + struct user_namespace *user_ns; + struct ucounts *ucounts; + struct llist_node mnt_llist; + struct ns_common ns; +}; + +struct srcu_notifier_head { + struct mutex mutex; + struct srcu_struct srcu; + struct notifier_block *head; +}; + +enum what { + PROC_EVENT_NONE = 0, + PROC_EVENT_FORK = 1, + PROC_EVENT_EXEC = 2, + PROC_EVENT_UID = 4, + PROC_EVENT_GID = 64, + PROC_EVENT_SID = 128, + PROC_EVENT_PTRACE = 256, + PROC_EVENT_COMM = 512, + PROC_EVENT_COREDUMP = 1073741824, + PROC_EVENT_EXIT = 2147483648, +}; + +typedef u64 async_cookie_t; + +typedef void (*async_func_t)(void *, async_cookie_t); + +struct async_domain { + struct list_head pending; + unsigned int registered: 1; +}; + +struct async_entry { + struct list_head domain_list; + struct list_head global_list; + struct work_struct work; + async_cookie_t cookie; + async_func_t func; + void *data; + struct async_domain *domain; +}; + +struct smpboot_thread_data { + unsigned int cpu; + unsigned int status; + struct smp_hotplug_thread *ht; +}; + +enum { + HP_THREAD_NONE = 0, + HP_THREAD_ACTIVE = 1, + HP_THREAD_PARKED = 2, +}; + +struct umd_info { + const char *driver_name; + struct file *pipe_to_umh; + struct file *pipe_from_umh; + struct path wd; + struct pid *tgid; +}; + +struct pin_cookie {}; + +struct preempt_notifier; + +struct preempt_ops { + void (*sched_in)(struct preempt_notifier *, int); + void (*sched_out)(struct preempt_notifier *, struct task_struct *); +}; + +struct preempt_notifier { + struct hlist_node link; + struct preempt_ops *ops; +}; + +enum { + CSD_FLAG_LOCK = 1, + IRQ_WORK_PENDING = 1, + IRQ_WORK_BUSY = 2, + IRQ_WORK_LAZY = 4, + IRQ_WORK_HARD_IRQ = 8, + IRQ_WORK_CLAIMED = 3, + CSD_TYPE_ASYNC = 0, + CSD_TYPE_SYNC = 16, + CSD_TYPE_IRQ_WORK = 32, + CSD_TYPE_TTWU = 48, + CSD_FLAG_TYPE_MASK = 240, +}; + +struct dl_bw { + raw_spinlock_t lock; + u64 bw; + u64 total_bw; +}; + +struct cpudl_item; + +struct cpudl { + raw_spinlock_t lock; + int size; + cpumask_var_t free_cpus; + struct cpudl_item *elements; +}; + +struct cpupri_vec { + atomic_t count; + cpumask_var_t mask; +}; + +struct cpupri { + struct cpupri_vec pri_to_cpu[102]; + int *cpu_to_pri; +}; + +struct perf_domain; + +struct root_domain { + atomic_t refcount; + atomic_t rto_count; + struct callback_head rcu; + cpumask_var_t span; + cpumask_var_t online; + int overload; + int overutilized; + cpumask_var_t dlo_mask; + atomic_t dlo_count; + struct dl_bw dl_bw; + struct cpudl cpudl; + struct irq_work rto_push_work; + raw_spinlock_t rto_lock; + int rto_loop; + int rto_cpu; + atomic_t rto_loop_next; + atomic_t rto_loop_start; + cpumask_var_t rto_mask; + struct cpupri cpupri; + long unsigned int max_cpu_capacity; + struct perf_domain *pd; +}; + +struct cfs_rq { + struct load_weight load; + unsigned int nr_running; + unsigned int h_nr_running; + unsigned int idle_h_nr_running; + u64 exec_clock; + u64 min_vruntime; + struct rb_root_cached tasks_timeline; + struct sched_entity *curr; + struct sched_entity *next; + struct sched_entity *last; + struct sched_entity *skip; + unsigned int nr_spread_over; + long: 32; + long: 64; + long: 64; + long: 64; + struct sched_avg avg; + struct { + raw_spinlock_t lock; + int nr; + long unsigned int load_avg; + long unsigned int util_avg; + long unsigned int runnable_avg; + long: 64; + } removed; + long unsigned int tg_load_avg_contrib; + long int propagate; + long int prop_runnable_sum; + long unsigned int h_load; + u64 last_h_load_update; + struct sched_entity *h_load_next; + struct rq *rq; + int on_list; + struct list_head leaf_cfs_rq_list; + struct task_group *tg; + int runtime_enabled; + s64 runtime_remaining; + u64 throttled_clock; + u64 throttled_clock_task; + u64 throttled_clock_task_time; + int throttled; + int throttle_count; + struct list_head throttled_list; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct cfs_bandwidth { + raw_spinlock_t lock; + ktime_t period; + u64 quota; + u64 runtime; + s64 hierarchical_quota; + u8 idle; + u8 period_active; + u8 slack_started; + struct hrtimer period_timer; + struct hrtimer slack_timer; + struct list_head throttled_cfs_rq; + int nr_periods; + int nr_throttled; + u64 throttled_time; +}; + +struct task_group { + struct cgroup_subsys_state css; + struct sched_entity **se; + struct cfs_rq **cfs_rq; + long unsigned int shares; + long: 64; + long: 64; + long: 64; + long: 64; + atomic_long_t load_avg; + struct callback_head rcu; + struct list_head list; + struct task_group *parent; + struct list_head siblings; + struct list_head children; + struct cfs_bandwidth cfs_bandwidth; + long: 64; + long: 64; +}; + +struct sched_group { + struct sched_group *next; + atomic_t ref; + unsigned int group_weight; + struct sched_group_capacity *sgc; + int asym_prefer_cpu; + long unsigned int cpumask[0]; +}; + +struct sched_group_capacity { + atomic_t ref; + long unsigned int capacity; + long unsigned int min_capacity; + long unsigned int max_capacity; + long unsigned int next_update; + int imbalance; + int id; + long unsigned int cpumask[0]; +}; + +struct em_perf_state { + long unsigned int frequency; + long unsigned int power; + long unsigned int cost; +}; + +struct em_perf_domain { + struct em_perf_state *table; + int nr_perf_states; + long unsigned int cpus[0]; +}; + +enum ctx_state { + CONTEXT_DISABLED = 4294967295, + CONTEXT_KERNEL = 0, + CONTEXT_USER = 1, + CONTEXT_GUEST = 2, +}; + +struct kernel_cpustat { + u64 cpustat[10]; +}; + +enum { + MEMBARRIER_STATE_PRIVATE_EXPEDITED_READY = 1, + MEMBARRIER_STATE_PRIVATE_EXPEDITED = 2, + MEMBARRIER_STATE_GLOBAL_EXPEDITED_READY = 4, + MEMBARRIER_STATE_GLOBAL_EXPEDITED = 8, + MEMBARRIER_STATE_PRIVATE_EXPEDITED_SYNC_CORE_READY = 16, + MEMBARRIER_STATE_PRIVATE_EXPEDITED_SYNC_CORE = 32, + MEMBARRIER_STATE_PRIVATE_EXPEDITED_RSEQ_READY = 64, + MEMBARRIER_STATE_PRIVATE_EXPEDITED_RSEQ = 128, +}; + +enum { + CFTYPE_ONLY_ON_ROOT = 1, + CFTYPE_NOT_ON_ROOT = 2, + CFTYPE_NS_DELEGATABLE = 4, + CFTYPE_NO_PREFIX = 8, + CFTYPE_WORLD_WRITABLE = 16, + CFTYPE_DEBUG = 32, + __CFTYPE_ONLY_ON_DFL = 65536, + __CFTYPE_NOT_ON_DFL = 131072, +}; + +struct trace_event_raw_sched_kthread_stop { + struct trace_entry ent; + char comm[16]; + pid_t pid; + char __data[0]; +}; + +struct trace_event_raw_sched_kthread_stop_ret { + struct trace_entry ent; + int ret; + char __data[0]; +}; + +struct trace_event_raw_sched_wakeup_template { + struct trace_entry ent; + char comm[16]; + pid_t pid; + int prio; + int success; + int target_cpu; + char __data[0]; +}; + +struct trace_event_raw_sched_switch { + struct trace_entry ent; + char prev_comm[16]; + pid_t prev_pid; + int prev_prio; + long int prev_state; + char next_comm[16]; + pid_t next_pid; + int next_prio; + char __data[0]; +}; + +struct trace_event_raw_sched_migrate_task { + struct trace_entry ent; + char comm[16]; + pid_t pid; + int prio; + int orig_cpu; + int dest_cpu; + char __data[0]; +}; + +struct trace_event_raw_sched_process_template { + struct trace_entry ent; + char comm[16]; + pid_t pid; + int prio; + char __data[0]; +}; + +struct trace_event_raw_sched_process_wait { + struct trace_entry ent; + char comm[16]; + pid_t pid; + int prio; + char __data[0]; +}; + +struct trace_event_raw_sched_process_fork { + struct trace_entry ent; + char parent_comm[16]; + pid_t parent_pid; + char child_comm[16]; + pid_t child_pid; + char __data[0]; +}; + +struct trace_event_raw_sched_process_exec { + struct trace_entry ent; + u32 __data_loc_filename; + pid_t pid; + pid_t old_pid; + char __data[0]; +}; + +struct trace_event_raw_sched_stat_template { + struct trace_entry ent; + char comm[16]; + pid_t pid; + u64 delay; + char __data[0]; +}; + +struct trace_event_raw_sched_stat_runtime { + struct trace_entry ent; + char comm[16]; + pid_t pid; + u64 runtime; + u64 vruntime; + char __data[0]; +}; + +struct trace_event_raw_sched_pi_setprio { + struct trace_entry ent; + char comm[16]; + pid_t pid; + int oldprio; + int newprio; + char __data[0]; +}; + +struct trace_event_raw_sched_process_hang { + struct trace_entry ent; + char comm[16]; + pid_t pid; + char __data[0]; +}; + +struct trace_event_raw_sched_move_numa { + struct trace_entry ent; + pid_t pid; + pid_t tgid; + pid_t ngid; + int src_cpu; + int src_nid; + int dst_cpu; + int dst_nid; + char __data[0]; +}; + +struct trace_event_raw_sched_numa_pair_template { + struct trace_entry ent; + pid_t src_pid; + pid_t src_tgid; + pid_t src_ngid; + int src_cpu; + int src_nid; + pid_t dst_pid; + pid_t dst_tgid; + pid_t dst_ngid; + int dst_cpu; + int dst_nid; + char __data[0]; +}; + +struct trace_event_raw_sched_wake_idle_without_ipi { + struct trace_entry ent; + int cpu; + char __data[0]; +}; + +struct trace_event_data_offsets_sched_kthread_stop {}; + +struct trace_event_data_offsets_sched_kthread_stop_ret {}; + +struct trace_event_data_offsets_sched_wakeup_template {}; + +struct trace_event_data_offsets_sched_switch {}; + +struct trace_event_data_offsets_sched_migrate_task {}; + +struct trace_event_data_offsets_sched_process_template {}; + +struct trace_event_data_offsets_sched_process_wait {}; + +struct trace_event_data_offsets_sched_process_fork {}; + +struct trace_event_data_offsets_sched_process_exec { + u32 filename; +}; + +struct trace_event_data_offsets_sched_stat_template {}; + +struct trace_event_data_offsets_sched_stat_runtime {}; + +struct trace_event_data_offsets_sched_pi_setprio {}; + +struct trace_event_data_offsets_sched_process_hang {}; + +struct trace_event_data_offsets_sched_move_numa {}; + +struct trace_event_data_offsets_sched_numa_pair_template {}; + +struct trace_event_data_offsets_sched_wake_idle_without_ipi {}; + +typedef void (*btf_trace_sched_kthread_stop)(void *, struct task_struct *); + +typedef void (*btf_trace_sched_kthread_stop_ret)(void *, int); + +typedef void (*btf_trace_sched_waking)(void *, struct task_struct *); + +typedef void (*btf_trace_sched_wakeup)(void *, struct task_struct *); + +typedef void (*btf_trace_sched_wakeup_new)(void *, struct task_struct *); + +typedef void (*btf_trace_sched_switch)(void *, bool, struct task_struct *, struct task_struct *); + +typedef void (*btf_trace_sched_migrate_task)(void *, struct task_struct *, int); + +typedef void (*btf_trace_sched_process_free)(void *, struct task_struct *); + +typedef void (*btf_trace_sched_process_exit)(void *, struct task_struct *); + +typedef void (*btf_trace_sched_wait_task)(void *, struct task_struct *); + +typedef void (*btf_trace_sched_process_wait)(void *, struct pid *); + +typedef void (*btf_trace_sched_process_fork)(void *, struct task_struct *, struct task_struct *); + +typedef void (*btf_trace_sched_process_exec)(void *, struct task_struct *, pid_t, struct linux_binprm *); + +typedef void (*btf_trace_sched_stat_wait)(void *, struct task_struct *, u64); + +typedef void (*btf_trace_sched_stat_sleep)(void *, struct task_struct *, u64); + +typedef void (*btf_trace_sched_stat_iowait)(void *, struct task_struct *, u64); + +typedef void (*btf_trace_sched_stat_blocked)(void *, struct task_struct *, u64); + +typedef void (*btf_trace_sched_stat_runtime)(void *, struct task_struct *, u64, u64); + +typedef void (*btf_trace_sched_pi_setprio)(void *, struct task_struct *, struct task_struct *); + +typedef void (*btf_trace_sched_process_hang)(void *, struct task_struct *); + +typedef void (*btf_trace_sched_move_numa)(void *, struct task_struct *, int, int); + +typedef void (*btf_trace_sched_stick_numa)(void *, struct task_struct *, int, struct task_struct *, int); + +typedef void (*btf_trace_sched_swap_numa)(void *, struct task_struct *, int, struct task_struct *, int); + +typedef void (*btf_trace_sched_wake_idle_without_ipi)(void *, int); + +struct wake_q_head { + struct wake_q_node *first; + struct wake_q_node **lastp; +}; + +struct sched_attr { + __u32 size; + __u32 sched_policy; + __u64 sched_flags; + __s32 sched_nice; + __u32 sched_priority; + __u64 sched_runtime; + __u64 sched_deadline; + __u64 sched_period; + __u32 sched_util_min; + __u32 sched_util_max; +}; + +struct cpuidle_state_usage { + long long unsigned int disable; + long long unsigned int usage; + u64 time_ns; + long long unsigned int above; + long long unsigned int below; + long long unsigned int rejected; + long long unsigned int s2idle_usage; + long long unsigned int s2idle_time; +}; + +struct cpuidle_device; + +struct cpuidle_driver; + +struct cpuidle_state { + char name[16]; + char desc[32]; + u64 exit_latency_ns; + u64 target_residency_ns; + unsigned int flags; + unsigned int exit_latency; + int power_usage; + unsigned int target_residency; + int (*enter)(struct cpuidle_device *, struct cpuidle_driver *, int); + int (*enter_dead)(struct cpuidle_device *, int); + int (*enter_s2idle)(struct cpuidle_device *, struct cpuidle_driver *, int); +}; + +struct cpuidle_driver_kobj; + +struct cpuidle_state_kobj; + +struct cpuidle_device_kobj; + +struct cpuidle_device { + unsigned int registered: 1; + unsigned int enabled: 1; + unsigned int poll_time_limit: 1; + unsigned int cpu; + ktime_t next_hrtimer; + int last_state_idx; + u64 last_residency_ns; + u64 poll_limit_ns; + u64 forced_idle_latency_limit_ns; + struct cpuidle_state_usage states_usage[10]; + struct cpuidle_state_kobj *kobjs[10]; + struct cpuidle_driver_kobj *kobj_driver; + struct cpuidle_device_kobj *kobj_dev; + struct list_head device_list; +}; + +struct cpuidle_driver { + const char *name; + struct module *owner; + unsigned int bctimer: 1; + struct cpuidle_state states[10]; + int state_count; + int safe_state_index; + struct cpumask *cpumask; + const char *governor; +}; + +typedef int (*cpu_stop_fn_t)(void *); + +struct cpu_stop_done; + +struct cpu_stop_work { + struct list_head list; + cpu_stop_fn_t fn; + void *arg; + struct cpu_stop_done *done; +}; + +struct cpudl_item { + u64 dl; + int cpu; + int idx; +}; + +struct rt_prio_array { + long unsigned int bitmap[2]; + struct list_head queue[100]; +}; + +struct rt_bandwidth { + raw_spinlock_t rt_runtime_lock; + ktime_t rt_period; + u64 rt_runtime; + struct hrtimer rt_period_timer; + unsigned int rt_period_active; +}; + +struct dl_bandwidth { + raw_spinlock_t dl_runtime_lock; + u64 dl_runtime; + u64 dl_period; +}; + +typedef int (*tg_visitor)(struct task_group *, void *); + +struct rt_rq { + struct rt_prio_array active; + unsigned int rt_nr_running; + unsigned int rr_nr_running; + struct { + int curr; + int next; + } highest_prio; + long unsigned int rt_nr_migratory; + long unsigned int rt_nr_total; + int overloaded; + struct plist_head pushable_tasks; + int rt_queued; + int rt_throttled; + u64 rt_time; + u64 rt_runtime; + raw_spinlock_t rt_runtime_lock; +}; + +struct dl_rq { + struct rb_root_cached root; + long unsigned int dl_nr_running; + struct { + u64 curr; + u64 next; + } earliest_dl; + long unsigned int dl_nr_migratory; + int overloaded; + struct rb_root_cached pushable_dl_tasks_root; + u64 running_bw; + u64 this_bw; + u64 extra_bw; + u64 bw_ratio; +}; + +struct rq { + raw_spinlock_t lock; + unsigned int nr_running; + unsigned int nr_numa_running; + unsigned int nr_preferred_running; + unsigned int numa_migrate_on; + long unsigned int last_blocked_load_update_tick; + unsigned int has_blocked_load; + long: 32; + long: 64; + call_single_data_t nohz_csd; + unsigned int nohz_tick_stopped; + atomic_t nohz_flags; + unsigned int ttwu_pending; + u64 nr_switches; + long: 64; + struct cfs_rq cfs; + struct rt_rq rt; + struct dl_rq dl; + struct list_head leaf_cfs_rq_list; + struct list_head *tmp_alone_branch; + long unsigned int nr_uninterruptible; + struct task_struct *curr; + struct task_struct *idle; + struct task_struct *stop; + long unsigned int next_balance; + struct mm_struct *prev_mm; + unsigned int clock_update_flags; + u64 clock; + long: 64; + u64 clock_task; + u64 clock_pelt; + long unsigned int lost_idle_time; + atomic_t nr_iowait; + int membarrier_state; + struct root_domain *rd; + struct sched_domain *sd; + long unsigned int cpu_capacity; + long unsigned int cpu_capacity_orig; + struct callback_head *balance_callback; + unsigned char nohz_idle_balance; + unsigned char idle_balance; + long unsigned int misfit_task_load; + int active_balance; + int push_cpu; + struct cpu_stop_work active_balance_work; + int cpu; + int online; + struct list_head cfs_tasks; + long: 64; + long: 64; + long: 64; + long: 64; + struct sched_avg avg_rt; + struct sched_avg avg_dl; + u64 idle_stamp; + u64 avg_idle; + u64 max_idle_balance_cost; + long unsigned int calc_load_update; + long int calc_load_active; + long: 64; + long: 64; + long: 64; + call_single_data_t hrtick_csd; + struct hrtimer hrtick_timer; + struct sched_info rq_sched_info; + long long unsigned int rq_cpu_time; + unsigned int yld_count; + unsigned int sched_count; + unsigned int sched_goidle; + unsigned int ttwu_count; + unsigned int ttwu_local; + struct cpuidle_state *idle_state; + long: 64; + long: 64; + long: 64; +}; + +struct perf_domain { + struct em_perf_domain *em_pd; + struct perf_domain *next; + struct callback_head rcu; +}; + +struct rq_flags { + long unsigned int flags; + struct pin_cookie cookie; + unsigned int clock_update_flags; +}; + +enum { + __SCHED_FEAT_GENTLE_FAIR_SLEEPERS = 0, + __SCHED_FEAT_START_DEBIT = 1, + __SCHED_FEAT_NEXT_BUDDY = 2, + __SCHED_FEAT_LAST_BUDDY = 3, + __SCHED_FEAT_CACHE_HOT_BUDDY = 4, + __SCHED_FEAT_WAKEUP_PREEMPTION = 5, + __SCHED_FEAT_HRTICK = 6, + __SCHED_FEAT_DOUBLE_TICK = 7, + __SCHED_FEAT_NONTASK_CAPACITY = 8, + __SCHED_FEAT_TTWU_QUEUE = 9, + __SCHED_FEAT_SIS_AVG_CPU = 10, + __SCHED_FEAT_SIS_PROP = 11, + __SCHED_FEAT_WARN_DOUBLE_CLOCK = 12, + __SCHED_FEAT_RT_PUSH_IPI = 13, + __SCHED_FEAT_RT_RUNTIME_SHARE = 14, + __SCHED_FEAT_LB_MIN = 15, + __SCHED_FEAT_ATTACH_AGE_LOAD = 16, + __SCHED_FEAT_WA_IDLE = 17, + __SCHED_FEAT_WA_WEIGHT = 18, + __SCHED_FEAT_WA_BIAS = 19, + __SCHED_FEAT_UTIL_EST = 20, + __SCHED_FEAT_UTIL_EST_FASTUP = 21, + __SCHED_FEAT_NR = 22, +}; + +struct migration_arg { + struct task_struct *task; + int dest_cpu; +}; + +struct migration_swap_arg { + struct task_struct *src_task; + struct task_struct *dst_task; + int src_cpu; + int dst_cpu; +}; + +struct cfs_schedulable_data { + struct task_group *tg; + u64 period; + u64 quota; +}; + +enum { + cpuset = 0, + possible = 1, + fail = 2, +}; + +enum tick_dep_bits { + TICK_DEP_BIT_POSIX_TIMER = 0, + TICK_DEP_BIT_PERF_EVENTS = 1, + TICK_DEP_BIT_SCHED = 2, + TICK_DEP_BIT_CLOCK_UNSTABLE = 3, + TICK_DEP_BIT_RCU = 4, + TICK_DEP_BIT_RCU_EXP = 5, +}; + +struct sched_clock_data { + u64 tick_raw; + u64 tick_gtod; + u64 clock; +}; + +enum s2idle_states { + S2IDLE_STATE_NONE = 0, + S2IDLE_STATE_ENTER = 1, + S2IDLE_STATE_WAKE = 2, +}; + +struct idle_timer { + struct hrtimer timer; + int done; +}; + +typedef void (*rcu_callback_t)(struct callback_head *); + +struct numa_group { + refcount_t refcount; + spinlock_t lock; + int nr_tasks; + pid_t gid; + int active_nodes; + struct callback_head rcu; + long unsigned int total_faults; + long unsigned int max_faults_cpu; + long unsigned int *faults_cpu; + long unsigned int faults[0]; +}; + +struct update_util_data { + void (*func)(struct update_util_data *, u64, unsigned int); +}; + +enum numa_topology_type { + NUMA_DIRECT = 0, + NUMA_GLUELESS_MESH = 1, + NUMA_BACKPLANE = 2, +}; + +enum numa_faults_stats { + NUMA_MEM = 0, + NUMA_CPU = 1, + NUMA_MEMBUF = 2, + NUMA_CPUBUF = 3, +}; + +enum schedutil_type { + FREQUENCY_UTIL = 0, + ENERGY_UTIL = 1, +}; + +enum numa_type { + node_has_spare = 0, + node_fully_busy = 1, + node_overloaded = 2, +}; + +struct numa_stats { + long unsigned int load; + long unsigned int runnable; + long unsigned int util; + long unsigned int compute_capacity; + unsigned int nr_running; + unsigned int weight; + enum numa_type node_type; + int idle_cpu; +}; + +struct task_numa_env { + struct task_struct *p; + int src_cpu; + int src_nid; + int dst_cpu; + int dst_nid; + struct numa_stats src_stats; + struct numa_stats dst_stats; + int imbalance_pct; + int dist; + struct task_struct *best_task; + long int best_imp; + int best_cpu; +}; + +enum fbq_type { + regular = 0, + remote = 1, + all = 2, +}; + +enum group_type { + group_has_spare = 0, + group_fully_busy = 1, + group_misfit_task = 2, + group_asym_packing = 3, + group_imbalanced = 4, + group_overloaded = 5, +}; + +enum migration_type { + migrate_load = 0, + migrate_util = 1, + migrate_task = 2, + migrate_misfit = 3, +}; + +struct lb_env { + struct sched_domain *sd; + struct rq *src_rq; + int src_cpu; + int dst_cpu; + struct rq *dst_rq; + struct cpumask *dst_grpmask; + int new_dst_cpu; + enum cpu_idle_type idle; + long int imbalance; + struct cpumask *cpus; + unsigned int flags; + unsigned int loop; + unsigned int loop_break; + unsigned int loop_max; + enum fbq_type fbq_type; + enum migration_type migration_type; + struct list_head tasks; +}; + +struct sg_lb_stats { + long unsigned int avg_load; + long unsigned int group_load; + long unsigned int group_capacity; + long unsigned int group_util; + long unsigned int group_runnable; + unsigned int sum_nr_running; + unsigned int sum_h_nr_running; + unsigned int idle_cpus; + unsigned int group_weight; + enum group_type group_type; + unsigned int group_asym_packing; + long unsigned int group_misfit_task_load; + unsigned int nr_numa_running; + unsigned int nr_preferred_running; +}; + +struct sd_lb_stats { + struct sched_group *busiest; + struct sched_group *local; + long unsigned int total_load; + long unsigned int total_capacity; + long unsigned int avg_load; + unsigned int prefer_sibling; + struct sg_lb_stats busiest_stat; + struct sg_lb_stats local_stat; +}; + +typedef struct rt_rq *rt_rq_iter_t; + +struct wait_bit_key { + void *flags; + int bit_nr; + long unsigned int timeout; +}; + +struct wait_bit_queue_entry { + struct wait_bit_key key; + struct wait_queue_entry wq_entry; +}; + +typedef int wait_bit_action_f(struct wait_bit_key *, int); + +struct swait_queue { + struct task_struct *task; + struct list_head task_list; +}; + +struct sd_flag_debug { + unsigned int meta_flags; + char *name; +}; + +struct sched_domain_attr { + int relax_domain_level; +}; + +struct s_data { + struct sched_domain **sd; + struct root_domain *rd; +}; + +enum s_alloc { + sa_rootdomain = 0, + sa_sd = 1, + sa_sd_storage = 2, + sa_none = 3, +}; + +enum cpuacct_stat_index { + CPUACCT_STAT_USER = 0, + CPUACCT_STAT_SYSTEM = 1, + CPUACCT_STAT_NSTATS = 2, +}; + +struct cpuacct_usage { + u64 usages[2]; +}; + +struct cpuacct { + struct cgroup_subsys_state css; + struct cpuacct_usage *cpuusage; + struct kernel_cpustat *cpustat; +}; + +struct gov_attr_set { + struct kobject kobj; + struct list_head policy_list; + struct mutex update_lock; + int usage_count; +}; + +struct governor_attr { + struct attribute attr; + ssize_t (*show)(struct gov_attr_set *, char *); + ssize_t (*store)(struct gov_attr_set *, const char *, size_t); +}; + +struct sugov_tunables { + struct gov_attr_set attr_set; + unsigned int rate_limit_us; +}; + +struct sugov_policy { + struct cpufreq_policy *policy; + struct sugov_tunables *tunables; + struct list_head tunables_hook; + raw_spinlock_t update_lock; + u64 last_freq_update_time; + s64 freq_update_delay_ns; + unsigned int next_freq; + unsigned int cached_raw_freq; + struct irq_work irq_work; + struct kthread_work work; + struct mutex work_lock; + struct kthread_worker worker; + struct task_struct *thread; + bool work_in_progress; + bool limits_changed; + bool need_freq_update; +}; + +struct sugov_cpu { + struct update_util_data update_util; + struct sugov_policy *sg_policy; + unsigned int cpu; + bool iowait_boost_pending; + unsigned int iowait_boost; + u64 last_update; + long unsigned int bw_dl; + long unsigned int max; + long unsigned int saved_idle_calls; +}; + +enum { + MEMBARRIER_FLAG_SYNC_CORE = 1, + MEMBARRIER_FLAG_RSEQ = 2, +}; + +enum membarrier_cmd { + MEMBARRIER_CMD_QUERY = 0, + MEMBARRIER_CMD_GLOBAL = 1, + MEMBARRIER_CMD_GLOBAL_EXPEDITED = 2, + MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED = 4, + MEMBARRIER_CMD_PRIVATE_EXPEDITED = 8, + MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED = 16, + MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE = 32, + MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE = 64, + MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ = 128, + MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ = 256, + MEMBARRIER_CMD_SHARED = 1, +}; + +enum membarrier_cmd_flag { + MEMBARRIER_CMD_FLAG_CPU = 1, +}; + +enum psi_res { + PSI_IO = 0, + PSI_MEM = 1, + PSI_CPU = 2, + NR_PSI_RESOURCES = 3, +}; + +struct psi_window { + u64 size; + u64 start_time; + u64 start_value; + u64 prev_growth; +}; + +struct psi_trigger { + enum psi_states state; + u64 threshold; + struct list_head node; + struct psi_group *group; + wait_queue_head_t event_wait; + int event; + struct psi_window win; + u64 last_event_time; + struct kref refcount; +}; + +enum mutex_trylock_recursive_enum { + MUTEX_TRYLOCK_FAILED = 0, + MUTEX_TRYLOCK_SUCCESS = 1, + MUTEX_TRYLOCK_RECURSIVE = 2, +}; + +struct semaphore { + raw_spinlock_t lock; + unsigned int count; + struct list_head wait_list; +}; + +struct semaphore_waiter { + struct list_head list; + struct task_struct *task; + bool up; +}; + +enum rwsem_waiter_type { + RWSEM_WAITING_FOR_WRITE = 0, + RWSEM_WAITING_FOR_READ = 1, +}; + +struct rwsem_waiter { + struct list_head list; + struct task_struct *task; + enum rwsem_waiter_type type; + long unsigned int timeout; + long unsigned int last_rowner; +}; + +enum rwsem_wake_type { + RWSEM_WAKE_ANY = 0, + RWSEM_WAKE_READERS = 1, + RWSEM_WAKE_READ_OWNED = 2, +}; + +enum writer_wait_state { + WRITER_NOT_FIRST = 0, + WRITER_FIRST = 1, + WRITER_HANDOFF = 2, +}; + +enum owner_state { + OWNER_NULL = 1, + OWNER_WRITER = 2, + OWNER_READER = 4, + OWNER_NONSPINNABLE = 8, +}; + +struct optimistic_spin_node { + struct optimistic_spin_node *next; + struct optimistic_spin_node *prev; + int locked; + int cpu; +}; + +struct mcs_spinlock { + struct mcs_spinlock *next; + int locked; + int count; +}; + +struct qnode { + struct mcs_spinlock mcs; +}; + +struct hrtimer_sleeper { + struct hrtimer timer; + struct task_struct *task; +}; + +struct rt_mutex; + +struct rt_mutex_waiter { + struct rb_node tree_entry; + struct rb_node pi_tree_entry; + struct task_struct *task; + struct rt_mutex *lock; + long unsigned int ip; + struct pid *deadlock_task_pid; + struct rt_mutex *deadlock_lock; + int prio; + u64 deadline; +}; + +struct rt_mutex { + raw_spinlock_t wait_lock; + struct rb_root_cached waiters; + struct task_struct *owner; + int save_state; + const char *name; + const char *file; + int line; + void *magic; +}; + +enum rtmutex_chainwalk { + RT_MUTEX_MIN_CHAINWALK = 0, + RT_MUTEX_FULL_CHAINWALK = 1, +}; + +struct pm_qos_request { + struct plist_node node; + struct pm_qos_constraints *qos; +}; + +enum pm_qos_req_action { + PM_QOS_ADD_REQ = 0, + PM_QOS_UPDATE_REQ = 1, + PM_QOS_REMOVE_REQ = 2, +}; + +struct miscdevice { + int minor; + const char *name; + const struct file_operations *fops; + struct list_head list; + struct device *parent; + struct device *this_device; + const struct attribute_group **groups; + const char *nodename; + umode_t mode; +}; + +typedef int suspend_state_t; + +enum suspend_stat_step { + SUSPEND_FREEZE = 1, + SUSPEND_PREPARE = 2, + SUSPEND_SUSPEND = 3, + SUSPEND_SUSPEND_LATE = 4, + SUSPEND_SUSPEND_NOIRQ = 5, + SUSPEND_RESUME_NOIRQ = 6, + SUSPEND_RESUME_EARLY = 7, + SUSPEND_RESUME = 8, +}; + +struct suspend_stats { + int success; + int fail; + int failed_freeze; + int failed_prepare; + int failed_suspend; + int failed_suspend_late; + int failed_suspend_noirq; + int failed_resume; + int failed_resume_early; + int failed_resume_noirq; + int last_failed_dev; + char failed_devs[80]; + int last_failed_errno; + int errno[2]; + int last_failed_step; + enum suspend_stat_step failed_steps[2]; +}; + +struct pm_vt_switch { + struct list_head head; + struct device *dev; + bool required; +}; + +struct platform_suspend_ops { + int (*valid)(suspend_state_t); + int (*begin)(suspend_state_t); + int (*prepare)(); + int (*prepare_late)(); + int (*enter)(suspend_state_t); + void (*wake)(); + void (*finish)(); + bool (*suspend_again)(); + void (*end)(); + void (*recover)(); +}; + +struct platform_s2idle_ops { + int (*begin)(); + int (*prepare)(); + int (*prepare_late)(); + bool (*wake)(); + void (*restore_early)(); + void (*restore)(); + void (*end)(); +}; + +enum { + TEST_NONE = 0, + TEST_CORE = 1, + TEST_CPUS = 2, + TEST_PLATFORM = 3, + TEST_DEVICES = 4, + TEST_FREEZER = 5, + __TEST_AFTER_LAST = 6, +}; + +struct sysrq_key_op { + void (* const handler)(int); + const char * const help_msg; + const char * const action_msg; + const int enable_mask; +}; + +struct dev_printk_info { + char subsystem[16]; + char device[48]; +}; + +struct kmsg_dumper { + struct list_head list; + void (*dump)(struct kmsg_dumper *, enum kmsg_dump_reason); + enum kmsg_dump_reason max_reason; + bool active; + bool registered; + u32 cur_idx; + u32 next_idx; + u64 cur_seq; + u64 next_seq; +}; + +struct trace_event_raw_console { + struct trace_entry ent; + u32 __data_loc_msg; + char __data[0]; +}; + +struct trace_event_data_offsets_console { + u32 msg; +}; + +typedef void (*btf_trace_console)(void *, const char *, size_t); + +struct printk_info { + u64 seq; + u64 ts_nsec; + u16 text_len; + u8 facility; + u8 flags: 5; + u8 level: 3; + u32 caller_id; + struct dev_printk_info dev_info; +}; + +struct printk_record { + struct printk_info *info; + char *text_buf; + unsigned int text_buf_size; +}; + +struct prb_data_blk_lpos { + long unsigned int begin; + long unsigned int next; +}; + +struct prb_desc { + atomic_long_t state_var; + struct prb_data_blk_lpos text_blk_lpos; +}; + +struct prb_data_ring { + unsigned int size_bits; + char *data; + atomic_long_t head_lpos; + atomic_long_t tail_lpos; +}; + +struct prb_desc_ring { + unsigned int count_bits; + struct prb_desc *descs; + struct printk_info *infos; + atomic_long_t head_id; + atomic_long_t tail_id; +}; + +struct printk_ringbuffer { + struct prb_desc_ring desc_ring; + struct prb_data_ring text_data_ring; + atomic_long_t fail; +}; + +struct prb_reserved_entry { + struct printk_ringbuffer *rb; + long unsigned int irqflags; + long unsigned int id; + unsigned int text_space; +}; + +enum desc_state { + desc_miss = 4294967295, + desc_reserved = 0, + desc_committed = 1, + desc_finalized = 2, + desc_reusable = 3, +}; + +struct console_cmdline { + char name[16]; + int index; + bool user_specified; + char *options; +}; + +enum devkmsg_log_bits { + __DEVKMSG_LOG_BIT_ON = 0, + __DEVKMSG_LOG_BIT_OFF = 1, + __DEVKMSG_LOG_BIT_LOCK = 2, +}; + +enum devkmsg_log_masks { + DEVKMSG_LOG_MASK_ON = 1, + DEVKMSG_LOG_MASK_OFF = 2, + DEVKMSG_LOG_MASK_LOCK = 4, +}; + +enum con_msg_format_flags { + MSG_FORMAT_DEFAULT = 0, + MSG_FORMAT_SYSLOG = 1, +}; + +enum log_flags { + LOG_NEWLINE = 2, + LOG_CONT = 8, +}; + +struct devkmsg_user { + u64 seq; + struct ratelimit_state rs; + struct mutex lock; + char buf[8192]; + struct printk_info info; + char text_buf[8192]; + struct printk_record record; +}; + +struct printk_safe_seq_buf { + atomic_t len; + atomic_t message_lost; + struct irq_work work; + unsigned char buffer[8160]; +}; + +struct prb_data_block { + long unsigned int id; + char data[0]; +}; + +enum { + IRQS_AUTODETECT = 1, + IRQS_SPURIOUS_DISABLED = 2, + IRQS_POLL_INPROGRESS = 8, + IRQS_ONESHOT = 32, + IRQS_REPLAY = 64, + IRQS_WAITING = 128, + IRQS_PENDING = 512, + IRQS_SUSPENDED = 2048, + IRQS_TIMINGS = 4096, + IRQS_NMI = 8192, +}; + +enum { + _IRQ_DEFAULT_INIT_FLAGS = 0, + _IRQ_PER_CPU = 512, + _IRQ_LEVEL = 256, + _IRQ_NOPROBE = 1024, + _IRQ_NOREQUEST = 2048, + _IRQ_NOTHREAD = 65536, + _IRQ_NOAUTOEN = 4096, + _IRQ_MOVE_PCNTXT = 16384, + _IRQ_NO_BALANCING = 8192, + _IRQ_NESTED_THREAD = 32768, + _IRQ_PER_CPU_DEVID = 131072, + _IRQ_IS_POLLED = 262144, + _IRQ_DISABLE_UNLAZY = 524288, + _IRQ_HIDDEN = 1048576, + _IRQF_MODIFY_MASK = 2096911, +}; + +enum { + IRQTF_RUNTHREAD = 0, + IRQTF_WARNED = 1, + IRQTF_AFFINITY = 2, + IRQTF_FORCED_THREAD = 3, +}; + +enum { + IRQC_IS_HARDIRQ = 0, + IRQC_IS_NESTED = 1, +}; + +enum { + IRQ_STARTUP_NORMAL = 0, + IRQ_STARTUP_MANAGED = 1, + IRQ_STARTUP_ABORT = 2, +}; + +struct irq_devres { + unsigned int irq; + void *dev_id; +}; + +struct irq_desc_devres { + unsigned int from; + unsigned int cnt; +}; + +struct irqchip_fwid { + struct fwnode_handle fwnode; + unsigned int type; + char *name; + phys_addr_t *pa; +}; + +enum { + AFFINITY = 0, + AFFINITY_LIST = 1, + EFFECTIVE = 2, + EFFECTIVE_LIST = 3, +}; + +struct irq_affinity { + unsigned int pre_vectors; + unsigned int post_vectors; + unsigned int nr_sets; + unsigned int set_size[4]; + void (*calc_sets)(struct irq_affinity *, unsigned int); + void *priv; +}; + +struct node_vectors { + unsigned int id; + union { + unsigned int nvectors; + unsigned int ncpus; + }; +}; + +struct cpumap { + unsigned int available; + unsigned int allocated; + unsigned int managed; + unsigned int managed_allocated; + bool initialized; + bool online; + long unsigned int alloc_map[4]; + long unsigned int managed_map[4]; +}; + +struct irq_matrix___2 { + unsigned int matrix_bits; + unsigned int alloc_start; + unsigned int alloc_end; + unsigned int alloc_size; + unsigned int global_available; + unsigned int global_reserved; + unsigned int systembits_inalloc; + unsigned int total_allocated; + unsigned int online_maps; + struct cpumap *maps; + long unsigned int scratch_map[4]; + long unsigned int system_map[4]; +}; + +struct trace_event_raw_irq_matrix_global { + struct trace_entry ent; + unsigned int online_maps; + unsigned int global_available; + unsigned int global_reserved; + unsigned int total_allocated; + char __data[0]; +}; + +struct trace_event_raw_irq_matrix_global_update { + struct trace_entry ent; + int bit; + unsigned int online_maps; + unsigned int global_available; + unsigned int global_reserved; + unsigned int total_allocated; + char __data[0]; +}; + +struct trace_event_raw_irq_matrix_cpu { + struct trace_entry ent; + int bit; + unsigned int cpu; + bool online; + unsigned int available; + unsigned int allocated; + unsigned int managed; + unsigned int online_maps; + unsigned int global_available; + unsigned int global_reserved; + unsigned int total_allocated; + char __data[0]; +}; + +struct trace_event_data_offsets_irq_matrix_global {}; + +struct trace_event_data_offsets_irq_matrix_global_update {}; + +struct trace_event_data_offsets_irq_matrix_cpu {}; + +typedef void (*btf_trace_irq_matrix_online)(void *, struct irq_matrix___2 *); + +typedef void (*btf_trace_irq_matrix_offline)(void *, struct irq_matrix___2 *); + +typedef void (*btf_trace_irq_matrix_reserve)(void *, struct irq_matrix___2 *); + +typedef void (*btf_trace_irq_matrix_remove_reserved)(void *, struct irq_matrix___2 *); + +typedef void (*btf_trace_irq_matrix_assign_system)(void *, int, struct irq_matrix___2 *); + +typedef void (*btf_trace_irq_matrix_alloc_reserved)(void *, int, unsigned int, struct irq_matrix___2 *, struct cpumap *); + +typedef void (*btf_trace_irq_matrix_reserve_managed)(void *, int, unsigned int, struct irq_matrix___2 *, struct cpumap *); + +typedef void (*btf_trace_irq_matrix_remove_managed)(void *, int, unsigned int, struct irq_matrix___2 *, struct cpumap *); + +typedef void (*btf_trace_irq_matrix_alloc_managed)(void *, int, unsigned int, struct irq_matrix___2 *, struct cpumap *); + +typedef void (*btf_trace_irq_matrix_assign)(void *, int, unsigned int, struct irq_matrix___2 *, struct cpumap *); + +typedef void (*btf_trace_irq_matrix_alloc)(void *, int, unsigned int, struct irq_matrix___2 *, struct cpumap *); + +typedef void (*btf_trace_irq_matrix_free)(void *, int, unsigned int, struct irq_matrix___2 *, struct cpumap *); + +typedef void (*call_rcu_func_t)(struct callback_head *, rcu_callback_t); + +struct rcu_synchronize { + struct callback_head head; + struct completion completion; +}; + +struct trace_event_raw_rcu_utilization { + struct trace_entry ent; + const char *s; + char __data[0]; +}; + +struct trace_event_data_offsets_rcu_utilization {}; + +typedef void (*btf_trace_rcu_utilization)(void *, const char *); + +struct rcu_tasks; + +typedef void (*rcu_tasks_gp_func_t)(struct rcu_tasks *); + +typedef void (*pregp_func_t)(); + +typedef void (*pertask_func_t)(struct task_struct *, struct list_head *); + +typedef void (*postscan_func_t)(struct list_head *); + +typedef void (*holdouts_func_t)(struct list_head *, bool, bool *); + +typedef void (*postgp_func_t)(struct rcu_tasks *); + +struct rcu_tasks { + struct callback_head *cbs_head; + struct callback_head **cbs_tail; + struct wait_queue_head cbs_wq; + raw_spinlock_t cbs_lock; + int gp_state; + int gp_sleep; + int init_fract; + long unsigned int gp_jiffies; + long unsigned int gp_start; + long unsigned int n_gps; + long unsigned int n_ipis; + long unsigned int n_ipis_fails; + struct task_struct *kthread_ptr; + rcu_tasks_gp_func_t gp_func; + pregp_func_t pregp_func; + pertask_func_t pertask_func; + postscan_func_t postscan_func; + holdouts_func_t holdouts_func; + postgp_func_t postgp_func; + call_rcu_func_t call_func; + char *name; + char *kname; +}; + +enum { + GP_IDLE = 0, + GP_ENTER = 1, + GP_PASSED = 2, + GP_EXIT = 3, + GP_REPLAY = 4, +}; + +typedef long unsigned int ulong; + +struct rcu_cblist { + struct callback_head *head; + struct callback_head **tail; + long int len; +}; + +enum rcutorture_type { + RCU_FLAVOR = 0, + RCU_TASKS_FLAVOR = 1, + RCU_TASKS_RUDE_FLAVOR = 2, + RCU_TASKS_TRACING_FLAVOR = 3, + RCU_TRIVIAL_FLAVOR = 4, + SRCU_FLAVOR = 5, + INVALID_RCU_FLAVOR = 6, +}; + +struct rcu_exp_work { + long unsigned int rew_s; + struct work_struct rew_work; +}; + +struct rcu_node { + raw_spinlock_t lock; + long unsigned int gp_seq; + long unsigned int gp_seq_needed; + long unsigned int completedqs; + long unsigned int qsmask; + long unsigned int rcu_gp_init_mask; + long unsigned int qsmaskinit; + long unsigned int qsmaskinitnext; + long unsigned int expmask; + long unsigned int expmaskinit; + long unsigned int expmaskinitnext; + long unsigned int cbovldmask; + long unsigned int ffmask; + long unsigned int grpmask; + int grplo; + int grphi; + u8 grpnum; + u8 level; + bool wait_blkd_tasks; + struct rcu_node *parent; + struct list_head blkd_tasks; + struct list_head *gp_tasks; + struct list_head *exp_tasks; + struct list_head *boost_tasks; + struct rt_mutex boost_mtx; + long unsigned int boost_time; + struct task_struct *boost_kthread_task; + unsigned int boost_kthread_status; + long: 32; + long: 64; + long: 64; + raw_spinlock_t fqslock; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + spinlock_t exp_lock; + long unsigned int exp_seq_rq; + wait_queue_head_t exp_wq[4]; + struct rcu_exp_work rew; + bool exp_need_flush; + long: 56; + long: 64; + long: 64; +}; + +union rcu_noqs { + struct { + u8 norm; + u8 exp; + } b; + u16 s; +}; + +struct rcu_data { + long unsigned int gp_seq; + long unsigned int gp_seq_needed; + union rcu_noqs cpu_no_qs; + bool core_needs_qs; + bool beenonline; + bool gpwrap; + bool exp_deferred_qs; + bool cpu_started; + struct rcu_node *mynode; + long unsigned int grpmask; + long unsigned int ticks_this_gp; + struct irq_work defer_qs_iw; + bool defer_qs_iw_pending; + struct work_struct strict_work; + struct rcu_segcblist cblist; + long int qlen_last_fqs_check; + long unsigned int n_cbs_invoked; + long unsigned int n_force_qs_snap; + long int blimit; + int dynticks_snap; + long int dynticks_nesting; + long int dynticks_nmi_nesting; + atomic_t dynticks; + bool rcu_need_heavy_qs; + bool rcu_urgent_qs; + bool rcu_forced_tick; + bool rcu_forced_tick_exp; + struct callback_head barrier_head; + int exp_dynticks_snap; + struct task_struct *rcu_cpu_kthread_task; + unsigned int rcu_cpu_kthread_status; + char rcu_cpu_has_work; + unsigned int softirq_snap; + struct irq_work rcu_iw; + bool rcu_iw_pending; + long unsigned int rcu_iw_gp_seq; + long unsigned int rcu_ofl_gp_seq; + short int rcu_ofl_gp_flags; + long unsigned int rcu_onl_gp_seq; + short int rcu_onl_gp_flags; + long unsigned int last_fqs_resched; + int cpu; +}; + +struct rcu_state { + struct rcu_node node[9]; + struct rcu_node *level[3]; + int ncpus; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + u8 boost; + long unsigned int gp_seq; + long unsigned int gp_max; + struct task_struct *gp_kthread; + struct swait_queue_head gp_wq; + short int gp_flags; + short int gp_state; + long unsigned int gp_wake_time; + long unsigned int gp_wake_seq; + struct mutex barrier_mutex; + atomic_t barrier_cpu_count; + struct completion barrier_completion; + long unsigned int barrier_sequence; + struct mutex exp_mutex; + struct mutex exp_wake_mutex; + long unsigned int expedited_sequence; + atomic_t expedited_need_qs; + struct swait_queue_head expedited_wq; + int ncpus_snap; + u8 cbovld; + u8 cbovldnext; + long unsigned int jiffies_force_qs; + long unsigned int jiffies_kick_kthreads; + long unsigned int n_force_qs; + long unsigned int gp_start; + long unsigned int gp_end; + long unsigned int gp_activity; + long unsigned int gp_req_activity; + long unsigned int jiffies_stall; + long unsigned int jiffies_resched; + long unsigned int n_force_qs_gpstart; + const char *name; + char abbr; + raw_spinlock_t ofl_lock; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct kvfree_rcu_bulk_data { + long unsigned int nr_records; + struct kvfree_rcu_bulk_data *next; + void *records[0]; +}; + +struct kfree_rcu_cpu; + +struct kfree_rcu_cpu_work { + struct rcu_work rcu_work; + struct callback_head *head_free; + struct kvfree_rcu_bulk_data *bkvhead_free[2]; + struct kfree_rcu_cpu *krcp; +}; + +struct kfree_rcu_cpu { + struct callback_head *head; + struct kvfree_rcu_bulk_data *bkvhead[2]; + struct kfree_rcu_cpu_work krw_arr[2]; + raw_spinlock_t lock; + struct delayed_work monitor_work; + bool monitor_todo; + bool initialized; + int count; + struct llist_head bkvcache; + int nr_bkv_objs; +}; + +enum dma_sync_target { + SYNC_FOR_CPU = 0, + SYNC_FOR_DEVICE = 1, +}; + +struct dma_devres { + size_t size; + void *vaddr; + dma_addr_t dma_handle; + long unsigned int attrs; +}; + +struct trace_event_raw_swiotlb_bounced { + struct trace_entry ent; + u32 __data_loc_dev_name; + u64 dma_mask; + dma_addr_t dev_addr; + size_t size; + enum swiotlb_force swiotlb_force; + char __data[0]; +}; + +struct trace_event_data_offsets_swiotlb_bounced { + u32 dev_name; +}; + +typedef void (*btf_trace_swiotlb_bounced)(void *, struct device *, dma_addr_t, size_t, enum swiotlb_force); + +struct trace_event_raw_sys_enter { + struct trace_entry ent; + long int id; + long unsigned int args[6]; + char __data[0]; +}; + +struct trace_event_raw_sys_exit { + struct trace_entry ent; + long int id; + long int ret; + char __data[0]; +}; + +struct trace_event_data_offsets_sys_enter {}; + +struct trace_event_data_offsets_sys_exit {}; + +typedef void (*btf_trace_sys_enter)(void *, struct pt_regs *, long int); + +typedef void (*btf_trace_sys_exit)(void *, struct pt_regs *, long int); + +enum mmu_notifier_event { + MMU_NOTIFY_UNMAP = 0, + MMU_NOTIFY_CLEAR = 1, + MMU_NOTIFY_PROTECTION_VMA = 2, + MMU_NOTIFY_PROTECTION_PAGE = 3, + MMU_NOTIFY_SOFT_DIRTY = 4, + MMU_NOTIFY_RELEASE = 5, + MMU_NOTIFY_MIGRATE = 6, +}; + +struct mmu_notifier; + +struct mmu_notifier_range; + +struct mmu_notifier_ops { + void (*release)(struct mmu_notifier *, struct mm_struct *); + int (*clear_flush_young)(struct mmu_notifier *, struct mm_struct *, long unsigned int, long unsigned int); + int (*clear_young)(struct mmu_notifier *, struct mm_struct *, long unsigned int, long unsigned int); + int (*test_young)(struct mmu_notifier *, struct mm_struct *, long unsigned int); + void (*change_pte)(struct mmu_notifier *, struct mm_struct *, long unsigned int, pte_t); + int (*invalidate_range_start)(struct mmu_notifier *, const struct mmu_notifier_range *); + void (*invalidate_range_end)(struct mmu_notifier *, const struct mmu_notifier_range *); + void (*invalidate_range)(struct mmu_notifier *, struct mm_struct *, long unsigned int, long unsigned int); + struct mmu_notifier * (*alloc_notifier)(struct mm_struct *); + void (*free_notifier)(struct mmu_notifier *); +}; + +struct mmu_notifier { + struct hlist_node hlist; + const struct mmu_notifier_ops *ops; + struct mm_struct *mm; + struct callback_head rcu; + unsigned int users; +}; + +struct mmu_notifier_range { + struct vm_area_struct *vma; + struct mm_struct *mm; + long unsigned int start; + long unsigned int end; + unsigned int flags; + enum mmu_notifier_event event; + void *migrate_pgmap_owner; +}; + +struct kvm_regs { + __u64 rax; + __u64 rbx; + __u64 rcx; + __u64 rdx; + __u64 rsi; + __u64 rdi; + __u64 rsp; + __u64 rbp; + __u64 r8; + __u64 r9; + __u64 r10; + __u64 r11; + __u64 r12; + __u64 r13; + __u64 r14; + __u64 r15; + __u64 rip; + __u64 rflags; +}; + +struct kvm_segment { + __u64 base; + __u32 limit; + __u16 selector; + __u8 type; + __u8 present; + __u8 dpl; + __u8 db; + __u8 s; + __u8 l; + __u8 g; + __u8 avl; + __u8 unusable; + __u8 padding; +}; + +struct kvm_dtable { + __u64 base; + __u16 limit; + __u16 padding[3]; +}; + +struct kvm_sregs { + struct kvm_segment cs; + struct kvm_segment ds; + struct kvm_segment es; + struct kvm_segment fs; + struct kvm_segment gs; + struct kvm_segment ss; + struct kvm_segment tr; + struct kvm_segment ldt; + struct kvm_dtable gdt; + struct kvm_dtable idt; + __u64 cr0; + __u64 cr2; + __u64 cr3; + __u64 cr4; + __u64 cr8; + __u64 efer; + __u64 apic_base; + __u64 interrupt_bitmap[4]; +}; + +struct kvm_cpuid_entry2 { + __u32 function; + __u32 index; + __u32 flags; + __u32 eax; + __u32 ebx; + __u32 ecx; + __u32 edx; + __u32 padding[3]; +}; + +struct kvm_debug_exit_arch { + __u32 exception; + __u32 pad; + __u64 pc; + __u64 dr6; + __u64 dr7; +}; + +struct kvm_vcpu_events { + struct { + __u8 injected; + __u8 nr; + __u8 has_error_code; + __u8 pending; + __u32 error_code; + } exception; + struct { + __u8 injected; + __u8 nr; + __u8 soft; + __u8 shadow; + } interrupt; + struct { + __u8 injected; + __u8 pending; + __u8 masked; + __u8 pad; + } nmi; + __u32 sipi_vector; + __u32 flags; + struct { + __u8 smm; + __u8 pending; + __u8 smm_inside_nmi; + __u8 latched_init; + } smi; + __u8 reserved[27]; + __u8 exception_has_payload; + __u64 exception_payload; +}; + +struct kvm_sync_regs { + struct kvm_regs regs; + struct kvm_sregs sregs; + struct kvm_vcpu_events events; +}; + +struct kvm_pmu_event_filter { + __u32 action; + __u32 nevents; + __u32 fixed_counter_bitmap; + __u32 flags; + __u32 pad[4]; + __u64 events[0]; +}; + +struct kvm_hyperv_exit { + __u32 type; + __u32 pad1; + union { + struct { + __u32 msr; + __u32 pad2; + __u64 control; + __u64 evt_page; + __u64 msg_page; + } synic; + struct { + __u64 input; + __u64 result; + __u64 params[2]; + } hcall; + struct { + __u32 msr; + __u32 pad2; + __u64 control; + __u64 status; + __u64 send_page; + __u64 recv_page; + __u64 pending_page; + } syndbg; + } u; +}; + +struct kvm_run { + __u8 request_interrupt_window; + __u8 immediate_exit; + __u8 padding1[6]; + __u32 exit_reason; + __u8 ready_for_interrupt_injection; + __u8 if_flag; + __u16 flags; + __u64 cr8; + __u64 apic_base; + union { + struct { + __u64 hardware_exit_reason; + } hw; + struct { + __u64 hardware_entry_failure_reason; + __u32 cpu; + } fail_entry; + struct { + __u32 exception; + __u32 error_code; + } ex; + struct { + __u8 direction; + __u8 size; + __u16 port; + __u32 count; + __u64 data_offset; + } io; + struct { + struct kvm_debug_exit_arch arch; + } debug; + struct { + __u64 phys_addr; + __u8 data[8]; + __u32 len; + __u8 is_write; + } mmio; + struct { + __u64 nr; + __u64 args[6]; + __u64 ret; + __u32 longmode; + __u32 pad; + } hypercall; + struct { + __u64 rip; + __u32 is_write; + __u32 pad; + } tpr_access; + struct { + __u8 icptcode; + __u16 ipa; + __u32 ipb; + } s390_sieic; + __u64 s390_reset_flags; + struct { + __u64 trans_exc_code; + __u32 pgm_code; + } s390_ucontrol; + struct { + __u32 dcrn; + __u32 data; + __u8 is_write; + } dcr; + struct { + __u32 suberror; + __u32 ndata; + __u64 data[16]; + } internal; + struct { + __u64 gprs[32]; + } osi; + struct { + __u64 nr; + __u64 ret; + __u64 args[9]; + } papr_hcall; + struct { + __u16 subchannel_id; + __u16 subchannel_nr; + __u32 io_int_parm; + __u32 io_int_word; + __u32 ipb; + __u8 dequeued; + } s390_tsch; + struct { + __u32 epr; + } epr; + struct { + __u32 type; + __u64 flags; + } system_event; + struct { + __u64 addr; + __u8 ar; + __u8 reserved; + __u8 fc; + __u8 sel1; + __u16 sel2; + } s390_stsi; + struct { + __u8 vector; + } eoi; + struct kvm_hyperv_exit hyperv; + struct { + __u64 esr_iss; + __u64 fault_ipa; + } arm_nisv; + struct { + __u8 error; + __u8 pad[7]; + __u32 reason; + __u32 index; + __u64 data; + } msr; + char padding[256]; + }; + __u64 kvm_valid_regs; + __u64 kvm_dirty_regs; + union { + struct kvm_sync_regs regs; + char padding[2048]; + } s; +}; + +struct kvm_coalesced_mmio { + __u64 phys_addr; + __u32 len; + union { + __u32 pad; + __u32 pio; + }; + __u8 data[8]; +}; + +struct kvm_coalesced_mmio_ring { + __u32 first; + __u32 last; + struct kvm_coalesced_mmio coalesced_mmio[0]; +}; + +struct kvm_xen_hvm_config { + __u32 flags; + __u32 msr; + __u64 blob_addr_32; + __u64 blob_addr_64; + __u8 blob_size_32; + __u8 blob_size_64; + __u8 pad2[30]; +}; + +typedef long unsigned int gva_t; + +typedef u64 gpa_t; + +typedef u64 gfn_t; + +typedef u64 hpa_t; + +typedef u64 hfn_t; + +typedef hfn_t kvm_pfn_t; + +struct kvm_memory_slot; + +struct gfn_to_hva_cache { + u64 generation; + gpa_t gpa; + long unsigned int hva; + long unsigned int len; + struct kvm_memory_slot *memslot; +}; + +struct kvm_rmap_head; + +struct kvm_lpage_info; + +struct kvm_arch_memory_slot { + struct kvm_rmap_head *rmap[3]; + struct kvm_lpage_info *lpage_info[2]; + short unsigned int *gfn_track[1]; +}; + +struct kvm_memory_slot { + gfn_t base_gfn; + long unsigned int npages; + long unsigned int *dirty_bitmap; + struct kvm_arch_memory_slot arch; + long unsigned int userspace_addr; + u32 flags; + short int id; + u16 as_id; +}; + +struct gfn_to_pfn_cache { + u64 generation; + gfn_t gfn; + kvm_pfn_t pfn; + bool dirty; +}; + +struct kvm_mmu_memory_cache { + int nobjs; + gfp_t gfp_zero; + struct kmem_cache *kmem_cache; + void *objects[40]; +}; + +struct hv_partition_assist_pg { + u32 tlb_lock_count; +}; + +union hv_message_flags { + __u8 asu8; + struct { + __u8 msg_pending: 1; + __u8 reserved: 7; + }; +}; + +union hv_port_id { + __u32 asu32; + struct { + __u32 id: 24; + __u32 reserved: 8; + } u; +}; + +struct hv_message_header { + __u32 message_type; + __u8 payload_size; + union hv_message_flags message_flags; + __u8 reserved[2]; + union { + __u64 sender; + union hv_port_id port; + }; +}; + +struct hv_message { + struct hv_message_header header; + union { + __u64 payload[30]; + } u; +}; + +union hv_stimer_config { + u64 as_uint64; + struct { + u64 enable: 1; + u64 periodic: 1; + u64 lazy: 1; + u64 auto_enable: 1; + u64 apic_vector: 8; + u64 direct_mode: 1; + u64 reserved_z0: 3; + u64 sintx: 4; + u64 reserved_z1: 44; + }; +}; + +enum kvm_page_track_mode { + KVM_PAGE_TRACK_WRITE = 0, + KVM_PAGE_TRACK_MAX = 1, +}; + +struct kvm_page_track_notifier_head { + struct srcu_struct track_srcu; + struct hlist_head track_notifier_list; +}; + +struct kvm_vcpu; + +struct kvm; + +struct kvm_page_track_notifier_node { + struct hlist_node node; + void (*track_write)(struct kvm_vcpu *, gpa_t, const u8 *, int, struct kvm_page_track_notifier_node *); + void (*track_flush_slot)(struct kvm *, struct kvm_memory_slot *, struct kvm_page_track_notifier_node *); +}; + +struct kvm_vcpu_stat { + u64 pf_fixed; + u64 pf_guest; + u64 tlb_flush; + u64 invlpg; + u64 exits; + u64 io_exits; + u64 mmio_exits; + u64 signal_exits; + u64 irq_window_exits; + u64 nmi_window_exits; + u64 l1d_flush; + u64 halt_exits; + u64 halt_successful_poll; + u64 halt_attempted_poll; + u64 halt_poll_invalid; + u64 halt_wakeup; + u64 request_irq_exits; + u64 irq_exits; + u64 host_state_reload; + u64 fpu_reload; + u64 insn_emulation; + u64 insn_emulation_fail; + u64 hypercalls; + u64 irq_injections; + u64 nmi_injections; + u64 req_event; + u64 halt_poll_success_ns; + u64 halt_poll_fail_ns; +}; + +struct kvm_mmio_fragment { + gpa_t gpa; + void *data; + unsigned int len; +}; + +struct kvm_lapic; + +struct x86_exception; + +struct kvm_mmu_page; + +union kvm_mmu_page_role { + u32 word; + struct { + unsigned int level: 4; + unsigned int gpte_is_8_bytes: 1; + unsigned int quadrant: 2; + unsigned int direct: 1; + unsigned int access: 3; + unsigned int invalid: 1; + unsigned int nxe: 1; + unsigned int cr0_wp: 1; + unsigned int smep_andnot_wp: 1; + unsigned int smap_andnot_wp: 1; + unsigned int ad_disabled: 1; + unsigned int guest_mode: 1; + char: 6; + unsigned int smm: 8; + }; +}; + +union kvm_mmu_extended_role { + u32 word; + struct { + unsigned int valid: 1; + unsigned int execonly: 1; + unsigned int cr0_pg: 1; + unsigned int cr4_pae: 1; + unsigned int cr4_pse: 1; + unsigned int cr4_pke: 1; + unsigned int cr4_smap: 1; + unsigned int cr4_smep: 1; + unsigned int maxphyaddr: 6; + }; +}; + +union kvm_mmu_role { + u64 as_u64; + struct { + union kvm_mmu_page_role base; + union kvm_mmu_extended_role ext; + }; +}; + +struct kvm_mmu_root_info { + gpa_t pgd; + hpa_t hpa; +}; + +struct rsvd_bits_validate { + u64 rsvd_bits_mask[10]; + u64 bad_mt_xwr; +}; + +struct kvm_mmu { + long unsigned int (*get_guest_pgd)(struct kvm_vcpu *); + u64 (*get_pdptr)(struct kvm_vcpu *, int); + int (*page_fault)(struct kvm_vcpu *, gpa_t, u32, bool); + void (*inject_page_fault)(struct kvm_vcpu *, struct x86_exception *); + gpa_t (*gva_to_gpa)(struct kvm_vcpu *, gpa_t, u32, struct x86_exception *); + gpa_t (*translate_gpa)(struct kvm_vcpu *, gpa_t, u32, struct x86_exception *); + int (*sync_page)(struct kvm_vcpu *, struct kvm_mmu_page *); + void (*invlpg)(struct kvm_vcpu *, gva_t, hpa_t); + void (*update_pte)(struct kvm_vcpu *, struct kvm_mmu_page *, u64 *, const void *); + hpa_t root_hpa; + gpa_t root_pgd; + union kvm_mmu_role mmu_role; + u8 root_level; + u8 shadow_root_level; + u8 ept_ad; + bool direct_map; + struct kvm_mmu_root_info prev_roots[3]; + u8 permissions[16]; + u32 pkru_mask; + u64 *pae_root; + u64 *lm_root; + struct rsvd_bits_validate shadow_zero_check; + struct rsvd_bits_validate guest_rsvd_check; + u8 last_nonleaf_level; + bool nx; + u64 pdptrs[4]; +}; + +struct kvm_pio_request { + long unsigned int linear_rip; + long unsigned int count; + int in; + int port; + int size; +}; + +struct kvm_queued_exception { + bool pending; + bool injected; + bool has_error_code; + u8 nr; + u32 error_code; + long unsigned int payload; + bool has_payload; + u8 nested_apf; +}; + +struct kvm_queued_interrupt { + bool injected; + bool soft; + u8 nr; +}; + +struct x86_emulate_ctxt; + +struct kvm_mtrr_range { + u64 base; + u64 mask; + struct list_head node; +}; + +struct kvm_mtrr { + struct kvm_mtrr_range var_ranges[8]; + mtrr_type fixed_ranges[88]; + u64 deftype; + struct list_head head; +}; + +enum pmc_type { + KVM_PMC_GP = 0, + KVM_PMC_FIXED = 1, +}; + +struct kvm_pmc { + enum pmc_type type; + u8 idx; + u64 counter; + u64 eventsel; + struct perf_event *perf_event; + struct kvm_vcpu *vcpu; + u64 current_config; +}; + +struct kvm_pmu { + unsigned int nr_arch_gp_counters; + unsigned int nr_arch_fixed_counters; + unsigned int available_event_types; + u64 fixed_ctr_ctrl; + u64 global_ctrl; + u64 global_status; + u64 global_ovf_ctrl; + u64 counter_bitmask[2]; + u64 global_ctrl_mask; + u64 global_ovf_ctrl_mask; + u64 reserved_bits; + u8 version; + struct kvm_pmc gp_counters[32]; + struct kvm_pmc fixed_counters[4]; + struct irq_work irq_work; + long unsigned int reprogram_pmi[1]; + long unsigned int all_valid_pmc_idx[1]; + long unsigned int pmc_in_use[1]; + bool need_cleanup; + u8 event_count; +}; + +struct kvm_vcpu_hv_synic { + u64 version; + u64 control; + u64 msg_page; + u64 evt_page; + atomic64_t sint[16]; + atomic_t sint_to_gsi[16]; + long unsigned int auto_eoi_bitmap[4]; + long unsigned int vec_bitmap[4]; + bool active; + bool dont_zero_synic_pages; +}; + +struct kvm_vcpu_hv_stimer { + struct hrtimer timer; + int index; + union hv_stimer_config config; + u64 count; + u64 exp_time; + struct hv_message msg; + bool msg_pending; +}; + +struct kvm_vcpu_hv { + u32 vp_index; + u64 hv_vapic; + s64 runtime_offset; + struct kvm_vcpu_hv_synic synic; + struct kvm_hyperv_exit exit; + struct kvm_vcpu_hv_stimer stimer[4]; + long unsigned int stimer_pending_bitmap[1]; + cpumask_t tlb_flush; +}; + +struct kvm_vcpu_arch { + long unsigned int regs[17]; + u32 regs_avail; + u32 regs_dirty; + long unsigned int cr0; + long unsigned int cr0_guest_owned_bits; + long unsigned int cr2; + long unsigned int cr3; + long unsigned int cr4; + long unsigned int cr4_guest_owned_bits; + long unsigned int cr4_guest_rsvd_bits; + long unsigned int cr8; + u32 host_pkru; + u32 pkru; + u32 hflags; + u64 efer; + u64 apic_base; + struct kvm_lapic *apic; + bool apicv_active; + bool load_eoi_exitmap_pending; + long unsigned int ioapic_handled_vectors[4]; + long unsigned int apic_attention; + int32_t apic_arb_prio; + int mp_state; + u64 ia32_misc_enable_msr; + u64 smbase; + u64 smi_count; + bool tpr_access_reporting; + bool xsaves_enabled; + u64 ia32_xss; + u64 microcode_version; + u64 arch_capabilities; + u64 perf_capabilities; + struct kvm_mmu *mmu; + struct kvm_mmu root_mmu; + struct kvm_mmu guest_mmu; + struct kvm_mmu nested_mmu; + struct kvm_mmu *walk_mmu; + struct kvm_mmu_memory_cache mmu_pte_list_desc_cache; + struct kvm_mmu_memory_cache mmu_shadow_page_cache; + struct kvm_mmu_memory_cache mmu_gfn_array_cache; + struct kvm_mmu_memory_cache mmu_page_header_cache; + struct fpu *user_fpu; + struct fpu *guest_fpu; + u64 xcr0; + u64 guest_supported_xcr0; + struct kvm_pio_request pio; + void *pio_data; + u8 event_exit_inst_len; + struct kvm_queued_exception exception; + struct kvm_queued_interrupt interrupt; + int halt_request; + int cpuid_nent; + struct kvm_cpuid_entry2 *cpuid_entries; + int maxphyaddr; + int max_tdp_level; + struct x86_emulate_ctxt *emulate_ctxt; + bool emulate_regs_need_sync_to_vcpu; + bool emulate_regs_need_sync_from_vcpu; + int (*complete_userspace_io)(struct kvm_vcpu *); + gpa_t time; + struct pvclock_vcpu_time_info hv_clock; + unsigned int hw_tsc_khz; + struct gfn_to_hva_cache pv_time; + bool pv_time_enabled; + bool pvclock_set_guest_stopped_request; + struct { + u8 preempted; + u64 msr_val; + u64 last_steal; + struct gfn_to_pfn_cache cache; + } st; + u64 l1_tsc_offset; + u64 tsc_offset; + u64 last_guest_tsc; + u64 last_host_tsc; + u64 tsc_offset_adjustment; + u64 this_tsc_nsec; + u64 this_tsc_write; + u64 this_tsc_generation; + bool tsc_catchup; + bool tsc_always_catchup; + s8 virtual_tsc_shift; + u32 virtual_tsc_mult; + u32 virtual_tsc_khz; + s64 ia32_tsc_adjust_msr; + u64 msr_ia32_power_ctl; + u64 tsc_scaling_ratio; + atomic_t nmi_queued; + unsigned int nmi_pending; + bool nmi_injected; + bool smi_pending; + struct kvm_mtrr mtrr_state; + u64 pat; + unsigned int switch_db_regs; + long unsigned int db[4]; + long unsigned int dr6; + long unsigned int dr7; + long unsigned int eff_db[4]; + long unsigned int guest_debug_dr7; + u64 msr_platform_info; + u64 msr_misc_features_enables; + u64 mcg_cap; + u64 mcg_status; + u64 mcg_ctl; + u64 mcg_ext_ctl; + u64 *mce_banks; + u64 mmio_gva; + unsigned int mmio_access; + gfn_t mmio_gfn; + u64 mmio_gen; + struct kvm_pmu pmu; + long unsigned int singlestep_rip; + struct kvm_vcpu_hv hyperv; + cpumask_var_t wbinvd_dirty_mask; + long unsigned int last_retry_eip; + long unsigned int last_retry_addr; + struct { + bool halted; + gfn_t gfns[64]; + struct gfn_to_hva_cache data; + u64 msr_en_val; + u64 msr_int_val; + u16 vec; + u32 id; + bool send_user_only; + u32 host_apf_flags; + long unsigned int nested_apf_token; + bool delivery_as_pf_vmexit; + bool pageready_pending; + } apf; + struct { + u64 length; + u64 status; + } osvw; + struct { + u64 msr_val; + struct gfn_to_hva_cache data; + } pv_eoi; + u64 msr_kvm_poll_control; + bool write_fault_to_shadow_pgtable; + long unsigned int exit_qualification; + struct { + bool pv_unhalted; + } pv; + int pending_ioapic_eoi; + int pending_external_vector; + bool preempted_in_kernel; + bool l1tf_flush_l1d; + unsigned int last_vmentry_cpu; + u64 msr_hwcr; + struct { + u32 features; + bool enforce; + } pv_cpuid; +}; + +struct kvm_vcpu { + struct kvm *kvm; + struct preempt_notifier preempt_notifier; + int cpu; + int vcpu_id; + int vcpu_idx; + int srcu_idx; + int mode; + u64 requests; + long unsigned int guest_debug; + int pre_pcpu; + struct list_head blocked_vcpu_list; + struct mutex mutex; + struct kvm_run *run; + struct rcuwait wait; + struct pid *pid; + int sigset_active; + sigset_t sigset; + struct kvm_vcpu_stat stat; + unsigned int halt_poll_ns; + bool valid_wakeup; + int mmio_needed; + int mmio_read_completed; + int mmio_is_write; + int mmio_cur_fragment; + int mmio_nr_fragments; + struct kvm_mmio_fragment mmio_fragments[2]; + struct { + u32 queued; + struct list_head queue; + struct list_head done; + spinlock_t lock; + } async_pf; + struct { + bool in_spin_loop; + bool dy_eligible; + } spin_loop; + bool preempted; + bool ready; + struct kvm_vcpu_arch arch; +}; + +struct kvm_vm_stat { + ulong mmu_shadow_zapped; + ulong mmu_pte_write; + ulong mmu_pte_updated; + ulong mmu_pde_zapped; + ulong mmu_flooded; + ulong mmu_recycled; + ulong mmu_cache_miss; + ulong mmu_unsync; + ulong remote_tlb_flush; + ulong lpages; + ulong nx_lpage_splits; + ulong max_mmu_page_hash_collisions; +}; + +struct iommu_domain___2; + +struct kvm_pic; + +struct kvm_ioapic; + +struct kvm_pit; + +struct kvm_hv_syndbg { + struct { + u64 control; + u64 status; + u64 send_page; + u64 recv_page; + u64 pending_page; + } control; + u64 options; +}; + +struct kvm_hv { + struct mutex hv_lock; + u64 hv_guest_os_id; + u64 hv_hypercall; + u64 hv_tsc_page; + u64 hv_crash_param[5]; + u64 hv_crash_ctl; + struct ms_hyperv_tsc_page tsc_ref; + struct idr conn_to_evt; + u64 hv_reenlightenment_control; + u64 hv_tsc_emulation_control; + u64 hv_tsc_emulation_status; + atomic_t num_mismatched_vp_indexes; + struct hv_partition_assist_pg *hv_pa_pg; + struct kvm_hv_syndbg hv_syndbg; +}; + +enum kvm_irqchip_mode { + KVM_IRQCHIP_NONE = 0, + KVM_IRQCHIP_KERNEL = 1, + KVM_IRQCHIP_SPLIT = 2, +}; + +struct msr_bitmap_range { + u32 flags; + u32 nmsrs; + u32 base; + long unsigned int *bitmap; +}; + +struct kvm_apic_map; + +struct kvm_arch { + long unsigned int n_used_mmu_pages; + long unsigned int n_requested_mmu_pages; + long unsigned int n_max_mmu_pages; + unsigned int indirect_shadow_pages; + u8 mmu_valid_gen; + struct hlist_head mmu_page_hash[4096]; + struct list_head active_mmu_pages; + struct list_head zapped_obsolete_pages; + struct list_head lpage_disallowed_mmu_pages; + struct kvm_page_track_notifier_node mmu_sp_tracker; + struct kvm_page_track_notifier_head track_notifier_head; + struct list_head assigned_dev_head; + struct iommu_domain___2 *iommu_domain; + bool iommu_noncoherent; + atomic_t noncoherent_dma_count; + atomic_t assigned_device_count; + struct kvm_pic *vpic; + struct kvm_ioapic *vioapic; + struct kvm_pit *vpit; + atomic_t vapics_in_nmi_mode; + struct mutex apic_map_lock; + struct kvm_apic_map *apic_map; + atomic_t apic_map_dirty; + bool apic_access_page_done; + long unsigned int apicv_inhibit_reasons; + gpa_t wall_clock; + bool mwait_in_guest; + bool hlt_in_guest; + bool pause_in_guest; + bool cstate_in_guest; + long unsigned int irq_sources_bitmap; + s64 kvmclock_offset; + raw_spinlock_t tsc_write_lock; + u64 last_tsc_nsec; + u64 last_tsc_write; + u32 last_tsc_khz; + u64 cur_tsc_nsec; + u64 cur_tsc_write; + u64 cur_tsc_offset; + u64 cur_tsc_generation; + int nr_vcpus_matched_tsc; + spinlock_t pvclock_gtod_sync_lock; + bool use_master_clock; + u64 master_kernel_ns; + u64 master_cycle_now; + struct delayed_work kvmclock_update_work; + struct delayed_work kvmclock_sync_work; + struct kvm_xen_hvm_config xen_hvm_config; + struct hlist_head mask_notifier_list; + struct kvm_hv hyperv; + bool backwards_tsc_observed; + bool boot_vcpu_runs_old_kvmclock; + u32 bsp_vcpu_id; + u64 disabled_quirks; + enum kvm_irqchip_mode irqchip_mode; + u8 nr_reserved_ioapic_pins; + bool disabled_lapic_found; + bool x2apic_format; + bool x2apic_broadcast_quirk_disabled; + bool guest_can_read_msr_platform_info; + bool exception_payload_enabled; + u32 user_space_msr_mask; + struct { + u8 count; + bool default_allow: 1; + struct msr_bitmap_range ranges[16]; + } msr_filter; + struct kvm_pmu_event_filter *pmu_event_filter; + struct task_struct *nx_lpage_recovery_thread; + bool tdp_mmu_enabled; + struct list_head tdp_mmu_roots; + struct list_head tdp_mmu_pages; +}; + +struct kvm_memslots; + +struct kvm_io_bus; + +struct kvm_irq_routing_table; + +struct kvm_stat_data; + +struct kvm { + spinlock_t mmu_lock; + struct mutex slots_lock; + struct mm_struct *mm; + struct kvm_memslots *memslots[2]; + struct kvm_vcpu *vcpus[288]; + atomic_t online_vcpus; + int created_vcpus; + int last_boosted_vcpu; + struct list_head vm_list; + struct mutex lock; + struct kvm_io_bus *buses[4]; + struct { + spinlock_t lock; + struct list_head items; + struct list_head resampler_list; + struct mutex resampler_lock; + } irqfds; + struct list_head ioeventfds; + struct kvm_vm_stat stat; + struct kvm_arch arch; + refcount_t users_count; + struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; + spinlock_t ring_lock; + struct list_head coalesced_zones; + struct mutex irq_lock; + struct kvm_irq_routing_table *irq_routing; + struct hlist_head irq_ack_notifier_list; + struct mmu_notifier mmu_notifier; + long unsigned int mmu_notifier_seq; + long int mmu_notifier_count; + long int tlbs_dirty; + struct list_head devices; + u64 manual_dirty_log_protect; + struct dentry *debugfs_dentry; + struct kvm_stat_data **debugfs_stat_data; + struct srcu_struct srcu; + struct srcu_struct irq_srcu; + pid_t userspace_pid; + unsigned int max_halt_poll_ns; +}; + +enum kvm_reg { + VCPU_REGS_RAX = 0, + VCPU_REGS_RCX = 1, + VCPU_REGS_RDX = 2, + VCPU_REGS_RBX = 3, + VCPU_REGS_RSP = 4, + VCPU_REGS_RBP = 5, + VCPU_REGS_RSI = 6, + VCPU_REGS_RDI = 7, + VCPU_REGS_R8 = 8, + VCPU_REGS_R9 = 9, + VCPU_REGS_R10 = 10, + VCPU_REGS_R11 = 11, + VCPU_REGS_R12 = 12, + VCPU_REGS_R13 = 13, + VCPU_REGS_R14 = 14, + VCPU_REGS_R15 = 15, + VCPU_REGS_RIP = 16, + NR_VCPU_REGS = 17, + VCPU_EXREG_PDPTR = 17, + VCPU_EXREG_CR0 = 18, + VCPU_EXREG_CR3 = 19, + VCPU_EXREG_CR4 = 20, + VCPU_EXREG_RFLAGS = 21, + VCPU_EXREG_SEGMENTS = 22, + VCPU_EXREG_EXIT_INFO_1 = 23, + VCPU_EXREG_EXIT_INFO_2 = 24, +}; + +struct kvm_rmap_head { + long unsigned int val; +}; + +struct kvm_lpage_info { + int disallow_lpage; +}; + +struct kvm_apic_map { + struct callback_head rcu; + u8 mode; + u32 max_apic_id; + union { + struct kvm_lapic *xapic_flat_map[8]; + struct kvm_lapic *xapic_cluster_map[64]; + }; + struct kvm_lapic *phys_map[0]; +}; + +struct kvm_io_device; + +struct kvm_io_range { + gpa_t addr; + int len; + struct kvm_io_device *dev; +}; + +struct kvm_io_bus { + int dev_count; + int ioeventfd_count; + struct kvm_io_range range[0]; +}; + +enum kvm_bus { + KVM_MMIO_BUS = 0, + KVM_PIO_BUS = 1, + KVM_VIRTIO_CCW_NOTIFY_BUS = 2, + KVM_FAST_MMIO_BUS = 3, + KVM_NR_BUSES = 4, +}; + +struct kvm_irq_routing_table { + int chip[72]; + u32 nr_rt_entries; + struct hlist_head map[0]; +}; + +struct kvm_memslots { + u64 generation; + short int id_to_index[512]; + atomic_t lru_slot; + int used_slots; + struct kvm_memory_slot memslots[0]; +}; + +struct kvm_stats_debugfs_item; + +struct kvm_stat_data { + struct kvm *kvm; + struct kvm_stats_debugfs_item *dbgfs_item; +}; + +enum kvm_stat_kind { + KVM_STAT_VM = 0, + KVM_STAT_VCPU = 1, +}; + +struct kvm_stats_debugfs_item { + const char *name; + int offset; + enum kvm_stat_kind kind; + int mode; +}; + +enum profile_type { + PROFILE_TASK_EXIT = 0, + PROFILE_MUNMAP = 1, +}; + +struct profile_hit { + u32 pc; + u32 hits; +}; + +struct stacktrace_cookie { + long unsigned int *store; + unsigned int size; + unsigned int skip; + unsigned int len; +}; + +typedef __kernel_long_t __kernel_suseconds_t; + +typedef __kernel_long_t __kernel_old_time_t; + +typedef __kernel_suseconds_t suseconds_t; + +typedef __u64 timeu64_t; + +struct __kernel_itimerspec { + struct __kernel_timespec it_interval; + struct __kernel_timespec it_value; +}; + +struct timezone { + int tz_minuteswest; + int tz_dsttime; +}; + +struct itimerspec64 { + struct timespec64 it_interval; + struct timespec64 it_value; +}; + +struct old_itimerspec32 { + struct old_timespec32 it_interval; + struct old_timespec32 it_value; +}; + +struct old_timex32 { + u32 modes; + s32 offset; + s32 freq; + s32 maxerror; + s32 esterror; + s32 status; + s32 constant; + s32 precision; + s32 tolerance; + struct old_timeval32 time; + s32 tick; + s32 ppsfreq; + s32 jitter; + s32 shift; + s32 stabil; + s32 jitcnt; + s32 calcnt; + s32 errcnt; + s32 stbcnt; + s32 tai; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct __kernel_timex_timeval { + __kernel_time64_t tv_sec; + long long int tv_usec; +}; + +struct __kernel_timex { + unsigned int modes; + long long int offset; + long long int freq; + long long int maxerror; + long long int esterror; + int status; + long long int constant; + long long int precision; + long long int tolerance; + struct __kernel_timex_timeval time; + long long int tick; + long long int ppsfreq; + long long int jitter; + int shift; + long long int stabil; + long long int jitcnt; + long long int calcnt; + long long int errcnt; + long long int stbcnt; + int tai; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct trace_event_raw_timer_class { + struct trace_entry ent; + void *timer; + char __data[0]; +}; + +struct trace_event_raw_timer_start { + struct trace_entry ent; + void *timer; + void *function; + long unsigned int expires; + long unsigned int now; + unsigned int flags; + char __data[0]; +}; + +struct trace_event_raw_timer_expire_entry { + struct trace_entry ent; + void *timer; + long unsigned int now; + void *function; + long unsigned int baseclk; + char __data[0]; +}; + +struct trace_event_raw_hrtimer_init { + struct trace_entry ent; + void *hrtimer; + clockid_t clockid; + enum hrtimer_mode mode; + char __data[0]; +}; + +struct trace_event_raw_hrtimer_start { + struct trace_entry ent; + void *hrtimer; + void *function; + s64 expires; + s64 softexpires; + enum hrtimer_mode mode; + char __data[0]; +}; + +struct trace_event_raw_hrtimer_expire_entry { + struct trace_entry ent; + void *hrtimer; + s64 now; + void *function; + char __data[0]; +}; + +struct trace_event_raw_hrtimer_class { + struct trace_entry ent; + void *hrtimer; + char __data[0]; +}; + +struct trace_event_raw_itimer_state { + struct trace_entry ent; + int which; + long long unsigned int expires; + long int value_sec; + long int value_nsec; + long int interval_sec; + long int interval_nsec; + char __data[0]; +}; + +struct trace_event_raw_itimer_expire { + struct trace_entry ent; + int which; + pid_t pid; + long long unsigned int now; + char __data[0]; +}; + +struct trace_event_raw_tick_stop { + struct trace_entry ent; + int success; + int dependency; + char __data[0]; +}; + +struct trace_event_data_offsets_timer_class {}; + +struct trace_event_data_offsets_timer_start {}; + +struct trace_event_data_offsets_timer_expire_entry {}; + +struct trace_event_data_offsets_hrtimer_init {}; + +struct trace_event_data_offsets_hrtimer_start {}; + +struct trace_event_data_offsets_hrtimer_expire_entry {}; + +struct trace_event_data_offsets_hrtimer_class {}; + +struct trace_event_data_offsets_itimer_state {}; + +struct trace_event_data_offsets_itimer_expire {}; + +struct trace_event_data_offsets_tick_stop {}; + +typedef void (*btf_trace_timer_init)(void *, struct timer_list *); + +typedef void (*btf_trace_timer_start)(void *, struct timer_list *, long unsigned int, unsigned int); + +typedef void (*btf_trace_timer_expire_entry)(void *, struct timer_list *, long unsigned int); + +typedef void (*btf_trace_timer_expire_exit)(void *, struct timer_list *); + +typedef void (*btf_trace_timer_cancel)(void *, struct timer_list *); + +typedef void (*btf_trace_hrtimer_init)(void *, struct hrtimer *, clockid_t, enum hrtimer_mode); + +typedef void (*btf_trace_hrtimer_start)(void *, struct hrtimer *, enum hrtimer_mode); + +typedef void (*btf_trace_hrtimer_expire_entry)(void *, struct hrtimer *, ktime_t *); + +typedef void (*btf_trace_hrtimer_expire_exit)(void *, struct hrtimer *); + +typedef void (*btf_trace_hrtimer_cancel)(void *, struct hrtimer *); + +typedef void (*btf_trace_itimer_state)(void *, int, const struct itimerspec64 * const, long long unsigned int); + +typedef void (*btf_trace_itimer_expire)(void *, int, struct pid *, long long unsigned int); + +typedef void (*btf_trace_tick_stop)(void *, int, int); + +struct timer_base { + raw_spinlock_t lock; + struct timer_list *running_timer; + long unsigned int clk; + long unsigned int next_expiry; + unsigned int cpu; + bool next_expiry_recalc; + bool is_idle; + long unsigned int pending_map[9]; + struct hlist_head vectors[576]; +}; + +struct process_timer { + struct timer_list timer; + struct task_struct *task; +}; + +enum tick_device_mode { + TICKDEV_MODE_PERIODIC = 0, + TICKDEV_MODE_ONESHOT = 1, +}; + +struct tick_device { + struct clock_event_device *evtdev; + enum tick_device_mode mode; +}; + +struct ktime_timestamps { + u64 mono; + u64 boot; + u64 real; +}; + +struct system_time_snapshot { + u64 cycles; + ktime_t real; + ktime_t raw; + unsigned int clock_was_set_seq; + u8 cs_was_changed_seq; +}; + +struct system_device_crosststamp { + ktime_t device; + ktime_t sys_realtime; + ktime_t sys_monoraw; +}; + +struct tk_read_base { + struct clocksource *clock; + u64 mask; + u64 cycle_last; + u32 mult; + u32 shift; + u64 xtime_nsec; + ktime_t base; + u64 base_real; +}; + +struct timekeeper { + struct tk_read_base tkr_mono; + struct tk_read_base tkr_raw; + u64 xtime_sec; + long unsigned int ktime_sec; + struct timespec64 wall_to_monotonic; + ktime_t offs_real; + ktime_t offs_boot; + ktime_t offs_tai; + s32 tai_offset; + unsigned int clock_was_set_seq; + u8 cs_was_changed_seq; + ktime_t next_leap_ktime; + u64 raw_sec; + struct timespec64 monotonic_to_boot; + u64 cycle_interval; + u64 xtime_interval; + s64 xtime_remainder; + u64 raw_interval; + u64 ntp_tick; + s64 ntp_error; + u32 ntp_error_shift; + u32 ntp_err_mult; + u32 skip_second_overflow; +}; + +struct audit_ntp_val { + long long int oldval; + long long int newval; +}; + +struct audit_ntp_data { + struct audit_ntp_val vals[6]; +}; + +enum timekeeping_adv_mode { + TK_ADV_TICK = 0, + TK_ADV_FREQ = 1, +}; + +struct tk_fast { + seqcount_latch_t seq; + struct tk_read_base base[2]; +}; + +typedef s64 int64_t; + +enum tick_nohz_mode { + NOHZ_MODE_INACTIVE = 0, + NOHZ_MODE_LOWRES = 1, + NOHZ_MODE_HIGHRES = 2, +}; + +struct tick_sched { + struct hrtimer sched_timer; + long unsigned int check_clocks; + enum tick_nohz_mode nohz_mode; + unsigned int inidle: 1; + unsigned int tick_stopped: 1; + unsigned int idle_active: 1; + unsigned int do_timer_last: 1; + unsigned int got_idle_tick: 1; + ktime_t last_tick; + ktime_t next_tick; + long unsigned int idle_jiffies; + long unsigned int idle_calls; + long unsigned int idle_sleeps; + ktime_t idle_entrytime; + ktime_t idle_waketime; + ktime_t idle_exittime; + ktime_t idle_sleeptime; + ktime_t iowait_sleeptime; + long unsigned int last_jiffies; + u64 timer_expires; + u64 timer_expires_base; + u64 next_timer; + ktime_t idle_expires; + atomic_t tick_dep_mask; +}; + +struct timer_list_iter { + int cpu; + bool second_pass; + u64 now; +}; + +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + long int tm_year; + int tm_wday; + int tm_yday; +}; + +struct cyclecounter { + u64 (*read)(const struct cyclecounter *); + u64 mask; + u32 mult; + u32 shift; +}; + +struct timecounter { + const struct cyclecounter *cc; + u64 cycle_last; + u64 nsec; + u64 mask; + u64 frac; +}; + +typedef __kernel_timer_t timer_t; + +struct rtc_wkalrm { + unsigned char enabled; + unsigned char pending; + struct rtc_time time; +}; + +enum alarmtimer_type { + ALARM_REALTIME = 0, + ALARM_BOOTTIME = 1, + ALARM_NUMTYPE = 2, + ALARM_REALTIME_FREEZER = 3, + ALARM_BOOTTIME_FREEZER = 4, +}; + +enum alarmtimer_restart { + ALARMTIMER_NORESTART = 0, + ALARMTIMER_RESTART = 1, +}; + +struct alarm { + struct timerqueue_node node; + struct hrtimer timer; + enum alarmtimer_restart (*function)(struct alarm *, ktime_t); + enum alarmtimer_type type; + int state; + void *data; +}; + +struct cpu_timer { + struct timerqueue_node node; + struct timerqueue_head *head; + struct pid *pid; + struct list_head elist; + int firing; +}; + +struct k_clock; + +struct k_itimer { + struct list_head list; + struct hlist_node t_hash; + spinlock_t it_lock; + const struct k_clock *kclock; + clockid_t it_clock; + timer_t it_id; + int it_active; + s64 it_overrun; + s64 it_overrun_last; + int it_requeue_pending; + int it_sigev_notify; + ktime_t it_interval; + struct signal_struct *it_signal; + union { + struct pid *it_pid; + struct task_struct *it_process; + }; + struct sigqueue *sigq; + union { + struct { + struct hrtimer timer; + } real; + struct cpu_timer cpu; + struct { + struct alarm alarmtimer; + } alarm; + } it; + struct callback_head rcu; +}; + +struct k_clock { + int (*clock_getres)(const clockid_t, struct timespec64 *); + int (*clock_set)(const clockid_t, const struct timespec64 *); + int (*clock_get_timespec)(const clockid_t, struct timespec64 *); + ktime_t (*clock_get_ktime)(const clockid_t); + int (*clock_adj)(const clockid_t, struct __kernel_timex *); + int (*timer_create)(struct k_itimer *); + int (*nsleep)(const clockid_t, int, const struct timespec64 *); + int (*timer_set)(struct k_itimer *, int, struct itimerspec64 *, struct itimerspec64 *); + int (*timer_del)(struct k_itimer *); + void (*timer_get)(struct k_itimer *, struct itimerspec64 *); + void (*timer_rearm)(struct k_itimer *); + s64 (*timer_forward)(struct k_itimer *, ktime_t); + ktime_t (*timer_remaining)(struct k_itimer *, ktime_t); + int (*timer_try_to_cancel)(struct k_itimer *); + void (*timer_arm)(struct k_itimer *, ktime_t, bool, bool); + void (*timer_wait_running)(struct k_itimer *); +}; + +struct class_interface { + struct list_head node; + struct class *class; + int (*add_dev)(struct device *, struct class_interface *); + void (*remove_dev)(struct device *, struct class_interface *); +}; + +struct rtc_class_ops { + int (*ioctl)(struct device *, unsigned int, long unsigned int); + int (*read_time)(struct device *, struct rtc_time *); + int (*set_time)(struct device *, struct rtc_time *); + int (*read_alarm)(struct device *, struct rtc_wkalrm *); + int (*set_alarm)(struct device *, struct rtc_wkalrm *); + int (*proc)(struct device *, struct seq_file *); + int (*alarm_irq_enable)(struct device *, unsigned int); + int (*read_offset)(struct device *, long int *); + int (*set_offset)(struct device *, long int); +}; + +struct rtc_device; + +struct rtc_timer { + struct timerqueue_node node; + ktime_t period; + void (*func)(struct rtc_device *); + struct rtc_device *rtc; + int enabled; +}; + +struct rtc_device { + struct device dev; + struct module *owner; + int id; + const struct rtc_class_ops *ops; + struct mutex ops_lock; + struct cdev char_dev; + long unsigned int flags; + long unsigned int irq_data; + spinlock_t irq_lock; + wait_queue_head_t irq_queue; + struct fasync_struct *async_queue; + int irq_freq; + int max_user_freq; + struct timerqueue_head timerqueue; + struct rtc_timer aie_timer; + struct rtc_timer uie_rtctimer; + struct hrtimer pie_timer; + int pie_enabled; + struct work_struct irqwork; + int uie_unsupported; + long int set_offset_nsec; + bool registered; + bool nvram_old_abi; + struct bin_attribute *nvram; + time64_t range_min; + timeu64_t range_max; + time64_t start_secs; + time64_t offset_secs; + bool set_start_time; +}; + +struct platform_driver { + int (*probe)(struct platform_device *); + int (*remove)(struct platform_device *); + void (*shutdown)(struct platform_device *); + int (*suspend)(struct platform_device *, pm_message_t); + int (*resume)(struct platform_device *); + struct device_driver driver; + const struct platform_device_id *id_table; + bool prevent_deferred_probe; +}; + +struct trace_event_raw_alarmtimer_suspend { + struct trace_entry ent; + s64 expires; + unsigned char alarm_type; + char __data[0]; +}; + +struct trace_event_raw_alarm_class { + struct trace_entry ent; + void *alarm; + unsigned char alarm_type; + s64 expires; + s64 now; + char __data[0]; +}; + +struct trace_event_data_offsets_alarmtimer_suspend {}; + +struct trace_event_data_offsets_alarm_class {}; + +typedef void (*btf_trace_alarmtimer_suspend)(void *, ktime_t, int); + +typedef void (*btf_trace_alarmtimer_fired)(void *, struct alarm *, ktime_t); + +typedef void (*btf_trace_alarmtimer_start)(void *, struct alarm *, ktime_t); + +typedef void (*btf_trace_alarmtimer_cancel)(void *, struct alarm *, ktime_t); + +struct alarm_base { + spinlock_t lock; + struct timerqueue_head timerqueue; + ktime_t (*get_ktime)(); + void (*get_timespec)(struct timespec64 *); + clockid_t base_clockid; +}; + +struct sigevent { + sigval_t sigev_value; + int sigev_signo; + int sigev_notify; + union { + int _pad[12]; + int _tid; + struct { + void (*_function)(sigval_t); + void *_attribute; + } _sigev_thread; + } _sigev_un; +}; + +typedef struct sigevent sigevent_t; + +struct compat_sigevent { + compat_sigval_t sigev_value; + compat_int_t sigev_signo; + compat_int_t sigev_notify; + union { + compat_int_t _pad[13]; + compat_int_t _tid; + struct { + compat_uptr_t _function; + compat_uptr_t _attribute; + } _sigev_thread; + } _sigev_un; +}; + +typedef unsigned int uint; + +struct posix_clock; + +struct posix_clock_operations { + struct module *owner; + int (*clock_adjtime)(struct posix_clock *, struct __kernel_timex *); + int (*clock_gettime)(struct posix_clock *, struct timespec64 *); + int (*clock_getres)(struct posix_clock *, struct timespec64 *); + int (*clock_settime)(struct posix_clock *, const struct timespec64 *); + long int (*ioctl)(struct posix_clock *, unsigned int, long unsigned int); + int (*open)(struct posix_clock *, fmode_t); + __poll_t (*poll)(struct posix_clock *, struct file *, poll_table *); + int (*release)(struct posix_clock *); + ssize_t (*read)(struct posix_clock *, uint, char *, size_t); +}; + +struct posix_clock { + struct posix_clock_operations ops; + struct cdev cdev; + struct device *dev; + struct rw_semaphore rwsem; + bool zombie; +}; + +struct posix_clock_desc { + struct file *fp; + struct posix_clock *clk; +}; + +struct __kernel_old_itimerval { + struct __kernel_old_timeval it_interval; + struct __kernel_old_timeval it_value; +}; + +struct old_itimerval32 { + struct old_timeval32 it_interval; + struct old_timeval32 it_value; +}; + +struct ce_unbind { + struct clock_event_device *ce; + int res; +}; + +union futex_key { + struct { + u64 i_seq; + long unsigned int pgoff; + unsigned int offset; + } shared; + struct { + union { + struct mm_struct *mm; + u64 __tmp; + }; + long unsigned int address; + unsigned int offset; + } private; + struct { + u64 ptr; + long unsigned int word; + unsigned int offset; + } both; +}; + +struct futex_pi_state { + struct list_head list; + struct rt_mutex pi_mutex; + struct task_struct *owner; + refcount_t refcount; + union futex_key key; +}; + +struct futex_q { + struct plist_node list; + struct task_struct *task; + spinlock_t *lock_ptr; + union futex_key key; + struct futex_pi_state *pi_state; + struct rt_mutex_waiter *rt_waiter; + union futex_key *requeue_pi_key; + u32 bitset; +}; + +struct futex_hash_bucket { + atomic_t waiters; + spinlock_t lock; + struct plist_head chain; + long: 64; + long: 64; +}; + +enum futex_access { + FUTEX_READ = 0, + FUTEX_WRITE = 1, +}; + +struct dma_chan { + int lock; + const char *device_id; +}; + +typedef bool (*smp_cond_func_t)(int, void *); + +struct call_function_data { + call_single_data_t *csd; + cpumask_var_t cpumask; + cpumask_var_t cpumask_ipi; +}; + +struct smp_call_on_cpu_struct { + struct work_struct work; + struct completion done; + int (*func)(void *); + void *data; + int ret; + int cpu; +}; + +struct latch_tree_root { + seqcount_latch_t seq; + struct rb_root tree[2]; +}; + +struct latch_tree_ops { + bool (*less)(struct latch_tree_node *, struct latch_tree_node *); + int (*comp)(void *, struct latch_tree_node *); +}; + +struct modversion_info { + long unsigned int crc; + char name[56]; +}; + +struct module_use { + struct list_head source_list; + struct list_head target_list; + struct module *source; + struct module *target; +}; + +struct module_sect_attr { + struct bin_attribute battr; + long unsigned int address; +}; + +struct module_sect_attrs { + struct attribute_group grp; + unsigned int nsections; + struct module_sect_attr attrs[0]; +}; + +struct module_notes_attrs { + struct kobject *dir; + unsigned int notes; + struct bin_attribute attrs[0]; +}; + +enum mod_license { + NOT_GPL_ONLY = 0, + GPL_ONLY = 1, + WILL_BE_GPL_ONLY = 2, +}; + +struct symsearch { + const struct kernel_symbol *start; + const struct kernel_symbol *stop; + const s32 *crcs; + enum mod_license license; + bool unused; +}; + +enum kernel_read_file_id { + READING_UNKNOWN = 0, + READING_FIRMWARE = 1, + READING_MODULE = 2, + READING_KEXEC_IMAGE = 3, + READING_KEXEC_INITRAMFS = 4, + READING_POLICY = 5, + READING_X509_CERTIFICATE = 6, + READING_MAX_ID = 7, +}; + +enum kernel_load_data_id { + LOADING_UNKNOWN = 0, + LOADING_FIRMWARE = 1, + LOADING_MODULE = 2, + LOADING_KEXEC_IMAGE = 3, + LOADING_KEXEC_INITRAMFS = 4, + LOADING_POLICY = 5, + LOADING_X509_CERTIFICATE = 6, + LOADING_MAX_ID = 7, +}; + +enum { + PROC_ENTRY_PERMANENT = 1, +}; + +struct _ddebug { + const char *modname; + const char *function; + const char *filename; + const char *format; + unsigned int lineno: 18; + unsigned int flags: 8; + union { + struct static_key_true dd_key_true; + struct static_key_false dd_key_false; + } key; +}; + +struct load_info { + const char *name; + struct module *mod; + Elf64_Ehdr *hdr; + long unsigned int len; + Elf64_Shdr *sechdrs; + char *secstrings; + char *strtab; + long unsigned int symoffs; + long unsigned int stroffs; + long unsigned int init_typeoffs; + long unsigned int core_typeoffs; + struct _ddebug *debug; + unsigned int num_debug; + bool sig_ok; + long unsigned int mod_kallsyms_init_off; + struct { + unsigned int sym; + unsigned int str; + unsigned int mod; + unsigned int vers; + unsigned int info; + unsigned int pcpu; + } index; +}; + +struct trace_event_raw_module_load { + struct trace_entry ent; + unsigned int taints; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_module_free { + struct trace_entry ent; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_module_refcnt { + struct trace_entry ent; + long unsigned int ip; + int refcnt; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_module_request { + struct trace_entry ent; + long unsigned int ip; + bool wait; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_data_offsets_module_load { + u32 name; +}; + +struct trace_event_data_offsets_module_free { + u32 name; +}; + +struct trace_event_data_offsets_module_refcnt { + u32 name; +}; + +struct trace_event_data_offsets_module_request { + u32 name; +}; + +typedef void (*btf_trace_module_load)(void *, struct module *); + +typedef void (*btf_trace_module_free)(void *, struct module *); + +typedef void (*btf_trace_module_get)(void *, struct module *, long unsigned int); + +typedef void (*btf_trace_module_put)(void *, struct module *, long unsigned int); + +typedef void (*btf_trace_module_request)(void *, char *, bool, long unsigned int); + +struct mod_tree_root { + struct latch_tree_root root; + long unsigned int addr_min; + long unsigned int addr_max; +}; + +struct find_symbol_arg { + const char *name; + bool gplok; + bool warn; + struct module *owner; + const s32 *crc; + const struct kernel_symbol *sym; + enum mod_license license; +}; + +struct mod_initfree { + struct llist_node node; + void *module_init; +}; + +struct module_signature { + u8 algo; + u8 hash; + u8 id_type; + u8 signer_len; + u8 key_id_len; + u8 __pad[3]; + __be32 sig_len; +}; + +enum key_being_used_for { + VERIFYING_MODULE_SIGNATURE = 0, + VERIFYING_FIRMWARE_SIGNATURE = 1, + VERIFYING_KEXEC_PE_SIGNATURE = 2, + VERIFYING_KEY_SIGNATURE = 3, + VERIFYING_KEY_SELF_SIGNATURE = 4, + VERIFYING_UNSPECIFIED_SIGNATURE = 5, + NR__KEY_BEING_USED_FOR = 6, +}; + +enum pkey_id_type { + PKEY_ID_PGP = 0, + PKEY_ID_X509 = 1, + PKEY_ID_PKCS7 = 2, +}; + +struct kallsym_iter { + loff_t pos; + loff_t pos_arch_end; + loff_t pos_mod_end; + loff_t pos_ftrace_mod_end; + loff_t pos_bpf_end; + long unsigned int value; + unsigned int nameoff; + char type; + char name[128]; + char module_name[56]; + int exported; + int show_value; +}; + +typedef __u16 comp_t; + +typedef __u32 comp2_t; + +struct acct { + char ac_flag; + char ac_version; + __u16 ac_uid16; + __u16 ac_gid16; + __u16 ac_tty; + __u32 ac_btime; + comp_t ac_utime; + comp_t ac_stime; + comp_t ac_etime; + comp_t ac_mem; + comp_t ac_io; + comp_t ac_rw; + comp_t ac_minflt; + comp_t ac_majflt; + comp_t ac_swaps; + __u16 ac_ahz; + __u32 ac_exitcode; + char ac_comm[17]; + __u8 ac_etime_hi; + __u16 ac_etime_lo; + __u32 ac_uid; + __u32 ac_gid; +}; + +typedef struct acct acct_t; + +struct fs_pin { + wait_queue_head_t wait; + int done; + struct hlist_node s_list; + struct hlist_node m_list; + void (*kill)(struct fs_pin *); +}; + +struct bsd_acct_struct { + struct fs_pin pin; + atomic_long_t count; + struct callback_head rcu; + struct mutex lock; + int active; + long unsigned int needcheck; + struct file *file; + struct pid_namespace *ns; + struct work_struct work; + struct completion done; +}; + +struct elf64_note { + Elf64_Word n_namesz; + Elf64_Word n_descsz; + Elf64_Word n_type; +}; + +struct elf_note_section { + struct elf64_note n_hdr; + u8 n_data[0]; +}; + +typedef long unsigned int elf_greg_t; + +typedef elf_greg_t elf_gregset_t[27]; + +struct elf_siginfo { + int si_signo; + int si_code; + int si_errno; +}; + +struct elf_prstatus { + struct elf_siginfo pr_info; + short int pr_cursig; + long unsigned int pr_sigpend; + long unsigned int pr_sighold; + pid_t pr_pid; + pid_t pr_ppid; + pid_t pr_pgrp; + pid_t pr_sid; + struct __kernel_old_timeval pr_utime; + struct __kernel_old_timeval pr_stime; + struct __kernel_old_timeval pr_cutime; + struct __kernel_old_timeval pr_cstime; + elf_gregset_t pr_reg; + int pr_fpvalid; +}; + +typedef u32 note_buf_t[92]; + +struct compat_kexec_segment { + compat_uptr_t buf; + compat_size_t bufsz; + compat_ulong_t mem; + compat_size_t memsz; +}; + +enum migrate_reason { + MR_COMPACTION = 0, + MR_MEMORY_FAILURE = 1, + MR_MEMORY_HOTPLUG = 2, + MR_SYSCALL = 3, + MR_MEMPOLICY_MBIND = 4, + MR_NUMA_MISPLACED = 5, + MR_CONTIG_RANGE = 6, + MR_TYPES = 7, +}; + +typedef __kernel_ulong_t __kernel_ino_t; + +typedef __kernel_ino_t ino_t; + +enum kernfs_node_type { + KERNFS_DIR = 1, + KERNFS_FILE = 2, + KERNFS_LINK = 4, +}; + +enum kernfs_root_flag { + KERNFS_ROOT_CREATE_DEACTIVATED = 1, + KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK = 2, + KERNFS_ROOT_SUPPORT_EXPORTOP = 4, + KERNFS_ROOT_SUPPORT_USER_XATTR = 8, +}; + +struct kernfs_fs_context { + struct kernfs_root *root; + void *ns_tag; + long unsigned int magic; + bool new_sb_created; +}; + +enum bpf_link_type { + BPF_LINK_TYPE_UNSPEC = 0, + BPF_LINK_TYPE_RAW_TRACEPOINT = 1, + BPF_LINK_TYPE_TRACING = 2, + BPF_LINK_TYPE_CGROUP = 3, + BPF_LINK_TYPE_ITER = 4, + BPF_LINK_TYPE_NETNS = 5, + BPF_LINK_TYPE_XDP = 6, + MAX_BPF_LINK_TYPE = 7, +}; + +struct bpf_link_info { + __u32 type; + __u32 id; + __u32 prog_id; + union { + struct { + __u64 tp_name; + __u32 tp_name_len; + } raw_tracepoint; + struct { + __u32 attach_type; + } tracing; + struct { + __u64 cgroup_id; + __u32 attach_type; + } cgroup; + struct { + __u64 target_name; + __u32 target_name_len; + union { + struct { + __u32 map_id; + } map; + }; + } iter; + struct { + __u32 netns_ino; + __u32 attach_type; + } netns; + struct { + __u32 ifindex; + } xdp; + }; +}; + +struct bpf_link_ops; + +struct bpf_link { + atomic64_t refcnt; + u32 id; + enum bpf_link_type type; + const struct bpf_link_ops *ops; + struct bpf_prog *prog; + struct work_struct work; +}; + +struct bpf_link_ops { + void (*release)(struct bpf_link *); + void (*dealloc)(struct bpf_link *); + int (*detach)(struct bpf_link *); + int (*update_prog)(struct bpf_link *, struct bpf_prog *, struct bpf_prog *); + void (*show_fdinfo)(const struct bpf_link *, struct seq_file *); + int (*fill_link_info)(const struct bpf_link *, struct bpf_link_info *); +}; + +struct bpf_cgroup_link { + struct bpf_link link; + struct cgroup *cgroup; + enum bpf_attach_type type; +}; + +enum { + CGRP_NOTIFY_ON_RELEASE = 0, + CGRP_CPUSET_CLONE_CHILDREN = 1, + CGRP_FREEZE = 2, + CGRP_FROZEN = 3, +}; + +enum { + CGRP_ROOT_NOPREFIX = 2, + CGRP_ROOT_XATTR = 4, + CGRP_ROOT_NS_DELEGATE = 8, + CGRP_ROOT_CPUSET_V2_MODE = 16, + CGRP_ROOT_MEMORY_LOCAL_EVENTS = 32, + CGRP_ROOT_MEMORY_RECURSIVE_PROT = 64, +}; + +struct cgroup_taskset { + struct list_head src_csets; + struct list_head dst_csets; + int nr_tasks; + int ssid; + struct list_head *csets; + struct css_set *cur_cset; + struct task_struct *cur_task; +}; + +struct css_task_iter { + struct cgroup_subsys *ss; + unsigned int flags; + struct list_head *cset_pos; + struct list_head *cset_head; + struct list_head *tcset_pos; + struct list_head *tcset_head; + struct list_head *task_pos; + struct list_head *cur_tasks_head; + struct css_set *cur_cset; + struct css_set *cur_dcset; + struct task_struct *cur_task; + struct list_head iters_node; +}; + +struct cgroup_fs_context { + struct kernfs_fs_context kfc; + struct cgroup_root *root; + struct cgroup_namespace *ns; + unsigned int flags; + bool cpuset_clone_children; + bool none; + bool all_ss; + u16 subsys_mask; + char *name; + char *release_agent; +}; + +struct cgrp_cset_link { + struct cgroup *cgrp; + struct css_set *cset; + struct list_head cset_link; + struct list_head cgrp_link; +}; + +struct cgroup_mgctx { + struct list_head preloaded_src_csets; + struct list_head preloaded_dst_csets; + struct cgroup_taskset tset; + u16 ss_mask; +}; + +struct trace_event_raw_cgroup_root { + struct trace_entry ent; + int root; + u16 ss_mask; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_cgroup { + struct trace_entry ent; + int root; + int id; + int level; + u32 __data_loc_path; + char __data[0]; +}; + +struct trace_event_raw_cgroup_migrate { + struct trace_entry ent; + int dst_root; + int dst_id; + int dst_level; + int pid; + u32 __data_loc_dst_path; + u32 __data_loc_comm; + char __data[0]; +}; + +struct trace_event_raw_cgroup_event { + struct trace_entry ent; + int root; + int id; + int level; + u32 __data_loc_path; + int val; + char __data[0]; +}; + +struct trace_event_data_offsets_cgroup_root { + u32 name; +}; + +struct trace_event_data_offsets_cgroup { + u32 path; +}; + +struct trace_event_data_offsets_cgroup_migrate { + u32 dst_path; + u32 comm; +}; + +struct trace_event_data_offsets_cgroup_event { + u32 path; +}; + +typedef void (*btf_trace_cgroup_setup_root)(void *, struct cgroup_root *); + +typedef void (*btf_trace_cgroup_destroy_root)(void *, struct cgroup_root *); + +typedef void (*btf_trace_cgroup_remount)(void *, struct cgroup_root *); + +typedef void (*btf_trace_cgroup_mkdir)(void *, struct cgroup *, const char *); + +typedef void (*btf_trace_cgroup_rmdir)(void *, struct cgroup *, const char *); + +typedef void (*btf_trace_cgroup_release)(void *, struct cgroup *, const char *); + +typedef void (*btf_trace_cgroup_rename)(void *, struct cgroup *, const char *); + +typedef void (*btf_trace_cgroup_freeze)(void *, struct cgroup *, const char *); + +typedef void (*btf_trace_cgroup_unfreeze)(void *, struct cgroup *, const char *); + +typedef void (*btf_trace_cgroup_attach_task)(void *, struct cgroup *, const char *, struct task_struct *, bool); + +typedef void (*btf_trace_cgroup_transfer_tasks)(void *, struct cgroup *, const char *, struct task_struct *, bool); + +typedef void (*btf_trace_cgroup_notify_populated)(void *, struct cgroup *, const char *, int); + +typedef void (*btf_trace_cgroup_notify_frozen)(void *, struct cgroup *, const char *, int); + +enum cgroup2_param { + Opt_nsdelegate = 0, + Opt_memory_localevents = 1, + Opt_memory_recursiveprot = 2, + nr__cgroup2_params = 3, +}; + +struct cgroupstats { + __u64 nr_sleeping; + __u64 nr_running; + __u64 nr_stopped; + __u64 nr_uninterruptible; + __u64 nr_io_wait; +}; + +enum cgroup_filetype { + CGROUP_FILE_PROCS = 0, + CGROUP_FILE_TASKS = 1, +}; + +struct cgroup_pidlist { + struct { + enum cgroup_filetype type; + struct pid_namespace *ns; + } key; + pid_t *list; + int length; + struct list_head links; + struct cgroup *owner; + struct delayed_work destroy_dwork; +}; + +enum cgroup1_param { + Opt_all = 0, + Opt_clone_children = 1, + Opt_cpuset_v2_mode = 2, + Opt_name = 3, + Opt_none = 4, + Opt_noprefix = 5, + Opt_release_agent = 6, + Opt_xattr = 7, +}; + +enum freezer_state_flags { + CGROUP_FREEZER_ONLINE = 1, + CGROUP_FREEZING_SELF = 2, + CGROUP_FREEZING_PARENT = 4, + CGROUP_FROZEN = 8, + CGROUP_FREEZING = 6, +}; + +struct freezer { + struct cgroup_subsys_state css; + unsigned int state; +}; + +struct root_domain___2; + +struct fmeter { + int cnt; + int val; + time64_t time; + spinlock_t lock; +}; + +struct cpuset { + struct cgroup_subsys_state css; + long unsigned int flags; + cpumask_var_t cpus_allowed; + nodemask_t mems_allowed; + cpumask_var_t effective_cpus; + nodemask_t effective_mems; + cpumask_var_t subparts_cpus; + nodemask_t old_mems_allowed; + struct fmeter fmeter; + int attach_in_progress; + int pn; + int relax_domain_level; + int nr_subparts_cpus; + int partition_root_state; + int use_parent_ecpus; + int child_ecpus_count; +}; + +struct tmpmasks { + cpumask_var_t addmask; + cpumask_var_t delmask; + cpumask_var_t new_cpus; +}; + +typedef enum { + CS_ONLINE = 0, + CS_CPU_EXCLUSIVE = 1, + CS_MEM_EXCLUSIVE = 2, + CS_MEM_HARDWALL = 3, + CS_MEMORY_MIGRATE = 4, + CS_SCHED_LOAD_BALANCE = 5, + CS_SPREAD_PAGE = 6, + CS_SPREAD_SLAB = 7, +} cpuset_flagbits_t; + +enum subparts_cmd { + partcmd_enable = 0, + partcmd_disable = 1, + partcmd_update = 2, +}; + +struct cpuset_migrate_mm_work { + struct work_struct work; + struct mm_struct *mm; + nodemask_t from; + nodemask_t to; +}; + +typedef enum { + FILE_MEMORY_MIGRATE = 0, + FILE_CPULIST = 1, + FILE_MEMLIST = 2, + FILE_EFFECTIVE_CPULIST = 3, + FILE_EFFECTIVE_MEMLIST = 4, + FILE_SUBPARTS_CPULIST = 5, + FILE_CPU_EXCLUSIVE = 6, + FILE_MEM_EXCLUSIVE = 7, + FILE_MEM_HARDWALL = 8, + FILE_SCHED_LOAD_BALANCE = 9, + FILE_PARTITION_ROOT = 10, + FILE_SCHED_RELAX_DOMAIN_LEVEL = 11, + FILE_MEMORY_PRESSURE_ENABLED = 12, + FILE_MEMORY_PRESSURE = 13, + FILE_SPREAD_PAGE = 14, + FILE_SPREAD_SLAB = 15, +} cpuset_filetype_t; + +struct kernel_pkey_query { + __u32 supported_ops; + __u32 key_size; + __u16 max_data_size; + __u16 max_sig_size; + __u16 max_enc_size; + __u16 max_dec_size; +}; + +enum kernel_pkey_operation { + kernel_pkey_encrypt = 0, + kernel_pkey_decrypt = 1, + kernel_pkey_sign = 2, + kernel_pkey_verify = 3, +}; + +struct kernel_pkey_params { + struct key *key; + const char *encoding; + const char *hash_algo; + char *info; + __u32 in_len; + union { + __u32 out_len; + __u32 in2_len; + }; + enum kernel_pkey_operation op: 8; +}; + +struct key_preparsed_payload { + char *description; + union key_payload payload; + const void *data; + size_t datalen; + size_t quotalen; + time64_t expiry; +}; + +struct key_match_data { + bool (*cmp)(const struct key *, const struct key_match_data *); + const void *raw_data; + void *preparsed; + unsigned int lookup_type; +}; + +struct idmap_key { + bool map_up; + u32 id; + u32 count; +}; + +struct cpu_stop_done { + atomic_t nr_todo; + int ret; + struct completion completion; +}; + +struct cpu_stopper { + struct task_struct *thread; + raw_spinlock_t lock; + bool enabled; + struct list_head works; + struct cpu_stop_work stop_work; +}; + +enum multi_stop_state { + MULTI_STOP_NONE = 0, + MULTI_STOP_PREPARE = 1, + MULTI_STOP_DISABLE_IRQ = 2, + MULTI_STOP_RUN = 3, + MULTI_STOP_EXIT = 4, +}; + +struct multi_stop_data { + cpu_stop_fn_t fn; + void *data; + unsigned int num_threads; + const struct cpumask *active_cpus; + enum multi_stop_state state; + atomic_t thread_ack; +}; + +typedef int __kernel_mqd_t; + +typedef __kernel_mqd_t mqd_t; + +enum audit_state { + AUDIT_DISABLED = 0, + AUDIT_BUILD_CONTEXT = 1, + AUDIT_RECORD_CONTEXT = 2, +}; + +struct audit_cap_data { + kernel_cap_t permitted; + kernel_cap_t inheritable; + union { + unsigned int fE; + kernel_cap_t effective; + }; + kernel_cap_t ambient; + kuid_t rootid; +}; + +struct audit_names { + struct list_head list; + struct filename *name; + int name_len; + bool hidden; + long unsigned int ino; + dev_t dev; + umode_t mode; + kuid_t uid; + kgid_t gid; + dev_t rdev; + u32 osid; + struct audit_cap_data fcap; + unsigned int fcap_ver; + unsigned char type; + bool should_free; +}; + +struct mq_attr { + __kernel_long_t mq_flags; + __kernel_long_t mq_maxmsg; + __kernel_long_t mq_msgsize; + __kernel_long_t mq_curmsgs; + __kernel_long_t __reserved[4]; +}; + +struct audit_proctitle { + int len; + char *value; +}; + +struct audit_aux_data; + +struct __kernel_sockaddr_storage; + +struct audit_tree_refs; + +struct audit_context { + int dummy; + int in_syscall; + enum audit_state state; + enum audit_state current_state; + unsigned int serial; + int major; + struct timespec64 ctime; + long unsigned int argv[4]; + long int return_code; + u64 prio; + int return_valid; + struct audit_names preallocated_names[5]; + int name_count; + struct list_head names_list; + char *filterkey; + struct path pwd; + struct audit_aux_data *aux; + struct audit_aux_data *aux_pids; + struct __kernel_sockaddr_storage *sockaddr; + size_t sockaddr_len; + pid_t pid; + pid_t ppid; + kuid_t uid; + kuid_t euid; + kuid_t suid; + kuid_t fsuid; + kgid_t gid; + kgid_t egid; + kgid_t sgid; + kgid_t fsgid; + long unsigned int personality; + int arch; + pid_t target_pid; + kuid_t target_auid; + kuid_t target_uid; + unsigned int target_sessionid; + u32 target_sid; + char target_comm[16]; + struct audit_tree_refs *trees; + struct audit_tree_refs *first_trees; + struct list_head killed_trees; + int tree_count; + int type; + union { + struct { + int nargs; + long int args[6]; + } socketcall; + struct { + kuid_t uid; + kgid_t gid; + umode_t mode; + u32 osid; + int has_perm; + uid_t perm_uid; + gid_t perm_gid; + umode_t perm_mode; + long unsigned int qbytes; + } ipc; + struct { + mqd_t mqdes; + struct mq_attr mqstat; + } mq_getsetattr; + struct { + mqd_t mqdes; + int sigev_signo; + } mq_notify; + struct { + mqd_t mqdes; + size_t msg_len; + unsigned int msg_prio; + struct timespec64 abs_timeout; + } mq_sendrecv; + struct { + int oflag; + umode_t mode; + struct mq_attr attr; + } mq_open; + struct { + pid_t pid; + struct audit_cap_data cap; + } capset; + struct { + int fd; + int flags; + } mmap; + struct { + int argc; + } execve; + struct { + char *name; + } module; + }; + int fds[2]; + struct audit_proctitle proctitle; +}; + +struct __kernel_sockaddr_storage { + union { + struct { + __kernel_sa_family_t ss_family; + char __data[126]; + }; + void *__align; + }; +}; + +enum audit_nlgrps { + AUDIT_NLGRP_NONE = 0, + AUDIT_NLGRP_READLOG = 1, + __AUDIT_NLGRP_MAX = 2, +}; + +struct audit_status { + __u32 mask; + __u32 enabled; + __u32 failure; + __u32 pid; + __u32 rate_limit; + __u32 backlog_limit; + __u32 lost; + __u32 backlog; + union { + __u32 version; + __u32 feature_bitmap; + }; + __u32 backlog_wait_time; + __u32 backlog_wait_time_actual; +}; + +struct audit_features { + __u32 vers; + __u32 mask; + __u32 features; + __u32 lock; +}; + +struct audit_tty_status { + __u32 enabled; + __u32 log_passwd; +}; + +struct audit_sig_info { + uid_t uid; + pid_t pid; + char ctx[0]; +}; + +struct net_generic { + union { + struct { + unsigned int len; + struct callback_head rcu; + } s; + void *ptr[0]; + }; +}; + +struct pernet_operations { + struct list_head list; + int (*init)(struct net *); + void (*pre_exit)(struct net *); + void (*exit)(struct net *); + void (*exit_batch)(struct list_head *); + unsigned int *id; + size_t size; +}; + +struct scm_creds { + u32 pid; + kuid_t uid; + kgid_t gid; +}; + +struct netlink_skb_parms { + struct scm_creds creds; + __u32 portid; + __u32 dst_group; + __u32 flags; + struct sock *sk; + bool nsid_is_set; + int nsid; +}; + +struct netlink_kernel_cfg { + unsigned int groups; + unsigned int flags; + void (*input)(struct sk_buff *); + struct mutex *cb_mutex; + int (*bind)(struct net *, int); + void (*unbind)(struct net *, int); + bool (*compare)(struct net *, struct sock *); +}; + +struct audit_netlink_list { + __u32 portid; + struct net *net; + struct sk_buff_head q; +}; + +struct audit_net { + struct sock *sk; +}; + +struct auditd_connection { + struct pid *pid; + u32 portid; + struct net *net; + struct callback_head rcu; +}; + +struct audit_ctl_mutex { + struct mutex lock; + void *owner; +}; + +struct audit_buffer { + struct sk_buff *skb; + struct audit_context *ctx; + gfp_t gfp_mask; +}; + +struct audit_reply { + __u32 portid; + struct net *net; + struct sk_buff *skb; +}; + +enum { + Audit_equal = 0, + Audit_not_equal = 1, + Audit_bitmask = 2, + Audit_bittest = 3, + Audit_lt = 4, + Audit_gt = 5, + Audit_le = 6, + Audit_ge = 7, + Audit_bad = 8, +}; + +struct audit_rule_data { + __u32 flags; + __u32 action; + __u32 field_count; + __u32 mask[64]; + __u32 fields[64]; + __u32 values[64]; + __u32 fieldflags[64]; + __u32 buflen; + char buf[0]; +}; + +struct audit_field; + +struct audit_watch; + +struct audit_tree; + +struct audit_fsnotify_mark; + +struct audit_krule { + u32 pflags; + u32 flags; + u32 listnr; + u32 action; + u32 mask[64]; + u32 buflen; + u32 field_count; + char *filterkey; + struct audit_field *fields; + struct audit_field *arch_f; + struct audit_field *inode_f; + struct audit_watch *watch; + struct audit_tree *tree; + struct audit_fsnotify_mark *exe; + struct list_head rlist; + struct list_head list; + u64 prio; +}; + +struct audit_field { + u32 type; + union { + u32 val; + kuid_t uid; + kgid_t gid; + struct { + char *lsm_str; + void *lsm_rule; + }; + }; + u32 op; +}; + +struct audit_entry { + struct list_head list; + struct callback_head rcu; + struct audit_krule rule; +}; + +struct audit_buffer___2; + +typedef int __kernel_key_t; + +typedef __kernel_key_t key_t; + +struct cpu_vfs_cap_data { + __u32 magic_etc; + kernel_cap_t permitted; + kernel_cap_t inheritable; + kuid_t rootid; +}; + +struct kern_ipc_perm { + spinlock_t lock; + bool deleted; + int id; + key_t key; + kuid_t uid; + kgid_t gid; + kuid_t cuid; + kgid_t cgid; + umode_t mode; + long unsigned int seq; + void *security; + struct rhash_head khtnode; + struct callback_head rcu; + refcount_t refcount; + long: 32; + long: 64; + long: 64; + long: 64; +}; + +typedef struct fsnotify_mark_connector *fsnotify_connp_t; + +struct fsnotify_mark_connector { + spinlock_t lock; + short unsigned int type; + short unsigned int flags; + __kernel_fsid_t fsid; + union { + fsnotify_connp_t *obj; + struct fsnotify_mark_connector *destroy_next; + }; + struct hlist_head list; +}; + +enum audit_nfcfgop { + AUDIT_XT_OP_REGISTER = 0, + AUDIT_XT_OP_REPLACE = 1, + AUDIT_XT_OP_UNREGISTER = 2, + AUDIT_NFT_OP_TABLE_REGISTER = 3, + AUDIT_NFT_OP_TABLE_UNREGISTER = 4, + AUDIT_NFT_OP_CHAIN_REGISTER = 5, + AUDIT_NFT_OP_CHAIN_UNREGISTER = 6, + AUDIT_NFT_OP_RULE_REGISTER = 7, + AUDIT_NFT_OP_RULE_UNREGISTER = 8, + AUDIT_NFT_OP_SET_REGISTER = 9, + AUDIT_NFT_OP_SET_UNREGISTER = 10, + AUDIT_NFT_OP_SETELEM_REGISTER = 11, + AUDIT_NFT_OP_SETELEM_UNREGISTER = 12, + AUDIT_NFT_OP_GEN_REGISTER = 13, + AUDIT_NFT_OP_OBJ_REGISTER = 14, + AUDIT_NFT_OP_OBJ_UNREGISTER = 15, + AUDIT_NFT_OP_OBJ_RESET = 16, + AUDIT_NFT_OP_FLOWTABLE_REGISTER = 17, + AUDIT_NFT_OP_FLOWTABLE_UNREGISTER = 18, + AUDIT_NFT_OP_INVALID = 19, +}; + +enum fsnotify_obj_type { + FSNOTIFY_OBJ_TYPE_INODE = 0, + FSNOTIFY_OBJ_TYPE_CHILD = 1, + FSNOTIFY_OBJ_TYPE_VFSMOUNT = 2, + FSNOTIFY_OBJ_TYPE_SB = 3, + FSNOTIFY_OBJ_TYPE_COUNT = 4, + FSNOTIFY_OBJ_TYPE_DETACHED = 4, +}; + +struct audit_aux_data { + struct audit_aux_data *next; + int type; +}; + +struct audit_chunk; + +struct audit_tree_refs { + struct audit_tree_refs *next; + struct audit_chunk *c[31]; +}; + +struct audit_aux_data_pids { + struct audit_aux_data d; + pid_t target_pid[16]; + kuid_t target_auid[16]; + kuid_t target_uid[16]; + unsigned int target_sessionid[16]; + u32 target_sid[16]; + char target_comm[256]; + int pid_count; +}; + +struct audit_aux_data_bprm_fcaps { + struct audit_aux_data d; + struct audit_cap_data fcap; + unsigned int fcap_ver; + struct audit_cap_data old_pcap; + struct audit_cap_data new_pcap; +}; + +struct audit_nfcfgop_tab { + enum audit_nfcfgop op; + const char *s; +}; + +struct audit_parent; + +struct audit_watch { + refcount_t count; + dev_t dev; + char *path; + long unsigned int ino; + struct audit_parent *parent; + struct list_head wlist; + struct list_head rules; +}; + +struct fsnotify_group; + +struct fsnotify_iter_info; + +struct fsnotify_mark; + +struct fsnotify_event; + +struct fsnotify_ops { + int (*handle_event)(struct fsnotify_group *, u32, const void *, int, struct inode *, const struct qstr *, u32, struct fsnotify_iter_info *); + int (*handle_inode_event)(struct fsnotify_mark *, u32, struct inode *, struct inode *, const struct qstr *); + void (*free_group_priv)(struct fsnotify_group *); + void (*freeing_mark)(struct fsnotify_mark *, struct fsnotify_group *); + void (*free_event)(struct fsnotify_event *); + void (*free_mark)(struct fsnotify_mark *); +}; + +struct inotify_group_private_data { + spinlock_t idr_lock; + struct idr idr; + struct ucounts *ucounts; +}; + +struct fsnotify_group { + const struct fsnotify_ops *ops; + refcount_t refcnt; + spinlock_t notification_lock; + struct list_head notification_list; + wait_queue_head_t notification_waitq; + unsigned int q_len; + unsigned int max_events; + unsigned int priority; + bool shutdown; + struct mutex mark_mutex; + atomic_t num_marks; + atomic_t user_waits; + struct list_head marks_list; + struct fasync_struct *fsn_fa; + struct fsnotify_event *overflow_event; + struct mem_cgroup *memcg; + union { + void *private; + struct inotify_group_private_data inotify_data; + }; +}; + +struct fsnotify_iter_info { + struct fsnotify_mark *marks[4]; + unsigned int report_mask; + int srcu_idx; +}; + +struct fsnotify_mark { + __u32 mask; + refcount_t refcnt; + struct fsnotify_group *group; + struct list_head g_list; + spinlock_t lock; + struct hlist_node obj_list; + struct fsnotify_mark_connector *connector; + __u32 ignored_mask; + unsigned int flags; +}; + +struct fsnotify_event { + struct list_head list; + long unsigned int objectid; +}; + +struct audit_parent { + struct list_head watches; + struct fsnotify_mark mark; +}; + +struct audit_fsnotify_mark { + dev_t dev; + long unsigned int ino; + char *path; + struct fsnotify_mark mark; + struct audit_krule *rule; +}; + +struct audit_chunk___2; + +struct audit_tree { + refcount_t count; + int goner; + struct audit_chunk___2 *root; + struct list_head chunks; + struct list_head rules; + struct list_head list; + struct list_head same_root; + struct callback_head head; + char pathname[0]; +}; + +struct node { + struct list_head list; + struct audit_tree *owner; + unsigned int index; +}; + +struct audit_chunk___2 { + struct list_head hash; + long unsigned int key; + struct fsnotify_mark *mark; + struct list_head trees; + int count; + atomic_long_t refs; + struct callback_head head; + struct node owners[0]; +}; + +struct audit_tree_mark { + struct fsnotify_mark mark; + struct audit_chunk___2 *chunk; +}; + +enum { + HASH_SIZE = 128, +}; + +struct kprobe_blacklist_entry { + struct list_head list; + long unsigned int start_addr; + long unsigned int end_addr; +}; + +enum perf_record_ksymbol_type { + PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0, + PERF_RECORD_KSYMBOL_TYPE_BPF = 1, + PERF_RECORD_KSYMBOL_TYPE_OOL = 2, + PERF_RECORD_KSYMBOL_TYPE_MAX = 3, +}; + +struct kprobe_insn_page { + struct list_head list; + kprobe_opcode_t *insns; + struct kprobe_insn_cache *cache; + int nused; + int ngarbage; + char slot_used[0]; +}; + +enum kprobe_slot_state { + SLOT_CLEAN = 0, + SLOT_DIRTY = 1, + SLOT_USED = 2, +}; + +struct fault_attr { + long unsigned int probability; + long unsigned int interval; + atomic_t times; + atomic_t space; + long unsigned int verbose; + bool task_filter; + long unsigned int stacktrace_depth; + long unsigned int require_start; + long unsigned int require_end; + long unsigned int reject_start; + long unsigned int reject_end; + long unsigned int count; + struct ratelimit_state ratelimit_state; + struct dentry *dname; +}; + +struct fei_attr { + struct list_head list; + struct kprobe kp; + long unsigned int retval; +}; + +struct seccomp_data { + int nr; + __u32 arch; + __u64 instruction_pointer; + __u64 args[6]; +}; + +struct seccomp_notif_sizes { + __u16 seccomp_notif; + __u16 seccomp_notif_resp; + __u16 seccomp_data; +}; + +struct seccomp_notif { + __u64 id; + __u32 pid; + __u32 flags; + struct seccomp_data data; +}; + +struct seccomp_notif_resp { + __u64 id; + __s64 val; + __s32 error; + __u32 flags; +}; + +struct seccomp_notif_addfd { + __u64 id; + __u32 flags; + __u32 srcfd; + __u32 newfd; + __u32 newfd_flags; +}; + +struct notification; + +struct seccomp_filter { + refcount_t refs; + refcount_t users; + bool log; + struct seccomp_filter *prev; + struct bpf_prog *prog; + struct notification *notif; + struct mutex notify_lock; + wait_queue_head_t wqh; +}; + +struct ctl_path { + const char *procname; +}; + +struct sock_fprog { + short unsigned int len; + struct sock_filter *filter; +}; + +struct compat_sock_fprog { + u16 len; + compat_uptr_t filter; +}; + +enum notify_state { + SECCOMP_NOTIFY_INIT = 0, + SECCOMP_NOTIFY_SENT = 1, + SECCOMP_NOTIFY_REPLIED = 2, +}; + +struct seccomp_knotif { + struct task_struct *task; + u64 id; + const struct seccomp_data *data; + enum notify_state state; + int error; + long int val; + u32 flags; + struct completion ready; + struct list_head list; + struct list_head addfd; +}; + +struct seccomp_kaddfd { + struct file *file; + int fd; + unsigned int flags; + int ret; + struct completion completion; + struct list_head list; +}; + +struct notification { + struct semaphore request; + u64 next_id; + struct list_head notifications; +}; + +struct seccomp_log_name { + u32 log; + const char *name; +}; + +struct rchan; + +struct rchan_buf { + void *start; + void *data; + size_t offset; + size_t subbufs_produced; + size_t subbufs_consumed; + struct rchan *chan; + wait_queue_head_t read_wait; + struct irq_work wakeup_work; + struct dentry *dentry; + struct kref kref; + struct page **page_array; + unsigned int page_count; + unsigned int finalized; + size_t *padding; + size_t prev_padding; + size_t bytes_consumed; + size_t early_bytes; + unsigned int cpu; + long: 32; + long: 64; +}; + +struct rchan_callbacks; + +struct rchan { + u32 version; + size_t subbuf_size; + size_t n_subbufs; + size_t alloc_size; + struct rchan_callbacks *cb; + struct kref kref; + void *private_data; + size_t last_toobig; + struct rchan_buf **buf; + int is_global; + struct list_head list; + struct dentry *parent; + int has_base_filename; + char base_filename[255]; +}; + +struct rchan_callbacks { + int (*subbuf_start)(struct rchan_buf *, void *, void *, size_t); + void (*buf_mapped)(struct rchan_buf *, struct file *); + void (*buf_unmapped)(struct rchan_buf *, struct file *); + struct dentry * (*create_buf_file)(const char *, struct dentry *, umode_t, struct rchan_buf *, int *); + int (*remove_buf_file)(struct dentry *); +}; + +struct partial_page { + unsigned int offset; + unsigned int len; + long unsigned int private; +}; + +struct splice_pipe_desc { + struct page **pages; + struct partial_page *partial; + int nr_pages; + unsigned int nr_pages_max; + const struct pipe_buf_operations *ops; + void (*spd_release)(struct splice_pipe_desc *, unsigned int); +}; + +struct rchan_percpu_buf_dispatcher { + struct rchan_buf *buf; + struct dentry *dentry; +}; + +enum { + TASKSTATS_TYPE_UNSPEC = 0, + TASKSTATS_TYPE_PID = 1, + TASKSTATS_TYPE_TGID = 2, + TASKSTATS_TYPE_STATS = 3, + TASKSTATS_TYPE_AGGR_PID = 4, + TASKSTATS_TYPE_AGGR_TGID = 5, + TASKSTATS_TYPE_NULL = 6, + __TASKSTATS_TYPE_MAX = 7, +}; + +enum { + TASKSTATS_CMD_ATTR_UNSPEC = 0, + TASKSTATS_CMD_ATTR_PID = 1, + TASKSTATS_CMD_ATTR_TGID = 2, + TASKSTATS_CMD_ATTR_REGISTER_CPUMASK = 3, + TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK = 4, + __TASKSTATS_CMD_ATTR_MAX = 5, +}; + +enum { + CGROUPSTATS_CMD_UNSPEC = 3, + CGROUPSTATS_CMD_GET = 4, + CGROUPSTATS_CMD_NEW = 5, + __CGROUPSTATS_CMD_MAX = 6, +}; + +enum { + CGROUPSTATS_TYPE_UNSPEC = 0, + CGROUPSTATS_TYPE_CGROUP_STATS = 1, + __CGROUPSTATS_TYPE_MAX = 2, +}; + +enum { + CGROUPSTATS_CMD_ATTR_UNSPEC = 0, + CGROUPSTATS_CMD_ATTR_FD = 1, + __CGROUPSTATS_CMD_ATTR_MAX = 2, +}; + +struct genlmsghdr { + __u8 cmd; + __u8 version; + __u16 reserved; +}; + +enum { + NLA_UNSPEC = 0, + NLA_U8 = 1, + NLA_U16 = 2, + NLA_U32 = 3, + NLA_U64 = 4, + NLA_STRING = 5, + NLA_FLAG = 6, + NLA_MSECS = 7, + NLA_NESTED = 8, + NLA_NESTED_ARRAY = 9, + NLA_NUL_STRING = 10, + NLA_BINARY = 11, + NLA_S8 = 12, + NLA_S16 = 13, + NLA_S32 = 14, + NLA_S64 = 15, + NLA_BITFIELD32 = 16, + NLA_REJECT = 17, + __NLA_TYPE_MAX = 18, +}; + +struct genl_multicast_group { + char name[16]; +}; + +struct genl_ops; + +struct genl_info; + +struct genl_small_ops; + +struct genl_family { + int id; + unsigned int hdrsize; + char name[16]; + unsigned int version; + unsigned int maxattr; + unsigned int mcgrp_offset; + u8 netnsok: 1; + u8 parallel_ops: 1; + u8 n_ops; + u8 n_small_ops; + u8 n_mcgrps; + const struct nla_policy *policy; + int (*pre_doit)(const struct genl_ops *, struct sk_buff *, struct genl_info *); + void (*post_doit)(const struct genl_ops *, struct sk_buff *, struct genl_info *); + const struct genl_ops *ops; + const struct genl_small_ops *small_ops; + const struct genl_multicast_group *mcgrps; + struct module *module; +}; + +struct genl_ops { + int (*doit)(struct sk_buff *, struct genl_info *); + int (*start)(struct netlink_callback *); + int (*dumpit)(struct sk_buff *, struct netlink_callback *); + int (*done)(struct netlink_callback *); + const struct nla_policy *policy; + unsigned int maxattr; + u8 cmd; + u8 internal_flags; + u8 flags; + u8 validate; +}; + +struct genl_info { + u32 snd_seq; + u32 snd_portid; + struct nlmsghdr *nlhdr; + struct genlmsghdr *genlhdr; + void *userhdr; + struct nlattr **attrs; + possible_net_t _net; + void *user_ptr[2]; + struct netlink_ext_ack *extack; +}; + +struct genl_small_ops { + int (*doit)(struct sk_buff *, struct genl_info *); + int (*dumpit)(struct sk_buff *, struct netlink_callback *); + u8 cmd; + u8 internal_flags; + u8 flags; + u8 validate; +}; + +enum genl_validate_flags { + GENL_DONT_VALIDATE_STRICT = 1, + GENL_DONT_VALIDATE_DUMP = 2, + GENL_DONT_VALIDATE_DUMP_STRICT = 4, +}; + +struct listener { + struct list_head list; + pid_t pid; + char valid; +}; + +struct listener_list { + struct rw_semaphore sem; + struct list_head list; +}; + +enum actions { + REGISTER = 0, + DEREGISTER = 1, + CPU_DONT_CARE = 2, +}; + +struct tp_module { + struct list_head list; + struct module *mod; +}; + +struct tp_probes { + struct callback_head rcu; + struct tracepoint_func probes[0]; +}; + +struct ftrace_hash { + long unsigned int size_bits; + struct hlist_head *buckets; + long unsigned int count; + long unsigned int flags; + struct callback_head rcu; +}; + +struct ftrace_func_entry { + struct hlist_node hlist; + long unsigned int ip; + long unsigned int direct; +}; + +enum ftrace_bug_type { + FTRACE_BUG_UNKNOWN = 0, + FTRACE_BUG_INIT = 1, + FTRACE_BUG_NOP = 2, + FTRACE_BUG_CALL = 3, + FTRACE_BUG_UPDATE = 4, +}; + +enum { + FTRACE_UPDATE_CALLS = 1, + FTRACE_DISABLE_CALLS = 2, + FTRACE_UPDATE_TRACE_FUNC = 4, + FTRACE_START_FUNC_RET = 8, + FTRACE_STOP_FUNC_RET = 16, + FTRACE_MAY_SLEEP = 32, +}; + +enum { + FTRACE_ITER_FILTER = 1, + FTRACE_ITER_NOTRACE = 2, + FTRACE_ITER_PRINTALL = 4, + FTRACE_ITER_DO_PROBES = 8, + FTRACE_ITER_PROBE = 16, + FTRACE_ITER_MOD = 32, + FTRACE_ITER_ENABLED = 64, +}; + +struct prog_entry; + +struct event_filter { + struct prog_entry *prog; + char *filter_string; +}; + +struct trace_array_cpu; + +struct array_buffer { + struct trace_array *tr; + struct trace_buffer *buffer; + struct trace_array_cpu *data; + u64 time_start; + int cpu; +}; + +struct trace_pid_list; + +struct trace_options; + +struct trace_array { + struct list_head list; + char *name; + struct array_buffer array_buffer; + struct trace_pid_list *filtered_pids; + struct trace_pid_list *filtered_no_pids; + arch_spinlock_t max_lock; + int buffer_disabled; + int sys_refcount_enter; + int sys_refcount_exit; + struct trace_event_file *enter_syscall_files[441]; + struct trace_event_file *exit_syscall_files[441]; + int stop_count; + int clock_id; + int nr_topts; + bool clear_trace; + int buffer_percent; + unsigned int n_err_log_entries; + struct tracer *current_trace; + unsigned int trace_flags; + unsigned char trace_flags_index[32]; + unsigned int flags; + raw_spinlock_t start_lock; + struct list_head err_log; + struct dentry *dir; + struct dentry *options; + struct dentry *percpu_dir; + struct dentry *event_dir; + struct trace_options *topts; + struct list_head systems; + struct list_head events; + struct trace_event_file *trace_marker_file; + cpumask_var_t tracing_cpumask; + int ref; + int trace_ref; + struct ftrace_ops *ops; + struct trace_pid_list *function_pids; + struct trace_pid_list *function_no_pids; + struct list_head func_probes; + struct list_head mod_trace; + struct list_head mod_notrace; + int function_enabled; + int time_stamp_abs_ref; + struct list_head hist_vars; +}; + +struct tracer_flags; + +struct tracer { + const char *name; + int (*init)(struct trace_array *); + void (*reset)(struct trace_array *); + void (*start)(struct trace_array *); + void (*stop)(struct trace_array *); + int (*update_thresh)(struct trace_array *); + void (*open)(struct trace_iterator *); + void (*pipe_open)(struct trace_iterator *); + void (*close)(struct trace_iterator *); + void (*pipe_close)(struct trace_iterator *); + ssize_t (*read)(struct trace_iterator *, struct file *, char *, size_t, loff_t *); + ssize_t (*splice_read)(struct trace_iterator *, struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); + void (*print_header)(struct seq_file *); + enum print_line_t (*print_line)(struct trace_iterator *); + int (*set_flag)(struct trace_array *, u32, u32, int); + int (*flag_changed)(struct trace_array *, u32, int); + struct tracer *next; + struct tracer_flags *flags; + int enabled; + bool print_max; + bool allow_instances; + bool noboot; +}; + +struct event_subsystem; + +struct trace_subsystem_dir { + struct list_head list; + struct event_subsystem *subsystem; + struct trace_array *tr; + struct dentry *entry; + int ref_count; + int nr_events; +}; + +struct trace_array_cpu { + atomic_t disabled; + void *buffer_page; + long unsigned int entries; + long unsigned int saved_latency; + long unsigned int critical_start; + long unsigned int critical_end; + long unsigned int critical_sequence; + long unsigned int nice; + long unsigned int policy; + long unsigned int rt_priority; + long unsigned int skipped_entries; + u64 preempt_timestamp; + pid_t pid; + kuid_t uid; + char comm[16]; + int ftrace_ignore_pid; + bool ignore_pid; +}; + +struct trace_option_dentry; + +struct trace_options { + struct tracer *tracer; + struct trace_option_dentry *topts; +}; + +struct tracer_opt; + +struct trace_option_dentry { + struct tracer_opt *opt; + struct tracer_flags *flags; + struct trace_array *tr; + struct dentry *entry; +}; + +struct trace_pid_list { + int pid_max; + long unsigned int *pids; +}; + +enum { + TRACE_PIDS = 1, + TRACE_NO_PIDS = 2, +}; + +enum { + TRACE_ARRAY_FL_GLOBAL = 1, +}; + +struct tracer_opt { + const char *name; + u32 bit; +}; + +struct tracer_flags { + u32 val; + struct tracer_opt *opts; + struct tracer *trace; +}; + +enum { + TRACE_FTRACE_BIT = 0, + TRACE_FTRACE_NMI_BIT = 1, + TRACE_FTRACE_IRQ_BIT = 2, + TRACE_FTRACE_SIRQ_BIT = 3, + TRACE_INTERNAL_BIT = 4, + TRACE_INTERNAL_NMI_BIT = 5, + TRACE_INTERNAL_IRQ_BIT = 6, + TRACE_INTERNAL_SIRQ_BIT = 7, + TRACE_BRANCH_BIT = 8, + TRACE_IRQ_BIT = 9, + TRACE_GRAPH_BIT = 10, + TRACE_GRAPH_DEPTH_START_BIT = 11, + TRACE_GRAPH_DEPTH_END_BIT = 12, + TRACE_GRAPH_NOTRACE_BIT = 13, + TRACE_TRANSITION_BIT = 14, +}; + +struct ftrace_mod_load { + struct list_head list; + char *func; + char *module; + int enable; +}; + +enum { + FTRACE_HASH_FL_MOD = 1, +}; + +struct ftrace_func_command { + struct list_head list; + char *name; + int (*func)(struct trace_array *, struct ftrace_hash *, char *, char *, char *, int); +}; + +struct ftrace_probe_ops { + void (*func)(long unsigned int, long unsigned int, struct trace_array *, struct ftrace_probe_ops *, void *); + int (*init)(struct ftrace_probe_ops *, struct trace_array *, long unsigned int, void *, void **); + void (*free)(struct ftrace_probe_ops *, struct trace_array *, long unsigned int, void *); + int (*print)(struct seq_file *, long unsigned int, struct ftrace_probe_ops *, void *); +}; + +typedef int (*ftrace_mapper_func)(void *); + +struct trace_parser { + bool cont; + char *buffer; + unsigned int idx; + unsigned int size; +}; + +enum trace_iterator_bits { + TRACE_ITER_PRINT_PARENT_BIT = 0, + TRACE_ITER_SYM_OFFSET_BIT = 1, + TRACE_ITER_SYM_ADDR_BIT = 2, + TRACE_ITER_VERBOSE_BIT = 3, + TRACE_ITER_RAW_BIT = 4, + TRACE_ITER_HEX_BIT = 5, + TRACE_ITER_BIN_BIT = 6, + TRACE_ITER_BLOCK_BIT = 7, + TRACE_ITER_PRINTK_BIT = 8, + TRACE_ITER_ANNOTATE_BIT = 9, + TRACE_ITER_USERSTACKTRACE_BIT = 10, + TRACE_ITER_SYM_USEROBJ_BIT = 11, + TRACE_ITER_PRINTK_MSGONLY_BIT = 12, + TRACE_ITER_CONTEXT_INFO_BIT = 13, + TRACE_ITER_LATENCY_FMT_BIT = 14, + TRACE_ITER_RECORD_CMD_BIT = 15, + TRACE_ITER_RECORD_TGID_BIT = 16, + TRACE_ITER_OVERWRITE_BIT = 17, + TRACE_ITER_STOP_ON_FREE_BIT = 18, + TRACE_ITER_IRQ_INFO_BIT = 19, + TRACE_ITER_MARKERS_BIT = 20, + TRACE_ITER_EVENT_FORK_BIT = 21, + TRACE_ITER_PAUSE_ON_TRACE_BIT = 22, + TRACE_ITER_FUNCTION_BIT = 23, + TRACE_ITER_FUNC_FORK_BIT = 24, + TRACE_ITER_DISPLAY_GRAPH_BIT = 25, + TRACE_ITER_STACKTRACE_BIT = 26, + TRACE_ITER_LAST_BIT = 27, +}; + +struct event_subsystem { + struct list_head list; + const char *name; + struct event_filter *filter; + int ref_count; +}; + +enum regex_type { + MATCH_FULL = 0, + MATCH_FRONT_ONLY = 1, + MATCH_MIDDLE_ONLY = 2, + MATCH_END_ONLY = 3, + MATCH_GLOB = 4, + MATCH_INDEX = 5, +}; + +enum { + FTRACE_MODIFY_ENABLE_FL = 1, + FTRACE_MODIFY_MAY_SLEEP_FL = 2, +}; + +struct ftrace_func_probe { + struct ftrace_probe_ops *probe_ops; + struct ftrace_ops ops; + struct trace_array *tr; + struct list_head list; + void *data; + int ref; +}; + +struct ftrace_page { + struct ftrace_page *next; + struct dyn_ftrace *records; + int index; + int size; +}; + +struct ftrace_rec_iter___2 { + struct ftrace_page *pg; + int index; +}; + +struct ftrace_iterator { + loff_t pos; + loff_t func_pos; + loff_t mod_pos; + struct ftrace_page *pg; + struct dyn_ftrace *func; + struct ftrace_func_probe *probe; + struct ftrace_func_entry *probe_entry; + struct trace_parser parser; + struct ftrace_hash *hash; + struct ftrace_ops *ops; + struct trace_array *tr; + struct list_head *mod_list; + int pidx; + int idx; + unsigned int flags; +}; + +struct ftrace_glob { + char *search; + unsigned int len; + int type; +}; + +struct ftrace_func_map { + struct ftrace_func_entry entry; + void *data; +}; + +struct ftrace_func_mapper { + struct ftrace_hash hash; +}; + +struct ftrace_direct_func { + struct list_head next; + long unsigned int addr; + int count; +}; + +enum graph_filter_type { + GRAPH_FILTER_NOTRACE = 0, + GRAPH_FILTER_FUNCTION = 1, +}; + +struct ftrace_graph_data { + struct ftrace_hash *hash; + struct ftrace_func_entry *entry; + int idx; + enum graph_filter_type type; + struct ftrace_hash *new_hash; + const struct seq_operations *seq_ops; + struct trace_parser parser; +}; + +struct ftrace_mod_func { + struct list_head list; + char *name; + long unsigned int ip; + unsigned int size; +}; + +struct ftrace_mod_map { + struct callback_head rcu; + struct list_head list; + struct module *mod; + long unsigned int start_addr; + long unsigned int end_addr; + struct list_head funcs; + unsigned int num_funcs; +}; + +struct ftrace_init_func { + struct list_head list; + long unsigned int ip; +}; + +enum ring_buffer_type { + RINGBUF_TYPE_DATA_TYPE_LEN_MAX = 28, + RINGBUF_TYPE_PADDING = 29, + RINGBUF_TYPE_TIME_EXTEND = 30, + RINGBUF_TYPE_TIME_STAMP = 31, +}; + +enum ring_buffer_flags { + RB_FL_OVERWRITE = 1, +}; + +struct ring_buffer_per_cpu; + +struct buffer_page; + +struct ring_buffer_iter { + struct ring_buffer_per_cpu *cpu_buffer; + long unsigned int head; + long unsigned int next_event; + struct buffer_page *head_page; + struct buffer_page *cache_reader_page; + long unsigned int cache_read; + u64 read_stamp; + u64 page_stamp; + struct ring_buffer_event *event; + int missed_events; +}; + +struct rb_irq_work { + struct irq_work work; + wait_queue_head_t waiters; + wait_queue_head_t full_waiters; + bool waiters_pending; + bool full_waiters_pending; + bool wakeup_full; +}; + +struct trace_buffer___2 { + unsigned int flags; + int cpus; + atomic_t record_disabled; + cpumask_var_t cpumask; + struct lock_class_key *reader_lock_key; + struct mutex mutex; + struct ring_buffer_per_cpu **buffers; + struct hlist_node node; + u64 (*clock)(); + struct rb_irq_work irq_work; + bool time_stamp_abs; +}; + +enum { + RB_LEN_TIME_EXTEND = 8, + RB_LEN_TIME_STAMP = 8, +}; + +struct buffer_data_page { + u64 time_stamp; + local_t commit; + unsigned char data[0]; +}; + +struct buffer_page { + struct list_head list; + local_t write; + unsigned int read; + local_t entries; + long unsigned int real_end; + struct buffer_data_page *page; +}; + +struct rb_event_info { + u64 ts; + u64 delta; + u64 before; + u64 after; + long unsigned int length; + struct buffer_page *tail_page; + int add_timestamp; +}; + +enum { + RB_ADD_STAMP_NONE = 0, + RB_ADD_STAMP_EXTEND = 2, + RB_ADD_STAMP_ABSOLUTE = 4, + RB_ADD_STAMP_FORCE = 8, +}; + +enum { + RB_CTX_TRANSITION = 0, + RB_CTX_NMI = 1, + RB_CTX_IRQ = 2, + RB_CTX_SOFTIRQ = 3, + RB_CTX_NORMAL = 4, + RB_CTX_MAX = 5, +}; + +struct rb_time_struct { + local64_t time; +}; + +typedef struct rb_time_struct rb_time_t; + +struct ring_buffer_per_cpu { + int cpu; + atomic_t record_disabled; + atomic_t resize_disabled; + struct trace_buffer___2 *buffer; + raw_spinlock_t reader_lock; + arch_spinlock_t lock; + struct lock_class_key lock_key; + struct buffer_data_page *free_page; + long unsigned int nr_pages; + unsigned int current_context; + struct list_head *pages; + struct buffer_page *head_page; + struct buffer_page *tail_page; + struct buffer_page *commit_page; + struct buffer_page *reader_page; + long unsigned int lost_events; + long unsigned int last_overrun; + long unsigned int nest; + local_t entries_bytes; + local_t entries; + local_t overrun; + local_t commit_overrun; + local_t dropped_events; + local_t committing; + local_t commits; + local_t pages_touched; + local_t pages_read; + long int last_pages_touch; + size_t shortest_full; + long unsigned int read; + long unsigned int read_bytes; + rb_time_t write_stamp; + rb_time_t before_stamp; + u64 read_stamp; + long int nr_pages_to_update; + struct list_head new_pages; + struct work_struct update_pages_work; + struct completion update_done; + struct rb_irq_work irq_work; +}; + +struct trace_export { + struct trace_export *next; + void (*write)(struct trace_export *, const void *, unsigned int); + int flags; +}; + +enum trace_iter_flags { + TRACE_FILE_LAT_FMT = 1, + TRACE_FILE_ANNOTATE = 2, + TRACE_FILE_TIME_IN_NS = 4, +}; + +enum event_trigger_type { + ETT_NONE = 0, + ETT_TRACE_ONOFF = 1, + ETT_SNAPSHOT = 2, + ETT_STACKTRACE = 4, + ETT_EVENT_ENABLE = 8, + ETT_EVENT_HIST = 16, + ETT_HIST_ENABLE = 32, +}; + +enum trace_type { + __TRACE_FIRST_TYPE = 0, + TRACE_FN = 1, + TRACE_CTX = 2, + TRACE_WAKE = 3, + TRACE_STACK = 4, + TRACE_PRINT = 5, + TRACE_BPRINT = 6, + TRACE_MMIO_RW = 7, + TRACE_MMIO_MAP = 8, + TRACE_BRANCH = 9, + TRACE_GRAPH_RET = 10, + TRACE_GRAPH_ENT = 11, + TRACE_USER_STACK = 12, + TRACE_BLK = 13, + TRACE_BPUTS = 14, + TRACE_HWLAT = 15, + TRACE_RAW_DATA = 16, + __TRACE_LAST_TYPE = 17, +}; + +struct ftrace_entry { + struct trace_entry ent; + long unsigned int ip; + long unsigned int parent_ip; +}; + +struct stack_entry { + struct trace_entry ent; + int size; + long unsigned int caller[8]; +}; + +struct userstack_entry { + struct trace_entry ent; + unsigned int tgid; + long unsigned int caller[8]; +}; + +struct bprint_entry { + struct trace_entry ent; + long unsigned int ip; + const char *fmt; + u32 buf[0]; +}; + +struct print_entry { + struct trace_entry ent; + long unsigned int ip; + char buf[0]; +}; + +struct raw_data_entry { + struct trace_entry ent; + unsigned int id; + char buf[0]; +}; + +struct bputs_entry { + struct trace_entry ent; + long unsigned int ip; + const char *str; +}; + +enum trace_flag_type { + TRACE_FLAG_IRQS_OFF = 1, + TRACE_FLAG_IRQS_NOSUPPORT = 2, + TRACE_FLAG_NEED_RESCHED = 4, + TRACE_FLAG_HARDIRQ = 8, + TRACE_FLAG_SOFTIRQ = 16, + TRACE_FLAG_PREEMPT_RESCHED = 32, + TRACE_FLAG_NMI = 64, +}; + +typedef bool (*cond_update_fn_t)(struct trace_array *, void *); + +enum trace_iterator_flags { + TRACE_ITER_PRINT_PARENT = 1, + TRACE_ITER_SYM_OFFSET = 2, + TRACE_ITER_SYM_ADDR = 4, + TRACE_ITER_VERBOSE = 8, + TRACE_ITER_RAW = 16, + TRACE_ITER_HEX = 32, + TRACE_ITER_BIN = 64, + TRACE_ITER_BLOCK = 128, + TRACE_ITER_PRINTK = 256, + TRACE_ITER_ANNOTATE = 512, + TRACE_ITER_USERSTACKTRACE = 1024, + TRACE_ITER_SYM_USEROBJ = 2048, + TRACE_ITER_PRINTK_MSGONLY = 4096, + TRACE_ITER_CONTEXT_INFO = 8192, + TRACE_ITER_LATENCY_FMT = 16384, + TRACE_ITER_RECORD_CMD = 32768, + TRACE_ITER_RECORD_TGID = 65536, + TRACE_ITER_OVERWRITE = 131072, + TRACE_ITER_STOP_ON_FREE = 262144, + TRACE_ITER_IRQ_INFO = 524288, + TRACE_ITER_MARKERS = 1048576, + TRACE_ITER_EVENT_FORK = 2097152, + TRACE_ITER_PAUSE_ON_TRACE = 4194304, + TRACE_ITER_FUNCTION = 8388608, + TRACE_ITER_FUNC_FORK = 16777216, + TRACE_ITER_DISPLAY_GRAPH = 33554432, + TRACE_ITER_STACKTRACE = 67108864, +}; + +struct saved_cmdlines_buffer { + unsigned int map_pid_to_cmdline[32769]; + unsigned int *map_cmdline_to_pid; + unsigned int cmdline_num; + int cmdline_idx; + char *saved_cmdlines; +}; + +struct ftrace_stack { + long unsigned int calls[1024]; +}; + +struct ftrace_stacks { + struct ftrace_stack stacks[4]; +}; + +struct trace_buffer_struct { + int nesting; + char buffer[4096]; +}; + +struct ftrace_buffer_info { + struct trace_iterator iter; + void *spare; + unsigned int spare_cpu; + unsigned int read; +}; + +struct err_info { + const char **errs; + u8 type; + u8 pos; + u64 ts; +}; + +struct tracing_log_err { + struct list_head list; + struct err_info info; + char loc[128]; + char cmd[256]; +}; + +struct buffer_ref { + struct trace_buffer *buffer; + void *page; + int cpu; + refcount_t refcount; +}; + +struct ctx_switch_entry { + struct trace_entry ent; + unsigned int prev_pid; + unsigned int next_pid; + unsigned int next_cpu; + unsigned char prev_prio; + unsigned char prev_state; + unsigned char next_prio; + unsigned char next_state; +}; + +struct hwlat_entry { + struct trace_entry ent; + u64 duration; + u64 outer_duration; + u64 nmi_total_ts; + struct timespec64 timestamp; + unsigned int nmi_count; + unsigned int seqnum; + unsigned int count; +}; + +struct trace_mark { + long long unsigned int val; + char sym; +}; + +struct tracer_stat { + const char *name; + void * (*stat_start)(struct tracer_stat *); + void * (*stat_next)(void *, int); + cmp_func_t stat_cmp; + int (*stat_show)(struct seq_file *, void *); + void (*stat_release)(void *); + int (*stat_headers)(struct seq_file *); +}; + +struct stat_node { + struct rb_node node; + void *stat; +}; + +struct stat_session { + struct list_head session_list; + struct tracer_stat *ts; + struct rb_root stat_root; + struct mutex stat_mutex; + struct dentry *file; +}; + +struct trace_bprintk_fmt { + struct list_head list; + const char *fmt; +}; + +enum { + TRACE_FUNC_OPT_STACK = 1, +}; + +struct ftrace_func_mapper___2; + +enum { + TRACE_NOP_OPT_ACCEPT = 1, + TRACE_NOP_OPT_REFUSE = 2, +}; + +struct ftrace_graph_ent { + long unsigned int func; + int depth; +} __attribute__((packed)); + +struct ftrace_graph_ret { + long unsigned int func; + long unsigned int overrun; + long long unsigned int calltime; + long long unsigned int rettime; + int depth; +} __attribute__((packed)); + +typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); + +typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); + +struct fgraph_ops { + trace_func_graph_ent_t entryfunc; + trace_func_graph_ret_t retfunc; +}; + +struct ftrace_graph_ent_entry { + struct trace_entry ent; + struct ftrace_graph_ent graph_ent; +} __attribute__((packed)); + +struct ftrace_graph_ret_entry { + struct trace_entry ent; + struct ftrace_graph_ret ret; +} __attribute__((packed)); + +struct fgraph_cpu_data { + pid_t last_pid; + int depth; + int depth_irq; + int ignore; + long unsigned int enter_funcs[50]; +}; + +struct fgraph_data { + struct fgraph_cpu_data *cpu_data; + struct ftrace_graph_ent_entry ent; + struct ftrace_graph_ret_entry ret; + int failed; + int cpu; +} __attribute__((packed)); + +enum { + FLAGS_FILL_FULL = 268435456, + FLAGS_FILL_START = 536870912, + FLAGS_FILL_END = 805306368, +}; + +typedef __u32 blk_mq_req_flags_t; + +enum req_opf { + REQ_OP_READ = 0, + REQ_OP_WRITE = 1, + REQ_OP_FLUSH = 2, + REQ_OP_DISCARD = 3, + REQ_OP_SECURE_ERASE = 5, + REQ_OP_WRITE_SAME = 7, + REQ_OP_WRITE_ZEROES = 9, + REQ_OP_ZONE_OPEN = 10, + REQ_OP_ZONE_CLOSE = 11, + REQ_OP_ZONE_FINISH = 12, + REQ_OP_ZONE_APPEND = 13, + REQ_OP_ZONE_RESET = 15, + REQ_OP_ZONE_RESET_ALL = 17, + REQ_OP_SCSI_IN = 32, + REQ_OP_SCSI_OUT = 33, + REQ_OP_DRV_IN = 34, + REQ_OP_DRV_OUT = 35, + REQ_OP_LAST = 36, +}; + +enum req_flag_bits { + __REQ_FAILFAST_DEV = 8, + __REQ_FAILFAST_TRANSPORT = 9, + __REQ_FAILFAST_DRIVER = 10, + __REQ_SYNC = 11, + __REQ_META = 12, + __REQ_PRIO = 13, + __REQ_NOMERGE = 14, + __REQ_IDLE = 15, + __REQ_INTEGRITY = 16, + __REQ_FUA = 17, + __REQ_PREFLUSH = 18, + __REQ_RAHEAD = 19, + __REQ_BACKGROUND = 20, + __REQ_NOWAIT = 21, + __REQ_CGROUP_PUNT = 22, + __REQ_NOUNMAP = 23, + __REQ_HIPRI = 24, + __REQ_DRV = 25, + __REQ_SWAP = 26, + __REQ_NR_BITS = 27, +}; + +struct disk_stats { + u64 nsecs[4]; + long unsigned int sectors[4]; + long unsigned int ios[4]; + long unsigned int merges[4]; + long unsigned int io_ticks; + local_t in_flight[2]; +}; + +struct blk_mq_ctxs; + +struct blk_mq_ctx { + struct { + spinlock_t lock; + struct list_head rq_lists[3]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + }; + unsigned int cpu; + short unsigned int index_hw[3]; + struct blk_mq_hw_ctx *hctxs[3]; + long unsigned int rq_dispatched[2]; + long unsigned int rq_merged; + long unsigned int rq_completed[2]; + struct request_queue *queue; + struct blk_mq_ctxs *ctxs; + struct kobject kobj; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct sbitmap_word; + +struct sbitmap { + unsigned int depth; + unsigned int shift; + unsigned int map_nr; + struct sbitmap_word *map; +}; + +struct blk_mq_tags; + +struct blk_mq_hw_ctx { + struct { + spinlock_t lock; + struct list_head dispatch; + long unsigned int state; + long: 64; + long: 64; + }; + struct delayed_work run_work; + cpumask_var_t cpumask; + int next_cpu; + int next_cpu_batch; + long unsigned int flags; + void *sched_data; + struct request_queue *queue; + struct blk_flush_queue *fq; + void *driver_data; + struct sbitmap ctx_map; + struct blk_mq_ctx *dispatch_from; + unsigned int dispatch_busy; + short unsigned int type; + short unsigned int nr_ctx; + struct blk_mq_ctx **ctxs; + spinlock_t dispatch_wait_lock; + wait_queue_entry_t dispatch_wait; + atomic_t wait_index; + struct blk_mq_tags *tags; + struct blk_mq_tags *sched_tags; + long unsigned int queued; + long unsigned int run; + long unsigned int dispatched[7]; + unsigned int numa_node; + unsigned int queue_num; + atomic_t nr_active; + atomic_t elevator_queued; + struct hlist_node cpuhp_online; + struct hlist_node cpuhp_dead; + struct kobject kobj; + long unsigned int poll_considered; + long unsigned int poll_invoked; + long unsigned int poll_success; + struct dentry *debugfs_dir; + struct dentry *sched_debugfs_dir; + struct list_head hctx_list; + struct srcu_struct srcu[0]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct blk_mq_alloc_data { + struct request_queue *q; + blk_mq_req_flags_t flags; + unsigned int shallow_depth; + unsigned int cmd_flags; + struct blk_mq_ctx *ctx; + struct blk_mq_hw_ctx *hctx; +}; + +struct blk_stat_callback { + struct list_head list; + struct timer_list timer; + struct blk_rq_stat *cpu_stat; + int (*bucket_fn)(const struct request *); + unsigned int buckets; + struct blk_rq_stat *stat; + void (*timer_fn)(struct blk_stat_callback *); + void *data; + struct callback_head rcu; +}; + +struct blk_trace { + int trace_state; + struct rchan *rchan; + long unsigned int *sequence; + unsigned char *msg_data; + u16 act_mask; + u64 start_lba; + u64 end_lba; + u32 pid; + u32 dev; + struct dentry *dir; + struct dentry *dropped_file; + struct dentry *msg_file; + struct list_head running_list; + atomic_t dropped; +}; + +struct blk_flush_queue { + unsigned int flush_pending_idx: 1; + unsigned int flush_running_idx: 1; + blk_status_t rq_status; + long unsigned int flush_pending_since; + struct list_head flush_queue[2]; + struct list_head flush_data_in_flight; + struct request *flush_rq; + struct lock_class_key key; + spinlock_t mq_flush_lock; +}; + +struct blk_mq_queue_map { + unsigned int *mq_map; + unsigned int nr_queues; + unsigned int queue_offset; +}; + +struct sbq_wait_state; + +struct sbitmap_queue { + struct sbitmap sb; + unsigned int *alloc_hint; + unsigned int wake_batch; + atomic_t wake_index; + struct sbq_wait_state *ws; + atomic_t ws_active; + bool round_robin; + unsigned int min_shallow_depth; +}; + +struct blk_mq_tag_set { + struct blk_mq_queue_map map[3]; + unsigned int nr_maps; + const struct blk_mq_ops *ops; + unsigned int nr_hw_queues; + unsigned int queue_depth; + unsigned int reserved_tags; + unsigned int cmd_size; + int numa_node; + unsigned int timeout; + unsigned int flags; + void *driver_data; + atomic_t active_queues_shared_sbitmap; + struct sbitmap_queue __bitmap_tags; + struct sbitmap_queue __breserved_tags; + struct blk_mq_tags **tags; + struct mutex tag_list_lock; + struct list_head tag_list; +}; + +typedef u64 compat_u64; + +enum blktrace_cat { + BLK_TC_READ = 1, + BLK_TC_WRITE = 2, + BLK_TC_FLUSH = 4, + BLK_TC_SYNC = 8, + BLK_TC_SYNCIO = 8, + BLK_TC_QUEUE = 16, + BLK_TC_REQUEUE = 32, + BLK_TC_ISSUE = 64, + BLK_TC_COMPLETE = 128, + BLK_TC_FS = 256, + BLK_TC_PC = 512, + BLK_TC_NOTIFY = 1024, + BLK_TC_AHEAD = 2048, + BLK_TC_META = 4096, + BLK_TC_DISCARD = 8192, + BLK_TC_DRV_DATA = 16384, + BLK_TC_FUA = 32768, + BLK_TC_END = 32768, +}; + +enum blktrace_act { + __BLK_TA_QUEUE = 1, + __BLK_TA_BACKMERGE = 2, + __BLK_TA_FRONTMERGE = 3, + __BLK_TA_GETRQ = 4, + __BLK_TA_SLEEPRQ = 5, + __BLK_TA_REQUEUE = 6, + __BLK_TA_ISSUE = 7, + __BLK_TA_COMPLETE = 8, + __BLK_TA_PLUG = 9, + __BLK_TA_UNPLUG_IO = 10, + __BLK_TA_UNPLUG_TIMER = 11, + __BLK_TA_INSERT = 12, + __BLK_TA_SPLIT = 13, + __BLK_TA_BOUNCE = 14, + __BLK_TA_REMAP = 15, + __BLK_TA_ABORT = 16, + __BLK_TA_DRV_DATA = 17, + __BLK_TA_CGROUP = 256, +}; + +enum blktrace_notify { + __BLK_TN_PROCESS = 0, + __BLK_TN_TIMESTAMP = 1, + __BLK_TN_MESSAGE = 2, + __BLK_TN_CGROUP = 256, +}; + +struct blk_io_trace { + __u32 magic; + __u32 sequence; + __u64 time; + __u64 sector; + __u32 bytes; + __u32 action; + __u32 pid; + __u32 device; + __u32 cpu; + __u16 error; + __u16 pdu_len; +}; + +struct blk_io_trace_remap { + __be32 device_from; + __be32 device_to; + __be64 sector_from; +}; + +enum { + Blktrace_setup = 1, + Blktrace_running = 2, + Blktrace_stopped = 3, +}; + +struct blk_user_trace_setup { + char name[32]; + __u16 act_mask; + __u32 buf_size; + __u32 buf_nr; + __u64 start_lba; + __u64 end_lba; + __u32 pid; +}; + +struct compat_blk_user_trace_setup { + char name[32]; + u16 act_mask; + short: 16; + u32 buf_size; + u32 buf_nr; + compat_u64 start_lba; + compat_u64 end_lba; + u32 pid; +} __attribute__((packed)); + +struct sbitmap_word { + long unsigned int depth; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long unsigned int word; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long unsigned int cleared; + spinlock_t swap_lock; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct sbq_wait_state { + atomic_t wait_cnt; + wait_queue_head_t wait; + long: 64; + long: 64; +}; + +struct blk_mq_tags { + unsigned int nr_tags; + unsigned int nr_reserved_tags; + atomic_t active_queues; + struct sbitmap_queue *bitmap_tags; + struct sbitmap_queue *breserved_tags; + struct sbitmap_queue __bitmap_tags; + struct sbitmap_queue __breserved_tags; + struct request **rqs; + struct request **static_rqs; + struct list_head page_list; +}; + +struct blk_mq_queue_data { + struct request *rq; + bool last; +}; + +struct blk_mq_ctxs { + struct kobject kobj; + struct blk_mq_ctx *queue_ctx; +}; + +typedef void blk_log_action_t(struct trace_iterator *, const char *, bool); + +struct ftrace_event_field { + struct list_head link; + const char *name; + const char *type; + int filter_type; + int offset; + int size; + int is_signed; +}; + +enum { + FORMAT_HEADER = 1, + FORMAT_FIELD_SEPERATOR = 2, + FORMAT_PRINTFMT = 3, +}; + +struct event_probe_data { + struct trace_event_file *file; + long unsigned int count; + int ref; + bool enable; +}; + +struct syscall_trace_enter { + struct trace_entry ent; + int nr; + long unsigned int args[0]; +}; + +struct syscall_trace_exit { + struct trace_entry ent; + int nr; + long int ret; +}; + +struct syscall_tp_t { + long long unsigned int regs; + long unsigned int syscall_nr; + long unsigned int ret; +}; + +struct syscall_tp_t___2 { + long long unsigned int regs; + long unsigned int syscall_nr; + long unsigned int args[6]; +}; + +typedef long unsigned int perf_trace_t[256]; + +struct filter_pred; + +struct prog_entry { + int target; + int when_to_branch; + struct filter_pred *pred; +}; + +typedef int (*filter_pred_fn_t)(struct filter_pred *, void *); + +struct regex; + +typedef int (*regex_match_func)(char *, struct regex *, int); + +struct regex { + char pattern[256]; + int len; + int field_len; + regex_match_func match; +}; + +struct filter_pred { + filter_pred_fn_t fn; + u64 val; + struct regex regex; + short unsigned int *ops; + struct ftrace_event_field *field; + int offset; + int not; + int op; +}; + +enum filter_op_ids { + OP_GLOB = 0, + OP_NE = 1, + OP_EQ = 2, + OP_LE = 3, + OP_LT = 4, + OP_GE = 5, + OP_GT = 6, + OP_BAND = 7, + OP_MAX = 8, +}; + +enum { + FILT_ERR_NONE = 0, + FILT_ERR_INVALID_OP = 1, + FILT_ERR_TOO_MANY_OPEN = 2, + FILT_ERR_TOO_MANY_CLOSE = 3, + FILT_ERR_MISSING_QUOTE = 4, + FILT_ERR_OPERAND_TOO_LONG = 5, + FILT_ERR_EXPECT_STRING = 6, + FILT_ERR_EXPECT_DIGIT = 7, + FILT_ERR_ILLEGAL_FIELD_OP = 8, + FILT_ERR_FIELD_NOT_FOUND = 9, + FILT_ERR_ILLEGAL_INTVAL = 10, + FILT_ERR_BAD_SUBSYS_FILTER = 11, + FILT_ERR_TOO_MANY_PREDS = 12, + FILT_ERR_INVALID_FILTER = 13, + FILT_ERR_IP_FIELD_ONLY = 14, + FILT_ERR_INVALID_VALUE = 15, + FILT_ERR_ERRNO = 16, + FILT_ERR_NO_FILTER = 17, +}; + +struct filter_parse_error { + int lasterr; + int lasterr_pos; +}; + +typedef int (*parse_pred_fn)(const char *, void *, int, struct filter_parse_error *, struct filter_pred **); + +enum { + INVERT = 1, + PROCESS_AND = 2, + PROCESS_OR = 4, +}; + +enum { + TOO_MANY_CLOSE = 4294967295, + TOO_MANY_OPEN = 4294967294, + MISSING_QUOTE = 4294967293, +}; + +struct filter_list { + struct list_head list; + struct event_filter *filter; +}; + +struct function_filter_data { + struct ftrace_ops *ops; + int first_filter; + int first_notrace; +}; + +struct event_trigger_ops; + +struct event_command; + +struct event_trigger_data { + long unsigned int count; + int ref; + struct event_trigger_ops *ops; + struct event_command *cmd_ops; + struct event_filter *filter; + char *filter_str; + void *private_data; + bool paused; + bool paused_tmp; + struct list_head list; + char *name; + struct list_head named_list; + struct event_trigger_data *named_data; +}; + +struct event_trigger_ops { + void (*func)(struct event_trigger_data *, void *, struct ring_buffer_event *); + int (*init)(struct event_trigger_ops *, struct event_trigger_data *); + void (*free)(struct event_trigger_ops *, struct event_trigger_data *); + int (*print)(struct seq_file *, struct event_trigger_ops *, struct event_trigger_data *); +}; + +struct event_command { + struct list_head list; + char *name; + enum event_trigger_type trigger_type; + int flags; + int (*func)(struct event_command *, struct trace_event_file *, char *, char *, char *); + int (*reg)(char *, struct event_trigger_ops *, struct event_trigger_data *, struct trace_event_file *); + void (*unreg)(char *, struct event_trigger_ops *, struct event_trigger_data *, struct trace_event_file *); + void (*unreg_all)(struct trace_event_file *); + int (*set_filter)(char *, struct event_trigger_data *, struct trace_event_file *); + struct event_trigger_ops * (*get_trigger_ops)(char *, char *); +}; + +struct enable_trigger_data { + struct trace_event_file *file; + bool enable; + bool hist; +}; + +enum event_command_flags { + EVENT_CMD_FL_POST_TRIGGER = 1, + EVENT_CMD_FL_NEEDS_REC = 2, +}; + +enum bpf_func_id { + BPF_FUNC_unspec = 0, + BPF_FUNC_map_lookup_elem = 1, + BPF_FUNC_map_update_elem = 2, + BPF_FUNC_map_delete_elem = 3, + BPF_FUNC_probe_read = 4, + BPF_FUNC_ktime_get_ns = 5, + BPF_FUNC_trace_printk = 6, + BPF_FUNC_get_prandom_u32 = 7, + BPF_FUNC_get_smp_processor_id = 8, + BPF_FUNC_skb_store_bytes = 9, + BPF_FUNC_l3_csum_replace = 10, + BPF_FUNC_l4_csum_replace = 11, + BPF_FUNC_tail_call = 12, + BPF_FUNC_clone_redirect = 13, + BPF_FUNC_get_current_pid_tgid = 14, + BPF_FUNC_get_current_uid_gid = 15, + BPF_FUNC_get_current_comm = 16, + BPF_FUNC_get_cgroup_classid = 17, + BPF_FUNC_skb_vlan_push = 18, + BPF_FUNC_skb_vlan_pop = 19, + BPF_FUNC_skb_get_tunnel_key = 20, + BPF_FUNC_skb_set_tunnel_key = 21, + BPF_FUNC_perf_event_read = 22, + BPF_FUNC_redirect = 23, + BPF_FUNC_get_route_realm = 24, + BPF_FUNC_perf_event_output = 25, + BPF_FUNC_skb_load_bytes = 26, + BPF_FUNC_get_stackid = 27, + BPF_FUNC_csum_diff = 28, + BPF_FUNC_skb_get_tunnel_opt = 29, + BPF_FUNC_skb_set_tunnel_opt = 30, + BPF_FUNC_skb_change_proto = 31, + BPF_FUNC_skb_change_type = 32, + BPF_FUNC_skb_under_cgroup = 33, + BPF_FUNC_get_hash_recalc = 34, + BPF_FUNC_get_current_task = 35, + BPF_FUNC_probe_write_user = 36, + BPF_FUNC_current_task_under_cgroup = 37, + BPF_FUNC_skb_change_tail = 38, + BPF_FUNC_skb_pull_data = 39, + BPF_FUNC_csum_update = 40, + BPF_FUNC_set_hash_invalid = 41, + BPF_FUNC_get_numa_node_id = 42, + BPF_FUNC_skb_change_head = 43, + BPF_FUNC_xdp_adjust_head = 44, + BPF_FUNC_probe_read_str = 45, + BPF_FUNC_get_socket_cookie = 46, + BPF_FUNC_get_socket_uid = 47, + BPF_FUNC_set_hash = 48, + BPF_FUNC_setsockopt = 49, + BPF_FUNC_skb_adjust_room = 50, + BPF_FUNC_redirect_map = 51, + BPF_FUNC_sk_redirect_map = 52, + BPF_FUNC_sock_map_update = 53, + BPF_FUNC_xdp_adjust_meta = 54, + BPF_FUNC_perf_event_read_value = 55, + BPF_FUNC_perf_prog_read_value = 56, + BPF_FUNC_getsockopt = 57, + BPF_FUNC_override_return = 58, + BPF_FUNC_sock_ops_cb_flags_set = 59, + BPF_FUNC_msg_redirect_map = 60, + BPF_FUNC_msg_apply_bytes = 61, + BPF_FUNC_msg_cork_bytes = 62, + BPF_FUNC_msg_pull_data = 63, + BPF_FUNC_bind = 64, + BPF_FUNC_xdp_adjust_tail = 65, + BPF_FUNC_skb_get_xfrm_state = 66, + BPF_FUNC_get_stack = 67, + BPF_FUNC_skb_load_bytes_relative = 68, + BPF_FUNC_fib_lookup = 69, + BPF_FUNC_sock_hash_update = 70, + BPF_FUNC_msg_redirect_hash = 71, + BPF_FUNC_sk_redirect_hash = 72, + BPF_FUNC_lwt_push_encap = 73, + BPF_FUNC_lwt_seg6_store_bytes = 74, + BPF_FUNC_lwt_seg6_adjust_srh = 75, + BPF_FUNC_lwt_seg6_action = 76, + BPF_FUNC_rc_repeat = 77, + BPF_FUNC_rc_keydown = 78, + BPF_FUNC_skb_cgroup_id = 79, + BPF_FUNC_get_current_cgroup_id = 80, + BPF_FUNC_get_local_storage = 81, + BPF_FUNC_sk_select_reuseport = 82, + BPF_FUNC_skb_ancestor_cgroup_id = 83, + BPF_FUNC_sk_lookup_tcp = 84, + BPF_FUNC_sk_lookup_udp = 85, + BPF_FUNC_sk_release = 86, + BPF_FUNC_map_push_elem = 87, + BPF_FUNC_map_pop_elem = 88, + BPF_FUNC_map_peek_elem = 89, + BPF_FUNC_msg_push_data = 90, + BPF_FUNC_msg_pop_data = 91, + BPF_FUNC_rc_pointer_rel = 92, + BPF_FUNC_spin_lock = 93, + BPF_FUNC_spin_unlock = 94, + BPF_FUNC_sk_fullsock = 95, + BPF_FUNC_tcp_sock = 96, + BPF_FUNC_skb_ecn_set_ce = 97, + BPF_FUNC_get_listener_sock = 98, + BPF_FUNC_skc_lookup_tcp = 99, + BPF_FUNC_tcp_check_syncookie = 100, + BPF_FUNC_sysctl_get_name = 101, + BPF_FUNC_sysctl_get_current_value = 102, + BPF_FUNC_sysctl_get_new_value = 103, + BPF_FUNC_sysctl_set_new_value = 104, + BPF_FUNC_strtol = 105, + BPF_FUNC_strtoul = 106, + BPF_FUNC_sk_storage_get = 107, + BPF_FUNC_sk_storage_delete = 108, + BPF_FUNC_send_signal = 109, + BPF_FUNC_tcp_gen_syncookie = 110, + BPF_FUNC_skb_output = 111, + BPF_FUNC_probe_read_user = 112, + BPF_FUNC_probe_read_kernel = 113, + BPF_FUNC_probe_read_user_str = 114, + BPF_FUNC_probe_read_kernel_str = 115, + BPF_FUNC_tcp_send_ack = 116, + BPF_FUNC_send_signal_thread = 117, + BPF_FUNC_jiffies64 = 118, + BPF_FUNC_read_branch_records = 119, + BPF_FUNC_get_ns_current_pid_tgid = 120, + BPF_FUNC_xdp_output = 121, + BPF_FUNC_get_netns_cookie = 122, + BPF_FUNC_get_current_ancestor_cgroup_id = 123, + BPF_FUNC_sk_assign = 124, + BPF_FUNC_ktime_get_boot_ns = 125, + BPF_FUNC_seq_printf = 126, + BPF_FUNC_seq_write = 127, + BPF_FUNC_sk_cgroup_id = 128, + BPF_FUNC_sk_ancestor_cgroup_id = 129, + BPF_FUNC_ringbuf_output = 130, + BPF_FUNC_ringbuf_reserve = 131, + BPF_FUNC_ringbuf_submit = 132, + BPF_FUNC_ringbuf_discard = 133, + BPF_FUNC_ringbuf_query = 134, + BPF_FUNC_csum_level = 135, + BPF_FUNC_skc_to_tcp6_sock = 136, + BPF_FUNC_skc_to_tcp_sock = 137, + BPF_FUNC_skc_to_tcp_timewait_sock = 138, + BPF_FUNC_skc_to_tcp_request_sock = 139, + BPF_FUNC_skc_to_udp6_sock = 140, + BPF_FUNC_get_task_stack = 141, + BPF_FUNC_load_hdr_opt = 142, + BPF_FUNC_store_hdr_opt = 143, + BPF_FUNC_reserve_hdr_opt = 144, + BPF_FUNC_inode_storage_get = 145, + BPF_FUNC_inode_storage_delete = 146, + BPF_FUNC_d_path = 147, + BPF_FUNC_copy_from_user = 148, + BPF_FUNC_snprintf_btf = 149, + BPF_FUNC_seq_printf_btf = 150, + BPF_FUNC_skb_cgroup_classid = 151, + BPF_FUNC_redirect_neigh = 152, + BPF_FUNC_bpf_per_cpu_ptr = 153, + BPF_FUNC_bpf_this_cpu_ptr = 154, + BPF_FUNC_redirect_peer = 155, + BPF_FUNC_task_storage_get = 156, + BPF_FUNC_task_storage_delete = 157, + BPF_FUNC_get_current_task_btf = 158, + BPF_FUNC_bprm_opts_set = 159, + BPF_FUNC_ktime_get_coarse_ns = 160, + BPF_FUNC_ima_inode_hash = 161, + __BPF_FUNC_MAX_ID = 162, +}; + +enum { + BPF_F_INDEX_MASK = 4294967295, + BPF_F_CURRENT_CPU = 4294967295, + BPF_F_CTXLEN_MASK = 0, +}; + +enum { + BPF_F_GET_BRANCH_RECORDS_SIZE = 1, +}; + +struct bpf_perf_event_value { + __u64 counter; + __u64 enabled; + __u64 running; +}; + +struct bpf_raw_tracepoint_args { + __u64 args[0]; +}; + +enum bpf_task_fd_type { + BPF_FD_TYPE_RAW_TRACEPOINT = 0, + BPF_FD_TYPE_TRACEPOINT = 1, + BPF_FD_TYPE_KPROBE = 2, + BPF_FD_TYPE_KRETPROBE = 3, + BPF_FD_TYPE_UPROBE = 4, + BPF_FD_TYPE_URETPROBE = 5, +}; + +struct btf_ptr { + void *ptr; + __u32 type_id; + __u32 flags; +}; + +enum { + BTF_F_COMPACT = 1, + BTF_F_NONAME = 2, + BTF_F_PTR_RAW = 4, + BTF_F_ZERO = 8, +}; + +struct bpf_local_storage_map_bucket; + +struct bpf_local_storage_map { + struct bpf_map map; + struct bpf_local_storage_map_bucket *buckets; + u32 bucket_log; + u16 elem_size; + u16 cache_idx; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct bpf_local_storage_data; + +struct bpf_local_storage { + struct bpf_local_storage_data *cache[16]; + struct hlist_head list; + void *owner; + struct callback_head rcu; + raw_spinlock_t lock; +}; + +enum bpf_arg_type { + ARG_DONTCARE = 0, + ARG_CONST_MAP_PTR = 1, + ARG_PTR_TO_MAP_KEY = 2, + ARG_PTR_TO_MAP_VALUE = 3, + ARG_PTR_TO_UNINIT_MAP_VALUE = 4, + ARG_PTR_TO_MAP_VALUE_OR_NULL = 5, + ARG_PTR_TO_MEM = 6, + ARG_PTR_TO_MEM_OR_NULL = 7, + ARG_PTR_TO_UNINIT_MEM = 8, + ARG_CONST_SIZE = 9, + ARG_CONST_SIZE_OR_ZERO = 10, + ARG_PTR_TO_CTX = 11, + ARG_PTR_TO_CTX_OR_NULL = 12, + ARG_ANYTHING = 13, + ARG_PTR_TO_SPIN_LOCK = 14, + ARG_PTR_TO_SOCK_COMMON = 15, + ARG_PTR_TO_INT = 16, + ARG_PTR_TO_LONG = 17, + ARG_PTR_TO_SOCKET = 18, + ARG_PTR_TO_SOCKET_OR_NULL = 19, + ARG_PTR_TO_BTF_ID = 20, + ARG_PTR_TO_ALLOC_MEM = 21, + ARG_PTR_TO_ALLOC_MEM_OR_NULL = 22, + ARG_CONST_ALLOC_SIZE_OR_ZERO = 23, + ARG_PTR_TO_BTF_ID_SOCK_COMMON = 24, + ARG_PTR_TO_PERCPU_BTF_ID = 25, + __BPF_ARG_TYPE_MAX = 26, +}; + +enum bpf_return_type { + RET_INTEGER = 0, + RET_VOID = 1, + RET_PTR_TO_MAP_VALUE = 2, + RET_PTR_TO_MAP_VALUE_OR_NULL = 3, + RET_PTR_TO_SOCKET_OR_NULL = 4, + RET_PTR_TO_TCP_SOCK_OR_NULL = 5, + RET_PTR_TO_SOCK_COMMON_OR_NULL = 6, + RET_PTR_TO_ALLOC_MEM_OR_NULL = 7, + RET_PTR_TO_BTF_ID_OR_NULL = 8, + RET_PTR_TO_MEM_OR_BTF_ID_OR_NULL = 9, + RET_PTR_TO_MEM_OR_BTF_ID = 10, + RET_PTR_TO_BTF_ID = 11, +}; + +struct bpf_func_proto { + u64 (*func)(u64, u64, u64, u64, u64); + bool gpl_only; + bool pkt_access; + enum bpf_return_type ret_type; + union { + struct { + enum bpf_arg_type arg1_type; + enum bpf_arg_type arg2_type; + enum bpf_arg_type arg3_type; + enum bpf_arg_type arg4_type; + enum bpf_arg_type arg5_type; + }; + enum bpf_arg_type arg_type[5]; + }; + union { + struct { + u32 *arg1_btf_id; + u32 *arg2_btf_id; + u32 *arg3_btf_id; + u32 *arg4_btf_id; + u32 *arg5_btf_id; + }; + u32 *arg_btf_id[5]; + }; + int *ret_btf_id; + bool (*allowed)(const struct bpf_prog *); +}; + +enum bpf_access_type { + BPF_READ = 1, + BPF_WRITE = 2, +}; + +struct bpf_verifier_log; + +struct bpf_insn_access_aux { + enum bpf_reg_type reg_type; + union { + int ctx_field_size; + struct { + struct btf *btf; + u32 btf_id; + }; + }; + struct bpf_verifier_log *log; +}; + +struct bpf_verifier_ops { + const struct bpf_func_proto * (*get_func_proto)(enum bpf_func_id, const struct bpf_prog *); + bool (*is_valid_access)(int, int, enum bpf_access_type, const struct bpf_prog *, struct bpf_insn_access_aux *); + int (*gen_prologue)(struct bpf_insn *, bool, const struct bpf_prog *); + int (*gen_ld_abs)(const struct bpf_insn *, struct bpf_insn *); + u32 (*convert_ctx_access)(enum bpf_access_type, const struct bpf_insn *, struct bpf_insn *, struct bpf_prog *, u32 *); + int (*btf_struct_access)(struct bpf_verifier_log *, const struct btf *, const struct btf_type *, int, int, enum bpf_access_type, u32 *); +}; + +struct bpf_event_entry { + struct perf_event *event; + struct file *perf_file; + struct file *map_file; + struct callback_head rcu; +}; + +typedef long unsigned int (*bpf_ctx_copy_t)(void *, const void *, long unsigned int, long unsigned int); + +typedef struct pt_regs bpf_user_pt_regs_t; + +struct bpf_perf_event_data { + bpf_user_pt_regs_t regs; + __u64 sample_period; + __u64 addr; +}; + +struct perf_event_query_bpf { + __u32 ids_len; + __u32 prog_cnt; + __u32 ids[0]; +}; + +struct bpf_perf_event_data_kern { + bpf_user_pt_regs_t *regs; + struct perf_sample_data *data; + struct perf_event *event; +}; + +struct btf_id_set { + u32 cnt; + u32 ids[0]; +}; + +struct bpf_local_storage_map_bucket { + struct hlist_head list; + raw_spinlock_t lock; +}; + +struct bpf_local_storage_data { + struct bpf_local_storage_map *smap; + u8 data[0]; +}; + +struct trace_event_raw_bpf_trace_printk { + struct trace_entry ent; + u32 __data_loc_bpf_string; + char __data[0]; +}; + +struct trace_event_data_offsets_bpf_trace_printk { + u32 bpf_string; +}; + +typedef void (*btf_trace_bpf_trace_printk)(void *, const char *); + +struct bpf_trace_module { + struct module *module; + struct list_head list; +}; + +typedef u64 (*btf_bpf_override_return)(struct pt_regs *, long unsigned int); + +typedef u64 (*btf_bpf_probe_read_user)(void *, u32, const void *); + +typedef u64 (*btf_bpf_probe_read_user_str)(void *, u32, const void *); + +typedef u64 (*btf_bpf_probe_read_kernel)(void *, u32, const void *); + +typedef u64 (*btf_bpf_probe_read_kernel_str)(void *, u32, const void *); + +typedef u64 (*btf_bpf_probe_read_compat)(void *, u32, const void *); + +typedef u64 (*btf_bpf_probe_read_compat_str)(void *, u32, const void *); + +typedef u64 (*btf_bpf_probe_write_user)(void *, const void *, u32); + +typedef u64 (*btf_bpf_trace_printk)(char *, u32, u64, u64, u64); + +struct bpf_seq_printf_buf { + char buf[768]; +}; + +typedef u64 (*btf_bpf_seq_printf)(struct seq_file *, char *, u32, const void *, u32); + +typedef u64 (*btf_bpf_seq_write)(struct seq_file *, const void *, u32); + +typedef u64 (*btf_bpf_seq_printf_btf)(struct seq_file *, struct btf_ptr *, u32, u64); + +typedef u64 (*btf_bpf_perf_event_read)(struct bpf_map *, u64); + +typedef u64 (*btf_bpf_perf_event_read_value)(struct bpf_map *, u64, struct bpf_perf_event_value *, u32); + +struct bpf_trace_sample_data { + struct perf_sample_data sds[3]; +}; + +typedef u64 (*btf_bpf_perf_event_output)(struct pt_regs *, struct bpf_map *, u64, void *, u64); + +struct bpf_nested_pt_regs { + struct pt_regs regs[3]; +}; + +typedef u64 (*btf_bpf_get_current_task)(); + +typedef u64 (*btf_bpf_get_current_task_btf)(); + +typedef u64 (*btf_bpf_current_task_under_cgroup)(struct bpf_map *, u32); + +struct send_signal_irq_work { + struct irq_work irq_work; + struct task_struct *task; + u32 sig; + enum pid_type type; +}; + +typedef u64 (*btf_bpf_send_signal)(u32); + +typedef u64 (*btf_bpf_send_signal_thread)(u32); + +typedef u64 (*btf_bpf_d_path)(struct path *, char *, u32); + +typedef u64 (*btf_bpf_snprintf_btf)(char *, u32, struct btf_ptr *, u32, u64); + +typedef u64 (*btf_bpf_perf_event_output_tp)(void *, struct bpf_map *, u64, void *, u64); + +typedef u64 (*btf_bpf_get_stackid_tp)(void *, struct bpf_map *, u64); + +typedef u64 (*btf_bpf_get_stack_tp)(void *, void *, u32, u64); + +typedef u64 (*btf_bpf_perf_prog_read_value)(struct bpf_perf_event_data_kern *, struct bpf_perf_event_value *, u32); + +typedef u64 (*btf_bpf_read_branch_records)(struct bpf_perf_event_data_kern *, void *, u32, u64); + +struct bpf_raw_tp_regs { + struct pt_regs regs[3]; +}; + +typedef u64 (*btf_bpf_perf_event_output_raw_tp)(struct bpf_raw_tracepoint_args *, struct bpf_map *, u64, void *, u64); + +typedef u64 (*btf_bpf_get_stackid_raw_tp)(struct bpf_raw_tracepoint_args *, struct bpf_map *, u64); + +typedef u64 (*btf_bpf_get_stack_raw_tp)(struct bpf_raw_tracepoint_args *, void *, u32, u64); + +enum dynevent_type { + DYNEVENT_TYPE_SYNTH = 1, + DYNEVENT_TYPE_KPROBE = 2, + DYNEVENT_TYPE_NONE = 3, +}; + +struct dynevent_cmd; + +typedef int (*dynevent_create_fn_t)(struct dynevent_cmd *); + +struct dynevent_cmd { + struct seq_buf seq; + const char *event_name; + unsigned int n_fields; + enum dynevent_type type; + dynevent_create_fn_t run_command; + void *private_data; +}; + +struct kprobe_trace_entry_head { + struct trace_entry ent; + long unsigned int ip; +}; + +struct kretprobe_trace_entry_head { + struct trace_entry ent; + long unsigned int func; + long unsigned int ret_ip; +}; + +struct dyn_event; + +struct dyn_event_operations { + struct list_head list; + int (*create)(int, const char **); + int (*show)(struct seq_file *, struct dyn_event *); + bool (*is_busy)(struct dyn_event *); + int (*free)(struct dyn_event *); + bool (*match)(const char *, const char *, int, const char **, struct dyn_event *); +}; + +struct dyn_event { + struct list_head list; + struct dyn_event_operations *ops; +}; + +struct dynevent_arg { + const char *str; + char separator; +}; + +typedef int (*print_type_func_t)(struct trace_seq *, void *, void *); + +enum fetch_op { + FETCH_OP_NOP = 0, + FETCH_OP_REG = 1, + FETCH_OP_STACK = 2, + FETCH_OP_STACKP = 3, + FETCH_OP_RETVAL = 4, + FETCH_OP_IMM = 5, + FETCH_OP_COMM = 6, + FETCH_OP_ARG = 7, + FETCH_OP_FOFFS = 8, + FETCH_OP_DATA = 9, + FETCH_OP_DEREF = 10, + FETCH_OP_UDEREF = 11, + FETCH_OP_ST_RAW = 12, + FETCH_OP_ST_MEM = 13, + FETCH_OP_ST_UMEM = 14, + FETCH_OP_ST_STRING = 15, + FETCH_OP_ST_USTRING = 16, + FETCH_OP_MOD_BF = 17, + FETCH_OP_LP_ARRAY = 18, + FETCH_OP_END = 19, + FETCH_NOP_SYMBOL = 20, +}; + +struct fetch_insn { + enum fetch_op op; + union { + unsigned int param; + struct { + unsigned int size; + int offset; + }; + struct { + unsigned char basesize; + unsigned char lshift; + unsigned char rshift; + }; + long unsigned int immediate; + void *data; + }; +}; + +struct fetch_type { + const char *name; + size_t size; + int is_signed; + print_type_func_t print; + const char *fmt; + const char *fmttype; +}; + +struct probe_arg { + struct fetch_insn *code; + bool dynamic; + unsigned int offset; + unsigned int count; + const char *name; + const char *comm; + char *fmt; + const struct fetch_type *type; +}; + +struct trace_uprobe_filter { + rwlock_t rwlock; + int nr_systemwide; + struct list_head perf_events; +}; + +struct trace_probe_event { + unsigned int flags; + struct trace_event_class class; + struct trace_event_call call; + struct list_head files; + struct list_head probes; + struct trace_uprobe_filter filter[0]; +}; + +struct trace_probe { + struct list_head list; + struct trace_probe_event *event; + ssize_t size; + unsigned int nr_args; + struct probe_arg args[0]; +}; + +struct event_file_link { + struct trace_event_file *file; + struct list_head list; +}; + +enum { + TP_ERR_FILE_NOT_FOUND = 0, + TP_ERR_NO_REGULAR_FILE = 1, + TP_ERR_BAD_REFCNT = 2, + TP_ERR_REFCNT_OPEN_BRACE = 3, + TP_ERR_BAD_REFCNT_SUFFIX = 4, + TP_ERR_BAD_UPROBE_OFFS = 5, + TP_ERR_MAXACT_NO_KPROBE = 6, + TP_ERR_BAD_MAXACT = 7, + TP_ERR_MAXACT_TOO_BIG = 8, + TP_ERR_BAD_PROBE_ADDR = 9, + TP_ERR_BAD_RETPROBE = 10, + TP_ERR_BAD_ADDR_SUFFIX = 11, + TP_ERR_NO_GROUP_NAME = 12, + TP_ERR_GROUP_TOO_LONG = 13, + TP_ERR_BAD_GROUP_NAME = 14, + TP_ERR_NO_EVENT_NAME = 15, + TP_ERR_EVENT_TOO_LONG = 16, + TP_ERR_BAD_EVENT_NAME = 17, + TP_ERR_RETVAL_ON_PROBE = 18, + TP_ERR_BAD_STACK_NUM = 19, + TP_ERR_BAD_ARG_NUM = 20, + TP_ERR_BAD_VAR = 21, + TP_ERR_BAD_REG_NAME = 22, + TP_ERR_BAD_MEM_ADDR = 23, + TP_ERR_BAD_IMM = 24, + TP_ERR_IMMSTR_NO_CLOSE = 25, + TP_ERR_FILE_ON_KPROBE = 26, + TP_ERR_BAD_FILE_OFFS = 27, + TP_ERR_SYM_ON_UPROBE = 28, + TP_ERR_TOO_MANY_OPS = 29, + TP_ERR_DEREF_NEED_BRACE = 30, + TP_ERR_BAD_DEREF_OFFS = 31, + TP_ERR_DEREF_OPEN_BRACE = 32, + TP_ERR_COMM_CANT_DEREF = 33, + TP_ERR_BAD_FETCH_ARG = 34, + TP_ERR_ARRAY_NO_CLOSE = 35, + TP_ERR_BAD_ARRAY_SUFFIX = 36, + TP_ERR_BAD_ARRAY_NUM = 37, + TP_ERR_ARRAY_TOO_BIG = 38, + TP_ERR_BAD_TYPE = 39, + TP_ERR_BAD_STRING = 40, + TP_ERR_BAD_BITFIELD = 41, + TP_ERR_ARG_NAME_TOO_LONG = 42, + TP_ERR_NO_ARG_NAME = 43, + TP_ERR_BAD_ARG_NAME = 44, + TP_ERR_USED_ARG_NAME = 45, + TP_ERR_ARG_TOO_LONG = 46, + TP_ERR_NO_ARG_BODY = 47, + TP_ERR_BAD_INSN_BNDRY = 48, + TP_ERR_FAIL_REG_PROBE = 49, + TP_ERR_DIFF_PROBE_TYPE = 50, + TP_ERR_DIFF_ARG_TYPE = 51, + TP_ERR_SAME_PROBE = 52, +}; + +struct trace_kprobe { + struct dyn_event devent; + struct kretprobe rp; + long unsigned int *nhit; + const char *symbol; + struct trace_probe tp; +}; + +struct trace_event_raw_cpu { + struct trace_entry ent; + u32 state; + u32 cpu_id; + char __data[0]; +}; + +struct trace_event_raw_powernv_throttle { + struct trace_entry ent; + int chip_id; + u32 __data_loc_reason; + int pmax; + char __data[0]; +}; + +struct trace_event_raw_pstate_sample { + struct trace_entry ent; + u32 core_busy; + u32 scaled_busy; + u32 from; + u32 to; + u64 mperf; + u64 aperf; + u64 tsc; + u32 freq; + u32 io_boost; + char __data[0]; +}; + +struct trace_event_raw_cpu_frequency_limits { + struct trace_entry ent; + u32 min_freq; + u32 max_freq; + u32 cpu_id; + char __data[0]; +}; + +struct trace_event_raw_device_pm_callback_start { + struct trace_entry ent; + u32 __data_loc_device; + u32 __data_loc_driver; + u32 __data_loc_parent; + u32 __data_loc_pm_ops; + int event; + char __data[0]; +}; + +struct trace_event_raw_device_pm_callback_end { + struct trace_entry ent; + u32 __data_loc_device; + u32 __data_loc_driver; + int error; + char __data[0]; +}; + +struct trace_event_raw_suspend_resume { + struct trace_entry ent; + const char *action; + int val; + bool start; + char __data[0]; +}; + +struct trace_event_raw_wakeup_source { + struct trace_entry ent; + u32 __data_loc_name; + u64 state; + char __data[0]; +}; + +struct trace_event_raw_clock { + struct trace_entry ent; + u32 __data_loc_name; + u64 state; + u64 cpu_id; + char __data[0]; +}; + +struct trace_event_raw_power_domain { + struct trace_entry ent; + u32 __data_loc_name; + u64 state; + u64 cpu_id; + char __data[0]; +}; + +struct trace_event_raw_cpu_latency_qos_request { + struct trace_entry ent; + s32 value; + char __data[0]; +}; + +struct trace_event_raw_pm_qos_update { + struct trace_entry ent; + enum pm_qos_req_action action; + int prev_value; + int curr_value; + char __data[0]; +}; + +struct trace_event_raw_dev_pm_qos_request { + struct trace_entry ent; + u32 __data_loc_name; + enum dev_pm_qos_req_type type; + s32 new_value; + char __data[0]; +}; + +struct trace_event_data_offsets_cpu {}; + +struct trace_event_data_offsets_powernv_throttle { + u32 reason; +}; + +struct trace_event_data_offsets_pstate_sample {}; + +struct trace_event_data_offsets_cpu_frequency_limits {}; + +struct trace_event_data_offsets_device_pm_callback_start { + u32 device; + u32 driver; + u32 parent; + u32 pm_ops; +}; + +struct trace_event_data_offsets_device_pm_callback_end { + u32 device; + u32 driver; +}; + +struct trace_event_data_offsets_suspend_resume {}; + +struct trace_event_data_offsets_wakeup_source { + u32 name; +}; + +struct trace_event_data_offsets_clock { + u32 name; +}; + +struct trace_event_data_offsets_power_domain { + u32 name; +}; + +struct trace_event_data_offsets_cpu_latency_qos_request {}; + +struct trace_event_data_offsets_pm_qos_update {}; + +struct trace_event_data_offsets_dev_pm_qos_request { + u32 name; +}; + +typedef void (*btf_trace_cpu_idle)(void *, unsigned int, unsigned int); + +typedef void (*btf_trace_powernv_throttle)(void *, int, const char *, int); + +typedef void (*btf_trace_pstate_sample)(void *, u32, u32, u32, u32, u64, u64, u64, u32, u32); + +typedef void (*btf_trace_cpu_frequency)(void *, unsigned int, unsigned int); + +typedef void (*btf_trace_cpu_frequency_limits)(void *, struct cpufreq_policy *); + +typedef void (*btf_trace_device_pm_callback_start)(void *, struct device *, const char *, int); + +typedef void (*btf_trace_device_pm_callback_end)(void *, struct device *, int); + +typedef void (*btf_trace_suspend_resume)(void *, const char *, int, bool); + +typedef void (*btf_trace_wakeup_source_activate)(void *, const char *, unsigned int); + +typedef void (*btf_trace_wakeup_source_deactivate)(void *, const char *, unsigned int); + +typedef void (*btf_trace_clock_enable)(void *, const char *, unsigned int, unsigned int); + +typedef void (*btf_trace_clock_disable)(void *, const char *, unsigned int, unsigned int); + +typedef void (*btf_trace_clock_set_rate)(void *, const char *, unsigned int, unsigned int); + +typedef void (*btf_trace_power_domain_target)(void *, const char *, unsigned int, unsigned int); + +typedef void (*btf_trace_pm_qos_add_request)(void *, s32); + +typedef void (*btf_trace_pm_qos_update_request)(void *, s32); + +typedef void (*btf_trace_pm_qos_remove_request)(void *, s32); + +typedef void (*btf_trace_pm_qos_update_target)(void *, enum pm_qos_req_action, int, int); + +typedef void (*btf_trace_pm_qos_update_flags)(void *, enum pm_qos_req_action, int, int); + +typedef void (*btf_trace_dev_pm_qos_add_request)(void *, const char *, enum dev_pm_qos_req_type, s32); + +typedef void (*btf_trace_dev_pm_qos_update_request)(void *, const char *, enum dev_pm_qos_req_type, s32); + +typedef void (*btf_trace_dev_pm_qos_remove_request)(void *, const char *, enum dev_pm_qos_req_type, s32); + +struct trace_event_raw_rpm_internal { + struct trace_entry ent; + u32 __data_loc_name; + int flags; + int usage_count; + int disable_depth; + int runtime_auto; + int request_pending; + int irq_safe; + int child_count; + char __data[0]; +}; + +struct trace_event_raw_rpm_return_int { + struct trace_entry ent; + u32 __data_loc_name; + long unsigned int ip; + int ret; + char __data[0]; +}; + +struct trace_event_data_offsets_rpm_internal { + u32 name; +}; + +struct trace_event_data_offsets_rpm_return_int { + u32 name; +}; + +typedef void (*btf_trace_rpm_suspend)(void *, struct device *, int); + +typedef void (*btf_trace_rpm_resume)(void *, struct device *, int); + +typedef void (*btf_trace_rpm_idle)(void *, struct device *, int); + +typedef void (*btf_trace_rpm_usage)(void *, struct device *, int); + +typedef void (*btf_trace_rpm_return_int)(void *, struct device *, long unsigned int, int); + +typedef int (*dynevent_check_arg_fn_t)(void *); + +struct dynevent_arg_pair { + const char *lhs; + const char *rhs; + char operator; + char separator; +}; + +struct trace_probe_log { + const char *subsystem; + const char **argv; + int argc; + int index; +}; + +enum uprobe_filter_ctx { + UPROBE_FILTER_REGISTER = 0, + UPROBE_FILTER_UNREGISTER = 1, + UPROBE_FILTER_MMAP = 2, +}; + +struct uprobe_consumer { + int (*handler)(struct uprobe_consumer *, struct pt_regs *); + int (*ret_handler)(struct uprobe_consumer *, long unsigned int, struct pt_regs *); + bool (*filter)(struct uprobe_consumer *, enum uprobe_filter_ctx, struct mm_struct *); + struct uprobe_consumer *next; +}; + +struct uprobe_trace_entry_head { + struct trace_entry ent; + long unsigned int vaddr[0]; +}; + +struct trace_uprobe { + struct dyn_event devent; + struct uprobe_consumer consumer; + struct path path; + struct inode *inode; + char *filename; + long unsigned int offset; + long unsigned int ref_ctr_offset; + long unsigned int nhit; + struct trace_probe tp; +}; + +struct uprobe_dispatch_data { + struct trace_uprobe *tu; + long unsigned int bp_addr; +}; + +struct uprobe_cpu_buffer { + struct mutex mutex; + void *buf; +}; + +typedef bool (*filter_func_t)(struct uprobe_consumer *, enum uprobe_filter_ctx, struct mm_struct *); + +struct rhash_lock_head; + +struct bucket_table { + unsigned int size; + unsigned int nest; + u32 hash_rnd; + struct list_head walkers; + struct callback_head rcu; + struct bucket_table *future_tbl; + struct lockdep_map dep_map; + long: 64; + struct rhash_lock_head *buckets[0]; +}; + +struct rnd_state { + __u32 s1; + __u32 s2; + __u32 s3; + __u32 s4; +}; + +enum xdp_action { + XDP_ABORTED = 0, + XDP_DROP = 1, + XDP_PASS = 2, + XDP_TX = 3, + XDP_REDIRECT = 4, +}; + +enum xdp_mem_type { + MEM_TYPE_PAGE_SHARED = 0, + MEM_TYPE_PAGE_ORDER0 = 1, + MEM_TYPE_PAGE_POOL = 2, + MEM_TYPE_XSK_BUFF_POOL = 3, + MEM_TYPE_MAX = 4, +}; + +struct xdp_cpumap_stats { + unsigned int redirect; + unsigned int pass; + unsigned int drop; +}; + +typedef void (*bpf_jit_fill_hole_t)(void *, unsigned int); + +struct bpf_prog_dummy { + struct bpf_prog prog; +}; + +typedef u64 (*btf_bpf_user_rnd_u32)(); + +typedef u64 (*btf_bpf_get_raw_cpu_id)(); + +struct _bpf_dtab_netdev { + struct net_device *dev; +}; + +struct rhash_lock_head {}; + +struct zero_copy_allocator; + +struct page_pool; + +struct xdp_mem_allocator { + struct xdp_mem_info mem; + union { + void *allocator; + struct page_pool *page_pool; + struct zero_copy_allocator *zc_alloc; + }; + struct rhash_head node; + struct callback_head rcu; +}; + +struct trace_event_raw_xdp_exception { + struct trace_entry ent; + int prog_id; + u32 act; + int ifindex; + char __data[0]; +}; + +struct trace_event_raw_xdp_bulk_tx { + struct trace_entry ent; + int ifindex; + u32 act; + int drops; + int sent; + int err; + char __data[0]; +}; + +struct trace_event_raw_xdp_redirect_template { + struct trace_entry ent; + int prog_id; + u32 act; + int ifindex; + int err; + int to_ifindex; + u32 map_id; + int map_index; + char __data[0]; +}; + +struct trace_event_raw_xdp_cpumap_kthread { + struct trace_entry ent; + int map_id; + u32 act; + int cpu; + unsigned int drops; + unsigned int processed; + int sched; + unsigned int xdp_pass; + unsigned int xdp_drop; + unsigned int xdp_redirect; + char __data[0]; +}; + +struct trace_event_raw_xdp_cpumap_enqueue { + struct trace_entry ent; + int map_id; + u32 act; + int cpu; + unsigned int drops; + unsigned int processed; + int to_cpu; + char __data[0]; +}; + +struct trace_event_raw_xdp_devmap_xmit { + struct trace_entry ent; + int from_ifindex; + u32 act; + int to_ifindex; + int drops; + int sent; + int err; + char __data[0]; +}; + +struct trace_event_raw_mem_disconnect { + struct trace_entry ent; + const struct xdp_mem_allocator *xa; + u32 mem_id; + u32 mem_type; + const void *allocator; + char __data[0]; +}; + +struct trace_event_raw_mem_connect { + struct trace_entry ent; + const struct xdp_mem_allocator *xa; + u32 mem_id; + u32 mem_type; + const void *allocator; + const struct xdp_rxq_info *rxq; + int ifindex; + char __data[0]; +}; + +struct trace_event_raw_mem_return_failed { + struct trace_entry ent; + const struct page *page; + u32 mem_id; + u32 mem_type; + char __data[0]; +}; + +struct trace_event_data_offsets_xdp_exception {}; + +struct trace_event_data_offsets_xdp_bulk_tx {}; + +struct trace_event_data_offsets_xdp_redirect_template {}; + +struct trace_event_data_offsets_xdp_cpumap_kthread {}; + +struct trace_event_data_offsets_xdp_cpumap_enqueue {}; + +struct trace_event_data_offsets_xdp_devmap_xmit {}; + +struct trace_event_data_offsets_mem_disconnect {}; + +struct trace_event_data_offsets_mem_connect {}; + +struct trace_event_data_offsets_mem_return_failed {}; + +typedef void (*btf_trace_xdp_exception)(void *, const struct net_device *, const struct bpf_prog *, u32); + +typedef void (*btf_trace_xdp_bulk_tx)(void *, const struct net_device *, int, int, int); + +typedef void (*btf_trace_xdp_redirect)(void *, const struct net_device *, const struct bpf_prog *, const void *, int, const struct bpf_map *, u32); + +typedef void (*btf_trace_xdp_redirect_err)(void *, const struct net_device *, const struct bpf_prog *, const void *, int, const struct bpf_map *, u32); + +typedef void (*btf_trace_xdp_redirect_map)(void *, const struct net_device *, const struct bpf_prog *, const void *, int, const struct bpf_map *, u32); + +typedef void (*btf_trace_xdp_redirect_map_err)(void *, const struct net_device *, const struct bpf_prog *, const void *, int, const struct bpf_map *, u32); + +typedef void (*btf_trace_xdp_cpumap_kthread)(void *, int, unsigned int, unsigned int, int, struct xdp_cpumap_stats *); + +typedef void (*btf_trace_xdp_cpumap_enqueue)(void *, int, unsigned int, unsigned int, int); + +typedef void (*btf_trace_xdp_devmap_xmit)(void *, const struct net_device *, const struct net_device *, int, int, int); + +typedef void (*btf_trace_mem_disconnect)(void *, const struct xdp_mem_allocator *); + +typedef void (*btf_trace_mem_connect)(void *, const struct xdp_mem_allocator *, const struct xdp_rxq_info *); + +typedef void (*btf_trace_mem_return_failed)(void *, const struct xdp_mem_info *, const struct page *); + +enum bpf_cmd { + BPF_MAP_CREATE = 0, + BPF_MAP_LOOKUP_ELEM = 1, + BPF_MAP_UPDATE_ELEM = 2, + BPF_MAP_DELETE_ELEM = 3, + BPF_MAP_GET_NEXT_KEY = 4, + BPF_PROG_LOAD = 5, + BPF_OBJ_PIN = 6, + BPF_OBJ_GET = 7, + BPF_PROG_ATTACH = 8, + BPF_PROG_DETACH = 9, + BPF_PROG_TEST_RUN = 10, + BPF_PROG_GET_NEXT_ID = 11, + BPF_MAP_GET_NEXT_ID = 12, + BPF_PROG_GET_FD_BY_ID = 13, + BPF_MAP_GET_FD_BY_ID = 14, + BPF_OBJ_GET_INFO_BY_FD = 15, + BPF_PROG_QUERY = 16, + BPF_RAW_TRACEPOINT_OPEN = 17, + BPF_BTF_LOAD = 18, + BPF_BTF_GET_FD_BY_ID = 19, + BPF_TASK_FD_QUERY = 20, + BPF_MAP_LOOKUP_AND_DELETE_ELEM = 21, + BPF_MAP_FREEZE = 22, + BPF_BTF_GET_NEXT_ID = 23, + BPF_MAP_LOOKUP_BATCH = 24, + BPF_MAP_LOOKUP_AND_DELETE_BATCH = 25, + BPF_MAP_UPDATE_BATCH = 26, + BPF_MAP_DELETE_BATCH = 27, + BPF_LINK_CREATE = 28, + BPF_LINK_UPDATE = 29, + BPF_LINK_GET_FD_BY_ID = 30, + BPF_LINK_GET_NEXT_ID = 31, + BPF_ENABLE_STATS = 32, + BPF_ITER_CREATE = 33, + BPF_LINK_DETACH = 34, + BPF_PROG_BIND_MAP = 35, +}; + +enum { + BPF_ANY = 0, + BPF_NOEXIST = 1, + BPF_EXIST = 2, + BPF_F_LOCK = 4, +}; + +enum { + BPF_F_NO_PREALLOC = 1, + BPF_F_NO_COMMON_LRU = 2, + BPF_F_NUMA_NODE = 4, + BPF_F_RDONLY = 8, + BPF_F_WRONLY = 16, + BPF_F_STACK_BUILD_ID = 32, + BPF_F_ZERO_SEED = 64, + BPF_F_RDONLY_PROG = 128, + BPF_F_WRONLY_PROG = 256, + BPF_F_CLONE = 512, + BPF_F_MMAPABLE = 1024, + BPF_F_PRESERVE_ELEMS = 2048, + BPF_F_INNER_MAP = 4096, +}; + +enum bpf_stats_type { + BPF_STATS_RUN_TIME = 0, +}; + +struct bpf_prog_info { + __u32 type; + __u32 id; + __u8 tag[8]; + __u32 jited_prog_len; + __u32 xlated_prog_len; + __u64 jited_prog_insns; + __u64 xlated_prog_insns; + __u64 load_time; + __u32 created_by_uid; + __u32 nr_map_ids; + __u64 map_ids; + char name[16]; + __u32 ifindex; + __u32 gpl_compatible: 1; + __u64 netns_dev; + __u64 netns_ino; + __u32 nr_jited_ksyms; + __u32 nr_jited_func_lens; + __u64 jited_ksyms; + __u64 jited_func_lens; + __u32 btf_id; + __u32 func_info_rec_size; + __u64 func_info; + __u32 nr_func_info; + __u32 nr_line_info; + __u64 line_info; + __u64 jited_line_info; + __u32 nr_jited_line_info; + __u32 line_info_rec_size; + __u32 jited_line_info_rec_size; + __u32 nr_prog_tags; + __u64 prog_tags; + __u64 run_time_ns; + __u64 run_cnt; +}; + +struct bpf_map_info { + __u32 type; + __u32 id; + __u32 key_size; + __u32 value_size; + __u32 max_entries; + __u32 map_flags; + char name[16]; + __u32 ifindex; + __u32 btf_vmlinux_value_type_id; + __u64 netns_dev; + __u64 netns_ino; + __u32 btf_id; + __u32 btf_key_type_id; + __u32 btf_value_type_id; +}; + +struct bpf_btf_info { + __u64 btf; + __u32 btf_size; + __u32 id; + __u64 name; + __u32 name_len; + __u32 kernel_btf; +}; + +struct bpf_spin_lock { + __u32 val; +}; + +struct bpf_attach_target_info { + struct btf_func_model fmodel; + long int tgt_addr; + const char *tgt_name; + const struct btf_type *tgt_type; +}; + +struct bpf_link_primer { + struct bpf_link *link; + struct file *file; + int fd; + u32 id; +}; + +enum perf_bpf_event_type { + PERF_BPF_EVENT_UNKNOWN = 0, + PERF_BPF_EVENT_PROG_LOAD = 1, + PERF_BPF_EVENT_PROG_UNLOAD = 2, + PERF_BPF_EVENT_MAX = 3, +}; + +enum bpf_audit { + BPF_AUDIT_LOAD = 0, + BPF_AUDIT_UNLOAD = 1, + BPF_AUDIT_MAX = 2, +}; + +struct bpf_tracing_link { + struct bpf_link link; + enum bpf_attach_type attach_type; + struct bpf_trampoline *trampoline; + struct bpf_prog *tgt_prog; +}; + +struct bpf_raw_tp_link { + struct bpf_link link; + struct bpf_raw_event_map *btp; +}; + +struct btf_member { + __u32 name_off; + __u32 type; + __u32 offset; +}; + +enum btf_func_linkage { + BTF_FUNC_STATIC = 0, + BTF_FUNC_GLOBAL = 1, + BTF_FUNC_EXTERN = 2, +}; + +struct btf_var_secinfo { + __u32 type; + __u32 offset; + __u32 size; +}; + +enum sk_action { + SK_DROP = 0, + SK_PASS = 1, +}; + +struct bpf_verifier_log { + u32 level; + char kbuf[1024]; + char *ubuf; + u32 len_used; + u32 len_total; +}; + +struct bpf_subprog_info { + u32 start; + u32 linfo_idx; + u16 stack_depth; + bool has_tail_call; + bool tail_call_reachable; + bool has_ld_abs; +}; + +struct bpf_verifier_stack_elem; + +struct bpf_verifier_state; + +struct bpf_verifier_state_list; + +struct bpf_insn_aux_data; + +struct bpf_verifier_env { + u32 insn_idx; + u32 prev_insn_idx; + struct bpf_prog *prog; + const struct bpf_verifier_ops *ops; + struct bpf_verifier_stack_elem *head; + int stack_size; + bool strict_alignment; + bool test_state_freq; + struct bpf_verifier_state *cur_state; + struct bpf_verifier_state_list **explored_states; + struct bpf_verifier_state_list *free_list; + struct bpf_map *used_maps[64]; + u32 used_map_cnt; + u32 id_gen; + bool allow_ptr_leaks; + bool allow_ptr_to_map_access; + bool bpf_capable; + bool bypass_spec_v1; + bool bypass_spec_v4; + bool seen_direct_write; + struct bpf_insn_aux_data *insn_aux_data; + const struct bpf_line_info *prev_linfo; + struct bpf_verifier_log log; + struct bpf_subprog_info subprog_info[257]; + struct { + int *insn_state; + int *insn_stack; + int cur_stack; + } cfg; + u32 pass_cnt; + u32 subprog_cnt; + u32 prev_insn_processed; + u32 insn_processed; + u32 prev_jmps_processed; + u32 jmps_processed; + u64 verification_time; + u32 max_states_per_insn; + u32 total_states; + u32 peak_states; + u32 longest_mark_read_walk; +}; + +struct bpf_struct_ops { + const struct bpf_verifier_ops *verifier_ops; + int (*init)(struct btf *); + int (*check_member)(const struct btf_type *, const struct btf_member *); + int (*init_member)(const struct btf_type *, const struct btf_member *, void *, const void *); + int (*reg)(void *); + void (*unreg)(void *); + const struct btf_type *type; + const struct btf_type *value_type; + const char *name; + struct btf_func_model func_models[64]; + u32 type_id; + u32 value_id; +}; + +typedef u32 (*bpf_convert_ctx_access_t)(enum bpf_access_type, const struct bpf_insn *, struct bpf_insn *, struct bpf_prog *, u32 *); + +struct tnum { + u64 value; + u64 mask; +}; + +enum bpf_reg_liveness { + REG_LIVE_NONE = 0, + REG_LIVE_READ32 = 1, + REG_LIVE_READ64 = 2, + REG_LIVE_READ = 3, + REG_LIVE_WRITTEN = 4, + REG_LIVE_DONE = 8, +}; + +struct bpf_reg_state { + enum bpf_reg_type type; + s32 off; + union { + int range; + struct bpf_map *map_ptr; + struct { + struct btf *btf; + u32 btf_id; + }; + u32 mem_size; + struct { + long unsigned int raw1; + long unsigned int raw2; + } raw; + }; + u32 id; + u32 ref_obj_id; + struct tnum var_off; + s64 smin_value; + s64 smax_value; + u64 umin_value; + u64 umax_value; + s32 s32_min_value; + s32 s32_max_value; + u32 u32_min_value; + u32 u32_max_value; + struct bpf_reg_state *parent; + u32 frameno; + s32 subreg_def; + enum bpf_reg_liveness live; + bool precise; +}; + +enum bpf_stack_slot_type { + STACK_INVALID = 0, + STACK_SPILL = 1, + STACK_MISC = 2, + STACK_ZERO = 3, +}; + +struct bpf_stack_state { + struct bpf_reg_state spilled_ptr; + u8 slot_type[8]; +}; + +struct bpf_reference_state { + int id; + int insn_idx; +}; + +struct bpf_func_state { + struct bpf_reg_state regs[11]; + int callsite; + u32 frameno; + u32 subprogno; + int acquired_refs; + struct bpf_reference_state *refs; + int allocated_stack; + struct bpf_stack_state *stack; +}; + +struct bpf_idx_pair { + u32 prev_idx; + u32 idx; +}; + +struct bpf_verifier_state { + struct bpf_func_state *frame[8]; + struct bpf_verifier_state *parent; + u32 branches; + u32 insn_idx; + u32 curframe; + u32 active_spin_lock; + bool speculative; + u32 first_insn_idx; + u32 last_insn_idx; + struct bpf_idx_pair *jmp_history; + u32 jmp_history_cnt; +}; + +struct bpf_verifier_state_list { + struct bpf_verifier_state state; + struct bpf_verifier_state_list *next; + int miss_cnt; + int hit_cnt; +}; + +struct bpf_insn_aux_data { + union { + enum bpf_reg_type ptr_type; + long unsigned int map_ptr_state; + s32 call_imm; + u32 alu_limit; + struct { + u32 map_index; + u32 map_off; + }; + struct { + enum bpf_reg_type reg_type; + union { + struct { + struct btf *btf; + u32 btf_id; + }; + u32 mem_size; + }; + } btf_var; + }; + u64 map_key_state; + int ctx_field_size; + int sanitize_stack_off; + u32 seen; + bool zext_dst; + u8 alu_state; + unsigned int orig_idx; + bool prune_point; +}; + +struct bpf_verifier_stack_elem { + struct bpf_verifier_state st; + int insn_idx; + int prev_insn_idx; + struct bpf_verifier_stack_elem *next; + u32 log_pos; +}; + +enum { + BTF_SOCK_TYPE_INET = 0, + BTF_SOCK_TYPE_INET_CONN = 1, + BTF_SOCK_TYPE_INET_REQ = 2, + BTF_SOCK_TYPE_INET_TW = 3, + BTF_SOCK_TYPE_REQ = 4, + BTF_SOCK_TYPE_SOCK = 5, + BTF_SOCK_TYPE_SOCK_COMMON = 6, + BTF_SOCK_TYPE_TCP = 7, + BTF_SOCK_TYPE_TCP_REQ = 8, + BTF_SOCK_TYPE_TCP_TW = 9, + BTF_SOCK_TYPE_TCP6 = 10, + BTF_SOCK_TYPE_UDP = 11, + BTF_SOCK_TYPE_UDP6 = 12, + MAX_BTF_SOCK_TYPE = 13, +}; + +typedef void (*bpf_insn_print_t)(void *, const char *, ...); + +typedef const char * (*bpf_insn_revmap_call_t)(void *, const struct bpf_insn *); + +typedef const char * (*bpf_insn_print_imm_t)(void *, const struct bpf_insn *, __u64); + +struct bpf_insn_cbs { + bpf_insn_print_t cb_print; + bpf_insn_revmap_call_t cb_call; + bpf_insn_print_imm_t cb_imm; + void *private_data; +}; + +struct bpf_call_arg_meta { + struct bpf_map *map_ptr; + bool raw_mode; + bool pkt_access; + int regno; + int access_size; + int mem_size; + u64 msize_max_value; + int ref_obj_id; + int func_id; + struct btf *btf; + u32 btf_id; + struct btf *ret_btf; + u32 ret_btf_id; +}; + +enum reg_arg_type { + SRC_OP = 0, + DST_OP = 1, + DST_OP_NO_MARK = 2, +}; + +struct bpf_reg_types { + const enum bpf_reg_type types[10]; + u32 *btf_id; +}; + +enum { + AT_PKT_END = 4294967295, + BEYOND_PKT_END = 4294967294, +}; + +enum { + DISCOVERED = 16, + EXPLORED = 32, + FALLTHROUGH = 1, + BRANCH = 2, +}; + +enum { + DONE_EXPLORING = 0, + KEEP_EXPLORING = 1, +}; + +struct idpair { + u32 old; + u32 cur; +}; + +struct tree_descr { + const char *name; + const struct file_operations *ops; + int mode; +}; + +struct bpf_preload_info { + char link_name[16]; + int link_id; +}; + +struct bpf_preload_ops { + struct umd_info info; + int (*preload)(struct bpf_preload_info *); + int (*finish)(); + struct module *owner; +}; + +enum bpf_type { + BPF_TYPE_UNSPEC = 0, + BPF_TYPE_PROG = 1, + BPF_TYPE_MAP = 2, + BPF_TYPE_LINK = 3, +}; + +struct map_iter { + void *key; + bool done; +}; + +enum { + OPT_MODE = 0, +}; + +struct bpf_mount_opts { + umode_t mode; +}; + +struct bpf_pidns_info { + __u32 pid; + __u32 tgid; +}; + +typedef u64 (*btf_bpf_map_lookup_elem)(struct bpf_map *, void *); + +typedef u64 (*btf_bpf_map_update_elem)(struct bpf_map *, void *, void *, u64); + +typedef u64 (*btf_bpf_map_delete_elem)(struct bpf_map *, void *); + +typedef u64 (*btf_bpf_map_push_elem)(struct bpf_map *, void *, u64); + +typedef u64 (*btf_bpf_map_pop_elem)(struct bpf_map *, void *); + +typedef u64 (*btf_bpf_map_peek_elem)(struct bpf_map *, void *); + +typedef u64 (*btf_bpf_get_smp_processor_id)(); + +typedef u64 (*btf_bpf_get_numa_node_id)(); + +typedef u64 (*btf_bpf_ktime_get_ns)(); + +typedef u64 (*btf_bpf_ktime_get_boot_ns)(); + +typedef u64 (*btf_bpf_ktime_get_coarse_ns)(); + +typedef u64 (*btf_bpf_get_current_pid_tgid)(); + +typedef u64 (*btf_bpf_get_current_uid_gid)(); + +typedef u64 (*btf_bpf_get_current_comm)(char *, u32); + +typedef u64 (*btf_bpf_spin_lock)(struct bpf_spin_lock *); + +typedef u64 (*btf_bpf_spin_unlock)(struct bpf_spin_lock *); + +typedef u64 (*btf_bpf_jiffies64)(); + +typedef u64 (*btf_bpf_get_current_cgroup_id)(); + +typedef u64 (*btf_bpf_get_current_ancestor_cgroup_id)(int); + +typedef u64 (*btf_bpf_get_local_storage)(struct bpf_map *, u64); + +typedef u64 (*btf_bpf_strtol)(const char *, size_t, u64, long int *); + +typedef u64 (*btf_bpf_strtoul)(const char *, size_t, u64, long unsigned int *); + +typedef u64 (*btf_bpf_get_ns_current_pid_tgid)(u64, u64, struct bpf_pidns_info *, u32); + +typedef u64 (*btf_bpf_event_output_data)(void *, struct bpf_map *, u64, void *, u64); + +typedef u64 (*btf_bpf_copy_from_user)(void *, u32, const void *); + +typedef u64 (*btf_bpf_per_cpu_ptr)(const void *, u32); + +typedef u64 (*btf_bpf_this_cpu_ptr)(const void *); + +union bpf_iter_link_info { + struct { + __u32 map_fd; + } map; +}; + +typedef int (*bpf_iter_attach_target_t)(struct bpf_prog *, union bpf_iter_link_info *, struct bpf_iter_aux_info *); + +typedef void (*bpf_iter_detach_target_t)(struct bpf_iter_aux_info *); + +typedef void (*bpf_iter_show_fdinfo_t)(const struct bpf_iter_aux_info *, struct seq_file *); + +typedef int (*bpf_iter_fill_link_info_t)(const struct bpf_iter_aux_info *, struct bpf_link_info *); + +enum bpf_iter_feature { + BPF_ITER_RESCHED = 1, +}; + +struct bpf_iter_reg { + const char *target; + bpf_iter_attach_target_t attach_target; + bpf_iter_detach_target_t detach_target; + bpf_iter_show_fdinfo_t show_fdinfo; + bpf_iter_fill_link_info_t fill_link_info; + u32 ctx_arg_info_size; + u32 feature; + struct bpf_ctx_arg_aux ctx_arg_info[2]; + const struct bpf_iter_seq_info *seq_info; +}; + +struct bpf_iter_meta { + union { + struct seq_file *seq; + }; + u64 session_id; + u64 seq_num; +}; + +struct bpf_iter_target_info { + struct list_head list; + const struct bpf_iter_reg *reg_info; + u32 btf_id; +}; + +struct bpf_iter_link { + struct bpf_link link; + struct bpf_iter_aux_info aux; + struct bpf_iter_target_info *tinfo; +}; + +struct bpf_iter_priv_data { + struct bpf_iter_target_info *tinfo; + const struct bpf_iter_seq_info *seq_info; + struct bpf_prog *prog; + u64 session_id; + u64 seq_num; + bool done_stop; + long: 56; + u8 target_private[0]; +}; + +struct bpf_iter_seq_map_info { + u32 map_id; +}; + +struct bpf_iter__bpf_map { + union { + struct bpf_iter_meta *meta; + }; + union { + struct bpf_map *map; + }; +}; + +struct bpf_iter_seq_task_common { + struct pid_namespace *ns; +}; + +struct bpf_iter_seq_task_info { + struct bpf_iter_seq_task_common common; + u32 tid; +}; + +struct bpf_iter__task { + union { + struct bpf_iter_meta *meta; + }; + union { + struct task_struct *task; + }; +}; + +struct bpf_iter_seq_task_file_info { + struct bpf_iter_seq_task_common common; + struct task_struct *task; + struct files_struct *files; + u32 tid; + u32 fd; +}; + +struct bpf_iter__task_file { + union { + struct bpf_iter_meta *meta; + }; + union { + struct task_struct *task; + }; + u32 fd; + union { + struct file *file; + }; +}; + +struct bpf_iter_seq_prog_info { + u32 prog_id; +}; + +struct bpf_iter__bpf_prog { + union { + struct bpf_iter_meta *meta; + }; + union { + struct bpf_prog *prog; + }; +}; + +struct bpf_iter__bpf_map_elem { + union { + struct bpf_iter_meta *meta; + }; + union { + struct bpf_map *map; + }; + union { + void *key; + }; + union { + void *value; + }; +}; + +struct hlist_nulls_head { + struct hlist_nulls_node *first; +}; + +struct pcpu_freelist_node; + +struct pcpu_freelist_head { + struct pcpu_freelist_node *first; + raw_spinlock_t lock; +}; + +struct pcpu_freelist_node { + struct pcpu_freelist_node *next; +}; + +struct pcpu_freelist { + struct pcpu_freelist_head *freelist; + struct pcpu_freelist_head extralist; +}; + +struct bpf_lru_node { + struct list_head list; + u16 cpu; + u8 type; + u8 ref; +}; + +struct bpf_lru_list { + struct list_head lists[3]; + unsigned int counts[2]; + struct list_head *next_inactive_rotation; + raw_spinlock_t lock; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct bpf_lru_locallist { + struct list_head lists[2]; + u16 next_steal; + raw_spinlock_t lock; +}; + +struct bpf_common_lru { + struct bpf_lru_list lru_list; + struct bpf_lru_locallist *local_list; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +typedef bool (*del_from_htab_func)(void *, struct bpf_lru_node *); + +struct bpf_lru { + union { + struct bpf_common_lru common_lru; + struct bpf_lru_list *percpu_lru; + }; + del_from_htab_func del_from_htab; + void *del_arg; + unsigned int hash_offset; + unsigned int nr_scans; + bool percpu; + long: 56; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct bucket { + struct hlist_nulls_head head; + union { + raw_spinlock_t raw_lock; + spinlock_t lock; + }; +}; + +struct htab_elem; + +struct bpf_htab { + struct bpf_map map; + struct bucket *buckets; + void *elems; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + union { + struct pcpu_freelist freelist; + struct bpf_lru lru; + }; + struct htab_elem **extra_elems; + atomic_t count; + u32 n_buckets; + u32 elem_size; + u32 hashrnd; + struct lock_class_key lockdep_key; + int *map_locked[8]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct htab_elem { + union { + struct hlist_nulls_node hash_node; + struct { + void *padding; + union { + struct bpf_htab *htab; + struct pcpu_freelist_node fnode; + struct htab_elem *batch_flink; + }; + }; + }; + union { + struct callback_head rcu; + struct bpf_lru_node lru_node; + }; + u32 hash; + int: 32; + char key[0]; +}; + +struct bpf_iter_seq_hash_map_info { + struct bpf_map *map; + struct bpf_htab *htab; + void *percpu_value_buf; + u32 bucket_id; + u32 skip_elems; +}; + +struct bpf_iter_seq_array_map_info { + struct bpf_map *map; + void *percpu_value_buf; + u32 index; +}; + +struct prog_poke_elem { + struct list_head list; + struct bpf_prog_aux *aux; +}; + +enum bpf_lru_list_type { + BPF_LRU_LIST_T_ACTIVE = 0, + BPF_LRU_LIST_T_INACTIVE = 1, + BPF_LRU_LIST_T_FREE = 2, + BPF_LRU_LOCAL_LIST_T_FREE = 3, + BPF_LRU_LOCAL_LIST_T_PENDING = 4, +}; + +struct bpf_lpm_trie_key { + __u32 prefixlen; + __u8 data[0]; +}; + +struct lpm_trie_node { + struct callback_head rcu; + struct lpm_trie_node *child[2]; + u32 prefixlen; + u32 flags; + u8 data[0]; +}; + +struct lpm_trie { + struct bpf_map map; + struct lpm_trie_node *root; + size_t n_entries; + size_t max_prefixlen; + size_t data_size; + spinlock_t lock; + long: 64; +}; + +struct bpf_cgroup_storage_map { + struct bpf_map map; + spinlock_t lock; + struct rb_root root; + struct list_head list; + long: 64; + long: 64; +}; + +struct bpf_queue_stack { + struct bpf_map map; + raw_spinlock_t lock; + u32 head; + u32 tail; + u32 size; + int: 32; + char elements[0]; + long: 64; + long: 64; + long: 64; +}; + +enum { + BPF_RB_NO_WAKEUP = 1, + BPF_RB_FORCE_WAKEUP = 2, +}; + +enum { + BPF_RB_AVAIL_DATA = 0, + BPF_RB_RING_SIZE = 1, + BPF_RB_CONS_POS = 2, + BPF_RB_PROD_POS = 3, +}; + +enum { + BPF_RINGBUF_BUSY_BIT = 2147483648, + BPF_RINGBUF_DISCARD_BIT = 1073741824, + BPF_RINGBUF_HDR_SZ = 8, +}; + +struct bpf_ringbuf { + wait_queue_head_t waitq; + struct irq_work work; + u64 mask; + struct page **pages; + int nr_pages; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + spinlock_t spinlock; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long unsigned int consumer_pos; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long unsigned int producer_pos; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + char data[0]; +}; + +struct bpf_ringbuf_map { + struct bpf_map map; + struct bpf_ringbuf *rb; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct bpf_ringbuf_hdr { + u32 len; + u32 pg_off; +}; + +typedef u64 (*btf_bpf_ringbuf_reserve)(struct bpf_map *, u64, u64); + +typedef u64 (*btf_bpf_ringbuf_submit)(void *, u64); + +typedef u64 (*btf_bpf_ringbuf_discard)(void *, u64); + +typedef u64 (*btf_bpf_ringbuf_output)(struct bpf_map *, void *, u64, u64); + +typedef u64 (*btf_bpf_ringbuf_query)(struct bpf_map *, u64); + +enum { + BPF_LOCAL_STORAGE_GET_F_CREATE = 1, + BPF_SK_STORAGE_GET_F_CREATE = 1, +}; + +struct bpf_local_storage_elem { + struct hlist_node map_node; + struct hlist_node snode; + struct bpf_local_storage *local_storage; + struct callback_head rcu; + long: 64; + struct bpf_local_storage_data sdata; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct bpf_local_storage_cache { + spinlock_t idx_lock; + u64 idx_usage_counts[16]; +}; + +struct lsm_blob_sizes { + int lbs_cred; + int lbs_file; + int lbs_inode; + int lbs_ipc; + int lbs_msg_msg; + int lbs_task; +}; + +struct bpf_storage_blob { + struct bpf_local_storage *storage; +}; + +typedef u64 (*btf_bpf_inode_storage_get)(struct bpf_map *, struct inode *, void *, u64); + +typedef u64 (*btf_bpf_inode_storage_delete)(struct bpf_map *, struct inode *); + +typedef u64 (*btf_bpf_task_storage_get)(struct bpf_map *, struct task_struct *, void *, u64); + +typedef u64 (*btf_bpf_task_storage_delete)(struct bpf_map *, struct task_struct *); + +struct btf_enum { + __u32 name_off; + __s32 val; +}; + +struct btf_array { + __u32 type; + __u32 index_type; + __u32 nelems; +}; + +struct btf_param { + __u32 name_off; + __u32 type; +}; + +enum { + BTF_VAR_STATIC = 0, + BTF_VAR_GLOBAL_ALLOCATED = 1, + BTF_VAR_GLOBAL_EXTERN = 2, +}; + +struct btf_var { + __u32 linkage; +}; + +struct bpf_flow_keys { + __u16 nhoff; + __u16 thoff; + __u16 addr_proto; + __u8 is_frag; + __u8 is_first_frag; + __u8 is_encap; + __u8 ip_proto; + __be16 n_proto; + __be16 sport; + __be16 dport; + union { + struct { + __be32 ipv4_src; + __be32 ipv4_dst; + }; + struct { + __u32 ipv6_src[4]; + __u32 ipv6_dst[4]; + }; + }; + __u32 flags; + __be32 flow_label; +}; + +struct bpf_sock { + __u32 bound_dev_if; + __u32 family; + __u32 type; + __u32 protocol; + __u32 mark; + __u32 priority; + __u32 src_ip4; + __u32 src_ip6[4]; + __u32 src_port; + __u32 dst_port; + __u32 dst_ip4; + __u32 dst_ip6[4]; + __u32 state; + __s32 rx_queue_mapping; +}; + +struct __sk_buff { + __u32 len; + __u32 pkt_type; + __u32 mark; + __u32 queue_mapping; + __u32 protocol; + __u32 vlan_present; + __u32 vlan_tci; + __u32 vlan_proto; + __u32 priority; + __u32 ingress_ifindex; + __u32 ifindex; + __u32 tc_index; + __u32 cb[5]; + __u32 hash; + __u32 tc_classid; + __u32 data; + __u32 data_end; + __u32 napi_id; + __u32 family; + __u32 remote_ip4; + __u32 local_ip4; + __u32 remote_ip6[4]; + __u32 local_ip6[4]; + __u32 remote_port; + __u32 local_port; + __u32 data_meta; + union { + struct bpf_flow_keys *flow_keys; + }; + __u64 tstamp; + __u32 wire_len; + __u32 gso_segs; + union { + struct bpf_sock *sk; + }; + __u32 gso_size; +}; + +struct xdp_md { + __u32 data; + __u32 data_end; + __u32 data_meta; + __u32 ingress_ifindex; + __u32 rx_queue_index; + __u32 egress_ifindex; +}; + +struct sk_msg_md { + union { + void *data; + }; + union { + void *data_end; + }; + __u32 family; + __u32 remote_ip4; + __u32 local_ip4; + __u32 remote_ip6[4]; + __u32 local_ip6[4]; + __u32 remote_port; + __u32 local_port; + __u32 size; + union { + struct bpf_sock *sk; + }; +}; + +struct sk_reuseport_md { + union { + void *data; + }; + union { + void *data_end; + }; + __u32 len; + __u32 eth_protocol; + __u32 ip_protocol; + __u32 bind_inany; + __u32 hash; +}; + +struct bpf_sock_addr { + __u32 user_family; + __u32 user_ip4; + __u32 user_ip6[4]; + __u32 user_port; + __u32 family; + __u32 type; + __u32 protocol; + __u32 msg_src_ip4; + __u32 msg_src_ip6[4]; + union { + struct bpf_sock *sk; + }; +}; + +struct bpf_sock_ops { + __u32 op; + union { + __u32 args[4]; + __u32 reply; + __u32 replylong[4]; + }; + __u32 family; + __u32 remote_ip4; + __u32 local_ip4; + __u32 remote_ip6[4]; + __u32 local_ip6[4]; + __u32 remote_port; + __u32 local_port; + __u32 is_fullsock; + __u32 snd_cwnd; + __u32 srtt_us; + __u32 bpf_sock_ops_cb_flags; + __u32 state; + __u32 rtt_min; + __u32 snd_ssthresh; + __u32 rcv_nxt; + __u32 snd_nxt; + __u32 snd_una; + __u32 mss_cache; + __u32 ecn_flags; + __u32 rate_delivered; + __u32 rate_interval_us; + __u32 packets_out; + __u32 retrans_out; + __u32 total_retrans; + __u32 segs_in; + __u32 data_segs_in; + __u32 segs_out; + __u32 data_segs_out; + __u32 lost_out; + __u32 sacked_out; + __u32 sk_txhash; + __u64 bytes_received; + __u64 bytes_acked; + union { + struct bpf_sock *sk; + }; + union { + void *skb_data; + }; + union { + void *skb_data_end; + }; + __u32 skb_len; + __u32 skb_tcp_flags; +}; + +struct bpf_cgroup_dev_ctx { + __u32 access_type; + __u32 major; + __u32 minor; +}; + +struct bpf_sysctl { + __u32 write; + __u32 file_pos; +}; + +struct bpf_sockopt { + union { + struct bpf_sock *sk; + }; + union { + void *optval; + }; + union { + void *optval_end; + }; + __s32 level; + __s32 optname; + __s32 optlen; + __s32 retval; +}; + +struct bpf_sk_lookup { + union { + struct bpf_sock *sk; + }; + __u32 family; + __u32 protocol; + __u32 remote_ip4; + __u32 remote_ip6[4]; + __u32 remote_port; + __u32 local_ip4; + __u32 local_ip6[4]; + __u32 local_port; +}; + +struct sk_reuseport_kern { + struct sk_buff *skb; + struct sock *sk; + struct sock *selected_sk; + void *data_end; + u32 hash; + u32 reuseport_id; + bool bind_inany; +}; + +struct bpf_flow_dissector { + struct bpf_flow_keys *flow_keys; + const struct sk_buff *skb; + void *data; + void *data_end; +}; + +struct inet_listen_hashbucket { + spinlock_t lock; + unsigned int count; + union { + struct hlist_head head; + struct hlist_nulls_head nulls_head; + }; +}; + +struct inet_ehash_bucket; + +struct inet_bind_hashbucket; + +struct inet_hashinfo { + struct inet_ehash_bucket *ehash; + spinlock_t *ehash_locks; + unsigned int ehash_mask; + unsigned int ehash_locks_mask; + struct kmem_cache *bind_bucket_cachep; + struct inet_bind_hashbucket *bhash; + unsigned int bhash_size; + unsigned int lhash2_mask; + struct inet_listen_hashbucket *lhash2; + long: 64; + struct inet_listen_hashbucket listening_hash[32]; +}; + +struct ip_ra_chain { + struct ip_ra_chain *next; + struct sock *sk; + union { + void (*destructor)(struct sock *); + struct sock *saved_sk; + }; + struct callback_head rcu; +}; + +struct fib_table { + struct hlist_node tb_hlist; + u32 tb_id; + int tb_num_default; + struct callback_head rcu; + long unsigned int *tb_data; + long unsigned int __data[0]; +}; + +struct inet_peer_base { + struct rb_root rb_root; + seqlock_t lock; + int total; +}; + +struct tcp_fastopen_context { + siphash_key_t key[2]; + int num; + struct callback_head rcu; +}; + +struct xdp_txq_info { + struct net_device *dev; +}; + +struct xdp_buff { + void *data; + void *data_end; + void *data_meta; + void *data_hard_start; + struct xdp_rxq_info *rxq; + struct xdp_txq_info *txq; + u32 frame_sz; +}; + +struct bpf_sock_addr_kern { + struct sock *sk; + struct sockaddr *uaddr; + u64 tmp_reg; + void *t_ctx; +}; + +struct bpf_sock_ops_kern { + struct sock *sk; + union { + u32 args[4]; + u32 reply; + u32 replylong[4]; + }; + struct sk_buff *syn_skb; + struct sk_buff *skb; + void *skb_data_end; + u8 op; + u8 is_fullsock; + u8 remaining_opt_len; + u64 temp; +}; + +struct bpf_sysctl_kern { + struct ctl_table_header *head; + struct ctl_table *table; + void *cur_val; + size_t cur_len; + void *new_val; + size_t new_len; + int new_updated; + int write; + loff_t *ppos; + u64 tmp_reg; +}; + +struct bpf_sockopt_kern { + struct sock *sk; + u8 *optval; + u8 *optval_end; + s32 level; + s32 optname; + s32 optlen; + s32 retval; +}; + +struct bpf_sk_lookup_kern { + u16 family; + u16 protocol; + __be16 sport; + u16 dport; + struct { + __be32 saddr; + __be32 daddr; + } v4; + struct { + const struct in6_addr *saddr; + const struct in6_addr *daddr; + } v6; + struct sock *selected_sk; + bool no_reuseport; +}; + +struct sock_reuseport { + struct callback_head rcu; + u16 max_socks; + u16 num_socks; + unsigned int synq_overflow_ts; + unsigned int reuseport_id; + unsigned int bind_inany: 1; + unsigned int has_conns: 1; + struct bpf_prog *prog; + struct sock *socks[0]; +}; + +struct inet_ehash_bucket { + struct hlist_nulls_head chain; +}; + +struct inet_bind_hashbucket { + spinlock_t lock; + struct hlist_head chain; +}; + +struct ack_sample { + u32 pkts_acked; + s32 rtt_us; + u32 in_flight; +}; + +struct rate_sample { + u64 prior_mstamp; + u32 prior_delivered; + s32 delivered; + long int interval_us; + u32 snd_interval_us; + u32 rcv_interval_us; + long int rtt_us; + int losses; + u32 acked_sacked; + u32 prior_in_flight; + bool is_app_limited; + bool is_retrans; + bool is_ack_delayed; +}; + +struct sk_msg_sg { + u32 start; + u32 curr; + u32 end; + u32 size; + u32 copybreak; + long unsigned int copy; + struct scatterlist data[19]; +}; + +struct sk_msg { + struct sk_msg_sg sg; + void *data; + void *data_end; + u32 apply_bytes; + u32 cork_bytes; + u32 flags; + struct sk_buff *skb; + struct sock *sk_redir; + struct sock *sk; + struct list_head list; +}; + +enum verifier_phase { + CHECK_META = 0, + CHECK_TYPE = 1, +}; + +struct resolve_vertex { + const struct btf_type *t; + u32 type_id; + u16 next_member; +}; + +enum visit_state { + NOT_VISITED = 0, + VISITED = 1, + RESOLVED = 2, +}; + +enum resolve_mode { + RESOLVE_TBD = 0, + RESOLVE_PTR = 1, + RESOLVE_STRUCT_OR_ARRAY = 2, +}; + +struct btf_sec_info { + u32 off; + u32 len; +}; + +struct btf_verifier_env { + struct btf *btf; + u8 *visit_states; + struct resolve_vertex stack[32]; + struct bpf_verifier_log log; + u32 log_type_id; + u32 top_stack; + enum verifier_phase phase; + enum resolve_mode resolve_mode; +}; + +struct btf_show { + u64 flags; + void *target; + void (*showfn)(struct btf_show *, const char *, struct __va_list_tag *); + const struct btf *btf; + struct { + u8 depth; + u8 depth_to_show; + u8 depth_check; + u8 array_member: 1; + u8 array_terminated: 1; + u16 array_encoding; + u32 type_id; + int status; + const struct btf_type *type; + const struct btf_member *member; + char name[80]; + } state; + struct { + u32 size; + void *head; + void *data; + u8 safe[32]; + } obj; +}; + +struct btf_kind_operations { + s32 (*check_meta)(struct btf_verifier_env *, const struct btf_type *, u32); + int (*resolve)(struct btf_verifier_env *, const struct resolve_vertex *); + int (*check_member)(struct btf_verifier_env *, const struct btf_type *, const struct btf_member *, const struct btf_type *); + int (*check_kflag_member)(struct btf_verifier_env *, const struct btf_type *, const struct btf_member *, const struct btf_type *); + void (*log_details)(struct btf_verifier_env *, const struct btf_type *); + void (*show)(const struct btf *, const struct btf_type *, u32, void *, u8, struct btf_show *); +}; + +struct bpf_ctx_convert { + struct __sk_buff BPF_PROG_TYPE_SOCKET_FILTER_prog; + struct sk_buff BPF_PROG_TYPE_SOCKET_FILTER_kern; + struct __sk_buff BPF_PROG_TYPE_SCHED_CLS_prog; + struct sk_buff BPF_PROG_TYPE_SCHED_CLS_kern; + struct __sk_buff BPF_PROG_TYPE_SCHED_ACT_prog; + struct sk_buff BPF_PROG_TYPE_SCHED_ACT_kern; + struct xdp_md BPF_PROG_TYPE_XDP_prog; + struct xdp_buff BPF_PROG_TYPE_XDP_kern; + struct __sk_buff BPF_PROG_TYPE_CGROUP_SKB_prog; + struct sk_buff BPF_PROG_TYPE_CGROUP_SKB_kern; + struct bpf_sock BPF_PROG_TYPE_CGROUP_SOCK_prog; + struct sock BPF_PROG_TYPE_CGROUP_SOCK_kern; + struct bpf_sock_addr BPF_PROG_TYPE_CGROUP_SOCK_ADDR_prog; + struct bpf_sock_addr_kern BPF_PROG_TYPE_CGROUP_SOCK_ADDR_kern; + struct __sk_buff BPF_PROG_TYPE_LWT_IN_prog; + struct sk_buff BPF_PROG_TYPE_LWT_IN_kern; + struct __sk_buff BPF_PROG_TYPE_LWT_OUT_prog; + struct sk_buff BPF_PROG_TYPE_LWT_OUT_kern; + struct __sk_buff BPF_PROG_TYPE_LWT_XMIT_prog; + struct sk_buff BPF_PROG_TYPE_LWT_XMIT_kern; + struct __sk_buff BPF_PROG_TYPE_LWT_SEG6LOCAL_prog; + struct sk_buff BPF_PROG_TYPE_LWT_SEG6LOCAL_kern; + struct bpf_sock_ops BPF_PROG_TYPE_SOCK_OPS_prog; + struct bpf_sock_ops_kern BPF_PROG_TYPE_SOCK_OPS_kern; + struct __sk_buff BPF_PROG_TYPE_SK_SKB_prog; + struct sk_buff BPF_PROG_TYPE_SK_SKB_kern; + struct sk_msg_md BPF_PROG_TYPE_SK_MSG_prog; + struct sk_msg BPF_PROG_TYPE_SK_MSG_kern; + struct __sk_buff BPF_PROG_TYPE_FLOW_DISSECTOR_prog; + struct bpf_flow_dissector BPF_PROG_TYPE_FLOW_DISSECTOR_kern; + bpf_user_pt_regs_t BPF_PROG_TYPE_KPROBE_prog; + struct pt_regs BPF_PROG_TYPE_KPROBE_kern; + __u64 BPF_PROG_TYPE_TRACEPOINT_prog; + u64 BPF_PROG_TYPE_TRACEPOINT_kern; + struct bpf_perf_event_data BPF_PROG_TYPE_PERF_EVENT_prog; + struct bpf_perf_event_data_kern BPF_PROG_TYPE_PERF_EVENT_kern; + struct bpf_raw_tracepoint_args BPF_PROG_TYPE_RAW_TRACEPOINT_prog; + u64 BPF_PROG_TYPE_RAW_TRACEPOINT_kern; + struct bpf_raw_tracepoint_args BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE_prog; + u64 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE_kern; + void *BPF_PROG_TYPE_TRACING_prog; + void *BPF_PROG_TYPE_TRACING_kern; + struct bpf_cgroup_dev_ctx BPF_PROG_TYPE_CGROUP_DEVICE_prog; + struct bpf_cgroup_dev_ctx BPF_PROG_TYPE_CGROUP_DEVICE_kern; + struct bpf_sysctl BPF_PROG_TYPE_CGROUP_SYSCTL_prog; + struct bpf_sysctl_kern BPF_PROG_TYPE_CGROUP_SYSCTL_kern; + struct bpf_sockopt BPF_PROG_TYPE_CGROUP_SOCKOPT_prog; + struct bpf_sockopt_kern BPF_PROG_TYPE_CGROUP_SOCKOPT_kern; + struct sk_reuseport_md BPF_PROG_TYPE_SK_REUSEPORT_prog; + struct sk_reuseport_kern BPF_PROG_TYPE_SK_REUSEPORT_kern; + struct bpf_sk_lookup BPF_PROG_TYPE_SK_LOOKUP_prog; + struct bpf_sk_lookup_kern BPF_PROG_TYPE_SK_LOOKUP_kern; + void *BPF_PROG_TYPE_STRUCT_OPS_prog; + void *BPF_PROG_TYPE_STRUCT_OPS_kern; + void *BPF_PROG_TYPE_EXT_prog; + void *BPF_PROG_TYPE_EXT_kern; + void *BPF_PROG_TYPE_LSM_prog; + void *BPF_PROG_TYPE_LSM_kern; +}; + +enum { + __ctx_convertBPF_PROG_TYPE_SOCKET_FILTER = 0, + __ctx_convertBPF_PROG_TYPE_SCHED_CLS = 1, + __ctx_convertBPF_PROG_TYPE_SCHED_ACT = 2, + __ctx_convertBPF_PROG_TYPE_XDP = 3, + __ctx_convertBPF_PROG_TYPE_CGROUP_SKB = 4, + __ctx_convertBPF_PROG_TYPE_CGROUP_SOCK = 5, + __ctx_convertBPF_PROG_TYPE_CGROUP_SOCK_ADDR = 6, + __ctx_convertBPF_PROG_TYPE_LWT_IN = 7, + __ctx_convertBPF_PROG_TYPE_LWT_OUT = 8, + __ctx_convertBPF_PROG_TYPE_LWT_XMIT = 9, + __ctx_convertBPF_PROG_TYPE_LWT_SEG6LOCAL = 10, + __ctx_convertBPF_PROG_TYPE_SOCK_OPS = 11, + __ctx_convertBPF_PROG_TYPE_SK_SKB = 12, + __ctx_convertBPF_PROG_TYPE_SK_MSG = 13, + __ctx_convertBPF_PROG_TYPE_FLOW_DISSECTOR = 14, + __ctx_convertBPF_PROG_TYPE_KPROBE = 15, + __ctx_convertBPF_PROG_TYPE_TRACEPOINT = 16, + __ctx_convertBPF_PROG_TYPE_PERF_EVENT = 17, + __ctx_convertBPF_PROG_TYPE_RAW_TRACEPOINT = 18, + __ctx_convertBPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE = 19, + __ctx_convertBPF_PROG_TYPE_TRACING = 20, + __ctx_convertBPF_PROG_TYPE_CGROUP_DEVICE = 21, + __ctx_convertBPF_PROG_TYPE_CGROUP_SYSCTL = 22, + __ctx_convertBPF_PROG_TYPE_CGROUP_SOCKOPT = 23, + __ctx_convertBPF_PROG_TYPE_SK_REUSEPORT = 24, + __ctx_convertBPF_PROG_TYPE_SK_LOOKUP = 25, + __ctx_convertBPF_PROG_TYPE_STRUCT_OPS = 26, + __ctx_convertBPF_PROG_TYPE_EXT = 27, + __ctx_convertBPF_PROG_TYPE_LSM = 28, + __ctx_convert_unused = 29, +}; + +enum bpf_struct_walk_result { + WALK_SCALAR = 0, + WALK_PTR = 1, + WALK_STRUCT = 2, +}; + +struct btf_show_snprintf { + struct btf_show show; + int len_left; + int len; +}; + +struct btf_module { + struct list_head list; + struct module *module; + struct btf *btf; + struct bin_attribute *sysfs_attr; +}; + +struct bpf_dispatcher_prog { + struct bpf_prog *prog; + refcount_t users; +}; + +struct bpf_dispatcher { + struct mutex mutex; + void *func; + struct bpf_dispatcher_prog progs[48]; + int num_progs; + void *image; + u32 image_off; + struct bpf_ksym ksym; +}; + +struct bpf_devmap_val { + __u32 ifindex; + union { + int fd; + __u32 id; + } bpf_prog; +}; + +enum net_device_flags { + IFF_UP = 1, + IFF_BROADCAST = 2, + IFF_DEBUG = 4, + IFF_LOOPBACK = 8, + IFF_POINTOPOINT = 16, + IFF_NOTRAILERS = 32, + IFF_RUNNING = 64, + IFF_NOARP = 128, + IFF_PROMISC = 256, + IFF_ALLMULTI = 512, + IFF_MASTER = 1024, + IFF_SLAVE = 2048, + IFF_MULTICAST = 4096, + IFF_PORTSEL = 8192, + IFF_AUTOMEDIA = 16384, + IFF_DYNAMIC = 32768, + IFF_LOWER_UP = 65536, + IFF_DORMANT = 131072, + IFF_ECHO = 262144, +}; + +struct xdp_dev_bulk_queue { + struct xdp_frame *q[16]; + struct list_head flush_node; + struct net_device *dev; + struct net_device *dev_rx; + unsigned int count; +}; + +enum netdev_cmd { + NETDEV_UP = 1, + NETDEV_DOWN = 2, + NETDEV_REBOOT = 3, + NETDEV_CHANGE = 4, + NETDEV_REGISTER = 5, + NETDEV_UNREGISTER = 6, + NETDEV_CHANGEMTU = 7, + NETDEV_CHANGEADDR = 8, + NETDEV_PRE_CHANGEADDR = 9, + NETDEV_GOING_DOWN = 10, + NETDEV_CHANGENAME = 11, + NETDEV_FEAT_CHANGE = 12, + NETDEV_BONDING_FAILOVER = 13, + NETDEV_PRE_UP = 14, + NETDEV_PRE_TYPE_CHANGE = 15, + NETDEV_POST_TYPE_CHANGE = 16, + NETDEV_POST_INIT = 17, + NETDEV_RELEASE = 18, + NETDEV_NOTIFY_PEERS = 19, + NETDEV_JOIN = 20, + NETDEV_CHANGEUPPER = 21, + NETDEV_RESEND_IGMP = 22, + NETDEV_PRECHANGEMTU = 23, + NETDEV_CHANGEINFODATA = 24, + NETDEV_BONDING_INFO = 25, + NETDEV_PRECHANGEUPPER = 26, + NETDEV_CHANGELOWERSTATE = 27, + NETDEV_UDP_TUNNEL_PUSH_INFO = 28, + NETDEV_UDP_TUNNEL_DROP_INFO = 29, + NETDEV_CHANGE_TX_QUEUE_LEN = 30, + NETDEV_CVLAN_FILTER_PUSH_INFO = 31, + NETDEV_CVLAN_FILTER_DROP_INFO = 32, + NETDEV_SVLAN_FILTER_PUSH_INFO = 33, + NETDEV_SVLAN_FILTER_DROP_INFO = 34, +}; + +struct netdev_notifier_info { + struct net_device *dev; + struct netlink_ext_ack *extack; +}; + +struct bpf_dtab; + +struct bpf_dtab_netdev { + struct net_device *dev; + struct hlist_node index_hlist; + struct bpf_dtab *dtab; + struct bpf_prog *xdp_prog; + struct callback_head rcu; + unsigned int idx; + struct bpf_devmap_val val; +}; + +struct bpf_dtab { + struct bpf_map map; + struct bpf_dtab_netdev **netdev_map; + struct list_head list; + struct hlist_head *dev_index_head; + spinlock_t index_lock; + unsigned int items; + u32 n_buckets; +}; + +struct bpf_cpumap_val { + __u32 qsize; + union { + int fd; + __u32 id; + } bpf_prog; +}; + +typedef struct bio_vec skb_frag_t; + +struct skb_shared_hwtstamps { + ktime_t hwtstamp; +}; + +struct skb_shared_info { + __u8 __unused; + __u8 meta_len; + __u8 nr_frags; + __u8 tx_flags; + short unsigned int gso_size; + short unsigned int gso_segs; + struct sk_buff *frag_list; + struct skb_shared_hwtstamps hwtstamps; + unsigned int gso_type; + u32 tskey; + atomic_t dataref; + void *destructor_arg; + skb_frag_t frags[17]; +}; + +struct bpf_nh_params { + u32 nh_family; + union { + u32 ipv4_nh; + struct in6_addr ipv6_nh; + }; +}; + +struct bpf_redirect_info { + u32 flags; + u32 tgt_index; + void *tgt_value; + struct bpf_map *map; + u32 kern_flags; + struct bpf_nh_params nh; +}; + +struct ptr_ring { + int producer; + spinlock_t producer_lock; + long: 64; + long: 64; + long: 64; + long: 64; + int consumer_head; + int consumer_tail; + spinlock_t consumer_lock; + long: 64; + long: 64; + long: 64; + long: 64; + int size; + int batch; + void **queue; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct bpf_cpu_map_entry; + +struct xdp_bulk_queue { + void *q[8]; + struct list_head flush_node; + struct bpf_cpu_map_entry *obj; + unsigned int count; +}; + +struct bpf_cpu_map; + +struct bpf_cpu_map_entry { + u32 cpu; + int map_id; + struct xdp_bulk_queue *bulkq; + struct bpf_cpu_map *cmap; + struct ptr_ring *queue; + struct task_struct *kthread; + struct bpf_cpumap_val value; + struct bpf_prog *prog; + atomic_t refcnt; + struct callback_head rcu; + struct work_struct kthread_stop_wq; +}; + +struct bpf_cpu_map { + struct bpf_map map; + struct bpf_cpu_map_entry **cpu_map; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct rhlist_head { + struct rhash_head rhead; + struct rhlist_head *next; +}; + +struct bpf_prog_offload_ops { + int (*insn_hook)(struct bpf_verifier_env *, int, int); + int (*finalize)(struct bpf_verifier_env *); + int (*replace_insn)(struct bpf_verifier_env *, u32, struct bpf_insn *); + int (*remove_insns)(struct bpf_verifier_env *, u32, u32); + int (*prepare)(struct bpf_prog *); + int (*translate)(struct bpf_prog *); + void (*destroy)(struct bpf_prog *); +}; + +struct bpf_offload_dev { + const struct bpf_prog_offload_ops *ops; + struct list_head netdevs; + void *priv; +}; + +struct bpf_offload_netdev { + struct rhash_head l; + struct net_device *netdev; + struct bpf_offload_dev *offdev; + struct list_head progs; + struct list_head maps; + struct list_head offdev_netdevs; +}; + +struct ns_get_path_bpf_prog_args { + struct bpf_prog *prog; + struct bpf_prog_info *info; +}; + +struct ns_get_path_bpf_map_args { + struct bpf_offloaded_map *offmap; + struct bpf_map_info *info; +}; + +struct bpf_netns_link { + struct bpf_link link; + enum bpf_attach_type type; + enum netns_bpf_attach_type netns_type; + struct net *net; + struct list_head node; +}; + +enum bpf_stack_build_id_status { + BPF_STACK_BUILD_ID_EMPTY = 0, + BPF_STACK_BUILD_ID_VALID = 1, + BPF_STACK_BUILD_ID_IP = 2, +}; + +struct bpf_stack_build_id { + __s32 status; + unsigned char build_id[20]; + union { + __u64 offset; + __u64 ip; + }; +}; + +enum { + BPF_F_SKIP_FIELD_MASK = 255, + BPF_F_USER_STACK = 256, + BPF_F_FAST_STACK_CMP = 512, + BPF_F_REUSE_STACKID = 1024, + BPF_F_USER_BUILD_ID = 2048, +}; + +typedef __u32 Elf32_Addr; + +typedef __u16 Elf32_Half; + +typedef __u32 Elf32_Off; + +struct elf32_hdr { + unsigned char e_ident[16]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +}; + +typedef struct elf32_hdr Elf32_Ehdr; + +struct elf32_phdr { + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +}; + +typedef struct elf32_phdr Elf32_Phdr; + +struct elf64_phdr { + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; +}; + +typedef struct elf64_phdr Elf64_Phdr; + +typedef struct elf32_note Elf32_Nhdr; + +enum perf_callchain_context { + PERF_CONTEXT_HV = 4294967264, + PERF_CONTEXT_KERNEL = 4294967168, + PERF_CONTEXT_USER = 4294966784, + PERF_CONTEXT_GUEST = 4294965248, + PERF_CONTEXT_GUEST_KERNEL = 4294965120, + PERF_CONTEXT_GUEST_USER = 4294964736, + PERF_CONTEXT_MAX = 4294963201, +}; + +struct stack_map_bucket { + struct pcpu_freelist_node fnode; + u32 hash; + u32 nr; + u64 data[0]; +}; + +struct bpf_stack_map { + struct bpf_map map; + void *elems; + struct pcpu_freelist freelist; + u32 n_buckets; + struct stack_map_bucket *buckets[0]; + long: 64; +}; + +struct stack_map_irq_work { + struct irq_work irq_work; + struct mm_struct *mm; +}; + +typedef u64 (*btf_bpf_get_stackid)(struct pt_regs *, struct bpf_map *, u64); + +typedef u64 (*btf_bpf_get_stackid_pe)(struct bpf_perf_event_data_kern *, struct bpf_map *, u64); + +typedef u64 (*btf_bpf_get_stack)(struct pt_regs *, void *, u32, u64); + +typedef u64 (*btf_bpf_get_task_stack)(struct task_struct *, void *, u32, u64); + +typedef u64 (*btf_bpf_get_stack_pe)(struct bpf_perf_event_data_kern *, void *, u32, u64); + +enum { + BPF_F_SYSCTL_BASE_NAME = 1, +}; + +struct bpf_prog_list { + struct list_head node; + struct bpf_prog *prog; + struct bpf_cgroup_link *link; + struct bpf_cgroup_storage *storage[2]; +}; + +struct qdisc_skb_cb { + struct { + unsigned int pkt_len; + u16 slave_dev_queue_mapping; + u16 tc_classid; + }; + unsigned char data[20]; + u16 mru; +}; + +struct bpf_skb_data_end { + struct qdisc_skb_cb qdisc_cb; + void *data_meta; + void *data_end; +}; + +enum { + TCPF_ESTABLISHED = 2, + TCPF_SYN_SENT = 4, + TCPF_SYN_RECV = 8, + TCPF_FIN_WAIT1 = 16, + TCPF_FIN_WAIT2 = 32, + TCPF_TIME_WAIT = 64, + TCPF_CLOSE = 128, + TCPF_CLOSE_WAIT = 256, + TCPF_LAST_ACK = 512, + TCPF_LISTEN = 1024, + TCPF_CLOSING = 2048, + TCPF_NEW_SYN_RECV = 4096, +}; + +typedef u64 (*btf_bpf_sysctl_get_name)(struct bpf_sysctl_kern *, char *, size_t, u64); + +typedef u64 (*btf_bpf_sysctl_get_current_value)(struct bpf_sysctl_kern *, char *, size_t); + +typedef u64 (*btf_bpf_sysctl_get_new_value)(struct bpf_sysctl_kern *, char *, size_t); + +typedef u64 (*btf_bpf_sysctl_set_new_value)(struct bpf_sysctl_kern *, const char *, size_t); + +enum sock_type { + SOCK_STREAM = 1, + SOCK_DGRAM = 2, + SOCK_RAW = 3, + SOCK_RDM = 4, + SOCK_SEQPACKET = 5, + SOCK_DCCP = 6, + SOCK_PACKET = 10, +}; + +enum { + IPPROTO_IP = 0, + IPPROTO_ICMP = 1, + IPPROTO_IGMP = 2, + IPPROTO_IPIP = 4, + IPPROTO_TCP = 6, + IPPROTO_EGP = 8, + IPPROTO_PUP = 12, + IPPROTO_UDP = 17, + IPPROTO_IDP = 22, + IPPROTO_TP = 29, + IPPROTO_DCCP = 33, + IPPROTO_IPV6 = 41, + IPPROTO_RSVP = 46, + IPPROTO_GRE = 47, + IPPROTO_ESP = 50, + IPPROTO_AH = 51, + IPPROTO_MTP = 92, + IPPROTO_BEETPH = 94, + IPPROTO_ENCAP = 98, + IPPROTO_PIM = 103, + IPPROTO_COMP = 108, + IPPROTO_SCTP = 132, + IPPROTO_UDPLITE = 136, + IPPROTO_MPLS = 137, + IPPROTO_ETHERNET = 143, + IPPROTO_RAW = 255, + IPPROTO_MPTCP = 262, + IPPROTO_MAX = 263, +}; + +enum sock_flags { + SOCK_DEAD = 0, + SOCK_DONE = 1, + SOCK_URGINLINE = 2, + SOCK_KEEPOPEN = 3, + SOCK_LINGER = 4, + SOCK_DESTROY = 5, + SOCK_BROADCAST = 6, + SOCK_TIMESTAMP = 7, + SOCK_ZAPPED = 8, + SOCK_USE_WRITE_QUEUE = 9, + SOCK_DBG = 10, + SOCK_RCVTSTAMP = 11, + SOCK_RCVTSTAMPNS = 12, + SOCK_LOCALROUTE = 13, + SOCK_MEMALLOC = 14, + SOCK_TIMESTAMPING_RX_SOFTWARE = 15, + SOCK_FASYNC = 16, + SOCK_RXQ_OVFL = 17, + SOCK_ZEROCOPY = 18, + SOCK_WIFI_STATUS = 19, + SOCK_NOFCS = 20, + SOCK_FILTER_LOCKED = 21, + SOCK_SELECT_ERR_QUEUE = 22, + SOCK_RCU_FREE = 23, + SOCK_TXTIME = 24, + SOCK_XDP = 25, + SOCK_TSTAMP_NEW = 26, +}; + +struct reuseport_array { + struct bpf_map map; + struct sock *ptrs[0]; +}; + +enum bpf_struct_ops_state { + BPF_STRUCT_OPS_STATE_INIT = 0, + BPF_STRUCT_OPS_STATE_INUSE = 1, + BPF_STRUCT_OPS_STATE_TOBEFREE = 2, +}; + +struct bpf_struct_ops_value { + refcount_t refcnt; + enum bpf_struct_ops_state state; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + char data[0]; +}; + +struct bpf_struct_ops_map { + struct bpf_map map; + const struct bpf_struct_ops *st_ops; + struct mutex lock; + struct bpf_prog **progs; + void *image; + struct bpf_struct_ops_value *uvalue; + long: 64; + long: 64; + long: 64; + long: 64; + struct bpf_struct_ops_value kvalue; +}; + +struct bpf_struct_ops_tcp_congestion_ops { + refcount_t refcnt; + enum bpf_struct_ops_state state; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct tcp_congestion_ops data; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct sembuf { + short unsigned int sem_num; + short int sem_op; + short int sem_flg; +}; + +enum key_need_perm { + KEY_NEED_UNSPECIFIED = 0, + KEY_NEED_VIEW = 1, + KEY_NEED_READ = 2, + KEY_NEED_WRITE = 3, + KEY_NEED_SEARCH = 4, + KEY_NEED_LINK = 5, + KEY_NEED_SETATTR = 6, + KEY_NEED_UNLINK = 7, + KEY_SYSADMIN_OVERRIDE = 8, + KEY_AUTHTOKEN_OVERRIDE = 9, + KEY_DEFER_PERM_CHECK = 10, +}; + +struct __key_reference_with_attributes; + +typedef struct __key_reference_with_attributes *key_ref_t; + +enum { + BPF_F_BPRM_SECUREEXEC = 1, +}; + +typedef u64 (*btf_bpf_bprm_opts_set)(struct linux_binprm *, u64); + +typedef u64 (*btf_bpf_ima_inode_hash)(struct inode *, void *, u32); + +enum perf_event_read_format { + PERF_FORMAT_TOTAL_TIME_ENABLED = 1, + PERF_FORMAT_TOTAL_TIME_RUNNING = 2, + PERF_FORMAT_ID = 4, + PERF_FORMAT_GROUP = 8, + PERF_FORMAT_MAX = 16, +}; + +enum perf_event_ioc_flags { + PERF_IOC_FLAG_GROUP = 1, +}; + +struct perf_ns_link_info { + __u64 dev; + __u64 ino; +}; + +enum { + NET_NS_INDEX = 0, + UTS_NS_INDEX = 1, + IPC_NS_INDEX = 2, + PID_NS_INDEX = 3, + USER_NS_INDEX = 4, + MNT_NS_INDEX = 5, + CGROUP_NS_INDEX = 6, + NR_NAMESPACES = 7, +}; + +enum perf_event_type { + PERF_RECORD_MMAP = 1, + PERF_RECORD_LOST = 2, + PERF_RECORD_COMM = 3, + PERF_RECORD_EXIT = 4, + PERF_RECORD_THROTTLE = 5, + PERF_RECORD_UNTHROTTLE = 6, + PERF_RECORD_FORK = 7, + PERF_RECORD_READ = 8, + PERF_RECORD_SAMPLE = 9, + PERF_RECORD_MMAP2 = 10, + PERF_RECORD_AUX = 11, + PERF_RECORD_ITRACE_START = 12, + PERF_RECORD_LOST_SAMPLES = 13, + PERF_RECORD_SWITCH = 14, + PERF_RECORD_SWITCH_CPU_WIDE = 15, + PERF_RECORD_NAMESPACES = 16, + PERF_RECORD_KSYMBOL = 17, + PERF_RECORD_BPF_EVENT = 18, + PERF_RECORD_CGROUP = 19, + PERF_RECORD_TEXT_POKE = 20, + PERF_RECORD_MAX = 21, +}; + +struct swevent_hlist { + struct hlist_head heads[256]; + struct callback_head callback_head; +}; + +struct pmu_event_list { + raw_spinlock_t lock; + struct list_head list; +}; + +struct perf_buffer { + refcount_t refcount; + struct callback_head callback_head; + int nr_pages; + int overwrite; + int paused; + atomic_t poll; + local_t head; + unsigned int nest; + local_t events; + local_t wakeup; + local_t lost; + long int watermark; + long int aux_watermark; + spinlock_t event_lock; + struct list_head event_list; + atomic_t mmap_count; + long unsigned int mmap_locked; + struct user_struct *mmap_user; + long int aux_head; + unsigned int aux_nest; + long int aux_wakeup; + long unsigned int aux_pgoff; + int aux_nr_pages; + int aux_overwrite; + atomic_t aux_mmap_count; + long unsigned int aux_mmap_locked; + void (*free_aux)(void *); + refcount_t aux_refcount; + int aux_in_sampling; + void **aux_pages; + void *aux_priv; + struct perf_event_mmap_page *user_page; + void *data_pages[0]; +}; + +struct match_token { + int token; + const char *pattern; +}; + +enum { + MAX_OPT_ARGS = 3, +}; + +typedef struct { + char *from; + char *to; +} substring_t; + +struct min_heap { + void *data; + int nr; + int size; +}; + +struct min_heap_callbacks { + int elem_size; + bool (*less)(const void *, const void *); + void (*swp)(void *, void *); +}; + +typedef int (*remote_function_f)(void *); + +struct remote_function_call { + struct task_struct *p; + remote_function_f func; + void *info; + int ret; +}; + +typedef void (*event_f)(struct perf_event *, struct perf_cpu_context *, struct perf_event_context *, void *); + +struct event_function_struct { + struct perf_event *event; + event_f func; + void *data; +}; + +enum event_type_t { + EVENT_FLEXIBLE = 1, + EVENT_PINNED = 2, + EVENT_TIME = 4, + EVENT_CPU = 8, + EVENT_ALL = 3, +}; + +struct stop_event_data { + struct perf_event *event; + unsigned int restart; +}; + +struct perf_read_data { + struct perf_event *event; + bool group; + int ret; +}; + +struct perf_read_event { + struct perf_event_header header; + u32 pid; + u32 tid; +}; + +typedef void perf_iterate_f(struct perf_event *, void *); + +struct remote_output { + struct perf_buffer *rb; + int err; +}; + +struct perf_task_event { + struct task_struct *task; + struct perf_event_context *task_ctx; + struct { + struct perf_event_header header; + u32 pid; + u32 ppid; + u32 tid; + u32 ptid; + u64 time; + } event_id; +}; + +struct perf_comm_event { + struct task_struct *task; + char *comm; + int comm_size; + struct { + struct perf_event_header header; + u32 pid; + u32 tid; + } event_id; +}; + +struct perf_namespaces_event { + struct task_struct *task; + struct { + struct perf_event_header header; + u32 pid; + u32 tid; + u64 nr_namespaces; + struct perf_ns_link_info link_info[7]; + } event_id; +}; + +struct perf_cgroup_event { + char *path; + int path_size; + struct { + struct perf_event_header header; + u64 id; + char path[0]; + } event_id; +}; + +struct perf_mmap_event { + struct vm_area_struct *vma; + const char *file_name; + int file_size; + int maj; + int min; + u64 ino; + u64 ino_generation; + u32 prot; + u32 flags; + struct { + struct perf_event_header header; + u32 pid; + u32 tid; + u64 start; + u64 len; + u64 pgoff; + } event_id; +}; + +struct perf_switch_event { + struct task_struct *task; + struct task_struct *next_prev; + struct { + struct perf_event_header header; + u32 next_prev_pid; + u32 next_prev_tid; + } event_id; +}; + +struct perf_ksymbol_event { + const char *name; + int name_len; + struct { + struct perf_event_header header; + u64 addr; + u32 len; + u16 ksym_type; + u16 flags; + } event_id; +}; + +struct perf_bpf_event { + struct bpf_prog *prog; + struct { + struct perf_event_header header; + u16 type; + u16 flags; + u32 id; + u8 tag[8]; + } event_id; +}; + +struct perf_text_poke_event { + const void *old_bytes; + const void *new_bytes; + size_t pad; + u16 old_len; + u16 new_len; + struct { + struct perf_event_header header; + u64 addr; + } event_id; +}; + +struct swevent_htable { + struct swevent_hlist *swevent_hlist; + struct mutex hlist_mutex; + int hlist_refcount; + int recursion[4]; +}; + +enum perf_probe_config { + PERF_PROBE_CONFIG_IS_RETPROBE = 1, + PERF_UPROBE_REF_CTR_OFFSET_BITS = 32, + PERF_UPROBE_REF_CTR_OFFSET_SHIFT = 32, +}; + +enum { + IF_ACT_NONE = 4294967295, + IF_ACT_FILTER = 0, + IF_ACT_START = 1, + IF_ACT_STOP = 2, + IF_SRC_FILE = 3, + IF_SRC_KERNEL = 4, + IF_SRC_FILEADDR = 5, + IF_SRC_KERNELADDR = 6, +}; + +enum { + IF_STATE_ACTION = 0, + IF_STATE_SOURCE = 1, + IF_STATE_END = 2, +}; + +struct perf_aux_event { + struct perf_event_header header; + u32 pid; + u32 tid; +}; + +struct perf_aux_event___2 { + struct perf_event_header header; + u64 offset; + u64 size; + u64 flags; +}; + +struct callchain_cpus_entries { + struct callback_head callback_head; + struct perf_callchain_entry *cpu_entries[0]; +}; + +enum bp_type_idx { + TYPE_INST = 0, + TYPE_DATA = 0, + TYPE_MAX = 1, +}; + +struct bp_cpuinfo { + unsigned int cpu_pinned; + unsigned int *tsk_pinned; + unsigned int flexible; +}; + +struct bp_busy_slots { + unsigned int pinned; + unsigned int flexible; +}; + +typedef u8 uprobe_opcode_t; + +struct uprobe { + struct rb_node rb_node; + refcount_t ref; + struct rw_semaphore register_rwsem; + struct rw_semaphore consumer_rwsem; + struct list_head pending_list; + struct uprobe_consumer *consumers; + struct inode *inode; + loff_t offset; + loff_t ref_ctr_offset; + long unsigned int flags; + struct arch_uprobe arch; +}; + +struct xol_area { + wait_queue_head_t wq; + atomic_t slot_count; + long unsigned int *bitmap; + struct vm_special_mapping xol_mapping; + struct page *pages[2]; + long unsigned int vaddr; +}; + +typedef long unsigned int vm_flags_t; + +struct compact_control; + +struct capture_control { + struct compact_control *cc; + struct page *page; +}; + +struct page_vma_mapped_walk { + struct page *page; + struct vm_area_struct *vma; + long unsigned int address; + pmd_t *pmd; + pte_t *pte; + spinlock_t *ptl; + unsigned int flags; +}; + +struct compact_control { + struct list_head freepages; + struct list_head migratepages; + unsigned int nr_freepages; + unsigned int nr_migratepages; + long unsigned int free_pfn; + long unsigned int migrate_pfn; + long unsigned int fast_start_pfn; + struct zone *zone; + long unsigned int total_migrate_scanned; + long unsigned int total_free_scanned; + short unsigned int fast_search_fail; + short int search_order; + const gfp_t gfp_mask; + int order; + int migratetype; + const unsigned int alloc_flags; + const int highest_zoneidx; + enum migrate_mode mode; + bool ignore_skip_hint; + bool no_set_skip_hint; + bool ignore_block_suitable; + bool direct_compaction; + bool proactive_compaction; + bool whole_zone; + bool contended; + bool rescan; + bool alloc_contig; +}; + +struct delayed_uprobe { + struct list_head list; + struct uprobe *uprobe; + struct mm_struct *mm; +}; + +struct map_info { + struct map_info *next; + struct mm_struct *mm; + long unsigned int vaddr; +}; + +struct user_return_notifier { + void (*on_user_return)(struct user_return_notifier *); + struct hlist_node link; +}; + +struct static_key_mod { + struct static_key_mod *next; + struct jump_entry *entries; + struct module *mod; +}; + +struct static_key_deferred { + struct static_key key; + long unsigned int timeout; + struct delayed_work work; +}; + +enum rseq_cpu_id_state { + RSEQ_CPU_ID_UNINITIALIZED = 4294967295, + RSEQ_CPU_ID_REGISTRATION_FAILED = 4294967294, +}; + +enum rseq_flags { + RSEQ_FLAG_UNREGISTER = 1, +}; + +enum rseq_cs_flags { + RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT = 1, + RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL = 2, + RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE = 4, +}; + +struct rseq_cs { + __u32 version; + __u32 flags; + __u64 start_ip; + __u64 post_commit_offset; + __u64 abort_ip; +}; + +struct trace_event_raw_rseq_update { + struct trace_entry ent; + s32 cpu_id; + char __data[0]; +}; + +struct trace_event_raw_rseq_ip_fixup { + struct trace_entry ent; + long unsigned int regs_ip; + long unsigned int start_ip; + long unsigned int post_commit_offset; + long unsigned int abort_ip; + char __data[0]; +}; + +struct trace_event_data_offsets_rseq_update {}; + +struct trace_event_data_offsets_rseq_ip_fixup {}; + +typedef void (*btf_trace_rseq_update)(void *, struct task_struct *); + +typedef void (*btf_trace_rseq_ip_fixup)(void *, long unsigned int, long unsigned int, long unsigned int, long unsigned int); + +struct pkcs7_message; + +typedef void (*xa_update_node_t)(struct xa_node *); + +struct xa_state { + struct xarray *xa; + long unsigned int xa_index; + unsigned char xa_shift; + unsigned char xa_sibs; + unsigned char xa_offset; + unsigned char xa_pad; + struct xa_node *xa_node; + struct xa_node *xa_alloc; + xa_update_node_t xa_update; +}; + +typedef int __kernel_rwf_t; + +enum positive_aop_returns { + AOP_WRITEPAGE_ACTIVATE = 524288, + AOP_TRUNCATED_PAGE = 524289, +}; + +struct vm_event_state { + long unsigned int event[96]; +}; + +enum mapping_flags { + AS_EIO = 0, + AS_ENOSPC = 1, + AS_MM_ALL_LOCKS = 2, + AS_UNEVICTABLE = 3, + AS_EXITING = 4, + AS_NO_WRITEBACK_TAGS = 5, + AS_THP_SUPPORT = 6, +}; + +struct wait_page_key { + struct page *page; + int bit_nr; + int page_match; +}; + +enum iter_type { + ITER_IOVEC = 4, + ITER_KVEC = 8, + ITER_BVEC = 16, + ITER_PIPE = 32, + ITER_DISCARD = 64, +}; + +struct pagevec { + unsigned char nr; + bool percpu_pvec_drained; + struct page *pages[15]; +}; + +struct fid { + union { + struct { + u32 ino; + u32 gen; + u32 parent_ino; + u32 parent_gen; + } i32; + struct { + u32 block; + u16 partref; + u16 parent_partref; + u32 generation; + u32 parent_block; + u32 parent_generation; + } udf; + __u32 raw[0]; + }; +}; + +struct trace_event_raw_mm_filemap_op_page_cache { + struct trace_entry ent; + long unsigned int pfn; + long unsigned int i_ino; + long unsigned int index; + dev_t s_dev; + char __data[0]; +}; + +struct trace_event_raw_filemap_set_wb_err { + struct trace_entry ent; + long unsigned int i_ino; + dev_t s_dev; + errseq_t errseq; + char __data[0]; +}; + +struct trace_event_raw_file_check_and_advance_wb_err { + struct trace_entry ent; + struct file *file; + long unsigned int i_ino; + dev_t s_dev; + errseq_t old; + errseq_t new; + char __data[0]; +}; + +struct trace_event_data_offsets_mm_filemap_op_page_cache {}; + +struct trace_event_data_offsets_filemap_set_wb_err {}; + +struct trace_event_data_offsets_file_check_and_advance_wb_err {}; + +typedef void (*btf_trace_mm_filemap_delete_from_page_cache)(void *, struct page *); + +typedef void (*btf_trace_mm_filemap_add_to_page_cache)(void *, struct page *); + +typedef void (*btf_trace_filemap_set_wb_err)(void *, struct address_space *, errseq_t); + +typedef void (*btf_trace_file_check_and_advance_wb_err)(void *, struct file *, errseq_t); + +enum behavior { + EXCLUSIVE = 0, + SHARED = 1, + DROP = 2, +}; + +struct reciprocal_value { + u32 m; + u8 sh1; + u8 sh2; +}; + +struct kmem_cache_order_objects { + unsigned int x; +}; + +struct kmem_cache_cpu; + +struct kmem_cache_node; + +struct kmem_cache { + struct kmem_cache_cpu *cpu_slab; + slab_flags_t flags; + long unsigned int min_partial; + unsigned int size; + unsigned int object_size; + struct reciprocal_value reciprocal_size; + unsigned int offset; + unsigned int cpu_partial; + struct kmem_cache_order_objects oo; + struct kmem_cache_order_objects max; + struct kmem_cache_order_objects min; + gfp_t allocflags; + int refcount; + void (*ctor)(void *); + unsigned int inuse; + unsigned int align; + unsigned int red_left_pad; + const char *name; + struct list_head list; + struct kobject kobj; + unsigned int remote_node_defrag_ratio; + unsigned int useroffset; + unsigned int usersize; + struct kmem_cache_node *node[64]; +}; + +struct kmem_cache_cpu { + void **freelist; + long unsigned int tid; + struct page *page; + struct page *partial; +}; + +struct kmem_cache_node { + spinlock_t list_lock; + long unsigned int nr_partial; + struct list_head partial; + atomic_long_t nr_slabs; + atomic_long_t total_objects; + struct list_head full; +}; + +enum oom_constraint { + CONSTRAINT_NONE = 0, + CONSTRAINT_CPUSET = 1, + CONSTRAINT_MEMORY_POLICY = 2, + CONSTRAINT_MEMCG = 3, +}; + +struct oom_control { + struct zonelist *zonelist; + nodemask_t *nodemask; + struct mem_cgroup *memcg; + const gfp_t gfp_mask; + const int order; + long unsigned int totalpages; + struct task_struct *chosen; + long int chosen_points; + enum oom_constraint constraint; +}; + +enum compact_priority { + COMPACT_PRIO_SYNC_FULL = 0, + MIN_COMPACT_PRIORITY = 0, + COMPACT_PRIO_SYNC_LIGHT = 1, + MIN_COMPACT_COSTLY_PRIORITY = 1, + DEF_COMPACT_PRIORITY = 1, + COMPACT_PRIO_ASYNC = 2, + INIT_COMPACT_PRIORITY = 2, +}; + +enum compact_result { + COMPACT_NOT_SUITABLE_ZONE = 0, + COMPACT_SKIPPED = 1, + COMPACT_DEFERRED = 2, + COMPACT_NO_SUITABLE_PAGE = 3, + COMPACT_CONTINUE = 4, + COMPACT_COMPLETE = 5, + COMPACT_PARTIAL_SKIPPED = 6, + COMPACT_CONTENDED = 7, + COMPACT_SUCCESS = 8, +}; + +struct trace_event_raw_oom_score_adj_update { + struct trace_entry ent; + pid_t pid; + char comm[16]; + short int oom_score_adj; + char __data[0]; +}; + +struct trace_event_raw_reclaim_retry_zone { + struct trace_entry ent; + int node; + int zone_idx; + int order; + long unsigned int reclaimable; + long unsigned int available; + long unsigned int min_wmark; + int no_progress_loops; + bool wmark_check; + char __data[0]; +}; + +struct trace_event_raw_mark_victim { + struct trace_entry ent; + int pid; + char __data[0]; +}; + +struct trace_event_raw_wake_reaper { + struct trace_entry ent; + int pid; + char __data[0]; +}; + +struct trace_event_raw_start_task_reaping { + struct trace_entry ent; + int pid; + char __data[0]; +}; + +struct trace_event_raw_finish_task_reaping { + struct trace_entry ent; + int pid; + char __data[0]; +}; + +struct trace_event_raw_skip_task_reaping { + struct trace_entry ent; + int pid; + char __data[0]; +}; + +struct trace_event_raw_compact_retry { + struct trace_entry ent; + int order; + int priority; + int result; + int retries; + int max_retries; + bool ret; + char __data[0]; +}; + +struct trace_event_data_offsets_oom_score_adj_update {}; + +struct trace_event_data_offsets_reclaim_retry_zone {}; + +struct trace_event_data_offsets_mark_victim {}; + +struct trace_event_data_offsets_wake_reaper {}; + +struct trace_event_data_offsets_start_task_reaping {}; + +struct trace_event_data_offsets_finish_task_reaping {}; + +struct trace_event_data_offsets_skip_task_reaping {}; + +struct trace_event_data_offsets_compact_retry {}; + +typedef void (*btf_trace_oom_score_adj_update)(void *, struct task_struct *); + +typedef void (*btf_trace_reclaim_retry_zone)(void *, struct zoneref *, int, long unsigned int, long unsigned int, long unsigned int, int, bool); + +typedef void (*btf_trace_mark_victim)(void *, int); + +typedef void (*btf_trace_wake_reaper)(void *, int); + +typedef void (*btf_trace_start_task_reaping)(void *, int); + +typedef void (*btf_trace_finish_task_reaping)(void *, int); + +typedef void (*btf_trace_skip_task_reaping)(void *, int); + +typedef void (*btf_trace_compact_retry)(void *, int, enum compact_priority, enum compact_result, int, int, bool); + +enum wb_congested_state { + WB_async_congested = 0, + WB_sync_congested = 1, +}; + +enum { + XA_CHECK_SCHED = 4096, +}; + +enum wb_state { + WB_registered = 0, + WB_writeback_running = 1, + WB_has_dirty_io = 2, + WB_start_all = 3, +}; + +enum { + BLK_RW_ASYNC = 0, + BLK_RW_SYNC = 1, +}; + +struct wb_lock_cookie { + bool locked; + long unsigned int flags; +}; + +typedef int (*writepage_t)(struct page *, struct writeback_control *, void *); + +struct dirty_throttle_control { + struct wb_domain *dom; + struct dirty_throttle_control *gdtc; + struct bdi_writeback *wb; + struct fprop_local_percpu *wb_completions; + long unsigned int avail; + long unsigned int dirty; + long unsigned int thresh; + long unsigned int bg_thresh; + long unsigned int wb_dirty; + long unsigned int wb_thresh; + long unsigned int wb_bg_thresh; + long unsigned int pos_ratio; +}; + +typedef void compound_page_dtor(struct page *); + +struct trace_event_raw_mm_lru_insertion { + struct trace_entry ent; + struct page *page; + long unsigned int pfn; + int lru; + long unsigned int flags; + char __data[0]; +}; + +struct trace_event_raw_mm_lru_activate { + struct trace_entry ent; + struct page *page; + long unsigned int pfn; + char __data[0]; +}; + +struct trace_event_data_offsets_mm_lru_insertion {}; + +struct trace_event_data_offsets_mm_lru_activate {}; + +typedef void (*btf_trace_mm_lru_insertion)(void *, struct page *, int); + +typedef void (*btf_trace_mm_lru_activate)(void *, struct page *); + +struct lru_rotate { + local_lock_t lock; + struct pagevec pvec; +}; + +struct lru_pvecs { + local_lock_t lock; + struct pagevec lru_add; + struct pagevec lru_deactivate_file; + struct pagevec lru_deactivate; + struct pagevec lru_lazyfree; + struct pagevec activate_page; +}; + +typedef struct { + long unsigned int val; +} swp_entry_t; + +enum lruvec_flags { + LRUVEC_CONGESTED = 0, +}; + +enum pgdat_flags { + PGDAT_DIRTY = 0, + PGDAT_WRITEBACK = 1, + PGDAT_RECLAIM_LOCKED = 2, +}; + +struct reclaim_stat { + unsigned int nr_dirty; + unsigned int nr_unqueued_dirty; + unsigned int nr_congested; + unsigned int nr_writeback; + unsigned int nr_immediate; + unsigned int nr_pageout; + unsigned int nr_activate[2]; + unsigned int nr_ref_keep; + unsigned int nr_unmap_fail; + unsigned int nr_lazyfree_fail; +}; + +enum ttu_flags { + TTU_MIGRATION = 1, + TTU_MUNLOCK = 2, + TTU_SPLIT_HUGE_PMD = 4, + TTU_IGNORE_MLOCK = 8, + TTU_IGNORE_ACCESS = 16, + TTU_IGNORE_HWPOISON = 32, + TTU_BATCH_FLUSH = 64, + TTU_RMAP_LOCKED = 128, + TTU_SPLIT_FREEZE = 256, +}; + +struct trace_event_raw_mm_vmscan_kswapd_sleep { + struct trace_entry ent; + int nid; + char __data[0]; +}; + +struct trace_event_raw_mm_vmscan_kswapd_wake { + struct trace_entry ent; + int nid; + int zid; + int order; + char __data[0]; +}; + +struct trace_event_raw_mm_vmscan_wakeup_kswapd { + struct trace_entry ent; + int nid; + int zid; + int order; + gfp_t gfp_flags; + char __data[0]; +}; + +struct trace_event_raw_mm_vmscan_direct_reclaim_begin_template { + struct trace_entry ent; + int order; + gfp_t gfp_flags; + char __data[0]; +}; + +struct trace_event_raw_mm_vmscan_direct_reclaim_end_template { + struct trace_entry ent; + long unsigned int nr_reclaimed; + char __data[0]; +}; + +struct trace_event_raw_mm_shrink_slab_start { + struct trace_entry ent; + struct shrinker *shr; + void *shrink; + int nid; + long int nr_objects_to_shrink; + gfp_t gfp_flags; + long unsigned int cache_items; + long long unsigned int delta; + long unsigned int total_scan; + int priority; + char __data[0]; +}; + +struct trace_event_raw_mm_shrink_slab_end { + struct trace_entry ent; + struct shrinker *shr; + int nid; + void *shrink; + long int unused_scan; + long int new_scan; + int retval; + long int total_scan; + char __data[0]; +}; + +struct trace_event_raw_mm_vmscan_lru_isolate { + struct trace_entry ent; + int highest_zoneidx; + int order; + long unsigned int nr_requested; + long unsigned int nr_scanned; + long unsigned int nr_skipped; + long unsigned int nr_taken; + isolate_mode_t isolate_mode; + int lru; + char __data[0]; +}; + +struct trace_event_raw_mm_vmscan_writepage { + struct trace_entry ent; + long unsigned int pfn; + int reclaim_flags; + char __data[0]; +}; + +struct trace_event_raw_mm_vmscan_lru_shrink_inactive { + struct trace_entry ent; + int nid; + long unsigned int nr_scanned; + long unsigned int nr_reclaimed; + long unsigned int nr_dirty; + long unsigned int nr_writeback; + long unsigned int nr_congested; + long unsigned int nr_immediate; + unsigned int nr_activate0; + unsigned int nr_activate1; + long unsigned int nr_ref_keep; + long unsigned int nr_unmap_fail; + int priority; + int reclaim_flags; + char __data[0]; +}; + +struct trace_event_raw_mm_vmscan_lru_shrink_active { + struct trace_entry ent; + int nid; + long unsigned int nr_taken; + long unsigned int nr_active; + long unsigned int nr_deactivated; + long unsigned int nr_referenced; + int priority; + int reclaim_flags; + char __data[0]; +}; + +struct trace_event_raw_mm_vmscan_inactive_list_is_low { + struct trace_entry ent; + int nid; + int reclaim_idx; + long unsigned int total_inactive; + long unsigned int inactive; + long unsigned int total_active; + long unsigned int active; + long unsigned int ratio; + int reclaim_flags; + char __data[0]; +}; + +struct trace_event_raw_mm_vmscan_node_reclaim_begin { + struct trace_entry ent; + int nid; + int order; + gfp_t gfp_flags; + char __data[0]; +}; + +struct trace_event_data_offsets_mm_vmscan_kswapd_sleep {}; + +struct trace_event_data_offsets_mm_vmscan_kswapd_wake {}; + +struct trace_event_data_offsets_mm_vmscan_wakeup_kswapd {}; + +struct trace_event_data_offsets_mm_vmscan_direct_reclaim_begin_template {}; + +struct trace_event_data_offsets_mm_vmscan_direct_reclaim_end_template {}; + +struct trace_event_data_offsets_mm_shrink_slab_start {}; + +struct trace_event_data_offsets_mm_shrink_slab_end {}; + +struct trace_event_data_offsets_mm_vmscan_lru_isolate {}; + +struct trace_event_data_offsets_mm_vmscan_writepage {}; + +struct trace_event_data_offsets_mm_vmscan_lru_shrink_inactive {}; + +struct trace_event_data_offsets_mm_vmscan_lru_shrink_active {}; + +struct trace_event_data_offsets_mm_vmscan_inactive_list_is_low {}; + +struct trace_event_data_offsets_mm_vmscan_node_reclaim_begin {}; + +typedef void (*btf_trace_mm_vmscan_kswapd_sleep)(void *, int); + +typedef void (*btf_trace_mm_vmscan_kswapd_wake)(void *, int, int, int); + +typedef void (*btf_trace_mm_vmscan_wakeup_kswapd)(void *, int, int, int, gfp_t); + +typedef void (*btf_trace_mm_vmscan_direct_reclaim_begin)(void *, int, gfp_t); + +typedef void (*btf_trace_mm_vmscan_memcg_reclaim_begin)(void *, int, gfp_t); + +typedef void (*btf_trace_mm_vmscan_memcg_softlimit_reclaim_begin)(void *, int, gfp_t); + +typedef void (*btf_trace_mm_vmscan_direct_reclaim_end)(void *, long unsigned int); + +typedef void (*btf_trace_mm_vmscan_memcg_reclaim_end)(void *, long unsigned int); + +typedef void (*btf_trace_mm_vmscan_memcg_softlimit_reclaim_end)(void *, long unsigned int); + +typedef void (*btf_trace_mm_shrink_slab_start)(void *, struct shrinker *, struct shrink_control *, long int, long unsigned int, long long unsigned int, long unsigned int, int); + +typedef void (*btf_trace_mm_shrink_slab_end)(void *, struct shrinker *, int, int, long int, long int, long int); + +typedef void (*btf_trace_mm_vmscan_lru_isolate)(void *, int, int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, isolate_mode_t, int); + +typedef void (*btf_trace_mm_vmscan_writepage)(void *, struct page *); + +typedef void (*btf_trace_mm_vmscan_lru_shrink_inactive)(void *, int, long unsigned int, long unsigned int, struct reclaim_stat *, int, int); + +typedef void (*btf_trace_mm_vmscan_lru_shrink_active)(void *, int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, int, int); + +typedef void (*btf_trace_mm_vmscan_inactive_list_is_low)(void *, int, int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, int); + +typedef void (*btf_trace_mm_vmscan_node_reclaim_begin)(void *, int, int, gfp_t); + +typedef void (*btf_trace_mm_vmscan_node_reclaim_end)(void *, long unsigned int); + +struct scan_control { + long unsigned int nr_to_reclaim; + nodemask_t *nodemask; + struct mem_cgroup *target_mem_cgroup; + long unsigned int anon_cost; + long unsigned int file_cost; + unsigned int may_deactivate: 2; + unsigned int force_deactivate: 1; + unsigned int skipped_deactivate: 1; + unsigned int may_writepage: 1; + unsigned int may_unmap: 1; + unsigned int may_swap: 1; + unsigned int memcg_low_reclaim: 1; + unsigned int memcg_low_skipped: 1; + unsigned int hibernation_mode: 1; + unsigned int compaction_ready: 1; + unsigned int cache_trim_mode: 1; + unsigned int file_is_tiny: 1; + s8 order; + s8 priority; + s8 reclaim_idx; + gfp_t gfp_mask; + long unsigned int nr_scanned; + long unsigned int nr_reclaimed; + struct { + unsigned int dirty; + unsigned int unqueued_dirty; + unsigned int congested; + unsigned int writeback; + unsigned int immediate; + unsigned int file_taken; + unsigned int taken; + } nr; + struct reclaim_state reclaim_state; +}; + +typedef enum { + PAGE_KEEP = 0, + PAGE_ACTIVATE = 1, + PAGE_SUCCESS = 2, + PAGE_CLEAN = 3, +} pageout_t; + +enum page_references { + PAGEREF_RECLAIM = 0, + PAGEREF_RECLAIM_CLEAN = 1, + PAGEREF_KEEP = 2, + PAGEREF_ACTIVATE = 3, +}; + +enum scan_balance { + SCAN_EQUAL = 0, + SCAN_FRACT = 1, + SCAN_ANON = 2, + SCAN_FILE = 3, +}; + +enum transparent_hugepage_flag { + TRANSPARENT_HUGEPAGE_FLAG = 0, + TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG = 1, + TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG = 2, + TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG = 3, + TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG = 4, + TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG = 5, + TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG = 6, + TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG = 7, +}; + +struct xattr { + const char *name; + void *value; + size_t value_len; +}; + +struct constant_table { + const char *name; + int value; +}; + +enum { + MPOL_DEFAULT = 0, + MPOL_PREFERRED = 1, + MPOL_BIND = 2, + MPOL_INTERLEAVE = 3, + MPOL_LOCAL = 4, + MPOL_MAX = 5, +}; + +struct shared_policy { + struct rb_root root; + rwlock_t lock; +}; + +struct simple_xattrs { + struct list_head head; + spinlock_t lock; +}; + +struct simple_xattr { + struct list_head list; + char *name; + size_t size; + char value[0]; +}; + +enum fid_type { + FILEID_ROOT = 0, + FILEID_INO32_GEN = 1, + FILEID_INO32_GEN_PARENT = 2, + FILEID_BTRFS_WITHOUT_PARENT = 77, + FILEID_BTRFS_WITH_PARENT = 78, + FILEID_BTRFS_WITH_PARENT_ROOT = 79, + FILEID_UDF_WITHOUT_PARENT = 81, + FILEID_UDF_WITH_PARENT = 82, + FILEID_NILFS_WITHOUT_PARENT = 97, + FILEID_NILFS_WITH_PARENT = 98, + FILEID_FAT_WITHOUT_PARENT = 113, + FILEID_FAT_WITH_PARENT = 114, + FILEID_LUSTRE = 151, + FILEID_KERNFS = 254, + FILEID_INVALID = 255, +}; + +struct shmem_inode_info { + spinlock_t lock; + unsigned int seals; + long unsigned int flags; + long unsigned int alloced; + long unsigned int swapped; + struct list_head shrinklist; + struct list_head swaplist; + struct shared_policy policy; + struct simple_xattrs xattrs; + atomic_t stop_eviction; + struct inode vfs_inode; +}; + +struct shmem_sb_info { + long unsigned int max_blocks; + struct percpu_counter used_blocks; + long unsigned int max_inodes; + long unsigned int free_inodes; + spinlock_t stat_lock; + umode_t mode; + unsigned char huge; + kuid_t uid; + kgid_t gid; + bool full_inums; + ino_t next_ino; + ino_t *ino_batch; + struct mempolicy *mpol; + spinlock_t shrinklist_lock; + struct list_head shrinklist; + long unsigned int shrinklist_len; +}; + +enum sgp_type { + SGP_READ = 0, + SGP_CACHE = 1, + SGP_NOHUGE = 2, + SGP_HUGE = 3, + SGP_WRITE = 4, + SGP_FALLOC = 5, +}; + +struct shmem_falloc { + wait_queue_head_t *waitq; + long unsigned int start; + long unsigned int next; + long unsigned int nr_falloced; + long unsigned int nr_unswapped; +}; + +struct shmem_options { + long long unsigned int blocks; + long long unsigned int inodes; + struct mempolicy *mpol; + kuid_t uid; + kgid_t gid; + umode_t mode; + bool full_inums; + int huge; + int seen; +}; + +enum shmem_param { + Opt_gid = 0, + Opt_huge = 1, + Opt_mode = 2, + Opt_mpol = 3, + Opt_nr_blocks = 4, + Opt_nr_inodes = 5, + Opt_size = 6, + Opt_uid = 7, + Opt_inode32 = 8, + Opt_inode64 = 9, +}; + +enum writeback_stat_item { + NR_DIRTY_THRESHOLD = 0, + NR_DIRTY_BG_THRESHOLD = 1, + NR_VM_WRITEBACK_STAT_ITEMS = 2, +}; + +struct contig_page_info { + long unsigned int free_pages; + long unsigned int free_blocks_total; + long unsigned int free_blocks_suitable; +}; + +struct radix_tree_iter { + long unsigned int index; + long unsigned int next_index; + long unsigned int tags; + struct xa_node *node; +}; + +enum { + RADIX_TREE_ITER_TAG_MASK = 15, + RADIX_TREE_ITER_TAGGED = 16, + RADIX_TREE_ITER_CONTIG = 32, +}; + +enum mminit_level { + MMINIT_WARNING = 0, + MMINIT_VERIFY = 1, + MMINIT_TRACE = 2, +}; + +struct pcpu_group_info { + int nr_units; + long unsigned int base_offset; + unsigned int *cpu_map; +}; + +struct pcpu_alloc_info { + size_t static_size; + size_t reserved_size; + size_t dyn_size; + size_t unit_size; + size_t atom_size; + size_t alloc_size; + size_t __ai_size; + int nr_groups; + struct pcpu_group_info groups[0]; +}; + +typedef void * (*pcpu_fc_alloc_fn_t)(unsigned int, size_t, size_t); + +typedef void (*pcpu_fc_free_fn_t)(void *, size_t); + +typedef void (*pcpu_fc_populate_pte_fn_t)(long unsigned int); + +typedef int pcpu_fc_cpu_distance_fn_t(unsigned int, unsigned int); + +struct trace_event_raw_percpu_alloc_percpu { + struct trace_entry ent; + bool reserved; + bool is_atomic; + size_t size; + size_t align; + void *base_addr; + int off; + void *ptr; + char __data[0]; +}; + +struct trace_event_raw_percpu_free_percpu { + struct trace_entry ent; + void *base_addr; + int off; + void *ptr; + char __data[0]; +}; + +struct trace_event_raw_percpu_alloc_percpu_fail { + struct trace_entry ent; + bool reserved; + bool is_atomic; + size_t size; + size_t align; + char __data[0]; +}; + +struct trace_event_raw_percpu_create_chunk { + struct trace_entry ent; + void *base_addr; + char __data[0]; +}; + +struct trace_event_raw_percpu_destroy_chunk { + struct trace_entry ent; + void *base_addr; + char __data[0]; +}; + +struct trace_event_data_offsets_percpu_alloc_percpu {}; + +struct trace_event_data_offsets_percpu_free_percpu {}; + +struct trace_event_data_offsets_percpu_alloc_percpu_fail {}; + +struct trace_event_data_offsets_percpu_create_chunk {}; + +struct trace_event_data_offsets_percpu_destroy_chunk {}; + +typedef void (*btf_trace_percpu_alloc_percpu)(void *, bool, bool, size_t, size_t, void *, int, void *); + +typedef void (*btf_trace_percpu_free_percpu)(void *, void *, int, void *); + +typedef void (*btf_trace_percpu_alloc_percpu_fail)(void *, bool, bool, size_t, size_t); + +typedef void (*btf_trace_percpu_create_chunk)(void *, void *); + +typedef void (*btf_trace_percpu_destroy_chunk)(void *, void *); + +enum pcpu_chunk_type { + PCPU_CHUNK_ROOT = 0, + PCPU_CHUNK_MEMCG = 1, + PCPU_NR_CHUNK_TYPES = 2, + PCPU_FAIL_ALLOC = 2, +}; + +struct pcpu_block_md { + int scan_hint; + int scan_hint_start; + int contig_hint; + int contig_hint_start; + int left_free; + int right_free; + int first_free; + int nr_bits; +}; + +struct pcpu_chunk { + struct list_head list; + int free_bytes; + struct pcpu_block_md chunk_md; + void *base_addr; + long unsigned int *alloc_map; + long unsigned int *bound_map; + struct pcpu_block_md *md_blocks; + void *data; + bool immutable; + int start_offset; + int end_offset; + struct obj_cgroup **obj_cgroups; + int nr_pages; + int nr_populated; + int nr_empty_pop_pages; + long unsigned int populated[0]; +}; + +struct trace_event_raw_kmem_alloc { + struct trace_entry ent; + long unsigned int call_site; + const void *ptr; + size_t bytes_req; + size_t bytes_alloc; + gfp_t gfp_flags; + char __data[0]; +}; + +struct trace_event_raw_kmem_alloc_node { + struct trace_entry ent; + long unsigned int call_site; + const void *ptr; + size_t bytes_req; + size_t bytes_alloc; + gfp_t gfp_flags; + int node; + char __data[0]; +}; + +struct trace_event_raw_kmem_free { + struct trace_entry ent; + long unsigned int call_site; + const void *ptr; + char __data[0]; +}; + +struct trace_event_raw_mm_page_free { + struct trace_entry ent; + long unsigned int pfn; + unsigned int order; + char __data[0]; +}; + +struct trace_event_raw_mm_page_free_batched { + struct trace_entry ent; + long unsigned int pfn; + char __data[0]; +}; + +struct trace_event_raw_mm_page_alloc { + struct trace_entry ent; + long unsigned int pfn; + unsigned int order; + gfp_t gfp_flags; + int migratetype; + char __data[0]; +}; + +struct trace_event_raw_mm_page { + struct trace_entry ent; + long unsigned int pfn; + unsigned int order; + int migratetype; + char __data[0]; +}; + +struct trace_event_raw_mm_page_pcpu_drain { + struct trace_entry ent; + long unsigned int pfn; + unsigned int order; + int migratetype; + char __data[0]; +}; + +struct trace_event_raw_mm_page_alloc_extfrag { + struct trace_entry ent; + long unsigned int pfn; + int alloc_order; + int fallback_order; + int alloc_migratetype; + int fallback_migratetype; + int change_ownership; + char __data[0]; +}; + +struct trace_event_raw_rss_stat { + struct trace_entry ent; + unsigned int mm_id; + unsigned int curr; + int member; + long int size; + char __data[0]; +}; + +struct trace_event_data_offsets_kmem_alloc {}; + +struct trace_event_data_offsets_kmem_alloc_node {}; + +struct trace_event_data_offsets_kmem_free {}; + +struct trace_event_data_offsets_mm_page_free {}; + +struct trace_event_data_offsets_mm_page_free_batched {}; + +struct trace_event_data_offsets_mm_page_alloc {}; + +struct trace_event_data_offsets_mm_page {}; + +struct trace_event_data_offsets_mm_page_pcpu_drain {}; + +struct trace_event_data_offsets_mm_page_alloc_extfrag {}; + +struct trace_event_data_offsets_rss_stat {}; + +typedef void (*btf_trace_kmalloc)(void *, long unsigned int, const void *, size_t, size_t, gfp_t); + +typedef void (*btf_trace_kmem_cache_alloc)(void *, long unsigned int, const void *, size_t, size_t, gfp_t); + +typedef void (*btf_trace_kmalloc_node)(void *, long unsigned int, const void *, size_t, size_t, gfp_t, int); + +typedef void (*btf_trace_kmem_cache_alloc_node)(void *, long unsigned int, const void *, size_t, size_t, gfp_t, int); + +typedef void (*btf_trace_kfree)(void *, long unsigned int, const void *); + +typedef void (*btf_trace_kmem_cache_free)(void *, long unsigned int, const void *); + +typedef void (*btf_trace_mm_page_free)(void *, struct page *, unsigned int); + +typedef void (*btf_trace_mm_page_free_batched)(void *, struct page *); + +typedef void (*btf_trace_mm_page_alloc)(void *, struct page *, unsigned int, gfp_t, int); + +typedef void (*btf_trace_mm_page_alloc_zone_locked)(void *, struct page *, unsigned int, int); + +typedef void (*btf_trace_mm_page_pcpu_drain)(void *, struct page *, unsigned int, int); + +typedef void (*btf_trace_mm_page_alloc_extfrag)(void *, struct page *, int, int, int, int); + +typedef void (*btf_trace_rss_stat)(void *, struct mm_struct *, int, long int); + +enum slab_state { + DOWN = 0, + PARTIAL = 1, + PARTIAL_NODE = 2, + UP = 3, + FULL = 4, +}; + +struct kmalloc_info_struct { + const char *name[3]; + unsigned int size; +}; + +struct slabinfo { + long unsigned int active_objs; + long unsigned int num_objs; + long unsigned int active_slabs; + long unsigned int num_slabs; + long unsigned int shared_avail; + unsigned int limit; + unsigned int batchcount; + unsigned int shared; + unsigned int objects_per_slab; + unsigned int cache_order; +}; + +enum pageblock_bits { + PB_migrate = 0, + PB_migrate_end = 2, + PB_migrate_skip = 3, + NR_PAGEBLOCK_BITS = 4, +}; + +struct node___2 { + struct device dev; + struct list_head access_list; +}; + +struct alloc_context { + struct zonelist *zonelist; + nodemask_t *nodemask; + struct zoneref *preferred_zoneref; + int migratetype; + enum zone_type highest_zoneidx; + bool spread_dirty_pages; +}; + +struct trace_event_raw_mm_compaction_isolate_template { + struct trace_entry ent; + long unsigned int start_pfn; + long unsigned int end_pfn; + long unsigned int nr_scanned; + long unsigned int nr_taken; + char __data[0]; +}; + +struct trace_event_raw_mm_compaction_migratepages { + struct trace_entry ent; + long unsigned int nr_migrated; + long unsigned int nr_failed; + char __data[0]; +}; + +struct trace_event_raw_mm_compaction_begin { + struct trace_entry ent; + long unsigned int zone_start; + long unsigned int migrate_pfn; + long unsigned int free_pfn; + long unsigned int zone_end; + bool sync; + char __data[0]; +}; + +struct trace_event_raw_mm_compaction_end { + struct trace_entry ent; + long unsigned int zone_start; + long unsigned int migrate_pfn; + long unsigned int free_pfn; + long unsigned int zone_end; + bool sync; + int status; + char __data[0]; +}; + +struct trace_event_raw_mm_compaction_try_to_compact_pages { + struct trace_entry ent; + int order; + gfp_t gfp_mask; + int prio; + char __data[0]; +}; + +struct trace_event_raw_mm_compaction_suitable_template { + struct trace_entry ent; + int nid; + enum zone_type idx; + int order; + int ret; + char __data[0]; +}; + +struct trace_event_raw_mm_compaction_defer_template { + struct trace_entry ent; + int nid; + enum zone_type idx; + int order; + unsigned int considered; + unsigned int defer_shift; + int order_failed; + char __data[0]; +}; + +struct trace_event_raw_mm_compaction_kcompactd_sleep { + struct trace_entry ent; + int nid; + char __data[0]; +}; + +struct trace_event_raw_kcompactd_wake_template { + struct trace_entry ent; + int nid; + int order; + enum zone_type highest_zoneidx; + char __data[0]; +}; + +struct trace_event_data_offsets_mm_compaction_isolate_template {}; + +struct trace_event_data_offsets_mm_compaction_migratepages {}; + +struct trace_event_data_offsets_mm_compaction_begin {}; + +struct trace_event_data_offsets_mm_compaction_end {}; + +struct trace_event_data_offsets_mm_compaction_try_to_compact_pages {}; + +struct trace_event_data_offsets_mm_compaction_suitable_template {}; + +struct trace_event_data_offsets_mm_compaction_defer_template {}; + +struct trace_event_data_offsets_mm_compaction_kcompactd_sleep {}; + +struct trace_event_data_offsets_kcompactd_wake_template {}; + +typedef void (*btf_trace_mm_compaction_isolate_migratepages)(void *, long unsigned int, long unsigned int, long unsigned int, long unsigned int); + +typedef void (*btf_trace_mm_compaction_isolate_freepages)(void *, long unsigned int, long unsigned int, long unsigned int, long unsigned int); + +typedef void (*btf_trace_mm_compaction_migratepages)(void *, long unsigned int, int, struct list_head *); + +typedef void (*btf_trace_mm_compaction_begin)(void *, long unsigned int, long unsigned int, long unsigned int, long unsigned int, bool); + +typedef void (*btf_trace_mm_compaction_end)(void *, long unsigned int, long unsigned int, long unsigned int, long unsigned int, bool, int); + +typedef void (*btf_trace_mm_compaction_try_to_compact_pages)(void *, int, gfp_t, int); + +typedef void (*btf_trace_mm_compaction_finished)(void *, struct zone *, int, int); + +typedef void (*btf_trace_mm_compaction_suitable)(void *, struct zone *, int, int); + +typedef void (*btf_trace_mm_compaction_deferred)(void *, struct zone *, int); + +typedef void (*btf_trace_mm_compaction_defer_compaction)(void *, struct zone *, int); + +typedef void (*btf_trace_mm_compaction_defer_reset)(void *, struct zone *, int); + +typedef void (*btf_trace_mm_compaction_kcompactd_sleep)(void *, int); + +typedef void (*btf_trace_mm_compaction_wakeup_kcompactd)(void *, int, int, enum zone_type); + +typedef void (*btf_trace_mm_compaction_kcompactd_wake)(void *, int, int, enum zone_type); + +typedef enum { + ISOLATE_ABORT = 0, + ISOLATE_NONE = 1, + ISOLATE_SUCCESS = 2, +} isolate_migrate_t; + +struct anon_vma_chain { + struct vm_area_struct *vma; + struct anon_vma *anon_vma; + struct list_head same_vma; + struct rb_node rb; + long unsigned int rb_subtree_last; +}; + +enum lru_status { + LRU_REMOVED = 0, + LRU_REMOVED_RETRY = 1, + LRU_ROTATE = 2, + LRU_SKIP = 3, + LRU_RETRY = 4, +}; + +typedef enum lru_status (*list_lru_walk_cb)(struct list_head *, struct list_lru_one *, spinlock_t *, void *); + +typedef struct { + long unsigned int pd; +} hugepd_t; + +struct migration_target_control { + int nid; + nodemask_t *nmask; + gfp_t gfp_mask; +}; + +struct follow_page_context { + struct dev_pagemap *pgmap; + unsigned int page_mask; +}; + +typedef unsigned int pgtbl_mod_mask; + +struct zap_details { + struct address_space *check_mapping; + long unsigned int first_index; + long unsigned int last_index; +}; + +typedef int (*pte_fn_t)(pte_t *, long unsigned int, void *); + +enum { + SWP_USED = 1, + SWP_WRITEOK = 2, + SWP_DISCARDABLE = 4, + SWP_DISCARDING = 8, + SWP_SOLIDSTATE = 16, + SWP_CONTINUED = 32, + SWP_BLKDEV = 64, + SWP_ACTIVATED = 128, + SWP_FS_OPS = 256, + SWP_AREA_DISCARD = 512, + SWP_PAGE_DISCARD = 1024, + SWP_STABLE_WRITES = 2048, + SWP_SYNCHRONOUS_IO = 4096, + SWP_VALID = 8192, + SWP_SCANNING = 16384, +}; + +struct copy_subpage_arg { + struct page *dst; + struct page *src; + struct vm_area_struct *vma; +}; + +struct mm_walk; + +struct mm_walk_ops { + int (*pgd_entry)(pgd_t *, long unsigned int, long unsigned int, struct mm_walk *); + int (*p4d_entry)(p4d_t *, long unsigned int, long unsigned int, struct mm_walk *); + int (*pud_entry)(pud_t *, long unsigned int, long unsigned int, struct mm_walk *); + int (*pmd_entry)(pmd_t *, long unsigned int, long unsigned int, struct mm_walk *); + int (*pte_entry)(pte_t *, long unsigned int, long unsigned int, struct mm_walk *); + int (*pte_hole)(long unsigned int, long unsigned int, int, struct mm_walk *); + int (*hugetlb_entry)(pte_t *, long unsigned int, long unsigned int, long unsigned int, struct mm_walk *); + int (*test_walk)(long unsigned int, long unsigned int, struct mm_walk *); + int (*pre_vma)(long unsigned int, long unsigned int, struct mm_walk *); + void (*post_vma)(struct mm_walk *); +}; + +enum page_walk_action { + ACTION_SUBTREE = 0, + ACTION_CONTINUE = 1, + ACTION_AGAIN = 2, +}; + +struct mm_walk { + const struct mm_walk_ops *ops; + struct mm_struct *mm; + pgd_t *pgd; + struct vm_area_struct *vma; + enum page_walk_action action; + bool no_vma; + void *private; +}; + +enum { + HUGETLB_SHMFS_INODE = 1, + HUGETLB_ANONHUGE_INODE = 2, +}; + +struct trace_event_raw_vm_unmapped_area { + struct trace_entry ent; + long unsigned int addr; + long unsigned int total_vm; + long unsigned int flags; + long unsigned int length; + long unsigned int low_limit; + long unsigned int high_limit; + long unsigned int align_mask; + long unsigned int align_offset; + char __data[0]; +}; + +struct trace_event_data_offsets_vm_unmapped_area {}; + +typedef void (*btf_trace_vm_unmapped_area)(void *, long unsigned int, struct vm_unmapped_area_info *); + +struct rmap_walk_control { + void *arg; + bool (*rmap_one)(struct page *, struct vm_area_struct *, long unsigned int, void *); + int (*done)(struct page *); + struct anon_vma * (*anon_lock)(struct page *); + bool (*invalid_vma)(struct vm_area_struct *, void *); +}; + +struct page_referenced_arg { + int mapcount; + int referenced; + long unsigned int vm_flags; + struct mem_cgroup *memcg; +}; + +struct vmap_area { + long unsigned int va_start; + long unsigned int va_end; + struct rb_node rb_node; + struct list_head list; + union { + long unsigned int subtree_max_size; + struct vm_struct *vm; + struct llist_node purge_list; + }; +}; + +struct vfree_deferred { + struct llist_head list; + struct work_struct wq; +}; + +enum fit_type { + NOTHING_FIT = 0, + FL_FIT_TYPE = 1, + LE_FIT_TYPE = 2, + RE_FIT_TYPE = 3, + NE_FIT_TYPE = 4, +}; + +struct vmap_block_queue { + spinlock_t lock; + struct list_head free; +}; + +struct vmap_block { + spinlock_t lock; + struct vmap_area *va; + long unsigned int free; + long unsigned int dirty; + long unsigned int dirty_min; + long unsigned int dirty_max; + struct list_head free_list; + struct callback_head callback_head; + struct list_head purge; +}; + +struct vmap_pfn_data { + long unsigned int *pfns; + pgprot_t prot; + unsigned int idx; +}; + +struct page_frag_cache { + void *va; + __u16 offset; + __u16 size; + unsigned int pagecnt_bias; + bool pfmemalloc; +}; + +enum zone_flags { + ZONE_BOOSTED_WATERMARK = 0, +}; + +struct mminit_pfnnid_cache { + long unsigned int last_start; + long unsigned int last_end; + int last_nid; +}; + +typedef int fpi_t; + +struct pcpu_drain { + struct zone *zone; + struct work_struct work; +}; + +struct madvise_walk_private { + struct mmu_gather *tlb; + bool pageout; +}; + +enum { + BIO_NO_PAGE_REF = 0, + BIO_CLONED = 1, + BIO_BOUNCED = 2, + BIO_WORKINGSET = 3, + BIO_QUIET = 4, + BIO_CHAIN = 5, + BIO_REFFED = 6, + BIO_THROTTLED = 7, + BIO_TRACE_COMPLETION = 8, + BIO_CGROUP_ACCT = 9, + BIO_TRACKED = 10, + BIO_FLAG_LAST = 11, +}; + +struct vma_swap_readahead { + short unsigned int win; + short unsigned int offset; + short unsigned int nr_pte; + pte_t *ptes; +}; + +union swap_header { + struct { + char reserved[4086]; + char magic[10]; + } magic; + struct { + char bootbits[1024]; + __u32 version; + __u32 last_page; + __u32 nr_badpages; + unsigned char sws_uuid[16]; + unsigned char sws_volume[16]; + __u32 padding[117]; + __u32 badpages[1]; + } info; +}; + +struct swap_extent { + struct rb_node rb_node; + long unsigned int start_page; + long unsigned int nr_pages; + sector_t start_block; +}; + +struct swap_slots_cache { + bool lock_initialized; + struct mutex alloc_lock; + swp_entry_t *slots; + int nr; + int cur; + spinlock_t free_lock; + swp_entry_t *slots_ret; + int n_ret; +}; + +struct dma_pool { + struct list_head page_list; + spinlock_t lock; + size_t size; + struct device *dev; + size_t allocation; + size_t boundary; + char name[32]; + struct list_head pools; +}; + +struct dma_page { + struct list_head page_list; + void *vaddr; + dma_addr_t dma; + unsigned int in_use; + unsigned int offset; +}; + +enum string_size_units { + STRING_UNITS_10 = 0, + STRING_UNITS_2 = 1, +}; + +struct resv_map { + struct kref refs; + spinlock_t lock; + struct list_head regions; + long int adds_in_progress; + struct list_head region_cache; + long int region_cache_count; + struct page_counter *reservation_counter; + long unsigned int pages_per_hpage; + struct cgroup_subsys_state *css; +}; + +struct file_region { + struct list_head link; + long int from; + long int to; + struct page_counter *reservation_counter; + struct cgroup_subsys_state *css; +}; + +struct huge_bootmem_page { + struct list_head list; + struct hstate *hstate; +}; + +enum hugetlb_memory_event { + HUGETLB_MAX = 0, + HUGETLB_NR_MEMORY_EVENTS = 1, +}; + +struct hugetlb_cgroup { + struct cgroup_subsys_state css; + struct page_counter hugepage[2]; + struct page_counter rsvd_hugepage[2]; + atomic_long_t events[2]; + atomic_long_t events_local[2]; + struct cgroup_file events_file[2]; + struct cgroup_file events_local_file[2]; +}; + +enum vma_resv_mode { + VMA_NEEDS_RESV = 0, + VMA_COMMIT_RESV = 1, + VMA_END_RESV = 2, + VMA_ADD_RESV = 3, +}; + +struct node_hstate { + struct kobject *hugepages_kobj; + struct kobject *hstate_kobjs[2]; +}; + +struct nodemask_scratch { + nodemask_t mask1; + nodemask_t mask2; +}; + +struct sp_node { + struct rb_node nd; + long unsigned int start; + long unsigned int end; + struct mempolicy *policy; +}; + +struct mempolicy_operations { + int (*create)(struct mempolicy *, const nodemask_t *); + void (*rebind)(struct mempolicy *, const nodemask_t *); +}; + +struct queue_pages { + struct list_head *pagelist; + long unsigned int flags; + nodemask_t *nmask; + long unsigned int start; + long unsigned int end; + struct vm_area_struct *first; +}; + +struct mmu_notifier_subscriptions { + struct hlist_head list; + bool has_itree; + spinlock_t lock; + long unsigned int invalidate_seq; + long unsigned int active_invalidate_ranges; + struct rb_root_cached itree; + wait_queue_head_t wq; + struct hlist_head deferred_list; +}; + +struct interval_tree_node { + struct rb_node rb; + long unsigned int start; + long unsigned int last; + long unsigned int __subtree_last; +}; + +struct mmu_interval_notifier; + +struct mmu_interval_notifier_ops { + bool (*invalidate)(struct mmu_interval_notifier *, const struct mmu_notifier_range *, long unsigned int); +}; + +struct mmu_interval_notifier { + struct interval_tree_node interval_tree; + const struct mmu_interval_notifier_ops *ops; + struct mm_struct *mm; + struct hlist_node deferred_item; + long unsigned int invalidate_seq; +}; + +struct rmap_item; + +struct mm_slot { + struct hlist_node link; + struct list_head mm_list; + struct rmap_item *rmap_list; + struct mm_struct *mm; +}; + +struct stable_node; + +struct rmap_item { + struct rmap_item *rmap_list; + union { + struct anon_vma *anon_vma; + int nid; + }; + struct mm_struct *mm; + long unsigned int address; + unsigned int oldchecksum; + union { + struct rb_node node; + struct { + struct stable_node *head; + struct hlist_node hlist; + }; + }; +}; + +struct ksm_scan { + struct mm_slot *mm_slot; + long unsigned int address; + struct rmap_item **rmap_list; + long unsigned int seqnr; +}; + +struct stable_node { + union { + struct rb_node node; + struct { + struct list_head *head; + struct { + struct hlist_node hlist_dup; + struct list_head list; + }; + }; + }; + struct hlist_head hlist; + union { + long unsigned int kpfn; + long unsigned int chain_prune_time; + }; + int rmap_hlist_len; + int nid; +}; + +enum get_ksm_page_flags { + GET_KSM_PAGE_NOLOCK = 0, + GET_KSM_PAGE_LOCK = 1, + GET_KSM_PAGE_TRYLOCK = 2, +}; + +enum stat_item { + ALLOC_FASTPATH = 0, + ALLOC_SLOWPATH = 1, + FREE_FASTPATH = 2, + FREE_SLOWPATH = 3, + FREE_FROZEN = 4, + FREE_ADD_PARTIAL = 5, + FREE_REMOVE_PARTIAL = 6, + ALLOC_FROM_PARTIAL = 7, + ALLOC_SLAB = 8, + ALLOC_REFILL = 9, + ALLOC_NODE_MISMATCH = 10, + FREE_SLAB = 11, + CPUSLAB_FLUSH = 12, + DEACTIVATE_FULL = 13, + DEACTIVATE_EMPTY = 14, + DEACTIVATE_TO_HEAD = 15, + DEACTIVATE_TO_TAIL = 16, + DEACTIVATE_REMOTE_FREES = 17, + DEACTIVATE_BYPASS = 18, + ORDER_FALLBACK = 19, + CMPXCHG_DOUBLE_CPU_FAIL = 20, + CMPXCHG_DOUBLE_FAIL = 21, + CPU_PARTIAL_ALLOC = 22, + CPU_PARTIAL_FREE = 23, + CPU_PARTIAL_NODE = 24, + CPU_PARTIAL_DRAIN = 25, + NR_SLUB_STAT_ITEMS = 26, +}; + +struct track { + long unsigned int addr; + long unsigned int addrs[16]; + int cpu; + int pid; + long unsigned int when; +}; + +enum track_item { + TRACK_ALLOC = 0, + TRACK_FREE = 1, +}; + +struct detached_freelist { + struct page *page; + void *tail; + void *freelist; + int cnt; + struct kmem_cache *s; +}; + +struct location { + long unsigned int count; + long unsigned int addr; + long long int sum_time; + long int min_time; + long int max_time; + long int min_pid; + long int max_pid; + long unsigned int cpus[2]; + nodemask_t nodes; +}; + +struct loc_track { + long unsigned int max; + long unsigned int count; + struct location *loc; +}; + +enum slab_stat_type { + SL_ALL = 0, + SL_PARTIAL = 1, + SL_CPU = 2, + SL_OBJECTS = 3, + SL_TOTAL = 4, +}; + +struct slab_attribute { + struct attribute attr; + ssize_t (*show)(struct kmem_cache *, char *); + ssize_t (*store)(struct kmem_cache *, const char *, size_t); +}; + +struct saved_alias { + struct kmem_cache *s; + const char *name; + struct saved_alias *next; +}; + +enum slab_modes { + M_NONE = 0, + M_PARTIAL = 1, + M_FULL = 2, + M_FREE = 3, +}; + +struct buffer_head; + +typedef void bh_end_io_t(struct buffer_head *, int); + +struct buffer_head { + long unsigned int b_state; + struct buffer_head *b_this_page; + struct page *b_page; + sector_t b_blocknr; + size_t b_size; + char *b_data; + struct block_device *b_bdev; + bh_end_io_t *b_end_io; + void *b_private; + struct list_head b_assoc_buffers; + struct address_space *b_assoc_map; + atomic_t b_count; + spinlock_t b_uptodate_lock; +}; + +typedef struct page *new_page_t(struct page *, long unsigned int); + +typedef void free_page_t(struct page *, long unsigned int); + +enum bh_state_bits { + BH_Uptodate = 0, + BH_Dirty = 1, + BH_Lock = 2, + BH_Req = 3, + BH_Mapped = 4, + BH_New = 5, + BH_Async_Read = 6, + BH_Async_Write = 7, + BH_Delay = 8, + BH_Boundary = 9, + BH_Write_EIO = 10, + BH_Unwritten = 11, + BH_Quiet = 12, + BH_Meta = 13, + BH_Prio = 14, + BH_Defer_Completion = 15, + BH_PrivateStart = 16, +}; + +struct trace_event_raw_mm_migrate_pages { + struct trace_entry ent; + long unsigned int succeeded; + long unsigned int failed; + long unsigned int thp_succeeded; + long unsigned int thp_failed; + long unsigned int thp_split; + enum migrate_mode mode; + int reason; + char __data[0]; +}; + +struct trace_event_data_offsets_mm_migrate_pages {}; + +typedef void (*btf_trace_mm_migrate_pages)(void *, long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, enum migrate_mode, int); + +enum scan_result { + SCAN_FAIL = 0, + SCAN_SUCCEED = 1, + SCAN_PMD_NULL = 2, + SCAN_EXCEED_NONE_PTE = 3, + SCAN_EXCEED_SWAP_PTE = 4, + SCAN_EXCEED_SHARED_PTE = 5, + SCAN_PTE_NON_PRESENT = 6, + SCAN_PTE_UFFD_WP = 7, + SCAN_PAGE_RO = 8, + SCAN_LACK_REFERENCED_PAGE = 9, + SCAN_PAGE_NULL = 10, + SCAN_SCAN_ABORT = 11, + SCAN_PAGE_COUNT = 12, + SCAN_PAGE_LRU = 13, + SCAN_PAGE_LOCK = 14, + SCAN_PAGE_ANON = 15, + SCAN_PAGE_COMPOUND = 16, + SCAN_ANY_PROCESS = 17, + SCAN_VMA_NULL = 18, + SCAN_VMA_CHECK = 19, + SCAN_ADDRESS_RANGE = 20, + SCAN_SWAP_CACHE_PAGE = 21, + SCAN_DEL_PAGE_LRU = 22, + SCAN_ALLOC_HUGE_PAGE_FAIL = 23, + SCAN_CGROUP_CHARGE_FAIL = 24, + SCAN_TRUNCATED = 25, + SCAN_PAGE_HAS_PRIVATE = 26, +}; + +struct trace_event_raw_mm_khugepaged_scan_pmd { + struct trace_entry ent; + struct mm_struct *mm; + long unsigned int pfn; + bool writable; + int referenced; + int none_or_zero; + int status; + int unmapped; + char __data[0]; +}; + +struct trace_event_raw_mm_collapse_huge_page { + struct trace_entry ent; + struct mm_struct *mm; + int isolated; + int status; + char __data[0]; +}; + +struct trace_event_raw_mm_collapse_huge_page_isolate { + struct trace_entry ent; + long unsigned int pfn; + int none_or_zero; + int referenced; + bool writable; + int status; + char __data[0]; +}; + +struct trace_event_raw_mm_collapse_huge_page_swapin { + struct trace_entry ent; + struct mm_struct *mm; + int swapped_in; + int referenced; + int ret; + char __data[0]; +}; + +struct trace_event_data_offsets_mm_khugepaged_scan_pmd {}; + +struct trace_event_data_offsets_mm_collapse_huge_page {}; + +struct trace_event_data_offsets_mm_collapse_huge_page_isolate {}; + +struct trace_event_data_offsets_mm_collapse_huge_page_swapin {}; + +typedef void (*btf_trace_mm_khugepaged_scan_pmd)(void *, struct mm_struct *, struct page *, bool, int, int, int, int); + +typedef void (*btf_trace_mm_collapse_huge_page)(void *, struct mm_struct *, int, int); + +typedef void (*btf_trace_mm_collapse_huge_page_isolate)(void *, struct page *, int, int, bool, int); + +typedef void (*btf_trace_mm_collapse_huge_page_swapin)(void *, struct mm_struct *, int, int, int); + +struct mm_slot___2 { + struct hlist_node hash; + struct list_head mm_node; + struct mm_struct *mm; + int nr_pte_mapped_thp; + long unsigned int pte_mapped_thp[8]; +}; + +struct khugepaged_scan { + struct list_head mm_head; + struct mm_slot___2 *mm_slot; + long unsigned int address; +}; + +struct mem_cgroup_reclaim_cookie { + pg_data_t *pgdat; + unsigned int generation; +}; + +struct mem_cgroup_tree_per_node { + struct rb_root rb_root; + struct rb_node *rb_rightmost; + spinlock_t lock; +}; + +struct mem_cgroup_tree { + struct mem_cgroup_tree_per_node *rb_tree_per_node[64]; +}; + +struct mem_cgroup_eventfd_list { + struct list_head list; + struct eventfd_ctx *eventfd; +}; + +struct mem_cgroup_event { + struct mem_cgroup *memcg; + struct eventfd_ctx *eventfd; + struct list_head list; + int (*register_event)(struct mem_cgroup *, struct eventfd_ctx *, const char *); + void (*unregister_event)(struct mem_cgroup *, struct eventfd_ctx *); + poll_table pt; + wait_queue_head_t *wqh; + wait_queue_entry_t wait; + struct work_struct remove; +}; + +struct move_charge_struct { + spinlock_t lock; + struct mm_struct *mm; + struct mem_cgroup *from; + struct mem_cgroup *to; + long unsigned int flags; + long unsigned int precharge; + long unsigned int moved_charge; + long unsigned int moved_swap; + struct task_struct *moving_task; + wait_queue_head_t waitq; +}; + +enum res_type { + _MEM = 0, + _MEMSWAP = 1, + _OOM_TYPE = 2, + _KMEM = 3, + _TCP = 4, +}; + +struct memory_stat { + const char *name; + unsigned int ratio; + unsigned int idx; +}; + +struct oom_wait_info { + struct mem_cgroup *memcg; + wait_queue_entry_t wait; +}; + +enum oom_status { + OOM_SUCCESS = 0, + OOM_FAILED = 1, + OOM_ASYNC = 2, + OOM_SKIPPED = 3, +}; + +struct memcg_stock_pcp { + struct mem_cgroup *cached; + unsigned int nr_pages; + struct obj_cgroup *cached_objcg; + unsigned int nr_bytes; + struct work_struct work; + long unsigned int flags; +}; + +enum { + RES_USAGE = 0, + RES_LIMIT = 1, + RES_MAX_USAGE = 2, + RES_FAILCNT = 3, + RES_SOFT_LIMIT = 4, +}; + +union mc_target { + struct page *page; + swp_entry_t ent; +}; + +enum mc_target_type { + MC_TARGET_NONE = 0, + MC_TARGET_PAGE = 1, + MC_TARGET_SWAP = 2, + MC_TARGET_DEVICE = 3, +}; + +struct uncharge_gather { + struct mem_cgroup *memcg; + long unsigned int nr_pages; + long unsigned int pgpgout; + long unsigned int nr_kmem; + struct page *dummy_page; +}; + +struct numa_stat { + const char *name; + unsigned int lru_mask; +}; + +enum vmpressure_levels { + VMPRESSURE_LOW = 0, + VMPRESSURE_MEDIUM = 1, + VMPRESSURE_CRITICAL = 2, + VMPRESSURE_NUM_LEVELS = 3, +}; + +enum vmpressure_modes { + VMPRESSURE_NO_PASSTHROUGH = 0, + VMPRESSURE_HIERARCHY = 1, + VMPRESSURE_LOCAL = 2, + VMPRESSURE_NUM_MODES = 3, +}; + +struct vmpressure_event { + struct eventfd_ctx *efd; + enum vmpressure_levels level; + enum vmpressure_modes mode; + struct list_head node; +}; + +struct swap_cgroup_ctrl { + struct page **map; + long unsigned int length; + spinlock_t lock; +}; + +struct swap_cgroup { + short unsigned int id; +}; + +enum { + RES_USAGE___2 = 0, + RES_RSVD_USAGE = 1, + RES_LIMIT___2 = 2, + RES_RSVD_LIMIT = 3, + RES_MAX_USAGE___2 = 4, + RES_RSVD_MAX_USAGE = 5, + RES_FAILCNT___2 = 6, + RES_RSVD_FAILCNT = 7, +}; + +enum mf_result { + MF_IGNORED = 0, + MF_FAILED = 1, + MF_DELAYED = 2, + MF_RECOVERED = 3, +}; + +enum mf_action_page_type { + MF_MSG_KERNEL = 0, + MF_MSG_KERNEL_HIGH_ORDER = 1, + MF_MSG_SLAB = 2, + MF_MSG_DIFFERENT_COMPOUND = 3, + MF_MSG_POISONED_HUGE = 4, + MF_MSG_HUGE = 5, + MF_MSG_FREE_HUGE = 6, + MF_MSG_NON_PMD_HUGE = 7, + MF_MSG_UNMAP_FAILED = 8, + MF_MSG_DIRTY_SWAPCACHE = 9, + MF_MSG_CLEAN_SWAPCACHE = 10, + MF_MSG_DIRTY_MLOCKED_LRU = 11, + MF_MSG_CLEAN_MLOCKED_LRU = 12, + MF_MSG_DIRTY_UNEVICTABLE_LRU = 13, + MF_MSG_CLEAN_UNEVICTABLE_LRU = 14, + MF_MSG_DIRTY_LRU = 15, + MF_MSG_CLEAN_LRU = 16, + MF_MSG_TRUNCATED_LRU = 17, + MF_MSG_BUDDY = 18, + MF_MSG_BUDDY_2ND = 19, + MF_MSG_DAX = 20, + MF_MSG_UNSPLIT_THP = 21, + MF_MSG_UNKNOWN = 22, +}; + +typedef long unsigned int dax_entry_t; + +struct __kfifo { + unsigned int in; + unsigned int out; + unsigned int mask; + unsigned int esize; + void *data; +}; + +struct to_kill { + struct list_head nd; + struct task_struct *tsk; + long unsigned int addr; + short int size_shift; +}; + +struct page_state { + long unsigned int mask; + long unsigned int res; + enum mf_action_page_type type; + int (*action)(struct page *, long unsigned int); +}; + +struct memory_failure_entry { + long unsigned int pfn; + int flags; +}; + +struct memory_failure_cpu { + struct { + union { + struct __kfifo kfifo; + struct memory_failure_entry *type; + const struct memory_failure_entry *const_type; + char (*rectype)[0]; + struct memory_failure_entry *ptr; + const struct memory_failure_entry *ptr_const; + }; + struct memory_failure_entry buf[16]; + } fifo; + spinlock_t lock; + struct work_struct work; +}; + +struct trace_event_raw_test_pages_isolated { + struct trace_entry ent; + long unsigned int start_pfn; + long unsigned int end_pfn; + long unsigned int fin_pfn; + char __data[0]; +}; + +struct trace_event_data_offsets_test_pages_isolated {}; + +typedef void (*btf_trace_test_pages_isolated)(void *, long unsigned int, long unsigned int, long unsigned int); + +struct cma { + long unsigned int base_pfn; + long unsigned int count; + long unsigned int *bitmap; + unsigned int order_per_bit; + struct mutex lock; + char name[64]; +}; + +struct trace_event_raw_cma_alloc { + struct trace_entry ent; + long unsigned int pfn; + const struct page *page; + unsigned int count; + unsigned int align; + char __data[0]; +}; + +struct trace_event_raw_cma_release { + struct trace_entry ent; + long unsigned int pfn; + const struct page *page; + unsigned int count; + char __data[0]; +}; + +struct trace_event_data_offsets_cma_alloc {}; + +struct trace_event_data_offsets_cma_release {}; + +typedef void (*btf_trace_cma_alloc)(void *, long unsigned int, const struct page *, unsigned int, unsigned int); + +typedef void (*btf_trace_cma_release)(void *, long unsigned int, const struct page *, unsigned int); + +struct balloon_dev_info { + long unsigned int isolated_pages; + spinlock_t pages_lock; + struct list_head pages; + int (*migratepage)(struct balloon_dev_info *, struct page *, struct page *, enum migrate_mode); + struct inode *inode; +}; + +enum hmm_pfn_flags { + HMM_PFN_VALID = 0, + HMM_PFN_WRITE = 0, + HMM_PFN_ERROR = 0, + HMM_PFN_ORDER_SHIFT = 56, + HMM_PFN_REQ_FAULT = 0, + HMM_PFN_REQ_WRITE = 0, + HMM_PFN_FLAGS = 0, +}; + +struct hmm_range { + struct mmu_interval_notifier *notifier; + long unsigned int notifier_seq; + long unsigned int start; + long unsigned int end; + long unsigned int *hmm_pfns; + long unsigned int default_flags; + long unsigned int pfn_flags_mask; + void *dev_private_owner; +}; + +struct hmm_vma_walk { + struct hmm_range *range; + long unsigned int last; +}; + +enum { + HMM_NEED_FAULT = 1, + HMM_NEED_WRITE_FAULT = 2, + HMM_NEED_ALL_BITS = 3, +}; + +struct hugetlbfs_inode_info { + struct shared_policy policy; + struct inode vfs_inode; + unsigned int seals; +}; + +struct page_reporting_dev_info { + int (*report)(struct page_reporting_dev_info *, struct scatterlist *, unsigned int); + struct delayed_work work; + atomic_t state; +}; + +enum { + PAGE_REPORTING_IDLE = 0, + PAGE_REPORTING_REQUESTED = 1, + PAGE_REPORTING_ACTIVE = 2, +}; + +struct open_how { + __u64 flags; + __u64 mode; + __u64 resolve; +}; + +enum fsnotify_data_type { + FSNOTIFY_EVENT_NONE = 0, + FSNOTIFY_EVENT_PATH = 1, + FSNOTIFY_EVENT_INODE = 2, +}; + +typedef s32 compat_off_t; + +struct open_flags { + int open_flag; + umode_t mode; + int acc_mode; + int intent; + int lookup_flags; +}; + +typedef __kernel_long_t __kernel_off_t; + +typedef __kernel_off_t off_t; + +typedef __kernel_rwf_t rwf_t; + +typedef s64 compat_loff_t; + +enum vfs_get_super_keying { + vfs_get_single_super = 0, + vfs_get_single_reconf_super = 1, + vfs_get_keyed_super = 2, + vfs_get_independent_super = 3, +}; + +struct kobj_map; + +struct char_device_struct { + struct char_device_struct *next; + unsigned int major; + unsigned int baseminor; + int minorct; + char name[64]; + struct cdev *cdev; +}; + +struct stat { + __kernel_ulong_t st_dev; + __kernel_ulong_t st_ino; + __kernel_ulong_t st_nlink; + unsigned int st_mode; + unsigned int st_uid; + unsigned int st_gid; + unsigned int __pad0; + __kernel_ulong_t st_rdev; + __kernel_long_t st_size; + __kernel_long_t st_blksize; + __kernel_long_t st_blocks; + __kernel_ulong_t st_atime; + __kernel_ulong_t st_atime_nsec; + __kernel_ulong_t st_mtime; + __kernel_ulong_t st_mtime_nsec; + __kernel_ulong_t st_ctime; + __kernel_ulong_t st_ctime_nsec; + __kernel_long_t __unused[3]; +}; + +struct __old_kernel_stat { + short unsigned int st_dev; + short unsigned int st_ino; + short unsigned int st_mode; + short unsigned int st_nlink; + short unsigned int st_uid; + short unsigned int st_gid; + short unsigned int st_rdev; + unsigned int st_size; + unsigned int st_atime; + unsigned int st_mtime; + unsigned int st_ctime; +}; + +struct statx_timestamp { + __s64 tv_sec; + __u32 tv_nsec; + __s32 __reserved; +}; + +struct statx { + __u32 stx_mask; + __u32 stx_blksize; + __u64 stx_attributes; + __u32 stx_nlink; + __u32 stx_uid; + __u32 stx_gid; + __u16 stx_mode; + __u16 __spare0[1]; + __u64 stx_ino; + __u64 stx_size; + __u64 stx_blocks; + __u64 stx_attributes_mask; + struct statx_timestamp stx_atime; + struct statx_timestamp stx_btime; + struct statx_timestamp stx_ctime; + struct statx_timestamp stx_mtime; + __u32 stx_rdev_major; + __u32 stx_rdev_minor; + __u32 stx_dev_major; + __u32 stx_dev_minor; + __u64 stx_mnt_id; + __u64 __spare2; + __u64 __spare3[12]; +}; + +struct mount; + +struct mnt_namespace { + atomic_t count; + struct ns_common ns; + struct mount *root; + struct list_head list; + spinlock_t ns_lock; + struct user_namespace *user_ns; + struct ucounts *ucounts; + u64 seq; + wait_queue_head_t poll; + u64 event; + unsigned int mounts; + unsigned int pending_mounts; +}; + +typedef u32 compat_ino_t; + +typedef u16 __compat_uid_t; + +typedef u16 __compat_gid_t; + +typedef u16 compat_mode_t; + +typedef u16 compat_dev_t; + +typedef u16 compat_nlink_t; + +struct compat_stat { + compat_dev_t st_dev; + u16 __pad1; + compat_ino_t st_ino; + compat_mode_t st_mode; + compat_nlink_t st_nlink; + __compat_uid_t st_uid; + __compat_gid_t st_gid; + compat_dev_t st_rdev; + u16 __pad2; + u32 st_size; + u32 st_blksize; + u32 st_blocks; + u32 st_atime; + u32 st_atime_nsec; + u32 st_mtime; + u32 st_mtime_nsec; + u32 st_ctime; + u32 st_ctime_nsec; + u32 __unused4; + u32 __unused5; +}; + +struct mnt_pcp; + +struct mountpoint; + +struct mount { + struct hlist_node mnt_hash; + struct mount *mnt_parent; + struct dentry *mnt_mountpoint; + struct vfsmount mnt; + union { + struct callback_head mnt_rcu; + struct llist_node mnt_llist; + }; + struct mnt_pcp *mnt_pcp; + struct list_head mnt_mounts; + struct list_head mnt_child; + struct list_head mnt_instance; + const char *mnt_devname; + struct list_head mnt_list; + struct list_head mnt_expire; + struct list_head mnt_share; + struct list_head mnt_slave_list; + struct list_head mnt_slave; + struct mount *mnt_master; + struct mnt_namespace *mnt_ns; + struct mountpoint *mnt_mp; + union { + struct hlist_node mnt_mp_list; + struct hlist_node mnt_umount; + }; + struct list_head mnt_umounting; + struct fsnotify_mark_connector *mnt_fsnotify_marks; + __u32 mnt_fsnotify_mask; + int mnt_id; + int mnt_group_id; + int mnt_expiry_mark; + struct hlist_head mnt_pins; + struct hlist_head mnt_stuck_children; +}; + +struct mnt_pcp { + int mnt_count; + int mnt_writers; +}; + +struct mountpoint { + struct hlist_node m_hash; + struct dentry *m_dentry; + struct hlist_head m_list; + int m_count; +}; + +typedef short unsigned int ushort; + +struct user_arg_ptr { + bool is_compat; + union { + const char * const *native; + const compat_uptr_t *compat; + } ptr; +}; + +enum inode_i_mutex_lock_class { + I_MUTEX_NORMAL = 0, + I_MUTEX_PARENT = 1, + I_MUTEX_CHILD = 2, + I_MUTEX_XATTR = 3, + I_MUTEX_NONDIR2 = 4, + I_MUTEX_PARENT2 = 5, +}; + +struct pseudo_fs_context { + const struct super_operations *ops; + const struct xattr_handler **xattr; + const struct dentry_operations *dops; + long unsigned int magic; +}; + +struct name_snapshot { + struct qstr name; + unsigned char inline_name[32]; +}; + +struct saved { + struct path link; + struct delayed_call done; + const char *name; + unsigned int seq; +}; + +struct nameidata { + struct path path; + struct qstr last; + struct path root; + struct inode *inode; + unsigned int flags; + unsigned int seq; + unsigned int m_seq; + unsigned int r_seq; + int last_type; + unsigned int depth; + int total_link_count; + struct saved *stack; + struct saved internal[2]; + struct filename *name; + struct nameidata *saved; + unsigned int root_seq; + int dfd; + kuid_t dir_uid; + umode_t dir_mode; +}; + +enum { + LAST_NORM = 0, + LAST_ROOT = 1, + LAST_DOT = 2, + LAST_DOTDOT = 3, +}; + +enum { + WALK_TRAILING = 1, + WALK_MORE = 2, + WALK_NOFOLLOW = 4, +}; + +struct word_at_a_time { + const long unsigned int one_bits; + const long unsigned int high_bits; +}; + +struct f_owner_ex { + int type; + __kernel_pid_t pid; +}; + +struct flock { + short int l_type; + short int l_whence; + __kernel_off_t l_start; + __kernel_off_t l_len; + __kernel_pid_t l_pid; +}; + +struct compat_flock { + short int l_type; + short int l_whence; + compat_off_t l_start; + compat_off_t l_len; + compat_pid_t l_pid; +}; + +struct compat_flock64 { + short int l_type; + short int l_whence; + compat_loff_t l_start; + compat_loff_t l_len; + compat_pid_t l_pid; +} __attribute__((packed)); + +struct file_clone_range { + __s64 src_fd; + __u64 src_offset; + __u64 src_length; + __u64 dest_offset; +}; + +struct file_dedupe_range_info { + __s64 dest_fd; + __u64 dest_offset; + __u64 bytes_deduped; + __s32 status; + __u32 reserved; +}; + +struct file_dedupe_range { + __u64 src_offset; + __u64 src_length; + __u16 dest_count; + __u16 reserved1; + __u32 reserved2; + struct file_dedupe_range_info info[0]; +}; + +typedef int get_block_t(struct inode *, sector_t, struct buffer_head *, int); + +struct fiemap_extent; + +struct fiemap_extent_info { + unsigned int fi_flags; + unsigned int fi_extents_mapped; + unsigned int fi_extents_max; + struct fiemap_extent *fi_extents_start; +}; + +struct space_resv { + __s16 l_type; + __s16 l_whence; + __s64 l_start; + __s64 l_len; + __s32 l_sysid; + __u32 l_pid; + __s32 l_pad[4]; +}; + +struct space_resv_32 { + __s16 l_type; + __s16 l_whence; + __s64 l_start; + __s64 l_len; + __s32 l_sysid; + __u32 l_pid; + __s32 l_pad[4]; +} __attribute__((packed)); + +struct fiemap_extent { + __u64 fe_logical; + __u64 fe_physical; + __u64 fe_length; + __u64 fe_reserved64[2]; + __u32 fe_flags; + __u32 fe_reserved[3]; +}; + +struct fiemap { + __u64 fm_start; + __u64 fm_length; + __u32 fm_flags; + __u32 fm_mapped_extents; + __u32 fm_extent_count; + __u32 fm_reserved; + struct fiemap_extent fm_extents[0]; +}; + +struct linux_dirent64 { + u64 d_ino; + s64 d_off; + short unsigned int d_reclen; + unsigned char d_type; + char d_name[0]; +}; + +struct old_linux_dirent { + long unsigned int d_ino; + long unsigned int d_offset; + short unsigned int d_namlen; + char d_name[1]; +}; + +struct readdir_callback { + struct dir_context ctx; + struct old_linux_dirent *dirent; + int result; +}; + +struct linux_dirent { + long unsigned int d_ino; + long unsigned int d_off; + short unsigned int d_reclen; + char d_name[1]; +}; + +struct getdents_callback { + struct dir_context ctx; + struct linux_dirent *current_dir; + int prev_reclen; + int count; + int error; +}; + +struct getdents_callback64 { + struct dir_context ctx; + struct linux_dirent64 *current_dir; + int prev_reclen; + int count; + int error; +}; + +struct compat_old_linux_dirent { + compat_ulong_t d_ino; + compat_ulong_t d_offset; + short unsigned int d_namlen; + char d_name[1]; +}; + +struct compat_readdir_callback { + struct dir_context ctx; + struct compat_old_linux_dirent *dirent; + int result; +}; + +struct compat_linux_dirent { + compat_ulong_t d_ino; + compat_ulong_t d_off; + short unsigned int d_reclen; + char d_name[1]; +}; + +struct compat_getdents_callback { + struct dir_context ctx; + struct compat_linux_dirent *current_dir; + int prev_reclen; + int count; + int error; +}; + +typedef struct { + long unsigned int fds_bits[16]; +} __kernel_fd_set; + +typedef __kernel_fd_set fd_set; + +struct poll_table_entry { + struct file *filp; + __poll_t key; + wait_queue_entry_t wait; + wait_queue_head_t *wait_address; +}; + +struct poll_table_page; + +struct poll_wqueues { + poll_table pt; + struct poll_table_page *table; + struct task_struct *polling_task; + int triggered; + int error; + int inline_index; + struct poll_table_entry inline_entries[9]; +}; + +struct poll_table_page { + struct poll_table_page *next; + struct poll_table_entry *entry; + struct poll_table_entry entries[0]; +}; + +enum poll_time_type { + PT_TIMEVAL = 0, + PT_OLD_TIMEVAL = 1, + PT_TIMESPEC = 2, + PT_OLD_TIMESPEC = 3, +}; + +typedef struct { + long unsigned int *in; + long unsigned int *out; + long unsigned int *ex; + long unsigned int *res_in; + long unsigned int *res_out; + long unsigned int *res_ex; +} fd_set_bits; + +struct sigset_argpack { + sigset_t *p; + size_t size; +}; + +struct poll_list { + struct poll_list *next; + int len; + struct pollfd entries[0]; +}; + +struct compat_sel_arg_struct { + compat_ulong_t n; + compat_uptr_t inp; + compat_uptr_t outp; + compat_uptr_t exp; + compat_uptr_t tvp; +}; + +struct compat_sigset_argpack { + compat_uptr_t p; + compat_size_t size; +}; + +enum dentry_d_lock_class { + DENTRY_D_LOCK_NORMAL = 0, + DENTRY_D_LOCK_NESTED = 1, +}; + +struct external_name { + union { + atomic_t count; + struct callback_head head; + } u; + unsigned char name[0]; +}; + +enum d_walk_ret { + D_WALK_CONTINUE = 0, + D_WALK_QUIT = 1, + D_WALK_NORETRY = 2, + D_WALK_SKIP = 3, +}; + +struct check_mount { + struct vfsmount *mnt; + unsigned int mounted; +}; + +struct select_data { + struct dentry *start; + union { + long int found; + struct dentry *victim; + }; + struct list_head dispose; +}; + +struct fsxattr { + __u32 fsx_xflags; + __u32 fsx_extsize; + __u32 fsx_nextents; + __u32 fsx_projid; + __u32 fsx_cowextsize; + unsigned char fsx_pad[8]; +}; + +enum file_time_flags { + S_ATIME = 1, + S_MTIME = 2, + S_CTIME = 4, + S_VERSION = 8, +}; + +struct proc_mounts { + struct mnt_namespace *ns; + struct path root; + int (*show)(struct seq_file *, struct vfsmount *); + struct mount cursor; +}; + +enum umount_tree_flags { + UMOUNT_SYNC = 1, + UMOUNT_PROPAGATE = 2, + UMOUNT_CONNECTED = 4, +}; + +struct simple_transaction_argresp { + ssize_t size; + char data[0]; +}; + +struct simple_attr { + int (*get)(void *, u64 *); + int (*set)(void *, u64); + char get_buf[24]; + char set_buf[24]; + void *data; + const char *fmt; + struct mutex mutex; +}; + +struct wb_writeback_work { + long int nr_pages; + struct super_block *sb; + enum writeback_sync_modes sync_mode; + unsigned int tagged_writepages: 1; + unsigned int for_kupdate: 1; + unsigned int range_cyclic: 1; + unsigned int for_background: 1; + unsigned int for_sync: 1; + unsigned int auto_free: 1; + enum wb_reason reason; + struct list_head list; + struct wb_completion *done; +}; + +struct trace_event_raw_writeback_page_template { + struct trace_entry ent; + char name[32]; + ino_t ino; + long unsigned int index; + char __data[0]; +}; + +struct trace_event_raw_writeback_dirty_inode_template { + struct trace_entry ent; + char name[32]; + ino_t ino; + long unsigned int state; + long unsigned int flags; + char __data[0]; +}; + +struct trace_event_raw_inode_foreign_history { + struct trace_entry ent; + char name[32]; + ino_t ino; + ino_t cgroup_ino; + unsigned int history; + char __data[0]; +}; + +struct trace_event_raw_inode_switch_wbs { + struct trace_entry ent; + char name[32]; + ino_t ino; + ino_t old_cgroup_ino; + ino_t new_cgroup_ino; + char __data[0]; +}; + +struct trace_event_raw_track_foreign_dirty { + struct trace_entry ent; + char name[32]; + u64 bdi_id; + ino_t ino; + unsigned int memcg_id; + ino_t cgroup_ino; + ino_t page_cgroup_ino; + char __data[0]; +}; + +struct trace_event_raw_flush_foreign { + struct trace_entry ent; + char name[32]; + ino_t cgroup_ino; + unsigned int frn_bdi_id; + unsigned int frn_memcg_id; + char __data[0]; +}; + +struct trace_event_raw_writeback_write_inode_template { + struct trace_entry ent; + char name[32]; + ino_t ino; + int sync_mode; + ino_t cgroup_ino; + char __data[0]; +}; + +struct trace_event_raw_writeback_work_class { + struct trace_entry ent; + char name[32]; + long int nr_pages; + dev_t sb_dev; + int sync_mode; + int for_kupdate; + int range_cyclic; + int for_background; + int reason; + ino_t cgroup_ino; + char __data[0]; +}; + +struct trace_event_raw_writeback_pages_written { + struct trace_entry ent; + long int pages; + char __data[0]; +}; + +struct trace_event_raw_writeback_class { + struct trace_entry ent; + char name[32]; + ino_t cgroup_ino; + char __data[0]; +}; + +struct trace_event_raw_writeback_bdi_register { + struct trace_entry ent; + char name[32]; + char __data[0]; +}; + +struct trace_event_raw_wbc_class { + struct trace_entry ent; + char name[32]; + long int nr_to_write; + long int pages_skipped; + int sync_mode; + int for_kupdate; + int for_background; + int for_reclaim; + int range_cyclic; + long int range_start; + long int range_end; + ino_t cgroup_ino; + char __data[0]; +}; + +struct trace_event_raw_writeback_queue_io { + struct trace_entry ent; + char name[32]; + long unsigned int older; + long int age; + int moved; + int reason; + ino_t cgroup_ino; + char __data[0]; +}; + +struct trace_event_raw_global_dirty_state { + struct trace_entry ent; + long unsigned int nr_dirty; + long unsigned int nr_writeback; + long unsigned int background_thresh; + long unsigned int dirty_thresh; + long unsigned int dirty_limit; + long unsigned int nr_dirtied; + long unsigned int nr_written; + char __data[0]; +}; + +struct trace_event_raw_bdi_dirty_ratelimit { + struct trace_entry ent; + char bdi[32]; + long unsigned int write_bw; + long unsigned int avg_write_bw; + long unsigned int dirty_rate; + long unsigned int dirty_ratelimit; + long unsigned int task_ratelimit; + long unsigned int balanced_dirty_ratelimit; + ino_t cgroup_ino; + char __data[0]; +}; + +struct trace_event_raw_balance_dirty_pages { + struct trace_entry ent; + char bdi[32]; + long unsigned int limit; + long unsigned int setpoint; + long unsigned int dirty; + long unsigned int bdi_setpoint; + long unsigned int bdi_dirty; + long unsigned int dirty_ratelimit; + long unsigned int task_ratelimit; + unsigned int dirtied; + unsigned int dirtied_pause; + long unsigned int paused; + long int pause; + long unsigned int period; + long int think; + ino_t cgroup_ino; + char __data[0]; +}; + +struct trace_event_raw_writeback_sb_inodes_requeue { + struct trace_entry ent; + char name[32]; + ino_t ino; + long unsigned int state; + long unsigned int dirtied_when; + ino_t cgroup_ino; + char __data[0]; +}; + +struct trace_event_raw_writeback_congest_waited_template { + struct trace_entry ent; + unsigned int usec_timeout; + unsigned int usec_delayed; + char __data[0]; +}; + +struct trace_event_raw_writeback_single_inode_template { + struct trace_entry ent; + char name[32]; + ino_t ino; + long unsigned int state; + long unsigned int dirtied_when; + long unsigned int writeback_index; + long int nr_to_write; + long unsigned int wrote; + ino_t cgroup_ino; + char __data[0]; +}; + +struct trace_event_raw_writeback_inode_template { + struct trace_entry ent; + dev_t dev; + ino_t ino; + long unsigned int state; + __u16 mode; + long unsigned int dirtied_when; + char __data[0]; +}; + +struct trace_event_data_offsets_writeback_page_template {}; + +struct trace_event_data_offsets_writeback_dirty_inode_template {}; + +struct trace_event_data_offsets_inode_foreign_history {}; + +struct trace_event_data_offsets_inode_switch_wbs {}; + +struct trace_event_data_offsets_track_foreign_dirty {}; + +struct trace_event_data_offsets_flush_foreign {}; + +struct trace_event_data_offsets_writeback_write_inode_template {}; + +struct trace_event_data_offsets_writeback_work_class {}; + +struct trace_event_data_offsets_writeback_pages_written {}; + +struct trace_event_data_offsets_writeback_class {}; + +struct trace_event_data_offsets_writeback_bdi_register {}; + +struct trace_event_data_offsets_wbc_class {}; + +struct trace_event_data_offsets_writeback_queue_io {}; + +struct trace_event_data_offsets_global_dirty_state {}; + +struct trace_event_data_offsets_bdi_dirty_ratelimit {}; + +struct trace_event_data_offsets_balance_dirty_pages {}; + +struct trace_event_data_offsets_writeback_sb_inodes_requeue {}; + +struct trace_event_data_offsets_writeback_congest_waited_template {}; + +struct trace_event_data_offsets_writeback_single_inode_template {}; + +struct trace_event_data_offsets_writeback_inode_template {}; + +typedef void (*btf_trace_writeback_dirty_page)(void *, struct page *, struct address_space *); + +typedef void (*btf_trace_wait_on_page_writeback)(void *, struct page *, struct address_space *); + +typedef void (*btf_trace_writeback_mark_inode_dirty)(void *, struct inode *, int); + +typedef void (*btf_trace_writeback_dirty_inode_start)(void *, struct inode *, int); + +typedef void (*btf_trace_writeback_dirty_inode)(void *, struct inode *, int); + +typedef void (*btf_trace_inode_foreign_history)(void *, struct inode *, struct writeback_control *, unsigned int); + +typedef void (*btf_trace_inode_switch_wbs)(void *, struct inode *, struct bdi_writeback *, struct bdi_writeback *); + +typedef void (*btf_trace_track_foreign_dirty)(void *, struct page *, struct bdi_writeback *); + +typedef void (*btf_trace_flush_foreign)(void *, struct bdi_writeback *, unsigned int, unsigned int); + +typedef void (*btf_trace_writeback_write_inode_start)(void *, struct inode *, struct writeback_control *); + +typedef void (*btf_trace_writeback_write_inode)(void *, struct inode *, struct writeback_control *); + +typedef void (*btf_trace_writeback_queue)(void *, struct bdi_writeback *, struct wb_writeback_work *); + +typedef void (*btf_trace_writeback_exec)(void *, struct bdi_writeback *, struct wb_writeback_work *); + +typedef void (*btf_trace_writeback_start)(void *, struct bdi_writeback *, struct wb_writeback_work *); + +typedef void (*btf_trace_writeback_written)(void *, struct bdi_writeback *, struct wb_writeback_work *); + +typedef void (*btf_trace_writeback_wait)(void *, struct bdi_writeback *, struct wb_writeback_work *); + +typedef void (*btf_trace_writeback_pages_written)(void *, long int); + +typedef void (*btf_trace_writeback_wake_background)(void *, struct bdi_writeback *); + +typedef void (*btf_trace_writeback_bdi_register)(void *, struct backing_dev_info *); + +typedef void (*btf_trace_wbc_writepage)(void *, struct writeback_control *, struct backing_dev_info *); + +typedef void (*btf_trace_writeback_queue_io)(void *, struct bdi_writeback *, struct wb_writeback_work *, long unsigned int, int); + +typedef void (*btf_trace_global_dirty_state)(void *, long unsigned int, long unsigned int); + +typedef void (*btf_trace_bdi_dirty_ratelimit)(void *, struct bdi_writeback *, long unsigned int, long unsigned int); + +typedef void (*btf_trace_balance_dirty_pages)(void *, struct bdi_writeback *, long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, long int, long unsigned int); + +typedef void (*btf_trace_writeback_sb_inodes_requeue)(void *, struct inode *); + +typedef void (*btf_trace_writeback_congestion_wait)(void *, unsigned int, unsigned int); + +typedef void (*btf_trace_writeback_wait_iff_congested)(void *, unsigned int, unsigned int); + +typedef void (*btf_trace_writeback_single_inode_start)(void *, struct inode *, struct writeback_control *, long unsigned int); + +typedef void (*btf_trace_writeback_single_inode)(void *, struct inode *, struct writeback_control *, long unsigned int); + +typedef void (*btf_trace_writeback_lazytime)(void *, struct inode *); + +typedef void (*btf_trace_writeback_lazytime_iput)(void *, struct inode *); + +typedef void (*btf_trace_writeback_dirty_inode_enqueue)(void *, struct inode *); + +typedef void (*btf_trace_sb_mark_inode_writeback)(void *, struct inode *); + +typedef void (*btf_trace_sb_clear_inode_writeback)(void *, struct inode *); + +struct inode_switch_wbs_context { + struct inode *inode; + struct bdi_writeback *new_wb; + struct callback_head callback_head; + struct work_struct work; +}; + +struct splice_desc { + size_t total_len; + unsigned int len; + unsigned int flags; + union { + void *userptr; + struct file *file; + void *data; + } u; + loff_t pos; + loff_t *opos; + size_t num_spliced; + bool need_wakeup; +}; + +typedef int splice_actor(struct pipe_inode_info *, struct pipe_buffer *, struct splice_desc *); + +typedef int splice_direct_actor(struct pipe_inode_info *, struct splice_desc *); + +struct old_utimbuf32 { + old_time32_t actime; + old_time32_t modtime; +}; + +struct utimbuf { + __kernel_old_time_t actime; + __kernel_old_time_t modtime; +}; + +typedef int __kernel_daddr_t; + +struct ustat { + __kernel_daddr_t f_tfree; + __kernel_ino_t f_tinode; + char f_fname[6]; + char f_fpack[6]; +}; + +typedef s32 compat_daddr_t; + +typedef __kernel_fsid_t compat_fsid_t; + +struct compat_statfs { + int f_type; + int f_bsize; + int f_blocks; + int f_bfree; + int f_bavail; + int f_files; + int f_ffree; + compat_fsid_t f_fsid; + int f_namelen; + int f_frsize; + int f_flags; + int f_spare[4]; +}; + +struct compat_ustat { + compat_daddr_t f_tfree; + compat_ino_t f_tinode; + char f_fname[6]; + char f_fpack[6]; +}; + +struct statfs { + __kernel_long_t f_type; + __kernel_long_t f_bsize; + __kernel_long_t f_blocks; + __kernel_long_t f_bfree; + __kernel_long_t f_bavail; + __kernel_long_t f_files; + __kernel_long_t f_ffree; + __kernel_fsid_t f_fsid; + __kernel_long_t f_namelen; + __kernel_long_t f_frsize; + __kernel_long_t f_flags; + __kernel_long_t f_spare[4]; +}; + +struct statfs64 { + __kernel_long_t f_type; + __kernel_long_t f_bsize; + __u64 f_blocks; + __u64 f_bfree; + __u64 f_bavail; + __u64 f_files; + __u64 f_ffree; + __kernel_fsid_t f_fsid; + __kernel_long_t f_namelen; + __kernel_long_t f_frsize; + __kernel_long_t f_flags; + __kernel_long_t f_spare[4]; +}; + +struct compat_statfs64 { + __u32 f_type; + __u32 f_bsize; + __u64 f_blocks; + __u64 f_bfree; + __u64 f_bavail; + __u64 f_files; + __u64 f_ffree; + __kernel_fsid_t f_fsid; + __u32 f_namelen; + __u32 f_frsize; + __u32 f_flags; + __u32 f_spare[4]; +} __attribute__((packed)); + +typedef struct ns_common *ns_get_path_helper_t(void *); + +struct ns_get_path_task_args { + const struct proc_ns_operations *ns_ops; + struct task_struct *task; +}; + +enum legacy_fs_param { + LEGACY_FS_UNSET_PARAMS = 0, + LEGACY_FS_MONOLITHIC_PARAMS = 1, + LEGACY_FS_INDIVIDUAL_PARAMS = 2, +}; + +struct legacy_fs_context { + char *legacy_data; + size_t data_size; + enum legacy_fs_param param_type; +}; + +enum fsconfig_command { + FSCONFIG_SET_FLAG = 0, + FSCONFIG_SET_STRING = 1, + FSCONFIG_SET_BINARY = 2, + FSCONFIG_SET_PATH = 3, + FSCONFIG_SET_PATH_EMPTY = 4, + FSCONFIG_SET_FD = 5, + FSCONFIG_CMD_CREATE = 6, + FSCONFIG_CMD_RECONFIGURE = 7, +}; + +struct dax_device; + +struct iomap_page_ops; + +struct iomap___2 { + u64 addr; + loff_t offset; + u64 length; + u16 type; + u16 flags; + struct block_device *bdev; + struct dax_device *dax_dev; + void *inline_data; + void *private; + const struct iomap_page_ops *page_ops; +}; + +struct iomap_page_ops { + int (*page_prepare)(struct inode *, loff_t, unsigned int, struct iomap___2 *); + void (*page_done)(struct inode *, loff_t, unsigned int, struct page *, struct iomap___2 *); +}; + +struct decrypt_bh_ctx { + struct work_struct work; + struct buffer_head *bh; +}; + +struct bh_lru { + struct buffer_head *bhs[16]; +}; + +struct bh_accounting { + int nr; + int ratelimit; +}; + +enum { + DISK_EVENT_MEDIA_CHANGE = 1, + DISK_EVENT_EJECT_REQUEST = 2, +}; + +struct blk_integrity_profile; + +struct blk_integrity { + const struct blk_integrity_profile *profile; + unsigned char flags; + unsigned char tuple_size; + unsigned char interval_exp; + unsigned char tag_size; +}; + +enum { + BIOSET_NEED_BVECS = 1, + BIOSET_NEED_RESCUER = 2, +}; + +struct bdev_inode { + struct block_device bdev; + struct inode vfs_inode; +}; + +struct blkdev_dio { + union { + struct kiocb *iocb; + struct task_struct *waiter; + }; + size_t size; + atomic_t ref; + bool multi_bio: 1; + bool should_dirty: 1; + bool is_sync: 1; + struct bio bio; +}; + +struct bd_holder_disk { + struct list_head list; + struct gendisk *disk; + int refcnt; +}; + +typedef int dio_iodone_t(struct kiocb *, loff_t, ssize_t, void *); + +typedef void dio_submit_t(struct bio *, struct inode *, loff_t); + +enum { + DIO_LOCKING = 1, + DIO_SKIP_HOLES = 2, +}; + +struct dio_submit { + struct bio *bio; + unsigned int blkbits; + unsigned int blkfactor; + unsigned int start_zero_done; + int pages_in_io; + sector_t block_in_file; + unsigned int blocks_available; + int reap_counter; + sector_t final_block_in_request; + int boundary; + get_block_t *get_block; + dio_submit_t *submit_io; + loff_t logical_offset_in_bio; + sector_t final_block_in_bio; + sector_t next_block_for_io; + struct page *cur_page; + unsigned int cur_page_offset; + unsigned int cur_page_len; + sector_t cur_page_block; + loff_t cur_page_fs_offset; + struct iov_iter *iter; + unsigned int head; + unsigned int tail; + size_t from; + size_t to; +}; + +struct dio { + int flags; + int op; + int op_flags; + blk_qc_t bio_cookie; + struct gendisk *bio_disk; + struct inode *inode; + loff_t i_size; + dio_iodone_t *end_io; + void *private; + spinlock_t bio_lock; + int page_errors; + int is_async; + bool defer_completion; + bool should_dirty; + int io_error; + long unsigned int refcount; + struct bio *bio_list; + struct task_struct *waiter; + struct kiocb *iocb; + ssize_t result; + union { + struct page *pages[64]; + struct work_struct complete_work; + }; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct bvec_iter_all { + struct bio_vec bv; + int idx; + unsigned int done; +}; + +struct mpage_readpage_args { + struct bio *bio; + struct page *page; + unsigned int nr_pages; + bool is_readahead; + sector_t last_block_in_bio; + struct buffer_head map_bh; + long unsigned int first_logical_block; + get_block_t *get_block; +}; + +struct mpage_data { + struct bio *bio; + sector_t last_block_in_bio; + get_block_t *get_block; + unsigned int use_writepage; +}; + +typedef u32 nlink_t; + +typedef int (*proc_write_t)(struct file *, char *, size_t); + +struct proc_dir_entry { + atomic_t in_use; + refcount_t refcnt; + struct list_head pde_openers; + spinlock_t pde_unload_lock; + struct completion *pde_unload_completion; + const struct inode_operations *proc_iops; + union { + const struct proc_ops *proc_ops; + const struct file_operations *proc_dir_ops; + }; + const struct dentry_operations *proc_dops; + union { + const struct seq_operations *seq_ops; + int (*single_show)(struct seq_file *, void *); + }; + proc_write_t write; + void *data; + unsigned int state_size; + unsigned int low_ino; + nlink_t nlink; + kuid_t uid; + kgid_t gid; + loff_t size; + struct proc_dir_entry *parent; + struct rb_root subdir; + struct rb_node subdir_node; + char *name; + umode_t mode; + u8 flags; + u8 namelen; + char inline_name[0]; +}; + +union proc_op { + int (*proc_get_link)(struct dentry *, struct path *); + int (*proc_show)(struct seq_file *, struct pid_namespace *, struct pid *, struct task_struct *); + const char *lsm; +}; + +struct proc_inode { + struct pid *pid; + unsigned int fd; + union proc_op op; + struct proc_dir_entry *pde; + struct ctl_table_header *sysctl; + struct ctl_table *sysctl_entry; + struct hlist_node sibling_inodes; + const struct proc_ns_operations *ns_ops; + struct inode vfs_inode; +}; + +struct proc_fs_opts { + int flag; + const char *str; +}; + +struct file_handle { + __u32 handle_bytes; + int handle_type; + unsigned char f_handle[0]; +}; + +struct inotify_inode_mark { + struct fsnotify_mark fsn_mark; + int wd; +}; + +struct dnotify_struct { + struct dnotify_struct *dn_next; + __u32 dn_mask; + int dn_fd; + struct file *dn_filp; + fl_owner_t dn_owner; +}; + +struct dnotify_mark { + struct fsnotify_mark fsn_mark; + struct dnotify_struct *dn; +}; + +struct inotify_event_info { + struct fsnotify_event fse; + u32 mask; + int wd; + u32 sync_cookie; + int name_len; + char name[0]; +}; + +struct inotify_event { + __s32 wd; + __u32 mask; + __u32 cookie; + __u32 len; + char name[0]; +}; + +struct epoll_event { + __poll_t events; + __u64 data; +} __attribute__((packed)); + +struct epoll_filefd { + struct file *file; + int fd; +} __attribute__((packed)); + +struct nested_call_node { + struct list_head llink; + void *cookie; + void *ctx; +}; + +struct nested_calls { + struct list_head tasks_call_list; + spinlock_t lock; +}; + +struct eventpoll; + +struct epitem { + union { + struct rb_node rbn; + struct callback_head rcu; + }; + struct list_head rdllink; + struct epitem *next; + struct epoll_filefd ffd; + int nwait; + struct list_head pwqlist; + struct eventpoll *ep; + struct list_head fllink; + struct wakeup_source *ws; + struct epoll_event event; +}; + +struct eventpoll { + struct mutex mtx; + wait_queue_head_t wq; + wait_queue_head_t poll_wait; + struct list_head rdllist; + rwlock_t lock; + struct rb_root_cached rbr; + struct epitem *ovflist; + struct wakeup_source *ws; + struct user_struct *user; + struct file *file; + u64 gen; + unsigned int napi_id; +}; + +struct eppoll_entry { + struct list_head llink; + struct epitem *base; + wait_queue_entry_t wait; + wait_queue_head_t *whead; +}; + +struct ep_pqueue { + poll_table pt; + struct epitem *epi; +}; + +struct ep_send_events_data { + int maxevents; + struct epoll_event *events; + int res; +}; + +struct signalfd_siginfo { + __u32 ssi_signo; + __s32 ssi_errno; + __s32 ssi_code; + __u32 ssi_pid; + __u32 ssi_uid; + __s32 ssi_fd; + __u32 ssi_tid; + __u32 ssi_band; + __u32 ssi_overrun; + __u32 ssi_trapno; + __s32 ssi_status; + __s32 ssi_int; + __u64 ssi_ptr; + __u64 ssi_utime; + __u64 ssi_stime; + __u64 ssi_addr; + __u16 ssi_addr_lsb; + __u16 __pad2; + __s32 ssi_syscall; + __u64 ssi_call_addr; + __u32 ssi_arch; + __u8 __pad[28]; +}; + +struct signalfd_ctx { + sigset_t sigmask; +}; + +struct timerfd_ctx { + union { + struct hrtimer tmr; + struct alarm alarm; + } t; + ktime_t tintv; + ktime_t moffs; + wait_queue_head_t wqh; + u64 ticks; + int clockid; + short unsigned int expired; + short unsigned int settime_flags; + struct callback_head rcu; + struct list_head clist; + spinlock_t cancel_lock; + bool might_cancel; +}; + +struct eventfd_ctx___2 { + struct kref kref; + wait_queue_head_t wqh; + __u64 count; + unsigned int flags; + int id; +}; + +struct kioctx; + +struct kioctx_table { + struct callback_head rcu; + unsigned int nr; + struct kioctx *table[0]; +}; + +typedef __kernel_ulong_t aio_context_t; + +enum { + IOCB_CMD_PREAD = 0, + IOCB_CMD_PWRITE = 1, + IOCB_CMD_FSYNC = 2, + IOCB_CMD_FDSYNC = 3, + IOCB_CMD_POLL = 5, + IOCB_CMD_NOOP = 6, + IOCB_CMD_PREADV = 7, + IOCB_CMD_PWRITEV = 8, +}; + +struct io_event { + __u64 data; + __u64 obj; + __s64 res; + __s64 res2; +}; + +struct iocb { + __u64 aio_data; + __u32 aio_key; + __kernel_rwf_t aio_rw_flags; + __u16 aio_lio_opcode; + __s16 aio_reqprio; + __u32 aio_fildes; + __u64 aio_buf; + __u64 aio_nbytes; + __s64 aio_offset; + __u64 aio_reserved2; + __u32 aio_flags; + __u32 aio_resfd; +}; + +typedef u32 compat_aio_context_t; + +typedef int kiocb_cancel_fn(struct kiocb *); + +struct aio_ring { + unsigned int id; + unsigned int nr; + unsigned int head; + unsigned int tail; + unsigned int magic; + unsigned int compat_features; + unsigned int incompat_features; + unsigned int header_length; + struct io_event io_events[0]; +}; + +struct kioctx_cpu; + +struct ctx_rq_wait; + +struct kioctx { + struct percpu_ref users; + atomic_t dead; + struct percpu_ref reqs; + long unsigned int user_id; + struct kioctx_cpu *cpu; + unsigned int req_batch; + unsigned int max_reqs; + unsigned int nr_events; + long unsigned int mmap_base; + long unsigned int mmap_size; + struct page **ring_pages; + long int nr_pages; + struct rcu_work free_rwork; + struct ctx_rq_wait *rq_wait; + long: 64; + long: 64; + long: 64; + struct { + atomic_t reqs_available; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + }; + struct { + spinlock_t ctx_lock; + struct list_head active_reqs; + long: 64; + long: 64; + long: 64; + }; + struct { + struct mutex ring_lock; + wait_queue_head_t wait; + long: 64; + long: 64; + long: 64; + }; + struct { + unsigned int tail; + unsigned int completed_events; + spinlock_t completion_lock; + long: 64; + long: 64; + long: 64; + long: 64; + }; + struct page *internal_pages[8]; + struct file *aio_ring_file; + unsigned int id; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct kioctx_cpu { + unsigned int reqs_available; +}; + +struct ctx_rq_wait { + struct completion comp; + atomic_t count; +}; + +struct fsync_iocb { + struct file *file; + struct work_struct work; + bool datasync; + struct cred *creds; +}; + +struct poll_iocb { + struct file *file; + struct wait_queue_head *head; + __poll_t events; + bool done; + bool cancelled; + struct wait_queue_entry wait; + struct work_struct work; +}; + +struct aio_kiocb { + union { + struct file *ki_filp; + struct kiocb rw; + struct fsync_iocb fsync; + struct poll_iocb poll; + }; + struct kioctx *ki_ctx; + kiocb_cancel_fn *ki_cancel; + struct io_event ki_res; + struct list_head ki_list; + refcount_t ki_refcnt; + struct eventfd_ctx *ki_eventfd; +}; + +struct aio_poll_table { + struct poll_table_struct pt; + struct aio_kiocb *iocb; + int error; +}; + +struct __aio_sigset { + const sigset_t *sigmask; + size_t sigsetsize; +}; + +struct __compat_aio_sigset { + compat_uptr_t sigmask; + compat_size_t sigsetsize; +}; + +enum { + PERCPU_REF_INIT_ATOMIC = 1, + PERCPU_REF_INIT_DEAD = 2, + PERCPU_REF_ALLOW_REINIT = 4, +}; + +struct user_msghdr { + void *msg_name; + int msg_namelen; + struct iovec *msg_iov; + __kernel_size_t msg_iovlen; + void *msg_control; + __kernel_size_t msg_controllen; + unsigned int msg_flags; +}; + +typedef s32 compat_ssize_t; + +struct compat_msghdr { + compat_uptr_t msg_name; + compat_int_t msg_namelen; + compat_uptr_t msg_iov; + compat_size_t msg_iovlen; + compat_uptr_t msg_control; + compat_size_t msg_controllen; + compat_uint_t msg_flags; +}; + +struct scm_fp_list { + short int count; + short int max; + struct user_struct *user; + struct file *fp[253]; +}; + +struct unix_skb_parms { + struct pid *pid; + kuid_t uid; + kgid_t gid; + struct scm_fp_list *fp; + u32 secid; + u32 consumed; +}; + +struct trace_event_raw_io_uring_create { + struct trace_entry ent; + int fd; + void *ctx; + u32 sq_entries; + u32 cq_entries; + u32 flags; + char __data[0]; +}; + +struct trace_event_raw_io_uring_register { + struct trace_entry ent; + void *ctx; + unsigned int opcode; + unsigned int nr_files; + unsigned int nr_bufs; + bool eventfd; + long int ret; + char __data[0]; +}; + +struct trace_event_raw_io_uring_file_get { + struct trace_entry ent; + void *ctx; + int fd; + char __data[0]; +}; + +struct io_wq_work; + +struct trace_event_raw_io_uring_queue_async_work { + struct trace_entry ent; + void *ctx; + int rw; + void *req; + struct io_wq_work *work; + unsigned int flags; + char __data[0]; +}; + +struct io_wq_work_node { + struct io_wq_work_node *next; +}; + +struct io_wq_work { + struct io_wq_work_node list; + struct io_identity *identity; + unsigned int flags; +}; + +struct trace_event_raw_io_uring_defer { + struct trace_entry ent; + void *ctx; + void *req; + long long unsigned int data; + char __data[0]; +}; + +struct trace_event_raw_io_uring_link { + struct trace_entry ent; + void *ctx; + void *req; + void *target_req; + char __data[0]; +}; + +struct trace_event_raw_io_uring_cqring_wait { + struct trace_entry ent; + void *ctx; + int min_events; + char __data[0]; +}; + +struct trace_event_raw_io_uring_fail_link { + struct trace_entry ent; + void *req; + void *link; + char __data[0]; +}; + +struct trace_event_raw_io_uring_complete { + struct trace_entry ent; + void *ctx; + u64 user_data; + long int res; + char __data[0]; +}; + +struct trace_event_raw_io_uring_submit_sqe { + struct trace_entry ent; + void *ctx; + u8 opcode; + u64 user_data; + bool force_nonblock; + bool sq_thread; + char __data[0]; +}; + +struct trace_event_raw_io_uring_poll_arm { + struct trace_entry ent; + void *ctx; + u8 opcode; + u64 user_data; + int mask; + int events; + char __data[0]; +}; + +struct trace_event_raw_io_uring_poll_wake { + struct trace_entry ent; + void *ctx; + u8 opcode; + u64 user_data; + int mask; + char __data[0]; +}; + +struct trace_event_raw_io_uring_task_add { + struct trace_entry ent; + void *ctx; + u8 opcode; + u64 user_data; + int mask; + char __data[0]; +}; + +struct trace_event_raw_io_uring_task_run { + struct trace_entry ent; + void *ctx; + u8 opcode; + u64 user_data; + char __data[0]; +}; + +struct trace_event_data_offsets_io_uring_create {}; + +struct trace_event_data_offsets_io_uring_register {}; + +struct trace_event_data_offsets_io_uring_file_get {}; + +struct trace_event_data_offsets_io_uring_queue_async_work {}; + +struct trace_event_data_offsets_io_uring_defer {}; + +struct trace_event_data_offsets_io_uring_link {}; + +struct trace_event_data_offsets_io_uring_cqring_wait {}; + +struct trace_event_data_offsets_io_uring_fail_link {}; + +struct trace_event_data_offsets_io_uring_complete {}; + +struct trace_event_data_offsets_io_uring_submit_sqe {}; + +struct trace_event_data_offsets_io_uring_poll_arm {}; + +struct trace_event_data_offsets_io_uring_poll_wake {}; + +struct trace_event_data_offsets_io_uring_task_add {}; + +struct trace_event_data_offsets_io_uring_task_run {}; + +typedef void (*btf_trace_io_uring_create)(void *, int, void *, u32, u32, u32); + +typedef void (*btf_trace_io_uring_register)(void *, void *, unsigned int, unsigned int, unsigned int, bool, long int); + +typedef void (*btf_trace_io_uring_file_get)(void *, void *, int); + +typedef void (*btf_trace_io_uring_queue_async_work)(void *, void *, int, void *, struct io_wq_work *, unsigned int); + +typedef void (*btf_trace_io_uring_defer)(void *, void *, void *, long long unsigned int); + +typedef void (*btf_trace_io_uring_link)(void *, void *, void *, void *); + +typedef void (*btf_trace_io_uring_cqring_wait)(void *, void *, int); + +typedef void (*btf_trace_io_uring_fail_link)(void *, void *, void *); + +typedef void (*btf_trace_io_uring_complete)(void *, void *, u64, long int); + +typedef void (*btf_trace_io_uring_submit_sqe)(void *, void *, u8, u64, bool, bool); + +typedef void (*btf_trace_io_uring_poll_arm)(void *, void *, u8, u64, int, int); + +typedef void (*btf_trace_io_uring_poll_wake)(void *, void *, u8, u64, int); + +typedef void (*btf_trace_io_uring_task_add)(void *, void *, u8, u64, int); + +typedef void (*btf_trace_io_uring_task_run)(void *, void *, u8, u64); + +struct io_uring_sqe { + __u8 opcode; + __u8 flags; + __u16 ioprio; + __s32 fd; + union { + __u64 off; + __u64 addr2; + }; + union { + __u64 addr; + __u64 splice_off_in; + }; + __u32 len; + union { + __kernel_rwf_t rw_flags; + __u32 fsync_flags; + __u16 poll_events; + __u32 poll32_events; + __u32 sync_range_flags; + __u32 msg_flags; + __u32 timeout_flags; + __u32 accept_flags; + __u32 cancel_flags; + __u32 open_flags; + __u32 statx_flags; + __u32 fadvise_advice; + __u32 splice_flags; + }; + __u64 user_data; + union { + struct { + union { + __u16 buf_index; + __u16 buf_group; + }; + __u16 personality; + __s32 splice_fd_in; + }; + __u64 __pad2[3]; + }; +}; + +enum { + IOSQE_FIXED_FILE_BIT = 0, + IOSQE_IO_DRAIN_BIT = 1, + IOSQE_IO_LINK_BIT = 2, + IOSQE_IO_HARDLINK_BIT = 3, + IOSQE_ASYNC_BIT = 4, + IOSQE_BUFFER_SELECT_BIT = 5, +}; + +enum { + IORING_OP_NOP = 0, + IORING_OP_READV = 1, + IORING_OP_WRITEV = 2, + IORING_OP_FSYNC = 3, + IORING_OP_READ_FIXED = 4, + IORING_OP_WRITE_FIXED = 5, + IORING_OP_POLL_ADD = 6, + IORING_OP_POLL_REMOVE = 7, + IORING_OP_SYNC_FILE_RANGE = 8, + IORING_OP_SENDMSG = 9, + IORING_OP_RECVMSG = 10, + IORING_OP_TIMEOUT = 11, + IORING_OP_TIMEOUT_REMOVE = 12, + IORING_OP_ACCEPT = 13, + IORING_OP_ASYNC_CANCEL = 14, + IORING_OP_LINK_TIMEOUT = 15, + IORING_OP_CONNECT = 16, + IORING_OP_FALLOCATE = 17, + IORING_OP_OPENAT = 18, + IORING_OP_CLOSE = 19, + IORING_OP_FILES_UPDATE = 20, + IORING_OP_STATX = 21, + IORING_OP_READ = 22, + IORING_OP_WRITE = 23, + IORING_OP_FADVISE = 24, + IORING_OP_MADVISE = 25, + IORING_OP_SEND = 26, + IORING_OP_RECV = 27, + IORING_OP_OPENAT2 = 28, + IORING_OP_EPOLL_CTL = 29, + IORING_OP_SPLICE = 30, + IORING_OP_PROVIDE_BUFFERS = 31, + IORING_OP_REMOVE_BUFFERS = 32, + IORING_OP_TEE = 33, + IORING_OP_LAST = 34, +}; + +struct io_uring_cqe { + __u64 user_data; + __s32 res; + __u32 flags; +}; + +enum { + IORING_CQE_BUFFER_SHIFT = 16, +}; + +struct io_sqring_offsets { + __u32 head; + __u32 tail; + __u32 ring_mask; + __u32 ring_entries; + __u32 flags; + __u32 dropped; + __u32 array; + __u32 resv1; + __u64 resv2; +}; + +struct io_cqring_offsets { + __u32 head; + __u32 tail; + __u32 ring_mask; + __u32 ring_entries; + __u32 overflow; + __u32 cqes; + __u32 flags; + __u32 resv1; + __u64 resv2; +}; + +struct io_uring_params { + __u32 sq_entries; + __u32 cq_entries; + __u32 flags; + __u32 sq_thread_cpu; + __u32 sq_thread_idle; + __u32 features; + __u32 wq_fd; + __u32 resv[3]; + struct io_sqring_offsets sq_off; + struct io_cqring_offsets cq_off; +}; + +enum { + IORING_REGISTER_BUFFERS = 0, + IORING_UNREGISTER_BUFFERS = 1, + IORING_REGISTER_FILES = 2, + IORING_UNREGISTER_FILES = 3, + IORING_REGISTER_EVENTFD = 4, + IORING_UNREGISTER_EVENTFD = 5, + IORING_REGISTER_FILES_UPDATE = 6, + IORING_REGISTER_EVENTFD_ASYNC = 7, + IORING_REGISTER_PROBE = 8, + IORING_REGISTER_PERSONALITY = 9, + IORING_UNREGISTER_PERSONALITY = 10, + IORING_REGISTER_RESTRICTIONS = 11, + IORING_REGISTER_ENABLE_RINGS = 12, + IORING_REGISTER_LAST = 13, +}; + +struct io_uring_files_update { + __u32 offset; + __u32 resv; + __u64 fds; +}; + +struct io_uring_probe_op { + __u8 op; + __u8 resv; + __u16 flags; + __u32 resv2; +}; + +struct io_uring_probe { + __u8 last_op; + __u8 ops_len; + __u16 resv; + __u32 resv2[3]; + struct io_uring_probe_op ops[0]; +}; + +struct io_uring_restriction { + __u16 opcode; + union { + __u8 register_op; + __u8 sqe_op; + __u8 sqe_flags; + }; + __u8 resv; + __u32 resv2[3]; +}; + +enum { + IORING_RESTRICTION_REGISTER_OP = 0, + IORING_RESTRICTION_SQE_OP = 1, + IORING_RESTRICTION_SQE_FLAGS_ALLOWED = 2, + IORING_RESTRICTION_SQE_FLAGS_REQUIRED = 3, + IORING_RESTRICTION_LAST = 4, +}; + +enum { + IO_WQ_WORK_CANCEL = 1, + IO_WQ_WORK_HASHED = 2, + IO_WQ_WORK_UNBOUND = 4, + IO_WQ_WORK_NO_CANCEL = 8, + IO_WQ_WORK_CONCURRENT = 16, + IO_WQ_WORK_FILES = 32, + IO_WQ_WORK_FS = 64, + IO_WQ_WORK_MM = 128, + IO_WQ_WORK_CREDS = 256, + IO_WQ_WORK_BLKCG = 512, + IO_WQ_WORK_FSIZE = 1024, + IO_WQ_HASH_SHIFT = 24, +}; + +enum io_wq_cancel { + IO_WQ_CANCEL_OK = 0, + IO_WQ_CANCEL_RUNNING = 1, + IO_WQ_CANCEL_NOTFOUND = 2, +}; + +typedef void free_work_fn(struct io_wq_work *); + +typedef struct io_wq_work *io_wq_work_fn(struct io_wq_work *); + +struct io_wq_data { + struct user_struct *user; + io_wq_work_fn *do_work; + free_work_fn *free_work; +}; + +struct io_uring { + u32 head; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + u32 tail; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct io_rings { + struct io_uring sq; + struct io_uring cq; + u32 sq_ring_mask; + u32 cq_ring_mask; + u32 sq_ring_entries; + u32 cq_ring_entries; + u32 sq_dropped; + u32 sq_flags; + u32 cq_flags; + u32 cq_overflow; + long: 64; + long: 64; + long: 64; + long: 64; + struct io_uring_cqe cqes[0]; +}; + +struct io_mapped_ubuf { + u64 ubuf; + size_t len; + struct bio_vec *bvec; + unsigned int nr_bvecs; + long unsigned int acct_pages; +}; + +struct fixed_file_table { + struct file **files; +}; + +struct fixed_file_data; + +struct fixed_file_ref_node { + struct percpu_ref refs; + struct list_head node; + struct list_head file_list; + struct fixed_file_data *file_data; + struct llist_node llist; +}; + +struct io_ring_ctx; + +struct fixed_file_data { + struct fixed_file_table *table; + struct io_ring_ctx *ctx; + struct fixed_file_ref_node *node; + struct percpu_ref refs; + struct completion done; + struct list_head ref_list; + spinlock_t lock; +}; + +struct io_wq; + +struct io_restriction { + long unsigned int register_op[1]; + long unsigned int sqe_op[1]; + u8 sqe_flags_allowed; + u8 sqe_flags_required; + bool registered; +}; + +struct io_sq_data; + +struct io_kiocb; + +struct io_ring_ctx { + struct { + struct percpu_ref refs; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + }; + struct { + unsigned int flags; + unsigned int compat: 1; + unsigned int limit_mem: 1; + unsigned int cq_overflow_flushed: 1; + unsigned int drain_next: 1; + unsigned int eventfd_async: 1; + unsigned int restricted: 1; + u32 *sq_array; + unsigned int cached_sq_head; + unsigned int sq_entries; + unsigned int sq_mask; + unsigned int sq_thread_idle; + unsigned int cached_sq_dropped; + unsigned int cached_cq_overflow; + long unsigned int sq_check_overflow; + struct list_head defer_list; + struct list_head timeout_list; + struct list_head cq_overflow_list; + wait_queue_head_t inflight_wait; + struct io_uring_sqe *sq_sqes; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + }; + struct io_rings *rings; + struct io_wq *io_wq; + struct task_struct *sqo_task; + struct mm_struct *mm_account; + struct cgroup_subsys_state *sqo_blkcg_css; + struct io_sq_data *sq_data; + struct wait_queue_head sqo_sq_wait; + struct wait_queue_entry sqo_wait_entry; + struct list_head sqd_list; + struct fixed_file_data *file_data; + unsigned int nr_user_files; + unsigned int nr_user_bufs; + struct io_mapped_ubuf *user_bufs; + struct user_struct *user; + const struct cred *creds; + kuid_t loginuid; + unsigned int sessionid; + struct completion ref_comp; + struct completion sq_thread_comp; + struct io_kiocb *fallback_req; + struct socket *ring_sock; + struct idr io_buffer_idr; + struct idr personality_idr; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct { + unsigned int cached_cq_tail; + unsigned int cq_entries; + unsigned int cq_mask; + atomic_t cq_timeouts; + long unsigned int cq_check_overflow; + struct wait_queue_head cq_wait; + struct fasync_struct *cq_fasync; + struct eventfd_ctx *cq_ev_fd; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + }; + struct { + struct mutex uring_lock; + wait_queue_head_t wait; + long: 64; + long: 64; + long: 64; + }; + struct { + spinlock_t completion_lock; + struct list_head iopoll_list; + struct hlist_head *cancel_hash; + unsigned int cancel_hash_bits; + bool poll_multi_file; + spinlock_t inflight_lock; + struct list_head inflight_list; + long: 64; + long: 64; + long: 64; + long: 64; + }; + struct delayed_work file_put_work; + struct llist_head file_put_llist; + struct work_struct exit_work; + struct io_restriction restrictions; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct io_buffer { + struct list_head list; + __u64 addr; + __s32 len; + __u16 bid; +}; + +struct io_sq_data { + refcount_t refs; + struct mutex lock; + struct list_head ctx_list; + struct list_head ctx_new_list; + struct mutex ctx_lock; + struct task_struct *thread; + struct wait_queue_head wait; +}; + +struct io_rw { + struct kiocb kiocb; + u64 addr; + u64 len; +}; + +struct io_poll_iocb { + struct file *file; + union { + struct wait_queue_head *head; + u64 addr; + }; + __poll_t events; + bool done; + bool canceled; + struct wait_queue_entry wait; +}; + +struct io_accept { + struct file *file; + struct sockaddr *addr; + int *addr_len; + int flags; + long unsigned int nofile; +}; + +struct io_sync { + struct file *file; + loff_t len; + loff_t off; + int flags; + int mode; +}; + +struct io_cancel { + struct file *file; + u64 addr; +}; + +struct io_timeout { + struct file *file; + u32 off; + u32 target_seq; + struct list_head list; +}; + +struct io_timeout_rem { + struct file *file; + u64 addr; +}; + +struct io_connect { + struct file *file; + struct sockaddr *addr; + int addr_len; +}; + +struct io_sr_msg { + struct file *file; + union { + struct user_msghdr *umsg; + void *buf; + }; + int msg_flags; + int bgid; + size_t len; + struct io_buffer *kbuf; +}; + +struct io_open { + struct file *file; + int dfd; + struct filename *filename; + struct open_how how; + long unsigned int nofile; +}; + +struct io_close { + struct file *file; + struct file *put_file; + int fd; +}; + +struct io_files_update { + struct file *file; + u64 arg; + u32 nr_args; + u32 offset; +}; + +struct io_fadvise { + struct file *file; + u64 offset; + u32 len; + u32 advice; +}; + +struct io_madvise { + struct file *file; + u64 addr; + u32 len; + u32 advice; +}; + +struct io_epoll { + struct file *file; + int epfd; + int op; + int fd; + struct epoll_event event; +} __attribute__((packed)); + +struct io_splice { + struct file *file_out; + struct file *file_in; + loff_t off_out; + loff_t off_in; + u64 len; + unsigned int flags; +}; + +struct io_provide_buf { + struct file *file; + __u64 addr; + __s32 len; + __u32 bgid; + __u16 nbufs; + __u16 bid; +}; + +struct io_statx { + struct file *file; + int dfd; + unsigned int mask; + unsigned int flags; + const char *filename; + struct statx *buffer; +}; + +struct io_completion { + struct file *file; + struct list_head list; + int cflags; +}; + +struct async_poll; + +struct io_kiocb { + union { + struct file *file; + struct io_rw rw; + struct io_poll_iocb poll; + struct io_accept accept; + struct io_sync sync; + struct io_cancel cancel; + struct io_timeout timeout; + struct io_timeout_rem timeout_rem; + struct io_connect connect; + struct io_sr_msg sr_msg; + struct io_open open; + struct io_close close; + struct io_files_update files_update; + struct io_fadvise fadvise; + struct io_madvise madvise; + struct io_epoll epoll; + struct io_splice splice; + struct io_provide_buf pbuf; + struct io_statx statx; + struct io_completion compl; + }; + void *async_data; + u8 opcode; + u8 iopoll_completed; + u16 buf_index; + u32 result; + struct io_ring_ctx *ctx; + unsigned int flags; + refcount_t refs; + struct task_struct *task; + u64 user_data; + struct list_head link_list; + struct list_head inflight_entry; + struct percpu_ref *fixed_file_refs; + struct callback_head task_work; + struct hlist_node hash_node; + struct async_poll *apoll; + struct io_wq_work work; +}; + +struct io_timeout_data { + struct io_kiocb *req; + struct hrtimer timer; + struct timespec64 ts; + enum hrtimer_mode mode; +}; + +struct io_async_connect { + struct __kernel_sockaddr_storage address; +}; + +struct io_async_msghdr { + struct iovec fast_iov[8]; + struct iovec *iov; + struct sockaddr *uaddr; + struct msghdr msg; + struct __kernel_sockaddr_storage addr; +}; + +struct io_async_rw { + struct iovec fast_iov[8]; + const struct iovec *free_iovec; + struct iov_iter iter; + size_t bytes_done; + struct wait_page_queue wpq; +}; + +enum { + REQ_F_FIXED_FILE_BIT = 0, + REQ_F_IO_DRAIN_BIT = 1, + REQ_F_LINK_BIT = 2, + REQ_F_HARDLINK_BIT = 3, + REQ_F_FORCE_ASYNC_BIT = 4, + REQ_F_BUFFER_SELECT_BIT = 5, + REQ_F_LINK_HEAD_BIT = 6, + REQ_F_FAIL_LINK_BIT = 7, + REQ_F_INFLIGHT_BIT = 8, + REQ_F_CUR_POS_BIT = 9, + REQ_F_NOWAIT_BIT = 10, + REQ_F_LINK_TIMEOUT_BIT = 11, + REQ_F_ISREG_BIT = 12, + REQ_F_NEED_CLEANUP_BIT = 13, + REQ_F_POLLED_BIT = 14, + REQ_F_BUFFER_SELECTED_BIT = 15, + REQ_F_NO_FILE_TABLE_BIT = 16, + REQ_F_WORK_INITIALIZED_BIT = 17, + REQ_F_LTIMEOUT_ACTIVE_BIT = 18, + __REQ_F_LAST_BIT = 19, +}; + +enum { + REQ_F_FIXED_FILE = 1, + REQ_F_IO_DRAIN = 2, + REQ_F_LINK = 4, + REQ_F_HARDLINK = 8, + REQ_F_FORCE_ASYNC = 16, + REQ_F_BUFFER_SELECT = 32, + REQ_F_LINK_HEAD = 64, + REQ_F_FAIL_LINK = 128, + REQ_F_INFLIGHT = 256, + REQ_F_CUR_POS = 512, + REQ_F_NOWAIT = 1024, + REQ_F_LINK_TIMEOUT = 2048, + REQ_F_ISREG = 4096, + REQ_F_NEED_CLEANUP = 8192, + REQ_F_POLLED = 16384, + REQ_F_BUFFER_SELECTED = 32768, + REQ_F_NO_FILE_TABLE = 65536, + REQ_F_WORK_INITIALIZED = 131072, + REQ_F_LTIMEOUT_ACTIVE = 262144, +}; + +struct async_poll { + struct io_poll_iocb poll; + struct io_poll_iocb *double_poll; +}; + +struct io_defer_entry { + struct list_head list; + struct io_kiocb *req; + u32 seq; +}; + +struct io_comp_state { + unsigned int nr; + struct list_head list; + struct io_ring_ctx *ctx; +}; + +struct io_submit_state { + struct blk_plug plug; + void *reqs[8]; + unsigned int free_reqs; + struct io_comp_state comp; + struct file *file; + unsigned int fd; + unsigned int has_refs; + unsigned int ios_left; +}; + +struct io_op_def { + unsigned int needs_file: 1; + unsigned int needs_file_no_error: 1; + unsigned int hash_reg_file: 1; + unsigned int unbound_nonreg_file: 1; + unsigned int not_supported: 1; + unsigned int pollin: 1; + unsigned int pollout: 1; + unsigned int buffer_select: 1; + unsigned int needs_async_data: 1; + short unsigned int async_size; + unsigned int work_flags; +}; + +enum io_mem_account { + ACCT_LOCKED = 0, + ACCT_PINNED = 1, +}; + +struct req_batch { + void *reqs[8]; + int to_free; + struct task_struct *task; + int task_refs; +}; + +struct io_poll_table { + struct poll_table_struct pt; + struct io_kiocb *req; + int error; +}; + +enum sq_ret { + SQT_IDLE = 1, + SQT_SPIN = 2, + SQT_DID_WORK = 4, +}; + +struct io_wait_queue { + struct wait_queue_entry wq; + struct io_ring_ctx *ctx; + unsigned int to_wait; + unsigned int nr_timeouts; +}; + +struct io_file_put { + struct list_head list; + struct file *file; +}; + +struct io_wq_work_list { + struct io_wq_work_node *first; + struct io_wq_work_node *last; +}; + +typedef bool work_cancel_fn(struct io_wq_work *, void *); + +enum { + IO_WORKER_F_UP = 1, + IO_WORKER_F_RUNNING = 2, + IO_WORKER_F_FREE = 4, + IO_WORKER_F_FIXED = 8, + IO_WORKER_F_BOUND = 16, +}; + +enum { + IO_WQ_BIT_EXIT = 0, + IO_WQ_BIT_CANCEL = 1, + IO_WQ_BIT_ERROR = 2, +}; + +enum { + IO_WQE_FLAG_STALLED = 1, +}; + +struct io_wqe; + +struct io_worker { + refcount_t ref; + unsigned int flags; + struct hlist_nulls_node nulls_node; + struct list_head all_list; + struct task_struct *task; + struct io_wqe *wqe; + struct io_wq_work *cur_work; + spinlock_t lock; + struct callback_head rcu; + struct mm_struct *mm; + struct cgroup_subsys_state *blkcg_css; + const struct cred *cur_creds; + const struct cred *saved_creds; + struct files_struct *restore_files; + struct nsproxy *restore_nsproxy; + struct fs_struct *restore_fs; +}; + +struct io_wqe_acct { + unsigned int nr_workers; + unsigned int max_workers; + atomic_t nr_running; +}; + +struct io_wq___2; + +struct io_wqe { + struct { + raw_spinlock_t lock; + struct io_wq_work_list work_list; + long unsigned int hash_map; + unsigned int flags; + long: 32; + long: 64; + }; + int node; + struct io_wqe_acct acct[2]; + struct hlist_nulls_head free_list; + struct list_head all_list; + struct io_wq___2 *wq; + struct io_wq_work *hash_tail[64]; +}; + +enum { + IO_WQ_ACCT_BOUND = 0, + IO_WQ_ACCT_UNBOUND = 1, +}; + +struct io_wq___2 { + struct io_wqe **wqes; + long unsigned int state; + free_work_fn *free_work; + io_wq_work_fn *do_work; + struct task_struct *manager; + struct user_struct *user; + refcount_t refs; + struct completion done; + struct hlist_node cpuhp_node; + refcount_t use_refs; +}; + +struct io_cb_cancel_data { + work_cancel_fn *fn; + void *data; + int nr_running; + int nr_pending; + bool cancel_all; +}; + +struct flock64 { + short int l_type; + short int l_whence; + __kernel_loff_t l_start; + __kernel_loff_t l_len; + __kernel_pid_t l_pid; +}; + +struct trace_event_raw_locks_get_lock_context { + struct trace_entry ent; + long unsigned int i_ino; + dev_t s_dev; + unsigned char type; + struct file_lock_context *ctx; + char __data[0]; +}; + +struct trace_event_raw_filelock_lock { + struct trace_entry ent; + struct file_lock *fl; + long unsigned int i_ino; + dev_t s_dev; + struct file_lock *fl_blocker; + fl_owner_t fl_owner; + unsigned int fl_pid; + unsigned int fl_flags; + unsigned char fl_type; + loff_t fl_start; + loff_t fl_end; + int ret; + char __data[0]; +}; + +struct trace_event_raw_filelock_lease { + struct trace_entry ent; + struct file_lock *fl; + long unsigned int i_ino; + dev_t s_dev; + struct file_lock *fl_blocker; + fl_owner_t fl_owner; + unsigned int fl_flags; + unsigned char fl_type; + long unsigned int fl_break_time; + long unsigned int fl_downgrade_time; + char __data[0]; +}; + +struct trace_event_raw_generic_add_lease { + struct trace_entry ent; + long unsigned int i_ino; + int wcount; + int rcount; + int icount; + dev_t s_dev; + fl_owner_t fl_owner; + unsigned int fl_flags; + unsigned char fl_type; + char __data[0]; +}; + +struct trace_event_raw_leases_conflict { + struct trace_entry ent; + void *lease; + void *breaker; + unsigned int l_fl_flags; + unsigned int b_fl_flags; + unsigned char l_fl_type; + unsigned char b_fl_type; + bool conflict; + char __data[0]; +}; + +struct trace_event_data_offsets_locks_get_lock_context {}; + +struct trace_event_data_offsets_filelock_lock {}; + +struct trace_event_data_offsets_filelock_lease {}; + +struct trace_event_data_offsets_generic_add_lease {}; + +struct trace_event_data_offsets_leases_conflict {}; + +typedef void (*btf_trace_locks_get_lock_context)(void *, struct inode *, int, struct file_lock_context *); + +typedef void (*btf_trace_posix_lock_inode)(void *, struct inode *, struct file_lock *, int); + +typedef void (*btf_trace_fcntl_setlk)(void *, struct inode *, struct file_lock *, int); + +typedef void (*btf_trace_locks_remove_posix)(void *, struct inode *, struct file_lock *, int); + +typedef void (*btf_trace_flock_lock_inode)(void *, struct inode *, struct file_lock *, int); + +typedef void (*btf_trace_break_lease_noblock)(void *, struct inode *, struct file_lock *); + +typedef void (*btf_trace_break_lease_block)(void *, struct inode *, struct file_lock *); + +typedef void (*btf_trace_break_lease_unblock)(void *, struct inode *, struct file_lock *); + +typedef void (*btf_trace_generic_delete_lease)(void *, struct inode *, struct file_lock *); + +typedef void (*btf_trace_time_out_leases)(void *, struct inode *, struct file_lock *); + +typedef void (*btf_trace_generic_add_lease)(void *, struct inode *, struct file_lock *); + +typedef void (*btf_trace_leases_conflict)(void *, bool, struct file_lock *, struct file_lock *); + +struct file_lock_list_struct { + spinlock_t lock; + struct hlist_head hlist; +}; + +struct locks_iterator { + int li_cpu; + loff_t li_pos; +}; + +enum { + VERBOSE_STATUS = 1, +}; + +enum { + Enabled = 0, + Magic = 1, +}; + +typedef struct { + struct list_head list; + long unsigned int flags; + int offset; + int size; + char *magic; + char *mask; + const char *interpreter; + char *name; + struct dentry *dentry; + struct file *interp_file; +} Node; + +typedef unsigned int __kernel_uid_t; + +typedef unsigned int __kernel_gid_t; + +struct elf_prpsinfo { + char pr_state; + char pr_sname; + char pr_zomb; + char pr_nice; + long unsigned int pr_flag; + __kernel_uid_t pr_uid; + __kernel_gid_t pr_gid; + pid_t pr_pid; + pid_t pr_ppid; + pid_t pr_pgrp; + pid_t pr_sid; + char pr_fname[16]; + char pr_psargs[80]; +}; + +struct core_vma_metadata { + long unsigned int start; + long unsigned int end; + long unsigned int flags; + long unsigned int dump_size; +}; + +struct arch_elf_state {}; + +struct memelfnote { + const char *name; + int type; + unsigned int datasz; + void *data; +}; + +struct elf_thread_core_info { + struct elf_thread_core_info *next; + struct task_struct *task; + struct elf_prstatus prstatus; + struct memelfnote notes[0]; +}; + +struct elf_note_info { + struct elf_thread_core_info *thread; + struct memelfnote psinfo; + struct memelfnote signote; + struct memelfnote auxv; + struct memelfnote files; + siginfo_t csigdata; + size_t size; + int thread_notes; +}; + +struct user_regs_struct { + long unsigned int r15; + long unsigned int r14; + long unsigned int r13; + long unsigned int r12; + long unsigned int bp; + long unsigned int bx; + long unsigned int r11; + long unsigned int r10; + long unsigned int r9; + long unsigned int r8; + long unsigned int ax; + long unsigned int cx; + long unsigned int dx; + long unsigned int si; + long unsigned int di; + long unsigned int orig_ax; + long unsigned int ip; + long unsigned int cs; + long unsigned int flags; + long unsigned int sp; + long unsigned int ss; + long unsigned int fs_base; + long unsigned int gs_base; + long unsigned int ds; + long unsigned int es; + long unsigned int fs; + long unsigned int gs; +}; + +struct elf32_shdr { + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +}; + +typedef struct user_regs_struct compat_elf_gregset_t; + +struct compat_elf_siginfo { + compat_int_t si_signo; + compat_int_t si_code; + compat_int_t si_errno; +}; + +struct compat_elf_prstatus { + struct compat_elf_siginfo pr_info; + short int pr_cursig; + compat_ulong_t pr_sigpend; + compat_ulong_t pr_sighold; + compat_pid_t pr_pid; + compat_pid_t pr_ppid; + compat_pid_t pr_pgrp; + compat_pid_t pr_sid; + struct old_timeval32 pr_utime; + struct old_timeval32 pr_stime; + struct old_timeval32 pr_cutime; + struct old_timeval32 pr_cstime; + compat_elf_gregset_t pr_reg; + compat_int_t pr_fpvalid; +}; + +struct compat_elf_prpsinfo { + char pr_state; + char pr_sname; + char pr_zomb; + char pr_nice; + compat_ulong_t pr_flag; + __compat_uid_t pr_uid; + __compat_gid_t pr_gid; + compat_pid_t pr_pid; + compat_pid_t pr_ppid; + compat_pid_t pr_pgrp; + compat_pid_t pr_sid; + char pr_fname[16]; + char pr_psargs[80]; +}; + +struct elf_thread_core_info___2 { + struct elf_thread_core_info___2 *next; + struct task_struct *task; + struct compat_elf_prstatus prstatus; + struct memelfnote notes[0]; +}; + +struct elf_note_info___2 { + struct elf_thread_core_info___2 *thread; + struct memelfnote psinfo; + struct memelfnote signote; + struct memelfnote auxv; + struct memelfnote files; + compat_siginfo_t csigdata; + size_t size; + int thread_notes; +}; + +struct mb_cache_entry { + struct list_head e_list; + struct hlist_bl_node e_hash_list; + atomic_t e_refcnt; + u32 e_key; + u32 e_referenced: 1; + u32 e_reusable: 1; + u64 e_value; +}; + +struct mb_cache { + struct hlist_bl_head *c_hash; + int c_bucket_bits; + long unsigned int c_max_entries; + spinlock_t c_list_lock; + struct list_head c_list; + long unsigned int c_entry_count; + struct shrinker c_shrink; + struct work_struct c_shrink_work; +}; + +struct posix_acl_xattr_entry { + __le16 e_tag; + __le16 e_perm; + __le32 e_id; +}; + +struct posix_acl_xattr_header { + __le32 a_version; +}; + +struct xdr_buf { + struct kvec head[1]; + struct kvec tail[1]; + struct bio_vec *bvec; + struct page **pages; + unsigned int page_base; + unsigned int page_len; + unsigned int flags; + unsigned int buflen; + unsigned int len; +}; + +struct xdr_array2_desc; + +typedef int (*xdr_xcode_elem_t)(struct xdr_array2_desc *, void *); + +struct xdr_array2_desc { + unsigned int elem_size; + unsigned int array_len; + unsigned int array_maxlen; + xdr_xcode_elem_t xcode; +}; + +struct nfsacl_encode_desc { + struct xdr_array2_desc desc; + unsigned int count; + struct posix_acl *acl; + int typeflag; + kuid_t uid; + kgid_t gid; +}; + +struct nfsacl_simple_acl { + struct posix_acl acl; + struct posix_acl_entry ace[4]; +}; + +struct nfsacl_decode_desc { + struct xdr_array2_desc desc; + unsigned int count; + struct posix_acl *acl; +}; + +struct lock_manager { + struct list_head list; + bool block_opens; +}; + +struct rpc_timer { + struct list_head list; + long unsigned int expires; + struct delayed_work dwork; +}; + +struct rpc_wait_queue { + spinlock_t lock; + struct list_head tasks[4]; + unsigned char maxpriority; + unsigned char priority; + unsigned char nr; + short unsigned int qlen; + struct rpc_timer timer_list; + const char *name; +}; + +struct nfs_seqid_counter { + ktime_t create_time; + int owner_id; + int flags; + u32 counter; + spinlock_t lock; + struct list_head list; + struct rpc_wait_queue wait; +}; + +struct nfs4_stateid_struct { + union { + char data[16]; + struct { + __be32 seqid; + char other[12]; + }; + }; + enum { + NFS4_INVALID_STATEID_TYPE = 0, + NFS4_SPECIAL_STATEID_TYPE = 1, + NFS4_OPEN_STATEID_TYPE = 2, + NFS4_LOCK_STATEID_TYPE = 3, + NFS4_DELEGATION_STATEID_TYPE = 4, + NFS4_LAYOUT_STATEID_TYPE = 5, + NFS4_PNFS_DS_STATEID_TYPE = 6, + NFS4_REVOKED_STATEID_TYPE = 7, + } type; +}; + +typedef struct nfs4_stateid_struct nfs4_stateid; + +struct nfs4_state; + +struct nfs4_lock_state { + struct list_head ls_locks; + struct nfs4_state *ls_state; + long unsigned int ls_flags; + struct nfs_seqid_counter ls_seqid; + nfs4_stateid ls_stateid; + refcount_t ls_count; + fl_owner_t ls_owner; +}; + +struct rpc_rqst; + +struct xdr_stream { + __be32 *p; + struct xdr_buf *buf; + __be32 *end; + struct kvec *iov; + struct kvec scratch; + struct page **page_ptr; + unsigned int nwords; + struct rpc_rqst *rqst; +}; + +struct rpc_xprt; + +struct rpc_task; + +struct rpc_cred; + +struct rpc_rqst { + struct rpc_xprt *rq_xprt; + struct xdr_buf rq_snd_buf; + struct xdr_buf rq_rcv_buf; + struct rpc_task *rq_task; + struct rpc_cred *rq_cred; + __be32 rq_xid; + int rq_cong; + u32 rq_seqno; + int rq_enc_pages_num; + struct page **rq_enc_pages; + void (*rq_release_snd_buf)(struct rpc_rqst *); + union { + struct list_head rq_list; + struct rb_node rq_recv; + }; + struct list_head rq_xmit; + struct list_head rq_xmit2; + void *rq_buffer; + size_t rq_callsize; + void *rq_rbuffer; + size_t rq_rcvsize; + size_t rq_xmit_bytes_sent; + size_t rq_reply_bytes_recvd; + struct xdr_buf rq_private_buf; + long unsigned int rq_majortimeo; + long unsigned int rq_minortimeo; + long unsigned int rq_timeout; + ktime_t rq_rtt; + unsigned int rq_retries; + unsigned int rq_connect_cookie; + atomic_t rq_pin; + u32 rq_bytes_sent; + ktime_t rq_xtime; + int rq_ntrans; +}; + +typedef void (*kxdreproc_t)(struct rpc_rqst *, struct xdr_stream *, const void *); + +typedef int (*kxdrdproc_t)(struct rpc_rqst *, struct xdr_stream *, void *); + +struct rpc_procinfo; + +struct rpc_message { + const struct rpc_procinfo *rpc_proc; + void *rpc_argp; + void *rpc_resp; + const struct cred *rpc_cred; +}; + +struct rpc_procinfo { + u32 p_proc; + kxdreproc_t p_encode; + kxdrdproc_t p_decode; + unsigned int p_arglen; + unsigned int p_replen; + unsigned int p_timer; + u32 p_statidx; + const char *p_name; +}; + +struct rpc_wait { + struct list_head list; + struct list_head links; + struct list_head timer_list; +}; + +struct rpc_call_ops; + +struct rpc_clnt; + +struct rpc_task { + atomic_t tk_count; + int tk_status; + struct list_head tk_task; + void (*tk_callback)(struct rpc_task *); + void (*tk_action)(struct rpc_task *); + long unsigned int tk_timeout; + long unsigned int tk_runstate; + struct rpc_wait_queue *tk_waitqueue; + union { + struct work_struct tk_work; + struct rpc_wait tk_wait; + } u; + int tk_rpc_status; + struct rpc_message tk_msg; + void *tk_calldata; + const struct rpc_call_ops *tk_ops; + struct rpc_clnt *tk_client; + struct rpc_xprt *tk_xprt; + struct rpc_cred *tk_op_cred; + struct rpc_rqst *tk_rqstp; + struct workqueue_struct *tk_workqueue; + ktime_t tk_start; + pid_t tk_owner; + short unsigned int tk_flags; + short unsigned int tk_timeouts; + short unsigned int tk_pid; + unsigned char tk_priority: 2; + unsigned char tk_garb_retry: 2; + unsigned char tk_cred_retry: 2; + unsigned char tk_rebind_retry: 2; +}; + +struct rpc_call_ops { + void (*rpc_call_prepare)(struct rpc_task *, void *); + void (*rpc_call_done)(struct rpc_task *, void *); + void (*rpc_count_stats)(struct rpc_task *, void *); + void (*rpc_release)(void *); +}; + +struct rpc_pipe_dir_head { + struct list_head pdh_entries; + struct dentry *pdh_dentry; +}; + +struct rpc_rtt { + long unsigned int timeo; + long unsigned int srtt[5]; + long unsigned int sdrtt[5]; + int ntimeouts[5]; +}; + +struct rpc_timeout { + long unsigned int to_initval; + long unsigned int to_maxval; + long unsigned int to_increment; + unsigned int to_retries; + unsigned char to_exponential; +}; + +struct rpc_xprt_switch; + +struct rpc_xprt_iter_ops; + +struct rpc_xprt_iter { + struct rpc_xprt_switch *xpi_xpswitch; + struct rpc_xprt *xpi_cursor; + const struct rpc_xprt_iter_ops *xpi_ops; +}; + +struct rpc_auth; + +struct rpc_stat; + +struct rpc_iostats; + +struct rpc_program; + +struct rpc_clnt { + atomic_t cl_count; + unsigned int cl_clid; + struct list_head cl_clients; + struct list_head cl_tasks; + spinlock_t cl_lock; + struct rpc_xprt *cl_xprt; + const struct rpc_procinfo *cl_procinfo; + u32 cl_prog; + u32 cl_vers; + u32 cl_maxproc; + struct rpc_auth *cl_auth; + struct rpc_stat *cl_stats; + struct rpc_iostats *cl_metrics; + unsigned int cl_softrtry: 1; + unsigned int cl_softerr: 1; + unsigned int cl_discrtry: 1; + unsigned int cl_noretranstimeo: 1; + unsigned int cl_autobind: 1; + unsigned int cl_chatty: 1; + struct rpc_rtt *cl_rtt; + const struct rpc_timeout *cl_timeout; + atomic_t cl_swapper; + int cl_nodelen; + char cl_nodename[65]; + struct rpc_pipe_dir_head cl_pipedir_objects; + struct rpc_clnt *cl_parent; + struct rpc_rtt cl_rtt_default; + struct rpc_timeout cl_timeout_default; + const struct rpc_program *cl_program; + const char *cl_principal; + union { + struct rpc_xprt_iter cl_xpi; + struct work_struct cl_work; + }; + const struct cred *cl_cred; +}; + +struct rpc_xprt_ops; + +struct svc_xprt; + +struct rpc_xprt { + struct kref kref; + const struct rpc_xprt_ops *ops; + const struct rpc_timeout *timeout; + struct __kernel_sockaddr_storage addr; + size_t addrlen; + int prot; + long unsigned int cong; + long unsigned int cwnd; + size_t max_payload; + struct rpc_wait_queue binding; + struct rpc_wait_queue sending; + struct rpc_wait_queue pending; + struct rpc_wait_queue backlog; + struct list_head free; + unsigned int max_reqs; + unsigned int min_reqs; + unsigned int num_reqs; + long unsigned int state; + unsigned char resvport: 1; + unsigned char reuseport: 1; + atomic_t swapper; + unsigned int bind_index; + struct list_head xprt_switch; + long unsigned int bind_timeout; + long unsigned int reestablish_timeout; + unsigned int connect_cookie; + struct work_struct task_cleanup; + struct timer_list timer; + long unsigned int last_used; + long unsigned int idle_timeout; + long unsigned int connect_timeout; + long unsigned int max_reconnect_timeout; + atomic_long_t queuelen; + spinlock_t transport_lock; + spinlock_t reserve_lock; + spinlock_t queue_lock; + u32 xid; + struct rpc_task *snd_task; + struct list_head xmit_queue; + struct svc_xprt *bc_xprt; + struct rb_root recv_queue; + struct { + long unsigned int bind_count; + long unsigned int connect_count; + long unsigned int connect_start; + long unsigned int connect_time; + long unsigned int sends; + long unsigned int recvs; + long unsigned int bad_xids; + long unsigned int max_slots; + long long unsigned int req_u; + long long unsigned int bklog_u; + long long unsigned int sending_u; + long long unsigned int pending_u; + } stat; + struct net *xprt_net; + const char *servername; + const char *address_strings[6]; + struct callback_head rcu; +}; + +struct rpc_credops; + +struct rpc_cred { + struct hlist_node cr_hash; + struct list_head cr_lru; + struct callback_head cr_rcu; + struct rpc_auth *cr_auth; + const struct rpc_credops *cr_ops; + long unsigned int cr_expire; + long unsigned int cr_flags; + refcount_t cr_count; + const struct cred *cr_cred; +}; + +typedef u32 rpc_authflavor_t; + +struct auth_cred { + const struct cred *cred; + const char *principal; +}; + +struct rpc_authops; + +struct rpc_cred_cache; + +struct rpc_auth { + unsigned int au_cslack; + unsigned int au_rslack; + unsigned int au_verfsize; + unsigned int au_ralign; + long unsigned int au_flags; + const struct rpc_authops *au_ops; + rpc_authflavor_t au_flavor; + refcount_t au_count; + struct rpc_cred_cache *au_credcache; +}; + +struct rpc_credops { + const char *cr_name; + int (*cr_init)(struct rpc_auth *, struct rpc_cred *); + void (*crdestroy)(struct rpc_cred *); + int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); + int (*crmarshal)(struct rpc_task *, struct xdr_stream *); + int (*crrefresh)(struct rpc_task *); + int (*crvalidate)(struct rpc_task *, struct xdr_stream *); + int (*crwrap_req)(struct rpc_task *, struct xdr_stream *); + int (*crunwrap_resp)(struct rpc_task *, struct xdr_stream *); + int (*crkey_timeout)(struct rpc_cred *); + char * (*crstringify_acceptor)(struct rpc_cred *); + bool (*crneed_reencode)(struct rpc_task *); +}; + +struct rpc_auth_create_args; + +struct rpcsec_gss_info; + +struct rpc_authops { + struct module *owner; + rpc_authflavor_t au_flavor; + char *au_name; + struct rpc_auth * (*create)(const struct rpc_auth_create_args *, struct rpc_clnt *); + void (*destroy)(struct rpc_auth *); + int (*hash_cred)(struct auth_cred *, unsigned int); + struct rpc_cred * (*lookup_cred)(struct rpc_auth *, struct auth_cred *, int); + struct rpc_cred * (*crcreate)(struct rpc_auth *, struct auth_cred *, int, gfp_t); + rpc_authflavor_t (*info2flavor)(struct rpcsec_gss_info *); + int (*flavor2info)(rpc_authflavor_t, struct rpcsec_gss_info *); + int (*key_timeout)(struct rpc_auth *, struct rpc_cred *); +}; + +struct rpc_auth_create_args { + rpc_authflavor_t pseudoflavor; + const char *target_name; +}; + +struct rpcsec_gss_oid { + unsigned int len; + u8 data[32]; +}; + +struct rpcsec_gss_info { + struct rpcsec_gss_oid oid; + u32 qop; + u32 service; +}; + +struct rpc_xprt_ops { + void (*set_buffer_size)(struct rpc_xprt *, size_t, size_t); + int (*reserve_xprt)(struct rpc_xprt *, struct rpc_task *); + void (*release_xprt)(struct rpc_xprt *, struct rpc_task *); + void (*alloc_slot)(struct rpc_xprt *, struct rpc_task *); + void (*free_slot)(struct rpc_xprt *, struct rpc_rqst *); + void (*rpcbind)(struct rpc_task *); + void (*set_port)(struct rpc_xprt *, short unsigned int); + void (*connect)(struct rpc_xprt *, struct rpc_task *); + int (*buf_alloc)(struct rpc_task *); + void (*buf_free)(struct rpc_task *); + void (*prepare_request)(struct rpc_rqst *); + int (*send_request)(struct rpc_rqst *); + void (*wait_for_reply_request)(struct rpc_task *); + void (*timer)(struct rpc_xprt *, struct rpc_task *); + void (*release_request)(struct rpc_task *); + void (*close)(struct rpc_xprt *); + void (*destroy)(struct rpc_xprt *); + void (*set_connect_timeout)(struct rpc_xprt *, long unsigned int, long unsigned int); + void (*print_stats)(struct rpc_xprt *, struct seq_file *); + int (*enable_swap)(struct rpc_xprt *); + void (*disable_swap)(struct rpc_xprt *); + void (*inject_disconnect)(struct rpc_xprt *); + int (*bc_setup)(struct rpc_xprt *, unsigned int); + size_t (*bc_maxpayload)(struct rpc_xprt *); + unsigned int (*bc_num_slots)(struct rpc_xprt *); + void (*bc_free_rqst)(struct rpc_rqst *); + void (*bc_destroy)(struct rpc_xprt *, unsigned int); +}; + +struct rpc_xprt_switch { + spinlock_t xps_lock; + struct kref xps_kref; + unsigned int xps_nxprts; + unsigned int xps_nactive; + atomic_long_t xps_queuelen; + struct list_head xps_xprt_list; + struct net *xps_net; + const struct rpc_xprt_iter_ops *xps_iter_ops; + struct callback_head xps_rcu; +}; + +struct rpc_stat { + const struct rpc_program *program; + unsigned int netcnt; + unsigned int netudpcnt; + unsigned int nettcpcnt; + unsigned int nettcpconn; + unsigned int netreconn; + unsigned int rpccnt; + unsigned int rpcretrans; + unsigned int rpcauthrefresh; + unsigned int rpcgarbage; +}; + +struct rpc_version; + +struct rpc_program { + const char *name; + u32 number; + unsigned int nrvers; + const struct rpc_version **version; + struct rpc_stat *stats; + const char *pipe_dir_name; +}; + +struct rpc_xprt_iter_ops { + void (*xpi_rewind)(struct rpc_xprt_iter *); + struct rpc_xprt * (*xpi_xprt)(struct rpc_xprt_iter *); + struct rpc_xprt * (*xpi_next)(struct rpc_xprt_iter *); +}; + +struct rpc_version { + u32 number; + unsigned int nrprocs; + const struct rpc_procinfo *procs; + unsigned int *counts; +}; + +struct nfs_fh { + short unsigned int size; + unsigned char data[128]; +}; + +enum nfs3_stable_how { + NFS_UNSTABLE = 0, + NFS_DATA_SYNC = 1, + NFS_FILE_SYNC = 2, + NFS_INVALID_STABLE_HOW = 4294967295, +}; + +struct nfs4_label { + uint32_t lfs; + uint32_t pi; + u32 len; + char *label; +}; + +typedef struct { + char data[8]; +} nfs4_verifier; + +struct nfs4_string { + unsigned int len; + char *data; +}; + +struct nfs_fsid { + uint64_t major; + uint64_t minor; +}; + +struct nfs4_threshold { + __u32 bm; + __u32 l_type; + __u64 rd_sz; + __u64 wr_sz; + __u64 rd_io_sz; + __u64 wr_io_sz; +}; + +struct nfs_fattr { + unsigned int valid; + umode_t mode; + __u32 nlink; + kuid_t uid; + kgid_t gid; + dev_t rdev; + __u64 size; + union { + struct { + __u32 blocksize; + __u32 blocks; + } nfs2; + struct { + __u64 used; + } nfs3; + } du; + struct nfs_fsid fsid; + __u64 fileid; + __u64 mounted_on_fileid; + struct timespec64 atime; + struct timespec64 mtime; + struct timespec64 ctime; + __u64 change_attr; + __u64 pre_change_attr; + __u64 pre_size; + struct timespec64 pre_mtime; + struct timespec64 pre_ctime; + long unsigned int time_start; + long unsigned int gencount; + struct nfs4_string *owner_name; + struct nfs4_string *group_name; + struct nfs4_threshold *mdsthreshold; + struct nfs4_label *label; +}; + +struct nfs_fsinfo { + struct nfs_fattr *fattr; + __u32 rtmax; + __u32 rtpref; + __u32 rtmult; + __u32 wtmax; + __u32 wtpref; + __u32 wtmult; + __u32 dtpref; + __u64 maxfilesize; + struct timespec64 time_delta; + __u32 lease_time; + __u32 nlayouttypes; + __u32 layouttype[8]; + __u32 blksize; + __u32 clone_blksize; + __u32 xattr_support; +}; + +struct nfs_fsstat { + struct nfs_fattr *fattr; + __u64 tbytes; + __u64 fbytes; + __u64 abytes; + __u64 tfiles; + __u64 ffiles; + __u64 afiles; +}; + +struct nfs_pathconf { + struct nfs_fattr *fattr; + __u32 max_link; + __u32 max_namelen; +}; + +struct nfs4_change_info { + u32 atomic; + u64 before; + u64 after; +}; + +struct nfs4_slot; + +struct nfs4_sequence_args { + struct nfs4_slot *sa_slot; + u8 sa_cache_this: 1; + u8 sa_privileged: 1; +}; + +struct nfs4_sequence_res { + struct nfs4_slot *sr_slot; + long unsigned int sr_timestamp; + int sr_status; + u32 sr_status_flags; + u32 sr_highest_slotid; + u32 sr_target_highest_slotid; +}; + +struct nfs_open_context; + +struct nfs_lock_context { + refcount_t count; + struct list_head list; + struct nfs_open_context *open_context; + fl_owner_t lockowner; + atomic_t io_count; + struct callback_head callback_head; +}; + +struct nfs_open_context { + struct nfs_lock_context lock_context; + fl_owner_t flock_owner; + struct dentry *dentry; + const struct cred *cred; + struct rpc_cred *ll_cred; + struct nfs4_state *state; + fmode_t mode; + long unsigned int flags; + int error; + struct list_head list; + struct nfs4_threshold *mdsthreshold; + struct callback_head callback_head; +}; + +struct nlm_host; + +struct nfs_auth_info { + unsigned int flavor_len; + rpc_authflavor_t flavors[12]; +}; + +struct pnfs_layoutdriver_type; + +struct nfs_client; + +struct nfs_iostats; + +struct nfs_server { + struct nfs_client *nfs_client; + struct list_head client_link; + struct list_head master_link; + struct rpc_clnt *client; + struct rpc_clnt *client_acl; + struct nlm_host *nlm_host; + struct nfs_iostats *io_stats; + atomic_long_t writeback; + int flags; + unsigned int caps; + unsigned int rsize; + unsigned int rpages; + unsigned int wsize; + unsigned int wpages; + unsigned int wtmult; + unsigned int dtsize; + short unsigned int port; + unsigned int bsize; + unsigned int acregmin; + unsigned int acregmax; + unsigned int acdirmin; + unsigned int acdirmax; + unsigned int namelen; + unsigned int options; + unsigned int clone_blksize; + struct nfs_fsid fsid; + __u64 maxfilesize; + struct timespec64 time_delta; + long unsigned int mount_time; + struct super_block *super; + dev_t s_dev; + struct nfs_auth_info auth_info; + u32 pnfs_blksize; + u32 attr_bitmask[3]; + u32 attr_bitmask_nl[3]; + u32 exclcreat_bitmask[3]; + u32 cache_consistency_bitmask[3]; + u32 acl_bitmask; + u32 fh_expire_type; + struct pnfs_layoutdriver_type *pnfs_curr_ld; + struct rpc_wait_queue roc_rpcwaitq; + void *pnfs_ld_data; + struct rb_root state_owners; + struct ida openowner_id; + struct ida lockowner_id; + struct list_head state_owners_lru; + struct list_head layouts; + struct list_head delegations; + struct list_head ss_copies; + long unsigned int mig_gen; + long unsigned int mig_status; + void (*destroy)(struct nfs_server *); + atomic_t active; + struct __kernel_sockaddr_storage mountd_address; + size_t mountd_addrlen; + u32 mountd_version; + short unsigned int mountd_port; + short unsigned int mountd_protocol; + struct rpc_wait_queue uoc_rpcwaitq; + unsigned int read_hdrsize; + const struct cred *cred; +}; + +struct idmap; + +struct nfs41_server_owner; + +struct nfs41_server_scope; + +struct nfs41_impl_id; + +struct nfs_rpc_ops; + +struct nfs_subversion; + +struct nfs4_minor_version_ops; + +struct nfs4_slot_table; + +struct nfs4_session; + +struct nfs_client { + refcount_t cl_count; + atomic_t cl_mds_count; + int cl_cons_state; + long unsigned int cl_res_state; + long unsigned int cl_flags; + struct __kernel_sockaddr_storage cl_addr; + size_t cl_addrlen; + char *cl_hostname; + char *cl_acceptor; + struct list_head cl_share_link; + struct list_head cl_superblocks; + struct rpc_clnt *cl_rpcclient; + const struct nfs_rpc_ops *rpc_ops; + int cl_proto; + struct nfs_subversion *cl_nfs_mod; + u32 cl_minorversion; + unsigned int cl_nconnect; + const char *cl_principal; + struct list_head cl_ds_clients; + u64 cl_clientid; + nfs4_verifier cl_confirm; + long unsigned int cl_state; + spinlock_t cl_lock; + long unsigned int cl_lease_time; + long unsigned int cl_last_renewal; + struct delayed_work cl_renewd; + struct rpc_wait_queue cl_rpcwaitq; + struct idmap *cl_idmap; + const char *cl_owner_id; + u32 cl_cb_ident; + const struct nfs4_minor_version_ops *cl_mvops; + long unsigned int cl_mig_gen; + struct nfs4_slot_table *cl_slot_tbl; + u32 cl_seqid; + u32 cl_exchange_flags; + struct nfs4_session *cl_session; + bool cl_preserve_clid; + struct nfs41_server_owner *cl_serverowner; + struct nfs41_server_scope *cl_serverscope; + struct nfs41_impl_id *cl_implid; + long unsigned int cl_sp4_flags; + char cl_ipaddr[48]; + struct net *cl_net; + struct list_head pending_cb_stateids; +}; + +struct nfs_seqid { + struct nfs_seqid_counter *sequence; + struct list_head list; + struct rpc_task *task; +}; + +struct nfs_write_verifier { + char data[8]; +}; + +struct nfs_writeverf { + struct nfs_write_verifier verifier; + enum nfs3_stable_how committed; +}; + +struct nfs_pgio_args { + struct nfs4_sequence_args seq_args; + struct nfs_fh *fh; + struct nfs_open_context *context; + struct nfs_lock_context *lock_context; + nfs4_stateid stateid; + __u64 offset; + __u32 count; + unsigned int pgbase; + struct page **pages; + union { + unsigned int replen; + struct { + u32 *bitmask; + enum nfs3_stable_how stable; + }; + }; +}; + +struct nfs_pgio_res { + struct nfs4_sequence_res seq_res; + struct nfs_fattr *fattr; + __u64 count; + __u32 op_status; + union { + struct { + unsigned int replen; + int eof; + }; + struct { + struct nfs_writeverf *verf; + const struct nfs_server *server; + }; + }; +}; + +struct nfs_commitargs { + struct nfs4_sequence_args seq_args; + struct nfs_fh *fh; + __u64 offset; + __u32 count; + const u32 *bitmask; +}; + +struct nfs_commitres { + struct nfs4_sequence_res seq_res; + __u32 op_status; + struct nfs_fattr *fattr; + struct nfs_writeverf *verf; + const struct nfs_server *server; +}; + +struct nfs_removeargs { + struct nfs4_sequence_args seq_args; + const struct nfs_fh *fh; + struct qstr name; +}; + +struct nfs_removeres { + struct nfs4_sequence_res seq_res; + struct nfs_server *server; + struct nfs_fattr *dir_attr; + struct nfs4_change_info cinfo; +}; + +struct nfs_renameargs { + struct nfs4_sequence_args seq_args; + const struct nfs_fh *old_dir; + const struct nfs_fh *new_dir; + const struct qstr *old_name; + const struct qstr *new_name; +}; + +struct nfs_renameres { + struct nfs4_sequence_res seq_res; + struct nfs_server *server; + struct nfs4_change_info old_cinfo; + struct nfs_fattr *old_fattr; + struct nfs4_change_info new_cinfo; + struct nfs_fattr *new_fattr; +}; + +struct nfs_entry { + __u64 ino; + __u64 cookie; + __u64 prev_cookie; + const char *name; + unsigned int len; + int eof; + struct nfs_fh *fh; + struct nfs_fattr *fattr; + struct nfs4_label *label; + unsigned char d_type; + struct nfs_server *server; +}; + +struct nfs4_pathname { + unsigned int ncomponents; + struct nfs4_string components[512]; +}; + +struct nfs4_fs_location { + unsigned int nservers; + struct nfs4_string servers[10]; + struct nfs4_pathname rootpath; +}; + +struct nfs4_fs_locations { + struct nfs_fattr fattr; + const struct nfs_server *server; + struct nfs4_pathname fs_path; + int nlocations; + struct nfs4_fs_location locations[10]; +}; + +struct pnfs_ds_commit_info {}; + +struct nfs_page_array { + struct page **pagevec; + unsigned int npages; + struct page *page_array[8]; +}; + +struct nfs_page; + +struct pnfs_layout_segment; + +struct nfs_pgio_completion_ops; + +struct nfs_rw_ops; + +struct nfs_io_completion; + +struct nfs_direct_req; + +struct nfs_pgio_header { + struct inode *inode; + const struct cred *cred; + struct list_head pages; + struct nfs_page *req; + struct nfs_writeverf verf; + fmode_t rw_mode; + struct pnfs_layout_segment *lseg; + loff_t io_start; + const struct rpc_call_ops *mds_ops; + void (*release)(struct nfs_pgio_header *); + const struct nfs_pgio_completion_ops *completion_ops; + const struct nfs_rw_ops *rw_ops; + struct nfs_io_completion *io_completion; + struct nfs_direct_req *dreq; + int pnfs_error; + int error; + unsigned int good_bytes; + long unsigned int flags; + struct rpc_task task; + struct nfs_fattr fattr; + struct nfs_pgio_args args; + struct nfs_pgio_res res; + long unsigned int timestamp; + int (*pgio_done_cb)(struct rpc_task *, struct nfs_pgio_header *); + __u64 mds_offset; + struct nfs_page_array page_array; + struct nfs_client *ds_clp; + u32 ds_commit_idx; + u32 pgio_mirror_idx; +}; + +struct nfs_pgio_completion_ops { + void (*error_cleanup)(struct list_head *, int); + void (*init_hdr)(struct nfs_pgio_header *); + void (*completion)(struct nfs_pgio_header *); + void (*reschedule_io)(struct nfs_pgio_header *); +}; + +struct rpc_task_setup; + +struct nfs_rw_ops { + struct nfs_pgio_header * (*rw_alloc_header)(); + void (*rw_free_header)(struct nfs_pgio_header *); + int (*rw_done)(struct rpc_task *, struct nfs_pgio_header *, struct inode *); + void (*rw_result)(struct rpc_task *, struct nfs_pgio_header *); + void (*rw_initiate)(struct nfs_pgio_header *, struct rpc_message *, const struct nfs_rpc_ops *, struct rpc_task_setup *, int); +}; + +struct nfs_mds_commit_info { + atomic_t rpcs_out; + atomic_long_t ncommit; + struct list_head list; +}; + +struct nfs_commit_data; + +struct nfs_commit_info; + +struct nfs_commit_completion_ops { + void (*completion)(struct nfs_commit_data *); + void (*resched_write)(struct nfs_commit_info *, struct nfs_page *); +}; + +struct nfs_commit_data { + struct rpc_task task; + struct inode *inode; + const struct cred *cred; + struct nfs_fattr fattr; + struct nfs_writeverf verf; + struct list_head pages; + struct list_head list; + struct nfs_direct_req *dreq; + struct nfs_commitargs args; + struct nfs_commitres res; + struct nfs_open_context *context; + struct pnfs_layout_segment *lseg; + struct nfs_client *ds_clp; + int ds_commit_index; + loff_t lwb; + const struct rpc_call_ops *mds_ops; + const struct nfs_commit_completion_ops *completion_ops; + int (*commit_done_cb)(struct rpc_task *, struct nfs_commit_data *); + long unsigned int flags; +}; + +struct nfs_commit_info { + struct inode *inode; + struct nfs_mds_commit_info *mds; + struct pnfs_ds_commit_info *ds; + struct nfs_direct_req *dreq; + const struct nfs_commit_completion_ops *completion_ops; +}; + +struct nfs_unlinkdata { + struct nfs_removeargs args; + struct nfs_removeres res; + struct dentry *dentry; + wait_queue_head_t wq; + const struct cred *cred; + struct nfs_fattr dir_attr; + long int timeout; +}; + +struct nfs_renamedata { + struct nfs_renameargs args; + struct nfs_renameres res; + const struct cred *cred; + struct inode *old_dir; + struct dentry *old_dentry; + struct nfs_fattr old_fattr; + struct inode *new_dir; + struct dentry *new_dentry; + struct nfs_fattr new_fattr; + void (*complete)(struct rpc_task *, struct nfs_renamedata *); + long int timeout; + bool cancelled; +}; + +struct nlmclnt_operations; + +struct nfs_access_entry; + +struct nfs_client_initdata; + +struct nfs_rpc_ops { + u32 version; + const struct dentry_operations *dentry_ops; + const struct inode_operations *dir_inode_ops; + const struct inode_operations *file_inode_ops; + const struct file_operations *file_ops; + const struct nlmclnt_operations *nlmclnt_ops; + int (*getroot)(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); + int (*submount)(struct fs_context *, struct nfs_server *); + int (*try_get_tree)(struct fs_context *); + int (*getattr)(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *, struct nfs4_label *, struct inode *); + int (*setattr)(struct dentry *, struct nfs_fattr *, struct iattr *); + int (*lookup)(struct inode *, struct dentry *, struct nfs_fh *, struct nfs_fattr *, struct nfs4_label *); + int (*lookupp)(struct inode *, struct nfs_fh *, struct nfs_fattr *, struct nfs4_label *); + int (*access)(struct inode *, struct nfs_access_entry *); + int (*readlink)(struct inode *, struct page *, unsigned int, unsigned int); + int (*create)(struct inode *, struct dentry *, struct iattr *, int); + int (*remove)(struct inode *, struct dentry *); + void (*unlink_setup)(struct rpc_message *, struct dentry *, struct inode *); + void (*unlink_rpc_prepare)(struct rpc_task *, struct nfs_unlinkdata *); + int (*unlink_done)(struct rpc_task *, struct inode *); + void (*rename_setup)(struct rpc_message *, struct dentry *, struct dentry *); + void (*rename_rpc_prepare)(struct rpc_task *, struct nfs_renamedata *); + int (*rename_done)(struct rpc_task *, struct inode *, struct inode *); + int (*link)(struct inode *, struct inode *, const struct qstr *); + int (*symlink)(struct inode *, struct dentry *, struct page *, unsigned int, struct iattr *); + int (*mkdir)(struct inode *, struct dentry *, struct iattr *); + int (*rmdir)(struct inode *, const struct qstr *); + int (*readdir)(struct dentry *, const struct cred *, u64, struct page **, unsigned int, bool); + int (*mknod)(struct inode *, struct dentry *, struct iattr *, dev_t); + int (*statfs)(struct nfs_server *, struct nfs_fh *, struct nfs_fsstat *); + int (*fsinfo)(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); + int (*pathconf)(struct nfs_server *, struct nfs_fh *, struct nfs_pathconf *); + int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); + int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, bool); + int (*pgio_rpc_prepare)(struct rpc_task *, struct nfs_pgio_header *); + void (*read_setup)(struct nfs_pgio_header *, struct rpc_message *); + int (*read_done)(struct rpc_task *, struct nfs_pgio_header *); + void (*write_setup)(struct nfs_pgio_header *, struct rpc_message *, struct rpc_clnt **); + int (*write_done)(struct rpc_task *, struct nfs_pgio_header *); + void (*commit_setup)(struct nfs_commit_data *, struct rpc_message *, struct rpc_clnt **); + void (*commit_rpc_prepare)(struct rpc_task *, struct nfs_commit_data *); + int (*commit_done)(struct rpc_task *, struct nfs_commit_data *); + int (*lock)(struct file *, int, struct file_lock *); + int (*lock_check_bounds)(const struct file_lock *); + void (*clear_acl_cache)(struct inode *); + void (*close_context)(struct nfs_open_context *, int); + struct inode * (*open_context)(struct inode *, struct nfs_open_context *, int, struct iattr *, int *); + int (*have_delegation)(struct inode *, fmode_t); + struct nfs_client * (*alloc_client)(const struct nfs_client_initdata *); + struct nfs_client * (*init_client)(struct nfs_client *, const struct nfs_client_initdata *); + void (*free_client)(struct nfs_client *); + struct nfs_server * (*create_server)(struct fs_context *); + struct nfs_server * (*clone_server)(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *, rpc_authflavor_t); +}; + +struct nlmclnt_operations { + void (*nlmclnt_alloc_call)(void *); + bool (*nlmclnt_unlock_prepare)(struct rpc_task *, void *); + void (*nlmclnt_release_call)(void *); +}; + +struct nfs_access_entry { + struct rb_node rb_node; + struct list_head lru; + const struct cred *cred; + __u32 mask; + struct callback_head callback_head; +}; + +struct nfs_client_initdata { + long unsigned int init_flags; + const char *hostname; + const struct sockaddr *addr; + const char *nodename; + const char *ip_addr; + size_t addrlen; + struct nfs_subversion *nfs_mod; + int proto; + u32 minorversion; + unsigned int nconnect; + struct net *net; + const struct rpc_timeout *timeparms; + const struct cred *cred; +}; + +struct nfs4_state_recovery_ops; + +struct nfs4_state_maintenance_ops; + +struct nfs4_mig_recovery_ops; + +struct nfs4_minor_version_ops { + u32 minor_version; + unsigned int init_caps; + int (*init_client)(struct nfs_client *); + void (*shutdown_client)(struct nfs_client *); + bool (*match_stateid)(const nfs4_stateid *, const nfs4_stateid *); + int (*find_root_sec)(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); + void (*free_lock_state)(struct nfs_server *, struct nfs4_lock_state *); + int (*test_and_free_expired)(struct nfs_server *, nfs4_stateid *, const struct cred *); + struct nfs_seqid * (*alloc_seqid)(struct nfs_seqid_counter *, gfp_t); + void (*session_trunk)(struct rpc_clnt *, struct rpc_xprt *, void *); + const struct rpc_call_ops *call_sync_ops; + const struct nfs4_state_recovery_ops *reboot_recovery_ops; + const struct nfs4_state_recovery_ops *nograce_recovery_ops; + const struct nfs4_state_maintenance_ops *state_renewal_ops; + const struct nfs4_mig_recovery_ops *mig_recovery_ops; +}; + +struct nfs4_state_owner; + +struct nfs4_state { + struct list_head open_states; + struct list_head inode_states; + struct list_head lock_states; + struct nfs4_state_owner *owner; + struct inode *inode; + long unsigned int flags; + spinlock_t state_lock; + seqlock_t seqlock; + nfs4_stateid stateid; + nfs4_stateid open_stateid; + unsigned int n_rdonly; + unsigned int n_wronly; + unsigned int n_rdwr; + fmode_t state; + refcount_t count; + wait_queue_head_t waitq; + struct callback_head callback_head; +}; + +struct nfs4_ssc_client_ops; + +struct nfs_ssc_client_ops; + +struct nfs_ssc_client_ops_tbl { + const struct nfs4_ssc_client_ops *ssc_nfs4_ops; + const struct nfs_ssc_client_ops *ssc_nfs_ops; +}; + +struct nfs4_ssc_client_ops { + struct file * (*sco_open)(struct vfsmount *, struct nfs_fh *, nfs4_stateid *); + void (*sco_close)(struct file *); +}; + +struct nfs_ssc_client_ops { + void (*sco_sb_deactive)(struct super_block *); +}; + +struct nfs4_state_recovery_ops { + int owner_flag_bit; + int state_flag_bit; + int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *); + int (*recover_lock)(struct nfs4_state *, struct file_lock *); + int (*establish_clid)(struct nfs_client *, const struct cred *); + int (*reclaim_complete)(struct nfs_client *, const struct cred *); + int (*detect_trunking)(struct nfs_client *, struct nfs_client **, const struct cred *); +}; + +struct nfs4_state_maintenance_ops { + int (*sched_state_renewal)(struct nfs_client *, const struct cred *, unsigned int); + const struct cred * (*get_state_renewal_cred)(struct nfs_client *); + int (*renew_lease)(struct nfs_client *, const struct cred *); +}; + +struct nfs4_mig_recovery_ops { + int (*get_locations)(struct inode *, struct nfs4_fs_locations *, struct page *, const struct cred *); + int (*fsid_present)(struct inode *, const struct cred *); +}; + +struct nfs4_state_owner { + struct nfs_server *so_server; + struct list_head so_lru; + long unsigned int so_expires; + struct rb_node so_server_node; + const struct cred *so_cred; + spinlock_t so_lock; + atomic_t so_count; + long unsigned int so_flags; + struct list_head so_states; + struct nfs_seqid_counter so_seqid; + seqcount_spinlock_t so_reclaim_seqcount; + struct mutex so_delegreturn_mutex; +}; + +struct core_name { + char *corename; + int used; + int size; +}; + +struct trace_event_raw_iomap_readpage_class { + struct trace_entry ent; + dev_t dev; + u64 ino; + int nr_pages; + char __data[0]; +}; + +struct trace_event_raw_iomap_range_class { + struct trace_entry ent; + dev_t dev; + u64 ino; + loff_t size; + long unsigned int offset; + unsigned int length; + char __data[0]; +}; + +struct trace_event_raw_iomap_class { + struct trace_entry ent; + dev_t dev; + u64 ino; + u64 addr; + loff_t offset; + u64 length; + u16 type; + u16 flags; + dev_t bdev; + char __data[0]; +}; + +struct trace_event_raw_iomap_apply { + struct trace_entry ent; + dev_t dev; + u64 ino; + loff_t pos; + loff_t length; + unsigned int flags; + const void *ops; + void *actor; + long unsigned int caller; + char __data[0]; +}; + +struct trace_event_data_offsets_iomap_readpage_class {}; + +struct trace_event_data_offsets_iomap_range_class {}; + +struct trace_event_data_offsets_iomap_class {}; + +struct trace_event_data_offsets_iomap_apply {}; + +typedef void (*btf_trace_iomap_readpage)(void *, struct inode *, int); + +typedef void (*btf_trace_iomap_readahead)(void *, struct inode *, int); + +typedef void (*btf_trace_iomap_writepage)(void *, struct inode *, long unsigned int, unsigned int); + +typedef void (*btf_trace_iomap_releasepage)(void *, struct inode *, long unsigned int, unsigned int); + +typedef void (*btf_trace_iomap_invalidatepage)(void *, struct inode *, long unsigned int, unsigned int); + +typedef void (*btf_trace_iomap_dio_invalidate_fail)(void *, struct inode *, long unsigned int, unsigned int); + +typedef void (*btf_trace_iomap_apply_dstmap)(void *, struct inode *, struct iomap___2 *); + +typedef void (*btf_trace_iomap_apply_srcmap)(void *, struct inode *, struct iomap___2 *); + +typedef void (*btf_trace_iomap_apply)(void *, struct inode *, loff_t, loff_t, unsigned int, const void *, void *, long unsigned int); + +struct iomap_ops { + int (*iomap_begin)(struct inode *, loff_t, loff_t, unsigned int, struct iomap___2 *, struct iomap___2 *); + int (*iomap_end)(struct inode *, loff_t, loff_t, ssize_t, unsigned int, struct iomap___2 *); +}; + +typedef loff_t (*iomap_actor_t)(struct inode *, loff_t, loff_t, void *, struct iomap___2 *, struct iomap___2 *); + +struct iomap_ioend { + struct list_head io_list; + u16 io_type; + u16 io_flags; + struct inode *io_inode; + size_t io_size; + loff_t io_offset; + void *io_private; + struct bio *io_bio; + struct bio io_inline_bio; +}; + +struct iomap_writepage_ctx; + +struct iomap_writeback_ops { + int (*map_blocks)(struct iomap_writepage_ctx *, struct inode *, loff_t); + int (*prepare_ioend)(struct iomap_ioend *, int); + void (*discard_page)(struct page *, loff_t); +}; + +struct iomap_writepage_ctx { + struct iomap___2 iomap; + struct iomap_ioend *ioend; + const struct iomap_writeback_ops *ops; +}; + +struct iomap_page { + atomic_t read_bytes_pending; + atomic_t write_bytes_pending; + spinlock_t uptodate_lock; + long unsigned int uptodate[0]; +}; + +struct iomap_readpage_ctx { + struct page *cur_page; + bool cur_page_in_bio; + struct bio *bio; + struct readahead_control *rac; +}; + +enum { + IOMAP_WRITE_F_UNSHARE = 1, +}; + +struct iomap_dio_ops { + int (*end_io)(struct kiocb *, ssize_t, int, unsigned int); + blk_qc_t (*submit_io)(struct inode *, struct iomap___2 *, struct bio *, loff_t); +}; + +struct iomap_dio { + struct kiocb *iocb; + const struct iomap_dio_ops *dops; + loff_t i_size; + loff_t size; + atomic_t ref; + unsigned int flags; + int error; + bool wait_for_completion; + union { + struct { + struct iov_iter *iter; + struct task_struct *waiter; + struct request_queue *last_queue; + blk_qc_t cookie; + } submit; + struct { + struct work_struct work; + } aio; + }; +}; + +struct fiemap_ctx { + struct fiemap_extent_info *fi; + struct iomap___2 prev; +}; + +struct iomap_swapfile_info { + struct iomap___2 iomap; + struct swap_info_struct *sis; + uint64_t lowest_ppage; + uint64_t highest_ppage; + long unsigned int nr_pages; + int nr_extents; +}; + +enum { + QIF_BLIMITS_B = 0, + QIF_SPACE_B = 1, + QIF_ILIMITS_B = 2, + QIF_INODES_B = 3, + QIF_BTIME_B = 4, + QIF_ITIME_B = 5, +}; + +typedef __kernel_uid32_t qid_t; + +enum { + DQF_INFO_DIRTY_B = 17, +}; + +struct dqstats { + long unsigned int stat[8]; + struct percpu_counter counter[8]; +}; + +enum { + _DQUOT_USAGE_ENABLED = 0, + _DQUOT_LIMITS_ENABLED = 1, + _DQUOT_SUSPENDED = 2, + _DQUOT_STATE_FLAGS = 3, +}; + +struct quota_module_name { + int qm_fmt_id; + char *qm_mod_name; +}; + +struct dquot_warn { + struct super_block *w_sb; + struct kqid w_dq_id; + short int w_type; +}; + +struct qtree_fmt_operations { + void (*mem2disk_dqblk)(void *, struct dquot *); + void (*disk2mem_dqblk)(struct dquot *, void *); + int (*is_id)(void *, struct dquot *); +}; + +struct qtree_mem_dqinfo { + struct super_block *dqi_sb; + int dqi_type; + unsigned int dqi_blocks; + unsigned int dqi_free_blk; + unsigned int dqi_free_entry; + unsigned int dqi_blocksize_bits; + unsigned int dqi_entry_size; + unsigned int dqi_usable_bs; + unsigned int dqi_qtree_depth; + const struct qtree_fmt_operations *dqi_ops; +}; + +struct v2_disk_dqheader { + __le32 dqh_magic; + __le32 dqh_version; +}; + +struct v2r0_disk_dqblk { + __le32 dqb_id; + __le32 dqb_ihardlimit; + __le32 dqb_isoftlimit; + __le32 dqb_curinodes; + __le32 dqb_bhardlimit; + __le32 dqb_bsoftlimit; + __le64 dqb_curspace; + __le64 dqb_btime; + __le64 dqb_itime; +}; + +struct v2r1_disk_dqblk { + __le32 dqb_id; + __le32 dqb_pad; + __le64 dqb_ihardlimit; + __le64 dqb_isoftlimit; + __le64 dqb_curinodes; + __le64 dqb_bhardlimit; + __le64 dqb_bsoftlimit; + __le64 dqb_curspace; + __le64 dqb_btime; + __le64 dqb_itime; +}; + +struct v2_disk_dqinfo { + __le32 dqi_bgrace; + __le32 dqi_igrace; + __le32 dqi_flags; + __le32 dqi_blocks; + __le32 dqi_free_blk; + __le32 dqi_free_entry; +}; + +struct qt_disk_dqdbheader { + __le32 dqdh_next_free; + __le32 dqdh_prev_free; + __le16 dqdh_entries; + __le16 dqdh_pad1; + __le32 dqdh_pad2; +}; + +struct fs_disk_quota { + __s8 d_version; + __s8 d_flags; + __u16 d_fieldmask; + __u32 d_id; + __u64 d_blk_hardlimit; + __u64 d_blk_softlimit; + __u64 d_ino_hardlimit; + __u64 d_ino_softlimit; + __u64 d_bcount; + __u64 d_icount; + __s32 d_itimer; + __s32 d_btimer; + __u16 d_iwarns; + __u16 d_bwarns; + __s8 d_itimer_hi; + __s8 d_btimer_hi; + __s8 d_rtbtimer_hi; + __s8 d_padding2; + __u64 d_rtb_hardlimit; + __u64 d_rtb_softlimit; + __u64 d_rtbcount; + __s32 d_rtbtimer; + __u16 d_rtbwarns; + __s16 d_padding3; + char d_padding4[8]; +}; + +struct fs_qfilestat { + __u64 qfs_ino; + __u64 qfs_nblks; + __u32 qfs_nextents; +}; + +typedef struct fs_qfilestat fs_qfilestat_t; + +struct fs_quota_stat { + __s8 qs_version; + __u16 qs_flags; + __s8 qs_pad; + fs_qfilestat_t qs_uquota; + fs_qfilestat_t qs_gquota; + __u32 qs_incoredqs; + __s32 qs_btimelimit; + __s32 qs_itimelimit; + __s32 qs_rtbtimelimit; + __u16 qs_bwarnlimit; + __u16 qs_iwarnlimit; +}; + +struct fs_qfilestatv { + __u64 qfs_ino; + __u64 qfs_nblks; + __u32 qfs_nextents; + __u32 qfs_pad; +}; + +struct fs_quota_statv { + __s8 qs_version; + __u8 qs_pad1; + __u16 qs_flags; + __u32 qs_incoredqs; + struct fs_qfilestatv qs_uquota; + struct fs_qfilestatv qs_gquota; + struct fs_qfilestatv qs_pquota; + __s32 qs_btimelimit; + __s32 qs_itimelimit; + __s32 qs_rtbtimelimit; + __u16 qs_bwarnlimit; + __u16 qs_iwarnlimit; + __u64 qs_pad2[8]; +}; + +struct if_dqblk { + __u64 dqb_bhardlimit; + __u64 dqb_bsoftlimit; + __u64 dqb_curspace; + __u64 dqb_ihardlimit; + __u64 dqb_isoftlimit; + __u64 dqb_curinodes; + __u64 dqb_btime; + __u64 dqb_itime; + __u32 dqb_valid; +}; + +struct if_nextdqblk { + __u64 dqb_bhardlimit; + __u64 dqb_bsoftlimit; + __u64 dqb_curspace; + __u64 dqb_ihardlimit; + __u64 dqb_isoftlimit; + __u64 dqb_curinodes; + __u64 dqb_btime; + __u64 dqb_itime; + __u32 dqb_valid; + __u32 dqb_id; +}; + +struct if_dqinfo { + __u64 dqi_bgrace; + __u64 dqi_igrace; + __u32 dqi_flags; + __u32 dqi_valid; +}; + +struct compat_if_dqblk { + compat_u64 dqb_bhardlimit; + compat_u64 dqb_bsoftlimit; + compat_u64 dqb_curspace; + compat_u64 dqb_ihardlimit; + compat_u64 dqb_isoftlimit; + compat_u64 dqb_curinodes; + compat_u64 dqb_btime; + compat_u64 dqb_itime; + compat_uint_t dqb_valid; +} __attribute__((packed)); + +struct compat_fs_qfilestat { + compat_u64 dqb_bhardlimit; + compat_u64 qfs_nblks; + compat_uint_t qfs_nextents; +} __attribute__((packed)); + +struct compat_fs_quota_stat { + __s8 qs_version; + char: 8; + __u16 qs_flags; + __s8 qs_pad; + int: 24; + struct compat_fs_qfilestat qs_uquota; + struct compat_fs_qfilestat qs_gquota; + compat_uint_t qs_incoredqs; + compat_int_t qs_btimelimit; + compat_int_t qs_itimelimit; + compat_int_t qs_rtbtimelimit; + __u16 qs_bwarnlimit; + __u16 qs_iwarnlimit; +} __attribute__((packed)); + +struct proc_maps_private { + struct inode *inode; + struct task_struct *task; + struct mm_struct *mm; + struct vm_area_struct *tail_vma; + struct mempolicy *task_mempolicy; +}; + +struct mem_size_stats { + long unsigned int resident; + long unsigned int shared_clean; + long unsigned int shared_dirty; + long unsigned int private_clean; + long unsigned int private_dirty; + long unsigned int referenced; + long unsigned int anonymous; + long unsigned int lazyfree; + long unsigned int anonymous_thp; + long unsigned int shmem_thp; + long unsigned int file_thp; + long unsigned int swap; + long unsigned int shared_hugetlb; + long unsigned int private_hugetlb; + u64 pss; + u64 pss_anon; + u64 pss_file; + u64 pss_shmem; + u64 pss_locked; + u64 swap_pss; + bool check_shmem_swap; +}; + +enum clear_refs_types { + CLEAR_REFS_ALL = 1, + CLEAR_REFS_ANON = 2, + CLEAR_REFS_MAPPED = 3, + CLEAR_REFS_SOFT_DIRTY = 4, + CLEAR_REFS_MM_HIWATER_RSS = 5, + CLEAR_REFS_LAST = 6, +}; + +struct clear_refs_private { + enum clear_refs_types type; +}; + +typedef struct { + u64 pme; +} pagemap_entry_t; + +struct pagemapread { + int pos; + int len; + pagemap_entry_t *buffer; + bool show_pfn; +}; + +struct numa_maps { + long unsigned int pages; + long unsigned int anon; + long unsigned int active; + long unsigned int writeback; + long unsigned int mapcount_max; + long unsigned int dirty; + long unsigned int swapcache; + long unsigned int node[64]; +}; + +struct numa_maps_private { + struct proc_maps_private proc_maps; + struct numa_maps md; +}; + +struct pde_opener { + struct list_head lh; + struct file *file; + bool closing; + struct completion *c; +}; + +enum { + BIAS = 2147483648, +}; + +struct proc_fs_context { + struct pid_namespace *pid_ns; + unsigned int mask; + enum proc_hidepid hidepid; + int gid; + enum proc_pidonly pidonly; +}; + +enum proc_param { + Opt_gid___2 = 0, + Opt_hidepid = 1, + Opt_subset = 2, +}; + +struct genradix_root; + +struct __genradix { + struct genradix_root *root; +}; + +struct syscall_info { + __u64 sp; + struct seccomp_data data; +}; + +typedef struct dentry *instantiate_t(struct dentry *, struct task_struct *, const void *); + +struct pid_entry { + const char *name; + unsigned int len; + umode_t mode; + const struct inode_operations *iop; + const struct file_operations *fop; + union proc_op op; +}; + +struct limit_names { + const char *name; + const char *unit; +}; + +struct map_files_info { + long unsigned int start; + long unsigned int end; + fmode_t mode; +}; + +struct tgid_iter { + unsigned int tgid; + struct task_struct *task; +}; + +struct fd_data { + fmode_t mode; + unsigned int fd; +}; + +struct sysctl_alias { + const char *kernel_param; + const char *sysctl_param; +}; + +struct seq_net_private { + struct net *net; +}; + +struct bpf_iter_aux_info___2; + +struct kernfs_iattrs { + kuid_t ia_uid; + kgid_t ia_gid; + struct timespec64 ia_atime; + struct timespec64 ia_mtime; + struct timespec64 ia_ctime; + struct simple_xattrs xattrs; + atomic_t nr_user_xattrs; + atomic_t user_xattr_size; +}; + +struct kernfs_super_info { + struct super_block *sb; + struct kernfs_root *root; + const void *ns; + struct list_head node; +}; + +enum kernfs_node_flag { + KERNFS_ACTIVATED = 16, + KERNFS_NS = 32, + KERNFS_HAS_SEQ_SHOW = 64, + KERNFS_HAS_MMAP = 128, + KERNFS_LOCKDEP = 256, + KERNFS_SUICIDAL = 1024, + KERNFS_SUICIDED = 2048, + KERNFS_EMPTY_DIR = 4096, + KERNFS_HAS_RELEASE = 8192, +}; + +struct kernfs_open_node { + atomic_t refcnt; + atomic_t event; + wait_queue_head_t poll; + struct list_head files; +}; + +struct pts_mount_opts { + int setuid; + int setgid; + kuid_t uid; + kgid_t gid; + umode_t mode; + umode_t ptmxmode; + int reserve; + int max; +}; + +enum { + Opt_uid___2 = 0, + Opt_gid___3 = 1, + Opt_mode___2 = 2, + Opt_ptmxmode = 3, + Opt_newinstance = 4, + Opt_max = 5, + Opt_err = 6, +}; + +struct pts_fs_info { + struct ida allocated_ptys; + struct pts_mount_opts mount_opts; + struct super_block *sb; + struct dentry *ptmx_dentry; +}; + +struct dcookie_struct { + struct path path; + struct list_head hash_list; +}; + +struct dcookie_user { + struct list_head next; +}; + +typedef unsigned int tid_t; + +struct transaction_chp_stats_s { + long unsigned int cs_chp_time; + __u32 cs_forced_to_close; + __u32 cs_written; + __u32 cs_dropped; +}; + +struct journal_s; + +typedef struct journal_s journal_t; + +struct journal_head; + +struct transaction_s; + +typedef struct transaction_s transaction_t; + +struct transaction_s { + journal_t *t_journal; + tid_t t_tid; + enum { + T_RUNNING = 0, + T_LOCKED = 1, + T_SWITCH = 2, + T_FLUSH = 3, + T_COMMIT = 4, + T_COMMIT_DFLUSH = 5, + T_COMMIT_JFLUSH = 6, + T_COMMIT_CALLBACK = 7, + T_FINISHED = 8, + } t_state; + long unsigned int t_log_start; + int t_nr_buffers; + struct journal_head *t_reserved_list; + struct journal_head *t_buffers; + struct journal_head *t_forget; + struct journal_head *t_checkpoint_list; + struct journal_head *t_checkpoint_io_list; + struct journal_head *t_shadow_list; + struct list_head t_inode_list; + spinlock_t t_handle_lock; + long unsigned int t_max_wait; + long unsigned int t_start; + long unsigned int t_requested; + struct transaction_chp_stats_s t_chp_stats; + atomic_t t_updates; + atomic_t t_outstanding_credits; + atomic_t t_outstanding_revokes; + atomic_t t_handle_count; + transaction_t *t_cpnext; + transaction_t *t_cpprev; + long unsigned int t_expires; + ktime_t t_start_time; + unsigned int t_synchronous_commit: 1; + int t_need_data_flush; + struct list_head t_private_list; +}; + +struct jbd2_buffer_trigger_type; + +struct journal_head { + struct buffer_head *b_bh; + spinlock_t b_state_lock; + int b_jcount; + unsigned int b_jlist; + unsigned int b_modified; + char *b_frozen_data; + char *b_committed_data; + transaction_t *b_transaction; + transaction_t *b_next_transaction; + struct journal_head *b_tnext; + struct journal_head *b_tprev; + transaction_t *b_cp_transaction; + struct journal_head *b_cpnext; + struct journal_head *b_cpprev; + struct jbd2_buffer_trigger_type *b_triggers; + struct jbd2_buffer_trigger_type *b_frozen_triggers; +}; + +struct jbd2_buffer_trigger_type { + void (*t_frozen)(struct jbd2_buffer_trigger_type *, struct buffer_head *, void *, size_t); + void (*t_abort)(struct jbd2_buffer_trigger_type *, struct buffer_head *); +}; + +struct crypto_alg; + +struct crypto_tfm { + u32 crt_flags; + int node; + void (*exit)(struct crypto_tfm *); + struct crypto_alg *__crt_alg; + void *__crt_ctx[0]; +}; + +struct cipher_alg { + unsigned int cia_min_keysize; + unsigned int cia_max_keysize; + int (*cia_setkey)(struct crypto_tfm *, const u8 *, unsigned int); + void (*cia_encrypt)(struct crypto_tfm *, u8 *, const u8 *); + void (*cia_decrypt)(struct crypto_tfm *, u8 *, const u8 *); +}; + +struct compress_alg { + int (*coa_compress)(struct crypto_tfm *, const u8 *, unsigned int, u8 *, unsigned int *); + int (*coa_decompress)(struct crypto_tfm *, const u8 *, unsigned int, u8 *, unsigned int *); +}; + +struct crypto_type; + +struct crypto_alg { + struct list_head cra_list; + struct list_head cra_users; + u32 cra_flags; + unsigned int cra_blocksize; + unsigned int cra_ctxsize; + unsigned int cra_alignmask; + int cra_priority; + refcount_t cra_refcnt; + char cra_name[128]; + char cra_driver_name[128]; + const struct crypto_type *cra_type; + union { + struct cipher_alg cipher; + struct compress_alg compress; + } cra_u; + int (*cra_init)(struct crypto_tfm *); + void (*cra_exit)(struct crypto_tfm *); + void (*cra_destroy)(struct crypto_alg *); + struct module *cra_module; +}; + +struct crypto_instance; + +struct crypto_type { + unsigned int (*ctxsize)(struct crypto_alg *, u32, u32); + unsigned int (*extsize)(struct crypto_alg *); + int (*init)(struct crypto_tfm *, u32, u32); + int (*init_tfm)(struct crypto_tfm *); + void (*show)(struct seq_file *, struct crypto_alg *); + int (*report)(struct sk_buff *, struct crypto_alg *); + void (*free)(struct crypto_instance *); + unsigned int type; + unsigned int maskclear; + unsigned int maskset; + unsigned int tfmsize; +}; + +struct crypto_shash { + unsigned int descsize; + struct crypto_tfm base; +}; + +struct jbd2_journal_handle; + +typedef struct jbd2_journal_handle handle_t; + +struct jbd2_journal_handle { + union { + transaction_t *h_transaction; + journal_t *h_journal; + }; + handle_t *h_rsv_handle; + int h_total_credits; + int h_revoke_credits; + int h_revoke_credits_requested; + int h_ref; + int h_err; + unsigned int h_sync: 1; + unsigned int h_jdata: 1; + unsigned int h_reserved: 1; + unsigned int h_aborted: 1; + unsigned int h_type: 8; + unsigned int h_line_no: 16; + long unsigned int h_start_jiffies; + unsigned int h_requested_credits; + unsigned int saved_alloc_context; +}; + +struct transaction_run_stats_s { + long unsigned int rs_wait; + long unsigned int rs_request_delay; + long unsigned int rs_running; + long unsigned int rs_locked; + long unsigned int rs_flushing; + long unsigned int rs_logging; + __u32 rs_handle_count; + __u32 rs_blocks; + __u32 rs_blocks_logged; +}; + +struct transaction_stats_s { + long unsigned int ts_tid; + long unsigned int ts_requested; + struct transaction_run_stats_s run; +}; + +enum passtype { + PASS_SCAN = 0, + PASS_REVOKE = 1, + PASS_REPLAY = 2, +}; + +struct journal_superblock_s; + +typedef struct journal_superblock_s journal_superblock_t; + +struct jbd2_revoke_table_s; + +struct jbd2_inode; + +struct journal_s { + long unsigned int j_flags; + int j_errno; + struct mutex j_abort_mutex; + struct buffer_head *j_sb_buffer; + journal_superblock_t *j_superblock; + int j_format_version; + rwlock_t j_state_lock; + int j_barrier_count; + struct mutex j_barrier; + transaction_t *j_running_transaction; + transaction_t *j_committing_transaction; + transaction_t *j_checkpoint_transactions; + wait_queue_head_t j_wait_transaction_locked; + wait_queue_head_t j_wait_done_commit; + wait_queue_head_t j_wait_commit; + wait_queue_head_t j_wait_updates; + wait_queue_head_t j_wait_reserved; + wait_queue_head_t j_fc_wait; + struct mutex j_checkpoint_mutex; + struct buffer_head *j_chkpt_bhs[64]; + long unsigned int j_head; + long unsigned int j_tail; + long unsigned int j_free; + long unsigned int j_first; + long unsigned int j_last; + long unsigned int j_fc_first; + long unsigned int j_fc_off; + long unsigned int j_fc_last; + struct block_device *j_dev; + int j_blocksize; + long long unsigned int j_blk_offset; + char j_devname[56]; + struct block_device *j_fs_dev; + unsigned int j_total_len; + atomic_t j_reserved_credits; + spinlock_t j_list_lock; + struct inode *j_inode; + tid_t j_tail_sequence; + tid_t j_transaction_sequence; + tid_t j_commit_sequence; + tid_t j_commit_request; + __u8 j_uuid[16]; + struct task_struct *j_task; + int j_max_transaction_buffers; + int j_revoke_records_per_block; + long unsigned int j_commit_interval; + struct timer_list j_commit_timer; + spinlock_t j_revoke_lock; + struct jbd2_revoke_table_s *j_revoke; + struct jbd2_revoke_table_s *j_revoke_table[2]; + struct buffer_head **j_wbuf; + struct buffer_head **j_fc_wbuf; + int j_wbufsize; + int j_fc_wbufsize; + pid_t j_last_sync_writer; + u64 j_average_commit_time; + u32 j_min_batch_time; + u32 j_max_batch_time; + void (*j_commit_callback)(journal_t *, transaction_t *); + int (*j_submit_inode_data_buffers)(struct jbd2_inode *); + int (*j_finish_inode_data_buffers)(struct jbd2_inode *); + spinlock_t j_history_lock; + struct proc_dir_entry *j_proc_entry; + struct transaction_stats_s j_stats; + unsigned int j_failed_commit; + void *j_private; + struct crypto_shash *j_chksum_driver; + __u32 j_csum_seed; + void (*j_fc_cleanup_callback)(struct journal_s *, int); + int (*j_fc_replay_callback)(struct journal_s *, struct buffer_head *, enum passtype, int, tid_t); +}; + +struct journal_header_s { + __be32 h_magic; + __be32 h_blocktype; + __be32 h_sequence; +}; + +typedef struct journal_header_s journal_header_t; + +struct journal_superblock_s { + journal_header_t s_header; + __be32 s_blocksize; + __be32 s_maxlen; + __be32 s_first; + __be32 s_sequence; + __be32 s_start; + __be32 s_errno; + __be32 s_feature_compat; + __be32 s_feature_incompat; + __be32 s_feature_ro_compat; + __u8 s_uuid[16]; + __be32 s_nr_users; + __be32 s_dynsuper; + __be32 s_max_transaction; + __be32 s_max_trans_data; + __u8 s_checksum_type; + __u8 s_padding2[3]; + __be32 s_num_fc_blks; + __u32 s_padding[41]; + __be32 s_checksum; + __u8 s_users[768]; +}; + +enum jbd_state_bits { + BH_JBD = 16, + BH_JWrite = 17, + BH_Freed = 18, + BH_Revoked = 19, + BH_RevokeValid = 20, + BH_JBDDirty = 21, + BH_JournalHead = 22, + BH_Shadow = 23, + BH_Verified = 24, + BH_JBDPrivateStart = 25, +}; + +struct jbd2_inode { + transaction_t *i_transaction; + transaction_t *i_next_transaction; + struct list_head i_list; + struct inode *i_vfs_inode; + long unsigned int i_flags; + loff_t i_dirty_start; + loff_t i_dirty_end; +}; + +struct bgl_lock { + spinlock_t lock; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct blockgroup_lock { + struct bgl_lock locks[128]; +}; + +struct fscrypt_dummy_policy {}; + +typedef int ext4_grpblk_t; + +typedef long long unsigned int ext4_fsblk_t; + +typedef __u32 ext4_lblk_t; + +typedef unsigned int ext4_group_t; + +struct ext4_allocation_request { + struct inode *inode; + unsigned int len; + ext4_lblk_t logical; + ext4_lblk_t lleft; + ext4_lblk_t lright; + ext4_fsblk_t goal; + ext4_fsblk_t pleft; + ext4_fsblk_t pright; + unsigned int flags; +}; + +struct ext4_system_blocks { + struct rb_root root; + struct callback_head rcu; +}; + +struct ext4_group_desc { + __le32 bg_block_bitmap_lo; + __le32 bg_inode_bitmap_lo; + __le32 bg_inode_table_lo; + __le16 bg_free_blocks_count_lo; + __le16 bg_free_inodes_count_lo; + __le16 bg_used_dirs_count_lo; + __le16 bg_flags; + __le32 bg_exclude_bitmap_lo; + __le16 bg_block_bitmap_csum_lo; + __le16 bg_inode_bitmap_csum_lo; + __le16 bg_itable_unused_lo; + __le16 bg_checksum; + __le32 bg_block_bitmap_hi; + __le32 bg_inode_bitmap_hi; + __le32 bg_inode_table_hi; + __le16 bg_free_blocks_count_hi; + __le16 bg_free_inodes_count_hi; + __le16 bg_used_dirs_count_hi; + __le16 bg_itable_unused_hi; + __le32 bg_exclude_bitmap_hi; + __le16 bg_block_bitmap_csum_hi; + __le16 bg_inode_bitmap_csum_hi; + __u32 bg_reserved; +}; + +struct flex_groups { + atomic64_t free_clusters; + atomic_t free_inodes; + atomic_t used_dirs; +}; + +struct extent_status { + struct rb_node rb_node; + ext4_lblk_t es_lblk; + ext4_lblk_t es_len; + ext4_fsblk_t es_pblk; +}; + +struct ext4_es_tree { + struct rb_root root; + struct extent_status *cache_es; +}; + +struct ext4_es_stats { + long unsigned int es_stats_shrunk; + struct percpu_counter es_stats_cache_hits; + struct percpu_counter es_stats_cache_misses; + u64 es_stats_scan_time; + u64 es_stats_max_scan_time; + struct percpu_counter es_stats_all_cnt; + struct percpu_counter es_stats_shk_cnt; +}; + +struct ext4_pending_tree { + struct rb_root root; +}; + +struct ext4_fc_stats { + unsigned int fc_ineligible_reason_count[10]; + long unsigned int fc_num_commits; + long unsigned int fc_ineligible_commits; + long unsigned int fc_numblks; +}; + +struct ext4_fc_alloc_region { + ext4_lblk_t lblk; + ext4_fsblk_t pblk; + int ino; + int len; +}; + +struct ext4_fc_replay_state { + int fc_replay_num_tags; + int fc_replay_expected_off; + int fc_current_pass; + int fc_cur_tag; + int fc_crc; + struct ext4_fc_alloc_region *fc_regions; + int fc_regions_size; + int fc_regions_used; + int fc_regions_valid; + int *fc_modified_inodes; + int fc_modified_inodes_used; + int fc_modified_inodes_size; +}; + +struct ext4_inode_info { + __le32 i_data[15]; + __u32 i_dtime; + ext4_fsblk_t i_file_acl; + ext4_group_t i_block_group; + ext4_lblk_t i_dir_start_lookup; + long unsigned int i_flags; + struct rw_semaphore xattr_sem; + struct list_head i_orphan; + struct list_head i_fc_list; + ext4_lblk_t i_fc_lblk_start; + ext4_lblk_t i_fc_lblk_len; + atomic_t i_fc_updates; + wait_queue_head_t i_fc_wait; + struct mutex i_fc_lock; + loff_t i_disksize; + struct rw_semaphore i_data_sem; + struct rw_semaphore i_mmap_sem; + struct inode vfs_inode; + struct jbd2_inode *jinode; + spinlock_t i_raw_lock; + struct timespec64 i_crtime; + atomic_t i_prealloc_active; + struct list_head i_prealloc_list; + spinlock_t i_prealloc_lock; + struct ext4_es_tree i_es_tree; + rwlock_t i_es_lock; + struct list_head i_es_list; + unsigned int i_es_all_nr; + unsigned int i_es_shk_nr; + ext4_lblk_t i_es_shrink_lblk; + ext4_group_t i_last_alloc_group; + unsigned int i_reserved_data_blocks; + struct ext4_pending_tree i_pending_tree; + __u16 i_extra_isize; + u16 i_inline_off; + u16 i_inline_size; + qsize_t i_reserved_quota; + spinlock_t i_completed_io_lock; + struct list_head i_rsv_conversion_list; + struct work_struct i_rsv_conversion_work; + atomic_t i_unwritten; + spinlock_t i_block_reservation_lock; + tid_t i_sync_tid; + tid_t i_datasync_tid; + struct dquot *i_dquot[3]; + __u32 i_csum_seed; + kprojid_t i_projid; +}; + +struct ext4_super_block { + __le32 s_inodes_count; + __le32 s_blocks_count_lo; + __le32 s_r_blocks_count_lo; + __le32 s_free_blocks_count_lo; + __le32 s_free_inodes_count; + __le32 s_first_data_block; + __le32 s_log_block_size; + __le32 s_log_cluster_size; + __le32 s_blocks_per_group; + __le32 s_clusters_per_group; + __le32 s_inodes_per_group; + __le32 s_mtime; + __le32 s_wtime; + __le16 s_mnt_count; + __le16 s_max_mnt_count; + __le16 s_magic; + __le16 s_state; + __le16 s_errors; + __le16 s_minor_rev_level; + __le32 s_lastcheck; + __le32 s_checkinterval; + __le32 s_creator_os; + __le32 s_rev_level; + __le16 s_def_resuid; + __le16 s_def_resgid; + __le32 s_first_ino; + __le16 s_inode_size; + __le16 s_block_group_nr; + __le32 s_feature_compat; + __le32 s_feature_incompat; + __le32 s_feature_ro_compat; + __u8 s_uuid[16]; + char s_volume_name[16]; + char s_last_mounted[64]; + __le32 s_algorithm_usage_bitmap; + __u8 s_prealloc_blocks; + __u8 s_prealloc_dir_blocks; + __le16 s_reserved_gdt_blocks; + __u8 s_journal_uuid[16]; + __le32 s_journal_inum; + __le32 s_journal_dev; + __le32 s_last_orphan; + __le32 s_hash_seed[4]; + __u8 s_def_hash_version; + __u8 s_jnl_backup_type; + __le16 s_desc_size; + __le32 s_default_mount_opts; + __le32 s_first_meta_bg; + __le32 s_mkfs_time; + __le32 s_jnl_blocks[17]; + __le32 s_blocks_count_hi; + __le32 s_r_blocks_count_hi; + __le32 s_free_blocks_count_hi; + __le16 s_min_extra_isize; + __le16 s_want_extra_isize; + __le32 s_flags; + __le16 s_raid_stride; + __le16 s_mmp_update_interval; + __le64 s_mmp_block; + __le32 s_raid_stripe_width; + __u8 s_log_groups_per_flex; + __u8 s_checksum_type; + __u8 s_encryption_level; + __u8 s_reserved_pad; + __le64 s_kbytes_written; + __le32 s_snapshot_inum; + __le32 s_snapshot_id; + __le64 s_snapshot_r_blocks_count; + __le32 s_snapshot_list; + __le32 s_error_count; + __le32 s_first_error_time; + __le32 s_first_error_ino; + __le64 s_first_error_block; + __u8 s_first_error_func[32]; + __le32 s_first_error_line; + __le32 s_last_error_time; + __le32 s_last_error_ino; + __le32 s_last_error_line; + __le64 s_last_error_block; + __u8 s_last_error_func[32]; + __u8 s_mount_opts[64]; + __le32 s_usr_quota_inum; + __le32 s_grp_quota_inum; + __le32 s_overhead_clusters; + __le32 s_backup_bgs[2]; + __u8 s_encrypt_algos[4]; + __u8 s_encrypt_pw_salt[16]; + __le32 s_lpf_ino; + __le32 s_prj_quota_inum; + __le32 s_checksum_seed; + __u8 s_wtime_hi; + __u8 s_mtime_hi; + __u8 s_mkfs_time_hi; + __u8 s_lastcheck_hi; + __u8 s_first_error_time_hi; + __u8 s_last_error_time_hi; + __u8 s_first_error_errcode; + __u8 s_last_error_errcode; + __le16 s_encoding; + __le16 s_encoding_flags; + __le32 s_reserved[95]; + __le32 s_checksum; +}; + +struct mb_cache___2; + +struct ext4_group_info; + +struct ext4_locality_group; + +struct ext4_li_request; + +struct ext4_sb_info { + long unsigned int s_desc_size; + long unsigned int s_inodes_per_block; + long unsigned int s_blocks_per_group; + long unsigned int s_clusters_per_group; + long unsigned int s_inodes_per_group; + long unsigned int s_itb_per_group; + long unsigned int s_gdb_count; + long unsigned int s_desc_per_block; + ext4_group_t s_groups_count; + ext4_group_t s_blockfile_groups; + long unsigned int s_overhead; + unsigned int s_cluster_ratio; + unsigned int s_cluster_bits; + loff_t s_bitmap_maxbytes; + struct buffer_head *s_sbh; + struct ext4_super_block *s_es; + struct buffer_head **s_group_desc; + unsigned int s_mount_opt; + unsigned int s_mount_opt2; + long unsigned int s_mount_flags; + unsigned int s_def_mount_opt; + ext4_fsblk_t s_sb_block; + atomic64_t s_resv_clusters; + kuid_t s_resuid; + kgid_t s_resgid; + short unsigned int s_mount_state; + short unsigned int s_pad; + int s_addr_per_block_bits; + int s_desc_per_block_bits; + int s_inode_size; + int s_first_ino; + unsigned int s_inode_readahead_blks; + unsigned int s_inode_goal; + u32 s_hash_seed[4]; + int s_def_hash_version; + int s_hash_unsigned; + struct percpu_counter s_freeclusters_counter; + struct percpu_counter s_freeinodes_counter; + struct percpu_counter s_dirs_counter; + struct percpu_counter s_dirtyclusters_counter; + struct blockgroup_lock *s_blockgroup_lock; + struct proc_dir_entry *s_proc; + struct kobject s_kobj; + struct completion s_kobj_unregister; + struct super_block *s_sb; + struct journal_s *s_journal; + struct list_head s_orphan; + struct mutex s_orphan_lock; + long unsigned int s_ext4_flags; + long unsigned int s_commit_interval; + u32 s_max_batch_time; + u32 s_min_batch_time; + struct block_device *s_journal_bdev; + char *s_qf_names[3]; + int s_jquota_fmt; + unsigned int s_want_extra_isize; + struct ext4_system_blocks *s_system_blks; + struct ext4_group_info ***s_group_info; + struct inode *s_buddy_cache; + spinlock_t s_md_lock; + short unsigned int *s_mb_offsets; + unsigned int *s_mb_maxs; + unsigned int s_group_info_size; + unsigned int s_mb_free_pending; + struct list_head s_freed_data_list; + long unsigned int s_stripe; + unsigned int s_mb_stream_request; + unsigned int s_mb_max_to_scan; + unsigned int s_mb_min_to_scan; + unsigned int s_mb_stats; + unsigned int s_mb_order2_reqs; + unsigned int s_mb_group_prealloc; + unsigned int s_mb_max_inode_prealloc; + unsigned int s_max_dir_size_kb; + long unsigned int s_mb_last_group; + long unsigned int s_mb_last_start; + unsigned int s_mb_prefetch; + unsigned int s_mb_prefetch_limit; + atomic_t s_bal_reqs; + atomic_t s_bal_success; + atomic_t s_bal_allocated; + atomic_t s_bal_ex_scanned; + atomic_t s_bal_goals; + atomic_t s_bal_breaks; + atomic_t s_bal_2orders; + spinlock_t s_bal_lock; + long unsigned int s_mb_buddies_generated; + long long unsigned int s_mb_generation_time; + atomic_t s_mb_lost_chunks; + atomic_t s_mb_preallocated; + atomic_t s_mb_discarded; + atomic_t s_lock_busy; + struct ext4_locality_group *s_locality_groups; + long unsigned int s_sectors_written_start; + u64 s_kbytes_written; + unsigned int s_extent_max_zeroout_kb; + unsigned int s_log_groups_per_flex; + struct flex_groups **s_flex_groups; + ext4_group_t s_flex_groups_allocated; + struct workqueue_struct *rsv_conversion_wq; + struct timer_list s_err_report; + struct ext4_li_request *s_li_request; + unsigned int s_li_wait_mult; + struct task_struct *s_mmp_tsk; + atomic_t s_last_trim_minblks; + struct crypto_shash *s_chksum_driver; + __u32 s_csum_seed; + struct shrinker s_es_shrinker; + struct list_head s_es_list; + long int s_es_nr_inode; + struct ext4_es_stats s_es_stats; + struct mb_cache___2 *s_ea_block_cache; + struct mb_cache___2 *s_ea_inode_cache; + spinlock_t s_es_lock; + struct ratelimit_state s_err_ratelimit_state; + struct ratelimit_state s_warning_ratelimit_state; + struct ratelimit_state s_msg_ratelimit_state; + atomic_t s_warning_count; + atomic_t s_msg_count; + struct fscrypt_dummy_policy s_dummy_enc_policy; + struct percpu_rw_semaphore s_writepages_rwsem; + struct dax_device *s_daxdev; + errseq_t s_bdev_wb_err; + spinlock_t s_bdev_wb_lock; + atomic_t s_fc_subtid; + atomic_t s_fc_ineligible_updates; + struct list_head s_fc_q[2]; + struct list_head s_fc_dentry_q[2]; + unsigned int s_fc_bytes; + spinlock_t s_fc_lock; + struct buffer_head *s_fc_bh; + struct ext4_fc_stats s_fc_stats; + u64 s_fc_avg_commit_time; + struct ext4_fc_replay_state s_fc_replay_state; + long: 64; + long: 64; + long: 64; +}; + +struct ext4_group_info { + long unsigned int bb_state; + struct rb_root bb_free_root; + ext4_grpblk_t bb_first_free; + ext4_grpblk_t bb_free; + ext4_grpblk_t bb_fragments; + ext4_grpblk_t bb_largest_free_order; + struct list_head bb_prealloc_list; + struct rw_semaphore alloc_sem; + ext4_grpblk_t bb_counters[0]; +}; + +struct ext4_locality_group { + struct mutex lg_mutex; + struct list_head lg_prealloc_list[10]; + spinlock_t lg_prealloc_lock; +}; + +enum ext4_li_mode { + EXT4_LI_MODE_PREFETCH_BBITMAP = 0, + EXT4_LI_MODE_ITABLE = 1, +}; + +struct ext4_li_request { + struct super_block *lr_super; + enum ext4_li_mode lr_mode; + ext4_group_t lr_first_not_zeroed; + ext4_group_t lr_next_group; + struct list_head lr_request; + long unsigned int lr_next_sched; + long unsigned int lr_timeout; +}; + +struct shash_desc { + struct crypto_shash *tfm; + void *__ctx[0]; +}; + +struct ext4_map_blocks { + ext4_fsblk_t m_pblk; + ext4_lblk_t m_lblk; + unsigned int m_len; + unsigned int m_flags; +}; + +struct ext4_system_zone { + struct rb_node node; + ext4_fsblk_t start_blk; + unsigned int count; + u32 ino; +}; + +struct fscrypt_str { + unsigned char *name; + u32 len; +}; + +enum { + EXT4_INODE_SECRM = 0, + EXT4_INODE_UNRM = 1, + EXT4_INODE_COMPR = 2, + EXT4_INODE_SYNC = 3, + EXT4_INODE_IMMUTABLE = 4, + EXT4_INODE_APPEND = 5, + EXT4_INODE_NODUMP = 6, + EXT4_INODE_NOATIME = 7, + EXT4_INODE_DIRTY = 8, + EXT4_INODE_COMPRBLK = 9, + EXT4_INODE_NOCOMPR = 10, + EXT4_INODE_ENCRYPT = 11, + EXT4_INODE_INDEX = 12, + EXT4_INODE_IMAGIC = 13, + EXT4_INODE_JOURNAL_DATA = 14, + EXT4_INODE_NOTAIL = 15, + EXT4_INODE_DIRSYNC = 16, + EXT4_INODE_TOPDIR = 17, + EXT4_INODE_HUGE_FILE = 18, + EXT4_INODE_EXTENTS = 19, + EXT4_INODE_VERITY = 20, + EXT4_INODE_EA_INODE = 21, + EXT4_INODE_DAX = 25, + EXT4_INODE_INLINE_DATA = 28, + EXT4_INODE_PROJINHERIT = 29, + EXT4_INODE_CASEFOLD = 30, + EXT4_INODE_RESERVED = 31, +}; + +enum { + EXT4_FC_REASON_OK = 0, + EXT4_FC_REASON_INELIGIBLE = 1, + EXT4_FC_REASON_ALREADY_COMMITTED = 2, + EXT4_FC_REASON_FC_START_FAILED = 3, + EXT4_FC_REASON_FC_FAILED = 4, + EXT4_FC_REASON_XATTR = 0, + EXT4_FC_REASON_CROSS_RENAME = 1, + EXT4_FC_REASON_JOURNAL_FLAG_CHANGE = 2, + EXT4_FC_REASON_NOMEM = 3, + EXT4_FC_REASON_SWAP_BOOT = 4, + EXT4_FC_REASON_RESIZE = 5, + EXT4_FC_REASON_RENAME_DIR = 6, + EXT4_FC_REASON_FALLOC_RANGE = 7, + EXT4_FC_REASON_INODE_JOURNAL_DATA = 8, + EXT4_FC_COMMIT_FAILED = 9, + EXT4_FC_REASON_MAX = 10, +}; + +struct ext4_dir_entry_2 { + __le32 inode; + __le16 rec_len; + __u8 name_len; + __u8 file_type; + char name[255]; +}; + +struct fname; + +struct dir_private_info { + struct rb_root root; + struct rb_node *curr_node; + struct fname *extra_fname; + loff_t last_pos; + __u32 curr_hash; + __u32 curr_minor_hash; + __u32 next_hash; +}; + +struct fname { + __u32 hash; + __u32 minor_hash; + struct rb_node rb_hash; + struct fname *next; + __u32 inode; + __u8 name_len; + __u8 file_type; + char name[0]; +}; + +enum SHIFT_DIRECTION { + SHIFT_LEFT = 0, + SHIFT_RIGHT = 1, +}; + +struct ext4_io_end_vec { + struct list_head list; + loff_t offset; + ssize_t size; +}; + +struct ext4_io_end { + struct list_head list; + handle_t *handle; + struct inode *inode; + struct bio *bio; + unsigned int flag; + atomic_t count; + struct list_head list_vec; +}; + +typedef struct ext4_io_end ext4_io_end_t; + +enum { + ES_WRITTEN_B = 0, + ES_UNWRITTEN_B = 1, + ES_DELAYED_B = 2, + ES_HOLE_B = 3, + ES_REFERENCED_B = 4, + ES_FLAGS = 5, +}; + +enum { + EXT4_STATE_JDATA = 0, + EXT4_STATE_NEW = 1, + EXT4_STATE_XATTR = 2, + EXT4_STATE_NO_EXPAND = 3, + EXT4_STATE_DA_ALLOC_CLOSE = 4, + EXT4_STATE_EXT_MIGRATE = 5, + EXT4_STATE_NEWENTRY = 6, + EXT4_STATE_MAY_INLINE_DATA = 7, + EXT4_STATE_EXT_PRECACHED = 8, + EXT4_STATE_LUSTRE_EA_INODE = 9, + EXT4_STATE_VERITY_IN_PROGRESS = 10, + EXT4_STATE_FC_COMMITTING = 11, +}; + +struct ext4_iloc { + struct buffer_head *bh; + long unsigned int offset; + ext4_group_t block_group; +}; + +struct ext4_extent_tail { + __le32 et_checksum; +}; + +struct ext4_extent { + __le32 ee_block; + __le16 ee_len; + __le16 ee_start_hi; + __le32 ee_start_lo; +}; + +struct ext4_extent_idx { + __le32 ei_block; + __le32 ei_leaf_lo; + __le16 ei_leaf_hi; + __u16 ei_unused; +}; + +struct ext4_extent_header { + __le16 eh_magic; + __le16 eh_entries; + __le16 eh_max; + __le16 eh_depth; + __le32 eh_generation; +}; + +struct ext4_ext_path { + ext4_fsblk_t p_block; + __u16 p_depth; + __u16 p_maxdepth; + struct ext4_extent *p_ext; + struct ext4_extent_idx *p_idx; + struct ext4_extent_header *p_hdr; + struct buffer_head *p_bh; +}; + +struct partial_cluster { + ext4_fsblk_t pclu; + ext4_lblk_t lblk; + enum { + initial = 0, + tofree = 1, + nofree = 2, + } state; +}; + +struct pending_reservation { + struct rb_node rb_node; + ext4_lblk_t lclu; +}; + +struct rsvd_count { + int ndelonly; + bool first_do_lblk_found; + ext4_lblk_t first_do_lblk; + ext4_lblk_t last_do_lblk; + struct extent_status *left_es; + bool partial; + ext4_lblk_t lclu; +}; + +enum { + EXT4_MF_MNTDIR_SAMPLED = 0, + EXT4_MF_FS_ABORTED = 1, + EXT4_MF_FC_INELIGIBLE = 2, + EXT4_MF_FC_COMMITTING = 3, +}; + +struct fsverity_info; + +struct fsmap { + __u32 fmr_device; + __u32 fmr_flags; + __u64 fmr_physical; + __u64 fmr_owner; + __u64 fmr_offset; + __u64 fmr_length; + __u64 fmr_reserved[3]; +}; + +struct ext4_fsmap { + struct list_head fmr_list; + dev_t fmr_device; + uint32_t fmr_flags; + uint64_t fmr_physical; + uint64_t fmr_owner; + uint64_t fmr_length; +}; + +struct ext4_fsmap_head { + uint32_t fmh_iflags; + uint32_t fmh_oflags; + unsigned int fmh_count; + unsigned int fmh_entries; + struct ext4_fsmap fmh_keys[2]; +}; + +typedef int (*ext4_fsmap_format_t)(struct ext4_fsmap *, void *); + +struct ext4_getfsmap_info { + struct ext4_fsmap_head *gfi_head; + ext4_fsmap_format_t gfi_formatter; + void *gfi_format_arg; + ext4_fsblk_t gfi_next_fsblk; + u32 gfi_dev; + ext4_group_t gfi_agno; + struct ext4_fsmap gfi_low; + struct ext4_fsmap gfi_high; + struct ext4_fsmap gfi_lastfree; + struct list_head gfi_meta_list; + bool gfi_last; +}; + +struct ext4_getfsmap_dev { + int (*gfd_fn)(struct super_block *, struct ext4_fsmap *, struct ext4_getfsmap_info *); + u32 gfd_dev; +}; + +struct dx_hash_info { + u32 hash; + u32 minor_hash; + int hash_version; + u32 *seed; +}; + +typedef unsigned int __kernel_mode_t; + +typedef __kernel_mode_t mode_t; + +struct ext4_inode { + __le16 i_mode; + __le16 i_uid; + __le32 i_size_lo; + __le32 i_atime; + __le32 i_ctime; + __le32 i_mtime; + __le32 i_dtime; + __le16 i_gid; + __le16 i_links_count; + __le32 i_blocks_lo; + __le32 i_flags; + union { + struct { + __le32 l_i_version; + } linux1; + struct { + __u32 h_i_translator; + } hurd1; + struct { + __u32 m_i_reserved1; + } masix1; + } osd1; + __le32 i_block[15]; + __le32 i_generation; + __le32 i_file_acl_lo; + __le32 i_size_high; + __le32 i_obso_faddr; + union { + struct { + __le16 l_i_blocks_high; + __le16 l_i_file_acl_high; + __le16 l_i_uid_high; + __le16 l_i_gid_high; + __le16 l_i_checksum_lo; + __le16 l_i_reserved; + } linux2; + struct { + __le16 h_i_reserved1; + __u16 h_i_mode_high; + __u16 h_i_uid_high; + __u16 h_i_gid_high; + __u32 h_i_author; + } hurd2; + struct { + __le16 h_i_reserved1; + __le16 m_i_file_acl_high; + __u32 m_i_reserved2[2]; + } masix2; + } osd2; + __le16 i_extra_isize; + __le16 i_checksum_hi; + __le32 i_ctime_extra; + __le32 i_mtime_extra; + __le32 i_atime_extra; + __le32 i_crtime; + __le32 i_crtime_extra; + __le32 i_version_hi; + __le32 i_projid; +}; + +struct orlov_stats { + __u64 free_clusters; + __u32 free_inodes; + __u32 used_dirs; +}; + +typedef struct { + __le32 *p; + __le32 key; + struct buffer_head *bh; +} Indirect; + +struct ext4_filename { + const struct qstr *usr_fname; + struct fscrypt_str disk_name; + struct dx_hash_info hinfo; +}; + +struct ext4_xattr_ibody_header { + __le32 h_magic; +}; + +struct ext4_xattr_entry { + __u8 e_name_len; + __u8 e_name_index; + __le16 e_value_offs; + __le32 e_value_inum; + __le32 e_value_size; + __le32 e_hash; + char e_name[0]; +}; + +struct ext4_xattr_info { + const char *name; + const void *value; + size_t value_len; + int name_index; + int in_inode; +}; + +struct ext4_xattr_search { + struct ext4_xattr_entry *first; + void *base; + void *end; + struct ext4_xattr_entry *here; + int not_found; +}; + +struct ext4_xattr_ibody_find { + struct ext4_xattr_search s; + struct ext4_iloc iloc; +}; + +typedef short unsigned int __kernel_uid16_t; + +typedef short unsigned int __kernel_gid16_t; + +typedef __kernel_uid16_t uid16_t; + +typedef __kernel_gid16_t gid16_t; + +struct ext4_io_submit { + struct writeback_control *io_wbc; + struct bio *io_bio; + ext4_io_end_t *io_end; + sector_t io_next_block; +}; + +typedef enum { + EXT4_IGET_NORMAL = 0, + EXT4_IGET_SPECIAL = 1, + EXT4_IGET_HANDLE = 2, +} ext4_iget_flags; + +struct ext4_xattr_inode_array { + unsigned int count; + struct inode *inodes[0]; +}; + +struct mpage_da_data { + struct inode *inode; + struct writeback_control *wbc; + long unsigned int first_page; + long unsigned int next_page; + long unsigned int last_page; + struct ext4_map_blocks map; + struct ext4_io_submit io_submit; + unsigned int do_map: 1; + unsigned int scanned_until_end: 1; +}; + +struct fscrypt_info; + +struct fstrim_range { + __u64 start; + __u64 len; + __u64 minlen; +}; + +struct ext4_new_group_input { + __u32 group; + __u64 block_bitmap; + __u64 inode_bitmap; + __u64 inode_table; + __u32 blocks_count; + __u16 reserved_blocks; + __u16 unused; +}; + +struct compat_ext4_new_group_input { + u32 group; + compat_u64 block_bitmap; + compat_u64 inode_bitmap; + compat_u64 inode_table; + u32 blocks_count; + u16 reserved_blocks; + u16 unused; +} __attribute__((packed)); + +struct ext4_new_group_data { + __u32 group; + __u64 block_bitmap; + __u64 inode_bitmap; + __u64 inode_table; + __u32 blocks_count; + __u16 reserved_blocks; + __u16 mdata_blocks; + __u32 free_clusters_count; +}; + +struct move_extent { + __u32 reserved; + __u32 donor_fd; + __u64 orig_start; + __u64 donor_start; + __u64 len; + __u64 moved_len; +}; + +struct fsmap_head { + __u32 fmh_iflags; + __u32 fmh_oflags; + __u32 fmh_count; + __u32 fmh_entries; + __u64 fmh_reserved[6]; + struct fsmap fmh_keys[2]; + struct fsmap fmh_recs[0]; +}; + +struct getfsmap_info { + struct super_block *gi_sb; + struct fsmap_head *gi_data; + unsigned int gi_idx; + __u32 gi_last_flags; +}; + +struct ext4_free_data { + struct list_head efd_list; + struct rb_node efd_node; + ext4_group_t efd_group; + ext4_grpblk_t efd_start_cluster; + ext4_grpblk_t efd_count; + tid_t efd_tid; +}; + +struct ext4_prealloc_space { + struct list_head pa_inode_list; + struct list_head pa_group_list; + union { + struct list_head pa_tmp_list; + struct callback_head pa_rcu; + } u; + spinlock_t pa_lock; + atomic_t pa_count; + unsigned int pa_deleted; + ext4_fsblk_t pa_pstart; + ext4_lblk_t pa_lstart; + ext4_grpblk_t pa_len; + ext4_grpblk_t pa_free; + short unsigned int pa_type; + spinlock_t *pa_obj_lock; + struct inode *pa_inode; +}; + +enum { + MB_INODE_PA = 0, + MB_GROUP_PA = 1, +}; + +struct ext4_free_extent { + ext4_lblk_t fe_logical; + ext4_grpblk_t fe_start; + ext4_group_t fe_group; + ext4_grpblk_t fe_len; +}; + +struct ext4_allocation_context { + struct inode *ac_inode; + struct super_block *ac_sb; + struct ext4_free_extent ac_o_ex; + struct ext4_free_extent ac_g_ex; + struct ext4_free_extent ac_b_ex; + struct ext4_free_extent ac_f_ex; + __u16 ac_groups_scanned; + __u16 ac_found; + __u16 ac_tail; + __u16 ac_buddy; + __u16 ac_flags; + __u8 ac_status; + __u8 ac_criteria; + __u8 ac_2order; + __u8 ac_op; + struct page *ac_bitmap_page; + struct page *ac_buddy_page; + struct ext4_prealloc_space *ac_pa; + struct ext4_locality_group *ac_lg; +}; + +struct ext4_buddy { + struct page *bd_buddy_page; + void *bd_buddy; + struct page *bd_bitmap_page; + void *bd_bitmap; + struct ext4_group_info *bd_info; + struct super_block *bd_sb; + __u16 bd_blkbits; + ext4_group_t bd_group; +}; + +typedef int (*ext4_mballoc_query_range_fn)(struct super_block *, ext4_group_t, ext4_grpblk_t, ext4_grpblk_t, void *); + +struct sg { + struct ext4_group_info info; + ext4_grpblk_t counters[18]; +}; + +struct migrate_struct { + ext4_lblk_t first_block; + ext4_lblk_t last_block; + ext4_lblk_t curr_block; + ext4_fsblk_t first_pblock; + ext4_fsblk_t last_pblock; +}; + +struct mmp_struct { + __le32 mmp_magic; + __le32 mmp_seq; + __le64 mmp_time; + char mmp_nodename[64]; + char mmp_bdevname[32]; + __le16 mmp_check_interval; + __le16 mmp_pad1; + __le32 mmp_pad2[226]; + __le32 mmp_checksum; +}; + +struct mmpd_data { + struct buffer_head *bh; + struct super_block *sb; +}; + +struct fscrypt_name { + const struct qstr *usr_fname; + struct fscrypt_str disk_name; + u32 hash; + u32 minor_hash; + struct fscrypt_str crypto_buf; + bool is_nokey_name; +}; + +struct ext4_dir_entry { + __le32 inode; + __le16 rec_len; + __le16 name_len; + char name[255]; +}; + +struct ext4_dir_entry_tail { + __le32 det_reserved_zero1; + __le16 det_rec_len; + __u8 det_reserved_zero2; + __u8 det_reserved_ft; + __le32 det_checksum; +}; + +typedef enum { + EITHER = 0, + INDEX = 1, + DIRENT = 2, + DIRENT_HTREE = 3, +} dirblock_type_t; + +struct fake_dirent { + __le32 inode; + __le16 rec_len; + u8 name_len; + u8 file_type; +}; + +struct dx_countlimit { + __le16 limit; + __le16 count; +}; + +struct dx_entry { + __le32 hash; + __le32 block; +}; + +struct dx_root_info { + __le32 reserved_zero; + u8 hash_version; + u8 info_length; + u8 indirect_levels; + u8 unused_flags; +}; + +struct dx_root { + struct fake_dirent dot; + char dot_name[4]; + struct fake_dirent dotdot; + char dotdot_name[4]; + struct dx_root_info info; + struct dx_entry entries[0]; +}; + +struct dx_node { + struct fake_dirent fake; + struct dx_entry entries[0]; +}; + +struct dx_frame { + struct buffer_head *bh; + struct dx_entry *entries; + struct dx_entry *at; +}; + +struct dx_map_entry { + u32 hash; + u16 offs; + u16 size; +}; + +struct dx_tail { + u32 dt_reserved; + __le32 dt_checksum; +}; + +struct ext4_renament { + struct inode *dir; + struct dentry *dentry; + struct inode *inode; + bool is_dir; + int dir_nlink_delta; + struct buffer_head *bh; + struct ext4_dir_entry_2 *de; + int inlined; + struct buffer_head *dir_bh; + struct ext4_dir_entry_2 *parent_de; + int dir_inlined; +}; + +enum bio_post_read_step { + STEP_INITIAL = 0, + STEP_DECRYPT = 1, + STEP_VERITY = 2, + STEP_MAX = 3, +}; + +struct bio_post_read_ctx { + struct bio *bio; + struct work_struct work; + unsigned int cur_step; + unsigned int enabled_steps; +}; + +enum { + BLOCK_BITMAP = 0, + INODE_BITMAP = 1, + INODE_TABLE = 2, + GROUP_TABLE_COUNT = 3, +}; + +struct ext4_rcu_ptr { + struct callback_head rcu; + void *ptr; +}; + +struct ext4_new_flex_group_data { + struct ext4_new_group_data *groups; + __u16 *bg_flags; + ext4_group_t count; +}; + +enum stat_group { + STAT_READ = 0, + STAT_WRITE = 1, + STAT_DISCARD = 2, + STAT_FLUSH = 3, + NR_STAT_GROUPS = 4, +}; + +enum { + I_DATA_SEM_NORMAL = 0, + I_DATA_SEM_OTHER = 1, + I_DATA_SEM_QUOTA = 2, +}; + +struct ext4_lazy_init { + long unsigned int li_state; + struct list_head li_request_list; + struct mutex li_list_mtx; +}; + +struct ext4_journal_cb_entry { + struct list_head jce_list; + void (*jce_func)(struct super_block *, struct ext4_journal_cb_entry *, int); +}; + +struct trace_event_raw_ext4_other_inode_update_time { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ino_t orig_ino; + uid_t uid; + gid_t gid; + __u16 mode; + char __data[0]; +}; + +struct trace_event_raw_ext4_free_inode { + struct trace_entry ent; + dev_t dev; + ino_t ino; + uid_t uid; + gid_t gid; + __u64 blocks; + __u16 mode; + char __data[0]; +}; + +struct trace_event_raw_ext4_request_inode { + struct trace_entry ent; + dev_t dev; + ino_t dir; + __u16 mode; + char __data[0]; +}; + +struct trace_event_raw_ext4_allocate_inode { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ino_t dir; + __u16 mode; + char __data[0]; +}; + +struct trace_event_raw_ext4_evict_inode { + struct trace_entry ent; + dev_t dev; + ino_t ino; + int nlink; + char __data[0]; +}; + +struct trace_event_raw_ext4_drop_inode { + struct trace_entry ent; + dev_t dev; + ino_t ino; + int drop; + char __data[0]; +}; + +struct trace_event_raw_ext4_nfs_commit_metadata { + struct trace_entry ent; + dev_t dev; + ino_t ino; + char __data[0]; +}; + +struct trace_event_raw_ext4_mark_inode_dirty { + struct trace_entry ent; + dev_t dev; + ino_t ino; + long unsigned int ip; + char __data[0]; +}; + +struct trace_event_raw_ext4_begin_ordered_truncate { + struct trace_entry ent; + dev_t dev; + ino_t ino; + loff_t new_size; + char __data[0]; +}; + +struct trace_event_raw_ext4__write_begin { + struct trace_entry ent; + dev_t dev; + ino_t ino; + loff_t pos; + unsigned int len; + unsigned int flags; + char __data[0]; +}; + +struct trace_event_raw_ext4__write_end { + struct trace_entry ent; + dev_t dev; + ino_t ino; + loff_t pos; + unsigned int len; + unsigned int copied; + char __data[0]; +}; + +struct trace_event_raw_ext4_writepages { + struct trace_entry ent; + dev_t dev; + ino_t ino; + long int nr_to_write; + long int pages_skipped; + loff_t range_start; + loff_t range_end; + long unsigned int writeback_index; + int sync_mode; + char for_kupdate; + char range_cyclic; + char __data[0]; +}; + +struct trace_event_raw_ext4_da_write_pages { + struct trace_entry ent; + dev_t dev; + ino_t ino; + long unsigned int first_page; + long int nr_to_write; + int sync_mode; + char __data[0]; +}; + +struct trace_event_raw_ext4_da_write_pages_extent { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u64 lblk; + __u32 len; + __u32 flags; + char __data[0]; +}; + +struct trace_event_raw_ext4_writepages_result { + struct trace_entry ent; + dev_t dev; + ino_t ino; + int ret; + int pages_written; + long int pages_skipped; + long unsigned int writeback_index; + int sync_mode; + char __data[0]; +}; + +struct trace_event_raw_ext4__page_op { + struct trace_entry ent; + dev_t dev; + ino_t ino; + long unsigned int index; + char __data[0]; +}; + +struct trace_event_raw_ext4_invalidatepage_op { + struct trace_entry ent; + dev_t dev; + ino_t ino; + long unsigned int index; + unsigned int offset; + unsigned int length; + char __data[0]; +}; + +struct trace_event_raw_ext4_discard_blocks { + struct trace_entry ent; + dev_t dev; + __u64 blk; + __u64 count; + char __data[0]; +}; + +struct trace_event_raw_ext4__mb_new_pa { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u64 pa_pstart; + __u64 pa_lstart; + __u32 pa_len; + char __data[0]; +}; + +struct trace_event_raw_ext4_mb_release_inode_pa { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u64 block; + __u32 count; + char __data[0]; +}; + +struct trace_event_raw_ext4_mb_release_group_pa { + struct trace_entry ent; + dev_t dev; + __u64 pa_pstart; + __u32 pa_len; + char __data[0]; +}; + +struct trace_event_raw_ext4_discard_preallocations { + struct trace_entry ent; + dev_t dev; + ino_t ino; + unsigned int len; + unsigned int needed; + char __data[0]; +}; + +struct trace_event_raw_ext4_mb_discard_preallocations { + struct trace_entry ent; + dev_t dev; + int needed; + char __data[0]; +}; + +struct trace_event_raw_ext4_request_blocks { + struct trace_entry ent; + dev_t dev; + ino_t ino; + unsigned int len; + __u32 logical; + __u32 lleft; + __u32 lright; + __u64 goal; + __u64 pleft; + __u64 pright; + unsigned int flags; + char __data[0]; +}; + +struct trace_event_raw_ext4_allocate_blocks { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u64 block; + unsigned int len; + __u32 logical; + __u32 lleft; + __u32 lright; + __u64 goal; + __u64 pleft; + __u64 pright; + unsigned int flags; + char __data[0]; +}; + +struct trace_event_raw_ext4_free_blocks { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u64 block; + long unsigned int count; + int flags; + __u16 mode; + char __data[0]; +}; + +struct trace_event_raw_ext4_sync_file_enter { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ino_t parent; + int datasync; + char __data[0]; +}; + +struct trace_event_raw_ext4_sync_file_exit { + struct trace_entry ent; + dev_t dev; + ino_t ino; + int ret; + char __data[0]; +}; + +struct trace_event_raw_ext4_sync_fs { + struct trace_entry ent; + dev_t dev; + int wait; + char __data[0]; +}; + +struct trace_event_raw_ext4_alloc_da_blocks { + struct trace_entry ent; + dev_t dev; + ino_t ino; + unsigned int data_blocks; + char __data[0]; +}; + +struct trace_event_raw_ext4_mballoc_alloc { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u32 orig_logical; + int orig_start; + __u32 orig_group; + int orig_len; + __u32 goal_logical; + int goal_start; + __u32 goal_group; + int goal_len; + __u32 result_logical; + int result_start; + __u32 result_group; + int result_len; + __u16 found; + __u16 groups; + __u16 buddy; + __u16 flags; + __u16 tail; + __u8 cr; + char __data[0]; +}; + +struct trace_event_raw_ext4_mballoc_prealloc { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u32 orig_logical; + int orig_start; + __u32 orig_group; + int orig_len; + __u32 result_logical; + int result_start; + __u32 result_group; + int result_len; + char __data[0]; +}; + +struct trace_event_raw_ext4__mballoc { + struct trace_entry ent; + dev_t dev; + ino_t ino; + int result_start; + __u32 result_group; + int result_len; + char __data[0]; +}; + +struct trace_event_raw_ext4_forget { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u64 block; + int is_metadata; + __u16 mode; + char __data[0]; +}; + +struct trace_event_raw_ext4_da_update_reserve_space { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u64 i_blocks; + int used_blocks; + int reserved_data_blocks; + int quota_claim; + __u16 mode; + char __data[0]; +}; + +struct trace_event_raw_ext4_da_reserve_space { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u64 i_blocks; + int reserved_data_blocks; + __u16 mode; + char __data[0]; +}; + +struct trace_event_raw_ext4_da_release_space { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u64 i_blocks; + int freed_blocks; + int reserved_data_blocks; + __u16 mode; + char __data[0]; +}; + +struct trace_event_raw_ext4__bitmap_load { + struct trace_entry ent; + dev_t dev; + __u32 group; + char __data[0]; +}; + +struct trace_event_raw_ext4_read_block_bitmap_load { + struct trace_entry ent; + dev_t dev; + __u32 group; + bool prefetch; + char __data[0]; +}; + +struct trace_event_raw_ext4_direct_IO_enter { + struct trace_entry ent; + dev_t dev; + ino_t ino; + loff_t pos; + long unsigned int len; + int rw; + char __data[0]; +}; + +struct trace_event_raw_ext4_direct_IO_exit { + struct trace_entry ent; + dev_t dev; + ino_t ino; + loff_t pos; + long unsigned int len; + int rw; + int ret; + char __data[0]; +}; + +struct trace_event_raw_ext4__fallocate_mode { + struct trace_entry ent; + dev_t dev; + ino_t ino; + loff_t offset; + loff_t len; + int mode; + char __data[0]; +}; + +struct trace_event_raw_ext4_fallocate_exit { + struct trace_entry ent; + dev_t dev; + ino_t ino; + loff_t pos; + unsigned int blocks; + int ret; + char __data[0]; +}; + +struct trace_event_raw_ext4_unlink_enter { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ino_t parent; + loff_t size; + char __data[0]; +}; + +struct trace_event_raw_ext4_unlink_exit { + struct trace_entry ent; + dev_t dev; + ino_t ino; + int ret; + char __data[0]; +}; + +struct trace_event_raw_ext4__truncate { + struct trace_entry ent; + dev_t dev; + ino_t ino; + __u64 blocks; + char __data[0]; +}; + +struct trace_event_raw_ext4_ext_convert_to_initialized_enter { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t m_lblk; + unsigned int m_len; + ext4_lblk_t u_lblk; + unsigned int u_len; + ext4_fsblk_t u_pblk; + char __data[0]; +}; + +struct trace_event_raw_ext4_ext_convert_to_initialized_fastpath { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t m_lblk; + unsigned int m_len; + ext4_lblk_t u_lblk; + unsigned int u_len; + ext4_fsblk_t u_pblk; + ext4_lblk_t i_lblk; + unsigned int i_len; + ext4_fsblk_t i_pblk; + char __data[0]; +}; + +struct trace_event_raw_ext4__map_blocks_enter { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t lblk; + unsigned int len; + unsigned int flags; + char __data[0]; +}; + +struct trace_event_raw_ext4__map_blocks_exit { + struct trace_entry ent; + dev_t dev; + ino_t ino; + unsigned int flags; + ext4_fsblk_t pblk; + ext4_lblk_t lblk; + unsigned int len; + unsigned int mflags; + int ret; + char __data[0]; +}; + +struct trace_event_raw_ext4_ext_load_extent { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_fsblk_t pblk; + ext4_lblk_t lblk; + char __data[0]; +}; + +struct trace_event_raw_ext4_load_inode { + struct trace_entry ent; + dev_t dev; + ino_t ino; + char __data[0]; +}; + +struct trace_event_raw_ext4_journal_start { + struct trace_entry ent; + dev_t dev; + long unsigned int ip; + int blocks; + int rsv_blocks; + int revoke_creds; + char __data[0]; +}; + +struct trace_event_raw_ext4_journal_start_reserved { + struct trace_entry ent; + dev_t dev; + long unsigned int ip; + int blocks; + char __data[0]; +}; + +struct trace_event_raw_ext4__trim { + struct trace_entry ent; + int dev_major; + int dev_minor; + __u32 group; + int start; + int len; + char __data[0]; +}; + +struct trace_event_raw_ext4_ext_handle_unwritten_extents { + struct trace_entry ent; + dev_t dev; + ino_t ino; + int flags; + ext4_lblk_t lblk; + ext4_fsblk_t pblk; + unsigned int len; + unsigned int allocated; + ext4_fsblk_t newblk; + char __data[0]; +}; + +struct trace_event_raw_ext4_get_implied_cluster_alloc_exit { + struct trace_entry ent; + dev_t dev; + unsigned int flags; + ext4_lblk_t lblk; + ext4_fsblk_t pblk; + unsigned int len; + int ret; + char __data[0]; +}; + +struct trace_event_raw_ext4_ext_put_in_cache { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t lblk; + unsigned int len; + ext4_fsblk_t start; + char __data[0]; +}; + +struct trace_event_raw_ext4_ext_in_cache { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t lblk; + int ret; + char __data[0]; +}; + +struct trace_event_raw_ext4_find_delalloc_range { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t from; + ext4_lblk_t to; + int reverse; + int found; + ext4_lblk_t found_blk; + char __data[0]; +}; + +struct trace_event_raw_ext4_get_reserved_cluster_alloc { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t lblk; + unsigned int len; + char __data[0]; +}; + +struct trace_event_raw_ext4_ext_show_extent { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_fsblk_t pblk; + ext4_lblk_t lblk; + short unsigned int len; + char __data[0]; +}; + +struct trace_event_raw_ext4_remove_blocks { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t from; + ext4_lblk_t to; + ext4_fsblk_t ee_pblk; + ext4_lblk_t ee_lblk; + short unsigned int ee_len; + ext4_fsblk_t pc_pclu; + ext4_lblk_t pc_lblk; + int pc_state; + char __data[0]; +}; + +struct trace_event_raw_ext4_ext_rm_leaf { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t start; + ext4_lblk_t ee_lblk; + ext4_fsblk_t ee_pblk; + short int ee_len; + ext4_fsblk_t pc_pclu; + ext4_lblk_t pc_lblk; + int pc_state; + char __data[0]; +}; + +struct trace_event_raw_ext4_ext_rm_idx { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_fsblk_t pblk; + char __data[0]; +}; + +struct trace_event_raw_ext4_ext_remove_space { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t start; + ext4_lblk_t end; + int depth; + char __data[0]; +}; + +struct trace_event_raw_ext4_ext_remove_space_done { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t start; + ext4_lblk_t end; + int depth; + ext4_fsblk_t pc_pclu; + ext4_lblk_t pc_lblk; + int pc_state; + short unsigned int eh_entries; + char __data[0]; +}; + +struct trace_event_raw_ext4__es_extent { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t lblk; + ext4_lblk_t len; + ext4_fsblk_t pblk; + char status; + char __data[0]; +}; + +struct trace_event_raw_ext4_es_remove_extent { + struct trace_entry ent; + dev_t dev; + ino_t ino; + loff_t lblk; + loff_t len; + char __data[0]; +}; + +struct trace_event_raw_ext4_es_find_extent_range_enter { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t lblk; + char __data[0]; +}; + +struct trace_event_raw_ext4_es_find_extent_range_exit { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t lblk; + ext4_lblk_t len; + ext4_fsblk_t pblk; + char status; + char __data[0]; +}; + +struct trace_event_raw_ext4_es_lookup_extent_enter { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t lblk; + char __data[0]; +}; + +struct trace_event_raw_ext4_es_lookup_extent_exit { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t lblk; + ext4_lblk_t len; + ext4_fsblk_t pblk; + char status; + int found; + char __data[0]; +}; + +struct trace_event_raw_ext4__es_shrink_enter { + struct trace_entry ent; + dev_t dev; + int nr_to_scan; + int cache_cnt; + char __data[0]; +}; + +struct trace_event_raw_ext4_es_shrink_scan_exit { + struct trace_entry ent; + dev_t dev; + int nr_shrunk; + int cache_cnt; + char __data[0]; +}; + +struct trace_event_raw_ext4_collapse_range { + struct trace_entry ent; + dev_t dev; + ino_t ino; + loff_t offset; + loff_t len; + char __data[0]; +}; + +struct trace_event_raw_ext4_insert_range { + struct trace_entry ent; + dev_t dev; + ino_t ino; + loff_t offset; + loff_t len; + char __data[0]; +}; + +struct trace_event_raw_ext4_es_shrink { + struct trace_entry ent; + dev_t dev; + int nr_shrunk; + long long unsigned int scan_time; + int nr_skipped; + int retried; + char __data[0]; +}; + +struct trace_event_raw_ext4_es_insert_delayed_block { + struct trace_entry ent; + dev_t dev; + ino_t ino; + ext4_lblk_t lblk; + ext4_lblk_t len; + ext4_fsblk_t pblk; + char status; + bool allocated; + char __data[0]; +}; + +struct trace_event_raw_ext4_fsmap_class { + struct trace_entry ent; + dev_t dev; + dev_t keydev; + u32 agno; + u64 bno; + u64 len; + u64 owner; + char __data[0]; +}; + +struct trace_event_raw_ext4_getfsmap_class { + struct trace_entry ent; + dev_t dev; + dev_t keydev; + u64 block; + u64 len; + u64 owner; + u64 flags; + char __data[0]; +}; + +struct trace_event_raw_ext4_shutdown { + struct trace_entry ent; + dev_t dev; + unsigned int flags; + char __data[0]; +}; + +struct trace_event_raw_ext4_error { + struct trace_entry ent; + dev_t dev; + const char *function; + unsigned int line; + char __data[0]; +}; + +struct trace_event_raw_ext4_prefetch_bitmaps { + struct trace_entry ent; + dev_t dev; + __u32 group; + __u32 next; + __u32 ios; + char __data[0]; +}; + +struct trace_event_raw_ext4_lazy_itable_init { + struct trace_entry ent; + dev_t dev; + __u32 group; + char __data[0]; +}; + +struct trace_event_raw_ext4_fc_replay_scan { + struct trace_entry ent; + dev_t dev; + int error; + int off; + char __data[0]; +}; + +struct trace_event_raw_ext4_fc_replay { + struct trace_entry ent; + dev_t dev; + int tag; + int ino; + int priv1; + int priv2; + char __data[0]; +}; + +struct trace_event_raw_ext4_fc_commit_start { + struct trace_entry ent; + dev_t dev; + char __data[0]; +}; + +struct trace_event_raw_ext4_fc_commit_stop { + struct trace_entry ent; + dev_t dev; + int nblks; + int reason; + int num_fc; + int num_fc_ineligible; + int nblks_agg; + char __data[0]; +}; + +struct trace_event_raw_ext4_fc_stats { + struct trace_entry ent; + dev_t dev; + struct ext4_sb_info *sbi; + int count; + char __data[0]; +}; + +struct trace_event_raw_ext4_fc_track_create { + struct trace_entry ent; + dev_t dev; + int ino; + int error; + char __data[0]; +}; + +struct trace_event_raw_ext4_fc_track_link { + struct trace_entry ent; + dev_t dev; + int ino; + int error; + char __data[0]; +}; + +struct trace_event_raw_ext4_fc_track_unlink { + struct trace_entry ent; + dev_t dev; + int ino; + int error; + char __data[0]; +}; + +struct trace_event_raw_ext4_fc_track_inode { + struct trace_entry ent; + dev_t dev; + int ino; + int error; + char __data[0]; +}; + +struct trace_event_raw_ext4_fc_track_range { + struct trace_entry ent; + dev_t dev; + int ino; + long int start; + long int end; + int error; + char __data[0]; +}; + +struct trace_event_data_offsets_ext4_other_inode_update_time {}; + +struct trace_event_data_offsets_ext4_free_inode {}; + +struct trace_event_data_offsets_ext4_request_inode {}; + +struct trace_event_data_offsets_ext4_allocate_inode {}; + +struct trace_event_data_offsets_ext4_evict_inode {}; + +struct trace_event_data_offsets_ext4_drop_inode {}; + +struct trace_event_data_offsets_ext4_nfs_commit_metadata {}; + +struct trace_event_data_offsets_ext4_mark_inode_dirty {}; + +struct trace_event_data_offsets_ext4_begin_ordered_truncate {}; + +struct trace_event_data_offsets_ext4__write_begin {}; + +struct trace_event_data_offsets_ext4__write_end {}; + +struct trace_event_data_offsets_ext4_writepages {}; + +struct trace_event_data_offsets_ext4_da_write_pages {}; + +struct trace_event_data_offsets_ext4_da_write_pages_extent {}; + +struct trace_event_data_offsets_ext4_writepages_result {}; + +struct trace_event_data_offsets_ext4__page_op {}; + +struct trace_event_data_offsets_ext4_invalidatepage_op {}; + +struct trace_event_data_offsets_ext4_discard_blocks {}; + +struct trace_event_data_offsets_ext4__mb_new_pa {}; + +struct trace_event_data_offsets_ext4_mb_release_inode_pa {}; + +struct trace_event_data_offsets_ext4_mb_release_group_pa {}; + +struct trace_event_data_offsets_ext4_discard_preallocations {}; + +struct trace_event_data_offsets_ext4_mb_discard_preallocations {}; + +struct trace_event_data_offsets_ext4_request_blocks {}; + +struct trace_event_data_offsets_ext4_allocate_blocks {}; + +struct trace_event_data_offsets_ext4_free_blocks {}; + +struct trace_event_data_offsets_ext4_sync_file_enter {}; + +struct trace_event_data_offsets_ext4_sync_file_exit {}; + +struct trace_event_data_offsets_ext4_sync_fs {}; + +struct trace_event_data_offsets_ext4_alloc_da_blocks {}; + +struct trace_event_data_offsets_ext4_mballoc_alloc {}; + +struct trace_event_data_offsets_ext4_mballoc_prealloc {}; + +struct trace_event_data_offsets_ext4__mballoc {}; + +struct trace_event_data_offsets_ext4_forget {}; + +struct trace_event_data_offsets_ext4_da_update_reserve_space {}; + +struct trace_event_data_offsets_ext4_da_reserve_space {}; + +struct trace_event_data_offsets_ext4_da_release_space {}; + +struct trace_event_data_offsets_ext4__bitmap_load {}; + +struct trace_event_data_offsets_ext4_read_block_bitmap_load {}; + +struct trace_event_data_offsets_ext4_direct_IO_enter {}; + +struct trace_event_data_offsets_ext4_direct_IO_exit {}; + +struct trace_event_data_offsets_ext4__fallocate_mode {}; + +struct trace_event_data_offsets_ext4_fallocate_exit {}; + +struct trace_event_data_offsets_ext4_unlink_enter {}; + +struct trace_event_data_offsets_ext4_unlink_exit {}; + +struct trace_event_data_offsets_ext4__truncate {}; + +struct trace_event_data_offsets_ext4_ext_convert_to_initialized_enter {}; + +struct trace_event_data_offsets_ext4_ext_convert_to_initialized_fastpath {}; + +struct trace_event_data_offsets_ext4__map_blocks_enter {}; + +struct trace_event_data_offsets_ext4__map_blocks_exit {}; + +struct trace_event_data_offsets_ext4_ext_load_extent {}; + +struct trace_event_data_offsets_ext4_load_inode {}; + +struct trace_event_data_offsets_ext4_journal_start {}; + +struct trace_event_data_offsets_ext4_journal_start_reserved {}; + +struct trace_event_data_offsets_ext4__trim {}; + +struct trace_event_data_offsets_ext4_ext_handle_unwritten_extents {}; + +struct trace_event_data_offsets_ext4_get_implied_cluster_alloc_exit {}; + +struct trace_event_data_offsets_ext4_ext_put_in_cache {}; + +struct trace_event_data_offsets_ext4_ext_in_cache {}; + +struct trace_event_data_offsets_ext4_find_delalloc_range {}; + +struct trace_event_data_offsets_ext4_get_reserved_cluster_alloc {}; + +struct trace_event_data_offsets_ext4_ext_show_extent {}; + +struct trace_event_data_offsets_ext4_remove_blocks {}; + +struct trace_event_data_offsets_ext4_ext_rm_leaf {}; + +struct trace_event_data_offsets_ext4_ext_rm_idx {}; + +struct trace_event_data_offsets_ext4_ext_remove_space {}; + +struct trace_event_data_offsets_ext4_ext_remove_space_done {}; + +struct trace_event_data_offsets_ext4__es_extent {}; + +struct trace_event_data_offsets_ext4_es_remove_extent {}; + +struct trace_event_data_offsets_ext4_es_find_extent_range_enter {}; + +struct trace_event_data_offsets_ext4_es_find_extent_range_exit {}; + +struct trace_event_data_offsets_ext4_es_lookup_extent_enter {}; + +struct trace_event_data_offsets_ext4_es_lookup_extent_exit {}; + +struct trace_event_data_offsets_ext4__es_shrink_enter {}; + +struct trace_event_data_offsets_ext4_es_shrink_scan_exit {}; + +struct trace_event_data_offsets_ext4_collapse_range {}; + +struct trace_event_data_offsets_ext4_insert_range {}; + +struct trace_event_data_offsets_ext4_es_shrink {}; + +struct trace_event_data_offsets_ext4_es_insert_delayed_block {}; + +struct trace_event_data_offsets_ext4_fsmap_class {}; + +struct trace_event_data_offsets_ext4_getfsmap_class {}; + +struct trace_event_data_offsets_ext4_shutdown {}; + +struct trace_event_data_offsets_ext4_error {}; + +struct trace_event_data_offsets_ext4_prefetch_bitmaps {}; + +struct trace_event_data_offsets_ext4_lazy_itable_init {}; + +struct trace_event_data_offsets_ext4_fc_replay_scan {}; + +struct trace_event_data_offsets_ext4_fc_replay {}; + +struct trace_event_data_offsets_ext4_fc_commit_start {}; + +struct trace_event_data_offsets_ext4_fc_commit_stop {}; + +struct trace_event_data_offsets_ext4_fc_stats {}; + +struct trace_event_data_offsets_ext4_fc_track_create {}; + +struct trace_event_data_offsets_ext4_fc_track_link {}; + +struct trace_event_data_offsets_ext4_fc_track_unlink {}; + +struct trace_event_data_offsets_ext4_fc_track_inode {}; + +struct trace_event_data_offsets_ext4_fc_track_range {}; + +typedef void (*btf_trace_ext4_other_inode_update_time)(void *, struct inode *, ino_t); + +typedef void (*btf_trace_ext4_free_inode)(void *, struct inode *); + +typedef void (*btf_trace_ext4_request_inode)(void *, struct inode *, int); + +typedef void (*btf_trace_ext4_allocate_inode)(void *, struct inode *, struct inode *, int); + +typedef void (*btf_trace_ext4_evict_inode)(void *, struct inode *); + +typedef void (*btf_trace_ext4_drop_inode)(void *, struct inode *, int); + +typedef void (*btf_trace_ext4_nfs_commit_metadata)(void *, struct inode *); + +typedef void (*btf_trace_ext4_mark_inode_dirty)(void *, struct inode *, long unsigned int); + +typedef void (*btf_trace_ext4_begin_ordered_truncate)(void *, struct inode *, loff_t); + +typedef void (*btf_trace_ext4_write_begin)(void *, struct inode *, loff_t, unsigned int, unsigned int); + +typedef void (*btf_trace_ext4_da_write_begin)(void *, struct inode *, loff_t, unsigned int, unsigned int); + +typedef void (*btf_trace_ext4_write_end)(void *, struct inode *, loff_t, unsigned int, unsigned int); + +typedef void (*btf_trace_ext4_journalled_write_end)(void *, struct inode *, loff_t, unsigned int, unsigned int); + +typedef void (*btf_trace_ext4_da_write_end)(void *, struct inode *, loff_t, unsigned int, unsigned int); + +typedef void (*btf_trace_ext4_writepages)(void *, struct inode *, struct writeback_control *); + +typedef void (*btf_trace_ext4_da_write_pages)(void *, struct inode *, long unsigned int, struct writeback_control *); + +typedef void (*btf_trace_ext4_da_write_pages_extent)(void *, struct inode *, struct ext4_map_blocks *); + +typedef void (*btf_trace_ext4_writepages_result)(void *, struct inode *, struct writeback_control *, int, int); + +typedef void (*btf_trace_ext4_writepage)(void *, struct page *); + +typedef void (*btf_trace_ext4_readpage)(void *, struct page *); + +typedef void (*btf_trace_ext4_releasepage)(void *, struct page *); + +typedef void (*btf_trace_ext4_invalidatepage)(void *, struct page *, unsigned int, unsigned int); + +typedef void (*btf_trace_ext4_journalled_invalidatepage)(void *, struct page *, unsigned int, unsigned int); + +typedef void (*btf_trace_ext4_discard_blocks)(void *, struct super_block *, long long unsigned int, long long unsigned int); + +typedef void (*btf_trace_ext4_mb_new_inode_pa)(void *, struct ext4_allocation_context *, struct ext4_prealloc_space *); + +typedef void (*btf_trace_ext4_mb_new_group_pa)(void *, struct ext4_allocation_context *, struct ext4_prealloc_space *); + +typedef void (*btf_trace_ext4_mb_release_inode_pa)(void *, struct ext4_prealloc_space *, long long unsigned int, unsigned int); + +typedef void (*btf_trace_ext4_mb_release_group_pa)(void *, struct super_block *, struct ext4_prealloc_space *); + +typedef void (*btf_trace_ext4_discard_preallocations)(void *, struct inode *, unsigned int, unsigned int); + +typedef void (*btf_trace_ext4_mb_discard_preallocations)(void *, struct super_block *, int); + +typedef void (*btf_trace_ext4_request_blocks)(void *, struct ext4_allocation_request *); + +typedef void (*btf_trace_ext4_allocate_blocks)(void *, struct ext4_allocation_request *, long long unsigned int); + +typedef void (*btf_trace_ext4_free_blocks)(void *, struct inode *, __u64, long unsigned int, int); + +typedef void (*btf_trace_ext4_sync_file_enter)(void *, struct file *, int); + +typedef void (*btf_trace_ext4_sync_file_exit)(void *, struct inode *, int); + +typedef void (*btf_trace_ext4_sync_fs)(void *, struct super_block *, int); + +typedef void (*btf_trace_ext4_alloc_da_blocks)(void *, struct inode *); + +typedef void (*btf_trace_ext4_mballoc_alloc)(void *, struct ext4_allocation_context *); + +typedef void (*btf_trace_ext4_mballoc_prealloc)(void *, struct ext4_allocation_context *); + +typedef void (*btf_trace_ext4_mballoc_discard)(void *, struct super_block *, struct inode *, ext4_group_t, ext4_grpblk_t, ext4_grpblk_t); + +typedef void (*btf_trace_ext4_mballoc_free)(void *, struct super_block *, struct inode *, ext4_group_t, ext4_grpblk_t, ext4_grpblk_t); + +typedef void (*btf_trace_ext4_forget)(void *, struct inode *, int, __u64); + +typedef void (*btf_trace_ext4_da_update_reserve_space)(void *, struct inode *, int, int); + +typedef void (*btf_trace_ext4_da_reserve_space)(void *, struct inode *); + +typedef void (*btf_trace_ext4_da_release_space)(void *, struct inode *, int); + +typedef void (*btf_trace_ext4_mb_bitmap_load)(void *, struct super_block *, long unsigned int); + +typedef void (*btf_trace_ext4_mb_buddy_bitmap_load)(void *, struct super_block *, long unsigned int); + +typedef void (*btf_trace_ext4_load_inode_bitmap)(void *, struct super_block *, long unsigned int); + +typedef void (*btf_trace_ext4_read_block_bitmap_load)(void *, struct super_block *, long unsigned int, bool); + +typedef void (*btf_trace_ext4_direct_IO_enter)(void *, struct inode *, loff_t, long unsigned int, int); + +typedef void (*btf_trace_ext4_direct_IO_exit)(void *, struct inode *, loff_t, long unsigned int, int, int); + +typedef void (*btf_trace_ext4_fallocate_enter)(void *, struct inode *, loff_t, loff_t, int); + +typedef void (*btf_trace_ext4_punch_hole)(void *, struct inode *, loff_t, loff_t, int); + +typedef void (*btf_trace_ext4_zero_range)(void *, struct inode *, loff_t, loff_t, int); + +typedef void (*btf_trace_ext4_fallocate_exit)(void *, struct inode *, loff_t, unsigned int, int); + +typedef void (*btf_trace_ext4_unlink_enter)(void *, struct inode *, struct dentry *); + +typedef void (*btf_trace_ext4_unlink_exit)(void *, struct dentry *, int); + +typedef void (*btf_trace_ext4_truncate_enter)(void *, struct inode *); + +typedef void (*btf_trace_ext4_truncate_exit)(void *, struct inode *); + +typedef void (*btf_trace_ext4_ext_convert_to_initialized_enter)(void *, struct inode *, struct ext4_map_blocks *, struct ext4_extent *); + +typedef void (*btf_trace_ext4_ext_convert_to_initialized_fastpath)(void *, struct inode *, struct ext4_map_blocks *, struct ext4_extent *, struct ext4_extent *); + +typedef void (*btf_trace_ext4_ext_map_blocks_enter)(void *, struct inode *, ext4_lblk_t, unsigned int, unsigned int); + +typedef void (*btf_trace_ext4_ind_map_blocks_enter)(void *, struct inode *, ext4_lblk_t, unsigned int, unsigned int); + +typedef void (*btf_trace_ext4_ext_map_blocks_exit)(void *, struct inode *, unsigned int, struct ext4_map_blocks *, int); + +typedef void (*btf_trace_ext4_ind_map_blocks_exit)(void *, struct inode *, unsigned int, struct ext4_map_blocks *, int); + +typedef void (*btf_trace_ext4_ext_load_extent)(void *, struct inode *, ext4_lblk_t, ext4_fsblk_t); + +typedef void (*btf_trace_ext4_load_inode)(void *, struct super_block *, long unsigned int); + +typedef void (*btf_trace_ext4_journal_start)(void *, struct super_block *, int, int, int, long unsigned int); + +typedef void (*btf_trace_ext4_journal_start_reserved)(void *, struct super_block *, int, long unsigned int); + +typedef void (*btf_trace_ext4_trim_extent)(void *, struct super_block *, ext4_group_t, ext4_grpblk_t, ext4_grpblk_t); + +typedef void (*btf_trace_ext4_trim_all_free)(void *, struct super_block *, ext4_group_t, ext4_grpblk_t, ext4_grpblk_t); + +typedef void (*btf_trace_ext4_ext_handle_unwritten_extents)(void *, struct inode *, struct ext4_map_blocks *, int, unsigned int, ext4_fsblk_t); + +typedef void (*btf_trace_ext4_get_implied_cluster_alloc_exit)(void *, struct super_block *, struct ext4_map_blocks *, int); + +typedef void (*btf_trace_ext4_ext_put_in_cache)(void *, struct inode *, ext4_lblk_t, unsigned int, ext4_fsblk_t); + +typedef void (*btf_trace_ext4_ext_in_cache)(void *, struct inode *, ext4_lblk_t, int); + +typedef void (*btf_trace_ext4_find_delalloc_range)(void *, struct inode *, ext4_lblk_t, ext4_lblk_t, int, int, ext4_lblk_t); + +typedef void (*btf_trace_ext4_get_reserved_cluster_alloc)(void *, struct inode *, ext4_lblk_t, unsigned int); + +typedef void (*btf_trace_ext4_ext_show_extent)(void *, struct inode *, ext4_lblk_t, ext4_fsblk_t, short unsigned int); + +typedef void (*btf_trace_ext4_remove_blocks)(void *, struct inode *, struct ext4_extent *, ext4_lblk_t, ext4_fsblk_t, struct partial_cluster *); + +typedef void (*btf_trace_ext4_ext_rm_leaf)(void *, struct inode *, ext4_lblk_t, struct ext4_extent *, struct partial_cluster *); + +typedef void (*btf_trace_ext4_ext_rm_idx)(void *, struct inode *, ext4_fsblk_t); + +typedef void (*btf_trace_ext4_ext_remove_space)(void *, struct inode *, ext4_lblk_t, ext4_lblk_t, int); + +typedef void (*btf_trace_ext4_ext_remove_space_done)(void *, struct inode *, ext4_lblk_t, ext4_lblk_t, int, struct partial_cluster *, __le16); + +typedef void (*btf_trace_ext4_es_insert_extent)(void *, struct inode *, struct extent_status *); + +typedef void (*btf_trace_ext4_es_cache_extent)(void *, struct inode *, struct extent_status *); + +typedef void (*btf_trace_ext4_es_remove_extent)(void *, struct inode *, ext4_lblk_t, ext4_lblk_t); + +typedef void (*btf_trace_ext4_es_find_extent_range_enter)(void *, struct inode *, ext4_lblk_t); + +typedef void (*btf_trace_ext4_es_find_extent_range_exit)(void *, struct inode *, struct extent_status *); + +typedef void (*btf_trace_ext4_es_lookup_extent_enter)(void *, struct inode *, ext4_lblk_t); + +typedef void (*btf_trace_ext4_es_lookup_extent_exit)(void *, struct inode *, struct extent_status *, int); + +typedef void (*btf_trace_ext4_es_shrink_count)(void *, struct super_block *, int, int); + +typedef void (*btf_trace_ext4_es_shrink_scan_enter)(void *, struct super_block *, int, int); + +typedef void (*btf_trace_ext4_es_shrink_scan_exit)(void *, struct super_block *, int, int); + +typedef void (*btf_trace_ext4_collapse_range)(void *, struct inode *, loff_t, loff_t); + +typedef void (*btf_trace_ext4_insert_range)(void *, struct inode *, loff_t, loff_t); + +typedef void (*btf_trace_ext4_es_shrink)(void *, struct super_block *, int, u64, int, int); + +typedef void (*btf_trace_ext4_es_insert_delayed_block)(void *, struct inode *, struct extent_status *, bool); + +typedef void (*btf_trace_ext4_fsmap_low_key)(void *, struct super_block *, u32, u32, u64, u64, u64); + +typedef void (*btf_trace_ext4_fsmap_high_key)(void *, struct super_block *, u32, u32, u64, u64, u64); + +typedef void (*btf_trace_ext4_fsmap_mapping)(void *, struct super_block *, u32, u32, u64, u64, u64); + +typedef void (*btf_trace_ext4_getfsmap_low_key)(void *, struct super_block *, struct ext4_fsmap *); + +typedef void (*btf_trace_ext4_getfsmap_high_key)(void *, struct super_block *, struct ext4_fsmap *); + +typedef void (*btf_trace_ext4_getfsmap_mapping)(void *, struct super_block *, struct ext4_fsmap *); + +typedef void (*btf_trace_ext4_shutdown)(void *, struct super_block *, long unsigned int); + +typedef void (*btf_trace_ext4_error)(void *, struct super_block *, const char *, unsigned int); + +typedef void (*btf_trace_ext4_prefetch_bitmaps)(void *, struct super_block *, ext4_group_t, ext4_group_t, unsigned int); + +typedef void (*btf_trace_ext4_lazy_itable_init)(void *, struct super_block *, ext4_group_t); + +typedef void (*btf_trace_ext4_fc_replay_scan)(void *, struct super_block *, int, int); + +typedef void (*btf_trace_ext4_fc_replay)(void *, struct super_block *, int, int, int, int); + +typedef void (*btf_trace_ext4_fc_commit_start)(void *, struct super_block *); + +typedef void (*btf_trace_ext4_fc_commit_stop)(void *, struct super_block *, int, int); + +typedef void (*btf_trace_ext4_fc_stats)(void *, struct super_block *); + +typedef void (*btf_trace_ext4_fc_track_create)(void *, struct inode *, struct dentry *, int); + +typedef void (*btf_trace_ext4_fc_track_link)(void *, struct inode *, struct dentry *, int); + +typedef void (*btf_trace_ext4_fc_track_unlink)(void *, struct inode *, struct dentry *, int); + +typedef void (*btf_trace_ext4_fc_track_inode)(void *, struct inode *, int); + +typedef void (*btf_trace_ext4_fc_track_range)(void *, struct inode *, long int, long int, int); + +enum { + Opt_bsd_df = 0, + Opt_minix_df = 1, + Opt_grpid = 2, + Opt_nogrpid = 3, + Opt_resgid = 4, + Opt_resuid = 5, + Opt_sb = 6, + Opt_err_cont = 7, + Opt_err_panic = 8, + Opt_err_ro = 9, + Opt_nouid32 = 10, + Opt_debug = 11, + Opt_removed = 12, + Opt_user_xattr = 13, + Opt_nouser_xattr = 14, + Opt_acl = 15, + Opt_noacl = 16, + Opt_auto_da_alloc = 17, + Opt_noauto_da_alloc = 18, + Opt_noload = 19, + Opt_commit = 20, + Opt_min_batch_time = 21, + Opt_max_batch_time = 22, + Opt_journal_dev = 23, + Opt_journal_path = 24, + Opt_journal_checksum = 25, + Opt_journal_async_commit = 26, + Opt_abort = 27, + Opt_data_journal = 28, + Opt_data_ordered = 29, + Opt_data_writeback = 30, + Opt_data_err_abort = 31, + Opt_data_err_ignore = 32, + Opt_test_dummy_encryption = 33, + Opt_inlinecrypt = 34, + Opt_usrjquota = 35, + Opt_grpjquota = 36, + Opt_offusrjquota = 37, + Opt_offgrpjquota = 38, + Opt_jqfmt_vfsold = 39, + Opt_jqfmt_vfsv0 = 40, + Opt_jqfmt_vfsv1 = 41, + Opt_quota = 42, + Opt_noquota = 43, + Opt_barrier = 44, + Opt_nobarrier = 45, + Opt_err___2 = 46, + Opt_usrquota = 47, + Opt_grpquota = 48, + Opt_prjquota = 49, + Opt_i_version = 50, + Opt_dax = 51, + Opt_dax_always = 52, + Opt_dax_inode = 53, + Opt_dax_never = 54, + Opt_stripe = 55, + Opt_delalloc = 56, + Opt_nodelalloc = 57, + Opt_warn_on_error = 58, + Opt_nowarn_on_error = 59, + Opt_mblk_io_submit = 60, + Opt_lazytime = 61, + Opt_nolazytime = 62, + Opt_debug_want_extra_isize = 63, + Opt_nomblk_io_submit = 64, + Opt_block_validity = 65, + Opt_noblock_validity = 66, + Opt_inode_readahead_blks = 67, + Opt_journal_ioprio = 68, + Opt_dioread_nolock = 69, + Opt_dioread_lock = 70, + Opt_discard = 71, + Opt_nodiscard = 72, + Opt_init_itable = 73, + Opt_noinit_itable = 74, + Opt_max_dir_size_kb = 75, + Opt_nojournal_checksum = 76, + Opt_nombcache = 77, + Opt_prefetch_block_bitmaps = 78, +}; + +struct mount_opts { + int token; + int mount_opt; + int flags; +}; + +struct ext4_mount_options { + long unsigned int s_mount_opt; + long unsigned int s_mount_opt2; + kuid_t s_resuid; + kgid_t s_resgid; + long unsigned int s_commit_interval; + u32 s_min_batch_time; + u32 s_max_batch_time; + int s_jquota_fmt; + char *s_qf_names[3]; +}; + +enum { + attr_noop = 0, + attr_delayed_allocation_blocks = 1, + attr_session_write_kbytes = 2, + attr_lifetime_write_kbytes = 3, + attr_reserved_clusters = 4, + attr_inode_readahead = 5, + attr_trigger_test_error = 6, + attr_first_error_time = 7, + attr_last_error_time = 8, + attr_feature = 9, + attr_pointer_ui = 10, + attr_pointer_ul = 11, + attr_pointer_u64 = 12, + attr_pointer_u8 = 13, + attr_pointer_string = 14, + attr_pointer_atomic = 15, + attr_journal_task = 16, +}; + +enum { + ptr_explicit = 0, + ptr_ext4_sb_info_offset = 1, + ptr_ext4_super_block_offset = 2, +}; + +struct ext4_attr { + struct attribute attr; + short int attr_id; + short int attr_ptr; + short unsigned int attr_size; + union { + int offset; + void *explicit_ptr; + } u; +}; + +struct ext4_xattr_header { + __le32 h_magic; + __le32 h_refcount; + __le32 h_blocks; + __le32 h_hash; + __le32 h_checksum; + __u32 h_reserved[3]; +}; + +struct ext4_xattr_block_find { + struct ext4_xattr_search s; + struct buffer_head *bh; +}; + +struct ext4_fc_tl { + __le16 fc_tag; + __le16 fc_len; +}; + +struct ext4_fc_head { + __le32 fc_features; + __le32 fc_tid; +}; + +struct ext4_fc_add_range { + __le32 fc_ino; + __u8 fc_ex[12]; +}; + +struct ext4_fc_del_range { + __le32 fc_ino; + __le32 fc_lblk; + __le32 fc_len; +}; + +struct ext4_fc_dentry_info { + __le32 fc_parent_ino; + __le32 fc_ino; + u8 fc_dname[0]; +}; + +struct ext4_fc_inode { + __le32 fc_ino; + __u8 fc_raw_inode[0]; +}; + +struct ext4_fc_tail { + __le32 fc_tid; + __le32 fc_crc; +}; + +struct ext4_fc_dentry_update { + int fcd_op; + int fcd_parent; + int fcd_ino; + struct qstr fcd_name; + unsigned char fcd_iname[32]; + struct list_head fcd_list; +}; + +struct __track_dentry_update_args { + struct dentry *dentry; + int op; +}; + +struct __track_range_args { + ext4_lblk_t start; + ext4_lblk_t end; +}; + +struct dentry_info_args { + int parent_ino; + int dname_len; + int ino; + int inode_len; + char *dname; +}; + +typedef struct { + __le16 e_tag; + __le16 e_perm; + __le32 e_id; +} ext4_acl_entry; + +typedef struct { + __le32 a_version; +} ext4_acl_header; + +struct commit_header { + __be32 h_magic; + __be32 h_blocktype; + __be32 h_sequence; + unsigned char h_chksum_type; + unsigned char h_chksum_size; + unsigned char h_padding[2]; + __be32 h_chksum[8]; + __be64 h_commit_sec; + __be32 h_commit_nsec; +}; + +struct journal_block_tag3_s { + __be32 t_blocknr; + __be32 t_flags; + __be32 t_blocknr_high; + __be32 t_checksum; +}; + +typedef struct journal_block_tag3_s journal_block_tag3_t; + +struct journal_block_tag_s { + __be32 t_blocknr; + __be16 t_checksum; + __be16 t_flags; + __be32 t_blocknr_high; +}; + +typedef struct journal_block_tag_s journal_block_tag_t; + +struct jbd2_journal_block_tail { + __be32 t_checksum; +}; + +struct jbd2_journal_revoke_header_s { + journal_header_t r_header; + __be32 r_count; +}; + +typedef struct jbd2_journal_revoke_header_s jbd2_journal_revoke_header_t; + +struct recovery_info { + tid_t start_transaction; + tid_t end_transaction; + int nr_replays; + int nr_revokes; + int nr_revoke_hits; +}; + +struct jbd2_revoke_table_s { + int hash_size; + int hash_shift; + struct list_head *hash_table; +}; + +struct jbd2_revoke_record_s { + struct list_head hash; + tid_t sequence; + long long unsigned int blocknr; +}; + +struct trace_event_raw_jbd2_checkpoint { + struct trace_entry ent; + dev_t dev; + int result; + char __data[0]; +}; + +struct trace_event_raw_jbd2_commit { + struct trace_entry ent; + dev_t dev; + char sync_commit; + int transaction; + char __data[0]; +}; + +struct trace_event_raw_jbd2_end_commit { + struct trace_entry ent; + dev_t dev; + char sync_commit; + int transaction; + int head; + char __data[0]; +}; + +struct trace_event_raw_jbd2_submit_inode_data { + struct trace_entry ent; + dev_t dev; + ino_t ino; + char __data[0]; +}; + +struct trace_event_raw_jbd2_handle_start_class { + struct trace_entry ent; + dev_t dev; + long unsigned int tid; + unsigned int type; + unsigned int line_no; + int requested_blocks; + char __data[0]; +}; + +struct trace_event_raw_jbd2_handle_extend { + struct trace_entry ent; + dev_t dev; + long unsigned int tid; + unsigned int type; + unsigned int line_no; + int buffer_credits; + int requested_blocks; + char __data[0]; +}; + +struct trace_event_raw_jbd2_handle_stats { + struct trace_entry ent; + dev_t dev; + long unsigned int tid; + unsigned int type; + unsigned int line_no; + int interval; + int sync; + int requested_blocks; + int dirtied_blocks; + char __data[0]; +}; + +struct trace_event_raw_jbd2_run_stats { + struct trace_entry ent; + dev_t dev; + long unsigned int tid; + long unsigned int wait; + long unsigned int request_delay; + long unsigned int running; + long unsigned int locked; + long unsigned int flushing; + long unsigned int logging; + __u32 handle_count; + __u32 blocks; + __u32 blocks_logged; + char __data[0]; +}; + +struct trace_event_raw_jbd2_checkpoint_stats { + struct trace_entry ent; + dev_t dev; + long unsigned int tid; + long unsigned int chp_time; + __u32 forced_to_close; + __u32 written; + __u32 dropped; + char __data[0]; +}; + +struct trace_event_raw_jbd2_update_log_tail { + struct trace_entry ent; + dev_t dev; + tid_t tail_sequence; + tid_t first_tid; + long unsigned int block_nr; + long unsigned int freed; + char __data[0]; +}; + +struct trace_event_raw_jbd2_write_superblock { + struct trace_entry ent; + dev_t dev; + int write_op; + char __data[0]; +}; + +struct trace_event_raw_jbd2_lock_buffer_stall { + struct trace_entry ent; + dev_t dev; + long unsigned int stall_ms; + char __data[0]; +}; + +struct trace_event_data_offsets_jbd2_checkpoint {}; + +struct trace_event_data_offsets_jbd2_commit {}; + +struct trace_event_data_offsets_jbd2_end_commit {}; + +struct trace_event_data_offsets_jbd2_submit_inode_data {}; + +struct trace_event_data_offsets_jbd2_handle_start_class {}; + +struct trace_event_data_offsets_jbd2_handle_extend {}; + +struct trace_event_data_offsets_jbd2_handle_stats {}; + +struct trace_event_data_offsets_jbd2_run_stats {}; + +struct trace_event_data_offsets_jbd2_checkpoint_stats {}; + +struct trace_event_data_offsets_jbd2_update_log_tail {}; + +struct trace_event_data_offsets_jbd2_write_superblock {}; + +struct trace_event_data_offsets_jbd2_lock_buffer_stall {}; + +typedef void (*btf_trace_jbd2_checkpoint)(void *, journal_t *, int); + +typedef void (*btf_trace_jbd2_start_commit)(void *, journal_t *, transaction_t *); + +typedef void (*btf_trace_jbd2_commit_locking)(void *, journal_t *, transaction_t *); + +typedef void (*btf_trace_jbd2_commit_flushing)(void *, journal_t *, transaction_t *); + +typedef void (*btf_trace_jbd2_commit_logging)(void *, journal_t *, transaction_t *); + +typedef void (*btf_trace_jbd2_drop_transaction)(void *, journal_t *, transaction_t *); + +typedef void (*btf_trace_jbd2_end_commit)(void *, journal_t *, transaction_t *); + +typedef void (*btf_trace_jbd2_submit_inode_data)(void *, struct inode *); + +typedef void (*btf_trace_jbd2_handle_start)(void *, dev_t, long unsigned int, unsigned int, unsigned int, int); + +typedef void (*btf_trace_jbd2_handle_restart)(void *, dev_t, long unsigned int, unsigned int, unsigned int, int); + +typedef void (*btf_trace_jbd2_handle_extend)(void *, dev_t, long unsigned int, unsigned int, unsigned int, int, int); + +typedef void (*btf_trace_jbd2_handle_stats)(void *, dev_t, long unsigned int, unsigned int, unsigned int, int, int, int, int); + +typedef void (*btf_trace_jbd2_run_stats)(void *, dev_t, long unsigned int, struct transaction_run_stats_s *); + +typedef void (*btf_trace_jbd2_checkpoint_stats)(void *, dev_t, long unsigned int, struct transaction_chp_stats_s *); + +typedef void (*btf_trace_jbd2_update_log_tail)(void *, journal_t *, tid_t, long unsigned int, long unsigned int); + +typedef void (*btf_trace_jbd2_write_superblock)(void *, journal_t *, int); + +typedef void (*btf_trace_jbd2_lock_buffer_stall)(void *, dev_t, long unsigned int); + +struct jbd2_stats_proc_session { + journal_t *journal; + struct transaction_stats_s *stats; + int start; + int max; +}; + +struct ramfs_mount_opts { + umode_t mode; +}; + +struct ramfs_fs_info { + struct ramfs_mount_opts mount_opts; +}; + +enum ramfs_param { + Opt_mode___3 = 0, +}; + +enum hugetlbfs_size_type { + NO_SIZE = 0, + SIZE_STD = 1, + SIZE_PERCENT = 2, +}; + +struct hugetlbfs_fs_context { + struct hstate *hstate; + long long unsigned int max_size_opt; + long long unsigned int min_size_opt; + long int max_hpages; + long int nr_inodes; + long int min_hpages; + enum hugetlbfs_size_type max_val_type; + enum hugetlbfs_size_type min_val_type; + kuid_t uid; + kgid_t gid; + umode_t mode; +}; + +enum hugetlb_param { + Opt_gid___4 = 0, + Opt_min_size = 1, + Opt_mode___4 = 2, + Opt_nr_inodes___2 = 3, + Opt_pagesize = 4, + Opt_size___2 = 5, + Opt_uid___3 = 6, +}; + +struct iso_directory_record { + __u8 length[1]; + __u8 ext_attr_length[1]; + __u8 extent[8]; + __u8 size[8]; + __u8 date[7]; + __u8 flags[1]; + __u8 file_unit_size[1]; + __u8 interleave[1]; + __u8 volume_sequence_number[4]; + __u8 name_len[1]; + char name[0]; +}; + +struct iso_inode_info { + long unsigned int i_iget5_block; + long unsigned int i_iget5_offset; + unsigned int i_first_extent; + unsigned char i_file_format; + unsigned char i_format_parm[3]; + long unsigned int i_next_section_block; + long unsigned int i_next_section_offset; + off_t i_section_size; + struct inode vfs_inode; +}; + +struct nls_table; + +struct isofs_sb_info { + long unsigned int s_ninodes; + long unsigned int s_nzones; + long unsigned int s_firstdatazone; + long unsigned int s_log_zone_size; + long unsigned int s_max_size; + int s_rock_offset; + s32 s_sbsector; + unsigned char s_joliet_level; + unsigned char s_mapping; + unsigned char s_check; + unsigned char s_session; + unsigned int s_high_sierra: 1; + unsigned int s_rock: 2; + unsigned int s_utf8: 1; + unsigned int s_cruft: 1; + unsigned int s_nocompress: 1; + unsigned int s_hide: 1; + unsigned int s_showassoc: 1; + unsigned int s_overriderockperm: 1; + unsigned int s_uid_set: 1; + unsigned int s_gid_set: 1; + umode_t s_fmode; + umode_t s_dmode; + kgid_t s_gid; + kuid_t s_uid; + struct nls_table *s_nls_iocharset; +}; + +typedef u16 wchar_t; + +struct nls_table { + const char *charset; + const char *alias; + int (*uni2char)(wchar_t, unsigned char *, int); + int (*char2uni)(const unsigned char *, int, wchar_t *); + const unsigned char *charset2lower; + const unsigned char *charset2upper; + struct module *owner; + struct nls_table *next; +}; + +struct scsi_sense_hdr { + u8 response_code; + u8 sense_key; + u8 asc; + u8 ascq; + u8 byte4; + u8 byte5; + u8 byte6; + u8 additional_length; +}; + +struct cdrom_msf0 { + __u8 minute; + __u8 second; + __u8 frame; +}; + +union cdrom_addr { + struct cdrom_msf0 msf; + int lba; +}; + +struct cdrom_tocentry { + __u8 cdte_track; + __u8 cdte_adr: 4; + __u8 cdte_ctrl: 4; + __u8 cdte_format; + union cdrom_addr cdte_addr; + __u8 cdte_datamode; +}; + +struct cdrom_multisession { + union cdrom_addr addr; + __u8 xa_flag; + __u8 addr_format; +}; + +struct cdrom_mcn { + __u8 medium_catalog_number[14]; +}; + +struct packet_command { + unsigned char cmd[12]; + unsigned char *buffer; + unsigned int buflen; + int stat; + struct scsi_sense_hdr *sshdr; + unsigned char data_direction; + int quiet; + int timeout; + void *reserved[1]; +}; + +struct cdrom_device_ops; + +struct cdrom_device_info { + const struct cdrom_device_ops *ops; + struct list_head list; + struct gendisk *disk; + void *handle; + int mask; + int speed; + int capacity; + unsigned int options: 30; + unsigned int mc_flags: 2; + unsigned int vfs_events; + unsigned int ioctl_events; + int use_count; + char name[20]; + __u8 sanyo_slot: 2; + __u8 keeplocked: 1; + __u8 reserved: 5; + int cdda_method; + __u8 last_sense; + __u8 media_written; + short unsigned int mmc3_profile; + int for_data; + int (*exit)(struct cdrom_device_info *); + int mrw_mode_page; +}; + +struct cdrom_device_ops { + int (*open)(struct cdrom_device_info *, int); + void (*release)(struct cdrom_device_info *); + int (*drive_status)(struct cdrom_device_info *, int); + unsigned int (*check_events)(struct cdrom_device_info *, unsigned int, int); + int (*tray_move)(struct cdrom_device_info *, int); + int (*lock_door)(struct cdrom_device_info *, int); + int (*select_speed)(struct cdrom_device_info *, int); + int (*select_disc)(struct cdrom_device_info *, int); + int (*get_last_session)(struct cdrom_device_info *, struct cdrom_multisession *); + int (*get_mcn)(struct cdrom_device_info *, struct cdrom_mcn *); + int (*reset)(struct cdrom_device_info *); + int (*audio_ioctl)(struct cdrom_device_info *, unsigned int, void *); + const int capability; + int (*generic_packet)(struct cdrom_device_info *, struct packet_command *); +}; + +struct iso_volume_descriptor { + __u8 type[1]; + char id[5]; + __u8 version[1]; + __u8 data[2041]; +}; + +struct iso_primary_descriptor { + __u8 type[1]; + char id[5]; + __u8 version[1]; + __u8 unused1[1]; + char system_id[32]; + char volume_id[32]; + __u8 unused2[8]; + __u8 volume_space_size[8]; + __u8 unused3[32]; + __u8 volume_set_size[4]; + __u8 volume_sequence_number[4]; + __u8 logical_block_size[4]; + __u8 path_table_size[8]; + __u8 type_l_path_table[4]; + __u8 opt_type_l_path_table[4]; + __u8 type_m_path_table[4]; + __u8 opt_type_m_path_table[4]; + __u8 root_directory_record[34]; + char volume_set_id[128]; + char publisher_id[128]; + char preparer_id[128]; + char application_id[128]; + char copyright_file_id[37]; + char abstract_file_id[37]; + char bibliographic_file_id[37]; + __u8 creation_date[17]; + __u8 modification_date[17]; + __u8 expiration_date[17]; + __u8 effective_date[17]; + __u8 file_structure_version[1]; + __u8 unused4[1]; + __u8 application_data[512]; + __u8 unused5[653]; +}; + +struct iso_supplementary_descriptor { + __u8 type[1]; + char id[5]; + __u8 version[1]; + __u8 flags[1]; + char system_id[32]; + char volume_id[32]; + __u8 unused2[8]; + __u8 volume_space_size[8]; + __u8 escape[32]; + __u8 volume_set_size[4]; + __u8 volume_sequence_number[4]; + __u8 logical_block_size[4]; + __u8 path_table_size[8]; + __u8 type_l_path_table[4]; + __u8 opt_type_l_path_table[4]; + __u8 type_m_path_table[4]; + __u8 opt_type_m_path_table[4]; + __u8 root_directory_record[34]; + char volume_set_id[128]; + char publisher_id[128]; + char preparer_id[128]; + char application_id[128]; + char copyright_file_id[37]; + char abstract_file_id[37]; + char bibliographic_file_id[37]; + __u8 creation_date[17]; + __u8 modification_date[17]; + __u8 expiration_date[17]; + __u8 effective_date[17]; + __u8 file_structure_version[1]; + __u8 unused4[1]; + __u8 application_data[512]; + __u8 unused5[653]; +}; + +struct hs_volume_descriptor { + __u8 foo[8]; + __u8 type[1]; + char id[5]; + __u8 version[1]; + __u8 data[2033]; +}; + +struct hs_primary_descriptor { + __u8 foo[8]; + __u8 type[1]; + __u8 id[5]; + __u8 version[1]; + __u8 unused1[1]; + char system_id[32]; + char volume_id[32]; + __u8 unused2[8]; + __u8 volume_space_size[8]; + __u8 unused3[32]; + __u8 volume_set_size[4]; + __u8 volume_sequence_number[4]; + __u8 logical_block_size[4]; + __u8 path_table_size[8]; + __u8 type_l_path_table[4]; + __u8 unused4[28]; + __u8 root_directory_record[34]; +}; + +enum isofs_file_format { + isofs_file_normal = 0, + isofs_file_sparse = 1, + isofs_file_compressed = 2, +}; + +struct iso9660_options { + unsigned int rock: 1; + unsigned int joliet: 1; + unsigned int cruft: 1; + unsigned int hide: 1; + unsigned int showassoc: 1; + unsigned int nocompress: 1; + unsigned int overriderockperm: 1; + unsigned int uid_set: 1; + unsigned int gid_set: 1; + unsigned int utf8: 1; + unsigned char map; + unsigned char check; + unsigned int blocksize; + umode_t fmode; + umode_t dmode; + kgid_t gid; + kuid_t uid; + char *iocharset; + s32 session; + s32 sbsector; +}; + +enum { + Opt_block = 0, + Opt_check_r = 1, + Opt_check_s = 2, + Opt_cruft = 3, + Opt_gid___5 = 4, + Opt_ignore = 5, + Opt_iocharset = 6, + Opt_map_a = 7, + Opt_map_n = 8, + Opt_map_o = 9, + Opt_mode___5 = 10, + Opt_nojoliet = 11, + Opt_norock = 12, + Opt_sb___2 = 13, + Opt_session = 14, + Opt_uid___4 = 15, + Opt_unhide = 16, + Opt_utf8 = 17, + Opt_err___3 = 18, + Opt_nocompress = 19, + Opt_hide = 20, + Opt_showassoc = 21, + Opt_dmode = 22, + Opt_overriderockperm = 23, +}; + +struct isofs_iget5_callback_data { + long unsigned int block; + long unsigned int offset; +}; + +struct SU_SP_s { + __u8 magic[2]; + __u8 skip; +}; + +struct SU_CE_s { + __u8 extent[8]; + __u8 offset[8]; + __u8 size[8]; +}; + +struct SU_ER_s { + __u8 len_id; + __u8 len_des; + __u8 len_src; + __u8 ext_ver; + __u8 data[0]; +}; + +struct RR_RR_s { + __u8 flags[1]; +}; + +struct RR_PX_s { + __u8 mode[8]; + __u8 n_links[8]; + __u8 uid[8]; + __u8 gid[8]; +}; + +struct RR_PN_s { + __u8 dev_high[8]; + __u8 dev_low[8]; +}; + +struct SL_component { + __u8 flags; + __u8 len; + __u8 text[0]; +}; + +struct RR_SL_s { + __u8 flags; + struct SL_component link; +}; + +struct RR_NM_s { + __u8 flags; + char name[0]; +}; + +struct RR_CL_s { + __u8 location[8]; +}; + +struct RR_PL_s { + __u8 location[8]; +}; + +struct stamp { + __u8 time[7]; +}; + +struct RR_TF_s { + __u8 flags; + struct stamp times[0]; +}; + +struct RR_ZF_s { + __u8 algorithm[2]; + __u8 parms[2]; + __u8 real_size[8]; +}; + +struct rock_ridge { + __u8 signature[2]; + __u8 len; + __u8 version; + union { + struct SU_SP_s SP; + struct SU_CE_s CE; + struct SU_ER_s ER; + struct RR_RR_s RR; + struct RR_PX_s PX; + struct RR_PN_s PN; + struct RR_SL_s SL; + struct RR_NM_s NM; + struct RR_CL_s CL; + struct RR_PL_s PL; + struct RR_TF_s TF; + struct RR_ZF_s ZF; + } u; +}; + +struct rock_state { + void *buffer; + unsigned char *chr; + int len; + int cont_size; + int cont_extent; + int cont_offset; + int cont_loops; + struct inode *inode; +}; + +struct isofs_fid { + u32 block; + u16 offset; + u16 parent_offset; + u32 generation; + u32 parent_block; + u32 parent_generation; +}; + +enum utf16_endian { + UTF16_HOST_ENDIAN = 0, + UTF16_LITTLE_ENDIAN = 1, + UTF16_BIG_ENDIAN = 2, +}; + +typedef unsigned char Byte; + +typedef long unsigned int uLong; + +struct internal_state; + +struct z_stream_s { + const Byte *next_in; + uLong avail_in; + uLong total_in; + Byte *next_out; + uLong avail_out; + uLong total_out; + char *msg; + struct internal_state *state; + void *workspace; + int data_type; + uLong adler; + uLong reserved; +}; + +struct internal_state { + int dummy; +}; + +typedef struct z_stream_s z_stream; + +struct in_addr { + __be32 s_addr; +}; + +struct sockaddr_in { + __kernel_sa_family_t sin_family; + __be16 sin_port; + struct in_addr sin_addr; + unsigned char __pad[8]; +}; + +struct sockaddr_in6 { + short unsigned int sin6_family; + __be16 sin6_port; + __be32 sin6_flowinfo; + struct in6_addr sin6_addr; + __u32 sin6_scope_id; +}; + +enum rpc_auth_flavors { + RPC_AUTH_NULL = 0, + RPC_AUTH_UNIX = 1, + RPC_AUTH_SHORT = 2, + RPC_AUTH_DES = 3, + RPC_AUTH_KRB = 4, + RPC_AUTH_GSS = 6, + RPC_AUTH_MAXFLAVOR = 8, + RPC_AUTH_GSS_KRB5 = 390003, + RPC_AUTH_GSS_KRB5I = 390004, + RPC_AUTH_GSS_KRB5P = 390005, + RPC_AUTH_GSS_LKEY = 390006, + RPC_AUTH_GSS_LKEYI = 390007, + RPC_AUTH_GSS_LKEYP = 390008, + RPC_AUTH_GSS_SPKM = 390009, + RPC_AUTH_GSS_SPKMI = 390010, + RPC_AUTH_GSS_SPKMP = 390011, +}; + +struct xdr_netobj { + unsigned int len; + u8 *data; +}; + +struct rpc_task_setup { + struct rpc_task *task; + struct rpc_clnt *rpc_client; + struct rpc_xprt *rpc_xprt; + struct rpc_cred *rpc_op_cred; + const struct rpc_message *rpc_message; + const struct rpc_call_ops *callback_ops; + void *callback_data; + struct workqueue_struct *workqueue; + short unsigned int flags; + signed char priority; +}; + +enum rpc_display_format_t { + RPC_DISPLAY_ADDR = 0, + RPC_DISPLAY_PORT = 1, + RPC_DISPLAY_PROTO = 2, + RPC_DISPLAY_HEX_ADDR = 3, + RPC_DISPLAY_HEX_PORT = 4, + RPC_DISPLAY_NETID = 5, + RPC_DISPLAY_MAX = 6, +}; + +enum xprt_transports { + XPRT_TRANSPORT_UDP = 17, + XPRT_TRANSPORT_TCP = 6, + XPRT_TRANSPORT_BC_TCP = 2147483654, + XPRT_TRANSPORT_RDMA = 256, + XPRT_TRANSPORT_BC_RDMA = 2147483904, + XPRT_TRANSPORT_LOCAL = 257, +}; + +struct svc_xprt_class; + +struct svc_xprt_ops; + +struct svc_serv; + +struct svc_xprt { + struct svc_xprt_class *xpt_class; + const struct svc_xprt_ops *xpt_ops; + struct kref xpt_ref; + struct list_head xpt_list; + struct list_head xpt_ready; + long unsigned int xpt_flags; + struct svc_serv *xpt_server; + atomic_t xpt_reserved; + atomic_t xpt_nr_rqsts; + struct mutex xpt_mutex; + spinlock_t xpt_lock; + void *xpt_auth_cache; + struct list_head xpt_deferred; + struct __kernel_sockaddr_storage xpt_local; + size_t xpt_locallen; + struct __kernel_sockaddr_storage xpt_remote; + size_t xpt_remotelen; + char xpt_remotebuf[58]; + struct list_head xpt_users; + struct net *xpt_net; + const struct cred *xpt_cred; + struct rpc_xprt *xpt_bc_xprt; + struct rpc_xprt_switch *xpt_bc_xps; +}; + +struct svc_program; + +struct svc_stat { + struct svc_program *program; + unsigned int netcnt; + unsigned int netudpcnt; + unsigned int nettcpcnt; + unsigned int nettcpconn; + unsigned int rpccnt; + unsigned int rpcbadfmt; + unsigned int rpcbadauth; + unsigned int rpcbadclnt; +}; + +struct svc_version; + +struct svc_rqst; + +struct svc_process_info; + +struct svc_program { + struct svc_program *pg_next; + u32 pg_prog; + unsigned int pg_lovers; + unsigned int pg_hivers; + unsigned int pg_nvers; + const struct svc_version **pg_vers; + char *pg_name; + char *pg_class; + struct svc_stat *pg_stats; + int (*pg_authenticate)(struct svc_rqst *); + __be32 (*pg_init_request)(struct svc_rqst *, const struct svc_program *, struct svc_process_info *); + int (*pg_rpcbind_set)(struct net *, const struct svc_program *, u32, int, short unsigned int, short unsigned int); +}; + +struct rpc_pipe_msg { + struct list_head list; + void *data; + size_t len; + size_t copied; + int errno; +}; + +struct rpc_pipe_ops { + ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char *, size_t); + ssize_t (*downcall)(struct file *, const char *, size_t); + void (*release_pipe)(struct inode *); + int (*open_pipe)(struct inode *); + void (*destroy_msg)(struct rpc_pipe_msg *); +}; + +struct rpc_pipe { + struct list_head pipe; + struct list_head in_upcall; + struct list_head in_downcall; + int pipelen; + int nreaders; + int nwriters; + int flags; + struct delayed_work queue_timeout; + const struct rpc_pipe_ops *ops; + spinlock_t lock; + struct dentry *dentry; +}; + +struct rpc_iostats { + spinlock_t om_lock; + long unsigned int om_ops; + long unsigned int om_ntrans; + long unsigned int om_timeouts; + long long unsigned int om_bytes_sent; + long long unsigned int om_bytes_recv; + ktime_t om_queue; + ktime_t om_rtt; + ktime_t om_execute; + long unsigned int om_error_status; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct rpc_create_args { + struct net *net; + int protocol; + struct sockaddr *address; + size_t addrsize; + struct sockaddr *saddress; + const struct rpc_timeout *timeout; + const char *servername; + const char *nodename; + const struct rpc_program *program; + u32 prognumber; + u32 version; + rpc_authflavor_t authflavor; + u32 nconnect; + long unsigned int flags; + char *client_name; + struct svc_xprt *bc_xprt; + const struct cred *cred; +}; + +struct gss_api_mech; + +struct gss_ctx { + struct gss_api_mech *mech_type; + void *internal_ctx_id; + unsigned int slack; + unsigned int align; +}; + +struct gss_api_ops; + +struct pf_desc; + +struct gss_api_mech { + struct list_head gm_list; + struct module *gm_owner; + struct rpcsec_gss_oid gm_oid; + char *gm_name; + const struct gss_api_ops *gm_ops; + int gm_pf_num; + struct pf_desc *gm_pfs; + const char *gm_upcall_enctypes; +}; + +struct auth_domain; + +struct pf_desc { + u32 pseudoflavor; + u32 qop; + u32 service; + char *name; + char *auth_domain_name; + struct auth_domain *domain; + bool datatouch; +}; + +struct auth_ops; + +struct auth_domain { + struct kref ref; + struct hlist_node hash; + char *name; + struct auth_ops *flavour; + struct callback_head callback_head; +}; + +struct gss_api_ops { + int (*gss_import_sec_context)(const void *, size_t, struct gss_ctx *, time64_t *, gfp_t); + u32 (*gss_get_mic)(struct gss_ctx *, struct xdr_buf *, struct xdr_netobj *); + u32 (*gss_verify_mic)(struct gss_ctx *, struct xdr_buf *, struct xdr_netobj *); + u32 (*gss_wrap)(struct gss_ctx *, int, struct xdr_buf *, struct page **); + u32 (*gss_unwrap)(struct gss_ctx *, int, int, struct xdr_buf *); + void (*gss_delete_sec_context)(void *); +}; + +struct pnfs_layout_range { + u32 iomode; + u64 offset; + u64 length; +}; + +struct pnfs_layout_hdr; + +struct pnfs_layout_segment { + struct list_head pls_list; + struct list_head pls_lc_list; + struct list_head pls_commits; + struct pnfs_layout_range pls_range; + refcount_t pls_refcount; + u32 pls_seq; + long unsigned int pls_flags; + struct pnfs_layout_hdr *pls_layout; +}; + +struct nfs_page { + struct list_head wb_list; + struct page *wb_page; + struct nfs_lock_context *wb_lock_context; + long unsigned int wb_index; + unsigned int wb_offset; + unsigned int wb_pgbase; + unsigned int wb_bytes; + struct kref wb_kref; + long unsigned int wb_flags; + struct nfs_write_verifier wb_verf; + struct nfs_page *wb_this_page; + struct nfs_page *wb_head; + short unsigned int wb_nio; +}; + +struct nfs_subversion { + struct module *owner; + struct file_system_type *nfs_fs; + const struct rpc_version *rpc_vers; + const struct nfs_rpc_ops *rpc_ops; + const struct super_operations *sops; + const struct xattr_handler **xattr; + struct list_head list; +}; + +struct nfs_iostats { + long long unsigned int bytes[8]; + long unsigned int events[27]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct svc_cred { + kuid_t cr_uid; + kgid_t cr_gid; + struct group_info *cr_group_info; + u32 cr_flavor; + char *cr_raw_principal; + char *cr_principal; + char *cr_targ_princ; + struct gss_api_mech *cr_gss_mech; +}; + +struct cache_deferred_req; + +struct cache_req { + struct cache_deferred_req * (*defer)(struct cache_req *); + int thread_wait; +}; + +struct svc_cacherep; + +struct svc_pool; + +struct svc_procedure; + +struct svc_deferred_req; + +struct svc_rqst { + struct list_head rq_all; + struct callback_head rq_rcu_head; + struct svc_xprt *rq_xprt; + struct __kernel_sockaddr_storage rq_addr; + size_t rq_addrlen; + struct __kernel_sockaddr_storage rq_daddr; + size_t rq_daddrlen; + struct svc_serv *rq_server; + struct svc_pool *rq_pool; + const struct svc_procedure *rq_procinfo; + struct auth_ops *rq_authop; + struct svc_cred rq_cred; + void *rq_xprt_ctxt; + struct svc_deferred_req *rq_deferred; + size_t rq_xprt_hlen; + struct xdr_buf rq_arg; + struct xdr_buf rq_res; + struct page *rq_pages[260]; + struct page **rq_respages; + struct page **rq_next_page; + struct page **rq_page_end; + struct kvec rq_vec[259]; + struct bio_vec rq_bvec[259]; + __be32 rq_xid; + u32 rq_prog; + u32 rq_vers; + u32 rq_proc; + u32 rq_prot; + int rq_cachetype; + long unsigned int rq_flags; + ktime_t rq_qtime; + void *rq_argp; + void *rq_resp; + void *rq_auth_data; + int rq_auth_slack; + int rq_reserved; + ktime_t rq_stime; + struct cache_req rq_chandle; + struct auth_domain *rq_client; + struct auth_domain *rq_gssclient; + struct svc_cacherep *rq_cacherep; + struct task_struct *rq_task; + spinlock_t rq_lock; + struct net *rq_bc_net; + void **rq_lease_breaker; +}; + +struct nlmclnt_initdata { + const char *hostname; + const struct sockaddr *address; + size_t addrlen; + short unsigned int protocol; + u32 nfs_version; + int noresvport; + struct net *net; + const struct nlmclnt_operations *nlmclnt_ops; + const struct cred *cred; +}; + +struct cache_head { + struct hlist_node cache_list; + time64_t expiry_time; + time64_t last_refresh; + struct kref ref; + long unsigned int flags; +}; + +struct cache_detail { + struct module *owner; + int hash_size; + struct hlist_head *hash_table; + spinlock_t hash_lock; + char *name; + void (*cache_put)(struct kref *); + int (*cache_upcall)(struct cache_detail *, struct cache_head *); + void (*cache_request)(struct cache_detail *, struct cache_head *, char **, int *); + int (*cache_parse)(struct cache_detail *, char *, int); + int (*cache_show)(struct seq_file *, struct cache_detail *, struct cache_head *); + void (*warn_no_listener)(struct cache_detail *, int); + struct cache_head * (*alloc)(); + void (*flush)(); + int (*match)(struct cache_head *, struct cache_head *); + void (*init)(struct cache_head *, struct cache_head *); + void (*update)(struct cache_head *, struct cache_head *); + time64_t flush_time; + struct list_head others; + time64_t nextcheck; + int entries; + struct list_head queue; + atomic_t writers; + time64_t last_close; + time64_t last_warn; + union { + struct proc_dir_entry *procfs; + struct dentry *pipefs; + }; + struct net *net; +}; + +struct cache_deferred_req { + struct hlist_node hash; + struct list_head recent; + struct cache_head *item; + void *owner; + void (*revisit)(struct cache_deferred_req *, int); +}; + +struct auth_ops { + char *name; + struct module *owner; + int flavour; + int (*accept)(struct svc_rqst *, __be32 *); + int (*release)(struct svc_rqst *); + void (*domain_release)(struct auth_domain *); + int (*set_client)(struct svc_rqst *); +}; + +struct svc_pool_stats { + atomic_long_t packets; + long unsigned int sockets_queued; + atomic_long_t threads_woken; + atomic_long_t threads_timedout; +}; + +struct svc_pool { + unsigned int sp_id; + spinlock_t sp_lock; + struct list_head sp_sockets; + unsigned int sp_nrthreads; + struct list_head sp_all_threads; + struct svc_pool_stats sp_stats; + long unsigned int sp_flags; + long: 64; + long: 64; +}; + +struct svc_serv_ops { + void (*svo_shutdown)(struct svc_serv *, struct net *); + int (*svo_function)(void *); + void (*svo_enqueue_xprt)(struct svc_xprt *); + int (*svo_setup)(struct svc_serv *, struct svc_pool *, int); + struct module *svo_module; +}; + +struct svc_serv { + struct svc_program *sv_program; + struct svc_stat *sv_stats; + spinlock_t sv_lock; + unsigned int sv_nrthreads; + unsigned int sv_maxconn; + unsigned int sv_max_payload; + unsigned int sv_max_mesg; + unsigned int sv_xdrsize; + struct list_head sv_permsocks; + struct list_head sv_tempsocks; + int sv_tmpcnt; + struct timer_list sv_temptimer; + char *sv_name; + unsigned int sv_nrpools; + struct svc_pool *sv_pools; + const struct svc_serv_ops *sv_ops; +}; + +struct svc_procedure { + __be32 (*pc_func)(struct svc_rqst *); + int (*pc_decode)(struct svc_rqst *, __be32 *); + int (*pc_encode)(struct svc_rqst *, __be32 *); + void (*pc_release)(struct svc_rqst *); + unsigned int pc_argsize; + unsigned int pc_ressize; + unsigned int pc_cachetype; + unsigned int pc_xdrressize; +}; + +struct svc_deferred_req { + u32 prot; + struct svc_xprt *xprt; + struct __kernel_sockaddr_storage addr; + size_t addrlen; + struct __kernel_sockaddr_storage daddr; + size_t daddrlen; + struct cache_deferred_req handle; + size_t xprt_hlen; + int argslen; + __be32 args[0]; +}; + +struct svc_process_info { + union { + int (*dispatch)(struct svc_rqst *, __be32 *); + struct { + unsigned int lovers; + unsigned int hivers; + } mismatch; + }; +}; + +struct svc_version { + u32 vs_vers; + u32 vs_nproc; + const struct svc_procedure *vs_proc; + unsigned int *vs_count; + u32 vs_xdrsize; + bool vs_hidden; + bool vs_rpcb_optnl; + bool vs_need_cong_ctrl; + int (*vs_dispatch)(struct svc_rqst *, __be32 *); +}; + +struct svc_xprt_ops { + struct svc_xprt * (*xpo_create)(struct svc_serv *, struct net *, struct sockaddr *, int, int); + struct svc_xprt * (*xpo_accept)(struct svc_xprt *); + int (*xpo_has_wspace)(struct svc_xprt *); + int (*xpo_recvfrom)(struct svc_rqst *); + int (*xpo_sendto)(struct svc_rqst *); + int (*xpo_read_payload)(struct svc_rqst *, unsigned int, unsigned int); + void (*xpo_release_rqst)(struct svc_rqst *); + void (*xpo_detach)(struct svc_xprt *); + void (*xpo_free)(struct svc_xprt *); + void (*xpo_secure_port)(struct svc_rqst *); + void (*xpo_kill_temp_xprt)(struct svc_xprt *); +}; + +struct svc_xprt_class { + const char *xcl_name; + struct module *xcl_owner; + const struct svc_xprt_ops *xcl_ops; + struct list_head xcl_list; + u32 xcl_max_payload; + int xcl_ident; +}; + +enum nfs_stat_bytecounters { + NFSIOS_NORMALREADBYTES = 0, + NFSIOS_NORMALWRITTENBYTES = 1, + NFSIOS_DIRECTREADBYTES = 2, + NFSIOS_DIRECTWRITTENBYTES = 3, + NFSIOS_SERVERREADBYTES = 4, + NFSIOS_SERVERWRITTENBYTES = 5, + NFSIOS_READPAGES = 6, + NFSIOS_WRITEPAGES = 7, + __NFSIOS_BYTESMAX = 8, +}; + +enum nfs_stat_eventcounters { + NFSIOS_INODEREVALIDATE = 0, + NFSIOS_DENTRYREVALIDATE = 1, + NFSIOS_DATAINVALIDATE = 2, + NFSIOS_ATTRINVALIDATE = 3, + NFSIOS_VFSOPEN = 4, + NFSIOS_VFSLOOKUP = 5, + NFSIOS_VFSACCESS = 6, + NFSIOS_VFSUPDATEPAGE = 7, + NFSIOS_VFSREADPAGE = 8, + NFSIOS_VFSREADPAGES = 9, + NFSIOS_VFSWRITEPAGE = 10, + NFSIOS_VFSWRITEPAGES = 11, + NFSIOS_VFSGETDENTS = 12, + NFSIOS_VFSSETATTR = 13, + NFSIOS_VFSFLUSH = 14, + NFSIOS_VFSFSYNC = 15, + NFSIOS_VFSLOCK = 16, + NFSIOS_VFSRELEASE = 17, + NFSIOS_CONGESTIONWAIT = 18, + NFSIOS_SETATTRTRUNC = 19, + NFSIOS_EXTENDWRITE = 20, + NFSIOS_SILLYRENAME = 21, + NFSIOS_SHORTREAD = 22, + NFSIOS_SHORTWRITE = 23, + NFSIOS_DELAY = 24, + NFSIOS_PNFS_READ = 25, + NFSIOS_PNFS_WRITE = 26, + __NFSIOS_COUNTSMAX = 27, +}; + +struct nfs_clone_mount { + struct super_block *sb; + struct dentry *dentry; + struct nfs_fattr *fattr; + unsigned int inherited_bsize; +}; + +struct nfs_fs_context { + bool internal; + bool skip_reconfig_option_check; + bool need_mount; + bool sloppy; + unsigned int flags; + unsigned int rsize; + unsigned int wsize; + unsigned int timeo; + unsigned int retrans; + unsigned int acregmin; + unsigned int acregmax; + unsigned int acdirmin; + unsigned int acdirmax; + unsigned int namlen; + unsigned int options; + unsigned int bsize; + struct nfs_auth_info auth_info; + rpc_authflavor_t selected_flavor; + char *client_address; + unsigned int version; + unsigned int minorversion; + char *fscache_uniq; + short unsigned int protofamily; + short unsigned int mountfamily; + struct { + union { + struct sockaddr address; + struct __kernel_sockaddr_storage _address; + }; + size_t addrlen; + char *hostname; + u32 version; + int port; + short unsigned int protocol; + } mount_server; + struct { + union { + struct sockaddr address; + struct __kernel_sockaddr_storage _address; + }; + size_t addrlen; + char *hostname; + char *export_path; + int port; + short unsigned int protocol; + short unsigned int nconnect; + short unsigned int export_path_len; + } nfs_server; + struct nfs_fh *mntfh; + struct nfs_server *server; + struct nfs_subversion *nfs_mod; + struct nfs_clone_mount clone_data; +}; + +struct bl_dev_msg { + int32_t status; + uint32_t major; + uint32_t minor; +}; + +struct nfs_netns_client; + +struct nfs_net { + struct cache_detail *nfs_dns_resolve; + struct rpc_pipe *bl_device_pipe; + struct bl_dev_msg bl_mount_reply; + wait_queue_head_t bl_wq; + struct mutex bl_mutex; + struct list_head nfs_client_list; + struct list_head nfs_volume_list; + struct idr cb_ident_idr; + short unsigned int nfs_callback_tcpport; + short unsigned int nfs_callback_tcpport6; + int cb_users[1]; + struct nfs_netns_client *nfs_client; + spinlock_t nfs_client_lock; + ktime_t boot_time; + struct proc_dir_entry *proc_nfsfs; +}; + +struct nfs_netns_client { + struct kobject kobject; + struct net *net; + const char *identifier; +}; + +struct nfs_open_dir_context { + struct list_head list; + const struct cred *cred; + long unsigned int attr_gencount; + __u64 dir_cookie; + __u64 dup_cookie; + signed char duped; +}; + +struct nfs4_cached_acl; + +struct nfs_delegation; + +struct nfs_inode { + __u64 fileid; + struct nfs_fh fh; + long unsigned int flags; + long unsigned int cache_validity; + long unsigned int read_cache_jiffies; + long unsigned int attrtimeo; + long unsigned int attrtimeo_timestamp; + long unsigned int attr_gencount; + long unsigned int cache_change_attribute; + struct rb_root access_cache; + struct list_head access_cache_entry_lru; + struct list_head access_cache_inode_lru; + __be32 cookieverf[2]; + atomic_long_t nrequests; + struct nfs_mds_commit_info commit_info; + struct list_head open_files; + struct rw_semaphore rmdir_sem; + struct mutex commit_mutex; + long unsigned int page_index; + struct nfs4_cached_acl *nfs4_acl; + struct list_head open_states; + struct nfs_delegation *delegation; + struct rw_semaphore rwsem; + struct pnfs_layout_hdr *layout; + __u64 write_io; + __u64 read_io; + struct inode vfs_inode; +}; + +struct nfs_delegation { + struct list_head super_list; + const struct cred *cred; + struct inode *inode; + nfs4_stateid stateid; + fmode_t type; + long unsigned int pagemod_limit; + __u64 change_attr; + long unsigned int flags; + refcount_t refcount; + spinlock_t lock; + struct callback_head rcu; +}; + +struct nfs_cache_array_entry { + u64 cookie; + u64 ino; + struct qstr string; + unsigned char d_type; +}; + +struct nfs_cache_array { + int size; + int eof_index; + u64 last_cookie; + struct nfs_cache_array_entry array[0]; +}; + +typedef struct { + struct file *file; + struct page *page; + struct dir_context *ctx; + long unsigned int page_index; + u64 *dir_cookie; + u64 last_cookie; + loff_t current_index; + loff_t prev_index; + long unsigned int dir_verifier; + long unsigned int timestamp; + long unsigned int gencount; + unsigned int cache_entry_index; + bool plus; + bool eof; +} nfs_readdir_descriptor_t; + +struct nfs_find_desc { + struct nfs_fh *fh; + struct nfs_fattr *fattr; +}; + +struct nfs4_sessionid { + unsigned char data[16]; +}; + +struct nfs4_channel_attrs { + u32 max_rqst_sz; + u32 max_resp_sz; + u32 max_resp_sz_cached; + u32 max_ops; + u32 max_reqs; +}; + +struct nfs4_slot { + struct nfs4_slot_table *table; + struct nfs4_slot *next; + long unsigned int generation; + u32 slot_nr; + u32 seq_nr; + u32 seq_nr_last_acked; + u32 seq_nr_highest_sent; + unsigned int privileged: 1; + unsigned int seq_done: 1; +}; + +struct nfs4_slot_table { + struct nfs4_session *session; + struct nfs4_slot *slots; + long unsigned int used_slots[16]; + spinlock_t slot_tbl_lock; + struct rpc_wait_queue slot_tbl_waitq; + wait_queue_head_t slot_waitq; + u32 max_slots; + u32 max_slotid; + u32 highest_used_slotid; + u32 target_highest_slotid; + u32 server_highest_slotid; + s32 d_target_highest_slotid; + s32 d2_target_highest_slotid; + long unsigned int generation; + struct completion complete; + long unsigned int slot_tbl_state; +}; + +struct nfs4_session { + struct nfs4_sessionid sess_id; + u32 flags; + long unsigned int session_state; + u32 hash_alg; + u32 ssv_len; + struct nfs4_channel_attrs fc_attrs; + struct nfs4_slot_table fc_slot_table; + struct nfs4_channel_attrs bc_attrs; + struct nfs4_slot_table bc_slot_table; + struct nfs_client *clp; +}; + +struct nfs_mount_request { + struct sockaddr *sap; + size_t salen; + char *hostname; + char *dirpath; + u32 version; + short unsigned int protocol; + struct nfs_fh *fh; + int noresvport; + unsigned int *auth_flav_len; + rpc_authflavor_t *auth_flavs; + struct net *net; +}; + +struct proc_nfs_info { + int flag; + const char *str; + const char *nostr; +}; + +enum { + NFS_IOHDR_ERROR = 0, + NFS_IOHDR_EOF = 1, + NFS_IOHDR_REDO = 2, + NFS_IOHDR_STAT = 3, + NFS_IOHDR_RESEND_PNFS = 4, + NFS_IOHDR_RESEND_MDS = 5, +}; + +struct nfs_direct_req { + struct kref kref; + struct nfs_open_context *ctx; + struct nfs_lock_context *l_ctx; + struct kiocb *iocb; + struct inode *inode; + atomic_t io_count; + spinlock_t lock; + loff_t io_start; + ssize_t count; + ssize_t max_count; + ssize_t bytes_left; + ssize_t error; + struct completion completion; + struct nfs_mds_commit_info mds_cinfo; + struct pnfs_ds_commit_info ds_cinfo; + struct work_struct work; + int flags; +}; + +enum { + PG_BUSY = 0, + PG_MAPPED = 1, + PG_CLEAN = 2, + PG_COMMIT_TO_DS = 3, + PG_INODE_REF = 4, + PG_HEADLOCK = 5, + PG_TEARDOWN = 6, + PG_UNLOCKPAGE = 7, + PG_UPTODATE = 8, + PG_WB_END = 9, + PG_REMOVE = 10, + PG_CONTENDED1 = 11, + PG_CONTENDED2 = 12, +}; + +struct nfs_pageio_descriptor; + +struct nfs_pageio_ops { + void (*pg_init)(struct nfs_pageio_descriptor *, struct nfs_page *); + size_t (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *); + int (*pg_doio)(struct nfs_pageio_descriptor *); + unsigned int (*pg_get_mirror_count)(struct nfs_pageio_descriptor *, struct nfs_page *); + void (*pg_cleanup)(struct nfs_pageio_descriptor *); +}; + +struct nfs_pgio_mirror { + struct list_head pg_list; + long unsigned int pg_bytes_written; + size_t pg_count; + size_t pg_bsize; + unsigned int pg_base; + unsigned char pg_recoalesce: 1; +}; + +struct nfs_pageio_descriptor { + struct inode *pg_inode; + const struct nfs_pageio_ops *pg_ops; + const struct nfs_rw_ops *pg_rw_ops; + int pg_ioflags; + int pg_error; + const struct rpc_call_ops *pg_rpc_callops; + const struct nfs_pgio_completion_ops *pg_completion_ops; + struct pnfs_layout_segment *pg_lseg; + struct nfs_io_completion *pg_io_completion; + struct nfs_direct_req *pg_dreq; + unsigned int pg_bsize; + u32 pg_mirror_count; + struct nfs_pgio_mirror *pg_mirrors; + struct nfs_pgio_mirror pg_mirrors_static[1]; + struct nfs_pgio_mirror *pg_mirrors_dynamic; + u32 pg_mirror_idx; + short unsigned int pg_maxretrans; + unsigned char pg_moreio: 1; +}; + +struct nfs_readdesc { + struct nfs_pageio_descriptor *pgio; + struct nfs_open_context *ctx; +}; + +struct nfs_io_completion { + void (*complete)(void *); + void *data; + struct kref refcount; +}; + +enum pnfs_try_status { + PNFS_ATTEMPTED = 0, + PNFS_NOT_ATTEMPTED = 1, + PNFS_TRY_AGAIN = 2, +}; + +enum { + MOUNTPROC_NULL = 0, + MOUNTPROC_MNT = 1, + MOUNTPROC_DUMP = 2, + MOUNTPROC_UMNT = 3, + MOUNTPROC_UMNTALL = 4, + MOUNTPROC_EXPORT = 5, +}; + +enum { + MOUNTPROC3_NULL = 0, + MOUNTPROC3_MNT = 1, + MOUNTPROC3_DUMP = 2, + MOUNTPROC3_UMNT = 3, + MOUNTPROC3_UMNTALL = 4, + MOUNTPROC3_EXPORT = 5, +}; + +enum mountstat { + MNT_OK = 0, + MNT_EPERM = 1, + MNT_ENOENT = 2, + MNT_EACCES = 13, + MNT_EINVAL = 22, +}; + +enum mountstat3 { + MNT3_OK = 0, + MNT3ERR_PERM = 1, + MNT3ERR_NOENT = 2, + MNT3ERR_IO = 5, + MNT3ERR_ACCES = 13, + MNT3ERR_NOTDIR = 20, + MNT3ERR_INVAL = 22, + MNT3ERR_NAMETOOLONG = 63, + MNT3ERR_NOTSUPP = 10004, + MNT3ERR_SERVERFAULT = 10006, +}; + +struct mountres { + int errno; + struct nfs_fh *fh; + unsigned int *auth_count; + rpc_authflavor_t *auth_flavors; +}; + +enum nfs_stat { + NFS_OK = 0, + NFSERR_PERM = 1, + NFSERR_NOENT = 2, + NFSERR_IO = 5, + NFSERR_NXIO = 6, + NFSERR_EAGAIN = 11, + NFSERR_ACCES = 13, + NFSERR_EXIST = 17, + NFSERR_XDEV = 18, + NFSERR_NODEV = 19, + NFSERR_NOTDIR = 20, + NFSERR_ISDIR = 21, + NFSERR_INVAL = 22, + NFSERR_FBIG = 27, + NFSERR_NOSPC = 28, + NFSERR_ROFS = 30, + NFSERR_MLINK = 31, + NFSERR_OPNOTSUPP = 45, + NFSERR_NAMETOOLONG = 63, + NFSERR_NOTEMPTY = 66, + NFSERR_DQUOT = 69, + NFSERR_STALE = 70, + NFSERR_REMOTE = 71, + NFSERR_WFLUSH = 99, + NFSERR_BADHANDLE = 10001, + NFSERR_NOT_SYNC = 10002, + NFSERR_BAD_COOKIE = 10003, + NFSERR_NOTSUPP = 10004, + NFSERR_TOOSMALL = 10005, + NFSERR_SERVERFAULT = 10006, + NFSERR_BADTYPE = 10007, + NFSERR_JUKEBOX = 10008, + NFSERR_SAME = 10009, + NFSERR_DENIED = 10010, + NFSERR_EXPIRED = 10011, + NFSERR_LOCKED = 10012, + NFSERR_GRACE = 10013, + NFSERR_FHEXPIRED = 10014, + NFSERR_SHARE_DENIED = 10015, + NFSERR_WRONGSEC = 10016, + NFSERR_CLID_INUSE = 10017, + NFSERR_RESOURCE = 10018, + NFSERR_MOVED = 10019, + NFSERR_NOFILEHANDLE = 10020, + NFSERR_MINOR_VERS_MISMATCH = 10021, + NFSERR_STALE_CLIENTID = 10022, + NFSERR_STALE_STATEID = 10023, + NFSERR_OLD_STATEID = 10024, + NFSERR_BAD_STATEID = 10025, + NFSERR_BAD_SEQID = 10026, + NFSERR_NOT_SAME = 10027, + NFSERR_LOCK_RANGE = 10028, + NFSERR_SYMLINK = 10029, + NFSERR_RESTOREFH = 10030, + NFSERR_LEASE_MOVED = 10031, + NFSERR_ATTRNOTSUPP = 10032, + NFSERR_NO_GRACE = 10033, + NFSERR_RECLAIM_BAD = 10034, + NFSERR_RECLAIM_CONFLICT = 10035, + NFSERR_BAD_XDR = 10036, + NFSERR_LOCKS_HELD = 10037, + NFSERR_OPENMODE = 10038, + NFSERR_BADOWNER = 10039, + NFSERR_BADCHAR = 10040, + NFSERR_BADNAME = 10041, + NFSERR_BAD_RANGE = 10042, + NFSERR_LOCK_NOTSUPP = 10043, + NFSERR_OP_ILLEGAL = 10044, + NFSERR_DEADLOCK = 10045, + NFSERR_FILE_OPEN = 10046, + NFSERR_ADMIN_REVOKED = 10047, + NFSERR_CB_PATH_DOWN = 10048, +}; + +struct trace_event_raw_nfs_inode_event { + struct trace_entry ent; + dev_t dev; + u32 fhandle; + u64 fileid; + u64 version; + char __data[0]; +}; + +struct trace_event_raw_nfs_inode_event_done { + struct trace_entry ent; + long unsigned int error; + dev_t dev; + u32 fhandle; + unsigned char type; + u64 fileid; + u64 version; + loff_t size; + long unsigned int nfsi_flags; + long unsigned int cache_validity; + char __data[0]; +}; + +struct trace_event_raw_nfs_access_exit { + struct trace_entry ent; + long unsigned int error; + dev_t dev; + u32 fhandle; + unsigned char type; + u64 fileid; + u64 version; + loff_t size; + long unsigned int nfsi_flags; + long unsigned int cache_validity; + unsigned int mask; + unsigned int permitted; + char __data[0]; +}; + +struct trace_event_raw_nfs_lookup_event { + struct trace_entry ent; + long unsigned int flags; + dev_t dev; + u64 dir; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_lookup_event_done { + struct trace_entry ent; + long unsigned int error; + long unsigned int flags; + dev_t dev; + u64 dir; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_atomic_open_enter { + struct trace_entry ent; + long unsigned int flags; + unsigned int fmode; + dev_t dev; + u64 dir; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_atomic_open_exit { + struct trace_entry ent; + long unsigned int error; + long unsigned int flags; + unsigned int fmode; + dev_t dev; + u64 dir; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_create_enter { + struct trace_entry ent; + long unsigned int flags; + dev_t dev; + u64 dir; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_create_exit { + struct trace_entry ent; + long unsigned int error; + long unsigned int flags; + dev_t dev; + u64 dir; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_directory_event { + struct trace_entry ent; + dev_t dev; + u64 dir; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_directory_event_done { + struct trace_entry ent; + long unsigned int error; + dev_t dev; + u64 dir; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_link_enter { + struct trace_entry ent; + dev_t dev; + u64 fileid; + u64 dir; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_link_exit { + struct trace_entry ent; + long unsigned int error; + dev_t dev; + u64 fileid; + u64 dir; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_rename_event { + struct trace_entry ent; + dev_t dev; + u64 old_dir; + u64 new_dir; + u32 __data_loc_old_name; + u32 __data_loc_new_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_rename_event_done { + struct trace_entry ent; + dev_t dev; + long unsigned int error; + u64 old_dir; + u32 __data_loc_old_name; + u64 new_dir; + u32 __data_loc_new_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_sillyrename_unlink { + struct trace_entry ent; + dev_t dev; + long unsigned int error; + u64 dir; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_nfs_initiate_read { + struct trace_entry ent; + dev_t dev; + u32 fhandle; + u64 fileid; + loff_t offset; + u32 count; + char __data[0]; +}; + +struct trace_event_raw_nfs_readpage_done { + struct trace_entry ent; + dev_t dev; + u32 fhandle; + u64 fileid; + loff_t offset; + u32 arg_count; + u32 res_count; + bool eof; + int status; + char __data[0]; +}; + +struct trace_event_raw_nfs_readpage_short { + struct trace_entry ent; + dev_t dev; + u32 fhandle; + u64 fileid; + loff_t offset; + u32 arg_count; + u32 res_count; + bool eof; + int status; + char __data[0]; +}; + +struct trace_event_raw_nfs_pgio_error { + struct trace_entry ent; + dev_t dev; + u32 fhandle; + u64 fileid; + loff_t offset; + u32 arg_count; + u32 res_count; + loff_t pos; + int status; + char __data[0]; +}; + +struct trace_event_raw_nfs_initiate_write { + struct trace_entry ent; + dev_t dev; + u32 fhandle; + u64 fileid; + loff_t offset; + u32 count; + enum nfs3_stable_how stable; + char __data[0]; +}; + +struct trace_event_raw_nfs_writeback_done { + struct trace_entry ent; + dev_t dev; + u32 fhandle; + u64 fileid; + loff_t offset; + u32 arg_count; + u32 res_count; + int status; + enum nfs3_stable_how stable; + char verifier[8]; + char __data[0]; +}; + +struct trace_event_raw_nfs_page_error_class { + struct trace_entry ent; + const void *req; + long unsigned int index; + unsigned int offset; + unsigned int pgbase; + unsigned int bytes; + int error; + char __data[0]; +}; + +struct trace_event_raw_nfs_initiate_commit { + struct trace_entry ent; + dev_t dev; + u32 fhandle; + u64 fileid; + loff_t offset; + u32 count; + char __data[0]; +}; + +struct trace_event_raw_nfs_commit_done { + struct trace_entry ent; + dev_t dev; + u32 fhandle; + u64 fileid; + loff_t offset; + int status; + enum nfs3_stable_how stable; + char verifier[8]; + char __data[0]; +}; + +struct trace_event_raw_nfs_fh_to_dentry { + struct trace_entry ent; + int error; + dev_t dev; + u32 fhandle; + u64 fileid; + char __data[0]; +}; + +struct trace_event_raw_nfs_xdr_status { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + u32 xid; + int version; + long unsigned int error; + u32 __data_loc_program; + u32 __data_loc_procedure; + char __data[0]; +}; + +struct trace_event_data_offsets_nfs_inode_event {}; + +struct trace_event_data_offsets_nfs_inode_event_done {}; + +struct trace_event_data_offsets_nfs_access_exit {}; + +struct trace_event_data_offsets_nfs_lookup_event { + u32 name; +}; + +struct trace_event_data_offsets_nfs_lookup_event_done { + u32 name; +}; + +struct trace_event_data_offsets_nfs_atomic_open_enter { + u32 name; +}; + +struct trace_event_data_offsets_nfs_atomic_open_exit { + u32 name; +}; + +struct trace_event_data_offsets_nfs_create_enter { + u32 name; +}; + +struct trace_event_data_offsets_nfs_create_exit { + u32 name; +}; + +struct trace_event_data_offsets_nfs_directory_event { + u32 name; +}; + +struct trace_event_data_offsets_nfs_directory_event_done { + u32 name; +}; + +struct trace_event_data_offsets_nfs_link_enter { + u32 name; +}; + +struct trace_event_data_offsets_nfs_link_exit { + u32 name; +}; + +struct trace_event_data_offsets_nfs_rename_event { + u32 old_name; + u32 new_name; +}; + +struct trace_event_data_offsets_nfs_rename_event_done { + u32 old_name; + u32 new_name; +}; + +struct trace_event_data_offsets_nfs_sillyrename_unlink { + u32 name; +}; + +struct trace_event_data_offsets_nfs_initiate_read {}; + +struct trace_event_data_offsets_nfs_readpage_done {}; + +struct trace_event_data_offsets_nfs_readpage_short {}; + +struct trace_event_data_offsets_nfs_pgio_error {}; + +struct trace_event_data_offsets_nfs_initiate_write {}; + +struct trace_event_data_offsets_nfs_writeback_done {}; + +struct trace_event_data_offsets_nfs_page_error_class {}; + +struct trace_event_data_offsets_nfs_initiate_commit {}; + +struct trace_event_data_offsets_nfs_commit_done {}; + +struct trace_event_data_offsets_nfs_fh_to_dentry {}; + +struct trace_event_data_offsets_nfs_xdr_status { + u32 program; + u32 procedure; +}; + +typedef void (*btf_trace_nfs_set_inode_stale)(void *, const struct inode *); + +typedef void (*btf_trace_nfs_refresh_inode_enter)(void *, const struct inode *); + +typedef void (*btf_trace_nfs_refresh_inode_exit)(void *, const struct inode *, int); + +typedef void (*btf_trace_nfs_revalidate_inode_enter)(void *, const struct inode *); + +typedef void (*btf_trace_nfs_revalidate_inode_exit)(void *, const struct inode *, int); + +typedef void (*btf_trace_nfs_invalidate_mapping_enter)(void *, const struct inode *); + +typedef void (*btf_trace_nfs_invalidate_mapping_exit)(void *, const struct inode *, int); + +typedef void (*btf_trace_nfs_getattr_enter)(void *, const struct inode *); + +typedef void (*btf_trace_nfs_getattr_exit)(void *, const struct inode *, int); + +typedef void (*btf_trace_nfs_setattr_enter)(void *, const struct inode *); + +typedef void (*btf_trace_nfs_setattr_exit)(void *, const struct inode *, int); + +typedef void (*btf_trace_nfs_writeback_page_enter)(void *, const struct inode *); + +typedef void (*btf_trace_nfs_writeback_page_exit)(void *, const struct inode *, int); + +typedef void (*btf_trace_nfs_writeback_inode_enter)(void *, const struct inode *); + +typedef void (*btf_trace_nfs_writeback_inode_exit)(void *, const struct inode *, int); + +typedef void (*btf_trace_nfs_fsync_enter)(void *, const struct inode *); + +typedef void (*btf_trace_nfs_fsync_exit)(void *, const struct inode *, int); + +typedef void (*btf_trace_nfs_access_enter)(void *, const struct inode *); + +typedef void (*btf_trace_nfs_access_exit)(void *, const struct inode *, unsigned int, unsigned int, int); + +typedef void (*btf_trace_nfs_lookup_enter)(void *, const struct inode *, const struct dentry *, unsigned int); + +typedef void (*btf_trace_nfs_lookup_exit)(void *, const struct inode *, const struct dentry *, unsigned int, int); + +typedef void (*btf_trace_nfs_lookup_revalidate_enter)(void *, const struct inode *, const struct dentry *, unsigned int); + +typedef void (*btf_trace_nfs_lookup_revalidate_exit)(void *, const struct inode *, const struct dentry *, unsigned int, int); + +typedef void (*btf_trace_nfs_atomic_open_enter)(void *, const struct inode *, const struct nfs_open_context *, unsigned int); + +typedef void (*btf_trace_nfs_atomic_open_exit)(void *, const struct inode *, const struct nfs_open_context *, unsigned int, int); + +typedef void (*btf_trace_nfs_create_enter)(void *, const struct inode *, const struct dentry *, unsigned int); + +typedef void (*btf_trace_nfs_create_exit)(void *, const struct inode *, const struct dentry *, unsigned int, int); + +typedef void (*btf_trace_nfs_mknod_enter)(void *, const struct inode *, const struct dentry *); + +typedef void (*btf_trace_nfs_mknod_exit)(void *, const struct inode *, const struct dentry *, int); + +typedef void (*btf_trace_nfs_mkdir_enter)(void *, const struct inode *, const struct dentry *); + +typedef void (*btf_trace_nfs_mkdir_exit)(void *, const struct inode *, const struct dentry *, int); + +typedef void (*btf_trace_nfs_rmdir_enter)(void *, const struct inode *, const struct dentry *); + +typedef void (*btf_trace_nfs_rmdir_exit)(void *, const struct inode *, const struct dentry *, int); + +typedef void (*btf_trace_nfs_remove_enter)(void *, const struct inode *, const struct dentry *); + +typedef void (*btf_trace_nfs_remove_exit)(void *, const struct inode *, const struct dentry *, int); + +typedef void (*btf_trace_nfs_unlink_enter)(void *, const struct inode *, const struct dentry *); + +typedef void (*btf_trace_nfs_unlink_exit)(void *, const struct inode *, const struct dentry *, int); + +typedef void (*btf_trace_nfs_symlink_enter)(void *, const struct inode *, const struct dentry *); + +typedef void (*btf_trace_nfs_symlink_exit)(void *, const struct inode *, const struct dentry *, int); + +typedef void (*btf_trace_nfs_link_enter)(void *, const struct inode *, const struct inode *, const struct dentry *); + +typedef void (*btf_trace_nfs_link_exit)(void *, const struct inode *, const struct inode *, const struct dentry *, int); + +typedef void (*btf_trace_nfs_rename_enter)(void *, const struct inode *, const struct dentry *, const struct inode *, const struct dentry *); + +typedef void (*btf_trace_nfs_rename_exit)(void *, const struct inode *, const struct dentry *, const struct inode *, const struct dentry *, int); + +typedef void (*btf_trace_nfs_sillyrename_rename)(void *, const struct inode *, const struct dentry *, const struct inode *, const struct dentry *, int); + +typedef void (*btf_trace_nfs_sillyrename_unlink)(void *, const struct nfs_unlinkdata *, int); + +typedef void (*btf_trace_nfs_initiate_read)(void *, const struct nfs_pgio_header *); + +typedef void (*btf_trace_nfs_readpage_done)(void *, const struct rpc_task *, const struct nfs_pgio_header *); + +typedef void (*btf_trace_nfs_readpage_short)(void *, const struct rpc_task *, const struct nfs_pgio_header *); + +typedef void (*btf_trace_nfs_pgio_error)(void *, const struct nfs_pgio_header *, int, loff_t); + +typedef void (*btf_trace_nfs_initiate_write)(void *, const struct nfs_pgio_header *); + +typedef void (*btf_trace_nfs_writeback_done)(void *, const struct rpc_task *, const struct nfs_pgio_header *); + +typedef void (*btf_trace_nfs_write_error)(void *, const struct nfs_page *, int); + +typedef void (*btf_trace_nfs_comp_error)(void *, const struct nfs_page *, int); + +typedef void (*btf_trace_nfs_commit_error)(void *, const struct nfs_page *, int); + +typedef void (*btf_trace_nfs_initiate_commit)(void *, const struct nfs_commit_data *); + +typedef void (*btf_trace_nfs_commit_done)(void *, const struct rpc_task *, const struct nfs_commit_data *); + +typedef void (*btf_trace_nfs_fh_to_dentry)(void *, const struct super_block *, const struct nfs_fh *, u64, int); + +typedef void (*btf_trace_nfs_xdr_status)(void *, const struct xdr_stream *, int); + +enum { + FILEID_HIGH_OFF = 0, + FILEID_LOW_OFF = 1, + FILE_I_TYPE_OFF = 2, + EMBED_FH_OFF = 3, +}; + +struct nfs2_fh { + char data[32]; +}; + +struct nfs3_fh { + short unsigned int size; + unsigned char data[64]; +}; + +struct nfs_mount_data { + int version; + int fd; + struct nfs2_fh old_root; + int flags; + int rsize; + int wsize; + int timeo; + int retrans; + int acregmin; + int acregmax; + int acdirmin; + int acdirmax; + struct sockaddr_in addr; + char hostname[256]; + int namlen; + unsigned int bsize; + struct nfs3_fh root; + int pseudoflavor; + char context[257]; +}; + +struct nfs_string { + unsigned int len; + const char *data; +}; + +struct nfs4_mount_data { + int version; + int flags; + int rsize; + int wsize; + int timeo; + int retrans; + int acregmin; + int acregmax; + int acdirmin; + int acdirmax; + struct nfs_string client_addr; + struct nfs_string mnt_path; + struct nfs_string hostname; + unsigned int host_addrlen; + struct sockaddr *host_addr; + int proto; + int auth_flavourlen; + int *auth_flavours; +}; + +enum nfs_param { + Opt_ac = 0, + Opt_acdirmax = 1, + Opt_acdirmin = 2, + Opt_acl___2 = 3, + Opt_acregmax = 4, + Opt_acregmin = 5, + Opt_actimeo = 6, + Opt_addr = 7, + Opt_bg = 8, + Opt_bsize = 9, + Opt_clientaddr = 10, + Opt_cto = 11, + Opt_fg = 12, + Opt_fscache = 13, + Opt_fscache_flag = 14, + Opt_hard = 15, + Opt_intr = 16, + Opt_local_lock = 17, + Opt_lock = 18, + Opt_lookupcache = 19, + Opt_migration = 20, + Opt_minorversion = 21, + Opt_mountaddr = 22, + Opt_mounthost = 23, + Opt_mountport = 24, + Opt_mountproto = 25, + Opt_mountvers = 26, + Opt_namelen = 27, + Opt_nconnect = 28, + Opt_port = 29, + Opt_posix = 30, + Opt_proto = 31, + Opt_rdirplus = 32, + Opt_rdma = 33, + Opt_resvport = 34, + Opt_retrans = 35, + Opt_retry = 36, + Opt_rsize = 37, + Opt_sec = 38, + Opt_sharecache = 39, + Opt_sloppy = 40, + Opt_soft = 41, + Opt_softerr = 42, + Opt_softreval = 43, + Opt_source = 44, + Opt_tcp = 45, + Opt_timeo = 46, + Opt_udp = 47, + Opt_v = 48, + Opt_vers = 49, + Opt_wsize = 50, +}; + +enum { + Opt_local_lock_all = 0, + Opt_local_lock_flock = 1, + Opt_local_lock_none = 2, + Opt_local_lock_posix = 3, +}; + +enum { + Opt_lookupcache_all = 0, + Opt_lookupcache_none = 1, + Opt_lookupcache_positive = 2, +}; + +enum { + Opt_vers_2 = 0, + Opt_vers_3 = 1, + Opt_vers_4 = 2, + Opt_vers_4_0 = 3, + Opt_vers_4_1 = 4, + Opt_vers_4_2 = 5, +}; + +enum { + Opt_xprt_rdma = 0, + Opt_xprt_rdma6 = 1, + Opt_xprt_tcp = 2, + Opt_xprt_tcp6 = 3, + Opt_xprt_udp = 4, + Opt_xprt_udp6 = 5, + nr__Opt_xprt = 6, +}; + +enum { + Opt_sec_krb5 = 0, + Opt_sec_krb5i = 1, + Opt_sec_krb5p = 2, + Opt_sec_lkey = 3, + Opt_sec_lkeyi = 4, + Opt_sec_lkeyp = 5, + Opt_sec_none = 6, + Opt_sec_spkm = 7, + Opt_sec_spkmi = 8, + Opt_sec_spkmp = 9, + Opt_sec_sys = 10, + nr__Opt_sec = 11, +}; + +struct compat_nfs_string { + compat_uint_t len; + compat_uptr_t data; +}; + +struct compat_nfs4_mount_data_v1 { + compat_int_t version; + compat_int_t flags; + compat_int_t rsize; + compat_int_t wsize; + compat_int_t timeo; + compat_int_t retrans; + compat_int_t acregmin; + compat_int_t acregmax; + compat_int_t acdirmin; + compat_int_t acdirmax; + struct compat_nfs_string client_addr; + struct compat_nfs_string mnt_path; + struct compat_nfs_string hostname; + compat_uint_t host_addrlen; + compat_uptr_t host_addr; + compat_int_t proto; + compat_int_t auth_flavourlen; + compat_uptr_t auth_flavours; +}; + +enum nfs3_createmode { + NFS3_CREATE_UNCHECKED = 0, + NFS3_CREATE_GUARDED = 1, + NFS3_CREATE_EXCLUSIVE = 2, +}; + +enum nfs3_ftype { + NF3NON = 0, + NF3REG = 1, + NF3DIR = 2, + NF3BLK = 3, + NF3CHR = 4, + NF3LNK = 5, + NF3SOCK = 6, + NF3FIFO = 7, + NF3BAD = 8, +}; + +struct nfs3_sattrargs { + struct nfs_fh *fh; + struct iattr *sattr; + unsigned int guard; + struct timespec64 guardtime; +}; + +struct nfs3_diropargs { + struct nfs_fh *fh; + const char *name; + unsigned int len; +}; + +struct nfs3_accessargs { + struct nfs_fh *fh; + __u32 access; +}; + +struct nfs3_createargs { + struct nfs_fh *fh; + const char *name; + unsigned int len; + struct iattr *sattr; + enum nfs3_createmode createmode; + __be32 verifier[2]; +}; + +struct nfs3_mkdirargs { + struct nfs_fh *fh; + const char *name; + unsigned int len; + struct iattr *sattr; +}; + +struct nfs3_symlinkargs { + struct nfs_fh *fromfh; + const char *fromname; + unsigned int fromlen; + struct page **pages; + unsigned int pathlen; + struct iattr *sattr; +}; + +struct nfs3_mknodargs { + struct nfs_fh *fh; + const char *name; + unsigned int len; + enum nfs3_ftype type; + struct iattr *sattr; + dev_t rdev; +}; + +struct nfs3_linkargs { + struct nfs_fh *fromfh; + struct nfs_fh *tofh; + const char *toname; + unsigned int tolen; +}; + +struct nfs3_readdirargs { + struct nfs_fh *fh; + __u64 cookie; + __be32 verf[2]; + bool plus; + unsigned int count; + struct page **pages; +}; + +struct nfs3_diropres { + struct nfs_fattr *dir_attr; + struct nfs_fh *fh; + struct nfs_fattr *fattr; +}; + +struct nfs3_accessres { + struct nfs_fattr *fattr; + __u32 access; +}; + +struct nfs3_readlinkargs { + struct nfs_fh *fh; + unsigned int pgbase; + unsigned int pglen; + struct page **pages; +}; + +struct nfs3_linkres { + struct nfs_fattr *dir_attr; + struct nfs_fattr *fattr; +}; + +struct nfs3_readdirres { + struct nfs_fattr *dir_attr; + __be32 *verf; + bool plus; +}; + +struct nfs3_createdata { + struct rpc_message msg; + union { + struct nfs3_createargs create; + struct nfs3_mkdirargs mkdir; + struct nfs3_symlinkargs symlink; + struct nfs3_mknodargs mknod; + } arg; + struct nfs3_diropres res; + struct nfs_fh fh; + struct nfs_fattr fattr; + struct nfs_fattr dir_attr; +}; + +struct nfs3_getaclargs { + struct nfs_fh *fh; + int mask; + struct page **pages; +}; + +struct nfs3_setaclargs { + struct inode *inode; + int mask; + struct posix_acl *acl_access; + struct posix_acl *acl_default; + size_t len; + unsigned int npages; + struct page **pages; +}; + +struct nfs3_getaclres { + struct nfs_fattr *fattr; + int mask; + unsigned int acl_access_count; + unsigned int acl_default_count; + struct posix_acl *acl_access; + struct posix_acl *acl_default; +}; + +struct getdents_callback___2 { + struct dir_context ctx; + char *name; + u64 ino; + int found; + int sequence; +}; + +struct nlm_host___2; + +struct nlm_lockowner { + struct list_head list; + refcount_t count; + struct nlm_host___2 *host; + fl_owner_t owner; + uint32_t pid; +}; + +struct nsm_handle; + +struct nlm_host___2 { + struct hlist_node h_hash; + struct __kernel_sockaddr_storage h_addr; + size_t h_addrlen; + struct __kernel_sockaddr_storage h_srcaddr; + size_t h_srcaddrlen; + struct rpc_clnt *h_rpcclnt; + char *h_name; + u32 h_version; + short unsigned int h_proto; + short unsigned int h_reclaiming: 1; + short unsigned int h_server: 1; + short unsigned int h_noresvport: 1; + short unsigned int h_inuse: 1; + wait_queue_head_t h_gracewait; + struct rw_semaphore h_rwsem; + u32 h_state; + u32 h_nsmstate; + u32 h_pidcount; + refcount_t h_count; + struct mutex h_mutex; + long unsigned int h_nextrebind; + long unsigned int h_expires; + struct list_head h_lockowners; + spinlock_t h_lock; + struct list_head h_granted; + struct list_head h_reclaim; + struct nsm_handle *h_nsmhandle; + char *h_addrbuf; + struct net *net; + const struct cred *h_cred; + char nodename[65]; + const struct nlmclnt_operations *h_nlmclnt_ops; +}; + +enum { + NLM_LCK_GRANTED = 0, + NLM_LCK_DENIED = 1, + NLM_LCK_DENIED_NOLOCKS = 2, + NLM_LCK_BLOCKED = 3, + NLM_LCK_DENIED_GRACE_PERIOD = 4, + NLM_DEADLCK = 5, + NLM_ROFS = 6, + NLM_STALE_FH = 7, + NLM_FBIG = 8, + NLM_FAILED = 9, +}; + +struct nsm_private { + unsigned char data[16]; +}; + +struct nlm_lock { + char *caller; + unsigned int len; + struct nfs_fh fh; + struct xdr_netobj oh; + u32 svid; + struct file_lock fl; +}; + +struct nlm_cookie { + unsigned char data[32]; + unsigned int len; +}; + +struct nlm_args { + struct nlm_cookie cookie; + struct nlm_lock lock; + u32 block; + u32 reclaim; + u32 state; + u32 monitor; + u32 fsm_access; + u32 fsm_mode; +}; + +struct nlm_res { + struct nlm_cookie cookie; + __be32 status; + struct nlm_lock lock; +}; + +struct nsm_handle { + struct list_head sm_link; + refcount_t sm_count; + char *sm_mon_name; + char *sm_name; + struct __kernel_sockaddr_storage sm_addr; + size_t sm_addrlen; + unsigned int sm_monitored: 1; + unsigned int sm_sticky: 1; + struct nsm_private sm_priv; + char sm_addrbuf[51]; +}; + +struct nlm_block; + +struct nlm_rqst { + refcount_t a_count; + unsigned int a_flags; + struct nlm_host___2 *a_host; + struct nlm_args a_args; + struct nlm_res a_res; + struct nlm_block *a_block; + unsigned int a_retries; + u8 a_owner[74]; + void *a_callback_data; +}; + +struct nlm_file; + +struct nlm_block { + struct kref b_count; + struct list_head b_list; + struct list_head b_flist; + struct nlm_rqst *b_call; + struct svc_serv *b_daemon; + struct nlm_host___2 *b_host; + long unsigned int b_when; + unsigned int b_id; + unsigned char b_granted; + struct nlm_file *b_file; + struct cache_req *b_cache_req; + struct cache_deferred_req *b_deferred_req; + unsigned int b_flags; +}; + +struct nlm_share; + +struct nlm_file { + struct hlist_node f_list; + struct nfs_fh f_handle; + struct file *f_file; + struct nlm_share *f_shares; + struct list_head f_blocks; + unsigned int f_locks; + unsigned int f_count; + struct mutex f_mutex; +}; + +struct nlm_wait { + struct list_head b_list; + wait_queue_head_t b_wait; + struct nlm_host___2 *b_host; + struct file_lock *b_lock; + short unsigned int b_reclaim; + __be32 b_status; +}; + +struct nlm_wait___2; + +struct nlm_reboot { + char *mon; + unsigned int len; + u32 state; + struct nsm_private priv; +}; + +struct lockd_net { + unsigned int nlmsvc_users; + long unsigned int next_gc; + long unsigned int nrhosts; + struct delayed_work grace_period_end; + struct lock_manager lockd_manager; + struct list_head nsm_handles; +}; + +struct nlm_lookup_host_info { + const int server; + const struct sockaddr *sap; + const size_t salen; + const short unsigned int protocol; + const u32 version; + const char *hostname; + const size_t hostname_len; + const int noresvport; + struct net *net; + const struct cred *cred; +}; + +struct ipv4_devconf { + void *sysctl; + int data[32]; + long unsigned int state[1]; +}; + +struct in_ifaddr; + +struct ip_mc_list; + +struct in_device { + struct net_device *dev; + refcount_t refcnt; + int dead; + struct in_ifaddr *ifa_list; + struct ip_mc_list *mc_list; + struct ip_mc_list **mc_hash; + int mc_count; + spinlock_t mc_tomb_lock; + struct ip_mc_list *mc_tomb; + long unsigned int mr_v1_seen; + long unsigned int mr_v2_seen; + long unsigned int mr_maxdelay; + long unsigned int mr_qi; + long unsigned int mr_qri; + unsigned char mr_qrv; + unsigned char mr_gq_running; + unsigned char mr_ifc_count; + struct timer_list mr_gq_timer; + struct timer_list mr_ifc_timer; + struct neigh_parms *arp_parms; + struct ipv4_devconf cnf; + struct callback_head callback_head; +}; + +struct in_ifaddr { + struct hlist_node hash; + struct in_ifaddr *ifa_next; + struct in_device *ifa_dev; + struct callback_head callback_head; + __be32 ifa_local; + __be32 ifa_address; + __be32 ifa_mask; + __u32 ifa_rt_priority; + __be32 ifa_broadcast; + unsigned char ifa_scope; + unsigned char ifa_prefixlen; + __u32 ifa_flags; + char ifa_label[16]; + __u32 ifa_valid_lft; + __u32 ifa_preferred_lft; + long unsigned int ifa_cstamp; + long unsigned int ifa_tstamp; +}; + +struct inet6_ifaddr { + struct in6_addr addr; + __u32 prefix_len; + __u32 rt_priority; + __u32 valid_lft; + __u32 prefered_lft; + refcount_t refcnt; + spinlock_t lock; + int state; + __u32 flags; + __u8 dad_probes; + __u8 stable_privacy_retry; + __u16 scope; + __u64 dad_nonce; + long unsigned int cstamp; + long unsigned int tstamp; + struct delayed_work dad_work; + struct inet6_dev *idev; + struct fib6_info *rt; + struct hlist_node addr_lst; + struct list_head if_list; + struct list_head tmp_list; + struct inet6_ifaddr *ifpub; + int regen_count; + bool tokenized; + struct callback_head rcu; + struct in6_addr peer_addr; +}; + +struct nlmsvc_binding { + __be32 (*fopen)(struct svc_rqst *, struct nfs_fh *, struct file **); + void (*fclose)(struct file *); +}; + +typedef int (*nlm_host_match_fn_t)(void *, struct nlm_host___2 *); + +struct nlm_share { + struct nlm_share *s_next; + struct nlm_host___2 *s_host; + struct nlm_file *s_file; + struct xdr_netobj s_owner; + u32 s_access; + u32 s_mode; +}; + +enum rpc_accept_stat { + RPC_SUCCESS = 0, + RPC_PROG_UNAVAIL = 1, + RPC_PROG_MISMATCH = 2, + RPC_PROC_UNAVAIL = 3, + RPC_GARBAGE_ARGS = 4, + RPC_SYSTEM_ERR = 5, + RPC_DROP_REPLY = 60000, +}; + +enum { + NSMPROC_NULL = 0, + NSMPROC_STAT = 1, + NSMPROC_MON = 2, + NSMPROC_UNMON = 3, + NSMPROC_UNMON_ALL = 4, + NSMPROC_SIMU_CRASH = 5, + NSMPROC_NOTIFY = 6, +}; + +struct nsm_args { + struct nsm_private *priv; + u32 prog; + u32 vers; + u32 proc; + char *mon_name; + const char *nodename; +}; + +struct nsm_res { + u32 status; + u32 state; +}; + +typedef u32 unicode_t; + +struct utf8_table { + int cmask; + int cval; + int shift; + long int lmask; + long int lval; +}; + +typedef unsigned int autofs_wqt_t; + +struct autofs_sb_info; + +struct autofs_info { + struct dentry *dentry; + struct inode *inode; + int flags; + struct completion expire_complete; + struct list_head active; + struct list_head expiring; + struct autofs_sb_info *sbi; + long unsigned int last_used; + int count; + kuid_t uid; + kgid_t gid; + struct callback_head rcu; +}; + +struct autofs_wait_queue; + +struct autofs_sb_info { + u32 magic; + int pipefd; + struct file *pipe; + struct pid *oz_pgrp; + int version; + int sub_version; + int min_proto; + int max_proto; + unsigned int flags; + long unsigned int exp_timeout; + unsigned int type; + struct super_block *sb; + struct mutex wq_mutex; + struct mutex pipe_mutex; + spinlock_t fs_lock; + struct autofs_wait_queue *queues; + spinlock_t lookup_lock; + struct list_head active_list; + struct list_head expiring_list; + struct callback_head rcu; +}; + +struct autofs_wait_queue { + wait_queue_head_t queue; + struct autofs_wait_queue *next; + autofs_wqt_t wait_queue_token; + struct qstr name; + u32 dev; + u64 ino; + kuid_t uid; + kgid_t gid; + pid_t pid; + pid_t tgid; + int status; + unsigned int wait_ctr; +}; + +enum { + Opt_err___4 = 0, + Opt_fd = 1, + Opt_uid___5 = 2, + Opt_gid___6 = 3, + Opt_pgrp = 4, + Opt_minproto = 5, + Opt_maxproto = 6, + Opt_indirect = 7, + Opt_direct = 8, + Opt_offset = 9, + Opt_strictexpire = 10, + Opt_ignore___2 = 11, +}; + +enum { + AUTOFS_IOC_READY_CMD = 96, + AUTOFS_IOC_FAIL_CMD = 97, + AUTOFS_IOC_CATATONIC_CMD = 98, + AUTOFS_IOC_PROTOVER_CMD = 99, + AUTOFS_IOC_SETTIMEOUT_CMD = 100, + AUTOFS_IOC_EXPIRE_CMD = 101, +}; + +enum autofs_notify { + NFY_NONE = 0, + NFY_MOUNT = 1, + NFY_EXPIRE = 2, +}; + +enum { + AUTOFS_IOC_EXPIRE_MULTI_CMD = 102, + AUTOFS_IOC_PROTOSUBVER_CMD = 103, + AUTOFS_IOC_ASKUMOUNT_CMD = 112, +}; + +struct autofs_packet_hdr { + int proto_version; + int type; +}; + +struct autofs_packet_missing { + struct autofs_packet_hdr hdr; + autofs_wqt_t wait_queue_token; + int len; + char name[256]; +}; + +struct autofs_packet_expire { + struct autofs_packet_hdr hdr; + int len; + char name[256]; +}; + +struct autofs_packet_expire_multi { + struct autofs_packet_hdr hdr; + autofs_wqt_t wait_queue_token; + int len; + char name[256]; +}; + +union autofs_packet_union { + struct autofs_packet_hdr hdr; + struct autofs_packet_missing missing; + struct autofs_packet_expire expire; + struct autofs_packet_expire_multi expire_multi; +}; + +struct autofs_v5_packet { + struct autofs_packet_hdr hdr; + autofs_wqt_t wait_queue_token; + __u32 dev; + __u64 ino; + __u32 uid; + __u32 gid; + __u32 pid; + __u32 tgid; + __u32 len; + char name[256]; +}; + +typedef struct autofs_v5_packet autofs_packet_missing_indirect_t; + +typedef struct autofs_v5_packet autofs_packet_expire_indirect_t; + +typedef struct autofs_v5_packet autofs_packet_missing_direct_t; + +typedef struct autofs_v5_packet autofs_packet_expire_direct_t; + +union autofs_v5_packet_union { + struct autofs_packet_hdr hdr; + struct autofs_v5_packet v5_packet; + autofs_packet_missing_indirect_t missing_indirect; + autofs_packet_expire_indirect_t expire_indirect; + autofs_packet_missing_direct_t missing_direct; + autofs_packet_expire_direct_t expire_direct; +}; + +struct args_protover { + __u32 version; +}; + +struct args_protosubver { + __u32 sub_version; +}; + +struct args_openmount { + __u32 devid; +}; + +struct args_ready { + __u32 token; +}; + +struct args_fail { + __u32 token; + __s32 status; +}; + +struct args_setpipefd { + __s32 pipefd; +}; + +struct args_timeout { + __u64 timeout; +}; + +struct args_requester { + __u32 uid; + __u32 gid; +}; + +struct args_expire { + __u32 how; +}; + +struct args_askumount { + __u32 may_umount; +}; + +struct args_in { + __u32 type; +}; + +struct args_out { + __u32 devid; + __u32 magic; +}; + +struct args_ismountpoint { + union { + struct args_in in; + struct args_out out; + }; +}; + +struct autofs_dev_ioctl { + __u32 ver_major; + __u32 ver_minor; + __u32 size; + __s32 ioctlfd; + union { + struct args_protover protover; + struct args_protosubver protosubver; + struct args_openmount openmount; + struct args_ready ready; + struct args_fail fail; + struct args_setpipefd setpipefd; + struct args_timeout timeout; + struct args_requester requester; + struct args_expire expire; + struct args_askumount askumount; + struct args_ismountpoint ismountpoint; + }; + char path[0]; +}; + +enum { + AUTOFS_DEV_IOCTL_VERSION_CMD = 113, + AUTOFS_DEV_IOCTL_PROTOVER_CMD = 114, + AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD = 115, + AUTOFS_DEV_IOCTL_OPENMOUNT_CMD = 116, + AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD = 117, + AUTOFS_DEV_IOCTL_READY_CMD = 118, + AUTOFS_DEV_IOCTL_FAIL_CMD = 119, + AUTOFS_DEV_IOCTL_SETPIPEFD_CMD = 120, + AUTOFS_DEV_IOCTL_CATATONIC_CMD = 121, + AUTOFS_DEV_IOCTL_TIMEOUT_CMD = 122, + AUTOFS_DEV_IOCTL_REQUESTER_CMD = 123, + AUTOFS_DEV_IOCTL_EXPIRE_CMD = 124, + AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD = 125, + AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD = 126, +}; + +typedef int (*ioctl_fn)(struct file *, struct autofs_sb_info *, struct autofs_dev_ioctl *); + +struct p9_qid { + u8 type; + u32 version; + u64 path; +}; + +struct p9_wstat { + u16 size; + u16 type; + u32 dev; + struct p9_qid qid; + u32 mode; + u32 atime; + u32 mtime; + u64 length; + const char *name; + const char *uid; + const char *gid; + const char *muid; + char *extension; + kuid_t n_uid; + kgid_t n_gid; + kuid_t n_muid; +}; + +struct p9_stat_dotl { + u64 st_result_mask; + struct p9_qid qid; + u32 st_mode; + kuid_t st_uid; + kgid_t st_gid; + u64 st_nlink; + u64 st_rdev; + u64 st_size; + u64 st_blksize; + u64 st_blocks; + u64 st_atime_sec; + u64 st_atime_nsec; + u64 st_mtime_sec; + u64 st_mtime_nsec; + u64 st_ctime_sec; + u64 st_ctime_nsec; + u64 st_btime_sec; + u64 st_btime_nsec; + u64 st_gen; + u64 st_data_version; +}; + +struct p9_rstatfs { + u32 type; + u32 bsize; + u64 blocks; + u64 bfree; + u64 bavail; + u64 files; + u64 ffree; + u64 fsid; + u32 namelen; +}; + +enum p9_trans_status { + Connected = 0, + BeginDisconnect = 1, + Disconnected = 2, + Hung = 3, +}; + +struct p9_trans_module; + +struct p9_client { + spinlock_t lock; + unsigned int msize; + unsigned char proto_version; + struct p9_trans_module *trans_mod; + enum p9_trans_status status; + void *trans; + struct kmem_cache *fcall_cache; + union { + struct { + int rfd; + int wfd; + } fd; + struct { + u16 port; + bool privport; + } tcp; + } trans_opts; + struct idr fids; + struct idr reqs; + char name[65]; +}; + +struct p9_fid { + struct p9_client *clnt; + u32 fid; + int mode; + struct p9_qid qid; + u32 iounit; + kuid_t uid; + void *rdir; + struct hlist_node dlist; +}; + +enum p9_session_flags { + V9FS_PROTO_2000U = 1, + V9FS_PROTO_2000L = 2, + V9FS_ACCESS_SINGLE = 4, + V9FS_ACCESS_USER = 8, + V9FS_ACCESS_CLIENT = 16, + V9FS_POSIX_ACL = 32, +}; + +enum p9_cache_modes { + CACHE_NONE = 0, + CACHE_MMAP = 1, + CACHE_LOOSE = 2, + CACHE_FSCACHE = 3, + nr__p9_cache_modes = 4, +}; + +struct v9fs_session_info { + unsigned char flags; + unsigned char nodev; + short unsigned int debug; + unsigned int afid; + unsigned int cache; + char *uname; + char *aname; + unsigned int maxdata; + kuid_t dfltuid; + kgid_t dfltgid; + kuid_t uid; + struct p9_client *clnt; + struct list_head slist; + struct rw_semaphore rename_sem; + long int session_lock_timeout; +}; + +struct v9fs_inode { + struct p9_qid qid; + unsigned int cache_validity; + struct p9_fid *writeback_fid; + struct mutex v_mutex; + struct inode vfs_inode; +}; + +enum p9_open_mode_t { + P9_OREAD = 0, + P9_OWRITE = 1, + P9_ORDWR = 2, + P9_OEXEC = 3, + P9_OTRUNC = 16, + P9_OREXEC = 32, + P9_ORCLOSE = 64, + P9_OAPPEND = 128, + P9_OEXCL = 4096, +}; + +enum p9_perm_t { + P9_DMDIR = 2147483648, + P9_DMAPPEND = 1073741824, + P9_DMEXCL = 536870912, + P9_DMMOUNT = 268435456, + P9_DMAUTH = 134217728, + P9_DMTMP = 67108864, + P9_DMSYMLINK = 33554432, + P9_DMLINK = 16777216, + P9_DMDEVICE = 8388608, + P9_DMNAMEDPIPE = 2097152, + P9_DMSOCKET = 1048576, + P9_DMSETUID = 524288, + P9_DMSETGID = 262144, + P9_DMSETVTX = 65536, +}; + +struct p9_iattr_dotl { + u32 valid; + u32 mode; + kuid_t uid; + kgid_t gid; + u64 size; + u64 atime_sec; + u64 atime_nsec; + u64 mtime_sec; + u64 mtime_nsec; +}; + +struct dotl_openflag_map { + int open_flag; + int dotl_flag; +}; + +struct dotl_iattr_map { + int iattr_valid; + int p9_iattr_valid; +}; + +struct p9_flock { + u8 type; + u32 flags; + u64 start; + u64 length; + u32 proc_id; + char *client_id; +}; + +struct p9_getlock { + u8 type; + u64 start; + u64 length; + u32 proc_id; + char *client_id; +}; + +struct p9_dirent { + struct p9_qid qid; + u64 d_off; + unsigned char d_type; + char d_name[256]; +}; + +struct p9_rdir { + int head; + int tail; + uint8_t buf[0]; +}; + +struct p9_fcall { + u32 size; + u8 id; + u16 tag; + size_t offset; + size_t capacity; + struct kmem_cache *cache; + u8 *sdata; +}; + +struct p9_req_t { + int status; + int t_err; + struct kref refcount; + wait_queue_head_t wq; + struct p9_fcall tc; + struct p9_fcall rc; + struct list_head req_list; +}; + +struct p9_trans_module { + struct list_head list; + char *name; + int maxsize; + int def; + struct module *owner; + int (*create)(struct p9_client *, const char *, char *); + void (*close)(struct p9_client *); + int (*request)(struct p9_client *, struct p9_req_t *); + int (*cancel)(struct p9_client *, struct p9_req_t *); + int (*cancelled)(struct p9_client *, struct p9_req_t *); + int (*zc_request)(struct p9_client *, struct p9_req_t *, struct iov_iter *, struct iov_iter *, int, int, int); + int (*show_options)(struct seq_file *, struct p9_client *); +}; + +enum { + Opt_debug___2 = 0, + Opt_dfltuid = 1, + Opt_dfltgid = 2, + Opt_afid = 3, + Opt_uname = 4, + Opt_remotename = 5, + Opt_cache = 6, + Opt_cachetag = 7, + Opt_nodevmap = 8, + Opt_cache_loose = 9, + Opt_fscache___2 = 10, + Opt_mmap = 11, + Opt_access = 12, + Opt_posixacl = 13, + Opt_locktimeout = 14, + Opt_err___5 = 15, +}; + +typedef struct vfsmount * (*debugfs_automount_t)(struct dentry *, void *); + +struct debugfs_fsdata { + const struct file_operations *real_fops; + refcount_t active_users; + struct completion active_users_drained; +}; + +struct debugfs_mount_opts { + kuid_t uid; + kgid_t gid; + umode_t mode; +}; + +enum { + Opt_uid___6 = 0, + Opt_gid___7 = 1, + Opt_mode___6 = 2, + Opt_err___6 = 3, +}; + +struct debugfs_fs_info { + struct debugfs_mount_opts mount_opts; +}; + +struct debugfs_blob_wrapper { + void *data; + long unsigned int size; +}; + +struct debugfs_reg32 { + char *name; + long unsigned int offset; +}; + +struct debugfs_regset32 { + const struct debugfs_reg32 *regs; + int nregs; + void *base; + struct device *dev; +}; + +struct debugfs_u32_array { + u32 *array; + u32 n_elements; +}; + +struct debugfs_devm_entry { + int (*read)(struct seq_file *, void *); + struct device *dev; +}; + +struct tracefs_dir_ops { + int (*mkdir)(const char *); + int (*rmdir)(const char *); +}; + +struct tracefs_mount_opts { + kuid_t uid; + kgid_t gid; + umode_t mode; +}; + +struct tracefs_fs_info { + struct tracefs_mount_opts mount_opts; +}; + +struct btrfs_ioctl_vol_args { + __s64 fd; + char name[4088]; +}; + +struct btrfs_scrub_progress { + __u64 data_extents_scrubbed; + __u64 tree_extents_scrubbed; + __u64 data_bytes_scrubbed; + __u64 tree_bytes_scrubbed; + __u64 read_errors; + __u64 csum_errors; + __u64 verify_errors; + __u64 no_csum; + __u64 csum_discards; + __u64 super_errors; + __u64 malloc_errors; + __u64 uncorrectable_errors; + __u64 corrected_errors; + __u64 last_physical; + __u64 unverified_errors; +}; + +struct btrfs_balance_args { + __u64 profiles; + union { + __u64 usage; + struct { + __u32 usage_min; + __u32 usage_max; + }; + }; + __u64 devid; + __u64 pstart; + __u64 pend; + __u64 vstart; + __u64 vend; + __u64 target; + __u64 flags; + union { + __u64 limit; + struct { + __u32 limit_min; + __u32 limit_max; + }; + }; + __u32 stripes_min; + __u32 stripes_max; + __u64 unused[6]; +}; + +struct btrfs_balance_progress { + __u64 expected; + __u64 considered; + __u64 completed; +}; + +enum btrfs_dev_stat_values { + BTRFS_DEV_STAT_WRITE_ERRS = 0, + BTRFS_DEV_STAT_READ_ERRS = 1, + BTRFS_DEV_STAT_FLUSH_ERRS = 2, + BTRFS_DEV_STAT_CORRUPTION_ERRS = 3, + BTRFS_DEV_STAT_GENERATION_ERRS = 4, + BTRFS_DEV_STAT_VALUES_MAX = 5, +}; + +struct btrfs_disk_key { + __le64 objectid; + __u8 type; + __le64 offset; +} __attribute__((packed)); + +struct btrfs_key { + __u64 objectid; + __u8 type; + __u64 offset; +} __attribute__((packed)); + +struct btrfs_dev_item { + __le64 devid; + __le64 total_bytes; + __le64 bytes_used; + __le32 io_align; + __le32 io_width; + __le32 sector_size; + __le64 type; + __le64 generation; + __le64 start_offset; + __le32 dev_group; + __u8 seek_speed; + __u8 bandwidth; + __u8 uuid[16]; + __u8 fsid[16]; +} __attribute__((packed)); + +struct btrfs_inode_ref { + __le64 index; + __le16 name_len; +} __attribute__((packed)); + +struct btrfs_timespec { + __le64 sec; + __le32 nsec; +} __attribute__((packed)); + +struct btrfs_inode_item { + __le64 generation; + __le64 transid; + __le64 size; + __le64 nbytes; + __le64 block_group; + __le32 nlink; + __le32 uid; + __le32 gid; + __le32 mode; + __le64 rdev; + __le64 flags; + __le64 sequence; + __le64 reserved[4]; + struct btrfs_timespec atime; + struct btrfs_timespec ctime; + struct btrfs_timespec mtime; + struct btrfs_timespec otime; +} __attribute__((packed)); + +struct btrfs_dir_item { + struct btrfs_disk_key location; + __le64 transid; + __le16 data_len; + __le16 name_len; + __u8 type; +} __attribute__((packed)); + +struct btrfs_root_item { + struct btrfs_inode_item inode; + __le64 generation; + __le64 root_dirid; + __le64 bytenr; + __le64 byte_limit; + __le64 bytes_used; + __le64 last_snapshot; + __le64 flags; + __le32 refs; + struct btrfs_disk_key drop_progress; + __u8 drop_level; + __u8 level; + __le64 generation_v2; + __u8 uuid[16]; + __u8 parent_uuid[16]; + __u8 received_uuid[16]; + __le64 ctransid; + __le64 otransid; + __le64 stransid; + __le64 rtransid; + struct btrfs_timespec ctime; + struct btrfs_timespec otime; + struct btrfs_timespec stime; + struct btrfs_timespec rtime; + __le64 reserved[8]; +} __attribute__((packed)); + +struct btrfs_root_ref { + __le64 dirid; + __le64 sequence; + __le16 name_len; +} __attribute__((packed)); + +enum { + BTRFS_FILE_EXTENT_INLINE = 0, + BTRFS_FILE_EXTENT_REG = 1, + BTRFS_FILE_EXTENT_PREALLOC = 2, + BTRFS_NR_FILE_EXTENT_TYPES = 3, +}; + +struct btrfs_file_extent_item { + __le64 generation; + __le64 ram_bytes; + __u8 compression; + __u8 encryption; + __le16 other_encoding; + __u8 type; + __le64 disk_bytenr; + __le64 disk_num_bytes; + __le64 offset; + __le64 num_bytes; +} __attribute__((packed)); + +enum btrfs_raid_types { + BTRFS_RAID_RAID10 = 0, + BTRFS_RAID_RAID1 = 1, + BTRFS_RAID_DUP = 2, + BTRFS_RAID_RAID0 = 3, + BTRFS_RAID_SINGLE = 4, + BTRFS_RAID_RAID5 = 5, + BTRFS_RAID_RAID6 = 6, + BTRFS_RAID_RAID1C3 = 7, + BTRFS_RAID_RAID1C4 = 8, + BTRFS_NR_RAID_TYPES = 9, +}; + +enum { + IO_TREE_FS_PINNED_EXTENTS = 0, + IO_TREE_FS_EXCLUDED_EXTENTS = 1, + IO_TREE_BTREE_INODE_IO = 2, + IO_TREE_INODE_IO = 3, + IO_TREE_INODE_IO_FAILURE = 4, + IO_TREE_RELOC_BLOCKS = 5, + IO_TREE_TRANS_DIRTY_PAGES = 6, + IO_TREE_ROOT_DIRTY_LOG_PAGES = 7, + IO_TREE_INODE_FILE_EXTENT = 8, + IO_TREE_LOG_CSUM_RANGE = 9, + IO_TREE_SELFTEST = 10, + IO_TREE_DEVICE_ALLOC_STATE = 11, +}; + +struct btrfs_fs_info; + +struct extent_io_tree { + struct rb_root state; + struct btrfs_fs_info *fs_info; + void *private_data; + u64 dirty_bytes; + bool track_uptodate; + u8 owner; + spinlock_t lock; +}; + +struct extent_map_tree { + struct rb_root_cached map; + struct list_head modified_extents; + rwlock_t lock; +}; + +struct btrfs_space_info; + +struct btrfs_block_rsv { + u64 size; + u64 reserved; + struct btrfs_space_info *space_info; + spinlock_t lock; + short unsigned int full; + short unsigned int type; + short unsigned int failfast; + u64 qgroup_rsv_size; + u64 qgroup_rsv_reserved; +}; + +struct btrfs_block_group; + +struct btrfs_free_cluster { + spinlock_t lock; + spinlock_t refill_lock; + struct rb_root root; + u64 max_size; + u64 window_start; + bool fragmented; + struct btrfs_block_group *block_group; + struct list_head block_group_list; +}; + +struct btrfs_discard_ctl { + struct workqueue_struct *discard_workers; + struct delayed_work work; + spinlock_t lock; + struct btrfs_block_group *block_group; + struct list_head discard_list[3]; + u64 prev_discard; + atomic_t discardable_extents; + atomic64_t discardable_bytes; + u64 max_discard_size; + long unsigned int delay; + u32 iops_limit; + u32 kbps_limit; + u64 discard_extent_bytes; + u64 discard_bitmap_bytes; + atomic64_t discard_bytes_saved; +}; + +struct btrfs_work; + +typedef void (*btrfs_func_t)(struct btrfs_work *); + +struct __btrfs_workqueue; + +struct btrfs_work { + btrfs_func_t func; + btrfs_func_t ordered_func; + btrfs_func_t ordered_free; + struct work_struct normal_work; + struct list_head ordered_list; + struct __btrfs_workqueue *wq; + long unsigned int flags; +}; + +struct btrfs_device; + +struct btrfs_dev_replace { + u64 replace_state; + time64_t time_started; + time64_t time_stopped; + atomic64_t num_write_errors; + atomic64_t num_uncorrectable_read_errors; + u64 cursor_left; + u64 committed_cursor_left; + u64 cursor_left_last_write_of_item; + u64 cursor_right; + u64 cont_reading_from_srcdev_mode; + int is_valid; + int item_needs_writeback; + struct btrfs_device *srcdev; + struct btrfs_device *tgtdev; + struct mutex lock_finishing_cancel_unmount; + struct rw_semaphore rwsem; + struct btrfs_scrub_progress scrub_progress; + struct percpu_counter bio_counter; + wait_queue_head_t replace_wait; +}; + +struct btrfs_root; + +struct btrfs_transaction; + +struct btrfs_super_block; + +struct btrfs_stripe_hash_table; + +struct btrfs_workqueue; + +struct btrfs_fs_devices; + +struct reloc_control; + +struct btrfs_balance_control; + +struct ulist; + +struct btrfs_delayed_root; + +struct btrfs_fs_info { + u8 chunk_tree_uuid[16]; + long unsigned int flags; + struct btrfs_root *extent_root; + struct btrfs_root *tree_root; + struct btrfs_root *chunk_root; + struct btrfs_root *dev_root; + struct btrfs_root *fs_root; + struct btrfs_root *csum_root; + struct btrfs_root *quota_root; + struct btrfs_root *uuid_root; + struct btrfs_root *free_space_root; + struct btrfs_root *data_reloc_root; + struct btrfs_root *log_root_tree; + spinlock_t fs_roots_radix_lock; + struct xarray fs_roots_radix; + spinlock_t block_group_cache_lock; + u64 first_logical_byte; + struct rb_root block_group_cache_tree; + atomic64_t free_chunk_space; + struct extent_io_tree excluded_extents; + struct extent_map_tree mapping_tree; + struct btrfs_block_rsv global_block_rsv; + struct btrfs_block_rsv trans_block_rsv; + struct btrfs_block_rsv chunk_block_rsv; + struct btrfs_block_rsv delayed_block_rsv; + struct btrfs_block_rsv delayed_refs_rsv; + struct btrfs_block_rsv empty_block_rsv; + u64 generation; + u64 last_trans_committed; + u64 avg_delayed_ref_runtime; + u64 last_trans_log_full_commit; + long unsigned int mount_opt; + long unsigned int pending_changes; + long unsigned int compress_type: 4; + unsigned int compress_level; + u32 commit_interval; + u64 max_inline; + struct btrfs_transaction *running_transaction; + wait_queue_head_t transaction_throttle; + wait_queue_head_t transaction_wait; + wait_queue_head_t transaction_blocked_wait; + wait_queue_head_t async_submit_wait; + spinlock_t super_lock; + struct btrfs_super_block *super_copy; + struct btrfs_super_block *super_for_commit; + struct super_block *sb; + struct inode *btree_inode; + struct mutex tree_log_mutex; + struct mutex transaction_kthread_mutex; + struct mutex cleaner_mutex; + struct mutex chunk_mutex; + struct mutex ro_block_group_mutex; + struct btrfs_stripe_hash_table *stripe_hash_table; + struct mutex ordered_operations_mutex; + struct rw_semaphore commit_root_sem; + struct rw_semaphore cleanup_work_sem; + struct rw_semaphore subvol_sem; + spinlock_t trans_lock; + struct mutex reloc_mutex; + struct list_head trans_list; + struct list_head dead_roots; + struct list_head caching_block_groups; + spinlock_t delayed_iput_lock; + struct list_head delayed_iputs; + atomic_t nr_delayed_iputs; + wait_queue_head_t delayed_iputs_wait; + atomic64_t tree_mod_seq; + rwlock_t tree_mod_log_lock; + struct rb_root tree_mod_log; + struct list_head tree_mod_seq_list; + atomic_t async_delalloc_pages; + spinlock_t ordered_root_lock; + struct list_head ordered_roots; + struct mutex delalloc_root_mutex; + spinlock_t delalloc_root_lock; + struct list_head delalloc_roots; + struct btrfs_workqueue *workers; + struct btrfs_workqueue *delalloc_workers; + struct btrfs_workqueue *flush_workers; + struct btrfs_workqueue *endio_workers; + struct btrfs_workqueue *endio_meta_workers; + struct btrfs_workqueue *endio_raid56_workers; + struct btrfs_workqueue *rmw_workers; + struct btrfs_workqueue *endio_meta_write_workers; + struct btrfs_workqueue *endio_write_workers; + struct btrfs_workqueue *endio_freespace_worker; + struct btrfs_workqueue *caching_workers; + struct btrfs_workqueue *readahead_workers; + struct btrfs_workqueue *fixup_workers; + struct btrfs_workqueue *delayed_workers; + struct task_struct *transaction_kthread; + struct task_struct *cleaner_kthread; + u32 thread_pool_size; + struct kobject *space_info_kobj; + struct kobject *qgroups_kobj; + u64 total_pinned; + struct percpu_counter dirty_metadata_bytes; + struct percpu_counter delalloc_bytes; + struct percpu_counter dio_bytes; + s32 dirty_metadata_batch; + s32 delalloc_batch; + struct list_head dirty_cowonly_roots; + struct btrfs_fs_devices *fs_devices; + struct list_head space_info; + struct btrfs_space_info *data_sinfo; + struct reloc_control *reloc_ctl; + struct btrfs_free_cluster data_alloc_cluster; + struct btrfs_free_cluster meta_alloc_cluster; + spinlock_t defrag_inodes_lock; + struct rb_root defrag_inodes; + atomic_t defrag_running; + seqlock_t profiles_lock; + u64 avail_data_alloc_bits; + u64 avail_metadata_alloc_bits; + u64 avail_system_alloc_bits; + spinlock_t balance_lock; + struct mutex balance_mutex; + atomic_t balance_pause_req; + atomic_t balance_cancel_req; + struct btrfs_balance_control *balance_ctl; + wait_queue_head_t balance_wait_q; + u32 data_chunk_allocations; + u32 metadata_ratio; + void *bdev_holder; + struct mutex scrub_lock; + atomic_t scrubs_running; + atomic_t scrub_pause_req; + atomic_t scrubs_paused; + atomic_t scrub_cancel_req; + wait_queue_head_t scrub_pause_wait; + refcount_t scrub_workers_refcnt; + struct btrfs_workqueue *scrub_workers; + struct btrfs_workqueue *scrub_wr_completion_workers; + struct btrfs_workqueue *scrub_parity_workers; + struct btrfs_discard_ctl discard_ctl; + u64 qgroup_flags; + struct rb_root qgroup_tree; + spinlock_t qgroup_lock; + struct ulist *qgroup_ulist; + struct mutex qgroup_ioctl_lock; + struct list_head dirty_qgroups; + u64 qgroup_seq; + struct mutex qgroup_rescan_lock; + struct btrfs_key qgroup_rescan_progress; + struct btrfs_workqueue *qgroup_rescan_workers; + struct completion qgroup_rescan_completion; + struct btrfs_work qgroup_rescan_work; + bool qgroup_rescan_running; + long unsigned int fs_state; + struct btrfs_delayed_root *delayed_root; + spinlock_t reada_lock; + struct xarray reada_tree; + atomic_t reada_works_cnt; + spinlock_t buffer_lock; + struct xarray buffer_radix; + int backup_root_index; + struct btrfs_dev_replace dev_replace; + struct semaphore uuid_tree_rescan_sem; + struct work_struct async_reclaim_work; + struct work_struct async_data_reclaim_work; + spinlock_t unused_bgs_lock; + struct list_head unused_bgs; + struct mutex unused_bg_unpin_mutex; + struct mutex delete_unused_bgs_mutex; + u32 nodesize; + u32 sectorsize; + u32 stripesize; + spinlock_t swapfile_pins_lock; + struct rb_root swapfile_pins; + struct crypto_shash *csum_shash; + int send_in_progress; + long unsigned int exclusive_operation; +}; + +struct io_failure_record; + +struct extent_state { + u64 start; + u64 end; + struct rb_node rb_node; + wait_queue_head_t wq; + refcount_t refs; + unsigned int state; + struct io_failure_record *failrec; +}; + +struct io_failure_record { + struct page *page; + u64 start; + u64 len; + u64 logical; + long unsigned int bio_flags; + int this_mirror; + int failed_mirror; + int in_validation; +}; + +struct ulist { + long unsigned int nnodes; + struct list_head nodes; + struct rb_root root; +}; + +struct extent_buffer { + u64 start; + long unsigned int len; + long unsigned int bflags; + struct btrfs_fs_info *fs_info; + spinlock_t refs_lock; + atomic_t refs; + atomic_t io_pages; + int read_mirror; + struct callback_head callback_head; + pid_t lock_owner; + int blocking_writers; + atomic_t blocking_readers; + bool lock_recursed; + short int log_index; + rwlock_t lock; + wait_queue_head_t write_lock_wq; + wait_queue_head_t read_lock_wq; + struct page *pages[16]; +}; + +struct map_lookup; + +struct extent_map { + struct rb_node rb_node; + u64 start; + u64 len; + u64 mod_start; + u64 mod_len; + u64 orig_start; + u64 orig_block_len; + u64 ram_bytes; + u64 block_start; + u64 block_len; + u64 generation; + long unsigned int flags; + struct map_lookup *map_lookup; + refcount_t refs; + unsigned int compress_type; + struct list_head list; +}; + +struct btrfs_ordered_inode_tree { + spinlock_t lock; + struct rb_root tree; + struct rb_node *last; +}; + +struct btrfs_delayed_node; + +struct btrfs_inode { + struct btrfs_root *root; + struct btrfs_key location; + spinlock_t lock; + struct extent_map_tree extent_tree; + struct extent_io_tree io_tree; + struct extent_io_tree io_failure_tree; + struct extent_io_tree file_extent_tree; + struct mutex log_mutex; + struct btrfs_ordered_inode_tree ordered_tree; + struct list_head delalloc_inodes; + struct rb_node rb_node; + long unsigned int runtime_flags; + atomic_t sync_writers; + u64 generation; + u64 last_trans; + u64 logged_trans; + int last_sub_trans; + int last_log_commit; + u64 delalloc_bytes; + u64 new_delalloc_bytes; + u64 defrag_bytes; + u64 disk_i_size; + u64 index_cnt; + u64 dir_index; + u64 last_unlink_trans; + u64 last_reflink_trans; + u64 csum_bytes; + u32 flags; + unsigned int outstanding_extents; + struct btrfs_block_rsv block_rsv; + unsigned int prop_compress; + unsigned int defrag_compress; + struct btrfs_delayed_node *delayed_node; + struct timespec64 i_otime; + struct list_head delayed_iput; + struct rw_semaphore dio_sem; + struct inode vfs_inode; +}; + +enum { + EXTENT_FLAG_PINNED = 0, + EXTENT_FLAG_COMPRESSED = 1, + EXTENT_FLAG_PREALLOC = 2, + EXTENT_FLAG_LOGGING = 3, + EXTENT_FLAG_FILLING = 4, + EXTENT_FLAG_FS_MAPPING = 5, +}; + +struct btrfs_bio_stripe { + struct btrfs_device *dev; + u64 physical; + u64 length; +}; + +struct map_lookup { + u64 type; + int io_align; + int io_width; + u64 stripe_len; + int num_stripes; + int sub_stripes; + int verified_stripes; + struct btrfs_bio_stripe stripes[0]; +}; + +struct __btrfs_workqueue { + struct workqueue_struct *normal_wq; + struct btrfs_fs_info *fs_info; + struct list_head ordered_list; + spinlock_t list_lock; + atomic_t pending; + int limit_active; + int current_active; + int thresh; + unsigned int count; + spinlock_t thres_lock; +}; + +struct btrfs_space_info { + spinlock_t lock; + u64 total_bytes; + u64 bytes_used; + u64 bytes_pinned; + u64 bytes_reserved; + u64 bytes_may_use; + u64 bytes_readonly; + u64 max_extent_size; + unsigned int full: 1; + unsigned int chunk_alloc: 1; + unsigned int flush: 1; + unsigned int force_alloc; + u64 disk_used; + u64 disk_total; + u64 flags; + struct percpu_counter total_bytes_pinned; + struct list_head list; + struct list_head ro_bgs; + struct list_head priority_tickets; + struct list_head tickets; + u64 reclaim_size; + u64 tickets_id; + struct rw_semaphore groups_sem; + struct list_head block_groups[9]; + struct kobject kobj; + struct kobject *block_group_kobjs[9]; +}; + +enum btrfs_lock_nesting { + BTRFS_NESTING_NORMAL = 0, + BTRFS_NESTING_COW = 1, + BTRFS_NESTING_LEFT = 2, + BTRFS_NESTING_RIGHT = 3, + BTRFS_NESTING_LEFT_COW = 4, + BTRFS_NESTING_RIGHT_COW = 5, + BTRFS_NESTING_SPLIT = 6, + BTRFS_NESTING_NEW_ROOT = 7, + BTRFS_NESTING_MAX = 8, +}; + +struct btrfs_drew_lock { + atomic_t readers; + struct percpu_counter writers; + wait_queue_head_t pending_writers; + wait_queue_head_t pending_readers; +}; + +enum { + BTRFS_FS_STATE_ERROR = 0, + BTRFS_FS_STATE_REMOUNTING = 1, + BTRFS_FS_STATE_TRANS_ABORTED = 2, + BTRFS_FS_STATE_DEV_REPLACING = 3, + BTRFS_FS_STATE_DUMMY_FS_INFO = 4, +}; + +struct btrfs_header { + u8 csum[32]; + u8 fsid[16]; + __le64 bytenr; + __le64 flags; + u8 chunk_tree_uuid[16]; + __le64 generation; + __le64 owner; + __le32 nritems; + u8 level; +} __attribute__((packed)); + +struct btrfs_root_backup { + __le64 tree_root; + __le64 tree_root_gen; + __le64 chunk_root; + __le64 chunk_root_gen; + __le64 extent_root; + __le64 extent_root_gen; + __le64 fs_root; + __le64 fs_root_gen; + __le64 dev_root; + __le64 dev_root_gen; + __le64 csum_root; + __le64 csum_root_gen; + __le64 total_bytes; + __le64 bytes_used; + __le64 num_devices; + __le64 unused_64[4]; + u8 tree_root_level; + u8 chunk_root_level; + u8 extent_root_level; + u8 fs_root_level; + u8 dev_root_level; + u8 csum_root_level; + u8 unused_8[10]; +}; + +struct btrfs_super_block { + u8 csum[32]; + u8 fsid[16]; + __le64 bytenr; + __le64 flags; + __le64 magic; + __le64 generation; + __le64 root; + __le64 chunk_root; + __le64 log_root; + __le64 log_root_transid; + __le64 total_bytes; + __le64 bytes_used; + __le64 root_dir_objectid; + __le64 num_devices; + __le32 sectorsize; + __le32 nodesize; + __le32 __unused_leafsize; + __le32 stripesize; + __le32 sys_chunk_array_size; + __le64 chunk_root_generation; + __le64 compat_flags; + __le64 compat_ro_flags; + __le64 incompat_flags; + __le16 csum_type; + u8 root_level; + u8 chunk_root_level; + u8 log_root_level; + struct btrfs_dev_item dev_item; + char label[256]; + __le64 cache_generation; + __le64 uuid_tree_generation; + u8 metadata_uuid[16]; + __le64 reserved[28]; + u8 sys_chunk_array[2048]; + struct btrfs_root_backup super_roots[4]; +} __attribute__((packed)); + +struct btrfs_item { + struct btrfs_disk_key key; + __le32 offset; + __le32 size; +} __attribute__((packed)); + +struct btrfs_path { + struct extent_buffer *nodes[8]; + int slots[8]; + u8 locks[8]; + u8 reada; + u8 lowest_level; + unsigned int search_for_split: 1; + unsigned int keep_locks: 1; + unsigned int skip_locking: 1; + unsigned int leave_spinning: 1; + unsigned int search_commit_root: 1; + unsigned int need_commit_sem: 1; + unsigned int skip_release_on_error: 1; + unsigned int recurse: 1; +}; + +struct rcu_string; + +struct scrub_ctx; + +struct reada_zone; + +struct btrfs_device { + struct list_head dev_list; + struct list_head dev_alloc_list; + struct list_head post_commit_list; + struct btrfs_fs_devices *fs_devices; + struct btrfs_fs_info *fs_info; + struct rcu_string *name; + u64 generation; + struct block_device *bdev; + fmode_t mode; + long unsigned int dev_state; + blk_status_t last_flush_error; + u64 devid; + u64 total_bytes; + u64 disk_total_bytes; + u64 bytes_used; + u32 io_align; + u32 io_width; + u64 type; + u32 sector_size; + u8 uuid[16]; + u64 commit_total_bytes; + u64 commit_bytes_used; + struct bio *flush_bio; + struct completion flush_wait; + struct scrub_ctx *scrub_ctx; + atomic_t reada_in_flight; + u64 reada_next; + struct reada_zone *reada_curr_zone; + struct xarray reada_zones; + struct xarray reada_extents; + int dev_stats_valid; + atomic_t dev_stats_ccnt; + atomic_t dev_stat_values[5]; + struct extent_io_tree alloc_state; + struct completion kobj_unregister; + struct kobject devid_kobj; +}; + +enum btrfs_discard_state { + BTRFS_DISCARD_EXTENTS = 0, + BTRFS_DISCARD_BITMAPS = 1, + BTRFS_DISCARD_RESET_CURSOR = 2, +}; + +struct btrfs_io_ctl { + void *cur; + void *orig; + struct page *page; + struct page **pages; + struct btrfs_fs_info *fs_info; + struct inode *inode; + long unsigned int size; + int index; + int num_pages; + int entries; + int bitmaps; + unsigned int check_crcs: 1; +}; + +struct btrfs_full_stripe_locks_tree { + struct rb_root root; + struct mutex lock; +}; + +struct btrfs_caching_control; + +struct btrfs_free_space_ctl; + +struct btrfs_block_group { + struct btrfs_fs_info *fs_info; + struct inode *inode; + spinlock_t lock; + u64 start; + u64 length; + u64 pinned; + u64 reserved; + u64 used; + u64 delalloc_bytes; + u64 bytes_super; + u64 flags; + u64 cache_generation; + u32 bitmap_high_thresh; + u32 bitmap_low_thresh; + struct rw_semaphore data_rwsem; + long unsigned int full_stripe_len; + unsigned int ro; + unsigned int iref: 1; + unsigned int has_caching_ctl: 1; + unsigned int removed: 1; + int disk_cache_state; + int cached; + struct btrfs_caching_control *caching_ctl; + u64 last_byte_to_unpin; + struct btrfs_space_info *space_info; + struct btrfs_free_space_ctl *free_space_ctl; + struct rb_node cache_node; + struct list_head list; + refcount_t refs; + struct list_head cluster_list; + struct list_head bg_list; + struct list_head ro_list; + atomic_t frozen; + struct list_head discard_list; + int discard_index; + u64 discard_eligible_time; + u64 discard_cursor; + enum btrfs_discard_state discard_state; + struct list_head dirty_list; + struct list_head io_list; + struct btrfs_io_ctl io_ctl; + atomic_t reservations; + atomic_t nocow_writers; + struct mutex free_space_lock; + int needs_free_space; + struct btrfs_full_stripe_locks_tree full_stripe_locks_root; +}; + +enum btrfs_caching_type { + BTRFS_CACHE_NO = 0, + BTRFS_CACHE_STARTED = 1, + BTRFS_CACHE_FAST = 2, + BTRFS_CACHE_FINISHED = 3, + BTRFS_CACHE_ERROR = 4, +}; + +enum { + BTRFS_FS_BARRIER = 0, + BTRFS_FS_CLOSING_START = 1, + BTRFS_FS_CLOSING_DONE = 2, + BTRFS_FS_LOG_RECOVERING = 3, + BTRFS_FS_OPEN = 4, + BTRFS_FS_QUOTA_ENABLED = 5, + BTRFS_FS_UPDATE_UUID_TREE_GEN = 6, + BTRFS_FS_CREATING_FREE_SPACE_TREE = 7, + BTRFS_FS_BTREE_ERR = 8, + BTRFS_FS_LOG1_ERR = 9, + BTRFS_FS_LOG2_ERR = 10, + BTRFS_FS_QUOTA_OVERRIDE = 11, + BTRFS_FS_FROZEN = 12, + BTRFS_FS_BALANCE_RUNNING = 13, + BTRFS_FS_CLEANER_RUNNING = 14, + BTRFS_FS_CSUM_IMPL_FAST = 15, + BTRFS_FS_DISCARD_RUNNING = 16, +}; + +struct btrfs_qgroup_swapped_blocks { + spinlock_t lock; + bool swapped; + struct rb_root blocks[8]; +}; + +struct btrfs_root { + struct extent_buffer *node; + struct extent_buffer *commit_root; + struct btrfs_root *log_root; + struct btrfs_root *reloc_root; + long unsigned int state; + struct btrfs_root_item root_item; + struct btrfs_key root_key; + struct btrfs_fs_info *fs_info; + struct extent_io_tree dirty_log_pages; + struct mutex objectid_mutex; + spinlock_t accounting_lock; + struct btrfs_block_rsv *block_rsv; + struct btrfs_free_space_ctl *free_ino_ctl; + enum btrfs_caching_type ino_cache_state; + int: 32; + spinlock_t ino_cache_lock; + wait_queue_head_t ino_cache_wait; + struct btrfs_free_space_ctl *free_ino_pinned; + u64 ino_cache_progress; + struct inode *ino_cache_inode; + struct mutex log_mutex; + wait_queue_head_t log_writer_wait; + wait_queue_head_t log_commit_wait[2]; + struct list_head log_ctxs[2]; + atomic_t log_writers; + atomic_t log_commit[2]; + atomic_t log_batch; + int log_transid; + int log_transid_committed; + int last_log_commit; + pid_t log_start_pid; + u64 last_trans; + u32 type; + int: 32; + u64 highest_objectid; + struct btrfs_key defrag_progress; + struct btrfs_key defrag_max; + long: 48; + struct list_head dirty_list; + struct list_head root_list; + spinlock_t log_extents_lock[2]; + struct list_head logged_list[2]; + int orphan_cleanup_state; + int: 32; + spinlock_t inode_lock; + struct rb_root inode_tree; + struct xarray delayed_nodes_tree; + dev_t anon_dev; + int: 32; + spinlock_t root_item_lock; + refcount_t refs; + int: 32; + struct mutex delalloc_mutex; + spinlock_t delalloc_lock; + struct list_head delalloc_inodes; + struct list_head delalloc_root; + u64 nr_delalloc_inodes; + struct mutex ordered_extent_mutex; + spinlock_t ordered_extent_lock; + struct list_head ordered_extents; + struct list_head ordered_root; + u64 nr_ordered_extents; + struct list_head reloc_dirty_list; + int send_in_progress; + int dedupe_in_progress; + struct btrfs_drew_lock snapshot_lock; + atomic_t snapshot_force_cow; + int: 32; + spinlock_t qgroup_meta_rsv_lock; + u64 qgroup_meta_rsv_pertrans; + u64 qgroup_meta_rsv_prealloc; + wait_queue_head_t qgroup_flush_wait; + atomic_t nr_swapfiles; + int: 32; + struct btrfs_qgroup_swapped_blocks swapped_blocks; + struct extent_io_tree log_csum_range; +} __attribute__((packed)); + +enum btrfs_trans_state { + TRANS_STATE_RUNNING = 0, + TRANS_STATE_COMMIT_START = 1, + TRANS_STATE_COMMIT_DOING = 2, + TRANS_STATE_UNBLOCKED = 3, + TRANS_STATE_COMPLETED = 4, + TRANS_STATE_MAX = 5, +}; + +struct btrfs_delayed_ref_root { + struct rb_root_cached href_root; + struct rb_root dirty_extent_root; + spinlock_t lock; + atomic_t num_entries; + long unsigned int num_heads; + long unsigned int num_heads_ready; + u64 pending_csums; + int flushing; + u64 run_delayed_start; + u64 qgroup_to_skip; +}; + +struct btrfs_transaction { + u64 transid; + atomic_t num_extwriters; + atomic_t num_writers; + refcount_t use_count; + long unsigned int flags; + enum btrfs_trans_state state; + int aborted; + struct list_head list; + struct extent_io_tree dirty_pages; + time64_t start_time; + wait_queue_head_t writer_wait; + wait_queue_head_t commit_wait; + struct list_head pending_snapshots; + struct list_head dev_update_list; + struct list_head switch_commits; + struct list_head dirty_bgs; + struct list_head io_bgs; + struct list_head dropped_roots; + struct extent_io_tree pinned_extents; + struct mutex cache_write_mutex; + spinlock_t dirty_bgs_lock; + struct list_head deleted_bgs; + spinlock_t dropped_roots_lock; + struct btrfs_delayed_ref_root delayed_refs; + struct btrfs_fs_info *fs_info; + atomic_t pending_ordered; + wait_queue_head_t pending_wait; +}; + +enum btrfs_chunk_allocation_policy { + BTRFS_CHUNK_ALLOC_REGULAR = 0, +}; + +struct btrfs_fs_devices { + u8 fsid[16]; + u8 metadata_uuid[16]; + bool fsid_change; + struct list_head fs_list; + u64 num_devices; + u64 open_devices; + u64 rw_devices; + u64 missing_devices; + u64 total_rw_bytes; + u64 total_devices; + u64 latest_generation; + struct block_device *latest_bdev; + struct mutex device_list_mutex; + struct list_head devices; + struct list_head alloc_list; + struct list_head seed_list; + bool seeding; + int opened; + bool rotating; + struct btrfs_fs_info *fs_info; + struct kobject fsid_kobj; + struct kobject *devices_kobj; + struct kobject *devinfo_kobj; + struct completion kobj_unregister; + enum btrfs_chunk_allocation_policy chunk_alloc_policy; +}; + +struct btrfs_balance_control { + struct btrfs_balance_args data; + struct btrfs_balance_args meta; + struct btrfs_balance_args sys; + u64 flags; + struct btrfs_balance_progress stat; +}; + +struct btrfs_delayed_root { + spinlock_t lock; + struct list_head node_list; + struct list_head prepare_list; + atomic_t items; + atomic_t items_seq; + int nodes; + wait_queue_head_t wait; +}; + +struct btrfs_free_space_op; + +struct btrfs_free_space_ctl { + spinlock_t tree_lock; + struct rb_root free_space_offset; + u64 free_space; + int extents_thresh; + int free_extents; + int total_bitmaps; + int unit; + u64 start; + s32 discardable_extents[2]; + s64 discardable_bytes[2]; + const struct btrfs_free_space_op *op; + void *private; + struct mutex cache_writeout_mutex; + struct list_head trimming_ranges; +}; + +enum btrfs_reserve_flush_enum { + BTRFS_RESERVE_NO_FLUSH = 0, + BTRFS_RESERVE_FLUSH_LIMIT = 1, + BTRFS_RESERVE_FLUSH_EVICT = 2, + BTRFS_RESERVE_FLUSH_DATA = 3, + BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE = 4, + BTRFS_RESERVE_FLUSH_ALL = 5, + BTRFS_RESERVE_FLUSH_ALL_STEAL = 6, +}; + +enum btrfs_flush_state { + FLUSH_DELAYED_ITEMS_NR = 1, + FLUSH_DELAYED_ITEMS = 2, + FLUSH_DELAYED_REFS_NR = 3, + FLUSH_DELAYED_REFS = 4, + FLUSH_DELALLOC = 5, + FLUSH_DELALLOC_WAIT = 6, + ALLOC_CHUNK = 7, + ALLOC_CHUNK_FORCE = 8, + RUN_DELAYED_IPUTS = 9, + COMMIT_TRANS = 10, +}; + +struct btrfs_delayed_node { + u64 inode_id; + u64 bytes_reserved; + struct btrfs_root *root; + struct list_head n_list; + struct list_head p_list; + struct rb_root_cached ins_root; + struct rb_root_cached del_root; + struct mutex mutex; + struct btrfs_inode_item inode_item; + refcount_t refs; + u64 index_cnt; + long unsigned int flags; + int count; +}; + +enum { + BTRFS_ORDERED_IO_DONE = 0, + BTRFS_ORDERED_COMPLETE = 1, + BTRFS_ORDERED_NOCOW = 2, + BTRFS_ORDERED_COMPRESSED = 3, + BTRFS_ORDERED_PREALLOC = 4, + BTRFS_ORDERED_DIRECT = 5, + BTRFS_ORDERED_IOERR = 6, + BTRFS_ORDERED_TRUNCATED = 7, + BTRFS_ORDERED_REGULAR = 8, + BTRFS_ORDERED_LOGGED = 9, + BTRFS_ORDERED_LOGGED_CSUM = 10, + BTRFS_ORDERED_PENDING = 11, +}; + +struct btrfs_ordered_extent { + u64 file_offset; + u64 disk_bytenr; + u64 num_bytes; + u64 disk_num_bytes; + u64 bytes_left; + u64 outstanding_isize; + u64 truncated_len; + long unsigned int flags; + int compress_type; + int qgroup_rsv; + refcount_t refs; + struct inode *inode; + struct list_head list; + struct list_head log_list; + wait_queue_head_t wait; + struct rb_node rb_node; + struct list_head root_extent_list; + struct btrfs_work work; + struct completion completion; + struct btrfs_work flush_work; + struct list_head work_list; +}; + +struct btrfs_delayed_ref_node { + struct rb_node ref_node; + struct list_head add_list; + u64 bytenr; + u64 num_bytes; + u64 seq; + refcount_t refs; + int ref_mod; + unsigned int action: 8; + unsigned int type: 8; + unsigned int is_head: 1; + unsigned int in_tree: 1; +}; + +struct btrfs_delayed_extent_op { + struct btrfs_disk_key key; + u8 level; + bool update_key; + bool update_flags; + bool is_data; + u64 flags_to_set; +}; + +struct btrfs_delayed_ref_head { + u64 bytenr; + u64 num_bytes; + refcount_t refs; + struct mutex mutex; + spinlock_t lock; + struct rb_root_cached ref_tree; + struct list_head ref_add_list; + struct rb_node href_node; + struct btrfs_delayed_extent_op *extent_op; + int total_ref_mod; + int ref_mod; + unsigned int must_insert_reserved: 1; + unsigned int is_data: 1; + unsigned int is_system: 1; + unsigned int processing: 1; +}; + +struct btrfs_delayed_tree_ref { + struct btrfs_delayed_ref_node node; + u64 root; + u64 parent; + int level; +}; + +struct btrfs_delayed_data_ref { + struct btrfs_delayed_ref_node node; + u64 root; + u64 parent; + u64 objectid; + u64 offset; +}; + +struct btrfs_trans_handle { + u64 transid; + u64 bytes_reserved; + u64 chunk_bytes_reserved; + long unsigned int delayed_ref_updates; + struct btrfs_transaction *transaction; + struct btrfs_block_rsv *block_rsv; + struct btrfs_block_rsv *orig_rsv; + refcount_t use_count; + unsigned int type; + short int aborted; + bool adding_csums; + bool allocating_chunk; + bool can_flush_pending_bgs; + bool reloc_reserved; + bool dirty; + struct btrfs_root *root; + struct btrfs_fs_info *fs_info; + struct list_head new_bgs; +}; + +struct rcu_string { + struct callback_head rcu; + char str[0]; +}; + +struct btrfs_device_info { + struct btrfs_device *dev; + u64 dev_offset; + u64 max_avail; + u64 total_avail; +}; + +struct btrfs_raid_attr { + u8 sub_stripes; + u8 dev_stripes; + u8 devs_max; + u8 devs_min; + u8 tolerated_failures; + u8 devs_increment; + u8 ncopies; + u8 nparity; + u8 mindev_error; + const char raid_name[8]; + u64 bg_flag; +}; + +enum btrfs_compression_type { + BTRFS_COMPRESS_NONE = 0, + BTRFS_COMPRESS_ZLIB = 1, + BTRFS_COMPRESS_LZO = 2, + BTRFS_COMPRESS_ZSTD = 3, + BTRFS_NR_COMPRESS_TYPES = 4, +}; + +enum btrfs_trim_state { + BTRFS_TRIM_STATE_UNTRIMMED = 0, + BTRFS_TRIM_STATE_TRIMMED = 1, + BTRFS_TRIM_STATE_TRIMMING = 2, +}; + +struct btrfs_free_space { + struct rb_node offset_index; + u64 offset; + u64 bytes; + u64 max_extent_size; + long unsigned int *bitmap; + struct list_head list; + enum btrfs_trim_state trim_state; + s32 bitmap_extents; +}; + +struct btrfs_free_space_op { + void (*recalc_thresholds)(struct btrfs_free_space_ctl *); + bool (*use_bitmap)(struct btrfs_free_space_ctl *, struct btrfs_free_space *); +}; + +struct extent_inode_elem; + +struct prelim_ref { + struct rb_node rbnode; + u64 root_id; + struct btrfs_key key_for_search; + int level; + int count; + struct extent_inode_elem *inode_list; + u64 parent; + u64 wanted_disk_byte; +}; + +struct btrfs_caching_control { + struct list_head list; + struct mutex mutex; + wait_queue_head_t wait; + struct btrfs_work work; + struct btrfs_block_group *block_group; + u64 progress; + refcount_t count; +}; + +struct btrfs_qgroup_extent_record { + struct rb_node node; + u64 bytenr; + u64 num_bytes; + u32 data_rsv; + u64 data_rsv_refroot; + struct ulist *old_roots; +}; + +enum btrfs_qgroup_rsv_type { + BTRFS_QGROUP_RSV_DATA = 0, + BTRFS_QGROUP_RSV_META_PERTRANS = 1, + BTRFS_QGROUP_RSV_META_PREALLOC = 2, + BTRFS_QGROUP_RSV_LAST = 3, +}; + +struct btrfs_qgroup_rsv { + u64 values[3]; +}; + +struct btrfs_qgroup { + u64 qgroupid; + u64 rfer; + u64 rfer_cmpr; + u64 excl; + u64 excl_cmpr; + u64 lim_flags; + u64 max_rfer; + u64 max_excl; + u64 rsv_rfer; + u64 rsv_excl; + struct btrfs_qgroup_rsv rsv; + struct list_head groups; + struct list_head members; + struct list_head dirty; + struct rb_node node; + u64 old_refcnt; + u64 new_refcnt; + struct kobject kobj; +}; + +struct trace_event_raw_btrfs_transaction_commit { + struct trace_entry ent; + u8 fsid[16]; + u64 generation; + u64 root_objectid; + char __data[0]; +}; + +struct trace_event_raw_btrfs__inode { + struct trace_entry ent; + u8 fsid[16]; + u64 ino; + u64 blocks; + u64 disk_i_size; + u64 generation; + u64 last_trans; + u64 logged_trans; + u64 root_objectid; + char __data[0]; +}; + +struct trace_event_raw_btrfs_get_extent { + struct trace_entry ent; + u8 fsid[16]; + u64 root_objectid; + u64 ino; + u64 start; + u64 len; + u64 orig_start; + u64 block_start; + u64 block_len; + long unsigned int flags; + int refs; + unsigned int compress_type; + char __data[0]; +}; + +struct trace_event_raw_btrfs_handle_em_exist { + struct trace_entry ent; + u8 fsid[16]; + u64 e_start; + u64 e_len; + u64 map_start; + u64 map_len; + u64 start; + u64 len; + char __data[0]; +}; + +struct trace_event_raw_btrfs__file_extent_item_regular { + struct trace_entry ent; + u8 fsid[16]; + u64 root_obj; + u64 ino; + loff_t isize; + u64 disk_isize; + u64 num_bytes; + u64 ram_bytes; + u64 disk_bytenr; + u64 disk_num_bytes; + u64 extent_offset; + u8 extent_type; + u8 compression; + u64 extent_start; + u64 extent_end; + char __data[0]; +}; + +struct trace_event_raw_btrfs__file_extent_item_inline { + struct trace_entry ent; + u8 fsid[16]; + u64 root_obj; + u64 ino; + loff_t isize; + u64 disk_isize; + u8 extent_type; + u8 compression; + u64 extent_start; + u64 extent_end; + char __data[0]; +}; + +struct trace_event_raw_btrfs__ordered_extent { + struct trace_entry ent; + u8 fsid[16]; + u64 ino; + u64 file_offset; + u64 start; + u64 len; + u64 disk_len; + u64 bytes_left; + long unsigned int flags; + int compress_type; + int refs; + u64 root_objectid; + u64 truncated_len; + char __data[0]; +}; + +struct trace_event_raw_btrfs__writepage { + struct trace_entry ent; + u8 fsid[16]; + u64 ino; + long unsigned int index; + long int nr_to_write; + long int pages_skipped; + loff_t range_start; + loff_t range_end; + char for_kupdate; + char for_reclaim; + char range_cyclic; + long unsigned int writeback_index; + u64 root_objectid; + char __data[0]; +}; + +struct trace_event_raw_btrfs_writepage_end_io_hook { + struct trace_entry ent; + u8 fsid[16]; + u64 ino; + long unsigned int index; + u64 start; + u64 end; + int uptodate; + u64 root_objectid; + char __data[0]; +}; + +struct trace_event_raw_btrfs_sync_file { + struct trace_entry ent; + u8 fsid[16]; + u64 ino; + u64 parent; + int datasync; + u64 root_objectid; + char __data[0]; +}; + +struct trace_event_raw_btrfs_sync_fs { + struct trace_entry ent; + u8 fsid[16]; + int wait; + char __data[0]; +}; + +struct trace_event_raw_btrfs_add_block_group { + struct trace_entry ent; + u8 fsid[16]; + u64 offset; + u64 size; + u64 flags; + u64 bytes_used; + u64 bytes_super; + int create; + char __data[0]; +}; + +struct trace_event_raw_btrfs_delayed_tree_ref { + struct trace_entry ent; + u8 fsid[16]; + u64 bytenr; + u64 num_bytes; + int action; + u64 parent; + u64 ref_root; + int level; + int type; + u64 seq; + char __data[0]; +}; + +struct trace_event_raw_btrfs_delayed_data_ref { + struct trace_entry ent; + u8 fsid[16]; + u64 bytenr; + u64 num_bytes; + int action; + u64 parent; + u64 ref_root; + u64 owner; + u64 offset; + int type; + u64 seq; + char __data[0]; +}; + +struct trace_event_raw_btrfs_delayed_ref_head { + struct trace_entry ent; + u8 fsid[16]; + u64 bytenr; + u64 num_bytes; + int action; + int is_data; + char __data[0]; +}; + +struct trace_event_raw_btrfs__chunk { + struct trace_entry ent; + u8 fsid[16]; + int num_stripes; + u64 type; + int sub_stripes; + u64 offset; + u64 size; + u64 root_objectid; + char __data[0]; +}; + +struct trace_event_raw_btrfs_cow_block { + struct trace_entry ent; + u8 fsid[16]; + u64 root_objectid; + u64 buf_start; + int refs; + u64 cow_start; + int buf_level; + int cow_level; + char __data[0]; +}; + +struct trace_event_raw_btrfs_space_reservation { + struct trace_entry ent; + u8 fsid[16]; + u32 __data_loc_type; + u64 val; + u64 bytes; + int reserve; + char __data[0]; +}; + +struct trace_event_raw_btrfs_trigger_flush { + struct trace_entry ent; + u8 fsid[16]; + u64 flags; + u64 bytes; + int flush; + u32 __data_loc_reason; + char __data[0]; +}; + +struct trace_event_raw_btrfs_flush_space { + struct trace_entry ent; + u8 fsid[16]; + u64 flags; + u64 num_bytes; + int state; + int ret; + char __data[0]; +}; + +struct trace_event_raw_btrfs__reserved_extent { + struct trace_entry ent; + u8 fsid[16]; + u64 start; + u64 len; + char __data[0]; +}; + +struct trace_event_raw_find_free_extent { + struct trace_entry ent; + u8 fsid[16]; + u64 root_objectid; + u64 num_bytes; + u64 empty_size; + u64 data; + char __data[0]; +}; + +struct trace_event_raw_btrfs__reserve_extent { + struct trace_entry ent; + u8 fsid[16]; + u64 bg_objectid; + u64 flags; + u64 start; + u64 len; + char __data[0]; +}; + +struct trace_event_raw_btrfs_find_cluster { + struct trace_entry ent; + u8 fsid[16]; + u64 bg_objectid; + u64 flags; + u64 start; + u64 bytes; + u64 empty_size; + u64 min_bytes; + char __data[0]; +}; + +struct trace_event_raw_btrfs_failed_cluster_setup { + struct trace_entry ent; + u8 fsid[16]; + u64 bg_objectid; + char __data[0]; +}; + +struct trace_event_raw_btrfs_setup_cluster { + struct trace_entry ent; + u8 fsid[16]; + u64 bg_objectid; + u64 flags; + u64 start; + u64 max_size; + u64 size; + int bitmap; + char __data[0]; +}; + +struct trace_event_raw_alloc_extent_state { + struct trace_entry ent; + const struct extent_state *state; + gfp_t mask; + const void *ip; + char __data[0]; +}; + +struct trace_event_raw_free_extent_state { + struct trace_entry ent; + const struct extent_state *state; + const void *ip; + char __data[0]; +}; + +struct trace_event_raw_btrfs__work { + struct trace_entry ent; + u8 fsid[16]; + const void *work; + const void *wq; + const void *func; + const void *ordered_func; + const void *ordered_free; + const void *normal_work; + char __data[0]; +}; + +struct trace_event_raw_btrfs__work__done { + struct trace_entry ent; + u8 fsid[16]; + const void *wtag; + char __data[0]; +}; + +struct trace_event_raw_btrfs__workqueue { + struct trace_entry ent; + u8 fsid[16]; + const void *wq; + u32 __data_loc_name; + int high; + char __data[0]; +}; + +struct trace_event_raw_btrfs__workqueue_done { + struct trace_entry ent; + u8 fsid[16]; + const void *wq; + char __data[0]; +}; + +struct trace_event_raw_btrfs__qgroup_rsv_data { + struct trace_entry ent; + u8 fsid[16]; + u64 rootid; + u64 ino; + u64 start; + u64 len; + u64 reserved; + int op; + char __data[0]; +}; + +struct trace_event_raw_btrfs_qgroup_extent { + struct trace_entry ent; + u8 fsid[16]; + u64 bytenr; + u64 num_bytes; + char __data[0]; +}; + +struct trace_event_raw_qgroup_num_dirty_extents { + struct trace_entry ent; + u8 fsid[16]; + u64 transid; + u64 num_dirty_extents; + char __data[0]; +}; + +struct trace_event_raw_btrfs_qgroup_account_extent { + struct trace_entry ent; + u8 fsid[16]; + u64 transid; + u64 bytenr; + u64 num_bytes; + u64 nr_old_roots; + u64 nr_new_roots; + char __data[0]; +}; + +struct trace_event_raw_qgroup_update_counters { + struct trace_entry ent; + u8 fsid[16]; + u64 qgid; + u64 old_rfer; + u64 old_excl; + u64 cur_old_count; + u64 cur_new_count; + char __data[0]; +}; + +struct trace_event_raw_qgroup_update_reserve { + struct trace_entry ent; + u8 fsid[16]; + u64 qgid; + u64 cur_reserved; + s64 diff; + int type; + char __data[0]; +}; + +struct trace_event_raw_qgroup_meta_reserve { + struct trace_entry ent; + u8 fsid[16]; + u64 refroot; + s64 diff; + int type; + char __data[0]; +}; + +struct trace_event_raw_qgroup_meta_convert { + struct trace_entry ent; + u8 fsid[16]; + u64 refroot; + s64 diff; + char __data[0]; +}; + +struct trace_event_raw_qgroup_meta_free_all_pertrans { + struct trace_entry ent; + u8 fsid[16]; + u64 refroot; + s64 diff; + int type; + char __data[0]; +}; + +struct trace_event_raw_btrfs__prelim_ref { + struct trace_entry ent; + u8 fsid[16]; + u64 root_id; + u64 objectid; + u8 type; + u64 offset; + int level; + int old_count; + u64 parent; + u64 bytenr; + int mod_count; + u64 tree_size; + char __data[0]; +}; + +struct trace_event_raw_btrfs_inode_mod_outstanding_extents { + struct trace_entry ent; + u8 fsid[16]; + u64 root_objectid; + u64 ino; + int mod; + char __data[0]; +}; + +struct trace_event_raw_btrfs__block_group { + struct trace_entry ent; + u8 fsid[16]; + u64 bytenr; + u64 len; + u64 used; + u64 flags; + char __data[0]; +}; + +struct trace_event_raw_btrfs_set_extent_bit { + struct trace_entry ent; + u8 fsid[16]; + unsigned int owner; + u64 ino; + u64 rootid; + u64 start; + u64 len; + unsigned int set_bits; + char __data[0]; +}; + +struct trace_event_raw_btrfs_clear_extent_bit { + struct trace_entry ent; + u8 fsid[16]; + unsigned int owner; + u64 ino; + u64 rootid; + u64 start; + u64 len; + unsigned int clear_bits; + char __data[0]; +}; + +struct trace_event_raw_btrfs_convert_extent_bit { + struct trace_entry ent; + u8 fsid[16]; + unsigned int owner; + u64 ino; + u64 rootid; + u64 start; + u64 len; + unsigned int set_bits; + unsigned int clear_bits; + char __data[0]; +}; + +struct trace_event_raw_btrfs_sleep_tree_lock { + struct trace_entry ent; + u8 fsid[16]; + u64 block; + u64 generation; + u64 start_ns; + u64 end_ns; + u64 diff_ns; + u64 owner; + int is_log_tree; + char __data[0]; +}; + +struct trace_event_raw_btrfs_locking_events { + struct trace_entry ent; + u8 fsid[16]; + u64 block; + u64 generation; + u64 owner; + int is_log_tree; + char __data[0]; +}; + +struct trace_event_raw_btrfs__space_info_update { + struct trace_entry ent; + u8 fsid[16]; + u64 type; + u64 old; + s64 diff; + char __data[0]; +}; + +struct trace_event_data_offsets_btrfs_transaction_commit {}; + +struct trace_event_data_offsets_btrfs__inode {}; + +struct trace_event_data_offsets_btrfs_get_extent {}; + +struct trace_event_data_offsets_btrfs_handle_em_exist {}; + +struct trace_event_data_offsets_btrfs__file_extent_item_regular {}; + +struct trace_event_data_offsets_btrfs__file_extent_item_inline {}; + +struct trace_event_data_offsets_btrfs__ordered_extent {}; + +struct trace_event_data_offsets_btrfs__writepage {}; + +struct trace_event_data_offsets_btrfs_writepage_end_io_hook {}; + +struct trace_event_data_offsets_btrfs_sync_file {}; + +struct trace_event_data_offsets_btrfs_sync_fs {}; + +struct trace_event_data_offsets_btrfs_add_block_group {}; + +struct trace_event_data_offsets_btrfs_delayed_tree_ref {}; + +struct trace_event_data_offsets_btrfs_delayed_data_ref {}; + +struct trace_event_data_offsets_btrfs_delayed_ref_head {}; + +struct trace_event_data_offsets_btrfs__chunk {}; + +struct trace_event_data_offsets_btrfs_cow_block {}; + +struct trace_event_data_offsets_btrfs_space_reservation { + u32 type; +}; + +struct trace_event_data_offsets_btrfs_trigger_flush { + u32 reason; +}; + +struct trace_event_data_offsets_btrfs_flush_space {}; + +struct trace_event_data_offsets_btrfs__reserved_extent {}; + +struct trace_event_data_offsets_find_free_extent {}; + +struct trace_event_data_offsets_btrfs__reserve_extent {}; + +struct trace_event_data_offsets_btrfs_find_cluster {}; + +struct trace_event_data_offsets_btrfs_failed_cluster_setup {}; + +struct trace_event_data_offsets_btrfs_setup_cluster {}; + +struct trace_event_data_offsets_alloc_extent_state {}; + +struct trace_event_data_offsets_free_extent_state {}; + +struct trace_event_data_offsets_btrfs__work {}; + +struct trace_event_data_offsets_btrfs__work__done {}; + +struct trace_event_data_offsets_btrfs__workqueue { + u32 name; +}; + +struct trace_event_data_offsets_btrfs__workqueue_done {}; + +struct trace_event_data_offsets_btrfs__qgroup_rsv_data {}; + +struct trace_event_data_offsets_btrfs_qgroup_extent {}; + +struct trace_event_data_offsets_qgroup_num_dirty_extents {}; + +struct trace_event_data_offsets_btrfs_qgroup_account_extent {}; + +struct trace_event_data_offsets_qgroup_update_counters {}; + +struct trace_event_data_offsets_qgroup_update_reserve {}; + +struct trace_event_data_offsets_qgroup_meta_reserve {}; + +struct trace_event_data_offsets_qgroup_meta_convert {}; + +struct trace_event_data_offsets_qgroup_meta_free_all_pertrans {}; + +struct trace_event_data_offsets_btrfs__prelim_ref {}; + +struct trace_event_data_offsets_btrfs_inode_mod_outstanding_extents {}; + +struct trace_event_data_offsets_btrfs__block_group {}; + +struct trace_event_data_offsets_btrfs_set_extent_bit {}; + +struct trace_event_data_offsets_btrfs_clear_extent_bit {}; + +struct trace_event_data_offsets_btrfs_convert_extent_bit {}; + +struct trace_event_data_offsets_btrfs_sleep_tree_lock {}; + +struct trace_event_data_offsets_btrfs_locking_events {}; + +struct trace_event_data_offsets_btrfs__space_info_update {}; + +typedef void (*btf_trace_btrfs_transaction_commit)(void *, const struct btrfs_root *); + +typedef void (*btf_trace_btrfs_inode_new)(void *, const struct inode *); + +typedef void (*btf_trace_btrfs_inode_request)(void *, const struct inode *); + +typedef void (*btf_trace_btrfs_inode_evict)(void *, const struct inode *); + +typedef void (*btf_trace_btrfs_get_extent)(void *, const struct btrfs_root *, const struct btrfs_inode *, const struct extent_map *); + +typedef void (*btf_trace_btrfs_handle_em_exist)(void *, const struct btrfs_fs_info *, const struct extent_map *, const struct extent_map *, u64, u64); + +typedef void (*btf_trace_btrfs_get_extent_show_fi_regular)(void *, const struct btrfs_inode *, const struct extent_buffer *, const struct btrfs_file_extent_item *, u64); + +typedef void (*btf_trace_btrfs_truncate_show_fi_regular)(void *, const struct btrfs_inode *, const struct extent_buffer *, const struct btrfs_file_extent_item *, u64); + +typedef void (*btf_trace_btrfs_get_extent_show_fi_inline)(void *, const struct btrfs_inode *, const struct extent_buffer *, const struct btrfs_file_extent_item *, int, u64); + +typedef void (*btf_trace_btrfs_truncate_show_fi_inline)(void *, const struct btrfs_inode *, const struct extent_buffer *, const struct btrfs_file_extent_item *, int, u64); + +typedef void (*btf_trace_btrfs_ordered_extent_add)(void *, const struct btrfs_inode *, const struct btrfs_ordered_extent *); + +typedef void (*btf_trace_btrfs_ordered_extent_remove)(void *, const struct btrfs_inode *, const struct btrfs_ordered_extent *); + +typedef void (*btf_trace_btrfs_ordered_extent_start)(void *, const struct btrfs_inode *, const struct btrfs_ordered_extent *); + +typedef void (*btf_trace_btrfs_ordered_extent_put)(void *, const struct btrfs_inode *, const struct btrfs_ordered_extent *); + +typedef void (*btf_trace___extent_writepage)(void *, const struct page *, const struct inode *, const struct writeback_control *); + +typedef void (*btf_trace_btrfs_writepage_end_io_hook)(void *, const struct page *, u64, u64, int); + +typedef void (*btf_trace_btrfs_sync_file)(void *, const struct file *, int); + +typedef void (*btf_trace_btrfs_sync_fs)(void *, const struct btrfs_fs_info *, int); + +typedef void (*btf_trace_btrfs_add_block_group)(void *, const struct btrfs_fs_info *, const struct btrfs_block_group *, int); + +typedef void (*btf_trace_add_delayed_tree_ref)(void *, const struct btrfs_fs_info *, const struct btrfs_delayed_ref_node *, const struct btrfs_delayed_tree_ref *, int); + +typedef void (*btf_trace_run_delayed_tree_ref)(void *, const struct btrfs_fs_info *, const struct btrfs_delayed_ref_node *, const struct btrfs_delayed_tree_ref *, int); + +typedef void (*btf_trace_add_delayed_data_ref)(void *, const struct btrfs_fs_info *, const struct btrfs_delayed_ref_node *, const struct btrfs_delayed_data_ref *, int); + +typedef void (*btf_trace_run_delayed_data_ref)(void *, const struct btrfs_fs_info *, const struct btrfs_delayed_ref_node *, const struct btrfs_delayed_data_ref *, int); + +typedef void (*btf_trace_add_delayed_ref_head)(void *, const struct btrfs_fs_info *, const struct btrfs_delayed_ref_head *, int); + +typedef void (*btf_trace_run_delayed_ref_head)(void *, const struct btrfs_fs_info *, const struct btrfs_delayed_ref_head *, int); + +typedef void (*btf_trace_btrfs_chunk_alloc)(void *, const struct btrfs_fs_info *, const struct map_lookup *, u64, u64); + +typedef void (*btf_trace_btrfs_chunk_free)(void *, const struct btrfs_fs_info *, const struct map_lookup *, u64, u64); + +typedef void (*btf_trace_btrfs_cow_block)(void *, const struct btrfs_root *, const struct extent_buffer *, const struct extent_buffer *); + +typedef void (*btf_trace_btrfs_space_reservation)(void *, const struct btrfs_fs_info *, const char *, u64, u64, int); + +typedef void (*btf_trace_btrfs_trigger_flush)(void *, const struct btrfs_fs_info *, u64, u64, int, const char *); + +typedef void (*btf_trace_btrfs_flush_space)(void *, const struct btrfs_fs_info *, u64, u64, int, int); + +typedef void (*btf_trace_btrfs_reserved_extent_alloc)(void *, const struct btrfs_fs_info *, u64, u64); + +typedef void (*btf_trace_btrfs_reserved_extent_free)(void *, const struct btrfs_fs_info *, u64, u64); + +typedef void (*btf_trace_find_free_extent)(void *, const struct btrfs_root *, u64, u64, u64); + +typedef void (*btf_trace_btrfs_reserve_extent)(void *, const struct btrfs_block_group *, u64, u64); + +typedef void (*btf_trace_btrfs_reserve_extent_cluster)(void *, const struct btrfs_block_group *, u64, u64); + +typedef void (*btf_trace_btrfs_find_cluster)(void *, const struct btrfs_block_group *, u64, u64, u64, u64); + +typedef void (*btf_trace_btrfs_failed_cluster_setup)(void *, const struct btrfs_block_group *); + +typedef void (*btf_trace_btrfs_setup_cluster)(void *, const struct btrfs_block_group *, const struct btrfs_free_cluster *, u64, int); + +typedef void (*btf_trace_alloc_extent_state)(void *, const struct extent_state *, gfp_t, long unsigned int); + +typedef void (*btf_trace_free_extent_state)(void *, const struct extent_state *, long unsigned int); + +typedef void (*btf_trace_btrfs_work_queued)(void *, const struct btrfs_work *); + +typedef void (*btf_trace_btrfs_work_sched)(void *, const struct btrfs_work *); + +typedef void (*btf_trace_btrfs_all_work_done)(void *, const struct btrfs_fs_info *, const void *); + +typedef void (*btf_trace_btrfs_ordered_sched)(void *, const struct btrfs_work *); + +typedef void (*btf_trace_btrfs_workqueue_alloc)(void *, const struct __btrfs_workqueue *, const char *, int); + +typedef void (*btf_trace_btrfs_workqueue_destroy)(void *, const struct __btrfs_workqueue *); + +typedef void (*btf_trace_btrfs_qgroup_reserve_data)(void *, const struct inode *, u64, u64, u64, int); + +typedef void (*btf_trace_btrfs_qgroup_release_data)(void *, const struct inode *, u64, u64, u64, int); + +typedef void (*btf_trace_btrfs_qgroup_account_extents)(void *, const struct btrfs_fs_info *, const struct btrfs_qgroup_extent_record *); + +typedef void (*btf_trace_btrfs_qgroup_trace_extent)(void *, const struct btrfs_fs_info *, const struct btrfs_qgroup_extent_record *); + +typedef void (*btf_trace_qgroup_num_dirty_extents)(void *, const struct btrfs_fs_info *, u64, u64); + +typedef void (*btf_trace_btrfs_qgroup_account_extent)(void *, const struct btrfs_fs_info *, u64, u64, u64, u64, u64); + +typedef void (*btf_trace_qgroup_update_counters)(void *, const struct btrfs_fs_info *, const struct btrfs_qgroup *, u64, u64); + +typedef void (*btf_trace_qgroup_update_reserve)(void *, struct btrfs_fs_info *, struct btrfs_qgroup *, s64, int); + +typedef void (*btf_trace_qgroup_meta_reserve)(void *, struct btrfs_root *, s64, int); + +typedef void (*btf_trace_qgroup_meta_convert)(void *, struct btrfs_root *, s64); + +typedef void (*btf_trace_qgroup_meta_free_all_pertrans)(void *, struct btrfs_root *); + +typedef void (*btf_trace_btrfs_prelim_ref_merge)(void *, const struct btrfs_fs_info *, const struct prelim_ref *, const struct prelim_ref *, u64); + +typedef void (*btf_trace_btrfs_prelim_ref_insert)(void *, const struct btrfs_fs_info *, const struct prelim_ref *, const struct prelim_ref *, u64); + +typedef void (*btf_trace_btrfs_inode_mod_outstanding_extents)(void *, const struct btrfs_root *, u64, int); + +typedef void (*btf_trace_btrfs_remove_block_group)(void *, const struct btrfs_block_group *); + +typedef void (*btf_trace_btrfs_add_unused_block_group)(void *, const struct btrfs_block_group *); + +typedef void (*btf_trace_btrfs_skip_unused_block_group)(void *, const struct btrfs_block_group *); + +typedef void (*btf_trace_btrfs_set_extent_bit)(void *, const struct extent_io_tree *, u64, u64, unsigned int); + +typedef void (*btf_trace_btrfs_clear_extent_bit)(void *, const struct extent_io_tree *, u64, u64, unsigned int); + +typedef void (*btf_trace_btrfs_convert_extent_bit)(void *, const struct extent_io_tree *, u64, u64, unsigned int, unsigned int); + +typedef void (*btf_trace_btrfs_tree_read_lock)(void *, const struct extent_buffer *, u64); + +typedef void (*btf_trace_btrfs_tree_lock)(void *, const struct extent_buffer *, u64); + +typedef void (*btf_trace_btrfs_tree_unlock)(void *, const struct extent_buffer *); + +typedef void (*btf_trace_btrfs_tree_read_unlock)(void *, const struct extent_buffer *); + +typedef void (*btf_trace_btrfs_tree_read_unlock_blocking)(void *, const struct extent_buffer *); + +typedef void (*btf_trace_btrfs_set_lock_blocking_read)(void *, const struct extent_buffer *); + +typedef void (*btf_trace_btrfs_set_lock_blocking_write)(void *, const struct extent_buffer *); + +typedef void (*btf_trace_btrfs_try_tree_read_lock)(void *, const struct extent_buffer *); + +typedef void (*btf_trace_btrfs_try_tree_write_lock)(void *, const struct extent_buffer *); + +typedef void (*btf_trace_btrfs_tree_read_lock_atomic)(void *, const struct extent_buffer *); + +typedef void (*btf_trace_update_bytes_may_use)(void *, const struct btrfs_fs_info *, const struct btrfs_space_info *, u64, s64); + +typedef void (*btf_trace_update_bytes_pinned)(void *, const struct btrfs_fs_info *, const struct btrfs_space_info *, u64, s64); + +enum { + Opt_acl___3 = 0, + Opt_noacl___2 = 1, + Opt_clear_cache = 2, + Opt_commit_interval = 3, + Opt_compress = 4, + Opt_compress_force = 5, + Opt_compress_force_type = 6, + Opt_compress_type = 7, + Opt_degraded = 8, + Opt_device = 9, + Opt_fatal_errors = 10, + Opt_flushoncommit = 11, + Opt_noflushoncommit = 12, + Opt_inode_cache = 13, + Opt_noinode_cache = 14, + Opt_max_inline = 15, + Opt_barrier___2 = 16, + Opt_nobarrier___2 = 17, + Opt_datacow = 18, + Opt_nodatacow = 19, + Opt_datasum = 20, + Opt_nodatasum = 21, + Opt_defrag = 22, + Opt_nodefrag = 23, + Opt_discard___2 = 24, + Opt_nodiscard___2 = 25, + Opt_discard_mode = 26, + Opt_norecovery = 27, + Opt_ratio = 28, + Opt_rescan_uuid_tree = 29, + Opt_skip_balance = 30, + Opt_space_cache = 31, + Opt_no_space_cache = 32, + Opt_space_cache_version = 33, + Opt_ssd = 34, + Opt_nossd = 35, + Opt_ssd_spread = 36, + Opt_nossd_spread = 37, + Opt_subvol = 38, + Opt_subvol_empty = 39, + Opt_subvolid = 40, + Opt_thread_pool = 41, + Opt_treelog = 42, + Opt_notreelog = 43, + Opt_user_subvol_rm_allowed = 44, + Opt_rescue = 45, + Opt_usebackuproot = 46, + Opt_nologreplay = 47, + Opt_recovery = 48, + Opt_check_integrity = 49, + Opt_check_integrity_including_extent_data = 50, + Opt_check_integrity_print_mask = 51, + Opt_enospc_debug = 52, + Opt_noenospc_debug = 53, + Opt_err___7 = 54, +}; + +enum btrfs_csum_type { + BTRFS_CSUM_TYPE_CRC32 = 0, + BTRFS_CSUM_TYPE_XXHASH = 1, + BTRFS_CSUM_TYPE_SHA256 = 2, + BTRFS_CSUM_TYPE_BLAKE2 = 3, +}; + +enum { + EXTENT_BUFFER_UPTODATE = 0, + EXTENT_BUFFER_DIRTY = 1, + EXTENT_BUFFER_CORRUPT = 2, + EXTENT_BUFFER_READAHEAD = 3, + EXTENT_BUFFER_TREE_REF = 4, + EXTENT_BUFFER_STALE = 5, + EXTENT_BUFFER_WRITEBACK = 6, + EXTENT_BUFFER_READ_ERR = 7, + EXTENT_BUFFER_UNMAPPED = 8, + EXTENT_BUFFER_IN_TREE = 9, + EXTENT_BUFFER_WRITE_ERR = 10, +}; + +struct btrfs_key_ptr { + struct btrfs_disk_key key; + __le64 blockptr; + __le64 generation; +} __attribute__((packed)); + +enum { + READA_NONE = 0, + READA_BACK = 1, + READA_FORWARD = 2, +}; + +struct seq_list { + struct list_head list; + u64 seq; +}; + +enum { + BTRFS_ROOT_IN_TRANS_SETUP = 0, + BTRFS_ROOT_SHAREABLE = 1, + BTRFS_ROOT_TRACK_DIRTY = 2, + BTRFS_ROOT_IN_RADIX = 3, + BTRFS_ROOT_ORPHAN_ITEM_INSERTED = 4, + BTRFS_ROOT_DEFRAG_RUNNING = 5, + BTRFS_ROOT_FORCE_COW = 6, + BTRFS_ROOT_MULTI_LOG_TASKS = 7, + BTRFS_ROOT_DIRTY = 8, + BTRFS_ROOT_DELETING = 9, + BTRFS_ROOT_DEAD_RELOC_TREE = 10, + BTRFS_ROOT_DEAD_TREE = 11, + BTRFS_ROOT_HAS_LOG_TREE = 12, + BTRFS_ROOT_QGROUP_FLUSHING = 13, +}; + +struct btrfs_map_token { + struct extent_buffer *eb; + char *kaddr; + long unsigned int offset; +}; + +struct btrfs_csums { + u16 size; + const char name[10]; + const char driver[12]; +}; + +enum mod_log_op { + MOD_LOG_KEY_REPLACE = 0, + MOD_LOG_KEY_ADD = 1, + MOD_LOG_KEY_REMOVE = 2, + MOD_LOG_KEY_REMOVE_WHILE_FREEING = 3, + MOD_LOG_KEY_REMOVE_WHILE_MOVING = 4, + MOD_LOG_MOVE_KEYS = 5, + MOD_LOG_ROOT_REPLACE = 6, +}; + +struct tree_mod_root { + u64 logical; + u8 level; +}; + +struct tree_mod_elem { + struct rb_node node; + u64 logical; + u64 seq; + enum mod_log_op op; + int slot; + u64 generation; + struct btrfs_disk_key key; + u64 blockptr; + struct { + int dst_slot; + int nr_items; + } move; + struct tree_mod_root old_root; +}; + +struct btrfs_extent_item { + __le64 refs; + __le64 generation; + __le64 flags; +}; + +struct btrfs_tree_block_info { + struct btrfs_disk_key key; + __u8 level; +} __attribute__((packed)); + +struct btrfs_extent_data_ref { + __le64 root; + __le64 objectid; + __le64 offset; + __le32 count; +} __attribute__((packed)); + +struct btrfs_shared_data_ref { + __le32 count; +}; + +struct btrfs_extent_inline_ref { + __u8 type; + __le64 offset; +} __attribute__((packed)); + +enum btrfs_inline_ref_type { + BTRFS_REF_TYPE_INVALID = 0, + BTRFS_REF_TYPE_BLOCK = 1, + BTRFS_REF_TYPE_DATA = 2, + BTRFS_REF_TYPE_ANY = 3, +}; + +enum btrfs_ref_type { + BTRFS_REF_NOT_SET = 0, + BTRFS_REF_DATA = 1, + BTRFS_REF_METADATA = 2, + BTRFS_REF_LAST = 3, +}; + +struct btrfs_data_ref { + u64 ref_root; + u64 ino; + u64 offset; +}; + +struct btrfs_tree_ref { + int level; + u64 root; +}; + +struct btrfs_ref { + enum btrfs_ref_type type; + int action; + bool skip_qgroup; + u64 real_root; + u64 bytenr; + u64 len; + u64 parent; + union { + struct btrfs_data_ref data_ref; + struct btrfs_tree_ref tree_ref; + }; +}; + +struct btrfs_bio { + refcount_t refs; + atomic_t stripes_pending; + struct btrfs_fs_info *fs_info; + u64 map_type; + bio_end_io_t *end_io; + struct bio *orig_bio; + void *private; + atomic_t error; + int max_errors; + int num_stripes; + int mirror_num; + int num_tgtdevs; + int *tgtdev_map; + u64 *raid_map; + struct btrfs_bio_stripe stripes[0]; +}; + +enum btrfs_map_op { + BTRFS_MAP_READ = 0, + BTRFS_MAP_WRITE = 1, + BTRFS_MAP_DISCARD = 2, + BTRFS_MAP_GET_READ_MIRRORS = 3, +}; + +enum btrfs_chunk_alloc_enum { + CHUNK_ALLOC_NO_FORCE = 0, + CHUNK_ALLOC_LIMITED = 1, + CHUNK_ALLOC_FORCE = 2, +}; + +enum btrfs_loop_type { + LOOP_CACHING_NOWAIT = 0, + LOOP_CACHING_WAIT = 1, + LOOP_ALLOC_CHUNK = 2, + LOOP_NO_EMPTY_SIZE = 3, +}; + +enum btrfs_extent_allocation_policy { + BTRFS_EXTENT_ALLOC_CLUSTERED = 0, +}; + +struct find_free_extent_ctl { + u64 num_bytes; + u64 empty_size; + u64 flags; + int delalloc; + u64 search_start; + u64 empty_cluster; + struct btrfs_free_cluster *last_ptr; + bool use_cluster; + bool have_caching_bg; + bool orig_have_caching_bg; + int index; + int loop; + bool retry_clustered; + bool retry_unclustered; + int cached; + u64 max_extent_size; + u64 total_free_space; + u64 found_offset; + u64 hint_byte; + enum btrfs_extent_allocation_policy policy; +}; + +struct walk_control { + u64 refs[8]; + u64 flags[8]; + struct btrfs_key update_progress; + struct btrfs_key drop_progress; + short: 16; + int drop_level; + int stage; + int level; + int shared_level; + int update_ref; + int keep_locks; + int reada_slot; + int reada_count; + int restarted; +} __attribute__((packed)); + +struct btrfs_stripe { + __le64 devid; + __le64 offset; + __u8 dev_uuid[16]; +}; + +struct btrfs_chunk { + __le64 length; + __le64 owner; + __le64 stripe_len; + __le64 type; + __le32 io_align; + __le32 io_width; + __le32 sector_size; + __le16 num_stripes; + __le16 sub_stripes; + struct btrfs_stripe stripe; +}; + +struct btrfs_dev_extent { + __le64 chunk_tree; + __le64 chunk_objectid; + __le64 chunk_offset; + __le64 length; + __u8 chunk_tree_uuid[16]; +}; + +struct btrfs_block_group_item { + __le64 used; + __le64 chunk_objectid; + __le64 flags; +}; + +struct root_name_map { + u64 id; + char name[16]; +}; + +struct btrfs_csum_item { + __u8 csum; +}; + +struct btrfs_ordered_sum { + u64 bytenr; + int len; + struct list_head list; + u8 sums[0]; +}; + +struct btrfs_io_bio { + unsigned int mirror_num; + struct btrfs_device *device; + u64 logical; + u8 *csum; + u8 csum_inline[64]; + struct bvec_iter iter; + struct bio bio; +}; + +struct btrfs_inode_extref { + __le64 parent_objectid; + __le64 index; + __le16 name_len; + __u8 name[0]; +} __attribute__((packed)); + +struct extent_changeset { + unsigned int bytes_changed; + struct ulist range_changed; +}; + +struct shash_alg { + int (*init)(struct shash_desc *); + int (*update)(struct shash_desc *, const u8 *, unsigned int); + int (*final)(struct shash_desc *, u8 *); + int (*finup)(struct shash_desc *, const u8 *, unsigned int, u8 *); + int (*digest)(struct shash_desc *, const u8 *, unsigned int, u8 *); + int (*export)(struct shash_desc *, void *); + int (*import)(struct shash_desc *, const void *); + int (*setkey)(struct crypto_shash *, const u8 *, unsigned int); + int (*init_tfm)(struct crypto_shash *); + void (*exit_tfm)(struct crypto_shash *); + unsigned int descsize; + int: 32; + unsigned int digestsize; + unsigned int statesize; + struct crypto_alg base; +}; + +typedef blk_status_t extent_submit_bio_start_t(void *, struct bio *, u64); + +enum { + BTRFS_BLOCK_RSV_GLOBAL = 0, + BTRFS_BLOCK_RSV_DELALLOC = 1, + BTRFS_BLOCK_RSV_TRANS = 2, + BTRFS_BLOCK_RSV_CHUNK = 3, + BTRFS_BLOCK_RSV_DELOPS = 4, + BTRFS_BLOCK_RSV_DELREFS = 5, + BTRFS_BLOCK_RSV_EMPTY = 6, + BTRFS_BLOCK_RSV_TEMP = 7, +}; + +enum btrfs_wq_endio_type { + BTRFS_WQ_ENDIO_DATA = 0, + BTRFS_WQ_ENDIO_METADATA = 1, + BTRFS_WQ_ENDIO_FREE_SPACE = 2, + BTRFS_WQ_ENDIO_RAID56 = 3, +}; + +enum { + BTRFS_INODE_FLUSH_ON_CLOSE = 0, + BTRFS_INODE_DUMMY = 1, + BTRFS_INODE_IN_DEFRAG = 2, + BTRFS_INODE_HAS_ASYNC_EXTENT = 3, + BTRFS_INODE_NEEDS_FULL_SYNC = 4, + BTRFS_INODE_COPY_EVERYTHING = 5, + BTRFS_INODE_IN_DELALLOC_LIST = 6, + BTRFS_INODE_HAS_PROPS = 7, + BTRFS_INODE_SNAPSHOT_FLUSH = 8, +}; + +enum btrfs_disk_cache_state { + BTRFS_DC_WRITTEN = 0, + BTRFS_DC_ERROR = 1, + BTRFS_DC_CLEAR = 2, + BTRFS_DC_SETUP = 3, +}; + +struct btrfs_end_io_wq { + struct bio *bio; + bio_end_io_t *end_io; + void *private; + struct btrfs_fs_info *info; + blk_status_t status; + enum btrfs_wq_endio_type metadata; + struct btrfs_work work; +}; + +struct async_submit_bio { + void *private_data; + struct bio *bio; + extent_submit_bio_start_t *submit_bio_start; + int mirror_num; + u64 bio_offset; + struct btrfs_work work; + blk_status_t status; +}; + +struct btrfs_qgroup_limit { + __u64 flags; + __u64 max_rfer; + __u64 max_excl; + __u64 rsv_rfer; + __u64 rsv_excl; +}; + +struct btrfs_qgroup_inherit { + __u64 flags; + __u64 num_qgroups; + __u64 num_ref_copies; + __u64 num_excl_copies; + struct btrfs_qgroup_limit lim; + __u64 qgroups[0]; +}; + +struct btrfs_pending_snapshot { + struct dentry *dentry; + struct inode *dir; + struct btrfs_root *root; + struct btrfs_root_item *root_item; + struct btrfs_root *snap; + struct btrfs_qgroup_inherit *inherit; + struct btrfs_path *path; + struct btrfs_block_rsv block_rsv; + int error; + dev_t anon_dev; + bool readonly; + struct list_head list; +}; + +struct btrfs_async_commit { + struct btrfs_trans_handle *newtrans; + struct work_struct work; +}; + +enum btrfs_orphan_cleanup_state { + ORPHAN_CLEANUP_STARTED = 1, + ORPHAN_CLEANUP_DONE = 2, +}; + +struct btrfs_swapfile_pin { + struct rb_node node; + void *ptr; + struct inode *inode; + bool is_block_group; +}; + +enum btrfs_exclusive_operation { + BTRFS_EXCLOP_NONE = 0, + BTRFS_EXCLOP_BALANCE = 1, + BTRFS_EXCLOP_DEV_ADD = 2, + BTRFS_EXCLOP_DEV_REMOVE = 3, + BTRFS_EXCLOP_DEV_REPLACE = 4, + BTRFS_EXCLOP_RESIZE = 5, + BTRFS_EXCLOP_SWAP_ACTIVATE = 6, +}; + +struct btrfs_replace_extent_info { + u64 disk_offset; + u64 disk_len; + u64 data_offset; + u64 data_len; + u64 file_offset; + char *extent_buf; + bool is_new_extent; + int qgroup_reserved; + int insertions; +}; + +struct btrfs_file_private { + void *filldir_buf; +}; + +struct btrfs_dio_private { + struct inode *inode; + u64 logical_offset; + u64 disk_bytenr; + u64 bytes; + refcount_t refs; + struct bio *dio_bio; + u8 csums[0]; +}; + +struct btrfs_io_geometry { + u64 len; + u64 offset; + u64 stripe_len; + u64 stripe_nr; + u64 stripe_offset; + u64 raid56_stripe_offset; +}; + +struct btrfs_iget_args { + u64 ino; + struct btrfs_root *root; +}; + +struct btrfs_dio_data { + u64 reserve; + loff_t length; + ssize_t submitted; + struct extent_changeset *data_reserved; + bool sync; +}; + +struct async_extent { + u64 start; + u64 ram_size; + u64 compressed_size; + struct page **pages; + long unsigned int nr_pages; + int compress_type; + struct list_head list; +}; + +struct async_chunk { + struct inode *inode; + struct page *locked_page; + u64 start; + u64 end; + unsigned int write_flags; + struct list_head extents; + struct cgroup_subsys_state *blkcg_css; + struct btrfs_work work; + atomic_t *pending; +}; + +struct async_cow { + atomic_t num_chunks; + struct async_chunk chunks[0]; +}; + +struct btrfs_writepage_fixup { + struct page *page; + struct inode *inode; + struct btrfs_work work; +}; + +struct dir_entry___2 { + u64 ino; + u64 offset; + unsigned int type; + int name_len; +}; + +struct btrfs_delalloc_work { + struct inode *inode; + struct completion completion; + struct list_head list; + struct btrfs_work work; +}; + +struct btrfs_swap_info { + u64 start; + u64 block_start; + u64 block_len; + u64 lowest_ppage; + u64 highest_ppage; + long unsigned int nr_pages; + int nr_extents; +}; + +struct btrfs_ioctl_defrag_range_args { + __u64 start; + __u64 len; + __u64 flags; + __u32 extent_thresh; + __u32 compress_type; + __u32 unused[4]; +}; + +struct btrfs_log_ctx { + int log_ret; + int log_transid; + bool log_new_dentries; + bool logging_new_name; + struct inode *inode; + struct list_head list; + struct list_head ordered_extents; +}; + +struct inode_defrag { + struct rb_node rb_node; + u64 ino; + u64 transid; + u64 root; + u64 last_offset; + int cycled; +}; + +struct falloc_range { + struct list_head list; + u64 start; + u64 len; +}; + +enum { + RANGE_BOUNDARY_WRITTEN_EXTENT = 0, + RANGE_BOUNDARY_PREALLOC_EXTENT = 1, + RANGE_BOUNDARY_HOLE = 2, +}; + +enum btrfs_feature_set { + FEAT_COMPAT = 0, + FEAT_COMPAT_RO = 1, + FEAT_INCOMPAT = 2, + FEAT_MAX = 3, +}; + +struct btrfs_feature_attr { + struct kobj_attribute kobj_attr; + enum btrfs_feature_set feature_set; + u64 feature_bit; +}; + +struct raid_kobject { + u64 flags; + struct kobject kobj; +}; + +typedef blk_status_t submit_bio_hook_t(struct inode *, struct bio *, int, long unsigned int); + +struct tree_entry { + u64 start; + u64 end; + struct rb_node rb_node; +}; + +struct extent_page_data { + struct bio *bio; + unsigned int extent_locked: 1; + unsigned int sync_io: 1; +}; + +struct fiemap_cache { + u64 offset; + u64 phys; + u64 len; + u32 flags; + bool cached; +}; + +struct btrfs_ioctl_balance_args { + __u64 flags; + __u64 state; + struct btrfs_balance_args data; + struct btrfs_balance_args meta; + struct btrfs_balance_args sys; + struct btrfs_balance_progress stat; + __u64 unused[72]; +}; + +struct btrfs_ioctl_get_dev_stats { + __u64 devid; + __u64 nr_items; + __u64 flags; + __u64 values[5]; + __u64 unused[121]; +}; + +enum btrfs_err_code { + BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1, + BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET = 2, + BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET = 3, + BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET = 4, + BTRFS_ERROR_DEV_TGT_REPLACE = 5, + BTRFS_ERROR_DEV_MISSING_NOT_FOUND = 6, + BTRFS_ERROR_DEV_ONLY_WRITABLE = 7, + BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS = 8, + BTRFS_ERROR_DEV_RAID1C3_MIN_NOT_MET = 9, + BTRFS_ERROR_DEV_RAID1C4_MIN_NOT_MET = 10, +}; + +struct btrfs_disk_balance_args { + __le64 profiles; + union { + __le64 usage; + struct { + __le32 usage_min; + __le32 usage_max; + }; + }; + __le64 devid; + __le64 pstart; + __le64 pend; + __le64 vstart; + __le64 vend; + __le64 target; + __le64 flags; + union { + __le64 limit; + struct { + __le32 limit_min; + __le32 limit_max; + }; + }; + __le32 stripes_min; + __le32 stripes_max; + __le64 unused[6]; +}; + +struct btrfs_balance_item { + __le64 flags; + struct btrfs_disk_balance_args data; + struct btrfs_disk_balance_args meta; + struct btrfs_disk_balance_args sys; + __le64 unused[4]; +}; + +struct btrfs_dev_stats_item { + __le64 values[5]; +}; + +struct alloc_chunk_ctl { + u64 start; + u64 type; + int num_stripes; + int sub_stripes; + int dev_stripes; + int devs_max; + int devs_min; + int devs_increment; + int ncopies; + int nparity; + u64 max_stripe_size; + u64 max_chunk_size; + u64 dev_extent_min; + u64 stripe_size; + u64 chunk_size; + int ndevs; +}; + +struct btrfs_workqueue { + struct __btrfs_workqueue *normal; + struct __btrfs_workqueue *high; +}; + +enum { + WORK_DONE_BIT = 0, + WORK_ORDER_DONE_BIT = 1, + WORK_HIGH_PRIO_BIT = 2, +}; + +struct btrfs_ioctl_qgroup_limit_args { + __u64 qgroupid; + struct btrfs_qgroup_limit lim; +}; + +struct btrfs_ioctl_vol_args_v2 { + __s64 fd; + __u64 transid; + __u64 flags; + union { + struct { + __u64 size; + struct btrfs_qgroup_inherit *qgroup_inherit; + }; + __u64 unused[4]; + }; + union { + char name[4040]; + __u64 devid; + __u64 subvolid; + }; +}; + +struct btrfs_ioctl_scrub_args { + __u64 devid; + __u64 start; + __u64 end; + __u64 flags; + struct btrfs_scrub_progress progress; + __u64 unused[109]; +}; + +struct btrfs_ioctl_dev_replace_start_params { + __u64 srcdevid; + __u64 cont_reading_from_srcdev_mode; + __u8 srcdev_name[1025]; + __u8 tgtdev_name[1025]; +}; + +struct btrfs_ioctl_dev_replace_status_params { + __u64 replace_state; + __u64 progress_1000; + __u64 time_started; + __u64 time_stopped; + __u64 num_write_errors; + __u64 num_uncorrectable_read_errors; +}; + +struct btrfs_ioctl_dev_replace_args { + __u64 cmd; + __u64 result; + union { + struct btrfs_ioctl_dev_replace_start_params start; + struct btrfs_ioctl_dev_replace_status_params status; + }; + __u64 spare[64]; +}; + +struct btrfs_ioctl_dev_info_args { + __u64 devid; + __u8 uuid[16]; + __u64 bytes_used; + __u64 total_bytes; + __u64 unused[379]; + __u8 path[1024]; +}; + +struct btrfs_ioctl_fs_info_args { + __u64 max_id; + __u64 num_devices; + __u8 fsid[16]; + __u32 nodesize; + __u32 sectorsize; + __u32 clone_alignment; + __u16 csum_type; + __u16 csum_size; + __u64 flags; + __u64 generation; + __u8 metadata_uuid[16]; + __u8 reserved[944]; +}; + +struct btrfs_ioctl_feature_flags { + __u64 compat_flags; + __u64 compat_ro_flags; + __u64 incompat_flags; +}; + +struct btrfs_ioctl_ino_lookup_args { + __u64 treeid; + __u64 objectid; + char name[4080]; +}; + +struct btrfs_ioctl_ino_lookup_user_args { + __u64 dirid; + __u64 treeid; + char name[256]; + char path[3824]; +}; + +struct btrfs_ioctl_search_key { + __u64 tree_id; + __u64 min_objectid; + __u64 max_objectid; + __u64 min_offset; + __u64 max_offset; + __u64 min_transid; + __u64 max_transid; + __u32 min_type; + __u32 max_type; + __u32 nr_items; + __u32 unused; + __u64 unused1; + __u64 unused2; + __u64 unused3; + __u64 unused4; +}; + +struct btrfs_ioctl_search_header { + __u64 transid; + __u64 objectid; + __u64 offset; + __u32 type; + __u32 len; +}; + +struct btrfs_ioctl_search_args { + struct btrfs_ioctl_search_key key; + char buf[3992]; +}; + +struct btrfs_ioctl_search_args_v2 { + struct btrfs_ioctl_search_key key; + __u64 buf_size; + __u64 buf[0]; +}; + +struct btrfs_ioctl_space_info { + __u64 flags; + __u64 total_bytes; + __u64 used_bytes; +}; + +struct btrfs_ioctl_space_args { + __u64 space_slots; + __u64 total_spaces; + struct btrfs_ioctl_space_info spaces[0]; +}; + +struct btrfs_data_container { + __u32 bytes_left; + __u32 bytes_missing; + __u32 elem_cnt; + __u32 elem_missed; + __u64 val[0]; +}; + +struct btrfs_ioctl_ino_path_args { + __u64 inum; + __u64 size; + __u64 reserved[4]; + __u64 fspath; +}; + +struct btrfs_ioctl_logical_ino_args { + __u64 logical; + __u64 size; + __u64 reserved[3]; + __u64 flags; + __u64 inodes; +}; + +struct btrfs_ioctl_quota_ctl_args { + __u64 cmd; + __u64 status; +}; + +struct btrfs_ioctl_quota_rescan_args { + __u64 flags; + __u64 progress; + __u64 reserved[6]; +}; + +struct btrfs_ioctl_qgroup_assign_args { + __u64 assign; + __u64 src; + __u64 dst; +}; + +struct btrfs_ioctl_qgroup_create_args { + __u64 create; + __u64 qgroupid; +}; + +struct btrfs_ioctl_timespec { + __u64 sec; + __u32 nsec; +}; + +struct btrfs_ioctl_received_subvol_args { + char uuid[16]; + __u64 stransid; + __u64 rtransid; + struct btrfs_ioctl_timespec stime; + struct btrfs_ioctl_timespec rtime; + __u64 flags; + __u64 reserved[16]; +}; + +struct btrfs_ioctl_send_args { + __s64 send_fd; + __u64 clone_sources_count; + __u64 *clone_sources; + __u64 parent_root; + __u64 flags; + __u64 reserved[4]; +}; + +struct btrfs_ioctl_get_subvol_info_args { + __u64 treeid; + char name[256]; + __u64 parent_id; + __u64 dirid; + __u64 generation; + __u64 flags; + __u8 uuid[16]; + __u8 parent_uuid[16]; + __u8 received_uuid[16]; + __u64 ctransid; + __u64 otransid; + __u64 stransid; + __u64 rtransid; + struct btrfs_ioctl_timespec ctime; + struct btrfs_ioctl_timespec otime; + struct btrfs_ioctl_timespec stime; + struct btrfs_ioctl_timespec rtime; + __u64 reserved[8]; +}; + +struct btrfs_ioctl_get_subvol_rootref_args { + __u64 min_treeid; + struct { + __u64 treeid; + __u64 dirid; + } rootref[255]; + __u8 num_items; + __u8 align[7]; +}; + +struct inode_fs_paths { + struct btrfs_path *btrfs_path; + struct btrfs_root *fs_root; + struct btrfs_data_container *fspath; +}; + +struct btrfs_ioctl_timespec_32 { + __u64 sec; + __u32 nsec; +} __attribute__((packed)); + +struct btrfs_ioctl_received_subvol_args_32 { + char uuid[16]; + __u64 stransid; + __u64 rtransid; + struct btrfs_ioctl_timespec_32 stime; + struct btrfs_ioctl_timespec_32 rtime; + __u64 flags; + __u64 reserved[16]; +} __attribute__((packed)); + +struct btrfs_ioctl_send_args_32 { + __s64 send_fd; + __u64 clone_sources_count; + compat_uptr_t clone_sources; + __u64 parent_root; + __u64 flags; + __u64 reserved[4]; +} __attribute__((packed)); + +struct btrfs_trans_handle___2; + +struct btrfs_fid { + u64 objectid; + u64 root_objectid; + u32 gen; + u64 parent_objectid; + u32 parent_gen; + u64 parent_root_objectid; +} __attribute__((packed)); + +struct btrfs_dir_log_item { + __le64 end; +}; + +enum { + LOG_INODE_ALL = 0, + LOG_INODE_EXISTS = 1, + LOG_OTHER_INODE = 2, + LOG_OTHER_INODE_ALL = 3, +}; + +enum { + LOG_WALK_PIN_ONLY = 0, + LOG_WALK_REPLAY_INODES = 1, + LOG_WALK_REPLAY_DIR_INDEX = 2, + LOG_WALK_REPLAY_ALL = 3, +}; + +struct walk_control___2 { + int free; + int write; + int wait; + int pin; + int stage; + bool ignore_cur_inode; + struct btrfs_root *replay_dest; + struct btrfs_trans_handle *trans; + int (*process_func)(struct btrfs_root *, struct extent_buffer *, struct walk_control___2 *, u64, int); +}; + +struct btrfs_ino_list { + u64 ino; + u64 parent; + struct list_head list; +}; + +struct btrfs_dir_list { + u64 ino; + struct list_head list; +}; + +struct btrfs_free_space_entry { + __le64 offset; + __le64 bytes; + __u8 type; +} __attribute__((packed)); + +struct btrfs_free_space_header { + struct btrfs_disk_key location; + __le64 generation; + __le64 num_entries; + __le64 num_bitmaps; +} __attribute__((packed)); + +struct btrfs_trim_range { + u64 start; + u64 bytes; + struct list_head list; +}; + +struct compressed_bio { + refcount_t pending_bios; + struct page **compressed_pages; + struct inode *inode; + u64 start; + long unsigned int len; + long unsigned int compressed_len; + int compress_type; + long unsigned int nr_pages; + int errors; + int mirror_num; + struct bio *orig_bio; + u8 sums[0]; +}; + +struct workspace_manager { + struct list_head idle_ws; + spinlock_t ws_lock; + int free_ws; + atomic_t total_ws; + wait_queue_head_t ws_wait; +}; + +struct btrfs_compress_op { + struct workspace_manager *workspace_manager; + unsigned int max_level; + unsigned int default_level; +}; + +struct workspace { + z_stream strm; + char *buf; + unsigned int buf_size; + struct list_head list; + int level; +}; + +struct workspace___2 { + void *mem; + void *buf; + void *cbuf; + struct list_head list; +}; + +typedef enum { + ZSTD_fast = 0, + ZSTD_dfast = 1, + ZSTD_greedy = 2, + ZSTD_lazy = 3, + ZSTD_lazy2 = 4, + ZSTD_btlazy2 = 5, + ZSTD_btopt = 6, + ZSTD_btopt2 = 7, +} ZSTD_strategy; + +typedef struct { + unsigned int windowLog; + unsigned int chainLog; + unsigned int hashLog; + unsigned int searchLog; + unsigned int searchLength; + unsigned int targetLength; + ZSTD_strategy strategy; +} ZSTD_compressionParameters; + +typedef struct { + unsigned int contentSizeFlag; + unsigned int checksumFlag; + unsigned int noDictIDFlag; +} ZSTD_frameParameters; + +typedef struct { + ZSTD_compressionParameters cParams; + ZSTD_frameParameters fParams; +} ZSTD_parameters; + +struct ZSTD_inBuffer_s { + const void *src; + size_t size; + size_t pos; +}; + +typedef struct ZSTD_inBuffer_s ZSTD_inBuffer; + +struct ZSTD_outBuffer_s { + void *dst; + size_t size; + size_t pos; +}; + +typedef struct ZSTD_outBuffer_s ZSTD_outBuffer; + +struct ZSTD_CStream_s; + +typedef struct ZSTD_CStream_s ZSTD_CStream; + +struct ZSTD_DStream_s; + +typedef struct ZSTD_DStream_s ZSTD_DStream; + +struct workspace___3 { + void *mem; + size_t size; + char *buf; + unsigned int level; + unsigned int req_level; + long unsigned int last_used; + struct list_head list; + struct list_head lru_list; + ZSTD_inBuffer in_buf; + ZSTD_outBuffer out_buf; +}; + +struct zstd_workspace_manager { + const struct btrfs_compress_op *ops; + spinlock_t lock; + struct list_head lru_list; + struct list_head idle_ws[15]; + long unsigned int active_map; + wait_queue_head_t wait; + struct timer_list timer; +}; + +struct bucket_item { + u32 count; +}; + +struct heuristic_ws { + u8 *sample; + u32 sample_size; + struct bucket_item *bucket; + struct bucket_item *bucket_b; + struct list_head list; +}; + +struct ulist_iterator { + struct list_head *cur_list; +}; + +struct ulist_node { + u64 val; + u64 aux; + struct list_head list; + struct rb_node rb_node; +}; + +struct btrfs_backref_node; + +struct btrfs_backref_cache { + struct rb_root rb_root; + struct btrfs_backref_node *path[8]; + struct list_head pending[8]; + struct list_head leaves; + struct list_head changed; + struct list_head detached; + u64 last_trans; + int nr_nodes; + int nr_edges; + struct list_head pending_edge; + struct list_head useless_node; + struct btrfs_fs_info *fs_info; + unsigned int is_reloc; +}; + +struct file_extent_cluster { + u64 start; + u64 end; + u64 boundary[128]; + unsigned int nr; +}; + +struct mapping_tree { + struct rb_root rb_root; + spinlock_t lock; +}; + +struct reloc_control { + struct btrfs_block_group *block_group; + struct btrfs_root *extent_root; + struct inode *data_inode; + struct btrfs_block_rsv *block_rsv; + struct btrfs_backref_cache backref_cache; + struct file_extent_cluster cluster; + struct extent_io_tree processed_blocks; + struct mapping_tree reloc_root_tree; + struct list_head reloc_roots; + struct list_head dirty_subvol_roots; + u64 merging_rsv_size; + u64 nodes_relocated; + u64 reserved_bytes; + u64 search_start; + u64 extents_found; + unsigned int stage: 8; + unsigned int create_reloc_tree: 1; + unsigned int merge_reloc_tree: 1; + unsigned int found_file_extent: 1; +}; + +struct btrfs_backref_iter { + u64 bytenr; + struct btrfs_path *path; + struct btrfs_fs_info *fs_info; + struct btrfs_key cur_key; + u32 item_ptr; + u32 cur_ptr; + u32 end_ptr; +}; + +struct btrfs_backref_node { + struct { + struct rb_node rb_node; + u64 bytenr; + }; + u64 new_bytenr; + u64 owner; + struct list_head list; + struct list_head upper; + struct list_head lower; + struct btrfs_root *root; + struct extent_buffer *eb; + unsigned int level: 8; + unsigned int cowonly: 1; + unsigned int lowest: 1; + unsigned int locked: 1; + unsigned int processed: 1; + unsigned int checked: 1; + unsigned int pending: 1; + unsigned int detached: 1; + unsigned int is_reloc_root: 1; +}; + +struct btrfs_backref_edge { + struct list_head list[2]; + struct btrfs_backref_node *node[2]; +}; + +struct rb_simple_node { + struct rb_node rb_node; + u64 bytenr; +}; + +struct mapping_node { + struct { + struct rb_node rb_node; + u64 bytenr; + }; + void *data; +}; + +struct tree_block { + struct { + struct rb_node rb_node; + u64 bytenr; + }; + struct btrfs_key key; + unsigned int level: 8; + unsigned int key_ready: 1; +}; + +struct btrfs_delayed_item { + struct rb_node rb_node; + struct btrfs_key key; + struct list_head tree_list; + struct list_head readdir_list; + u64 bytes_reserved; + struct btrfs_delayed_node *delayed_node; + refcount_t refs; + int ins_or_del; + u32 data_len; + char data[0]; +}; + +struct btrfs_async_delayed_work { + struct btrfs_delayed_root *delayed_root; + int nr; + struct btrfs_work work; +}; + +struct reada_control { + struct btrfs_fs_info *fs_info; + struct btrfs_key key_start; + struct btrfs_key key_end; + short: 16; + atomic_t elems; + struct kref refcnt; + int: 32; + wait_queue_head_t wait; +} __attribute__((packed)); + +struct scrub_bio; + +struct scrub_ctx { + struct scrub_bio *bios[64]; + struct btrfs_fs_info *fs_info; + int first_free; + int curr; + atomic_t bios_in_flight; + atomic_t workers_pending; + spinlock_t list_lock; + wait_queue_head_t list_wait; + u16 csum_size; + struct list_head csum_list; + atomic_t cancel_req; + int readonly; + int pages_per_rd_bio; + int is_dev_replace; + struct scrub_bio *wr_curr_bio; + struct mutex wr_lock; + int pages_per_wr_bio; + struct btrfs_device *wr_tgtdev; + bool flush_all_writes; + struct btrfs_scrub_progress stat; + spinlock_t stat_lock; + refcount_t refs; +}; + +struct scrub_recover { + refcount_t refs; + struct btrfs_bio *bbio; + u64 map_length; +}; + +struct scrub_block; + +struct scrub_page { + struct scrub_block *sblock; + struct page *page; + struct btrfs_device *dev; + struct list_head list; + u64 flags; + u64 generation; + u64 logical; + u64 physical; + u64 physical_for_dev_replace; + atomic_t refs; + struct { + unsigned int mirror_num: 8; + unsigned int have_csum: 1; + unsigned int io_error: 1; + }; + u8 csum[32]; + struct scrub_recover *recover; +}; + +struct scrub_parity; + +struct scrub_block { + struct scrub_page *pagev[16]; + int page_count; + atomic_t outstanding_pages; + refcount_t refs; + struct scrub_ctx *sctx; + struct scrub_parity *sparity; + struct { + unsigned int header_error: 1; + unsigned int checksum_error: 1; + unsigned int no_io_error_seen: 1; + unsigned int generation_error: 1; + unsigned int data_corrected: 1; + }; + struct btrfs_work work; +}; + +struct scrub_bio { + int index; + struct scrub_ctx *sctx; + struct btrfs_device *dev; + struct bio *bio; + blk_status_t status; + u64 logical; + u64 physical; + struct scrub_page *pagev[32]; + int page_count; + int next_free; + struct btrfs_work work; +}; + +struct scrub_parity { + struct scrub_ctx *sctx; + struct btrfs_device *scrub_dev; + u64 logic_start; + u64 logic_end; + int nsectors; + u64 stripe_len; + refcount_t refs; + struct list_head spages; + struct btrfs_work work; + long unsigned int *dbitmap; + long unsigned int *ebitmap; + long unsigned int bitmap[0]; +}; + +struct scrub_warning { + struct btrfs_path *path; + u64 extent_item_size; + const char *errstr; + u64 physical; + u64 logical; + struct btrfs_device *dev; +}; + +struct full_stripe_lock { + struct rb_node node; + u64 logical; + u64 refs; + struct mutex mutex; +}; + +struct btrfs_raid_bio; + +struct reada_zone { + u64 start; + u64 end; + u64 elems; + struct list_head list; + spinlock_t lock; + int locked; + struct btrfs_device *device; + struct btrfs_device *devs[5]; + int ndevs; + struct kref refcnt; +}; + +struct reada_extctl { + struct list_head list; + struct reada_control *rc; + u64 generation; +}; + +struct reada_extent { + u64 logical; + struct btrfs_key top; + struct list_head extctl; + int refcnt; + spinlock_t lock; + struct reada_zone *zones[5]; + int nzones; + int scheduled; +}; + +struct reada_machine_work { + struct btrfs_work work; + struct btrfs_fs_info *fs_info; +}; + +typedef int iterate_extent_inodes_t(u64, u64, u64, void *); + +struct extent_inode_elem { + u64 inum; + u64 offset; + struct extent_inode_elem *next; +}; + +struct preftree { + struct rb_root_cached root; + unsigned int count; +}; + +struct preftrees { + struct preftree direct; + struct preftree indirect; + struct preftree indirect_missing_keys; +}; + +struct share_check { + u64 root_objectid; + u64 inum; + int share_count; +}; + +typedef int iterate_irefs_t(u64, u32, long unsigned int, struct extent_buffer *, void *); + +struct btrfs_qgroup_status_item { + __le64 version; + __le64 generation; + __le64 flags; + __le64 rescan; +}; + +struct btrfs_qgroup_info_item { + __le64 generation; + __le64 rfer; + __le64 rfer_cmpr; + __le64 excl; + __le64 excl_cmpr; +}; + +struct btrfs_qgroup_limit_item { + __le64 flags; + __le64 max_rfer; + __le64 max_excl; + __le64 rsv_rfer; + __le64 rsv_excl; +}; + +struct btrfs_qgroup_swapped_block { + struct rb_node node; + int level; + bool trace_leaf; + u64 subvol_bytenr; + u64 subvol_generation; + u64 reloc_bytenr; + u64 reloc_generation; + u64 last_snapshot; + struct btrfs_key first_key; +}; + +struct btrfs_qgroup_list { + struct list_head next_group; + struct list_head next_member; + struct btrfs_qgroup *group; + struct btrfs_qgroup *member; +}; + +struct btrfs_stream_header { + char magic[13]; + __le32 version; +} __attribute__((packed)); + +struct btrfs_cmd_header { + __le32 len; + __le16 cmd; + __le32 crc; +} __attribute__((packed)); + +struct btrfs_tlv_header { + __le16 tlv_type; + __le16 tlv_len; +}; + +enum btrfs_send_cmd { + BTRFS_SEND_C_UNSPEC = 0, + BTRFS_SEND_C_SUBVOL = 1, + BTRFS_SEND_C_SNAPSHOT = 2, + BTRFS_SEND_C_MKFILE = 3, + BTRFS_SEND_C_MKDIR = 4, + BTRFS_SEND_C_MKNOD = 5, + BTRFS_SEND_C_MKFIFO = 6, + BTRFS_SEND_C_MKSOCK = 7, + BTRFS_SEND_C_SYMLINK = 8, + BTRFS_SEND_C_RENAME = 9, + BTRFS_SEND_C_LINK = 10, + BTRFS_SEND_C_UNLINK = 11, + BTRFS_SEND_C_RMDIR = 12, + BTRFS_SEND_C_SET_XATTR = 13, + BTRFS_SEND_C_REMOVE_XATTR = 14, + BTRFS_SEND_C_WRITE = 15, + BTRFS_SEND_C_CLONE = 16, + BTRFS_SEND_C_TRUNCATE = 17, + BTRFS_SEND_C_CHMOD = 18, + BTRFS_SEND_C_CHOWN = 19, + BTRFS_SEND_C_UTIMES = 20, + BTRFS_SEND_C_END = 21, + BTRFS_SEND_C_UPDATE_EXTENT = 22, + __BTRFS_SEND_C_MAX = 23, +}; + +enum { + BTRFS_SEND_A_UNSPEC = 0, + BTRFS_SEND_A_UUID = 1, + BTRFS_SEND_A_CTRANSID = 2, + BTRFS_SEND_A_INO = 3, + BTRFS_SEND_A_SIZE = 4, + BTRFS_SEND_A_MODE = 5, + BTRFS_SEND_A_UID = 6, + BTRFS_SEND_A_GID = 7, + BTRFS_SEND_A_RDEV = 8, + BTRFS_SEND_A_CTIME = 9, + BTRFS_SEND_A_MTIME = 10, + BTRFS_SEND_A_ATIME = 11, + BTRFS_SEND_A_OTIME = 12, + BTRFS_SEND_A_XATTR_NAME = 13, + BTRFS_SEND_A_XATTR_DATA = 14, + BTRFS_SEND_A_PATH = 15, + BTRFS_SEND_A_PATH_TO = 16, + BTRFS_SEND_A_PATH_LINK = 17, + BTRFS_SEND_A_FILE_OFFSET = 18, + BTRFS_SEND_A_DATA = 19, + BTRFS_SEND_A_CLONE_UUID = 20, + BTRFS_SEND_A_CLONE_CTRANSID = 21, + BTRFS_SEND_A_CLONE_PATH = 22, + BTRFS_SEND_A_CLONE_OFFSET = 23, + BTRFS_SEND_A_CLONE_LEN = 24, + __BTRFS_SEND_A_MAX = 25, +}; + +struct fs_path { + union { + struct { + char *start; + char *end; + char *buf; + short unsigned int buf_len: 15; + short unsigned int reversed: 1; + char inline_buf[0]; + }; + char pad[256]; + }; +}; + +struct clone_root { + struct btrfs_root *root; + u64 ino; + u64 offset; + u64 found_refs; +}; + +struct send_ctx { + struct file *send_filp; + loff_t send_off; + char *send_buf; + u32 send_size; + u32 send_max_size; + u64 total_send_size; + u64 cmd_send_size[23]; + u64 flags; + struct btrfs_root *send_root; + struct btrfs_root *parent_root; + struct clone_root *clone_roots; + int clone_roots_cnt; + struct btrfs_path *left_path; + struct btrfs_path *right_path; + struct btrfs_key *cmp_key; + u64 cur_ino; + u64 cur_inode_gen; + int cur_inode_new; + int cur_inode_new_gen; + int cur_inode_deleted; + u64 cur_inode_size; + u64 cur_inode_mode; + u64 cur_inode_rdev; + u64 cur_inode_last_extent; + u64 cur_inode_next_write_offset; + bool ignore_cur_inode; + u64 send_progress; + struct list_head new_refs; + struct list_head deleted_refs; + struct xarray name_cache; + struct list_head name_cache_list; + int name_cache_size; + struct file_ra_state ra; + struct rb_root pending_dir_moves; + struct rb_root waiting_dir_moves; + struct rb_root orphan_dirs; +}; + +struct pending_dir_move { + struct rb_node node; + struct list_head list; + u64 parent_ino; + u64 ino; + u64 gen; + struct list_head update_refs; +}; + +struct waiting_dir_move { + struct rb_node node; + u64 ino; + u64 rmdir_ino; + bool orphanized; +}; + +struct orphan_dir_info { + struct rb_node node; + u64 ino; + u64 gen; + u64 last_dir_index_offset; +}; + +struct name_cache_entry { + struct list_head list; + struct list_head radix_list; + u64 ino; + u64 gen; + u64 parent_ino; + u64 parent_gen; + int ret; + int need_later_update; + int name_len; + char name[0]; +}; + +enum btrfs_compare_tree_result { + BTRFS_COMPARE_TREE_NEW = 0, + BTRFS_COMPARE_TREE_DELETED = 1, + BTRFS_COMPARE_TREE_CHANGED = 2, + BTRFS_COMPARE_TREE_SAME = 3, +}; + +typedef int (*iterate_inode_ref_t)(int, u64, int, struct fs_path *, void *); + +typedef int (*iterate_dir_item_t)(int, struct btrfs_key *, const char *, int, const char *, int, u8, void *); + +struct backref_ctx { + struct send_ctx *sctx; + u64 found; + u64 cur_objectid; + u64 cur_offset; + u64 extent_len; + u64 data_offset; + int found_itself; +}; + +enum inode_state { + inode_state_no_change = 0, + inode_state_will_create = 1, + inode_state_did_create = 2, + inode_state_will_delete = 3, + inode_state_did_delete = 4, +}; + +struct recorded_ref { + struct list_head list; + char *name; + struct fs_path *full_path; + u64 dir; + u64 dir_gen; + int name_len; +}; + +struct find_ref_ctx { + u64 dir; + u64 dir_gen; + struct btrfs_root *root; + struct fs_path *name; + int found_idx; +}; + +struct find_xattr_ctx { + const char *name; + int name_len; + int found_idx; + char *found_data; + int found_data_len; +}; + +struct parent_paths_ctx { + struct list_head *refs; + struct send_ctx *sctx; +}; + +struct btrfs_dev_replace_item { + __le64 src_devid; + __le64 cursor_left; + __le64 cursor_right; + __le64 cont_reading_from_srcdev_mode; + __le64 replace_state; + __le64 time_started; + __le64 time_stopped; + __le64 num_write_errors; + __le64 num_uncorrectable_read_errors; +}; + +struct blk_plug_cb; + +typedef void (*blk_plug_cb_fn)(struct blk_plug_cb *, bool); + +struct blk_plug_cb { + struct list_head list; + blk_plug_cb_fn callback; + void *data; +}; + +struct raid6_calls { + void (*gen_syndrome)(int, size_t, void **); + void (*xor_syndrome)(int, int, int, size_t, void **); + int (*valid)(); + const char *name; + int prefer; +}; + +struct btrfs_stripe_hash { + struct list_head hash_list; + spinlock_t lock; +}; + +struct btrfs_stripe_hash_table { + struct list_head stripe_cache; + spinlock_t cache_lock; + int cache_size; + struct btrfs_stripe_hash table[0]; +}; + +enum btrfs_rbio_ops { + BTRFS_RBIO_WRITE = 0, + BTRFS_RBIO_READ_REBUILD = 1, + BTRFS_RBIO_PARITY_SCRUB = 2, + BTRFS_RBIO_REBUILD_MISSING = 3, +}; + +struct btrfs_raid_bio___2 { + struct btrfs_fs_info *fs_info; + struct btrfs_bio *bbio; + struct list_head hash_list; + struct list_head stripe_cache; + struct btrfs_work work; + struct bio_list bio_list; + spinlock_t bio_list_lock; + struct list_head plug_list; + long unsigned int flags; + int stripe_len; + int nr_data; + int real_stripes; + int stripe_npages; + enum btrfs_rbio_ops operation; + int faila; + int failb; + int scrubp; + int nr_pages; + int bio_list_bytes; + int generic_bio_cnt; + refcount_t refs; + atomic_t stripes_pending; + atomic_t error; + struct page **stripe_pages; + struct page **bio_pages; + long unsigned int *dbitmap; + void **finish_pointers; + long unsigned int *finish_pbitmap; +}; + +struct btrfs_plug_cb { + struct blk_plug_cb cb; + struct btrfs_fs_info *info; + struct list_head rbio_list; + struct btrfs_work work; +}; + +struct prop_handler { + struct hlist_node node; + const char *xattr_name; + int (*validate)(const char *, size_t); + int (*apply)(struct inode *, const char *, size_t); + const char * (*extract)(struct inode *); + int inheritable; +}; + +struct btrfs_free_space_info { + __le32 extent_count; + __le32 flags; +}; + +struct reserve_ticket { + u64 bytes; + int error; + bool steal; + struct list_head list; + wait_queue_head_t wait; +}; + +struct ipc64_perm { + __kernel_key_t key; + __kernel_uid32_t uid; + __kernel_gid32_t gid; + __kernel_uid32_t cuid; + __kernel_gid32_t cgid; + __kernel_mode_t mode; + unsigned char __pad1[0]; + short unsigned int seq; + short unsigned int __pad2; + __kernel_ulong_t __unused1; + __kernel_ulong_t __unused2; +}; + +typedef s32 compat_key_t; + +typedef u32 __compat_gid32_t; + +struct compat_ipc64_perm { + compat_key_t key; + __compat_uid32_t uid; + __compat_gid32_t gid; + __compat_uid32_t cuid; + __compat_gid32_t cgid; + short unsigned int mode; + short unsigned int __pad1; + short unsigned int seq; + short unsigned int __pad2; + compat_ulong_t unused1; + compat_ulong_t unused2; +}; + +struct compat_ipc_perm { + key_t key; + __compat_uid_t uid; + __compat_gid_t gid; + __compat_uid_t cuid; + __compat_gid_t cgid; + compat_mode_t mode; + short unsigned int seq; +}; + +struct ipc_perm { + __kernel_key_t key; + __kernel_uid_t uid; + __kernel_gid_t gid; + __kernel_uid_t cuid; + __kernel_gid_t cgid; + __kernel_mode_t mode; + short unsigned int seq; +}; + +struct ipc_params { + key_t key; + int flg; + union { + size_t size; + int nsems; + } u; +}; + +struct ipc_ops { + int (*getnew)(struct ipc_namespace *, struct ipc_params *); + int (*associate)(struct kern_ipc_perm *, int); + int (*more_checks)(struct kern_ipc_perm *, struct ipc_params *); +}; + +struct ipc_proc_iface { + const char *path; + const char *header; + int ids; + int (*show)(struct seq_file *, void *); +}; + +struct ipc_proc_iter { + struct ipc_namespace *ns; + struct pid_namespace *pid_ns; + struct ipc_proc_iface *iface; +}; + +struct msg_msgseg; + +struct msg_msg { + struct list_head m_list; + long int m_type; + size_t m_ts; + struct msg_msgseg *next; + void *security; +}; + +struct msg_msgseg { + struct msg_msgseg *next; +}; + +typedef int __kernel_ipc_pid_t; + +struct msgbuf { + __kernel_long_t mtype; + char mtext[1]; +}; + +struct msg; + +struct msqid_ds { + struct ipc_perm msg_perm; + struct msg *msg_first; + struct msg *msg_last; + __kernel_old_time_t msg_stime; + __kernel_old_time_t msg_rtime; + __kernel_old_time_t msg_ctime; + long unsigned int msg_lcbytes; + long unsigned int msg_lqbytes; + short unsigned int msg_cbytes; + short unsigned int msg_qnum; + short unsigned int msg_qbytes; + __kernel_ipc_pid_t msg_lspid; + __kernel_ipc_pid_t msg_lrpid; +}; + +struct msqid64_ds { + struct ipc64_perm msg_perm; + long int msg_stime; + long int msg_rtime; + long int msg_ctime; + long unsigned int msg_cbytes; + long unsigned int msg_qnum; + long unsigned int msg_qbytes; + __kernel_pid_t msg_lspid; + __kernel_pid_t msg_lrpid; + long unsigned int __unused4; + long unsigned int __unused5; +}; + +struct msginfo { + int msgpool; + int msgmap; + int msgmax; + int msgmnb; + int msgmni; + int msgssz; + int msgtql; + short unsigned int msgseg; +}; + +typedef u16 compat_ipc_pid_t; + +struct compat_msqid64_ds { + struct compat_ipc64_perm msg_perm; + compat_ulong_t msg_stime; + compat_ulong_t msg_stime_high; + compat_ulong_t msg_rtime; + compat_ulong_t msg_rtime_high; + compat_ulong_t msg_ctime; + compat_ulong_t msg_ctime_high; + compat_ulong_t msg_cbytes; + compat_ulong_t msg_qnum; + compat_ulong_t msg_qbytes; + compat_pid_t msg_lspid; + compat_pid_t msg_lrpid; + compat_ulong_t __unused4; + compat_ulong_t __unused5; +}; + +struct msg_queue { + struct kern_ipc_perm q_perm; + time64_t q_stime; + time64_t q_rtime; + time64_t q_ctime; + long unsigned int q_cbytes; + long unsigned int q_qnum; + long unsigned int q_qbytes; + struct pid *q_lspid; + struct pid *q_lrpid; + struct list_head q_messages; + struct list_head q_receivers; + struct list_head q_senders; + long: 64; + long: 64; +}; + +struct msg_receiver { + struct list_head r_list; + struct task_struct *r_tsk; + int r_mode; + long int r_msgtype; + long int r_maxsize; + struct msg_msg *r_msg; +}; + +struct msg_sender { + struct list_head list; + struct task_struct *tsk; + size_t msgsz; +}; + +struct compat_msqid_ds { + struct compat_ipc_perm msg_perm; + compat_uptr_t msg_first; + compat_uptr_t msg_last; + old_time32_t msg_stime; + old_time32_t msg_rtime; + old_time32_t msg_ctime; + compat_ulong_t msg_lcbytes; + compat_ulong_t msg_lqbytes; + short unsigned int msg_cbytes; + short unsigned int msg_qnum; + short unsigned int msg_qbytes; + compat_ipc_pid_t msg_lspid; + compat_ipc_pid_t msg_lrpid; +}; + +struct compat_msgbuf { + compat_long_t mtype; + char mtext[1]; +}; + +struct sem; + +struct sem_queue; + +struct sem_undo; + +struct semid_ds { + struct ipc_perm sem_perm; + __kernel_old_time_t sem_otime; + __kernel_old_time_t sem_ctime; + struct sem *sem_base; + struct sem_queue *sem_pending; + struct sem_queue **sem_pending_last; + struct sem_undo *undo; + short unsigned int sem_nsems; +}; + +struct sem { + int semval; + struct pid *sempid; + spinlock_t lock; + struct list_head pending_alter; + struct list_head pending_const; + time64_t sem_otime; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct sem_queue { + struct list_head list; + struct task_struct *sleeper; + struct sem_undo *undo; + struct pid *pid; + int status; + struct sembuf *sops; + struct sembuf *blocking; + int nsops; + bool alter; + bool dupsop; +}; + +struct sem_undo { + struct list_head list_proc; + struct callback_head rcu; + struct sem_undo_list *ulp; + struct list_head list_id; + int semid; + short int *semadj; +}; + +struct semid64_ds { + struct ipc64_perm sem_perm; + __kernel_long_t sem_otime; + __kernel_ulong_t __unused1; + __kernel_long_t sem_ctime; + __kernel_ulong_t __unused2; + __kernel_ulong_t sem_nsems; + __kernel_ulong_t __unused3; + __kernel_ulong_t __unused4; +}; + +struct seminfo { + int semmap; + int semmni; + int semmns; + int semmnu; + int semmsl; + int semopm; + int semume; + int semusz; + int semvmx; + int semaem; +}; + +struct sem_undo_list { + refcount_t refcnt; + spinlock_t lock; + struct list_head list_proc; +}; + +struct compat_semid64_ds { + struct compat_ipc64_perm sem_perm; + compat_ulong_t sem_otime; + compat_ulong_t sem_otime_high; + compat_ulong_t sem_ctime; + compat_ulong_t sem_ctime_high; + compat_ulong_t sem_nsems; + compat_ulong_t __unused3; + compat_ulong_t __unused4; +}; + +struct sem_array { + struct kern_ipc_perm sem_perm; + time64_t sem_ctime; + struct list_head pending_alter; + struct list_head pending_const; + struct list_head list_id; + int sem_nsems; + int complex_count; + unsigned int use_global_lock; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct sem sems[0]; +}; + +struct compat_semid_ds { + struct compat_ipc_perm sem_perm; + old_time32_t sem_otime; + old_time32_t sem_ctime; + compat_uptr_t sem_base; + compat_uptr_t sem_pending; + compat_uptr_t sem_pending_last; + compat_uptr_t undo; + short unsigned int sem_nsems; +}; + +struct shmid_ds { + struct ipc_perm shm_perm; + int shm_segsz; + __kernel_old_time_t shm_atime; + __kernel_old_time_t shm_dtime; + __kernel_old_time_t shm_ctime; + __kernel_ipc_pid_t shm_cpid; + __kernel_ipc_pid_t shm_lpid; + short unsigned int shm_nattch; + short unsigned int shm_unused; + void *shm_unused2; + void *shm_unused3; +}; + +struct shmid64_ds { + struct ipc64_perm shm_perm; + size_t shm_segsz; + long int shm_atime; + long int shm_dtime; + long int shm_ctime; + __kernel_pid_t shm_cpid; + __kernel_pid_t shm_lpid; + long unsigned int shm_nattch; + long unsigned int __unused4; + long unsigned int __unused5; +}; + +struct shminfo64 { + long unsigned int shmmax; + long unsigned int shmmin; + long unsigned int shmmni; + long unsigned int shmseg; + long unsigned int shmall; + long unsigned int __unused1; + long unsigned int __unused2; + long unsigned int __unused3; + long unsigned int __unused4; +}; + +struct shminfo { + int shmmax; + int shmmin; + int shmmni; + int shmseg; + int shmall; +}; + +struct shm_info { + int used_ids; + __kernel_ulong_t shm_tot; + __kernel_ulong_t shm_rss; + __kernel_ulong_t shm_swp; + __kernel_ulong_t swap_attempts; + __kernel_ulong_t swap_successes; +}; + +struct compat_shmid64_ds { + struct compat_ipc64_perm shm_perm; + compat_size_t shm_segsz; + compat_ulong_t shm_atime; + compat_ulong_t shm_atime_high; + compat_ulong_t shm_dtime; + compat_ulong_t shm_dtime_high; + compat_ulong_t shm_ctime; + compat_ulong_t shm_ctime_high; + compat_pid_t shm_cpid; + compat_pid_t shm_lpid; + compat_ulong_t shm_nattch; + compat_ulong_t __unused4; + compat_ulong_t __unused5; +}; + +struct shmid_kernel { + struct kern_ipc_perm shm_perm; + struct file *shm_file; + long unsigned int shm_nattch; + long unsigned int shm_segsz; + time64_t shm_atim; + time64_t shm_dtim; + time64_t shm_ctim; + struct pid *shm_cprid; + struct pid *shm_lprid; + struct user_struct *mlock_user; + struct task_struct *shm_creator; + struct list_head shm_clist; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct shm_file_data { + int id; + struct ipc_namespace *ns; + struct file *file; + const struct vm_operations_struct *vm_ops; +}; + +struct compat_shmid_ds { + struct compat_ipc_perm shm_perm; + int shm_segsz; + old_time32_t shm_atime; + old_time32_t shm_dtime; + old_time32_t shm_ctime; + compat_ipc_pid_t shm_cpid; + compat_ipc_pid_t shm_lpid; + short unsigned int shm_nattch; + short unsigned int shm_unused; + compat_uptr_t shm_unused2; + compat_uptr_t shm_unused3; +}; + +struct compat_shminfo64 { + compat_ulong_t shmmax; + compat_ulong_t shmmin; + compat_ulong_t shmmni; + compat_ulong_t shmseg; + compat_ulong_t shmall; + compat_ulong_t __unused1; + compat_ulong_t __unused2; + compat_ulong_t __unused3; + compat_ulong_t __unused4; +}; + +struct compat_shm_info { + compat_int_t used_ids; + compat_ulong_t shm_tot; + compat_ulong_t shm_rss; + compat_ulong_t shm_swp; + compat_ulong_t swap_attempts; + compat_ulong_t swap_successes; +}; + +struct compat_ipc_kludge { + compat_uptr_t msgp; + compat_long_t msgtyp; +}; + +struct mqueue_fs_context { + struct ipc_namespace *ipc_ns; +}; + +struct posix_msg_tree_node { + struct rb_node rb_node; + struct list_head msg_list; + int priority; +}; + +struct ext_wait_queue { + struct task_struct *task; + struct list_head list; + struct msg_msg *msg; + int state; +}; + +struct mqueue_inode_info { + spinlock_t lock; + struct inode vfs_inode; + wait_queue_head_t wait_q; + struct rb_root msg_tree; + struct rb_node *msg_tree_rightmost; + struct posix_msg_tree_node *node_cache; + struct mq_attr attr; + struct sigevent notify; + struct pid *notify_owner; + u32 notify_self_exec_id; + struct user_namespace *notify_user_ns; + struct user_struct *user; + struct sock *notify_sock; + struct sk_buff *notify_cookie; + struct ext_wait_queue e_wait_q[2]; + long unsigned int qsize; +}; + +struct compat_mq_attr { + compat_long_t mq_flags; + compat_long_t mq_maxmsg; + compat_long_t mq_msgsize; + compat_long_t mq_curmsgs; + compat_long_t __reserved[4]; +}; + +enum key_state { + KEY_IS_UNINSTANTIATED = 0, + KEY_IS_POSITIVE = 1, +}; + +struct key_user { + struct rb_node node; + struct mutex cons_lock; + spinlock_t lock; + refcount_t usage; + atomic_t nkeys; + atomic_t nikeys; + kuid_t uid; + int qnkeys; + int qnbytes; +}; + +enum key_notification_subtype { + NOTIFY_KEY_INSTANTIATED = 0, + NOTIFY_KEY_UPDATED = 1, + NOTIFY_KEY_LINKED = 2, + NOTIFY_KEY_UNLINKED = 3, + NOTIFY_KEY_CLEARED = 4, + NOTIFY_KEY_REVOKED = 5, + NOTIFY_KEY_INVALIDATED = 6, + NOTIFY_KEY_SETATTR = 7, +}; + +struct assoc_array_edit; + +struct assoc_array_ops { + long unsigned int (*get_key_chunk)(const void *, int); + long unsigned int (*get_object_key_chunk)(const void *, int); + bool (*compare_object)(const void *, const void *); + int (*diff_objects)(const void *, const void *); + void (*free_object)(void *); +}; + +struct assoc_array_node { + struct assoc_array_ptr *back_pointer; + u8 parent_slot; + struct assoc_array_ptr *slots[16]; + long unsigned int nr_leaves_on_branch; +}; + +struct assoc_array_shortcut { + struct assoc_array_ptr *back_pointer; + int parent_slot; + int skip_to_level; + struct assoc_array_ptr *next_node; + long unsigned int index_key[0]; +}; + +struct assoc_array_edit___2 { + struct callback_head rcu; + struct assoc_array *array; + const struct assoc_array_ops *ops; + const struct assoc_array_ops *ops_for_excised_subtree; + struct assoc_array_ptr *leaf; + struct assoc_array_ptr **leaf_p; + struct assoc_array_ptr *dead_leaf; + struct assoc_array_ptr *new_meta[3]; + struct assoc_array_ptr *excised_meta[1]; + struct assoc_array_ptr *excised_subtree; + struct assoc_array_ptr **set_backpointers[16]; + struct assoc_array_ptr *set_backpointers_to; + struct assoc_array_node *adjust_count_on; + long int adjust_count_by; + struct { + struct assoc_array_ptr **ptr; + struct assoc_array_ptr *to; + } set[2]; + struct { + u8 *p; + u8 to; + } set_parent_slot[1]; + u8 segment_cache[17]; +}; + +struct keyring_search_context { + struct keyring_index_key index_key; + const struct cred *cred; + struct key_match_data match_data; + unsigned int flags; + int (*iterator)(const void *, void *); + int skipped_ret; + bool possessed; + key_ref_t result; + time64_t now; +}; + +struct keyring_read_iterator_context { + size_t buflen; + size_t count; + key_serial_t *buffer; +}; + +struct keyctl_dh_params { + union { + __s32 private; + __s32 priv; + }; + __s32 prime; + __s32 base; +}; + +struct keyctl_kdf_params { + char *hashname; + char *otherinfo; + __u32 otherinfolen; + __u32 __spare[8]; +}; + +struct keyctl_pkey_query { + __u32 supported_ops; + __u32 key_size; + __u16 max_data_size; + __u16 max_sig_size; + __u16 max_enc_size; + __u16 max_dec_size; + __u32 __spare[10]; +}; + +struct keyctl_pkey_params { + __s32 key_id; + __u32 in_len; + union { + __u32 out_len; + __u32 in2_len; + }; + __u32 __spare[7]; +}; + +struct request_key_auth { + struct callback_head rcu; + struct key *target_key; + struct key *dest_keyring; + const struct cred *cred; + void *callout_info; + size_t callout_len; + pid_t pid; + char op[8]; +}; + +struct user_key_payload { + struct callback_head rcu; + short unsigned int datalen; + long: 48; + char data[0]; +}; + +enum { + Opt_err___8 = 0, + Opt_enc = 1, + Opt_hash = 2, +}; + +struct vfs_cap_data { + __le32 magic_etc; + struct { + __le32 permitted; + __le32 inheritable; + } data[2]; +}; + +struct vfs_ns_cap_data { + __le32 magic_etc; + struct { + __le32 permitted; + __le32 inheritable; + } data[2]; + __le32 rootid; +}; + +struct sctp_endpoint; + +union security_list_options { + int (*binder_set_context_mgr)(struct task_struct *); + int (*binder_transaction)(struct task_struct *, struct task_struct *); + int (*binder_transfer_binder)(struct task_struct *, struct task_struct *); + int (*binder_transfer_file)(struct task_struct *, struct task_struct *, struct file *); + int (*ptrace_access_check)(struct task_struct *, unsigned int); + int (*ptrace_traceme)(struct task_struct *); + int (*capget)(struct task_struct *, kernel_cap_t *, kernel_cap_t *, kernel_cap_t *); + int (*capset)(struct cred *, const struct cred *, const kernel_cap_t *, const kernel_cap_t *, const kernel_cap_t *); + int (*capable)(const struct cred *, struct user_namespace *, int, unsigned int); + int (*quotactl)(int, int, int, struct super_block *); + int (*quota_on)(struct dentry *); + int (*syslog)(int); + int (*settime)(const struct timespec64 *, const struct timezone *); + int (*vm_enough_memory)(struct mm_struct *, long int); + int (*bprm_creds_for_exec)(struct linux_binprm *); + int (*bprm_creds_from_file)(struct linux_binprm *, struct file *); + int (*bprm_check_security)(struct linux_binprm *); + void (*bprm_committing_creds)(struct linux_binprm *); + void (*bprm_committed_creds)(struct linux_binprm *); + int (*fs_context_dup)(struct fs_context *, struct fs_context *); + int (*fs_context_parse_param)(struct fs_context *, struct fs_parameter *); + int (*sb_alloc_security)(struct super_block *); + void (*sb_free_security)(struct super_block *); + void (*sb_free_mnt_opts)(void *); + int (*sb_eat_lsm_opts)(char *, void **); + int (*sb_remount)(struct super_block *, void *); + int (*sb_kern_mount)(struct super_block *); + int (*sb_show_options)(struct seq_file *, struct super_block *); + int (*sb_statfs)(struct dentry *); + int (*sb_mount)(const char *, const struct path *, const char *, long unsigned int, void *); + int (*sb_umount)(struct vfsmount *, int); + int (*sb_pivotroot)(const struct path *, const struct path *); + int (*sb_set_mnt_opts)(struct super_block *, void *, long unsigned int, long unsigned int *); + int (*sb_clone_mnt_opts)(const struct super_block *, struct super_block *, long unsigned int, long unsigned int *); + int (*sb_add_mnt_opt)(const char *, const char *, int, void **); + int (*move_mount)(const struct path *, const struct path *); + int (*dentry_init_security)(struct dentry *, int, const struct qstr *, void **, u32 *); + int (*dentry_create_files_as)(struct dentry *, int, struct qstr *, const struct cred *, struct cred *); + int (*path_notify)(const struct path *, u64, unsigned int); + int (*inode_alloc_security)(struct inode *); + void (*inode_free_security)(struct inode *); + int (*inode_init_security)(struct inode *, struct inode *, const struct qstr *, const char **, void **, size_t *); + int (*inode_create)(struct inode *, struct dentry *, umode_t); + int (*inode_link)(struct dentry *, struct inode *, struct dentry *); + int (*inode_unlink)(struct inode *, struct dentry *); + int (*inode_symlink)(struct inode *, struct dentry *, const char *); + int (*inode_mkdir)(struct inode *, struct dentry *, umode_t); + int (*inode_rmdir)(struct inode *, struct dentry *); + int (*inode_mknod)(struct inode *, struct dentry *, umode_t, dev_t); + int (*inode_rename)(struct inode *, struct dentry *, struct inode *, struct dentry *); + int (*inode_readlink)(struct dentry *); + int (*inode_follow_link)(struct dentry *, struct inode *, bool); + int (*inode_permission)(struct inode *, int); + int (*inode_setattr)(struct dentry *, struct iattr *); + int (*inode_getattr)(const struct path *); + int (*inode_setxattr)(struct dentry *, const char *, const void *, size_t, int); + void (*inode_post_setxattr)(struct dentry *, const char *, const void *, size_t, int); + int (*inode_getxattr)(struct dentry *, const char *); + int (*inode_listxattr)(struct dentry *); + int (*inode_removexattr)(struct dentry *, const char *); + int (*inode_need_killpriv)(struct dentry *); + int (*inode_killpriv)(struct dentry *); + int (*inode_getsecurity)(struct inode *, const char *, void **, bool); + int (*inode_setsecurity)(struct inode *, const char *, const void *, size_t, int); + int (*inode_listsecurity)(struct inode *, char *, size_t); + void (*inode_getsecid)(struct inode *, u32 *); + int (*inode_copy_up)(struct dentry *, struct cred **); + int (*inode_copy_up_xattr)(const char *); + int (*kernfs_init_security)(struct kernfs_node *, struct kernfs_node *); + int (*file_permission)(struct file *, int); + int (*file_alloc_security)(struct file *); + void (*file_free_security)(struct file *); + int (*file_ioctl)(struct file *, unsigned int, long unsigned int); + int (*mmap_addr)(long unsigned int); + int (*mmap_file)(struct file *, long unsigned int, long unsigned int, long unsigned int); + int (*file_mprotect)(struct vm_area_struct *, long unsigned int, long unsigned int); + int (*file_lock)(struct file *, unsigned int); + int (*file_fcntl)(struct file *, unsigned int, long unsigned int); + void (*file_set_fowner)(struct file *); + int (*file_send_sigiotask)(struct task_struct *, struct fown_struct *, int); + int (*file_receive)(struct file *); + int (*file_open)(struct file *); + int (*task_alloc)(struct task_struct *, long unsigned int); + void (*task_free)(struct task_struct *); + int (*cred_alloc_blank)(struct cred *, gfp_t); + void (*cred_free)(struct cred *); + int (*cred_prepare)(struct cred *, const struct cred *, gfp_t); + void (*cred_transfer)(struct cred *, const struct cred *); + void (*cred_getsecid)(const struct cred *, u32 *); + int (*kernel_act_as)(struct cred *, u32); + int (*kernel_create_files_as)(struct cred *, struct inode *); + int (*kernel_module_request)(char *); + int (*kernel_load_data)(enum kernel_load_data_id, bool); + int (*kernel_post_load_data)(char *, loff_t, enum kernel_load_data_id, char *); + int (*kernel_read_file)(struct file *, enum kernel_read_file_id, bool); + int (*kernel_post_read_file)(struct file *, char *, loff_t, enum kernel_read_file_id); + int (*task_fix_setuid)(struct cred *, const struct cred *, int); + int (*task_fix_setgid)(struct cred *, const struct cred *, int); + int (*task_setpgid)(struct task_struct *, pid_t); + int (*task_getpgid)(struct task_struct *); + int (*task_getsid)(struct task_struct *); + void (*task_getsecid)(struct task_struct *, u32 *); + int (*task_setnice)(struct task_struct *, int); + int (*task_setioprio)(struct task_struct *, int); + int (*task_getioprio)(struct task_struct *); + int (*task_prlimit)(const struct cred *, const struct cred *, unsigned int); + int (*task_setrlimit)(struct task_struct *, unsigned int, struct rlimit *); + int (*task_setscheduler)(struct task_struct *); + int (*task_getscheduler)(struct task_struct *); + int (*task_movememory)(struct task_struct *); + int (*task_kill)(struct task_struct *, struct kernel_siginfo *, int, const struct cred *); + int (*task_prctl)(int, long unsigned int, long unsigned int, long unsigned int, long unsigned int); + void (*task_to_inode)(struct task_struct *, struct inode *); + int (*ipc_permission)(struct kern_ipc_perm *, short int); + void (*ipc_getsecid)(struct kern_ipc_perm *, u32 *); + int (*msg_msg_alloc_security)(struct msg_msg *); + void (*msg_msg_free_security)(struct msg_msg *); + int (*msg_queue_alloc_security)(struct kern_ipc_perm *); + void (*msg_queue_free_security)(struct kern_ipc_perm *); + int (*msg_queue_associate)(struct kern_ipc_perm *, int); + int (*msg_queue_msgctl)(struct kern_ipc_perm *, int); + int (*msg_queue_msgsnd)(struct kern_ipc_perm *, struct msg_msg *, int); + int (*msg_queue_msgrcv)(struct kern_ipc_perm *, struct msg_msg *, struct task_struct *, long int, int); + int (*shm_alloc_security)(struct kern_ipc_perm *); + void (*shm_free_security)(struct kern_ipc_perm *); + int (*shm_associate)(struct kern_ipc_perm *, int); + int (*shm_shmctl)(struct kern_ipc_perm *, int); + int (*shm_shmat)(struct kern_ipc_perm *, char *, int); + int (*sem_alloc_security)(struct kern_ipc_perm *); + void (*sem_free_security)(struct kern_ipc_perm *); + int (*sem_associate)(struct kern_ipc_perm *, int); + int (*sem_semctl)(struct kern_ipc_perm *, int); + int (*sem_semop)(struct kern_ipc_perm *, struct sembuf *, unsigned int, int); + int (*netlink_send)(struct sock *, struct sk_buff *); + void (*d_instantiate)(struct dentry *, struct inode *); + int (*getprocattr)(struct task_struct *, char *, char **); + int (*setprocattr)(const char *, void *, size_t); + int (*ismaclabel)(const char *); + int (*secid_to_secctx)(u32, char **, u32 *); + int (*secctx_to_secid)(const char *, u32, u32 *); + void (*release_secctx)(char *, u32); + void (*inode_invalidate_secctx)(struct inode *); + int (*inode_notifysecctx)(struct inode *, void *, u32); + int (*inode_setsecctx)(struct dentry *, void *, u32); + int (*inode_getsecctx)(struct inode *, void **, u32 *); + int (*unix_stream_connect)(struct sock *, struct sock *, struct sock *); + int (*unix_may_send)(struct socket *, struct socket *); + int (*socket_create)(int, int, int, int); + int (*socket_post_create)(struct socket *, int, int, int, int); + int (*socket_socketpair)(struct socket *, struct socket *); + int (*socket_bind)(struct socket *, struct sockaddr *, int); + int (*socket_connect)(struct socket *, struct sockaddr *, int); + int (*socket_listen)(struct socket *, int); + int (*socket_accept)(struct socket *, struct socket *); + int (*socket_sendmsg)(struct socket *, struct msghdr *, int); + int (*socket_recvmsg)(struct socket *, struct msghdr *, int, int); + int (*socket_getsockname)(struct socket *); + int (*socket_getpeername)(struct socket *); + int (*socket_getsockopt)(struct socket *, int, int); + int (*socket_setsockopt)(struct socket *, int, int); + int (*socket_shutdown)(struct socket *, int); + int (*socket_sock_rcv_skb)(struct sock *, struct sk_buff *); + int (*socket_getpeersec_stream)(struct socket *, char *, int *, unsigned int); + int (*socket_getpeersec_dgram)(struct socket *, struct sk_buff *, u32 *); + int (*sk_alloc_security)(struct sock *, int, gfp_t); + void (*sk_free_security)(struct sock *); + void (*sk_clone_security)(const struct sock *, struct sock *); + void (*sk_getsecid)(struct sock *, u32 *); + void (*sock_graft)(struct sock *, struct socket *); + int (*inet_conn_request)(struct sock *, struct sk_buff *, struct request_sock *); + void (*inet_csk_clone)(struct sock *, const struct request_sock *); + void (*inet_conn_established)(struct sock *, struct sk_buff *); + int (*secmark_relabel_packet)(u32); + void (*secmark_refcount_inc)(); + void (*secmark_refcount_dec)(); + void (*req_classify_flow)(const struct request_sock *, struct flowi *); + int (*tun_dev_alloc_security)(void **); + void (*tun_dev_free_security)(void *); + int (*tun_dev_create)(); + int (*tun_dev_attach_queue)(void *); + int (*tun_dev_attach)(struct sock *, void *); + int (*tun_dev_open)(void *); + int (*sctp_assoc_request)(struct sctp_endpoint *, struct sk_buff *); + int (*sctp_bind_connect)(struct sock *, int, struct sockaddr *, int); + void (*sctp_sk_clone)(struct sctp_endpoint *, struct sock *, struct sock *); + int (*key_alloc)(struct key *, const struct cred *, long unsigned int); + void (*key_free)(struct key *); + int (*key_permission)(key_ref_t, const struct cred *, enum key_need_perm); + int (*key_getsecurity)(struct key *, char **); + int (*audit_rule_init)(u32, u32, char *, void **); + int (*audit_rule_known)(struct audit_krule *); + int (*audit_rule_match)(u32, u32, u32, void *); + void (*audit_rule_free)(void *); + int (*bpf)(int, union bpf_attr *, unsigned int); + int (*bpf_map)(struct bpf_map *, fmode_t); + int (*bpf_prog)(struct bpf_prog *); + int (*bpf_map_alloc_security)(struct bpf_map *); + void (*bpf_map_free_security)(struct bpf_map *); + int (*bpf_prog_alloc_security)(struct bpf_prog_aux *); + void (*bpf_prog_free_security)(struct bpf_prog_aux *); + int (*locked_down)(enum lockdown_reason); + int (*perf_event_open)(struct perf_event_attr *, int); + int (*perf_event_alloc)(struct perf_event *); + void (*perf_event_free)(struct perf_event *); + int (*perf_event_read)(struct perf_event *); + int (*perf_event_write)(struct perf_event *); +}; + +struct security_hook_heads { + struct hlist_head binder_set_context_mgr; + struct hlist_head binder_transaction; + struct hlist_head binder_transfer_binder; + struct hlist_head binder_transfer_file; + struct hlist_head ptrace_access_check; + struct hlist_head ptrace_traceme; + struct hlist_head capget; + struct hlist_head capset; + struct hlist_head capable; + struct hlist_head quotactl; + struct hlist_head quota_on; + struct hlist_head syslog; + struct hlist_head settime; + struct hlist_head vm_enough_memory; + struct hlist_head bprm_creds_for_exec; + struct hlist_head bprm_creds_from_file; + struct hlist_head bprm_check_security; + struct hlist_head bprm_committing_creds; + struct hlist_head bprm_committed_creds; + struct hlist_head fs_context_dup; + struct hlist_head fs_context_parse_param; + struct hlist_head sb_alloc_security; + struct hlist_head sb_free_security; + struct hlist_head sb_free_mnt_opts; + struct hlist_head sb_eat_lsm_opts; + struct hlist_head sb_remount; + struct hlist_head sb_kern_mount; + struct hlist_head sb_show_options; + struct hlist_head sb_statfs; + struct hlist_head sb_mount; + struct hlist_head sb_umount; + struct hlist_head sb_pivotroot; + struct hlist_head sb_set_mnt_opts; + struct hlist_head sb_clone_mnt_opts; + struct hlist_head sb_add_mnt_opt; + struct hlist_head move_mount; + struct hlist_head dentry_init_security; + struct hlist_head dentry_create_files_as; + struct hlist_head path_notify; + struct hlist_head inode_alloc_security; + struct hlist_head inode_free_security; + struct hlist_head inode_init_security; + struct hlist_head inode_create; + struct hlist_head inode_link; + struct hlist_head inode_unlink; + struct hlist_head inode_symlink; + struct hlist_head inode_mkdir; + struct hlist_head inode_rmdir; + struct hlist_head inode_mknod; + struct hlist_head inode_rename; + struct hlist_head inode_readlink; + struct hlist_head inode_follow_link; + struct hlist_head inode_permission; + struct hlist_head inode_setattr; + struct hlist_head inode_getattr; + struct hlist_head inode_setxattr; + struct hlist_head inode_post_setxattr; + struct hlist_head inode_getxattr; + struct hlist_head inode_listxattr; + struct hlist_head inode_removexattr; + struct hlist_head inode_need_killpriv; + struct hlist_head inode_killpriv; + struct hlist_head inode_getsecurity; + struct hlist_head inode_setsecurity; + struct hlist_head inode_listsecurity; + struct hlist_head inode_getsecid; + struct hlist_head inode_copy_up; + struct hlist_head inode_copy_up_xattr; + struct hlist_head kernfs_init_security; + struct hlist_head file_permission; + struct hlist_head file_alloc_security; + struct hlist_head file_free_security; + struct hlist_head file_ioctl; + struct hlist_head mmap_addr; + struct hlist_head mmap_file; + struct hlist_head file_mprotect; + struct hlist_head file_lock; + struct hlist_head file_fcntl; + struct hlist_head file_set_fowner; + struct hlist_head file_send_sigiotask; + struct hlist_head file_receive; + struct hlist_head file_open; + struct hlist_head task_alloc; + struct hlist_head task_free; + struct hlist_head cred_alloc_blank; + struct hlist_head cred_free; + struct hlist_head cred_prepare; + struct hlist_head cred_transfer; + struct hlist_head cred_getsecid; + struct hlist_head kernel_act_as; + struct hlist_head kernel_create_files_as; + struct hlist_head kernel_module_request; + struct hlist_head kernel_load_data; + struct hlist_head kernel_post_load_data; + struct hlist_head kernel_read_file; + struct hlist_head kernel_post_read_file; + struct hlist_head task_fix_setuid; + struct hlist_head task_fix_setgid; + struct hlist_head task_setpgid; + struct hlist_head task_getpgid; + struct hlist_head task_getsid; + struct hlist_head task_getsecid; + struct hlist_head task_setnice; + struct hlist_head task_setioprio; + struct hlist_head task_getioprio; + struct hlist_head task_prlimit; + struct hlist_head task_setrlimit; + struct hlist_head task_setscheduler; + struct hlist_head task_getscheduler; + struct hlist_head task_movememory; + struct hlist_head task_kill; + struct hlist_head task_prctl; + struct hlist_head task_to_inode; + struct hlist_head ipc_permission; + struct hlist_head ipc_getsecid; + struct hlist_head msg_msg_alloc_security; + struct hlist_head msg_msg_free_security; + struct hlist_head msg_queue_alloc_security; + struct hlist_head msg_queue_free_security; + struct hlist_head msg_queue_associate; + struct hlist_head msg_queue_msgctl; + struct hlist_head msg_queue_msgsnd; + struct hlist_head msg_queue_msgrcv; + struct hlist_head shm_alloc_security; + struct hlist_head shm_free_security; + struct hlist_head shm_associate; + struct hlist_head shm_shmctl; + struct hlist_head shm_shmat; + struct hlist_head sem_alloc_security; + struct hlist_head sem_free_security; + struct hlist_head sem_associate; + struct hlist_head sem_semctl; + struct hlist_head sem_semop; + struct hlist_head netlink_send; + struct hlist_head d_instantiate; + struct hlist_head getprocattr; + struct hlist_head setprocattr; + struct hlist_head ismaclabel; + struct hlist_head secid_to_secctx; + struct hlist_head secctx_to_secid; + struct hlist_head release_secctx; + struct hlist_head inode_invalidate_secctx; + struct hlist_head inode_notifysecctx; + struct hlist_head inode_setsecctx; + struct hlist_head inode_getsecctx; + struct hlist_head unix_stream_connect; + struct hlist_head unix_may_send; + struct hlist_head socket_create; + struct hlist_head socket_post_create; + struct hlist_head socket_socketpair; + struct hlist_head socket_bind; + struct hlist_head socket_connect; + struct hlist_head socket_listen; + struct hlist_head socket_accept; + struct hlist_head socket_sendmsg; + struct hlist_head socket_recvmsg; + struct hlist_head socket_getsockname; + struct hlist_head socket_getpeername; + struct hlist_head socket_getsockopt; + struct hlist_head socket_setsockopt; + struct hlist_head socket_shutdown; + struct hlist_head socket_sock_rcv_skb; + struct hlist_head socket_getpeersec_stream; + struct hlist_head socket_getpeersec_dgram; + struct hlist_head sk_alloc_security; + struct hlist_head sk_free_security; + struct hlist_head sk_clone_security; + struct hlist_head sk_getsecid; + struct hlist_head sock_graft; + struct hlist_head inet_conn_request; + struct hlist_head inet_csk_clone; + struct hlist_head inet_conn_established; + struct hlist_head secmark_relabel_packet; + struct hlist_head secmark_refcount_inc; + struct hlist_head secmark_refcount_dec; + struct hlist_head req_classify_flow; + struct hlist_head tun_dev_alloc_security; + struct hlist_head tun_dev_free_security; + struct hlist_head tun_dev_create; + struct hlist_head tun_dev_attach_queue; + struct hlist_head tun_dev_attach; + struct hlist_head tun_dev_open; + struct hlist_head sctp_assoc_request; + struct hlist_head sctp_bind_connect; + struct hlist_head sctp_sk_clone; + struct hlist_head key_alloc; + struct hlist_head key_free; + struct hlist_head key_permission; + struct hlist_head key_getsecurity; + struct hlist_head audit_rule_init; + struct hlist_head audit_rule_known; + struct hlist_head audit_rule_match; + struct hlist_head audit_rule_free; + struct hlist_head bpf; + struct hlist_head bpf_map; + struct hlist_head bpf_prog; + struct hlist_head bpf_map_alloc_security; + struct hlist_head bpf_map_free_security; + struct hlist_head bpf_prog_alloc_security; + struct hlist_head bpf_prog_free_security; + struct hlist_head locked_down; + struct hlist_head perf_event_open; + struct hlist_head perf_event_alloc; + struct hlist_head perf_event_free; + struct hlist_head perf_event_read; + struct hlist_head perf_event_write; +}; + +struct security_hook_list { + struct hlist_node list; + struct hlist_head *head; + union security_list_options hook; + char *lsm; +}; + +enum lsm_order { + LSM_ORDER_FIRST = 4294967295, + LSM_ORDER_MUTABLE = 0, +}; + +struct lsm_info { + const char *name; + enum lsm_order order; + long unsigned int flags; + int *enabled; + int (*init)(); + struct lsm_blob_sizes *blobs; +}; + +enum lsm_event { + LSM_POLICY_CHANGE = 0, +}; + +typedef int (*initxattrs)(struct inode *, const struct xattr *, void *); + +enum ib_uverbs_write_cmds { + IB_USER_VERBS_CMD_GET_CONTEXT = 0, + IB_USER_VERBS_CMD_QUERY_DEVICE = 1, + IB_USER_VERBS_CMD_QUERY_PORT = 2, + IB_USER_VERBS_CMD_ALLOC_PD = 3, + IB_USER_VERBS_CMD_DEALLOC_PD = 4, + IB_USER_VERBS_CMD_CREATE_AH = 5, + IB_USER_VERBS_CMD_MODIFY_AH = 6, + IB_USER_VERBS_CMD_QUERY_AH = 7, + IB_USER_VERBS_CMD_DESTROY_AH = 8, + IB_USER_VERBS_CMD_REG_MR = 9, + IB_USER_VERBS_CMD_REG_SMR = 10, + IB_USER_VERBS_CMD_REREG_MR = 11, + IB_USER_VERBS_CMD_QUERY_MR = 12, + IB_USER_VERBS_CMD_DEREG_MR = 13, + IB_USER_VERBS_CMD_ALLOC_MW = 14, + IB_USER_VERBS_CMD_BIND_MW = 15, + IB_USER_VERBS_CMD_DEALLOC_MW = 16, + IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL = 17, + IB_USER_VERBS_CMD_CREATE_CQ = 18, + IB_USER_VERBS_CMD_RESIZE_CQ = 19, + IB_USER_VERBS_CMD_DESTROY_CQ = 20, + IB_USER_VERBS_CMD_POLL_CQ = 21, + IB_USER_VERBS_CMD_PEEK_CQ = 22, + IB_USER_VERBS_CMD_REQ_NOTIFY_CQ = 23, + IB_USER_VERBS_CMD_CREATE_QP = 24, + IB_USER_VERBS_CMD_QUERY_QP = 25, + IB_USER_VERBS_CMD_MODIFY_QP = 26, + IB_USER_VERBS_CMD_DESTROY_QP = 27, + IB_USER_VERBS_CMD_POST_SEND = 28, + IB_USER_VERBS_CMD_POST_RECV = 29, + IB_USER_VERBS_CMD_ATTACH_MCAST = 30, + IB_USER_VERBS_CMD_DETACH_MCAST = 31, + IB_USER_VERBS_CMD_CREATE_SRQ = 32, + IB_USER_VERBS_CMD_MODIFY_SRQ = 33, + IB_USER_VERBS_CMD_QUERY_SRQ = 34, + IB_USER_VERBS_CMD_DESTROY_SRQ = 35, + IB_USER_VERBS_CMD_POST_SRQ_RECV = 36, + IB_USER_VERBS_CMD_OPEN_XRCD = 37, + IB_USER_VERBS_CMD_CLOSE_XRCD = 38, + IB_USER_VERBS_CMD_CREATE_XSRQ = 39, + IB_USER_VERBS_CMD_OPEN_QP = 40, +}; + +enum ib_uverbs_wc_opcode { + IB_UVERBS_WC_SEND = 0, + IB_UVERBS_WC_RDMA_WRITE = 1, + IB_UVERBS_WC_RDMA_READ = 2, + IB_UVERBS_WC_COMP_SWAP = 3, + IB_UVERBS_WC_FETCH_ADD = 4, + IB_UVERBS_WC_BIND_MW = 5, + IB_UVERBS_WC_LOCAL_INV = 6, + IB_UVERBS_WC_TSO = 7, +}; + +enum ib_uverbs_create_qp_mask { + IB_UVERBS_CREATE_QP_MASK_IND_TABLE = 1, +}; + +enum ib_uverbs_wr_opcode { + IB_UVERBS_WR_RDMA_WRITE = 0, + IB_UVERBS_WR_RDMA_WRITE_WITH_IMM = 1, + IB_UVERBS_WR_SEND = 2, + IB_UVERBS_WR_SEND_WITH_IMM = 3, + IB_UVERBS_WR_RDMA_READ = 4, + IB_UVERBS_WR_ATOMIC_CMP_AND_SWP = 5, + IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD = 6, + IB_UVERBS_WR_LOCAL_INV = 7, + IB_UVERBS_WR_BIND_MW = 8, + IB_UVERBS_WR_SEND_WITH_INV = 9, + IB_UVERBS_WR_TSO = 10, + IB_UVERBS_WR_RDMA_READ_WITH_INV = 11, + IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP = 12, + IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD = 13, +}; + +enum ib_uverbs_access_flags { + IB_UVERBS_ACCESS_LOCAL_WRITE = 1, + IB_UVERBS_ACCESS_REMOTE_WRITE = 2, + IB_UVERBS_ACCESS_REMOTE_READ = 4, + IB_UVERBS_ACCESS_REMOTE_ATOMIC = 8, + IB_UVERBS_ACCESS_MW_BIND = 16, + IB_UVERBS_ACCESS_ZERO_BASED = 32, + IB_UVERBS_ACCESS_ON_DEMAND = 64, + IB_UVERBS_ACCESS_HUGETLB = 128, + IB_UVERBS_ACCESS_RELAXED_ORDERING = 1048576, + IB_UVERBS_ACCESS_OPTIONAL_RANGE = 1072693248, +}; + +enum ib_uverbs_srq_type { + IB_UVERBS_SRQT_BASIC = 0, + IB_UVERBS_SRQT_XRC = 1, + IB_UVERBS_SRQT_TM = 2, +}; + +enum ib_uverbs_wq_type { + IB_UVERBS_WQT_RQ = 0, +}; + +enum ib_uverbs_wq_flags { + IB_UVERBS_WQ_FLAGS_CVLAN_STRIPPING = 1, + IB_UVERBS_WQ_FLAGS_SCATTER_FCS = 2, + IB_UVERBS_WQ_FLAGS_DELAY_DROP = 4, + IB_UVERBS_WQ_FLAGS_PCI_WRITE_END_PADDING = 8, +}; + +enum ib_uverbs_qp_type { + IB_UVERBS_QPT_RC = 2, + IB_UVERBS_QPT_UC = 3, + IB_UVERBS_QPT_UD = 4, + IB_UVERBS_QPT_RAW_PACKET = 8, + IB_UVERBS_QPT_XRC_INI = 9, + IB_UVERBS_QPT_XRC_TGT = 10, + IB_UVERBS_QPT_DRIVER = 255, +}; + +enum ib_uverbs_qp_create_flags { + IB_UVERBS_QP_CREATE_BLOCK_MULTICAST_LOOPBACK = 2, + IB_UVERBS_QP_CREATE_SCATTER_FCS = 256, + IB_UVERBS_QP_CREATE_CVLAN_STRIPPING = 512, + IB_UVERBS_QP_CREATE_PCI_WRITE_END_PADDING = 2048, + IB_UVERBS_QP_CREATE_SQ_SIG_ALL = 4096, +}; + +enum ib_uverbs_gid_type { + IB_UVERBS_GID_TYPE_IB = 0, + IB_UVERBS_GID_TYPE_ROCE_V1 = 1, + IB_UVERBS_GID_TYPE_ROCE_V2 = 2, +}; + +enum ib_poll_context { + IB_POLL_SOFTIRQ = 0, + IB_POLL_WORKQUEUE = 1, + IB_POLL_UNBOUND_WORKQUEUE = 2, + IB_POLL_LAST_POOL_TYPE = 2, + IB_POLL_DIRECT = 3, +}; + +struct lsm_network_audit { + int netif; + struct sock *sk; + u16 family; + __be16 dport; + __be16 sport; + union { + struct { + __be32 daddr; + __be32 saddr; + } v4; + struct { + struct in6_addr daddr; + struct in6_addr saddr; + } v6; + } fam; +}; + +struct lsm_ioctlop_audit { + struct path path; + u16 cmd; +}; + +struct lsm_ibpkey_audit { + u64 subnet_prefix; + u16 pkey; +}; + +struct lsm_ibendport_audit { + char dev_name[64]; + u8 port; +}; + +struct selinux_state; + +struct selinux_audit_data { + u32 ssid; + u32 tsid; + u16 tclass; + u32 requested; + u32 audited; + u32 denied; + int result; + struct selinux_state *state; +}; + +struct common_audit_data { + char type; + union { + struct path path; + struct dentry *dentry; + struct inode *inode; + struct lsm_network_audit *net; + int cap; + int ipc_id; + struct task_struct *tsk; + struct { + key_serial_t key; + char *key_desc; + } key_struct; + char *kmod_name; + struct lsm_ioctlop_audit *op; + struct file *file; + struct lsm_ibpkey_audit *ibpkey; + struct lsm_ibendport_audit *ibendport; + int reason; + } u; + union { + struct selinux_audit_data *selinux_audit_data; + }; +}; + +enum { + POLICYDB_CAPABILITY_NETPEER = 0, + POLICYDB_CAPABILITY_OPENPERM = 1, + POLICYDB_CAPABILITY_EXTSOCKCLASS = 2, + POLICYDB_CAPABILITY_ALWAYSNETWORK = 3, + POLICYDB_CAPABILITY_CGROUPSECLABEL = 4, + POLICYDB_CAPABILITY_NNP_NOSUID_TRANSITION = 5, + POLICYDB_CAPABILITY_GENFS_SECLABEL_SYMLINKS = 6, + __POLICYDB_CAPABILITY_MAX = 7, +}; + +struct selinux_avc; + +struct selinux_policy; + +struct selinux_state { + bool disabled; + bool enforcing; + bool checkreqprot; + bool initialized; + bool policycap[7]; + struct page *status_page; + struct mutex status_lock; + struct selinux_avc *avc; + struct selinux_policy *policy; + struct mutex policy_mutex; +}; + +struct avc_cache { + struct hlist_head slots[512]; + spinlock_t slots_lock[512]; + atomic_t lru_hint; + atomic_t active_nodes; + u32 latest_notif; +}; + +struct selinux_avc { + unsigned int avc_cache_threshold; + struct avc_cache avc_cache; +}; + +struct av_decision { + u32 allowed; + u32 auditallow; + u32 auditdeny; + u32 seqno; + u32 flags; +}; + +struct extended_perms_data { + u32 p[8]; +}; + +struct extended_perms_decision { + u8 used; + u8 driver; + struct extended_perms_data *allowed; + struct extended_perms_data *auditallow; + struct extended_perms_data *dontaudit; +}; + +struct extended_perms { + u16 len; + struct extended_perms_data drivers; +}; + +struct avc_cache_stats { + unsigned int lookups; + unsigned int misses; + unsigned int allocations; + unsigned int reclaims; + unsigned int frees; +}; + +struct security_class_mapping { + const char *name; + const char *perms[33]; +}; + +struct trace_event_raw_selinux_audited { + struct trace_entry ent; + u32 requested; + u32 denied; + u32 audited; + int result; + u32 __data_loc_scontext; + u32 __data_loc_tcontext; + u32 __data_loc_tclass; + char __data[0]; +}; + +struct trace_event_data_offsets_selinux_audited { + u32 scontext; + u32 tcontext; + u32 tclass; +}; + +typedef void (*btf_trace_selinux_audited)(void *, struct selinux_audit_data *, char *, char *, const char *); + +struct avc_xperms_node; + +struct avc_entry { + u32 ssid; + u32 tsid; + u16 tclass; + struct av_decision avd; + struct avc_xperms_node *xp_node; +}; + +struct avc_xperms_node { + struct extended_perms xp; + struct list_head xpd_head; +}; + +struct avc_node { + struct avc_entry ae; + struct hlist_node list; + struct callback_head rhead; +}; + +struct avc_xperms_decision_node { + struct extended_perms_decision xpd; + struct list_head xpd_list; +}; + +struct avc_callback_node { + int (*callback)(u32); + u32 events; + struct avc_callback_node *next; +}; + +typedef __u16 __sum16; + +enum sctp_endpoint_type { + SCTP_EP_TYPE_SOCKET = 0, + SCTP_EP_TYPE_ASSOCIATION = 1, +}; + +struct sctp_chunk; + +struct sctp_inq { + struct list_head in_chunk_list; + struct sctp_chunk *in_progress; + struct work_struct immediate; +}; + +struct sctp_bind_addr { + __u16 port; + struct list_head address_list; +}; + +struct sctp_ep_common { + struct hlist_node node; + int hashent; + enum sctp_endpoint_type type; + refcount_t refcnt; + bool dead; + struct sock *sk; + struct net *net; + struct sctp_inq inqueue; + struct sctp_bind_addr bind_addr; +}; + +struct sctp_hmac_algo_param; + +struct sctp_chunks_param; + +struct sctp_endpoint { + struct sctp_ep_common base; + struct list_head asocs; + __u8 secret_key[32]; + __u8 *digest; + __u32 sndbuf_policy; + __u32 rcvbuf_policy; + struct crypto_shash **auth_hmacs; + struct sctp_hmac_algo_param *auth_hmacs_list; + struct sctp_chunks_param *auth_chunk_list; + struct list_head endpoint_shared_keys; + __u16 active_key_id; + __u8 ecn_enable: 1; + __u8 auth_enable: 1; + __u8 intl_enable: 1; + __u8 prsctp_enable: 1; + __u8 asconf_enable: 1; + __u8 reconf_enable: 1; + __u8 strreset_enable; + u32 secid; + u32 peer_secid; +}; + +struct nf_hook_state; + +typedef unsigned int nf_hookfn(void *, struct sk_buff *, const struct nf_hook_state *); + +struct nf_hook_entry { + nf_hookfn *hook; + void *priv; +}; + +struct nf_hook_entries { + u16 num_hook_entries; + struct nf_hook_entry hooks[0]; +}; + +struct nf_hook_state { + unsigned int hook; + u_int8_t pf; + struct net_device *in; + struct net_device *out; + struct sock *sk; + struct net *net; + int (*okfn)(struct net *, struct sock *, struct sk_buff *); +}; + +struct nf_hook_ops { + nf_hookfn *hook; + struct net_device *dev; + void *priv; + u_int8_t pf; + unsigned int hooknum; + int priority; +}; + +enum nf_ip_hook_priorities { + NF_IP_PRI_FIRST = 2147483648, + NF_IP_PRI_RAW_BEFORE_DEFRAG = 4294966846, + NF_IP_PRI_CONNTRACK_DEFRAG = 4294966896, + NF_IP_PRI_RAW = 4294966996, + NF_IP_PRI_SELINUX_FIRST = 4294967071, + NF_IP_PRI_CONNTRACK = 4294967096, + NF_IP_PRI_MANGLE = 4294967146, + NF_IP_PRI_NAT_DST = 4294967196, + NF_IP_PRI_FILTER = 0, + NF_IP_PRI_SECURITY = 50, + NF_IP_PRI_NAT_SRC = 100, + NF_IP_PRI_SELINUX_LAST = 225, + NF_IP_PRI_CONNTRACK_HELPER = 300, + NF_IP_PRI_CONNTRACK_CONFIRM = 2147483647, + NF_IP_PRI_LAST = 2147483647, +}; + +enum nf_ip6_hook_priorities { + NF_IP6_PRI_FIRST = 2147483648, + NF_IP6_PRI_RAW_BEFORE_DEFRAG = 4294966846, + NF_IP6_PRI_CONNTRACK_DEFRAG = 4294966896, + NF_IP6_PRI_RAW = 4294966996, + NF_IP6_PRI_SELINUX_FIRST = 4294967071, + NF_IP6_PRI_CONNTRACK = 4294967096, + NF_IP6_PRI_MANGLE = 4294967146, + NF_IP6_PRI_NAT_DST = 4294967196, + NF_IP6_PRI_FILTER = 0, + NF_IP6_PRI_SECURITY = 50, + NF_IP6_PRI_NAT_SRC = 100, + NF_IP6_PRI_SELINUX_LAST = 225, + NF_IP6_PRI_CONNTRACK_HELPER = 300, + NF_IP6_PRI_LAST = 2147483647, +}; + +struct socket_alloc { + struct socket socket; + struct inode vfs_inode; +}; + +struct ip_options { + __be32 faddr; + __be32 nexthop; + unsigned char optlen; + unsigned char srr; + unsigned char rr; + unsigned char ts; + unsigned char is_strictroute: 1; + unsigned char srr_is_hit: 1; + unsigned char is_changed: 1; + unsigned char rr_needaddr: 1; + unsigned char ts_needtime: 1; + unsigned char ts_needaddr: 1; + unsigned char router_alert; + unsigned char cipso; + unsigned char __pad2; + unsigned char __data[0]; +}; + +struct ip_options_rcu { + struct callback_head rcu; + struct ip_options opt; +}; + +struct ipv6_opt_hdr; + +struct ipv6_rt_hdr; + +struct ipv6_txoptions { + refcount_t refcnt; + int tot_len; + __u16 opt_flen; + __u16 opt_nflen; + struct ipv6_opt_hdr *hopopt; + struct ipv6_opt_hdr *dst0opt; + struct ipv6_rt_hdr *srcrt; + struct ipv6_opt_hdr *dst1opt; + struct callback_head rcu; +}; + +struct inet_cork { + unsigned int flags; + __be32 addr; + struct ip_options *opt; + unsigned int fragsize; + int length; + struct dst_entry *dst; + u8 tx_flags; + __u8 ttl; + __s16 tos; + char priority; + __u16 gso_size; + u64 transmit_time; + u32 mark; +}; + +struct inet_cork_full { + struct inet_cork base; + struct flowi fl; +}; + +struct ipv6_pinfo; + +struct ip_mc_socklist; + +struct inet_sock { + struct sock sk; + struct ipv6_pinfo *pinet6; + __be32 inet_saddr; + __s16 uc_ttl; + __u16 cmsg_flags; + __be16 inet_sport; + __u16 inet_id; + struct ip_options_rcu *inet_opt; + int rx_dst_ifindex; + __u8 tos; + __u8 min_ttl; + __u8 mc_ttl; + __u8 pmtudisc; + __u8 recverr: 1; + __u8 is_icsk: 1; + __u8 freebind: 1; + __u8 hdrincl: 1; + __u8 mc_loop: 1; + __u8 transparent: 1; + __u8 mc_all: 1; + __u8 nodefrag: 1; + __u8 bind_address_no_port: 1; + __u8 recverr_rfc4884: 1; + __u8 defer_connect: 1; + __u8 rcv_tos; + __u8 convert_csum; + int uc_index; + int mc_index; + __be32 mc_addr; + struct ip_mc_socklist *mc_list; + struct inet_cork_full cork; +}; + +struct in6_pktinfo { + struct in6_addr ipi6_addr; + int ipi6_ifindex; +}; + +struct inet6_cork { + struct ipv6_txoptions *opt; + u8 hop_limit; + u8 tclass; +}; + +struct ipv6_mc_socklist; + +struct ipv6_ac_socklist; + +struct ipv6_fl_socklist; + +struct ipv6_pinfo { + struct in6_addr saddr; + struct in6_pktinfo sticky_pktinfo; + const struct in6_addr *daddr_cache; + const struct in6_addr *saddr_cache; + __be32 flow_label; + __u32 frag_size; + __u16 __unused_1: 7; + __s16 hop_limit: 9; + __u16 mc_loop: 1; + __u16 __unused_2: 6; + __s16 mcast_hops: 9; + int ucast_oif; + int mcast_oif; + union { + struct { + __u16 srcrt: 1; + __u16 osrcrt: 1; + __u16 rxinfo: 1; + __u16 rxoinfo: 1; + __u16 rxhlim: 1; + __u16 rxohlim: 1; + __u16 hopopts: 1; + __u16 ohopopts: 1; + __u16 dstopts: 1; + __u16 odstopts: 1; + __u16 rxflow: 1; + __u16 rxtclass: 1; + __u16 rxpmtu: 1; + __u16 rxorigdstaddr: 1; + __u16 recvfragsize: 1; + } bits; + __u16 all; + } rxopt; + __u16 recverr: 1; + __u16 sndflow: 1; + __u16 repflow: 1; + __u16 pmtudisc: 3; + __u16 padding: 1; + __u16 srcprefs: 3; + __u16 dontfrag: 1; + __u16 autoflowlabel: 1; + __u16 autoflowlabel_set: 1; + __u16 mc_all: 1; + __u16 recverr_rfc4884: 1; + __u16 rtalert_isolate: 1; + __u8 min_hopcount; + __u8 tclass; + __be32 rcv_flowinfo; + __u32 dst_cookie; + __u32 rx_dst_cookie; + struct ipv6_mc_socklist *ipv6_mc_list; + struct ipv6_ac_socklist *ipv6_ac_list; + struct ipv6_fl_socklist *ipv6_fl_list; + struct ipv6_txoptions *opt; + struct sk_buff *pktoptions; + struct sk_buff *rxpmtu; + struct inet6_cork cork; +}; + +struct tcphdr { + __be16 source; + __be16 dest; + __be32 seq; + __be32 ack_seq; + __u16 res1: 4; + __u16 doff: 4; + __u16 fin: 1; + __u16 syn: 1; + __u16 rst: 1; + __u16 psh: 1; + __u16 ack: 1; + __u16 urg: 1; + __u16 ece: 1; + __u16 cwr: 1; + __be16 window; + __sum16 check; + __be16 urg_ptr; +}; + +struct iphdr { + __u8 ihl: 4; + __u8 version: 4; + __u8 tos; + __be16 tot_len; + __be16 id; + __be16 frag_off; + __u8 ttl; + __u8 protocol; + __sum16 check; + __be32 saddr; + __be32 daddr; +}; + +struct ipv6_rt_hdr { + __u8 nexthdr; + __u8 hdrlen; + __u8 type; + __u8 segments_left; +}; + +struct ipv6_opt_hdr { + __u8 nexthdr; + __u8 hdrlen; +}; + +struct ipv6hdr { + __u8 priority: 4; + __u8 version: 4; + __u8 flow_lbl[3]; + __be16 payload_len; + __u8 nexthdr; + __u8 hop_limit; + struct in6_addr saddr; + struct in6_addr daddr; +}; + +struct udphdr { + __be16 source; + __be16 dest; + __be16 len; + __sum16 check; +}; + +struct inet6_skb_parm { + int iif; + __be16 ra; + __u16 dst0; + __u16 srcrt; + __u16 dst1; + __u16 lastopt; + __u16 nhoff; + __u16 flags; + __u16 dsthao; + __u16 frag_max_size; +}; + +struct ip6_sf_socklist; + +struct ipv6_mc_socklist { + struct in6_addr addr; + int ifindex; + unsigned int sfmode; + struct ipv6_mc_socklist *next; + rwlock_t sflock; + struct ip6_sf_socklist *sflist; + struct callback_head rcu; +}; + +struct ipv6_ac_socklist { + struct in6_addr acl_addr; + int acl_ifindex; + struct ipv6_ac_socklist *acl_next; +}; + +struct ip6_flowlabel; + +struct ipv6_fl_socklist { + struct ipv6_fl_socklist *next; + struct ip6_flowlabel *fl; + struct callback_head rcu; +}; + +struct ip6_sf_socklist { + unsigned int sl_max; + unsigned int sl_count; + struct in6_addr sl_addr[0]; +}; + +struct ip6_flowlabel { + struct ip6_flowlabel *next; + __be32 label; + atomic_t users; + struct in6_addr dst; + struct ipv6_txoptions *opt; + long unsigned int linger; + struct callback_head rcu; + u8 share; + union { + struct pid *pid; + kuid_t uid; + } owner; + long unsigned int lastuse; + long unsigned int expires; + struct net *fl_net; +}; + +struct inet_skb_parm { + int iif; + struct ip_options opt; + u16 flags; + u16 frag_max_size; +}; + +struct tty_file_private { + struct tty_struct *tty; + struct file *file; + struct list_head list; +}; + +struct netlbl_lsm_cache { + refcount_t refcount; + void (*free)(const void *); + void *data; +}; + +struct netlbl_lsm_catmap { + u32 startbit; + u64 bitmap[4]; + struct netlbl_lsm_catmap *next; +}; + +struct netlbl_lsm_secattr { + u32 flags; + u32 type; + char *domain; + struct netlbl_lsm_cache *cache; + struct { + struct { + struct netlbl_lsm_catmap *cat; + u32 lvl; + } mls; + u32 secid; + } attr; +}; + +struct dccp_hdr { + __be16 dccph_sport; + __be16 dccph_dport; + __u8 dccph_doff; + __u8 dccph_cscov: 4; + __u8 dccph_ccval: 4; + __sum16 dccph_checksum; + __u8 dccph_x: 1; + __u8 dccph_type: 4; + __u8 dccph_reserved: 3; + __u8 dccph_seq2; + __be16 dccph_seq; +}; + +enum dccp_state { + DCCP_OPEN = 1, + DCCP_REQUESTING = 2, + DCCP_LISTEN = 10, + DCCP_RESPOND = 3, + DCCP_ACTIVE_CLOSEREQ = 4, + DCCP_PASSIVE_CLOSE = 8, + DCCP_CLOSING = 11, + DCCP_TIME_WAIT = 6, + DCCP_CLOSED = 7, + DCCP_NEW_SYN_RECV = 12, + DCCP_PARTOPEN = 13, + DCCP_PASSIVE_CLOSEREQ = 14, + DCCP_MAX_STATES = 15, +}; + +typedef __s32 sctp_assoc_t; + +enum sctp_msg_flags { + MSG_NOTIFICATION = 32768, +}; + +struct sctp_initmsg { + __u16 sinit_num_ostreams; + __u16 sinit_max_instreams; + __u16 sinit_max_attempts; + __u16 sinit_max_init_timeo; +}; + +struct sctp_sndrcvinfo { + __u16 sinfo_stream; + __u16 sinfo_ssn; + __u16 sinfo_flags; + __u32 sinfo_ppid; + __u32 sinfo_context; + __u32 sinfo_timetolive; + __u32 sinfo_tsn; + __u32 sinfo_cumtsn; + sctp_assoc_t sinfo_assoc_id; +}; + +struct sctp_rtoinfo { + sctp_assoc_t srto_assoc_id; + __u32 srto_initial; + __u32 srto_max; + __u32 srto_min; +}; + +struct sctp_assocparams { + sctp_assoc_t sasoc_assoc_id; + __u16 sasoc_asocmaxrxt; + __u16 sasoc_number_peer_destinations; + __u32 sasoc_peer_rwnd; + __u32 sasoc_local_rwnd; + __u32 sasoc_cookie_life; +}; + +struct sctp_paddrparams { + sctp_assoc_t spp_assoc_id; + struct __kernel_sockaddr_storage spp_address; + __u32 spp_hbinterval; + __u16 spp_pathmaxrxt; + __u32 spp_pathmtu; + __u32 spp_sackdelay; + __u32 spp_flags; + __u32 spp_ipv6_flowlabel; + __u8 spp_dscp; + char: 8; +} __attribute__((packed)); + +struct sctphdr { + __be16 source; + __be16 dest; + __be32 vtag; + __le32 checksum; +}; + +struct sctp_chunkhdr { + __u8 type; + __u8 flags; + __be16 length; +}; + +enum sctp_cid { + SCTP_CID_DATA = 0, + SCTP_CID_INIT = 1, + SCTP_CID_INIT_ACK = 2, + SCTP_CID_SACK = 3, + SCTP_CID_HEARTBEAT = 4, + SCTP_CID_HEARTBEAT_ACK = 5, + SCTP_CID_ABORT = 6, + SCTP_CID_SHUTDOWN = 7, + SCTP_CID_SHUTDOWN_ACK = 8, + SCTP_CID_ERROR = 9, + SCTP_CID_COOKIE_ECHO = 10, + SCTP_CID_COOKIE_ACK = 11, + SCTP_CID_ECN_ECNE = 12, + SCTP_CID_ECN_CWR = 13, + SCTP_CID_SHUTDOWN_COMPLETE = 14, + SCTP_CID_AUTH = 15, + SCTP_CID_I_DATA = 64, + SCTP_CID_FWD_TSN = 192, + SCTP_CID_ASCONF = 193, + SCTP_CID_I_FWD_TSN = 194, + SCTP_CID_ASCONF_ACK = 128, + SCTP_CID_RECONF = 130, +}; + +struct sctp_paramhdr { + __be16 type; + __be16 length; +}; + +enum sctp_param { + SCTP_PARAM_HEARTBEAT_INFO = 256, + SCTP_PARAM_IPV4_ADDRESS = 1280, + SCTP_PARAM_IPV6_ADDRESS = 1536, + SCTP_PARAM_STATE_COOKIE = 1792, + SCTP_PARAM_UNRECOGNIZED_PARAMETERS = 2048, + SCTP_PARAM_COOKIE_PRESERVATIVE = 2304, + SCTP_PARAM_HOST_NAME_ADDRESS = 2816, + SCTP_PARAM_SUPPORTED_ADDRESS_TYPES = 3072, + SCTP_PARAM_ECN_CAPABLE = 128, + SCTP_PARAM_RANDOM = 640, + SCTP_PARAM_CHUNKS = 896, + SCTP_PARAM_HMAC_ALGO = 1152, + SCTP_PARAM_SUPPORTED_EXT = 2176, + SCTP_PARAM_FWD_TSN_SUPPORT = 192, + SCTP_PARAM_ADD_IP = 448, + SCTP_PARAM_DEL_IP = 704, + SCTP_PARAM_ERR_CAUSE = 960, + SCTP_PARAM_SET_PRIMARY = 1216, + SCTP_PARAM_SUCCESS_REPORT = 1472, + SCTP_PARAM_ADAPTATION_LAYER_IND = 1728, + SCTP_PARAM_RESET_OUT_REQUEST = 3328, + SCTP_PARAM_RESET_IN_REQUEST = 3584, + SCTP_PARAM_RESET_TSN_REQUEST = 3840, + SCTP_PARAM_RESET_RESPONSE = 4096, + SCTP_PARAM_RESET_ADD_OUT_STREAMS = 4352, + SCTP_PARAM_RESET_ADD_IN_STREAMS = 4608, +}; + +struct sctp_datahdr { + __be32 tsn; + __be16 stream; + __be16 ssn; + __u32 ppid; + __u8 payload[0]; +}; + +struct sctp_idatahdr { + __be32 tsn; + __be16 stream; + __be16 reserved; + __be32 mid; + union { + __u32 ppid; + __be32 fsn; + }; + __u8 payload[0]; +}; + +struct sctp_inithdr { + __be32 init_tag; + __be32 a_rwnd; + __be16 num_outbound_streams; + __be16 num_inbound_streams; + __be32 initial_tsn; + __u8 params[0]; +}; + +struct sctp_init_chunk { + struct sctp_chunkhdr chunk_hdr; + struct sctp_inithdr init_hdr; +}; + +struct sctp_ipv4addr_param { + struct sctp_paramhdr param_hdr; + struct in_addr addr; +}; + +struct sctp_ipv6addr_param { + struct sctp_paramhdr param_hdr; + struct in6_addr addr; +}; + +struct sctp_cookie_preserve_param { + struct sctp_paramhdr param_hdr; + __be32 lifespan_increment; +}; + +struct sctp_hostname_param { + struct sctp_paramhdr param_hdr; + uint8_t hostname[0]; +}; + +struct sctp_supported_addrs_param { + struct sctp_paramhdr param_hdr; + __be16 types[0]; +}; + +struct sctp_adaptation_ind_param { + struct sctp_paramhdr param_hdr; + __be32 adaptation_ind; +}; + +struct sctp_supported_ext_param { + struct sctp_paramhdr param_hdr; + __u8 chunks[0]; +}; + +struct sctp_random_param { + struct sctp_paramhdr param_hdr; + __u8 random_val[0]; +}; + +struct sctp_chunks_param { + struct sctp_paramhdr param_hdr; + __u8 chunks[0]; +}; + +struct sctp_hmac_algo_param { + struct sctp_paramhdr param_hdr; + __be16 hmac_ids[0]; +}; + +struct sctp_cookie_param { + struct sctp_paramhdr p; + __u8 body[0]; +}; + +struct sctp_gap_ack_block { + __be16 start; + __be16 end; +}; + +union sctp_sack_variable { + struct sctp_gap_ack_block gab; + __be32 dup; +}; + +struct sctp_sackhdr { + __be32 cum_tsn_ack; + __be32 a_rwnd; + __be16 num_gap_ack_blocks; + __be16 num_dup_tsns; + union sctp_sack_variable variable[0]; +}; + +struct sctp_heartbeathdr { + struct sctp_paramhdr info; +}; + +struct sctp_shutdownhdr { + __be32 cum_tsn_ack; +}; + +struct sctp_errhdr { + __be16 cause; + __be16 length; + __u8 variable[0]; +}; + +struct sctp_ecnehdr { + __be32 lowest_tsn; +}; + +struct sctp_cwrhdr { + __be32 lowest_tsn; +}; + +struct sctp_fwdtsn_skip { + __be16 stream; + __be16 ssn; +}; + +struct sctp_fwdtsn_hdr { + __be32 new_cum_tsn; + struct sctp_fwdtsn_skip skip[0]; +}; + +struct sctp_ifwdtsn_skip { + __be16 stream; + __u8 reserved; + __u8 flags; + __be32 mid; +}; + +struct sctp_ifwdtsn_hdr { + __be32 new_cum_tsn; + struct sctp_ifwdtsn_skip skip[0]; +}; + +struct sctp_addip_param { + struct sctp_paramhdr param_hdr; + __be32 crr_id; +}; + +struct sctp_addiphdr { + __be32 serial; + __u8 params[0]; +}; + +struct sctp_authhdr { + __be16 shkey_id; + __be16 hmac_id; + __u8 hmac[0]; +}; + +union sctp_addr { + struct sockaddr_in v4; + struct sockaddr_in6 v6; + struct sockaddr sa; +}; + +struct sctp_cookie { + __u32 my_vtag; + __u32 peer_vtag; + __u32 my_ttag; + __u32 peer_ttag; + ktime_t expiration; + __u16 sinit_num_ostreams; + __u16 sinit_max_instreams; + __u32 initial_tsn; + union sctp_addr peer_addr; + __u16 my_port; + __u8 prsctp_capable; + __u8 padding; + __u32 adaptation_ind; + __u8 auth_random[36]; + __u8 auth_hmacs[10]; + __u8 auth_chunks[20]; + __u32 raw_addr_list_len; + struct sctp_init_chunk peer_init[0]; +}; + +struct sctp_tsnmap { + long unsigned int *tsn_map; + __u32 base_tsn; + __u32 cumulative_tsn_ack_point; + __u32 max_tsn_seen; + __u16 len; + __u16 pending_data; + __u16 num_dup_tsns; + __be32 dup_tsns[16]; +}; + +struct sctp_inithdr_host { + __u32 init_tag; + __u32 a_rwnd; + __u16 num_outbound_streams; + __u16 num_inbound_streams; + __u32 initial_tsn; +}; + +enum sctp_state { + SCTP_STATE_CLOSED = 0, + SCTP_STATE_COOKIE_WAIT = 1, + SCTP_STATE_COOKIE_ECHOED = 2, + SCTP_STATE_ESTABLISHED = 3, + SCTP_STATE_SHUTDOWN_PENDING = 4, + SCTP_STATE_SHUTDOWN_SENT = 5, + SCTP_STATE_SHUTDOWN_RECEIVED = 6, + SCTP_STATE_SHUTDOWN_ACK_SENT = 7, +}; + +struct sctp_stream_out_ext; + +struct sctp_stream_out { + union { + __u32 mid; + __u16 ssn; + }; + __u32 mid_uo; + struct sctp_stream_out_ext *ext; + __u8 state; +}; + +struct sctp_stream_in { + union { + __u32 mid; + __u16 ssn; + }; + __u32 mid_uo; + __u32 fsn; + __u32 fsn_uo; + char pd_mode; + char pd_mode_uo; +}; + +struct sctp_stream_interleave; + +struct sctp_stream { + struct { + struct __genradix tree; + struct sctp_stream_out type[0]; + } out; + struct { + struct __genradix tree; + struct sctp_stream_in type[0]; + } in; + __u16 outcnt; + __u16 incnt; + struct sctp_stream_out *out_curr; + union { + struct { + struct list_head prio_list; + }; + struct { + struct list_head rr_list; + struct sctp_stream_out_ext *rr_next; + }; + }; + struct sctp_stream_interleave *si; +}; + +struct sctp_sched_ops; + +struct sctp_association; + +struct sctp_outq { + struct sctp_association *asoc; + struct list_head out_chunk_list; + struct sctp_sched_ops *sched; + unsigned int out_qlen; + unsigned int error; + struct list_head control_chunk_list; + struct list_head sacked; + struct list_head retransmit; + struct list_head abandoned; + __u32 outstanding_bytes; + char fast_rtx; + char cork; +}; + +struct sctp_ulpq { + char pd_mode; + struct sctp_association *asoc; + struct sk_buff_head reasm; + struct sk_buff_head reasm_uo; + struct sk_buff_head lobby; +}; + +struct sctp_priv_assoc_stats { + struct __kernel_sockaddr_storage obs_rto_ipaddr; + __u64 max_obs_rto; + __u64 isacks; + __u64 osacks; + __u64 opackets; + __u64 ipackets; + __u64 rtxchunks; + __u64 outofseqtsns; + __u64 idupchunks; + __u64 gapcnt; + __u64 ouodchunks; + __u64 iuodchunks; + __u64 oodchunks; + __u64 iodchunks; + __u64 octrlchunks; + __u64 ictrlchunks; +}; + +struct sctp_transport; + +struct sctp_auth_bytes; + +struct sctp_shared_key; + +struct sctp_association { + struct sctp_ep_common base; + struct list_head asocs; + sctp_assoc_t assoc_id; + struct sctp_endpoint *ep; + struct sctp_cookie c; + struct { + struct list_head transport_addr_list; + __u32 rwnd; + __u16 transport_count; + __u16 port; + struct sctp_transport *primary_path; + union sctp_addr primary_addr; + struct sctp_transport *active_path; + struct sctp_transport *retran_path; + struct sctp_transport *last_sent_to; + struct sctp_transport *last_data_from; + struct sctp_tsnmap tsn_map; + __be16 addip_disabled_mask; + __u16 ecn_capable: 1; + __u16 ipv4_address: 1; + __u16 ipv6_address: 1; + __u16 hostname_address: 1; + __u16 asconf_capable: 1; + __u16 prsctp_capable: 1; + __u16 reconf_capable: 1; + __u16 intl_capable: 1; + __u16 auth_capable: 1; + __u16 sack_needed: 1; + __u16 sack_generation: 1; + __u16 zero_window_announced: 1; + __u32 sack_cnt; + __u32 adaptation_ind; + struct sctp_inithdr_host i; + void *cookie; + int cookie_len; + __u32 addip_serial; + struct sctp_random_param *peer_random; + struct sctp_chunks_param *peer_chunks; + struct sctp_hmac_algo_param *peer_hmacs; + } peer; + enum sctp_state state; + int overall_error_count; + ktime_t cookie_life; + long unsigned int rto_initial; + long unsigned int rto_max; + long unsigned int rto_min; + int max_burst; + int max_retrans; + __u16 pf_retrans; + __u16 ps_retrans; + __u16 max_init_attempts; + __u16 init_retries; + long unsigned int max_init_timeo; + long unsigned int hbinterval; + __be16 encap_port; + __u16 pathmaxrxt; + __u32 flowlabel; + __u8 dscp; + __u8 pmtu_pending; + __u32 pathmtu; + __u32 param_flags; + __u32 sackfreq; + long unsigned int sackdelay; + long unsigned int timeouts[11]; + struct timer_list timers[11]; + struct sctp_transport *shutdown_last_sent_to; + struct sctp_transport *init_last_sent_to; + int shutdown_retries; + __u32 next_tsn; + __u32 ctsn_ack_point; + __u32 adv_peer_ack_point; + __u32 highest_sacked; + __u32 fast_recovery_exit; + __u8 fast_recovery; + __u16 unack_data; + __u32 rtx_data_chunks; + __u32 rwnd; + __u32 a_rwnd; + __u32 rwnd_over; + __u32 rwnd_press; + int sndbuf_used; + atomic_t rmem_alloc; + wait_queue_head_t wait; + __u32 frag_point; + __u32 user_frag; + int init_err_counter; + int init_cycle; + __u16 default_stream; + __u16 default_flags; + __u32 default_ppid; + __u32 default_context; + __u32 default_timetolive; + __u32 default_rcv_context; + struct sctp_stream stream; + struct sctp_outq outqueue; + struct sctp_ulpq ulpq; + __u32 last_ecne_tsn; + __u32 last_cwr_tsn; + int numduptsns; + struct sctp_chunk *addip_last_asconf; + struct list_head asconf_ack_list; + struct list_head addip_chunk_list; + __u32 addip_serial; + int src_out_of_asoc_ok; + union sctp_addr *asconf_addr_del_pending; + struct sctp_transport *new_transport; + struct list_head endpoint_shared_keys; + struct sctp_auth_bytes *asoc_shared_key; + struct sctp_shared_key *shkey; + __u16 default_hmac_id; + __u16 active_key_id; + __u8 need_ecne: 1; + __u8 temp: 1; + __u8 pf_expose: 2; + __u8 force_delay: 1; + __u8 strreset_enable; + __u8 strreset_outstanding; + __u32 strreset_outseq; + __u32 strreset_inseq; + __u32 strreset_result[2]; + struct sctp_chunk *strreset_chunk; + struct sctp_priv_assoc_stats stats; + int sent_cnt_removable; + __u16 subscribe; + __u64 abandoned_unsent[3]; + __u64 abandoned_sent[3]; + struct callback_head rcu; +}; + +struct sctp_auth_bytes { + refcount_t refcnt; + __u32 len; + __u8 data[0]; +}; + +struct sctp_shared_key { + struct list_head key_list; + struct sctp_auth_bytes *key; + refcount_t refcnt; + __u16 key_id; + __u8 deactivated; +}; + +enum { + SCTP_MAX_STREAM = 65535, +}; + +enum sctp_event_timeout { + SCTP_EVENT_TIMEOUT_NONE = 0, + SCTP_EVENT_TIMEOUT_T1_COOKIE = 1, + SCTP_EVENT_TIMEOUT_T1_INIT = 2, + SCTP_EVENT_TIMEOUT_T2_SHUTDOWN = 3, + SCTP_EVENT_TIMEOUT_T3_RTX = 4, + SCTP_EVENT_TIMEOUT_T4_RTO = 5, + SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD = 6, + SCTP_EVENT_TIMEOUT_HEARTBEAT = 7, + SCTP_EVENT_TIMEOUT_RECONF = 8, + SCTP_EVENT_TIMEOUT_SACK = 9, + SCTP_EVENT_TIMEOUT_AUTOCLOSE = 10, +}; + +enum { + SCTP_MAX_DUP_TSNS = 16, +}; + +enum sctp_scope { + SCTP_SCOPE_GLOBAL = 0, + SCTP_SCOPE_PRIVATE = 1, + SCTP_SCOPE_LINK = 2, + SCTP_SCOPE_LOOPBACK = 3, + SCTP_SCOPE_UNUSABLE = 4, +}; + +enum { + SCTP_AUTH_HMAC_ID_RESERVED_0 = 0, + SCTP_AUTH_HMAC_ID_SHA1 = 1, + SCTP_AUTH_HMAC_ID_RESERVED_2 = 2, + SCTP_AUTH_HMAC_ID_SHA256 = 3, + __SCTP_AUTH_HMAC_MAX = 4, +}; + +struct sctp_ulpevent { + struct sctp_association *asoc; + struct sctp_chunk *chunk; + unsigned int rmem_len; + union { + __u32 mid; + __u16 ssn; + }; + union { + __u32 ppid; + __u32 fsn; + }; + __u32 tsn; + __u32 cumtsn; + __u16 stream; + __u16 flags; + __u16 msg_flags; +} __attribute__((packed)); + +union sctp_addr_param; + +union sctp_params { + void *v; + struct sctp_paramhdr *p; + struct sctp_cookie_preserve_param *life; + struct sctp_hostname_param *dns; + struct sctp_cookie_param *cookie; + struct sctp_supported_addrs_param *sat; + struct sctp_ipv4addr_param *v4; + struct sctp_ipv6addr_param *v6; + union sctp_addr_param *addr; + struct sctp_adaptation_ind_param *aind; + struct sctp_supported_ext_param *ext; + struct sctp_random_param *random; + struct sctp_chunks_param *chunks; + struct sctp_hmac_algo_param *hmac_algo; + struct sctp_addip_param *addip; +}; + +struct sctp_sender_hb_info; + +struct sctp_signed_cookie; + +struct sctp_datamsg; + +struct sctp_chunk { + struct list_head list; + refcount_t refcnt; + int sent_count; + union { + struct list_head transmitted_list; + struct list_head stream_list; + }; + struct list_head frag_list; + struct sk_buff *skb; + union { + struct sk_buff *head_skb; + struct sctp_shared_key *shkey; + }; + union sctp_params param_hdr; + union { + __u8 *v; + struct sctp_datahdr *data_hdr; + struct sctp_inithdr *init_hdr; + struct sctp_sackhdr *sack_hdr; + struct sctp_heartbeathdr *hb_hdr; + struct sctp_sender_hb_info *hbs_hdr; + struct sctp_shutdownhdr *shutdown_hdr; + struct sctp_signed_cookie *cookie_hdr; + struct sctp_ecnehdr *ecne_hdr; + struct sctp_cwrhdr *ecn_cwr_hdr; + struct sctp_errhdr *err_hdr; + struct sctp_addiphdr *addip_hdr; + struct sctp_fwdtsn_hdr *fwdtsn_hdr; + struct sctp_authhdr *auth_hdr; + struct sctp_idatahdr *idata_hdr; + struct sctp_ifwdtsn_hdr *ifwdtsn_hdr; + } subh; + __u8 *chunk_end; + struct sctp_chunkhdr *chunk_hdr; + struct sctphdr *sctp_hdr; + struct sctp_sndrcvinfo sinfo; + struct sctp_association *asoc; + struct sctp_ep_common *rcvr; + long unsigned int sent_at; + union sctp_addr source; + union sctp_addr dest; + struct sctp_datamsg *msg; + struct sctp_transport *transport; + struct sk_buff *auth_chunk; + __u16 rtt_in_progress: 1; + __u16 has_tsn: 1; + __u16 has_ssn: 1; + __u16 singleton: 1; + __u16 end_of_packet: 1; + __u16 ecn_ce_done: 1; + __u16 pdiscard: 1; + __u16 tsn_gap_acked: 1; + __u16 data_accepted: 1; + __u16 auth: 1; + __u16 has_asconf: 1; + __u16 tsn_missing_report: 2; + __u16 fast_retransmit: 2; +}; + +struct sctp_stream_interleave { + __u16 data_chunk_len; + __u16 ftsn_chunk_len; + struct sctp_chunk * (*make_datafrag)(const struct sctp_association *, const struct sctp_sndrcvinfo *, int, __u8, gfp_t); + void (*assign_number)(struct sctp_chunk *); + bool (*validate_data)(struct sctp_chunk *); + int (*ulpevent_data)(struct sctp_ulpq *, struct sctp_chunk *, gfp_t); + int (*enqueue_event)(struct sctp_ulpq *, struct sctp_ulpevent *); + void (*renege_events)(struct sctp_ulpq *, struct sctp_chunk *, gfp_t); + void (*start_pd)(struct sctp_ulpq *, gfp_t); + void (*abort_pd)(struct sctp_ulpq *, gfp_t); + void (*generate_ftsn)(struct sctp_outq *, __u32); + bool (*validate_ftsn)(struct sctp_chunk *); + void (*report_ftsn)(struct sctp_ulpq *, __u32); + void (*handle_ftsn)(struct sctp_ulpq *, struct sctp_chunk *); +}; + +struct sctp_bind_bucket { + short unsigned int port; + signed char fastreuse; + signed char fastreuseport; + kuid_t fastuid; + struct hlist_node node; + struct hlist_head owner; + struct net *net; +}; + +enum sctp_socket_type { + SCTP_SOCKET_UDP = 0, + SCTP_SOCKET_UDP_HIGH_BANDWIDTH = 1, + SCTP_SOCKET_TCP = 2, +}; + +struct sctp_pf; + +struct sctp_sock { + struct inet_sock inet; + enum sctp_socket_type type; + struct sctp_pf *pf; + struct crypto_shash *hmac; + char *sctp_hmac_alg; + struct sctp_endpoint *ep; + struct sctp_bind_bucket *bind_hash; + __u16 default_stream; + __u32 default_ppid; + __u16 default_flags; + __u32 default_context; + __u32 default_timetolive; + __u32 default_rcv_context; + int max_burst; + __u32 hbinterval; + __be16 udp_port; + __be16 encap_port; + __u16 pathmaxrxt; + __u32 flowlabel; + __u8 dscp; + __u16 pf_retrans; + __u16 ps_retrans; + __u32 pathmtu; + __u32 sackdelay; + __u32 sackfreq; + __u32 param_flags; + __u32 default_ss; + struct sctp_rtoinfo rtoinfo; + struct sctp_paddrparams paddrparam; + struct sctp_assocparams assocparams; + __u16 subscribe; + struct sctp_initmsg initmsg; + int user_frag; + __u32 autoclose; + __u32 adaptation_ind; + __u32 pd_point; + __u16 nodelay: 1; + __u16 pf_expose: 2; + __u16 reuse: 1; + __u16 disable_fragments: 1; + __u16 v4mapped: 1; + __u16 frag_interleave: 1; + __u16 recvrcvinfo: 1; + __u16 recvnxtinfo: 1; + __u16 data_ready_signalled: 1; + atomic_t pd_mode; + struct sk_buff_head pd_lobby; + struct list_head auto_asconf_list; + int do_auto_asconf; +}; + +struct sctp_af; + +struct sctp_pf { + void (*event_msgname)(struct sctp_ulpevent *, char *, int *); + void (*skb_msgname)(struct sk_buff *, char *, int *); + int (*af_supported)(sa_family_t, struct sctp_sock *); + int (*cmp_addr)(const union sctp_addr *, const union sctp_addr *, struct sctp_sock *); + int (*bind_verify)(struct sctp_sock *, union sctp_addr *); + int (*send_verify)(struct sctp_sock *, union sctp_addr *); + int (*supported_addrs)(const struct sctp_sock *, __be16 *); + struct sock * (*create_accept_sk)(struct sock *, struct sctp_association *, bool); + int (*addr_to_user)(struct sctp_sock *, union sctp_addr *); + void (*to_sk_saddr)(union sctp_addr *, struct sock *); + void (*to_sk_daddr)(union sctp_addr *, struct sock *); + void (*copy_ip_options)(struct sock *, struct sock *); + struct sctp_af *af; +}; + +struct sctp_signed_cookie { + __u8 signature[32]; + __u32 __pad; + struct sctp_cookie c; +} __attribute__((packed)); + +union sctp_addr_param { + struct sctp_paramhdr p; + struct sctp_ipv4addr_param v4; + struct sctp_ipv6addr_param v6; +}; + +struct sctp_sender_hb_info { + struct sctp_paramhdr param_hdr; + union sctp_addr daddr; + long unsigned int sent_at; + __u64 hb_nonce; +}; + +struct sctp_af { + int (*sctp_xmit)(struct sk_buff *, struct sctp_transport *); + int (*setsockopt)(struct sock *, int, int, sockptr_t, unsigned int); + int (*getsockopt)(struct sock *, int, int, char *, int *); + void (*get_dst)(struct sctp_transport *, union sctp_addr *, struct flowi *, struct sock *); + void (*get_saddr)(struct sctp_sock *, struct sctp_transport *, struct flowi *); + void (*copy_addrlist)(struct list_head *, struct net_device *); + int (*cmp_addr)(const union sctp_addr *, const union sctp_addr *); + void (*addr_copy)(union sctp_addr *, union sctp_addr *); + void (*from_skb)(union sctp_addr *, struct sk_buff *, int); + void (*from_sk)(union sctp_addr *, struct sock *); + void (*from_addr_param)(union sctp_addr *, union sctp_addr_param *, __be16, int); + int (*to_addr_param)(const union sctp_addr *, union sctp_addr_param *); + int (*addr_valid)(union sctp_addr *, struct sctp_sock *, const struct sk_buff *); + enum sctp_scope (*scope)(union sctp_addr *); + void (*inaddr_any)(union sctp_addr *, __be16); + int (*is_any)(const union sctp_addr *); + int (*available)(union sctp_addr *, struct sctp_sock *); + int (*skb_iif)(const struct sk_buff *); + int (*is_ce)(const struct sk_buff *); + void (*seq_dump_addr)(struct seq_file *, union sctp_addr *); + void (*ecn_capable)(struct sock *); + __u16 net_header_len; + int sockaddr_len; + int (*ip_options_len)(struct sock *); + sa_family_t sa_family; + struct list_head list; +}; + +struct sctp_packet { + __u16 source_port; + __u16 destination_port; + __u32 vtag; + struct list_head chunk_list; + size_t overhead; + size_t size; + size_t max_size; + struct sctp_transport *transport; + struct sctp_chunk *auth; + u8 has_cookie_echo: 1; + u8 has_sack: 1; + u8 has_auth: 1; + u8 has_data: 1; + u8 ipfragok: 1; +}; + +struct sctp_transport { + struct list_head transports; + struct rhlist_head node; + refcount_t refcnt; + __u32 rto_pending: 1; + __u32 hb_sent: 1; + __u32 pmtu_pending: 1; + __u32 dst_pending_confirm: 1; + __u32 sack_generation: 1; + u32 dst_cookie; + struct flowi fl; + union sctp_addr ipaddr; + struct sctp_af *af_specific; + struct sctp_association *asoc; + long unsigned int rto; + __u32 rtt; + __u32 rttvar; + __u32 srtt; + __u32 cwnd; + __u32 ssthresh; + __u32 partial_bytes_acked; + __u32 flight_size; + __u32 burst_limited; + struct dst_entry *dst; + union sctp_addr saddr; + long unsigned int hbinterval; + long unsigned int sackdelay; + __u32 sackfreq; + atomic_t mtu_info; + ktime_t last_time_heard; + long unsigned int last_time_sent; + long unsigned int last_time_ecne_reduced; + __be16 encap_port; + __u16 pathmaxrxt; + __u32 flowlabel; + __u8 dscp; + __u16 pf_retrans; + __u16 ps_retrans; + __u32 pathmtu; + __u32 param_flags; + int init_sent_count; + int state; + short unsigned int error_count; + struct timer_list T3_rtx_timer; + struct timer_list hb_timer; + struct timer_list proto_unreach_timer; + struct timer_list reconf_timer; + struct list_head transmitted; + struct sctp_packet packet; + struct list_head send_ready; + struct { + __u32 next_tsn_at_change; + char changeover_active; + char cycling_changeover; + char cacc_saw_newack; + } cacc; + __u64 hb_nonce; + struct callback_head rcu; +}; + +struct sctp_datamsg { + struct list_head chunks; + refcount_t refcnt; + long unsigned int expires_at; + int send_error; + u8 send_failed: 1; + u8 can_delay: 1; + u8 abandoned: 1; +}; + +struct sctp_stream_priorities { + struct list_head prio_sched; + struct list_head active; + struct sctp_stream_out_ext *next; + __u16 prio; +}; + +struct sctp_stream_out_ext { + __u64 abandoned_unsent[3]; + __u64 abandoned_sent[3]; + struct list_head outq; + union { + struct { + struct list_head prio_list; + struct sctp_stream_priorities *prio_head; + }; + struct { + struct list_head rr_list; + }; + }; +}; + +struct task_security_struct { + u32 osid; + u32 sid; + u32 exec_sid; + u32 create_sid; + u32 keycreate_sid; + u32 sockcreate_sid; +}; + +enum label_initialized { + LABEL_INVALID = 0, + LABEL_INITIALIZED = 1, + LABEL_PENDING = 2, +}; + +struct inode_security_struct { + struct inode *inode; + struct list_head list; + u32 task_sid; + u32 sid; + u16 sclass; + unsigned char initialized; + spinlock_t lock; +}; + +struct file_security_struct { + u32 sid; + u32 fown_sid; + u32 isid; + u32 pseqno; +}; + +struct superblock_security_struct { + struct super_block *sb; + u32 sid; + u32 def_sid; + u32 mntpoint_sid; + short unsigned int behavior; + short unsigned int flags; + struct mutex lock; + struct list_head isec_head; + spinlock_t isec_lock; +}; + +struct msg_security_struct { + u32 sid; +}; + +struct ipc_security_struct { + u16 sclass; + u32 sid; +}; + +struct sk_security_struct { + enum { + NLBL_UNSET = 0, + NLBL_REQUIRE = 1, + NLBL_LABELED = 2, + NLBL_REQSKB = 3, + NLBL_CONNLABELED = 4, + } nlbl_state; + struct netlbl_lsm_secattr *nlbl_secattr; + u32 sid; + u32 peer_sid; + u16 sclass; + enum { + SCTP_ASSOC_UNSET = 0, + SCTP_ASSOC_SET = 1, + } sctp_assoc_state; +}; + +struct tun_security_struct { + u32 sid; +}; + +struct key_security_struct { + u32 sid; +}; + +struct bpf_security_struct { + u32 sid; +}; + +struct perf_event_security_struct { + u32 sid; +}; + +struct selinux_mnt_opts { + const char *fscontext; + const char *context; + const char *rootcontext; + const char *defcontext; +}; + +enum { + Opt_error = 4294967295, + Opt_context = 0, + Opt_defcontext = 1, + Opt_fscontext = 2, + Opt_rootcontext = 3, + Opt_seclabel = 4, +}; + +enum sel_inos { + SEL_ROOT_INO = 2, + SEL_LOAD = 3, + SEL_ENFORCE = 4, + SEL_CONTEXT = 5, + SEL_ACCESS = 6, + SEL_CREATE = 7, + SEL_RELABEL = 8, + SEL_USER = 9, + SEL_POLICYVERS = 10, + SEL_COMMIT_BOOLS = 11, + SEL_MLS = 12, + SEL_DISABLE = 13, + SEL_MEMBER = 14, + SEL_CHECKREQPROT = 15, + SEL_COMPAT_NET = 16, + SEL_REJECT_UNKNOWN = 17, + SEL_DENY_UNKNOWN = 18, + SEL_STATUS = 19, + SEL_POLICY = 20, + SEL_VALIDATE_TRANS = 21, + SEL_INO_NEXT = 22, +}; + +struct selinux_fs_info { + struct dentry *bool_dir; + unsigned int bool_num; + char **bool_pending_names; + unsigned int *bool_pending_values; + struct dentry *class_dir; + long unsigned int last_class_ino; + bool policy_opened; + struct dentry *policycap_dir; + long unsigned int last_ino; + struct selinux_state *state; + struct super_block *sb; +}; + +struct policy_load_memory { + size_t len; + void *data; +}; + +enum { + SELNL_MSG_SETENFORCE = 16, + SELNL_MSG_POLICYLOAD = 17, + SELNL_MSG_MAX = 18, +}; + +enum selinux_nlgroups { + SELNLGRP_NONE = 0, + SELNLGRP_AVC = 1, + __SELNLGRP_MAX = 2, +}; + +struct selnl_msg_setenforce { + __s32 val; +}; + +struct selnl_msg_policyload { + __u32 seqno; +}; + +enum { + XFRM_MSG_BASE = 16, + XFRM_MSG_NEWSA = 16, + XFRM_MSG_DELSA = 17, + XFRM_MSG_GETSA = 18, + XFRM_MSG_NEWPOLICY = 19, + XFRM_MSG_DELPOLICY = 20, + XFRM_MSG_GETPOLICY = 21, + XFRM_MSG_ALLOCSPI = 22, + XFRM_MSG_ACQUIRE = 23, + XFRM_MSG_EXPIRE = 24, + XFRM_MSG_UPDPOLICY = 25, + XFRM_MSG_UPDSA = 26, + XFRM_MSG_POLEXPIRE = 27, + XFRM_MSG_FLUSHSA = 28, + XFRM_MSG_FLUSHPOLICY = 29, + XFRM_MSG_NEWAE = 30, + XFRM_MSG_GETAE = 31, + XFRM_MSG_REPORT = 32, + XFRM_MSG_MIGRATE = 33, + XFRM_MSG_NEWSADINFO = 34, + XFRM_MSG_GETSADINFO = 35, + XFRM_MSG_NEWSPDINFO = 36, + XFRM_MSG_GETSPDINFO = 37, + XFRM_MSG_MAPPING = 38, + __XFRM_MSG_MAX = 39, +}; + +enum { + RTM_BASE = 16, + RTM_NEWLINK = 16, + RTM_DELLINK = 17, + RTM_GETLINK = 18, + RTM_SETLINK = 19, + RTM_NEWADDR = 20, + RTM_DELADDR = 21, + RTM_GETADDR = 22, + RTM_NEWROUTE = 24, + RTM_DELROUTE = 25, + RTM_GETROUTE = 26, + RTM_NEWNEIGH = 28, + RTM_DELNEIGH = 29, + RTM_GETNEIGH = 30, + RTM_NEWRULE = 32, + RTM_DELRULE = 33, + RTM_GETRULE = 34, + RTM_NEWQDISC = 36, + RTM_DELQDISC = 37, + RTM_GETQDISC = 38, + RTM_NEWTCLASS = 40, + RTM_DELTCLASS = 41, + RTM_GETTCLASS = 42, + RTM_NEWTFILTER = 44, + RTM_DELTFILTER = 45, + RTM_GETTFILTER = 46, + RTM_NEWACTION = 48, + RTM_DELACTION = 49, + RTM_GETACTION = 50, + RTM_NEWPREFIX = 52, + RTM_GETMULTICAST = 58, + RTM_GETANYCAST = 62, + RTM_NEWNEIGHTBL = 64, + RTM_GETNEIGHTBL = 66, + RTM_SETNEIGHTBL = 67, + RTM_NEWNDUSEROPT = 68, + RTM_NEWADDRLABEL = 72, + RTM_DELADDRLABEL = 73, + RTM_GETADDRLABEL = 74, + RTM_GETDCB = 78, + RTM_SETDCB = 79, + RTM_NEWNETCONF = 80, + RTM_DELNETCONF = 81, + RTM_GETNETCONF = 82, + RTM_NEWMDB = 84, + RTM_DELMDB = 85, + RTM_GETMDB = 86, + RTM_NEWNSID = 88, + RTM_DELNSID = 89, + RTM_GETNSID = 90, + RTM_NEWSTATS = 92, + RTM_GETSTATS = 94, + RTM_NEWCACHEREPORT = 96, + RTM_NEWCHAIN = 100, + RTM_DELCHAIN = 101, + RTM_GETCHAIN = 102, + RTM_NEWNEXTHOP = 104, + RTM_DELNEXTHOP = 105, + RTM_GETNEXTHOP = 106, + RTM_NEWLINKPROP = 108, + RTM_DELLINKPROP = 109, + RTM_GETLINKPROP = 110, + RTM_NEWVLAN = 112, + RTM_DELVLAN = 113, + RTM_GETVLAN = 114, + __RTM_MAX = 115, +}; + +struct nlmsg_perm { + u16 nlmsg_type; + u32 perm; +}; + +struct netif_security_struct { + struct net *ns; + int ifindex; + u32 sid; +}; + +struct sel_netif { + struct list_head list; + struct netif_security_struct nsec; + struct callback_head callback_head; +}; + +struct netnode_security_struct { + union { + __be32 ipv4; + struct in6_addr ipv6; + } addr; + u32 sid; + u16 family; +}; + +struct sel_netnode_bkt { + unsigned int size; + struct list_head list; +}; + +struct sel_netnode { + struct netnode_security_struct nsec; + struct list_head list; + struct callback_head rcu; +}; + +struct netport_security_struct { + u32 sid; + u16 port; + u8 protocol; +}; + +struct sel_netport_bkt { + int size; + struct list_head list; +}; + +struct sel_netport { + struct netport_security_struct psec; + struct list_head list; + struct callback_head rcu; +}; + +struct selinux_kernel_status { + u32 version; + u32 sequence; + u32 enforcing; + u32 policyload; + u32 deny_unknown; +}; + +struct ebitmap_node { + struct ebitmap_node *next; + long unsigned int maps[6]; + u32 startbit; +}; + +struct ebitmap { + struct ebitmap_node *node; + u32 highbit; +}; + +struct policy_file { + char *data; + size_t len; +}; + +struct hashtab_node { + void *key; + void *datum; + struct hashtab_node *next; +}; + +struct hashtab { + struct hashtab_node **htable; + u32 size; + u32 nel; +}; + +struct hashtab_info { + u32 slots_used; + u32 max_chain_len; +}; + +struct hashtab_key_params { + u32 (*hash)(const void *); + int (*cmp)(const void *, const void *); +}; + +struct symtab { + struct hashtab table; + u32 nprim; +}; + +struct mls_level { + u32 sens; + struct ebitmap cat; +}; + +struct mls_range { + struct mls_level level[2]; +}; + +struct context___2 { + u32 user; + u32 role; + u32 type; + u32 len; + struct mls_range range; + char *str; +}; + +struct sidtab_str_cache; + +struct sidtab_entry { + u32 sid; + u32 hash; + struct context___2 context; + struct sidtab_str_cache *cache; + struct hlist_node list; +}; + +struct sidtab_str_cache { + struct callback_head rcu_member; + struct list_head lru_member; + struct sidtab_entry *parent; + u32 len; + char str[0]; +}; + +struct sidtab_node_inner; + +struct sidtab_node_leaf; + +union sidtab_entry_inner { + struct sidtab_node_inner *ptr_inner; + struct sidtab_node_leaf *ptr_leaf; +}; + +struct sidtab_node_inner { + union sidtab_entry_inner entries[512]; +}; + +struct sidtab_node_leaf { + struct sidtab_entry entries[39]; +}; + +struct sidtab_isid_entry { + int set; + struct sidtab_entry entry; +}; + +struct sidtab; + +struct sidtab_convert_params { + int (*func)(struct context___2 *, struct context___2 *, void *); + void *args; + struct sidtab *target; +}; + +struct sidtab { + union sidtab_entry_inner roots[4]; + u32 count; + struct sidtab_convert_params *convert; + spinlock_t lock; + u32 cache_free_slots; + struct list_head cache_lru_list; + spinlock_t cache_lock; + struct sidtab_isid_entry isids[27]; + struct hlist_head context_to_sid[512]; +}; + +struct avtab_key { + u16 source_type; + u16 target_type; + u16 target_class; + u16 specified; +}; + +struct avtab_extended_perms { + u8 specified; + u8 driver; + struct extended_perms_data perms; +}; + +struct avtab_datum { + union { + u32 data; + struct avtab_extended_perms *xperms; + } u; +}; + +struct avtab_node { + struct avtab_key key; + struct avtab_datum datum; + struct avtab_node *next; +}; + +struct avtab { + struct avtab_node **htable; + u32 nel; + u32 nslot; + u32 mask; +}; + +struct type_set; + +struct constraint_expr { + u32 expr_type; + u32 attr; + u32 op; + struct ebitmap names; + struct type_set *type_names; + struct constraint_expr *next; +}; + +struct type_set { + struct ebitmap types; + struct ebitmap negset; + u32 flags; +}; + +struct constraint_node { + u32 permissions; + struct constraint_expr *expr; + struct constraint_node *next; +}; + +struct common_datum { + u32 value; + struct symtab permissions; +}; + +struct class_datum { + u32 value; + char *comkey; + struct common_datum *comdatum; + struct symtab permissions; + struct constraint_node *constraints; + struct constraint_node *validatetrans; + char default_user; + char default_role; + char default_type; + char default_range; +}; + +struct role_datum { + u32 value; + u32 bounds; + struct ebitmap dominates; + struct ebitmap types; +}; + +struct role_allow { + u32 role; + u32 new_role; + struct role_allow *next; +}; + +struct type_datum { + u32 value; + u32 bounds; + unsigned char primary; + unsigned char attribute; +}; + +struct user_datum { + u32 value; + u32 bounds; + struct ebitmap roles; + struct mls_range range; + struct mls_level dfltlevel; +}; + +struct cond_bool_datum { + __u32 value; + int state; +}; + +struct ocontext { + union { + char *name; + struct { + u8 protocol; + u16 low_port; + u16 high_port; + } port; + struct { + u32 addr; + u32 mask; + } node; + struct { + u32 addr[4]; + u32 mask[4]; + } node6; + struct { + u64 subnet_prefix; + u16 low_pkey; + u16 high_pkey; + } ibpkey; + struct { + char *dev_name; + u8 port; + } ibendport; + } u; + union { + u32 sclass; + u32 behavior; + } v; + struct context___2 context[2]; + u32 sid[2]; + struct ocontext *next; +}; + +struct genfs { + char *fstype; + struct ocontext *head; + struct genfs *next; +}; + +struct cond_node; + +struct policydb { + int mls_enabled; + struct symtab symtab[8]; + char **sym_val_to_name[8]; + struct class_datum **class_val_to_struct; + struct role_datum **role_val_to_struct; + struct user_datum **user_val_to_struct; + struct type_datum **type_val_to_struct; + struct avtab te_avtab; + struct hashtab role_tr; + struct ebitmap filename_trans_ttypes; + struct hashtab filename_trans; + u32 compat_filename_trans_count; + struct cond_bool_datum **bool_val_to_struct; + struct avtab te_cond_avtab; + struct cond_node *cond_list; + u32 cond_list_len; + struct role_allow *role_allow; + struct ocontext *ocontexts[9]; + struct genfs *genfs; + struct hashtab range_tr; + struct ebitmap *type_attr_map_array; + struct ebitmap policycaps; + struct ebitmap permissive_map; + size_t len; + unsigned int policyvers; + unsigned int reject_unknown: 1; + unsigned int allow_unknown: 1; + u16 process_class; + u32 process_trans_perms; +}; + +struct perm_datum { + u32 value; +}; + +struct role_trans_key { + u32 role; + u32 type; + u32 tclass; +}; + +struct role_trans_datum { + u32 new_role; +}; + +struct filename_trans_key { + u32 ttype; + u16 tclass; + const char *name; +}; + +struct filename_trans_datum { + struct ebitmap stypes; + u32 otype; + struct filename_trans_datum *next; +}; + +struct level_datum { + struct mls_level *level; + unsigned char isalias; +}; + +struct cat_datum { + u32 value; + unsigned char isalias; +}; + +struct range_trans { + u32 source_type; + u32 target_type; + u32 target_class; +}; + +struct cond_expr_node; + +struct cond_expr { + struct cond_expr_node *nodes; + u32 len; +}; + +struct cond_av_list { + struct avtab_node **nodes; + u32 len; +}; + +struct cond_node { + int cur_state; + struct cond_expr expr; + struct cond_av_list true_list; + struct cond_av_list false_list; +}; + +struct policy_data { + struct policydb *p; + void *fp; +}; + +struct cond_expr_node { + u32 expr_type; + u32 bool; +}; + +struct policydb_compat_info { + int version; + int sym_num; + int ocon_num; +}; + +struct selinux_mapping; + +struct selinux_map { + struct selinux_mapping *mapping; + u16 size; +}; + +struct selinux_policy { + struct sidtab *sidtab; + struct policydb policydb; + struct selinux_map map; + u32 latest_granting; +}; + +struct selinux_mapping { + u16 value; + unsigned int num_perms; + u32 perms[32]; +}; + +struct convert_context_args { + struct selinux_state *state; + struct policydb *oldp; + struct policydb *newp; +}; + +struct selinux_audit_rule { + u32 au_seqno; + struct context___2 au_ctxt; +}; + +struct cond_insertf_data { + struct policydb *p; + struct avtab_node **dst; + struct cond_av_list *other; +}; + +struct sockaddr_un { + __kernel_sa_family_t sun_family; + char sun_path[108]; +}; + +struct unix_address { + refcount_t refcnt; + int len; + unsigned int hash; + struct sockaddr_un name[0]; +}; + +struct scm_stat { + atomic_t nr_fds; +}; + +struct unix_sock { + struct sock sk; + struct unix_address *addr; + struct path path; + struct mutex iolock; + struct mutex bindlock; + struct sock *peer; + struct list_head link; + atomic_long_t inflight; + spinlock_t lock; + long unsigned int gc_flags; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct socket_wq peer_wq; + wait_queue_entry_t peer_wake; + struct scm_stat scm_stat; + long: 32; + long: 64; + long: 64; +}; + +enum devcg_behavior { + DEVCG_DEFAULT_NONE = 0, + DEVCG_DEFAULT_ALLOW = 1, + DEVCG_DEFAULT_DENY = 2, +}; + +struct dev_exception_item { + u32 major; + u32 minor; + short int type; + short int access; + struct list_head list; + struct callback_head rcu; +}; + +struct dev_cgroup { + struct cgroup_subsys_state css; + struct list_head exceptions; + enum devcg_behavior behavior; +}; + +enum integrity_status { + INTEGRITY_PASS = 0, + INTEGRITY_PASS_IMMUTABLE = 1, + INTEGRITY_FAIL = 2, + INTEGRITY_NOLABEL = 3, + INTEGRITY_NOXATTRS = 4, + INTEGRITY_UNKNOWN = 5, +}; + +struct ima_digest_data { + u8 algo; + u8 length; + union { + struct { + u8 unused; + u8 type; + } sha1; + struct { + u8 type; + u8 algo; + } ng; + u8 data[2]; + } xattr; + u8 digest[0]; +}; + +struct integrity_iint_cache { + struct rb_node rb_node; + struct mutex mutex; + struct inode *inode; + u64 version; + long unsigned int flags; + long unsigned int measured_pcrs; + long unsigned int atomic_flags; + enum integrity_status ima_file_status: 4; + enum integrity_status ima_mmap_status: 4; + enum integrity_status ima_bprm_status: 4; + enum integrity_status ima_read_status: 4; + enum integrity_status ima_creds_status: 4; + enum integrity_status evm_status: 4; + struct ima_digest_data *ima_hash; +}; + +struct tpm_digest { + u16 alg_id; + u8 digest[64]; +}; + +struct evm_ima_xattr_data { + u8 type; + u8 data[0]; +}; + +enum ima_show_type { + IMA_SHOW_BINARY = 0, + IMA_SHOW_BINARY_NO_FIELD_LEN = 1, + IMA_SHOW_BINARY_OLD_STRING_FMT = 2, + IMA_SHOW_ASCII = 3, +}; + +struct modsig; + +struct ima_event_data { + struct integrity_iint_cache *iint; + struct file *file; + const unsigned char *filename; + struct evm_ima_xattr_data *xattr_value; + int xattr_len; + const struct modsig *modsig; + const char *violation; + const void *buf; + int buf_len; +}; + +struct ima_field_data { + u8 *data; + u32 len; +}; + +struct ima_template_field { + const char field_id[16]; + int (*field_init)(struct ima_event_data *, struct ima_field_data *); + void (*field_show)(struct seq_file *, enum ima_show_type, struct ima_field_data *); +}; + +struct ima_template_desc { + struct list_head list; + char *name; + char *fmt; + int num_fields; + const struct ima_template_field **fields; +}; + +struct ima_template_entry { + int pcr; + struct tpm_digest *digests; + struct ima_template_desc *template_desc; + u32 template_data_len; + struct ima_field_data template_data[0]; +}; + +struct ima_queue_entry { + struct hlist_node hnext; + struct list_head later; + struct ima_template_entry *entry; +}; + +struct ima_h_table { + atomic_long_t len; + atomic_long_t violations; + struct hlist_head queue[1024]; +}; + +enum ima_fs_flags { + IMA_FS_BUSY = 0, +}; + +struct hwrng { + const char *name; + int (*init)(struct hwrng *); + void (*cleanup)(struct hwrng *); + int (*data_present)(struct hwrng *, int); + int (*data_read)(struct hwrng *, u32 *); + int (*read)(struct hwrng *, void *, size_t, bool); + long unsigned int priv; + short unsigned int quality; + struct list_head list; + struct kref ref; + struct completion cleanup_done; +}; + +enum hash_algo { + HASH_ALGO_MD4 = 0, + HASH_ALGO_MD5 = 1, + HASH_ALGO_SHA1 = 2, + HASH_ALGO_RIPE_MD_160 = 3, + HASH_ALGO_SHA256 = 4, + HASH_ALGO_SHA384 = 5, + HASH_ALGO_SHA512 = 6, + HASH_ALGO_SHA224 = 7, + HASH_ALGO_RIPE_MD_128 = 8, + HASH_ALGO_RIPE_MD_256 = 9, + HASH_ALGO_RIPE_MD_320 = 10, + HASH_ALGO_WP_256 = 11, + HASH_ALGO_WP_384 = 12, + HASH_ALGO_WP_512 = 13, + HASH_ALGO_TGR_128 = 14, + HASH_ALGO_TGR_160 = 15, + HASH_ALGO_TGR_192 = 16, + HASH_ALGO_SM3_256 = 17, + HASH_ALGO_STREEBOG_256 = 18, + HASH_ALGO_STREEBOG_512 = 19, + HASH_ALGO__LAST = 20, +}; + +struct tpm_bank_info { + u16 alg_id; + u16 digest_size; + u16 crypto_id; +}; + +struct tpm_chip; + +struct tpm_class_ops { + unsigned int flags; + const u8 req_complete_mask; + const u8 req_complete_val; + bool (*req_canceled)(struct tpm_chip *, u8); + int (*recv)(struct tpm_chip *, u8 *, size_t); + int (*send)(struct tpm_chip *, u8 *, size_t); + void (*cancel)(struct tpm_chip *); + u8 (*status)(struct tpm_chip *); + void (*update_timeouts)(struct tpm_chip *, long unsigned int *); + void (*update_durations)(struct tpm_chip *, long unsigned int *); + int (*go_idle)(struct tpm_chip *); + int (*cmd_ready)(struct tpm_chip *); + int (*request_locality)(struct tpm_chip *, int); + int (*relinquish_locality)(struct tpm_chip *, int); + void (*clk_enable)(struct tpm_chip *, bool); +}; + +struct tpm_bios_log { + void *bios_event_log; + void *bios_event_log_end; +}; + +struct tpm_chip_seqops { + struct tpm_chip *chip; + const struct seq_operations *seqops; +}; + +struct tpm_space { + u32 context_tbl[3]; + u8 *context_buf; + u32 session_tbl[3]; + u8 *session_buf; + u32 buf_size; +}; + +struct tpm_chip { + struct device dev; + struct device devs; + struct cdev cdev; + struct cdev cdevs; + struct rw_semaphore ops_sem; + const struct tpm_class_ops *ops; + struct tpm_bios_log log; + struct tpm_chip_seqops bin_log_seqops; + struct tpm_chip_seqops ascii_log_seqops; + unsigned int flags; + int dev_num; + long unsigned int is_open; + char hwrng_name[64]; + struct hwrng hwrng; + struct mutex tpm_mutex; + long unsigned int timeout_a; + long unsigned int timeout_b; + long unsigned int timeout_c; + long unsigned int timeout_d; + bool timeout_adjusted; + long unsigned int duration[4]; + bool duration_adjusted; + struct dentry *bios_dir[3]; + const struct attribute_group *groups[3]; + unsigned int groups_cnt; + u32 nr_allocated_banks; + struct tpm_bank_info *allocated_banks; + acpi_handle acpi_dev_handle; + char ppi_version[4]; + struct tpm_space work_space; + u32 last_cc; + u32 nr_commands; + u32 *cc_attrs_tbl; + int locality; +}; + +enum tpm_duration { + TPM_SHORT = 0, + TPM_MEDIUM = 1, + TPM_LONG = 2, + TPM_LONG_LONG = 3, + TPM_UNDEFINED = 4, + TPM_NUM_DURATIONS = 4, +}; + +enum evm_ima_xattr_type { + IMA_XATTR_DIGEST = 1, + EVM_XATTR_HMAC = 2, + EVM_IMA_XATTR_DIGSIG = 3, + IMA_XATTR_DIGEST_NG = 4, + EVM_XATTR_PORTABLE_DIGSIG = 5, + IMA_XATTR_LAST = 6, +}; + +enum ima_hooks { + NONE___2 = 0, + FILE_CHECK = 1, + MMAP_CHECK = 2, + BPRM_CHECK = 3, + CREDS_CHECK = 4, + POST_SETATTR = 5, + MODULE_CHECK = 6, + FIRMWARE_CHECK = 7, + KEXEC_KERNEL_CHECK = 8, + KEXEC_INITRAMFS_CHECK = 9, + POLICY_CHECK = 10, + KEXEC_CMDLINE = 11, + KEY_CHECK = 12, + MAX_CHECK = 13, +}; + +struct crypto_async_request; + +typedef void (*crypto_completion_t)(struct crypto_async_request *, int); + +struct crypto_async_request { + struct list_head list; + crypto_completion_t complete; + void *data; + struct crypto_tfm *tfm; + u32 flags; +}; + +struct crypto_wait { + struct completion completion; + int err; +}; + +struct hash_alg_common { + unsigned int digestsize; + unsigned int statesize; + struct crypto_alg base; +}; + +struct ahash_request { + struct crypto_async_request base; + unsigned int nbytes; + struct scatterlist *src; + u8 *result; + void *priv; + void *__ctx[0]; +}; + +struct crypto_ahash { + int (*init)(struct ahash_request *); + int (*update)(struct ahash_request *); + int (*final)(struct ahash_request *); + int (*finup)(struct ahash_request *); + int (*digest)(struct ahash_request *); + int (*export)(struct ahash_request *, void *); + int (*import)(struct ahash_request *, const void *); + int (*setkey)(struct crypto_ahash *, const u8 *, unsigned int); + unsigned int reqsize; + struct crypto_tfm base; +}; + +enum tpm_algorithms { + TPM_ALG_ERROR = 0, + TPM_ALG_SHA1 = 4, + TPM_ALG_KEYEDHASH = 8, + TPM_ALG_SHA256 = 11, + TPM_ALG_SHA384 = 12, + TPM_ALG_SHA512 = 13, + TPM_ALG_NULL = 16, + TPM_ALG_SM3_256 = 18, +}; + +enum tpm_pcrs { + TPM_PCR0 = 0, + TPM_PCR8 = 8, + TPM_PCR10 = 10, +}; + +struct ima_algo_desc { + struct crypto_shash *tfm; + enum hash_algo algo; +}; + +enum lsm_rule_types { + LSM_OBJ_USER = 0, + LSM_OBJ_ROLE = 1, + LSM_OBJ_TYPE = 2, + LSM_SUBJ_USER = 3, + LSM_SUBJ_ROLE = 4, + LSM_SUBJ_TYPE = 5, +}; + +enum policy_types { + ORIGINAL_TCB = 1, + DEFAULT_TCB = 2, +}; + +enum policy_rule_list { + IMA_DEFAULT_POLICY = 1, + IMA_CUSTOM_POLICY = 2, +}; + +struct ima_rule_opt_list { + size_t count; + char *items[0]; +}; + +struct ima_rule_entry { + struct list_head list; + int action; + unsigned int flags; + enum ima_hooks func; + int mask; + long unsigned int fsmagic; + uuid_t fsuuid; + kuid_t uid; + kuid_t fowner; + bool (*uid_op)(kuid_t, kuid_t); + bool (*fowner_op)(kuid_t, kuid_t); + int pcr; + struct { + void *rule; + char *args_p; + int type; + } lsm[6]; + char *fsname; + struct ima_rule_opt_list *keyrings; + struct ima_template_desc *template; +}; + +enum { + Opt_measure = 0, + Opt_dont_measure = 1, + Opt_appraise = 2, + Opt_dont_appraise = 3, + Opt_audit = 4, + Opt_hash___2 = 5, + Opt_dont_hash = 6, + Opt_obj_user = 7, + Opt_obj_role = 8, + Opt_obj_type = 9, + Opt_subj_user = 10, + Opt_subj_role = 11, + Opt_subj_type = 12, + Opt_func = 13, + Opt_mask = 14, + Opt_fsmagic = 15, + Opt_fsname = 16, + Opt_fsuuid = 17, + Opt_uid_eq = 18, + Opt_euid_eq = 19, + Opt_fowner_eq = 20, + Opt_uid_gt = 21, + Opt_euid_gt = 22, + Opt_fowner_gt = 23, + Opt_uid_lt = 24, + Opt_euid_lt = 25, + Opt_fowner_lt = 26, + Opt_appraise_type = 27, + Opt_appraise_flag = 28, + Opt_permit_directio = 29, + Opt_pcr = 30, + Opt_template = 31, + Opt_keyrings = 32, + Opt_err___9 = 33, +}; + +enum { + mask_exec = 0, + mask_write = 1, + mask_read = 2, + mask_append = 3, +}; + +struct ima_kexec_hdr { + u16 version; + u16 _reserved0; + u32 _reserved1; + u64 buffer_size; + u64 count; +}; + +enum header_fields { + HDR_PCR = 0, + HDR_DIGEST = 1, + HDR_TEMPLATE_NAME = 2, + HDR_TEMPLATE_DATA = 3, + HDR__LAST = 4, +}; + +enum data_formats { + DATA_FMT_DIGEST = 0, + DATA_FMT_DIGEST_WITH_ALGO = 1, + DATA_FMT_STRING = 2, + DATA_FMT_HEX = 3, +}; + +struct ima_key_entry { + struct list_head list; + void *payload; + size_t payload_len; + char *keyring_name; +}; + +struct crypto_template; + +struct crypto_spawn; + +struct crypto_instance { + struct crypto_alg alg; + struct crypto_template *tmpl; + union { + struct hlist_node list; + struct crypto_spawn *spawns; + }; + void *__ctx[0]; +}; + +struct crypto_spawn { + struct list_head list; + struct crypto_alg *alg; + union { + struct crypto_instance *inst; + struct crypto_spawn *next; + }; + const struct crypto_type *frontend; + u32 mask; + bool dead; + bool registered; +}; + +struct rtattr; + +struct crypto_template { + struct list_head list; + struct hlist_head instances; + struct module *module; + int (*create)(struct crypto_template *, struct rtattr **); + char name[128]; +}; + +enum { + CRYPTO_MSG_ALG_REQUEST = 0, + CRYPTO_MSG_ALG_REGISTER = 1, + CRYPTO_MSG_ALG_LOADED = 2, +}; + +struct crypto_larval { + struct crypto_alg alg; + struct crypto_alg *adult; + struct completion completion; + u32 mask; +}; + +struct crypto_cipher { + struct crypto_tfm base; +}; + +struct crypto_comp { + struct crypto_tfm base; +}; + +enum { + CRYPTOA_UNSPEC = 0, + CRYPTOA_ALG = 1, + CRYPTOA_TYPE = 2, + CRYPTOA_U32 = 3, + __CRYPTOA_MAX = 4, +}; + +struct crypto_attr_alg { + char name[128]; +}; + +struct crypto_attr_type { + u32 type; + u32 mask; +}; + +struct crypto_attr_u32 { + u32 num; +}; + +struct rtattr { + short unsigned int rta_len; + short unsigned int rta_type; +}; + +struct crypto_queue { + struct list_head list; + struct list_head *backlog; + unsigned int qlen; + unsigned int max_qlen; +}; + +enum { + NAPI_STATE_SCHED = 0, + NAPI_STATE_MISSED = 1, + NAPI_STATE_DISABLE = 2, + NAPI_STATE_NPSVC = 3, + NAPI_STATE_LISTED = 4, + NAPI_STATE_NO_BUSY_POLL = 5, + NAPI_STATE_IN_BUSY_POLL = 6, + NAPI_STATE_PREFER_BUSY_POLL = 7, +}; + +enum bpf_xdp_mode { + XDP_MODE_SKB = 0, + XDP_MODE_DRV = 1, + XDP_MODE_HW = 2, + __MAX_XDP_MODE = 3, +}; + +enum { + NETIF_MSG_DRV_BIT = 0, + NETIF_MSG_PROBE_BIT = 1, + NETIF_MSG_LINK_BIT = 2, + NETIF_MSG_TIMER_BIT = 3, + NETIF_MSG_IFDOWN_BIT = 4, + NETIF_MSG_IFUP_BIT = 5, + NETIF_MSG_RX_ERR_BIT = 6, + NETIF_MSG_TX_ERR_BIT = 7, + NETIF_MSG_TX_QUEUED_BIT = 8, + NETIF_MSG_INTR_BIT = 9, + NETIF_MSG_TX_DONE_BIT = 10, + NETIF_MSG_RX_STATUS_BIT = 11, + NETIF_MSG_PKTDATA_BIT = 12, + NETIF_MSG_HW_BIT = 13, + NETIF_MSG_WOL_BIT = 14, + NETIF_MSG_CLASS_COUNT = 15, +}; + +struct scatter_walk { + struct scatterlist *sg; + unsigned int offset; +}; + +struct aead_request { + struct crypto_async_request base; + unsigned int assoclen; + unsigned int cryptlen; + u8 *iv; + struct scatterlist *src; + struct scatterlist *dst; + void *__ctx[0]; +}; + +struct crypto_aead; + +struct aead_alg { + int (*setkey)(struct crypto_aead *, const u8 *, unsigned int); + int (*setauthsize)(struct crypto_aead *, unsigned int); + int (*encrypt)(struct aead_request *); + int (*decrypt)(struct aead_request *); + int (*init)(struct crypto_aead *); + void (*exit)(struct crypto_aead *); + unsigned int ivsize; + unsigned int maxauthsize; + unsigned int chunksize; + struct crypto_alg base; +}; + +struct crypto_aead { + unsigned int authsize; + unsigned int reqsize; + struct crypto_tfm base; +}; + +struct aead_instance { + void (*free)(struct aead_instance *); + union { + struct { + char head[64]; + struct crypto_instance base; + } s; + struct aead_alg alg; + }; +}; + +struct crypto_aead_spawn { + struct crypto_spawn base; +}; + +enum crypto_attr_type_t { + CRYPTOCFGA_UNSPEC = 0, + CRYPTOCFGA_PRIORITY_VAL = 1, + CRYPTOCFGA_REPORT_LARVAL = 2, + CRYPTOCFGA_REPORT_HASH = 3, + CRYPTOCFGA_REPORT_BLKCIPHER = 4, + CRYPTOCFGA_REPORT_AEAD = 5, + CRYPTOCFGA_REPORT_COMPRESS = 6, + CRYPTOCFGA_REPORT_RNG = 7, + CRYPTOCFGA_REPORT_CIPHER = 8, + CRYPTOCFGA_REPORT_AKCIPHER = 9, + CRYPTOCFGA_REPORT_KPP = 10, + CRYPTOCFGA_REPORT_ACOMP = 11, + CRYPTOCFGA_STAT_LARVAL = 12, + CRYPTOCFGA_STAT_HASH = 13, + CRYPTOCFGA_STAT_BLKCIPHER = 14, + CRYPTOCFGA_STAT_AEAD = 15, + CRYPTOCFGA_STAT_COMPRESS = 16, + CRYPTOCFGA_STAT_RNG = 17, + CRYPTOCFGA_STAT_CIPHER = 18, + CRYPTOCFGA_STAT_AKCIPHER = 19, + CRYPTOCFGA_STAT_KPP = 20, + CRYPTOCFGA_STAT_ACOMP = 21, + __CRYPTOCFGA_MAX = 22, +}; + +struct crypto_report_aead { + char type[64]; + char geniv[64]; + unsigned int blocksize; + unsigned int maxauthsize; + unsigned int ivsize; +}; + +struct crypto_sync_skcipher; + +struct aead_geniv_ctx { + spinlock_t lock; + struct crypto_aead *child; + struct crypto_sync_skcipher *sknull; + u8 salt[0]; +}; + +struct crypto_rng; + +struct rng_alg { + int (*generate)(struct crypto_rng *, const u8 *, unsigned int, u8 *, unsigned int); + int (*seed)(struct crypto_rng *, const u8 *, unsigned int); + void (*set_ent)(struct crypto_rng *, const u8 *, unsigned int); + unsigned int seedsize; + struct crypto_alg base; +}; + +struct crypto_rng { + struct crypto_tfm base; +}; + +struct crypto_cipher_spawn { + struct crypto_spawn base; +}; + +struct skcipher_request { + unsigned int cryptlen; + u8 *iv; + struct scatterlist *src; + struct scatterlist *dst; + struct crypto_async_request base; + void *__ctx[0]; +}; + +struct crypto_skcipher { + unsigned int reqsize; + struct crypto_tfm base; +}; + +struct crypto_sync_skcipher { + struct crypto_skcipher base; +}; + +struct skcipher_alg { + int (*setkey)(struct crypto_skcipher *, const u8 *, unsigned int); + int (*encrypt)(struct skcipher_request *); + int (*decrypt)(struct skcipher_request *); + int (*init)(struct crypto_skcipher *); + void (*exit)(struct crypto_skcipher *); + unsigned int min_keysize; + unsigned int max_keysize; + unsigned int ivsize; + unsigned int chunksize; + unsigned int walksize; + struct crypto_alg base; +}; + +struct skcipher_instance { + void (*free)(struct skcipher_instance *); + union { + struct { + char head[64]; + struct crypto_instance base; + } s; + struct skcipher_alg alg; + }; +}; + +struct crypto_skcipher_spawn { + struct crypto_spawn base; +}; + +struct skcipher_walk { + union { + struct { + struct page *page; + long unsigned int offset; + } phys; + struct { + u8 *page; + void *addr; + } virt; + } src; + union { + struct { + struct page *page; + long unsigned int offset; + } phys; + struct { + u8 *page; + void *addr; + } virt; + } dst; + struct scatter_walk in; + unsigned int nbytes; + struct scatter_walk out; + unsigned int total; + struct list_head buffers; + u8 *page; + u8 *buffer; + u8 *oiv; + void *iv; + unsigned int ivsize; + int flags; + unsigned int blocksize; + unsigned int stride; + unsigned int alignmask; +}; + +struct skcipher_ctx_simple { + struct crypto_cipher *cipher; +}; + +struct crypto_report_blkcipher { + char type[64]; + char geniv[64]; + unsigned int blocksize; + unsigned int min_keysize; + unsigned int max_keysize; + unsigned int ivsize; +}; + +enum { + SKCIPHER_WALK_PHYS = 1, + SKCIPHER_WALK_SLOW = 2, + SKCIPHER_WALK_COPY = 4, + SKCIPHER_WALK_DIFF = 8, + SKCIPHER_WALK_SLEEP = 16, +}; + +struct skcipher_walk_buffer { + struct list_head entry; + struct scatter_walk dst; + unsigned int len; + u8 *data; + u8 buffer[0]; +}; + +struct ahash_alg { + int (*init)(struct ahash_request *); + int (*update)(struct ahash_request *); + int (*final)(struct ahash_request *); + int (*finup)(struct ahash_request *); + int (*digest)(struct ahash_request *); + int (*export)(struct ahash_request *, void *); + int (*import)(struct ahash_request *, const void *); + int (*setkey)(struct crypto_ahash *, const u8 *, unsigned int); + int (*init_tfm)(struct crypto_ahash *); + void (*exit_tfm)(struct crypto_ahash *); + struct hash_alg_common halg; +}; + +struct crypto_hash_walk { + char *data; + unsigned int offset; + unsigned int alignmask; + struct page *pg; + unsigned int entrylen; + unsigned int total; + struct scatterlist *sg; + unsigned int flags; +}; + +struct ahash_instance { + void (*free)(struct ahash_instance *); + union { + struct { + char head[88]; + struct crypto_instance base; + } s; + struct ahash_alg alg; + }; +}; + +struct crypto_ahash_spawn { + struct crypto_spawn base; +}; + +struct crypto_report_hash { + char type[64]; + unsigned int blocksize; + unsigned int digestsize; +}; + +struct ahash_request_priv { + crypto_completion_t complete; + void *data; + u8 *result; + u32 flags; + void *ubuf[0]; +}; + +struct shash_instance { + void (*free)(struct shash_instance *); + union { + struct { + char head[96]; + struct crypto_instance base; + } s; + struct shash_alg alg; + }; +}; + +struct crypto_shash_spawn { + struct crypto_spawn base; +}; + +struct crypto_report_akcipher { + char type[64]; +}; + +struct akcipher_request { + struct crypto_async_request base; + struct scatterlist *src; + struct scatterlist *dst; + unsigned int src_len; + unsigned int dst_len; + void *__ctx[0]; +}; + +struct crypto_akcipher { + struct crypto_tfm base; +}; + +struct akcipher_alg { + int (*sign)(struct akcipher_request *); + int (*verify)(struct akcipher_request *); + int (*encrypt)(struct akcipher_request *); + int (*decrypt)(struct akcipher_request *); + int (*set_pub_key)(struct crypto_akcipher *, const void *, unsigned int); + int (*set_priv_key)(struct crypto_akcipher *, const void *, unsigned int); + unsigned int (*max_size)(struct crypto_akcipher *); + int (*init)(struct crypto_akcipher *); + void (*exit)(struct crypto_akcipher *); + unsigned int reqsize; + struct crypto_alg base; +}; + +struct akcipher_instance { + void (*free)(struct akcipher_instance *); + union { + struct { + char head[80]; + struct crypto_instance base; + } s; + struct akcipher_alg alg; + }; +}; + +struct crypto_akcipher_spawn { + struct crypto_spawn base; +}; + +struct crypto_report_kpp { + char type[64]; +}; + +struct kpp_request { + struct crypto_async_request base; + struct scatterlist *src; + struct scatterlist *dst; + unsigned int src_len; + unsigned int dst_len; + void *__ctx[0]; +}; + +struct crypto_kpp { + struct crypto_tfm base; +}; + +struct kpp_alg { + int (*set_secret)(struct crypto_kpp *, const void *, unsigned int); + int (*generate_public_key)(struct kpp_request *); + int (*compute_shared_secret)(struct kpp_request *); + unsigned int (*max_size)(struct crypto_kpp *); + int (*init)(struct crypto_kpp *); + void (*exit)(struct crypto_kpp *); + unsigned int reqsize; + struct crypto_alg base; +}; + +enum asn1_class { + ASN1_UNIV = 0, + ASN1_APPL = 1, + ASN1_CONT = 2, + ASN1_PRIV = 3, +}; + +enum asn1_method { + ASN1_PRIM = 0, + ASN1_CONS = 1, +}; + +enum asn1_tag { + ASN1_EOC = 0, + ASN1_BOOL = 1, + ASN1_INT = 2, + ASN1_BTS = 3, + ASN1_OTS = 4, + ASN1_NULL = 5, + ASN1_OID = 6, + ASN1_ODE = 7, + ASN1_EXT = 8, + ASN1_REAL = 9, + ASN1_ENUM = 10, + ASN1_EPDV = 11, + ASN1_UTF8STR = 12, + ASN1_RELOID = 13, + ASN1_SEQ = 16, + ASN1_SET = 17, + ASN1_NUMSTR = 18, + ASN1_PRNSTR = 19, + ASN1_TEXSTR = 20, + ASN1_VIDSTR = 21, + ASN1_IA5STR = 22, + ASN1_UNITIM = 23, + ASN1_GENTIM = 24, + ASN1_GRASTR = 25, + ASN1_VISSTR = 26, + ASN1_GENSTR = 27, + ASN1_UNISTR = 28, + ASN1_CHRSTR = 29, + ASN1_BMPSTR = 30, + ASN1_LONG_TAG = 31, +}; + +typedef int (*asn1_action_t)(void *, size_t, unsigned char, const void *, size_t); + +struct asn1_decoder { + const unsigned char *machine; + size_t machlen; + const asn1_action_t *actions; +}; + +enum asn1_opcode { + ASN1_OP_MATCH = 0, + ASN1_OP_MATCH_OR_SKIP = 1, + ASN1_OP_MATCH_ACT = 2, + ASN1_OP_MATCH_ACT_OR_SKIP = 3, + ASN1_OP_MATCH_JUMP = 4, + ASN1_OP_MATCH_JUMP_OR_SKIP = 5, + ASN1_OP_MATCH_ANY = 8, + ASN1_OP_MATCH_ANY_OR_SKIP = 9, + ASN1_OP_MATCH_ANY_ACT = 10, + ASN1_OP_MATCH_ANY_ACT_OR_SKIP = 11, + ASN1_OP_COND_MATCH_OR_SKIP = 17, + ASN1_OP_COND_MATCH_ACT_OR_SKIP = 19, + ASN1_OP_COND_MATCH_JUMP_OR_SKIP = 21, + ASN1_OP_COND_MATCH_ANY = 24, + ASN1_OP_COND_MATCH_ANY_OR_SKIP = 25, + ASN1_OP_COND_MATCH_ANY_ACT = 26, + ASN1_OP_COND_MATCH_ANY_ACT_OR_SKIP = 27, + ASN1_OP_COND_FAIL = 28, + ASN1_OP_COMPLETE = 29, + ASN1_OP_ACT = 30, + ASN1_OP_MAYBE_ACT = 31, + ASN1_OP_END_SEQ = 32, + ASN1_OP_END_SET = 33, + ASN1_OP_END_SEQ_OF = 34, + ASN1_OP_END_SET_OF = 35, + ASN1_OP_END_SEQ_ACT = 36, + ASN1_OP_END_SET_ACT = 37, + ASN1_OP_END_SEQ_OF_ACT = 38, + ASN1_OP_END_SET_OF_ACT = 39, + ASN1_OP_RETURN = 40, + ASN1_OP__NR = 41, +}; + +enum rsapubkey_actions { + ACT_rsa_get_e = 0, + ACT_rsa_get_n = 1, + NR__rsapubkey_actions = 2, +}; + +enum rsaprivkey_actions { + ACT_rsa_get_d = 0, + ACT_rsa_get_dp = 1, + ACT_rsa_get_dq = 2, + ACT_rsa_get_e___2 = 3, + ACT_rsa_get_n___2 = 4, + ACT_rsa_get_p = 5, + ACT_rsa_get_q = 6, + ACT_rsa_get_qinv = 7, + NR__rsaprivkey_actions = 8, +}; + +typedef long unsigned int mpi_limb_t; + +struct gcry_mpi { + int alloced; + int nlimbs; + int nbits; + int sign; + unsigned int flags; + mpi_limb_t *d; +}; + +typedef struct gcry_mpi *MPI; + +struct rsa_key { + const u8 *n; + const u8 *e; + const u8 *d; + const u8 *p; + const u8 *q; + const u8 *dp; + const u8 *dq; + const u8 *qinv; + size_t n_sz; + size_t e_sz; + size_t d_sz; + size_t p_sz; + size_t q_sz; + size_t dp_sz; + size_t dq_sz; + size_t qinv_sz; +}; + +struct rsa_mpi_key { + MPI n; + MPI e; + MPI d; +}; + +struct asn1_decoder___2; + +struct rsa_asn1_template { + const char *name; + const u8 *data; + size_t size; +}; + +struct pkcs1pad_ctx { + struct crypto_akcipher *child; + unsigned int key_size; +}; + +struct pkcs1pad_inst_ctx { + struct crypto_akcipher_spawn spawn; + const struct rsa_asn1_template *digest_info; +}; + +struct pkcs1pad_request { + struct scatterlist in_sg[2]; + struct scatterlist out_sg[1]; + uint8_t *in_buf; + uint8_t *out_buf; + struct akcipher_request child_req; +}; + +struct crypto_report_acomp { + char type[64]; +}; + +struct acomp_req { + struct crypto_async_request base; + struct scatterlist *src; + struct scatterlist *dst; + unsigned int slen; + unsigned int dlen; + u32 flags; + void *__ctx[0]; +}; + +struct crypto_acomp { + int (*compress)(struct acomp_req *); + int (*decompress)(struct acomp_req *); + void (*dst_free)(struct scatterlist *); + unsigned int reqsize; + struct crypto_tfm base; +}; + +struct acomp_alg { + int (*compress)(struct acomp_req *); + int (*decompress)(struct acomp_req *); + void (*dst_free)(struct scatterlist *); + int (*init)(struct crypto_acomp *); + void (*exit)(struct crypto_acomp *); + unsigned int reqsize; + struct crypto_alg base; +}; + +struct crypto_report_comp { + char type[64]; +}; + +struct crypto_scomp { + struct crypto_tfm base; +}; + +struct scomp_alg { + void * (*alloc_ctx)(struct crypto_scomp *); + void (*free_ctx)(struct crypto_scomp *, void *); + int (*compress)(struct crypto_scomp *, const u8 *, unsigned int, u8 *, unsigned int *, void *); + int (*decompress)(struct crypto_scomp *, const u8 *, unsigned int, u8 *, unsigned int *, void *); + struct crypto_alg base; +}; + +struct scomp_scratch { + spinlock_t lock; + void *src; + void *dst; +}; + +struct cryptomgr_param { + struct rtattr *tb[34]; + struct { + struct rtattr attr; + struct crypto_attr_type data; + } type; + union { + struct rtattr attr; + struct { + struct rtattr attr; + struct crypto_attr_alg data; + } alg; + struct { + struct rtattr attr; + struct crypto_attr_u32 data; + } nu32; + } attrs[32]; + char template[128]; + struct crypto_larval *larval; + u32 otype; + u32 omask; +}; + +struct crypto_test_param { + char driver[128]; + char alg[128]; + u32 type; +}; + +struct cmac_tfm_ctx { + struct crypto_cipher *child; + u8 ctx[0]; +}; + +struct cmac_desc_ctx { + unsigned int len; + u8 ctx[0]; +}; + +struct hmac_ctx { + struct crypto_shash *hash; +}; + +struct md5_state { + u32 hash[4]; + u32 block[16]; + u64 byte_count; +}; + +struct sha1_state { + u32 state[5]; + u64 count; + u8 buffer[64]; +}; + +typedef void sha1_block_fn(struct sha1_state *, const u8 *, int); + +struct sha256_state { + u32 state[8]; + u64 count; + u8 buf[64]; +}; + +enum blake2b_constant { + BLAKE2B_BLOCKBYTES = 128, + BLAKE2B_KEYBYTES = 64, +}; + +struct blake2b_state { + u64 h[8]; + u64 t[2]; + u64 f[2]; + u8 buf[128]; + size_t buflen; +}; + +struct blake2b_tfm_ctx { + u8 key[64]; + unsigned int keylen; +}; + +typedef struct { + u64 a; + u64 b; +} u128; + +typedef struct { + __be64 a; + __be64 b; +} be128; + +typedef struct { + __le64 b; + __le64 a; +} le128; + +struct gf128mul_4k { + be128 t[256]; +}; + +struct gf128mul_64k { + struct gf128mul_4k *t[16]; +}; + +struct crypto_rfc3686_ctx { + struct crypto_skcipher *child; + u8 nonce[4]; +}; + +struct crypto_rfc3686_req_ctx { + u8 iv[16]; + struct skcipher_request subreq; +}; + +struct gcm_instance_ctx { + struct crypto_skcipher_spawn ctr; + struct crypto_ahash_spawn ghash; +}; + +struct crypto_gcm_ctx { + struct crypto_skcipher *ctr; + struct crypto_ahash *ghash; +}; + +struct crypto_rfc4106_ctx { + struct crypto_aead *child; + u8 nonce[4]; +}; + +struct crypto_rfc4106_req_ctx { + struct scatterlist src[3]; + struct scatterlist dst[3]; + struct aead_request subreq; +}; + +struct crypto_rfc4543_instance_ctx { + struct crypto_aead_spawn aead; +}; + +struct crypto_rfc4543_ctx { + struct crypto_aead *child; + struct crypto_sync_skcipher *null; + u8 nonce[4]; +}; + +struct crypto_rfc4543_req_ctx { + struct aead_request subreq; +}; + +struct crypto_gcm_ghash_ctx { + unsigned int cryptlen; + struct scatterlist *src; + int (*complete)(struct aead_request *, u32); +}; + +struct crypto_gcm_req_priv_ctx { + u8 iv[16]; + u8 auth_tag[16]; + u8 iauth_tag[16]; + struct scatterlist src[3]; + struct scatterlist dst[3]; + struct scatterlist sg; + struct crypto_gcm_ghash_ctx ghash_ctx; + union { + struct ahash_request ahreq; + struct skcipher_request skreq; + } u; +}; + +struct ccm_instance_ctx { + struct crypto_skcipher_spawn ctr; + struct crypto_ahash_spawn mac; +}; + +struct crypto_ccm_ctx { + struct crypto_ahash *mac; + struct crypto_skcipher *ctr; +}; + +struct crypto_rfc4309_ctx { + struct crypto_aead *child; + u8 nonce[3]; +}; + +struct crypto_rfc4309_req_ctx { + struct scatterlist src[3]; + struct scatterlist dst[3]; + struct aead_request subreq; +}; + +struct crypto_ccm_req_priv_ctx { + u8 odata[16]; + u8 idata[16]; + u8 auth_tag[16]; + u32 flags; + struct scatterlist src[3]; + struct scatterlist dst[3]; + union { + struct ahash_request ahreq; + struct skcipher_request skreq; + }; +}; + +struct cbcmac_tfm_ctx { + struct crypto_cipher *child; +}; + +struct cbcmac_desc_ctx { + unsigned int len; +}; + +struct crypto_aes_ctx { + u32 key_enc[60]; + u32 key_dec[60]; + u32 key_length; +}; + +struct chksum_ctx { + u32 key; +}; + +struct chksum_desc_ctx { + u32 crc; +}; + +struct chksum_desc_ctx___2 { + __u16 crc; +}; + +struct xxh64_state { + uint64_t total_len; + uint64_t v1; + uint64_t v2; + uint64_t v3; + uint64_t v4; + uint64_t mem64[4]; + uint32_t memsize; +}; + +struct xxhash64_tfm_ctx { + u64 seed; +}; + +struct xxhash64_desc_ctx { + struct xxh64_state xxhstate; +}; + +struct crypto_report_rng { + char type[64]; + unsigned int seedsize; +}; + +struct random_ready_callback { + struct list_head list; + void (*func)(struct random_ready_callback *); + struct module *owner; +}; + +struct drbg_string { + const unsigned char *buf; + size_t len; + struct list_head list; +}; + +typedef uint32_t drbg_flag_t; + +struct drbg_core { + drbg_flag_t flags; + __u8 statelen; + __u8 blocklen_bytes; + char cra_name[128]; + char backend_cra_name[128]; +}; + +struct drbg_state; + +struct drbg_state_ops { + int (*update)(struct drbg_state *, struct list_head *, int); + int (*generate)(struct drbg_state *, unsigned char *, unsigned int, struct list_head *); + int (*crypto_init)(struct drbg_state *); + int (*crypto_fini)(struct drbg_state *); +}; + +struct drbg_state { + struct mutex drbg_mutex; + unsigned char *V; + unsigned char *Vbuf; + unsigned char *C; + unsigned char *Cbuf; + size_t reseed_ctr; + size_t reseed_threshold; + unsigned char *scratchpad; + unsigned char *scratchpadbuf; + void *priv_data; + struct crypto_skcipher *ctr_handle; + struct skcipher_request *ctr_req; + __u8 *outscratchpadbuf; + __u8 *outscratchpad; + struct crypto_wait ctr_wait; + struct scatterlist sg_in; + struct scatterlist sg_out; + bool seeded; + bool pr; + bool fips_primed; + unsigned char *prev; + struct work_struct seed_work; + struct crypto_rng *jent; + const struct drbg_state_ops *d_ops; + const struct drbg_core *core; + struct drbg_string test_data; + struct random_ready_callback random_ready; +}; + +enum drbg_prefixes { + DRBG_PREFIX0 = 0, + DRBG_PREFIX1 = 1, + DRBG_PREFIX2 = 2, + DRBG_PREFIX3 = 3, +}; + +struct sdesc { + struct shash_desc shash; + char ctx[0]; +}; + +struct rand_data { + __u64 data; + __u64 old_data; + __u64 prev_time; + __u64 last_delta; + __s64 last_delta2; + unsigned int osr; + unsigned char *mem; + unsigned int memlocation; + unsigned int memblocks; + unsigned int memblocksize; + unsigned int memaccessloops; + int rct_count; + unsigned int apt_observations; + unsigned int apt_count; + unsigned int apt_base; + unsigned int apt_base_set: 1; + unsigned int health_failure: 1; +}; + +struct rand_data___2; + +struct jitterentropy { + spinlock_t jent_lock; + struct rand_data___2 *entropy_collector; + unsigned int reset_cnt; +}; + +struct ghash_ctx { + struct gf128mul_4k *gf128; +}; + +struct ghash_desc_ctx { + u8 buffer[16]; + u32 bytes; +}; + +struct sockaddr_alg { + __u16 salg_family; + __u8 salg_type[14]; + __u32 salg_feat; + __u32 salg_mask; + __u8 salg_name[64]; +}; + +struct af_alg_iv { + __u32 ivlen; + __u8 iv[0]; +}; + +struct cmsghdr { + __kernel_size_t cmsg_len; + int cmsg_level; + int cmsg_type; +}; + +struct net_proto_family { + int family; + int (*create)(struct net *, struct socket *, int, int); + struct module *owner; +}; + +enum { + SOCK_WAKE_IO = 0, + SOCK_WAKE_WAITD = 1, + SOCK_WAKE_SPACE = 2, + SOCK_WAKE_URG = 3, +}; + +struct af_alg_type; + +struct alg_sock { + struct sock sk; + struct sock *parent; + atomic_t refcnt; + atomic_t nokey_refcnt; + const struct af_alg_type *type; + void *private; +}; + +struct af_alg_type { + void * (*bind)(const char *, u32, u32); + void (*release)(void *); + int (*setkey)(void *, const u8 *, unsigned int); + int (*setentropy)(void *, sockptr_t, unsigned int); + int (*accept)(void *, struct sock *); + int (*accept_nokey)(void *, struct sock *); + int (*setauthsize)(void *, unsigned int); + struct proto_ops *ops; + struct proto_ops *ops_nokey; + struct module *owner; + char name[14]; +}; + +struct af_alg_control { + struct af_alg_iv *iv; + int op; + unsigned int aead_assoclen; +}; + +struct af_alg_sgl { + struct scatterlist sg[17]; + struct page *pages[16]; + unsigned int npages; +}; + +struct af_alg_tsgl { + struct list_head list; + unsigned int cur; + struct scatterlist sg[0]; +}; + +struct af_alg_rsgl { + struct af_alg_sgl sgl; + struct list_head list; + size_t sg_num_bytes; +}; + +struct af_alg_async_req { + struct kiocb *iocb; + struct sock *sk; + struct af_alg_rsgl first_rsgl; + struct af_alg_rsgl *last_rsgl; + struct list_head rsgl_list; + struct scatterlist *tsgl; + unsigned int tsgl_entries; + unsigned int outlen; + unsigned int areqlen; + union { + struct aead_request aead_req; + struct skcipher_request skcipher_req; + } cra_u; +}; + +struct af_alg_ctx { + struct list_head tsgl_list; + void *iv; + size_t aead_assoclen; + struct crypto_wait wait; + size_t used; + atomic_t rcvused; + bool more; + bool merge; + bool enc; + bool init; + unsigned int len; +}; + +struct alg_type_list { + const struct af_alg_type *type; + struct list_head list; +}; + +struct hash_ctx { + struct af_alg_sgl sgl; + u8 *result; + struct crypto_wait wait; + unsigned int len; + bool more; + struct ahash_request req; +}; + +struct xor_block_template { + struct xor_block_template *next; + const char *name; + int speed; + void (*do_2)(long unsigned int, long unsigned int *, long unsigned int *); + void (*do_3)(long unsigned int, long unsigned int *, long unsigned int *, long unsigned int *); + void (*do_4)(long unsigned int, long unsigned int *, long unsigned int *, long unsigned int *, long unsigned int *); + void (*do_5)(long unsigned int, long unsigned int *, long unsigned int *, long unsigned int *, long unsigned int *, long unsigned int *); +}; + +enum asymmetric_payload_bits { + asym_crypto = 0, + asym_subtype = 1, + asym_key_ids = 2, + asym_auth = 3, +}; + +struct asymmetric_key_id { + short unsigned int len; + unsigned char data[0]; +}; + +struct asymmetric_key_ids { + void *id[2]; +}; + +struct public_key_signature; + +struct asymmetric_key_subtype { + struct module *owner; + const char *name; + short unsigned int name_len; + void (*describe)(const struct key *, struct seq_file *); + void (*destroy)(void *, void *); + int (*query)(const struct kernel_pkey_params *, struct kernel_pkey_query *); + int (*eds_op)(struct kernel_pkey_params *, const void *, void *); + int (*verify_signature)(const struct key *, const struct public_key_signature *); +}; + +struct public_key_signature { + struct asymmetric_key_id *auth_ids[2]; + u8 *s; + u32 s_size; + u8 *digest; + u8 digest_size; + const char *pkey_algo; + const char *hash_algo; + const char *encoding; + const void *data; + unsigned int data_size; +}; + +struct asymmetric_key_parser { + struct list_head link; + struct module *owner; + const char *name; + int (*parse)(struct key_preparsed_payload *); +}; + +enum OID { + OID_id_dsa_with_sha1 = 0, + OID_id_dsa = 1, + OID_id_ecdsa_with_sha1 = 2, + OID_id_ecPublicKey = 3, + OID_rsaEncryption = 4, + OID_md2WithRSAEncryption = 5, + OID_md3WithRSAEncryption = 6, + OID_md4WithRSAEncryption = 7, + OID_sha1WithRSAEncryption = 8, + OID_sha256WithRSAEncryption = 9, + OID_sha384WithRSAEncryption = 10, + OID_sha512WithRSAEncryption = 11, + OID_sha224WithRSAEncryption = 12, + OID_data = 13, + OID_signed_data = 14, + OID_email_address = 15, + OID_contentType = 16, + OID_messageDigest = 17, + OID_signingTime = 18, + OID_smimeCapabilites = 19, + OID_smimeAuthenticatedAttrs = 20, + OID_md2 = 21, + OID_md4 = 22, + OID_md5 = 23, + OID_msIndirectData = 24, + OID_msStatementType = 25, + OID_msSpOpusInfo = 26, + OID_msPeImageDataObjId = 27, + OID_msIndividualSPKeyPurpose = 28, + OID_msOutlookExpress = 29, + OID_certAuthInfoAccess = 30, + OID_sha1 = 31, + OID_sha256 = 32, + OID_sha384 = 33, + OID_sha512 = 34, + OID_sha224 = 35, + OID_commonName = 36, + OID_surname = 37, + OID_countryName = 38, + OID_locality = 39, + OID_stateOrProvinceName = 40, + OID_organizationName = 41, + OID_organizationUnitName = 42, + OID_title = 43, + OID_description = 44, + OID_name = 45, + OID_givenName = 46, + OID_initials = 47, + OID_generationalQualifier = 48, + OID_subjectKeyIdentifier = 49, + OID_keyUsage = 50, + OID_subjectAltName = 51, + OID_issuerAltName = 52, + OID_basicConstraints = 53, + OID_crlDistributionPoints = 54, + OID_certPolicies = 55, + OID_authorityKeyIdentifier = 56, + OID_extKeyUsage = 57, + OID_gostCPSignA = 58, + OID_gostCPSignB = 59, + OID_gostCPSignC = 60, + OID_gost2012PKey256 = 61, + OID_gost2012PKey512 = 62, + OID_gost2012Digest256 = 63, + OID_gost2012Digest512 = 64, + OID_gost2012Signature256 = 65, + OID_gost2012Signature512 = 66, + OID_gostTC26Sign256A = 67, + OID_gostTC26Sign256B = 68, + OID_gostTC26Sign256C = 69, + OID_gostTC26Sign256D = 70, + OID_gostTC26Sign512A = 71, + OID_gostTC26Sign512B = 72, + OID_gostTC26Sign512C = 73, + OID_sm2 = 74, + OID_sm3 = 75, + OID_SM2_with_SM3 = 76, + OID_sm3WithRSAEncryption = 77, + OID__NR = 78, +}; + +struct public_key { + void *key; + u32 keylen; + enum OID algo; + void *params; + u32 paramlen; + bool key_is_private; + const char *id_type; + const char *pkey_algo; +}; + +enum x509_actions { + ACT_x509_extract_key_data = 0, + ACT_x509_extract_name_segment = 1, + ACT_x509_note_OID = 2, + ACT_x509_note_issuer = 3, + ACT_x509_note_not_after = 4, + ACT_x509_note_not_before = 5, + ACT_x509_note_params = 6, + ACT_x509_note_pkey_algo = 7, + ACT_x509_note_serial = 8, + ACT_x509_note_signature = 9, + ACT_x509_note_subject = 10, + ACT_x509_note_tbs_certificate = 11, + ACT_x509_process_extension = 12, + NR__x509_actions = 13, +}; + +enum x509_akid_actions { + ACT_x509_akid_note_kid = 0, + ACT_x509_akid_note_name = 1, + ACT_x509_akid_note_serial = 2, + ACT_x509_extract_name_segment___2 = 3, + ACT_x509_note_OID___2 = 4, + NR__x509_akid_actions = 5, +}; + +struct x509_certificate { + struct x509_certificate *next; + struct x509_certificate *signer; + struct public_key *pub; + struct public_key_signature *sig; + char *issuer; + char *subject; + struct asymmetric_key_id *id; + struct asymmetric_key_id *skid; + time64_t valid_from; + time64_t valid_to; + const void *tbs; + unsigned int tbs_size; + unsigned int raw_sig_size; + const void *raw_sig; + const void *raw_serial; + unsigned int raw_serial_size; + unsigned int raw_issuer_size; + const void *raw_issuer; + const void *raw_subject; + unsigned int raw_subject_size; + unsigned int raw_skid_size; + const void *raw_skid; + unsigned int index; + bool seen; + bool verified; + bool self_signed; + bool unsupported_key; + bool unsupported_sig; + bool blacklisted; +}; + +struct x509_parse_context { + struct x509_certificate *cert; + long unsigned int data; + const void *cert_start; + const void *key; + size_t key_size; + const void *params; + size_t params_size; + enum OID key_algo; + enum OID last_oid; + enum OID algo_oid; + unsigned char nr_mpi; + u8 o_size; + u8 cn_size; + u8 email_size; + u16 o_offset; + u16 cn_offset; + u16 email_offset; + unsigned int raw_akid_size; + const void *raw_akid; + const void *akid_raw_issuer; + unsigned int akid_raw_issuer_size; +}; + +enum pkcs7_actions { + ACT_pkcs7_check_content_type = 0, + ACT_pkcs7_extract_cert = 1, + ACT_pkcs7_note_OID = 2, + ACT_pkcs7_note_certificate_list = 3, + ACT_pkcs7_note_content = 4, + ACT_pkcs7_note_data = 5, + ACT_pkcs7_note_signed_info = 6, + ACT_pkcs7_note_signeddata_version = 7, + ACT_pkcs7_note_signerinfo_version = 8, + ACT_pkcs7_sig_note_authenticated_attr = 9, + ACT_pkcs7_sig_note_digest_algo = 10, + ACT_pkcs7_sig_note_issuer = 11, + ACT_pkcs7_sig_note_pkey_algo = 12, + ACT_pkcs7_sig_note_serial = 13, + ACT_pkcs7_sig_note_set_of_authattrs = 14, + ACT_pkcs7_sig_note_signature = 15, + ACT_pkcs7_sig_note_skid = 16, + NR__pkcs7_actions = 17, +}; + +struct pkcs7_signed_info { + struct pkcs7_signed_info *next; + struct x509_certificate *signer; + unsigned int index; + bool unsupported_crypto; + bool blacklisted; + const void *msgdigest; + unsigned int msgdigest_len; + unsigned int authattrs_len; + const void *authattrs; + long unsigned int aa_set; + time64_t signing_time; + struct public_key_signature *sig; +}; + +struct pkcs7_message___2 { + struct x509_certificate *certs; + struct x509_certificate *crl; + struct pkcs7_signed_info *signed_infos; + u8 version; + bool have_authattrs; + enum OID data_type; + size_t data_len; + size_t data_hdrlen; + const void *data; +}; + +struct pkcs7_parse_context { + struct pkcs7_message___2 *msg; + struct pkcs7_signed_info *sinfo; + struct pkcs7_signed_info **ppsinfo; + struct x509_certificate *certs; + struct x509_certificate **ppcerts; + long unsigned int data; + enum OID last_oid; + unsigned int x509_index; + unsigned int sinfo_index; + const void *raw_serial; + unsigned int raw_serial_size; + unsigned int raw_issuer_size; + const void *raw_issuer; + const void *raw_skid; + unsigned int raw_skid_size; + bool expect_skid; +}; + +struct biovec_slab { + int nr_vecs; + char *name; + struct kmem_cache *slab; +}; + +enum rq_qos_id { + RQ_QOS_WBT = 0, + RQ_QOS_LATENCY = 1, + RQ_QOS_COST = 2, +}; + +struct rq_qos_ops; + +struct rq_qos { + struct rq_qos_ops *ops; + struct request_queue *q; + enum rq_qos_id id; + struct rq_qos *next; + struct dentry *debugfs_dir; +}; + +enum hctx_type { + HCTX_TYPE_DEFAULT = 0, + HCTX_TYPE_READ = 1, + HCTX_TYPE_POLL = 2, + HCTX_MAX_TYPES = 3, +}; + +struct rq_qos_ops { + void (*throttle)(struct rq_qos *, struct bio *); + void (*track)(struct rq_qos *, struct request *, struct bio *); + void (*merge)(struct rq_qos *, struct request *, struct bio *); + void (*issue)(struct rq_qos *, struct request *); + void (*requeue)(struct rq_qos *, struct request *); + void (*done)(struct rq_qos *, struct request *); + void (*done_bio)(struct rq_qos *, struct bio *); + void (*cleanup)(struct rq_qos *, struct bio *); + void (*queue_depth_changed)(struct rq_qos *); + void (*exit)(struct rq_qos *); + const struct blk_mq_debugfs_attr *debugfs_attrs; +}; + +struct bio_slab { + struct kmem_cache *slab; + unsigned int slab_ref; + unsigned int slab_size; + char name[8]; +}; + +enum { + BLK_MQ_F_SHOULD_MERGE = 1, + BLK_MQ_F_TAG_QUEUE_SHARED = 2, + BLK_MQ_F_STACKING = 4, + BLK_MQ_F_TAG_HCTX_SHARED = 8, + BLK_MQ_F_BLOCKING = 32, + BLK_MQ_F_NO_SCHED = 64, + BLK_MQ_F_ALLOC_POLICY_START_BIT = 8, + BLK_MQ_F_ALLOC_POLICY_BITS = 1, + BLK_MQ_S_STOPPED = 0, + BLK_MQ_S_TAG_ACTIVE = 1, + BLK_MQ_S_SCHED_RESTART = 2, + BLK_MQ_S_INACTIVE = 3, + BLK_MQ_MAX_DEPTH = 10240, + BLK_MQ_CPU_WORK_BATCH = 8, +}; + +enum { + WBT_RWQ_BG = 0, + WBT_RWQ_KSWAPD = 1, + WBT_RWQ_DISCARD = 2, + WBT_NUM_RWQ = 3, +}; + +enum { + BLK_MQ_REQ_NOWAIT = 1, + BLK_MQ_REQ_RESERVED = 2, + BLK_MQ_REQ_PREEMPT = 8, +}; + +struct trace_event_raw_block_buffer { + struct trace_entry ent; + dev_t dev; + sector_t sector; + size_t size; + char __data[0]; +}; + +struct trace_event_raw_block_rq_requeue { + struct trace_entry ent; + dev_t dev; + sector_t sector; + unsigned int nr_sector; + char rwbs[8]; + u32 __data_loc_cmd; + char __data[0]; +}; + +struct trace_event_raw_block_rq_complete { + struct trace_entry ent; + dev_t dev; + sector_t sector; + unsigned int nr_sector; + int error; + char rwbs[8]; + u32 __data_loc_cmd; + char __data[0]; +}; + +struct trace_event_raw_block_rq { + struct trace_entry ent; + dev_t dev; + sector_t sector; + unsigned int nr_sector; + unsigned int bytes; + char rwbs[8]; + char comm[16]; + u32 __data_loc_cmd; + char __data[0]; +}; + +struct trace_event_raw_block_bio_bounce { + struct trace_entry ent; + dev_t dev; + sector_t sector; + unsigned int nr_sector; + char rwbs[8]; + char comm[16]; + char __data[0]; +}; + +struct trace_event_raw_block_bio_complete { + struct trace_entry ent; + dev_t dev; + sector_t sector; + unsigned int nr_sector; + int error; + char rwbs[8]; + char __data[0]; +}; + +struct trace_event_raw_block_bio_merge { + struct trace_entry ent; + dev_t dev; + sector_t sector; + unsigned int nr_sector; + char rwbs[8]; + char comm[16]; + char __data[0]; +}; + +struct trace_event_raw_block_bio_queue { + struct trace_entry ent; + dev_t dev; + sector_t sector; + unsigned int nr_sector; + char rwbs[8]; + char comm[16]; + char __data[0]; +}; + +struct trace_event_raw_block_get_rq { + struct trace_entry ent; + dev_t dev; + sector_t sector; + unsigned int nr_sector; + char rwbs[8]; + char comm[16]; + char __data[0]; +}; + +struct trace_event_raw_block_plug { + struct trace_entry ent; + char comm[16]; + char __data[0]; +}; + +struct trace_event_raw_block_unplug { + struct trace_entry ent; + int nr_rq; + char comm[16]; + char __data[0]; +}; + +struct trace_event_raw_block_split { + struct trace_entry ent; + dev_t dev; + sector_t sector; + sector_t new_sector; + char rwbs[8]; + char comm[16]; + char __data[0]; +}; + +struct trace_event_raw_block_bio_remap { + struct trace_entry ent; + dev_t dev; + sector_t sector; + unsigned int nr_sector; + dev_t old_dev; + sector_t old_sector; + char rwbs[8]; + char __data[0]; +}; + +struct trace_event_raw_block_rq_remap { + struct trace_entry ent; + dev_t dev; + sector_t sector; + unsigned int nr_sector; + dev_t old_dev; + sector_t old_sector; + unsigned int nr_bios; + char rwbs[8]; + char __data[0]; +}; + +struct trace_event_data_offsets_block_buffer {}; + +struct trace_event_data_offsets_block_rq_requeue { + u32 cmd; +}; + +struct trace_event_data_offsets_block_rq_complete { + u32 cmd; +}; + +struct trace_event_data_offsets_block_rq { + u32 cmd; +}; + +struct trace_event_data_offsets_block_bio_bounce {}; + +struct trace_event_data_offsets_block_bio_complete {}; + +struct trace_event_data_offsets_block_bio_merge {}; + +struct trace_event_data_offsets_block_bio_queue {}; + +struct trace_event_data_offsets_block_get_rq {}; + +struct trace_event_data_offsets_block_plug {}; + +struct trace_event_data_offsets_block_unplug {}; + +struct trace_event_data_offsets_block_split {}; + +struct trace_event_data_offsets_block_bio_remap {}; + +struct trace_event_data_offsets_block_rq_remap {}; + +typedef void (*btf_trace_block_touch_buffer)(void *, struct buffer_head *); + +typedef void (*btf_trace_block_dirty_buffer)(void *, struct buffer_head *); + +typedef void (*btf_trace_block_rq_requeue)(void *, struct request_queue *, struct request *); + +typedef void (*btf_trace_block_rq_complete)(void *, struct request *, int, unsigned int); + +typedef void (*btf_trace_block_rq_insert)(void *, struct request_queue *, struct request *); + +typedef void (*btf_trace_block_rq_issue)(void *, struct request_queue *, struct request *); + +typedef void (*btf_trace_block_rq_merge)(void *, struct request_queue *, struct request *); + +typedef void (*btf_trace_block_bio_bounce)(void *, struct request_queue *, struct bio *); + +typedef void (*btf_trace_block_bio_complete)(void *, struct request_queue *, struct bio *); + +typedef void (*btf_trace_block_bio_backmerge)(void *, struct request_queue *, struct request *, struct bio *); + +typedef void (*btf_trace_block_bio_frontmerge)(void *, struct request_queue *, struct request *, struct bio *); + +typedef void (*btf_trace_block_bio_queue)(void *, struct request_queue *, struct bio *); + +typedef void (*btf_trace_block_getrq)(void *, struct request_queue *, struct bio *, int); + +typedef void (*btf_trace_block_sleeprq)(void *, struct request_queue *, struct bio *, int); + +typedef void (*btf_trace_block_plug)(void *, struct request_queue *); + +typedef void (*btf_trace_block_unplug)(void *, struct request_queue *, unsigned int, bool); + +typedef void (*btf_trace_block_split)(void *, struct request_queue *, struct bio *, unsigned int); + +typedef void (*btf_trace_block_bio_remap)(void *, struct request_queue *, struct bio *, dev_t, sector_t); + +typedef void (*btf_trace_block_rq_remap)(void *, struct request_queue *, struct request *, dev_t, sector_t); + +enum { + BLK_MQ_NO_TAG = 4294967295, + BLK_MQ_TAG_MIN = 1, + BLK_MQ_TAG_MAX = 4294967294, +}; + +struct queue_sysfs_entry { + struct attribute attr; + ssize_t (*show)(struct request_queue *, char *); + ssize_t (*store)(struct request_queue *, const char *, size_t); +}; + +enum { + REQ_FSEQ_PREFLUSH = 1, + REQ_FSEQ_DATA = 2, + REQ_FSEQ_POSTFLUSH = 4, + REQ_FSEQ_DONE = 8, + REQ_FSEQ_ACTIONS = 7, + FLUSH_PENDING_TIMEOUT = 5000, +}; + +enum blk_default_limits { + BLK_MAX_SEGMENTS = 128, + BLK_SAFE_MAX_SECTORS = 255, + BLK_DEF_MAX_SECTORS = 2560, + BLK_MAX_SEGMENT_SIZE = 65536, + BLK_SEG_BOUNDARY_MASK = 4294967295, +}; + +enum { + ICQ_EXITED = 4, + ICQ_DESTROYED = 8, +}; + +struct rq_map_data { + struct page **pages; + int page_order; + int nr_entries; + long unsigned int offset; + int null_mapped; + int from_user; +}; + +struct bio_map_data { + bool is_our_pages: 1; + bool is_null_mapped: 1; + struct iov_iter iter; + struct iovec iov[0]; +}; + +struct req_iterator { + struct bvec_iter iter; + struct bio *bio; +}; + +enum bio_merge_status { + BIO_MERGE_OK = 0, + BIO_MERGE_NONE = 1, + BIO_MERGE_FAILED = 2, +}; + +typedef bool (*sb_for_each_fn)(struct sbitmap *, unsigned int, void *); + +enum { + BLK_MQ_UNIQUE_TAG_BITS = 16, + BLK_MQ_UNIQUE_TAG_MASK = 65535, +}; + +struct mq_inflight { + struct hd_struct *part; + unsigned int inflight[2]; +}; + +struct flush_busy_ctx_data { + struct blk_mq_hw_ctx *hctx; + struct list_head *list; +}; + +struct dispatch_rq_data { + struct blk_mq_hw_ctx *hctx; + struct request *rq; +}; + +enum prep_dispatch { + PREP_DISPATCH_OK = 0, + PREP_DISPATCH_NO_TAG = 1, + PREP_DISPATCH_NO_BUDGET = 2, +}; + +struct rq_iter_data { + struct blk_mq_hw_ctx *hctx; + bool has_rq; +}; + +struct blk_mq_qe_pair { + struct list_head node; + struct request_queue *q; + struct elevator_type *type; +}; + +struct sbq_wait { + struct sbitmap_queue *sbq; + struct wait_queue_entry wait; +}; + +typedef bool busy_iter_fn(struct blk_mq_hw_ctx *, struct request *, void *, bool); + +typedef bool busy_tag_iter_fn(struct request *, void *, bool); + +struct bt_iter_data { + struct blk_mq_hw_ctx *hctx; + busy_iter_fn *fn; + void *data; + bool reserved; +}; + +struct bt_tags_iter_data { + struct blk_mq_tags *tags; + busy_tag_iter_fn *fn; + void *data; + unsigned int flags; +}; + +struct blk_queue_stats { + struct list_head callbacks; + spinlock_t lock; + bool enable_accounting; +}; + +struct blk_mq_ctx_sysfs_entry { + struct attribute attr; + ssize_t (*show)(struct blk_mq_ctx *, char *); + ssize_t (*store)(struct blk_mq_ctx *, const char *, size_t); +}; + +struct blk_mq_hw_ctx_sysfs_entry { + struct attribute attr; + ssize_t (*show)(struct blk_mq_hw_ctx *, char *); + ssize_t (*store)(struct blk_mq_hw_ctx *, const char *, size_t); +}; + +typedef u32 compat_caddr_t; + +struct hd_geometry { + unsigned char heads; + unsigned char sectors; + short unsigned int cylinders; + long unsigned int start; +}; + +struct blkpg_ioctl_arg { + int op; + int flags; + int datalen; + void *data; +}; + +struct blkpg_partition { + long long int start; + long long int length; + int pno; + char devname[64]; + char volname[64]; +}; + +struct pr_reservation { + __u64 key; + __u32 type; + __u32 flags; +}; + +struct pr_registration { + __u64 old_key; + __u64 new_key; + __u32 flags; + __u32 __pad; +}; + +struct pr_preempt { + __u64 old_key; + __u64 new_key; + __u32 type; + __u32 flags; +}; + +struct pr_clear { + __u64 key; + __u32 flags; + __u32 __pad; +}; + +struct compat_blkpg_ioctl_arg { + compat_int_t op; + compat_int_t flags; + compat_int_t datalen; + compat_caddr_t data; +}; + +struct compat_hd_geometry { + unsigned char heads; + unsigned char sectors; + short unsigned int cylinders; + u32 start; +}; + +struct klist_node; + +struct klist { + spinlock_t k_lock; + struct list_head k_list; + void (*get)(struct klist_node *); + void (*put)(struct klist_node *); +}; + +struct klist_node { + void *n_klist; + struct list_head n_node; + struct kref n_ref; +}; + +struct klist_iter { + struct klist *i_klist; + struct klist_node *i_cur; +}; + +struct class_dev_iter { + struct klist_iter ki; + const struct device_type *type; +}; + +enum { + DISK_EVENT_FLAG_POLL = 1, + DISK_EVENT_FLAG_UEVENT = 2, +}; + +struct disk_events { + struct list_head node; + struct gendisk *disk; + spinlock_t lock; + struct mutex block_mutex; + int block; + unsigned int pending; + unsigned int clearing; + long int poll_msecs; + struct delayed_work dwork; +}; + +struct badblocks { + struct device *dev; + int count; + int unacked_exist; + int shift; + u64 *page; + int changed; + seqlock_t lock; + sector_t sector; + sector_t size; +}; + +struct disk_part_iter { + struct gendisk *disk; + struct hd_struct *part; + int idx; + unsigned int flags; +}; + +struct blk_major_name { + struct blk_major_name *next; + int major; + char name[16]; +}; + +enum { + IOPRIO_WHO_PROCESS = 1, + IOPRIO_WHO_PGRP = 2, + IOPRIO_WHO_USER = 3, +}; + +struct parsed_partitions { + struct block_device *bdev; + char name[32]; + struct { + sector_t from; + sector_t size; + int flags; + bool has_info; + struct partition_meta_info info; + } *parts; + int next; + int limit; + bool access_beyond_eod; + char *pp_buf; +}; + +typedef struct { + struct page *v; +} Sector; + +struct RigidDiskBlock { + __u32 rdb_ID; + __be32 rdb_SummedLongs; + __s32 rdb_ChkSum; + __u32 rdb_HostID; + __be32 rdb_BlockBytes; + __u32 rdb_Flags; + __u32 rdb_BadBlockList; + __be32 rdb_PartitionList; + __u32 rdb_FileSysHeaderList; + __u32 rdb_DriveInit; + __u32 rdb_Reserved1[6]; + __u32 rdb_Cylinders; + __u32 rdb_Sectors; + __u32 rdb_Heads; + __u32 rdb_Interleave; + __u32 rdb_Park; + __u32 rdb_Reserved2[3]; + __u32 rdb_WritePreComp; + __u32 rdb_ReducedWrite; + __u32 rdb_StepRate; + __u32 rdb_Reserved3[5]; + __u32 rdb_RDBBlocksLo; + __u32 rdb_RDBBlocksHi; + __u32 rdb_LoCylinder; + __u32 rdb_HiCylinder; + __u32 rdb_CylBlocks; + __u32 rdb_AutoParkSeconds; + __u32 rdb_HighRDSKBlock; + __u32 rdb_Reserved4; + char rdb_DiskVendor[8]; + char rdb_DiskProduct[16]; + char rdb_DiskRevision[4]; + char rdb_ControllerVendor[8]; + char rdb_ControllerProduct[16]; + char rdb_ControllerRevision[4]; + __u32 rdb_Reserved5[10]; +}; + +struct PartitionBlock { + __be32 pb_ID; + __be32 pb_SummedLongs; + __s32 pb_ChkSum; + __u32 pb_HostID; + __be32 pb_Next; + __u32 pb_Flags; + __u32 pb_Reserved1[2]; + __u32 pb_DevFlags; + __u8 pb_DriveName[32]; + __u32 pb_Reserved2[15]; + __be32 pb_Environment[17]; + __u32 pb_EReserved[15]; +}; + +struct mac_partition { + __be16 signature; + __be16 res1; + __be32 map_count; + __be32 start_block; + __be32 block_count; + char name[32]; + char type[32]; + __be32 data_start; + __be32 data_count; + __be32 status; + __be32 boot_start; + __be32 boot_size; + __be32 boot_load; + __be32 boot_load2; + __be32 boot_entry; + __be32 boot_entry2; + __be32 boot_cksum; + char processor[16]; +}; + +struct mac_driver_desc { + __be16 signature; + __be16 block_size; + __be32 block_count; +}; + +struct fat_boot_sector { + __u8 ignored[3]; + __u8 system_id[8]; + __u8 sector_size[2]; + __u8 sec_per_clus; + __le16 reserved; + __u8 fats; + __u8 dir_entries[2]; + __u8 sectors[2]; + __u8 media; + __le16 fat_length; + __le16 secs_track; + __le16 heads; + __le32 hidden; + __le32 total_sect; + union { + struct { + __u8 drive_number; + __u8 state; + __u8 signature; + __u8 vol_id[4]; + __u8 vol_label[11]; + __u8 fs_type[8]; + } fat16; + struct { + __le32 length; + __le16 flags; + __u8 version[2]; + __le32 root_cluster; + __le16 info_sector; + __le16 backup_boot; + __le16 reserved2[6]; + __u8 drive_number; + __u8 state; + __u8 signature; + __u8 vol_id[4]; + __u8 vol_label[11]; + __u8 fs_type[8]; + } fat32; + }; +}; + +struct msdos_partition { + u8 boot_ind; + u8 head; + u8 sector; + u8 cyl; + u8 sys_ind; + u8 end_head; + u8 end_sector; + u8 end_cyl; + __le32 start_sect; + __le32 nr_sects; +}; + +enum msdos_sys_ind { + DOS_EXTENDED_PARTITION = 5, + LINUX_EXTENDED_PARTITION = 133, + WIN98_EXTENDED_PARTITION = 15, + LINUX_DATA_PARTITION = 131, + LINUX_LVM_PARTITION = 142, + LINUX_RAID_PARTITION = 253, + SOLARIS_X86_PARTITION = 130, + NEW_SOLARIS_X86_PARTITION = 191, + DM6_AUX1PARTITION = 81, + DM6_AUX3PARTITION = 83, + DM6_PARTITION = 84, + EZD_PARTITION = 85, + FREEBSD_PARTITION = 165, + OPENBSD_PARTITION = 166, + NETBSD_PARTITION = 169, + BSDI_PARTITION = 183, + MINIX_PARTITION = 129, + UNIXWARE_PARTITION = 99, +}; + +struct solaris_x86_slice { + __le16 s_tag; + __le16 s_flag; + __le32 s_start; + __le32 s_size; +}; + +struct solaris_x86_vtoc { + unsigned int v_bootinfo[3]; + __le32 v_sanity; + __le32 v_version; + char v_volume[8]; + __le16 v_sectorsz; + __le16 v_nparts; + unsigned int v_reserved[10]; + struct solaris_x86_slice v_slice[16]; + unsigned int timestamp[16]; + char v_asciilabel[128]; +}; + +struct bsd_partition { + __le32 p_size; + __le32 p_offset; + __le32 p_fsize; + __u8 p_fstype; + __u8 p_frag; + __le16 p_cpg; +}; + +struct bsd_disklabel { + __le32 d_magic; + __s16 d_type; + __s16 d_subtype; + char d_typename[16]; + char d_packname[16]; + __u32 d_secsize; + __u32 d_nsectors; + __u32 d_ntracks; + __u32 d_ncylinders; + __u32 d_secpercyl; + __u32 d_secperunit; + __u16 d_sparespertrack; + __u16 d_sparespercyl; + __u32 d_acylinders; + __u16 d_rpm; + __u16 d_interleave; + __u16 d_trackskew; + __u16 d_cylskew; + __u32 d_headswitch; + __u32 d_trkseek; + __u32 d_flags; + __u32 d_drivedata[5]; + __u32 d_spare[5]; + __le32 d_magic2; + __le16 d_checksum; + __le16 d_npartitions; + __le32 d_bbsize; + __le32 d_sbsize; + struct bsd_partition d_partitions[16]; +}; + +struct unixware_slice { + __le16 s_label; + __le16 s_flags; + __le32 start_sect; + __le32 nr_sects; +}; + +struct unixware_vtoc { + __le32 v_magic; + __le32 v_version; + char v_name[8]; + __le16 v_nslices; + __le16 v_unknown1; + __le32 v_reserved[10]; + struct unixware_slice v_slice[16]; +}; + +struct unixware_disklabel { + __le32 d_type; + __le32 d_magic; + __le32 d_version; + char d_serial[12]; + __le32 d_ncylinders; + __le32 d_ntracks; + __le32 d_nsectors; + __le32 d_secsize; + __le32 d_part_start; + __le32 d_unknown1[12]; + __le32 d_alt_tbl; + __le32 d_alt_len; + __le32 d_phys_cyl; + __le32 d_phys_trk; + __le32 d_phys_sec; + __le32 d_phys_bytes; + __le32 d_unknown2; + __le32 d_unknown3; + __le32 d_pad[8]; + struct unixware_vtoc vtoc; +}; + +struct d_partition { + __le32 p_size; + __le32 p_offset; + __le32 p_fsize; + u8 p_fstype; + u8 p_frag; + __le16 p_cpg; +}; + +struct disklabel { + __le32 d_magic; + __le16 d_type; + __le16 d_subtype; + u8 d_typename[16]; + u8 d_packname[16]; + __le32 d_secsize; + __le32 d_nsectors; + __le32 d_ntracks; + __le32 d_ncylinders; + __le32 d_secpercyl; + __le32 d_secprtunit; + __le16 d_sparespertrack; + __le16 d_sparespercyl; + __le32 d_acylinders; + __le16 d_rpm; + __le16 d_interleave; + __le16 d_trackskew; + __le16 d_cylskew; + __le32 d_headswitch; + __le32 d_trkseek; + __le32 d_flags; + __le32 d_drivedata[5]; + __le32 d_spare[5]; + __le32 d_magic2; + __le16 d_checksum; + __le16 d_npartitions; + __le32 d_bbsize; + __le32 d_sbsize; + struct d_partition d_partitions[18]; +}; + +enum { + LINUX_RAID_PARTITION___2 = 253, +}; + +struct sgi_volume { + s8 name[8]; + __be32 block_num; + __be32 num_bytes; +}; + +struct sgi_partition { + __be32 num_blocks; + __be32 first_block; + __be32 type; +}; + +struct sgi_disklabel { + __be32 magic_mushroom; + __be16 root_part_num; + __be16 swap_part_num; + s8 boot_file[16]; + u8 _unused0[48]; + struct sgi_volume volume[15]; + struct sgi_partition partitions[16]; + __be32 csum; + __be32 _unused1; +}; + +enum { + SUN_WHOLE_DISK = 5, + LINUX_RAID_PARTITION___3 = 253, +}; + +struct sun_info { + __be16 id; + __be16 flags; +}; + +struct sun_vtoc { + __be32 version; + char volume[8]; + __be16 nparts; + struct sun_info infos[8]; + __be16 padding; + __be32 bootinfo[3]; + __be32 sanity; + __be32 reserved[10]; + __be32 timestamp[8]; +}; + +struct sun_partition { + __be32 start_cylinder; + __be32 num_sectors; +}; + +struct sun_disklabel { + unsigned char info[128]; + struct sun_vtoc vtoc; + __be32 write_reinstruct; + __be32 read_reinstruct; + unsigned char spare[148]; + __be16 rspeed; + __be16 pcylcount; + __be16 sparecyl; + __be16 obs1; + __be16 obs2; + __be16 ilfact; + __be16 ncyl; + __be16 nacyl; + __be16 ntrks; + __be16 nsect; + __be16 obs3; + __be16 obs4; + struct sun_partition partitions[8]; + __be16 magic; + __be16 csum; +}; + +struct _gpt_header { + __le64 signature; + __le32 revision; + __le32 header_size; + __le32 header_crc32; + __le32 reserved1; + __le64 my_lba; + __le64 alternate_lba; + __le64 first_usable_lba; + __le64 last_usable_lba; + efi_guid_t disk_guid; + __le64 partition_entry_lba; + __le32 num_partition_entries; + __le32 sizeof_partition_entry; + __le32 partition_entry_array_crc32; +} __attribute__((packed)); + +typedef struct _gpt_header gpt_header; + +struct _gpt_entry_attributes { + u64 required_to_function: 1; + u64 reserved: 47; + u64 type_guid_specific: 16; +}; + +typedef struct _gpt_entry_attributes gpt_entry_attributes; + +struct _gpt_entry { + efi_guid_t partition_type_guid; + efi_guid_t unique_partition_guid; + __le64 starting_lba; + __le64 ending_lba; + gpt_entry_attributes attributes; + __le16 partition_name[36]; +}; + +typedef struct _gpt_entry gpt_entry; + +struct _gpt_mbr_record { + u8 boot_indicator; + u8 start_head; + u8 start_sector; + u8 start_track; + u8 os_type; + u8 end_head; + u8 end_sector; + u8 end_track; + __le32 starting_lba; + __le32 size_in_lba; +}; + +typedef struct _gpt_mbr_record gpt_mbr_record; + +struct _legacy_mbr { + u8 boot_code[440]; + __le32 unique_mbr_signature; + __le16 unknown; + gpt_mbr_record partition_record[4]; + __le16 signature; +} __attribute__((packed)); + +typedef struct _legacy_mbr legacy_mbr; + +struct d_partition___2 { + __le32 p_res; + u8 p_fstype; + u8 p_res2[3]; + __le32 p_offset; + __le32 p_size; +}; + +struct disklabel___2 { + u8 d_reserved[270]; + struct d_partition___2 d_partitions[2]; + u8 d_blank[208]; + __le16 d_magic; +} __attribute__((packed)); + +struct rq_wait { + wait_queue_head_t wait; + atomic_t inflight; +}; + +struct rq_depth { + unsigned int max_depth; + int scale_step; + bool scaled_max; + unsigned int queue_depth; + unsigned int default_depth; +}; + +typedef bool acquire_inflight_cb_t(struct rq_wait *, void *); + +typedef void cleanup_cb_t(struct rq_wait *, void *); + +struct rq_qos_wait_data { + struct wait_queue_entry wq; + struct task_struct *task; + struct rq_wait *rqw; + acquire_inflight_cb_t *cb; + void *private_data; + bool got_token; +}; + +struct request_sense; + +struct cdrom_generic_command { + unsigned char cmd[12]; + unsigned char *buffer; + unsigned int buflen; + int stat; + struct request_sense *sense; + unsigned char data_direction; + int quiet; + int timeout; + union { + void *reserved[1]; + void *unused; + }; +}; + +struct request_sense { + __u8 error_code: 7; + __u8 valid: 1; + __u8 segment_number; + __u8 sense_key: 4; + __u8 reserved2: 1; + __u8 ili: 1; + __u8 reserved1: 2; + __u8 information[4]; + __u8 add_sense_len; + __u8 command_info[4]; + __u8 asc; + __u8 ascq; + __u8 fruc; + __u8 sks[3]; + __u8 asb[46]; +}; + +struct scsi_ioctl_command { + unsigned int inlen; + unsigned int outlen; + unsigned char data[0]; +}; + +enum scsi_device_event { + SDEV_EVT_MEDIA_CHANGE = 1, + SDEV_EVT_INQUIRY_CHANGE_REPORTED = 2, + SDEV_EVT_CAPACITY_CHANGE_REPORTED = 3, + SDEV_EVT_SOFT_THRESHOLD_REACHED_REPORTED = 4, + SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED = 5, + SDEV_EVT_LUN_CHANGE_REPORTED = 6, + SDEV_EVT_ALUA_STATE_CHANGE_REPORTED = 7, + SDEV_EVT_POWER_ON_RESET_OCCURRED = 8, + SDEV_EVT_FIRST = 1, + SDEV_EVT_LAST = 8, + SDEV_EVT_MAXBITS = 9, +}; + +struct scsi_request { + unsigned char __cmd[16]; + unsigned char *cmd; + short unsigned int cmd_len; + int result; + unsigned int sense_len; + unsigned int resid_len; + int retries; + void *sense; +}; + +struct sg_io_hdr { + int interface_id; + int dxfer_direction; + unsigned char cmd_len; + unsigned char mx_sb_len; + short unsigned int iovec_count; + unsigned int dxfer_len; + void *dxferp; + unsigned char *cmdp; + void *sbp; + unsigned int timeout; + unsigned int flags; + int pack_id; + void *usr_ptr; + unsigned char status; + unsigned char masked_status; + unsigned char msg_status; + unsigned char sb_len_wr; + short unsigned int host_status; + short unsigned int driver_status; + int resid; + unsigned int duration; + unsigned int info; +}; + +struct compat_sg_io_hdr { + compat_int_t interface_id; + compat_int_t dxfer_direction; + unsigned char cmd_len; + unsigned char mx_sb_len; + short unsigned int iovec_count; + compat_uint_t dxfer_len; + compat_uint_t dxferp; + compat_uptr_t cmdp; + compat_uptr_t sbp; + compat_uint_t timeout; + compat_uint_t flags; + compat_int_t pack_id; + compat_uptr_t usr_ptr; + unsigned char status; + unsigned char masked_status; + unsigned char msg_status; + unsigned char sb_len_wr; + short unsigned int host_status; + short unsigned int driver_status; + compat_int_t resid; + compat_uint_t duration; + compat_uint_t info; +}; + +struct blk_cmd_filter { + long unsigned int read_ok[4]; + long unsigned int write_ok[4]; +}; + +struct compat_cdrom_generic_command { + unsigned char cmd[12]; + compat_caddr_t buffer; + compat_uint_t buflen; + compat_int_t stat; + compat_caddr_t sense; + unsigned char data_direction; + unsigned char pad[3]; + compat_int_t quiet; + compat_int_t timeout; + compat_caddr_t unused; +}; + +enum { + OMAX_SB_LEN = 16, +}; + +struct bsg_device { + struct request_queue *queue; + spinlock_t lock; + struct hlist_node dev_list; + refcount_t ref_count; + char name[20]; + int max_queue; +}; + +struct bsg_job; + +typedef int bsg_job_fn(struct bsg_job *); + +struct bsg_buffer { + unsigned int payload_len; + int sg_cnt; + struct scatterlist *sg_list; +}; + +struct bsg_job { + struct device *dev; + struct kref kref; + unsigned int timeout; + void *request; + void *reply; + unsigned int request_len; + unsigned int reply_len; + struct bsg_buffer request_payload; + struct bsg_buffer reply_payload; + int result; + unsigned int reply_payload_rcv_len; + struct request *bidi_rq; + struct bio *bidi_bio; + void *dd_data; +}; + +typedef enum blk_eh_timer_return bsg_timeout_fn(struct request *); + +struct bsg_set { + struct blk_mq_tag_set tag_set; + bsg_job_fn *job_fn; + bsg_timeout_fn *timeout_fn; +}; + +typedef struct blkcg_policy_data *blkcg_pol_alloc_cpd_fn(gfp_t); + +typedef void blkcg_pol_init_cpd_fn(struct blkcg_policy_data *); + +typedef void blkcg_pol_free_cpd_fn(struct blkcg_policy_data *); + +typedef void blkcg_pol_bind_cpd_fn(struct blkcg_policy_data *); + +typedef struct blkg_policy_data *blkcg_pol_alloc_pd_fn(gfp_t, struct request_queue *, struct blkcg *); + +typedef void blkcg_pol_init_pd_fn(struct blkg_policy_data *); + +typedef void blkcg_pol_online_pd_fn(struct blkg_policy_data *); + +typedef void blkcg_pol_offline_pd_fn(struct blkg_policy_data *); + +typedef void blkcg_pol_free_pd_fn(struct blkg_policy_data *); + +typedef void blkcg_pol_reset_pd_stats_fn(struct blkg_policy_data *); + +typedef size_t blkcg_pol_stat_pd_fn(struct blkg_policy_data *, char *, size_t); + +struct blkcg_policy { + int plid; + struct cftype *dfl_cftypes; + struct cftype *legacy_cftypes; + blkcg_pol_alloc_cpd_fn *cpd_alloc_fn; + blkcg_pol_init_cpd_fn *cpd_init_fn; + blkcg_pol_free_cpd_fn *cpd_free_fn; + blkcg_pol_bind_cpd_fn *cpd_bind_fn; + blkcg_pol_alloc_pd_fn *pd_alloc_fn; + blkcg_pol_init_pd_fn *pd_init_fn; + blkcg_pol_online_pd_fn *pd_online_fn; + blkcg_pol_offline_pd_fn *pd_offline_fn; + blkcg_pol_free_pd_fn *pd_free_fn; + blkcg_pol_reset_pd_stats_fn *pd_reset_stats_fn; + blkcg_pol_stat_pd_fn *pd_stat_fn; +}; + +struct blkg_conf_ctx { + struct gendisk *disk; + struct blkcg_gq *blkg; + char *body; +}; + +enum blkg_rwstat_type { + BLKG_RWSTAT_READ = 0, + BLKG_RWSTAT_WRITE = 1, + BLKG_RWSTAT_SYNC = 2, + BLKG_RWSTAT_ASYNC = 3, + BLKG_RWSTAT_DISCARD = 4, + BLKG_RWSTAT_NR = 5, + BLKG_RWSTAT_TOTAL = 5, +}; + +struct blkg_rwstat { + struct percpu_counter cpu_cnt[5]; + atomic64_t aux_cnt[5]; +}; + +struct blkg_rwstat_sample { + u64 cnt[5]; +}; + +struct throtl_service_queue { + struct throtl_service_queue *parent_sq; + struct list_head queued[2]; + unsigned int nr_queued[2]; + struct rb_root_cached pending_tree; + unsigned int nr_pending; + long unsigned int first_pending_disptime; + struct timer_list pending_timer; +}; + +struct latency_bucket { + long unsigned int total_latency; + int samples; +}; + +struct avg_latency_bucket { + long unsigned int latency; + bool valid; +}; + +struct throtl_data { + struct throtl_service_queue service_queue; + struct request_queue *queue; + unsigned int nr_queued[2]; + unsigned int throtl_slice; + struct work_struct dispatch_work; + unsigned int limit_index; + bool limit_valid[2]; + long unsigned int low_upgrade_time; + long unsigned int low_downgrade_time; + unsigned int scale; + struct latency_bucket tmp_buckets[18]; + struct avg_latency_bucket avg_buckets[18]; + struct latency_bucket *latency_buckets[2]; + long unsigned int last_calculate_time; + long unsigned int filtered_latency; + bool track_bio_latency; +}; + +struct throtl_grp; + +struct throtl_qnode { + struct list_head node; + struct bio_list bios; + struct throtl_grp *tg; +}; + +struct throtl_grp { + struct blkg_policy_data pd; + struct rb_node rb_node; + struct throtl_data *td; + struct throtl_service_queue service_queue; + struct throtl_qnode qnode_on_self[2]; + struct throtl_qnode qnode_on_parent[2]; + long unsigned int disptime; + unsigned int flags; + bool has_rules[2]; + uint64_t bps[4]; + uint64_t bps_conf[4]; + unsigned int iops[4]; + unsigned int iops_conf[4]; + uint64_t bytes_disp[2]; + unsigned int io_disp[2]; + long unsigned int last_low_overflow_time[2]; + uint64_t last_bytes_disp[2]; + unsigned int last_io_disp[2]; + long unsigned int last_check_time; + long unsigned int latency_target; + long unsigned int latency_target_conf; + long unsigned int slice_start[2]; + long unsigned int slice_end[2]; + long unsigned int last_finish_time; + long unsigned int checked_last_finish_time; + long unsigned int avg_idletime; + long unsigned int idletime_threshold; + long unsigned int idletime_threshold_conf; + unsigned int bio_cnt; + unsigned int bad_bio_cnt; + long unsigned int bio_cnt_reset_time; + struct blkg_rwstat stat_bytes; + struct blkg_rwstat stat_ios; +}; + +enum tg_state_flags { + THROTL_TG_PENDING = 1, + THROTL_TG_WAS_EMPTY = 2, +}; + +enum { + LIMIT_LOW = 0, + LIMIT_MAX = 1, + LIMIT_CNT = 2, +}; + +struct deadline_data { + struct rb_root sort_list[2]; + struct list_head fifo_list[2]; + struct request *next_rq[2]; + unsigned int batching; + unsigned int starved; + int fifo_expire[2]; + int fifo_batch; + int writes_starved; + int front_merges; + spinlock_t lock; + spinlock_t zone_lock; + struct list_head dispatch; +}; + +struct trace_event_raw_kyber_latency { + struct trace_entry ent; + dev_t dev; + char domain[16]; + char type[8]; + u8 percentile; + u8 numerator; + u8 denominator; + unsigned int samples; + char __data[0]; +}; + +struct trace_event_raw_kyber_adjust { + struct trace_entry ent; + dev_t dev; + char domain[16]; + unsigned int depth; + char __data[0]; +}; + +struct trace_event_raw_kyber_throttled { + struct trace_entry ent; + dev_t dev; + char domain[16]; + char __data[0]; +}; + +struct trace_event_data_offsets_kyber_latency {}; + +struct trace_event_data_offsets_kyber_adjust {}; + +struct trace_event_data_offsets_kyber_throttled {}; + +typedef void (*btf_trace_kyber_latency)(void *, struct request_queue *, const char *, const char *, unsigned int, unsigned int, unsigned int, unsigned int); + +typedef void (*btf_trace_kyber_adjust)(void *, struct request_queue *, const char *, unsigned int); + +typedef void (*btf_trace_kyber_throttled)(void *, struct request_queue *, const char *); + +enum { + KYBER_READ = 0, + KYBER_WRITE = 1, + KYBER_DISCARD = 2, + KYBER_OTHER = 3, + KYBER_NUM_DOMAINS = 4, +}; + +enum { + KYBER_ASYNC_PERCENT = 75, +}; + +enum { + KYBER_LATENCY_SHIFT = 2, + KYBER_GOOD_BUCKETS = 4, + KYBER_LATENCY_BUCKETS = 8, +}; + +enum { + KYBER_TOTAL_LATENCY = 0, + KYBER_IO_LATENCY = 1, +}; + +struct kyber_cpu_latency { + atomic_t buckets[48]; +}; + +struct kyber_ctx_queue { + spinlock_t lock; + struct list_head rq_list[4]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct kyber_queue_data { + struct request_queue *q; + struct sbitmap_queue domain_tokens[4]; + unsigned int async_depth; + struct kyber_cpu_latency *cpu_latency; + struct timer_list timer; + unsigned int latency_buckets[48]; + long unsigned int latency_timeout[3]; + int domain_p99[3]; + u64 latency_targets[3]; +}; + +struct kyber_hctx_data { + spinlock_t lock; + struct list_head rqs[4]; + unsigned int cur_domain; + unsigned int batching; + struct kyber_ctx_queue *kcqs; + struct sbitmap kcq_map[4]; + struct sbq_wait domain_wait[4]; + struct sbq_wait_state *domain_ws[4]; + atomic_t wait_index[4]; +}; + +struct flush_kcq_data { + struct kyber_hctx_data *khd; + unsigned int sched_domain; + struct list_head *list; +}; + +struct virtio_device_id { + __u32 device; + __u32 vendor; +}; + +struct virtio_device; + +struct virtqueue { + struct list_head list; + void (*callback)(struct virtqueue *); + const char *name; + struct virtio_device *vdev; + unsigned int index; + unsigned int num_free; + void *priv; +}; + +struct vringh_config_ops; + +struct virtio_config_ops; + +struct virtio_device { + int index; + bool failed; + bool config_enabled; + bool config_change_pending; + spinlock_t config_lock; + struct device dev; + struct virtio_device_id id; + const struct virtio_config_ops *config; + const struct vringh_config_ops *vringh_config; + struct list_head vqs; + u64 features; + void *priv; +}; + +typedef void vq_callback_t(struct virtqueue *); + +struct virtio_shm_region; + +struct virtio_config_ops { + void (*get)(struct virtio_device *, unsigned int, void *, unsigned int); + void (*set)(struct virtio_device *, unsigned int, const void *, unsigned int); + u32 (*generation)(struct virtio_device *); + u8 (*get_status)(struct virtio_device *); + void (*set_status)(struct virtio_device *, u8); + void (*reset)(struct virtio_device *); + int (*find_vqs)(struct virtio_device *, unsigned int, struct virtqueue **, vq_callback_t **, const char * const *, const bool *, struct irq_affinity *); + void (*del_vqs)(struct virtio_device *); + u64 (*get_features)(struct virtio_device *); + int (*finalize_features)(struct virtio_device *); + const char * (*bus_name)(struct virtio_device *); + int (*set_vq_affinity)(struct virtqueue *, const struct cpumask *); + const struct cpumask * (*get_vq_affinity)(struct virtio_device *, int); + bool (*get_shm_region)(struct virtio_device *, struct virtio_shm_region *, u8); +}; + +struct virtio_shm_region { + u64 addr; + u64 len; +}; + +struct irq_poll; + +typedef int irq_poll_fn(struct irq_poll *, int); + +struct irq_poll { + struct list_head list; + long unsigned int state; + int weight; + irq_poll_fn *poll; +}; + +struct dim_sample { + ktime_t time; + u32 pkt_ctr; + u32 byte_ctr; + u16 event_ctr; + u32 comp_ctr; +}; + +struct dim_stats { + int ppms; + int bpms; + int epms; + int cpms; + int cpe_ratio; +}; + +struct dim { + u8 state; + struct dim_stats prev_stats; + struct dim_sample start_sample; + struct dim_sample measuring_sample; + struct work_struct work; + void *priv; + u8 profile_ix; + u8 mode; + u8 tune_state; + u8 steps_right; + u8 steps_left; + u8 tired; +}; + +enum rdma_nl_counter_mode { + RDMA_COUNTER_MODE_NONE = 0, + RDMA_COUNTER_MODE_AUTO = 1, + RDMA_COUNTER_MODE_MANUAL = 2, + RDMA_COUNTER_MODE_MAX = 3, +}; + +enum rdma_nl_counter_mask { + RDMA_COUNTER_MASK_QP_TYPE = 1, + RDMA_COUNTER_MASK_PID = 2, +}; + +enum rdma_restrack_type { + RDMA_RESTRACK_PD = 0, + RDMA_RESTRACK_CQ = 1, + RDMA_RESTRACK_QP = 2, + RDMA_RESTRACK_CM_ID = 3, + RDMA_RESTRACK_MR = 4, + RDMA_RESTRACK_CTX = 5, + RDMA_RESTRACK_COUNTER = 6, + RDMA_RESTRACK_MAX = 7, +}; + +struct rdma_restrack_entry { + bool valid; + struct kref kref; + struct completion comp; + struct task_struct *task; + const char *kern_name; + enum rdma_restrack_type type; + bool user; + u32 id; +}; + +struct rdma_link_ops { + struct list_head list; + const char *type; + int (*newlink)(const char *, struct net_device *); +}; + +struct auto_mode_param { + int qp_type; +}; + +struct rdma_counter_mode { + enum rdma_nl_counter_mode mode; + enum rdma_nl_counter_mask mask; + struct auto_mode_param param; +}; + +struct rdma_hw_stats; + +struct rdma_port_counter { + struct rdma_counter_mode mode; + struct rdma_hw_stats *hstats; + unsigned int num_counters; + struct mutex lock; +}; + +struct rdma_hw_stats { + struct mutex lock; + long unsigned int timestamp; + long unsigned int lifespan; + const char * const *names; + int num_counters; + u64 value[0]; +}; + +struct ib_device; + +struct rdma_counter { + struct rdma_restrack_entry res; + struct ib_device *device; + uint32_t id; + struct kref kref; + struct rdma_counter_mode mode; + struct mutex lock; + struct rdma_hw_stats *stats; + u8 port; +}; + +enum rdma_driver_id { + RDMA_DRIVER_UNKNOWN = 0, + RDMA_DRIVER_MLX5 = 1, + RDMA_DRIVER_MLX4 = 2, + RDMA_DRIVER_CXGB3 = 3, + RDMA_DRIVER_CXGB4 = 4, + RDMA_DRIVER_MTHCA = 5, + RDMA_DRIVER_BNXT_RE = 6, + RDMA_DRIVER_OCRDMA = 7, + RDMA_DRIVER_NES = 8, + RDMA_DRIVER_I40IW = 9, + RDMA_DRIVER_VMW_PVRDMA = 10, + RDMA_DRIVER_QEDR = 11, + RDMA_DRIVER_HNS = 12, + RDMA_DRIVER_USNIC = 13, + RDMA_DRIVER_RXE = 14, + RDMA_DRIVER_HFI1 = 15, + RDMA_DRIVER_QIB = 16, + RDMA_DRIVER_EFA = 17, + RDMA_DRIVER_SIW = 18, +}; + +enum ib_cq_notify_flags { + IB_CQ_SOLICITED = 1, + IB_CQ_NEXT_COMP = 2, + IB_CQ_SOLICITED_MASK = 3, + IB_CQ_REPORT_MISSED_EVENTS = 4, +}; + +struct ib_mad; + +enum rdma_link_layer { + IB_LINK_LAYER_UNSPECIFIED = 0, + IB_LINK_LAYER_INFINIBAND = 1, + IB_LINK_LAYER_ETHERNET = 2, +}; + +enum rdma_netdev_t { + RDMA_NETDEV_OPA_VNIC = 0, + RDMA_NETDEV_IPOIB = 1, +}; + +enum ib_srq_attr_mask { + IB_SRQ_MAX_WR = 1, + IB_SRQ_LIMIT = 2, +}; + +enum ib_mr_type { + IB_MR_TYPE_MEM_REG = 0, + IB_MR_TYPE_SG_GAPS = 1, + IB_MR_TYPE_DM = 2, + IB_MR_TYPE_USER = 3, + IB_MR_TYPE_DMA = 4, + IB_MR_TYPE_INTEGRITY = 5, +}; + +enum ib_uverbs_advise_mr_advice { + IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH = 0, + IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH_WRITE = 1, + IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH_NO_FAULT = 2, +}; + +struct uverbs_attr_bundle; + +struct rdma_cm_id; + +struct iw_cm_id; + +struct iw_cm_conn_param; + +struct ib_qp; + +struct ib_send_wr; + +struct ib_recv_wr; + +struct ib_cq; + +struct ib_wc; + +struct ib_srq; + +struct ib_grh; + +struct ib_device_attr; + +struct ib_udata; + +struct ib_device_modify; + +struct ib_port_attr; + +struct ib_port_modify; + +struct ib_port_immutable; + +struct rdma_netdev_alloc_params; + +union ib_gid; + +struct ib_gid_attr; + +struct ib_ucontext; + +struct rdma_user_mmap_entry; + +struct ib_pd; + +struct ib_ah; + +struct rdma_ah_init_attr; + +struct rdma_ah_attr; + +struct ib_srq_init_attr; + +struct ib_srq_attr; + +struct ib_qp_init_attr; + +struct ib_qp_attr; + +struct ib_cq_init_attr; + +struct ib_mr; + +struct ib_sge; + +struct ib_mr_status; + +struct ib_mw; + +struct ib_xrcd; + +struct ib_flow; + +struct ib_flow_attr; + +struct ib_flow_action; + +struct ib_flow_action_attrs_esp; + +struct ib_wq; + +struct ib_wq_init_attr; + +struct ib_wq_attr; + +struct ib_rwq_ind_table; + +struct ib_rwq_ind_table_init_attr; + +struct ib_dm; + +struct ib_dm_alloc_attr; + +struct ib_dm_mr_attr; + +struct ib_counters; + +struct ib_counters_read_attr; + +struct ib_device_ops { + struct module *owner; + enum rdma_driver_id driver_id; + u32 uverbs_abi_ver; + unsigned int uverbs_no_driver_id_binding: 1; + int (*post_send)(struct ib_qp *, const struct ib_send_wr *, const struct ib_send_wr **); + int (*post_recv)(struct ib_qp *, const struct ib_recv_wr *, const struct ib_recv_wr **); + void (*drain_rq)(struct ib_qp *); + void (*drain_sq)(struct ib_qp *); + int (*poll_cq)(struct ib_cq *, int, struct ib_wc *); + int (*peek_cq)(struct ib_cq *, int); + int (*req_notify_cq)(struct ib_cq *, enum ib_cq_notify_flags); + int (*req_ncomp_notif)(struct ib_cq *, int); + int (*post_srq_recv)(struct ib_srq *, const struct ib_recv_wr *, const struct ib_recv_wr **); + int (*process_mad)(struct ib_device *, int, u8, const struct ib_wc *, const struct ib_grh *, const struct ib_mad *, struct ib_mad *, size_t *, u16 *); + int (*query_device)(struct ib_device *, struct ib_device_attr *, struct ib_udata *); + int (*modify_device)(struct ib_device *, int, struct ib_device_modify *); + void (*get_dev_fw_str)(struct ib_device *, char *); + const struct cpumask * (*get_vector_affinity)(struct ib_device *, int); + int (*query_port)(struct ib_device *, u8, struct ib_port_attr *); + int (*modify_port)(struct ib_device *, u8, int, struct ib_port_modify *); + int (*get_port_immutable)(struct ib_device *, u8, struct ib_port_immutable *); + enum rdma_link_layer (*get_link_layer)(struct ib_device *, u8); + struct net_device * (*get_netdev)(struct ib_device *, u8); + struct net_device * (*alloc_rdma_netdev)(struct ib_device *, u8, enum rdma_netdev_t, const char *, unsigned char, void (*)(struct net_device *)); + int (*rdma_netdev_get_params)(struct ib_device *, u8, enum rdma_netdev_t, struct rdma_netdev_alloc_params *); + int (*query_gid)(struct ib_device *, u8, int, union ib_gid *); + int (*add_gid)(const struct ib_gid_attr *, void **); + int (*del_gid)(const struct ib_gid_attr *, void **); + int (*query_pkey)(struct ib_device *, u8, u16, u16 *); + int (*alloc_ucontext)(struct ib_ucontext *, struct ib_udata *); + void (*dealloc_ucontext)(struct ib_ucontext *); + int (*mmap)(struct ib_ucontext *, struct vm_area_struct *); + void (*mmap_free)(struct rdma_user_mmap_entry *); + void (*disassociate_ucontext)(struct ib_ucontext *); + int (*alloc_pd)(struct ib_pd *, struct ib_udata *); + int (*dealloc_pd)(struct ib_pd *, struct ib_udata *); + int (*create_ah)(struct ib_ah *, struct rdma_ah_init_attr *, struct ib_udata *); + int (*modify_ah)(struct ib_ah *, struct rdma_ah_attr *); + int (*query_ah)(struct ib_ah *, struct rdma_ah_attr *); + int (*destroy_ah)(struct ib_ah *, u32); + int (*create_srq)(struct ib_srq *, struct ib_srq_init_attr *, struct ib_udata *); + int (*modify_srq)(struct ib_srq *, struct ib_srq_attr *, enum ib_srq_attr_mask, struct ib_udata *); + int (*query_srq)(struct ib_srq *, struct ib_srq_attr *); + int (*destroy_srq)(struct ib_srq *, struct ib_udata *); + struct ib_qp * (*create_qp)(struct ib_pd *, struct ib_qp_init_attr *, struct ib_udata *); + int (*modify_qp)(struct ib_qp *, struct ib_qp_attr *, int, struct ib_udata *); + int (*query_qp)(struct ib_qp *, struct ib_qp_attr *, int, struct ib_qp_init_attr *); + int (*destroy_qp)(struct ib_qp *, struct ib_udata *); + int (*create_cq)(struct ib_cq *, const struct ib_cq_init_attr *, struct ib_udata *); + int (*modify_cq)(struct ib_cq *, u16, u16); + int (*destroy_cq)(struct ib_cq *, struct ib_udata *); + int (*resize_cq)(struct ib_cq *, int, struct ib_udata *); + struct ib_mr * (*get_dma_mr)(struct ib_pd *, int); + struct ib_mr * (*reg_user_mr)(struct ib_pd *, u64, u64, u64, int, struct ib_udata *); + int (*rereg_user_mr)(struct ib_mr *, int, u64, u64, u64, int, struct ib_pd *, struct ib_udata *); + int (*dereg_mr)(struct ib_mr *, struct ib_udata *); + struct ib_mr * (*alloc_mr)(struct ib_pd *, enum ib_mr_type, u32); + struct ib_mr * (*alloc_mr_integrity)(struct ib_pd *, u32, u32); + int (*advise_mr)(struct ib_pd *, enum ib_uverbs_advise_mr_advice, u32, struct ib_sge *, u32, struct uverbs_attr_bundle *); + int (*map_mr_sg)(struct ib_mr *, struct scatterlist *, int, unsigned int *); + int (*check_mr_status)(struct ib_mr *, u32, struct ib_mr_status *); + int (*alloc_mw)(struct ib_mw *, struct ib_udata *); + int (*dealloc_mw)(struct ib_mw *); + int (*attach_mcast)(struct ib_qp *, union ib_gid *, u16); + int (*detach_mcast)(struct ib_qp *, union ib_gid *, u16); + int (*alloc_xrcd)(struct ib_xrcd *, struct ib_udata *); + int (*dealloc_xrcd)(struct ib_xrcd *, struct ib_udata *); + struct ib_flow * (*create_flow)(struct ib_qp *, struct ib_flow_attr *, struct ib_udata *); + int (*destroy_flow)(struct ib_flow *); + struct ib_flow_action * (*create_flow_action_esp)(struct ib_device *, const struct ib_flow_action_attrs_esp *, struct uverbs_attr_bundle *); + int (*destroy_flow_action)(struct ib_flow_action *); + int (*modify_flow_action_esp)(struct ib_flow_action *, const struct ib_flow_action_attrs_esp *, struct uverbs_attr_bundle *); + int (*set_vf_link_state)(struct ib_device *, int, u8, int); + int (*get_vf_config)(struct ib_device *, int, u8, struct ifla_vf_info *); + int (*get_vf_stats)(struct ib_device *, int, u8, struct ifla_vf_stats *); + int (*get_vf_guid)(struct ib_device *, int, u8, struct ifla_vf_guid *, struct ifla_vf_guid *); + int (*set_vf_guid)(struct ib_device *, int, u8, u64, int); + struct ib_wq * (*create_wq)(struct ib_pd *, struct ib_wq_init_attr *, struct ib_udata *); + int (*destroy_wq)(struct ib_wq *, struct ib_udata *); + int (*modify_wq)(struct ib_wq *, struct ib_wq_attr *, u32, struct ib_udata *); + int (*create_rwq_ind_table)(struct ib_rwq_ind_table *, struct ib_rwq_ind_table_init_attr *, struct ib_udata *); + int (*destroy_rwq_ind_table)(struct ib_rwq_ind_table *); + struct ib_dm * (*alloc_dm)(struct ib_device *, struct ib_ucontext *, struct ib_dm_alloc_attr *, struct uverbs_attr_bundle *); + int (*dealloc_dm)(struct ib_dm *, struct uverbs_attr_bundle *); + struct ib_mr * (*reg_dm_mr)(struct ib_pd *, struct ib_dm *, struct ib_dm_mr_attr *, struct uverbs_attr_bundle *); + int (*create_counters)(struct ib_counters *, struct uverbs_attr_bundle *); + int (*destroy_counters)(struct ib_counters *); + int (*read_counters)(struct ib_counters *, struct ib_counters_read_attr *, struct uverbs_attr_bundle *); + int (*map_mr_sg_pi)(struct ib_mr *, struct scatterlist *, int, unsigned int *, struct scatterlist *, int, unsigned int *); + struct rdma_hw_stats * (*alloc_hw_stats)(struct ib_device *, u8); + int (*get_hw_stats)(struct ib_device *, struct rdma_hw_stats *, u8, int); + int (*init_port)(struct ib_device *, u8, struct kobject *); + int (*fill_res_mr_entry)(struct sk_buff *, struct ib_mr *); + int (*fill_res_mr_entry_raw)(struct sk_buff *, struct ib_mr *); + int (*fill_res_cq_entry)(struct sk_buff *, struct ib_cq *); + int (*fill_res_cq_entry_raw)(struct sk_buff *, struct ib_cq *); + int (*fill_res_qp_entry)(struct sk_buff *, struct ib_qp *); + int (*fill_res_qp_entry_raw)(struct sk_buff *, struct ib_qp *); + int (*fill_res_cm_id_entry)(struct sk_buff *, struct rdma_cm_id *); + int (*enable_driver)(struct ib_device *); + void (*dealloc_driver)(struct ib_device *); + void (*iw_add_ref)(struct ib_qp *); + void (*iw_rem_ref)(struct ib_qp *); + struct ib_qp * (*iw_get_qp)(struct ib_device *, int); + int (*iw_connect)(struct iw_cm_id *, struct iw_cm_conn_param *); + int (*iw_accept)(struct iw_cm_id *, struct iw_cm_conn_param *); + int (*iw_reject)(struct iw_cm_id *, const void *, u8); + int (*iw_create_listen)(struct iw_cm_id *, int); + int (*iw_destroy_listen)(struct iw_cm_id *); + int (*counter_bind_qp)(struct rdma_counter *, struct ib_qp *); + int (*counter_unbind_qp)(struct ib_qp *); + int (*counter_dealloc)(struct rdma_counter *); + struct rdma_hw_stats * (*counter_alloc_stats)(struct rdma_counter *); + int (*counter_update_stats)(struct rdma_counter *); + int (*fill_stat_mr_entry)(struct sk_buff *, struct ib_mr *); + int (*query_ucontext)(struct ib_ucontext *, struct uverbs_attr_bundle *); + size_t size_ib_ah; + size_t size_ib_counters; + size_t size_ib_cq; + size_t size_ib_mw; + size_t size_ib_pd; + size_t size_ib_rwq_ind_table; + size_t size_ib_srq; + size_t size_ib_ucontext; + size_t size_ib_xrcd; +}; + +struct ib_core_device { + struct device dev; + possible_net_t rdma_net; + struct kobject *ports_kobj; + struct list_head port_list; + struct ib_device *owner; +}; + +enum ib_atomic_cap { + IB_ATOMIC_NONE = 0, + IB_ATOMIC_HCA = 1, + IB_ATOMIC_GLOB = 2, +}; + +struct ib_odp_caps { + uint64_t general_caps; + struct { + uint32_t rc_odp_caps; + uint32_t uc_odp_caps; + uint32_t ud_odp_caps; + uint32_t xrc_odp_caps; + } per_transport_caps; +}; + +struct ib_rss_caps { + u32 supported_qpts; + u32 max_rwq_indirection_tables; + u32 max_rwq_indirection_table_size; +}; + +struct ib_tm_caps { + u32 max_rndv_hdr_size; + u32 max_num_tags; + u32 flags; + u32 max_ops; + u32 max_sge; +}; + +struct ib_cq_caps { + u16 max_cq_moderation_count; + u16 max_cq_moderation_period; +}; + +struct ib_device_attr { + u64 fw_ver; + __be64 sys_image_guid; + u64 max_mr_size; + u64 page_size_cap; + u32 vendor_id; + u32 vendor_part_id; + u32 hw_ver; + int max_qp; + int max_qp_wr; + u64 device_cap_flags; + int max_send_sge; + int max_recv_sge; + int max_sge_rd; + int max_cq; + int max_cqe; + int max_mr; + int max_pd; + int max_qp_rd_atom; + int max_ee_rd_atom; + int max_res_rd_atom; + int max_qp_init_rd_atom; + int max_ee_init_rd_atom; + enum ib_atomic_cap atomic_cap; + enum ib_atomic_cap masked_atomic_cap; + int max_ee; + int max_rdd; + int max_mw; + int max_raw_ipv6_qp; + int max_raw_ethy_qp; + int max_mcast_grp; + int max_mcast_qp_attach; + int max_total_mcast_qp_attach; + int max_ah; + int max_srq; + int max_srq_wr; + int max_srq_sge; + unsigned int max_fast_reg_page_list_len; + unsigned int max_pi_fast_reg_page_list_len; + u16 max_pkeys; + u8 local_ca_ack_delay; + int sig_prot_cap; + int sig_guard_cap; + struct ib_odp_caps odp_caps; + uint64_t timestamp_mask; + uint64_t hca_core_clock; + struct ib_rss_caps rss_caps; + u32 max_wq_type_rq; + u32 raw_packet_caps; + struct ib_tm_caps tm_caps; + struct ib_cq_caps cq_caps; + u64 max_dm_size; + u32 max_sgl_rd; +}; + +struct rdma_restrack_root; + +struct uapi_definition; + +struct ib_port_data; + +struct ib_device { + struct device *dma_device; + struct ib_device_ops ops; + char name[64]; + struct callback_head callback_head; + struct list_head event_handler_list; + struct rw_semaphore event_handler_rwsem; + spinlock_t qp_open_list_lock; + struct rw_semaphore client_data_rwsem; + struct xarray client_data; + struct mutex unregistration_lock; + rwlock_t cache_lock; + struct ib_port_data *port_data; + int num_comp_vectors; + union { + struct device dev; + struct ib_core_device coredev; + }; + const struct attribute_group *groups[3]; + u64 uverbs_cmd_mask; + u64 uverbs_ex_cmd_mask; + char node_desc[64]; + __be64 node_guid; + u32 local_dma_lkey; + u16 is_switch: 1; + u16 kverbs_provider: 1; + u16 use_cq_dim: 1; + u8 node_type; + u8 phys_port_cnt; + struct ib_device_attr attrs; + struct attribute_group *hw_stats_ag; + struct rdma_hw_stats *hw_stats; + u32 index; + spinlock_t cq_pools_lock; + struct list_head cq_pools[3]; + struct rdma_restrack_root *res; + const struct uapi_definition *driver_def; + refcount_t refcount; + struct completion unreg_completion; + struct work_struct unregistration_work; + const struct rdma_link_ops *link_ops; + struct mutex compat_devs_mutex; + struct xarray compat_devs; + char iw_ifname[16]; + u32 iw_driver_flags; + u32 lag_flags; +}; + +enum ib_signature_type { + IB_SIG_TYPE_NONE = 0, + IB_SIG_TYPE_T10_DIF = 1, +}; + +enum ib_t10_dif_bg_type { + IB_T10DIF_CRC = 0, + IB_T10DIF_CSUM = 1, +}; + +struct ib_t10_dif_domain { + enum ib_t10_dif_bg_type bg_type; + u16 pi_interval; + u16 bg; + u16 app_tag; + u32 ref_tag; + bool ref_remap; + bool app_escape; + bool ref_escape; + u16 apptag_check_mask; +}; + +struct ib_sig_domain { + enum ib_signature_type sig_type; + union { + struct ib_t10_dif_domain dif; + } sig; +}; + +struct ib_sig_attrs { + u8 check_mask; + struct ib_sig_domain mem; + struct ib_sig_domain wire; + int meta_length; +}; + +enum ib_sig_err_type { + IB_SIG_BAD_GUARD = 0, + IB_SIG_BAD_REFTAG = 1, + IB_SIG_BAD_APPTAG = 2, +}; + +struct ib_sig_err { + enum ib_sig_err_type err_type; + u32 expected; + u32 actual; + u64 sig_err_offset; + u32 key; +}; + +enum ib_uverbs_flow_action_esp_keymat { + IB_UVERBS_FLOW_ACTION_ESP_KEYMAT_AES_GCM = 0, +}; + +struct ib_uverbs_flow_action_esp_keymat_aes_gcm { + __u64 iv; + __u32 iv_algo; + __u32 salt; + __u32 icv_len; + __u32 key_len; + __u32 aes_key[8]; +}; + +enum ib_uverbs_flow_action_esp_replay { + IB_UVERBS_FLOW_ACTION_ESP_REPLAY_NONE = 0, + IB_UVERBS_FLOW_ACTION_ESP_REPLAY_BMP = 1, +}; + +struct ib_uverbs_flow_action_esp_replay_bmp { + __u32 size; +}; + +union ib_gid { + u8 raw[16]; + struct { + __be64 subnet_prefix; + __be64 interface_id; + } global; +}; + +enum ib_gid_type { + IB_GID_TYPE_IB = 0, + IB_GID_TYPE_ROCE = 1, + IB_GID_TYPE_ROCE_UDP_ENCAP = 2, + IB_GID_TYPE_SIZE = 3, +}; + +struct ib_gid_attr { + struct net_device *ndev; + struct ib_device *device; + union ib_gid gid; + enum ib_gid_type gid_type; + u16 index; + u8 port_num; +}; + +struct ib_cq_init_attr { + unsigned int cqe; + u32 comp_vector; + u32 flags; +}; + +struct ib_dm_mr_attr { + u64 length; + u64 offset; + u32 access_flags; +}; + +struct ib_dm_alloc_attr { + u64 length; + u32 alignment; + u32 flags; +}; + +enum ib_mtu { + IB_MTU_256 = 1, + IB_MTU_512 = 2, + IB_MTU_1024 = 3, + IB_MTU_2048 = 4, + IB_MTU_4096 = 5, +}; + +enum ib_port_state { + IB_PORT_NOP = 0, + IB_PORT_DOWN = 1, + IB_PORT_INIT = 2, + IB_PORT_ARMED = 3, + IB_PORT_ACTIVE = 4, + IB_PORT_ACTIVE_DEFER = 5, +}; + +struct ib_port_attr { + u64 subnet_prefix; + enum ib_port_state state; + enum ib_mtu max_mtu; + enum ib_mtu active_mtu; + u32 phys_mtu; + int gid_tbl_len; + unsigned int ip_gids: 1; + u32 port_cap_flags; + u32 max_msg_sz; + u32 bad_pkey_cntr; + u32 qkey_viol_cntr; + u16 pkey_tbl_len; + u32 sm_lid; + u32 lid; + u8 lmc; + u8 max_vl_num; + u8 sm_sl; + u8 subnet_timeout; + u8 init_type_reply; + u8 active_width; + u16 active_speed; + u8 phys_state; + u16 port_cap_flags2; +}; + +struct ib_device_modify { + u64 sys_image_guid; + char node_desc[64]; +}; + +struct ib_port_modify { + u32 set_port_cap_mask; + u32 clr_port_cap_mask; + u8 init_type; +}; + +enum ib_event_type { + IB_EVENT_CQ_ERR = 0, + IB_EVENT_QP_FATAL = 1, + IB_EVENT_QP_REQ_ERR = 2, + IB_EVENT_QP_ACCESS_ERR = 3, + IB_EVENT_COMM_EST = 4, + IB_EVENT_SQ_DRAINED = 5, + IB_EVENT_PATH_MIG = 6, + IB_EVENT_PATH_MIG_ERR = 7, + IB_EVENT_DEVICE_FATAL = 8, + IB_EVENT_PORT_ACTIVE = 9, + IB_EVENT_PORT_ERR = 10, + IB_EVENT_LID_CHANGE = 11, + IB_EVENT_PKEY_CHANGE = 12, + IB_EVENT_SM_CHANGE = 13, + IB_EVENT_SRQ_ERR = 14, + IB_EVENT_SRQ_LIMIT_REACHED = 15, + IB_EVENT_QP_LAST_WQE_REACHED = 16, + IB_EVENT_CLIENT_REREGISTER = 17, + IB_EVENT_GID_CHANGE = 18, + IB_EVENT_WQ_FATAL = 19, +}; + +struct ib_ucq_object; + +typedef void (*ib_comp_handler)(struct ib_cq *, void *); + +struct ib_event; + +struct ib_cq { + struct ib_device *device; + struct ib_ucq_object *uobject; + ib_comp_handler comp_handler; + void (*event_handler)(struct ib_event *, void *); + void *cq_context; + int cqe; + unsigned int cqe_used; + atomic_t usecnt; + enum ib_poll_context poll_ctx; + struct ib_wc *wc; + struct list_head pool_entry; + union { + struct irq_poll iop; + struct work_struct work; + }; + struct workqueue_struct *comp_wq; + struct dim *dim; + ktime_t timestamp; + u8 interrupt: 1; + u8 shared: 1; + unsigned int comp_vector; + struct rdma_restrack_entry res; +}; + +struct ib_uqp_object; + +enum ib_qp_type { + IB_QPT_SMI = 0, + IB_QPT_GSI = 1, + IB_QPT_RC = 2, + IB_QPT_UC = 3, + IB_QPT_UD = 4, + IB_QPT_RAW_IPV6 = 5, + IB_QPT_RAW_ETHERTYPE = 6, + IB_QPT_RAW_PACKET = 8, + IB_QPT_XRC_INI = 9, + IB_QPT_XRC_TGT = 10, + IB_QPT_MAX = 11, + IB_QPT_DRIVER = 255, + IB_QPT_RESERVED1 = 4096, + IB_QPT_RESERVED2 = 4097, + IB_QPT_RESERVED3 = 4098, + IB_QPT_RESERVED4 = 4099, + IB_QPT_RESERVED5 = 4100, + IB_QPT_RESERVED6 = 4101, + IB_QPT_RESERVED7 = 4102, + IB_QPT_RESERVED8 = 4103, + IB_QPT_RESERVED9 = 4104, + IB_QPT_RESERVED10 = 4105, +}; + +struct ib_qp_security; + +struct ib_qp { + struct ib_device *device; + struct ib_pd *pd; + struct ib_cq *send_cq; + struct ib_cq *recv_cq; + spinlock_t mr_lock; + int mrs_used; + struct list_head rdma_mrs; + struct list_head sig_mrs; + struct ib_srq *srq; + struct ib_xrcd *xrcd; + struct list_head xrcd_list; + atomic_t usecnt; + struct list_head open_list; + struct ib_qp *real_qp; + struct ib_uqp_object *uobject; + void (*event_handler)(struct ib_event *, void *); + void *qp_context; + const struct ib_gid_attr *av_sgid_attr; + const struct ib_gid_attr *alt_path_sgid_attr; + u32 qp_num; + u32 max_write_sge; + u32 max_read_sge; + enum ib_qp_type qp_type; + struct ib_rwq_ind_table *rwq_ind_tbl; + struct ib_qp_security *qp_sec; + u8 port; + bool integrity_en; + struct rdma_restrack_entry res; + struct rdma_counter *counter; +}; + +struct ib_usrq_object; + +enum ib_srq_type { + IB_SRQT_BASIC = 0, + IB_SRQT_XRC = 1, + IB_SRQT_TM = 2, +}; + +struct ib_srq { + struct ib_device *device; + struct ib_pd *pd; + struct ib_usrq_object *uobject; + void (*event_handler)(struct ib_event *, void *); + void *srq_context; + enum ib_srq_type srq_type; + atomic_t usecnt; + struct { + struct ib_cq *cq; + union { + struct { + struct ib_xrcd *xrcd; + u32 srq_num; + } xrc; + }; + } ext; +}; + +struct ib_uwq_object; + +enum ib_wq_state { + IB_WQS_RESET = 0, + IB_WQS_RDY = 1, + IB_WQS_ERR = 2, +}; + +enum ib_wq_type { + IB_WQT_RQ = 0, +}; + +struct ib_wq { + struct ib_device *device; + struct ib_uwq_object *uobject; + void *wq_context; + void (*event_handler)(struct ib_event *, void *); + struct ib_pd *pd; + struct ib_cq *cq; + u32 wq_num; + enum ib_wq_state state; + enum ib_wq_type wq_type; + atomic_t usecnt; +}; + +struct ib_event { + struct ib_device *device; + union { + struct ib_cq *cq; + struct ib_qp *qp; + struct ib_srq *srq; + struct ib_wq *wq; + u8 port_num; + } element; + enum ib_event_type event; +}; + +struct ib_global_route { + const struct ib_gid_attr *sgid_attr; + union ib_gid dgid; + u32 flow_label; + u8 sgid_index; + u8 hop_limit; + u8 traffic_class; +}; + +struct ib_grh { + __be32 version_tclass_flow; + __be16 paylen; + u8 next_hdr; + u8 hop_limit; + union ib_gid sgid; + union ib_gid dgid; +}; + +struct ib_mr_status { + u32 fail_status; + struct ib_sig_err sig_err; +}; + +struct rdma_ah_init_attr { + struct rdma_ah_attr *ah_attr; + u32 flags; + struct net_device *xmit_slave; +}; + +enum rdma_ah_attr_type { + RDMA_AH_ATTR_TYPE_UNDEFINED = 0, + RDMA_AH_ATTR_TYPE_IB = 1, + RDMA_AH_ATTR_TYPE_ROCE = 2, + RDMA_AH_ATTR_TYPE_OPA = 3, +}; + +struct ib_ah_attr { + u16 dlid; + u8 src_path_bits; +}; + +struct roce_ah_attr { + u8 dmac[6]; +}; + +struct opa_ah_attr { + u32 dlid; + u8 src_path_bits; + bool make_grd; +}; + +struct rdma_ah_attr { + struct ib_global_route grh; + u8 sl; + u8 static_rate; + u8 port_num; + u8 ah_flags; + enum rdma_ah_attr_type type; + union { + struct ib_ah_attr ib; + struct roce_ah_attr roce; + struct opa_ah_attr opa; + }; +}; + +enum ib_wc_status { + IB_WC_SUCCESS = 0, + IB_WC_LOC_LEN_ERR = 1, + IB_WC_LOC_QP_OP_ERR = 2, + IB_WC_LOC_EEC_OP_ERR = 3, + IB_WC_LOC_PROT_ERR = 4, + IB_WC_WR_FLUSH_ERR = 5, + IB_WC_MW_BIND_ERR = 6, + IB_WC_BAD_RESP_ERR = 7, + IB_WC_LOC_ACCESS_ERR = 8, + IB_WC_REM_INV_REQ_ERR = 9, + IB_WC_REM_ACCESS_ERR = 10, + IB_WC_REM_OP_ERR = 11, + IB_WC_RETRY_EXC_ERR = 12, + IB_WC_RNR_RETRY_EXC_ERR = 13, + IB_WC_LOC_RDD_VIOL_ERR = 14, + IB_WC_REM_INV_RD_REQ_ERR = 15, + IB_WC_REM_ABORT_ERR = 16, + IB_WC_INV_EECN_ERR = 17, + IB_WC_INV_EEC_STATE_ERR = 18, + IB_WC_FATAL_ERR = 19, + IB_WC_RESP_TIMEOUT_ERR = 20, + IB_WC_GENERAL_ERR = 21, +}; + +enum ib_wc_opcode { + IB_WC_SEND = 0, + IB_WC_RDMA_WRITE = 1, + IB_WC_RDMA_READ = 2, + IB_WC_COMP_SWAP = 3, + IB_WC_FETCH_ADD = 4, + IB_WC_BIND_MW = 5, + IB_WC_LOCAL_INV = 6, + IB_WC_LSO = 7, + IB_WC_REG_MR = 8, + IB_WC_MASKED_COMP_SWAP = 9, + IB_WC_MASKED_FETCH_ADD = 10, + IB_WC_RECV = 128, + IB_WC_RECV_RDMA_WITH_IMM = 129, +}; + +struct ib_cqe { + void (*done)(struct ib_cq *, struct ib_wc *); +}; + +struct ib_wc { + union { + u64 wr_id; + struct ib_cqe *wr_cqe; + }; + enum ib_wc_status status; + enum ib_wc_opcode opcode; + u32 vendor_err; + u32 byte_len; + struct ib_qp *qp; + union { + __be32 imm_data; + u32 invalidate_rkey; + } ex; + u32 src_qp; + u32 slid; + int wc_flags; + u16 pkey_index; + u8 sl; + u8 dlid_path_bits; + u8 port_num; + u8 smac[6]; + u16 vlan_id; + u8 network_hdr_type; +}; + +struct ib_srq_attr { + u32 max_wr; + u32 max_sge; + u32 srq_limit; +}; + +struct ib_xrcd { + struct ib_device *device; + atomic_t usecnt; + struct inode *inode; + struct rw_semaphore tgt_qps_rwsem; + struct xarray tgt_qps; +}; + +struct ib_srq_init_attr { + void (*event_handler)(struct ib_event *, void *); + void *srq_context; + struct ib_srq_attr attr; + enum ib_srq_type srq_type; + struct { + struct ib_cq *cq; + union { + struct { + struct ib_xrcd *xrcd; + } xrc; + struct { + u32 max_num_tags; + } tag_matching; + }; + } ext; +}; + +struct ib_qp_cap { + u32 max_send_wr; + u32 max_recv_wr; + u32 max_send_sge; + u32 max_recv_sge; + u32 max_inline_data; + u32 max_rdma_ctxs; +}; + +enum ib_sig_type { + IB_SIGNAL_ALL_WR = 0, + IB_SIGNAL_REQ_WR = 1, +}; + +struct ib_qp_init_attr { + void (*event_handler)(struct ib_event *, void *); + void *qp_context; + struct ib_cq *send_cq; + struct ib_cq *recv_cq; + struct ib_srq *srq; + struct ib_xrcd *xrcd; + struct ib_qp_cap cap; + enum ib_sig_type sq_sig_type; + enum ib_qp_type qp_type; + u32 create_flags; + u8 port_num; + struct ib_rwq_ind_table *rwq_ind_tbl; + u32 source_qpn; +}; + +struct ib_uobject; + +struct ib_rwq_ind_table { + struct ib_device *device; + struct ib_uobject *uobject; + atomic_t usecnt; + u32 ind_tbl_num; + u32 log_ind_tbl_size; + struct ib_wq **ind_tbl; +}; + +enum ib_qp_state { + IB_QPS_RESET = 0, + IB_QPS_INIT = 1, + IB_QPS_RTR = 2, + IB_QPS_RTS = 3, + IB_QPS_SQD = 4, + IB_QPS_SQE = 5, + IB_QPS_ERR = 6, +}; + +enum ib_mig_state { + IB_MIG_MIGRATED = 0, + IB_MIG_REARM = 1, + IB_MIG_ARMED = 2, +}; + +enum ib_mw_type { + IB_MW_TYPE_1 = 1, + IB_MW_TYPE_2 = 2, +}; + +struct ib_qp_attr { + enum ib_qp_state qp_state; + enum ib_qp_state cur_qp_state; + enum ib_mtu path_mtu; + enum ib_mig_state path_mig_state; + u32 qkey; + u32 rq_psn; + u32 sq_psn; + u32 dest_qp_num; + int qp_access_flags; + struct ib_qp_cap cap; + struct rdma_ah_attr ah_attr; + struct rdma_ah_attr alt_ah_attr; + u16 pkey_index; + u16 alt_pkey_index; + u8 en_sqd_async_notify; + u8 sq_draining; + u8 max_rd_atomic; + u8 max_dest_rd_atomic; + u8 min_rnr_timer; + u8 port_num; + u8 timeout; + u8 retry_cnt; + u8 rnr_retry; + u8 alt_port_num; + u8 alt_timeout; + u32 rate_limit; + struct net_device *xmit_slave; +}; + +enum ib_wr_opcode { + IB_WR_RDMA_WRITE = 0, + IB_WR_RDMA_WRITE_WITH_IMM = 1, + IB_WR_SEND = 2, + IB_WR_SEND_WITH_IMM = 3, + IB_WR_RDMA_READ = 4, + IB_WR_ATOMIC_CMP_AND_SWP = 5, + IB_WR_ATOMIC_FETCH_AND_ADD = 6, + IB_WR_BIND_MW = 8, + IB_WR_LSO = 10, + IB_WR_SEND_WITH_INV = 9, + IB_WR_RDMA_READ_WITH_INV = 11, + IB_WR_LOCAL_INV = 7, + IB_WR_MASKED_ATOMIC_CMP_AND_SWP = 12, + IB_WR_MASKED_ATOMIC_FETCH_AND_ADD = 13, + IB_WR_REG_MR = 32, + IB_WR_REG_MR_INTEGRITY = 33, + IB_WR_RESERVED1 = 240, + IB_WR_RESERVED2 = 241, + IB_WR_RESERVED3 = 242, + IB_WR_RESERVED4 = 243, + IB_WR_RESERVED5 = 244, + IB_WR_RESERVED6 = 245, + IB_WR_RESERVED7 = 246, + IB_WR_RESERVED8 = 247, + IB_WR_RESERVED9 = 248, + IB_WR_RESERVED10 = 249, +}; + +struct ib_sge { + u64 addr; + u32 length; + u32 lkey; +}; + +struct ib_send_wr { + struct ib_send_wr *next; + union { + u64 wr_id; + struct ib_cqe *wr_cqe; + }; + struct ib_sge *sg_list; + int num_sge; + enum ib_wr_opcode opcode; + int send_flags; + union { + __be32 imm_data; + u32 invalidate_rkey; + } ex; +}; + +struct ib_ah { + struct ib_device *device; + struct ib_pd *pd; + struct ib_uobject *uobject; + const struct ib_gid_attr *sgid_attr; + enum rdma_ah_attr_type type; +}; + +struct ib_mr { + struct ib_device *device; + struct ib_pd *pd; + u32 lkey; + u32 rkey; + u64 iova; + u64 length; + unsigned int page_size; + enum ib_mr_type type; + bool need_inval; + union { + struct ib_uobject *uobject; + struct list_head qp_entry; + }; + struct ib_dm *dm; + struct ib_sig_attrs *sig_attrs; + struct rdma_restrack_entry res; +}; + +struct ib_recv_wr { + struct ib_recv_wr *next; + union { + u64 wr_id; + struct ib_cqe *wr_cqe; + }; + struct ib_sge *sg_list; + int num_sge; +}; + +struct ib_rdmacg_object {}; + +struct ib_uverbs_file; + +struct ib_ucontext { + struct ib_device *device; + struct ib_uverbs_file *ufile; + bool cleanup_retryable; + struct ib_rdmacg_object cg_obj; + struct rdma_restrack_entry res; + struct xarray mmap_xa; +}; + +struct uverbs_api_object; + +struct ib_uobject { + u64 user_handle; + struct ib_uverbs_file *ufile; + struct ib_ucontext *context; + void *object; + struct list_head list; + struct ib_rdmacg_object cg_obj; + int id; + struct kref ref; + atomic_t usecnt; + struct callback_head rcu; + const struct uverbs_api_object *uapi_object; +}; + +struct ib_udata { + const void *inbuf; + void *outbuf; + size_t inlen; + size_t outlen; +}; + +struct ib_pd { + u32 local_dma_lkey; + u32 flags; + struct ib_device *device; + struct ib_uobject *uobject; + atomic_t usecnt; + u32 unsafe_global_rkey; + struct ib_mr *__internal_mr; + struct rdma_restrack_entry res; +}; + +struct ib_wq_init_attr { + void *wq_context; + enum ib_wq_type wq_type; + u32 max_wr; + u32 max_sge; + struct ib_cq *cq; + void (*event_handler)(struct ib_event *, void *); + u32 create_flags; +}; + +struct ib_wq_attr { + enum ib_wq_state wq_state; + enum ib_wq_state curr_wq_state; + u32 flags; + u32 flags_mask; +}; + +struct ib_rwq_ind_table_init_attr { + u32 log_ind_tbl_size; + struct ib_wq **ind_tbl; +}; + +enum port_pkey_state { + IB_PORT_PKEY_NOT_VALID = 0, + IB_PORT_PKEY_VALID = 1, + IB_PORT_PKEY_LISTED = 2, +}; + +struct ib_port_pkey { + enum port_pkey_state state; + u16 pkey_index; + u8 port_num; + struct list_head qp_list; + struct list_head to_error_list; + struct ib_qp_security *sec; +}; + +struct ib_ports_pkeys; + +struct ib_qp_security { + struct ib_qp *qp; + struct ib_device *dev; + struct mutex mutex; + struct ib_ports_pkeys *ports_pkeys; + struct list_head shared_qp_list; + void *security; + bool destroying; + atomic_t error_list_count; + struct completion error_complete; + int error_comps_pending; +}; + +struct ib_ports_pkeys { + struct ib_port_pkey main; + struct ib_port_pkey alt; +}; + +struct ib_dm { + struct ib_device *device; + u32 length; + u32 flags; + struct ib_uobject *uobject; + atomic_t usecnt; +}; + +struct ib_mw { + struct ib_device *device; + struct ib_pd *pd; + struct ib_uobject *uobject; + u32 rkey; + enum ib_mw_type type; +}; + +enum ib_flow_attr_type { + IB_FLOW_ATTR_NORMAL = 0, + IB_FLOW_ATTR_ALL_DEFAULT = 1, + IB_FLOW_ATTR_MC_DEFAULT = 2, + IB_FLOW_ATTR_SNIFFER = 3, +}; + +enum ib_flow_spec_type { + IB_FLOW_SPEC_ETH = 32, + IB_FLOW_SPEC_IB = 34, + IB_FLOW_SPEC_IPV4 = 48, + IB_FLOW_SPEC_IPV6 = 49, + IB_FLOW_SPEC_ESP = 52, + IB_FLOW_SPEC_TCP = 64, + IB_FLOW_SPEC_UDP = 65, + IB_FLOW_SPEC_VXLAN_TUNNEL = 80, + IB_FLOW_SPEC_GRE = 81, + IB_FLOW_SPEC_MPLS = 96, + IB_FLOW_SPEC_INNER = 256, + IB_FLOW_SPEC_ACTION_TAG = 4096, + IB_FLOW_SPEC_ACTION_DROP = 4097, + IB_FLOW_SPEC_ACTION_HANDLE = 4098, + IB_FLOW_SPEC_ACTION_COUNT = 4099, +}; + +struct ib_flow_eth_filter { + u8 dst_mac[6]; + u8 src_mac[6]; + __be16 ether_type; + __be16 vlan_tag; + u8 real_sz[0]; +}; + +struct ib_flow_spec_eth { + u32 type; + u16 size; + struct ib_flow_eth_filter val; + struct ib_flow_eth_filter mask; +}; + +struct ib_flow_ib_filter { + __be16 dlid; + __u8 sl; + u8 real_sz[0]; +}; + +struct ib_flow_spec_ib { + u32 type; + u16 size; + struct ib_flow_ib_filter val; + struct ib_flow_ib_filter mask; +}; + +struct ib_flow_ipv4_filter { + __be32 src_ip; + __be32 dst_ip; + u8 proto; + u8 tos; + u8 ttl; + u8 flags; + u8 real_sz[0]; +}; + +struct ib_flow_spec_ipv4 { + u32 type; + u16 size; + struct ib_flow_ipv4_filter val; + struct ib_flow_ipv4_filter mask; +}; + +struct ib_flow_ipv6_filter { + u8 src_ip[16]; + u8 dst_ip[16]; + __be32 flow_label; + u8 next_hdr; + u8 traffic_class; + u8 hop_limit; + u8 real_sz[0]; +}; + +struct ib_flow_spec_ipv6 { + u32 type; + u16 size; + struct ib_flow_ipv6_filter val; + struct ib_flow_ipv6_filter mask; +}; + +struct ib_flow_tcp_udp_filter { + __be16 dst_port; + __be16 src_port; + u8 real_sz[0]; +}; + +struct ib_flow_spec_tcp_udp { + u32 type; + u16 size; + struct ib_flow_tcp_udp_filter val; + struct ib_flow_tcp_udp_filter mask; +}; + +struct ib_flow_tunnel_filter { + __be32 tunnel_id; + u8 real_sz[0]; +}; + +struct ib_flow_spec_tunnel { + u32 type; + u16 size; + struct ib_flow_tunnel_filter val; + struct ib_flow_tunnel_filter mask; +}; + +struct ib_flow_esp_filter { + __be32 spi; + __be32 seq; + u8 real_sz[0]; +}; + +struct ib_flow_spec_esp { + u32 type; + u16 size; + struct ib_flow_esp_filter val; + struct ib_flow_esp_filter mask; +}; + +struct ib_flow_gre_filter { + __be16 c_ks_res0_ver; + __be16 protocol; + __be32 key; + u8 real_sz[0]; +}; + +struct ib_flow_spec_gre { + u32 type; + u16 size; + struct ib_flow_gre_filter val; + struct ib_flow_gre_filter mask; +}; + +struct ib_flow_mpls_filter { + __be32 tag; + u8 real_sz[0]; +}; + +struct ib_flow_spec_mpls { + u32 type; + u16 size; + struct ib_flow_mpls_filter val; + struct ib_flow_mpls_filter mask; +}; + +struct ib_flow_spec_action_tag { + enum ib_flow_spec_type type; + u16 size; + u32 tag_id; +}; + +struct ib_flow_spec_action_drop { + enum ib_flow_spec_type type; + u16 size; +}; + +struct ib_flow_spec_action_handle { + enum ib_flow_spec_type type; + u16 size; + struct ib_flow_action *act; +}; + +enum ib_flow_action_type { + IB_FLOW_ACTION_UNSPECIFIED = 0, + IB_FLOW_ACTION_ESP = 1, +}; + +struct ib_flow_action { + struct ib_device *device; + struct ib_uobject *uobject; + enum ib_flow_action_type type; + atomic_t usecnt; +}; + +struct ib_flow_spec_action_count { + enum ib_flow_spec_type type; + u16 size; + struct ib_counters *counters; +}; + +struct ib_counters { + struct ib_device *device; + struct ib_uobject *uobject; + atomic_t usecnt; +}; + +union ib_flow_spec { + struct { + u32 type; + u16 size; + }; + struct ib_flow_spec_eth eth; + struct ib_flow_spec_ib ib; + struct ib_flow_spec_ipv4 ipv4; + struct ib_flow_spec_tcp_udp tcp_udp; + struct ib_flow_spec_ipv6 ipv6; + struct ib_flow_spec_tunnel tunnel; + struct ib_flow_spec_esp esp; + struct ib_flow_spec_gre gre; + struct ib_flow_spec_mpls mpls; + struct ib_flow_spec_action_tag flow_tag; + struct ib_flow_spec_action_drop drop; + struct ib_flow_spec_action_handle action; + struct ib_flow_spec_action_count flow_count; +}; + +struct ib_flow_attr { + enum ib_flow_attr_type type; + u16 size; + u16 priority; + u32 flags; + u8 num_of_specs; + u8 port; + union ib_flow_spec flows[0]; +}; + +struct ib_flow { + struct ib_qp *qp; + struct ib_device *device; + struct ib_uobject *uobject; +}; + +struct ib_flow_action_attrs_esp_keymats { + enum ib_uverbs_flow_action_esp_keymat protocol; + union { + struct ib_uverbs_flow_action_esp_keymat_aes_gcm aes_gcm; + } keymat; +}; + +struct ib_flow_action_attrs_esp_replays { + enum ib_uverbs_flow_action_esp_replay protocol; + union { + struct ib_uverbs_flow_action_esp_replay_bmp bmp; + } replay; +}; + +struct ib_flow_spec_list { + struct ib_flow_spec_list *next; + union ib_flow_spec spec; +}; + +struct ib_flow_action_attrs_esp { + struct ib_flow_action_attrs_esp_keymats *keymat; + struct ib_flow_action_attrs_esp_replays *replay; + struct ib_flow_spec_list *encap; + u32 esn; + u32 spi; + u32 seq; + u32 tfc_pad; + u64 flags; + u64 hard_limit_pkts; +}; + +struct ib_pkey_cache; + +struct ib_gid_table; + +struct ib_port_cache { + u64 subnet_prefix; + struct ib_pkey_cache *pkey; + struct ib_gid_table *gid; + u8 lmc; + enum ib_port_state port_state; +}; + +struct ib_port_immutable { + int pkey_tbl_len; + int gid_tbl_len; + u32 core_cap_flags; + u32 max_mad_size; +}; + +struct ib_port_data { + struct ib_device *ib_dev; + struct ib_port_immutable immutable; + spinlock_t pkey_list_lock; + struct list_head pkey_list; + struct ib_port_cache cache; + spinlock_t netdev_lock; + struct net_device *netdev; + struct hlist_node ndev_hash_link; + struct rdma_port_counter port_counter; + struct rdma_hw_stats *hw_stats; +}; + +struct rdma_netdev_alloc_params { + size_t sizeof_priv; + unsigned int txqs; + unsigned int rxqs; + void *param; + int (*initialize_rdma_netdev)(struct ib_device *, u8, struct net_device *, void *); +}; + +struct ib_counters_read_attr { + u64 *counters_buff; + u32 ncounters; + u32 flags; +}; + +struct rdma_user_mmap_entry { + struct kref ref; + struct ib_ucontext *ucontext; + long unsigned int start_pgoff; + size_t npages; + bool driver_removed; +}; + +struct show_busy_params { + struct seq_file *m; + struct blk_mq_hw_ctx *hctx; +}; + +typedef void (*swap_func_t)(void *, void *, int); + +typedef int (*cmp_r_func_t)(const void *, const void *, const void *); + +struct siprand_state { + long unsigned int v0; + long unsigned int v1; + long unsigned int v2; + long unsigned int v3; +}; + +typedef __kernel_long_t __kernel_ptrdiff_t; + +typedef __kernel_ptrdiff_t ptrdiff_t; + +struct region { + unsigned int start; + unsigned int off; + unsigned int group_len; + unsigned int end; +}; + +enum { + REG_OP_ISFREE = 0, + REG_OP_ALLOC = 1, + REG_OP_RELEASE = 2, +}; + +typedef struct scatterlist *sg_alloc_fn(unsigned int, gfp_t); + +typedef void sg_free_fn(struct scatterlist *, unsigned int); + +struct sg_page_iter { + struct scatterlist *sg; + unsigned int sg_pgoffset; + unsigned int __nents; + int __pg_advance; +}; + +struct sg_dma_page_iter { + struct sg_page_iter base; +}; + +struct sg_mapping_iter { + struct page *page; + void *addr; + size_t length; + size_t consumed; + struct sg_page_iter piter; + unsigned int __offset; + unsigned int __remaining; + unsigned int __flags; +}; + +typedef int (*cmp_func)(void *, const struct list_head *, const struct list_head *); + +struct rhltable { + struct rhashtable ht; +}; + +struct rhashtable_walker { + struct list_head list; + struct bucket_table *tbl; +}; + +struct rhashtable_iter { + struct rhashtable *ht; + struct rhash_head *p; + struct rhlist_head *list; + struct rhashtable_walker walker; + unsigned int slot; + unsigned int skip; + bool end_of_table; +}; + +union nested_table { + union nested_table *table; + struct rhash_lock_head *bucket; +}; + +struct once_work { + struct work_struct work; + struct static_key_true *key; +}; + +struct genradix_iter { + size_t offset; + size_t pos; +}; + +struct genradix_node { + union { + struct genradix_node *children[512]; + u8 data[4096]; + }; +}; + +struct reciprocal_value_adv { + u32 m; + u8 sh; + u8 exp; + bool is_wide_m; +}; + +struct arc4_ctx { + u32 S[256]; + u32 x; + u32 y; +}; + +enum devm_ioremap_type { + DEVM_IOREMAP = 0, + DEVM_IOREMAP_UC = 1, + DEVM_IOREMAP_WC = 2, +}; + +struct pcim_iomap_devres { + void *table[6]; +}; + +enum assoc_array_walk_status { + assoc_array_walk_tree_empty = 0, + assoc_array_walk_found_terminal_node = 1, + assoc_array_walk_found_wrong_shortcut = 2, +}; + +struct assoc_array_walk_result { + struct { + struct assoc_array_node *node; + int level; + int slot; + } terminal_node; + struct { + struct assoc_array_shortcut *shortcut; + int level; + int sc_level; + long unsigned int sc_segments; + long unsigned int dissimilarity; + } wrong_shortcut; +}; + +struct assoc_array_delete_collapse_context { + struct assoc_array_node *node; + const void *skip_leaf; + int slot; +}; + +struct xxh32_state { + uint32_t total_len_32; + uint32_t large_len; + uint32_t v1; + uint32_t v2; + uint32_t v3; + uint32_t v4; + uint32_t mem32[4]; + uint32_t memsize; +}; + +struct gen_pool_chunk { + struct list_head next_chunk; + atomic_long_t avail; + phys_addr_t phys_addr; + void *owner; + long unsigned int start_addr; + long unsigned int end_addr; + long unsigned int bits[0]; +}; + +struct genpool_data_align { + int align; +}; + +struct genpool_data_fixed { + long unsigned int offset; +}; + +typedef z_stream *z_streamp; + +typedef struct { + unsigned char op; + unsigned char bits; + short unsigned int val; +} code; + +typedef enum { + HEAD = 0, + FLAGS = 1, + TIME = 2, + OS = 3, + EXLEN = 4, + EXTRA = 5, + NAME = 6, + COMMENT = 7, + HCRC = 8, + DICTID = 9, + DICT = 10, + TYPE = 11, + TYPEDO = 12, + STORED = 13, + COPY = 14, + TABLE = 15, + LENLENS = 16, + CODELENS = 17, + LEN = 18, + LENEXT = 19, + DIST = 20, + DISTEXT = 21, + MATCH = 22, + LIT = 23, + CHECK = 24, + LENGTH = 25, + DONE = 26, + BAD = 27, + MEM = 28, + SYNC = 29, +} inflate_mode; + +struct inflate_state { + inflate_mode mode; + int last; + int wrap; + int havedict; + int flags; + unsigned int dmax; + long unsigned int check; + long unsigned int total; + unsigned int wbits; + unsigned int wsize; + unsigned int whave; + unsigned int write; + unsigned char *window; + long unsigned int hold; + unsigned int bits; + unsigned int length; + unsigned int offset; + unsigned int extra; + const code *lencode; + const code *distcode; + unsigned int lenbits; + unsigned int distbits; + unsigned int ncode; + unsigned int nlen; + unsigned int ndist; + unsigned int have; + code *next; + short unsigned int lens[320]; + short unsigned int work[288]; + code codes[2048]; +}; + +union uu { + short unsigned int us; + unsigned char b[2]; +}; + +typedef unsigned int uInt; + +struct inflate_workspace { + struct inflate_state inflate_state; + unsigned char working_window[32768]; +}; + +typedef enum { + CODES = 0, + LENS = 1, + DISTS = 2, +} codetype; + +typedef unsigned char uch; + +typedef short unsigned int ush; + +typedef long unsigned int ulg; + +struct ct_data_s { + union { + ush freq; + ush code; + } fc; + union { + ush dad; + ush len; + } dl; +}; + +typedef struct ct_data_s ct_data; + +struct static_tree_desc_s { + const ct_data *static_tree; + const int *extra_bits; + int extra_base; + int elems; + int max_length; +}; + +typedef struct static_tree_desc_s static_tree_desc; + +struct tree_desc_s { + ct_data *dyn_tree; + int max_code; + static_tree_desc *stat_desc; +}; + +typedef ush Pos; + +typedef unsigned int IPos; + +struct deflate_state { + z_streamp strm; + int status; + Byte *pending_buf; + ulg pending_buf_size; + Byte *pending_out; + int pending; + int noheader; + Byte data_type; + Byte method; + int last_flush; + uInt w_size; + uInt w_bits; + uInt w_mask; + Byte *window; + ulg window_size; + Pos *prev; + Pos *head; + uInt ins_h; + uInt hash_size; + uInt hash_bits; + uInt hash_mask; + uInt hash_shift; + long int block_start; + uInt match_length; + IPos prev_match; + int match_available; + uInt strstart; + uInt match_start; + uInt lookahead; + uInt prev_length; + uInt max_chain_length; + uInt max_lazy_match; + int level; + int strategy; + uInt good_match; + int nice_match; + struct ct_data_s dyn_ltree[573]; + struct ct_data_s dyn_dtree[61]; + struct ct_data_s bl_tree[39]; + struct tree_desc_s l_desc; + struct tree_desc_s d_desc; + struct tree_desc_s bl_desc; + ush bl_count[16]; + int heap[573]; + int heap_len; + int heap_max; + uch depth[573]; + uch *l_buf; + uInt lit_bufsize; + uInt last_lit; + ush *d_buf; + ulg opt_len; + ulg static_len; + ulg compressed_len; + uInt matches; + int last_eob_len; + ush bi_buf; + int bi_valid; +}; + +typedef struct deflate_state deflate_state; + +typedef enum { + need_more = 0, + block_done = 1, + finish_started = 2, + finish_done = 3, +} block_state; + +typedef block_state (*compress_func)(deflate_state *, int); + +struct deflate_workspace { + deflate_state deflate_memory; + Byte *window_memory; + Pos *prev_memory; + Pos *head_memory; + char *overlay_memory; +}; + +typedef struct deflate_workspace deflate_workspace; + +struct config_s { + ush good_length; + ush max_lazy; + ush nice_length; + ush max_chain; + compress_func func; +}; + +typedef struct config_s config; + +typedef struct tree_desc_s tree_desc; + +typedef struct { + const uint8_t *externalDict; + size_t extDictSize; + const uint8_t *prefixEnd; + size_t prefixSize; +} LZ4_streamDecode_t_internal; + +typedef union { + long long unsigned int table[4]; + LZ4_streamDecode_t_internal internal_donotuse; +} LZ4_streamDecode_t; + +typedef uint8_t BYTE; + +typedef uint16_t U16; + +typedef uint32_t U32; + +typedef uint64_t U64; + +typedef uintptr_t uptrval; + +typedef enum { + noDict = 0, + withPrefix64k = 1, + usingExtDict = 2, +} dict_directive; + +typedef enum { + endOnOutputSize = 0, + endOnInputSize = 1, +} endCondition_directive; + +typedef enum { + decode_full_block = 0, + partial_decode = 1, +} earlyEnd_directive; + +typedef struct { + size_t bitContainer; + int bitPos; + char *startPtr; + char *ptr; + char *endPtr; +} BIT_CStream_t; + +typedef unsigned int FSE_CTable; + +typedef struct { + ptrdiff_t value; + const void *stateTable; + const void *symbolTT; + unsigned int stateLog; +} FSE_CState_t; + +typedef struct { + int deltaFindState; + U32 deltaNbBits; +} FSE_symbolCompressionTransform; + +typedef s16 int16_t; + +typedef int16_t S16; + +struct HUF_CElt_s { + U16 val; + BYTE nbBits; +}; + +typedef struct HUF_CElt_s HUF_CElt; + +typedef enum { + HUF_repeat_none = 0, + HUF_repeat_check = 1, + HUF_repeat_valid = 2, +} HUF_repeat; + +struct nodeElt_s { + U32 count; + U16 parent; + BYTE byte; + BYTE nbBits; +}; + +typedef struct nodeElt_s nodeElt; + +typedef struct { + U32 base; + U32 curr; +} rankPos; + +typedef enum { + ZSTDcs_created = 0, + ZSTDcs_init = 1, + ZSTDcs_ongoing = 2, + ZSTDcs_ending = 3, +} ZSTD_compressionStage_e; + +typedef void * (*ZSTD_allocFunction)(void *, size_t); + +typedef void (*ZSTD_freeFunction)(void *, void *); + +typedef struct { + ZSTD_allocFunction customAlloc; + ZSTD_freeFunction customFree; + void *opaque; +} ZSTD_customMem; + +typedef struct { + U32 price; + U32 off; + U32 mlen; + U32 litlen; + U32 rep[3]; +} ZSTD_optimal_t; + +typedef struct { + U32 off; + U32 len; +} ZSTD_match_t; + +struct seqDef_s; + +typedef struct seqDef_s seqDef; + +typedef struct { + seqDef *sequencesStart; + seqDef *sequences; + BYTE *litStart; + BYTE *lit; + BYTE *llCode; + BYTE *mlCode; + BYTE *ofCode; + U32 longLengthID; + U32 longLengthPos; + ZSTD_optimal_t *priceTable; + ZSTD_match_t *matchTable; + U32 *matchLengthFreq; + U32 *litLengthFreq; + U32 *litFreq; + U32 *offCodeFreq; + U32 matchLengthSum; + U32 matchSum; + U32 litLengthSum; + U32 litSum; + U32 offCodeSum; + U32 log2matchLengthSum; + U32 log2matchSum; + U32 log2litLengthSum; + U32 log2litSum; + U32 log2offCodeSum; + U32 factor; + U32 staticPrices; + U32 cachedPrice; + U32 cachedLitLength; + const BYTE *cachedLiterals; +} seqStore_t; + +struct HUF_CElt_s___2; + +typedef struct HUF_CElt_s___2 HUF_CElt___2; + +struct ZSTD_CCtx_s { + const BYTE *nextSrc; + const BYTE *base; + const BYTE *dictBase; + U32 dictLimit; + U32 lowLimit; + U32 nextToUpdate; + U32 nextToUpdate3; + U32 hashLog3; + U32 loadedDictEnd; + U32 forceWindow; + U32 forceRawDict; + ZSTD_compressionStage_e stage; + U32 rep[3]; + U32 repToConfirm[3]; + U32 dictID; + ZSTD_parameters params; + void *workSpace; + size_t workSpaceSize; + size_t blockSize; + U64 frameContentSize; + struct xxh64_state xxhState; + ZSTD_customMem customMem; + seqStore_t seqStore; + U32 *hashTable; + U32 *hashTable3; + U32 *chainTable; + HUF_CElt___2 *hufTable; + U32 flagStaticTables; + HUF_repeat flagStaticHufTable; + FSE_CTable offcodeCTable[187]; + FSE_CTable matchlengthCTable[363]; + FSE_CTable litlengthCTable[329]; + unsigned int tmpCounters[1536]; +}; + +typedef struct ZSTD_CCtx_s ZSTD_CCtx; + +struct ZSTD_CDict_s { + void *dictBuffer; + const void *dictContent; + size_t dictContentSize; + ZSTD_CCtx *refContext; +}; + +typedef struct ZSTD_CDict_s ZSTD_CDict; + +typedef enum { + zcss_init = 0, + zcss_load = 1, + zcss_flush = 2, + zcss_final = 3, +} ZSTD_cStreamStage; + +struct ZSTD_CStream_s___2 { + ZSTD_CCtx *cctx; + ZSTD_CDict *cdictLocal; + const ZSTD_CDict *cdict; + char *inBuff; + size_t inBuffSize; + size_t inToCompress; + size_t inBuffPos; + size_t inBuffTarget; + size_t blockSize; + char *outBuff; + size_t outBuffSize; + size_t outBuffContentSize; + size_t outBuffFlushedSize; + ZSTD_cStreamStage stage; + U32 checksum; + U32 frameEnded; + U64 pledgedSrcSize; + U64 inputProcessed; + ZSTD_parameters params; + ZSTD_customMem customMem; +}; + +typedef struct ZSTD_CStream_s___2 ZSTD_CStream___2; + +typedef int32_t S32; + +typedef enum { + set_basic = 0, + set_rle = 1, + set_compressed = 2, + set_repeat = 3, +} symbolEncodingType_e; + +struct seqDef_s { + U32 offset; + U16 litLength; + U16 matchLength; +}; + +typedef enum { + ZSTDcrp_continue = 0, + ZSTDcrp_noMemset = 1, + ZSTDcrp_fullReset = 2, +} ZSTD_compResetPolicy_e; + +typedef void (*ZSTD_blockCompressor)(ZSTD_CCtx *, const void *, size_t); + +typedef enum { + zsf_gather = 0, + zsf_flush = 1, + zsf_end = 2, +} ZSTD_flush_e; + +typedef size_t (*searchMax_f)(ZSTD_CCtx *, const BYTE *, const BYTE *, size_t *, U32, U32); + +typedef struct { + size_t bitContainer; + unsigned int bitsConsumed; + const char *ptr; + const char *start; +} BIT_DStream_t; + +typedef enum { + BIT_DStream_unfinished = 0, + BIT_DStream_endOfBuffer = 1, + BIT_DStream_completed = 2, + BIT_DStream_overflow = 3, +} BIT_DStream_status; + +typedef unsigned int FSE_DTable; + +typedef struct { + size_t state; + const void *table; +} FSE_DState_t; + +typedef struct { + U16 tableLog; + U16 fastMode; +} FSE_DTableHeader; + +typedef struct { + short unsigned int newState; + unsigned char symbol; + unsigned char nbBits; +} FSE_decode_t; + +typedef struct { + void *ptr; + const void *end; +} ZSTD_stack; + +typedef U32 HUF_DTable; + +typedef struct { + BYTE maxTableLog; + BYTE tableType; + BYTE tableLog; + BYTE reserved; +} DTableDesc; + +typedef struct { + BYTE byte; + BYTE nbBits; +} HUF_DEltX2; + +typedef struct { + U16 sequence; + BYTE nbBits; + BYTE length; +} HUF_DEltX4; + +typedef struct { + BYTE symbol; + BYTE weight; +} sortedSymbol_t; + +typedef U32 rankValCol_t[13]; + +typedef struct { + U32 tableTime; + U32 decode256Time; +} algo_time_t; + +typedef struct { + FSE_DTable LLTable[513]; + FSE_DTable OFTable[257]; + FSE_DTable MLTable[513]; + HUF_DTable hufTable[4097]; + U64 workspace[384]; + U32 rep[3]; +} ZSTD_entropyTables_t; + +typedef struct { + long long unsigned int frameContentSize; + unsigned int windowSize; + unsigned int dictID; + unsigned int checksumFlag; +} ZSTD_frameParams; + +typedef enum { + bt_raw = 0, + bt_rle = 1, + bt_compressed = 2, + bt_reserved = 3, +} blockType_e; + +typedef enum { + ZSTDds_getFrameHeaderSize = 0, + ZSTDds_decodeFrameHeader = 1, + ZSTDds_decodeBlockHeader = 2, + ZSTDds_decompressBlock = 3, + ZSTDds_decompressLastBlock = 4, + ZSTDds_checkChecksum = 5, + ZSTDds_decodeSkippableHeader = 6, + ZSTDds_skipFrame = 7, +} ZSTD_dStage; + +struct ZSTD_DCtx_s { + const FSE_DTable *LLTptr; + const FSE_DTable *MLTptr; + const FSE_DTable *OFTptr; + const HUF_DTable *HUFptr; + ZSTD_entropyTables_t entropy; + const void *previousDstEnd; + const void *base; + const void *vBase; + const void *dictEnd; + size_t expected; + ZSTD_frameParams fParams; + blockType_e bType; + ZSTD_dStage stage; + U32 litEntropy; + U32 fseEntropy; + struct xxh64_state xxhState; + size_t headerSize; + U32 dictID; + const BYTE *litPtr; + ZSTD_customMem customMem; + size_t litSize; + size_t rleSize; + BYTE litBuffer[131080]; + BYTE headerBuffer[18]; +}; + +typedef struct ZSTD_DCtx_s ZSTD_DCtx; + +struct ZSTD_DDict_s { + void *dictBuffer; + const void *dictContent; + size_t dictSize; + ZSTD_entropyTables_t entropy; + U32 dictID; + U32 entropyPresent; + ZSTD_customMem cMem; +}; + +typedef struct ZSTD_DDict_s ZSTD_DDict; + +typedef enum { + zdss_init = 0, + zdss_loadHeader = 1, + zdss_read = 2, + zdss_load = 3, + zdss_flush = 4, +} ZSTD_dStreamStage; + +struct ZSTD_DStream_s___2 { + ZSTD_DCtx *dctx; + ZSTD_DDict *ddictLocal; + const ZSTD_DDict *ddict; + ZSTD_frameParams fParams; + ZSTD_dStreamStage stage; + char *inBuff; + size_t inBuffSize; + size_t inPos; + size_t maxWindowSize; + char *outBuff; + size_t outBuffSize; + size_t outStart; + size_t outEnd; + size_t blockSize; + BYTE headerBuffer[18]; + size_t lhSize; + ZSTD_customMem customMem; + void *legacyContext; + U32 previousLegacyVersion; + U32 legacyVersion; + U32 hostageByte; +}; + +typedef struct ZSTD_DStream_s___2 ZSTD_DStream___2; + +typedef enum { + ZSTDnit_frameHeader = 0, + ZSTDnit_blockHeader = 1, + ZSTDnit_block = 2, + ZSTDnit_lastBlock = 3, + ZSTDnit_checksum = 4, + ZSTDnit_skippableFrame = 5, +} ZSTD_nextInputType_e; + +typedef uintptr_t uPtrDiff; + +typedef struct { + blockType_e blockType; + U32 lastBlock; + U32 origSize; +} blockProperties_t; + +typedef union { + FSE_decode_t realData; + U32 alignedBy4; +} FSE_decode_t4; + +typedef struct { + size_t litLength; + size_t matchLength; + size_t offset; + const BYTE *match; +} seq_t; + +typedef struct { + BIT_DStream_t DStream; + FSE_DState_t stateLL; + FSE_DState_t stateOffb; + FSE_DState_t stateML; + size_t prevOffset[3]; + const BYTE *base; + size_t pos; + uPtrDiff gotoDict; +} seqState_t; + +enum xz_mode { + XZ_SINGLE = 0, + XZ_PREALLOC = 1, + XZ_DYNALLOC = 2, +}; + +enum xz_ret { + XZ_OK = 0, + XZ_STREAM_END = 1, + XZ_UNSUPPORTED_CHECK = 2, + XZ_MEM_ERROR = 3, + XZ_MEMLIMIT_ERROR = 4, + XZ_FORMAT_ERROR = 5, + XZ_OPTIONS_ERROR = 6, + XZ_DATA_ERROR = 7, + XZ_BUF_ERROR = 8, +}; + +struct xz_buf { + const uint8_t *in; + size_t in_pos; + size_t in_size; + uint8_t *out; + size_t out_pos; + size_t out_size; +}; + +typedef uint64_t vli_type; + +enum xz_check { + XZ_CHECK_NONE = 0, + XZ_CHECK_CRC32 = 1, + XZ_CHECK_CRC64 = 4, + XZ_CHECK_SHA256 = 10, +}; + +struct xz_dec_hash { + vli_type unpadded; + vli_type uncompressed; + uint32_t crc32; +}; + +struct xz_dec_lzma2; + +struct xz_dec_bcj; + +struct xz_dec { + enum { + SEQ_STREAM_HEADER = 0, + SEQ_BLOCK_START = 1, + SEQ_BLOCK_HEADER = 2, + SEQ_BLOCK_UNCOMPRESS = 3, + SEQ_BLOCK_PADDING = 4, + SEQ_BLOCK_CHECK = 5, + SEQ_INDEX = 6, + SEQ_INDEX_PADDING = 7, + SEQ_INDEX_CRC32 = 8, + SEQ_STREAM_FOOTER = 9, + } sequence; + uint32_t pos; + vli_type vli; + size_t in_start; + size_t out_start; + uint32_t crc32; + enum xz_check check_type; + enum xz_mode mode; + bool allow_buf_error; + struct { + vli_type compressed; + vli_type uncompressed; + uint32_t size; + } block_header; + struct { + vli_type compressed; + vli_type uncompressed; + vli_type count; + struct xz_dec_hash hash; + } block; + struct { + enum { + SEQ_INDEX_COUNT = 0, + SEQ_INDEX_UNPADDED = 1, + SEQ_INDEX_UNCOMPRESSED = 2, + } sequence; + vli_type size; + vli_type count; + struct xz_dec_hash hash; + } index; + struct { + size_t pos; + size_t size; + uint8_t buf[1024]; + } temp; + struct xz_dec_lzma2 *lzma2; + struct xz_dec_bcj *bcj; + bool bcj_active; +}; + +enum lzma_state { + STATE_LIT_LIT = 0, + STATE_MATCH_LIT_LIT = 1, + STATE_REP_LIT_LIT = 2, + STATE_SHORTREP_LIT_LIT = 3, + STATE_MATCH_LIT = 4, + STATE_REP_LIT = 5, + STATE_SHORTREP_LIT = 6, + STATE_LIT_MATCH = 7, + STATE_LIT_LONGREP = 8, + STATE_LIT_SHORTREP = 9, + STATE_NONLIT_MATCH = 10, + STATE_NONLIT_REP = 11, +}; + +struct dictionary { + uint8_t *buf; + size_t start; + size_t pos; + size_t full; + size_t limit; + size_t end; + uint32_t size; + uint32_t size_max; + uint32_t allocated; + enum xz_mode mode; +}; + +struct rc_dec { + uint32_t range; + uint32_t code; + uint32_t init_bytes_left; + const uint8_t *in; + size_t in_pos; + size_t in_limit; +}; + +struct lzma_len_dec { + uint16_t choice; + uint16_t choice2; + uint16_t low[128]; + uint16_t mid[128]; + uint16_t high[256]; +}; + +struct lzma_dec { + uint32_t rep0; + uint32_t rep1; + uint32_t rep2; + uint32_t rep3; + enum lzma_state state; + uint32_t len; + uint32_t lc; + uint32_t literal_pos_mask; + uint32_t pos_mask; + uint16_t is_match[192]; + uint16_t is_rep[12]; + uint16_t is_rep0[12]; + uint16_t is_rep1[12]; + uint16_t is_rep2[12]; + uint16_t is_rep0_long[192]; + uint16_t dist_slot[256]; + uint16_t dist_special[114]; + uint16_t dist_align[16]; + struct lzma_len_dec match_len_dec; + struct lzma_len_dec rep_len_dec; + uint16_t literal[12288]; +}; + +enum lzma2_seq { + SEQ_CONTROL = 0, + SEQ_UNCOMPRESSED_1 = 1, + SEQ_UNCOMPRESSED_2 = 2, + SEQ_COMPRESSED_0 = 3, + SEQ_COMPRESSED_1 = 4, + SEQ_PROPERTIES = 5, + SEQ_LZMA_PREPARE = 6, + SEQ_LZMA_RUN = 7, + SEQ_COPY = 8, +}; + +struct lzma2_dec { + enum lzma2_seq sequence; + enum lzma2_seq next_sequence; + uint32_t uncompressed; + uint32_t compressed; + bool need_dict_reset; + bool need_props; +}; + +struct xz_dec_lzma2___2 { + struct rc_dec rc; + struct dictionary dict; + struct lzma2_dec lzma2; + struct lzma_dec lzma; + struct { + uint32_t size; + uint8_t buf[63]; + } temp; +}; + +struct xz_dec_bcj___2 { + enum { + BCJ_X86 = 4, + BCJ_POWERPC = 5, + BCJ_IA64 = 6, + BCJ_ARM = 7, + BCJ_ARMTHUMB = 8, + BCJ_SPARC = 9, + } type; + enum xz_ret ret; + bool single_call; + uint32_t pos; + uint32_t x86_prev_mask; + uint8_t *out; + size_t out_pos; + size_t out_size; + struct { + size_t filtered; + size_t size; + uint8_t buf[16]; + } temp; +}; + +struct raid6_recov_calls { + void (*data2)(int, size_t, int, int, void **); + void (*datap)(int, size_t, int, void **); + int (*valid)(); + const char *name; + int priority; +}; + +typedef u64 unative_t; + +struct raid6_sse_constants { + u64 x1d[2]; +}; + +struct raid6_avx2_constants { + u64 x1d[4]; +}; + +struct raid6_avx512_constants { + u64 x1d[8]; +}; + +struct ts_state { + unsigned int offset; + char cb[40]; +}; + +struct ts_config; + +struct ts_ops { + const char *name; + struct ts_config * (*init)(const void *, unsigned int, gfp_t, int); + unsigned int (*find)(struct ts_config *, struct ts_state *); + void (*destroy)(struct ts_config *); + void * (*get_pattern)(struct ts_config *); + unsigned int (*get_pattern_len)(struct ts_config *); + struct module *owner; + struct list_head list; +}; + +struct ts_config { + struct ts_ops *ops; + int flags; + unsigned int (*get_next_block)(unsigned int, const u8 **, struct ts_config *, struct ts_state *); + void (*finish)(struct ts_config *, struct ts_state *); +}; + +struct ts_linear_state { + unsigned int len; + const void *data; +}; + +struct ei_entry { + struct list_head list; + long unsigned int start_addr; + long unsigned int end_addr; + int etype; + void *priv; +}; + +struct nla_bitfield32 { + __u32 value; + __u32 selector; +}; + +enum nla_policy_validation { + NLA_VALIDATE_NONE = 0, + NLA_VALIDATE_RANGE = 1, + NLA_VALIDATE_RANGE_WARN_TOO_LONG = 2, + NLA_VALIDATE_MIN = 3, + NLA_VALIDATE_MAX = 4, + NLA_VALIDATE_MASK = 5, + NLA_VALIDATE_RANGE_PTR = 6, + NLA_VALIDATE_FUNCTION = 7, +}; + +enum netlink_validation { + NL_VALIDATE_LIBERAL = 0, + NL_VALIDATE_TRAILING = 1, + NL_VALIDATE_MAXTYPE = 2, + NL_VALIDATE_UNSPEC = 4, + NL_VALIDATE_STRICT_ATTRS = 8, + NL_VALIDATE_NESTED = 16, +}; + +struct cpu_rmap { + struct kref refcount; + u16 size; + u16 used; + void **obj; + struct { + u16 index; + u16 dist; + } near[0]; +}; + +struct irq_glue { + struct irq_affinity_notify notify; + struct cpu_rmap *rmap; + u16 index; +}; + +typedef mpi_limb_t *mpi_ptr_t; + +typedef int mpi_size_t; + +typedef mpi_limb_t UWtype; + +typedef unsigned int UHWtype; + +enum gcry_mpi_constants { + MPI_C_ZERO = 0, + MPI_C_ONE = 1, + MPI_C_TWO = 2, + MPI_C_THREE = 3, + MPI_C_FOUR = 4, + MPI_C_EIGHT = 5, +}; + +struct barrett_ctx_s; + +typedef struct barrett_ctx_s *mpi_barrett_t; + +struct gcry_mpi_point { + MPI x; + MPI y; + MPI z; +}; + +typedef struct gcry_mpi_point *MPI_POINT; + +enum gcry_mpi_ec_models { + MPI_EC_WEIERSTRASS = 0, + MPI_EC_MONTGOMERY = 1, + MPI_EC_EDWARDS = 2, +}; + +enum ecc_dialects { + ECC_DIALECT_STANDARD = 0, + ECC_DIALECT_ED25519 = 1, + ECC_DIALECT_SAFECURVE = 2, +}; + +struct mpi_ec_ctx { + enum gcry_mpi_ec_models model; + enum ecc_dialects dialect; + int flags; + unsigned int nbits; + MPI p; + MPI a; + MPI b; + MPI_POINT G; + MPI n; + unsigned int h; + MPI_POINT Q; + MPI d; + const char *name; + struct { + struct { + unsigned int a_is_pminus3: 1; + unsigned int two_inv_p: 1; + } valid; + int a_is_pminus3; + MPI two_inv_p; + mpi_barrett_t p_barrett; + MPI scratch[11]; + } t; + void (*addm)(MPI, MPI, MPI, struct mpi_ec_ctx *); + void (*subm)(MPI, MPI, MPI, struct mpi_ec_ctx *); + void (*mulm)(MPI, MPI, MPI, struct mpi_ec_ctx *); + void (*pow2)(MPI, const MPI, struct mpi_ec_ctx *); + void (*mul2)(MPI, MPI, struct mpi_ec_ctx *); +}; + +struct field_table { + const char *p; + void (*addm)(MPI, MPI, MPI, struct mpi_ec_ctx *); + void (*subm)(MPI, MPI, MPI, struct mpi_ec_ctx *); + void (*mulm)(MPI, MPI, MPI, struct mpi_ec_ctx *); + void (*mul2)(MPI, MPI, struct mpi_ec_ctx *); + void (*pow2)(MPI, const MPI, struct mpi_ec_ctx *); +}; + +enum gcry_mpi_format { + GCRYMPI_FMT_NONE = 0, + GCRYMPI_FMT_STD = 1, + GCRYMPI_FMT_PGP = 2, + GCRYMPI_FMT_SSH = 3, + GCRYMPI_FMT_HEX = 4, + GCRYMPI_FMT_USG = 5, + GCRYMPI_FMT_OPAQUE = 8, +}; + +struct barrett_ctx_s___2; + +typedef struct barrett_ctx_s___2 *mpi_barrett_t___2; + +struct barrett_ctx_s___2 { + MPI m; + int m_copied; + int k; + MPI y; + MPI r1; + MPI r2; + MPI r3; +}; + +struct karatsuba_ctx { + struct karatsuba_ctx *next; + mpi_ptr_t tspace; + mpi_size_t tspace_size; + mpi_ptr_t tp; + mpi_size_t tp_size; +}; + +typedef long int mpi_limb_signed_t; + +enum dim_tune_state { + DIM_PARKING_ON_TOP = 0, + DIM_PARKING_TIRED = 1, + DIM_GOING_RIGHT = 2, + DIM_GOING_LEFT = 3, +}; + +struct dim_cq_moder { + u16 usec; + u16 pkts; + u16 comps; + u8 cq_period_mode; +}; + +enum dim_cq_period_mode { + DIM_CQ_PERIOD_MODE_START_FROM_EQE = 0, + DIM_CQ_PERIOD_MODE_START_FROM_CQE = 1, + DIM_CQ_PERIOD_NUM_MODES = 2, +}; + +enum dim_state { + DIM_START_MEASURE = 0, + DIM_MEASURE_IN_PROGRESS = 1, + DIM_APPLY_NEW_PROFILE = 2, +}; + +enum dim_stats_state { + DIM_STATS_WORSE = 0, + DIM_STATS_SAME = 1, + DIM_STATS_BETTER = 2, +}; + +enum dim_step_result { + DIM_STEPPED = 0, + DIM_TOO_TIRED = 1, + DIM_ON_EDGE = 2, +}; + +struct sg_pool { + size_t size; + char *name; + struct kmem_cache *slab; + mempool_t *pool; +}; + +enum { + IRQ_POLL_F_SCHED = 0, + IRQ_POLL_F_DISABLE = 1, +}; + +struct font_desc { + int idx; + const char *name; + int width; + int height; + const void *data; + int pref; +}; + +struct font_data { + unsigned int extra[4]; + const unsigned char data[0]; +}; + +typedef u16 ucs2_char_t; + +struct msr { + union { + struct { + u32 l; + u32 h; + }; + u64 q; + }; +}; + +struct msr_info { + u32 msr_no; + struct msr reg; + struct msr *msrs; + int err; +}; + +struct msr_regs_info { + u32 *regs; + int err; +}; + +struct msr_info_completion { + struct msr_info msr; + struct completion done; +}; + +struct trace_event_raw_msr_trace_class { + struct trace_entry ent; + unsigned int msr; + u64 val; + int failed; + char __data[0]; +}; + +struct trace_event_data_offsets_msr_trace_class {}; + +typedef void (*btf_trace_read_msr)(void *, unsigned int, u64, int); + +typedef void (*btf_trace_write_msr)(void *, unsigned int, u64, int); + +typedef void (*btf_trace_rdpmc)(void *, unsigned int, u64, int); + +struct compress_format { + unsigned char magic[2]; + const char *name; + decompress_fn decompressor; +}; + +struct group_data { + int limit[21]; + int base[20]; + int permute[258]; + int minLen; + int maxLen; +}; + +struct bunzip_data { + int writeCopies; + int writePos; + int writeRunCountdown; + int writeCount; + int writeCurrent; + long int (*fill)(void *, long unsigned int); + long int inbufCount; + long int inbufPos; + unsigned char *inbuf; + unsigned int inbufBitCount; + unsigned int inbufBits; + unsigned int crc32Table[256]; + unsigned int headerCRC; + unsigned int totalCRC; + unsigned int writeCRC; + unsigned int *dbuf; + unsigned int dbufSize; + unsigned char selectors[32768]; + struct group_data groups[6]; + int io_error; + int byteCount[256]; + unsigned char symToByte[256]; + unsigned char mtfSymbol[256]; +}; + +struct rc { + long int (*fill)(void *, long unsigned int); + uint8_t *ptr; + uint8_t *buffer; + uint8_t *buffer_end; + long int buffer_size; + uint32_t code; + uint32_t range; + uint32_t bound; + void (*error)(char *); +}; + +struct lzma_header { + uint8_t pos; + uint32_t dict_size; + uint64_t dst_size; +} __attribute__((packed)); + +struct writer { + uint8_t *buffer; + uint8_t previous_byte; + size_t buffer_pos; + int bufsize; + size_t global_pos; + long int (*flush)(void *, long unsigned int); + struct lzma_header *header; +}; + +struct cstate { + int state; + uint32_t rep0; + uint32_t rep1; + uint32_t rep2; + uint32_t rep3; +}; + +struct xz_dec___2; + +typedef enum { + ZSTD_error_no_error = 0, + ZSTD_error_GENERIC = 1, + ZSTD_error_prefix_unknown = 2, + ZSTD_error_version_unsupported = 3, + ZSTD_error_parameter_unknown = 4, + ZSTD_error_frameParameter_unsupported = 5, + ZSTD_error_frameParameter_unsupportedBy32bits = 6, + ZSTD_error_frameParameter_windowTooLarge = 7, + ZSTD_error_compressionParameter_unsupported = 8, + ZSTD_error_init_missing = 9, + ZSTD_error_memory_allocation = 10, + ZSTD_error_stage_wrong = 11, + ZSTD_error_dstSize_tooSmall = 12, + ZSTD_error_srcSize_wrong = 13, + ZSTD_error_corruption_detected = 14, + ZSTD_error_checksum_wrong = 15, + ZSTD_error_tableLog_tooLarge = 16, + ZSTD_error_maxSymbolValue_tooLarge = 17, + ZSTD_error_maxSymbolValue_tooSmall = 18, + ZSTD_error_dictionary_corrupted = 19, + ZSTD_error_dictionary_wrong = 20, + ZSTD_error_dictionaryCreation_failed = 21, + ZSTD_error_maxCode = 22, +} ZSTD_ErrorCode; + +struct ZSTD_DCtx_s___2; + +typedef struct ZSTD_DCtx_s___2 ZSTD_DCtx___2; + +struct cpio_data { + void *data; + size_t size; + char name[18]; +}; + +enum cpio_fields { + C_MAGIC = 0, + C_INO = 1, + C_MODE = 2, + C_UID = 3, + C_GID = 4, + C_NLINK = 5, + C_MTIME = 6, + C_FILESIZE = 7, + C_MAJ = 8, + C_MIN = 9, + C_RMAJ = 10, + C_RMIN = 11, + C_NAMESIZE = 12, + C_CHKSUM = 13, + C_NFIELDS = 14, +}; + +struct fprop_local_single { + long unsigned int events; + unsigned int period; + raw_spinlock_t lock; +}; + +struct ida_bitmap { + long unsigned int bitmap[16]; +}; + +struct klist_waiter { + struct list_head list; + struct klist_node *node; + struct task_struct *process; + int woken; +}; + +struct uevent_sock { + struct list_head list; + struct sock *sk; +}; + +enum { + LOGIC_PIO_INDIRECT = 0, + LOGIC_PIO_CPU_MMIO = 1, +}; + +struct logic_pio_host_ops; + +struct logic_pio_hwaddr { + struct list_head list; + struct fwnode_handle *fwnode; + resource_size_t hw_start; + resource_size_t io_start; + resource_size_t size; + long unsigned int flags; + void *hostdata; + const struct logic_pio_host_ops *ops; +}; + +struct logic_pio_host_ops { + u32 (*in)(void *, long unsigned int, size_t); + void (*out)(void *, long unsigned int, u32, size_t); + u32 (*ins)(void *, long unsigned int, void *, size_t, unsigned int); + void (*outs)(void *, long unsigned int, const void *, size_t, unsigned int); +}; + +typedef struct { + long unsigned int key[2]; +} hsiphash_key_t; + +enum format_type { + FORMAT_TYPE_NONE = 0, + FORMAT_TYPE_WIDTH = 1, + FORMAT_TYPE_PRECISION = 2, + FORMAT_TYPE_CHAR = 3, + FORMAT_TYPE_STR = 4, + FORMAT_TYPE_PTR = 5, + FORMAT_TYPE_PERCENT_CHAR = 6, + FORMAT_TYPE_INVALID = 7, + FORMAT_TYPE_LONG_LONG = 8, + FORMAT_TYPE_ULONG = 9, + FORMAT_TYPE_LONG = 10, + FORMAT_TYPE_UBYTE = 11, + FORMAT_TYPE_BYTE = 12, + FORMAT_TYPE_USHORT = 13, + FORMAT_TYPE_SHORT = 14, + FORMAT_TYPE_UINT = 15, + FORMAT_TYPE_INT = 16, + FORMAT_TYPE_SIZE_T = 17, + FORMAT_TYPE_PTRDIFF = 18, +}; + +struct printf_spec { + unsigned int type: 8; + int field_width: 24; + unsigned int flags: 8; + unsigned int base: 8; + int precision: 16; +}; + +struct minmax_sample { + u32 t; + u32 v; +}; + +struct minmax { + struct minmax_sample s[3]; +}; + +struct xa_limit { + u32 max; + u32 min; +}; + +enum { + st_wordstart = 0, + st_wordcmp = 1, + st_wordskip = 2, + st_bufcpy = 3, +}; + +enum { + st_wordstart___2 = 0, + st_wordcmp___2 = 1, + st_wordskip___2 = 2, +}; + +struct in6_addr___2; + +enum reg_type { + REG_TYPE_RM = 0, + REG_TYPE_REG = 1, + REG_TYPE_INDEX = 2, + REG_TYPE_BASE = 3, +}; + +enum device_link_state { + DL_STATE_NONE = 4294967295, + DL_STATE_DORMANT = 0, + DL_STATE_AVAILABLE = 1, + DL_STATE_CONSUMER_PROBE = 2, + DL_STATE_ACTIVE = 3, + DL_STATE_SUPPLIER_UNBIND = 4, +}; + +struct device_link { + struct device *supplier; + struct list_head s_node; + struct device *consumer; + struct list_head c_node; + struct device link_dev; + enum device_link_state status; + u32 flags; + refcount_t rpm_active; + struct kref kref; + struct callback_head callback_head; + bool supplier_preactivated; +}; + +struct regulator; + +struct phy_configure_opts_dp { + unsigned int link_rate; + unsigned int lanes; + unsigned int voltage[4]; + unsigned int pre[4]; + u8 ssc: 1; + u8 set_rate: 1; + u8 set_lanes: 1; + u8 set_voltages: 1; +}; + +struct phy_configure_opts_mipi_dphy { + unsigned int clk_miss; + unsigned int clk_post; + unsigned int clk_pre; + unsigned int clk_prepare; + unsigned int clk_settle; + unsigned int clk_term_en; + unsigned int clk_trail; + unsigned int clk_zero; + unsigned int d_term_en; + unsigned int eot; + unsigned int hs_exit; + unsigned int hs_prepare; + unsigned int hs_settle; + unsigned int hs_skip; + unsigned int hs_trail; + unsigned int hs_zero; + unsigned int init; + unsigned int lpx; + unsigned int ta_get; + unsigned int ta_go; + unsigned int ta_sure; + unsigned int wakeup; + long unsigned int hs_clk_rate; + long unsigned int lp_clk_rate; + unsigned char lanes; +}; + +enum phy_mode { + PHY_MODE_INVALID = 0, + PHY_MODE_USB_HOST = 1, + PHY_MODE_USB_HOST_LS = 2, + PHY_MODE_USB_HOST_FS = 3, + PHY_MODE_USB_HOST_HS = 4, + PHY_MODE_USB_HOST_SS = 5, + PHY_MODE_USB_DEVICE = 6, + PHY_MODE_USB_DEVICE_LS = 7, + PHY_MODE_USB_DEVICE_FS = 8, + PHY_MODE_USB_DEVICE_HS = 9, + PHY_MODE_USB_DEVICE_SS = 10, + PHY_MODE_USB_OTG = 11, + PHY_MODE_UFS_HS_A = 12, + PHY_MODE_UFS_HS_B = 13, + PHY_MODE_PCIE = 14, + PHY_MODE_ETHERNET = 15, + PHY_MODE_MIPI_DPHY = 16, + PHY_MODE_SATA = 17, + PHY_MODE_LVDS = 18, + PHY_MODE_DP = 19, +}; + +union phy_configure_opts { + struct phy_configure_opts_mipi_dphy mipi_dphy; + struct phy_configure_opts_dp dp; +}; + +struct phy; + +struct phy_ops { + int (*init)(struct phy *); + int (*exit)(struct phy *); + int (*power_on)(struct phy *); + int (*power_off)(struct phy *); + int (*set_mode)(struct phy *, enum phy_mode, int); + int (*configure)(struct phy *, union phy_configure_opts *); + int (*validate)(struct phy *, enum phy_mode, int, union phy_configure_opts *); + int (*reset)(struct phy *); + int (*calibrate)(struct phy *); + void (*release)(struct phy *); + struct module *owner; +}; + +struct phy_attrs { + u32 bus_width; + u32 max_link_rate; + enum phy_mode mode; +}; + +struct phy { + struct device dev; + int id; + const struct phy_ops *ops; + struct mutex mutex; + int init_count; + int power_count; + struct phy_attrs attrs; + struct regulator *pwr; +}; + +struct phy_provider { + struct device *dev; + struct device_node *children; + struct module *owner; + struct list_head list; + struct phy * (*of_xlate)(struct device *, struct of_phandle_args *); +}; + +struct phy_lookup { + struct list_head node; + const char *dev_id; + const char *con_id; + struct phy *phy; +}; + +struct gpio_device; + +struct gpio_chip { + const char *label; + struct gpio_device *gpiodev; + struct device *parent; + struct module *owner; + int (*request)(struct gpio_chip *, unsigned int); + void (*free)(struct gpio_chip *, unsigned int); + int (*get_direction)(struct gpio_chip *, unsigned int); + int (*direction_input)(struct gpio_chip *, unsigned int); + int (*direction_output)(struct gpio_chip *, unsigned int, int); + int (*get)(struct gpio_chip *, unsigned int); + int (*get_multiple)(struct gpio_chip *, long unsigned int *, long unsigned int *); + void (*set)(struct gpio_chip *, unsigned int, int); + void (*set_multiple)(struct gpio_chip *, long unsigned int *, long unsigned int *); + int (*set_config)(struct gpio_chip *, unsigned int, long unsigned int); + int (*to_irq)(struct gpio_chip *, unsigned int); + void (*dbg_show)(struct seq_file *, struct gpio_chip *); + int (*init_valid_mask)(struct gpio_chip *, long unsigned int *, unsigned int); + int (*add_pin_ranges)(struct gpio_chip *); + int base; + u16 ngpio; + const char * const *names; + bool can_sleep; + long unsigned int *valid_mask; +}; + +enum pin_config_param { + PIN_CONFIG_BIAS_BUS_HOLD = 0, + PIN_CONFIG_BIAS_DISABLE = 1, + PIN_CONFIG_BIAS_HIGH_IMPEDANCE = 2, + PIN_CONFIG_BIAS_PULL_DOWN = 3, + PIN_CONFIG_BIAS_PULL_PIN_DEFAULT = 4, + PIN_CONFIG_BIAS_PULL_UP = 5, + PIN_CONFIG_DRIVE_OPEN_DRAIN = 6, + PIN_CONFIG_DRIVE_OPEN_SOURCE = 7, + PIN_CONFIG_DRIVE_PUSH_PULL = 8, + PIN_CONFIG_DRIVE_STRENGTH = 9, + PIN_CONFIG_DRIVE_STRENGTH_UA = 10, + PIN_CONFIG_INPUT_DEBOUNCE = 11, + PIN_CONFIG_INPUT_ENABLE = 12, + PIN_CONFIG_INPUT_SCHMITT = 13, + PIN_CONFIG_INPUT_SCHMITT_ENABLE = 14, + PIN_CONFIG_LOW_POWER_MODE = 15, + PIN_CONFIG_OUTPUT_ENABLE = 16, + PIN_CONFIG_OUTPUT = 17, + PIN_CONFIG_POWER_SOURCE = 18, + PIN_CONFIG_SLEEP_HARDWARE_STATE = 19, + PIN_CONFIG_SLEW_RATE = 20, + PIN_CONFIG_SKEW_DELAY = 21, + PIN_CONFIG_PERSIST_STATE = 22, + PIN_CONFIG_END = 127, + PIN_CONFIG_MAX = 255, +}; + +struct gpio_desc; + +struct gpio_device { + int id; + struct device dev; + struct cdev chrdev; + struct device *mockdev; + struct module *owner; + struct gpio_chip *chip; + struct gpio_desc *descs; + int base; + u16 ngpio; + const char *label; + void *data; + struct list_head list; + struct blocking_notifier_head notifier; +}; + +struct gpio_array; + +struct gpio_descs { + struct gpio_array *info; + unsigned int ndescs; + struct gpio_desc *desc[0]; +}; + +struct gpio_array { + struct gpio_desc **desc; + unsigned int size; + struct gpio_chip *chip; + long unsigned int *get_mask; + long unsigned int *set_mask; + long unsigned int invert_mask[0]; +}; + +struct gpio_desc { + struct gpio_device *gdev; + long unsigned int flags; + const char *label; + const char *name; + unsigned int debounce_period_us; +}; + +enum gpiod_flags { + GPIOD_ASIS = 0, + GPIOD_IN = 1, + GPIOD_OUT_LOW = 3, + GPIOD_OUT_HIGH = 7, + GPIOD_OUT_LOW_OPEN_DRAIN = 11, + GPIOD_OUT_HIGH_OPEN_DRAIN = 15, +}; + +struct acpi_gpio_params { + unsigned int crs_entry_index; + unsigned int line_index; + bool active_low; +}; + +struct acpi_gpio_mapping { + const char *name; + const struct acpi_gpio_params *data; + unsigned int size; + unsigned int quirks; +}; + +typedef u64 acpi_io_address; + +typedef u32 acpi_object_type; + +union acpi_object { + acpi_object_type type; + struct { + acpi_object_type type; + u64 value; + } integer; + struct { + acpi_object_type type; + u32 length; + char *pointer; + } string; + struct { + acpi_object_type type; + u32 length; + u8 *pointer; + } buffer; + struct { + acpi_object_type type; + u32 count; + union acpi_object *elements; + } package; + struct { + acpi_object_type type; + acpi_object_type actual_type; + acpi_handle handle; + } reference; + struct { + acpi_object_type type; + u32 proc_id; + acpi_io_address pblk_address; + u32 pblk_length; + } processor; + struct { + acpi_object_type type; + u32 system_level; + u32 resource_order; + } power_resource; +}; + +struct acpi_hotplug_profile { + struct kobject kobj; + int (*scan_dependent)(struct acpi_device *); + void (*notify_online)(struct acpi_device *); + bool enabled: 1; + bool demand_offline: 1; +}; + +struct acpi_device_status { + u32 present: 1; + u32 enabled: 1; + u32 show_in_ui: 1; + u32 functional: 1; + u32 battery_present: 1; + u32 reserved: 27; +}; + +struct acpi_device_flags { + u32 dynamic_status: 1; + u32 removable: 1; + u32 ejectable: 1; + u32 power_manageable: 1; + u32 match_driver: 1; + u32 initialized: 1; + u32 visited: 1; + u32 hotplug_notify: 1; + u32 is_dock_station: 1; + u32 of_compatible_ok: 1; + u32 coherent_dma: 1; + u32 cca_seen: 1; + u32 enumeration_by_parent: 1; + u32 reserved: 19; +}; + +typedef char acpi_bus_id[8]; + +struct acpi_pnp_type { + u32 hardware_id: 1; + u32 bus_address: 1; + u32 platform_id: 1; + u32 reserved: 29; +}; + +typedef u64 acpi_bus_address; + +typedef char acpi_device_name[40]; + +typedef char acpi_device_class[20]; + +struct acpi_device_pnp { + acpi_bus_id bus_id; + struct acpi_pnp_type type; + acpi_bus_address bus_address; + char *unique_id; + struct list_head ids; + acpi_device_name device_name; + acpi_device_class device_class; + union acpi_object *str_obj; +}; + +struct acpi_device_power_flags { + u32 explicit_get: 1; + u32 power_resources: 1; + u32 inrush_current: 1; + u32 power_removed: 1; + u32 ignore_parent: 1; + u32 dsw_present: 1; + u32 reserved: 26; +}; + +struct acpi_device_power_state { + struct { + u8 valid: 1; + u8 explicit_set: 1; + u8 reserved: 6; + } flags; + int power; + int latency; + struct list_head resources; +}; + +struct acpi_device_power { + int state; + struct acpi_device_power_flags flags; + struct acpi_device_power_state states[5]; +}; + +struct acpi_device_wakeup_flags { + u8 valid: 1; + u8 notifier_present: 1; +}; + +struct acpi_device_wakeup_context { + void (*func)(struct acpi_device_wakeup_context *); + struct device *dev; +}; + +struct acpi_device_wakeup { + acpi_handle gpe_device; + u64 gpe_number; + u64 sleep_state; + struct list_head resources; + struct acpi_device_wakeup_flags flags; + struct acpi_device_wakeup_context context; + struct wakeup_source *ws; + int prepare_count; + int enable_count; +}; + +struct acpi_device_perf_flags { + u8 reserved: 8; +}; + +struct acpi_device_perf_state; + +struct acpi_device_perf { + int state; + struct acpi_device_perf_flags flags; + int state_count; + struct acpi_device_perf_state *states; +}; + +struct acpi_device_dir { + struct proc_dir_entry *entry; +}; + +struct acpi_device_data { + const union acpi_object *pointer; + struct list_head properties; + const union acpi_object *of_compatible; + struct list_head subnodes; +}; + +struct acpi_scan_handler; + +struct acpi_hotplug_context; + +struct acpi_driver; + +struct acpi_device { + int device_type; + acpi_handle handle; + struct fwnode_handle fwnode; + struct acpi_device *parent; + struct list_head children; + struct list_head node; + struct list_head wakeup_list; + struct list_head del_list; + struct acpi_device_status status; + struct acpi_device_flags flags; + struct acpi_device_pnp pnp; + struct acpi_device_power power; + struct acpi_device_wakeup wakeup; + struct acpi_device_perf performance; + struct acpi_device_dir dir; + struct acpi_device_data data; + struct acpi_scan_handler *handler; + struct acpi_hotplug_context *hp; + struct acpi_driver *driver; + const struct acpi_gpio_mapping *driver_gpios; + void *driver_data; + struct device dev; + unsigned int physical_node_count; + unsigned int dep_unmet; + struct list_head physical_node_list; + struct mutex physical_node_lock; + void (*remove)(struct acpi_device *); +}; + +struct acpi_scan_handler { + const struct acpi_device_id *ids; + struct list_head list_node; + bool (*match)(const char *, const struct acpi_device_id **); + int (*attach)(struct acpi_device *, const struct acpi_device_id *); + void (*detach)(struct acpi_device *); + void (*bind)(struct device *); + void (*unbind)(struct device *); + struct acpi_hotplug_profile hotplug; +}; + +struct acpi_hotplug_context { + struct acpi_device *self; + int (*notify)(struct acpi_device *, u32); + void (*uevent)(struct acpi_device *, u32); + void (*fixup)(struct acpi_device *); +}; + +typedef int (*acpi_op_add)(struct acpi_device *); + +typedef int (*acpi_op_remove)(struct acpi_device *); + +typedef void (*acpi_op_notify)(struct acpi_device *, u32); + +struct acpi_device_ops { + acpi_op_add add; + acpi_op_remove remove; + acpi_op_notify notify; +}; + +struct acpi_driver { + char name[80]; + char class[80]; + const struct acpi_device_id *ids; + unsigned int flags; + struct acpi_device_ops ops; + struct device_driver drv; + struct module *owner; +}; + +struct acpi_device_perf_state { + struct { + u8 valid: 1; + u8 reserved: 7; + } flags; + u8 power; + u8 performance; + int latency; +}; + +enum gpio_lookup_flags { + GPIO_ACTIVE_HIGH = 0, + GPIO_ACTIVE_LOW = 1, + GPIO_OPEN_DRAIN = 2, + GPIO_OPEN_SOURCE = 4, + GPIO_PERSISTENT = 0, + GPIO_TRANSITORY = 8, + GPIO_PULL_UP = 16, + GPIO_PULL_DOWN = 32, + GPIO_LOOKUP_FLAGS_DEFAULT = 0, +}; + +struct gpiod_lookup { + const char *key; + u16 chip_hwnum; + const char *con_id; + unsigned int idx; + long unsigned int flags; +}; + +struct gpiod_lookup_table { + struct list_head list; + const char *dev_id; + struct gpiod_lookup table[0]; +}; + +struct gpiod_hog { + struct list_head list; + const char *chip_label; + u16 chip_hwnum; + const char *line_name; + long unsigned int lflags; + int dflags; +}; + +enum { + GPIOLINE_CHANGED_REQUESTED = 1, + GPIOLINE_CHANGED_RELEASED = 2, + GPIOLINE_CHANGED_CONFIG = 3, +}; + +struct acpi_gpio_info { + struct acpi_device *adev; + enum gpiod_flags flags; + bool gpioint; + int pin_config; + int polarity; + int triggering; + unsigned int quirks; +}; + +struct trace_event_raw_gpio_direction { + struct trace_entry ent; + unsigned int gpio; + int in; + int err; + char __data[0]; +}; + +struct trace_event_raw_gpio_value { + struct trace_entry ent; + unsigned int gpio; + int get; + int value; + char __data[0]; +}; + +struct trace_event_data_offsets_gpio_direction {}; + +struct trace_event_data_offsets_gpio_value {}; + +typedef void (*btf_trace_gpio_direction)(void *, unsigned int, int, int); + +typedef void (*btf_trace_gpio_value)(void *, unsigned int, int, int); + +struct devres; + +struct gpio { + unsigned int gpio; + long unsigned int flags; + const char *label; +}; + +struct gpiochip_info { + char name[32]; + char label[32]; + __u32 lines; +}; + +enum gpio_v2_line_flag { + GPIO_V2_LINE_FLAG_USED = 1, + GPIO_V2_LINE_FLAG_ACTIVE_LOW = 2, + GPIO_V2_LINE_FLAG_INPUT = 4, + GPIO_V2_LINE_FLAG_OUTPUT = 8, + GPIO_V2_LINE_FLAG_EDGE_RISING = 16, + GPIO_V2_LINE_FLAG_EDGE_FALLING = 32, + GPIO_V2_LINE_FLAG_OPEN_DRAIN = 64, + GPIO_V2_LINE_FLAG_OPEN_SOURCE = 128, + GPIO_V2_LINE_FLAG_BIAS_PULL_UP = 256, + GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN = 512, + GPIO_V2_LINE_FLAG_BIAS_DISABLED = 1024, +}; + +struct gpio_v2_line_values { + __u64 bits; + __u64 mask; +}; + +enum gpio_v2_line_attr_id { + GPIO_V2_LINE_ATTR_ID_FLAGS = 1, + GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES = 2, + GPIO_V2_LINE_ATTR_ID_DEBOUNCE = 3, +}; + +struct gpio_v2_line_attribute { + __u32 id; + __u32 padding; + union { + __u64 flags; + __u64 values; + __u32 debounce_period_us; + }; +}; + +struct gpio_v2_line_config_attribute { + struct gpio_v2_line_attribute attr; + __u64 mask; +}; + +struct gpio_v2_line_config { + __u64 flags; + __u32 num_attrs; + __u32 padding[5]; + struct gpio_v2_line_config_attribute attrs[10]; +}; + +struct gpio_v2_line_request { + __u32 offsets[64]; + char consumer[32]; + struct gpio_v2_line_config config; + __u32 num_lines; + __u32 event_buffer_size; + __u32 padding[5]; + __s32 fd; +}; + +struct gpio_v2_line_info { + char name[32]; + char consumer[32]; + __u32 offset; + __u32 num_attrs; + __u64 flags; + struct gpio_v2_line_attribute attrs[10]; + __u32 padding[4]; +}; + +enum gpio_v2_line_changed_type { + GPIO_V2_LINE_CHANGED_REQUESTED = 1, + GPIO_V2_LINE_CHANGED_RELEASED = 2, + GPIO_V2_LINE_CHANGED_CONFIG = 3, +}; + +struct gpio_v2_line_info_changed { + struct gpio_v2_line_info info; + __u64 timestamp_ns; + __u32 event_type; + __u32 padding[5]; +}; + +enum gpio_v2_line_event_id { + GPIO_V2_LINE_EVENT_RISING_EDGE = 1, + GPIO_V2_LINE_EVENT_FALLING_EDGE = 2, +}; + +struct gpio_v2_line_event { + __u64 timestamp_ns; + __u32 id; + __u32 offset; + __u32 seqno; + __u32 line_seqno; + __u32 padding[6]; +}; + +struct gpioline_info { + __u32 line_offset; + __u32 flags; + char name[32]; + char consumer[32]; +}; + +struct gpioline_info_changed { + struct gpioline_info info; + __u64 timestamp; + __u32 event_type; + __u32 padding[5]; +}; + +struct gpiohandle_request { + __u32 lineoffsets[64]; + __u32 flags; + __u8 default_values[64]; + char consumer_label[32]; + __u32 lines; + int fd; +}; + +struct gpiohandle_config { + __u32 flags; + __u8 default_values[64]; + __u32 padding[4]; +}; + +struct gpiohandle_data { + __u8 values[64]; +}; + +struct gpioevent_request { + __u32 lineoffset; + __u32 handleflags; + __u32 eventflags; + char consumer_label[32]; + int fd; +}; + +struct gpioevent_data { + __u64 timestamp; + __u32 id; +}; + +struct linehandle_state { + struct gpio_device *gdev; + const char *label; + struct gpio_desc *descs[64]; + u32 num_descs; +}; + +struct linereq; + +struct line { + struct gpio_desc *desc; + struct linereq *req; + unsigned int irq; + u64 eflags; + u64 timestamp_ns; + u32 req_seqno; + u32 line_seqno; + struct delayed_work work; + unsigned int sw_debounced; + unsigned int level; +}; + +struct linereq { + struct gpio_device *gdev; + const char *label; + u32 num_lines; + wait_queue_head_t wait; + u32 event_buffer_size; + struct { + union { + struct __kfifo kfifo; + struct gpio_v2_line_event *type; + const struct gpio_v2_line_event *const_type; + char (*rectype)[0]; + struct gpio_v2_line_event *ptr; + const struct gpio_v2_line_event *ptr_const; + }; + struct gpio_v2_line_event buf[0]; + } events; + atomic_t seqno; + struct mutex config_mutex; + struct line lines[0]; +}; + +struct lineevent_state { + struct gpio_device *gdev; + const char *label; + struct gpio_desc *desc; + u32 eflags; + int irq; + wait_queue_head_t wait; + struct { + union { + struct __kfifo kfifo; + struct gpioevent_data *type; + const struct gpioevent_data *const_type; + char (*rectype)[0]; + struct gpioevent_data *ptr; + const struct gpioevent_data *ptr_const; + }; + struct gpioevent_data buf[16]; + } events; + u64 timestamp; +}; + +struct gpio_chardev_data { + struct gpio_device *gdev; + wait_queue_head_t wait; + struct { + union { + struct __kfifo kfifo; + struct gpio_v2_line_info_changed *type; + const struct gpio_v2_line_info_changed *const_type; + char (*rectype)[0]; + struct gpio_v2_line_info_changed *ptr; + const struct gpio_v2_line_info_changed *ptr_const; + }; + struct gpio_v2_line_info_changed buf[32]; + } events; + struct notifier_block lineinfo_changed_nb; + long unsigned int *watched_lines; + atomic_t watch_abi_version; +}; + +struct class_attribute { + struct attribute attr; + ssize_t (*show)(struct class *, struct class_attribute *, char *); + ssize_t (*store)(struct class *, struct class_attribute *, const char *, size_t); +}; + +struct gpiod_data { + struct gpio_desc *desc; + struct mutex mutex; + struct kernfs_node *value_kn; + int irq; + unsigned char irq_flags; + bool direction_can_change; +}; + +struct acpi_connection_info { + u8 *connection; + u16 length; + u8 access_length; +}; + +struct acpi_resource_irq { + u8 descriptor_length; + u8 triggering; + u8 polarity; + u8 shareable; + u8 wake_capable; + u8 interrupt_count; + u8 interrupts[1]; +}; + +struct acpi_resource_dma { + u8 type; + u8 bus_master; + u8 transfer; + u8 channel_count; + u8 channels[1]; +}; + +struct acpi_resource_start_dependent { + u8 descriptor_length; + u8 compatibility_priority; + u8 performance_robustness; +}; + +struct acpi_resource_io { + u8 io_decode; + u8 alignment; + u8 address_length; + u16 minimum; + u16 maximum; +} __attribute__((packed)); + +struct acpi_resource_fixed_io { + u16 address; + u8 address_length; +} __attribute__((packed)); + +struct acpi_resource_fixed_dma { + u16 request_lines; + u16 channels; + u8 width; +} __attribute__((packed)); + +struct acpi_resource_vendor { + u16 byte_length; + u8 byte_data[1]; +} __attribute__((packed)); + +struct acpi_resource_vendor_typed { + u16 byte_length; + u8 uuid_subtype; + u8 uuid[16]; + u8 byte_data[1]; +}; + +struct acpi_resource_end_tag { + u8 checksum; +}; + +struct acpi_resource_memory24 { + u8 write_protect; + u16 minimum; + u16 maximum; + u16 alignment; + u16 address_length; +} __attribute__((packed)); + +struct acpi_resource_memory32 { + u8 write_protect; + u32 minimum; + u32 maximum; + u32 alignment; + u32 address_length; +} __attribute__((packed)); + +struct acpi_resource_fixed_memory32 { + u8 write_protect; + u32 address; + u32 address_length; +} __attribute__((packed)); + +struct acpi_memory_attribute { + u8 write_protect; + u8 caching; + u8 range_type; + u8 translation; +}; + +struct acpi_io_attribute { + u8 range_type; + u8 translation; + u8 translation_type; + u8 reserved1; +}; + +union acpi_resource_attribute { + struct acpi_memory_attribute mem; + struct acpi_io_attribute io; + u8 type_specific; +}; + +struct acpi_resource_label { + u16 string_length; + char *string_ptr; +} __attribute__((packed)); + +struct acpi_resource_source { + u8 index; + u16 string_length; + char *string_ptr; +} __attribute__((packed)); + +struct acpi_address16_attribute { + u16 granularity; + u16 minimum; + u16 maximum; + u16 translation_offset; + u16 address_length; +}; + +struct acpi_address32_attribute { + u32 granularity; + u32 minimum; + u32 maximum; + u32 translation_offset; + u32 address_length; +}; + +struct acpi_address64_attribute { + u64 granularity; + u64 minimum; + u64 maximum; + u64 translation_offset; + u64 address_length; +}; + +struct acpi_resource_address { + u8 resource_type; + u8 producer_consumer; + u8 decode; + u8 min_address_fixed; + u8 max_address_fixed; + union acpi_resource_attribute info; +}; + +struct acpi_resource_address16 { + u8 resource_type; + u8 producer_consumer; + u8 decode; + u8 min_address_fixed; + u8 max_address_fixed; + union acpi_resource_attribute info; + struct acpi_address16_attribute address; + struct acpi_resource_source resource_source; +} __attribute__((packed)); + +struct acpi_resource_address32 { + u8 resource_type; + u8 producer_consumer; + u8 decode; + u8 min_address_fixed; + u8 max_address_fixed; + union acpi_resource_attribute info; + struct acpi_address32_attribute address; + struct acpi_resource_source resource_source; +} __attribute__((packed)); + +struct acpi_resource_address64 { + u8 resource_type; + u8 producer_consumer; + u8 decode; + u8 min_address_fixed; + u8 max_address_fixed; + union acpi_resource_attribute info; + struct acpi_address64_attribute address; + struct acpi_resource_source resource_source; +} __attribute__((packed)); + +struct acpi_resource_extended_address64 { + u8 resource_type; + u8 producer_consumer; + u8 decode; + u8 min_address_fixed; + u8 max_address_fixed; + union acpi_resource_attribute info; + u8 revision_ID; + struct acpi_address64_attribute address; + u64 type_specific; +} __attribute__((packed)); + +struct acpi_resource_extended_irq { + u8 producer_consumer; + u8 triggering; + u8 polarity; + u8 shareable; + u8 wake_capable; + u8 interrupt_count; + struct acpi_resource_source resource_source; + u32 interrupts[1]; +} __attribute__((packed)); + +struct acpi_resource_generic_register { + u8 space_id; + u8 bit_width; + u8 bit_offset; + u8 access_size; + u64 address; +} __attribute__((packed)); + +struct acpi_resource_gpio { + u8 revision_id; + u8 connection_type; + u8 producer_consumer; + u8 pin_config; + u8 shareable; + u8 wake_capable; + u8 io_restriction; + u8 triggering; + u8 polarity; + u16 drive_strength; + u16 debounce_timeout; + u16 pin_table_length; + u16 vendor_length; + struct acpi_resource_source resource_source; + u16 *pin_table; + u8 *vendor_data; +} __attribute__((packed)); + +struct acpi_resource_common_serialbus { + u8 revision_id; + u8 type; + u8 producer_consumer; + u8 slave_mode; + u8 connection_sharing; + u8 type_revision_id; + u16 type_data_length; + u16 vendor_length; + struct acpi_resource_source resource_source; + u8 *vendor_data; +} __attribute__((packed)); + +struct acpi_resource_i2c_serialbus { + u8 revision_id; + u8 type; + u8 producer_consumer; + u8 slave_mode; + u8 connection_sharing; + u8 type_revision_id; + u16 type_data_length; + u16 vendor_length; + struct acpi_resource_source resource_source; + u8 *vendor_data; + u8 access_mode; + u16 slave_address; + u32 connection_speed; +} __attribute__((packed)); + +struct acpi_resource_spi_serialbus { + u8 revision_id; + u8 type; + u8 producer_consumer; + u8 slave_mode; + u8 connection_sharing; + u8 type_revision_id; + u16 type_data_length; + u16 vendor_length; + struct acpi_resource_source resource_source; + u8 *vendor_data; + u8 wire_mode; + u8 device_polarity; + u8 data_bit_length; + u8 clock_phase; + u8 clock_polarity; + u16 device_selection; + u32 connection_speed; +} __attribute__((packed)); + +struct acpi_resource_uart_serialbus { + u8 revision_id; + u8 type; + u8 producer_consumer; + u8 slave_mode; + u8 connection_sharing; + u8 type_revision_id; + u16 type_data_length; + u16 vendor_length; + struct acpi_resource_source resource_source; + u8 *vendor_data; + u8 endian; + u8 data_bits; + u8 stop_bits; + u8 flow_control; + u8 parity; + u8 lines_enabled; + u16 rx_fifo_size; + u16 tx_fifo_size; + u32 default_baud_rate; +} __attribute__((packed)); + +struct acpi_resource_pin_function { + u8 revision_id; + u8 pin_config; + u8 shareable; + u16 function_number; + u16 pin_table_length; + u16 vendor_length; + struct acpi_resource_source resource_source; + u16 *pin_table; + u8 *vendor_data; +} __attribute__((packed)); + +struct acpi_resource_pin_config { + u8 revision_id; + u8 producer_consumer; + u8 shareable; + u8 pin_config_type; + u32 pin_config_value; + u16 pin_table_length; + u16 vendor_length; + struct acpi_resource_source resource_source; + u16 *pin_table; + u8 *vendor_data; +} __attribute__((packed)); + +struct acpi_resource_pin_group { + u8 revision_id; + u8 producer_consumer; + u16 pin_table_length; + u16 vendor_length; + u16 *pin_table; + struct acpi_resource_label resource_label; + u8 *vendor_data; +} __attribute__((packed)); + +struct acpi_resource_pin_group_function { + u8 revision_id; + u8 producer_consumer; + u8 shareable; + u16 function_number; + u16 vendor_length; + struct acpi_resource_source resource_source; + struct acpi_resource_label resource_source_label; + u8 *vendor_data; +} __attribute__((packed)); + +struct acpi_resource_pin_group_config { + u8 revision_id; + u8 producer_consumer; + u8 shareable; + u8 pin_config_type; + u32 pin_config_value; + u16 vendor_length; + struct acpi_resource_source resource_source; + struct acpi_resource_label resource_source_label; + u8 *vendor_data; +} __attribute__((packed)); + +union acpi_resource_data { + struct acpi_resource_irq irq; + struct acpi_resource_dma dma; + struct acpi_resource_start_dependent start_dpf; + struct acpi_resource_io io; + struct acpi_resource_fixed_io fixed_io; + struct acpi_resource_fixed_dma fixed_dma; + struct acpi_resource_vendor vendor; + struct acpi_resource_vendor_typed vendor_typed; + struct acpi_resource_end_tag end_tag; + struct acpi_resource_memory24 memory24; + struct acpi_resource_memory32 memory32; + struct acpi_resource_fixed_memory32 fixed_memory32; + struct acpi_resource_address16 address16; + struct acpi_resource_address32 address32; + struct acpi_resource_address64 address64; + struct acpi_resource_extended_address64 ext_address64; + struct acpi_resource_extended_irq extended_irq; + struct acpi_resource_generic_register generic_reg; + struct acpi_resource_gpio gpio; + struct acpi_resource_i2c_serialbus i2c_serial_bus; + struct acpi_resource_spi_serialbus spi_serial_bus; + struct acpi_resource_uart_serialbus uart_serial_bus; + struct acpi_resource_common_serialbus common_serial_bus; + struct acpi_resource_pin_function pin_function; + struct acpi_resource_pin_config pin_config; + struct acpi_resource_pin_group pin_group; + struct acpi_resource_pin_group_function pin_group_function; + struct acpi_resource_pin_group_config pin_group_config; + struct acpi_resource_address address; +}; + +struct acpi_resource { + u32 type; + u32 length; + union acpi_resource_data data; +} __attribute__((packed)); + +struct acpi_gpiolib_dmi_quirk { + bool no_edge_events_on_boot; + char *ignore_wake; +}; + +struct acpi_gpio_event { + struct list_head node; + acpi_handle handle; + irq_handler_t handler; + unsigned int pin; + unsigned int irq; + long unsigned int irqflags; + bool irq_is_wake; + bool irq_requested; + struct gpio_desc *desc; +}; + +struct acpi_gpio_connection { + struct list_head node; + unsigned int pin; + struct gpio_desc *desc; +}; + +struct acpi_gpio_chip { + struct acpi_connection_info conn_info; + struct list_head conns; + struct mutex conn_lock; + struct gpio_chip *chip; + struct list_head events; + struct list_head deferred_req_irqs_list_entry; +}; + +struct acpi_gpio_lookup { + struct acpi_gpio_info info; + int index; + int pin_index; + bool active_low; + struct gpio_desc *desc; + int n; +}; + +enum { + pci_channel_io_normal = 1, + pci_channel_io_frozen = 2, + pci_channel_io_perm_failure = 3, +}; + +struct pci_sriov { + int pos; + int nres; + u32 cap; + u16 ctrl; + u16 total_VFs; + u16 initial_VFs; + u16 num_VFs; + u16 offset; + u16 stride; + u16 vf_device; + u32 pgsz; + u8 link; + u8 max_VF_buses; + u16 driver_max_VFs; + struct pci_dev *dev; + struct pci_dev *self; + u32 class; + u8 hdr_type; + u16 subsystem_vendor; + u16 subsystem_device; + resource_size_t barsz[6]; + bool drivers_autoprobe; +}; + +struct pci_bus_resource { + struct list_head list; + struct resource *res; + unsigned int flags; +}; + +typedef u64 pci_bus_addr_t; + +struct pci_bus_region { + pci_bus_addr_t start; + pci_bus_addr_t end; +}; + +enum pci_fixup_pass { + pci_fixup_early = 0, + pci_fixup_header = 1, + pci_fixup_final = 2, + pci_fixup_enable = 3, + pci_fixup_resume = 4, + pci_fixup_suspend = 5, + pci_fixup_resume_early = 6, + pci_fixup_suspend_late = 7, +}; + +struct hotplug_slot_ops; + +struct hotplug_slot { + const struct hotplug_slot_ops *ops; + struct list_head slot_list; + struct pci_slot *pci_slot; + struct module *owner; + const char *mod_name; +}; + +enum pci_dev_flags { + PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = 1, + PCI_DEV_FLAGS_NO_D3 = 2, + PCI_DEV_FLAGS_ASSIGNED = 4, + PCI_DEV_FLAGS_ACS_ENABLED_QUIRK = 8, + PCI_DEV_FLAG_PCIE_BRIDGE_ALIAS = 32, + PCI_DEV_FLAGS_NO_BUS_RESET = 64, + PCI_DEV_FLAGS_NO_PM_RESET = 128, + PCI_DEV_FLAGS_VPD_REF_F0 = 256, + PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT = 512, + PCI_DEV_FLAGS_NO_FLR_RESET = 1024, + PCI_DEV_FLAGS_NO_RELAXED_ORDERING = 2048, +}; + +enum pci_bus_flags { + PCI_BUS_FLAGS_NO_MSI = 1, + PCI_BUS_FLAGS_NO_MMRBC = 2, + PCI_BUS_FLAGS_NO_AERSID = 4, + PCI_BUS_FLAGS_NO_EXTCFG = 8, +}; + +enum pci_bus_speed { + PCI_SPEED_33MHz = 0, + PCI_SPEED_66MHz = 1, + PCI_SPEED_66MHz_PCIX = 2, + PCI_SPEED_100MHz_PCIX = 3, + PCI_SPEED_133MHz_PCIX = 4, + PCI_SPEED_66MHz_PCIX_ECC = 5, + PCI_SPEED_100MHz_PCIX_ECC = 6, + PCI_SPEED_133MHz_PCIX_ECC = 7, + PCI_SPEED_66MHz_PCIX_266 = 9, + PCI_SPEED_100MHz_PCIX_266 = 10, + PCI_SPEED_133MHz_PCIX_266 = 11, + AGP_UNKNOWN = 12, + AGP_1X = 13, + AGP_2X = 14, + AGP_4X = 15, + AGP_8X = 16, + PCI_SPEED_66MHz_PCIX_533 = 17, + PCI_SPEED_100MHz_PCIX_533 = 18, + PCI_SPEED_133MHz_PCIX_533 = 19, + PCIE_SPEED_2_5GT = 20, + PCIE_SPEED_5_0GT = 21, + PCIE_SPEED_8_0GT = 22, + PCIE_SPEED_16_0GT = 23, + PCIE_SPEED_32_0GT = 24, + PCI_SPEED_UNKNOWN = 255, +}; + +struct pci_host_bridge { + struct device dev; + struct pci_bus *bus; + struct pci_ops *ops; + struct pci_ops *child_ops; + void *sysdata; + int busnr; + struct list_head windows; + struct list_head dma_ranges; + u8 (*swizzle_irq)(struct pci_dev *, u8 *); + int (*map_irq)(const struct pci_dev *, u8, u8); + void (*release_fn)(struct pci_host_bridge *); + void *release_data; + struct msi_controller *msi; + unsigned int ignore_reset_delay: 1; + unsigned int no_ext_tags: 1; + unsigned int native_aer: 1; + unsigned int native_pcie_hotplug: 1; + unsigned int native_shpc_hotplug: 1; + unsigned int native_pme: 1; + unsigned int native_ltr: 1; + unsigned int native_dpc: 1; + unsigned int preserve_config: 1; + unsigned int size_windows: 1; + resource_size_t (*align_resource)(struct pci_dev *, const struct resource *, resource_size_t, resource_size_t, resource_size_t); + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long unsigned int private[0]; +}; + +enum { + PCI_REASSIGN_ALL_RSRC = 1, + PCI_REASSIGN_ALL_BUS = 2, + PCI_PROBE_ONLY = 4, + PCI_CAN_SKIP_ISA_ALIGN = 8, + PCI_ENABLE_PROC_DOMAINS = 16, + PCI_COMPAT_DOMAIN_0 = 32, + PCI_SCAN_ALL_PCIE_DEVS = 64, +}; + +enum pcie_bus_config_types { + PCIE_BUS_TUNE_OFF = 0, + PCIE_BUS_DEFAULT = 1, + PCIE_BUS_SAFE = 2, + PCIE_BUS_PERFORMANCE = 3, + PCIE_BUS_PEER2PEER = 4, +}; + +struct hotplug_slot_ops { + int (*enable_slot)(struct hotplug_slot *); + int (*disable_slot)(struct hotplug_slot *); + int (*set_attention_status)(struct hotplug_slot *, u8); + int (*hardware_test)(struct hotplug_slot *, u32); + int (*get_power_status)(struct hotplug_slot *, u8 *); + int (*get_attention_status)(struct hotplug_slot *, u8 *); + int (*get_latch_status)(struct hotplug_slot *, u8 *); + int (*get_adapter_status)(struct hotplug_slot *, u8 *); + int (*reset_slot)(struct hotplug_slot *, int); +}; + +enum pci_bar_type { + pci_bar_unknown = 0, + pci_bar_io = 1, + pci_bar_mem32 = 2, + pci_bar_mem64 = 3, +}; + +struct pci_domain_busn_res { + struct list_head list; + struct resource res; + int domain_nr; +}; + +struct bus_attribute { + struct attribute attr; + ssize_t (*show)(struct bus_type *, char *); + ssize_t (*store)(struct bus_type *, const char *, size_t); +}; + +enum pcie_reset_state { + pcie_deassert_reset = 1, + pcie_warm_reset = 2, + pcie_hot_reset = 3, +}; + +enum pcie_link_width { + PCIE_LNK_WIDTH_RESRV = 0, + PCIE_LNK_X1 = 1, + PCIE_LNK_X2 = 2, + PCIE_LNK_X4 = 4, + PCIE_LNK_X8 = 8, + PCIE_LNK_X12 = 12, + PCIE_LNK_X16 = 16, + PCIE_LNK_X32 = 32, + PCIE_LNK_WIDTH_UNKNOWN = 255, +}; + +struct pci_cap_saved_data { + u16 cap_nr; + bool cap_extended; + unsigned int size; + u32 data[0]; +}; + +struct pci_cap_saved_state { + struct hlist_node next; + struct pci_cap_saved_data cap; +}; + +typedef int (*arch_set_vga_state_t)(struct pci_dev *, bool, unsigned int, u32); + +struct pci_platform_pm_ops { + bool (*bridge_d3)(struct pci_dev *); + bool (*is_manageable)(struct pci_dev *); + int (*set_state)(struct pci_dev *, pci_power_t); + pci_power_t (*get_state)(struct pci_dev *); + void (*refresh_state)(struct pci_dev *); + pci_power_t (*choose_state)(struct pci_dev *); + int (*set_wakeup)(struct pci_dev *, bool); + bool (*need_resume)(struct pci_dev *); +}; + +struct pci_pme_device { + struct list_head list; + struct pci_dev *dev; +}; + +struct pci_saved_state { + u32 config_space[16]; + struct pci_cap_saved_data cap[0]; +}; + +struct pci_devres { + unsigned int enabled: 1; + unsigned int pinned: 1; + unsigned int orig_intx: 1; + unsigned int restore_intx: 1; + unsigned int mwi: 1; + u32 region_mask; +}; + +struct driver_attribute { + struct attribute attr; + ssize_t (*show)(struct device_driver *, char *); + ssize_t (*store)(struct device_driver *, const char *, size_t); +}; + +enum pci_ers_result { + PCI_ERS_RESULT_NONE = 1, + PCI_ERS_RESULT_CAN_RECOVER = 2, + PCI_ERS_RESULT_NEED_RESET = 3, + PCI_ERS_RESULT_DISCONNECT = 4, + PCI_ERS_RESULT_RECOVERED = 5, + PCI_ERS_RESULT_NO_AER_DRIVER = 6, +}; + +enum dev_dma_attr { + DEV_DMA_NOT_SUPPORTED = 0, + DEV_DMA_NON_COHERENT = 1, + DEV_DMA_COHERENT = 2, +}; + +struct pcie_device { + int irq; + struct pci_dev *port; + u32 service; + void *priv_data; + struct device device; +}; + +struct pcie_port_service_driver { + const char *name; + int (*probe)(struct pcie_device *); + void (*remove)(struct pcie_device *); + int (*suspend)(struct pcie_device *); + int (*resume_noirq)(struct pcie_device *); + int (*resume)(struct pcie_device *); + int (*runtime_suspend)(struct pcie_device *); + int (*runtime_resume)(struct pcie_device *); + void (*error_resume)(struct pci_dev *); + int port_type; + u32 service; + struct device_driver driver; +}; + +struct pci_dynid { + struct list_head node; + struct pci_device_id id; +}; + +struct drv_dev_and_id { + struct pci_driver *drv; + struct pci_dev *dev; + const struct pci_device_id *id; +}; + +enum pci_mmap_state { + pci_mmap_io = 0, + pci_mmap_mem = 1, +}; + +enum pci_mmap_api { + PCI_MMAP_SYSFS = 0, + PCI_MMAP_PROCFS = 1, +}; + +struct pci_vpd_ops; + +struct pci_vpd { + const struct pci_vpd_ops *ops; + struct bin_attribute *attr; + struct mutex lock; + unsigned int len; + u16 flag; + u8 cap; + unsigned int busy: 1; + unsigned int valid: 1; +}; + +struct pci_vpd_ops { + ssize_t (*read)(struct pci_dev *, loff_t, size_t, void *); + ssize_t (*write)(struct pci_dev *, loff_t, size_t, const void *); + int (*set_size)(struct pci_dev *, size_t); +}; + +struct pci_dev_resource { + struct list_head list; + struct resource *res; + struct pci_dev *dev; + resource_size_t start; + resource_size_t end; + resource_size_t add_size; + resource_size_t min_align; + long unsigned int flags; +}; + +enum release_type { + leaf_only = 0, + whole_subtree = 1, +}; + +enum enable_type { + undefined = 4294967295, + user_disabled = 0, + auto_disabled = 1, + user_enabled = 2, + auto_enabled = 3, +}; + +struct portdrv_service_data { + struct pcie_port_service_driver *drv; + struct device *dev; + u32 service; +}; + +typedef int (*pcie_pm_callback_t)(struct pcie_device *); + +struct aspm_latency { + u32 l0s; + u32 l1; +}; + +struct pcie_link_state { + struct pci_dev *pdev; + struct pci_dev *downstream; + struct pcie_link_state *root; + struct pcie_link_state *parent; + struct list_head sibling; + u32 aspm_support: 7; + u32 aspm_enabled: 7; + u32 aspm_capable: 7; + u32 aspm_default: 7; + char: 4; + u32 aspm_disable: 7; + u32 clkpm_capable: 1; + u32 clkpm_enabled: 1; + u32 clkpm_default: 1; + u32 clkpm_disable: 1; + struct aspm_latency latency_up; + struct aspm_latency latency_dw; + struct aspm_latency acceptable[8]; +}; + +struct pcie_pme_service_data { + spinlock_t lock; + struct pcie_device *srv; + struct work_struct work; + bool noirq; +}; + +struct pci_filp_private { + enum pci_mmap_state mmap_state; + int write_combine; +}; + +struct pci_slot_attribute { + struct attribute attr; + ssize_t (*show)(struct pci_slot *, char *); + ssize_t (*store)(struct pci_slot *, const char *, size_t); +}; + +typedef u64 acpi_size; + +struct acpi_buffer { + acpi_size length; + void *pointer; +}; + +struct acpi_bus_type { + struct list_head list; + const char *name; + bool (*match)(struct device *); + struct acpi_device * (*find_companion)(struct device *); + void (*setup)(struct device *); + void (*cleanup)(struct device *); +}; + +struct acpi_pci_root { + struct acpi_device *device; + struct pci_bus *bus; + u16 segment; + struct resource secondary; + u32 osc_support_set; + u32 osc_control_set; + phys_addr_t mcfg_addr; +}; + +enum pm_qos_flags_status { + PM_QOS_FLAGS_UNDEFINED = 4294967295, + PM_QOS_FLAGS_NONE = 0, + PM_QOS_FLAGS_SOME = 1, + PM_QOS_FLAGS_ALL = 2, +}; + +struct hpx_type0 { + u32 revision; + u8 cache_line_size; + u8 latency_timer; + u8 enable_serr; + u8 enable_perr; +}; + +struct hpx_type1 { + u32 revision; + u8 max_mem_read; + u8 avg_max_split; + u16 tot_max_split; +}; + +struct hpx_type2 { + u32 revision; + u32 unc_err_mask_and; + u32 unc_err_mask_or; + u32 unc_err_sever_and; + u32 unc_err_sever_or; + u32 cor_err_mask_and; + u32 cor_err_mask_or; + u32 adv_err_cap_and; + u32 adv_err_cap_or; + u16 pci_exp_devctl_and; + u16 pci_exp_devctl_or; + u16 pci_exp_lnkctl_and; + u16 pci_exp_lnkctl_or; + u32 sec_unc_err_sever_and; + u32 sec_unc_err_sever_or; + u32 sec_unc_err_mask_and; + u32 sec_unc_err_mask_or; +}; + +struct hpx_type3 { + u16 device_type; + u16 function_type; + u16 config_space_location; + u16 pci_exp_cap_id; + u16 pci_exp_cap_ver; + u16 pci_exp_vendor_id; + u16 dvsec_id; + u16 dvsec_rev; + u16 match_offset; + u32 match_mask_and; + u32 match_value; + u16 reg_offset; + u32 reg_mask_and; + u32 reg_mask_or; +}; + +enum hpx_type3_dev_type { + HPX_TYPE_ENDPOINT = 1, + HPX_TYPE_LEG_END = 2, + HPX_TYPE_RC_END = 4, + HPX_TYPE_RC_EC = 8, + HPX_TYPE_ROOT_PORT = 16, + HPX_TYPE_UPSTREAM = 32, + HPX_TYPE_DOWNSTREAM = 64, + HPX_TYPE_PCI_BRIDGE = 128, + HPX_TYPE_PCIE_BRIDGE = 256, +}; + +enum hpx_type3_fn_type { + HPX_FN_NORMAL = 1, + HPX_FN_SRIOV_PHYS = 2, + HPX_FN_SRIOV_VIRT = 4, +}; + +enum hpx_type3_cfg_loc { + HPX_CFG_PCICFG = 0, + HPX_CFG_PCIE_CAP = 1, + HPX_CFG_PCIE_CAP_EXT = 2, + HPX_CFG_VEND_CAP = 3, + HPX_CFG_DVSEC = 4, + HPX_CFG_MAX = 5, +}; + +enum pci_irq_reroute_variant { + INTEL_IRQ_REROUTE_VARIANT = 1, + MAX_IRQ_REROUTE_VARIANTS = 3, +}; + +struct pci_fixup { + u16 vendor; + u16 device; + u32 class; + unsigned int class_shift; + int hook_offset; +}; + +enum { + NVME_REG_CAP = 0, + NVME_REG_VS = 8, + NVME_REG_INTMS = 12, + NVME_REG_INTMC = 16, + NVME_REG_CC = 20, + NVME_REG_CSTS = 28, + NVME_REG_NSSR = 32, + NVME_REG_AQA = 36, + NVME_REG_ASQ = 40, + NVME_REG_ACQ = 48, + NVME_REG_CMBLOC = 56, + NVME_REG_CMBSZ = 60, + NVME_REG_BPINFO = 64, + NVME_REG_BPRSEL = 68, + NVME_REG_BPMBL = 72, + NVME_REG_PMRCAP = 3584, + NVME_REG_PMRCTL = 3588, + NVME_REG_PMRSTS = 3592, + NVME_REG_PMREBS = 3596, + NVME_REG_PMRSWTP = 3600, + NVME_REG_DBS = 4096, +}; + +enum { + NVME_CC_ENABLE = 1, + NVME_CC_EN_SHIFT = 0, + NVME_CC_CSS_SHIFT = 4, + NVME_CC_MPS_SHIFT = 7, + NVME_CC_AMS_SHIFT = 11, + NVME_CC_SHN_SHIFT = 14, + NVME_CC_IOSQES_SHIFT = 16, + NVME_CC_IOCQES_SHIFT = 20, + NVME_CC_CSS_NVM = 0, + NVME_CC_CSS_CSI = 96, + NVME_CC_CSS_MASK = 112, + NVME_CC_AMS_RR = 0, + NVME_CC_AMS_WRRU = 2048, + NVME_CC_AMS_VS = 14336, + NVME_CC_SHN_NONE = 0, + NVME_CC_SHN_NORMAL = 16384, + NVME_CC_SHN_ABRUPT = 32768, + NVME_CC_SHN_MASK = 49152, + NVME_CC_IOSQES = 393216, + NVME_CC_IOCQES = 4194304, + NVME_CAP_CSS_NVM = 1, + NVME_CAP_CSS_CSI = 64, + NVME_CSTS_RDY = 1, + NVME_CSTS_CFS = 2, + NVME_CSTS_NSSRO = 16, + NVME_CSTS_PP = 32, + NVME_CSTS_SHST_NORMAL = 0, + NVME_CSTS_SHST_OCCUR = 4, + NVME_CSTS_SHST_CMPLT = 8, + NVME_CSTS_SHST_MASK = 12, +}; + +enum { + NVME_AEN_BIT_NS_ATTR = 8, + NVME_AEN_BIT_FW_ACT = 9, + NVME_AEN_BIT_ANA_CHANGE = 11, + NVME_AEN_BIT_DISC_CHANGE = 31, +}; + +enum { + SWITCHTEC_GAS_MRPC_OFFSET = 0, + SWITCHTEC_GAS_TOP_CFG_OFFSET = 4096, + SWITCHTEC_GAS_SW_EVENT_OFFSET = 6144, + SWITCHTEC_GAS_SYS_INFO_OFFSET = 8192, + SWITCHTEC_GAS_FLASH_INFO_OFFSET = 8704, + SWITCHTEC_GAS_PART_CFG_OFFSET = 16384, + SWITCHTEC_GAS_NTB_OFFSET = 65536, + SWITCHTEC_GAS_PFF_CSR_OFFSET = 1261568, +}; + +enum { + SWITCHTEC_NTB_REG_INFO_OFFSET = 0, + SWITCHTEC_NTB_REG_CTRL_OFFSET = 16384, + SWITCHTEC_NTB_REG_DBMSG_OFFSET = 409600, +}; + +struct nt_partition_info { + u32 xlink_enabled; + u32 target_part_low; + u32 target_part_high; + u32 reserved; +}; + +struct ntb_info_regs { + u8 partition_count; + u8 partition_id; + u16 reserved1; + u64 ep_map; + u16 requester_id; + u16 reserved2; + u32 reserved3[4]; + struct nt_partition_info ntp_info[48]; +} __attribute__((packed)); + +struct ntb_ctrl_regs { + u32 partition_status; + u32 partition_op; + u32 partition_ctrl; + u32 bar_setup; + u32 bar_error; + u16 lut_table_entries; + u16 lut_table_offset; + u32 lut_error; + u16 req_id_table_size; + u16 req_id_table_offset; + u32 req_id_error; + u32 reserved1[7]; + struct { + u32 ctl; + u32 win_size; + u64 xlate_addr; + } bar_entry[6]; + struct { + u32 win_size; + u32 reserved[3]; + } bar_ext_entry[6]; + u32 reserved2[192]; + u32 req_id_table[512]; + u32 reserved3[256]; + u64 lut_entry[512]; +}; + +struct pci_dev_reset_methods { + u16 vendor; + u16 device; + int (*reset)(struct pci_dev *, int); +}; + +struct pci_dev_acs_enabled { + u16 vendor; + u16 device; + int (*acs_enabled)(struct pci_dev *, u16); +}; + +struct pci_dev_acs_ops { + u16 vendor; + u16 device; + int (*enable_acs)(struct pci_dev *); + int (*disable_acs_redir)(struct pci_dev *); +}; + +struct msix_entry { + u32 vector; + u16 entry; +}; + +enum dmi_device_type { + DMI_DEV_TYPE_ANY = 0, + DMI_DEV_TYPE_OTHER = 1, + DMI_DEV_TYPE_UNKNOWN = 2, + DMI_DEV_TYPE_VIDEO = 3, + DMI_DEV_TYPE_SCSI = 4, + DMI_DEV_TYPE_ETHERNET = 5, + DMI_DEV_TYPE_TOKENRING = 6, + DMI_DEV_TYPE_SOUND = 7, + DMI_DEV_TYPE_PATA = 8, + DMI_DEV_TYPE_SATA = 9, + DMI_DEV_TYPE_SAS = 10, + DMI_DEV_TYPE_IPMI = 4294967295, + DMI_DEV_TYPE_OEM_STRING = 4294967294, + DMI_DEV_TYPE_DEV_ONBOARD = 4294967293, + DMI_DEV_TYPE_DEV_SLOT = 4294967292, +}; + +struct dmi_device { + struct list_head list; + int type; + const char *name; + void *device_data; +}; + +struct dmi_dev_onboard { + struct dmi_device dev; + int instance; + int segment; + int bus; + int devfn; +}; + +enum smbios_attr_enum { + SMBIOS_ATTR_NONE = 0, + SMBIOS_ATTR_LABEL_SHOW = 1, + SMBIOS_ATTR_INSTANCE_SHOW = 2, +}; + +enum acpi_attr_enum { + ACPI_ATTR_LABEL_SHOW = 0, + ACPI_ATTR_INDEX_SHOW = 1, +}; + +enum hdmi_infoframe_type { + HDMI_INFOFRAME_TYPE_VENDOR = 129, + HDMI_INFOFRAME_TYPE_AVI = 130, + HDMI_INFOFRAME_TYPE_SPD = 131, + HDMI_INFOFRAME_TYPE_AUDIO = 132, + HDMI_INFOFRAME_TYPE_DRM = 135, +}; + +struct hdmi_any_infoframe { + enum hdmi_infoframe_type type; + unsigned char version; + unsigned char length; +}; + +enum hdmi_colorspace { + HDMI_COLORSPACE_RGB = 0, + HDMI_COLORSPACE_YUV422 = 1, + HDMI_COLORSPACE_YUV444 = 2, + HDMI_COLORSPACE_YUV420 = 3, + HDMI_COLORSPACE_RESERVED4 = 4, + HDMI_COLORSPACE_RESERVED5 = 5, + HDMI_COLORSPACE_RESERVED6 = 6, + HDMI_COLORSPACE_IDO_DEFINED = 7, +}; + +enum hdmi_scan_mode { + HDMI_SCAN_MODE_NONE = 0, + HDMI_SCAN_MODE_OVERSCAN = 1, + HDMI_SCAN_MODE_UNDERSCAN = 2, + HDMI_SCAN_MODE_RESERVED = 3, +}; + +enum hdmi_colorimetry { + HDMI_COLORIMETRY_NONE = 0, + HDMI_COLORIMETRY_ITU_601 = 1, + HDMI_COLORIMETRY_ITU_709 = 2, + HDMI_COLORIMETRY_EXTENDED = 3, +}; + +enum hdmi_picture_aspect { + HDMI_PICTURE_ASPECT_NONE = 0, + HDMI_PICTURE_ASPECT_4_3 = 1, + HDMI_PICTURE_ASPECT_16_9 = 2, + HDMI_PICTURE_ASPECT_64_27 = 3, + HDMI_PICTURE_ASPECT_256_135 = 4, + HDMI_PICTURE_ASPECT_RESERVED = 5, +}; + +enum hdmi_active_aspect { + HDMI_ACTIVE_ASPECT_16_9_TOP = 2, + HDMI_ACTIVE_ASPECT_14_9_TOP = 3, + HDMI_ACTIVE_ASPECT_16_9_CENTER = 4, + HDMI_ACTIVE_ASPECT_PICTURE = 8, + HDMI_ACTIVE_ASPECT_4_3 = 9, + HDMI_ACTIVE_ASPECT_16_9 = 10, + HDMI_ACTIVE_ASPECT_14_9 = 11, + HDMI_ACTIVE_ASPECT_4_3_SP_14_9 = 13, + HDMI_ACTIVE_ASPECT_16_9_SP_14_9 = 14, + HDMI_ACTIVE_ASPECT_16_9_SP_4_3 = 15, +}; + +enum hdmi_extended_colorimetry { + HDMI_EXTENDED_COLORIMETRY_XV_YCC_601 = 0, + HDMI_EXTENDED_COLORIMETRY_XV_YCC_709 = 1, + HDMI_EXTENDED_COLORIMETRY_S_YCC_601 = 2, + HDMI_EXTENDED_COLORIMETRY_OPYCC_601 = 3, + HDMI_EXTENDED_COLORIMETRY_OPRGB = 4, + HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM = 5, + HDMI_EXTENDED_COLORIMETRY_BT2020 = 6, + HDMI_EXTENDED_COLORIMETRY_RESERVED = 7, +}; + +enum hdmi_quantization_range { + HDMI_QUANTIZATION_RANGE_DEFAULT = 0, + HDMI_QUANTIZATION_RANGE_LIMITED = 1, + HDMI_QUANTIZATION_RANGE_FULL = 2, + HDMI_QUANTIZATION_RANGE_RESERVED = 3, +}; + +enum hdmi_nups { + HDMI_NUPS_UNKNOWN = 0, + HDMI_NUPS_HORIZONTAL = 1, + HDMI_NUPS_VERTICAL = 2, + HDMI_NUPS_BOTH = 3, +}; + +enum hdmi_ycc_quantization_range { + HDMI_YCC_QUANTIZATION_RANGE_LIMITED = 0, + HDMI_YCC_QUANTIZATION_RANGE_FULL = 1, +}; + +enum hdmi_content_type { + HDMI_CONTENT_TYPE_GRAPHICS = 0, + HDMI_CONTENT_TYPE_PHOTO = 1, + HDMI_CONTENT_TYPE_CINEMA = 2, + HDMI_CONTENT_TYPE_GAME = 3, +}; + +enum hdmi_metadata_type { + HDMI_STATIC_METADATA_TYPE1 = 1, +}; + +enum hdmi_eotf { + HDMI_EOTF_TRADITIONAL_GAMMA_SDR = 0, + HDMI_EOTF_TRADITIONAL_GAMMA_HDR = 1, + HDMI_EOTF_SMPTE_ST2084 = 2, + HDMI_EOTF_BT_2100_HLG = 3, +}; + +struct hdmi_avi_infoframe { + enum hdmi_infoframe_type type; + unsigned char version; + unsigned char length; + enum hdmi_colorspace colorspace; + enum hdmi_scan_mode scan_mode; + enum hdmi_colorimetry colorimetry; + enum hdmi_picture_aspect picture_aspect; + enum hdmi_active_aspect active_aspect; + bool itc; + enum hdmi_extended_colorimetry extended_colorimetry; + enum hdmi_quantization_range quantization_range; + enum hdmi_nups nups; + unsigned char video_code; + enum hdmi_ycc_quantization_range ycc_quantization_range; + enum hdmi_content_type content_type; + unsigned char pixel_repeat; + short unsigned int top_bar; + short unsigned int bottom_bar; + short unsigned int left_bar; + short unsigned int right_bar; +}; + +struct hdmi_drm_infoframe { + enum hdmi_infoframe_type type; + unsigned char version; + unsigned char length; + enum hdmi_eotf eotf; + enum hdmi_metadata_type metadata_type; + struct { + u16 x; + u16 y; + } display_primaries[3]; + struct { + u16 x; + u16 y; + } white_point; + u16 max_display_mastering_luminance; + u16 min_display_mastering_luminance; + u16 max_cll; + u16 max_fall; +}; + +enum hdmi_spd_sdi { + HDMI_SPD_SDI_UNKNOWN = 0, + HDMI_SPD_SDI_DSTB = 1, + HDMI_SPD_SDI_DVDP = 2, + HDMI_SPD_SDI_DVHS = 3, + HDMI_SPD_SDI_HDDVR = 4, + HDMI_SPD_SDI_DVC = 5, + HDMI_SPD_SDI_DSC = 6, + HDMI_SPD_SDI_VCD = 7, + HDMI_SPD_SDI_GAME = 8, + HDMI_SPD_SDI_PC = 9, + HDMI_SPD_SDI_BD = 10, + HDMI_SPD_SDI_SACD = 11, + HDMI_SPD_SDI_HDDVD = 12, + HDMI_SPD_SDI_PMP = 13, +}; + +struct hdmi_spd_infoframe { + enum hdmi_infoframe_type type; + unsigned char version; + unsigned char length; + char vendor[8]; + char product[16]; + enum hdmi_spd_sdi sdi; +}; + +enum hdmi_audio_coding_type { + HDMI_AUDIO_CODING_TYPE_STREAM = 0, + HDMI_AUDIO_CODING_TYPE_PCM = 1, + HDMI_AUDIO_CODING_TYPE_AC3 = 2, + HDMI_AUDIO_CODING_TYPE_MPEG1 = 3, + HDMI_AUDIO_CODING_TYPE_MP3 = 4, + HDMI_AUDIO_CODING_TYPE_MPEG2 = 5, + HDMI_AUDIO_CODING_TYPE_AAC_LC = 6, + HDMI_AUDIO_CODING_TYPE_DTS = 7, + HDMI_AUDIO_CODING_TYPE_ATRAC = 8, + HDMI_AUDIO_CODING_TYPE_DSD = 9, + HDMI_AUDIO_CODING_TYPE_EAC3 = 10, + HDMI_AUDIO_CODING_TYPE_DTS_HD = 11, + HDMI_AUDIO_CODING_TYPE_MLP = 12, + HDMI_AUDIO_CODING_TYPE_DST = 13, + HDMI_AUDIO_CODING_TYPE_WMA_PRO = 14, + HDMI_AUDIO_CODING_TYPE_CXT = 15, +}; + +enum hdmi_audio_sample_size { + HDMI_AUDIO_SAMPLE_SIZE_STREAM = 0, + HDMI_AUDIO_SAMPLE_SIZE_16 = 1, + HDMI_AUDIO_SAMPLE_SIZE_20 = 2, + HDMI_AUDIO_SAMPLE_SIZE_24 = 3, +}; + +enum hdmi_audio_sample_frequency { + HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM = 0, + HDMI_AUDIO_SAMPLE_FREQUENCY_32000 = 1, + HDMI_AUDIO_SAMPLE_FREQUENCY_44100 = 2, + HDMI_AUDIO_SAMPLE_FREQUENCY_48000 = 3, + HDMI_AUDIO_SAMPLE_FREQUENCY_88200 = 4, + HDMI_AUDIO_SAMPLE_FREQUENCY_96000 = 5, + HDMI_AUDIO_SAMPLE_FREQUENCY_176400 = 6, + HDMI_AUDIO_SAMPLE_FREQUENCY_192000 = 7, +}; + +enum hdmi_audio_coding_type_ext { + HDMI_AUDIO_CODING_TYPE_EXT_CT = 0, + HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC = 1, + HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2 = 2, + HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND = 3, + HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC = 4, + HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_V2 = 5, + HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC = 6, + HDMI_AUDIO_CODING_TYPE_EXT_DRA = 7, + HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_SURROUND = 8, + HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC_SURROUND = 10, +}; + +struct hdmi_audio_infoframe { + enum hdmi_infoframe_type type; + unsigned char version; + unsigned char length; + unsigned char channels; + enum hdmi_audio_coding_type coding_type; + enum hdmi_audio_sample_size sample_size; + enum hdmi_audio_sample_frequency sample_frequency; + enum hdmi_audio_coding_type_ext coding_type_ext; + unsigned char channel_allocation; + unsigned char level_shift_value; + bool downmix_inhibit; +}; + +enum hdmi_3d_structure { + HDMI_3D_STRUCTURE_INVALID = 4294967295, + HDMI_3D_STRUCTURE_FRAME_PACKING = 0, + HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE = 1, + HDMI_3D_STRUCTURE_LINE_ALTERNATIVE = 2, + HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL = 3, + HDMI_3D_STRUCTURE_L_DEPTH = 4, + HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH = 5, + HDMI_3D_STRUCTURE_TOP_AND_BOTTOM = 6, + HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF = 8, +}; + +struct hdmi_vendor_infoframe { + enum hdmi_infoframe_type type; + unsigned char version; + unsigned char length; + unsigned int oui; + u8 vic; + enum hdmi_3d_structure s3d_struct; + unsigned int s3d_ext_data; +}; + +union hdmi_vendor_any_infoframe { + struct { + enum hdmi_infoframe_type type; + unsigned char version; + unsigned char length; + unsigned int oui; + } any; + struct hdmi_vendor_infoframe hdmi; +}; + +union hdmi_infoframe { + struct hdmi_any_infoframe any; + struct hdmi_avi_infoframe avi; + struct hdmi_spd_infoframe spd; + union hdmi_vendor_any_infoframe vendor; + struct hdmi_audio_infoframe audio; + struct hdmi_drm_infoframe drm; +}; + +struct vc { + struct vc_data *d; + struct work_struct SAK_work; +}; + +struct vgastate { + void *vgabase; + long unsigned int membase; + __u32 memsize; + __u32 flags; + __u32 depth; + __u32 num_attr; + __u32 num_crtc; + __u32 num_gfx; + __u32 num_seq; + void *vidstate; +}; + +struct linux_logo { + int type; + unsigned int width; + unsigned int height; + unsigned int clutsize; + const unsigned char *clut; + const unsigned char *data; +}; + +struct fb_fix_screeninfo { + char id[16]; + long unsigned int smem_start; + __u32 smem_len; + __u32 type; + __u32 type_aux; + __u32 visual; + __u16 xpanstep; + __u16 ypanstep; + __u16 ywrapstep; + __u32 line_length; + long unsigned int mmio_start; + __u32 mmio_len; + __u32 accel; + __u16 capabilities; + __u16 reserved[2]; +}; + +struct fb_bitfield { + __u32 offset; + __u32 length; + __u32 msb_right; +}; + +struct fb_var_screeninfo { + __u32 xres; + __u32 yres; + __u32 xres_virtual; + __u32 yres_virtual; + __u32 xoffset; + __u32 yoffset; + __u32 bits_per_pixel; + __u32 grayscale; + struct fb_bitfield red; + struct fb_bitfield green; + struct fb_bitfield blue; + struct fb_bitfield transp; + __u32 nonstd; + __u32 activate; + __u32 height; + __u32 width; + __u32 accel_flags; + __u32 pixclock; + __u32 left_margin; + __u32 right_margin; + __u32 upper_margin; + __u32 lower_margin; + __u32 hsync_len; + __u32 vsync_len; + __u32 sync; + __u32 vmode; + __u32 rotate; + __u32 colorspace; + __u32 reserved[4]; +}; + +struct fb_cmap { + __u32 start; + __u32 len; + __u16 *red; + __u16 *green; + __u16 *blue; + __u16 *transp; +}; + +enum { + FB_BLANK_UNBLANK = 0, + FB_BLANK_NORMAL = 1, + FB_BLANK_VSYNC_SUSPEND = 2, + FB_BLANK_HSYNC_SUSPEND = 3, + FB_BLANK_POWERDOWN = 4, +}; + +struct fb_copyarea { + __u32 dx; + __u32 dy; + __u32 width; + __u32 height; + __u32 sx; + __u32 sy; +}; + +struct fb_fillrect { + __u32 dx; + __u32 dy; + __u32 width; + __u32 height; + __u32 color; + __u32 rop; +}; + +struct fb_image { + __u32 dx; + __u32 dy; + __u32 width; + __u32 height; + __u32 fg_color; + __u32 bg_color; + __u8 depth; + const char *data; + struct fb_cmap cmap; +}; + +struct fbcurpos { + __u16 x; + __u16 y; +}; + +struct fb_cursor { + __u16 set; + __u16 enable; + __u16 rop; + const char *mask; + struct fbcurpos hot; + struct fb_image image; +}; + +struct fb_chroma { + __u32 redx; + __u32 greenx; + __u32 bluex; + __u32 whitex; + __u32 redy; + __u32 greeny; + __u32 bluey; + __u32 whitey; +}; + +struct fb_videomode; + +struct fb_monspecs { + struct fb_chroma chroma; + struct fb_videomode *modedb; + __u8 manufacturer[4]; + __u8 monitor[14]; + __u8 serial_no[14]; + __u8 ascii[14]; + __u32 modedb_len; + __u32 model; + __u32 serial; + __u32 year; + __u32 week; + __u32 hfmin; + __u32 hfmax; + __u32 dclkmin; + __u32 dclkmax; + __u16 input; + __u16 dpms; + __u16 signal; + __u16 vfmin; + __u16 vfmax; + __u16 gamma; + __u16 gtf: 1; + __u16 misc; + __u8 version; + __u8 revision; + __u8 max_x; + __u8 max_y; +}; + +struct fb_videomode { + const char *name; + u32 refresh; + u32 xres; + u32 yres; + u32 pixclock; + u32 left_margin; + u32 right_margin; + u32 upper_margin; + u32 lower_margin; + u32 hsync_len; + u32 vsync_len; + u32 sync; + u32 vmode; + u32 flag; +}; + +struct fb_info; + +struct fb_event { + struct fb_info *info; + void *data; +}; + +struct fb_pixmap { + u8 *addr; + u32 size; + u32 offset; + u32 buf_align; + u32 scan_align; + u32 access_align; + u32 flags; + u32 blit_x; + u32 blit_y; + void (*writeio)(struct fb_info *, void *, void *, unsigned int); + void (*readio)(struct fb_info *, void *, void *, unsigned int); +}; + +struct backlight_device; + +struct fb_deferred_io; + +struct fb_ops; + +struct fb_tile_ops; + +struct apertures_struct; + +struct fb_info { + atomic_t count; + int node; + int flags; + int fbcon_rotate_hint; + struct mutex lock; + struct mutex mm_lock; + struct fb_var_screeninfo var; + struct fb_fix_screeninfo fix; + struct fb_monspecs monspecs; + struct work_struct queue; + struct fb_pixmap pixmap; + struct fb_pixmap sprite; + struct fb_cmap cmap; + struct list_head modelist; + struct fb_videomode *mode; + struct backlight_device *bl_dev; + struct mutex bl_curve_mutex; + u8 bl_curve[128]; + struct delayed_work deferred_work; + struct fb_deferred_io *fbdefio; + const struct fb_ops *fbops; + struct device *device; + struct device *dev; + int class_flag; + struct fb_tile_ops *tileops; + union { + char *screen_base; + char *screen_buffer; + }; + long unsigned int screen_size; + void *pseudo_palette; + u32 state; + void *fbcon_par; + void *par; + struct apertures_struct *apertures; + bool skip_vt_switch; +}; + +struct fb_blit_caps { + u32 x; + u32 y; + u32 len; + u32 flags; +}; + +struct fb_deferred_io { + long unsigned int delay; + struct mutex lock; + struct list_head pagelist; + void (*first_io)(struct fb_info *); + void (*deferred_io)(struct fb_info *, struct list_head *); +}; + +struct fb_ops { + struct module *owner; + int (*fb_open)(struct fb_info *, int); + int (*fb_release)(struct fb_info *, int); + ssize_t (*fb_read)(struct fb_info *, char *, size_t, loff_t *); + ssize_t (*fb_write)(struct fb_info *, const char *, size_t, loff_t *); + int (*fb_check_var)(struct fb_var_screeninfo *, struct fb_info *); + int (*fb_set_par)(struct fb_info *); + int (*fb_setcolreg)(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, struct fb_info *); + int (*fb_setcmap)(struct fb_cmap *, struct fb_info *); + int (*fb_blank)(int, struct fb_info *); + int (*fb_pan_display)(struct fb_var_screeninfo *, struct fb_info *); + void (*fb_fillrect)(struct fb_info *, const struct fb_fillrect *); + void (*fb_copyarea)(struct fb_info *, const struct fb_copyarea *); + void (*fb_imageblit)(struct fb_info *, const struct fb_image *); + int (*fb_cursor)(struct fb_info *, struct fb_cursor *); + int (*fb_sync)(struct fb_info *); + int (*fb_ioctl)(struct fb_info *, unsigned int, long unsigned int); + int (*fb_compat_ioctl)(struct fb_info *, unsigned int, long unsigned int); + int (*fb_mmap)(struct fb_info *, struct vm_area_struct *); + void (*fb_get_caps)(struct fb_info *, struct fb_blit_caps *, struct fb_var_screeninfo *); + void (*fb_destroy)(struct fb_info *); + int (*fb_debug_enter)(struct fb_info *); + int (*fb_debug_leave)(struct fb_info *); +}; + +struct fb_tilemap { + __u32 width; + __u32 height; + __u32 depth; + __u32 length; + const __u8 *data; +}; + +struct fb_tilerect { + __u32 sx; + __u32 sy; + __u32 width; + __u32 height; + __u32 index; + __u32 fg; + __u32 bg; + __u32 rop; +}; + +struct fb_tilearea { + __u32 sx; + __u32 sy; + __u32 dx; + __u32 dy; + __u32 width; + __u32 height; +}; + +struct fb_tileblit { + __u32 sx; + __u32 sy; + __u32 width; + __u32 height; + __u32 fg; + __u32 bg; + __u32 length; + __u32 *indices; +}; + +struct fb_tilecursor { + __u32 sx; + __u32 sy; + __u32 mode; + __u32 shape; + __u32 fg; + __u32 bg; +}; + +struct fb_tile_ops { + void (*fb_settile)(struct fb_info *, struct fb_tilemap *); + void (*fb_tilecopy)(struct fb_info *, struct fb_tilearea *); + void (*fb_tilefill)(struct fb_info *, struct fb_tilerect *); + void (*fb_tileblit)(struct fb_info *, struct fb_tileblit *); + void (*fb_tilecursor)(struct fb_info *, struct fb_tilecursor *); + int (*fb_get_tilemax)(struct fb_info *); +}; + +struct aperture { + resource_size_t base; + resource_size_t size; +}; + +struct apertures_struct { + unsigned int count; + struct aperture ranges[0]; +}; + +enum backlight_type { + BACKLIGHT_RAW = 1, + BACKLIGHT_PLATFORM = 2, + BACKLIGHT_FIRMWARE = 3, + BACKLIGHT_TYPE_MAX = 4, +}; + +enum backlight_scale { + BACKLIGHT_SCALE_UNKNOWN = 0, + BACKLIGHT_SCALE_LINEAR = 1, + BACKLIGHT_SCALE_NON_LINEAR = 2, +}; + +struct backlight_properties { + int brightness; + int max_brightness; + int power; + int fb_blank; + enum backlight_type type; + unsigned int state; + enum backlight_scale scale; +}; + +struct backlight_ops; + +struct backlight_device { + struct backlight_properties props; + struct mutex update_lock; + struct mutex ops_lock; + const struct backlight_ops *ops; + struct notifier_block fb_notif; + struct list_head entry; + struct device dev; + bool fb_bl_on[32]; + int use_count; +}; + +enum backlight_update_reason { + BACKLIGHT_UPDATE_HOTKEY = 0, + BACKLIGHT_UPDATE_SYSFS = 1, +}; + +enum backlight_notification { + BACKLIGHT_REGISTERED = 0, + BACKLIGHT_UNREGISTERED = 1, +}; + +struct backlight_ops { + unsigned int options; + int (*update_status)(struct backlight_device *); + int (*get_brightness)(struct backlight_device *); + int (*check_fb)(struct backlight_device *, struct fb_info *); +}; + +struct fb_cmap_user { + __u32 start; + __u32 len; + __u16 *red; + __u16 *green; + __u16 *blue; + __u16 *transp; +}; + +struct fb_modelist { + struct list_head list; + struct fb_videomode mode; +}; + +struct logo_data { + int depth; + int needs_directpalette; + int needs_truepalette; + int needs_cmapreset; + const struct linux_logo *logo; +}; + +struct fb_fix_screeninfo32 { + char id[16]; + compat_caddr_t smem_start; + u32 smem_len; + u32 type; + u32 type_aux; + u32 visual; + u16 xpanstep; + u16 ypanstep; + u16 ywrapstep; + u32 line_length; + compat_caddr_t mmio_start; + u32 mmio_len; + u32 accel; + u16 reserved[3]; +}; + +struct fb_cmap32 { + u32 start; + u32 len; + compat_caddr_t red; + compat_caddr_t green; + compat_caddr_t blue; + compat_caddr_t transp; +}; + +struct dmt_videomode { + u32 dmt_id; + u32 std_2byte_code; + u32 cvt_3byte_code; + const struct fb_videomode *mode; +}; + +struct broken_edid { + u8 manufacturer[4]; + u32 model; + u32 fix; +}; + +struct __fb_timings { + u32 dclk; + u32 hfreq; + u32 vfreq; + u32 hactive; + u32 vactive; + u32 hblank; + u32 vblank; + u32 htotal; + u32 vtotal; +}; + +struct fb_cvt_data { + u32 xres; + u32 yres; + u32 refresh; + u32 f_refresh; + u32 pixclock; + u32 hperiod; + u32 hblank; + u32 hfreq; + u32 htotal; + u32 vtotal; + u32 vsync; + u32 hsync; + u32 h_front_porch; + u32 h_back_porch; + u32 v_front_porch; + u32 v_back_porch; + u32 h_margin; + u32 v_margin; + u32 interlace; + u32 aspect_ratio; + u32 active_pixels; + u32 flags; + u32 status; +}; + +typedef unsigned char u_char; + +typedef short unsigned int u_short; + +struct fb_con2fbmap { + __u32 console; + __u32 framebuffer; +}; + +struct fbcon_display { + const u_char *fontdata; + int userfont; + u_short scrollmode; + u_short inverse; + short int yscroll; + int vrows; + int cursor_shape; + int con_rotate; + u32 xres_virtual; + u32 yres_virtual; + u32 height; + u32 width; + u32 bits_per_pixel; + u32 grayscale; + u32 nonstd; + u32 accel_flags; + u32 rotate; + struct fb_bitfield red; + struct fb_bitfield green; + struct fb_bitfield blue; + struct fb_bitfield transp; + const struct fb_videomode *mode; +}; + +struct fbcon_ops { + void (*bmove)(struct vc_data *, struct fb_info *, int, int, int, int, int, int); + void (*clear)(struct vc_data *, struct fb_info *, int, int, int, int); + void (*putcs)(struct vc_data *, struct fb_info *, const short unsigned int *, int, int, int, int, int); + void (*clear_margins)(struct vc_data *, struct fb_info *, int, int); + void (*cursor)(struct vc_data *, struct fb_info *, int, int, int); + int (*update_start)(struct fb_info *); + int (*rotate_font)(struct fb_info *, struct vc_data *); + struct fb_var_screeninfo var; + struct timer_list cursor_timer; + struct fb_cursor cursor_state; + struct fbcon_display *p; + struct fb_info *info; + int currcon; + int cur_blink_jiffies; + int cursor_flash; + int cursor_reset; + int blank_state; + int graphics; + int save_graphics; + int flags; + int rotate; + int cur_rotate; + char *cursor_data; + u8 *fontbuffer; + u8 *fontdata; + u8 *cursor_src; + u32 cursor_size; + u32 fd_size; +}; + +enum { + FBCON_LOGO_CANSHOW = 4294967295, + FBCON_LOGO_DRAW = 4294967294, + FBCON_LOGO_DONTSHOW = 4294967293, +}; + +struct vesafb_par { + u32 pseudo_palette[256]; + int wc_cookie; + struct resource *region; +}; + +struct thermal_cooling_device_ops; + +struct thermal_cooling_device { + int id; + char type[20]; + struct device device; + struct device_node *np; + void *devdata; + void *stats; + const struct thermal_cooling_device_ops *ops; + bool updated; + struct mutex lock; + struct list_head thermal_instances; + struct list_head node; +}; + +struct idle_cpu { + struct cpuidle_state *state_table; + long unsigned int auto_demotion_disable_flags; + bool byt_auto_demotion_disable_flag; + bool disable_promotion_to_c1e; + bool use_acpi; +}; + +struct thermal_cooling_device_ops { + int (*get_max_state)(struct thermal_cooling_device *, long unsigned int *); + int (*get_cur_state)(struct thermal_cooling_device *, long unsigned int *); + int (*set_cur_state)(struct thermal_cooling_device *, long unsigned int); + int (*get_requested_power)(struct thermal_cooling_device *, u32 *); + int (*state2power)(struct thermal_cooling_device *, long unsigned int, u32 *); + int (*power2state)(struct thermal_cooling_device *, u32, long unsigned int *); +}; + +struct acpi_lpi_state { + u32 min_residency; + u32 wake_latency; + u32 flags; + u32 arch_flags; + u32 res_cnt_freq; + u32 enable_parent_state; + u64 address; + u8 index; + u8 entry_method; + char desc[32]; +}; + +struct acpi_processor_power { + int count; + union { + struct acpi_processor_cx states[8]; + struct acpi_lpi_state lpi_states[8]; + }; + int timer_broadcast_on_state; +}; + +struct acpi_psd_package { + u64 num_entries; + u64 revision; + u64 domain; + u64 coord_type; + u64 num_processors; +}; + +struct acpi_pct_register { + u8 descriptor; + u16 length; + u8 space_id; + u8 bit_width; + u8 bit_offset; + u8 reserved; + u64 address; +} __attribute__((packed)); + +struct acpi_processor_px { + u64 core_frequency; + u64 power; + u64 transition_latency; + u64 bus_master_latency; + u64 control; + u64 status; +}; + +struct acpi_processor_performance { + unsigned int state; + unsigned int platform_limit; + struct acpi_pct_register control_register; + struct acpi_pct_register status_register; + short: 16; + unsigned int state_count; + int: 32; + struct acpi_processor_px *states; + struct acpi_psd_package domain_info; + cpumask_var_t shared_cpu_map; + unsigned int shared_type; + int: 32; +} __attribute__((packed)); + +struct acpi_tsd_package { + u64 num_entries; + u64 revision; + u64 domain; + u64 coord_type; + u64 num_processors; +}; + +struct acpi_processor_tx_tss { + u64 freqpercentage; + u64 power; + u64 transition_latency; + u64 control; + u64 status; +}; + +struct acpi_processor_tx { + u16 power; + u16 performance; +}; + +struct acpi_processor; + +struct acpi_processor_throttling { + unsigned int state; + unsigned int platform_limit; + struct acpi_pct_register control_register; + struct acpi_pct_register status_register; + short: 16; + unsigned int state_count; + int: 32; + struct acpi_processor_tx_tss *states_tss; + struct acpi_tsd_package domain_info; + cpumask_var_t shared_cpu_map; + int (*acpi_processor_get_throttling)(struct acpi_processor *); + int (*acpi_processor_set_throttling)(struct acpi_processor *, int, bool); + u32 address; + u8 duty_offset; + u8 duty_width; + u8 tsd_valid_flag; + char: 8; + unsigned int shared_type; + struct acpi_processor_tx states[16]; + int: 32; +} __attribute__((packed)); + +struct acpi_processor_lx { + int px; + int tx; +}; + +struct acpi_processor_limit { + struct acpi_processor_lx state; + struct acpi_processor_lx thermal; + struct acpi_processor_lx user; +}; + +struct acpi_processor { + acpi_handle handle; + u32 acpi_id; + phys_cpuid_t phys_id; + u32 id; + u32 pblk; + int performance_platform_limit; + int throttling_platform_limit; + struct acpi_processor_flags flags; + struct acpi_processor_power power; + struct acpi_processor_performance *performance; + struct acpi_processor_throttling throttling; + struct acpi_processor_limit limit; + struct thermal_cooling_device *cdev; + struct device *dev; + struct freq_qos_request perflib_req; + struct freq_qos_request thermal_req; +}; + +enum ipmi_addr_src { + SI_INVALID = 0, + SI_HOTMOD = 1, + SI_HARDCODED = 2, + SI_SPMI = 3, + SI_ACPI = 4, + SI_SMBIOS = 5, + SI_PCI = 6, + SI_DEVICETREE = 7, + SI_PLATFORM = 8, + SI_LAST = 9, +}; + +struct dmi_header { + u8 type; + u8 length; + u16 handle; +}; + +enum si_type { + SI_TYPE_INVALID = 0, + SI_KCS = 1, + SI_SMIC = 2, + SI_BT = 3, +}; + +enum ipmi_addr_space { + IPMI_IO_ADDR_SPACE = 0, + IPMI_MEM_ADDR_SPACE = 1, +}; + +enum ipmi_plat_interface_type { + IPMI_PLAT_IF_SI = 0, + IPMI_PLAT_IF_SSIF = 1, +}; + +struct ipmi_plat_data { + enum ipmi_plat_interface_type iftype; + unsigned int type; + unsigned int space; + long unsigned int addr; + unsigned int regspacing; + unsigned int regsize; + unsigned int regshift; + unsigned int irq; + unsigned int slave_addr; + enum ipmi_addr_src addr_source; +}; + +struct ipmi_dmi_info { + enum si_type si_type; + unsigned int space; + long unsigned int addr; + u8 slave_addr; + struct ipmi_dmi_info *next; +}; + +typedef u16 acpi_owner_id; + +union acpi_name_union { + u32 integer; + char ascii[4]; +}; + +struct acpi_table_desc { + acpi_physical_address address; + struct acpi_table_header *pointer; + u32 length; + union acpi_name_union signature; + acpi_owner_id owner_id; + u8 flags; + u16 validation_count; +}; + +struct acpi_madt_io_sapic { + struct acpi_subtable_header header; + u8 id; + u8 reserved; + u32 global_irq_base; + u64 address; +}; + +struct acpi_madt_interrupt_source { + struct acpi_subtable_header header; + u16 inti_flags; + u8 type; + u8 id; + u8 eid; + u8 io_sapic_vector; + u32 global_irq; + u32 flags; +}; + +struct acpi_madt_generic_interrupt { + struct acpi_subtable_header header; + u16 reserved; + u32 cpu_interface_number; + u32 uid; + u32 flags; + u32 parking_version; + u32 performance_interrupt; + u64 parked_address; + u64 base_address; + u64 gicv_base_address; + u64 gich_base_address; + u32 vgic_interrupt; + u64 gicr_base_address; + u64 arm_mpidr; + u8 efficiency_class; + u8 reserved2[1]; + u16 spe_interrupt; +} __attribute__((packed)); + +struct acpi_madt_generic_distributor { + struct acpi_subtable_header header; + u16 reserved; + u32 gic_id; + u64 base_address; + u32 global_irq_base; + u8 version; + u8 reserved2[3]; +}; + +typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *); + +enum acpi_subtable_type { + ACPI_SUBTABLE_COMMON = 0, + ACPI_SUBTABLE_HMAT = 1, +}; + +struct acpi_subtable_entry { + union acpi_subtable_headers *hdr; + enum acpi_subtable_type type; +}; + +enum acpi_predicate { + all_versions = 0, + less_than_or_equal = 1, + equal = 2, + greater_than_or_equal = 3, +}; + +struct acpi_platform_list { + char oem_id[7]; + char oem_table_id[9]; + u32 oem_revision; + char *table; + enum acpi_predicate pred; + char *reason; + u32 data; +}; + +typedef char *acpi_string; + +struct acpi_osi_entry { + char string[64]; + bool enable; +}; + +struct acpi_osi_config { + u8 default_disabling; + unsigned int linux_enable: 1; + unsigned int linux_dmi: 1; + unsigned int linux_cmdline: 1; + unsigned int darwin_enable: 1; + unsigned int darwin_dmi: 1; + unsigned int darwin_cmdline: 1; +}; + +struct acpi_predefined_names { + const char *name; + u8 type; + char *val; +}; + +typedef u32 (*acpi_osd_handler)(void *); + +typedef void (*acpi_osd_exec_callback)(void *); + +typedef u32 (*acpi_gpe_handler)(acpi_handle, u32, void *); + +typedef void (*acpi_notify_handler)(acpi_handle, u32, void *); + +typedef void (*acpi_object_handler)(acpi_handle, void *); + +typedef acpi_status (*acpi_adr_space_handler)(u32, acpi_physical_address, u32, u64 *, void *, void *); + +typedef acpi_status (*acpi_adr_space_setup)(acpi_handle, u32, void *, void **); + +struct acpi_pci_id { + u16 segment; + u16 bus; + u16 device; + u16 function; +}; + +struct acpi_mem_mapping { + acpi_physical_address physical_address; + u8 *logical_address; + acpi_size length; + struct acpi_mem_mapping *next_mm; +}; + +struct acpi_mem_space_context { + u32 length; + acpi_physical_address address; + struct acpi_mem_mapping *cur_mm; + struct acpi_mem_mapping *first_mm; +}; + +typedef enum { + OSL_GLOBAL_LOCK_HANDLER = 0, + OSL_NOTIFY_HANDLER = 1, + OSL_GPE_HANDLER = 2, + OSL_DEBUGGER_MAIN_THREAD = 3, + OSL_DEBUGGER_EXEC_THREAD = 4, + OSL_EC_POLL_HANDLER = 5, + OSL_EC_BURST_HANDLER = 6, +} acpi_execute_type; + +union acpi_operand_object; + +struct acpi_namespace_node { + union acpi_operand_object *object; + u8 descriptor_type; + u8 type; + u16 flags; + union acpi_name_union name; + struct acpi_namespace_node *parent; + struct acpi_namespace_node *child; + struct acpi_namespace_node *peer; + acpi_owner_id owner_id; +}; + +struct acpi_object_common { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; +}; + +struct acpi_object_integer { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 fill[3]; + u64 value; +}; + +struct acpi_object_string { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + char *pointer; + u32 length; +}; + +struct acpi_object_buffer { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 *pointer; + u32 length; + u32 aml_length; + u8 *aml_start; + struct acpi_namespace_node *node; +}; + +struct acpi_object_package { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + struct acpi_namespace_node *node; + union acpi_operand_object **elements; + u8 *aml_start; + u32 aml_length; + u32 count; +}; + +struct acpi_object_event { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + void *os_semaphore; +}; + +struct acpi_walk_state; + +typedef acpi_status (*acpi_internal_method)(struct acpi_walk_state *); + +struct acpi_object_method { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 info_flags; + u8 param_count; + u8 sync_level; + union acpi_operand_object *mutex; + union acpi_operand_object *node; + u8 *aml_start; + union { + acpi_internal_method implementation; + union acpi_operand_object *handler; + } dispatch; + u32 aml_length; + acpi_owner_id owner_id; + u8 thread_count; +}; + +struct acpi_thread_state; + +struct acpi_object_mutex { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 sync_level; + u16 acquisition_depth; + void *os_mutex; + u64 thread_id; + struct acpi_thread_state *owner_thread; + union acpi_operand_object *prev; + union acpi_operand_object *next; + struct acpi_namespace_node *node; + u8 original_sync_level; +}; + +struct acpi_object_region { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 space_id; + struct acpi_namespace_node *node; + union acpi_operand_object *handler; + union acpi_operand_object *next; + acpi_physical_address address; + u32 length; +}; + +struct acpi_object_notify_common { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + union acpi_operand_object *notify_list[2]; + union acpi_operand_object *handler; +}; + +struct acpi_gpe_block_info; + +struct acpi_object_device { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + union acpi_operand_object *notify_list[2]; + union acpi_operand_object *handler; + struct acpi_gpe_block_info *gpe_block; +}; + +struct acpi_object_power_resource { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + union acpi_operand_object *notify_list[2]; + union acpi_operand_object *handler; + u32 system_level; + u32 resource_order; +}; + +struct acpi_object_processor { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 proc_id; + u8 length; + union acpi_operand_object *notify_list[2]; + union acpi_operand_object *handler; + acpi_io_address address; +}; + +struct acpi_object_thermal_zone { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + union acpi_operand_object *notify_list[2]; + union acpi_operand_object *handler; +}; + +struct acpi_object_field_common { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 field_flags; + u8 attribute; + u8 access_byte_width; + struct acpi_namespace_node *node; + u32 bit_length; + u32 base_byte_offset; + u32 value; + u8 start_field_bit_offset; + u8 access_length; + union acpi_operand_object *region_obj; +}; + +struct acpi_object_region_field { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 field_flags; + u8 attribute; + u8 access_byte_width; + struct acpi_namespace_node *node; + u32 bit_length; + u32 base_byte_offset; + u32 value; + u8 start_field_bit_offset; + u8 access_length; + u16 resource_length; + union acpi_operand_object *region_obj; + u8 *resource_buffer; + u16 pin_number_index; + u8 *internal_pcc_buffer; +}; + +struct acpi_object_buffer_field { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 field_flags; + u8 attribute; + u8 access_byte_width; + struct acpi_namespace_node *node; + u32 bit_length; + u32 base_byte_offset; + u32 value; + u8 start_field_bit_offset; + u8 access_length; + u8 is_create_field; + union acpi_operand_object *buffer_obj; +}; + +struct acpi_object_bank_field { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 field_flags; + u8 attribute; + u8 access_byte_width; + struct acpi_namespace_node *node; + u32 bit_length; + u32 base_byte_offset; + u32 value; + u8 start_field_bit_offset; + u8 access_length; + union acpi_operand_object *region_obj; + union acpi_operand_object *bank_obj; +}; + +struct acpi_object_index_field { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 field_flags; + u8 attribute; + u8 access_byte_width; + struct acpi_namespace_node *node; + u32 bit_length; + u32 base_byte_offset; + u32 value; + u8 start_field_bit_offset; + u8 access_length; + union acpi_operand_object *index_obj; + union acpi_operand_object *data_obj; +}; + +struct acpi_object_notify_handler { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + struct acpi_namespace_node *node; + u32 handler_type; + acpi_notify_handler handler; + void *context; + union acpi_operand_object *next[2]; +}; + +struct acpi_object_addr_handler { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 space_id; + u8 handler_flags; + acpi_adr_space_handler handler; + struct acpi_namespace_node *node; + void *context; + acpi_adr_space_setup setup; + union acpi_operand_object *region_list; + union acpi_operand_object *next; +}; + +struct acpi_object_reference { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + u8 class; + u8 target_type; + u8 resolved; + void *object; + struct acpi_namespace_node *node; + union acpi_operand_object **where; + u8 *index_pointer; + u8 *aml; + u32 value; +}; + +struct acpi_object_extra { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + struct acpi_namespace_node *method_REG; + struct acpi_namespace_node *scope_node; + void *region_context; + u8 *aml_start; + u32 aml_length; +}; + +struct acpi_object_data { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + acpi_object_handler handler; + void *pointer; +}; + +struct acpi_object_cache_list { + union acpi_operand_object *next_object; + u8 descriptor_type; + u8 type; + u16 reference_count; + u8 flags; + union acpi_operand_object *next; +}; + +union acpi_operand_object { + struct acpi_object_common common; + struct acpi_object_integer integer; + struct acpi_object_string string; + struct acpi_object_buffer buffer; + struct acpi_object_package package; + struct acpi_object_event event; + struct acpi_object_method method; + struct acpi_object_mutex mutex; + struct acpi_object_region region; + struct acpi_object_notify_common common_notify; + struct acpi_object_device device; + struct acpi_object_power_resource power_resource; + struct acpi_object_processor processor; + struct acpi_object_thermal_zone thermal_zone; + struct acpi_object_field_common common_field; + struct acpi_object_region_field field; + struct acpi_object_buffer_field buffer_field; + struct acpi_object_bank_field bank_field; + struct acpi_object_index_field index_field; + struct acpi_object_notify_handler notify; + struct acpi_object_addr_handler address_space; + struct acpi_object_reference reference; + struct acpi_object_extra extra; + struct acpi_object_data data; + struct acpi_object_cache_list cache; + struct acpi_namespace_node node; +}; + +union acpi_parse_object; + +union acpi_generic_state; + +struct acpi_parse_state { + u8 *aml_start; + u8 *aml; + u8 *aml_end; + u8 *pkg_start; + u8 *pkg_end; + union acpi_parse_object *start_op; + struct acpi_namespace_node *start_node; + union acpi_generic_state *scope; + union acpi_parse_object *start_scope; + u32 aml_size; +}; + +typedef acpi_status (*acpi_parse_downwards)(struct acpi_walk_state *, union acpi_parse_object **); + +typedef acpi_status (*acpi_parse_upwards)(struct acpi_walk_state *); + +struct acpi_opcode_info; + +struct acpi_walk_state { + struct acpi_walk_state *next; + u8 descriptor_type; + u8 walk_type; + u16 opcode; + u8 next_op_info; + u8 num_operands; + u8 operand_index; + acpi_owner_id owner_id; + u8 last_predicate; + u8 current_result; + u8 return_used; + u8 scope_depth; + u8 pass_number; + u8 namespace_override; + u8 result_size; + u8 result_count; + u8 *aml; + u32 arg_types; + u32 method_breakpoint; + u32 user_breakpoint; + u32 parse_flags; + struct acpi_parse_state parser_state; + u32 prev_arg_types; + u32 arg_count; + u16 method_nesting_depth; + u8 method_is_nested; + struct acpi_namespace_node arguments[7]; + struct acpi_namespace_node local_variables[8]; + union acpi_operand_object *operands[9]; + union acpi_operand_object **params; + u8 *aml_last_while; + union acpi_operand_object **caller_return_desc; + union acpi_generic_state *control_state; + struct acpi_namespace_node *deferred_node; + union acpi_operand_object *implicit_return_obj; + struct acpi_namespace_node *method_call_node; + union acpi_parse_object *method_call_op; + union acpi_operand_object *method_desc; + struct acpi_namespace_node *method_node; + char *method_pathname; + union acpi_parse_object *op; + const struct acpi_opcode_info *op_info; + union acpi_parse_object *origin; + union acpi_operand_object *result_obj; + union acpi_generic_state *results; + union acpi_operand_object *return_desc; + union acpi_generic_state *scope_info; + union acpi_parse_object *prev_op; + union acpi_parse_object *next_op; + struct acpi_thread_state *thread; + acpi_parse_downwards descending_callback; + acpi_parse_upwards ascending_callback; +}; + +struct acpi_gpe_handler_info { + acpi_gpe_handler address; + void *context; + struct acpi_namespace_node *method_node; + u8 original_flags; + u8 originally_enabled; +}; + +struct acpi_gpe_notify_info { + struct acpi_namespace_node *device_node; + struct acpi_gpe_notify_info *next; +}; + +union acpi_gpe_dispatch_info { + struct acpi_namespace_node *method_node; + struct acpi_gpe_handler_info *handler; + struct acpi_gpe_notify_info *notify_list; +}; + +struct acpi_gpe_register_info; + +struct acpi_gpe_event_info { + union acpi_gpe_dispatch_info dispatch; + struct acpi_gpe_register_info *register_info; + u8 flags; + u8 gpe_number; + u8 runtime_count; + u8 disable_for_dispatch; +}; + +struct acpi_gpe_address { + u8 space_id; + u64 address; +}; + +struct acpi_gpe_register_info { + struct acpi_gpe_address status_address; + struct acpi_gpe_address enable_address; + u16 base_gpe_number; + u8 enable_for_wake; + u8 enable_for_run; + u8 mask_for_run; + u8 enable_mask; +}; + +struct acpi_gpe_xrupt_info; + +struct acpi_gpe_block_info { + struct acpi_namespace_node *node; + struct acpi_gpe_block_info *previous; + struct acpi_gpe_block_info *next; + struct acpi_gpe_xrupt_info *xrupt_block; + struct acpi_gpe_register_info *register_info; + struct acpi_gpe_event_info *event_info; + u64 address; + u32 register_count; + u16 gpe_count; + u16 block_base_number; + u8 space_id; + u8 initialized; +}; + +struct acpi_gpe_xrupt_info { + struct acpi_gpe_xrupt_info *previous; + struct acpi_gpe_xrupt_info *next; + struct acpi_gpe_block_info *gpe_block_list_head; + u32 interrupt_number; +}; + +struct acpi_common_state { + void *next; + u8 descriptor_type; + u8 flags; + u16 value; + u16 state; +}; + +struct acpi_update_state { + void *next; + u8 descriptor_type; + u8 flags; + u16 value; + u16 state; + union acpi_operand_object *object; +}; + +struct acpi_pkg_state { + void *next; + u8 descriptor_type; + u8 flags; + u16 value; + u16 state; + u32 index; + union acpi_operand_object *source_object; + union acpi_operand_object *dest_object; + struct acpi_walk_state *walk_state; + void *this_target_obj; + u32 num_packages; +}; + +struct acpi_control_state { + void *next; + u8 descriptor_type; + u8 flags; + u16 value; + u16 state; + u16 opcode; + union acpi_parse_object *predicate_op; + u8 *aml_predicate_start; + u8 *package_end; + u64 loop_timeout; +}; + +union acpi_parse_value { + u64 integer; + u32 size; + char *string; + u8 *buffer; + char *name; + union acpi_parse_object *arg; +}; + +struct acpi_parse_obj_common { + union acpi_parse_object *parent; + u8 descriptor_type; + u8 flags; + u16 aml_opcode; + u8 *aml; + union acpi_parse_object *next; + struct acpi_namespace_node *node; + union acpi_parse_value value; + u8 arg_list_length; +}; + +struct acpi_parse_obj_named { + union acpi_parse_object *parent; + u8 descriptor_type; + u8 flags; + u16 aml_opcode; + u8 *aml; + union acpi_parse_object *next; + struct acpi_namespace_node *node; + union acpi_parse_value value; + u8 arg_list_length; + char *path; + u8 *data; + u32 length; + u32 name; +}; + +struct acpi_parse_obj_asl { + union acpi_parse_object *parent; + u8 descriptor_type; + u8 flags; + u16 aml_opcode; + u8 *aml; + union acpi_parse_object *next; + struct acpi_namespace_node *node; + union acpi_parse_value value; + u8 arg_list_length; + union acpi_parse_object *child; + union acpi_parse_object *parent_method; + char *filename; + u8 file_changed; + char *parent_filename; + char *external_name; + char *namepath; + char name_seg[4]; + u32 extra_value; + u32 column; + u32 line_number; + u32 logical_line_number; + u32 logical_byte_offset; + u32 end_line; + u32 end_logical_line; + u32 acpi_btype; + u32 aml_length; + u32 aml_subtree_length; + u32 final_aml_length; + u32 final_aml_offset; + u32 compile_flags; + u16 parse_opcode; + u8 aml_opcode_length; + u8 aml_pkg_len_bytes; + u8 extra; + char parse_op_name[20]; +}; + +union acpi_parse_object { + struct acpi_parse_obj_common common; + struct acpi_parse_obj_named named; + struct acpi_parse_obj_asl asl; +}; + +struct acpi_scope_state { + void *next; + u8 descriptor_type; + u8 flags; + u16 value; + u16 state; + struct acpi_namespace_node *node; +}; + +struct acpi_pscope_state { + void *next; + u8 descriptor_type; + u8 flags; + u16 value; + u16 state; + u32 arg_count; + union acpi_parse_object *op; + u8 *arg_end; + u8 *pkg_end; + u32 arg_list; +}; + +struct acpi_thread_state { + void *next; + u8 descriptor_type; + u8 flags; + u16 value; + u16 state; + u8 current_sync_level; + struct acpi_walk_state *walk_state_list; + union acpi_operand_object *acquired_mutex_list; + u64 thread_id; +}; + +struct acpi_result_values { + void *next; + u8 descriptor_type; + u8 flags; + u16 value; + u16 state; + union acpi_operand_object *obj_desc[8]; +}; + +struct acpi_global_notify_handler { + acpi_notify_handler handler; + void *context; +}; + +struct acpi_notify_info { + void *next; + u8 descriptor_type; + u8 flags; + u16 value; + u16 state; + u8 handler_list_id; + struct acpi_namespace_node *node; + union acpi_operand_object *handler_list_head; + struct acpi_global_notify_handler *global; +}; + +union acpi_generic_state { + struct acpi_common_state common; + struct acpi_control_state control; + struct acpi_update_state update; + struct acpi_scope_state scope; + struct acpi_pscope_state parse_scope; + struct acpi_pkg_state pkg; + struct acpi_thread_state thread; + struct acpi_result_values results; + struct acpi_notify_info notify; +}; + +struct acpi_opcode_info { + u32 parse_args; + u32 runtime_args; + u16 flags; + u8 object_type; + u8 class; + u8 type; +}; + +struct acpi_os_dpc { + acpi_osd_exec_callback function; + void *context; + struct work_struct work; +}; + +struct acpi_ioremap { + struct list_head list; + void *virt; + acpi_physical_address phys; + acpi_size size; + union { + long unsigned int refcount; + struct rcu_work rwork; + } track; +}; + +struct acpi_hp_work { + struct work_struct work; + struct acpi_device *adev; + u32 src; +}; + +struct acpi_object_list { + u32 count; + union acpi_object *pointer; +}; + +struct acpi_pld_info { + u8 revision; + u8 ignore_color; + u8 red; + u8 green; + u8 blue; + u16 width; + u16 height; + u8 user_visible; + u8 dock; + u8 lid; + u8 panel; + u8 vertical_position; + u8 horizontal_position; + u8 shape; + u8 group_orientation; + u8 group_token; + u8 group_position; + u8 bay; + u8 ejectable; + u8 ospm_eject_required; + u8 cabinet_number; + u8 card_cage_number; + u8 reference; + u8 rotation; + u8 order; + u8 reserved; + u16 vertical_offset; + u16 horizontal_offset; +}; + +struct acpi_handle_list { + u32 count; + acpi_handle handles[10]; +}; + +struct acpi_device_bus_id { + char bus_id[15]; + unsigned int instance_no; + struct list_head node; +}; + +struct acpi_dev_match_info { + struct acpi_device_id hid[2]; + const char *uid; + s64 hrv; +}; + +struct nvs_region { + __u64 phys_start; + __u64 size; + struct list_head node; +}; + +struct nvs_page { + long unsigned int phys_start; + unsigned int size; + void *kaddr; + void *data; + bool unmap; + struct list_head node; +}; + +struct acpi_wakeup_handler { + struct list_head list_node; + bool (*wakeup)(void *); + void *context; +}; + +typedef u32 acpi_event_status; + +struct lpi_device_info { + char *name; + int enabled; + union acpi_object *package; +}; + +struct lpi_device_constraint { + int uid; + int min_dstate; + int function_states; +}; + +struct lpi_constraints { + acpi_handle handle; + int min_dstate; +}; + +struct acpi_hardware_id { + struct list_head list; + const char *id; +}; + +struct acpi_data_node { + const char *name; + acpi_handle handle; + struct fwnode_handle fwnode; + struct fwnode_handle *parent; + struct acpi_device_data data; + struct list_head sibling; + struct kobject kobj; + struct completion kobj_done; +}; + +struct acpi_data_node_attr { + struct attribute attr; + ssize_t (*show)(struct acpi_data_node *, char *); + ssize_t (*store)(struct acpi_data_node *, const char *, size_t); +}; + +struct acpi_device_physical_node { + unsigned int node_id; + struct list_head node; + struct device *dev; + bool put_online: 1; +}; + +enum acpi_bus_device_type { + ACPI_BUS_TYPE_DEVICE = 0, + ACPI_BUS_TYPE_POWER = 1, + ACPI_BUS_TYPE_PROCESSOR = 2, + ACPI_BUS_TYPE_THERMAL = 3, + ACPI_BUS_TYPE_POWER_BUTTON = 4, + ACPI_BUS_TYPE_SLEEP_BUTTON = 5, + ACPI_BUS_TYPE_ECDT_EC = 6, + ACPI_BUS_DEVICE_TYPE_COUNT = 7, +}; + +struct acpi_osc_context { + char *uuid_str; + int rev; + struct acpi_buffer cap; + struct acpi_buffer ret; +}; + +struct acpi_pnp_device_id { + u32 length; + char *string; +}; + +struct acpi_pnp_device_id_list { + u32 count; + u32 list_size; + struct acpi_pnp_device_id ids[0]; +}; + +struct acpi_device_info { + u32 info_size; + u32 name; + acpi_object_type type; + u8 param_count; + u16 valid; + u8 flags; + u8 highest_dstates[4]; + u8 lowest_dstates[5]; + u64 address; + struct acpi_pnp_device_id hardware_id; + struct acpi_pnp_device_id unique_id; + struct acpi_pnp_device_id class_code; + struct acpi_pnp_device_id_list compatible_id_list; +}; + +struct acpi_table_spcr { + struct acpi_table_header header; + u8 interface_type; + u8 reserved[3]; + struct acpi_generic_address serial_port; + u8 interrupt_type; + u8 pc_interrupt; + u32 interrupt; + u8 baud_rate; + u8 parity; + u8 stop_bits; + u8 flow_control; + u8 terminal_type; + u8 reserved1; + u16 pci_device_id; + u16 pci_vendor_id; + u8 pci_bus; + u8 pci_device; + u8 pci_function; + u32 pci_flags; + u8 pci_segment; + u32 reserved2; +} __attribute__((packed)); + +struct acpi_table_stao { + struct acpi_table_header header; + u8 ignore_uart; +} __attribute__((packed)); + +enum acpi_reconfig_event { + ACPI_RECONFIG_DEVICE_ADD = 0, + ACPI_RECONFIG_DEVICE_REMOVE = 1, +}; + +struct acpi_probe_entry; + +typedef bool (*acpi_probe_entry_validate_subtbl)(struct acpi_subtable_header *, struct acpi_probe_entry *); + +struct acpi_probe_entry { + __u8 id[5]; + __u8 type; + acpi_probe_entry_validate_subtbl subtable_valid; + union { + acpi_tbl_table_handler probe_table; + acpi_tbl_entry_handler probe_subtbl; + }; + kernel_ulong_t driver_data; +}; + +struct acpi_dep_data { + struct list_head node; + acpi_handle master; + acpi_handle slave; +}; + +struct acpi_table_events_work { + struct work_struct work; + void *table; + u32 event; +}; + +struct resource_win { + struct resource res; + resource_size_t offset; +}; + +struct res_proc_context { + struct list_head *list; + int (*preproc)(struct acpi_resource *, void *); + void *preproc_data; + int count; + int error; +}; + +struct acpi_processor_errata { + u8 smp; + struct { + u8 throttle: 1; + u8 fdma: 1; + u8 reserved: 6; + u32 bmisx; + } piix4; +}; + +struct acpi_table_ecdt { + struct acpi_table_header header; + struct acpi_generic_address control; + struct acpi_generic_address data; + u32 uid; + u8 gpe; + u8 id[1]; +} __attribute__((packed)); + +struct transaction; + +struct acpi_ec { + acpi_handle handle; + int gpe; + int irq; + long unsigned int command_addr; + long unsigned int data_addr; + bool global_lock; + long unsigned int flags; + long unsigned int reference_count; + struct mutex mutex; + wait_queue_head_t wait; + struct list_head list; + struct transaction *curr; + spinlock_t lock; + struct work_struct work; + long unsigned int timestamp; + long unsigned int nr_pending_queries; + bool busy_polling; + unsigned int polling_guard; +}; + +struct transaction { + const u8 *wdata; + u8 *rdata; + short unsigned int irq_count; + u8 command; + u8 wi; + u8 ri; + u8 wlen; + u8 rlen; + u8 flags; +}; + +typedef int (*acpi_ec_query_func)(void *); + +enum ec_command { + ACPI_EC_COMMAND_READ = 128, + ACPI_EC_COMMAND_WRITE = 129, + ACPI_EC_BURST_ENABLE = 130, + ACPI_EC_BURST_DISABLE = 131, + ACPI_EC_COMMAND_QUERY = 132, +}; + +enum { + EC_FLAGS_QUERY_ENABLED = 0, + EC_FLAGS_QUERY_PENDING = 1, + EC_FLAGS_QUERY_GUARDING = 2, + EC_FLAGS_EVENT_HANDLER_INSTALLED = 3, + EC_FLAGS_EC_HANDLER_INSTALLED = 4, + EC_FLAGS_QUERY_METHODS_INSTALLED = 5, + EC_FLAGS_STARTED = 6, + EC_FLAGS_STOPPED = 7, + EC_FLAGS_EVENTS_MASKED = 8, +}; + +struct acpi_ec_query_handler { + struct list_head node; + acpi_ec_query_func func; + acpi_handle handle; + void *data; + u8 query_bit; + struct kref kref; +}; + +struct acpi_ec_query { + struct transaction transaction; + struct work_struct work; + struct acpi_ec_query_handler *handler; +}; + +struct dock_station { + acpi_handle handle; + long unsigned int last_dock_time; + u32 flags; + struct list_head dependent_devices; + struct list_head sibling; + struct platform_device *dock_device; +}; + +struct dock_dependent_device { + struct list_head list; + struct acpi_device *adev; +}; + +enum dock_callback_type { + DOCK_CALL_HANDLER = 0, + DOCK_CALL_FIXUP = 1, + DOCK_CALL_UEVENT = 2, +}; + +struct acpi_pci_root_ops; + +struct acpi_pci_root_info { + struct acpi_pci_root *root; + struct acpi_device *bridge; + struct acpi_pci_root_ops *ops; + struct list_head resources; + char name[16]; +}; + +struct acpi_pci_root_ops { + struct pci_ops *pci_ops; + int (*init_info)(struct acpi_pci_root_info *); + void (*release_info)(struct acpi_pci_root_info *); + int (*prepare_resources)(struct acpi_pci_root_info *); +}; + +struct pci_osc_bit_struct { + u32 bit; + char *desc; +}; + +struct acpi_handle_node { + struct list_head node; + acpi_handle handle; +}; + +struct acpi_pci_link_irq { + u32 active; + u8 triggering; + u8 polarity; + u8 resource_type; + u8 possible_count; + u32 possible[16]; + u8 initialized: 1; + u8 reserved: 7; +}; + +struct acpi_pci_link { + struct list_head list; + struct acpi_device *device; + struct acpi_pci_link_irq irq; + int refcnt; +}; + +struct acpi_pci_routing_table { + u32 length; + u32 pin; + u64 address; + u32 source_index; + char source[4]; +}; + +struct acpi_prt_entry { + struct acpi_pci_id id; + u8 pin; + acpi_handle link; + u32 index; +}; + +struct prt_quirk { + const struct dmi_system_id *system; + unsigned int segment; + unsigned int bus; + unsigned int device; + unsigned char pin; + const char *source; + const char *actual_source; +}; + +struct apd_private_data; + +struct apd_device_desc { + unsigned int fixed_clk_rate; + struct property_entry *properties; + int (*setup)(struct apd_private_data *); +}; + +struct apd_private_data { + struct clk *clk; + struct acpi_device *adev; + const struct apd_device_desc *dev_desc; +}; + +struct acpi_power_dependent_device { + struct device *dev; + struct list_head node; +}; + +struct acpi_power_resource { + struct acpi_device device; + struct list_head list_node; + char *name; + u32 system_level; + u32 order; + unsigned int ref_count; + bool wakeup_enabled; + struct mutex resource_lock; + struct list_head dependents; +}; + +struct acpi_power_resource_entry { + struct list_head node; + struct acpi_power_resource *resource; +}; + +struct acpi_bus_event { + struct list_head node; + acpi_device_class device_class; + acpi_bus_id bus_id; + u32 type; + u32 data; +}; + +struct acpi_genl_event { + acpi_device_class device_class; + char bus_id[15]; + u32 type; + u32 data; +}; + +enum { + ACPI_GENL_ATTR_UNSPEC = 0, + ACPI_GENL_ATTR_EVENT = 1, + __ACPI_GENL_ATTR_MAX = 2, +}; + +enum { + ACPI_GENL_CMD_UNSPEC = 0, + ACPI_GENL_CMD_EVENT = 1, + __ACPI_GENL_CMD_MAX = 2, +}; + +struct acpi_ged_device { + struct device *dev; + struct list_head event_list; +}; + +struct acpi_ged_event { + struct list_head node; + struct device *dev; + unsigned int gsi; + unsigned int irq; + acpi_handle handle; +}; + +struct acpi_table_bert { + struct acpi_table_header header; + u32 region_length; + u64 address; +}; + +struct acpi_table_attr { + struct bin_attribute attr; + char name[4]; + int instance; + char filename[8]; + struct list_head node; +}; + +struct acpi_data_attr { + struct bin_attribute attr; + u64 addr; +}; + +struct acpi_data_obj { + char *name; + int (*fn)(void *, struct acpi_data_attr *); +}; + +struct event_counter { + u32 count; + u32 flags; +}; + +struct acpi_device_properties { + const guid_t *guid; + const union acpi_object *properties; + struct list_head list; +}; + +struct always_present_id { + struct acpi_device_id hid[2]; + struct x86_cpu_id cpu_ids[2]; + struct dmi_system_id dmi_ids[2]; + const char *uid; +}; + +struct acpi_lpat { + int temp; + int raw; +}; + +struct acpi_lpat_conversion_table { + struct acpi_lpat *lpat; + int lpat_count; +}; + +struct acpi_table_lpit { + struct acpi_table_header header; +}; + +struct acpi_lpit_header { + u32 type; + u32 length; + u16 unique_id; + u16 reserved; + u32 flags; +}; + +struct acpi_lpit_native { + struct acpi_lpit_header header; + struct acpi_generic_address entry_trigger; + u32 residency; + u32 latency; + struct acpi_generic_address residency_counter; + u64 counter_frequency; +} __attribute__((packed)); + +struct lpit_residency_info { + struct acpi_generic_address gaddr; + u64 frequency; + void *iomem_addr; +}; + +enum { + ACPI_REFCLASS_LOCAL = 0, + ACPI_REFCLASS_ARG = 1, + ACPI_REFCLASS_REFOF = 2, + ACPI_REFCLASS_INDEX = 3, + ACPI_REFCLASS_TABLE = 4, + ACPI_REFCLASS_NAME = 5, + ACPI_REFCLASS_DEBUG = 6, + ACPI_REFCLASS_MAX = 6, +}; + +struct acpi_common_descriptor { + void *common_pointer; + u8 descriptor_type; +}; + +union acpi_descriptor { + struct acpi_common_descriptor common; + union acpi_operand_object object; + struct acpi_namespace_node node; + union acpi_parse_object op; +}; + +struct acpi_create_field_info { + struct acpi_namespace_node *region_node; + struct acpi_namespace_node *field_node; + struct acpi_namespace_node *register_node; + struct acpi_namespace_node *data_register_node; + struct acpi_namespace_node *connection_node; + u8 *resource_buffer; + u32 bank_value; + u32 field_bit_position; + u32 field_bit_length; + u16 resource_length; + u16 pin_number_index; + u8 field_flags; + u8 attribute; + u8 field_type; + u8 access_length; +}; + +struct acpi_init_walk_info { + u32 table_index; + u32 object_count; + u32 method_count; + u32 serial_method_count; + u32 non_serial_method_count; + u32 serialized_method_count; + u32 device_count; + u32 op_region_count; + u32 field_count; + u32 buffer_count; + u32 package_count; + u32 op_region_init; + u32 field_init; + u32 buffer_init; + u32 package_init; + acpi_owner_id owner_id; +}; + +typedef u32 acpi_name; + +typedef acpi_status (*acpi_exception_handler)(acpi_status, acpi_name, u16, u32, void *); + +struct acpi_name_info { + char name[4]; + u16 argument_list; + u8 expected_btypes; +} __attribute__((packed)); + +struct acpi_package_info { + u8 type; + u8 object_type1; + u8 count1; + u8 object_type2; + u8 count2; + u16 reserved; +} __attribute__((packed)); + +struct acpi_package_info2 { + u8 type; + u8 count; + u8 object_type[4]; + u8 reserved; +}; + +struct acpi_package_info3 { + u8 type; + u8 count; + u8 object_type[2]; + u8 tail_object_type; + u16 reserved; +} __attribute__((packed)); + +struct acpi_package_info4 { + u8 type; + u8 object_type1; + u8 count1; + u8 sub_object_types; + u8 pkg_count; + u16 reserved; +} __attribute__((packed)); + +union acpi_predefined_info { + struct acpi_name_info info; + struct acpi_package_info ret_info; + struct acpi_package_info2 ret_info2; + struct acpi_package_info3 ret_info3; + struct acpi_package_info4 ret_info4; +}; + +struct acpi_evaluate_info { + struct acpi_namespace_node *prefix_node; + const char *relative_pathname; + union acpi_operand_object **parameters; + struct acpi_namespace_node *node; + union acpi_operand_object *obj_desc; + char *full_pathname; + const union acpi_predefined_info *predefined; + union acpi_operand_object *return_object; + union acpi_operand_object *parent_package; + u32 return_flags; + u32 return_btype; + u16 param_count; + u16 node_flags; + u8 pass_number; + u8 return_object_type; + u8 flags; +}; + +enum { + AML_FIELD_ACCESS_ANY = 0, + AML_FIELD_ACCESS_BYTE = 1, + AML_FIELD_ACCESS_WORD = 2, + AML_FIELD_ACCESS_DWORD = 3, + AML_FIELD_ACCESS_QWORD = 4, + AML_FIELD_ACCESS_BUFFER = 5, +}; + +typedef enum { + ACPI_IMODE_LOAD_PASS1 = 1, + ACPI_IMODE_LOAD_PASS2 = 2, + ACPI_IMODE_EXECUTE = 3, +} acpi_interpreter_mode; + +typedef acpi_status (*acpi_execute_op)(struct acpi_walk_state *); + +typedef void (*acpi_gbl_event_handler)(u32, acpi_handle, u32, void *); + +typedef u32 (*acpi_event_handler)(void *); + +struct acpi_fixed_event_handler { + acpi_event_handler handler; + void *context; +}; + +struct acpi_fixed_event_info { + u8 status_register_id; + u8 enable_register_id; + u16 status_bit_mask; + u16 enable_bit_mask; +}; + +struct acpi_gpe_walk_info { + struct acpi_namespace_node *gpe_device; + struct acpi_gpe_block_info *gpe_block; + u16 count; + acpi_owner_id owner_id; + u8 execute_by_owner_id; +}; + +struct acpi_gpe_device_info { + u32 index; + u32 next_block_base_index; + acpi_status status; + struct acpi_namespace_node *gpe_device; +}; + +typedef acpi_status (*acpi_gpe_callback)(struct acpi_gpe_xrupt_info *, struct acpi_gpe_block_info *, void *); + +struct acpi_table_facs { + char signature[4]; + u32 length; + u32 hardware_signature; + u32 firmware_waking_vector; + u32 global_lock; + u32 flags; + u64 xfirmware_waking_vector; + u8 version; + u8 reserved[3]; + u32 ospm_flags; + u8 reserved1[24]; +}; + +struct acpi_reg_walk_info { + u32 function; + u32 reg_run_count; + acpi_adr_space_type space_id; +}; + +typedef u32 (*acpi_sci_handler)(void *); + +struct acpi_sci_handler_info { + struct acpi_sci_handler_info *next; + acpi_sci_handler address; + void *context; +}; + +enum { + AML_FIELD_UPDATE_PRESERVE = 0, + AML_FIELD_UPDATE_WRITE_AS_ONES = 32, + AML_FIELD_UPDATE_WRITE_AS_ZEROS = 64, +}; + +struct acpi_signal_fatal_info { + u32 type; + u32 code; + u32 argument; +}; + +enum { + MATCH_MTR = 0, + MATCH_MEQ = 1, + MATCH_MLE = 2, + MATCH_MLT = 3, + MATCH_MGE = 4, + MATCH_MGT = 5, +}; + +enum { + AML_FIELD_ATTRIB_QUICK = 2, + AML_FIELD_ATTRIB_SEND_RECEIVE = 4, + AML_FIELD_ATTRIB_BYTE = 6, + AML_FIELD_ATTRIB_WORD = 8, + AML_FIELD_ATTRIB_BLOCK = 10, + AML_FIELD_ATTRIB_BYTES = 11, + AML_FIELD_ATTRIB_PROCESS_CALL = 12, + AML_FIELD_ATTRIB_BLOCK_PROCESS_CALL = 13, + AML_FIELD_ATTRIB_RAW_BYTES = 14, + AML_FIELD_ATTRIB_RAW_PROCESS_BYTES = 15, +}; + +typedef enum { + ACPI_TRACE_AML_METHOD = 0, + ACPI_TRACE_AML_OPCODE = 1, + ACPI_TRACE_AML_REGION = 2, +} acpi_trace_event_type; + +struct acpi_gpe_block_status_context { + struct acpi_gpe_register_info *gpe_skip_register_info; + u8 gpe_skip_mask; + u8 retval; +}; + +struct acpi_bit_register_info { + u8 parent_register; + u8 bit_position; + u16 access_bit_mask; +}; + +struct acpi_port_info { + char *name; + u16 start; + u16 end; + u8 osi_dependency; +}; + +struct acpi_pci_device { + acpi_handle device; + struct acpi_pci_device *next; +}; + +typedef acpi_status (*acpi_init_handler)(acpi_handle, u32); + +struct acpi_device_walk_info { + struct acpi_table_desc *table_desc; + struct acpi_evaluate_info *evaluate_info; + u32 device_count; + u32 num_STA; + u32 num_INI; +}; + +struct acpi_table_list { + struct acpi_table_desc *tables; + u32 current_table_count; + u32 max_table_count; + u8 flags; +}; + +enum acpi_return_package_types { + ACPI_PTYPE1_FIXED = 1, + ACPI_PTYPE1_VAR = 2, + ACPI_PTYPE1_OPTION = 3, + ACPI_PTYPE2 = 4, + ACPI_PTYPE2_COUNT = 5, + ACPI_PTYPE2_PKG_COUNT = 6, + ACPI_PTYPE2_FIXED = 7, + ACPI_PTYPE2_MIN = 8, + ACPI_PTYPE2_REV_FIXED = 9, + ACPI_PTYPE2_FIX_VAR = 10, + ACPI_PTYPE2_VAR_VAR = 11, + ACPI_PTYPE2_UUID_PAIR = 12, + ACPI_PTYPE_CUSTOM = 13, +}; + +typedef acpi_status (*acpi_object_converter)(struct acpi_namespace_node *, union acpi_operand_object *, union acpi_operand_object **); + +struct acpi_simple_repair_info { + char name[4]; + u32 unexpected_btypes; + u32 package_index; + acpi_object_converter object_converter; +}; + +typedef acpi_status (*acpi_repair_function)(struct acpi_evaluate_info *, union acpi_operand_object **); + +struct acpi_repair_info { + char name[4]; + acpi_repair_function repair_function; +}; + +struct acpi_namestring_info { + const char *external_name; + const char *next_external_char; + char *internal_name; + u32 length; + u32 num_segments; + u32 num_carats; + u8 fully_qualified; +}; + +typedef acpi_status (*acpi_walk_callback)(acpi_handle, u32, void *, void **); + +struct acpi_rw_lock { + void *writer_mutex; + void *reader_mutex; + u32 num_readers; +}; + +struct acpi_get_devices_info { + acpi_walk_callback user_function; + void *context; + const char *hid; +}; + +struct aml_resource_small_header { + u8 descriptor_type; +}; + +struct aml_resource_irq { + u8 descriptor_type; + u16 irq_mask; + u8 flags; +} __attribute__((packed)); + +struct aml_resource_dma { + u8 descriptor_type; + u8 dma_channel_mask; + u8 flags; +}; + +struct aml_resource_start_dependent { + u8 descriptor_type; + u8 flags; +}; + +struct aml_resource_end_dependent { + u8 descriptor_type; +}; + +struct aml_resource_io { + u8 descriptor_type; + u8 flags; + u16 minimum; + u16 maximum; + u8 alignment; + u8 address_length; +}; + +struct aml_resource_fixed_io { + u8 descriptor_type; + u16 address; + u8 address_length; +} __attribute__((packed)); + +struct aml_resource_vendor_small { + u8 descriptor_type; +}; + +struct aml_resource_end_tag { + u8 descriptor_type; + u8 checksum; +}; + +struct aml_resource_fixed_dma { + u8 descriptor_type; + u16 request_lines; + u16 channels; + u8 width; +} __attribute__((packed)); + +struct aml_resource_large_header { + u8 descriptor_type; + u16 resource_length; +} __attribute__((packed)); + +struct aml_resource_memory24 { + u8 descriptor_type; + u16 resource_length; + u8 flags; + u16 minimum; + u16 maximum; + u16 alignment; + u16 address_length; +} __attribute__((packed)); + +struct aml_resource_vendor_large { + u8 descriptor_type; + u16 resource_length; +} __attribute__((packed)); + +struct aml_resource_memory32 { + u8 descriptor_type; + u16 resource_length; + u8 flags; + u32 minimum; + u32 maximum; + u32 alignment; + u32 address_length; +} __attribute__((packed)); + +struct aml_resource_fixed_memory32 { + u8 descriptor_type; + u16 resource_length; + u8 flags; + u32 address; + u32 address_length; +} __attribute__((packed)); + +struct aml_resource_address { + u8 descriptor_type; + u16 resource_length; + u8 resource_type; + u8 flags; + u8 specific_flags; +} __attribute__((packed)); + +struct aml_resource_extended_address64 { + u8 descriptor_type; + u16 resource_length; + u8 resource_type; + u8 flags; + u8 specific_flags; + u8 revision_ID; + u8 reserved; + u64 granularity; + u64 minimum; + u64 maximum; + u64 translation_offset; + u64 address_length; + u64 type_specific; +} __attribute__((packed)); + +struct aml_resource_address64 { + u8 descriptor_type; + u16 resource_length; + u8 resource_type; + u8 flags; + u8 specific_flags; + u64 granularity; + u64 minimum; + u64 maximum; + u64 translation_offset; + u64 address_length; +} __attribute__((packed)); + +struct aml_resource_address32 { + u8 descriptor_type; + u16 resource_length; + u8 resource_type; + u8 flags; + u8 specific_flags; + u32 granularity; + u32 minimum; + u32 maximum; + u32 translation_offset; + u32 address_length; +} __attribute__((packed)); + +struct aml_resource_address16 { + u8 descriptor_type; + u16 resource_length; + u8 resource_type; + u8 flags; + u8 specific_flags; + u16 granularity; + u16 minimum; + u16 maximum; + u16 translation_offset; + u16 address_length; +} __attribute__((packed)); + +struct aml_resource_extended_irq { + u8 descriptor_type; + u16 resource_length; + u8 flags; + u8 interrupt_count; + u32 interrupts[1]; +} __attribute__((packed)); + +struct aml_resource_generic_register { + u8 descriptor_type; + u16 resource_length; + u8 address_space_id; + u8 bit_width; + u8 bit_offset; + u8 access_size; + u64 address; +} __attribute__((packed)); + +struct aml_resource_gpio { + u8 descriptor_type; + u16 resource_length; + u8 revision_id; + u8 connection_type; + u16 flags; + u16 int_flags; + u8 pin_config; + u16 drive_strength; + u16 debounce_timeout; + u16 pin_table_offset; + u8 res_source_index; + u16 res_source_offset; + u16 vendor_offset; + u16 vendor_length; +} __attribute__((packed)); + +struct aml_resource_common_serialbus { + u8 descriptor_type; + u16 resource_length; + u8 revision_id; + u8 res_source_index; + u8 type; + u8 flags; + u16 type_specific_flags; + u8 type_revision_id; + u16 type_data_length; +} __attribute__((packed)); + +struct aml_resource_i2c_serialbus { + u8 descriptor_type; + u16 resource_length; + u8 revision_id; + u8 res_source_index; + u8 type; + u8 flags; + u16 type_specific_flags; + u8 type_revision_id; + u16 type_data_length; + u32 connection_speed; + u16 slave_address; +} __attribute__((packed)); + +struct aml_resource_spi_serialbus { + u8 descriptor_type; + u16 resource_length; + u8 revision_id; + u8 res_source_index; + u8 type; + u8 flags; + u16 type_specific_flags; + u8 type_revision_id; + u16 type_data_length; + u32 connection_speed; + u8 data_bit_length; + u8 clock_phase; + u8 clock_polarity; + u16 device_selection; +} __attribute__((packed)); + +struct aml_resource_uart_serialbus { + u8 descriptor_type; + u16 resource_length; + u8 revision_id; + u8 res_source_index; + u8 type; + u8 flags; + u16 type_specific_flags; + u8 type_revision_id; + u16 type_data_length; + u32 default_baud_rate; + u16 rx_fifo_size; + u16 tx_fifo_size; + u8 parity; + u8 lines_enabled; +} __attribute__((packed)); + +struct aml_resource_pin_function { + u8 descriptor_type; + u16 resource_length; + u8 revision_id; + u16 flags; + u8 pin_config; + u16 function_number; + u16 pin_table_offset; + u8 res_source_index; + u16 res_source_offset; + u16 vendor_offset; + u16 vendor_length; +} __attribute__((packed)); + +struct aml_resource_pin_config { + u8 descriptor_type; + u16 resource_length; + u8 revision_id; + u16 flags; + u8 pin_config_type; + u32 pin_config_value; + u16 pin_table_offset; + u8 res_source_index; + u16 res_source_offset; + u16 vendor_offset; + u16 vendor_length; +} __attribute__((packed)); + +struct aml_resource_pin_group { + u8 descriptor_type; + u16 resource_length; + u8 revision_id; + u16 flags; + u16 pin_table_offset; + u16 label_offset; + u16 vendor_offset; + u16 vendor_length; +} __attribute__((packed)); + +struct aml_resource_pin_group_function { + u8 descriptor_type; + u16 resource_length; + u8 revision_id; + u16 flags; + u16 function_number; + u8 res_source_index; + u16 res_source_offset; + u16 res_source_label_offset; + u16 vendor_offset; + u16 vendor_length; +} __attribute__((packed)); + +struct aml_resource_pin_group_config { + u8 descriptor_type; + u16 resource_length; + u8 revision_id; + u16 flags; + u8 pin_config_type; + u32 pin_config_value; + u8 res_source_index; + u16 res_source_offset; + u16 res_source_label_offset; + u16 vendor_offset; + u16 vendor_length; +} __attribute__((packed)); + +union aml_resource { + u8 descriptor_type; + struct aml_resource_small_header small_header; + struct aml_resource_large_header large_header; + struct aml_resource_irq irq; + struct aml_resource_dma dma; + struct aml_resource_start_dependent start_dpf; + struct aml_resource_end_dependent end_dpf; + struct aml_resource_io io; + struct aml_resource_fixed_io fixed_io; + struct aml_resource_fixed_dma fixed_dma; + struct aml_resource_vendor_small vendor_small; + struct aml_resource_end_tag end_tag; + struct aml_resource_memory24 memory24; + struct aml_resource_generic_register generic_reg; + struct aml_resource_vendor_large vendor_large; + struct aml_resource_memory32 memory32; + struct aml_resource_fixed_memory32 fixed_memory32; + struct aml_resource_address16 address16; + struct aml_resource_address32 address32; + struct aml_resource_address64 address64; + struct aml_resource_extended_address64 ext_address64; + struct aml_resource_extended_irq extended_irq; + struct aml_resource_gpio gpio; + struct aml_resource_i2c_serialbus i2c_serial_bus; + struct aml_resource_spi_serialbus spi_serial_bus; + struct aml_resource_uart_serialbus uart_serial_bus; + struct aml_resource_common_serialbus common_serial_bus; + struct aml_resource_pin_function pin_function; + struct aml_resource_pin_config pin_config; + struct aml_resource_pin_group pin_group; + struct aml_resource_pin_group_function pin_group_function; + struct aml_resource_pin_group_config pin_group_config; + struct aml_resource_address address; + u32 dword_item; + u16 word_item; + u8 byte_item; +}; + +struct acpi_rsconvert_info { + u8 opcode; + u8 resource_offset; + u8 aml_offset; + u8 value; +}; + +enum { + ACPI_RSC_INITGET = 0, + ACPI_RSC_INITSET = 1, + ACPI_RSC_FLAGINIT = 2, + ACPI_RSC_1BITFLAG = 3, + ACPI_RSC_2BITFLAG = 4, + ACPI_RSC_3BITFLAG = 5, + ACPI_RSC_ADDRESS = 6, + ACPI_RSC_BITMASK = 7, + ACPI_RSC_BITMASK16 = 8, + ACPI_RSC_COUNT = 9, + ACPI_RSC_COUNT16 = 10, + ACPI_RSC_COUNT_GPIO_PIN = 11, + ACPI_RSC_COUNT_GPIO_RES = 12, + ACPI_RSC_COUNT_GPIO_VEN = 13, + ACPI_RSC_COUNT_SERIAL_RES = 14, + ACPI_RSC_COUNT_SERIAL_VEN = 15, + ACPI_RSC_DATA8 = 16, + ACPI_RSC_EXIT_EQ = 17, + ACPI_RSC_EXIT_LE = 18, + ACPI_RSC_EXIT_NE = 19, + ACPI_RSC_LENGTH = 20, + ACPI_RSC_MOVE_GPIO_PIN = 21, + ACPI_RSC_MOVE_GPIO_RES = 22, + ACPI_RSC_MOVE_SERIAL_RES = 23, + ACPI_RSC_MOVE_SERIAL_VEN = 24, + ACPI_RSC_MOVE8 = 25, + ACPI_RSC_MOVE16 = 26, + ACPI_RSC_MOVE32 = 27, + ACPI_RSC_MOVE64 = 28, + ACPI_RSC_SET8 = 29, + ACPI_RSC_SOURCE = 30, + ACPI_RSC_SOURCEX = 31, +}; + +typedef u16 acpi_rs_length; + +typedef u32 acpi_rsdesc_size; + +struct acpi_vendor_uuid { + u8 subtype; + u8 data[16]; +}; + +typedef acpi_status (*acpi_walk_resource_callback)(struct acpi_resource *, void *); + +struct acpi_vendor_walk_info { + struct acpi_vendor_uuid *uuid; + struct acpi_buffer *buffer; + acpi_status status; +}; + +typedef acpi_status (*acpi_table_handler)(u32, void *, void *); + +struct acpi_fadt_info { + const char *name; + u16 address64; + u16 address32; + u16 length; + u8 default_length; + u8 flags; +}; + +struct acpi_fadt_pm_info { + struct acpi_generic_address *target; + u16 source; + u8 register_num; +}; + +struct acpi_table_rsdp { + char signature[8]; + u8 checksum; + char oem_id[6]; + u8 revision; + u32 rsdt_physical_address; + u32 length; + u64 xsdt_physical_address; + u8 extended_checksum; + u8 reserved[3]; +} __attribute__((packed)); + +struct acpi_address_range { + struct acpi_address_range *next; + struct acpi_namespace_node *region_node; + acpi_physical_address start_address; + acpi_physical_address end_address; +}; + +struct acpi_pkg_info { + u8 *free_space; + acpi_size length; + u32 object_space; + u32 num_packages; +}; + +struct acpi_exception_info { + char *name; +}; + +typedef u32 (*acpi_interface_handler)(acpi_string, u32); + +struct acpi_mutex_info { + void *mutex; + u32 use_count; + u64 thread_id; +}; + +struct acpi_comment_node { + char *comment; + struct acpi_comment_node *next; +}; + +struct acpi_interface_info { + char *name; + struct acpi_interface_info *next; + u8 flags; + u8 value; +}; + +typedef acpi_status (*acpi_pkg_callback)(u8, union acpi_operand_object *, union acpi_generic_state *, void *); + +typedef u32 acpi_mutex_handle; + +typedef acpi_status (*acpi_walk_aml_callback)(u8 *, u32, u32, u8, void **); + +struct acpi_fan_fps { + u64 control; + u64 trip_point; + u64 speed; + u64 noise_level; + u64 power; + char name[20]; + struct device_attribute dev_attr; +}; + +struct acpi_fan_fif { + u64 revision; + u64 fine_grain_ctrl; + u64 step_size; + u64 low_speed_notification; +}; + +struct acpi_fan { + bool acpi4; + struct acpi_fan_fif fif; + struct acpi_fan_fps *fps; + int fps_count; + struct thermal_cooling_device *cdev; +}; + +struct acpi_lpi_states_array { + unsigned int size; + unsigned int composite_states_size; + struct acpi_lpi_state *entries; + struct acpi_lpi_state *composite_states[8]; +}; + +struct throttling_tstate { + unsigned int cpu; + int target_state; +}; + +struct acpi_processor_throttling_arg { + struct acpi_processor *pr; + int target_state; + bool force; +}; + +struct container_dev { + struct device dev; + int (*offline)(struct container_dev *); +}; + +enum thermal_device_mode { + THERMAL_DEVICE_DISABLED = 0, + THERMAL_DEVICE_ENABLED = 1, +}; + +enum thermal_trip_type { + THERMAL_TRIP_ACTIVE = 0, + THERMAL_TRIP_PASSIVE = 1, + THERMAL_TRIP_HOT = 2, + THERMAL_TRIP_CRITICAL = 3, +}; + +enum thermal_trend { + THERMAL_TREND_STABLE = 0, + THERMAL_TREND_RAISING = 1, + THERMAL_TREND_DROPPING = 2, + THERMAL_TREND_RAISE_FULL = 3, + THERMAL_TREND_DROP_FULL = 4, +}; + +enum thermal_notify_event { + THERMAL_EVENT_UNSPECIFIED = 0, + THERMAL_EVENT_TEMP_SAMPLE = 1, + THERMAL_TRIP_VIOLATED = 2, + THERMAL_TRIP_CHANGED = 3, + THERMAL_DEVICE_DOWN = 4, + THERMAL_DEVICE_UP = 5, + THERMAL_DEVICE_POWER_CAPABILITY_CHANGED = 6, + THERMAL_TABLE_CHANGED = 7, + THERMAL_EVENT_KEEP_ALIVE = 8, +}; + +struct thermal_zone_device; + +struct thermal_zone_device_ops { + int (*bind)(struct thermal_zone_device *, struct thermal_cooling_device *); + int (*unbind)(struct thermal_zone_device *, struct thermal_cooling_device *); + int (*get_temp)(struct thermal_zone_device *, int *); + int (*set_trips)(struct thermal_zone_device *, int, int); + int (*change_mode)(struct thermal_zone_device *, enum thermal_device_mode); + int (*get_trip_type)(struct thermal_zone_device *, int, enum thermal_trip_type *); + int (*get_trip_temp)(struct thermal_zone_device *, int, int *); + int (*set_trip_temp)(struct thermal_zone_device *, int, int); + int (*get_trip_hyst)(struct thermal_zone_device *, int, int *); + int (*set_trip_hyst)(struct thermal_zone_device *, int, int); + int (*get_crit_temp)(struct thermal_zone_device *, int *); + int (*set_emul_temp)(struct thermal_zone_device *, int); + int (*get_trend)(struct thermal_zone_device *, int, enum thermal_trend *); + int (*notify)(struct thermal_zone_device *, int, enum thermal_trip_type); +}; + +struct thermal_attr; + +struct thermal_zone_params; + +struct thermal_governor; + +struct thermal_zone_device { + int id; + char type[20]; + struct device device; + struct attribute_group trips_attribute_group; + struct thermal_attr *trip_temp_attrs; + struct thermal_attr *trip_type_attrs; + struct thermal_attr *trip_hyst_attrs; + enum thermal_device_mode mode; + void *devdata; + int trips; + long unsigned int trips_disabled; + int passive_delay; + int polling_delay; + int temperature; + int last_temperature; + int emul_temperature; + int passive; + int prev_low_trip; + int prev_high_trip; + unsigned int forced_passive; + atomic_t need_update; + struct thermal_zone_device_ops *ops; + struct thermal_zone_params *tzp; + struct thermal_governor *governor; + void *governor_data; + struct list_head thermal_instances; + struct ida ida; + struct mutex lock; + struct list_head node; + struct delayed_work poll_queue; + enum thermal_notify_event notify_event; +}; + +struct thermal_bind_params; + +struct thermal_zone_params { + char governor_name[20]; + bool no_hwmon; + int num_tbps; + struct thermal_bind_params *tbp; + u32 sustainable_power; + s32 k_po; + s32 k_pu; + s32 k_i; + s32 k_d; + s32 integral_cutoff; + int slope; + int offset; +}; + +struct thermal_governor { + char name[20]; + int (*bind_to_tz)(struct thermal_zone_device *); + void (*unbind_from_tz)(struct thermal_zone_device *); + int (*throttle)(struct thermal_zone_device *, int); + struct list_head governor_list; +}; + +struct thermal_bind_params { + struct thermal_cooling_device *cdev; + int weight; + int trip_mask; + long unsigned int *binding_limits; + int (*match)(struct thermal_zone_device *, struct thermal_cooling_device *); +}; + +struct acpi_thermal_state { + u8 critical: 1; + u8 hot: 1; + u8 passive: 1; + u8 active: 1; + u8 reserved: 4; + int active_index; +}; + +struct acpi_thermal_state_flags { + u8 valid: 1; + u8 enabled: 1; + u8 reserved: 6; +}; + +struct acpi_thermal_critical { + struct acpi_thermal_state_flags flags; + long unsigned int temperature; +}; + +struct acpi_thermal_hot { + struct acpi_thermal_state_flags flags; + long unsigned int temperature; +}; + +struct acpi_thermal_passive { + struct acpi_thermal_state_flags flags; + long unsigned int temperature; + long unsigned int tc1; + long unsigned int tc2; + long unsigned int tsp; + struct acpi_handle_list devices; +}; + +struct acpi_thermal_active { + struct acpi_thermal_state_flags flags; + long unsigned int temperature; + struct acpi_handle_list devices; +}; + +struct acpi_thermal_trips { + struct acpi_thermal_critical critical; + struct acpi_thermal_hot hot; + struct acpi_thermal_passive passive; + struct acpi_thermal_active active[10]; +}; + +struct acpi_thermal_flags { + u8 cooling_mode: 1; + u8 devices: 1; + u8 reserved: 6; +}; + +struct acpi_thermal { + struct acpi_device *device; + acpi_bus_id name; + long unsigned int temperature; + long unsigned int last_temperature; + long unsigned int polling_frequency; + volatile u8 zombie; + struct acpi_thermal_flags flags; + struct acpi_thermal_state state; + struct acpi_thermal_trips trips; + struct acpi_handle_list devices; + struct thermal_zone_device *thermal_zone; + int kelvin_offset; + struct work_struct thermal_check_work; +}; + +struct acpi_table_slit { + struct acpi_table_header header; + u64 locality_count; + u8 entry[1]; +} __attribute__((packed)); + +struct acpi_table_srat { + struct acpi_table_header header; + u32 table_revision; + u64 reserved; +}; + +enum acpi_srat_type { + ACPI_SRAT_TYPE_CPU_AFFINITY = 0, + ACPI_SRAT_TYPE_MEMORY_AFFINITY = 1, + ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY = 2, + ACPI_SRAT_TYPE_GICC_AFFINITY = 3, + ACPI_SRAT_TYPE_GIC_ITS_AFFINITY = 4, + ACPI_SRAT_TYPE_GENERIC_AFFINITY = 5, + ACPI_SRAT_TYPE_RESERVED = 6, +}; + +struct acpi_srat_mem_affinity { + struct acpi_subtable_header header; + u32 proximity_domain; + u16 reserved; + u64 base_address; + u64 length; + u32 reserved1; + u32 flags; + u64 reserved2; +} __attribute__((packed)); + +struct acpi_srat_gicc_affinity { + struct acpi_subtable_header header; + u32 proximity_domain; + u32 acpi_processor_uid; + u32 flags; + u32 clock_domain; +} __attribute__((packed)); + +struct acpi_srat_generic_affinity { + struct acpi_subtable_header header; + u8 reserved; + u8 device_handle_type; + u32 proximity_domain; + u8 device_handle[16]; + u32 flags; + u32 reserved1; +}; + +struct acpi_pci_ioapic { + acpi_handle root_handle; + acpi_handle handle; + u32 gsi_base; + struct resource res; + struct pci_dev *pdev; + struct list_head list; +}; + +struct acpi_pcct_hw_reduced { + struct acpi_subtable_header header; + u32 platform_interrupt; + u8 flags; + u8 reserved; + u64 base_address; + u64 length; + struct acpi_generic_address doorbell_register; + u64 preserve_mask; + u64 write_mask; + u32 latency; + u32 max_access_rate; + u16 min_turnaround_time; +} __attribute__((packed)); + +struct acpi_pcct_shared_memory { + u32 signature; + u16 command; + u16 status; +}; + +struct mbox_chan; + +struct mbox_chan_ops { + int (*send_data)(struct mbox_chan *, void *); + int (*flush)(struct mbox_chan *, long unsigned int); + int (*startup)(struct mbox_chan *); + void (*shutdown)(struct mbox_chan *); + bool (*last_tx_done)(struct mbox_chan *); + bool (*peek_data)(struct mbox_chan *); +}; + +struct mbox_controller; + +struct mbox_client; + +struct mbox_chan { + struct mbox_controller *mbox; + unsigned int txdone_method; + struct mbox_client *cl; + struct completion tx_complete; + void *active_req; + unsigned int msg_count; + unsigned int msg_free; + void *msg_data[20]; + spinlock_t lock; + void *con_priv; +}; + +struct mbox_controller { + struct device *dev; + const struct mbox_chan_ops *ops; + struct mbox_chan *chans; + int num_chans; + bool txdone_irq; + bool txdone_poll; + unsigned int txpoll_period; + struct mbox_chan * (*of_xlate)(struct mbox_controller *, const struct of_phandle_args *); + struct hrtimer poll_hrt; + struct list_head node; +}; + +struct mbox_client { + struct device *dev; + bool tx_block; + long unsigned int tx_tout; + bool knows_txdone; + void (*rx_callback)(struct mbox_client *, void *); + void (*tx_prepare)(struct mbox_client *, void *); + void (*tx_done)(struct mbox_client *, void *, int); +}; + +struct cpc_register_resource { + acpi_object_type type; + u64 *sys_mem_vaddr; + union { + struct cpc_reg reg; + u64 int_value; + } cpc_entry; +}; + +struct cpc_desc { + int num_entries; + int version; + int cpu_id; + int write_cmd_status; + int write_cmd_id; + struct cpc_register_resource cpc_regs[21]; + struct acpi_psd_package domain_info; + struct kobject kobj; +}; + +enum cppc_regs { + HIGHEST_PERF = 0, + NOMINAL_PERF = 1, + LOW_NON_LINEAR_PERF = 2, + LOWEST_PERF = 3, + GUARANTEED_PERF = 4, + DESIRED_PERF = 5, + MIN_PERF = 6, + MAX_PERF = 7, + PERF_REDUC_TOLERANCE = 8, + TIME_WINDOW = 9, + CTR_WRAP_TIME = 10, + REFERENCE_CTR = 11, + DELIVERED_CTR = 12, + PERF_LIMITED = 13, + ENABLE = 14, + AUTO_SEL_ENABLE = 15, + AUTO_ACT_WINDOW = 16, + ENERGY_PERF = 17, + REFERENCE_PERF = 18, + LOWEST_FREQ = 19, + NOMINAL_FREQ = 20, +}; + +struct cppc_perf_caps { + u32 guaranteed_perf; + u32 highest_perf; + u32 nominal_perf; + u32 lowest_perf; + u32 lowest_nonlinear_perf; + u32 lowest_freq; + u32 nominal_freq; +}; + +struct cppc_perf_ctrls { + u32 max_perf; + u32 min_perf; + u32 desired_perf; +}; + +struct cppc_perf_fb_ctrs { + u64 reference; + u64 delivered; + u64 reference_perf; + u64 wraparound_time; +}; + +struct cppc_cpudata { + int cpu; + struct cppc_perf_caps perf_caps; + struct cppc_perf_ctrls perf_ctrls; + struct cppc_perf_fb_ctrs perf_fb_ctrs; + struct cpufreq_policy *cur_policy; + unsigned int shared_type; + cpumask_var_t shared_cpu_map; +}; + +struct cppc_pcc_data { + struct mbox_chan *pcc_channel; + void *pcc_comm_addr; + bool pcc_channel_acquired; + unsigned int deadline_us; + unsigned int pcc_mpar; + unsigned int pcc_mrtt; + unsigned int pcc_nominal; + bool pending_pcc_write_cmd; + bool platform_owns_pcc; + unsigned int pcc_write_cnt; + struct rw_semaphore pcc_lock; + wait_queue_head_t pcc_write_wait_q; + ktime_t last_cmd_cmpl_time; + ktime_t last_mpar_reset; + int mpar_count; + int refcount; +}; + +struct cppc_attr { + struct attribute attr; + ssize_t (*show)(struct kobject *, struct attribute *, char *); + ssize_t (*store)(struct kobject *, struct attribute *, const char *, ssize_t); +}; + +struct pnp_resource { + struct list_head list; + struct resource res; +}; + +struct pnp_port { + resource_size_t min; + resource_size_t max; + resource_size_t align; + resource_size_t size; + unsigned char flags; +}; + +typedef struct { + long unsigned int bits[4]; +} pnp_irq_mask_t; + +struct pnp_irq { + pnp_irq_mask_t map; + unsigned char flags; +}; + +struct pnp_dma { + unsigned char map; + unsigned char flags; +}; + +struct pnp_mem { + resource_size_t min; + resource_size_t max; + resource_size_t align; + resource_size_t size; + unsigned char flags; +}; + +struct pnp_option { + struct list_head list; + unsigned int flags; + long unsigned int type; + union { + struct pnp_port port; + struct pnp_irq irq; + struct pnp_dma dma; + struct pnp_mem mem; + } u; +}; + +struct pnp_info_buffer { + char *buffer; + char *curr; + long unsigned int size; + long unsigned int len; + int stop; + int error; +}; + +typedef struct pnp_info_buffer pnp_info_buffer_t; + +struct pnp_fixup { + char id[7]; + void (*quirk_function)(struct pnp_dev *); +}; + +struct acpipnp_parse_option_s { + struct pnp_dev *dev; + unsigned int option_flags; +}; + +struct clk_bulk_data { + const char *id; + struct clk *clk; +}; + +struct clk_bulk_devres { + struct clk_bulk_data *clks; + int num_clks; +}; + +struct clk_hw; + +struct clk_lookup { + struct list_head node; + const char *dev_id; + const char *con_id; + struct clk *clk; + struct clk_hw *clk_hw; +}; + +struct clk_core; + +struct clk_init_data; + +struct clk_hw { + struct clk_core *core; + struct clk *clk; + const struct clk_init_data *init; +}; + +struct clk_rate_request { + long unsigned int rate; + long unsigned int min_rate; + long unsigned int max_rate; + long unsigned int best_parent_rate; + struct clk_hw *best_parent_hw; +}; + +struct clk_duty { + unsigned int num; + unsigned int den; +}; + +struct clk_ops { + int (*prepare)(struct clk_hw *); + void (*unprepare)(struct clk_hw *); + int (*is_prepared)(struct clk_hw *); + void (*unprepare_unused)(struct clk_hw *); + int (*enable)(struct clk_hw *); + void (*disable)(struct clk_hw *); + int (*is_enabled)(struct clk_hw *); + void (*disable_unused)(struct clk_hw *); + int (*save_context)(struct clk_hw *); + void (*restore_context)(struct clk_hw *); + long unsigned int (*recalc_rate)(struct clk_hw *, long unsigned int); + long int (*round_rate)(struct clk_hw *, long unsigned int, long unsigned int *); + int (*determine_rate)(struct clk_hw *, struct clk_rate_request *); + int (*set_parent)(struct clk_hw *, u8); + u8 (*get_parent)(struct clk_hw *); + int (*set_rate)(struct clk_hw *, long unsigned int, long unsigned int); + int (*set_rate_and_parent)(struct clk_hw *, long unsigned int, long unsigned int, u8); + long unsigned int (*recalc_accuracy)(struct clk_hw *, long unsigned int); + int (*get_phase)(struct clk_hw *); + int (*set_phase)(struct clk_hw *, int); + int (*get_duty_cycle)(struct clk_hw *, struct clk_duty *); + int (*set_duty_cycle)(struct clk_hw *, struct clk_duty *); + int (*init)(struct clk_hw *); + void (*terminate)(struct clk_hw *); + void (*debug_init)(struct clk_hw *, struct dentry *); +}; + +struct clk_parent_data { + const struct clk_hw *hw; + const char *fw_name; + const char *name; + int index; +}; + +struct clk_init_data { + const char *name; + const struct clk_ops *ops; + const char * const *parent_names; + const struct clk_parent_data *parent_data; + const struct clk_hw **parent_hws; + u8 num_parents; + long unsigned int flags; +}; + +struct clk_lookup_alloc { + struct clk_lookup cl; + char dev_id[20]; + char con_id[16]; +}; + +struct clk_notifier { + struct clk *clk; + struct srcu_notifier_head notifier_head; + struct list_head node; +}; + +struct clk { + struct clk_core *core; + struct device *dev; + const char *dev_id; + const char *con_id; + long unsigned int min_rate; + long unsigned int max_rate; + unsigned int exclusive_count; + struct hlist_node clks_node; +}; + +struct clk_notifier_data { + struct clk *clk; + long unsigned int old_rate; + long unsigned int new_rate; +}; + +struct clk_parent_map; + +struct clk_core { + const char *name; + const struct clk_ops *ops; + struct clk_hw *hw; + struct module *owner; + struct device *dev; + struct device_node *of_node; + struct clk_core *parent; + struct clk_parent_map *parents; + u8 num_parents; + u8 new_parent_index; + long unsigned int rate; + long unsigned int req_rate; + long unsigned int new_rate; + struct clk_core *new_parent; + struct clk_core *new_child; + long unsigned int flags; + bool orphan; + bool rpm_enabled; + unsigned int enable_count; + unsigned int prepare_count; + unsigned int protect_count; + long unsigned int min_rate; + long unsigned int max_rate; + long unsigned int accuracy; + int phase; + struct clk_duty duty; + struct hlist_head children; + struct hlist_node child_node; + struct hlist_head clks; + unsigned int notifier_count; + struct dentry *dentry; + struct hlist_node debug_node; + struct kref ref; +}; + +struct clk_parent_map { + const struct clk_hw *hw; + struct clk_core *core; + const char *fw_name; + const char *name; + int index; +}; + +struct trace_event_raw_clk { + struct trace_entry ent; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_clk_rate { + struct trace_entry ent; + u32 __data_loc_name; + long unsigned int rate; + char __data[0]; +}; + +struct trace_event_raw_clk_parent { + struct trace_entry ent; + u32 __data_loc_name; + u32 __data_loc_pname; + char __data[0]; +}; + +struct trace_event_raw_clk_phase { + struct trace_entry ent; + u32 __data_loc_name; + int phase; + char __data[0]; +}; + +struct trace_event_raw_clk_duty_cycle { + struct trace_entry ent; + u32 __data_loc_name; + unsigned int num; + unsigned int den; + char __data[0]; +}; + +struct trace_event_data_offsets_clk { + u32 name; +}; + +struct trace_event_data_offsets_clk_rate { + u32 name; +}; + +struct trace_event_data_offsets_clk_parent { + u32 name; + u32 pname; +}; + +struct trace_event_data_offsets_clk_phase { + u32 name; +}; + +struct trace_event_data_offsets_clk_duty_cycle { + u32 name; +}; + +typedef void (*btf_trace_clk_enable)(void *, struct clk_core *); + +typedef void (*btf_trace_clk_enable_complete)(void *, struct clk_core *); + +typedef void (*btf_trace_clk_disable)(void *, struct clk_core *); + +typedef void (*btf_trace_clk_disable_complete)(void *, struct clk_core *); + +typedef void (*btf_trace_clk_prepare)(void *, struct clk_core *); + +typedef void (*btf_trace_clk_prepare_complete)(void *, struct clk_core *); + +typedef void (*btf_trace_clk_unprepare)(void *, struct clk_core *); + +typedef void (*btf_trace_clk_unprepare_complete)(void *, struct clk_core *); + +typedef void (*btf_trace_clk_set_rate)(void *, struct clk_core *, long unsigned int); + +typedef void (*btf_trace_clk_set_rate_complete)(void *, struct clk_core *, long unsigned int); + +typedef void (*btf_trace_clk_set_parent)(void *, struct clk_core *, struct clk_core *); + +typedef void (*btf_trace_clk_set_parent_complete)(void *, struct clk_core *, struct clk_core *); + +typedef void (*btf_trace_clk_set_phase)(void *, struct clk_core *, int); + +typedef void (*btf_trace_clk_set_phase_complete)(void *, struct clk_core *, int); + +typedef void (*btf_trace_clk_set_duty_cycle)(void *, struct clk_core *, struct clk_duty *); + +typedef void (*btf_trace_clk_set_duty_cycle_complete)(void *, struct clk_core *, struct clk_duty *); + +struct clk_div_table { + unsigned int val; + unsigned int div; +}; + +struct clk_divider { + struct clk_hw hw; + void *reg; + u8 shift; + u8 width; + u8 flags; + const struct clk_div_table *table; + spinlock_t *lock; +}; + +struct clk_fixed_factor { + struct clk_hw hw; + unsigned int mult; + unsigned int div; +}; + +struct clk_fixed_rate { + struct clk_hw hw; + long unsigned int fixed_rate; + long unsigned int fixed_accuracy; + long unsigned int flags; +}; + +struct clk_gate { + struct clk_hw hw; + void *reg; + u8 bit_idx; + u8 flags; + spinlock_t *lock; +}; + +struct clk_multiplier { + struct clk_hw hw; + void *reg; + u8 shift; + u8 width; + u8 flags; + spinlock_t *lock; +}; + +struct clk_mux { + struct clk_hw hw; + void *reg; + u32 *table; + u32 mask; + u8 shift; + u8 flags; + spinlock_t *lock; +}; + +struct clk_composite { + struct clk_hw hw; + struct clk_ops ops; + struct clk_hw *mux_hw; + struct clk_hw *rate_hw; + struct clk_hw *gate_hw; + const struct clk_ops *mux_ops; + const struct clk_ops *rate_ops; + const struct clk_ops *gate_ops; +}; + +struct clk_fractional_divider { + struct clk_hw hw; + void *reg; + u8 mshift; + u8 mwidth; + u32 mmask; + u8 nshift; + u8 nwidth; + u32 nmask; + u8 flags; + void (*approximation)(struct clk_hw *, long unsigned int, long unsigned int *, long unsigned int *, long unsigned int *); + spinlock_t *lock; +}; + +struct gpio_desc___2; + +struct clk_gpio { + struct clk_hw hw; + struct gpio_desc___2 *gpiod; +}; + +struct pmc_clk { + const char *name; + long unsigned int freq; + const char *parent_name; +}; + +struct pmc_clk_data { + void *base; + const struct pmc_clk *clks; + bool critical; +}; + +struct clk_plt_fixed { + struct clk_hw *clk; + struct clk_lookup *lookup; +}; + +struct clk_plt { + struct clk_hw hw; + void *reg; + struct clk_lookup *lookup; + spinlock_t lock; +}; + +struct clk_plt_data { + struct clk_plt_fixed **parents; + u8 nparents; + struct clk_plt *clks[6]; + struct clk_lookup *mclk_lookup; + struct clk_lookup *ether_clk_lookup; +}; + +typedef s32 dma_cookie_t; + +enum dma_status { + DMA_COMPLETE = 0, + DMA_IN_PROGRESS = 1, + DMA_PAUSED = 2, + DMA_ERROR = 3, + DMA_OUT_OF_ORDER = 4, +}; + +enum dma_transaction_type { + DMA_MEMCPY = 0, + DMA_XOR = 1, + DMA_PQ = 2, + DMA_XOR_VAL = 3, + DMA_PQ_VAL = 4, + DMA_MEMSET = 5, + DMA_MEMSET_SG = 6, + DMA_INTERRUPT = 7, + DMA_PRIVATE = 8, + DMA_ASYNC_TX = 9, + DMA_SLAVE = 10, + DMA_CYCLIC = 11, + DMA_INTERLEAVE = 12, + DMA_COMPLETION_NO_ORDER = 13, + DMA_REPEAT = 14, + DMA_LOAD_EOT = 15, + DMA_TX_TYPE_END = 16, +}; + +enum dma_transfer_direction { + DMA_MEM_TO_MEM = 0, + DMA_MEM_TO_DEV = 1, + DMA_DEV_TO_MEM = 2, + DMA_DEV_TO_DEV = 3, + DMA_TRANS_NONE = 4, +}; + +struct data_chunk { + size_t size; + size_t icg; + size_t dst_icg; + size_t src_icg; +}; + +struct dma_interleaved_template { + dma_addr_t src_start; + dma_addr_t dst_start; + enum dma_transfer_direction dir; + bool src_inc; + bool dst_inc; + bool src_sgl; + bool dst_sgl; + size_t numf; + size_t frame_size; + struct data_chunk sgl[0]; +}; + +enum dma_ctrl_flags { + DMA_PREP_INTERRUPT = 1, + DMA_CTRL_ACK = 2, + DMA_PREP_PQ_DISABLE_P = 4, + DMA_PREP_PQ_DISABLE_Q = 8, + DMA_PREP_CONTINUE = 16, + DMA_PREP_FENCE = 32, + DMA_CTRL_REUSE = 64, + DMA_PREP_CMD = 128, + DMA_PREP_REPEAT = 256, + DMA_PREP_LOAD_EOT = 512, +}; + +enum sum_check_bits { + SUM_CHECK_P = 0, + SUM_CHECK_Q = 1, +}; + +enum sum_check_flags { + SUM_CHECK_P_RESULT = 1, + SUM_CHECK_Q_RESULT = 2, +}; + +typedef struct { + long unsigned int bits[1]; +} dma_cap_mask_t; + +enum dma_desc_metadata_mode { + DESC_METADATA_NONE = 0, + DESC_METADATA_CLIENT = 1, + DESC_METADATA_ENGINE = 2, +}; + +struct dma_chan_percpu { + long unsigned int memcpy_count; + long unsigned int bytes_transferred; +}; + +struct dma_router { + struct device *dev; + void (*route_free)(struct device *, void *); +}; + +struct dma_device; + +struct dma_chan_dev; + +struct dma_chan___2 { + struct dma_device *device; + struct device *slave; + dma_cookie_t cookie; + dma_cookie_t completed_cookie; + int chan_id; + struct dma_chan_dev *dev; + const char *name; + char *dbg_client_name; + struct list_head device_node; + struct dma_chan_percpu *local; + int client_count; + int table_count; + struct dma_router *router; + void *route_data; + void *private; +}; + +typedef bool (*dma_filter_fn)(struct dma_chan___2 *, void *); + +struct dma_slave_map; + +struct dma_filter { + dma_filter_fn fn; + int mapcnt; + const struct dma_slave_map *map; +}; + +enum dmaengine_alignment { + DMAENGINE_ALIGN_1_BYTE = 0, + DMAENGINE_ALIGN_2_BYTES = 1, + DMAENGINE_ALIGN_4_BYTES = 2, + DMAENGINE_ALIGN_8_BYTES = 3, + DMAENGINE_ALIGN_16_BYTES = 4, + DMAENGINE_ALIGN_32_BYTES = 5, + DMAENGINE_ALIGN_64_BYTES = 6, +}; + +enum dma_residue_granularity { + DMA_RESIDUE_GRANULARITY_DESCRIPTOR = 0, + DMA_RESIDUE_GRANULARITY_SEGMENT = 1, + DMA_RESIDUE_GRANULARITY_BURST = 2, +}; + +struct dma_async_tx_descriptor; + +struct dma_slave_caps; + +struct dma_slave_config; + +struct dma_tx_state; + +struct dma_device { + struct kref ref; + unsigned int chancnt; + unsigned int privatecnt; + struct list_head channels; + struct list_head global_node; + struct dma_filter filter; + dma_cap_mask_t cap_mask; + enum dma_desc_metadata_mode desc_metadata_modes; + short unsigned int max_xor; + short unsigned int max_pq; + enum dmaengine_alignment copy_align; + enum dmaengine_alignment xor_align; + enum dmaengine_alignment pq_align; + enum dmaengine_alignment fill_align; + int dev_id; + struct device *dev; + struct module *owner; + struct ida chan_ida; + struct mutex chan_mutex; + u32 src_addr_widths; + u32 dst_addr_widths; + u32 directions; + u32 min_burst; + u32 max_burst; + u32 max_sg_burst; + bool descriptor_reuse; + enum dma_residue_granularity residue_granularity; + int (*device_alloc_chan_resources)(struct dma_chan___2 *); + void (*device_free_chan_resources)(struct dma_chan___2 *); + struct dma_async_tx_descriptor * (*device_prep_dma_memcpy)(struct dma_chan___2 *, dma_addr_t, dma_addr_t, size_t, long unsigned int); + struct dma_async_tx_descriptor * (*device_prep_dma_xor)(struct dma_chan___2 *, dma_addr_t, dma_addr_t *, unsigned int, size_t, long unsigned int); + struct dma_async_tx_descriptor * (*device_prep_dma_xor_val)(struct dma_chan___2 *, dma_addr_t *, unsigned int, size_t, enum sum_check_flags *, long unsigned int); + struct dma_async_tx_descriptor * (*device_prep_dma_pq)(struct dma_chan___2 *, dma_addr_t *, dma_addr_t *, unsigned int, const unsigned char *, size_t, long unsigned int); + struct dma_async_tx_descriptor * (*device_prep_dma_pq_val)(struct dma_chan___2 *, dma_addr_t *, dma_addr_t *, unsigned int, const unsigned char *, size_t, enum sum_check_flags *, long unsigned int); + struct dma_async_tx_descriptor * (*device_prep_dma_memset)(struct dma_chan___2 *, dma_addr_t, int, size_t, long unsigned int); + struct dma_async_tx_descriptor * (*device_prep_dma_memset_sg)(struct dma_chan___2 *, struct scatterlist *, unsigned int, int, long unsigned int); + struct dma_async_tx_descriptor * (*device_prep_dma_interrupt)(struct dma_chan___2 *, long unsigned int); + struct dma_async_tx_descriptor * (*device_prep_slave_sg)(struct dma_chan___2 *, struct scatterlist *, unsigned int, enum dma_transfer_direction, long unsigned int, void *); + struct dma_async_tx_descriptor * (*device_prep_dma_cyclic)(struct dma_chan___2 *, dma_addr_t, size_t, size_t, enum dma_transfer_direction, long unsigned int); + struct dma_async_tx_descriptor * (*device_prep_interleaved_dma)(struct dma_chan___2 *, struct dma_interleaved_template *, long unsigned int); + struct dma_async_tx_descriptor * (*device_prep_dma_imm_data)(struct dma_chan___2 *, dma_addr_t, u64, long unsigned int); + void (*device_caps)(struct dma_chan___2 *, struct dma_slave_caps *); + int (*device_config)(struct dma_chan___2 *, struct dma_slave_config *); + int (*device_pause)(struct dma_chan___2 *); + int (*device_resume)(struct dma_chan___2 *); + int (*device_terminate_all)(struct dma_chan___2 *); + void (*device_synchronize)(struct dma_chan___2 *); + enum dma_status (*device_tx_status)(struct dma_chan___2 *, dma_cookie_t, struct dma_tx_state *); + void (*device_issue_pending)(struct dma_chan___2 *); + void (*device_release)(struct dma_device *); + void (*dbg_summary_show)(struct seq_file *, struct dma_device *); + struct dentry *dbg_dev_root; +}; + +struct dma_chan_dev { + struct dma_chan___2 *chan; + struct device device; + int dev_id; +}; + +enum dma_slave_buswidth { + DMA_SLAVE_BUSWIDTH_UNDEFINED = 0, + DMA_SLAVE_BUSWIDTH_1_BYTE = 1, + DMA_SLAVE_BUSWIDTH_2_BYTES = 2, + DMA_SLAVE_BUSWIDTH_3_BYTES = 3, + DMA_SLAVE_BUSWIDTH_4_BYTES = 4, + DMA_SLAVE_BUSWIDTH_8_BYTES = 8, + DMA_SLAVE_BUSWIDTH_16_BYTES = 16, + DMA_SLAVE_BUSWIDTH_32_BYTES = 32, + DMA_SLAVE_BUSWIDTH_64_BYTES = 64, +}; + +struct dma_slave_config { + enum dma_transfer_direction direction; + phys_addr_t src_addr; + phys_addr_t dst_addr; + enum dma_slave_buswidth src_addr_width; + enum dma_slave_buswidth dst_addr_width; + u32 src_maxburst; + u32 dst_maxburst; + u32 src_port_window_size; + u32 dst_port_window_size; + bool device_fc; + unsigned int slave_id; +}; + +struct dma_slave_caps { + u32 src_addr_widths; + u32 dst_addr_widths; + u32 directions; + u32 min_burst; + u32 max_burst; + u32 max_sg_burst; + bool cmd_pause; + bool cmd_resume; + bool cmd_terminate; + enum dma_residue_granularity residue_granularity; + bool descriptor_reuse; +}; + +typedef void (*dma_async_tx_callback)(void *); + +enum dmaengine_tx_result { + DMA_TRANS_NOERROR = 0, + DMA_TRANS_READ_FAILED = 1, + DMA_TRANS_WRITE_FAILED = 2, + DMA_TRANS_ABORTED = 3, +}; + +struct dmaengine_result { + enum dmaengine_tx_result result; + u32 residue; +}; + +typedef void (*dma_async_tx_callback_result)(void *, const struct dmaengine_result *); + +struct dmaengine_unmap_data { + u16 map_cnt; + u8 to_cnt; + u8 from_cnt; + u8 bidi_cnt; + struct device *dev; + struct kref kref; + size_t len; + dma_addr_t addr[0]; +}; + +struct dma_descriptor_metadata_ops { + int (*attach)(struct dma_async_tx_descriptor *, void *, size_t); + void * (*get_ptr)(struct dma_async_tx_descriptor *, size_t *, size_t *); + int (*set_len)(struct dma_async_tx_descriptor *, size_t); +}; + +struct dma_async_tx_descriptor { + dma_cookie_t cookie; + enum dma_ctrl_flags flags; + dma_addr_t phys; + struct dma_chan___2 *chan; + dma_cookie_t (*tx_submit)(struct dma_async_tx_descriptor *); + int (*desc_free)(struct dma_async_tx_descriptor *); + dma_async_tx_callback callback; + dma_async_tx_callback_result callback_result; + void *callback_param; + struct dmaengine_unmap_data *unmap; + enum dma_desc_metadata_mode desc_metadata_mode; + struct dma_descriptor_metadata_ops *metadata_ops; +}; + +struct dma_tx_state { + dma_cookie_t last; + dma_cookie_t used; + u32 residue; + u32 in_flight_bytes; +}; + +struct dma_slave_map { + const char *devname; + const char *slave; + void *param; +}; + +struct dma_chan_tbl_ent { + struct dma_chan___2 *chan; +}; + +struct dmaengine_unmap_pool { + struct kmem_cache *cache; + const char *name; + mempool_t *pool; + size_t size; +}; + +struct acpi_table_csrt { + struct acpi_table_header header; +}; + +struct acpi_csrt_group { + u32 length; + u32 vendor_id; + u32 subvendor_id; + u16 device_id; + u16 subdevice_id; + u16 revision; + u16 reserved; + u32 shared_info_length; +}; + +struct acpi_csrt_shared_info { + u16 major_version; + u16 minor_version; + u32 mmio_base_low; + u32 mmio_base_high; + u32 gsi_interrupt; + u8 interrupt_polarity; + u8 interrupt_mode; + u8 num_channels; + u8 dma_address_width; + u16 base_request_line; + u16 num_handshake_signals; + u32 max_block_size; +}; + +struct acpi_dma_spec { + int chan_id; + int slave_id; + struct device *dev; +}; + +struct acpi_dma { + struct list_head dma_controllers; + struct device *dev; + struct dma_chan___2 * (*acpi_dma_xlate)(struct acpi_dma_spec *, struct acpi_dma *); + void *data; + short unsigned int base_request_line; + short unsigned int end_request_line; +}; + +struct acpi_dma_filter_info { + dma_cap_mask_t dma_cap; + dma_filter_fn filter_fn; +}; + +struct acpi_dma_parser_data { + struct acpi_dma_spec dma_spec; + size_t index; + size_t n; +}; + +struct dca_ops; + +struct dca_provider { + struct list_head node; + const struct dca_ops *ops; + struct device *cd; + int id; +}; + +struct dca_ops { + int (*add_requester)(struct dca_provider *, struct device *); + int (*remove_requester)(struct dca_provider *, struct device *); + u8 (*get_tag)(struct dca_provider *, struct device *, int); + int (*dev_managed)(struct dca_provider *, struct device *); +}; + +struct ioat_dma_descriptor { + uint32_t size; + union { + uint32_t ctl; + struct { + unsigned int int_en: 1; + unsigned int src_snoop_dis: 1; + unsigned int dest_snoop_dis: 1; + unsigned int compl_write: 1; + unsigned int fence: 1; + unsigned int null: 1; + unsigned int src_brk: 1; + unsigned int dest_brk: 1; + unsigned int bundle: 1; + unsigned int dest_dca: 1; + unsigned int hint: 1; + unsigned int rsvd2: 13; + unsigned int op: 8; + } ctl_f; + }; + uint64_t src_addr; + uint64_t dst_addr; + uint64_t next; + uint64_t rsv1; + uint64_t rsv2; + union { + uint64_t user1; + uint64_t tx_cnt; + }; + uint64_t user2; +}; + +struct ioat_xor_descriptor { + uint32_t size; + union { + uint32_t ctl; + struct { + unsigned int int_en: 1; + unsigned int src_snoop_dis: 1; + unsigned int dest_snoop_dis: 1; + unsigned int compl_write: 1; + unsigned int fence: 1; + unsigned int src_cnt: 3; + unsigned int bundle: 1; + unsigned int dest_dca: 1; + unsigned int hint: 1; + unsigned int rsvd: 13; + unsigned int op: 8; + } ctl_f; + }; + uint64_t src_addr; + uint64_t dst_addr; + uint64_t next; + uint64_t src_addr2; + uint64_t src_addr3; + uint64_t src_addr4; + uint64_t src_addr5; +}; + +struct ioat_xor_ext_descriptor { + uint64_t src_addr6; + uint64_t src_addr7; + uint64_t src_addr8; + uint64_t next; + uint64_t rsvd[4]; +}; + +struct ioat_pq_descriptor { + union { + uint32_t size; + uint32_t dwbes; + struct { + unsigned int rsvd: 25; + unsigned int p_val_err: 1; + unsigned int q_val_err: 1; + unsigned int rsvd1: 4; + unsigned int wbes: 1; + } dwbes_f; + }; + union { + uint32_t ctl; + struct { + unsigned int int_en: 1; + unsigned int src_snoop_dis: 1; + unsigned int dest_snoop_dis: 1; + unsigned int compl_write: 1; + unsigned int fence: 1; + unsigned int src_cnt: 3; + unsigned int bundle: 1; + unsigned int dest_dca: 1; + unsigned int hint: 1; + unsigned int p_disable: 1; + unsigned int q_disable: 1; + unsigned int rsvd2: 2; + unsigned int wb_en: 1; + unsigned int prl_en: 1; + unsigned int rsvd3: 7; + unsigned int op: 8; + } ctl_f; + }; + uint64_t src_addr; + uint64_t p_addr; + uint64_t next; + uint64_t src_addr2; + union { + uint64_t src_addr3; + uint64_t sed_addr; + }; + uint8_t coef[8]; + uint64_t q_addr; +}; + +struct ioat_pq_ext_descriptor { + uint64_t src_addr4; + uint64_t src_addr5; + uint64_t src_addr6; + uint64_t next; + uint64_t src_addr7; + uint64_t src_addr8; + uint64_t rsvd[2]; +}; + +struct ioat_pq_update_descriptor { + uint32_t size; + union { + uint32_t ctl; + struct { + unsigned int int_en: 1; + unsigned int src_snoop_dis: 1; + unsigned int dest_snoop_dis: 1; + unsigned int compl_write: 1; + unsigned int fence: 1; + unsigned int src_cnt: 3; + unsigned int bundle: 1; + unsigned int dest_dca: 1; + unsigned int hint: 1; + unsigned int p_disable: 1; + unsigned int q_disable: 1; + unsigned int rsvd: 3; + unsigned int coef: 8; + unsigned int op: 8; + } ctl_f; + }; + uint64_t src_addr; + uint64_t p_addr; + uint64_t next; + uint64_t src_addr2; + uint64_t p_src; + uint64_t q_src; + uint64_t q_addr; +}; + +struct ioat_raw_descriptor { + uint64_t field[8]; +}; + +struct ioat_sed_raw_descriptor { + uint64_t a[8]; + uint64_t b[8]; + uint64_t c[8]; +}; + +enum ioat_irq_mode { + IOAT_NOIRQ = 0, + IOAT_MSIX = 1, + IOAT_MSI = 2, + IOAT_INTX = 3, +}; + +struct dma_pool___2; + +struct ioatdma_chan; + +struct ioatdma_device { + struct pci_dev *pdev; + void *reg_base; + struct dma_pool___2 *completion_pool; + struct dma_pool___2 *sed_hw_pool[5]; + struct dma_device dma_dev; + u8 version; + struct msix_entry msix_entries[4]; + struct ioatdma_chan *idx[4]; + struct dca_provider *dca; + enum ioat_irq_mode irq_mode; + u32 cap; + u64 msixtba0; + u64 msixdata0; + u32 msixpba; +}; + +struct ioat_descs { + void *virt; + dma_addr_t hw; +}; + +struct ioat_ring_ent; + +struct ioatdma_chan { + struct dma_chan___2 dma_chan; + void *reg_base; + dma_addr_t last_completion; + spinlock_t cleanup_lock; + long unsigned int state; + struct timer_list timer; + struct ioatdma_device *ioat_dma; + dma_addr_t completion_dma; + u64 *completion; + struct tasklet_struct cleanup_task; + struct kobject kobj; + size_t xfercap_log; + u16 head; + u16 issued; + u16 tail; + u16 dmacount; + u16 alloc_order; + u16 produce; + struct ioat_ring_ent **ring; + spinlock_t prep_lock; + struct ioat_descs descs[8]; + int desc_chunks; + int intr_coalesce; + int prev_intr_coalesce; +}; + +struct ioat_sed_ent; + +struct ioat_ring_ent { + union { + struct ioat_dma_descriptor *hw; + struct ioat_xor_descriptor *xor; + struct ioat_xor_ext_descriptor *xor_ex; + struct ioat_pq_descriptor *pq; + struct ioat_pq_ext_descriptor *pq_ex; + struct ioat_pq_update_descriptor *pqu; + struct ioat_raw_descriptor *raw; + }; + size_t len; + struct dma_async_tx_descriptor txd; + enum sum_check_flags *result; + struct ioat_sed_ent *sed; +}; + +struct ioat_sed_ent { + struct ioat_sed_raw_descriptor *hw; + dma_addr_t dma; + struct ioat_ring_ent *parent; + unsigned int hw_pool; +}; + +struct dmaengine_desc_callback { + dma_async_tx_callback callback; + dma_async_tx_callback_result callback_result; + void *callback_param; +}; + +struct ioat_pq16a_descriptor { + uint8_t coef[8]; + uint64_t src_addr3; + uint64_t src_addr4; + uint64_t src_addr5; + uint64_t src_addr6; + uint64_t src_addr7; + uint64_t src_addr8; + uint64_t src_addr9; +}; + +struct ioat_dca_slot { + struct pci_dev *pdev; + u16 rid; +}; + +struct ioat_dca_priv { + void *iobase; + void *dca_base; + int max_requesters; + int requester_count; + u8 tag_map[8]; + struct ioat_dca_slot req_slots[0]; +}; + +struct ioat_sysfs_entry { + struct attribute attr; + ssize_t (*show)(struct dma_chan___2 *, char *); + ssize_t (*store)(struct dma_chan___2 *, const char *, size_t); +}; + +struct virtio_driver { + struct device_driver driver; + const struct virtio_device_id *id_table; + const unsigned int *feature_table; + unsigned int feature_table_size; + const unsigned int *feature_table_legacy; + unsigned int feature_table_size_legacy; + int (*validate)(struct virtio_device *); + int (*probe)(struct virtio_device *); + void (*scan)(struct virtio_device *); + void (*remove)(struct virtio_device *); + void (*config_changed)(struct virtio_device *); + int (*freeze)(struct virtio_device *); + int (*restore)(struct virtio_device *); +}; + +typedef __u16 __virtio16; + +typedef __u32 __virtio32; + +typedef __u64 __virtio64; + +struct vring_desc { + __virtio64 addr; + __virtio32 len; + __virtio16 flags; + __virtio16 next; +}; + +struct vring_avail { + __virtio16 flags; + __virtio16 idx; + __virtio16 ring[0]; +}; + +struct vring_used_elem { + __virtio32 id; + __virtio32 len; +}; + +typedef struct vring_used_elem vring_used_elem_t; + +struct vring_used { + __virtio16 flags; + __virtio16 idx; + vring_used_elem_t ring[0]; +}; + +typedef struct vring_desc vring_desc_t; + +typedef struct vring_avail vring_avail_t; + +typedef struct vring_used vring_used_t; + +struct vring { + unsigned int num; + vring_desc_t *desc; + vring_avail_t *avail; + vring_used_t *used; +}; + +struct vring_packed_desc_event { + __le16 off_wrap; + __le16 flags; +}; + +struct vring_packed_desc { + __le64 addr; + __le32 len; + __le16 id; + __le16 flags; +}; + +struct vring_desc_state_split { + void *data; + struct vring_desc *indir_desc; +}; + +struct vring_desc_state_packed { + void *data; + struct vring_packed_desc *indir_desc; + u16 num; + u16 next; + u16 last; +}; + +struct vring_desc_extra_packed { + dma_addr_t addr; + u32 len; + u16 flags; +}; + +struct vring_virtqueue { + struct virtqueue vq; + bool packed_ring; + bool use_dma_api; + bool weak_barriers; + bool broken; + bool indirect; + bool event; + unsigned int free_head; + unsigned int num_added; + u16 last_used_idx; + union { + struct { + struct vring vring; + u16 avail_flags_shadow; + u16 avail_idx_shadow; + struct vring_desc_state_split *desc_state; + dma_addr_t queue_dma_addr; + size_t queue_size_in_bytes; + } split; + struct { + struct { + unsigned int num; + struct vring_packed_desc *desc; + struct vring_packed_desc_event *driver; + struct vring_packed_desc_event *device; + } vring; + bool avail_wrap_counter; + bool used_wrap_counter; + u16 avail_used_flags; + u16 next_avail_idx; + u16 event_flags_shadow; + struct vring_desc_state_packed *desc_state; + struct vring_desc_extra_packed *desc_extra; + dma_addr_t ring_dma_addr; + dma_addr_t driver_event_dma_addr; + dma_addr_t device_event_dma_addr; + size_t ring_size_in_bytes; + size_t event_size_in_bytes; + } packed; + }; + bool (*notify)(struct virtqueue *); + bool we_own_ring; +}; + +struct virtio_pci_common_cfg { + __le32 device_feature_select; + __le32 device_feature; + __le32 guest_feature_select; + __le32 guest_feature; + __le16 msix_config; + __le16 num_queues; + __u8 device_status; + __u8 config_generation; + __le16 queue_select; + __le16 queue_size; + __le16 queue_msix_vector; + __le16 queue_enable; + __le16 queue_notify_off; + __le32 queue_desc_lo; + __le32 queue_desc_hi; + __le32 queue_avail_lo; + __le32 queue_avail_hi; + __le32 queue_used_lo; + __le32 queue_used_hi; +}; + +struct virtio_pci_vq_info { + struct virtqueue *vq; + struct list_head node; + unsigned int msix_vector; +}; + +struct virtio_pci_device { + struct virtio_device vdev; + struct pci_dev *pci_dev; + u8 *isr; + struct virtio_pci_common_cfg *common; + void *device; + void *notify_base; + size_t notify_len; + size_t device_len; + int notify_map_cap; + u32 notify_offset_multiplier; + int modern_bars; + void *ioaddr; + spinlock_t lock; + struct list_head virtqueues; + struct virtio_pci_vq_info **vqs; + int msix_enabled; + int intx_enabled; + cpumask_var_t *msix_affinity_masks; + char (*msix_names)[256]; + unsigned int msix_vectors; + unsigned int msix_used_vectors; + bool per_vq_vectors; + struct virtqueue * (*setup_vq)(struct virtio_pci_device *, struct virtio_pci_vq_info *, unsigned int, void (*)(struct virtqueue *), const char *, bool, u16); + void (*del_vq)(struct virtio_pci_vq_info *); + u16 (*config_vector)(struct virtio_pci_device *, u16); +}; + +enum { + VP_MSIX_CONFIG_VECTOR = 0, + VP_MSIX_VQ_VECTOR = 1, +}; + +struct virtio_balloon_config { + __le32 num_pages; + __le32 actual; + union { + __le32 free_page_hint_cmd_id; + __le32 free_page_report_cmd_id; + }; + __le32 poison_val; +}; + +struct virtio_balloon_stat { + __virtio16 tag; + __virtio64 val; +} __attribute__((packed)); + +enum virtio_balloon_vq { + VIRTIO_BALLOON_VQ_INFLATE = 0, + VIRTIO_BALLOON_VQ_DEFLATE = 1, + VIRTIO_BALLOON_VQ_STATS = 2, + VIRTIO_BALLOON_VQ_FREE_PAGE = 3, + VIRTIO_BALLOON_VQ_REPORTING = 4, + VIRTIO_BALLOON_VQ_MAX = 5, +}; + +enum virtio_balloon_config_read { + VIRTIO_BALLOON_CONFIG_READ_CMD_ID = 0, +}; + +struct virtio_balloon { + struct virtio_device *vdev; + struct virtqueue *inflate_vq; + struct virtqueue *deflate_vq; + struct virtqueue *stats_vq; + struct virtqueue *free_page_vq; + struct workqueue_struct *balloon_wq; + struct work_struct report_free_page_work; + struct work_struct update_balloon_stats_work; + struct work_struct update_balloon_size_work; + spinlock_t stop_update_lock; + bool stop_update; + long: 56; + long unsigned int config_read_bitmap; + struct list_head free_page_list; + spinlock_t free_page_list_lock; + long unsigned int num_free_page_blocks; + u32 cmd_id_received_cache; + __virtio32 cmd_id_active; + __virtio32 cmd_id_stop; + int: 32; + wait_queue_head_t acked; + unsigned int num_pages; + int: 32; + struct balloon_dev_info vb_dev_info; + struct mutex balloon_lock; + unsigned int num_pfns; + __virtio32 pfns[256]; + struct virtio_balloon_stat stats[10]; + struct shrinker shrinker; + struct notifier_block oom_nb; + struct virtqueue *reporting_vq; + struct page_reporting_dev_info pr_dev_info; +} __attribute__((packed)); + +struct serial_struct32 { + compat_int_t type; + compat_int_t line; + compat_uint_t port; + compat_int_t irq; + compat_int_t flags; + compat_int_t xmit_fifo_size; + compat_int_t custom_divisor; + compat_int_t baud_base; + short unsigned int close_delay; + char io_type; + char reserved_char; + compat_int_t hub6; + short unsigned int closing_wait; + short unsigned int closing_wait2; + compat_uint_t iomem_base; + short unsigned int iomem_reg_shift; + unsigned int port_high; + compat_int_t reserved; +}; + +struct n_tty_data { + size_t read_head; + size_t commit_head; + size_t canon_head; + size_t echo_head; + size_t echo_commit; + size_t echo_mark; + long unsigned int char_map[4]; + long unsigned int overrun_time; + int num_overrun; + bool no_room; + unsigned char lnext: 1; + unsigned char erasing: 1; + unsigned char raw: 1; + unsigned char real_raw: 1; + unsigned char icanon: 1; + unsigned char push: 1; + char read_buf[4096]; + long unsigned int read_flags[64]; + unsigned char echo_buf[4096]; + size_t read_tail; + size_t line_start; + unsigned int column; + unsigned int canon_column; + size_t echo_tail; + struct mutex atomic_read_lock; + struct mutex output_lock; +}; + +enum { + ERASE = 0, + WERASE = 1, + KILL = 2, +}; + +struct termios { + tcflag_t c_iflag; + tcflag_t c_oflag; + tcflag_t c_cflag; + tcflag_t c_lflag; + cc_t c_line; + cc_t c_cc[19]; +}; + +struct termios2 { + tcflag_t c_iflag; + tcflag_t c_oflag; + tcflag_t c_cflag; + tcflag_t c_lflag; + cc_t c_line; + cc_t c_cc[19]; + speed_t c_ispeed; + speed_t c_ospeed; +}; + +struct termio { + short unsigned int c_iflag; + short unsigned int c_oflag; + short unsigned int c_cflag; + short unsigned int c_lflag; + unsigned char c_line; + unsigned char c_cc[8]; +}; + +struct ldsem_waiter { + struct list_head list; + struct task_struct *task; +}; + +struct pts_fs_info___2; + +struct tty_audit_buf { + struct mutex mutex; + dev_t dev; + unsigned int icanon: 1; + size_t valid; + unsigned char *data; +}; + +struct input_id { + __u16 bustype; + __u16 vendor; + __u16 product; + __u16 version; +}; + +struct input_absinfo { + __s32 value; + __s32 minimum; + __s32 maximum; + __s32 fuzz; + __s32 flat; + __s32 resolution; +}; + +struct input_keymap_entry { + __u8 flags; + __u8 len; + __u16 index; + __u32 keycode; + __u8 scancode[32]; +}; + +struct ff_replay { + __u16 length; + __u16 delay; +}; + +struct ff_trigger { + __u16 button; + __u16 interval; +}; + +struct ff_envelope { + __u16 attack_length; + __u16 attack_level; + __u16 fade_length; + __u16 fade_level; +}; + +struct ff_constant_effect { + __s16 level; + struct ff_envelope envelope; +}; + +struct ff_ramp_effect { + __s16 start_level; + __s16 end_level; + struct ff_envelope envelope; +}; + +struct ff_condition_effect { + __u16 right_saturation; + __u16 left_saturation; + __s16 right_coeff; + __s16 left_coeff; + __u16 deadband; + __s16 center; +}; + +struct ff_periodic_effect { + __u16 waveform; + __u16 period; + __s16 magnitude; + __s16 offset; + __u16 phase; + struct ff_envelope envelope; + __u32 custom_len; + __s16 *custom_data; +}; + +struct ff_rumble_effect { + __u16 strong_magnitude; + __u16 weak_magnitude; +}; + +struct ff_effect { + __u16 type; + __s16 id; + __u16 direction; + struct ff_trigger trigger; + struct ff_replay replay; + union { + struct ff_constant_effect constant; + struct ff_ramp_effect ramp; + struct ff_periodic_effect periodic; + struct ff_condition_effect condition[2]; + struct ff_rumble_effect rumble; + } u; +}; + +struct input_device_id { + kernel_ulong_t flags; + __u16 bustype; + __u16 vendor; + __u16 product; + __u16 version; + kernel_ulong_t evbit[1]; + kernel_ulong_t keybit[12]; + kernel_ulong_t relbit[1]; + kernel_ulong_t absbit[1]; + kernel_ulong_t mscbit[1]; + kernel_ulong_t ledbit[1]; + kernel_ulong_t sndbit[1]; + kernel_ulong_t ffbit[2]; + kernel_ulong_t swbit[1]; + kernel_ulong_t propbit[1]; + kernel_ulong_t driver_info; +}; + +struct input_value { + __u16 type; + __u16 code; + __s32 value; +}; + +enum input_clock_type { + INPUT_CLK_REAL = 0, + INPUT_CLK_MONO = 1, + INPUT_CLK_BOOT = 2, + INPUT_CLK_MAX = 3, +}; + +struct ff_device; + +struct input_dev_poller; + +struct input_mt; + +struct input_handle; + +struct input_dev { + const char *name; + const char *phys; + const char *uniq; + struct input_id id; + long unsigned int propbit[1]; + long unsigned int evbit[1]; + long unsigned int keybit[12]; + long unsigned int relbit[1]; + long unsigned int absbit[1]; + long unsigned int mscbit[1]; + long unsigned int ledbit[1]; + long unsigned int sndbit[1]; + long unsigned int ffbit[2]; + long unsigned int swbit[1]; + unsigned int hint_events_per_packet; + unsigned int keycodemax; + unsigned int keycodesize; + void *keycode; + int (*setkeycode)(struct input_dev *, const struct input_keymap_entry *, unsigned int *); + int (*getkeycode)(struct input_dev *, struct input_keymap_entry *); + struct ff_device *ff; + struct input_dev_poller *poller; + unsigned int repeat_key; + struct timer_list timer; + int rep[2]; + struct input_mt *mt; + struct input_absinfo *absinfo; + long unsigned int key[12]; + long unsigned int led[1]; + long unsigned int snd[1]; + long unsigned int sw[1]; + int (*open)(struct input_dev *); + void (*close)(struct input_dev *); + int (*flush)(struct input_dev *, struct file *); + int (*event)(struct input_dev *, unsigned int, unsigned int, int); + struct input_handle *grab; + spinlock_t event_lock; + struct mutex mutex; + unsigned int users; + bool going_away; + struct device dev; + struct list_head h_list; + struct list_head node; + unsigned int num_vals; + unsigned int max_vals; + struct input_value *vals; + bool devres_managed; + ktime_t timestamp[3]; +}; + +struct ff_device { + int (*upload)(struct input_dev *, struct ff_effect *, struct ff_effect *); + int (*erase)(struct input_dev *, int); + int (*playback)(struct input_dev *, int, int); + void (*set_gain)(struct input_dev *, u16); + void (*set_autocenter)(struct input_dev *, u16); + void (*destroy)(struct ff_device *); + void *private; + long unsigned int ffbit[2]; + struct mutex mutex; + int max_effects; + struct ff_effect *effects; + struct file *effect_owners[0]; +}; + +struct input_handler; + +struct input_handle { + void *private; + int open; + const char *name; + struct input_dev *dev; + struct input_handler *handler; + struct list_head d_node; + struct list_head h_node; +}; + +struct input_handler { + void *private; + void (*event)(struct input_handle *, unsigned int, unsigned int, int); + void (*events)(struct input_handle *, const struct input_value *, unsigned int); + bool (*filter)(struct input_handle *, unsigned int, unsigned int, int); + bool (*match)(struct input_handler *, struct input_dev *); + int (*connect)(struct input_handler *, struct input_dev *, const struct input_device_id *); + void (*disconnect)(struct input_handle *); + void (*start)(struct input_handle *); + bool legacy_minors; + int minor; + const char *name; + const struct input_device_id *id_table; + struct list_head h_list; + struct list_head node; +}; + +struct sysrq_state { + struct input_handle handle; + struct work_struct reinject_work; + long unsigned int key_down[12]; + unsigned int alt; + unsigned int alt_use; + unsigned int shift; + unsigned int shift_use; + bool active; + bool need_reinject; + bool reinjecting; + bool reset_canceled; + bool reset_requested; + long unsigned int reset_keybit[12]; + int reset_seq_len; + int reset_seq_cnt; + int reset_seq_version; + struct timer_list keyreset_timer; +}; + +struct consolefontdesc { + short unsigned int charcount; + short unsigned int charheight; + char *chardata; +}; + +struct unipair { + short unsigned int unicode; + short unsigned int fontpos; +}; + +struct unimapdesc { + short unsigned int entry_ct; + struct unipair *entries; +}; + +struct kbd_repeat { + int delay; + int period; +}; + +struct console_font_op { + unsigned int op; + unsigned int flags; + unsigned int width; + unsigned int height; + unsigned int charcount; + unsigned char *data; +}; + +struct vt_stat { + short unsigned int v_active; + short unsigned int v_signal; + short unsigned int v_state; +}; + +struct vt_sizes { + short unsigned int v_rows; + short unsigned int v_cols; + short unsigned int v_scrollsize; +}; + +struct vt_consize { + short unsigned int v_rows; + short unsigned int v_cols; + short unsigned int v_vlin; + short unsigned int v_clin; + short unsigned int v_vcol; + short unsigned int v_ccol; +}; + +struct vt_event { + unsigned int event; + unsigned int oldev; + unsigned int newev; + unsigned int pad[4]; +}; + +struct vt_setactivate { + unsigned int console; + struct vt_mode mode; +}; + +struct vt_spawn_console { + spinlock_t lock; + struct pid *pid; + int sig; +}; + +struct vt_event_wait { + struct list_head list; + struct vt_event event; + int done; +}; + +struct compat_consolefontdesc { + short unsigned int charcount; + short unsigned int charheight; + compat_caddr_t chardata; +}; + +struct compat_console_font_op { + compat_uint_t op; + compat_uint_t flags; + compat_uint_t width; + compat_uint_t height; + compat_uint_t charcount; + compat_caddr_t data; +}; + +struct compat_unimapdesc { + short unsigned int entry_ct; + compat_caddr_t entries; +}; + +struct vt_notifier_param { + struct vc_data *vc; + unsigned int c; +}; + +struct vcs_poll_data { + struct notifier_block notifier; + unsigned int cons_num; + int event; + wait_queue_head_t waitq; + struct fasync_struct *fasync; +}; + +struct tiocl_selection { + short unsigned int xs; + short unsigned int ys; + short unsigned int xe; + short unsigned int ye; + short unsigned int sel_mode; +}; + +struct vc_selection { + struct mutex lock; + struct vc_data *cons; + char *buffer; + unsigned int buf_len; + volatile int start; + int end; +}; + +struct keyboard_notifier_param { + struct vc_data *vc; + int down; + int shift; + int ledstate; + unsigned int value; +}; + +struct kbd_struct { + unsigned char lockstate; + unsigned char slockstate; + unsigned char ledmode: 1; + unsigned char ledflagstate: 4; + char: 3; + unsigned char default_ledflagstate: 4; + unsigned char kbdmode: 3; + char: 1; + unsigned char modeflags: 5; +}; + +struct kbentry { + unsigned char kb_table; + unsigned char kb_index; + short unsigned int kb_value; +}; + +struct kbsentry { + unsigned char kb_func; + unsigned char kb_string[512]; +}; + +struct kbdiacr { + unsigned char diacr; + unsigned char base; + unsigned char result; +}; + +struct kbdiacrs { + unsigned int kb_cnt; + struct kbdiacr kbdiacr[256]; +}; + +struct kbdiacruc { + unsigned int diacr; + unsigned int base; + unsigned int result; +}; + +struct kbdiacrsuc { + unsigned int kb_cnt; + struct kbdiacruc kbdiacruc[256]; +}; + +struct kbkeycode { + unsigned int scancode; + unsigned int keycode; +}; + +typedef void k_handler_fn(struct vc_data *, unsigned char, char); + +typedef void fn_handler_fn(struct vc_data *); + +struct getset_keycode_data { + struct input_keymap_entry ke; + int error; +}; + +struct uni_pagedir { + u16 **uni_pgdir[32]; + long unsigned int refcount; + long unsigned int sum; + unsigned char *inverse_translations[4]; + u16 *inverse_trans_unicode; +}; + +typedef uint32_t char32_t; + +struct uni_screen { + char32_t *lines[0]; +}; + +struct con_driver { + const struct consw *con; + const char *desc; + struct device *dev; + int node; + int first; + int last; + int flag; +}; + +enum { + blank_off = 0, + blank_normal_wait = 1, + blank_vesa_wait = 2, +}; + +enum { + EPecma = 0, + EPdec = 1, + EPeq = 2, + EPgt = 3, + EPlt = 4, +}; + +struct rgb { + u8 r; + u8 g; + u8 b; +}; + +enum { + ESnormal = 0, + ESesc = 1, + ESsquare = 2, + ESgetpars = 3, + ESfunckey = 4, + EShash = 5, + ESsetG0 = 6, + ESsetG1 = 7, + ESpercent = 8, + EScsiignore = 9, + ESnonstd = 10, + ESpalette = 11, + ESosc = 12, +}; + +struct interval { + uint32_t first; + uint32_t last; +}; + +struct vc_draw_region { + long unsigned int from; + long unsigned int to; + int x; +}; + +struct hv_ops; + +struct hvc_struct { + struct tty_port port; + spinlock_t lock; + int index; + int do_wakeup; + char *outbuf; + int outbuf_size; + int n_outbuf; + uint32_t vtermno; + const struct hv_ops *ops; + int irq_requested; + int data; + struct winsize ws; + struct work_struct tty_resize; + struct list_head next; + long unsigned int flags; +}; + +struct hv_ops { + int (*get_chars)(uint32_t, char *, int); + int (*put_chars)(uint32_t, const char *, int); + int (*flush)(uint32_t, bool); + int (*notifier_add)(struct hvc_struct *, int); + void (*notifier_del)(struct hvc_struct *, int); + void (*notifier_hangup)(struct hvc_struct *, int); + int (*tiocmget)(struct hvc_struct *); + int (*tiocmset)(struct hvc_struct *, unsigned int, unsigned int); + void (*dtr_rts)(struct hvc_struct *, int); +}; + +struct serial_rs485 { + __u32 flags; + __u32 delay_rts_before_send; + __u32 delay_rts_after_send; + __u32 padding[5]; +}; + +struct serial_iso7816 { + __u32 flags; + __u32 tg; + __u32 sc_fi; + __u32 sc_di; + __u32 clk; + __u32 reserved[5]; +}; + +struct circ_buf { + char *buf; + int head; + int tail; +}; + +struct uart_port; + +struct uart_ops { + unsigned int (*tx_empty)(struct uart_port *); + void (*set_mctrl)(struct uart_port *, unsigned int); + unsigned int (*get_mctrl)(struct uart_port *); + void (*stop_tx)(struct uart_port *); + void (*start_tx)(struct uart_port *); + void (*throttle)(struct uart_port *); + void (*unthrottle)(struct uart_port *); + void (*send_xchar)(struct uart_port *, char); + void (*stop_rx)(struct uart_port *); + void (*enable_ms)(struct uart_port *); + void (*break_ctl)(struct uart_port *, int); + int (*startup)(struct uart_port *); + void (*shutdown)(struct uart_port *); + void (*flush_buffer)(struct uart_port *); + void (*set_termios)(struct uart_port *, struct ktermios *, struct ktermios *); + void (*set_ldisc)(struct uart_port *, struct ktermios *); + void (*pm)(struct uart_port *, unsigned int, unsigned int); + const char * (*type)(struct uart_port *); + void (*release_port)(struct uart_port *); + int (*request_port)(struct uart_port *); + void (*config_port)(struct uart_port *, int); + int (*verify_port)(struct uart_port *, struct serial_struct *); + int (*ioctl)(struct uart_port *, unsigned int, long unsigned int); +}; + +struct uart_icount { + __u32 cts; + __u32 dsr; + __u32 rng; + __u32 dcd; + __u32 rx; + __u32 tx; + __u32 frame; + __u32 overrun; + __u32 parity; + __u32 brk; + __u32 buf_overrun; +}; + +typedef unsigned int upf_t; + +typedef unsigned int upstat_t; + +struct uart_state; + +struct uart_port { + spinlock_t lock; + long unsigned int iobase; + unsigned char *membase; + unsigned int (*serial_in)(struct uart_port *, int); + void (*serial_out)(struct uart_port *, int, int); + void (*set_termios)(struct uart_port *, struct ktermios *, struct ktermios *); + void (*set_ldisc)(struct uart_port *, struct ktermios *); + unsigned int (*get_mctrl)(struct uart_port *); + void (*set_mctrl)(struct uart_port *, unsigned int); + unsigned int (*get_divisor)(struct uart_port *, unsigned int, unsigned int *); + void (*set_divisor)(struct uart_port *, unsigned int, unsigned int, unsigned int); + int (*startup)(struct uart_port *); + void (*shutdown)(struct uart_port *); + void (*throttle)(struct uart_port *); + void (*unthrottle)(struct uart_port *); + int (*handle_irq)(struct uart_port *); + void (*pm)(struct uart_port *, unsigned int, unsigned int); + void (*handle_break)(struct uart_port *); + int (*rs485_config)(struct uart_port *, struct serial_rs485 *); + int (*iso7816_config)(struct uart_port *, struct serial_iso7816 *); + unsigned int irq; + long unsigned int irqflags; + unsigned int uartclk; + unsigned int fifosize; + unsigned char x_char; + unsigned char regshift; + unsigned char iotype; + unsigned char quirks; + unsigned int read_status_mask; + unsigned int ignore_status_mask; + struct uart_state *state; + struct uart_icount icount; + struct console *cons; + upf_t flags; + upstat_t status; + int hw_stopped; + unsigned int mctrl; + unsigned int timeout; + unsigned int type; + const struct uart_ops *ops; + unsigned int custom_divisor; + unsigned int line; + unsigned int minor; + resource_size_t mapbase; + resource_size_t mapsize; + struct device *dev; + long unsigned int sysrq; + unsigned int sysrq_ch; + unsigned char has_sysrq; + unsigned char sysrq_seq; + unsigned char hub6; + unsigned char suspended; + unsigned char console_reinit; + const char *name; + struct attribute_group *attr_group; + const struct attribute_group **tty_groups; + struct serial_rs485 rs485; + struct gpio_desc___2 *rs485_term_gpio; + struct serial_iso7816 iso7816; + void *private_data; +}; + +enum uart_pm_state { + UART_PM_STATE_ON = 0, + UART_PM_STATE_OFF = 3, + UART_PM_STATE_UNDEFINED = 4, +}; + +struct uart_state { + struct tty_port port; + enum uart_pm_state pm_state; + struct circ_buf xmit; + atomic_t refcount; + wait_queue_head_t remove_wait; + struct uart_port *uart_port; +}; + +struct uart_driver { + struct module *owner; + const char *driver_name; + const char *dev_name; + int major; + int minor; + int nr; + struct console *cons; + struct uart_state *state; + struct tty_driver *tty_driver; +}; + +struct uart_match { + struct uart_port *port; + struct uart_driver *driver; +}; + +struct earlycon_device { + struct console *con; + struct uart_port port; + char options[16]; + unsigned int baud; +}; + +struct earlycon_id { + char name[15]; + char name_term; + char compatible[128]; + int (*setup)(struct earlycon_device *, const char *); +}; + +enum hwparam_type { + hwparam_ioport = 0, + hwparam_iomem = 1, + hwparam_ioport_or_iomem = 2, + hwparam_irq = 3, + hwparam_dma = 4, + hwparam_dma_addr = 5, + hwparam_other = 6, +}; + +struct plat_serial8250_port { + long unsigned int iobase; + void *membase; + resource_size_t mapbase; + unsigned int irq; + long unsigned int irqflags; + unsigned int uartclk; + void *private_data; + unsigned char regshift; + unsigned char iotype; + unsigned char hub6; + unsigned char has_sysrq; + upf_t flags; + unsigned int type; + unsigned int (*serial_in)(struct uart_port *, int); + void (*serial_out)(struct uart_port *, int, int); + void (*set_termios)(struct uart_port *, struct ktermios *, struct ktermios *); + void (*set_ldisc)(struct uart_port *, struct ktermios *); + unsigned int (*get_mctrl)(struct uart_port *); + int (*handle_irq)(struct uart_port *); + void (*pm)(struct uart_port *, unsigned int, unsigned int); + void (*handle_break)(struct uart_port *); +}; + +enum { + PLAT8250_DEV_LEGACY = 4294967295, + PLAT8250_DEV_PLATFORM = 0, + PLAT8250_DEV_PLATFORM1 = 1, + PLAT8250_DEV_PLATFORM2 = 2, + PLAT8250_DEV_FOURPORT = 3, + PLAT8250_DEV_ACCENT = 4, + PLAT8250_DEV_BOCA = 5, + PLAT8250_DEV_EXAR_ST16C554 = 6, + PLAT8250_DEV_HUB6 = 7, + PLAT8250_DEV_AU1X00 = 8, + PLAT8250_DEV_SM501 = 9, +}; + +struct uart_8250_port; + +struct uart_8250_ops { + int (*setup_irq)(struct uart_8250_port *); + void (*release_irq)(struct uart_8250_port *); +}; + +struct mctrl_gpios; + +struct uart_8250_dma; + +struct uart_8250_em485; + +struct uart_8250_port { + struct uart_port port; + struct timer_list timer; + struct list_head list; + u32 capabilities; + short unsigned int bugs; + bool fifo_bug; + unsigned int tx_loadsz; + unsigned char acr; + unsigned char fcr; + unsigned char ier; + unsigned char lcr; + unsigned char mcr; + unsigned char mcr_mask; + unsigned char mcr_force; + unsigned char cur_iotype; + unsigned int rpm_tx_active; + unsigned char canary; + unsigned char probe; + struct mctrl_gpios *gpios; + unsigned char lsr_saved_flags; + unsigned char msr_saved_flags; + struct uart_8250_dma *dma; + const struct uart_8250_ops *ops; + int (*dl_read)(struct uart_8250_port *); + void (*dl_write)(struct uart_8250_port *, int); + struct uart_8250_em485 *em485; + void (*rs485_start_tx)(struct uart_8250_port *); + void (*rs485_stop_tx)(struct uart_8250_port *); + struct delayed_work overrun_backoff; + u32 overrun_backoff_time_ms; +}; + +struct uart_8250_em485 { + struct hrtimer start_tx_timer; + struct hrtimer stop_tx_timer; + struct hrtimer *active_timer; + struct uart_8250_port *port; + unsigned int tx_stopped: 1; +}; + +struct uart_8250_dma { + int (*tx_dma)(struct uart_8250_port *); + int (*rx_dma)(struct uart_8250_port *); + dma_filter_fn fn; + void *rx_param; + void *tx_param; + struct dma_slave_config rxconf; + struct dma_slave_config txconf; + struct dma_chan___2 *rxchan; + struct dma_chan___2 *txchan; + phys_addr_t rx_dma_addr; + phys_addr_t tx_dma_addr; + dma_addr_t rx_addr; + dma_addr_t tx_addr; + dma_cookie_t rx_cookie; + dma_cookie_t tx_cookie; + void *rx_buf; + size_t rx_size; + size_t tx_size; + unsigned char tx_running; + unsigned char tx_err; + unsigned char rx_running; +}; + +struct old_serial_port { + unsigned int uart; + unsigned int baud_base; + unsigned int port; + unsigned int irq; + upf_t flags; + unsigned char io_type; + unsigned char *iomem_base; + short unsigned int iomem_reg_shift; +}; + +struct irq_info { + struct hlist_node node; + int irq; + spinlock_t lock; + struct list_head *head; +}; + +struct serial8250_config { + const char *name; + short unsigned int fifo_size; + short unsigned int tx_loadsz; + unsigned char fcr; + unsigned char rxtrig_bytes[4]; + unsigned int flags; +}; + +struct pciserial_board { + unsigned int flags; + unsigned int num_ports; + unsigned int base_baud; + unsigned int uart_offset; + unsigned int reg_shift; + unsigned int first_offset; +}; + +struct serial_private; + +struct pci_serial_quirk { + u32 vendor; + u32 device; + u32 subvendor; + u32 subdevice; + int (*probe)(struct pci_dev *); + int (*init)(struct pci_dev *); + int (*setup)(struct serial_private *, const struct pciserial_board *, struct uart_8250_port *, int); + void (*exit)(struct pci_dev *); +}; + +struct serial_private { + struct pci_dev *dev; + unsigned int nr; + struct pci_serial_quirk *quirk; + const struct pciserial_board *board; + int line[0]; +}; + +struct f815xxa_data { + spinlock_t lock; + int idx; +}; + +struct timedia_struct { + int num; + const short unsigned int *ids; +}; + +struct quatech_feature { + u16 devid; + bool amcc; +}; + +enum pci_board_num_t { + pbn_default = 0, + pbn_b0_1_115200 = 1, + pbn_b0_2_115200 = 2, + pbn_b0_4_115200 = 3, + pbn_b0_5_115200 = 4, + pbn_b0_8_115200 = 5, + pbn_b0_1_921600 = 6, + pbn_b0_2_921600 = 7, + pbn_b0_4_921600 = 8, + pbn_b0_2_1130000 = 9, + pbn_b0_4_1152000 = 10, + pbn_b0_4_1250000 = 11, + pbn_b0_2_1843200 = 12, + pbn_b0_4_1843200 = 13, + pbn_b0_1_4000000 = 14, + pbn_b0_bt_1_115200 = 15, + pbn_b0_bt_2_115200 = 16, + pbn_b0_bt_4_115200 = 17, + pbn_b0_bt_8_115200 = 18, + pbn_b0_bt_1_460800 = 19, + pbn_b0_bt_2_460800 = 20, + pbn_b0_bt_4_460800 = 21, + pbn_b0_bt_1_921600 = 22, + pbn_b0_bt_2_921600 = 23, + pbn_b0_bt_4_921600 = 24, + pbn_b0_bt_8_921600 = 25, + pbn_b1_1_115200 = 26, + pbn_b1_2_115200 = 27, + pbn_b1_4_115200 = 28, + pbn_b1_8_115200 = 29, + pbn_b1_16_115200 = 30, + pbn_b1_1_921600 = 31, + pbn_b1_2_921600 = 32, + pbn_b1_4_921600 = 33, + pbn_b1_8_921600 = 34, + pbn_b1_2_1250000 = 35, + pbn_b1_bt_1_115200 = 36, + pbn_b1_bt_2_115200 = 37, + pbn_b1_bt_4_115200 = 38, + pbn_b1_bt_2_921600 = 39, + pbn_b1_1_1382400 = 40, + pbn_b1_2_1382400 = 41, + pbn_b1_4_1382400 = 42, + pbn_b1_8_1382400 = 43, + pbn_b2_1_115200 = 44, + pbn_b2_2_115200 = 45, + pbn_b2_4_115200 = 46, + pbn_b2_8_115200 = 47, + pbn_b2_1_460800 = 48, + pbn_b2_4_460800 = 49, + pbn_b2_8_460800 = 50, + pbn_b2_16_460800 = 51, + pbn_b2_1_921600 = 52, + pbn_b2_4_921600 = 53, + pbn_b2_8_921600 = 54, + pbn_b2_8_1152000 = 55, + pbn_b2_bt_1_115200 = 56, + pbn_b2_bt_2_115200 = 57, + pbn_b2_bt_4_115200 = 58, + pbn_b2_bt_2_921600 = 59, + pbn_b2_bt_4_921600 = 60, + pbn_b3_2_115200 = 61, + pbn_b3_4_115200 = 62, + pbn_b3_8_115200 = 63, + pbn_b4_bt_2_921600 = 64, + pbn_b4_bt_4_921600 = 65, + pbn_b4_bt_8_921600 = 66, + pbn_panacom = 67, + pbn_panacom2 = 68, + pbn_panacom4 = 69, + pbn_plx_romulus = 70, + pbn_endrun_2_4000000 = 71, + pbn_oxsemi = 72, + pbn_oxsemi_1_4000000 = 73, + pbn_oxsemi_2_4000000 = 74, + pbn_oxsemi_4_4000000 = 75, + pbn_oxsemi_8_4000000 = 76, + pbn_intel_i960 = 77, + pbn_sgi_ioc3 = 78, + pbn_computone_4 = 79, + pbn_computone_6 = 80, + pbn_computone_8 = 81, + pbn_sbsxrsio = 82, + pbn_pasemi_1682M = 83, + pbn_ni8430_2 = 84, + pbn_ni8430_4 = 85, + pbn_ni8430_8 = 86, + pbn_ni8430_16 = 87, + pbn_ADDIDATA_PCIe_1_3906250 = 88, + pbn_ADDIDATA_PCIe_2_3906250 = 89, + pbn_ADDIDATA_PCIe_4_3906250 = 90, + pbn_ADDIDATA_PCIe_8_3906250 = 91, + pbn_ce4100_1_115200 = 92, + pbn_omegapci = 93, + pbn_NETMOS9900_2s_115200 = 94, + pbn_brcm_trumanage = 95, + pbn_fintek_4 = 96, + pbn_fintek_8 = 97, + pbn_fintek_12 = 98, + pbn_fintek_F81504A = 99, + pbn_fintek_F81508A = 100, + pbn_fintek_F81512A = 101, + pbn_wch382_2 = 102, + pbn_wch384_4 = 103, + pbn_wch384_8 = 104, + pbn_pericom_PI7C9X7951 = 105, + pbn_pericom_PI7C9X7952 = 106, + pbn_pericom_PI7C9X7954 = 107, + pbn_pericom_PI7C9X7958 = 108, + pbn_sunix_pci_1s = 109, + pbn_sunix_pci_2s = 110, + pbn_sunix_pci_4s = 111, + pbn_sunix_pci_8s = 112, + pbn_sunix_pci_16s = 113, + pbn_moxa8250_2p = 114, + pbn_moxa8250_4p = 115, + pbn_moxa8250_8p = 116, +}; + +struct exar8250_platform { + int (*rs485_config)(struct uart_port *, struct serial_rs485 *); + int (*register_gpio)(struct pci_dev *, struct uart_8250_port *); +}; + +struct exar8250; + +struct exar8250_board { + unsigned int num_ports; + unsigned int reg_shift; + int (*setup)(struct exar8250 *, struct pci_dev *, struct uart_8250_port *, int); + void (*exit)(struct pci_dev *); +}; + +struct exar8250 { + unsigned int nr; + struct exar8250_board *board; + void *virt; + int line[0]; +}; + +enum mctrl_gpio_idx { + UART_GPIO_CTS = 0, + UART_GPIO_DSR = 1, + UART_GPIO_DCD = 2, + UART_GPIO_RNG = 3, + UART_GPIO_RI = 3, + UART_GPIO_RTS = 4, + UART_GPIO_DTR = 5, + UART_GPIO_MAX = 6, +}; + +struct mctrl_gpios___2 { + struct uart_port *port; + struct gpio_desc___2 *gpio[6]; + int irq[6]; + unsigned int mctrl_prev; + bool mctrl_on; +}; + +struct memdev { + const char *name; + umode_t mode; + const struct file_operations *fops; + fmode_t fmode; +}; + +struct timer_rand_state { + cycles_t last_time; + long int last_delta; + long int last_delta2; +}; + +struct trace_event_raw_add_device_randomness { + struct trace_entry ent; + int bytes; + long unsigned int IP; + char __data[0]; +}; + +struct trace_event_raw_random__mix_pool_bytes { + struct trace_entry ent; + const char *pool_name; + int bytes; + long unsigned int IP; + char __data[0]; +}; + +struct trace_event_raw_credit_entropy_bits { + struct trace_entry ent; + const char *pool_name; + int bits; + int entropy_count; + long unsigned int IP; + char __data[0]; +}; + +struct trace_event_raw_push_to_pool { + struct trace_entry ent; + const char *pool_name; + int pool_bits; + int input_bits; + char __data[0]; +}; + +struct trace_event_raw_debit_entropy { + struct trace_entry ent; + const char *pool_name; + int debit_bits; + char __data[0]; +}; + +struct trace_event_raw_add_input_randomness { + struct trace_entry ent; + int input_bits; + char __data[0]; +}; + +struct trace_event_raw_add_disk_randomness { + struct trace_entry ent; + dev_t dev; + int input_bits; + char __data[0]; +}; + +struct trace_event_raw_xfer_secondary_pool { + struct trace_entry ent; + const char *pool_name; + int xfer_bits; + int request_bits; + int pool_entropy; + int input_entropy; + char __data[0]; +}; + +struct trace_event_raw_random__get_random_bytes { + struct trace_entry ent; + int nbytes; + long unsigned int IP; + char __data[0]; +}; + +struct trace_event_raw_random__extract_entropy { + struct trace_entry ent; + const char *pool_name; + int nbytes; + int entropy_count; + long unsigned int IP; + char __data[0]; +}; + +struct trace_event_raw_random_read { + struct trace_entry ent; + int got_bits; + int need_bits; + int pool_left; + int input_left; + char __data[0]; +}; + +struct trace_event_raw_urandom_read { + struct trace_entry ent; + int got_bits; + int pool_left; + int input_left; + char __data[0]; +}; + +struct trace_event_raw_prandom_u32 { + struct trace_entry ent; + unsigned int ret; + char __data[0]; +}; + +struct trace_event_data_offsets_add_device_randomness {}; + +struct trace_event_data_offsets_random__mix_pool_bytes {}; + +struct trace_event_data_offsets_credit_entropy_bits {}; + +struct trace_event_data_offsets_push_to_pool {}; + +struct trace_event_data_offsets_debit_entropy {}; + +struct trace_event_data_offsets_add_input_randomness {}; + +struct trace_event_data_offsets_add_disk_randomness {}; + +struct trace_event_data_offsets_xfer_secondary_pool {}; + +struct trace_event_data_offsets_random__get_random_bytes {}; + +struct trace_event_data_offsets_random__extract_entropy {}; + +struct trace_event_data_offsets_random_read {}; + +struct trace_event_data_offsets_urandom_read {}; + +struct trace_event_data_offsets_prandom_u32 {}; + +typedef void (*btf_trace_add_device_randomness)(void *, int, long unsigned int); + +typedef void (*btf_trace_mix_pool_bytes)(void *, const char *, int, long unsigned int); + +typedef void (*btf_trace_mix_pool_bytes_nolock)(void *, const char *, int, long unsigned int); + +typedef void (*btf_trace_credit_entropy_bits)(void *, const char *, int, int, long unsigned int); + +typedef void (*btf_trace_push_to_pool)(void *, const char *, int, int); + +typedef void (*btf_trace_debit_entropy)(void *, const char *, int); + +typedef void (*btf_trace_add_input_randomness)(void *, int); + +typedef void (*btf_trace_add_disk_randomness)(void *, dev_t, int); + +typedef void (*btf_trace_xfer_secondary_pool)(void *, const char *, int, int, int, int); + +typedef void (*btf_trace_get_random_bytes)(void *, int, long unsigned int); + +typedef void (*btf_trace_get_random_bytes_arch)(void *, int, long unsigned int); + +typedef void (*btf_trace_extract_entropy)(void *, const char *, int, int, long unsigned int); + +typedef void (*btf_trace_extract_entropy_user)(void *, const char *, int, int, long unsigned int); + +typedef void (*btf_trace_random_read)(void *, int, int, int, int); + +typedef void (*btf_trace_urandom_read)(void *, int, int, int); + +typedef void (*btf_trace_prandom_u32)(void *, unsigned int); + +struct poolinfo { + int poolbitshift; + int poolwords; + int poolbytes; + int poolfracbits; + int tap1; + int tap2; + int tap3; + int tap4; + int tap5; +}; + +struct crng_state { + __u32 state[16]; + long unsigned int init_time; + spinlock_t lock; +}; + +struct entropy_store { + const struct poolinfo *poolinfo; + __u32 *pool; + const char *name; + spinlock_t lock; + short unsigned int add_ptr; + short unsigned int input_rotate; + int entropy_count; + unsigned int initialized: 1; + unsigned int last_data_init: 1; + __u8 last_data[10]; +}; + +struct fast_pool { + __u32 pool[4]; + long unsigned int last; + short unsigned int reg_idx; + unsigned char count; +}; + +struct batched_entropy { + union { + u64 entropy_u64[8]; + u32 entropy_u32[16]; + }; + unsigned int position; + spinlock_t batch_lock; +}; + +struct virtio_console_config { + __virtio16 cols; + __virtio16 rows; + __virtio32 max_nr_ports; + __virtio32 emerg_wr; +}; + +struct virtio_console_control { + __virtio32 id; + __virtio16 event; + __virtio16 value; +}; + +struct ports_driver_data { + struct class *class; + struct dentry *debugfs_dir; + struct list_head portdevs; + unsigned int next_vtermno; + struct list_head consoles; +}; + +struct console___2 { + struct list_head list; + struct hvc_struct *hvc; + struct winsize ws; + u32 vtermno; +}; + +struct port_buffer { + char *buf; + size_t size; + size_t len; + size_t offset; + dma_addr_t dma; + struct device *dev; + struct list_head list; + unsigned int sgpages; + struct scatterlist sg[0]; +}; + +struct ports_device { + struct list_head list; + struct work_struct control_work; + struct work_struct config_work; + struct list_head ports; + spinlock_t ports_lock; + spinlock_t c_ivq_lock; + spinlock_t c_ovq_lock; + u32 max_nr_ports; + struct virtio_device *vdev; + struct virtqueue *c_ivq; + struct virtqueue *c_ovq; + struct virtio_console_control cpkt; + struct virtqueue **in_vqs; + struct virtqueue **out_vqs; + int chr_major; +}; + +struct port_stats { + long unsigned int bytes_sent; + long unsigned int bytes_received; + long unsigned int bytes_discarded; +}; + +struct port { + struct list_head list; + struct ports_device *portdev; + struct port_buffer *inbuf; + spinlock_t inbuf_lock; + spinlock_t outvq_lock; + struct virtqueue *in_vq; + struct virtqueue *out_vq; + struct dentry *debugfs_file; + struct port_stats stats; + struct console___2 cons; + struct cdev *cdev; + struct device *dev; + struct kref kref; + wait_queue_head_t waitqueue; + char *name; + struct fasync_struct *async_queue; + u32 id; + bool outvq_full; + bool host_connected; + bool guest_connected; +}; + +struct sg_list { + unsigned int n; + unsigned int size; + size_t len; + struct scatterlist *sg; +}; + +struct hpet_info { + long unsigned int hi_ireqfreq; + long unsigned int hi_flags; + short unsigned int hi_hpet; + short unsigned int hi_timer; +}; + +struct hpet_timer { + u64 hpet_config; + union { + u64 _hpet_hc64; + u32 _hpet_hc32; + long unsigned int _hpet_compare; + } _u1; + u64 hpet_fsb[2]; +}; + +struct hpet { + u64 hpet_cap; + u64 res0; + u64 hpet_config; + u64 res1; + u64 hpet_isr; + u64 res2[25]; + union { + u64 _hpet_mc64; + u32 _hpet_mc32; + long unsigned int _hpet_mc; + } _u0; + u64 res3; + struct hpet_timer hpet_timers[1]; +}; + +struct hpets; + +struct hpet_dev { + struct hpets *hd_hpets; + struct hpet *hd_hpet; + struct hpet_timer *hd_timer; + long unsigned int hd_ireqfreq; + long unsigned int hd_irqdata; + wait_queue_head_t hd_waitqueue; + struct fasync_struct *hd_async_queue; + unsigned int hd_flags; + unsigned int hd_irq; + unsigned int hd_hdwirq; + char hd_name[7]; +}; + +struct hpets { + struct hpets *hp_next; + struct hpet *hp_hpet; + long unsigned int hp_hpet_phys; + struct clocksource *hp_clocksource; + long long unsigned int hp_tick_freq; + long unsigned int hp_delta; + unsigned int hp_ntimer; + unsigned int hp_which; + struct hpet_dev hp_dev[0]; +}; + +struct compat_hpet_info { + compat_ulong_t hi_ireqfreq; + compat_ulong_t hi_flags; + short unsigned int hi_hpet; + short unsigned int hi_timer; +}; + +struct nvram_ops { + ssize_t (*get_size)(); + unsigned char (*read_byte)(int); + void (*write_byte)(unsigned char, int); + ssize_t (*read)(char *, size_t, loff_t *); + ssize_t (*write)(char *, size_t, loff_t *); + long int (*initialize)(); + long int (*set_checksum)(); +}; + +struct intel_rng_hw { + struct pci_dev *dev; + void *mem; + u8 bios_cntl_off; + u8 bios_cntl_val; + u8 fwh_dec_en1_off; + u8 fwh_dec_en1_val; +}; + +enum { + VIA_STRFILT_CNT_SHIFT = 16, + VIA_STRFILT_FAIL = 32768, + VIA_STRFILT_ENABLE = 16384, + VIA_RAWBITS_ENABLE = 8192, + VIA_RNG_ENABLE = 64, + VIA_NOISESRC1 = 256, + VIA_NOISESRC2 = 512, + VIA_XSTORE_CNT_MASK = 15, + VIA_RNG_CHUNK_8 = 0, + VIA_RNG_CHUNK_4 = 1, + VIA_RNG_CHUNK_4_MASK = 4294967295, + VIA_RNG_CHUNK_2 = 2, + VIA_RNG_CHUNK_2_MASK = 65535, + VIA_RNG_CHUNK_1 = 3, + VIA_RNG_CHUNK_1_MASK = 255, +}; + +struct agp_bridge_data___2; + +struct agp_memory { + struct agp_memory *next; + struct agp_memory *prev; + struct agp_bridge_data___2 *bridge; + struct page **pages; + size_t page_count; + int key; + int num_scratch_pages; + off_t pg_start; + u32 type; + u32 physical; + bool is_bound; + bool is_flushed; + struct list_head mapped_list; + struct scatterlist *sg_list; + int num_sg; +}; + +struct agp_bridge_driver; + +struct agp_bridge_data___2 { + const struct agp_version *version; + const struct agp_bridge_driver *driver; + const struct vm_operations_struct *vm_ops; + void *previous_size; + void *current_size; + void *dev_private_data; + struct pci_dev *dev; + u32 *gatt_table; + u32 *gatt_table_real; + long unsigned int scratch_page; + struct page *scratch_page_page; + dma_addr_t scratch_page_dma; + long unsigned int gart_bus_addr; + long unsigned int gatt_bus_addr; + u32 mode; + enum chipset_type type; + long unsigned int *key_list; + atomic_t current_memory_agp; + atomic_t agp_in_use; + int max_memory_agp; + int aperture_size_idx; + int capndx; + int flags; + char major_version; + char minor_version; + struct list_head list; + u32 apbase_config; + struct list_head mapped_list; + spinlock_t mapped_lock; +}; + +enum aper_size_type { + U8_APER_SIZE = 0, + U16_APER_SIZE = 1, + U32_APER_SIZE = 2, + LVL2_APER_SIZE = 3, + FIXED_APER_SIZE = 4, +}; + +struct gatt_mask { + long unsigned int mask; + u32 type; +}; + +struct agp_bridge_driver { + struct module *owner; + const void *aperture_sizes; + int num_aperture_sizes; + enum aper_size_type size_type; + bool cant_use_aperture; + bool needs_scratch_page; + const struct gatt_mask *masks; + int (*fetch_size)(); + int (*configure)(); + void (*agp_enable)(struct agp_bridge_data___2 *, u32); + void (*cleanup)(); + void (*tlb_flush)(struct agp_memory *); + long unsigned int (*mask_memory)(struct agp_bridge_data___2 *, dma_addr_t, int); + void (*cache_flush)(); + int (*create_gatt_table)(struct agp_bridge_data___2 *); + int (*free_gatt_table)(struct agp_bridge_data___2 *); + int (*insert_memory)(struct agp_memory *, off_t, int); + int (*remove_memory)(struct agp_memory *, off_t, int); + struct agp_memory * (*alloc_by_type)(size_t, int); + void (*free_by_type)(struct agp_memory *); + struct page * (*agp_alloc_page)(struct agp_bridge_data___2 *); + int (*agp_alloc_pages)(struct agp_bridge_data___2 *, struct agp_memory *, size_t); + void (*agp_destroy_page)(struct page *, int); + void (*agp_destroy_pages)(struct agp_memory *); + int (*agp_type_to_mask_type)(struct agp_bridge_data___2 *, int); +}; + +struct agp_info { + struct agp_version version; + u32 bridge_id; + u32 agp_mode; + long unsigned int aper_base; + size_t aper_size; + size_t pg_total; + size_t pg_system; + size_t pg_used; +}; + +struct agp_setup { + u32 agp_mode; +}; + +struct agp_segment { + off_t pg_start; + size_t pg_count; + int prot; +}; + +struct agp_segment_priv { + off_t pg_start; + size_t pg_count; + pgprot_t prot; +}; + +struct agp_region { + pid_t pid; + size_t seg_count; + struct agp_segment *seg_list; +}; + +struct agp_allocate { + int key; + size_t pg_count; + u32 type; + u32 physical; +}; + +struct agp_bind { + int key; + off_t pg_start; +}; + +struct agp_unbind { + int key; + u32 priority; +}; + +struct agp_client { + struct agp_client *next; + struct agp_client *prev; + pid_t pid; + int num_segments; + struct agp_segment_priv **segments; +}; + +struct agp_controller { + struct agp_controller *next; + struct agp_controller *prev; + pid_t pid; + int num_clients; + struct agp_memory *pool; + struct agp_client *clients; +}; + +struct agp_file_private { + struct agp_file_private *next; + struct agp_file_private *prev; + pid_t my_pid; + long unsigned int access_flags; +}; + +struct agp_front_data { + struct mutex agp_mutex; + struct agp_controller *current_controller; + struct agp_controller *controllers; + struct agp_file_private *file_priv_list; + bool used_by_controller; + bool backend_acquired; +}; + +struct aper_size_info_8 { + int size; + int num_entries; + int page_order; + u8 size_value; +}; + +struct aper_size_info_16 { + int size; + int num_entries; + int page_order; + u16 size_value; +}; + +struct aper_size_info_32 { + int size; + int num_entries; + int page_order; + u32 size_value; +}; + +struct aper_size_info_lvl2 { + int size; + int num_entries; + u32 size_value; +}; + +struct aper_size_info_fixed { + int size; + int num_entries; + int page_order; +}; + +struct agp_3_5_dev { + struct list_head list; + u8 capndx; + u32 maxbw; + struct pci_dev *dev; +}; + +struct isoch_data { + u32 maxbw; + u32 n; + u32 y; + u32 l; + u32 rq; + struct agp_3_5_dev *dev; +}; + +struct agp_info32 { + struct agp_version version; + u32 bridge_id; + u32 agp_mode; + compat_long_t aper_base; + compat_size_t aper_size; + compat_size_t pg_total; + compat_size_t pg_system; + compat_size_t pg_used; +}; + +struct agp_segment32 { + compat_off_t pg_start; + compat_size_t pg_count; + compat_int_t prot; +}; + +struct agp_region32 { + compat_pid_t pid; + compat_size_t seg_count; + struct agp_segment32 *seg_list; +}; + +struct agp_allocate32 { + compat_int_t key; + compat_size_t pg_count; + u32 type; + u32 physical; +}; + +struct agp_bind32 { + compat_int_t key; + compat_off_t pg_start; +}; + +struct agp_unbind32 { + compat_int_t key; + u32 priority; +}; + +struct intel_agp_driver_description { + unsigned int chip_id; + char *name; + const struct agp_bridge_driver *driver; +}; + +struct intel_gtt_driver { + unsigned int gen: 8; + unsigned int is_g33: 1; + unsigned int is_pineview: 1; + unsigned int is_ironlake: 1; + unsigned int has_pgtbl_enable: 1; + unsigned int dma_mask_size: 8; + int (*setup)(); + void (*cleanup)(); + void (*write_entry)(dma_addr_t, unsigned int, unsigned int); + bool (*check_flags)(unsigned int); + void (*chipset_flush)(); +}; + +struct _intel_private { + const struct intel_gtt_driver *driver; + struct pci_dev *pcidev; + struct pci_dev *bridge_dev; + u8 *registers; + phys_addr_t gtt_phys_addr; + u32 PGETBL_save; + u32 *gtt; + bool clear_fake_agp; + int num_dcache_entries; + void *i9xx_flush_page; + char *i81x_gtt_table; + struct resource ifp_resource; + int resource_valid; + struct page *scratch_page; + phys_addr_t scratch_page_dma; + int refcount; + unsigned int needs_dmar: 1; + phys_addr_t gma_bus_addr; + resource_size_t stolen_size; + unsigned int gtt_total_entries; + unsigned int gtt_mappable_entries; +}; + +struct intel_gtt_driver_description { + unsigned int gmch_chip_id; + char *name; + const struct intel_gtt_driver *gtt_driver; +}; + +struct agp_device_ids { + short unsigned int device_id; + enum chipset_type chipset; + const char *chipset_name; + int (*chipset_setup)(struct pci_dev *); +}; + +enum tpm2_startup_types { + TPM2_SU_CLEAR = 0, + TPM2_SU_STATE = 1, +}; + +enum tpm_chip_flags { + TPM_CHIP_FLAG_TPM2 = 2, + TPM_CHIP_FLAG_IRQ = 4, + TPM_CHIP_FLAG_VIRTUAL = 8, + TPM_CHIP_FLAG_HAVE_TIMEOUTS = 16, + TPM_CHIP_FLAG_ALWAYS_POWERED = 32, + TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED = 64, +}; + +enum tpm2_structures { + TPM2_ST_NO_SESSIONS = 32769, + TPM2_ST_SESSIONS = 32770, +}; + +enum tpm2_return_codes { + TPM2_RC_SUCCESS = 0, + TPM2_RC_HASH = 131, + TPM2_RC_HANDLE = 139, + TPM2_RC_INITIALIZE = 256, + TPM2_RC_FAILURE = 257, + TPM2_RC_DISABLED = 288, + TPM2_RC_COMMAND_CODE = 323, + TPM2_RC_TESTING = 2314, + TPM2_RC_REFERENCE_H0 = 2320, + TPM2_RC_RETRY = 2338, +}; + +struct tpm_header { + __be16 tag; + __be32 length; + union { + __be32 ordinal; + __be32 return_code; + }; +} __attribute__((packed)); + +struct file_priv { + struct tpm_chip *chip; + struct tpm_space *space; + struct mutex buffer_mutex; + struct timer_list user_read_timer; + struct work_struct timeout_work; + struct work_struct async_work; + wait_queue_head_t async_wait; + ssize_t response_length; + bool response_read; + bool command_enqueued; + u8 data_buffer[4096]; +}; + +enum TPM_OPS_FLAGS { + TPM_OPS_AUTO_STARTUP = 1, +}; + +enum tpm2_timeouts { + TPM2_TIMEOUT_A = 750, + TPM2_TIMEOUT_B = 2000, + TPM2_TIMEOUT_C = 200, + TPM2_TIMEOUT_D = 30, + TPM2_DURATION_SHORT = 20, + TPM2_DURATION_MEDIUM = 750, + TPM2_DURATION_LONG = 2000, + TPM2_DURATION_LONG_LONG = 300000, + TPM2_DURATION_DEFAULT = 120000, +}; + +enum tpm2_command_codes { + TPM2_CC_FIRST = 287, + TPM2_CC_HIERARCHY_CONTROL = 289, + TPM2_CC_HIERARCHY_CHANGE_AUTH = 297, + TPM2_CC_CREATE_PRIMARY = 305, + TPM2_CC_SEQUENCE_COMPLETE = 318, + TPM2_CC_SELF_TEST = 323, + TPM2_CC_STARTUP = 324, + TPM2_CC_SHUTDOWN = 325, + TPM2_CC_NV_READ = 334, + TPM2_CC_CREATE = 339, + TPM2_CC_LOAD = 343, + TPM2_CC_SEQUENCE_UPDATE = 348, + TPM2_CC_UNSEAL = 350, + TPM2_CC_CONTEXT_LOAD = 353, + TPM2_CC_CONTEXT_SAVE = 354, + TPM2_CC_FLUSH_CONTEXT = 357, + TPM2_CC_VERIFY_SIGNATURE = 375, + TPM2_CC_GET_CAPABILITY = 378, + TPM2_CC_GET_RANDOM = 379, + TPM2_CC_PCR_READ = 382, + TPM2_CC_PCR_EXTEND = 386, + TPM2_CC_EVENT_SEQUENCE_COMPLETE = 389, + TPM2_CC_HASH_SEQUENCE_START = 390, + TPM2_CC_CREATE_LOADED = 401, + TPM2_CC_LAST = 403, +}; + +struct tpm_buf { + unsigned int flags; + u8 *data; +}; + +enum tpm_timeout { + TPM_TIMEOUT = 5, + TPM_TIMEOUT_RETRY = 100, + TPM_TIMEOUT_RANGE_US = 300, + TPM_TIMEOUT_POLL = 1, + TPM_TIMEOUT_USECS_MIN = 100, + TPM_TIMEOUT_USECS_MAX = 500, +}; + +enum tpm_buf_flags { + TPM_BUF_OVERFLOW = 1, +}; + +struct stclear_flags_t { + __be16 tag; + u8 deactivated; + u8 disableForceClear; + u8 physicalPresence; + u8 physicalPresenceLock; + u8 bGlobalLock; +} __attribute__((packed)); + +struct tpm1_version { + u8 major; + u8 minor; + u8 rev_major; + u8 rev_minor; +}; + +struct tpm1_version2 { + __be16 tag; + struct tpm1_version version; +}; + +struct timeout_t { + __be32 a; + __be32 b; + __be32 c; + __be32 d; +}; + +struct duration_t { + __be32 tpm_short; + __be32 tpm_medium; + __be32 tpm_long; +}; + +struct permanent_flags_t { + __be16 tag; + u8 disable; + u8 ownership; + u8 deactivated; + u8 readPubek; + u8 disableOwnerClear; + u8 allowMaintenance; + u8 physicalPresenceLifetimeLock; + u8 physicalPresenceHWEnable; + u8 physicalPresenceCMDEnable; + u8 CEKPUsed; + u8 TPMpost; + u8 TPMpostLock; + u8 FIPS; + u8 operator; + u8 enableRevokeEK; + u8 nvLocked; + u8 readSRKPub; + u8 tpmEstablished; + u8 maintenanceDone; + u8 disableFullDALogicInfo; +}; + +typedef union { + struct permanent_flags_t perm_flags; + struct stclear_flags_t stclear_flags; + __u8 owned; + __be32 num_pcrs; + struct tpm1_version version1; + struct tpm1_version2 version2; + __be32 manufacturer_id; + struct timeout_t timeout; + struct duration_t duration; +} cap_t; + +enum tpm_capabilities { + TPM_CAP_FLAG = 4, + TPM_CAP_PROP = 5, + TPM_CAP_VERSION_1_1 = 6, + TPM_CAP_VERSION_1_2 = 26, +}; + +enum tpm_sub_capabilities { + TPM_CAP_PROP_PCR = 257, + TPM_CAP_PROP_MANUFACTURER = 259, + TPM_CAP_FLAG_PERM = 264, + TPM_CAP_FLAG_VOL = 265, + TPM_CAP_PROP_OWNER = 273, + TPM_CAP_PROP_TIS_TIMEOUT = 277, + TPM_CAP_PROP_TIS_DURATION = 288, +}; + +struct tpm1_get_random_out { + __be32 rng_data_len; + u8 rng_data[128]; +}; + +enum tpm2_const { + TPM2_PLATFORM_PCR = 24, + TPM2_PCR_SELECT_MIN = 3, +}; + +enum tpm2_permanent_handles { + TPM2_RS_PW = 1073741833, +}; + +enum tpm2_capabilities { + TPM2_CAP_HANDLES = 1, + TPM2_CAP_COMMANDS = 2, + TPM2_CAP_PCRS = 5, + TPM2_CAP_TPM_PROPERTIES = 6, +}; + +enum tpm2_properties { + TPM_PT_TOTAL_COMMANDS = 297, +}; + +enum tpm2_cc_attrs { + TPM2_CC_ATTR_CHANDLES = 25, + TPM2_CC_ATTR_RHANDLE = 28, +}; + +struct tpm2_hash { + unsigned int crypto_id; + unsigned int tpm_id; +}; + +struct tpm2_pcr_read_out { + __be32 update_cnt; + __be32 pcr_selects_cnt; + __be16 hash_alg; + u8 pcr_select_size; + u8 pcr_select[3]; + __be32 digests_cnt; + __be16 digest_size; + u8 digest[0]; +} __attribute__((packed)); + +struct tpm2_null_auth_area { + __be32 handle; + __be16 nonce_size; + u8 attributes; + __be16 auth_size; +} __attribute__((packed)); + +struct tpm2_get_random_out { + __be16 size; + u8 buffer[128]; +}; + +struct tpm2_get_cap_out { + u8 more_data; + __be32 subcap_id; + __be32 property_cnt; + __be32 property_id; + __be32 value; +} __attribute__((packed)); + +struct tpm2_pcr_selection { + __be16 hash_alg; + u8 size_of_select; + u8 pcr_select[3]; +}; + +struct tpmrm_priv { + struct file_priv priv; + struct tpm_space space; +}; + +enum tpm2_handle_types { + TPM2_HT_HMAC_SESSION = 33554432, + TPM2_HT_POLICY_SESSION = 50331648, + TPM2_HT_TRANSIENT = 2147483648, +}; + +struct tpm2_context { + __be64 sequence; + __be32 saved_handle; + __be32 hierarchy; + __be16 blob_size; +} __attribute__((packed)); + +struct tpm2_cap_handles { + u8 more_data; + __be32 capability; + __be32 count; + __be32 handles[0]; +} __attribute__((packed)); + +struct tpm_readpubek_out { + u8 algorithm[4]; + u8 encscheme[2]; + u8 sigscheme[2]; + __be32 paramsize; + u8 parameters[12]; + __be32 keysize; + u8 modulus[256]; + u8 checksum[20]; +}; + +struct tcpa_event { + u32 pcr_index; + u32 event_type; + u8 pcr_value[20]; + u32 event_size; + u8 event_data[0]; +}; + +enum tcpa_event_types { + PREBOOT = 0, + POST_CODE = 1, + UNUSED = 2, + NO_ACTION = 3, + SEPARATOR = 4, + ACTION = 5, + EVENT_TAG = 6, + SCRTM_CONTENTS = 7, + SCRTM_VERSION = 8, + CPU_MICROCODE = 9, + PLATFORM_CONFIG_FLAGS = 10, + TABLE_OF_DEVICES = 11, + COMPACT_HASH = 12, + IPL = 13, + IPL_PARTITION_DATA = 14, + NONHOST_CODE = 15, + NONHOST_CONFIG = 16, + NONHOST_INFO = 17, +}; + +struct tcpa_pc_event { + u32 event_id; + u32 event_size; + u8 event_data[0]; +}; + +enum tcpa_pc_event_ids { + SMBIOS = 1, + BIS_CERT = 2, + POST_BIOS_ROM = 3, + ESCD = 4, + CMOS = 5, + NVRAM = 6, + OPTION_ROM_EXEC = 7, + OPTION_ROM_CONFIG = 8, + OPTION_ROM_MICROCODE = 10, + S_CRTM_VERSION = 11, + S_CRTM_CONTENTS = 12, + POST_CONTENTS = 13, + HOST_TABLE_OF_DEVICES = 14, +}; + +struct tcg_efi_specid_event_algs { + u16 alg_id; + u16 digest_size; +}; + +struct tcg_efi_specid_event_head { + u8 signature[16]; + u32 platform_class; + u8 spec_version_minor; + u8 spec_version_major; + u8 spec_errata; + u8 uintnsize; + u32 num_algs; + struct tcg_efi_specid_event_algs digest_sizes[0]; +}; + +struct tcg_pcr_event { + u32 pcr_idx; + u32 event_type; + u8 digest[20]; + u32 event_size; + u8 event[0]; +}; + +struct tcg_event_field { + u32 event_size; + u8 event[0]; +}; + +struct tcg_pcr_event2_head { + u32 pcr_idx; + u32 event_type; + u32 count; + struct tpm_digest digests[0]; +}; + +struct acpi_table_tpm2 { + struct acpi_table_header header; + u16 platform_class; + u16 reserved; + u64 control_address; + u32 start_method; +} __attribute__((packed)); + +struct acpi_tpm2_phy { + u8 start_method_specific[12]; + u32 log_area_minimum_length; + u64 log_area_start_address; +}; + +enum bios_platform_class { + BIOS_CLIENT = 0, + BIOS_SERVER = 1, +}; + +struct client_hdr { + u32 log_max_len; + u64 log_start_addr; +} __attribute__((packed)); + +struct server_hdr { + u16 reserved; + u64 log_max_len; + u64 log_start_addr; +} __attribute__((packed)); + +struct acpi_tcpa { + struct acpi_table_header hdr; + u16 platform_class; + union { + struct client_hdr client; + struct server_hdr server; + }; +} __attribute__((packed)); + +struct linux_efi_tpm_eventlog { + u32 size; + u32 final_events_preboot_size; + u8 version; + u8 log[0]; +}; + +struct efi_tcg2_final_events_table { + u64 version; + u64 nr_events; + u8 events[0]; +}; + +enum tis_access { + TPM_ACCESS_VALID = 128, + TPM_ACCESS_ACTIVE_LOCALITY = 32, + TPM_ACCESS_REQUEST_PENDING = 4, + TPM_ACCESS_REQUEST_USE = 2, +}; + +enum tis_status { + TPM_STS_VALID = 128, + TPM_STS_COMMAND_READY = 64, + TPM_STS_GO = 32, + TPM_STS_DATA_AVAIL = 16, + TPM_STS_DATA_EXPECT = 8, + TPM_STS_READ_ZERO = 35, +}; + +enum tis_int_flags { + TPM_GLOBAL_INT_ENABLE = 2147483648, + TPM_INTF_BURST_COUNT_STATIC = 256, + TPM_INTF_CMD_READY_INT = 128, + TPM_INTF_INT_EDGE_FALLING = 64, + TPM_INTF_INT_EDGE_RISING = 32, + TPM_INTF_INT_LEVEL_LOW = 16, + TPM_INTF_INT_LEVEL_HIGH = 8, + TPM_INTF_LOCALITY_CHANGE_INT = 4, + TPM_INTF_STS_VALID_INT = 2, + TPM_INTF_DATA_AVAIL_INT = 1, +}; + +enum tis_defaults { + TIS_MEM_LEN = 20480, + TIS_SHORT_TIMEOUT = 750, + TIS_LONG_TIMEOUT = 2000, +}; + +enum tpm_tis_flags { + TPM_TIS_ITPM_WORKAROUND = 1, +}; + +struct tpm_tis_phy_ops; + +struct tpm_tis_data { + u16 manufacturer_id; + int locality; + int irq; + bool irq_tested; + unsigned int flags; + void *ilb_base_addr; + u16 clkrun_enabled; + wait_queue_head_t int_queue; + wait_queue_head_t read_queue; + const struct tpm_tis_phy_ops *phy_ops; + short unsigned int rng_quality; +}; + +struct tpm_tis_phy_ops { + int (*read_bytes)(struct tpm_tis_data *, u32, u16, u8 *); + int (*write_bytes)(struct tpm_tis_data *, u32, u16, const u8 *); + int (*read16)(struct tpm_tis_data *, u32, u16 *); + int (*read32)(struct tpm_tis_data *, u32, u32 *); + int (*write32)(struct tpm_tis_data *, u32, u32); +}; + +struct tis_vendor_durations_override { + u32 did_vid; + struct tpm1_version version; + long unsigned int durations[3]; +}; + +struct tis_vendor_timeout_override { + u32 did_vid; + long unsigned int timeout_us[4]; +}; + +struct tpm_info { + struct resource res; + int irq; +}; + +struct tpm_tis_tcg_phy { + struct tpm_tis_data priv; + void *iobase; +}; + +enum crb_defaults { + CRB_ACPI_START_REVISION_ID = 1, + CRB_ACPI_START_INDEX = 1, +}; + +enum crb_loc_ctrl { + CRB_LOC_CTRL_REQUEST_ACCESS = 1, + CRB_LOC_CTRL_RELINQUISH = 2, +}; + +enum crb_loc_state { + CRB_LOC_STATE_LOC_ASSIGNED = 2, + CRB_LOC_STATE_TPM_REG_VALID_STS = 128, +}; + +enum crb_ctrl_req { + CRB_CTRL_REQ_CMD_READY = 1, + CRB_CTRL_REQ_GO_IDLE = 2, +}; + +enum crb_ctrl_sts { + CRB_CTRL_STS_ERROR = 1, + CRB_CTRL_STS_TPM_IDLE = 2, +}; + +enum crb_start { + CRB_START_INVOKE = 1, +}; + +enum crb_cancel { + CRB_CANCEL_INVOKE = 1, +}; + +struct crb_regs_head { + u32 loc_state; + u32 reserved1; + u32 loc_ctrl; + u32 loc_sts; + u8 reserved2[32]; + u64 intf_id; + u64 ctrl_ext; +}; + +struct crb_regs_tail { + u32 ctrl_req; + u32 ctrl_sts; + u32 ctrl_cancel; + u32 ctrl_start; + u32 ctrl_int_enable; + u32 ctrl_int_sts; + u32 ctrl_cmd_size; + u32 ctrl_cmd_pa_low; + u32 ctrl_cmd_pa_high; + u32 ctrl_rsp_size; + u64 ctrl_rsp_pa; +}; + +enum crb_status { + CRB_DRV_STS_COMPLETE = 1, +}; + +struct crb_priv { + u32 sm; + const char *hid; + struct crb_regs_head *regs_h; + struct crb_regs_tail *regs_t; + u8 *cmd; + u8 *rsp; + u32 cmd_size; + u32 smc_func_id; +}; + +struct tpm2_crb_smc { + u32 interrupt; + u8 interrupt_flags; + u8 op_flags; + u16 reserved2; + u32 smc_func_id; +}; + +struct acpi_table_dmar { + struct acpi_table_header header; + u8 width; + u8 flags; + u8 reserved[10]; +}; + +struct acpi_dmar_header { + u16 type; + u16 length; +}; + +enum acpi_dmar_type { + ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, + ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, + ACPI_DMAR_TYPE_ROOT_ATS = 2, + ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3, + ACPI_DMAR_TYPE_NAMESPACE = 4, + ACPI_DMAR_TYPE_RESERVED = 5, +}; + +struct acpi_dmar_device_scope { + u8 entry_type; + u8 length; + u16 reserved; + u8 enumeration_id; + u8 bus; +}; + +enum acpi_dmar_scope_type { + ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0, + ACPI_DMAR_SCOPE_TYPE_ENDPOINT = 1, + ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, + ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3, + ACPI_DMAR_SCOPE_TYPE_HPET = 4, + ACPI_DMAR_SCOPE_TYPE_NAMESPACE = 5, + ACPI_DMAR_SCOPE_TYPE_RESERVED = 6, +}; + +struct acpi_dmar_pci_path { + u8 device; + u8 function; +}; + +struct acpi_dmar_hardware_unit { + struct acpi_dmar_header header; + u8 flags; + u8 reserved; + u16 segment; + u64 address; +}; + +struct acpi_dmar_reserved_memory { + struct acpi_dmar_header header; + u16 reserved; + u16 segment; + u64 base_address; + u64 end_address; +}; + +struct acpi_dmar_atsr { + struct acpi_dmar_header header; + u8 flags; + u8 reserved; + u16 segment; +}; + +struct acpi_dmar_rhsa { + struct acpi_dmar_header header; + u32 reserved; + u64 base_address; + u32 proximity_domain; +} __attribute__((packed)); + +struct acpi_dmar_andd { + struct acpi_dmar_header header; + u8 reserved[3]; + u8 device_number; + char device_name[1]; +} __attribute__((packed)); + +struct dmar_dev_scope { + struct device *dev; + u8 bus; + u8 devfn; +}; + +struct intel_iommu; + +struct dmar_drhd_unit { + struct list_head list; + struct acpi_dmar_header *hdr; + u64 reg_base_addr; + struct dmar_dev_scope *devices; + int devices_cnt; + u16 segment; + u8 ignored: 1; + u8 include_all: 1; + u8 gfx_dedicated: 1; + struct intel_iommu *iommu; +}; + +struct iommu_flush { + void (*flush_context)(struct intel_iommu *, u16, u16, u8, u64); + void (*flush_iotlb)(struct intel_iommu *, u16, u64, unsigned int, u64); +}; + +struct dmar_domain; + +struct root_entry; + +struct q_inval; + +struct ir_table; + +struct intel_iommu { + void *reg; + u64 reg_phys; + u64 reg_size; + u64 cap; + u64 ecap; + u64 vccap; + u32 gcmd; + raw_spinlock_t register_lock; + int seq_id; + int agaw; + int msagaw; + unsigned int irq; + unsigned int pr_irq; + u16 segment; + unsigned char name[13]; + long unsigned int *domain_ids; + struct dmar_domain ***domains; + spinlock_t lock; + struct root_entry *root_entry; + struct iommu_flush flush; + struct q_inval *qi; + u32 *iommu_state; + struct ir_table *ir_table; + struct irq_domain *ir_domain; + struct irq_domain *ir_msi_domain; + struct iommu_device iommu; + int node; + u32 flags; + struct dmar_drhd_unit *drhd; +}; + +struct dmar_pci_path { + u8 bus; + u8 device; + u8 function; +}; + +struct dmar_pci_notify_info { + struct pci_dev *dev; + long unsigned int event; + int bus; + u16 seg; + u16 level; + struct dmar_pci_path path[0]; +}; + +struct irte { + union { + struct { + __u64 present: 1; + __u64 fpd: 1; + __u64 __res0: 6; + __u64 avail: 4; + __u64 __res1: 3; + __u64 pst: 1; + __u64 vector: 8; + __u64 __res2: 40; + }; + struct { + __u64 r_present: 1; + __u64 r_fpd: 1; + __u64 dst_mode: 1; + __u64 redir_hint: 1; + __u64 trigger_mode: 1; + __u64 dlvry_mode: 3; + __u64 r_avail: 4; + __u64 r_res0: 4; + __u64 r_vector: 8; + __u64 r_res1: 8; + __u64 dest_id: 32; + }; + struct { + __u64 p_present: 1; + __u64 p_fpd: 1; + __u64 p_res0: 6; + __u64 p_avail: 4; + __u64 p_res1: 2; + __u64 p_urgent: 1; + __u64 p_pst: 1; + __u64 p_vector: 8; + __u64 p_res2: 14; + __u64 pda_l: 26; + }; + __u64 low; + }; + union { + struct { + __u64 sid: 16; + __u64 sq: 2; + __u64 svt: 2; + __u64 __res3: 44; + }; + struct { + __u64 p_sid: 16; + __u64 p_sq: 2; + __u64 p_svt: 2; + __u64 p_res3: 12; + __u64 pda_h: 32; + }; + __u64 high; + }; +}; + +struct iova { + struct rb_node node; + long unsigned int pfn_hi; + long unsigned int pfn_lo; +}; + +struct iova_magazine; + +struct iova_cpu_rcache; + +struct iova_rcache { + spinlock_t lock; + long unsigned int depot_size; + struct iova_magazine *depot[32]; + struct iova_cpu_rcache *cpu_rcaches; +}; + +struct iova_domain; + +typedef void (*iova_flush_cb)(struct iova_domain *); + +typedef void (*iova_entry_dtor)(long unsigned int); + +struct iova_fq; + +struct iova_domain { + spinlock_t iova_rbtree_lock; + struct rb_root rbroot; + struct rb_node *cached_node; + struct rb_node *cached32_node; + long unsigned int granule; + long unsigned int start_pfn; + long unsigned int dma_32bit_pfn; + long unsigned int max32_alloc_size; + struct iova_fq *fq; + atomic64_t fq_flush_start_cnt; + atomic64_t fq_flush_finish_cnt; + struct iova anchor; + struct iova_rcache rcaches[6]; + iova_flush_cb flush_cb; + iova_entry_dtor entry_dtor; + struct timer_list fq_timer; + atomic_t fq_timer_on; +}; + +struct iova_fq_entry { + long unsigned int iova_pfn; + long unsigned int pages; + long unsigned int data; + u64 counter; +}; + +struct iova_fq { + struct iova_fq_entry entries[256]; + unsigned int head; + unsigned int tail; + spinlock_t lock; +}; + +enum { + QI_FREE = 0, + QI_IN_USE = 1, + QI_DONE = 2, + QI_ABORT = 3, +}; + +struct qi_desc { + u64 qw0; + u64 qw1; + u64 qw2; + u64 qw3; +}; + +struct q_inval { + raw_spinlock_t q_lock; + void *desc; + int *desc_status; + int free_head; + int free_tail; + int free_cnt; +}; + +struct ir_table { + struct irte *base; + long unsigned int *bitmap; +}; + +struct root_entry { + u64 lo; + u64 hi; +}; + +struct dma_pte; + +struct dmar_domain { + int nid; + unsigned int iommu_refcnt[128]; + u16 iommu_did[128]; + unsigned int auxd_refcnt; + bool has_iotlb_device; + struct list_head devices; + struct list_head auxd; + struct iova_domain iovad; + struct dma_pte *pgd; + int gaw; + int agaw; + int flags; + int iommu_coherency; + int iommu_snooping; + int iommu_count; + int iommu_superpage; + u64 max_addr; + u32 default_pasid; + struct iommu_domain domain; +}; + +struct dma_pte { + u64 val; +}; + +typedef int (*dmar_res_handler_t)(struct acpi_dmar_header *, void *); + +struct dmar_res_callback { + dmar_res_handler_t cb[5]; + void *arg[5]; + bool ignore_unhandled; + bool print_entry; +}; + +enum faulttype { + DMA_REMAP = 0, + INTR_REMAP = 1, + UNKNOWN = 2, +}; + +struct memory_notify { + long unsigned int start_pfn; + long unsigned int nr_pages; + int status_change_nid_normal; + int status_change_nid_high; + int status_change_nid; +}; + +typedef unsigned int ioasid_t; + +enum { + SR_DMAR_FECTL_REG = 0, + SR_DMAR_FEDATA_REG = 1, + SR_DMAR_FEADDR_REG = 2, + SR_DMAR_FEUADDR_REG = 3, + MAX_SR_DMAR_REGS = 4, +}; + +struct context_entry { + u64 lo; + u64 hi; +}; + +struct pasid_table; + +struct device_domain_info { + struct list_head link; + struct list_head global; + struct list_head table; + struct list_head auxiliary_domains; + u32 segment; + u8 bus; + u8 devfn; + u16 pfsid; + u8 pasid_supported: 3; + u8 pasid_enabled: 1; + u8 pri_supported: 1; + u8 pri_enabled: 1; + u8 ats_supported: 1; + u8 ats_enabled: 1; + u8 auxd_enabled: 1; + u8 ats_qdep; + struct device *dev; + struct intel_iommu *iommu; + struct dmar_domain *domain; + struct pasid_table *pasid_table; +}; + +struct pasid_table { + void *table; + int order; + u32 max_pasid; + struct list_head dev; +}; + +struct dmar_rmrr_unit { + struct list_head list; + struct acpi_dmar_header *hdr; + u64 base_address; + u64 end_address; + struct dmar_dev_scope *devices; + int devices_cnt; +}; + +struct dmar_atsr_unit { + struct list_head list; + struct acpi_dmar_header *hdr; + struct dmar_dev_scope *devices; + int devices_cnt; + u8 include_all: 1; +}; + +struct domain_context_mapping_data { + struct dmar_domain *domain; + struct intel_iommu *iommu; + struct pasid_table *table; +}; + +struct pasid_dir_entry { + u64 val; +}; + +struct pasid_entry { + u64 val[8]; +}; + +struct pasid_table_opaque { + struct pasid_table **pasid_table; + int segment; + int bus; + int devfn; +}; + +struct trace_event_raw_dma_map { + struct trace_entry ent; + u32 __data_loc_dev_name; + dma_addr_t dev_addr; + phys_addr_t phys_addr; + size_t size; + char __data[0]; +}; + +struct trace_event_raw_dma_unmap { + struct trace_entry ent; + u32 __data_loc_dev_name; + dma_addr_t dev_addr; + size_t size; + char __data[0]; +}; + +struct trace_event_raw_dma_map_sg { + struct trace_entry ent; + u32 __data_loc_dev_name; + dma_addr_t dev_addr; + phys_addr_t phys_addr; + size_t size; + int index; + int total; + char __data[0]; +}; + +struct trace_event_data_offsets_dma_map { + u32 dev_name; +}; + +struct trace_event_data_offsets_dma_unmap { + u32 dev_name; +}; + +struct trace_event_data_offsets_dma_map_sg { + u32 dev_name; +}; + +typedef void (*btf_trace_map_single)(void *, struct device *, dma_addr_t, phys_addr_t, size_t); + +typedef void (*btf_trace_bounce_map_single)(void *, struct device *, dma_addr_t, phys_addr_t, size_t); + +typedef void (*btf_trace_unmap_single)(void *, struct device *, dma_addr_t, size_t); + +typedef void (*btf_trace_unmap_sg)(void *, struct device *, dma_addr_t, size_t); + +typedef void (*btf_trace_bounce_unmap_single)(void *, struct device *, dma_addr_t, size_t); + +typedef void (*btf_trace_map_sg)(void *, struct device *, int, int, struct scatterlist *); + +typedef void (*btf_trace_bounce_map_sg)(void *, struct device *, int, int, struct scatterlist *); + +enum irq_remap_cap { + IRQ_POSTING_CAP = 0, +}; + +struct vcpu_data { + u64 pi_desc_addr; + u32 vector; +}; + +struct irq_remap_ops { + int capability; + int (*prepare)(); + int (*enable)(); + void (*disable)(); + int (*reenable)(int); + int (*enable_faulting)(); + struct irq_domain * (*get_irq_domain)(struct irq_alloc_info *); +}; + +enum irq_mode { + IRQ_REMAPPING = 0, + IRQ_POSTING = 1, +}; + +struct ioapic_scope { + struct intel_iommu *iommu; + unsigned int id; + unsigned int bus; + unsigned int devfn; +}; + +struct hpet_scope { + struct intel_iommu *iommu; + u8 id; + unsigned int bus; + unsigned int devfn; +}; + +struct irq_2_iommu { + struct intel_iommu *iommu; + u16 irte_index; + u16 sub_handle; + u8 irte_mask; + enum irq_mode mode; +}; + +struct intel_ir_data { + struct irq_2_iommu irq_2_iommu; + struct irte irte_entry; + union { + struct msi_msg msi_entry; + }; +}; + +struct set_msi_sid_data { + struct pci_dev *pdev; + u16 alias; + int count; + int busmatch_count; +}; + +struct iommu_group { + struct kobject kobj; + struct kobject *devices_kobj; + struct list_head devices; + struct mutex mutex; + struct blocking_notifier_head notifier; + void *iommu_data; + void (*iommu_data_release)(void *); + char *name; + int id; + struct iommu_domain *default_domain; + struct iommu_domain *domain; + struct list_head entry; +}; + +enum iommu_fault_type { + IOMMU_FAULT_DMA_UNRECOV = 1, + IOMMU_FAULT_PAGE_REQ = 2, +}; + +enum iommu_inv_granularity { + IOMMU_INV_GRANU_DOMAIN = 0, + IOMMU_INV_GRANU_PASID = 1, + IOMMU_INV_GRANU_ADDR = 2, + IOMMU_INV_GRANU_NR = 3, +}; + +struct fsl_mc_obj_desc { + char type[16]; + int id; + u16 vendor; + u16 ver_major; + u16 ver_minor; + u8 irq_count; + u8 region_count; + u32 state; + char label[16]; + u16 flags; +}; + +struct fsl_mc_io; + +struct fsl_mc_device_irq; + +struct fsl_mc_resource; + +struct fsl_mc_device { + struct device dev; + u64 dma_mask; + u16 flags; + u32 icid; + u16 mc_handle; + struct fsl_mc_io *mc_io; + struct fsl_mc_obj_desc obj_desc; + struct resource *regions; + struct fsl_mc_device_irq **irqs; + struct fsl_mc_resource *resource; + struct device_link *consumer_link; + char *driver_override; +}; + +enum fsl_mc_pool_type { + FSL_MC_POOL_DPMCP = 0, + FSL_MC_POOL_DPBP = 1, + FSL_MC_POOL_DPCON = 2, + FSL_MC_POOL_IRQ = 3, + FSL_MC_NUM_POOL_TYPES = 4, +}; + +struct fsl_mc_resource_pool; + +struct fsl_mc_resource { + enum fsl_mc_pool_type type; + s32 id; + void *data; + struct fsl_mc_resource_pool *parent_pool; + struct list_head node; +}; + +struct fsl_mc_device_irq { + struct msi_desc *msi_desc; + struct fsl_mc_device *mc_dev; + u8 dev_irq_index; + struct fsl_mc_resource resource; +}; + +struct fsl_mc_io { + struct device *dev; + u16 flags; + u32 portal_size; + phys_addr_t portal_phys_addr; + void *portal_virt_addr; + struct fsl_mc_device *dpmcp_dev; + union { + struct mutex mutex; + raw_spinlock_t spinlock; + }; +}; + +struct group_device { + struct list_head list; + struct device *dev; + char *name; +}; + +struct iommu_group_attribute { + struct attribute attr; + ssize_t (*show)(struct iommu_group *, char *); + ssize_t (*store)(struct iommu_group *, const char *, size_t); +}; + +struct group_for_pci_data { + struct pci_dev *pdev; + struct iommu_group *group; +}; + +struct __group_domain_type { + struct device *dev; + unsigned int type; +}; + +struct trace_event_raw_iommu_group_event { + struct trace_entry ent; + int gid; + u32 __data_loc_device; + char __data[0]; +}; + +struct trace_event_raw_iommu_device_event { + struct trace_entry ent; + u32 __data_loc_device; + char __data[0]; +}; + +struct trace_event_raw_map { + struct trace_entry ent; + u64 iova; + u64 paddr; + size_t size; + char __data[0]; +}; + +struct trace_event_raw_unmap { + struct trace_entry ent; + u64 iova; + size_t size; + size_t unmapped_size; + char __data[0]; +}; + +struct trace_event_raw_iommu_error { + struct trace_entry ent; + u32 __data_loc_device; + u32 __data_loc_driver; + u64 iova; + int flags; + char __data[0]; +}; + +struct trace_event_data_offsets_iommu_group_event { + u32 device; +}; + +struct trace_event_data_offsets_iommu_device_event { + u32 device; +}; + +struct trace_event_data_offsets_map {}; + +struct trace_event_data_offsets_unmap {}; + +struct trace_event_data_offsets_iommu_error { + u32 device; + u32 driver; +}; + +typedef void (*btf_trace_add_device_to_group)(void *, int, struct device *); + +typedef void (*btf_trace_remove_device_from_group)(void *, int, struct device *); + +typedef void (*btf_trace_attach_device_to_domain)(void *, struct device *); + +typedef void (*btf_trace_detach_device_from_domain)(void *, struct device *); + +typedef void (*btf_trace_map)(void *, long unsigned int, phys_addr_t, size_t); + +typedef void (*btf_trace_unmap)(void *, long unsigned int, size_t, size_t); + +typedef void (*btf_trace_io_page_fault)(void *, struct device *, long unsigned int, int); + +typedef ioasid_t (*ioasid_alloc_fn_t)(ioasid_t, ioasid_t, void *); + +typedef void (*ioasid_free_fn_t)(ioasid_t, void *); + +struct ioasid_set { + int dummy; +}; + +struct ioasid_allocator_ops { + ioasid_alloc_fn_t alloc; + ioasid_free_fn_t free; + struct list_head list; + void *pdata; +}; + +struct ioasid_data { + ioasid_t id; + struct ioasid_set *set; + void *private; + struct callback_head rcu; +}; + +struct ioasid_allocator_data { + struct ioasid_allocator_ops *ops; + struct list_head list; + struct list_head slist; + long unsigned int flags; + struct xarray xa; + struct callback_head rcu; +}; + +struct iova_magazine { + long unsigned int size; + long unsigned int pfns[128]; +}; + +struct iova_cpu_rcache { + spinlock_t lock; + struct iova_magazine *loaded; + struct iova_magazine *prev; +}; + +struct mipi_dsi_msg { + u8 channel; + u8 type; + u16 flags; + size_t tx_len; + const void *tx_buf; + size_t rx_len; + void *rx_buf; +}; + +struct mipi_dsi_packet { + size_t size; + u8 header[4]; + size_t payload_length; + const u8 *payload; +}; + +struct mipi_dsi_host; + +struct mipi_dsi_device; + +struct mipi_dsi_host_ops { + int (*attach)(struct mipi_dsi_host *, struct mipi_dsi_device *); + int (*detach)(struct mipi_dsi_host *, struct mipi_dsi_device *); + ssize_t (*transfer)(struct mipi_dsi_host *, const struct mipi_dsi_msg *); +}; + +struct mipi_dsi_host { + struct device *dev; + const struct mipi_dsi_host_ops *ops; + struct list_head list; +}; + +enum mipi_dsi_pixel_format { + MIPI_DSI_FMT_RGB888 = 0, + MIPI_DSI_FMT_RGB666 = 1, + MIPI_DSI_FMT_RGB666_PACKED = 2, + MIPI_DSI_FMT_RGB565 = 3, +}; + +struct mipi_dsi_device { + struct mipi_dsi_host *host; + struct device dev; + char name[20]; + unsigned int channel; + unsigned int lanes; + enum mipi_dsi_pixel_format format; + long unsigned int mode_flags; + long unsigned int hs_rate; + long unsigned int lp_rate; +}; + +struct mipi_dsi_device_info { + char type[20]; + u32 channel; + struct device_node *node; +}; + +enum mipi_dsi_dcs_tear_mode { + MIPI_DSI_DCS_TEAR_MODE_VBLANK = 0, + MIPI_DSI_DCS_TEAR_MODE_VHBLANK = 1, +}; + +struct mipi_dsi_driver { + struct device_driver driver; + int (*probe)(struct mipi_dsi_device *); + int (*remove)(struct mipi_dsi_device *); + void (*shutdown)(struct mipi_dsi_device *); +}; + +struct drm_dsc_picture_parameter_set { + u8 dsc_version; + u8 pps_identifier; + u8 pps_reserved; + u8 pps_3; + u8 pps_4; + u8 bits_per_pixel_low; + __be16 pic_height; + __be16 pic_width; + __be16 slice_height; + __be16 slice_width; + __be16 chunk_size; + u8 initial_xmit_delay_high; + u8 initial_xmit_delay_low; + __be16 initial_dec_delay; + u8 pps20_reserved; + u8 initial_scale_value; + __be16 scale_increment_interval; + u8 scale_decrement_interval_high; + u8 scale_decrement_interval_low; + u8 pps26_reserved; + u8 first_line_bpg_offset; + __be16 nfl_bpg_offset; + __be16 slice_bpg_offset; + __be16 initial_offset; + __be16 final_offset; + u8 flatness_min_qp; + u8 flatness_max_qp; + __be16 rc_model_size; + u8 rc_edge_factor; + u8 rc_quant_incr_limit0; + u8 rc_quant_incr_limit1; + u8 rc_tgt_offset; + u8 rc_buf_thresh[14]; + __be16 rc_range_parameters[15]; + u8 native_422_420; + u8 second_line_bpg_offset; + __be16 nsl_bpg_offset; + __be16 second_line_offset_adj; + u32 pps_long_94_reserved; + u32 pps_long_98_reserved; + u32 pps_long_102_reserved; + u32 pps_long_106_reserved; + u32 pps_long_110_reserved; + u32 pps_long_114_reserved; + u32 pps_long_118_reserved; + u32 pps_long_122_reserved; + __be16 pps_short_126_reserved; +} __attribute__((packed)); + +enum { + MIPI_DSI_V_SYNC_START = 1, + MIPI_DSI_V_SYNC_END = 17, + MIPI_DSI_H_SYNC_START = 33, + MIPI_DSI_H_SYNC_END = 49, + MIPI_DSI_COMPRESSION_MODE = 7, + MIPI_DSI_END_OF_TRANSMISSION = 8, + MIPI_DSI_COLOR_MODE_OFF = 2, + MIPI_DSI_COLOR_MODE_ON = 18, + MIPI_DSI_SHUTDOWN_PERIPHERAL = 34, + MIPI_DSI_TURN_ON_PERIPHERAL = 50, + MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM = 3, + MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM = 19, + MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM = 35, + MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM = 4, + MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM = 20, + MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM = 36, + MIPI_DSI_DCS_SHORT_WRITE = 5, + MIPI_DSI_DCS_SHORT_WRITE_PARAM = 21, + MIPI_DSI_DCS_READ = 6, + MIPI_DSI_EXECUTE_QUEUE = 22, + MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE = 55, + MIPI_DSI_NULL_PACKET = 9, + MIPI_DSI_BLANKING_PACKET = 25, + MIPI_DSI_GENERIC_LONG_WRITE = 41, + MIPI_DSI_DCS_LONG_WRITE = 57, + MIPI_DSI_PICTURE_PARAMETER_SET = 10, + MIPI_DSI_COMPRESSED_PIXEL_STREAM = 11, + MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20 = 12, + MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24 = 28, + MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16 = 44, + MIPI_DSI_PACKED_PIXEL_STREAM_30 = 13, + MIPI_DSI_PACKED_PIXEL_STREAM_36 = 29, + MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12 = 61, + MIPI_DSI_PACKED_PIXEL_STREAM_16 = 14, + MIPI_DSI_PACKED_PIXEL_STREAM_18 = 30, + MIPI_DSI_PIXEL_STREAM_3BYTE_18 = 46, + MIPI_DSI_PACKED_PIXEL_STREAM_24 = 62, +}; + +enum { + MIPI_DCS_NOP = 0, + MIPI_DCS_SOFT_RESET = 1, + MIPI_DCS_GET_COMPRESSION_MODE = 3, + MIPI_DCS_GET_DISPLAY_ID = 4, + MIPI_DCS_GET_ERROR_COUNT_ON_DSI = 5, + MIPI_DCS_GET_RED_CHANNEL = 6, + MIPI_DCS_GET_GREEN_CHANNEL = 7, + MIPI_DCS_GET_BLUE_CHANNEL = 8, + MIPI_DCS_GET_DISPLAY_STATUS = 9, + MIPI_DCS_GET_POWER_MODE = 10, + MIPI_DCS_GET_ADDRESS_MODE = 11, + MIPI_DCS_GET_PIXEL_FORMAT = 12, + MIPI_DCS_GET_DISPLAY_MODE = 13, + MIPI_DCS_GET_SIGNAL_MODE = 14, + MIPI_DCS_GET_DIAGNOSTIC_RESULT = 15, + MIPI_DCS_ENTER_SLEEP_MODE = 16, + MIPI_DCS_EXIT_SLEEP_MODE = 17, + MIPI_DCS_ENTER_PARTIAL_MODE = 18, + MIPI_DCS_ENTER_NORMAL_MODE = 19, + MIPI_DCS_GET_IMAGE_CHECKSUM_RGB = 20, + MIPI_DCS_GET_IMAGE_CHECKSUM_CT = 21, + MIPI_DCS_EXIT_INVERT_MODE = 32, + MIPI_DCS_ENTER_INVERT_MODE = 33, + MIPI_DCS_SET_GAMMA_CURVE = 38, + MIPI_DCS_SET_DISPLAY_OFF = 40, + MIPI_DCS_SET_DISPLAY_ON = 41, + MIPI_DCS_SET_COLUMN_ADDRESS = 42, + MIPI_DCS_SET_PAGE_ADDRESS = 43, + MIPI_DCS_WRITE_MEMORY_START = 44, + MIPI_DCS_WRITE_LUT = 45, + MIPI_DCS_READ_MEMORY_START = 46, + MIPI_DCS_SET_PARTIAL_ROWS = 48, + MIPI_DCS_SET_PARTIAL_COLUMNS = 49, + MIPI_DCS_SET_SCROLL_AREA = 51, + MIPI_DCS_SET_TEAR_OFF = 52, + MIPI_DCS_SET_TEAR_ON = 53, + MIPI_DCS_SET_ADDRESS_MODE = 54, + MIPI_DCS_SET_SCROLL_START = 55, + MIPI_DCS_EXIT_IDLE_MODE = 56, + MIPI_DCS_ENTER_IDLE_MODE = 57, + MIPI_DCS_SET_PIXEL_FORMAT = 58, + MIPI_DCS_WRITE_MEMORY_CONTINUE = 60, + MIPI_DCS_SET_3D_CONTROL = 61, + MIPI_DCS_READ_MEMORY_CONTINUE = 62, + MIPI_DCS_GET_3D_CONTROL = 63, + MIPI_DCS_SET_VSYNC_TIMING = 64, + MIPI_DCS_SET_TEAR_SCANLINE = 68, + MIPI_DCS_GET_SCANLINE = 69, + MIPI_DCS_SET_DISPLAY_BRIGHTNESS = 81, + MIPI_DCS_GET_DISPLAY_BRIGHTNESS = 82, + MIPI_DCS_WRITE_CONTROL_DISPLAY = 83, + MIPI_DCS_GET_CONTROL_DISPLAY = 84, + MIPI_DCS_WRITE_POWER_SAVE = 85, + MIPI_DCS_GET_POWER_SAVE = 86, + MIPI_DCS_SET_CABC_MIN_BRIGHTNESS = 94, + MIPI_DCS_GET_CABC_MIN_BRIGHTNESS = 95, + MIPI_DCS_READ_DDB_START = 161, + MIPI_DCS_READ_PPS_START = 162, + MIPI_DCS_READ_DDB_CONTINUE = 168, + MIPI_DCS_READ_PPS_CONTINUE = 169, +}; + +struct vga_device { + struct list_head list; + struct pci_dev *pdev; + unsigned int decodes; + unsigned int owns; + unsigned int locks; + unsigned int io_lock_cnt; + unsigned int mem_lock_cnt; + unsigned int io_norm_cnt; + unsigned int mem_norm_cnt; + bool bridge_has_one_vga; + void *cookie; + void (*irq_set_state)(void *, bool); + unsigned int (*set_vga_decode)(void *, bool); +}; + +struct vga_arb_user_card { + struct pci_dev *pdev; + unsigned int mem_cnt; + unsigned int io_cnt; +}; + +struct vga_arb_private { + struct list_head list; + struct pci_dev *target; + struct vga_arb_user_card cards[16]; + spinlock_t lock; +}; + +struct cb_id { + __u32 idx; + __u32 val; +}; + +struct cn_msg { + struct cb_id id; + __u32 seq; + __u32 ack; + __u16 len; + __u16 flags; + __u8 data[0]; +}; + +struct cn_queue_dev { + atomic_t refcnt; + unsigned char name[32]; + struct list_head queue_list; + spinlock_t queue_lock; + struct sock *nls; +}; + +struct cn_callback_id { + unsigned char name[32]; + struct cb_id id; +}; + +struct cn_callback_entry { + struct list_head callback_entry; + refcount_t refcnt; + struct cn_queue_dev *pdev; + struct cn_callback_id id; + void (*callback)(struct cn_msg *, struct netlink_skb_parms *); + u32 seq; + u32 group; +}; + +struct cn_dev { + struct cb_id id; + u32 seq; + u32 groups; + struct sock *nls; + struct cn_queue_dev *cbdev; +}; + +enum proc_cn_mcast_op { + PROC_CN_MCAST_LISTEN = 1, + PROC_CN_MCAST_IGNORE = 2, +}; + +struct fork_proc_event { + __kernel_pid_t parent_pid; + __kernel_pid_t parent_tgid; + __kernel_pid_t child_pid; + __kernel_pid_t child_tgid; +}; + +struct exec_proc_event { + __kernel_pid_t process_pid; + __kernel_pid_t process_tgid; +}; + +struct id_proc_event { + __kernel_pid_t process_pid; + __kernel_pid_t process_tgid; + union { + __u32 ruid; + __u32 rgid; + } r; + union { + __u32 euid; + __u32 egid; + } e; +}; + +struct sid_proc_event { + __kernel_pid_t process_pid; + __kernel_pid_t process_tgid; +}; + +struct ptrace_proc_event { + __kernel_pid_t process_pid; + __kernel_pid_t process_tgid; + __kernel_pid_t tracer_pid; + __kernel_pid_t tracer_tgid; +}; + +struct comm_proc_event { + __kernel_pid_t process_pid; + __kernel_pid_t process_tgid; + char comm[16]; +}; + +struct coredump_proc_event { + __kernel_pid_t process_pid; + __kernel_pid_t process_tgid; + __kernel_pid_t parent_pid; + __kernel_pid_t parent_tgid; +}; + +struct exit_proc_event { + __kernel_pid_t process_pid; + __kernel_pid_t process_tgid; + __u32 exit_code; + __u32 exit_signal; + __kernel_pid_t parent_pid; + __kernel_pid_t parent_tgid; +}; + +struct proc_event { + enum what what; + __u32 cpu; + __u64 timestamp_ns; + union { + struct { + __u32 err; + } ack; + struct fork_proc_event fork; + struct exec_proc_event exec; + struct id_proc_event id; + struct sid_proc_event sid; + struct ptrace_proc_event ptrace; + struct comm_proc_event comm; + struct coredump_proc_event coredump; + struct exit_proc_event exit; + } event_data; +}; + +struct local_event { + local_lock_t lock; + __u32 count; +}; + +struct component_ops { + int (*bind)(struct device *, struct device *, void *); + void (*unbind)(struct device *, struct device *, void *); +}; + +struct component_master_ops { + int (*bind)(struct device *); + void (*unbind)(struct device *); +}; + +struct component; + +struct component_match_array { + void *data; + int (*compare)(struct device *, void *); + int (*compare_typed)(struct device *, int, void *); + void (*release)(struct device *, void *); + struct component *component; + bool duplicate; +}; + +struct master; + +struct component { + struct list_head node; + struct master *master; + bool bound; + const struct component_ops *ops; + int subcomponent; + struct device *dev; +}; + +struct component_match { + size_t alloc; + size_t num; + struct component_match_array *compare; +}; + +struct master { + struct list_head node; + bool bound; + const struct component_master_ops *ops; + struct device *dev; + struct component_match *match; + struct dentry *dentry; +}; + +struct wake_irq { + struct device *dev; + unsigned int status; + int irq; + const char *name; +}; + +enum dpm_order { + DPM_ORDER_NONE = 0, + DPM_ORDER_DEV_AFTER_PARENT = 1, + DPM_ORDER_PARENT_BEFORE_DEV = 2, + DPM_ORDER_DEV_LAST = 3, +}; + +struct subsys_private { + struct kset subsys; + struct kset *devices_kset; + struct list_head interfaces; + struct mutex mutex; + struct kset *drivers_kset; + struct klist klist_devices; + struct klist klist_drivers; + struct blocking_notifier_head bus_notifier; + unsigned int drivers_autoprobe: 1; + struct bus_type *bus; + struct kset glue_dirs; + struct class *class; +}; + +struct driver_private { + struct kobject kobj; + struct klist klist_devices; + struct klist_node knode_bus; + struct module_kobject *mkobj; + struct device_driver *driver; +}; + +struct device_private { + struct klist klist_children; + struct klist_node knode_parent; + struct klist_node knode_driver; + struct klist_node knode_bus; + struct klist_node knode_class; + struct list_head deferred_probe; + struct device_driver *async_driver; + char *deferred_probe_reason; + struct device *device; + u8 dead: 1; +}; + +union device_attr_group_devres { + const struct attribute_group *group; + const struct attribute_group **groups; +}; + +struct class_dir { + struct kobject kobj; + struct class *class; +}; + +struct root_device { + struct device dev; + struct module *owner; +}; + +struct subsys_dev_iter { + struct klist_iter ki; + const struct device_type *type; +}; + +struct subsys_interface { + const char *name; + struct bus_type *subsys; + struct list_head node; + int (*add_dev)(struct device *, struct subsys_interface *); + void (*remove_dev)(struct device *, struct subsys_interface *); +}; + +struct device_attach_data { + struct device *dev; + bool check_async; + bool want_async; + bool have_async; +}; + +struct class_attribute_string { + struct class_attribute attr; + char *str; +}; + +struct class_compat { + struct kobject *kobj; +}; + +struct platform_object { + struct platform_device pdev; + char name[0]; +}; + +struct cpu_attr { + struct device_attribute attr; + const struct cpumask * const map; +}; + +typedef struct kobject *kobj_probe_t(dev_t, int *, void *); + +struct probe { + struct probe *next; + dev_t dev; + long unsigned int range; + struct module *owner; + kobj_probe_t *get; + int (*lock)(dev_t, void *); + void *data; +}; + +struct kobj_map___2 { + struct probe *probes[255]; + struct mutex *lock; +}; + +typedef int (*dr_match_t)(struct device *, void *, void *); + +struct devres_node { + struct list_head entry; + dr_release_t release; +}; + +struct devres___2 { + struct devres_node node; + u8 data[0]; +}; + +struct devres_group { + struct devres_node node[2]; + void *id; + int color; +}; + +struct action_devres { + void *data; + void (*action)(void *); +}; + +struct pages_devres { + long unsigned int addr; + unsigned int order; +}; + +struct attribute_container { + struct list_head node; + struct klist containers; + struct class *class; + const struct attribute_group *grp; + struct device_attribute **attrs; + int (*match)(struct attribute_container *, struct device *); + long unsigned int flags; +}; + +struct internal_container { + struct klist_node node; + struct attribute_container *cont; + struct device classdev; +}; + +struct transport_container; + +struct transport_class { + struct class class; + int (*setup)(struct transport_container *, struct device *, struct device *); + int (*configure)(struct transport_container *, struct device *, struct device *); + int (*remove)(struct transport_container *, struct device *, struct device *); +}; + +struct transport_container { + struct attribute_container ac; + const struct attribute_group *statistics; +}; + +struct anon_transport_class { + struct transport_class tclass; + struct attribute_container container; +}; + +typedef void * (*devcon_match_fn_t)(struct fwnode_handle *, const char *, void *); + +enum ethtool_link_mode_bit_indices { + ETHTOOL_LINK_MODE_10baseT_Half_BIT = 0, + ETHTOOL_LINK_MODE_10baseT_Full_BIT = 1, + ETHTOOL_LINK_MODE_100baseT_Half_BIT = 2, + ETHTOOL_LINK_MODE_100baseT_Full_BIT = 3, + ETHTOOL_LINK_MODE_1000baseT_Half_BIT = 4, + ETHTOOL_LINK_MODE_1000baseT_Full_BIT = 5, + ETHTOOL_LINK_MODE_Autoneg_BIT = 6, + ETHTOOL_LINK_MODE_TP_BIT = 7, + ETHTOOL_LINK_MODE_AUI_BIT = 8, + ETHTOOL_LINK_MODE_MII_BIT = 9, + ETHTOOL_LINK_MODE_FIBRE_BIT = 10, + ETHTOOL_LINK_MODE_BNC_BIT = 11, + ETHTOOL_LINK_MODE_10000baseT_Full_BIT = 12, + ETHTOOL_LINK_MODE_Pause_BIT = 13, + ETHTOOL_LINK_MODE_Asym_Pause_BIT = 14, + ETHTOOL_LINK_MODE_2500baseX_Full_BIT = 15, + ETHTOOL_LINK_MODE_Backplane_BIT = 16, + ETHTOOL_LINK_MODE_1000baseKX_Full_BIT = 17, + ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT = 18, + ETHTOOL_LINK_MODE_10000baseKR_Full_BIT = 19, + ETHTOOL_LINK_MODE_10000baseR_FEC_BIT = 20, + ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT = 21, + ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT = 22, + ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT = 23, + ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT = 24, + ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT = 25, + ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT = 26, + ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT = 27, + ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT = 28, + ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT = 29, + ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT = 30, + ETHTOOL_LINK_MODE_25000baseCR_Full_BIT = 31, + ETHTOOL_LINK_MODE_25000baseKR_Full_BIT = 32, + ETHTOOL_LINK_MODE_25000baseSR_Full_BIT = 33, + ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT = 34, + ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT = 35, + ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT = 36, + ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT = 37, + ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT = 38, + ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT = 39, + ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT = 40, + ETHTOOL_LINK_MODE_1000baseX_Full_BIT = 41, + ETHTOOL_LINK_MODE_10000baseCR_Full_BIT = 42, + ETHTOOL_LINK_MODE_10000baseSR_Full_BIT = 43, + ETHTOOL_LINK_MODE_10000baseLR_Full_BIT = 44, + ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT = 45, + ETHTOOL_LINK_MODE_10000baseER_Full_BIT = 46, + ETHTOOL_LINK_MODE_2500baseT_Full_BIT = 47, + ETHTOOL_LINK_MODE_5000baseT_Full_BIT = 48, + ETHTOOL_LINK_MODE_FEC_NONE_BIT = 49, + ETHTOOL_LINK_MODE_FEC_RS_BIT = 50, + ETHTOOL_LINK_MODE_FEC_BASER_BIT = 51, + ETHTOOL_LINK_MODE_50000baseKR_Full_BIT = 52, + ETHTOOL_LINK_MODE_50000baseSR_Full_BIT = 53, + ETHTOOL_LINK_MODE_50000baseCR_Full_BIT = 54, + ETHTOOL_LINK_MODE_50000baseLR_ER_FR_Full_BIT = 55, + ETHTOOL_LINK_MODE_50000baseDR_Full_BIT = 56, + ETHTOOL_LINK_MODE_100000baseKR2_Full_BIT = 57, + ETHTOOL_LINK_MODE_100000baseSR2_Full_BIT = 58, + ETHTOOL_LINK_MODE_100000baseCR2_Full_BIT = 59, + ETHTOOL_LINK_MODE_100000baseLR2_ER2_FR2_Full_BIT = 60, + ETHTOOL_LINK_MODE_100000baseDR2_Full_BIT = 61, + ETHTOOL_LINK_MODE_200000baseKR4_Full_BIT = 62, + ETHTOOL_LINK_MODE_200000baseSR4_Full_BIT = 63, + ETHTOOL_LINK_MODE_200000baseLR4_ER4_FR4_Full_BIT = 64, + ETHTOOL_LINK_MODE_200000baseDR4_Full_BIT = 65, + ETHTOOL_LINK_MODE_200000baseCR4_Full_BIT = 66, + ETHTOOL_LINK_MODE_100baseT1_Full_BIT = 67, + ETHTOOL_LINK_MODE_1000baseT1_Full_BIT = 68, + ETHTOOL_LINK_MODE_400000baseKR8_Full_BIT = 69, + ETHTOOL_LINK_MODE_400000baseSR8_Full_BIT = 70, + ETHTOOL_LINK_MODE_400000baseLR8_ER8_FR8_Full_BIT = 71, + ETHTOOL_LINK_MODE_400000baseDR8_Full_BIT = 72, + ETHTOOL_LINK_MODE_400000baseCR8_Full_BIT = 73, + ETHTOOL_LINK_MODE_FEC_LLRS_BIT = 74, + ETHTOOL_LINK_MODE_100000baseKR_Full_BIT = 75, + ETHTOOL_LINK_MODE_100000baseSR_Full_BIT = 76, + ETHTOOL_LINK_MODE_100000baseLR_ER_FR_Full_BIT = 77, + ETHTOOL_LINK_MODE_100000baseCR_Full_BIT = 78, + ETHTOOL_LINK_MODE_100000baseDR_Full_BIT = 79, + ETHTOOL_LINK_MODE_200000baseKR2_Full_BIT = 80, + ETHTOOL_LINK_MODE_200000baseSR2_Full_BIT = 81, + ETHTOOL_LINK_MODE_200000baseLR2_ER2_FR2_Full_BIT = 82, + ETHTOOL_LINK_MODE_200000baseDR2_Full_BIT = 83, + ETHTOOL_LINK_MODE_200000baseCR2_Full_BIT = 84, + ETHTOOL_LINK_MODE_400000baseKR4_Full_BIT = 85, + ETHTOOL_LINK_MODE_400000baseSR4_Full_BIT = 86, + ETHTOOL_LINK_MODE_400000baseLR4_ER4_FR4_Full_BIT = 87, + ETHTOOL_LINK_MODE_400000baseDR4_Full_BIT = 88, + ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT = 89, + ETHTOOL_LINK_MODE_100baseFX_Half_BIT = 90, + ETHTOOL_LINK_MODE_100baseFX_Full_BIT = 91, + __ETHTOOL_LINK_MODE_MASK_NBITS = 92, +}; + +struct reset_control; + +struct mii_bus; + +struct mdio_device { + struct device dev; + struct mii_bus *bus; + char modalias[32]; + int (*bus_match)(struct device *, struct device_driver *); + void (*device_free)(struct mdio_device *); + void (*device_remove)(struct mdio_device *); + int addr; + int flags; + struct gpio_desc___2 *reset_gpio; + struct reset_control *reset_ctrl; + unsigned int reset_assert_delay; + unsigned int reset_deassert_delay; +}; + +struct phy_c45_device_ids { + u32 devices_in_package; + u32 mmds_present; + u32 device_ids[32]; +}; + +enum phy_state { + PHY_DOWN = 0, + PHY_READY = 1, + PHY_HALTED = 2, + PHY_UP = 3, + PHY_RUNNING = 4, + PHY_NOLINK = 5, + PHY_CABLETEST = 6, +}; + +typedef enum { + PHY_INTERFACE_MODE_NA = 0, + PHY_INTERFACE_MODE_INTERNAL = 1, + PHY_INTERFACE_MODE_MII = 2, + PHY_INTERFACE_MODE_GMII = 3, + PHY_INTERFACE_MODE_SGMII = 4, + PHY_INTERFACE_MODE_TBI = 5, + PHY_INTERFACE_MODE_REVMII = 6, + PHY_INTERFACE_MODE_RMII = 7, + PHY_INTERFACE_MODE_RGMII = 8, + PHY_INTERFACE_MODE_RGMII_ID = 9, + PHY_INTERFACE_MODE_RGMII_RXID = 10, + PHY_INTERFACE_MODE_RGMII_TXID = 11, + PHY_INTERFACE_MODE_RTBI = 12, + PHY_INTERFACE_MODE_SMII = 13, + PHY_INTERFACE_MODE_XGMII = 14, + PHY_INTERFACE_MODE_XLGMII = 15, + PHY_INTERFACE_MODE_MOCA = 16, + PHY_INTERFACE_MODE_QSGMII = 17, + PHY_INTERFACE_MODE_TRGMII = 18, + PHY_INTERFACE_MODE_1000BASEX = 19, + PHY_INTERFACE_MODE_2500BASEX = 20, + PHY_INTERFACE_MODE_RXAUI = 21, + PHY_INTERFACE_MODE_XAUI = 22, + PHY_INTERFACE_MODE_10GBASER = 23, + PHY_INTERFACE_MODE_USXGMII = 24, + PHY_INTERFACE_MODE_10GKR = 25, + PHY_INTERFACE_MODE_MAX = 26, +} phy_interface_t; + +struct phylink; + +struct phy_driver; + +struct phy_package_shared; + +struct mii_timestamper; + +struct phy_device { + struct mdio_device mdio; + struct phy_driver *drv; + u32 phy_id; + struct phy_c45_device_ids c45_ids; + unsigned int is_c45: 1; + unsigned int is_internal: 1; + unsigned int is_pseudo_fixed_link: 1; + unsigned int is_gigabit_capable: 1; + unsigned int has_fixups: 1; + unsigned int suspended: 1; + unsigned int suspended_by_mdio_bus: 1; + unsigned int sysfs_links: 1; + unsigned int loopback_enabled: 1; + unsigned int downshifted_rate: 1; + unsigned int autoneg: 1; + unsigned int link: 1; + unsigned int autoneg_complete: 1; + unsigned int interrupts: 1; + enum phy_state state; + u32 dev_flags; + phy_interface_t interface; + int speed; + int duplex; + int pause; + int asym_pause; + u8 master_slave_get; + u8 master_slave_set; + u8 master_slave_state; + long unsigned int supported[2]; + long unsigned int advertising[2]; + long unsigned int lp_advertising[2]; + long unsigned int adv_old[2]; + u32 eee_broken_modes; + int irq; + void *priv; + struct phy_package_shared *shared; + struct sk_buff *skb; + void *ehdr; + struct nlattr *nest; + struct delayed_work state_queue; + struct mutex lock; + bool sfp_bus_attached; + struct sfp_bus *sfp_bus; + struct phylink *phylink; + struct net_device *attached_dev; + struct mii_timestamper *mii_ts; + u8 mdix; + u8 mdix_ctrl; + void (*phy_link_change)(struct phy_device *, bool); + void (*adjust_link)(struct net_device *); +}; + +struct phy_tdr_config { + u32 first; + u32 last; + u32 step; + s8 pair; +}; + +struct mdio_bus_stats { + u64_stats_t transfers; + u64_stats_t errors; + u64_stats_t writes; + u64_stats_t reads; + struct u64_stats_sync syncp; +}; + +struct mii_bus { + struct module *owner; + const char *name; + char id[61]; + void *priv; + int (*read)(struct mii_bus *, int, int); + int (*write)(struct mii_bus *, int, int, u16); + int (*reset)(struct mii_bus *); + struct mdio_bus_stats stats[32]; + struct mutex mdio_lock; + struct device *parent; + enum { + MDIOBUS_ALLOCATED = 1, + MDIOBUS_REGISTERED = 2, + MDIOBUS_UNREGISTERED = 3, + MDIOBUS_RELEASED = 4, + } state; + struct device dev; + struct mdio_device *mdio_map[32]; + u32 phy_mask; + u32 phy_ignore_ta_mask; + int irq[32]; + int reset_delay_us; + int reset_post_delay_us; + struct gpio_desc___2 *reset_gpiod; + enum { + MDIOBUS_NO_CAP = 0, + MDIOBUS_C22 = 1, + MDIOBUS_C45 = 2, + MDIOBUS_C22_C45 = 3, + } probe_capabilities; + struct mutex shared_lock; + struct phy_package_shared *shared[32]; +}; + +struct mdio_driver_common { + struct device_driver driver; + int flags; +}; + +struct mii_timestamper { + bool (*rxtstamp)(struct mii_timestamper *, struct sk_buff *, int); + void (*txtstamp)(struct mii_timestamper *, struct sk_buff *, int); + int (*hwtstamp)(struct mii_timestamper *, struct ifreq *); + void (*link_state)(struct mii_timestamper *, struct phy_device *); + int (*ts_info)(struct mii_timestamper *, struct ethtool_ts_info *); + struct device *device; +}; + +struct phy_package_shared { + int addr; + refcount_t refcnt; + long unsigned int flags; + size_t priv_size; + void *priv; +}; + +struct phy_driver { + struct mdio_driver_common mdiodrv; + u32 phy_id; + char *name; + u32 phy_id_mask; + const long unsigned int * const features; + u32 flags; + const void *driver_data; + int (*soft_reset)(struct phy_device *); + int (*config_init)(struct phy_device *); + int (*probe)(struct phy_device *); + int (*get_features)(struct phy_device *); + int (*suspend)(struct phy_device *); + int (*resume)(struct phy_device *); + int (*config_aneg)(struct phy_device *); + int (*aneg_done)(struct phy_device *); + int (*read_status)(struct phy_device *); + int (*ack_interrupt)(struct phy_device *); + int (*config_intr)(struct phy_device *); + int (*did_interrupt)(struct phy_device *); + irqreturn_t (*handle_interrupt)(struct phy_device *); + void (*remove)(struct phy_device *); + int (*match_phy_device)(struct phy_device *); + int (*set_wol)(struct phy_device *, struct ethtool_wolinfo *); + void (*get_wol)(struct phy_device *, struct ethtool_wolinfo *); + void (*link_change_notify)(struct phy_device *); + int (*read_mmd)(struct phy_device *, int, u16); + int (*write_mmd)(struct phy_device *, int, u16, u16); + int (*read_page)(struct phy_device *); + int (*write_page)(struct phy_device *, int); + int (*module_info)(struct phy_device *, struct ethtool_modinfo *); + int (*module_eeprom)(struct phy_device *, struct ethtool_eeprom *, u8 *); + int (*cable_test_start)(struct phy_device *); + int (*cable_test_tdr_start)(struct phy_device *, const struct phy_tdr_config *); + int (*cable_test_get_status)(struct phy_device *, bool *); + int (*get_sset_count)(struct phy_device *); + void (*get_strings)(struct phy_device *, u8 *); + void (*get_stats)(struct phy_device *, struct ethtool_stats *, u64 *); + int (*get_tunable)(struct phy_device *, struct ethtool_tunable *, void *); + int (*set_tunable)(struct phy_device *, struct ethtool_tunable *, const void *); + int (*set_loopback)(struct phy_device *, bool); + int (*get_sqi)(struct phy_device *); + int (*get_sqi_max)(struct phy_device *); +}; + +struct software_node; + +struct software_node_ref_args { + const struct software_node *node; + unsigned int nargs; + u64 args[8]; +}; + +struct software_node { + const char *name; + const struct software_node *parent; + const struct property_entry *properties; +}; + +struct swnode { + int id; + struct kobject kobj; + struct fwnode_handle fwnode; + const struct software_node *node; + struct ida child_ids; + struct list_head entry; + struct list_head children; + struct swnode *parent; + unsigned int allocated: 1; +}; + +struct req { + struct req *next; + struct completion done; + int err; + const char *name; + umode_t mode; + kuid_t uid; + kgid_t gid; + struct device *dev; +}; + +typedef int (*pm_callback_t)(struct device *); + +struct pm_clk_notifier_block { + struct notifier_block nb; + struct dev_pm_domain *pm_domain; + char *con_ids[0]; +}; + +enum pce_status { + PCE_STATUS_NONE = 0, + PCE_STATUS_ACQUIRED = 1, + PCE_STATUS_ENABLED = 2, + PCE_STATUS_ERROR = 3, +}; + +struct pm_clock_entry { + struct list_head node; + char *con_id; + struct clk *clk; + enum pce_status status; +}; + +struct firmware_fallback_config { + unsigned int force_sysfs_fallback; + unsigned int ignore_sysfs_fallback; + int old_timeout; + int loading_timeout; +}; + +struct firmware { + size_t size; + const u8 *data; + void *priv; +}; + +struct builtin_fw { + char *name; + void *data; + long unsigned int size; +}; + +enum fw_opt { + FW_OPT_UEVENT = 1, + FW_OPT_NOWAIT = 2, + FW_OPT_USERHELPER = 4, + FW_OPT_NO_WARN = 8, + FW_OPT_NOCACHE = 16, + FW_OPT_NOFALLBACK_SYSFS = 32, + FW_OPT_FALLBACK_PLATFORM = 64, + FW_OPT_PARTIAL = 128, +}; + +enum fw_status { + FW_STATUS_UNKNOWN = 0, + FW_STATUS_LOADING = 1, + FW_STATUS_DONE = 2, + FW_STATUS_ABORTED = 3, +}; + +struct fw_state { + struct completion completion; + enum fw_status status; +}; + +struct firmware_cache; + +struct fw_priv { + struct kref ref; + struct list_head list; + struct firmware_cache *fwc; + struct fw_state fw_st; + void *data; + size_t size; + size_t allocated_size; + size_t offset; + u32 opt_flags; + bool is_paged_buf; + struct page **pages; + int nr_pages; + int page_array_size; + bool need_uevent; + struct list_head pending_list; + const char *fw_name; +}; + +struct firmware_cache { + spinlock_t lock; + struct list_head head; + int state; + spinlock_t name_lock; + struct list_head fw_names; + struct delayed_work work; + struct notifier_block pm_notify; +}; + +struct fw_cache_entry { + struct list_head list; + const char *name; +}; + +struct fw_name_devm { + long unsigned int magic; + const char *name; +}; + +struct firmware_work { + struct work_struct work; + struct module *module; + const char *name; + struct device *device; + void *context; + void (*cont)(const struct firmware *, void *); + u32 opt_flags; +}; + +struct fw_sysfs { + bool nowait; + struct device dev; + struct fw_priv *fw_priv; + struct firmware *fw; +}; + +typedef void (*node_registration_func_t)(struct node___2 *); + +struct node_access_nodes { + struct device dev; + struct list_head list_node; + unsigned int access; +}; + +struct node_attr { + struct device_attribute attr; + enum node_states state; +}; + +enum regcache_type { + REGCACHE_NONE = 0, + REGCACHE_RBTREE = 1, + REGCACHE_COMPRESSED = 2, + REGCACHE_FLAT = 3, +}; + +struct reg_default { + unsigned int reg; + unsigned int def; +}; + +struct reg_sequence { + unsigned int reg; + unsigned int def; + unsigned int delay_us; +}; + +enum regmap_endian { + REGMAP_ENDIAN_DEFAULT = 0, + REGMAP_ENDIAN_BIG = 1, + REGMAP_ENDIAN_LITTLE = 2, + REGMAP_ENDIAN_NATIVE = 3, +}; + +struct regmap_range { + unsigned int range_min; + unsigned int range_max; +}; + +struct regmap_access_table { + const struct regmap_range *yes_ranges; + unsigned int n_yes_ranges; + const struct regmap_range *no_ranges; + unsigned int n_no_ranges; +}; + +typedef void (*regmap_lock)(void *); + +typedef void (*regmap_unlock)(void *); + +struct regmap_range_cfg; + +struct regmap_config { + const char *name; + int reg_bits; + int reg_stride; + int pad_bits; + int val_bits; + bool (*writeable_reg)(struct device *, unsigned int); + bool (*readable_reg)(struct device *, unsigned int); + bool (*volatile_reg)(struct device *, unsigned int); + bool (*precious_reg)(struct device *, unsigned int); + bool (*writeable_noinc_reg)(struct device *, unsigned int); + bool (*readable_noinc_reg)(struct device *, unsigned int); + bool disable_locking; + regmap_lock lock; + regmap_unlock unlock; + void *lock_arg; + int (*reg_read)(void *, unsigned int, unsigned int *); + int (*reg_write)(void *, unsigned int, unsigned int); + bool fast_io; + unsigned int max_register; + const struct regmap_access_table *wr_table; + const struct regmap_access_table *rd_table; + const struct regmap_access_table *volatile_table; + const struct regmap_access_table *precious_table; + const struct regmap_access_table *wr_noinc_table; + const struct regmap_access_table *rd_noinc_table; + const struct reg_default *reg_defaults; + unsigned int num_reg_defaults; + enum regcache_type cache_type; + const void *reg_defaults_raw; + unsigned int num_reg_defaults_raw; + long unsigned int read_flag_mask; + long unsigned int write_flag_mask; + bool zero_flag_mask; + bool use_single_read; + bool use_single_write; + bool can_multi_write; + enum regmap_endian reg_format_endian; + enum regmap_endian val_format_endian; + const struct regmap_range_cfg *ranges; + unsigned int num_ranges; + bool use_hwlock; + unsigned int hwlock_id; + unsigned int hwlock_mode; + bool can_sleep; +}; + +struct regmap_range_cfg { + const char *name; + unsigned int range_min; + unsigned int range_max; + unsigned int selector_reg; + unsigned int selector_mask; + int selector_shift; + unsigned int window_start; + unsigned int window_len; +}; + +typedef int (*regmap_hw_write)(void *, const void *, size_t); + +typedef int (*regmap_hw_gather_write)(void *, const void *, size_t, const void *, size_t); + +struct regmap_async; + +typedef int (*regmap_hw_async_write)(void *, const void *, size_t, const void *, size_t, struct regmap_async *); + +struct regmap; + +struct regmap_async { + struct list_head list; + struct regmap *map; + void *work_buf; +}; + +typedef int (*regmap_hw_read)(void *, const void *, size_t, void *, size_t); + +typedef int (*regmap_hw_reg_read)(void *, unsigned int, unsigned int *); + +typedef int (*regmap_hw_reg_write)(void *, unsigned int, unsigned int); + +typedef int (*regmap_hw_reg_update_bits)(void *, unsigned int, unsigned int, unsigned int); + +typedef struct regmap_async * (*regmap_hw_async_alloc)(); + +typedef void (*regmap_hw_free_context)(void *); + +struct regmap_bus { + bool fast_io; + regmap_hw_write write; + regmap_hw_gather_write gather_write; + regmap_hw_async_write async_write; + regmap_hw_reg_write reg_write; + regmap_hw_reg_update_bits reg_update_bits; + regmap_hw_read read; + regmap_hw_reg_read reg_read; + regmap_hw_free_context free_context; + regmap_hw_async_alloc async_alloc; + u8 read_flag_mask; + enum regmap_endian reg_format_endian_default; + enum regmap_endian val_format_endian_default; + size_t max_raw_read; + size_t max_raw_write; +}; + +struct reg_field { + unsigned int reg; + unsigned int lsb; + unsigned int msb; + unsigned int id_size; + unsigned int id_offset; +}; + +struct regmap_format { + size_t buf_size; + size_t reg_bytes; + size_t pad_bytes; + size_t val_bytes; + void (*format_write)(struct regmap *, unsigned int, unsigned int); + void (*format_reg)(void *, unsigned int, unsigned int); + void (*format_val)(void *, unsigned int, unsigned int); + unsigned int (*parse_val)(const void *); + void (*parse_inplace)(void *); +}; + +struct hwspinlock; + +struct regcache_ops; + +struct regmap { + union { + struct mutex mutex; + struct { + spinlock_t spinlock; + long unsigned int spinlock_flags; + }; + }; + regmap_lock lock; + regmap_unlock unlock; + void *lock_arg; + gfp_t alloc_flags; + struct device *dev; + void *work_buf; + struct regmap_format format; + const struct regmap_bus *bus; + void *bus_context; + const char *name; + bool async; + spinlock_t async_lock; + wait_queue_head_t async_waitq; + struct list_head async_list; + struct list_head async_free; + int async_ret; + bool debugfs_disable; + struct dentry *debugfs; + const char *debugfs_name; + unsigned int debugfs_reg_len; + unsigned int debugfs_val_len; + unsigned int debugfs_tot_len; + struct list_head debugfs_off_cache; + struct mutex cache_lock; + unsigned int max_register; + bool (*writeable_reg)(struct device *, unsigned int); + bool (*readable_reg)(struct device *, unsigned int); + bool (*volatile_reg)(struct device *, unsigned int); + bool (*precious_reg)(struct device *, unsigned int); + bool (*writeable_noinc_reg)(struct device *, unsigned int); + bool (*readable_noinc_reg)(struct device *, unsigned int); + const struct regmap_access_table *wr_table; + const struct regmap_access_table *rd_table; + const struct regmap_access_table *volatile_table; + const struct regmap_access_table *precious_table; + const struct regmap_access_table *wr_noinc_table; + const struct regmap_access_table *rd_noinc_table; + int (*reg_read)(void *, unsigned int, unsigned int *); + int (*reg_write)(void *, unsigned int, unsigned int); + int (*reg_update_bits)(void *, unsigned int, unsigned int, unsigned int); + bool defer_caching; + long unsigned int read_flag_mask; + long unsigned int write_flag_mask; + int reg_shift; + int reg_stride; + int reg_stride_order; + const struct regcache_ops *cache_ops; + enum regcache_type cache_type; + unsigned int cache_size_raw; + unsigned int cache_word_size; + unsigned int num_reg_defaults; + unsigned int num_reg_defaults_raw; + bool cache_only; + bool cache_bypass; + bool cache_free; + struct reg_default *reg_defaults; + const void *reg_defaults_raw; + void *cache; + bool cache_dirty; + bool no_sync_defaults; + struct reg_sequence *patch; + int patch_regs; + bool use_single_read; + bool use_single_write; + bool can_multi_write; + size_t max_raw_read; + size_t max_raw_write; + struct rb_root range_tree; + void *selector_work_buf; + struct hwspinlock *hwlock; + bool can_sleep; +}; + +struct regcache_ops { + const char *name; + enum regcache_type type; + int (*init)(struct regmap *); + int (*exit)(struct regmap *); + void (*debugfs_init)(struct regmap *); + int (*read)(struct regmap *, unsigned int, unsigned int *); + int (*write)(struct regmap *, unsigned int, unsigned int); + int (*sync)(struct regmap *, unsigned int, unsigned int); + int (*drop)(struct regmap *, unsigned int, unsigned int); +}; + +struct regmap_range_node { + struct rb_node node; + const char *name; + struct regmap *map; + unsigned int range_min; + unsigned int range_max; + unsigned int selector_reg; + unsigned int selector_mask; + int selector_shift; + unsigned int window_start; + unsigned int window_len; +}; + +struct regmap_field { + struct regmap *regmap; + unsigned int mask; + unsigned int shift; + unsigned int reg; + unsigned int id_size; + unsigned int id_offset; +}; + +struct trace_event_raw_regmap_reg { + struct trace_entry ent; + u32 __data_loc_name; + unsigned int reg; + unsigned int val; + char __data[0]; +}; + +struct trace_event_raw_regmap_block { + struct trace_entry ent; + u32 __data_loc_name; + unsigned int reg; + int count; + char __data[0]; +}; + +struct trace_event_raw_regcache_sync { + struct trace_entry ent; + u32 __data_loc_name; + u32 __data_loc_status; + u32 __data_loc_type; + int type; + char __data[0]; +}; + +struct trace_event_raw_regmap_bool { + struct trace_entry ent; + u32 __data_loc_name; + int flag; + char __data[0]; +}; + +struct trace_event_raw_regmap_async { + struct trace_entry ent; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_regcache_drop_region { + struct trace_entry ent; + u32 __data_loc_name; + unsigned int from; + unsigned int to; + char __data[0]; +}; + +struct trace_event_data_offsets_regmap_reg { + u32 name; +}; + +struct trace_event_data_offsets_regmap_block { + u32 name; +}; + +struct trace_event_data_offsets_regcache_sync { + u32 name; + u32 status; + u32 type; +}; + +struct trace_event_data_offsets_regmap_bool { + u32 name; +}; + +struct trace_event_data_offsets_regmap_async { + u32 name; +}; + +struct trace_event_data_offsets_regcache_drop_region { + u32 name; +}; + +typedef void (*btf_trace_regmap_reg_write)(void *, struct regmap *, unsigned int, unsigned int); + +typedef void (*btf_trace_regmap_reg_read)(void *, struct regmap *, unsigned int, unsigned int); + +typedef void (*btf_trace_regmap_reg_read_cache)(void *, struct regmap *, unsigned int, unsigned int); + +typedef void (*btf_trace_regmap_hw_read_start)(void *, struct regmap *, unsigned int, int); + +typedef void (*btf_trace_regmap_hw_read_done)(void *, struct regmap *, unsigned int, int); + +typedef void (*btf_trace_regmap_hw_write_start)(void *, struct regmap *, unsigned int, int); + +typedef void (*btf_trace_regmap_hw_write_done)(void *, struct regmap *, unsigned int, int); + +typedef void (*btf_trace_regcache_sync)(void *, struct regmap *, const char *, const char *); + +typedef void (*btf_trace_regmap_cache_only)(void *, struct regmap *, bool); + +typedef void (*btf_trace_regmap_cache_bypass)(void *, struct regmap *, bool); + +typedef void (*btf_trace_regmap_async_write_start)(void *, struct regmap *, unsigned int, int); + +typedef void (*btf_trace_regmap_async_io_complete)(void *, struct regmap *); + +typedef void (*btf_trace_regmap_async_complete_start)(void *, struct regmap *); + +typedef void (*btf_trace_regmap_async_complete_done)(void *, struct regmap *); + +typedef void (*btf_trace_regcache_drop_region)(void *, struct regmap *, unsigned int, unsigned int); + +struct regcache_rbtree_node { + void *block; + long int *cache_present; + unsigned int base_reg; + unsigned int blklen; + struct rb_node node; +}; + +struct regcache_rbtree_ctx { + struct rb_root root; + struct regcache_rbtree_node *cached_rbnode; +}; + +struct regmap_debugfs_off_cache { + struct list_head list; + off_t min; + off_t max; + unsigned int base_reg; + unsigned int max_reg; +}; + +struct regmap_debugfs_node { + struct regmap *map; + struct list_head link; +}; + +typedef void (*irq_write_msi_msg_t)(struct msi_desc *, struct msi_msg *); + +struct platform_msi_priv_data { + struct device *dev; + void *host_data; + msi_alloc_info_t arg; + irq_write_msi_msg_t write_msg; + int devid; +}; + +struct brd_device { + int brd_number; + struct request_queue *brd_queue; + struct gendisk *brd_disk; + struct list_head brd_list; + spinlock_t brd_lock; + struct xarray brd_pages; +}; + +typedef long unsigned int __kernel_old_dev_t; + +enum { + LO_FLAGS_READ_ONLY = 1, + LO_FLAGS_AUTOCLEAR = 4, + LO_FLAGS_PARTSCAN = 8, + LO_FLAGS_DIRECT_IO = 16, +}; + +struct loop_info { + int lo_number; + __kernel_old_dev_t lo_device; + long unsigned int lo_inode; + __kernel_old_dev_t lo_rdevice; + int lo_offset; + int lo_encrypt_type; + int lo_encrypt_key_size; + int lo_flags; + char lo_name[64]; + unsigned char lo_encrypt_key[32]; + long unsigned int lo_init[2]; + char reserved[4]; +}; + +struct loop_info64 { + __u64 lo_device; + __u64 lo_inode; + __u64 lo_rdevice; + __u64 lo_offset; + __u64 lo_sizelimit; + __u32 lo_number; + __u32 lo_encrypt_type; + __u32 lo_encrypt_key_size; + __u32 lo_flags; + __u8 lo_file_name[64]; + __u8 lo_crypt_name[64]; + __u8 lo_encrypt_key[32]; + __u64 lo_init[2]; +}; + +struct loop_config { + __u32 fd; + __u32 block_size; + struct loop_info64 info; + __u64 __reserved[8]; +}; + +enum { + Lo_unbound = 0, + Lo_bound = 1, + Lo_rundown = 2, +}; + +struct loop_func_table; + +struct loop_device { + int lo_number; + atomic_t lo_refcnt; + loff_t lo_offset; + loff_t lo_sizelimit; + int lo_flags; + int (*transfer)(struct loop_device *, int, struct page *, unsigned int, struct page *, unsigned int, int, sector_t); + char lo_file_name[64]; + char lo_crypt_name[64]; + char lo_encrypt_key[32]; + int lo_encrypt_key_size; + struct loop_func_table *lo_encryption; + __u32 lo_init[2]; + kuid_t lo_key_owner; + int (*ioctl)(struct loop_device *, int, long unsigned int); + struct file *lo_backing_file; + struct block_device *lo_device; + void *key_data; + gfp_t old_gfp_mask; + spinlock_t lo_lock; + int lo_state; + struct kthread_worker worker; + struct task_struct *worker_task; + bool use_dio; + bool sysfs_inited; + struct request_queue *lo_queue; + struct blk_mq_tag_set tag_set; + struct gendisk *lo_disk; +}; + +struct loop_func_table { + int number; + int (*transfer)(struct loop_device *, int, struct page *, unsigned int, struct page *, unsigned int, int, sector_t); + int (*init)(struct loop_device *, const struct loop_info64 *); + int (*release)(struct loop_device *); + int (*ioctl)(struct loop_device *, int, long unsigned int); + struct module *owner; +}; + +struct loop_cmd { + struct kthread_work work; + bool use_aio; + atomic_t ref; + long int ret; + struct kiocb iocb; + struct bio_vec *bvec; + struct cgroup_subsys_state *css; +}; + +struct compat_loop_info { + compat_int_t lo_number; + compat_dev_t lo_device; + compat_ulong_t lo_inode; + compat_dev_t lo_rdevice; + compat_int_t lo_offset; + compat_int_t lo_encrypt_type; + compat_int_t lo_encrypt_key_size; + compat_int_t lo_flags; + char lo_name[64]; + unsigned char lo_encrypt_key[32]; + compat_ulong_t lo_init[2]; + char reserved[4]; +}; + +typedef int (*encdec_cbc_t)(struct skcipher_request *); + +struct virtio_blk_geometry { + __virtio16 cylinders; + __u8 heads; + __u8 sectors; +}; + +struct virtio_blk_config { + __virtio64 capacity; + __virtio32 size_max; + __virtio32 seg_max; + struct virtio_blk_geometry geometry; + __virtio32 blk_size; + __u8 physical_block_exp; + __u8 alignment_offset; + __virtio16 min_io_size; + __virtio32 opt_io_size; + __u8 wce; + __u8 unused; + __virtio16 num_queues; + __virtio32 max_discard_sectors; + __virtio32 max_discard_seg; + __virtio32 discard_sector_alignment; + __virtio32 max_write_zeroes_sectors; + __virtio32 max_write_zeroes_seg; + __u8 write_zeroes_may_unmap; + __u8 unused1[3]; +} __attribute__((packed)); + +struct virtio_blk_outhdr { + __virtio32 type; + __virtio32 ioprio; + __virtio64 sector; +}; + +struct virtio_blk_discard_write_zeroes { + __le64 sector; + __le32 num_sectors; + __le32 flags; +}; + +struct virtio_blk_vq { + struct virtqueue *vq; + spinlock_t lock; + char name[16]; + long: 64; + long: 64; +}; + +struct virtio_blk { + struct mutex vdev_mutex; + struct virtio_device *vdev; + struct gendisk *disk; + struct blk_mq_tag_set tag_set; + struct work_struct config_work; + refcount_t refs; + unsigned int sg_elems; + int index; + int num_vqs; + struct virtio_blk_vq *vqs; +}; + +struct virtblk_req { + struct virtio_blk_outhdr out_hdr; + u8 status; + struct scatterlist sg[0]; +}; + +struct seqcount_ww_mutex { + seqcount_t seqcount; +}; + +typedef struct seqcount_ww_mutex seqcount_ww_mutex_t; + +struct dma_fence_ops; + +struct dma_fence { + spinlock_t *lock; + const struct dma_fence_ops *ops; + union { + struct list_head cb_list; + ktime_t timestamp; + struct callback_head rcu; + }; + u64 context; + u64 seqno; + long unsigned int flags; + struct kref refcount; + int error; +}; + +struct dma_fence_ops { + bool use_64bit_seqno; + const char * (*get_driver_name)(struct dma_fence *); + const char * (*get_timeline_name)(struct dma_fence *); + bool (*enable_signaling)(struct dma_fence *); + bool (*signaled)(struct dma_fence *); + long int (*wait)(struct dma_fence *, bool, long int); + void (*release)(struct dma_fence *); + void (*fence_value_str)(struct dma_fence *, char *, int); + void (*timeline_value_str)(struct dma_fence *, char *, int); +}; + +enum dma_fence_flag_bits { + DMA_FENCE_FLAG_SIGNALED_BIT = 0, + DMA_FENCE_FLAG_TIMESTAMP_BIT = 1, + DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT = 2, + DMA_FENCE_FLAG_USER_BITS = 3, +}; + +struct dma_fence_cb; + +typedef void (*dma_fence_func_t)(struct dma_fence *, struct dma_fence_cb *); + +struct dma_fence_cb { + struct list_head node; + dma_fence_func_t func; +}; + +struct dma_buf; + +struct dma_buf_attachment; + +struct dma_buf_ops { + bool cache_sgt_mapping; + int (*attach)(struct dma_buf *, struct dma_buf_attachment *); + void (*detach)(struct dma_buf *, struct dma_buf_attachment *); + int (*pin)(struct dma_buf_attachment *); + void (*unpin)(struct dma_buf_attachment *); + struct sg_table * (*map_dma_buf)(struct dma_buf_attachment *, enum dma_data_direction); + void (*unmap_dma_buf)(struct dma_buf_attachment *, struct sg_table *, enum dma_data_direction); + void (*release)(struct dma_buf *); + int (*begin_cpu_access)(struct dma_buf *, enum dma_data_direction); + int (*end_cpu_access)(struct dma_buf *, enum dma_data_direction); + int (*mmap)(struct dma_buf *, struct vm_area_struct *); + void * (*vmap)(struct dma_buf *); + void (*vunmap)(struct dma_buf *, void *); +}; + +struct dma_buf_poll_cb_t { + struct dma_fence_cb cb; + wait_queue_head_t *poll; + __poll_t active; +}; + +struct dma_resv; + +struct dma_buf { + size_t size; + struct file *file; + struct list_head attachments; + const struct dma_buf_ops *ops; + struct mutex lock; + unsigned int vmapping_counter; + void *vmap_ptr; + const char *exp_name; + const char *name; + spinlock_t name_lock; + struct module *owner; + struct list_head list_node; + void *priv; + struct dma_resv *resv; + wait_queue_head_t poll; + struct dma_buf_poll_cb_t cb_excl; + struct dma_buf_poll_cb_t cb_shared; +}; + +struct dma_buf_attach_ops; + +struct dma_buf_attachment { + struct dma_buf *dmabuf; + struct device *dev; + struct list_head node; + struct sg_table *sgt; + enum dma_data_direction dir; + bool peer2peer; + const struct dma_buf_attach_ops *importer_ops; + void *importer_priv; + void *priv; +}; + +struct dma_resv_list; + +struct dma_resv { + struct ww_mutex lock; + seqcount_ww_mutex_t seq; + struct dma_fence *fence_excl; + struct dma_resv_list *fence; +}; + +struct dma_buf_attach_ops { + bool allow_peer2peer; + void (*move_notify)(struct dma_buf_attachment *); +}; + +struct dma_buf_export_info { + const char *exp_name; + struct module *owner; + const struct dma_buf_ops *ops; + size_t size; + int flags; + struct dma_resv *resv; + void *priv; +}; + +struct dma_resv_list { + struct callback_head rcu; + u32 shared_count; + u32 shared_max; + struct dma_fence *shared[0]; +}; + +struct dma_buf_sync { + __u64 flags; +}; + +struct dma_buf_list { + struct list_head head; + struct mutex lock; +}; + +struct trace_event_raw_dma_fence { + struct trace_entry ent; + u32 __data_loc_driver; + u32 __data_loc_timeline; + unsigned int context; + unsigned int seqno; + char __data[0]; +}; + +struct trace_event_data_offsets_dma_fence { + u32 driver; + u32 timeline; +}; + +typedef void (*btf_trace_dma_fence_emit)(void *, struct dma_fence *); + +typedef void (*btf_trace_dma_fence_init)(void *, struct dma_fence *); + +typedef void (*btf_trace_dma_fence_destroy)(void *, struct dma_fence *); + +typedef void (*btf_trace_dma_fence_enable_signal)(void *, struct dma_fence *); + +typedef void (*btf_trace_dma_fence_signaled)(void *, struct dma_fence *); + +typedef void (*btf_trace_dma_fence_wait_start)(void *, struct dma_fence *); + +typedef void (*btf_trace_dma_fence_wait_end)(void *, struct dma_fence *); + +struct default_wait_cb { + struct dma_fence_cb base; + struct task_struct *task; +}; + +struct dma_fence_array; + +struct dma_fence_array_cb { + struct dma_fence_cb cb; + struct dma_fence_array *array; +}; + +struct dma_fence_array { + struct dma_fence base; + spinlock_t lock; + unsigned int num_fences; + atomic_t num_pending; + struct dma_fence **fences; + struct irq_work work; +}; + +struct dma_fence_chain { + struct dma_fence base; + spinlock_t lock; + struct dma_fence *prev; + u64 prev_seqno; + struct dma_fence *fence; + struct dma_fence_cb cb; + struct irq_work work; +}; + +enum seqno_fence_condition { + SEQNO_FENCE_WAIT_GEQUAL = 0, + SEQNO_FENCE_WAIT_NONZERO = 1, +}; + +struct seqno_fence { + struct dma_fence base; + const struct dma_fence_ops *ops; + struct dma_buf *sync_buf; + uint32_t seqno_ofs; + enum seqno_fence_condition condition; +}; + +struct sync_file { + struct file *file; + char user_name[32]; + struct list_head sync_file_list; + wait_queue_head_t wq; + long unsigned int flags; + struct dma_fence *fence; + struct dma_fence_cb cb; +}; + +struct sync_merge_data { + char name[32]; + __s32 fd2; + __s32 fence; + __u32 flags; + __u32 pad; +}; + +struct sync_fence_info { + char obj_name[32]; + char driver_name[32]; + __s32 status; + __u32 flags; + __u64 timestamp_ns; +}; + +struct sync_file_info { + char name[32]; + __s32 status; + __u32 flags; + __u32 num_fences; + __u32 pad; + __u64 sync_fence_info; +}; + +enum { + ATA_MAX_DEVICES = 2, + ATA_MAX_PRD = 256, + ATA_SECT_SIZE = 512, + ATA_MAX_SECTORS_128 = 128, + ATA_MAX_SECTORS = 256, + ATA_MAX_SECTORS_1024 = 1024, + ATA_MAX_SECTORS_LBA48 = 65535, + ATA_MAX_SECTORS_TAPE = 65535, + ATA_MAX_TRIM_RNUM = 64, + ATA_ID_WORDS = 256, + ATA_ID_CONFIG = 0, + ATA_ID_CYLS = 1, + ATA_ID_HEADS = 3, + ATA_ID_SECTORS = 6, + ATA_ID_SERNO = 10, + ATA_ID_BUF_SIZE = 21, + ATA_ID_FW_REV = 23, + ATA_ID_PROD = 27, + ATA_ID_MAX_MULTSECT = 47, + ATA_ID_DWORD_IO = 48, + ATA_ID_TRUSTED = 48, + ATA_ID_CAPABILITY = 49, + ATA_ID_OLD_PIO_MODES = 51, + ATA_ID_OLD_DMA_MODES = 52, + ATA_ID_FIELD_VALID = 53, + ATA_ID_CUR_CYLS = 54, + ATA_ID_CUR_HEADS = 55, + ATA_ID_CUR_SECTORS = 56, + ATA_ID_MULTSECT = 59, + ATA_ID_LBA_CAPACITY = 60, + ATA_ID_SWDMA_MODES = 62, + ATA_ID_MWDMA_MODES = 63, + ATA_ID_PIO_MODES = 64, + ATA_ID_EIDE_DMA_MIN = 65, + ATA_ID_EIDE_DMA_TIME = 66, + ATA_ID_EIDE_PIO = 67, + ATA_ID_EIDE_PIO_IORDY = 68, + ATA_ID_ADDITIONAL_SUPP = 69, + ATA_ID_QUEUE_DEPTH = 75, + ATA_ID_SATA_CAPABILITY = 76, + ATA_ID_SATA_CAPABILITY_2 = 77, + ATA_ID_FEATURE_SUPP = 78, + ATA_ID_MAJOR_VER = 80, + ATA_ID_COMMAND_SET_1 = 82, + ATA_ID_COMMAND_SET_2 = 83, + ATA_ID_CFSSE = 84, + ATA_ID_CFS_ENABLE_1 = 85, + ATA_ID_CFS_ENABLE_2 = 86, + ATA_ID_CSF_DEFAULT = 87, + ATA_ID_UDMA_MODES = 88, + ATA_ID_HW_CONFIG = 93, + ATA_ID_SPG = 98, + ATA_ID_LBA_CAPACITY_2 = 100, + ATA_ID_SECTOR_SIZE = 106, + ATA_ID_WWN = 108, + ATA_ID_LOGICAL_SECTOR_SIZE = 117, + ATA_ID_COMMAND_SET_3 = 119, + ATA_ID_COMMAND_SET_4 = 120, + ATA_ID_LAST_LUN = 126, + ATA_ID_DLF = 128, + ATA_ID_CSFO = 129, + ATA_ID_CFA_POWER = 160, + ATA_ID_CFA_KEY_MGMT = 162, + ATA_ID_CFA_MODES = 163, + ATA_ID_DATA_SET_MGMT = 169, + ATA_ID_SCT_CMD_XPORT = 206, + ATA_ID_ROT_SPEED = 217, + ATA_ID_PIO4 = 2, + ATA_ID_SERNO_LEN = 20, + ATA_ID_FW_REV_LEN = 8, + ATA_ID_PROD_LEN = 40, + ATA_ID_WWN_LEN = 8, + ATA_PCI_CTL_OFS = 2, + ATA_PIO0 = 1, + ATA_PIO1 = 3, + ATA_PIO2 = 7, + ATA_PIO3 = 15, + ATA_PIO4 = 31, + ATA_PIO5 = 63, + ATA_PIO6 = 127, + ATA_PIO4_ONLY = 16, + ATA_SWDMA0 = 1, + ATA_SWDMA1 = 3, + ATA_SWDMA2 = 7, + ATA_SWDMA2_ONLY = 4, + ATA_MWDMA0 = 1, + ATA_MWDMA1 = 3, + ATA_MWDMA2 = 7, + ATA_MWDMA3 = 15, + ATA_MWDMA4 = 31, + ATA_MWDMA12_ONLY = 6, + ATA_MWDMA2_ONLY = 4, + ATA_UDMA0 = 1, + ATA_UDMA1 = 3, + ATA_UDMA2 = 7, + ATA_UDMA3 = 15, + ATA_UDMA4 = 31, + ATA_UDMA5 = 63, + ATA_UDMA6 = 127, + ATA_UDMA7 = 255, + ATA_UDMA24_ONLY = 20, + ATA_UDMA_MASK_40C = 7, + ATA_PRD_SZ = 8, + ATA_PRD_TBL_SZ = 2048, + ATA_PRD_EOT = 2147483648, + ATA_DMA_TABLE_OFS = 4, + ATA_DMA_STATUS = 2, + ATA_DMA_CMD = 0, + ATA_DMA_WR = 8, + ATA_DMA_START = 1, + ATA_DMA_INTR = 4, + ATA_DMA_ERR = 2, + ATA_DMA_ACTIVE = 1, + ATA_HOB = 128, + ATA_NIEN = 2, + ATA_LBA = 64, + ATA_DEV1 = 16, + ATA_DEVICE_OBS = 160, + ATA_DEVCTL_OBS = 8, + ATA_BUSY = 128, + ATA_DRDY = 64, + ATA_DF = 32, + ATA_DSC = 16, + ATA_DRQ = 8, + ATA_CORR = 4, + ATA_SENSE = 2, + ATA_ERR = 1, + ATA_SRST = 4, + ATA_ICRC = 128, + ATA_BBK = 128, + ATA_UNC = 64, + ATA_MC = 32, + ATA_IDNF = 16, + ATA_MCR = 8, + ATA_ABORTED = 4, + ATA_TRK0NF = 2, + ATA_AMNF = 1, + ATAPI_LFS = 240, + ATAPI_EOM = 2, + ATAPI_ILI = 1, + ATAPI_IO = 2, + ATAPI_COD = 1, + ATA_REG_DATA = 0, + ATA_REG_ERR = 1, + ATA_REG_NSECT = 2, + ATA_REG_LBAL = 3, + ATA_REG_LBAM = 4, + ATA_REG_LBAH = 5, + ATA_REG_DEVICE = 6, + ATA_REG_STATUS = 7, + ATA_REG_FEATURE = 1, + ATA_REG_CMD = 7, + ATA_REG_BYTEL = 4, + ATA_REG_BYTEH = 5, + ATA_REG_DEVSEL = 6, + ATA_REG_IRQ = 2, + ATA_CMD_DEV_RESET = 8, + ATA_CMD_CHK_POWER = 229, + ATA_CMD_STANDBY = 226, + ATA_CMD_IDLE = 227, + ATA_CMD_EDD = 144, + ATA_CMD_DOWNLOAD_MICRO = 146, + ATA_CMD_DOWNLOAD_MICRO_DMA = 147, + ATA_CMD_NOP = 0, + ATA_CMD_FLUSH = 231, + ATA_CMD_FLUSH_EXT = 234, + ATA_CMD_ID_ATA = 236, + ATA_CMD_ID_ATAPI = 161, + ATA_CMD_SERVICE = 162, + ATA_CMD_READ = 200, + ATA_CMD_READ_EXT = 37, + ATA_CMD_READ_QUEUED = 38, + ATA_CMD_READ_STREAM_EXT = 43, + ATA_CMD_READ_STREAM_DMA_EXT = 42, + ATA_CMD_WRITE = 202, + ATA_CMD_WRITE_EXT = 53, + ATA_CMD_WRITE_QUEUED = 54, + ATA_CMD_WRITE_STREAM_EXT = 59, + ATA_CMD_WRITE_STREAM_DMA_EXT = 58, + ATA_CMD_WRITE_FUA_EXT = 61, + ATA_CMD_WRITE_QUEUED_FUA_EXT = 62, + ATA_CMD_FPDMA_READ = 96, + ATA_CMD_FPDMA_WRITE = 97, + ATA_CMD_NCQ_NON_DATA = 99, + ATA_CMD_FPDMA_SEND = 100, + ATA_CMD_FPDMA_RECV = 101, + ATA_CMD_PIO_READ = 32, + ATA_CMD_PIO_READ_EXT = 36, + ATA_CMD_PIO_WRITE = 48, + ATA_CMD_PIO_WRITE_EXT = 52, + ATA_CMD_READ_MULTI = 196, + ATA_CMD_READ_MULTI_EXT = 41, + ATA_CMD_WRITE_MULTI = 197, + ATA_CMD_WRITE_MULTI_EXT = 57, + ATA_CMD_WRITE_MULTI_FUA_EXT = 206, + ATA_CMD_SET_FEATURES = 239, + ATA_CMD_SET_MULTI = 198, + ATA_CMD_PACKET = 160, + ATA_CMD_VERIFY = 64, + ATA_CMD_VERIFY_EXT = 66, + ATA_CMD_WRITE_UNCORR_EXT = 69, + ATA_CMD_STANDBYNOW1 = 224, + ATA_CMD_IDLEIMMEDIATE = 225, + ATA_CMD_SLEEP = 230, + ATA_CMD_INIT_DEV_PARAMS = 145, + ATA_CMD_READ_NATIVE_MAX = 248, + ATA_CMD_READ_NATIVE_MAX_EXT = 39, + ATA_CMD_SET_MAX = 249, + ATA_CMD_SET_MAX_EXT = 55, + ATA_CMD_READ_LOG_EXT = 47, + ATA_CMD_WRITE_LOG_EXT = 63, + ATA_CMD_READ_LOG_DMA_EXT = 71, + ATA_CMD_WRITE_LOG_DMA_EXT = 87, + ATA_CMD_TRUSTED_NONDATA = 91, + ATA_CMD_TRUSTED_RCV = 92, + ATA_CMD_TRUSTED_RCV_DMA = 93, + ATA_CMD_TRUSTED_SND = 94, + ATA_CMD_TRUSTED_SND_DMA = 95, + ATA_CMD_PMP_READ = 228, + ATA_CMD_PMP_READ_DMA = 233, + ATA_CMD_PMP_WRITE = 232, + ATA_CMD_PMP_WRITE_DMA = 235, + ATA_CMD_CONF_OVERLAY = 177, + ATA_CMD_SEC_SET_PASS = 241, + ATA_CMD_SEC_UNLOCK = 242, + ATA_CMD_SEC_ERASE_PREP = 243, + ATA_CMD_SEC_ERASE_UNIT = 244, + ATA_CMD_SEC_FREEZE_LOCK = 245, + ATA_CMD_SEC_DISABLE_PASS = 246, + ATA_CMD_CONFIG_STREAM = 81, + ATA_CMD_SMART = 176, + ATA_CMD_MEDIA_LOCK = 222, + ATA_CMD_MEDIA_UNLOCK = 223, + ATA_CMD_DSM = 6, + ATA_CMD_CHK_MED_CRD_TYP = 209, + ATA_CMD_CFA_REQ_EXT_ERR = 3, + ATA_CMD_CFA_WRITE_NE = 56, + ATA_CMD_CFA_TRANS_SECT = 135, + ATA_CMD_CFA_ERASE = 192, + ATA_CMD_CFA_WRITE_MULT_NE = 205, + ATA_CMD_REQ_SENSE_DATA = 11, + ATA_CMD_SANITIZE_DEVICE = 180, + ATA_CMD_ZAC_MGMT_IN = 74, + ATA_CMD_ZAC_MGMT_OUT = 159, + ATA_CMD_RESTORE = 16, + ATA_SUBCMD_FPDMA_RECV_RD_LOG_DMA_EXT = 1, + ATA_SUBCMD_FPDMA_RECV_ZAC_MGMT_IN = 2, + ATA_SUBCMD_FPDMA_SEND_DSM = 0, + ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT = 2, + ATA_SUBCMD_NCQ_NON_DATA_ABORT_QUEUE = 0, + ATA_SUBCMD_NCQ_NON_DATA_SET_FEATURES = 5, + ATA_SUBCMD_NCQ_NON_DATA_ZERO_EXT = 6, + ATA_SUBCMD_NCQ_NON_DATA_ZAC_MGMT_OUT = 7, + ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES = 0, + ATA_SUBCMD_ZAC_MGMT_OUT_CLOSE_ZONE = 1, + ATA_SUBCMD_ZAC_MGMT_OUT_FINISH_ZONE = 2, + ATA_SUBCMD_ZAC_MGMT_OUT_OPEN_ZONE = 3, + ATA_SUBCMD_ZAC_MGMT_OUT_RESET_WRITE_POINTER = 4, + ATA_LOG_DIRECTORY = 0, + ATA_LOG_SATA_NCQ = 16, + ATA_LOG_NCQ_NON_DATA = 18, + ATA_LOG_NCQ_SEND_RECV = 19, + ATA_LOG_IDENTIFY_DEVICE = 48, + ATA_LOG_SECURITY = 6, + ATA_LOG_SATA_SETTINGS = 8, + ATA_LOG_ZONED_INFORMATION = 9, + ATA_LOG_DEVSLP_OFFSET = 48, + ATA_LOG_DEVSLP_SIZE = 8, + ATA_LOG_DEVSLP_MDAT = 0, + ATA_LOG_DEVSLP_MDAT_MASK = 31, + ATA_LOG_DEVSLP_DETO = 1, + ATA_LOG_DEVSLP_VALID = 7, + ATA_LOG_DEVSLP_VALID_MASK = 128, + ATA_LOG_NCQ_PRIO_OFFSET = 9, + ATA_LOG_NCQ_SEND_RECV_SUBCMDS_OFFSET = 0, + ATA_LOG_NCQ_SEND_RECV_SUBCMDS_DSM = 1, + ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET = 4, + ATA_LOG_NCQ_SEND_RECV_DSM_TRIM = 1, + ATA_LOG_NCQ_SEND_RECV_RD_LOG_OFFSET = 8, + ATA_LOG_NCQ_SEND_RECV_RD_LOG_SUPPORTED = 1, + ATA_LOG_NCQ_SEND_RECV_WR_LOG_OFFSET = 12, + ATA_LOG_NCQ_SEND_RECV_WR_LOG_SUPPORTED = 1, + ATA_LOG_NCQ_SEND_RECV_ZAC_MGMT_OFFSET = 16, + ATA_LOG_NCQ_SEND_RECV_ZAC_MGMT_OUT_SUPPORTED = 1, + ATA_LOG_NCQ_SEND_RECV_ZAC_MGMT_IN_SUPPORTED = 2, + ATA_LOG_NCQ_SEND_RECV_SIZE = 20, + ATA_LOG_NCQ_NON_DATA_SUBCMDS_OFFSET = 0, + ATA_LOG_NCQ_NON_DATA_ABORT_OFFSET = 0, + ATA_LOG_NCQ_NON_DATA_ABORT_NCQ = 1, + ATA_LOG_NCQ_NON_DATA_ABORT_ALL = 2, + ATA_LOG_NCQ_NON_DATA_ABORT_STREAMING = 4, + ATA_LOG_NCQ_NON_DATA_ABORT_NON_STREAMING = 8, + ATA_LOG_NCQ_NON_DATA_ABORT_SELECTED = 16, + ATA_LOG_NCQ_NON_DATA_ZAC_MGMT_OFFSET = 28, + ATA_LOG_NCQ_NON_DATA_ZAC_MGMT_OUT = 1, + ATA_LOG_NCQ_NON_DATA_SIZE = 64, + ATA_CMD_READ_LONG = 34, + ATA_CMD_READ_LONG_ONCE = 35, + ATA_CMD_WRITE_LONG = 50, + ATA_CMD_WRITE_LONG_ONCE = 51, + SETFEATURES_XFER = 3, + XFER_UDMA_7 = 71, + XFER_UDMA_6 = 70, + XFER_UDMA_5 = 69, + XFER_UDMA_4 = 68, + XFER_UDMA_3 = 67, + XFER_UDMA_2 = 66, + XFER_UDMA_1 = 65, + XFER_UDMA_0 = 64, + XFER_MW_DMA_4 = 36, + XFER_MW_DMA_3 = 35, + XFER_MW_DMA_2 = 34, + XFER_MW_DMA_1 = 33, + XFER_MW_DMA_0 = 32, + XFER_SW_DMA_2 = 18, + XFER_SW_DMA_1 = 17, + XFER_SW_DMA_0 = 16, + XFER_PIO_6 = 14, + XFER_PIO_5 = 13, + XFER_PIO_4 = 12, + XFER_PIO_3 = 11, + XFER_PIO_2 = 10, + XFER_PIO_1 = 9, + XFER_PIO_0 = 8, + XFER_PIO_SLOW = 0, + SETFEATURES_WC_ON = 2, + SETFEATURES_WC_OFF = 130, + SETFEATURES_RA_ON = 170, + SETFEATURES_RA_OFF = 85, + SETFEATURES_AAM_ON = 66, + SETFEATURES_AAM_OFF = 194, + SETFEATURES_SPINUP = 7, + SETFEATURES_SPINUP_TIMEOUT = 30000, + SETFEATURES_SATA_ENABLE = 16, + SETFEATURES_SATA_DISABLE = 144, + SATA_FPDMA_OFFSET = 1, + SATA_FPDMA_AA = 2, + SATA_DIPM = 3, + SATA_FPDMA_IN_ORDER = 4, + SATA_AN = 5, + SATA_SSP = 6, + SATA_DEVSLP = 9, + SETFEATURE_SENSE_DATA = 195, + ATA_SET_MAX_ADDR = 0, + ATA_SET_MAX_PASSWD = 1, + ATA_SET_MAX_LOCK = 2, + ATA_SET_MAX_UNLOCK = 3, + ATA_SET_MAX_FREEZE_LOCK = 4, + ATA_SET_MAX_PASSWD_DMA = 5, + ATA_SET_MAX_UNLOCK_DMA = 6, + ATA_DCO_RESTORE = 192, + ATA_DCO_FREEZE_LOCK = 193, + ATA_DCO_IDENTIFY = 194, + ATA_DCO_SET = 195, + ATA_SMART_ENABLE = 216, + ATA_SMART_READ_VALUES = 208, + ATA_SMART_READ_THRESHOLDS = 209, + ATA_DSM_TRIM = 1, + ATA_SMART_LBAM_PASS = 79, + ATA_SMART_LBAH_PASS = 194, + ATAPI_PKT_DMA = 1, + ATAPI_DMADIR = 4, + ATAPI_CDB_LEN = 16, + SATA_PMP_MAX_PORTS = 15, + SATA_PMP_CTRL_PORT = 15, + SATA_PMP_GSCR_DWORDS = 128, + SATA_PMP_GSCR_PROD_ID = 0, + SATA_PMP_GSCR_REV = 1, + SATA_PMP_GSCR_PORT_INFO = 2, + SATA_PMP_GSCR_ERROR = 32, + SATA_PMP_GSCR_ERROR_EN = 33, + SATA_PMP_GSCR_FEAT = 64, + SATA_PMP_GSCR_FEAT_EN = 96, + SATA_PMP_PSCR_STATUS = 0, + SATA_PMP_PSCR_ERROR = 1, + SATA_PMP_PSCR_CONTROL = 2, + SATA_PMP_FEAT_BIST = 1, + SATA_PMP_FEAT_PMREQ = 2, + SATA_PMP_FEAT_DYNSSC = 4, + SATA_PMP_FEAT_NOTIFY = 8, + ATA_CBL_NONE = 0, + ATA_CBL_PATA40 = 1, + ATA_CBL_PATA80 = 2, + ATA_CBL_PATA40_SHORT = 3, + ATA_CBL_PATA_UNK = 4, + ATA_CBL_PATA_IGN = 5, + ATA_CBL_SATA = 6, + SCR_STATUS = 0, + SCR_ERROR = 1, + SCR_CONTROL = 2, + SCR_ACTIVE = 3, + SCR_NOTIFICATION = 4, + SERR_DATA_RECOVERED = 1, + SERR_COMM_RECOVERED = 2, + SERR_DATA = 256, + SERR_PERSISTENT = 512, + SERR_PROTOCOL = 1024, + SERR_INTERNAL = 2048, + SERR_PHYRDY_CHG = 65536, + SERR_PHY_INT_ERR = 131072, + SERR_COMM_WAKE = 262144, + SERR_10B_8B_ERR = 524288, + SERR_DISPARITY = 1048576, + SERR_CRC = 2097152, + SERR_HANDSHAKE = 4194304, + SERR_LINK_SEQ_ERR = 8388608, + SERR_TRANS_ST_ERROR = 16777216, + SERR_UNRECOG_FIS = 33554432, + SERR_DEV_XCHG = 67108864, +}; + +struct ide_io_ports { + long unsigned int data_addr; + union { + long unsigned int error_addr; + long unsigned int feature_addr; + }; + long unsigned int nsect_addr; + long unsigned int lbal_addr; + long unsigned int lbam_addr; + long unsigned int lbah_addr; + long unsigned int device_addr; + union { + long unsigned int status_addr; + long unsigned int command_addr; + }; + long unsigned int ctl_addr; + long unsigned int irq_addr; +}; + +typedef u8 hwif_chipset_t; + +typedef enum { + ide_stopped = 0, + ide_started = 1, +} ide_startstop_t; + +struct ide_taskfile { + u8 data; + union { + u8 error; + u8 feature; + }; + u8 nsect; + u8 lbal; + u8 lbam; + u8 lbah; + u8 device; + union { + u8 status; + u8 command; + }; +}; + +struct ide_cmd { + struct ide_taskfile tf; + struct ide_taskfile hob; + struct { + struct { + u8 tf; + u8 hob; + } out; + struct { + u8 tf; + u8 hob; + } in; + } valid; + u16 tf_flags; + u8 ftf_flags; + int protocol; + int sg_nents; + int orig_sg_nents; + int sg_dma_direction; + unsigned int nbytes; + unsigned int nleft; + unsigned int last_xfer_len; + struct scatterlist *cursg; + unsigned int cursg_ofs; + struct request *rq; +}; + +struct ide_atapi_pc { + u8 c[12]; + int retries; + int error; + int req_xfer; + struct request *rq; + long unsigned int flags; + long unsigned int timeout; +}; + +struct ide_drive_s; + +struct ide_disk_ops { + int (*check)(struct ide_drive_s *, const char *); + int (*get_capacity)(struct ide_drive_s *); + void (*unlock_native_capacity)(struct ide_drive_s *); + void (*setup)(struct ide_drive_s *); + void (*flush)(struct ide_drive_s *); + int (*init_media)(struct ide_drive_s *, struct gendisk *); + int (*set_doorlock)(struct ide_drive_s *, struct gendisk *, int); + ide_startstop_t (*do_request)(struct ide_drive_s *, struct request *, sector_t); + int (*ioctl)(struct ide_drive_s *, struct block_device *, fmode_t, unsigned int, long unsigned int); + int (*compat_ioctl)(struct ide_drive_s *, struct block_device *, fmode_t, unsigned int, long unsigned int); +}; + +struct ide_proc_devset; + +struct hwif_s; + +struct ide_drive_s { + char name[4]; + char driver_req[10]; + struct request_queue *queue; + bool (*prep_rq)(struct ide_drive_s *, struct request *); + struct blk_mq_tag_set tag_set; + struct request *rq; + void *driver_data; + u16 *id; + struct proc_dir_entry *proc; + const struct ide_proc_devset *settings; + struct hwif_s *hwif; + const struct ide_disk_ops *disk_ops; + long unsigned int dev_flags; + long unsigned int sleep; + long unsigned int timeout; + u8 special_flags; + u8 select; + u8 retry_pio; + u8 waiting_for_dma; + u8 dma; + u8 init_speed; + u8 current_speed; + u8 desired_speed; + u8 pio_mode; + u8 dma_mode; + u8 dn; + u8 acoustic; + u8 media; + u8 ready_stat; + u8 mult_count; + u8 mult_req; + u8 io_32bit; + u8 bad_wstat; + u8 head; + u8 sect; + u8 bios_head; + u8 bios_sect; + u8 pc_delay; + unsigned int bios_cyl; + unsigned int cyl; + void *drive_data; + unsigned int failures; + unsigned int max_failures; + u64 probed_capacity; + u64 capacity64; + int lun; + int crc_count; + long unsigned int debug_mask; + struct list_head list; + struct device gendev; + struct completion gendev_rel_comp; + struct ide_atapi_pc *pc; + struct ide_atapi_pc *failed_pc; + int (*pc_callback)(struct ide_drive_s *, int); + ide_startstop_t (*irq_handler)(struct ide_drive_s *); + long unsigned int atapi_flags; + struct ide_atapi_pc request_sense_pc; + bool sense_rq_armed; + bool sense_rq_active; + struct request *sense_rq; + struct request_sense sense_data; + struct work_struct rq_work; + struct list_head rq_list; +}; + +enum { + IDE_DFLAG_KEEP_SETTINGS = 1, + IDE_DFLAG_USING_DMA = 2, + IDE_DFLAG_UNMASK = 4, + IDE_DFLAG_NOFLUSH = 8, + IDE_DFLAG_DSC_OVERLAP = 16, + IDE_DFLAG_NICE1 = 32, + IDE_DFLAG_PRESENT = 64, + IDE_DFLAG_NOHPA = 128, + IDE_DFLAG_ID_READ = 256, + IDE_DFLAG_NOPROBE = 512, + IDE_DFLAG_REMOVABLE = 1024, + IDE_DFLAG_FORCED_GEOM = 4096, + IDE_DFLAG_NO_UNMASK = 8192, + IDE_DFLAG_NO_IO_32BIT = 16384, + IDE_DFLAG_DOORLOCKING = 32768, + IDE_DFLAG_NODMA = 65536, + IDE_DFLAG_BLOCKED = 131072, + IDE_DFLAG_SLEEPING = 262144, + IDE_DFLAG_POST_RESET = 524288, + IDE_DFLAG_UDMA33_WARNED = 1048576, + IDE_DFLAG_LBA48 = 2097152, + IDE_DFLAG_WCACHE = 4194304, + IDE_DFLAG_NOWERR = 8388608, + IDE_DFLAG_DMA_PIO_RETRY = 16777216, + IDE_DFLAG_LBA = 33554432, + IDE_DFLAG_NO_UNLOAD = 67108864, + IDE_DFLAG_PARKED = 134217728, + IDE_DFLAG_MEDIA_CHANGED = 268435456, + IDE_DFLAG_WP = 536870912, + IDE_DFLAG_FORMAT_IN_PROGRESS = 1073741824, + IDE_DFLAG_NIEN_QUIRK = 2147483648, +}; + +typedef struct ide_drive_s ide_drive_t; + +struct ide_devset; + +struct ide_proc_devset { + const char *name; + const struct ide_devset *setting; + int min; + int max; + int (*mulf)(ide_drive_t *); + int (*divf)(ide_drive_t *); +}; + +struct ide_host; + +struct ide_tp_ops; + +struct ide_port_ops; + +struct ide_dma_ops; + +struct hwif_s { + struct hwif_s *mate; + struct proc_dir_entry *proc; + struct ide_host *host; + char name[6]; + struct ide_io_ports io_ports; + long unsigned int sata_scr[3]; + ide_drive_t *devices[3]; + long unsigned int port_flags; + u8 major; + u8 index; + u8 channel; + u32 host_flags; + u8 pio_mask; + u8 ultra_mask; + u8 mwdma_mask; + u8 swdma_mask; + u8 cbl; + hwif_chipset_t chipset; + struct device *dev; + void (*rw_disk)(ide_drive_t *, struct request *); + const struct ide_tp_ops *tp_ops; + const struct ide_port_ops *port_ops; + const struct ide_dma_ops *dma_ops; + unsigned int *dmatable_cpu; + dma_addr_t dmatable_dma; + int prd_max_nents; + int prd_ent_size; + struct scatterlist *sg_table; + int sg_max_nents; + struct ide_cmd cmd; + int rqsize; + int irq; + long unsigned int dma_base; + long unsigned int config_data; + long unsigned int select_data; + long unsigned int extra_base; + unsigned int extra_ports; + unsigned int present: 1; + unsigned int busy: 1; + struct device gendev; + struct device *portdev; + struct completion gendev_rel_comp; + void *hwif_data; + ide_startstop_t (*handler)(ide_drive_t *); + unsigned int polling: 1; + ide_drive_t *cur_dev; + struct request *rq; + struct timer_list timer; + long unsigned int poll_timeout; + int (*expiry)(ide_drive_t *); + int req_gen; + int req_gen_timer; + spinlock_t lock; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct ide_tp_ops { + void (*exec_command)(struct hwif_s *, u8); + u8 (*read_status)(struct hwif_s *); + u8 (*read_altstatus)(struct hwif_s *); + void (*write_devctl)(struct hwif_s *, u8); + void (*dev_select)(ide_drive_t *); + void (*tf_load)(ide_drive_t *, struct ide_taskfile *, u8); + void (*tf_read)(ide_drive_t *, struct ide_taskfile *, u8); + void (*input_data)(ide_drive_t *, struct ide_cmd *, void *, unsigned int); + void (*output_data)(ide_drive_t *, struct ide_cmd *, void *, unsigned int); +}; + +struct ide_port_ops { + void (*init_dev)(ide_drive_t *); + void (*set_pio_mode)(struct hwif_s *, ide_drive_t *); + void (*set_dma_mode)(struct hwif_s *, ide_drive_t *); + blk_status_t (*reset_poll)(ide_drive_t *); + void (*pre_reset)(ide_drive_t *); + void (*resetproc)(ide_drive_t *); + void (*maskproc)(ide_drive_t *, int); + void (*quirkproc)(ide_drive_t *); + void (*clear_irq)(ide_drive_t *); + int (*test_irq)(struct hwif_s *); + u8 (*mdma_filter)(ide_drive_t *); + u8 (*udma_filter)(ide_drive_t *); + u8 (*cable_detect)(struct hwif_s *); +}; + +struct ide_dma_ops { + void (*dma_host_set)(struct ide_drive_s *, int); + int (*dma_setup)(struct ide_drive_s *, struct ide_cmd *); + void (*dma_start)(struct ide_drive_s *); + int (*dma_end)(struct ide_drive_s *); + int (*dma_test_irq)(struct ide_drive_s *); + void (*dma_lost_irq)(struct ide_drive_s *); + int (*dma_check)(struct ide_drive_s *, struct ide_cmd *); + int (*dma_timer_expiry)(struct ide_drive_s *); + void (*dma_clear)(struct ide_drive_s *); + u8 (*dma_sff_read_status)(struct hwif_s *); +}; + +typedef struct hwif_s ide_hwif_t; + +struct ide_host { + ide_hwif_t *ports[5]; + unsigned int n_ports; + struct device *dev[2]; + int (*init_chipset)(struct pci_dev *); + void (*get_lock)(irq_handler_t, void *); + void (*release_lock)(); + irq_handler_t irq_handler; + long unsigned int host_flags; + int irq_flags; + void *host_priv; + ide_hwif_t *cur_port; + volatile long unsigned int host_busy; +}; + +struct ide_devset { + int (*get)(ide_drive_t *); + int (*set)(ide_drive_t *, int); + unsigned int flags; +}; + +typedef struct { + const char *name; + umode_t mode; + int (*show)(struct seq_file *, void *); +} ide_proc_entry_t; + +struct ide_driver { + const char *version; + ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); + struct device_driver gen_driver; + int (*probe)(ide_drive_t *); + void (*remove)(ide_drive_t *); + void (*resume)(ide_drive_t *); + void (*shutdown)(ide_drive_t *); + ide_proc_entry_t * (*proc_entries)(ide_drive_t *); + const struct ide_proc_devset * (*proc_devsets)(ide_drive_t *); +}; + +struct chs_geom { + unsigned int cyl; + u8 head; + u8 sect; +}; + +enum { + BUSSTATE_OFF = 0, + BUSSTATE_ON = 1, + BUSSTATE_TRISTATE = 2, +}; + +enum ata_prot_flags { + ATA_PROT_FLAG_PIO = 1, + ATA_PROT_FLAG_DMA = 2, + ATA_PROT_FLAG_NCQ = 4, + ATA_PROT_FLAG_ATAPI = 8, + ATA_PROT_UNKNOWN = 255, + ATA_PROT_NODATA = 0, + ATA_PROT_PIO = 1, + ATA_PROT_DMA = 2, + ATA_PROT_NCQ_NODATA = 4, + ATA_PROT_NCQ = 6, + ATAPI_PROT_NODATA = 8, + ATAPI_PROT_PIO = 9, + ATAPI_PROT_DMA = 10, +}; + +enum ata_priv_type { + ATA_PRIV_MISC = 0, + ATA_PRIV_TASKFILE = 1, + ATA_PRIV_PC = 2, + ATA_PRIV_SENSE = 3, + ATA_PRIV_PM_SUSPEND = 4, + ATA_PRIV_PM_RESUME = 5, +}; + +struct ide_request { + struct scsi_request sreq; + u8 sense[96]; + u8 type; + void *special; +}; + +enum { + IDE_VALID_ERROR = 2, + IDE_VALID_FEATURE = 2, + IDE_VALID_NSECT = 4, + IDE_VALID_LBAL = 8, + IDE_VALID_LBAM = 16, + IDE_VALID_LBAH = 32, + IDE_VALID_DEVICE = 64, + IDE_VALID_LBA = 56, + IDE_VALID_OUT_TF = 62, + IDE_VALID_IN_TF = 60, + IDE_VALID_OUT_HOB = 62, + IDE_VALID_IN_HOB = 62, +}; + +enum { + IDE_TFLAG_LBA48 = 1, + IDE_TFLAG_WRITE = 2, + IDE_TFLAG_CUSTOM_HANDLER = 4, + IDE_TFLAG_DMA_PIO_FALLBACK = 8, + IDE_TFLAG_IO_16BIT = 16, + IDE_TFLAG_DYN = 32, + IDE_TFLAG_FS = 64, + IDE_TFLAG_MULTI_PIO = 128, + IDE_TFLAG_SET_XFER = 256, +}; + +struct ide_ioctl_devset { + unsigned int get_ioctl; + unsigned int set_ioctl; + const struct ide_devset *setting; +}; + +enum { + IDE_DRV_ERROR_GENERAL = 101, + IDE_DRV_ERROR_FILEMARK = 102, + IDE_DRV_ERROR_EOD = 103, +}; + +enum { + WAIT_DRQ = 1000, + WAIT_READY = 5000, + WAIT_PIDENTIFY = 10000, + WAIT_WORSTCASE = 30000, + WAIT_CMD = 10000, + WAIT_FLOPPY_CMD = 50000, + WAIT_TAPE_CMD = 900000, + WAIT_MIN_SLEEP = 20, +}; + +enum { + IDE_SFLAG_SET_GEOMETRY = 1, + IDE_SFLAG_RECALIBRATE = 2, + IDE_SFLAG_SET_MULTMODE = 4, +}; + +enum { + IDE_FTFLAG_FLAGGED = 1, + IDE_FTFLAG_SET_IN_FLAGS = 2, + IDE_FTFLAG_OUT_DATA = 4, + IDE_FTFLAG_IN_DATA = 8, +}; + +typedef ide_startstop_t ide_handler_t(ide_drive_t *); + +typedef int ide_expiry_t(ide_drive_t *); + +enum { + IDE_PM_START_SUSPEND = 0, + IDE_PM_FLUSH_CACHE = 0, + IDE_PM_STANDBY = 1, + IDE_PM_START_RESUME = 2, + IDE_PM_RESTORE_PIO = 2, + IDE_PM_IDLE = 3, + IDE_PM_RESTORE_DMA = 4, + IDE_PM_COMPLETED = 5, +}; + +enum { + IDE_HFLAG_ISA_PORTS = 1, + IDE_HFLAG_SINGLE = 2, + IDE_HFLAG_PIO_NO_BLACKLIST = 4, + IDE_HFLAG_QD_2ND_PORT = 8, + IDE_HFLAG_ABUSE_PREFETCH = 16, + IDE_HFLAG_ABUSE_FAST_DEVSEL = 32, + IDE_HFLAG_ABUSE_DMA_MODES = 64, + IDE_HFLAG_SET_PIO_MODE_KEEP_DMA = 128, + IDE_HFLAG_POST_SET_MODE = 256, + IDE_HFLAG_NO_SET_MODE = 512, + IDE_HFLAG_TRUST_BIOS_FOR_DMA = 1024, + IDE_HFLAG_CS5520 = 2048, + IDE_HFLAG_NO_ATAPI_DMA = 4096, + IDE_HFLAG_NON_BOOTABLE = 8192, + IDE_HFLAG_NO_DMA = 16384, + IDE_HFLAG_NO_AUTODMA = 32768, + IDE_HFLAG_MMIO = 65536, + IDE_HFLAG_NO_LBA48 = 131072, + IDE_HFLAG_NO_LBA48_DMA = 262144, + IDE_HFLAG_ERROR_STOPS_FIFO = 524288, + IDE_HFLAG_SERIALIZE = 1048576, + IDE_HFLAG_DTC2278 = 2097152, + IDE_HFLAG_4DRIVES = 4194304, + IDE_HFLAG_TRM290 = 8388608, + IDE_HFLAG_IO_32BIT = 16777216, + IDE_HFLAG_UNMASK_IRQS = 33554432, + IDE_HFLAG_BROKEN_ALTSTATUS = 67108864, + IDE_HFLAG_SERIALIZE_DMA = 134217728, + IDE_HFLAG_CLEAR_SIMPLEX = 268435456, + IDE_HFLAG_NO_DSC = 536870912, + IDE_HFLAG_NO_IO_32BIT = 1073741824, + IDE_HFLAG_NO_UNMASK_IRQS = 2147483648, +}; + +struct ide_pm_state { + int pm_step; + u32 pm_state; + void *data; +}; + +enum { + IDE_AFLAG_DRQ_INTERRUPT = 1, + IDE_AFLAG_NO_EJECT = 2, + IDE_AFLAG_PRE_ATAPI12 = 4, + IDE_AFLAG_TOCADDR_AS_BCD = 8, + IDE_AFLAG_TOCTRACKS_AS_BCD = 16, + IDE_AFLAG_TOC_VALID = 64, + IDE_AFLAG_DOOR_LOCKED = 128, + IDE_AFLAG_NO_SPEED_SELECT = 256, + IDE_AFLAG_VERTOS_300_SSD = 512, + IDE_AFLAG_VERTOS_600_ESD = 1024, + IDE_AFLAG_SANYO_3CD = 2048, + IDE_AFLAG_FULL_CAPS_PAGE = 4096, + IDE_AFLAG_PLAY_AUDIO_OK = 8192, + IDE_AFLAG_LE_SPEED_FIELDS = 16384, + IDE_AFLAG_CLIK_DRIVE = 32768, + IDE_AFLAG_ZIP_DRIVE = 65536, + IDE_AFLAG_SRFP = 131072, + IDE_AFLAG_IGNORE_DSC = 262144, + IDE_AFLAG_ADDRESS_VALID = 524288, + IDE_AFLAG_BUSY = 1048576, + IDE_AFLAG_DETECT_BS = 2097152, + IDE_AFLAG_FILEMARK = 4194304, + IDE_AFLAG_MEDIUM_PRESENT = 8388608, + IDE_AFLAG_NO_AUTOCLOSE = 16777216, +}; + +struct drive_list_entry { + const char *id_model; + const char *id_firmware; +}; + +enum { + ide_unknown = 0, + ide_generic = 1, + ide_pci = 2, + ide_cmd640 = 3, + ide_dtc2278 = 4, + ide_ali14xx = 5, + ide_qd65xx = 6, + ide_umc8672 = 7, + ide_ht6560b = 8, + ide_4drives = 9, + ide_pmac = 10, + ide_acorn = 11, + ide_au1xxx = 12, + ide_palm3710 = 13, +}; + +struct ide_hw { + union { + struct ide_io_ports io_ports; + long unsigned int io_ports_array[10]; + }; + int irq; + struct device *dev; + struct device *parent; + long unsigned int config; +}; + +enum { + IDE_PFLAG_PROBING = 1, +}; + +struct ide_pci_enablebit { + u8 reg; + u8 mask; + u8 val; +}; + +struct ide_port_info { + char *name; + int (*init_chipset)(struct pci_dev *); + void (*get_lock)(irq_handler_t, void *); + void (*release_lock)(); + void (*init_iops)(ide_hwif_t *); + void (*init_hwif)(ide_hwif_t *); + int (*init_dma)(ide_hwif_t *, const struct ide_port_info *); + const struct ide_tp_ops *tp_ops; + const struct ide_port_ops *port_ops; + const struct ide_dma_ops *dma_ops; + struct ide_pci_enablebit enablebits[2]; + hwif_chipset_t chipset; + u16 max_sectors; + u32 host_flags; + int irq_flags; + u8 pio_mask; + u8 swdma_mask; + u8 mwdma_mask; + u8 udma_mask; +}; + +union ide_reg_valid_s { + unsigned int all: 16; + struct { + unsigned int data: 1; + unsigned int error_feature: 1; + unsigned int sector: 1; + unsigned int nsector: 1; + unsigned int lcyl: 1; + unsigned int hcyl: 1; + unsigned int select: 1; + unsigned int status_command: 1; + unsigned int data_hob: 1; + unsigned int error_feature_hob: 1; + unsigned int sector_hob: 1; + unsigned int nsector_hob: 1; + unsigned int lcyl_hob: 1; + unsigned int hcyl_hob: 1; + unsigned int select_hob: 1; + unsigned int control_hob: 1; + } b; +}; + +typedef union ide_reg_valid_s ide_reg_valid_t; + +struct ide_task_request_s { + __u8 io_ports[8]; + __u8 hob_ports[8]; + ide_reg_valid_t out_flags; + ide_reg_valid_t in_flags; + int data_phase; + int req_cmd; + long unsigned int out_size; + long unsigned int in_size; +}; + +typedef struct ide_task_request_s ide_task_request_t; + +struct ide_pio_info { + const char *name; + int pio; +}; + +struct ide_timing { + u8 mode; + u8 setup; + u16 act8b; + u16 rec8b; + u16 cyc8b; + u16 active; + u16 recover; + u16 cycle; + u16 udma; +}; + +enum { + IDE_TIMING_SETUP = 1, + IDE_TIMING_ACT8B = 2, + IDE_TIMING_REC8B = 4, + IDE_TIMING_CYC8B = 8, + IDE_TIMING_8BIT = 14, + IDE_TIMING_ACTIVE = 16, + IDE_TIMING_RECOVER = 32, + IDE_TIMING_CYCLE = 64, + IDE_TIMING_UDMA = 128, + IDE_TIMING_ALL = 255, +}; + +enum { + PC_FLAG_ABORT = 1, + PC_FLAG_SUPPRESS_ERROR = 2, + PC_FLAG_WAIT_FOR_DSC = 4, + PC_FLAG_DMA_OK = 8, + PC_FLAG_DMA_IN_PROGRESS = 16, + PC_FLAG_DMA_ERROR = 32, + PC_FLAG_WRITING = 64, +}; + +enum { + REQ_IDETAPE_PC1 = 1, + REQ_IDETAPE_PC2 = 2, + REQ_IDETAPE_READ = 4, + REQ_IDETAPE_WRITE = 8, +}; + +struct chipset_bus_clock_list_entry { + u8 xfer_speed; + u8 chipset_settings; + u8 ultra_settings; +}; + +enum { + AMD_IDE_CONFIG = 65, + AMD_CABLE_DETECT = 66, + AMD_DRIVE_TIMING = 72, + AMD_8BIT_TIMING = 78, + AMD_ADDRESS_SETUP = 76, + AMD_UDMA_TIMING = 80, +}; + +struct atiixp_ide_timing { + u8 command_width; + u8 recover_width; +}; + +enum ata_clock { + ATA_CLOCK_25MHZ = 0, + ATA_CLOCK_33MHZ = 1, + ATA_CLOCK_40MHZ = 2, + ATA_CLOCK_50MHZ = 3, + ATA_CLOCK_66MHZ = 4, + NUM_ATA_CLOCKS = 5, +}; + +struct hpt_timings { + u32 pio_mask; + u32 dma_mask; + u32 ultra_mask; + u32 *clock_table[5]; +}; + +struct hpt_info { + char *chip_name; + u8 chip_type; + u8 udma_mask; + u8 dpll_clk; + u8 pci_clk; + struct hpt_timings *timings; + u8 clock; +}; + +enum { + HPT36x = 0, + HPT370 = 1, + HPT370A = 2, + HPT374 = 3, + HPT372 = 4, + HPT372A = 5, + HPT302 = 6, + HPT371 = 7, + HPT372N = 8, + HPT302N = 9, + HPT371N = 10, +}; + +struct ide_info; + +struct it821x_dev { + unsigned int smart: 1; + unsigned int timing10: 1; + u8 clock_mode; + u8 want[4]; + u16 pio[2]; + u16 mwdma[2]; + u16 udma[2]; + u16 quirks; +}; + +typedef enum { + PORT_PATA0 = 0, + PORT_PATA1 = 1, + PORT_SATA = 2, +} port_type; + +struct pio_timing { + u8 reg0c; + u8 reg0d; + u8 reg13; +}; + +struct mwdma_timing { + u8 reg0e; + u8 reg0f; +}; + +struct udma_timing { + u8 reg10; + u8 reg11; + u8 reg12; +}; + +struct ich_laptop { + u16 device; + u16 subvendor; + u16 subdevice; +}; + +struct sis_laptop { + u16 device; + u16 subvendor; + u16 subdevice; +}; + +enum { + VIA_IDFLAG_SINGLE = 2, +}; + +struct via_isa_bridge { + char *name; + u16 id; + u8 rev_min; + u8 rev_max; + u8 udma_mask; + u8 flags; +}; + +struct via82cxxx_dev { + struct via_isa_bridge *via_config; + unsigned int via_80w; +}; + +struct ide_disk_obj { + ide_drive_t *drive; + struct ide_driver *driver; + struct gendisk *disk; + struct device dev; + unsigned int openers; + struct ide_atapi_pc queued_pc; + u8 sense_key; + u8 asc; + u8 ascq; + int progress_indication; + int blocks; + int block_size; + int bs_factor; + u8 cap_desc[8]; + u8 flexible_disk_page[32]; +}; + +typedef __u64 blist_flags_t; + +enum scsi_device_state { + SDEV_CREATED = 1, + SDEV_RUNNING = 2, + SDEV_CANCEL = 3, + SDEV_DEL = 4, + SDEV_QUIESCE = 5, + SDEV_OFFLINE = 6, + SDEV_TRANSPORT_OFFLINE = 7, + SDEV_BLOCK = 8, + SDEV_CREATED_BLOCK = 9, +}; + +struct scsi_vpd { + struct callback_head rcu; + int len; + unsigned char data[0]; +}; + +struct Scsi_Host; + +struct scsi_target; + +struct scsi_device_handler; + +struct scsi_device { + struct Scsi_Host *host; + struct request_queue *request_queue; + struct list_head siblings; + struct list_head same_target_siblings; + atomic_t device_busy; + atomic_t device_blocked; + atomic_t restarts; + spinlock_t list_lock; + struct list_head starved_entry; + short unsigned int queue_depth; + short unsigned int max_queue_depth; + short unsigned int last_queue_full_depth; + short unsigned int last_queue_full_count; + long unsigned int last_queue_full_time; + long unsigned int queue_ramp_up_period; + long unsigned int last_queue_ramp_up; + unsigned int id; + unsigned int channel; + u64 lun; + unsigned int manufacturer; + unsigned int sector_size; + void *hostdata; + unsigned char type; + char scsi_level; + char inq_periph_qual; + struct mutex inquiry_mutex; + unsigned char inquiry_len; + unsigned char *inquiry; + const char *vendor; + const char *model; + const char *rev; + struct scsi_vpd *vpd_pg0; + struct scsi_vpd *vpd_pg83; + struct scsi_vpd *vpd_pg80; + struct scsi_vpd *vpd_pg89; + unsigned char current_tag; + struct scsi_target *sdev_target; + blist_flags_t sdev_bflags; + unsigned int eh_timeout; + unsigned int removable: 1; + unsigned int changed: 1; + unsigned int busy: 1; + unsigned int lockable: 1; + unsigned int locked: 1; + unsigned int borken: 1; + unsigned int disconnect: 1; + unsigned int soft_reset: 1; + unsigned int sdtr: 1; + unsigned int wdtr: 1; + unsigned int ppr: 1; + unsigned int tagged_supported: 1; + unsigned int simple_tags: 1; + unsigned int was_reset: 1; + unsigned int expecting_cc_ua: 1; + unsigned int use_10_for_rw: 1; + unsigned int use_10_for_ms: 1; + unsigned int set_dbd_for_ms: 1; + unsigned int no_report_opcodes: 1; + unsigned int no_write_same: 1; + unsigned int use_16_for_rw: 1; + unsigned int skip_ms_page_8: 1; + unsigned int skip_ms_page_3f: 1; + unsigned int skip_vpd_pages: 1; + unsigned int try_vpd_pages: 1; + unsigned int use_192_bytes_for_3f: 1; + unsigned int no_start_on_add: 1; + unsigned int allow_restart: 1; + unsigned int manage_start_stop: 1; + unsigned int start_stop_pwr_cond: 1; + unsigned int no_uld_attach: 1; + unsigned int select_no_atn: 1; + unsigned int fix_capacity: 1; + unsigned int guess_capacity: 1; + unsigned int retry_hwerror: 1; + unsigned int last_sector_bug: 1; + unsigned int no_read_disc_info: 1; + unsigned int no_read_capacity_16: 1; + unsigned int try_rc_10_first: 1; + unsigned int security_supported: 1; + unsigned int is_visible: 1; + unsigned int wce_default_on: 1; + unsigned int no_dif: 1; + unsigned int broken_fua: 1; + unsigned int lun_in_cdb: 1; + unsigned int unmap_limit_for_ws: 1; + unsigned int rpm_autosuspend: 1; + bool offline_already; + atomic_t disk_events_disable_depth; + long unsigned int supported_events[1]; + long unsigned int pending_events[1]; + struct list_head event_list; + struct work_struct event_work; + unsigned int max_device_blocked; + atomic_t iorequest_cnt; + atomic_t iodone_cnt; + atomic_t ioerr_cnt; + struct device sdev_gendev; + struct device sdev_dev; + struct execute_work ew; + struct work_struct requeue_work; + struct scsi_device_handler *handler; + void *handler_data; + size_t dma_drain_len; + void *dma_drain_buf; + unsigned char access_state; + struct mutex state_mutex; + enum scsi_device_state sdev_state; + struct task_struct *quiesced_by; + long unsigned int sdev_data[0]; +}; + +enum scsi_host_state { + SHOST_CREATED = 1, + SHOST_RUNNING = 2, + SHOST_CANCEL = 3, + SHOST_DEL = 4, + SHOST_RECOVERY = 5, + SHOST_CANCEL_RECOVERY = 6, + SHOST_DEL_RECOVERY = 7, +}; + +struct scsi_host_template; + +struct scsi_transport_template; + +struct Scsi_Host { + struct list_head __devices; + struct list_head __targets; + struct list_head starved_list; + spinlock_t default_lock; + spinlock_t *host_lock; + struct mutex scan_mutex; + struct list_head eh_cmd_q; + struct task_struct *ehandler; + struct completion *eh_action; + wait_queue_head_t host_wait; + struct scsi_host_template *hostt; + struct scsi_transport_template *transportt; + struct blk_mq_tag_set tag_set; + atomic_t host_blocked; + unsigned int host_failed; + unsigned int host_eh_scheduled; + unsigned int host_no; + int eh_deadline; + long unsigned int last_reset; + unsigned int max_channel; + unsigned int max_id; + u64 max_lun; + unsigned int unique_id; + short unsigned int max_cmd_len; + int this_id; + int can_queue; + short int cmd_per_lun; + short unsigned int sg_tablesize; + short unsigned int sg_prot_tablesize; + unsigned int max_sectors; + unsigned int max_segment_size; + long unsigned int dma_boundary; + long unsigned int virt_boundary_mask; + unsigned int nr_hw_queues; + unsigned int active_mode: 2; + unsigned int unchecked_isa_dma: 1; + unsigned int host_self_blocked: 1; + unsigned int reverse_ordering: 1; + unsigned int tmf_in_progress: 1; + unsigned int async_scan: 1; + unsigned int eh_noresume: 1; + unsigned int no_write_same: 1; + unsigned int host_tagset: 1; + unsigned int short_inquiry: 1; + unsigned int no_scsi2_lun_in_cdb: 1; + char work_q_name[20]; + struct workqueue_struct *work_q; + struct workqueue_struct *tmf_work_q; + unsigned int max_host_blocked; + unsigned int prot_capabilities; + unsigned char prot_guard_type; + long unsigned int base; + long unsigned int io_port; + unsigned char n_io_port; + unsigned char dma_channel; + unsigned int irq; + enum scsi_host_state shost_state; + struct device shost_gendev; + struct device shost_dev; + void *shost_data; + struct device *dma_dev; + long unsigned int hostdata[0]; +}; + +enum scsi_target_state { + STARGET_CREATED = 1, + STARGET_RUNNING = 2, + STARGET_REMOVE = 3, + STARGET_CREATED_REMOVE = 4, + STARGET_DEL = 5, +}; + +struct scsi_target { + struct scsi_device *starget_sdev_user; + struct list_head siblings; + struct list_head devices; + struct device dev; + struct kref reap_ref; + unsigned int channel; + unsigned int id; + unsigned int create: 1; + unsigned int single_lun: 1; + unsigned int pdt_1f_for_no_lun: 1; + unsigned int no_report_luns: 1; + unsigned int expecting_lun_change: 1; + atomic_t target_busy; + atomic_t target_blocked; + unsigned int can_queue; + unsigned int max_target_blocked; + char scsi_level; + enum scsi_target_state state; + void *hostdata; + long unsigned int starget_data[0]; +}; + +struct scsi_data_buffer { + struct sg_table table; + unsigned int length; +}; + +struct scsi_pointer { + char *ptr; + int this_residual; + struct scatterlist *buffer; + int buffers_residual; + dma_addr_t dma_handle; + volatile int Status; + volatile int Message; + volatile int have_data_in; + volatile int sent_command; + volatile int phase; +}; + +struct scsi_cmnd { + struct scsi_request req; + struct scsi_device *device; + struct list_head eh_entry; + struct delayed_work abort_work; + struct callback_head rcu; + int eh_eflags; + long unsigned int jiffies_at_alloc; + int retries; + int allowed; + unsigned char prot_op; + unsigned char prot_type; + unsigned char prot_flags; + short unsigned int cmd_len; + enum dma_data_direction sc_data_direction; + unsigned char *cmnd; + struct scsi_data_buffer sdb; + struct scsi_data_buffer *prot_sdb; + unsigned int underflow; + unsigned int transfersize; + struct request *request; + unsigned char *sense_buffer; + void (*scsi_done)(struct scsi_cmnd *); + struct scsi_pointer SCp; + unsigned char *host_scribble; + int result; + int flags; + long unsigned int state; + unsigned char tag; + unsigned int extra_len; +}; + +enum scsi_prot_operations { + SCSI_PROT_NORMAL = 0, + SCSI_PROT_READ_INSERT = 1, + SCSI_PROT_WRITE_STRIP = 2, + SCSI_PROT_READ_STRIP = 3, + SCSI_PROT_WRITE_INSERT = 4, + SCSI_PROT_READ_PASS = 5, + SCSI_PROT_WRITE_PASS = 6, +}; + +struct scsi_driver { + struct device_driver gendrv; + void (*rescan)(struct device *); + blk_status_t (*init_command)(struct scsi_cmnd *); + void (*uninit_command)(struct scsi_cmnd *); + int (*done)(struct scsi_cmnd *); + int (*eh_action)(struct scsi_cmnd *, int); + void (*eh_reset)(struct scsi_cmnd *); +}; + +struct scsi_host_cmd_pool; + +struct scsi_host_template { + struct module *module; + const char *name; + const char * (*info)(struct Scsi_Host *); + int (*ioctl)(struct scsi_device *, unsigned int, void *); + int (*compat_ioctl)(struct scsi_device *, unsigned int, void *); + int (*init_cmd_priv)(struct Scsi_Host *, struct scsi_cmnd *); + int (*exit_cmd_priv)(struct Scsi_Host *, struct scsi_cmnd *); + int (*queuecommand)(struct Scsi_Host *, struct scsi_cmnd *); + void (*commit_rqs)(struct Scsi_Host *, u16); + int (*eh_abort_handler)(struct scsi_cmnd *); + int (*eh_device_reset_handler)(struct scsi_cmnd *); + int (*eh_target_reset_handler)(struct scsi_cmnd *); + int (*eh_bus_reset_handler)(struct scsi_cmnd *); + int (*eh_host_reset_handler)(struct scsi_cmnd *); + int (*slave_alloc)(struct scsi_device *); + int (*slave_configure)(struct scsi_device *); + void (*slave_destroy)(struct scsi_device *); + int (*target_alloc)(struct scsi_target *); + void (*target_destroy)(struct scsi_target *); + int (*scan_finished)(struct Scsi_Host *, long unsigned int); + void (*scan_start)(struct Scsi_Host *); + int (*change_queue_depth)(struct scsi_device *, int); + int (*map_queues)(struct Scsi_Host *); + bool (*dma_need_drain)(struct request *); + int (*bios_param)(struct scsi_device *, struct block_device *, sector_t, int *); + void (*unlock_native_capacity)(struct scsi_device *); + int (*show_info)(struct seq_file *, struct Scsi_Host *); + int (*write_info)(struct Scsi_Host *, char *, int); + enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *); + int (*host_reset)(struct Scsi_Host *, int); + const char *proc_name; + struct proc_dir_entry *proc_dir; + int can_queue; + int this_id; + short unsigned int sg_tablesize; + short unsigned int sg_prot_tablesize; + unsigned int max_sectors; + unsigned int max_segment_size; + long unsigned int dma_boundary; + long unsigned int virt_boundary_mask; + short int cmd_per_lun; + unsigned char present; + int tag_alloc_policy; + unsigned int track_queue_depth: 1; + unsigned int supported_mode: 2; + unsigned int unchecked_isa_dma: 1; + unsigned int emulated: 1; + unsigned int skip_settle_delay: 1; + unsigned int no_write_same: 1; + unsigned int host_tagset: 1; + unsigned int max_host_blocked; + struct device_attribute **shost_attrs; + struct device_attribute **sdev_attrs; + const struct attribute_group **sdev_groups; + u64 vendor_id; + unsigned int cmd_size; + struct scsi_host_cmd_pool *cmd_pool; + int rpm_autosuspend_delay; +}; + +struct trace_event_raw_scsi_dispatch_cmd_start { + struct trace_entry ent; + unsigned int host_no; + unsigned int channel; + unsigned int id; + unsigned int lun; + unsigned int opcode; + unsigned int cmd_len; + unsigned int data_sglen; + unsigned int prot_sglen; + unsigned char prot_op; + u32 __data_loc_cmnd; + char __data[0]; +}; + +struct trace_event_raw_scsi_dispatch_cmd_error { + struct trace_entry ent; + unsigned int host_no; + unsigned int channel; + unsigned int id; + unsigned int lun; + int rtn; + unsigned int opcode; + unsigned int cmd_len; + unsigned int data_sglen; + unsigned int prot_sglen; + unsigned char prot_op; + u32 __data_loc_cmnd; + char __data[0]; +}; + +struct trace_event_raw_scsi_cmd_done_timeout_template { + struct trace_entry ent; + unsigned int host_no; + unsigned int channel; + unsigned int id; + unsigned int lun; + int result; + unsigned int opcode; + unsigned int cmd_len; + unsigned int data_sglen; + unsigned int prot_sglen; + unsigned char prot_op; + u32 __data_loc_cmnd; + char __data[0]; +}; + +struct trace_event_raw_scsi_eh_wakeup { + struct trace_entry ent; + unsigned int host_no; + char __data[0]; +}; + +struct trace_event_data_offsets_scsi_dispatch_cmd_start { + u32 cmnd; +}; + +struct trace_event_data_offsets_scsi_dispatch_cmd_error { + u32 cmnd; +}; + +struct trace_event_data_offsets_scsi_cmd_done_timeout_template { + u32 cmnd; +}; + +struct trace_event_data_offsets_scsi_eh_wakeup {}; + +typedef void (*btf_trace_scsi_dispatch_cmd_start)(void *, struct scsi_cmnd *); + +typedef void (*btf_trace_scsi_dispatch_cmd_error)(void *, struct scsi_cmnd *, int); + +typedef void (*btf_trace_scsi_dispatch_cmd_done)(void *, struct scsi_cmnd *); + +typedef void (*btf_trace_scsi_dispatch_cmd_timeout)(void *, struct scsi_cmnd *); + +typedef void (*btf_trace_scsi_eh_wakeup)(void *, struct Scsi_Host *); + +struct scsi_transport_template { + struct transport_container host_attrs; + struct transport_container target_attrs; + struct transport_container device_attrs; + int (*user_scan)(struct Scsi_Host *, uint, uint, u64); + int device_size; + int device_private_offset; + int target_size; + int target_private_offset; + int host_size; + unsigned int create_work_queue: 1; + void (*eh_strategy_handler)(struct Scsi_Host *); +}; + +struct scsi_host_busy_iter_data { + bool (*fn)(struct scsi_cmnd *, void *, bool); + void *priv; +}; + +struct scsi_idlun { + __u32 dev_id; + __u32 host_unique_id; +}; + +typedef void (*activate_complete)(void *, int); + +struct scsi_device_handler { + struct list_head list; + struct module *module; + const char *name; + int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *); + int (*attach)(struct scsi_device *); + void (*detach)(struct scsi_device *); + int (*activate)(struct scsi_device *, activate_complete, void *); + blk_status_t (*prep_fn)(struct scsi_device *, struct request *); + int (*set_params)(struct scsi_device *, const char *); + void (*rescan)(struct scsi_device *); +}; + +struct scsi_eh_save { + int result; + unsigned int resid_len; + int eh_eflags; + enum dma_data_direction data_direction; + unsigned int underflow; + unsigned char cmd_len; + unsigned char prot_op; + unsigned char *cmnd; + struct scsi_data_buffer sdb; + unsigned char eh_cmnd[16]; + struct scatterlist sense_sgl; +}; + +struct scsi_varlen_cdb_hdr { + __u8 opcode; + __u8 control; + __u8 misc[5]; + __u8 additional_cdb_length; + __be16 service_action; +}; + +struct scsi_mode_data { + __u32 length; + __u16 block_descriptor_length; + __u8 medium_type; + __u8 device_specific; + __u8 header_length; + __u8 longlba: 1; +}; + +struct scsi_event { + enum scsi_device_event evt_type; + struct list_head node; +}; + +enum scsi_host_prot_capabilities { + SHOST_DIF_TYPE1_PROTECTION = 1, + SHOST_DIF_TYPE2_PROTECTION = 2, + SHOST_DIF_TYPE3_PROTECTION = 4, + SHOST_DIX_TYPE0_PROTECTION = 8, + SHOST_DIX_TYPE1_PROTECTION = 16, + SHOST_DIX_TYPE2_PROTECTION = 32, + SHOST_DIX_TYPE3_PROTECTION = 64, +}; + +enum { + ACTION_FAIL = 0, + ACTION_REPREP = 1, + ACTION_RETRY = 2, + ACTION_DELAYED_RETRY = 3, +}; + +struct value_name_pair; + +struct sa_name_list { + int opcode; + const struct value_name_pair *arr; + int arr_sz; +}; + +struct value_name_pair { + int value; + const char *name; +}; + +struct error_info { + short unsigned int code12; + short unsigned int size; +}; + +struct error_info2 { + unsigned char code1; + unsigned char code2_min; + unsigned char code2_max; + const char *str; + const char *fmt; +}; + +struct scsi_lun { + __u8 scsi_lun[8]; +}; + +enum scsi_timeouts { + SCSI_DEFAULT_EH_TIMEOUT = 10000, +}; + +enum scsi_scan_mode { + SCSI_SCAN_INITIAL = 0, + SCSI_SCAN_RESCAN = 1, + SCSI_SCAN_MANUAL = 2, +}; + +struct async_scan_data { + struct list_head list; + struct Scsi_Host *shost; + struct completion prev_finished; +}; + +enum scsi_devinfo_key { + SCSI_DEVINFO_GLOBAL = 0, + SCSI_DEVINFO_SPI = 1, +}; + +struct scsi_dev_info_list { + struct list_head dev_info_list; + char vendor[8]; + char model[16]; + blist_flags_t flags; + unsigned int compatible; +}; + +struct scsi_dev_info_list_table { + struct list_head node; + struct list_head scsi_dev_info_list; + const char *name; + int key; +}; + +struct double_list { + struct list_head *top; + struct list_head *bottom; +}; + +struct scsi_nl_hdr { + __u8 version; + __u8 transport; + __u16 magic; + __u16 msgtype; + __u16 msglen; +}; + +struct spi_transport_attrs { + int period; + int min_period; + int offset; + int max_offset; + unsigned int width: 1; + unsigned int max_width: 1; + unsigned int iu: 1; + unsigned int max_iu: 1; + unsigned int dt: 1; + unsigned int qas: 1; + unsigned int max_qas: 1; + unsigned int wr_flow: 1; + unsigned int rd_strm: 1; + unsigned int rti: 1; + unsigned int pcomp_en: 1; + unsigned int hold_mcs: 1; + unsigned int initial_dv: 1; + long unsigned int flags; + unsigned int support_sync: 1; + unsigned int support_wide: 1; + unsigned int support_dt: 1; + unsigned int support_dt_only; + unsigned int support_ius; + unsigned int support_qas; + unsigned int dv_pending: 1; + unsigned int dv_in_progress: 1; + struct mutex dv_mutex; +}; + +enum spi_signal_type { + SPI_SIGNAL_UNKNOWN = 1, + SPI_SIGNAL_SE = 2, + SPI_SIGNAL_LVD = 3, + SPI_SIGNAL_HVD = 4, +}; + +struct spi_host_attrs { + enum spi_signal_type signalling; +}; + +struct spi_function_template { + void (*get_period)(struct scsi_target *); + void (*set_period)(struct scsi_target *, int); + void (*get_offset)(struct scsi_target *); + void (*set_offset)(struct scsi_target *, int); + void (*get_width)(struct scsi_target *); + void (*set_width)(struct scsi_target *, int); + void (*get_iu)(struct scsi_target *); + void (*set_iu)(struct scsi_target *, int); + void (*get_dt)(struct scsi_target *); + void (*set_dt)(struct scsi_target *, int); + void (*get_qas)(struct scsi_target *); + void (*set_qas)(struct scsi_target *, int); + void (*get_wr_flow)(struct scsi_target *); + void (*set_wr_flow)(struct scsi_target *, int); + void (*get_rd_strm)(struct scsi_target *); + void (*set_rd_strm)(struct scsi_target *, int); + void (*get_rti)(struct scsi_target *); + void (*set_rti)(struct scsi_target *, int); + void (*get_pcomp_en)(struct scsi_target *); + void (*set_pcomp_en)(struct scsi_target *, int); + void (*get_hold_mcs)(struct scsi_target *); + void (*set_hold_mcs)(struct scsi_target *, int); + void (*get_signalling)(struct Scsi_Host *); + void (*set_signalling)(struct Scsi_Host *, enum spi_signal_type); + int (*deny_binding)(struct scsi_target *); + long unsigned int show_period: 1; + long unsigned int show_offset: 1; + long unsigned int show_width: 1; + long unsigned int show_iu: 1; + long unsigned int show_dt: 1; + long unsigned int show_qas: 1; + long unsigned int show_wr_flow: 1; + long unsigned int show_rd_strm: 1; + long unsigned int show_rti: 1; + long unsigned int show_pcomp_en: 1; + long unsigned int show_hold_mcs: 1; +}; + +enum { + SPI_BLIST_NOIUS = 1, +}; + +struct spi_internal { + struct scsi_transport_template t; + struct spi_function_template *f; +}; + +enum spi_compare_returns { + SPI_COMPARE_SUCCESS = 0, + SPI_COMPARE_FAILURE = 1, + SPI_COMPARE_SKIP_TEST = 2, +}; + +struct work_queue_wrapper { + struct work_struct work; + struct scsi_device *sdev; +}; + +enum fc_port_type { + FC_PORTTYPE_UNKNOWN = 0, + FC_PORTTYPE_OTHER = 1, + FC_PORTTYPE_NOTPRESENT = 2, + FC_PORTTYPE_NPORT = 3, + FC_PORTTYPE_NLPORT = 4, + FC_PORTTYPE_LPORT = 5, + FC_PORTTYPE_PTP = 6, + FC_PORTTYPE_NPIV = 7, +}; + +enum fc_port_state { + FC_PORTSTATE_UNKNOWN = 0, + FC_PORTSTATE_NOTPRESENT = 1, + FC_PORTSTATE_ONLINE = 2, + FC_PORTSTATE_OFFLINE = 3, + FC_PORTSTATE_BLOCKED = 4, + FC_PORTSTATE_BYPASSED = 5, + FC_PORTSTATE_DIAGNOSTICS = 6, + FC_PORTSTATE_LINKDOWN = 7, + FC_PORTSTATE_ERROR = 8, + FC_PORTSTATE_LOOPBACK = 9, + FC_PORTSTATE_DELETED = 10, +}; + +enum fc_vport_state { + FC_VPORT_UNKNOWN = 0, + FC_VPORT_ACTIVE = 1, + FC_VPORT_DISABLED = 2, + FC_VPORT_LINKDOWN = 3, + FC_VPORT_INITIALIZING = 4, + FC_VPORT_NO_FABRIC_SUPP = 5, + FC_VPORT_NO_FABRIC_RSCS = 6, + FC_VPORT_FABRIC_LOGOUT = 7, + FC_VPORT_FABRIC_REJ_WWN = 8, + FC_VPORT_FAILED = 9, +}; + +enum fc_tgtid_binding_type { + FC_TGTID_BIND_NONE = 0, + FC_TGTID_BIND_BY_WWPN = 1, + FC_TGTID_BIND_BY_WWNN = 2, + FC_TGTID_BIND_BY_ID = 3, +}; + +struct fc_vport_identifiers { + u64 node_name; + u64 port_name; + u32 roles; + bool disable; + enum fc_port_type vport_type; + char symbolic_name[64]; +}; + +struct fc_vport { + enum fc_vport_state vport_state; + enum fc_vport_state vport_last_state; + u64 node_name; + u64 port_name; + u32 roles; + u32 vport_id; + enum fc_port_type vport_type; + char symbolic_name[64]; + void *dd_data; + struct Scsi_Host *shost; + unsigned int channel; + u32 number; + u8 flags; + struct list_head peers; + struct device dev; + struct work_struct vport_delete_work; +}; + +struct fc_rport_identifiers { + u64 node_name; + u64 port_name; + u32 port_id; + u32 roles; +}; + +struct fc_rport { + u32 maxframe_size; + u32 supported_classes; + u32 dev_loss_tmo; + u64 node_name; + u64 port_name; + u32 port_id; + u32 roles; + enum fc_port_state port_state; + u32 scsi_target_id; + u32 fast_io_fail_tmo; + void *dd_data; + unsigned int channel; + u32 number; + u8 flags; + struct list_head peers; + struct device dev; + struct delayed_work dev_loss_work; + struct work_struct scan_work; + struct delayed_work fail_io_work; + struct work_struct stgt_delete_work; + struct work_struct rport_delete_work; + struct request_queue *rqst_q; +}; + +struct fc_starget_attrs { + u64 node_name; + u64 port_name; + u32 port_id; +}; + +struct fc_host_statistics { + u64 seconds_since_last_reset; + u64 tx_frames; + u64 tx_words; + u64 rx_frames; + u64 rx_words; + u64 lip_count; + u64 nos_count; + u64 error_frames; + u64 dumped_frames; + u64 link_failure_count; + u64 loss_of_sync_count; + u64 loss_of_signal_count; + u64 prim_seq_protocol_err_count; + u64 invalid_tx_word_count; + u64 invalid_crc_count; + u64 fcp_input_requests; + u64 fcp_output_requests; + u64 fcp_control_requests; + u64 fcp_input_megabytes; + u64 fcp_output_megabytes; + u64 fcp_packet_alloc_failures; + u64 fcp_packet_aborts; + u64 fcp_frame_alloc_failures; + u64 fc_no_free_exch; + u64 fc_no_free_exch_xid; + u64 fc_xid_not_found; + u64 fc_xid_busy; + u64 fc_seq_not_found; + u64 fc_non_bls_resp; +}; + +enum fc_host_event_code { + FCH_EVT_LIP = 1, + FCH_EVT_LINKUP = 2, + FCH_EVT_LINKDOWN = 3, + FCH_EVT_LIPRESET = 4, + FCH_EVT_RSCN = 5, + FCH_EVT_ADAPTER_CHANGE = 259, + FCH_EVT_PORT_UNKNOWN = 512, + FCH_EVT_PORT_OFFLINE = 513, + FCH_EVT_PORT_ONLINE = 514, + FCH_EVT_PORT_FABRIC = 516, + FCH_EVT_LINK_UNKNOWN = 1280, + FCH_EVT_LINK_FPIN = 1281, + FCH_EVT_VENDOR_UNIQUE = 65535, +}; + +struct fc_host_attrs { + u64 node_name; + u64 port_name; + u64 permanent_port_name; + u32 supported_classes; + u8 supported_fc4s[32]; + u32 supported_speeds; + u32 maxframe_size; + u16 max_npiv_vports; + char serial_number[80]; + char manufacturer[80]; + char model[256]; + char model_description[256]; + char hardware_version[64]; + char driver_version[64]; + char firmware_version[64]; + char optionrom_version[64]; + u32 port_id; + enum fc_port_type port_type; + enum fc_port_state port_state; + u8 active_fc4s[32]; + u32 speed; + u64 fabric_name; + char symbolic_name[256]; + char system_hostname[256]; + u32 dev_loss_tmo; + enum fc_tgtid_binding_type tgtid_bind_type; + struct list_head rports; + struct list_head rport_bindings; + struct list_head vports; + u32 next_rport_number; + u32 next_target_id; + u32 next_vport_number; + u16 npiv_vports_inuse; + char work_q_name[20]; + struct workqueue_struct *work_q; + char devloss_work_q_name[20]; + struct workqueue_struct *devloss_work_q; + struct request_queue *rqst_q; +}; + +struct fc_function_template { + void (*get_rport_dev_loss_tmo)(struct fc_rport *); + void (*set_rport_dev_loss_tmo)(struct fc_rport *, u32); + void (*get_starget_node_name)(struct scsi_target *); + void (*get_starget_port_name)(struct scsi_target *); + void (*get_starget_port_id)(struct scsi_target *); + void (*get_host_port_id)(struct Scsi_Host *); + void (*get_host_port_type)(struct Scsi_Host *); + void (*get_host_port_state)(struct Scsi_Host *); + void (*get_host_active_fc4s)(struct Scsi_Host *); + void (*get_host_speed)(struct Scsi_Host *); + void (*get_host_fabric_name)(struct Scsi_Host *); + void (*get_host_symbolic_name)(struct Scsi_Host *); + void (*set_host_system_hostname)(struct Scsi_Host *); + struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *); + void (*reset_fc_host_stats)(struct Scsi_Host *); + int (*issue_fc_host_lip)(struct Scsi_Host *); + void (*dev_loss_tmo_callbk)(struct fc_rport *); + void (*terminate_rport_io)(struct fc_rport *); + void (*set_vport_symbolic_name)(struct fc_vport *); + int (*vport_create)(struct fc_vport *, bool); + int (*vport_disable)(struct fc_vport *, bool); + int (*vport_delete)(struct fc_vport *); + int (*bsg_request)(struct bsg_job *); + int (*bsg_timeout)(struct bsg_job *); + u32 dd_fcrport_size; + u32 dd_fcvport_size; + u32 dd_bsg_size; + long unsigned int show_rport_maxframe_size: 1; + long unsigned int show_rport_supported_classes: 1; + long unsigned int show_rport_dev_loss_tmo: 1; + long unsigned int show_starget_node_name: 1; + long unsigned int show_starget_port_name: 1; + long unsigned int show_starget_port_id: 1; + long unsigned int show_host_node_name: 1; + long unsigned int show_host_port_name: 1; + long unsigned int show_host_permanent_port_name: 1; + long unsigned int show_host_supported_classes: 1; + long unsigned int show_host_supported_fc4s: 1; + long unsigned int show_host_supported_speeds: 1; + long unsigned int show_host_maxframe_size: 1; + long unsigned int show_host_serial_number: 1; + long unsigned int show_host_manufacturer: 1; + long unsigned int show_host_model: 1; + long unsigned int show_host_model_description: 1; + long unsigned int show_host_hardware_version: 1; + long unsigned int show_host_driver_version: 1; + long unsigned int show_host_firmware_version: 1; + long unsigned int show_host_optionrom_version: 1; + long unsigned int show_host_port_id: 1; + long unsigned int show_host_port_type: 1; + long unsigned int show_host_port_state: 1; + long unsigned int show_host_active_fc4s: 1; + long unsigned int show_host_speed: 1; + long unsigned int show_host_fabric_name: 1; + long unsigned int show_host_symbolic_name: 1; + long unsigned int show_host_system_hostname: 1; + long unsigned int disable_target_scan: 1; +}; + +struct fc_nl_event { + struct scsi_nl_hdr snlh; + __u64 seconds; + __u64 vendor_id; + __u16 host_no; + __u16 event_datalen; + __u32 event_num; + __u32 event_code; + __u32 event_data; +}; + +struct fc_bsg_host_add_rport { + __u8 reserved; + __u8 port_id[3]; +}; + +struct fc_bsg_host_del_rport { + __u8 reserved; + __u8 port_id[3]; +}; + +struct fc_bsg_host_els { + __u8 command_code; + __u8 port_id[3]; +}; + +struct fc_bsg_ctels_reply { + __u32 status; + struct { + __u8 action; + __u8 reason_code; + __u8 reason_explanation; + __u8 vendor_unique; + } rjt_data; +}; + +struct fc_bsg_host_ct { + __u8 reserved; + __u8 port_id[3]; + __u32 preamble_word0; + __u32 preamble_word1; + __u32 preamble_word2; +}; + +struct fc_bsg_host_vendor { + __u64 vendor_id; + __u32 vendor_cmd[0]; +}; + +struct fc_bsg_host_vendor_reply { + __u32 vendor_rsp[0]; +}; + +struct fc_bsg_rport_els { + __u8 els_code; +}; + +struct fc_bsg_rport_ct { + __u32 preamble_word0; + __u32 preamble_word1; + __u32 preamble_word2; +}; + +struct fc_bsg_request { + __u32 msgcode; + union { + struct fc_bsg_host_add_rport h_addrport; + struct fc_bsg_host_del_rport h_delrport; + struct fc_bsg_host_els h_els; + struct fc_bsg_host_ct h_ct; + struct fc_bsg_host_vendor h_vendor; + struct fc_bsg_rport_els r_els; + struct fc_bsg_rport_ct r_ct; + } rqst_data; +} __attribute__((packed)); + +struct fc_bsg_reply { + __u32 result; + __u32 reply_payload_rcv_len; + union { + struct fc_bsg_host_vendor_reply vendor_reply; + struct fc_bsg_ctels_reply ctels_reply; + } reply_data; +}; + +struct fc_internal { + struct scsi_transport_template t; + struct fc_function_template *f; + struct device_attribute private_starget_attrs[3]; + struct device_attribute *starget_attrs[4]; + struct device_attribute private_host_attrs[29]; + struct device_attribute *host_attrs[30]; + struct transport_container rport_attr_cont; + struct device_attribute private_rport_attrs[10]; + struct device_attribute *rport_attrs[11]; + struct transport_container vport_attr_cont; + struct device_attribute private_vport_attrs[9]; + struct device_attribute *vport_attrs[10]; +}; + +enum sas_device_type { + SAS_PHY_UNUSED = 0, + SAS_END_DEVICE = 1, + SAS_EDGE_EXPANDER_DEVICE = 2, + SAS_FANOUT_EXPANDER_DEVICE = 3, + SAS_HA = 4, + SAS_SATA_DEV = 5, + SAS_SATA_PM = 7, + SAS_SATA_PM_PORT = 8, + SAS_SATA_PENDING = 9, +}; + +enum sas_protocol { + SAS_PROTOCOL_NONE = 0, + SAS_PROTOCOL_SATA = 1, + SAS_PROTOCOL_SMP = 2, + SAS_PROTOCOL_STP = 4, + SAS_PROTOCOL_SSP = 8, + SAS_PROTOCOL_ALL = 14, + SAS_PROTOCOL_STP_ALL = 5, +}; + +enum sas_linkrate { + SAS_LINK_RATE_UNKNOWN = 0, + SAS_PHY_DISABLED = 1, + SAS_PHY_RESET_PROBLEM = 2, + SAS_SATA_SPINUP_HOLD = 3, + SAS_SATA_PORT_SELECTOR = 4, + SAS_PHY_RESET_IN_PROGRESS = 5, + SAS_LINK_RATE_1_5_GBPS = 8, + SAS_LINK_RATE_G1 = 8, + SAS_LINK_RATE_3_0_GBPS = 9, + SAS_LINK_RATE_G2 = 9, + SAS_LINK_RATE_6_0_GBPS = 10, + SAS_LINK_RATE_12_0_GBPS = 11, + SAS_LINK_RATE_FAILED = 16, + SAS_PHY_VIRTUAL = 17, +}; + +struct sas_identify { + enum sas_device_type device_type; + enum sas_protocol initiator_port_protocols; + enum sas_protocol target_port_protocols; + u64 sas_address; + u8 phy_identifier; +}; + +struct sas_phy { + struct device dev; + int number; + int enabled; + struct sas_identify identify; + enum sas_linkrate negotiated_linkrate; + enum sas_linkrate minimum_linkrate_hw; + enum sas_linkrate minimum_linkrate; + enum sas_linkrate maximum_linkrate_hw; + enum sas_linkrate maximum_linkrate; + u32 invalid_dword_count; + u32 running_disparity_error_count; + u32 loss_of_dword_sync_count; + u32 phy_reset_problem_count; + struct list_head port_siblings; + void *hostdata; +}; + +struct sas_rphy { + struct device dev; + struct sas_identify identify; + struct list_head list; + struct request_queue *q; + u32 scsi_target_id; +}; + +struct sas_end_device { + struct sas_rphy rphy; + unsigned int ready_led_meaning: 1; + unsigned int tlr_supported: 1; + unsigned int tlr_enabled: 1; + u16 I_T_nexus_loss_timeout; + u16 initiator_response_timeout; +}; + +struct sas_expander_device { + int level; + int next_port_id; + char vendor_id[9]; + char product_id[17]; + char product_rev[5]; + char component_vendor_id[9]; + u16 component_id; + u8 component_revision_id; + struct sas_rphy rphy; +}; + +struct sas_port { + struct device dev; + int port_identifier; + int num_phys; + unsigned int is_backlink: 1; + struct sas_rphy *rphy; + struct mutex phy_list_mutex; + struct list_head phy_list; + struct list_head del_list; +}; + +struct sas_phy_linkrates { + enum sas_linkrate maximum_linkrate; + enum sas_linkrate minimum_linkrate; +}; + +struct sas_function_template { + int (*get_linkerrors)(struct sas_phy *); + int (*get_enclosure_identifier)(struct sas_rphy *, u64 *); + int (*get_bay_identifier)(struct sas_rphy *); + int (*phy_reset)(struct sas_phy *, int); + int (*phy_enable)(struct sas_phy *, int); + int (*phy_setup)(struct sas_phy *); + void (*phy_release)(struct sas_phy *); + int (*set_phy_speed)(struct sas_phy *, struct sas_phy_linkrates *); + void (*smp_handler)(struct bsg_job *, struct Scsi_Host *, struct sas_rphy *); +}; + +struct sas_domain_function_template; + +struct sas_internal { + struct scsi_transport_template t; + struct sas_function_template *f; + struct sas_domain_function_template *dft; + struct device_attribute private_host_attrs[0]; + struct device_attribute private_phy_attrs[17]; + struct device_attribute private_port_attrs[1]; + struct device_attribute private_rphy_attrs[8]; + struct device_attribute private_end_dev_attrs[5]; + struct device_attribute private_expander_attrs[7]; + struct transport_container phy_attr_cont; + struct transport_container port_attr_cont; + struct transport_container rphy_attr_cont; + struct transport_container end_dev_attr_cont; + struct transport_container expander_attr_cont; + struct device_attribute *host_attrs[1]; + struct device_attribute *phy_attrs[18]; + struct device_attribute *port_attrs[2]; + struct device_attribute *rphy_attrs[9]; + struct device_attribute *end_dev_attrs[6]; + struct device_attribute *expander_attrs[8]; +}; + +struct sas_host_attrs { + struct list_head rphy_list; + struct mutex lock; + struct request_queue *q; + u32 next_target_id; + u32 next_expander_id; + int next_port_id; +}; + +struct ata_bmdma_prd { + __le32 addr; + __le32 flags_len; +}; + +enum { + LIBATA_MAX_PRD = 128, + LIBATA_DUMB_MAX_PRD = 64, + ATA_DEF_QUEUE = 1, + ATA_MAX_QUEUE = 32, + ATA_TAG_INTERNAL = 32, + ATA_SHORT_PAUSE = 16, + ATAPI_MAX_DRAIN = 16384, + ATA_ALL_DEVICES = 3, + ATA_SHT_EMULATED = 1, + ATA_SHT_THIS_ID = 4294967295, + ATA_TFLAG_LBA48 = 1, + ATA_TFLAG_ISADDR = 2, + ATA_TFLAG_DEVICE = 4, + ATA_TFLAG_WRITE = 8, + ATA_TFLAG_LBA = 16, + ATA_TFLAG_FUA = 32, + ATA_TFLAG_POLLING = 64, + ATA_DFLAG_LBA = 1, + ATA_DFLAG_LBA48 = 2, + ATA_DFLAG_CDB_INTR = 4, + ATA_DFLAG_NCQ = 8, + ATA_DFLAG_FLUSH_EXT = 16, + ATA_DFLAG_ACPI_PENDING = 32, + ATA_DFLAG_ACPI_FAILED = 64, + ATA_DFLAG_AN = 128, + ATA_DFLAG_TRUSTED = 256, + ATA_DFLAG_DMADIR = 1024, + ATA_DFLAG_CFG_MASK = 4095, + ATA_DFLAG_PIO = 4096, + ATA_DFLAG_NCQ_OFF = 8192, + ATA_DFLAG_SLEEPING = 32768, + ATA_DFLAG_DUBIOUS_XFER = 65536, + ATA_DFLAG_NO_UNLOAD = 131072, + ATA_DFLAG_UNLOCK_HPA = 262144, + ATA_DFLAG_NCQ_SEND_RECV = 524288, + ATA_DFLAG_NCQ_PRIO = 1048576, + ATA_DFLAG_NCQ_PRIO_ENABLE = 2097152, + ATA_DFLAG_INIT_MASK = 16777215, + ATA_DFLAG_DETACH = 16777216, + ATA_DFLAG_DETACHED = 33554432, + ATA_DFLAG_DA = 67108864, + ATA_DFLAG_DEVSLP = 134217728, + ATA_DFLAG_ACPI_DISABLED = 268435456, + ATA_DFLAG_D_SENSE = 536870912, + ATA_DFLAG_ZAC = 1073741824, + ATA_DEV_UNKNOWN = 0, + ATA_DEV_ATA = 1, + ATA_DEV_ATA_UNSUP = 2, + ATA_DEV_ATAPI = 3, + ATA_DEV_ATAPI_UNSUP = 4, + ATA_DEV_PMP = 5, + ATA_DEV_PMP_UNSUP = 6, + ATA_DEV_SEMB = 7, + ATA_DEV_SEMB_UNSUP = 8, + ATA_DEV_ZAC = 9, + ATA_DEV_ZAC_UNSUP = 10, + ATA_DEV_NONE = 11, + ATA_LFLAG_NO_HRST = 2, + ATA_LFLAG_NO_SRST = 4, + ATA_LFLAG_ASSUME_ATA = 8, + ATA_LFLAG_ASSUME_SEMB = 16, + ATA_LFLAG_ASSUME_CLASS = 24, + ATA_LFLAG_NO_RETRY = 32, + ATA_LFLAG_DISABLED = 64, + ATA_LFLAG_SW_ACTIVITY = 128, + ATA_LFLAG_NO_LPM = 256, + ATA_LFLAG_RST_ONCE = 512, + ATA_LFLAG_CHANGED = 1024, + ATA_LFLAG_NO_DB_DELAY = 2048, + ATA_FLAG_SLAVE_POSS = 1, + ATA_FLAG_SATA = 2, + ATA_FLAG_NO_LPM = 4, + ATA_FLAG_NO_LOG_PAGE = 32, + ATA_FLAG_NO_ATAPI = 64, + ATA_FLAG_PIO_DMA = 128, + ATA_FLAG_PIO_LBA48 = 256, + ATA_FLAG_PIO_POLLING = 512, + ATA_FLAG_NCQ = 1024, + ATA_FLAG_NO_POWEROFF_SPINDOWN = 2048, + ATA_FLAG_NO_HIBERNATE_SPINDOWN = 4096, + ATA_FLAG_DEBUGMSG = 8192, + ATA_FLAG_FPDMA_AA = 16384, + ATA_FLAG_IGN_SIMPLEX = 32768, + ATA_FLAG_NO_IORDY = 65536, + ATA_FLAG_ACPI_SATA = 131072, + ATA_FLAG_AN = 262144, + ATA_FLAG_PMP = 524288, + ATA_FLAG_FPDMA_AUX = 1048576, + ATA_FLAG_EM = 2097152, + ATA_FLAG_SW_ACTIVITY = 4194304, + ATA_FLAG_NO_DIPM = 8388608, + ATA_FLAG_SAS_HOST = 16777216, + ATA_PFLAG_EH_PENDING = 1, + ATA_PFLAG_EH_IN_PROGRESS = 2, + ATA_PFLAG_FROZEN = 4, + ATA_PFLAG_RECOVERED = 8, + ATA_PFLAG_LOADING = 16, + ATA_PFLAG_SCSI_HOTPLUG = 64, + ATA_PFLAG_INITIALIZING = 128, + ATA_PFLAG_RESETTING = 256, + ATA_PFLAG_UNLOADING = 512, + ATA_PFLAG_UNLOADED = 1024, + ATA_PFLAG_SUSPENDED = 131072, + ATA_PFLAG_PM_PENDING = 262144, + ATA_PFLAG_INIT_GTM_VALID = 524288, + ATA_PFLAG_PIO32 = 1048576, + ATA_PFLAG_PIO32CHANGE = 2097152, + ATA_PFLAG_EXTERNAL = 4194304, + ATA_QCFLAG_ACTIVE = 1, + ATA_QCFLAG_DMAMAP = 2, + ATA_QCFLAG_IO = 8, + ATA_QCFLAG_RESULT_TF = 16, + ATA_QCFLAG_CLEAR_EXCL = 32, + ATA_QCFLAG_QUIET = 64, + ATA_QCFLAG_RETRY = 128, + ATA_QCFLAG_FAILED = 65536, + ATA_QCFLAG_SENSE_VALID = 131072, + ATA_QCFLAG_EH_SCHEDULED = 262144, + ATA_HOST_SIMPLEX = 1, + ATA_HOST_STARTED = 2, + ATA_HOST_PARALLEL_SCAN = 4, + ATA_HOST_IGNORE_ATA = 8, + ATA_TMOUT_BOOT = 30000, + ATA_TMOUT_BOOT_QUICK = 7000, + ATA_TMOUT_INTERNAL_QUICK = 5000, + ATA_TMOUT_MAX_PARK = 30000, + ATA_TMOUT_FF_WAIT_LONG = 2000, + ATA_TMOUT_FF_WAIT = 800, + ATA_WAIT_AFTER_RESET = 150, + ATA_TMOUT_PMP_SRST_WAIT = 5000, + ATA_TMOUT_SPURIOUS_PHY = 10000, + BUS_UNKNOWN = 0, + BUS_DMA = 1, + BUS_IDLE = 2, + BUS_NOINTR = 3, + BUS_NODATA = 4, + BUS_TIMER = 5, + BUS_PIO = 6, + BUS_EDD = 7, + BUS_IDENTIFY = 8, + BUS_PACKET = 9, + PORT_UNKNOWN = 0, + PORT_ENABLED = 1, + PORT_DISABLED = 2, + ATA_NR_PIO_MODES = 7, + ATA_NR_MWDMA_MODES = 5, + ATA_NR_UDMA_MODES = 8, + ATA_SHIFT_PIO = 0, + ATA_SHIFT_MWDMA = 7, + ATA_SHIFT_UDMA = 12, + ATA_SHIFT_PRIO = 6, + ATA_PRIO_HIGH = 2, + ATA_DMA_PAD_SZ = 4, + ATA_ERING_SIZE = 32, + ATA_DEFER_LINK = 1, + ATA_DEFER_PORT = 2, + ATA_EH_DESC_LEN = 80, + ATA_EH_REVALIDATE = 1, + ATA_EH_SOFTRESET = 2, + ATA_EH_HARDRESET = 4, + ATA_EH_RESET = 6, + ATA_EH_ENABLE_LINK = 8, + ATA_EH_PARK = 32, + ATA_EH_PERDEV_MASK = 33, + ATA_EH_ALL_ACTIONS = 15, + ATA_EHI_HOTPLUGGED = 1, + ATA_EHI_NO_AUTOPSY = 4, + ATA_EHI_QUIET = 8, + ATA_EHI_NO_RECOVERY = 16, + ATA_EHI_DID_SOFTRESET = 65536, + ATA_EHI_DID_HARDRESET = 131072, + ATA_EHI_PRINTINFO = 262144, + ATA_EHI_SETMODE = 524288, + ATA_EHI_POST_SETMODE = 1048576, + ATA_EHI_DID_RESET = 196608, + ATA_EHI_TO_SLAVE_MASK = 12, + ATA_EH_MAX_TRIES = 5, + ATA_LINK_RESUME_TRIES = 5, + ATA_PROBE_MAX_TRIES = 3, + ATA_EH_DEV_TRIES = 3, + ATA_EH_PMP_TRIES = 5, + ATA_EH_PMP_LINK_TRIES = 3, + SATA_PMP_RW_TIMEOUT = 3000, + ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 6, + ATA_HORKAGE_DIAGNOSTIC = 1, + ATA_HORKAGE_NODMA = 2, + ATA_HORKAGE_NONCQ = 4, + ATA_HORKAGE_MAX_SEC_128 = 8, + ATA_HORKAGE_BROKEN_HPA = 16, + ATA_HORKAGE_DISABLE = 32, + ATA_HORKAGE_HPA_SIZE = 64, + ATA_HORKAGE_IVB = 256, + ATA_HORKAGE_STUCK_ERR = 512, + ATA_HORKAGE_BRIDGE_OK = 1024, + ATA_HORKAGE_ATAPI_MOD16_DMA = 2048, + ATA_HORKAGE_FIRMWARE_WARN = 4096, + ATA_HORKAGE_1_5_GBPS = 8192, + ATA_HORKAGE_NOSETXFER = 16384, + ATA_HORKAGE_BROKEN_FPDMA_AA = 32768, + ATA_HORKAGE_DUMP_ID = 65536, + ATA_HORKAGE_MAX_SEC_LBA48 = 131072, + ATA_HORKAGE_ATAPI_DMADIR = 262144, + ATA_HORKAGE_NO_NCQ_TRIM = 524288, + ATA_HORKAGE_NOLPM = 1048576, + ATA_HORKAGE_WD_BROKEN_LPM = 2097152, + ATA_HORKAGE_ZERO_AFTER_TRIM = 4194304, + ATA_HORKAGE_NO_DMA_LOG = 8388608, + ATA_HORKAGE_NOTRIM = 16777216, + ATA_HORKAGE_MAX_SEC_1024 = 33554432, + ATA_HORKAGE_MAX_TRIM_128M = 67108864, + ATA_DMA_MASK_ATA = 1, + ATA_DMA_MASK_ATAPI = 2, + ATA_DMA_MASK_CFA = 4, + ATAPI_READ = 0, + ATAPI_WRITE = 1, + ATAPI_READ_CD = 2, + ATAPI_PASS_THRU = 3, + ATAPI_MISC = 4, + ATA_TIMING_SETUP = 1, + ATA_TIMING_ACT8B = 2, + ATA_TIMING_REC8B = 4, + ATA_TIMING_CYC8B = 8, + ATA_TIMING_8BIT = 14, + ATA_TIMING_ACTIVE = 16, + ATA_TIMING_RECOVER = 32, + ATA_TIMING_DMACK_HOLD = 64, + ATA_TIMING_CYCLE = 128, + ATA_TIMING_UDMA = 256, + ATA_TIMING_ALL = 511, + ATA_ACPI_FILTER_SETXFER = 1, + ATA_ACPI_FILTER_LOCK = 2, + ATA_ACPI_FILTER_DIPM = 4, + ATA_ACPI_FILTER_FPDMA_OFFSET = 8, + ATA_ACPI_FILTER_FPDMA_AA = 16, + ATA_ACPI_FILTER_DEFAULT = 7, +}; + +enum ata_completion_errors { + AC_ERR_OK = 0, + AC_ERR_DEV = 1, + AC_ERR_HSM = 2, + AC_ERR_TIMEOUT = 4, + AC_ERR_MEDIA = 8, + AC_ERR_ATA_BUS = 16, + AC_ERR_HOST_BUS = 32, + AC_ERR_SYSTEM = 64, + AC_ERR_INVALID = 128, + AC_ERR_OTHER = 256, + AC_ERR_NODEV_HINT = 512, + AC_ERR_NCQ = 1024, +}; + +enum ata_lpm_policy { + ATA_LPM_UNKNOWN = 0, + ATA_LPM_MAX_POWER = 1, + ATA_LPM_MED_POWER = 2, + ATA_LPM_MED_POWER_WITH_DIPM = 3, + ATA_LPM_MIN_POWER_WITH_PARTIAL = 4, + ATA_LPM_MIN_POWER = 5, +}; + +struct ata_queued_cmd; + +typedef void (*ata_qc_cb_t)(struct ata_queued_cmd *); + +struct ata_taskfile { + long unsigned int flags; + u8 protocol; + u8 ctl; + u8 hob_feature; + u8 hob_nsect; + u8 hob_lbal; + u8 hob_lbam; + u8 hob_lbah; + u8 feature; + u8 nsect; + u8 lbal; + u8 lbam; + u8 lbah; + u8 device; + u8 command; + u32 auxiliary; +}; + +struct ata_port; + +struct ata_device; + +struct ata_queued_cmd { + struct ata_port *ap; + struct ata_device *dev; + struct scsi_cmnd *scsicmd; + void (*scsidone)(struct scsi_cmnd *); + struct ata_taskfile tf; + u8 cdb[16]; + long unsigned int flags; + unsigned int tag; + unsigned int hw_tag; + unsigned int n_elem; + unsigned int orig_n_elem; + int dma_dir; + unsigned int sect_size; + unsigned int nbytes; + unsigned int extrabytes; + unsigned int curbytes; + struct scatterlist sgent; + struct scatterlist *sg; + struct scatterlist *cursg; + unsigned int cursg_ofs; + unsigned int err_mask; + struct ata_taskfile result_tf; + ata_qc_cb_t complete_fn; + void *private_data; + void *lldd_task; +}; + +struct ata_link; + +typedef int (*ata_prereset_fn_t)(struct ata_link *, long unsigned int); + +struct ata_eh_info { + struct ata_device *dev; + u32 serror; + unsigned int err_mask; + unsigned int action; + unsigned int dev_action[2]; + unsigned int flags; + unsigned int probe_mask; + char desc[80]; + int desc_len; +}; + +struct ata_eh_context { + struct ata_eh_info i; + int tries[2]; + int cmd_timeout_idx[12]; + unsigned int classes[2]; + unsigned int did_probe_mask; + unsigned int unloaded_mask; + unsigned int saved_ncq_enabled; + u8 saved_xfer_mode[2]; + long unsigned int last_reset; +}; + +struct ata_ering_entry { + unsigned int eflags; + unsigned int err_mask; + u64 timestamp; +}; + +struct ata_ering { + int cursor; + struct ata_ering_entry ring[32]; +}; + +struct ata_device { + struct ata_link *link; + unsigned int devno; + unsigned int horkage; + long unsigned int flags; + struct scsi_device *sdev; + void *private_data; + union acpi_object *gtf_cache; + unsigned int gtf_filter; + struct device tdev; + u64 n_sectors; + u64 n_native_sectors; + unsigned int class; + long unsigned int unpark_deadline; + u8 pio_mode; + u8 dma_mode; + u8 xfer_mode; + unsigned int xfer_shift; + unsigned int multi_count; + unsigned int max_sectors; + unsigned int cdb_len; + long unsigned int pio_mask; + long unsigned int mwdma_mask; + long unsigned int udma_mask; + u16 cylinders; + u16 heads; + u16 sectors; + long: 16; + long: 64; + long: 64; + long: 64; + long: 64; + union { + u16 id[256]; + u32 gscr[128]; + }; + u8 devslp_timing[8]; + u8 ncq_send_recv_cmds[20]; + u8 ncq_non_data_cmds[64]; + u32 zac_zoned_cap; + u32 zac_zones_optimal_open; + u32 zac_zones_optimal_nonseq; + u32 zac_zones_max_open; + int spdn_cnt; + struct ata_ering ering; + long: 64; +}; + +struct ata_link { + struct ata_port *ap; + int pmp; + struct device tdev; + unsigned int active_tag; + u32 sactive; + unsigned int flags; + u32 saved_scontrol; + unsigned int hw_sata_spd_limit; + unsigned int sata_spd_limit; + unsigned int sata_spd; + enum ata_lpm_policy lpm_policy; + struct ata_eh_info eh_info; + struct ata_eh_context eh_context; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct ata_device device[2]; + long unsigned int last_lpm_change; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +typedef int (*ata_reset_fn_t)(struct ata_link *, unsigned int *, long unsigned int); + +typedef void (*ata_postreset_fn_t)(struct ata_link *, unsigned int *); + +enum sw_activity { + OFF = 0, + BLINK_ON = 1, + BLINK_OFF = 2, +}; + +struct ata_ioports { + void *cmd_addr; + void *data_addr; + void *error_addr; + void *feature_addr; + void *nsect_addr; + void *lbal_addr; + void *lbam_addr; + void *lbah_addr; + void *device_addr; + void *status_addr; + void *command_addr; + void *altstatus_addr; + void *ctl_addr; + void *bmdma_addr; + void *scr_addr; +}; + +struct ata_port_operations; + +struct ata_host { + spinlock_t lock; + struct device *dev; + void * const *iomap; + unsigned int n_ports; + unsigned int n_tags; + void *private_data; + struct ata_port_operations *ops; + long unsigned int flags; + struct kref kref; + struct mutex eh_mutex; + struct task_struct *eh_owner; + struct ata_port *simplex_claimed; + struct ata_port *ports[0]; +}; + +struct ata_port_operations { + int (*qc_defer)(struct ata_queued_cmd *); + int (*check_atapi_dma)(struct ata_queued_cmd *); + enum ata_completion_errors (*qc_prep)(struct ata_queued_cmd *); + unsigned int (*qc_issue)(struct ata_queued_cmd *); + bool (*qc_fill_rtf)(struct ata_queued_cmd *); + int (*cable_detect)(struct ata_port *); + long unsigned int (*mode_filter)(struct ata_device *, long unsigned int); + void (*set_piomode)(struct ata_port *, struct ata_device *); + void (*set_dmamode)(struct ata_port *, struct ata_device *); + int (*set_mode)(struct ata_link *, struct ata_device **); + unsigned int (*read_id)(struct ata_device *, struct ata_taskfile *, u16 *); + void (*dev_config)(struct ata_device *); + void (*freeze)(struct ata_port *); + void (*thaw)(struct ata_port *); + ata_prereset_fn_t prereset; + ata_reset_fn_t softreset; + ata_reset_fn_t hardreset; + ata_postreset_fn_t postreset; + ata_prereset_fn_t pmp_prereset; + ata_reset_fn_t pmp_softreset; + ata_reset_fn_t pmp_hardreset; + ata_postreset_fn_t pmp_postreset; + void (*error_handler)(struct ata_port *); + void (*lost_interrupt)(struct ata_port *); + void (*post_internal_cmd)(struct ata_queued_cmd *); + void (*sched_eh)(struct ata_port *); + void (*end_eh)(struct ata_port *); + int (*scr_read)(struct ata_link *, unsigned int, u32 *); + int (*scr_write)(struct ata_link *, unsigned int, u32); + void (*pmp_attach)(struct ata_port *); + void (*pmp_detach)(struct ata_port *); + int (*set_lpm)(struct ata_link *, enum ata_lpm_policy, unsigned int); + int (*port_suspend)(struct ata_port *, pm_message_t); + int (*port_resume)(struct ata_port *); + int (*port_start)(struct ata_port *); + void (*port_stop)(struct ata_port *); + void (*host_stop)(struct ata_host *); + void (*sff_dev_select)(struct ata_port *, unsigned int); + void (*sff_set_devctl)(struct ata_port *, u8); + u8 (*sff_check_status)(struct ata_port *); + u8 (*sff_check_altstatus)(struct ata_port *); + void (*sff_tf_load)(struct ata_port *, const struct ata_taskfile *); + void (*sff_tf_read)(struct ata_port *, struct ata_taskfile *); + void (*sff_exec_command)(struct ata_port *, const struct ata_taskfile *); + unsigned int (*sff_data_xfer)(struct ata_queued_cmd *, unsigned char *, unsigned int, int); + void (*sff_irq_on)(struct ata_port *); + bool (*sff_irq_check)(struct ata_port *); + void (*sff_irq_clear)(struct ata_port *); + void (*sff_drain_fifo)(struct ata_queued_cmd *); + void (*bmdma_setup)(struct ata_queued_cmd *); + void (*bmdma_start)(struct ata_queued_cmd *); + void (*bmdma_stop)(struct ata_queued_cmd *); + u8 (*bmdma_status)(struct ata_port *); + ssize_t (*em_show)(struct ata_port *, char *); + ssize_t (*em_store)(struct ata_port *, const char *, size_t); + ssize_t (*sw_activity_show)(struct ata_device *, char *); + ssize_t (*sw_activity_store)(struct ata_device *, enum sw_activity); + ssize_t (*transmit_led_message)(struct ata_port *, u32, ssize_t); + void (*phy_reset)(struct ata_port *); + void (*eng_timeout)(struct ata_port *); + const struct ata_port_operations *inherits; +}; + +struct ata_port_stats { + long unsigned int unhandled_irq; + long unsigned int idle_irq; + long unsigned int rw_reqbuf; +}; + +struct ata_acpi_drive { + u32 pio; + u32 dma; +}; + +struct ata_acpi_gtm { + struct ata_acpi_drive drive[2]; + u32 flags; +}; + +struct ata_port { + struct Scsi_Host *scsi_host; + struct ata_port_operations *ops; + spinlock_t *lock; + long unsigned int flags; + unsigned int pflags; + unsigned int print_id; + unsigned int local_port_no; + unsigned int port_no; + struct ata_ioports ioaddr; + u8 ctl; + u8 last_ctl; + struct ata_link *sff_pio_task_link; + struct delayed_work sff_pio_task; + struct ata_bmdma_prd *bmdma_prd; + dma_addr_t bmdma_prd_dma; + unsigned int pio_mask; + unsigned int mwdma_mask; + unsigned int udma_mask; + unsigned int cbl; + struct ata_queued_cmd qcmd[33]; + long unsigned int sas_tag_allocated; + u64 qc_active; + int nr_active_links; + unsigned int sas_last_tag; + long: 64; + struct ata_link link; + struct ata_link *slave_link; + int nr_pmp_links; + struct ata_link *pmp_link; + struct ata_link *excl_link; + struct ata_port_stats stats; + struct ata_host *host; + struct device *dev; + struct device tdev; + struct mutex scsi_scan_mutex; + struct delayed_work hotplug_task; + struct work_struct scsi_rescan_task; + unsigned int hsm_task_state; + u32 msg_enable; + struct list_head eh_done_q; + wait_queue_head_t eh_wait_q; + int eh_tries; + struct completion park_req_pending; + pm_message_t pm_mesg; + enum ata_lpm_policy target_lpm_policy; + struct timer_list fastdrain_timer; + long unsigned int fastdrain_cnt; + async_cookie_t cookie; + int em_message_type; + void *private_data; + struct ata_acpi_gtm __acpi_init_gtm; + long: 32; + long: 64; + long: 64; + u8 sector_buf[512]; +}; + +enum sas_oob_mode { + OOB_NOT_CONNECTED = 0, + SATA_OOB_MODE = 1, + SAS_OOB_MODE = 2, +}; + +enum phy_func { + PHY_FUNC_NOP = 0, + PHY_FUNC_LINK_RESET = 1, + PHY_FUNC_HARD_RESET = 2, + PHY_FUNC_DISABLE = 3, + PHY_FUNC_CLEAR_ERROR_LOG = 5, + PHY_FUNC_CLEAR_AFFIL = 6, + PHY_FUNC_TX_SATA_PS_SIGNAL = 7, + PHY_FUNC_RELEASE_SPINUP_HOLD = 16, + PHY_FUNC_SET_LINK_RATE = 17, + PHY_FUNC_GET_EVENTS = 18, +}; + +enum sas_open_rej_reason { + SAS_OREJ_UNKNOWN = 0, + SAS_OREJ_BAD_DEST = 1, + SAS_OREJ_CONN_RATE = 2, + SAS_OREJ_EPROTO = 3, + SAS_OREJ_RESV_AB0 = 4, + SAS_OREJ_RESV_AB1 = 5, + SAS_OREJ_RESV_AB2 = 6, + SAS_OREJ_RESV_AB3 = 7, + SAS_OREJ_WRONG_DEST = 8, + SAS_OREJ_STP_NORES = 9, + SAS_OREJ_NO_DEST = 10, + SAS_OREJ_PATH_BLOCKED = 11, + SAS_OREJ_RSVD_CONT0 = 12, + SAS_OREJ_RSVD_CONT1 = 13, + SAS_OREJ_RSVD_INIT0 = 14, + SAS_OREJ_RSVD_INIT1 = 15, + SAS_OREJ_RSVD_STOP0 = 16, + SAS_OREJ_RSVD_STOP1 = 17, + SAS_OREJ_RSVD_RETRY = 18, +}; + +struct dev_to_host_fis { + u8 fis_type; + u8 flags; + u8 status; + u8 error; + u8 lbal; + union { + u8 lbam; + u8 byte_count_low; + }; + union { + u8 lbah; + u8 byte_count_high; + }; + u8 device; + u8 lbal_exp; + u8 lbam_exp; + u8 lbah_exp; + u8 _r_a; + union { + u8 sector_count; + u8 interrupt_reason; + }; + u8 sector_count_exp; + u8 _r_b; + u8 _r_c; + u32 _r_d; +}; + +struct host_to_dev_fis { + u8 fis_type; + u8 flags; + u8 command; + u8 features; + u8 lbal; + union { + u8 lbam; + u8 byte_count_low; + }; + union { + u8 lbah; + u8 byte_count_high; + }; + u8 device; + u8 lbal_exp; + u8 lbam_exp; + u8 lbah_exp; + u8 features_exp; + union { + u8 sector_count; + u8 interrupt_reason; + }; + u8 sector_count_exp; + u8 _r_a; + u8 control; + u32 _r_b; +}; + +struct report_general_resp { + __be16 change_count; + __be16 route_indexes; + u8 _r_a; + u8 num_phys; + u8 conf_route_table: 1; + u8 configuring: 1; + u8 config_others: 1; + u8 orej_retry_supp: 1; + u8 stp_cont_awt: 1; + u8 self_config: 1; + u8 zone_config: 1; + u8 t2t_supp: 1; + u8 _r_c; + u8 enclosure_logical_id[8]; + u8 _r_d[12]; +}; + +struct discover_resp { + u8 _r_a[5]; + u8 phy_id; + __be16 _r_b; + u8 _r_c: 4; + u8 attached_dev_type: 3; + u8 _r_d: 1; + u8 linkrate: 4; + u8 _r_e: 4; + u8 attached_sata_host: 1; + u8 iproto: 3; + u8 _r_f: 4; + u8 attached_sata_dev: 1; + u8 tproto: 3; + u8 _r_g: 3; + u8 attached_sata_ps: 1; + u8 sas_addr[8]; + u8 attached_sas_addr[8]; + u8 attached_phy_id; + u8 _r_h[7]; + u8 hmin_linkrate: 4; + u8 pmin_linkrate: 4; + u8 hmax_linkrate: 4; + u8 pmax_linkrate: 4; + u8 change_count; + u8 pptv: 4; + u8 _r_i: 3; + u8 virtual: 1; + u8 routing_attr: 4; + u8 _r_j: 4; + u8 conn_type; + u8 conn_el_index; + u8 conn_phy_link; + u8 _r_k[8]; +}; + +struct report_phy_sata_resp { + u8 _r_a[5]; + u8 phy_id; + u8 _r_b; + u8 affil_valid: 1; + u8 affil_supp: 1; + u8 _r_c: 6; + u32 _r_d; + u8 stp_sas_addr[8]; + struct dev_to_host_fis fis; + u32 _r_e; + u8 affil_stp_ini_addr[8]; + __be32 crc; +}; + +struct smp_resp { + u8 frame_type; + u8 function; + u8 result; + u8 reserved; + union { + struct report_general_resp rg; + struct discover_resp disc; + struct report_phy_sata_resp rps; + }; +}; + +enum sas_class { + SAS = 0, + EXPANDER = 1, +}; + +enum sas_phy_role { + PHY_ROLE_NONE = 0, + PHY_ROLE_TARGET = 64, + PHY_ROLE_INITIATOR = 128, +}; + +enum sas_phy_type { + PHY_TYPE_PHYSICAL = 0, + PHY_TYPE_VIRTUAL = 1, +}; + +enum port_event { + PORTE_BYTES_DMAED = 0, + PORTE_BROADCAST_RCVD = 1, + PORTE_LINK_RESET_ERR = 2, + PORTE_TIMER_EVENT = 3, + PORTE_HARD_RESET = 4, + PORT_NUM_EVENTS = 5, +}; + +enum phy_event { + PHYE_LOSS_OF_SIGNAL = 0, + PHYE_OOB_DONE = 1, + PHYE_OOB_ERROR = 2, + PHYE_SPINUP_HOLD = 3, + PHYE_RESUME_TIMEOUT = 4, + PHYE_SHUTDOWN = 5, + PHY_NUM_EVENTS = 6, +}; + +enum discover_event { + DISCE_DISCOVER_DOMAIN = 0, + DISCE_REVALIDATE_DOMAIN = 1, + DISCE_SUSPEND = 2, + DISCE_RESUME = 3, + DISC_NUM_EVENTS = 4, +}; + +enum routing_attribute { + DIRECT_ROUTING = 0, + SUBTRACTIVE_ROUTING = 1, + TABLE_ROUTING = 2, +}; + +enum ex_phy_state { + PHY_EMPTY = 0, + PHY_VACANT = 1, + PHY_NOT_PRESENT = 2, + PHY_DEVICE_DISCOVERED = 3, +}; + +struct ex_phy { + int phy_id; + enum ex_phy_state phy_state; + enum sas_device_type attached_dev_type; + enum sas_linkrate linkrate; + u8 attached_sata_host: 1; + u8 attached_sata_dev: 1; + u8 attached_sata_ps: 1; + enum sas_protocol attached_tproto; + enum sas_protocol attached_iproto; + u8 attached_sas_addr[8]; + u8 attached_phy_id; + int phy_change_count; + enum routing_attribute routing_attr; + u8 virtual: 1; + int last_da_index; + struct sas_phy *phy; + struct sas_port *port; +}; + +struct expander_device { + struct list_head children; + int ex_change_count; + u16 max_route_indexes; + u8 num_phys; + u8 t2t_supp: 1; + u8 configuring: 1; + u8 conf_route_table: 1; + u8 enclosure_logical_id[8]; + struct ex_phy *ex_phy; + struct sas_port *parent_port; + struct mutex cmd_mutex; +}; + +struct sata_device { + unsigned int class; + u8 port_no; + struct ata_port *ap; + struct ata_host *ata_host; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct smp_resp rps_resp; + u8 fis[24]; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct ssp_device { + struct list_head eh_list_node; + struct scsi_lun reset_lun; +}; + +struct asd_sas_port; + +struct domain_device { + spinlock_t done_lock; + enum sas_device_type dev_type; + enum sas_linkrate linkrate; + enum sas_linkrate min_linkrate; + enum sas_linkrate max_linkrate; + int pathways; + struct domain_device *parent; + struct list_head siblings; + struct asd_sas_port *port; + struct sas_phy *phy; + struct list_head dev_list_node; + struct list_head disco_list_node; + enum sas_protocol iproto; + enum sas_protocol tproto; + struct sas_rphy *rphy; + u8 sas_addr[8]; + u8 hashed_sas_addr[3]; + u8 frame_rcvd[32]; + long: 40; + long: 64; + union { + struct expander_device ex_dev; + struct sata_device sata_dev; + struct ssp_device ssp_dev; + }; + void *lldd_dev; + long unsigned int state; + struct kref kref; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct sas_work { + struct list_head drain_node; + struct work_struct work; +}; + +struct sas_discovery_event { + struct sas_work work; + struct asd_sas_port *port; +}; + +struct sas_discovery { + struct sas_discovery_event disc_work[4]; + long unsigned int pending; + u8 fanout_sas_addr[8]; + u8 eeds_a[8]; + u8 eeds_b[8]; + int max_level; +}; + +struct sas_ha_struct; + +struct asd_sas_port { + struct sas_discovery disc; + struct domain_device *port_dev; + spinlock_t dev_list_lock; + struct list_head dev_list; + struct list_head disco_list; + struct list_head destroy_list; + struct list_head sas_port_del_list; + enum sas_linkrate linkrate; + struct sas_work work; + int suspended; + int id; + enum sas_class class; + u8 sas_addr[8]; + u8 attached_sas_addr[8]; + enum sas_protocol iproto; + enum sas_protocol tproto; + enum sas_oob_mode oob_mode; + spinlock_t phy_list_lock; + struct list_head phy_list; + int num_phys; + u32 phy_mask; + struct sas_ha_struct *ha; + struct sas_port *port; + void *lldd_port; +}; + +struct scsi_core { + struct Scsi_Host *shost; +}; + +struct asd_sas_phy; + +struct sas_ha_struct { + struct list_head defer_q; + struct mutex drain_mutex; + long unsigned int state; + spinlock_t lock; + int eh_active; + wait_queue_head_t eh_wait_q; + struct list_head eh_dev_q; + struct mutex disco_mutex; + struct scsi_core core; + char *sas_ha_name; + struct device *dev; + struct module *lldd_module; + struct workqueue_struct *event_q; + struct workqueue_struct *disco_q; + u8 *sas_addr; + u8 hashed_sas_addr[3]; + spinlock_t phy_port_lock; + struct asd_sas_phy **sas_phy; + struct asd_sas_port **sas_port; + int num_phys; + int strict_wide_ports; + int (*notify_port_event)(struct asd_sas_phy *, enum port_event); + int (*notify_phy_event)(struct asd_sas_phy *, enum phy_event); + void *lldd_ha; + struct list_head eh_done_q; + struct list_head eh_ata_q; + int event_thres; +}; + +struct asd_sas_event { + struct sas_work work; + struct asd_sas_phy *phy; + int event; +}; + +struct asd_sas_phy { + atomic_t event_nr; + int in_shutdown; + int error; + int suspended; + struct sas_phy *phy; + int enabled; + int id; + enum sas_class class; + enum sas_protocol iproto; + enum sas_protocol tproto; + enum sas_phy_type type; + enum sas_phy_role role; + enum sas_oob_mode oob_mode; + enum sas_linkrate linkrate; + u8 *sas_addr; + u8 attached_sas_addr[8]; + spinlock_t frame_rcvd_lock; + u8 *frame_rcvd; + int frame_rcvd_size; + spinlock_t sas_prim_lock; + u32 sas_prim; + struct list_head port_phy_el; + struct asd_sas_port *port; + struct sas_ha_struct *ha; + void *lldd_phy; +}; + +enum sas_ha_state { + SAS_HA_REGISTERED = 0, + SAS_HA_DRAINING = 1, + SAS_HA_ATA_EH_ACTIVE = 2, + SAS_HA_FROZEN = 3, +}; + +enum service_response { + SAS_TASK_COMPLETE = 0, + SAS_TASK_UNDELIVERED = 4294967295, +}; + +enum exec_status { + __SAM_STAT_CHECK_CONDITION = 2, + SAS_DEV_NO_RESPONSE = 128, + SAS_DATA_UNDERRUN = 129, + SAS_DATA_OVERRUN = 130, + SAS_INTERRUPTED = 131, + SAS_QUEUE_FULL = 132, + SAS_DEVICE_UNKNOWN = 133, + SAS_SG_ERR = 134, + SAS_OPEN_REJECT = 135, + SAS_OPEN_TO = 136, + SAS_PROTO_RESPONSE = 137, + SAS_PHY_DOWN = 138, + SAS_NAK_R_ERR = 139, + SAS_PENDING = 140, + SAS_ABORTED_TASK = 141, +}; + +struct task_status_struct { + enum service_response resp; + enum exec_status stat; + int buf_valid_size; + u8 buf[96]; + u32 residual; + enum sas_open_rej_reason open_rej_reason; +}; + +struct sas_ata_task { + struct host_to_dev_fis fis; + u8 atapi_packet[16]; + u8 retry_count; + u8 dma_xfer: 1; + u8 use_ncq: 1; + u8 set_affil_pol: 1; + u8 stp_affil_pol: 1; + u8 device_control_reg_update: 1; +} __attribute__((packed)); + +struct sas_smp_task { + struct scatterlist smp_req; + struct scatterlist smp_resp; +}; + +enum task_attribute { + TASK_ATTR_SIMPLE = 0, + TASK_ATTR_HOQ = 1, + TASK_ATTR_ORDERED = 2, + TASK_ATTR_ACA = 4, +}; + +struct sas_ssp_task { + u8 retry_count; + u8 LUN[8]; + u8 enable_first_burst: 1; + enum task_attribute task_attr; + u8 task_prio; + struct scsi_cmnd *cmd; +}; + +struct sas_task_slow; + +struct sas_task { + struct domain_device *dev; + spinlock_t task_state_lock; + unsigned int task_state_flags; + enum sas_protocol task_proto; + union { + struct sas_ata_task ata_task; + struct sas_smp_task smp_task; + struct sas_ssp_task ssp_task; + }; + struct scatterlist *scatter; + int num_scatter; + u32 total_xfer_len; + u8 data_dir: 2; + struct task_status_struct task_status; + void (*task_done)(struct sas_task *); + void *lldd_task; + void *uldd_task; + struct sas_task_slow *slow_task; +}; + +struct sas_task_slow { + struct timer_list timer; + struct completion completion; + struct sas_task *task; +}; + +struct sas_domain_function_template { + void (*lldd_port_formed)(struct asd_sas_phy *); + void (*lldd_port_deformed)(struct asd_sas_phy *); + int (*lldd_dev_found)(struct domain_device *); + void (*lldd_dev_gone)(struct domain_device *); + int (*lldd_execute_task)(struct sas_task *, gfp_t); + int (*lldd_abort_task)(struct sas_task *); + int (*lldd_abort_task_set)(struct domain_device *, u8 *); + int (*lldd_clear_aca)(struct domain_device *, u8 *); + int (*lldd_clear_task_set)(struct domain_device *, u8 *); + int (*lldd_I_T_nexus_reset)(struct domain_device *); + int (*lldd_ata_check_ready)(struct domain_device *); + void (*lldd_ata_set_dmamode)(struct domain_device *); + int (*lldd_lu_reset)(struct domain_device *, u8 *); + int (*lldd_query_task)(struct sas_task *); + int (*lldd_clear_nexus_port)(struct asd_sas_port *); + int (*lldd_clear_nexus_ha)(struct sas_ha_struct *); + int (*lldd_control_phy)(struct asd_sas_phy *, enum phy_func, void *); + int (*lldd_write_gpio)(struct sas_ha_struct *, u8, u8, u8, u8 *); +}; + +struct sas_phy_data { + struct sas_phy *phy; + struct mutex event_lock; + int hard_reset; + int reset_result; + struct sas_work reset_work; + int enable; + int enable_result; + struct sas_work enable_work; +}; + +struct sas_identify_frame { + u8 frame_type: 4; + u8 dev_type: 3; + u8 _un0: 1; + u8 _un1; + union { + struct { + u8 _un20: 1; + u8 smp_iport: 1; + u8 stp_iport: 1; + u8 ssp_iport: 1; + u8 _un247: 4; + }; + u8 initiator_bits; + }; + union { + struct { + u8 _un30: 1; + u8 smp_tport: 1; + u8 stp_tport: 1; + u8 ssp_tport: 1; + u8 _un347: 4; + }; + u8 target_bits; + }; + u8 _un4_11[8]; + u8 sas_addr[8]; + u8 phy_id; + u8 _un21_27[7]; + __be32 crc; +}; + +enum { + SAS_DEV_GONE = 0, + SAS_DEV_FOUND = 1, + SAS_DEV_DESTROY = 2, + SAS_DEV_EH_PENDING = 3, + SAS_DEV_LU_RESET = 4, + SAS_DEV_RESET = 5, +}; + +enum task_disposition { + TASK_IS_DONE = 0, + TASK_IS_ABORTED = 1, + TASK_IS_AT_LU = 2, + TASK_IS_NOT_AT_LU = 3, + TASK_ABORT_FAILED = 4, +}; + +struct ssp_response_iu { + u8 _r_a[10]; + u8 datapres: 2; + u8 _r_b: 6; + u8 status; + u32 _r_c; + __be32 sense_data_len; + __be32 response_data_len; + u8 resp_data[0]; + u8 sense_data[0]; +}; + +enum blogic_msglevel { + BLOGIC_ANNOUNCE_LEVEL = 0, + BLOGIC_INFO_LEVEL = 1, + BLOGIC_NOTICE_LEVEL = 2, + BLOGIC_WARN_LEVEL = 3, + BLOGIC_ERR_LEVEL = 4, +}; + +enum blogic_adapter_type { + BLOGIC_MULTIMASTER = 1, + BLOGIC_FLASHPOINT = 2, +}; + +enum blogic_adapter_bus_type { + BLOGIC_UNKNOWN_BUS = 0, + BLOGIC_ISA_BUS = 1, + BLOGIC_EISA_BUS = 2, + BLOGIC_PCI_BUS = 3, + BLOGIC_VESA_BUS = 4, + BLOGIC_MCA_BUS = 5, +}; + +enum blogic_bios_diskgeometry { + BLOGIC_BIOS_NODISK = 0, + BLOGIC_BIOS_DISK64x32 = 1, + BLOGIC_BIOS_DISK128x32 = 2, + BLOGIC_BIOS_DISK255x63 = 3, +}; + +struct blogic_byte_count { + unsigned int units; + unsigned int billions; +}; + +struct blogic_probeinfo { + enum blogic_adapter_type adapter_type; + enum blogic_adapter_bus_type adapter_bus_type; + long unsigned int io_addr; + long unsigned int pci_addr; + struct pci_dev *pci_device; + unsigned char bus; + unsigned char dev; + unsigned char irq_ch; +}; + +struct blogic_probe_options { + bool noprobe: 1; + bool noprobe_isa: 1; + bool noprobe_pci: 1; + bool nosort_pci: 1; + bool multimaster_first: 1; + bool flashpoint_first: 1; + bool limited_isa: 1; + bool probe330: 1; + bool probe334: 1; + bool probe230: 1; + bool probe234: 1; + bool probe130: 1; + bool probe134: 1; +}; + +struct blogic_global_options { + bool trace_probe: 1; + bool trace_hw_reset: 1; + bool trace_config: 1; + bool trace_err: 1; +}; + +union blogic_cntrl_reg { + unsigned char all; + struct { + char: 4; + bool bus_reset: 1; + bool int_reset: 1; + bool soft_reset: 1; + bool hard_reset: 1; + } cr; +}; + +union blogic_stat_reg { + unsigned char all; + struct { + bool cmd_invalid: 1; + bool rsvd: 1; + bool datain_ready: 1; + bool cmd_param_busy: 1; + bool adapter_ready: 1; + bool init_reqd: 1; + bool diag_failed: 1; + bool diag_active: 1; + } sr; +}; + +union blogic_int_reg { + unsigned char all; + struct { + bool mailin_loaded: 1; + bool mailout_avail: 1; + bool cmd_complete: 1; + bool ext_busreset: 1; + unsigned char rsvd: 3; + bool int_valid: 1; + } ir; +}; + +union blogic_geo_reg { + unsigned char all; + struct { + enum blogic_bios_diskgeometry d0_geo: 2; + enum blogic_bios_diskgeometry d1_geo: 2; + char: 3; + bool ext_trans_enable: 1; + } gr; +}; + +enum blogic_opcode { + BLOGIC_TEST_CMP_COMPLETE = 0, + BLOGIC_INIT_MBOX = 1, + BLOGIC_EXEC_MBOX_CMD = 2, + BLOGIC_EXEC_BIOS_CMD = 3, + BLOGIC_GET_BOARD_ID = 4, + BLOGIC_ENABLE_OUTBOX_AVAIL_INT = 5, + BLOGIC_SET_SELECT_TIMEOUT = 6, + BLOGIC_SET_PREEMPT_TIME = 7, + BLOGIC_SET_TIMEOFF_BUS = 8, + BLOGIC_SET_TXRATE = 9, + BLOGIC_INQ_DEV0TO7 = 10, + BLOGIC_INQ_CONFIG = 11, + BLOGIC_TGT_MODE = 12, + BLOGIC_INQ_SETUPINFO = 13, + BLOGIC_WRITE_LOCALRAM = 26, + BLOGIC_READ_LOCALRAM = 27, + BLOGIC_WRITE_BUSMASTER_FIFO = 28, + BLOGIC_READ_BUSMASTER_FIFO = 29, + BLOGIC_ECHO_CMDDATA = 31, + BLOGIC_ADAPTER_DIAG = 32, + BLOGIC_SET_OPTIONS = 33, + BLOGIC_INQ_DEV8TO15 = 35, + BLOGIC_INQ_DEV = 36, + BLOGIC_DISABLE_INT = 37, + BLOGIC_INIT_EXT_MBOX = 129, + BLOGIC_EXEC_SCS_CMD = 131, + BLOGIC_INQ_FWVER_D3 = 132, + BLOGIC_INQ_FWVER_LETTER = 133, + BLOGIC_INQ_PCI_INFO = 134, + BLOGIC_INQ_MODELNO = 139, + BLOGIC_INQ_SYNC_PERIOD = 140, + BLOGIC_INQ_EXTSETUP = 141, + BLOGIC_STRICT_RR = 143, + BLOGIC_STORE_LOCALRAM = 144, + BLOGIC_FETCH_LOCALRAM = 145, + BLOGIC_STORE_TO_EEPROM = 146, + BLOGIC_LOAD_AUTOSCSICODE = 148, + BLOGIC_MOD_IOADDR = 149, + BLOGIC_SETCCB_FMT = 150, + BLOGIC_WRITE_INQBUF = 154, + BLOGIC_READ_INQBUF = 155, + BLOGIC_FLASH_LOAD = 167, + BLOGIC_READ_SCAMDATA = 168, + BLOGIC_WRITE_SCAMDATA = 169, +}; + +struct blogic_board_id { + unsigned char type; + unsigned char custom_features; + unsigned char fw_ver_digit1; + unsigned char fw_ver_digit2; +}; + +struct blogic_config { + char: 5; + bool dma_ch5: 1; + bool dma_ch6: 1; + bool dma_ch7: 1; + bool irq_ch9: 1; + bool irq_ch10: 1; + bool irq_ch11: 1; + bool irq_ch12: 1; + char: 1; + bool irq_ch14: 1; + bool irq_ch15: 1; + char: 1; + unsigned char id: 4; +}; + +struct blogic_syncval { + unsigned char offset: 4; + unsigned char tx_period: 3; + bool sync: 1; +}; + +struct blogic_setup_info { + bool sync: 1; + bool parity: 1; + unsigned char tx_rate; + unsigned char preempt_time; + unsigned char timeoff_bus; + unsigned char mbox_count; + unsigned char mbox_addr[3]; + struct blogic_syncval sync0to7[8]; + unsigned char disconnect_ok0to7; + unsigned char sig; + unsigned char char_d; + unsigned char bus_type; + unsigned char wide_tx_ok0to7; + unsigned char wide_tx_active0to7; + struct blogic_syncval sync8to15[8]; + unsigned char disconnect_ok8to15; + char: 8; + unsigned char wide_tx_ok8to15; + unsigned char wide_tx_active8to15; +}; + +struct blogic_extmbox_req { + unsigned char mbox_count; + u32 base_mbox_addr; +} __attribute__((packed)); + +enum blogic_isa_ioport { + BLOGIC_IO_330 = 0, + BLOGIC_IO_334 = 1, + BLOGIC_IO_230 = 2, + BLOGIC_IO_234 = 3, + BLOGIC_IO_130 = 4, + BLOGIC_IO_134 = 5, + BLOGIC_IO_DISABLE = 6, + BLOGIC_IO_DISABLE2 = 7, +}; + +struct blogic_adapter_info { + enum blogic_isa_ioport isa_port; + unsigned char irq_ch; + bool low_term: 1; + bool high_term: 1; + char: 2; + bool JP1: 1; + bool JP2: 1; + bool JP3: 1; + bool genericinfo_valid: 1; + char: 8; +}; + +struct blogic_ext_setup { + unsigned char bus_type; + unsigned char bios_addr; + short unsigned int sg_limit; + unsigned char mbox_count; + u32 base_mbox_addr; + struct { + char: 2; + bool fast_on_eisa: 1; + char: 3; + bool level_int: 1; + } misc; + unsigned char fw_rev[3]; + bool wide: 1; + bool differential: 1; + bool scam: 1; + bool ultra: 1; + bool smart_term: 1; +} __attribute__((packed)); + +enum blogic_rr_req { + BLOGIC_AGGRESSIVE_RR = 0, + BLOGIC_STRICT_RR_MODE = 1, +}; + +struct blogic_fetch_localram { + unsigned char offset; + unsigned char count; +}; + +struct blogic_autoscsi { + unsigned char factory_sig[2]; + unsigned char info_bytes; + unsigned char adapter_type[6]; + char: 8; + bool floppy: 1; + bool floppy_sec: 1; + bool level_int: 1; + char: 2; + unsigned char systemram_bios: 3; + unsigned char dma_ch: 7; + bool dma_autoconf: 1; + unsigned char irq_ch: 7; + bool irq_autoconf: 1; + unsigned char dma_tx_rate; + unsigned char scsi_id; + bool low_term: 1; + bool parity: 1; + bool high_term: 1; + bool noisy_cable: 1; + bool fast_sync_neg: 1; + bool reset_enabled: 1; + char: 1; + bool active_negation: 1; + unsigned char bus_on_delay; + unsigned char bus_off_delay; + bool bios_enabled: 1; + bool int19_redir_enabled: 1; + bool ext_trans_enable: 1; + bool removable_as_fixed: 1; + char: 1; + bool morethan2_drives: 1; + bool bios_int: 1; + bool floptical: 1; + short unsigned int dev_enabled; + short unsigned int wide_ok; + short unsigned int fast_ok; + short unsigned int sync_ok; + short unsigned int discon_ok; + short unsigned int send_start_unit; + short unsigned int ignore_bios_scan; + unsigned char pci_int_pin: 2; + unsigned char adapter_ioport: 2; + bool strict_rr_enabled: 1; + bool vesabus_33mhzplus: 1; + bool vesa_burst_write: 1; + bool vesa_burst_read: 1; + short unsigned int ultra_ok; + long: 40; + unsigned char autoscsi_maxlun; + char: 1; + bool scam_dominant: 1; + bool scam_enabled: 1; + bool scam_lev2: 1; + char: 4; + bool int13_exten: 1; + char: 1; + bool cd_boot: 1; + char: 5; + unsigned char boot_id: 4; + unsigned char boot_ch: 4; + unsigned char force_scan_order: 1; + short unsigned int nontagged_to_alt_ok; + short unsigned int reneg_sync_on_check; + unsigned char rsvd[10]; + unsigned char manuf_diag[2]; + short unsigned int cksum; +} __attribute__((packed)); + +struct blogic_autoscsi_byte45 { + unsigned char force_scan_order: 1; +}; + +struct blogic_bios_drvmap { + unsigned char tgt_idbit3: 1; + char: 2; + enum blogic_bios_diskgeometry diskgeom: 2; + unsigned char tgt_id: 3; +}; + +enum blogic_setccb_fmt { + BLOGIC_LEGACY_LUN_CCB = 0, + BLOGIC_EXT_LUN_CCB = 1, +}; + +enum blogic_action { + BLOGIC_OUTBOX_FREE = 0, + BLOGIC_MBOX_START = 1, + BLOGIC_MBOX_ABORT = 2, +}; + +enum blogic_cmplt_code { + BLOGIC_INBOX_FREE = 0, + BLOGIC_CMD_COMPLETE_GOOD = 1, + BLOGIC_CMD_ABORT_BY_HOST = 2, + BLOGIC_CMD_NOTFOUND = 3, + BLOGIC_CMD_COMPLETE_ERROR = 4, + BLOGIC_INVALID_CCB = 5, +}; + +enum blogic_ccb_opcode { + BLOGIC_INITIATOR_CCB = 0, + BLOGIC_TGT_CCB = 1, + BLOGIC_INITIATOR_CCB_SG = 2, + BLOGIC_INITIATOR_CCBB_RESIDUAL = 3, + BLOGIC_INITIATOR_CCB_SG_RESIDUAL = 4, + BLOGIC_BDR = 129, +}; + +enum blogic_datadir { + BLOGIC_UNCHECKED_TX = 0, + BLOGIC_DATAIN_CHECKED = 1, + BLOGIC_DATAOUT_CHECKED = 2, + BLOGIC_NOTX = 3, +}; + +enum blogic_adapter_status { + BLOGIC_CMD_CMPLT_NORMAL = 0, + BLOGIC_LINK_CMD_CMPLT = 10, + BLOGIC_LINK_CMD_CMPLT_FLAG = 11, + BLOGIC_DATA_UNDERRUN = 12, + BLOGIC_SELECT_TIMEOUT = 17, + BLOGIC_DATA_OVERRUN = 18, + BLOGIC_NOEXPECT_BUSFREE = 19, + BLOGIC_INVALID_BUSPHASE = 20, + BLOGIC_INVALID_OUTBOX_CODE = 21, + BLOGIC_INVALID_CMD_CODE = 22, + BLOGIC_LINKCCB_BADLUN = 23, + BLOGIC_BAD_CMD_PARAM = 26, + BLOGIC_AUTOREQSENSE_FAIL = 27, + BLOGIC_TAGQUEUE_REJECT = 28, + BLOGIC_BAD_MSG_RCVD = 29, + BLOGIC_HW_FAIL = 32, + BLOGIC_NORESPONSE_TO_ATN = 33, + BLOGIC_HW_RESET = 34, + BLOGIC_RST_FROM_OTHERDEV = 35, + BLOGIC_BAD_RECONNECT = 36, + BLOGIC_HW_BDR = 37, + BLOGIC_ABRT_QUEUE = 38, + BLOGIC_ADAPTER_SW_ERROR = 39, + BLOGIC_HW_TIMEOUT = 48, + BLOGIC_PARITY_ERR = 52, +}; + +enum blogic_tgt_status { + BLOGIC_OP_GOOD = 0, + BLOGIC_CHECKCONDITION = 2, + BLOGIC_DEVBUSY = 8, +}; + +enum blogic_queuetag { + BLOGIC_SIMPLETAG = 0, + BLOGIC_HEADTAG = 1, + BLOGIC_ORDEREDTAG = 2, + BLOGIC_RSVDTAG = 3, +}; + +struct blogic_sg_seg { + u32 segbytes; + u32 segdata; +}; + +enum blogic_ccb_status { + BLOGIC_CCB_FREE = 0, + BLOGIC_CCB_ACTIVE = 1, + BLOGIC_CCB_COMPLETE = 2, + BLOGIC_CCB_RESET = 3, +}; + +struct blogic_adapter; + +struct blogic_ccb { + enum blogic_ccb_opcode opcode; + char: 3; + enum blogic_datadir datadir: 2; + bool tag_enable: 1; + enum blogic_queuetag queuetag: 2; + unsigned char cdblen; + unsigned char sense_datalen; + u32 datalen; + void *data; + short: 16; + enum blogic_adapter_status adapter_status; + enum blogic_tgt_status tgt_status; + unsigned char tgt_id; + unsigned char lun: 5; + bool legacytag_enable: 1; + enum blogic_queuetag legacy_tag: 2; + unsigned char cdb[12]; + u32 rsvd_int; + u32 sensedata; + void (*callback)(struct blogic_ccb *); + u32 base_addr; + enum blogic_cmplt_code comp_code; + dma_addr_t allocgrp_head; + unsigned int allocgrp_size; + u32 dma_handle; + enum blogic_ccb_status status; + long unsigned int serial; + struct scsi_cmnd *command; + struct blogic_adapter *adapter; + struct blogic_ccb *next; + struct blogic_ccb *next_all; + struct blogic_sg_seg sglist[128]; +}; + +struct fpoint_info { + u32 base_addr; + bool present; + unsigned char irq_ch; + unsigned char scsi_id; + unsigned char scsi_lun; + u16 fw_rev; + u16 sync_ok; + u16 fast_ok; + u16 ultra_ok; + u16 discon_ok; + u16 wide_ok; + bool parity: 1; + bool wide: 1; + bool softreset: 1; + bool ext_trans_enable: 1; + bool low_term: 1; + bool high_term: 1; + bool report_underrun: 1; + bool scam_enabled: 1; + bool scam_lev2: 1; + unsigned char family; + unsigned char bus_type; + unsigned char model[3]; + unsigned char relative_cardnum; + unsigned char rsvd[4]; + u32 os_rsvd; + unsigned char translation_info[4]; + u32 rsvd2[5]; + u32 sec_range; +}; + +struct blogic_tgt_flags { + bool tgt_exists: 1; + bool tagq_ok: 1; + bool wide_ok: 1; + bool tagq_active: 1; + bool wide_active: 1; + bool cmd_good: 1; + bool tgt_info_in: 1; +}; + +struct blogic_tgt_stats { + unsigned int cmds_tried; + unsigned int cmds_complete; + unsigned int read_cmds; + unsigned int write_cmds; + struct blogic_byte_count bytesread; + struct blogic_byte_count byteswritten; + unsigned int read_sz_buckets[10]; + unsigned int write_sz_buckets[10]; + short unsigned int aborts_request; + short unsigned int aborts_tried; + short unsigned int aborts_done; + short unsigned int bdr_request; + short unsigned int bdr_tried; + short unsigned int bdr_done; + short unsigned int adapter_reset_req; + short unsigned int adapter_reset_attempt; + short unsigned int adapter_reset_done; +}; + +struct blogic_drvr_options; + +struct blogic_outbox; + +struct blogic_inbox; + +struct blogic_adapter { + struct Scsi_Host *scsi_host; + struct pci_dev *pci_device; + enum blogic_adapter_type adapter_type; + enum blogic_adapter_bus_type adapter_bus_type; + long unsigned int io_addr; + long unsigned int pci_addr; + short unsigned int addr_count; + unsigned char host_no; + unsigned char model[9]; + unsigned char fw_ver[6]; + unsigned char full_model[18]; + unsigned char bus; + unsigned char dev; + unsigned char irq_ch; + unsigned char dma_ch; + unsigned char scsi_id; + bool irq_acquired: 1; + bool dma_chan_acquired: 1; + bool ext_trans_enable: 1; + bool parity: 1; + bool reset_enabled: 1; + bool level_int: 1; + bool wide: 1; + bool differential: 1; + bool scam: 1; + bool ultra: 1; + bool ext_lun: 1; + bool terminfo_valid: 1; + bool low_term: 1; + bool high_term: 1; + bool need_bouncebuf: 1; + bool strict_rr: 1; + bool scam_enabled: 1; + bool scam_lev2: 1; + bool adapter_initd: 1; + bool adapter_extreset: 1; + bool adapter_intern_err: 1; + bool processing_ccbs; + volatile bool adapter_cmd_complete; + short unsigned int adapter_sglimit; + short unsigned int drvr_sglimit; + short unsigned int maxdev; + short unsigned int maxlun; + short unsigned int mbox_count; + short unsigned int initccbs; + short unsigned int inc_ccbs; + short unsigned int alloc_ccbs; + short unsigned int drvr_qdepth; + short unsigned int adapter_qdepth; + short unsigned int untag_qdepth; + short unsigned int common_qdepth; + short unsigned int bus_settle_time; + short unsigned int sync_ok; + short unsigned int fast_ok; + short unsigned int ultra_ok; + short unsigned int wide_ok; + short unsigned int discon_ok; + short unsigned int tagq_ok; + short unsigned int ext_resets; + short unsigned int adapter_intern_errors; + short unsigned int tgt_count; + short unsigned int msgbuflen; + u32 bios_addr; + struct blogic_drvr_options *drvr_opts; + struct fpoint_info fpinfo; + void *cardhandle; + struct list_head host_list; + struct blogic_ccb *all_ccbs; + struct blogic_ccb *free_ccbs; + struct blogic_ccb *firstccb; + struct blogic_ccb *lastccb; + struct blogic_ccb *bdr_pend[16]; + struct blogic_tgt_flags tgt_flags[16]; + unsigned char qdepth[16]; + unsigned char sync_period[16]; + unsigned char sync_offset[16]; + unsigned char active_cmds[16]; + unsigned int cmds_since_rst[16]; + long unsigned int last_seqpoint[16]; + long unsigned int last_resettried[16]; + long unsigned int last_resetdone[16]; + struct blogic_outbox *first_outbox; + struct blogic_outbox *last_outbox; + struct blogic_outbox *next_outbox; + struct blogic_inbox *first_inbox; + struct blogic_inbox *last_inbox; + struct blogic_inbox *next_inbox; + struct blogic_tgt_stats tgt_stats[16]; + unsigned char *mbox_space; + dma_addr_t mbox_space_handle; + unsigned int mbox_sz; + long unsigned int ccb_offset; + char msgbuf[9700]; +}; + +struct blogic_outbox { + u32 ccb; + int: 24; + enum blogic_action action; +}; + +struct blogic_inbox { + u32 ccb; + enum blogic_adapter_status adapter_status; + enum blogic_tgt_status tgt_status; + char: 8; + enum blogic_cmplt_code comp_code; +}; + +struct blogic_drvr_options { + short unsigned int tagq_ok; + short unsigned int tagq_ok_mask; + short unsigned int bus_settle_time; + short unsigned int stop_tgt_inquiry; + unsigned char common_qdepth; + unsigned char qdepth[16]; +}; + +struct bios_diskparam { + int heads; + int sectors; + int cylinders; +}; + +struct scsi_inquiry { + unsigned char devtype: 5; + unsigned char dev_qual: 3; + unsigned char dev_modifier: 7; + bool rmb: 1; + unsigned char ansi_ver: 3; + unsigned char ecma_ver: 3; + unsigned char iso_ver: 2; + unsigned char resp_fmt: 4; + char: 2; + bool TrmIOP: 1; + bool AENC: 1; + unsigned char addl_len; + short: 16; + bool SftRe: 1; + bool CmdQue: 1; + char: 1; + bool linked: 1; + bool sync: 1; + bool WBus16: 1; + bool WBus32: 1; + bool RelAdr: 1; + unsigned char vendor[8]; + unsigned char product[16]; + unsigned char product_rev[4]; +}; + +typedef long unsigned int u_long; + +typedef enum { + CAM_REQ_INPROG = 0, + CAM_REQ_CMP = 1, + CAM_REQ_ABORTED = 2, + CAM_UA_ABORT = 3, + CAM_REQ_CMP_ERR = 4, + CAM_BUSY = 5, + CAM_REQ_INVALID = 6, + CAM_PATH_INVALID = 7, + CAM_SEL_TIMEOUT = 8, + CAM_CMD_TIMEOUT = 9, + CAM_SCSI_STATUS_ERROR = 10, + CAM_SCSI_BUS_RESET = 11, + CAM_UNCOR_PARITY = 12, + CAM_AUTOSENSE_FAIL = 13, + CAM_NO_HBA = 14, + CAM_DATA_RUN_ERR = 15, + CAM_UNEXP_BUSFREE = 16, + CAM_SEQUENCE_FAIL = 17, + CAM_CCB_LEN_ERR = 18, + CAM_PROVIDE_FAIL = 19, + CAM_BDR_SENT = 20, + CAM_REQ_TERMIO = 21, + CAM_UNREC_HBA_ERROR = 22, + CAM_REQ_TOO_BIG = 23, + CAM_UA_TERMIO = 24, + CAM_MSG_REJECT_REC = 25, + CAM_DEV_NOT_THERE = 26, + CAM_RESRC_UNAVAIL = 27, + CAM_REQUEUE_REQ = 28, + CAM_DEV_QFRZN = 64, + CAM_STATUS_MASK = 63, +} cam_status; + +enum { + CAM_DIR_IN = 2, + CAM_DIR_OUT = 1, + CAM_DIR_NONE = 3, +}; + +struct scsi_sense { + uint8_t opcode; + uint8_t byte2; + uint8_t unused[2]; + uint8_t length; + uint8_t control; +}; + +struct scsi_sense_data { + uint8_t error_code; + uint8_t segment; + uint8_t flags; + uint8_t info[4]; + uint8_t extra_len; + uint8_t cmd_spec_info[4]; + uint8_t add_sense_code; + uint8_t add_sense_code_qual; + uint8_t fru; + uint8_t sense_key_spec[3]; + uint8_t extra_bytes[14]; +}; + +typedef struct pci_dev *ahc_dev_softc_t; + +typedef struct scsi_cmnd *ahc_io_ctx_t; + +typedef uint32_t bus_size_t; + +typedef enum { + BUS_SPACE_MEMIO = 0, + BUS_SPACE_PIO = 1, +} bus_space_tag_t; + +typedef union { + u_long ioport; + volatile uint8_t *maddr; +} bus_space_handle_t; + +struct bus_dma_segment { + dma_addr_t ds_addr; + bus_size_t ds_len; +}; + +typedef struct bus_dma_segment bus_dma_segment_t; + +struct ahc_linux_dma_tag { + bus_size_t alignment; + bus_size_t boundary; + bus_size_t maxsize; +}; + +typedef struct ahc_linux_dma_tag *bus_dma_tag_t; + +typedef dma_addr_t bus_dmamap_t; + +struct ahc_reg_parse_entry { + char *name; + uint8_t value; + uint8_t mask; +}; + +typedef struct ahc_reg_parse_entry ahc_reg_parse_entry_t; + +typedef enum { + AHC_NONE = 0, + AHC_CHIPID_MASK = 255, + AHC_AIC7770 = 1, + AHC_AIC7850 = 2, + AHC_AIC7855 = 3, + AHC_AIC7859 = 4, + AHC_AIC7860 = 5, + AHC_AIC7870 = 6, + AHC_AIC7880 = 7, + AHC_AIC7895 = 8, + AHC_AIC7895C = 9, + AHC_AIC7890 = 10, + AHC_AIC7896 = 11, + AHC_AIC7892 = 12, + AHC_AIC7899 = 13, + AHC_VL = 256, + AHC_EISA = 512, + AHC_PCI = 1024, + AHC_BUS_MASK = 3840, +} ahc_chip; + +typedef enum { + AHC_FENONE = 0, + AHC_ULTRA = 1, + AHC_ULTRA2 = 2, + AHC_WIDE = 4, + AHC_TWIN = 8, + AHC_MORE_SRAM = 16, + AHC_CMD_CHAN = 32, + AHC_QUEUE_REGS = 64, + AHC_SG_PRELOAD = 128, + AHC_SPIOCAP = 256, + AHC_MULTI_TID = 512, + AHC_HS_MAILBOX = 1024, + AHC_DT = 2048, + AHC_NEW_TERMCTL = 4096, + AHC_MULTI_FUNC = 8192, + AHC_LARGE_SCBS = 16384, + AHC_AUTORATE = 32768, + AHC_AUTOPAUSE = 65536, + AHC_TARGETMODE = 131072, + AHC_MULTIROLE = 262144, + AHC_REMOVABLE = 524288, + AHC_HVD = 1048576, + AHC_AIC7770_FE = 0, + AHC_AIC7850_FE = 196865, + AHC_AIC7860_FE = 196865, + AHC_AIC7870_FE = 196608, + AHC_AIC7880_FE = 196609, + AHC_AIC7890_FE = 153330, + AHC_AIC7892_FE = 253682, + AHC_AIC7895_FE = 221233, + AHC_AIC7895C_FE = 221745, + AHC_AIC7896_FE = 161522, + AHC_AIC7899_FE = 261874, +} ahc_feature; + +typedef enum { + AHC_BUGNONE = 0, + AHC_TMODE_WIDEODD_BUG = 1, + AHC_AUTOFLUSH_BUG = 2, + AHC_CACHETHEN_BUG = 4, + AHC_CACHETHEN_DIS_BUG = 8, + AHC_PCI_2_1_RETRY_BUG = 16, + AHC_PCI_MWI_BUG = 32, + AHC_SCBCHAN_UPLOAD_BUG = 64, +} ahc_bug; + +typedef enum { + AHC_FNONE = 0, + AHC_PRIMARY_CHANNEL = 3, + AHC_USEDEFAULTS = 4, + AHC_SEQUENCER_DEBUG = 8, + AHC_SHARED_SRAM = 16, + AHC_LARGE_SEEPROM = 32, + AHC_RESET_BUS_A = 64, + AHC_RESET_BUS_B = 128, + AHC_EXTENDED_TRANS_A = 256, + AHC_EXTENDED_TRANS_B = 512, + AHC_TERM_ENB_A = 1024, + AHC_TERM_ENB_B = 2048, + AHC_INITIATORROLE = 4096, + AHC_TARGETROLE = 8192, + AHC_NEWEEPROM_FMT = 16384, + AHC_TQINFIFO_BLOCKED = 65536, + AHC_INT50_SPEEDFLEX = 131072, + AHC_SCB_BTT = 262144, + AHC_BIOS_ENABLED = 524288, + AHC_ALL_INTERRUPTS = 1048576, + AHC_PAGESCBS = 4194304, + AHC_EDGE_INTERRUPT = 8388608, + AHC_39BIT_ADDRESSING = 16777216, + AHC_LSCBS_ENABLED = 33554432, + AHC_SCB_CONFIG_USED = 67108864, + AHC_NO_BIOS_INIT = 134217728, + AHC_DISABLE_PCI_PERR = 268435456, + AHC_HAS_TERM_LOGIC = 536870912, +} ahc_flag; + +struct status_pkt { + uint32_t residual_datacnt; + uint32_t residual_sg_ptr; + uint8_t scsi_status; +}; + +struct target_data { + uint32_t residual_datacnt; + uint32_t residual_sg_ptr; + uint8_t scsi_status; + uint8_t target_phases; + uint8_t data_phase; + uint8_t initiator_tag; +}; + +struct hardware_scb { + union { + uint8_t cdb[12]; + uint32_t cdb_ptr; + struct status_pkt status; + struct target_data tdata; + } shared_data; + uint32_t dataptr; + uint32_t datacnt; + uint32_t sgptr; + uint8_t control; + uint8_t scsiid; + uint8_t lun; + uint8_t tag; + uint8_t cdb_len; + uint8_t scsirate; + uint8_t scsioffset; + uint8_t next; + uint8_t cdb32[32]; +}; + +struct ahc_dma_seg { + uint32_t addr; + uint32_t len; +}; + +struct sg_map_node { + bus_dmamap_t sg_dmamap; + dma_addr_t sg_physaddr; + struct ahc_dma_seg *sg_vaddr; + struct { + struct sg_map_node *sle_next; + } links; +}; + +typedef enum { + SCB_FREE = 0, + SCB_OTHERTCL_TIMEOUT = 2, + SCB_DEVICE_RESET = 4, + SCB_SENSE = 8, + SCB_CDB32_PTR = 16, + SCB_RECOVERY_SCB = 32, + SCB_AUTO_NEGOTIATE = 64, + SCB_NEGOTIATE = 128, + SCB_ABORT = 256, + SCB_UNTAGGEDQ = 512, + SCB_ACTIVE = 1024, + SCB_TARGET_IMMEDIATE = 2048, + SCB_TRANSMISSION_ERROR = 4096, + SCB_TARGET_SCB = 8192, + SCB_SILENT = 16384, +} scb_flag; + +struct ahc_softc; + +struct scb_platform_data; + +struct scb { + struct hardware_scb *hscb; + union { + struct { + struct scb *sle_next; + } sle; + struct { + struct scb *tqe_next; + struct scb **tqe_prev; + } tqe; + } links; + struct { + struct scb *le_next; + struct scb **le_prev; + } pending_links; + ahc_io_ctx_t io_ctx; + struct ahc_softc *ahc_softc; + scb_flag flags; + struct scb_platform_data *platform_data; + struct sg_map_node *sg_map; + struct ahc_dma_seg *sg_list; + dma_addr_t sg_list_phys; + u_int sg_count; +}; + +struct scb_tailq { + struct scb *tqh_first; + struct scb **tqh_last; +}; + +struct ahc_aic7770_softc { + uint8_t busspd; + uint8_t bustime; +}; + +struct ahc_pci_softc { + uint32_t devconfig; + uint16_t targcrccnt; + uint8_t command; + uint8_t csize_lattime; + uint8_t optionmode; + uint8_t crccontrol1; + uint8_t dscommand0; + uint8_t dspcistatus; + uint8_t scbbaddr; + uint8_t dff_thrsh; +}; + +union ahc_bus_softc { + struct ahc_aic7770_softc aic7770_softc; + struct ahc_pci_softc pci_softc; +}; + +typedef void (*ahc_bus_intr_t)(struct ahc_softc *); + +typedef int (*ahc_bus_chip_init_t)(struct ahc_softc *); + +struct ahc_tmode_lstate; + +typedef enum { + MSG_TYPE_NONE = 0, + MSG_TYPE_INITIATOR_MSGOUT = 1, + MSG_TYPE_INITIATOR_MSGIN = 2, + MSG_TYPE_TARGET_MSGOUT = 3, + MSG_TYPE_TARGET_MSGIN = 4, +} ahc_msg_type; + +struct scb_data; + +struct ahc_platform_data; + +struct ahc_tmode_tstate; + +struct seeprom_config; + +struct cs; + +struct target_cmd; + +struct ahc_softc { + bus_space_tag_t tag; + bus_space_handle_t bsh; + struct scb_data *scb_data; + struct scb *next_queued_scb; + struct { + struct scb *lh_first; + } pending_scbs; + u_int untagged_queue_lock; + struct scb_tailq untagged_queues[16]; + union ahc_bus_softc bus_softc; + struct ahc_platform_data *platform_data; + ahc_dev_softc_t dev_softc; + struct device *dev; + ahc_bus_intr_t bus_intr; + ahc_bus_chip_init_t bus_chip_init; + struct ahc_tmode_tstate *enabled_targets[16]; + struct ahc_tmode_lstate *black_hole; + struct ahc_tmode_lstate *pending_device; + ahc_chip chip; + ahc_feature features; + ahc_bug bugs; + ahc_flag flags; + struct seeprom_config *seep_config; + uint8_t unpause; + uint8_t pause; + uint8_t qoutfifonext; + uint8_t qinfifonext; + uint8_t *qoutfifo; + uint8_t *qinfifo; + struct cs *critical_sections; + u_int num_critical_sections; + char channel; + char channel_b; + uint8_t our_id; + uint8_t our_id_b; + int unsolicited_ints; + struct target_cmd *targetcmds; + uint8_t tqinfifonext; + uint8_t seqctl; + uint8_t send_msg_perror; + ahc_msg_type msg_type; + uint8_t msgout_buf[12]; + uint8_t msgin_buf[12]; + u_int msgout_len; + u_int msgout_index; + u_int msgin_index; + bus_dma_tag_t parent_dmat; + bus_dma_tag_t shared_data_dmat; + bus_dmamap_t shared_data_dmamap; + dma_addr_t shared_data_busaddr; + dma_addr_t dma_bug_buf; + u_int enabled_luns; + u_int init_level; + u_int pci_cachesize; + u_int pci_target_perr_count; + u_int instruction_ram_size; + const char *description; + char *name; + int unit; + int seltime; + int seltime_b; + uint16_t user_discenable; + uint16_t user_tagenable; +}; + +struct ahc_linux_device; + +struct scb_platform_data { + struct ahc_linux_device *dev; + dma_addr_t buf_busaddr; + uint32_t xfer_len; + uint32_t sense_resid; +}; + +struct scb_data { + struct { + struct scb *slh_first; + } free_scbs; + struct scb *scbindex[256]; + struct hardware_scb *hscbs; + struct scb *scbarray; + struct scsi_sense_data *sense; + bus_dma_tag_t hscb_dmat; + bus_dmamap_t hscb_dmamap; + dma_addr_t hscb_busaddr; + bus_dma_tag_t sense_dmat; + bus_dmamap_t sense_dmamap; + dma_addr_t sense_busaddr; + bus_dma_tag_t sg_dmat; + struct { + struct sg_map_node *slh_first; + } sg_maps; + uint8_t numscbs; + uint8_t maxhscbs; + uint8_t init_level; +}; + +struct target_cmd { + uint8_t scsiid; + uint8_t identify; + uint8_t bytes[22]; + uint8_t cmd_valid; + uint8_t pad[7]; +}; + +struct ahc_transinfo { + uint8_t protocol_version; + uint8_t transport_version; + uint8_t width; + uint8_t period; + uint8_t offset; + uint8_t ppr_options; +}; + +struct ahc_initiator_tinfo { + uint8_t scsirate; + struct ahc_transinfo curr; + struct ahc_transinfo goal; + struct ahc_transinfo user; +}; + +struct ahc_tmode_tstate { + struct ahc_tmode_lstate *enabled_luns[64]; + struct ahc_initiator_tinfo transinfo[16]; + uint16_t auto_negotiate; + uint16_t ultraenb; + uint16_t discenable; + uint16_t tagenable; +}; + +struct ahc_syncrate { + u_int sxfr_u2; + u_int sxfr; + uint8_t period; + const char *rate; +}; + +struct ahc_phase_table_entry { + uint8_t phase; + uint8_t mesg_out; + char *phasemsg; +}; + +struct seeprom_config { + uint16_t device_flags[16]; + uint16_t bios_control; + uint16_t adapter_control; + uint16_t brtime_id; + uint16_t max_targets; + uint16_t res_1[10]; + uint16_t signature; + uint16_t checksum; +}; + +enum { + MSGLOOP_IN_PROG = 0, + MSGLOOP_MSGCOMPLETE = 1, + MSGLOOP_TERMINATED = 2, +}; + +struct ahc_platform_data { + struct scsi_target *starget[16]; + spinlock_t spin_lock; + u_int qfrozen; + struct completion *eh_done; + struct Scsi_Host *host; + uint32_t irq; + uint32_t bios_address; + resource_size_t mem_busaddr; +}; + +struct cs { + uint16_t begin; + uint16_t end; +}; + +typedef enum { + ROLE_UNKNOWN = 0, + ROLE_INITIATOR = 1, + ROLE_TARGET = 2, +} role_t; + +struct ahc_devinfo { + int our_scsiid; + int target_offset; + uint16_t target_mask; + u_int target; + u_int lun; + char channel; + role_t role; +}; + +typedef enum { + SEARCH_COMPLETE = 0, + SEARCH_COUNT = 1, + SEARCH_REMOVE = 2, +} ahc_search_action; + +typedef enum { + AHC_NEG_TO_GOAL = 0, + AHC_NEG_IF_NON_ASYNC = 1, + AHC_NEG_ALWAYS = 2, +} ahc_neg_type; + +typedef enum { + AHC_QUEUE_NONE = 0, + AHC_QUEUE_BASIC = 1, + AHC_QUEUE_TAGGED = 2, +} ahc_queue_alg; + +typedef enum { + AHC_DEV_FREEZE_TIL_EMPTY = 2, + AHC_DEV_Q_BASIC = 16, + AHC_DEV_Q_TAGGED = 32, + AHC_DEV_PERIODIC_OTAG = 64, +} ahc_linux_dev_flags; + +struct ahc_linux_device { + int active; + int openings; + u_int qfrozen; + u_long commands_issued; + u_int tag_success_count; + ahc_linux_dev_flags flags; + u_int maxtags; + u_int tags_on_last_queuefull; + u_int last_queuefull_same_count; + u_int commands_since_idle_or_otag; +}; + +struct ins_format1 { + uint32_t immediate: 8; + uint32_t source: 9; + uint32_t destination: 9; + uint32_t ret: 1; + uint32_t opcode: 4; + uint32_t parity: 1; +}; + +struct ins_format2 { + uint32_t shift_control: 8; + uint32_t source: 9; + uint32_t destination: 9; + uint32_t ret: 1; + uint32_t opcode: 4; + uint32_t parity: 1; +}; + +struct ins_format3 { + uint32_t immediate: 8; + uint32_t source: 9; + uint32_t address: 10; + uint32_t opcode: 4; + uint32_t parity: 1; +}; + +struct ins_format4 { + uint32_t opcode_ext: 8; + uint32_t source: 9; + uint32_t destination: 9; + uint32_t ret: 1; + uint32_t opcode: 4; + uint32_t parity: 1; +}; + +struct ins_format5 { + uint32_t opcode_ext: 8; + uint32_t source: 9; + uint32_t address: 10; + uint32_t opcode: 4; + uint32_t parity: 1; +}; + +struct ins_format6 { + uint32_t page: 3; + uint32_t opcode_ext: 5; + uint32_t source: 9; + uint32_t address: 10; + uint32_t opcode: 4; + uint32_t parity: 1; +}; + +union ins_formats { + struct ins_format1 format1; + struct ins_format2 format2; + struct ins_format3 format3; + struct ins_format4 format4; + struct ins_format5 format5; + struct ins_format6 format6; + uint8_t bytes[4]; + uint32_t integer; +}; + +struct ahc_hard_error_entry { + uint8_t errno; + const char *errmesg; +}; + +typedef int ahc_patch_func_t(struct ahc_softc *); + +struct patch { + ahc_patch_func_t *patch_func; + uint32_t begin: 10; + uint32_t skip_instr: 10; + uint32_t skip_patch: 12; +}; + +typedef enum { + AHCMSG_1B = 0, + AHCMSG_2B = 1, + AHCMSG_EXT = 2, +} ahc_msgtype; + +typedef enum { + C46 = 6, + C56_66 = 8, +} seeprom_chip_t; + +struct seeprom_descriptor { + struct ahc_softc *sd_ahc; + u_int sd_control_offset; + u_int sd_status_offset; + u_int sd_dataout_offset; + seeprom_chip_t sd_chip; + uint16_t sd_MS; + uint16_t sd_RDY; + uint16_t sd_CS; + uint16_t sd_CK; + uint16_t sd_DO; + uint16_t sd_DI; +}; + +struct seeprom_cmd { + uint8_t len; + uint8_t bits[11]; +}; + +typedef int ahc_device_setup_t(struct ahc_softc *); + +struct ahc_pci_identity { + uint64_t full_id; + uint64_t id_mask; + const char *name; + ahc_device_setup_t *setup; +}; + +enum { + AHC_POWER_STATE_D0 = 0, + AHC_POWER_STATE_D1 = 1, + AHC_POWER_STATE_D2 = 2, + AHC_POWER_STATE_D3 = 3, +}; + +typedef enum { + AC_GETDEV_CHANGED = 2048, + AC_INQ_CHANGED = 1024, + AC_TRANSFER_NEG = 512, + AC_LOST_DEVICE = 256, + AC_FOUND_DEVICE = 128, + AC_PATH_DEREGISTERED = 64, + AC_PATH_REGISTERED = 32, + AC_SENT_BDR = 16, + AC_SCSI_AEN = 8, + AC_UNSOL_RESEL = 2, + AC_BUS_RESET = 1, +} ac_code; + +typedef int bus_dma_filter_t(void *, dma_addr_t); + +typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); + +typedef struct { + uint8_t tag_commands[16]; +} adapter_tag_info_t; + +typedef u16 u_int16_t; + +struct scsi_status_iu_header { + u_int8_t reserved[2]; + u_int8_t flags; + u_int8_t status; + u_int8_t sense_length[4]; + u_int8_t pkt_failures_length[4]; + u_int8_t pkt_failures[1]; +}; + +typedef struct pci_dev *ahd_dev_softc_t; + +typedef struct scsi_cmnd *ahd_io_ctx_t; + +struct ahd_linux_dma_tag { + bus_size_t alignment; + bus_size_t boundary; + bus_size_t maxsize; +}; + +typedef struct ahd_linux_dma_tag *bus_dma_tag_t___2; + +struct ahd_reg_parse_entry { + char *name; + uint8_t value; + uint8_t mask; +}; + +typedef struct ahd_reg_parse_entry ahd_reg_parse_entry_t; + +typedef enum { + AHD_NONE = 0, + AHD_CHIPID_MASK = 255, + AHD_AIC7901 = 1, + AHD_AIC7902 = 2, + AHD_AIC7901A = 3, + AHD_PCI = 256, + AHD_PCIX = 512, + AHD_BUS_MASK = 3840, +} ahd_chip; + +typedef enum { + AHD_FENONE = 0, + AHD_WIDE = 1, + AHD_AIC79XXB_SLOWCRC = 2, + AHD_MULTI_FUNC = 256, + AHD_TARGETMODE = 4096, + AHD_MULTIROLE = 8192, + AHD_RTI = 16384, + AHD_NEW_IOCELL_OPTS = 32768, + AHD_NEW_DFCNTRL_OPTS = 65536, + AHD_FAST_CDB_DELIVERY = 131072, + AHD_REMOVABLE = 0, + AHD_AIC7901_FE = 0, + AHD_AIC7901A_FE = 0, + AHD_AIC7902_FE = 256, +} ahd_feature; + +typedef enum { + AHD_BUGNONE = 0, + AHD_SENT_SCB_UPDATE_BUG = 1, + AHD_ABORT_LQI_BUG = 2, + AHD_PKT_BITBUCKET_BUG = 4, + AHD_LONG_SETIMO_BUG = 8, + AHD_NLQICRC_DELAYED_BUG = 16, + AHD_SCSIRST_BUG = 32, + AHD_PCIX_CHIPRST_BUG = 64, + AHD_PCIX_MMAPIO_BUG = 128, + AHD_PCIX_SCBRAM_RD_BUG = 256, + AHD_PCIX_BUG_MASK = 448, + AHD_LQO_ATNO_BUG = 512, + AHD_AUTOFLUSH_BUG = 1024, + AHD_CLRLQO_AUTOCLR_BUG = 2048, + AHD_PKTIZED_STATUS_BUG = 4096, + AHD_PKT_LUN_BUG = 8192, + AHD_NONPACKFIFO_BUG = 16384, + AHD_MDFF_WSCBPTR_BUG = 32768, + AHD_REG_SLOW_SETTLE_BUG = 65536, + AHD_SET_MODE_BUG = 131072, + AHD_BUSFREEREV_BUG = 262144, + AHD_PACED_NEGTABLE_BUG = 524288, + AHD_LQOOVERRUN_BUG = 1048576, + AHD_INTCOLLISION_BUG = 2097152, + AHD_EARLY_REQ_BUG = 4194304, + AHD_FAINT_LED_BUG = 8388608, +} ahd_bug; + +typedef enum { + AHD_FNONE = 0, + AHD_BOOT_CHANNEL = 1, + AHD_USEDEFAULTS = 4, + AHD_SEQUENCER_DEBUG = 8, + AHD_RESET_BUS_A = 16, + AHD_EXTENDED_TRANS_A = 32, + AHD_TERM_ENB_A = 64, + AHD_SPCHK_ENB_A = 128, + AHD_STPWLEVEL_A = 256, + AHD_INITIATORROLE = 512, + AHD_TARGETROLE = 1024, + AHD_RESOURCE_SHORTAGE = 2048, + AHD_TQINFIFO_BLOCKED = 4096, + AHD_INT50_SPEEDFLEX = 8192, + AHD_BIOS_ENABLED = 16384, + AHD_ALL_INTERRUPTS = 32768, + AHD_39BIT_ADDRESSING = 65536, + AHD_64BIT_ADDRESSING = 131072, + AHD_CURRENT_SENSING = 262144, + AHD_SCB_CONFIG_USED = 524288, + AHD_HP_BOARD = 1048576, + AHD_BUS_RESET_ACTIVE = 2097152, + AHD_UPDATE_PEND_CMDS = 4194304, + AHD_RUNNING_QOUTFIFO = 8388608, + AHD_HAD_FIRST_SEL = 16777216, +} ahd_flag; + +struct initiator_status { + uint32_t residual_datacnt; + uint32_t residual_sgptr; + uint8_t scsi_status; +}; + +struct target_status { + uint32_t residual_datacnt; + uint32_t residual_sgptr; + uint8_t scsi_status; + uint8_t target_phases; + uint8_t data_phase; + uint8_t initiator_tag; +}; + +typedef uint32_t sense_addr_t; + +union initiator_data { + struct { + uint64_t cdbptr; + uint8_t cdblen; + } cdb_from_host; + uint8_t cdb[16]; + struct { + uint8_t cdb[12]; + sense_addr_t sense_addr; + } cdb_plus_saddr; +}; + +struct target_data___2 { + uint32_t spare[2]; + uint8_t scsi_status; + uint8_t target_phases; + uint8_t data_phase; + uint8_t initiator_tag; +}; + +struct hardware_scb___2 { + union { + union initiator_data idata; + struct target_data___2 tdata; + struct initiator_status istatus; + struct target_status tstatus; + } shared_data; + uint16_t tag; + uint8_t control; + uint8_t scsiid; + uint8_t lun; + uint8_t task_attribute; + uint8_t cdb_len; + uint8_t task_management; + uint64_t dataptr; + uint32_t datacnt; + uint32_t sgptr; + uint32_t hscb_busaddr; + uint32_t next_hscb_busaddr; + uint8_t pkt_long_lun[8]; + uint8_t spare[8]; +}; + +struct ahd_dma_seg { + uint32_t addr; + uint32_t len; +}; + +struct ahd_dma64_seg { + uint64_t addr; + uint32_t len; + uint32_t pad; +}; + +struct map_node { + bus_dmamap_t dmamap; + dma_addr_t physaddr; + uint8_t *vaddr; + struct { + struct map_node *sle_next; + } links; +}; + +typedef enum { + SCB_FLAG_NONE = 0, + SCB_TRANSMISSION_ERROR___2 = 1, + SCB_OTHERTCL_TIMEOUT___2 = 2, + SCB_DEVICE_RESET___2 = 4, + SCB_SENSE___2 = 8, + SCB_CDB32_PTR___2 = 16, + SCB_RECOVERY_SCB___2 = 32, + SCB_AUTO_NEGOTIATE___2 = 64, + SCB_NEGOTIATE___2 = 128, + SCB_ABORT___2 = 256, + SCB_ACTIVE___2 = 512, + SCB_TARGET_IMMEDIATE___2 = 1024, + SCB_PACKETIZED = 2048, + SCB_EXPECT_PPR_BUSFREE = 4096, + SCB_PKT_SENSE = 8192, + SCB_EXTERNAL_RESET = 16384, + SCB_ON_COL_LIST = 32768, + SCB_SILENT___2 = 65536, +} scb_flag___2; + +struct ahd_softc; + +struct scb_platform_data___2; + +struct scb___2 { + struct hardware_scb___2 *hscb; + union { + struct { + struct scb___2 *sle_next; + } sle; + struct { + struct scb___2 *le_next; + struct scb___2 **le_prev; + } le; + struct { + struct scb___2 *tqe_next; + struct scb___2 **tqe_prev; + } tqe; + } links; + union { + struct { + struct scb___2 *sle_next; + } sle; + struct { + struct scb___2 *le_next; + struct scb___2 **le_prev; + } le; + struct { + struct scb___2 *tqe_next; + struct scb___2 **tqe_prev; + } tqe; + } links2; + struct scb___2 *col_scb; + ahd_io_ctx_t io_ctx; + struct ahd_softc *ahd_softc; + scb_flag___2 flags; + struct scb_platform_data___2 *platform_data; + struct map_node *hscb_map; + struct map_node *sg_map; + struct map_node *sense_map; + void *sg_list; + uint8_t *sense_data; + dma_addr_t sg_list_busaddr; + dma_addr_t sense_busaddr; + u_int sg_count; + u_int crc_retry_count; +}; + +struct scb_tailq___2 { + struct scb___2 *tqh_first; + struct scb___2 **tqh_last; +}; + +struct scb_list { + struct scb___2 *lh_first; +}; + +struct scb_data___2 { + struct scb_tailq___2 free_scbs; + struct scb_list free_scb_lists[1024]; + struct scb_list any_dev_free_scb_list; + struct scb___2 *scbindex[512]; + bus_dma_tag_t___2 hscb_dmat; + bus_dma_tag_t___2 sg_dmat; + bus_dma_tag_t___2 sense_dmat; + struct { + struct map_node *slh_first; + } hscb_maps; + struct { + struct map_node *slh_first; + } sg_maps; + struct { + struct map_node *slh_first; + } sense_maps; + int scbs_left; + int sgs_left; + int sense_left; + uint16_t numscbs; + uint16_t maxhscbs; + uint8_t init_level; +}; + +typedef enum { + AHD_MODE_DFF0 = 0, + AHD_MODE_DFF1 = 1, + AHD_MODE_CCHAN = 2, + AHD_MODE_SCSI = 3, + AHD_MODE_CFG = 4, + AHD_MODE_UNKNOWN = 5, +} ahd_mode; + +typedef void (*ahd_bus_intr_t)(struct ahd_softc *); + +struct ahd_tmode_lstate; + +typedef enum { + MSG_FLAG_NONE = 0, + MSG_FLAG_EXPECT_PPR_BUSFREE = 1, + MSG_FLAG_IU_REQ_CHANGED = 2, + MSG_FLAG_EXPECT_IDE_BUSFREE = 4, + MSG_FLAG_EXPECT_QASREJ_BUSFREE = 8, + MSG_FLAG_PACKETIZED = 16, +} ahd_msg_flags; + +typedef enum { + MSG_TYPE_NONE___2 = 0, + MSG_TYPE_INITIATOR_MSGOUT___2 = 1, + MSG_TYPE_INITIATOR_MSGIN___2 = 2, + MSG_TYPE_TARGET_MSGOUT___2 = 3, + MSG_TYPE_TARGET_MSGIN___2 = 4, +} ahd_msg_type; + +struct ahd_suspend_channel_state { + uint8_t scsiseq; + uint8_t sxfrctl0; + uint8_t sxfrctl1; + uint8_t simode0; + uint8_t simode1; + uint8_t seltimer; + uint8_t seqctl; +}; + +struct ahd_suspend_pci_state { + uint32_t devconfig; + uint8_t command; + uint8_t csize_lattime; +}; + +struct ahd_suspend_state { + struct ahd_suspend_channel_state channel[2]; + struct ahd_suspend_pci_state pci_state; + uint8_t optionmode; + uint8_t dscommand0; + uint8_t dspcistatus; + uint8_t crccontrol1; + uint8_t scbbaddr; + uint8_t dff_thrsh; + uint8_t *scratch_ram; + uint8_t *btt; +}; + +struct ahd_platform_data; + +struct ahd_tmode_tstate; + +struct ahd_completion; + +struct ahd_softc { + bus_space_tag_t tags[2]; + bus_space_handle_t bshs[2]; + struct scb_data___2 scb_data; + struct hardware_scb___2 *next_queued_hscb; + struct map_node *next_queued_hscb_map; + struct { + struct scb___2 *lh_first; + } pending_scbs; + ahd_mode dst_mode; + ahd_mode src_mode; + ahd_mode saved_dst_mode; + ahd_mode saved_src_mode; + struct ahd_platform_data *platform_data; + ahd_dev_softc_t dev_softc; + ahd_bus_intr_t bus_intr; + struct ahd_tmode_tstate *enabled_targets[16]; + struct ahd_tmode_lstate *black_hole; + struct ahd_tmode_lstate *pending_device; + struct timer_list stat_timer; + u_int cmdcmplt_bucket; + uint32_t cmdcmplt_counts[4]; + uint32_t cmdcmplt_total; + ahd_chip chip; + ahd_feature features; + ahd_bug bugs; + ahd_flag flags; + struct seeprom_config *seep_config; + struct ahd_completion *qoutfifo; + uint16_t qoutfifonext; + uint16_t qoutfifonext_valid_tag; + uint16_t qinfifonext; + uint16_t qinfifo[512]; + uint16_t qfreeze_cnt; + uint8_t unpause; + uint8_t pause; + struct cs *critical_sections; + u_int num_critical_sections; + uint8_t *overrun_buf; + struct { + struct ahd_softc *tqe_next; + struct ahd_softc **tqe_prev; + } links; + char channel; + uint8_t our_id; + struct target_cmd *targetcmds; + uint8_t tqinfifonext; + uint8_t hs_mailbox; + uint8_t send_msg_perror; + ahd_msg_flags msg_flags; + ahd_msg_type msg_type; + uint8_t msgout_buf[12]; + uint8_t msgin_buf[12]; + u_int msgout_len; + u_int msgout_index; + u_int msgin_index; + bus_dma_tag_t___2 parent_dmat; + bus_dma_tag_t___2 shared_data_dmat; + struct map_node shared_data_map; + struct ahd_suspend_state suspend_state; + u_int enabled_luns; + u_int init_level; + u_int pci_cachesize; + uint8_t iocell_opts[4]; + u_int stack_size; + uint16_t *saved_stack; + const char *description; + const char *bus_description; + char *name; + int unit; + int seltime; + u_int int_coalescing_timer; + u_int int_coalescing_maxcmds; + u_int int_coalescing_mincmds; + u_int int_coalescing_threshold; + u_int int_coalescing_stop_threshold; + uint16_t user_discenable; + uint16_t user_tagenable; +}; + +struct ahd_linux_device; + +struct scb_platform_data___2 { + struct ahd_linux_device *dev; + dma_addr_t buf_busaddr; + uint32_t xfer_len; + uint32_t sense_resid; +}; + +struct ahd_transinfo { + uint8_t protocol_version; + uint8_t transport_version; + uint8_t width; + uint8_t period; + uint8_t offset; + uint8_t ppr_options; +}; + +struct ahd_initiator_tinfo { + struct ahd_transinfo curr; + struct ahd_transinfo goal; + struct ahd_transinfo user; +}; + +struct ahd_tmode_tstate { + struct ahd_tmode_lstate *enabled_luns[256]; + struct ahd_initiator_tinfo transinfo[16]; + uint16_t auto_negotiate; + uint16_t discenable; + uint16_t tagenable; +}; + +struct ahd_phase_table_entry { + uint8_t phase; + uint8_t mesg_out; + const char *phasemsg; +}; + +struct vpd_config { + uint8_t bios_flags; + uint8_t reserved_1[21]; + uint8_t resource_type; + uint8_t resource_len[2]; + uint8_t resource_data[8]; + uint8_t vpd_tag; + uint16_t vpd_len; + uint8_t vpd_keyword[2]; + uint8_t length; + uint8_t revision; + uint8_t device_flags; + uint8_t termination_menus[2]; + uint8_t fifo_threshold; + uint8_t end_tag; + uint8_t vpd_checksum; + uint16_t default_target_flags; + uint16_t default_bios_flags; + uint16_t default_ctrl_flags; + uint8_t default_irq; + uint8_t pci_lattime; + uint8_t max_target; + uint8_t boot_lun; + uint16_t signature; + uint8_t reserved_2; + uint8_t checksum; + uint8_t reserved_3[4]; +}; + +typedef uint8_t ahd_mode_state; + +struct ahd_completion { + uint16_t tag; + uint8_t sg_status; + uint8_t valid_tag; +}; + +struct ahd_platform_data { + struct scsi_target *starget[16]; + spinlock_t spin_lock; + struct completion *eh_done; + struct Scsi_Host *host; + uint32_t irq; + uint32_t bios_address; + resource_size_t mem_busaddr; +}; + +struct ahd_devinfo { + int our_scsiid; + int target_offset; + uint16_t target_mask; + u_int target; + u_int lun; + char channel; + role_t role; +}; + +typedef enum { + SEARCH_COMPLETE___2 = 0, + SEARCH_COUNT___2 = 1, + SEARCH_REMOVE___2 = 2, + SEARCH_PRINT = 3, +} ahd_search_action; + +typedef enum { + AHD_NEG_TO_GOAL = 0, + AHD_NEG_IF_NON_ASYNC = 1, + AHD_NEG_ALWAYS = 2, +} ahd_neg_type; + +typedef enum { + AHD_QUEUE_NONE = 0, + AHD_QUEUE_BASIC = 1, + AHD_QUEUE_TAGGED = 2, +} ahd_queue_alg; + +typedef enum { + AHD_DEV_FREEZE_TIL_EMPTY = 2, + AHD_DEV_Q_BASIC = 16, + AHD_DEV_Q_TAGGED = 32, + AHD_DEV_PERIODIC_OTAG = 64, +} ahd_linux_dev_flags; + +struct ahd_linux_device { + struct { + struct ahd_linux_device *tqe_next; + struct ahd_linux_device **tqe_prev; + } links; + int active; + int openings; + u_int qfrozen; + u_long commands_issued; + u_int tag_success_count; + ahd_linux_dev_flags flags; + struct timer_list timer; + u_int maxtags; + u_int tags_on_last_queuefull; + u_int last_queuefull_same_count; + u_int commands_since_idle_or_otag; +}; + +struct ahd_hard_error_entry { + uint8_t errno; + const char *errmesg; +}; + +typedef int ahd_patch_func_t(struct ahd_softc *); + +struct patch___2 { + ahd_patch_func_t *patch_func; + uint32_t begin: 10; + uint32_t skip_instr: 10; + uint32_t skip_patch: 12; +}; + +typedef enum { + AHDMSG_1B = 0, + AHDMSG_2B = 1, + AHDMSG_EXT = 2, +} ahd_msgtype; + +typedef int ahd_device_setup_t(struct ahd_softc *); + +struct ahd_pci_identity { + uint64_t full_id; + uint64_t id_mask; + const char *name; + ahd_device_setup_t *setup; +}; + +typedef struct { + uint16_t tag_commands[16]; +} adapter_tag_info_t___2; + +struct ahd_linux_iocell_opts { + uint8_t precomp; + uint8_t slewrate; + uint8_t amplitude; +}; + +typedef enum { + AHD_POWER_STATE_D0 = 0, + AHD_POWER_STATE_D1 = 1, + AHD_POWER_STATE_D2 = 2, + AHD_POWER_STATE_D3 = 3, +} ahd_power_state; + +enum { + AAC_ENABLE_INTERRUPT = 0, + AAC_DISABLE_INTERRUPT = 1, + AAC_ENABLE_MSIX = 2, + AAC_DISABLE_MSIX = 3, + AAC_CLEAR_AIF_BIT = 4, + AAC_CLEAR_SYNC_BIT = 5, + AAC_ENABLE_INTX = 6, +}; + +struct aac_hba_sgl { + u32 addr_lo; + u32 addr_hi; + u32 len; + u32 flags; +}; + +enum { + HBA_IU_TYPE_SCSI_CMD_REQ = 64, + HBA_IU_TYPE_SCSI_TM_REQ = 65, + HBA_IU_TYPE_SATA_REQ = 66, + HBA_IU_TYPE_RESP = 96, + HBA_IU_TYPE_COALESCED_RESP = 97, + HBA_IU_TYPE_INT_COALESCING_CFG_REQ = 112, +}; + +enum { + HBA_RESP_SVCRES_TASK_COMPLETE = 0, + HBA_RESP_SVCRES_FAILURE = 1, + HBA_RESP_SVCRES_TMF_COMPLETE = 2, + HBA_RESP_SVCRES_TMF_SUCCEEDED = 3, + HBA_RESP_SVCRES_TMF_REJECTED = 4, + HBA_RESP_SVCRES_TMF_LUN_INVALID = 5, +}; + +struct aac_hba_cmd_req { + u8 iu_type; + u8 byte1; + u8 reply_qid; + u8 reserved1; + __le32 it_nexus; + __le32 request_id; + __le32 tweak_value_lo; + u8 cdb[16]; + u8 lun[8]; + __le32 data_length; + u8 attr_prio; + u8 emb_data_desc_count; + __le16 dek_index; + __le32 error_ptr_lo; + __le32 error_ptr_hi; + __le32 error_length; + __le32 tweak_value_hi; + struct aac_hba_sgl sge[92]; +}; + +struct aac_hba_tm_req { + u8 iu_type; + u8 reply_qid; + u8 tmf; + u8 reserved1; + __le32 it_nexus; + u8 lun[8]; + __le32 request_id; + __le32 reserved2; + __le32 managed_request_id; + __le32 reserved3; + __le32 error_ptr_lo; + __le32 error_ptr_hi; + __le32 error_length; +}; + +struct aac_hba_reset_req { + u8 iu_type; + u8 reset_type; + u8 reply_qid; + u8 reserved1; + __le32 it_nexus; + __le32 request_id; + __le32 error_ptr_lo; + __le32 error_ptr_hi; + __le32 error_length; +}; + +struct aac_hba_resp { + u8 iu_type; + u8 reserved1[3]; + __le32 request_identifier; + __le32 reserved2; + u8 service_response; + u8 status; + u8 datapres; + u8 sense_response_data_len; + __le32 residual_count; + u8 sense_response_buf[32]; +}; + +struct aac_native_hba { + union { + struct aac_hba_cmd_req cmd; + struct aac_hba_tm_req tmr; + u8 cmd_bytes[1536]; + } cmd; + union { + struct aac_hba_resp err; + u8 resp_bytes[512]; + } resp; +}; + +struct _ciss_lun { + u8 tid[3]; + u8 bus; + u8 level3[2]; + u8 level2[2]; + u8 node_ident[16]; +}; + +struct aac_ciss_phys_luns_resp { + u8 list_length[4]; + u8 resp_flag; + u8 reserved[3]; + struct _ciss_lun lun[1]; +}; + +struct aac_ciss_identify_pd { + u8 scsi_bus; + u8 scsi_id; + u16 block_size; + u32 total_blocks; + u32 reserved_blocks; + u8 model[40]; + u8 serial_number[40]; + u8 firmware_revision[8]; + u8 scsi_inquiry_bits; + u8 compaq_drive_stamp; + u8 last_failure_reason; + u8 flags; + u8 more_flags; + u8 scsi_lun; + u8 yet_more_flags; + u8 even_more_flags; + u32 spi_speed_rules; + u8 phys_connector[2]; + u8 phys_box_on_bus; + u8 phys_bay_in_box; + u32 rpm; + u8 device_type; + u8 sata_version; + u64 big_total_block_count; + u64 ris_starting_lba; + u32 ris_size; + u8 wwid[20]; + u8 controller_phy_map[32]; + u16 phy_count; + u8 phy_connected_dev_type[256]; + u8 phy_to_drive_bay_num[256]; + u16 phy_to_attached_dev_index[256]; + u8 box_index; + u8 spitfire_support; + u16 extra_physical_drive_flags; + u8 negotiated_link_rate[256]; + u8 phy_to_phy_map[256]; + u8 redundant_path_present_map; + u8 redundant_path_failure_map; + u8 active_path_number; + u16 alternate_paths_phys_connector[8]; + u8 alternate_paths_phys_box_on_port[8]; + u8 multi_lun_device_lun_count; + u8 minimum_good_fw_revision[8]; + u8 unique_inquiry_bytes[20]; + u8 current_temperature_degreesC; + u8 temperature_threshold_degreesC; + u8 max_temperature_degreesC; + u8 logical_blocks_per_phys_block_exp; + u16 current_queue_depth_limit; + u8 switch_name[10]; + u16 switch_port; + u8 alternate_paths_switch_name[40]; + u8 alternate_paths_switch_port[8]; + u16 power_on_hours; + u16 percent_endurance_used; + u8 drive_authentication; + u8 smart_carrier_authentication; + u8 smart_carrier_app_fw_version; + u8 smart_carrier_bootloader_fw_version; + u8 SanitizeSecureEraseSupport; + u8 DriveKeyFlags; + u8 encryption_key_name[64]; + u32 misc_drive_flags; + u16 dek_index; + u16 drive_encryption_flags; + u8 sanitize_maximum_time[6]; + u8 connector_info_mode; + u8 connector_info_number[4]; + u8 long_connector_name[64]; + u8 device_unique_identifier[16]; + u8 padto_2K[17]; +} __attribute__((packed)); + +struct diskparm { + int heads; + int sectors; + int cylinders; +}; + +struct aac_entry { + __le32 size; + __le32 addr; +}; + +struct aac_qhdr { + __le64 header_addr; + __le32 *producer; + __le32 *consumer; +}; + +struct aac_fibhdr { + __le32 XferState; + __le16 Command; + u8 StructType; + u8 Unused; + __le16 Size; + __le16 SenderSize; + __le32 SenderFibAddress; + union { + __le32 ReceiverFibAddress; + __le32 SenderFibAddressHigh; + __le32 TimeStamp; + } u; + __le32 Handle; + u32 Previous; + u32 Next; +}; + +struct hw_fib { + struct aac_fibhdr header; + u8 data[480]; +}; + +enum fib_xfer_state { + HostOwned = 1, + AdapterOwned = 2, + FibInitialized = 4, + FibEmpty = 8, + AllocatedFromPool = 16, + SentFromHost = 32, + SentFromAdapter = 64, + ResponseExpected = 128, + NoResponseExpected = 256, + AdapterProcessed = 512, + HostProcessed = 1024, + HighPriority = 2048, + NormalPriority = 4096, + Async = 8192, + AsyncIo = 8192, + PageFileIo = 16384, + ShutdownRequest = 32768, + LazyWrite = 65536, + AdapterMicroFib = 131072, + BIOSFibPath = 262144, + FastResponseCapable = 524288, + ApiFib = 1048576, + NoMoreAifDataAvailable = 2097152, +}; + +struct _r7 { + __le32 init_struct_revision; + __le32 no_of_msix_vectors; + __le32 fsrev; + __le32 comm_header_address; + __le32 fast_io_comm_area_address; + __le32 adapter_fibs_physical_address; + __le32 adapter_fibs_virtual_address; + __le32 adapter_fibs_size; + __le32 adapter_fib_align; + __le32 printfbuf; + __le32 printfbufsiz; + __le32 host_phys_mem_pages; + __le32 host_elapsed_seconds; + __le32 init_flags; + __le32 max_io_commands; + __le32 max_io_size; + __le32 max_fib_size; + __le32 max_num_aif; + __le32 host_rrq_addr_low; + __le32 host_rrq_addr_high; +}; + +struct _rrq { + __le32 host_addr_low; + __le32 host_addr_high; + __le16 msix_id; + __le16 element_count; + __le16 comp_thresh; + __le16 unused; +}; + +struct _r8 { + __le32 init_struct_revision; + __le32 rr_queue_count; + __le32 host_elapsed_seconds; + __le32 init_flags; + __le32 max_io_size; + __le32 max_num_aif; + __le32 reserved1; + __le32 reserved2; + struct _rrq rrq[1]; +}; + +union aac_init { + struct _r7 r7; + struct _r8 r8; +}; + +struct aac_dev; + +struct fib; + +struct adapter_ops { + void (*adapter_interrupt)(struct aac_dev *); + void (*adapter_notify)(struct aac_dev *, u32); + void (*adapter_disable_int)(struct aac_dev *); + void (*adapter_enable_int)(struct aac_dev *); + int (*adapter_sync_cmd)(struct aac_dev *, u32, u32, u32, u32, u32, u32, u32, u32 *, u32 *, u32 *, u32 *, u32 *); + int (*adapter_check_health)(struct aac_dev *); + int (*adapter_restart)(struct aac_dev *, int, u8); + void (*adapter_start)(struct aac_dev *); + int (*adapter_ioremap)(struct aac_dev *, u32); + irq_handler_t adapter_intr; + int (*adapter_deliver)(struct fib *); + int (*adapter_bounds)(struct aac_dev *, struct scsi_cmnd *, u64); + int (*adapter_read)(struct fib *, struct scsi_cmnd *, u64, u32); + int (*adapter_write)(struct fib *, struct scsi_cmnd *, u64, u32, int); + int (*adapter_scsi)(struct fib *, struct scsi_cmnd *); + int (*adapter_comm)(struct aac_dev *, int); +}; + +struct aac_adapter_info { + __le32 platform; + __le32 cpu; + __le32 subcpu; + __le32 clock; + __le32 execmem; + __le32 buffermem; + __le32 totalmem; + __le32 kernelrev; + __le32 kernelbuild; + __le32 monitorrev; + __le32 monitorbuild; + __le32 hwrev; + __le32 hwbuild; + __le32 biosrev; + __le32 biosbuild; + __le32 cluster; + __le32 clusterchannelmask; + __le32 serial[2]; + __le32 battery; + __le32 options; + __le32 OEM; +}; + +struct aac_supplement_adapter_info { + u8 adapter_type_text[18]; + u8 pad[2]; + __le32 flash_memory_byte_size; + __le32 flash_image_id; + __le32 max_number_ports; + __le32 version; + __le32 feature_bits; + u8 slot_number; + u8 reserved_pad0[3]; + u8 build_date[12]; + __le32 current_number_ports; + struct { + u8 assembly_pn[8]; + u8 fru_pn[8]; + u8 battery_fru_pn[8]; + u8 ec_version_string[8]; + u8 tsid[12]; + } vpd_info; + __le32 flash_firmware_revision; + __le32 flash_firmware_build; + __le32 raid_type_morph_options; + __le32 flash_firmware_boot_revision; + __le32 flash_firmware_boot_build; + u8 mfg_pcba_serial_no[12]; + u8 mfg_wwn_name[8]; + __le32 supported_options2; + __le32 struct_expansion; + __le32 feature_bits3; + __le32 supported_performance_modes; + u8 host_bus_type; + u8 host_bus_width; + u16 host_bus_speed; + u8 max_rrc_drives; + u8 max_disk_xtasks; + u8 cpld_ver_loaded; + u8 cpld_ver_in_flash; + __le64 max_rrc_capacity; + __le32 compiled_max_hist_log_level; + u8 custom_board_name[12]; + u16 supported_cntlr_mode; + u16 reserved_for_future16; + __le32 supported_options3; + __le16 virt_device_bus; + __le16 virt_device_target; + __le16 virt_device_lun; + __le16 unused; + __le32 reserved_for_future_growth[68]; +}; + +struct aac_msix_ctx { + int vector_no; + struct aac_dev *dev; +}; + +struct aac_hba_map_info { + __le32 rmw_nexus; + u8 devtype; + s8 reset_state; + u16 qd_limit; + u32 scan_counter; + struct aac_ciss_identify_pd *safw_identify_resp; +}; + +struct aac_queue_block; + +struct fsa_dev_info; + +struct sa_registers; + +struct rx_registers; + +struct rkt_registers; + +struct src_registers; + +struct rx_inbound; + +struct aac_dev { + struct list_head entry; + const char *name; + int id; + unsigned int max_fib_size; + unsigned int sg_tablesize; + unsigned int max_num_aif; + unsigned int max_cmd_size; + dma_addr_t hw_fib_pa; + struct hw_fib *hw_fib_va; + struct hw_fib *aif_base_va; + struct fib *fibs; + struct fib *free_fib; + spinlock_t fib_lock; + struct mutex ioctl_mutex; + struct mutex scan_mutex; + struct aac_queue_block *queues; + struct list_head fib_list; + struct adapter_ops a_ops; + long unsigned int fsrev; + resource_size_t base_start; + resource_size_t dbg_base; + resource_size_t base_size; + resource_size_t dbg_size; + union aac_init *init; + dma_addr_t init_pa; + __le32 *host_rrq; + dma_addr_t host_rrq_pa; + u32 host_rrq_idx[32]; + atomic_t rrq_outstanding[32]; + u32 fibs_pushed_no; + struct pci_dev *pdev; + void *printfbuf; + void *comm_addr; + dma_addr_t comm_phys; + size_t comm_size; + struct Scsi_Host *scsi_host_ptr; + int maximum_num_containers; + int maximum_num_physicals; + int maximum_num_channels; + struct fsa_dev_info *fsa_dev; + struct task_struct *thread; + struct delayed_work safw_rescan_work; + struct delayed_work src_reinit_aif_worker; + int cardtype; + spinlock_t iq_lock; + union { + struct sa_registers *sa; + struct rx_registers *rx; + struct rkt_registers *rkt; + struct { + struct src_registers *bar0; + char *bar1; + } src; + } regs; + volatile void *base; + volatile void *dbg_base_mapped; + volatile struct rx_inbound *IndexRegs; + u32 OIMR; + u32 aif_thread; + struct aac_adapter_info adapter_info; + struct aac_supplement_adapter_info supplement_adapter_info; + u8 nondasd_support; + u8 jbod; + u8 cache_protected; + u8 dac_support; + u8 needs_dac; + u8 raid_scsi_mode; + u8 comm_interface; + u8 raw_io_interface; + u8 raw_io_64; + u8 printf_enabled; + u8 in_reset; + u8 in_soft_reset; + u8 msi; + u8 sa_firmware; + int management_fib_count; + spinlock_t manage_lock; + spinlock_t sync_lock; + int sync_mode; + struct fib *sync_fib; + struct list_head sync_fib_list; + u32 doorbell_mask; + u32 max_msix; + u32 vector_cap; + int msi_enabled; + atomic_t msix_counter; + u32 scan_counter; + struct msix_entry msixentry[32]; + struct aac_msix_ctx aac_msix[32]; + struct aac_hba_map_info hba_map[1280]; + struct aac_ciss_phys_luns_resp *safw_phys_luns; + u8 adapter_shutdown; + u32 handle_pci_error; + bool init_reset; + u8 soft_reset_support; +}; + +typedef void (*fib_callback)(void *, struct fib *); + +struct fib { + void *next; + s16 type; + s16 size; + struct aac_dev *dev; + struct completion event_wait; + spinlock_t event_lock; + u32 done; + fib_callback callback; + void *callback_data; + u32 flags; + struct list_head fiblink; + void *data; + u32 vector_no; + struct hw_fib *hw_fib_va; + dma_addr_t hw_fib_pa; + dma_addr_t hw_sgl_pa; + dma_addr_t hw_error_pa; + u32 hbacmd_size; +}; + +struct aac_driver_ident { + int (*init)(struct aac_dev *); + char *name; + char *vname; + char *model; + u16 channels; + int quirks; +}; + +struct aac_queue { + u64 logical; + struct aac_entry *base; + struct aac_qhdr headers; + u32 entries; + wait_queue_head_t qfull; + wait_queue_head_t cmdready; + spinlock_t *lock; + spinlock_t lockdata; + struct list_head cmdq; + atomic_t numpending; + struct aac_dev *dev; +}; + +struct aac_queue_block { + struct aac_queue queue[8]; +}; + +struct sa_drawbridge_CSR { + __le32 reserved[10]; + u8 LUT_Offset; + u8 reserved1[3]; + __le32 LUT_Data; + __le32 reserved2[26]; + __le16 PRICLEARIRQ; + __le16 SECCLEARIRQ; + __le16 PRISETIRQ; + __le16 SECSETIRQ; + __le16 PRICLEARIRQMASK; + __le16 SECCLEARIRQMASK; + __le16 PRISETIRQMASK; + __le16 SECSETIRQMASK; + __le32 MAILBOX0; + __le32 MAILBOX1; + __le32 MAILBOX2; + __le32 MAILBOX3; + __le32 MAILBOX4; + __le32 MAILBOX5; + __le32 MAILBOX6; + __le32 MAILBOX7; + __le32 ROM_Setup_Data; + __le32 ROM_Control_Addr; + __le32 reserved3[12]; + __le32 LUT[64]; +}; + +struct sa_registers { + struct sa_drawbridge_CSR SaDbCSR; +}; + +struct rx_mu_registers { + __le32 ARSR; + __le32 reserved0; + __le32 AWR; + __le32 reserved1; + __le32 IMRx[2]; + __le32 OMRx[2]; + __le32 IDR; + __le32 IISR; + __le32 IIMR; + __le32 ODR; + __le32 OISR; + __le32 OIMR; + __le32 reserved2; + __le32 reserved3; + __le32 InboundQueue; + __le32 OutboundQueue; +}; + +struct rx_inbound { + __le32 Mailbox[8]; +}; + +struct rx_registers { + struct rx_mu_registers MUnit; + __le32 reserved1[2]; + struct rx_inbound IndexRegs; +}; + +struct rkt_registers { + struct rx_mu_registers MUnit; + __le32 reserved1[1006]; + struct rx_inbound IndexRegs; +}; + +struct src_mu_registers { + __le32 reserved0[6]; + __le32 IOAR[2]; + __le32 IDR; + __le32 IISR; + __le32 reserved1[3]; + __le32 OIMR; + __le32 reserved2[25]; + __le32 ODR_R; + __le32 ODR_C; + __le32 reserved3[3]; + __le32 SCR0; + __le32 reserved4[2]; + __le32 OMR; + __le32 IQ_L; + __le32 IQ_H; + __le32 ODR_MSI; + __le32 reserved5; + __le32 IQN_L; + __le32 IQN_H; +}; + +struct src_registers { + struct src_mu_registers MUnit; + union { + struct { + __le32 reserved1[130786]; + struct rx_inbound IndexRegs; + } tupelo; + struct { + __le32 reserved1[970]; + struct rx_inbound IndexRegs; + } denali; + } u; +}; + +struct sense_data { + u8 error_code; + u8 valid: 1; + u8 segment_number; + u8 sense_key: 4; + u8 reserved: 1; + u8 ILI: 1; + u8 EOM: 1; + u8 filemark: 1; + u8 information[4]; + u8 add_sense_len; + u8 cmnd_info[4]; + u8 ASC; + u8 ASCQ; + u8 FRUC; + u8 bit_ptr: 3; + u8 BPV: 1; + u8 reserved2: 2; + u8 CD: 1; + u8 SKSV: 1; + u8 field_ptr[2]; +}; + +struct fsa_dev_info { + u64 last; + u64 size; + u32 type; + u32 config_waiting_on; + long unsigned int config_waiting_stamp; + u16 queue_depth; + u8 config_needed; + u8 valid; + u8 ro; + u8 locked; + u8 deleted; + char devname[8]; + struct sense_data sense_data; + u32 block_size; + u8 identifier[16]; +}; + +struct fib_ioctl { + u32 fibctx; + s32 wait; + char *fib; +}; + +struct fib_count_data { + int mlcnt; + int llcnt; + int ehcnt; + int fwcnt; + int krlcnt; +}; + +enum { + HBA_RESP_STAT_IO_ERROR = 1, + HBA_RESP_STAT_IO_ABORTED = 2, + HBA_RESP_STAT_NO_PATH_TO_DEVICE = 3, + HBA_RESP_STAT_INVALID_DEVICE = 4, + HBA_RESP_STAT_HBAMODE_DISABLED = 14, + HBA_RESP_STAT_UNDERRUN = 81, + HBA_RESP_STAT_OVERRUN = 117, +}; + +struct sgentry { + __le32 addr; + __le32 count; +}; + +struct sgentry64 { + __le32 addr[2]; + __le32 count; +}; + +struct sgentryraw { + __le32 next; + __le32 prev; + __le32 addr[2]; + __le32 count; + __le32 flags; +}; + +struct sge_ieee1212 { + u32 addrLow; + u32 addrHigh; + u32 length; + u32 flags; +}; + +struct sgmap { + __le32 count; + struct sgentry sg[1]; +}; + +struct sgmap64 { + __le32 count; + struct sgentry64 sg[1]; +}; + +struct sgmapraw { + __le32 count; + struct sgentryraw sg[1]; +}; + +struct creation_info { + u8 buildnum; + u8 usec; + u8 via; + u8 year; + __le32 date; + __le32 serial[2]; +}; + +struct aac_bus_info { + __le32 Command; + __le32 ObjType; + __le32 MethodId; + __le32 ObjectId; + __le32 CtlCmd; +}; + +struct aac_bus_info_response { + __le32 Status; + __le32 ObjType; + __le32 MethodId; + __le32 ObjectId; + __le32 CtlCmd; + __le32 ProbeComplete; + __le32 BusCount; + __le32 TargetsPerBus; + u8 InitiatorBusId[10]; + u8 BusValid[10]; +}; + +struct aac_read { + __le32 command; + __le32 cid; + __le32 block; + __le32 count; + struct sgmap sg; +}; + +struct aac_read64 { + __le32 command; + __le16 cid; + __le16 sector_count; + __le32 block; + __le16 pad; + __le16 flags; + struct sgmap64 sg; +}; + +struct aac_read_reply { + __le32 status; + __le32 count; +}; + +struct aac_write { + __le32 command; + __le32 cid; + __le32 block; + __le32 count; + __le32 stable; + struct sgmap sg; +}; + +struct aac_write64 { + __le32 command; + __le16 cid; + __le16 sector_count; + __le32 block; + __le16 pad; + __le16 flags; + struct sgmap64 sg; +}; + +struct aac_raw_io { + __le32 block[2]; + __le32 count; + __le16 cid; + __le16 flags; + __le16 bpTotal; + __le16 bpComplete; + struct sgmapraw sg; +}; + +struct aac_raw_io2 { + __le32 blockLow; + __le32 blockHigh; + __le32 byteCount; + __le16 cid; + __le16 flags; + __le32 sgeFirstSize; + __le32 sgeNominalSize; + u8 sgeCnt; + u8 bpTotal; + u8 bpComplete; + u8 sgeFirstIndex; + u8 unused[4]; + struct sge_ieee1212 sge[1]; +}; + +struct aac_synchronize { + __le32 command; + __le32 type; + __le32 cid; + __le32 parm1; + __le32 parm2; + __le32 parm3; + __le32 parm4; + __le32 count; +}; + +struct aac_synchronize_reply { + __le32 dummy0; + __le32 dummy1; + __le32 status; + __le32 parm1; + __le32 parm2; + __le32 parm3; + __le32 parm4; + __le32 parm5; + u8 data[16]; +}; + +struct aac_power_management { + __le32 command; + __le32 type; + __le32 sub; + __le32 cid; + __le32 parm; +}; + +struct aac_srb { + __le32 function; + __le32 channel; + __le32 id; + __le32 lun; + __le32 timeout; + __le32 flags; + __le32 count; + __le32 retry_limit; + __le32 cdb_size; + u8 cdb[16]; + struct sgmap sg; +}; + +struct aac_srb_reply { + __le32 status; + __le32 srb_status; + __le32 scsi_status; + __le32 data_xfer_length; + __le32 sense_data_size; + u8 sense_data[30]; +}; + +struct aac_srb_unit { + struct aac_srb srb; + struct aac_srb_reply srb_reply; +}; + +struct aac_fsinfo { + __le32 fsTotalSize; + __le32 fsBlockSize; + __le32 fsFragSize; + __le32 fsMaxExtendSize; + __le32 fsSpaceUnits; + __le32 fsMaxNumFiles; + __le32 fsNumFreeFiles; + __le32 fsInodeDensity; +}; + +struct aac_blockdevinfo { + __le32 block_size; + __le32 logical_phys_map; + u8 identifier[16]; +}; + +union aac_contentinfo { + struct aac_fsinfo filesys; + struct aac_blockdevinfo bdevinfo; +}; + +struct aac_get_config_status { + __le32 command; + __le32 type; + __le32 parm1; + __le32 parm2; + __le32 parm3; + __le32 parm4; + __le32 parm5; + __le32 count; +}; + +struct aac_get_config_status_resp { + __le32 response; + __le32 dummy0; + __le32 status; + __le32 parm1; + __le32 parm2; + __le32 parm3; + __le32 parm4; + __le32 parm5; + struct { + __le32 action; + __le16 flags; + __le16 count; + } data; +}; + +struct aac_commit_config { + __le32 command; + __le32 type; +}; + +struct aac_get_container_count { + __le32 command; + __le32 type; +}; + +struct aac_get_container_count_resp { + __le32 response; + __le32 dummy0; + __le32 MaxContainers; + __le32 ContainerSwitchEntries; + __le32 MaxPartitions; + __le32 MaxSimpleVolumes; +}; + +struct aac_mntent { + __le32 oid; + u8 name[16]; + struct creation_info create_info; + __le32 capacity; + __le32 vol; + __le32 obj; + __le32 state; + union aac_contentinfo fileinfo; + __le32 altoid; + __le32 capacityhigh; +}; + +struct aac_query_mount { + __le32 command; + __le32 type; + __le32 count; +}; + +struct aac_mount { + __le32 status; + __le32 type; + __le32 count; + struct aac_mntent mnt[1]; +}; + +struct aac_get_name { + __le32 command; + __le32 type; + __le32 cid; + __le32 parm1; + __le32 parm2; + __le32 parm3; + __le32 parm4; + __le32 count; +}; + +struct aac_get_name_resp { + __le32 dummy0; + __le32 dummy1; + __le32 status; + __le32 parm1; + __le32 parm2; + __le32 parm3; + __le32 parm4; + __le32 parm5; + u8 data[17]; +}; + +struct aac_get_serial { + __le32 command; + __le32 type; + __le32 cid; +}; + +struct aac_get_serial_resp { + __le32 dummy0; + __le32 dummy1; + __le32 status; + __le32 uid; +}; + +struct aac_query_disk { + s32 cnum; + s32 bus; + s32 id; + s32 lun; + u32 valid; + u32 locked; + u32 deleted; + s32 instance; + s8 name[10]; + u32 unmapped; +}; + +struct aac_delete_disk { + u32 disknum; + u32 cnum; +}; + +typedef struct { + struct { + u8 data_length; + u8 med_type; + u8 dev_par; + u8 bd_length; + } hd; + struct { + u8 dens_code; + u8 block_count[3]; + u8 reserved; + u8 block_length[3]; + } bd; + u8 mpc_buf[3]; +} aac_modep_data; + +typedef struct { + struct { + u8 data_length[2]; + u8 med_type; + u8 dev_par; + u8 rsrvd[2]; + u8 bd_length[2]; + } hd; + struct { + u8 dens_code; + u8 block_count[3]; + u8 reserved; + u8 block_length[3]; + } bd; + u8 mpc_buf[3]; +} aac_modep10_data; + +struct inquiry_data { + u8 inqd_pdt; + u8 inqd_dtq; + u8 inqd_ver; + u8 inqd_rdf; + u8 inqd_len; + u8 inqd_pad1[2]; + u8 inqd_pad2; + u8 inqd_vid[8]; + u8 inqd_pid[16]; + u8 inqd_prl[4]; +}; + +struct tvpd_id_descriptor_type_1 { + u8 codeset: 4; + u8 reserved: 4; + u8 identifiertype: 4; + u8 reserved2: 4; + u8 reserved3; + u8 identifierlength; + u8 venid[8]; + u8 productid[16]; + u8 serialnumber[8]; +}; + +struct teu64id { + u32 Serial; + u8 reserved; + u8 venid[3]; +}; + +struct tvpd_id_descriptor_type_2 { + u8 codeset: 4; + u8 reserved: 4; + u8 identifiertype: 4; + u8 reserved2: 4; + u8 reserved3; + u8 identifierlength; + struct teu64id eu64id; +}; + +struct tvpd_id_descriptor_type_3 { + u8 codeset: 4; + u8 reserved: 4; + u8 identifiertype: 4; + u8 reserved2: 4; + u8 reserved3; + u8 identifierlength; + u8 Identifier[16]; +}; + +struct tvpd_page83 { + u8 DeviceType: 5; + u8 DeviceTypeQualifier: 3; + u8 PageCode; + u8 reserved; + u8 PageLength; + struct tvpd_id_descriptor_type_1 type1; + struct tvpd_id_descriptor_type_2 type2; + struct tvpd_id_descriptor_type_3 type3; +}; + +struct scsi_inq { + char vid[8]; + char pid[16]; + char prl[4]; +}; + +struct user_sgentry { + u32 addr; + u32 count; +}; + +struct user_sgentry64 { + u32 addr[2]; + u32 count; +}; + +struct user_sgmap { + u32 count; + struct user_sgentry sg[1]; +}; + +struct user_sgmap64 { + u32 count; + struct user_sgentry64 sg[1]; +}; + +struct aac_fib_context { + s16 type; + s16 size; + u32 unique; + ulong jiffies; + struct list_head next; + struct completion completion; + int wait; + long unsigned int count; + struct list_head fib_list; +}; + +struct user_aac_srb { + u32 function; + u32 channel; + u32 id; + u32 lun; + u32 timeout; + u32 flags; + u32 count; + u32 retry_limit; + u32 cdb_size; + u8 cdb[16]; + struct user_sgmap sg; +}; + +struct revision { + u32 compat; + __le32 version; + __le32 build; +}; + +struct aac_hba_info { + u8 driver_name[50]; + u8 adapter_number; + u8 system_io_bus_number; + u8 device_number; + u32 function_number; + u32 vendor_id; + u32 device_id; + u32 sub_vendor_id; + u32 sub_system_id; + u32 mapped_base_address_size; + u32 base_physical_address_high_part; + u32 base_physical_address_low_part; + u32 max_command_size; + u32 max_fib_size; + u32 max_scatter_gather_from_os; + u32 max_scatter_gather_to_fw; + u32 max_outstanding_fibs; + u32 queue_start_threshold; + u32 queue_dump_threshold; + u32 max_io_size_queued; + u32 outstanding_io; + u32 firmware_build_number; + u32 bios_build_number; + u32 driver_build_number; + u32 serial_number_high_part; + u32 serial_number_low_part; + u32 supported_options; + u32 feature_bits; + u32 currentnumber_ports; + u8 new_comm_interface: 1; + u8 new_commands_supported: 1; + u8 disable_passthrough: 1; + u8 expose_non_dasd: 1; + u8 queue_allowed: 1; + u8 bled_check_enabled: 1; + u8 reserved1: 1; + u8 reserted2: 1; + u32 reserved3[10]; +}; + +struct aac_pci_info { + u32 bus; + u32 slot; +}; + +struct aac_reset_iop { + u8 reset_type; +}; + +enum aac_queue_types { + HostNormCmdQueue = 0, + HostHighCmdQueue = 1, + AdapNormCmdQueue = 2, + AdapHighCmdQueue = 3, + HostNormRespQueue = 4, + HostHighRespQueue = 5, + AdapNormRespQueue = 6, + AdapHighRespQueue = 7, +}; + +struct aac_close { + __le32 command; + __le32 cid; +}; + +struct aac_common { + u32 irq_mod; + u32 peak_fibs; + u32 zero_fibs; + u32 fib_timeouts; +}; + +enum aac_log_level { + LOG_AAC_INIT = 10, + LOG_AAC_INFORMATIONAL = 20, + LOG_AAC_WARNING = 30, + LOG_AAC_LOW_ERROR = 40, + LOG_AAC_MEDIUM_ERROR = 50, + LOG_AAC_HIGH_ERROR = 60, + LOG_AAC_PANIC = 70, + LOG_AAC_DEBUG = 80, + LOG_AAC_WINDBG_PRINT = 90, +}; + +struct aac_pause { + __le32 command; + __le32 type; + __le32 timeout; + __le32 min; + __le32 noRescan; + __le32 parm3; + __le32 parm4; + __le32 count; +}; + +struct aac_aifcmd { + __le32 command; + __le32 seqnum; + u8 data[1]; +}; + +enum { + NOTHING = 0, + DELETE = 1, + ADD = 2, + CHANGE = 3, +}; + +struct POSTSTATUS { + __le32 Post_Command; + __le32 Post_Address; +}; + +typedef u32 u_int32_t; + +struct aac_fib_xporthdr { + __le64 HostAddress; + __le32 Size; + __le32 Handle; + __le64 Reserved[2]; +}; + +struct ssp_frame_hdr { + u8 frame_type; + u8 hashed_dest_addr[3]; + u8 _r_a; + u8 hashed_src_addr[3]; + __be16 _r_b; + u8 changing_data_ptr: 1; + u8 retransmit: 1; + u8 retry_data_frames: 1; + u8 _r_c: 5; + u8 num_fill_bytes: 2; + u8 _r_d: 6; + u32 _r_e; + __be16 tag; + __be16 tptt; + __be32 data_offs; +}; + +struct ssp_command_iu { + u8 lun[8]; + u8 _r_a; + union { + struct { + u8 attr: 3; + u8 prio: 4; + u8 efb: 1; + }; + u8 efb_prio_attr; + }; + u8 _r_b; + u8 _r_c: 2; + u8 add_cdb_len: 6; + u8 cdb[16]; + u8 add_cdb[0]; +}; + +struct ssp_tmf_iu { + u8 lun[8]; + u16 _r_a; + u8 tmf; + u8 _r_b; + __be16 tag; + u8 _r_c[14]; +}; + +struct sg_el { + __le64 bus_addr; + __le32 size; + __le16 _r; + u8 next_sg_offs; + u8 flags; +}; + +struct scb_header { + __le64 next_scb; + __le16 index; + u8 opcode; +} __attribute__((packed)); + +struct initiate_ssp_task { + u8 proto_conn_rate; + __le32 total_xfer_len; + struct ssp_frame_hdr ssp_frame; + struct ssp_command_iu ssp_cmd; + __le16 sister_scb; + __le16 conn_handle; + u8 data_dir; + u8 _r_a; + u8 retry_count; + u8 _r_b[5]; + struct sg_el sg_element[3]; +} __attribute__((packed)); + +struct initiate_ata_task { + u8 proto_conn_rate; + __le32 total_xfer_len; + struct host_to_dev_fis fis; + __le32 data_offs; + u8 atapi_packet[16]; + u8 _r_a[12]; + __le16 sister_scb; + __le16 conn_handle; + u8 ata_flags; + u8 _r_b; + u8 retry_count; + u8 _r_c; + u8 flags; + u8 _r_d[3]; + struct sg_el sg_element[3]; +} __attribute__((packed)); + +struct initiate_smp_task { + u8 proto_conn_rate; + u8 _r_a[40]; + struct sg_el smp_req; + __le16 sister_scb; + __le16 conn_handle; + u8 _r_c[8]; + struct sg_el smp_resp; + u8 _r_d[32]; +} __attribute__((packed)); + +struct control_phy { + u8 phy_id; + u8 sub_func; + u8 func_mask; + u8 speed_mask; + u8 hot_plug_delay; + u8 port_type; + u8 flags; + __le32 timeout_override; + u8 link_reset_retries; + u8 _r_a[47]; + __le16 conn_handle; + u8 _r_b[56]; +} __attribute__((packed)); + +struct control_ata_dev { + u8 proto_conn_rate; + __le32 _r_a; + struct host_to_dev_fis fis; + u8 _r_b[32]; + __le16 sister_scb; + __le16 conn_handle; + u8 ata_flags; + u8 _r_c[55]; +} __attribute__((packed)); + +struct empty_scb { + u8 num_valid; + __le32 _r_a; + struct sg_el eb[7]; +} __attribute__((packed)); + +struct initiate_link_adm { + u8 phy_id; + u8 sub_func; + u8 _r_a[57]; + __le16 conn_handle; + u8 _r_b[56]; +} __attribute__((packed)); + +struct copy_memory { + u8 _r_a; + __le16 xfer_len; + __le16 _r_b; + __le64 src_busaddr; + u8 src_ds; + u8 _r_c[45]; + __le16 conn_handle; + __le64 _r_d; + __le64 dest_busaddr; + u8 dest_ds; + u8 _r_e[39]; +} __attribute__((packed)); + +struct abort_task { + u8 proto_conn_rate; + __le32 _r_a; + struct ssp_frame_hdr ssp_frame; + struct ssp_tmf_iu ssp_task; + __le16 sister_scb; + __le16 conn_handle; + u8 flags; + u8 _r_b; + u8 retry_count; + u8 _r_c[5]; + __le16 index; + __le16 itnl_to; + u8 _r_d[44]; +} __attribute__((packed)); + +struct clear_nexus { + u8 nexus; + __le32 _r_a; + u8 flags; + u8 _r_b[3]; + u8 conn_mask; + u8 _r_c[19]; + struct ssp_tmf_iu ssp_task; + __le16 _r_d; + __le16 conn_handle; + __le64 _r_e; + __le16 index; + __le16 context; + u8 _r_f[44]; +} __attribute__((packed)); + +struct initiate_ssp_tmf { + u8 proto_conn_rate; + __le32 _r_a; + struct ssp_frame_hdr ssp_frame; + struct ssp_tmf_iu ssp_task; + __le16 sister_scb; + __le16 conn_handle; + u8 flags; + u8 _r_b; + u8 retry_count; + u8 _r_c[5]; + __le16 index; + __le16 itnl_to; + u8 _r_d[44]; +} __attribute__((packed)); + +struct scb___3 { + struct scb_header header; + union { + struct initiate_ssp_task ssp_task; + struct initiate_ata_task ata_task; + struct initiate_smp_task smp_task; + struct control_phy control_phy; + struct control_ata_dev control_ata_dev; + struct empty_scb escb; + struct initiate_link_adm link_adm; + struct copy_memory cp_mem; + struct abort_task abort_task; + struct clear_nexus clear_nexus; + struct initiate_ssp_tmf ssp_tmf; + }; +} __attribute__((packed)); + +struct done_list_struct { + __le16 index; + u8 opcode; + u8 status_block[4]; + u8 toggle; +}; + +struct asd_phy_desc; + +struct asd_dma_tok; + +struct asd_port; + +struct asd_phy { + struct asd_sas_phy sas_phy; + struct asd_phy_desc *phy_desc; + struct sas_identify_frame *identify_frame; + struct asd_dma_tok *id_frm_tok; + struct asd_port *asd_port; + u8 frame_rcvd[1068]; +}; + +struct asd_phy_desc { + u8 sas_addr[8]; + u8 max_sas_lrate; + u8 min_sas_lrate; + u8 max_sata_lrate; + u8 min_sata_lrate; + u8 flags; + u8 phy_control_0; + u8 phy_control_1; + u8 phy_control_2; + u8 phy_control_3; +}; + +struct asd_dma_tok { + void *vaddr; + dma_addr_t dma_handle; + size_t size; +}; + +struct asd_port { + u8 sas_addr[8]; + u8 attached_sas_addr[8]; + u32 phy_mask; + int num_phys; +}; + +struct asd_ha_addrspace { + void *addr; + long unsigned int start; + long unsigned int len; + long unsigned int flags; + u32 swa_base; + u32 swb_base; + u32 swc_base; +}; + +struct bios_struct { + int present; + u8 maj; + u8 min; + u32 bld; +}; + +struct unit_element_struct { + u16 num; + u16 size; + void *area; +}; + +struct flash_struct { + u32 bar; + int present; + int wide; + u8 manuf; + u8 dev_id; + u8 sec_prot; + u8 method; + u32 dir_offs; +}; + +struct hw_profile { + struct bios_struct bios; + struct unit_element_struct ue; + struct flash_struct flash; + u8 sas_addr[8]; + char pcba_sn[13]; + u8 enabled_phys; + struct asd_phy_desc phy_desc[8]; + u32 max_scbs; + struct asd_dma_tok *scb_ext; + u32 max_ddbs; + struct asd_dma_tok *ddb_ext; + spinlock_t ddb_lock; + void *ddb_bitmap; + int num_phys; + int max_phys; + unsigned int addr_range; + unsigned int port_name_base; + unsigned int dev_name_base; + unsigned int sata_name_base; +}; + +struct asd_ha_struct; + +struct asd_ascb { + struct list_head list; + struct asd_ha_struct *ha; + struct scb___3 *scb; + struct asd_dma_tok dma_scb; + struct asd_dma_tok *sg_arr; + void (*tasklet_complete)(struct asd_ascb *, struct done_list_struct *); + u8 uldd_timer: 1; + struct timer_list timer; + struct completion *completion; + u8 tag_valid: 1; + __be16 tag; + int edb_index; + int tc_index; + void *uldd_task; +}; + +struct asd_seq_data { + spinlock_t pend_q_lock; + u16 scbpro; + int pending; + struct list_head pend_q; + int can_queue; + struct asd_dma_tok next_scb; + spinlock_t tc_index_lock; + void **tc_index_array; + void *tc_index_bitmap; + int tc_index_bitmap_bits; + struct tasklet_struct dl_tasklet; + struct done_list_struct *dl; + struct asd_dma_tok *actual_dl; + int dl_toggle; + int dl_next; + int num_edbs; + struct asd_dma_tok **edb_arr; + int num_escbs; + struct asd_ascb **escb_arr; +}; + +struct asd_ha_struct { + struct pci_dev *pcidev; + const char *name; + struct sas_ha_struct sas_ha; + u8 revision_id; + int iospace; + spinlock_t iolock; + struct asd_ha_addrspace io_handle[2]; + struct hw_profile hw_prof; + struct asd_phy phys[8]; + spinlock_t asd_ports_lock; + struct asd_port asd_ports[8]; + struct asd_sas_port ports[8]; + struct dma_pool___2 *scb_pool; + struct asd_seq_data seq; + u32 bios_status; + const struct firmware *bios_image; +}; + +struct controller_id { + u32 vendor; + u32 device; + u32 sub_vendor; + u32 sub_device; +}; + +struct image_info { + u32 ImageId; + u32 ImageOffset; + u32 ImageLength; + u32 ImageChecksum; + u32 ImageVersion; +}; + +struct bios_file_header { + u8 signature[32]; + u32 checksum; + u32 antidote; + struct controller_id contrl_id; + u32 filelen; + u32 chunk_num; + u32 total_chunks; + u32 num_images; + u32 build_num; + struct image_info image_header; +}; + +struct flash_command { + u8 command[8]; + int code; +}; + +struct error_bios { + char *reason; + int err_code; +}; + +struct asd_pcidev_struct { + const char *name; + int (*setup)(struct asd_ha_struct *); +}; + +enum { + FLASH_METHOD_UNKNOWN = 0, + FLASH_METHOD_A = 1, + FLASH_METHOD_B = 2, +}; + +struct asd_ocm_dir_ent { + u8 type; + u8 offs[3]; + u8 _r1; + u8 size[3]; +}; + +struct asd_ocm_dir { + char sig[2]; + u8 _r1[2]; + u8 major; + u8 minor; + u8 _r2; + u8 num_de; + struct asd_ocm_dir_ent entry[15]; +}; + +struct asd_bios_chim_struct { + char sig[4]; + u8 major; + u8 minor; + u8 bios_major; + u8 bios_minor; + __le32 bios_build; + u8 flags; + u8 pci_slot; + __le16 ue_num; + __le16 ue_size; + u8 _r[14]; +}; + +struct asd_flash_de { + __le32 type; + __le32 offs; + __le32 pad_size; + __le32 image_size; + __le32 chksum; + u8 _r[12]; + u8 version[32]; +}; + +struct asd_flash_dir { + u8 cookie[32]; + __le32 rev; + __le32 chksum; + __le32 chksum_antidote; + __le32 bld; + u8 bld_id[32]; + u8 ver_data[32]; + __le32 ae_mask; + __le32 v_mask; + __le32 oc_mask; + u8 _r[20]; + struct asd_flash_de dir_entry[32]; +}; + +struct asd_manuf_sec { + char sig[2]; + u16 offs_next; + u8 maj; + u8 min; + u16 chksum; + u16 size; + u8 _r[6]; + u8 sas_addr[8]; + u8 pcba_sn[12]; + u8 linked_list[0]; +}; + +struct asd_manuf_phy_desc { + u8 state; + u8 phy_id; + u16 _r; + u8 phy_control_0; + u8 phy_control_1; + u8 phy_control_2; + u8 phy_control_3; +}; + +struct asd_manuf_phy_param { + char sig[2]; + u16 next; + u8 maj; + u8 min; + u8 num_phy_desc; + u8 phy_desc_size; + u8 _r[3]; + u8 usage_model_id; + u32 _r2; + struct asd_manuf_phy_desc phy_desc[8]; +}; + +struct asd_ms_sb_desc { + u8 type; + u8 node_desc_index; + u8 conn_desc_index; + u8 _recvd[0]; +}; + +struct asd_ms_conn_desc { + u8 type; + u8 location; + u8 num_sideband_desc; + u8 size_sideband_desc; + u32 _resvd; + u8 name[16]; + struct asd_ms_sb_desc sb_desc[0]; +}; + +struct asd_nd_phy_desc { + u8 vp_attch_type; + u8 attch_specific[0]; +}; + +struct asd_ms_node_desc { + u8 type; + u8 num_phy_desc; + u8 size_phy_desc; + u8 _resvd; + u8 name[16]; + struct asd_nd_phy_desc phy_desc[0]; +}; + +struct asd_ms_conn_map { + char sig[2]; + __le16 next; + u8 maj; + u8 min; + __le16 cm_size; + u8 num_conn; + u8 conn_size; + u8 num_nodes; + u8 usage_model_id; + u32 _resvd; + struct asd_ms_conn_desc conn_desc[0]; + struct asd_ms_node_desc node_desc[0]; +}; + +struct asd_ctrla_phy_entry { + u8 sas_addr[8]; + u8 sas_link_rates; + u8 flags; + u8 sata_link_rates; + u8 _r[5]; +}; + +struct asd_ctrla_phy_settings { + u8 id0; + u8 _r; + u16 next; + u8 num_phys; + u8 _r2[3]; + struct asd_ctrla_phy_entry phy_ent[8]; +}; + +struct asd_ll_el { + u8 id0; + u8 id1; + __le16 next; + u8 something_here[0]; +}; + +struct sequencer_file_header { + u32 csum; + u32 major; + u32 minor; + char version[16]; + u32 cseq_table_offset; + u32 cseq_table_size; + u32 lseq_table_offset; + u32 lseq_table_size; + u32 cseq_code_offset; + u32 cseq_code_size; + u32 lseq_code_offset; + u32 lseq_code_size; + u16 mode2_task; + u16 cseq_idle_loop; + u16 lseq_idle_loop; +} __attribute__((packed)); + +struct tasklet_completion_status { + int dl_opcode; + int tmf_state; + u8 tag_valid: 1; + __be16 tag; +}; + +enum clear_nexus_phase { + NEXUS_PHASE_PRE = 0, + NEXUS_PHASE_POST = 1, + NEXUS_PHASE_RESUME = 2, +}; + +struct tc_resp_sb_struct { + __le16 index_escb; + u8 len_lsb; + u8 flags; +}; + +struct ata_task_resp { + u16 frame_len; + u8 ending_fis[24]; +}; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint8_t log_drv; + uint8_t sg_count; + uint32_t lba; + uint32_t sg_addr; + uint16_t sector_count; + uint8_t segment_4G; + uint8_t enhanced_sg; + uint32_t ccsar; + uint32_t cccr; +} IPS_IO_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint16_t reserved; + uint32_t reserved2; + uint32_t buffer_addr; + uint32_t reserved3; + uint32_t ccsar; + uint32_t cccr; +} IPS_LD_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint8_t reserved; + uint8_t reserved2; + uint32_t reserved3; + uint32_t buffer_addr; + uint32_t reserved4; +} IPS_IOCTL_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint8_t channel; + uint8_t reserved3; + uint8_t reserved4; + uint8_t reserved5; + uint8_t reserved6; + uint8_t reserved7; + uint8_t reserved8; + uint8_t reserved9; + uint8_t reserved10; + uint8_t reserved11; + uint8_t reserved12; + uint8_t reserved13; + uint8_t reserved14; + uint8_t adapter_flag; +} IPS_RESET_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint16_t reserved; + uint32_t reserved2; + uint32_t dcdb_address; + uint16_t reserved3; + uint8_t segment_4G; + uint8_t enhanced_sg; + uint32_t ccsar; + uint32_t cccr; +} IPS_DCDB_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint8_t channel; + uint8_t source_target; + uint32_t reserved; + uint32_t reserved2; + uint32_t reserved3; + uint32_t ccsar; + uint32_t cccr; +} IPS_CS_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint8_t log_drv; + uint8_t control; + uint32_t reserved; + uint32_t reserved2; + uint32_t reserved3; + uint32_t ccsar; + uint32_t cccr; +} IPS_US_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint8_t reserved; + uint8_t state; + uint32_t reserved2; + uint32_t reserved3; + uint32_t reserved4; + uint32_t ccsar; + uint32_t cccr; +} IPS_FC_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint8_t reserved; + uint8_t desc; + uint32_t reserved2; + uint32_t buffer_addr; + uint32_t reserved3; + uint32_t ccsar; + uint32_t cccr; +} IPS_STATUS_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint8_t page; + uint8_t write; + uint32_t reserved; + uint32_t buffer_addr; + uint32_t reserved2; + uint32_t ccsar; + uint32_t cccr; +} IPS_NVRAM_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint16_t reserved; + uint32_t count; + uint32_t buffer_addr; + uint32_t reserved2; +} IPS_VERSION_INFO; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint8_t reset_count; + uint8_t reset_type; + uint8_t second; + uint8_t minute; + uint8_t hour; + uint8_t day; + uint8_t reserved1[4]; + uint8_t month; + uint8_t yearH; + uint8_t yearL; + uint8_t reserved2; +} IPS_FFDC_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint8_t type; + uint8_t direction; + uint32_t count; + uint32_t buffer_addr; + uint8_t total_packets; + uint8_t packet_num; + uint16_t reserved; +} IPS_FLASHFW_CMD; + +typedef struct { + uint8_t op_code; + uint8_t command_id; + uint8_t type; + uint8_t direction; + uint32_t count; + uint32_t buffer_addr; + uint32_t offset; +} IPS_FLASHBIOS_CMD; + +typedef union { + IPS_IO_CMD basic_io; + IPS_LD_CMD logical_info; + IPS_IOCTL_CMD ioctl_info; + IPS_DCDB_CMD dcdb; + IPS_CS_CMD config_sync; + IPS_US_CMD unlock_stripe; + IPS_FC_CMD flush_cache; + IPS_STATUS_CMD status; + IPS_NVRAM_CMD nvram; + IPS_FFDC_CMD ffdc; + IPS_FLASHFW_CMD flashfw; + IPS_FLASHBIOS_CMD flashbios; + IPS_VERSION_INFO version_info; + IPS_RESET_CMD reset; +} IPS_HOST_COMMAND; + +typedef struct { + uint8_t logical_id; + uint8_t reserved; + uint8_t raid_level; + uint8_t state; + uint32_t sector_count; +} IPS_DRIVE_INFO; + +typedef struct { + uint8_t no_of_log_drive; + uint8_t reserved[3]; + IPS_DRIVE_INFO drive_info[8]; +} IPS_LD_INFO; + +typedef struct { + uint8_t device_address; + uint8_t cmd_attribute; + uint16_t transfer_length; + uint32_t buffer_pointer; + uint8_t cdb_length; + uint8_t sense_length; + uint8_t sg_count; + uint8_t reserved; + uint8_t scsi_cdb[12]; + uint8_t sense_info[64]; + uint8_t scsi_status; + uint8_t reserved2[3]; +} IPS_DCDB_TABLE; + +typedef struct { + uint8_t device_address; + uint8_t cmd_attribute; + uint8_t cdb_length; + uint8_t reserved_for_LUN; + uint32_t transfer_length; + uint32_t buffer_pointer; + uint16_t sg_count; + uint8_t sense_length; + uint8_t scsi_status; + uint32_t reserved; + uint8_t scsi_cdb[16]; + uint8_t sense_info[56]; +} IPS_DCDB_TABLE_TAPE; + +typedef union { + struct { + volatile uint8_t reserved; + volatile uint8_t command_id; + volatile uint8_t basic_status; + volatile uint8_t extended_status; + } fields; + volatile uint32_t value; +} IPS_STATUS; + +typedef union { + struct { + volatile uint8_t reserved; + volatile uint8_t command_id; + volatile uint8_t basic_status; + volatile uint8_t extended_status; + } fields; + volatile uint32_t value; +} *PIPS_STATUS; + +typedef struct { + IPS_STATUS status[129]; + volatile PIPS_STATUS p_status_start; + volatile PIPS_STATUS p_status_end; + volatile PIPS_STATUS p_status_tail; + volatile uint32_t hw_status_start; + volatile uint32_t hw_status_tail; +} IPS_ADAPTER; + +typedef struct { + uint8_t ucLogDriveCount; + uint8_t ucMiscFlag; + uint8_t ucSLTFlag; + uint8_t ucBSTFlag; + uint8_t ucPwrChgCnt; + uint8_t ucWrongAdrCnt; + uint8_t ucUnidentCnt; + uint8_t ucNVramDevChgCnt; + uint8_t CodeBlkVersion[8]; + uint8_t BootBlkVersion[8]; + uint32_t ulDriveSize[8]; + uint8_t ucConcurrentCmdCount; + uint8_t ucMaxPhysicalDevices; + uint16_t usFlashRepgmCount; + uint8_t ucDefunctDiskCount; + uint8_t ucRebuildFlag; + uint8_t ucOfflineLogDrvCount; + uint8_t ucCriticalDrvCount; + uint16_t usConfigUpdateCount; + uint8_t ucBlkFlag; + uint8_t reserved; + uint16_t usAddrDeadDisk[64]; +} IPS_ENQ; + +typedef struct { + uint8_t ucInitiator; + uint8_t ucParameters; + uint8_t ucMiscFlag; + uint8_t ucState; + uint32_t ulBlockCount; + uint8_t ucDeviceId[28]; +} IPS_DEVSTATE; + +typedef struct { + uint8_t ucChn; + uint8_t ucTgt; + uint16_t ucReserved; + uint32_t ulStartSect; + uint32_t ulNoOfSects; +} IPS_CHUNK; + +typedef struct { + uint16_t ucUserField; + uint8_t ucState; + uint8_t ucRaidCacheParam; + uint8_t ucNoOfChunkUnits; + uint8_t ucStripeSize; + uint8_t ucParams; + uint8_t ucReserved; + uint32_t ulLogDrvSize; + IPS_CHUNK chunk[16]; +} IPS_LD; + +typedef struct { + uint8_t board_disc[8]; + uint8_t processor[8]; + uint8_t ucNoChanType; + uint8_t ucNoHostIntType; + uint8_t ucCompression; + uint8_t ucNvramType; + uint32_t ulNvramSize; +} IPS_HARDWARE; + +typedef struct { + uint8_t ucLogDriveCount; + uint8_t ucDateD; + uint8_t ucDateM; + uint8_t ucDateY; + uint8_t init_id[4]; + uint8_t host_id[12]; + uint8_t time_sign[8]; + uint32_t UserOpt; + uint16_t user_field; + uint8_t ucRebuildRate; + uint8_t ucReserve; + IPS_HARDWARE hardware_disc; + IPS_LD logical_drive[8]; + IPS_DEVSTATE dev[64]; + uint8_t reserved[512]; +} IPS_CONF; + +typedef struct { + uint32_t signature; + uint8_t reserved1; + uint8_t adapter_slot; + uint16_t adapter_type; + uint8_t ctrl_bios[8]; + uint8_t versioning; + uint8_t version_mismatch; + uint8_t reserved2; + uint8_t operating_system; + uint8_t driver_high[4]; + uint8_t driver_low[4]; + uint8_t BiosCompatibilityID[8]; + uint8_t ReservedForOS2[8]; + uint8_t bios_high[4]; + uint8_t bios_low[4]; + uint8_t adapter_order[16]; + uint8_t Filler[60]; +} IPS_NVRAM_P5; + +struct _IPS_SUBSYS { + uint32_t param[128]; +}; + +typedef struct _IPS_SUBSYS IPS_SUBSYS; + +typedef struct { + uint8_t DeviceType; + uint8_t DeviceTypeQualifier; + uint8_t Version; + uint8_t ResponseDataFormat; + uint8_t AdditionalLength; + uint8_t Reserved; + uint8_t Flags[2]; + uint8_t VendorId[8]; + uint8_t ProductId[16]; + uint8_t ProductRevisionLevel[4]; + uint8_t Reserved2; +} IPS_SCSI_INQ_DATA; + +typedef struct { + uint32_t lba; + uint32_t len; +} IPS_SCSI_CAPACITY; + +typedef struct { + uint8_t ResponseCode; + uint8_t SegmentNumber; + uint8_t Flags; + uint8_t Information[4]; + uint8_t AdditionalLength; + uint8_t CommandSpecific[4]; + uint8_t AdditionalSenseCode; + uint8_t AdditionalSenseCodeQual; + uint8_t FRUCode; + uint8_t SenseKeySpecific[3]; +} IPS_SCSI_REQSEN; + +typedef struct { + uint8_t PageCode; + uint8_t PageLength; + uint16_t TracksPerZone; + uint16_t AltSectorsPerZone; + uint16_t AltTracksPerZone; + uint16_t AltTracksPerVolume; + uint16_t SectorsPerTrack; + uint16_t BytesPerSector; + uint16_t Interleave; + uint16_t TrackSkew; + uint16_t CylinderSkew; + uint8_t flags; + uint8_t reserved[3]; +} IPS_SCSI_MODE_PAGE3; + +typedef struct { + uint8_t PageCode; + uint8_t PageLength; + uint16_t CylindersHigh; + uint8_t CylindersLow; + uint8_t Heads; + uint16_t WritePrecompHigh; + uint8_t WritePrecompLow; + uint16_t ReducedWriteCurrentHigh; + uint8_t ReducedWriteCurrentLow; + uint16_t StepRate; + uint16_t LandingZoneHigh; + uint8_t LandingZoneLow; + uint8_t flags; + uint8_t RotationalOffset; + uint8_t Reserved; + uint16_t MediumRotationRate; + uint8_t Reserved2[2]; +} IPS_SCSI_MODE_PAGE4; + +typedef struct { + uint8_t PageCode; + uint8_t PageLength; + uint8_t flags; + uint8_t RetentPrio; + uint16_t DisPrefetchLen; + uint16_t MinPrefetchLen; + uint16_t MaxPrefetchLen; + uint16_t MaxPrefetchCeiling; +} IPS_SCSI_MODE_PAGE8; + +typedef struct { + uint32_t NumberOfBlocks; + uint8_t DensityCode; + uint16_t BlockLengthHigh; + uint8_t BlockLengthLow; +} IPS_SCSI_MODE_PAGE_BLKDESC; + +typedef struct { + uint8_t DataLength; + uint8_t MediumType; + uint8_t Reserved; + uint8_t BlockDescLength; +} IPS_SCSI_MODE_PAGE_HEADER; + +typedef struct { + IPS_SCSI_MODE_PAGE_HEADER hdr; + IPS_SCSI_MODE_PAGE_BLKDESC blkdesc; + union { + IPS_SCSI_MODE_PAGE3 pg3; + IPS_SCSI_MODE_PAGE4 pg4; + IPS_SCSI_MODE_PAGE8 pg8; + } pdata; +} IPS_SCSI_MODE_PAGE_DATA; + +struct ips_sglist { + uint32_t address; + uint32_t length; +}; + +typedef struct ips_sglist IPS_STD_SG_LIST; + +struct ips_enh_sglist { + uint32_t address_lo; + uint32_t address_hi; + uint32_t length; + uint32_t reserved; +}; + +typedef struct ips_enh_sglist IPS_ENH_SG_LIST; + +typedef union { + void *list; + IPS_STD_SG_LIST *std_list; + IPS_ENH_SG_LIST *enh_list; +} IPS_SG_LIST; + +typedef struct { + char *option_name; + int *option_flag; + int option_value; +} IPS_OPTION; + +struct ips_stat { + uint32_t residue_len; + void *scb_addr; + uint8_t padding[4]; +}; + +typedef struct ips_stat ips_stat_t; + +struct ips_scb; + +struct ips_scb_queue { + struct ips_scb *head; + struct ips_scb *tail; + int count; +}; + +struct ips_ha; + +typedef struct ips_ha ips_ha_t; + +typedef void (*ips_scb_callback)(ips_ha_t *, struct ips_scb *); + +struct ips_scb { + IPS_HOST_COMMAND cmd; + IPS_DCDB_TABLE dcdb; + uint8_t target_id; + uint8_t bus; + uint8_t lun; + uint8_t cdb[12]; + uint32_t scb_busaddr; + uint32_t old_data_busaddr; + uint32_t timeout; + uint8_t basic_status; + uint8_t extended_status; + uint8_t breakup; + uint8_t sg_break; + uint32_t data_len; + uint32_t sg_len; + uint32_t flags; + uint32_t op_code; + IPS_SG_LIST sg_list; + struct scsi_cmnd *scsi_cmd; + struct ips_scb *q_next; + ips_scb_callback callback; + uint32_t sg_busaddr; + int sg_count; + dma_addr_t data_busaddr; +}; + +typedef struct ips_scb_queue ips_scb_queue_t; + +struct ips_wait_queue { + struct scsi_cmnd *head; + struct scsi_cmnd *tail; + int count; +}; + +typedef struct ips_wait_queue ips_wait_queue_entry_t; + +struct ips_copp_wait_item { + struct scsi_cmnd *scsi_cmd; + struct ips_copp_wait_item *next; +}; + +typedef struct ips_copp_wait_item ips_copp_wait_item_t; + +struct ips_copp_queue { + struct ips_copp_wait_item *head; + struct ips_copp_wait_item *tail; + int count; +}; + +typedef struct ips_copp_queue ips_copp_queue_t; + +typedef struct { + int (*reset)(struct ips_ha *); + int (*issue)(struct ips_ha *, struct ips_scb *); + int (*isinit)(struct ips_ha *); + int (*isintr)(struct ips_ha *); + int (*init)(struct ips_ha *); + int (*erasebios)(struct ips_ha *); + int (*programbios)(struct ips_ha *, char *, uint32_t, uint32_t); + int (*verifybios)(struct ips_ha *, char *, uint32_t, uint32_t); + void (*statinit)(struct ips_ha *); + int (*intr)(struct ips_ha *); + void (*enableint)(struct ips_ha *); + uint32_t (*statupd)(struct ips_ha *); +} ips_hw_func_t; + +struct ips_ha { + uint8_t ha_id[5]; + uint32_t dcdb_active[4]; + uint32_t io_addr; + uint8_t ntargets; + uint8_t nbus; + uint8_t nlun; + uint16_t ad_type; + uint16_t host_num; + uint32_t max_xfer; + uint32_t max_cmds; + uint32_t num_ioctl; + ips_stat_t sp; + struct ips_scb *scbs; + struct ips_scb *scb_freelist; + ips_wait_queue_entry_t scb_waitlist; + ips_copp_queue_t copp_waitlist; + ips_scb_queue_t scb_activelist; + IPS_IO_CMD *dummy; + IPS_ADAPTER *adapt; + IPS_LD_INFO *logical_drive_info; + dma_addr_t logical_drive_info_dma_addr; + IPS_ENQ *enq; + IPS_CONF *conf; + IPS_NVRAM_P5 *nvram; + IPS_SUBSYS *subsys; + char *ioctl_data; + uint32_t ioctl_datasize; + uint32_t cmd_in_progress; + int flags; + uint8_t waitflag; + uint8_t active; + int ioctl_reset; + uint16_t reset_count; + time64_t last_ffdc; + uint8_t slot_num; + int ioctl_len; + dma_addr_t ioctl_busaddr; + uint8_t bios_version[8]; + uint32_t mem_addr; + uint32_t io_len; + uint32_t mem_len; + char *mem_ptr; + char *ioremap_ptr; + ips_hw_func_t func; + struct pci_dev *pcidev; + char *flash_data; + int flash_len; + u32 flash_datasize; + dma_addr_t flash_busaddr; + dma_addr_t enq_busaddr; + uint8_t requires_esl; +}; + +typedef struct ips_scb ips_scb_t; + +struct ips_scb_pt { + IPS_HOST_COMMAND cmd; + IPS_DCDB_TABLE dcdb; + uint8_t target_id; + uint8_t bus; + uint8_t lun; + uint8_t cdb[12]; + uint32_t scb_busaddr; + uint32_t data_busaddr; + uint32_t timeout; + uint8_t basic_status; + uint8_t extended_status; + uint16_t breakup; + uint32_t data_len; + uint32_t sg_len; + uint32_t flags; + uint32_t op_code; + IPS_SG_LIST *sg_list; + struct scsi_cmnd *scsi_cmd; + struct ips_scb *q_next; + ips_scb_callback callback; +}; + +typedef struct ips_scb_pt ips_scb_pt_t; + +typedef struct { + uint8_t CoppID[4]; + uint32_t CoppCmd; + uint32_t PtBuffer; + uint8_t *CmdBuffer; + uint32_t CmdBSize; + ips_scb_pt_t CoppCP; + uint32_t TimeOut; + uint8_t BasicStatus; + uint8_t ExtendedStatus; + uint8_t AdapterType; + uint8_t reserved; +} ips_passthru_t; + +struct sym_chip { + u_short device_id; + u_short revision_id; + char *name; + u_char burst_max; + u_char offset_max; + u_char nr_divisor; + u_char lp_probe_bit; + u_int features; +}; + +struct sym_tblmove { + u32 size; + u32 addr; +}; + +struct sym_tblsel { + u_char sel_scntl4; + u_char sel_sxfer; + u_char sel_id; + u_char sel_scntl3; +}; + +struct sym_quehead { + struct sym_quehead *flink; + struct sym_quehead *blink; +}; + +typedef struct sym_quehead SYM_QUEHEAD; + +struct sym_slcb { + u_short reqtags; + u_short scdev_depth; +}; + +struct sym_shcb { + int unit; + char inst_name[16]; + char chip_name[8]; + struct Scsi_Host *host; + void *ioaddr; + void *ramaddr; + struct timer_list timer; + u_long lasttime; + u_long settle_time; + u_char settle_time_valid; +}; + +struct sym_hcb; + +struct sym_data { + struct sym_hcb *ncb; + struct completion *io_reset; + struct pci_dev *pdev; +}; + +struct sym_actscr { + u32 start; + u32 restart; +}; + +struct sym_ccbh { + struct sym_actscr go; + u32 savep; + u32 lastp; + u8 status[4]; +}; + +struct sym_tcbh { + u32 luntbl_sa; + u32 lun0_sa; + u_char uval; + u_char sval; + u_char filler1; + u_char wval; +}; + +struct sym_lcbh { + u32 resel_sa; + u32 itl_task_sa; + u32 itlq_tbl_sa; +}; + +struct sym_trans { + u8 period; + u8 offset; + unsigned int width: 1; + unsigned int iu: 1; + unsigned int dt: 1; + unsigned int qas: 1; + unsigned int check_nego: 1; + unsigned int renego: 2; +}; + +struct sym_lcb; + +struct sym_ccb; + +struct sym_tcb { + struct sym_tcbh head; + u32 *luntbl; + int nlcb; + struct sym_lcb *lun0p; + struct sym_lcb **lunmp; + struct sym_trans tgoal; + struct sym_trans tprint; + struct sym_ccb *nego_cp; + u_char to_reset; + unsigned char usrflags; + unsigned char usr_period; + unsigned char usr_width; + short unsigned int usrtags; + struct scsi_target *starget; +}; + +typedef struct device *m_pool_ident_t; + +struct sym_fwa_ba { + u32 start; + u32 getjob_begin; + u32 getjob_end; + u32 select; + u32 wf_sel_done; + u32 send_ident; + u32 dispatch; + u32 init; + u32 clrack; + u32 complete_error; + u32 done; + u32 done_end; + u32 idle; + u32 ungetjob; + u32 reselect; + u32 resel_tag; + u32 resel_dsa; + u32 resel_no_tag; + u32 data_in; + u32 data_in2; + u32 data_out; + u32 data_out2; + u32 pm0_data; + u32 pm1_data; +}; + +struct sym_fwb_ba { + u32 no_data; + u32 sel_for_abort; + u32 sel_for_abort_1; + u32 msg_bad; + u32 msg_weird; + u32 wdtr_resp; + u32 send_wdtr; + u32 sdtr_resp; + u32 send_sdtr; + u32 ppr_resp; + u32 send_ppr; + u32 nego_bad_phase; + u32 ident_break; + u32 ident_break_atn; + u32 sdata_in; + u32 resel_bad_lun; + u32 bad_i_t_l; + u32 bad_i_t_l_q; + u32 wsr_ma_helper; + u32 start64; + u32 pm_handle; +}; + +struct sym_fwz_ba { + u32 snooptest; + u32 snoopend; +}; + +struct sym_fw; + +struct sym_hcb { + struct sym_ccbh ccb_head; + struct sym_tcbh tcb_head; + struct sym_lcbh lcb_head; + struct sym_actscr idletask; + struct sym_actscr notask; + struct sym_actscr bad_itl; + struct sym_actscr bad_itlq; + u32 idletask_ba; + u32 notask_ba; + u32 bad_itl_ba; + u32 bad_itlq_ba; + u32 *badluntbl; + u32 badlun_sa; + u32 hcb_ba; + u32 scr_ram_seg; + u_char sv_scntl0; + u_char sv_scntl3; + u_char sv_dmode; + u_char sv_dcntl; + u_char sv_ctest3; + u_char sv_ctest4; + u_char sv_ctest5; + u_char sv_gpcntl; + u_char sv_stest2; + u_char sv_stest4; + u_char sv_scntl4; + u_char sv_stest1; + u_char rv_scntl0; + u_char rv_scntl3; + u_char rv_dmode; + u_char rv_dcntl; + u_char rv_ctest3; + u_char rv_ctest4; + u_char rv_ctest5; + u_char rv_stest2; + u_char rv_ccntl0; + u_char rv_ccntl1; + u_char rv_scntl4; + struct sym_tcb target[16]; + u32 *targtbl; + u32 targtbl_ba; + m_pool_ident_t bus_dmat; + struct sym_shcb s; + u32 mmio_ba; + u32 ram_ba; + u_char *scripta0; + u_char *scriptb0; + u_char *scriptz0; + u32 scripta_ba; + u32 scriptb_ba; + u32 scriptz_ba; + u_short scripta_sz; + u_short scriptb_sz; + u_short scriptz_sz; + struct sym_fwa_ba fwa_bas; + struct sym_fwb_ba fwb_bas; + struct sym_fwz_ba fwz_bas; + void (*fw_setup)(struct sym_hcb *, struct sym_fw *); + void (*fw_patch)(struct Scsi_Host *); + char *fw_name; + u_int features; + u_char myaddr; + u_char maxburst; + u_char maxwide; + u_char minsync; + u_char maxsync; + u_char maxoffs; + u_char minsync_dt; + u_char maxsync_dt; + u_char maxoffs_dt; + u_char multiplier; + u_char clock_divn; + u32 clock_khz; + u32 pciclk_khz; + volatile u32 *squeue; + u32 squeue_ba; + u_short squeueput; + u_short actccbs; + u_short dqueueget; + volatile u32 *dqueue; + u32 dqueue_ba; + u_char msgout[8]; + u_char msgin[8]; + u32 lastmsg; + u32 scratch; + u_char usrflags; + u_char scsi_mode; + u_char verbose; + struct sym_ccb **ccbh; + SYM_QUEHEAD free_ccbq; + SYM_QUEHEAD busy_ccbq; + SYM_QUEHEAD comp_ccbq; + u_char abrt_msg[4]; + struct sym_tblmove abrt_tbl; + struct sym_tblsel abrt_sel; + u_char istat_sem; + u_char use_dac; +}; + +struct sym_fwa_ofs { + u_short start; + u_short getjob_begin; + u_short getjob_end; + u_short select; + u_short wf_sel_done; + u_short send_ident; + u_short dispatch; + u_short init; + u_short clrack; + u_short complete_error; + u_short done; + u_short done_end; + u_short idle; + u_short ungetjob; + u_short reselect; + u_short resel_tag; + u_short resel_dsa; + u_short resel_no_tag; + u_short data_in; + u_short data_in2; + u_short data_out; + u_short data_out2; + u_short pm0_data; + u_short pm1_data; +}; + +struct sym_fwb_ofs { + u_short no_data; + u_short sel_for_abort; + u_short sel_for_abort_1; + u_short msg_bad; + u_short msg_weird; + u_short wdtr_resp; + u_short send_wdtr; + u_short sdtr_resp; + u_short send_sdtr; + u_short ppr_resp; + u_short send_ppr; + u_short nego_bad_phase; + u_short ident_break; + u_short ident_break_atn; + u_short sdata_in; + u_short resel_bad_lun; + u_short bad_i_t_l; + u_short bad_i_t_l_q; + u_short wsr_ma_helper; + u_short start64; + u_short pm_handle; +}; + +struct sym_fwz_ofs { + u_short snooptest; + u_short snoopend; +}; + +struct sym_fw { + char *name; + u32 *a_base; + int a_size; + struct sym_fwa_ofs *a_ofs; + u32 *b_base; + int b_size; + struct sym_fwb_ofs *b_ofs; + u32 *z_base; + int z_size; + struct sym_fwz_ofs *z_ofs; + void (*setup)(struct sym_hcb *, struct sym_fw *); + void (*patch)(struct Scsi_Host *); +}; + +struct sym_lcb { + struct sym_lcbh head; + u32 *itlq_tbl; + u_short busy_itlq; + u_short busy_itl; + u_short ia_tag; + u_short if_tag; + u_char *cb_tags; + struct sym_slcb s; + u_char tags_si; + u_short tags_sum[2]; + u_short tags_since; + u_char to_clear; + u_char user_flags; + u_char curr_flags; +}; + +struct sym_pmc { + struct sym_tblmove sg; + u32 ret; +}; + +struct sym_dsb { + struct sym_ccbh head; + struct sym_pmc pm0; + struct sym_pmc pm1; + struct sym_tblsel select; + struct sym_tblmove smsg; + struct sym_tblmove smsg_ext; + struct sym_tblmove cmd; + struct sym_tblmove sense; + struct sym_tblmove wresid; + struct sym_tblmove data[96]; +}; + +struct sym_ccb { + struct sym_dsb phys; + struct scsi_cmnd *cmd; + u8 cdb_buf[16]; + u8 sns_bbuf[32]; + int data_len; + int segments; + u8 order; + unsigned char odd_byte_adjustment; + u_char nego_status; + u_char xerr_status; + u32 extra_bytes; + u_char scsi_smsg[12]; + u_char scsi_smsg2[12]; + u_char sensecmd[6]; + u_char sv_scsi_status; + u_char sv_xerr_status; + int sv_resid; + u32 ccb_ba; + u_short tag; + u_char target; + u_char lun; + struct sym_ccb *link_ccbh; + SYM_QUEHEAD link_ccbq; + u32 startp; + u32 goalp; + int ext_sg; + int ext_ofs; + u_char to_abort; + u_char tags_si; +}; + +struct sym_fw1a_scr { + u32 start[11]; + u32 getjob_begin[4]; + u32 _sms_a10[5]; + u32 getjob_end[4]; + u32 _sms_a20[4]; + u32 select[6]; + u32 _sms_a30[5]; + u32 wf_sel_done[2]; + u32 send_ident[2]; + u32 select2[2]; + u32 command[2]; + u32 dispatch[28]; + u32 sel_no_cmd[10]; + u32 init[6]; + u32 clrack[4]; + u32 datai_done[11]; + u32 datai_done_wsr[20]; + u32 datao_done[11]; + u32 datao_done_wss[6]; + u32 datai_phase[5]; + u32 datao_phase[5]; + u32 msg_in[2]; + u32 msg_in2[10]; + u32 status[10]; + u32 complete[6]; + u32 complete2[8]; + u32 _sms_a40[12]; + u32 done[5]; + u32 _sms_a50[5]; + u32 _sms_a60[2]; + u32 done_end[4]; + u32 complete_error[5]; + u32 save_dp[11]; + u32 restore_dp[7]; + u32 disconnect[11]; + u32 disconnect2[5]; + u32 _sms_a65[3]; + u32 idle[2]; + u32 ungetjob[5]; + u32 reselect[2]; + u32 reselected[19]; + u32 _sms_a70[6]; + u32 _sms_a80[4]; + u32 reselected1[25]; + u32 _sms_a90[4]; + u32 resel_lun0[7]; + u32 _sms_a100[4]; + u32 resel_tag[8]; + u32 _sms_a110[13]; + u32 _sms_a120[2]; + u32 resel_go[4]; + u32 _sms_a130[7]; + u32 resel_dsa[2]; + u32 resel_dsa1[4]; + u32 _sms_a140[7]; + u32 resel_no_tag[4]; + u32 _sms_a145[7]; + u32 data_in[192]; + u32 data_in2[4]; + u32 data_out[192]; + u32 data_out2[4]; + u32 pm0_data[12]; + u32 pm0_data_out[6]; + u32 pm0_data_end[7]; + u32 pm_data_end[4]; + u32 _sms_a150[4]; + u32 pm1_data[12]; + u32 pm1_data_out[6]; + u32 pm1_data_end[9]; +}; + +struct sym_fw1b_scr { + u32 no_data[2]; + u32 sel_for_abort[16]; + u32 sel_for_abort_1[2]; + u32 msg_in_etc[12]; + u32 msg_received[5]; + u32 msg_weird_seen[5]; + u32 msg_extended[17]; + u32 _sms_b10[4]; + u32 msg_bad[6]; + u32 msg_weird[4]; + u32 msg_weird1[8]; + u32 wdtr_resp[6]; + u32 send_wdtr[4]; + u32 sdtr_resp[6]; + u32 send_sdtr[4]; + u32 ppr_resp[6]; + u32 send_ppr[4]; + u32 nego_bad_phase[4]; + u32 msg_out[4]; + u32 msg_out_done[4]; + u32 data_ovrun[3]; + u32 data_ovrun1[22]; + u32 data_ovrun2[8]; + u32 abort_resel[16]; + u32 resend_ident[4]; + u32 ident_break[4]; + u32 ident_break_atn[4]; + u32 sdata_in[6]; + u32 resel_bad_lun[4]; + u32 bad_i_t_l[4]; + u32 bad_i_t_l_q[4]; + u32 bad_status[7]; + u32 wsr_ma_helper[4]; + u32 zero[1]; + u32 scratch[1]; + u32 scratch1[1]; + u32 prev_done[1]; + u32 done_pos[1]; + u32 nextjob[1]; + u32 startpos[1]; + u32 targtbl[1]; +}; + +struct sym_fw1z_scr { + u32 snooptest[9]; + u32 snoopend[2]; +}; + +struct sym_fw2a_scr { + u32 start[14]; + u32 getjob_begin[4]; + u32 getjob_end[4]; + u32 select[4]; + u32 wf_sel_done[2]; + u32 sel_done[2]; + u32 send_ident[2]; + u32 select2[2]; + u32 command[2]; + u32 dispatch[28]; + u32 sel_no_cmd[10]; + u32 init[6]; + u32 clrack[4]; + u32 datai_done[10]; + u32 datai_done_wsr[20]; + u32 datao_done[10]; + u32 datao_done_wss[6]; + u32 datai_phase[4]; + u32 datao_phase[6]; + u32 msg_in[2]; + u32 msg_in2[10]; + u32 status[10]; + u32 complete[6]; + u32 complete2[12]; + u32 done[14]; + u32 done_end[2]; + u32 complete_error[4]; + u32 save_dp[12]; + u32 restore_dp[8]; + u32 disconnect[12]; + u32 idle[2]; + u32 ungetjob[4]; + u32 reselect[2]; + u32 reselected[22]; + u32 resel_scntl4[20]; + u32 resel_lun0[6]; + u32 resel_tag[16]; + u32 resel_dsa[2]; + u32 resel_dsa1[4]; + u32 resel_no_tag[6]; + u32 data_in[192]; + u32 data_in2[4]; + u32 data_out[192]; + u32 data_out2[4]; + u32 pm0_data[12]; + u32 pm0_data_out[6]; + u32 pm0_data_end[6]; + u32 pm1_data[12]; + u32 pm1_data_out[6]; + u32 pm1_data_end[6]; +}; + +struct sym_fw2b_scr { + u32 start64[2]; + u32 no_data[2]; + u32 sel_for_abort[16]; + u32 sel_for_abort_1[2]; + u32 msg_in_etc[12]; + u32 msg_received[4]; + u32 msg_weird_seen[4]; + u32 msg_extended[20]; + u32 msg_bad[6]; + u32 msg_weird[4]; + u32 msg_weird1[8]; + u32 wdtr_resp[6]; + u32 send_wdtr[4]; + u32 sdtr_resp[6]; + u32 send_sdtr[4]; + u32 ppr_resp[6]; + u32 send_ppr[4]; + u32 nego_bad_phase[4]; + u32 msg_out[4]; + u32 msg_out_done[4]; + u32 data_ovrun[2]; + u32 data_ovrun1[22]; + u32 data_ovrun2[8]; + u32 abort_resel[16]; + u32 resend_ident[4]; + u32 ident_break[4]; + u32 ident_break_atn[4]; + u32 sdata_in[6]; + u32 resel_bad_lun[4]; + u32 bad_i_t_l[4]; + u32 bad_i_t_l_q[4]; + u32 bad_status[6]; + u32 pm_handle[20]; + u32 pm_handle1[4]; + u32 pm_save[4]; + u32 pm0_save[12]; + u32 pm_save_end[4]; + u32 pm1_save[14]; + u32 pm_wsr_handle[38]; + u32 wsr_ma_helper[4]; + u32 zero[1]; + u32 scratch[1]; + u32 pm0_data_addr[1]; + u32 pm1_data_addr[1]; + u32 done_pos[1]; + u32 startpos[1]; + u32 targtbl[1]; +}; + +struct sym_fw2z_scr { + u32 snooptest[6]; + u32 snoopend[2]; +}; + +struct sym_driver_setup { + u_short max_tag; + u_char burst_order; + u_char scsi_led; + u_char scsi_diff; + u_char irq_mode; + u_char scsi_bus_check; + u_char host_id; + u_char verbose; + u_char settle_delay; + u_char use_nvram; + u_long excludes[8]; +}; + +struct sym_nvram; + +struct sym_device { + struct pci_dev *pdev; + long unsigned int mmio_base; + long unsigned int ram_base; + struct { + void *ioaddr; + void *ramaddr; + } s; + struct sym_chip chip; + struct sym_nvram *nvram; + u_char host_id; +}; + +struct Symbios_host { + u_short type; + u_short device_id; + u_short vendor_id; + u_char bus_nr; + u_char device_fn; + u_short word8; + u_short flags; + u_short io_port; +}; + +struct Symbios_target { + u_char flags; + u_char rsvd; + u_char bus_width; + u_char sync_offset; + u_short sync_period; + u_short timeout; +}; + +struct Symbios_scam { + u_short id; + u_short method; + u_short status; + u_char target_id; + u_char rsvd; +}; + +struct Symbios_nvram { + u_short type; + u_short byte_count; + u_short checksum; + u_char v_major; + u_char v_minor; + u32 boot_crc; + u_short flags; + u_short flags1; + u_short term_state; + u_short rmvbl_flags; + u_char host_id; + u_char num_hba; + u_char num_devices; + u_char max_scam_devices; + u_char num_valid_scam_devices; + u_char flags2; + struct Symbios_host host[4]; + struct Symbios_target target[16]; + struct Symbios_scam scam[4]; + u_char spare_devices[120]; + u_char trailer[6]; +}; + +typedef struct Symbios_nvram Symbios_nvram; + +struct Tekram_target { + u_char flags; + u_char sync_index; + u_short word2; +}; + +struct Tekram_nvram { + struct Tekram_target target[16]; + u_char host_id; + u_char flags; + u_char boot_delay_index; + u_char max_tags_index; + u_short flags1; + u_short spare[29]; +}; + +typedef struct Tekram_nvram Tekram_nvram; + +struct pdc_initiator { + int dummy; +}; + +struct sym_nvram { + int type; + union { + Symbios_nvram Symbios; + Tekram_nvram Tekram; + struct pdc_initiator parisc; + } data; +}; + +struct sym_ucmd { + struct completion *eh_done; +}; + +struct sym_usrcmd { + u_long target; + u_long lun; + u_long data; + u_long cmd; +}; + +struct sym_m_link { + struct sym_m_link *next; +}; + +typedef struct sym_m_link *m_link_p; + +struct sym_m_vtob { + struct sym_m_vtob *next; + void *vaddr; + dma_addr_t baddr; +}; + +typedef struct sym_m_vtob *m_vtob_p; + +struct sym_m_pool { + m_pool_ident_t dev_dmat; + void * (*get_mem_cluster)(struct sym_m_pool *); + void (*free_mem_cluster)(struct sym_m_pool *, void *); + int nump; + m_vtob_p vtob[32]; + struct sym_m_pool *next; + struct sym_m_link h[9]; +}; + +typedef struct sym_m_pool *m_pool_p; + +typedef struct Symbios_target Symbios_target; + +typedef char *__kernel_caddr_t; + +typedef __kernel_caddr_t caddr_t; + +struct mbox_out { + u8 cmd; + u8 cmdid; + u16 numsectors; + u32 lba; + u32 xferaddr; + u8 logdrv; + u8 numsgelements; + u8 resvd; +} __attribute__((packed)); + +struct mbox_in { + volatile u8 busy; + volatile u8 numstatus; + volatile u8 status; + volatile u8 completed[46]; + volatile u8 poll; + volatile u8 ack; +}; + +typedef struct { + struct mbox_out m_out; + struct mbox_in m_in; +} __attribute__((packed)) mbox_t; + +typedef struct { + u32 xfer_segment_lo; + u32 xfer_segment_hi; + mbox_t mbox; +} __attribute__((packed)) mbox64_t; + +typedef struct { + u8 timeout: 3; + u8 ars: 1; + u8 reserved: 3; + u8 islogical: 1; + u8 logdrv; + u8 channel; + u8 target; + u8 queuetag; + u8 queueaction; + u8 cdb[10]; + u8 cdblen; + u8 reqsenselen; + u8 reqsensearea[32]; + u8 numsgelements; + u8 scsistatus; + u32 dataxferaddr; + u32 dataxferlen; +} mega_passthru; + +typedef struct { + u8 timeout: 3; + u8 ars: 1; + u8 rsvd1: 1; + u8 cd_rom: 1; + u8 rsvd2: 1; + u8 islogical: 1; + u8 logdrv; + u8 channel; + u8 target; + u8 queuetag; + u8 queueaction; + u8 cdblen; + u8 rsvd3; + u8 cdb[16]; + u8 numsgelements; + u8 status; + u8 reqsenselen; + u8 reqsensearea[32]; + u8 rsvd4; + u32 dataxferaddr; + u32 dataxferlen; +} mega_ext_passthru; + +typedef struct { + u64 address; + u32 length; +} __attribute__((packed)) mega_sgl64; + +typedef struct { + u32 address; + u32 length; +} mega_sglist; + +typedef struct { + int idx; + u32 state; + struct list_head list; + u8 raw_mbox[66]; + u32 dma_type; + u32 dma_direction; + struct scsi_cmnd *cmd; + dma_addr_t dma_h_bulkdata; + dma_addr_t dma_h_sgdata; + mega_sglist *sgl; + mega_sgl64 *sgl64; + dma_addr_t sgl_dma_addr; + mega_passthru *pthru; + dma_addr_t pthru_dma_addr; + mega_ext_passthru *epthru; + dma_addr_t epthru_dma_addr; +} scb_t; + +typedef struct { + u32 data_size; + u32 config_signature; + u8 fw_version[16]; + u8 bios_version[16]; + u8 product_name[80]; + u8 max_commands; + u8 nchannels; + u8 fc_loop_present; + u8 mem_type; + u32 signature; + u16 dram_size; + u16 subsysid; + u16 subsysvid; + u8 notify_counters; + u8 pad1k[889]; +} mega_product_info; + +struct notify { + u32 global_counter; + u8 param_counter; + u8 param_id; + u16 param_val; + u8 write_config_counter; + u8 write_config_rsvd[3]; + u8 ldrv_op_counter; + u8 ldrv_opid; + u8 ldrv_opcmd; + u8 ldrv_opstatus; + u8 ldrv_state_counter; + u8 ldrv_state_id; + u8 ldrv_state_new; + u8 ldrv_state_old; + u8 pdrv_state_counter; + u8 pdrv_state_id; + u8 pdrv_state_new; + u8 pdrv_state_old; + u8 pdrv_fmt_counter; + u8 pdrv_fmt_id; + u8 pdrv_fmt_val; + u8 pdrv_fmt_rsvd; + u8 targ_xfer_counter; + u8 targ_xfer_id; + u8 targ_xfer_val; + u8 targ_xfer_rsvd; + u8 fcloop_id_chg_counter; + u8 fcloopid_pdrvid; + u8 fcloop_id0; + u8 fcloop_id1; + u8 fcloop_state_counter; + u8 fcloop_state0; + u8 fcloop_state1; + u8 fcloop_state_rsvd; +}; + +typedef struct { + u32 data_size; + struct notify notify; + u8 notify_rsvd[88]; + u8 rebuild_rate; + u8 cache_flush_interval; + u8 sense_alert; + u8 drive_insert_count; + u8 battery_status; + u8 num_ldrv; + u8 recon_state[5]; + u16 ldrv_op_status[5]; + u32 ldrv_size[40]; + u8 ldrv_prop[40]; + u8 ldrv_state[40]; + u8 pdrv_state[256]; + u16 pdrv_format[16]; + u8 targ_xfer[80]; + u8 pad1k[263]; +} __attribute__((packed)) mega_inquiry3; + +typedef struct { + u8 max_commands; + u8 rebuild_rate; + u8 max_targ_per_chan; + u8 nchannels; + u8 fw_version[4]; + u16 age_of_flash; + u8 chip_set_value; + u8 dram_size; + u8 cache_flush_interval; + u8 bios_version[4]; + u8 board_type; + u8 sense_alert; + u8 write_config_count; + u8 drive_inserted_count; + u8 inserted_drive; + u8 battery_status; + u8 dec_fault_bus_info; +} mega_adp_info; + +typedef struct { + u8 num_ldrv; + u8 rsvd[3]; + u32 ldrv_size[8]; + u8 ldrv_prop[8]; + u8 ldrv_state[8]; +} mega_ldrv_info; + +typedef struct { + u8 pdrv_state[75]; + u8 rsvd; +} mega_pdrv_info; + +typedef struct { + mega_adp_info adapter_info; + mega_ldrv_info logdrv_info; + mega_pdrv_info pdrv_info; +} mraid_inquiry; + +typedef struct { + mraid_inquiry raid_inq; + u16 phys_drv_format[5]; + u8 stack_attn; + u8 modem_status; + u8 rsvd[2]; +} __attribute__((packed)) mraid_ext_inquiry; + +typedef struct { + u8 channel; + u8 target; +} adp_device; + +typedef struct { + u32 start_blk; + u32 num_blks; + adp_device device[32]; +} adp_span_40ld; + +typedef struct { + u32 start_blk; + u32 num_blks; + adp_device device[8]; +} adp_span_8ld; + +typedef struct { + u8 span_depth; + u8 level; + u8 read_ahead; + u8 stripe_sz; + u8 status; + u8 write_mode; + u8 direct_io; + u8 row_size; +} logdrv_param; + +typedef struct { + logdrv_param lparam; + adp_span_40ld span[8]; +} logdrv_40ld; + +typedef struct { + logdrv_param lparam; + adp_span_8ld span[8]; +} logdrv_8ld; + +typedef struct { + u8 type; + u8 cur_status; + u8 tag_depth; + u8 sync_neg; + u32 size; +} phys_drv; + +typedef struct { + u8 nlog_drives; + u8 resvd[3]; + logdrv_40ld ldrv[40]; + phys_drv pdrv[75]; +} disk_array_40ld; + +typedef struct { + u8 nlog_drives; + u8 resvd[3]; + logdrv_8ld ldrv[8]; + phys_drv pdrv[75]; +} disk_array_8ld; + +struct uioctl_t { + u32 inlen; + u32 outlen; + union { + u8 fca[16]; + struct { + u8 opcode; + u8 subopcode; + u16 adapno; + u8 *buffer; + u32 length; + } __attribute__((packed)) fcs; + } ui; + u8 mbox[18]; + mega_passthru pthru; + char *data; +} __attribute__((packed)); + +struct mcontroller { + u64 base; + u8 irq; + u8 numldrv; + u8 pcibus; + u16 pcidev; + u8 pcifun; + u16 pciid; + u16 pcivendor; + u8 pcislot; + u32 uid; +}; + +typedef struct { + u8 cmd; + u8 cmdid; + u8 opcode; + u8 subopcode; + u32 lba; + u32 xferaddr; + u8 logdrv; + u8 rsvd[3]; + u8 numstatus; + u8 status; +} __attribute__((packed)) megacmd_t; + +typedef struct { + char signature[8]; + u32 opcode; + u32 adapno; + union { + u8 __raw_mbox[18]; + void *__uaddr; + } __ua; + u32 xferlen; + u32 flags; +} nitioctl_t; + +struct private_bios_data { + u8 geometry: 4; + u8 unused: 4; + u8 boot_drv; + u8 rsvd[12]; + u16 cksum; +}; + +typedef struct { + int this_id; + u32 flag; + long unsigned int base; + void *mmio_base; + mbox64_t *una_mbox64; + dma_addr_t una_mbox64_dma; + volatile mbox64_t *mbox64; + volatile mbox_t *mbox; + dma_addr_t mbox_dma; + struct pci_dev *dev; + struct list_head free_list; + struct list_head pending_list; + struct list_head completed_list; + struct Scsi_Host *host; + u8 *mega_buffer; + dma_addr_t buf_dma_handle; + mega_product_info product_info; + u8 max_cmds; + scb_t *scb_list; + atomic_t pend_cmds; + u8 numldrv; + u8 fw_version[7]; + u8 bios_version[7]; + struct proc_dir_entry *controller_proc_dir_entry; + int has_64bit_addr; + int support_ext_cdb; + int boot_ldrv_enabled; + int boot_ldrv; + int boot_pdrv_enabled; + int boot_pdrv_ch; + int boot_pdrv_tgt; + int support_random_del; + int read_ldidmap; + atomic_t quiescent; + spinlock_t lock; + u8 logdrv_chan[9]; + int mega_ch_class; + u8 sglen; + scb_t int_scb; + struct mutex int_mtx; + int int_status; + struct completion int_waitq; + int has_cluster; +} adapter_t; + +struct mega_hbas { + int is_bios_enabled; + adapter_t *hostdata_addr; +}; + +typedef s8 int8_t; + +typedef struct { + uint8_t cmd; + uint8_t cmdid; + uint16_t numsectors; + uint32_t lba; + uint32_t xferaddr; + uint8_t logdrv; + uint8_t numsge; + uint8_t resvd; + uint8_t busy; + uint8_t numstatus; + uint8_t status; + uint8_t completed[46]; + uint8_t poll; + uint8_t ack; +} __attribute__((packed)) mbox_t___2; + +typedef struct { + uint32_t xferaddr_lo; + uint32_t xferaddr_hi; + mbox_t___2 mbox32; +} __attribute__((packed)) mbox64_t___2; + +typedef struct { + uint8_t timeout: 3; + uint8_t ars: 1; + uint8_t reserved: 3; + uint8_t islogical: 1; + uint8_t logdrv; + uint8_t channel; + uint8_t target; + uint8_t queuetag; + uint8_t queueaction; + uint8_t cdb[10]; + uint8_t cdblen; + uint8_t reqsenselen; + uint8_t reqsensearea[32]; + uint8_t numsge; + uint8_t scsistatus; + uint32_t dataxferaddr; + uint32_t dataxferlen; +} mraid_passthru_t; + +struct uioc { + uint8_t signature[16]; + uint16_t mb_type; + uint16_t app_type; + uint32_t opcode; + uint32_t adapno; + uint64_t cmdbuf; + uint32_t xferlen; + uint32_t data_dir; + int32_t status; + uint8_t reserved[128]; + void *user_data; + uint32_t user_data_len; + uint32_t pad_for_64bit_align; + mraid_passthru_t *user_pthru; + mraid_passthru_t *pthru32; + dma_addr_t pthru32_h; + struct list_head list; + void (*done)(struct uioc *); + caddr_t buf_vaddr; + dma_addr_t buf_paddr; + int8_t pool_index; + uint8_t free_buf; + uint8_t timedout; + long: 40; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +} __attribute__((packed)); + +typedef struct uioc uioc_t; + +struct uioc_timeout { + struct timer_list timer; + uioc_t *uioc; +}; + +struct mraid_hba_info { + uint16_t pci_vendor_id; + uint16_t pci_device_id; + uint16_t subsys_vendor_id; + uint16_t subsys_device_id; + uint64_t baseport; + uint8_t pci_bus; + uint8_t pci_dev_fn; + uint8_t pci_slot; + uint8_t irq; + uint32_t unique_id; + uint32_t host_no; + uint8_t num_ldrv; + long: 24; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +typedef struct mraid_hba_info mraid_hba_info_t; + +struct mcontroller___2 { + uint64_t base; + uint8_t irq; + uint8_t numldrv; + uint8_t pcibus; + uint16_t pcidev; + uint8_t pcifun; + uint16_t pciid; + uint16_t pcivendor; + uint8_t pcislot; + uint32_t uid; +} __attribute__((packed)); + +typedef struct mcontroller___2 mcontroller_t; + +struct mm_dmapool { + caddr_t vaddr; + dma_addr_t paddr; + uint32_t buf_size; + struct dma_pool___2 *handle; + spinlock_t lock; + uint8_t in_use; +}; + +typedef struct mm_dmapool mm_dmapool_t; + +struct mraid_mmadp { + uint32_t unique_id; + uint32_t drvr_type; + long unsigned int drvr_data; + uint16_t timeout; + uint8_t max_kioc; + struct pci_dev *pdev; + int (*issue_uioc)(long unsigned int, uioc_t *, uint32_t); + uint32_t quiescent; + struct list_head list; + uioc_t *kioc_list; + struct list_head kioc_pool; + spinlock_t kioc_pool_lock; + struct semaphore kioc_semaphore; + mbox64_t___2 *mbox_list; + struct dma_pool___2 *pthru_dma_pool; + mm_dmapool_t dma_pool_list[5]; +}; + +typedef struct mraid_mmadp mraid_mmadp_t; + +struct mimd { + uint32_t inlen; + uint32_t outlen; + union { + uint8_t fca[16]; + struct { + uint8_t opcode; + uint8_t subopcode; + uint16_t adapno; + uint8_t *buffer; + uint32_t length; + } __attribute__((packed)) fcs; + } ui; + uint8_t mbox[18]; + mraid_passthru_t pthru; + char *data; +} __attribute__((packed)); + +typedef struct mimd mimd_t; + +typedef struct { + caddr_t ccb; + struct list_head list; + long unsigned int gp; + unsigned int sno; + struct scsi_cmnd *scp; + uint32_t state; + uint32_t dma_direction; + uint32_t dma_type; + uint16_t dev_channel; + uint16_t dev_target; + uint32_t status; +} scb_t___2; + +typedef struct { + struct tasklet_struct dpc_h; + struct pci_dev *pdev; + struct Scsi_Host *host; + spinlock_t lock; + uint8_t quiescent; + int outstanding_cmds; + scb_t___2 *kscb_list; + struct list_head kscb_pool; + spinlock_t kscb_pool_lock; + struct list_head pend_list; + spinlock_t pend_list_lock; + struct list_head completed_list; + spinlock_t completed_list_lock; + uint16_t sglen; + int device_ids[1040]; + caddr_t raid_device; + uint8_t max_channel; + uint16_t max_target; + uint8_t max_lun; + uint32_t unique_id; + int irq; + uint8_t ito; + caddr_t ibuf; + dma_addr_t ibuf_dma_h; + scb_t___2 *uscb_list; + struct list_head uscb_pool; + spinlock_t uscb_pool_lock; + int max_cmds; + uint8_t fw_version[16]; + uint8_t bios_version[16]; + uint8_t max_cdb_sz; + uint8_t ha; + uint16_t init_id; + uint16_t max_sectors; + uint16_t cmd_per_lun; + atomic_t being_detached; +} adapter_t___2; + +struct mraid_pci_blk { + caddr_t vaddr; + dma_addr_t dma_addr; +}; + +typedef struct { + uint8_t timeout: 3; + uint8_t ars: 1; + uint8_t rsvd1: 1; + uint8_t cd_rom: 1; + uint8_t rsvd2: 1; + uint8_t islogical: 1; + uint8_t logdrv; + uint8_t channel; + uint8_t target; + uint8_t queuetag; + uint8_t queueaction; + uint8_t cdblen; + uint8_t rsvd3; + uint8_t cdb[16]; + uint8_t numsge; + uint8_t status; + uint8_t reqsenselen; + uint8_t reqsensearea[32]; + uint8_t rsvd4; + uint32_t dataxferaddr; + uint32_t dataxferlen; +} mraid_epassthru_t; + +typedef struct { + uint32_t data_size; + uint32_t config_signature; + uint8_t fw_version[16]; + uint8_t bios_version[16]; + uint8_t product_name[80]; + uint8_t max_commands; + uint8_t nchannels; + uint8_t fc_loop_present; + uint8_t mem_type; + uint32_t signature; + uint16_t dram_size; + uint16_t subsysid; + uint16_t subsysvid; + uint8_t notify_counters; + uint8_t pad1k[889]; +} mraid_pinfo_t; + +typedef struct { + uint32_t global_counter; + uint8_t param_counter; + uint8_t param_id; + uint16_t param_val; + uint8_t write_config_counter; + uint8_t write_config_rsvd[3]; + uint8_t ldrv_op_counter; + uint8_t ldrv_opid; + uint8_t ldrv_opcmd; + uint8_t ldrv_opstatus; + uint8_t ldrv_state_counter; + uint8_t ldrv_state_id; + uint8_t ldrv_state_new; + uint8_t ldrv_state_old; + uint8_t pdrv_state_counter; + uint8_t pdrv_state_id; + uint8_t pdrv_state_new; + uint8_t pdrv_state_old; + uint8_t pdrv_fmt_counter; + uint8_t pdrv_fmt_id; + uint8_t pdrv_fmt_val; + uint8_t pdrv_fmt_rsvd; + uint8_t targ_xfer_counter; + uint8_t targ_xfer_id; + uint8_t targ_xfer_val; + uint8_t targ_xfer_rsvd; + uint8_t fcloop_id_chg_counter; + uint8_t fcloopid_pdrvid; + uint8_t fcloop_id0; + uint8_t fcloop_id1; + uint8_t fcloop_state_counter; + uint8_t fcloop_state0; + uint8_t fcloop_state1; + uint8_t fcloop_state_rsvd; +} mraid_notify_t; + +typedef struct { + uint32_t data_size; + mraid_notify_t notify; + uint8_t notify_rsvd[88]; + uint8_t rebuild_rate; + uint8_t cache_flush_int; + uint8_t sense_alert; + uint8_t drive_insert_count; + uint8_t battery_status; + uint8_t num_ldrv; + uint8_t recon_state[5]; + uint16_t ldrv_op_status[5]; + uint32_t ldrv_size[40]; + uint8_t ldrv_prop[40]; + uint8_t ldrv_state[40]; + uint8_t pdrv_state[256]; + uint16_t pdrv_format[16]; + uint8_t targ_xfer[80]; + uint8_t pad1k[263]; +} __attribute__((packed)) mraid_inquiry3_t; + +typedef struct { + uint64_t address; + uint32_t length; +} __attribute__((packed)) mbox_sgl64; + +typedef struct { + uint32_t address; + uint32_t length; +} mbox_sgl32; + +typedef struct { + uint8_t *raw_mbox; + mbox_t___2 *mbox; + mbox64_t___2 *mbox64; + dma_addr_t mbox_dma_h; + mbox_sgl64 *sgl64; + mbox_sgl32 *sgl32; + dma_addr_t sgl_dma_h; + mraid_passthru_t *pthru; + dma_addr_t pthru_dma_h; + mraid_epassthru_t *epthru; + dma_addr_t epthru_dma_h; + dma_addr_t buf_dma_h; +} mbox_ccb_t; + +typedef struct { + mbox64_t___2 *una_mbox64; + dma_addr_t una_mbox64_dma; + mbox_t___2 *mbox; + mbox64_t___2 *mbox64; + dma_addr_t mbox_dma; + spinlock_t mailbox_lock; + long unsigned int baseport; + void *baseaddr; + struct mraid_pci_blk mbox_pool[128]; + struct dma_pool___2 *mbox_pool_handle; + struct mraid_pci_blk epthru_pool[128]; + struct dma_pool___2 *epthru_pool_handle; + struct mraid_pci_blk sg_pool[128]; + struct dma_pool___2 *sg_pool_handle; + mbox_ccb_t ccb_list[128]; + mbox_ccb_t uccb_list[32]; + mbox64_t___2 umbox64[32]; + uint8_t pdrv_state[75]; + uint32_t last_disp; + int hw_error; + int fast_load; + uint8_t channel_class; + struct mutex sysfs_mtx; + uioc_t *sysfs_uioc; + mbox64_t___2 *sysfs_mbox64; + caddr_t sysfs_buffer; + dma_addr_t sysfs_buffer_dma; + wait_queue_head_t sysfs_wait_q; + int random_del_supported; + uint16_t curr_ldmap[64]; +} mraid_device_t; + +struct TAG_twa_message_type { + unsigned int code; + char *text; +}; + +typedef struct TAG_twa_message_type twa_message_type; + +struct TAG_TW_SG_Entry { + dma_addr_t address; + u32 length; +} __attribute__((packed)); + +typedef struct TAG_TW_SG_Entry TW_SG_Entry; + +struct TW_Command { + unsigned char opcode__sgloffset; + unsigned char size; + unsigned char request_id; + unsigned char unit__hostid; + unsigned char status; + unsigned char flags; + union { + short unsigned int block_count; + short unsigned int parameter_count; + } byte6_offset; + union { + struct { + u32 lba; + TW_SG_Entry sgl[41]; + dma_addr_t padding; + } __attribute__((packed)) io; + struct { + TW_SG_Entry sgl[41]; + u32 padding; + dma_addr_t padding2; + } param; + } byte8_offset; +}; + +typedef struct TW_Command TW_Command; + +struct TAG_TW_Command_Apache { + unsigned char opcode__reserved; + unsigned char unit; + short unsigned int request_id__lunl; + unsigned char status; + unsigned char sgl_offset; + short unsigned int sgl_entries__lunh; + unsigned char cdb[16]; + TW_SG_Entry sg_list[72]; + unsigned char padding[8]; +}; + +typedef struct TAG_TW_Command_Apache TW_Command_Apache; + +struct TAG_TW_Command_Apache_Header { + unsigned char sense_data[18]; + struct { + char reserved[4]; + short unsigned int error; + unsigned char padding; + unsigned char severity__reserved; + } status_block; + unsigned char err_specific_desc[98]; + struct { + unsigned char size_header; + short unsigned int reserved; + unsigned char size_sense; + } __attribute__((packed)) header_desc; +}; + +typedef struct TAG_TW_Command_Apache_Header TW_Command_Apache_Header; + +struct TAG_TW_Command_Full { + TW_Command_Apache_Header header; + union { + TW_Command oldcommand; + TW_Command_Apache newcommand; + } command; +}; + +typedef struct TAG_TW_Command_Full TW_Command_Full; + +struct TAG_TW_Initconnect { + unsigned char opcode__reserved; + unsigned char size; + unsigned char request_id; + unsigned char res2; + unsigned char status; + unsigned char flags; + short unsigned int message_credits; + u32 features; + short unsigned int fw_srl; + short unsigned int fw_arch_id; + short unsigned int fw_branch; + short unsigned int fw_build; + u32 result; +}; + +typedef struct TAG_TW_Initconnect TW_Initconnect; + +struct TAG_TW_Event { + unsigned int sequence_id; + unsigned int time_stamp_sec; + short unsigned int aen_code; + unsigned char severity; + unsigned char retrieved; + unsigned char repeat_count; + unsigned char parameter_len; + unsigned char parameter_data[98]; +}; + +typedef struct TAG_TW_Event TW_Event; + +struct TAG_TW_Ioctl_Driver_Command { + unsigned int control_code; + unsigned int status; + unsigned int unique_id; + unsigned int sequence_id; + unsigned int os_specific; + unsigned int buffer_length; +}; + +typedef struct TAG_TW_Ioctl_Driver_Command TW_Ioctl_Driver_Command; + +struct TAG_TW_Ioctl_Apache { + TW_Ioctl_Driver_Command driver_command; + char padding[488]; + TW_Command_Full firmware_command; + char data_buffer[1]; +} __attribute__((packed)); + +typedef struct TAG_TW_Ioctl_Apache TW_Ioctl_Buf_Apache; + +struct TAG_TW_Lock { + long unsigned int timeout_msec; + long unsigned int time_remaining_msec; + long unsigned int force_flag; +}; + +typedef struct TAG_TW_Lock TW_Lock; + +typedef struct { + short unsigned int table_id; + short unsigned int parameter_id; + short unsigned int parameter_size_bytes; + short unsigned int actual_parameter_size_bytes; + unsigned char data[1]; +} __attribute__((packed)) TW_Param_Apache; + +union TAG_TW_Response_Queue { + u32 response_id; + u32 value; +}; + +typedef union TAG_TW_Response_Queue TW_Response_Queue; + +struct TAG_TW_Compatibility_Info { + char driver_version[32]; + short unsigned int working_srl; + short unsigned int working_branch; + short unsigned int working_build; + short unsigned int driver_srl_high; + short unsigned int driver_branch_high; + short unsigned int driver_build_high; + short unsigned int driver_srl_low; + short unsigned int driver_branch_low; + short unsigned int driver_build_low; + short unsigned int fw_on_ctlr_srl; + short unsigned int fw_on_ctlr_branch; + short unsigned int fw_on_ctlr_build; +}; + +typedef struct TAG_TW_Compatibility_Info TW_Compatibility_Info; + +struct TAG_TW_Device_Extension { + u32 *base_addr; + long unsigned int *generic_buffer_virt[256]; + dma_addr_t generic_buffer_phys[256]; + TW_Command_Full *command_packet_virt[256]; + dma_addr_t command_packet_phys[256]; + struct pci_dev *tw_pci_dev; + struct scsi_cmnd *srb[256]; + unsigned char free_queue[256]; + unsigned char free_head; + unsigned char free_tail; + unsigned char pending_queue[256]; + unsigned char pending_head; + unsigned char pending_tail; + int state[256]; + unsigned int posted_request_count; + unsigned int max_posted_request_count; + unsigned int pending_request_count; + unsigned int max_pending_request_count; + unsigned int max_sgl_entries; + unsigned int sgl_entries; + unsigned int num_resets; + unsigned int sector_count; + unsigned int max_sector_count; + unsigned int aen_count; + int: 32; + struct Scsi_Host *host; + long int flags; + int reset_print; + int: 32; + TW_Event *event_queue[256]; + unsigned char error_index; + unsigned char event_queue_wrapped; + short: 16; + unsigned int error_sequence_id; + int ioctl_sem_lock; + int: 32; + ktime_t ioctl_time; + int chrdev_request_id; + int: 32; + wait_queue_head_t ioctl_wqueue; + struct mutex ioctl_lock; + char aen_clobber; + TW_Compatibility_Info tw_compat_info; + long: 56; +} __attribute__((packed)); + +typedef struct TAG_TW_Device_Extension TW_Device_Extension; + +struct virtio_scsi_cmd_req { + __u8 lun[8]; + __virtio64 tag; + __u8 task_attr; + __u8 prio; + __u8 crn; + __u8 cdb[32]; +} __attribute__((packed)); + +struct virtio_scsi_cmd_req_pi { + __u8 lun[8]; + __virtio64 tag; + __u8 task_attr; + __u8 prio; + __u8 crn; + __virtio32 pi_bytesout; + __virtio32 pi_bytesin; + __u8 cdb[32]; +} __attribute__((packed)); + +struct virtio_scsi_cmd_resp { + __virtio32 sense_len; + __virtio32 resid; + __virtio16 status_qualifier; + __u8 status; + __u8 response; + __u8 sense[96]; +}; + +struct virtio_scsi_ctrl_tmf_req { + __virtio32 type; + __virtio32 subtype; + __u8 lun[8]; + __virtio64 tag; +}; + +struct virtio_scsi_ctrl_tmf_resp { + __u8 response; +}; + +struct virtio_scsi_ctrl_an_req { + __virtio32 type; + __u8 lun[8]; + __virtio32 event_requested; +}; + +struct virtio_scsi_ctrl_an_resp { + __virtio32 event_actual; + __u8 response; +} __attribute__((packed)); + +struct virtio_scsi_event { + __virtio32 event; + __u8 lun[8]; + __virtio32 reason; +}; + +struct virtio_scsi_config { + __virtio32 num_queues; + __virtio32 seg_max; + __virtio32 max_sectors; + __virtio32 cmd_per_lun; + __virtio32 event_info_size; + __virtio32 sense_size; + __virtio32 cdb_size; + __virtio16 max_channel; + __virtio16 max_target; + __virtio32 max_lun; +}; + +struct virtio_scsi_cmd { + struct scsi_cmnd *sc; + struct completion *comp; + union { + struct virtio_scsi_cmd_req cmd; + struct virtio_scsi_cmd_req_pi cmd_pi; + struct virtio_scsi_ctrl_tmf_req tmf; + struct virtio_scsi_ctrl_an_req an; + } req; + union { + struct virtio_scsi_cmd_resp cmd; + struct virtio_scsi_ctrl_tmf_resp tmf; + struct virtio_scsi_ctrl_an_resp an; + struct virtio_scsi_event evt; + } resp; + long: 8; + long: 64; +} __attribute__((packed)); + +struct virtio_scsi; + +struct virtio_scsi_event_node { + struct virtio_scsi *vscsi; + struct virtio_scsi_event event; + struct work_struct work; +}; + +struct virtio_scsi_vq { + spinlock_t vq_lock; + struct virtqueue *vq; +}; + +struct virtio_scsi { + struct virtio_device *vdev; + struct virtio_scsi_event_node event_list[8]; + u32 num_queues; + struct hlist_node node; + bool stop_events; + struct virtio_scsi_vq ctrl_vq; + struct virtio_scsi_vq event_vq; + struct virtio_scsi_vq req_vqs[0]; +}; + +enum bip_flags { + BIP_BLOCK_INTEGRITY = 1, + BIP_MAPPED_INTEGRITY = 2, + BIP_CTRL_NOCHECK = 4, + BIP_DISK_NOCHECK = 8, + BIP_IP_CHECKSUM = 16, +}; + +enum t10_dif_type { + T10_PI_TYPE0_PROTECTION = 0, + T10_PI_TYPE1_PROTECTION = 1, + T10_PI_TYPE2_PROTECTION = 2, + T10_PI_TYPE3_PROTECTION = 3, +}; + +enum scsi_prot_flags { + SCSI_PROT_TRANSFER_PI = 1, + SCSI_PROT_GUARD_CHECK = 2, + SCSI_PROT_REF_CHECK = 4, + SCSI_PROT_REF_INCREMENT = 8, + SCSI_PROT_IP_CHECKSUM = 16, +}; + +enum { + SD_EXT_CDB_SIZE = 32, + SD_MEMPOOL_SIZE = 2, +}; + +enum { + SD_DEF_XFER_BLOCKS = 65535, + SD_MAX_XFER_BLOCKS = 4294967295, + SD_MAX_WS10_BLOCKS = 65535, + SD_MAX_WS16_BLOCKS = 8388607, +}; + +enum { + SD_LBP_FULL = 0, + SD_LBP_UNMAP = 1, + SD_LBP_WS16 = 2, + SD_LBP_WS10 = 3, + SD_LBP_ZERO = 4, + SD_LBP_DISABLE = 5, +}; + +enum { + SD_ZERO_WRITE = 0, + SD_ZERO_WS = 1, + SD_ZERO_WS16_UNMAP = 2, + SD_ZERO_WS10_UNMAP = 3, +}; + +struct opal_dev; + +struct scsi_disk { + struct scsi_driver *driver; + struct scsi_device *device; + struct device dev; + struct gendisk *disk; + struct opal_dev *opal_dev; + atomic_t openers; + sector_t capacity; + int max_retries; + u32 max_xfer_blocks; + u32 opt_xfer_blocks; + u32 max_ws_blocks; + u32 max_unmap_blocks; + u32 unmap_granularity; + u32 unmap_alignment; + u32 index; + unsigned int physical_block_size; + unsigned int max_medium_access_timeouts; + unsigned int medium_access_timed_out; + u8 media_present; + u8 write_prot; + u8 protection_type; + u8 provisioning_mode; + u8 zeroing_mode; + unsigned int ATO: 1; + unsigned int cache_override: 1; + unsigned int WCE: 1; + unsigned int RCD: 1; + unsigned int DPOFUA: 1; + unsigned int first_scan: 1; + unsigned int lbpme: 1; + unsigned int lbprz: 1; + unsigned int lbpu: 1; + unsigned int lbpws: 1; + unsigned int lbpws10: 1; + unsigned int lbpvpd: 1; + unsigned int ws10: 1; + unsigned int ws16: 1; + unsigned int rc_basis: 2; + unsigned int zoned: 2; + unsigned int urswrz: 1; + unsigned int security: 1; + unsigned int ignore_medium_access_errors: 1; +}; + +enum { + ATA_MSG_DRV = 1, + ATA_MSG_INFO = 2, + ATA_MSG_PROBE = 4, + ATA_MSG_WARN = 8, + ATA_MSG_MALLOC = 16, + ATA_MSG_CTL = 32, + ATA_MSG_INTR = 64, + ATA_MSG_ERR = 128, +}; + +enum ata_xfer_mask { + ATA_MASK_PIO = 127, + ATA_MASK_MWDMA = 3968, + ATA_MASK_UDMA = 1044480, +}; + +struct ata_port_info { + long unsigned int flags; + long unsigned int link_flags; + long unsigned int pio_mask; + long unsigned int mwdma_mask; + long unsigned int udma_mask; + struct ata_port_operations *port_ops; + void *private_data; +}; + +struct ata_timing { + short unsigned int mode; + short unsigned int setup; + short unsigned int act8b; + short unsigned int rec8b; + short unsigned int cyc8b; + short unsigned int active; + short unsigned int recover; + short unsigned int dmack_hold; + short unsigned int cycle; + short unsigned int udma; +}; + +struct pci_bits { + unsigned int reg; + unsigned int width; + long unsigned int mask; + long unsigned int val; +}; + +enum ata_link_iter_mode { + ATA_LITER_EDGE = 0, + ATA_LITER_HOST_FIRST = 1, + ATA_LITER_PMP_FIRST = 2, +}; + +enum ata_dev_iter_mode { + ATA_DITER_ENABLED = 0, + ATA_DITER_ENABLED_REVERSE = 1, + ATA_DITER_ALL = 2, + ATA_DITER_ALL_REVERSE = 3, +}; + +struct trace_event_raw_ata_qc_issue { + struct trace_entry ent; + unsigned int ata_port; + unsigned int ata_dev; + unsigned int tag; + unsigned char cmd; + unsigned char dev; + unsigned char lbal; + unsigned char lbam; + unsigned char lbah; + unsigned char nsect; + unsigned char feature; + unsigned char hob_lbal; + unsigned char hob_lbam; + unsigned char hob_lbah; + unsigned char hob_nsect; + unsigned char hob_feature; + unsigned char ctl; + unsigned char proto; + long unsigned int flags; + char __data[0]; +}; + +struct trace_event_raw_ata_qc_complete_template { + struct trace_entry ent; + unsigned int ata_port; + unsigned int ata_dev; + unsigned int tag; + unsigned char status; + unsigned char dev; + unsigned char lbal; + unsigned char lbam; + unsigned char lbah; + unsigned char nsect; + unsigned char error; + unsigned char hob_lbal; + unsigned char hob_lbam; + unsigned char hob_lbah; + unsigned char hob_nsect; + unsigned char hob_feature; + unsigned char ctl; + long unsigned int flags; + char __data[0]; +}; + +struct trace_event_raw_ata_eh_link_autopsy { + struct trace_entry ent; + unsigned int ata_port; + unsigned int ata_dev; + unsigned int eh_action; + unsigned int eh_err_mask; + char __data[0]; +}; + +struct trace_event_raw_ata_eh_link_autopsy_qc { + struct trace_entry ent; + unsigned int ata_port; + unsigned int ata_dev; + unsigned int tag; + unsigned int qc_flags; + unsigned int eh_err_mask; + char __data[0]; +}; + +struct trace_event_data_offsets_ata_qc_issue {}; + +struct trace_event_data_offsets_ata_qc_complete_template {}; + +struct trace_event_data_offsets_ata_eh_link_autopsy {}; + +struct trace_event_data_offsets_ata_eh_link_autopsy_qc {}; + +typedef void (*btf_trace_ata_qc_issue)(void *, struct ata_queued_cmd *); + +typedef void (*btf_trace_ata_qc_complete_internal)(void *, struct ata_queued_cmd *); + +typedef void (*btf_trace_ata_qc_complete_failed)(void *, struct ata_queued_cmd *); + +typedef void (*btf_trace_ata_qc_complete_done)(void *, struct ata_queued_cmd *); + +typedef void (*btf_trace_ata_eh_link_autopsy)(void *, struct ata_device *, unsigned int, unsigned int); + +typedef void (*btf_trace_ata_eh_link_autopsy_qc)(void *, struct ata_queued_cmd *); + +enum { + ATA_READID_POSTRESET = 1, + ATA_DNXFER_PIO = 0, + ATA_DNXFER_DMA = 1, + ATA_DNXFER_40C = 2, + ATA_DNXFER_FORCE_PIO = 3, + ATA_DNXFER_FORCE_PIO0 = 4, + ATA_DNXFER_QUIET = 2147483648, +}; + +struct ata_force_param { + const char *name; + u8 cbl; + u8 spd_limit; + long unsigned int xfer_mask; + unsigned int horkage_on; + unsigned int horkage_off; + u16 lflags; +}; + +struct ata_force_ent { + int port; + int device; + struct ata_force_param param; +}; + +struct ata_xfer_ent { + int shift; + int bits; + u8 base; +}; + +struct ata_blacklist_entry { + const char *model_num; + const char *model_rev; + long unsigned int horkage; +}; + +typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *); + +struct ata_scsi_args { + struct ata_device *dev; + u16 *id; + struct scsi_cmnd *cmd; +}; + +enum ata_lpm_hints { + ATA_LPM_EMPTY = 1, + ATA_LPM_HIPM = 2, + ATA_LPM_WAKE_ONLY = 4, +}; + +enum { + ATA_EH_SPDN_NCQ_OFF = 1, + ATA_EH_SPDN_SPEED_DOWN = 2, + ATA_EH_SPDN_FALLBACK_TO_PIO = 4, + ATA_EH_SPDN_KEEP_ERRORS = 8, + ATA_EFLAG_IS_IO = 1, + ATA_EFLAG_DUBIOUS_XFER = 2, + ATA_EFLAG_OLD_ER = 2147483648, + ATA_ECAT_NONE = 0, + ATA_ECAT_ATA_BUS = 1, + ATA_ECAT_TOUT_HSM = 2, + ATA_ECAT_UNK_DEV = 3, + ATA_ECAT_DUBIOUS_NONE = 4, + ATA_ECAT_DUBIOUS_ATA_BUS = 5, + ATA_ECAT_DUBIOUS_TOUT_HSM = 6, + ATA_ECAT_DUBIOUS_UNK_DEV = 7, + ATA_ECAT_NR = 8, + ATA_EH_CMD_DFL_TIMEOUT = 5000, + ATA_EH_RESET_COOL_DOWN = 5000, + ATA_EH_PRERESET_TIMEOUT = 10000, + ATA_EH_FASTDRAIN_INTERVAL = 3000, + ATA_EH_UA_TRIES = 5, + ATA_EH_PROBE_TRIAL_INTERVAL = 60000, + ATA_EH_PROBE_TRIALS = 2, +}; + +struct ata_eh_cmd_timeout_ent { + const u8 *commands; + const long unsigned int *timeouts; +}; + +struct speed_down_verdict_arg { + u64 since; + int xfer_ok; + int nr_errors[8]; +}; + +struct ata_internal { + struct scsi_transport_template t; + struct device_attribute private_port_attrs[3]; + struct device_attribute private_link_attrs[3]; + struct device_attribute private_dev_attrs[9]; + struct transport_container link_attr_cont; + struct transport_container dev_attr_cont; + struct device_attribute *link_attrs[4]; + struct device_attribute *port_attrs[4]; + struct device_attribute *dev_attrs[10]; +}; + +struct ata_show_ering_arg { + char *buf; + int written; +}; + +enum hsm_task_states { + HSM_ST_IDLE = 0, + HSM_ST_FIRST = 1, + HSM_ST = 2, + HSM_ST_LAST = 3, + HSM_ST_ERR = 4, +}; + +struct ata_acpi_gtf { + u8 tf[7]; +}; + +struct ata_acpi_hotplug_context { + struct acpi_hotplug_context hp; + union { + struct ata_port *ap; + struct ata_device *dev; + } data; +}; + +enum { + AHCI_MAX_PORTS = 32, + AHCI_MAX_CLKS = 5, + AHCI_MAX_SG = 168, + AHCI_DMA_BOUNDARY = 4294967295, + AHCI_MAX_CMDS = 32, + AHCI_CMD_SZ = 32, + AHCI_CMD_SLOT_SZ = 1024, + AHCI_RX_FIS_SZ = 256, + AHCI_CMD_TBL_CDB = 64, + AHCI_CMD_TBL_HDR_SZ = 128, + AHCI_CMD_TBL_SZ = 2816, + AHCI_CMD_TBL_AR_SZ = 90112, + AHCI_PORT_PRIV_DMA_SZ = 91392, + AHCI_PORT_PRIV_FBS_DMA_SZ = 95232, + AHCI_IRQ_ON_SG = 2147483648, + AHCI_CMD_ATAPI = 32, + AHCI_CMD_WRITE = 64, + AHCI_CMD_PREFETCH = 128, + AHCI_CMD_RESET = 256, + AHCI_CMD_CLR_BUSY = 1024, + RX_FIS_PIO_SETUP = 32, + RX_FIS_D2H_REG = 64, + RX_FIS_SDB = 88, + RX_FIS_UNK = 96, + HOST_CAP = 0, + HOST_CTL = 4, + HOST_IRQ_STAT = 8, + HOST_PORTS_IMPL = 12, + HOST_VERSION = 16, + HOST_EM_LOC = 28, + HOST_EM_CTL = 32, + HOST_CAP2 = 36, + HOST_RESET = 1, + HOST_IRQ_EN = 2, + HOST_MRSM = 4, + HOST_AHCI_EN = 2147483648, + HOST_CAP_SXS = 32, + HOST_CAP_EMS = 64, + HOST_CAP_CCC = 128, + HOST_CAP_PART = 8192, + HOST_CAP_SSC = 16384, + HOST_CAP_PIO_MULTI = 32768, + HOST_CAP_FBS = 65536, + HOST_CAP_PMP = 131072, + HOST_CAP_ONLY = 262144, + HOST_CAP_CLO = 16777216, + HOST_CAP_LED = 33554432, + HOST_CAP_ALPM = 67108864, + HOST_CAP_SSS = 134217728, + HOST_CAP_MPS = 268435456, + HOST_CAP_SNTF = 536870912, + HOST_CAP_NCQ = 1073741824, + HOST_CAP_64 = 2147483648, + HOST_CAP2_BOH = 1, + HOST_CAP2_NVMHCI = 2, + HOST_CAP2_APST = 4, + HOST_CAP2_SDS = 8, + HOST_CAP2_SADM = 16, + HOST_CAP2_DESO = 32, + PORT_LST_ADDR = 0, + PORT_LST_ADDR_HI = 4, + PORT_FIS_ADDR = 8, + PORT_FIS_ADDR_HI = 12, + PORT_IRQ_STAT = 16, + PORT_IRQ_MASK = 20, + PORT_CMD = 24, + PORT_TFDATA = 32, + PORT_SIG = 36, + PORT_CMD_ISSUE = 56, + PORT_SCR_STAT = 40, + PORT_SCR_CTL = 44, + PORT_SCR_ERR = 48, + PORT_SCR_ACT = 52, + PORT_SCR_NTF = 60, + PORT_FBS = 64, + PORT_DEVSLP = 68, + PORT_IRQ_COLD_PRES = 2147483648, + PORT_IRQ_TF_ERR = 1073741824, + PORT_IRQ_HBUS_ERR = 536870912, + PORT_IRQ_HBUS_DATA_ERR = 268435456, + PORT_IRQ_IF_ERR = 134217728, + PORT_IRQ_IF_NONFATAL = 67108864, + PORT_IRQ_OVERFLOW = 16777216, + PORT_IRQ_BAD_PMP = 8388608, + PORT_IRQ_PHYRDY = 4194304, + PORT_IRQ_DEV_ILCK = 128, + PORT_IRQ_CONNECT = 64, + PORT_IRQ_SG_DONE = 32, + PORT_IRQ_UNK_FIS = 16, + PORT_IRQ_SDB_FIS = 8, + PORT_IRQ_DMAS_FIS = 4, + PORT_IRQ_PIOS_FIS = 2, + PORT_IRQ_D2H_REG_FIS = 1, + PORT_IRQ_FREEZE = 683671632, + PORT_IRQ_ERROR = 2025848912, + DEF_PORT_IRQ = 2025848959, + PORT_CMD_ASP = 134217728, + PORT_CMD_ALPE = 67108864, + PORT_CMD_ATAPI = 16777216, + PORT_CMD_FBSCP = 4194304, + PORT_CMD_ESP = 2097152, + PORT_CMD_HPCP = 262144, + PORT_CMD_PMP = 131072, + PORT_CMD_LIST_ON = 32768, + PORT_CMD_FIS_ON = 16384, + PORT_CMD_FIS_RX = 16, + PORT_CMD_CLO = 8, + PORT_CMD_POWER_ON = 4, + PORT_CMD_SPIN_UP = 2, + PORT_CMD_START = 1, + PORT_CMD_ICC_MASK = 4026531840, + PORT_CMD_ICC_ACTIVE = 268435456, + PORT_CMD_ICC_PARTIAL = 536870912, + PORT_CMD_ICC_SLUMBER = 1610612736, + PORT_FBS_DWE_OFFSET = 16, + PORT_FBS_ADO_OFFSET = 12, + PORT_FBS_DEV_OFFSET = 8, + PORT_FBS_DEV_MASK = 3840, + PORT_FBS_SDE = 4, + PORT_FBS_DEC = 2, + PORT_FBS_EN = 1, + PORT_DEVSLP_DM_OFFSET = 25, + PORT_DEVSLP_DM_MASK = 503316480, + PORT_DEVSLP_DITO_OFFSET = 15, + PORT_DEVSLP_MDAT_OFFSET = 10, + PORT_DEVSLP_DETO_OFFSET = 2, + PORT_DEVSLP_DSP = 2, + PORT_DEVSLP_ADSE = 1, + AHCI_HFLAG_NO_NCQ = 1, + AHCI_HFLAG_IGN_IRQ_IF_ERR = 2, + AHCI_HFLAG_IGN_SERR_INTERNAL = 4, + AHCI_HFLAG_32BIT_ONLY = 8, + AHCI_HFLAG_MV_PATA = 16, + AHCI_HFLAG_NO_MSI = 32, + AHCI_HFLAG_NO_PMP = 64, + AHCI_HFLAG_SECT255 = 256, + AHCI_HFLAG_YES_NCQ = 512, + AHCI_HFLAG_NO_SUSPEND = 1024, + AHCI_HFLAG_SRST_TOUT_IS_OFFLINE = 2048, + AHCI_HFLAG_NO_SNTF = 4096, + AHCI_HFLAG_NO_FPDMA_AA = 8192, + AHCI_HFLAG_YES_FBS = 16384, + AHCI_HFLAG_DELAY_ENGINE = 32768, + AHCI_HFLAG_NO_DEVSLP = 131072, + AHCI_HFLAG_NO_FBS = 262144, + AHCI_HFLAG_MULTI_MSI = 1048576, + AHCI_HFLAG_WAKE_BEFORE_STOP = 4194304, + AHCI_HFLAG_YES_ALPM = 8388608, + AHCI_HFLAG_NO_WRITE_TO_RO = 16777216, + AHCI_HFLAG_IS_MOBILE = 33554432, + AHCI_HFLAG_SUSPEND_PHYS = 67108864, + AHCI_HFLAG_IGN_NOTSUPP_POWER_ON = 134217728, + AHCI_FLAG_COMMON = 393346, + ICH_MAP = 144, + PCS_6 = 146, + PCS_7 = 148, + EM_MAX_SLOTS = 8, + EM_MAX_RETRY = 5, + EM_CTL_RST = 512, + EM_CTL_TM = 256, + EM_CTL_MR = 1, + EM_CTL_ALHD = 67108864, + EM_CTL_XMT = 33554432, + EM_CTL_SMB = 16777216, + EM_CTL_SGPIO = 524288, + EM_CTL_SES = 262144, + EM_CTL_SAFTE = 131072, + EM_CTL_LED = 65536, + EM_MSG_TYPE_LED = 1, + EM_MSG_TYPE_SAFTE = 2, + EM_MSG_TYPE_SES2 = 4, + EM_MSG_TYPE_SGPIO = 8, +}; + +struct ahci_cmd_hdr { + __le32 opts; + __le32 status; + __le32 tbl_addr; + __le32 tbl_addr_hi; + __le32 reserved[4]; +}; + +struct ahci_em_priv { + enum sw_activity blink_policy; + struct timer_list timer; + long unsigned int saved_activity; + long unsigned int activity; + long unsigned int led_state; + struct ata_link *link; +}; + +struct ahci_port_priv { + struct ata_link *active_link; + struct ahci_cmd_hdr *cmd_slot; + dma_addr_t cmd_slot_dma; + void *cmd_tbl; + dma_addr_t cmd_tbl_dma; + void *rx_fis; + dma_addr_t rx_fis_dma; + unsigned int ncq_saw_d2h: 1; + unsigned int ncq_saw_dmas: 1; + unsigned int ncq_saw_sdb: 1; + spinlock_t lock; + u32 intr_mask; + bool fbs_supported; + bool fbs_enabled; + int fbs_last_dev; + struct ahci_em_priv em_priv[8]; + char *irq_desc; +}; + +struct ahci_host_priv { + unsigned int flags; + u32 force_port_map; + u32 mask_port_map; + void *mmio; + u32 cap; + u32 cap2; + u32 version; + u32 port_map; + u32 saved_cap; + u32 saved_cap2; + u32 saved_port_map; + u32 em_loc; + u32 em_buf_sz; + u32 em_msg_type; + u32 remapped_nvme; + bool got_runtime_pm; + struct clk *clks[5]; + struct reset_control *rsts; + struct regulator **target_pwrs; + struct regulator *ahci_regulator; + struct regulator *phy_regulator; + struct phy **phys; + unsigned int nports; + void *plat_data; + unsigned int irq; + void (*start_engine)(struct ata_port *); + int (*stop_engine)(struct ata_port *); + irqreturn_t (*irq_handler)(int, void *); + int (*get_irq_vector)(struct ata_host *, int); +}; + +enum { + AHCI_PCI_BAR_STA2X11 = 0, + AHCI_PCI_BAR_CAVIUM = 0, + AHCI_PCI_BAR_LOONGSON = 0, + AHCI_PCI_BAR_ENMOTUS = 2, + AHCI_PCI_BAR_CAVIUM_GEN5 = 4, + AHCI_PCI_BAR_STANDARD = 5, +}; + +enum board_ids { + board_ahci = 0, + board_ahci_ign_iferr = 1, + board_ahci_mobile = 2, + board_ahci_nomsi = 3, + board_ahci_noncq = 4, + board_ahci_nosntf = 5, + board_ahci_yes_fbs = 6, + board_ahci_al = 7, + board_ahci_avn = 8, + board_ahci_mcp65 = 9, + board_ahci_mcp77 = 10, + board_ahci_mcp89 = 11, + board_ahci_mv = 12, + board_ahci_sb600 = 13, + board_ahci_sb700 = 14, + board_ahci_vt8251 = 15, + board_ahci_pcs7 = 16, + board_ahci_mcp_linux = 9, + board_ahci_mcp67 = 9, + board_ahci_mcp73 = 9, + board_ahci_mcp79 = 10, +}; + +struct ahci_sg { + __le32 addr; + __le32 addr_hi; + __le32 reserved; + __le32 flags_size; +}; + +enum { + PIIX_IOCFG = 84, + ICH5_PMR = 144, + ICH5_PCS = 146, + PIIX_SIDPR_BAR = 5, + PIIX_SIDPR_LEN = 16, + PIIX_SIDPR_IDX = 0, + PIIX_SIDPR_DATA = 4, + PIIX_FLAG_CHECKINTR = 268435456, + PIIX_FLAG_SIDPR = 536870912, + PIIX_PATA_FLAGS = 1, + PIIX_SATA_FLAGS = 268435458, + PIIX_FLAG_PIO16 = 1073741824, + PIIX_80C_PRI = 48, + PIIX_80C_SEC = 192, + P0 = 0, + P1 = 1, + P2 = 2, + P3 = 3, + IDE = 4294967295, + NA = 4294967294, + RV = 4294967293, + PIIX_AHCI_DEVICE = 6, + PIIX_HOST_BROKEN_SUSPEND = 16777216, +}; + +enum piix_controller_ids { + piix_pata_mwdma = 0, + piix_pata_33 = 1, + ich_pata_33 = 2, + ich_pata_66 = 3, + ich_pata_100 = 4, + ich_pata_100_nomwdma1 = 5, + ich5_sata = 6, + ich6_sata = 7, + ich6m_sata = 8, + ich8_sata = 9, + ich8_2port_sata = 10, + ich8m_apple_sata = 11, + tolapai_sata = 12, + piix_pata_vmw = 13, + ich8_sata_snb = 14, + ich8_2port_sata_snb = 15, + ich8_2port_sata_byt = 16, +}; + +struct piix_map_db { + const u32 mask; + const u16 port_enable; + const int map[0]; +}; + +struct piix_host_priv { + const int *map; + u32 saved_iocfg; + void *sidpr; +}; + +enum { + NV_MMIO_BAR = 5, + NV_PORTS = 2, + NV_PIO_MASK = 31, + NV_MWDMA_MASK = 7, + NV_UDMA_MASK = 127, + NV_PORT0_SCR_REG_OFFSET = 0, + NV_PORT1_SCR_REG_OFFSET = 64, + NV_INT_STATUS = 16, + NV_INT_ENABLE = 17, + NV_INT_STATUS_CK804 = 1088, + NV_INT_ENABLE_CK804 = 1089, + NV_INT_DEV = 1, + NV_INT_PM = 2, + NV_INT_ADDED = 4, + NV_INT_REMOVED = 8, + NV_INT_PORT_SHIFT = 4, + NV_INT_ALL = 15, + NV_INT_MASK = 13, + NV_INT_CONFIG = 18, + NV_INT_CONFIG_METHD = 1, + NV_MCP_SATA_CFG_20 = 80, + NV_MCP_SATA_CFG_20_SATA_SPACE_EN = 4, + NV_MCP_SATA_CFG_20_PORT0_EN = 131072, + NV_MCP_SATA_CFG_20_PORT1_EN = 65536, + NV_MCP_SATA_CFG_20_PORT0_PWB_EN = 16384, + NV_MCP_SATA_CFG_20_PORT1_PWB_EN = 4096, + NV_ADMA_MAX_CPBS = 32, + NV_ADMA_CPB_SZ = 128, + NV_ADMA_APRD_SZ = 16, + NV_ADMA_SGTBL_LEN = 56, + NV_ADMA_SGTBL_TOTAL_LEN = 61, + NV_ADMA_SGTBL_SZ = 896, + NV_ADMA_PORT_PRIV_DMA_SZ = 32768, + NV_ADMA_GEN = 1024, + NV_ADMA_GEN_CTL = 0, + NV_ADMA_NOTIFIER_CLEAR = 48, + NV_ADMA_PORT = 1152, + NV_ADMA_PORT_SIZE = 256, + NV_ADMA_CTL = 64, + NV_ADMA_CPB_COUNT = 66, + NV_ADMA_NEXT_CPB_IDX = 67, + NV_ADMA_STAT = 68, + NV_ADMA_CPB_BASE_LOW = 72, + NV_ADMA_CPB_BASE_HIGH = 76, + NV_ADMA_APPEND = 80, + NV_ADMA_NOTIFIER = 104, + NV_ADMA_NOTIFIER_ERROR = 108, + NV_ADMA_CTL_HOTPLUG_IEN = 1, + NV_ADMA_CTL_CHANNEL_RESET = 32, + NV_ADMA_CTL_GO = 128, + NV_ADMA_CTL_AIEN = 256, + NV_ADMA_CTL_READ_NON_COHERENT = 2048, + NV_ADMA_CTL_WRITE_NON_COHERENT = 4096, + NV_CPB_RESP_DONE = 1, + NV_CPB_RESP_ATA_ERR = 8, + NV_CPB_RESP_CMD_ERR = 16, + NV_CPB_RESP_CPB_ERR = 128, + NV_CPB_CTL_CPB_VALID = 1, + NV_CPB_CTL_QUEUE = 2, + NV_CPB_CTL_APRD_VALID = 4, + NV_CPB_CTL_IEN = 8, + NV_CPB_CTL_FPDMA = 16, + NV_APRD_WRITE = 2, + NV_APRD_END = 4, + NV_APRD_CONT = 8, + NV_ADMA_STAT_TIMEOUT = 1, + NV_ADMA_STAT_HOTUNPLUG = 2, + NV_ADMA_STAT_HOTPLUG = 4, + NV_ADMA_STAT_CPBERR = 16, + NV_ADMA_STAT_SERROR = 32, + NV_ADMA_STAT_CMD_COMPLETE = 64, + NV_ADMA_STAT_IDLE = 256, + NV_ADMA_STAT_LEGACY = 512, + NV_ADMA_STAT_STOPPED = 1024, + NV_ADMA_STAT_DONE = 4096, + NV_ADMA_STAT_ERR = 17, + NV_ADMA_PORT_REGISTER_MODE = 1, + NV_ADMA_ATAPI_SETUP_COMPLETE = 2, + NV_CTL_MCP55 = 1024, + NV_INT_STATUS_MCP55 = 1088, + NV_INT_ENABLE_MCP55 = 1092, + NV_NCQ_REG_MCP55 = 1096, + NV_INT_ALL_MCP55 = 65535, + NV_INT_PORT_SHIFT_MCP55 = 16, + NV_INT_MASK_MCP55 = 65533, + NV_CTL_PRI_SWNCQ = 2, + NV_CTL_SEC_SWNCQ = 4, + NV_SWNCQ_IRQ_DEV = 1, + NV_SWNCQ_IRQ_PM = 2, + NV_SWNCQ_IRQ_ADDED = 4, + NV_SWNCQ_IRQ_REMOVED = 8, + NV_SWNCQ_IRQ_BACKOUT = 16, + NV_SWNCQ_IRQ_SDBFIS = 32, + NV_SWNCQ_IRQ_DHREGFIS = 64, + NV_SWNCQ_IRQ_DMASETUP = 128, + NV_SWNCQ_IRQ_HOTPLUG = 12, +}; + +struct nv_adma_prd { + __le64 addr; + __le32 len; + u8 flags; + u8 packet_len; + __le16 reserved; +}; + +enum nv_adma_regbits { + CMDEND = 32768, + WNB = 16384, + IGN = 8192, + CS1n = 4096, + DA2 = 1024, + DA1 = 512, + DA0 = 256, +}; + +struct nv_adma_cpb { + u8 resp_flags; + u8 reserved1; + u8 ctl_flags; + u8 len; + u8 tag; + u8 next_cpb_idx; + __le16 reserved2; + __le16 tf[12]; + struct nv_adma_prd aprd[5]; + __le64 next_aprd; + __le64 reserved3; +}; + +struct nv_adma_port_priv { + struct nv_adma_cpb *cpb; + dma_addr_t cpb_dma; + struct nv_adma_prd *aprd; + dma_addr_t aprd_dma; + void *ctl_block; + void *gen_block; + void *notifier_clear_block; + u64 adma_dma_mask; + u8 flags; + int last_issue_ncq; +}; + +struct nv_host_priv { + long unsigned int type; +}; + +struct defer_queue { + u32 defer_bits; + unsigned int head; + unsigned int tail; + unsigned int tag[32]; +}; + +enum ncq_saw_flag_list { + ncq_saw_d2h = 1, + ncq_saw_dmas = 2, + ncq_saw_sdb = 4, + ncq_saw_backout = 8, +}; + +struct nv_swncq_port_priv { + struct ata_bmdma_prd *prd; + dma_addr_t prd_dma; + void *sactive_block; + void *irq_block; + void *tag_block; + u32 qc_active; + unsigned int last_issue_tag; + struct defer_queue defer_queue; + u32 dhfis_bits; + u32 dmafis_bits; + u32 sdbfis_bits; + unsigned int ncq_flags; +}; + +enum nv_host_type { + GENERIC = 0, + NFORCE2 = 1, + NFORCE3 = 1, + CK804 = 2, + ADMA = 3, + MCP5x = 4, + SWNCQ = 5, +}; + +struct nv_pi_priv { + irq_handler_t irq_handler; + struct scsi_host_template *sht; +}; + +enum { + SIL_MMIO_BAR = 5, + SIL_FLAG_NO_SATA_IRQ = 268435456, + SIL_FLAG_RERR_ON_DMA_ACT = 536870912, + SIL_FLAG_MOD15WRITE = 1073741824, + SIL_DFL_PORT_FLAGS = 2, + sil_3112 = 0, + sil_3112_no_sata_irq = 1, + sil_3512 = 2, + sil_3114 = 3, + SIL_SYSCFG = 72, + SIL_MASK_IDE0_INT = 4194304, + SIL_MASK_IDE1_INT = 8388608, + SIL_MASK_IDE2_INT = 16777216, + SIL_MASK_IDE3_INT = 33554432, + SIL_MASK_2PORT = 12582912, + SIL_MASK_4PORT = 62914560, + SIL_INTR_STEERING = 2, + SIL_DMA_ENABLE = 1, + SIL_DMA_RDWR = 8, + SIL_DMA_SATA_IRQ = 16, + SIL_DMA_ACTIVE = 65536, + SIL_DMA_ERROR = 131072, + SIL_DMA_COMPLETE = 262144, + SIL_DMA_N_SATA_IRQ = 64, + SIL_DMA_N_ACTIVE = 16777216, + SIL_DMA_N_ERROR = 33554432, + SIL_DMA_N_COMPLETE = 67108864, + SIL_SIEN_N = 65536, + SIL_QUIRK_MOD15WRITE = 1, + SIL_QUIRK_UDMA5MAX = 2, +}; + +struct sil_drivelist { + const char *product; + unsigned int quirk; +}; + +struct ethtool_cmd { + __u32 cmd; + __u32 supported; + __u32 advertising; + __u16 speed; + __u8 duplex; + __u8 port; + __u8 phy_address; + __u8 transceiver; + __u8 autoneg; + __u8 mdio_support; + __u32 maxtxpkt; + __u32 maxrxpkt; + __u16 speed_hi; + __u8 eth_tp_mdix; + __u8 eth_tp_mdix_ctrl; + __u32 lp_advertising; + __u32 reserved[2]; +}; + +struct mii_ioctl_data { + __u16 phy_id; + __u16 reg_num; + __u16 val_in; + __u16 val_out; +}; + +struct mdio_if_info { + int prtad; + u32 mmds; + unsigned int mode_support; + struct net_device *dev; + int (*mdio_read)(struct net_device *, int, int, u16); + int (*mdio_write)(struct net_device *, int, int, u16, u16); +}; + +struct devprobe2 { + struct net_device * (*probe)(int); + int status; +}; + +enum { + NETIF_F_SG_BIT = 0, + NETIF_F_IP_CSUM_BIT = 1, + __UNUSED_NETIF_F_1 = 2, + NETIF_F_HW_CSUM_BIT = 3, + NETIF_F_IPV6_CSUM_BIT = 4, + NETIF_F_HIGHDMA_BIT = 5, + NETIF_F_FRAGLIST_BIT = 6, + NETIF_F_HW_VLAN_CTAG_TX_BIT = 7, + NETIF_F_HW_VLAN_CTAG_RX_BIT = 8, + NETIF_F_HW_VLAN_CTAG_FILTER_BIT = 9, + NETIF_F_VLAN_CHALLENGED_BIT = 10, + NETIF_F_GSO_BIT = 11, + NETIF_F_LLTX_BIT = 12, + NETIF_F_NETNS_LOCAL_BIT = 13, + NETIF_F_GRO_BIT = 14, + NETIF_F_LRO_BIT = 15, + NETIF_F_GSO_SHIFT = 16, + NETIF_F_TSO_BIT = 16, + NETIF_F_GSO_ROBUST_BIT = 17, + NETIF_F_TSO_ECN_BIT = 18, + NETIF_F_TSO_MANGLEID_BIT = 19, + NETIF_F_TSO6_BIT = 20, + NETIF_F_FSO_BIT = 21, + NETIF_F_GSO_GRE_BIT = 22, + NETIF_F_GSO_GRE_CSUM_BIT = 23, + NETIF_F_GSO_IPXIP4_BIT = 24, + NETIF_F_GSO_IPXIP6_BIT = 25, + NETIF_F_GSO_UDP_TUNNEL_BIT = 26, + NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT = 27, + NETIF_F_GSO_PARTIAL_BIT = 28, + NETIF_F_GSO_TUNNEL_REMCSUM_BIT = 29, + NETIF_F_GSO_SCTP_BIT = 30, + NETIF_F_GSO_ESP_BIT = 31, + NETIF_F_GSO_UDP_BIT = 32, + NETIF_F_GSO_UDP_L4_BIT = 33, + NETIF_F_GSO_FRAGLIST_BIT = 34, + NETIF_F_GSO_LAST = 34, + NETIF_F_FCOE_CRC_BIT = 35, + NETIF_F_SCTP_CRC_BIT = 36, + NETIF_F_FCOE_MTU_BIT = 37, + NETIF_F_NTUPLE_BIT = 38, + NETIF_F_RXHASH_BIT = 39, + NETIF_F_RXCSUM_BIT = 40, + NETIF_F_NOCACHE_COPY_BIT = 41, + NETIF_F_LOOPBACK_BIT = 42, + NETIF_F_RXFCS_BIT = 43, + NETIF_F_RXALL_BIT = 44, + NETIF_F_HW_VLAN_STAG_TX_BIT = 45, + NETIF_F_HW_VLAN_STAG_RX_BIT = 46, + NETIF_F_HW_VLAN_STAG_FILTER_BIT = 47, + NETIF_F_HW_L2FW_DOFFLOAD_BIT = 48, + NETIF_F_HW_TC_BIT = 49, + NETIF_F_HW_ESP_BIT = 50, + NETIF_F_HW_ESP_TX_CSUM_BIT = 51, + NETIF_F_RX_UDP_TUNNEL_PORT_BIT = 52, + NETIF_F_HW_TLS_TX_BIT = 53, + NETIF_F_HW_TLS_RX_BIT = 54, + NETIF_F_GRO_HW_BIT = 55, + NETIF_F_HW_TLS_RECORD_BIT = 56, + NETIF_F_GRO_FRAGLIST_BIT = 57, + NETIF_F_HW_MACSEC_BIT = 58, + NETDEV_FEATURE_COUNT = 59, +}; + +enum { + SKBTX_HW_TSTAMP = 1, + SKBTX_SW_TSTAMP = 2, + SKBTX_IN_PROGRESS = 4, + SKBTX_DEV_ZEROCOPY = 8, + SKBTX_WIFI_STATUS = 16, + SKBTX_SHARED_FRAG = 32, + SKBTX_SCHED_TSTAMP = 64, +}; + +enum netdev_priv_flags { + IFF_802_1Q_VLAN = 1, + IFF_EBRIDGE = 2, + IFF_BONDING = 4, + IFF_ISATAP = 8, + IFF_WAN_HDLC = 16, + IFF_XMIT_DST_RELEASE = 32, + IFF_DONT_BRIDGE = 64, + IFF_DISABLE_NETPOLL = 128, + IFF_MACVLAN_PORT = 256, + IFF_BRIDGE_PORT = 512, + IFF_OVS_DATAPATH = 1024, + IFF_TX_SKB_SHARING = 2048, + IFF_UNICAST_FLT = 4096, + IFF_TEAM_PORT = 8192, + IFF_SUPP_NOFCS = 16384, + IFF_LIVE_ADDR_CHANGE = 32768, + IFF_MACVLAN = 65536, + IFF_XMIT_DST_RELEASE_PERM = 131072, + IFF_L3MDEV_MASTER = 262144, + IFF_NO_QUEUE = 524288, + IFF_OPENVSWITCH = 1048576, + IFF_L3MDEV_SLAVE = 2097152, + IFF_TEAM = 4194304, + IFF_RXFH_CONFIGURED = 8388608, + IFF_PHONY_HEADROOM = 16777216, + IFF_MACSEC = 33554432, + IFF_NO_RX_HANDLER = 67108864, + IFF_FAILOVER = 134217728, + IFF_FAILOVER_SLAVE = 268435456, + IFF_L3MDEV_RX_HANDLER = 536870912, + IFF_LIVE_RENAME_OK = 1073741824, +}; + +struct mdio_board_info { + const char *bus_id; + char modalias[32]; + int mdio_addr; + const void *platform_data; +}; + +struct mdio_board_entry { + struct list_head list; + struct mdio_board_info board_info; +}; + +struct mdiobus_devres { + struct mii_bus *mii; +}; + +enum netdev_state_t { + __LINK_STATE_START = 0, + __LINK_STATE_PRESENT = 1, + __LINK_STATE_NOCARRIER = 2, + __LINK_STATE_LINKWATCH_PENDING = 3, + __LINK_STATE_DORMANT = 4, + __LINK_STATE_TESTING = 5, +}; + +enum { + ETHTOOL_MSG_KERNEL_NONE = 0, + ETHTOOL_MSG_STRSET_GET_REPLY = 1, + ETHTOOL_MSG_LINKINFO_GET_REPLY = 2, + ETHTOOL_MSG_LINKINFO_NTF = 3, + ETHTOOL_MSG_LINKMODES_GET_REPLY = 4, + ETHTOOL_MSG_LINKMODES_NTF = 5, + ETHTOOL_MSG_LINKSTATE_GET_REPLY = 6, + ETHTOOL_MSG_DEBUG_GET_REPLY = 7, + ETHTOOL_MSG_DEBUG_NTF = 8, + ETHTOOL_MSG_WOL_GET_REPLY = 9, + ETHTOOL_MSG_WOL_NTF = 10, + ETHTOOL_MSG_FEATURES_GET_REPLY = 11, + ETHTOOL_MSG_FEATURES_SET_REPLY = 12, + ETHTOOL_MSG_FEATURES_NTF = 13, + ETHTOOL_MSG_PRIVFLAGS_GET_REPLY = 14, + ETHTOOL_MSG_PRIVFLAGS_NTF = 15, + ETHTOOL_MSG_RINGS_GET_REPLY = 16, + ETHTOOL_MSG_RINGS_NTF = 17, + ETHTOOL_MSG_CHANNELS_GET_REPLY = 18, + ETHTOOL_MSG_CHANNELS_NTF = 19, + ETHTOOL_MSG_COALESCE_GET_REPLY = 20, + ETHTOOL_MSG_COALESCE_NTF = 21, + ETHTOOL_MSG_PAUSE_GET_REPLY = 22, + ETHTOOL_MSG_PAUSE_NTF = 23, + ETHTOOL_MSG_EEE_GET_REPLY = 24, + ETHTOOL_MSG_EEE_NTF = 25, + ETHTOOL_MSG_TSINFO_GET_REPLY = 26, + ETHTOOL_MSG_CABLE_TEST_NTF = 27, + ETHTOOL_MSG_CABLE_TEST_TDR_NTF = 28, + ETHTOOL_MSG_TUNNEL_INFO_GET_REPLY = 29, + __ETHTOOL_MSG_KERNEL_CNT = 30, + ETHTOOL_MSG_KERNEL_MAX = 29, +}; + +struct phy_setting { + u32 speed; + u8 duplex; + u8 bit; +}; + +struct ethtool_phy_ops { + int (*get_sset_count)(struct phy_device *); + int (*get_strings)(struct phy_device *, u8 *); + int (*get_stats)(struct phy_device *, struct ethtool_stats *, u64 *); + int (*start_cable_test)(struct phy_device *, struct netlink_ext_ack *); + int (*start_cable_test_tdr)(struct phy_device *, struct netlink_ext_ack *, const struct phy_tdr_config *); +}; + +struct phy_fixup { + struct list_head list; + char bus_id[64]; + u32 phy_uid; + u32 phy_uid_mask; + int (*run)(struct phy_device *); +}; + +struct sfp_eeprom_base { + u8 phys_id; + u8 phys_ext_id; + u8 connector; + u8 if_1x_copper_passive: 1; + u8 if_1x_copper_active: 1; + u8 if_1x_lx: 1; + u8 if_1x_sx: 1; + u8 e10g_base_sr: 1; + u8 e10g_base_lr: 1; + u8 e10g_base_lrm: 1; + u8 e10g_base_er: 1; + u8 sonet_oc3_short_reach: 1; + u8 sonet_oc3_smf_intermediate_reach: 1; + u8 sonet_oc3_smf_long_reach: 1; + u8 unallocated_5_3: 1; + u8 sonet_oc12_short_reach: 1; + u8 sonet_oc12_smf_intermediate_reach: 1; + u8 sonet_oc12_smf_long_reach: 1; + u8 unallocated_5_7: 1; + u8 sonet_oc48_short_reach: 1; + u8 sonet_oc48_intermediate_reach: 1; + u8 sonet_oc48_long_reach: 1; + u8 sonet_reach_bit2: 1; + u8 sonet_reach_bit1: 1; + u8 sonet_oc192_short_reach: 1; + u8 escon_smf_1310_laser: 1; + u8 escon_mmf_1310_led: 1; + u8 e1000_base_sx: 1; + u8 e1000_base_lx: 1; + u8 e1000_base_cx: 1; + u8 e1000_base_t: 1; + u8 e100_base_lx: 1; + u8 e100_base_fx: 1; + u8 e_base_bx10: 1; + u8 e_base_px: 1; + u8 fc_tech_electrical_inter_enclosure: 1; + u8 fc_tech_lc: 1; + u8 fc_tech_sa: 1; + u8 fc_ll_m: 1; + u8 fc_ll_l: 1; + u8 fc_ll_i: 1; + u8 fc_ll_s: 1; + u8 fc_ll_v: 1; + u8 unallocated_8_0: 1; + u8 unallocated_8_1: 1; + u8 sfp_ct_passive: 1; + u8 sfp_ct_active: 1; + u8 fc_tech_ll: 1; + u8 fc_tech_sl: 1; + u8 fc_tech_sn: 1; + u8 fc_tech_electrical_intra_enclosure: 1; + u8 fc_media_sm: 1; + u8 unallocated_9_1: 1; + u8 fc_media_m5: 1; + u8 fc_media_m6: 1; + u8 fc_media_tv: 1; + u8 fc_media_mi: 1; + u8 fc_media_tp: 1; + u8 fc_media_tw: 1; + u8 fc_speed_100: 1; + u8 unallocated_10_1: 1; + u8 fc_speed_200: 1; + u8 fc_speed_3200: 1; + u8 fc_speed_400: 1; + u8 fc_speed_1600: 1; + u8 fc_speed_800: 1; + u8 fc_speed_1200: 1; + u8 encoding; + u8 br_nominal; + u8 rate_id; + u8 link_len[6]; + char vendor_name[16]; + u8 extended_cc; + char vendor_oui[3]; + char vendor_pn[16]; + char vendor_rev[4]; + union { + __be16 optical_wavelength; + __be16 cable_compliance; + struct { + u8 sff8431_app_e: 1; + u8 fc_pi_4_app_h: 1; + u8 reserved60_2: 6; + u8 reserved61: 8; + } passive; + struct { + u8 sff8431_app_e: 1; + u8 fc_pi_4_app_h: 1; + u8 sff8431_lim: 1; + u8 fc_pi_4_lim: 1; + u8 reserved60_4: 4; + u8 reserved61: 8; + } active; + }; + u8 reserved62; + u8 cc_base; +}; + +struct sfp_eeprom_ext { + __be16 options; + u8 br_max; + u8 br_min; + char vendor_sn[16]; + char datecode[8]; + u8 diagmon; + u8 enhopts; + u8 sff8472_compliance; + u8 cc_ext; +}; + +struct sfp_eeprom_id { + struct sfp_eeprom_base base; + struct sfp_eeprom_ext ext; +}; + +struct sfp_upstream_ops { + void (*attach)(void *, struct sfp_bus *); + void (*detach)(void *, struct sfp_bus *); + int (*module_insert)(void *, const struct sfp_eeprom_id *); + void (*module_remove)(void *); + int (*module_start)(void *); + void (*module_stop)(void *); + void (*link_down)(void *); + void (*link_up)(void *); + int (*connect_phy)(void *, struct phy_device *); + void (*disconnect_phy)(void *); +}; + +struct trace_event_raw_mdio_access { + struct trace_entry ent; + char busid[61]; + char read; + u8 addr; + u16 val; + unsigned int regnum; + char __data[0]; +}; + +struct trace_event_data_offsets_mdio_access {}; + +typedef void (*btf_trace_mdio_access)(void *, struct mii_bus *, char, u8, unsigned int, u16, int); + +struct mdio_bus_stat_attr { + int addr; + unsigned int field_offset; +}; + +struct mdio_driver { + struct mdio_driver_common mdiodrv; + int (*probe)(struct mdio_device *); + void (*remove)(struct mdio_device *); +}; + +struct flow_dissector_key_control { + u16 thoff; + u16 addr_type; + u32 flags; +}; + +struct flow_dissector_key_basic { + __be16 n_proto; + u8 ip_proto; + u8 padding; +}; + +struct flow_dissector { + unsigned int used_keys; + short unsigned int offset[28]; +}; + +struct flow_keys_basic { + struct flow_dissector_key_control control; + struct flow_dissector_key_basic basic; +}; + +struct mmpin { + struct user_struct *user; + unsigned int num_pg; +}; + +struct ubuf_info { + void (*callback)(struct ubuf_info *, bool); + union { + struct { + long unsigned int desc; + void *ctx; + }; + struct { + u32 id; + u16 len; + u16 zerocopy: 1; + u32 bytelen; + }; + }; + refcount_t refcnt; + struct mmpin mmp; +}; + +enum { + SKB_GSO_TCPV4 = 1, + SKB_GSO_DODGY = 2, + SKB_GSO_TCP_ECN = 4, + SKB_GSO_TCP_FIXEDID = 8, + SKB_GSO_TCPV6 = 16, + SKB_GSO_FCOE = 32, + SKB_GSO_GRE = 64, + SKB_GSO_GRE_CSUM = 128, + SKB_GSO_IPXIP4 = 256, + SKB_GSO_IPXIP6 = 512, + SKB_GSO_UDP_TUNNEL = 1024, + SKB_GSO_UDP_TUNNEL_CSUM = 2048, + SKB_GSO_PARTIAL = 4096, + SKB_GSO_TUNNEL_REMCSUM = 8192, + SKB_GSO_SCTP = 16384, + SKB_GSO_ESP = 32768, + SKB_GSO_UDP = 65536, + SKB_GSO_UDP_L4 = 131072, + SKB_GSO_FRAGLIST = 262144, +}; + +struct rt6key { + struct in6_addr addr; + int plen; +}; + +struct rtable; + +struct fnhe_hash_bucket; + +struct fib_nh_common { + struct net_device *nhc_dev; + int nhc_oif; + unsigned char nhc_scope; + u8 nhc_family; + u8 nhc_gw_family; + unsigned char nhc_flags; + struct lwtunnel_state *nhc_lwtstate; + union { + __be32 ipv4; + struct in6_addr ipv6; + } nhc_gw; + int nhc_weight; + atomic_t nhc_upper_bound; + struct rtable **nhc_pcpu_rth_output; + struct rtable *nhc_rth_input; + struct fnhe_hash_bucket *nhc_exceptions; +}; + +struct rt6_exception_bucket; + +struct fib6_nh { + struct fib_nh_common nh_common; + long unsigned int last_probe; + struct rt6_info **rt6i_pcpu; + struct rt6_exception_bucket *rt6i_exception_bucket; +}; + +struct fib6_node; + +struct dst_metrics; + +struct nexthop; + +struct fib6_info { + struct fib6_table *fib6_table; + struct fib6_info *fib6_next; + struct fib6_node *fib6_node; + union { + struct list_head fib6_siblings; + struct list_head nh_list; + }; + unsigned int fib6_nsiblings; + refcount_t fib6_ref; + long unsigned int expires; + struct dst_metrics *fib6_metrics; + struct rt6key fib6_dst; + u32 fib6_flags; + struct rt6key fib6_src; + struct rt6key fib6_prefsrc; + u32 fib6_metric; + u8 fib6_protocol; + u8 fib6_type; + u8 should_flush: 1; + u8 dst_nocount: 1; + u8 dst_nopolicy: 1; + u8 fib6_destroying: 1; + u8 offload: 1; + u8 trap: 1; + u8 unused: 2; + struct callback_head rcu; + struct nexthop *nh; + struct fib6_nh fib6_nh[0]; +}; + +struct uncached_list; + +struct rt6_info { + struct dst_entry dst; + struct fib6_info *from; + int sernum; + struct rt6key rt6i_dst; + struct rt6key rt6i_src; + struct in6_addr rt6i_gateway; + struct inet6_dev *rt6i_idev; + u32 rt6i_flags; + struct list_head rt6i_uncached; + struct uncached_list *rt6i_uncached_list; + short unsigned int rt6i_nfheader_len; +}; + +struct rt6_statistics { + __u32 fib_nodes; + __u32 fib_route_nodes; + __u32 fib_rt_entries; + __u32 fib_rt_cache; + __u32 fib_discarded_routes; + atomic_t fib_rt_alloc; + atomic_t fib_rt_uncache; +}; + +struct fib6_node { + struct fib6_node *parent; + struct fib6_node *left; + struct fib6_node *right; + struct fib6_node *subtree; + struct fib6_info *leaf; + __u16 fn_bit; + __u16 fn_flags; + int fn_sernum; + struct fib6_info *rr_ptr; + struct callback_head rcu; +}; + +struct fib6_table { + struct hlist_node tb6_hlist; + u32 tb6_id; + spinlock_t tb6_lock; + struct fib6_node tb6_root; + struct inet_peer_base tb6_peers; + unsigned int flags; + unsigned int fib_seq; +}; + +enum { + IFLA_TUN_UNSPEC = 0, + IFLA_TUN_OWNER = 1, + IFLA_TUN_GROUP = 2, + IFLA_TUN_TYPE = 3, + IFLA_TUN_PI = 4, + IFLA_TUN_VNET_HDR = 5, + IFLA_TUN_PERSIST = 6, + IFLA_TUN_MULTI_QUEUE = 7, + IFLA_TUN_NUM_QUEUES = 8, + IFLA_TUN_NUM_DISABLED_QUEUES = 9, + __IFLA_TUN_MAX = 10, +}; + +struct gro_list { + struct list_head list; + int count; +}; + +struct napi_struct { + struct list_head poll_list; + long unsigned int state; + int weight; + int defer_hard_irqs_count; + long unsigned int gro_bitmask; + int (*poll)(struct napi_struct *, int); + int poll_owner; + struct net_device *dev; + struct gro_list gro_hash[8]; + struct sk_buff *skb; + struct list_head rx_list; + int rx_count; + struct hrtimer timer; + struct list_head dev_list; + struct hlist_node napi_hash_node; + unsigned int napi_id; +}; + +enum netdev_queue_state_t { + __QUEUE_STATE_DRV_XOFF = 0, + __QUEUE_STATE_STACK_XOFF = 1, + __QUEUE_STATE_FROZEN = 2, +}; + +struct rps_sock_flow_table { + u32 mask; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + u32 ents[0]; +}; + +struct ip_tunnel_parm { + char name[16]; + int link; + __be16 i_flags; + __be16 o_flags; + __be32 i_key; + __be32 o_key; + struct iphdr iph; +}; + +struct tun_pi { + __u16 flags; + __be16 proto; +}; + +struct tun_filter { + __u16 flags; + __u16 count; + __u8 addr[0]; +}; + +struct virtio_net_hdr { + __u8 flags; + __u8 gso_type; + __virtio16 hdr_len; + __virtio16 gso_size; + __virtio16 csum_start; + __virtio16 csum_offset; +}; + +struct tun_msg_ctl { + short unsigned int type; + short unsigned int num; + void *ptr; +}; + +struct tun_xdp_hdr { + int buflen; + struct virtio_net_hdr gso; +}; + +struct lwtunnel_state { + __u16 type; + __u16 flags; + __u16 headroom; + atomic_t refcnt; + int (*orig_output)(struct net *, struct sock *, struct sk_buff *); + int (*orig_input)(struct sk_buff *); + struct callback_head rcu; + __u8 data[0]; +}; + +struct dst_metrics { + u32 metrics[17]; + refcount_t refcnt; +}; + +struct fib_nh_exception { + struct fib_nh_exception *fnhe_next; + int fnhe_genid; + __be32 fnhe_daddr; + u32 fnhe_pmtu; + bool fnhe_mtu_locked; + __be32 fnhe_gw; + long unsigned int fnhe_expires; + struct rtable *fnhe_rth_input; + struct rtable *fnhe_rth_output; + long unsigned int fnhe_stamp; + struct callback_head rcu; +}; + +struct rtable { + struct dst_entry dst; + int rt_genid; + unsigned int rt_flags; + __u16 rt_type; + __u8 rt_is_input; + __u8 rt_uses_gateway; + int rt_iif; + u8 rt_gw_family; + union { + __be32 rt_gw4; + struct in6_addr rt_gw6; + }; + u32 rt_mtu_locked: 1; + u32 rt_pmtu: 31; + struct list_head rt_uncached; + struct uncached_list *rt_uncached_list; +}; + +struct fnhe_hash_bucket { + struct fib_nh_exception *chain; +}; + +struct fib_info; + +struct fib_nh { + struct fib_nh_common nh_common; + struct hlist_node nh_hash; + struct fib_info *nh_parent; + __u32 nh_tclassid; + __be32 nh_saddr; + int nh_saddr_genid; +}; + +struct fib_info { + struct hlist_node fib_hash; + struct hlist_node fib_lhash; + struct list_head nh_list; + struct net *fib_net; + int fib_treeref; + refcount_t fib_clntref; + unsigned int fib_flags; + unsigned char fib_dead; + unsigned char fib_protocol; + unsigned char fib_scope; + unsigned char fib_type; + __be32 fib_prefsrc; + u32 fib_tb_id; + u32 fib_priority; + struct dst_metrics *fib_metrics; + int fib_nhs; + bool fib_nh_is_v6; + bool nh_updated; + struct nexthop *nh; + struct callback_head rcu; + struct fib_nh fib_nh[0]; +}; + +struct nh_info; + +struct nh_group; + +struct nexthop { + struct rb_node rb_node; + struct list_head fi_list; + struct list_head f6i_list; + struct list_head fdb_list; + struct list_head grp_list; + struct net *net; + u32 id; + u8 protocol; + u8 nh_flags; + bool is_group; + refcount_t refcnt; + struct callback_head rcu; + union { + struct nh_info *nh_info; + struct nh_group *nh_grp; + }; +}; + +struct rt6_exception_bucket { + struct hlist_head chain; + int depth; +}; + +struct nh_info { + struct hlist_node dev_hash; + struct nexthop *nh_parent; + u8 family; + bool reject_nh; + bool fdb_nh; + union { + struct fib_nh_common fib_nhc; + struct fib_nh fib_nh; + struct fib6_nh fib6_nh; + }; +}; + +struct nh_grp_entry { + struct nexthop *nh; + u8 weight; + atomic_t upper_bound; + struct list_head nh_list; + struct nexthop *nh_parent; +}; + +struct nh_group { + struct nh_group *spare; + u16 num_nh; + bool mpath; + bool fdb_nh; + bool has_v4; + struct nh_grp_entry nh_entries[0]; +}; + +struct tap_filter { + unsigned int count; + u32 mask[2]; + unsigned char addr[48]; +}; + +struct tun_struct; + +struct tun_file { + struct sock sk; + long: 64; + long: 64; + struct socket socket; + struct tun_struct *tun; + struct fasync_struct *fasync; + unsigned int flags; + union { + u16 queue_index; + unsigned int ifindex; + }; + struct napi_struct napi; + bool napi_enabled; + bool napi_frags_enabled; + struct mutex napi_mutex; + struct list_head next; + struct tun_struct *detached; + struct ptr_ring tx_ring; + struct xdp_rxq_info xdp_rxq; +}; + +struct tun_prog; + +struct tun_struct { + struct tun_file *tfiles[256]; + unsigned int numqueues; + unsigned int flags; + kuid_t owner; + kgid_t group; + struct net_device *dev; + netdev_features_t set_features; + int align; + int vnet_hdr_sz; + int sndbuf; + struct tap_filter txflt; + struct sock_fprog fprog; + bool filter_attached; + u32 msg_enable; + spinlock_t lock; + struct hlist_head flows[1024]; + struct timer_list flow_gc_timer; + long unsigned int ageing_time; + unsigned int numdisabled; + struct list_head disabled; + void *security; + u32 flow_count; + u32 rx_batched; + atomic_long_t rx_frame_errors; + struct bpf_prog *xdp_prog; + struct tun_prog *steering_prog; + struct tun_prog *filter_prog; + struct ethtool_link_ksettings link_ksettings; +}; + +struct tun_page { + struct page *page; + int count; +}; + +struct tun_flow_entry { + struct hlist_node hash_link; + struct callback_head rcu; + struct tun_struct *tun; + u32 rxhash; + u32 rps_rxhash; + int queue_index; + long: 32; + long: 64; + long unsigned int updated; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct tun_prog { + struct callback_head rcu; + struct bpf_prog *prog; +}; + +struct veth { + __be16 h_vlan_proto; + __be16 h_vlan_TCI; +}; + +enum ethtool_stringset { + ETH_SS_TEST = 0, + ETH_SS_STATS = 1, + ETH_SS_PRIV_FLAGS = 2, + ETH_SS_NTUPLE_FILTERS = 3, + ETH_SS_FEATURES = 4, + ETH_SS_RSS_HASH_FUNCS = 5, + ETH_SS_TUNABLES = 6, + ETH_SS_PHY_STATS = 7, + ETH_SS_PHY_TUNABLES = 8, + ETH_SS_LINK_MODES = 9, + ETH_SS_MSG_CLASSES = 10, + ETH_SS_WOL_MODES = 11, + ETH_SS_SOF_TIMESTAMPING = 12, + ETH_SS_TS_TX_TYPES = 13, + ETH_SS_TS_RX_FILTERS = 14, + ETH_SS_UDP_TUNNEL_TYPES = 15, + ETH_SS_COUNT = 16, +}; + +typedef union { + __be32 a4; + __be32 a6[4]; + struct in6_addr in6; +} xfrm_address_t; + +struct xfrm_id { + xfrm_address_t daddr; + __be32 spi; + __u8 proto; +}; + +struct xfrm_sec_ctx { + __u8 ctx_doi; + __u8 ctx_alg; + __u16 ctx_len; + __u32 ctx_sid; + char ctx_str[0]; +}; + +struct xfrm_selector { + xfrm_address_t daddr; + xfrm_address_t saddr; + __be16 dport; + __be16 dport_mask; + __be16 sport; + __be16 sport_mask; + __u16 family; + __u8 prefixlen_d; + __u8 prefixlen_s; + __u8 proto; + int ifindex; + __kernel_uid32_t user; +}; + +struct xfrm_lifetime_cfg { + __u64 soft_byte_limit; + __u64 hard_byte_limit; + __u64 soft_packet_limit; + __u64 hard_packet_limit; + __u64 soft_add_expires_seconds; + __u64 hard_add_expires_seconds; + __u64 soft_use_expires_seconds; + __u64 hard_use_expires_seconds; +}; + +struct xfrm_lifetime_cur { + __u64 bytes; + __u64 packets; + __u64 add_time; + __u64 use_time; +}; + +struct xfrm_replay_state { + __u32 oseq; + __u32 seq; + __u32 bitmap; +}; + +struct xfrm_replay_state_esn { + unsigned int bmp_len; + __u32 oseq; + __u32 seq; + __u32 oseq_hi; + __u32 seq_hi; + __u32 replay_window; + __u32 bmp[0]; +}; + +struct xfrm_algo { + char alg_name[64]; + unsigned int alg_key_len; + char alg_key[0]; +}; + +struct xfrm_algo_auth { + char alg_name[64]; + unsigned int alg_key_len; + unsigned int alg_trunc_len; + char alg_key[0]; +}; + +struct xfrm_algo_aead { + char alg_name[64]; + unsigned int alg_key_len; + unsigned int alg_icv_len; + char alg_key[0]; +}; + +struct xfrm_stats { + __u32 replay_window; + __u32 replay; + __u32 integrity_failed; +}; + +enum { + XFRM_POLICY_TYPE_MAIN = 0, + XFRM_POLICY_TYPE_SUB = 1, + XFRM_POLICY_TYPE_MAX = 2, + XFRM_POLICY_TYPE_ANY = 255, +}; + +struct xfrm_encap_tmpl { + __u16 encap_type; + __be16 encap_sport; + __be16 encap_dport; + xfrm_address_t encap_oa; +}; + +enum xfrm_attr_type_t { + XFRMA_UNSPEC = 0, + XFRMA_ALG_AUTH = 1, + XFRMA_ALG_CRYPT = 2, + XFRMA_ALG_COMP = 3, + XFRMA_ENCAP = 4, + XFRMA_TMPL = 5, + XFRMA_SA = 6, + XFRMA_POLICY = 7, + XFRMA_SEC_CTX = 8, + XFRMA_LTIME_VAL = 9, + XFRMA_REPLAY_VAL = 10, + XFRMA_REPLAY_THRESH = 11, + XFRMA_ETIMER_THRESH = 12, + XFRMA_SRCADDR = 13, + XFRMA_COADDR = 14, + XFRMA_LASTUSED = 15, + XFRMA_POLICY_TYPE = 16, + XFRMA_MIGRATE = 17, + XFRMA_ALG_AEAD = 18, + XFRMA_KMADDRESS = 19, + XFRMA_ALG_AUTH_TRUNC = 20, + XFRMA_MARK = 21, + XFRMA_TFCPAD = 22, + XFRMA_REPLAY_ESN_VAL = 23, + XFRMA_SA_EXTRA_FLAGS = 24, + XFRMA_PROTO = 25, + XFRMA_ADDRESS_FILTER = 26, + XFRMA_PAD = 27, + XFRMA_OFFLOAD_DEV = 28, + XFRMA_SET_MARK = 29, + XFRMA_SET_MARK_MASK = 30, + XFRMA_IF_ID = 31, + __XFRMA_MAX = 32, +}; + +struct xfrm_mark { + __u32 v; + __u32 m; +}; + +struct xfrm_address_filter { + xfrm_address_t saddr; + xfrm_address_t daddr; + __u16 family; + __u8 splen; + __u8 dplen; +}; + +enum { + IFLA_UNSPEC = 0, + IFLA_ADDRESS = 1, + IFLA_BROADCAST = 2, + IFLA_IFNAME = 3, + IFLA_MTU = 4, + IFLA_LINK = 5, + IFLA_QDISC = 6, + IFLA_STATS = 7, + IFLA_COST = 8, + IFLA_PRIORITY = 9, + IFLA_MASTER = 10, + IFLA_WIRELESS = 11, + IFLA_PROTINFO = 12, + IFLA_TXQLEN = 13, + IFLA_MAP = 14, + IFLA_WEIGHT = 15, + IFLA_OPERSTATE = 16, + IFLA_LINKMODE = 17, + IFLA_LINKINFO = 18, + IFLA_NET_NS_PID = 19, + IFLA_IFALIAS = 20, + IFLA_NUM_VF = 21, + IFLA_VFINFO_LIST = 22, + IFLA_STATS64 = 23, + IFLA_VF_PORTS = 24, + IFLA_PORT_SELF = 25, + IFLA_AF_SPEC = 26, + IFLA_GROUP = 27, + IFLA_NET_NS_FD = 28, + IFLA_EXT_MASK = 29, + IFLA_PROMISCUITY = 30, + IFLA_NUM_TX_QUEUES = 31, + IFLA_NUM_RX_QUEUES = 32, + IFLA_CARRIER = 33, + IFLA_PHYS_PORT_ID = 34, + IFLA_CARRIER_CHANGES = 35, + IFLA_PHYS_SWITCH_ID = 36, + IFLA_LINK_NETNSID = 37, + IFLA_PHYS_PORT_NAME = 38, + IFLA_PROTO_DOWN = 39, + IFLA_GSO_MAX_SEGS = 40, + IFLA_GSO_MAX_SIZE = 41, + IFLA_PAD = 42, + IFLA_XDP = 43, + IFLA_EVENT = 44, + IFLA_NEW_NETNSID = 45, + IFLA_IF_NETNSID = 46, + IFLA_TARGET_NETNSID = 46, + IFLA_CARRIER_UP_COUNT = 47, + IFLA_CARRIER_DOWN_COUNT = 48, + IFLA_NEW_IFINDEX = 49, + IFLA_MIN_MTU = 50, + IFLA_MAX_MTU = 51, + IFLA_PROP_LIST = 52, + IFLA_ALT_IFNAME = 53, + IFLA_PERM_ADDRESS = 54, + IFLA_PROTO_DOWN_REASON = 55, + __IFLA_MAX = 56, +}; + +enum skb_free_reason { + SKB_REASON_CONSUMED = 0, + SKB_REASON_DROPPED = 1, +}; + +struct ifinfomsg { + unsigned char ifi_family; + unsigned char __ifi_pad; + short unsigned int ifi_type; + int ifi_index; + unsigned int ifi_flags; + unsigned int ifi_change; +}; + +struct xfrm_state_walk { + struct list_head all; + u8 state; + u8 dying; + u8 proto; + u32 seq; + struct xfrm_address_filter *filter; +}; + +struct xfrm_state_offload { + struct net_device *dev; + struct net_device *real_dev; + long unsigned int offload_handle; + unsigned int num_exthdrs; + u8 flags; +}; + +struct xfrm_mode { + u8 encap; + u8 family; + u8 flags; +}; + +struct xfrm_replay; + +struct xfrm_type; + +struct xfrm_type_offload; + +struct xfrm_state { + possible_net_t xs_net; + union { + struct hlist_node gclist; + struct hlist_node bydst; + }; + struct hlist_node bysrc; + struct hlist_node byspi; + refcount_t refcnt; + spinlock_t lock; + struct xfrm_id id; + struct xfrm_selector sel; + struct xfrm_mark mark; + u32 if_id; + u32 tfcpad; + u32 genid; + struct xfrm_state_walk km; + struct { + u32 reqid; + u8 mode; + u8 replay_window; + u8 aalgo; + u8 ealgo; + u8 calgo; + u8 flags; + u16 family; + xfrm_address_t saddr; + int header_len; + int trailer_len; + u32 extra_flags; + struct xfrm_mark smark; + } props; + struct xfrm_lifetime_cfg lft; + struct xfrm_algo_auth *aalg; + struct xfrm_algo *ealg; + struct xfrm_algo *calg; + struct xfrm_algo_aead *aead; + const char *geniv; + struct xfrm_encap_tmpl *encap; + struct sock *encap_sk; + xfrm_address_t *coaddr; + struct xfrm_state *tunnel; + atomic_t tunnel_users; + struct xfrm_replay_state replay; + struct xfrm_replay_state_esn *replay_esn; + struct xfrm_replay_state preplay; + struct xfrm_replay_state_esn *preplay_esn; + const struct xfrm_replay *repl; + u32 xflags; + u32 replay_maxage; + u32 replay_maxdiff; + struct timer_list rtimer; + struct xfrm_stats stats; + struct xfrm_lifetime_cur curlft; + struct hrtimer mtimer; + struct xfrm_state_offload xso; + long int saved_tmo; + time64_t lastused; + struct page_frag xfrag; + const struct xfrm_type *type; + struct xfrm_mode inner_mode; + struct xfrm_mode inner_mode_iaf; + struct xfrm_mode outer_mode; + const struct xfrm_type_offload *type_offload; + struct xfrm_sec_ctx *security; + void *data; +}; + +struct xfrm_policy_walk_entry { + struct list_head all; + u8 dead; +}; + +struct xfrm_policy_queue { + struct sk_buff_head hold_queue; + struct timer_list hold_timer; + long unsigned int timeout; +}; + +struct xfrm_tmpl { + struct xfrm_id id; + xfrm_address_t saddr; + short unsigned int encap_family; + u32 reqid; + u8 mode; + u8 share; + u8 optional; + u8 allalgs; + u32 aalgos; + u32 ealgos; + u32 calgos; +}; + +struct xfrm_policy { + possible_net_t xp_net; + struct hlist_node bydst; + struct hlist_node byidx; + rwlock_t lock; + refcount_t refcnt; + u32 pos; + struct timer_list timer; + atomic_t genid; + u32 priority; + u32 index; + u32 if_id; + struct xfrm_mark mark; + struct xfrm_selector selector; + struct xfrm_lifetime_cfg lft; + struct xfrm_lifetime_cur curlft; + struct xfrm_policy_walk_entry walk; + struct xfrm_policy_queue polq; + bool bydst_reinsert; + u8 type; + u8 action; + u8 flags; + u8 xfrm_nr; + u16 family; + struct xfrm_sec_ctx *security; + struct xfrm_tmpl xfrm_vec[6]; + struct hlist_node bydst_inexact_list; + struct callback_head rcu; +}; + +struct xfrm_replay { + void (*advance)(struct xfrm_state *, __be32); + int (*check)(struct xfrm_state *, struct sk_buff *, __be32); + int (*recheck)(struct xfrm_state *, struct sk_buff *, __be32); + void (*notify)(struct xfrm_state *, int); + int (*overflow)(struct xfrm_state *, struct sk_buff *); +}; + +struct xfrm_type { + char *description; + struct module *owner; + u8 proto; + u8 flags; + int (*init_state)(struct xfrm_state *); + void (*destructor)(struct xfrm_state *); + int (*input)(struct xfrm_state *, struct sk_buff *); + int (*output)(struct xfrm_state *, struct sk_buff *); + int (*reject)(struct xfrm_state *, struct sk_buff *, const struct flowi *); + int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); +}; + +struct xfrm_type_offload { + char *description; + struct module *owner; + u8 proto; + void (*encap)(struct xfrm_state *, struct sk_buff *); + int (*input_tail)(struct xfrm_state *, struct sk_buff *); + int (*xmit)(struct xfrm_state *, struct sk_buff *, netdev_features_t); +}; + +enum { + VETH_INFO_UNSPEC = 0, + VETH_INFO_PEER = 1, + __VETH_INFO_MAX = 2, +}; + +struct veth_stats { + u64 rx_drops; + u64 xdp_packets; + u64 xdp_bytes; + u64 xdp_redirect; + u64 xdp_drops; + u64 xdp_tx; + u64 xdp_tx_err; + u64 peer_tq_xdp_xmit; + u64 peer_tq_xdp_xmit_err; +}; + +struct veth_rq_stats { + struct veth_stats vs; + struct u64_stats_sync syncp; +}; + +struct veth_rq { + struct napi_struct xdp_napi; + struct net_device *dev; + struct bpf_prog *xdp_prog; + struct xdp_mem_info xdp_mem; + struct veth_rq_stats stats; + bool rx_notify_masked; + long: 56; + long: 64; + long: 64; + struct ptr_ring xdp_ring; + struct xdp_rxq_info xdp_rxq; +}; + +struct veth_priv { + struct net_device *peer; + atomic64_t dropped; + struct bpf_prog *_xdp_prog; + struct veth_rq *rq; + unsigned int requested_headroom; +}; + +struct veth_xdp_tx_bq { + struct xdp_frame *q[16]; + unsigned int count; +}; + +struct veth_q_stat_desc { + char desc[32]; + size_t offset; +}; + +struct netdev_hw_addr { + struct list_head list; + unsigned char addr[32]; + unsigned char type; + bool global_use; + int sync_cnt; + int refcount; + int synced; + struct callback_head callback_head; +}; + +struct rx_queue_attribute { + struct attribute attr; + ssize_t (*show)(struct netdev_rx_queue *, char *); + ssize_t (*store)(struct netdev_rx_queue *, const char *, size_t); +}; + +struct sd_flow_limit { + u64 count; + unsigned int num_buckets; + unsigned int history_head; + u16 history[128]; + u8 buckets[0]; +}; + +struct softnet_data { + struct list_head poll_list; + struct sk_buff_head process_queue; + unsigned int processed; + unsigned int time_squeeze; + unsigned int received_rps; + struct softnet_data *rps_ipi_list; + struct sd_flow_limit *flow_limit; + struct Qdisc *output_queue; + struct Qdisc **output_queue_tailp; + struct sk_buff *completion_queue; + struct { + u16 recursion; + u8 more; + } xmit; + int: 32; + unsigned int input_queue_head; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + call_single_data_t csd; + struct softnet_data *rps_ipi_next; + unsigned int cpu; + unsigned int input_queue_tail; + unsigned int dropped; + struct sk_buff_head input_pkt_queue; + struct napi_struct backlog; + long: 64; + long: 64; +}; + +struct virtio_net_config { + __u8 mac[6]; + __virtio16 status; + __virtio16 max_virtqueue_pairs; + __virtio16 mtu; + __le32 speed; + __u8 duplex; + __u8 rss_max_key_size; + __le16 rss_max_indirection_table_length; + __le32 supported_hash_types; +}; + +struct virtio_net_hdr_mrg_rxbuf { + struct virtio_net_hdr hdr; + __virtio16 num_buffers; +}; + +struct virtio_net_ctrl_hdr { + __u8 class; + __u8 cmd; +}; + +typedef __u8 virtio_net_ctrl_ack; + +struct virtio_net_ctrl_mac { + __virtio32 entries; + __u8 macs[0]; +}; + +struct virtio_net_ctrl_mq { + __virtio16 virtqueue_pairs; +}; + +struct failover_ops { + int (*slave_pre_register)(struct net_device *, struct net_device *); + int (*slave_register)(struct net_device *, struct net_device *); + int (*slave_pre_unregister)(struct net_device *, struct net_device *); + int (*slave_unregister)(struct net_device *, struct net_device *); + int (*slave_link_change)(struct net_device *, struct net_device *); + int (*slave_name_change)(struct net_device *, struct net_device *); + rx_handler_result_t (*slave_handle_frame)(struct sk_buff **); +}; + +struct failover { + struct list_head list; + struct net_device *failover_dev; + struct failover_ops *ops; +}; + +struct ewma_pkt_len { + long unsigned int internal; +}; + +struct virtnet_stat_desc { + char desc[32]; + size_t offset; +}; + +struct virtnet_sq_stats { + struct u64_stats_sync syncp; + u64 packets; + u64 bytes; + u64 xdp_tx; + u64 xdp_tx_drops; + u64 kicks; +}; + +struct virtnet_rq_stats { + struct u64_stats_sync syncp; + u64 packets; + u64 bytes; + u64 drops; + u64 xdp_packets; + u64 xdp_tx; + u64 xdp_redirects; + u64 xdp_drops; + u64 kicks; +}; + +struct send_queue { + struct virtqueue *vq; + struct scatterlist sg[19]; + char name[40]; + struct virtnet_sq_stats stats; + struct napi_struct napi; +}; + +struct receive_queue { + struct virtqueue *vq; + struct napi_struct napi; + struct bpf_prog *xdp_prog; + struct virtnet_rq_stats stats; + struct page *pages; + struct ewma_pkt_len mrg_avg_pkt_len; + struct page_frag alloc_frag; + struct scatterlist sg[19]; + unsigned int min_buf_len; + char name[40]; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct xdp_rxq_info xdp_rxq; +}; + +struct control_buf { + struct virtio_net_ctrl_hdr hdr; + virtio_net_ctrl_ack status; + struct virtio_net_ctrl_mq mq; + u8 promisc; + u8 allmulti; + __virtio16 vid; + __virtio64 offloads; +}; + +struct virtnet_info { + struct virtio_device *vdev; + struct virtqueue *cvq; + struct net_device *dev; + struct send_queue *sq; + struct receive_queue *rq; + unsigned int status; + u16 max_queue_pairs; + u16 curr_queue_pairs; + u16 xdp_queue_pairs; + bool big_packets; + bool mergeable_rx_bufs; + bool has_cvq; + bool any_header_sg; + u8 hdr_len; + struct delayed_work refill; + struct work_struct config_work; + bool affinity_hint_set; + struct hlist_node node; + struct hlist_node node_dead; + struct control_buf *ctrl; + u8 duplex; + u32 speed; + long unsigned int guest_offloads; + long unsigned int guest_offloads_capable; + struct failover *failover; +}; + +struct icmpv6_echo { + __be16 identifier; + __be16 sequence; +}; + +struct icmpv6_nd_advt { + __u32 reserved: 5; + __u32 override: 1; + __u32 solicited: 1; + __u32 router: 1; + __u32 reserved2: 24; +}; + +struct icmpv6_nd_ra { + __u8 hop_limit; + __u8 reserved: 3; + __u8 router_pref: 2; + __u8 home_agent: 1; + __u8 other: 1; + __u8 managed: 1; + __be16 rt_lifetime; +}; + +struct icmp6hdr { + __u8 icmp6_type; + __u8 icmp6_code; + __sum16 icmp6_cksum; + union { + __be32 un_data32[1]; + __be16 un_data16[2]; + __u8 un_data8[4]; + struct icmpv6_echo u_echo; + struct icmpv6_nd_advt u_nd_advt; + struct icmpv6_nd_ra u_nd_ra; + } icmp6_dataun; +}; + +struct ip_mreqn { + struct in_addr imr_multiaddr; + struct in_addr imr_address; + int imr_ifindex; +}; + +enum { + NDA_UNSPEC = 0, + NDA_DST = 1, + NDA_LLADDR = 2, + NDA_CACHEINFO = 3, + NDA_PROBES = 4, + NDA_VLAN = 5, + NDA_PORT = 6, + NDA_VNI = 7, + NDA_IFINDEX = 8, + NDA_MASTER = 9, + NDA_LINK_NETNSID = 10, + NDA_SRC_VNI = 11, + NDA_PROTOCOL = 12, + NDA_NH_ID = 13, + NDA_FDB_EXT_ATTRS = 14, + __NDA_MAX = 15, +}; + +struct nda_cacheinfo { + __u32 ndm_confirmed; + __u32 ndm_used; + __u32 ndm_updated; + __u32 ndm_refcnt; +}; + +enum { + IFLA_VXLAN_UNSPEC = 0, + IFLA_VXLAN_ID = 1, + IFLA_VXLAN_GROUP = 2, + IFLA_VXLAN_LINK = 3, + IFLA_VXLAN_LOCAL = 4, + IFLA_VXLAN_TTL = 5, + IFLA_VXLAN_TOS = 6, + IFLA_VXLAN_LEARNING = 7, + IFLA_VXLAN_AGEING = 8, + IFLA_VXLAN_LIMIT = 9, + IFLA_VXLAN_PORT_RANGE = 10, + IFLA_VXLAN_PROXY = 11, + IFLA_VXLAN_RSC = 12, + IFLA_VXLAN_L2MISS = 13, + IFLA_VXLAN_L3MISS = 14, + IFLA_VXLAN_PORT = 15, + IFLA_VXLAN_GROUP6 = 16, + IFLA_VXLAN_LOCAL6 = 17, + IFLA_VXLAN_UDP_CSUM = 18, + IFLA_VXLAN_UDP_ZERO_CSUM6_TX = 19, + IFLA_VXLAN_UDP_ZERO_CSUM6_RX = 20, + IFLA_VXLAN_REMCSUM_TX = 21, + IFLA_VXLAN_REMCSUM_RX = 22, + IFLA_VXLAN_GBP = 23, + IFLA_VXLAN_REMCSUM_NOPARTIAL = 24, + IFLA_VXLAN_COLLECT_METADATA = 25, + IFLA_VXLAN_LABEL = 26, + IFLA_VXLAN_GPE = 27, + IFLA_VXLAN_TTL_INHERIT = 28, + IFLA_VXLAN_DF = 29, + __IFLA_VXLAN_MAX = 30, +}; + +struct ifla_vxlan_port_range { + __be16 low; + __be16 high; +}; + +enum ifla_vxlan_df { + VXLAN_DF_UNSET = 0, + VXLAN_DF_SET = 1, + VXLAN_DF_INHERIT = 2, + __VXLAN_DF_END = 3, + VXLAN_DF_MAX = 2, +}; + +struct udp_tunnel_info { + short unsigned int type; + sa_family_t sa_family; + __be16 port; + u8 hw_priv; +}; + +struct napi_gro_cb { + void *frag0; + unsigned int frag0_len; + int data_offset; + u16 flush; + u16 flush_id; + u16 count; + u16 gro_remcsum_start; + long unsigned int age; + u16 proto; + u8 same_flow: 1; + u8 encap_mark: 1; + u8 csum_valid: 1; + u8 csum_cnt: 3; + u8 free: 2; + u8 is_ipv6: 1; + u8 is_fou: 1; + u8 is_atomic: 1; + u8 recursion_counter: 4; + u8 is_flist: 1; + __wsum csum; + struct sk_buff *last; +}; + +typedef struct sk_buff * (*gro_receive_t)(struct list_head *, struct sk_buff *); + +struct gro_remcsum { + int offset; + __wsum delta; +}; + +enum { + RTN_UNSPEC = 0, + RTN_UNICAST = 1, + RTN_LOCAL = 2, + RTN_BROADCAST = 3, + RTN_ANYCAST = 4, + RTN_MULTICAST = 5, + RTN_BLACKHOLE = 6, + RTN_UNREACHABLE = 7, + RTN_PROHIBIT = 8, + RTN_THROW = 9, + RTN_NAT = 10, + RTN_XRESOLVE = 11, + __RTN_MAX = 12, +}; + +enum rtnetlink_groups { + RTNLGRP_NONE = 0, + RTNLGRP_LINK = 1, + RTNLGRP_NOTIFY = 2, + RTNLGRP_NEIGH = 3, + RTNLGRP_TC = 4, + RTNLGRP_IPV4_IFADDR = 5, + RTNLGRP_IPV4_MROUTE = 6, + RTNLGRP_IPV4_ROUTE = 7, + RTNLGRP_IPV4_RULE = 8, + RTNLGRP_IPV6_IFADDR = 9, + RTNLGRP_IPV6_MROUTE = 10, + RTNLGRP_IPV6_ROUTE = 11, + RTNLGRP_IPV6_IFINFO = 12, + RTNLGRP_DECnet_IFADDR = 13, + RTNLGRP_NOP2 = 14, + RTNLGRP_DECnet_ROUTE = 15, + RTNLGRP_DECnet_RULE = 16, + RTNLGRP_NOP4 = 17, + RTNLGRP_IPV6_PREFIX = 18, + RTNLGRP_IPV6_RULE = 19, + RTNLGRP_ND_USEROPT = 20, + RTNLGRP_PHONET_IFADDR = 21, + RTNLGRP_PHONET_ROUTE = 22, + RTNLGRP_DCB = 23, + RTNLGRP_IPV4_NETCONF = 24, + RTNLGRP_IPV6_NETCONF = 25, + RTNLGRP_MDB = 26, + RTNLGRP_MPLS_ROUTE = 27, + RTNLGRP_NSID = 28, + RTNLGRP_MPLS_NETCONF = 29, + RTNLGRP_IPV4_MROUTE_R = 30, + RTNLGRP_IPV6_MROUTE_R = 31, + RTNLGRP_NEXTHOP = 32, + RTNLGRP_BRVLAN = 33, + __RTNLGRP_MAX = 34, +}; + +struct vlan_hdr { + __be16 h_vlan_TCI; + __be16 h_vlan_encapsulated_proto; +}; + +struct nl_info { + struct nlmsghdr *nlh; + struct net *nl_net; + u32 portid; + u8 skip_notify: 1; + u8 skip_notify_kernel: 1; +}; + +struct ip_tunnel_key { + __be64 tun_id; + union { + struct { + __be32 src; + __be32 dst; + } ipv4; + struct { + struct in6_addr src; + struct in6_addr dst; + } ipv6; + } u; + __be16 tun_flags; + u8 tos; + u8 ttl; + __be32 label; + __be16 tp_src; + __be16 tp_dst; +}; + +struct dst_cache_pcpu; + +struct dst_cache { + struct dst_cache_pcpu *cache; + long unsigned int reset_ts; +}; + +struct ip_tunnel_info { + struct ip_tunnel_key key; + struct dst_cache dst_cache; + u8 options_len; + u8 mode; +}; + +struct udp_hslot; + +struct udp_table { + struct udp_hslot *hash; + struct udp_hslot *hash2; + unsigned int mask; + unsigned int log; +}; + +struct ip_sf_socklist; + +struct ip_mc_socklist { + struct ip_mc_socklist *next_rcu; + struct ip_mreqn multi; + unsigned int sfmode; + struct ip_sf_socklist *sflist; + struct callback_head rcu; +}; + +struct ip_sf_socklist { + unsigned int sl_max; + unsigned int sl_count; + struct callback_head rcu; + __be32 sl_addr[0]; +}; + +struct arphdr { + __be16 ar_hrd; + __be16 ar_pro; + unsigned char ar_hln; + unsigned char ar_pln; + __be16 ar_op; +}; + +struct fib6_result; + +struct fib6_config; + +struct ipv6_stub { + int (*ipv6_sock_mc_join)(struct sock *, int, const struct in6_addr *); + int (*ipv6_sock_mc_drop)(struct sock *, int, const struct in6_addr *); + struct dst_entry * (*ipv6_dst_lookup_flow)(struct net *, const struct sock *, struct flowi6 *, const struct in6_addr *); + int (*ipv6_route_input)(struct sk_buff *); + struct fib6_table * (*fib6_get_table)(struct net *, u32); + int (*fib6_lookup)(struct net *, int, struct flowi6 *, struct fib6_result *, int); + int (*fib6_table_lookup)(struct net *, struct fib6_table *, int, struct flowi6 *, struct fib6_result *, int); + void (*fib6_select_path)(const struct net *, struct fib6_result *, struct flowi6 *, int, bool, const struct sk_buff *, int); + u32 (*ip6_mtu_from_fib6)(const struct fib6_result *, const struct in6_addr *, const struct in6_addr *); + int (*fib6_nh_init)(struct net *, struct fib6_nh *, struct fib6_config *, gfp_t, struct netlink_ext_ack *); + void (*fib6_nh_release)(struct fib6_nh *); + void (*fib6_update_sernum)(struct net *, struct fib6_info *); + int (*ip6_del_rt)(struct net *, struct fib6_info *, bool); + void (*fib6_rt_update)(struct net *, struct fib6_info *, struct nl_info *); + void (*udpv6_encap_enable)(); + void (*ndisc_send_na)(struct net_device *, const struct in6_addr *, const struct in6_addr *, bool, bool, bool, bool); + void (*xfrm6_local_rxpmtu)(struct sk_buff *, u32); + int (*xfrm6_udp_encap_rcv)(struct sock *, struct sk_buff *); + int (*xfrm6_rcv_encap)(struct sk_buff *, int, __be32, int); + struct neigh_table *nd_tbl; + int (*ipv6_fragment)(struct net *, struct sock *, struct sk_buff *, int (*)(struct net *, struct sock *, struct sk_buff *)); +}; + +struct fib6_result { + struct fib6_nh *nh; + struct fib6_info *f6i; + u32 fib6_flags; + u8 fib6_type; + struct rt6_info *rt6; +}; + +struct fib6_config { + u32 fc_table; + u32 fc_metric; + int fc_dst_len; + int fc_src_len; + int fc_ifindex; + u32 fc_flags; + u32 fc_protocol; + u16 fc_type; + u16 fc_delete_all_nh: 1; + u16 fc_ignore_dev_down: 1; + u16 __unused: 14; + u32 fc_nh_id; + struct in6_addr fc_dst; + struct in6_addr fc_src; + struct in6_addr fc_prefsrc; + struct in6_addr fc_gateway; + long unsigned int fc_expires; + struct nlattr *fc_mx; + int fc_mx_len; + int fc_mp_len; + struct nlattr *fc_mp; + struct nl_info fc_nlinfo; + struct nlattr *fc_encap; + u16 fc_encap_type; + bool fc_is_fdb; +}; + +struct nd_msg { + struct icmp6hdr icmph; + struct in6_addr target; + __u8 opt[0]; +}; + +enum { + INET_ECN_NOT_ECT = 0, + INET_ECN_ECT_1 = 1, + INET_ECN_ECT_0 = 2, + INET_ECN_CE = 3, + INET_ECN_MASK = 3, +}; + +struct gro_cell; + +struct gro_cells { + struct gro_cell *cells; +}; + +enum nexthop_event_type { + NEXTHOP_EVENT_DEL = 0, + NEXTHOP_EVENT_REPLACE = 1, +}; + +struct nh_notifier_single_info { + struct net_device *dev; + u8 gw_family; + union { + __be32 ipv4; + struct in6_addr ipv6; + }; + u8 is_reject: 1; + u8 is_fdb: 1; + u8 has_encap: 1; +}; + +struct nh_notifier_grp_entry_info { + u8 weight; + u32 id; + struct nh_notifier_single_info nh; +}; + +struct nh_notifier_grp_info { + u16 num_nh; + bool is_fdb; + struct nh_notifier_grp_entry_info nh_entries[0]; +}; + +struct nh_notifier_info { + struct net *net; + struct netlink_ext_ack *extack; + u32 id; + bool is_grp; + union { + struct nh_notifier_single_info *nh; + struct nh_notifier_grp_info *nh_grp; + }; +}; + +struct udp_hslot { + struct hlist_head head; + int count; + spinlock_t lock; + long: 64; +}; + +struct udp_port_cfg { + u8 family; + union { + struct in_addr local_ip; + struct in6_addr local_ip6; + }; + union { + struct in_addr peer_ip; + struct in6_addr peer_ip6; + }; + __be16 local_udp_port; + __be16 peer_udp_port; + int bind_ifindex; + unsigned int use_udp_checksums: 1; + unsigned int use_udp6_tx_checksums: 1; + unsigned int use_udp6_rx_checksums: 1; + unsigned int ipv6_v6only: 1; +}; + +typedef int (*udp_tunnel_encap_rcv_t)(struct sock *, struct sk_buff *); + +typedef int (*udp_tunnel_encap_err_lookup_t)(struct sock *, struct sk_buff *); + +typedef void (*udp_tunnel_encap_destroy_t)(struct sock *); + +typedef struct sk_buff * (*udp_tunnel_gro_receive_t)(struct sock *, struct list_head *, struct sk_buff *); + +typedef int (*udp_tunnel_gro_complete_t)(struct sock *, struct sk_buff *, int); + +struct udp_tunnel_sock_cfg { + void *sk_user_data; + __u8 encap_type; + udp_tunnel_encap_rcv_t encap_rcv; + udp_tunnel_encap_err_lookup_t encap_err_lookup; + udp_tunnel_encap_destroy_t encap_destroy; + udp_tunnel_gro_receive_t gro_receive; + udp_tunnel_gro_complete_t gro_complete; +}; + +enum udp_parsable_tunnel_type { + UDP_TUNNEL_TYPE_VXLAN = 1, + UDP_TUNNEL_TYPE_GENEVE = 2, + UDP_TUNNEL_TYPE_VXLAN_GPE = 4, +}; + +struct udp_tunnel_nic_shared { + struct udp_tunnel_nic *udp_tunnel_nic_info; + struct list_head devices; +}; + +enum metadata_type { + METADATA_IP_TUNNEL = 0, + METADATA_HW_PORT_MUX = 1, +}; + +struct hw_port_info { + struct net_device *lower_dev; + u32 port_id; +}; + +struct metadata_dst { + struct dst_entry dst; + enum metadata_type type; + union { + struct ip_tunnel_info tun_info; + struct hw_port_info port_info; + } u; +}; + +enum switchdev_notifier_type { + SWITCHDEV_FDB_ADD_TO_BRIDGE = 1, + SWITCHDEV_FDB_DEL_TO_BRIDGE = 2, + SWITCHDEV_FDB_ADD_TO_DEVICE = 3, + SWITCHDEV_FDB_DEL_TO_DEVICE = 4, + SWITCHDEV_FDB_OFFLOADED = 5, + SWITCHDEV_FDB_FLUSH_TO_BRIDGE = 6, + SWITCHDEV_PORT_OBJ_ADD = 7, + SWITCHDEV_PORT_OBJ_DEL = 8, + SWITCHDEV_PORT_ATTR_SET = 9, + SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE = 10, + SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE = 11, + SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE = 12, + SWITCHDEV_VXLAN_FDB_DEL_TO_DEVICE = 13, + SWITCHDEV_VXLAN_FDB_OFFLOADED = 14, +}; + +struct switchdev_notifier_info { + struct net_device *dev; + struct netlink_ext_ack *extack; +}; + +struct vxlanhdr { + __be32 vx_flags; + __be32 vx_vni; +}; + +struct vxlanhdr_gbp { + u8 vx_flags; + u8 reserved_flags1: 3; + u8 policy_applied: 1; + u8 reserved_flags2: 2; + u8 dont_learn: 1; + u8 reserved_flags3: 1; + __be16 policy_id; + __be32 vx_vni; +}; + +struct vxlanhdr_gpe { + u8 oam_flag: 1; + u8 reserved_flags1: 1; + u8 np_applied: 1; + u8 instance_applied: 1; + u8 version: 2; + u8 reserved_flags2: 2; + u8 reserved_flags3; + u8 reserved_flags4; + u8 next_protocol; + __be32 vx_vni; +}; + +struct vxlan_metadata { + u32 gbp; +}; + +struct vxlan_sock { + struct hlist_node hlist; + struct socket *sock; + struct hlist_head vni_list[1024]; + refcount_t refcnt; + u32 flags; +}; + +union vxlan_addr { + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + struct sockaddr sa; +}; + +struct vxlan_rdst { + union vxlan_addr remote_ip; + __be16 remote_port; + u8 offloaded: 1; + __be32 remote_vni; + u32 remote_ifindex; + struct net_device *remote_dev; + struct list_head list; + struct callback_head rcu; + struct dst_cache dst_cache; +}; + +struct vxlan_config { + union vxlan_addr remote_ip; + union vxlan_addr saddr; + __be32 vni; + int remote_ifindex; + int mtu; + __be16 dst_port; + u16 port_min; + u16 port_max; + u8 tos; + u8 ttl; + __be32 label; + u32 flags; + long unsigned int age_interval; + unsigned int addrmax; + bool no_share; + enum ifla_vxlan_df df; +}; + +struct vxlan_dev; + +struct vxlan_dev_node { + struct hlist_node hlist; + struct vxlan_dev *vxlan; +}; + +struct vxlan_dev { + struct vxlan_dev_node hlist4; + struct vxlan_dev_node hlist6; + struct list_head next; + struct vxlan_sock *vn4_sock; + struct vxlan_sock *vn6_sock; + struct net_device *dev; + struct net *net; + struct vxlan_rdst default_dst; + struct timer_list age_timer; + spinlock_t hash_lock[256]; + unsigned int addrcnt; + struct gro_cells gro_cells; + struct vxlan_config cfg; + struct hlist_head fdb_head[256]; +}; + +struct switchdev_notifier_vxlan_fdb_info { + struct switchdev_notifier_info info; + union vxlan_addr remote_ip; + __be16 remote_port; + __be32 remote_vni; + u32 remote_ifindex; + u8 eth_addr[6]; + __be32 vni; + bool offloaded; + bool added_by_user; +}; + +struct vxlan_net { + struct list_head vxlan_list; + struct hlist_head sock_list[256]; + spinlock_t sock_lock; + struct notifier_block nexthop_notifier_block; +}; + +struct vxlan_fdb { + struct hlist_node hlist; + struct callback_head rcu; + long unsigned int updated; + long unsigned int used; + struct list_head remotes; + u8 eth_addr[6]; + u16 state; + __be32 vni; + u16 flags; + struct list_head nh_list; + struct nexthop *nh; + struct vxlan_dev *vdev; +}; + +struct qdisc_walker { + int stop; + int skip; + int count; + int (*fn)(struct Qdisc *, long unsigned int, struct qdisc_walker *); +}; + +typedef enum { + e1000_undefined = 0, + e1000_82542_rev2_0 = 1, + e1000_82542_rev2_1 = 2, + e1000_82543 = 3, + e1000_82544 = 4, + e1000_82540 = 5, + e1000_82545 = 6, + e1000_82545_rev_3 = 7, + e1000_82546 = 8, + e1000_ce4100 = 9, + e1000_82546_rev_3 = 10, + e1000_82541 = 11, + e1000_82541_rev_2 = 12, + e1000_82547 = 13, + e1000_82547_rev_2 = 14, + e1000_num_macs = 15, +} e1000_mac_type; + +typedef enum { + e1000_eeprom_uninitialized = 0, + e1000_eeprom_spi = 1, + e1000_eeprom_microwire = 2, + e1000_eeprom_flash = 3, + e1000_eeprom_none = 4, + e1000_num_eeprom_types = 5, +} e1000_eeprom_type; + +typedef enum { + e1000_media_type_copper = 0, + e1000_media_type_fiber = 1, + e1000_media_type_internal_serdes = 2, + e1000_num_media_types = 3, +} e1000_media_type; + +enum { + e1000_10_half = 0, + e1000_10_full = 1, + e1000_100_half = 2, + e1000_100_full = 3, +}; + +typedef enum { + E1000_FC_NONE = 0, + E1000_FC_RX_PAUSE = 1, + E1000_FC_TX_PAUSE = 2, + E1000_FC_FULL = 3, + E1000_FC_DEFAULT = 255, +} e1000_fc_type; + +struct e1000_shadow_ram { + u16 eeprom_word; + bool modified; +}; + +typedef enum { + e1000_bus_type_unknown = 0, + e1000_bus_type_pci = 1, + e1000_bus_type_pcix = 2, + e1000_bus_type_reserved = 3, +} e1000_bus_type; + +typedef enum { + e1000_bus_speed_unknown = 0, + e1000_bus_speed_33 = 1, + e1000_bus_speed_66 = 2, + e1000_bus_speed_100 = 3, + e1000_bus_speed_120 = 4, + e1000_bus_speed_133 = 5, + e1000_bus_speed_reserved = 6, +} e1000_bus_speed; + +typedef enum { + e1000_bus_width_unknown = 0, + e1000_bus_width_32 = 1, + e1000_bus_width_64 = 2, + e1000_bus_width_reserved = 3, +} e1000_bus_width; + +typedef enum { + e1000_cable_length_50 = 0, + e1000_cable_length_50_80 = 1, + e1000_cable_length_80_110 = 2, + e1000_cable_length_110_140 = 3, + e1000_cable_length_140 = 4, + e1000_cable_length_undefined = 255, +} e1000_cable_length; + +typedef enum { + e1000_10bt_ext_dist_enable_normal = 0, + e1000_10bt_ext_dist_enable_lower = 1, + e1000_10bt_ext_dist_enable_undefined = 255, +} e1000_10bt_ext_dist_enable; + +typedef enum { + e1000_rev_polarity_normal = 0, + e1000_rev_polarity_reversed = 1, + e1000_rev_polarity_undefined = 255, +} e1000_rev_polarity; + +typedef enum { + e1000_downshift_normal = 0, + e1000_downshift_activated = 1, + e1000_downshift_undefined = 255, +} e1000_downshift; + +typedef enum { + e1000_smart_speed_default = 0, + e1000_smart_speed_on = 1, + e1000_smart_speed_off = 2, +} e1000_smart_speed; + +typedef enum { + e1000_polarity_reversal_enabled = 0, + e1000_polarity_reversal_disabled = 1, + e1000_polarity_reversal_undefined = 255, +} e1000_polarity_reversal; + +typedef enum { + e1000_auto_x_mode_manual_mdi = 0, + e1000_auto_x_mode_manual_mdix = 1, + e1000_auto_x_mode_auto1 = 2, + e1000_auto_x_mode_auto2 = 3, + e1000_auto_x_mode_undefined = 255, +} e1000_auto_x_mode; + +typedef enum { + e1000_1000t_rx_status_not_ok = 0, + e1000_1000t_rx_status_ok = 1, + e1000_1000t_rx_status_undefined = 255, +} e1000_1000t_rx_status; + +typedef enum { + e1000_phy_m88 = 0, + e1000_phy_igp = 1, + e1000_phy_8211 = 2, + e1000_phy_8201 = 3, + e1000_phy_undefined = 255, +} e1000_phy_type; + +typedef enum { + e1000_ms_hw_default = 0, + e1000_ms_force_master = 1, + e1000_ms_force_slave = 2, + e1000_ms_auto = 3, +} e1000_ms_type; + +typedef enum { + e1000_ffe_config_enabled = 0, + e1000_ffe_config_active = 1, + e1000_ffe_config_blocked = 2, +} e1000_ffe_config; + +typedef enum { + e1000_dsp_config_disabled = 0, + e1000_dsp_config_enabled = 1, + e1000_dsp_config_activated = 2, + e1000_dsp_config_undefined = 255, +} e1000_dsp_config; + +struct e1000_phy_info { + e1000_cable_length cable_length; + e1000_10bt_ext_dist_enable extended_10bt_distance; + e1000_rev_polarity cable_polarity; + e1000_downshift downshift; + e1000_polarity_reversal polarity_correction; + e1000_auto_x_mode mdix_mode; + e1000_1000t_rx_status local_rx; + e1000_1000t_rx_status remote_rx; +}; + +struct e1000_phy_stats { + u32 idle_errors; + u32 receive_errors; +}; + +struct e1000_eeprom_info { + e1000_eeprom_type type; + u16 word_size; + u16 opcode_bits; + u16 address_bits; + u16 delay_usec; + u16 page_size; +}; + +struct e1000_host_mng_dhcp_cookie { + u32 signature; + u8 status; + u8 reserved0; + u16 vlan_id; + u32 reserved1; + u16 reserved2; + u8 reserved3; + u8 checksum; +}; + +struct e1000_rx_desc { + __le64 buffer_addr; + __le16 length; + __le16 csum; + u8 status; + u8 errors; + __le16 special; +}; + +struct e1000_tx_desc { + __le64 buffer_addr; + union { + __le32 data; + struct { + __le16 length; + u8 cso; + u8 cmd; + } flags; + } lower; + union { + __le32 data; + struct { + u8 status; + u8 css; + __le16 special; + } fields; + } upper; +}; + +struct e1000_context_desc { + union { + __le32 ip_config; + struct { + u8 ipcss; + u8 ipcso; + __le16 ipcse; + } ip_fields; + } lower_setup; + union { + __le32 tcp_config; + struct { + u8 tucss; + u8 tucso; + __le16 tucse; + } tcp_fields; + } upper_setup; + __le32 cmd_and_length; + union { + __le32 data; + struct { + u8 status; + u8 hdr_len; + __le16 mss; + } fields; + } tcp_seg_setup; +}; + +struct e1000_hw_stats { + u64 crcerrs; + u64 algnerrc; + u64 symerrs; + u64 rxerrc; + u64 txerrc; + u64 mpc; + u64 scc; + u64 ecol; + u64 mcc; + u64 latecol; + u64 colc; + u64 dc; + u64 tncrs; + u64 sec; + u64 cexterr; + u64 rlec; + u64 xonrxc; + u64 xontxc; + u64 xoffrxc; + u64 xofftxc; + u64 fcruc; + u64 prc64; + u64 prc127; + u64 prc255; + u64 prc511; + u64 prc1023; + u64 prc1522; + u64 gprc; + u64 bprc; + u64 mprc; + u64 gptc; + u64 gorcl; + u64 gorch; + u64 gotcl; + u64 gotch; + u64 rnbc; + u64 ruc; + u64 rfc; + u64 roc; + u64 rlerrc; + u64 rjc; + u64 mgprc; + u64 mgpdc; + u64 mgptc; + u64 torl; + u64 torh; + u64 totl; + u64 toth; + u64 tpr; + u64 tpt; + u64 ptc64; + u64 ptc127; + u64 ptc255; + u64 ptc511; + u64 ptc1023; + u64 ptc1522; + u64 mptc; + u64 bptc; + u64 tsctc; + u64 tsctfc; + u64 iac; + u64 icrxptc; + u64 icrxatc; + u64 ictxptc; + u64 ictxatc; + u64 ictxqec; + u64 ictxqmtc; + u64 icrxdmtc; + u64 icrxoc; +}; + +struct e1000_hw { + u8 *hw_addr; + u8 *flash_address; + void *ce4100_gbe_mdio_base_virt; + e1000_mac_type mac_type; + e1000_phy_type phy_type; + u32 phy_init_script; + e1000_media_type media_type; + void *back; + struct e1000_shadow_ram *eeprom_shadow_ram; + u32 flash_bank_size; + u32 flash_base_addr; + e1000_fc_type fc; + e1000_bus_speed bus_speed; + e1000_bus_width bus_width; + e1000_bus_type bus_type; + struct e1000_eeprom_info eeprom; + e1000_ms_type master_slave; + e1000_ms_type original_master_slave; + e1000_ffe_config ffe_config_state; + u32 asf_firmware_present; + u32 eeprom_semaphore_present; + long unsigned int io_base; + u32 phy_id; + u32 phy_revision; + u32 phy_addr; + u32 original_fc; + u32 txcw; + u32 autoneg_failed; + u32 max_frame_size; + u32 min_frame_size; + u32 mc_filter_type; + u32 num_mc_addrs; + u32 collision_delta; + u32 tx_packet_delta; + u32 ledctl_default; + u32 ledctl_mode1; + u32 ledctl_mode2; + bool tx_pkt_filtering; + struct e1000_host_mng_dhcp_cookie mng_cookie; + u16 phy_spd_default; + u16 autoneg_advertised; + u16 pci_cmd_word; + u16 fc_high_water; + u16 fc_low_water; + u16 fc_pause_time; + u16 current_ifs_val; + u16 ifs_min_val; + u16 ifs_max_val; + u16 ifs_step_size; + u16 ifs_ratio; + u16 device_id; + u16 vendor_id; + u16 subsystem_id; + u16 subsystem_vendor_id; + u8 revision_id; + u8 autoneg; + u8 mdix; + u8 forced_speed_duplex; + u8 wait_autoneg_complete; + u8 dma_fairness; + u8 mac_addr[6]; + u8 perm_mac_addr[6]; + bool disable_polarity_correction; + bool speed_downgraded; + e1000_smart_speed smart_speed; + e1000_dsp_config dsp_config_state; + bool get_link_status; + bool serdes_has_link; + bool tbi_compatibility_en; + bool tbi_compatibility_on; + bool laa_is_present; + bool phy_reset_disable; + bool initialize_hw_bits_disable; + bool fc_send_xon; + bool fc_strict_ieee; + bool report_tx_early; + bool adaptive_ifs; + bool ifs_params_forced; + bool in_ifs_mode; + bool mng_reg_access_disabled; + bool leave_av_bit_off; + bool bad_tx_carr_stats_fd; + bool has_smbus; +}; + +struct e1000_tx_buffer { + struct sk_buff *skb; + dma_addr_t dma; + long unsigned int time_stamp; + u16 length; + u16 next_to_watch; + bool mapped_as_page; + short unsigned int segs; + unsigned int bytecount; +}; + +struct e1000_rx_buffer { + union { + struct page *page; + u8 *data; + } rxbuf; + dma_addr_t dma; +}; + +struct e1000_tx_ring { + void *desc; + dma_addr_t dma; + unsigned int size; + unsigned int count; + unsigned int next_to_use; + unsigned int next_to_clean; + struct e1000_tx_buffer *buffer_info; + u16 tdh; + u16 tdt; + bool last_tx_tso; +}; + +struct e1000_rx_ring { + void *desc; + dma_addr_t dma; + unsigned int size; + unsigned int count; + unsigned int next_to_use; + unsigned int next_to_clean; + struct e1000_rx_buffer *buffer_info; + struct sk_buff *rx_skb_top; + int cpu; + u16 rdh; + u16 rdt; +}; + +struct e1000_adapter { + long unsigned int active_vlans[64]; + u16 mng_vlan_id; + u32 bd_number; + u32 rx_buffer_len; + u32 wol; + u32 smartspeed; + u32 en_mng_pt; + u16 link_speed; + u16 link_duplex; + spinlock_t stats_lock; + unsigned int total_tx_bytes; + unsigned int total_tx_packets; + unsigned int total_rx_bytes; + unsigned int total_rx_packets; + u32 itr; + u32 itr_setting; + u16 tx_itr; + u16 rx_itr; + u8 fc_autoneg; + struct e1000_tx_ring *tx_ring; + unsigned int restart_queue; + u32 txd_cmd; + u32 tx_int_delay; + u32 tx_abs_int_delay; + u32 gotcl; + u64 gotcl_old; + u64 tpt_old; + u64 colc_old; + u32 tx_timeout_count; + u32 tx_fifo_head; + u32 tx_head_addr; + u32 tx_fifo_size; + u8 tx_timeout_factor; + atomic_t tx_fifo_stall; + bool pcix_82544; + bool detect_tx_hung; + bool dump_buffers; + bool (*clean_rx)(struct e1000_adapter *, struct e1000_rx_ring *, int *, int); + void (*alloc_rx_buf)(struct e1000_adapter *, struct e1000_rx_ring *, int); + struct e1000_rx_ring *rx_ring; + struct napi_struct napi; + int num_tx_queues; + int num_rx_queues; + u64 hw_csum_err; + u64 hw_csum_good; + u32 alloc_rx_buff_failed; + u32 rx_int_delay; + u32 rx_abs_int_delay; + bool rx_csum; + u32 gorcl; + u64 gorcl_old; + struct net_device *netdev; + struct pci_dev *pdev; + struct e1000_hw hw; + struct e1000_hw_stats stats; + struct e1000_phy_info phy_info; + struct e1000_phy_stats phy_stats; + u32 test_icr; + struct e1000_tx_ring test_tx_ring; + struct e1000_rx_ring test_rx_ring; + int msg_enable; + bool tso_force; + bool smart_power_down; + bool quad_port_a; + long unsigned int flags; + u32 eeprom_wol; + int bars; + int need_ioport; + bool discarding; + struct work_struct reset_task; + struct delayed_work watchdog_task; + struct delayed_work fifo_stall_task; + struct delayed_work phy_info_task; +}; + +enum e1000_state_t { + __E1000_TESTING = 0, + __E1000_RESETTING = 1, + __E1000_DOWN = 2, + __E1000_DISABLED = 3, +}; + +enum latency_range { + lowest_latency = 0, + low_latency = 1, + bulk_latency = 2, + latency_invalid = 255, +}; + +struct my_u { + __le64 a; + __le64 b; +}; + +enum { + e1000_igp_cable_length_10 = 10, + e1000_igp_cable_length_20 = 20, + e1000_igp_cable_length_30 = 30, + e1000_igp_cable_length_40 = 40, + e1000_igp_cable_length_50 = 50, + e1000_igp_cable_length_60 = 60, + e1000_igp_cable_length_70 = 70, + e1000_igp_cable_length_80 = 80, + e1000_igp_cable_length_90 = 90, + e1000_igp_cable_length_100 = 100, + e1000_igp_cable_length_110 = 110, + e1000_igp_cable_length_115 = 115, + e1000_igp_cable_length_120 = 120, + e1000_igp_cable_length_130 = 130, + e1000_igp_cable_length_140 = 140, + e1000_igp_cable_length_150 = 150, + e1000_igp_cable_length_160 = 160, + e1000_igp_cable_length_170 = 170, + e1000_igp_cable_length_180 = 180, +}; + +enum ethtool_test_flags { + ETH_TEST_FL_OFFLINE = 1, + ETH_TEST_FL_FAILED = 2, + ETH_TEST_FL_EXTERNAL_LB = 4, + ETH_TEST_FL_EXTERNAL_LB_DONE = 8, +}; + +enum { + NETDEV_STATS = 0, + E1000_STATS = 1, +}; + +struct e1000_stats { + char stat_string[32]; + int type; + int sizeof_stat; + int stat_offset; +}; + +struct e1000_opt_list { + int i; + char *str; +}; + +struct e1000_option { + enum { + enable_option = 0, + range_option = 1, + list_option = 2, + } type; + const char *name; + const char *err; + int def; + union { + struct { + int min; + int max; + } r; + struct { + int nr; + const struct e1000_opt_list *p; + } l; + } arg; +}; + +enum pkt_hash_types { + PKT_HASH_TYPE_NONE = 0, + PKT_HASH_TYPE_L2 = 1, + PKT_HASH_TYPE_L3 = 2, + PKT_HASH_TYPE_L4 = 3, +}; + +enum macvlan_mode { + MACVLAN_MODE_PRIVATE = 1, + MACVLAN_MODE_VEPA = 2, + MACVLAN_MODE_BRIDGE = 4, + MACVLAN_MODE_PASSTHRU = 8, + MACVLAN_MODE_SOURCE = 16, +}; + +enum { + TC_MQPRIO_HW_OFFLOAD_NONE = 0, + TC_MQPRIO_HW_OFFLOAD_TCS = 1, + __TC_MQPRIO_HW_OFFLOAD_MAX = 2, +}; + +struct tc_mqprio_qopt { + __u8 num_tc; + __u8 prio_tc_map[16]; + __u8 hw; + __u16 count[16]; + __u16 offset[16]; +}; + +enum tca_id { + TCA_ID_UNSPEC = 0, + TCA_ID_POLICE = 1, + TCA_ID_GACT = 5, + TCA_ID_IPT = 6, + TCA_ID_PEDIT = 7, + TCA_ID_MIRRED = 8, + TCA_ID_NAT = 9, + TCA_ID_XT = 10, + TCA_ID_SKBEDIT = 11, + TCA_ID_VLAN = 12, + TCA_ID_BPF = 13, + TCA_ID_CONNMARK = 14, + TCA_ID_SKBMOD = 15, + TCA_ID_CSUM = 16, + TCA_ID_TUNNEL_KEY = 17, + TCA_ID_SIMP = 22, + TCA_ID_IFE = 25, + TCA_ID_SAMPLE = 26, + TCA_ID_CTINFO = 27, + TCA_ID_MPLS = 28, + TCA_ID_CT = 29, + TCA_ID_GATE = 30, + __TCA_ID_MAX = 255, +}; + +struct tcf_t { + __u64 install; + __u64 lastuse; + __u64 expires; + __u64 firstuse; +}; + +struct tc_u32_key { + __be32 mask; + __be32 val; + int off; + int offmask; +}; + +struct tc_u32_sel { + unsigned char flags; + unsigned char offshift; + unsigned char nkeys; + __be16 offmask; + __u16 off; + short int offoff; + short int hoff; + __be32 hmask; + struct tc_u32_key keys[0]; +}; + +struct xdp_umem; + +struct xsk_queue; + +struct xdp_buff_xsk; + +struct xsk_buff_pool { + struct device *dev; + struct net_device *netdev; + struct list_head xsk_tx_list; + spinlock_t xsk_tx_list_lock; + refcount_t users; + struct xdp_umem *umem; + struct work_struct work; + struct list_head free_list; + u32 heads_cnt; + u16 queue_id; + struct xsk_queue *fq; + struct xsk_queue *cq; + dma_addr_t *dma_pages; + struct xdp_buff_xsk *heads; + u64 chunk_mask; + u64 addrs_cnt; + u32 free_list_cnt; + u32 dma_pages_cnt; + u32 free_heads_cnt; + u32 headroom; + u32 chunk_size; + u32 frame_len; + u8 cached_need_wakeup; + bool uses_need_wakeup; + bool dma_need_sync; + bool unaligned; + void *addrs; + struct xdp_buff_xsk *free_heads[0]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct netdev_nested_priv { + unsigned char flags; + void *data; +}; + +struct vlan_ethhdr { + unsigned char h_dest[6]; + unsigned char h_source[6]; + __be16 h_vlan_proto; + __be16 h_vlan_TCI; + __be16 h_vlan_encapsulated_proto; +}; + +struct vlan_pcpu_stats { + u64 rx_packets; + u64 rx_bytes; + u64 rx_multicast; + u64 tx_packets; + u64 tx_bytes; + struct u64_stats_sync syncp; + u32 rx_errors; + u32 tx_dropped; +}; + +struct flow_cls_common_offload { + u32 chain_index; + __be16 protocol; + u32 prio; + struct netlink_ext_ack *extack; +}; + +struct tcf_walker { + int stop; + int skip; + int count; + bool nonempty; + long unsigned int cookie; + int (*fn)(struct tcf_proto *, void *, struct tcf_walker *); +}; + +struct hwtstamp_config { + int flags; + int tx_type; + int rx_filter; +}; + +enum hwtstamp_tx_types { + HWTSTAMP_TX_OFF = 0, + HWTSTAMP_TX_ON = 1, + HWTSTAMP_TX_ONESTEP_SYNC = 2, + HWTSTAMP_TX_ONESTEP_P2P = 3, + __HWTSTAMP_TX_CNT = 4, +}; + +struct macvlan_port; + +struct netpoll; + +struct macvlan_dev { + struct net_device *dev; + struct list_head list; + struct hlist_node hlist; + struct macvlan_port *port; + struct net_device *lowerdev; + void *accel_priv; + struct vlan_pcpu_stats *pcpu_stats; + long unsigned int mc_filter[4]; + netdev_features_t set_features; + enum macvlan_mode mode; + u16 flags; + unsigned int macaddr_count; + struct netpoll *netpoll; +}; + +enum { + IFLA_BRIDGE_FLAGS = 0, + IFLA_BRIDGE_MODE = 1, + IFLA_BRIDGE_VLAN_INFO = 2, + IFLA_BRIDGE_VLAN_TUNNEL_INFO = 3, + IFLA_BRIDGE_MRP = 4, + IFLA_BRIDGE_CFM = 5, + __IFLA_BRIDGE_MAX = 6, +}; + +enum { + BR_MCAST_DIR_RX = 0, + BR_MCAST_DIR_TX = 1, + BR_MCAST_DIR_SIZE = 2, +}; + +enum udp_tunnel_nic_info_flags { + UDP_TUNNEL_NIC_INFO_MAY_SLEEP = 1, + UDP_TUNNEL_NIC_INFO_OPEN_ONLY = 2, + UDP_TUNNEL_NIC_INFO_IPV4_ONLY = 4, + UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN = 8, +}; + +struct udp_tunnel_nic_ops { + void (*get_port)(struct net_device *, unsigned int, unsigned int, struct udp_tunnel_info *); + void (*set_port_priv)(struct net_device *, unsigned int, unsigned int, u8); + void (*add_port)(struct net_device *, struct udp_tunnel_info *); + void (*del_port)(struct net_device *, struct udp_tunnel_info *); + void (*reset_ntf)(struct net_device *); + size_t (*dump_size)(struct net_device *, unsigned int); + int (*dump_write)(struct net_device *, unsigned int, struct sk_buff *); +}; + +struct tcf_idrinfo { + struct mutex lock; + struct idr action_idr; + struct net *net; +}; + +struct tc_action_ops; + +struct tc_cookie; + +struct tc_action { + const struct tc_action_ops *ops; + __u32 type; + struct tcf_idrinfo *idrinfo; + u32 tcfa_index; + refcount_t tcfa_refcnt; + atomic_t tcfa_bindcnt; + int tcfa_action; + struct tcf_t tcfa_tm; + struct gnet_stats_basic_packed tcfa_bstats; + struct gnet_stats_basic_packed tcfa_bstats_hw; + struct gnet_stats_queue tcfa_qstats; + struct net_rate_estimator *tcfa_rate_est; + spinlock_t tcfa_lock; + struct gnet_stats_basic_cpu *cpu_bstats; + struct gnet_stats_basic_cpu *cpu_bstats_hw; + struct gnet_stats_queue *cpu_qstats; + struct tc_cookie *act_cookie; + struct tcf_chain *goto_chain; + u32 tcfa_flags; + u8 hw_stats; + u8 used_hw_stats; + bool used_hw_stats_valid; +}; + +typedef void (*tc_action_priv_destructor)(void *); + +struct psample_group; + +struct tc_action_ops { + struct list_head head; + char kind[16]; + enum tca_id id; + size_t size; + struct module *owner; + int (*act)(struct sk_buff *, const struct tc_action *, struct tcf_result *); + int (*dump)(struct sk_buff *, struct tc_action *, int, int); + void (*cleanup)(struct tc_action *); + int (*lookup)(struct net *, struct tc_action **, u32); + int (*init)(struct net *, struct nlattr *, struct nlattr *, struct tc_action **, int, int, bool, struct tcf_proto *, u32, struct netlink_ext_ack *); + int (*walk)(struct net *, struct sk_buff *, struct netlink_callback *, int, const struct tc_action_ops *, struct netlink_ext_ack *); + void (*stats_update)(struct tc_action *, u64, u64, u64, u64, bool); + size_t (*get_fill_size)(const struct tc_action *); + struct net_device * (*get_dev)(const struct tc_action *, tc_action_priv_destructor *); + struct psample_group * (*get_psample_group)(const struct tc_action *, tc_action_priv_destructor *); +}; + +struct tc_cookie { + u8 *data; + u32 len; + struct callback_head rcu; +}; + +struct tcf_exts { + __u32 type; + int nr_actions; + struct tc_action **actions; + struct net *net; + int action; + int police; +}; + +struct tc_cls_u32_knode { + struct tcf_exts *exts; + struct tcf_result *res; + struct tc_u32_sel *sel; + u32 handle; + u32 val; + u32 mask; + u32 link_handle; + u8 fshift; +}; + +struct tc_cls_u32_hnode { + u32 handle; + u32 prio; + unsigned int divisor; +}; + +enum tc_clsu32_command { + TC_CLSU32_NEW_KNODE = 0, + TC_CLSU32_REPLACE_KNODE = 1, + TC_CLSU32_DELETE_KNODE = 2, + TC_CLSU32_NEW_HNODE = 3, + TC_CLSU32_REPLACE_HNODE = 4, + TC_CLSU32_DELETE_HNODE = 5, +}; + +struct tc_cls_u32_offload { + struct flow_cls_common_offload common; + enum tc_clsu32_command command; + union { + struct tc_cls_u32_knode knode; + struct tc_cls_u32_hnode hnode; + }; +}; + +struct tcf_gact { + struct tc_action common; + u16 tcfg_ptype; + u16 tcfg_pval; + int tcfg_paction; + atomic_t packets; +}; + +struct tcf_mirred { + struct tc_action common; + int tcfm_eaction; + bool tcfm_mac_header_xmit; + struct net_device *tcfm_dev; + struct list_head tcfm_list; +}; + +struct xdp_umem { + void *addrs; + u64 size; + u32 headroom; + u32 chunk_size; + u32 chunks; + u32 npgs; + struct user_struct *user; + refcount_t users; + u8 flags; + bool zc; + struct page **pgs; + int id; + struct list_head xsk_dma_list; +}; + +struct xdp_buff_xsk { + struct xdp_buff xdp; + dma_addr_t dma; + dma_addr_t frame_dma; + struct xsk_buff_pool *pool; + bool unaligned; + u64 orig_addr; + struct list_head free_list_node; +}; + +struct ptp_clock_time { + __s64 sec; + __u32 nsec; + __u32 reserved; +}; + +struct ptp_extts_request { + unsigned int index; + unsigned int flags; + unsigned int rsv[2]; +}; + +struct ptp_perout_request { + union { + struct ptp_clock_time start; + struct ptp_clock_time phase; + }; + struct ptp_clock_time period; + unsigned int index; + unsigned int flags; + union { + struct ptp_clock_time on; + unsigned int rsv[4]; + }; +}; + +enum ptp_pin_function { + PTP_PF_NONE = 0, + PTP_PF_EXTTS = 1, + PTP_PF_PEROUT = 2, + PTP_PF_PHYSYNC = 3, +}; + +struct ptp_pin_desc { + char name[64]; + unsigned int index; + unsigned int func; + unsigned int chan; + unsigned int rsv[5]; +}; + +struct ptp_clock_request { + enum { + PTP_CLK_REQ_EXTTS = 0, + PTP_CLK_REQ_PEROUT = 1, + PTP_CLK_REQ_PPS = 2, + } type; + union { + struct ptp_extts_request extts; + struct ptp_perout_request perout; + }; +}; + +struct ptp_system_timestamp { + struct timespec64 pre_ts; + struct timespec64 post_ts; +}; + +struct ptp_clock_info { + struct module *owner; + char name[16]; + s32 max_adj; + int n_alarm; + int n_ext_ts; + int n_per_out; + int n_pins; + int pps; + struct ptp_pin_desc *pin_config; + int (*adjfine)(struct ptp_clock_info *, long int); + int (*adjfreq)(struct ptp_clock_info *, s32); + int (*adjphase)(struct ptp_clock_info *, s32); + int (*adjtime)(struct ptp_clock_info *, s64); + int (*gettime64)(struct ptp_clock_info *, struct timespec64 *); + int (*gettimex64)(struct ptp_clock_info *, struct timespec64 *, struct ptp_system_timestamp *); + int (*getcrosststamp)(struct ptp_clock_info *, struct system_device_crosststamp *); + int (*settime64)(struct ptp_clock_info *, const struct timespec64 *); + int (*enable)(struct ptp_clock_info *, struct ptp_clock_request *, int); + int (*verify)(struct ptp_clock_info *, unsigned int, enum ptp_pin_function, unsigned int); + long int (*do_aux_work)(struct ptp_clock_info *); +}; + +struct ixgbe_thermal_diode_data { + u8 location; + u8 temp; + u8 caution_thresh; + u8 max_op_thresh; +}; + +struct ixgbe_thermal_sensor_data { + struct ixgbe_thermal_diode_data sensor[3]; +}; + +struct ixgbe_nvm_version { + u32 etk_id; + u8 nvm_major; + u16 nvm_minor; + u8 nvm_id; + bool oem_valid; + u8 oem_major; + u8 oem_minor; + u16 oem_release; + bool or_valid; + u8 or_major; + u16 or_build; + u8 or_patch; +}; + +enum { + PBA_STRATEGY_EQUAL = 0, + PBA_STRATEGY_WEIGHTED = 1, +}; + +enum ixgbe_fdir_pballoc_type { + IXGBE_FDIR_PBALLOC_NONE = 0, + IXGBE_FDIR_PBALLOC_64K = 1, + IXGBE_FDIR_PBALLOC_128K = 2, + IXGBE_FDIR_PBALLOC_256K = 3, +}; + +union ixgbe_adv_tx_desc { + struct { + __le64 buffer_addr; + __le32 cmd_type_len; + __le32 olinfo_status; + } read; + struct { + __le64 rsvd; + __le32 nxtseq_seed; + __le32 status; + } wb; +}; + +union ixgbe_adv_rx_desc { + struct { + __le64 pkt_addr; + __le64 hdr_addr; + } read; + struct { + struct { + union { + __le32 data; + struct { + __le16 pkt_info; + __le16 hdr_info; + } hs_rss; + } lo_dword; + union { + __le32 rss; + struct { + __le16 ip_id; + __le16 csum; + } csum_ip; + } hi_dword; + } lower; + struct { + __le32 status_error; + __le16 length; + __le16 vlan; + } upper; + } wb; +}; + +typedef u32 ixgbe_autoneg_advertised; + +typedef u32 ixgbe_link_speed; + +enum ixgbe_atr_flow_type { + IXGBE_ATR_FLOW_TYPE_IPV4 = 0, + IXGBE_ATR_FLOW_TYPE_UDPV4 = 1, + IXGBE_ATR_FLOW_TYPE_TCPV4 = 2, + IXGBE_ATR_FLOW_TYPE_SCTPV4 = 3, + IXGBE_ATR_FLOW_TYPE_IPV6 = 4, + IXGBE_ATR_FLOW_TYPE_UDPV6 = 5, + IXGBE_ATR_FLOW_TYPE_TCPV6 = 6, + IXGBE_ATR_FLOW_TYPE_SCTPV6 = 7, +}; + +union ixgbe_atr_input { + struct { + u8 vm_pool; + u8 flow_type; + __be16 vlan_id; + __be32 dst_ip[4]; + __be32 src_ip[4]; + __be16 src_port; + __be16 dst_port; + __be16 flex_bytes; + __be16 bkt_hash; + } formatted; + __be32 dword_stream[11]; +}; + +union ixgbe_atr_hash_dword { + struct { + u8 vm_pool; + u8 flow_type; + __be16 vlan_id; + } formatted; + __be32 ip; + struct { + __be16 src; + __be16 dst; + } port; + __be16 flex_bytes; + __be32 dword; +}; + +enum ixgbe_mvals { + IXGBE_EEC_IDX = 0, + IXGBE_FLA_IDX = 1, + IXGBE_GRC_IDX = 2, + IXGBE_FACTPS_IDX = 3, + IXGBE_SWSM_IDX = 4, + IXGBE_SWFW_SYNC_IDX = 5, + IXGBE_FWSM_IDX = 6, + IXGBE_SDP0_GPIEN_IDX = 7, + IXGBE_SDP1_GPIEN_IDX = 8, + IXGBE_SDP2_GPIEN_IDX = 9, + IXGBE_EICR_GPI_SDP0_IDX = 10, + IXGBE_EICR_GPI_SDP1_IDX = 11, + IXGBE_EICR_GPI_SDP2_IDX = 12, + IXGBE_CIAA_IDX = 13, + IXGBE_CIAD_IDX = 14, + IXGBE_I2C_CLK_IN_IDX = 15, + IXGBE_I2C_CLK_OUT_IDX = 16, + IXGBE_I2C_DATA_IN_IDX = 17, + IXGBE_I2C_DATA_OUT_IDX = 18, + IXGBE_I2C_DATA_OE_N_EN_IDX = 19, + IXGBE_I2C_BB_EN_IDX = 20, + IXGBE_I2C_CLK_OE_N_EN_IDX = 21, + IXGBE_I2CCTL_IDX = 22, + IXGBE_MVALS_IDX_LIMIT = 23, +}; + +enum ixgbe_eeprom_type { + ixgbe_eeprom_uninitialized = 0, + ixgbe_eeprom_spi = 1, + ixgbe_flash = 2, + ixgbe_eeprom_none = 3, +}; + +enum ixgbe_mac_type { + ixgbe_mac_unknown = 0, + ixgbe_mac_82598EB = 1, + ixgbe_mac_82599EB = 2, + ixgbe_mac_X540 = 3, + ixgbe_mac_X550 = 4, + ixgbe_mac_X550EM_x = 5, + ixgbe_mac_x550em_a = 6, + ixgbe_num_macs = 7, +}; + +enum ixgbe_phy_type { + ixgbe_phy_unknown = 0, + ixgbe_phy_none = 1, + ixgbe_phy_tn = 2, + ixgbe_phy_aq = 3, + ixgbe_phy_x550em_kr = 4, + ixgbe_phy_x550em_kx4 = 5, + ixgbe_phy_x550em_xfi = 6, + ixgbe_phy_x550em_ext_t = 7, + ixgbe_phy_ext_1g_t = 8, + ixgbe_phy_cu_unknown = 9, + ixgbe_phy_qt = 10, + ixgbe_phy_xaui = 11, + ixgbe_phy_nl = 12, + ixgbe_phy_sfp_passive_tyco = 13, + ixgbe_phy_sfp_passive_unknown = 14, + ixgbe_phy_sfp_active_unknown = 15, + ixgbe_phy_sfp_avago = 16, + ixgbe_phy_sfp_ftl = 17, + ixgbe_phy_sfp_ftl_active = 18, + ixgbe_phy_sfp_unknown = 19, + ixgbe_phy_sfp_intel = 20, + ixgbe_phy_qsfp_passive_unknown = 21, + ixgbe_phy_qsfp_active_unknown = 22, + ixgbe_phy_qsfp_intel = 23, + ixgbe_phy_qsfp_unknown = 24, + ixgbe_phy_sfp_unsupported = 25, + ixgbe_phy_sgmii = 26, + ixgbe_phy_fw = 27, + ixgbe_phy_generic = 28, +}; + +enum ixgbe_sfp_type { + ixgbe_sfp_type_da_cu = 0, + ixgbe_sfp_type_sr = 1, + ixgbe_sfp_type_lr = 2, + ixgbe_sfp_type_da_cu_core0 = 3, + ixgbe_sfp_type_da_cu_core1 = 4, + ixgbe_sfp_type_srlr_core0 = 5, + ixgbe_sfp_type_srlr_core1 = 6, + ixgbe_sfp_type_da_act_lmt_core0 = 7, + ixgbe_sfp_type_da_act_lmt_core1 = 8, + ixgbe_sfp_type_1g_cu_core0 = 9, + ixgbe_sfp_type_1g_cu_core1 = 10, + ixgbe_sfp_type_1g_sx_core0 = 11, + ixgbe_sfp_type_1g_sx_core1 = 12, + ixgbe_sfp_type_1g_lx_core0 = 13, + ixgbe_sfp_type_1g_lx_core1 = 14, + ixgbe_sfp_type_not_present = 65534, + ixgbe_sfp_type_unknown = 65535, +}; + +enum ixgbe_media_type { + ixgbe_media_type_unknown = 0, + ixgbe_media_type_fiber = 1, + ixgbe_media_type_fiber_qsfp = 2, + ixgbe_media_type_fiber_lco = 3, + ixgbe_media_type_copper = 4, + ixgbe_media_type_backplane = 5, + ixgbe_media_type_cx4 = 6, + ixgbe_media_type_virtual = 7, +}; + +enum ixgbe_fc_mode { + ixgbe_fc_none = 0, + ixgbe_fc_rx_pause = 1, + ixgbe_fc_tx_pause = 2, + ixgbe_fc_full = 3, + ixgbe_fc_default = 4, +}; + +enum ixgbe_smart_speed { + ixgbe_smart_speed_auto = 0, + ixgbe_smart_speed_on = 1, + ixgbe_smart_speed_off = 2, +}; + +enum ixgbe_bus_type { + ixgbe_bus_type_unknown = 0, + ixgbe_bus_type_pci_express = 1, + ixgbe_bus_type_internal = 2, + ixgbe_bus_type_reserved = 3, +}; + +enum ixgbe_bus_speed { + ixgbe_bus_speed_unknown = 0, + ixgbe_bus_speed_33 = 33, + ixgbe_bus_speed_66 = 66, + ixgbe_bus_speed_100 = 100, + ixgbe_bus_speed_120 = 120, + ixgbe_bus_speed_133 = 133, + ixgbe_bus_speed_2500 = 2500, + ixgbe_bus_speed_5000 = 5000, + ixgbe_bus_speed_8000 = 8000, + ixgbe_bus_speed_reserved = 8001, +}; + +enum ixgbe_bus_width { + ixgbe_bus_width_unknown = 0, + ixgbe_bus_width_pcie_x1 = 1, + ixgbe_bus_width_pcie_x2 = 2, + ixgbe_bus_width_pcie_x4 = 4, + ixgbe_bus_width_pcie_x8 = 8, + ixgbe_bus_width_32 = 32, + ixgbe_bus_width_64 = 64, + ixgbe_bus_width_reserved = 65, +}; + +struct ixgbe_addr_filter_info { + u32 num_mc_addrs; + u32 rar_used_count; + u32 mta_in_use; + u32 overflow_promisc; + bool uc_set_promisc; + bool user_set_promisc; +}; + +struct ixgbe_bus_info { + enum ixgbe_bus_speed speed; + enum ixgbe_bus_width width; + enum ixgbe_bus_type type; + u8 func; + u8 lan_id; + u8 instance_id; +}; + +struct ixgbe_fc_info { + u32 high_water[8]; + u32 low_water[8]; + u16 pause_time; + bool send_xon; + bool strict_ieee; + bool disable_fc_autoneg; + bool fc_was_autonegged; + enum ixgbe_fc_mode current_mode; + enum ixgbe_fc_mode requested_mode; +}; + +struct ixgbe_hw_stats { + u64 crcerrs; + u64 illerrc; + u64 errbc; + u64 mspdc; + u64 mpctotal; + u64 mpc[8]; + u64 mlfc; + u64 mrfc; + u64 rlec; + u64 lxontxc; + u64 lxonrxc; + u64 lxofftxc; + u64 lxoffrxc; + u64 pxontxc[8]; + u64 pxonrxc[8]; + u64 pxofftxc[8]; + u64 pxoffrxc[8]; + u64 prc64; + u64 prc127; + u64 prc255; + u64 prc511; + u64 prc1023; + u64 prc1522; + u64 gprc; + u64 bprc; + u64 mprc; + u64 gptc; + u64 gorc; + u64 gotc; + u64 rnbc[8]; + u64 ruc; + u64 rfc; + u64 roc; + u64 rjc; + u64 mngprc; + u64 mngpdc; + u64 mngptc; + u64 tor; + u64 tpr; + u64 tpt; + u64 ptc64; + u64 ptc127; + u64 ptc255; + u64 ptc511; + u64 ptc1023; + u64 ptc1522; + u64 mptc; + u64 bptc; + u64 xec; + u64 rqsmr[16]; + u64 tqsmr[8]; + u64 qprc[16]; + u64 qptc[16]; + u64 qbrc[16]; + u64 qbtc[16]; + u64 qprdc[16]; + u64 pxon2offc[8]; + u64 fdirustat_add; + u64 fdirustat_remove; + u64 fdirfstat_fadd; + u64 fdirfstat_fremove; + u64 fdirmatch; + u64 fdirmiss; + u64 fccrc; + u64 fcoerpdc; + u64 fcoeprc; + u64 fcoeptc; + u64 fcoedwrc; + u64 fcoedwtc; + u64 fcoe_noddp; + u64 fcoe_noddp_ext_buff; + u64 b2ospc; + u64 b2ogprc; + u64 o2bgptc; + u64 o2bspc; +}; + +struct ixgbe_hw; + +struct ixgbe_mac_operations { + s32 (*init_hw)(struct ixgbe_hw *); + s32 (*reset_hw)(struct ixgbe_hw *); + s32 (*start_hw)(struct ixgbe_hw *); + s32 (*clear_hw_cntrs)(struct ixgbe_hw *); + enum ixgbe_media_type (*get_media_type)(struct ixgbe_hw *); + s32 (*get_mac_addr)(struct ixgbe_hw *, u8 *); + s32 (*get_san_mac_addr)(struct ixgbe_hw *, u8 *); + s32 (*get_device_caps)(struct ixgbe_hw *, u16 *); + s32 (*get_wwn_prefix)(struct ixgbe_hw *, u16 *, u16 *); + s32 (*stop_adapter)(struct ixgbe_hw *); + s32 (*get_bus_info)(struct ixgbe_hw *); + void (*set_lan_id)(struct ixgbe_hw *); + s32 (*read_analog_reg8)(struct ixgbe_hw *, u32, u8 *); + s32 (*write_analog_reg8)(struct ixgbe_hw *, u32, u8); + s32 (*setup_sfp)(struct ixgbe_hw *); + s32 (*disable_rx_buff)(struct ixgbe_hw *); + s32 (*enable_rx_buff)(struct ixgbe_hw *); + s32 (*enable_rx_dma)(struct ixgbe_hw *, u32); + s32 (*acquire_swfw_sync)(struct ixgbe_hw *, u32); + void (*release_swfw_sync)(struct ixgbe_hw *, u32); + void (*init_swfw_sync)(struct ixgbe_hw *); + s32 (*prot_autoc_read)(struct ixgbe_hw *, bool *, u32 *); + s32 (*prot_autoc_write)(struct ixgbe_hw *, u32, bool); + void (*disable_tx_laser)(struct ixgbe_hw *); + void (*enable_tx_laser)(struct ixgbe_hw *); + void (*flap_tx_laser)(struct ixgbe_hw *); + void (*stop_link_on_d3)(struct ixgbe_hw *); + s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool); + s32 (*setup_mac_link)(struct ixgbe_hw *, ixgbe_link_speed, bool); + s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool); + s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *, bool *); + void (*set_rate_select_speed)(struct ixgbe_hw *, ixgbe_link_speed); + void (*set_rxpba)(struct ixgbe_hw *, int, u32, int); + s32 (*led_on)(struct ixgbe_hw *, u32); + s32 (*led_off)(struct ixgbe_hw *, u32); + s32 (*blink_led_start)(struct ixgbe_hw *, u32); + s32 (*blink_led_stop)(struct ixgbe_hw *, u32); + s32 (*init_led_link_act)(struct ixgbe_hw *); + s32 (*set_rar)(struct ixgbe_hw *, u32, u8 *, u32, u32); + s32 (*clear_rar)(struct ixgbe_hw *, u32); + s32 (*set_vmdq)(struct ixgbe_hw *, u32, u32); + s32 (*set_vmdq_san_mac)(struct ixgbe_hw *, u32); + s32 (*clear_vmdq)(struct ixgbe_hw *, u32, u32); + s32 (*init_rx_addrs)(struct ixgbe_hw *); + s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *); + s32 (*enable_mc)(struct ixgbe_hw *); + s32 (*disable_mc)(struct ixgbe_hw *); + s32 (*clear_vfta)(struct ixgbe_hw *); + s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool, bool); + s32 (*init_uta_tables)(struct ixgbe_hw *); + void (*set_mac_anti_spoofing)(struct ixgbe_hw *, bool, int); + void (*set_vlan_anti_spoofing)(struct ixgbe_hw *, bool, int); + s32 (*fc_enable)(struct ixgbe_hw *); + s32 (*setup_fc)(struct ixgbe_hw *); + void (*fc_autoneg)(struct ixgbe_hw *); + s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8, u16, const char *); + s32 (*get_thermal_sensor_data)(struct ixgbe_hw *); + s32 (*init_thermal_sensor_thresh)(struct ixgbe_hw *); + bool (*fw_recovery_mode)(struct ixgbe_hw *); + void (*disable_rx)(struct ixgbe_hw *); + void (*enable_rx)(struct ixgbe_hw *); + void (*set_source_address_pruning)(struct ixgbe_hw *, bool, unsigned int); + void (*set_ethertype_anti_spoofing)(struct ixgbe_hw *, bool, int); + s32 (*dmac_config)(struct ixgbe_hw *); + s32 (*dmac_update_tcs)(struct ixgbe_hw *); + s32 (*dmac_config_tcs)(struct ixgbe_hw *); + s32 (*read_iosf_sb_reg)(struct ixgbe_hw *, u32, u32, u32 *); + s32 (*write_iosf_sb_reg)(struct ixgbe_hw *, u32, u32, u32); +}; + +struct ixgbe_mac_info { + struct ixgbe_mac_operations ops; + enum ixgbe_mac_type type; + u8 addr[6]; + u8 perm_addr[6]; + u8 san_addr[6]; + u16 wwnn_prefix; + u16 wwpn_prefix; + u16 max_msix_vectors; + u32 mta_shadow[128]; + s32 mc_filter_type; + u32 mcft_size; + u32 vft_size; + u32 num_rar_entries; + u32 rar_highwater; + u32 rx_pb_size; + u32 max_tx_queues; + u32 max_rx_queues; + u32 orig_autoc; + u32 orig_autoc2; + bool orig_link_settings_stored; + bool autotry_restart; + u8 flags; + u8 san_mac_rar_index; + struct ixgbe_thermal_sensor_data thermal_sensor_data; + bool set_lben; + u8 led_link_act; +}; + +struct ixgbe_phy_operations { + s32 (*identify)(struct ixgbe_hw *); + s32 (*identify_sfp)(struct ixgbe_hw *); + s32 (*init)(struct ixgbe_hw *); + s32 (*reset)(struct ixgbe_hw *); + s32 (*read_reg)(struct ixgbe_hw *, u32, u32, u16 *); + s32 (*write_reg)(struct ixgbe_hw *, u32, u32, u16); + s32 (*read_reg_mdi)(struct ixgbe_hw *, u32, u32, u16 *); + s32 (*write_reg_mdi)(struct ixgbe_hw *, u32, u32, u16); + s32 (*setup_link)(struct ixgbe_hw *); + s32 (*setup_internal_link)(struct ixgbe_hw *); + s32 (*setup_link_speed)(struct ixgbe_hw *, ixgbe_link_speed, bool); + s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *); + s32 (*read_i2c_byte)(struct ixgbe_hw *, u8, u8, u8 *); + s32 (*write_i2c_byte)(struct ixgbe_hw *, u8, u8, u8); + s32 (*read_i2c_sff8472)(struct ixgbe_hw *, u8, u8 *); + s32 (*read_i2c_eeprom)(struct ixgbe_hw *, u8, u8 *); + s32 (*write_i2c_eeprom)(struct ixgbe_hw *, u8, u8); + s32 (*check_overtemp)(struct ixgbe_hw *); + s32 (*set_phy_power)(struct ixgbe_hw *, bool); + s32 (*enter_lplu)(struct ixgbe_hw *); + s32 (*handle_lasi)(struct ixgbe_hw *); + s32 (*read_i2c_byte_unlocked)(struct ixgbe_hw *, u8, u8, u8 *); + s32 (*write_i2c_byte_unlocked)(struct ixgbe_hw *, u8, u8, u8); +}; + +struct ixgbe_phy_info { + struct ixgbe_phy_operations ops; + struct mdio_if_info mdio; + enum ixgbe_phy_type type; + u32 id; + enum ixgbe_sfp_type sfp_type; + bool sfp_setup_needed; + u32 revision; + enum ixgbe_media_type media_type; + u32 phy_semaphore_mask; + bool reset_disable; + ixgbe_autoneg_advertised autoneg_advertised; + ixgbe_link_speed speeds_supported; + ixgbe_link_speed eee_speeds_supported; + ixgbe_link_speed eee_speeds_advertised; + enum ixgbe_smart_speed smart_speed; + bool smart_speed_active; + bool multispeed_fiber; + bool reset_if_overtemp; + bool qsfp_shared_i2c_bus; + u32 nw_mng_if_sel; +}; + +struct ixgbe_link_operations { + s32 (*read_link)(struct ixgbe_hw *, u8, u16, u16 *); + s32 (*read_link_unlocked)(struct ixgbe_hw *, u8, u16, u16 *); + s32 (*write_link)(struct ixgbe_hw *, u8, u16, u16); + s32 (*write_link_unlocked)(struct ixgbe_hw *, u8, u16, u16); +}; + +struct ixgbe_link_info { + struct ixgbe_link_operations ops; + u8 addr; +}; + +struct ixgbe_eeprom_operations { + s32 (*init_params)(struct ixgbe_hw *); + s32 (*read)(struct ixgbe_hw *, u16, u16 *); + s32 (*read_buffer)(struct ixgbe_hw *, u16, u16, u16 *); + s32 (*write)(struct ixgbe_hw *, u16, u16); + s32 (*write_buffer)(struct ixgbe_hw *, u16, u16, u16 *); + s32 (*validate_checksum)(struct ixgbe_hw *, u16 *); + s32 (*update_checksum)(struct ixgbe_hw *); + s32 (*calc_checksum)(struct ixgbe_hw *); +}; + +struct ixgbe_eeprom_info { + struct ixgbe_eeprom_operations ops; + enum ixgbe_eeprom_type type; + u32 semaphore_delay; + u16 word_size; + u16 address_bits; + u16 word_page_size; + u16 ctrl_word_3; +}; + +struct ixgbe_mbx_stats { + u32 msgs_tx; + u32 msgs_rx; + u32 acks; + u32 reqs; + u32 rsts; +}; + +struct ixgbe_mbx_operations; + +struct ixgbe_mbx_info { + const struct ixgbe_mbx_operations *ops; + struct ixgbe_mbx_stats stats; + u32 timeout; + u32 usec_delay; + u32 v2p_mailbox; + u16 size; +}; + +struct ixgbe_hw { + u8 *hw_addr; + void *back; + struct ixgbe_mac_info mac; + struct ixgbe_addr_filter_info addr_ctrl; + struct ixgbe_fc_info fc; + struct ixgbe_phy_info phy; + struct ixgbe_link_info link; + struct ixgbe_eeprom_info eeprom; + struct ixgbe_bus_info bus; + struct ixgbe_mbx_info mbx; + const u32 *mvals; + u16 device_id; + u16 vendor_id; + u16 subsystem_device_id; + u16 subsystem_vendor_id; + u8 revision_id; + bool adapter_stopped; + bool force_full_reset; + bool allow_unsupported_sfp; + bool wol_enabled; + bool need_crosstalk_fix; +}; + +struct ixgbe_mbx_operations { + s32 (*init_params)(struct ixgbe_hw *); + s32 (*read)(struct ixgbe_hw *, u32 *, u16, u16); + s32 (*write)(struct ixgbe_hw *, u32 *, u16, u16); + s32 (*read_posted)(struct ixgbe_hw *, u32 *, u16, u16); + s32 (*write_posted)(struct ixgbe_hw *, u32 *, u16, u16); + s32 (*check_for_msg)(struct ixgbe_hw *, u16); + s32 (*check_for_ack)(struct ixgbe_hw *, u16); + s32 (*check_for_rst)(struct ixgbe_hw *, u16); +}; + +struct ixgbe_info { + enum ixgbe_mac_type mac; + s32 (*get_invariants)(struct ixgbe_hw *); + const struct ixgbe_mac_operations *mac_ops; + const struct ixgbe_eeprom_operations *eeprom_ops; + const struct ixgbe_phy_operations *phy_ops; + const struct ixgbe_mbx_operations *mbx_ops; + const struct ixgbe_link_operations *link_ops; + const u32 *mvals; +}; + +enum strict_prio_type { + prio_none = 0, + prio_group = 1, + prio_link = 2, +}; + +struct dcb_support { + u32 capabilities; + u8 traffic_classes; + u8 pfc_traffic_classes; +}; + +struct tc_bw_alloc { + u8 bwg_id; + u8 bwg_percent; + u8 link_percent; + u8 up_to_tc_bitmap; + u16 data_credits_refill; + u16 data_credits_max; + enum strict_prio_type prio_type; +}; + +enum dcb_pfc_type { + pfc_disabled = 0, + pfc_enabled_full = 1, + pfc_enabled_tx = 2, + pfc_enabled_rx = 3, +}; + +struct tc_configuration { + struct tc_bw_alloc path[2]; + enum dcb_pfc_type dcb_pfc; + u16 desc_credits_max; + u8 tc; +}; + +struct dcb_num_tcs { + u8 pg_tcs; + u8 pfc_tcs; +}; + +struct ixgbe_dcb_config { + struct dcb_support support; + struct dcb_num_tcs num_tcs; + struct tc_configuration tc_config[8]; + u8 bw_percentage[16]; + bool pfc_mode_enable; + u32 dcb_cfg_version; + u32 link_speed; +}; + +struct ixgbe_ipsec_tx_data { + u32 flags; + u16 trailer_len; + u16 sa_idx; +}; + +enum ixgbe_tx_flags { + IXGBE_TX_FLAGS_HW_VLAN = 1, + IXGBE_TX_FLAGS_TSO = 2, + IXGBE_TX_FLAGS_TSTAMP = 4, + IXGBE_TX_FLAGS_CC = 8, + IXGBE_TX_FLAGS_IPV4 = 16, + IXGBE_TX_FLAGS_CSUM = 32, + IXGBE_TX_FLAGS_IPSEC = 64, + IXGBE_TX_FLAGS_SW_VLAN = 128, + IXGBE_TX_FLAGS_FCOE = 256, +}; + +struct vf_data_storage { + struct pci_dev *vfdev; + unsigned char vf_mac_addresses[6]; + u16 vf_mc_hashes[30]; + u16 num_vf_mc_hashes; + bool clear_to_send; + bool pf_set_mac; + u16 pf_vlan; + u16 pf_qos; + u16 tx_rate; + u8 spoofchk_enabled; + bool rss_query_enabled; + u8 trusted; + int xcast_mode; + unsigned int vf_api; +}; + +struct vf_macvlans { + struct list_head l; + int vf; + bool free; + bool is_macvlan; + u8 vf_macvlan[6]; +}; + +struct ixgbe_tx_buffer { + union ixgbe_adv_tx_desc *next_to_watch; + long unsigned int time_stamp; + union { + struct sk_buff *skb; + struct xdp_frame *xdpf; + }; + unsigned int bytecount; + short unsigned int gso_segs; + __be16 protocol; + dma_addr_t dma; + __u32 len; + u32 tx_flags; +}; + +struct ixgbe_rx_buffer { + union { + struct { + struct sk_buff *skb; + dma_addr_t dma; + struct page *page; + __u32 page_offset; + __u16 pagecnt_bias; + }; + struct { + bool discard; + struct xdp_buff *xdp; + }; + }; +}; + +struct ixgbe_queue_stats { + u64 packets; + u64 bytes; +}; + +struct ixgbe_tx_queue_stats { + u64 restart_queue; + u64 tx_busy; + u64 tx_done_old; +}; + +struct ixgbe_rx_queue_stats { + u64 rsc_count; + u64 rsc_flush; + u64 non_eop_descs; + u64 alloc_rx_page; + u64 alloc_rx_page_failed; + u64 alloc_rx_buff_failed; + u64 csum_err; +}; + +enum ixgbe_ring_state_t { + __IXGBE_RX_3K_BUFFER = 0, + __IXGBE_RX_BUILD_SKB_ENABLED = 1, + __IXGBE_RX_RSC_ENABLED = 2, + __IXGBE_RX_CSUM_UDP_ZERO_ERR = 3, + __IXGBE_RX_FCOE = 4, + __IXGBE_TX_FDIR_INIT_DONE = 5, + __IXGBE_TX_XPS_INIT_DONE = 6, + __IXGBE_TX_DETECT_HANG = 7, + __IXGBE_HANG_CHECK_ARMED = 8, + __IXGBE_TX_XDP_RING = 9, + __IXGBE_TX_DISABLED = 10, +}; + +struct ixgbe_fwd_adapter { + long unsigned int active_vlans[64]; + struct net_device *netdev; + unsigned int tx_base_queue; + unsigned int rx_base_queue; + int pool; +}; + +struct ixgbe_q_vector; + +struct ixgbe_ring { + struct ixgbe_ring *next; + struct ixgbe_q_vector *q_vector; + struct net_device *netdev; + struct bpf_prog *xdp_prog; + struct device *dev; + void *desc; + union { + struct ixgbe_tx_buffer *tx_buffer_info; + struct ixgbe_rx_buffer *rx_buffer_info; + }; + long unsigned int state; + u8 *tail; + dma_addr_t dma; + unsigned int size; + u16 count; + u8 queue_index; + u8 reg_idx; + u16 next_to_use; + u16 next_to_clean; + long unsigned int last_rx_timestamp; + union { + u16 next_to_alloc; + struct { + u8 atr_sample_rate; + u8 atr_count; + }; + }; + u8 dcb_tc; + struct ixgbe_queue_stats stats; + struct u64_stats_sync syncp; + union { + struct ixgbe_tx_queue_stats tx_stats; + struct ixgbe_rx_queue_stats rx_stats; + }; + long: 64; + struct xdp_rxq_info xdp_rxq; + struct xsk_buff_pool *xsk_pool; + u16 ring_idx; + u16 rx_buf_len; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct ixgbe_ring_container { + struct ixgbe_ring *ring; + long unsigned int next_update; + unsigned int total_bytes; + unsigned int total_packets; + u16 work_limit; + u8 count; + u8 itr; +}; + +struct ixgbe_adapter; + +struct ixgbe_q_vector { + struct ixgbe_adapter *adapter; + int cpu; + u16 v_idx; + u16 itr; + struct ixgbe_ring_container rx; + struct ixgbe_ring_container tx; + struct napi_struct napi; + cpumask_t affinity_mask; + int numa_node; + struct callback_head rcu; + char name[25]; + long: 56; + long: 64; + long: 64; + long: 64; + long: 64; + struct ixgbe_ring ring[0]; +}; + +enum ixgbe_ring_f_enum { + RING_F_NONE = 0, + RING_F_VMDQ = 1, + RING_F_RSS = 2, + RING_F_FDIR = 3, + RING_F_ARRAY_SIZE = 4, +}; + +struct ixgbe_ring_feature { + u16 limit; + u16 indices; + u16 mask; + u16 offset; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct ptp_clock; + +struct ixgbe_mac_addr; + +struct hwmon_buff; + +struct ixgbe_jump_table; + +struct ixgbe_adapter { + long unsigned int active_vlans[64]; + struct net_device *netdev; + struct bpf_prog *xdp_prog; + struct pci_dev *pdev; + struct mii_bus *mii_bus; + long unsigned int state; + u32 flags; + u32 flags2; + int num_tx_queues; + u16 tx_itr_setting; + u16 tx_work_limit; + u64 tx_ipsec; + int num_rx_queues; + u16 rx_itr_setting; + u64 rx_ipsec; + __be16 vxlan_port; + __be16 geneve_port; + int num_xdp_queues; + struct ixgbe_ring *xdp_ring[64]; + long unsigned int *af_xdp_zc_qps; + long: 64; + long: 64; + long: 64; + long: 64; + struct ixgbe_ring *tx_ring[64]; + u64 restart_queue; + u64 lsc_int; + u32 tx_timeout_count; + struct ixgbe_ring *rx_ring[64]; + int num_rx_pools; + int num_rx_queues_per_pool; + u64 hw_csum_rx_error; + u64 hw_rx_no_dma_resources; + u64 rsc_total_count; + u64 rsc_total_flush; + u64 non_eop_descs; + u32 alloc_rx_page; + u32 alloc_rx_page_failed; + u32 alloc_rx_buff_failed; + struct ixgbe_q_vector *q_vector[64]; + struct ieee_pfc *ixgbe_ieee_pfc; + struct ieee_ets *ixgbe_ieee_ets; + struct ixgbe_dcb_config dcb_cfg; + struct ixgbe_dcb_config temp_dcb_cfg; + u8 hw_tcs; + u8 dcb_set_bitmap; + u8 dcbx_cap; + enum ixgbe_fc_mode last_lfc_mode; + int num_q_vectors; + int max_q_vectors; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct ixgbe_ring_feature ring_feature[4]; + struct msix_entry *msix_entries; + u32 test_icr; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct ixgbe_ring test_tx_ring; + struct ixgbe_ring test_rx_ring; + struct ixgbe_hw hw; + u16 msg_enable; + struct ixgbe_hw_stats stats; + u64 tx_busy; + unsigned int tx_ring_count; + unsigned int xdp_ring_count; + unsigned int rx_ring_count; + u32 link_speed; + bool link_up; + long unsigned int sfp_poll_time; + long unsigned int link_check_timeout; + struct timer_list service_timer; + struct work_struct service_task; + struct hlist_head fdir_filter_list; + long unsigned int fdir_overflow; + union ixgbe_atr_input fdir_mask; + int fdir_filter_count; + u32 fdir_pballoc; + u32 atr_sample_rate; + spinlock_t fdir_perfect_lock; + u8 *io_addr; + u32 wol; + u16 bridge_mode; + char eeprom_id[32]; + u16 eeprom_cap; + u32 interrupt_event; + u32 led_reg; + struct ptp_clock *ptp_clock; + struct ptp_clock_info ptp_caps; + struct work_struct ptp_tx_work; + struct sk_buff *ptp_tx_skb; + struct hwtstamp_config tstamp_config; + long unsigned int ptp_tx_start; + long unsigned int last_overflow_check; + long unsigned int last_rx_ptp_check; + long unsigned int last_rx_timestamp; + spinlock_t tmreg_lock; + struct cyclecounter hw_cc; + struct timecounter hw_tc; + u32 base_incval; + u32 tx_hwtstamp_timeouts; + u32 tx_hwtstamp_skipped; + u32 rx_hwtstamp_cleared; + void (*ptp_setup_sdp)(struct ixgbe_adapter *); + long unsigned int active_vfs[1]; + unsigned int num_vfs; + struct vf_data_storage *vfinfo; + int vf_rate_link_speed; + struct vf_macvlans vf_mvs; + struct vf_macvlans *mv_list; + u32 timer_event_accumulator; + u32 vferr_refcount; + struct ixgbe_mac_addr *mac_table; + struct kobject *info_kobj; + struct hwmon_buff *ixgbe_hwmon_buff; + struct dentry *ixgbe_dbg_adapter; + u8 default_up; + long unsigned int fwd_bitmask[1]; + struct ixgbe_jump_table *jump_tables[10]; + long unsigned int tables; + u8 rss_indir_tbl[512]; + u32 *rss_key; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct hwmon_attr { + struct device_attribute dev_attr; + struct ixgbe_hw *hw; + struct ixgbe_thermal_diode_data *sensor; + char name[12]; +}; + +struct hwmon_buff { + struct attribute_group group; + const struct attribute_group *groups[2]; + struct attribute *attrs[13]; + struct hwmon_attr hwmon_list[12]; + unsigned int n_hwmon; +}; + +struct ixgbe_mac_addr { + u8 addr[6]; + u16 pool; + u16 state; +}; + +struct ixgbe_mat_field; + +struct ixgbe_fdir_filter; + +struct ixgbe_jump_table { + struct ixgbe_mat_field *mat; + struct ixgbe_fdir_filter *input; + union ixgbe_atr_input *mask; + u32 link_hdl; + long unsigned int child_loc_map[32]; +}; + +struct ixgbe_fdir_filter { + struct hlist_node fdir_node; + union ixgbe_atr_input filter; + u16 sw_idx; + u64 action; +}; + +enum ixgbe_state_t { + __IXGBE_TESTING = 0, + __IXGBE_RESETTING = 1, + __IXGBE_DOWN = 2, + __IXGBE_DISABLED = 3, + __IXGBE_REMOVING = 4, + __IXGBE_SERVICE_SCHED = 5, + __IXGBE_SERVICE_INITED = 6, + __IXGBE_IN_SFP_INIT = 7, + __IXGBE_PTP_RUNNING = 8, + __IXGBE_PTP_TX_IN_PROGRESS = 9, + __IXGBE_RESET_REQUESTED = 10, +}; + +struct ixgbe_cb { + union { + struct sk_buff *head; + struct sk_buff *tail; + }; + dma_addr_t dma; + u16 append_cnt; + bool page_released; +}; + +enum ixgbe_boards { + board_82598 = 0, + board_82599 = 1, + board_X540 = 2, + board_X550 = 3, + board_X550EM_x = 4, + board_x550em_x_fw = 5, + board_x550em_a = 6, + board_x550em_a_fw = 7, +}; + +struct ixgbe_mat_field { + unsigned int off; + int (*val)(struct ixgbe_fdir_filter *, union ixgbe_atr_input *, u32, u32); + unsigned int type; +}; + +struct ixgbe_nexthdr { + unsigned int o; + u32 s; + u32 m; + unsigned int off; + u32 val; + u32 mask; + struct ixgbe_mat_field *jump; +}; + +struct ixgbe_reg_info { + u32 ofs; + char *name; +}; + +struct upper_walk_data { + struct ixgbe_adapter *adapter; + u64 action; + int ifindex; + u8 queue; +}; + +struct my_u0 { + u64 a; + u64 b; +}; + +struct ixgbe_hic_hdr { + u8 cmd; + u8 buf_len; + union { + u8 cmd_resv; + u8 ret_status; + } cmd_or_resp; + u8 checksum; +}; + +struct ixgbe_hic_drv_info { + struct ixgbe_hic_hdr hdr; + u8 port_num; + u8 ver_sub; + u8 ver_build; + u8 ver_min; + u8 ver_maj; + u8 pad; + u16 pad2; +}; + +enum { + ETH_RSS_HASH_TOP_BIT = 0, + ETH_RSS_HASH_XOR_BIT = 1, + ETH_RSS_HASH_CRC32_BIT = 2, + ETH_RSS_HASH_FUNCS_COUNT = 3, +}; + +enum { + SOF_TIMESTAMPING_TX_HARDWARE = 1, + SOF_TIMESTAMPING_TX_SOFTWARE = 2, + SOF_TIMESTAMPING_RX_HARDWARE = 4, + SOF_TIMESTAMPING_RX_SOFTWARE = 8, + SOF_TIMESTAMPING_SOFTWARE = 16, + SOF_TIMESTAMPING_SYS_HARDWARE = 32, + SOF_TIMESTAMPING_RAW_HARDWARE = 64, + SOF_TIMESTAMPING_OPT_ID = 128, + SOF_TIMESTAMPING_TX_SCHED = 256, + SOF_TIMESTAMPING_TX_ACK = 512, + SOF_TIMESTAMPING_OPT_CMSG = 1024, + SOF_TIMESTAMPING_OPT_TSONLY = 2048, + SOF_TIMESTAMPING_OPT_STATS = 4096, + SOF_TIMESTAMPING_OPT_PKTINFO = 8192, + SOF_TIMESTAMPING_OPT_TX_SWHW = 16384, + SOF_TIMESTAMPING_LAST = 16384, + SOF_TIMESTAMPING_MASK = 32767, +}; + +enum hwtstamp_rx_filters { + HWTSTAMP_FILTER_NONE = 0, + HWTSTAMP_FILTER_ALL = 1, + HWTSTAMP_FILTER_SOME = 2, + HWTSTAMP_FILTER_PTP_V1_L4_EVENT = 3, + HWTSTAMP_FILTER_PTP_V1_L4_SYNC = 4, + HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ = 5, + HWTSTAMP_FILTER_PTP_V2_L4_EVENT = 6, + HWTSTAMP_FILTER_PTP_V2_L4_SYNC = 7, + HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ = 8, + HWTSTAMP_FILTER_PTP_V2_L2_EVENT = 9, + HWTSTAMP_FILTER_PTP_V2_L2_SYNC = 10, + HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ = 11, + HWTSTAMP_FILTER_PTP_V2_EVENT = 12, + HWTSTAMP_FILTER_PTP_V2_SYNC = 13, + HWTSTAMP_FILTER_PTP_V2_DELAY_REQ = 14, + HWTSTAMP_FILTER_NTP_ALL = 15, + __HWTSTAMP_FILTER_CNT = 16, +}; + +enum { + NETDEV_STATS___2 = 0, + IXGBE_STATS = 1, +}; + +struct ixgbe_stats { + char stat_string[32]; + int type; + int sizeof_stat; + int stat_offset; +}; + +struct ixgbe_reg_test { + u16 reg; + u8 array_len; + u8 test_type; + u32 mask; + u32 write; +}; + +enum ixgbe_pfvf_api_rev { + ixgbe_mbox_api_10 = 0, + ixgbe_mbox_api_20 = 1, + ixgbe_mbox_api_11 = 2, + ixgbe_mbox_api_12 = 3, + ixgbe_mbox_api_13 = 4, + ixgbe_mbox_api_14 = 5, + ixgbe_mbox_api_unknown = 6, +}; + +enum ixgbevf_xcast_modes { + IXGBEVF_XCAST_MODE_NONE = 0, + IXGBEVF_XCAST_MODE_MULTI = 1, + IXGBEVF_XCAST_MODE_ALLMULTI = 2, + IXGBEVF_XCAST_MODE_PROMISC = 3, +}; + +struct ixgbe_hic_hdr2_req { + u8 cmd; + u8 buf_lenh; + u8 buf_lenl; + u8 checksum; +}; + +struct ixgbe_hic_hdr2_rsp { + u8 cmd; + u8 buf_lenl; + u8 buf_lenh_status; + u8 checksum; +}; + +union ixgbe_hic_hdr2 { + struct ixgbe_hic_hdr2_req req; + struct ixgbe_hic_hdr2_rsp rsp; +}; + +struct ixgbe_hic_drv_info2 { + struct ixgbe_hic_hdr hdr; + u8 port_num; + u8 ver_sub; + u8 ver_build; + u8 ver_min; + u8 ver_maj; + char driver_string[39]; +}; + +struct ixgbe_hic_read_shadow_ram { + union ixgbe_hic_hdr2 hdr; + u32 address; + u16 length; + u16 pad2; + u16 data; + u16 pad3; +}; + +struct ixgbe_hic_write_shadow_ram { + union ixgbe_hic_hdr2 hdr; + __be32 address; + __be16 length; + u16 pad2; + u16 data; + u16 pad3; +}; + +struct ixgbe_hic_disable_rxen { + struct ixgbe_hic_hdr hdr; + u8 port_number; + u8 pad2; + u16 pad3; +}; + +struct ixgbe_hic_phy_token_req { + struct ixgbe_hic_hdr hdr; + u8 port_number; + u8 command_type; + u16 pad; +}; + +struct ixgbe_hic_internal_phy_req { + struct ixgbe_hic_hdr hdr; + u8 port_number; + u8 command_type; + __be16 address; + u16 rsv1; + __be32 write_data; + u16 pad; +} __attribute__((packed)); + +struct ixgbe_hic_internal_phy_resp { + struct ixgbe_hic_hdr hdr; + __be32 read_data; +}; + +struct ixgbe_hic_phy_activity_req { + struct ixgbe_hic_hdr hdr; + u8 port_number; + u8 pad; + __le16 activity_id; + __be32 data[4]; +}; + +struct ixgbe_hic_phy_activity_resp { + struct ixgbe_hic_hdr hdr; + __be32 data[4]; +}; + +struct ixgbe_adv_tx_context_desc { + __le32 vlan_macip_lens; + __le32 fceof_saidx; + __le32 type_tucmd_mlhl; + __le32 mss_l4len_idx; +}; + +struct pps_event_time { + struct timespec64 ts_real; +}; + +enum ptp_clock_events { + PTP_CLOCK_ALARM = 0, + PTP_CLOCK_EXTTS = 1, + PTP_CLOCK_PPS = 2, + PTP_CLOCK_PPSUSR = 3, +}; + +struct ptp_clock_event { + int type; + int index; + union { + u64 timestamp; + struct pps_event_time pps_times; + }; +}; + +enum { + NAPIF_STATE_SCHED = 1, + NAPIF_STATE_MISSED = 2, + NAPIF_STATE_DISABLE = 4, + NAPIF_STATE_NPSVC = 8, + NAPIF_STATE_LISTED = 16, + NAPIF_STATE_NO_BUSY_POLL = 32, + NAPIF_STATE_IN_BUSY_POLL = 64, + NAPIF_STATE_PREFER_BUSY_POLL = 128, +}; + +struct xdp_desc { + __u64 addr; + __u32 len; + __u32 options; +}; + +enum dcbnl_pfc_up_attrs { + DCB_PFC_UP_ATTR_UNDEFINED = 0, + DCB_PFC_UP_ATTR_0 = 1, + DCB_PFC_UP_ATTR_1 = 2, + DCB_PFC_UP_ATTR_2 = 3, + DCB_PFC_UP_ATTR_3 = 4, + DCB_PFC_UP_ATTR_4 = 5, + DCB_PFC_UP_ATTR_5 = 6, + DCB_PFC_UP_ATTR_6 = 7, + DCB_PFC_UP_ATTR_7 = 8, + DCB_PFC_UP_ATTR_ALL = 9, + __DCB_PFC_UP_ATTR_ENUM_MAX = 10, + DCB_PFC_UP_ATTR_MAX = 9, +}; + +enum dcbnl_pg_attrs { + DCB_PG_ATTR_UNDEFINED = 0, + DCB_PG_ATTR_TC_0 = 1, + DCB_PG_ATTR_TC_1 = 2, + DCB_PG_ATTR_TC_2 = 3, + DCB_PG_ATTR_TC_3 = 4, + DCB_PG_ATTR_TC_4 = 5, + DCB_PG_ATTR_TC_5 = 6, + DCB_PG_ATTR_TC_6 = 7, + DCB_PG_ATTR_TC_7 = 8, + DCB_PG_ATTR_TC_MAX = 9, + DCB_PG_ATTR_TC_ALL = 10, + DCB_PG_ATTR_BW_ID_0 = 11, + DCB_PG_ATTR_BW_ID_1 = 12, + DCB_PG_ATTR_BW_ID_2 = 13, + DCB_PG_ATTR_BW_ID_3 = 14, + DCB_PG_ATTR_BW_ID_4 = 15, + DCB_PG_ATTR_BW_ID_5 = 16, + DCB_PG_ATTR_BW_ID_6 = 17, + DCB_PG_ATTR_BW_ID_7 = 18, + DCB_PG_ATTR_BW_ID_MAX = 19, + DCB_PG_ATTR_BW_ID_ALL = 20, + __DCB_PG_ATTR_ENUM_MAX = 21, + DCB_PG_ATTR_MAX = 20, +}; + +enum dcbnl_cap_attrs { + DCB_CAP_ATTR_UNDEFINED = 0, + DCB_CAP_ATTR_ALL = 1, + DCB_CAP_ATTR_PG = 2, + DCB_CAP_ATTR_PFC = 3, + DCB_CAP_ATTR_UP2TC = 4, + DCB_CAP_ATTR_PG_TCS = 5, + DCB_CAP_ATTR_PFC_TCS = 6, + DCB_CAP_ATTR_GSP = 7, + DCB_CAP_ATTR_BCN = 8, + DCB_CAP_ATTR_DCBX = 9, + __DCB_CAP_ATTR_ENUM_MAX = 10, + DCB_CAP_ATTR_MAX = 9, +}; + +enum dcbnl_numtcs_attrs { + DCB_NUMTCS_ATTR_UNDEFINED = 0, + DCB_NUMTCS_ATTR_ALL = 1, + DCB_NUMTCS_ATTR_PG = 2, + DCB_NUMTCS_ATTR_PFC = 3, + __DCB_NUMTCS_ATTR_ENUM_MAX = 4, + DCB_NUMTCS_ATTR_MAX = 3, +}; + +enum dcb_general_attr_values { + DCB_ATTR_VALUE_UNDEFINED = 255, +}; + +typedef enum { + ixgb_mac_unknown = 0, + ixgb_82597 = 1, + ixgb_num_macs = 2, +} ixgb_mac_type; + +typedef enum { + ixgb_phy_type_unknown = 0, + ixgb_phy_type_g6005 = 1, + ixgb_phy_type_g6104 = 2, + ixgb_phy_type_txn17201 = 3, + ixgb_phy_type_txn17401 = 4, + ixgb_phy_type_bcm = 5, +} ixgb_phy_type; + +typedef enum { + ixgb_fc_none = 0, + ixgb_fc_rx_pause = 1, + ixgb_fc_tx_pause = 2, + ixgb_fc_full = 3, + ixgb_fc_default = 255, +} ixgb_fc_type; + +typedef enum { + ixgb_bus_type_unknown = 0, + ixgb_bus_type_pci = 1, + ixgb_bus_type_pcix = 2, +} ixgb_bus_type; + +typedef enum { + ixgb_bus_speed_unknown = 0, + ixgb_bus_speed_33 = 1, + ixgb_bus_speed_66 = 2, + ixgb_bus_speed_100 = 3, + ixgb_bus_speed_133 = 4, + ixgb_bus_speed_reserved = 5, +} ixgb_bus_speed; + +typedef enum { + ixgb_bus_width_unknown = 0, + ixgb_bus_width_32 = 1, + ixgb_bus_width_64 = 2, +} ixgb_bus_width; + +struct ixgb_rx_desc { + __le64 buff_addr; + __le16 length; + __le16 reserved; + u8 status; + u8 errors; + __le16 special; +}; + +struct ixgb_tx_desc { + __le64 buff_addr; + __le32 cmd_type_len; + u8 status; + u8 popts; + __le16 vlan; +}; + +struct ixgb_context_desc { + u8 ipcss; + u8 ipcso; + __le16 ipcse; + u8 tucss; + u8 tucso; + __le16 tucse; + __le32 cmd_type_len; + u8 status; + u8 hdr_len; + __le16 mss; +}; + +struct ixgb_fc { + u32 high_water; + u32 low_water; + u16 pause_time; + bool send_xon; + ixgb_fc_type type; +}; + +struct ixgb_bus { + ixgb_bus_speed speed; + ixgb_bus_width width; + ixgb_bus_type type; +}; + +struct ixgb_hw { + u8 *hw_addr; + void *back; + struct ixgb_fc fc; + struct ixgb_bus bus; + u32 phy_id; + u32 phy_addr; + ixgb_mac_type mac_type; + ixgb_phy_type phy_type; + u32 max_frame_size; + u32 mc_filter_type; + u32 num_mc_addrs; + u8 curr_mac_addr[6]; + u32 num_tx_desc; + u32 num_rx_desc; + u32 rx_buffer_size; + bool link_up; + bool adapter_stopped; + u16 device_id; + u16 vendor_id; + u8 revision_id; + u16 subsystem_vendor_id; + u16 subsystem_id; + u32 bar0; + u32 bar1; + u32 bar2; + u32 bar3; + u16 pci_cmd_word; + __le16 eeprom[64]; + long unsigned int io_base; + u32 lastLFC; + u32 lastRFC; +}; + +struct ixgb_hw_stats { + u64 tprl; + u64 tprh; + u64 gprcl; + u64 gprch; + u64 bprcl; + u64 bprch; + u64 mprcl; + u64 mprch; + u64 uprcl; + u64 uprch; + u64 vprcl; + u64 vprch; + u64 jprcl; + u64 jprch; + u64 gorcl; + u64 gorch; + u64 torl; + u64 torh; + u64 rnbc; + u64 ruc; + u64 roc; + u64 rlec; + u64 crcerrs; + u64 icbc; + u64 ecbc; + u64 mpc; + u64 tptl; + u64 tpth; + u64 gptcl; + u64 gptch; + u64 bptcl; + u64 bptch; + u64 mptcl; + u64 mptch; + u64 uptcl; + u64 uptch; + u64 vptcl; + u64 vptch; + u64 jptcl; + u64 jptch; + u64 gotcl; + u64 gotch; + u64 totl; + u64 toth; + u64 dc; + u64 plt64c; + u64 tsctc; + u64 tsctfc; + u64 ibic; + u64 rfc; + u64 lfc; + u64 pfrc; + u64 pftc; + u64 mcfrc; + u64 mcftc; + u64 xonrxc; + u64 xontxc; + u64 xoffrxc; + u64 xofftxc; + u64 rjc; +}; + +struct ixgb_buffer { + struct sk_buff *skb; + dma_addr_t dma; + long unsigned int time_stamp; + u16 length; + u16 next_to_watch; + u16 mapped_as_page; +}; + +struct ixgb_desc_ring { + void *desc; + dma_addr_t dma; + unsigned int size; + unsigned int count; + unsigned int next_to_use; + unsigned int next_to_clean; + struct ixgb_buffer *buffer_info; +}; + +struct ixgb_adapter { + struct timer_list watchdog_timer; + long unsigned int active_vlans[64]; + u32 bd_number; + u32 rx_buffer_len; + u32 part_num; + u16 link_speed; + u16 link_duplex; + struct work_struct tx_timeout_task; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct ixgb_desc_ring tx_ring; + unsigned int restart_queue; + long unsigned int timeo_start; + u32 tx_cmd_type; + u64 hw_csum_tx_good; + u64 hw_csum_tx_error; + u32 tx_int_delay; + u32 tx_timeout_count; + bool tx_int_delay_enable; + bool detect_tx_hung; + struct ixgb_desc_ring rx_ring; + u64 hw_csum_rx_error; + u64 hw_csum_rx_good; + u32 rx_int_delay; + bool rx_csum; + struct napi_struct napi; + struct net_device *netdev; + struct pci_dev *pdev; + struct ixgb_hw hw; + u16 msg_enable; + struct ixgb_hw_stats stats; + u32 alloc_rx_buff_failed; + bool have_msi; + long unsigned int flags; +}; + +enum ixgb_state_t { + __IXGB_DOWN = 0, +}; + +typedef enum { + ixgb_xpak_vendor_intel = 0, + ixgb_xpak_vendor_infineon = 1, +} ixgb_xpak_vendor; + +struct ixgb_ee_map_type { + u8 mac_addr[6]; + __le16 compatibility; + __le16 reserved1[4]; + __le32 pba_number; + __le16 init_ctrl_reg_1; + __le16 subsystem_id; + __le16 subvendor_id; + __le16 device_id; + __le16 vendor_id; + __le16 init_ctrl_reg_2; + __le16 oem_reserved[16]; + __le16 swdpins_reg; + __le16 circuit_ctrl_reg; + u8 d3_power; + u8 d0_power; + __le16 reserved2[28]; + __le16 checksum; +}; + +enum { + NETDEV_STATS___3 = 0, + IXGB_STATS = 1, +}; + +struct ixgb_stats { + char stat_string[32]; + int type; + int sizeof_stat; + int stat_offset; +}; + +struct ixgb_opt_list { + int i; + const char *str; +}; + +struct ixgb_option { + enum { + enable_option___2 = 0, + range_option___2 = 1, + list_option___2 = 2, + } type; + const char *name; + const char *err; + int def; + union { + struct { + int min; + int max; + } r; + struct { + int nr; + const struct ixgb_opt_list *p; + } l; + } arg; +}; + +enum devlink_port_type { + DEVLINK_PORT_TYPE_NOTSET = 0, + DEVLINK_PORT_TYPE_AUTO = 1, + DEVLINK_PORT_TYPE_ETH = 2, + DEVLINK_PORT_TYPE_IB = 3, +}; + +enum devlink_port_flavour { + DEVLINK_PORT_FLAVOUR_PHYSICAL = 0, + DEVLINK_PORT_FLAVOUR_CPU = 1, + DEVLINK_PORT_FLAVOUR_DSA = 2, + DEVLINK_PORT_FLAVOUR_PCI_PF = 3, + DEVLINK_PORT_FLAVOUR_PCI_VF = 4, + DEVLINK_PORT_FLAVOUR_VIRTUAL = 5, + DEVLINK_PORT_FLAVOUR_UNUSED = 6, +}; + +struct devlink_port_phys_attrs { + u32 port_number; + u32 split_subport_number; +}; + +struct devlink_port_pci_pf_attrs { + u32 controller; + u16 pf; + u8 external: 1; +}; + +struct devlink_port_pci_vf_attrs { + u32 controller; + u16 pf; + u16 vf; + u8 external: 1; +}; + +struct devlink_port_attrs { + u8 split: 1; + u8 splittable: 1; + u32 lanes; + enum devlink_port_flavour flavour; + struct netdev_phys_item_id switch_id; + union { + struct devlink_port_phys_attrs phys; + struct devlink_port_pci_pf_attrs pci_pf; + struct devlink_port_pci_vf_attrs pci_vf; + }; +}; + +struct devlink; + +struct devlink_port { + struct list_head list; + struct list_head param_list; + struct list_head region_list; + struct devlink *devlink; + unsigned int index; + bool registered; + spinlock_t type_lock; + enum devlink_port_type type; + enum devlink_port_type desired_type; + void *type_dev; + struct devlink_port_attrs attrs; + u8 attrs_set: 1; + u8 switch_port: 1; + struct delayed_work type_warn_dw; + struct list_head reporter_list; + struct mutex reporters_lock; +}; + +enum devlink_sb_pool_type { + DEVLINK_SB_POOL_TYPE_INGRESS = 0, + DEVLINK_SB_POOL_TYPE_EGRESS = 1, +}; + +enum devlink_sb_threshold_type { + DEVLINK_SB_THRESHOLD_TYPE_STATIC = 0, + DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC = 1, +}; + +enum devlink_eswitch_encap_mode { + DEVLINK_ESWITCH_ENCAP_MODE_NONE = 0, + DEVLINK_ESWITCH_ENCAP_MODE_BASIC = 1, +}; + +enum devlink_trap_action { + DEVLINK_TRAP_ACTION_DROP = 0, + DEVLINK_TRAP_ACTION_TRAP = 1, + DEVLINK_TRAP_ACTION_MIRROR = 2, +}; + +enum devlink_trap_type { + DEVLINK_TRAP_TYPE_DROP = 0, + DEVLINK_TRAP_TYPE_EXCEPTION = 1, + DEVLINK_TRAP_TYPE_CONTROL = 2, +}; + +enum devlink_reload_action { + DEVLINK_RELOAD_ACTION_UNSPEC = 0, + DEVLINK_RELOAD_ACTION_DRIVER_REINIT = 1, + DEVLINK_RELOAD_ACTION_FW_ACTIVATE = 2, + __DEVLINK_RELOAD_ACTION_MAX = 3, + DEVLINK_RELOAD_ACTION_MAX = 2, +}; + +enum devlink_reload_limit { + DEVLINK_RELOAD_LIMIT_UNSPEC = 0, + DEVLINK_RELOAD_LIMIT_NO_RESET = 1, + __DEVLINK_RELOAD_LIMIT_MAX = 2, + DEVLINK_RELOAD_LIMIT_MAX = 1, +}; + +enum devlink_dpipe_field_mapping_type { + DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0, + DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 1, +}; + +struct devlink_dev_stats { + u32 reload_stats[6]; + u32 remote_reload_stats[6]; +}; + +struct devlink_dpipe_headers; + +struct devlink_ops; + +struct devlink { + struct list_head list; + struct list_head port_list; + struct list_head sb_list; + struct list_head dpipe_table_list; + struct list_head resource_list; + struct list_head param_list; + struct list_head region_list; + struct list_head reporter_list; + struct mutex reporters_lock; + struct devlink_dpipe_headers *dpipe_headers; + struct list_head trap_list; + struct list_head trap_group_list; + struct list_head trap_policer_list; + const struct devlink_ops *ops; + struct xarray snapshot_ids; + struct devlink_dev_stats stats; + struct device *dev; + possible_net_t _net; + struct mutex lock; + u8 reload_failed: 1; + u8 reload_enabled: 1; + u8 registered: 1; + long: 61; + long: 64; + long: 64; + char priv[0]; +}; + +struct devlink_dpipe_header; + +struct devlink_dpipe_headers { + struct devlink_dpipe_header **headers; + unsigned int headers_count; +}; + +struct devlink_sb_pool_info; + +struct devlink_info_req; + +struct devlink_flash_update_params; + +struct devlink_trap; + +struct devlink_trap_group; + +struct devlink_trap_policer; + +struct devlink_ops { + u32 supported_flash_update_params; + long unsigned int reload_actions; + long unsigned int reload_limits; + int (*reload_down)(struct devlink *, bool, enum devlink_reload_action, enum devlink_reload_limit, struct netlink_ext_ack *); + int (*reload_up)(struct devlink *, enum devlink_reload_action, enum devlink_reload_limit, u32 *, struct netlink_ext_ack *); + int (*port_type_set)(struct devlink_port *, enum devlink_port_type); + int (*port_split)(struct devlink *, unsigned int, unsigned int, struct netlink_ext_ack *); + int (*port_unsplit)(struct devlink *, unsigned int, struct netlink_ext_ack *); + int (*sb_pool_get)(struct devlink *, unsigned int, u16, struct devlink_sb_pool_info *); + int (*sb_pool_set)(struct devlink *, unsigned int, u16, u32, enum devlink_sb_threshold_type, struct netlink_ext_ack *); + int (*sb_port_pool_get)(struct devlink_port *, unsigned int, u16, u32 *); + int (*sb_port_pool_set)(struct devlink_port *, unsigned int, u16, u32, struct netlink_ext_ack *); + int (*sb_tc_pool_bind_get)(struct devlink_port *, unsigned int, u16, enum devlink_sb_pool_type, u16 *, u32 *); + int (*sb_tc_pool_bind_set)(struct devlink_port *, unsigned int, u16, enum devlink_sb_pool_type, u16, u32, struct netlink_ext_ack *); + int (*sb_occ_snapshot)(struct devlink *, unsigned int); + int (*sb_occ_max_clear)(struct devlink *, unsigned int); + int (*sb_occ_port_pool_get)(struct devlink_port *, unsigned int, u16, u32 *, u32 *); + int (*sb_occ_tc_port_bind_get)(struct devlink_port *, unsigned int, u16, enum devlink_sb_pool_type, u32 *, u32 *); + int (*eswitch_mode_get)(struct devlink *, u16 *); + int (*eswitch_mode_set)(struct devlink *, u16, struct netlink_ext_ack *); + int (*eswitch_inline_mode_get)(struct devlink *, u8 *); + int (*eswitch_inline_mode_set)(struct devlink *, u8, struct netlink_ext_ack *); + int (*eswitch_encap_mode_get)(struct devlink *, enum devlink_eswitch_encap_mode *); + int (*eswitch_encap_mode_set)(struct devlink *, enum devlink_eswitch_encap_mode, struct netlink_ext_ack *); + int (*info_get)(struct devlink *, struct devlink_info_req *, struct netlink_ext_ack *); + int (*flash_update)(struct devlink *, struct devlink_flash_update_params *, struct netlink_ext_ack *); + int (*trap_init)(struct devlink *, const struct devlink_trap *, void *); + void (*trap_fini)(struct devlink *, const struct devlink_trap *, void *); + int (*trap_action_set)(struct devlink *, const struct devlink_trap *, enum devlink_trap_action, struct netlink_ext_ack *); + int (*trap_group_init)(struct devlink *, const struct devlink_trap_group *); + int (*trap_group_set)(struct devlink *, const struct devlink_trap_group *, const struct devlink_trap_policer *, struct netlink_ext_ack *); + int (*trap_group_action_set)(struct devlink *, const struct devlink_trap_group *, enum devlink_trap_action, struct netlink_ext_ack *); + int (*trap_policer_init)(struct devlink *, const struct devlink_trap_policer *); + void (*trap_policer_fini)(struct devlink *, const struct devlink_trap_policer *); + int (*trap_policer_set)(struct devlink *, const struct devlink_trap_policer *, u64, u64, struct netlink_ext_ack *); + int (*trap_policer_counter_get)(struct devlink *, const struct devlink_trap_policer *, u64 *); + int (*port_function_hw_addr_get)(struct devlink *, struct devlink_port *, u8 *, int *, struct netlink_ext_ack *); + int (*port_function_hw_addr_set)(struct devlink *, struct devlink_port *, const u8 *, int, struct netlink_ext_ack *); +}; + +struct devlink_sb_pool_info { + enum devlink_sb_pool_type pool_type; + u32 size; + enum devlink_sb_threshold_type threshold_type; + u32 cell_size; +}; + +struct devlink_dpipe_field { + const char *name; + unsigned int id; + unsigned int bitwidth; + enum devlink_dpipe_field_mapping_type mapping_type; +}; + +struct devlink_dpipe_header { + const char *name; + unsigned int id; + struct devlink_dpipe_field *fields; + unsigned int fields_count; + bool global; +}; + +struct devlink_flash_update_params { + const char *file_name; + const char *component; + u32 overwrite_mask; +}; + +struct devlink_trap_policer { + u32 id; + u64 init_rate; + u64 init_burst; + u64 max_rate; + u64 min_rate; + u64 max_burst; + u64 min_burst; +}; + +struct devlink_trap_group { + const char *name; + u16 id; + bool generic; + u32 init_policer_id; +}; + +struct devlink_trap { + enum devlink_trap_type type; + enum devlink_trap_action init_action; + bool generic; + u16 id; + const char *name; + u16 init_group_id; + u32 metadata_cap; +}; + +enum { + MLX4_MAX_PORTS = 2, + MLX4_MAX_PORT_PKEYS = 128, + MLX4_MAX_PORT_GIDS = 128, +}; + +enum { + MLX4_BOARD_ID_LEN = 64, +}; + +enum { + MLX4_MAX_NUM_PF = 16, + MLX4_MAX_NUM_VF = 126, + MLX4_MAX_NUM_VF_P_PORT = 64, + MLX4_MFUNC_MAX = 128, + MLX4_MAX_EQ_NUM = 1024, + MLX4_MFUNC_EQ_NUM = 4, + MLX4_MFUNC_MAX_EQES = 8, + MLX4_MFUNC_EQE_MASK = 7, +}; + +enum { + MLX4_BMME_FLAG_WIN_TYPE_2B = 2, + MLX4_BMME_FLAG_LOCAL_INV = 64, + MLX4_BMME_FLAG_REMOTE_INV = 128, + MLX4_BMME_FLAG_TYPE_2_WIN = 512, + MLX4_BMME_FLAG_RESERVED_LKEY = 1024, + MLX4_BMME_FLAG_FAST_REG_WR = 2048, + MLX4_BMME_FLAG_ROCE_V1_V2 = 524288, + MLX4_BMME_FLAG_PORT_REMAP = 16777216, + MLX4_BMME_FLAG_VSD_INIT2RTR = 268435456, +}; + +enum slave_port_state { + SLAVE_PORT_DOWN = 0, + SLAVE_PENDING_UP = 1, + SLAVE_PORT_UP = 2, +}; + +enum mlx4_qp_region { + MLX4_QP_REGION_FW = 0, + MLX4_QP_REGION_RSS_RAW_ETH = 1, + MLX4_QP_REGION_BOTTOM = 1, + MLX4_QP_REGION_ETH_ADDR = 2, + MLX4_QP_REGION_FC_ADDR = 3, + MLX4_QP_REGION_FC_EXCH = 4, + MLX4_NUM_QP_REGION = 5, +}; + +enum mlx4_port_type { + MLX4_PORT_TYPE_NONE = 0, + MLX4_PORT_TYPE_IB = 1, + MLX4_PORT_TYPE_ETH = 2, + MLX4_PORT_TYPE_AUTO = 3, +}; + +enum mlx4_steer_type { + MLX4_MC_STEER = 0, + MLX4_UC_STEER = 1, + MLX4_NUM_STEERS = 2, +}; + +struct mlx4_rate_limit_caps { + u16 num_rates; + u8 min_unit; + u16 min_val; + u8 max_unit; + u16 max_val; +}; + +struct mlx4_phys_caps { + u32 gid_phys_table_len[3]; + u32 pkey_phys_table_len[3]; + u32 num_phys_eqs; + u32 base_sqpn; + u32 base_proxy_sqpn; + u32 base_tunnel_sqpn; +}; + +struct mlx4_spec_qps { + u32 qp0_qkey; + u32 qp0_proxy; + u32 qp0_tunnel; + u32 qp1_proxy; + u32 qp1_tunnel; +}; + +struct mlx4_caps { + u64 fw_ver; + u32 function; + int num_ports; + int vl_cap[3]; + int ib_mtu_cap[3]; + __be32 ib_port_def_cap[3]; + u64 def_mac[3]; + int eth_mtu_cap[3]; + int gid_table_len[3]; + int pkey_table_len[3]; + int trans_type[3]; + int vendor_oui[3]; + int wavelength[3]; + u64 trans_code[3]; + int local_ca_ack_delay; + int num_uars; + u32 uar_page_size; + int bf_reg_size; + int bf_regs_per_page; + int max_sq_sg; + int max_rq_sg; + int num_qps; + int max_wqes; + int max_sq_desc_sz; + int max_rq_desc_sz; + int max_qp_init_rdma; + int max_qp_dest_rdma; + int max_tc_eth; + struct mlx4_spec_qps *spec_qps; + int num_srqs; + int max_srq_wqes; + int max_srq_sge; + int reserved_srqs; + int num_cqs; + int max_cqes; + int reserved_cqs; + int num_sys_eqs; + int num_eqs; + int reserved_eqs; + int num_comp_vectors; + int num_mpts; + int num_mtts; + int fmr_reserved_mtts; + int reserved_mtts; + int reserved_mrws; + int reserved_uars; + int num_mgms; + int num_amgms; + int reserved_mcgs; + int num_qp_per_mgm; + int steering_mode; + int dmfs_high_steer_mode; + int fs_log_max_ucast_qp_range_size; + int num_pds; + int reserved_pds; + int max_xrcds; + int reserved_xrcds; + int mtt_entry_sz; + u32 max_msg_sz; + u32 page_size_cap; + u64 flags; + u64 flags2; + u32 bmme_flags; + u32 reserved_lkey; + u16 stat_rate_support; + u8 port_width_cap[3]; + int max_gso_sz; + int max_rss_tbl_sz; + int reserved_qps_cnt[5]; + int reserved_qps; + int reserved_qps_base[5]; + int log_num_macs; + int log_num_vlans; + enum mlx4_port_type port_type[3]; + u8 supported_type[3]; + u8 suggested_type[3]; + u8 default_sense[3]; + u32 port_mask[3]; + enum mlx4_port_type possible_type[3]; + u32 max_counters; + u8 port_ib_mtu[3]; + u16 sqp_demux; + u32 eqe_size; + u32 cqe_size; + u8 eqe_factor; + u32 userspace_caps; + u32 function_caps; + u16 hca_core_clock; + u64 phys_port_id[3]; + int tunnel_offload_mode; + u8 rx_checksum_flags_port[3]; + u8 phv_bit[3]; + u8 alloc_res_qp_mask; + u32 dmfs_high_rate_qpn_base; + u32 dmfs_high_rate_qpn_range; + u32 vf_caps; + bool wol_port[3]; + struct mlx4_rate_limit_caps rl_caps; + u32 health_buffer_addrs; +}; + +struct mlx4_buf_list { + void *buf; + dma_addr_t map; +}; + +struct mlx4_buf { + struct mlx4_buf_list direct; + struct mlx4_buf_list *page_list; + int nbufs; + int npages; + int page_shift; +}; + +struct mlx4_mtt { + u32 offset; + int order; + int page_shift; +}; + +enum { + MLX4_DB_PER_PAGE = 1024, +}; + +struct mlx4_db_pgdir { + struct list_head list; + long unsigned int order0[16]; + long unsigned int order1[8]; + long unsigned int *bits[2]; + __be32 *db_page; + dma_addr_t db_dma; +}; + +struct mlx4_ib_user_db_page; + +struct mlx4_db { + __be32 *db; + union { + struct mlx4_db_pgdir *pgdir; + struct mlx4_ib_user_db_page *user_page; + } u; + dma_addr_t dma; + int index; + int order; +}; + +struct mlx4_hwq_resources { + struct mlx4_db db; + struct mlx4_mtt mtt; + struct mlx4_buf buf; +}; + +struct mlx4_uar { + long unsigned int pfn; + int index; + struct list_head bf_list; + unsigned int free_bf_bmap; + void *map; + void *bf_map; +}; + +struct mlx4_quotas { + int qp; + int cq; + int srq; + int mpt; + int mtt; + int counter; + int xrcd; +}; + +struct mlx4_vf_dev { + u8 min_port; + u8 n_ports; +}; + +struct devlink_region; + +struct mlx4_fw_crdump { + bool snapshot_enable; + struct devlink_region *region_crspace; + struct devlink_region *region_fw_health; +}; + +enum mlx4_pci_status { + MLX4_PCI_STATUS_DISABLED = 0, + MLX4_PCI_STATUS_ENABLED = 1, +}; + +struct mlx4_dev; + +struct mlx4_dev_persistent { + struct pci_dev *pdev; + struct mlx4_dev *dev; + int nvfs[3]; + int num_vfs; + enum mlx4_port_type curr_port_type[3]; + enum mlx4_port_type curr_port_poss_type[3]; + struct work_struct catas_work; + struct workqueue_struct *catas_wq; + struct mutex device_state_mutex; + u8 state; + struct mutex interface_state_mutex; + u8 interface_state; + struct mutex pci_status_mutex; + enum mlx4_pci_status pci_status; + struct mlx4_fw_crdump crdump; +}; + +struct mlx4_dev { + struct mlx4_dev_persistent *persist; + long unsigned int flags; + long unsigned int num_slaves; + struct mlx4_caps caps; + struct mlx4_phys_caps phys_caps; + struct mlx4_quotas quotas; + struct xarray qp_table_tree; + u8 rev_id; + u8 port_random_macs; + char board_id[64]; + int numa_node; + int oper_log_mgm_entry_size; + u64 regid_promisc_array[3]; + u64 regid_allmulti_array[3]; + struct mlx4_vf_dev *dev_vfs; + u8 uar_page_shift; +}; + +struct mlx4_eqe { + u8 reserved1; + u8 type; + u8 reserved2; + u8 subtype; + union { + u32 raw[6]; + struct { + __be32 cqn; + } comp; + struct { + u16 reserved1; + __be16 token; + u32 reserved2; + u8 reserved3[3]; + u8 status; + __be64 out_param; + } __attribute__((packed)) cmd; + struct { + __be32 qpn; + } qp; + struct { + __be32 srqn; + } srq; + struct { + __be32 cqn; + u32 reserved1; + u8 reserved2[3]; + u8 syndrome; + } cq_err; + struct { + u32 reserved1[2]; + __be32 port; + } port_change; + struct { + u32 reserved; + u32 bit_vec[4]; + } comm_channel_arm; + struct { + u8 port; + u8 reserved[3]; + __be64 mac; + } __attribute__((packed)) mac_update; + struct { + __be32 slave_id; + } flr_event; + struct { + __be16 current_temperature; + __be16 warning_threshold; + } warming; + struct { + u8 reserved[3]; + u8 port; + union { + struct { + __be16 mstr_sm_lid; + __be16 port_lid; + __be32 changed_attr; + u8 reserved[3]; + u8 mstr_sm_sl; + __be64 gid_prefix; + } __attribute__((packed)) port_info; + struct { + __be32 block_ptr; + __be32 tbl_entries_mask; + } tbl_change_info; + struct { + u8 sl2vl_table[8]; + } sl2vl_tbl_change_info; + } params; + } __attribute__((packed)) port_mgmt_change; + struct { + u8 reserved[3]; + u8 port; + u32 reserved1[5]; + } bad_cable; + } event; + u8 slave_id; + u8 reserved3[2]; + u8 owner; +} __attribute__((packed)); + +struct mlx4_active_ports { + long unsigned int ports[1]; +}; + +struct mlx4_port_map { + u8 port1; + u8 port2; +}; + +enum { + MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE = 10, + MLX4_MIN_MGM_LOG_ENTRY_SIZE = 7, + MLX4_MAX_MGM_LOG_ENTRY_SIZE = 12, + MLX4_MAX_QP_PER_MGM = 1016, +}; + +enum { + MLX4_CMPT_TYPE_QP = 0, + MLX4_CMPT_TYPE_SRQ = 1, + MLX4_CMPT_TYPE_CQ = 2, + MLX4_CMPT_TYPE_EQ = 3, + MLX4_CMPT_NUM_TYPE = 4, +}; + +enum mlx4_resource { + RES_QP = 0, + RES_CQ = 1, + RES_SRQ = 2, + RES_XRCD = 3, + RES_MPT = 4, + RES_MTT = 5, + RES_MAC = 6, + RES_VLAN = 7, + RES_NPORT_ID = 8, + RES_COUNTER = 9, + RES_FS_RULE = 10, + RES_EQ = 11, + MLX4_NUM_OF_RESOURCE_TYPE = 12, +}; + +struct mlx4_vhcr_cmd { + __be64 in_param; + __be32 in_modifier; + u32 reserved1; + __be64 out_param; + __be16 token; + u16 reserved; + u8 status; + u8 flags; + __be16 opcode; +}; + +struct mlx4_bitmap { + u32 last; + u32 top; + u32 max; + u32 reserved_top; + u32 mask; + u32 avail; + u32 effective_len; + spinlock_t lock; + long unsigned int *table; +}; + +struct mlx4_buddy { + long unsigned int **bits; + unsigned int *num_free; + u32 max_order; + spinlock_t lock; +}; + +struct mlx4_icm; + +struct mlx4_icm_table { + u64 virt; + int num_icm; + u32 num_obj; + int obj_size; + int lowmem; + int coherent; + struct mutex mutex; + struct mlx4_icm **icm; +}; + +struct mlx4_eq_tasklet { + struct list_head list; + struct list_head process_list; + struct tasklet_struct task; + spinlock_t lock; +}; + +struct mlx4_eq { + struct mlx4_dev *dev; + void *doorbell; + int eqn; + u32 cons_index; + u16 irq; + u16 have_irq; + int nent; + struct mlx4_buf_list *page_list; + struct mlx4_mtt mtt; + struct mlx4_eq_tasklet tasklet_ctx; + struct mlx4_active_ports actv_ports; + u32 ref_count; + cpumask_var_t affinity_mask; +}; + +struct mlx4_slave_eqe { + u8 type; + u8 port; + u32 param; +}; + +struct mlx4_slave_event_eq_info { + int eqn; + u16 token; +}; + +struct mlx4_fw { + u64 clr_int_base; + u64 catas_offset; + u64 comm_base; + u64 clock_offset; + struct mlx4_icm *fw_icm; + struct mlx4_icm *aux_icm; + u32 catas_size; + u16 fw_pages; + u8 clr_int_bar; + u8 catas_bar; + u8 comm_bar; + u8 clock_bar; +}; + +struct mlx4_comm { + u32 slave_write; + u32 slave_read; +}; + +struct mlx4_vlan_fltr { + __be32 entry[128]; +}; + +struct mlx4_slave_state { + u8 comm_toggle; + u8 last_cmd; + u8 init_port_mask; + bool active; + bool old_vlan_api; + bool vst_qinq_supported; + u8 function; + dma_addr_t vhcr_dma; + u16 user_mtu[3]; + u16 mtu[3]; + __be32 ib_cap_mask[3]; + struct mlx4_slave_eqe eq[8]; + struct list_head mcast_filters[3]; + struct mlx4_vlan_fltr *vlan_filter[3]; + struct mlx4_slave_event_eq_info event_eq[64]; + u16 eq_pi; + u16 eq_ci; + spinlock_t lock; + u8 is_slave_going_down; + u32 cookie; + enum slave_port_state port_state[3]; +}; + +struct mlx4_vport_state { + u64 mac; + u16 default_vlan; + u8 default_qos; + __be16 vlan_proto; + u32 tx_rate; + bool spoofchk; + u32 link_state; + u8 qos_vport; + __be64 guid; +}; + +struct mlx4_vf_admin_state { + struct mlx4_vport_state vport[3]; + u8 enable_smi[3]; +}; + +struct mlx4_vport_oper_state { + struct mlx4_vport_state state; + int mac_idx; + int vlan_idx; +}; + +struct mlx4_vf_oper_state { + struct mlx4_vport_oper_state vport[3]; + u8 smi_enabled[3]; +}; + +struct slave_list { + struct mutex mutex; + struct list_head res_list[12]; +}; + +struct resource_allocator { + spinlock_t alloc_lock; + union { + unsigned int res_reserved; + unsigned int res_port_rsvd[2]; + }; + union { + int res_free; + int res_port_free[2]; + }; + int *quota; + int *allocated; + int *guaranteed; +}; + +struct mlx4_resource_tracker { + spinlock_t lock; + struct rb_root res_tree[12]; + struct slave_list *slave_list; + struct resource_allocator res_alloc[12]; +}; + +struct mlx4_slave_event_eq { + u32 eqn; + u32 cons; + u32 prod; + spinlock_t event_lock; + struct mlx4_eqe event_eqe[128]; +}; + +struct mlx4_qos_manager { + int num_of_qos_vfs; + long unsigned int priority_bm[1]; +}; + +struct mlx4_master_qp0_state { + int proxy_qp0_active; + int qp0_active; + int port_active; +}; + +struct mlx4_mfunc_master_ctx { + struct mlx4_slave_state *slave_state; + struct mlx4_vf_admin_state *vf_admin; + struct mlx4_vf_oper_state *vf_oper; + struct mlx4_master_qp0_state qp0_state[3]; + int init_port_ref[3]; + u16 max_mtu[3]; + u16 max_user_mtu[3]; + u8 pptx; + u8 pprx; + int disable_mcast_ref[3]; + struct mlx4_resource_tracker res_tracker; + struct workqueue_struct *comm_wq; + struct work_struct comm_work; + struct work_struct slave_event_work; + struct work_struct slave_flr_event_work; + spinlock_t slave_state_lock; + __be32 comm_arm_bit_vector[4]; + struct mlx4_eqe cmd_eqe; + struct mlx4_slave_event_eq slave_eq; + struct mutex gen_eqe_mutex[128]; + struct mlx4_qos_manager qos_ctl[3]; +}; + +struct mlx4_mfunc { + struct mlx4_comm *comm; + struct mlx4_vhcr_cmd *vhcr; + dma_addr_t vhcr_dma; + struct mlx4_mfunc_master_ctx master; +}; + +struct mlx4_cmd_context; + +struct mlx4_cmd { + struct dma_pool___2 *pool; + void *hcr; + struct mutex slave_cmd_mutex; + struct semaphore poll_sem; + struct semaphore event_sem; + struct rw_semaphore switch_sem; + int max_cmds; + spinlock_t context_lock; + int free_head; + struct mlx4_cmd_context *context; + u16 token_mask; + u8 use_events; + u8 toggle; + u8 comm_toggle; + u8 initialized; +}; + +struct mlx4_uar_table { + struct mlx4_bitmap bitmap; +}; + +struct mlx4_mr_table { + struct mlx4_bitmap mpt_bitmap; + struct mlx4_buddy mtt_buddy; + u64 mtt_base; + u64 mpt_base; + struct mlx4_icm_table mtt_table; + struct mlx4_icm_table dmpt_table; +}; + +struct mlx4_cq_table { + struct mlx4_bitmap bitmap; + spinlock_t lock; + struct xarray tree; + struct mlx4_icm_table table; + struct mlx4_icm_table cmpt_table; +}; + +struct mlx4_eq_table { + struct mlx4_bitmap bitmap; + char *irq_names; + void *clr_int; + void **uar_map; + u32 clr_mask; + struct mlx4_eq *eq; + struct mlx4_icm_table table; + struct mlx4_icm_table cmpt_table; + int have_irq; + u8 inta_pin; +}; + +struct mlx4_srq_table { + struct mlx4_bitmap bitmap; + spinlock_t lock; + struct xarray tree; + struct mlx4_icm_table table; + struct mlx4_icm_table cmpt_table; +}; + +struct mlx4_zone_allocator; + +struct mlx4_qp_table { + struct mlx4_bitmap *bitmap_gen; + struct mlx4_zone_allocator *zones; + u32 zones_uids[3]; + u32 rdmarc_base; + int rdmarc_shift; + spinlock_t lock; + struct mlx4_icm_table qp_table; + struct mlx4_icm_table auxc_table; + struct mlx4_icm_table altc_table; + struct mlx4_icm_table rdmarc_table; + struct mlx4_icm_table cmpt_table; +}; + +struct mlx4_mcg_table { + struct mutex mutex; + struct mlx4_bitmap bitmap; + struct mlx4_icm_table table; +}; + +struct mlx4_catas_err { + u32 *map; + struct timer_list timer; + struct list_head list; +}; + +struct mlx4_mac_table { + __be64 entries[128]; + int refs[128]; + bool is_dup[128]; + struct mutex mutex; + int total; + int max; +}; + +struct mlx4_vlan_table { + __be32 entries[128]; + int refs[128]; + int is_dup[128]; + struct mutex mutex; + int total; + int max; +}; + +struct mlx4_roce_gid_entry { + u8 raw[16]; +}; + +struct mlx4_roce_gid_table { + struct mlx4_roce_gid_entry roce_gids[128]; + struct mutex mutex; +}; + +struct mlx4_port_info { + struct mlx4_dev *dev; + int port; + char dev_name[16]; + struct device_attribute port_attr; + enum mlx4_port_type tmp_type; + char dev_mtu_name[16]; + struct device_attribute port_mtu_attr; + struct mlx4_mac_table mac_table; + struct mlx4_vlan_table vlan_table; + struct mlx4_roce_gid_table gid_table; + int base_qpn; + struct cpu_rmap *rmap; + struct devlink_port devlink_port; +}; + +struct mlx4_sense { + struct mlx4_dev *dev; + u8 do_sense_port[3]; + u8 sense_allowed[3]; + struct delayed_work sense_poll; +}; + +struct mlx4_msix_ctl { + long unsigned int pool_bm[2]; + struct mutex pool_lock; +}; + +struct mlx4_steer; + +struct io_mapping; + +struct mlx4_priv { + struct mlx4_dev dev; + struct list_head dev_list; + struct list_head ctx_list; + spinlock_t ctx_lock; + int pci_dev_data; + int removed; + struct list_head pgdir_list; + struct mutex pgdir_mutex; + struct mlx4_fw fw; + struct mlx4_cmd cmd; + struct mlx4_mfunc mfunc; + struct mlx4_bitmap pd_bitmap; + struct mlx4_bitmap xrcd_bitmap; + struct mlx4_uar_table uar_table; + struct mlx4_mr_table mr_table; + struct mlx4_cq_table cq_table; + struct mlx4_eq_table eq_table; + struct mlx4_srq_table srq_table; + struct mlx4_qp_table qp_table; + struct mlx4_mcg_table mcg_table; + struct mlx4_bitmap counters_bitmap; + int def_counter[2]; + struct mlx4_catas_err catas_err; + void *clr_base; + struct mlx4_uar driver_uar; + void *kar; + struct mlx4_port_info port[3]; + struct mlx4_sense sense; + struct mutex port_mutex; + struct mlx4_msix_ctl msix_ctl; + struct mlx4_steer *steer; + struct list_head bf_list; + struct mutex bf_mutex; + struct io_mapping *bf_mapping; + void *clock_mapping; + int reserved_mtts; + int fs_hash_mode; + u8 virt2phys_pkey[32768]; + struct mlx4_port_map v2p; + struct mutex bond_mutex; + __be64 slave_node_guids[128]; + atomic_t opreq_count; + struct work_struct opreq_task; +}; + +enum mlx4_qp_table_zones { + MLX4_QP_TABLE_ZONE_GENERAL = 0, + MLX4_QP_TABLE_ZONE_RSS = 1, + MLX4_QP_TABLE_ZONE_RAW_ETH = 2, + MLX4_QP_TABLE_ZONE_NUM = 3, +}; + +enum mlx4_zone_alloc_flags { + MLX4_ZONE_ALLOC_FLAGS_NO_OVERLAP = 1, +}; + +struct mlx4_zone_allocator { + struct list_head entries; + struct list_head prios; + u32 last_uid; + u32 mask; + spinlock_t lock; + enum mlx4_zone_alloc_flags flags; +}; + +struct mlx4_steer { + struct list_head promisc_qps[2]; + struct list_head steer_entries[2]; +}; + +enum { + MLX4_NO_RR = 0, + MLX4_USE_RR = 1, +}; + +enum mlx4_zone_flags { + MLX4_ZONE_ALLOW_ALLOC_FROM_LOWER_PRIO = 1, + MLX4_ZONE_ALLOW_ALLOC_FROM_EQ_PRIO = 2, + MLX4_ZONE_FALLBACK_TO_HIGHER_PRIO = 4, + MLX4_ZONE_USE_RR = 8, +}; + +struct mlx4_zone_entry { + struct list_head list; + struct list_head prio_list; + u32 uid; + struct mlx4_zone_allocator *allocator; + struct mlx4_bitmap *bitmap; + int use_rr; + int priority; + int offset; + enum mlx4_zone_flags flags; +}; + +enum { + MLX4_FLAG_MSI_X = 1, + MLX4_FLAG_OLD_PORT_CMDS = 2, + MLX4_FLAG_MASTER = 4, + MLX4_FLAG_SLAVE = 8, + MLX4_FLAG_SRIOV = 16, + MLX4_FLAG_OLD_REG_MAC = 64, + MLX4_FLAG_BONDED = 128, + MLX4_FLAG_SECURE_HOST = 256, +}; + +enum { + MLX4_VF_CAP_FLAG_RESET = 1, +}; + +enum { + MLX4_DEVICE_STATE_UP = 1, + MLX4_DEVICE_STATE_INTERNAL_ERROR = 2, +}; + +enum { + MLX4_INTERFACE_STATE_UP = 1, + MLX4_INTERFACE_STATE_DELETION = 2, + MLX4_INTERFACE_STATE_NOWAIT = 4, +}; + +enum mlx4_dev_event { + MLX4_DEV_EVENT_CATASTROPHIC_ERROR = 0, + MLX4_DEV_EVENT_PORT_UP = 1, + MLX4_DEV_EVENT_PORT_DOWN = 2, + MLX4_DEV_EVENT_PORT_REINIT = 3, + MLX4_DEV_EVENT_PORT_MGMT_CHANGE = 4, + MLX4_DEV_EVENT_SLAVE_INIT = 5, + MLX4_DEV_EVENT_SLAVE_SHUTDOWN = 6, +}; + +enum { + MLX4_HCR_BASE = 525952, + MLX4_HCR_SIZE = 28, + MLX4_CLR_INT_SIZE = 8, + MLX4_SLAVE_COMM_BASE = 0, + MLX4_COMM_PAGESIZE = 4096, + MLX4_CLOCK_SIZE = 8, + MLX4_COMM_CHAN_CAPS = 8, + MLX4_COMM_CHAN_FLAGS = 12, +}; + +enum { + MLX4_CATAS_POLL_INTERVAL = 5000, +}; + +enum { + IFLA_VF_LINK_STATE_AUTO = 0, + IFLA_VF_LINK_STATE_ENABLE = 1, + IFLA_VF_LINK_STATE_DISABLE = 2, + __IFLA_VF_LINK_STATE_MAX = 3, +}; + +enum { + MLX4_DEV_CAP_FLAG2_RSS = 1, + MLX4_DEV_CAP_FLAG2_RSS_TOP = 2, + MLX4_DEV_CAP_FLAG2_RSS_XOR = 4, + MLX4_DEV_CAP_FLAG2_FS_EN = 8, + MLX4_DEV_CAP_FLAG2_REASSIGN_MAC_EN = 16, + MLX4_DEV_CAP_FLAG2_TS = 32, + MLX4_DEV_CAP_FLAG2_VLAN_CONTROL = 64, + MLX4_DEV_CAP_FLAG2_FSM = 128, + MLX4_DEV_CAP_FLAG2_UPDATE_QP = 256, + MLX4_DEV_CAP_FLAG2_DMFS_IPOIB = 512, + MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS = 1024, + MLX4_DEV_CAP_FLAG2_MAD_DEMUX = 2048, + MLX4_DEV_CAP_FLAG2_CQE_STRIDE = 4096, + MLX4_DEV_CAP_FLAG2_EQE_STRIDE = 8192, + MLX4_DEV_CAP_FLAG2_ETH_PROT_CTRL = 16384, + MLX4_DEV_CAP_FLAG2_ETH_BACKPL_AN_REP = 32768, + MLX4_DEV_CAP_FLAG2_CONFIG_DEV = 65536, + MLX4_DEV_CAP_FLAG2_SYS_EQS = 131072, + MLX4_DEV_CAP_FLAG2_80_VFS = 262144, + MLX4_DEV_CAP_FLAG2_FS_A0 = 524288, + MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT = 1048576, + MLX4_DEV_CAP_FLAG2_PORT_REMAP = 2097152, + MLX4_DEV_CAP_FLAG2_QCN = 4194304, + MLX4_DEV_CAP_FLAG2_QP_RATE_LIMIT = 8388608, + MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN = 16777216, + MLX4_DEV_CAP_FLAG2_QOS_VPP = 33554432, + MLX4_DEV_CAP_FLAG2_ETS_CFG = 67108864, + MLX4_DEV_CAP_FLAG2_PORT_BEACON = 134217728, + MLX4_DEV_CAP_FLAG2_IGNORE_FCS = 268435456, + MLX4_DEV_CAP_FLAG2_PHV_EN = 536870912, + MLX4_DEV_CAP_FLAG2_SKIP_OUTER_VLAN = 1073741824, + MLX4_DEV_CAP_FLAG2_UPDATE_QP_SRC_CHECK_LB = 2147483648, + MLX4_DEV_CAP_FLAG2_LB_SRC_CHK = 0, + MLX4_DEV_CAP_FLAG2_ROCE_V1_V2 = 0, + MLX4_DEV_CAP_FLAG2_DMFS_UC_MC_SNIFFER = 0, + MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT = 0, + MLX4_DEV_CAP_FLAG2_SVLAN_BY_QP = 0, + MLX4_DEV_CAP_FLAG2_SL_TO_VL_CHANGE_EVENT = 0, + MLX4_DEV_CAP_FLAG2_USER_MAC_EN = 0, + MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW = 0, + MLX4_DEV_CAP_FLAG2_SW_CQ_INIT = 0, +}; + +enum mlx4_event { + MLX4_EVENT_TYPE_COMP = 0, + MLX4_EVENT_TYPE_PATH_MIG = 1, + MLX4_EVENT_TYPE_COMM_EST = 2, + MLX4_EVENT_TYPE_SQ_DRAINED = 3, + MLX4_EVENT_TYPE_SRQ_QP_LAST_WQE = 19, + MLX4_EVENT_TYPE_SRQ_LIMIT = 20, + MLX4_EVENT_TYPE_CQ_ERROR = 4, + MLX4_EVENT_TYPE_WQ_CATAS_ERROR = 5, + MLX4_EVENT_TYPE_EEC_CATAS_ERROR = 6, + MLX4_EVENT_TYPE_PATH_MIG_FAILED = 7, + MLX4_EVENT_TYPE_WQ_INVAL_REQ_ERROR = 16, + MLX4_EVENT_TYPE_WQ_ACCESS_ERROR = 17, + MLX4_EVENT_TYPE_SRQ_CATAS_ERROR = 18, + MLX4_EVENT_TYPE_LOCAL_CATAS_ERROR = 8, + MLX4_EVENT_TYPE_PORT_CHANGE = 9, + MLX4_EVENT_TYPE_EQ_OVERFLOW = 15, + MLX4_EVENT_TYPE_ECC_DETECT = 14, + MLX4_EVENT_TYPE_CMD = 10, + MLX4_EVENT_TYPE_VEP_UPDATE = 25, + MLX4_EVENT_TYPE_COMM_CHANNEL = 24, + MLX4_EVENT_TYPE_OP_REQUIRED = 26, + MLX4_EVENT_TYPE_FATAL_WARNING = 27, + MLX4_EVENT_TYPE_FLR_EVENT = 28, + MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT = 29, + MLX4_EVENT_TYPE_RECOVERABLE_ERROR_EVENT = 62, + MLX4_EVENT_TYPE_NONE = 255, +}; + +enum { + MLX4_PORT_CHANGE_SUBTYPE_DOWN = 1, + MLX4_PORT_CHANGE_SUBTYPE_ACTIVE = 4, +}; + +struct mlx4_counter { + u8 reserved1[3]; + u8 counter_mode; + __be32 num_ifc; + u32 reserved2[2]; + __be64 rx_frames; + __be64 rx_bytes; + __be64 tx_frames; + __be64 tx_bytes; +}; + +struct mlx4_slaves_pport { + long unsigned int slaves[2]; +}; + +enum { + MLX4_CMD_SYS_EN = 1, + MLX4_CMD_SYS_DIS = 2, + MLX4_CMD_MAP_FA = 4095, + MLX4_CMD_UNMAP_FA = 4094, + MLX4_CMD_RUN_FW = 4086, + MLX4_CMD_MOD_STAT_CFG = 52, + MLX4_CMD_QUERY_DEV_CAP = 3, + MLX4_CMD_QUERY_FW = 4, + MLX4_CMD_ENABLE_LAM = 4088, + MLX4_CMD_DISABLE_LAM = 4087, + MLX4_CMD_QUERY_DDR = 5, + MLX4_CMD_QUERY_ADAPTER = 6, + MLX4_CMD_INIT_HCA = 7, + MLX4_CMD_CLOSE_HCA = 8, + MLX4_CMD_INIT_PORT = 9, + MLX4_CMD_CLOSE_PORT = 10, + MLX4_CMD_QUERY_HCA = 11, + MLX4_CMD_QUERY_PORT = 67, + MLX4_CMD_SENSE_PORT = 77, + MLX4_CMD_HW_HEALTH_CHECK = 80, + MLX4_CMD_SET_PORT = 12, + MLX4_CMD_SET_NODE = 90, + MLX4_CMD_QUERY_FUNC = 86, + MLX4_CMD_ACCESS_DDR = 46, + MLX4_CMD_MAP_ICM = 4090, + MLX4_CMD_UNMAP_ICM = 4089, + MLX4_CMD_MAP_ICM_AUX = 4092, + MLX4_CMD_UNMAP_ICM_AUX = 4091, + MLX4_CMD_SET_ICM_SIZE = 4093, + MLX4_CMD_ACCESS_REG = 59, + MLX4_CMD_ALLOCATE_VPP = 128, + MLX4_CMD_SET_VPORT_QOS = 129, + MLX4_CMD_INFORM_FLR_DONE = 91, + MLX4_CMD_VIRT_PORT_MAP = 92, + MLX4_CMD_GET_OP_REQ = 89, + MLX4_CMD_SW2HW_MPT = 13, + MLX4_CMD_QUERY_MPT = 14, + MLX4_CMD_HW2SW_MPT = 15, + MLX4_CMD_READ_MTT = 16, + MLX4_CMD_WRITE_MTT = 17, + MLX4_CMD_SYNC_TPT = 47, + MLX4_CMD_MAP_EQ = 18, + MLX4_CMD_SW2HW_EQ = 19, + MLX4_CMD_HW2SW_EQ = 20, + MLX4_CMD_QUERY_EQ = 21, + MLX4_CMD_SW2HW_CQ = 22, + MLX4_CMD_HW2SW_CQ = 23, + MLX4_CMD_QUERY_CQ = 24, + MLX4_CMD_MODIFY_CQ = 44, + MLX4_CMD_SW2HW_SRQ = 53, + MLX4_CMD_HW2SW_SRQ = 54, + MLX4_CMD_QUERY_SRQ = 55, + MLX4_CMD_ARM_SRQ = 64, + MLX4_CMD_RST2INIT_QP = 25, + MLX4_CMD_INIT2RTR_QP = 26, + MLX4_CMD_RTR2RTS_QP = 27, + MLX4_CMD_RTS2RTS_QP = 28, + MLX4_CMD_SQERR2RTS_QP = 29, + MLX4_CMD_2ERR_QP = 30, + MLX4_CMD_RTS2SQD_QP = 31, + MLX4_CMD_SQD2SQD_QP = 56, + MLX4_CMD_SQD2RTS_QP = 32, + MLX4_CMD_2RST_QP = 33, + MLX4_CMD_QUERY_QP = 34, + MLX4_CMD_INIT2INIT_QP = 45, + MLX4_CMD_SUSPEND_QP = 50, + MLX4_CMD_UNSUSPEND_QP = 51, + MLX4_CMD_UPDATE_QP = 97, + MLX4_CMD_CONF_SPECIAL_QP = 35, + MLX4_CMD_MAD_IFC = 36, + MLX4_CMD_MAD_DEMUX = 515, + MLX4_CMD_READ_MCG = 37, + MLX4_CMD_WRITE_MCG = 38, + MLX4_CMD_MGID_HASH = 39, + MLX4_CMD_DIAG_RPRT = 48, + MLX4_CMD_NOP = 49, + MLX4_CMD_CONFIG_DEV = 58, + MLX4_CMD_ACCESS_MEM = 46, + MLX4_CMD_SET_VEP = 82, + MLX4_CMD_SET_VLAN_FLTR = 71, + MLX4_CMD_SET_MCAST_FLTR = 72, + MLX4_CMD_DUMP_ETH_STATS = 73, + MLX4_CMD_ARM_COMM_CHANNEL = 87, + MLX4_CMD_GEN_EQE = 88, + MLX4_CMD_ALLOC_RES = 3840, + MLX4_CMD_FREE_RES = 3841, + MLX4_CMD_MCAST_ATTACH = 3845, + MLX4_CMD_UCAST_ATTACH = 3846, + MLX4_CMD_PROMISC = 3848, + MLX4_CMD_QUERY_FUNC_CAP = 3850, + MLX4_CMD_QP_ATTACH = 3851, + MLX4_CMD_QUERY_DEBUG_MSG = 42, + MLX4_CMD_SET_DEBUG_MSG = 43, + MLX4_CMD_QUERY_IF_STAT = 84, + MLX4_CMD_SET_IF_STAT = 85, + MLX4_QP_FLOW_STEERING_ATTACH = 101, + MLX4_QP_FLOW_STEERING_DETACH = 102, + MLX4_FLOW_STEERING_IB_UC_QP_RANGE = 100, + MLX4_CMD_CONGESTION_CTRL_OPCODE = 104, +}; + +enum { + MLX4_CMD_TIME_CLASS_A = 60000, + MLX4_CMD_TIME_CLASS_B = 60000, + MLX4_CMD_TIME_CLASS_C = 60000, +}; + +enum { + MLX4_MAILBOX_SIZE = 4096, + MLX4_ACCESS_MEM_ALIGN = 256, +}; + +enum { + MLX4_SET_PORT_IB_OPCODE = 0, + MLX4_SET_PORT_ETH_OPCODE = 1, + MLX4_SET_PORT_BEACON_OPCODE = 4, +}; + +enum { + MLX4_CMD_WRAPPED = 0, + MLX4_CMD_NATIVE = 1, +}; + +struct mlx4_cmd_mailbox { + void *buf; + dma_addr_t dma; +}; + +enum { + IB_USER_MAD_USER_RMPP = 1, +}; + +enum { + IB_MGMT_MAD_HDR = 24, + IB_MGMT_MAD_DATA = 232, + IB_MGMT_RMPP_HDR = 36, + IB_MGMT_RMPP_DATA = 220, + IB_MGMT_VENDOR_HDR = 40, + IB_MGMT_VENDOR_DATA = 216, + IB_MGMT_SA_HDR = 56, + IB_MGMT_SA_DATA = 200, + IB_MGMT_DEVICE_HDR = 64, + IB_MGMT_DEVICE_DATA = 192, + IB_MGMT_MAD_SIZE = 256, + OPA_MGMT_MAD_DATA = 2024, + OPA_MGMT_RMPP_DATA = 2012, + OPA_MGMT_MAD_SIZE = 2048, +}; + +struct ib_smp { + u8 base_version; + u8 mgmt_class; + u8 class_version; + u8 method; + __be16 status; + u8 hop_ptr; + u8 hop_cnt; + __be64 tid; + __be16 attr_id; + __be16 resv; + __be32 attr_mod; + __be64 mkey; + __be16 dr_slid; + __be16 dr_dlid; + u8 reserved[28]; + u8 data[64]; + u8 initial_path[64]; + u8 return_path[64]; +}; + +struct mlx4_vport_qos_param { + u32 bw_share; + u32 max_avg_bw; + u8 enable; +}; + +enum { + MLX4_COMM_CMD_RESET = 0, + MLX4_COMM_CMD_VHCR0 = 1, + MLX4_COMM_CMD_VHCR1 = 2, + MLX4_COMM_CMD_VHCR2 = 3, + MLX4_COMM_CMD_VHCR_EN = 4, + MLX4_COMM_CMD_VHCR_POST = 5, + MLX4_COMM_CMD_FLR = 254, +}; + +enum { + MLX4_VF_SMI_DISABLED = 0, + MLX4_VF_SMI_ENABLED = 1, +}; + +struct mlx4_vhcr { + u64 in_param; + u64 out_param; + u32 in_modifier; + u32 errno; + u16 op; + u16 token; + u8 op_modifier; + u8 e_bit; +}; + +struct mlx4_cmd_info { + u16 opcode; + bool has_inbox; + bool has_outbox; + bool out_is_imm; + bool encode_slave_id; + int (*verify)(struct mlx4_dev *, int, struct mlx4_vhcr *, struct mlx4_cmd_mailbox *); + int (*wrapper)(struct mlx4_dev *, int, struct mlx4_vhcr *, struct mlx4_cmd_mailbox *, struct mlx4_cmd_mailbox *, struct mlx4_cmd_info *); +}; + +struct mlx4_icm { + struct list_head chunk_list; + int refcount; +}; + +struct mlx4_cmd_context { + struct completion done; + int result; + int next; + u64 out_param; + u16 token; + u8 fw_status; +}; + +enum { + MLX4_VF_IMMED_VLAN_FLAG_VLAN = 1, + MLX4_VF_IMMED_VLAN_FLAG_QOS = 2, + MLX4_VF_IMMED_VLAN_FLAG_LINK_DISABLE = 4, +}; + +struct mlx4_vf_immed_vlan_work { + struct work_struct work; + struct mlx4_priv *priv; + int flags; + int slave; + int vlan_ix; + int orig_vlan_ix; + u8 port; + u8 qos; + u8 qos_vport; + u16 vlan_id; + u16 orig_vlan_id; + __be16 vlan_proto; +}; + +enum { + MLX4_CMD_CLEANUP_STRUCT = 1, + MLX4_CMD_CLEANUP_POOL = 2, + MLX4_CMD_CLEANUP_HCR = 4, + MLX4_CMD_CLEANUP_VHCR = 8, + MLX4_CMD_CLEANUP_ALL = 15, +}; + +enum { + CMD_STAT_OK = 0, + CMD_STAT_INTERNAL_ERR = 1, + CMD_STAT_BAD_OP = 2, + CMD_STAT_BAD_PARAM = 3, + CMD_STAT_BAD_SYS_STATE = 4, + CMD_STAT_BAD_RESOURCE = 5, + CMD_STAT_RESOURCE_BUSY = 6, + CMD_STAT_EXCEED_LIM = 8, + CMD_STAT_BAD_RES_STATE = 9, + CMD_STAT_BAD_INDEX = 10, + CMD_STAT_BAD_NVMEM = 11, + CMD_STAT_ICM_ERROR = 12, + CMD_STAT_BAD_QP_STATE = 16, + CMD_STAT_BAD_SEG_PARAM = 32, + CMD_STAT_REG_BOUND = 33, + CMD_STAT_LAM_NOT_PRE = 34, + CMD_STAT_BAD_PKT = 48, + CMD_STAT_BAD_SIZE = 64, + CMD_STAT_MULTI_FUNC_REQ = 80, +}; + +enum { + HCR_IN_PARAM_OFFSET = 0, + HCR_IN_MODIFIER_OFFSET = 8, + HCR_OUT_PARAM_OFFSET = 12, + HCR_TOKEN_OFFSET = 20, + HCR_STATUS_OFFSET = 24, + HCR_OPMOD_SHIFT = 12, + HCR_T_BIT = 21, + HCR_E_BIT = 22, + HCR_GO_BIT = 23, +}; + +enum { + GO_BIT_TIMEOUT_MSECS = 10000, +}; + +struct mlx4_cq { + void (*comp)(struct mlx4_cq *); + void (*event)(struct mlx4_cq *, enum mlx4_event); + struct mlx4_uar *uar; + u32 cons_index; + u16 irq; + __be32 *set_ci_db; + __be32 *arm_db; + int arm_sn; + int cqn; + unsigned int vector; + refcount_t refcount; + struct completion free; + struct { + struct list_head list; + void (*comp)(struct mlx4_cq *); + void *priv; + } tasklet_ctx; + int reset_notify_added; + struct list_head reset_notify; + u8 usage; +}; + +enum mlx4_alloc_mode { + RES_OP_RESERVE = 0, + RES_OP_RESERVE_AND_MAP = 1, + RES_OP_MAP_ICM = 2, +}; + +struct mlx4_cq_context { + __be32 flags; + u16 reserved1[3]; + __be16 page_offset; + __be32 logsize_usrpage; + __be16 cq_period; + __be16 cq_max_count; + u8 reserved2[3]; + u8 comp_eqn; + u8 log_page_size; + u8 reserved3[2]; + u8 mtt_base_addr_h; + __be32 mtt_base_addr_l; + __be32 last_notified_index; + __be32 solicit_producer_index; + __be32 consumer_index; + __be32 producer_index; + u32 reserved4[2]; + __be64 db_rec_addr; +}; + +enum { + MLX4_ICM_PAGE_SHIFT = 12, + MLX4_ICM_PAGE_SIZE = 4096, +}; + +enum { + MLX4_DEV_CAP_FLAG_RC = 1, + MLX4_DEV_CAP_FLAG_UC = 2, + MLX4_DEV_CAP_FLAG_UD = 4, + MLX4_DEV_CAP_FLAG_XRC = 8, + MLX4_DEV_CAP_FLAG_SRQ = 64, + MLX4_DEV_CAP_FLAG_IPOIB_CSUM = 128, + MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR = 256, + MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR = 512, + MLX4_DEV_CAP_FLAG_DPDP = 4096, + MLX4_DEV_CAP_FLAG_BLH = 32768, + MLX4_DEV_CAP_FLAG_MEM_WINDOW = 65536, + MLX4_DEV_CAP_FLAG_APM = 131072, + MLX4_DEV_CAP_FLAG_ATOMIC = 262144, + MLX4_DEV_CAP_FLAG_RAW_MCAST = 524288, + MLX4_DEV_CAP_FLAG_UD_AV_PORT = 1048576, + MLX4_DEV_CAP_FLAG_UD_MCAST = 2097152, + MLX4_DEV_CAP_FLAG_IBOE = 1073741824, + MLX4_DEV_CAP_FLAG_UC_LOOPBACK = 0, + MLX4_DEV_CAP_FLAG_FCS_KEEP = 0, + MLX4_DEV_CAP_FLAG_WOL_PORT1 = 0, + MLX4_DEV_CAP_FLAG_WOL_PORT2 = 0, + MLX4_DEV_CAP_FLAG_UDP_RSS = 0, + MLX4_DEV_CAP_FLAG_VEP_UC_STEER = 0, + MLX4_DEV_CAP_FLAG_VEP_MC_STEER = 0, + MLX4_DEV_CAP_FLAG_COUNTERS = 0, + MLX4_DEV_CAP_FLAG_RSS_IP_FRAG = 0, + MLX4_DEV_CAP_FLAG_SET_ETH_SCHED = 0, + MLX4_DEV_CAP_FLAG_SENSE_SUPPORT = 0, + MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV = 0, + MLX4_DEV_CAP_FLAG_64B_EQE = 0, + MLX4_DEV_CAP_FLAG_64B_CQE = 0, +}; + +enum { + MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_BAD_CABLE = 1, + MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_UNSUPPORTED_CABLE = 2, +}; + +enum { + MLX4_FATAL_WARNING_SUBTYPE_WARMING = 0, +}; + +enum slave_port_gen_event { + SLAVE_PORT_GEN_EVENT_DOWN = 0, + SLAVE_PORT_GEN_EVENT_UP = 1, + SLAVE_PORT_GEN_EVENT_NONE = 2, +}; + +enum slave_port_state_event { + MLX4_PORT_STATE_DEV_EVENT_PORT_DOWN = 0, + MLX4_PORT_STATE_DEV_EVENT_PORT_UP = 1, + MLX4_PORT_STATE_IB_PORT_STATE_EVENT_GID_VALID = 2, + MLX4_PORT_STATE_IB_EVENT_GID_INVALID = 3, +}; + +enum { + MLX4_DEV_PMC_SUBTYPE_GUID_INFO = 20, + MLX4_DEV_PMC_SUBTYPE_PORT_INFO = 21, + MLX4_DEV_PMC_SUBTYPE_PKEY_TABLE = 22, + MLX4_DEV_PMC_SUBTYPE_SL_TO_VL_MAP = 23, +}; + +struct mlx4_eq_context { + __be32 flags; + u16 reserved1[3]; + __be16 page_offset; + u8 log_eq_size; + u8 reserved2[4]; + u8 eq_period; + u8 reserved3; + u8 eq_max_count; + u8 reserved4[3]; + u8 intr; + u8 log_page_size; + u8 reserved5[2]; + u8 mtt_base_addr_h; + __be32 mtt_base_addr_l; + u32 reserved6[2]; + __be32 consumer_index; + __be32 producer_index; + u32 reserved7[4]; +}; + +struct mlx4_port_cap { + u8 link_state; + u8 supported_port_types; + u8 suggested_type; + u8 default_sense; + u8 log_max_macs; + u8 log_max_vlans; + int ib_mtu; + int max_port_width; + int max_vl; + int max_tc_eth; + int max_gids; + int max_pkeys; + u64 def_mac; + u16 eth_mtu; + int trans_type; + int vendor_oui; + u16 wavelength; + u64 trans_code; + u8 dmfs_optimized_state; +}; + +enum { + MLX4_IRQNAME_SIZE = 32, +}; + +enum { + MLX4_NUM_ASYNC_EQE = 256, + MLX4_NUM_SPARE_EQE = 128, + MLX4_EQ_ENTRY_SIZE = 32, +}; + +enum { + MLX4_STEERING_MODE_A0 = 0, + MLX4_STEERING_MODE_B0 = 1, + MLX4_STEERING_MODE_DEVICE_MANAGED = 2, +}; + +enum { + MLX4_STEERING_DMFS_A0_DEFAULT = 0, + MLX4_STEERING_DMFS_A0_DYNAMIC = 1, + MLX4_STEERING_DMFS_A0_STATIC = 2, + MLX4_STEERING_DMFS_A0_DISABLE = 3, + MLX4_STEERING_DMFS_A0_NOT_SUPPORTED = 4, +}; + +enum { + MLX4_QUERY_FUNC_FLAGS_BF_RES_QP = 1, + MLX4_QUERY_FUNC_FLAGS_A0_RES_QP = 2, +}; + +enum { + MLX4_DEV_CAP_64B_EQE_ENABLED = 1, + MLX4_DEV_CAP_64B_CQE_ENABLED = 2, + MLX4_DEV_CAP_CQE_STRIDE_ENABLED = 4, + MLX4_DEV_CAP_EQE_STRIDE_ENABLED = 8, +}; + +enum { + MLX4_FLAG_PORT_REMAP = 16777216, + MLX4_FLAG_ROCE_V1_V2 = 524288, +}; + +struct mlx4_qp { + void (*event)(struct mlx4_qp *, enum mlx4_event); + int qpn; + refcount_t refcount; + struct completion free; + u8 usage; +}; + +enum mlx4_access_reg_method { + MLX4_ACCESS_REG_QUERY = 1, + MLX4_ACCESS_REG_WRITE = 2, +}; + +struct mlx4_ptys_reg { + u8 flags; + u8 local_port; + u8 resrvd2; + u8 proto_mask; + __be32 resrvd3[2]; + __be32 eth_proto_cap; + __be16 ib_width_cap; + __be16 ib_speed_cap; + __be32 resrvd4; + __be32 eth_proto_admin; + __be16 ib_width_admin; + __be16 ib_speed_admin; + __be32 resrvd5; + __be32 eth_proto_oper; + __be16 ib_width_oper; + __be16 ib_speed_oper; + __be32 resrvd6; + __be32 eth_proto_lp_adv; +}; + +enum { + MLX4_GET_PORT_VIRT2PHY = 0, + MLX4_SET_PORT_VIRT2PHY = 1, +}; + +enum { + MLX4_SET_PORT_GENERAL = 0, + MLX4_SET_PORT_RQP_CALC = 1, + MLX4_SET_PORT_MAC_TABLE = 2, + MLX4_SET_PORT_VLAN_TABLE = 3, + MLX4_SET_PORT_PRIO_MAP = 4, + MLX4_SET_PORT_GID_TABLE = 5, + MLX4_SET_PORT_PRIO2TC = 8, + MLX4_SET_PORT_SCHEDULER = 9, + MLX4_SET_PORT_VXLAN = 11, + MLX4_SET_PORT_ROCE_ADDR = 13, +}; + +enum { + MLX4_CMD_MAD_DEMUX_CONFIG = 0, + MLX4_CMD_MAD_DEMUX_QUERY_STATE = 1, + MLX4_CMD_MAD_DEMUX_QUERY_RESTR = 2, +}; + +enum mlx4_rx_csum_mode { + MLX4_RX_CSUM_MODE_VAL_NON_TCP_UDP = 1, + MLX4_RX_CSUM_MODE_L4 = 2, + MLX4_RX_CSUM_MODE_IP_OK_IP_NON_TCP_UDP = 4, + MLX4_RX_CSUM_MODE_MULTI_VLAN = 8, +}; + +struct mlx4_config_dev_params { + u16 vxlan_udp_dport; + u8 rx_csum_flags_port_1; + u8 rx_csum_flags_port_2; +}; + +enum { + MLX4_USER_DEV_CAP_LARGE_CQE = 1, +}; + +struct mlx4_mgm { + __be32 next_gid_index; + __be32 members_count; + u32 reserved[2]; + u8 gid[16]; + __be32 qp[1016]; +}; + +struct mlx4_set_port_general_context { + u16 reserved1; + u8 flags2; + u8 flags; + union { + u8 ignore_fcs; + u8 roce_mode; + }; + u8 reserved2; + __be16 mtu; + u8 pptx; + u8 pfctx; + u16 reserved3; + u8 pprx; + u8 pfcrx; + u16 reserved4; + u32 reserved5; + u8 phv_en; + u8 reserved6[5]; + __be16 user_mtu; + u16 reserved7; + u8 user_mac[6]; +}; + +struct mlx4_icm_buf { + void *addr; + size_t size; + dma_addr_t dma_addr; +}; + +struct mlx4_icm_chunk { + struct list_head list; + int npages; + int nsg; + bool coherent; + union { + struct scatterlist sg[7]; + struct mlx4_icm_buf buf[7]; + }; +}; + +struct mlx4_icm_iter { + struct mlx4_icm *icm; + struct mlx4_icm_chunk *chunk; + int page_idx; +}; + +struct mlx4_mod_stat_cfg { + u8 log_pg_sz; + u8 log_pg_sz_m; +}; + +struct mlx4_dev_cap { + int max_srq_sz; + int max_qp_sz; + int reserved_qps; + int max_qps; + int reserved_srqs; + int max_srqs; + int max_cq_sz; + int reserved_cqs; + int max_cqs; + int max_mpts; + int reserved_eqs; + int max_eqs; + int num_sys_eqs; + int reserved_mtts; + int reserved_mrws; + int max_requester_per_qp; + int max_responder_per_qp; + int max_rdma_global; + int local_ca_ack_delay; + int num_ports; + u32 max_msg_sz; + u16 stat_rate_support; + int fs_log_max_ucast_qp_range_size; + int fs_max_num_qp_per_entry; + u64 flags; + u64 flags2; + int reserved_uars; + int uar_size; + int min_page_sz; + int bf_reg_size; + int bf_regs_per_page; + int max_sq_sg; + int max_sq_desc_sz; + int max_rq_sg; + int max_rq_desc_sz; + int max_qp_per_mcg; + int reserved_mgms; + int max_mcgs; + int reserved_pds; + int max_pds; + int reserved_xrcds; + int max_xrcds; + int qpc_entry_sz; + int rdmarc_entry_sz; + int altc_entry_sz; + int aux_entry_sz; + int srq_entry_sz; + int cqc_entry_sz; + int eqc_entry_sz; + int dmpt_entry_sz; + int cmpt_entry_sz; + int mtt_entry_sz; + int resize_srq; + u32 bmme_flags; + u32 reserved_lkey; + u64 max_icm_sz; + int max_gso_sz; + int max_rss_tbl_sz; + u32 max_counters; + u32 dmfs_high_rate_qpn_base; + u32 dmfs_high_rate_qpn_range; + struct mlx4_rate_limit_caps rl_caps; + u32 health_buffer_addrs; + struct mlx4_port_cap port_cap[3]; + bool wol_port[3]; +}; + +struct mlx4_func_cap { + u8 num_ports; + u8 flags; + u32 pf_context_behaviour; + int qp_quota; + int cq_quota; + int srq_quota; + int mpt_quota; + int mtt_quota; + int max_eq; + int reserved_eq; + int mcg_quota; + struct mlx4_spec_qps spec_qps; + u32 reserved_lkey; + u8 physical_port; + u8 flags0; + u8 flags1; + u64 phys_port_id; + u32 extra_flags; +}; + +struct mlx4_func { + int bus; + int device; + int function; + int physical_function; + int rsvd_eqs; + int max_eq; + int rsvd_uars; +}; + +struct mlx4_adapter { + char board_id[64]; + u8 inta_pin; +}; + +struct mlx4_init_hca_param { + u64 qpc_base; + u64 rdmarc_base; + u64 auxc_base; + u64 altc_base; + u64 srqc_base; + u64 cqc_base; + u64 eqc_base; + u64 mc_base; + u64 dmpt_base; + u64 cmpt_base; + u64 mtt_base; + u64 global_caps; + u16 log_mc_entry_sz; + u16 log_mc_hash_sz; + u16 hca_core_clock; + u8 log_num_qps; + u8 log_num_srqs; + u8 log_num_cqs; + u8 log_num_eqs; + u16 num_sys_eqs; + u8 log_rd_per_qp; + u8 log_mc_table_sz; + u8 log_mpt_sz; + u8 log_uar_sz; + u8 mw_enabled; + u8 uar_page_sz; + u8 steering_mode; + u8 dmfs_high_steer_mode; + u64 dev_cap_enabled; + u16 cqe_size; + u16 eqe_size; + u8 rss_ip_frags; + u8 phv_check_en; +}; + +enum { + MLX4_COMMAND_INTERFACE_MIN_REV = 2, + MLX4_COMMAND_INTERFACE_MAX_REV = 3, + MLX4_COMMAND_INTERFACE_NEW_PORT_CMDS = 3, +}; + +struct mlx4_config_dev { + __be32 update_flags; + __be32 rsvd1[3]; + __be16 vxlan_udp_dport; + __be16 rsvd2; + __be16 roce_v2_entropy; + __be16 roce_v2_udp_dport; + __be32 roce_flags; + __be32 rsvd4[25]; + __be16 rsvd5; + u8 rsvd6; + u8 rx_checksum_val; +}; + +enum { + ADD_TO_MCG = 38, +}; + +enum mlx4_access_reg_masks { + MLX4_ACCESS_REG_STATUS_MASK = 127, + MLX4_ACCESS_REG_METHOD_MASK = 127, + MLX4_ACCESS_REG_LEN_MASK = 2047, +}; + +struct mlx4_access_reg { + __be16 constant1; + u8 status; + u8 resrvd1; + __be16 reg_id; + u8 method; + u8 constant2; + __be32 resrvd2[2]; + __be16 len_const; + __be16 resrvd3; + u8 reg_data[4076]; +}; + +enum mlx4_reg_id { + MLX4_REG_ID_PTYS = 20484, +}; + +enum { + MLX4_ALLOCATE_VPP_ALLOCATE = 0, + MLX4_ALLOCATE_VPP_QUERY = 1, +}; + +enum { + MLX4_SET_VPORT_QOS_SET = 0, + MLX4_SET_VPORT_QOS_QUERY = 1, +}; + +struct mlx4_set_port_prio2tc_context { + u8 prio2tc[4]; +}; + +struct mlx4_port_scheduler_tc_cfg_be { + __be16 pg; + __be16 bw_precentage; + __be16 max_bw_units; + __be16 max_bw_value; +}; + +struct mlx4_set_port_scheduler_context { + struct mlx4_port_scheduler_tc_cfg_be tc[8]; +}; + +struct mlx4_alloc_vpp_param { + __be32 available_vpp; + __be32 vpp_p_up[8]; +}; + +struct mlx4_prio_qos_param { + __be32 bw_share; + __be32 max_avg_bw; + __be32 reserved; + __be32 enable; + __be32 reserved1[4]; +}; + +struct mlx4_set_vport_context { + __be32 reserved[8]; + struct mlx4_prio_qos_param qos_p_up[8]; +}; + +enum { + MLX4_ICM_ALLOC_SIZE = 262144, + MLX4_TABLE_CHUNK_SIZE = 262144, +}; + +enum mlx4_protocol { + MLX4_PROT_IB_IPV6 = 0, + MLX4_PROT_ETH = 1, + MLX4_PROT_IB_IPV4 = 2, + MLX4_PROT_FCOE = 3, +}; + +enum { + MLX4_INTFF_BONDING = 1, +}; + +struct mlx4_interface { + void * (*add)(struct mlx4_dev *); + void (*remove)(struct mlx4_dev *, void *); + void (*event)(struct mlx4_dev *, void *, enum mlx4_dev_event, long unsigned int); + void * (*get_dev)(struct mlx4_dev *, void *, u8); + void (*activate)(struct mlx4_dev *, void *); + struct list_head list; + enum mlx4_protocol protocol; + int flags; +}; + +struct mlx4_device_context { + struct list_head list; + struct list_head bond_list; + struct mlx4_interface *intf; + void *context; +}; + +struct io_mapping { + resource_size_t base; + long unsigned int size; + pgprot_t prot; + void *iomem; +}; + +enum devlink_param_cmode { + DEVLINK_PARAM_CMODE_RUNTIME = 0, + DEVLINK_PARAM_CMODE_DRIVERINIT = 1, + DEVLINK_PARAM_CMODE_PERMANENT = 2, + __DEVLINK_PARAM_CMODE_MAX = 3, + DEVLINK_PARAM_CMODE_MAX = 2, +}; + +enum devlink_param_type { + DEVLINK_PARAM_TYPE_U8 = 0, + DEVLINK_PARAM_TYPE_U16 = 1, + DEVLINK_PARAM_TYPE_U32 = 2, + DEVLINK_PARAM_TYPE_STRING = 3, + DEVLINK_PARAM_TYPE_BOOL = 4, +}; + +union devlink_param_value { + u8 vu8; + u16 vu16; + u32 vu32; + char vstr[32]; + bool vbool; +}; + +struct devlink_param_gset_ctx { + union devlink_param_value val; + enum devlink_param_cmode cmode; +}; + +struct devlink_param { + u32 id; + const char *name; + bool generic; + enum devlink_param_type type; + long unsigned int supported_cmodes; + int (*get)(struct devlink *, u32, struct devlink_param_gset_ctx *); + int (*set)(struct devlink *, u32, struct devlink_param_gset_ctx *); + int (*validate)(struct devlink *, u32, union devlink_param_value, struct netlink_ext_ack *); +}; + +enum devlink_param_generic_id { + DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET = 0, + DEVLINK_PARAM_GENERIC_ID_MAX_MACS = 1, + DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV = 2, + DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT = 3, + DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI = 4, + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX = 5, + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN = 6, + DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY = 7, + DEVLINK_PARAM_GENERIC_ID_RESET_DEV_ON_DRV_PROBE = 8, + DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE = 9, + DEVLINK_PARAM_GENERIC_ID_ENABLE_REMOTE_DEV_RESET = 10, + __DEVLINK_PARAM_GENERIC_ID_MAX = 11, + DEVLINK_PARAM_GENERIC_ID_MAX = 10, +}; + +enum { + MLX4_TUNNEL_OFFLOAD_MODE_NONE = 0, + MLX4_TUNNEL_OFFLOAD_MODE_VXLAN = 1, +}; + +enum { + MLX4_RESERVE_A0_QP = 64, + MLX4_RESERVE_ETH_BF_QP = 128, +}; + +enum { + MLX4_FUNC_CAP_64B_EQE_CQE = 1, + MLX4_FUNC_CAP_EQE_CQE_STRIDE = 2, + MLX4_FUNC_CAP_DMFS_A0_STATIC = 4, +}; + +enum mlx4_resource_usage { + MLX4_RES_USAGE_NONE = 0, + MLX4_RES_USAGE_DRIVER = 1, + MLX4_RES_USAGE_USER_VERBS = 2, +}; + +enum { + MLX4_NUM_FEXCH = 65536, +}; + +struct mlx4_clock_params { + u64 offset; + u8 bar; + u8 size; +}; + +enum { + MLX4_DOMAIN_UVERBS = 4096, + MLX4_DOMAIN_ETHTOOL = 8192, + MLX4_DOMAIN_RFS = 12288, + MLX4_DOMAIN_NIC = 20480, +}; + +struct mlx4_net_trans_rule_hw_ctrl { + __be16 prio; + u8 type; + u8 flags; + u8 rsvd1; + u8 funcid; + u8 vep; + u8 port; + __be32 qpn; + __be32 rsvd2; +}; + +struct mlx4_net_trans_rule_hw_ib { + u8 size; + u8 rsvd1; + __be16 id; + u32 rsvd2; + __be32 l3_qpn; + __be32 qpn_mask; + u8 dst_gid[16]; + u8 dst_gid_msk[16]; +}; + +struct mlx4_net_trans_rule_hw_eth { + u8 size; + u8 rsvd; + __be16 id; + u8 rsvd1[6]; + u8 dst_mac[6]; + u16 rsvd2; + u8 dst_mac_msk[6]; + u16 rsvd3; + u8 src_mac[6]; + u16 rsvd4; + u8 src_mac_msk[6]; + u8 rsvd5; + u8 ether_type_enable; + __be16 ether_type; + __be16 vlan_tag_msk; + __be16 vlan_tag; +}; + +struct mlx4_net_trans_rule_hw_tcp_udp { + u8 size; + u8 rsvd; + __be16 id; + __be16 rsvd1[3]; + __be16 dst_port; + __be16 rsvd2; + __be16 dst_port_msk; + __be16 rsvd3; + __be16 src_port; + __be16 rsvd4; + __be16 src_port_msk; +}; + +struct mlx4_net_trans_rule_hw_ipv4 { + u8 size; + u8 rsvd; + __be16 id; + __be32 rsvd1; + __be32 dst_ip; + __be32 dst_ip_msk; + __be32 src_ip; + __be32 src_ip_msk; +}; + +struct mlx4_net_trans_rule_hw_vxlan { + u8 size; + u8 rsvd; + __be16 id; + __be32 rsvd1; + __be32 vni; + __be32 vni_mask; +}; + +struct _rule_hw { + union { + struct { + u8 size; + u8 rsvd; + __be16 id; + }; + struct mlx4_net_trans_rule_hw_eth eth; + struct mlx4_net_trans_rule_hw_ib ib; + struct mlx4_net_trans_rule_hw_ipv4 ipv4; + struct mlx4_net_trans_rule_hw_tcp_udp tcp_udp; + struct mlx4_net_trans_rule_hw_vxlan vxlan; + }; +}; + +enum { + MLX4_NUM_PDS = 32768, +}; + +enum { + MLX4_CMPT_SHIFT = 24, + MLX4_NUM_CMPTS = 67108864, +}; + +enum mlx4_res_tracker_free_type { + RES_TR_FREE_ALL = 0, + RES_TR_FREE_SLAVES_ONLY = 1, + RES_TR_FREE_STRUCTS_ONLY = 2, +}; + +struct mlx4_profile { + int num_qp; + int rdmarc_per_qp; + int num_srq; + int num_cq; + int num_mcg; + int num_mpt; + unsigned int num_mtt; +}; + +struct mlx4_promisc_qp { + struct list_head list; + u32 qpn; +}; + +struct mlx4_steer_index { + struct list_head list; + unsigned int index; + struct list_head duplicates; +}; + +enum { + MLX4_PCI_DEV_IS_VF = 1, + MLX4_PCI_DEV_FORCE_SENSE_PORT = 2, +}; + +enum mlx4_devlink_param_id { + MLX4_DEVLINK_PARAM_ID_BASE = 10, + MLX4_DEVLINK_PARAM_ID_ENABLE_64B_CQE_EQE = 11, + MLX4_DEVLINK_PARAM_ID_ENABLE_4K_UAR = 12, +}; + +enum { + MLX4_QUERY_FUNC_NUM_SYS_EQS = 1, +}; + +enum ibta_mtu { + IB_MTU_256___2 = 1, + IB_MTU_512___2 = 2, + IB_MTU_1024___2 = 3, + IB_MTU_2048___2 = 4, + IB_MTU_4096___2 = 5, +}; + +enum { + MLX4_DEV_CAP_CHECK_NUM_VFS_ABOVE_64 = 4294967295, +}; + +enum mlx4_net_trans_rule_id { + MLX4_NET_TRANS_RULE_ID_ETH = 0, + MLX4_NET_TRANS_RULE_ID_IB = 1, + MLX4_NET_TRANS_RULE_ID_IPV6 = 2, + MLX4_NET_TRANS_RULE_ID_IPV4 = 3, + MLX4_NET_TRANS_RULE_ID_TCP = 4, + MLX4_NET_TRANS_RULE_ID_UDP = 5, + MLX4_NET_TRANS_RULE_ID_VXLAN = 6, + MLX4_NET_TRANS_RULE_NUM = 7, +}; + +enum mlx4_net_trans_promisc_mode { + MLX4_FS_REGULAR = 1, + MLX4_FS_ALL_DEFAULT = 2, + MLX4_FS_MC_DEFAULT = 3, + MLX4_FS_MIRROR_RX_PORT = 4, + MLX4_FS_MIRROR_SX_PORT = 5, + MLX4_FS_UC_SNIFFER = 6, + MLX4_FS_MC_SNIFFER = 7, + MLX4_FS_MODE_NUM = 8, +}; + +struct mlx4_spec_eth { + u8 dst_mac[6]; + u8 dst_mac_msk[6]; + u8 src_mac[6]; + u8 src_mac_msk[6]; + u8 ether_type_enable; + __be16 ether_type; + __be16 vlan_id_msk; + __be16 vlan_id; +}; + +struct mlx4_spec_tcp_udp { + __be16 dst_port; + __be16 dst_port_msk; + __be16 src_port; + __be16 src_port_msk; +}; + +struct mlx4_spec_ipv4 { + __be32 dst_ip; + __be32 dst_ip_msk; + __be32 src_ip; + __be32 src_ip_msk; +}; + +struct mlx4_spec_ib { + __be32 l3_qpn; + __be32 qpn_msk; + u8 dst_gid[16]; + u8 dst_gid_msk[16]; +}; + +struct mlx4_spec_vxlan { + __be32 vni; + __be32 vni_mask; +}; + +struct mlx4_spec_list { + struct list_head list; + enum mlx4_net_trans_rule_id id; + union { + struct mlx4_spec_eth eth; + struct mlx4_spec_ib ib; + struct mlx4_spec_ipv4 ipv4; + struct mlx4_spec_tcp_udp tcp_udp; + struct mlx4_spec_vxlan vxlan; + }; +}; + +enum mlx4_net_trans_hw_rule_queue { + MLX4_NET_TRANS_Q_FIFO = 0, + MLX4_NET_TRANS_Q_LIFO = 1, +}; + +struct mlx4_net_trans_rule { + struct list_head list; + enum mlx4_net_trans_hw_rule_queue queue_mode; + bool exclusive; + bool allow_loopback; + enum mlx4_net_trans_promisc_mode promisc_mode; + u8 port; + u16 priority; + u32 qpn; +}; + +enum { + MLX4_PERM_LOCAL_READ = 1024, + MLX4_PERM_LOCAL_WRITE = 2048, + MLX4_PERM_REMOTE_READ = 4096, + MLX4_PERM_REMOTE_WRITE = 8192, + MLX4_PERM_ATOMIC = 16384, + MLX4_PERM_BIND_MW = 32768, + MLX4_PERM_MASK = 64512, +}; + +enum { + MLX4_MTT_FLAG_PRESENT = 1, +}; + +struct mlx4_mr { + struct mlx4_mtt mtt; + u64 iova; + u64 size; + u32 key; + u32 pd; + u32 access; + int enabled; +}; + +enum mlx4_mw_type { + MLX4_MW_TYPE_1 = 1, + MLX4_MW_TYPE_2 = 2, +}; + +struct mlx4_mw { + u32 key; + u32 pd; + enum mlx4_mw_type type; + int enabled; +}; + +enum mlx4_mpt_state { + MLX4_MPT_DISABLED = 0, + MLX4_MPT_EN_HW = 1, + MLX4_MPT_EN_SW = 2, +}; + +struct mlx4_mpt_entry { + __be32 flags; + __be32 qpn; + __be32 key; + __be32 pd_flags; + __be64 start; + __be64 length; + __be32 lkey; + __be32 win_cnt; + u8 reserved1[3]; + u8 mtt_rep; + __be64 mtt_addr; + __be32 mtt_sz; + __be32 entity_size; + __be32 first_byte_offset; +} __attribute__((packed)); + +struct mlx4_bf { + unsigned int offset; + int buf_size; + struct mlx4_uar *uar; + void *reg; +}; + +enum { + MLX4_NUM_RESERVED_UARS = 8, +}; + +enum { + MLX4_PORT_CAP_IS_SM = 2, + MLX4_PORT_CAP_DEV_MGMT_SUP = 524288, +}; + +enum mlx4_special_vlan_idx { + MLX4_NO_VLAN_IDX = 0, + MLX4_VLAN_MISS_IDX = 1, + MLX4_VLAN_REGULAR = 2, +}; + +struct mlx4_mad_ifc { + u8 base_version; + u8 mgmt_class; + u8 class_version; + u8 method; + __be16 status; + __be16 class_specific; + __be64 tid; + __be16 attr_id; + __be16 resv; + __be32 attr_mod; + __be64 mkey; + __be16 dr_slid; + __be16 dr_dlid; + u8 reserved[28]; + u8 data[192]; +}; + +enum { + MCAST_DIRECT_ONLY = 0, + MCAST_DIRECT = 1, + MCAST_DEFAULT = 2, +}; + +struct mlx4_set_port_rqp_calc_context { + __be32 base_qpn; + u8 rererved; + u8 n_mac; + u8 n_vlan; + u8 n_prio; + u8 reserved2[3]; + u8 mac_miss; + u8 intra_no_vlan; + u8 no_vlan; + u8 intra_vlan_miss; + u8 vlan_miss; + u8 reserved3[3]; + u8 no_vlan_prio; + __be32 promisc; + __be32 mcast; +}; + +enum { + MLX4_SET_PORT_VL_CAP = 4, + MLX4_SET_PORT_MTU_CAP = 12, + MLX4_CHANGE_PORT_PKEY_TBL_SZ = 20, + MLX4_CHANGE_PORT_VL_CAP = 21, + MLX4_CHANGE_PORT_MTU_CAP = 22, +}; + +enum { + VXLAN_ENABLE_MODIFY = 128, + VXLAN_STEERING_MODIFY = 64, + VXLAN_ENABLE = 128, +}; + +struct mlx4_set_port_vxlan_context { + u32 reserved1; + u8 modify_flags; + u8 reserved2; + u8 enable_flags; + u8 steering; +}; + +struct mlx4_cable_info { + u8 i2c_addr; + u8 page_num; + __be16 dev_mem_address; + __be16 reserved1; + __be16 size; + __be32 reserved2[2]; + u8 data[48]; +}; + +enum cable_info_err { + CABLE_INF_INV_PORT = 1, + CABLE_INF_OP_NOSUP = 2, + CABLE_INF_NOT_CONN = 3, + CABLE_INF_NO_EEPRM = 4, + CABLE_INF_PAGE_ERR = 5, + CABLE_INF_INV_ADDR = 6, + CABLE_INF_I2C_ADDR = 7, + CABLE_INF_QSFP_VIO = 8, + CABLE_INF_I2C_BUSY = 9, +}; + +enum { + MLX4_RES_QP = 0, + MLX4_RES_RDMARC = 1, + MLX4_RES_ALTC = 2, + MLX4_RES_AUXC = 3, + MLX4_RES_SRQ = 4, + MLX4_RES_CQ = 5, + MLX4_RES_EQ = 6, + MLX4_RES_DMPT = 7, + MLX4_RES_CMPT = 8, + MLX4_RES_MTT = 9, + MLX4_RES_MCG = 10, + MLX4_RES_NUM = 11, +}; + +struct mlx4_resource___2 { + u64 size; + u64 start; + int type; + u32 num; + int log_num; +}; + +enum mlx4_qp_optpar { + MLX4_QP_OPTPAR_ALT_ADDR_PATH = 1, + MLX4_QP_OPTPAR_RRE = 2, + MLX4_QP_OPTPAR_RAE = 4, + MLX4_QP_OPTPAR_RWE = 8, + MLX4_QP_OPTPAR_PKEY_INDEX = 16, + MLX4_QP_OPTPAR_Q_KEY = 32, + MLX4_QP_OPTPAR_RNR_TIMEOUT = 64, + MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH = 128, + MLX4_QP_OPTPAR_SRA_MAX = 256, + MLX4_QP_OPTPAR_RRA_MAX = 512, + MLX4_QP_OPTPAR_PM_STATE = 1024, + MLX4_QP_OPTPAR_RETRY_COUNT = 4096, + MLX4_QP_OPTPAR_RNR_RETRY = 8192, + MLX4_QP_OPTPAR_ACK_TIMEOUT = 16384, + MLX4_QP_OPTPAR_SCHED_QUEUE = 65536, + MLX4_QP_OPTPAR_COUNTER_INDEX = 1048576, + MLX4_QP_OPTPAR_VLAN_STRIPPING = 2097152, +}; + +enum mlx4_qp_state { + MLX4_QP_STATE_RST = 0, + MLX4_QP_STATE_INIT = 1, + MLX4_QP_STATE_RTR = 2, + MLX4_QP_STATE_RTS = 3, + MLX4_QP_STATE_SQER = 4, + MLX4_QP_STATE_SQD = 5, + MLX4_QP_STATE_ERR = 6, + MLX4_QP_STATE_SQ_DRAINING = 7, + MLX4_QP_NUM_STATE = 8, +}; + +enum { + MLX4_QP_BIT_SRE = 32768, + MLX4_QP_BIT_SWE = 16384, + MLX4_QP_BIT_SAE = 8192, + MLX4_QP_BIT_RRE = 32768, + MLX4_QP_BIT_RWE = 16384, + MLX4_QP_BIT_RAE = 8192, + MLX4_QP_BIT_FPP = 8, + MLX4_QP_BIT_RIC = 16, +}; + +struct mlx4_qp_path { + u8 fl; + union { + u8 vlan_control; + u8 control; + }; + u8 disable_pkey_check; + u8 pkey_index; + u8 counter_index; + u8 grh_mylmc; + __be16 rlid; + u8 ackto; + u8 mgid_index; + u8 static_rate; + u8 hop_limit; + __be32 tclass_flowlabel; + u8 rgid[16]; + u8 sched_queue; + u8 vlan_index; + u8 feup; + u8 fvl_rx; + u8 reserved4[2]; + u8 dmac[6]; +}; + +enum { + MLX4_FL_CV = 64, + MLX4_FL_SV = 32, + MLX4_FL_ETH_HIDE_CQE_VLAN = 4, + MLX4_FL_ETH_SRC_CHECK_MC_LB = 2, + MLX4_FL_ETH_SRC_CHECK_UC_LB = 1, +}; + +struct mlx4_qp_context { + __be32 flags; + __be32 pd; + u8 mtu_msgmax; + u8 rq_size_stride; + u8 sq_size_stride; + u8 rlkey_roce_mode; + __be32 usr_page; + __be32 local_qpn; + __be32 remote_qpn; + struct mlx4_qp_path pri_path; + struct mlx4_qp_path alt_path; + __be32 params1; + u32 reserved1; + __be32 next_send_psn; + __be32 cqn_send; + __be16 roce_entropy; + __be16 reserved2[3]; + __be32 last_acked_psn; + __be32 ssn; + __be32 params2; + __be32 rnr_nextrecvpsn; + __be32 xrcd; + __be32 cqn_recv; + __be64 db_rec_addr; + __be32 qkey; + __be32 srqn; + __be32 msn; + __be16 rq_wqe_counter; + __be16 sq_wqe_counter; + u32 reserved3; + __be16 rate_limit_params; + u8 reserved4; + u8 qos_vport; + __be32 param3; + __be32 nummmcpeers_basemkey; + u8 log_page_size; + u8 reserved5[2]; + u8 mtt_base_addr_h; + __be32 mtt_base_addr_l; + u32 reserved6[10]; +}; + +struct mlx4_update_qp_context { + __be64 qp_mask; + __be64 primary_addr_path_mask; + __be64 secondary_addr_path_mask; + u64 reserved1; + struct mlx4_qp_context qp_context; + u64 reserved2[58]; +}; + +enum { + MLX4_UPD_QP_MASK_PM_STATE = 32, + MLX4_UPD_QP_MASK_VSD = 33, + MLX4_UPD_QP_MASK_QOS_VPP = 34, + MLX4_UPD_QP_MASK_RATE_LIMIT = 35, +}; + +enum { + MLX4_UPD_QP_PATH_MASK_PKEY_INDEX = 32, + MLX4_UPD_QP_PATH_MASK_FSM = 33, + MLX4_UPD_QP_PATH_MASK_MAC_INDEX = 34, + MLX4_UPD_QP_PATH_MASK_FVL = 35, + MLX4_UPD_QP_PATH_MASK_CV = 36, + MLX4_UPD_QP_PATH_MASK_VLAN_INDEX = 37, + MLX4_UPD_QP_PATH_MASK_ETH_HIDE_CQE_VLAN = 38, + MLX4_UPD_QP_PATH_MASK_ETH_TX_BLOCK_UNTAGGED = 39, + MLX4_UPD_QP_PATH_MASK_ETH_TX_BLOCK_1P = 40, + MLX4_UPD_QP_PATH_MASK_ETH_TX_BLOCK_TAGGED = 41, + MLX4_UPD_QP_PATH_MASK_ETH_RX_BLOCK_UNTAGGED = 42, + MLX4_UPD_QP_PATH_MASK_ETH_RX_BLOCK_1P = 43, + MLX4_UPD_QP_PATH_MASK_ETH_RX_BLOCK_TAGGED = 44, + MLX4_UPD_QP_PATH_MASK_FEUP = 45, + MLX4_UPD_QP_PATH_MASK_SCHED_QUEUE = 46, + MLX4_UPD_QP_PATH_MASK_IF_COUNTER_INDEX = 47, + MLX4_UPD_QP_PATH_MASK_FVL_RX = 48, + MLX4_UPD_QP_PATH_MASK_ETH_SRC_CHECK_UC_LB = 50, + MLX4_UPD_QP_PATH_MASK_ETH_SRC_CHECK_MC_LB = 51, + MLX4_UPD_QP_PATH_MASK_SV = 54, +}; + +enum { + MLX4_STRIP_VLAN = 1073741824, +}; + +enum mlx4_update_qp_attr { + MLX4_UPDATE_QP_SMAC = 1, + MLX4_UPDATE_QP_VSD = 2, + MLX4_UPDATE_QP_RATE_LIMIT = 4, + MLX4_UPDATE_QP_QOS_VPORT = 8, + MLX4_UPDATE_QP_ETH_SRC_CHECK_MC_LB = 16, + MLX4_UPDATE_QP_SUPPORTED_ATTRS = 31, +}; + +enum mlx4_update_qp_params_flags { + MLX4_UPDATE_QP_PARAMS_FLAGS_ETH_CHECK_MC_LB = 1, + MLX4_UPDATE_QP_PARAMS_FLAGS_VSD_ENABLE = 2, +}; + +struct mlx4_update_qp_params { + u8 smac_index; + u8 qos_vport; + u32 flags; + u16 rate_unit; + u16 rate_val; +}; + +struct mlx4_srq { + void (*event)(struct mlx4_srq *, enum mlx4_event); + int srqn; + int max; + int max_gs; + int wqe_shift; + refcount_t refcount; + struct completion free; +}; + +struct mlx4_srq_context { + __be32 state_logsize_srqn; + u8 logstride; + u8 reserved1; + __be16 xrcd; + __be32 pg_offset_cqn; + u32 reserved2; + u8 log_page_size; + u8 reserved3[2]; + u8 mtt_base_addr_h; + __be32 mtt_base_addr_l; + __be32 pd; + __be16 limit_watermark; + __be16 wqe_cnt; + u16 reserved4; + __be16 wqe_counter; + u32 reserved5; + __be64 db_rec_addr; +}; + +enum { + MLX4_QP_ST_RC = 0, + MLX4_QP_ST_UC = 1, + MLX4_QP_ST_RD = 2, + MLX4_QP_ST_UD = 3, + MLX4_QP_ST_XRC = 6, + MLX4_QP_ST_MLX = 7, +}; + +enum { + MLX4_RSS_HASH_XOR = 0, + MLX4_RSS_HASH_TOP = 1, + MLX4_RSS_UDP_IPV6 = 1, + MLX4_RSS_UDP_IPV4 = 2, + MLX4_RSS_TCP_IPV6 = 4, + MLX4_RSS_IPV6 = 8, + MLX4_RSS_TCP_IPV4 = 16, + MLX4_RSS_IPV4 = 32, + MLX4_RSS_BY_OUTER_HEADERS = 0, + MLX4_RSS_BY_INNER_HEADERS = 128, + MLX4_RSS_BY_INNER_HEADERS_IPONLY = 192, + MLX4_RSS_OFFSET_IN_QPC_PRI_PATH = 36, + MLX4_RSS_QPC_FLAG_OFFSET = 13, +}; + +enum { + MLX4_CTRL_ETH_SRC_CHECK_IF_COUNTER = 128, +}; + +enum { + MLX4_VLAN_CTRL_ETH_TX_BLOCK_TAGGED = 64, + MLX4_VLAN_CTRL_ETH_TX_BLOCK_PRIO_TAGGED = 32, + MLX4_VLAN_CTRL_ETH_TX_BLOCK_UNTAGGED = 16, + MLX4_VLAN_CTRL_ETH_RX_BLOCK_TAGGED = 4, + MLX4_VLAN_CTRL_ETH_RX_BLOCK_PRIO_TAGGED = 2, + MLX4_VLAN_CTRL_ETH_RX_BLOCK_UNTAGGED = 1, +}; + +enum { + MLX4_FEUP_FORCE_ETH_UP = 64, + MLX4_FSM_FORCE_ETH_SRC_MAC = 32, + MLX4_FVL_FORCE_ETH_VLAN = 8, +}; + +enum { + MLX4_FVL_RX_FORCE_ETH_VLAN = 1, +}; + +struct mac_res { + struct list_head list; + u64 mac; + int ref_count; + u8 smac_index; + u8 port; +}; + +struct vlan_res { + struct list_head list; + u16 vlan; + int ref_count; + int vlan_index; + u8 port; +}; + +struct res_common { + struct list_head list; + struct rb_node node; + u64 res_id; + int owner; + int state; + int from_state; + int to_state; + int removing; + const char *func_name; +}; + +enum { + RES_ANY_BUSY = 1, +}; + +struct res_gid { + struct list_head list; + u8 gid[16]; + enum mlx4_protocol prot; + enum mlx4_steer_type steer; + u64 reg_id; +}; + +enum res_qp_states { + RES_QP_BUSY = 1, + RES_QP_RESERVED = 2, + RES_QP_MAPPED = 3, + RES_QP_HW = 4, +}; + +struct res_mtt; + +struct res_cq; + +struct res_srq; + +struct res_qp { + struct res_common com; + struct res_mtt *mtt; + struct res_cq *rcq; + struct res_cq *scq; + struct res_srq *srq; + struct list_head mcg_list; + spinlock_t mcg_spl; + int local_qpn; + atomic_t ref_count; + u32 qpc_flags; + u8 sched_queue; + __be32 param3; + u8 vlan_control; + u8 fvl_rx; + u8 pri_path_fl; + u8 vlan_index; + u8 feup; +}; + +struct res_mtt { + struct res_common com; + int order; + atomic_t ref_count; +}; + +struct res_cq { + struct res_common com; + struct res_mtt *mtt; + atomic_t ref_count; +}; + +struct res_srq { + struct res_common com; + struct res_mtt *mtt; + struct res_cq *cq; + atomic_t ref_count; +}; + +enum res_mtt_states { + RES_MTT_BUSY = 1, + RES_MTT_ALLOCATED = 2, +}; + +enum res_mpt_states { + RES_MPT_BUSY = 1, + RES_MPT_RESERVED = 2, + RES_MPT_MAPPED = 3, + RES_MPT_HW = 4, +}; + +struct res_mpt { + struct res_common com; + struct res_mtt *mtt; + int key; +}; + +enum res_eq_states { + RES_EQ_BUSY = 1, + RES_EQ_RESERVED = 2, + RES_EQ_HW = 3, +}; + +struct res_eq { + struct res_common com; + struct res_mtt *mtt; +}; + +enum res_cq_states { + RES_CQ_BUSY = 1, + RES_CQ_ALLOCATED = 2, + RES_CQ_HW = 3, +}; + +enum res_srq_states { + RES_SRQ_BUSY = 1, + RES_SRQ_ALLOCATED = 2, + RES_SRQ_HW = 3, +}; + +enum res_counter_states { + RES_COUNTER_BUSY = 1, + RES_COUNTER_ALLOCATED = 2, +}; + +struct res_counter { + struct res_common com; + int port; +}; + +enum res_xrcdn_states { + RES_XRCD_BUSY = 1, + RES_XRCD_ALLOCATED = 2, +}; + +struct res_xrcdn { + struct res_common com; + int port; +}; + +enum res_fs_rule_states { + RES_FS_RULE_BUSY = 1, + RES_FS_RULE_ALLOCATED = 2, +}; + +struct res_fs_rule { + struct res_common com; + int qpn; + void *mirr_mbox; + u32 mirr_mbox_size; + struct list_head mirr_list; + u64 mirr_rule_id; +}; + +enum qp_transition { + QP_TRANS_INIT2RTR = 0, + QP_TRANS_RTR2RTS = 1, + QP_TRANS_RTS2RTS = 2, + QP_TRANS_SQERR2RTS = 3, + QP_TRANS_SQD2SQD = 4, + QP_TRANS_SQD2RTS = 5, +}; + +struct devlink_region_ops { + const char *name; + void (*destructor)(const void *); + int (*snapshot)(struct devlink *, const struct devlink_region_ops *, struct netlink_ext_ack *, u8 **); + void *priv; +}; + +enum dcbnl_cndd_states { + DCB_CNDD_RESET = 0, + DCB_CNDD_EDGE = 1, + DCB_CNDD_INTERIOR = 2, + DCB_CNDD_INTERIOR_READY = 3, +}; + +enum { + MLX4_WQE_CTRL_NEC = 536870912, + MLX4_WQE_CTRL_IIP = 268435456, + MLX4_WQE_CTRL_ILP = 134217728, + MLX4_WQE_CTRL_FENCE = 64, + MLX4_WQE_CTRL_CQ_UPDATE = 12, + MLX4_WQE_CTRL_SOLICITED = 2, + MLX4_WQE_CTRL_IP_CSUM = 16, + MLX4_WQE_CTRL_TCP_UDP_CSUM = 32, + MLX4_WQE_CTRL_INS_CVLAN = 64, + MLX4_WQE_CTRL_INS_SVLAN = 128, + MLX4_WQE_CTRL_STRONG_ORDER = 128, + MLX4_WQE_CTRL_FORCE_LOOPBACK = 1, +}; + +struct mlx4_cqe { + __be32 vlan_my_qpn; + __be32 immed_rss_invalid; + __be32 g_mlpath_rqpn; + __be16 sl_vid; + union { + struct { + __be16 rlid; + __be16 status; + u8 ipv6_ext_mask; + u8 badfcs_enc; + }; + u8 smac[6]; + }; + __be32 byte_cnt; + __be16 wqe_index; + __be16 checksum; + u8 reserved[3]; + u8 owner_sr_opcode; +}; + +struct mlx4_en_stat_out_mbox { + __be64 R64_prio_0; + __be64 R64_prio_1; + __be64 R64_prio_2; + __be64 R64_prio_3; + __be64 R64_prio_4; + __be64 R64_prio_5; + __be64 R64_prio_6; + __be64 R64_prio_7; + __be64 R64_novlan; + __be64 R127_prio_0; + __be64 R127_prio_1; + __be64 R127_prio_2; + __be64 R127_prio_3; + __be64 R127_prio_4; + __be64 R127_prio_5; + __be64 R127_prio_6; + __be64 R127_prio_7; + __be64 R127_novlan; + __be64 R255_prio_0; + __be64 R255_prio_1; + __be64 R255_prio_2; + __be64 R255_prio_3; + __be64 R255_prio_4; + __be64 R255_prio_5; + __be64 R255_prio_6; + __be64 R255_prio_7; + __be64 R255_novlan; + __be64 R511_prio_0; + __be64 R511_prio_1; + __be64 R511_prio_2; + __be64 R511_prio_3; + __be64 R511_prio_4; + __be64 R511_prio_5; + __be64 R511_prio_6; + __be64 R511_prio_7; + __be64 R511_novlan; + __be64 R1023_prio_0; + __be64 R1023_prio_1; + __be64 R1023_prio_2; + __be64 R1023_prio_3; + __be64 R1023_prio_4; + __be64 R1023_prio_5; + __be64 R1023_prio_6; + __be64 R1023_prio_7; + __be64 R1023_novlan; + __be64 R1518_prio_0; + __be64 R1518_prio_1; + __be64 R1518_prio_2; + __be64 R1518_prio_3; + __be64 R1518_prio_4; + __be64 R1518_prio_5; + __be64 R1518_prio_6; + __be64 R1518_prio_7; + __be64 R1518_novlan; + __be64 R1522_prio_0; + __be64 R1522_prio_1; + __be64 R1522_prio_2; + __be64 R1522_prio_3; + __be64 R1522_prio_4; + __be64 R1522_prio_5; + __be64 R1522_prio_6; + __be64 R1522_prio_7; + __be64 R1522_novlan; + __be64 R1548_prio_0; + __be64 R1548_prio_1; + __be64 R1548_prio_2; + __be64 R1548_prio_3; + __be64 R1548_prio_4; + __be64 R1548_prio_5; + __be64 R1548_prio_6; + __be64 R1548_prio_7; + __be64 R1548_novlan; + __be64 R2MTU_prio_0; + __be64 R2MTU_prio_1; + __be64 R2MTU_prio_2; + __be64 R2MTU_prio_3; + __be64 R2MTU_prio_4; + __be64 R2MTU_prio_5; + __be64 R2MTU_prio_6; + __be64 R2MTU_prio_7; + __be64 R2MTU_novlan; + __be64 RGIANT_prio_0; + __be64 RGIANT_prio_1; + __be64 RGIANT_prio_2; + __be64 RGIANT_prio_3; + __be64 RGIANT_prio_4; + __be64 RGIANT_prio_5; + __be64 RGIANT_prio_6; + __be64 RGIANT_prio_7; + __be64 RGIANT_novlan; + __be64 RBCAST_prio_0; + __be64 RBCAST_prio_1; + __be64 RBCAST_prio_2; + __be64 RBCAST_prio_3; + __be64 RBCAST_prio_4; + __be64 RBCAST_prio_5; + __be64 RBCAST_prio_6; + __be64 RBCAST_prio_7; + __be64 RBCAST_novlan; + __be64 MCAST_prio_0; + __be64 MCAST_prio_1; + __be64 MCAST_prio_2; + __be64 MCAST_prio_3; + __be64 MCAST_prio_4; + __be64 MCAST_prio_5; + __be64 MCAST_prio_6; + __be64 MCAST_prio_7; + __be64 MCAST_novlan; + __be64 RTOTG_prio_0; + __be64 RTOTG_prio_1; + __be64 RTOTG_prio_2; + __be64 RTOTG_prio_3; + __be64 RTOTG_prio_4; + __be64 RTOTG_prio_5; + __be64 RTOTG_prio_6; + __be64 RTOTG_prio_7; + __be64 RTOTG_novlan; + __be64 RTTLOCT_prio_0; + __be64 RTTLOCT_NOFRM_prio_0; + __be64 ROCT_prio_0; + __be64 RTTLOCT_prio_1; + __be64 RTTLOCT_NOFRM_prio_1; + __be64 ROCT_prio_1; + __be64 RTTLOCT_prio_2; + __be64 RTTLOCT_NOFRM_prio_2; + __be64 ROCT_prio_2; + __be64 RTTLOCT_prio_3; + __be64 RTTLOCT_NOFRM_prio_3; + __be64 ROCT_prio_3; + __be64 RTTLOCT_prio_4; + __be64 RTTLOCT_NOFRM_prio_4; + __be64 ROCT_prio_4; + __be64 RTTLOCT_prio_5; + __be64 RTTLOCT_NOFRM_prio_5; + __be64 ROCT_prio_5; + __be64 RTTLOCT_prio_6; + __be64 RTTLOCT_NOFRM_prio_6; + __be64 ROCT_prio_6; + __be64 RTTLOCT_prio_7; + __be64 RTTLOCT_NOFRM_prio_7; + __be64 ROCT_prio_7; + __be64 RTTLOCT_novlan; + __be64 RTTLOCT_NOFRM_novlan; + __be64 ROCT_novlan; + __be64 RTOT_prio_0; + __be64 R1Q_prio_0; + __be64 reserved1; + __be64 RTOT_prio_1; + __be64 R1Q_prio_1; + __be64 reserved2; + __be64 RTOT_prio_2; + __be64 R1Q_prio_2; + __be64 reserved3; + __be64 RTOT_prio_3; + __be64 R1Q_prio_3; + __be64 reserved4; + __be64 RTOT_prio_4; + __be64 R1Q_prio_4; + __be64 reserved5; + __be64 RTOT_prio_5; + __be64 R1Q_prio_5; + __be64 reserved6; + __be64 RTOT_prio_6; + __be64 R1Q_prio_6; + __be64 reserved7; + __be64 RTOT_prio_7; + __be64 R1Q_prio_7; + __be64 reserved8; + __be64 RTOT_novlan; + __be64 R1Q_novlan; + __be64 reserved9; + __be64 RCNTL; + __be64 reserved10; + __be64 reserved11; + __be64 reserved12; + __be64 RInRangeLengthErr; + __be64 ROutRangeLengthErr; + __be64 RFrmTooLong; + __be64 PCS; + __be64 T64_prio_0; + __be64 T64_prio_1; + __be64 T64_prio_2; + __be64 T64_prio_3; + __be64 T64_prio_4; + __be64 T64_prio_5; + __be64 T64_prio_6; + __be64 T64_prio_7; + __be64 T64_novlan; + __be64 T64_loopbk; + __be64 T127_prio_0; + __be64 T127_prio_1; + __be64 T127_prio_2; + __be64 T127_prio_3; + __be64 T127_prio_4; + __be64 T127_prio_5; + __be64 T127_prio_6; + __be64 T127_prio_7; + __be64 T127_novlan; + __be64 T127_loopbk; + __be64 T255_prio_0; + __be64 T255_prio_1; + __be64 T255_prio_2; + __be64 T255_prio_3; + __be64 T255_prio_4; + __be64 T255_prio_5; + __be64 T255_prio_6; + __be64 T255_prio_7; + __be64 T255_novlan; + __be64 T255_loopbk; + __be64 T511_prio_0; + __be64 T511_prio_1; + __be64 T511_prio_2; + __be64 T511_prio_3; + __be64 T511_prio_4; + __be64 T511_prio_5; + __be64 T511_prio_6; + __be64 T511_prio_7; + __be64 T511_novlan; + __be64 T511_loopbk; + __be64 T1023_prio_0; + __be64 T1023_prio_1; + __be64 T1023_prio_2; + __be64 T1023_prio_3; + __be64 T1023_prio_4; + __be64 T1023_prio_5; + __be64 T1023_prio_6; + __be64 T1023_prio_7; + __be64 T1023_novlan; + __be64 T1023_loopbk; + __be64 T1518_prio_0; + __be64 T1518_prio_1; + __be64 T1518_prio_2; + __be64 T1518_prio_3; + __be64 T1518_prio_4; + __be64 T1518_prio_5; + __be64 T1518_prio_6; + __be64 T1518_prio_7; + __be64 T1518_novlan; + __be64 T1518_loopbk; + __be64 T1522_prio_0; + __be64 T1522_prio_1; + __be64 T1522_prio_2; + __be64 T1522_prio_3; + __be64 T1522_prio_4; + __be64 T1522_prio_5; + __be64 T1522_prio_6; + __be64 T1522_prio_7; + __be64 T1522_novlan; + __be64 T1522_loopbk; + __be64 T1548_prio_0; + __be64 T1548_prio_1; + __be64 T1548_prio_2; + __be64 T1548_prio_3; + __be64 T1548_prio_4; + __be64 T1548_prio_5; + __be64 T1548_prio_6; + __be64 T1548_prio_7; + __be64 T1548_novlan; + __be64 T1548_loopbk; + __be64 T2MTU_prio_0; + __be64 T2MTU_prio_1; + __be64 T2MTU_prio_2; + __be64 T2MTU_prio_3; + __be64 T2MTU_prio_4; + __be64 T2MTU_prio_5; + __be64 T2MTU_prio_6; + __be64 T2MTU_prio_7; + __be64 T2MTU_novlan; + __be64 T2MTU_loopbk; + __be64 TGIANT_prio_0; + __be64 TGIANT_prio_1; + __be64 TGIANT_prio_2; + __be64 TGIANT_prio_3; + __be64 TGIANT_prio_4; + __be64 TGIANT_prio_5; + __be64 TGIANT_prio_6; + __be64 TGIANT_prio_7; + __be64 TGIANT_novlan; + __be64 TGIANT_loopbk; + __be64 TBCAST_prio_0; + __be64 TBCAST_prio_1; + __be64 TBCAST_prio_2; + __be64 TBCAST_prio_3; + __be64 TBCAST_prio_4; + __be64 TBCAST_prio_5; + __be64 TBCAST_prio_6; + __be64 TBCAST_prio_7; + __be64 TBCAST_novlan; + __be64 TBCAST_loopbk; + __be64 TMCAST_prio_0; + __be64 TMCAST_prio_1; + __be64 TMCAST_prio_2; + __be64 TMCAST_prio_3; + __be64 TMCAST_prio_4; + __be64 TMCAST_prio_5; + __be64 TMCAST_prio_6; + __be64 TMCAST_prio_7; + __be64 TMCAST_novlan; + __be64 TMCAST_loopbk; + __be64 TTOTG_prio_0; + __be64 TTOTG_prio_1; + __be64 TTOTG_prio_2; + __be64 TTOTG_prio_3; + __be64 TTOTG_prio_4; + __be64 TTOTG_prio_5; + __be64 TTOTG_prio_6; + __be64 TTOTG_prio_7; + __be64 TTOTG_novlan; + __be64 TTOTG_loopbk; + __be64 TTTLOCT_prio_0; + __be64 TTTLOCT_NOFRM_prio_0; + __be64 TOCT_prio_0; + __be64 TTTLOCT_prio_1; + __be64 TTTLOCT_NOFRM_prio_1; + __be64 TOCT_prio_1; + __be64 TTTLOCT_prio_2; + __be64 TTTLOCT_NOFRM_prio_2; + __be64 TOCT_prio_2; + __be64 TTTLOCT_prio_3; + __be64 TTTLOCT_NOFRM_prio_3; + __be64 TOCT_prio_3; + __be64 TTTLOCT_prio_4; + __be64 TTTLOCT_NOFRM_prio_4; + __be64 TOCT_prio_4; + __be64 TTTLOCT_prio_5; + __be64 TTTLOCT_NOFRM_prio_5; + __be64 TOCT_prio_5; + __be64 TTTLOCT_prio_6; + __be64 TTTLOCT_NOFRM_prio_6; + __be64 TOCT_prio_6; + __be64 TTTLOCT_prio_7; + __be64 TTTLOCT_NOFRM_prio_7; + __be64 TOCT_prio_7; + __be64 TTTLOCT_novlan; + __be64 TTTLOCT_NOFRM_novlan; + __be64 TOCT_novlan; + __be64 TTTLOCT_loopbk; + __be64 TTTLOCT_NOFRM_loopbk; + __be64 TOCT_loopbk; + __be64 TTOT_prio_0; + __be64 T1Q_prio_0; + __be64 reserved13; + __be64 TTOT_prio_1; + __be64 T1Q_prio_1; + __be64 reserved14; + __be64 TTOT_prio_2; + __be64 T1Q_prio_2; + __be64 reserved15; + __be64 TTOT_prio_3; + __be64 T1Q_prio_3; + __be64 reserved16; + __be64 TTOT_prio_4; + __be64 T1Q_prio_4; + __be64 reserved17; + __be64 TTOT_prio_5; + __be64 T1Q_prio_5; + __be64 reserved18; + __be64 TTOT_prio_6; + __be64 T1Q_prio_6; + __be64 reserved19; + __be64 TTOT_prio_7; + __be64 T1Q_prio_7; + __be64 reserved20; + __be64 TTOT_novlan; + __be64 T1Q_novlan; + __be64 reserved21; + __be64 TTOT_loopbk; + __be64 T1Q_loopbk; + __be64 reserved22; + __be32 RJBBR; + __be32 RCRC; + __be32 RRUNT; + __be32 RSHORT; + __be32 RDROP; + __be32 RdropOvflw; + __be32 RdropLength; + __be32 RTOTFRMS; + __be32 TDROP; +}; + +struct mlx4_en_pkt_stats { + long unsigned int rx_multicast_packets; + long unsigned int rx_broadcast_packets; + long unsigned int rx_jabbers; + long unsigned int rx_in_range_length_error; + long unsigned int rx_out_range_length_error; + long unsigned int tx_multicast_packets; + long unsigned int tx_broadcast_packets; + long unsigned int rx_prio[18]; + long unsigned int tx_prio[18]; +}; + +struct mlx4_en_counter_stats { + long unsigned int rx_packets; + long unsigned int rx_bytes; + long unsigned int tx_packets; + long unsigned int tx_bytes; +}; + +struct mlx4_en_port_stats { + long unsigned int tso_packets; + long unsigned int xmit_more; + long unsigned int queue_stopped; + long unsigned int wake_queue; + long unsigned int tx_timeout; + long unsigned int rx_alloc_pages; + long unsigned int rx_chksum_good; + long unsigned int rx_chksum_none; + long unsigned int rx_chksum_complete; + long unsigned int tx_chksum_offload; +}; + +struct mlx4_en_perf_stats { + u32 tx_poll; + u64 tx_pktsz_avg; + u32 inflight_avg; + u16 tx_coal_avg; + u16 rx_coal_avg; + u32 napi_quota; +}; + +struct mlx4_en_xdp_stats { + long unsigned int rx_xdp_drop; + long unsigned int rx_xdp_tx; + long unsigned int rx_xdp_tx_full; +}; + +struct mlx4_en_phy_stats { + long unsigned int rx_packets_phy; + long unsigned int rx_bytes_phy; + long unsigned int tx_packets_phy; + long unsigned int tx_bytes_phy; +}; + +struct mlx4_en_flow_stats_rx { + u64 rx_pause; + u64 rx_pause_duration; + u64 rx_pause_transition; +}; + +struct mlx4_en_flow_stats_tx { + u64 tx_pause; + u64 tx_pause_duration; + u64 tx_pause_transition; +}; + +enum { + MAX_INLINE = 104, + MAX_BF = 256, + MIN_PKT_LEN = 17, +}; + +enum cq_type { + TX = 0, + TX_XDP = 1, + RX = 2, +}; + +struct mlx4_en_tx_info { + union { + struct sk_buff *skb; + struct page *page; + }; + dma_addr_t map0_dma; + u32 map0_byte_count; + u32 nr_txbb; + u32 nr_bytes; + u8 linear; + u8 data_offset; + u8 inl; + u8 ts_requested; + u8 nr_maps; + long: 56; + long: 64; + long: 64; + long: 64; +}; + +struct mlx4_en_page_cache { + u32 index; + struct { + struct page *page; + dma_addr_t dma; + } buf[128]; +}; + +struct mlx4_en_priv; + +struct mlx4_en_rx_ring; + +struct mlx4_en_tx_ring { + u32 last_nr_txbb; + u32 cons; + long unsigned int wake_queue; + struct netdev_queue *tx_queue; + u32 (*free_tx_desc)(struct mlx4_en_priv *, struct mlx4_en_tx_ring *, int, u64, int); + struct mlx4_en_rx_ring *recycle_ring; + long: 64; + long: 64; + long: 64; + u32 prod; + unsigned int tx_dropped; + long unsigned int bytes; + long unsigned int packets; + long unsigned int tx_csum; + long unsigned int tso_packets; + long unsigned int xmit_more; + struct mlx4_bf bf; + __be32 doorbell_qpn; + __be32 mr_key; + u32 size; + u32 size_mask; + u32 full_size; + u32 buf_size; + void *buf; + struct mlx4_en_tx_info *tx_info; + int qpn; + u8 queue_index; + bool bf_enabled; + bool bf_alloced; + u8 hwtstamp_tx_type; + u8 *bounce_buf; + long unsigned int queue_stopped; + struct mlx4_hwq_resources sp_wqres; + struct mlx4_qp sp_qp; + struct mlx4_qp_context sp_context; + cpumask_t sp_affinity_mask; + enum mlx4_qp_state sp_qp_state; + u16 sp_stride; + u16 sp_cqn; + long: 64; +}; + +struct mlx4_en_port_state { + int link_state; + int link_speed; + int transceiver; + u32 flags; +}; + +struct ethtool_flow_id { + struct list_head list; + struct ethtool_rx_flow_spec flow_spec; + u64 id; +}; + +struct mlx4_en_rss_map { + int base_qpn; + struct mlx4_qp qps[128]; + enum mlx4_qp_state state[128]; + struct mlx4_qp *indir_qp; + enum mlx4_qp_state indir_state; +}; + +struct mlx4_en_frag_info { + u16 frag_size; + u32 frag_stride; +}; + +struct mlx4_en_stats_bitmap { + long unsigned int bitmap[3]; + struct mutex mutex; +}; + +struct mlx4_en_cee_config { + bool pfc_state; + enum dcb_pfc_type dcb_pfc[8]; +}; + +struct mlx4_en_dev; + +struct mlx4_en_port_profile; + +struct mlx4_en_cq; + +struct mlx4_en_priv { + struct mlx4_en_dev *mdev; + struct mlx4_en_port_profile *prof; + struct net_device *dev; + long unsigned int active_vlans[64]; + struct mlx4_en_port_state port_state; + spinlock_t stats_lock; + struct ethtool_flow_id ethtool_rules[256]; + struct list_head ethtool_list; + long unsigned int last_moder_packets[128]; + long unsigned int last_moder_tx_packets; + long unsigned int last_moder_bytes[128]; + long unsigned int last_moder_jiffies; + int last_moder_time[128]; + u16 rx_usecs; + u16 rx_frames; + u16 tx_usecs; + u16 tx_frames; + u32 pkt_rate_low; + u16 rx_usecs_low; + u32 pkt_rate_high; + u16 rx_usecs_high; + u32 sample_interval; + u32 adaptive_rx_coal; + u32 msg_enable; + u32 loopback_ok; + u32 validate_loopback; + struct mlx4_hwq_resources res; + int link_state; + int last_link_state; + bool port_up; + int port; + int registered; + int allocated; + int stride; + unsigned char current_mac[8]; + int mac_index; + unsigned int max_mtu; + int base_qpn; + int cqe_factor; + int cqe_size; + struct mlx4_en_rss_map rss_map; + __be32 ctrl_flags; + u32 flags; + u8 num_tx_rings_p_up; + u32 tx_work_limit; + u32 tx_ring_num[2]; + u32 rx_ring_num; + u32 rx_skb_size; + struct mlx4_en_frag_info frag_info[4]; + u8 num_frags; + u8 log_rx_info; + u8 dma_dir; + u16 rx_headroom; + struct mlx4_en_tx_ring **tx_ring[2]; + struct mlx4_en_rx_ring *rx_ring[128]; + struct mlx4_en_cq **tx_cq[2]; + struct mlx4_en_cq *rx_cq[128]; + struct mlx4_qp drop_qp; + struct work_struct rx_mode_task; + struct work_struct watchdog_task; + struct work_struct linkstate_task; + struct delayed_work stats_task; + struct delayed_work service_task; + struct mlx4_en_perf_stats pstats; + struct mlx4_en_pkt_stats pkstats; + struct mlx4_en_counter_stats pf_stats; + struct mlx4_en_flow_stats_rx rx_priority_flowstats[8]; + struct mlx4_en_flow_stats_tx tx_priority_flowstats[8]; + struct mlx4_en_flow_stats_rx rx_flowstats; + struct mlx4_en_flow_stats_tx tx_flowstats; + struct mlx4_en_port_stats port_stats; + struct mlx4_en_xdp_stats xdp_stats; + struct mlx4_en_phy_stats phy_stats; + struct mlx4_en_stats_bitmap stats_bitmap; + struct list_head mc_list; + struct list_head curr_list; + u64 broadcast_id; + struct mlx4_en_stat_out_mbox hw_stats; + int vids[128]; + bool wol; + struct device *ddev; + struct hlist_head mac_hash[256]; + struct hwtstamp_config hwtstamp_config; + u32 counter_index; + struct ieee_ets ets; + u16 maxrate[8]; + enum dcbnl_cndd_states cndd_state[8]; + struct mlx4_en_cee_config cee_config; + u8 dcbx_cap; + spinlock_t filters_lock; + int last_filter_id; + struct list_head filters; + struct hlist_head filter_hash[16]; + u64 tunnel_reg_id; + __be16 vxlan_port; + u32 pflags; + u8 rss_key[40]; + u8 rss_hash_fn; +}; + +struct mlx4_en_rx_ring { + struct mlx4_hwq_resources wqres; + u32 size; + u32 actual_size; + u32 size_mask; + u16 stride; + u16 log_stride; + u16 cqn; + u32 prod; + u32 cons; + u32 buf_size; + u8 fcs_del; + void *buf; + void *rx_info; + struct bpf_prog *xdp_prog; + struct mlx4_en_page_cache page_cache; + long unsigned int bytes; + long unsigned int packets; + long unsigned int csum_ok; + long unsigned int csum_none; + long unsigned int csum_complete; + long unsigned int rx_alloc_pages; + long unsigned int xdp_drop; + long unsigned int xdp_tx; + long unsigned int xdp_tx_full; + long unsigned int dropped; + int hwtstamp_rx_filter; + cpumask_var_t affinity_mask; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct xdp_rxq_info xdp_rxq; +}; + +struct mlx4_en_cq { + struct mlx4_cq mcq; + struct mlx4_hwq_resources wqres; + int ring; + struct net_device *dev; + union { + struct napi_struct napi; + bool xdp_busy; + }; + int size; + int buf_size; + int vector; + enum cq_type type; + u16 moder_time; + u16 moder_cnt; + struct mlx4_cqe *buf; + struct irq_desc *irq_desc; +}; + +struct mlx4_en_port_profile { + u32 flags; + u32 tx_ring_num[2]; + u32 rx_ring_num; + u32 tx_ring_size; + u32 rx_ring_size; + u8 num_tx_rings_p_up; + u8 rx_pause; + u8 rx_ppp; + u8 tx_pause; + u8 tx_ppp; + u8 num_up; + int rss_rings; + int inline_thold; + struct hwtstamp_config hwtstamp_config; +}; + +struct mlx4_en_profile { + int udp_rss; + u8 rss_mask; + u32 active_ports; + u32 small_pkt_int; + u8 no_reset; + u8 max_num_tx_rings_p_up; + struct mlx4_en_port_profile prof[3]; +}; + +struct mlx4_en_dev { + struct mlx4_dev *dev; + struct pci_dev *pdev; + struct mutex state_lock; + struct net_device *pndev[3]; + struct net_device *upper[3]; + u32 port_cnt; + bool device_up; + struct mlx4_en_profile profile; + u32 LSO_support; + struct workqueue_struct *workqueue; + struct device *dma_device; + void *uar_map; + struct mlx4_uar priv_uar; + struct mlx4_mr mr; + u32 priv_pdn; + spinlock_t uar_lock; + u8 mac_removed[3]; + u32 nominal_c_mult; + struct cyclecounter cycles; + seqlock_t clock_lock; + struct timecounter clock; + long unsigned int last_overflow_check; + struct ptp_clock *ptp_clock; + struct ptp_clock_info ptp_clock_info; + struct notifier_block nb; +}; + +enum { + MLX4_EN_FLAG_PROMISC = 1, + MLX4_EN_FLAG_MC_PROMISC = 2, + MLX4_EN_FLAG_ENABLE_HW_LOOPBACK = 4, + MLX4_EN_FLAG_RX_FILTER_NEEDED = 8, + MLX4_EN_FLAG_FORCE_PROMISC = 16, + MLX4_EN_FLAG_RX_CSUM_NON_TCP_UDP = 32, + MLX4_EN_FLAG_DCB_ENABLED = 64, +}; + +enum { + MLX4_OPCODE_NOP = 0, + MLX4_OPCODE_SEND_INVAL = 1, + MLX4_OPCODE_RDMA_WRITE = 8, + MLX4_OPCODE_RDMA_WRITE_IMM = 9, + MLX4_OPCODE_SEND = 10, + MLX4_OPCODE_SEND_IMM = 11, + MLX4_OPCODE_LSO = 14, + MLX4_OPCODE_RDMA_READ = 16, + MLX4_OPCODE_ATOMIC_CS = 17, + MLX4_OPCODE_ATOMIC_FA = 18, + MLX4_OPCODE_MASKED_ATOMIC_CS = 20, + MLX4_OPCODE_MASKED_ATOMIC_FA = 21, + MLX4_OPCODE_BIND_MW = 24, + MLX4_OPCODE_FMR = 25, + MLX4_OPCODE_LOCAL_INVAL = 27, + MLX4_OPCODE_CONFIG_CMD = 31, + MLX4_RECV_OPCODE_RDMA_WRITE_IMM = 0, + MLX4_RECV_OPCODE_SEND = 1, + MLX4_RECV_OPCODE_SEND_IMM = 2, + MLX4_RECV_OPCODE_SEND_INVAL = 3, + MLX4_CQE_OPCODE_ERROR = 30, + MLX4_CQE_OPCODE_RESIZE = 22, +}; + +struct mlx4_err_cqe { + __be32 my_qpn; + u32 reserved1[5]; + __be16 wqe_index; + u8 vendor_err_syndrome; + u8 syndrome; + u8 reserved2[3]; + u8 owner_sr_opcode; +}; + +enum { + MLX4_CQE_OWNER_MASK = 128, + MLX4_CQE_IS_SEND_MASK = 64, + MLX4_CQE_OPCODE_MASK = 31, +}; + +union mlx4_wqe_qpn_vlan { + struct { + __be16 vlan_tag; + u8 ins_vlan; + u8 fence_size; + }; + __be32 bf_qpn; +}; + +struct mlx4_wqe_ctrl_seg { + __be32 owner_opcode; + union mlx4_wqe_qpn_vlan qpn_vlan; + union { + __be32 srcrb_flags; + __be16 srcrb_flags16[2]; + }; + __be32 imm; +}; + +struct mlx4_wqe_lso_seg { + __be32 mss_hdr_size; + __be32 header[0]; +}; + +struct mlx4_wqe_data_seg { + __be32 byte_count; + __be32 lkey; + __be64 addr; +}; + +enum { + MLX4_INLINE_ALIGN = 64, + MLX4_INLINE_SEG = 2147483648, +}; + +struct mlx4_wqe_inline_seg { + __be32 byte_count; +}; + +struct mlx4_en_tx_desc { + struct mlx4_wqe_ctrl_seg ctrl; + union { + struct mlx4_wqe_data_seg data; + struct mlx4_wqe_lso_seg lso; + struct mlx4_wqe_inline_seg inl; + }; +}; + +struct mlx4_en_rx_alloc { + struct page *page; + dma_addr_t dma; + u32 page_offset; +}; + +enum { + MLX4_CQE_L2_TUNNEL_IPOK = 2147483648, + MLX4_CQE_CVLAN_PRESENT_MASK = 536870912, + MLX4_CQE_SVLAN_PRESENT_MASK = 1073741824, + MLX4_CQE_L2_TUNNEL = 134217728, + MLX4_CQE_L2_TUNNEL_CSUM = 67108864, + MLX4_CQE_L2_TUNNEL_IPV4 = 33554432, + MLX4_CQE_QPN_MASK = 16777215, + MLX4_CQE_VID_MASK = 4095, +}; + +enum { + MLX4_CQE_STATUS_IPV4 = 64, + MLX4_CQE_STATUS_IPV4F = 128, + MLX4_CQE_STATUS_IPV6 = 256, + MLX4_CQE_STATUS_IPV4OPT = 512, + MLX4_CQE_STATUS_TCP = 1024, + MLX4_CQE_STATUS_UDP = 2048, + MLX4_CQE_STATUS_IPOK = 4096, +}; + +enum { + MLX4_CQE_LLC = 1, + MLX4_CQE_SNAP = 2, + MLX4_CQE_BAD_FCS = 16, +}; + +struct mlx4_rss_context { + __be32 base_qpn; + __be32 default_qpn; + u16 reserved; + u8 hash_fn; + u8 flags; + __be32 rss_key[10]; + __be32 base_qpn_udp; +}; + +struct mlx4_en_rx_desc { + struct mlx4_wqe_data_seg data[0]; +}; + +struct mlx4_mac_entry { + struct hlist_node hlist; + unsigned char mac[8]; + u64 reg_id; + struct callback_head rcu; +}; + +enum tunable_id { + ETHTOOL_ID_UNSPEC = 0, + ETHTOOL_RX_COPYBREAK = 1, + ETHTOOL_TX_COPYBREAK = 2, + ETHTOOL_PFC_PREVENTION_TOUT = 3, + __ETHTOOL_TUNABLE_COUNT = 4, +}; + +enum mlx4_module_id { + MLX4_MODULE_ID_SFP = 3, + MLX4_MODULE_ID_QSFP = 12, + MLX4_MODULE_ID_QSFP_PLUS = 13, + MLX4_MODULE_ID_QSFP28 = 17, +}; + +enum mlx4_ptys_proto { + MLX4_PTYS_IB = 1, + MLX4_PTYS_EN = 4, +}; + +enum mlx4_ptys_flags { + MLX4_PTYS_AN_DISABLE_CAP = 32, + MLX4_PTYS_AN_DISABLE_ADMIN = 64, +}; + +enum mlx4_link_mode { + MLX4_1000BASE_CX_SGMII = 0, + MLX4_1000BASE_KX = 1, + MLX4_10GBASE_CX4 = 2, + MLX4_10GBASE_KX4 = 3, + MLX4_10GBASE_KR = 4, + MLX4_20GBASE_KR2 = 5, + MLX4_40GBASE_CR4 = 6, + MLX4_40GBASE_KR4 = 7, + MLX4_56GBASE_KR4 = 8, + MLX4_10GBASE_CR = 12, + MLX4_10GBASE_SR = 13, + MLX4_40GBASE_SR4 = 15, + MLX4_56GBASE_CR4 = 17, + MLX4_56GBASE_SR4 = 18, + MLX4_100BASE_TX = 24, + MLX4_1000BASE_T = 25, + MLX4_10GBASE_T = 26, +}; + +enum mlx4_en_port_flag { + MLX4_EN_PORT_ANC = 1, + MLX4_EN_PORT_ANE = 2, +}; + +enum mlx4_en_wol { + MLX4_EN_WOL_MAGIC = 0, + MLX4_EN_WOL_ENABLED = 0, +}; + +struct bitmap_iterator { + long unsigned int *stats_bitmap; + unsigned int count; + unsigned int iterator; + bool advance_array; +}; + +enum ethtool_report { + SUPPORTED___2 = 0, + ADVERTISED = 1, +}; + +struct ptys2ethtool_config { + long unsigned int supported[2]; + long unsigned int advertised[2]; + u32 speed; +}; + +struct mlx4_set_vlan_fltr_mbox { + __be32 entry[128]; +}; + +enum { + MLX4_EN_100M_SPEED = 4, + MLX4_EN_10G_SPEED_XAUI = 0, + MLX4_EN_10G_SPEED_XFI = 1, + MLX4_EN_1G_SPEED = 2, + MLX4_EN_20G_SPEED = 8, + MLX4_EN_40G_SPEED = 64, + MLX4_EN_56G_SPEED = 32, + MLX4_EN_OTHER_SPEED = 15, +}; + +struct mlx4_en_query_port_context { + u8 link_up; + u8 autoneg; + __be16 mtu; + u8 reserved2; + u8 link_speed; + u16 reserved3[5]; + __be64 mac; + u8 transceiver; +}; + +struct mlx4_en_stat_out_flow_control_mbox { + __be64 rx_pause; + __be64 rx_pause_duration; + __be64 rx_pause_transition; + __be64 tx_pause; + __be64 tx_pause_duration; + __be64 tx_pause_transition; + __be64 reserved[2]; +}; + +enum { + MLX4_DUMP_ETH_STATS_FLOW_CONTROL = 4096, +}; + +enum { + MLX4_CQ_DB_REQ_NOT_SOL = 16777216, + MLX4_CQ_DB_REQ_NOT = 33554432, +}; + +struct ifbond { + __s32 bond_mode; + __s32 num_slaves; + __s32 miimon; +}; + +typedef struct ifbond ifbond; + +struct ifslave { + __s32 slave_id; + char slave_name[16]; + __s8 link; + __s8 state; + __u32 link_failure_count; +}; + +typedef struct ifslave ifslave; + +struct netdev_bonding_info { + ifslave slave; + ifbond master; +}; + +struct netdev_notifier_bonding_info { + struct netdev_notifier_info info; + struct netdev_bonding_info bonding_info; +}; + +enum { + MLX4_QP_RATE_LIMIT_NONE = 0, + MLX4_QP_RATE_LIMIT_KBS = 1, + MLX4_QP_RATE_LIMIT_MBS = 2, + MLX4_QP_RATE_LIMIT_GBS = 3, +}; + +enum { + VXLAN_STEER_BY_OUTER_MAC = 1, + VXLAN_STEER_BY_OUTER_VLAN = 2, + VXLAN_STEER_BY_VSID_VNI = 4, + VXLAN_STEER_BY_INNER_MAC = 8, + VXLAN_STEER_BY_INNER_VLAN = 16, +}; + +enum { + MLX4_MCAST_CONFIG = 0, + MLX4_MCAST_DISABLE = 1, + MLX4_MCAST_ENABLE = 2, +}; + +enum mlx4_en_mclist_act { + MCLIST_NONE = 0, + MCLIST_REM = 1, + MCLIST_ADD = 2, +}; + +struct mlx4_en_mc_list { + struct list_head list; + enum mlx4_en_mclist_act action; + u8 addr[6]; + u64 reg_id; + u64 tunnel_reg_id; +}; + +struct mlx4_en_filter { + struct list_head next; + struct work_struct work; + u8 ip_proto; + __be32 src_ip; + __be32 dst_ip; + __be16 src_port; + __be16 dst_port; + int rxq_index; + struct mlx4_en_priv *priv; + u32 flow_id; + int id; + u64 reg_id; + u8 activated; + struct hlist_node filter_chain; +}; + +struct mlx4_en_bond { + struct work_struct work; + struct mlx4_en_priv *priv; + int is_bonded; + struct mlx4_port_map port_map; +}; + +struct mlx4_ts_cqe { + __be32 vlan_my_qpn; + __be32 immed_rss_invalid; + __be32 g_mlpath_rqpn; + __be32 timestamp_hi; + __be16 status; + u8 ipv6_ext_mask; + u8 badfcs_enc; + __be32 byte_cnt; + __be16 wqe_index; + __be16 checksum; + u8 reserved; + __be16 timestamp_lo; + u8 owner_sr_opcode; +} __attribute__((packed)); + +enum mlx4_en_congestion_control_algorithm { + MLX4_CTRL_ALGO_802_1_QAU_REACTION_POINT = 0, +}; + +enum mlx4_en_congestion_control_opmod { + MLX4_CONGESTION_CONTROL_GET_PARAMS = 0, + MLX4_CONGESTION_CONTROL_GET_STATISTICS = 1, + MLX4_CONGESTION_CONTROL_SET_PARAMS = 4, +}; + +enum { + MLX4_CEE_STATE_DOWN = 0, + MLX4_CEE_STATE_UP = 1, +}; + +struct mlx4_congestion_control_mb_prio_802_1_qau_params { + __be32 modify_enable_high; + __be32 modify_enable_low; + __be32 reserved1; + __be32 extended_enable; + __be32 rppp_max_rps; + __be32 rpg_time_reset; + __be32 rpg_byte_reset; + __be32 rpg_threshold; + __be32 rpg_max_rate; + __be32 rpg_ai_rate; + __be32 rpg_hai_rate; + __be32 rpg_gd; + __be32 rpg_min_dec_fac; + __be32 rpg_min_rate; + __be32 max_time_rise; + __be32 max_byte_rise; + __be32 max_qdelta; + __be32 min_qoffset; + __be32 gd_coefficient; + __be32 reserved2[5]; + __be32 cp_sample_base; + __be32 reserved3[39]; +}; + +struct mlx4_congestion_control_mb_prio_802_1_qau_statistics { + __be64 rppp_rp_centiseconds; + __be32 reserved1; + __be32 ignored_cnm; + __be32 rppp_created_rps; + __be32 estimated_total_rate; + __be32 max_active_rate_limiter_index; + __be32 dropped_cnms_busy_fw; + __be32 reserved2; + __be32 cnms_handled_successfully; + __be32 min_total_limiters_rate; + __be32 max_total_limiters_rate; + __be32 reserved3[4]; +}; + +struct nfp_cpp_explicit_command { + u32 cpp_id; + u16 data_ref; + u8 data_master; + u8 len; + u8 byte_mask; + u8 signal_master; + u8 signal_ref; + u8 posted; + u8 siga; + u8 sigb; + s8 siga_mode; + s8 sigb_mode; +}; + +struct nfp_cpp; + +struct nfp_cpp_area; + +struct nfp_cpp_explicit; + +struct nfp_cpp_operations { + size_t area_priv_size; + struct module *owner; + int (*init)(struct nfp_cpp *); + void (*free)(struct nfp_cpp *); + int (*read_serial)(struct device *, u8 *); + int (*get_interface)(struct device *); + int (*area_init)(struct nfp_cpp_area *, u32, long long unsigned int, long unsigned int); + void (*area_cleanup)(struct nfp_cpp_area *); + int (*area_acquire)(struct nfp_cpp_area *); + void (*area_release)(struct nfp_cpp_area *); + struct resource * (*area_resource)(struct nfp_cpp_area *); + phys_addr_t (*area_phys)(struct nfp_cpp_area *); + void * (*area_iomem)(struct nfp_cpp_area *); + int (*area_read)(struct nfp_cpp_area *, void *, long unsigned int, unsigned int); + int (*area_write)(struct nfp_cpp_area *, const void *, long unsigned int, unsigned int); + size_t explicit_priv_size; + int (*explicit_acquire)(struct nfp_cpp_explicit *); + void (*explicit_release)(struct nfp_cpp_explicit *); + int (*explicit_put)(struct nfp_cpp_explicit *, const void *, size_t); + int (*explicit_get)(struct nfp_cpp_explicit *, void *, size_t); + int (*explicit_do)(struct nfp_cpp_explicit *, const struct nfp_cpp_explicit_command *, u64); +}; + +struct nfp6000_pcie; + +struct nfp_bar { + struct nfp6000_pcie *nfp; + u32 barcfg; + u64 base; + u64 mask; + u32 bitsize; + int index; + atomic_t refcnt; + void *iomem; + struct resource *resource; +}; + +struct nfp6000_pcie { + struct pci_dev *pdev; + struct device *dev; + spinlock_t bar_lock; + int bars; + struct nfp_bar bar[24]; + wait_queue_head_t bar_waiters; + struct { + void *csr; + void *em; + void *expl[4]; + } iomem; + struct { + struct mutex mutex; + u8 master_id; + u8 signal_ref; + void *data; + struct { + void *addr; + int bitsize; + int free[4]; + } group[4]; + } expl; +}; + +struct nfp6000_area_priv { + atomic_t refcnt; + struct nfp_bar *bar; + u32 bar_offset; + u32 target; + u32 action; + u32 token; + u64 offset; + struct { + int read; + int write; + int bar; + } width; + size_t size; + void *iomem; + phys_addr_t phys; + struct resource resource; +}; + +struct nfp6000_explicit_priv { + struct nfp6000_pcie *nfp; + struct { + int group; + int area; + } bar; + int bitsize; + void *data; + void *addr; +}; + +struct nfp_cpp { + struct device dev; + void *priv; + u32 model; + u16 interface; + u8 serial[6]; + const struct nfp_cpp_operations *op; + struct list_head resource_list; + rwlock_t resource_lock; + wait_queue_head_t waitq; + u32 imb_cat_table[16]; + unsigned int mu_locality_lsb; + struct mutex area_cache_mutex; + struct list_head area_cache_list; +}; + +struct nfp_cpp_resource { + struct list_head list; + const char *name; + u32 cpp_id; + u64 start; + u64 end; +}; + +struct nfp_cpp_area { + struct nfp_cpp *cpp; + struct kref kref; + atomic_t refcount; + struct mutex mutex; + long long unsigned int offset; + long unsigned int size; + struct nfp_cpp_resource resource; + void *iomem; +}; + +struct nfp_cpp_explicit { + struct nfp_cpp *cpp; + struct nfp_cpp_explicit_command cmd; +}; + +enum nfp_cpp_explicit_signal_mode { + NFP_SIGNAL_NONE = 0, + NFP_SIGNAL_PUSH = 1, + NFP_SIGNAL_PUSH_OPTIONAL = 4294967295, + NFP_SIGNAL_PULL = 2, + NFP_SIGNAL_PULL_OPTIONAL = 4294967294, +}; + +struct nfp_cpp_area_cache { + struct list_head entry; + u32 id; + u64 addr; + u32 size; + struct nfp_cpp_area *area; +}; + +struct nfp_hwinfo { + u8 start[0]; + __le32 version; + __le32 size; + __le32 limit; + __le32 resv; + char data[0]; +}; + +struct nfp_resource; + +struct nfp_mip { + __le32 signature; + __le32 mip_version; + __le32 mip_size; + __le32 first_entry; + __le32 version; + __le32 buildnum; + __le32 buildtime; + __le32 loadtime; + __le32 symtab_addr; + __le32 symtab_size; + __le32 strtab_addr; + __le32 strtab_size; + char name[16]; + char toolchain[32]; +}; + +struct nfp_nffw_info; + +struct nfp_cpp_mutex { + struct nfp_cpp *cpp; + int target; + u16 depth; + long long unsigned int address; + u32 key; +}; + +struct nffw_meinfo { + __le32 ctxmask__fwid__meid; +}; + +struct nffw_fwinfo { + __le32 loaded__mu_da__mip_off_hi; + __le32 mip_cppid; + __le32 mip_offset_lo; +}; + +struct nfp_nffw_info_v1 { + struct nffw_meinfo meinfo[120]; + struct nffw_fwinfo fwinfo[120]; +}; + +struct nfp_nffw_info_v2 { + struct nffw_meinfo meinfo[200]; + struct nffw_fwinfo fwinfo[200]; +}; + +struct nfp_nffw_info_data { + __le32 flags[2]; + union { + struct nfp_nffw_info_v1 v1; + struct nfp_nffw_info_v2 v2; + } info; +}; + +struct nfp_nffw_info___2 { + struct nfp_cpp *cpp; + struct nfp_resource *res; + struct nfp_nffw_info_data fwinf; +}; + +enum nfp_nsp_versions { + NFP_VERSIONS_BSP = 0, + NFP_VERSIONS_CPLD = 1, + NFP_VERSIONS_APP = 2, + NFP_VERSIONS_BUNDLE = 3, + NFP_VERSIONS_UNDI = 4, + NFP_VERSIONS_NCSI = 5, + NFP_VERSIONS_CFGR = 6, +}; + +enum nfp_nsp_cmd { + SPCODE_NOOP = 0, + SPCODE_SOFT_RESET = 1, + SPCODE_FW_DEFAULT = 2, + SPCODE_PHY_INIT = 3, + SPCODE_MAC_INIT = 4, + SPCODE_PHY_RXADAPT = 5, + SPCODE_FW_LOAD = 6, + SPCODE_ETH_RESCAN = 7, + SPCODE_ETH_CONTROL = 8, + SPCODE_NSP_WRITE_FLASH = 11, + SPCODE_NSP_SENSORS = 12, + SPCODE_NSP_IDENTIFY = 13, + SPCODE_FW_STORED = 16, + SPCODE_HWINFO_LOOKUP = 17, + SPCODE_HWINFO_SET = 18, + SPCODE_FW_LOADED = 19, + SPCODE_VERSIONS = 21, + SPCODE_READ_SFF_EEPROM = 22, +}; + +struct nfp_nsp_dma_buf { + __le32 chunk_cnt; + __le32 reserved[3]; + struct { + __le32 size; + __le32 reserved; + __le64 addr; + } descs[0]; +}; + +struct nfp_nsp { + struct nfp_cpp *cpp; + struct nfp_resource *res; + struct { + u16 major; + u16 minor; + } ver; + bool modified; + unsigned int idx; + void *entries; +}; + +struct nfp_nsp_command_arg { + u16 code; + bool dma; + unsigned int timeout_sec; + u32 option; + u64 buf; + void (*error_cb)(struct nfp_nsp *, u32); + bool error_quiet; +}; + +struct nfp_nsp_command_buf_arg { + struct nfp_nsp_command_arg arg; + const void *in_buf; + unsigned int in_size; + void *out_buf; + unsigned int out_size; +}; + +struct eeprom_buf { + u8 metalen; + __le16 length; + __le16 offset; + __le16 readlen; + u8 eth_index; + u8 data[0]; +} __attribute__((packed)); + +struct nfp_nsp_identify { + char version[40]; + u8 flags; + u8 br_primary; + u8 br_secondary; + u8 br_nsp; + u16 primary; + u16 secondary; + u16 nsp; + u64 sensor_mask; +}; + +enum nfp_nsp_sensor_id { + NFP_SENSOR_CHIP_TEMPERATURE = 0, + NFP_SENSOR_ASSEMBLY_POWER = 1, + NFP_SENSOR_ASSEMBLY_12V_POWER = 2, + NFP_SENSOR_ASSEMBLY_3V3_POWER = 3, +}; + +struct nsp_identify { + u8 version[40]; + u8 flags; + u8 br_primary; + u8 br_secondary; + u8 br_nsp; + __le16 primary; + __le16 secondary; + __le16 nsp; + u8 reserved[6]; + __le64 sensor_mask; +}; + +struct nfp_sensors { + __le32 chip_temp; + __le32 assembly_power; + __le32 assembly_12v_power; + __le32 assembly_3v3_power; +}; + +struct nfp_nsp___2; + +enum nfp_eth_interface { + NFP_INTERFACE_NONE = 0, + NFP_INTERFACE_SFP = 1, + NFP_INTERFACE_SFPP = 10, + NFP_INTERFACE_SFP28 = 28, + NFP_INTERFACE_QSFP = 40, + NFP_INTERFACE_RJ45 = 45, + NFP_INTERFACE_CXP = 100, + NFP_INTERFACE_QSFP28 = 112, +}; + +enum nfp_eth_media { + NFP_MEDIA_DAC_PASSIVE = 0, + NFP_MEDIA_DAC_ACTIVE = 1, + NFP_MEDIA_FIBRE = 2, +}; + +enum nfp_eth_aneg { + NFP_ANEG_AUTO = 0, + NFP_ANEG_SEARCH = 1, + NFP_ANEG_25G_CONSORTIUM = 2, + NFP_ANEG_25G_IEEE = 3, + NFP_ANEG_DISABLED = 4, +}; + +enum nfp_eth_fec { + NFP_FEC_AUTO_BIT = 0, + NFP_FEC_BASER_BIT = 1, + NFP_FEC_REED_SOLOMON_BIT = 2, + NFP_FEC_DISABLED_BIT = 3, +}; + +struct nfp_eth_table_port { + unsigned int eth_index; + unsigned int index; + unsigned int nbi; + unsigned int base; + unsigned int lanes; + unsigned int speed; + unsigned int interface; + enum nfp_eth_media media; + enum nfp_eth_fec fec; + enum nfp_eth_aneg aneg; + u8 mac_addr[6]; + u8 label_port; + u8 label_subport; + bool enabled; + bool tx_enabled; + bool rx_enabled; + bool override_changed; + u8 port_type; + unsigned int port_lanes; + bool is_split; + unsigned int fec_modes_supported; +}; + +struct nfp_eth_table { + unsigned int count; + unsigned int max_index; + struct nfp_eth_table_port ports[0]; +}; + +enum nfp_eth_raw { + NSP_ETH_RAW_PORT = 0, + NSP_ETH_RAW_STATE = 1, + NSP_ETH_RAW_MAC = 2, + NSP_ETH_RAW_CONTROL = 3, + NSP_ETH_NUM_RAW = 4, +}; + +enum nfp_eth_rate { + RATE_INVALID = 0, + RATE_10M = 1, + RATE_100M = 2, + RATE_1G = 3, + RATE_10G = 4, + RATE_25G = 5, +}; + +union eth_table_entry { + struct { + __le64 port; + __le64 state; + u8 mac_addr[6]; + u8 resv[2]; + __le64 control; + }; + __le64 raw[4]; +}; + +struct nfp_resource_entry_mutex { + u32 owner; + u32 key; +}; + +struct nfp_resource_entry_region { + u8 name[8]; + u8 reserved[5]; + u8 cpp_action; + u8 cpp_token; + u8 cpp_target; + u32 page_offset; + u32 page_size; +}; + +struct nfp_resource_entry { + struct nfp_resource_entry_mutex mutex; + struct nfp_resource_entry_region region; +}; + +struct nfp_cpp_mutex___2; + +struct nfp_resource___2 { + char name[9]; + u32 cpp_id; + u64 addr; + u64 size; + struct nfp_cpp_mutex___2 *mutex; +}; + +enum nfp_rtsym_type { + NFP_RTSYM_TYPE_NONE = 0, + NFP_RTSYM_TYPE_OBJECT = 1, + NFP_RTSYM_TYPE_FUNCTION = 2, + NFP_RTSYM_TYPE_ABS = 3, +}; + +struct nfp_rtsym { + const char *name; + u64 addr; + u64 size; + enum nfp_rtsym_type type; + int target; + int domain; +}; + +struct nfp_rtsym_entry { + u8 type; + u8 target; + u8 island; + u8 addr_hi; + __le32 addr_lo; + __le16 name; + u8 menum; + u8 size_hi; + __le32 size_lo; +}; + +struct nfp_rtsym_table { + struct nfp_cpp *cpp; + int num; + char *strtab; + struct nfp_rtsym symtab[0]; +}; + +struct nfp_mip___2; + +enum nfp_ccm_type { + NFP_CCM_TYPE_BPF_MAP_ALLOC = 1, + NFP_CCM_TYPE_BPF_MAP_FREE = 2, + NFP_CCM_TYPE_BPF_MAP_LOOKUP = 3, + NFP_CCM_TYPE_BPF_MAP_UPDATE = 4, + NFP_CCM_TYPE_BPF_MAP_DELETE = 5, + NFP_CCM_TYPE_BPF_MAP_GETNEXT = 6, + NFP_CCM_TYPE_BPF_MAP_GETFIRST = 7, + NFP_CCM_TYPE_BPF_BPF_EVENT = 8, + NFP_CCM_TYPE_CRYPTO_RESET = 9, + NFP_CCM_TYPE_CRYPTO_ADD = 10, + NFP_CCM_TYPE_CRYPTO_DEL = 11, + NFP_CCM_TYPE_CRYPTO_UPDATE = 12, + NFP_CCM_TYPE_CRYPTO_RESYNC = 13, + __NFP_CCM_TYPE_MAX = 14, +}; + +struct nfp_ccm_hdr { + union { + struct { + u8 type; + u8 ver; + __be16 tag; + }; + __be32 raw; + }; +}; + +struct nfp_app; + +struct nfp_ccm { + struct nfp_app *app; + long unsigned int tag_allocator[1024]; + u16 tag_alloc_next; + u16 tag_alloc_last; + struct sk_buff_head replies; + wait_queue_head_t wq; +}; + +struct nfp_pf; + +struct nfp_net; + +struct nfp_reprs; + +struct nfp_app_type; + +struct nfp_app { + struct pci_dev *pdev; + struct nfp_pf *pf; + struct nfp_cpp *cpp; + struct nfp_net *ctrl; + struct nfp_reprs *reprs[3]; + const struct nfp_app_type *type; + unsigned int ctrl_mtu; + struct notifier_block netdev_nb; + void *priv; +}; + +struct xdp_attachment_info { + struct bpf_prog *prog; + u32 flags; +}; + +enum devlink_eswitch_mode { + DEVLINK_ESWITCH_MODE_LEGACY = 0, + DEVLINK_ESWITCH_MODE_SWITCHDEV = 1, +}; + +struct nfp_reprs { + unsigned int num_reprs; + struct net_device *reprs[0]; +}; + +struct nfp_repr_pcpu_stats { + u64 rx_packets; + u64 rx_bytes; + u64 tx_packets; + u64 tx_bytes; + u64 tx_drops; + struct u64_stats_sync syncp; +}; + +struct nfp_port; + +struct nfp_repr { + struct net_device *netdev; + struct metadata_dst *dst; + struct nfp_port *port; + struct nfp_app *app; + struct nfp_repr_pcpu_stats *stats; + void *app_priv; +}; + +enum nfp_app_id { + NFP_APP_CORE_NIC = 1, + NFP_APP_BPF_NIC = 2, + NFP_APP_FLOWER_NIC = 3, + NFP_APP_ACTIVE_BUFFER_MGMT_NIC = 4, +}; + +struct nfp_app_type { + enum nfp_app_id id; + const char *name; + u32 ctrl_cap_mask; + bool ctrl_has_meta; + int (*init)(struct nfp_app *); + void (*clean)(struct nfp_app *); + const char * (*extra_cap)(struct nfp_app *, struct nfp_net *); + int (*ndo_init)(struct nfp_app *, struct net_device *); + void (*ndo_uninit)(struct nfp_app *, struct net_device *); + int (*vnic_alloc)(struct nfp_app *, struct nfp_net *, unsigned int); + void (*vnic_free)(struct nfp_app *, struct nfp_net *); + int (*vnic_init)(struct nfp_app *, struct nfp_net *); + void (*vnic_clean)(struct nfp_app *, struct nfp_net *); + int (*repr_init)(struct nfp_app *, struct net_device *); + void (*repr_preclean)(struct nfp_app *, struct net_device *); + void (*repr_clean)(struct nfp_app *, struct net_device *); + int (*repr_open)(struct nfp_app *, struct nfp_repr *); + int (*repr_stop)(struct nfp_app *, struct nfp_repr *); + int (*check_mtu)(struct nfp_app *, struct net_device *, int); + int (*repr_change_mtu)(struct nfp_app *, struct net_device *, int); + u64 * (*port_get_stats)(struct nfp_app *, struct nfp_port *, u64 *); + int (*port_get_stats_count)(struct nfp_app *, struct nfp_port *); + u8 * (*port_get_stats_strings)(struct nfp_app *, struct nfp_port *, u8 *); + int (*start)(struct nfp_app *); + void (*stop)(struct nfp_app *); + int (*netdev_event)(struct nfp_app *, struct net_device *, long unsigned int, void *); + void (*ctrl_msg_rx)(struct nfp_app *, struct sk_buff *); + void (*ctrl_msg_rx_raw)(struct nfp_app *, const void *, unsigned int); + int (*setup_tc)(struct nfp_app *, struct net_device *, enum tc_setup_type, void *); + int (*bpf)(struct nfp_app *, struct nfp_net *, struct netdev_bpf *); + int (*xdp_offload)(struct nfp_app *, struct nfp_net *, struct bpf_prog *, struct netlink_ext_ack *); + int (*sriov_enable)(struct nfp_app *, int); + void (*sriov_disable)(struct nfp_app *); + enum devlink_eswitch_mode (*eswitch_mode_get)(struct nfp_app *); + int (*eswitch_mode_set)(struct nfp_app *, u16); + struct net_device * (*dev_get)(struct nfp_app *, u32, bool *); +}; + +struct nfp_net_tx_ring; + +struct nfp_net_rx_ring; + +struct nfp_net_dp { + struct device *dev; + struct net_device *netdev; + u8 is_vf: 1; + u8 chained_metadata_format: 1; + u8 ktls_tx: 1; + u8 rx_dma_dir; + u8 rx_offset; + u32 rx_dma_off; + u32 ctrl; + u32 fl_bufsz; + struct bpf_prog *xdp_prog; + struct nfp_net_tx_ring *tx_rings; + struct nfp_net_rx_ring *rx_rings; + u8 *ctrl_bar; + unsigned int txd_cnt; + unsigned int rxd_cnt; + unsigned int num_r_vecs; + unsigned int num_tx_rings; + unsigned int num_stack_tx_rings; + unsigned int num_rx_rings; + unsigned int mtu; +}; + +struct nfp_net_fw_version { + u8 minor; + u8 major; + u8 class; + u8 resv; +}; + +struct nfp_net_r_vector { + struct nfp_net *nfp_net; + union { + struct napi_struct napi; + struct { + struct tasklet_struct tasklet; + struct sk_buff_head queue; + spinlock_t lock; + }; + }; + struct nfp_net_tx_ring *tx_ring; + struct nfp_net_rx_ring *rx_ring; + u16 irq_entry; + struct u64_stats_sync rx_sync; + u64 rx_pkts; + u64 rx_bytes; + u64 rx_drops; + u64 hw_csum_rx_ok; + u64 hw_csum_rx_inner_ok; + u64 hw_csum_rx_complete; + u64 hw_tls_rx; + u64 hw_csum_rx_error; + u64 rx_replace_buf_alloc_fail; + struct nfp_net_tx_ring *xdp_ring; + struct u64_stats_sync tx_sync; + u64 tx_pkts; + u64 tx_bytes; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + u64 hw_csum_tx; + u64 hw_csum_tx_inner; + u64 tx_gather; + u64 tx_lso; + u64 hw_tls_tx; + u64 tls_tx_fallback; + u64 tls_tx_no_fallback; + u64 tx_errors; + u64 tx_busy; + u32 irq_vector; + irq_handler_t handler; + char name[24]; + cpumask_t affinity_mask; +}; + +struct nfp_net_tlv_caps { + u32 me_freq_mhz; + unsigned int mbox_off; + unsigned int mbox_len; + u32 repr_cap; + u32 mbox_cmsg_types; + u32 crypto_ops; + unsigned int crypto_enable_off; + unsigned int vnic_stats_off; + unsigned int vnic_stats_cnt; + unsigned int tls_resync_ss: 1; +}; + +struct nfp_net { + struct nfp_net_dp dp; + struct nfp_net_fw_version fw_ver; + u32 id; + u32 cap; + u32 max_mtu; + u8 rss_hfunc; + u32 rss_cfg; + u8 rss_key[40]; + u8 rss_itbl[128]; + struct xdp_attachment_info xdp; + struct xdp_attachment_info xdp_hw; + unsigned int max_tx_rings; + unsigned int max_rx_rings; + int stride_tx; + int stride_rx; + unsigned int max_r_vecs; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct nfp_net_r_vector r_vecs[64]; + struct msix_entry irq_entries[66]; + irq_handler_t lsc_handler; + char lsc_name[24]; + irq_handler_t exn_handler; + char exn_name[24]; + irq_handler_t shared_handler; + char shared_name[24]; + u32 me_freq_mhz; + bool link_up; + spinlock_t link_status_lock; + spinlock_t reconfig_lock; + u32 reconfig_posted; + bool reconfig_timer_active; + bool reconfig_sync_present; + struct timer_list reconfig_timer; + u32 reconfig_in_progress_update; + struct semaphore bar_lock; + u32 rx_coalesce_usecs; + u32 rx_coalesce_max_frames; + u32 tx_coalesce_usecs; + u32 tx_coalesce_max_frames; + u8 *qcp_cfg; + u8 *tx_bar; + u8 *rx_bar; + struct nfp_net_tlv_caps tlv_caps; + unsigned int ktls_tx_conn_cnt; + unsigned int ktls_rx_conn_cnt; + atomic64_t ktls_conn_id_gen; + atomic_t ktls_no_space; + atomic_t ktls_rx_resync_req; + atomic_t ktls_rx_resync_ign; + atomic_t ktls_rx_resync_sent; + struct { + struct sk_buff_head queue; + wait_queue_head_t wq; + struct workqueue_struct *workq; + struct work_struct wait_work; + struct work_struct runq_work; + u16 tag; + } mbox_cmsg; + struct dentry *debugfs_dir; + struct list_head vnic_list; + struct pci_dev *pdev; + struct nfp_app *app; + bool vnic_no_name; + struct nfp_port *port; + void *app_priv; + long: 64; + long: 64; + long: 64; +}; + +struct nfp_net_tx_desc { + union { + struct { + u8 dma_addr_hi; + __le16 dma_len; + u8 offset_eop; + __le32 dma_addr_lo; + __le16 mss; + u8 lso_hdrlen; + u8 flags; + union { + struct { + u8 l3_offset; + u8 l4_offset; + }; + __le16 vlan; + }; + __le16 data_len; + } __attribute__((packed)); + __le32 vals[4]; + __le64 vals8[2]; + }; +}; + +struct nfp_net_tx_buf { + union { + struct sk_buff *skb; + void *frag; + }; + dma_addr_t dma_addr; + short int fidx; + u16 pkt_cnt; + u32 real_len; +}; + +struct nfp_net_tx_ring { + struct nfp_net_r_vector *r_vec; + u32 idx; + int qcidx; + u8 *qcp_q; + u32 cnt; + u32 wr_p; + u32 rd_p; + u32 qcp_rd_p; + u32 wr_ptr_add; + struct nfp_net_tx_buf *txbufs; + struct nfp_net_tx_desc *txds; + dma_addr_t dma; + size_t size; + bool is_xdp; + long: 56; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct nfp_net_rx_desc { + union { + struct { + u8 dma_addr_hi; + __le16 reserved; + u8 meta_len_dd; + __le32 dma_addr_lo; + } __attribute__((packed)) fld; + struct { + __le16 data_len; + u8 reserved; + u8 meta_len_dd; + __le16 flags; + __le16 vlan; + } rxd; + __le32 vals[2]; + }; +}; + +struct nfp_net_rx_buf { + void *frag; + dma_addr_t dma_addr; +}; + +struct nfp_net_rx_ring { + struct nfp_net_r_vector *r_vec; + u32 cnt; + u32 wr_p; + u32 rd_p; + u32 idx; + int fl_qcidx; + u8 *qcp_fl; + struct nfp_net_rx_buf *rxbufs; + struct nfp_net_rx_desc *rxds; + long: 64; + struct xdp_rxq_info xdp_rxq; + dma_addr_t dma; + size_t size; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +enum nfp_ccm_mbox_tlv_type { + NFP_NET_MBOX_TLV_TYPE_UNKNOWN = 0, + NFP_NET_MBOX_TLV_TYPE_END = 1, + NFP_NET_MBOX_TLV_TYPE_MSG = 2, + NFP_NET_MBOX_TLV_TYPE_MSG_NOSUP = 3, + NFP_NET_MBOX_TLV_TYPE_RESV = 4, +}; + +enum nfp_net_mbox_cmsg_state { + NFP_NET_MBOX_CMSG_STATE_QUEUED = 0, + NFP_NET_MBOX_CMSG_STATE_NEXT = 1, + NFP_NET_MBOX_CMSG_STATE_BUSY = 2, + NFP_NET_MBOX_CMSG_STATE_REPLY_FOUND = 3, + NFP_NET_MBOX_CMSG_STATE_DONE = 4, +}; + +struct nfp_ccm_mbox_cmsg_cb { + enum nfp_net_mbox_cmsg_state state; + int err; + unsigned int max_len; + unsigned int exp_reply; + bool posted; +}; + +enum devlink_param_fw_load_policy_value { + DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DRIVER = 0, + DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_FLASH = 1, + DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DISK = 2, + DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_UNKNOWN = 3, +}; + +enum devlink_param_reset_dev_on_drv_probe_value { + DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_UNKNOWN = 0, + DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_ALWAYS = 1, + DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_NEVER = 2, + DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_DISK = 3, +}; + +struct nfp_dumpspec { + u32 size; + u8 data[0]; +}; + +struct nfp_rtsym_table___2; + +struct nfp_hwinfo___2; + +struct nfp_shared_buf; + +struct nfp_pf { + struct pci_dev *pdev; + struct nfp_cpp *cpp; + struct nfp_app *app; + struct nfp_cpp_area *data_vnic_bar; + struct nfp_cpp_area *ctrl_vnic_bar; + struct nfp_cpp_area *qc_area; + struct nfp_cpp_area *mac_stats_bar; + u8 *mac_stats_mem; + struct nfp_cpp_area *vf_cfg_bar; + u8 *vf_cfg_mem; + struct nfp_cpp_area *vfcfg_tbl2_area; + u8 *vfcfg_tbl2; + const struct nfp_rtsym *mbox; + struct msix_entry *irq_entries; + unsigned int limit_vfs; + unsigned int num_vfs; + bool fw_loaded; + bool unload_fw_on_remove; + struct nfp_net *ctrl_vnic; + const struct nfp_mip___2 *mip; + struct nfp_rtsym_table___2 *rtbl; + struct nfp_hwinfo___2 *hwinfo; + struct nfp_dumpspec *dumpspec; + u32 dump_flag; + u32 dump_len; + struct nfp_eth_table *eth_tbl; + struct nfp_nsp_identify *nspi; + struct device *hwmon_dev; + struct dentry *ddir; + unsigned int max_data_vnics; + unsigned int num_vnics; + struct list_head vnics; + struct list_head ports; + struct workqueue_struct *wq; + struct work_struct port_refresh_work; + struct nfp_shared_buf *shared_bufs; + unsigned int num_shared_bufs; + struct mutex lock; +}; + +struct nfp_devlink_param_u8_arg { + const char *hwinfo_name; + const char *default_hi_val; + int invalid_dl_val; + u8 hi_to_dl[4]; + u8 dl_to_hi[4]; + u8 max_dl_val; + u8 max_hi_val; +}; + +enum immed_width { + IMMED_WIDTH_ALL = 0, + IMMED_WIDTH_BYTE = 1, + IMMED_WIDTH_WORD = 2, +}; + +enum alu_dst_ab { + ALU_DST_A = 0, + ALU_DST_B = 1, +}; + +struct cmd_tgt_act { + u8 token; + u8 tgt_cmd; +}; + +enum cmd_tgt_map { + CMD_TGT_READ8 = 0, + CMD_TGT_WRITE8_SWAP = 1, + CMD_TGT_WRITE32_SWAP = 2, + CMD_TGT_READ32 = 3, + CMD_TGT_READ32_LE = 4, + CMD_TGT_READ32_SWAP = 5, + CMD_TGT_READ_LE = 6, + CMD_TGT_READ_SWAP_LE = 7, + CMD_TGT_ADD = 8, + CMD_TGT_ADD_IMM = 9, + __CMD_TGT_MAP_SIZE = 10, +}; + +enum nfp_bpf_reg_type { + NN_REG_GPR_A = 1, + NN_REG_GPR_B = 2, + NN_REG_GPR_BOTH = 3, + NN_REG_NNR = 4, + NN_REG_XFER = 8, + NN_REG_IMM = 16, + NN_REG_NONE = 32, + NN_REG_LMEM = 64, +}; + +enum nfp_bpf_lm_mode { + NN_LM_MOD_NONE = 0, + NN_LM_MOD_INC = 1, + NN_LM_MOD_DEC = 2, +}; + +typedef __u32 swreg; + +struct nfp_insn_ur_regs { + enum alu_dst_ab dst_ab; + u16 dst; + u16 areg; + u16 breg; + bool swap; + bool wr_both; + bool dst_lmextn; + bool src_lmextn; +}; + +struct nfp_insn_re_regs { + enum alu_dst_ab dst_ab; + u8 dst; + u8 areg; + u8 breg; + bool swap; + bool wr_both; + bool i8; + bool dst_lmextn; + bool src_lmextn; +}; + +enum nfp_port_type { + NFP_PORT_INVALID = 0, + NFP_PORT_PHYS_PORT = 1, + NFP_PORT_PF_PORT = 2, + NFP_PORT_VF_PORT = 3, +}; + +struct nfp_port { + struct net_device *netdev; + enum nfp_port_type type; + long unsigned int flags; + long unsigned int tc_offload_cnt; + struct nfp_app *app; + struct devlink_port dl_port; + union { + struct { + unsigned int eth_id; + bool eth_forced; + struct nfp_eth_table_port *eth_port; + u8 *eth_stats; + }; + struct { + unsigned int pf_id; + unsigned int vf_id; + bool pf_split; + unsigned int pf_split_id; + u8 *vnic; + }; + }; + struct list_head port_list; +}; + +enum nfp_repr_type { + NFP_REPR_TYPE_PHYS_PORT = 0, + NFP_REPR_TYPE_PF = 1, + NFP_REPR_TYPE_VF = 2, + __NFP_REPR_TYPE_MAX = 3, +}; + +struct nfp_devlink_versions_simple { + const char *key; + const char *hwinfo; +}; + +struct nfp_devlink_versions { + enum nfp_nsp_versions id; + const char *key; +}; + +enum hwmon_sensor_types { + hwmon_chip = 0, + hwmon_temp = 1, + hwmon_in = 2, + hwmon_curr = 3, + hwmon_power = 4, + hwmon_energy = 5, + hwmon_humidity = 6, + hwmon_fan = 7, + hwmon_pwm = 8, + hwmon_intrusion = 9, + hwmon_max = 10, +}; + +enum hwmon_chip_attributes { + hwmon_chip_temp_reset_history = 0, + hwmon_chip_in_reset_history = 1, + hwmon_chip_curr_reset_history = 2, + hwmon_chip_power_reset_history = 3, + hwmon_chip_register_tz = 4, + hwmon_chip_update_interval = 5, + hwmon_chip_alarms = 6, + hwmon_chip_samples = 7, + hwmon_chip_curr_samples = 8, + hwmon_chip_in_samples = 9, + hwmon_chip_power_samples = 10, + hwmon_chip_temp_samples = 11, +}; + +enum hwmon_temp_attributes { + hwmon_temp_enable = 0, + hwmon_temp_input = 1, + hwmon_temp_type = 2, + hwmon_temp_lcrit = 3, + hwmon_temp_lcrit_hyst = 4, + hwmon_temp_min = 5, + hwmon_temp_min_hyst = 6, + hwmon_temp_max = 7, + hwmon_temp_max_hyst = 8, + hwmon_temp_crit = 9, + hwmon_temp_crit_hyst = 10, + hwmon_temp_emergency = 11, + hwmon_temp_emergency_hyst = 12, + hwmon_temp_alarm = 13, + hwmon_temp_lcrit_alarm = 14, + hwmon_temp_min_alarm = 15, + hwmon_temp_max_alarm = 16, + hwmon_temp_crit_alarm = 17, + hwmon_temp_emergency_alarm = 18, + hwmon_temp_fault = 19, + hwmon_temp_offset = 20, + hwmon_temp_label = 21, + hwmon_temp_lowest = 22, + hwmon_temp_highest = 23, + hwmon_temp_reset_history = 24, + hwmon_temp_rated_min = 25, + hwmon_temp_rated_max = 26, +}; + +enum hwmon_power_attributes { + hwmon_power_enable = 0, + hwmon_power_average = 1, + hwmon_power_average_interval = 2, + hwmon_power_average_interval_max = 3, + hwmon_power_average_interval_min = 4, + hwmon_power_average_highest = 5, + hwmon_power_average_lowest = 6, + hwmon_power_average_max = 7, + hwmon_power_average_min = 8, + hwmon_power_input = 9, + hwmon_power_input_highest = 10, + hwmon_power_input_lowest = 11, + hwmon_power_reset_history = 12, + hwmon_power_accuracy = 13, + hwmon_power_cap = 14, + hwmon_power_cap_hyst = 15, + hwmon_power_cap_max = 16, + hwmon_power_cap_min = 17, + hwmon_power_min = 18, + hwmon_power_max = 19, + hwmon_power_crit = 20, + hwmon_power_lcrit = 21, + hwmon_power_label = 22, + hwmon_power_alarm = 23, + hwmon_power_cap_alarm = 24, + hwmon_power_min_alarm = 25, + hwmon_power_max_alarm = 26, + hwmon_power_lcrit_alarm = 27, + hwmon_power_crit_alarm = 28, + hwmon_power_rated_min = 29, + hwmon_power_rated_max = 30, +}; + +struct hwmon_ops { + umode_t (*is_visible)(const void *, enum hwmon_sensor_types, u32, int); + int (*read)(struct device *, enum hwmon_sensor_types, u32, int, long int *); + int (*read_string)(struct device *, enum hwmon_sensor_types, u32, int, const char **); + int (*write)(struct device *, enum hwmon_sensor_types, u32, int, long int); +}; + +struct hwmon_channel_info { + enum hwmon_sensor_types type; + const u32 *config; +}; + +struct hwmon_chip_info { + const struct hwmon_ops *ops; + const struct hwmon_channel_info **info; +}; + +struct nfp_shared_buf { + __le32 id; + __le32 size; + __le16 ingress_pools_count; + __le16 egress_pools_count; + __le16 ingress_tc_count; + __le16 egress_tc_count; + __le32 pool_size_unit; +}; + +enum nfp_dump_diag { + NFP_DUMP_NSP_DIAG = 0, +}; + +struct nfp_meta_parsed { + u8 hash_type; + u8 csum_type; + u32 hash; + u32 mark; + u32 portid; + __wsum csum; +}; + +struct nfp_net_rx_hash { + __be32 hash_type; + __be32 hash; +}; + +enum nfp_qcp_ptr { + NFP_QCP_READ_PTR = 0, + NFP_QCP_WRITE_PTR = 1, +}; + +enum nfp_port_flags { + NFP_PORT_CHANGED = 0, +}; + +struct nfp_net_tls_resync_req { + __be32 fw_handle[2]; + __be32 tcp_seq; + u8 l3_offset; + u8 l4_offset; + u8 resv[2]; +}; + +enum nfp_dumpspec_type { + NFP_DUMPSPEC_TYPE_CPP_CSR = 0, + NFP_DUMPSPEC_TYPE_XPB_CSR = 1, + NFP_DUMPSPEC_TYPE_ME_CSR = 2, + NFP_DUMPSPEC_TYPE_INDIRECT_ME_CSR = 3, + NFP_DUMPSPEC_TYPE_RTSYM = 4, + NFP_DUMPSPEC_TYPE_HWINFO = 5, + NFP_DUMPSPEC_TYPE_FWNAME = 6, + NFP_DUMPSPEC_TYPE_HWINFO_FIELD = 7, + NFP_DUMPSPEC_TYPE_PROLOG = 10000, + NFP_DUMPSPEC_TYPE_ERROR = 10001, +}; + +struct nfp_dump_tl { + __be32 type; + __be32 length; + char data[0]; +}; + +struct nfp_dumpspec_cpp_isl_id { + u8 target; + u8 action; + u8 token; + u8 island; +}; + +struct nfp_dump_common_cpp { + struct nfp_dumpspec_cpp_isl_id cpp_id; + __be32 offset; + __be32 dump_length; +}; + +struct nfp_dumpspec_csr { + struct nfp_dump_tl tl; + struct nfp_dump_common_cpp cpp; + __be32 register_width; +}; + +struct nfp_dumpspec_rtsym { + struct nfp_dump_tl tl; + char rtsym[0]; +}; + +struct nfp_dump_csr { + struct nfp_dump_tl tl; + struct nfp_dump_common_cpp cpp; + __be32 register_width; + __be32 error; + __be32 error_offset; +}; + +struct nfp_dump_rtsym { + struct nfp_dump_tl tl; + struct nfp_dump_common_cpp cpp; + __be32 error; + u8 padded_name_length; + char rtsym[0]; +}; + +struct nfp_dump_prolog { + struct nfp_dump_tl tl; + __be32 dump_level; +}; + +struct nfp_dump_error { + struct nfp_dump_tl tl; + __be32 error; + char padding[4]; + char spec[0]; +}; + +struct nfp_level_size { + __be32 requested_level; + u32 total_size; +}; + +struct nfp_dump_state { + __be32 requested_level; + u32 dumped_size; + u32 buf_size; + void *p; +}; + +typedef int (*nfp_tlv_visit)(struct nfp_pf *, struct nfp_dump_tl *, void *); + +enum ethtool_fec_config_bits { + ETHTOOL_FEC_NONE_BIT = 0, + ETHTOOL_FEC_AUTO_BIT = 1, + ETHTOOL_FEC_OFF_BIT = 2, + ETHTOOL_FEC_RS_BIT = 3, + ETHTOOL_FEC_BASER_BIT = 4, + ETHTOOL_FEC_LLRS_BIT = 5, +}; + +enum { + SFP_PHYS_ID = 0, + SFP_PHYS_EXT_ID = 1, + SFP_CONNECTOR = 2, + SFP_COMPLIANCE = 3, + SFP_ENCODING = 11, + SFP_BR_NOMINAL = 12, + SFP_RATE_ID = 13, + SFP_LINK_LEN_SM_KM = 14, + SFP_LINK_LEN_SM_100M = 15, + SFP_LINK_LEN_50UM_OM2_10M = 16, + SFP_LINK_LEN_62_5UM_OM1_10M = 17, + SFP_LINK_LEN_COPPER_1M = 18, + SFP_LINK_LEN_50UM_OM4_10M = 18, + SFP_LINK_LEN_50UM_OM3_10M = 19, + SFP_VENDOR_NAME = 20, + SFP_VENDOR_OUI = 37, + SFP_VENDOR_PN = 40, + SFP_VENDOR_REV = 56, + SFP_OPTICAL_WAVELENGTH_MSB = 60, + SFP_OPTICAL_WAVELENGTH_LSB = 61, + SFP_CABLE_SPEC = 60, + SFP_CC_BASE = 63, + SFP_OPTIONS = 64, + SFP_BR_MAX = 66, + SFP_BR_MIN = 67, + SFP_VENDOR_SN = 68, + SFP_DATECODE = 84, + SFP_DIAGMON = 92, + SFP_ENHOPTS = 93, + SFP_SFF8472_COMPLIANCE = 94, + SFP_CC_EXT = 95, + SFP_PHYS_EXT_ID_SFP = 4, + SFP_OPTIONS_HIGH_POWER_LEVEL = 8192, + SFP_OPTIONS_PAGING_A2 = 4096, + SFP_OPTIONS_RETIMER = 2048, + SFP_OPTIONS_COOLED_XCVR = 1024, + SFP_OPTIONS_POWER_DECL = 512, + SFP_OPTIONS_RX_LINEAR_OUT = 256, + SFP_OPTIONS_RX_DECISION_THRESH = 128, + SFP_OPTIONS_TUNABLE_TX = 64, + SFP_OPTIONS_RATE_SELECT = 32, + SFP_OPTIONS_TX_DISABLE = 16, + SFP_OPTIONS_TX_FAULT = 8, + SFP_OPTIONS_LOS_INVERTED = 4, + SFP_OPTIONS_LOS_NORMAL = 2, + SFP_DIAGMON_DDM = 64, + SFP_DIAGMON_INT_CAL = 32, + SFP_DIAGMON_EXT_CAL = 16, + SFP_DIAGMON_RXPWR_AVG = 8, + SFP_DIAGMON_ADDRMODE = 4, + SFP_ENHOPTS_ALARMWARN = 128, + SFP_ENHOPTS_SOFT_TX_DISABLE = 64, + SFP_ENHOPTS_SOFT_TX_FAULT = 32, + SFP_ENHOPTS_SOFT_RX_LOS = 16, + SFP_ENHOPTS_SOFT_RATE_SELECT = 8, + SFP_ENHOPTS_APP_SELECT_SFF8079 = 4, + SFP_ENHOPTS_SOFT_RATE_SFF8431 = 2, + SFP_SFF8472_COMPLIANCE_NONE = 0, + SFP_SFF8472_COMPLIANCE_REV9_3 = 1, + SFP_SFF8472_COMPLIANCE_REV9_5 = 2, + SFP_SFF8472_COMPLIANCE_REV10_2 = 3, + SFP_SFF8472_COMPLIANCE_REV10_4 = 4, + SFP_SFF8472_COMPLIANCE_REV11_0 = 5, + SFP_SFF8472_COMPLIANCE_REV11_3 = 6, + SFP_SFF8472_COMPLIANCE_REV11_4 = 7, + SFP_SFF8472_COMPLIANCE_REV12_0 = 8, +}; + +struct nfp_et_stat { + char name[32]; + int off; +}; + +enum { + IFLA_OFFLOAD_XSTATS_UNSPEC = 0, + IFLA_OFFLOAD_XSTATS_CPU_HIT = 1, + __IFLA_OFFLOAD_XSTATS_MAX = 2, +}; + +struct nfp_net_vf { + struct nfp_net *nn; + struct msix_entry irq_entries[66]; + u8 *q_bar; + struct dentry *ddir; +}; + +enum nfp_mbox_cmd { + NFP_MBOX_NO_CMD = 0, + NFP_MBOX_POOL_GET = 1, + NFP_MBOX_POOL_SET = 2, + NFP_MBOX_PCIE_ABM_ENABLE = 3, + NFP_MBOX_PCIE_ABM_DISABLE = 4, +}; + +struct nfp_shared_buf_pool_id { + __le32 shared_buf; + __le32 pool; +}; + +struct nfp_shared_buf_pool_info_get { + __le32 pool_type; + __le32 size; + __le32 threshold_type; +}; + +struct nfp_shared_buf_pool_info_set { + struct nfp_shared_buf_pool_id id; + __le32 size; + __le32 threshold_type; +}; + +enum nfp_bpf_cmsg_status { + CMSG_RC_SUCCESS = 0, + CMSG_RC_ERR_MAP_FD = 1, + CMSG_RC_ERR_MAP_NOENT = 2, + CMSG_RC_ERR_MAP_ERR = 3, + CMSG_RC_ERR_MAP_PARSE = 4, + CMSG_RC_ERR_MAP_EXIST = 5, + CMSG_RC_ERR_MAP_NOMEM = 6, + CMSG_RC_ERR_MAP_E2BIG = 7, +}; + +struct cmsg_reply_map_simple { + struct nfp_ccm_hdr hdr; + __be32 rc; +}; + +struct cmsg_req_map_alloc_tbl { + struct nfp_ccm_hdr hdr; + __be32 key_size; + __be32 value_size; + __be32 max_entries; + __be32 map_type; + __be32 map_flags; +}; + +struct cmsg_reply_map_alloc_tbl { + struct cmsg_reply_map_simple reply_hdr; + __be32 tid; +}; + +struct cmsg_req_map_free_tbl { + struct nfp_ccm_hdr hdr; + __be32 tid; +}; + +struct cmsg_reply_map_free_tbl { + struct cmsg_reply_map_simple reply_hdr; + __be32 count; +}; + +struct cmsg_req_map_op { + struct nfp_ccm_hdr hdr; + __be32 tid; + __be32 count; + __be32 flags; + u8 data[0]; +}; + +struct cmsg_reply_map_op { + struct cmsg_reply_map_simple reply_hdr; + __be32 count; + __be32 resv; + u8 data[0]; +}; + +struct nfp_bpf_cap_adjust_head { + u32 flags; + int off_min; + int off_max; + int guaranteed_sub; + int guaranteed_add; +}; + +struct nfp_app_bpf { + struct nfp_app *app; + struct nfp_ccm ccm; + struct bpf_offload_dev *bpf_dev; + unsigned int cmsg_key_sz; + unsigned int cmsg_val_sz; + unsigned int cmsg_cache_cnt; + struct list_head map_list; + unsigned int maps_in_use; + unsigned int map_elems_in_use; + struct rhashtable maps_neutral; + u32 abi_version; + struct nfp_bpf_cap_adjust_head adjust_head; + struct { + u32 types; + u32 max_maps; + u32 max_elems; + u32 max_key_sz; + u32 max_val_sz; + u32 max_elem_sz; + } maps; + struct { + u32 map_lookup; + u32 map_update; + u32 map_delete; + u32 perf_event_output; + } helpers; + bool pseudo_random; + bool queue_select; + bool adjust_tail; + bool cmsg_multi_ent; +}; + +struct nfp_bpf_map_word { + unsigned char type: 4; + unsigned char non_zero_update: 1; +}; + +struct nfp_bpf_map { + struct bpf_offloaded_map *offmap; + struct nfp_app_bpf *bpf; + u32 tid; + spinlock_t cache_lock; + u32 cache_blockers; + u32 cache_gen; + u64 cache_to; + struct sk_buff *cache; + struct list_head l; + struct nfp_bpf_map_word use_map[0]; +}; + +enum tc_clsbpf_command { + TC_CLSBPF_OFFLOAD = 0, + TC_CLSBPF_STATS = 1, +}; + +struct tc_cls_bpf_offload { + struct flow_cls_common_offload common; + enum tc_clsbpf_command command; + struct tcf_exts *exts; + struct bpf_prog *prog; + struct bpf_prog *oldprog; + const char *name; + bool exts_integrated; +}; + +enum bpf_cap_tlv_type { + NFP_BPF_CAP_TYPE_FUNC = 1, + NFP_BPF_CAP_TYPE_ADJUST_HEAD = 2, + NFP_BPF_CAP_TYPE_MAPS = 3, + NFP_BPF_CAP_TYPE_RANDOM = 4, + NFP_BPF_CAP_TYPE_QUEUE_SELECT = 5, + NFP_BPF_CAP_TYPE_ADJUST_TAIL = 6, + NFP_BPF_CAP_TYPE_ABI_VERSION = 7, + NFP_BPF_CAP_TYPE_CMSG_MULTI_ENT = 8, +}; + +struct nfp_bpf_cap_tlv_func { + __le32 func_id; + __le32 func_addr; +}; + +struct nfp_bpf_cap_tlv_adjust_head { + __le32 flags; + __le32 off_min; + __le32 off_max; + __le32 guaranteed_sub; + __le32 guaranteed_add; +}; + +struct nfp_bpf_cap_tlv_maps { + __le32 types; + __le32 max_maps; + __le32 max_elems; + __le32 max_key_sz; + __le32 max_val_sz; + __le32 max_elem_sz; +}; + +struct nfp_bpf_vnic { + struct bpf_prog *tc_prog; + unsigned int start_off; + unsigned int tgt_done; +}; + +struct cmsg_bpf_event { + struct nfp_ccm_hdr hdr; + __be32 cpu_id; + __be64 map_ptr; + __be32 data_size; + __be32 pkt_size; + u8 data[0]; +}; + +enum nfp_bpf_map_use { + NFP_MAP_UNUSED = 0, + NFP_MAP_USE_READ = 1, + NFP_MAP_USE_WRITE = 2, + NFP_MAP_USE_ATOMIC_CNT = 3, +}; + +struct nfp_bpf_neutral_map { + struct rhash_head l; + struct bpf_map *ptr; + u32 map_id; + u32 count; +}; + +struct nfp_prog; + +struct nfp_insn_meta; + +typedef int (*instr_cb_t)(struct nfp_prog *, struct nfp_insn_meta *); + +struct nfp_bpf_subprog_info; + +struct nfp_prog { + struct nfp_app_bpf *bpf; + u64 *prog; + unsigned int prog_len; + unsigned int __prog_alloc_len; + unsigned int stack_size; + struct nfp_insn_meta *verifier_meta; + enum bpf_prog_type type; + unsigned int last_bpf_off; + unsigned int tgt_out; + unsigned int tgt_abort; + unsigned int tgt_call_push_regs; + unsigned int tgt_call_pop_regs; + unsigned int n_translated; + int error; + unsigned int stack_frame_depth; + unsigned int adjust_head_location; + unsigned int map_records_cnt; + unsigned int subprog_cnt; + struct nfp_bpf_neutral_map **map_records; + struct nfp_bpf_subprog_info *subprog; + unsigned int n_insns; + struct list_head insns; +}; + +struct nfp_bpf_reg_state { + struct bpf_reg_state reg; + bool var_off; +}; + +struct nfp_insn_meta { + struct bpf_insn insn; + union { + struct { + struct bpf_reg_state ptr; + struct bpf_insn *paired_st; + s16 ldst_gather_len; + bool ptr_not_const; + struct { + s16 range_start; + s16 range_end; + bool do_init; + } pkt_cache; + bool xadd_over_16bit; + bool xadd_maybe_16bit; + }; + struct { + struct nfp_insn_meta *jmp_dst; + bool jump_neg_op; + u32 num_insns_after_br; + }; + struct { + u32 func_id; + struct bpf_reg_state arg1; + struct nfp_bpf_reg_state arg2; + }; + struct { + u64 umin_src; + u64 umax_src; + u64 umin_dst; + u64 umax_dst; + }; + }; + unsigned int off; + short unsigned int n; + short unsigned int flags; + short unsigned int subprog_idx; + instr_cb_t double_cb; + struct list_head l; +}; + +struct nfp_bpf_subprog_info { + u16 stack_depth; + u8 needs_reg_push: 1; +}; + +enum br_mask { + BR_BEQ = 0, + BR_BNE = 1, + BR_BMI = 2, + BR_BHS = 4, + BR_BCC = 5, + BR_BLO = 5, + BR_BGE = 8, + BR_BLT = 9, + BR_UNC = 24, +}; + +enum br_ev_pip { + BR_EV_PIP_UNCOND = 0, + BR_EV_PIP_COND = 1, +}; + +enum br_ctx_signal_state { + BR_CSS_NONE = 2, +}; + +enum immed_shift { + IMMED_SHIFT_0B = 0, + IMMED_SHIFT_1B = 1, + IMMED_SHIFT_2B = 2, +}; + +enum shf_op { + SHF_OP_NONE = 0, + SHF_OP_AND = 2, + SHF_OP_OR = 5, + SHF_OP_ASHR = 6, +}; + +enum shf_sc { + SHF_SC_R_ROT = 0, + SHF_SC_NONE = 0, + SHF_SC_R_SHF = 1, + SHF_SC_L_SHF = 2, + SHF_SC_R_DSHF = 3, +}; + +enum alu_op { + ALU_OP_NONE = 0, + ALU_OP_ADD = 1, + ALU_OP_NOT = 4, + ALU_OP_ADD_2B = 5, + ALU_OP_AND = 8, + ALU_OP_AND_NOT_A = 12, + ALU_OP_SUB_C = 13, + ALU_OP_AND_NOT_B = 16, + ALU_OP_ADD_C = 17, + ALU_OP_OR = 20, + ALU_OP_SUB = 21, + ALU_OP_XOR = 24, +}; + +enum cmd_mode { + CMD_MODE_40b_AB = 0, + CMD_MODE_40b_BA = 1, + CMD_MODE_32b = 4, +}; + +enum cmd_ctx_swap { + CMD_CTX_SWAP = 0, + CMD_CTX_SWAP_DEFER1 = 1, + CMD_CTX_SWAP_DEFER2 = 2, + CMD_CTX_NO_SWAP = 3, +}; + +enum mul_type { + MUL_TYPE_START = 0, + MUL_TYPE_STEP_24x8 = 1, + MUL_TYPE_STEP_16x16 = 2, + MUL_TYPE_STEP_32x32 = 3, +}; + +enum mul_step { + MUL_STEP_1 = 0, + MUL_STEP_NONE = 0, + MUL_STEP_2 = 1, + MUL_STEP_3 = 2, + MUL_STEP_4 = 3, + MUL_LAST = 4, + MUL_LAST_2 = 5, +}; + +enum nfp_relo_type { + RELO_NONE = 0, + RELO_BR_REL = 1, + RELO_BR_GO_OUT = 2, + RELO_BR_GO_ABORT = 3, + RELO_BR_GO_CALL_PUSH_REGS = 4, + RELO_BR_GO_CALL_POP_REGS = 5, + RELO_BR_NEXT_PKT = 6, + RELO_BR_HELPER = 7, + RELO_IMMED_REL = 8, +}; + +enum static_regs { + STATIC_REG_IMMA = 20, + STATIC_REG_IMM = 21, + STATIC_REG_STACK = 22, + STATIC_REG_PKT_LEN = 22, +}; + +enum pkt_vec { + PKT_VEC_PKT_LEN = 0, + PKT_VEC_PKT_PTR = 2, + PKT_VEC_QSEL_SET = 4, + PKT_VEC_QSEL_VAL = 6, +}; + +typedef int (*lmem_step)(struct nfp_prog *, u8, u8, s32, unsigned int, bool, bool, bool, bool, bool); + +struct jmp_code_map { + enum br_mask br_mask; + bool swap; +}; + +struct flow_action_cookie { + u32 cookie_len; + u8 cookie[0]; +}; + +struct nsim_sa { + struct xfrm_state *xs; + __be32 ipaddr[4]; + u32 key[4]; + u32 salt; + bool used; + bool crypt; + bool rx; +}; + +struct nsim_ipsec { + struct nsim_sa sa[33]; + struct dentry *pfile; + u32 count; + u32 tx; + u32 ok; +}; + +struct nsim_ethtool { + bool rx; + bool tx; + bool report_stats_rx; + bool report_stats_tx; +}; + +struct nsim_dev; + +struct nsim_dev_port; + +struct nsim_bus_dev; + +struct netdevsim { + struct net_device *netdev; + struct nsim_dev *nsim_dev; + struct nsim_dev_port *nsim_dev_port; + u64 tx_packets; + u64 tx_bytes; + struct u64_stats_sync syncp; + struct nsim_bus_dev *nsim_bus_dev; + struct bpf_prog *bpf_offloaded; + u32 bpf_offloaded_id; + struct xdp_attachment_info xdp; + struct xdp_attachment_info xdp_hw; + bool bpf_tc_accept; + bool bpf_tc_non_bound_accept; + bool bpf_xdpdrv_accept; + bool bpf_xdpoffload_accept; + bool bpf_map_accept; + struct nsim_ipsec ipsec; + struct { + u32 inject_error; + u32 sleep; + u32 __ports[8]; + u32 (*ports)[4]; + struct debugfs_u32_array dfs_ports[2]; + } udp_ports; + struct nsim_ethtool ethtool; +}; + +struct nsim_fib_data; + +struct devlink_health_reporter; + +struct nsim_dev_health { + struct devlink_health_reporter *empty_reporter; + struct devlink_health_reporter *dummy_reporter; + struct dentry *ddir; + char *recovered_break_msg; + u32 binary_len; + bool fail_recover; +}; + +struct nsim_trap_data; + +struct nsim_dev { + struct nsim_bus_dev *nsim_bus_dev; + struct nsim_fib_data *fib_data; + struct nsim_trap_data *trap_data; + struct dentry *ddir; + struct dentry *ports_ddir; + struct dentry *take_snapshot; + struct bpf_offload_dev *bpf_dev; + bool bpf_bind_accept; + u32 bpf_bind_verifier_delay; + struct dentry *ddir_bpf_bound_progs; + u32 prog_id_gen; + struct list_head bpf_bound_progs; + struct list_head bpf_bound_maps; + struct netdev_phys_item_id switch_id; + struct list_head port_list; + struct mutex port_list_lock; + bool fw_update_status; + u32 fw_update_overwrite_mask; + u32 max_macs; + bool test1; + bool dont_allow_reload; + bool fail_reload; + struct devlink_region *dummy_region; + struct nsim_dev_health health; + struct flow_action_cookie *fa_cookie; + spinlock_t fa_cookie_lock; + bool fail_trap_group_set; + bool fail_trap_policer_set; + bool fail_trap_policer_counter_get; + struct { + struct udp_tunnel_nic_shared utn_shared; + u32 __ports[8]; + bool sync_all; + bool open_only; + bool ipv4_only; + bool shared; + bool static_iana_vxlan; + u32 sleep; + } udp_ports; +}; + +struct nsim_dev_port { + struct list_head list; + struct devlink_port devlink_port; + unsigned int port_index; + struct dentry *ddir; + struct netdevsim *ns; +}; + +struct nsim_vf_config; + +struct nsim_bus_dev { + struct device dev; + struct list_head list; + unsigned int port_count; + struct net *initial_net; + unsigned int num_vfs; + struct nsim_vf_config *vfconfigs; + struct mutex nsim_bus_reload_lock; + bool init; +}; + +struct nsim_vf_config { + int link_state; + u16 min_tx_rate; + u16 max_tx_rate; + u16 vlan; + __be16 vlan_proto; + u16 qos; + u8 vf_mac[6]; + bool spoofchk_enabled; + bool trusted; + bool rss_query_enabled; +}; + +enum devlink_resource_unit { + DEVLINK_RESOURCE_UNIT_ENTRY = 0, +}; + +struct devlink_resource_size_params { + u64 size_min; + u64 size_max; + u64 size_granularity; + enum devlink_resource_unit unit; +}; + +enum devlink_trap_generic_id { + DEVLINK_TRAP_GENERIC_ID_SMAC_MC = 0, + DEVLINK_TRAP_GENERIC_ID_VLAN_TAG_MISMATCH = 1, + DEVLINK_TRAP_GENERIC_ID_INGRESS_VLAN_FILTER = 2, + DEVLINK_TRAP_GENERIC_ID_INGRESS_STP_FILTER = 3, + DEVLINK_TRAP_GENERIC_ID_EMPTY_TX_LIST = 4, + DEVLINK_TRAP_GENERIC_ID_PORT_LOOPBACK_FILTER = 5, + DEVLINK_TRAP_GENERIC_ID_BLACKHOLE_ROUTE = 6, + DEVLINK_TRAP_GENERIC_ID_TTL_ERROR = 7, + DEVLINK_TRAP_GENERIC_ID_TAIL_DROP = 8, + DEVLINK_TRAP_GENERIC_ID_NON_IP_PACKET = 9, + DEVLINK_TRAP_GENERIC_ID_UC_DIP_MC_DMAC = 10, + DEVLINK_TRAP_GENERIC_ID_DIP_LB = 11, + DEVLINK_TRAP_GENERIC_ID_SIP_MC = 12, + DEVLINK_TRAP_GENERIC_ID_SIP_LB = 13, + DEVLINK_TRAP_GENERIC_ID_CORRUPTED_IP_HDR = 14, + DEVLINK_TRAP_GENERIC_ID_IPV4_SIP_BC = 15, + DEVLINK_TRAP_GENERIC_ID_IPV6_MC_DIP_RESERVED_SCOPE = 16, + DEVLINK_TRAP_GENERIC_ID_IPV6_MC_DIP_INTERFACE_LOCAL_SCOPE = 17, + DEVLINK_TRAP_GENERIC_ID_MTU_ERROR = 18, + DEVLINK_TRAP_GENERIC_ID_UNRESOLVED_NEIGH = 19, + DEVLINK_TRAP_GENERIC_ID_RPF = 20, + DEVLINK_TRAP_GENERIC_ID_REJECT_ROUTE = 21, + DEVLINK_TRAP_GENERIC_ID_IPV4_LPM_UNICAST_MISS = 22, + DEVLINK_TRAP_GENERIC_ID_IPV6_LPM_UNICAST_MISS = 23, + DEVLINK_TRAP_GENERIC_ID_NON_ROUTABLE = 24, + DEVLINK_TRAP_GENERIC_ID_DECAP_ERROR = 25, + DEVLINK_TRAP_GENERIC_ID_OVERLAY_SMAC_MC = 26, + DEVLINK_TRAP_GENERIC_ID_INGRESS_FLOW_ACTION_DROP = 27, + DEVLINK_TRAP_GENERIC_ID_EGRESS_FLOW_ACTION_DROP = 28, + DEVLINK_TRAP_GENERIC_ID_STP = 29, + DEVLINK_TRAP_GENERIC_ID_LACP = 30, + DEVLINK_TRAP_GENERIC_ID_LLDP = 31, + DEVLINK_TRAP_GENERIC_ID_IGMP_QUERY = 32, + DEVLINK_TRAP_GENERIC_ID_IGMP_V1_REPORT = 33, + DEVLINK_TRAP_GENERIC_ID_IGMP_V2_REPORT = 34, + DEVLINK_TRAP_GENERIC_ID_IGMP_V3_REPORT = 35, + DEVLINK_TRAP_GENERIC_ID_IGMP_V2_LEAVE = 36, + DEVLINK_TRAP_GENERIC_ID_MLD_QUERY = 37, + DEVLINK_TRAP_GENERIC_ID_MLD_V1_REPORT = 38, + DEVLINK_TRAP_GENERIC_ID_MLD_V2_REPORT = 39, + DEVLINK_TRAP_GENERIC_ID_MLD_V1_DONE = 40, + DEVLINK_TRAP_GENERIC_ID_IPV4_DHCP = 41, + DEVLINK_TRAP_GENERIC_ID_IPV6_DHCP = 42, + DEVLINK_TRAP_GENERIC_ID_ARP_REQUEST = 43, + DEVLINK_TRAP_GENERIC_ID_ARP_RESPONSE = 44, + DEVLINK_TRAP_GENERIC_ID_ARP_OVERLAY = 45, + DEVLINK_TRAP_GENERIC_ID_IPV6_NEIGH_SOLICIT = 46, + DEVLINK_TRAP_GENERIC_ID_IPV6_NEIGH_ADVERT = 47, + DEVLINK_TRAP_GENERIC_ID_IPV4_BFD = 48, + DEVLINK_TRAP_GENERIC_ID_IPV6_BFD = 49, + DEVLINK_TRAP_GENERIC_ID_IPV4_OSPF = 50, + DEVLINK_TRAP_GENERIC_ID_IPV6_OSPF = 51, + DEVLINK_TRAP_GENERIC_ID_IPV4_BGP = 52, + DEVLINK_TRAP_GENERIC_ID_IPV6_BGP = 53, + DEVLINK_TRAP_GENERIC_ID_IPV4_VRRP = 54, + DEVLINK_TRAP_GENERIC_ID_IPV6_VRRP = 55, + DEVLINK_TRAP_GENERIC_ID_IPV4_PIM = 56, + DEVLINK_TRAP_GENERIC_ID_IPV6_PIM = 57, + DEVLINK_TRAP_GENERIC_ID_UC_LB = 58, + DEVLINK_TRAP_GENERIC_ID_LOCAL_ROUTE = 59, + DEVLINK_TRAP_GENERIC_ID_EXTERNAL_ROUTE = 60, + DEVLINK_TRAP_GENERIC_ID_IPV6_UC_DIP_LINK_LOCAL_SCOPE = 61, + DEVLINK_TRAP_GENERIC_ID_IPV6_DIP_ALL_NODES = 62, + DEVLINK_TRAP_GENERIC_ID_IPV6_DIP_ALL_ROUTERS = 63, + DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_SOLICIT = 64, + DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_ADVERT = 65, + DEVLINK_TRAP_GENERIC_ID_IPV6_REDIRECT = 66, + DEVLINK_TRAP_GENERIC_ID_IPV4_ROUTER_ALERT = 67, + DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_ALERT = 68, + DEVLINK_TRAP_GENERIC_ID_PTP_EVENT = 69, + DEVLINK_TRAP_GENERIC_ID_PTP_GENERAL = 70, + DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_SAMPLE = 71, + DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_TRAP = 72, + DEVLINK_TRAP_GENERIC_ID_EARLY_DROP = 73, + DEVLINK_TRAP_GENERIC_ID_VXLAN_PARSING = 74, + DEVLINK_TRAP_GENERIC_ID_LLC_SNAP_PARSING = 75, + DEVLINK_TRAP_GENERIC_ID_VLAN_PARSING = 76, + DEVLINK_TRAP_GENERIC_ID_PPPOE_PPP_PARSING = 77, + DEVLINK_TRAP_GENERIC_ID_MPLS_PARSING = 78, + DEVLINK_TRAP_GENERIC_ID_ARP_PARSING = 79, + DEVLINK_TRAP_GENERIC_ID_IP_1_PARSING = 80, + DEVLINK_TRAP_GENERIC_ID_IP_N_PARSING = 81, + DEVLINK_TRAP_GENERIC_ID_GRE_PARSING = 82, + DEVLINK_TRAP_GENERIC_ID_UDP_PARSING = 83, + DEVLINK_TRAP_GENERIC_ID_TCP_PARSING = 84, + DEVLINK_TRAP_GENERIC_ID_IPSEC_PARSING = 85, + DEVLINK_TRAP_GENERIC_ID_SCTP_PARSING = 86, + DEVLINK_TRAP_GENERIC_ID_DCCP_PARSING = 87, + DEVLINK_TRAP_GENERIC_ID_GTP_PARSING = 88, + DEVLINK_TRAP_GENERIC_ID_ESP_PARSING = 89, + __DEVLINK_TRAP_GENERIC_ID_MAX = 90, + DEVLINK_TRAP_GENERIC_ID_MAX = 89, +}; + +enum devlink_trap_group_generic_id { + DEVLINK_TRAP_GROUP_GENERIC_ID_L2_DROPS = 0, + DEVLINK_TRAP_GROUP_GENERIC_ID_L3_DROPS = 1, + DEVLINK_TRAP_GROUP_GENERIC_ID_L3_EXCEPTIONS = 2, + DEVLINK_TRAP_GROUP_GENERIC_ID_BUFFER_DROPS = 3, + DEVLINK_TRAP_GROUP_GENERIC_ID_TUNNEL_DROPS = 4, + DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_DROPS = 5, + DEVLINK_TRAP_GROUP_GENERIC_ID_STP = 6, + DEVLINK_TRAP_GROUP_GENERIC_ID_LACP = 7, + DEVLINK_TRAP_GROUP_GENERIC_ID_LLDP = 8, + DEVLINK_TRAP_GROUP_GENERIC_ID_MC_SNOOPING = 9, + DEVLINK_TRAP_GROUP_GENERIC_ID_DHCP = 10, + DEVLINK_TRAP_GROUP_GENERIC_ID_NEIGH_DISCOVERY = 11, + DEVLINK_TRAP_GROUP_GENERIC_ID_BFD = 12, + DEVLINK_TRAP_GROUP_GENERIC_ID_OSPF = 13, + DEVLINK_TRAP_GROUP_GENERIC_ID_BGP = 14, + DEVLINK_TRAP_GROUP_GENERIC_ID_VRRP = 15, + DEVLINK_TRAP_GROUP_GENERIC_ID_PIM = 16, + DEVLINK_TRAP_GROUP_GENERIC_ID_UC_LB = 17, + DEVLINK_TRAP_GROUP_GENERIC_ID_LOCAL_DELIVERY = 18, + DEVLINK_TRAP_GROUP_GENERIC_ID_EXTERNAL_DELIVERY = 19, + DEVLINK_TRAP_GROUP_GENERIC_ID_IPV6 = 20, + DEVLINK_TRAP_GROUP_GENERIC_ID_PTP_EVENT = 21, + DEVLINK_TRAP_GROUP_GENERIC_ID_PTP_GENERAL = 22, + DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_SAMPLE = 23, + DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_TRAP = 24, + DEVLINK_TRAP_GROUP_GENERIC_ID_PARSER_ERROR_DROPS = 25, + __DEVLINK_TRAP_GROUP_GENERIC_ID_MAX = 26, + DEVLINK_TRAP_GROUP_GENERIC_ID_MAX = 25, +}; + +enum nsim_resource_id { + NSIM_RESOURCE_NONE = 0, + NSIM_RESOURCE_IPV4 = 1, + NSIM_RESOURCE_IPV4_FIB = 2, + NSIM_RESOURCE_IPV4_FIB_RULES = 3, + NSIM_RESOURCE_IPV6 = 4, + NSIM_RESOURCE_IPV6_FIB = 5, + NSIM_RESOURCE_IPV6_FIB_RULES = 6, + NSIM_RESOURCE_NEXTHOPS = 7, +}; + +struct nsim_trap_item; + +struct nsim_trap_data { + struct delayed_work trap_report_dw; + struct nsim_trap_item *trap_items_arr; + u64 *trap_policers_cnt_arr; + struct nsim_dev *nsim_dev; + spinlock_t trap_lock; +}; + +enum nsim_devlink_param_id { + NSIM_DEVLINK_PARAM_ID_BASE = 10, + NSIM_DEVLINK_PARAM_ID_TEST1 = 11, +}; + +struct nsim_trap_item { + void *trap_ctx; + enum devlink_trap_action action; +}; + +enum { + NSIM_TRAP_ID_BASE = 89, + NSIM_TRAP_ID_FID_MISS = 90, +}; + +struct fib_notifier_info { + int family; + struct netlink_ext_ack *extack; +}; + +enum fib_event_type { + FIB_EVENT_ENTRY_REPLACE = 0, + FIB_EVENT_ENTRY_APPEND = 1, + FIB_EVENT_ENTRY_ADD = 2, + FIB_EVENT_ENTRY_DEL = 3, + FIB_EVENT_RULE_ADD = 4, + FIB_EVENT_RULE_DEL = 5, + FIB_EVENT_NH_ADD = 6, + FIB_EVENT_NH_DEL = 7, + FIB_EVENT_VIF_ADD = 8, + FIB_EVENT_VIF_DEL = 9, +}; + +struct fib_rt_info { + struct fib_info *fi; + u32 tb_id; + __be32 dst; + int dst_len; + u8 tos; + u8 type; + u8 offload: 1; + u8 trap: 1; + u8 unused: 6; +}; + +struct fib_entry_notifier_info { + struct fib_notifier_info info; + u32 dst; + int dst_len; + struct fib_info *fi; + u8 tos; + u8 type; + u32 tb_id; +}; + +struct fib6_entry_notifier_info { + struct fib_notifier_info info; + struct fib6_info *rt; + unsigned int nsiblings; +}; + +struct nsim_fib_entry { + u64 max; + u64 num; +}; + +struct nsim_per_fib_data { + struct nsim_fib_entry fib; + struct nsim_fib_entry rules; +}; + +struct nsim_fib_data___2 { + struct notifier_block fib_nb; + struct nsim_per_fib_data ipv4; + struct nsim_per_fib_data ipv6; + struct nsim_fib_entry nexthops; + struct rhashtable fib_rt_ht; + struct list_head fib_rt_list; + spinlock_t fib_lock; + struct notifier_block nexthop_nb; + struct rhashtable nexthop_ht; + struct devlink *devlink; +}; + +struct nsim_fib_rt_key { + unsigned char addr[16]; + unsigned char prefix_len; + int family; + u32 tb_id; +}; + +struct nsim_fib_rt { + struct nsim_fib_rt_key key; + struct rhash_head ht_node; + struct list_head list; +}; + +struct nsim_fib4_rt { + struct nsim_fib_rt common; + struct fib_info *fi; + u8 tos; + u8 type; +}; + +struct nsim_fib6_rt { + struct nsim_fib_rt common; + struct list_head nh_list; + unsigned int nhs; +}; + +struct nsim_fib6_rt_nh { + struct list_head list; + struct fib6_info *rt; +}; + +struct nsim_nexthop { + struct rhash_head ht_node; + u64 occ; + u32 id; +}; + +struct devlink_fmsg; + +struct devlink_health_reporter_ops { + char *name; + int (*recover)(struct devlink_health_reporter *, void *, struct netlink_ext_ack *); + int (*dump)(struct devlink_health_reporter *, struct devlink_fmsg *, void *, struct netlink_ext_ack *); + int (*diagnose)(struct devlink_health_reporter *, struct devlink_fmsg *, struct netlink_ext_ack *); + int (*test)(struct devlink_health_reporter *, struct netlink_ext_ack *); +}; + +struct nsim_dev_dummy_reporter_ctx { + char *break_msg; +}; + +struct nsim_bpf_bound_prog { + struct nsim_dev *nsim_dev; + struct bpf_prog *prog; + struct dentry *ddir; + const char *state; + bool is_loaded; + struct list_head l; +}; + +struct nsim_map_entry { + void *key; + void *value; +}; + +struct nsim_bpf_bound_map { + struct netdevsim *ns; + struct bpf_offloaded_map *map; + struct mutex mutex; + struct nsim_map_entry entry[2]; + struct list_head l; +}; + +struct netpoll_info { + refcount_t refcnt; + struct semaphore dev_lock; + struct sk_buff_head txq; + struct delayed_work tx_work; + struct netpoll *netpoll; + struct callback_head rcu; +}; + +struct netdev_lag_lower_state_info { + u8 link_up: 1; + u8 tx_enabled: 1; +}; + +union inet_addr { + __u32 all[4]; + __be32 ip; + __be32 ip6[4]; + struct in_addr in; + struct in6_addr in6; +}; + +struct netpoll { + struct net_device *dev; + char dev_name[16]; + const char *name; + union inet_addr local_ip; + union inet_addr remote_ip; + bool ipv6; + u16 local_port; + u16 remote_port; + u8 remote_mac[6]; +}; + +struct net_failover_info { + struct net_device *primary_dev; + struct net_device *standby_dev; + struct rtnl_link_stats64 primary_stats; + struct rtnl_link_stats64 standby_stats; + struct rtnl_link_stats64 failover_stats; + spinlock_t stats_lock; +}; + +typedef unsigned char U8; + +typedef short unsigned int U16___2; + +typedef u_int32_t U32___2; + +struct _U64 { + U32___2 Low; + U32___2 High; +}; + +typedef struct _U64 U64___2; + +struct _SGE_SIMPLE32 { + U32___2 FlagsLength; + U32___2 Address; +}; + +typedef struct _SGE_SIMPLE32 SGESimple32_t; + +struct _SGE_SIMPLE64 { + U32___2 FlagsLength; + U64___2 Address; +}; + +typedef struct _SGE_SIMPLE64 SGESimple64_t; + +struct _SGE_SIMPLE_UNION { + U32___2 FlagsLength; + union { + U32___2 Address32; + U64___2 Address64; + } u; +}; + +typedef struct _SGE_SIMPLE_UNION SGE_SIMPLE_UNION; + +struct _SGE_CHAIN32 { + U16___2 Length; + U8 NextChainOffset; + U8 Flags; + U32___2 Address; +}; + +typedef struct _SGE_CHAIN32 SGEChain32_t; + +struct _SGE_CHAIN64 { + U16___2 Length; + U8 NextChainOffset; + U8 Flags; + U64___2 Address; +}; + +typedef struct _SGE_CHAIN64 SGEChain64_t; + +struct _SGE_CHAIN_UNION { + U16___2 Length; + U8 NextChainOffset; + U8 Flags; + union { + U32___2 Address32; + U64___2 Address64; + } u; +}; + +typedef struct _SGE_CHAIN_UNION SGE_CHAIN_UNION; + +struct _SGE_TRANSACTION_UNION { + U8 Reserved; + U8 ContextSize; + U8 DetailsLength; + U8 Flags; + union { + U32___2 TransactionContext32[1]; + U32___2 TransactionContext64[2]; + U32___2 TransactionContext96[3]; + U32___2 TransactionContext128[4]; + } u; + U32___2 TransactionDetails[1]; +}; + +typedef struct _SGE_TRANSACTION_UNION SGE_TRANSACTION_UNION; + +struct _SGE_IO_UNION { + union { + SGE_SIMPLE_UNION Simple; + SGE_CHAIN_UNION Chain; + } u; +}; + +typedef struct _SGE_IO_UNION SGE_IO_UNION; + +struct _SGE_MPI_UNION { + union { + SGE_SIMPLE_UNION Simple; + SGE_CHAIN_UNION Chain; + SGE_TRANSACTION_UNION Transaction; + } u; +}; + +typedef struct _SGE_MPI_UNION SGE_MPI_UNION; + +struct _MSG_REQUEST_HEADER { + U8 Reserved[2]; + U8 ChainOffset; + U8 Function; + U8 Reserved1[3]; + U8 MsgFlags; + U32___2 MsgContext; +}; + +typedef struct _MSG_REQUEST_HEADER MPIHeader_t; + +struct _MSG_DEFAULT_REPLY { + U8 Reserved[2]; + U8 MsgLength; + U8 Function; + U8 Reserved1[3]; + U8 MsgFlags; + U32___2 MsgContext; + U8 Reserved2[2]; + U16___2 IOCStatus; + U32___2 IOCLogInfo; +}; + +typedef struct _MSG_DEFAULT_REPLY MPIDefaultReply_t; + +struct _MSG_IOC_INIT { + U8 WhoInit; + U8 Reserved; + U8 ChainOffset; + U8 Function; + U8 Flags; + U8 MaxDevices; + U8 MaxBuses; + U8 MsgFlags; + U32___2 MsgContext; + U16___2 ReplyFrameSize; + U8 Reserved1[2]; + U32___2 HostMfaHighAddr; + U32___2 SenseBufferHighAddr; + U32___2 ReplyFifoHostSignalingAddr; + SGE_SIMPLE_UNION HostPageBufferSGE; + U16___2 MsgVersion; + U16___2 HeaderVersion; +}; + +typedef struct _MSG_IOC_INIT IOCInit_t; + +typedef struct _MSG_IOC_INIT *pIOCInit_t; + +struct _MSG_IOC_FACTS { + U8 Reserved[2]; + U8 ChainOffset; + U8 Function; + U8 Reserved1[3]; + U8 MsgFlags; + U32___2 MsgContext; +}; + +typedef struct _MSG_IOC_FACTS IOCFacts_t; + +struct _MPI_FW_VERSION_STRUCT { + U8 Dev; + U8 Unit; + U8 Minor; + U8 Major; +}; + +typedef struct _MPI_FW_VERSION_STRUCT MPI_FW_VERSION_STRUCT; + +union _MPI_FW_VERSION { + MPI_FW_VERSION_STRUCT Struct; + U32___2 Word; +}; + +typedef union _MPI_FW_VERSION MPI_FW_VERSION; + +struct _MSG_IOC_FACTS_REPLY { + U16___2 MsgVersion; + U8 MsgLength; + U8 Function; + U16___2 HeaderVersion; + U8 IOCNumber; + U8 MsgFlags; + U32___2 MsgContext; + U16___2 IOCExceptions; + U16___2 IOCStatus; + U32___2 IOCLogInfo; + U8 MaxChainDepth; + U8 WhoInit; + U8 BlockSize; + U8 Flags; + U16___2 ReplyQueueDepth; + U16___2 RequestFrameSize; + U16___2 Reserved_0101_FWVersion; + U16___2 ProductID; + U32___2 CurrentHostMfaHighAddr; + U16___2 GlobalCredits; + U8 NumberOfPorts; + U8 EventState; + U32___2 CurrentSenseBufferHighAddr; + U16___2 CurReplyFrameSize; + U8 MaxDevices; + U8 MaxBuses; + U32___2 FWImageSize; + U32___2 IOCCapabilities; + MPI_FW_VERSION FWVersion; + U16___2 HighPriorityQueueDepth; + U16___2 Reserved2; + SGE_SIMPLE_UNION HostPageBufferSGE; + U32___2 ReplyFifoHostSignalingAddr; +}; + +typedef struct _MSG_IOC_FACTS_REPLY IOCFactsReply_t; + +struct _MSG_PORT_FACTS { + U8 Reserved[2]; + U8 ChainOffset; + U8 Function; + U8 Reserved1[2]; + U8 PortNumber; + U8 MsgFlags; + U32___2 MsgContext; +}; + +typedef struct _MSG_PORT_FACTS PortFacts_t; + +struct _MSG_PORT_FACTS_REPLY { + U16___2 Reserved; + U8 MsgLength; + U8 Function; + U16___2 Reserved1; + U8 PortNumber; + U8 MsgFlags; + U32___2 MsgContext; + U16___2 Reserved2; + U16___2 IOCStatus; + U32___2 IOCLogInfo; + U8 Reserved3; + U8 PortType; + U16___2 MaxDevices; + U16___2 PortSCSIID; + U16___2 ProtocolFlags; + U16___2 MaxPostedCmdBuffers; + U16___2 MaxPersistentIDs; + U16___2 MaxLanBuckets; + U8 MaxInitiators; + U8 Reserved4; + U32___2 Reserved5; +}; + +typedef struct _MSG_PORT_FACTS_REPLY PortFactsReply_t; + +struct _MSG_PORT_ENABLE { + U8 Reserved[2]; + U8 ChainOffset; + U8 Function; + U8 Reserved1[2]; + U8 PortNumber; + U8 MsgFlags; + U32___2 MsgContext; +}; + +typedef struct _MSG_PORT_ENABLE PortEnable_t; + +struct _MSG_EVENT_NOTIFY { + U8 Switch; + U8 Reserved; + U8 ChainOffset; + U8 Function; + U8 Reserved1[3]; + U8 MsgFlags; + U32___2 MsgContext; +}; + +typedef struct _MSG_EVENT_NOTIFY EventNotification_t; + +struct _MSG_EVENT_NOTIFY_REPLY { + U16___2 EventDataLength; + U8 MsgLength; + U8 Function; + U8 Reserved1[2]; + U8 AckRequired; + U8 MsgFlags; + U32___2 MsgContext; + U8 Reserved2[2]; + U16___2 IOCStatus; + U32___2 IOCLogInfo; + U32___2 Event; + U32___2 EventContext; + U32___2 Data[1]; +}; + +typedef struct _MSG_EVENT_NOTIFY_REPLY EventNotificationReply_t; + +struct _MSG_EVENT_ACK { + U8 Reserved[2]; + U8 ChainOffset; + U8 Function; + U8 Reserved1[3]; + U8 MsgFlags; + U32___2 MsgContext; + U32___2 Event; + U32___2 EventContext; +}; + +typedef struct _MSG_EVENT_ACK EventAck_t; + +struct _EVENT_DATA_RAID { + U8 VolumeID; + U8 VolumeBus; + U8 ReasonCode; + U8 PhysDiskNum; + U8 ASC; + U8 ASCQ; + U16___2 Reserved; + U32___2 SettingsStatus; +}; + +typedef struct _EVENT_DATA_RAID MpiEventDataRaid_t; + +struct _MSG_FW_UPLOAD { + U8 ImageType; + U8 Reserved; + U8 ChainOffset; + U8 Function; + U8 Reserved1[3]; + U8 MsgFlags; + U32___2 MsgContext; + SGE_MPI_UNION SGL; +}; + +typedef struct _MSG_FW_UPLOAD FWUpload_t; + +struct _FWUploadTCSGE { + U8 Reserved; + U8 ContextSize; + U8 DetailsLength; + U8 Flags; + U32___2 Reserved1; + U32___2 ImageOffset; + U32___2 ImageSize; +}; + +typedef struct _FWUploadTCSGE FWUploadTCSGE_t; + +struct _MSG_FW_UPLOAD_REPLY { + U8 ImageType; + U8 Reserved; + U8 MsgLength; + U8 Function; + U8 Reserved1[3]; + U8 MsgFlags; + U32___2 MsgContext; + U16___2 Reserved2; + U16___2 IOCStatus; + U32___2 IOCLogInfo; + U32___2 ActualImageSize; +}; + +typedef struct _MSG_FW_UPLOAD_REPLY FWUploadReply_t; + +struct _MPI_FW_HEADER { + U32___2 ArmBranchInstruction0; + U32___2 Signature0; + U32___2 Signature1; + U32___2 Signature2; + U32___2 ArmBranchInstruction1; + U32___2 ArmBranchInstruction2; + U32___2 Reserved; + U32___2 Checksum; + U16___2 VendorId; + U16___2 ProductId; + MPI_FW_VERSION FWVersion; + U32___2 SeqCodeVersion; + U32___2 ImageSize; + U32___2 NextImageHeaderOffset; + U32___2 LoadStartAddress; + U32___2 IopResetVectorValue; + U32___2 IopResetRegAddr; + U32___2 VersionNameWhat; + U8 VersionName[32]; + U32___2 VendorNameWhat; + U8 VendorName[32]; +}; + +typedef struct _MPI_FW_HEADER MpiFwHeader_t; + +struct _MPI_EXT_IMAGE_HEADER { + U8 ImageType; + U8 Reserved; + U16___2 Reserved1; + U32___2 Checksum; + U32___2 ImageSize; + U32___2 NextImageHeaderOffset; + U32___2 LoadStartAddress; + U32___2 Reserved2; +}; + +typedef struct _MPI_EXT_IMAGE_HEADER MpiExtImageHeader_t; + +struct _CONFIG_PAGE_HEADER { + U8 PageVersion; + U8 PageLength; + U8 PageNumber; + U8 PageType; +}; + +typedef struct _CONFIG_PAGE_HEADER CONFIG_PAGE_HEADER; + +typedef struct _CONFIG_PAGE_HEADER ConfigPageHeader_t; + +struct _CONFIG_EXTENDED_PAGE_HEADER { + U8 PageVersion; + U8 Reserved1; + U8 PageNumber; + U8 PageType; + U16___2 ExtPageLength; + U8 ExtPageType; + U8 Reserved2; +}; + +typedef struct _CONFIG_EXTENDED_PAGE_HEADER CONFIG_EXTENDED_PAGE_HEADER; + +typedef struct _CONFIG_EXTENDED_PAGE_HEADER ConfigExtendedPageHeader_t; + +struct _MSG_CONFIG { + U8 Action; + U8 Reserved; + U8 ChainOffset; + U8 Function; + U16___2 ExtPageLength; + U8 ExtPageType; + U8 MsgFlags; + U32___2 MsgContext; + U8 Reserved2[8]; + CONFIG_PAGE_HEADER Header; + U32___2 PageAddress; + SGE_IO_UNION PageBufferSGE; +}; + +typedef struct _MSG_CONFIG Config_t; + +struct _MSG_CONFIG_REPLY { + U8 Action; + U8 Reserved; + U8 MsgLength; + U8 Function; + U16___2 ExtPageLength; + U8 ExtPageType; + U8 MsgFlags; + U32___2 MsgContext; + U8 Reserved2[2]; + U16___2 IOCStatus; + U32___2 IOCLogInfo; + CONFIG_PAGE_HEADER Header; +}; + +typedef struct _MSG_CONFIG_REPLY ConfigReply_t; + +struct _CONFIG_PAGE_MANUFACTURING_0 { + CONFIG_PAGE_HEADER Header; + U8 ChipName[16]; + U8 ChipRevision[8]; + U8 BoardName[16]; + U8 BoardAssembly[16]; + U8 BoardTracerNumber[16]; +}; + +typedef struct _CONFIG_PAGE_MANUFACTURING_0 ManufacturingPage0_t; + +struct _MPI_ADAPTER_INFO { + U8 PciBusNumber; + U8 PciDeviceAndFunctionNumber; + U16___2 AdapterFlags; +}; + +typedef struct _MPI_ADAPTER_INFO MPI_ADAPTER_INFO; + +struct _CONFIG_PAGE_IO_UNIT_2 { + CONFIG_PAGE_HEADER Header; + U32___2 Flags; + U32___2 BiosVersion; + MPI_ADAPTER_INFO AdapterOrder[4]; + U32___2 Reserved1; +}; + +typedef struct _CONFIG_PAGE_IO_UNIT_2 IOUnitPage2_t; + +struct _CONFIG_PAGE_IOC_1 { + CONFIG_PAGE_HEADER Header; + U32___2 Flags; + U32___2 CoalescingTimeout; + U8 CoalescingDepth; + U8 PCISlotNum; + U8 Reserved[2]; +}; + +typedef struct _CONFIG_PAGE_IOC_1 IOCPage1_t; + +struct _CONFIG_PAGE_IOC_2_RAID_VOL { + U8 VolumeID; + U8 VolumeBus; + U8 VolumeIOC; + U8 VolumePageNumber; + U8 VolumeType; + U8 Flags; + U16___2 Reserved3; +}; + +typedef struct _CONFIG_PAGE_IOC_2_RAID_VOL CONFIG_PAGE_IOC_2_RAID_VOL; + +struct _CONFIG_PAGE_IOC_2 { + CONFIG_PAGE_HEADER Header; + U32___2 CapabilitiesFlags; + U8 NumActiveVolumes; + U8 MaxVolumes; + U8 NumActivePhysDisks; + U8 MaxPhysDisks; + CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[1]; +}; + +typedef struct _CONFIG_PAGE_IOC_2 IOCPage2_t; + +struct _IOC_3_PHYS_DISK { + U8 PhysDiskID; + U8 PhysDiskBus; + U8 PhysDiskIOC; + U8 PhysDiskNum; +}; + +typedef struct _IOC_3_PHYS_DISK IOC_3_PHYS_DISK; + +struct _CONFIG_PAGE_IOC_3 { + CONFIG_PAGE_HEADER Header; + U8 NumPhysDisks; + U8 Reserved1; + U16___2 Reserved2; + IOC_3_PHYS_DISK PhysDisk[1]; +}; + +typedef struct _CONFIG_PAGE_IOC_3 IOCPage3_t; + +struct _IOC_4_SEP { + U8 SEPTargetID; + U8 SEPBus; + U16___2 Reserved; +}; + +typedef struct _IOC_4_SEP IOC_4_SEP; + +struct _CONFIG_PAGE_IOC_4 { + CONFIG_PAGE_HEADER Header; + U8 ActiveSEP; + U8 MaxSEP; + U16___2 Reserved1; + IOC_4_SEP SEP[1]; +}; + +typedef struct _CONFIG_PAGE_IOC_4 IOCPage4_t; + +struct _CONFIG_PAGE_SCSI_PORT_0 { + CONFIG_PAGE_HEADER Header; + U32___2 Capabilities; + U32___2 PhysicalInterface; +}; + +typedef struct _CONFIG_PAGE_SCSI_PORT_0 SCSIPortPage0_t; + +struct _MPI_DEVICE_INFO { + U8 Timeout; + U8 SyncFactor; + U16___2 DeviceFlags; +}; + +typedef struct _MPI_DEVICE_INFO MPI_DEVICE_INFO; + +typedef struct _MPI_DEVICE_INFO MpiDeviceInfo_t; + +struct _CONFIG_PAGE_SCSI_PORT_2 { + CONFIG_PAGE_HEADER Header; + U32___2 PortFlags; + U32___2 PortSettings; + MPI_DEVICE_INFO DeviceSettings[16]; +}; + +typedef struct _CONFIG_PAGE_SCSI_PORT_2 SCSIPortPage2_t; + +struct _CONFIG_PAGE_FC_PORT_0 { + CONFIG_PAGE_HEADER Header; + U32___2 Flags; + U8 MPIPortNumber; + U8 LinkType; + U8 PortState; + U8 Reserved; + U32___2 PortIdentifier; + U64___2 WWNN; + U64___2 WWPN; + U32___2 SupportedServiceClass; + U32___2 SupportedSpeeds; + U32___2 CurrentSpeed; + U32___2 MaxFrameSize; + U64___2 FabricWWNN; + U64___2 FabricWWPN; + U32___2 DiscoveredPortsCount; + U32___2 MaxInitiators; + U8 MaxAliasesSupported; + U8 MaxHardAliasesSupported; + U8 NumCurrentAliases; + U8 Reserved1; +}; + +typedef struct _CONFIG_PAGE_FC_PORT_0 FCPortPage0_t; + +struct _CONFIG_PAGE_FC_PORT_1 { + CONFIG_PAGE_HEADER Header; + U32___2 Flags; + U64___2 NoSEEPROMWWNN; + U64___2 NoSEEPROMWWPN; + U8 HardALPA; + U8 LinkConfig; + U8 TopologyConfig; + U8 AltConnector; + U8 NumRequestedAliases; + U8 RR_TOV; + U8 InitiatorDeviceTimeout; + U8 InitiatorIoPendTimeout; +}; + +typedef struct _CONFIG_PAGE_FC_PORT_1 FCPortPage1_t; + +struct _RAID_VOL0_PHYS_DISK { + U16___2 Reserved; + U8 PhysDiskMap; + U8 PhysDiskNum; +}; + +typedef struct _RAID_VOL0_PHYS_DISK RAID_VOL0_PHYS_DISK; + +struct _RAID_VOL0_STATUS { + U8 Flags; + U8 State; + U16___2 Reserved; +}; + +typedef struct _RAID_VOL0_STATUS RAID_VOL0_STATUS; + +struct _RAID_VOL0_SETTINGS { + U16___2 Settings; + U8 HotSparePool; + U8 Reserved; +}; + +typedef struct _RAID_VOL0_SETTINGS RAID_VOL0_SETTINGS; + +struct _CONFIG_PAGE_RAID_VOL_0 { + CONFIG_PAGE_HEADER Header; + U8 VolumeID; + U8 VolumeBus; + U8 VolumeIOC; + U8 VolumeType; + RAID_VOL0_STATUS VolumeStatus; + RAID_VOL0_SETTINGS VolumeSettings; + U32___2 MaxLBA; + U32___2 MaxLBAHigh; + U32___2 StripeSize; + U32___2 Reserved2; + U32___2 Reserved3; + U8 NumPhysDisks; + U8 DataScrubRate; + U8 ResyncRate; + U8 InactiveStatus; + RAID_VOL0_PHYS_DISK PhysDisk[1]; +}; + +typedef struct _CONFIG_PAGE_RAID_VOL_0 *pRaidVolumePage0_t; + +struct _RAID_PHYS_DISK0_ERROR_DATA { + U8 ErrorCdbByte; + U8 ErrorSenseKey; + U16___2 Reserved; + U16___2 ErrorCount; + U8 ErrorASC; + U8 ErrorASCQ; + U16___2 SmartCount; + U8 SmartASC; + U8 SmartASCQ; +}; + +typedef struct _RAID_PHYS_DISK0_ERROR_DATA RAID_PHYS_DISK0_ERROR_DATA; + +struct _RAID_PHYS_DISK_INQUIRY_DATA { + U8 VendorID[8]; + U8 ProductID[16]; + U8 ProductRevLevel[4]; + U8 Info[32]; +}; + +typedef struct _RAID_PHYS_DISK_INQUIRY_DATA RAID_PHYS_DISK0_INQUIRY_DATA; + +struct _RAID_PHYS_DISK0_SETTINGS { + U8 SepID; + U8 SepBus; + U8 HotSparePool; + U8 PhysDiskSettings; +}; + +typedef struct _RAID_PHYS_DISK0_SETTINGS RAID_PHYS_DISK0_SETTINGS; + +struct _RAID_PHYS_DISK0_STATUS { + U8 Flags; + U8 State; + U16___2 Reserved; +}; + +typedef struct _RAID_PHYS_DISK0_STATUS RAID_PHYS_DISK0_STATUS; + +struct _CONFIG_PAGE_RAID_PHYS_DISK_0 { + CONFIG_PAGE_HEADER Header; + U8 PhysDiskID; + U8 PhysDiskBus; + U8 PhysDiskIOC; + U8 PhysDiskNum; + RAID_PHYS_DISK0_SETTINGS PhysDiskSettings; + U32___2 Reserved1; + U8 ExtDiskIdentifier[8]; + U8 DiskIdentifier[16]; + RAID_PHYS_DISK0_INQUIRY_DATA InquiryData; + RAID_PHYS_DISK0_STATUS PhysDiskStatus; + U32___2 MaxLBA; + RAID_PHYS_DISK0_ERROR_DATA ErrorData; +}; + +typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_0 RaidPhysDiskPage0_t; + +typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_0 *pRaidPhysDiskPage0_t; + +struct _RAID_PHYS_DISK1_PATH { + U8 PhysDiskID; + U8 PhysDiskBus; + U16___2 Reserved1; + U64___2 WWID; + U64___2 OwnerWWID; + U8 OwnerIdentifier; + U8 Reserved2; + U16___2 Flags; +}; + +typedef struct _RAID_PHYS_DISK1_PATH RAID_PHYS_DISK1_PATH; + +struct _CONFIG_PAGE_RAID_PHYS_DISK_1 { + CONFIG_PAGE_HEADER Header; + U8 NumPhysDiskPaths; + U8 PhysDiskNum; + U16___2 Reserved2; + U32___2 Reserved1; + RAID_PHYS_DISK1_PATH Path[1]; +}; + +typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1 RaidPhysDiskPage1_t; + +typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1 *pRaidPhysDiskPage1_t; + +struct _CONFIG_PAGE_LAN_0 { + ConfigPageHeader_t Header; + U16___2 TxRxModes; + U16___2 Reserved; + U32___2 PacketPrePad; +}; + +typedef struct _CONFIG_PAGE_LAN_0 LANPage0_t; + +struct _CONFIG_PAGE_LAN_1 { + ConfigPageHeader_t Header; + U16___2 Reserved; + U8 CurrentDeviceState; + U8 Reserved1; + U32___2 MinPacketSize; + U32___2 MaxPacketSize; + U32___2 HardwareAddressLow; + U32___2 HardwareAddressHigh; + U32___2 MaxWireSpeedLow; + U32___2 MaxWireSpeedHigh; + U32___2 BucketsRemaining; + U32___2 MaxReplySize; + U32___2 NegWireSpeedLow; + U32___2 NegWireSpeedHigh; +}; + +typedef struct _CONFIG_PAGE_LAN_1 LANPage1_t; + +struct _MPI_SAS_IO_UNIT0_PHY_DATA { + U8 Port; + U8 PortFlags; + U8 PhyFlags; + U8 NegotiatedLinkRate; + U32___2 ControllerPhyDeviceInfo; + U16___2 AttachedDeviceHandle; + U16___2 ControllerDevHandle; + U32___2 DiscoveryStatus; +}; + +typedef struct _MPI_SAS_IO_UNIT0_PHY_DATA MPI_SAS_IO_UNIT0_PHY_DATA; + +struct _CONFIG_PAGE_SAS_IO_UNIT_0 { + CONFIG_EXTENDED_PAGE_HEADER Header; + U16___2 NvdataVersionDefault; + U16___2 NvdataVersionPersistent; + U8 NumPhys; + U8 Reserved2; + U16___2 Reserved3; + MPI_SAS_IO_UNIT0_PHY_DATA PhyData[1]; +}; + +typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0 SasIOUnitPage0_t; + +struct _MSG_SCSI_IO_REQUEST { + U8 TargetID; + U8 Bus; + U8 ChainOffset; + U8 Function; + U8 CDBLength; + U8 SenseBufferLength; + U8 Reserved; + U8 MsgFlags; + U32___2 MsgContext; + U8 LUN[8]; + U32___2 Control; + U8 CDB[16]; + U32___2 DataLength; + U32___2 SenseBufferLowAddr; + SGE_IO_UNION SGL; +}; + +typedef struct _MSG_SCSI_IO_REQUEST SCSIIORequest_t; + +struct _MSG_SCSI_IO_REPLY { + U8 TargetID; + U8 Bus; + U8 MsgLength; + U8 Function; + U8 CDBLength; + U8 SenseBufferLength; + U8 Reserved; + U8 MsgFlags; + U32___2 MsgContext; + U8 SCSIStatus; + U8 SCSIState; + U16___2 IOCStatus; + U32___2 IOCLogInfo; + U32___2 TransferCount; + U32___2 SenseCount; + U32___2 ResponseInfo; + U16___2 TaskTag; + U16___2 Reserved1; +}; + +typedef struct _MSG_SCSI_IO_REPLY SCSIIOReply_t; + +struct _MSG_SAS_IOUNIT_CONTROL_REQUEST { + U8 Operation; + U8 Reserved1; + U8 ChainOffset; + U8 Function; + U16___2 DevHandle; + U8 IOCParameter; + U8 MsgFlags; + U32___2 MsgContext; + U8 TargetID; + U8 Bus; + U8 PhyNum; + U8 PrimFlags; + U32___2 Primitive; + U64___2 SASAddress; + U32___2 IOCParameterValue; +}; + +typedef struct _MSG_SAS_IOUNIT_CONTROL_REQUEST SasIoUnitControlRequest_t; + +struct _MSG_SAS_IOUNIT_CONTROL_REPLY { + U8 Operation; + U8 Reserved1; + U8 MsgLength; + U8 Function; + U16___2 DevHandle; + U8 IOCParameter; + U8 MsgFlags; + U32___2 MsgContext; + U16___2 Reserved4; + U16___2 IOCStatus; + U32___2 IOCLogInfo; +}; + +typedef struct _MSG_SAS_IOUNIT_CONTROL_REPLY SasIoUnitControlReply_t; + +struct _ATTO_DEVICE_INFO { + u8 Offset; + u8 Period; + u16 ATTOFlags; +}; + +typedef struct _ATTO_DEVICE_INFO ATTO_DEVICE_INFO; + +typedef struct _ATTO_DEVICE_INFO ATTODeviceInfo_t; + +struct _ATTO_CONFIG_PAGE_SCSI_PORT_2 { + CONFIG_PAGE_HEADER Header; + u16 PortFlags; + u16 Unused1; + u32 Unused2; + ATTO_DEVICE_INFO DeviceSettings[16]; +}; + +typedef struct _ATTO_CONFIG_PAGE_SCSI_PORT_2 ATTO_SCSIPortPage2_t; + +typedef enum { + MPTBASE_DRIVER = 0, + MPTCTL_DRIVER = 1, + MPTSPI_DRIVER = 2, + MPTFC_DRIVER = 3, + MPTSAS_DRIVER = 4, + MPTLAN_DRIVER = 5, + MPTSTM_DRIVER = 6, + MPTUNKNOWN_DRIVER = 7, +} MPT_DRIVER_CLASS; + +struct mpt_pci_driver { + int (*probe)(struct pci_dev *, const struct pci_device_id *); + void (*remove)(struct pci_dev *); +}; + +union _MPT_FRAME_TRACKER { + struct { + struct list_head list; + u32 arg1; + u32 pad; + void *argp1; + } linkage; + struct { + u32 __hdr[2]; + union { + u32 MsgContext; + struct { + u16 req_idx; + u8 cb_idx; + u8 rsvd; + } fld; + } msgctxu; + } hwhdr; +}; + +typedef union _MPT_FRAME_TRACKER MPT_FRAME_TRACKER; + +struct _MPT_FRAME_HDR { + union { + MPIHeader_t hdr; + SCSIIORequest_t scsireq; + SCSIIOReply_t sreply; + ConfigReply_t configreply; + MPIDefaultReply_t reply; + MPT_FRAME_TRACKER frame; + } u; +}; + +typedef struct _MPT_FRAME_HDR MPT_FRAME_HDR; + +struct _SYSIF_REGS { + u32 Doorbell; + u32 WriteSequence; + u32 Diagnostic; + u32 TestBase; + u32 DiagRwData; + u32 DiagRwAddress; + u32 Reserved1[6]; + u32 IntStatus; + u32 IntMask; + u32 Reserved2[2]; + u32 RequestFifo; + u32 ReplyFifo; + u32 RequestHiPriFifo; + u32 Reserved3; + u32 HostIndex; + u32 Reserved4[15]; + u32 Fubar; + u32 Reserved5[1050]; + u32 Reset_1078; +}; + +typedef struct _SYSIF_REGS SYSIF_REGS; + +struct _MPT_MGMT { + struct mutex mutex; + struct completion done; + u8 reply[128]; + u8 sense[64]; + u8 status; + int completion_code; + u32 msg_context; +}; + +typedef struct _MPT_MGMT MPT_MGMT; + +struct _mpt_ioctl_events { + u32 event; + u32 eventContext; + u32 data[2]; +}; + +struct _SpiCfgData { + u32 PortFlags; + int *nvram; + IOCPage4_t *pIocPg4; + dma_addr_t IocPg4_dma; + int IocPg4Sz; + u8 minSyncFactor; + u8 maxSyncOffset; + u8 maxBusWidth; + u8 busType; + u8 sdp1version; + u8 sdp1length; + u8 sdp0version; + u8 sdp0length; + u8 dvScheduled; + u8 noQas; + u8 Saf_Te; + u8 bus_reset; + u8 rsvd[1]; +}; + +typedef struct _SpiCfgData SpiCfgData; + +struct _SasCfgData { + u8 ptClear; +}; + +typedef struct _SasCfgData SasCfgData; + +struct inactive_raid_component_info { + struct list_head list; + u8 volumeID; + u8 volumeBus; + IOC_3_PHYS_DISK d; +}; + +struct _RaidCfgData { + IOCPage2_t *pIocPg2; + IOCPage3_t *pIocPg3; + struct mutex inactive_list_mutex; + struct list_head inactive_list; +}; + +typedef struct _RaidCfgData RaidCfgData; + +struct _FcCfgData { + struct { + FCPortPage1_t *data; + dma_addr_t dma; + int pg_sz; + } fc_port_page1[2]; +}; + +typedef struct _FcCfgData FcCfgData; + +enum { + FC = 0, + SPI = 1, + SAS___2 = 2, +}; + +struct _MPT_ADAPTER; + +struct _MPT_SCSI_HOST { + struct _MPT_ADAPTER *ioc; + ushort sel_timeout[255]; + char *info_kbuf; + long int last_queue_full; + u16 spi_pending; + struct list_head target_reset_list; +}; + +typedef void (*MPT_ADD_SGE)(void *, u32, dma_addr_t); + +typedef void (*MPT_ADD_CHAIN)(void *, u8, u16, dma_addr_t); + +typedef void (*MPT_SCHEDULE_TARGET_RESET)(void *); + +typedef struct _MPT_SCSI_HOST MPT_SCSI_HOST; + +typedef void (*MPT_FLUSH_RUNNING_CMDS)(MPT_SCSI_HOST *); + +struct mptsas_portinfo; + +struct _MPT_ADAPTER { + int id; + int pci_irq; + char name[32]; + const char *prod_name; + char board_name[16]; + char board_assembly[16]; + char board_tracer[16]; + u16 nvdata_version_persistent; + u16 nvdata_version_default; + int debug_level; + u8 io_missing_delay; + u16 device_missing_delay; + SYSIF_REGS *chip; + SYSIF_REGS *pio_chip; + u8 bus_type; + u32 mem_phys; + u32 pio_mem_phys; + int mem_size; + int number_of_buses; + int devices_per_bus; + int alloc_total; + u32 last_state; + int active; + u8 *alloc; + dma_addr_t alloc_dma; + u32 alloc_sz; + MPT_FRAME_HDR *reply_frames; + u32 reply_frames_low_dma; + int reply_depth; + int reply_sz; + int num_chain; + MPT_ADD_SGE add_sge; + MPT_ADD_CHAIN add_chain; + int *ReqToChain; + int *RequestNB; + int *ChainToChain; + u8 *ChainBuffer; + dma_addr_t ChainBufferDMA; + struct list_head FreeChainQ; + spinlock_t FreeChainQlock; + dma_addr_t req_frames_dma; + MPT_FRAME_HDR *req_frames; + u32 req_frames_low_dma; + int req_depth; + int req_sz; + spinlock_t FreeQlock; + struct list_head FreeQ; + u8 *sense_buf_pool; + dma_addr_t sense_buf_pool_dma; + u32 sense_buf_low_dma; + u8 *HostPageBuffer; + u32 HostPageBuffer_sz; + dma_addr_t HostPageBuffer_dma; + struct pci_dev *pcidev; + int bars; + int msi_enable; + u8 *memmap; + struct Scsi_Host *sh; + SpiCfgData spi_data; + RaidCfgData raid_data; + SasCfgData sas_data; + FcCfgData fc_data; + struct proc_dir_entry *ioc_dentry; + struct _MPT_ADAPTER *alt_ioc; + u32 biosVersion; + int eventTypes; + int eventContext; + int eventLogSize; + struct _mpt_ioctl_events *events; + u8 *cached_fw; + dma_addr_t cached_fw_dma; + int hs_reply_idx; + u32 pad0; + u32 NB_for_64_byte_frame; + u32 hs_req[32]; + u16 hs_reply[64]; + IOCFactsReply_t facts; + PortFactsReply_t pfacts[2]; + FCPortPage0_t fc_port_page0[2]; + LANPage0_t lan_cnfg_page0; + LANPage1_t lan_cnfg_page1; + u8 ir_firmware; + int errata_flag_1064; + int aen_event_read_flag; + u8 FirstWhoInit; + u8 upload_fw; + u8 NBShiftFactor; + u8 pad1[4]; + u8 DoneCtx; + u8 TaskCtx; + u8 InternalCtx; + struct list_head list; + struct net_device *netdev; + struct list_head sas_topology; + struct mutex sas_topology_mutex; + struct workqueue_struct *fw_event_q; + struct list_head fw_event_list; + spinlock_t fw_event_lock; + u8 fw_events_off; + char fw_event_q_name[20]; + struct mutex sas_discovery_mutex; + u8 sas_discovery_runtime; + u8 sas_discovery_ignore_events; + struct mptsas_portinfo *hba_port_info; + u64 hba_port_sas_addr; + u16 hba_port_num_phy; + struct list_head sas_device_info_list; + struct mutex sas_device_info_mutex; + u8 old_sas_discovery_protocal; + u8 sas_discovery_quiesce_io; + int sas_index; + MPT_MGMT sas_mgmt; + MPT_MGMT mptbase_cmds; + MPT_MGMT internal_cmds; + MPT_MGMT taskmgmt_cmds; + MPT_MGMT ioctl_cmds; + spinlock_t taskmgmt_lock; + int taskmgmt_in_progress; + u8 taskmgmt_quiesce_io; + u8 ioc_reset_in_progress; + u8 reset_status; + u8 wait_on_reset_completion; + MPT_SCHEDULE_TARGET_RESET schedule_target_reset; + MPT_FLUSH_RUNNING_CMDS schedule_dead_ioc_flush_running_cmds; + struct work_struct sas_persist_task; + struct work_struct fc_setup_reset_work; + struct list_head fc_rports; + struct work_struct fc_lsc_work; + u8 fc_link_speed[2]; + spinlock_t fc_rescan_work_lock; + struct work_struct fc_rescan_work; + char fc_rescan_work_q_name[20]; + struct workqueue_struct *fc_rescan_work_q; + long unsigned int hard_resets; + long unsigned int soft_resets; + long unsigned int timeouts; + struct scsi_cmnd **ScsiLookup; + spinlock_t scsi_lookup_lock; + u64 dma_mask; + u32 broadcast_aen_busy; + char reset_work_q_name[20]; + struct workqueue_struct *reset_work_q; + struct delayed_work fault_reset_work; + u8 sg_addr_size; + u8 in_rescan; + u8 SGE_size; +}; + +typedef struct _MPT_ADAPTER MPT_ADAPTER; + +typedef int (*MPT_CALLBACK)(MPT_ADAPTER *, MPT_FRAME_HDR *, MPT_FRAME_HDR *); + +typedef int (*MPT_EVHANDLER)(MPT_ADAPTER *, EventNotificationReply_t *); + +typedef int (*MPT_RESETHANDLER)(MPT_ADAPTER *, int); + +struct _x_config_parms { + union { + ConfigExtendedPageHeader_t *ehdr; + ConfigPageHeader_t *hdr; + } cfghdr; + dma_addr_t physAddr; + u32 pageAddr; + u16 status; + u8 action; + u8 dir; + u8 timeout; +}; + +typedef struct _x_config_parms CONFIGPARMS; + +enum _MpiIocLogInfoFc { + MPI_IOCLOGINFO_FC_INIT_BASE = 536870912, + MPI_IOCLOGINFO_FC_INIT_ERROR_OUT_OF_ORDER_FRAME = 536870913, + MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_START_OF_FRAME = 536870914, + MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_END_OF_FRAME = 536870915, + MPI_IOCLOGINFO_FC_INIT_ERROR_OVER_RUN = 536870916, + MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OTHER = 536870917, + MPI_IOCLOGINFO_FC_INIT_ERROR_SUBPROC_DEAD = 536870918, + MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OVERRUN = 536870919, + MPI_IOCLOGINFO_FC_INIT_ERROR_RX_BAD_STATUS = 536870920, + MPI_IOCLOGINFO_FC_INIT_ERROR_RX_UNEXPECTED_FRAME = 536870921, + MPI_IOCLOGINFO_FC_INIT_ERROR_LINK_FAILURE = 536870922, + MPI_IOCLOGINFO_FC_INIT_ERROR_TX_TIMEOUT = 536870923, + MPI_IOCLOGINFO_FC_TARGET_BASE = 553648128, + MPI_IOCLOGINFO_FC_TARGET_NO_PDISC = 553648129, + MPI_IOCLOGINFO_FC_TARGET_NO_LOGIN = 553648130, + MPI_IOCLOGINFO_FC_TARGET_DOAR_KILLED_BY_LIP = 553648131, + MPI_IOCLOGINFO_FC_TARGET_DIAR_KILLED_BY_LIP = 553648132, + MPI_IOCLOGINFO_FC_TARGET_DIAR_MISSING_DATA = 553648133, + MPI_IOCLOGINFO_FC_TARGET_DONR_KILLED_BY_LIP = 553648134, + MPI_IOCLOGINFO_FC_TARGET_WRSP_KILLED_BY_LIP = 553648135, + MPI_IOCLOGINFO_FC_TARGET_DINR_KILLED_BY_LIP = 553648136, + MPI_IOCLOGINFO_FC_TARGET_DINR_MISSING_DATA = 553648137, + MPI_IOCLOGINFO_FC_TARGET_MRSP_KILLED_BY_LIP = 553648138, + MPI_IOCLOGINFO_FC_TARGET_NO_CLASS_3 = 553648139, + MPI_IOCLOGINFO_FC_TARGET_LOGIN_NOT_VALID = 553648140, + MPI_IOCLOGINFO_FC_TARGET_FROM_OUTBOUND = 553648142, + MPI_IOCLOGINFO_FC_TARGET_WAITING_FOR_DATA_IN = 553648143, + MPI_IOCLOGINFO_FC_LAN_BASE = 570425344, + MPI_IOCLOGINFO_FC_LAN_TRANS_SGL_MISSING = 570425345, + MPI_IOCLOGINFO_FC_LAN_TRANS_WRONG_PLACE = 570425346, + MPI_IOCLOGINFO_FC_LAN_TRANS_RES_BITS_SET = 570425347, + MPI_IOCLOGINFO_FC_LAN_WRONG_SGL_FLAG = 570425348, + MPI_IOCLOGINFO_FC_MSG_BASE = 587202560, + MPI_IOCLOGINFO_FC_LINK_BASE = 603979776, + MPI_IOCLOGINFO_FC_LINK_LOOP_INIT_TIMEOUT = 603979777, + MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED = 603979778, + MPI_IOCLOGINFO_FC_LINK_LINK_NOT_ESTABLISHED = 603979779, + MPI_IOCLOGINFO_FC_LINK_CRC_ERROR = 603979780, + MPI_IOCLOGINFO_FC_CTX_BASE = 620756992, + MPI_IOCLOGINFO_FC_INVALID_FIELD_BYTE_OFFSET = 637534208, + MPI_IOCLOGINFO_FC_INVALID_FIELD_MAX_OFFSET = 654311423, + MPI_IOCLOGINFO_FC_STATE_CHANGE = 654311424, +}; + +union loginfo_type { + u32 loginfo; + struct { + u32 subcode: 16; + u32 code: 8; + u32 originator: 4; + u32 bus_type: 4; + } dw; +}; + +struct _MSG_SCSI_TASK_MGMT { + U8 TargetID; + U8 Bus; + U8 ChainOffset; + U8 Function; + U8 Reserved; + U8 TaskType; + U8 Reserved1; + U8 MsgFlags; + U32___2 MsgContext; + U8 LUN[8]; + U32___2 Reserved2[7]; + U32___2 TaskMsgContext; +}; + +typedef struct _MSG_SCSI_TASK_MGMT SCSITaskMgmt_t; + +struct _MSG_SCSI_TASK_MGMT_REPLY { + U8 TargetID; + U8 Bus; + U8 MsgLength; + U8 Function; + U8 ResponseCode; + U8 TaskType; + U8 Reserved1; + U8 MsgFlags; + U32___2 MsgContext; + U8 Reserved2[2]; + U16___2 IOCStatus; + U32___2 IOCLogInfo; + U32___2 TerminationCount; +}; + +typedef struct _MSG_SCSI_TASK_MGMT_REPLY SCSITaskMgmtReply_t; + +struct _MSG_SEP_REQUEST { + U8 TargetID; + U8 Bus; + U8 ChainOffset; + U8 Function; + U8 Action; + U8 Flags; + U8 Reserved1; + U8 MsgFlags; + U32___2 MsgContext; + U32___2 SlotStatus; + U32___2 Reserved2; + U32___2 Reserved3; + U32___2 Reserved4; + U16___2 Slot; + U16___2 EnclosureHandle; +}; + +typedef struct _MSG_SEP_REQUEST SEPRequest_t; + +struct _MSG_RAID_ACTION_REPLY { + U8 Action; + U8 Reserved; + U8 MsgLength; + U8 Function; + U8 VolumeID; + U8 VolumeBus; + U8 PhysDiskNum; + U8 MsgFlags; + U32___2 MsgContext; + U16___2 ActionStatus; + U16___2 IOCStatus; + U32___2 IOCLogInfo; + U32___2 VolumeStatus; + U32___2 ActionData; +}; + +typedef struct _MSG_RAID_ACTION_REPLY MpiRaidActionReply_t; + +struct _VirtTarget { + struct scsi_target *starget; + u8 tflags; + u8 ioc_id; + u8 id; + u8 channel; + u8 minSyncFactor; + u8 maxOffset; + u8 maxWidth; + u8 negoFlags; + u8 raidVolume; + u8 type; + u8 deleted; + u8 inDMD; + u32 num_luns; +}; + +typedef struct _VirtTarget VirtTarget; + +struct _VirtDevice { + VirtTarget *vtarget; + u8 configured_lun; + u64 lun; +}; + +typedef struct _VirtDevice VirtDevice; + +struct _internal_cmd { + char *data; + dma_addr_t data_dma; + int size; + u8 cmd; + u8 channel; + u8 id; + u64 lun; + u8 flags; + u8 physDiskNum; + u8 rsvd2; + u8 rsvd; +}; + +typedef struct _internal_cmd INTERNAL_CMD; + +struct _CONFIG_PAGE_SCSI_DEVICE_0 { + CONFIG_PAGE_HEADER Header; + U32___2 NegotiatedParameters; + U32___2 Information; +}; + +struct _CONFIG_PAGE_SCSI_DEVICE_1 { + CONFIG_PAGE_HEADER Header; + U32___2 RequestedParameters; + U32___2 Reserved; + U32___2 Configuration; +}; + +struct _MSG_RAID_ACTION { + U8 Action; + U8 Reserved1; + U8 ChainOffset; + U8 Function; + U8 VolumeID; + U8 VolumeBus; + U8 PhysDiskNum; + U8 MsgFlags; + U32___2 MsgContext; + U32___2 Reserved2; + U32___2 ActionDataWord; + SGE_SIMPLE_UNION ActionDataSGE; +}; + +typedef struct _MSG_RAID_ACTION MpiRaidActionRequest_t; + +struct work_queue_wrapper___2 { + struct work_struct work; + struct _MPT_SCSI_HOST *hd; + int disk; +}; + +struct _CONFIG_PAGE_FC_DEVICE_0 { + CONFIG_PAGE_HEADER Header; + U64___2 WWNN; + U64___2 WWPN; + U32___2 PortIdentifier; + U8 Protocol; + U8 Flags; + U16___2 BBCredit; + U16___2 MaxRxFrameSize; + U8 ADISCHardALPA; + U8 PortNumber; + U8 FcPhLowestVersion; + U8 FcPhHighestVersion; + U8 CurrentTargetID; + U8 CurrentBus; +}; + +typedef struct _CONFIG_PAGE_FC_DEVICE_0 FCDevicePage0_t; + +struct mptfc_rport_info { + struct list_head list; + struct fc_rport *rport; + struct scsi_target *starget; + FCDevicePage0_t pg0; + u8 flags; +}; + +struct _EVENT_DATA_SAS_DEVICE_STATUS_CHANGE { + U8 TargetID; + U8 Bus; + U8 ReasonCode; + U8 Reserved; + U8 ASC; + U8 ASCQ; + U16___2 DevHandle; + U32___2 DeviceInfo; + U16___2 ParentDevHandle; + U8 PhyNum; + U8 Reserved1; + U64___2 SASAddress; + U8 LUN[8]; + U16___2 TaskTag; + U16___2 Reserved2; +}; + +typedef struct _EVENT_DATA_SAS_DEVICE_STATUS_CHANGE EVENT_DATA_SAS_DEVICE_STATUS_CHANGE; + +typedef struct _EVENT_DATA_SAS_DEVICE_STATUS_CHANGE MpiEventDataSasDeviceStatusChange_t; + +struct _EVENT_DATA_QUEUE_FULL { + U8 TargetID; + U8 Bus; + U16___2 CurrentDepth; +}; + +typedef struct _EVENT_DATA_QUEUE_FULL EventDataQueueFull_t; + +typedef struct _EVENT_DATA_RAID EVENT_DATA_RAID; + +struct _IR2_STATE_CHANGED { + U16___2 PreviousState; + U16___2 NewState; +}; + +typedef struct _IR2_STATE_CHANGED IR2_STATE_CHANGED; + +struct _IR2_PD_INFO { + U16___2 DeviceHandle; + U8 TruncEnclosureHandle; + U8 TruncatedSlot; +}; + +typedef struct _IR2_PD_INFO IR2_PD_INFO; + +union _MPI_IR2_RC_EVENT_DATA { + IR2_STATE_CHANGED StateChanged; + U32___2 Lba; + IR2_PD_INFO PdInfo; +}; + +typedef union _MPI_IR2_RC_EVENT_DATA MPI_IR2_RC_EVENT_DATA; + +struct _MPI_EVENT_DATA_IR2 { + U8 TargetID; + U8 Bus; + U8 ReasonCode; + U8 PhysDiskNum; + MPI_IR2_RC_EVENT_DATA IR2EventData; +}; + +typedef struct _MPI_EVENT_DATA_IR2 MPI_EVENT_DATA_IR2; + +struct _EVENT_DATA_SAS_BROADCAST_PRIMITIVE { + U8 PhyNum; + U8 Port; + U8 PortWidth; + U8 Primitive; +}; + +typedef struct _EVENT_DATA_SAS_BROADCAST_PRIMITIVE EVENT_DATA_SAS_BROADCAST_PRIMITIVE; + +struct _EVENT_DATA_SAS_PHY_LINK_STATUS { + U8 PhyNum; + U8 LinkRates; + U16___2 DevHandle; + U64___2 SASAddress; +}; + +typedef struct _EVENT_DATA_SAS_PHY_LINK_STATUS MpiEventDataSasPhyLinkStatus_t; + +struct _EVENT_DATA_SAS_DISCOVERY { + U32___2 DiscoveryStatus; + U32___2 Reserved1; +}; + +typedef struct _EVENT_DATA_SAS_DISCOVERY EventDataSasDiscovery_t; + +struct _EVENT_DATA_SAS_EXPANDER_STATUS_CHANGE { + U8 ReasonCode; + U8 Reserved1; + U16___2 Reserved2; + U8 PhysicalPort; + U8 Reserved3; + U16___2 EnclosureHandle; + U64___2 SASAddress; + U32___2 DiscoveryStatus; + U16___2 DevHandle; + U16___2 ParentDevHandle; + U16___2 ExpanderChangeCount; + U16___2 ExpanderRouteIndexes; + U8 NumPhys; + U8 SASLevel; + U8 Flags; + U8 Reserved4; +}; + +typedef struct _EVENT_DATA_SAS_EXPANDER_STATUS_CHANGE MpiEventDataSasExpanderStatusChange_t; + +struct _MPI_SAS_IO_UNIT1_PHY_DATA { + U8 Port; + U8 PortFlags; + U8 PhyFlags; + U8 MaxMinLinkRate; + U32___2 ControllerPhyDeviceInfo; + U16___2 MaxTargetPortConnectTime; + U16___2 Reserved1; +}; + +typedef struct _MPI_SAS_IO_UNIT1_PHY_DATA MPI_SAS_IO_UNIT1_PHY_DATA; + +struct _CONFIG_PAGE_SAS_IO_UNIT_1 { + CONFIG_EXTENDED_PAGE_HEADER Header; + U16___2 ControlFlags; + U16___2 MaxNumSATATargets; + U16___2 AdditionalControlFlags; + U16___2 Reserved1; + U8 NumPhys; + U8 SATAMaxQDepth; + U8 ReportDeviceMissingDelay; + U8 IODeviceMissingDelay; + MPI_SAS_IO_UNIT1_PHY_DATA PhyData[1]; +}; + +typedef struct _CONFIG_PAGE_SAS_IO_UNIT_1 SasIOUnitPage1_t; + +struct _CONFIG_PAGE_SAS_EXPANDER_0 { + CONFIG_EXTENDED_PAGE_HEADER Header; + U8 PhysicalPort; + U8 Reserved1; + U16___2 EnclosureHandle; + U64___2 SASAddress; + U32___2 DiscoveryStatus; + U16___2 DevHandle; + U16___2 ParentDevHandle; + U16___2 ExpanderChangeCount; + U16___2 ExpanderRouteIndexes; + U8 NumPhys; + U8 SASLevel; + U8 Flags; + U8 Reserved3; +}; + +typedef struct _CONFIG_PAGE_SAS_EXPANDER_0 SasExpanderPage0_t; + +struct _CONFIG_PAGE_SAS_EXPANDER_1 { + CONFIG_EXTENDED_PAGE_HEADER Header; + U8 PhysicalPort; + U8 Reserved1; + U16___2 Reserved2; + U8 NumPhys; + U8 Phy; + U16___2 NumTableEntriesProgrammed; + U8 ProgrammedLinkRate; + U8 HwLinkRate; + U16___2 AttachedDevHandle; + U32___2 PhyInfo; + U32___2 AttachedDeviceInfo; + U16___2 OwnerDevHandle; + U8 ChangeCount; + U8 NegotiatedLinkRate; + U8 PhyIdentifier; + U8 AttachedPhyIdentifier; + U8 Reserved3; + U8 DiscoveryInfo; + U32___2 Reserved4; +}; + +typedef struct _CONFIG_PAGE_SAS_EXPANDER_1 SasExpanderPage1_t; + +struct _CONFIG_PAGE_SAS_DEVICE_0 { + CONFIG_EXTENDED_PAGE_HEADER Header; + U16___2 Slot; + U16___2 EnclosureHandle; + U64___2 SASAddress; + U16___2 ParentDevHandle; + U8 PhyNum; + U8 AccessStatus; + U16___2 DevHandle; + U8 TargetID; + U8 Bus; + U32___2 DeviceInfo; + U16___2 Flags; + U8 PhysicalPort; + U8 Reserved2; +}; + +typedef struct _CONFIG_PAGE_SAS_DEVICE_0 SasDevicePage0_t; + +struct _CONFIG_PAGE_SAS_PHY_0 { + CONFIG_EXTENDED_PAGE_HEADER Header; + U16___2 OwnerDevHandle; + U16___2 Reserved1; + U64___2 SASAddress; + U16___2 AttachedDevHandle; + U8 AttachedPhyIdentifier; + U8 Reserved2; + U32___2 AttachedDeviceInfo; + U8 ProgrammedLinkRate; + U8 HwLinkRate; + U8 ChangeCount; + U8 Flags; + U32___2 PhyInfo; +}; + +typedef struct _CONFIG_PAGE_SAS_PHY_0 SasPhyPage0_t; + +struct _CONFIG_PAGE_SAS_PHY_1 { + CONFIG_EXTENDED_PAGE_HEADER Header; + U32___2 Reserved1; + U32___2 InvalidDwordCount; + U32___2 RunningDisparityErrorCount; + U32___2 LossDwordSynchCount; + U32___2 PhyResetProblemCount; +}; + +typedef struct _CONFIG_PAGE_SAS_PHY_1 SasPhyPage1_t; + +struct _CONFIG_PAGE_SAS_ENCLOSURE_0 { + CONFIG_EXTENDED_PAGE_HEADER Header; + U32___2 Reserved1; + U64___2 EnclosureLogicalID; + U16___2 Flags; + U16___2 EnclosureHandle; + U16___2 NumSlots; + U16___2 StartSlot; + U8 StartTargetID; + U8 StartBus; + U8 SEPTargetID; + U8 SEPBus; + U32___2 Reserved2; + U32___2 Reserved3; +}; + +typedef struct _CONFIG_PAGE_SAS_ENCLOSURE_0 SasEnclosurePage0_t; + +struct _MSG_SMP_PASSTHROUGH_REQUEST { + U8 PassthroughFlags; + U8 PhysicalPort; + U8 ChainOffset; + U8 Function; + U16___2 RequestDataLength; + U8 ConnectionRate; + U8 MsgFlags; + U32___2 MsgContext; + U32___2 Reserved1; + U64___2 SASAddress; + U32___2 Reserved2; + U32___2 Reserved3; + SGE_SIMPLE_UNION SGL; +}; + +typedef struct _MSG_SMP_PASSTHROUGH_REQUEST SmpPassthroughRequest_t; + +struct _MSG_SMP_PASSTHROUGH_REPLY { + U8 PassthroughFlags; + U8 PhysicalPort; + U8 MsgLength; + U8 Function; + U16___2 ResponseDataLength; + U8 Reserved1; + U8 MsgFlags; + U32___2 MsgContext; + U8 Reserved2; + U8 SASStatus; + U16___2 IOCStatus; + U32___2 IOCLogInfo; + U32___2 Reserved3; + U8 ResponseData[4]; +}; + +typedef struct _MSG_SMP_PASSTHROUGH_REPLY SmpPassthroughReply_t; + +struct mptsas_phyinfo; + +struct mptsas_portinfo { + struct list_head list; + u16 num_phys; + struct mptsas_phyinfo *phy_info; +}; + +struct mptsas_target_reset_event { + struct list_head list; + EVENT_DATA_SAS_DEVICE_STATUS_CHANGE sas_event_data; + u8 target_reset_issued; + long unsigned int time_count; +}; + +enum mptsas_hotplug_action { + MPTSAS_ADD_DEVICE = 0, + MPTSAS_DEL_DEVICE = 1, + MPTSAS_ADD_RAID = 2, + MPTSAS_DEL_RAID = 3, + MPTSAS_ADD_PHYSDISK = 4, + MPTSAS_ADD_PHYSDISK_REPROBE = 5, + MPTSAS_DEL_PHYSDISK = 6, + MPTSAS_DEL_PHYSDISK_REPROBE = 7, + MPTSAS_ADD_INACTIVE_VOLUME = 8, + MPTSAS_IGNORE_EVENT = 9, +}; + +struct mptsas_mapping { + u8 id; + u8 channel; +}; + +struct mptsas_device_info { + struct list_head list; + struct mptsas_mapping os; + struct mptsas_mapping fw; + u64 sas_address; + u32 device_info; + u16 slot; + u64 enclosure_logical_id; + u8 is_logical_volume; + u8 is_hidden_raid_component; + u8 volume_id; + u8 is_cached; +}; + +struct mptsas_hotplug_event { + MPT_ADAPTER *ioc; + enum mptsas_hotplug_action event_type; + u64 sas_address; + u8 channel; + u8 id; + u32 device_info; + u16 handle; + u8 phy_id; + u8 phys_disk_num; + struct scsi_device *sdev; +}; + +struct fw_event_work { + struct list_head list; + struct delayed_work work; + MPT_ADAPTER *ioc; + u32 event; + u8 retries; + int: 24; + char event_data[0]; +}; + +struct mptsas_devinfo { + u16 handle; + u16 handle_parent; + u16 handle_enclosure; + u16 slot; + u8 phy_id; + u8 port_id; + u8 id; + u32 phys_disk_num; + u8 channel; + u64 sas_address; + u32 device_info; + u16 flags; +}; + +struct mptsas_portinfo_details { + u16 num_phys; + u64 phy_bitmask; + struct sas_rphy *rphy; + struct sas_port *port; + struct scsi_target *starget; + struct mptsas_portinfo *port_info; +}; + +struct mptsas_phyinfo { + u16 handle; + u8 phy_id; + u8 port_id; + u8 negotiated_link_rate; + u8 hw_link_rate; + u8 programmed_link_rate; + u8 sas_port_add_phy; + struct mptsas_devinfo identify; + struct mptsas_devinfo attached; + struct sas_phy *phy; + struct mptsas_portinfo *portinfo; + struct mptsas_portinfo_details *port_details; +}; + +struct mptsas_enclosure { + u64 enclosure_logical_id; + u16 enclosure_handle; + u16 flags; + u16 num_slot; + u16 start_slot; + u8 start_id; + u8 start_channel; + u8 sep_id; + u8 sep_channel; +}; + +struct rep_manu_request { + u8 smp_frame_type; + u8 function; + u8 reserved; + u8 request_length; +}; + +struct rep_manu_reply { + u8 smp_frame_type; + u8 function; + u8 function_result; + u8 response_length; + u16 expander_change_count; + u8 reserved0[2]; + u8 sas_format: 1; + u8 reserved1: 7; + u8 reserved2[3]; + u8 vendor_id[8]; + u8 product_id[16]; + u8 product_rev[4]; + u8 component_vendor_id[8]; + u16 component_id; + u8 component_revision_id; + u8 reserved3; + u8 vendor_specific[8]; +}; + +struct socket_state_t { + u_int flags; + u_int csc_mask; + u_char Vcc; + u_char Vpp; + u_char io_irq; +}; + +typedef struct socket_state_t socket_state_t; + +struct pccard_io_map { + u_char map; + u_char flags; + u_short speed; + phys_addr_t start; + phys_addr_t stop; +}; + +struct pccard_mem_map { + u_char map; + u_char flags; + u_short speed; + phys_addr_t static_start; + u_int card_start; + struct resource *res; +}; + +typedef struct pccard_mem_map pccard_mem_map; + +struct io_window_t { + u_int InUse; + u_int Config; + struct resource *res; +}; + +typedef struct io_window_t io_window_t; + +struct pcmcia_socket; + +struct pccard_operations { + int (*init)(struct pcmcia_socket *); + int (*suspend)(struct pcmcia_socket *); + int (*get_status)(struct pcmcia_socket *, u_int *); + int (*set_socket)(struct pcmcia_socket *, socket_state_t *); + int (*set_io_map)(struct pcmcia_socket *, struct pccard_io_map *); + int (*set_mem_map)(struct pcmcia_socket *, struct pccard_mem_map *); +}; + +struct pccard_resource_ops; + +struct pcmcia_callback; + +struct pcmcia_socket { + struct module *owner; + socket_state_t socket; + u_int state; + u_int suspended_state; + u_short functions; + u_short lock_count; + pccard_mem_map cis_mem; + void *cis_virt; + io_window_t io[2]; + pccard_mem_map win[4]; + struct list_head cis_cache; + size_t fake_cis_len; + u8 *fake_cis; + struct list_head socket_list; + struct completion socket_released; + unsigned int sock; + u_int features; + u_int irq_mask; + u_int map_size; + u_int io_offset; + u_int pci_irq; + struct pci_dev *cb_dev; + u8 resource_setup_done; + struct pccard_operations *ops; + struct pccard_resource_ops *resource_ops; + void *resource_data; + void (*zoom_video)(struct pcmcia_socket *, int); + int (*power_hook)(struct pcmcia_socket *, int); + void (*tune_bridge)(struct pcmcia_socket *, struct pci_bus *); + struct task_struct *thread; + struct completion thread_done; + unsigned int thread_events; + unsigned int sysfs_events; + struct mutex skt_mutex; + struct mutex ops_mutex; + spinlock_t thread_lock; + struct pcmcia_callback *callback; + struct list_head devices_list; + u8 device_count; + u8 pcmcia_pfc; + atomic_t present; + unsigned int pcmcia_irq; + struct device dev; + void *driver_data; + int resume_status; +}; + +struct pccard_resource_ops { + int (*validate_mem)(struct pcmcia_socket *); + int (*find_io)(struct pcmcia_socket *, unsigned int, unsigned int *, unsigned int, unsigned int, struct resource **); + struct resource * (*find_mem)(long unsigned int, long unsigned int, long unsigned int, int, struct pcmcia_socket *); + int (*init)(struct pcmcia_socket *); + void (*exit)(struct pcmcia_socket *); +}; + +struct pcmcia_callback { + struct module *owner; + int (*add)(struct pcmcia_socket *); + int (*remove)(struct pcmcia_socket *); + void (*requery)(struct pcmcia_socket *); + int (*validate)(struct pcmcia_socket *, unsigned int *); + int (*suspend)(struct pcmcia_socket *); + int (*early_resume)(struct pcmcia_socket *); + int (*resume)(struct pcmcia_socket *); +}; + +enum { + PCMCIA_IOPORT_0 = 0, + PCMCIA_IOPORT_1 = 1, + PCMCIA_IOMEM_0 = 2, + PCMCIA_IOMEM_1 = 3, + PCMCIA_IOMEM_2 = 4, + PCMCIA_IOMEM_3 = 5, + PCMCIA_NUM_RESOURCES = 6, +}; + +struct cistpl_longlink_mfc_t { + u_char nfn; + struct { + u_char space; + u_int addr; + } fn[8]; +}; + +typedef struct cistpl_longlink_mfc_t cistpl_longlink_mfc_t; + +struct cistpl_vers_1_t { + u_char major; + u_char minor; + u_char ns; + u_char ofs[4]; + char str[254]; +}; + +typedef struct cistpl_vers_1_t cistpl_vers_1_t; + +struct cistpl_manfid_t { + u_short manf; + u_short card; +}; + +typedef struct cistpl_manfid_t cistpl_manfid_t; + +struct cistpl_funcid_t { + u_char func; + u_char sysinit; +}; + +typedef struct cistpl_funcid_t cistpl_funcid_t; + +struct cistpl_config_t { + u_char last_idx; + u_int base; + u_int rmask[4]; + u_char subtuples; +}; + +typedef struct cistpl_config_t cistpl_config_t; + +struct cistpl_device_geo_t { + u_char ngeo; + struct { + u_char buswidth; + u_int erase_block; + u_int read_block; + u_int write_block; + u_int partition; + u_int interleave; + } geo[4]; +}; + +typedef struct cistpl_device_geo_t cistpl_device_geo_t; + +struct pcmcia_device_id { + __u16 match_flags; + __u16 manf_id; + __u16 card_id; + __u8 func_id; + __u8 function; + __u8 device_no; + __u32 prod_id_hash[4]; + const char *prod_id[4]; + kernel_ulong_t driver_info; + char *cisfile; +}; + +struct pcmcia_dynids { + struct mutex lock; + struct list_head list; +}; + +struct pcmcia_device; + +struct pcmcia_driver { + const char *name; + int (*probe)(struct pcmcia_device *); + void (*remove)(struct pcmcia_device *); + int (*suspend)(struct pcmcia_device *); + int (*resume)(struct pcmcia_device *); + struct module *owner; + const struct pcmcia_device_id *id_table; + struct device_driver drv; + struct pcmcia_dynids dynids; +}; + +struct config_t; + +struct pcmcia_device { + struct pcmcia_socket *socket; + char *devname; + u8 device_no; + u8 func; + struct config_t *function_config; + struct list_head socket_device_list; + unsigned int irq; + struct resource *resource[6]; + resource_size_t card_addr; + unsigned int vpp; + unsigned int config_flags; + unsigned int config_base; + unsigned int config_index; + unsigned int config_regs; + unsigned int io_lines; + u16 suspended: 1; + u16 _irq: 1; + u16 _io: 1; + u16 _win: 4; + u16 _locked: 1; + u16 allow_func_id_match: 1; + u16 has_manf_id: 1; + u16 has_card_id: 1; + u16 has_func_id: 1; + u16 reserved: 4; + u8 func_id; + u16 manf_id; + u16 card_id; + char *prod_id[4]; + u64 dma_mask; + struct device dev; + void *priv; + unsigned int open; +}; + +struct config_t { + struct kref ref; + unsigned int state; + struct resource io[2]; + struct resource mem[4]; +}; + +typedef struct config_t config_t; + +struct pcmcia_dynid { + struct list_head node; + struct pcmcia_device_id id; +}; + +typedef struct pccard_io_map pccard_io_map; + +typedef unsigned char cisdata_t; + +struct cistpl_longlink_t { + u_int addr; +}; + +typedef struct cistpl_longlink_t cistpl_longlink_t; + +struct cistpl_checksum_t { + u_short addr; + u_short len; + u_char sum; +}; + +typedef struct cistpl_checksum_t cistpl_checksum_t; + +struct cistpl_altstr_t { + u_char ns; + u_char ofs[4]; + char str[254]; +}; + +typedef struct cistpl_altstr_t cistpl_altstr_t; + +struct cistpl_device_t { + u_char ndev; + struct { + u_char type; + u_char wp; + u_int speed; + u_int size; + } dev[4]; +}; + +typedef struct cistpl_device_t cistpl_device_t; + +struct cistpl_jedec_t { + u_char nid; + struct { + u_char mfr; + u_char info; + } id[4]; +}; + +typedef struct cistpl_jedec_t cistpl_jedec_t; + +struct cistpl_funce_t { + u_char type; + u_char data[0]; +}; + +typedef struct cistpl_funce_t cistpl_funce_t; + +struct cistpl_bar_t { + u_char attr; + u_int size; +}; + +typedef struct cistpl_bar_t cistpl_bar_t; + +struct cistpl_power_t { + u_char present; + u_char flags; + u_int param[7]; +}; + +typedef struct cistpl_power_t cistpl_power_t; + +struct cistpl_timing_t { + u_int wait; + u_int waitscale; + u_int ready; + u_int rdyscale; + u_int reserved; + u_int rsvscale; +}; + +typedef struct cistpl_timing_t cistpl_timing_t; + +struct cistpl_io_t { + u_char flags; + u_char nwin; + struct { + u_int base; + u_int len; + } win[16]; +}; + +typedef struct cistpl_io_t cistpl_io_t; + +struct cistpl_irq_t { + u_int IRQInfo1; + u_int IRQInfo2; +}; + +typedef struct cistpl_irq_t cistpl_irq_t; + +struct cistpl_mem_t { + u_char flags; + u_char nwin; + struct { + u_int len; + u_int card_addr; + u_int host_addr; + } win[8]; +}; + +typedef struct cistpl_mem_t cistpl_mem_t; + +struct cistpl_cftable_entry_t { + u_char index; + u_short flags; + u_char interface; + cistpl_power_t vcc; + cistpl_power_t vpp1; + cistpl_power_t vpp2; + cistpl_timing_t timing; + cistpl_io_t io; + cistpl_irq_t irq; + cistpl_mem_t mem; + u_char subtuples; +}; + +typedef struct cistpl_cftable_entry_t cistpl_cftable_entry_t; + +struct cistpl_cftable_entry_cb_t { + u_char index; + u_int flags; + cistpl_power_t vcc; + cistpl_power_t vpp1; + cistpl_power_t vpp2; + u_char io; + cistpl_irq_t irq; + u_char mem; + u_char subtuples; +}; + +typedef struct cistpl_cftable_entry_cb_t cistpl_cftable_entry_cb_t; + +struct cistpl_vers_2_t { + u_char vers; + u_char comply; + u_short dindex; + u_char vspec8; + u_char vspec9; + u_char nhdr; + u_char vendor; + u_char info; + char str[244]; +}; + +typedef struct cistpl_vers_2_t cistpl_vers_2_t; + +struct cistpl_org_t { + u_char data_org; + char desc[30]; +}; + +typedef struct cistpl_org_t cistpl_org_t; + +struct cistpl_format_t { + u_char type; + u_char edc; + u_int offset; + u_int length; +}; + +typedef struct cistpl_format_t cistpl_format_t; + +union cisparse_t { + cistpl_device_t device; + cistpl_checksum_t checksum; + cistpl_longlink_t longlink; + cistpl_longlink_mfc_t longlink_mfc; + cistpl_vers_1_t version_1; + cistpl_altstr_t altstr; + cistpl_jedec_t jedec; + cistpl_manfid_t manfid; + cistpl_funcid_t funcid; + cistpl_funce_t funce; + cistpl_bar_t bar; + cistpl_config_t config; + cistpl_cftable_entry_t cftable_entry; + cistpl_cftable_entry_cb_t cftable_entry_cb; + cistpl_device_geo_t device_geo; + cistpl_vers_2_t vers_2; + cistpl_org_t org; + cistpl_format_t format; +}; + +typedef union cisparse_t cisparse_t; + +struct tuple_t { + u_int Attributes; + cisdata_t DesiredTuple; + u_int Flags; + u_int LinkOffset; + u_int CISOffset; + cisdata_t TupleCode; + cisdata_t TupleLink; + cisdata_t TupleOffset; + cisdata_t TupleDataMax; + cisdata_t TupleDataLen; + cisdata_t *TupleData; +}; + +typedef struct tuple_t tuple_t; + +struct cis_cache_entry { + struct list_head node; + unsigned int addr; + unsigned int len; + unsigned int attr; + unsigned char cache[0]; +}; + +struct tuple_flags { + u_int link_space: 4; + u_int has_link: 1; + u_int mfc_fn: 3; + u_int space: 4; +}; + +struct pcmcia_cfg_mem { + struct pcmcia_device *p_dev; + int (*conf_check)(struct pcmcia_device *, void *); + void *priv_data; + cisparse_t parse; + cistpl_cftable_entry_t dflt; +}; + +struct pcmcia_loop_mem { + struct pcmcia_device *p_dev; + void *priv_data; + int (*loop_tuple)(struct pcmcia_device *, tuple_t *, void *); +}; + +struct pcmcia_loop_get { + size_t len; + cisdata_t **buf; +}; + +struct resource_map { + u_long base; + u_long num; + struct resource_map *next; +}; + +struct socket_data { + struct resource_map mem_db; + struct resource_map mem_db_valid; + struct resource_map io_db; +}; + +struct pcmcia_align_data { + long unsigned int mask; + long unsigned int offset; + struct resource_map *map; +}; + +struct yenta_socket; + +struct cardbus_type { + int (*override)(struct yenta_socket *); + void (*save_state)(struct yenta_socket *); + void (*restore_state)(struct yenta_socket *); + int (*sock_init)(struct yenta_socket *); +}; + +struct yenta_socket { + struct pci_dev *dev; + int cb_irq; + int io_irq; + void *base; + struct timer_list poll_timer; + struct pcmcia_socket socket; + struct cardbus_type *type; + u32 flags; + unsigned int probe_status; + unsigned int private[8]; + u32 saved_state[2]; +}; + +enum { + CARDBUS_TYPE_DEFAULT = 4294967295, + CARDBUS_TYPE_TI = 0, + CARDBUS_TYPE_TI113X = 1, + CARDBUS_TYPE_TI12XX = 2, + CARDBUS_TYPE_TI1250 = 3, + CARDBUS_TYPE_RICOH = 4, + CARDBUS_TYPE_TOPIC95 = 5, + CARDBUS_TYPE_TOPIC97 = 6, + CARDBUS_TYPE_O2MICRO = 7, + CARDBUS_TYPE_ENE = 8, +}; + +enum usb_device_speed { + USB_SPEED_UNKNOWN = 0, + USB_SPEED_LOW = 1, + USB_SPEED_FULL = 2, + USB_SPEED_HIGH = 3, + USB_SPEED_WIRELESS = 4, + USB_SPEED_SUPER = 5, + USB_SPEED_SUPER_PLUS = 6, +}; + +enum usb_device_state { + USB_STATE_NOTATTACHED = 0, + USB_STATE_ATTACHED = 1, + USB_STATE_POWERED = 2, + USB_STATE_RECONNECTING = 3, + USB_STATE_UNAUTHENTICATED = 4, + USB_STATE_DEFAULT = 5, + USB_STATE_ADDRESS = 6, + USB_STATE_CONFIGURED = 7, + USB_STATE_SUSPENDED = 8, +}; + +enum usb_otg_state { + OTG_STATE_UNDEFINED = 0, + OTG_STATE_B_IDLE = 1, + OTG_STATE_B_SRP_INIT = 2, + OTG_STATE_B_PERIPHERAL = 3, + OTG_STATE_B_WAIT_ACON = 4, + OTG_STATE_B_HOST = 5, + OTG_STATE_A_IDLE = 6, + OTG_STATE_A_WAIT_VRISE = 7, + OTG_STATE_A_WAIT_BCON = 8, + OTG_STATE_A_HOST = 9, + OTG_STATE_A_SUSPEND = 10, + OTG_STATE_A_PERIPHERAL = 11, + OTG_STATE_A_WAIT_VFALL = 12, + OTG_STATE_A_VBUS_ERR = 13, +}; + +enum usb_dr_mode { + USB_DR_MODE_UNKNOWN = 0, + USB_DR_MODE_HOST = 1, + USB_DR_MODE_PERIPHERAL = 2, + USB_DR_MODE_OTG = 3, +}; + +struct usb_device_id { + __u16 match_flags; + __u16 idVendor; + __u16 idProduct; + __u16 bcdDevice_lo; + __u16 bcdDevice_hi; + __u8 bDeviceClass; + __u8 bDeviceSubClass; + __u8 bDeviceProtocol; + __u8 bInterfaceClass; + __u8 bInterfaceSubClass; + __u8 bInterfaceProtocol; + __u8 bInterfaceNumber; + kernel_ulong_t driver_info; +}; + +struct usb_descriptor_header { + __u8 bLength; + __u8 bDescriptorType; +}; + +struct usb_device_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __le16 bcdUSB; + __u8 bDeviceClass; + __u8 bDeviceSubClass; + __u8 bDeviceProtocol; + __u8 bMaxPacketSize0; + __le16 idVendor; + __le16 idProduct; + __le16 bcdDevice; + __u8 iManufacturer; + __u8 iProduct; + __u8 iSerialNumber; + __u8 bNumConfigurations; +}; + +struct usb_config_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __le16 wTotalLength; + __u8 bNumInterfaces; + __u8 bConfigurationValue; + __u8 iConfiguration; + __u8 bmAttributes; + __u8 bMaxPower; +} __attribute__((packed)); + +struct usb_interface_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bInterfaceNumber; + __u8 bAlternateSetting; + __u8 bNumEndpoints; + __u8 bInterfaceClass; + __u8 bInterfaceSubClass; + __u8 bInterfaceProtocol; + __u8 iInterface; +}; + +struct usb_endpoint_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bEndpointAddress; + __u8 bmAttributes; + __le16 wMaxPacketSize; + __u8 bInterval; + __u8 bRefresh; + __u8 bSynchAddress; +} __attribute__((packed)); + +struct usb_ssp_isoc_ep_comp_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __le16 wReseved; + __le32 dwBytesPerInterval; +}; + +struct usb_ss_ep_comp_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bMaxBurst; + __u8 bmAttributes; + __le16 wBytesPerInterval; +}; + +struct usb_interface_assoc_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bFirstInterface; + __u8 bInterfaceCount; + __u8 bFunctionClass; + __u8 bFunctionSubClass; + __u8 bFunctionProtocol; + __u8 iFunction; +}; + +struct usb_bos_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __le16 wTotalLength; + __u8 bNumDeviceCaps; +} __attribute__((packed)); + +struct usb_ext_cap_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; + __le32 bmAttributes; +} __attribute__((packed)); + +struct usb_ss_cap_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; + __u8 bmAttributes; + __le16 wSpeedSupported; + __u8 bFunctionalitySupport; + __u8 bU1devExitLat; + __le16 bU2DevExitLat; +}; + +struct usb_ss_container_id_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; + __u8 bReserved; + __u8 ContainerID[16]; +}; + +struct usb_ssp_cap_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; + __u8 bReserved; + __le32 bmAttributes; + __le16 wFunctionalitySupport; + __le16 wReserved; + __le32 bmSublinkSpeedAttr[1]; +}; + +struct usb_ptm_cap_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; +}; + +enum usb3_link_state { + USB3_LPM_U0 = 0, + USB3_LPM_U1 = 1, + USB3_LPM_U2 = 2, + USB3_LPM_U3 = 3, +}; + +struct ep_device; + +struct usb_host_endpoint { + struct usb_endpoint_descriptor desc; + struct usb_ss_ep_comp_descriptor ss_ep_comp; + struct usb_ssp_isoc_ep_comp_descriptor ssp_isoc_ep_comp; + char: 8; + struct list_head urb_list; + void *hcpriv; + struct ep_device *ep_dev; + unsigned char *extra; + int extralen; + int enabled; + int streams; + int: 32; +} __attribute__((packed)); + +struct usb_host_interface { + struct usb_interface_descriptor desc; + int extralen; + unsigned char *extra; + struct usb_host_endpoint *endpoint; + char *string; +}; + +enum usb_interface_condition { + USB_INTERFACE_UNBOUND = 0, + USB_INTERFACE_BINDING = 1, + USB_INTERFACE_BOUND = 2, + USB_INTERFACE_UNBINDING = 3, +}; + +struct usb_interface { + struct usb_host_interface *altsetting; + struct usb_host_interface *cur_altsetting; + unsigned int num_altsetting; + struct usb_interface_assoc_descriptor *intf_assoc; + int minor; + enum usb_interface_condition condition; + unsigned int sysfs_files_created: 1; + unsigned int ep_devs_created: 1; + unsigned int unregistering: 1; + unsigned int needs_remote_wakeup: 1; + unsigned int needs_altsetting0: 1; + unsigned int needs_binding: 1; + unsigned int resetting_device: 1; + unsigned int authorized: 1; + struct device dev; + struct device *usb_dev; + struct work_struct reset_ws; +}; + +struct usb_interface_cache { + unsigned int num_altsetting; + struct kref ref; + struct usb_host_interface altsetting[0]; +}; + +struct usb_host_config { + struct usb_config_descriptor desc; + char *string; + struct usb_interface_assoc_descriptor *intf_assoc[16]; + struct usb_interface *interface[32]; + struct usb_interface_cache *intf_cache[32]; + unsigned char *extra; + int extralen; +}; + +struct usb_host_bos { + struct usb_bos_descriptor *desc; + struct usb_ext_cap_descriptor *ext_cap; + struct usb_ss_cap_descriptor *ss_cap; + struct usb_ssp_cap_descriptor *ssp_cap; + struct usb_ss_container_id_descriptor *ss_id; + struct usb_ptm_cap_descriptor *ptm_cap; +}; + +struct usb_devmap { + long unsigned int devicemap[2]; +}; + +struct usb_device; + +struct mon_bus; + +struct usb_bus { + struct device *controller; + struct device *sysdev; + int busnum; + const char *bus_name; + u8 uses_pio_for_control; + u8 otg_port; + unsigned int is_b_host: 1; + unsigned int b_hnp_enable: 1; + unsigned int no_stop_on_short: 1; + unsigned int no_sg_constraint: 1; + unsigned int sg_tablesize; + int devnum_next; + struct mutex devnum_next_mutex; + struct usb_devmap devmap; + struct usb_device *root_hub; + struct usb_bus *hs_companion; + int bandwidth_allocated; + int bandwidth_int_reqs; + int bandwidth_isoc_reqs; + unsigned int resuming_ports; + struct mon_bus *mon_bus; + int monitored; +}; + +struct wusb_dev; + +enum usb_device_removable { + USB_DEVICE_REMOVABLE_UNKNOWN = 0, + USB_DEVICE_REMOVABLE = 1, + USB_DEVICE_FIXED = 2, +}; + +struct usb2_lpm_parameters { + unsigned int besl; + int timeout; +}; + +struct usb3_lpm_parameters { + unsigned int mel; + unsigned int pel; + unsigned int sel; + int timeout; +}; + +struct usb_tt; + +struct usb_device { + int devnum; + char devpath[16]; + u32 route; + enum usb_device_state state; + enum usb_device_speed speed; + unsigned int rx_lanes; + unsigned int tx_lanes; + struct usb_tt *tt; + int ttport; + unsigned int toggle[2]; + struct usb_device *parent; + struct usb_bus *bus; + struct usb_host_endpoint ep0; + struct device dev; + struct usb_device_descriptor descriptor; + struct usb_host_bos *bos; + struct usb_host_config *config; + struct usb_host_config *actconfig; + struct usb_host_endpoint *ep_in[16]; + struct usb_host_endpoint *ep_out[16]; + char **rawdescriptors; + short unsigned int bus_mA; + u8 portnum; + u8 level; + u8 devaddr; + unsigned int can_submit: 1; + unsigned int persist_enabled: 1; + unsigned int have_langid: 1; + unsigned int authorized: 1; + unsigned int authenticated: 1; + unsigned int wusb: 1; + unsigned int lpm_capable: 1; + unsigned int usb2_hw_lpm_capable: 1; + unsigned int usb2_hw_lpm_besl_capable: 1; + unsigned int usb2_hw_lpm_enabled: 1; + unsigned int usb2_hw_lpm_allowed: 1; + unsigned int usb3_lpm_u1_enabled: 1; + unsigned int usb3_lpm_u2_enabled: 1; + int string_langid; + char *product; + char *manufacturer; + char *serial; + struct list_head filelist; + int maxchild; + u32 quirks; + atomic_t urbnum; + long unsigned int active_duration; + long unsigned int connect_time; + unsigned int do_remote_wakeup: 1; + unsigned int reset_resume: 1; + unsigned int port_is_suspended: 1; + struct wusb_dev *wusb_dev; + int slot_id; + enum usb_device_removable removable; + struct usb2_lpm_parameters l1_params; + struct usb3_lpm_parameters u1_params; + struct usb3_lpm_parameters u2_params; + unsigned int lpm_disable_count; + u16 hub_delay; + unsigned int use_generic_driver: 1; +}; + +enum usb_port_connect_type { + USB_PORT_CONNECT_TYPE_UNKNOWN = 0, + USB_PORT_CONNECT_TYPE_HOT_PLUG = 1, + USB_PORT_CONNECT_TYPE_HARD_WIRED = 2, + USB_PORT_NOT_USED = 3, +}; + +struct usb_tt { + struct usb_device *hub; + int multi; + unsigned int think_time; + void *hcpriv; + spinlock_t lock; + struct list_head clear_list; + struct work_struct clear_work; +}; + +struct usb_dynids { + spinlock_t lock; + struct list_head list; +}; + +struct usbdrv_wrap { + struct device_driver driver; + int for_devices; +}; + +struct usb_driver { + const char *name; + int (*probe)(struct usb_interface *, const struct usb_device_id *); + void (*disconnect)(struct usb_interface *); + int (*unlocked_ioctl)(struct usb_interface *, unsigned int, void *); + int (*suspend)(struct usb_interface *, pm_message_t); + int (*resume)(struct usb_interface *); + int (*reset_resume)(struct usb_interface *); + int (*pre_reset)(struct usb_interface *); + int (*post_reset)(struct usb_interface *); + const struct usb_device_id *id_table; + const struct attribute_group **dev_groups; + struct usb_dynids dynids; + struct usbdrv_wrap drvwrap; + unsigned int no_dynamic_id: 1; + unsigned int supports_autosuspend: 1; + unsigned int disable_hub_initiated_lpm: 1; + unsigned int soft_unbind: 1; +}; + +struct usb_device_driver { + const char *name; + bool (*match)(struct usb_device *); + int (*probe)(struct usb_device *); + void (*disconnect)(struct usb_device *); + int (*suspend)(struct usb_device *, pm_message_t); + int (*resume)(struct usb_device *, pm_message_t); + const struct attribute_group **dev_groups; + struct usbdrv_wrap drvwrap; + const struct usb_device_id *id_table; + unsigned int supports_autosuspend: 1; + unsigned int generic_subclass: 1; +}; + +struct usb_iso_packet_descriptor { + unsigned int offset; + unsigned int length; + unsigned int actual_length; + int status; +}; + +struct usb_anchor { + struct list_head urb_list; + wait_queue_head_t wait; + spinlock_t lock; + atomic_t suspend_wakeups; + unsigned int poisoned: 1; +}; + +struct urb; + +typedef void (*usb_complete_t)(struct urb *); + +struct urb { + struct kref kref; + int unlinked; + void *hcpriv; + atomic_t use_count; + atomic_t reject; + struct list_head urb_list; + struct list_head anchor_list; + struct usb_anchor *anchor; + struct usb_device *dev; + struct usb_host_endpoint *ep; + unsigned int pipe; + unsigned int stream_id; + int status; + unsigned int transfer_flags; + void *transfer_buffer; + dma_addr_t transfer_dma; + struct scatterlist *sg; + int num_mapped_sgs; + int num_sgs; + u32 transfer_buffer_length; + u32 actual_length; + unsigned char *setup_packet; + dma_addr_t setup_dma; + int start_frame; + int number_of_packets; + int interval; + int error_count; + void *context; + usb_complete_t complete; + struct usb_iso_packet_descriptor iso_frame_desc[0]; +}; + +struct giveback_urb_bh { + bool running; + spinlock_t lock; + struct list_head head; + struct tasklet_struct bh; + struct usb_host_endpoint *completing_ep; +}; + +enum usb_dev_authorize_policy { + USB_DEVICE_AUTHORIZE_NONE = 0, + USB_DEVICE_AUTHORIZE_ALL = 1, + USB_DEVICE_AUTHORIZE_INTERNAL = 2, +}; + +struct usb_phy_roothub; + +struct hc_driver; + +struct usb_phy; + +struct usb_hcd { + struct usb_bus self; + struct kref kref; + const char *product_desc; + int speed; + char irq_descr[24]; + struct timer_list rh_timer; + struct urb *status_urb; + struct work_struct wakeup_work; + struct work_struct died_work; + const struct hc_driver *driver; + struct usb_phy *usb_phy; + struct usb_phy_roothub *phy_roothub; + long unsigned int flags; + enum usb_dev_authorize_policy dev_policy; + unsigned int rh_registered: 1; + unsigned int rh_pollable: 1; + unsigned int msix_enabled: 1; + unsigned int msi_enabled: 1; + unsigned int skip_phy_initialization: 1; + unsigned int uses_new_polling: 1; + unsigned int wireless: 1; + unsigned int has_tt: 1; + unsigned int amd_resume_bug: 1; + unsigned int can_do_streams: 1; + unsigned int tpl_support: 1; + unsigned int cant_recv_wakeups: 1; + unsigned int irq; + void *regs; + resource_size_t rsrc_start; + resource_size_t rsrc_len; + unsigned int power_budget; + struct giveback_urb_bh high_prio_bh; + struct giveback_urb_bh low_prio_bh; + struct mutex *address0_mutex; + struct mutex *bandwidth_mutex; + struct usb_hcd *shared_hcd; + struct usb_hcd *primary_hcd; + struct dma_pool___2 *pool[4]; + int state; + struct gen_pool *localmem_pool; + long unsigned int hcd_priv[0]; +}; + +struct hc_driver { + const char *description; + const char *product_desc; + size_t hcd_priv_size; + irqreturn_t (*irq)(struct usb_hcd *); + int flags; + int (*reset)(struct usb_hcd *); + int (*start)(struct usb_hcd *); + int (*pci_suspend)(struct usb_hcd *, bool); + int (*pci_resume)(struct usb_hcd *, bool); + void (*stop)(struct usb_hcd *); + void (*shutdown)(struct usb_hcd *); + int (*get_frame_number)(struct usb_hcd *); + int (*urb_enqueue)(struct usb_hcd *, struct urb *, gfp_t); + int (*urb_dequeue)(struct usb_hcd *, struct urb *, int); + int (*map_urb_for_dma)(struct usb_hcd *, struct urb *, gfp_t); + void (*unmap_urb_for_dma)(struct usb_hcd *, struct urb *); + void (*endpoint_disable)(struct usb_hcd *, struct usb_host_endpoint *); + void (*endpoint_reset)(struct usb_hcd *, struct usb_host_endpoint *); + int (*hub_status_data)(struct usb_hcd *, char *); + int (*hub_control)(struct usb_hcd *, u16, u16, u16, char *, u16); + int (*bus_suspend)(struct usb_hcd *); + int (*bus_resume)(struct usb_hcd *); + int (*start_port_reset)(struct usb_hcd *, unsigned int); + long unsigned int (*get_resuming_ports)(struct usb_hcd *); + void (*relinquish_port)(struct usb_hcd *, int); + int (*port_handed_over)(struct usb_hcd *, int); + void (*clear_tt_buffer_complete)(struct usb_hcd *, struct usb_host_endpoint *); + int (*alloc_dev)(struct usb_hcd *, struct usb_device *); + void (*free_dev)(struct usb_hcd *, struct usb_device *); + int (*alloc_streams)(struct usb_hcd *, struct usb_device *, struct usb_host_endpoint **, unsigned int, unsigned int, gfp_t); + int (*free_streams)(struct usb_hcd *, struct usb_device *, struct usb_host_endpoint **, unsigned int, gfp_t); + int (*add_endpoint)(struct usb_hcd *, struct usb_device *, struct usb_host_endpoint *); + int (*drop_endpoint)(struct usb_hcd *, struct usb_device *, struct usb_host_endpoint *); + int (*check_bandwidth)(struct usb_hcd *, struct usb_device *); + void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *); + int (*address_device)(struct usb_hcd *, struct usb_device *); + int (*enable_device)(struct usb_hcd *, struct usb_device *); + int (*update_hub_device)(struct usb_hcd *, struct usb_device *, struct usb_tt *, gfp_t); + int (*reset_device)(struct usb_hcd *, struct usb_device *); + int (*update_device)(struct usb_hcd *, struct usb_device *); + int (*set_usb2_hw_lpm)(struct usb_hcd *, struct usb_device *, int); + int (*enable_usb3_lpm_timeout)(struct usb_hcd *, struct usb_device *, enum usb3_link_state); + int (*disable_usb3_lpm_timeout)(struct usb_hcd *, struct usb_device *, enum usb3_link_state); + int (*find_raw_port_number)(struct usb_hcd *, int); + int (*port_power)(struct usb_hcd *, int, bool); +}; + +enum usb_phy_type { + USB_PHY_TYPE_UNDEFINED = 0, + USB_PHY_TYPE_USB2 = 1, + USB_PHY_TYPE_USB3 = 2, +}; + +enum usb_phy_events { + USB_EVENT_NONE = 0, + USB_EVENT_VBUS = 1, + USB_EVENT_ID = 2, + USB_EVENT_CHARGER = 3, + USB_EVENT_ENUMERATED = 4, +}; + +struct extcon_dev; + +enum usb_charger_type { + UNKNOWN_TYPE = 0, + SDP_TYPE = 1, + DCP_TYPE = 2, + CDP_TYPE = 3, + ACA_TYPE = 4, +}; + +enum usb_charger_state { + USB_CHARGER_DEFAULT = 0, + USB_CHARGER_PRESENT = 1, + USB_CHARGER_ABSENT = 2, +}; + +struct usb_charger_current { + unsigned int sdp_min; + unsigned int sdp_max; + unsigned int dcp_min; + unsigned int dcp_max; + unsigned int cdp_min; + unsigned int cdp_max; + unsigned int aca_min; + unsigned int aca_max; +}; + +struct usb_otg; + +struct usb_phy_io_ops; + +struct usb_phy { + struct device *dev; + const char *label; + unsigned int flags; + enum usb_phy_type type; + enum usb_phy_events last_event; + struct usb_otg *otg; + struct device *io_dev; + struct usb_phy_io_ops *io_ops; + void *io_priv; + struct extcon_dev *edev; + struct extcon_dev *id_edev; + struct notifier_block vbus_nb; + struct notifier_block id_nb; + struct notifier_block type_nb; + enum usb_charger_type chg_type; + enum usb_charger_state chg_state; + struct usb_charger_current chg_cur; + struct work_struct chg_work; + struct atomic_notifier_head notifier; + u16 port_status; + u16 port_change; + struct list_head head; + int (*init)(struct usb_phy *); + void (*shutdown)(struct usb_phy *); + int (*set_vbus)(struct usb_phy *, int); + int (*set_power)(struct usb_phy *, unsigned int); + int (*set_suspend)(struct usb_phy *, int); + int (*set_wakeup)(struct usb_phy *, bool); + int (*notify_connect)(struct usb_phy *, enum usb_device_speed); + int (*notify_disconnect)(struct usb_phy *, enum usb_device_speed); + enum usb_charger_type (*charger_detect)(struct usb_phy *); +}; + +struct usb_port_status { + __le16 wPortStatus; + __le16 wPortChange; + __le32 dwExtPortStatus; +}; + +struct usb_hub_status { + __le16 wHubStatus; + __le16 wHubChange; +}; + +struct usb_hub_descriptor { + __u8 bDescLength; + __u8 bDescriptorType; + __u8 bNbrPorts; + __le16 wHubCharacteristics; + __u8 bPwrOn2PwrGood; + __u8 bHubContrCurrent; + union { + struct { + __u8 DeviceRemovable[4]; + __u8 PortPwrCtrlMask[4]; + } hs; + struct { + __u8 bHubHdrDecLat; + __le16 wHubDelay; + __le16 DeviceRemovable; + } __attribute__((packed)) ss; + } u; +} __attribute__((packed)); + +struct usb_phy_io_ops { + int (*read)(struct usb_phy *, u32); + int (*write)(struct usb_phy *, u32, u32); +}; + +struct usb_gadget; + +struct usb_otg { + u8 default_a; + struct phy *phy; + struct usb_phy *usb_phy; + struct usb_bus *host; + struct usb_gadget *gadget; + enum usb_otg_state state; + int (*set_host)(struct usb_otg *, struct usb_bus *); + int (*set_peripheral)(struct usb_otg *, struct usb_gadget *); + int (*set_vbus)(struct usb_otg *, bool); + int (*start_srp)(struct usb_otg *); + int (*start_hnp)(struct usb_otg *); +}; + +typedef u32 usb_port_location_t; + +struct usb_port; + +struct usb_hub { + struct device *intfdev; + struct usb_device *hdev; + struct kref kref; + struct urb *urb; + u8 (*buffer)[8]; + union { + struct usb_hub_status hub; + struct usb_port_status port; + } *status; + struct mutex status_mutex; + int error; + int nerrors; + long unsigned int event_bits[1]; + long unsigned int change_bits[1]; + long unsigned int removed_bits[1]; + long unsigned int wakeup_bits[1]; + long unsigned int power_bits[1]; + long unsigned int child_usage_bits[1]; + long unsigned int warm_reset_bits[1]; + struct usb_hub_descriptor *descriptor; + struct usb_tt tt; + unsigned int mA_per_port; + unsigned int wakeup_enabled_descendants; + unsigned int limited_power: 1; + unsigned int quiescing: 1; + unsigned int disconnected: 1; + unsigned int in_reset: 1; + unsigned int quirk_disable_autosuspend: 1; + unsigned int quirk_check_port_auto_suspend: 1; + unsigned int has_indicators: 1; + u8 indicator[31]; + struct delayed_work leds; + struct delayed_work init_work; + struct work_struct events; + spinlock_t irq_urb_lock; + struct timer_list irq_urb_retry; + struct usb_port **ports; +}; + +struct usb_dev_state; + +struct usb_port { + struct usb_device *child; + struct device dev; + struct usb_dev_state *port_owner; + struct usb_port *peer; + struct dev_pm_qos_request *req; + enum usb_port_connect_type connect_type; + usb_port_location_t location; + struct mutex status_lock; + u32 over_current_count; + u8 portnum; + u32 quirks; + unsigned int is_superspeed: 1; + unsigned int usb3_lpm_u1_permit: 1; + unsigned int usb3_lpm_u2_permit: 1; +}; + +struct find_interface_arg { + int minor; + struct device_driver *drv; +}; + +struct each_dev_arg { + void *data; + int (*fn)(struct usb_device *, void *); +}; + +struct usb_qualifier_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __le16 bcdUSB; + __u8 bDeviceClass; + __u8 bDeviceSubClass; + __u8 bDeviceProtocol; + __u8 bMaxPacketSize0; + __u8 bNumConfigurations; + __u8 bRESERVED; +}; + +struct usb_set_sel_req { + __u8 u1_sel; + __u8 u1_pel; + __le16 u2_sel; + __le16 u2_pel; +}; + +struct usbdevfs_hub_portinfo { + char nports; + char port[127]; +}; + +enum hub_led_mode { + INDICATOR_AUTO = 0, + INDICATOR_CYCLE = 1, + INDICATOR_GREEN_BLINK = 2, + INDICATOR_GREEN_BLINK_OFF = 3, + INDICATOR_AMBER_BLINK = 4, + INDICATOR_AMBER_BLINK_OFF = 5, + INDICATOR_ALT_BLINK = 6, + INDICATOR_ALT_BLINK_OFF = 7, +}; + +struct usb_tt_clear { + struct list_head clear_list; + unsigned int tt; + u16 devinfo; + struct usb_hcd *hcd; + struct usb_host_endpoint *ep; +}; + +enum hub_activation_type { + HUB_INIT = 0, + HUB_INIT2 = 1, + HUB_INIT3 = 2, + HUB_POST_RESET = 3, + HUB_RESUME = 4, + HUB_RESET_RESUME = 5, +}; + +enum hub_quiescing_type { + HUB_DISCONNECT = 0, + HUB_PRE_RESET = 1, + HUB_SUSPEND = 2, +}; + +struct usb_ctrlrequest { + __u8 bRequestType; + __u8 bRequest; + __le16 wValue; + __le16 wIndex; + __le16 wLength; +}; + +enum usb_led_event { + USB_LED_EVENT_HOST = 0, + USB_LED_EVENT_GADGET = 1, +}; + +struct usb_mon_operations { + void (*urb_submit)(struct usb_bus *, struct urb *); + void (*urb_submit_error)(struct usb_bus *, struct urb *, int); + void (*urb_complete)(struct usb_bus *, struct urb *, int); +}; + +struct usb_sg_request { + int status; + size_t bytes; + spinlock_t lock; + struct usb_device *dev; + int pipe; + int entries; + struct urb **urbs; + int count; + struct completion complete; +}; + +struct usb_cdc_header_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __le16 bcdCDC; +} __attribute__((packed)); + +struct usb_cdc_call_mgmt_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __u8 bmCapabilities; + __u8 bDataInterface; +}; + +struct usb_cdc_acm_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __u8 bmCapabilities; +}; + +struct usb_cdc_union_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __u8 bMasterInterface0; + __u8 bSlaveInterface0; +}; + +struct usb_cdc_country_functional_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __u8 iCountryCodeRelDate; + __le16 wCountyCode0; +}; + +struct usb_cdc_network_terminal_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __u8 bEntityId; + __u8 iName; + __u8 bChannelIndex; + __u8 bPhysicalInterface; +}; + +struct usb_cdc_ether_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __u8 iMACAddress; + __le32 bmEthernetStatistics; + __le16 wMaxSegmentSize; + __le16 wNumberMCFilters; + __u8 bNumberPowerFilters; +} __attribute__((packed)); + +struct usb_cdc_dmm_desc { + __u8 bFunctionLength; + __u8 bDescriptorType; + __u8 bDescriptorSubtype; + __u16 bcdVersion; + __le16 wMaxCommand; +} __attribute__((packed)); + +struct usb_cdc_mdlm_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __le16 bcdVersion; + __u8 bGUID[16]; +} __attribute__((packed)); + +struct usb_cdc_mdlm_detail_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __u8 bGuidDescriptorType; + __u8 bDetailData[0]; +}; + +struct usb_cdc_obex_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __le16 bcdVersion; +} __attribute__((packed)); + +struct usb_cdc_ncm_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __le16 bcdNcmVersion; + __u8 bmNetworkCapabilities; +} __attribute__((packed)); + +struct usb_cdc_mbim_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __le16 bcdMBIMVersion; + __le16 wMaxControlMessage; + __u8 bNumberFilters; + __u8 bMaxFilterSize; + __le16 wMaxSegmentSize; + __u8 bmNetworkCapabilities; +} __attribute__((packed)); + +struct usb_cdc_mbim_extended_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + __le16 bcdMBIMExtendedVersion; + __u8 bMaxOutstandingCommandMessages; + __le16 wMTU; +} __attribute__((packed)); + +struct usb_cdc_parsed_header { + struct usb_cdc_union_desc *usb_cdc_union_desc; + struct usb_cdc_header_desc *usb_cdc_header_desc; + struct usb_cdc_call_mgmt_descriptor *usb_cdc_call_mgmt_descriptor; + struct usb_cdc_acm_descriptor *usb_cdc_acm_descriptor; + struct usb_cdc_country_functional_desc *usb_cdc_country_functional_desc; + struct usb_cdc_network_terminal_desc *usb_cdc_network_terminal_desc; + struct usb_cdc_ether_desc *usb_cdc_ether_desc; + struct usb_cdc_dmm_desc *usb_cdc_dmm_desc; + struct usb_cdc_mdlm_desc *usb_cdc_mdlm_desc; + struct usb_cdc_mdlm_detail_desc *usb_cdc_mdlm_detail_desc; + struct usb_cdc_obex_desc *usb_cdc_obex_desc; + struct usb_cdc_ncm_desc *usb_cdc_ncm_desc; + struct usb_cdc_mbim_desc *usb_cdc_mbim_desc; + struct usb_cdc_mbim_extended_desc *usb_cdc_mbim_extended_desc; + bool phonet_magic_present; +}; + +struct api_context { + struct completion done; + int status; +}; + +struct set_config_request { + struct usb_device *udev; + int config; + struct work_struct work; + struct list_head node; +}; + +struct usb_dynid { + struct list_head node; + struct usb_device_id id; +}; + +struct usb_dev_cap_header { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; +}; + +struct usb_class_driver { + char *name; + char * (*devnode)(struct device *, umode_t *); + const struct file_operations *fops; + int minor_base; +}; + +struct usb_class { + struct kref kref; + struct class *class; +}; + +struct ep_device { + struct usb_endpoint_descriptor *desc; + struct usb_device *udev; + struct device dev; +}; + +struct usbdevfs_ctrltransfer { + __u8 bRequestType; + __u8 bRequest; + __u16 wValue; + __u16 wIndex; + __u16 wLength; + __u32 timeout; + void *data; +}; + +struct usbdevfs_bulktransfer { + unsigned int ep; + unsigned int len; + unsigned int timeout; + void *data; +}; + +struct usbdevfs_setinterface { + unsigned int interface; + unsigned int altsetting; +}; + +struct usbdevfs_disconnectsignal { + unsigned int signr; + void *context; +}; + +struct usbdevfs_getdriver { + unsigned int interface; + char driver[256]; +}; + +struct usbdevfs_connectinfo { + unsigned int devnum; + unsigned char slow; +}; + +struct usbdevfs_conninfo_ex { + __u32 size; + __u32 busnum; + __u32 devnum; + __u32 speed; + __u8 num_ports; + __u8 ports[7]; +}; + +struct usbdevfs_iso_packet_desc { + unsigned int length; + unsigned int actual_length; + unsigned int status; +}; + +struct usbdevfs_urb { + unsigned char type; + unsigned char endpoint; + int status; + unsigned int flags; + void *buffer; + int buffer_length; + int actual_length; + int start_frame; + union { + int number_of_packets; + unsigned int stream_id; + }; + int error_count; + unsigned int signr; + void *usercontext; + struct usbdevfs_iso_packet_desc iso_frame_desc[0]; +}; + +struct usbdevfs_ioctl { + int ifno; + int ioctl_code; + void *data; +}; + +struct usbdevfs_disconnect_claim { + unsigned int interface; + unsigned int flags; + char driver[256]; +}; + +struct usbdevfs_streams { + unsigned int num_streams; + unsigned int num_eps; + unsigned char eps[0]; +}; + +struct usbdevfs_ctrltransfer32 { + u8 bRequestType; + u8 bRequest; + u16 wValue; + u16 wIndex; + u16 wLength; + u32 timeout; + compat_caddr_t data; +}; + +struct usbdevfs_bulktransfer32 { + compat_uint_t ep; + compat_uint_t len; + compat_uint_t timeout; + compat_caddr_t data; +}; + +struct usbdevfs_disconnectsignal32 { + compat_int_t signr; + compat_caddr_t context; +}; + +struct usbdevfs_urb32 { + unsigned char type; + unsigned char endpoint; + compat_int_t status; + compat_uint_t flags; + compat_caddr_t buffer; + compat_int_t buffer_length; + compat_int_t actual_length; + compat_int_t start_frame; + compat_int_t number_of_packets; + compat_int_t error_count; + compat_uint_t signr; + compat_caddr_t usercontext; + struct usbdevfs_iso_packet_desc iso_frame_desc[0]; +}; + +struct usbdevfs_ioctl32 { + s32 ifno; + s32 ioctl_code; + compat_caddr_t data; +}; + +struct usb_dev_state___2 { + struct list_head list; + struct usb_device *dev; + struct file *file; + spinlock_t lock; + struct list_head async_pending; + struct list_head async_completed; + struct list_head memory_list; + wait_queue_head_t wait; + wait_queue_head_t wait_for_resume; + unsigned int discsignr; + struct pid *disc_pid; + const struct cred *cred; + sigval_t disccontext; + long unsigned int ifclaimed; + u32 disabled_bulk_eps; + long unsigned int interface_allowed_mask; + int not_yet_resumed; + bool suspend_allowed; + bool privileges_dropped; +}; + +struct usb_memory { + struct list_head memlist; + int vma_use_count; + int urb_use_count; + u32 size; + void *mem; + dma_addr_t dma_handle; + long unsigned int vm_start; + struct usb_dev_state___2 *ps; +}; + +struct async { + struct list_head asynclist; + struct usb_dev_state___2 *ps; + struct pid *pid; + const struct cred *cred; + unsigned int signr; + unsigned int ifnum; + void *userbuffer; + void *userurb; + sigval_t userurb_sigval; + struct urb *urb; + struct usb_memory *usbm; + unsigned int mem_usage; + int status; + u8 bulk_addr; + u8 bulk_status; +}; + +enum snoop_when { + SUBMIT = 0, + COMPLETE = 1, +}; + +struct quirk_entry { + u16 vid; + u16 pid; + u32 flags; +}; + +struct class_info { + int class; + char *class_name; +}; + +struct usb_phy_roothub___2 { + struct phy *phy; + struct list_head list; +}; + +typedef void (*companion_fn)(struct pci_dev *, struct usb_hcd *, struct pci_dev *, struct usb_hcd *); + +struct mon_bus { + struct list_head bus_link; + spinlock_t lock; + struct usb_bus *u_bus; + int text_inited; + int bin_inited; + struct dentry *dent_s; + struct dentry *dent_t; + struct dentry *dent_u; + struct device *classdev; + int nreaders; + struct list_head r_list; + struct kref ref; + unsigned int cnt_events; + unsigned int cnt_text_lost; +}; + +struct mon_reader { + struct list_head r_link; + struct mon_bus *m_bus; + void *r_data; + void (*rnf_submit)(void *, struct urb *); + void (*rnf_error)(void *, struct urb *, int); + void (*rnf_complete)(void *, struct urb *, int); +}; + +struct snap { + int slen; + char str[80]; +}; + +struct mon_iso_desc { + int status; + unsigned int offset; + unsigned int length; +}; + +struct mon_event_text { + struct list_head e_link; + int type; + long unsigned int id; + unsigned int tstamp; + int busnum; + char devnum; + char epnum; + char is_in; + char xfertype; + int length; + int status; + int interval; + int start_frame; + int error_count; + char setup_flag; + char data_flag; + int numdesc; + struct mon_iso_desc isodesc[5]; + unsigned char setup[8]; + unsigned char data[32]; +}; + +struct mon_reader_text { + struct kmem_cache *e_slab; + int nevents; + struct list_head e_list; + struct mon_reader r; + wait_queue_head_t wait; + int printf_size; + size_t printf_offset; + size_t printf_togo; + char *printf_buf; + struct mutex printf_lock; + char slab_name[30]; +}; + +struct mon_text_ptr { + int cnt; + int limit; + char *pbuf; +}; + +enum { + NAMESZ = 10, +}; + +struct iso_rec { + int error_count; + int numdesc; +}; + +struct mon_bin_hdr { + u64 id; + unsigned char type; + unsigned char xfer_type; + unsigned char epnum; + unsigned char devnum; + short unsigned int busnum; + char flag_setup; + char flag_data; + s64 ts_sec; + s32 ts_usec; + int status; + unsigned int len_urb; + unsigned int len_cap; + union { + unsigned char setup[8]; + struct iso_rec iso; + } s; + int interval; + int start_frame; + unsigned int xfer_flags; + unsigned int ndesc; +}; + +struct mon_bin_isodesc { + int iso_status; + unsigned int iso_off; + unsigned int iso_len; + u32 _pad; +}; + +struct mon_bin_stats { + u32 queued; + u32 dropped; +}; + +struct mon_bin_get { + struct mon_bin_hdr *hdr; + void *data; + size_t alloc; +}; + +struct mon_bin_mfetch { + u32 *offvec; + u32 nfetch; + u32 nflush; +}; + +struct mon_bin_get32 { + u32 hdr32; + u32 data32; + u32 alloc32; +}; + +struct mon_bin_mfetch32 { + u32 offvec32; + u32 nfetch32; + u32 nflush32; +}; + +struct mon_pgmap { + struct page *pg; + unsigned char *ptr; +}; + +struct mon_reader_bin { + spinlock_t b_lock; + unsigned int b_size; + unsigned int b_cnt; + unsigned int b_in; + unsigned int b_out; + unsigned int b_read; + struct mon_pgmap *b_vec; + wait_queue_head_t b_wait; + struct mutex fetch_lock; + int mmap_active; + struct mon_reader r; + unsigned int cnt_lost; +}; + +enum amd_chipset_gen { + NOT_AMD_CHIPSET = 0, + AMD_CHIPSET_SB600 = 1, + AMD_CHIPSET_SB700 = 2, + AMD_CHIPSET_SB800 = 3, + AMD_CHIPSET_HUDSON2 = 4, + AMD_CHIPSET_BOLTON = 5, + AMD_CHIPSET_YANGTZE = 6, + AMD_CHIPSET_TAISHAN = 7, + AMD_CHIPSET_UNKNOWN = 8, +}; + +struct amd_chipset_type { + enum amd_chipset_gen gen; + u8 rev; +}; + +struct amd_chipset_info { + struct pci_dev *nb_dev; + struct pci_dev *smbus_dev; + int nb_type; + struct amd_chipset_type sb_type; + int isoc_reqs; + int probe_count; + bool need_pll_quirk; +}; + +struct serio_device_id { + __u8 type; + __u8 extra; + __u8 id; + __u8 proto; +}; + +struct serio_driver; + +struct serio { + void *port_data; + char name[32]; + char phys[32]; + char firmware_id[128]; + bool manual_bind; + struct serio_device_id id; + spinlock_t lock; + int (*write)(struct serio *, unsigned char); + int (*open)(struct serio *); + void (*close)(struct serio *); + int (*start)(struct serio *); + void (*stop)(struct serio *); + struct serio *parent; + struct list_head child_node; + struct list_head children; + unsigned int depth; + struct serio_driver *drv; + struct mutex drv_mutex; + struct device dev; + struct list_head node; + struct mutex *ps2_cmd_mutex; +}; + +struct serio_driver { + const char *description; + const struct serio_device_id *id_table; + bool manual_bind; + void (*write_wakeup)(struct serio *); + irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int); + int (*connect)(struct serio *, struct serio_driver *); + int (*reconnect)(struct serio *); + int (*fast_reconnect)(struct serio *); + void (*disconnect)(struct serio *); + void (*cleanup)(struct serio *); + struct device_driver driver; +}; + +enum serio_event_type { + SERIO_RESCAN_PORT = 0, + SERIO_RECONNECT_PORT = 1, + SERIO_RECONNECT_SUBTREE = 2, + SERIO_REGISTER_PORT = 3, + SERIO_ATTACH_DRIVER = 4, +}; + +struct serio_event { + enum serio_event_type type; + void *object; + struct module *owner; + struct list_head node; +}; + +enum i8042_controller_reset_mode { + I8042_RESET_NEVER = 0, + I8042_RESET_ALWAYS = 1, + I8042_RESET_ON_S2RAM = 2, +}; + +struct i8042_port { + struct serio *serio; + int irq; + bool exists; + bool driver_bound; + signed char mux; +}; + +struct serport { + struct tty_struct *tty; + wait_queue_head_t wait; + struct serio *serio; + struct serio_device_id id; + spinlock_t lock; + long unsigned int flags; +}; + +struct ps2dev { + struct serio *serio; + struct mutex cmd_mutex; + wait_queue_head_t wait; + long unsigned int flags; + u8 cmdbuf[8]; + u8 cmdcnt; + u8 nak; +}; + +struct input_mt_slot { + int abs[14]; + unsigned int frame; + unsigned int key; +}; + +struct input_mt { + int trkid; + int num_slots; + int slot; + unsigned int flags; + unsigned int frame; + int *red; + struct input_mt_slot slots[0]; +}; + +union input_seq_state { + struct { + short unsigned int pos; + bool mutex_acquired; + }; + void *p; +}; + +struct input_devres { + struct input_dev *input; +}; + +struct input_event { + __kernel_ulong_t __sec; + __kernel_ulong_t __usec; + __u16 type; + __u16 code; + __s32 value; +}; + +struct input_event_compat { + compat_ulong_t sec; + compat_ulong_t usec; + __u16 type; + __u16 code; + __s32 value; +}; + +struct ff_periodic_effect_compat { + __u16 waveform; + __u16 period; + __s16 magnitude; + __s16 offset; + __u16 phase; + struct ff_envelope envelope; + __u32 custom_len; + compat_uptr_t custom_data; +}; + +struct ff_effect_compat { + __u16 type; + __s16 id; + __u16 direction; + struct ff_trigger trigger; + struct ff_replay replay; + union { + struct ff_constant_effect constant; + struct ff_ramp_effect ramp; + struct ff_periodic_effect_compat periodic; + struct ff_condition_effect condition[2]; + struct ff_rumble_effect rumble; + } u; +}; + +struct input_mt_pos { + s16 x; + s16 y; +}; + +struct input_dev_poller { + void (*poll)(struct input_dev *); + unsigned int poll_interval; + unsigned int poll_interval_max; + unsigned int poll_interval_min; + struct input_dev *input; + struct delayed_work work; +}; + +struct ml_effect_state { + struct ff_effect *effect; + long unsigned int flags; + int count; + long unsigned int play_at; + long unsigned int stop_at; + long unsigned int adj_at; +}; + +struct ml_device { + void *private; + struct ml_effect_state states[16]; + int gain; + struct timer_list timer; + struct input_dev *dev; + int (*play_effect)(struct input_dev *, void *, struct ff_effect *); +}; + +struct mousedev_hw_data { + int dx; + int dy; + int dz; + int x; + int y; + int abs_event; + long unsigned int buttons; +}; + +struct mousedev { + int open; + struct input_handle handle; + wait_queue_head_t wait; + struct list_head client_list; + spinlock_t client_lock; + struct mutex mutex; + struct device dev; + struct cdev cdev; + bool exist; + struct list_head mixdev_node; + bool opened_by_mixdev; + struct mousedev_hw_data packet; + unsigned int pkt_count; + int old_x[4]; + int old_y[4]; + int frac_dx; + int frac_dy; + long unsigned int touch; + int (*open_device)(struct mousedev *); + void (*close_device)(struct mousedev *); +}; + +enum mousedev_emul { + MOUSEDEV_EMUL_PS2 = 0, + MOUSEDEV_EMUL_IMPS = 1, + MOUSEDEV_EMUL_EXPS = 2, +}; + +struct mousedev_motion { + int dx; + int dy; + int dz; + long unsigned int buttons; +}; + +struct mousedev_client { + struct fasync_struct *fasync; + struct mousedev *mousedev; + struct list_head node; + struct mousedev_motion packets[16]; + unsigned int head; + unsigned int tail; + spinlock_t packet_lock; + int pos_x; + int pos_y; + u8 ps2[6]; + unsigned char ready; + unsigned char buffer; + unsigned char bufsiz; + unsigned char imexseq; + unsigned char impsseq; + enum mousedev_emul mode; + long unsigned int last_buttons; +}; + +enum { + FRACTION_DENOM = 128, +}; + +struct input_mask { + __u32 type; + __u32 codes_size; + __u64 codes_ptr; +}; + +struct evdev_client; + +struct evdev { + int open; + struct input_handle handle; + struct evdev_client *grab; + struct list_head client_list; + spinlock_t client_lock; + struct mutex mutex; + struct device dev; + struct cdev cdev; + bool exist; +}; + +struct evdev_client { + unsigned int head; + unsigned int tail; + unsigned int packet_head; + spinlock_t buffer_lock; + wait_queue_head_t wait; + struct fasync_struct *fasync; + struct evdev *evdev; + struct list_head node; + enum input_clock_type clk_type; + bool revoked; + long unsigned int *evmasks[32]; + unsigned int bufsize; + struct input_event buffer[0]; +}; + +struct atkbd { + struct ps2dev ps2dev; + struct input_dev *dev; + char name[64]; + char phys[32]; + short unsigned int id; + short unsigned int keycode[512]; + long unsigned int force_release_mask[8]; + unsigned char set; + bool translated; + bool extra; + bool write; + bool softrepeat; + bool softraw; + bool scroll; + bool enabled; + unsigned char emul; + bool resend; + bool release; + long unsigned int xl_bit; + unsigned int last; + long unsigned int time; + long unsigned int err_count; + struct delayed_work event_work; + long unsigned int event_jiffies; + long unsigned int event_mask; + struct mutex mutex; + u32 function_row_physmap[24]; + int num_function_row_keys; +}; + +enum psmouse_state { + PSMOUSE_IGNORE = 0, + PSMOUSE_INITIALIZING = 1, + PSMOUSE_RESYNCING = 2, + PSMOUSE_CMD_MODE = 3, + PSMOUSE_ACTIVATED = 4, +}; + +typedef enum { + PSMOUSE_BAD_DATA = 0, + PSMOUSE_GOOD_DATA = 1, + PSMOUSE_FULL_PACKET = 2, +} psmouse_ret_t; + +enum psmouse_scale { + PSMOUSE_SCALE11 = 0, + PSMOUSE_SCALE21 = 1, +}; + +enum psmouse_type { + PSMOUSE_NONE = 0, + PSMOUSE_PS2 = 1, + PSMOUSE_PS2PP = 2, + PSMOUSE_THINKPS = 3, + PSMOUSE_GENPS = 4, + PSMOUSE_IMPS = 5, + PSMOUSE_IMEX = 6, + PSMOUSE_SYNAPTICS = 7, + PSMOUSE_ALPS = 8, + PSMOUSE_LIFEBOOK = 9, + PSMOUSE_TRACKPOINT = 10, + PSMOUSE_TOUCHKIT_PS2 = 11, + PSMOUSE_CORTRON = 12, + PSMOUSE_HGPK = 13, + PSMOUSE_ELANTECH = 14, + PSMOUSE_FSP = 15, + PSMOUSE_SYNAPTICS_RELATIVE = 16, + PSMOUSE_CYPRESS = 17, + PSMOUSE_FOCALTECH = 18, + PSMOUSE_VMMOUSE = 19, + PSMOUSE_BYD = 20, + PSMOUSE_SYNAPTICS_SMBUS = 21, + PSMOUSE_ELANTECH_SMBUS = 22, + PSMOUSE_AUTO = 23, +}; + +struct psmouse; + +struct psmouse_protocol { + enum psmouse_type type; + bool maxproto; + bool ignore_parity; + bool try_passthru; + bool smbus_companion; + const char *name; + const char *alias; + int (*detect)(struct psmouse *, bool); + int (*init)(struct psmouse *); +}; + +struct psmouse { + void *private; + struct input_dev *dev; + struct ps2dev ps2dev; + struct delayed_work resync_work; + const char *vendor; + const char *name; + const struct psmouse_protocol *protocol; + unsigned char packet[8]; + unsigned char badbyte; + unsigned char pktcnt; + unsigned char pktsize; + unsigned char oob_data_type; + unsigned char extra_buttons; + bool acks_disable_command; + unsigned int model; + long unsigned int last; + long unsigned int out_of_sync_cnt; + long unsigned int num_resyncs; + enum psmouse_state state; + char devname[64]; + char phys[32]; + unsigned int rate; + unsigned int resolution; + unsigned int resetafter; + unsigned int resync_time; + bool smartscroll; + psmouse_ret_t (*protocol_handler)(struct psmouse *); + void (*set_rate)(struct psmouse *, unsigned int); + void (*set_resolution)(struct psmouse *, unsigned int); + void (*set_scale)(struct psmouse *, enum psmouse_scale); + int (*reconnect)(struct psmouse *); + int (*fast_reconnect)(struct psmouse *); + void (*disconnect)(struct psmouse *); + void (*cleanup)(struct psmouse *); + int (*poll)(struct psmouse *); + void (*pt_activate)(struct psmouse *); + void (*pt_deactivate)(struct psmouse *); +}; + +struct psmouse_attribute { + struct device_attribute dattr; + void *data; + ssize_t (*show)(struct psmouse *, void *, char *); + ssize_t (*set)(struct psmouse *, void *, const char *, size_t); + bool protect; +}; + +enum synaptics_pkt_type { + SYN_NEWABS = 0, + SYN_NEWABS_STRICT = 1, + SYN_NEWABS_RELAXED = 2, + SYN_OLDABS = 3, +}; + +struct synaptics_hw_state { + int x; + int y; + int z; + int w; + unsigned int left: 1; + unsigned int right: 1; + unsigned int middle: 1; + unsigned int up: 1; + unsigned int down: 1; + u8 ext_buttons; + s8 scroll; +}; + +struct synaptics_device_info { + u32 model_id; + u32 firmware_id; + u32 board_id; + u32 capabilities; + u32 ext_cap; + u32 ext_cap_0c; + u32 ext_cap_10; + u32 identity; + u32 x_res; + u32 y_res; + u32 x_max; + u32 y_max; + u32 x_min; + u32 y_min; +}; + +struct synaptics_data { + struct synaptics_device_info info; + enum synaptics_pkt_type pkt_type; + u8 mode; + int scroll; + bool absolute_mode; + bool disable_gesture; + struct serio *pt_port; + struct synaptics_hw_state agm; + unsigned int agm_count; + long unsigned int press_start; + bool press; + bool report_press; + bool is_forcepad; +}; + +struct min_max_quirk { + const char * const *pnp_ids; + struct { + u32 min; + u32 max; + } board_id; + u32 x_min; + u32 x_max; + u32 y_min; + u32 y_max; +}; + +enum SS4_PACKET_ID { + SS4_PACKET_ID_IDLE = 0, + SS4_PACKET_ID_ONE = 1, + SS4_PACKET_ID_TWO = 2, + SS4_PACKET_ID_MULTI = 3, + SS4_PACKET_ID_STICK = 4, +}; + +enum V7_PACKET_ID { + V7_PACKET_ID_IDLE = 0, + V7_PACKET_ID_TWO = 1, + V7_PACKET_ID_MULTI = 2, + V7_PACKET_ID_NEW = 3, + V7_PACKET_ID_UNKNOWN = 4, +}; + +struct alps_protocol_info { + u16 version; + u8 byte0; + u8 mask0; + unsigned int flags; +}; + +struct alps_model_info { + u8 signature[3]; + struct alps_protocol_info protocol_info; +}; + +struct alps_nibble_commands { + int command; + unsigned char data; +}; + +struct alps_bitmap_point { + int start_bit; + int num_bits; +}; + +struct alps_fields { + unsigned int x_map; + unsigned int y_map; + unsigned int fingers; + int pressure; + struct input_mt_pos st; + struct input_mt_pos mt[4]; + unsigned int first_mp: 1; + unsigned int is_mp: 1; + unsigned int left: 1; + unsigned int right: 1; + unsigned int middle: 1; + unsigned int ts_left: 1; + unsigned int ts_right: 1; + unsigned int ts_middle: 1; +}; + +struct alps_data { + struct psmouse *psmouse; + struct input_dev *dev2; + struct input_dev *dev3; + char phys2[32]; + char phys3[32]; + struct delayed_work dev3_register_work; + const struct alps_nibble_commands *nibble_commands; + int addr_command; + u16 proto_version; + u8 byte0; + u8 mask0; + u8 dev_id[3]; + u8 fw_ver[3]; + int flags; + int x_max; + int y_max; + int x_bits; + int y_bits; + unsigned int x_res; + unsigned int y_res; + int (*hw_init)(struct psmouse *); + void (*process_packet)(struct psmouse *); + int (*decode_fields)(struct alps_fields *, unsigned char *, struct psmouse *); + void (*set_abs_params)(struct alps_data *, struct input_dev *); + int prev_fin; + int multi_packet; + int second_touch; + unsigned char multi_data[6]; + struct alps_fields f; + u8 quirks; + struct timer_list timer; +}; + +struct byd_data { + struct timer_list timer; + struct psmouse *psmouse; + s32 abs_x; + s32 abs_y; + volatile long unsigned int last_touch_time; + bool btn_left; + bool btn_right; + bool touch; +}; + +struct ps2pp_info { + u8 model; + u8 kind; + u16 features; +}; + +struct lifebook_data { + struct input_dev *dev2; + char phys[32]; +}; + +struct trackpoint_data { + u8 variant_id; + u8 firmware_id; + u8 sensitivity; + u8 speed; + u8 inertia; + u8 reach; + u8 draghys; + u8 mindrag; + u8 thresh; + u8 upthresh; + u8 ztime; + u8 jenks; + u8 drift_time; + bool press_to_select; + bool skipback; + bool ext_dev; +}; + +struct trackpoint_attr_data { + size_t field_offset; + u8 command; + u8 mask; + bool inverted; + u8 power_on_default; +}; + +struct cytp_contact { + int x; + int y; + int z; +}; + +struct cytp_report_data { + int contact_cnt; + struct cytp_contact contacts[2]; + unsigned int left: 1; + unsigned int right: 1; + unsigned int middle: 1; + unsigned int tap: 1; +}; + +struct cytp_data { + int fw_version; + int pkt_size; + int mode; + int tp_min_pressure; + int tp_max_pressure; + int tp_width; + int tp_high; + int tp_max_abs_x; + int tp_max_abs_y; + int tp_res_x; + int tp_res_y; + int tp_metrics_supported; +}; + +struct trace_event_raw_rtc_time_alarm_class { + struct trace_entry ent; + time64_t secs; + int err; + char __data[0]; +}; + +struct trace_event_raw_rtc_irq_set_freq { + struct trace_entry ent; + int freq; + int err; + char __data[0]; +}; + +struct trace_event_raw_rtc_irq_set_state { + struct trace_entry ent; + int enabled; + int err; + char __data[0]; +}; + +struct trace_event_raw_rtc_alarm_irq_enable { + struct trace_entry ent; + unsigned int enabled; + int err; + char __data[0]; +}; + +struct trace_event_raw_rtc_offset_class { + struct trace_entry ent; + long int offset; + int err; + char __data[0]; +}; + +struct trace_event_raw_rtc_timer_class { + struct trace_entry ent; + struct rtc_timer *timer; + ktime_t expires; + ktime_t period; + char __data[0]; +}; + +struct trace_event_data_offsets_rtc_time_alarm_class {}; + +struct trace_event_data_offsets_rtc_irq_set_freq {}; + +struct trace_event_data_offsets_rtc_irq_set_state {}; + +struct trace_event_data_offsets_rtc_alarm_irq_enable {}; + +struct trace_event_data_offsets_rtc_offset_class {}; + +struct trace_event_data_offsets_rtc_timer_class {}; + +typedef void (*btf_trace_rtc_set_time)(void *, time64_t, int); + +typedef void (*btf_trace_rtc_read_time)(void *, time64_t, int); + +typedef void (*btf_trace_rtc_set_alarm)(void *, time64_t, int); + +typedef void (*btf_trace_rtc_read_alarm)(void *, time64_t, int); + +typedef void (*btf_trace_rtc_irq_set_freq)(void *, int, int); + +typedef void (*btf_trace_rtc_irq_set_state)(void *, int, int); + +typedef void (*btf_trace_rtc_alarm_irq_enable)(void *, unsigned int, int); + +typedef void (*btf_trace_rtc_set_offset)(void *, long int, int); + +typedef void (*btf_trace_rtc_read_offset)(void *, long int, int); + +typedef void (*btf_trace_rtc_timer_enqueue)(void *, struct rtc_timer *); + +typedef void (*btf_trace_rtc_timer_dequeue)(void *, struct rtc_timer *); + +typedef void (*btf_trace_rtc_timer_fired)(void *, struct rtc_timer *); + +enum { + none = 0, + day = 1, + month = 2, + year = 3, +}; + +struct nvmem_cell_info { + const char *name; + unsigned int offset; + unsigned int bytes; + unsigned int bit_offset; + unsigned int nbits; +}; + +typedef int (*nvmem_reg_read_t)(void *, unsigned int, void *, size_t); + +typedef int (*nvmem_reg_write_t)(void *, unsigned int, void *, size_t); + +enum nvmem_type { + NVMEM_TYPE_UNKNOWN = 0, + NVMEM_TYPE_EEPROM = 1, + NVMEM_TYPE_OTP = 2, + NVMEM_TYPE_BATTERY_BACKED = 3, +}; + +struct nvmem_config { + struct device *dev; + const char *name; + int id; + struct module *owner; + struct gpio_desc___2 *wp_gpio; + const struct nvmem_cell_info *cells; + int ncells; + enum nvmem_type type; + bool read_only; + bool root_only; + bool no_of_node; + nvmem_reg_read_t reg_read; + nvmem_reg_write_t reg_write; + int size; + int word_size; + int stride; + void *priv; + bool compat; + struct device *base_dev; +}; + +struct nvmem_device; + +struct cmos_rtc_board_info { + void (*wake_on)(struct device *); + void (*wake_off)(struct device *); + u32 flags; + int address_space; + u8 rtc_day_alarm; + u8 rtc_mon_alarm; + u8 rtc_century; +}; + +struct cmos_rtc { + struct rtc_device *rtc; + struct device *dev; + int irq; + struct resource *iomem; + time64_t alarm_expires; + void (*wake_on)(struct device *); + void (*wake_off)(struct device *); + u8 enabled_wake; + u8 suspend_ctrl; + u8 day_alrm; + u8 mon_alrm; + u8 century; + struct rtc_wkalrm saved_wkalrm; +}; + +struct i2c_board_info { + char type[20]; + short unsigned int flags; + short unsigned int addr; + const char *dev_name; + void *platform_data; + struct device_node *of_node; + struct fwnode_handle *fwnode; + const struct property_entry *properties; + const struct resource *resources; + unsigned int num_resources; + int irq; +}; + +struct i2c_devinfo { + struct list_head list; + int busnum; + struct i2c_board_info board_info; +}; + +struct pps_ktime { + __s64 sec; + __s32 nsec; + __u32 flags; +}; + +struct pps_ktime_compat { + __s64 sec; + __s32 nsec; + __u32 flags; +}; + +struct pps_kinfo { + __u32 assert_sequence; + __u32 clear_sequence; + struct pps_ktime assert_tu; + struct pps_ktime clear_tu; + int current_mode; +}; + +struct pps_kinfo_compat { + __u32 assert_sequence; + __u32 clear_sequence; + struct pps_ktime_compat assert_tu; + struct pps_ktime_compat clear_tu; + int current_mode; +} __attribute__((packed)); + +struct pps_kparams { + int api_version; + int mode; + struct pps_ktime assert_off_tu; + struct pps_ktime clear_off_tu; +}; + +struct pps_fdata { + struct pps_kinfo info; + struct pps_ktime timeout; +}; + +struct pps_fdata_compat { + struct pps_kinfo_compat info; + struct pps_ktime_compat timeout; +} __attribute__((packed)); + +struct pps_bind_args { + int tsformat; + int edge; + int consumer; +}; + +struct pps_device; + +struct pps_source_info { + char name[32]; + char path[32]; + int mode; + void (*echo)(struct pps_device *, int, void *); + struct module *owner; + struct device *dev; +}; + +struct pps_device { + struct pps_source_info info; + struct pps_kparams params; + __u32 assert_sequence; + __u32 clear_sequence; + struct pps_ktime assert_tu; + struct pps_ktime clear_tu; + int current_mode; + unsigned int last_ev; + wait_queue_head_t queue; + unsigned int id; + const void *lookup_cookie; + struct cdev cdev; + struct device *dev; + struct fasync_struct *async_queue; + spinlock_t lock; +}; + +struct ptp_extts_event { + struct ptp_clock_time t; + unsigned int index; + unsigned int flags; + unsigned int rsv[2]; +}; + +struct timestamp_event_queue { + struct ptp_extts_event buf[128]; + int head; + int tail; + spinlock_t lock; +}; + +struct ptp_clock___2 { + struct posix_clock clock; + struct device dev; + struct ptp_clock_info *info; + dev_t devid; + int index; + struct pps_device *pps_source; + long int dialed_frequency; + struct timestamp_event_queue tsevq; + struct mutex tsevq_mux; + struct mutex pincfg_mux; + wait_queue_head_t tsev_wq; + int defunct; + struct device_attribute *pin_dev_attr; + struct attribute **pin_attr; + struct attribute_group pin_attr_group; + const struct attribute_group *pin_attr_groups[2]; + struct kthread_worker *kworker; + struct kthread_delayed_work aux_work; +}; + +struct ptp_clock_caps { + int max_adj; + int n_alarm; + int n_ext_ts; + int n_per_out; + int pps; + int n_pins; + int cross_timestamping; + int adjust_phase; + int rsv[12]; +}; + +struct ptp_sys_offset { + unsigned int n_samples; + unsigned int rsv[3]; + struct ptp_clock_time ts[51]; +}; + +struct ptp_sys_offset_extended { + unsigned int n_samples; + unsigned int rsv[3]; + struct ptp_clock_time ts[75]; +}; + +struct ptp_sys_offset_precise { + struct ptp_clock_time device; + struct ptp_clock_time sys_realtime; + struct ptp_clock_time sys_monoraw; + unsigned int rsv[4]; +}; + +enum led_brightness { + LED_OFF = 0, + LED_ON = 1, + LED_HALF = 127, + LED_FULL = 255, +}; + +struct led_hw_trigger_type { + int dummy; +}; + +struct led_pattern; + +struct led_trigger; + +struct led_classdev { + const char *name; + enum led_brightness brightness; + enum led_brightness max_brightness; + int flags; + long unsigned int work_flags; + void (*brightness_set)(struct led_classdev *, enum led_brightness); + int (*brightness_set_blocking)(struct led_classdev *, enum led_brightness); + enum led_brightness (*brightness_get)(struct led_classdev *); + int (*blink_set)(struct led_classdev *, long unsigned int *, long unsigned int *); + int (*pattern_set)(struct led_classdev *, struct led_pattern *, u32, int); + int (*pattern_clear)(struct led_classdev *); + struct device *dev; + const struct attribute_group **groups; + struct list_head node; + const char *default_trigger; + long unsigned int blink_delay_on; + long unsigned int blink_delay_off; + struct timer_list blink_timer; + int blink_brightness; + int new_blink_brightness; + void (*flash_resume)(struct led_classdev *); + struct work_struct set_brightness_work; + int delayed_set_value; + struct rw_semaphore trigger_lock; + struct led_trigger *trigger; + struct list_head trig_list; + void *trigger_data; + bool activated; + struct led_hw_trigger_type *trigger_type; + struct mutex led_access; +}; + +struct led_pattern { + u32 delta_t; + int brightness; +}; + +struct led_trigger { + const char *name; + int (*activate)(struct led_classdev *); + void (*deactivate)(struct led_classdev *); + struct led_hw_trigger_type *trigger_type; + rwlock_t leddev_list_lock; + struct list_head led_cdevs; + struct list_head next_trig; + const struct attribute_group **groups; +}; + +enum power_supply_property { + POWER_SUPPLY_PROP_STATUS = 0, + POWER_SUPPLY_PROP_CHARGE_TYPE = 1, + POWER_SUPPLY_PROP_HEALTH = 2, + POWER_SUPPLY_PROP_PRESENT = 3, + POWER_SUPPLY_PROP_ONLINE = 4, + POWER_SUPPLY_PROP_AUTHENTIC = 5, + POWER_SUPPLY_PROP_TECHNOLOGY = 6, + POWER_SUPPLY_PROP_CYCLE_COUNT = 7, + POWER_SUPPLY_PROP_VOLTAGE_MAX = 8, + POWER_SUPPLY_PROP_VOLTAGE_MIN = 9, + POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN = 10, + POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN = 11, + POWER_SUPPLY_PROP_VOLTAGE_NOW = 12, + POWER_SUPPLY_PROP_VOLTAGE_AVG = 13, + POWER_SUPPLY_PROP_VOLTAGE_OCV = 14, + POWER_SUPPLY_PROP_VOLTAGE_BOOT = 15, + POWER_SUPPLY_PROP_CURRENT_MAX = 16, + POWER_SUPPLY_PROP_CURRENT_NOW = 17, + POWER_SUPPLY_PROP_CURRENT_AVG = 18, + POWER_SUPPLY_PROP_CURRENT_BOOT = 19, + POWER_SUPPLY_PROP_POWER_NOW = 20, + POWER_SUPPLY_PROP_POWER_AVG = 21, + POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN = 22, + POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN = 23, + POWER_SUPPLY_PROP_CHARGE_FULL = 24, + POWER_SUPPLY_PROP_CHARGE_EMPTY = 25, + POWER_SUPPLY_PROP_CHARGE_NOW = 26, + POWER_SUPPLY_PROP_CHARGE_AVG = 27, + POWER_SUPPLY_PROP_CHARGE_COUNTER = 28, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT = 29, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX = 30, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE = 31, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX = 32, + POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT = 33, + POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX = 34, + POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD = 35, + POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD = 36, + POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT = 37, + POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT = 38, + POWER_SUPPLY_PROP_INPUT_POWER_LIMIT = 39, + POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN = 40, + POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN = 41, + POWER_SUPPLY_PROP_ENERGY_FULL = 42, + POWER_SUPPLY_PROP_ENERGY_EMPTY = 43, + POWER_SUPPLY_PROP_ENERGY_NOW = 44, + POWER_SUPPLY_PROP_ENERGY_AVG = 45, + POWER_SUPPLY_PROP_CAPACITY = 46, + POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN = 47, + POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX = 48, + POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN = 49, + POWER_SUPPLY_PROP_CAPACITY_LEVEL = 50, + POWER_SUPPLY_PROP_TEMP = 51, + POWER_SUPPLY_PROP_TEMP_MAX = 52, + POWER_SUPPLY_PROP_TEMP_MIN = 53, + POWER_SUPPLY_PROP_TEMP_ALERT_MIN = 54, + POWER_SUPPLY_PROP_TEMP_ALERT_MAX = 55, + POWER_SUPPLY_PROP_TEMP_AMBIENT = 56, + POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN = 57, + POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX = 58, + POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW = 59, + POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG = 60, + POWER_SUPPLY_PROP_TIME_TO_FULL_NOW = 61, + POWER_SUPPLY_PROP_TIME_TO_FULL_AVG = 62, + POWER_SUPPLY_PROP_TYPE = 63, + POWER_SUPPLY_PROP_USB_TYPE = 64, + POWER_SUPPLY_PROP_SCOPE = 65, + POWER_SUPPLY_PROP_PRECHARGE_CURRENT = 66, + POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT = 67, + POWER_SUPPLY_PROP_CALIBRATE = 68, + POWER_SUPPLY_PROP_MANUFACTURE_YEAR = 69, + POWER_SUPPLY_PROP_MANUFACTURE_MONTH = 70, + POWER_SUPPLY_PROP_MANUFACTURE_DAY = 71, + POWER_SUPPLY_PROP_MODEL_NAME = 72, + POWER_SUPPLY_PROP_MANUFACTURER = 73, + POWER_SUPPLY_PROP_SERIAL_NUMBER = 74, +}; + +enum power_supply_type { + POWER_SUPPLY_TYPE_UNKNOWN = 0, + POWER_SUPPLY_TYPE_BATTERY = 1, + POWER_SUPPLY_TYPE_UPS = 2, + POWER_SUPPLY_TYPE_MAINS = 3, + POWER_SUPPLY_TYPE_USB = 4, + POWER_SUPPLY_TYPE_USB_DCP = 5, + POWER_SUPPLY_TYPE_USB_CDP = 6, + POWER_SUPPLY_TYPE_USB_ACA = 7, + POWER_SUPPLY_TYPE_USB_TYPE_C = 8, + POWER_SUPPLY_TYPE_USB_PD = 9, + POWER_SUPPLY_TYPE_USB_PD_DRP = 10, + POWER_SUPPLY_TYPE_APPLE_BRICK_ID = 11, + POWER_SUPPLY_TYPE_WIRELESS = 12, +}; + +enum power_supply_usb_type { + POWER_SUPPLY_USB_TYPE_UNKNOWN = 0, + POWER_SUPPLY_USB_TYPE_SDP = 1, + POWER_SUPPLY_USB_TYPE_DCP = 2, + POWER_SUPPLY_USB_TYPE_CDP = 3, + POWER_SUPPLY_USB_TYPE_ACA = 4, + POWER_SUPPLY_USB_TYPE_C = 5, + POWER_SUPPLY_USB_TYPE_PD = 6, + POWER_SUPPLY_USB_TYPE_PD_DRP = 7, + POWER_SUPPLY_USB_TYPE_PD_PPS = 8, + POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID = 9, +}; + +enum power_supply_notifier_events { + PSY_EVENT_PROP_CHANGED = 0, +}; + +union power_supply_propval { + int intval; + const char *strval; +}; + +struct power_supply_config { + struct device_node *of_node; + struct fwnode_handle *fwnode; + void *drv_data; + const struct attribute_group **attr_grp; + char **supplied_to; + size_t num_supplicants; +}; + +struct power_supply; + +struct power_supply_desc { + const char *name; + enum power_supply_type type; + const enum power_supply_usb_type *usb_types; + size_t num_usb_types; + const enum power_supply_property *properties; + size_t num_properties; + int (*get_property)(struct power_supply *, enum power_supply_property, union power_supply_propval *); + int (*set_property)(struct power_supply *, enum power_supply_property, const union power_supply_propval *); + int (*property_is_writeable)(struct power_supply *, enum power_supply_property); + void (*external_power_changed)(struct power_supply *); + void (*set_charged)(struct power_supply *); + bool no_thermal; + int use_for_apm; +}; + +struct power_supply { + const struct power_supply_desc *desc; + char **supplied_to; + size_t num_supplicants; + char **supplied_from; + size_t num_supplies; + struct device_node *of_node; + void *drv_data; + struct device dev; + struct work_struct changed_work; + struct delayed_work deferred_register_work; + spinlock_t changed_lock; + bool changed; + bool initialized; + bool removing; + atomic_t use_cnt; + struct thermal_zone_device *tzd; + struct thermal_cooling_device *tcd; + struct led_trigger *charging_full_trig; + char *charging_full_trig_name; + struct led_trigger *charging_trig; + char *charging_trig_name; + struct led_trigger *full_trig; + char *full_trig_name; + struct led_trigger *online_trig; + char *online_trig_name; + struct led_trigger *charging_blink_full_solid_trig; + char *charging_blink_full_solid_trig_name; +}; + +struct power_supply_battery_ocv_table { + int ocv; + int capacity; +}; + +struct power_supply_resistance_temp_table { + int temp; + int resistance; +}; + +struct power_supply_battery_info { + int energy_full_design_uwh; + int charge_full_design_uah; + int voltage_min_design_uv; + int voltage_max_design_uv; + int tricklecharge_current_ua; + int precharge_current_ua; + int precharge_voltage_max_uv; + int charge_term_current_ua; + int charge_restart_voltage_uv; + int overvoltage_limit_uv; + int constant_charge_current_max_ua; + int constant_charge_voltage_max_uv; + int factory_internal_resistance_uohm; + int ocv_temp[20]; + int temp_ambient_alert_min; + int temp_ambient_alert_max; + int temp_alert_min; + int temp_alert_max; + int temp_min; + int temp_max; + struct power_supply_battery_ocv_table *ocv_table[20]; + int ocv_table_size[20]; + struct power_supply_resistance_temp_table *resist_table; + int resist_table_size; +}; + +struct psy_am_i_supplied_data { + struct power_supply *psy; + unsigned int count; +}; + +enum { + POWER_SUPPLY_STATUS_UNKNOWN = 0, + POWER_SUPPLY_STATUS_CHARGING = 1, + POWER_SUPPLY_STATUS_DISCHARGING = 2, + POWER_SUPPLY_STATUS_NOT_CHARGING = 3, + POWER_SUPPLY_STATUS_FULL = 4, +}; + +enum { + POWER_SUPPLY_CHARGE_TYPE_UNKNOWN = 0, + POWER_SUPPLY_CHARGE_TYPE_NONE = 1, + POWER_SUPPLY_CHARGE_TYPE_TRICKLE = 2, + POWER_SUPPLY_CHARGE_TYPE_FAST = 3, + POWER_SUPPLY_CHARGE_TYPE_STANDARD = 4, + POWER_SUPPLY_CHARGE_TYPE_ADAPTIVE = 5, + POWER_SUPPLY_CHARGE_TYPE_CUSTOM = 6, + POWER_SUPPLY_CHARGE_TYPE_LONGLIFE = 7, +}; + +enum { + POWER_SUPPLY_HEALTH_UNKNOWN = 0, + POWER_SUPPLY_HEALTH_GOOD = 1, + POWER_SUPPLY_HEALTH_OVERHEAT = 2, + POWER_SUPPLY_HEALTH_DEAD = 3, + POWER_SUPPLY_HEALTH_OVERVOLTAGE = 4, + POWER_SUPPLY_HEALTH_UNSPEC_FAILURE = 5, + POWER_SUPPLY_HEALTH_COLD = 6, + POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE = 7, + POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE = 8, + POWER_SUPPLY_HEALTH_OVERCURRENT = 9, + POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED = 10, + POWER_SUPPLY_HEALTH_WARM = 11, + POWER_SUPPLY_HEALTH_COOL = 12, + POWER_SUPPLY_HEALTH_HOT = 13, +}; + +enum { + POWER_SUPPLY_TECHNOLOGY_UNKNOWN = 0, + POWER_SUPPLY_TECHNOLOGY_NiMH = 1, + POWER_SUPPLY_TECHNOLOGY_LION = 2, + POWER_SUPPLY_TECHNOLOGY_LIPO = 3, + POWER_SUPPLY_TECHNOLOGY_LiFe = 4, + POWER_SUPPLY_TECHNOLOGY_NiCd = 5, + POWER_SUPPLY_TECHNOLOGY_LiMn = 6, +}; + +enum { + POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN = 0, + POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL = 1, + POWER_SUPPLY_CAPACITY_LEVEL_LOW = 2, + POWER_SUPPLY_CAPACITY_LEVEL_NORMAL = 3, + POWER_SUPPLY_CAPACITY_LEVEL_HIGH = 4, + POWER_SUPPLY_CAPACITY_LEVEL_FULL = 5, +}; + +enum { + POWER_SUPPLY_SCOPE_UNKNOWN = 0, + POWER_SUPPLY_SCOPE_SYSTEM = 1, + POWER_SUPPLY_SCOPE_DEVICE = 2, +}; + +struct power_supply_attr { + const char *prop_name; + char attr_name[31]; + struct device_attribute dev_attr; + const char * const *text_values; + int text_values_len; +}; + +enum hwmon_in_attributes { + hwmon_in_enable = 0, + hwmon_in_input = 1, + hwmon_in_min = 2, + hwmon_in_max = 3, + hwmon_in_lcrit = 4, + hwmon_in_crit = 5, + hwmon_in_average = 6, + hwmon_in_lowest = 7, + hwmon_in_highest = 8, + hwmon_in_reset_history = 9, + hwmon_in_label = 10, + hwmon_in_alarm = 11, + hwmon_in_min_alarm = 12, + hwmon_in_max_alarm = 13, + hwmon_in_lcrit_alarm = 14, + hwmon_in_crit_alarm = 15, + hwmon_in_rated_min = 16, + hwmon_in_rated_max = 17, +}; + +enum hwmon_curr_attributes { + hwmon_curr_enable = 0, + hwmon_curr_input = 1, + hwmon_curr_min = 2, + hwmon_curr_max = 3, + hwmon_curr_lcrit = 4, + hwmon_curr_crit = 5, + hwmon_curr_average = 6, + hwmon_curr_lowest = 7, + hwmon_curr_highest = 8, + hwmon_curr_reset_history = 9, + hwmon_curr_label = 10, + hwmon_curr_alarm = 11, + hwmon_curr_min_alarm = 12, + hwmon_curr_max_alarm = 13, + hwmon_curr_lcrit_alarm = 14, + hwmon_curr_crit_alarm = 15, + hwmon_curr_rated_min = 16, + hwmon_curr_rated_max = 17, +}; + +enum hwmon_energy_attributes { + hwmon_energy_enable = 0, + hwmon_energy_input = 1, + hwmon_energy_label = 2, +}; + +enum hwmon_humidity_attributes { + hwmon_humidity_enable = 0, + hwmon_humidity_input = 1, + hwmon_humidity_label = 2, + hwmon_humidity_min = 3, + hwmon_humidity_min_hyst = 4, + hwmon_humidity_max = 5, + hwmon_humidity_max_hyst = 6, + hwmon_humidity_alarm = 7, + hwmon_humidity_fault = 8, + hwmon_humidity_rated_min = 9, + hwmon_humidity_rated_max = 10, +}; + +enum hwmon_fan_attributes { + hwmon_fan_enable = 0, + hwmon_fan_input = 1, + hwmon_fan_label = 2, + hwmon_fan_min = 3, + hwmon_fan_max = 4, + hwmon_fan_div = 5, + hwmon_fan_pulses = 6, + hwmon_fan_target = 7, + hwmon_fan_alarm = 8, + hwmon_fan_min_alarm = 9, + hwmon_fan_max_alarm = 10, + hwmon_fan_fault = 11, +}; + +enum hwmon_pwm_attributes { + hwmon_pwm_input = 0, + hwmon_pwm_enable = 1, + hwmon_pwm_mode = 2, + hwmon_pwm_freq = 3, +}; + +enum hwmon_intrusion_attributes { + hwmon_intrusion_alarm = 0, + hwmon_intrusion_beep = 1, +}; + +struct trace_event_raw_hwmon_attr_class { + struct trace_entry ent; + int index; + u32 __data_loc_attr_name; + long int val; + char __data[0]; +}; + +struct trace_event_raw_hwmon_attr_show_string { + struct trace_entry ent; + int index; + u32 __data_loc_attr_name; + u32 __data_loc_label; + char __data[0]; +}; + +struct trace_event_data_offsets_hwmon_attr_class { + u32 attr_name; +}; + +struct trace_event_data_offsets_hwmon_attr_show_string { + u32 attr_name; + u32 label; +}; + +typedef void (*btf_trace_hwmon_attr_show)(void *, int, const char *, long int); + +typedef void (*btf_trace_hwmon_attr_store)(void *, int, const char *, long int); + +typedef void (*btf_trace_hwmon_attr_show_string)(void *, int, const char *, const char *); + +struct hwmon_device { + const char *name; + struct device dev; + const struct hwmon_chip_info *chip; + struct list_head tzdata; + struct attribute_group group; + const struct attribute_group **groups; +}; + +struct hwmon_device_attribute { + struct device_attribute dev_attr; + const struct hwmon_ops *ops; + enum hwmon_sensor_types type; + u32 attr; + int index; + char name[32]; +}; + +struct thermal_attr { + struct device_attribute attr; + char name[20]; +}; + +struct trace_event_raw_thermal_temperature { + struct trace_entry ent; + u32 __data_loc_thermal_zone; + int id; + int temp_prev; + int temp; + char __data[0]; +}; + +struct trace_event_raw_cdev_update { + struct trace_entry ent; + u32 __data_loc_type; + long unsigned int target; + char __data[0]; +}; + +struct trace_event_raw_thermal_zone_trip { + struct trace_entry ent; + u32 __data_loc_thermal_zone; + int id; + int trip; + enum thermal_trip_type trip_type; + char __data[0]; +}; + +struct trace_event_data_offsets_thermal_temperature { + u32 thermal_zone; +}; + +struct trace_event_data_offsets_cdev_update { + u32 type; +}; + +struct trace_event_data_offsets_thermal_zone_trip { + u32 thermal_zone; +}; + +typedef void (*btf_trace_thermal_temperature)(void *, struct thermal_zone_device *); + +typedef void (*btf_trace_cdev_update)(void *, struct thermal_cooling_device *, long unsigned int); + +typedef void (*btf_trace_thermal_zone_trip)(void *, struct thermal_zone_device *, int, enum thermal_trip_type); + +struct thermal_instance { + int id; + char name[20]; + struct thermal_zone_device *tz; + struct thermal_cooling_device *cdev; + int trip; + bool initialized; + long unsigned int upper; + long unsigned int lower; + long unsigned int target; + char attr_name[20]; + struct device_attribute attr; + char weight_attr_name[20]; + struct device_attribute weight_attr; + struct list_head tz_node; + struct list_head cdev_node; + unsigned int weight; +}; + +struct thermal_hwmon_device { + char type[20]; + struct device *device; + int count; + struct list_head tz_list; + struct list_head node; +}; + +struct thermal_hwmon_attr { + struct device_attribute attr; + char name[16]; +}; + +struct thermal_hwmon_temp { + struct list_head hwmon_node; + struct thermal_zone_device *tz; + struct thermal_hwmon_attr temp_input; + struct thermal_hwmon_attr temp_crit; +}; + +struct powerclamp_worker_data { + struct kthread_worker *worker; + struct kthread_work balancing_work; + struct kthread_delayed_work idle_injection_work; + unsigned int cpu; + unsigned int count; + unsigned int guard; + unsigned int window_size_now; + unsigned int target_ratio; + unsigned int duration_jiffies; + bool clamping; +}; + +struct powerclamp_calibration_data { + long unsigned int confidence; + long unsigned int steady_comp; + long unsigned int dynamic_comp; +}; + +struct pkg_cstate_info { + bool skip; + int msr_index; + int cstate_id; +}; + +struct watchdog_info { + __u32 options; + __u32 firmware_version; + __u8 identity[32]; +}; + +struct watchdog_device; + +struct watchdog_ops { + struct module *owner; + int (*start)(struct watchdog_device *); + int (*stop)(struct watchdog_device *); + int (*ping)(struct watchdog_device *); + unsigned int (*status)(struct watchdog_device *); + int (*set_timeout)(struct watchdog_device *, unsigned int); + int (*set_pretimeout)(struct watchdog_device *, unsigned int); + unsigned int (*get_timeleft)(struct watchdog_device *); + int (*restart)(struct watchdog_device *, long unsigned int, void *); + long int (*ioctl)(struct watchdog_device *, unsigned int, long unsigned int); +}; + +struct watchdog_governor; + +struct watchdog_core_data; + +struct watchdog_device { + int id; + struct device *parent; + const struct attribute_group **groups; + const struct watchdog_info *info; + const struct watchdog_ops *ops; + const struct watchdog_governor *gov; + unsigned int bootstatus; + unsigned int timeout; + unsigned int pretimeout; + unsigned int min_timeout; + unsigned int max_timeout; + unsigned int min_hw_heartbeat_ms; + unsigned int max_hw_heartbeat_ms; + struct notifier_block reboot_nb; + struct notifier_block restart_nb; + void *driver_data; + struct watchdog_core_data *wd_data; + long unsigned int status; + struct list_head deferred; +}; + +struct watchdog_governor { + const char name[20]; + void (*pretimeout)(struct watchdog_device *); +}; + +struct watchdog_core_data { + struct device dev; + struct cdev cdev; + struct watchdog_device *wdd; + struct mutex lock; + ktime_t last_keepalive; + ktime_t last_hw_keepalive; + ktime_t open_deadline; + struct hrtimer timer; + struct kthread_work work; + long unsigned int status; +}; + +struct mdp_device_descriptor_s { + __u32 number; + __u32 major; + __u32 minor; + __u32 raid_disk; + __u32 state; + __u32 reserved[27]; +}; + +typedef struct mdp_device_descriptor_s mdp_disk_t; + +struct mdp_superblock_s { + __u32 md_magic; + __u32 major_version; + __u32 minor_version; + __u32 patch_version; + __u32 gvalid_words; + __u32 set_uuid0; + __u32 ctime; + __u32 level; + __u32 size; + __u32 nr_disks; + __u32 raid_disks; + __u32 md_minor; + __u32 not_persistent; + __u32 set_uuid1; + __u32 set_uuid2; + __u32 set_uuid3; + __u32 gstate_creserved[16]; + __u32 utime; + __u32 state; + __u32 active_disks; + __u32 working_disks; + __u32 failed_disks; + __u32 spare_disks; + __u32 sb_csum; + __u32 events_lo; + __u32 events_hi; + __u32 cp_events_lo; + __u32 cp_events_hi; + __u32 recovery_cp; + __u64 reshape_position; + __u32 new_level; + __u32 delta_disks; + __u32 new_layout; + __u32 new_chunk; + __u32 gstate_sreserved[14]; + __u32 layout; + __u32 chunk_size; + __u32 root_pv; + __u32 root_block; + __u32 pstate_reserved[60]; + mdp_disk_t disks[27]; + __u32 reserved[0]; + mdp_disk_t this_disk; +}; + +typedef struct mdp_superblock_s mdp_super_t; + +struct mdp_superblock_1 { + __le32 magic; + __le32 major_version; + __le32 feature_map; + __le32 pad0; + __u8 set_uuid[16]; + char set_name[32]; + __le64 ctime; + __le32 level; + __le32 layout; + __le64 size; + __le32 chunksize; + __le32 raid_disks; + union { + __le32 bitmap_offset; + struct { + __le16 offset; + __le16 size; + } ppl; + }; + __le32 new_level; + __le64 reshape_position; + __le32 delta_disks; + __le32 new_layout; + __le32 new_chunk; + __le32 new_offset; + __le64 data_offset; + __le64 data_size; + __le64 super_offset; + union { + __le64 recovery_offset; + __le64 journal_tail; + }; + __le32 dev_number; + __le32 cnt_corrected_read; + __u8 device_uuid[16]; + __u8 devflags; + __u8 bblog_shift; + __le16 bblog_size; + __le32 bblog_offset; + __le64 utime; + __le64 events; + __le64 resync_offset; + __le32 sb_csum; + __le32 max_dev; + __u8 pad3[32]; + __le16 dev_roles[0]; +}; + +struct mdu_version_s { + int major; + int minor; + int patchlevel; +}; + +typedef struct mdu_version_s mdu_version_t; + +struct mdu_array_info_s { + int major_version; + int minor_version; + int patch_version; + unsigned int ctime; + int level; + int size; + int nr_disks; + int raid_disks; + int md_minor; + int not_persistent; + unsigned int utime; + int state; + int active_disks; + int working_disks; + int failed_disks; + int spare_disks; + int layout; + int chunk_size; +}; + +typedef struct mdu_array_info_s mdu_array_info_t; + +struct mdu_disk_info_s { + int number; + int major; + int minor; + int raid_disk; + int state; +}; + +typedef struct mdu_disk_info_s mdu_disk_info_t; + +struct mdu_bitmap_file_s { + char pathname[4096]; +}; + +typedef struct mdu_bitmap_file_s mdu_bitmap_file_t; + +struct mddev; + +struct md_rdev; + +struct md_cluster_operations { + int (*join)(struct mddev *, int); + int (*leave)(struct mddev *); + int (*slot_number)(struct mddev *); + int (*resync_info_update)(struct mddev *, sector_t, sector_t); + void (*resync_info_get)(struct mddev *, sector_t *, sector_t *); + int (*metadata_update_start)(struct mddev *); + int (*metadata_update_finish)(struct mddev *); + void (*metadata_update_cancel)(struct mddev *); + int (*resync_start)(struct mddev *); + int (*resync_finish)(struct mddev *); + int (*area_resyncing)(struct mddev *, int, sector_t, sector_t); + int (*add_new_disk)(struct mddev *, struct md_rdev *); + void (*add_new_disk_cancel)(struct mddev *); + int (*new_disk_ack)(struct mddev *, bool); + int (*remove_disk)(struct mddev *, struct md_rdev *); + void (*load_bitmaps)(struct mddev *, int); + int (*gather_bitmaps)(struct md_rdev *); + int (*resize_bitmaps)(struct mddev *, sector_t, sector_t); + int (*lock_all_bitmaps)(struct mddev *); + void (*unlock_all_bitmaps)(struct mddev *); + void (*update_size)(struct mddev *, sector_t); +}; + +struct md_cluster_info; + +struct md_personality; + +struct md_thread; + +struct bitmap; + +struct mddev { + void *private; + struct md_personality *pers; + dev_t unit; + int md_minor; + struct list_head disks; + long unsigned int flags; + long unsigned int sb_flags; + int suspended; + atomic_t active_io; + int ro; + int sysfs_active; + struct gendisk *gendisk; + struct kobject kobj; + int hold_active; + int major_version; + int minor_version; + int patch_version; + int persistent; + int external; + char metadata_type[17]; + int chunk_sectors; + time64_t ctime; + time64_t utime; + int level; + int layout; + char clevel[16]; + int raid_disks; + int max_disks; + sector_t dev_sectors; + sector_t array_sectors; + int external_size; + __u64 events; + int can_decrease_events; + char uuid[16]; + sector_t reshape_position; + int delta_disks; + int new_level; + int new_layout; + int new_chunk_sectors; + int reshape_backwards; + struct md_thread *thread; + struct md_thread *sync_thread; + char *last_sync_action; + sector_t curr_resync; + sector_t curr_resync_completed; + long unsigned int resync_mark; + sector_t resync_mark_cnt; + sector_t curr_mark_cnt; + sector_t resync_max_sectors; + atomic64_t resync_mismatches; + sector_t suspend_lo; + sector_t suspend_hi; + int sync_speed_min; + int sync_speed_max; + int parallel_resync; + int ok_start_degraded; + long unsigned int recovery; + int recovery_disabled; + int in_sync; + struct mutex open_mutex; + struct mutex reconfig_mutex; + atomic_t active; + atomic_t openers; + int changed; + int degraded; + atomic_t recovery_active; + wait_queue_head_t recovery_wait; + sector_t recovery_cp; + sector_t resync_min; + sector_t resync_max; + struct kernfs_node *sysfs_state; + struct kernfs_node *sysfs_action; + struct kernfs_node *sysfs_completed; + struct kernfs_node *sysfs_degraded; + struct kernfs_node *sysfs_level; + struct work_struct del_work; + spinlock_t lock; + wait_queue_head_t sb_wait; + atomic_t pending_writes; + unsigned int safemode; + unsigned int safemode_delay; + struct timer_list safemode_timer; + struct percpu_ref writes_pending; + int sync_checkers; + struct request_queue *queue; + struct bitmap *bitmap; + struct { + struct file *file; + loff_t offset; + long unsigned int space; + loff_t default_offset; + long unsigned int default_space; + struct mutex mutex; + long unsigned int chunksize; + long unsigned int daemon_sleep; + long unsigned int max_write_behind; + int external; + int nodes; + char cluster_name[64]; + } bitmap_info; + atomic_t max_corr_read_errors; + struct list_head all_mddevs; + struct attribute_group *to_remove; + struct bio_set bio_set; + struct bio_set sync_set; + mempool_t md_io_pool; + struct bio *flush_bio; + atomic_t flush_pending; + ktime_t start_flush; + ktime_t last_flush; + struct work_struct flush_work; + struct work_struct event_work; + mempool_t *serial_info_pool; + void (*sync_super)(struct mddev *, struct md_rdev *); + struct md_cluster_info *cluster_info; + unsigned int good_device_nr; + unsigned int noio_flag; + bool has_superblocks: 1; + bool fail_last_dev: 1; + bool serialize_policy: 1; +}; + +struct serial_in_rdev; + +struct md_rdev { + struct list_head same_set; + sector_t sectors; + struct mddev *mddev; + int last_events; + struct block_device *meta_bdev; + struct block_device *bdev; + struct page *sb_page; + struct page *bb_page; + int sb_loaded; + __u64 sb_events; + sector_t data_offset; + sector_t new_data_offset; + sector_t sb_start; + int sb_size; + int preferred_minor; + struct kobject kobj; + long unsigned int flags; + wait_queue_head_t blocked_wait; + int desc_nr; + int raid_disk; + int new_raid_disk; + int saved_raid_disk; + union { + sector_t recovery_offset; + sector_t journal_tail; + }; + atomic_t nr_pending; + atomic_t read_errors; + time64_t last_read_error; + atomic_t corrected_errors; + struct serial_in_rdev *serial; + struct work_struct del_work; + struct kernfs_node *sysfs_state; + struct kernfs_node *sysfs_unack_badblocks; + struct kernfs_node *sysfs_badblocks; + struct badblocks badblocks; + struct { + short int offset; + unsigned int size; + sector_t sector; + } ppl; +}; + +struct serial_in_rdev { + struct rb_root_cached serial_rb; + spinlock_t serial_lock; + wait_queue_head_t serial_io_wait; +}; + +enum flag_bits { + Faulty = 0, + In_sync = 1, + Bitmap_sync = 2, + WriteMostly = 3, + AutoDetected = 4, + Blocked = 5, + WriteErrorSeen = 6, + FaultRecorded = 7, + BlockedBadBlocks = 8, + WantReplacement = 9, + Replacement = 10, + Candidate = 11, + Journal = 12, + ClusterRemove = 13, + RemoveSynchronized = 14, + ExternalBbl = 15, + FailFast = 16, + LastDev = 17, + CollisionCheck = 18, +}; + +enum mddev_flags { + MD_ARRAY_FIRST_USE = 0, + MD_CLOSING = 1, + MD_JOURNAL_CLEAN = 2, + MD_HAS_JOURNAL = 3, + MD_CLUSTER_RESYNC_LOCKED = 4, + MD_FAILFAST_SUPPORTED = 5, + MD_HAS_PPL = 6, + MD_HAS_MULTIPLE_PPLS = 7, + MD_ALLOW_SB_UPDATE = 8, + MD_UPDATING_SB = 9, + MD_NOT_READY = 10, + MD_BROKEN = 11, +}; + +enum mddev_sb_flags { + MD_SB_CHANGE_DEVS = 0, + MD_SB_CHANGE_CLEAN = 1, + MD_SB_CHANGE_PENDING = 2, + MD_SB_NEED_REWRITE = 3, +}; + +struct md_personality { + char *name; + int level; + struct list_head list; + struct module *owner; + bool (*make_request)(struct mddev *, struct bio *); + int (*run)(struct mddev *); + int (*start)(struct mddev *); + void (*free)(struct mddev *, void *); + void (*status)(struct seq_file *, struct mddev *); + void (*error_handler)(struct mddev *, struct md_rdev *); + int (*hot_add_disk)(struct mddev *, struct md_rdev *); + int (*hot_remove_disk)(struct mddev *, struct md_rdev *); + int (*spare_active)(struct mddev *); + sector_t (*sync_request)(struct mddev *, sector_t, int *); + int (*resize)(struct mddev *, sector_t); + sector_t (*size)(struct mddev *, sector_t, int); + int (*check_reshape)(struct mddev *); + int (*start_reshape)(struct mddev *); + void (*finish_reshape)(struct mddev *); + void (*update_reshape_pos)(struct mddev *); + void (*quiesce)(struct mddev *, int); + void * (*takeover)(struct mddev *); + int (*change_consistency_policy)(struct mddev *, const char *); +}; + +struct md_thread { + void (*run)(struct md_thread *); + struct mddev *mddev; + wait_queue_head_t wqueue; + long unsigned int flags; + struct task_struct *tsk; + long unsigned int timeout; + void *private; +}; + +struct bitmap_page; + +struct bitmap_counts { + spinlock_t lock; + struct bitmap_page *bp; + long unsigned int pages; + long unsigned int missing_pages; + long unsigned int chunkshift; + long unsigned int chunks; +}; + +struct bitmap_storage { + struct file *file; + struct page *sb_page; + struct page **filemap; + long unsigned int *filemap_attr; + long unsigned int file_pages; + long unsigned int bytes; +}; + +struct bitmap { + struct bitmap_counts counts; + struct mddev *mddev; + __u64 events_cleared; + int need_sync; + struct bitmap_storage storage; + long unsigned int flags; + int allclean; + atomic_t behind_writes; + long unsigned int behind_writes_used; + long unsigned int daemon_lastrun; + long unsigned int last_end_sync; + atomic_t pending_writes; + wait_queue_head_t write_wait; + wait_queue_head_t overflow_wait; + wait_queue_head_t behind_wait; + struct kernfs_node *sysfs_can_clear; + int cluster_slot; +}; + +enum recovery_flags { + MD_RECOVERY_RUNNING = 0, + MD_RECOVERY_SYNC = 1, + MD_RECOVERY_RECOVER = 2, + MD_RECOVERY_INTR = 3, + MD_RECOVERY_DONE = 4, + MD_RECOVERY_NEEDED = 5, + MD_RECOVERY_REQUESTED = 6, + MD_RECOVERY_CHECK = 7, + MD_RECOVERY_RESHAPE = 8, + MD_RECOVERY_FROZEN = 9, + MD_RECOVERY_ERROR = 10, + MD_RECOVERY_WAIT = 11, + MD_RESYNCING_REMOTE = 12, +}; + +struct md_sysfs_entry { + struct attribute attr; + ssize_t (*show)(struct mddev *, char *); + ssize_t (*store)(struct mddev *, const char *, size_t); +}; + +struct bitmap_page { + char *map; + unsigned int hijacked: 1; + unsigned int pending: 1; + unsigned int count: 30; +}; + +struct md_io { + struct mddev *mddev; + bio_end_io_t *orig_bi_end_io; + void *orig_bi_private; + long unsigned int start_time; + struct hd_struct *part; +}; + +struct super_type { + char *name; + struct module *owner; + int (*load_super)(struct md_rdev *, struct md_rdev *, int); + int (*validate_super)(struct mddev *, struct md_rdev *); + void (*sync_super)(struct mddev *, struct md_rdev *); + long long unsigned int (*rdev_size_change)(struct md_rdev *, sector_t); + int (*allow_new_offset)(struct md_rdev *, long long unsigned int); +}; + +struct rdev_sysfs_entry { + struct attribute attr; + ssize_t (*show)(struct md_rdev *, char *); + ssize_t (*store)(struct md_rdev *, const char *, size_t); +}; + +enum array_state { + clear = 0, + inactive = 1, + suspended = 2, + readonly = 3, + read_auto = 4, + clean = 5, + active = 6, + write_pending = 7, + active_idle = 8, + broken = 9, + bad_word = 10, +}; + +struct detected_devices_node { + struct list_head list; + dev_t dev; +}; + +typedef __u16 bitmap_counter_t; + +enum bitmap_state { + BITMAP_STALE = 1, + BITMAP_WRITE_ERROR = 2, + BITMAP_HOSTENDIAN = 15, +}; + +struct bitmap_super_s { + __le32 magic; + __le32 version; + __u8 uuid[16]; + __le64 events; + __le64 events_cleared; + __le64 sync_size; + __le32 state; + __le32 chunksize; + __le32 daemon_sleep; + __le32 write_behind; + __le32 sectors_reserved; + __le32 nodes; + __u8 cluster_name[64]; + __u8 pad[120]; +}; + +typedef struct bitmap_super_s bitmap_super_t; + +enum bitmap_page_attr { + BITMAP_PAGE_DIRTY = 0, + BITMAP_PAGE_PENDING = 1, + BITMAP_PAGE_NEEDWRITE = 2, +}; + +struct md_setup_args { + int minor; + int partitioned; + int level; + int chunk; + char *device_names; +}; + +struct dm_kobject_holder { + struct kobject kobj; + struct completion completion; +}; + +struct cpufreq_policy_data { + struct cpufreq_cpuinfo cpuinfo; + struct cpufreq_frequency_table *freq_table; + unsigned int cpu; + unsigned int min; + unsigned int max; +}; + +struct freq_attr { + struct attribute attr; + ssize_t (*show)(struct cpufreq_policy *, char *); + ssize_t (*store)(struct cpufreq_policy *, const char *, size_t); +}; + +struct cpufreq_driver { + char name[16]; + u16 flags; + void *driver_data; + int (*init)(struct cpufreq_policy *); + int (*verify)(struct cpufreq_policy_data *); + int (*setpolicy)(struct cpufreq_policy *); + int (*target)(struct cpufreq_policy *, unsigned int, unsigned int); + int (*target_index)(struct cpufreq_policy *, unsigned int); + unsigned int (*fast_switch)(struct cpufreq_policy *, unsigned int); + unsigned int (*resolve_freq)(struct cpufreq_policy *, unsigned int); + unsigned int (*get_intermediate)(struct cpufreq_policy *, unsigned int); + int (*target_intermediate)(struct cpufreq_policy *, unsigned int); + unsigned int (*get)(unsigned int); + void (*update_limits)(unsigned int); + int (*bios_limit)(int, unsigned int *); + int (*online)(struct cpufreq_policy *); + int (*offline)(struct cpufreq_policy *); + int (*exit)(struct cpufreq_policy *); + void (*stop_cpu)(struct cpufreq_policy *); + int (*suspend)(struct cpufreq_policy *); + int (*resume)(struct cpufreq_policy *); + void (*ready)(struct cpufreq_policy *); + struct freq_attr **attr; + bool boost_enabled; + int (*set_boost)(struct cpufreq_policy *, int); +}; + +struct cpufreq_stats { + unsigned int total_trans; + long long unsigned int last_time; + unsigned int max_state; + unsigned int state_num; + unsigned int last_index; + u64 *time_in_state; + unsigned int *freq_table; + unsigned int *trans_table; + unsigned int reset_pending; + long long unsigned int reset_time; +}; + +enum { + OD_NORMAL_SAMPLE = 0, + OD_SUB_SAMPLE = 1, +}; + +struct dbs_data { + struct gov_attr_set attr_set; + void *tuners; + unsigned int ignore_nice_load; + unsigned int sampling_rate; + unsigned int sampling_down_factor; + unsigned int up_threshold; + unsigned int io_is_busy; +}; + +struct policy_dbs_info { + struct cpufreq_policy *policy; + struct mutex update_mutex; + u64 last_sample_time; + s64 sample_delay_ns; + atomic_t work_count; + struct irq_work irq_work; + struct work_struct work; + struct dbs_data *dbs_data; + struct list_head list; + unsigned int rate_mult; + unsigned int idle_periods; + bool is_shared; + bool work_in_progress; +}; + +struct dbs_governor { + struct cpufreq_governor gov; + struct kobj_type kobj_type; + struct dbs_data *gdbs_data; + unsigned int (*gov_dbs_update)(struct cpufreq_policy *); + struct policy_dbs_info * (*alloc)(); + void (*free)(struct policy_dbs_info *); + int (*init)(struct dbs_data *); + void (*exit)(struct dbs_data *); + void (*start)(struct cpufreq_policy *); +}; + +struct od_ops { + unsigned int (*powersave_bias_target)(struct cpufreq_policy *, unsigned int, unsigned int); +}; + +struct od_policy_dbs_info { + struct policy_dbs_info policy_dbs; + unsigned int freq_lo; + unsigned int freq_lo_delay_us; + unsigned int freq_hi_delay_us; + unsigned int sample_type: 1; +}; + +struct od_dbs_tuners { + unsigned int powersave_bias; +}; + +struct cs_policy_dbs_info { + struct policy_dbs_info policy_dbs; + unsigned int down_skip; + unsigned int requested_freq; +}; + +struct cs_dbs_tuners { + unsigned int down_threshold; + unsigned int freq_step; +}; + +struct cpu_dbs_info { + u64 prev_cpu_idle; + u64 prev_update_time; + u64 prev_cpu_nice; + unsigned int prev_load; + struct update_util_data update_util; + struct policy_dbs_info *policy_dbs; +}; + +enum { + UNDEFINED_CAPABLE = 0, + SYSTEM_INTEL_MSR_CAPABLE = 1, + SYSTEM_AMD_MSR_CAPABLE = 2, + SYSTEM_IO_CAPABLE = 3, +}; + +struct acpi_cpufreq_data { + unsigned int resume; + unsigned int cpu_feature; + unsigned int acpi_perf_cpu; + cpumask_var_t freqdomain_cpus; + void (*cpu_freq_write)(struct acpi_pct_register *, u32); + u32 (*cpu_freq_read)(struct acpi_pct_register *); +}; + +struct drv_cmd { + struct acpi_pct_register *reg; + u32 val; + union { + void (*write)(struct acpi_pct_register *, u32); + u32 (*read)(struct acpi_pct_register *); + } func; +}; + +struct powernow_k8_data { + unsigned int cpu; + u32 numps; + u32 batps; + u32 rvo; + u32 irt; + u32 vidmvs; + u32 vstable; + u32 plllock; + u32 exttype; + u32 currvid; + u32 currfid; + struct cpufreq_frequency_table *powernow_table; + struct acpi_processor_performance acpi_data; + struct cpumask *available_cores; +}; + +struct psb_s { + u8 signature[10]; + u8 tableversion; + u8 flags1; + u16 vstable; + u8 flags2; + u8 num_tables; + u32 cpuid; + u8 plllocktime; + u8 maxfid; + u8 maxvid; + u8 numps; +}; + +struct pst_s { + u8 fid; + u8 vid; +}; + +struct powernowk8_target_arg { + struct cpufreq_policy *pol; + unsigned int newstate; +}; + +struct init_on_cpu { + struct powernow_k8_data *data; + int rc; +}; + +enum acpi_preferred_pm_profiles { + PM_UNSPECIFIED = 0, + PM_DESKTOP = 1, + PM_MOBILE = 2, + PM_WORKSTATION = 3, + PM_ENTERPRISE_SERVER = 4, + PM_SOHO_SERVER = 5, + PM_APPLIANCE_PC = 6, + PM_PERFORMANCE_SERVER = 7, + PM_TABLET = 8, +}; + +struct sample { + int32_t core_avg_perf; + int32_t busy_scaled; + u64 aperf; + u64 mperf; + u64 tsc; + u64 time; +}; + +struct pstate_data { + int current_pstate; + int min_pstate; + int max_pstate; + int max_pstate_physical; + int scaling; + int turbo_pstate; + unsigned int max_freq; + unsigned int turbo_freq; +}; + +struct vid_data { + int min; + int max; + int turbo; + int32_t ratio; +}; + +struct global_params { + bool no_turbo; + bool turbo_disabled; + bool turbo_disabled_mf; + int max_perf_pct; + int min_perf_pct; +}; + +struct cpudata { + int cpu; + unsigned int policy; + struct update_util_data update_util; + bool update_util_set; + struct pstate_data pstate; + struct vid_data vid; + u64 last_update; + u64 last_sample_time; + u64 aperf_mperf_shift; + u64 prev_aperf; + u64 prev_mperf; + u64 prev_tsc; + u64 prev_cummulative_iowait; + struct sample sample; + int32_t min_perf_ratio; + int32_t max_perf_ratio; + struct acpi_processor_performance acpi_perf_data; + bool valid_pss_table; + unsigned int iowait_boost; + s16 epp_powersave; + s16 epp_policy; + s16 epp_default; + s16 epp_cached; + u64 hwp_req_cached; + u64 hwp_cap_cached; + u64 last_io_update; + unsigned int sched_flags; + u32 hwp_boost_min; + bool suspended; +}; + +struct pstate_funcs { + int (*get_max)(); + int (*get_max_physical)(); + int (*get_min)(); + int (*get_turbo)(); + int (*get_scaling)(); + int (*get_aperf_mperf_shift)(); + u64 (*get_val)(struct cpudata *, int); + void (*get_vid)(struct cpudata *); +}; + +enum { + PSS = 0, + PPC = 1, +}; + +struct cpuidle_governor { + char name[16]; + struct list_head governor_list; + unsigned int rating; + int (*enable)(struct cpuidle_driver *, struct cpuidle_device *); + void (*disable)(struct cpuidle_driver *, struct cpuidle_device *); + int (*select)(struct cpuidle_driver *, struct cpuidle_device *, bool *); + void (*reflect)(struct cpuidle_device *, int); +}; + +struct cpuidle_state_kobj { + struct cpuidle_state *state; + struct cpuidle_state_usage *state_usage; + struct completion kobj_unregister; + struct kobject kobj; + struct cpuidle_device *device; +}; + +struct cpuidle_device_kobj { + struct cpuidle_device *dev; + struct completion kobj_unregister; + struct kobject kobj; +}; + +struct cpuidle_attr { + struct attribute attr; + ssize_t (*show)(struct cpuidle_device *, char *); + ssize_t (*store)(struct cpuidle_device *, const char *, size_t); +}; + +struct cpuidle_state_attr { + struct attribute attr; + ssize_t (*show)(struct cpuidle_state *, struct cpuidle_state_usage *, char *); + ssize_t (*store)(struct cpuidle_state *, struct cpuidle_state_usage *, const char *, size_t); +}; + +struct ladder_device_state { + struct { + u32 promotion_count; + u32 demotion_count; + u64 promotion_time_ns; + u64 demotion_time_ns; + } threshold; + struct { + int promotion_count; + int demotion_count; + } stats; +}; + +struct ladder_device { + struct ladder_device_state states[10]; +}; + +struct menu_device { + int needs_update; + int tick_wakeup; + u64 next_timer_ns; + unsigned int bucket; + unsigned int correction_factor[12]; + unsigned int intervals[8]; + int interval_ptr; +}; + +struct led_init_data { + struct fwnode_handle *fwnode; + const char *default_label; + const char *devicename; + bool devname_mandatory; +}; + +struct led_properties { + u32 color; + bool color_present; + const char *function; + u32 func_enum; + bool func_enum_present; + const char *label; +}; + +enum dmi_entry_type { + DMI_ENTRY_BIOS = 0, + DMI_ENTRY_SYSTEM = 1, + DMI_ENTRY_BASEBOARD = 2, + DMI_ENTRY_CHASSIS = 3, + DMI_ENTRY_PROCESSOR = 4, + DMI_ENTRY_MEM_CONTROLLER = 5, + DMI_ENTRY_MEM_MODULE = 6, + DMI_ENTRY_CACHE = 7, + DMI_ENTRY_PORT_CONNECTOR = 8, + DMI_ENTRY_SYSTEM_SLOT = 9, + DMI_ENTRY_ONBOARD_DEVICE = 10, + DMI_ENTRY_OEMSTRINGS = 11, + DMI_ENTRY_SYSCONF = 12, + DMI_ENTRY_BIOS_LANG = 13, + DMI_ENTRY_GROUP_ASSOC = 14, + DMI_ENTRY_SYSTEM_EVENT_LOG = 15, + DMI_ENTRY_PHYS_MEM_ARRAY = 16, + DMI_ENTRY_MEM_DEVICE = 17, + DMI_ENTRY_32_MEM_ERROR = 18, + DMI_ENTRY_MEM_ARRAY_MAPPED_ADDR = 19, + DMI_ENTRY_MEM_DEV_MAPPED_ADDR = 20, + DMI_ENTRY_BUILTIN_POINTING_DEV = 21, + DMI_ENTRY_PORTABLE_BATTERY = 22, + DMI_ENTRY_SYSTEM_RESET = 23, + DMI_ENTRY_HW_SECURITY = 24, + DMI_ENTRY_SYSTEM_POWER_CONTROLS = 25, + DMI_ENTRY_VOLTAGE_PROBE = 26, + DMI_ENTRY_COOLING_DEV = 27, + DMI_ENTRY_TEMP_PROBE = 28, + DMI_ENTRY_ELECTRICAL_CURRENT_PROBE = 29, + DMI_ENTRY_OOB_REMOTE_ACCESS = 30, + DMI_ENTRY_BIS_ENTRY = 31, + DMI_ENTRY_SYSTEM_BOOT = 32, + DMI_ENTRY_MGMT_DEV = 33, + DMI_ENTRY_MGMT_DEV_COMPONENT = 34, + DMI_ENTRY_MGMT_DEV_THRES = 35, + DMI_ENTRY_MEM_CHANNEL = 36, + DMI_ENTRY_IPMI_DEV = 37, + DMI_ENTRY_SYS_POWER_SUPPLY = 38, + DMI_ENTRY_ADDITIONAL = 39, + DMI_ENTRY_ONBOARD_DEV_EXT = 40, + DMI_ENTRY_MGMT_CONTROLLER_HOST = 41, + DMI_ENTRY_INACTIVE = 126, + DMI_ENTRY_END_OF_TABLE = 127, +}; + +struct dmi_memdev_info { + const char *device; + const char *bank; + u64 size; + u16 handle; + u8 type; +}; + +struct dmi_device_attribute { + struct device_attribute dev_attr; + int field; +}; + +struct mafield { + const char *prefix; + int field; +}; + +struct firmware_map_entry { + u64 start; + u64 end; + const char *type; + struct list_head list; + struct kobject kobj; +}; + +struct memmap_attribute { + struct attribute attr; + ssize_t (*show)(struct firmware_map_entry *, char *); +}; + +typedef efi_status_t efi_query_variable_store_t(u32, long unsigned int, bool); + +typedef struct { + efi_guid_t guid; + u32 table; +} efi_config_table_32_t; + +typedef union { + struct { + efi_guid_t guid; + void *table; + }; + efi_config_table_32_t mixed_mode; +} efi_config_table_t; + +typedef struct { + u16 version; + u16 length; + u32 runtime_services_supported; +} efi_rt_properties_table_t; + +struct efivar_operations { + efi_get_variable_t *get_variable; + efi_get_next_variable_t *get_next_variable; + efi_set_variable_t *set_variable; + efi_set_variable_t *set_variable_nonblocking; + efi_query_variable_store_t *query_variable_store; +}; + +struct efivars { + struct kset *kset; + struct kobject *kobject; + const struct efivar_operations *ops; +}; + +struct linux_efi_random_seed { + u32 size; + u8 bits[0]; +}; + +struct linux_efi_memreserve { + int size; + atomic_t count; + phys_addr_t next; + struct { + phys_addr_t base; + phys_addr_t size; + } entry[0]; +}; + +struct efi_generic_dev_path { + u8 type; + u8 sub_type; + u16 length; +}; + +struct efi_variable { + efi_char16_t VariableName[512]; + efi_guid_t VendorGuid; + long unsigned int DataSize; + __u8 Data[1024]; + efi_status_t Status; + __u32 Attributes; +} __attribute__((packed)); + +struct efivar_entry { + struct efi_variable var; + struct list_head list; + struct kobject kobj; + bool scanning; + bool deleting; +}; + +struct variable_validate { + efi_guid_t vendor; + char *name; + bool (*validate)(efi_char16_t *, int, u8 *, long unsigned int); +}; + +typedef struct { + u32 version; + u32 num_entries; + u32 desc_size; + u32 reserved; + efi_memory_desc_t entry[0]; +} efi_memory_attributes_table_t; + +typedef int (*efi_memattr_perm_setter)(struct mm_struct *, efi_memory_desc_t *); + +typedef u64 efi_physical_addr_t; + +typedef struct { + u64 length; + u64 data; +} efi_capsule_block_desc_t; + +struct efi_system_resource_entry_v1 { + efi_guid_t fw_class; + u32 fw_type; + u32 fw_version; + u32 lowest_supported_fw_version; + u32 capsule_flags; + u32 last_attempt_version; + u32 last_attempt_status; +}; + +struct efi_system_resource_table { + u32 fw_resource_count; + u32 fw_resource_count_max; + u64 fw_resource_version; + u8 entries[0]; +}; + +struct esre_entry { + union { + struct efi_system_resource_entry_v1 *esre1; + } esre; + struct kobject kobj; + struct list_head list; +}; + +struct esre_attribute { + struct attribute attr; + ssize_t (*show)(struct esre_entry *, char *); + ssize_t (*store)(struct esre_entry *, const char *, size_t); +}; + +struct efi_runtime_map_entry { + efi_memory_desc_t md; + struct kobject kobj; +}; + +struct map_attribute { + struct attribute attr; + ssize_t (*show)(struct efi_runtime_map_entry *, char *); +}; + +struct dca_domain { + struct list_head node; + struct list_head dca_providers; + struct pci_bus *pci_rc; +}; + +struct hid_device_id { + __u16 bus; + __u16 group; + __u32 vendor; + __u32 product; + kernel_ulong_t driver_data; +}; + +struct hid_item { + unsigned int format; + __u8 size; + __u8 type; + __u8 tag; + union { + __u8 u8; + __s8 s8; + __u16 u16; + __s16 s16; + __u32 u32; + __s32 s32; + __u8 *longdata; + } data; +}; + +struct hid_global { + unsigned int usage_page; + __s32 logical_minimum; + __s32 logical_maximum; + __s32 physical_minimum; + __s32 physical_maximum; + __s32 unit_exponent; + unsigned int unit; + unsigned int report_id; + unsigned int report_size; + unsigned int report_count; +}; + +struct hid_local { + unsigned int usage[12288]; + u8 usage_size[12288]; + unsigned int collection_index[12288]; + unsigned int usage_index; + unsigned int usage_minimum; + unsigned int delimiter_depth; + unsigned int delimiter_branch; +}; + +struct hid_collection { + int parent_idx; + unsigned int type; + unsigned int usage; + unsigned int level; +}; + +struct hid_usage { + unsigned int hid; + unsigned int collection_index; + unsigned int usage_index; + __s8 resolution_multiplier; + __s8 wheel_factor; + __u16 code; + __u8 type; + __s8 hat_min; + __s8 hat_max; + __s8 hat_dir; + __s16 wheel_accumulated; +}; + +struct hid_report; + +struct hid_input; + +struct hid_field { + unsigned int physical; + unsigned int logical; + unsigned int application; + struct hid_usage *usage; + unsigned int maxusage; + unsigned int flags; + unsigned int report_offset; + unsigned int report_size; + unsigned int report_count; + unsigned int report_type; + __s32 *value; + __s32 logical_minimum; + __s32 logical_maximum; + __s32 physical_minimum; + __s32 physical_maximum; + __s32 unit_exponent; + unsigned int unit; + struct hid_report *report; + unsigned int index; + struct hid_input *hidinput; + __u16 dpad; +}; + +struct hid_device; + +struct hid_report { + struct list_head list; + struct list_head hidinput_list; + unsigned int id; + unsigned int type; + unsigned int application; + struct hid_field *field[256]; + unsigned int maxfield; + unsigned int size; + struct hid_device *device; +}; + +struct hid_input { + struct list_head list; + struct hid_report *report; + struct input_dev *input; + const char *name; + bool registered; + struct list_head reports; + unsigned int application; +}; + +enum hid_type { + HID_TYPE_OTHER = 0, + HID_TYPE_USBMOUSE = 1, + HID_TYPE_USBNONE = 2, +}; + +struct hid_report_enum { + unsigned int numbered; + struct list_head report_list; + struct hid_report *report_id_hash[256]; +}; + +struct hid_driver; + +struct hid_ll_driver; + +struct hid_device { + __u8 *dev_rdesc; + unsigned int dev_rsize; + __u8 *rdesc; + unsigned int rsize; + struct hid_collection *collection; + unsigned int collection_size; + unsigned int maxcollection; + unsigned int maxapplication; + __u16 bus; + __u16 group; + __u32 vendor; + __u32 product; + __u32 version; + enum hid_type type; + unsigned int country; + struct hid_report_enum report_enum[3]; + struct work_struct led_work; + struct semaphore driver_input_lock; + struct device dev; + struct hid_driver *driver; + struct hid_ll_driver *ll_driver; + struct mutex ll_open_lock; + unsigned int ll_open_count; + long unsigned int status; + unsigned int claimed; + unsigned int quirks; + bool io_started; + struct list_head inputs; + void *hiddev; + void *hidraw; + char name[128]; + char phys[64]; + char uniq[64]; + void *driver_data; + int (*ff_init)(struct hid_device *); + int (*hiddev_connect)(struct hid_device *, unsigned int); + void (*hiddev_disconnect)(struct hid_device *); + void (*hiddev_hid_event)(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); + void (*hiddev_report_event)(struct hid_device *, struct hid_report *); + short unsigned int debug; + struct dentry *debug_dir; + struct dentry *debug_rdesc; + struct dentry *debug_events; + struct list_head debug_list; + spinlock_t debug_list_lock; + wait_queue_head_t debug_wait; +}; + +struct hid_report_id; + +struct hid_usage_id; + +struct hid_driver { + char *name; + const struct hid_device_id *id_table; + struct list_head dyn_list; + spinlock_t dyn_lock; + bool (*match)(struct hid_device *, bool); + int (*probe)(struct hid_device *, const struct hid_device_id *); + void (*remove)(struct hid_device *); + const struct hid_report_id *report_table; + int (*raw_event)(struct hid_device *, struct hid_report *, u8 *, int); + const struct hid_usage_id *usage_table; + int (*event)(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); + void (*report)(struct hid_device *, struct hid_report *); + __u8 * (*report_fixup)(struct hid_device *, __u8 *, unsigned int *); + int (*input_mapping)(struct hid_device *, struct hid_input *, struct hid_field *, struct hid_usage *, long unsigned int **, int *); + int (*input_mapped)(struct hid_device *, struct hid_input *, struct hid_field *, struct hid_usage *, long unsigned int **, int *); + int (*input_configured)(struct hid_device *, struct hid_input *); + void (*feature_mapping)(struct hid_device *, struct hid_field *, struct hid_usage *); + int (*suspend)(struct hid_device *, pm_message_t); + int (*resume)(struct hid_device *); + int (*reset_resume)(struct hid_device *); + struct device_driver driver; +}; + +struct hid_ll_driver { + int (*start)(struct hid_device *); + void (*stop)(struct hid_device *); + int (*open)(struct hid_device *); + void (*close)(struct hid_device *); + int (*power)(struct hid_device *, int); + int (*parse)(struct hid_device *); + void (*request)(struct hid_device *, struct hid_report *, int); + int (*wait)(struct hid_device *); + int (*raw_request)(struct hid_device *, unsigned char, __u8 *, size_t, unsigned char, int); + int (*output_report)(struct hid_device *, __u8 *, size_t); + int (*idle)(struct hid_device *, int, int, int); +}; + +struct hid_parser { + struct hid_global global; + struct hid_global global_stack[4]; + unsigned int global_stack_ptr; + struct hid_local local; + unsigned int *collection_stack; + unsigned int collection_stack_ptr; + unsigned int collection_stack_size; + struct hid_device *device; + unsigned int scan_flags; +}; + +struct hid_report_id { + __u32 report_type; +}; + +struct hid_usage_id { + __u32 usage_hid; + __u32 usage_type; + __u32 usage_code; +}; + +struct hiddev { + int minor; + int exist; + int open; + struct mutex existancelock; + wait_queue_head_t wait; + struct hid_device *hid; + struct list_head list; + spinlock_t list_lock; + bool initialized; +}; + +struct hidraw { + unsigned int minor; + int exist; + int open; + wait_queue_head_t wait; + struct hid_device *hid; + struct device *dev; + spinlock_t list_lock; + struct list_head list; +}; + +struct hid_dynid { + struct list_head list; + struct hid_device_id id; +}; + +typedef bool (*hid_usage_cmp_t)(struct hid_usage *, unsigned int, unsigned int); + +struct quirks_list_struct { + struct hid_device_id hid_bl_item; + struct list_head node; +}; + +struct hid_debug_list { + struct { + union { + struct __kfifo kfifo; + char *type; + const char *const_type; + char (*rectype)[0]; + char *ptr; + const char *ptr_const; + }; + char buf[0]; + } hid_debug_fifo; + struct fasync_struct *fasync; + struct hid_device *hdev; + struct list_head node; + struct mutex read_mutex; +}; + +struct hid_usage_entry { + unsigned int page; + unsigned int usage; + const char *description; +}; + +struct a4tech_sc { + long unsigned int quirks; + unsigned int hw_wheel; + __s32 delayed_value; +}; + +struct apple_sc { + long unsigned int quirks; + unsigned int fn_on; + unsigned int fn_found; + long unsigned int pressed_numlock[12]; +}; + +struct apple_key_translation { + u16 from; + u16 to; + u8 flags; +}; + +struct lg_drv_data { + long unsigned int quirks; + void *device_props; +}; + +struct dev_type { + u16 idVendor; + u16 idProduct; + const short int *ff; +}; + +struct lg4ff_wheel_data { + const u32 product_id; + u16 combine; + u16 range; + const u16 min_range; + const u16 max_range; + u8 led_state; + struct led_classdev *led[5]; + const u32 alternate_modes; + const char * const real_tag; + const char * const real_name; + const u16 real_product_id; + void (*set_range)(struct hid_device *, u16); +}; + +struct lg4ff_device_entry { + spinlock_t report_lock; + struct hid_report *report; + struct lg4ff_wheel_data wdata; +}; + +struct lg4ff_wheel { + const u32 product_id; + const short int *ff_effects; + const u16 min_range; + const u16 max_range; + void (*set_range)(struct hid_device *, u16); +}; + +struct lg4ff_compat_mode_switch { + const u8 cmd_count; + const u8 cmd[0]; +}; + +struct lg4ff_wheel_ident_info { + const u32 modes; + const u16 mask; + const u16 result; + const u16 real_product_id; +}; + +struct lg4ff_multimode_wheel { + const u16 product_id; + const u32 alternate_modes; + const char *real_tag; + const char *real_name; +}; + +struct lg4ff_alternate_mode { + const u16 product_id; + const char *tag; + const char *name; +}; + +enum lg_g15_model { + LG_G15 = 0, + LG_G15_V2 = 1, + LG_G510 = 2, + LG_G510_USB_AUDIO = 3, +}; + +enum lg_g15_led_type { + LG_G15_KBD_BRIGHTNESS = 0, + LG_G15_LCD_BRIGHTNESS = 1, + LG_G15_BRIGHTNESS_MAX = 2, + LG_G15_MACRO_PRESET1 = 2, + LG_G15_MACRO_PRESET2 = 3, + LG_G15_MACRO_PRESET3 = 4, + LG_G15_MACRO_RECORD = 5, + LG_G15_LED_MAX = 6, +}; + +struct lg_g15_led { + struct led_classdev cdev; + enum led_brightness brightness; + enum lg_g15_led_type led; + u8 red; + u8 green; + u8 blue; +}; + +struct lg_g15_data { + u8 transfer_buf[20]; + struct mutex mutex; + struct work_struct work; + struct input_dev *input; + struct hid_device *hdev; + enum lg_g15_model model; + struct lg_g15_led leds[6]; + bool game_mode_enabled; +}; + +struct ms_data { + long unsigned int quirks; + struct hid_device *hdev; + struct work_struct ff_worker; + __u8 strong; + __u8 weak; + void *output_report_dmabuf; +}; + +enum { + MAGNITUDE_STRONG = 2, + MAGNITUDE_WEAK = 3, + MAGNITUDE_NUM = 4, +}; + +struct xb1s_ff_report { + __u8 report_id; + __u8 enable; + __u8 magnitude[4]; + __u8 duration_10ms; + __u8 start_delay_10ms; + __u8 loop_count; +}; + +struct ntrig_data { + __u16 x; + __u16 y; + __u16 w; + __u16 h; + __u16 id; + bool tipswitch; + bool confidence; + bool first_contact_touch; + bool reading_mt; + __u8 mt_footer[4]; + __u8 mt_foot_count; + __s8 act_state; + __s8 deactivate_slack; + __s8 activate_slack; + __u16 min_width; + __u16 min_height; + __u16 activation_width; + __u16 activation_height; + __u16 sensor_logical_width; + __u16 sensor_logical_height; + __u16 sensor_physical_width; + __u16 sensor_physical_height; +}; + +struct sixaxis_led { + u8 time_enabled; + u8 duty_length; + u8 enabled; + u8 duty_off; + u8 duty_on; +}; + +struct sixaxis_rumble { + u8 padding; + u8 right_duration; + u8 right_motor_on; + u8 left_duration; + u8 left_motor_force; +}; + +struct sixaxis_output_report { + u8 report_id; + struct sixaxis_rumble rumble; + u8 padding[4]; + u8 leds_bitmap; + struct sixaxis_led led[4]; + struct sixaxis_led _reserved; +}; + +union sixaxis_output_report_01 { + struct sixaxis_output_report data; + u8 buf[36]; +}; + +struct motion_output_report_02 { + u8 type; + u8 zero; + u8 r; + u8 g; + u8 b; + u8 zero2; + u8 rumble; +}; + +struct ds4_calibration_data { + int abs_code; + short int bias; + int sens_numer; + int sens_denom; +}; + +enum ds4_dongle_state { + DONGLE_DISCONNECTED = 0, + DONGLE_CALIBRATING = 1, + DONGLE_CONNECTED = 2, + DONGLE_DISABLED = 3, +}; + +enum sony_worker { + SONY_WORKER_STATE = 0, + SONY_WORKER_HOTPLUG = 1, +}; + +struct sony_sc { + spinlock_t lock; + struct list_head list_node; + struct hid_device *hdev; + struct input_dev *touchpad; + struct input_dev *sensor_dev; + struct led_classdev *leds[4]; + long unsigned int quirks; + struct work_struct hotplug_worker; + struct work_struct state_worker; + void (*send_output_report)(struct sony_sc *); + struct power_supply *battery; + struct power_supply_desc battery_desc; + int device_id; + unsigned int fw_version; + unsigned int hw_version; + u8 *output_report_dmabuf; + u8 mac_address[6]; + u8 hotplug_worker_initialized; + u8 state_worker_initialized; + u8 defer_initialization; + u8 cable_state; + u8 battery_charging; + u8 battery_capacity; + u8 led_state[4]; + u8 led_delay_on[4]; + u8 led_delay_off[4]; + u8 led_count; + bool timestamp_initialized; + u16 prev_timestamp; + unsigned int timestamp_us; + u8 ds4_bt_poll_interval; + enum ds4_dongle_state ds4_dongle_state; + struct ds4_calibration_data ds4_calib_data[6]; +}; + +struct tmff_device { + struct hid_report *report; + struct hid_field *ff_field; +}; + +struct zpff_device { + struct hid_report *report; +}; + +struct hid_control_fifo { + unsigned char dir; + struct hid_report *report; + char *raw_report; +}; + +struct hid_output_fifo { + struct hid_report *report; + char *raw_report; +}; + +struct hid_class_descriptor { + __u8 bDescriptorType; + __le16 wDescriptorLength; +} __attribute__((packed)); + +struct hid_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __le16 bcdHID; + __u8 bCountryCode; + __u8 bNumDescriptors; + struct hid_class_descriptor desc[1]; +} __attribute__((packed)); + +struct usbhid_device { + struct hid_device *hid; + struct usb_interface *intf; + int ifnum; + unsigned int bufsize; + struct urb *urbin; + char *inbuf; + dma_addr_t inbuf_dma; + struct urb *urbctrl; + struct usb_ctrlrequest *cr; + struct hid_control_fifo ctrl[256]; + unsigned char ctrlhead; + unsigned char ctrltail; + char *ctrlbuf; + dma_addr_t ctrlbuf_dma; + long unsigned int last_ctrl; + struct urb *urbout; + struct hid_output_fifo out[256]; + unsigned char outhead; + unsigned char outtail; + char *outbuf; + dma_addr_t outbuf_dma; + long unsigned int last_out; + struct mutex mutex; + spinlock_t lock; + long unsigned int iofl; + struct timer_list io_retry; + long unsigned int stop_retry; + unsigned int retry_delay; + struct work_struct reset_work; + wait_queue_head_t wait; +}; + +struct hiddev_event { + unsigned int hid; + int value; +}; + +struct hiddev_devinfo { + __u32 bustype; + __u32 busnum; + __u32 devnum; + __u32 ifnum; + __s16 vendor; + __s16 product; + __s16 version; + __u32 num_applications; +}; + +struct hiddev_collection_info { + __u32 index; + __u32 type; + __u32 usage; + __u32 level; +}; + +struct hiddev_report_info { + __u32 report_type; + __u32 report_id; + __u32 num_fields; +}; + +struct hiddev_field_info { + __u32 report_type; + __u32 report_id; + __u32 field_index; + __u32 maxusage; + __u32 flags; + __u32 physical; + __u32 logical; + __u32 application; + __s32 logical_minimum; + __s32 logical_maximum; + __s32 physical_minimum; + __s32 physical_maximum; + __u32 unit_exponent; + __u32 unit; +}; + +struct hiddev_usage_ref { + __u32 report_type; + __u32 report_id; + __u32 field_index; + __u32 usage_index; + __u32 usage_code; + __s32 value; +}; + +struct hiddev_usage_ref_multi { + struct hiddev_usage_ref uref; + __u32 num_values; + __s32 values[1024]; +}; + +struct hiddev_list { + struct hiddev_usage_ref buffer[2048]; + int head; + int tail; + unsigned int flags; + struct fasync_struct *fasync; + struct hiddev *hiddev; + struct list_head node; + struct mutex thread_lock; +}; + +struct pidff_usage { + struct hid_field *field; + s32 *value; +}; + +struct pidff_device { + struct hid_device *hid; + struct hid_report *reports[13]; + struct pidff_usage set_effect[7]; + struct pidff_usage set_envelope[5]; + struct pidff_usage set_condition[8]; + struct pidff_usage set_periodic[5]; + struct pidff_usage set_constant[2]; + struct pidff_usage set_ramp[3]; + struct pidff_usage device_gain[1]; + struct pidff_usage block_load[2]; + struct pidff_usage pool[3]; + struct pidff_usage effect_operation[2]; + struct pidff_usage block_free[1]; + struct hid_field *create_new_effect_type; + struct hid_field *set_effect_type; + struct hid_field *effect_direction; + struct hid_field *device_control; + struct hid_field *block_load_status; + struct hid_field *effect_operation_status; + int control_id[2]; + int type_id[11]; + int status_id[2]; + int operation_id[2]; + int pid_id[64]; +}; + +struct pmc_bit_map { + const char *name; + u32 bit_mask; +}; + +struct pmc_reg_map { + const struct pmc_bit_map *d3_sts_0; + const struct pmc_bit_map *d3_sts_1; + const struct pmc_bit_map *func_dis; + const struct pmc_bit_map *func_dis_2; + const struct pmc_bit_map *pss; +}; + +struct pmc_data { + const struct pmc_reg_map *map; + const struct pmc_clk *clks; +}; + +struct pmc_dev { + u32 base_addr; + void *regmap; + const struct pmc_reg_map *map; + struct dentry *dbgfs_dir; + bool init; +}; + +struct acpi_table_pcct { + struct acpi_table_header header; + u32 flags; + u64 reserved; +}; + +enum acpi_pcct_type { + ACPI_PCCT_TYPE_GENERIC_SUBSPACE = 0, + ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE = 1, + ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2 = 2, + ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE = 3, + ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE = 4, + ACPI_PCCT_TYPE_RESERVED = 5, +}; + +struct acpi_pcct_subspace { + struct acpi_subtable_header header; + u8 reserved[6]; + u64 base_address; + u64 length; + struct acpi_generic_address doorbell_register; + u64 preserve_mask; + u64 write_mask; + u32 latency; + u32 max_access_rate; + u16 min_turnaround_time; +} __attribute__((packed)); + +struct acpi_pcct_hw_reduced_type2 { + struct acpi_subtable_header header; + u32 platform_interrupt; + u8 flags; + u8 reserved; + u64 base_address; + u64 length; + struct acpi_generic_address doorbell_register; + u64 preserve_mask; + u64 write_mask; + u32 latency; + u32 max_access_rate; + u16 min_turnaround_time; + struct acpi_generic_address platform_ack_register; + u64 ack_preserve_mask; + u64 ack_write_mask; +} __attribute__((packed)); + +struct cper_sec_proc_arm { + u32 validation_bits; + u16 err_info_num; + u16 context_info_num; + u32 section_length; + u8 affinity_level; + u8 reserved[3]; + u64 mpidr; + u64 midr; + u32 running_state; + u32 psci_state; +}; + +enum hw_event_mc_err_type { + HW_EVENT_ERR_CORRECTED = 0, + HW_EVENT_ERR_UNCORRECTED = 1, + HW_EVENT_ERR_DEFERRED = 2, + HW_EVENT_ERR_FATAL = 3, + HW_EVENT_ERR_INFO = 4, +}; + +struct aer_header_log_regs { + unsigned int dw0; + unsigned int dw1; + unsigned int dw2; + unsigned int dw3; +}; + +struct trace_event_raw_mc_event { + struct trace_entry ent; + unsigned int error_type; + u32 __data_loc_msg; + u32 __data_loc_label; + u16 error_count; + u8 mc_index; + s8 top_layer; + s8 middle_layer; + s8 lower_layer; + long int address; + u8 grain_bits; + long int syndrome; + u32 __data_loc_driver_detail; + char __data[0]; +}; + +struct trace_event_raw_arm_event { + struct trace_entry ent; + u64 mpidr; + u64 midr; + u32 running_state; + u32 psci_state; + u8 affinity; + char __data[0]; +}; + +struct trace_event_raw_non_standard_event { + struct trace_entry ent; + char sec_type[16]; + char fru_id[16]; + u32 __data_loc_fru_text; + u8 sev; + u32 len; + u32 __data_loc_buf; + char __data[0]; +}; + +struct trace_event_raw_aer_event { + struct trace_entry ent; + u32 __data_loc_dev_name; + u32 status; + u8 severity; + u8 tlp_header_valid; + u32 tlp_header[4]; + char __data[0]; +}; + +struct trace_event_raw_memory_failure_event { + struct trace_entry ent; + long unsigned int pfn; + int type; + int result; + char __data[0]; +}; + +struct trace_event_data_offsets_mc_event { + u32 msg; + u32 label; + u32 driver_detail; +}; + +struct trace_event_data_offsets_arm_event {}; + +struct trace_event_data_offsets_non_standard_event { + u32 fru_text; + u32 buf; +}; + +struct trace_event_data_offsets_aer_event { + u32 dev_name; +}; + +struct trace_event_data_offsets_memory_failure_event {}; + +typedef void (*btf_trace_mc_event)(void *, const unsigned int, const char *, const char *, const int, const u8, const s8, const s8, const s8, long unsigned int, const u8, long unsigned int, const char *); + +typedef void (*btf_trace_arm_event)(void *, const struct cper_sec_proc_arm *); + +typedef void (*btf_trace_non_standard_event)(void *, const guid_t *, const guid_t *, const char *, const u8, const u8 *, const u32); + +typedef void (*btf_trace_aer_event)(void *, const char *, const u32, const u8, const u8, struct aer_header_log_regs *); + +typedef void (*btf_trace_memory_failure_event)(void *, long unsigned int, int, int); + +struct nvmem_cell_lookup { + const char *nvmem_name; + const char *cell_name; + const char *dev_id; + const char *con_id; + struct list_head node; +}; + +enum { + NVMEM_ADD = 1, + NVMEM_REMOVE = 2, + NVMEM_CELL_ADD = 3, + NVMEM_CELL_REMOVE = 4, +}; + +struct nvmem_cell_table { + const char *nvmem_name; + const struct nvmem_cell_info *cells; + size_t ncells; + struct list_head node; +}; + +struct nvmem_device___2 { + struct module *owner; + struct device dev; + int stride; + int word_size; + int id; + struct kref refcnt; + size_t size; + bool read_only; + bool root_only; + int flags; + enum nvmem_type type; + struct bin_attribute eeprom; + struct device *base_dev; + struct list_head cells; + nvmem_reg_read_t reg_read; + nvmem_reg_write_t reg_write; + struct gpio_desc___2 *wp_gpio; + void *priv; +}; + +struct nvmem_cell { + const char *name; + int offset; + int bytes; + int bit_offset; + int nbits; + struct device_node *np; + struct nvmem_device___2 *nvmem; + struct list_head node; +}; + +struct net_device_devres { + struct net_device *ndev; +}; + +struct __kernel_old_timespec { + __kernel_old_time_t tv_sec; + long int tv_nsec; +}; + +struct __kernel_sock_timeval { + __s64 tv_sec; + __s64 tv_usec; +}; + +struct mmsghdr { + struct user_msghdr msg_hdr; + unsigned int msg_len; +}; + +struct scm_timestamping_internal { + struct timespec64 ts[3]; +}; + +enum sock_shutdown_cmd { + SHUT_RD = 0, + SHUT_WR = 1, + SHUT_RDWR = 2, +}; + +struct ifconf { + int ifc_len; + union { + char *ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; +}; + +struct compat_ifmap { + compat_ulong_t mem_start; + compat_ulong_t mem_end; + short unsigned int base_addr; + unsigned char irq; + unsigned char dma; + unsigned char port; +}; + +struct compat_if_settings { + unsigned int type; + unsigned int size; + compat_uptr_t ifs_ifsu; +}; + +struct compat_ifreq { + union { + char ifrn_name[16]; + } ifr_ifrn; + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_dstaddr; + struct sockaddr ifru_broadaddr; + struct sockaddr ifru_netmask; + struct sockaddr ifru_hwaddr; + short int ifru_flags; + compat_int_t ifru_ivalue; + compat_int_t ifru_mtu; + struct compat_ifmap ifru_map; + char ifru_slave[16]; + char ifru_newname[16]; + compat_caddr_t ifru_data; + struct compat_if_settings ifru_settings; + } ifr_ifru; +}; + +struct compat_ifconf { + compat_int_t ifc_len; + compat_caddr_t ifcbuf; +}; + +struct compat_ethtool_rx_flow_spec { + u32 flow_type; + union ethtool_flow_union h_u; + struct ethtool_flow_ext h_ext; + union ethtool_flow_union m_u; + struct ethtool_flow_ext m_ext; + compat_u64 ring_cookie; + u32 location; +} __attribute__((packed)); + +struct compat_ethtool_rxnfc { + u32 cmd; + u32 flow_type; + compat_u64 data; + struct compat_ethtool_rx_flow_spec fs; + u32 rule_cnt; + u32 rule_locs[0]; +} __attribute__((packed)); + +struct compat_mmsghdr { + struct compat_msghdr msg_hdr; + compat_uint_t msg_len; +}; + +struct scm_ts_pktinfo { + __u32 if_index; + __u32 pkt_length; + __u32 reserved[2]; +}; + +struct sock_skb_cb { + u32 dropcount; +}; + +struct sock_ee_data_rfc4884 { + __u16 len; + __u8 flags; + __u8 reserved; +}; + +struct sock_extended_err { + __u32 ee_errno; + __u8 ee_origin; + __u8 ee_type; + __u8 ee_code; + __u8 ee_pad; + __u32 ee_info; + union { + __u32 ee_data; + struct sock_ee_data_rfc4884 ee_rfc4884; + }; +}; + +struct sock_exterr_skb { + union { + struct inet_skb_parm h4; + struct inet6_skb_parm h6; + } header; + struct sock_extended_err ee; + u16 addr_offset; + __be16 port; + u8 opt_stats: 1; + u8 unused: 7; +}; + +struct used_address { + struct __kernel_sockaddr_storage name; + unsigned int name_len; +}; + +struct linger { + int l_onoff; + int l_linger; +}; + +struct ucred { + __u32 pid; + __u32 uid; + __u32 gid; +}; + +struct prot_inuse { + int val[64]; +}; + +enum txtime_flags { + SOF_TXTIME_DEADLINE_MODE = 1, + SOF_TXTIME_REPORT_ERRORS = 2, + SOF_TXTIME_FLAGS_LAST = 2, + SOF_TXTIME_FLAGS_MASK = 3, +}; + +struct sock_txtime { + __kernel_clockid_t clockid; + __u32 flags; +}; + +enum sk_pacing { + SK_PACING_NONE = 0, + SK_PACING_NEEDED = 1, + SK_PACING_FQ = 2, +}; + +struct sockcm_cookie { + u64 transmit_time; + u32 mark; + u16 tsflags; +}; + +struct fastopen_queue { + struct request_sock *rskq_rst_head; + struct request_sock *rskq_rst_tail; + spinlock_t lock; + int qlen; + int max_qlen; + struct tcp_fastopen_context *ctx; +}; + +struct request_sock_queue { + spinlock_t rskq_lock; + u8 rskq_defer_accept; + u32 synflood_warned; + atomic_t qlen; + atomic_t young; + struct request_sock *rskq_accept_head; + struct request_sock *rskq_accept_tail; + struct fastopen_queue fastopenq; +}; + +struct inet_connection_sock_af_ops { + int (*queue_xmit)(struct sock *, struct sk_buff *, struct flowi *); + void (*send_check)(struct sock *, struct sk_buff *); + int (*rebuild_header)(struct sock *); + void (*sk_rx_dst_set)(struct sock *, const struct sk_buff *); + int (*conn_request)(struct sock *, struct sk_buff *); + struct sock * (*syn_recv_sock)(const struct sock *, struct sk_buff *, struct request_sock *, struct dst_entry *, struct request_sock *, bool *); + u16 net_header_len; + u16 net_frag_header_len; + u16 sockaddr_len; + int (*setsockopt)(struct sock *, int, int, sockptr_t, unsigned int); + int (*getsockopt)(struct sock *, int, int, char *, int *); + void (*addr2sockaddr)(struct sock *, struct sockaddr *); + void (*mtu_reduced)(struct sock *); +}; + +struct inet_bind_bucket; + +struct tcp_ulp_ops; + +struct inet_connection_sock { + struct inet_sock icsk_inet; + struct request_sock_queue icsk_accept_queue; + struct inet_bind_bucket *icsk_bind_hash; + long unsigned int icsk_timeout; + struct timer_list icsk_retransmit_timer; + struct timer_list icsk_delack_timer; + __u32 icsk_rto; + __u32 icsk_rto_min; + __u32 icsk_delack_max; + __u32 icsk_pmtu_cookie; + const struct tcp_congestion_ops *icsk_ca_ops; + const struct inet_connection_sock_af_ops *icsk_af_ops; + const struct tcp_ulp_ops *icsk_ulp_ops; + void *icsk_ulp_data; + void (*icsk_clean_acked)(struct sock *, u32); + struct hlist_node icsk_listen_portaddr_node; + unsigned int (*icsk_sync_mss)(struct sock *, u32); + __u8 icsk_ca_state: 5; + __u8 icsk_ca_initialized: 1; + __u8 icsk_ca_setsockopt: 1; + __u8 icsk_ca_dst_locked: 1; + __u8 icsk_retransmits; + __u8 icsk_pending; + __u8 icsk_backoff; + __u8 icsk_syn_retries; + __u8 icsk_probes_out; + __u16 icsk_ext_hdr_len; + struct { + __u8 pending; + __u8 quick; + __u8 pingpong; + __u8 retry; + __u32 ato; + long unsigned int timeout; + __u32 lrcvtime; + __u16 last_seg_size; + __u16 rcv_mss; + } icsk_ack; + struct { + int enabled; + int search_high; + int search_low; + int probe_size; + u32 probe_timestamp; + } icsk_mtup; + u32 icsk_user_timeout; + u64 icsk_ca_priv[13]; +}; + +struct inet_bind_bucket { + possible_net_t ib_net; + int l3mdev; + short unsigned int port; + signed char fastreuse; + signed char fastreuseport; + kuid_t fastuid; + struct in6_addr fast_v6_rcv_saddr; + __be32 fast_rcv_saddr; + short unsigned int fast_sk_family; + bool fast_ipv6_only; + struct hlist_node node; + struct hlist_head owners; +}; + +struct tcp_ulp_ops { + struct list_head list; + int (*init)(struct sock *); + void (*update)(struct sock *, struct proto *, void (*)(struct sock *)); + void (*release)(struct sock *); + int (*get_info)(const struct sock *, struct sk_buff *); + size_t (*get_info_size)(const struct sock *); + void (*clone)(const struct request_sock *, struct sock *, const gfp_t); + char name[16]; + struct module *owner; +}; + +struct tcp_fastopen_cookie { + __le64 val[2]; + s8 len; + bool exp; +}; + +struct tcp_sack_block { + u32 start_seq; + u32 end_seq; +}; + +struct tcp_options_received { + int ts_recent_stamp; + u32 ts_recent; + u32 rcv_tsval; + u32 rcv_tsecr; + u16 saw_tstamp: 1; + u16 tstamp_ok: 1; + u16 dsack: 1; + u16 wscale_ok: 1; + u16 sack_ok: 3; + u16 smc_ok: 1; + u16 snd_wscale: 4; + u16 rcv_wscale: 4; + u8 saw_unknown: 1; + u8 unused: 7; + u8 num_sacks; + u16 user_mss; + u16 mss_clamp; +}; + +struct tcp_rack { + u64 mstamp; + u32 rtt_us; + u32 end_seq; + u32 last_delivered; + u8 reo_wnd_steps; + u8 reo_wnd_persist: 5; + u8 dsack_seen: 1; + u8 advanced: 1; +}; + +struct tcp_sock_af_ops; + +struct tcp_md5sig_info; + +struct tcp_fastopen_request; + +struct tcp_sock { + struct inet_connection_sock inet_conn; + u16 tcp_header_len; + u16 gso_segs; + __be32 pred_flags; + u64 bytes_received; + u32 segs_in; + u32 data_segs_in; + u32 rcv_nxt; + u32 copied_seq; + u32 rcv_wup; + u32 snd_nxt; + u32 segs_out; + u32 data_segs_out; + u64 bytes_sent; + u64 bytes_acked; + u32 dsack_dups; + u32 snd_una; + u32 snd_sml; + u32 rcv_tstamp; + u32 lsndtime; + u32 last_oow_ack_time; + u32 compressed_ack_rcv_nxt; + u32 tsoffset; + struct list_head tsq_node; + struct list_head tsorted_sent_queue; + u32 snd_wl1; + u32 snd_wnd; + u32 max_window; + u32 mss_cache; + u32 window_clamp; + u32 rcv_ssthresh; + struct tcp_rack rack; + u16 advmss; + u8 compressed_ack; + u8 dup_ack_counter: 2; + u8 tlp_retrans: 1; + u8 unused: 5; + u32 chrono_start; + u32 chrono_stat[3]; + u8 chrono_type: 2; + u8 rate_app_limited: 1; + u8 fastopen_connect: 1; + u8 fastopen_no_cookie: 1; + u8 is_sack_reneg: 1; + u8 fastopen_client_fail: 2; + u8 nonagle: 4; + u8 thin_lto: 1; + u8 recvmsg_inq: 1; + u8 repair: 1; + u8 frto: 1; + u8 repair_queue; + u8 save_syn: 2; + u8 syn_data: 1; + u8 syn_fastopen: 1; + u8 syn_fastopen_exp: 1; + u8 syn_fastopen_ch: 1; + u8 syn_data_acked: 1; + u8 is_cwnd_limited: 1; + u32 tlp_high_seq; + u32 tcp_tx_delay; + u64 tcp_wstamp_ns; + u64 tcp_clock_cache; + u64 tcp_mstamp; + u32 srtt_us; + u32 mdev_us; + u32 mdev_max_us; + u32 rttvar_us; + u32 rtt_seq; + struct minmax rtt_min; + u32 packets_out; + u32 retrans_out; + u32 max_packets_out; + u32 max_packets_seq; + u16 urg_data; + u8 ecn_flags; + u8 keepalive_probes; + u32 reordering; + u32 reord_seen; + u32 snd_up; + struct tcp_options_received rx_opt; + u32 snd_ssthresh; + u32 snd_cwnd; + u32 snd_cwnd_cnt; + u32 snd_cwnd_clamp; + u32 snd_cwnd_used; + u32 snd_cwnd_stamp; + u32 prior_cwnd; + u32 prr_delivered; + u32 prr_out; + u32 delivered; + u32 delivered_ce; + u32 lost; + u32 app_limited; + u64 first_tx_mstamp; + u64 delivered_mstamp; + u32 rate_delivered; + u32 rate_interval_us; + u32 rcv_wnd; + u32 write_seq; + u32 notsent_lowat; + u32 pushed_seq; + u32 lost_out; + u32 sacked_out; + struct hrtimer pacing_timer; + struct hrtimer compressed_ack_timer; + struct sk_buff *lost_skb_hint; + struct sk_buff *retransmit_skb_hint; + struct rb_root out_of_order_queue; + struct sk_buff *ooo_last_skb; + struct tcp_sack_block duplicate_sack[1]; + struct tcp_sack_block selective_acks[4]; + struct tcp_sack_block recv_sack_cache[4]; + struct sk_buff *highest_sack; + int lost_cnt_hint; + u32 prior_ssthresh; + u32 high_seq; + u32 retrans_stamp; + u32 undo_marker; + int undo_retrans; + u64 bytes_retrans; + u32 total_retrans; + u32 urg_seq; + unsigned int keepalive_time; + unsigned int keepalive_intvl; + int linger2; + u8 bpf_sock_ops_cb_flags; + u16 timeout_rehash; + u32 rcv_ooopack; + u32 rcv_rtt_last_tsecr; + struct { + u32 rtt_us; + u32 seq; + u64 time; + } rcv_rtt_est; + struct { + u32 space; + u32 seq; + u64 time; + } rcvq_space; + struct { + u32 probe_seq_start; + u32 probe_seq_end; + } mtu_probe; + u32 mtu_info; + const struct tcp_sock_af_ops *af_specific; + struct tcp_md5sig_info *md5sig_info; + struct tcp_fastopen_request *fastopen_req; + struct request_sock *fastopen_rsk; + struct saved_syn *saved_syn; +}; + +struct tcp_md5sig_key; + +struct tcp_sock_af_ops { + struct tcp_md5sig_key * (*md5_lookup)(const struct sock *, const struct sock *); + int (*calc_md5_hash)(char *, const struct tcp_md5sig_key *, const struct sock *, const struct sk_buff *); + int (*md5_parse)(struct sock *, int, sockptr_t, int); +}; + +struct tcp_md5sig_info { + struct hlist_head head; + struct callback_head rcu; +}; + +struct tcp_fastopen_request { + struct tcp_fastopen_cookie cookie; + struct msghdr *data; + size_t size; + int copied; + struct ubuf_info *uarg; +}; + +union tcp_md5_addr { + struct in_addr a4; + struct in6_addr a6; +}; + +struct tcp_md5sig_key { + struct hlist_node node; + u8 keylen; + u8 family; + u8 prefixlen; + union tcp_md5_addr addr; + int l3index; + u8 key[80]; + struct callback_head rcu; +}; + +struct net_protocol { + int (*early_demux)(struct sk_buff *); + int (*early_demux_handler)(struct sk_buff *); + int (*handler)(struct sk_buff *); + int (*err_handler)(struct sk_buff *, u32); + unsigned int no_policy: 1; + unsigned int netns_ok: 1; + unsigned int icmp_strict_tag_validation: 1; +}; + +struct cgroup_cls_state { + struct cgroup_subsys_state css; + u32 classid; +}; + +enum { + SK_MEMINFO_RMEM_ALLOC = 0, + SK_MEMINFO_RCVBUF = 1, + SK_MEMINFO_WMEM_ALLOC = 2, + SK_MEMINFO_SNDBUF = 3, + SK_MEMINFO_FWD_ALLOC = 4, + SK_MEMINFO_WMEM_QUEUED = 5, + SK_MEMINFO_OPTMEM = 6, + SK_MEMINFO_BACKLOG = 7, + SK_MEMINFO_DROPS = 8, + SK_MEMINFO_VARS = 9, +}; + +enum sknetlink_groups { + SKNLGRP_NONE = 0, + SKNLGRP_INET_TCP_DESTROY = 1, + SKNLGRP_INET_UDP_DESTROY = 2, + SKNLGRP_INET6_TCP_DESTROY = 3, + SKNLGRP_INET6_UDP_DESTROY = 4, + __SKNLGRP_MAX = 5, +}; + +struct inet_request_sock { + struct request_sock req; + u16 snd_wscale: 4; + u16 rcv_wscale: 4; + u16 tstamp_ok: 1; + u16 sack_ok: 1; + u16 wscale_ok: 1; + u16 ecn_ok: 1; + u16 acked: 1; + u16 no_srccheck: 1; + u16 smc_ok: 1; + u32 ir_mark; + union { + struct ip_options_rcu *ireq_opt; + struct { + struct ipv6_txoptions *ipv6_opt; + struct sk_buff *pktopts; + }; + }; +}; + +struct tcp_request_sock_ops; + +struct tcp_request_sock { + struct inet_request_sock req; + const struct tcp_request_sock_ops *af_specific; + u64 snt_synack; + bool tfo_listener; + bool is_mptcp; + u32 txhash; + u32 rcv_isn; + u32 snt_isn; + u32 ts_off; + u32 last_oow_ack_time; + u32 rcv_nxt; + u8 syn_tos; +}; + +enum tcp_synack_type { + TCP_SYNACK_NORMAL = 0, + TCP_SYNACK_FASTOPEN = 1, + TCP_SYNACK_COOKIE = 2, +}; + +struct tcp_request_sock_ops { + u16 mss_clamp; + struct tcp_md5sig_key * (*req_md5_lookup)(const struct sock *, const struct sock *); + int (*calc_md5_hash)(char *, const struct tcp_md5sig_key *, const struct sock *, const struct sk_buff *); + void (*init_req)(struct request_sock *, const struct sock *, struct sk_buff *); + __u32 (*cookie_init_seq)(const struct sk_buff *, __u16 *); + struct dst_entry * (*route_req)(const struct sock *, struct flowi *, const struct request_sock *); + u32 (*init_seq)(const struct sk_buff *); + u32 (*init_ts_off)(const struct net *, const struct sk_buff *); + int (*send_synack)(const struct sock *, struct dst_entry *, struct flowi *, struct request_sock *, struct tcp_fastopen_cookie *, enum tcp_synack_type, struct sk_buff *); +}; + +enum { + SKB_FCLONE_UNAVAILABLE = 0, + SKB_FCLONE_ORIG = 1, + SKB_FCLONE_CLONE = 2, +}; + +struct sk_buff_fclones { + struct sk_buff skb1; + struct sk_buff skb2; + refcount_t fclone_ref; +}; + +struct skb_seq_state { + __u32 lower_offset; + __u32 upper_offset; + __u32 frag_idx; + __u32 stepped_offset; + struct sk_buff *root_skb; + struct sk_buff *cur_skb; + __u8 *frag_data; +}; + +struct skb_checksum_ops { + __wsum (*update)(const void *, int, __wsum); + __wsum (*combine)(__wsum, __wsum, int, int); +}; + +struct skb_gso_cb { + union { + int mac_offset; + int data_offset; + }; + int encap_level; + __wsum csum; + __u16 csum_start; +}; + +struct ip_auth_hdr { + __u8 nexthdr; + __u8 hdrlen; + __be16 reserved; + __be32 spi; + __be32 seq_no; + __u8 auth_data[0]; +}; + +struct frag_hdr { + __u8 nexthdr; + __u8 reserved; + __be16 frag_off; + __be32 identification; +}; + +enum { + SCM_TSTAMP_SND = 0, + SCM_TSTAMP_SCHED = 1, + SCM_TSTAMP_ACK = 2, +}; + +struct xfrm_offload { + struct { + __u32 low; + __u32 hi; + } seq; + __u32 flags; + __u32 status; + __u8 proto; +}; + +struct sec_path { + int len; + int olen; + struct xfrm_state *xvec[6]; + struct xfrm_offload ovec[1]; +}; + +struct mpls_shim_hdr { + __be32 label_stack_entry; +}; + +struct napi_alloc_cache { + struct page_frag_cache page; + unsigned int skb_count; + void *skb_cache[64]; +}; + +struct ahash_request___2; + +struct scm_cookie { + struct pid *pid; + struct scm_fp_list *fp; + struct scm_creds creds; + u32 secid; +}; + +struct scm_timestamping { + struct __kernel_old_timespec ts[3]; +}; + +struct scm_timestamping64 { + struct __kernel_timespec ts[3]; +}; + +enum { + TCA_STATS_UNSPEC = 0, + TCA_STATS_BASIC = 1, + TCA_STATS_RATE_EST = 2, + TCA_STATS_QUEUE = 3, + TCA_STATS_APP = 4, + TCA_STATS_RATE_EST64 = 5, + TCA_STATS_PAD = 6, + TCA_STATS_BASIC_HW = 7, + TCA_STATS_PKT64 = 8, + __TCA_STATS_MAX = 9, +}; + +struct gnet_stats_basic { + __u64 bytes; + __u32 packets; +}; + +struct gnet_stats_rate_est { + __u32 bps; + __u32 pps; +}; + +struct gnet_stats_rate_est64 { + __u64 bps; + __u64 pps; +}; + +struct gnet_estimator { + signed char interval; + unsigned char ewma_log; +}; + +struct net_rate_estimator___2 { + struct gnet_stats_basic_packed *bstats; + spinlock_t *stats_lock; + seqcount_t *running; + struct gnet_stats_basic_cpu *cpu_bstats; + u8 ewma_log; + u8 intvl_log; + seqcount_t seq; + u64 last_packets; + u64 last_bytes; + u64 avpps; + u64 avbps; + long unsigned int next_jiffies; + struct timer_list timer; + struct callback_head rcu; +}; + +struct rtgenmsg { + unsigned char rtgen_family; +}; + +enum { + NETNSA_NONE = 0, + NETNSA_NSID = 1, + NETNSA_PID = 2, + NETNSA_FD = 3, + NETNSA_TARGET_NSID = 4, + NETNSA_CURRENT_NSID = 5, + __NETNSA_MAX = 6, +}; + +struct pcpu_gen_cookie { + local_t nesting; + u64 last; +}; + +struct gen_cookie { + struct pcpu_gen_cookie *local; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + atomic64_t forward_last; + atomic64_t reverse_last; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +enum rtnl_link_flags { + RTNL_FLAG_DOIT_UNLOCKED = 1, +}; + +struct net_fill_args { + u32 portid; + u32 seq; + int flags; + int cmd; + int nsid; + bool add_ref; + int ref_nsid; +}; + +struct rtnl_net_dump_cb { + struct net *tgt_net; + struct net *ref_net; + struct sk_buff *skb; + struct net_fill_args fillargs; + int idx; + int s_idx; +}; + +enum flow_dissect_ret { + FLOW_DISSECT_RET_OUT_GOOD = 0, + FLOW_DISSECT_RET_OUT_BAD = 1, + FLOW_DISSECT_RET_PROTO_AGAIN = 2, + FLOW_DISSECT_RET_IPPROTO_AGAIN = 3, + FLOW_DISSECT_RET_CONTINUE = 4, +}; + +struct flow_dissector_key_tags { + u32 flow_label; +}; + +struct flow_dissector_key_vlan { + union { + struct { + u16 vlan_id: 12; + u16 vlan_dei: 1; + u16 vlan_priority: 3; + }; + __be16 vlan_tci; + }; + __be16 vlan_tpid; +}; + +struct flow_dissector_mpls_lse { + u32 mpls_ttl: 8; + u32 mpls_bos: 1; + u32 mpls_tc: 3; + u32 mpls_label: 20; +}; + +struct flow_dissector_key_mpls { + struct flow_dissector_mpls_lse ls[7]; + u8 used_lses; +}; + +struct flow_dissector_key_enc_opts { + u8 data[255]; + u8 len; + __be16 dst_opt_type; +}; + +struct flow_dissector_key_keyid { + __be32 keyid; +}; + +struct flow_dissector_key_ipv4_addrs { + __be32 src; + __be32 dst; +}; + +struct flow_dissector_key_ipv6_addrs { + struct in6_addr src; + struct in6_addr dst; +}; + +struct flow_dissector_key_tipc { + __be32 key; +}; + +struct flow_dissector_key_addrs { + union { + struct flow_dissector_key_ipv4_addrs v4addrs; + struct flow_dissector_key_ipv6_addrs v6addrs; + struct flow_dissector_key_tipc tipckey; + }; +}; + +struct flow_dissector_key_arp { + __u32 sip; + __u32 tip; + __u8 op; + unsigned char sha[6]; + unsigned char tha[6]; +}; + +struct flow_dissector_key_ports { + union { + __be32 ports; + struct { + __be16 src; + __be16 dst; + }; + }; +}; + +struct flow_dissector_key_icmp { + struct { + u8 type; + u8 code; + }; + u16 id; +}; + +struct flow_dissector_key_eth_addrs { + unsigned char dst[6]; + unsigned char src[6]; +}; + +struct flow_dissector_key_tcp { + __be16 flags; +}; + +struct flow_dissector_key_ip { + __u8 tos; + __u8 ttl; +}; + +struct flow_dissector_key_meta { + int ingress_ifindex; + u16 ingress_iftype; +}; + +struct flow_dissector_key_hash { + u32 hash; +}; + +struct flow_dissector_key { + enum flow_dissector_key_id key_id; + size_t offset; +}; + +struct flow_keys { + struct flow_dissector_key_control control; + struct flow_dissector_key_basic basic; + struct flow_dissector_key_tags tags; + struct flow_dissector_key_vlan vlan; + struct flow_dissector_key_vlan cvlan; + struct flow_dissector_key_keyid keyid; + struct flow_dissector_key_ports ports; + struct flow_dissector_key_icmp icmp; + struct flow_dissector_key_addrs addrs; + int: 32; +}; + +struct flow_keys_digest { + u8 data[16]; +}; + +enum bpf_ret_code { + BPF_OK = 0, + BPF_DROP = 2, + BPF_REDIRECT = 7, + BPF_LWT_REROUTE = 128, +}; + +enum { + BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = 1, + BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = 2, + BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = 4, +}; + +union tcp_word_hdr { + struct tcphdr hdr; + __be32 words[5]; +}; + +struct gre_base_hdr { + __be16 flags; + __be16 protocol; +}; + +struct gre_full_hdr { + struct gre_base_hdr fixed_header; + __be16 csum; + __be16 reserved1; + __be32 key; + __be32 seq; +}; + +struct pptp_gre_header { + struct gre_base_hdr gre_hd; + __be16 payload_len; + __be16 call_id; + __be32 seq; + __be32 ack; +}; + +struct tipc_basic_hdr { + __be32 w[4]; +}; + +struct icmphdr { + __u8 type; + __u8 code; + __sum16 checksum; + union { + struct { + __be16 id; + __be16 sequence; + } echo; + __be32 gateway; + struct { + __be16 __unused; + __be16 mtu; + } frag; + __u8 reserved[4]; + } un; +}; + +enum l2tp_debug_flags { + L2TP_MSG_DEBUG = 1, + L2TP_MSG_CONTROL = 2, + L2TP_MSG_SEQ = 4, + L2TP_MSG_DATA = 8, +}; + +struct pppoe_tag { + __be16 tag_type; + __be16 tag_len; + char tag_data[0]; +}; + +struct pppoe_hdr { + __u8 type: 4; + __u8 ver: 4; + __u8 code; + __be16 sid; + __be16 length; + struct pppoe_tag tag[0]; +}; + +struct mpls_label { + __be32 entry; +}; + +enum batadv_packettype { + BATADV_IV_OGM = 0, + BATADV_BCAST = 1, + BATADV_CODED = 2, + BATADV_ELP = 3, + BATADV_OGM2 = 4, + BATADV_UNICAST = 64, + BATADV_UNICAST_FRAG = 65, + BATADV_UNICAST_4ADDR = 66, + BATADV_ICMP = 67, + BATADV_UNICAST_TVLV = 68, +}; + +struct batadv_unicast_packet { + __u8 packet_type; + __u8 version; + __u8 ttl; + __u8 ttvn; + __u8 dest[6]; +}; + +struct _flow_keys_digest_data { + __be16 n_proto; + u8 ip_proto; + u8 padding; + __be32 ports; + __be32 src; + __be32 dst; +}; + +enum { + IF_OPER_UNKNOWN = 0, + IF_OPER_NOTPRESENT = 1, + IF_OPER_DOWN = 2, + IF_OPER_LOWERLAYERDOWN = 3, + IF_OPER_TESTING = 4, + IF_OPER_DORMANT = 5, + IF_OPER_UP = 6, +}; + +enum nf_dev_hooks { + NF_NETDEV_INGRESS = 0, + NF_NETDEV_NUMHOOKS = 1, +}; + +struct netdev_boot_setup { + char name[16]; + struct ifmap map; +}; + +enum gro_result { + GRO_MERGED = 0, + GRO_MERGED_FREE = 1, + GRO_HELD = 2, + GRO_NORMAL = 3, + GRO_DROP = 4, + GRO_CONSUMED = 5, +}; + +typedef enum gro_result gro_result_t; + +struct bpf_xdp_link { + struct bpf_link link; + struct net_device *dev; + int flags; +}; + +struct netdev_net_notifier { + struct list_head list; + struct notifier_block *nb; +}; + +struct packet_type { + __be16 type; + bool ignore_outgoing; + struct net_device *dev; + int (*func)(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); + void (*list_func)(struct list_head *, struct packet_type *, struct net_device *); + bool (*id_match)(struct packet_type *, struct sock *); + void *af_packet_priv; + struct list_head list; +}; + +struct offload_callbacks { + struct sk_buff * (*gso_segment)(struct sk_buff *, netdev_features_t); + struct sk_buff * (*gro_receive)(struct list_head *, struct sk_buff *); + int (*gro_complete)(struct sk_buff *, int); +}; + +struct packet_offload { + __be16 type; + u16 priority; + struct offload_callbacks callbacks; + struct list_head list; +}; + +struct netdev_notifier_info_ext { + struct netdev_notifier_info info; + union { + u32 mtu; + } ext; +}; + +struct netdev_notifier_change_info { + struct netdev_notifier_info info; + unsigned int flags_changed; +}; + +struct netdev_notifier_changeupper_info { + struct netdev_notifier_info info; + struct net_device *upper_dev; + bool master; + bool linking; + void *upper_info; +}; + +struct netdev_notifier_changelowerstate_info { + struct netdev_notifier_info info; + void *lower_state_info; +}; + +struct netdev_notifier_pre_changeaddr_info { + struct netdev_notifier_info info; + const unsigned char *dev_addr; +}; + +typedef int (*bpf_op_t)(struct net_device *, struct netdev_bpf *); + +enum { + NESTED_SYNC_IMM_BIT = 0, + NESTED_SYNC_TODO_BIT = 1, +}; + +enum qdisc_state_t { + __QDISC_STATE_SCHED = 0, + __QDISC_STATE_DEACTIVATED = 1, +}; + +enum { + IPV4_DEVCONF_FORWARDING = 1, + IPV4_DEVCONF_MC_FORWARDING = 2, + IPV4_DEVCONF_PROXY_ARP = 3, + IPV4_DEVCONF_ACCEPT_REDIRECTS = 4, + IPV4_DEVCONF_SECURE_REDIRECTS = 5, + IPV4_DEVCONF_SEND_REDIRECTS = 6, + IPV4_DEVCONF_SHARED_MEDIA = 7, + IPV4_DEVCONF_RP_FILTER = 8, + IPV4_DEVCONF_ACCEPT_SOURCE_ROUTE = 9, + IPV4_DEVCONF_BOOTP_RELAY = 10, + IPV4_DEVCONF_LOG_MARTIANS = 11, + IPV4_DEVCONF_TAG = 12, + IPV4_DEVCONF_ARPFILTER = 13, + IPV4_DEVCONF_MEDIUM_ID = 14, + IPV4_DEVCONF_NOXFRM = 15, + IPV4_DEVCONF_NOPOLICY = 16, + IPV4_DEVCONF_FORCE_IGMP_VERSION = 17, + IPV4_DEVCONF_ARP_ANNOUNCE = 18, + IPV4_DEVCONF_ARP_IGNORE = 19, + IPV4_DEVCONF_PROMOTE_SECONDARIES = 20, + IPV4_DEVCONF_ARP_ACCEPT = 21, + IPV4_DEVCONF_ARP_NOTIFY = 22, + IPV4_DEVCONF_ACCEPT_LOCAL = 23, + IPV4_DEVCONF_SRC_VMARK = 24, + IPV4_DEVCONF_PROXY_ARP_PVLAN = 25, + IPV4_DEVCONF_ROUTE_LOCALNET = 26, + IPV4_DEVCONF_IGMPV2_UNSOLICITED_REPORT_INTERVAL = 27, + IPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL = 28, + IPV4_DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN = 29, + IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST = 30, + IPV4_DEVCONF_DROP_GRATUITOUS_ARP = 31, + IPV4_DEVCONF_BC_FORWARDING = 32, + __IPV4_DEVCONF_MAX = 33, +}; + +struct dev_kfree_skb_cb { + enum skb_free_reason reason; +}; + +struct netdev_adjacent { + struct net_device *dev; + bool master; + bool ignore; + u16 ref_nr; + void *private; + struct list_head list; + struct callback_head rcu; +}; + +struct xfrm_dst { + union { + struct dst_entry dst; + struct rtable rt; + struct rt6_info rt6; + } u; + struct dst_entry *route; + struct dst_entry *child; + struct dst_entry *path; + struct xfrm_policy *pols[2]; + int num_pols; + int num_xfrms; + u32 xfrm_genid; + u32 policy_genid; + u32 route_mtu_cached; + u32 child_mtu_cached; + u32 route_cookie; + u32 path_cookie; +}; + +struct ndt_stats { + __u64 ndts_allocs; + __u64 ndts_destroys; + __u64 ndts_hash_grows; + __u64 ndts_res_failed; + __u64 ndts_lookups; + __u64 ndts_hits; + __u64 ndts_rcv_probes_mcast; + __u64 ndts_rcv_probes_ucast; + __u64 ndts_periodic_gc_runs; + __u64 ndts_forced_gc_runs; + __u64 ndts_table_fulls; +}; + +enum { + NDTPA_UNSPEC = 0, + NDTPA_IFINDEX = 1, + NDTPA_REFCNT = 2, + NDTPA_REACHABLE_TIME = 3, + NDTPA_BASE_REACHABLE_TIME = 4, + NDTPA_RETRANS_TIME = 5, + NDTPA_GC_STALETIME = 6, + NDTPA_DELAY_PROBE_TIME = 7, + NDTPA_QUEUE_LEN = 8, + NDTPA_APP_PROBES = 9, + NDTPA_UCAST_PROBES = 10, + NDTPA_MCAST_PROBES = 11, + NDTPA_ANYCAST_DELAY = 12, + NDTPA_PROXY_DELAY = 13, + NDTPA_PROXY_QLEN = 14, + NDTPA_LOCKTIME = 15, + NDTPA_QUEUE_LENBYTES = 16, + NDTPA_MCAST_REPROBES = 17, + NDTPA_PAD = 18, + __NDTPA_MAX = 19, +}; + +struct ndtmsg { + __u8 ndtm_family; + __u8 ndtm_pad1; + __u16 ndtm_pad2; +}; + +struct ndt_config { + __u16 ndtc_key_len; + __u16 ndtc_entry_size; + __u32 ndtc_entries; + __u32 ndtc_last_flush; + __u32 ndtc_last_rand; + __u32 ndtc_hash_rnd; + __u32 ndtc_hash_mask; + __u32 ndtc_hash_chain_gc; + __u32 ndtc_proxy_qlen; +}; + +enum { + NDTA_UNSPEC = 0, + NDTA_NAME = 1, + NDTA_THRESH1 = 2, + NDTA_THRESH2 = 3, + NDTA_THRESH3 = 4, + NDTA_CONFIG = 5, + NDTA_PARMS = 6, + NDTA_STATS = 7, + NDTA_GC_INTERVAL = 8, + NDTA_PAD = 9, + __NDTA_MAX = 10, +}; + +enum { + NEIGH_ARP_TABLE = 0, + NEIGH_ND_TABLE = 1, + NEIGH_DN_TABLE = 2, + NEIGH_NR_TABLES = 3, + NEIGH_LINK_TABLE = 3, +}; + +struct neigh_seq_state { + struct seq_net_private p; + struct neigh_table *tbl; + struct neigh_hash_table *nht; + void * (*neigh_sub_iter)(struct neigh_seq_state *, struct neighbour *, loff_t *); + unsigned int bucket; + unsigned int flags; +}; + +struct neighbour_cb { + long unsigned int sched_next; + unsigned int flags; +}; + +enum netevent_notif_type { + NETEVENT_NEIGH_UPDATE = 1, + NETEVENT_REDIRECT = 2, + NETEVENT_DELAY_PROBE_TIME_UPDATE = 3, + NETEVENT_IPV4_MPATH_HASH_UPDATE = 4, + NETEVENT_IPV6_MPATH_HASH_UPDATE = 5, + NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE = 6, +}; + +struct neigh_dump_filter { + int master_idx; + int dev_idx; +}; + +struct neigh_sysctl_table { + struct ctl_table_header *sysctl_header; + struct ctl_table neigh_vars[21]; +}; + +struct netlink_dump_control { + int (*start)(struct netlink_callback *); + int (*dump)(struct sk_buff *, struct netlink_callback *); + int (*done)(struct netlink_callback *); + void *data; + struct module *module; + u32 min_dump_alloc; +}; + +struct rtnl_link_stats { + __u32 rx_packets; + __u32 tx_packets; + __u32 rx_bytes; + __u32 tx_bytes; + __u32 rx_errors; + __u32 tx_errors; + __u32 rx_dropped; + __u32 tx_dropped; + __u32 multicast; + __u32 collisions; + __u32 rx_length_errors; + __u32 rx_over_errors; + __u32 rx_crc_errors; + __u32 rx_frame_errors; + __u32 rx_fifo_errors; + __u32 rx_missed_errors; + __u32 tx_aborted_errors; + __u32 tx_carrier_errors; + __u32 tx_fifo_errors; + __u32 tx_heartbeat_errors; + __u32 tx_window_errors; + __u32 rx_compressed; + __u32 tx_compressed; + __u32 rx_nohandler; +}; + +struct rtnl_link_ifmap { + __u64 mem_start; + __u64 mem_end; + __u64 base_addr; + __u16 irq; + __u8 dma; + __u8 port; +}; + +enum { + IFLA_PROTO_DOWN_REASON_UNSPEC = 0, + IFLA_PROTO_DOWN_REASON_MASK = 1, + IFLA_PROTO_DOWN_REASON_VALUE = 2, + __IFLA_PROTO_DOWN_REASON_CNT = 3, + IFLA_PROTO_DOWN_REASON_MAX = 2, +}; + +enum { + IFLA_BRPORT_UNSPEC = 0, + IFLA_BRPORT_STATE = 1, + IFLA_BRPORT_PRIORITY = 2, + IFLA_BRPORT_COST = 3, + IFLA_BRPORT_MODE = 4, + IFLA_BRPORT_GUARD = 5, + IFLA_BRPORT_PROTECT = 6, + IFLA_BRPORT_FAST_LEAVE = 7, + IFLA_BRPORT_LEARNING = 8, + IFLA_BRPORT_UNICAST_FLOOD = 9, + IFLA_BRPORT_PROXYARP = 10, + IFLA_BRPORT_LEARNING_SYNC = 11, + IFLA_BRPORT_PROXYARP_WIFI = 12, + IFLA_BRPORT_ROOT_ID = 13, + IFLA_BRPORT_BRIDGE_ID = 14, + IFLA_BRPORT_DESIGNATED_PORT = 15, + IFLA_BRPORT_DESIGNATED_COST = 16, + IFLA_BRPORT_ID = 17, + IFLA_BRPORT_NO = 18, + IFLA_BRPORT_TOPOLOGY_CHANGE_ACK = 19, + IFLA_BRPORT_CONFIG_PENDING = 20, + IFLA_BRPORT_MESSAGE_AGE_TIMER = 21, + IFLA_BRPORT_FORWARD_DELAY_TIMER = 22, + IFLA_BRPORT_HOLD_TIMER = 23, + IFLA_BRPORT_FLUSH = 24, + IFLA_BRPORT_MULTICAST_ROUTER = 25, + IFLA_BRPORT_PAD = 26, + IFLA_BRPORT_MCAST_FLOOD = 27, + IFLA_BRPORT_MCAST_TO_UCAST = 28, + IFLA_BRPORT_VLAN_TUNNEL = 29, + IFLA_BRPORT_BCAST_FLOOD = 30, + IFLA_BRPORT_GROUP_FWD_MASK = 31, + IFLA_BRPORT_NEIGH_SUPPRESS = 32, + IFLA_BRPORT_ISOLATED = 33, + IFLA_BRPORT_BACKUP_PORT = 34, + IFLA_BRPORT_MRP_RING_OPEN = 35, + IFLA_BRPORT_MRP_IN_OPEN = 36, + __IFLA_BRPORT_MAX = 37, +}; + +enum { + IFLA_INFO_UNSPEC = 0, + IFLA_INFO_KIND = 1, + IFLA_INFO_DATA = 2, + IFLA_INFO_XSTATS = 3, + IFLA_INFO_SLAVE_KIND = 4, + IFLA_INFO_SLAVE_DATA = 5, + __IFLA_INFO_MAX = 6, +}; + +enum { + IFLA_VF_INFO_UNSPEC = 0, + IFLA_VF_INFO = 1, + __IFLA_VF_INFO_MAX = 2, +}; + +enum { + IFLA_VF_UNSPEC = 0, + IFLA_VF_MAC = 1, + IFLA_VF_VLAN = 2, + IFLA_VF_TX_RATE = 3, + IFLA_VF_SPOOFCHK = 4, + IFLA_VF_LINK_STATE = 5, + IFLA_VF_RATE = 6, + IFLA_VF_RSS_QUERY_EN = 7, + IFLA_VF_STATS = 8, + IFLA_VF_TRUST = 9, + IFLA_VF_IB_NODE_GUID = 10, + IFLA_VF_IB_PORT_GUID = 11, + IFLA_VF_VLAN_LIST = 12, + IFLA_VF_BROADCAST = 13, + __IFLA_VF_MAX = 14, +}; + +struct ifla_vf_mac { + __u32 vf; + __u8 mac[32]; +}; + +struct ifla_vf_broadcast { + __u8 broadcast[32]; +}; + +struct ifla_vf_vlan { + __u32 vf; + __u32 vlan; + __u32 qos; +}; + +enum { + IFLA_VF_VLAN_INFO_UNSPEC = 0, + IFLA_VF_VLAN_INFO = 1, + __IFLA_VF_VLAN_INFO_MAX = 2, +}; + +struct ifla_vf_vlan_info { + __u32 vf; + __u32 vlan; + __u32 qos; + __be16 vlan_proto; +}; + +struct ifla_vf_tx_rate { + __u32 vf; + __u32 rate; +}; + +struct ifla_vf_rate { + __u32 vf; + __u32 min_tx_rate; + __u32 max_tx_rate; +}; + +struct ifla_vf_spoofchk { + __u32 vf; + __u32 setting; +}; + +struct ifla_vf_link_state { + __u32 vf; + __u32 link_state; +}; + +struct ifla_vf_rss_query_en { + __u32 vf; + __u32 setting; +}; + +enum { + IFLA_VF_STATS_RX_PACKETS = 0, + IFLA_VF_STATS_TX_PACKETS = 1, + IFLA_VF_STATS_RX_BYTES = 2, + IFLA_VF_STATS_TX_BYTES = 3, + IFLA_VF_STATS_BROADCAST = 4, + IFLA_VF_STATS_MULTICAST = 5, + IFLA_VF_STATS_PAD = 6, + IFLA_VF_STATS_RX_DROPPED = 7, + IFLA_VF_STATS_TX_DROPPED = 8, + __IFLA_VF_STATS_MAX = 9, +}; + +struct ifla_vf_trust { + __u32 vf; + __u32 setting; +}; + +enum { + IFLA_VF_PORT_UNSPEC = 0, + IFLA_VF_PORT = 1, + __IFLA_VF_PORT_MAX = 2, +}; + +enum { + IFLA_PORT_UNSPEC = 0, + IFLA_PORT_VF = 1, + IFLA_PORT_PROFILE = 2, + IFLA_PORT_VSI_TYPE = 3, + IFLA_PORT_INSTANCE_UUID = 4, + IFLA_PORT_HOST_UUID = 5, + IFLA_PORT_REQUEST = 6, + IFLA_PORT_RESPONSE = 7, + __IFLA_PORT_MAX = 8, +}; + +struct if_stats_msg { + __u8 family; + __u8 pad1; + __u16 pad2; + __u32 ifindex; + __u32 filter_mask; +}; + +enum { + IFLA_STATS_UNSPEC = 0, + IFLA_STATS_LINK_64 = 1, + IFLA_STATS_LINK_XSTATS = 2, + IFLA_STATS_LINK_XSTATS_SLAVE = 3, + IFLA_STATS_LINK_OFFLOAD_XSTATS = 4, + IFLA_STATS_AF_SPEC = 5, + __IFLA_STATS_MAX = 6, +}; + +enum { + XDP_ATTACHED_NONE = 0, + XDP_ATTACHED_DRV = 1, + XDP_ATTACHED_SKB = 2, + XDP_ATTACHED_HW = 3, + XDP_ATTACHED_MULTI = 4, +}; + +enum { + IFLA_XDP_UNSPEC = 0, + IFLA_XDP_FD = 1, + IFLA_XDP_ATTACHED = 2, + IFLA_XDP_FLAGS = 3, + IFLA_XDP_PROG_ID = 4, + IFLA_XDP_DRV_PROG_ID = 5, + IFLA_XDP_SKB_PROG_ID = 6, + IFLA_XDP_HW_PROG_ID = 7, + IFLA_XDP_EXPECTED_FD = 8, + __IFLA_XDP_MAX = 9, +}; + +enum { + IFLA_EVENT_NONE = 0, + IFLA_EVENT_REBOOT = 1, + IFLA_EVENT_FEATURES = 2, + IFLA_EVENT_BONDING_FAILOVER = 3, + IFLA_EVENT_NOTIFY_PEERS = 4, + IFLA_EVENT_IGMP_RESEND = 5, + IFLA_EVENT_BONDING_OPTIONS = 6, +}; + +enum rtattr_type_t { + RTA_UNSPEC = 0, + RTA_DST = 1, + RTA_SRC = 2, + RTA_IIF = 3, + RTA_OIF = 4, + RTA_GATEWAY = 5, + RTA_PRIORITY = 6, + RTA_PREFSRC = 7, + RTA_METRICS = 8, + RTA_MULTIPATH = 9, + RTA_PROTOINFO = 10, + RTA_FLOW = 11, + RTA_CACHEINFO = 12, + RTA_SESSION = 13, + RTA_MP_ALGO = 14, + RTA_TABLE = 15, + RTA_MARK = 16, + RTA_MFC_STATS = 17, + RTA_VIA = 18, + RTA_NEWDST = 19, + RTA_PREF = 20, + RTA_ENCAP_TYPE = 21, + RTA_ENCAP = 22, + RTA_EXPIRES = 23, + RTA_PAD = 24, + RTA_UID = 25, + RTA_TTL_PROPAGATE = 26, + RTA_IP_PROTO = 27, + RTA_SPORT = 28, + RTA_DPORT = 29, + RTA_NH_ID = 30, + __RTA_MAX = 31, +}; + +struct rta_cacheinfo { + __u32 rta_clntref; + __u32 rta_lastuse; + __s32 rta_expires; + __u32 rta_error; + __u32 rta_used; + __u32 rta_id; + __u32 rta_ts; + __u32 rta_tsage; +}; + +typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *, struct netlink_ext_ack *); + +typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *); + +struct rtnl_af_ops { + struct list_head list; + int family; + int (*fill_link_af)(struct sk_buff *, const struct net_device *, u32); + size_t (*get_link_af_size)(const struct net_device *, u32); + int (*validate_link_af)(const struct net_device *, const struct nlattr *); + int (*set_link_af)(struct net_device *, const struct nlattr *); + int (*fill_stats_af)(struct sk_buff *, const struct net_device *); + size_t (*get_stats_af_size)(const struct net_device *); +}; + +struct rtnl_link { + rtnl_doit_func doit; + rtnl_dumpit_func dumpit; + struct module *owner; + unsigned int flags; + struct callback_head rcu; +}; + +enum { + IF_LINK_MODE_DEFAULT = 0, + IF_LINK_MODE_DORMANT = 1, + IF_LINK_MODE_TESTING = 2, +}; + +enum lw_bits { + LW_URGENT = 0, +}; + +struct seg6_pernet_data { + struct mutex lock; + struct in6_addr *tun_src; +}; + +enum { + BPF_F_RECOMPUTE_CSUM = 1, + BPF_F_INVALIDATE_HASH = 2, +}; + +enum { + BPF_F_HDR_FIELD_MASK = 15, +}; + +enum { + BPF_F_PSEUDO_HDR = 16, + BPF_F_MARK_MANGLED_0 = 32, + BPF_F_MARK_ENFORCE = 64, +}; + +enum { + BPF_F_INGRESS = 1, +}; + +enum { + BPF_F_TUNINFO_IPV6 = 1, +}; + +enum { + BPF_F_ZERO_CSUM_TX = 2, + BPF_F_DONT_FRAGMENT = 4, + BPF_F_SEQ_NUMBER = 8, +}; + +enum { + BPF_CSUM_LEVEL_QUERY = 0, + BPF_CSUM_LEVEL_INC = 1, + BPF_CSUM_LEVEL_DEC = 2, + BPF_CSUM_LEVEL_RESET = 3, +}; + +enum { + BPF_F_ADJ_ROOM_FIXED_GSO = 1, + BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = 2, + BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = 4, + BPF_F_ADJ_ROOM_ENCAP_L4_GRE = 8, + BPF_F_ADJ_ROOM_ENCAP_L4_UDP = 16, + BPF_F_ADJ_ROOM_NO_CSUM_RESET = 32, +}; + +enum { + BPF_ADJ_ROOM_ENCAP_L2_MASK = 255, + BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 56, +}; + +enum { + BPF_SK_LOOKUP_F_REPLACE = 1, + BPF_SK_LOOKUP_F_NO_REUSEPORT = 2, +}; + +enum bpf_adj_room_mode { + BPF_ADJ_ROOM_NET = 0, + BPF_ADJ_ROOM_MAC = 1, +}; + +enum bpf_hdr_start_off { + BPF_HDR_START_MAC = 0, + BPF_HDR_START_NET = 1, +}; + +enum bpf_lwt_encap_mode { + BPF_LWT_ENCAP_SEG6 = 0, + BPF_LWT_ENCAP_SEG6_INLINE = 1, + BPF_LWT_ENCAP_IP = 2, +}; + +struct bpf_tunnel_key { + __u32 tunnel_id; + union { + __u32 remote_ipv4; + __u32 remote_ipv6[4]; + }; + __u8 tunnel_tos; + __u8 tunnel_ttl; + __u16 tunnel_ext; + __u32 tunnel_label; +}; + +struct bpf_xfrm_state { + __u32 reqid; + __u32 spi; + __u16 family; + __u16 ext; + union { + __u32 remote_ipv4; + __u32 remote_ipv6[4]; + }; +}; + +struct bpf_tcp_sock { + __u32 snd_cwnd; + __u32 srtt_us; + __u32 rtt_min; + __u32 snd_ssthresh; + __u32 rcv_nxt; + __u32 snd_nxt; + __u32 snd_una; + __u32 mss_cache; + __u32 ecn_flags; + __u32 rate_delivered; + __u32 rate_interval_us; + __u32 packets_out; + __u32 retrans_out; + __u32 total_retrans; + __u32 segs_in; + __u32 data_segs_in; + __u32 segs_out; + __u32 data_segs_out; + __u32 lost_out; + __u32 sacked_out; + __u64 bytes_received; + __u64 bytes_acked; + __u32 dsack_dups; + __u32 delivered; + __u32 delivered_ce; + __u32 icsk_retransmits; +}; + +struct bpf_sock_tuple { + union { + struct { + __be32 saddr; + __be32 daddr; + __be16 sport; + __be16 dport; + } ipv4; + struct { + __be32 saddr[4]; + __be32 daddr[4]; + __be16 sport; + __be16 dport; + } ipv6; + }; +}; + +struct bpf_xdp_sock { + __u32 queue_id; +}; + +enum { + BPF_SOCK_OPS_RTO_CB_FLAG = 1, + BPF_SOCK_OPS_RETRANS_CB_FLAG = 2, + BPF_SOCK_OPS_STATE_CB_FLAG = 4, + BPF_SOCK_OPS_RTT_CB_FLAG = 8, + BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG = 16, + BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG = 32, + BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = 64, + BPF_SOCK_OPS_ALL_CB_FLAGS = 127, +}; + +enum { + BPF_SOCK_OPS_VOID = 0, + BPF_SOCK_OPS_TIMEOUT_INIT = 1, + BPF_SOCK_OPS_RWND_INIT = 2, + BPF_SOCK_OPS_TCP_CONNECT_CB = 3, + BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB = 4, + BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB = 5, + BPF_SOCK_OPS_NEEDS_ECN = 6, + BPF_SOCK_OPS_BASE_RTT = 7, + BPF_SOCK_OPS_RTO_CB = 8, + BPF_SOCK_OPS_RETRANS_CB = 9, + BPF_SOCK_OPS_STATE_CB = 10, + BPF_SOCK_OPS_TCP_LISTEN_CB = 11, + BPF_SOCK_OPS_RTT_CB = 12, + BPF_SOCK_OPS_PARSE_HDR_OPT_CB = 13, + BPF_SOCK_OPS_HDR_OPT_LEN_CB = 14, + BPF_SOCK_OPS_WRITE_HDR_OPT_CB = 15, +}; + +enum { + TCP_BPF_IW = 1001, + TCP_BPF_SNDCWND_CLAMP = 1002, + TCP_BPF_DELACK_MAX = 1003, + TCP_BPF_RTO_MIN = 1004, + TCP_BPF_SYN = 1005, + TCP_BPF_SYN_IP = 1006, + TCP_BPF_SYN_MAC = 1007, +}; + +enum { + BPF_LOAD_HDR_OPT_TCP_SYN = 1, +}; + +enum { + BPF_FIB_LOOKUP_DIRECT = 1, + BPF_FIB_LOOKUP_OUTPUT = 2, +}; + +enum { + BPF_FIB_LKUP_RET_SUCCESS = 0, + BPF_FIB_LKUP_RET_BLACKHOLE = 1, + BPF_FIB_LKUP_RET_UNREACHABLE = 2, + BPF_FIB_LKUP_RET_PROHIBIT = 3, + BPF_FIB_LKUP_RET_NOT_FWDED = 4, + BPF_FIB_LKUP_RET_FWD_DISABLED = 5, + BPF_FIB_LKUP_RET_UNSUPP_LWT = 6, + BPF_FIB_LKUP_RET_NO_NEIGH = 7, + BPF_FIB_LKUP_RET_FRAG_NEEDED = 8, +}; + +struct bpf_fib_lookup { + __u8 family; + __u8 l4_protocol; + __be16 sport; + __be16 dport; + __u16 tot_len; + __u32 ifindex; + union { + __u8 tos; + __be32 flowinfo; + __u32 rt_metric; + }; + union { + __be32 ipv4_src; + __u32 ipv6_src[4]; + }; + union { + __be32 ipv4_dst; + __u32 ipv6_dst[4]; + }; + __be16 h_vlan_proto; + __be16 h_vlan_TCI; + __u8 smac[6]; + __u8 dmac[6]; +}; + +struct bpf_redir_neigh { + __u32 nh_family; + union { + __be32 ipv4_nh; + __u32 ipv6_nh[4]; + }; +}; + +enum rt_scope_t { + RT_SCOPE_UNIVERSE = 0, + RT_SCOPE_SITE = 200, + RT_SCOPE_LINK = 253, + RT_SCOPE_HOST = 254, + RT_SCOPE_NOWHERE = 255, +}; + +enum rt_class_t { + RT_TABLE_UNSPEC = 0, + RT_TABLE_COMPAT = 252, + RT_TABLE_DEFAULT = 253, + RT_TABLE_MAIN = 254, + RT_TABLE_LOCAL = 255, + RT_TABLE_MAX = 4294967295, +}; + +typedef int (*bpf_aux_classic_check_t)(struct sock_filter *, unsigned int); + +struct inet_timewait_sock { + struct sock_common __tw_common; + __u32 tw_mark; + volatile unsigned char tw_substate; + unsigned char tw_rcv_wscale; + __be16 tw_sport; + unsigned int tw_kill: 1; + unsigned int tw_transparent: 1; + unsigned int tw_flowlabel: 20; + unsigned int tw_pad: 2; + unsigned int tw_tos: 8; + u32 tw_txhash; + u32 tw_priority; + struct timer_list tw_timer; + struct inet_bind_bucket *tw_tb; +}; + +struct tcp_timewait_sock { + struct inet_timewait_sock tw_sk; + u32 tw_rcv_wnd; + u32 tw_ts_offset; + u32 tw_ts_recent; + u32 tw_last_oow_ack_time; + int tw_ts_recent_stamp; + u32 tw_tx_delay; + struct tcp_md5sig_key *tw_md5_key; +}; + +struct udp_sock { + struct inet_sock inet; + int pending; + unsigned int corkflag; + __u8 encap_type; + unsigned char no_check6_tx: 1; + unsigned char no_check6_rx: 1; + unsigned char encap_enabled: 1; + unsigned char gro_enabled: 1; + __u16 len; + __u16 gso_size; + __u16 pcslen; + __u16 pcrlen; + __u8 pcflag; + __u8 unused[3]; + int (*encap_rcv)(struct sock *, struct sk_buff *); + int (*encap_err_lookup)(struct sock *, struct sk_buff *); + void (*encap_destroy)(struct sock *); + struct sk_buff * (*gro_receive)(struct sock *, struct list_head *, struct sk_buff *); + int (*gro_complete)(struct sock *, struct sk_buff *, int); + struct sk_buff_head reader_queue; + int forward_deficit; + long: 32; + long: 64; +}; + +struct udp6_sock { + struct udp_sock udp; + struct ipv6_pinfo inet6; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct tcp6_sock { + struct tcp_sock tcp; + struct ipv6_pinfo inet6; +}; + +struct ipv6_bpf_stub { + int (*inet6_bind)(struct sock *, struct sockaddr *, int, u32); + struct sock * (*udp6_lib_lookup)(struct net *, const struct in6_addr *, __be16, const struct in6_addr *, __be16, int, int, struct udp_table *, struct sk_buff *); +}; + +struct fib_result { + __be32 prefix; + unsigned char prefixlen; + unsigned char nh_sel; + unsigned char type; + unsigned char scope; + u32 tclassid; + struct fib_nh_common *nhc; + struct fib_info *fi; + struct fib_table *table; + struct hlist_head *fa_head; +}; + +struct tcp_skb_cb { + __u32 seq; + __u32 end_seq; + union { + __u32 tcp_tw_isn; + struct { + u16 tcp_gso_segs; + u16 tcp_gso_size; + }; + }; + __u8 tcp_flags; + __u8 sacked; + __u8 ip_dsfield; + __u8 txstamp_ack: 1; + __u8 eor: 1; + __u8 has_rxtstamp: 1; + __u8 unused: 5; + __u32 ack_seq; + union { + struct { + __u32 in_flight: 30; + __u32 is_app_limited: 1; + __u32 unused: 1; + __u32 delivered; + u64 first_tx_mstamp; + u64 delivered_mstamp; + } tx; + union { + struct inet_skb_parm h4; + struct inet6_skb_parm h6; + } header; + struct { + __u32 flags; + struct sock *sk_redir; + void *data_end; + } bpf; + }; +}; + +struct strp_stats { + long long unsigned int msgs; + long long unsigned int bytes; + unsigned int mem_fail; + unsigned int need_more_hdr; + unsigned int msg_too_big; + unsigned int msg_timeouts; + unsigned int bad_hdr_len; +}; + +struct strparser; + +struct strp_callbacks { + int (*parse_msg)(struct strparser *, struct sk_buff *); + void (*rcv_msg)(struct strparser *, struct sk_buff *); + int (*read_sock_done)(struct strparser *, int); + void (*abort_parser)(struct strparser *, int); + void (*lock)(struct strparser *); + void (*unlock)(struct strparser *); +}; + +struct strparser { + struct sock *sk; + u32 stopped: 1; + u32 paused: 1; + u32 aborted: 1; + u32 interrupted: 1; + u32 unrecov_intr: 1; + struct sk_buff **skb_nextp; + struct sk_buff *skb_head; + unsigned int need_bytes; + struct delayed_work msg_timer_work; + struct work_struct work; + struct strp_stats stats; + struct strp_callbacks cb; +}; + +struct strp_msg { + int full_len; + int offset; +}; + +struct xdp_sock; + +struct xsk_map { + struct bpf_map map; + spinlock_t lock; + struct xdp_sock *xsk_map[0]; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct xdp_sock { + struct sock sk; + long: 64; + long: 64; + struct xsk_queue *rx; + struct net_device *dev; + struct xdp_umem *umem; + struct list_head flush_node; + struct xsk_buff_pool *pool; + u16 queue_id; + bool zc; + enum { + XSK_READY = 0, + XSK_BOUND = 1, + XSK_UNBOUND = 2, + } state; + long: 64; + struct xsk_queue *tx; + struct list_head tx_list; + spinlock_t tx_completion_lock; + spinlock_t rx_lock; + u64 rx_dropped; + u64 rx_queue_full; + struct list_head map_list; + spinlock_t map_list_lock; + struct mutex mutex; + struct xsk_queue *fq_tmp; + struct xsk_queue *cq_tmp; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct ipv6_sr_hdr { + __u8 nexthdr; + __u8 hdrlen; + __u8 type; + __u8 segments_left; + __u8 first_segment; + __u8 flags; + __u16 tag; + struct in6_addr segments[0]; +}; + +enum { + SEG6_LOCAL_ACTION_UNSPEC = 0, + SEG6_LOCAL_ACTION_END = 1, + SEG6_LOCAL_ACTION_END_X = 2, + SEG6_LOCAL_ACTION_END_T = 3, + SEG6_LOCAL_ACTION_END_DX2 = 4, + SEG6_LOCAL_ACTION_END_DX6 = 5, + SEG6_LOCAL_ACTION_END_DX4 = 6, + SEG6_LOCAL_ACTION_END_DT6 = 7, + SEG6_LOCAL_ACTION_END_DT4 = 8, + SEG6_LOCAL_ACTION_END_B6 = 9, + SEG6_LOCAL_ACTION_END_B6_ENCAP = 10, + SEG6_LOCAL_ACTION_END_BM = 11, + SEG6_LOCAL_ACTION_END_S = 12, + SEG6_LOCAL_ACTION_END_AS = 13, + SEG6_LOCAL_ACTION_END_AM = 14, + SEG6_LOCAL_ACTION_END_BPF = 15, + __SEG6_LOCAL_ACTION_MAX = 16, +}; + +struct seg6_bpf_srh_state { + struct ipv6_sr_hdr *srh; + u16 hdrlen; + bool valid; +}; + +struct tls_crypto_info { + __u16 version; + __u16 cipher_type; +}; + +struct tls12_crypto_info_aes_gcm_128 { + struct tls_crypto_info info; + unsigned char iv[8]; + unsigned char key[16]; + unsigned char salt[4]; + unsigned char rec_seq[8]; +}; + +struct tls12_crypto_info_aes_gcm_256 { + struct tls_crypto_info info; + unsigned char iv[8]; + unsigned char key[32]; + unsigned char salt[4]; + unsigned char rec_seq[8]; +}; + +struct tls_sw_context_rx { + struct crypto_aead *aead_recv; + struct crypto_wait async_wait; + struct strparser strp; + struct sk_buff_head rx_list; + void (*saved_data_ready)(struct sock *); + struct sk_buff *recv_pkt; + u8 control; + u8 async_capable: 1; + u8 decrypted: 1; + atomic_t decrypt_pending; + spinlock_t decrypt_compl_lock; + bool async_notify; +}; + +struct cipher_context { + char *iv; + char *rec_seq; +}; + +union tls_crypto_context { + struct tls_crypto_info info; + union { + struct tls12_crypto_info_aes_gcm_128 aes_gcm_128; + struct tls12_crypto_info_aes_gcm_256 aes_gcm_256; + }; +}; + +struct tls_prot_info { + u16 version; + u16 cipher_type; + u16 prepend_size; + u16 tag_size; + u16 overhead_size; + u16 iv_size; + u16 salt_size; + u16 rec_seq_size; + u16 aad_size; + u16 tail_size; +}; + +struct tls_context { + struct tls_prot_info prot_info; + u8 tx_conf: 3; + u8 rx_conf: 3; + int (*push_pending_record)(struct sock *, int); + void (*sk_write_space)(struct sock *); + void *priv_ctx_tx; + void *priv_ctx_rx; + struct net_device *netdev; + struct cipher_context tx; + struct cipher_context rx; + struct scatterlist *partially_sent_record; + u16 partially_sent_offset; + bool in_tcp_sendpages; + bool pending_open_record_frags; + struct mutex tx_lock; + long unsigned int flags; + struct proto *sk_proto; + void (*sk_destruct)(struct sock *); + union tls_crypto_context crypto_send; + union tls_crypto_context crypto_recv; + struct list_head list; + refcount_t refcount; + struct callback_head rcu; +}; + +typedef u64 (*btf_bpf_skb_get_pay_offset)(struct sk_buff *); + +typedef u64 (*btf_bpf_skb_get_nlattr)(struct sk_buff *, u32, u32); + +typedef u64 (*btf_bpf_skb_get_nlattr_nest)(struct sk_buff *, u32, u32); + +typedef u64 (*btf_bpf_skb_load_helper_8)(const struct sk_buff *, const void *, int, int); + +typedef u64 (*btf_bpf_skb_load_helper_8_no_cache)(const struct sk_buff *, int); + +typedef u64 (*btf_bpf_skb_load_helper_16)(const struct sk_buff *, const void *, int, int); + +typedef u64 (*btf_bpf_skb_load_helper_16_no_cache)(const struct sk_buff *, int); + +typedef u64 (*btf_bpf_skb_load_helper_32)(const struct sk_buff *, const void *, int, int); + +typedef u64 (*btf_bpf_skb_load_helper_32_no_cache)(const struct sk_buff *, int); + +struct bpf_scratchpad { + union { + __be32 diff[128]; + u8 buff[512]; + }; +}; + +typedef u64 (*btf_bpf_skb_store_bytes)(struct sk_buff *, u32, const void *, u32, u64); + +typedef u64 (*btf_bpf_skb_load_bytes)(const struct sk_buff *, u32, void *, u32); + +typedef u64 (*btf_bpf_flow_dissector_load_bytes)(const struct bpf_flow_dissector *, u32, void *, u32); + +typedef u64 (*btf_bpf_skb_load_bytes_relative)(const struct sk_buff *, u32, void *, u32, u32); + +typedef u64 (*btf_bpf_skb_pull_data)(struct sk_buff *, u32); + +typedef u64 (*btf_bpf_sk_fullsock)(struct sock *); + +typedef u64 (*btf_sk_skb_pull_data)(struct sk_buff *, u32); + +typedef u64 (*btf_bpf_l3_csum_replace)(struct sk_buff *, u32, u64, u64, u64); + +typedef u64 (*btf_bpf_l4_csum_replace)(struct sk_buff *, u32, u64, u64, u64); + +typedef u64 (*btf_bpf_csum_diff)(__be32 *, u32, __be32 *, u32, __wsum); + +typedef u64 (*btf_bpf_csum_update)(struct sk_buff *, __wsum); + +typedef u64 (*btf_bpf_csum_level)(struct sk_buff *, u64); + +enum { + BPF_F_NEIGH = 2, + BPF_F_PEER = 4, + BPF_F_NEXTHOP = 8, +}; + +typedef u64 (*btf_bpf_clone_redirect)(struct sk_buff *, u32, u64); + +typedef u64 (*btf_bpf_redirect)(u32, u64); + +typedef u64 (*btf_bpf_redirect_peer)(u32, u64); + +typedef u64 (*btf_bpf_redirect_neigh)(u32, struct bpf_redir_neigh *, int, u64); + +typedef u64 (*btf_bpf_msg_apply_bytes)(struct sk_msg *, u32); + +typedef u64 (*btf_bpf_msg_cork_bytes)(struct sk_msg *, u32); + +typedef u64 (*btf_bpf_msg_pull_data)(struct sk_msg *, u32, u32, u64); + +typedef u64 (*btf_bpf_msg_push_data)(struct sk_msg *, u32, u32, u64); + +typedef u64 (*btf_bpf_msg_pop_data)(struct sk_msg *, u32, u32, u64); + +typedef u64 (*btf_bpf_get_cgroup_classid_curr)(); + +typedef u64 (*btf_bpf_skb_cgroup_classid)(const struct sk_buff *); + +typedef u64 (*btf_bpf_get_cgroup_classid)(const struct sk_buff *); + +typedef u64 (*btf_bpf_get_route_realm)(const struct sk_buff *); + +typedef u64 (*btf_bpf_get_hash_recalc)(struct sk_buff *); + +typedef u64 (*btf_bpf_set_hash_invalid)(struct sk_buff *); + +typedef u64 (*btf_bpf_set_hash)(struct sk_buff *, u32); + +typedef u64 (*btf_bpf_skb_vlan_push)(struct sk_buff *, __be16, u16); + +typedef u64 (*btf_bpf_skb_vlan_pop)(struct sk_buff *); + +typedef u64 (*btf_bpf_skb_change_proto)(struct sk_buff *, __be16, u64); + +typedef u64 (*btf_bpf_skb_change_type)(struct sk_buff *, u32); + +typedef u64 (*btf_sk_skb_adjust_room)(struct sk_buff *, s32, u32, u64); + +typedef u64 (*btf_bpf_skb_adjust_room)(struct sk_buff *, s32, u32, u64); + +typedef u64 (*btf_bpf_skb_change_tail)(struct sk_buff *, u32, u64); + +typedef u64 (*btf_sk_skb_change_tail)(struct sk_buff *, u32, u64); + +typedef u64 (*btf_bpf_skb_change_head)(struct sk_buff *, u32, u64); + +typedef u64 (*btf_sk_skb_change_head)(struct sk_buff *, u32, u64); + +typedef u64 (*btf_bpf_xdp_adjust_head)(struct xdp_buff *, int); + +typedef u64 (*btf_bpf_xdp_adjust_tail)(struct xdp_buff *, int); + +typedef u64 (*btf_bpf_xdp_adjust_meta)(struct xdp_buff *, int); + +typedef u64 (*btf_bpf_xdp_redirect)(u32, u64); + +typedef u64 (*btf_bpf_xdp_redirect_map)(struct bpf_map *, u32, u64); + +typedef u64 (*btf_bpf_skb_event_output)(struct sk_buff *, struct bpf_map *, u64, void *, u64); + +typedef u64 (*btf_bpf_skb_get_tunnel_key)(struct sk_buff *, struct bpf_tunnel_key *, u32, u64); + +typedef u64 (*btf_bpf_skb_get_tunnel_opt)(struct sk_buff *, u8 *, u32); + +typedef u64 (*btf_bpf_skb_set_tunnel_key)(struct sk_buff *, const struct bpf_tunnel_key *, u32, u64); + +typedef u64 (*btf_bpf_skb_set_tunnel_opt)(struct sk_buff *, const u8 *, u32); + +typedef u64 (*btf_bpf_skb_under_cgroup)(struct sk_buff *, struct bpf_map *, u32); + +typedef u64 (*btf_bpf_skb_cgroup_id)(const struct sk_buff *); + +typedef u64 (*btf_bpf_skb_ancestor_cgroup_id)(const struct sk_buff *, int); + +typedef u64 (*btf_bpf_sk_cgroup_id)(struct sock *); + +typedef u64 (*btf_bpf_sk_ancestor_cgroup_id)(struct sock *, int); + +typedef u64 (*btf_bpf_xdp_event_output)(struct xdp_buff *, struct bpf_map *, u64, void *, u64); + +typedef u64 (*btf_bpf_get_socket_cookie)(struct sk_buff *); + +typedef u64 (*btf_bpf_get_socket_cookie_sock_addr)(struct bpf_sock_addr_kern *); + +typedef u64 (*btf_bpf_get_socket_cookie_sock)(struct sock *); + +typedef u64 (*btf_bpf_get_socket_cookie_sock_ops)(struct bpf_sock_ops_kern *); + +typedef u64 (*btf_bpf_get_netns_cookie_sock)(struct sock *); + +typedef u64 (*btf_bpf_get_netns_cookie_sock_addr)(struct bpf_sock_addr_kern *); + +typedef u64 (*btf_bpf_get_socket_uid)(struct sk_buff *); + +typedef u64 (*btf_bpf_sock_addr_setsockopt)(struct bpf_sock_addr_kern *, int, int, char *, int); + +typedef u64 (*btf_bpf_sock_addr_getsockopt)(struct bpf_sock_addr_kern *, int, int, char *, int); + +typedef u64 (*btf_bpf_sock_ops_setsockopt)(struct bpf_sock_ops_kern *, int, int, char *, int); + +typedef u64 (*btf_bpf_sock_ops_getsockopt)(struct bpf_sock_ops_kern *, int, int, char *, int); + +typedef u64 (*btf_bpf_sock_ops_cb_flags_set)(struct bpf_sock_ops_kern *, int); + +typedef u64 (*btf_bpf_bind)(struct bpf_sock_addr_kern *, struct sockaddr *, int); + +typedef u64 (*btf_bpf_skb_get_xfrm_state)(struct sk_buff *, u32, struct bpf_xfrm_state *, u32, u64); + +typedef u64 (*btf_bpf_xdp_fib_lookup)(struct xdp_buff *, struct bpf_fib_lookup *, int, u32); + +typedef u64 (*btf_bpf_skb_fib_lookup)(struct sk_buff *, struct bpf_fib_lookup *, int, u32); + +typedef u64 (*btf_bpf_lwt_in_push_encap)(struct sk_buff *, u32, void *, u32); + +typedef u64 (*btf_bpf_lwt_xmit_push_encap)(struct sk_buff *, u32, void *, u32); + +typedef u64 (*btf_bpf_lwt_seg6_store_bytes)(struct sk_buff *, u32, const void *, u32); + +typedef u64 (*btf_bpf_lwt_seg6_action)(struct sk_buff *, u32, void *, u32); + +typedef u64 (*btf_bpf_lwt_seg6_adjust_srh)(struct sk_buff *, u32, s32); + +typedef u64 (*btf_bpf_skc_lookup_tcp)(struct sk_buff *, struct bpf_sock_tuple *, u32, u64, u64); + +typedef u64 (*btf_bpf_sk_lookup_tcp)(struct sk_buff *, struct bpf_sock_tuple *, u32, u64, u64); + +typedef u64 (*btf_bpf_sk_lookup_udp)(struct sk_buff *, struct bpf_sock_tuple *, u32, u64, u64); + +typedef u64 (*btf_bpf_sk_release)(struct sock *); + +typedef u64 (*btf_bpf_xdp_sk_lookup_udp)(struct xdp_buff *, struct bpf_sock_tuple *, u32, u32, u64); + +typedef u64 (*btf_bpf_xdp_skc_lookup_tcp)(struct xdp_buff *, struct bpf_sock_tuple *, u32, u32, u64); + +typedef u64 (*btf_bpf_xdp_sk_lookup_tcp)(struct xdp_buff *, struct bpf_sock_tuple *, u32, u32, u64); + +typedef u64 (*btf_bpf_sock_addr_skc_lookup_tcp)(struct bpf_sock_addr_kern *, struct bpf_sock_tuple *, u32, u64, u64); + +typedef u64 (*btf_bpf_sock_addr_sk_lookup_tcp)(struct bpf_sock_addr_kern *, struct bpf_sock_tuple *, u32, u64, u64); + +typedef u64 (*btf_bpf_sock_addr_sk_lookup_udp)(struct bpf_sock_addr_kern *, struct bpf_sock_tuple *, u32, u64, u64); + +typedef u64 (*btf_bpf_tcp_sock)(struct sock *); + +typedef u64 (*btf_bpf_get_listener_sock)(struct sock *); + +typedef u64 (*btf_bpf_skb_ecn_set_ce)(struct sk_buff *); + +typedef u64 (*btf_bpf_tcp_check_syncookie)(struct sock *, void *, u32, struct tcphdr *, u32); + +typedef u64 (*btf_bpf_tcp_gen_syncookie)(struct sock *, void *, u32, struct tcphdr *, u32); + +typedef u64 (*btf_bpf_sk_assign)(struct sk_buff *, struct sock *, u64); + +typedef u64 (*btf_bpf_sock_ops_load_hdr_opt)(struct bpf_sock_ops_kern *, void *, u32, u64); + +typedef u64 (*btf_bpf_sock_ops_store_hdr_opt)(struct bpf_sock_ops_kern *, const void *, u32, u64); + +typedef u64 (*btf_bpf_sock_ops_reserve_hdr_opt)(struct bpf_sock_ops_kern *, u32, u64); + +typedef u64 (*btf_sk_select_reuseport)(struct sk_reuseport_kern *, struct bpf_map *, void *, u32); + +typedef u64 (*btf_sk_reuseport_load_bytes)(const struct sk_reuseport_kern *, u32, void *, u32); + +typedef u64 (*btf_sk_reuseport_load_bytes_relative)(const struct sk_reuseport_kern *, u32, void *, u32, u32); + +typedef u64 (*btf_bpf_sk_lookup_assign)(struct bpf_sk_lookup_kern *, struct sock *, u64); + +typedef u64 (*btf_bpf_skc_to_tcp6_sock)(struct sock *); + +typedef u64 (*btf_bpf_skc_to_tcp_sock)(struct sock *); + +typedef u64 (*btf_bpf_skc_to_tcp_timewait_sock)(struct sock *); + +typedef u64 (*btf_bpf_skc_to_tcp_request_sock)(struct sock *); + +typedef u64 (*btf_bpf_skc_to_udp6_sock)(struct sock *); + +struct bpf_dtab_netdev___2; + +enum { + INET_DIAG_REQ_NONE = 0, + INET_DIAG_REQ_BYTECODE = 1, + INET_DIAG_REQ_SK_BPF_STORAGES = 2, + INET_DIAG_REQ_PROTOCOL = 3, + __INET_DIAG_REQ_MAX = 4, +}; + +struct sock_diag_req { + __u8 sdiag_family; + __u8 sdiag_protocol; +}; + +struct sock_diag_handler { + __u8 family; + int (*dump)(struct sk_buff *, struct nlmsghdr *); + int (*get_info)(struct sk_buff *, struct sock *); + int (*destroy)(struct sk_buff *, struct nlmsghdr *); +}; + +struct broadcast_sk { + struct sock *sk; + struct work_struct work; +}; + +typedef int gifconf_func_t(struct net_device *, char *, int, int); + +struct tso_t { + int next_frag_idx; + int size; + void *data; + u16 ip_id; + u8 tlen; + bool ipv6; + u32 tcp_seq; +}; + +struct fib_notifier_net { + struct list_head fib_notifier_ops; + struct atomic_notifier_head fib_chain; +}; + +struct xdp_frame_bulk { + int count; + void *xa; + void *q[16]; +}; + +struct pp_alloc_cache { + u32 count; + void *cache[128]; +}; + +struct page_pool_params { + unsigned int flags; + unsigned int order; + unsigned int pool_size; + int nid; + struct device *dev; + enum dma_data_direction dma_dir; + unsigned int max_len; + unsigned int offset; +}; + +struct page_pool { + struct page_pool_params p; + struct delayed_work release_dw; + void (*disconnect)(void *); + long unsigned int defer_start; + long unsigned int defer_warn; + u32 pages_state_hold_cnt; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + struct pp_alloc_cache alloc; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct ptr_ring ring; + atomic_t pages_state_release_cnt; + refcount_t user_cnt; + u64 destroy_cnt; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct flow_dissector_key_ct { + u16 ct_state; + u16 ct_zone; + u32 ct_mark; + u32 ct_labels[4]; +}; + +struct flow_match { + struct flow_dissector *dissector; + void *mask; + void *key; +}; + +struct flow_match_meta { + struct flow_dissector_key_meta *key; + struct flow_dissector_key_meta *mask; +}; + +struct flow_match_basic { + struct flow_dissector_key_basic *key; + struct flow_dissector_key_basic *mask; +}; + +struct flow_match_control { + struct flow_dissector_key_control *key; + struct flow_dissector_key_control *mask; +}; + +struct flow_match_eth_addrs { + struct flow_dissector_key_eth_addrs *key; + struct flow_dissector_key_eth_addrs *mask; +}; + +struct flow_match_vlan { + struct flow_dissector_key_vlan *key; + struct flow_dissector_key_vlan *mask; +}; + +struct flow_match_ipv4_addrs { + struct flow_dissector_key_ipv4_addrs *key; + struct flow_dissector_key_ipv4_addrs *mask; +}; + +struct flow_match_ipv6_addrs { + struct flow_dissector_key_ipv6_addrs *key; + struct flow_dissector_key_ipv6_addrs *mask; +}; + +struct flow_match_ip { + struct flow_dissector_key_ip *key; + struct flow_dissector_key_ip *mask; +}; + +struct flow_match_ports { + struct flow_dissector_key_ports *key; + struct flow_dissector_key_ports *mask; +}; + +struct flow_match_icmp { + struct flow_dissector_key_icmp *key; + struct flow_dissector_key_icmp *mask; +}; + +struct flow_match_tcp { + struct flow_dissector_key_tcp *key; + struct flow_dissector_key_tcp *mask; +}; + +struct flow_match_mpls { + struct flow_dissector_key_mpls *key; + struct flow_dissector_key_mpls *mask; +}; + +struct flow_match_enc_keyid { + struct flow_dissector_key_keyid *key; + struct flow_dissector_key_keyid *mask; +}; + +struct flow_match_enc_opts { + struct flow_dissector_key_enc_opts *key; + struct flow_dissector_key_enc_opts *mask; +}; + +struct flow_match_ct { + struct flow_dissector_key_ct *key; + struct flow_dissector_key_ct *mask; +}; + +enum flow_action_id { + FLOW_ACTION_ACCEPT = 0, + FLOW_ACTION_DROP = 1, + FLOW_ACTION_TRAP = 2, + FLOW_ACTION_GOTO = 3, + FLOW_ACTION_REDIRECT = 4, + FLOW_ACTION_MIRRED = 5, + FLOW_ACTION_REDIRECT_INGRESS = 6, + FLOW_ACTION_MIRRED_INGRESS = 7, + FLOW_ACTION_VLAN_PUSH = 8, + FLOW_ACTION_VLAN_POP = 9, + FLOW_ACTION_VLAN_MANGLE = 10, + FLOW_ACTION_TUNNEL_ENCAP = 11, + FLOW_ACTION_TUNNEL_DECAP = 12, + FLOW_ACTION_MANGLE = 13, + FLOW_ACTION_ADD = 14, + FLOW_ACTION_CSUM = 15, + FLOW_ACTION_MARK = 16, + FLOW_ACTION_PTYPE = 17, + FLOW_ACTION_PRIORITY = 18, + FLOW_ACTION_WAKE = 19, + FLOW_ACTION_QUEUE = 20, + FLOW_ACTION_SAMPLE = 21, + FLOW_ACTION_POLICE = 22, + FLOW_ACTION_CT = 23, + FLOW_ACTION_CT_METADATA = 24, + FLOW_ACTION_MPLS_PUSH = 25, + FLOW_ACTION_MPLS_POP = 26, + FLOW_ACTION_MPLS_MANGLE = 27, + FLOW_ACTION_GATE = 28, + NUM_FLOW_ACTIONS = 29, +}; + +enum flow_action_mangle_base { + FLOW_ACT_MANGLE_UNSPEC = 0, + FLOW_ACT_MANGLE_HDR_TYPE_ETH = 1, + FLOW_ACT_MANGLE_HDR_TYPE_IP4 = 2, + FLOW_ACT_MANGLE_HDR_TYPE_IP6 = 3, + FLOW_ACT_MANGLE_HDR_TYPE_TCP = 4, + FLOW_ACT_MANGLE_HDR_TYPE_UDP = 5, +}; + +enum flow_action_hw_stats { + FLOW_ACTION_HW_STATS_IMMEDIATE = 1, + FLOW_ACTION_HW_STATS_DELAYED = 2, + FLOW_ACTION_HW_STATS_ANY = 3, + FLOW_ACTION_HW_STATS_DISABLED = 4, + FLOW_ACTION_HW_STATS_DONT_CARE = 7, +}; + +typedef void (*action_destr)(void *); + +struct nf_flowtable; + +struct action_gate_entry; + +struct flow_action_entry { + enum flow_action_id id; + enum flow_action_hw_stats hw_stats; + action_destr destructor; + void *destructor_priv; + union { + u32 chain_index; + struct net_device *dev; + struct { + u16 vid; + __be16 proto; + u8 prio; + } vlan; + struct { + enum flow_action_mangle_base htype; + u32 offset; + u32 mask; + u32 val; + } mangle; + struct ip_tunnel_info *tunnel; + u32 csum_flags; + u32 mark; + u16 ptype; + u32 priority; + struct { + u32 ctx; + u32 index; + u8 vf; + } queue; + struct { + struct psample_group *psample_group; + u32 rate; + u32 trunc_size; + bool truncate; + } sample; + struct { + u32 index; + u32 burst; + u64 rate_bytes_ps; + u32 mtu; + } police; + struct { + int action; + u16 zone; + struct nf_flowtable *flow_table; + } ct; + struct { + long unsigned int cookie; + u32 mark; + u32 labels[4]; + } ct_metadata; + struct { + u32 label; + __be16 proto; + u8 tc; + u8 bos; + u8 ttl; + } mpls_push; + struct { + __be16 proto; + } mpls_pop; + struct { + u32 label; + u8 tc; + u8 bos; + u8 ttl; + } mpls_mangle; + struct { + u32 index; + s32 prio; + u64 basetime; + u64 cycletime; + u64 cycletimeext; + u32 num_entries; + struct action_gate_entry *entries; + } gate; + }; + struct flow_action_cookie *cookie; +}; + +struct flow_action { + unsigned int num_entries; + struct flow_action_entry entries[0]; +}; + +struct flow_rule { + struct flow_match match; + struct flow_action action; +}; + +enum flow_block_command { + FLOW_BLOCK_BIND = 0, + FLOW_BLOCK_UNBIND = 1, +}; + +enum flow_block_binder_type { + FLOW_BLOCK_BINDER_TYPE_UNSPEC = 0, + FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS = 1, + FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS = 2, + FLOW_BLOCK_BINDER_TYPE_RED_EARLY_DROP = 3, + FLOW_BLOCK_BINDER_TYPE_RED_MARK = 4, +}; + +struct flow_block_offload { + enum flow_block_command command; + enum flow_block_binder_type binder_type; + bool block_shared; + bool unlocked_driver_cb; + struct net *net; + struct flow_block *block; + struct list_head cb_list; + struct list_head *driver_block_list; + struct netlink_ext_ack *extack; + struct Qdisc *sch; +}; + +struct flow_block_cb; + +struct flow_block_indr { + struct list_head list; + struct net_device *dev; + struct Qdisc *sch; + enum flow_block_binder_type binder_type; + void *data; + void *cb_priv; + void (*cleanup)(struct flow_block_cb *); +}; + +struct flow_block_cb { + struct list_head driver_list; + struct list_head list; + flow_setup_cb_t *cb; + void *cb_ident; + void *cb_priv; + void (*release)(void *); + struct flow_block_indr indr; + unsigned int refcnt; +}; + +typedef int flow_indr_block_bind_cb_t(struct net_device *, struct Qdisc *, void *, enum tc_setup_type, void *, void *, void (*)(struct flow_block_cb *)); + +struct flow_indr_dev { + struct list_head list; + flow_indr_block_bind_cb_t *cb; + void *cb_priv; + refcount_t refcnt; + struct callback_head rcu; +}; + +struct netdev_queue_attribute { + struct attribute attr; + ssize_t (*show)(struct netdev_queue *, char *); + ssize_t (*store)(struct netdev_queue *, const char *, size_t); +}; + +enum __sk_action { + __SK_DROP = 0, + __SK_PASS = 1, + __SK_REDIRECT = 2, + __SK_NONE = 3, +}; + +struct sk_psock_progs { + struct bpf_prog *msg_parser; + struct bpf_prog *skb_parser; + struct bpf_prog *skb_verdict; +}; + +enum sk_psock_state_bits { + SK_PSOCK_TX_ENABLED = 0, +}; + +struct sk_psock_link { + struct list_head list; + struct bpf_map *map; + void *link_raw; +}; + +struct sk_psock_parser { + struct strparser strp; + bool enabled; + void (*saved_data_ready)(struct sock *); +}; + +struct sk_psock_work_state { + struct sk_buff *skb; + u32 len; + u32 off; +}; + +struct sk_psock { + struct sock *sk; + struct sock *sk_redir; + u32 apply_bytes; + u32 cork_bytes; + u32 eval; + struct sk_msg *cork; + struct sk_psock_progs progs; + struct sk_psock_parser parser; + struct sk_buff_head ingress_skb; + struct list_head ingress_msg; + long unsigned int state; + struct list_head link; + spinlock_t link_lock; + refcount_t refcnt; + void (*saved_unhash)(struct sock *); + void (*saved_close)(struct sock *, long int); + void (*saved_write_space)(struct sock *); + struct proto *sk_proto; + struct sk_psock_work_state work_state; + struct work_struct work; + union { + struct callback_head rcu; + struct work_struct gc; + }; +}; + +struct fib_rule_uid_range { + __u32 start; + __u32 end; +}; + +enum { + FRA_UNSPEC = 0, + FRA_DST = 1, + FRA_SRC = 2, + FRA_IIFNAME = 3, + FRA_GOTO = 4, + FRA_UNUSED2 = 5, + FRA_PRIORITY = 6, + FRA_UNUSED3 = 7, + FRA_UNUSED4 = 8, + FRA_UNUSED5 = 9, + FRA_FWMARK = 10, + FRA_FLOW = 11, + FRA_TUN_ID = 12, + FRA_SUPPRESS_IFGROUP = 13, + FRA_SUPPRESS_PREFIXLEN = 14, + FRA_TABLE = 15, + FRA_FWMASK = 16, + FRA_OIFNAME = 17, + FRA_PAD = 18, + FRA_L3MDEV = 19, + FRA_UID_RANGE = 20, + FRA_PROTOCOL = 21, + FRA_IP_PROTO = 22, + FRA_SPORT_RANGE = 23, + FRA_DPORT_RANGE = 24, + __FRA_MAX = 25, +}; + +enum { + FR_ACT_UNSPEC = 0, + FR_ACT_TO_TBL = 1, + FR_ACT_GOTO = 2, + FR_ACT_NOP = 3, + FR_ACT_RES3 = 4, + FR_ACT_RES4 = 5, + FR_ACT_BLACKHOLE = 6, + FR_ACT_UNREACHABLE = 7, + FR_ACT_PROHIBIT = 8, + __FR_ACT_MAX = 9, +}; + +struct fib_rule_notifier_info { + struct fib_notifier_info info; + struct fib_rule *rule; +}; + +struct trace_event_raw_kfree_skb { + struct trace_entry ent; + void *skbaddr; + void *location; + short unsigned int protocol; + char __data[0]; +}; + +struct trace_event_raw_consume_skb { + struct trace_entry ent; + void *skbaddr; + char __data[0]; +}; + +struct trace_event_raw_skb_copy_datagram_iovec { + struct trace_entry ent; + const void *skbaddr; + int len; + char __data[0]; +}; + +struct trace_event_data_offsets_kfree_skb {}; + +struct trace_event_data_offsets_consume_skb {}; + +struct trace_event_data_offsets_skb_copy_datagram_iovec {}; + +typedef void (*btf_trace_kfree_skb)(void *, struct sk_buff *, void *); + +typedef void (*btf_trace_consume_skb)(void *, struct sk_buff *); + +typedef void (*btf_trace_skb_copy_datagram_iovec)(void *, const struct sk_buff *, int); + +struct trace_event_raw_net_dev_start_xmit { + struct trace_entry ent; + u32 __data_loc_name; + u16 queue_mapping; + const void *skbaddr; + bool vlan_tagged; + u16 vlan_proto; + u16 vlan_tci; + u16 protocol; + u8 ip_summed; + unsigned int len; + unsigned int data_len; + int network_offset; + bool transport_offset_valid; + int transport_offset; + u8 tx_flags; + u16 gso_size; + u16 gso_segs; + u16 gso_type; + char __data[0]; +}; + +struct trace_event_raw_net_dev_xmit { + struct trace_entry ent; + void *skbaddr; + unsigned int len; + int rc; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_net_dev_xmit_timeout { + struct trace_entry ent; + u32 __data_loc_name; + u32 __data_loc_driver; + int queue_index; + char __data[0]; +}; + +struct trace_event_raw_net_dev_template { + struct trace_entry ent; + void *skbaddr; + unsigned int len; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_net_dev_rx_verbose_template { + struct trace_entry ent; + u32 __data_loc_name; + unsigned int napi_id; + u16 queue_mapping; + const void *skbaddr; + bool vlan_tagged; + u16 vlan_proto; + u16 vlan_tci; + u16 protocol; + u8 ip_summed; + u32 hash; + bool l4_hash; + unsigned int len; + unsigned int data_len; + unsigned int truesize; + bool mac_header_valid; + int mac_header; + unsigned char nr_frags; + u16 gso_size; + u16 gso_type; + char __data[0]; +}; + +struct trace_event_raw_net_dev_rx_exit_template { + struct trace_entry ent; + int ret; + char __data[0]; +}; + +struct trace_event_data_offsets_net_dev_start_xmit { + u32 name; +}; + +struct trace_event_data_offsets_net_dev_xmit { + u32 name; +}; + +struct trace_event_data_offsets_net_dev_xmit_timeout { + u32 name; + u32 driver; +}; + +struct trace_event_data_offsets_net_dev_template { + u32 name; +}; + +struct trace_event_data_offsets_net_dev_rx_verbose_template { + u32 name; +}; + +struct trace_event_data_offsets_net_dev_rx_exit_template {}; + +typedef void (*btf_trace_net_dev_start_xmit)(void *, const struct sk_buff *, const struct net_device *); + +typedef void (*btf_trace_net_dev_xmit)(void *, struct sk_buff *, int, struct net_device *, unsigned int); + +typedef void (*btf_trace_net_dev_xmit_timeout)(void *, struct net_device *, int); + +typedef void (*btf_trace_net_dev_queue)(void *, struct sk_buff *); + +typedef void (*btf_trace_netif_receive_skb)(void *, struct sk_buff *); + +typedef void (*btf_trace_netif_rx)(void *, struct sk_buff *); + +typedef void (*btf_trace_napi_gro_frags_entry)(void *, const struct sk_buff *); + +typedef void (*btf_trace_napi_gro_receive_entry)(void *, const struct sk_buff *); + +typedef void (*btf_trace_netif_receive_skb_entry)(void *, const struct sk_buff *); + +typedef void (*btf_trace_netif_receive_skb_list_entry)(void *, const struct sk_buff *); + +typedef void (*btf_trace_netif_rx_entry)(void *, const struct sk_buff *); + +typedef void (*btf_trace_netif_rx_ni_entry)(void *, const struct sk_buff *); + +typedef void (*btf_trace_napi_gro_frags_exit)(void *, int); + +typedef void (*btf_trace_napi_gro_receive_exit)(void *, int); + +typedef void (*btf_trace_netif_receive_skb_exit)(void *, int); + +typedef void (*btf_trace_netif_rx_exit)(void *, int); + +typedef void (*btf_trace_netif_rx_ni_exit)(void *, int); + +typedef void (*btf_trace_netif_receive_skb_list_exit)(void *, int); + +struct trace_event_raw_napi_poll { + struct trace_entry ent; + struct napi_struct *napi; + u32 __data_loc_dev_name; + int work; + int budget; + char __data[0]; +}; + +struct trace_event_data_offsets_napi_poll { + u32 dev_name; +}; + +typedef void (*btf_trace_napi_poll)(void *, struct napi_struct *, int, int); + +enum tcp_ca_state { + TCP_CA_Open = 0, + TCP_CA_Disorder = 1, + TCP_CA_CWR = 2, + TCP_CA_Recovery = 3, + TCP_CA_Loss = 4, +}; + +struct trace_event_raw_sock_rcvqueue_full { + struct trace_entry ent; + int rmem_alloc; + unsigned int truesize; + int sk_rcvbuf; + char __data[0]; +}; + +struct trace_event_raw_sock_exceed_buf_limit { + struct trace_entry ent; + char name[32]; + long int *sysctl_mem; + long int allocated; + int sysctl_rmem; + int rmem_alloc; + int sysctl_wmem; + int wmem_alloc; + int wmem_queued; + int kind; + char __data[0]; +}; + +struct trace_event_raw_inet_sock_set_state { + struct trace_entry ent; + const void *skaddr; + int oldstate; + int newstate; + __u16 sport; + __u16 dport; + __u16 family; + __u16 protocol; + __u8 saddr[4]; + __u8 daddr[4]; + __u8 saddr_v6[16]; + __u8 daddr_v6[16]; + char __data[0]; +}; + +struct trace_event_data_offsets_sock_rcvqueue_full {}; + +struct trace_event_data_offsets_sock_exceed_buf_limit {}; + +struct trace_event_data_offsets_inet_sock_set_state {}; + +typedef void (*btf_trace_sock_rcvqueue_full)(void *, struct sock *, struct sk_buff *); + +typedef void (*btf_trace_sock_exceed_buf_limit)(void *, struct sock *, struct proto *, long int, int); + +typedef void (*btf_trace_inet_sock_set_state)(void *, const struct sock *, const int, const int); + +struct trace_event_raw_udp_fail_queue_rcv_skb { + struct trace_entry ent; + int rc; + __u16 lport; + char __data[0]; +}; + +struct trace_event_data_offsets_udp_fail_queue_rcv_skb {}; + +typedef void (*btf_trace_udp_fail_queue_rcv_skb)(void *, int, struct sock *); + +struct trace_event_raw_tcp_event_sk_skb { + struct trace_entry ent; + const void *skbaddr; + const void *skaddr; + int state; + __u16 sport; + __u16 dport; + __u8 saddr[4]; + __u8 daddr[4]; + __u8 saddr_v6[16]; + __u8 daddr_v6[16]; + char __data[0]; +}; + +struct trace_event_raw_tcp_event_sk { + struct trace_entry ent; + const void *skaddr; + __u16 sport; + __u16 dport; + __u8 saddr[4]; + __u8 daddr[4]; + __u8 saddr_v6[16]; + __u8 daddr_v6[16]; + __u64 sock_cookie; + char __data[0]; +}; + +struct trace_event_raw_tcp_retransmit_synack { + struct trace_entry ent; + const void *skaddr; + const void *req; + __u16 sport; + __u16 dport; + __u8 saddr[4]; + __u8 daddr[4]; + __u8 saddr_v6[16]; + __u8 daddr_v6[16]; + char __data[0]; +}; + +struct trace_event_raw_tcp_probe { + struct trace_entry ent; + __u8 saddr[28]; + __u8 daddr[28]; + __u16 sport; + __u16 dport; + __u32 mark; + __u16 data_len; + __u32 snd_nxt; + __u32 snd_una; + __u32 snd_cwnd; + __u32 ssthresh; + __u32 snd_wnd; + __u32 srtt; + __u32 rcv_wnd; + __u64 sock_cookie; + char __data[0]; +}; + +struct trace_event_data_offsets_tcp_event_sk_skb {}; + +struct trace_event_data_offsets_tcp_event_sk {}; + +struct trace_event_data_offsets_tcp_retransmit_synack {}; + +struct trace_event_data_offsets_tcp_probe {}; + +typedef void (*btf_trace_tcp_retransmit_skb)(void *, const struct sock *, const struct sk_buff *); + +typedef void (*btf_trace_tcp_send_reset)(void *, const struct sock *, const struct sk_buff *); + +typedef void (*btf_trace_tcp_receive_reset)(void *, struct sock *); + +typedef void (*btf_trace_tcp_destroy_sock)(void *, struct sock *); + +typedef void (*btf_trace_tcp_rcv_space_adjust)(void *, struct sock *); + +typedef void (*btf_trace_tcp_retransmit_synack)(void *, const struct sock *, const struct request_sock *); + +typedef void (*btf_trace_tcp_probe)(void *, struct sock *, struct sk_buff *); + +struct trace_event_raw_fib_table_lookup { + struct trace_entry ent; + u32 tb_id; + int err; + int oif; + int iif; + u8 proto; + __u8 tos; + __u8 scope; + __u8 flags; + __u8 src[4]; + __u8 dst[4]; + __u8 gw4[4]; + __u8 gw6[16]; + u16 sport; + u16 dport; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_data_offsets_fib_table_lookup { + u32 name; +}; + +typedef void (*btf_trace_fib_table_lookup)(void *, u32, const struct flowi4 *, const struct fib_nh_common *, int); + +struct trace_event_raw_qdisc_dequeue { + struct trace_entry ent; + struct Qdisc *qdisc; + const struct netdev_queue *txq; + int packets; + void *skbaddr; + int ifindex; + u32 handle; + u32 parent; + long unsigned int txq_state; + char __data[0]; +}; + +struct trace_event_raw_qdisc_reset { + struct trace_entry ent; + u32 __data_loc_dev; + u32 __data_loc_kind; + u32 parent; + u32 handle; + char __data[0]; +}; + +struct trace_event_raw_qdisc_destroy { + struct trace_entry ent; + u32 __data_loc_dev; + u32 __data_loc_kind; + u32 parent; + u32 handle; + char __data[0]; +}; + +struct trace_event_raw_qdisc_create { + struct trace_entry ent; + u32 __data_loc_dev; + u32 __data_loc_kind; + u32 parent; + char __data[0]; +}; + +struct trace_event_data_offsets_qdisc_dequeue {}; + +struct trace_event_data_offsets_qdisc_reset { + u32 dev; + u32 kind; +}; + +struct trace_event_data_offsets_qdisc_destroy { + u32 dev; + u32 kind; +}; + +struct trace_event_data_offsets_qdisc_create { + u32 dev; + u32 kind; +}; + +typedef void (*btf_trace_qdisc_dequeue)(void *, struct Qdisc *, const struct netdev_queue *, int, struct sk_buff *); + +typedef void (*btf_trace_qdisc_reset)(void *, struct Qdisc *); + +typedef void (*btf_trace_qdisc_destroy)(void *, struct Qdisc *); + +typedef void (*btf_trace_qdisc_create)(void *, const struct Qdisc_ops *, struct net_device *, u32); + +struct bridge_stp_xstats { + __u64 transition_blk; + __u64 transition_fwd; + __u64 rx_bpdu; + __u64 tx_bpdu; + __u64 rx_tcn; + __u64 tx_tcn; +}; + +struct br_mcast_stats { + __u64 igmp_v1queries[2]; + __u64 igmp_v2queries[2]; + __u64 igmp_v3queries[2]; + __u64 igmp_leaves[2]; + __u64 igmp_v1reports[2]; + __u64 igmp_v2reports[2]; + __u64 igmp_v3reports[2]; + __u64 igmp_parse_errors; + __u64 mld_v1queries[2]; + __u64 mld_v2queries[2]; + __u64 mld_leaves[2]; + __u64 mld_v1reports[2]; + __u64 mld_v2reports[2]; + __u64 mld_parse_errors; + __u64 mcast_bytes[2]; + __u64 mcast_packets[2]; +}; + +struct br_ip { + union { + __be32 ip4; + struct in6_addr ip6; + } src; + union { + __be32 ip4; + struct in6_addr ip6; + unsigned char mac_addr[6]; + } dst; + __be16 proto; + __u16 vid; +}; + +struct bridge_id { + unsigned char prio[2]; + unsigned char addr[6]; +}; + +typedef struct bridge_id bridge_id; + +struct mac_addr { + unsigned char addr[6]; +}; + +typedef struct mac_addr mac_addr; + +typedef __u16 port_id; + +struct bridge_mcast_own_query { + struct timer_list timer; + u32 startup_sent; +}; + +struct bridge_mcast_other_query { + struct timer_list timer; + long unsigned int delay_time; +}; + +struct net_bridge_port; + +struct bridge_mcast_querier { + struct br_ip addr; + struct net_bridge_port *port; +}; + +struct net_bridge; + +struct net_bridge_vlan_group; + +struct bridge_mcast_stats; + +struct net_bridge_port { + struct net_bridge *br; + struct net_device *dev; + struct list_head list; + long unsigned int flags; + struct net_bridge_vlan_group *vlgrp; + struct net_bridge_port *backup_port; + u8 priority; + u8 state; + u16 port_no; + unsigned char topology_change_ack; + unsigned char config_pending; + port_id port_id; + port_id designated_port; + bridge_id designated_root; + bridge_id designated_bridge; + u32 path_cost; + u32 designated_cost; + long unsigned int designated_age; + struct timer_list forward_delay_timer; + struct timer_list hold_timer; + struct timer_list message_age_timer; + struct kobject kobj; + struct callback_head rcu; + struct bridge_mcast_own_query ip4_own_query; + struct bridge_mcast_own_query ip6_own_query; + unsigned char multicast_router; + struct bridge_mcast_stats *mcast_stats; + struct timer_list multicast_router_timer; + struct hlist_head mglist; + struct hlist_node rlist; + char sysfs_name[16]; + struct netpoll *np; + u16 group_fwd_mask; + u16 backup_redirected_cnt; + struct bridge_stp_xstats stp_xstats; +}; + +struct bridge_mcast_stats { + struct br_mcast_stats mstats; + struct u64_stats_sync syncp; +}; + +struct net_bridge { + spinlock_t lock; + spinlock_t hash_lock; + struct hlist_head frame_type_list; + struct net_device *dev; + struct pcpu_sw_netstats *stats; + long unsigned int options; + __be16 vlan_proto; + u16 default_pvid; + struct net_bridge_vlan_group *vlgrp; + struct rhashtable fdb_hash_tbl; + struct list_head port_list; + union { + struct rtable fake_rtable; + struct rt6_info fake_rt6_info; + }; + u16 group_fwd_mask; + u16 group_fwd_mask_required; + bridge_id designated_root; + bridge_id bridge_id; + unsigned char topology_change; + unsigned char topology_change_detected; + u16 root_port; + long unsigned int max_age; + long unsigned int hello_time; + long unsigned int forward_delay; + long unsigned int ageing_time; + long unsigned int bridge_max_age; + long unsigned int bridge_hello_time; + long unsigned int bridge_forward_delay; + long unsigned int bridge_ageing_time; + u32 root_path_cost; + u8 group_addr[6]; + enum { + BR_NO_STP = 0, + BR_KERNEL_STP = 1, + BR_USER_STP = 2, + } stp_enabled; + u32 hash_max; + u32 multicast_last_member_count; + u32 multicast_startup_query_count; + u8 multicast_igmp_version; + u8 multicast_router; + u8 multicast_mld_version; + spinlock_t multicast_lock; + long unsigned int multicast_last_member_interval; + long unsigned int multicast_membership_interval; + long unsigned int multicast_querier_interval; + long unsigned int multicast_query_interval; + long unsigned int multicast_query_response_interval; + long unsigned int multicast_startup_query_interval; + struct rhashtable mdb_hash_tbl; + struct rhashtable sg_port_tbl; + struct hlist_head mcast_gc_list; + struct hlist_head mdb_list; + struct hlist_head router_list; + struct timer_list multicast_router_timer; + struct bridge_mcast_other_query ip4_other_query; + struct bridge_mcast_own_query ip4_own_query; + struct bridge_mcast_querier ip4_querier; + struct bridge_mcast_stats *mcast_stats; + struct bridge_mcast_other_query ip6_other_query; + struct bridge_mcast_own_query ip6_own_query; + struct bridge_mcast_querier ip6_querier; + struct work_struct mcast_gc_work; + struct timer_list hello_timer; + struct timer_list tcn_timer; + struct timer_list topology_change_timer; + struct delayed_work gc_work; + struct kobject *ifobj; + u32 auto_cnt; + struct hlist_head fdb_list; +}; + +struct net_bridge_vlan_group { + struct rhashtable vlan_hash; + struct rhashtable tunnel_hash; + struct list_head vlan_list; + u16 num_vlans; + u16 pvid; + u8 pvid_state; +}; + +struct net_bridge_fdb_key { + mac_addr addr; + u16 vlan_id; +}; + +struct net_bridge_fdb_entry { + struct rhash_head rhnode; + struct net_bridge_port *dst; + struct net_bridge_fdb_key key; + struct hlist_node fdb_node; + long unsigned int flags; + long: 64; + long: 64; + long unsigned int updated; + long unsigned int used; + struct callback_head rcu; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct trace_event_raw_br_fdb_add { + struct trace_entry ent; + u8 ndm_flags; + u32 __data_loc_dev; + unsigned char addr[6]; + u16 vid; + u16 nlh_flags; + char __data[0]; +}; + +struct trace_event_raw_br_fdb_external_learn_add { + struct trace_entry ent; + u32 __data_loc_br_dev; + u32 __data_loc_dev; + unsigned char addr[6]; + u16 vid; + char __data[0]; +}; + +struct trace_event_raw_fdb_delete { + struct trace_entry ent; + u32 __data_loc_br_dev; + u32 __data_loc_dev; + unsigned char addr[6]; + u16 vid; + char __data[0]; +}; + +struct trace_event_raw_br_fdb_update { + struct trace_entry ent; + u32 __data_loc_br_dev; + u32 __data_loc_dev; + unsigned char addr[6]; + u16 vid; + long unsigned int flags; + char __data[0]; +}; + +struct trace_event_data_offsets_br_fdb_add { + u32 dev; +}; + +struct trace_event_data_offsets_br_fdb_external_learn_add { + u32 br_dev; + u32 dev; +}; + +struct trace_event_data_offsets_fdb_delete { + u32 br_dev; + u32 dev; +}; + +struct trace_event_data_offsets_br_fdb_update { + u32 br_dev; + u32 dev; +}; + +typedef void (*btf_trace_br_fdb_add)(void *, struct ndmsg *, struct net_device *, const unsigned char *, u16, u16); + +typedef void (*btf_trace_br_fdb_external_learn_add)(void *, struct net_bridge *, struct net_bridge_port *, const unsigned char *, u16); + +typedef void (*btf_trace_fdb_delete)(void *, struct net_bridge *, struct net_bridge_fdb_entry *); + +typedef void (*btf_trace_br_fdb_update)(void *, struct net_bridge *, struct net_bridge_port *, const unsigned char *, u16, long unsigned int); + +struct trace_event_raw_neigh_create { + struct trace_entry ent; + u32 family; + u32 __data_loc_dev; + int entries; + u8 created; + u8 gc_exempt; + u8 primary_key4[4]; + u8 primary_key6[16]; + char __data[0]; +}; + +struct trace_event_raw_neigh_update { + struct trace_entry ent; + u32 family; + u32 __data_loc_dev; + u8 lladdr[32]; + u8 lladdr_len; + u8 flags; + u8 nud_state; + u8 type; + u8 dead; + int refcnt; + __u8 primary_key4[4]; + __u8 primary_key6[16]; + long unsigned int confirmed; + long unsigned int updated; + long unsigned int used; + u8 new_lladdr[32]; + u8 new_state; + u32 update_flags; + u32 pid; + char __data[0]; +}; + +struct trace_event_raw_neigh__update { + struct trace_entry ent; + u32 family; + u32 __data_loc_dev; + u8 lladdr[32]; + u8 lladdr_len; + u8 flags; + u8 nud_state; + u8 type; + u8 dead; + int refcnt; + __u8 primary_key4[4]; + __u8 primary_key6[16]; + long unsigned int confirmed; + long unsigned int updated; + long unsigned int used; + u32 err; + char __data[0]; +}; + +struct trace_event_data_offsets_neigh_create { + u32 dev; +}; + +struct trace_event_data_offsets_neigh_update { + u32 dev; +}; + +struct trace_event_data_offsets_neigh__update { + u32 dev; +}; + +typedef void (*btf_trace_neigh_create)(void *, struct neigh_table *, struct net_device *, const void *, const struct neighbour *, bool); + +typedef void (*btf_trace_neigh_update)(void *, struct neighbour *, const u8 *, u8, u32, u32); + +typedef void (*btf_trace_neigh_update_done)(void *, struct neighbour *, int); + +typedef void (*btf_trace_neigh_timer_handler)(void *, struct neighbour *, int); + +typedef void (*btf_trace_neigh_event_send_done)(void *, struct neighbour *, int); + +typedef void (*btf_trace_neigh_event_send_dead)(void *, struct neighbour *, int); + +typedef void (*btf_trace_neigh_cleanup_and_release)(void *, struct neighbour *, int); + +struct clock_identity { + u8 id[8]; +}; + +struct port_identity { + struct clock_identity clock_identity; + __be16 port_number; +}; + +struct ptp_header { + u8 tsmt; + u8 ver; + __be16 message_length; + u8 domain_number; + u8 reserved1; + u8 flag_field[2]; + __be64 correction; + __be32 reserved2; + struct port_identity source_port_identity; + __be16 sequence_id; + u8 control; + u8 log_message_interval; +} __attribute__((packed)); + +struct update_classid_context { + u32 classid; + unsigned int batch; +}; + +enum lwtunnel_encap_types { + LWTUNNEL_ENCAP_NONE = 0, + LWTUNNEL_ENCAP_MPLS = 1, + LWTUNNEL_ENCAP_IP = 2, + LWTUNNEL_ENCAP_ILA = 3, + LWTUNNEL_ENCAP_IP6 = 4, + LWTUNNEL_ENCAP_SEG6 = 5, + LWTUNNEL_ENCAP_BPF = 6, + LWTUNNEL_ENCAP_SEG6_LOCAL = 7, + LWTUNNEL_ENCAP_RPL = 8, + __LWTUNNEL_ENCAP_MAX = 9, +}; + +struct rtnexthop { + short unsigned int rtnh_len; + unsigned char rtnh_flags; + unsigned char rtnh_hops; + int rtnh_ifindex; +}; + +struct lwtunnel_encap_ops { + int (*build_state)(struct net *, struct nlattr *, unsigned int, const void *, struct lwtunnel_state **, struct netlink_ext_ack *); + void (*destroy_state)(struct lwtunnel_state *); + int (*output)(struct net *, struct sock *, struct sk_buff *); + int (*input)(struct sk_buff *); + int (*fill_encap)(struct sk_buff *, struct lwtunnel_state *); + int (*get_encap_size)(struct lwtunnel_state *); + int (*cmp_encap)(struct lwtunnel_state *, struct lwtunnel_state *); + int (*xmit)(struct sk_buff *); + struct module *owner; +}; + +enum { + LWT_BPF_PROG_UNSPEC = 0, + LWT_BPF_PROG_FD = 1, + LWT_BPF_PROG_NAME = 2, + __LWT_BPF_PROG_MAX = 3, +}; + +enum { + LWT_BPF_UNSPEC = 0, + LWT_BPF_IN = 1, + LWT_BPF_OUT = 2, + LWT_BPF_XMIT = 3, + LWT_BPF_XMIT_HEADROOM = 4, + __LWT_BPF_MAX = 5, +}; + +enum { + LWTUNNEL_XMIT_DONE = 0, + LWTUNNEL_XMIT_CONTINUE = 1, +}; + +struct bpf_lwt_prog { + struct bpf_prog *prog; + char *name; +}; + +struct bpf_lwt { + struct bpf_lwt_prog in; + struct bpf_lwt_prog out; + struct bpf_lwt_prog xmit; + int family; +}; + +struct bpf_stab { + struct bpf_map map; + struct sock **sks; + struct sk_psock_progs progs; + raw_spinlock_t lock; + long: 64; +}; + +typedef u64 (*btf_bpf_sock_map_update)(struct bpf_sock_ops_kern *, struct bpf_map *, void *, u64); + +typedef u64 (*btf_bpf_sk_redirect_map)(struct sk_buff *, struct bpf_map *, u32, u64); + +typedef u64 (*btf_bpf_msg_redirect_map)(struct sk_msg *, struct bpf_map *, u32, u64); + +struct sock_map_seq_info { + struct bpf_map *map; + struct sock *sk; + u32 index; +}; + +struct bpf_iter__sockmap { + union { + struct bpf_iter_meta *meta; + }; + union { + struct bpf_map *map; + }; + union { + void *key; + }; + union { + struct sock *sk; + }; +}; + +struct bpf_shtab_elem { + struct callback_head rcu; + u32 hash; + struct sock *sk; + struct hlist_node node; + u8 key[0]; +}; + +struct bpf_shtab_bucket { + struct hlist_head head; + raw_spinlock_t lock; +}; + +struct bpf_shtab { + struct bpf_map map; + struct bpf_shtab_bucket *buckets; + u32 buckets_num; + u32 elem_size; + struct sk_psock_progs progs; + atomic_t count; + long: 32; + long: 64; + long: 64; +}; + +typedef u64 (*btf_bpf_sock_hash_update)(struct bpf_sock_ops_kern *, struct bpf_map *, void *, u64); + +typedef u64 (*btf_bpf_sk_redirect_hash)(struct sk_buff *, struct bpf_map *, void *, u64); + +typedef u64 (*btf_bpf_msg_redirect_hash)(struct sk_msg *, struct bpf_map *, void *, u64); + +struct sock_hash_seq_info { + struct bpf_map *map; + struct bpf_shtab *htab; + u32 bucket_id; +}; + +struct dst_cache_pcpu { + long unsigned int refresh_ts; + struct dst_entry *dst; + u32 cookie; + union { + struct in_addr in_saddr; + struct in6_addr in6_saddr; + }; +}; + +struct genl_dumpit_info { + const struct genl_family *family; + struct genl_ops op; + struct nlattr **attrs; +}; + +enum devlink_command { + DEVLINK_CMD_UNSPEC = 0, + DEVLINK_CMD_GET = 1, + DEVLINK_CMD_SET = 2, + DEVLINK_CMD_NEW = 3, + DEVLINK_CMD_DEL = 4, + DEVLINK_CMD_PORT_GET = 5, + DEVLINK_CMD_PORT_SET = 6, + DEVLINK_CMD_PORT_NEW = 7, + DEVLINK_CMD_PORT_DEL = 8, + DEVLINK_CMD_PORT_SPLIT = 9, + DEVLINK_CMD_PORT_UNSPLIT = 10, + DEVLINK_CMD_SB_GET = 11, + DEVLINK_CMD_SB_SET = 12, + DEVLINK_CMD_SB_NEW = 13, + DEVLINK_CMD_SB_DEL = 14, + DEVLINK_CMD_SB_POOL_GET = 15, + DEVLINK_CMD_SB_POOL_SET = 16, + DEVLINK_CMD_SB_POOL_NEW = 17, + DEVLINK_CMD_SB_POOL_DEL = 18, + DEVLINK_CMD_SB_PORT_POOL_GET = 19, + DEVLINK_CMD_SB_PORT_POOL_SET = 20, + DEVLINK_CMD_SB_PORT_POOL_NEW = 21, + DEVLINK_CMD_SB_PORT_POOL_DEL = 22, + DEVLINK_CMD_SB_TC_POOL_BIND_GET = 23, + DEVLINK_CMD_SB_TC_POOL_BIND_SET = 24, + DEVLINK_CMD_SB_TC_POOL_BIND_NEW = 25, + DEVLINK_CMD_SB_TC_POOL_BIND_DEL = 26, + DEVLINK_CMD_SB_OCC_SNAPSHOT = 27, + DEVLINK_CMD_SB_OCC_MAX_CLEAR = 28, + DEVLINK_CMD_ESWITCH_GET = 29, + DEVLINK_CMD_ESWITCH_SET = 30, + DEVLINK_CMD_DPIPE_TABLE_GET = 31, + DEVLINK_CMD_DPIPE_ENTRIES_GET = 32, + DEVLINK_CMD_DPIPE_HEADERS_GET = 33, + DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET = 34, + DEVLINK_CMD_RESOURCE_SET = 35, + DEVLINK_CMD_RESOURCE_DUMP = 36, + DEVLINK_CMD_RELOAD = 37, + DEVLINK_CMD_PARAM_GET = 38, + DEVLINK_CMD_PARAM_SET = 39, + DEVLINK_CMD_PARAM_NEW = 40, + DEVLINK_CMD_PARAM_DEL = 41, + DEVLINK_CMD_REGION_GET = 42, + DEVLINK_CMD_REGION_SET = 43, + DEVLINK_CMD_REGION_NEW = 44, + DEVLINK_CMD_REGION_DEL = 45, + DEVLINK_CMD_REGION_READ = 46, + DEVLINK_CMD_PORT_PARAM_GET = 47, + DEVLINK_CMD_PORT_PARAM_SET = 48, + DEVLINK_CMD_PORT_PARAM_NEW = 49, + DEVLINK_CMD_PORT_PARAM_DEL = 50, + DEVLINK_CMD_INFO_GET = 51, + DEVLINK_CMD_HEALTH_REPORTER_GET = 52, + DEVLINK_CMD_HEALTH_REPORTER_SET = 53, + DEVLINK_CMD_HEALTH_REPORTER_RECOVER = 54, + DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE = 55, + DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET = 56, + DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR = 57, + DEVLINK_CMD_FLASH_UPDATE = 58, + DEVLINK_CMD_FLASH_UPDATE_END = 59, + DEVLINK_CMD_FLASH_UPDATE_STATUS = 60, + DEVLINK_CMD_TRAP_GET = 61, + DEVLINK_CMD_TRAP_SET = 62, + DEVLINK_CMD_TRAP_NEW = 63, + DEVLINK_CMD_TRAP_DEL = 64, + DEVLINK_CMD_TRAP_GROUP_GET = 65, + DEVLINK_CMD_TRAP_GROUP_SET = 66, + DEVLINK_CMD_TRAP_GROUP_NEW = 67, + DEVLINK_CMD_TRAP_GROUP_DEL = 68, + DEVLINK_CMD_TRAP_POLICER_GET = 69, + DEVLINK_CMD_TRAP_POLICER_SET = 70, + DEVLINK_CMD_TRAP_POLICER_NEW = 71, + DEVLINK_CMD_TRAP_POLICER_DEL = 72, + DEVLINK_CMD_HEALTH_REPORTER_TEST = 73, + __DEVLINK_CMD_MAX = 74, + DEVLINK_CMD_MAX = 73, +}; + +enum { + DEVLINK_ATTR_STATS_RX_PACKETS = 0, + DEVLINK_ATTR_STATS_RX_BYTES = 1, + DEVLINK_ATTR_STATS_RX_DROPPED = 2, + __DEVLINK_ATTR_STATS_MAX = 3, + DEVLINK_ATTR_STATS_MAX = 2, +}; + +enum { + DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT = 0, + DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT = 1, + __DEVLINK_FLASH_OVERWRITE_MAX_BIT = 2, + DEVLINK_FLASH_OVERWRITE_MAX_BIT = 1, +}; + +enum { + DEVLINK_ATTR_TRAP_METADATA_TYPE_IN_PORT = 0, + DEVLINK_ATTR_TRAP_METADATA_TYPE_FA_COOKIE = 1, +}; + +enum devlink_attr { + DEVLINK_ATTR_UNSPEC = 0, + DEVLINK_ATTR_BUS_NAME = 1, + DEVLINK_ATTR_DEV_NAME = 2, + DEVLINK_ATTR_PORT_INDEX = 3, + DEVLINK_ATTR_PORT_TYPE = 4, + DEVLINK_ATTR_PORT_DESIRED_TYPE = 5, + DEVLINK_ATTR_PORT_NETDEV_IFINDEX = 6, + DEVLINK_ATTR_PORT_NETDEV_NAME = 7, + DEVLINK_ATTR_PORT_IBDEV_NAME = 8, + DEVLINK_ATTR_PORT_SPLIT_COUNT = 9, + DEVLINK_ATTR_PORT_SPLIT_GROUP = 10, + DEVLINK_ATTR_SB_INDEX = 11, + DEVLINK_ATTR_SB_SIZE = 12, + DEVLINK_ATTR_SB_INGRESS_POOL_COUNT = 13, + DEVLINK_ATTR_SB_EGRESS_POOL_COUNT = 14, + DEVLINK_ATTR_SB_INGRESS_TC_COUNT = 15, + DEVLINK_ATTR_SB_EGRESS_TC_COUNT = 16, + DEVLINK_ATTR_SB_POOL_INDEX = 17, + DEVLINK_ATTR_SB_POOL_TYPE = 18, + DEVLINK_ATTR_SB_POOL_SIZE = 19, + DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE = 20, + DEVLINK_ATTR_SB_THRESHOLD = 21, + DEVLINK_ATTR_SB_TC_INDEX = 22, + DEVLINK_ATTR_SB_OCC_CUR = 23, + DEVLINK_ATTR_SB_OCC_MAX = 24, + DEVLINK_ATTR_ESWITCH_MODE = 25, + DEVLINK_ATTR_ESWITCH_INLINE_MODE = 26, + DEVLINK_ATTR_DPIPE_TABLES = 27, + DEVLINK_ATTR_DPIPE_TABLE = 28, + DEVLINK_ATTR_DPIPE_TABLE_NAME = 29, + DEVLINK_ATTR_DPIPE_TABLE_SIZE = 30, + DEVLINK_ATTR_DPIPE_TABLE_MATCHES = 31, + DEVLINK_ATTR_DPIPE_TABLE_ACTIONS = 32, + DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED = 33, + DEVLINK_ATTR_DPIPE_ENTRIES = 34, + DEVLINK_ATTR_DPIPE_ENTRY = 35, + DEVLINK_ATTR_DPIPE_ENTRY_INDEX = 36, + DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES = 37, + DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES = 38, + DEVLINK_ATTR_DPIPE_ENTRY_COUNTER = 39, + DEVLINK_ATTR_DPIPE_MATCH = 40, + DEVLINK_ATTR_DPIPE_MATCH_VALUE = 41, + DEVLINK_ATTR_DPIPE_MATCH_TYPE = 42, + DEVLINK_ATTR_DPIPE_ACTION = 43, + DEVLINK_ATTR_DPIPE_ACTION_VALUE = 44, + DEVLINK_ATTR_DPIPE_ACTION_TYPE = 45, + DEVLINK_ATTR_DPIPE_VALUE = 46, + DEVLINK_ATTR_DPIPE_VALUE_MASK = 47, + DEVLINK_ATTR_DPIPE_VALUE_MAPPING = 48, + DEVLINK_ATTR_DPIPE_HEADERS = 49, + DEVLINK_ATTR_DPIPE_HEADER = 50, + DEVLINK_ATTR_DPIPE_HEADER_NAME = 51, + DEVLINK_ATTR_DPIPE_HEADER_ID = 52, + DEVLINK_ATTR_DPIPE_HEADER_FIELDS = 53, + DEVLINK_ATTR_DPIPE_HEADER_GLOBAL = 54, + DEVLINK_ATTR_DPIPE_HEADER_INDEX = 55, + DEVLINK_ATTR_DPIPE_FIELD = 56, + DEVLINK_ATTR_DPIPE_FIELD_NAME = 57, + DEVLINK_ATTR_DPIPE_FIELD_ID = 58, + DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH = 59, + DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE = 60, + DEVLINK_ATTR_PAD = 61, + DEVLINK_ATTR_ESWITCH_ENCAP_MODE = 62, + DEVLINK_ATTR_RESOURCE_LIST = 63, + DEVLINK_ATTR_RESOURCE = 64, + DEVLINK_ATTR_RESOURCE_NAME = 65, + DEVLINK_ATTR_RESOURCE_ID = 66, + DEVLINK_ATTR_RESOURCE_SIZE = 67, + DEVLINK_ATTR_RESOURCE_SIZE_NEW = 68, + DEVLINK_ATTR_RESOURCE_SIZE_VALID = 69, + DEVLINK_ATTR_RESOURCE_SIZE_MIN = 70, + DEVLINK_ATTR_RESOURCE_SIZE_MAX = 71, + DEVLINK_ATTR_RESOURCE_SIZE_GRAN = 72, + DEVLINK_ATTR_RESOURCE_UNIT = 73, + DEVLINK_ATTR_RESOURCE_OCC = 74, + DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID = 75, + DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS = 76, + DEVLINK_ATTR_PORT_FLAVOUR = 77, + DEVLINK_ATTR_PORT_NUMBER = 78, + DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER = 79, + DEVLINK_ATTR_PARAM = 80, + DEVLINK_ATTR_PARAM_NAME = 81, + DEVLINK_ATTR_PARAM_GENERIC = 82, + DEVLINK_ATTR_PARAM_TYPE = 83, + DEVLINK_ATTR_PARAM_VALUES_LIST = 84, + DEVLINK_ATTR_PARAM_VALUE = 85, + DEVLINK_ATTR_PARAM_VALUE_DATA = 86, + DEVLINK_ATTR_PARAM_VALUE_CMODE = 87, + DEVLINK_ATTR_REGION_NAME = 88, + DEVLINK_ATTR_REGION_SIZE = 89, + DEVLINK_ATTR_REGION_SNAPSHOTS = 90, + DEVLINK_ATTR_REGION_SNAPSHOT = 91, + DEVLINK_ATTR_REGION_SNAPSHOT_ID = 92, + DEVLINK_ATTR_REGION_CHUNKS = 93, + DEVLINK_ATTR_REGION_CHUNK = 94, + DEVLINK_ATTR_REGION_CHUNK_DATA = 95, + DEVLINK_ATTR_REGION_CHUNK_ADDR = 96, + DEVLINK_ATTR_REGION_CHUNK_LEN = 97, + DEVLINK_ATTR_INFO_DRIVER_NAME = 98, + DEVLINK_ATTR_INFO_SERIAL_NUMBER = 99, + DEVLINK_ATTR_INFO_VERSION_FIXED = 100, + DEVLINK_ATTR_INFO_VERSION_RUNNING = 101, + DEVLINK_ATTR_INFO_VERSION_STORED = 102, + DEVLINK_ATTR_INFO_VERSION_NAME = 103, + DEVLINK_ATTR_INFO_VERSION_VALUE = 104, + DEVLINK_ATTR_SB_POOL_CELL_SIZE = 105, + DEVLINK_ATTR_FMSG = 106, + DEVLINK_ATTR_FMSG_OBJ_NEST_START = 107, + DEVLINK_ATTR_FMSG_PAIR_NEST_START = 108, + DEVLINK_ATTR_FMSG_ARR_NEST_START = 109, + DEVLINK_ATTR_FMSG_NEST_END = 110, + DEVLINK_ATTR_FMSG_OBJ_NAME = 111, + DEVLINK_ATTR_FMSG_OBJ_VALUE_TYPE = 112, + DEVLINK_ATTR_FMSG_OBJ_VALUE_DATA = 113, + DEVLINK_ATTR_HEALTH_REPORTER = 114, + DEVLINK_ATTR_HEALTH_REPORTER_NAME = 115, + DEVLINK_ATTR_HEALTH_REPORTER_STATE = 116, + DEVLINK_ATTR_HEALTH_REPORTER_ERR_COUNT = 117, + DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT = 118, + DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS = 119, + DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD = 120, + DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER = 121, + DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME = 122, + DEVLINK_ATTR_FLASH_UPDATE_COMPONENT = 123, + DEVLINK_ATTR_FLASH_UPDATE_STATUS_MSG = 124, + DEVLINK_ATTR_FLASH_UPDATE_STATUS_DONE = 125, + DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL = 126, + DEVLINK_ATTR_PORT_PCI_PF_NUMBER = 127, + DEVLINK_ATTR_PORT_PCI_VF_NUMBER = 128, + DEVLINK_ATTR_STATS = 129, + DEVLINK_ATTR_TRAP_NAME = 130, + DEVLINK_ATTR_TRAP_ACTION = 131, + DEVLINK_ATTR_TRAP_TYPE = 132, + DEVLINK_ATTR_TRAP_GENERIC = 133, + DEVLINK_ATTR_TRAP_METADATA = 134, + DEVLINK_ATTR_TRAP_GROUP_NAME = 135, + DEVLINK_ATTR_RELOAD_FAILED = 136, + DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS_NS = 137, + DEVLINK_ATTR_NETNS_FD = 138, + DEVLINK_ATTR_NETNS_PID = 139, + DEVLINK_ATTR_NETNS_ID = 140, + DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP = 141, + DEVLINK_ATTR_TRAP_POLICER_ID = 142, + DEVLINK_ATTR_TRAP_POLICER_RATE = 143, + DEVLINK_ATTR_TRAP_POLICER_BURST = 144, + DEVLINK_ATTR_PORT_FUNCTION = 145, + DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER = 146, + DEVLINK_ATTR_PORT_LANES = 147, + DEVLINK_ATTR_PORT_SPLITTABLE = 148, + DEVLINK_ATTR_PORT_EXTERNAL = 149, + DEVLINK_ATTR_PORT_CONTROLLER_NUMBER = 150, + DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT = 151, + DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK = 152, + DEVLINK_ATTR_RELOAD_ACTION = 153, + DEVLINK_ATTR_RELOAD_ACTIONS_PERFORMED = 154, + DEVLINK_ATTR_RELOAD_LIMITS = 155, + DEVLINK_ATTR_DEV_STATS = 156, + DEVLINK_ATTR_RELOAD_STATS = 157, + DEVLINK_ATTR_RELOAD_STATS_ENTRY = 158, + DEVLINK_ATTR_RELOAD_STATS_LIMIT = 159, + DEVLINK_ATTR_RELOAD_STATS_VALUE = 160, + DEVLINK_ATTR_REMOTE_RELOAD_STATS = 161, + __DEVLINK_ATTR_MAX = 162, + DEVLINK_ATTR_MAX = 161, +}; + +enum devlink_dpipe_match_type { + DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0, +}; + +enum devlink_dpipe_action_type { + DEVLINK_DPIPE_ACTION_TYPE_FIELD_MODIFY = 0, +}; + +enum devlink_dpipe_field_ethernet_id { + DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC = 0, +}; + +enum devlink_dpipe_field_ipv4_id { + DEVLINK_DPIPE_FIELD_IPV4_DST_IP = 0, +}; + +enum devlink_dpipe_field_ipv6_id { + DEVLINK_DPIPE_FIELD_IPV6_DST_IP = 0, +}; + +enum devlink_dpipe_header_id { + DEVLINK_DPIPE_HEADER_ETHERNET = 0, + DEVLINK_DPIPE_HEADER_IPV4 = 1, + DEVLINK_DPIPE_HEADER_IPV6 = 2, +}; + +enum devlink_port_function_attr { + DEVLINK_PORT_FUNCTION_ATTR_UNSPEC = 0, + DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR = 1, + __DEVLINK_PORT_FUNCTION_ATTR_MAX = 2, + DEVLINK_PORT_FUNCTION_ATTR_MAX = 1, +}; + +struct devlink_dpipe_match { + enum devlink_dpipe_match_type type; + unsigned int header_index; + struct devlink_dpipe_header *header; + unsigned int field_id; +}; + +struct devlink_dpipe_action { + enum devlink_dpipe_action_type type; + unsigned int header_index; + struct devlink_dpipe_header *header; + unsigned int field_id; +}; + +struct devlink_dpipe_value { + union { + struct devlink_dpipe_action *action; + struct devlink_dpipe_match *match; + }; + unsigned int mapping_value; + bool mapping_valid; + unsigned int value_size; + void *value; + void *mask; +}; + +struct devlink_dpipe_entry { + u64 index; + struct devlink_dpipe_value *match_values; + unsigned int match_values_count; + struct devlink_dpipe_value *action_values; + unsigned int action_values_count; + u64 counter; + bool counter_valid; +}; + +struct devlink_dpipe_dump_ctx { + struct genl_info *info; + enum devlink_command cmd; + struct sk_buff *skb; + struct nlattr *nest; + void *hdr; +}; + +struct devlink_dpipe_table_ops; + +struct devlink_dpipe_table { + void *priv; + struct list_head list; + const char *name; + bool counters_enabled; + bool counter_control_extern; + bool resource_valid; + u64 resource_id; + u64 resource_units; + struct devlink_dpipe_table_ops *table_ops; + struct callback_head rcu; +}; + +struct devlink_dpipe_table_ops { + int (*actions_dump)(void *, struct sk_buff *); + int (*matches_dump)(void *, struct sk_buff *); + int (*entries_dump)(void *, bool, struct devlink_dpipe_dump_ctx *); + int (*counters_set_update)(void *, bool); + u64 (*size_get)(void *); +}; + +typedef u64 devlink_resource_occ_get_t(void *); + +struct devlink_resource { + const char *name; + u64 id; + u64 size; + u64 size_new; + bool size_valid; + struct devlink_resource *parent; + struct devlink_resource_size_params size_params; + struct list_head list; + struct list_head resource_list; + devlink_resource_occ_get_t *occ_get; + void *occ_get_priv; +}; + +struct devlink_flash_notify { + const char *status_msg; + const char *component; + long unsigned int done; + long unsigned int total; + long unsigned int timeout; +}; + +struct devlink_param_item { + struct list_head list; + const struct devlink_param *param; + union devlink_param_value driverinit_value; + bool driverinit_value_valid; + bool published; +}; + +struct devlink_port_region_ops { + const char *name; + void (*destructor)(const void *); + int (*snapshot)(struct devlink_port *, const struct devlink_port_region_ops *, struct netlink_ext_ack *, u8 **); + void *priv; +}; + +enum devlink_health_reporter_state { + DEVLINK_HEALTH_REPORTER_STATE_HEALTHY = 0, + DEVLINK_HEALTH_REPORTER_STATE_ERROR = 1, +}; + +struct devlink_health_reporter { + struct list_head list; + void *priv; + const struct devlink_health_reporter_ops *ops; + struct devlink *devlink; + struct devlink_port *devlink_port; + struct devlink_fmsg *dump_fmsg; + struct mutex dump_lock; + u64 graceful_period; + bool auto_recover; + bool auto_dump; + u8 health_state; + u64 dump_ts; + u64 dump_real_ts; + u64 error_count; + u64 recovery_count; + u64 last_recovery_ts; + refcount_t refcount; +}; + +struct devlink_fmsg { + struct list_head item_list; + bool putting_binary; +}; + +struct devlink_trap_metadata { + const char *trap_name; + const char *trap_group_name; + struct net_device *input_dev; + const struct flow_action_cookie *fa_cookie; + enum devlink_trap_type trap_type; +}; + +struct devlink_info_req { + struct sk_buff *msg; +}; + +struct trace_event_raw_devlink_hwmsg { + struct trace_entry ent; + u32 __data_loc_bus_name; + u32 __data_loc_dev_name; + u32 __data_loc_driver_name; + bool incoming; + long unsigned int type; + u32 __data_loc_buf; + size_t len; + char __data[0]; +}; + +struct trace_event_raw_devlink_hwerr { + struct trace_entry ent; + u32 __data_loc_bus_name; + u32 __data_loc_dev_name; + u32 __data_loc_driver_name; + int err; + u32 __data_loc_msg; + char __data[0]; +}; + +struct trace_event_raw_devlink_health_report { + struct trace_entry ent; + u32 __data_loc_bus_name; + u32 __data_loc_dev_name; + u32 __data_loc_driver_name; + u32 __data_loc_reporter_name; + u32 __data_loc_msg; + char __data[0]; +}; + +struct trace_event_raw_devlink_health_recover_aborted { + struct trace_entry ent; + u32 __data_loc_bus_name; + u32 __data_loc_dev_name; + u32 __data_loc_driver_name; + u32 __data_loc_reporter_name; + bool health_state; + u64 time_since_last_recover; + char __data[0]; +}; + +struct trace_event_raw_devlink_health_reporter_state_update { + struct trace_entry ent; + u32 __data_loc_bus_name; + u32 __data_loc_dev_name; + u32 __data_loc_driver_name; + u32 __data_loc_reporter_name; + u8 new_state; + char __data[0]; +}; + +struct trace_event_raw_devlink_trap_report { + struct trace_entry ent; + u32 __data_loc_bus_name; + u32 __data_loc_dev_name; + u32 __data_loc_driver_name; + u32 __data_loc_trap_name; + u32 __data_loc_trap_group_name; + u32 __data_loc_input_dev_name; + char __data[0]; +}; + +struct trace_event_data_offsets_devlink_hwmsg { + u32 bus_name; + u32 dev_name; + u32 driver_name; + u32 buf; +}; + +struct trace_event_data_offsets_devlink_hwerr { + u32 bus_name; + u32 dev_name; + u32 driver_name; + u32 msg; +}; + +struct trace_event_data_offsets_devlink_health_report { + u32 bus_name; + u32 dev_name; + u32 driver_name; + u32 reporter_name; + u32 msg; +}; + +struct trace_event_data_offsets_devlink_health_recover_aborted { + u32 bus_name; + u32 dev_name; + u32 driver_name; + u32 reporter_name; +}; + +struct trace_event_data_offsets_devlink_health_reporter_state_update { + u32 bus_name; + u32 dev_name; + u32 driver_name; + u32 reporter_name; +}; + +struct trace_event_data_offsets_devlink_trap_report { + u32 bus_name; + u32 dev_name; + u32 driver_name; + u32 trap_name; + u32 trap_group_name; + u32 input_dev_name; +}; + +typedef void (*btf_trace_devlink_hwmsg)(void *, const struct devlink *, bool, long unsigned int, const u8 *, size_t); + +typedef void (*btf_trace_devlink_hwerr)(void *, const struct devlink *, int, const char *); + +typedef void (*btf_trace_devlink_health_report)(void *, const struct devlink *, const char *, const char *); + +typedef void (*btf_trace_devlink_health_recover_aborted)(void *, const struct devlink *, const char *, bool, u64); + +typedef void (*btf_trace_devlink_health_reporter_state_update)(void *, const struct devlink *, const char *, bool); + +typedef void (*btf_trace_devlink_trap_report)(void *, const struct devlink *, struct sk_buff *, const struct devlink_trap_metadata *); + +struct devlink_sb { + struct list_head list; + unsigned int index; + u32 size; + u16 ingress_pools_count; + u16 egress_pools_count; + u16 ingress_tc_count; + u16 egress_tc_count; +}; + +struct devlink_region___2 { + struct devlink *devlink; + struct devlink_port *port; + struct list_head list; + union { + const struct devlink_region_ops *ops; + const struct devlink_port_region_ops *port_ops; + }; + struct list_head snapshot_list; + u32 max_snapshots; + u32 cur_snapshots; + u64 size; +}; + +struct devlink_snapshot { + struct list_head list; + struct devlink_region___2 *region; + u8 *data; + u32 id; +}; + +enum devlink_multicast_groups { + DEVLINK_MCGRP_CONFIG = 0, +}; + +struct devlink_reload_combination { + enum devlink_reload_action action; + enum devlink_reload_limit limit; +}; + +struct devlink_fmsg_item { + struct list_head list; + int attrtype; + u8 nla_type; + u16 len; + int value[0]; +}; + +struct devlink_stats { + u64 rx_bytes; + u64 rx_packets; + struct u64_stats_sync syncp; +}; + +struct devlink_trap_policer_item { + const struct devlink_trap_policer *policer; + u64 rate; + u64 burst; + struct list_head list; +}; + +struct devlink_trap_group_item { + const struct devlink_trap_group *group; + struct devlink_trap_policer_item *policer_item; + struct list_head list; + struct devlink_stats *stats; +}; + +struct devlink_trap_item { + const struct devlink_trap *trap; + struct devlink_trap_group_item *group_item; + struct list_head list; + enum devlink_trap_action action; + struct devlink_stats *stats; + void *priv; +}; + +struct gro_cell { + struct sk_buff_head napi_skbs; + struct napi_struct napi; +}; + +enum netdev_lag_tx_type { + NETDEV_LAG_TX_TYPE_UNKNOWN = 0, + NETDEV_LAG_TX_TYPE_RANDOM = 1, + NETDEV_LAG_TX_TYPE_BROADCAST = 2, + NETDEV_LAG_TX_TYPE_ROUNDROBIN = 3, + NETDEV_LAG_TX_TYPE_ACTIVEBACKUP = 4, + NETDEV_LAG_TX_TYPE_HASH = 5, +}; + +enum netdev_lag_hash { + NETDEV_LAG_HASH_NONE = 0, + NETDEV_LAG_HASH_L2 = 1, + NETDEV_LAG_HASH_L34 = 2, + NETDEV_LAG_HASH_L23 = 3, + NETDEV_LAG_HASH_E23 = 4, + NETDEV_LAG_HASH_E34 = 5, + NETDEV_LAG_HASH_UNKNOWN = 6, +}; + +struct netdev_lag_upper_info { + enum netdev_lag_tx_type tx_type; + enum netdev_lag_hash hash_type; +}; + +enum { + SK_DIAG_BPF_STORAGE_REQ_NONE = 0, + SK_DIAG_BPF_STORAGE_REQ_MAP_FD = 1, + __SK_DIAG_BPF_STORAGE_REQ_MAX = 2, +}; + +enum { + SK_DIAG_BPF_STORAGE_REP_NONE = 0, + SK_DIAG_BPF_STORAGE = 1, + __SK_DIAG_BPF_STORAGE_REP_MAX = 2, +}; + +enum { + SK_DIAG_BPF_STORAGE_NONE = 0, + SK_DIAG_BPF_STORAGE_PAD = 1, + SK_DIAG_BPF_STORAGE_MAP_ID = 2, + SK_DIAG_BPF_STORAGE_MAP_VALUE = 3, + __SK_DIAG_BPF_STORAGE_MAX = 4, +}; + +typedef u64 (*btf_bpf_sk_storage_get)(struct bpf_map *, struct sock *, void *, u64); + +typedef u64 (*btf_bpf_sk_storage_delete)(struct bpf_map *, struct sock *); + +typedef u64 (*btf_bpf_sk_storage_get_tracing)(struct bpf_map *, struct sock *, void *, u64); + +typedef u64 (*btf_bpf_sk_storage_delete_tracing)(struct bpf_map *, struct sock *); + +struct bpf_sk_storage_diag { + u32 nr_maps; + struct bpf_map *maps[0]; +}; + +struct bpf_iter_seq_sk_storage_map_info { + struct bpf_map *map; + unsigned int bucket_id; + unsigned int skip_elems; +}; + +struct bpf_iter__bpf_sk_storage_map { + union { + struct bpf_iter_meta *meta; + }; + union { + struct bpf_map *map; + }; + union { + struct sock *sk; + }; + union { + void *value; + }; +}; + +struct compat_cmsghdr { + compat_size_t cmsg_len; + compat_int_t cmsg_level; + compat_int_t cmsg_type; +}; + +struct llc_addr { + unsigned char lsap; + unsigned char mac[6]; +}; + +struct llc_sap { + unsigned char state; + unsigned char p_bit; + unsigned char f_bit; + refcount_t refcnt; + int (*rcv_func)(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); + struct llc_addr laddr; + struct list_head node; + spinlock_t sk_lock; + int sk_count; + struct hlist_nulls_head sk_laddr_hash[64]; + struct hlist_head sk_dev_hash[64]; + struct callback_head rcu; +}; + +struct llc_pdu_sn { + u8 dsap; + u8 ssap; + u8 ctrl_1; + u8 ctrl_2; +}; + +struct llc_pdu_un { + u8 dsap; + u8 ssap; + u8 ctrl_1; +}; + +struct nvmem_cell___2; + +struct datalink_proto { + unsigned char type[8]; + struct llc_sap *sap; + short unsigned int header_length; + int (*rcvfunc)(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); + int (*request)(struct datalink_proto *, struct sk_buff *, unsigned char *); + struct list_head node; +}; + +struct fch_hdr { + __u8 daddr[6]; + __u8 saddr[6]; +}; + +struct fcllc { + __u8 dsap; + __u8 ssap; + __u8 llc; + __u8 protid[3]; + __be16 ethertype; +}; + +struct stp_proto { + unsigned char group_address[6]; + void (*rcv)(const struct stp_proto *, struct sk_buff *, struct net_device *); + void *data; +}; + +struct tc_ratespec { + unsigned char cell_log; + __u8 linklayer; + short unsigned int overhead; + short int cell_align; + short unsigned int mpu; + __u32 rate; +}; + +struct tc_prio_qopt { + int bands; + __u8 priomap[16]; +}; + +enum { + TCA_UNSPEC = 0, + TCA_KIND = 1, + TCA_OPTIONS = 2, + TCA_STATS = 3, + TCA_XSTATS = 4, + TCA_RATE = 5, + TCA_FCNT = 6, + TCA_STATS2 = 7, + TCA_STAB = 8, + TCA_PAD = 9, + TCA_DUMP_INVISIBLE = 10, + TCA_CHAIN = 11, + TCA_HW_OFFLOAD = 12, + TCA_INGRESS_BLOCK = 13, + TCA_EGRESS_BLOCK = 14, + TCA_DUMP_FLAGS = 15, + __TCA_MAX = 16, +}; + +struct skb_array { + struct ptr_ring ring; +}; + +struct psched_ratecfg { + u64 rate_bytes_ps; + u32 mult; + u16 overhead; + u8 linklayer; + u8 shift; +}; + +struct mini_Qdisc_pair { + struct mini_Qdisc miniq1; + struct mini_Qdisc miniq2; + struct mini_Qdisc **p_miniq; +}; + +struct pfifo_fast_priv { + struct skb_array q[3]; +}; + +struct tc_qopt_offload_stats { + struct gnet_stats_basic_packed *bstats; + struct gnet_stats_queue *qstats; +}; + +enum tc_mq_command { + TC_MQ_CREATE = 0, + TC_MQ_DESTROY = 1, + TC_MQ_STATS = 2, + TC_MQ_GRAFT = 3, +}; + +struct tc_mq_opt_offload_graft_params { + long unsigned int queue; + u32 child_handle; +}; + +struct tc_mq_qopt_offload { + enum tc_mq_command command; + u32 handle; + union { + struct tc_qopt_offload_stats stats; + struct tc_mq_opt_offload_graft_params graft_params; + }; +}; + +struct mq_sched { + struct Qdisc **qdiscs; +}; + +enum tc_link_layer { + TC_LINKLAYER_UNAWARE = 0, + TC_LINKLAYER_ETHERNET = 1, + TC_LINKLAYER_ATM = 2, +}; + +enum { + TCA_STAB_UNSPEC = 0, + TCA_STAB_BASE = 1, + TCA_STAB_DATA = 2, + __TCA_STAB_MAX = 3, +}; + +struct qdisc_rate_table { + struct tc_ratespec rate; + u32 data[256]; + struct qdisc_rate_table *next; + int refcnt; +}; + +struct Qdisc_class_common { + u32 classid; + struct hlist_node hnode; +}; + +struct Qdisc_class_hash { + struct hlist_head *hash; + unsigned int hashsize; + unsigned int hashmask; + unsigned int hashelems; +}; + +struct qdisc_watchdog { + u64 last_expires; + struct hrtimer timer; + struct Qdisc *qdisc; +}; + +enum tc_root_command { + TC_ROOT_GRAFT = 0, +}; + +struct tc_root_qopt_offload { + enum tc_root_command command; + u32 handle; + bool ingress; +}; + +struct check_loop_arg { + struct qdisc_walker w; + struct Qdisc *p; + int depth; +}; + +struct tcf_bind_args { + struct tcf_walker w; + long unsigned int base; + long unsigned int cl; + u32 classid; +}; + +struct tc_bind_class_args { + struct qdisc_walker w; + long unsigned int new_cl; + u32 portid; + u32 clid; +}; + +struct qdisc_dump_args { + struct qdisc_walker w; + struct sk_buff *skb; + struct netlink_callback *cb; +}; + +enum net_xmit_qdisc_t { + __NET_XMIT_STOLEN = 65536, + __NET_XMIT_BYPASS = 131072, +}; + +enum { + TCA_ACT_UNSPEC = 0, + TCA_ACT_KIND = 1, + TCA_ACT_OPTIONS = 2, + TCA_ACT_INDEX = 3, + TCA_ACT_STATS = 4, + TCA_ACT_PAD = 5, + TCA_ACT_COOKIE = 6, + TCA_ACT_FLAGS = 7, + TCA_ACT_HW_STATS = 8, + TCA_ACT_USED_HW_STATS = 9, + __TCA_ACT_MAX = 10, +}; + +struct psample_group { + struct list_head list; + struct net *net; + u32 group_num; + u32 refcount; + u32 seq; + struct callback_head rcu; +}; + +struct action_gate_entry { + u8 gate_state; + u32 interval; + s32 ipv; + s32 maxoctets; +}; + +enum qdisc_class_ops_flags { + QDISC_CLASS_OPS_DOIT_UNLOCKED = 1, +}; + +enum tcf_proto_ops_flags { + TCF_PROTO_OPS_DOIT_UNLOCKED = 1, +}; + +typedef void tcf_chain_head_change_t(struct tcf_proto *, void *); + +struct tcf_block_ext_info { + enum flow_block_binder_type binder_type; + tcf_chain_head_change_t *chain_head_change; + void *chain_head_change_priv; + u32 block_index; +}; + +struct tcf_qevent { + struct tcf_block *block; + struct tcf_block_ext_info info; + struct tcf_proto *filter_chain; +}; + +enum pedit_header_type { + TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK = 0, + TCA_PEDIT_KEY_EX_HDR_TYPE_ETH = 1, + TCA_PEDIT_KEY_EX_HDR_TYPE_IP4 = 2, + TCA_PEDIT_KEY_EX_HDR_TYPE_IP6 = 3, + TCA_PEDIT_KEY_EX_HDR_TYPE_TCP = 4, + TCA_PEDIT_KEY_EX_HDR_TYPE_UDP = 5, + __PEDIT_HDR_TYPE_MAX = 6, +}; + +enum pedit_cmd { + TCA_PEDIT_KEY_EX_CMD_SET = 0, + TCA_PEDIT_KEY_EX_CMD_ADD = 1, + __PEDIT_CMD_MAX = 2, +}; + +struct tc_pedit_key { + __u32 mask; + __u32 val; + __u32 off; + __u32 at; + __u32 offmask; + __u32 shift; +}; + +struct tcf_pedit_key_ex { + enum pedit_header_type htype; + enum pedit_cmd cmd; +}; + +struct tcf_pedit { + struct tc_action common; + unsigned char tcfp_nkeys; + unsigned char tcfp_flags; + struct tc_pedit_key *tcfp_keys; + struct tcf_pedit_key_ex *tcfp_keys_ex; +}; + +struct tcf_vlan_params { + int tcfv_action; + unsigned char tcfv_push_dst[6]; + unsigned char tcfv_push_src[6]; + u16 tcfv_push_vid; + __be16 tcfv_push_proto; + u8 tcfv_push_prio; + struct callback_head rcu; +}; + +struct tcf_vlan { + struct tc_action common; + struct tcf_vlan_params *vlan_p; +}; + +struct tcf_tunnel_key_params { + struct callback_head rcu; + int tcft_action; + struct metadata_dst *tcft_enc_metadata; +}; + +struct tcf_tunnel_key { + struct tc_action common; + struct tcf_tunnel_key_params *params; +}; + +struct tcf_csum_params { + u32 update_flags; + struct callback_head rcu; +}; + +struct tcf_csum { + struct tc_action common; + struct tcf_csum_params *params; +}; + +struct tcf_police_params { + int tcfp_result; + u32 tcfp_ewma_rate; + s64 tcfp_burst; + u32 tcfp_mtu; + s64 tcfp_mtu_ptoks; + struct psched_ratecfg rate; + bool rate_present; + struct psched_ratecfg peak; + bool peak_present; + struct callback_head rcu; +}; + +struct tcf_police { + struct tc_action common; + struct tcf_police_params *params; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + spinlock_t tcfp_lock; + s64 tcfp_toks; + s64 tcfp_ptoks; + s64 tcfp_t_c; + long: 64; + long: 64; +}; + +struct tcf_sample { + struct tc_action common; + u32 rate; + bool truncate; + u32 trunc_size; + struct psample_group *psample_group; + u32 psample_group_num; + struct list_head tcfm_list; +}; + +struct tcf_skbedit_params { + u32 flags; + u32 priority; + u32 mark; + u32 mask; + u16 queue_mapping; + u16 ptype; + struct callback_head rcu; +}; + +struct tcf_skbedit { + struct tc_action common; + struct tcf_skbedit_params *params; +}; + +struct tcf_mpls_params { + int tcfm_action; + u32 tcfm_label; + u8 tcfm_tc; + u8 tcfm_ttl; + u8 tcfm_bos; + __be16 tcfm_proto; + struct callback_head rcu; +}; + +struct tcf_mpls { + struct tc_action common; + struct tcf_mpls_params *mpls_p; +}; + +struct tcfg_gate_entry { + int index; + u8 gate_state; + u32 interval; + s32 ipv; + s32 maxoctets; + struct list_head list; +}; + +struct tcf_gate_params { + s32 tcfg_priority; + u64 tcfg_basetime; + u64 tcfg_cycletime; + u64 tcfg_cycletime_ext; + u32 tcfg_flags; + s32 tcfg_clockid; + size_t num_entries; + struct list_head entries; +}; + +struct tcf_gate { + struct tc_action common; + struct tcf_gate_params param; + u8 current_gate_status; + ktime_t current_close_time; + u32 current_entry_octets; + s32 current_max_octets; + struct tcfg_gate_entry *next_entry; + struct hrtimer hitimer; + enum tk_offsets tk_offset; +}; + +struct tcf_filter_chain_list_item { + struct list_head list; + tcf_chain_head_change_t *chain_head_change; + void *chain_head_change_priv; +}; + +struct tcf_net { + spinlock_t idr_lock; + struct idr idr; +}; + +struct tcf_block_owner_item { + struct list_head list; + struct Qdisc *q; + enum flow_block_binder_type binder_type; +}; + +struct tcf_chain_info { + struct tcf_proto **pprev; + struct tcf_proto *next; +}; + +struct tcf_dump_args { + struct tcf_walker w; + struct sk_buff *skb; + struct netlink_callback *cb; + struct tcf_block *block; + struct Qdisc *q; + u32 parent; + bool terse_dump; +}; + +struct tcamsg { + unsigned char tca_family; + unsigned char tca__pad1; + short unsigned int tca__pad2; +}; + +enum { + TCA_ROOT_UNSPEC = 0, + TCA_ROOT_TAB = 1, + TCA_ROOT_FLAGS = 2, + TCA_ROOT_COUNT = 3, + TCA_ROOT_TIME_DELTA = 4, + __TCA_ROOT_MAX = 5, +}; + +struct tc_action_net { + struct tcf_idrinfo *idrinfo; + const struct tc_action_ops *ops; +}; + +struct tc_act_bpf { + __u32 index; + __u32 capab; + int action; + int refcnt; + int bindcnt; +}; + +enum { + TCA_ACT_BPF_UNSPEC = 0, + TCA_ACT_BPF_TM = 1, + TCA_ACT_BPF_PARMS = 2, + TCA_ACT_BPF_OPS_LEN = 3, + TCA_ACT_BPF_OPS = 4, + TCA_ACT_BPF_FD = 5, + TCA_ACT_BPF_NAME = 6, + TCA_ACT_BPF_PAD = 7, + TCA_ACT_BPF_TAG = 8, + TCA_ACT_BPF_ID = 9, + __TCA_ACT_BPF_MAX = 10, +}; + +struct tcf_bpf { + struct tc_action common; + struct bpf_prog *filter; + union { + u32 bpf_fd; + u16 bpf_num_ops; + }; + struct sock_filter *bpf_ops; + const char *bpf_name; +}; + +struct tcf_bpf_cfg { + struct bpf_prog *filter; + struct sock_filter *bpf_ops; + const char *bpf_name; + u16 bpf_num_ops; + bool is_ebpf; +}; + +struct tc_fifo_qopt { + __u32 limit; +}; + +enum tc_fifo_command { + TC_FIFO_REPLACE = 0, + TC_FIFO_DESTROY = 1, + TC_FIFO_STATS = 2, +}; + +struct tc_fifo_qopt_offload { + enum tc_fifo_command command; + u32 handle; + u32 parent; + union { + struct tc_qopt_offload_stats stats; + }; +}; + +struct ingress_sched_data { + struct tcf_block *block; + struct tcf_block_ext_info block_info; + struct mini_Qdisc_pair miniqp; +}; + +struct clsact_sched_data { + struct tcf_block *ingress_block; + struct tcf_block *egress_block; + struct tcf_block_ext_info ingress_block_info; + struct tcf_block_ext_info egress_block_info; + struct mini_Qdisc_pair miniqp_ingress; + struct mini_Qdisc_pair miniqp_egress; +}; + +enum { + TCA_FQ_CODEL_UNSPEC = 0, + TCA_FQ_CODEL_TARGET = 1, + TCA_FQ_CODEL_LIMIT = 2, + TCA_FQ_CODEL_INTERVAL = 3, + TCA_FQ_CODEL_ECN = 4, + TCA_FQ_CODEL_FLOWS = 5, + TCA_FQ_CODEL_QUANTUM = 6, + TCA_FQ_CODEL_CE_THRESHOLD = 7, + TCA_FQ_CODEL_DROP_BATCH_SIZE = 8, + TCA_FQ_CODEL_MEMORY_LIMIT = 9, + __TCA_FQ_CODEL_MAX = 10, +}; + +enum { + TCA_FQ_CODEL_XSTATS_QDISC = 0, + TCA_FQ_CODEL_XSTATS_CLASS = 1, +}; + +struct tc_fq_codel_qd_stats { + __u32 maxpacket; + __u32 drop_overlimit; + __u32 ecn_mark; + __u32 new_flow_count; + __u32 new_flows_len; + __u32 old_flows_len; + __u32 ce_mark; + __u32 memory_usage; + __u32 drop_overmemory; +}; + +struct tc_fq_codel_cl_stats { + __s32 deficit; + __u32 ldelay; + __u32 count; + __u32 lastcount; + __u32 dropping; + __s32 drop_next; +}; + +struct tc_fq_codel_xstats { + __u32 type; + union { + struct tc_fq_codel_qd_stats qdisc_stats; + struct tc_fq_codel_cl_stats class_stats; + }; +}; + +typedef u32 codel_time_t; + +typedef s32 codel_tdiff_t; + +struct codel_params { + codel_time_t target; + codel_time_t ce_threshold; + codel_time_t interval; + u32 mtu; + bool ecn; +}; + +struct codel_vars { + u32 count; + u32 lastcount; + bool dropping; + u16 rec_inv_sqrt; + codel_time_t first_above_time; + codel_time_t drop_next; + codel_time_t ldelay; +}; + +struct codel_stats { + u32 maxpacket; + u32 drop_count; + u32 drop_len; + u32 ecn_mark; + u32 ce_mark; +}; + +typedef u32 (*codel_skb_len_t)(const struct sk_buff *); + +typedef codel_time_t (*codel_skb_time_t)(const struct sk_buff *); + +typedef void (*codel_skb_drop_t)(struct sk_buff *, void *); + +typedef struct sk_buff * (*codel_skb_dequeue_t)(struct codel_vars *, void *); + +struct codel_skb_cb { + codel_time_t enqueue_time; + unsigned int mem_usage; +}; + +struct fq_codel_flow { + struct sk_buff *head; + struct sk_buff *tail; + struct list_head flowchain; + int deficit; + struct codel_vars cvars; +}; + +struct fq_codel_sched_data { + struct tcf_proto *filter_list; + struct tcf_block *block; + struct fq_codel_flow *flows; + u32 *backlogs; + u32 flows_cnt; + u32 quantum; + u32 drop_batch_size; + u32 memory_limit; + struct codel_params cparams; + struct codel_stats cstats; + u32 memory_usage; + u32 drop_overmemory; + u32 drop_overlimit; + u32 new_flow_count; + struct list_head new_flows; + struct list_head old_flows; +}; + +enum { + TCA_FQ_UNSPEC = 0, + TCA_FQ_PLIMIT = 1, + TCA_FQ_FLOW_PLIMIT = 2, + TCA_FQ_QUANTUM = 3, + TCA_FQ_INITIAL_QUANTUM = 4, + TCA_FQ_RATE_ENABLE = 5, + TCA_FQ_FLOW_DEFAULT_RATE = 6, + TCA_FQ_FLOW_MAX_RATE = 7, + TCA_FQ_BUCKETS_LOG = 8, + TCA_FQ_FLOW_REFILL_DELAY = 9, + TCA_FQ_ORPHAN_MASK = 10, + TCA_FQ_LOW_RATE_THRESHOLD = 11, + TCA_FQ_CE_THRESHOLD = 12, + TCA_FQ_TIMER_SLACK = 13, + TCA_FQ_HORIZON = 14, + TCA_FQ_HORIZON_DROP = 15, + __TCA_FQ_MAX = 16, +}; + +struct tc_fq_qd_stats { + __u64 gc_flows; + __u64 highprio_packets; + __u64 tcp_retrans; + __u64 throttled; + __u64 flows_plimit; + __u64 pkts_too_long; + __u64 allocation_errors; + __s64 time_next_delayed_flow; + __u32 flows; + __u32 inactive_flows; + __u32 throttled_flows; + __u32 unthrottle_latency_ns; + __u64 ce_mark; + __u64 horizon_drops; + __u64 horizon_caps; +}; + +struct fq_skb_cb { + u64 time_to_send; +}; + +struct fq_flow { + struct rb_root t_root; + struct sk_buff *head; + union { + struct sk_buff *tail; + long unsigned int age; + }; + struct rb_node fq_node; + struct sock *sk; + u32 socket_hash; + int qlen; + int credit; + struct fq_flow *next; + struct rb_node rate_node; + u64 time_next_packet; + long: 64; + long: 64; +}; + +struct fq_flow_head { + struct fq_flow *first; + struct fq_flow *last; +}; + +struct fq_sched_data { + struct fq_flow_head new_flows; + struct fq_flow_head old_flows; + struct rb_root delayed; + u64 time_next_delayed_flow; + u64 ktime_cache; + long unsigned int unthrottle_latency_ns; + struct fq_flow internal; + u32 quantum; + u32 initial_quantum; + u32 flow_refill_delay; + u32 flow_plimit; + long unsigned int flow_max_rate; + u64 ce_threshold; + u64 horizon; + u32 orphan_mask; + u32 low_rate_threshold; + struct rb_root *fq_root; + u8 rate_enable; + u8 fq_trees_log; + u8 horizon_drop; + u32 flows; + u32 inactive_flows; + u32 throttled_flows; + u64 stat_gc_flows; + u64 stat_internal_packets; + u64 stat_throttled; + u64 stat_ce_mark; + u64 stat_horizon_drops; + u64 stat_horizon_caps; + u64 stat_flows_plimit; + u64 stat_pkts_too_long; + u64 stat_allocation_errors; + u32 timer_slack; + struct qdisc_watchdog watchdog; + long: 64; + long: 64; + long: 64; +}; + +enum { + TCA_CGROUP_UNSPEC = 0, + TCA_CGROUP_ACT = 1, + TCA_CGROUP_POLICE = 2, + TCA_CGROUP_EMATCHES = 3, + __TCA_CGROUP_MAX = 4, +}; + +struct tcf_ematch_tree_hdr { + __u16 nmatches; + __u16 progid; +}; + +struct tcf_pkt_info { + unsigned char *ptr; + int nexthdr; +}; + +struct tcf_ematch_ops; + +struct tcf_ematch { + struct tcf_ematch_ops *ops; + long unsigned int data; + unsigned int datalen; + u16 matchid; + u16 flags; + struct net *net; +}; + +struct tcf_ematch_ops { + int kind; + int datalen; + int (*change)(struct net *, void *, int, struct tcf_ematch *); + int (*match)(struct sk_buff *, struct tcf_ematch *, struct tcf_pkt_info *); + void (*destroy)(struct tcf_ematch *); + int (*dump)(struct sk_buff *, struct tcf_ematch *); + struct module *owner; + struct list_head link; +}; + +struct tcf_ematch_tree { + struct tcf_ematch_tree_hdr hdr; + struct tcf_ematch *matches; +}; + +struct cls_cgroup_head { + u32 handle; + struct tcf_exts exts; + struct tcf_ematch_tree ematches; + struct tcf_proto *tp; + struct rcu_work rwork; +}; + +enum { + TCA_BPF_UNSPEC = 0, + TCA_BPF_ACT = 1, + TCA_BPF_POLICE = 2, + TCA_BPF_CLASSID = 3, + TCA_BPF_OPS_LEN = 4, + TCA_BPF_OPS = 5, + TCA_BPF_FD = 6, + TCA_BPF_NAME = 7, + TCA_BPF_FLAGS = 8, + TCA_BPF_FLAGS_GEN = 9, + TCA_BPF_TAG = 10, + TCA_BPF_ID = 11, + __TCA_BPF_MAX = 12, +}; + +struct cls_bpf_head { + struct list_head plist; + struct idr handle_idr; + struct callback_head rcu; +}; + +struct cls_bpf_prog { + struct bpf_prog *filter; + struct list_head link; + struct tcf_result res; + bool exts_integrated; + u32 gen_flags; + unsigned int in_hw_count; + struct tcf_exts exts; + u32 handle; + u16 bpf_num_ops; + struct sock_filter *bpf_ops; + const char *bpf_name; + struct tcf_proto *tp; + struct rcu_work rwork; +}; + +enum { + TCA_FLOWER_UNSPEC = 0, + TCA_FLOWER_CLASSID = 1, + TCA_FLOWER_INDEV = 2, + TCA_FLOWER_ACT = 3, + TCA_FLOWER_KEY_ETH_DST = 4, + TCA_FLOWER_KEY_ETH_DST_MASK = 5, + TCA_FLOWER_KEY_ETH_SRC = 6, + TCA_FLOWER_KEY_ETH_SRC_MASK = 7, + TCA_FLOWER_KEY_ETH_TYPE = 8, + TCA_FLOWER_KEY_IP_PROTO = 9, + TCA_FLOWER_KEY_IPV4_SRC = 10, + TCA_FLOWER_KEY_IPV4_SRC_MASK = 11, + TCA_FLOWER_KEY_IPV4_DST = 12, + TCA_FLOWER_KEY_IPV4_DST_MASK = 13, + TCA_FLOWER_KEY_IPV6_SRC = 14, + TCA_FLOWER_KEY_IPV6_SRC_MASK = 15, + TCA_FLOWER_KEY_IPV6_DST = 16, + TCA_FLOWER_KEY_IPV6_DST_MASK = 17, + TCA_FLOWER_KEY_TCP_SRC = 18, + TCA_FLOWER_KEY_TCP_DST = 19, + TCA_FLOWER_KEY_UDP_SRC = 20, + TCA_FLOWER_KEY_UDP_DST = 21, + TCA_FLOWER_FLAGS = 22, + TCA_FLOWER_KEY_VLAN_ID = 23, + TCA_FLOWER_KEY_VLAN_PRIO = 24, + TCA_FLOWER_KEY_VLAN_ETH_TYPE = 25, + TCA_FLOWER_KEY_ENC_KEY_ID = 26, + TCA_FLOWER_KEY_ENC_IPV4_SRC = 27, + TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK = 28, + TCA_FLOWER_KEY_ENC_IPV4_DST = 29, + TCA_FLOWER_KEY_ENC_IPV4_DST_MASK = 30, + TCA_FLOWER_KEY_ENC_IPV6_SRC = 31, + TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK = 32, + TCA_FLOWER_KEY_ENC_IPV6_DST = 33, + TCA_FLOWER_KEY_ENC_IPV6_DST_MASK = 34, + TCA_FLOWER_KEY_TCP_SRC_MASK = 35, + TCA_FLOWER_KEY_TCP_DST_MASK = 36, + TCA_FLOWER_KEY_UDP_SRC_MASK = 37, + TCA_FLOWER_KEY_UDP_DST_MASK = 38, + TCA_FLOWER_KEY_SCTP_SRC_MASK = 39, + TCA_FLOWER_KEY_SCTP_DST_MASK = 40, + TCA_FLOWER_KEY_SCTP_SRC = 41, + TCA_FLOWER_KEY_SCTP_DST = 42, + TCA_FLOWER_KEY_ENC_UDP_SRC_PORT = 43, + TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK = 44, + TCA_FLOWER_KEY_ENC_UDP_DST_PORT = 45, + TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK = 46, + TCA_FLOWER_KEY_FLAGS = 47, + TCA_FLOWER_KEY_FLAGS_MASK = 48, + TCA_FLOWER_KEY_ICMPV4_CODE = 49, + TCA_FLOWER_KEY_ICMPV4_CODE_MASK = 50, + TCA_FLOWER_KEY_ICMPV4_TYPE = 51, + TCA_FLOWER_KEY_ICMPV4_TYPE_MASK = 52, + TCA_FLOWER_KEY_ICMPV6_CODE = 53, + TCA_FLOWER_KEY_ICMPV6_CODE_MASK = 54, + TCA_FLOWER_KEY_ICMPV6_TYPE = 55, + TCA_FLOWER_KEY_ICMPV6_TYPE_MASK = 56, + TCA_FLOWER_KEY_ARP_SIP = 57, + TCA_FLOWER_KEY_ARP_SIP_MASK = 58, + TCA_FLOWER_KEY_ARP_TIP = 59, + TCA_FLOWER_KEY_ARP_TIP_MASK = 60, + TCA_FLOWER_KEY_ARP_OP = 61, + TCA_FLOWER_KEY_ARP_OP_MASK = 62, + TCA_FLOWER_KEY_ARP_SHA = 63, + TCA_FLOWER_KEY_ARP_SHA_MASK = 64, + TCA_FLOWER_KEY_ARP_THA = 65, + TCA_FLOWER_KEY_ARP_THA_MASK = 66, + TCA_FLOWER_KEY_MPLS_TTL = 67, + TCA_FLOWER_KEY_MPLS_BOS = 68, + TCA_FLOWER_KEY_MPLS_TC = 69, + TCA_FLOWER_KEY_MPLS_LABEL = 70, + TCA_FLOWER_KEY_TCP_FLAGS = 71, + TCA_FLOWER_KEY_TCP_FLAGS_MASK = 72, + TCA_FLOWER_KEY_IP_TOS = 73, + TCA_FLOWER_KEY_IP_TOS_MASK = 74, + TCA_FLOWER_KEY_IP_TTL = 75, + TCA_FLOWER_KEY_IP_TTL_MASK = 76, + TCA_FLOWER_KEY_CVLAN_ID = 77, + TCA_FLOWER_KEY_CVLAN_PRIO = 78, + TCA_FLOWER_KEY_CVLAN_ETH_TYPE = 79, + TCA_FLOWER_KEY_ENC_IP_TOS = 80, + TCA_FLOWER_KEY_ENC_IP_TOS_MASK = 81, + TCA_FLOWER_KEY_ENC_IP_TTL = 82, + TCA_FLOWER_KEY_ENC_IP_TTL_MASK = 83, + TCA_FLOWER_KEY_ENC_OPTS = 84, + TCA_FLOWER_KEY_ENC_OPTS_MASK = 85, + TCA_FLOWER_IN_HW_COUNT = 86, + TCA_FLOWER_KEY_PORT_SRC_MIN = 87, + TCA_FLOWER_KEY_PORT_SRC_MAX = 88, + TCA_FLOWER_KEY_PORT_DST_MIN = 89, + TCA_FLOWER_KEY_PORT_DST_MAX = 90, + TCA_FLOWER_KEY_CT_STATE = 91, + TCA_FLOWER_KEY_CT_STATE_MASK = 92, + TCA_FLOWER_KEY_CT_ZONE = 93, + TCA_FLOWER_KEY_CT_ZONE_MASK = 94, + TCA_FLOWER_KEY_CT_MARK = 95, + TCA_FLOWER_KEY_CT_MARK_MASK = 96, + TCA_FLOWER_KEY_CT_LABELS = 97, + TCA_FLOWER_KEY_CT_LABELS_MASK = 98, + TCA_FLOWER_KEY_MPLS_OPTS = 99, + TCA_FLOWER_KEY_HASH = 100, + TCA_FLOWER_KEY_HASH_MASK = 101, + __TCA_FLOWER_MAX = 102, +}; + +enum { + TCA_FLOWER_KEY_CT_FLAGS_NEW = 1, + TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED = 2, + TCA_FLOWER_KEY_CT_FLAGS_RELATED = 4, + TCA_FLOWER_KEY_CT_FLAGS_TRACKED = 8, +}; + +enum { + TCA_FLOWER_KEY_ENC_OPTS_UNSPEC = 0, + TCA_FLOWER_KEY_ENC_OPTS_GENEVE = 1, + TCA_FLOWER_KEY_ENC_OPTS_VXLAN = 2, + TCA_FLOWER_KEY_ENC_OPTS_ERSPAN = 3, + __TCA_FLOWER_KEY_ENC_OPTS_MAX = 4, +}; + +enum { + TCA_FLOWER_KEY_ENC_OPT_GENEVE_UNSPEC = 0, + TCA_FLOWER_KEY_ENC_OPT_GENEVE_CLASS = 1, + TCA_FLOWER_KEY_ENC_OPT_GENEVE_TYPE = 2, + TCA_FLOWER_KEY_ENC_OPT_GENEVE_DATA = 3, + __TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX = 4, +}; + +enum { + TCA_FLOWER_KEY_ENC_OPT_VXLAN_UNSPEC = 0, + TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP = 1, + __TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX = 2, +}; + +enum { + TCA_FLOWER_KEY_ENC_OPT_ERSPAN_UNSPEC = 0, + TCA_FLOWER_KEY_ENC_OPT_ERSPAN_VER = 1, + TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX = 2, + TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR = 3, + TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID = 4, + __TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX = 5, +}; + +enum { + TCA_FLOWER_KEY_MPLS_OPTS_UNSPEC = 0, + TCA_FLOWER_KEY_MPLS_OPTS_LSE = 1, + __TCA_FLOWER_KEY_MPLS_OPTS_MAX = 2, +}; + +enum { + TCA_FLOWER_KEY_MPLS_OPT_LSE_UNSPEC = 0, + TCA_FLOWER_KEY_MPLS_OPT_LSE_DEPTH = 1, + TCA_FLOWER_KEY_MPLS_OPT_LSE_TTL = 2, + TCA_FLOWER_KEY_MPLS_OPT_LSE_BOS = 3, + TCA_FLOWER_KEY_MPLS_OPT_LSE_TC = 4, + TCA_FLOWER_KEY_MPLS_OPT_LSE_LABEL = 5, + __TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX = 6, +}; + +enum { + TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = 1, + TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = 2, +}; + +struct flow_stats { + u64 pkts; + u64 bytes; + u64 drops; + u64 lastused; + enum flow_action_hw_stats used_hw_stats; + bool used_hw_stats_valid; +}; + +enum flow_cls_command { + FLOW_CLS_REPLACE = 0, + FLOW_CLS_DESTROY = 1, + FLOW_CLS_STATS = 2, + FLOW_CLS_TMPLT_CREATE = 3, + FLOW_CLS_TMPLT_DESTROY = 4, +}; + +struct flow_cls_offload { + struct flow_cls_common_offload common; + enum flow_cls_command command; + long unsigned int cookie; + struct flow_rule *rule; + struct flow_stats stats; + u32 classid; +}; + +struct geneve_opt { + __be16 opt_class; + u8 type; + u8 length: 5; + u8 r3: 1; + u8 r2: 1; + u8 r1: 1; + u8 opt_data[0]; +}; + +struct erspan_md2 { + __be32 timestamp; + __be16 sgt; + __u8 hwid_upper: 2; + __u8 ft: 5; + __u8 p: 1; + __u8 o: 1; + __u8 gra: 2; + __u8 dir: 1; + __u8 hwid: 4; +}; + +struct erspan_metadata { + int version; + union { + __be32 index; + struct erspan_md2 md2; + } u; +}; + +enum ip_conntrack_info { + IP_CT_ESTABLISHED = 0, + IP_CT_RELATED = 1, + IP_CT_NEW = 2, + IP_CT_IS_REPLY = 3, + IP_CT_ESTABLISHED_REPLY = 3, + IP_CT_RELATED_REPLY = 4, + IP_CT_NUMBER = 5, + IP_CT_UNTRACKED = 7, +}; + +struct fl_flow_key { + struct flow_dissector_key_meta meta; + struct flow_dissector_key_control control; + struct flow_dissector_key_control enc_control; + struct flow_dissector_key_basic basic; + struct flow_dissector_key_eth_addrs eth; + struct flow_dissector_key_vlan vlan; + struct flow_dissector_key_vlan cvlan; + union { + struct flow_dissector_key_ipv4_addrs ipv4; + struct flow_dissector_key_ipv6_addrs ipv6; + }; + struct flow_dissector_key_ports tp; + struct flow_dissector_key_icmp icmp; + struct flow_dissector_key_arp arp; + struct flow_dissector_key_keyid enc_key_id; + union { + struct flow_dissector_key_ipv4_addrs enc_ipv4; + struct flow_dissector_key_ipv6_addrs enc_ipv6; + }; + struct flow_dissector_key_ports enc_tp; + struct flow_dissector_key_mpls mpls; + struct flow_dissector_key_tcp tcp; + struct flow_dissector_key_ip ip; + struct flow_dissector_key_ip enc_ip; + struct flow_dissector_key_enc_opts enc_opts; + union { + struct flow_dissector_key_ports tp; + struct { + struct flow_dissector_key_ports tp_min; + struct flow_dissector_key_ports tp_max; + }; + } tp_range; + struct flow_dissector_key_ct ct; + struct flow_dissector_key_hash hash; + int: 32; +}; + +struct fl_flow_mask_range { + short unsigned int start; + short unsigned int end; +}; + +struct fl_flow_mask { + struct fl_flow_key key; + struct fl_flow_mask_range range; + u32 flags; + struct rhash_head ht_node; + struct rhashtable ht; + struct rhashtable_params filter_ht_params; + struct flow_dissector dissector; + struct list_head filters; + struct rcu_work rwork; + struct list_head list; + refcount_t refcnt; +}; + +struct fl_flow_tmplt { + struct fl_flow_key dummy_key; + struct fl_flow_key mask; + struct flow_dissector dissector; + struct tcf_chain *chain; +}; + +struct cls_fl_head { + struct rhashtable ht; + spinlock_t masks_lock; + struct list_head masks; + struct list_head hw_filters; + struct rcu_work rwork; + struct idr handle_idr; +}; + +struct cls_fl_filter { + struct fl_flow_mask *mask; + struct rhash_head ht_node; + struct fl_flow_key mkey; + struct tcf_exts exts; + struct tcf_result res; + struct fl_flow_key key; + struct list_head list; + struct list_head hw_list; + u32 handle; + u32 flags; + u32 in_hw_count; + struct rcu_work rwork; + struct net_device *hw_dev; + refcount_t refcnt; + bool deleted; +}; + +enum { + TCA_EMATCH_TREE_UNSPEC = 0, + TCA_EMATCH_TREE_HDR = 1, + TCA_EMATCH_TREE_LIST = 2, + __TCA_EMATCH_TREE_MAX = 3, +}; + +struct tcf_ematch_hdr { + __u16 matchid; + __u16 kind; + __u16 flags; + __u16 pad; +}; + +struct sockaddr_nl { + __kernel_sa_family_t nl_family; + short unsigned int nl_pad; + __u32 nl_pid; + __u32 nl_groups; +}; + +struct nlmsgerr { + int error; + struct nlmsghdr msg; +}; + +enum nlmsgerr_attrs { + NLMSGERR_ATTR_UNUSED = 0, + NLMSGERR_ATTR_MSG = 1, + NLMSGERR_ATTR_OFFS = 2, + NLMSGERR_ATTR_COOKIE = 3, + NLMSGERR_ATTR_POLICY = 4, + __NLMSGERR_ATTR_MAX = 5, + NLMSGERR_ATTR_MAX = 4, +}; + +struct nl_pktinfo { + __u32 group; +}; + +enum { + NETLINK_UNCONNECTED = 0, + NETLINK_CONNECTED = 1, +}; + +enum netlink_skb_flags { + NETLINK_SKB_DST = 8, +}; + +struct netlink_notify { + struct net *net; + u32 portid; + int protocol; +}; + +struct netlink_tap { + struct net_device *dev; + struct module *module; + struct list_head list; +}; + +struct netlink_sock { + struct sock sk; + u32 portid; + u32 dst_portid; + u32 dst_group; + u32 flags; + u32 subscriptions; + u32 ngroups; + long unsigned int *groups; + long unsigned int state; + size_t max_recvmsg_len; + wait_queue_head_t wait; + bool bound; + bool cb_running; + int dump_done_errno; + struct netlink_callback cb; + struct mutex *cb_mutex; + struct mutex cb_def_mutex; + void (*netlink_rcv)(struct sk_buff *); + int (*netlink_bind)(struct net *, int); + void (*netlink_unbind)(struct net *, int); + struct module *module; + struct rhash_head node; + struct callback_head rcu; + struct work_struct work; +}; + +struct listeners; + +struct netlink_table { + struct rhashtable hash; + struct hlist_head mc_list; + struct listeners *listeners; + unsigned int flags; + unsigned int groups; + struct mutex *cb_mutex; + struct module *module; + int (*bind)(struct net *, int); + void (*unbind)(struct net *, int); + bool (*compare)(struct net *, struct sock *); + int registered; +}; + +struct listeners { + struct callback_head rcu; + long unsigned int masks[0]; +}; + +struct netlink_tap_net { + struct list_head netlink_tap_all; + struct mutex netlink_tap_lock; +}; + +struct netlink_compare_arg { + possible_net_t pnet; + u32 portid; +}; + +struct netlink_broadcast_data { + struct sock *exclude_sk; + struct net *net; + u32 portid; + u32 group; + int failure; + int delivery_failure; + int congested; + int delivered; + gfp_t allocation; + struct sk_buff *skb; + struct sk_buff *skb2; + int (*tx_filter)(struct sock *, struct sk_buff *, void *); + void *tx_data; +}; + +struct netlink_set_err_data { + struct sock *exclude_sk; + u32 portid; + u32 group; + int code; +}; + +struct nl_seq_iter { + struct seq_net_private p; + struct rhashtable_iter hti; + int link; +}; + +struct bpf_iter__netlink { + union { + struct bpf_iter_meta *meta; + }; + union { + struct netlink_sock *sk; + }; +}; + +enum { + CTRL_CMD_UNSPEC = 0, + CTRL_CMD_NEWFAMILY = 1, + CTRL_CMD_DELFAMILY = 2, + CTRL_CMD_GETFAMILY = 3, + CTRL_CMD_NEWOPS = 4, + CTRL_CMD_DELOPS = 5, + CTRL_CMD_GETOPS = 6, + CTRL_CMD_NEWMCAST_GRP = 7, + CTRL_CMD_DELMCAST_GRP = 8, + CTRL_CMD_GETMCAST_GRP = 9, + CTRL_CMD_GETPOLICY = 10, + __CTRL_CMD_MAX = 11, +}; + +enum { + CTRL_ATTR_UNSPEC = 0, + CTRL_ATTR_FAMILY_ID = 1, + CTRL_ATTR_FAMILY_NAME = 2, + CTRL_ATTR_VERSION = 3, + CTRL_ATTR_HDRSIZE = 4, + CTRL_ATTR_MAXATTR = 5, + CTRL_ATTR_OPS = 6, + CTRL_ATTR_MCAST_GROUPS = 7, + CTRL_ATTR_POLICY = 8, + CTRL_ATTR_OP_POLICY = 9, + CTRL_ATTR_OP = 10, + __CTRL_ATTR_MAX = 11, +}; + +enum { + CTRL_ATTR_OP_UNSPEC = 0, + CTRL_ATTR_OP_ID = 1, + CTRL_ATTR_OP_FLAGS = 2, + __CTRL_ATTR_OP_MAX = 3, +}; + +enum { + CTRL_ATTR_MCAST_GRP_UNSPEC = 0, + CTRL_ATTR_MCAST_GRP_NAME = 1, + CTRL_ATTR_MCAST_GRP_ID = 2, + __CTRL_ATTR_MCAST_GRP_MAX = 3, +}; + +enum { + CTRL_ATTR_POLICY_UNSPEC = 0, + CTRL_ATTR_POLICY_DO = 1, + CTRL_ATTR_POLICY_DUMP = 2, + __CTRL_ATTR_POLICY_DUMP_MAX = 3, + CTRL_ATTR_POLICY_DUMP_MAX = 2, +}; + +struct genl_start_context { + const struct genl_family *family; + struct nlmsghdr *nlh; + struct netlink_ext_ack *extack; + const struct genl_ops *ops; + int hdrlen; +}; + +struct netlink_policy_dump_state; + +struct ctrl_dump_policy_ctx { + struct netlink_policy_dump_state *state; + const struct genl_family *rt; + unsigned int opidx; + u32 op; + u16 fam_id; + u8 policies: 1; + u8 single_op: 1; +}; + +enum netlink_attribute_type { + NL_ATTR_TYPE_INVALID = 0, + NL_ATTR_TYPE_FLAG = 1, + NL_ATTR_TYPE_U8 = 2, + NL_ATTR_TYPE_U16 = 3, + NL_ATTR_TYPE_U32 = 4, + NL_ATTR_TYPE_U64 = 5, + NL_ATTR_TYPE_S8 = 6, + NL_ATTR_TYPE_S16 = 7, + NL_ATTR_TYPE_S32 = 8, + NL_ATTR_TYPE_S64 = 9, + NL_ATTR_TYPE_BINARY = 10, + NL_ATTR_TYPE_STRING = 11, + NL_ATTR_TYPE_NUL_STRING = 12, + NL_ATTR_TYPE_NESTED = 13, + NL_ATTR_TYPE_NESTED_ARRAY = 14, + NL_ATTR_TYPE_BITFIELD32 = 15, +}; + +enum netlink_policy_type_attr { + NL_POLICY_TYPE_ATTR_UNSPEC = 0, + NL_POLICY_TYPE_ATTR_TYPE = 1, + NL_POLICY_TYPE_ATTR_MIN_VALUE_S = 2, + NL_POLICY_TYPE_ATTR_MAX_VALUE_S = 3, + NL_POLICY_TYPE_ATTR_MIN_VALUE_U = 4, + NL_POLICY_TYPE_ATTR_MAX_VALUE_U = 5, + NL_POLICY_TYPE_ATTR_MIN_LENGTH = 6, + NL_POLICY_TYPE_ATTR_MAX_LENGTH = 7, + NL_POLICY_TYPE_ATTR_POLICY_IDX = 8, + NL_POLICY_TYPE_ATTR_POLICY_MAXTYPE = 9, + NL_POLICY_TYPE_ATTR_BITFIELD32_MASK = 10, + NL_POLICY_TYPE_ATTR_PAD = 11, + NL_POLICY_TYPE_ATTR_MASK = 12, + __NL_POLICY_TYPE_ATTR_MAX = 13, + NL_POLICY_TYPE_ATTR_MAX = 12, +}; + +struct netlink_policy_dump_state___2 { + unsigned int policy_idx; + unsigned int attr_idx; + unsigned int n_alloc; + struct { + const struct nla_policy *policy; + unsigned int maxtype; + } policies[0]; +}; + +struct trace_event_raw_bpf_test_finish { + struct trace_entry ent; + int err; + char __data[0]; +}; + +struct trace_event_data_offsets_bpf_test_finish {}; + +typedef void (*btf_trace_bpf_test_finish)(void *, int *); + +struct bpf_fentry_test_t { + struct bpf_fentry_test_t *a; +}; + +struct bpf_raw_tp_test_run_info { + struct bpf_prog *prog; + void *ctx; + u32 retval; +}; + +struct ethtool_value { + __u32 cmd; + __u32 data; +}; + +enum tunable_type_id { + ETHTOOL_TUNABLE_UNSPEC = 0, + ETHTOOL_TUNABLE_U8 = 1, + ETHTOOL_TUNABLE_U16 = 2, + ETHTOOL_TUNABLE_U32 = 3, + ETHTOOL_TUNABLE_U64 = 4, + ETHTOOL_TUNABLE_STRING = 5, + ETHTOOL_TUNABLE_S8 = 6, + ETHTOOL_TUNABLE_S16 = 7, + ETHTOOL_TUNABLE_S32 = 8, + ETHTOOL_TUNABLE_S64 = 9, +}; + +enum phy_tunable_id { + ETHTOOL_PHY_ID_UNSPEC = 0, + ETHTOOL_PHY_DOWNSHIFT = 1, + ETHTOOL_PHY_FAST_LINK_DOWN = 2, + ETHTOOL_PHY_EDPD = 3, + __ETHTOOL_PHY_TUNABLE_COUNT = 4, +}; + +struct ethtool_gstrings { + __u32 cmd; + __u32 string_set; + __u32 len; + __u8 data[0]; +}; + +struct ethtool_sset_info { + __u32 cmd; + __u32 reserved; + __u64 sset_mask; + __u32 data[0]; +}; + +struct ethtool_perm_addr { + __u32 cmd; + __u32 size; + __u8 data[0]; +}; + +enum ethtool_flags { + ETH_FLAG_TXVLAN = 128, + ETH_FLAG_RXVLAN = 256, + ETH_FLAG_LRO = 32768, + ETH_FLAG_NTUPLE = 134217728, + ETH_FLAG_RXHASH = 268435456, +}; + +struct ethtool_rxfh { + __u32 cmd; + __u32 rss_context; + __u32 indir_size; + __u32 key_size; + __u8 hfunc; + __u8 rsvd8[3]; + __u32 rsvd32; + __u32 rss_config[0]; +}; + +struct ethtool_get_features_block { + __u32 available; + __u32 requested; + __u32 active; + __u32 never_changed; +}; + +struct ethtool_gfeatures { + __u32 cmd; + __u32 size; + struct ethtool_get_features_block features[0]; +}; + +struct ethtool_set_features_block { + __u32 valid; + __u32 requested; +}; + +struct ethtool_sfeatures { + __u32 cmd; + __u32 size; + struct ethtool_set_features_block features[0]; +}; + +enum ethtool_sfeatures_retval_bits { + ETHTOOL_F_UNSUPPORTED__BIT = 0, + ETHTOOL_F_WISH__BIT = 1, + ETHTOOL_F_COMPAT__BIT = 2, +}; + +struct ethtool_per_queue_op { + __u32 cmd; + __u32 sub_command; + __u32 queue_mask[128]; + char data[0]; +}; + +struct ethtool_rx_flow_rule { + struct flow_rule *rule; + long unsigned int priv[0]; +}; + +struct ethtool_rx_flow_spec_input { + const struct ethtool_rx_flow_spec *fs; + u32 rss_ctx; +}; + +struct ethtool_link_usettings { + struct ethtool_link_settings base; + struct { + __u32 supported[3]; + __u32 advertising[3]; + __u32 lp_advertising[3]; + } link_modes; +}; + +struct ethtool_rx_flow_key { + struct flow_dissector_key_basic basic; + union { + struct flow_dissector_key_ipv4_addrs ipv4; + struct flow_dissector_key_ipv6_addrs ipv6; + }; + struct flow_dissector_key_ports tp; + struct flow_dissector_key_ip ip; + struct flow_dissector_key_vlan vlan; + struct flow_dissector_key_eth_addrs eth_addrs; + long: 48; +}; + +struct ethtool_rx_flow_match { + struct flow_dissector dissector; + int: 32; + struct ethtool_rx_flow_key key; + struct ethtool_rx_flow_key mask; +}; + +enum { + ETHTOOL_UDP_TUNNEL_TYPE_VXLAN = 0, + ETHTOOL_UDP_TUNNEL_TYPE_GENEVE = 1, + ETHTOOL_UDP_TUNNEL_TYPE_VXLAN_GPE = 2, + __ETHTOOL_UDP_TUNNEL_TYPE_CNT = 3, +}; + +enum { + ETHTOOL_MSG_USER_NONE = 0, + ETHTOOL_MSG_STRSET_GET = 1, + ETHTOOL_MSG_LINKINFO_GET = 2, + ETHTOOL_MSG_LINKINFO_SET = 3, + ETHTOOL_MSG_LINKMODES_GET = 4, + ETHTOOL_MSG_LINKMODES_SET = 5, + ETHTOOL_MSG_LINKSTATE_GET = 6, + ETHTOOL_MSG_DEBUG_GET = 7, + ETHTOOL_MSG_DEBUG_SET = 8, + ETHTOOL_MSG_WOL_GET = 9, + ETHTOOL_MSG_WOL_SET = 10, + ETHTOOL_MSG_FEATURES_GET = 11, + ETHTOOL_MSG_FEATURES_SET = 12, + ETHTOOL_MSG_PRIVFLAGS_GET = 13, + ETHTOOL_MSG_PRIVFLAGS_SET = 14, + ETHTOOL_MSG_RINGS_GET = 15, + ETHTOOL_MSG_RINGS_SET = 16, + ETHTOOL_MSG_CHANNELS_GET = 17, + ETHTOOL_MSG_CHANNELS_SET = 18, + ETHTOOL_MSG_COALESCE_GET = 19, + ETHTOOL_MSG_COALESCE_SET = 20, + ETHTOOL_MSG_PAUSE_GET = 21, + ETHTOOL_MSG_PAUSE_SET = 22, + ETHTOOL_MSG_EEE_GET = 23, + ETHTOOL_MSG_EEE_SET = 24, + ETHTOOL_MSG_TSINFO_GET = 25, + ETHTOOL_MSG_CABLE_TEST_ACT = 26, + ETHTOOL_MSG_CABLE_TEST_TDR_ACT = 27, + ETHTOOL_MSG_TUNNEL_INFO_GET = 28, + __ETHTOOL_MSG_USER_CNT = 29, + ETHTOOL_MSG_USER_MAX = 28, +}; + +enum { + ETHTOOL_A_HEADER_UNSPEC = 0, + ETHTOOL_A_HEADER_DEV_INDEX = 1, + ETHTOOL_A_HEADER_DEV_NAME = 2, + ETHTOOL_A_HEADER_FLAGS = 3, + __ETHTOOL_A_HEADER_CNT = 4, + ETHTOOL_A_HEADER_MAX = 3, +}; + +enum { + ETHTOOL_A_STRSET_UNSPEC = 0, + ETHTOOL_A_STRSET_HEADER = 1, + ETHTOOL_A_STRSET_STRINGSETS = 2, + ETHTOOL_A_STRSET_COUNTS_ONLY = 3, + __ETHTOOL_A_STRSET_CNT = 4, + ETHTOOL_A_STRSET_MAX = 3, +}; + +enum { + ETHTOOL_A_LINKINFO_UNSPEC = 0, + ETHTOOL_A_LINKINFO_HEADER = 1, + ETHTOOL_A_LINKINFO_PORT = 2, + ETHTOOL_A_LINKINFO_PHYADDR = 3, + ETHTOOL_A_LINKINFO_TP_MDIX = 4, + ETHTOOL_A_LINKINFO_TP_MDIX_CTRL = 5, + ETHTOOL_A_LINKINFO_TRANSCEIVER = 6, + __ETHTOOL_A_LINKINFO_CNT = 7, + ETHTOOL_A_LINKINFO_MAX = 6, +}; + +enum { + ETHTOOL_A_LINKMODES_UNSPEC = 0, + ETHTOOL_A_LINKMODES_HEADER = 1, + ETHTOOL_A_LINKMODES_AUTONEG = 2, + ETHTOOL_A_LINKMODES_OURS = 3, + ETHTOOL_A_LINKMODES_PEER = 4, + ETHTOOL_A_LINKMODES_SPEED = 5, + ETHTOOL_A_LINKMODES_DUPLEX = 6, + ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG = 7, + ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE = 8, + __ETHTOOL_A_LINKMODES_CNT = 9, + ETHTOOL_A_LINKMODES_MAX = 8, +}; + +enum { + ETHTOOL_A_LINKSTATE_UNSPEC = 0, + ETHTOOL_A_LINKSTATE_HEADER = 1, + ETHTOOL_A_LINKSTATE_LINK = 2, + ETHTOOL_A_LINKSTATE_SQI = 3, + ETHTOOL_A_LINKSTATE_SQI_MAX = 4, + ETHTOOL_A_LINKSTATE_EXT_STATE = 5, + ETHTOOL_A_LINKSTATE_EXT_SUBSTATE = 6, + __ETHTOOL_A_LINKSTATE_CNT = 7, + ETHTOOL_A_LINKSTATE_MAX = 6, +}; + +enum { + ETHTOOL_A_DEBUG_UNSPEC = 0, + ETHTOOL_A_DEBUG_HEADER = 1, + ETHTOOL_A_DEBUG_MSGMASK = 2, + __ETHTOOL_A_DEBUG_CNT = 3, + ETHTOOL_A_DEBUG_MAX = 2, +}; + +enum { + ETHTOOL_A_WOL_UNSPEC = 0, + ETHTOOL_A_WOL_HEADER = 1, + ETHTOOL_A_WOL_MODES = 2, + ETHTOOL_A_WOL_SOPASS = 3, + __ETHTOOL_A_WOL_CNT = 4, + ETHTOOL_A_WOL_MAX = 3, +}; + +enum { + ETHTOOL_A_FEATURES_UNSPEC = 0, + ETHTOOL_A_FEATURES_HEADER = 1, + ETHTOOL_A_FEATURES_HW = 2, + ETHTOOL_A_FEATURES_WANTED = 3, + ETHTOOL_A_FEATURES_ACTIVE = 4, + ETHTOOL_A_FEATURES_NOCHANGE = 5, + __ETHTOOL_A_FEATURES_CNT = 6, + ETHTOOL_A_FEATURES_MAX = 5, +}; + +enum { + ETHTOOL_A_PRIVFLAGS_UNSPEC = 0, + ETHTOOL_A_PRIVFLAGS_HEADER = 1, + ETHTOOL_A_PRIVFLAGS_FLAGS = 2, + __ETHTOOL_A_PRIVFLAGS_CNT = 3, + ETHTOOL_A_PRIVFLAGS_MAX = 2, +}; + +enum { + ETHTOOL_A_RINGS_UNSPEC = 0, + ETHTOOL_A_RINGS_HEADER = 1, + ETHTOOL_A_RINGS_RX_MAX = 2, + ETHTOOL_A_RINGS_RX_MINI_MAX = 3, + ETHTOOL_A_RINGS_RX_JUMBO_MAX = 4, + ETHTOOL_A_RINGS_TX_MAX = 5, + ETHTOOL_A_RINGS_RX = 6, + ETHTOOL_A_RINGS_RX_MINI = 7, + ETHTOOL_A_RINGS_RX_JUMBO = 8, + ETHTOOL_A_RINGS_TX = 9, + __ETHTOOL_A_RINGS_CNT = 10, + ETHTOOL_A_RINGS_MAX = 9, +}; + +enum { + ETHTOOL_A_CHANNELS_UNSPEC = 0, + ETHTOOL_A_CHANNELS_HEADER = 1, + ETHTOOL_A_CHANNELS_RX_MAX = 2, + ETHTOOL_A_CHANNELS_TX_MAX = 3, + ETHTOOL_A_CHANNELS_OTHER_MAX = 4, + ETHTOOL_A_CHANNELS_COMBINED_MAX = 5, + ETHTOOL_A_CHANNELS_RX_COUNT = 6, + ETHTOOL_A_CHANNELS_TX_COUNT = 7, + ETHTOOL_A_CHANNELS_OTHER_COUNT = 8, + ETHTOOL_A_CHANNELS_COMBINED_COUNT = 9, + __ETHTOOL_A_CHANNELS_CNT = 10, + ETHTOOL_A_CHANNELS_MAX = 9, +}; + +enum { + ETHTOOL_A_COALESCE_UNSPEC = 0, + ETHTOOL_A_COALESCE_HEADER = 1, + ETHTOOL_A_COALESCE_RX_USECS = 2, + ETHTOOL_A_COALESCE_RX_MAX_FRAMES = 3, + ETHTOOL_A_COALESCE_RX_USECS_IRQ = 4, + ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ = 5, + ETHTOOL_A_COALESCE_TX_USECS = 6, + ETHTOOL_A_COALESCE_TX_MAX_FRAMES = 7, + ETHTOOL_A_COALESCE_TX_USECS_IRQ = 8, + ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ = 9, + ETHTOOL_A_COALESCE_STATS_BLOCK_USECS = 10, + ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX = 11, + ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX = 12, + ETHTOOL_A_COALESCE_PKT_RATE_LOW = 13, + ETHTOOL_A_COALESCE_RX_USECS_LOW = 14, + ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW = 15, + ETHTOOL_A_COALESCE_TX_USECS_LOW = 16, + ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW = 17, + ETHTOOL_A_COALESCE_PKT_RATE_HIGH = 18, + ETHTOOL_A_COALESCE_RX_USECS_HIGH = 19, + ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH = 20, + ETHTOOL_A_COALESCE_TX_USECS_HIGH = 21, + ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH = 22, + ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 23, + __ETHTOOL_A_COALESCE_CNT = 24, + ETHTOOL_A_COALESCE_MAX = 23, +}; + +enum { + ETHTOOL_A_PAUSE_UNSPEC = 0, + ETHTOOL_A_PAUSE_HEADER = 1, + ETHTOOL_A_PAUSE_AUTONEG = 2, + ETHTOOL_A_PAUSE_RX = 3, + ETHTOOL_A_PAUSE_TX = 4, + ETHTOOL_A_PAUSE_STATS = 5, + __ETHTOOL_A_PAUSE_CNT = 6, + ETHTOOL_A_PAUSE_MAX = 5, +}; + +enum { + ETHTOOL_A_EEE_UNSPEC = 0, + ETHTOOL_A_EEE_HEADER = 1, + ETHTOOL_A_EEE_MODES_OURS = 2, + ETHTOOL_A_EEE_MODES_PEER = 3, + ETHTOOL_A_EEE_ACTIVE = 4, + ETHTOOL_A_EEE_ENABLED = 5, + ETHTOOL_A_EEE_TX_LPI_ENABLED = 6, + ETHTOOL_A_EEE_TX_LPI_TIMER = 7, + __ETHTOOL_A_EEE_CNT = 8, + ETHTOOL_A_EEE_MAX = 7, +}; + +enum { + ETHTOOL_A_TSINFO_UNSPEC = 0, + ETHTOOL_A_TSINFO_HEADER = 1, + ETHTOOL_A_TSINFO_TIMESTAMPING = 2, + ETHTOOL_A_TSINFO_TX_TYPES = 3, + ETHTOOL_A_TSINFO_RX_FILTERS = 4, + ETHTOOL_A_TSINFO_PHC_INDEX = 5, + __ETHTOOL_A_TSINFO_CNT = 6, + ETHTOOL_A_TSINFO_MAX = 5, +}; + +enum { + ETHTOOL_A_CABLE_TEST_UNSPEC = 0, + ETHTOOL_A_CABLE_TEST_HEADER = 1, + __ETHTOOL_A_CABLE_TEST_CNT = 2, + ETHTOOL_A_CABLE_TEST_MAX = 1, +}; + +enum { + ETHTOOL_A_CABLE_TEST_TDR_UNSPEC = 0, + ETHTOOL_A_CABLE_TEST_TDR_HEADER = 1, + ETHTOOL_A_CABLE_TEST_TDR_CFG = 2, + __ETHTOOL_A_CABLE_TEST_TDR_CNT = 3, + ETHTOOL_A_CABLE_TEST_TDR_MAX = 2, +}; + +enum { + ETHTOOL_A_TUNNEL_INFO_UNSPEC = 0, + ETHTOOL_A_TUNNEL_INFO_HEADER = 1, + ETHTOOL_A_TUNNEL_INFO_UDP_PORTS = 2, + __ETHTOOL_A_TUNNEL_INFO_CNT = 3, + ETHTOOL_A_TUNNEL_INFO_MAX = 2, +}; + +enum ethtool_multicast_groups { + ETHNL_MCGRP_MONITOR = 0, +}; + +struct ethnl_req_info { + struct net_device *dev; + u32 flags; +}; + +struct ethnl_reply_data { + struct net_device *dev; +}; + +struct ethnl_request_ops { + u8 request_cmd; + u8 reply_cmd; + u16 hdr_attr; + unsigned int req_info_size; + unsigned int reply_data_size; + bool allow_nodev_do; + int (*parse_request)(struct ethnl_req_info *, struct nlattr **, struct netlink_ext_ack *); + int (*prepare_data)(const struct ethnl_req_info *, struct ethnl_reply_data *, struct genl_info *); + int (*reply_size)(const struct ethnl_req_info *, const struct ethnl_reply_data *); + int (*fill_reply)(struct sk_buff *, const struct ethnl_req_info *, const struct ethnl_reply_data *); + void (*cleanup_data)(struct ethnl_reply_data *); +}; + +struct ethnl_dump_ctx { + const struct ethnl_request_ops *ops; + struct ethnl_req_info *req_info; + struct ethnl_reply_data *reply_data; + int pos_hash; + int pos_idx; +}; + +typedef void (*ethnl_notify_handler_t)(struct net_device *, unsigned int, const void *); + +enum { + ETHTOOL_A_BITSET_BIT_UNSPEC = 0, + ETHTOOL_A_BITSET_BIT_INDEX = 1, + ETHTOOL_A_BITSET_BIT_NAME = 2, + ETHTOOL_A_BITSET_BIT_VALUE = 3, + __ETHTOOL_A_BITSET_BIT_CNT = 4, + ETHTOOL_A_BITSET_BIT_MAX = 3, +}; + +enum { + ETHTOOL_A_BITSET_BITS_UNSPEC = 0, + ETHTOOL_A_BITSET_BITS_BIT = 1, + __ETHTOOL_A_BITSET_BITS_CNT = 2, + ETHTOOL_A_BITSET_BITS_MAX = 1, +}; + +enum { + ETHTOOL_A_BITSET_UNSPEC = 0, + ETHTOOL_A_BITSET_NOMASK = 1, + ETHTOOL_A_BITSET_SIZE = 2, + ETHTOOL_A_BITSET_BITS = 3, + ETHTOOL_A_BITSET_VALUE = 4, + ETHTOOL_A_BITSET_MASK = 5, + __ETHTOOL_A_BITSET_CNT = 6, + ETHTOOL_A_BITSET_MAX = 5, +}; + +typedef const char (* const ethnl_string_array_t)[32]; + +enum { + ETHTOOL_A_STRING_UNSPEC = 0, + ETHTOOL_A_STRING_INDEX = 1, + ETHTOOL_A_STRING_VALUE = 2, + __ETHTOOL_A_STRING_CNT = 3, + ETHTOOL_A_STRING_MAX = 2, +}; + +enum { + ETHTOOL_A_STRINGS_UNSPEC = 0, + ETHTOOL_A_STRINGS_STRING = 1, + __ETHTOOL_A_STRINGS_CNT = 2, + ETHTOOL_A_STRINGS_MAX = 1, +}; + +enum { + ETHTOOL_A_STRINGSET_UNSPEC = 0, + ETHTOOL_A_STRINGSET_ID = 1, + ETHTOOL_A_STRINGSET_COUNT = 2, + ETHTOOL_A_STRINGSET_STRINGS = 3, + __ETHTOOL_A_STRINGSET_CNT = 4, + ETHTOOL_A_STRINGSET_MAX = 3, +}; + +enum { + ETHTOOL_A_STRINGSETS_UNSPEC = 0, + ETHTOOL_A_STRINGSETS_STRINGSET = 1, + __ETHTOOL_A_STRINGSETS_CNT = 2, + ETHTOOL_A_STRINGSETS_MAX = 1, +}; + +struct strset_info { + bool per_dev; + bool free_strings; + unsigned int count; + const char (*strings)[32]; +}; + +struct strset_req_info { + struct ethnl_req_info base; + u32 req_ids; + bool counts_only; +}; + +struct strset_reply_data { + struct ethnl_reply_data base; + struct strset_info sets[16]; +}; + +struct linkinfo_reply_data { + struct ethnl_reply_data base; + struct ethtool_link_ksettings ksettings; + struct ethtool_link_settings *lsettings; +}; + +struct linkmodes_reply_data { + struct ethnl_reply_data base; + struct ethtool_link_ksettings ksettings; + struct ethtool_link_settings *lsettings; + bool peer_empty; +}; + +struct link_mode_info { + int speed; + u8 duplex; +}; + +struct linkstate_reply_data { + struct ethnl_reply_data base; + int link; + int sqi; + int sqi_max; + bool link_ext_state_provided; + struct ethtool_link_ext_state_info ethtool_link_ext_state_info; +}; + +struct debug_reply_data { + struct ethnl_reply_data base; + u32 msg_mask; +}; + +struct wol_reply_data { + struct ethnl_reply_data base; + struct ethtool_wolinfo wol; + bool show_sopass; +}; + +struct features_reply_data { + struct ethnl_reply_data base; + u32 hw[2]; + u32 wanted[2]; + u32 active[2]; + u32 nochange[2]; + u32 all[2]; +}; + +struct privflags_reply_data { + struct ethnl_reply_data base; + const char (*priv_flag_names)[32]; + unsigned int n_priv_flags; + u32 priv_flags; +}; + +struct rings_reply_data { + struct ethnl_reply_data base; + struct ethtool_ringparam ringparam; +}; + +struct channels_reply_data { + struct ethnl_reply_data base; + struct ethtool_channels channels; +}; + +struct coalesce_reply_data { + struct ethnl_reply_data base; + struct ethtool_coalesce coalesce; + u32 supported_params; +}; + +enum { + ETHTOOL_A_PAUSE_STAT_UNSPEC = 0, + ETHTOOL_A_PAUSE_STAT_PAD = 1, + ETHTOOL_A_PAUSE_STAT_TX_FRAMES = 2, + ETHTOOL_A_PAUSE_STAT_RX_FRAMES = 3, + __ETHTOOL_A_PAUSE_STAT_CNT = 4, + ETHTOOL_A_PAUSE_STAT_MAX = 3, +}; + +struct pause_reply_data { + struct ethnl_reply_data base; + struct ethtool_pauseparam pauseparam; + struct ethtool_pause_stats pausestat; +}; + +struct eee_reply_data { + struct ethnl_reply_data base; + struct ethtool_eee eee; +}; + +struct tsinfo_reply_data { + struct ethnl_reply_data base; + struct ethtool_ts_info ts_info; +}; + +enum { + ETHTOOL_A_CABLE_PAIR_A = 0, + ETHTOOL_A_CABLE_PAIR_B = 1, + ETHTOOL_A_CABLE_PAIR_C = 2, + ETHTOOL_A_CABLE_PAIR_D = 3, +}; + +enum { + ETHTOOL_A_CABLE_RESULT_UNSPEC = 0, + ETHTOOL_A_CABLE_RESULT_PAIR = 1, + ETHTOOL_A_CABLE_RESULT_CODE = 2, + __ETHTOOL_A_CABLE_RESULT_CNT = 3, + ETHTOOL_A_CABLE_RESULT_MAX = 2, +}; + +enum { + ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC = 0, + ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR = 1, + ETHTOOL_A_CABLE_FAULT_LENGTH_CM = 2, + __ETHTOOL_A_CABLE_FAULT_LENGTH_CNT = 3, + ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 2, +}; + +enum { + ETHTOOL_A_CABLE_TEST_NTF_STATUS_UNSPEC = 0, + ETHTOOL_A_CABLE_TEST_NTF_STATUS_STARTED = 1, + ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED = 2, +}; + +enum { + ETHTOOL_A_CABLE_NEST_UNSPEC = 0, + ETHTOOL_A_CABLE_NEST_RESULT = 1, + ETHTOOL_A_CABLE_NEST_FAULT_LENGTH = 2, + __ETHTOOL_A_CABLE_NEST_CNT = 3, + ETHTOOL_A_CABLE_NEST_MAX = 2, +}; + +enum { + ETHTOOL_A_CABLE_TEST_NTF_UNSPEC = 0, + ETHTOOL_A_CABLE_TEST_NTF_HEADER = 1, + ETHTOOL_A_CABLE_TEST_NTF_STATUS = 2, + ETHTOOL_A_CABLE_TEST_NTF_NEST = 3, + __ETHTOOL_A_CABLE_TEST_NTF_CNT = 4, + ETHTOOL_A_CABLE_TEST_NTF_MAX = 3, +}; + +enum { + ETHTOOL_A_CABLE_TEST_TDR_CFG_UNSPEC = 0, + ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST = 1, + ETHTOOL_A_CABLE_TEST_TDR_CFG_LAST = 2, + ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP = 3, + ETHTOOL_A_CABLE_TEST_TDR_CFG_PAIR = 4, + __ETHTOOL_A_CABLE_TEST_TDR_CFG_CNT = 5, + ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX = 4, +}; + +enum { + ETHTOOL_A_CABLE_AMPLITUDE_UNSPEC = 0, + ETHTOOL_A_CABLE_AMPLITUDE_PAIR = 1, + ETHTOOL_A_CABLE_AMPLITUDE_mV = 2, + __ETHTOOL_A_CABLE_AMPLITUDE_CNT = 3, + ETHTOOL_A_CABLE_AMPLITUDE_MAX = 2, +}; + +enum { + ETHTOOL_A_CABLE_PULSE_UNSPEC = 0, + ETHTOOL_A_CABLE_PULSE_mV = 1, + __ETHTOOL_A_CABLE_PULSE_CNT = 2, + ETHTOOL_A_CABLE_PULSE_MAX = 1, +}; + +enum { + ETHTOOL_A_CABLE_STEP_UNSPEC = 0, + ETHTOOL_A_CABLE_STEP_FIRST_DISTANCE = 1, + ETHTOOL_A_CABLE_STEP_LAST_DISTANCE = 2, + ETHTOOL_A_CABLE_STEP_STEP_DISTANCE = 3, + __ETHTOOL_A_CABLE_STEP_CNT = 4, + ETHTOOL_A_CABLE_STEP_MAX = 3, +}; + +enum { + ETHTOOL_A_CABLE_TDR_NEST_UNSPEC = 0, + ETHTOOL_A_CABLE_TDR_NEST_STEP = 1, + ETHTOOL_A_CABLE_TDR_NEST_AMPLITUDE = 2, + ETHTOOL_A_CABLE_TDR_NEST_PULSE = 3, + __ETHTOOL_A_CABLE_TDR_NEST_CNT = 4, + ETHTOOL_A_CABLE_TDR_NEST_MAX = 3, +}; + +enum { + ETHTOOL_A_TUNNEL_UDP_ENTRY_UNSPEC = 0, + ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT = 1, + ETHTOOL_A_TUNNEL_UDP_ENTRY_TYPE = 2, + __ETHTOOL_A_TUNNEL_UDP_ENTRY_CNT = 3, + ETHTOOL_A_TUNNEL_UDP_ENTRY_MAX = 2, +}; + +enum { + ETHTOOL_A_TUNNEL_UDP_TABLE_UNSPEC = 0, + ETHTOOL_A_TUNNEL_UDP_TABLE_SIZE = 1, + ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES = 2, + ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY = 3, + __ETHTOOL_A_TUNNEL_UDP_TABLE_CNT = 4, + ETHTOOL_A_TUNNEL_UDP_TABLE_MAX = 3, +}; + +enum { + ETHTOOL_A_TUNNEL_UDP_UNSPEC = 0, + ETHTOOL_A_TUNNEL_UDP_TABLE = 1, + __ETHTOOL_A_TUNNEL_UDP_CNT = 2, + ETHTOOL_A_TUNNEL_UDP_MAX = 1, +}; + +struct ethnl_tunnel_info_dump_ctx { + struct ethnl_req_info req_info; + int pos_hash; + int pos_idx; +}; + +struct nf_hook_entries_rcu_head { + struct callback_head head; + void *allocation; +}; + +struct nf_conn; + +struct nf_conntrack_tuple; + +struct nf_conntrack; + +struct nf_ct_hook { + int (*update)(struct net *, struct sk_buff *); + void (*destroy)(struct nf_conntrack *); + bool (*get_tuple_skb)(struct nf_conntrack_tuple *, const struct sk_buff *); +}; + +struct nfnl_ct_hook { + struct nf_conn * (*get_ct)(const struct sk_buff *, enum ip_conntrack_info *); + size_t (*build_size)(const struct nf_conn *); + int (*build)(struct sk_buff *, struct nf_conn *, enum ip_conntrack_info, u_int16_t, u_int16_t); + int (*parse)(const struct nlattr *, struct nf_conn *); + int (*attach_expect)(const struct nlattr *, struct nf_conn *, u32, u32); + void (*seq_adjust)(struct sk_buff *, struct nf_conn *, enum ip_conntrack_info, s32); +}; + +struct nf_ipv6_ops { + void (*route_input)(struct sk_buff *); + int (*fragment)(struct net *, struct sock *, struct sk_buff *, int (*)(struct net *, struct sock *, struct sk_buff *)); + int (*reroute)(struct sk_buff *, const struct nf_queue_entry *); +}; + +struct nf_queue_entry { + struct list_head list; + struct sk_buff *skb; + unsigned int id; + unsigned int hook_index; + struct net_device *physin; + struct net_device *physout; + struct nf_hook_state state; + u16 size; +}; + +struct nf_loginfo { + u_int8_t type; + union { + struct { + u_int32_t copy_len; + u_int16_t group; + u_int16_t qthreshold; + u_int16_t flags; + } ulog; + struct { + u_int8_t level; + u_int8_t logflags; + } log; + } u; +}; + +struct nf_log_buf { + unsigned int count; + char buf[1020]; +}; + +struct nf_bridge_info { + enum { + BRNF_PROTO_UNCHANGED = 0, + BRNF_PROTO_8021Q = 1, + BRNF_PROTO_PPPOE = 2, + } orig_proto: 8; + u8 pkt_otherhost: 1; + u8 in_prerouting: 1; + u8 bridged_dnat: 1; + __u16 frag_max_size; + struct net_device *physindev; + struct net_device *physoutdev; + union { + __be32 ipv4_daddr; + struct in6_addr ipv6_daddr; + char neigh_header[8]; + }; +}; + +struct ip_rt_info { + __be32 daddr; + __be32 saddr; + u_int8_t tos; + u_int32_t mark; +}; + +struct ip6_rt_info { + struct in6_addr daddr; + struct in6_addr saddr; + u_int32_t mark; +}; + +struct nf_sockopt_ops { + struct list_head list; + u_int8_t pf; + int set_optmin; + int set_optmax; + int (*set)(struct sock *, int, sockptr_t, unsigned int); + int get_optmin; + int get_optmax; + int (*get)(struct sock *, int, void *, int *); + struct module *owner; +}; + +enum nfnetlink_groups { + NFNLGRP_NONE = 0, + NFNLGRP_CONNTRACK_NEW = 1, + NFNLGRP_CONNTRACK_UPDATE = 2, + NFNLGRP_CONNTRACK_DESTROY = 3, + NFNLGRP_CONNTRACK_EXP_NEW = 4, + NFNLGRP_CONNTRACK_EXP_UPDATE = 5, + NFNLGRP_CONNTRACK_EXP_DESTROY = 6, + NFNLGRP_NFTABLES = 7, + NFNLGRP_ACCT_QUOTA = 8, + NFNLGRP_NFTRACE = 9, + __NFNLGRP_MAX = 10, +}; + +struct nfgenmsg { + __u8 nfgen_family; + __u8 version; + __be16 res_id; +}; + +enum nfnl_batch_attributes { + NFNL_BATCH_UNSPEC = 0, + NFNL_BATCH_GENID = 1, + __NFNL_BATCH_MAX = 2, +}; + +struct nfnl_callback { + int (*call)(struct net *, struct sock *, struct sk_buff *, const struct nlmsghdr *, const struct nlattr * const *, struct netlink_ext_ack *); + int (*call_rcu)(struct net *, struct sock *, struct sk_buff *, const struct nlmsghdr *, const struct nlattr * const *, struct netlink_ext_ack *); + int (*call_batch)(struct net *, struct sock *, struct sk_buff *, const struct nlmsghdr *, const struct nlattr * const *, struct netlink_ext_ack *); + const struct nla_policy *policy; + const u_int16_t attr_count; +}; + +enum nfnl_abort_action { + NFNL_ABORT_NONE = 0, + NFNL_ABORT_AUTOLOAD = 1, + NFNL_ABORT_VALIDATE = 2, +}; + +struct nfnetlink_subsystem { + const char *name; + __u8 subsys_id; + __u8 cb_count; + const struct nfnl_callback *cb; + struct module *owner; + int (*commit)(struct net *, struct sk_buff *); + int (*abort)(struct net *, struct sk_buff *, enum nfnl_abort_action); + void (*cleanup)(struct net *); + bool (*valid_genid)(struct net *, u32); +}; + +struct nfnl_err { + struct list_head head; + struct nlmsghdr *nlh; + int err; + struct netlink_ext_ack extack; +}; + +enum { + NFNL_BATCH_FAILURE = 1, + NFNL_BATCH_DONE = 2, + NFNL_BATCH_REPLAY = 4, +}; + +struct nf_conntrack { + atomic_t use; +}; + +enum nfqnl_msg_types { + NFQNL_MSG_PACKET = 0, + NFQNL_MSG_VERDICT = 1, + NFQNL_MSG_CONFIG = 2, + NFQNL_MSG_VERDICT_BATCH = 3, + NFQNL_MSG_MAX = 4, +}; + +struct nfqnl_msg_packet_hdr { + __be32 packet_id; + __be16 hw_protocol; + __u8 hook; +} __attribute__((packed)); + +struct nfqnl_msg_packet_hw { + __be16 hw_addrlen; + __u16 _pad; + __u8 hw_addr[8]; +}; + +struct nfqnl_msg_packet_timestamp { + __be64 sec; + __be64 usec; +}; + +enum nfqnl_vlan_attr { + NFQA_VLAN_UNSPEC = 0, + NFQA_VLAN_PROTO = 1, + NFQA_VLAN_TCI = 2, + __NFQA_VLAN_MAX = 3, +}; + +enum nfqnl_attr_type { + NFQA_UNSPEC = 0, + NFQA_PACKET_HDR = 1, + NFQA_VERDICT_HDR = 2, + NFQA_MARK = 3, + NFQA_TIMESTAMP = 4, + NFQA_IFINDEX_INDEV = 5, + NFQA_IFINDEX_OUTDEV = 6, + NFQA_IFINDEX_PHYSINDEV = 7, + NFQA_IFINDEX_PHYSOUTDEV = 8, + NFQA_HWADDR = 9, + NFQA_PAYLOAD = 10, + NFQA_CT = 11, + NFQA_CT_INFO = 12, + NFQA_CAP_LEN = 13, + NFQA_SKB_INFO = 14, + NFQA_EXP = 15, + NFQA_UID = 16, + NFQA_GID = 17, + NFQA_SECCTX = 18, + NFQA_VLAN = 19, + NFQA_L2HDR = 20, + __NFQA_MAX = 21, +}; + +struct nfqnl_msg_verdict_hdr { + __be32 verdict; + __be32 id; +}; + +enum nfqnl_msg_config_cmds { + NFQNL_CFG_CMD_NONE = 0, + NFQNL_CFG_CMD_BIND = 1, + NFQNL_CFG_CMD_UNBIND = 2, + NFQNL_CFG_CMD_PF_BIND = 3, + NFQNL_CFG_CMD_PF_UNBIND = 4, +}; + +struct nfqnl_msg_config_cmd { + __u8 command; + __u8 _pad; + __be16 pf; +}; + +enum nfqnl_config_mode { + NFQNL_COPY_NONE = 0, + NFQNL_COPY_META = 1, + NFQNL_COPY_PACKET = 2, +}; + +struct nfqnl_msg_config_params { + __be32 copy_range; + __u8 copy_mode; +} __attribute__((packed)); + +enum nfqnl_attr_config { + NFQA_CFG_UNSPEC = 0, + NFQA_CFG_CMD = 1, + NFQA_CFG_PARAMS = 2, + NFQA_CFG_QUEUE_MAXLEN = 3, + NFQA_CFG_MASK = 4, + NFQA_CFG_FLAGS = 5, + __NFQA_CFG_MAX = 6, +}; + +struct nfqnl_instance { + struct hlist_node hlist; + struct callback_head rcu; + u32 peer_portid; + unsigned int queue_maxlen; + unsigned int copy_range; + unsigned int queue_dropped; + unsigned int queue_user_dropped; + u_int16_t queue_num; + u_int8_t copy_mode; + u_int32_t flags; + spinlock_t lock; + unsigned int queue_total; + unsigned int id_sequence; + struct list_head queue_list; + long: 64; + long: 64; +}; + +typedef int (*nfqnl_cmpfn)(struct nf_queue_entry *, long unsigned int); + +struct nfnl_queue_net { + spinlock_t instances_lock; + struct hlist_head instance_table[16]; +}; + +struct iter_state { + struct seq_net_private p; + unsigned int bucket; +}; + +enum nfulnl_msg_types { + NFULNL_MSG_PACKET = 0, + NFULNL_MSG_CONFIG = 1, + NFULNL_MSG_MAX = 2, +}; + +struct nfulnl_msg_packet_hdr { + __be16 hw_protocol; + __u8 hook; + __u8 _pad; +}; + +struct nfulnl_msg_packet_hw { + __be16 hw_addrlen; + __u16 _pad; + __u8 hw_addr[8]; +}; + +struct nfulnl_msg_packet_timestamp { + __be64 sec; + __be64 usec; +}; + +enum nfulnl_vlan_attr { + NFULA_VLAN_UNSPEC = 0, + NFULA_VLAN_PROTO = 1, + NFULA_VLAN_TCI = 2, + __NFULA_VLAN_MAX = 3, +}; + +enum nfulnl_attr_type { + NFULA_UNSPEC = 0, + NFULA_PACKET_HDR = 1, + NFULA_MARK = 2, + NFULA_TIMESTAMP = 3, + NFULA_IFINDEX_INDEV = 4, + NFULA_IFINDEX_OUTDEV = 5, + NFULA_IFINDEX_PHYSINDEV = 6, + NFULA_IFINDEX_PHYSOUTDEV = 7, + NFULA_HWADDR = 8, + NFULA_PAYLOAD = 9, + NFULA_PREFIX = 10, + NFULA_UID = 11, + NFULA_SEQ = 12, + NFULA_SEQ_GLOBAL = 13, + NFULA_GID = 14, + NFULA_HWTYPE = 15, + NFULA_HWHEADER = 16, + NFULA_HWLEN = 17, + NFULA_CT = 18, + NFULA_CT_INFO = 19, + NFULA_VLAN = 20, + NFULA_L2HDR = 21, + __NFULA_MAX = 22, +}; + +enum nfulnl_msg_config_cmds { + NFULNL_CFG_CMD_NONE = 0, + NFULNL_CFG_CMD_BIND = 1, + NFULNL_CFG_CMD_UNBIND = 2, + NFULNL_CFG_CMD_PF_BIND = 3, + NFULNL_CFG_CMD_PF_UNBIND = 4, +}; + +struct nfulnl_msg_config_cmd { + __u8 command; +}; + +struct nfulnl_msg_config_mode { + __be32 copy_range; + __u8 copy_mode; + __u8 _pad; +} __attribute__((packed)); + +enum nfulnl_attr_config { + NFULA_CFG_UNSPEC = 0, + NFULA_CFG_CMD = 1, + NFULA_CFG_MODE = 2, + NFULA_CFG_NLBUFSIZ = 3, + NFULA_CFG_TIMEOUT = 4, + NFULA_CFG_QTHRESH = 5, + NFULA_CFG_FLAGS = 6, + __NFULA_CFG_MAX = 7, +}; + +struct nfulnl_instance { + struct hlist_node hlist; + spinlock_t lock; + refcount_t use; + unsigned int qlen; + struct sk_buff *skb; + struct timer_list timer; + struct net *net; + struct user_namespace *peer_user_ns; + u32 peer_portid; + unsigned int flushtimeout; + unsigned int nlbufsiz; + unsigned int qthreshold; + u_int32_t copy_range; + u_int32_t seq; + u_int16_t group_num; + u_int16_t flags; + u_int8_t copy_mode; + struct callback_head rcu; +}; + +struct nfnl_log_net { + spinlock_t instances_lock; + struct hlist_head instance_table[16]; + atomic_t global_seq; +}; + +struct xt_table_info; + +struct xt_table { + struct list_head list; + unsigned int valid_hooks; + struct xt_table_info *private; + struct module *me; + u_int8_t af; + int priority; + int (*table_init)(struct net *); + const char name[32]; +}; + +struct xt_action_param; + +struct xt_mtchk_param; + +struct xt_mtdtor_param; + +struct xt_match { + struct list_head list; + const char name[29]; + u_int8_t revision; + bool (*match)(const struct sk_buff *, struct xt_action_param *); + int (*checkentry)(const struct xt_mtchk_param *); + void (*destroy)(const struct xt_mtdtor_param *); + void (*compat_from_user)(void *, const void *); + int (*compat_to_user)(void *, const void *); + struct module *me; + const char *table; + unsigned int matchsize; + unsigned int usersize; + unsigned int compatsize; + unsigned int hooks; + short unsigned int proto; + short unsigned int family; +}; + +struct xt_entry_match { + union { + struct { + __u16 match_size; + char name[29]; + __u8 revision; + } user; + struct { + __u16 match_size; + struct xt_match *match; + } kernel; + __u16 match_size; + } u; + unsigned char data[0]; +}; + +struct xt_tgchk_param; + +struct xt_tgdtor_param; + +struct xt_target { + struct list_head list; + const char name[29]; + u_int8_t revision; + unsigned int (*target)(struct sk_buff *, const struct xt_action_param *); + int (*checkentry)(const struct xt_tgchk_param *); + void (*destroy)(const struct xt_tgdtor_param *); + void (*compat_from_user)(void *, const void *); + int (*compat_to_user)(void *, const void *); + struct module *me; + const char *table; + unsigned int targetsize; + unsigned int usersize; + unsigned int compatsize; + unsigned int hooks; + short unsigned int proto; + short unsigned int family; +}; + +struct xt_entry_target { + union { + struct { + __u16 target_size; + char name[29]; + __u8 revision; + } user; + struct { + __u16 target_size; + struct xt_target *target; + } kernel; + __u16 target_size; + } u; + unsigned char data[0]; +}; + +struct xt_standard_target { + struct xt_entry_target target; + int verdict; +}; + +struct xt_error_target { + struct xt_entry_target target; + char errorname[30]; +}; + +struct xt_counters { + __u64 pcnt; + __u64 bcnt; +}; + +struct xt_counters_info { + char name[32]; + unsigned int num_counters; + struct xt_counters counters[0]; +}; + +struct xt_action_param { + union { + const struct xt_match *match; + const struct xt_target *target; + }; + union { + const void *matchinfo; + const void *targinfo; + }; + const struct nf_hook_state *state; + int fragoff; + unsigned int thoff; + bool hotdrop; +}; + +struct xt_mtchk_param { + struct net *net; + const char *table; + const void *entryinfo; + const struct xt_match *match; + void *matchinfo; + unsigned int hook_mask; + u_int8_t family; + bool nft_compat; +}; + +struct xt_mtdtor_param { + struct net *net; + const struct xt_match *match; + void *matchinfo; + u_int8_t family; +}; + +struct xt_tgchk_param { + struct net *net; + const char *table; + const void *entryinfo; + const struct xt_target *target; + void *targinfo; + unsigned int hook_mask; + u_int8_t family; + bool nft_compat; +}; + +struct xt_tgdtor_param { + struct net *net; + const struct xt_target *target; + void *targinfo; + u_int8_t family; +}; + +struct xt_table_info { + unsigned int size; + unsigned int number; + unsigned int initial_entries; + unsigned int hook_entry[5]; + unsigned int underflow[5]; + unsigned int stacksize; + void ***jumpstack; + unsigned char entries[0]; +}; + +struct xt_percpu_counter_alloc_state { + unsigned int off; + const char *mem; +}; + +struct compat_xt_entry_match { + union { + struct { + u_int16_t match_size; + char name[29]; + u_int8_t revision; + } user; + struct { + u_int16_t match_size; + compat_uptr_t match; + } kernel; + u_int16_t match_size; + } u; + unsigned char data[0]; +}; + +struct compat_xt_entry_target { + union { + struct { + u_int16_t target_size; + char name[29]; + u_int8_t revision; + } user; + struct { + u_int16_t target_size; + compat_uptr_t target; + } kernel; + u_int16_t target_size; + } u; + unsigned char data[0]; +}; + +struct compat_xt_counters { + compat_u64 pcnt; + compat_u64 bcnt; +}; + +struct compat_xt_counters_info { + char name[32]; + compat_uint_t num_counters; + struct compat_xt_counters counters[0]; +} __attribute__((packed)); + +struct compat_delta { + unsigned int offset; + int delta; +}; + +struct xt_af { + struct mutex mutex; + struct list_head match; + struct list_head target; + struct mutex compat_mutex; + struct compat_delta *compat_tab; + unsigned int number; + unsigned int cur; +}; + +struct compat_xt_standard_target { + struct compat_xt_entry_target t; + compat_uint_t verdict; +}; + +struct compat_xt_error_target { + struct compat_xt_entry_target t; + char errorname[30]; +}; + +struct nf_mttg_trav { + struct list_head *head; + struct list_head *curr; + uint8_t class; +}; + +enum { + MTTG_TRAV_INIT = 0, + MTTG_TRAV_NFP_UNSPEC = 1, + MTTG_TRAV_NFP_SPEC = 2, + MTTG_TRAV_DONE = 3, +}; + +struct xt_tcp { + __u16 spts[2]; + __u16 dpts[2]; + __u8 option; + __u8 flg_mask; + __u8 flg_cmp; + __u8 invflags; +}; + +struct xt_udp { + __u16 spts[2]; + __u16 dpts[2]; + __u8 invflags; +}; + +struct xt_bpf_info { + __u16 bpf_program_num_elem; + struct sock_filter bpf_program[64]; + struct bpf_prog *filter; +}; + +enum xt_bpf_modes { + XT_BPF_MODE_BYTECODE = 0, + XT_BPF_MODE_FD_PINNED = 1, + XT_BPF_MODE_FD_ELF = 2, +}; + +struct xt_bpf_info_v1 { + __u16 mode; + __u16 bpf_program_num_elem; + __s32 fd; + union { + struct sock_filter bpf_program[64]; + char path[512]; + }; + struct bpf_prog *filter; +}; + +enum xt_statistic_mode { + XT_STATISTIC_MODE_RANDOM = 0, + XT_STATISTIC_MODE_NTH = 1, + __XT_STATISTIC_MODE_MAX = 2, +}; + +enum xt_statistic_flags { + XT_STATISTIC_INVERT = 1, +}; + +struct xt_statistic_priv; + +struct xt_statistic_info { + __u16 mode; + __u16 flags; + union { + struct { + __u32 probability; + } random; + struct { + __u32 every; + __u32 packet; + __u32 count; + } nth; + } u; + struct xt_statistic_priv *master; +}; + +struct xt_statistic_priv { + atomic_t count; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct mr_table_ops { + const struct rhashtable_params *rht_params; + void *cmparg_any; +}; + +struct vif_device { + struct net_device *dev; + long unsigned int bytes_in; + long unsigned int bytes_out; + long unsigned int pkt_in; + long unsigned int pkt_out; + long unsigned int rate_limit; + unsigned char threshold; + short unsigned int flags; + int link; + struct netdev_phys_item_id dev_parent_id; + __be32 local; + __be32 remote; +}; + +struct mr_table { + struct list_head list; + possible_net_t net; + struct mr_table_ops ops; + u32 id; + struct sock *mroute_sk; + struct timer_list ipmr_expire_timer; + struct list_head mfc_unres_queue; + struct vif_device vif_table[32]; + struct rhltable mfc_hash; + struct list_head mfc_cache_list; + int maxvif; + atomic_t cache_resolve_queue_len; + bool mroute_do_assert; + bool mroute_do_pim; + bool mroute_do_wrvifwhole; + int mroute_reg_vif_num; +}; + +struct rtmsg { + unsigned char rtm_family; + unsigned char rtm_dst_len; + unsigned char rtm_src_len; + unsigned char rtm_tos; + unsigned char rtm_table; + unsigned char rtm_protocol; + unsigned char rtm_scope; + unsigned char rtm_type; + unsigned int rtm_flags; +}; + +struct rtvia { + __kernel_sa_family_t rtvia_family; + __u8 rtvia_addr[0]; +}; + +struct ip_sf_list; + +struct ip_mc_list { + struct in_device *interface; + __be32 multiaddr; + unsigned int sfmode; + struct ip_sf_list *sources; + struct ip_sf_list *tomb; + long unsigned int sfcount[2]; + union { + struct ip_mc_list *next; + struct ip_mc_list *next_rcu; + }; + struct ip_mc_list *next_hash; + struct timer_list timer; + int users; + refcount_t refcnt; + spinlock_t lock; + char tm_running; + char reporter; + char unsolicit_count; + char loaded; + unsigned char gsquery; + unsigned char crcount; + struct callback_head rcu; +}; + +struct ip_sf_list { + struct ip_sf_list *sf_next; + long unsigned int sf_count[2]; + __be32 sf_inaddr; + unsigned char sf_gsresp; + unsigned char sf_oldin; + unsigned char sf_crcount; +}; + +struct ipv4_addr_key { + __be32 addr; + int vif; +}; + +struct inetpeer_addr { + union { + struct ipv4_addr_key a4; + struct in6_addr a6; + u32 key[4]; + }; + __u16 family; +}; + +struct inet_peer { + struct rb_node rb_node; + struct inetpeer_addr daddr; + u32 metrics[17]; + u32 rate_tokens; + u32 n_redirects; + long unsigned int rate_last; + union { + struct { + atomic_t rid; + }; + struct callback_head rcu; + }; + __u32 dtime; + refcount_t refcnt; +}; + +struct uncached_list { + spinlock_t lock; + struct list_head head; +}; + +struct ip_rt_acct { + __u32 o_bytes; + __u32 o_packets; + __u32 i_bytes; + __u32 i_packets; +}; + +struct rt_cache_stat { + unsigned int in_slow_tot; + unsigned int in_slow_mc; + unsigned int in_no_route; + unsigned int in_brd; + unsigned int in_martian_dst; + unsigned int in_martian_src; + unsigned int out_slow_tot; + unsigned int out_slow_mc; +}; + +struct fib_alias { + struct hlist_node fa_list; + struct fib_info *fa_info; + u8 fa_tos; + u8 fa_type; + u8 fa_state; + u8 fa_slen; + u32 tb_id; + s16 fa_default; + u8 offload: 1; + u8 trap: 1; + u8 unused: 6; + struct callback_head rcu; +}; + +struct fib_prop { + int error; + u8 scope; +}; + +struct net_offload { + struct offload_callbacks callbacks; + unsigned int flags; +}; + +struct raw_hashinfo { + rwlock_t lock; + struct hlist_head ht[256]; +}; + +enum ip_defrag_users { + IP_DEFRAG_LOCAL_DELIVER = 0, + IP_DEFRAG_CALL_RA_CHAIN = 1, + IP_DEFRAG_CONNTRACK_IN = 2, + __IP_DEFRAG_CONNTRACK_IN_END = 65537, + IP_DEFRAG_CONNTRACK_OUT = 65538, + __IP_DEFRAG_CONNTRACK_OUT_END = 131073, + IP_DEFRAG_CONNTRACK_BRIDGE_IN = 131074, + __IP_DEFRAG_CONNTRACK_BRIDGE_IN = 196609, + IP_DEFRAG_VS_IN = 196610, + IP_DEFRAG_VS_OUT = 196611, + IP_DEFRAG_VS_FWD = 196612, + IP_DEFRAG_AF_PACKET = 196613, + IP_DEFRAG_MACVLAN = 196614, +}; + +enum { + INET_FRAG_FIRST_IN = 1, + INET_FRAG_LAST_IN = 2, + INET_FRAG_COMPLETE = 4, + INET_FRAG_HASH_DEAD = 8, +}; + +struct ipq { + struct inet_frag_queue q; + u8 ecn; + u16 max_df_size; + int iif; + unsigned int rid; + struct inet_peer *peer; +}; + +struct ip_options_data { + struct ip_options_rcu opt; + char data[40]; +}; + +struct ipcm_cookie { + struct sockcm_cookie sockc; + __be32 addr; + int oif; + struct ip_options_rcu *opt; + __u8 ttl; + __s16 tos; + char priority; + __u16 gso_size; +}; + +struct ip_fraglist_iter { + struct sk_buff *frag; + struct iphdr *iph; + int offset; + unsigned int hlen; +}; + +struct ip_frag_state { + bool DF; + unsigned int hlen; + unsigned int ll_rs; + unsigned int mtu; + unsigned int left; + int offset; + int ptr; + __be16 not_last_frag; +}; + +struct ip_reply_arg { + struct kvec iov[1]; + int flags; + __wsum csum; + int csumoffset; + int bound_dev_if; + u8 tos; + kuid_t uid; +}; + +struct ip_mreq_source { + __be32 imr_multiaddr; + __be32 imr_interface; + __be32 imr_sourceaddr; +}; + +struct ip_msfilter { + __be32 imsf_multiaddr; + __be32 imsf_interface; + __u32 imsf_fmode; + __u32 imsf_numsrc; + __be32 imsf_slist[1]; +}; + +struct group_req { + __u32 gr_interface; + struct __kernel_sockaddr_storage gr_group; +}; + +struct group_source_req { + __u32 gsr_interface; + struct __kernel_sockaddr_storage gsr_group; + struct __kernel_sockaddr_storage gsr_source; +}; + +struct group_filter { + __u32 gf_interface; + struct __kernel_sockaddr_storage gf_group; + __u32 gf_fmode; + __u32 gf_numsrc; + struct __kernel_sockaddr_storage gf_slist[1]; +}; + +struct in_pktinfo { + int ipi_ifindex; + struct in_addr ipi_spec_dst; + struct in_addr ipi_addr; +}; + +struct compat_group_req { + __u32 gr_interface; + struct __kernel_sockaddr_storage gr_group; +} __attribute__((packed)); + +struct compat_group_source_req { + __u32 gsr_interface; + struct __kernel_sockaddr_storage gsr_group; + struct __kernel_sockaddr_storage gsr_source; +} __attribute__((packed)); + +struct compat_group_filter { + __u32 gf_interface; + struct __kernel_sockaddr_storage gf_group; + __u32 gf_fmode; + __u32 gf_numsrc; + struct __kernel_sockaddr_storage gf_slist[1]; +} __attribute__((packed)); + +enum { + BPFILTER_IPT_SO_SET_REPLACE = 64, + BPFILTER_IPT_SO_SET_ADD_COUNTERS = 65, + BPFILTER_IPT_SET_MAX = 66, +}; + +enum { + BPFILTER_IPT_SO_GET_INFO = 64, + BPFILTER_IPT_SO_GET_ENTRIES = 65, + BPFILTER_IPT_SO_GET_REVISION_MATCH = 66, + BPFILTER_IPT_SO_GET_REVISION_TARGET = 67, + BPFILTER_IPT_GET_MAX = 68, +}; + +struct tcpvegas_info { + __u32 tcpv_enabled; + __u32 tcpv_rttcnt; + __u32 tcpv_rtt; + __u32 tcpv_minrtt; +}; + +struct tcp_dctcp_info { + __u16 dctcp_enabled; + __u16 dctcp_ce_state; + __u32 dctcp_alpha; + __u32 dctcp_ab_ecn; + __u32 dctcp_ab_tot; +}; + +struct tcp_bbr_info { + __u32 bbr_bw_lo; + __u32 bbr_bw_hi; + __u32 bbr_min_rtt; + __u32 bbr_pacing_gain; + __u32 bbr_cwnd_gain; +}; + +union tcp_cc_info { + struct tcpvegas_info vegas; + struct tcp_dctcp_info dctcp; + struct tcp_bbr_info bbr; +}; + +enum { + BPF_TCP_ESTABLISHED = 1, + BPF_TCP_SYN_SENT = 2, + BPF_TCP_SYN_RECV = 3, + BPF_TCP_FIN_WAIT1 = 4, + BPF_TCP_FIN_WAIT2 = 5, + BPF_TCP_TIME_WAIT = 6, + BPF_TCP_CLOSE = 7, + BPF_TCP_CLOSE_WAIT = 8, + BPF_TCP_LAST_ACK = 9, + BPF_TCP_LISTEN = 10, + BPF_TCP_CLOSING = 11, + BPF_TCP_NEW_SYN_RECV = 12, + BPF_TCP_MAX_STATES = 13, +}; + +enum inet_csk_ack_state_t { + ICSK_ACK_SCHED = 1, + ICSK_ACK_TIMER = 2, + ICSK_ACK_PUSHED = 4, + ICSK_ACK_PUSHED2 = 8, + ICSK_ACK_NOW = 16, +}; + +enum { + TCP_FLAG_CWR = 32768, + TCP_FLAG_ECE = 16384, + TCP_FLAG_URG = 8192, + TCP_FLAG_ACK = 4096, + TCP_FLAG_PSH = 2048, + TCP_FLAG_RST = 1024, + TCP_FLAG_SYN = 512, + TCP_FLAG_FIN = 256, + TCP_RESERVED_BITS = 15, + TCP_DATA_OFFSET = 240, +}; + +struct tcp_repair_opt { + __u32 opt_code; + __u32 opt_val; +}; + +struct tcp_repair_window { + __u32 snd_wl1; + __u32 snd_wnd; + __u32 max_window; + __u32 rcv_wnd; + __u32 rcv_wup; +}; + +enum { + TCP_NO_QUEUE = 0, + TCP_RECV_QUEUE = 1, + TCP_SEND_QUEUE = 2, + TCP_QUEUES_NR = 3, +}; + +struct tcp_info { + __u8 tcpi_state; + __u8 tcpi_ca_state; + __u8 tcpi_retransmits; + __u8 tcpi_probes; + __u8 tcpi_backoff; + __u8 tcpi_options; + __u8 tcpi_snd_wscale: 4; + __u8 tcpi_rcv_wscale: 4; + __u8 tcpi_delivery_rate_app_limited: 1; + __u8 tcpi_fastopen_client_fail: 2; + __u32 tcpi_rto; + __u32 tcpi_ato; + __u32 tcpi_snd_mss; + __u32 tcpi_rcv_mss; + __u32 tcpi_unacked; + __u32 tcpi_sacked; + __u32 tcpi_lost; + __u32 tcpi_retrans; + __u32 tcpi_fackets; + __u32 tcpi_last_data_sent; + __u32 tcpi_last_ack_sent; + __u32 tcpi_last_data_recv; + __u32 tcpi_last_ack_recv; + __u32 tcpi_pmtu; + __u32 tcpi_rcv_ssthresh; + __u32 tcpi_rtt; + __u32 tcpi_rttvar; + __u32 tcpi_snd_ssthresh; + __u32 tcpi_snd_cwnd; + __u32 tcpi_advmss; + __u32 tcpi_reordering; + __u32 tcpi_rcv_rtt; + __u32 tcpi_rcv_space; + __u32 tcpi_total_retrans; + __u64 tcpi_pacing_rate; + __u64 tcpi_max_pacing_rate; + __u64 tcpi_bytes_acked; + __u64 tcpi_bytes_received; + __u32 tcpi_segs_out; + __u32 tcpi_segs_in; + __u32 tcpi_notsent_bytes; + __u32 tcpi_min_rtt; + __u32 tcpi_data_segs_in; + __u32 tcpi_data_segs_out; + __u64 tcpi_delivery_rate; + __u64 tcpi_busy_time; + __u64 tcpi_rwnd_limited; + __u64 tcpi_sndbuf_limited; + __u32 tcpi_delivered; + __u32 tcpi_delivered_ce; + __u64 tcpi_bytes_sent; + __u64 tcpi_bytes_retrans; + __u32 tcpi_dsack_dups; + __u32 tcpi_reord_seen; + __u32 tcpi_rcv_ooopack; + __u32 tcpi_snd_wnd; +}; + +enum { + TCP_NLA_PAD = 0, + TCP_NLA_BUSY = 1, + TCP_NLA_RWND_LIMITED = 2, + TCP_NLA_SNDBUF_LIMITED = 3, + TCP_NLA_DATA_SEGS_OUT = 4, + TCP_NLA_TOTAL_RETRANS = 5, + TCP_NLA_PACING_RATE = 6, + TCP_NLA_DELIVERY_RATE = 7, + TCP_NLA_SND_CWND = 8, + TCP_NLA_REORDERING = 9, + TCP_NLA_MIN_RTT = 10, + TCP_NLA_RECUR_RETRANS = 11, + TCP_NLA_DELIVERY_RATE_APP_LMT = 12, + TCP_NLA_SNDQ_SIZE = 13, + TCP_NLA_CA_STATE = 14, + TCP_NLA_SND_SSTHRESH = 15, + TCP_NLA_DELIVERED = 16, + TCP_NLA_DELIVERED_CE = 17, + TCP_NLA_BYTES_SENT = 18, + TCP_NLA_BYTES_RETRANS = 19, + TCP_NLA_DSACK_DUPS = 20, + TCP_NLA_REORD_SEEN = 21, + TCP_NLA_SRTT = 22, + TCP_NLA_TIMEOUT_REHASH = 23, + TCP_NLA_BYTES_NOTSENT = 24, + TCP_NLA_EDT = 25, +}; + +struct tcp_zerocopy_receive { + __u64 address; + __u32 length; + __u32 recv_skip_hint; + __u32 inq; + __s32 err; +}; + +struct tcp_md5sig_pool { + struct ahash_request *md5_req; + void *scratch; +}; + +enum tcp_chrono { + TCP_CHRONO_UNSPEC = 0, + TCP_CHRONO_BUSY = 1, + TCP_CHRONO_RWND_LIMITED = 2, + TCP_CHRONO_SNDBUF_LIMITED = 3, + __TCP_CHRONO_MAX = 4, +}; + +struct tcp_splice_state { + struct pipe_inode_info *pipe; + size_t len; + unsigned int flags; +}; + +enum tcp_fastopen_client_fail { + TFO_STATUS_UNSPEC = 0, + TFO_COOKIE_UNAVAILABLE = 1, + TFO_DATA_NOT_ACKED = 2, + TFO_SYN_RETRANSMITTED = 3, +}; + +struct tcp_sack_block_wire { + __be32 start_seq; + __be32 end_seq; +}; + +enum tcp_queue { + TCP_FRAG_IN_WRITE_QUEUE = 0, + TCP_FRAG_IN_RTX_QUEUE = 1, +}; + +enum tcp_ca_ack_event_flags { + CA_ACK_SLOWPATH = 1, + CA_ACK_WIN_UPDATE = 2, + CA_ACK_ECE = 4, +}; + +struct tcp_sacktag_state { + u64 first_sackt; + u64 last_sackt; + u32 reord; + u32 sack_delivered; + int flag; + unsigned int mss_now; + struct rate_sample *rate; +}; + +enum { + BPF_WRITE_HDR_TCP_CURRENT_MSS = 1, + BPF_WRITE_HDR_TCP_SYNACK_COOKIE = 2, +}; + +enum tsq_flags { + TSQF_THROTTLED = 1, + TSQF_QUEUED = 2, + TCPF_TSQ_DEFERRED = 4, + TCPF_WRITE_TIMER_DEFERRED = 8, + TCPF_DELACK_TIMER_DEFERRED = 16, + TCPF_MTU_REDUCED_DEFERRED = 32, +}; + +struct mptcp_out_options {}; + +struct tcp_out_options { + u16 options; + u16 mss; + u8 ws; + u8 num_sack_blocks; + u8 hash_size; + u8 bpf_opt_len; + __u8 *hash_location; + __u32 tsval; + __u32 tsecr; + struct tcp_fastopen_cookie *fastopen_cookie; + struct mptcp_out_options mptcp; +}; + +struct tsq_tasklet { + struct tasklet_struct tasklet; + struct list_head head; +}; + +struct tcp_md5sig { + struct __kernel_sockaddr_storage tcpm_addr; + __u8 tcpm_flags; + __u8 tcpm_prefixlen; + __u16 tcpm_keylen; + int tcpm_ifindex; + __u8 tcpm_key[80]; +}; + +struct icmp_err { + int errno; + unsigned int fatal: 1; +}; + +enum tcp_tw_status { + TCP_TW_SUCCESS = 0, + TCP_TW_RST = 1, + TCP_TW_ACK = 2, + TCP_TW_SYN = 3, +}; + +struct tcp4_pseudohdr { + __be32 saddr; + __be32 daddr; + __u8 pad; + __u8 protocol; + __be16 len; +}; + +enum tcp_seq_states { + TCP_SEQ_STATE_LISTENING = 0, + TCP_SEQ_STATE_ESTABLISHED = 1, +}; + +struct tcp_seq_afinfo { + sa_family_t family; +}; + +struct tcp_iter_state { + struct seq_net_private p; + enum tcp_seq_states state; + struct sock *syn_wait_sk; + struct tcp_seq_afinfo *bpf_seq_afinfo; + int bucket; + int offset; + int sbucket; + int num; + loff_t last_pos; +}; + +struct bpf_iter__tcp { + union { + struct bpf_iter_meta *meta; + }; + union { + struct sock_common *sk_common; + }; + uid_t uid; +}; + +enum tcp_metric_index { + TCP_METRIC_RTT = 0, + TCP_METRIC_RTTVAR = 1, + TCP_METRIC_SSTHRESH = 2, + TCP_METRIC_CWND = 3, + TCP_METRIC_REORDERING = 4, + TCP_METRIC_RTT_US = 5, + TCP_METRIC_RTTVAR_US = 6, + __TCP_METRIC_MAX = 7, +}; + +enum { + TCP_METRICS_ATTR_UNSPEC = 0, + TCP_METRICS_ATTR_ADDR_IPV4 = 1, + TCP_METRICS_ATTR_ADDR_IPV6 = 2, + TCP_METRICS_ATTR_AGE = 3, + TCP_METRICS_ATTR_TW_TSVAL = 4, + TCP_METRICS_ATTR_TW_TS_STAMP = 5, + TCP_METRICS_ATTR_VALS = 6, + TCP_METRICS_ATTR_FOPEN_MSS = 7, + TCP_METRICS_ATTR_FOPEN_SYN_DROPS = 8, + TCP_METRICS_ATTR_FOPEN_SYN_DROP_TS = 9, + TCP_METRICS_ATTR_FOPEN_COOKIE = 10, + TCP_METRICS_ATTR_SADDR_IPV4 = 11, + TCP_METRICS_ATTR_SADDR_IPV6 = 12, + TCP_METRICS_ATTR_PAD = 13, + __TCP_METRICS_ATTR_MAX = 14, +}; + +enum { + TCP_METRICS_CMD_UNSPEC = 0, + TCP_METRICS_CMD_GET = 1, + TCP_METRICS_CMD_DEL = 2, + __TCP_METRICS_CMD_MAX = 3, +}; + +struct tcp_fastopen_metrics { + u16 mss; + u16 syn_loss: 10; + u16 try_exp: 2; + long unsigned int last_syn_loss; + struct tcp_fastopen_cookie cookie; +}; + +struct tcp_metrics_block { + struct tcp_metrics_block *tcpm_next; + possible_net_t tcpm_net; + struct inetpeer_addr tcpm_saddr; + struct inetpeer_addr tcpm_daddr; + long unsigned int tcpm_stamp; + u32 tcpm_lock; + u32 tcpm_vals[5]; + struct tcp_fastopen_metrics tcpm_fastopen; + struct callback_head callback_head; +}; + +struct tcpm_hash_bucket { + struct tcp_metrics_block *chain; +}; + +struct icmp_filter { + __u32 data; +}; + +struct raw_iter_state { + struct seq_net_private p; + int bucket; +}; + +struct raw_sock { + struct inet_sock inet; + struct icmp_filter filter; + u32 ipmr_table; +}; + +struct raw_frag_vec { + struct msghdr *msg; + union { + struct icmphdr icmph; + char c[1]; + } hdr; + int hlen; +}; + +struct ip_tunnel_encap { + u16 type; + u16 flags; + __be16 sport; + __be16 dport; +}; + +struct ip_tunnel_encap_ops { + size_t (*encap_hlen)(struct ip_tunnel_encap *); + int (*build_header)(struct sk_buff *, struct ip_tunnel_encap *, u8 *, struct flowi4 *); + int (*err_handler)(struct sk_buff *, u32); +}; + +struct udp_skb_cb { + union { + struct inet_skb_parm h4; + struct inet6_skb_parm h6; + } header; + __u16 cscov; + __u8 partial_cov; +}; + +struct udp_dev_scratch { + u32 _tsize_state; + u16 len; + bool is_linear; + bool csum_unnecessary; +}; + +struct udp_seq_afinfo { + sa_family_t family; + struct udp_table *udp_table; +}; + +struct udp_iter_state { + struct seq_net_private p; + int bucket; + struct udp_seq_afinfo *bpf_seq_afinfo; +}; + +struct bpf_iter__udp { + union { + struct bpf_iter_meta *meta; + }; + union { + struct udp_sock *udp_sk; + }; + uid_t uid; + int: 32; + int bucket; +}; + +struct inet_protosw { + struct list_head list; + short unsigned int type; + short unsigned int protocol; + struct proto *prot; + const struct proto_ops *ops; + unsigned char flags; +}; + +typedef struct sk_buff * (*gro_receive_sk_t)(struct sock *, struct list_head *, struct sk_buff *); + +typedef struct sock * (*udp_lookup_t)(const struct sk_buff *, __be16, __be16); + +struct arpreq { + struct sockaddr arp_pa; + struct sockaddr arp_ha; + int arp_flags; + struct sockaddr arp_netmask; + char arp_dev[16]; +}; + +enum { + AX25_VALUES_IPDEFMODE = 0, + AX25_VALUES_AXDEFMODE = 1, + AX25_VALUES_BACKOFF = 2, + AX25_VALUES_CONMODE = 3, + AX25_VALUES_WINDOW = 4, + AX25_VALUES_EWINDOW = 5, + AX25_VALUES_T1 = 6, + AX25_VALUES_T2 = 7, + AX25_VALUES_T3 = 8, + AX25_VALUES_IDLE = 9, + AX25_VALUES_N2 = 10, + AX25_VALUES_PACLEN = 11, + AX25_VALUES_PROTOCOL = 12, + AX25_VALUES_DS_TIMEOUT = 13, + AX25_MAX_VALUES = 14, +}; + +enum { + XFRM_LOOKUP_ICMP = 1, + XFRM_LOOKUP_QUEUE = 2, + XFRM_LOOKUP_KEEP_DST_REF = 4, +}; + +struct icmp_ext_hdr { + __u8 reserved1: 4; + __u8 version: 4; + __u8 reserved2; + __sum16 checksum; +}; + +struct icmp_extobj_hdr { + __be16 length; + __u8 class_num; + __u8 class_type; +}; + +struct icmp_bxm { + struct sk_buff *skb; + int offset; + int data_len; + struct { + struct icmphdr icmph; + __be32 times[3]; + } data; + int head_len; + struct ip_options_data replyopts; +}; + +struct icmp_control { + bool (*handler)(struct sk_buff *); + short int error; +}; + +struct ifaddrmsg { + __u8 ifa_family; + __u8 ifa_prefixlen; + __u8 ifa_flags; + __u8 ifa_scope; + __u32 ifa_index; +}; + +enum { + IFA_UNSPEC = 0, + IFA_ADDRESS = 1, + IFA_LOCAL = 2, + IFA_LABEL = 3, + IFA_BROADCAST = 4, + IFA_ANYCAST = 5, + IFA_CACHEINFO = 6, + IFA_MULTICAST = 7, + IFA_FLAGS = 8, + IFA_RT_PRIORITY = 9, + IFA_TARGET_NETNSID = 10, + __IFA_MAX = 11, +}; + +struct ifa_cacheinfo { + __u32 ifa_prefered; + __u32 ifa_valid; + __u32 cstamp; + __u32 tstamp; +}; + +enum { + IFLA_INET_UNSPEC = 0, + IFLA_INET_CONF = 1, + __IFLA_INET_MAX = 2, +}; + +struct in_validator_info { + __be32 ivi_addr; + struct in_device *ivi_dev; + struct netlink_ext_ack *extack; +}; + +struct netconfmsg { + __u8 ncm_family; +}; + +enum { + NETCONFA_UNSPEC = 0, + NETCONFA_IFINDEX = 1, + NETCONFA_FORWARDING = 2, + NETCONFA_RP_FILTER = 3, + NETCONFA_MC_FORWARDING = 4, + NETCONFA_PROXY_NEIGH = 5, + NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN = 6, + NETCONFA_INPUT = 7, + NETCONFA_BC_FORWARDING = 8, + __NETCONFA_MAX = 9, +}; + +struct inet_fill_args { + u32 portid; + u32 seq; + int event; + unsigned int flags; + int netnsid; + int ifindex; +}; + +struct devinet_sysctl_table { + struct ctl_table_header *sysctl_header; + struct ctl_table devinet_vars[33]; +}; + +struct rtentry { + long unsigned int rt_pad1; + struct sockaddr rt_dst; + struct sockaddr rt_gateway; + struct sockaddr rt_genmask; + short unsigned int rt_flags; + short int rt_pad2; + long unsigned int rt_pad3; + void *rt_pad4; + short int rt_metric; + char *rt_dev; + long unsigned int rt_mtu; + long unsigned int rt_window; + short unsigned int rt_irtt; +}; + +struct pingv6_ops { + int (*ipv6_recv_error)(struct sock *, struct msghdr *, int, int *); + void (*ip6_datagram_recv_common_ctl)(struct sock *, struct msghdr *, struct sk_buff *); + void (*ip6_datagram_recv_specific_ctl)(struct sock *, struct msghdr *, struct sk_buff *); + int (*icmpv6_err_convert)(u8, u8, int *); + void (*ipv6_icmp_error)(struct sock *, struct sk_buff *, int, __be16, u32, u8 *); + int (*ipv6_chk_addr)(struct net *, const struct in6_addr *, const struct net_device *, int); +}; + +struct compat_rtentry { + u32 rt_pad1; + struct sockaddr rt_dst; + struct sockaddr rt_gateway; + struct sockaddr rt_genmask; + short unsigned int rt_flags; + short int rt_pad2; + u32 rt_pad3; + unsigned char rt_tos; + unsigned char rt_class; + short int rt_pad4; + short int rt_metric; + compat_uptr_t rt_dev; + u32 rt_mtu; + u32 rt_window; + short unsigned int rt_irtt; +}; + +struct igmphdr { + __u8 type; + __u8 code; + __sum16 csum; + __be32 group; +}; + +struct igmpv3_grec { + __u8 grec_type; + __u8 grec_auxwords; + __be16 grec_nsrcs; + __be32 grec_mca; + __be32 grec_src[0]; +}; + +struct igmpv3_report { + __u8 type; + __u8 resv1; + __sum16 csum; + __be16 resv2; + __be16 ngrec; + struct igmpv3_grec grec[0]; +}; + +struct igmpv3_query { + __u8 type; + __u8 code; + __sum16 csum; + __be32 group; + __u8 qrv: 3; + __u8 suppress: 1; + __u8 resv: 4; + __u8 qqic; + __be16 nsrcs; + __be32 srcs[0]; +}; + +struct igmp_mc_iter_state { + struct seq_net_private p; + struct net_device *dev; + struct in_device *in_dev; +}; + +struct igmp_mcf_iter_state { + struct seq_net_private p; + struct net_device *dev; + struct in_device *idev; + struct ip_mc_list *im; +}; + +struct fib_config { + u8 fc_dst_len; + u8 fc_tos; + u8 fc_protocol; + u8 fc_scope; + u8 fc_type; + u8 fc_gw_family; + u32 fc_table; + __be32 fc_dst; + union { + __be32 fc_gw4; + struct in6_addr fc_gw6; + }; + int fc_oif; + u32 fc_flags; + u32 fc_priority; + __be32 fc_prefsrc; + u32 fc_nh_id; + struct nlattr *fc_mx; + struct rtnexthop *fc_mp; + int fc_mx_len; + int fc_mp_len; + u32 fc_flow; + u32 fc_nlflags; + struct nl_info fc_nlinfo; + struct nlattr *fc_encap; + u16 fc_encap_type; +}; + +struct fib_result_nl { + __be32 fl_addr; + u32 fl_mark; + unsigned char fl_tos; + unsigned char fl_scope; + unsigned char tb_id_in; + unsigned char tb_id; + unsigned char prefixlen; + unsigned char nh_sel; + unsigned char type; + unsigned char scope; + int err; +}; + +struct fib_dump_filter { + u32 table_id; + bool filter_set; + bool dump_routes; + bool dump_exceptions; + unsigned char protocol; + unsigned char rt_type; + unsigned int flags; + struct net_device *dev; +}; + +struct fib_nh_notifier_info { + struct fib_notifier_info info; + struct fib_nh *fib_nh; +}; + +typedef unsigned int t_key; + +struct key_vector { + t_key key; + unsigned char pos; + unsigned char bits; + unsigned char slen; + union { + struct hlist_head leaf; + struct key_vector *tnode[0]; + }; +}; + +struct tnode { + struct callback_head rcu; + t_key empty_children; + t_key full_children; + struct key_vector *parent; + struct key_vector kv[1]; +}; + +struct trie_stat { + unsigned int totdepth; + unsigned int maxdepth; + unsigned int tnodes; + unsigned int leaves; + unsigned int nullpointers; + unsigned int prefixes; + unsigned int nodesizes[32]; +}; + +struct trie { + struct key_vector kv[1]; +}; + +struct fib_trie_iter { + struct seq_net_private p; + struct fib_table *tb; + struct key_vector *tnode; + unsigned int index; + unsigned int depth; +}; + +struct fib_route_iter { + struct seq_net_private p; + struct fib_table *main_tb; + struct key_vector *tnode; + loff_t pos; + t_key key; +}; + +struct ipfrag_skb_cb { + union { + struct inet_skb_parm h4; + struct inet6_skb_parm h6; + }; + struct sk_buff *next_frag; + int frag_run_len; +}; + +struct ping_iter_state { + struct seq_net_private p; + int bucket; + sa_family_t family; +}; + +struct pingfakehdr { + struct icmphdr icmph; + struct msghdr *msg; + sa_family_t family; + __wsum wcheck; +}; + +struct ping_table { + struct hlist_nulls_head hash[64]; + rwlock_t lock; +}; + +enum lwtunnel_ip_t { + LWTUNNEL_IP_UNSPEC = 0, + LWTUNNEL_IP_ID = 1, + LWTUNNEL_IP_DST = 2, + LWTUNNEL_IP_SRC = 3, + LWTUNNEL_IP_TTL = 4, + LWTUNNEL_IP_TOS = 5, + LWTUNNEL_IP_FLAGS = 6, + LWTUNNEL_IP_PAD = 7, + LWTUNNEL_IP_OPTS = 8, + __LWTUNNEL_IP_MAX = 9, +}; + +enum lwtunnel_ip6_t { + LWTUNNEL_IP6_UNSPEC = 0, + LWTUNNEL_IP6_ID = 1, + LWTUNNEL_IP6_DST = 2, + LWTUNNEL_IP6_SRC = 3, + LWTUNNEL_IP6_HOPLIMIT = 4, + LWTUNNEL_IP6_TC = 5, + LWTUNNEL_IP6_FLAGS = 6, + LWTUNNEL_IP6_PAD = 7, + LWTUNNEL_IP6_OPTS = 8, + __LWTUNNEL_IP6_MAX = 9, +}; + +enum { + LWTUNNEL_IP_OPTS_UNSPEC = 0, + LWTUNNEL_IP_OPTS_GENEVE = 1, + LWTUNNEL_IP_OPTS_VXLAN = 2, + LWTUNNEL_IP_OPTS_ERSPAN = 3, + __LWTUNNEL_IP_OPTS_MAX = 4, +}; + +enum { + LWTUNNEL_IP_OPT_GENEVE_UNSPEC = 0, + LWTUNNEL_IP_OPT_GENEVE_CLASS = 1, + LWTUNNEL_IP_OPT_GENEVE_TYPE = 2, + LWTUNNEL_IP_OPT_GENEVE_DATA = 3, + __LWTUNNEL_IP_OPT_GENEVE_MAX = 4, +}; + +enum { + LWTUNNEL_IP_OPT_VXLAN_UNSPEC = 0, + LWTUNNEL_IP_OPT_VXLAN_GBP = 1, + __LWTUNNEL_IP_OPT_VXLAN_MAX = 2, +}; + +enum { + LWTUNNEL_IP_OPT_ERSPAN_UNSPEC = 0, + LWTUNNEL_IP_OPT_ERSPAN_VER = 1, + LWTUNNEL_IP_OPT_ERSPAN_INDEX = 2, + LWTUNNEL_IP_OPT_ERSPAN_DIR = 3, + LWTUNNEL_IP_OPT_ERSPAN_HWID = 4, + __LWTUNNEL_IP_OPT_ERSPAN_MAX = 5, +}; + +struct ip6_tnl_encap_ops { + size_t (*encap_hlen)(struct ip_tunnel_encap *); + int (*build_header)(struct sk_buff *, struct ip_tunnel_encap *, u8 *, struct flowi6 *); + int (*err_handler)(struct sk_buff *, struct inet6_skb_parm *, u8, u8, int, __be32); +}; + +struct nhmsg { + unsigned char nh_family; + unsigned char nh_scope; + unsigned char nh_protocol; + unsigned char resvd; + unsigned int nh_flags; +}; + +struct nexthop_grp { + __u32 id; + __u8 weight; + __u8 resvd1; + __u16 resvd2; +}; + +enum { + NEXTHOP_GRP_TYPE_MPATH = 0, + __NEXTHOP_GRP_TYPE_MAX = 1, +}; + +enum { + NHA_UNSPEC = 0, + NHA_ID = 1, + NHA_GROUP = 2, + NHA_GROUP_TYPE = 3, + NHA_BLACKHOLE = 4, + NHA_OIF = 5, + NHA_GATEWAY = 6, + NHA_ENCAP_TYPE = 7, + NHA_ENCAP = 8, + NHA_GROUPS = 9, + NHA_MASTER = 10, + NHA_FDB = 11, + __NHA_MAX = 12, +}; + +struct nh_config { + u32 nh_id; + u8 nh_family; + u8 nh_protocol; + u8 nh_blackhole; + u8 nh_fdb; + u32 nh_flags; + int nh_ifindex; + struct net_device *dev; + union { + __be32 ipv4; + struct in6_addr ipv6; + } gw; + struct nlattr *nh_grp; + u16 nh_grp_type; + struct nlattr *nh_encap; + u16 nh_encap_type; + u32 nlflags; + struct nl_info nlinfo; +}; + +struct bpfilter_umh_ops { + struct umd_info info; + struct mutex lock; + int (*sockopt)(struct sock *, int, sockptr_t, unsigned int, bool); + int (*start)(); +}; + +enum tunnel_encap_types { + TUNNEL_ENCAP_NONE = 0, + TUNNEL_ENCAP_FOU = 1, + TUNNEL_ENCAP_GUE = 2, + TUNNEL_ENCAP_MPLS = 3, +}; + +struct ip_tunnel_prl_entry { + struct ip_tunnel_prl_entry *next; + __be32 addr; + u16 flags; + struct callback_head callback_head; +}; + +struct ip_tunnel { + struct ip_tunnel *next; + struct hlist_node hash_node; + struct net_device *dev; + struct net *net; + long unsigned int err_time; + int err_count; + u32 i_seqno; + u32 o_seqno; + int tun_hlen; + u32 index; + u8 erspan_ver; + u8 dir; + u16 hwid; + struct dst_cache dst_cache; + struct ip_tunnel_parm parms; + int mlink; + int encap_hlen; + int hlen; + struct ip_tunnel_encap encap; + struct ip_tunnel_prl_entry *prl; + unsigned int prl_count; + unsigned int ip_tnl_net_id; + struct gro_cells gro_cells; + __u32 fwmark; + bool collect_md; + bool ignore_df; +}; + +struct tnl_ptk_info { + __be16 flags; + __be16 proto; + __be32 key; + __be32 seq; + int hdr_len; +}; + +struct ip_tunnel_net { + struct net_device *fb_tunnel_dev; + struct rtnl_link_ops *rtnl_link_ops; + struct hlist_head tunnels[128]; + struct ip_tunnel *collect_md_tun; + int type; +}; + +struct inet6_protocol { + void (*early_demux)(struct sk_buff *); + void (*early_demux_handler)(struct sk_buff *); + int (*handler)(struct sk_buff *); + int (*err_handler)(struct sk_buff *, struct inet6_skb_parm *, u8, u8, int, __be32); + unsigned int flags; +}; + +struct snmp_mib { + const char *name; + int entry; +}; + +struct fib4_rule { + struct fib_rule common; + u8 dst_len; + u8 src_len; + u8 tos; + __be32 src; + __be32 srcmask; + __be32 dst; + __be32 dstmask; + u32 tclassid; +}; + +enum { + PIM_TYPE_HELLO = 0, + PIM_TYPE_REGISTER = 1, + PIM_TYPE_REGISTER_STOP = 2, + PIM_TYPE_JOIN_PRUNE = 3, + PIM_TYPE_BOOTSTRAP = 4, + PIM_TYPE_ASSERT = 5, + PIM_TYPE_GRAFT = 6, + PIM_TYPE_GRAFT_ACK = 7, + PIM_TYPE_CANDIDATE_RP_ADV = 8, +}; + +struct pimreghdr { + __u8 type; + __u8 reserved; + __be16 csum; + __be32 flags; +}; + +typedef short unsigned int vifi_t; + +struct vifctl { + vifi_t vifc_vifi; + unsigned char vifc_flags; + unsigned char vifc_threshold; + unsigned int vifc_rate_limit; + union { + struct in_addr vifc_lcl_addr; + int vifc_lcl_ifindex; + }; + struct in_addr vifc_rmt_addr; +}; + +struct mfcctl { + struct in_addr mfcc_origin; + struct in_addr mfcc_mcastgrp; + vifi_t mfcc_parent; + unsigned char mfcc_ttls[32]; + unsigned int mfcc_pkt_cnt; + unsigned int mfcc_byte_cnt; + unsigned int mfcc_wrong_if; + int mfcc_expire; +}; + +struct sioc_sg_req { + struct in_addr src; + struct in_addr grp; + long unsigned int pktcnt; + long unsigned int bytecnt; + long unsigned int wrong_if; +}; + +struct sioc_vif_req { + vifi_t vifi; + long unsigned int icount; + long unsigned int ocount; + long unsigned int ibytes; + long unsigned int obytes; +}; + +struct igmpmsg { + __u32 unused1; + __u32 unused2; + unsigned char im_msgtype; + unsigned char im_mbz; + unsigned char im_vif; + unsigned char im_vif_hi; + struct in_addr im_src; + struct in_addr im_dst; +}; + +enum { + IPMRA_TABLE_UNSPEC = 0, + IPMRA_TABLE_ID = 1, + IPMRA_TABLE_CACHE_RES_QUEUE_LEN = 2, + IPMRA_TABLE_MROUTE_REG_VIF_NUM = 3, + IPMRA_TABLE_MROUTE_DO_ASSERT = 4, + IPMRA_TABLE_MROUTE_DO_PIM = 5, + IPMRA_TABLE_VIFS = 6, + IPMRA_TABLE_MROUTE_DO_WRVIFWHOLE = 7, + __IPMRA_TABLE_MAX = 8, +}; + +enum { + IPMRA_VIF_UNSPEC = 0, + IPMRA_VIF = 1, + __IPMRA_VIF_MAX = 2, +}; + +enum { + IPMRA_VIFA_UNSPEC = 0, + IPMRA_VIFA_IFINDEX = 1, + IPMRA_VIFA_VIF_ID = 2, + IPMRA_VIFA_FLAGS = 3, + IPMRA_VIFA_BYTES_IN = 4, + IPMRA_VIFA_BYTES_OUT = 5, + IPMRA_VIFA_PACKETS_IN = 6, + IPMRA_VIFA_PACKETS_OUT = 7, + IPMRA_VIFA_LOCAL_ADDR = 8, + IPMRA_VIFA_REMOTE_ADDR = 9, + IPMRA_VIFA_PAD = 10, + __IPMRA_VIFA_MAX = 11, +}; + +enum { + IPMRA_CREPORT_UNSPEC = 0, + IPMRA_CREPORT_MSGTYPE = 1, + IPMRA_CREPORT_VIF_ID = 2, + IPMRA_CREPORT_SRC_ADDR = 3, + IPMRA_CREPORT_DST_ADDR = 4, + IPMRA_CREPORT_PKT = 5, + IPMRA_CREPORT_TABLE = 6, + __IPMRA_CREPORT_MAX = 7, +}; + +struct vif_entry_notifier_info { + struct fib_notifier_info info; + struct net_device *dev; + short unsigned int vif_index; + short unsigned int vif_flags; + u32 tb_id; +}; + +enum { + MFC_STATIC = 1, + MFC_OFFLOAD = 2, +}; + +struct mr_mfc { + struct rhlist_head mnode; + short unsigned int mfc_parent; + int mfc_flags; + union { + struct { + long unsigned int expires; + struct sk_buff_head unresolved; + } unres; + struct { + long unsigned int last_assert; + int minvif; + int maxvif; + long unsigned int bytes; + long unsigned int pkt; + long unsigned int wrong_if; + long unsigned int lastuse; + unsigned char ttls[32]; + refcount_t refcount; + } res; + } mfc_un; + struct list_head list; + struct callback_head rcu; + void (*free)(struct callback_head *); +}; + +struct mfc_entry_notifier_info { + struct fib_notifier_info info; + struct mr_mfc *mfc; + u32 tb_id; +}; + +struct mr_vif_iter { + struct seq_net_private p; + struct mr_table *mrt; + int ct; +}; + +struct mr_mfc_iter { + struct seq_net_private p; + struct mr_table *mrt; + struct list_head *cache; + spinlock_t *lock; +}; + +struct mfc_cache_cmp_arg { + __be32 mfc_mcastgrp; + __be32 mfc_origin; +}; + +struct mfc_cache { + struct mr_mfc _c; + union { + struct { + __be32 mfc_mcastgrp; + __be32 mfc_origin; + }; + struct mfc_cache_cmp_arg cmparg; + }; +}; + +struct compat_sioc_sg_req { + struct in_addr src; + struct in_addr grp; + compat_ulong_t pktcnt; + compat_ulong_t bytecnt; + compat_ulong_t wrong_if; +}; + +struct compat_sioc_vif_req { + vifi_t vifi; + compat_ulong_t icount; + compat_ulong_t ocount; + compat_ulong_t ibytes; + compat_ulong_t obytes; +}; + +struct rta_mfc_stats { + __u64 mfcs_packets; + __u64 mfcs_bytes; + __u64 mfcs_wrong_if; +}; + +enum { + IFLA_IPTUN_UNSPEC = 0, + IFLA_IPTUN_LINK = 1, + IFLA_IPTUN_LOCAL = 2, + IFLA_IPTUN_REMOTE = 3, + IFLA_IPTUN_TTL = 4, + IFLA_IPTUN_TOS = 5, + IFLA_IPTUN_ENCAP_LIMIT = 6, + IFLA_IPTUN_FLOWINFO = 7, + IFLA_IPTUN_FLAGS = 8, + IFLA_IPTUN_PROTO = 9, + IFLA_IPTUN_PMTUDISC = 10, + IFLA_IPTUN_6RD_PREFIX = 11, + IFLA_IPTUN_6RD_RELAY_PREFIX = 12, + IFLA_IPTUN_6RD_PREFIXLEN = 13, + IFLA_IPTUN_6RD_RELAY_PREFIXLEN = 14, + IFLA_IPTUN_ENCAP_TYPE = 15, + IFLA_IPTUN_ENCAP_FLAGS = 16, + IFLA_IPTUN_ENCAP_SPORT = 17, + IFLA_IPTUN_ENCAP_DPORT = 18, + IFLA_IPTUN_COLLECT_METADATA = 19, + IFLA_IPTUN_FWMARK = 20, + __IFLA_IPTUN_MAX = 21, +}; + +struct xfrm_tunnel { + int (*handler)(struct sk_buff *); + int (*cb_handler)(struct sk_buff *, int); + int (*err_handler)(struct sk_buff *, u32); + struct xfrm_tunnel *next; + int priority; +}; + +struct gre_protocol { + int (*handler)(struct sk_buff *); + void (*err_handler)(struct sk_buff *, u32); +}; + +struct erspan_base_hdr { + __u8 vlan_upper: 4; + __u8 ver: 4; + __u8 vlan: 8; + __u8 session_id_upper: 2; + __u8 t: 1; + __u8 en: 2; + __u8 cos: 3; + __u8 session_id: 8; +}; + +enum { + IFLA_GRE_UNSPEC = 0, + IFLA_GRE_LINK = 1, + IFLA_GRE_IFLAGS = 2, + IFLA_GRE_OFLAGS = 3, + IFLA_GRE_IKEY = 4, + IFLA_GRE_OKEY = 5, + IFLA_GRE_LOCAL = 6, + IFLA_GRE_REMOTE = 7, + IFLA_GRE_TTL = 8, + IFLA_GRE_TOS = 9, + IFLA_GRE_PMTUDISC = 10, + IFLA_GRE_ENCAP_LIMIT = 11, + IFLA_GRE_FLOWINFO = 12, + IFLA_GRE_FLAGS = 13, + IFLA_GRE_ENCAP_TYPE = 14, + IFLA_GRE_ENCAP_FLAGS = 15, + IFLA_GRE_ENCAP_SPORT = 16, + IFLA_GRE_ENCAP_DPORT = 17, + IFLA_GRE_COLLECT_METADATA = 18, + IFLA_GRE_IGNORE_DF = 19, + IFLA_GRE_FWMARK = 20, + IFLA_GRE_ERSPAN_INDEX = 21, + IFLA_GRE_ERSPAN_VER = 22, + IFLA_GRE_ERSPAN_DIR = 23, + IFLA_GRE_ERSPAN_HWID = 24, + __IFLA_GRE_MAX = 25, +}; + +enum erspan_encap_type { + ERSPAN_ENCAP_NOVLAN = 0, + ERSPAN_ENCAP_ISL = 1, + ERSPAN_ENCAP_8021Q = 2, + ERSPAN_ENCAP_INFRAME = 3, +}; + +enum erspan_bso { + BSO_NOERROR = 0, + BSO_SHORT = 1, + BSO_OVERSIZED = 2, + BSO_BAD = 3, +}; + +struct qtag_prefix { + __be16 eth_type; + __be16 tci; +}; + +struct udp_tunnel_nic_table_entry; + +struct udp_tunnel_nic { + struct work_struct work; + struct net_device *dev; + u8 need_sync: 1; + u8 need_replay: 1; + u8 work_pending: 1; + unsigned int n_tables; + long unsigned int missed; + struct udp_tunnel_nic_table_entry **entries; +}; + +struct udp_tunnel_nic_shared_node { + struct net_device *dev; + struct list_head list; +}; + +enum udp_tunnel_nic_table_entry_flags { + UDP_TUNNEL_NIC_ENTRY_ADD = 1, + UDP_TUNNEL_NIC_ENTRY_DEL = 2, + UDP_TUNNEL_NIC_ENTRY_OP_FAIL = 4, + UDP_TUNNEL_NIC_ENTRY_FROZEN = 8, +}; + +struct udp_tunnel_nic_table_entry { + __be16 port; + u8 type; + u8 flags; + u16 use_cnt; + u8 hw_priv; +}; + +struct xfrm_input_afinfo { + u8 family; + bool is_ipip; + int (*callback)(struct sk_buff *, u8, int); +}; + +struct xt_get_revision { + char name[29]; + __u8 revision; +}; + +struct ipt_ip { + struct in_addr src; + struct in_addr dst; + struct in_addr smsk; + struct in_addr dmsk; + char iniface[16]; + char outiface[16]; + unsigned char iniface_mask[16]; + unsigned char outiface_mask[16]; + __u16 proto; + __u8 flags; + __u8 invflags; +}; + +struct ipt_entry { + struct ipt_ip ip; + unsigned int nfcache; + __u16 target_offset; + __u16 next_offset; + unsigned int comefrom; + struct xt_counters counters; + unsigned char elems[0]; +}; + +struct ipt_icmp { + __u8 type; + __u8 code[2]; + __u8 invflags; +}; + +struct ipt_getinfo { + char name[32]; + unsigned int valid_hooks; + unsigned int hook_entry[5]; + unsigned int underflow[5]; + unsigned int num_entries; + unsigned int size; +}; + +struct ipt_replace { + char name[32]; + unsigned int valid_hooks; + unsigned int num_entries; + unsigned int size; + unsigned int hook_entry[5]; + unsigned int underflow[5]; + unsigned int num_counters; + struct xt_counters *counters; + struct ipt_entry entries[0]; +}; + +struct ipt_get_entries { + char name[32]; + unsigned int size; + struct ipt_entry entrytable[0]; +}; + +struct ipt_standard { + struct ipt_entry entry; + struct xt_standard_target target; +}; + +struct ipt_error { + struct ipt_entry entry; + struct xt_error_target target; +}; + +struct compat_ipt_entry { + struct ipt_ip ip; + compat_uint_t nfcache; + __u16 target_offset; + __u16 next_offset; + compat_uint_t comefrom; + struct compat_xt_counters counters; + unsigned char elems[0]; +}; + +struct compat_ipt_replace { + char name[32]; + u32 valid_hooks; + u32 num_entries; + u32 size; + u32 hook_entry[5]; + u32 underflow[5]; + u32 num_counters; + compat_uptr_t counters; + struct compat_ipt_entry entries[0]; +} __attribute__((packed)); + +struct compat_ipt_get_entries { + char name[32]; + compat_uint_t size; + struct compat_ipt_entry entrytable[0]; +} __attribute__((packed)); + +struct bictcp { + u32 cnt; + u32 last_max_cwnd; + u32 last_cwnd; + u32 last_time; + u32 bic_origin_point; + u32 bic_K; + u32 delay_min; + u32 epoch_start; + u32 ack_cnt; + u32 tcp_cwnd; + u16 unused; + u8 sample_cnt; + u8 found; + u32 round_start; + u32 end_seq; + u32 last_ack; + u32 curr_rtt; +}; + +struct tls_rec { + struct list_head list; + int tx_ready; + int tx_flags; + struct sk_msg msg_plaintext; + struct sk_msg msg_encrypted; + struct scatterlist sg_aead_in[2]; + struct scatterlist sg_aead_out[2]; + char content_type; + struct scatterlist sg_content_type; + char aad_space[13]; + u8 iv_data[16]; + struct aead_request aead_req; + u8 aead_req_ctx[0]; +}; + +struct tx_work { + struct delayed_work work; + struct sock *sk; +}; + +struct tls_sw_context_tx { + struct crypto_aead *aead_send; + struct crypto_wait async_wait; + struct tx_work tx_work; + struct tls_rec *open_rec; + struct list_head tx_list; + atomic_t encrypt_pending; + spinlock_t encrypt_compl_lock; + int async_notify; + u8 async_capable: 1; + long unsigned int tx_bitmask; +}; + +enum { + TCP_BPF_IPV4 = 0, + TCP_BPF_IPV6 = 1, + TCP_BPF_NUM_PROTS = 2, +}; + +enum { + TCP_BPF_BASE = 0, + TCP_BPF_TX = 1, + TCP_BPF_NUM_CFGS = 2, +}; + +enum { + UDP_BPF_IPV4 = 0, + UDP_BPF_IPV6 = 1, + UDP_BPF_NUM_PROTS = 2, +}; + +struct netlbl_audit { + u32 secid; + kuid_t loginuid; + unsigned int sessionid; +}; + +struct cipso_v4_std_map_tbl { + struct { + u32 *cipso; + u32 *local; + u32 cipso_size; + u32 local_size; + } lvl; + struct { + u32 *cipso; + u32 *local; + u32 cipso_size; + u32 local_size; + } cat; +}; + +struct cipso_v4_doi { + u32 doi; + u32 type; + union { + struct cipso_v4_std_map_tbl *std; + } map; + u8 tags[5]; + refcount_t refcount; + struct list_head list; + struct callback_head rcu; +}; + +struct cipso_v4_map_cache_bkt { + spinlock_t lock; + u32 size; + struct list_head list; +}; + +struct cipso_v4_map_cache_entry { + u32 hash; + unsigned char *key; + size_t key_len; + struct netlbl_lsm_cache *lsm_data; + u32 activity; + struct list_head list; +}; + +struct xfrm_policy_afinfo { + struct dst_ops *dst_ops; + struct dst_entry * (*dst_lookup)(struct net *, int, int, const xfrm_address_t *, const xfrm_address_t *, u32); + int (*get_saddr)(struct net *, int, xfrm_address_t *, xfrm_address_t *, u32); + int (*fill_dst)(struct xfrm_dst *, struct net_device *, const struct flowi *); + struct dst_entry * (*blackhole_route)(struct net *, struct dst_entry *); +}; + +struct xfrm_state_afinfo { + u8 family; + u8 proto; + const struct xfrm_type_offload *type_offload_esp; + const struct xfrm_type *type_esp; + const struct xfrm_type *type_ipip; + const struct xfrm_type *type_ipip6; + const struct xfrm_type *type_comp; + const struct xfrm_type *type_ah; + const struct xfrm_type *type_routing; + const struct xfrm_type *type_dstopts; + int (*output)(struct net *, struct sock *, struct sk_buff *); + int (*transport_finish)(struct sk_buff *, int); + void (*local_error)(struct sk_buff *, u32); +}; + +struct ip6_tnl; + +struct xfrm_tunnel_skb_cb { + union { + struct inet_skb_parm h4; + struct inet6_skb_parm h6; + } header; + union { + struct ip_tunnel *ip4; + struct ip6_tnl *ip6; + } tunnel; +}; + +struct xfrm_mode_skb_cb { + struct xfrm_tunnel_skb_cb header; + __be16 id; + __be16 frag_off; + u8 ihl; + u8 tos; + u8 ttl; + u8 protocol; + u8 optlen; + u8 flow_lbl[3]; +}; + +struct xfrm_spi_skb_cb { + struct xfrm_tunnel_skb_cb header; + unsigned int daddroff; + unsigned int family; + __be32 seq; +}; + +struct xfrm4_protocol { + int (*handler)(struct sk_buff *); + int (*input_handler)(struct sk_buff *, int, __be32, int); + int (*cb_handler)(struct sk_buff *, int); + int (*err_handler)(struct sk_buff *, u32); + struct xfrm4_protocol *next; + int priority; +}; + +typedef u64 (*btf_bpf_tcp_send_ack)(struct tcp_sock *, u32); + +enum { + INET_ULP_INFO_UNSPEC = 0, + INET_ULP_INFO_NAME = 1, + INET_ULP_INFO_TLS = 2, + INET_ULP_INFO_MPTCP = 3, + __INET_ULP_INFO_MAX = 4, +}; + +enum { + TLS_INFO_UNSPEC = 0, + TLS_INFO_VERSION = 1, + TLS_INFO_CIPHER = 2, + TLS_INFO_TXCONF = 3, + TLS_INFO_RXCONF = 4, + __TLS_INFO_MAX = 5, +}; + +enum { + TLS_BASE = 0, + TLS_SW = 1, + TLS_HW = 2, + TLS_HW_RECORD = 3, + TLS_NUM_CONFIG = 4, +}; + +enum { + TLSV4 = 0, + TLSV6 = 1, + TLS_NUM_PROTS = 2, +}; + +struct tls12_crypto_info_aes_ccm_128 { + struct tls_crypto_info info; + unsigned char iv[8]; + unsigned char key[16]; + unsigned char salt[4]; + unsigned char rec_seq[8]; +}; + +struct tls_msg { + struct strp_msg rxm; + u8 control; +}; + +struct trace_event_raw_tls_device_offload_set { + struct trace_entry ent; + struct sock *sk; + u64 rec_no; + int dir; + u32 tcp_seq; + int ret; + char __data[0]; +}; + +struct trace_event_raw_tls_device_decrypted { + struct trace_entry ent; + struct sock *sk; + u64 rec_no; + u32 tcp_seq; + u32 rec_len; + bool encrypted; + bool decrypted; + char __data[0]; +}; + +struct trace_event_raw_tls_device_rx_resync_send { + struct trace_entry ent; + struct sock *sk; + u64 rec_no; + u32 tcp_seq; + int sync_type; + char __data[0]; +}; + +struct trace_event_raw_tls_device_rx_resync_nh_schedule { + struct trace_entry ent; + struct sock *sk; + char __data[0]; +}; + +struct trace_event_raw_tls_device_rx_resync_nh_delay { + struct trace_entry ent; + struct sock *sk; + u32 sock_data; + u32 rec_len; + char __data[0]; +}; + +struct trace_event_raw_tls_device_tx_resync_req { + struct trace_entry ent; + struct sock *sk; + u32 tcp_seq; + u32 exp_tcp_seq; + char __data[0]; +}; + +struct trace_event_raw_tls_device_tx_resync_send { + struct trace_entry ent; + struct sock *sk; + u64 rec_no; + u32 tcp_seq; + char __data[0]; +}; + +struct trace_event_data_offsets_tls_device_offload_set {}; + +struct trace_event_data_offsets_tls_device_decrypted {}; + +struct trace_event_data_offsets_tls_device_rx_resync_send {}; + +struct trace_event_data_offsets_tls_device_rx_resync_nh_schedule {}; + +struct trace_event_data_offsets_tls_device_rx_resync_nh_delay {}; + +struct trace_event_data_offsets_tls_device_tx_resync_req {}; + +struct trace_event_data_offsets_tls_device_tx_resync_send {}; + +typedef void (*btf_trace_tls_device_offload_set)(void *, struct sock *, int, u32, u8 *, int); + +typedef void (*btf_trace_tls_device_decrypted)(void *, struct sock *, u32, u8 *, u32, bool, bool); + +typedef void (*btf_trace_tls_device_rx_resync_send)(void *, struct sock *, u32, u8 *, int); + +typedef void (*btf_trace_tls_device_rx_resync_nh_schedule)(void *, struct sock *); + +typedef void (*btf_trace_tls_device_rx_resync_nh_delay)(void *, struct sock *, u32, u32); + +typedef void (*btf_trace_tls_device_tx_resync_req)(void *, struct sock *, u32, u32); + +typedef void (*btf_trace_tls_device_tx_resync_send)(void *, struct sock *, u32, u8 *); + +struct seqcount_mutex { + seqcount_t seqcount; +}; + +typedef struct seqcount_mutex seqcount_mutex_t; + +enum { + XFRM_STATE_VOID = 0, + XFRM_STATE_ACQ = 1, + XFRM_STATE_VALID = 2, + XFRM_STATE_ERROR = 3, + XFRM_STATE_EXPIRED = 4, + XFRM_STATE_DEAD = 5, +}; + +struct xfrm_if; + +struct xfrm_if_cb { + struct xfrm_if * (*decode_session)(struct sk_buff *, short unsigned int); +}; + +struct xfrm_if_parms { + int link; + u32 if_id; +}; + +struct xfrm_if { + struct xfrm_if *next; + struct net_device *dev; + struct net *net; + struct xfrm_if_parms p; + struct gro_cells gro_cells; +}; + +struct xfrm_policy_walk { + struct xfrm_policy_walk_entry walk; + u8 type; + u32 seq; +}; + +struct xfrmk_spdinfo { + u32 incnt; + u32 outcnt; + u32 fwdcnt; + u32 inscnt; + u32 outscnt; + u32 fwdscnt; + u32 spdhcnt; + u32 spdhmcnt; +}; + +struct ip6_mh { + __u8 ip6mh_proto; + __u8 ip6mh_hdrlen; + __u8 ip6mh_type; + __u8 ip6mh_reserved; + __u16 ip6mh_cksum; + __u8 data[0]; +}; + +struct xfrm_flo { + struct dst_entry *dst_orig; + u8 flags; +}; + +struct xfrm_pol_inexact_node { + struct rb_node node; + union { + xfrm_address_t addr; + struct callback_head rcu; + }; + u8 prefixlen; + struct rb_root root; + struct hlist_head hhead; +}; + +struct xfrm_pol_inexact_key { + possible_net_t net; + u32 if_id; + u16 family; + u8 dir; + u8 type; +}; + +struct xfrm_pol_inexact_bin { + struct xfrm_pol_inexact_key k; + struct rhash_head head; + struct hlist_head hhead; + seqcount_spinlock_t count; + struct rb_root root_d; + struct rb_root root_s; + struct list_head inexact_bins; + struct callback_head rcu; +}; + +enum xfrm_pol_inexact_candidate_type { + XFRM_POL_CAND_BOTH = 0, + XFRM_POL_CAND_SADDR = 1, + XFRM_POL_CAND_DADDR = 2, + XFRM_POL_CAND_ANY = 3, + XFRM_POL_CAND_MAX = 4, +}; + +struct xfrm_pol_inexact_candidates { + struct hlist_head *res[4]; +}; + +enum xfrm_ae_ftype_t { + XFRM_AE_UNSPEC = 0, + XFRM_AE_RTHR = 1, + XFRM_AE_RVAL = 2, + XFRM_AE_LVAL = 4, + XFRM_AE_ETHR = 8, + XFRM_AE_CR = 16, + XFRM_AE_CE = 32, + XFRM_AE_CU = 64, + __XFRM_AE_MAX = 65, +}; + +enum xfrm_nlgroups { + XFRMNLGRP_NONE = 0, + XFRMNLGRP_ACQUIRE = 1, + XFRMNLGRP_EXPIRE = 2, + XFRMNLGRP_SA = 3, + XFRMNLGRP_POLICY = 4, + XFRMNLGRP_AEVENTS = 5, + XFRMNLGRP_REPORT = 6, + XFRMNLGRP_MIGRATE = 7, + XFRMNLGRP_MAPPING = 8, + __XFRMNLGRP_MAX = 9, +}; + +enum { + XFRM_MODE_FLAG_TUNNEL = 1, +}; + +struct km_event { + union { + u32 hard; + u32 proto; + u32 byid; + u32 aevent; + u32 type; + } data; + u32 seq; + u32 portid; + u32 event; + struct net *net; +}; + +struct xfrm_kmaddress { + xfrm_address_t local; + xfrm_address_t remote; + u32 reserved; + u16 family; +}; + +struct xfrm_migrate { + xfrm_address_t old_daddr; + xfrm_address_t old_saddr; + xfrm_address_t new_daddr; + xfrm_address_t new_saddr; + u8 proto; + u8 mode; + u16 reserved; + u32 reqid; + u16 old_family; + u16 new_family; +}; + +struct xfrm_mgr { + struct list_head list; + int (*notify)(struct xfrm_state *, const struct km_event *); + int (*acquire)(struct xfrm_state *, struct xfrm_tmpl *, struct xfrm_policy *); + struct xfrm_policy * (*compile_policy)(struct sock *, int, u8 *, int, int *); + int (*new_mapping)(struct xfrm_state *, xfrm_address_t *, __be16); + int (*notify_policy)(struct xfrm_policy *, int, const struct km_event *); + int (*report)(struct net *, u8, struct xfrm_selector *, xfrm_address_t *); + int (*migrate)(const struct xfrm_selector *, u8, u8, const struct xfrm_migrate *, int, const struct xfrm_kmaddress *, const struct xfrm_encap_tmpl *); + bool (*is_alive)(const struct km_event *); +}; + +struct xfrmk_sadinfo { + u32 sadhcnt; + u32 sadhmcnt; + u32 sadcnt; +}; + +struct xfrm_translator { + int (*alloc_compat)(struct sk_buff *, const struct nlmsghdr *); + struct nlmsghdr * (*rcv_msg_compat)(const struct nlmsghdr *, int, const struct nla_policy *, struct netlink_ext_ack *); + int (*xlate_user_policy_sockptr)(u8 **, int); + struct module *owner; +}; + +struct ip_beet_phdr { + __u8 nexthdr; + __u8 hdrlen; + __u8 padlen; + __u8 reserved; +}; + +struct __ip6_tnl_parm { + char name[16]; + int link; + __u8 proto; + __u8 encap_limit; + __u8 hop_limit; + bool collect_md; + __be32 flowinfo; + __u32 flags; + struct in6_addr laddr; + struct in6_addr raddr; + __be16 i_flags; + __be16 o_flags; + __be32 i_key; + __be32 o_key; + __u32 fwmark; + __u32 index; + __u8 erspan_ver; + __u8 dir; + __u16 hwid; +}; + +struct ip6_tnl { + struct ip6_tnl *next; + struct net_device *dev; + struct net *net; + struct __ip6_tnl_parm parms; + struct flowi fl; + struct dst_cache dst_cache; + struct gro_cells gro_cells; + int err_count; + long unsigned int err_time; + __u32 i_seqno; + __u32 o_seqno; + int hlen; + int tun_hlen; + int encap_hlen; + struct ip_tunnel_encap encap; + int mlink; +}; + +struct xfrm_skb_cb { + struct xfrm_tunnel_skb_cb header; + union { + struct { + __u32 low; + __u32 hi; + } output; + struct { + __be32 low; + __be32 hi; + } input; + } seq; +}; + +struct xfrm_trans_tasklet { + struct tasklet_struct tasklet; + struct sk_buff_head queue; +}; + +struct xfrm_trans_cb { + union { + struct inet_skb_parm h4; + struct inet6_skb_parm h6; + } header; + int (*finish)(struct net *, struct sock *, struct sk_buff *); + struct net *net; +}; + +struct sadb_alg { + __u8 sadb_alg_id; + __u8 sadb_alg_ivlen; + __u16 sadb_alg_minbits; + __u16 sadb_alg_maxbits; + __u16 sadb_alg_reserved; +}; + +struct xfrm_algo_aead_info { + char *geniv; + u16 icv_truncbits; +}; + +struct xfrm_algo_auth_info { + u16 icv_truncbits; + u16 icv_fullbits; +}; + +struct xfrm_algo_encr_info { + char *geniv; + u16 blockbits; + u16 defkeybits; +}; + +struct xfrm_algo_comp_info { + u16 threshold; +}; + +struct xfrm_algo_desc { + char *name; + char *compat; + u8 available: 1; + u8 pfkey_supported: 1; + union { + struct xfrm_algo_aead_info aead; + struct xfrm_algo_auth_info auth; + struct xfrm_algo_encr_info encr; + struct xfrm_algo_comp_info comp; + } uinfo; + struct sadb_alg desc; +}; + +struct xfrm_algo_list { + struct xfrm_algo_desc *algs; + int entries; + u32 type; + u32 mask; +}; + +struct xfrm_aead_name { + const char *name; + int icvbits; +}; + +enum { + XFRM_SHARE_ANY = 0, + XFRM_SHARE_SESSION = 1, + XFRM_SHARE_USER = 2, + XFRM_SHARE_UNIQUE = 3, +}; + +struct xfrm_user_sec_ctx { + __u16 len; + __u16 exttype; + __u8 ctx_alg; + __u8 ctx_doi; + __u16 ctx_len; +}; + +struct xfrm_user_tmpl { + struct xfrm_id id; + __u16 family; + xfrm_address_t saddr; + __u32 reqid; + __u8 mode; + __u8 share; + __u8 optional; + __u32 aalgos; + __u32 ealgos; + __u32 calgos; +}; + +struct xfrm_userpolicy_type { + __u8 type; + __u16 reserved1; + __u8 reserved2; +}; + +enum xfrm_sadattr_type_t { + XFRMA_SAD_UNSPEC = 0, + XFRMA_SAD_CNT = 1, + XFRMA_SAD_HINFO = 2, + __XFRMA_SAD_MAX = 3, +}; + +struct xfrmu_sadhinfo { + __u32 sadhcnt; + __u32 sadhmcnt; +}; + +enum xfrm_spdattr_type_t { + XFRMA_SPD_UNSPEC = 0, + XFRMA_SPD_INFO = 1, + XFRMA_SPD_HINFO = 2, + XFRMA_SPD_IPV4_HTHRESH = 3, + XFRMA_SPD_IPV6_HTHRESH = 4, + __XFRMA_SPD_MAX = 5, +}; + +struct xfrmu_spdinfo { + __u32 incnt; + __u32 outcnt; + __u32 fwdcnt; + __u32 inscnt; + __u32 outscnt; + __u32 fwdscnt; +}; + +struct xfrmu_spdhinfo { + __u32 spdhcnt; + __u32 spdhmcnt; +}; + +struct xfrmu_spdhthresh { + __u8 lbits; + __u8 rbits; +}; + +struct xfrm_usersa_info { + struct xfrm_selector sel; + struct xfrm_id id; + xfrm_address_t saddr; + struct xfrm_lifetime_cfg lft; + struct xfrm_lifetime_cur curlft; + struct xfrm_stats stats; + __u32 seq; + __u32 reqid; + __u16 family; + __u8 mode; + __u8 replay_window; + __u8 flags; +}; + +struct xfrm_usersa_id { + xfrm_address_t daddr; + __be32 spi; + __u16 family; + __u8 proto; +}; + +struct xfrm_aevent_id { + struct xfrm_usersa_id sa_id; + xfrm_address_t saddr; + __u32 flags; + __u32 reqid; +}; + +struct xfrm_userspi_info { + struct xfrm_usersa_info info; + __u32 min; + __u32 max; +}; + +struct xfrm_userpolicy_info { + struct xfrm_selector sel; + struct xfrm_lifetime_cfg lft; + struct xfrm_lifetime_cur curlft; + __u32 priority; + __u32 index; + __u8 dir; + __u8 action; + __u8 flags; + __u8 share; +}; + +struct xfrm_userpolicy_id { + struct xfrm_selector sel; + __u32 index; + __u8 dir; +}; + +struct xfrm_user_acquire { + struct xfrm_id id; + xfrm_address_t saddr; + struct xfrm_selector sel; + struct xfrm_userpolicy_info policy; + __u32 aalgos; + __u32 ealgos; + __u32 calgos; + __u32 seq; +}; + +struct xfrm_user_expire { + struct xfrm_usersa_info state; + __u8 hard; +}; + +struct xfrm_user_polexpire { + struct xfrm_userpolicy_info pol; + __u8 hard; +}; + +struct xfrm_usersa_flush { + __u8 proto; +}; + +struct xfrm_user_report { + __u8 proto; + struct xfrm_selector sel; +}; + +struct xfrm_user_mapping { + struct xfrm_usersa_id id; + __u32 reqid; + xfrm_address_t old_saddr; + xfrm_address_t new_saddr; + __be16 old_sport; + __be16 new_sport; +}; + +struct xfrm_user_offload { + int ifindex; + __u8 flags; +}; + +struct xfrm_dump_info { + struct sk_buff *in_skb; + struct sk_buff *out_skb; + u32 nlmsg_seq; + u16 nlmsg_flags; +}; + +struct xfrm_link { + int (*doit)(struct sk_buff *, struct nlmsghdr *, struct nlattr **); + int (*start)(struct netlink_callback *); + int (*dump)(struct sk_buff *, struct netlink_callback *); + int (*done)(struct netlink_callback *); + const struct nla_policy *nla_pol; + int nla_max; +}; + +struct unix_stream_read_state { + int (*recv_actor)(struct sk_buff *, int, int, struct unix_stream_read_state *); + struct socket *socket; + struct msghdr *msg; + struct pipe_inode_info *pipe; + size_t size; + int flags; + unsigned int splice_flags; +}; + +struct ipv6_params { + __s32 disable_ipv6; + __s32 autoconf; +}; + +enum flowlabel_reflect { + FLOWLABEL_REFLECT_ESTABLISHED = 1, + FLOWLABEL_REFLECT_TCP_RESET = 2, + FLOWLABEL_REFLECT_ICMPV6_ECHO_REPLIES = 4, +}; + +struct in6_rtmsg { + struct in6_addr rtmsg_dst; + struct in6_addr rtmsg_src; + struct in6_addr rtmsg_gateway; + __u32 rtmsg_type; + __u16 rtmsg_dst_len; + __u16 rtmsg_src_len; + __u32 rtmsg_metric; + long unsigned int rtmsg_info; + __u32 rtmsg_flags; + int rtmsg_ifindex; +}; + +struct compat_in6_rtmsg { + struct in6_addr rtmsg_dst; + struct in6_addr rtmsg_src; + struct in6_addr rtmsg_gateway; + u32 rtmsg_type; + u16 rtmsg_dst_len; + u16 rtmsg_src_len; + u32 rtmsg_metric; + u32 rtmsg_info; + u32 rtmsg_flags; + s32 rtmsg_ifindex; +}; + +struct ac6_iter_state { + struct seq_net_private p; + struct net_device *dev; + struct inet6_dev *idev; +}; + +struct ip6_fraglist_iter { + struct ipv6hdr *tmp_hdr; + struct sk_buff *frag; + int offset; + unsigned int hlen; + __be32 frag_id; + u8 nexthdr; +}; + +struct ip6_frag_state { + u8 *prevhdr; + unsigned int hlen; + unsigned int mtu; + unsigned int left; + int offset; + int ptr; + int hroom; + int troom; + __be32 frag_id; + u8 nexthdr; +}; + +struct ip6_ra_chain { + struct ip6_ra_chain *next; + struct sock *sk; + int sel; + void (*destructor)(struct sock *); +}; + +struct ipcm6_cookie { + struct sockcm_cookie sockc; + __s16 hlimit; + __s16 tclass; + __s8 dontfrag; + struct ipv6_txoptions *opt; + __u16 gso_size; +}; + +enum { + IFLA_INET6_UNSPEC = 0, + IFLA_INET6_FLAGS = 1, + IFLA_INET6_CONF = 2, + IFLA_INET6_STATS = 3, + IFLA_INET6_MCAST = 4, + IFLA_INET6_CACHEINFO = 5, + IFLA_INET6_ICMP6STATS = 6, + IFLA_INET6_TOKEN = 7, + IFLA_INET6_ADDR_GEN_MODE = 8, + __IFLA_INET6_MAX = 9, +}; + +enum in6_addr_gen_mode { + IN6_ADDR_GEN_MODE_EUI64 = 0, + IN6_ADDR_GEN_MODE_NONE = 1, + IN6_ADDR_GEN_MODE_STABLE_PRIVACY = 2, + IN6_ADDR_GEN_MODE_RANDOM = 3, +}; + +struct ifla_cacheinfo { + __u32 max_reasm_len; + __u32 tstamp; + __u32 reachable_time; + __u32 retrans_time; +}; + +struct wpan_phy; + +struct wpan_dev_header_ops; + +struct wpan_dev { + struct wpan_phy *wpan_phy; + int iftype; + struct list_head list; + struct net_device *netdev; + const struct wpan_dev_header_ops *header_ops; + struct net_device *lowpan_dev; + u32 identifier; + __le16 pan_id; + __le16 short_addr; + __le64 extended_addr; + atomic_t bsn; + atomic_t dsn; + u8 min_be; + u8 max_be; + u8 csma_retries; + s8 frame_retries; + bool lbt; + bool promiscuous_mode; + bool ackreq; +}; + +struct prefixmsg { + unsigned char prefix_family; + unsigned char prefix_pad1; + short unsigned int prefix_pad2; + int prefix_ifindex; + unsigned char prefix_type; + unsigned char prefix_len; + unsigned char prefix_flags; + unsigned char prefix_pad3; +}; + +enum { + PREFIX_UNSPEC = 0, + PREFIX_ADDRESS = 1, + PREFIX_CACHEINFO = 2, + __PREFIX_MAX = 3, +}; + +struct prefix_cacheinfo { + __u32 preferred_time; + __u32 valid_time; +}; + +struct in6_ifreq { + struct in6_addr ifr6_addr; + __u32 ifr6_prefixlen; + int ifr6_ifindex; +}; + +enum { + DEVCONF_FORWARDING = 0, + DEVCONF_HOPLIMIT = 1, + DEVCONF_MTU6 = 2, + DEVCONF_ACCEPT_RA = 3, + DEVCONF_ACCEPT_REDIRECTS = 4, + DEVCONF_AUTOCONF = 5, + DEVCONF_DAD_TRANSMITS = 6, + DEVCONF_RTR_SOLICITS = 7, + DEVCONF_RTR_SOLICIT_INTERVAL = 8, + DEVCONF_RTR_SOLICIT_DELAY = 9, + DEVCONF_USE_TEMPADDR = 10, + DEVCONF_TEMP_VALID_LFT = 11, + DEVCONF_TEMP_PREFERED_LFT = 12, + DEVCONF_REGEN_MAX_RETRY = 13, + DEVCONF_MAX_DESYNC_FACTOR = 14, + DEVCONF_MAX_ADDRESSES = 15, + DEVCONF_FORCE_MLD_VERSION = 16, + DEVCONF_ACCEPT_RA_DEFRTR = 17, + DEVCONF_ACCEPT_RA_PINFO = 18, + DEVCONF_ACCEPT_RA_RTR_PREF = 19, + DEVCONF_RTR_PROBE_INTERVAL = 20, + DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN = 21, + DEVCONF_PROXY_NDP = 22, + DEVCONF_OPTIMISTIC_DAD = 23, + DEVCONF_ACCEPT_SOURCE_ROUTE = 24, + DEVCONF_MC_FORWARDING = 25, + DEVCONF_DISABLE_IPV6 = 26, + DEVCONF_ACCEPT_DAD = 27, + DEVCONF_FORCE_TLLAO = 28, + DEVCONF_NDISC_NOTIFY = 29, + DEVCONF_MLDV1_UNSOLICITED_REPORT_INTERVAL = 30, + DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL = 31, + DEVCONF_SUPPRESS_FRAG_NDISC = 32, + DEVCONF_ACCEPT_RA_FROM_LOCAL = 33, + DEVCONF_USE_OPTIMISTIC = 34, + DEVCONF_ACCEPT_RA_MTU = 35, + DEVCONF_STABLE_SECRET = 36, + DEVCONF_USE_OIF_ADDRS_ONLY = 37, + DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT = 38, + DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN = 39, + DEVCONF_DROP_UNICAST_IN_L2_MULTICAST = 40, + DEVCONF_DROP_UNSOLICITED_NA = 41, + DEVCONF_KEEP_ADDR_ON_DOWN = 42, + DEVCONF_RTR_SOLICIT_MAX_INTERVAL = 43, + DEVCONF_SEG6_ENABLED = 44, + DEVCONF_SEG6_REQUIRE_HMAC = 45, + DEVCONF_ENHANCED_DAD = 46, + DEVCONF_ADDR_GEN_MODE = 47, + DEVCONF_DISABLE_POLICY = 48, + DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN = 49, + DEVCONF_NDISC_TCLASS = 50, + DEVCONF_RPL_SEG_ENABLED = 51, + DEVCONF_MAX = 52, +}; + +enum { + INET6_IFADDR_STATE_PREDAD = 0, + INET6_IFADDR_STATE_DAD = 1, + INET6_IFADDR_STATE_POSTDAD = 2, + INET6_IFADDR_STATE_ERRDAD = 3, + INET6_IFADDR_STATE_DEAD = 4, +}; + +enum nl802154_cca_modes { + __NL802154_CCA_INVALID = 0, + NL802154_CCA_ENERGY = 1, + NL802154_CCA_CARRIER = 2, + NL802154_CCA_ENERGY_CARRIER = 3, + NL802154_CCA_ALOHA = 4, + NL802154_CCA_UWB_SHR = 5, + NL802154_CCA_UWB_MULTIPLEXED = 6, + __NL802154_CCA_ATTR_AFTER_LAST = 7, + NL802154_CCA_ATTR_MAX = 6, +}; + +enum nl802154_cca_opts { + NL802154_CCA_OPT_ENERGY_CARRIER_AND = 0, + NL802154_CCA_OPT_ENERGY_CARRIER_OR = 1, + __NL802154_CCA_OPT_ATTR_AFTER_LAST = 2, + NL802154_CCA_OPT_ATTR_MAX = 1, +}; + +enum nl802154_supported_bool_states { + NL802154_SUPPORTED_BOOL_FALSE = 0, + NL802154_SUPPORTED_BOOL_TRUE = 1, + __NL802154_SUPPORTED_BOOL_INVALD = 2, + NL802154_SUPPORTED_BOOL_BOTH = 3, + __NL802154_SUPPORTED_BOOL_AFTER_LAST = 4, + NL802154_SUPPORTED_BOOL_MAX = 3, +}; + +struct wpan_phy_supported { + u32 channels[32]; + u32 cca_modes; + u32 cca_opts; + u32 iftypes; + enum nl802154_supported_bool_states lbt; + u8 min_minbe; + u8 max_minbe; + u8 min_maxbe; + u8 max_maxbe; + u8 min_csma_backoffs; + u8 max_csma_backoffs; + s8 min_frame_retries; + s8 max_frame_retries; + size_t tx_powers_size; + size_t cca_ed_levels_size; + const s32 *tx_powers; + const s32 *cca_ed_levels; +}; + +struct wpan_phy_cca { + enum nl802154_cca_modes mode; + enum nl802154_cca_opts opt; +}; + +struct wpan_phy { + const void *privid; + u32 flags; + u8 current_channel; + u8 current_page; + struct wpan_phy_supported supported; + s32 transmit_power; + struct wpan_phy_cca cca; + __le64 perm_extended_addr; + s32 cca_ed_level; + u8 symbol_duration; + u16 lifs_period; + u16 sifs_period; + struct device dev; + possible_net_t _net; + long: 64; + long: 64; + long: 64; + char priv[0]; +}; + +struct ieee802154_addr { + u8 mode; + __le16 pan_id; + union { + __le16 short_addr; + __le64 extended_addr; + }; +}; + +struct wpan_dev_header_ops { + int (*create)(struct sk_buff *, struct net_device *, const struct ieee802154_addr *, const struct ieee802154_addr *, unsigned int); +}; + +union fwnet_hwaddr { + u8 u[16]; + struct { + __be64 uniq_id; + u8 max_rec; + u8 sspd; + __be16 fifo_hi; + __be32 fifo_lo; + } uc; +}; + +struct in6_validator_info { + struct in6_addr i6vi_addr; + struct inet6_dev *i6vi_dev; + struct netlink_ext_ack *extack; +}; + +struct ifa6_config { + const struct in6_addr *pfx; + unsigned int plen; + const struct in6_addr *peer_pfx; + u32 rt_priority; + u32 ifa_flags; + u32 preferred_lft; + u32 valid_lft; + u16 scope; +}; + +enum cleanup_prefix_rt_t { + CLEANUP_PREFIX_RT_NOP = 0, + CLEANUP_PREFIX_RT_DEL = 1, + CLEANUP_PREFIX_RT_EXPIRE = 2, +}; + +enum { + IPV6_SADDR_RULE_INIT = 0, + IPV6_SADDR_RULE_LOCAL = 1, + IPV6_SADDR_RULE_SCOPE = 2, + IPV6_SADDR_RULE_PREFERRED = 3, + IPV6_SADDR_RULE_OIF = 4, + IPV6_SADDR_RULE_LABEL = 5, + IPV6_SADDR_RULE_PRIVACY = 6, + IPV6_SADDR_RULE_ORCHID = 7, + IPV6_SADDR_RULE_PREFIX = 8, + IPV6_SADDR_RULE_MAX = 9, +}; + +struct ipv6_saddr_score { + int rule; + int addr_type; + struct inet6_ifaddr *ifa; + long unsigned int scorebits[1]; + int scopedist; + int matchlen; +}; + +struct ipv6_saddr_dst { + const struct in6_addr *addr; + int ifindex; + int scope; + int label; + unsigned int prefs; +}; + +struct if6_iter_state { + struct seq_net_private p; + int bucket; + int offset; +}; + +enum addr_type_t { + UNICAST_ADDR = 0, + MULTICAST_ADDR = 1, + ANYCAST_ADDR = 2, +}; + +struct inet6_fill_args { + u32 portid; + u32 seq; + int event; + unsigned int flags; + int netnsid; + int ifindex; + enum addr_type_t type; +}; + +enum { + DAD_PROCESS = 0, + DAD_BEGIN = 1, + DAD_ABORT = 2, +}; + +struct ifaddrlblmsg { + __u8 ifal_family; + __u8 __ifal_reserved; + __u8 ifal_prefixlen; + __u8 ifal_flags; + __u32 ifal_index; + __u32 ifal_seq; +}; + +enum { + IFAL_ADDRESS = 1, + IFAL_LABEL = 2, + __IFAL_MAX = 3, +}; + +struct ip6addrlbl_entry { + struct in6_addr prefix; + int prefixlen; + int ifindex; + int addrtype; + u32 label; + struct hlist_node list; + struct callback_head rcu; +}; + +struct ip6addrlbl_init_table { + const struct in6_addr *prefix; + int prefixlen; + u32 label; +}; + +struct rd_msg { + struct icmp6hdr icmph; + struct in6_addr target; + struct in6_addr dest; + __u8 opt[0]; +}; + +struct fib6_gc_args { + int timeout; + int more; +}; + +struct rt6_exception { + struct hlist_node hlist; + struct rt6_info *rt6i; + long unsigned int stamp; + struct callback_head rcu; +}; + +struct route_info { + __u8 type; + __u8 length; + __u8 prefix_len; + __u8 reserved_l: 3; + __u8 route_pref: 2; + __u8 reserved_h: 3; + __be32 lifetime; + __u8 prefix[0]; +}; + +struct rt6_rtnl_dump_arg { + struct sk_buff *skb; + struct netlink_callback *cb; + struct net *net; + struct fib_dump_filter filter; +}; + +struct netevent_redirect { + struct dst_entry *old; + struct dst_entry *new; + struct neighbour *neigh; + const void *daddr; +}; + +struct trace_event_raw_fib6_table_lookup { + struct trace_entry ent; + u32 tb_id; + int err; + int oif; + int iif; + __u8 tos; + __u8 scope; + __u8 flags; + __u8 src[16]; + __u8 dst[16]; + u16 sport; + u16 dport; + u8 proto; + u8 rt_type; + u32 __data_loc_name; + __u8 gw[16]; + char __data[0]; +}; + +struct trace_event_data_offsets_fib6_table_lookup { + u32 name; +}; + +typedef void (*btf_trace_fib6_table_lookup)(void *, const struct net *, const struct fib6_result *, struct fib6_table *, const struct flowi6 *); + +enum rt6_nud_state { + RT6_NUD_FAIL_HARD = 4294967293, + RT6_NUD_FAIL_PROBE = 4294967294, + RT6_NUD_FAIL_DO_RR = 4294967295, + RT6_NUD_SUCCEED = 1, +}; + +struct fib6_nh_dm_arg { + struct net *net; + const struct in6_addr *saddr; + int oif; + int flags; + struct fib6_nh *nh; +}; + +struct __rt6_probe_work { + struct work_struct work; + struct in6_addr target; + struct net_device *dev; +}; + +struct fib6_nh_frl_arg { + u32 flags; + int oif; + int strict; + int *mpri; + bool *do_rr; + struct fib6_nh *nh; +}; + +struct fib6_nh_excptn_arg { + struct rt6_info *rt; + int plen; +}; + +struct fib6_nh_match_arg { + const struct net_device *dev; + const struct in6_addr *gw; + struct fib6_nh *match; +}; + +struct fib6_nh_age_excptn_arg { + struct fib6_gc_args *gc_args; + long unsigned int now; +}; + +struct fib6_nh_rd_arg { + struct fib6_result *res; + struct flowi6 *fl6; + const struct in6_addr *gw; + struct rt6_info **ret; +}; + +struct ip6rd_flowi { + struct flowi6 fl6; + struct in6_addr gateway; +}; + +struct fib6_nh_del_cached_rt_arg { + struct fib6_config *cfg; + struct fib6_info *f6i; +}; + +struct arg_dev_net_ip { + struct net_device *dev; + struct net *net; + struct in6_addr *addr; +}; + +struct arg_netdev_event { + const struct net_device *dev; + union { + unsigned char nh_flags; + long unsigned int event; + }; +}; + +struct rt6_mtu_change_arg { + struct net_device *dev; + unsigned int mtu; + struct fib6_info *f6i; +}; + +struct rt6_nh { + struct fib6_info *fib6_info; + struct fib6_config r_cfg; + struct list_head next; +}; + +struct fib6_nh_exception_dump_walker { + struct rt6_rtnl_dump_arg *dump; + struct fib6_info *rt; + unsigned int flags; + unsigned int skip; + unsigned int count; +}; + +enum fib6_walk_state { + FWS_S = 0, + FWS_L = 1, + FWS_R = 2, + FWS_C = 3, + FWS_U = 4, +}; + +struct fib6_walker { + struct list_head lh; + struct fib6_node *root; + struct fib6_node *node; + struct fib6_info *leaf; + enum fib6_walk_state state; + unsigned int skip; + unsigned int count; + unsigned int skip_in_node; + int (*func)(struct fib6_walker *); + void *args; +}; + +struct ipv6_route_iter { + struct seq_net_private p; + struct fib6_walker w; + loff_t skip; + struct fib6_table *tbl; + int sernum; +}; + +struct bpf_iter__ipv6_route { + union { + struct bpf_iter_meta *meta; + }; + union { + struct fib6_info *rt; + }; +}; + +struct fib6_cleaner { + struct fib6_walker w; + struct net *net; + int (*func)(struct fib6_info *, void *); + int sernum; + void *arg; + bool skip_notify; +}; + +enum { + FIB6_NO_SERNUM_CHANGE = 0, +}; + +struct fib6_dump_arg { + struct net *net; + struct notifier_block *nb; + struct netlink_ext_ack *extack; +}; + +struct fib6_nh_pcpu_arg { + struct fib6_info *from; + const struct fib6_table *table; +}; + +struct lookup_args { + int offset; + const struct in6_addr *addr; +}; + +struct ipv6_mreq { + struct in6_addr ipv6mr_multiaddr; + int ipv6mr_ifindex; +}; + +struct in6_flowlabel_req { + struct in6_addr flr_dst; + __be32 flr_label; + __u8 flr_action; + __u8 flr_share; + __u16 flr_flags; + __u16 flr_expires; + __u16 flr_linger; + __u32 __flr_pad; +}; + +struct ip6_mtuinfo { + struct sockaddr_in6 ip6m_addr; + __u32 ip6m_mtu; +}; + +struct nduseroptmsg { + unsigned char nduseropt_family; + unsigned char nduseropt_pad1; + short unsigned int nduseropt_opts_len; + int nduseropt_ifindex; + __u8 nduseropt_icmp_type; + __u8 nduseropt_icmp_code; + short unsigned int nduseropt_pad2; + unsigned int nduseropt_pad3; +}; + +enum { + NDUSEROPT_UNSPEC = 0, + NDUSEROPT_SRCADDR = 1, + __NDUSEROPT_MAX = 2, +}; + +struct rs_msg { + struct icmp6hdr icmph; + __u8 opt[0]; +}; + +struct ra_msg { + struct icmp6hdr icmph; + __be32 reachable_time; + __be32 retrans_timer; +}; + +struct static_key_false_deferred { + struct static_key_false key; + long unsigned int timeout; + struct delayed_work work; +}; + +struct icmp6_filter { + __u32 data[8]; +}; + +struct raw6_sock { + struct inet_sock inet; + __u32 checksum; + __u32 offset; + struct icmp6_filter filter; + __u32 ip6mr_table; + struct ipv6_pinfo inet6; +}; + +typedef int mh_filter_t(struct sock *, struct sk_buff *); + +struct raw6_frag_vec { + struct msghdr *msg; + int hlen; + char c[4]; +}; + +typedef void ip6_icmp_send_t(struct sk_buff *, u8, u8, __u32, const struct in6_addr *); + +struct ipv6_destopt_hao { + __u8 type; + __u8 length; + struct in6_addr addr; +} __attribute__((packed)); + +struct icmpv6_msg { + struct sk_buff *skb; + int offset; + uint8_t type; +}; + +struct icmp6_err { + int err; + int fatal; +}; + +struct mld_msg { + struct icmp6hdr mld_hdr; + struct in6_addr mld_mca; +}; + +struct mld2_grec { + __u8 grec_type; + __u8 grec_auxwords; + __be16 grec_nsrcs; + struct in6_addr grec_mca; + struct in6_addr grec_src[0]; +}; + +struct mld2_report { + struct icmp6hdr mld2r_hdr; + struct mld2_grec mld2r_grec[0]; +}; + +struct mld2_query { + struct icmp6hdr mld2q_hdr; + struct in6_addr mld2q_mca; + __u8 mld2q_qrv: 3; + __u8 mld2q_suppress: 1; + __u8 mld2q_resv2: 4; + __u8 mld2q_qqic; + __be16 mld2q_nsrcs; + struct in6_addr mld2q_srcs[0]; +}; + +struct igmp6_mc_iter_state { + struct seq_net_private p; + struct net_device *dev; + struct inet6_dev *idev; +}; + +struct igmp6_mcf_iter_state { + struct seq_net_private p; + struct net_device *dev; + struct inet6_dev *idev; + struct ifmcaddr6 *im; +}; + +enum ip6_defrag_users { + IP6_DEFRAG_LOCAL_DELIVER = 0, + IP6_DEFRAG_CONNTRACK_IN = 1, + __IP6_DEFRAG_CONNTRACK_IN = 65536, + IP6_DEFRAG_CONNTRACK_OUT = 65537, + __IP6_DEFRAG_CONNTRACK_OUT = 131072, + IP6_DEFRAG_CONNTRACK_BRIDGE_IN = 131073, + __IP6_DEFRAG_CONNTRACK_BRIDGE_IN = 196608, +}; + +struct frag_queue { + struct inet_frag_queue q; + int iif; + __u16 nhoffset; + u8 ecn; +}; + +struct tcp6_pseudohdr { + struct in6_addr saddr; + struct in6_addr daddr; + __be32 len; + __be32 protocol; +}; + +struct rt0_hdr { + struct ipv6_rt_hdr rt_hdr; + __u32 reserved; + struct in6_addr addr[0]; +}; + +struct ipv6_rpl_sr_hdr { + __u8 nexthdr; + __u8 hdrlen; + __u8 type; + __u8 segments_left; + __u32 cmpre: 4; + __u32 cmpri: 4; + __u32 reserved: 4; + __u32 pad: 4; + __u32 reserved1: 16; + union { + struct in6_addr addr[0]; + __u8 data[0]; + } segments; +}; + +struct tlvtype_proc { + int type; + bool (*func)(struct sk_buff *, int); +}; + +struct ip6fl_iter_state { + struct seq_net_private p; + struct pid_namespace *pid_ns; + int bucket; +}; + +struct sr6_tlv { + __u8 type; + __u8 len; + __u8 data[0]; +}; + +enum { + SEG6_ATTR_UNSPEC = 0, + SEG6_ATTR_DST = 1, + SEG6_ATTR_DSTLEN = 2, + SEG6_ATTR_HMACKEYID = 3, + SEG6_ATTR_SECRET = 4, + SEG6_ATTR_SECRETLEN = 5, + SEG6_ATTR_ALGID = 6, + SEG6_ATTR_HMACINFO = 7, + __SEG6_ATTR_MAX = 8, +}; + +enum { + SEG6_CMD_UNSPEC = 0, + SEG6_CMD_SETHMAC = 1, + SEG6_CMD_DUMPHMAC = 2, + SEG6_CMD_SET_TUNSRC = 3, + SEG6_CMD_GET_TUNSRC = 4, + __SEG6_CMD_MAX = 5, +}; + +struct xfrm6_protocol { + int (*handler)(struct sk_buff *); + int (*input_handler)(struct sk_buff *, int, __be32, int); + int (*cb_handler)(struct sk_buff *, int); + int (*err_handler)(struct sk_buff *, struct inet6_skb_parm *, u8, u8, int, __be32); + struct xfrm6_protocol *next; + int priority; +}; + +struct br_input_skb_cb { + struct net_device *brdev; + u16 frag_max_size; + u8 igmp; + u8 mrouters_only: 1; + u8 proxyarp_replied: 1; + u8 src_port_isolated: 1; + u8 vlan_filtered: 1; + u8 br_netfilter_broute: 1; +}; + +struct nf_bridge_frag_data; + +typedef struct rt6_info * (*pol_lookup_t)(struct net *, struct fib6_table *, struct flowi6 *, const struct sk_buff *, int); + +struct fib6_rule { + struct fib_rule common; + struct rt6key src; + struct rt6key dst; + u8 tclass; +}; + +struct calipso_doi; + +struct netlbl_calipso_ops { + int (*doi_add)(struct calipso_doi *, struct netlbl_audit *); + void (*doi_free)(struct calipso_doi *); + int (*doi_remove)(u32, struct netlbl_audit *); + struct calipso_doi * (*doi_getdef)(u32); + void (*doi_putdef)(struct calipso_doi *); + int (*doi_walk)(u32 *, int (*)(struct calipso_doi *, void *), void *); + int (*sock_getattr)(struct sock *, struct netlbl_lsm_secattr *); + int (*sock_setattr)(struct sock *, const struct calipso_doi *, const struct netlbl_lsm_secattr *); + void (*sock_delattr)(struct sock *); + int (*req_setattr)(struct request_sock *, const struct calipso_doi *, const struct netlbl_lsm_secattr *); + void (*req_delattr)(struct request_sock *); + int (*opt_getattr)(const unsigned char *, struct netlbl_lsm_secattr *); + unsigned char * (*skbuff_optptr)(const struct sk_buff *); + int (*skbuff_setattr)(struct sk_buff *, const struct calipso_doi *, const struct netlbl_lsm_secattr *); + int (*skbuff_delattr)(struct sk_buff *); + void (*cache_invalidate)(); + int (*cache_add)(const unsigned char *, const struct netlbl_lsm_secattr *); +}; + +struct calipso_doi { + u32 doi; + u32 type; + refcount_t refcount; + struct list_head list; + struct callback_head rcu; +}; + +struct calipso_map_cache_bkt { + spinlock_t lock; + u32 size; + struct list_head list; +}; + +struct calipso_map_cache_entry { + u32 hash; + unsigned char *key; + size_t key_len; + struct netlbl_lsm_cache *lsm_data; + u32 activity; + struct list_head list; +}; + +enum { + SEG6_IPTUNNEL_UNSPEC = 0, + SEG6_IPTUNNEL_SRH = 1, + __SEG6_IPTUNNEL_MAX = 2, +}; + +struct seg6_iptunnel_encap { + int mode; + struct ipv6_sr_hdr srh[0]; +}; + +enum { + SEG6_IPTUN_MODE_INLINE = 0, + SEG6_IPTUN_MODE_ENCAP = 1, + SEG6_IPTUN_MODE_L2ENCAP = 2, +}; + +struct seg6_lwt { + struct dst_cache cache; + struct seg6_iptunnel_encap tuninfo[0]; +}; + +enum { + SEG6_LOCAL_UNSPEC = 0, + SEG6_LOCAL_ACTION = 1, + SEG6_LOCAL_SRH = 2, + SEG6_LOCAL_TABLE = 3, + SEG6_LOCAL_NH4 = 4, + SEG6_LOCAL_NH6 = 5, + SEG6_LOCAL_IIF = 6, + SEG6_LOCAL_OIF = 7, + SEG6_LOCAL_BPF = 8, + __SEG6_LOCAL_MAX = 9, +}; + +enum { + SEG6_LOCAL_BPF_PROG_UNSPEC = 0, + SEG6_LOCAL_BPF_PROG = 1, + SEG6_LOCAL_BPF_PROG_NAME = 2, + __SEG6_LOCAL_BPF_PROG_MAX = 3, +}; + +struct seg6_local_lwt; + +struct seg6_action_desc { + int action; + long unsigned int attrs; + int (*input)(struct sk_buff *, struct seg6_local_lwt *); + int static_headroom; +}; + +struct seg6_local_lwt { + int action; + struct ipv6_sr_hdr *srh; + int table; + struct in_addr nh4; + struct in6_addr nh6; + int iif; + int oif; + struct bpf_lwt_prog bpf; + int headroom; + struct seg6_action_desc *desc; +}; + +struct seg6_action_param { + int (*parse)(struct nlattr **, struct seg6_local_lwt *); + int (*put)(struct sk_buff *, struct seg6_local_lwt *); + int (*cmp)(struct seg6_local_lwt *, struct seg6_local_lwt *); +}; + +struct xfrm6_tunnel { + int (*handler)(struct sk_buff *); + int (*cb_handler)(struct sk_buff *, int); + int (*err_handler)(struct sk_buff *, struct inet6_skb_parm *, u8, u8, int, __be32); + struct xfrm6_tunnel *next; + int priority; +}; + +struct ip6t_ip6 { + struct in6_addr src; + struct in6_addr dst; + struct in6_addr smsk; + struct in6_addr dmsk; + char iniface[16]; + char outiface[16]; + unsigned char iniface_mask[16]; + unsigned char outiface_mask[16]; + __u16 proto; + __u8 tos; + __u8 flags; + __u8 invflags; +}; + +struct ip6t_entry { + struct ip6t_ip6 ipv6; + unsigned int nfcache; + __u16 target_offset; + __u16 next_offset; + unsigned int comefrom; + struct xt_counters counters; + unsigned char elems[0]; +}; + +struct ip6t_standard { + struct ip6t_entry entry; + struct xt_standard_target target; +}; + +struct ip6t_error { + struct ip6t_entry entry; + struct xt_error_target target; +}; + +struct ip6t_icmp { + __u8 type; + __u8 code[2]; + __u8 invflags; +}; + +struct ip6t_getinfo { + char name[32]; + unsigned int valid_hooks; + unsigned int hook_entry[5]; + unsigned int underflow[5]; + unsigned int num_entries; + unsigned int size; +}; + +struct ip6t_replace { + char name[32]; + unsigned int valid_hooks; + unsigned int num_entries; + unsigned int size; + unsigned int hook_entry[5]; + unsigned int underflow[5]; + unsigned int num_counters; + struct xt_counters *counters; + struct ip6t_entry entries[0]; +}; + +struct ip6t_get_entries { + char name[32]; + unsigned int size; + struct ip6t_entry entrytable[0]; +}; + +struct compat_ip6t_entry { + struct ip6t_ip6 ipv6; + compat_uint_t nfcache; + __u16 target_offset; + __u16 next_offset; + compat_uint_t comefrom; + struct compat_xt_counters counters; + unsigned char elems[0]; +} __attribute__((packed)); + +struct compat_ip6t_replace { + char name[32]; + u32 valid_hooks; + u32 num_entries; + u32 size; + u32 hook_entry[5]; + u32 underflow[5]; + u32 num_counters; + compat_uptr_t counters; + struct compat_ip6t_entry entries[0]; +} __attribute__((packed)); + +struct compat_ip6t_get_entries { + char name[32]; + compat_uint_t size; + struct compat_ip6t_entry entrytable[0]; +} __attribute__((packed)); + +struct ip6_tnl_parm { + char name[16]; + int link; + __u8 proto; + __u8 encap_limit; + __u8 hop_limit; + __be32 flowinfo; + __u32 flags; + struct in6_addr laddr; + struct in6_addr raddr; +}; + +struct ipv6_tlv_tnl_enc_lim { + __u8 type; + __u8 length; + __u8 encap_limit; +}; + +struct ip6_tnl_net { + struct net_device *fb_tnl_dev; + struct ip6_tnl *tnls_r_l[32]; + struct ip6_tnl *tnls_wc[1]; + struct ip6_tnl **tnls[2]; + struct ip6_tnl *collect_md_tun; +}; + +struct ipv6_tel_txoption { + struct ipv6_txoptions ops; + __u8 dst_opt[8]; +}; + +struct ip6_tnl_parm2 { + char name[16]; + int link; + __u8 proto; + __u8 encap_limit; + __u8 hop_limit; + __be32 flowinfo; + __u32 flags; + struct in6_addr laddr; + struct in6_addr raddr; + __be16 i_flags; + __be16 o_flags; + __be32 i_key; + __be32 o_key; +}; + +struct ip6gre_net { + struct ip6_tnl *tunnels[128]; + struct ip6_tnl *collect_md_tun; + struct ip6_tnl *collect_md_tun_erspan; + struct net_device *fb_tunnel_dev; +}; + +enum { + IP6_FH_F_FRAG = 1, + IP6_FH_F_AUTH = 2, + IP6_FH_F_SKIP_RH = 4, +}; + +struct sockaddr_pkt { + short unsigned int spkt_family; + unsigned char spkt_device[14]; + __be16 spkt_protocol; +}; + +struct sockaddr_ll { + short unsigned int sll_family; + __be16 sll_protocol; + int sll_ifindex; + short unsigned int sll_hatype; + unsigned char sll_pkttype; + unsigned char sll_halen; + unsigned char sll_addr[8]; +}; + +struct tpacket_stats { + unsigned int tp_packets; + unsigned int tp_drops; +}; + +struct tpacket_stats_v3 { + unsigned int tp_packets; + unsigned int tp_drops; + unsigned int tp_freeze_q_cnt; +}; + +struct tpacket_rollover_stats { + __u64 tp_all; + __u64 tp_huge; + __u64 tp_failed; +}; + +union tpacket_stats_u { + struct tpacket_stats stats1; + struct tpacket_stats_v3 stats3; +}; + +struct tpacket_auxdata { + __u32 tp_status; + __u32 tp_len; + __u32 tp_snaplen; + __u16 tp_mac; + __u16 tp_net; + __u16 tp_vlan_tci; + __u16 tp_vlan_tpid; +}; + +struct tpacket_hdr { + long unsigned int tp_status; + unsigned int tp_len; + unsigned int tp_snaplen; + short unsigned int tp_mac; + short unsigned int tp_net; + unsigned int tp_sec; + unsigned int tp_usec; +}; + +struct tpacket2_hdr { + __u32 tp_status; + __u32 tp_len; + __u32 tp_snaplen; + __u16 tp_mac; + __u16 tp_net; + __u32 tp_sec; + __u32 tp_nsec; + __u16 tp_vlan_tci; + __u16 tp_vlan_tpid; + __u8 tp_padding[4]; +}; + +struct tpacket_hdr_variant1 { + __u32 tp_rxhash; + __u32 tp_vlan_tci; + __u16 tp_vlan_tpid; + __u16 tp_padding; +}; + +struct tpacket3_hdr { + __u32 tp_next_offset; + __u32 tp_sec; + __u32 tp_nsec; + __u32 tp_snaplen; + __u32 tp_len; + __u32 tp_status; + __u16 tp_mac; + __u16 tp_net; + union { + struct tpacket_hdr_variant1 hv1; + }; + __u8 tp_padding[8]; +}; + +struct tpacket_bd_ts { + unsigned int ts_sec; + union { + unsigned int ts_usec; + unsigned int ts_nsec; + }; +}; + +struct tpacket_hdr_v1 { + __u32 block_status; + __u32 num_pkts; + __u32 offset_to_first_pkt; + __u32 blk_len; + __u64 seq_num; + struct tpacket_bd_ts ts_first_pkt; + struct tpacket_bd_ts ts_last_pkt; +}; + +union tpacket_bd_header_u { + struct tpacket_hdr_v1 bh1; +}; + +struct tpacket_block_desc { + __u32 version; + __u32 offset_to_priv; + union tpacket_bd_header_u hdr; +}; + +enum tpacket_versions { + TPACKET_V1 = 0, + TPACKET_V2 = 1, + TPACKET_V3 = 2, +}; + +struct tpacket_req { + unsigned int tp_block_size; + unsigned int tp_block_nr; + unsigned int tp_frame_size; + unsigned int tp_frame_nr; +}; + +struct tpacket_req3 { + unsigned int tp_block_size; + unsigned int tp_block_nr; + unsigned int tp_frame_size; + unsigned int tp_frame_nr; + unsigned int tp_retire_blk_tov; + unsigned int tp_sizeof_priv; + unsigned int tp_feature_req_word; +}; + +union tpacket_req_u { + struct tpacket_req req; + struct tpacket_req3 req3; +}; + +struct fanout_args { + __u16 id; + __u16 type_flags; + __u32 max_num_members; +}; + +struct packet_mclist { + struct packet_mclist *next; + int ifindex; + int count; + short unsigned int type; + short unsigned int alen; + unsigned char addr[32]; +}; + +struct pgv; + +struct tpacket_kbdq_core { + struct pgv *pkbdq; + unsigned int feature_req_word; + unsigned int hdrlen; + unsigned char reset_pending_on_curr_blk; + unsigned char delete_blk_timer; + short unsigned int kactive_blk_num; + short unsigned int blk_sizeof_priv; + short unsigned int last_kactive_blk_num; + char *pkblk_start; + char *pkblk_end; + int kblk_size; + unsigned int max_frame_len; + unsigned int knum_blocks; + uint64_t knxt_seq_num; + char *prev; + char *nxt_offset; + struct sk_buff *skb; + rwlock_t blk_fill_in_prog_lock; + short unsigned int retire_blk_tov; + short unsigned int version; + long unsigned int tov_in_jiffies; + struct timer_list retire_blk_timer; +}; + +struct pgv { + char *buffer; +}; + +struct packet_ring_buffer { + struct pgv *pg_vec; + unsigned int head; + unsigned int frames_per_block; + unsigned int frame_size; + unsigned int frame_max; + unsigned int pg_vec_order; + unsigned int pg_vec_pages; + unsigned int pg_vec_len; + unsigned int *pending_refcnt; + union { + long unsigned int *rx_owner_map; + struct tpacket_kbdq_core prb_bdqc; + }; +}; + +struct packet_fanout { + possible_net_t net; + unsigned int num_members; + u32 max_num_members; + u16 id; + u8 type; + u8 flags; + union { + atomic_t rr_cur; + struct bpf_prog *bpf_prog; + }; + struct list_head list; + spinlock_t lock; + refcount_t sk_ref; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct packet_type prot_hook; + struct sock *arr[0]; +}; + +struct packet_rollover { + int sock; + atomic_long_t num; + atomic_long_t num_huge; + atomic_long_t num_failed; + long: 64; + long: 64; + long: 64; + long: 64; + u32 history[16]; +}; + +struct packet_sock { + struct sock sk; + struct packet_fanout *fanout; + union tpacket_stats_u stats; + struct packet_ring_buffer rx_ring; + struct packet_ring_buffer tx_ring; + int copy_thresh; + spinlock_t bind_lock; + struct mutex pg_vec_lock; + unsigned int running; + unsigned int auxdata: 1; + unsigned int origdev: 1; + unsigned int has_vnet_hdr: 1; + unsigned int tp_loss: 1; + unsigned int tp_tx_has_off: 1; + int pressure; + int ifindex; + __be16 num; + struct packet_rollover *rollover; + struct packet_mclist *mclist; + atomic_t mapped; + enum tpacket_versions tp_version; + unsigned int tp_hdrlen; + unsigned int tp_reserve; + unsigned int tp_tstamp; + struct completion skb_completion; + struct net_device *cached_dev; + int (*xmit)(struct sk_buff *); + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + struct packet_type prot_hook; + atomic_t tp_drops; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct packet_mreq_max { + int mr_ifindex; + short unsigned int mr_type; + short unsigned int mr_alen; + unsigned char mr_address[32]; +}; + +union tpacket_uhdr { + struct tpacket_hdr *h1; + struct tpacket2_hdr *h2; + struct tpacket3_hdr *h3; + void *raw; +}; + +struct packet_skb_cb { + union { + struct sockaddr_pkt pkt; + union { + unsigned int origlen; + struct sockaddr_ll ll; + }; + } sa; +}; + +struct switchdev_notifier_fdb_info { + struct switchdev_notifier_info info; + const unsigned char *addr; + u16 vid; + u8 added_by_user: 1; + u8 offloaded: 1; +}; + +enum br_boolopt_id { + BR_BOOLOPT_NO_LL_LEARN = 0, + BR_BOOLOPT_MAX = 1, +}; + +struct br_boolopt_multi { + __u32 optval; + __u32 optmask; +}; + +enum net_bridge_opts { + BROPT_VLAN_ENABLED = 0, + BROPT_VLAN_STATS_ENABLED = 1, + BROPT_NF_CALL_IPTABLES = 2, + BROPT_NF_CALL_IP6TABLES = 3, + BROPT_NF_CALL_ARPTABLES = 4, + BROPT_GROUP_ADDR_SET = 5, + BROPT_MULTICAST_ENABLED = 6, + BROPT_MULTICAST_QUERIER = 7, + BROPT_MULTICAST_QUERY_USE_IFADDR = 8, + BROPT_MULTICAST_STATS_ENABLED = 9, + BROPT_HAS_IPV6_ADDR = 10, + BROPT_NEIGH_SUPPRESS_ENABLED = 11, + BROPT_MTU_SET_BY_USER = 12, + BROPT_VLAN_STATS_PER_PORT = 13, + BROPT_NO_LL_LEARN = 14, + BROPT_VLAN_BRIDGE_BINDING = 15, +}; + +struct net_bridge_mcast_gc { + struct hlist_node gc_node; + void (*destroy)(struct net_bridge_mcast_gc *); +}; + +struct net_bridge_port_group_sg_key { + struct net_bridge_port *port; + struct br_ip addr; +}; + +struct net_bridge_port_group { + struct net_bridge_port_group *next; + struct net_bridge_port_group_sg_key key; + unsigned char eth_addr[6]; + unsigned char flags; + unsigned char filter_mode; + unsigned char grp_query_rexmit_cnt; + unsigned char rt_protocol; + struct hlist_head src_list; + unsigned int src_ents; + struct timer_list timer; + struct timer_list rexmit_timer; + struct hlist_node mglist; + struct rhash_head rhnode; + struct net_bridge_mcast_gc mcast_gc; + struct callback_head rcu; +}; + +struct net_bridge_mdb_entry { + struct rhash_head rhnode; + struct net_bridge *br; + struct net_bridge_port_group *ports; + struct br_ip addr; + bool host_joined; + struct timer_list timer; + struct hlist_node mdb_node; + struct net_bridge_mcast_gc mcast_gc; + struct callback_head rcu; +}; + +enum br_pkt_type { + BR_PKT_UNICAST = 0, + BR_PKT_MULTICAST = 1, + BR_PKT_BROADCAST = 2, +}; + +struct nf_br_ops { + int (*br_dev_xmit_hook)(struct sk_buff *); +}; + +enum { + FDB_NOTIFY_BIT = 1, + FDB_NOTIFY_INACTIVE_BIT = 2, +}; + +enum { + NFEA_UNSPEC = 0, + NFEA_ACTIVITY_NOTIFY = 1, + NFEA_DONT_REFRESH = 2, + __NFEA_MAX = 3, +}; + +struct __fdb_entry { + __u8 mac_addr[6]; + __u8 port_no; + __u8 is_local; + __u32 ageing_timer_value; + __u8 port_hi; + __u8 pad0; + __u16 unused; +}; + +struct br_vlan_stats { + u64 rx_bytes; + u64 rx_packets; + u64 tx_bytes; + u64 tx_packets; + struct u64_stats_sync syncp; +}; + +struct br_tunnel_info { + __be64 tunnel_id; + struct metadata_dst *tunnel_dst; +}; + +struct net_bridge_vlan { + struct rhash_head vnode; + struct rhash_head tnode; + u16 vid; + u16 flags; + u16 priv_flags; + u8 state; + struct br_vlan_stats *stats; + union { + struct net_bridge *br; + struct net_bridge_port *port; + }; + union { + refcount_t refcnt; + struct net_bridge_vlan *brvlan; + }; + struct br_tunnel_info tinfo; + struct list_head vlist; + struct callback_head rcu; +}; + +enum { + BR_FDB_LOCAL = 0, + BR_FDB_STATIC = 1, + BR_FDB_STICKY = 2, + BR_FDB_ADDED_BY_USER = 3, + BR_FDB_ADDED_BY_EXT_LEARN = 4, + BR_FDB_OFFLOADED = 5, + BR_FDB_NOTIFY = 6, + BR_FDB_NOTIFY_INACTIVE = 7, +}; + +struct br_frame_type { + __be16 type; + int (*frame_handler)(struct net_bridge_port *, struct sk_buff *); + struct hlist_node list; +}; + +struct __bridge_info { + __u64 designated_root; + __u64 bridge_id; + __u32 root_path_cost; + __u32 max_age; + __u32 hello_time; + __u32 forward_delay; + __u32 bridge_max_age; + __u32 bridge_hello_time; + __u32 bridge_forward_delay; + __u8 topology_change; + __u8 topology_change_detected; + __u8 root_port; + __u8 stp_enabled; + __u32 ageing_time; + __u32 gc_interval; + __u32 hello_timer_value; + __u32 tcn_timer_value; + __u32 topology_change_timer_value; + __u32 gc_timer_value; +}; + +struct __port_info { + __u64 designated_root; + __u64 designated_bridge; + __u16 port_id; + __u16 designated_port; + __u32 path_cost; + __u32 designated_cost; + __u8 state; + __u8 top_change_ack; + __u8 config_pending; + __u8 unused0; + __u32 message_age_timer_value; + __u32 forward_delay_timer_value; + __u32 hold_timer_value; +}; + +enum switchdev_attr_id { + SWITCHDEV_ATTR_ID_UNDEFINED = 0, + SWITCHDEV_ATTR_ID_PORT_STP_STATE = 1, + SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS = 2, + SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS = 3, + SWITCHDEV_ATTR_ID_PORT_MROUTER = 4, + SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME = 5, + SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING = 6, + SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED = 7, + SWITCHDEV_ATTR_ID_BRIDGE_MROUTER = 8, +}; + +struct switchdev_attr { + struct net_device *orig_dev; + enum switchdev_attr_id id; + u32 flags; + void *complete_priv; + void (*complete)(struct net_device *, int, void *); + union { + u8 stp_state; + long unsigned int brport_flags; + bool mrouter; + clock_t ageing_time; + bool vlan_filtering; + bool mc_disabled; + } u; +}; + +struct br_config_bpdu { + unsigned int topology_change: 1; + unsigned int topology_change_ack: 1; + bridge_id root; + int root_path_cost; + bridge_id bridge_id; + port_id port_id; + int message_age; + int max_age; + int hello_time; + int forward_delay; +}; + +enum { + IFLA_BR_UNSPEC = 0, + IFLA_BR_FORWARD_DELAY = 1, + IFLA_BR_HELLO_TIME = 2, + IFLA_BR_MAX_AGE = 3, + IFLA_BR_AGEING_TIME = 4, + IFLA_BR_STP_STATE = 5, + IFLA_BR_PRIORITY = 6, + IFLA_BR_VLAN_FILTERING = 7, + IFLA_BR_VLAN_PROTOCOL = 8, + IFLA_BR_GROUP_FWD_MASK = 9, + IFLA_BR_ROOT_ID = 10, + IFLA_BR_BRIDGE_ID = 11, + IFLA_BR_ROOT_PORT = 12, + IFLA_BR_ROOT_PATH_COST = 13, + IFLA_BR_TOPOLOGY_CHANGE = 14, + IFLA_BR_TOPOLOGY_CHANGE_DETECTED = 15, + IFLA_BR_HELLO_TIMER = 16, + IFLA_BR_TCN_TIMER = 17, + IFLA_BR_TOPOLOGY_CHANGE_TIMER = 18, + IFLA_BR_GC_TIMER = 19, + IFLA_BR_GROUP_ADDR = 20, + IFLA_BR_FDB_FLUSH = 21, + IFLA_BR_MCAST_ROUTER = 22, + IFLA_BR_MCAST_SNOOPING = 23, + IFLA_BR_MCAST_QUERY_USE_IFADDR = 24, + IFLA_BR_MCAST_QUERIER = 25, + IFLA_BR_MCAST_HASH_ELASTICITY = 26, + IFLA_BR_MCAST_HASH_MAX = 27, + IFLA_BR_MCAST_LAST_MEMBER_CNT = 28, + IFLA_BR_MCAST_STARTUP_QUERY_CNT = 29, + IFLA_BR_MCAST_LAST_MEMBER_INTVL = 30, + IFLA_BR_MCAST_MEMBERSHIP_INTVL = 31, + IFLA_BR_MCAST_QUERIER_INTVL = 32, + IFLA_BR_MCAST_QUERY_INTVL = 33, + IFLA_BR_MCAST_QUERY_RESPONSE_INTVL = 34, + IFLA_BR_MCAST_STARTUP_QUERY_INTVL = 35, + IFLA_BR_NF_CALL_IPTABLES = 36, + IFLA_BR_NF_CALL_IP6TABLES = 37, + IFLA_BR_NF_CALL_ARPTABLES = 38, + IFLA_BR_VLAN_DEFAULT_PVID = 39, + IFLA_BR_PAD = 40, + IFLA_BR_VLAN_STATS_ENABLED = 41, + IFLA_BR_MCAST_STATS_ENABLED = 42, + IFLA_BR_MCAST_IGMP_VERSION = 43, + IFLA_BR_MCAST_MLD_VERSION = 44, + IFLA_BR_VLAN_STATS_PER_PORT = 45, + IFLA_BR_MULTI_BOOLOPT = 46, + __IFLA_BR_MAX = 47, +}; + +enum { + LINK_XSTATS_TYPE_UNSPEC = 0, + LINK_XSTATS_TYPE_BRIDGE = 1, + LINK_XSTATS_TYPE_BOND = 2, + __LINK_XSTATS_TYPE_MAX = 3, +}; + +struct bridge_vlan_info { + __u16 flags; + __u16 vid; +}; + +struct bridge_vlan_xstats { + __u64 rx_bytes; + __u64 rx_packets; + __u64 tx_bytes; + __u64 tx_packets; + __u16 vid; + __u16 flags; + __u32 pad2; +}; + +enum { + BRIDGE_XSTATS_UNSPEC = 0, + BRIDGE_XSTATS_VLAN = 1, + BRIDGE_XSTATS_MCAST = 2, + BRIDGE_XSTATS_PAD = 3, + BRIDGE_XSTATS_STP = 4, + __BRIDGE_XSTATS_MAX = 5, +}; + +enum { + BR_GROUPFWD_STP = 1, + BR_GROUPFWD_MACPAUSE = 2, + BR_GROUPFWD_LACP = 4, +}; + +struct vtunnel_info { + u32 tunid; + u16 vid; + u16 flags; +}; + +enum { + IFLA_BRIDGE_VLAN_TUNNEL_UNSPEC = 0, + IFLA_BRIDGE_VLAN_TUNNEL_ID = 1, + IFLA_BRIDGE_VLAN_TUNNEL_VID = 2, + IFLA_BRIDGE_VLAN_TUNNEL_FLAGS = 3, + __IFLA_BRIDGE_VLAN_TUNNEL_MAX = 4, +}; + +struct brport_attribute { + struct attribute attr; + ssize_t (*show)(struct net_bridge_port *, char *); + int (*store)(struct net_bridge_port *, long unsigned int); + int (*store_raw)(struct net_bridge_port *, char *); +}; + +struct pimhdr { + __u8 type; + __u8 reserved; + __be16 csum; +}; + +enum { + MDB_RTR_TYPE_DISABLED = 0, + MDB_RTR_TYPE_TEMP_QUERY = 1, + MDB_RTR_TYPE_PERM = 2, + MDB_RTR_TYPE_TEMP = 3, +}; + +struct br_ip_list { + struct list_head list; + struct br_ip addr; +}; + +struct net_bridge_group_src { + struct hlist_node node; + struct br_ip addr; + struct net_bridge_port_group *pg; + u8 flags; + u8 src_query_rexmit_cnt; + struct timer_list timer; + struct net_bridge *br; + struct net_bridge_mcast_gc mcast_gc; + struct callback_head rcu; +}; + +enum switchdev_obj_id { + SWITCHDEV_OBJ_ID_UNDEFINED = 0, + SWITCHDEV_OBJ_ID_PORT_VLAN = 1, + SWITCHDEV_OBJ_ID_PORT_MDB = 2, + SWITCHDEV_OBJ_ID_HOST_MDB = 3, +}; + +struct switchdev_obj { + struct net_device *orig_dev; + enum switchdev_obj_id id; + u32 flags; + void *complete_priv; + void (*complete)(struct net_device *, int, void *); +}; + +struct switchdev_obj_port_mdb { + struct switchdev_obj obj; + unsigned char addr[6]; + u16 vid; +}; + +enum { + MDBA_UNSPEC = 0, + MDBA_MDB = 1, + MDBA_ROUTER = 2, + __MDBA_MAX = 3, +}; + +enum { + MDBA_MDB_UNSPEC = 0, + MDBA_MDB_ENTRY = 1, + __MDBA_MDB_MAX = 2, +}; + +enum { + MDBA_MDB_ENTRY_UNSPEC = 0, + MDBA_MDB_ENTRY_INFO = 1, + __MDBA_MDB_ENTRY_MAX = 2, +}; + +enum { + MDBA_MDB_EATTR_UNSPEC = 0, + MDBA_MDB_EATTR_TIMER = 1, + MDBA_MDB_EATTR_SRC_LIST = 2, + MDBA_MDB_EATTR_GROUP_MODE = 3, + MDBA_MDB_EATTR_SOURCE = 4, + MDBA_MDB_EATTR_RTPROT = 5, + __MDBA_MDB_EATTR_MAX = 6, +}; + +enum { + MDBA_MDB_SRCLIST_UNSPEC = 0, + MDBA_MDB_SRCLIST_ENTRY = 1, + __MDBA_MDB_SRCLIST_MAX = 2, +}; + +enum { + MDBA_MDB_SRCATTR_UNSPEC = 0, + MDBA_MDB_SRCATTR_ADDRESS = 1, + MDBA_MDB_SRCATTR_TIMER = 2, + __MDBA_MDB_SRCATTR_MAX = 3, +}; + +enum { + MDBA_ROUTER_UNSPEC = 0, + MDBA_ROUTER_PORT = 1, + __MDBA_ROUTER_MAX = 2, +}; + +enum { + MDBA_ROUTER_PATTR_UNSPEC = 0, + MDBA_ROUTER_PATTR_TIMER = 1, + MDBA_ROUTER_PATTR_TYPE = 2, + __MDBA_ROUTER_PATTR_MAX = 3, +}; + +struct br_port_msg { + __u8 family; + __u32 ifindex; +}; + +struct br_mdb_entry { + __u32 ifindex; + __u8 state; + __u8 flags; + __u16 vid; + struct { + union { + __be32 ip4; + struct in6_addr ip6; + unsigned char mac_addr[6]; + } u; + __be16 proto; + } addr; +}; + +enum { + MDBA_SET_ENTRY_UNSPEC = 0, + MDBA_SET_ENTRY = 1, + MDBA_SET_ENTRY_ATTRS = 2, + __MDBA_SET_ENTRY_MAX = 3, +}; + +enum { + MDBE_ATTR_UNSPEC = 0, + MDBE_ATTR_SOURCE = 1, + __MDBE_ATTR_MAX = 2, +}; + +struct br_mdb_complete_info { + struct net_bridge_port *port; + struct br_ip ip; +}; + +enum vlan_flags { + VLAN_FLAG_REORDER_HDR = 1, + VLAN_FLAG_GVRP = 2, + VLAN_FLAG_LOOSE_BINDING = 4, + VLAN_FLAG_MVRP = 8, + VLAN_FLAG_BRIDGE_BINDING = 16, +}; + +struct vlan_priority_tci_mapping { + u32 priority; + u16 vlan_qos; + struct vlan_priority_tci_mapping *next; +}; + +struct vlan_dev_priv { + unsigned int nr_ingress_mappings; + u32 ingress_priority_map[8]; + unsigned int nr_egress_mappings; + struct vlan_priority_tci_mapping *egress_priority_map[16]; + __be16 vlan_proto; + u16 vlan_id; + u16 flags; + struct net_device *real_dev; + unsigned char real_dev_addr[6]; + struct proc_dir_entry *dent; + struct vlan_pcpu_stats *vlan_pcpu_stats; + struct netpoll *netpoll; +}; + +struct br_vlan_msg { + __u8 family; + __u8 reserved1; + __u16 reserved2; + __u32 ifindex; +}; + +enum { + BRIDGE_VLANDB_DUMP_UNSPEC = 0, + BRIDGE_VLANDB_DUMP_FLAGS = 1, + __BRIDGE_VLANDB_DUMP_MAX = 2, +}; + +enum { + BRIDGE_VLANDB_UNSPEC = 0, + BRIDGE_VLANDB_ENTRY = 1, + __BRIDGE_VLANDB_MAX = 2, +}; + +enum { + BRIDGE_VLANDB_ENTRY_UNSPEC = 0, + BRIDGE_VLANDB_ENTRY_INFO = 1, + BRIDGE_VLANDB_ENTRY_RANGE = 2, + BRIDGE_VLANDB_ENTRY_STATE = 3, + BRIDGE_VLANDB_ENTRY_TUNNEL_INFO = 4, + BRIDGE_VLANDB_ENTRY_STATS = 5, + __BRIDGE_VLANDB_ENTRY_MAX = 6, +}; + +enum { + BRIDGE_VLANDB_STATS_UNSPEC = 0, + BRIDGE_VLANDB_STATS_RX_BYTES = 1, + BRIDGE_VLANDB_STATS_RX_PACKETS = 2, + BRIDGE_VLANDB_STATS_TX_BYTES = 3, + BRIDGE_VLANDB_STATS_TX_PACKETS = 4, + BRIDGE_VLANDB_STATS_PAD = 5, + __BRIDGE_VLANDB_STATS_MAX = 6, +}; + +enum { + BR_VLFLAG_PER_PORT_STATS = 1, + BR_VLFLAG_ADDED_BY_SWITCHDEV = 2, +}; + +struct br_vlan_bind_walk_data { + u16 vid; + struct net_device *result; +}; + +struct br_vlan_link_state_walk_data { + struct net_bridge *br; +}; + +enum { + BRIDGE_VLANDB_TINFO_UNSPEC = 0, + BRIDGE_VLANDB_TINFO_ID = 1, + BRIDGE_VLANDB_TINFO_CMD = 2, + __BRIDGE_VLANDB_TINFO_MAX = 3, +}; + +enum rpc_msg_type { + RPC_CALL = 0, + RPC_REPLY = 1, +}; + +enum rpc_reply_stat { + RPC_MSG_ACCEPTED = 0, + RPC_MSG_DENIED = 1, +}; + +enum rpc_reject_stat { + RPC_MISMATCH = 0, + RPC_AUTH_ERROR = 1, +}; + +enum rpc_auth_stat { + RPC_AUTH_OK = 0, + RPC_AUTH_BADCRED = 1, + RPC_AUTH_REJECTEDCRED = 2, + RPC_AUTH_BADVERF = 3, + RPC_AUTH_REJECTEDVERF = 4, + RPC_AUTH_TOOWEAK = 5, + RPCSEC_GSS_CREDPROBLEM = 13, + RPCSEC_GSS_CTXPROBLEM = 14, +}; + +struct xprt_create { + int ident; + struct net *net; + struct sockaddr *srcaddr; + struct sockaddr *dstaddr; + size_t addrlen; + const char *servername; + struct svc_xprt *bc_xprt; + struct rpc_xprt_switch *bc_xps; + unsigned int flags; +}; + +enum { + SUNRPC_PIPEFS_NFS_PRIO = 0, + SUNRPC_PIPEFS_RPC_PRIO = 1, +}; + +enum { + RPC_PIPEFS_MOUNT = 0, + RPC_PIPEFS_UMOUNT = 1, +}; + +struct rpc_add_xprt_test { + void (*add_xprt_test)(struct rpc_clnt *, struct rpc_xprt *, void *); + void *data; +}; + +struct sunrpc_net { + struct proc_dir_entry *proc_net_rpc; + struct cache_detail *ip_map_cache; + struct cache_detail *unix_gid_cache; + struct cache_detail *rsc_cache; + struct cache_detail *rsi_cache; + struct super_block *pipefs_sb; + struct rpc_pipe *gssd_dummy; + struct mutex pipefs_sb_lock; + struct list_head all_clients; + spinlock_t rpc_client_lock; + struct rpc_clnt *rpcb_local_clnt; + struct rpc_clnt *rpcb_local_clnt4; + spinlock_t rpcb_clnt_lock; + unsigned int rpcb_users; + unsigned int rpcb_is_af_local: 1; + struct mutex gssp_lock; + struct rpc_clnt *gssp_clnt; + int use_gss_proxy; + int pipe_version; + atomic_t pipe_users; + struct proc_dir_entry *use_gssp_proc; +}; + +struct rpc_cb_add_xprt_calldata { + struct rpc_xprt_switch *xps; + struct rpc_xprt *xprt; +}; + +struct connect_timeout_data { + long unsigned int connect_timeout; + long unsigned int reconnect_timeout; +}; + +struct xprt_class { + struct list_head list; + int ident; + struct rpc_xprt * (*setup)(struct xprt_create *); + struct module *owner; + char name[32]; +}; + +enum xprt_xid_rb_cmp { + XID_RB_EQUAL = 0, + XID_RB_LEFT = 1, + XID_RB_RIGHT = 2, +}; + +typedef __be32 rpc_fraghdr; + +struct xdr_skb_reader { + struct sk_buff *skb; + unsigned int offset; + size_t count; + __wsum csum; +}; + +typedef size_t (*xdr_skb_read_actor)(struct xdr_skb_reader *, void *, size_t); + +struct svc_sock { + struct svc_xprt sk_xprt; + struct socket *sk_sock; + struct sock *sk_sk; + void (*sk_ostate)(struct sock *); + void (*sk_odata)(struct sock *); + void (*sk_owspace)(struct sock *); + __be32 sk_marker; + u32 sk_tcplen; + u32 sk_datalen; + struct page *sk_pages[259]; +}; + +struct sock_xprt { + struct rpc_xprt xprt; + struct socket *sock; + struct sock *inet; + struct file *file; + struct { + struct { + __be32 fraghdr; + __be32 xid; + __be32 calldir; + }; + u32 offset; + u32 len; + long unsigned int copied; + } recv; + struct { + u32 offset; + } xmit; + long unsigned int sock_state; + struct delayed_work connect_worker; + struct work_struct error_worker; + struct work_struct recv_worker; + struct mutex recv_mutex; + struct __kernel_sockaddr_storage srcaddr; + short unsigned int srcport; + int xprt_err; + size_t rcvsize; + size_t sndsize; + struct rpc_timeout tcp_timeout; + void (*old_data_ready)(struct sock *); + void (*old_state_change)(struct sock *); + void (*old_write_space)(struct sock *); + void (*old_error_report)(struct sock *); +}; + +struct rpc_buffer { + size_t len; + char data[0]; +}; + +typedef void (*rpc_action)(struct rpc_task *); + +struct trace_event_raw_rpc_xdr_buf_class { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + const void *head_base; + size_t head_len; + const void *tail_base; + size_t tail_len; + unsigned int page_len; + unsigned int msg_len; + char __data[0]; +}; + +struct trace_event_raw_rpc_clnt_class { + struct trace_entry ent; + unsigned int client_id; + char __data[0]; +}; + +struct trace_event_raw_rpc_clnt_new { + struct trace_entry ent; + unsigned int client_id; + u32 __data_loc_addr; + u32 __data_loc_port; + u32 __data_loc_program; + u32 __data_loc_server; + char __data[0]; +}; + +struct trace_event_raw_rpc_clnt_new_err { + struct trace_entry ent; + int error; + u32 __data_loc_program; + u32 __data_loc_server; + char __data[0]; +}; + +struct trace_event_raw_rpc_clnt_clone_err { + struct trace_entry ent; + unsigned int client_id; + int error; + char __data[0]; +}; + +struct trace_event_raw_rpc_task_status { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + int status; + char __data[0]; +}; + +struct trace_event_raw_rpc_request { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + int version; + bool async; + u32 __data_loc_progname; + u32 __data_loc_procname; + char __data[0]; +}; + +struct trace_event_raw_rpc_task_running { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + const void *action; + long unsigned int runstate; + int status; + short unsigned int flags; + char __data[0]; +}; + +struct trace_event_raw_rpc_task_queued { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + long unsigned int timeout; + long unsigned int runstate; + int status; + short unsigned int flags; + u32 __data_loc_q_name; + char __data[0]; +}; + +struct trace_event_raw_rpc_failure { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + char __data[0]; +}; + +struct trace_event_raw_rpc_reply_event { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + u32 xid; + u32 __data_loc_progname; + u32 version; + u32 __data_loc_procname; + u32 __data_loc_servername; + char __data[0]; +}; + +struct trace_event_raw_rpc_buf_alloc { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + size_t callsize; + size_t recvsize; + int status; + char __data[0]; +}; + +struct trace_event_raw_rpc_call_rpcerror { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + int tk_status; + int rpc_status; + char __data[0]; +}; + +struct trace_event_raw_rpc_stats_latency { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + u32 xid; + int version; + u32 __data_loc_progname; + u32 __data_loc_procname; + long unsigned int backlog; + long unsigned int rtt; + long unsigned int execute; + char __data[0]; +}; + +struct trace_event_raw_rpc_xdr_overflow { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + int version; + size_t requested; + const void *end; + const void *p; + const void *head_base; + size_t head_len; + const void *tail_base; + size_t tail_len; + unsigned int page_len; + unsigned int len; + u32 __data_loc_progname; + u32 __data_loc_procedure; + char __data[0]; +}; + +struct trace_event_raw_rpc_xdr_alignment { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + int version; + size_t offset; + unsigned int copied; + const void *head_base; + size_t head_len; + const void *tail_base; + size_t tail_len; + unsigned int page_len; + unsigned int len; + u32 __data_loc_progname; + u32 __data_loc_procedure; + char __data[0]; +}; + +struct trace_event_raw_xs_socket_event { + struct trace_entry ent; + unsigned int socket_state; + unsigned int sock_state; + long long unsigned int ino; + u32 __data_loc_dstaddr; + u32 __data_loc_dstport; + char __data[0]; +}; + +struct trace_event_raw_xs_socket_event_done { + struct trace_entry ent; + int error; + unsigned int socket_state; + unsigned int sock_state; + long long unsigned int ino; + u32 __data_loc_dstaddr; + u32 __data_loc_dstport; + char __data[0]; +}; + +struct trace_event_raw_rpc_socket_nospace { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + unsigned int total; + unsigned int remaining; + char __data[0]; +}; + +struct trace_event_raw_rpc_xprt_lifetime_class { + struct trace_entry ent; + long unsigned int state; + u32 __data_loc_addr; + u32 __data_loc_port; + char __data[0]; +}; + +struct trace_event_raw_rpc_xprt_event { + struct trace_entry ent; + u32 xid; + int status; + u32 __data_loc_addr; + u32 __data_loc_port; + char __data[0]; +}; + +struct trace_event_raw_xprt_transmit { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + u32 xid; + u32 seqno; + int status; + char __data[0]; +}; + +struct trace_event_raw_xprt_ping { + struct trace_entry ent; + int status; + u32 __data_loc_addr; + u32 __data_loc_port; + char __data[0]; +}; + +struct trace_event_raw_xprt_writelock_event { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + unsigned int snd_task_id; + char __data[0]; +}; + +struct trace_event_raw_xprt_cong_event { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + unsigned int snd_task_id; + long unsigned int cong; + long unsigned int cwnd; + bool wait; + char __data[0]; +}; + +struct trace_event_raw_xprt_reserve { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + u32 xid; + char __data[0]; +}; + +struct trace_event_raw_xs_stream_read_data { + struct trace_entry ent; + ssize_t err; + size_t total; + u32 __data_loc_addr; + u32 __data_loc_port; + char __data[0]; +}; + +struct trace_event_raw_xs_stream_read_request { + struct trace_entry ent; + u32 __data_loc_addr; + u32 __data_loc_port; + u32 xid; + long unsigned int copied; + unsigned int reclen; + unsigned int offset; + char __data[0]; +}; + +struct trace_event_raw_rpcb_getport { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + unsigned int program; + unsigned int version; + int protocol; + unsigned int bind_version; + u32 __data_loc_servername; + char __data[0]; +}; + +struct trace_event_raw_rpcb_setport { + struct trace_entry ent; + unsigned int task_id; + unsigned int client_id; + int status; + short unsigned int port; + char __data[0]; +}; + +struct trace_event_raw_pmap_register { + struct trace_entry ent; + unsigned int program; + unsigned int version; + int protocol; + unsigned int port; + char __data[0]; +}; + +struct trace_event_raw_rpcb_register { + struct trace_entry ent; + unsigned int program; + unsigned int version; + u32 __data_loc_addr; + u32 __data_loc_netid; + char __data[0]; +}; + +struct trace_event_raw_rpcb_unregister { + struct trace_entry ent; + unsigned int program; + unsigned int version; + u32 __data_loc_netid; + char __data[0]; +}; + +struct trace_event_raw_svc_xdr_buf_class { + struct trace_entry ent; + u32 xid; + const void *head_base; + size_t head_len; + const void *tail_base; + size_t tail_len; + unsigned int page_len; + unsigned int msg_len; + char __data[0]; +}; + +struct trace_event_raw_svc_recv { + struct trace_entry ent; + u32 xid; + int len; + long unsigned int flags; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svc_authenticate { + struct trace_entry ent; + u32 xid; + long unsigned int svc_status; + long unsigned int auth_stat; + char __data[0]; +}; + +struct trace_event_raw_svc_process { + struct trace_entry ent; + u32 xid; + u32 vers; + u32 proc; + u32 __data_loc_service; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svc_rqst_event { + struct trace_entry ent; + u32 xid; + long unsigned int flags; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svc_rqst_status { + struct trace_entry ent; + u32 xid; + int status; + long unsigned int flags; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svc_xprt_create_err { + struct trace_entry ent; + long int error; + u32 __data_loc_program; + u32 __data_loc_protocol; + unsigned char addr[28]; + char __data[0]; +}; + +struct trace_event_raw_svc_xprt_do_enqueue { + struct trace_entry ent; + int pid; + long unsigned int flags; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svc_xprt_event { + struct trace_entry ent; + long unsigned int flags; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svc_xprt_accept { + struct trace_entry ent; + u32 __data_loc_addr; + u32 __data_loc_protocol; + u32 __data_loc_service; + char __data[0]; +}; + +struct trace_event_raw_svc_xprt_dequeue { + struct trace_entry ent; + long unsigned int flags; + long unsigned int wakeup; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svc_wake_up { + struct trace_entry ent; + int pid; + char __data[0]; +}; + +struct trace_event_raw_svc_handle_xprt { + struct trace_entry ent; + int len; + long unsigned int flags; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svc_stats_latency { + struct trace_entry ent; + u32 xid; + long unsigned int execute; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svc_deferred_event { + struct trace_entry ent; + const void *dr; + u32 xid; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svcsock_new_socket { + struct trace_entry ent; + long unsigned int type; + long unsigned int family; + bool listener; + char __data[0]; +}; + +struct trace_event_raw_svcsock_marker { + struct trace_entry ent; + unsigned int length; + bool last; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svcsock_class { + struct trace_entry ent; + ssize_t result; + long unsigned int flags; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svcsock_tcp_recv_short { + struct trace_entry ent; + u32 expected; + u32 received; + long unsigned int flags; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svcsock_tcp_state { + struct trace_entry ent; + long unsigned int socket_state; + long unsigned int sock_state; + long unsigned int flags; + u32 __data_loc_addr; + char __data[0]; +}; + +struct trace_event_raw_svcsock_accept_class { + struct trace_entry ent; + long int status; + u32 __data_loc_service; + unsigned char addr[28]; + char __data[0]; +}; + +struct trace_event_raw_cache_event { + struct trace_entry ent; + const struct cache_head *h; + u32 __data_loc_name; + char __data[0]; +}; + +struct trace_event_raw_register_class { + struct trace_entry ent; + u32 version; + long unsigned int family; + short unsigned int protocol; + short unsigned int port; + int error; + u32 __data_loc_program; + char __data[0]; +}; + +struct trace_event_raw_svc_unregister { + struct trace_entry ent; + u32 version; + int error; + u32 __data_loc_program; + char __data[0]; +}; + +struct trace_event_data_offsets_rpc_xdr_buf_class {}; + +struct trace_event_data_offsets_rpc_clnt_class {}; + +struct trace_event_data_offsets_rpc_clnt_new { + u32 addr; + u32 port; + u32 program; + u32 server; +}; + +struct trace_event_data_offsets_rpc_clnt_new_err { + u32 program; + u32 server; +}; + +struct trace_event_data_offsets_rpc_clnt_clone_err {}; + +struct trace_event_data_offsets_rpc_task_status {}; + +struct trace_event_data_offsets_rpc_request { + u32 progname; + u32 procname; +}; + +struct trace_event_data_offsets_rpc_task_running {}; + +struct trace_event_data_offsets_rpc_task_queued { + u32 q_name; +}; + +struct trace_event_data_offsets_rpc_failure {}; + +struct trace_event_data_offsets_rpc_reply_event { + u32 progname; + u32 procname; + u32 servername; +}; + +struct trace_event_data_offsets_rpc_buf_alloc {}; + +struct trace_event_data_offsets_rpc_call_rpcerror {}; + +struct trace_event_data_offsets_rpc_stats_latency { + u32 progname; + u32 procname; +}; + +struct trace_event_data_offsets_rpc_xdr_overflow { + u32 progname; + u32 procedure; +}; + +struct trace_event_data_offsets_rpc_xdr_alignment { + u32 progname; + u32 procedure; +}; + +struct trace_event_data_offsets_xs_socket_event { + u32 dstaddr; + u32 dstport; +}; + +struct trace_event_data_offsets_xs_socket_event_done { + u32 dstaddr; + u32 dstport; +}; + +struct trace_event_data_offsets_rpc_socket_nospace {}; + +struct trace_event_data_offsets_rpc_xprt_lifetime_class { + u32 addr; + u32 port; +}; + +struct trace_event_data_offsets_rpc_xprt_event { + u32 addr; + u32 port; +}; + +struct trace_event_data_offsets_xprt_transmit {}; + +struct trace_event_data_offsets_xprt_ping { + u32 addr; + u32 port; +}; + +struct trace_event_data_offsets_xprt_writelock_event {}; + +struct trace_event_data_offsets_xprt_cong_event {}; + +struct trace_event_data_offsets_xprt_reserve {}; + +struct trace_event_data_offsets_xs_stream_read_data { + u32 addr; + u32 port; +}; + +struct trace_event_data_offsets_xs_stream_read_request { + u32 addr; + u32 port; +}; + +struct trace_event_data_offsets_rpcb_getport { + u32 servername; +}; + +struct trace_event_data_offsets_rpcb_setport {}; + +struct trace_event_data_offsets_pmap_register {}; + +struct trace_event_data_offsets_rpcb_register { + u32 addr; + u32 netid; +}; + +struct trace_event_data_offsets_rpcb_unregister { + u32 netid; +}; + +struct trace_event_data_offsets_svc_xdr_buf_class {}; + +struct trace_event_data_offsets_svc_recv { + u32 addr; +}; + +struct trace_event_data_offsets_svc_authenticate {}; + +struct trace_event_data_offsets_svc_process { + u32 service; + u32 addr; +}; + +struct trace_event_data_offsets_svc_rqst_event { + u32 addr; +}; + +struct trace_event_data_offsets_svc_rqst_status { + u32 addr; +}; + +struct trace_event_data_offsets_svc_xprt_create_err { + u32 program; + u32 protocol; +}; + +struct trace_event_data_offsets_svc_xprt_do_enqueue { + u32 addr; +}; + +struct trace_event_data_offsets_svc_xprt_event { + u32 addr; +}; + +struct trace_event_data_offsets_svc_xprt_accept { + u32 addr; + u32 protocol; + u32 service; +}; + +struct trace_event_data_offsets_svc_xprt_dequeue { + u32 addr; +}; + +struct trace_event_data_offsets_svc_wake_up {}; + +struct trace_event_data_offsets_svc_handle_xprt { + u32 addr; +}; + +struct trace_event_data_offsets_svc_stats_latency { + u32 addr; +}; + +struct trace_event_data_offsets_svc_deferred_event { + u32 addr; +}; + +struct trace_event_data_offsets_svcsock_new_socket {}; + +struct trace_event_data_offsets_svcsock_marker { + u32 addr; +}; + +struct trace_event_data_offsets_svcsock_class { + u32 addr; +}; + +struct trace_event_data_offsets_svcsock_tcp_recv_short { + u32 addr; +}; + +struct trace_event_data_offsets_svcsock_tcp_state { + u32 addr; +}; + +struct trace_event_data_offsets_svcsock_accept_class { + u32 service; +}; + +struct trace_event_data_offsets_cache_event { + u32 name; +}; + +struct trace_event_data_offsets_register_class { + u32 program; +}; + +struct trace_event_data_offsets_svc_unregister { + u32 program; +}; + +typedef void (*btf_trace_rpc_xdr_sendto)(void *, const struct rpc_task *, const struct xdr_buf *); + +typedef void (*btf_trace_rpc_xdr_recvfrom)(void *, const struct rpc_task *, const struct xdr_buf *); + +typedef void (*btf_trace_rpc_xdr_reply_pages)(void *, const struct rpc_task *, const struct xdr_buf *); + +typedef void (*btf_trace_rpc_clnt_free)(void *, const struct rpc_clnt *); + +typedef void (*btf_trace_rpc_clnt_killall)(void *, const struct rpc_clnt *); + +typedef void (*btf_trace_rpc_clnt_shutdown)(void *, const struct rpc_clnt *); + +typedef void (*btf_trace_rpc_clnt_release)(void *, const struct rpc_clnt *); + +typedef void (*btf_trace_rpc_clnt_replace_xprt)(void *, const struct rpc_clnt *); + +typedef void (*btf_trace_rpc_clnt_replace_xprt_err)(void *, const struct rpc_clnt *); + +typedef void (*btf_trace_rpc_clnt_new)(void *, const struct rpc_clnt *, const struct rpc_xprt *, const char *, const char *); + +typedef void (*btf_trace_rpc_clnt_new_err)(void *, const char *, const char *, int); + +typedef void (*btf_trace_rpc_clnt_clone_err)(void *, const struct rpc_clnt *, int); + +typedef void (*btf_trace_rpc_call_status)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc_connect_status)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc_timeout_status)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc_retry_refresh_status)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc_refresh_status)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc_request)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc_task_begin)(void *, const struct rpc_task *, const void *); + +typedef void (*btf_trace_rpc_task_run_action)(void *, const struct rpc_task *, const void *); + +typedef void (*btf_trace_rpc_task_sync_sleep)(void *, const struct rpc_task *, const void *); + +typedef void (*btf_trace_rpc_task_sync_wake)(void *, const struct rpc_task *, const void *); + +typedef void (*btf_trace_rpc_task_complete)(void *, const struct rpc_task *, const void *); + +typedef void (*btf_trace_rpc_task_timeout)(void *, const struct rpc_task *, const void *); + +typedef void (*btf_trace_rpc_task_signalled)(void *, const struct rpc_task *, const void *); + +typedef void (*btf_trace_rpc_task_end)(void *, const struct rpc_task *, const void *); + +typedef void (*btf_trace_rpc_task_sleep)(void *, const struct rpc_task *, const struct rpc_wait_queue *); + +typedef void (*btf_trace_rpc_task_wakeup)(void *, const struct rpc_task *, const struct rpc_wait_queue *); + +typedef void (*btf_trace_rpc_bad_callhdr)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc_bad_verifier)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc__prog_unavail)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc__prog_mismatch)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc__proc_unavail)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc__garbage_args)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc__unparsable)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc__mismatch)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc__stale_creds)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc__bad_creds)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc__auth_tooweak)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpcb_prog_unavail_err)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpcb_timeout_err)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpcb_bind_version_err)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpcb_unreachable_err)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpcb_unrecognized_err)(void *, const struct rpc_task *); + +typedef void (*btf_trace_rpc_buf_alloc)(void *, const struct rpc_task *, int); + +typedef void (*btf_trace_rpc_call_rpcerror)(void *, const struct rpc_task *, int, int); + +typedef void (*btf_trace_rpc_stats_latency)(void *, const struct rpc_task *, ktime_t, ktime_t, ktime_t); + +typedef void (*btf_trace_rpc_xdr_overflow)(void *, const struct xdr_stream *, size_t); + +typedef void (*btf_trace_rpc_xdr_alignment)(void *, const struct xdr_stream *, size_t, unsigned int); + +typedef void (*btf_trace_rpc_socket_state_change)(void *, struct rpc_xprt *, struct socket *); + +typedef void (*btf_trace_rpc_socket_connect)(void *, struct rpc_xprt *, struct socket *, int); + +typedef void (*btf_trace_rpc_socket_error)(void *, struct rpc_xprt *, struct socket *, int); + +typedef void (*btf_trace_rpc_socket_reset_connection)(void *, struct rpc_xprt *, struct socket *, int); + +typedef void (*btf_trace_rpc_socket_close)(void *, struct rpc_xprt *, struct socket *); + +typedef void (*btf_trace_rpc_socket_shutdown)(void *, struct rpc_xprt *, struct socket *); + +typedef void (*btf_trace_rpc_socket_nospace)(void *, const struct rpc_rqst *, const struct sock_xprt *); + +typedef void (*btf_trace_xprt_create)(void *, const struct rpc_xprt *); + +typedef void (*btf_trace_xprt_connect)(void *, const struct rpc_xprt *); + +typedef void (*btf_trace_xprt_disconnect_auto)(void *, const struct rpc_xprt *); + +typedef void (*btf_trace_xprt_disconnect_done)(void *, const struct rpc_xprt *); + +typedef void (*btf_trace_xprt_disconnect_force)(void *, const struct rpc_xprt *); + +typedef void (*btf_trace_xprt_disconnect_cleanup)(void *, const struct rpc_xprt *); + +typedef void (*btf_trace_xprt_destroy)(void *, const struct rpc_xprt *); + +typedef void (*btf_trace_xprt_timer)(void *, const struct rpc_xprt *, __be32, int); + +typedef void (*btf_trace_xprt_lookup_rqst)(void *, const struct rpc_xprt *, __be32, int); + +typedef void (*btf_trace_xprt_transmit)(void *, const struct rpc_rqst *, int); + +typedef void (*btf_trace_xprt_ping)(void *, const struct rpc_xprt *, int); + +typedef void (*btf_trace_xprt_reserve_xprt)(void *, const struct rpc_xprt *, const struct rpc_task *); + +typedef void (*btf_trace_xprt_release_xprt)(void *, const struct rpc_xprt *, const struct rpc_task *); + +typedef void (*btf_trace_xprt_transmit_queued)(void *, const struct rpc_xprt *, const struct rpc_task *); + +typedef void (*btf_trace_xprt_reserve_cong)(void *, const struct rpc_xprt *, const struct rpc_task *); + +typedef void (*btf_trace_xprt_release_cong)(void *, const struct rpc_xprt *, const struct rpc_task *); + +typedef void (*btf_trace_xprt_get_cong)(void *, const struct rpc_xprt *, const struct rpc_task *); + +typedef void (*btf_trace_xprt_put_cong)(void *, const struct rpc_xprt *, const struct rpc_task *); + +typedef void (*btf_trace_xprt_reserve)(void *, const struct rpc_rqst *); + +typedef void (*btf_trace_xs_stream_read_data)(void *, struct rpc_xprt *, ssize_t, size_t); + +typedef void (*btf_trace_xs_stream_read_request)(void *, struct sock_xprt *); + +typedef void (*btf_trace_rpcb_getport)(void *, const struct rpc_clnt *, const struct rpc_task *, unsigned int); + +typedef void (*btf_trace_rpcb_setport)(void *, const struct rpc_task *, int, short unsigned int); + +typedef void (*btf_trace_pmap_register)(void *, u32, u32, int, short unsigned int); + +typedef void (*btf_trace_rpcb_register)(void *, u32, u32, const char *, const char *); + +typedef void (*btf_trace_rpcb_unregister)(void *, u32, u32, const char *); + +typedef void (*btf_trace_svc_xdr_recvfrom)(void *, const struct svc_rqst *, const struct xdr_buf *); + +typedef void (*btf_trace_svc_xdr_sendto)(void *, const struct svc_rqst *, const struct xdr_buf *); + +typedef void (*btf_trace_svc_recv)(void *, struct svc_rqst *, int); + +typedef void (*btf_trace_svc_authenticate)(void *, const struct svc_rqst *, int, __be32); + +typedef void (*btf_trace_svc_process)(void *, const struct svc_rqst *, const char *); + +typedef void (*btf_trace_svc_defer)(void *, const struct svc_rqst *); + +typedef void (*btf_trace_svc_drop)(void *, const struct svc_rqst *); + +typedef void (*btf_trace_svc_send)(void *, struct svc_rqst *, int); + +typedef void (*btf_trace_svc_xprt_create_err)(void *, const char *, const char *, struct sockaddr *, const struct svc_xprt *); + +typedef void (*btf_trace_svc_xprt_do_enqueue)(void *, struct svc_xprt *, struct svc_rqst *); + +typedef void (*btf_trace_svc_xprt_no_write_space)(void *, struct svc_xprt *); + +typedef void (*btf_trace_svc_xprt_close)(void *, struct svc_xprt *); + +typedef void (*btf_trace_svc_xprt_detach)(void *, struct svc_xprt *); + +typedef void (*btf_trace_svc_xprt_free)(void *, struct svc_xprt *); + +typedef void (*btf_trace_svc_xprt_accept)(void *, const struct svc_xprt *, const char *); + +typedef void (*btf_trace_svc_xprt_dequeue)(void *, struct svc_rqst *); + +typedef void (*btf_trace_svc_wake_up)(void *, int); + +typedef void (*btf_trace_svc_handle_xprt)(void *, struct svc_xprt *, int); + +typedef void (*btf_trace_svc_stats_latency)(void *, const struct svc_rqst *); + +typedef void (*btf_trace_svc_defer_drop)(void *, const struct svc_deferred_req *); + +typedef void (*btf_trace_svc_defer_queue)(void *, const struct svc_deferred_req *); + +typedef void (*btf_trace_svc_defer_recv)(void *, const struct svc_deferred_req *); + +typedef void (*btf_trace_svcsock_new_socket)(void *, const struct socket *); + +typedef void (*btf_trace_svcsock_marker)(void *, const struct svc_xprt *, __be32); + +typedef void (*btf_trace_svcsock_udp_send)(void *, const struct svc_xprt *, ssize_t); + +typedef void (*btf_trace_svcsock_udp_recv)(void *, const struct svc_xprt *, ssize_t); + +typedef void (*btf_trace_svcsock_udp_recv_err)(void *, const struct svc_xprt *, ssize_t); + +typedef void (*btf_trace_svcsock_tcp_send)(void *, const struct svc_xprt *, ssize_t); + +typedef void (*btf_trace_svcsock_tcp_recv)(void *, const struct svc_xprt *, ssize_t); + +typedef void (*btf_trace_svcsock_tcp_recv_eagain)(void *, const struct svc_xprt *, ssize_t); + +typedef void (*btf_trace_svcsock_tcp_recv_err)(void *, const struct svc_xprt *, ssize_t); + +typedef void (*btf_trace_svcsock_data_ready)(void *, const struct svc_xprt *, ssize_t); + +typedef void (*btf_trace_svcsock_write_space)(void *, const struct svc_xprt *, ssize_t); + +typedef void (*btf_trace_svcsock_tcp_recv_short)(void *, const struct svc_xprt *, u32, u32); + +typedef void (*btf_trace_svcsock_tcp_state)(void *, const struct svc_xprt *, const struct socket *); + +typedef void (*btf_trace_svcsock_accept_err)(void *, const struct svc_xprt *, const char *, long int); + +typedef void (*btf_trace_svcsock_getpeername_err)(void *, const struct svc_xprt *, const char *, long int); + +typedef void (*btf_trace_cache_entry_expired)(void *, const struct cache_detail *, const struct cache_head *); + +typedef void (*btf_trace_cache_entry_upcall)(void *, const struct cache_detail *, const struct cache_head *); + +typedef void (*btf_trace_cache_entry_update)(void *, const struct cache_detail *, const struct cache_head *); + +typedef void (*btf_trace_cache_entry_make_negative)(void *, const struct cache_detail *, const struct cache_head *); + +typedef void (*btf_trace_cache_entry_no_listener)(void *, const struct cache_detail *, const struct cache_head *); + +typedef void (*btf_trace_svc_register)(void *, const char *, const u32, const int, const short unsigned int, const short unsigned int, int); + +typedef void (*btf_trace_svc_noregister)(void *, const char *, const u32, const int, const short unsigned int, const short unsigned int, int); + +typedef void (*btf_trace_svc_unregister)(void *, const char *, const u32, int); + +struct rpc_cred_cache { + struct hlist_head *hashtable; + unsigned int hashbits; + spinlock_t lock; +}; + +enum { + SVC_POOL_AUTO = 4294967295, + SVC_POOL_GLOBAL = 0, + SVC_POOL_PERCPU = 1, + SVC_POOL_PERNODE = 2, +}; + +struct svc_pool_map { + int count; + int mode; + unsigned int npools; + unsigned int *pool_to; + unsigned int *to_pool; +}; + +struct unix_domain { + struct auth_domain h; +}; + +struct ip_map { + struct cache_head h; + char m_class[8]; + struct in6_addr m_addr; + struct unix_domain *m_client; + struct callback_head m_rcu; +}; + +struct unix_gid { + struct cache_head h; + kuid_t uid; + struct group_info *gi; + struct callback_head rcu; +}; + +enum { + RPCBPROC_NULL = 0, + RPCBPROC_SET = 1, + RPCBPROC_UNSET = 2, + RPCBPROC_GETPORT = 3, + RPCBPROC_GETADDR = 3, + RPCBPROC_DUMP = 4, + RPCBPROC_CALLIT = 5, + RPCBPROC_BCAST = 5, + RPCBPROC_GETTIME = 6, + RPCBPROC_UADDR2TADDR = 7, + RPCBPROC_TADDR2UADDR = 8, + RPCBPROC_GETVERSADDR = 9, + RPCBPROC_INDIRECT = 10, + RPCBPROC_GETADDRLIST = 11, + RPCBPROC_GETSTAT = 12, +}; + +struct rpcbind_args { + struct rpc_xprt *r_xprt; + u32 r_prog; + u32 r_vers; + u32 r_prot; + short unsigned int r_port; + const char *r_netid; + const char *r_addr; + const char *r_owner; + int r_status; +}; + +struct rpcb_info { + u32 rpc_vers; + const struct rpc_procinfo *rpc_proc; +}; + +struct rpc_inode { + struct inode vfs_inode; + void *private; + struct rpc_pipe *pipe; + wait_queue_head_t waitq; +}; + +struct thread_deferred_req { + struct cache_deferred_req handle; + struct completion completion; +}; + +struct cache_queue { + struct list_head list; + int reader; +}; + +struct cache_request { + struct cache_queue q; + struct cache_head *item; + char *buf; + int len; + int readers; +}; + +struct cache_reader { + struct cache_queue q; + int offset; +}; + +struct rpc_pipe_dir_object_ops; + +struct rpc_pipe_dir_object { + struct list_head pdo_head; + const struct rpc_pipe_dir_object_ops *pdo_ops; + void *pdo_data; +}; + +struct rpc_pipe_dir_object_ops { + int (*create)(struct dentry *, struct rpc_pipe_dir_object *); + void (*destroy)(struct dentry *, struct rpc_pipe_dir_object *); +}; + +struct rpc_filelist { + const char *name; + const struct file_operations *i_fop; + umode_t mode; +}; + +enum { + RPCAUTH_info = 0, + RPCAUTH_EOF = 1, +}; + +enum { + RPCAUTH_lockd = 0, + RPCAUTH_mount = 1, + RPCAUTH_nfs = 2, + RPCAUTH_portmap = 3, + RPCAUTH_statd = 4, + RPCAUTH_nfsd4_cb = 5, + RPCAUTH_cache = 6, + RPCAUTH_nfsd = 7, + RPCAUTH_gssd = 8, + RPCAUTH_RootEOF = 9, +}; + +struct svc_xpt_user { + struct list_head list; + void (*callback)(struct svc_xpt_user *); +}; + +typedef struct rpc_xprt * (*xprt_switch_find_xprt_t)(struct rpc_xprt_switch *, const struct rpc_xprt *); + +struct _strp_msg { + struct strp_msg strp; + int accum_len; +}; + +struct vlan_group { + unsigned int nr_vlan_devs; + struct hlist_node hlist; + struct net_device **vlan_devices_arrays[16]; +}; + +struct vlan_info { + struct net_device *real_dev; + struct vlan_group grp; + struct list_head vid_list; + unsigned int nr_vids; + struct callback_head rcu; +}; + +enum vlan_protos { + VLAN_PROTO_8021Q = 0, + VLAN_PROTO_8021AD = 1, + VLAN_PROTO_NUM = 2, +}; + +struct vlan_vid_info { + struct list_head list; + __be16 proto; + u16 vid; + int refcount; +}; + +enum vlan_ioctl_cmds { + ADD_VLAN_CMD = 0, + DEL_VLAN_CMD = 1, + SET_VLAN_INGRESS_PRIORITY_CMD = 2, + SET_VLAN_EGRESS_PRIORITY_CMD = 3, + GET_VLAN_INGRESS_PRIORITY_CMD = 4, + GET_VLAN_EGRESS_PRIORITY_CMD = 5, + SET_VLAN_NAME_TYPE_CMD = 6, + SET_VLAN_FLAG_CMD = 7, + GET_VLAN_REALDEV_NAME_CMD = 8, + GET_VLAN_VID_CMD = 9, +}; + +enum vlan_name_types { + VLAN_NAME_TYPE_PLUS_VID = 0, + VLAN_NAME_TYPE_RAW_PLUS_VID = 1, + VLAN_NAME_TYPE_PLUS_VID_NO_PAD = 2, + VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD = 3, + VLAN_NAME_TYPE_HIGHEST = 4, +}; + +struct vlan_ioctl_args { + int cmd; + char device1[24]; + union { + char device2[24]; + int VID; + unsigned int skb_priority; + unsigned int name_type; + unsigned int bind_type; + unsigned int flag; + } u; + short int vlan_qos; +}; + +struct vlan_net { + struct proc_dir_entry *proc_vlan_dir; + struct proc_dir_entry *proc_vlan_conf; + short unsigned int name_type; +}; + +enum { + IFLA_VLAN_UNSPEC = 0, + IFLA_VLAN_ID = 1, + IFLA_VLAN_FLAGS = 2, + IFLA_VLAN_EGRESS_QOS = 3, + IFLA_VLAN_INGRESS_QOS = 4, + IFLA_VLAN_PROTOCOL = 5, + __IFLA_VLAN_MAX = 6, +}; + +struct ifla_vlan_flags { + __u32 flags; + __u32 mask; +}; + +enum { + IFLA_VLAN_QOS_UNSPEC = 0, + IFLA_VLAN_QOS_MAPPING = 1, + __IFLA_VLAN_QOS_MAX = 2, +}; + +struct ifla_vlan_qos_mapping { + __u32 from; + __u32 to; +}; + +enum nl80211_commands { + NL80211_CMD_UNSPEC = 0, + NL80211_CMD_GET_WIPHY = 1, + NL80211_CMD_SET_WIPHY = 2, + NL80211_CMD_NEW_WIPHY = 3, + NL80211_CMD_DEL_WIPHY = 4, + NL80211_CMD_GET_INTERFACE = 5, + NL80211_CMD_SET_INTERFACE = 6, + NL80211_CMD_NEW_INTERFACE = 7, + NL80211_CMD_DEL_INTERFACE = 8, + NL80211_CMD_GET_KEY = 9, + NL80211_CMD_SET_KEY = 10, + NL80211_CMD_NEW_KEY = 11, + NL80211_CMD_DEL_KEY = 12, + NL80211_CMD_GET_BEACON = 13, + NL80211_CMD_SET_BEACON = 14, + NL80211_CMD_START_AP = 15, + NL80211_CMD_NEW_BEACON = 15, + NL80211_CMD_STOP_AP = 16, + NL80211_CMD_DEL_BEACON = 16, + NL80211_CMD_GET_STATION = 17, + NL80211_CMD_SET_STATION = 18, + NL80211_CMD_NEW_STATION = 19, + NL80211_CMD_DEL_STATION = 20, + NL80211_CMD_GET_MPATH = 21, + NL80211_CMD_SET_MPATH = 22, + NL80211_CMD_NEW_MPATH = 23, + NL80211_CMD_DEL_MPATH = 24, + NL80211_CMD_SET_BSS = 25, + NL80211_CMD_SET_REG = 26, + NL80211_CMD_REQ_SET_REG = 27, + NL80211_CMD_GET_MESH_CONFIG = 28, + NL80211_CMD_SET_MESH_CONFIG = 29, + NL80211_CMD_SET_MGMT_EXTRA_IE = 30, + NL80211_CMD_GET_REG = 31, + NL80211_CMD_GET_SCAN = 32, + NL80211_CMD_TRIGGER_SCAN = 33, + NL80211_CMD_NEW_SCAN_RESULTS = 34, + NL80211_CMD_SCAN_ABORTED = 35, + NL80211_CMD_REG_CHANGE = 36, + NL80211_CMD_AUTHENTICATE = 37, + NL80211_CMD_ASSOCIATE = 38, + NL80211_CMD_DEAUTHENTICATE = 39, + NL80211_CMD_DISASSOCIATE = 40, + NL80211_CMD_MICHAEL_MIC_FAILURE = 41, + NL80211_CMD_REG_BEACON_HINT = 42, + NL80211_CMD_JOIN_IBSS = 43, + NL80211_CMD_LEAVE_IBSS = 44, + NL80211_CMD_TESTMODE = 45, + NL80211_CMD_CONNECT = 46, + NL80211_CMD_ROAM = 47, + NL80211_CMD_DISCONNECT = 48, + NL80211_CMD_SET_WIPHY_NETNS = 49, + NL80211_CMD_GET_SURVEY = 50, + NL80211_CMD_NEW_SURVEY_RESULTS = 51, + NL80211_CMD_SET_PMKSA = 52, + NL80211_CMD_DEL_PMKSA = 53, + NL80211_CMD_FLUSH_PMKSA = 54, + NL80211_CMD_REMAIN_ON_CHANNEL = 55, + NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL = 56, + NL80211_CMD_SET_TX_BITRATE_MASK = 57, + NL80211_CMD_REGISTER_FRAME = 58, + NL80211_CMD_REGISTER_ACTION = 58, + NL80211_CMD_FRAME = 59, + NL80211_CMD_ACTION = 59, + NL80211_CMD_FRAME_TX_STATUS = 60, + NL80211_CMD_ACTION_TX_STATUS = 60, + NL80211_CMD_SET_POWER_SAVE = 61, + NL80211_CMD_GET_POWER_SAVE = 62, + NL80211_CMD_SET_CQM = 63, + NL80211_CMD_NOTIFY_CQM = 64, + NL80211_CMD_SET_CHANNEL = 65, + NL80211_CMD_SET_WDS_PEER = 66, + NL80211_CMD_FRAME_WAIT_CANCEL = 67, + NL80211_CMD_JOIN_MESH = 68, + NL80211_CMD_LEAVE_MESH = 69, + NL80211_CMD_UNPROT_DEAUTHENTICATE = 70, + NL80211_CMD_UNPROT_DISASSOCIATE = 71, + NL80211_CMD_NEW_PEER_CANDIDATE = 72, + NL80211_CMD_GET_WOWLAN = 73, + NL80211_CMD_SET_WOWLAN = 74, + NL80211_CMD_START_SCHED_SCAN = 75, + NL80211_CMD_STOP_SCHED_SCAN = 76, + NL80211_CMD_SCHED_SCAN_RESULTS = 77, + NL80211_CMD_SCHED_SCAN_STOPPED = 78, + NL80211_CMD_SET_REKEY_OFFLOAD = 79, + NL80211_CMD_PMKSA_CANDIDATE = 80, + NL80211_CMD_TDLS_OPER = 81, + NL80211_CMD_TDLS_MGMT = 82, + NL80211_CMD_UNEXPECTED_FRAME = 83, + NL80211_CMD_PROBE_CLIENT = 84, + NL80211_CMD_REGISTER_BEACONS = 85, + NL80211_CMD_UNEXPECTED_4ADDR_FRAME = 86, + NL80211_CMD_SET_NOACK_MAP = 87, + NL80211_CMD_CH_SWITCH_NOTIFY = 88, + NL80211_CMD_START_P2P_DEVICE = 89, + NL80211_CMD_STOP_P2P_DEVICE = 90, + NL80211_CMD_CONN_FAILED = 91, + NL80211_CMD_SET_MCAST_RATE = 92, + NL80211_CMD_SET_MAC_ACL = 93, + NL80211_CMD_RADAR_DETECT = 94, + NL80211_CMD_GET_PROTOCOL_FEATURES = 95, + NL80211_CMD_UPDATE_FT_IES = 96, + NL80211_CMD_FT_EVENT = 97, + NL80211_CMD_CRIT_PROTOCOL_START = 98, + NL80211_CMD_CRIT_PROTOCOL_STOP = 99, + NL80211_CMD_GET_COALESCE = 100, + NL80211_CMD_SET_COALESCE = 101, + NL80211_CMD_CHANNEL_SWITCH = 102, + NL80211_CMD_VENDOR = 103, + NL80211_CMD_SET_QOS_MAP = 104, + NL80211_CMD_ADD_TX_TS = 105, + NL80211_CMD_DEL_TX_TS = 106, + NL80211_CMD_GET_MPP = 107, + NL80211_CMD_JOIN_OCB = 108, + NL80211_CMD_LEAVE_OCB = 109, + NL80211_CMD_CH_SWITCH_STARTED_NOTIFY = 110, + NL80211_CMD_TDLS_CHANNEL_SWITCH = 111, + NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH = 112, + NL80211_CMD_WIPHY_REG_CHANGE = 113, + NL80211_CMD_ABORT_SCAN = 114, + NL80211_CMD_START_NAN = 115, + NL80211_CMD_STOP_NAN = 116, + NL80211_CMD_ADD_NAN_FUNCTION = 117, + NL80211_CMD_DEL_NAN_FUNCTION = 118, + NL80211_CMD_CHANGE_NAN_CONFIG = 119, + NL80211_CMD_NAN_MATCH = 120, + NL80211_CMD_SET_MULTICAST_TO_UNICAST = 121, + NL80211_CMD_UPDATE_CONNECT_PARAMS = 122, + NL80211_CMD_SET_PMK = 123, + NL80211_CMD_DEL_PMK = 124, + NL80211_CMD_PORT_AUTHORIZED = 125, + NL80211_CMD_RELOAD_REGDB = 126, + NL80211_CMD_EXTERNAL_AUTH = 127, + NL80211_CMD_STA_OPMODE_CHANGED = 128, + NL80211_CMD_CONTROL_PORT_FRAME = 129, + NL80211_CMD_GET_FTM_RESPONDER_STATS = 130, + NL80211_CMD_PEER_MEASUREMENT_START = 131, + NL80211_CMD_PEER_MEASUREMENT_RESULT = 132, + NL80211_CMD_PEER_MEASUREMENT_COMPLETE = 133, + NL80211_CMD_NOTIFY_RADAR = 134, + NL80211_CMD_UPDATE_OWE_INFO = 135, + NL80211_CMD_PROBE_MESH_LINK = 136, + NL80211_CMD_SET_TID_CONFIG = 137, + NL80211_CMD_UNPROT_BEACON = 138, + NL80211_CMD_CONTROL_PORT_FRAME_TX_STATUS = 139, + __NL80211_CMD_AFTER_LAST = 140, + NL80211_CMD_MAX = 139, +}; + +enum nl80211_iftype { + NL80211_IFTYPE_UNSPECIFIED = 0, + NL80211_IFTYPE_ADHOC = 1, + NL80211_IFTYPE_STATION = 2, + NL80211_IFTYPE_AP = 3, + NL80211_IFTYPE_AP_VLAN = 4, + NL80211_IFTYPE_WDS = 5, + NL80211_IFTYPE_MONITOR = 6, + NL80211_IFTYPE_MESH_POINT = 7, + NL80211_IFTYPE_P2P_CLIENT = 8, + NL80211_IFTYPE_P2P_GO = 9, + NL80211_IFTYPE_P2P_DEVICE = 10, + NL80211_IFTYPE_OCB = 11, + NL80211_IFTYPE_NAN = 12, + NUM_NL80211_IFTYPES = 13, + NL80211_IFTYPE_MAX = 12, +}; + +struct nl80211_sta_flag_update { + __u32 mask; + __u32 set; +}; + +enum nl80211_he_gi { + NL80211_RATE_INFO_HE_GI_0_8 = 0, + NL80211_RATE_INFO_HE_GI_1_6 = 1, + NL80211_RATE_INFO_HE_GI_3_2 = 2, +}; + +enum nl80211_he_ltf { + NL80211_RATE_INFO_HE_1XLTF = 0, + NL80211_RATE_INFO_HE_2XLTF = 1, + NL80211_RATE_INFO_HE_4XLTF = 2, +}; + +enum nl80211_reg_initiator { + NL80211_REGDOM_SET_BY_CORE = 0, + NL80211_REGDOM_SET_BY_USER = 1, + NL80211_REGDOM_SET_BY_DRIVER = 2, + NL80211_REGDOM_SET_BY_COUNTRY_IE = 3, +}; + +enum nl80211_dfs_regions { + NL80211_DFS_UNSET = 0, + NL80211_DFS_FCC = 1, + NL80211_DFS_ETSI = 2, + NL80211_DFS_JP = 3, +}; + +enum nl80211_user_reg_hint_type { + NL80211_USER_REG_HINT_USER = 0, + NL80211_USER_REG_HINT_CELL_BASE = 1, + NL80211_USER_REG_HINT_INDOOR = 2, +}; + +enum nl80211_mntr_flags { + __NL80211_MNTR_FLAG_INVALID = 0, + NL80211_MNTR_FLAG_FCSFAIL = 1, + NL80211_MNTR_FLAG_PLCPFAIL = 2, + NL80211_MNTR_FLAG_CONTROL = 3, + NL80211_MNTR_FLAG_OTHER_BSS = 4, + NL80211_MNTR_FLAG_COOK_FRAMES = 5, + NL80211_MNTR_FLAG_ACTIVE = 6, + __NL80211_MNTR_FLAG_AFTER_LAST = 7, + NL80211_MNTR_FLAG_MAX = 6, +}; + +enum nl80211_mesh_power_mode { + NL80211_MESH_POWER_UNKNOWN = 0, + NL80211_MESH_POWER_ACTIVE = 1, + NL80211_MESH_POWER_LIGHT_SLEEP = 2, + NL80211_MESH_POWER_DEEP_SLEEP = 3, + __NL80211_MESH_POWER_AFTER_LAST = 4, + NL80211_MESH_POWER_MAX = 3, +}; + +enum nl80211_ac { + NL80211_AC_VO = 0, + NL80211_AC_VI = 1, + NL80211_AC_BE = 2, + NL80211_AC_BK = 3, + NL80211_NUM_ACS = 4, +}; + +enum nl80211_key_mode { + NL80211_KEY_RX_TX = 0, + NL80211_KEY_NO_TX = 1, + NL80211_KEY_SET_TX = 2, +}; + +enum nl80211_chan_width { + NL80211_CHAN_WIDTH_20_NOHT = 0, + NL80211_CHAN_WIDTH_20 = 1, + NL80211_CHAN_WIDTH_40 = 2, + NL80211_CHAN_WIDTH_80 = 3, + NL80211_CHAN_WIDTH_80P80 = 4, + NL80211_CHAN_WIDTH_160 = 5, + NL80211_CHAN_WIDTH_5 = 6, + NL80211_CHAN_WIDTH_10 = 7, + NL80211_CHAN_WIDTH_1 = 8, + NL80211_CHAN_WIDTH_2 = 9, + NL80211_CHAN_WIDTH_4 = 10, + NL80211_CHAN_WIDTH_8 = 11, + NL80211_CHAN_WIDTH_16 = 12, +}; + +enum nl80211_bss_scan_width { + NL80211_BSS_CHAN_WIDTH_20 = 0, + NL80211_BSS_CHAN_WIDTH_10 = 1, + NL80211_BSS_CHAN_WIDTH_5 = 2, + NL80211_BSS_CHAN_WIDTH_1 = 3, + NL80211_BSS_CHAN_WIDTH_2 = 4, +}; + +enum nl80211_auth_type { + NL80211_AUTHTYPE_OPEN_SYSTEM = 0, + NL80211_AUTHTYPE_SHARED_KEY = 1, + NL80211_AUTHTYPE_FT = 2, + NL80211_AUTHTYPE_NETWORK_EAP = 3, + NL80211_AUTHTYPE_SAE = 4, + NL80211_AUTHTYPE_FILS_SK = 5, + NL80211_AUTHTYPE_FILS_SK_PFS = 6, + NL80211_AUTHTYPE_FILS_PK = 7, + __NL80211_AUTHTYPE_NUM = 8, + NL80211_AUTHTYPE_MAX = 7, + NL80211_AUTHTYPE_AUTOMATIC = 8, +}; + +enum nl80211_mfp { + NL80211_MFP_NO = 0, + NL80211_MFP_REQUIRED = 1, + NL80211_MFP_OPTIONAL = 2, +}; + +enum nl80211_txrate_gi { + NL80211_TXRATE_DEFAULT_GI = 0, + NL80211_TXRATE_FORCE_SGI = 1, + NL80211_TXRATE_FORCE_LGI = 2, +}; + +enum nl80211_band { + NL80211_BAND_2GHZ = 0, + NL80211_BAND_5GHZ = 1, + NL80211_BAND_60GHZ = 2, + NL80211_BAND_6GHZ = 3, + NL80211_BAND_S1GHZ = 4, + NUM_NL80211_BANDS = 5, +}; + +enum nl80211_tx_power_setting { + NL80211_TX_POWER_AUTOMATIC = 0, + NL80211_TX_POWER_LIMITED = 1, + NL80211_TX_POWER_FIXED = 2, +}; + +enum nl80211_tid_config { + NL80211_TID_CONFIG_ENABLE = 0, + NL80211_TID_CONFIG_DISABLE = 1, +}; + +enum nl80211_tx_rate_setting { + NL80211_TX_RATE_AUTOMATIC = 0, + NL80211_TX_RATE_LIMITED = 1, + NL80211_TX_RATE_FIXED = 2, +}; + +struct nl80211_wowlan_tcp_data_seq { + __u32 start; + __u32 offset; + __u32 len; +}; + +struct nl80211_wowlan_tcp_data_token { + __u32 offset; + __u32 len; + __u8 token_stream[0]; +}; + +struct nl80211_wowlan_tcp_data_token_feature { + __u32 min_len; + __u32 max_len; + __u32 bufsize; +}; + +enum nl80211_coalesce_condition { + NL80211_COALESCE_CONDITION_MATCH = 0, + NL80211_COALESCE_CONDITION_NO_MATCH = 1, +}; + +enum nl80211_hidden_ssid { + NL80211_HIDDEN_SSID_NOT_IN_USE = 0, + NL80211_HIDDEN_SSID_ZERO_LEN = 1, + NL80211_HIDDEN_SSID_ZERO_CONTENTS = 2, +}; + +enum nl80211_tdls_operation { + NL80211_TDLS_DISCOVERY_REQ = 0, + NL80211_TDLS_SETUP = 1, + NL80211_TDLS_TEARDOWN = 2, + NL80211_TDLS_ENABLE_LINK = 3, + NL80211_TDLS_DISABLE_LINK = 4, +}; + +enum nl80211_feature_flags { + NL80211_FEATURE_SK_TX_STATUS = 1, + NL80211_FEATURE_HT_IBSS = 2, + NL80211_FEATURE_INACTIVITY_TIMER = 4, + NL80211_FEATURE_CELL_BASE_REG_HINTS = 8, + NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL = 16, + NL80211_FEATURE_SAE = 32, + NL80211_FEATURE_LOW_PRIORITY_SCAN = 64, + NL80211_FEATURE_SCAN_FLUSH = 128, + NL80211_FEATURE_AP_SCAN = 256, + NL80211_FEATURE_VIF_TXPOWER = 512, + NL80211_FEATURE_NEED_OBSS_SCAN = 1024, + NL80211_FEATURE_P2P_GO_CTWIN = 2048, + NL80211_FEATURE_P2P_GO_OPPPS = 4096, + NL80211_FEATURE_ADVERTISE_CHAN_LIMITS = 16384, + NL80211_FEATURE_FULL_AP_CLIENT_STATE = 32768, + NL80211_FEATURE_USERSPACE_MPM = 65536, + NL80211_FEATURE_ACTIVE_MONITOR = 131072, + NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE = 262144, + NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES = 524288, + NL80211_FEATURE_WFA_TPC_IE_IN_PROBES = 1048576, + NL80211_FEATURE_QUIET = 2097152, + NL80211_FEATURE_TX_POWER_INSERTION = 4194304, + NL80211_FEATURE_ACKTO_ESTIMATION = 8388608, + NL80211_FEATURE_STATIC_SMPS = 16777216, + NL80211_FEATURE_DYNAMIC_SMPS = 33554432, + NL80211_FEATURE_SUPPORTS_WMM_ADMISSION = 67108864, + NL80211_FEATURE_MAC_ON_CREATE = 134217728, + NL80211_FEATURE_TDLS_CHANNEL_SWITCH = 268435456, + NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR = 536870912, + NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR = 1073741824, + NL80211_FEATURE_ND_RANDOM_MAC_ADDR = 2147483648, +}; + +enum nl80211_ext_feature_index { + NL80211_EXT_FEATURE_VHT_IBSS = 0, + NL80211_EXT_FEATURE_RRM = 1, + NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER = 2, + NL80211_EXT_FEATURE_SCAN_START_TIME = 3, + NL80211_EXT_FEATURE_BSS_PARENT_TSF = 4, + NL80211_EXT_FEATURE_SET_SCAN_DWELL = 5, + NL80211_EXT_FEATURE_BEACON_RATE_LEGACY = 6, + NL80211_EXT_FEATURE_BEACON_RATE_HT = 7, + NL80211_EXT_FEATURE_BEACON_RATE_VHT = 8, + NL80211_EXT_FEATURE_FILS_STA = 9, + NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA = 10, + NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED = 11, + NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI = 12, + NL80211_EXT_FEATURE_CQM_RSSI_LIST = 13, + NL80211_EXT_FEATURE_FILS_SK_OFFLOAD = 14, + NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK = 15, + NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_1X = 16, + NL80211_EXT_FEATURE_FILS_MAX_CHANNEL_TIME = 17, + NL80211_EXT_FEATURE_ACCEPT_BCAST_PROBE_RESP = 18, + NL80211_EXT_FEATURE_OCE_PROBE_REQ_HIGH_TX_RATE = 19, + NL80211_EXT_FEATURE_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION = 20, + NL80211_EXT_FEATURE_MFP_OPTIONAL = 21, + NL80211_EXT_FEATURE_LOW_SPAN_SCAN = 22, + NL80211_EXT_FEATURE_LOW_POWER_SCAN = 23, + NL80211_EXT_FEATURE_HIGH_ACCURACY_SCAN = 24, + NL80211_EXT_FEATURE_DFS_OFFLOAD = 25, + NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211 = 26, + NL80211_EXT_FEATURE_ACK_SIGNAL_SUPPORT = 27, + NL80211_EXT_FEATURE_DATA_ACK_SIGNAL_SUPPORT = 27, + NL80211_EXT_FEATURE_TXQS = 28, + NL80211_EXT_FEATURE_SCAN_RANDOM_SN = 29, + NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT = 30, + NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 = 31, + NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER = 32, + NL80211_EXT_FEATURE_AIRTIME_FAIRNESS = 33, + NL80211_EXT_FEATURE_AP_PMKSA_CACHING = 34, + NL80211_EXT_FEATURE_SCHED_SCAN_BAND_SPECIFIC_RSSI_THOLD = 35, + NL80211_EXT_FEATURE_EXT_KEY_ID = 36, + NL80211_EXT_FEATURE_STA_TX_PWR = 37, + NL80211_EXT_FEATURE_SAE_OFFLOAD = 38, + NL80211_EXT_FEATURE_VLAN_OFFLOAD = 39, + NL80211_EXT_FEATURE_AQL = 40, + NL80211_EXT_FEATURE_BEACON_PROTECTION = 41, + NL80211_EXT_FEATURE_CONTROL_PORT_NO_PREAUTH = 42, + NL80211_EXT_FEATURE_PROTECTED_TWT = 43, + NL80211_EXT_FEATURE_DEL_IBSS_STA = 44, + NL80211_EXT_FEATURE_MULTICAST_REGISTRATIONS = 45, + NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT = 46, + NL80211_EXT_FEATURE_SCAN_FREQ_KHZ = 47, + NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211_TX_STATUS = 48, + NL80211_EXT_FEATURE_OPERATING_CHANNEL_VALIDATION = 49, + NL80211_EXT_FEATURE_4WAY_HANDSHAKE_AP_PSK = 50, + NL80211_EXT_FEATURE_SAE_OFFLOAD_AP = 51, + NL80211_EXT_FEATURE_FILS_DISCOVERY = 52, + NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP = 53, + NL80211_EXT_FEATURE_BEACON_RATE_HE = 54, + NUM_NL80211_EXT_FEATURES = 55, + MAX_NL80211_EXT_FEATURES = 54, +}; + +enum nl80211_timeout_reason { + NL80211_TIMEOUT_UNSPECIFIED = 0, + NL80211_TIMEOUT_SCAN = 1, + NL80211_TIMEOUT_AUTH = 2, + NL80211_TIMEOUT_ASSOC = 3, +}; + +enum nl80211_acl_policy { + NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED = 0, + NL80211_ACL_POLICY_DENY_UNLESS_LISTED = 1, +}; + +enum nl80211_smps_mode { + NL80211_SMPS_OFF = 0, + NL80211_SMPS_STATIC = 1, + NL80211_SMPS_DYNAMIC = 2, + __NL80211_SMPS_AFTER_LAST = 3, + NL80211_SMPS_MAX = 2, +}; + +enum nl80211_radar_event { + NL80211_RADAR_DETECTED = 0, + NL80211_RADAR_CAC_FINISHED = 1, + NL80211_RADAR_CAC_ABORTED = 2, + NL80211_RADAR_NOP_FINISHED = 3, + NL80211_RADAR_PRE_CAC_EXPIRED = 4, + NL80211_RADAR_CAC_STARTED = 5, +}; + +enum nl80211_dfs_state { + NL80211_DFS_USABLE = 0, + NL80211_DFS_UNAVAILABLE = 1, + NL80211_DFS_AVAILABLE = 2, +}; + +enum nl80211_crit_proto_id { + NL80211_CRIT_PROTO_UNSPEC = 0, + NL80211_CRIT_PROTO_DHCP = 1, + NL80211_CRIT_PROTO_EAPOL = 2, + NL80211_CRIT_PROTO_APIPA = 3, + NUM_NL80211_CRIT_PROTO = 4, +}; + +struct nl80211_vendor_cmd_info { + __u32 vendor_id; + __u32 subcmd; +}; + +enum nl80211_bss_select_attr { + __NL80211_BSS_SELECT_ATTR_INVALID = 0, + NL80211_BSS_SELECT_ATTR_RSSI = 1, + NL80211_BSS_SELECT_ATTR_BAND_PREF = 2, + NL80211_BSS_SELECT_ATTR_RSSI_ADJUST = 3, + __NL80211_BSS_SELECT_ATTR_AFTER_LAST = 4, + NL80211_BSS_SELECT_ATTR_MAX = 3, +}; + +enum nl80211_nan_function_type { + NL80211_NAN_FUNC_PUBLISH = 0, + NL80211_NAN_FUNC_SUBSCRIBE = 1, + NL80211_NAN_FUNC_FOLLOW_UP = 2, + __NL80211_NAN_FUNC_TYPE_AFTER_LAST = 3, + NL80211_NAN_FUNC_MAX_TYPE = 2, +}; + +enum nl80211_external_auth_action { + NL80211_EXTERNAL_AUTH_START = 0, + NL80211_EXTERNAL_AUTH_ABORT = 1, +}; + +enum nl80211_preamble { + NL80211_PREAMBLE_LEGACY = 0, + NL80211_PREAMBLE_HT = 1, + NL80211_PREAMBLE_VHT = 2, + NL80211_PREAMBLE_DMG = 3, + NL80211_PREAMBLE_HE = 4, +}; + +enum nl80211_sae_pwe_mechanism { + NL80211_SAE_PWE_UNSPECIFIED = 0, + NL80211_SAE_PWE_HUNT_AND_PECK = 1, + NL80211_SAE_PWE_HASH_TO_ELEMENT = 2, + NL80211_SAE_PWE_BOTH = 3, +}; + +enum ieee80211_bss_type { + IEEE80211_BSS_TYPE_ESS = 0, + IEEE80211_BSS_TYPE_PBSS = 1, + IEEE80211_BSS_TYPE_IBSS = 2, + IEEE80211_BSS_TYPE_MBSS = 3, + IEEE80211_BSS_TYPE_ANY = 4, +}; + +enum ieee80211_edmg_bw_config { + IEEE80211_EDMG_BW_CONFIG_4 = 4, + IEEE80211_EDMG_BW_CONFIG_5 = 5, + IEEE80211_EDMG_BW_CONFIG_6 = 6, + IEEE80211_EDMG_BW_CONFIG_7 = 7, + IEEE80211_EDMG_BW_CONFIG_8 = 8, + IEEE80211_EDMG_BW_CONFIG_9 = 9, + IEEE80211_EDMG_BW_CONFIG_10 = 10, + IEEE80211_EDMG_BW_CONFIG_11 = 11, + IEEE80211_EDMG_BW_CONFIG_12 = 12, + IEEE80211_EDMG_BW_CONFIG_13 = 13, + IEEE80211_EDMG_BW_CONFIG_14 = 14, + IEEE80211_EDMG_BW_CONFIG_15 = 15, +}; + +struct ieee80211_edmg { + u8 channels; + enum ieee80211_edmg_bw_config bw_config; +}; + +struct ieee80211_channel; + +struct cfg80211_chan_def { + struct ieee80211_channel *chan; + enum nl80211_chan_width width; + u32 center_freq1; + u32 center_freq2; + struct ieee80211_edmg edmg; + u16 freq1_offset; +}; + +struct wiphy; + +struct cfg80211_conn; + +struct cfg80211_cached_keys; + +struct cfg80211_internal_bss; + +struct cfg80211_cqm_config; + +struct wireless_dev { + struct wiphy *wiphy; + enum nl80211_iftype iftype; + struct list_head list; + struct net_device *netdev; + u32 identifier; + struct list_head mgmt_registrations; + spinlock_t mgmt_registrations_lock; + u8 mgmt_registrations_need_update: 1; + struct mutex mtx; + bool use_4addr; + bool is_running; + u8 address[6]; + u8 ssid[32]; + u8 ssid_len; + u8 mesh_id_len; + u8 mesh_id_up_len; + struct cfg80211_conn *conn; + struct cfg80211_cached_keys *connect_keys; + enum ieee80211_bss_type conn_bss_type; + u32 conn_owner_nlportid; + struct work_struct disconnect_wk; + u8 disconnect_bssid[6]; + struct list_head event_list; + spinlock_t event_lock; + struct cfg80211_internal_bss *current_bss; + struct cfg80211_chan_def preset_chandef; + struct cfg80211_chan_def chandef; + bool ibss_fixed; + bool ibss_dfs_possible; + bool ps; + int ps_timeout; + int beacon_interval; + u32 ap_unexpected_nlportid; + u32 owner_nlportid; + bool nl_owner_dead; + bool cac_started; + long unsigned int cac_start_time; + unsigned int cac_time_ms; + struct cfg80211_cqm_config *cqm_config; + struct list_head pmsr_list; + spinlock_t pmsr_lock; + struct work_struct pmsr_free_wk; + long unsigned int unprot_beacon_reported; +}; + +struct ieee80211_s1g_cap { + u8 capab_info[10]; + u8 supp_mcs_nss[5]; +}; + +struct ieee80211_mcs_info { + u8 rx_mask[10]; + __le16 rx_highest; + u8 tx_params; + u8 reserved[3]; +}; + +struct ieee80211_ht_cap { + __le16 cap_info; + u8 ampdu_params_info; + struct ieee80211_mcs_info mcs; + __le16 extended_ht_cap_info; + __le32 tx_BF_cap_info; + u8 antenna_selection_info; +} __attribute__((packed)); + +struct ieee80211_vht_mcs_info { + __le16 rx_mcs_map; + __le16 rx_highest; + __le16 tx_mcs_map; + __le16 tx_highest; +}; + +struct ieee80211_vht_cap { + __le32 vht_cap_info; + struct ieee80211_vht_mcs_info supp_mcs; +}; + +struct ieee80211_he_cap_elem { + u8 mac_cap_info[6]; + u8 phy_cap_info[11]; +}; + +struct ieee80211_he_mcs_nss_supp { + __le16 rx_mcs_80; + __le16 tx_mcs_80; + __le16 rx_mcs_160; + __le16 tx_mcs_160; + __le16 rx_mcs_80p80; + __le16 tx_mcs_80p80; +}; + +struct ieee80211_he_operation { + __le32 he_oper_params; + __le16 he_mcs_nss_set; + u8 optional[0]; +} __attribute__((packed)); + +enum ieee80211_reasoncode { + WLAN_REASON_UNSPECIFIED = 1, + WLAN_REASON_PREV_AUTH_NOT_VALID = 2, + WLAN_REASON_DEAUTH_LEAVING = 3, + WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, + WLAN_REASON_DISASSOC_AP_BUSY = 5, + WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, + WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, + WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, + WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, + WLAN_REASON_DISASSOC_BAD_POWER = 10, + WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, + WLAN_REASON_INVALID_IE = 13, + WLAN_REASON_MIC_FAILURE = 14, + WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, + WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, + WLAN_REASON_IE_DIFFERENT = 17, + WLAN_REASON_INVALID_GROUP_CIPHER = 18, + WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, + WLAN_REASON_INVALID_AKMP = 20, + WLAN_REASON_UNSUPP_RSN_VERSION = 21, + WLAN_REASON_INVALID_RSN_IE_CAP = 22, + WLAN_REASON_IEEE8021X_FAILED = 23, + WLAN_REASON_CIPHER_SUITE_REJECTED = 24, + WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE = 25, + WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED = 26, + WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32, + WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33, + WLAN_REASON_DISASSOC_LOW_ACK = 34, + WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35, + WLAN_REASON_QSTA_LEAVE_QBSS = 36, + WLAN_REASON_QSTA_NOT_USE = 37, + WLAN_REASON_QSTA_REQUIRE_SETUP = 38, + WLAN_REASON_QSTA_TIMEOUT = 39, + WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45, + WLAN_REASON_MESH_PEER_CANCELED = 52, + WLAN_REASON_MESH_MAX_PEERS = 53, + WLAN_REASON_MESH_CONFIG = 54, + WLAN_REASON_MESH_CLOSE = 55, + WLAN_REASON_MESH_MAX_RETRIES = 56, + WLAN_REASON_MESH_CONFIRM_TIMEOUT = 57, + WLAN_REASON_MESH_INVALID_GTK = 58, + WLAN_REASON_MESH_INCONSISTENT_PARAM = 59, + WLAN_REASON_MESH_INVALID_SECURITY = 60, + WLAN_REASON_MESH_PATH_ERROR = 61, + WLAN_REASON_MESH_PATH_NOFORWARD = 62, + WLAN_REASON_MESH_PATH_DEST_UNREACHABLE = 63, + WLAN_REASON_MAC_EXISTS_IN_MBSS = 64, + WLAN_REASON_MESH_CHAN_REGULATORY = 65, + WLAN_REASON_MESH_CHAN = 66, +}; + +enum ieee80211_key_len { + WLAN_KEY_LEN_WEP40 = 5, + WLAN_KEY_LEN_WEP104 = 13, + WLAN_KEY_LEN_CCMP = 16, + WLAN_KEY_LEN_CCMP_256 = 32, + WLAN_KEY_LEN_TKIP = 32, + WLAN_KEY_LEN_AES_CMAC = 16, + WLAN_KEY_LEN_SMS4 = 32, + WLAN_KEY_LEN_GCMP = 16, + WLAN_KEY_LEN_GCMP_256 = 32, + WLAN_KEY_LEN_BIP_CMAC_256 = 32, + WLAN_KEY_LEN_BIP_GMAC_128 = 16, + WLAN_KEY_LEN_BIP_GMAC_256 = 32, +}; + +struct ieee80211_he_6ghz_capa { + __le16 capa; +}; + +enum environment_cap { + ENVIRON_ANY = 0, + ENVIRON_INDOOR = 1, + ENVIRON_OUTDOOR = 2, +}; + +struct regulatory_request { + struct callback_head callback_head; + int wiphy_idx; + enum nl80211_reg_initiator initiator; + enum nl80211_user_reg_hint_type user_reg_hint_type; + char alpha2[3]; + enum nl80211_dfs_regions dfs_region; + bool intersect; + bool processed; + enum environment_cap country_ie_env; + struct list_head list; +}; + +enum ieee80211_regulatory_flags { + REGULATORY_CUSTOM_REG = 1, + REGULATORY_STRICT_REG = 2, + REGULATORY_DISABLE_BEACON_HINTS = 4, + REGULATORY_COUNTRY_IE_FOLLOW_POWER = 8, + REGULATORY_COUNTRY_IE_IGNORE = 16, + REGULATORY_ENABLE_RELAX_NO_IR = 32, + REGULATORY_IGNORE_STALE_KICKOFF = 64, + REGULATORY_WIPHY_SELF_MANAGED = 128, +}; + +struct ieee80211_freq_range { + u32 start_freq_khz; + u32 end_freq_khz; + u32 max_bandwidth_khz; +}; + +struct ieee80211_power_rule { + u32 max_antenna_gain; + u32 max_eirp; +}; + +struct ieee80211_wmm_ac { + u16 cw_min; + u16 cw_max; + u16 cot; + u8 aifsn; +}; + +struct ieee80211_wmm_rule { + struct ieee80211_wmm_ac client[4]; + struct ieee80211_wmm_ac ap[4]; +}; + +struct ieee80211_reg_rule { + struct ieee80211_freq_range freq_range; + struct ieee80211_power_rule power_rule; + struct ieee80211_wmm_rule wmm_rule; + u32 flags; + u32 dfs_cac_ms; + bool has_wmm; +}; + +struct ieee80211_regdomain { + struct callback_head callback_head; + u32 n_reg_rules; + char alpha2[3]; + enum nl80211_dfs_regions dfs_region; + struct ieee80211_reg_rule reg_rules[0]; +}; + +struct ieee80211_channel { + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + u16 hw_value; + u32 flags; + int max_antenna_gain; + int max_power; + int max_reg_power; + bool beacon_found; + u32 orig_flags; + int orig_mag; + int orig_mpwr; + enum nl80211_dfs_state dfs_state; + long unsigned int dfs_state_entered; + unsigned int dfs_cac_ms; +}; + +struct ieee80211_rate { + u32 flags; + u16 bitrate; + u16 hw_value; + u16 hw_value_short; +}; + +struct ieee80211_he_obss_pd { + bool enable; + u8 sr_ctrl; + u8 non_srg_max_offset; + u8 min_offset; + u8 max_offset; + u8 bss_color_bitmap[8]; + u8 partial_bssid_bitmap[8]; +}; + +struct cfg80211_he_bss_color { + u8 color; + bool enabled; + bool partial; +}; + +struct ieee80211_sta_ht_cap { + u16 cap; + bool ht_supported; + u8 ampdu_factor; + u8 ampdu_density; + struct ieee80211_mcs_info mcs; + char: 8; +} __attribute__((packed)); + +struct ieee80211_sta_vht_cap { + bool vht_supported; + u32 cap; + struct ieee80211_vht_mcs_info vht_mcs; +}; + +struct ieee80211_sta_he_cap { + bool has_he; + struct ieee80211_he_cap_elem he_cap_elem; + struct ieee80211_he_mcs_nss_supp he_mcs_nss_supp; + u8 ppe_thres[25]; +} __attribute__((packed)); + +struct ieee80211_sband_iftype_data { + u16 types_mask; + struct ieee80211_sta_he_cap he_cap; + struct ieee80211_he_6ghz_capa he_6ghz_capa; + char: 8; +} __attribute__((packed)); + +struct ieee80211_sta_s1g_cap { + bool s1g; + u8 cap[10]; + u8 nss_mcs[5]; +}; + +struct ieee80211_supported_band { + struct ieee80211_channel *channels; + struct ieee80211_rate *bitrates; + enum nl80211_band band; + int n_channels; + int n_bitrates; + struct ieee80211_sta_ht_cap ht_cap; + struct ieee80211_sta_vht_cap vht_cap; + struct ieee80211_sta_s1g_cap s1g_cap; + struct ieee80211_edmg edmg_cap; + u16 n_iftype_data; + const struct ieee80211_sband_iftype_data *iftype_data; +}; + +struct vif_params { + u32 flags; + int use_4addr; + u8 macaddr[6]; + const u8 *vht_mumimo_groups; + const u8 *vht_mumimo_follow_addr; +}; + +struct key_params { + const u8 *key; + const u8 *seq; + int key_len; + int seq_len; + u16 vlan_id; + u32 cipher; + enum nl80211_key_mode mode; +}; + +struct cfg80211_bitrate_mask { + struct { + u32 legacy; + u8 ht_mcs[10]; + u16 vht_mcs[8]; + u16 he_mcs[8]; + enum nl80211_txrate_gi gi; + enum nl80211_he_gi he_gi; + enum nl80211_he_ltf he_ltf; + } control[5]; +}; + +struct cfg80211_tid_cfg { + bool config_override; + u8 tids; + u64 mask; + enum nl80211_tid_config noack; + u8 retry_long; + u8 retry_short; + enum nl80211_tid_config ampdu; + enum nl80211_tid_config rtscts; + enum nl80211_tid_config amsdu; + enum nl80211_tx_rate_setting txrate_type; + struct cfg80211_bitrate_mask txrate_mask; +}; + +struct cfg80211_tid_config { + const u8 *peer; + u32 n_tid_conf; + struct cfg80211_tid_cfg tid_conf[0]; +}; + +struct survey_info { + struct ieee80211_channel *channel; + u64 time; + u64 time_busy; + u64 time_ext_busy; + u64 time_rx; + u64 time_tx; + u64 time_scan; + u64 time_bss_rx; + u32 filled; + s8 noise; +}; + +struct cfg80211_crypto_settings { + u32 wpa_versions; + u32 cipher_group; + int n_ciphers_pairwise; + u32 ciphers_pairwise[5]; + int n_akm_suites; + u32 akm_suites[2]; + bool control_port; + __be16 control_port_ethertype; + bool control_port_no_encrypt; + bool control_port_over_nl80211; + bool control_port_no_preauth; + struct key_params *wep_keys; + int wep_tx_key; + const u8 *psk; + const u8 *sae_pwd; + u8 sae_pwd_len; + enum nl80211_sae_pwe_mechanism sae_pwe; +}; + +struct cfg80211_beacon_data { + const u8 *head; + const u8 *tail; + const u8 *beacon_ies; + const u8 *proberesp_ies; + const u8 *assocresp_ies; + const u8 *probe_resp; + const u8 *lci; + const u8 *civicloc; + s8 ftm_responder; + size_t head_len; + size_t tail_len; + size_t beacon_ies_len; + size_t proberesp_ies_len; + size_t assocresp_ies_len; + size_t probe_resp_len; + size_t lci_len; + size_t civicloc_len; +}; + +struct mac_address { + u8 addr[6]; +}; + +struct cfg80211_acl_data { + enum nl80211_acl_policy acl_policy; + int n_acl_entries; + struct mac_address mac_addrs[0]; +}; + +struct cfg80211_fils_discovery { + u32 min_interval; + u32 max_interval; + size_t tmpl_len; + const u8 *tmpl; +}; + +struct cfg80211_unsol_bcast_probe_resp { + u32 interval; + size_t tmpl_len; + const u8 *tmpl; +}; + +struct cfg80211_ap_settings { + struct cfg80211_chan_def chandef; + struct cfg80211_beacon_data beacon; + int beacon_interval; + int dtim_period; + const u8 *ssid; + size_t ssid_len; + enum nl80211_hidden_ssid hidden_ssid; + struct cfg80211_crypto_settings crypto; + bool privacy; + enum nl80211_auth_type auth_type; + enum nl80211_smps_mode smps_mode; + int inactivity_timeout; + u8 p2p_ctwindow; + bool p2p_opp_ps; + const struct cfg80211_acl_data *acl; + bool pbss; + struct cfg80211_bitrate_mask beacon_rate; + const struct ieee80211_ht_cap *ht_cap; + const struct ieee80211_vht_cap *vht_cap; + const struct ieee80211_he_cap_elem *he_cap; + const struct ieee80211_he_operation *he_oper; + bool ht_required; + bool vht_required; + bool he_required; + bool twt_responder; + u32 flags; + struct ieee80211_he_obss_pd he_obss_pd; + struct cfg80211_he_bss_color he_bss_color; + struct cfg80211_fils_discovery fils_discovery; + struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp; +}; + +struct cfg80211_csa_settings { + struct cfg80211_chan_def chandef; + struct cfg80211_beacon_data beacon_csa; + const u16 *counter_offsets_beacon; + const u16 *counter_offsets_presp; + unsigned int n_counter_offsets_beacon; + unsigned int n_counter_offsets_presp; + struct cfg80211_beacon_data beacon_after; + bool radar_required; + bool block_tx; + u8 count; +}; + +struct sta_txpwr { + s16 power; + enum nl80211_tx_power_setting type; +}; + +struct station_parameters { + const u8 *supported_rates; + struct net_device *vlan; + u32 sta_flags_mask; + u32 sta_flags_set; + u32 sta_modify_mask; + int listen_interval; + u16 aid; + u16 vlan_id; + u16 peer_aid; + u8 supported_rates_len; + u8 plink_action; + u8 plink_state; + const struct ieee80211_ht_cap *ht_capa; + const struct ieee80211_vht_cap *vht_capa; + u8 uapsd_queues; + u8 max_sp; + enum nl80211_mesh_power_mode local_pm; + u16 capability; + const u8 *ext_capab; + u8 ext_capab_len; + const u8 *supported_channels; + u8 supported_channels_len; + const u8 *supported_oper_classes; + u8 supported_oper_classes_len; + u8 opmode_notif; + bool opmode_notif_used; + int support_p2p_ps; + const struct ieee80211_he_cap_elem *he_capa; + u8 he_capa_len; + u16 airtime_weight; + struct sta_txpwr txpwr; + const struct ieee80211_he_6ghz_capa *he_6ghz_capa; +}; + +struct station_del_parameters { + const u8 *mac; + u8 subtype; + u16 reason_code; +}; + +struct rate_info { + u8 flags; + u8 mcs; + u16 legacy; + u8 nss; + u8 bw; + u8 he_gi; + u8 he_dcm; + u8 he_ru_alloc; + u8 n_bonded_ch; +}; + +struct sta_bss_parameters { + u8 flags; + u8 dtim_period; + u16 beacon_interval; +}; + +struct cfg80211_txq_stats { + u32 filled; + u32 backlog_bytes; + u32 backlog_packets; + u32 flows; + u32 drops; + u32 ecn_marks; + u32 overlimit; + u32 overmemory; + u32 collisions; + u32 tx_bytes; + u32 tx_packets; + u32 max_flows; +}; + +struct cfg80211_tid_stats { + u32 filled; + u64 rx_msdu; + u64 tx_msdu; + u64 tx_msdu_retries; + u64 tx_msdu_failed; + struct cfg80211_txq_stats txq_stats; +}; + +struct station_info { + u64 filled; + u32 connected_time; + u32 inactive_time; + u64 assoc_at; + u64 rx_bytes; + u64 tx_bytes; + u16 llid; + u16 plid; + u8 plink_state; + s8 signal; + s8 signal_avg; + u8 chains; + s8 chain_signal[4]; + s8 chain_signal_avg[4]; + struct rate_info txrate; + struct rate_info rxrate; + u32 rx_packets; + u32 tx_packets; + u32 tx_retries; + u32 tx_failed; + u32 rx_dropped_misc; + struct sta_bss_parameters bss_param; + struct nl80211_sta_flag_update sta_flags; + int generation; + const u8 *assoc_req_ies; + size_t assoc_req_ies_len; + u32 beacon_loss_count; + s64 t_offset; + enum nl80211_mesh_power_mode local_pm; + enum nl80211_mesh_power_mode peer_pm; + enum nl80211_mesh_power_mode nonpeer_pm; + u32 expected_throughput; + u64 tx_duration; + u64 rx_duration; + u64 rx_beacon; + u8 rx_beacon_signal_avg; + u8 connected_to_gate; + struct cfg80211_tid_stats *pertid; + s8 ack_signal; + s8 avg_ack_signal; + u16 airtime_weight; + u32 rx_mpdu_count; + u32 fcs_err_count; + u32 airtime_link_metric; + u8 connected_to_as; +}; + +struct mpath_info { + u32 filled; + u32 frame_qlen; + u32 sn; + u32 metric; + u32 exptime; + u32 discovery_timeout; + u8 discovery_retries; + u8 flags; + u8 hop_count; + u32 path_change_count; + int generation; +}; + +struct bss_parameters { + int use_cts_prot; + int use_short_preamble; + int use_short_slot_time; + const u8 *basic_rates; + u8 basic_rates_len; + int ap_isolate; + int ht_opmode; + s8 p2p_ctwindow; + s8 p2p_opp_ps; +}; + +struct mesh_config { + u16 dot11MeshRetryTimeout; + u16 dot11MeshConfirmTimeout; + u16 dot11MeshHoldingTimeout; + u16 dot11MeshMaxPeerLinks; + u8 dot11MeshMaxRetries; + u8 dot11MeshTTL; + u8 element_ttl; + bool auto_open_plinks; + u32 dot11MeshNbrOffsetMaxNeighbor; + u8 dot11MeshHWMPmaxPREQretries; + u32 path_refresh_time; + u16 min_discovery_timeout; + u32 dot11MeshHWMPactivePathTimeout; + u16 dot11MeshHWMPpreqMinInterval; + u16 dot11MeshHWMPperrMinInterval; + u16 dot11MeshHWMPnetDiameterTraversalTime; + u8 dot11MeshHWMPRootMode; + bool dot11MeshConnectedToMeshGate; + bool dot11MeshConnectedToAuthServer; + u16 dot11MeshHWMPRannInterval; + bool dot11MeshGateAnnouncementProtocol; + bool dot11MeshForwarding; + s32 rssi_threshold; + u16 ht_opmode; + u32 dot11MeshHWMPactivePathToRootTimeout; + u16 dot11MeshHWMProotInterval; + u16 dot11MeshHWMPconfirmationInterval; + enum nl80211_mesh_power_mode power_mode; + u16 dot11MeshAwakeWindowDuration; + u32 plink_timeout; + bool dot11MeshNolearn; +}; + +struct mesh_setup { + struct cfg80211_chan_def chandef; + const u8 *mesh_id; + u8 mesh_id_len; + u8 sync_method; + u8 path_sel_proto; + u8 path_metric; + u8 auth_id; + const u8 *ie; + u8 ie_len; + bool is_authenticated; + bool is_secure; + bool user_mpm; + u8 dtim_period; + u16 beacon_interval; + int mcast_rate[5]; + u32 basic_rates; + struct cfg80211_bitrate_mask beacon_rate; + bool userspace_handles_dfs; + bool control_port_over_nl80211; +}; + +struct ocb_setup { + struct cfg80211_chan_def chandef; +}; + +struct ieee80211_txq_params { + enum nl80211_ac ac; + u16 txop; + u16 cwmin; + u16 cwmax; + u8 aifs; +}; + +struct cfg80211_ssid { + u8 ssid[32]; + u8 ssid_len; +}; + +struct cfg80211_scan_info { + u64 scan_start_tsf; + u8 tsf_bssid[6]; + bool aborted; +}; + +struct cfg80211_scan_6ghz_params { + u32 short_ssid; + u32 channel_idx; + u8 bssid[6]; + bool unsolicited_probe; + bool short_ssid_valid; + bool psc_no_listen; +}; + +struct cfg80211_scan_request { + struct cfg80211_ssid *ssids; + int n_ssids; + u32 n_channels; + enum nl80211_bss_scan_width scan_width; + const u8 *ie; + size_t ie_len; + u16 duration; + bool duration_mandatory; + u32 flags; + u32 rates[5]; + struct wireless_dev *wdev; + u8 mac_addr[6]; + u8 mac_addr_mask[6]; + u8 bssid[6]; + struct wiphy *wiphy; + long unsigned int scan_start; + struct cfg80211_scan_info info; + bool notified; + bool no_cck; + bool scan_6ghz; + u32 n_6ghz_params; + struct cfg80211_scan_6ghz_params *scan_6ghz_params; + struct ieee80211_channel *channels[0]; +}; + +enum cfg80211_signal_type { + CFG80211_SIGNAL_TYPE_NONE = 0, + CFG80211_SIGNAL_TYPE_MBM = 1, + CFG80211_SIGNAL_TYPE_UNSPEC = 2, +}; + +struct ieee80211_txrx_stypes; + +struct ieee80211_iface_combination; + +struct wiphy_iftype_akm_suites; + +struct wiphy_wowlan_support; + +struct cfg80211_wowlan; + +struct wiphy_iftype_ext_capab; + +struct wiphy_coalesce_support; + +struct wiphy_vendor_command; + +struct cfg80211_pmsr_capabilities; + +struct wiphy { + u8 perm_addr[6]; + u8 addr_mask[6]; + struct mac_address *addresses; + const struct ieee80211_txrx_stypes *mgmt_stypes; + const struct ieee80211_iface_combination *iface_combinations; + int n_iface_combinations; + u16 software_iftypes; + u16 n_addresses; + u16 interface_modes; + u16 max_acl_mac_addrs; + u32 flags; + u32 regulatory_flags; + u32 features; + u8 ext_features[7]; + u32 ap_sme_capa; + enum cfg80211_signal_type signal_type; + int bss_priv_size; + u8 max_scan_ssids; + u8 max_sched_scan_reqs; + u8 max_sched_scan_ssids; + u8 max_match_sets; + u16 max_scan_ie_len; + u16 max_sched_scan_ie_len; + u32 max_sched_scan_plans; + u32 max_sched_scan_plan_interval; + u32 max_sched_scan_plan_iterations; + int n_cipher_suites; + const u32 *cipher_suites; + int n_akm_suites; + const u32 *akm_suites; + const struct wiphy_iftype_akm_suites *iftype_akm_suites; + unsigned int num_iftype_akm_suites; + u8 retry_short; + u8 retry_long; + u32 frag_threshold; + u32 rts_threshold; + u8 coverage_class; + char fw_version[32]; + u32 hw_version; + const struct wiphy_wowlan_support *wowlan; + struct cfg80211_wowlan *wowlan_config; + u16 max_remain_on_channel_duration; + u8 max_num_pmkids; + u32 available_antennas_tx; + u32 available_antennas_rx; + u32 probe_resp_offload; + const u8 *extended_capabilities; + const u8 *extended_capabilities_mask; + u8 extended_capabilities_len; + const struct wiphy_iftype_ext_capab *iftype_ext_capab; + unsigned int num_iftype_ext_capab; + const void *privid; + struct ieee80211_supported_band *bands[5]; + void (*reg_notifier)(struct wiphy *, struct regulatory_request *); + const struct ieee80211_regdomain *regd; + struct device dev; + bool registered; + struct dentry *debugfsdir; + const struct ieee80211_ht_cap *ht_capa_mod_mask; + const struct ieee80211_vht_cap *vht_capa_mod_mask; + struct list_head wdev_list; + possible_net_t _net; + const struct wiphy_coalesce_support *coalesce; + const struct wiphy_vendor_command *vendor_commands; + const struct nl80211_vendor_cmd_info *vendor_events; + int n_vendor_commands; + int n_vendor_events; + u16 max_ap_assoc_sta; + u8 max_num_csa_counters; + u32 bss_select_support; + u8 nan_supported_bands; + u32 txq_limit; + u32 txq_memory_limit; + u32 txq_quantum; + long unsigned int tx_queue_len; + u8 support_mbssid: 1; + u8 support_only_he_mbssid: 1; + const struct cfg80211_pmsr_capabilities *pmsr_capa; + struct { + u64 peer; + u64 vif; + u8 max_retry; + } tid_config_support; + u8 max_data_retry_count; + long: 56; + long: 64; + long: 64; + long: 64; + char priv[0]; +}; + +struct cfg80211_match_set { + struct cfg80211_ssid ssid; + u8 bssid[6]; + s32 rssi_thold; + s32 per_band_rssi_thold[5]; +}; + +struct cfg80211_sched_scan_plan { + u32 interval; + u32 iterations; +}; + +struct cfg80211_bss_select_adjust { + enum nl80211_band band; + s8 delta; +}; + +struct cfg80211_sched_scan_request { + u64 reqid; + struct cfg80211_ssid *ssids; + int n_ssids; + u32 n_channels; + enum nl80211_bss_scan_width scan_width; + const u8 *ie; + size_t ie_len; + u32 flags; + struct cfg80211_match_set *match_sets; + int n_match_sets; + s32 min_rssi_thold; + u32 delay; + struct cfg80211_sched_scan_plan *scan_plans; + int n_scan_plans; + u8 mac_addr[6]; + u8 mac_addr_mask[6]; + bool relative_rssi_set; + s8 relative_rssi; + struct cfg80211_bss_select_adjust rssi_adjust; + struct wiphy *wiphy; + struct net_device *dev; + long unsigned int scan_start; + bool report_results; + struct callback_head callback_head; + u32 owner_nlportid; + bool nl_owner_dead; + struct list_head list; + struct ieee80211_channel *channels[0]; +}; + +struct cfg80211_bss_ies { + u64 tsf; + struct callback_head callback_head; + int len; + bool from_beacon; + u8 data[0]; +}; + +struct cfg80211_bss { + struct ieee80211_channel *channel; + enum nl80211_bss_scan_width scan_width; + const struct cfg80211_bss_ies *ies; + const struct cfg80211_bss_ies *beacon_ies; + const struct cfg80211_bss_ies *proberesp_ies; + struct cfg80211_bss *hidden_beacon_bss; + struct cfg80211_bss *transmitted_bss; + struct list_head nontrans_list; + s32 signal; + u16 beacon_interval; + u16 capability; + u8 bssid[6]; + u8 chains; + s8 chain_signal[4]; + u8 bssid_index; + u8 max_bssid_indicator; + int: 24; + u8 priv[0]; +}; + +struct cfg80211_auth_request { + struct cfg80211_bss *bss; + const u8 *ie; + size_t ie_len; + enum nl80211_auth_type auth_type; + const u8 *key; + u8 key_len; + u8 key_idx; + const u8 *auth_data; + size_t auth_data_len; +}; + +struct cfg80211_assoc_request { + struct cfg80211_bss *bss; + const u8 *ie; + const u8 *prev_bssid; + size_t ie_len; + struct cfg80211_crypto_settings crypto; + bool use_mfp; + int: 24; + u32 flags; + struct ieee80211_ht_cap ht_capa; + struct ieee80211_ht_cap ht_capa_mask; + struct ieee80211_vht_cap vht_capa; + struct ieee80211_vht_cap vht_capa_mask; + int: 32; + const u8 *fils_kek; + size_t fils_kek_len; + const u8 *fils_nonces; + struct ieee80211_s1g_cap s1g_capa; + struct ieee80211_s1g_cap s1g_capa_mask; + short: 16; +} __attribute__((packed)); + +struct cfg80211_deauth_request { + const u8 *bssid; + const u8 *ie; + size_t ie_len; + u16 reason_code; + bool local_state_change; +}; + +struct cfg80211_disassoc_request { + struct cfg80211_bss *bss; + const u8 *ie; + size_t ie_len; + u16 reason_code; + bool local_state_change; +}; + +struct cfg80211_ibss_params { + const u8 *ssid; + const u8 *bssid; + struct cfg80211_chan_def chandef; + const u8 *ie; + u8 ssid_len; + u8 ie_len; + u16 beacon_interval; + u32 basic_rates; + bool channel_fixed; + bool privacy; + bool control_port; + bool control_port_over_nl80211; + bool userspace_handles_dfs; + int: 24; + int mcast_rate[5]; + struct ieee80211_ht_cap ht_capa; + struct ieee80211_ht_cap ht_capa_mask; + struct key_params *wep_keys; + int wep_tx_key; + int: 32; +} __attribute__((packed)); + +struct cfg80211_bss_selection { + enum nl80211_bss_select_attr behaviour; + union { + enum nl80211_band band_pref; + struct cfg80211_bss_select_adjust adjust; + } param; +}; + +struct cfg80211_connect_params { + struct ieee80211_channel *channel; + struct ieee80211_channel *channel_hint; + const u8 *bssid; + const u8 *bssid_hint; + const u8 *ssid; + size_t ssid_len; + enum nl80211_auth_type auth_type; + int: 32; + const u8 *ie; + size_t ie_len; + bool privacy; + int: 24; + enum nl80211_mfp mfp; + struct cfg80211_crypto_settings crypto; + const u8 *key; + u8 key_len; + u8 key_idx; + short: 16; + u32 flags; + int bg_scan_period; + struct ieee80211_ht_cap ht_capa; + struct ieee80211_ht_cap ht_capa_mask; + struct ieee80211_vht_cap vht_capa; + struct ieee80211_vht_cap vht_capa_mask; + bool pbss; + int: 24; + struct cfg80211_bss_selection bss_select; + const u8 *prev_bssid; + const u8 *fils_erp_username; + size_t fils_erp_username_len; + const u8 *fils_erp_realm; + size_t fils_erp_realm_len; + u16 fils_erp_next_seq_num; + long: 48; + const u8 *fils_erp_rrk; + size_t fils_erp_rrk_len; + bool want_1x; + int: 24; + struct ieee80211_edmg edmg; + int: 32; +} __attribute__((packed)); + +struct cfg80211_pmksa { + const u8 *bssid; + const u8 *pmkid; + const u8 *pmk; + size_t pmk_len; + const u8 *ssid; + size_t ssid_len; + const u8 *cache_id; + u32 pmk_lifetime; + u8 pmk_reauth_threshold; +}; + +struct cfg80211_pkt_pattern { + const u8 *mask; + const u8 *pattern; + int pattern_len; + int pkt_offset; +}; + +struct cfg80211_wowlan_tcp { + struct socket *sock; + __be32 src; + __be32 dst; + u16 src_port; + u16 dst_port; + u8 dst_mac[6]; + int payload_len; + const u8 *payload; + struct nl80211_wowlan_tcp_data_seq payload_seq; + u32 data_interval; + u32 wake_len; + const u8 *wake_data; + const u8 *wake_mask; + u32 tokens_size; + struct nl80211_wowlan_tcp_data_token payload_tok; +}; + +struct cfg80211_wowlan { + bool any; + bool disconnect; + bool magic_pkt; + bool gtk_rekey_failure; + bool eap_identity_req; + bool four_way_handshake; + bool rfkill_release; + struct cfg80211_pkt_pattern *patterns; + struct cfg80211_wowlan_tcp *tcp; + int n_patterns; + struct cfg80211_sched_scan_request *nd_config; +}; + +struct cfg80211_coalesce_rules { + int delay; + enum nl80211_coalesce_condition condition; + struct cfg80211_pkt_pattern *patterns; + int n_patterns; +}; + +struct cfg80211_coalesce { + struct cfg80211_coalesce_rules *rules; + int n_rules; +}; + +struct cfg80211_gtk_rekey_data { + const u8 *kek; + const u8 *kck; + const u8 *replay_ctr; + u32 akm; + u8 kek_len; + u8 kck_len; +}; + +struct cfg80211_update_ft_ies_params { + u16 md; + const u8 *ie; + size_t ie_len; +}; + +struct cfg80211_mgmt_tx_params { + struct ieee80211_channel *chan; + bool offchan; + unsigned int wait; + const u8 *buf; + size_t len; + bool no_cck; + bool dont_wait_for_ack; + int n_csa_offsets; + const u16 *csa_offsets; +}; + +struct cfg80211_dscp_exception { + u8 dscp; + u8 up; +}; + +struct cfg80211_dscp_range { + u8 low; + u8 high; +}; + +struct cfg80211_qos_map { + u8 num_des; + struct cfg80211_dscp_exception dscp_exception[21]; + struct cfg80211_dscp_range up[8]; +}; + +struct cfg80211_nan_conf { + u8 master_pref; + u8 bands; +}; + +struct cfg80211_nan_func_filter { + const u8 *filter; + u8 len; +}; + +struct cfg80211_nan_func { + enum nl80211_nan_function_type type; + u8 service_id[6]; + u8 publish_type; + bool close_range; + bool publish_bcast; + bool subscribe_active; + u8 followup_id; + u8 followup_reqid; + struct mac_address followup_dest; + u32 ttl; + const u8 *serv_spec_info; + u8 serv_spec_info_len; + bool srf_include; + const u8 *srf_bf; + u8 srf_bf_len; + u8 srf_bf_idx; + struct mac_address *srf_macs; + int srf_num_macs; + struct cfg80211_nan_func_filter *rx_filters; + struct cfg80211_nan_func_filter *tx_filters; + u8 num_tx_filters; + u8 num_rx_filters; + u8 instance_id; + u64 cookie; +}; + +struct cfg80211_pmk_conf { + const u8 *aa; + u8 pmk_len; + const u8 *pmk; + const u8 *pmk_r0_name; +}; + +struct cfg80211_external_auth_params { + enum nl80211_external_auth_action action; + u8 bssid[6]; + struct cfg80211_ssid ssid; + unsigned int key_mgmt_suite; + u16 status; + const u8 *pmkid; +}; + +struct cfg80211_ftm_responder_stats { + u32 filled; + u32 success_num; + u32 partial_num; + u32 failed_num; + u32 asap_num; + u32 non_asap_num; + u64 total_duration_ms; + u32 unknown_triggers_num; + u32 reschedule_requests_num; + u32 out_of_window_triggers_num; +}; + +struct cfg80211_pmsr_ftm_request_peer { + enum nl80211_preamble preamble; + u16 burst_period; + u8 requested: 1; + u8 asap: 1; + u8 request_lci: 1; + u8 request_civicloc: 1; + u8 trigger_based: 1; + u8 non_trigger_based: 1; + u8 num_bursts_exp; + u8 burst_duration; + u8 ftms_per_burst; + u8 ftmr_retries; +}; + +struct cfg80211_pmsr_request_peer { + u8 addr[6]; + struct cfg80211_chan_def chandef; + u8 report_ap_tsf: 1; + struct cfg80211_pmsr_ftm_request_peer ftm; +}; + +struct cfg80211_pmsr_request { + u64 cookie; + void *drv_data; + u32 n_peers; + u32 nl_portid; + u32 timeout; + u8 mac_addr[6]; + u8 mac_addr_mask[6]; + struct list_head list; + struct cfg80211_pmsr_request_peer peers[0]; +}; + +struct cfg80211_update_owe_info { + u8 peer[6]; + u16 status; + const u8 *ie; + size_t ie_len; +}; + +struct mgmt_frame_regs { + u32 global_stypes; + u32 interface_stypes; + u32 global_mcast_stypes; + u32 interface_mcast_stypes; +}; + +struct cfg80211_ops { + int (*suspend)(struct wiphy *, struct cfg80211_wowlan *); + int (*resume)(struct wiphy *); + void (*set_wakeup)(struct wiphy *, bool); + struct wireless_dev * (*add_virtual_intf)(struct wiphy *, const char *, unsigned char, enum nl80211_iftype, struct vif_params *); + int (*del_virtual_intf)(struct wiphy *, struct wireless_dev *); + int (*change_virtual_intf)(struct wiphy *, struct net_device *, enum nl80211_iftype, struct vif_params *); + int (*add_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *, struct key_params *); + int (*get_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *, void *, void (*)(void *, struct key_params *)); + int (*del_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *); + int (*set_default_key)(struct wiphy *, struct net_device *, u8, bool, bool); + int (*set_default_mgmt_key)(struct wiphy *, struct net_device *, u8); + int (*set_default_beacon_key)(struct wiphy *, struct net_device *, u8); + int (*start_ap)(struct wiphy *, struct net_device *, struct cfg80211_ap_settings *); + int (*change_beacon)(struct wiphy *, struct net_device *, struct cfg80211_beacon_data *); + int (*stop_ap)(struct wiphy *, struct net_device *); + int (*add_station)(struct wiphy *, struct net_device *, const u8 *, struct station_parameters *); + int (*del_station)(struct wiphy *, struct net_device *, struct station_del_parameters *); + int (*change_station)(struct wiphy *, struct net_device *, const u8 *, struct station_parameters *); + int (*get_station)(struct wiphy *, struct net_device *, const u8 *, struct station_info *); + int (*dump_station)(struct wiphy *, struct net_device *, int, u8 *, struct station_info *); + int (*add_mpath)(struct wiphy *, struct net_device *, const u8 *, const u8 *); + int (*del_mpath)(struct wiphy *, struct net_device *, const u8 *); + int (*change_mpath)(struct wiphy *, struct net_device *, const u8 *, const u8 *); + int (*get_mpath)(struct wiphy *, struct net_device *, u8 *, u8 *, struct mpath_info *); + int (*dump_mpath)(struct wiphy *, struct net_device *, int, u8 *, u8 *, struct mpath_info *); + int (*get_mpp)(struct wiphy *, struct net_device *, u8 *, u8 *, struct mpath_info *); + int (*dump_mpp)(struct wiphy *, struct net_device *, int, u8 *, u8 *, struct mpath_info *); + int (*get_mesh_config)(struct wiphy *, struct net_device *, struct mesh_config *); + int (*update_mesh_config)(struct wiphy *, struct net_device *, u32, const struct mesh_config *); + int (*join_mesh)(struct wiphy *, struct net_device *, const struct mesh_config *, const struct mesh_setup *); + int (*leave_mesh)(struct wiphy *, struct net_device *); + int (*join_ocb)(struct wiphy *, struct net_device *, struct ocb_setup *); + int (*leave_ocb)(struct wiphy *, struct net_device *); + int (*change_bss)(struct wiphy *, struct net_device *, struct bss_parameters *); + int (*set_txq_params)(struct wiphy *, struct net_device *, struct ieee80211_txq_params *); + int (*libertas_set_mesh_channel)(struct wiphy *, struct net_device *, struct ieee80211_channel *); + int (*set_monitor_channel)(struct wiphy *, struct cfg80211_chan_def *); + int (*scan)(struct wiphy *, struct cfg80211_scan_request *); + void (*abort_scan)(struct wiphy *, struct wireless_dev *); + int (*auth)(struct wiphy *, struct net_device *, struct cfg80211_auth_request *); + int (*assoc)(struct wiphy *, struct net_device *, struct cfg80211_assoc_request *); + int (*deauth)(struct wiphy *, struct net_device *, struct cfg80211_deauth_request *); + int (*disassoc)(struct wiphy *, struct net_device *, struct cfg80211_disassoc_request *); + int (*connect)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *); + int (*update_connect_params)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *, u32); + int (*disconnect)(struct wiphy *, struct net_device *, u16); + int (*join_ibss)(struct wiphy *, struct net_device *, struct cfg80211_ibss_params *); + int (*leave_ibss)(struct wiphy *, struct net_device *); + int (*set_mcast_rate)(struct wiphy *, struct net_device *, int *); + int (*set_wiphy_params)(struct wiphy *, u32); + int (*set_tx_power)(struct wiphy *, struct wireless_dev *, enum nl80211_tx_power_setting, int); + int (*get_tx_power)(struct wiphy *, struct wireless_dev *, int *); + void (*rfkill_poll)(struct wiphy *); + int (*set_bitrate_mask)(struct wiphy *, struct net_device *, const u8 *, const struct cfg80211_bitrate_mask *); + int (*dump_survey)(struct wiphy *, struct net_device *, int, struct survey_info *); + int (*set_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *); + int (*del_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *); + int (*flush_pmksa)(struct wiphy *, struct net_device *); + int (*remain_on_channel)(struct wiphy *, struct wireless_dev *, struct ieee80211_channel *, unsigned int, u64 *); + int (*cancel_remain_on_channel)(struct wiphy *, struct wireless_dev *, u64); + int (*mgmt_tx)(struct wiphy *, struct wireless_dev *, struct cfg80211_mgmt_tx_params *, u64 *); + int (*mgmt_tx_cancel_wait)(struct wiphy *, struct wireless_dev *, u64); + int (*set_power_mgmt)(struct wiphy *, struct net_device *, bool, int); + int (*set_cqm_rssi_config)(struct wiphy *, struct net_device *, s32, u32); + int (*set_cqm_rssi_range_config)(struct wiphy *, struct net_device *, s32, s32); + int (*set_cqm_txe_config)(struct wiphy *, struct net_device *, u32, u32, u32); + void (*update_mgmt_frame_registrations)(struct wiphy *, struct wireless_dev *, struct mgmt_frame_regs *); + int (*set_antenna)(struct wiphy *, u32, u32); + int (*get_antenna)(struct wiphy *, u32 *, u32 *); + int (*sched_scan_start)(struct wiphy *, struct net_device *, struct cfg80211_sched_scan_request *); + int (*sched_scan_stop)(struct wiphy *, struct net_device *, u64); + int (*set_rekey_data)(struct wiphy *, struct net_device *, struct cfg80211_gtk_rekey_data *); + int (*tdls_mgmt)(struct wiphy *, struct net_device *, const u8 *, u8, u8, u16, u32, bool, const u8 *, size_t); + int (*tdls_oper)(struct wiphy *, struct net_device *, const u8 *, enum nl80211_tdls_operation); + int (*probe_client)(struct wiphy *, struct net_device *, const u8 *, u64 *); + int (*set_noack_map)(struct wiphy *, struct net_device *, u16); + int (*get_channel)(struct wiphy *, struct wireless_dev *, struct cfg80211_chan_def *); + int (*start_p2p_device)(struct wiphy *, struct wireless_dev *); + void (*stop_p2p_device)(struct wiphy *, struct wireless_dev *); + int (*set_mac_acl)(struct wiphy *, struct net_device *, const struct cfg80211_acl_data *); + int (*start_radar_detection)(struct wiphy *, struct net_device *, struct cfg80211_chan_def *, u32); + void (*end_cac)(struct wiphy *, struct net_device *); + int (*update_ft_ies)(struct wiphy *, struct net_device *, struct cfg80211_update_ft_ies_params *); + int (*crit_proto_start)(struct wiphy *, struct wireless_dev *, enum nl80211_crit_proto_id, u16); + void (*crit_proto_stop)(struct wiphy *, struct wireless_dev *); + int (*set_coalesce)(struct wiphy *, struct cfg80211_coalesce *); + int (*channel_switch)(struct wiphy *, struct net_device *, struct cfg80211_csa_settings *); + int (*set_qos_map)(struct wiphy *, struct net_device *, struct cfg80211_qos_map *); + int (*set_ap_chanwidth)(struct wiphy *, struct net_device *, struct cfg80211_chan_def *); + int (*add_tx_ts)(struct wiphy *, struct net_device *, u8, const u8 *, u8, u16); + int (*del_tx_ts)(struct wiphy *, struct net_device *, u8, const u8 *); + int (*tdls_channel_switch)(struct wiphy *, struct net_device *, const u8 *, u8, struct cfg80211_chan_def *); + void (*tdls_cancel_channel_switch)(struct wiphy *, struct net_device *, const u8 *); + int (*start_nan)(struct wiphy *, struct wireless_dev *, struct cfg80211_nan_conf *); + void (*stop_nan)(struct wiphy *, struct wireless_dev *); + int (*add_nan_func)(struct wiphy *, struct wireless_dev *, struct cfg80211_nan_func *); + void (*del_nan_func)(struct wiphy *, struct wireless_dev *, u64); + int (*nan_change_conf)(struct wiphy *, struct wireless_dev *, struct cfg80211_nan_conf *, u32); + int (*set_multicast_to_unicast)(struct wiphy *, struct net_device *, const bool); + int (*get_txq_stats)(struct wiphy *, struct wireless_dev *, struct cfg80211_txq_stats *); + int (*set_pmk)(struct wiphy *, struct net_device *, const struct cfg80211_pmk_conf *); + int (*del_pmk)(struct wiphy *, struct net_device *, const u8 *); + int (*external_auth)(struct wiphy *, struct net_device *, struct cfg80211_external_auth_params *); + int (*tx_control_port)(struct wiphy *, struct net_device *, const u8 *, size_t, const u8 *, const __be16, const bool, u64 *); + int (*get_ftm_responder_stats)(struct wiphy *, struct net_device *, struct cfg80211_ftm_responder_stats *); + int (*start_pmsr)(struct wiphy *, struct wireless_dev *, struct cfg80211_pmsr_request *); + void (*abort_pmsr)(struct wiphy *, struct wireless_dev *, struct cfg80211_pmsr_request *); + int (*update_owe_info)(struct wiphy *, struct net_device *, struct cfg80211_update_owe_info *); + int (*probe_mesh_link)(struct wiphy *, struct net_device *, const u8 *, size_t); + int (*set_tid_config)(struct wiphy *, struct net_device *, struct cfg80211_tid_config *); + int (*reset_tid_config)(struct wiphy *, struct net_device *, const u8 *, u8); +}; + +enum wiphy_flags { + WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK = 1, + WIPHY_FLAG_SPLIT_SCAN_6GHZ = 4, + WIPHY_FLAG_NETNS_OK = 8, + WIPHY_FLAG_PS_ON_BY_DEFAULT = 16, + WIPHY_FLAG_4ADDR_AP = 32, + WIPHY_FLAG_4ADDR_STATION = 64, + WIPHY_FLAG_CONTROL_PORT_PROTOCOL = 128, + WIPHY_FLAG_IBSS_RSN = 256, + WIPHY_FLAG_MESH_AUTH = 1024, + WIPHY_FLAG_SUPPORTS_FW_ROAM = 8192, + WIPHY_FLAG_AP_UAPSD = 16384, + WIPHY_FLAG_SUPPORTS_TDLS = 32768, + WIPHY_FLAG_TDLS_EXTERNAL_SETUP = 65536, + WIPHY_FLAG_HAVE_AP_SME = 131072, + WIPHY_FLAG_REPORTS_OBSS = 262144, + WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = 524288, + WIPHY_FLAG_OFFCHAN_TX = 1048576, + WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = 2097152, + WIPHY_FLAG_SUPPORTS_5_10_MHZ = 4194304, + WIPHY_FLAG_HAS_CHANNEL_SWITCH = 8388608, + WIPHY_FLAG_HAS_STATIC_WEP = 16777216, +}; + +struct ieee80211_iface_limit { + u16 max; + u16 types; +}; + +struct ieee80211_iface_combination { + const struct ieee80211_iface_limit *limits; + u32 num_different_channels; + u16 max_interfaces; + u8 n_limits; + bool beacon_int_infra_match; + u8 radar_detect_widths; + u8 radar_detect_regions; + u32 beacon_int_min_gcd; +}; + +struct ieee80211_txrx_stypes { + u16 tx; + u16 rx; +}; + +enum wiphy_wowlan_support_flags { + WIPHY_WOWLAN_ANY = 1, + WIPHY_WOWLAN_MAGIC_PKT = 2, + WIPHY_WOWLAN_DISCONNECT = 4, + WIPHY_WOWLAN_SUPPORTS_GTK_REKEY = 8, + WIPHY_WOWLAN_GTK_REKEY_FAILURE = 16, + WIPHY_WOWLAN_EAP_IDENTITY_REQ = 32, + WIPHY_WOWLAN_4WAY_HANDSHAKE = 64, + WIPHY_WOWLAN_RFKILL_RELEASE = 128, + WIPHY_WOWLAN_NET_DETECT = 256, +}; + +struct wiphy_wowlan_tcp_support { + const struct nl80211_wowlan_tcp_data_token_feature *tok; + u32 data_payload_max; + u32 data_interval_max; + u32 wake_payload_max; + bool seq; +}; + +struct wiphy_wowlan_support { + u32 flags; + int n_patterns; + int pattern_max_len; + int pattern_min_len; + int max_pkt_offset; + int max_nd_match_sets; + const struct wiphy_wowlan_tcp_support *tcp; +}; + +struct wiphy_coalesce_support { + int n_rules; + int max_delay; + int n_patterns; + int pattern_max_len; + int pattern_min_len; + int max_pkt_offset; +}; + +struct wiphy_vendor_command { + struct nl80211_vendor_cmd_info info; + u32 flags; + int (*doit)(struct wiphy *, struct wireless_dev *, const void *, int); + int (*dumpit)(struct wiphy *, struct wireless_dev *, struct sk_buff *, const void *, int, long unsigned int *); + const struct nla_policy *policy; + unsigned int maxattr; +}; + +struct wiphy_iftype_ext_capab { + enum nl80211_iftype iftype; + const u8 *extended_capabilities; + const u8 *extended_capabilities_mask; + u8 extended_capabilities_len; +}; + +struct cfg80211_pmsr_capabilities { + unsigned int max_peers; + u8 report_ap_tsf: 1; + u8 randomize_mac_addr: 1; + struct { + u32 preambles; + u32 bandwidths; + s8 max_bursts_exponent; + u8 max_ftms_per_burst; + u8 supported: 1; + u8 asap: 1; + u8 non_asap: 1; + u8 request_lci: 1; + u8 request_civicloc: 1; + u8 trigger_based: 1; + u8 non_trigger_based: 1; + } ftm; +}; + +struct wiphy_iftype_akm_suites { + u16 iftypes_mask; + const u32 *akm_suites; + int n_akm_suites; +}; + +struct cfg80211_cached_keys { + struct key_params params[4]; + u8 data[52]; + int def; +}; + +struct cfg80211_internal_bss { + struct list_head list; + struct list_head hidden_list; + struct rb_node rbn; + u64 ts_boottime; + long unsigned int ts; + long unsigned int refcount; + atomic_t hold; + u64 parent_tsf; + u8 parent_bssid[6]; + struct cfg80211_bss pub; +}; + +struct cfg80211_cqm_config { + u32 rssi_hyst; + s32 last_rssi_event_value; + int n_rssi_thresholds; + s32 rssi_thresholds[0]; +}; + +struct cfg80211_fils_resp_params { + const u8 *kek; + size_t kek_len; + bool update_erp_next_seq_num; + u16 erp_next_seq_num; + const u8 *pmk; + size_t pmk_len; + const u8 *pmkid; +}; + +struct cfg80211_connect_resp_params { + int status; + const u8 *bssid; + struct cfg80211_bss *bss; + const u8 *req_ie; + size_t req_ie_len; + const u8 *resp_ie; + size_t resp_ie_len; + struct cfg80211_fils_resp_params fils; + enum nl80211_timeout_reason timeout_reason; +}; + +struct cfg80211_roam_info { + struct ieee80211_channel *channel; + struct cfg80211_bss *bss; + const u8 *bssid; + const u8 *req_ie; + size_t req_ie_len; + const u8 *resp_ie; + size_t resp_ie_len; + struct cfg80211_fils_resp_params fils; +}; + +enum rfkill_type { + RFKILL_TYPE_ALL = 0, + RFKILL_TYPE_WLAN = 1, + RFKILL_TYPE_BLUETOOTH = 2, + RFKILL_TYPE_UWB = 3, + RFKILL_TYPE_WIMAX = 4, + RFKILL_TYPE_WWAN = 5, + RFKILL_TYPE_GPS = 6, + RFKILL_TYPE_FM = 7, + RFKILL_TYPE_NFC = 8, + NUM_RFKILL_TYPES = 9, +}; + +struct rfkill; + +struct rfkill_ops { + void (*poll)(struct rfkill *, void *); + void (*query)(struct rfkill *, void *); + int (*set_block)(void *, bool); +}; + +struct cfg80211_registered_device { + const struct cfg80211_ops *ops; + struct list_head list; + struct rfkill_ops rfkill_ops; + struct rfkill *rfkill; + struct work_struct rfkill_block; + char country_ie_alpha2[2]; + const struct ieee80211_regdomain *requested_regd; + enum environment_cap env; + int wiphy_idx; + int devlist_generation; + int wdev_id; + int opencount; + wait_queue_head_t dev_wait; + struct list_head beacon_registrations; + spinlock_t beacon_registrations_lock; + int num_running_ifaces; + int num_running_monitor_ifaces; + u64 cookie_counter; + spinlock_t bss_lock; + struct list_head bss_list; + struct rb_root bss_tree; + u32 bss_generation; + u32 bss_entries; + struct cfg80211_scan_request *scan_req; + struct cfg80211_scan_request *int_scan_req; + struct sk_buff *scan_msg; + struct list_head sched_scan_req_list; + time64_t suspend_at; + struct work_struct scan_done_wk; + struct genl_info *cur_cmd_info; + struct work_struct conn_work; + struct work_struct event_work; + struct delayed_work dfs_update_channels_wk; + u32 crit_proto_nlportid; + struct cfg80211_coalesce *coalesce; + struct work_struct destroy_work; + struct work_struct sched_scan_stop_wk; + struct work_struct sched_scan_res_wk; + struct cfg80211_chan_def radar_chandef; + struct work_struct propagate_radar_detect_wk; + struct cfg80211_chan_def cac_done_chandef; + struct work_struct propagate_cac_done_wk; + struct work_struct mgmt_registrations_update_wk; + long: 64; + struct wiphy wiphy; +}; + +enum cfg80211_event_type { + EVENT_CONNECT_RESULT = 0, + EVENT_ROAMED = 1, + EVENT_DISCONNECTED = 2, + EVENT_IBSS_JOINED = 3, + EVENT_STOPPED = 4, + EVENT_PORT_AUTHORIZED = 5, +}; + +struct cfg80211_event { + struct list_head list; + enum cfg80211_event_type type; + union { + struct cfg80211_connect_resp_params cr; + struct cfg80211_roam_info rm; + struct { + const u8 *ie; + size_t ie_len; + u16 reason; + bool locally_generated; + } dc; + struct { + u8 bssid[6]; + struct ieee80211_channel *channel; + } ij; + struct { + u8 bssid[6]; + } pa; + }; +}; + +struct cfg80211_beacon_registration { + struct list_head list; + u32 nlportid; +}; + +struct radiotap_align_size { + uint8_t align: 4; + uint8_t size: 4; +}; + +struct ieee80211_radiotap_namespace { + const struct radiotap_align_size *align_size; + int n_bits; + uint32_t oui; + uint8_t subns; +}; + +struct ieee80211_radiotap_vendor_namespaces { + const struct ieee80211_radiotap_namespace *ns; + int n_ns; +}; + +struct ieee80211_radiotap_header; + +struct ieee80211_radiotap_iterator { + struct ieee80211_radiotap_header *_rtheader; + const struct ieee80211_radiotap_vendor_namespaces *_vns; + const struct ieee80211_radiotap_namespace *current_namespace; + unsigned char *_arg; + unsigned char *_next_ns_data; + __le32 *_next_bitmap; + unsigned char *this_arg; + int this_arg_index; + int this_arg_size; + int is_radiotap_ns; + int _max_length; + int _arg_index; + uint32_t _bitmap_shifter; + int _reset_on_ext; +}; + +struct ieee80211_radiotap_header { + uint8_t it_version; + uint8_t it_pad; + __le16 it_len; + __le32 it_present; +}; + +enum ieee80211_radiotap_presence { + IEEE80211_RADIOTAP_TSFT = 0, + IEEE80211_RADIOTAP_FLAGS = 1, + IEEE80211_RADIOTAP_RATE = 2, + IEEE80211_RADIOTAP_CHANNEL = 3, + IEEE80211_RADIOTAP_FHSS = 4, + IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, + IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, + IEEE80211_RADIOTAP_LOCK_QUALITY = 7, + IEEE80211_RADIOTAP_TX_ATTENUATION = 8, + IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, + IEEE80211_RADIOTAP_DBM_TX_POWER = 10, + IEEE80211_RADIOTAP_ANTENNA = 11, + IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, + IEEE80211_RADIOTAP_DB_ANTNOISE = 13, + IEEE80211_RADIOTAP_RX_FLAGS = 14, + IEEE80211_RADIOTAP_TX_FLAGS = 15, + IEEE80211_RADIOTAP_RTS_RETRIES = 16, + IEEE80211_RADIOTAP_DATA_RETRIES = 17, + IEEE80211_RADIOTAP_MCS = 19, + IEEE80211_RADIOTAP_AMPDU_STATUS = 20, + IEEE80211_RADIOTAP_VHT = 21, + IEEE80211_RADIOTAP_TIMESTAMP = 22, + IEEE80211_RADIOTAP_HE = 23, + IEEE80211_RADIOTAP_HE_MU = 24, + IEEE80211_RADIOTAP_ZERO_LEN_PSDU = 26, + IEEE80211_RADIOTAP_LSIG = 27, + IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, + IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, + IEEE80211_RADIOTAP_EXT = 31, +}; + +struct ieee80211_hdr { + __le16 frame_control; + __le16 duration_id; + u8 addr1[6]; + u8 addr2[6]; + u8 addr3[6]; + __le16 seq_ctrl; + u8 addr4[6]; +}; + +struct ieee80211s_hdr { + u8 flags; + u8 ttl; + __le32 seqnum; + u8 eaddr1[6]; + u8 eaddr2[6]; +} __attribute__((packed)); + +enum ieee80211_p2p_attr_id { + IEEE80211_P2P_ATTR_STATUS = 0, + IEEE80211_P2P_ATTR_MINOR_REASON = 1, + IEEE80211_P2P_ATTR_CAPABILITY = 2, + IEEE80211_P2P_ATTR_DEVICE_ID = 3, + IEEE80211_P2P_ATTR_GO_INTENT = 4, + IEEE80211_P2P_ATTR_GO_CONFIG_TIMEOUT = 5, + IEEE80211_P2P_ATTR_LISTEN_CHANNEL = 6, + IEEE80211_P2P_ATTR_GROUP_BSSID = 7, + IEEE80211_P2P_ATTR_EXT_LISTEN_TIMING = 8, + IEEE80211_P2P_ATTR_INTENDED_IFACE_ADDR = 9, + IEEE80211_P2P_ATTR_MANAGABILITY = 10, + IEEE80211_P2P_ATTR_CHANNEL_LIST = 11, + IEEE80211_P2P_ATTR_ABSENCE_NOTICE = 12, + IEEE80211_P2P_ATTR_DEVICE_INFO = 13, + IEEE80211_P2P_ATTR_GROUP_INFO = 14, + IEEE80211_P2P_ATTR_GROUP_ID = 15, + IEEE80211_P2P_ATTR_INTERFACE = 16, + IEEE80211_P2P_ATTR_OPER_CHANNEL = 17, + IEEE80211_P2P_ATTR_INVITE_FLAGS = 18, + IEEE80211_P2P_ATTR_VENDOR_SPECIFIC = 221, + IEEE80211_P2P_ATTR_MAX = 222, +}; + +enum ieee80211_vht_chanwidth { + IEEE80211_VHT_CHANWIDTH_USE_HT = 0, + IEEE80211_VHT_CHANWIDTH_80MHZ = 1, + IEEE80211_VHT_CHANWIDTH_160MHZ = 2, + IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3, +}; + +enum ieee80211_statuscode { + WLAN_STATUS_SUCCESS = 0, + WLAN_STATUS_UNSPECIFIED_FAILURE = 1, + WLAN_STATUS_CAPS_UNSUPPORTED = 10, + WLAN_STATUS_REASSOC_NO_ASSOC = 11, + WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, + WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, + WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, + WLAN_STATUS_CHALLENGE_FAIL = 15, + WLAN_STATUS_AUTH_TIMEOUT = 16, + WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, + WLAN_STATUS_ASSOC_DENIED_RATES = 18, + WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, + WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, + WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, + WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, + WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, + WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, + WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, + WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, + WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30, + WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31, + WLAN_STATUS_INVALID_IE = 40, + WLAN_STATUS_INVALID_GROUP_CIPHER = 41, + WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, + WLAN_STATUS_INVALID_AKMP = 43, + WLAN_STATUS_UNSUPP_RSN_VERSION = 44, + WLAN_STATUS_INVALID_RSN_IE_CAP = 45, + WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, + WLAN_STATUS_UNSPECIFIED_QOS = 32, + WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33, + WLAN_STATUS_ASSOC_DENIED_LOWACK = 34, + WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35, + WLAN_STATUS_REQUEST_DECLINED = 37, + WLAN_STATUS_INVALID_QOS_PARAM = 38, + WLAN_STATUS_CHANGE_TSPEC = 39, + WLAN_STATUS_WAIT_TS_DELAY = 47, + WLAN_STATUS_NO_DIRECT_LINK = 48, + WLAN_STATUS_STA_NOT_PRESENT = 49, + WLAN_STATUS_STA_NOT_QSTA = 50, + WLAN_STATUS_ANTI_CLOG_REQUIRED = 76, + WLAN_STATUS_FCG_NOT_SUPP = 78, + WLAN_STATUS_STA_NO_TBTT = 78, + WLAN_STATUS_REJECTED_WITH_SUGGESTED_CHANGES = 39, + WLAN_STATUS_REJECTED_FOR_DELAY_PERIOD = 47, + WLAN_STATUS_REJECT_WITH_SCHEDULE = 83, + WLAN_STATUS_PENDING_ADMITTING_FST_SESSION = 86, + WLAN_STATUS_PERFORMING_FST_NOW = 87, + WLAN_STATUS_PENDING_GAP_IN_BA_WINDOW = 88, + WLAN_STATUS_REJECT_U_PID_SETTING = 89, + WLAN_STATUS_REJECT_DSE_BAND = 96, + WLAN_STATUS_DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL = 99, + WLAN_STATUS_DENIED_DUE_TO_SPECTRUM_MANAGEMENT = 103, + WLAN_STATUS_FILS_AUTHENTICATION_FAILURE = 108, + WLAN_STATUS_UNKNOWN_AUTHENTICATION_SERVER = 109, + WLAN_STATUS_SAE_HASH_TO_ELEMENT = 126, + WLAN_STATUS_SAE_PK = 127, +}; + +enum ieee80211_eid { + WLAN_EID_SSID = 0, + WLAN_EID_SUPP_RATES = 1, + WLAN_EID_FH_PARAMS = 2, + WLAN_EID_DS_PARAMS = 3, + WLAN_EID_CF_PARAMS = 4, + WLAN_EID_TIM = 5, + WLAN_EID_IBSS_PARAMS = 6, + WLAN_EID_COUNTRY = 7, + WLAN_EID_REQUEST = 10, + WLAN_EID_QBSS_LOAD = 11, + WLAN_EID_EDCA_PARAM_SET = 12, + WLAN_EID_TSPEC = 13, + WLAN_EID_TCLAS = 14, + WLAN_EID_SCHEDULE = 15, + WLAN_EID_CHALLENGE = 16, + WLAN_EID_PWR_CONSTRAINT = 32, + WLAN_EID_PWR_CAPABILITY = 33, + WLAN_EID_TPC_REQUEST = 34, + WLAN_EID_TPC_REPORT = 35, + WLAN_EID_SUPPORTED_CHANNELS = 36, + WLAN_EID_CHANNEL_SWITCH = 37, + WLAN_EID_MEASURE_REQUEST = 38, + WLAN_EID_MEASURE_REPORT = 39, + WLAN_EID_QUIET = 40, + WLAN_EID_IBSS_DFS = 41, + WLAN_EID_ERP_INFO = 42, + WLAN_EID_TS_DELAY = 43, + WLAN_EID_TCLAS_PROCESSING = 44, + WLAN_EID_HT_CAPABILITY = 45, + WLAN_EID_QOS_CAPA = 46, + WLAN_EID_RSN = 48, + WLAN_EID_802_15_COEX = 49, + WLAN_EID_EXT_SUPP_RATES = 50, + WLAN_EID_AP_CHAN_REPORT = 51, + WLAN_EID_NEIGHBOR_REPORT = 52, + WLAN_EID_RCPI = 53, + WLAN_EID_MOBILITY_DOMAIN = 54, + WLAN_EID_FAST_BSS_TRANSITION = 55, + WLAN_EID_TIMEOUT_INTERVAL = 56, + WLAN_EID_RIC_DATA = 57, + WLAN_EID_DSE_REGISTERED_LOCATION = 58, + WLAN_EID_SUPPORTED_REGULATORY_CLASSES = 59, + WLAN_EID_EXT_CHANSWITCH_ANN = 60, + WLAN_EID_HT_OPERATION = 61, + WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62, + WLAN_EID_BSS_AVG_ACCESS_DELAY = 63, + WLAN_EID_ANTENNA_INFO = 64, + WLAN_EID_RSNI = 65, + WLAN_EID_MEASUREMENT_PILOT_TX_INFO = 66, + WLAN_EID_BSS_AVAILABLE_CAPACITY = 67, + WLAN_EID_BSS_AC_ACCESS_DELAY = 68, + WLAN_EID_TIME_ADVERTISEMENT = 69, + WLAN_EID_RRM_ENABLED_CAPABILITIES = 70, + WLAN_EID_MULTIPLE_BSSID = 71, + WLAN_EID_BSS_COEX_2040 = 72, + WLAN_EID_BSS_INTOLERANT_CHL_REPORT = 73, + WLAN_EID_OVERLAP_BSS_SCAN_PARAM = 74, + WLAN_EID_RIC_DESCRIPTOR = 75, + WLAN_EID_MMIE = 76, + WLAN_EID_ASSOC_COMEBACK_TIME = 77, + WLAN_EID_EVENT_REQUEST = 78, + WLAN_EID_EVENT_REPORT = 79, + WLAN_EID_DIAGNOSTIC_REQUEST = 80, + WLAN_EID_DIAGNOSTIC_REPORT = 81, + WLAN_EID_LOCATION_PARAMS = 82, + WLAN_EID_NON_TX_BSSID_CAP = 83, + WLAN_EID_SSID_LIST = 84, + WLAN_EID_MULTI_BSSID_IDX = 85, + WLAN_EID_FMS_DESCRIPTOR = 86, + WLAN_EID_FMS_REQUEST = 87, + WLAN_EID_FMS_RESPONSE = 88, + WLAN_EID_QOS_TRAFFIC_CAPA = 89, + WLAN_EID_BSS_MAX_IDLE_PERIOD = 90, + WLAN_EID_TSF_REQUEST = 91, + WLAN_EID_TSF_RESPOSNE = 92, + WLAN_EID_WNM_SLEEP_MODE = 93, + WLAN_EID_TIM_BCAST_REQ = 94, + WLAN_EID_TIM_BCAST_RESP = 95, + WLAN_EID_COLL_IF_REPORT = 96, + WLAN_EID_CHANNEL_USAGE = 97, + WLAN_EID_TIME_ZONE = 98, + WLAN_EID_DMS_REQUEST = 99, + WLAN_EID_DMS_RESPONSE = 100, + WLAN_EID_LINK_ID = 101, + WLAN_EID_WAKEUP_SCHEDUL = 102, + WLAN_EID_CHAN_SWITCH_TIMING = 104, + WLAN_EID_PTI_CONTROL = 105, + WLAN_EID_PU_BUFFER_STATUS = 106, + WLAN_EID_INTERWORKING = 107, + WLAN_EID_ADVERTISEMENT_PROTOCOL = 108, + WLAN_EID_EXPEDITED_BW_REQ = 109, + WLAN_EID_QOS_MAP_SET = 110, + WLAN_EID_ROAMING_CONSORTIUM = 111, + WLAN_EID_EMERGENCY_ALERT = 112, + WLAN_EID_MESH_CONFIG = 113, + WLAN_EID_MESH_ID = 114, + WLAN_EID_LINK_METRIC_REPORT = 115, + WLAN_EID_CONGESTION_NOTIFICATION = 116, + WLAN_EID_PEER_MGMT = 117, + WLAN_EID_CHAN_SWITCH_PARAM = 118, + WLAN_EID_MESH_AWAKE_WINDOW = 119, + WLAN_EID_BEACON_TIMING = 120, + WLAN_EID_MCCAOP_SETUP_REQ = 121, + WLAN_EID_MCCAOP_SETUP_RESP = 122, + WLAN_EID_MCCAOP_ADVERT = 123, + WLAN_EID_MCCAOP_TEARDOWN = 124, + WLAN_EID_GANN = 125, + WLAN_EID_RANN = 126, + WLAN_EID_EXT_CAPABILITY = 127, + WLAN_EID_PREQ = 130, + WLAN_EID_PREP = 131, + WLAN_EID_PERR = 132, + WLAN_EID_PXU = 137, + WLAN_EID_PXUC = 138, + WLAN_EID_AUTH_MESH_PEER_EXCH = 139, + WLAN_EID_MIC = 140, + WLAN_EID_DESTINATION_URI = 141, + WLAN_EID_UAPSD_COEX = 142, + WLAN_EID_WAKEUP_SCHEDULE = 143, + WLAN_EID_EXT_SCHEDULE = 144, + WLAN_EID_STA_AVAILABILITY = 145, + WLAN_EID_DMG_TSPEC = 146, + WLAN_EID_DMG_AT = 147, + WLAN_EID_DMG_CAP = 148, + WLAN_EID_CISCO_VENDOR_SPECIFIC = 150, + WLAN_EID_DMG_OPERATION = 151, + WLAN_EID_DMG_BSS_PARAM_CHANGE = 152, + WLAN_EID_DMG_BEAM_REFINEMENT = 153, + WLAN_EID_CHANNEL_MEASURE_FEEDBACK = 154, + WLAN_EID_AWAKE_WINDOW = 157, + WLAN_EID_MULTI_BAND = 158, + WLAN_EID_ADDBA_EXT = 159, + WLAN_EID_NEXT_PCP_LIST = 160, + WLAN_EID_PCP_HANDOVER = 161, + WLAN_EID_DMG_LINK_MARGIN = 162, + WLAN_EID_SWITCHING_STREAM = 163, + WLAN_EID_SESSION_TRANSITION = 164, + WLAN_EID_DYN_TONE_PAIRING_REPORT = 165, + WLAN_EID_CLUSTER_REPORT = 166, + WLAN_EID_RELAY_CAP = 167, + WLAN_EID_RELAY_XFER_PARAM_SET = 168, + WLAN_EID_BEAM_LINK_MAINT = 169, + WLAN_EID_MULTIPLE_MAC_ADDR = 170, + WLAN_EID_U_PID = 171, + WLAN_EID_DMG_LINK_ADAPT_ACK = 172, + WLAN_EID_MCCAOP_ADV_OVERVIEW = 174, + WLAN_EID_QUIET_PERIOD_REQ = 175, + WLAN_EID_QUIET_PERIOD_RESP = 177, + WLAN_EID_EPAC_POLICY = 182, + WLAN_EID_CLISTER_TIME_OFF = 183, + WLAN_EID_INTER_AC_PRIO = 184, + WLAN_EID_SCS_DESCRIPTOR = 185, + WLAN_EID_QLOAD_REPORT = 186, + WLAN_EID_HCCA_TXOP_UPDATE_COUNT = 187, + WLAN_EID_HL_STREAM_ID = 188, + WLAN_EID_GCR_GROUP_ADDR = 189, + WLAN_EID_ANTENNA_SECTOR_ID_PATTERN = 190, + WLAN_EID_VHT_CAPABILITY = 191, + WLAN_EID_VHT_OPERATION = 192, + WLAN_EID_EXTENDED_BSS_LOAD = 193, + WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194, + WLAN_EID_VHT_TX_POWER_ENVELOPE = 195, + WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196, + WLAN_EID_AID = 197, + WLAN_EID_QUIET_CHANNEL = 198, + WLAN_EID_OPMODE_NOTIF = 199, + WLAN_EID_REDUCED_NEIGHBOR_REPORT = 201, + WLAN_EID_AID_REQUEST = 210, + WLAN_EID_AID_RESPONSE = 211, + WLAN_EID_S1G_BCN_COMPAT = 213, + WLAN_EID_S1G_SHORT_BCN_INTERVAL = 214, + WLAN_EID_S1G_CAPABILITIES = 217, + WLAN_EID_VENDOR_SPECIFIC = 221, + WLAN_EID_QOS_PARAMETER = 222, + WLAN_EID_S1G_OPERATION = 232, + WLAN_EID_CAG_NUMBER = 237, + WLAN_EID_AP_CSN = 239, + WLAN_EID_FILS_INDICATION = 240, + WLAN_EID_DILS = 241, + WLAN_EID_FRAGMENT = 242, + WLAN_EID_RSNX = 244, + WLAN_EID_EXTENSION = 255, +}; + +struct element { + u8 id; + u8 datalen; + u8 data[0]; +}; + +enum nl80211_he_ru_alloc { + NL80211_RATE_INFO_HE_RU_ALLOC_26 = 0, + NL80211_RATE_INFO_HE_RU_ALLOC_52 = 1, + NL80211_RATE_INFO_HE_RU_ALLOC_106 = 2, + NL80211_RATE_INFO_HE_RU_ALLOC_242 = 3, + NL80211_RATE_INFO_HE_RU_ALLOC_484 = 4, + NL80211_RATE_INFO_HE_RU_ALLOC_996 = 5, + NL80211_RATE_INFO_HE_RU_ALLOC_2x996 = 6, +}; + +enum ieee80211_channel_flags { + IEEE80211_CHAN_DISABLED = 1, + IEEE80211_CHAN_NO_IR = 2, + IEEE80211_CHAN_RADAR = 8, + IEEE80211_CHAN_NO_HT40PLUS = 16, + IEEE80211_CHAN_NO_HT40MINUS = 32, + IEEE80211_CHAN_NO_OFDM = 64, + IEEE80211_CHAN_NO_80MHZ = 128, + IEEE80211_CHAN_NO_160MHZ = 256, + IEEE80211_CHAN_INDOOR_ONLY = 512, + IEEE80211_CHAN_IR_CONCURRENT = 1024, + IEEE80211_CHAN_NO_20MHZ = 2048, + IEEE80211_CHAN_NO_10MHZ = 4096, + IEEE80211_CHAN_NO_HE = 8192, + IEEE80211_CHAN_1MHZ = 16384, + IEEE80211_CHAN_2MHZ = 32768, + IEEE80211_CHAN_4MHZ = 65536, + IEEE80211_CHAN_8MHZ = 131072, + IEEE80211_CHAN_16MHZ = 262144, +}; + +enum ieee80211_rate_flags { + IEEE80211_RATE_SHORT_PREAMBLE = 1, + IEEE80211_RATE_MANDATORY_A = 2, + IEEE80211_RATE_MANDATORY_B = 4, + IEEE80211_RATE_MANDATORY_G = 8, + IEEE80211_RATE_ERP_G = 16, + IEEE80211_RATE_SUPPORTS_5MHZ = 32, + IEEE80211_RATE_SUPPORTS_10MHZ = 64, +}; + +struct iface_combination_params { + int num_different_channels; + u8 radar_detect; + int iftype_num[13]; + u32 new_beacon_int; +}; + +enum rate_info_flags { + RATE_INFO_FLAGS_MCS = 1, + RATE_INFO_FLAGS_VHT_MCS = 2, + RATE_INFO_FLAGS_SHORT_GI = 4, + RATE_INFO_FLAGS_DMG = 8, + RATE_INFO_FLAGS_HE_MCS = 16, + RATE_INFO_FLAGS_EDMG = 32, +}; + +enum rate_info_bw { + RATE_INFO_BW_20 = 0, + RATE_INFO_BW_5 = 1, + RATE_INFO_BW_10 = 2, + RATE_INFO_BW_40 = 3, + RATE_INFO_BW_80 = 4, + RATE_INFO_BW_160 = 5, + RATE_INFO_BW_HE_RU = 6, +}; + +struct iapp_layer2_update { + u8 da[6]; + u8 sa[6]; + __be16 len; + u8 dsap; + u8 ssap; + u8 control; + u8 xid_info[3]; +}; + +enum nl80211_reg_rule_flags { + NL80211_RRF_NO_OFDM = 1, + NL80211_RRF_NO_CCK = 2, + NL80211_RRF_NO_INDOOR = 4, + NL80211_RRF_NO_OUTDOOR = 8, + NL80211_RRF_DFS = 16, + NL80211_RRF_PTP_ONLY = 32, + NL80211_RRF_PTMP_ONLY = 64, + NL80211_RRF_NO_IR = 128, + __NL80211_RRF_NO_IBSS = 256, + NL80211_RRF_AUTO_BW = 2048, + NL80211_RRF_IR_CONCURRENT = 4096, + NL80211_RRF_NO_HT40MINUS = 8192, + NL80211_RRF_NO_HT40PLUS = 16384, + NL80211_RRF_NO_80MHZ = 32768, + NL80211_RRF_NO_160MHZ = 65536, + NL80211_RRF_NO_HE = 131072, +}; + +enum nl80211_channel_type { + NL80211_CHAN_NO_HT = 0, + NL80211_CHAN_HT20 = 1, + NL80211_CHAN_HT40MINUS = 2, + NL80211_CHAN_HT40PLUS = 3, +}; + +enum ieee80211_regd_source { + REGD_SOURCE_INTERNAL_DB = 0, + REGD_SOURCE_CRDA = 1, + REGD_SOURCE_CACHED = 2, +}; + +enum reg_request_treatment { + REG_REQ_OK = 0, + REG_REQ_IGNORE = 1, + REG_REQ_INTERSECT = 2, + REG_REQ_ALREADY_SET = 3, +}; + +struct reg_beacon { + struct list_head list; + struct ieee80211_channel chan; +}; + +struct reg_regdb_apply_request { + struct list_head list; + const struct ieee80211_regdomain *regdom; +}; + +struct fwdb_country { + u8 alpha2[2]; + __be16 coll_ptr; +}; + +struct fwdb_header { + __be32 magic; + __be32 version; + struct fwdb_country country[0]; +}; + +struct fwdb_collection { + u8 len; + u8 n_rules; + u8 dfs_region; + char: 8; +}; + +enum fwdb_flags { + FWDB_FLAG_NO_OFDM = 1, + FWDB_FLAG_NO_OUTDOOR = 2, + FWDB_FLAG_DFS = 4, + FWDB_FLAG_NO_IR = 8, + FWDB_FLAG_AUTO_BW = 16, +}; + +struct fwdb_wmm_ac { + u8 ecw; + u8 aifsn; + __be16 cot; +}; + +struct fwdb_wmm_rule { + struct fwdb_wmm_ac client[4]; + struct fwdb_wmm_ac ap[4]; +}; + +struct fwdb_rule { + u8 len; + u8 flags; + __be16 max_eirp; + __be32 start; + __be32 end; + __be32 max_bw; + __be16 cac_timeout; + __be16 wmm_ptr; +}; + +enum nl80211_scan_flags { + NL80211_SCAN_FLAG_LOW_PRIORITY = 1, + NL80211_SCAN_FLAG_FLUSH = 2, + NL80211_SCAN_FLAG_AP = 4, + NL80211_SCAN_FLAG_RANDOM_ADDR = 8, + NL80211_SCAN_FLAG_FILS_MAX_CHANNEL_TIME = 16, + NL80211_SCAN_FLAG_ACCEPT_BCAST_PROBE_RESP = 32, + NL80211_SCAN_FLAG_OCE_PROBE_REQ_HIGH_TX_RATE = 64, + NL80211_SCAN_FLAG_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION = 128, + NL80211_SCAN_FLAG_LOW_SPAN = 256, + NL80211_SCAN_FLAG_LOW_POWER = 512, + NL80211_SCAN_FLAG_HIGH_ACCURACY = 1024, + NL80211_SCAN_FLAG_RANDOM_SN = 2048, + NL80211_SCAN_FLAG_MIN_PREQ_CONTENT = 4096, + NL80211_SCAN_FLAG_FREQ_KHZ = 8192, + NL80211_SCAN_FLAG_COLOCATED_6GHZ = 16384, +}; + +struct ieee80211_msrment_ie { + u8 token; + u8 mode; + u8 type; + u8 request[0]; +}; + +struct ieee80211_ext_chansw_ie { + u8 mode; + u8 new_operating_class; + u8 new_ch_num; + u8 count; +}; + +struct ieee80211_tpc_report_ie { + u8 tx_power; + u8 link_margin; +}; + +struct ieee80211_s1g_bcn_compat_ie { + __le16 compat_info; + __le16 beacon_int; + __le32 tsf_completion; +}; + +struct ieee80211_s1g_oper_ie { + u8 ch_width; + u8 oper_class; + u8 primary_ch; + u8 oper_ch; + __le16 basic_mcs_nss; +}; + +struct ieee80211_ext { + __le16 frame_control; + __le16 duration; + union { + struct { + u8 sa[6]; + __le32 timestamp; + u8 change_seq; + u8 variable[0]; + } __attribute__((packed)) s1g_beacon; + struct { + u8 sa[6]; + __le32 timestamp; + u8 change_seq; + u8 next_tbtt[3]; + u8 variable[0]; + } __attribute__((packed)) s1g_short_beacon; + } u; +} __attribute__((packed)); + +struct ieee80211_mgmt { + __le16 frame_control; + __le16 duration; + u8 da[6]; + u8 sa[6]; + u8 bssid[6]; + __le16 seq_ctrl; + union { + struct { + __le16 auth_alg; + __le16 auth_transaction; + __le16 status_code; + u8 variable[0]; + } auth; + struct { + __le16 reason_code; + } deauth; + struct { + __le16 capab_info; + __le16 listen_interval; + u8 variable[0]; + } assoc_req; + struct { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8 variable[0]; + } assoc_resp; + struct { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8 variable[0]; + } reassoc_resp; + struct { + __le16 capab_info; + __le16 status_code; + u8 variable[0]; + } s1g_assoc_resp; + struct { + __le16 capab_info; + __le16 status_code; + u8 variable[0]; + } s1g_reassoc_resp; + struct { + __le16 capab_info; + __le16 listen_interval; + u8 current_ap[6]; + u8 variable[0]; + } reassoc_req; + struct { + __le16 reason_code; + } disassoc; + struct { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8 variable[0]; + } __attribute__((packed)) beacon; + struct { + u8 variable[0]; + } probe_req; + struct { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8 variable[0]; + } __attribute__((packed)) probe_resp; + struct { + u8 category; + union { + struct { + u8 action_code; + u8 dialog_token; + u8 status_code; + u8 variable[0]; + } wme_action; + struct { + u8 action_code; + u8 variable[0]; + } chan_switch; + struct { + u8 action_code; + struct ieee80211_ext_chansw_ie data; + u8 variable[0]; + } ext_chan_switch; + struct { + u8 action_code; + u8 dialog_token; + u8 element_id; + u8 length; + struct ieee80211_msrment_ie msr_elem; + } measurement; + struct { + u8 action_code; + u8 dialog_token; + __le16 capab; + __le16 timeout; + __le16 start_seq_num; + u8 variable[0]; + } addba_req; + struct { + u8 action_code; + u8 dialog_token; + __le16 status; + __le16 capab; + __le16 timeout; + } addba_resp; + struct { + u8 action_code; + __le16 params; + __le16 reason_code; + } __attribute__((packed)) delba; + struct { + u8 action_code; + u8 variable[0]; + } self_prot; + struct { + u8 action_code; + u8 variable[0]; + } mesh_action; + struct { + u8 action; + u8 trans_id[2]; + } sa_query; + struct { + u8 action; + u8 smps_control; + } ht_smps; + struct { + u8 action_code; + u8 chanwidth; + } ht_notify_cw; + struct { + u8 action_code; + u8 dialog_token; + __le16 capability; + u8 variable[0]; + } tdls_discover_resp; + struct { + u8 action_code; + u8 operating_mode; + } vht_opmode_notif; + struct { + u8 action_code; + u8 membership[8]; + u8 position[16]; + } vht_group_notif; + struct { + u8 action_code; + u8 dialog_token; + u8 tpc_elem_id; + u8 tpc_elem_length; + struct ieee80211_tpc_report_ie tpc; + } tpc_report; + struct { + u8 action_code; + u8 dialog_token; + u8 follow_up; + u8 tod[6]; + u8 toa[6]; + __le16 tod_error; + __le16 toa_error; + u8 variable[0]; + } __attribute__((packed)) ftm; + } u; + } __attribute__((packed)) action; + } u; +} __attribute__((packed)); + +struct ieee80211_ht_operation { + u8 primary_chan; + u8 ht_param; + __le16 operation_mode; + __le16 stbc_param; + u8 basic_set[16]; +}; + +enum ieee80211_eid_ext { + WLAN_EID_EXT_ASSOC_DELAY_INFO = 1, + WLAN_EID_EXT_FILS_REQ_PARAMS = 2, + WLAN_EID_EXT_FILS_KEY_CONFIRM = 3, + WLAN_EID_EXT_FILS_SESSION = 4, + WLAN_EID_EXT_FILS_HLP_CONTAINER = 5, + WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN = 6, + WLAN_EID_EXT_KEY_DELIVERY = 7, + WLAN_EID_EXT_FILS_WRAPPED_DATA = 8, + WLAN_EID_EXT_FILS_PUBLIC_KEY = 12, + WLAN_EID_EXT_FILS_NONCE = 13, + WLAN_EID_EXT_FUTURE_CHAN_GUIDANCE = 14, + WLAN_EID_EXT_HE_CAPABILITY = 35, + WLAN_EID_EXT_HE_OPERATION = 36, + WLAN_EID_EXT_UORA = 37, + WLAN_EID_EXT_HE_MU_EDCA = 38, + WLAN_EID_EXT_HE_SPR = 39, + WLAN_EID_EXT_NDP_FEEDBACK_REPORT_PARAMSET = 41, + WLAN_EID_EXT_BSS_COLOR_CHG_ANN = 42, + WLAN_EID_EXT_QUIET_TIME_PERIOD_SETUP = 43, + WLAN_EID_EXT_ESS_REPORT = 45, + WLAN_EID_EXT_OPS = 46, + WLAN_EID_EXT_HE_BSS_LOAD = 47, + WLAN_EID_EXT_MAX_CHANNEL_SWITCH_TIME = 52, + WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION = 55, + WLAN_EID_EXT_NON_INHERITANCE = 56, + WLAN_EID_EXT_KNOWN_BSSID = 57, + WLAN_EID_EXT_SHORT_SSID_LIST = 58, + WLAN_EID_EXT_HE_6GHZ_CAPA = 59, + WLAN_EID_EXT_UL_MU_POWER_CAPA = 60, +}; + +struct ieee80211_neighbor_ap_info { + u8 tbtt_info_hdr; + u8 tbtt_info_len; + u8 op_class; + u8 channel; +}; + +enum ieee80211_privacy { + IEEE80211_PRIVACY_ON = 0, + IEEE80211_PRIVACY_OFF = 1, + IEEE80211_PRIVACY_ANY = 2, +}; + +struct cfg80211_inform_bss { + struct ieee80211_channel *chan; + enum nl80211_bss_scan_width scan_width; + s32 signal; + u64 boottime_ns; + u64 parent_tsf; + u8 parent_bssid[6]; + u8 chains; + s8 chain_signal[4]; +}; + +enum cfg80211_bss_frame_type { + CFG80211_BSS_FTYPE_UNKNOWN = 0, + CFG80211_BSS_FTYPE_BEACON = 1, + CFG80211_BSS_FTYPE_PRESP = 2, +}; + +struct cfg80211_colocated_ap { + struct list_head list; + u8 bssid[6]; + u8 ssid[32]; + size_t ssid_len; + u32 short_ssid; + u32 center_freq; + u8 unsolicited_probe: 1; + u8 oct_recommended: 1; + u8 same_ssid: 1; + u8 multi_bss: 1; + u8 transmitted_bssid: 1; + u8 colocated_ess: 1; + u8 short_ssid_valid: 1; +}; + +enum bss_compare_mode { + BSS_CMP_REGULAR = 0, + BSS_CMP_HIDE_ZLEN = 1, + BSS_CMP_HIDE_NUL = 2, +}; + +struct cfg80211_non_tx_bss { + struct cfg80211_bss *tx_bss; + u8 max_bssid_indicator; + u8 bssid_index; +}; + +enum ieee80211_vht_mcs_support { + IEEE80211_VHT_MCS_SUPPORT_0_7 = 0, + IEEE80211_VHT_MCS_SUPPORT_0_8 = 1, + IEEE80211_VHT_MCS_SUPPORT_0_9 = 2, + IEEE80211_VHT_MCS_NOT_SUPPORTED = 3, +}; + +enum ieee80211_he_mcs_support { + IEEE80211_HE_MCS_SUPPORT_0_7 = 0, + IEEE80211_HE_MCS_SUPPORT_0_9 = 1, + IEEE80211_HE_MCS_SUPPORT_0_11 = 2, + IEEE80211_HE_MCS_NOT_SUPPORTED = 3, +}; + +enum ieee80211_mesh_sync_method { + IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET = 1, + IEEE80211_SYNC_METHOD_VENDOR = 255, +}; + +enum ieee80211_mesh_path_protocol { + IEEE80211_PATH_PROTOCOL_HWMP = 1, + IEEE80211_PATH_PROTOCOL_VENDOR = 255, +}; + +enum ieee80211_mesh_path_metric { + IEEE80211_PATH_METRIC_AIRTIME = 1, + IEEE80211_PATH_METRIC_VENDOR = 255, +}; + +enum nl80211_attrs { + NL80211_ATTR_UNSPEC = 0, + NL80211_ATTR_WIPHY = 1, + NL80211_ATTR_WIPHY_NAME = 2, + NL80211_ATTR_IFINDEX = 3, + NL80211_ATTR_IFNAME = 4, + NL80211_ATTR_IFTYPE = 5, + NL80211_ATTR_MAC = 6, + NL80211_ATTR_KEY_DATA = 7, + NL80211_ATTR_KEY_IDX = 8, + NL80211_ATTR_KEY_CIPHER = 9, + NL80211_ATTR_KEY_SEQ = 10, + NL80211_ATTR_KEY_DEFAULT = 11, + NL80211_ATTR_BEACON_INTERVAL = 12, + NL80211_ATTR_DTIM_PERIOD = 13, + NL80211_ATTR_BEACON_HEAD = 14, + NL80211_ATTR_BEACON_TAIL = 15, + NL80211_ATTR_STA_AID = 16, + NL80211_ATTR_STA_FLAGS = 17, + NL80211_ATTR_STA_LISTEN_INTERVAL = 18, + NL80211_ATTR_STA_SUPPORTED_RATES = 19, + NL80211_ATTR_STA_VLAN = 20, + NL80211_ATTR_STA_INFO = 21, + NL80211_ATTR_WIPHY_BANDS = 22, + NL80211_ATTR_MNTR_FLAGS = 23, + NL80211_ATTR_MESH_ID = 24, + NL80211_ATTR_STA_PLINK_ACTION = 25, + NL80211_ATTR_MPATH_NEXT_HOP = 26, + NL80211_ATTR_MPATH_INFO = 27, + NL80211_ATTR_BSS_CTS_PROT = 28, + NL80211_ATTR_BSS_SHORT_PREAMBLE = 29, + NL80211_ATTR_BSS_SHORT_SLOT_TIME = 30, + NL80211_ATTR_HT_CAPABILITY = 31, + NL80211_ATTR_SUPPORTED_IFTYPES = 32, + NL80211_ATTR_REG_ALPHA2 = 33, + NL80211_ATTR_REG_RULES = 34, + NL80211_ATTR_MESH_CONFIG = 35, + NL80211_ATTR_BSS_BASIC_RATES = 36, + NL80211_ATTR_WIPHY_TXQ_PARAMS = 37, + NL80211_ATTR_WIPHY_FREQ = 38, + NL80211_ATTR_WIPHY_CHANNEL_TYPE = 39, + NL80211_ATTR_KEY_DEFAULT_MGMT = 40, + NL80211_ATTR_MGMT_SUBTYPE = 41, + NL80211_ATTR_IE = 42, + NL80211_ATTR_MAX_NUM_SCAN_SSIDS = 43, + NL80211_ATTR_SCAN_FREQUENCIES = 44, + NL80211_ATTR_SCAN_SSIDS = 45, + NL80211_ATTR_GENERATION = 46, + NL80211_ATTR_BSS = 47, + NL80211_ATTR_REG_INITIATOR = 48, + NL80211_ATTR_REG_TYPE = 49, + NL80211_ATTR_SUPPORTED_COMMANDS = 50, + NL80211_ATTR_FRAME = 51, + NL80211_ATTR_SSID = 52, + NL80211_ATTR_AUTH_TYPE = 53, + NL80211_ATTR_REASON_CODE = 54, + NL80211_ATTR_KEY_TYPE = 55, + NL80211_ATTR_MAX_SCAN_IE_LEN = 56, + NL80211_ATTR_CIPHER_SUITES = 57, + NL80211_ATTR_FREQ_BEFORE = 58, + NL80211_ATTR_FREQ_AFTER = 59, + NL80211_ATTR_FREQ_FIXED = 60, + NL80211_ATTR_WIPHY_RETRY_SHORT = 61, + NL80211_ATTR_WIPHY_RETRY_LONG = 62, + NL80211_ATTR_WIPHY_FRAG_THRESHOLD = 63, + NL80211_ATTR_WIPHY_RTS_THRESHOLD = 64, + NL80211_ATTR_TIMED_OUT = 65, + NL80211_ATTR_USE_MFP = 66, + NL80211_ATTR_STA_FLAGS2 = 67, + NL80211_ATTR_CONTROL_PORT = 68, + NL80211_ATTR_TESTDATA = 69, + NL80211_ATTR_PRIVACY = 70, + NL80211_ATTR_DISCONNECTED_BY_AP = 71, + NL80211_ATTR_STATUS_CODE = 72, + NL80211_ATTR_CIPHER_SUITES_PAIRWISE = 73, + NL80211_ATTR_CIPHER_SUITE_GROUP = 74, + NL80211_ATTR_WPA_VERSIONS = 75, + NL80211_ATTR_AKM_SUITES = 76, + NL80211_ATTR_REQ_IE = 77, + NL80211_ATTR_RESP_IE = 78, + NL80211_ATTR_PREV_BSSID = 79, + NL80211_ATTR_KEY = 80, + NL80211_ATTR_KEYS = 81, + NL80211_ATTR_PID = 82, + NL80211_ATTR_4ADDR = 83, + NL80211_ATTR_SURVEY_INFO = 84, + NL80211_ATTR_PMKID = 85, + NL80211_ATTR_MAX_NUM_PMKIDS = 86, + NL80211_ATTR_DURATION = 87, + NL80211_ATTR_COOKIE = 88, + NL80211_ATTR_WIPHY_COVERAGE_CLASS = 89, + NL80211_ATTR_TX_RATES = 90, + NL80211_ATTR_FRAME_MATCH = 91, + NL80211_ATTR_ACK = 92, + NL80211_ATTR_PS_STATE = 93, + NL80211_ATTR_CQM = 94, + NL80211_ATTR_LOCAL_STATE_CHANGE = 95, + NL80211_ATTR_AP_ISOLATE = 96, + NL80211_ATTR_WIPHY_TX_POWER_SETTING = 97, + NL80211_ATTR_WIPHY_TX_POWER_LEVEL = 98, + NL80211_ATTR_TX_FRAME_TYPES = 99, + NL80211_ATTR_RX_FRAME_TYPES = 100, + NL80211_ATTR_FRAME_TYPE = 101, + NL80211_ATTR_CONTROL_PORT_ETHERTYPE = 102, + NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT = 103, + NL80211_ATTR_SUPPORT_IBSS_RSN = 104, + NL80211_ATTR_WIPHY_ANTENNA_TX = 105, + NL80211_ATTR_WIPHY_ANTENNA_RX = 106, + NL80211_ATTR_MCAST_RATE = 107, + NL80211_ATTR_OFFCHANNEL_TX_OK = 108, + NL80211_ATTR_BSS_HT_OPMODE = 109, + NL80211_ATTR_KEY_DEFAULT_TYPES = 110, + NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION = 111, + NL80211_ATTR_MESH_SETUP = 112, + NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX = 113, + NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX = 114, + NL80211_ATTR_SUPPORT_MESH_AUTH = 115, + NL80211_ATTR_STA_PLINK_STATE = 116, + NL80211_ATTR_WOWLAN_TRIGGERS = 117, + NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED = 118, + NL80211_ATTR_SCHED_SCAN_INTERVAL = 119, + NL80211_ATTR_INTERFACE_COMBINATIONS = 120, + NL80211_ATTR_SOFTWARE_IFTYPES = 121, + NL80211_ATTR_REKEY_DATA = 122, + NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS = 123, + NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN = 124, + NL80211_ATTR_SCAN_SUPP_RATES = 125, + NL80211_ATTR_HIDDEN_SSID = 126, + NL80211_ATTR_IE_PROBE_RESP = 127, + NL80211_ATTR_IE_ASSOC_RESP = 128, + NL80211_ATTR_STA_WME = 129, + NL80211_ATTR_SUPPORT_AP_UAPSD = 130, + NL80211_ATTR_ROAM_SUPPORT = 131, + NL80211_ATTR_SCHED_SCAN_MATCH = 132, + NL80211_ATTR_MAX_MATCH_SETS = 133, + NL80211_ATTR_PMKSA_CANDIDATE = 134, + NL80211_ATTR_TX_NO_CCK_RATE = 135, + NL80211_ATTR_TDLS_ACTION = 136, + NL80211_ATTR_TDLS_DIALOG_TOKEN = 137, + NL80211_ATTR_TDLS_OPERATION = 138, + NL80211_ATTR_TDLS_SUPPORT = 139, + NL80211_ATTR_TDLS_EXTERNAL_SETUP = 140, + NL80211_ATTR_DEVICE_AP_SME = 141, + NL80211_ATTR_DONT_WAIT_FOR_ACK = 142, + NL80211_ATTR_FEATURE_FLAGS = 143, + NL80211_ATTR_PROBE_RESP_OFFLOAD = 144, + NL80211_ATTR_PROBE_RESP = 145, + NL80211_ATTR_DFS_REGION = 146, + NL80211_ATTR_DISABLE_HT = 147, + NL80211_ATTR_HT_CAPABILITY_MASK = 148, + NL80211_ATTR_NOACK_MAP = 149, + NL80211_ATTR_INACTIVITY_TIMEOUT = 150, + NL80211_ATTR_RX_SIGNAL_DBM = 151, + NL80211_ATTR_BG_SCAN_PERIOD = 152, + NL80211_ATTR_WDEV = 153, + NL80211_ATTR_USER_REG_HINT_TYPE = 154, + NL80211_ATTR_CONN_FAILED_REASON = 155, + NL80211_ATTR_AUTH_DATA = 156, + NL80211_ATTR_VHT_CAPABILITY = 157, + NL80211_ATTR_SCAN_FLAGS = 158, + NL80211_ATTR_CHANNEL_WIDTH = 159, + NL80211_ATTR_CENTER_FREQ1 = 160, + NL80211_ATTR_CENTER_FREQ2 = 161, + NL80211_ATTR_P2P_CTWINDOW = 162, + NL80211_ATTR_P2P_OPPPS = 163, + NL80211_ATTR_LOCAL_MESH_POWER_MODE = 164, + NL80211_ATTR_ACL_POLICY = 165, + NL80211_ATTR_MAC_ADDRS = 166, + NL80211_ATTR_MAC_ACL_MAX = 167, + NL80211_ATTR_RADAR_EVENT = 168, + NL80211_ATTR_EXT_CAPA = 169, + NL80211_ATTR_EXT_CAPA_MASK = 170, + NL80211_ATTR_STA_CAPABILITY = 171, + NL80211_ATTR_STA_EXT_CAPABILITY = 172, + NL80211_ATTR_PROTOCOL_FEATURES = 173, + NL80211_ATTR_SPLIT_WIPHY_DUMP = 174, + NL80211_ATTR_DISABLE_VHT = 175, + NL80211_ATTR_VHT_CAPABILITY_MASK = 176, + NL80211_ATTR_MDID = 177, + NL80211_ATTR_IE_RIC = 178, + NL80211_ATTR_CRIT_PROT_ID = 179, + NL80211_ATTR_MAX_CRIT_PROT_DURATION = 180, + NL80211_ATTR_PEER_AID = 181, + NL80211_ATTR_COALESCE_RULE = 182, + NL80211_ATTR_CH_SWITCH_COUNT = 183, + NL80211_ATTR_CH_SWITCH_BLOCK_TX = 184, + NL80211_ATTR_CSA_IES = 185, + NL80211_ATTR_CNTDWN_OFFS_BEACON = 186, + NL80211_ATTR_CNTDWN_OFFS_PRESP = 187, + NL80211_ATTR_RXMGMT_FLAGS = 188, + NL80211_ATTR_STA_SUPPORTED_CHANNELS = 189, + NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES = 190, + NL80211_ATTR_HANDLE_DFS = 191, + NL80211_ATTR_SUPPORT_5_MHZ = 192, + NL80211_ATTR_SUPPORT_10_MHZ = 193, + NL80211_ATTR_OPMODE_NOTIF = 194, + NL80211_ATTR_VENDOR_ID = 195, + NL80211_ATTR_VENDOR_SUBCMD = 196, + NL80211_ATTR_VENDOR_DATA = 197, + NL80211_ATTR_VENDOR_EVENTS = 198, + NL80211_ATTR_QOS_MAP = 199, + NL80211_ATTR_MAC_HINT = 200, + NL80211_ATTR_WIPHY_FREQ_HINT = 201, + NL80211_ATTR_MAX_AP_ASSOC_STA = 202, + NL80211_ATTR_TDLS_PEER_CAPABILITY = 203, + NL80211_ATTR_SOCKET_OWNER = 204, + NL80211_ATTR_CSA_C_OFFSETS_TX = 205, + NL80211_ATTR_MAX_CSA_COUNTERS = 206, + NL80211_ATTR_TDLS_INITIATOR = 207, + NL80211_ATTR_USE_RRM = 208, + NL80211_ATTR_WIPHY_DYN_ACK = 209, + NL80211_ATTR_TSID = 210, + NL80211_ATTR_USER_PRIO = 211, + NL80211_ATTR_ADMITTED_TIME = 212, + NL80211_ATTR_SMPS_MODE = 213, + NL80211_ATTR_OPER_CLASS = 214, + NL80211_ATTR_MAC_MASK = 215, + NL80211_ATTR_WIPHY_SELF_MANAGED_REG = 216, + NL80211_ATTR_EXT_FEATURES = 217, + NL80211_ATTR_SURVEY_RADIO_STATS = 218, + NL80211_ATTR_NETNS_FD = 219, + NL80211_ATTR_SCHED_SCAN_DELAY = 220, + NL80211_ATTR_REG_INDOOR = 221, + NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS = 222, + NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL = 223, + NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS = 224, + NL80211_ATTR_SCHED_SCAN_PLANS = 225, + NL80211_ATTR_PBSS = 226, + NL80211_ATTR_BSS_SELECT = 227, + NL80211_ATTR_STA_SUPPORT_P2P_PS = 228, + NL80211_ATTR_PAD = 229, + NL80211_ATTR_IFTYPE_EXT_CAPA = 230, + NL80211_ATTR_MU_MIMO_GROUP_DATA = 231, + NL80211_ATTR_MU_MIMO_FOLLOW_MAC_ADDR = 232, + NL80211_ATTR_SCAN_START_TIME_TSF = 233, + NL80211_ATTR_SCAN_START_TIME_TSF_BSSID = 234, + NL80211_ATTR_MEASUREMENT_DURATION = 235, + NL80211_ATTR_MEASUREMENT_DURATION_MANDATORY = 236, + NL80211_ATTR_MESH_PEER_AID = 237, + NL80211_ATTR_NAN_MASTER_PREF = 238, + NL80211_ATTR_BANDS = 239, + NL80211_ATTR_NAN_FUNC = 240, + NL80211_ATTR_NAN_MATCH = 241, + NL80211_ATTR_FILS_KEK = 242, + NL80211_ATTR_FILS_NONCES = 243, + NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED = 244, + NL80211_ATTR_BSSID = 245, + NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI = 246, + NL80211_ATTR_SCHED_SCAN_RSSI_ADJUST = 247, + NL80211_ATTR_TIMEOUT_REASON = 248, + NL80211_ATTR_FILS_ERP_USERNAME = 249, + NL80211_ATTR_FILS_ERP_REALM = 250, + NL80211_ATTR_FILS_ERP_NEXT_SEQ_NUM = 251, + NL80211_ATTR_FILS_ERP_RRK = 252, + NL80211_ATTR_FILS_CACHE_ID = 253, + NL80211_ATTR_PMK = 254, + NL80211_ATTR_SCHED_SCAN_MULTI = 255, + NL80211_ATTR_SCHED_SCAN_MAX_REQS = 256, + NL80211_ATTR_WANT_1X_4WAY_HS = 257, + NL80211_ATTR_PMKR0_NAME = 258, + NL80211_ATTR_PORT_AUTHORIZED = 259, + NL80211_ATTR_EXTERNAL_AUTH_ACTION = 260, + NL80211_ATTR_EXTERNAL_AUTH_SUPPORT = 261, + NL80211_ATTR_NSS = 262, + NL80211_ATTR_ACK_SIGNAL = 263, + NL80211_ATTR_CONTROL_PORT_OVER_NL80211 = 264, + NL80211_ATTR_TXQ_STATS = 265, + NL80211_ATTR_TXQ_LIMIT = 266, + NL80211_ATTR_TXQ_MEMORY_LIMIT = 267, + NL80211_ATTR_TXQ_QUANTUM = 268, + NL80211_ATTR_HE_CAPABILITY = 269, + NL80211_ATTR_FTM_RESPONDER = 270, + NL80211_ATTR_FTM_RESPONDER_STATS = 271, + NL80211_ATTR_TIMEOUT = 272, + NL80211_ATTR_PEER_MEASUREMENTS = 273, + NL80211_ATTR_AIRTIME_WEIGHT = 274, + NL80211_ATTR_STA_TX_POWER_SETTING = 275, + NL80211_ATTR_STA_TX_POWER = 276, + NL80211_ATTR_SAE_PASSWORD = 277, + NL80211_ATTR_TWT_RESPONDER = 278, + NL80211_ATTR_HE_OBSS_PD = 279, + NL80211_ATTR_WIPHY_EDMG_CHANNELS = 280, + NL80211_ATTR_WIPHY_EDMG_BW_CONFIG = 281, + NL80211_ATTR_VLAN_ID = 282, + NL80211_ATTR_HE_BSS_COLOR = 283, + NL80211_ATTR_IFTYPE_AKM_SUITES = 284, + NL80211_ATTR_TID_CONFIG = 285, + NL80211_ATTR_CONTROL_PORT_NO_PREAUTH = 286, + NL80211_ATTR_PMK_LIFETIME = 287, + NL80211_ATTR_PMK_REAUTH_THRESHOLD = 288, + NL80211_ATTR_RECEIVE_MULTICAST = 289, + NL80211_ATTR_WIPHY_FREQ_OFFSET = 290, + NL80211_ATTR_CENTER_FREQ1_OFFSET = 291, + NL80211_ATTR_SCAN_FREQ_KHZ = 292, + NL80211_ATTR_HE_6GHZ_CAPABILITY = 293, + NL80211_ATTR_FILS_DISCOVERY = 294, + NL80211_ATTR_UNSOL_BCAST_PROBE_RESP = 295, + NL80211_ATTR_S1G_CAPABILITY = 296, + NL80211_ATTR_S1G_CAPABILITY_MASK = 297, + NL80211_ATTR_SAE_PWE = 298, + __NL80211_ATTR_AFTER_LAST = 299, + NUM_NL80211_ATTR = 299, + NL80211_ATTR_MAX = 298, +}; + +enum nl80211_sta_flags { + __NL80211_STA_FLAG_INVALID = 0, + NL80211_STA_FLAG_AUTHORIZED = 1, + NL80211_STA_FLAG_SHORT_PREAMBLE = 2, + NL80211_STA_FLAG_WME = 3, + NL80211_STA_FLAG_MFP = 4, + NL80211_STA_FLAG_AUTHENTICATED = 5, + NL80211_STA_FLAG_TDLS_PEER = 6, + NL80211_STA_FLAG_ASSOCIATED = 7, + __NL80211_STA_FLAG_AFTER_LAST = 8, + NL80211_STA_FLAG_MAX = 7, +}; + +enum nl80211_sta_p2p_ps_status { + NL80211_P2P_PS_UNSUPPORTED = 0, + NL80211_P2P_PS_SUPPORTED = 1, + NUM_NL80211_P2P_PS_STATUS = 2, +}; + +enum nl80211_rate_info { + __NL80211_RATE_INFO_INVALID = 0, + NL80211_RATE_INFO_BITRATE = 1, + NL80211_RATE_INFO_MCS = 2, + NL80211_RATE_INFO_40_MHZ_WIDTH = 3, + NL80211_RATE_INFO_SHORT_GI = 4, + NL80211_RATE_INFO_BITRATE32 = 5, + NL80211_RATE_INFO_VHT_MCS = 6, + NL80211_RATE_INFO_VHT_NSS = 7, + NL80211_RATE_INFO_80_MHZ_WIDTH = 8, + NL80211_RATE_INFO_80P80_MHZ_WIDTH = 9, + NL80211_RATE_INFO_160_MHZ_WIDTH = 10, + NL80211_RATE_INFO_10_MHZ_WIDTH = 11, + NL80211_RATE_INFO_5_MHZ_WIDTH = 12, + NL80211_RATE_INFO_HE_MCS = 13, + NL80211_RATE_INFO_HE_NSS = 14, + NL80211_RATE_INFO_HE_GI = 15, + NL80211_RATE_INFO_HE_DCM = 16, + NL80211_RATE_INFO_HE_RU_ALLOC = 17, + __NL80211_RATE_INFO_AFTER_LAST = 18, + NL80211_RATE_INFO_MAX = 17, +}; + +enum nl80211_sta_bss_param { + __NL80211_STA_BSS_PARAM_INVALID = 0, + NL80211_STA_BSS_PARAM_CTS_PROT = 1, + NL80211_STA_BSS_PARAM_SHORT_PREAMBLE = 2, + NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME = 3, + NL80211_STA_BSS_PARAM_DTIM_PERIOD = 4, + NL80211_STA_BSS_PARAM_BEACON_INTERVAL = 5, + __NL80211_STA_BSS_PARAM_AFTER_LAST = 6, + NL80211_STA_BSS_PARAM_MAX = 5, +}; + +enum nl80211_sta_info { + __NL80211_STA_INFO_INVALID = 0, + NL80211_STA_INFO_INACTIVE_TIME = 1, + NL80211_STA_INFO_RX_BYTES = 2, + NL80211_STA_INFO_TX_BYTES = 3, + NL80211_STA_INFO_LLID = 4, + NL80211_STA_INFO_PLID = 5, + NL80211_STA_INFO_PLINK_STATE = 6, + NL80211_STA_INFO_SIGNAL = 7, + NL80211_STA_INFO_TX_BITRATE = 8, + NL80211_STA_INFO_RX_PACKETS = 9, + NL80211_STA_INFO_TX_PACKETS = 10, + NL80211_STA_INFO_TX_RETRIES = 11, + NL80211_STA_INFO_TX_FAILED = 12, + NL80211_STA_INFO_SIGNAL_AVG = 13, + NL80211_STA_INFO_RX_BITRATE = 14, + NL80211_STA_INFO_BSS_PARAM = 15, + NL80211_STA_INFO_CONNECTED_TIME = 16, + NL80211_STA_INFO_STA_FLAGS = 17, + NL80211_STA_INFO_BEACON_LOSS = 18, + NL80211_STA_INFO_T_OFFSET = 19, + NL80211_STA_INFO_LOCAL_PM = 20, + NL80211_STA_INFO_PEER_PM = 21, + NL80211_STA_INFO_NONPEER_PM = 22, + NL80211_STA_INFO_RX_BYTES64 = 23, + NL80211_STA_INFO_TX_BYTES64 = 24, + NL80211_STA_INFO_CHAIN_SIGNAL = 25, + NL80211_STA_INFO_CHAIN_SIGNAL_AVG = 26, + NL80211_STA_INFO_EXPECTED_THROUGHPUT = 27, + NL80211_STA_INFO_RX_DROP_MISC = 28, + NL80211_STA_INFO_BEACON_RX = 29, + NL80211_STA_INFO_BEACON_SIGNAL_AVG = 30, + NL80211_STA_INFO_TID_STATS = 31, + NL80211_STA_INFO_RX_DURATION = 32, + NL80211_STA_INFO_PAD = 33, + NL80211_STA_INFO_ACK_SIGNAL = 34, + NL80211_STA_INFO_ACK_SIGNAL_AVG = 35, + NL80211_STA_INFO_RX_MPDUS = 36, + NL80211_STA_INFO_FCS_ERROR_COUNT = 37, + NL80211_STA_INFO_CONNECTED_TO_GATE = 38, + NL80211_STA_INFO_TX_DURATION = 39, + NL80211_STA_INFO_AIRTIME_WEIGHT = 40, + NL80211_STA_INFO_AIRTIME_LINK_METRIC = 41, + NL80211_STA_INFO_ASSOC_AT_BOOTTIME = 42, + NL80211_STA_INFO_CONNECTED_TO_AS = 43, + __NL80211_STA_INFO_AFTER_LAST = 44, + NL80211_STA_INFO_MAX = 43, +}; + +enum nl80211_tid_stats { + __NL80211_TID_STATS_INVALID = 0, + NL80211_TID_STATS_RX_MSDU = 1, + NL80211_TID_STATS_TX_MSDU = 2, + NL80211_TID_STATS_TX_MSDU_RETRIES = 3, + NL80211_TID_STATS_TX_MSDU_FAILED = 4, + NL80211_TID_STATS_PAD = 5, + NL80211_TID_STATS_TXQ_STATS = 6, + NUM_NL80211_TID_STATS = 7, + NL80211_TID_STATS_MAX = 6, +}; + +enum nl80211_txq_stats { + __NL80211_TXQ_STATS_INVALID = 0, + NL80211_TXQ_STATS_BACKLOG_BYTES = 1, + NL80211_TXQ_STATS_BACKLOG_PACKETS = 2, + NL80211_TXQ_STATS_FLOWS = 3, + NL80211_TXQ_STATS_DROPS = 4, + NL80211_TXQ_STATS_ECN_MARKS = 5, + NL80211_TXQ_STATS_OVERLIMIT = 6, + NL80211_TXQ_STATS_OVERMEMORY = 7, + NL80211_TXQ_STATS_COLLISIONS = 8, + NL80211_TXQ_STATS_TX_BYTES = 9, + NL80211_TXQ_STATS_TX_PACKETS = 10, + NL80211_TXQ_STATS_MAX_FLOWS = 11, + NUM_NL80211_TXQ_STATS = 12, + NL80211_TXQ_STATS_MAX = 11, +}; + +enum nl80211_mpath_info { + __NL80211_MPATH_INFO_INVALID = 0, + NL80211_MPATH_INFO_FRAME_QLEN = 1, + NL80211_MPATH_INFO_SN = 2, + NL80211_MPATH_INFO_METRIC = 3, + NL80211_MPATH_INFO_EXPTIME = 4, + NL80211_MPATH_INFO_FLAGS = 5, + NL80211_MPATH_INFO_DISCOVERY_TIMEOUT = 6, + NL80211_MPATH_INFO_DISCOVERY_RETRIES = 7, + NL80211_MPATH_INFO_HOP_COUNT = 8, + NL80211_MPATH_INFO_PATH_CHANGE = 9, + __NL80211_MPATH_INFO_AFTER_LAST = 10, + NL80211_MPATH_INFO_MAX = 9, +}; + +enum nl80211_band_iftype_attr { + __NL80211_BAND_IFTYPE_ATTR_INVALID = 0, + NL80211_BAND_IFTYPE_ATTR_IFTYPES = 1, + NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC = 2, + NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY = 3, + NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET = 4, + NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE = 5, + NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA = 6, + __NL80211_BAND_IFTYPE_ATTR_AFTER_LAST = 7, + NL80211_BAND_IFTYPE_ATTR_MAX = 6, +}; + +enum nl80211_band_attr { + __NL80211_BAND_ATTR_INVALID = 0, + NL80211_BAND_ATTR_FREQS = 1, + NL80211_BAND_ATTR_RATES = 2, + NL80211_BAND_ATTR_HT_MCS_SET = 3, + NL80211_BAND_ATTR_HT_CAPA = 4, + NL80211_BAND_ATTR_HT_AMPDU_FACTOR = 5, + NL80211_BAND_ATTR_HT_AMPDU_DENSITY = 6, + NL80211_BAND_ATTR_VHT_MCS_SET = 7, + NL80211_BAND_ATTR_VHT_CAPA = 8, + NL80211_BAND_ATTR_IFTYPE_DATA = 9, + NL80211_BAND_ATTR_EDMG_CHANNELS = 10, + NL80211_BAND_ATTR_EDMG_BW_CONFIG = 11, + __NL80211_BAND_ATTR_AFTER_LAST = 12, + NL80211_BAND_ATTR_MAX = 11, +}; + +enum nl80211_wmm_rule { + __NL80211_WMMR_INVALID = 0, + NL80211_WMMR_CW_MIN = 1, + NL80211_WMMR_CW_MAX = 2, + NL80211_WMMR_AIFSN = 3, + NL80211_WMMR_TXOP = 4, + __NL80211_WMMR_LAST = 5, + NL80211_WMMR_MAX = 4, +}; + +enum nl80211_frequency_attr { + __NL80211_FREQUENCY_ATTR_INVALID = 0, + NL80211_FREQUENCY_ATTR_FREQ = 1, + NL80211_FREQUENCY_ATTR_DISABLED = 2, + NL80211_FREQUENCY_ATTR_NO_IR = 3, + __NL80211_FREQUENCY_ATTR_NO_IBSS = 4, + NL80211_FREQUENCY_ATTR_RADAR = 5, + NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 6, + NL80211_FREQUENCY_ATTR_DFS_STATE = 7, + NL80211_FREQUENCY_ATTR_DFS_TIME = 8, + NL80211_FREQUENCY_ATTR_NO_HT40_MINUS = 9, + NL80211_FREQUENCY_ATTR_NO_HT40_PLUS = 10, + NL80211_FREQUENCY_ATTR_NO_80MHZ = 11, + NL80211_FREQUENCY_ATTR_NO_160MHZ = 12, + NL80211_FREQUENCY_ATTR_DFS_CAC_TIME = 13, + NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 14, + NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 15, + NL80211_FREQUENCY_ATTR_NO_20MHZ = 16, + NL80211_FREQUENCY_ATTR_NO_10MHZ = 17, + NL80211_FREQUENCY_ATTR_WMM = 18, + NL80211_FREQUENCY_ATTR_NO_HE = 19, + NL80211_FREQUENCY_ATTR_OFFSET = 20, + NL80211_FREQUENCY_ATTR_1MHZ = 21, + NL80211_FREQUENCY_ATTR_2MHZ = 22, + NL80211_FREQUENCY_ATTR_4MHZ = 23, + NL80211_FREQUENCY_ATTR_8MHZ = 24, + NL80211_FREQUENCY_ATTR_16MHZ = 25, + __NL80211_FREQUENCY_ATTR_AFTER_LAST = 26, + NL80211_FREQUENCY_ATTR_MAX = 25, +}; + +enum nl80211_bitrate_attr { + __NL80211_BITRATE_ATTR_INVALID = 0, + NL80211_BITRATE_ATTR_RATE = 1, + NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE = 2, + __NL80211_BITRATE_ATTR_AFTER_LAST = 3, + NL80211_BITRATE_ATTR_MAX = 2, +}; + +enum nl80211_reg_type { + NL80211_REGDOM_TYPE_COUNTRY = 0, + NL80211_REGDOM_TYPE_WORLD = 1, + NL80211_REGDOM_TYPE_CUSTOM_WORLD = 2, + NL80211_REGDOM_TYPE_INTERSECTION = 3, +}; + +enum nl80211_reg_rule_attr { + __NL80211_REG_RULE_ATTR_INVALID = 0, + NL80211_ATTR_REG_RULE_FLAGS = 1, + NL80211_ATTR_FREQ_RANGE_START = 2, + NL80211_ATTR_FREQ_RANGE_END = 3, + NL80211_ATTR_FREQ_RANGE_MAX_BW = 4, + NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN = 5, + NL80211_ATTR_POWER_RULE_MAX_EIRP = 6, + NL80211_ATTR_DFS_CAC_TIME = 7, + __NL80211_REG_RULE_ATTR_AFTER_LAST = 8, + NL80211_REG_RULE_ATTR_MAX = 7, +}; + +enum nl80211_sched_scan_match_attr { + __NL80211_SCHED_SCAN_MATCH_ATTR_INVALID = 0, + NL80211_SCHED_SCAN_MATCH_ATTR_SSID = 1, + NL80211_SCHED_SCAN_MATCH_ATTR_RSSI = 2, + NL80211_SCHED_SCAN_MATCH_ATTR_RELATIVE_RSSI = 3, + NL80211_SCHED_SCAN_MATCH_ATTR_RSSI_ADJUST = 4, + NL80211_SCHED_SCAN_MATCH_ATTR_BSSID = 5, + NL80211_SCHED_SCAN_MATCH_PER_BAND_RSSI = 6, + __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST = 7, + NL80211_SCHED_SCAN_MATCH_ATTR_MAX = 6, +}; + +enum nl80211_survey_info { + __NL80211_SURVEY_INFO_INVALID = 0, + NL80211_SURVEY_INFO_FREQUENCY = 1, + NL80211_SURVEY_INFO_NOISE = 2, + NL80211_SURVEY_INFO_IN_USE = 3, + NL80211_SURVEY_INFO_TIME = 4, + NL80211_SURVEY_INFO_TIME_BUSY = 5, + NL80211_SURVEY_INFO_TIME_EXT_BUSY = 6, + NL80211_SURVEY_INFO_TIME_RX = 7, + NL80211_SURVEY_INFO_TIME_TX = 8, + NL80211_SURVEY_INFO_TIME_SCAN = 9, + NL80211_SURVEY_INFO_PAD = 10, + NL80211_SURVEY_INFO_TIME_BSS_RX = 11, + NL80211_SURVEY_INFO_FREQUENCY_OFFSET = 12, + __NL80211_SURVEY_INFO_AFTER_LAST = 13, + NL80211_SURVEY_INFO_MAX = 12, +}; + +enum nl80211_meshconf_params { + __NL80211_MESHCONF_INVALID = 0, + NL80211_MESHCONF_RETRY_TIMEOUT = 1, + NL80211_MESHCONF_CONFIRM_TIMEOUT = 2, + NL80211_MESHCONF_HOLDING_TIMEOUT = 3, + NL80211_MESHCONF_MAX_PEER_LINKS = 4, + NL80211_MESHCONF_MAX_RETRIES = 5, + NL80211_MESHCONF_TTL = 6, + NL80211_MESHCONF_AUTO_OPEN_PLINKS = 7, + NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES = 8, + NL80211_MESHCONF_PATH_REFRESH_TIME = 9, + NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT = 10, + NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT = 11, + NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL = 12, + NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME = 13, + NL80211_MESHCONF_HWMP_ROOTMODE = 14, + NL80211_MESHCONF_ELEMENT_TTL = 15, + NL80211_MESHCONF_HWMP_RANN_INTERVAL = 16, + NL80211_MESHCONF_GATE_ANNOUNCEMENTS = 17, + NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL = 18, + NL80211_MESHCONF_FORWARDING = 19, + NL80211_MESHCONF_RSSI_THRESHOLD = 20, + NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR = 21, + NL80211_MESHCONF_HT_OPMODE = 22, + NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT = 23, + NL80211_MESHCONF_HWMP_ROOT_INTERVAL = 24, + NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL = 25, + NL80211_MESHCONF_POWER_MODE = 26, + NL80211_MESHCONF_AWAKE_WINDOW = 27, + NL80211_MESHCONF_PLINK_TIMEOUT = 28, + NL80211_MESHCONF_CONNECTED_TO_GATE = 29, + NL80211_MESHCONF_NOLEARN = 30, + NL80211_MESHCONF_CONNECTED_TO_AS = 31, + __NL80211_MESHCONF_ATTR_AFTER_LAST = 32, + NL80211_MESHCONF_ATTR_MAX = 31, +}; + +enum nl80211_mesh_setup_params { + __NL80211_MESH_SETUP_INVALID = 0, + NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL = 1, + NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC = 2, + NL80211_MESH_SETUP_IE = 3, + NL80211_MESH_SETUP_USERSPACE_AUTH = 4, + NL80211_MESH_SETUP_USERSPACE_AMPE = 5, + NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC = 6, + NL80211_MESH_SETUP_USERSPACE_MPM = 7, + NL80211_MESH_SETUP_AUTH_PROTOCOL = 8, + __NL80211_MESH_SETUP_ATTR_AFTER_LAST = 9, + NL80211_MESH_SETUP_ATTR_MAX = 8, +}; + +enum nl80211_txq_attr { + __NL80211_TXQ_ATTR_INVALID = 0, + NL80211_TXQ_ATTR_AC = 1, + NL80211_TXQ_ATTR_TXOP = 2, + NL80211_TXQ_ATTR_CWMIN = 3, + NL80211_TXQ_ATTR_CWMAX = 4, + NL80211_TXQ_ATTR_AIFS = 5, + __NL80211_TXQ_ATTR_AFTER_LAST = 6, + NL80211_TXQ_ATTR_MAX = 5, +}; + +enum nl80211_bss { + __NL80211_BSS_INVALID = 0, + NL80211_BSS_BSSID = 1, + NL80211_BSS_FREQUENCY = 2, + NL80211_BSS_TSF = 3, + NL80211_BSS_BEACON_INTERVAL = 4, + NL80211_BSS_CAPABILITY = 5, + NL80211_BSS_INFORMATION_ELEMENTS = 6, + NL80211_BSS_SIGNAL_MBM = 7, + NL80211_BSS_SIGNAL_UNSPEC = 8, + NL80211_BSS_STATUS = 9, + NL80211_BSS_SEEN_MS_AGO = 10, + NL80211_BSS_BEACON_IES = 11, + NL80211_BSS_CHAN_WIDTH = 12, + NL80211_BSS_BEACON_TSF = 13, + NL80211_BSS_PRESP_DATA = 14, + NL80211_BSS_LAST_SEEN_BOOTTIME = 15, + NL80211_BSS_PAD = 16, + NL80211_BSS_PARENT_TSF = 17, + NL80211_BSS_PARENT_BSSID = 18, + NL80211_BSS_CHAIN_SIGNAL = 19, + NL80211_BSS_FREQUENCY_OFFSET = 20, + __NL80211_BSS_AFTER_LAST = 21, + NL80211_BSS_MAX = 20, +}; + +enum nl80211_bss_status { + NL80211_BSS_STATUS_AUTHENTICATED = 0, + NL80211_BSS_STATUS_ASSOCIATED = 1, + NL80211_BSS_STATUS_IBSS_JOINED = 2, +}; + +enum nl80211_key_type { + NL80211_KEYTYPE_GROUP = 0, + NL80211_KEYTYPE_PAIRWISE = 1, + NL80211_KEYTYPE_PEERKEY = 2, + NUM_NL80211_KEYTYPES = 3, +}; + +enum nl80211_wpa_versions { + NL80211_WPA_VERSION_1 = 1, + NL80211_WPA_VERSION_2 = 2, + NL80211_WPA_VERSION_3 = 4, +}; + +enum nl80211_key_default_types { + __NL80211_KEY_DEFAULT_TYPE_INVALID = 0, + NL80211_KEY_DEFAULT_TYPE_UNICAST = 1, + NL80211_KEY_DEFAULT_TYPE_MULTICAST = 2, + NUM_NL80211_KEY_DEFAULT_TYPES = 3, +}; + +enum nl80211_key_attributes { + __NL80211_KEY_INVALID = 0, + NL80211_KEY_DATA = 1, + NL80211_KEY_IDX = 2, + NL80211_KEY_CIPHER = 3, + NL80211_KEY_SEQ = 4, + NL80211_KEY_DEFAULT = 5, + NL80211_KEY_DEFAULT_MGMT = 6, + NL80211_KEY_TYPE = 7, + NL80211_KEY_DEFAULT_TYPES = 8, + NL80211_KEY_MODE = 9, + NL80211_KEY_DEFAULT_BEACON = 10, + __NL80211_KEY_AFTER_LAST = 11, + NL80211_KEY_MAX = 10, +}; + +enum nl80211_tx_rate_attributes { + __NL80211_TXRATE_INVALID = 0, + NL80211_TXRATE_LEGACY = 1, + NL80211_TXRATE_HT = 2, + NL80211_TXRATE_VHT = 3, + NL80211_TXRATE_GI = 4, + NL80211_TXRATE_HE = 5, + NL80211_TXRATE_HE_GI = 6, + NL80211_TXRATE_HE_LTF = 7, + __NL80211_TXRATE_AFTER_LAST = 8, + NL80211_TXRATE_MAX = 7, +}; + +struct nl80211_txrate_vht { + __u16 mcs[8]; +}; + +struct nl80211_txrate_he { + __u16 mcs[8]; +}; + +enum nl80211_ps_state { + NL80211_PS_DISABLED = 0, + NL80211_PS_ENABLED = 1, +}; + +enum nl80211_attr_cqm { + __NL80211_ATTR_CQM_INVALID = 0, + NL80211_ATTR_CQM_RSSI_THOLD = 1, + NL80211_ATTR_CQM_RSSI_HYST = 2, + NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT = 3, + NL80211_ATTR_CQM_PKT_LOSS_EVENT = 4, + NL80211_ATTR_CQM_TXE_RATE = 5, + NL80211_ATTR_CQM_TXE_PKTS = 6, + NL80211_ATTR_CQM_TXE_INTVL = 7, + NL80211_ATTR_CQM_BEACON_LOSS_EVENT = 8, + NL80211_ATTR_CQM_RSSI_LEVEL = 9, + __NL80211_ATTR_CQM_AFTER_LAST = 10, + NL80211_ATTR_CQM_MAX = 9, +}; + +enum nl80211_cqm_rssi_threshold_event { + NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW = 0, + NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH = 1, + NL80211_CQM_RSSI_BEACON_LOSS_EVENT = 2, +}; + +enum nl80211_tid_config_attr { + __NL80211_TID_CONFIG_ATTR_INVALID = 0, + NL80211_TID_CONFIG_ATTR_PAD = 1, + NL80211_TID_CONFIG_ATTR_VIF_SUPP = 2, + NL80211_TID_CONFIG_ATTR_PEER_SUPP = 3, + NL80211_TID_CONFIG_ATTR_OVERRIDE = 4, + NL80211_TID_CONFIG_ATTR_TIDS = 5, + NL80211_TID_CONFIG_ATTR_NOACK = 6, + NL80211_TID_CONFIG_ATTR_RETRY_SHORT = 7, + NL80211_TID_CONFIG_ATTR_RETRY_LONG = 8, + NL80211_TID_CONFIG_ATTR_AMPDU_CTRL = 9, + NL80211_TID_CONFIG_ATTR_RTSCTS_CTRL = 10, + NL80211_TID_CONFIG_ATTR_AMSDU_CTRL = 11, + NL80211_TID_CONFIG_ATTR_TX_RATE_TYPE = 12, + NL80211_TID_CONFIG_ATTR_TX_RATE = 13, + __NL80211_TID_CONFIG_ATTR_AFTER_LAST = 14, + NL80211_TID_CONFIG_ATTR_MAX = 13, +}; + +enum nl80211_packet_pattern_attr { + __NL80211_PKTPAT_INVALID = 0, + NL80211_PKTPAT_MASK = 1, + NL80211_PKTPAT_PATTERN = 2, + NL80211_PKTPAT_OFFSET = 3, + NUM_NL80211_PKTPAT = 4, + MAX_NL80211_PKTPAT = 3, +}; + +struct nl80211_pattern_support { + __u32 max_patterns; + __u32 min_pattern_len; + __u32 max_pattern_len; + __u32 max_pkt_offset; +}; + +enum nl80211_wowlan_triggers { + __NL80211_WOWLAN_TRIG_INVALID = 0, + NL80211_WOWLAN_TRIG_ANY = 1, + NL80211_WOWLAN_TRIG_DISCONNECT = 2, + NL80211_WOWLAN_TRIG_MAGIC_PKT = 3, + NL80211_WOWLAN_TRIG_PKT_PATTERN = 4, + NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED = 5, + NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE = 6, + NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST = 7, + NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE = 8, + NL80211_WOWLAN_TRIG_RFKILL_RELEASE = 9, + NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211 = 10, + NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN = 11, + NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023 = 12, + NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN = 13, + NL80211_WOWLAN_TRIG_TCP_CONNECTION = 14, + NL80211_WOWLAN_TRIG_WAKEUP_TCP_MATCH = 15, + NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST = 16, + NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS = 17, + NL80211_WOWLAN_TRIG_NET_DETECT = 18, + NL80211_WOWLAN_TRIG_NET_DETECT_RESULTS = 19, + NUM_NL80211_WOWLAN_TRIG = 20, + MAX_NL80211_WOWLAN_TRIG = 19, +}; + +enum nl80211_wowlan_tcp_attrs { + __NL80211_WOWLAN_TCP_INVALID = 0, + NL80211_WOWLAN_TCP_SRC_IPV4 = 1, + NL80211_WOWLAN_TCP_DST_IPV4 = 2, + NL80211_WOWLAN_TCP_DST_MAC = 3, + NL80211_WOWLAN_TCP_SRC_PORT = 4, + NL80211_WOWLAN_TCP_DST_PORT = 5, + NL80211_WOWLAN_TCP_DATA_PAYLOAD = 6, + NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ = 7, + NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN = 8, + NL80211_WOWLAN_TCP_DATA_INTERVAL = 9, + NL80211_WOWLAN_TCP_WAKE_PAYLOAD = 10, + NL80211_WOWLAN_TCP_WAKE_MASK = 11, + NUM_NL80211_WOWLAN_TCP = 12, + MAX_NL80211_WOWLAN_TCP = 11, +}; + +struct nl80211_coalesce_rule_support { + __u32 max_rules; + struct nl80211_pattern_support pat; + __u32 max_delay; +}; + +enum nl80211_attr_coalesce_rule { + __NL80211_COALESCE_RULE_INVALID = 0, + NL80211_ATTR_COALESCE_RULE_DELAY = 1, + NL80211_ATTR_COALESCE_RULE_CONDITION = 2, + NL80211_ATTR_COALESCE_RULE_PKT_PATTERN = 3, + NUM_NL80211_ATTR_COALESCE_RULE = 4, + NL80211_ATTR_COALESCE_RULE_MAX = 3, +}; + +enum nl80211_iface_limit_attrs { + NL80211_IFACE_LIMIT_UNSPEC = 0, + NL80211_IFACE_LIMIT_MAX = 1, + NL80211_IFACE_LIMIT_TYPES = 2, + NUM_NL80211_IFACE_LIMIT = 3, + MAX_NL80211_IFACE_LIMIT = 2, +}; + +enum nl80211_if_combination_attrs { + NL80211_IFACE_COMB_UNSPEC = 0, + NL80211_IFACE_COMB_LIMITS = 1, + NL80211_IFACE_COMB_MAXNUM = 2, + NL80211_IFACE_COMB_STA_AP_BI_MATCH = 3, + NL80211_IFACE_COMB_NUM_CHANNELS = 4, + NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS = 5, + NL80211_IFACE_COMB_RADAR_DETECT_REGIONS = 6, + NL80211_IFACE_COMB_BI_MIN_GCD = 7, + NUM_NL80211_IFACE_COMB = 8, + MAX_NL80211_IFACE_COMB = 7, +}; + +enum nl80211_plink_state { + NL80211_PLINK_LISTEN = 0, + NL80211_PLINK_OPN_SNT = 1, + NL80211_PLINK_OPN_RCVD = 2, + NL80211_PLINK_CNF_RCVD = 3, + NL80211_PLINK_ESTAB = 4, + NL80211_PLINK_HOLDING = 5, + NL80211_PLINK_BLOCKED = 6, + NUM_NL80211_PLINK_STATES = 7, + MAX_NL80211_PLINK_STATES = 6, +}; + +enum plink_actions { + NL80211_PLINK_ACTION_NO_ACTION = 0, + NL80211_PLINK_ACTION_OPEN = 1, + NL80211_PLINK_ACTION_BLOCK = 2, + NUM_NL80211_PLINK_ACTIONS = 3, +}; + +enum nl80211_rekey_data { + __NL80211_REKEY_DATA_INVALID = 0, + NL80211_REKEY_DATA_KEK = 1, + NL80211_REKEY_DATA_KCK = 2, + NL80211_REKEY_DATA_REPLAY_CTR = 3, + NL80211_REKEY_DATA_AKM = 4, + NUM_NL80211_REKEY_DATA = 5, + MAX_NL80211_REKEY_DATA = 4, +}; + +enum nl80211_sta_wme_attr { + __NL80211_STA_WME_INVALID = 0, + NL80211_STA_WME_UAPSD_QUEUES = 1, + NL80211_STA_WME_MAX_SP = 2, + __NL80211_STA_WME_AFTER_LAST = 3, + NL80211_STA_WME_MAX = 2, +}; + +enum nl80211_pmksa_candidate_attr { + __NL80211_PMKSA_CANDIDATE_INVALID = 0, + NL80211_PMKSA_CANDIDATE_INDEX = 1, + NL80211_PMKSA_CANDIDATE_BSSID = 2, + NL80211_PMKSA_CANDIDATE_PREAUTH = 3, + NUM_NL80211_PMKSA_CANDIDATE = 4, + MAX_NL80211_PMKSA_CANDIDATE = 3, +}; + +enum nl80211_connect_failed_reason { + NL80211_CONN_FAIL_MAX_CLIENTS = 0, + NL80211_CONN_FAIL_BLOCKED_CLIENT = 1, +}; + +enum nl80211_protocol_features { + NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP = 1, +}; + +enum nl80211_sched_scan_plan { + __NL80211_SCHED_SCAN_PLAN_INVALID = 0, + NL80211_SCHED_SCAN_PLAN_INTERVAL = 1, + NL80211_SCHED_SCAN_PLAN_ITERATIONS = 2, + __NL80211_SCHED_SCAN_PLAN_AFTER_LAST = 3, + NL80211_SCHED_SCAN_PLAN_MAX = 2, +}; + +struct nl80211_bss_select_rssi_adjust { + __u8 band; + __s8 delta; +}; + +enum nl80211_nan_publish_type { + NL80211_NAN_SOLICITED_PUBLISH = 1, + NL80211_NAN_UNSOLICITED_PUBLISH = 2, +}; + +enum nl80211_nan_func_term_reason { + NL80211_NAN_FUNC_TERM_REASON_USER_REQUEST = 0, + NL80211_NAN_FUNC_TERM_REASON_TTL_EXPIRED = 1, + NL80211_NAN_FUNC_TERM_REASON_ERROR = 2, +}; + +enum nl80211_nan_func_attributes { + __NL80211_NAN_FUNC_INVALID = 0, + NL80211_NAN_FUNC_TYPE = 1, + NL80211_NAN_FUNC_SERVICE_ID = 2, + NL80211_NAN_FUNC_PUBLISH_TYPE = 3, + NL80211_NAN_FUNC_PUBLISH_BCAST = 4, + NL80211_NAN_FUNC_SUBSCRIBE_ACTIVE = 5, + NL80211_NAN_FUNC_FOLLOW_UP_ID = 6, + NL80211_NAN_FUNC_FOLLOW_UP_REQ_ID = 7, + NL80211_NAN_FUNC_FOLLOW_UP_DEST = 8, + NL80211_NAN_FUNC_CLOSE_RANGE = 9, + NL80211_NAN_FUNC_TTL = 10, + NL80211_NAN_FUNC_SERVICE_INFO = 11, + NL80211_NAN_FUNC_SRF = 12, + NL80211_NAN_FUNC_RX_MATCH_FILTER = 13, + NL80211_NAN_FUNC_TX_MATCH_FILTER = 14, + NL80211_NAN_FUNC_INSTANCE_ID = 15, + NL80211_NAN_FUNC_TERM_REASON = 16, + NUM_NL80211_NAN_FUNC_ATTR = 17, + NL80211_NAN_FUNC_ATTR_MAX = 16, +}; + +enum nl80211_nan_srf_attributes { + __NL80211_NAN_SRF_INVALID = 0, + NL80211_NAN_SRF_INCLUDE = 1, + NL80211_NAN_SRF_BF = 2, + NL80211_NAN_SRF_BF_IDX = 3, + NL80211_NAN_SRF_MAC_ADDRS = 4, + NUM_NL80211_NAN_SRF_ATTR = 5, + NL80211_NAN_SRF_ATTR_MAX = 4, +}; + +enum nl80211_nan_match_attributes { + __NL80211_NAN_MATCH_INVALID = 0, + NL80211_NAN_MATCH_FUNC_LOCAL = 1, + NL80211_NAN_MATCH_FUNC_PEER = 2, + NUM_NL80211_NAN_MATCH_ATTR = 3, + NL80211_NAN_MATCH_ATTR_MAX = 2, +}; + +enum nl80211_ftm_responder_attributes { + __NL80211_FTM_RESP_ATTR_INVALID = 0, + NL80211_FTM_RESP_ATTR_ENABLED = 1, + NL80211_FTM_RESP_ATTR_LCI = 2, + NL80211_FTM_RESP_ATTR_CIVICLOC = 3, + __NL80211_FTM_RESP_ATTR_LAST = 4, + NL80211_FTM_RESP_ATTR_MAX = 3, +}; + +enum nl80211_ftm_responder_stats { + __NL80211_FTM_STATS_INVALID = 0, + NL80211_FTM_STATS_SUCCESS_NUM = 1, + NL80211_FTM_STATS_PARTIAL_NUM = 2, + NL80211_FTM_STATS_FAILED_NUM = 3, + NL80211_FTM_STATS_ASAP_NUM = 4, + NL80211_FTM_STATS_NON_ASAP_NUM = 5, + NL80211_FTM_STATS_TOTAL_DURATION_MSEC = 6, + NL80211_FTM_STATS_UNKNOWN_TRIGGERS_NUM = 7, + NL80211_FTM_STATS_RESCHEDULE_REQUESTS_NUM = 8, + NL80211_FTM_STATS_OUT_OF_WINDOW_TRIGGERS_NUM = 9, + NL80211_FTM_STATS_PAD = 10, + __NL80211_FTM_STATS_AFTER_LAST = 11, + NL80211_FTM_STATS_MAX = 10, +}; + +enum nl80211_peer_measurement_type { + NL80211_PMSR_TYPE_INVALID = 0, + NL80211_PMSR_TYPE_FTM = 1, + NUM_NL80211_PMSR_TYPES = 2, + NL80211_PMSR_TYPE_MAX = 1, +}; + +enum nl80211_peer_measurement_req { + __NL80211_PMSR_REQ_ATTR_INVALID = 0, + NL80211_PMSR_REQ_ATTR_DATA = 1, + NL80211_PMSR_REQ_ATTR_GET_AP_TSF = 2, + NUM_NL80211_PMSR_REQ_ATTRS = 3, + NL80211_PMSR_REQ_ATTR_MAX = 2, +}; + +enum nl80211_peer_measurement_peer_attrs { + __NL80211_PMSR_PEER_ATTR_INVALID = 0, + NL80211_PMSR_PEER_ATTR_ADDR = 1, + NL80211_PMSR_PEER_ATTR_CHAN = 2, + NL80211_PMSR_PEER_ATTR_REQ = 3, + NL80211_PMSR_PEER_ATTR_RESP = 4, + NUM_NL80211_PMSR_PEER_ATTRS = 5, + NL80211_PMSR_PEER_ATTR_MAX = 4, +}; + +enum nl80211_peer_measurement_attrs { + __NL80211_PMSR_ATTR_INVALID = 0, + NL80211_PMSR_ATTR_MAX_PEERS = 1, + NL80211_PMSR_ATTR_REPORT_AP_TSF = 2, + NL80211_PMSR_ATTR_RANDOMIZE_MAC_ADDR = 3, + NL80211_PMSR_ATTR_TYPE_CAPA = 4, + NL80211_PMSR_ATTR_PEERS = 5, + NUM_NL80211_PMSR_ATTR = 6, + NL80211_PMSR_ATTR_MAX = 5, +}; + +enum nl80211_peer_measurement_ftm_capa { + __NL80211_PMSR_FTM_CAPA_ATTR_INVALID = 0, + NL80211_PMSR_FTM_CAPA_ATTR_ASAP = 1, + NL80211_PMSR_FTM_CAPA_ATTR_NON_ASAP = 2, + NL80211_PMSR_FTM_CAPA_ATTR_REQ_LCI = 3, + NL80211_PMSR_FTM_CAPA_ATTR_REQ_CIVICLOC = 4, + NL80211_PMSR_FTM_CAPA_ATTR_PREAMBLES = 5, + NL80211_PMSR_FTM_CAPA_ATTR_BANDWIDTHS = 6, + NL80211_PMSR_FTM_CAPA_ATTR_MAX_BURSTS_EXPONENT = 7, + NL80211_PMSR_FTM_CAPA_ATTR_MAX_FTMS_PER_BURST = 8, + NL80211_PMSR_FTM_CAPA_ATTR_TRIGGER_BASED = 9, + NL80211_PMSR_FTM_CAPA_ATTR_NON_TRIGGER_BASED = 10, + NUM_NL80211_PMSR_FTM_CAPA_ATTR = 11, + NL80211_PMSR_FTM_CAPA_ATTR_MAX = 10, +}; + +enum nl80211_peer_measurement_ftm_req { + __NL80211_PMSR_FTM_REQ_ATTR_INVALID = 0, + NL80211_PMSR_FTM_REQ_ATTR_ASAP = 1, + NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE = 2, + NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP = 3, + NL80211_PMSR_FTM_REQ_ATTR_BURST_PERIOD = 4, + NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION = 5, + NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST = 6, + NL80211_PMSR_FTM_REQ_ATTR_NUM_FTMR_RETRIES = 7, + NL80211_PMSR_FTM_REQ_ATTR_REQUEST_LCI = 8, + NL80211_PMSR_FTM_REQ_ATTR_REQUEST_CIVICLOC = 9, + NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED = 10, + NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED = 11, + NUM_NL80211_PMSR_FTM_REQ_ATTR = 12, + NL80211_PMSR_FTM_REQ_ATTR_MAX = 11, +}; + +enum nl80211_obss_pd_attributes { + __NL80211_HE_OBSS_PD_ATTR_INVALID = 0, + NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET = 1, + NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET = 2, + NL80211_HE_OBSS_PD_ATTR_NON_SRG_MAX_OFFSET = 3, + NL80211_HE_OBSS_PD_ATTR_BSS_COLOR_BITMAP = 4, + NL80211_HE_OBSS_PD_ATTR_PARTIAL_BSSID_BITMAP = 5, + NL80211_HE_OBSS_PD_ATTR_SR_CTRL = 6, + __NL80211_HE_OBSS_PD_ATTR_LAST = 7, + NL80211_HE_OBSS_PD_ATTR_MAX = 6, +}; + +enum nl80211_bss_color_attributes { + __NL80211_HE_BSS_COLOR_ATTR_INVALID = 0, + NL80211_HE_BSS_COLOR_ATTR_COLOR = 1, + NL80211_HE_BSS_COLOR_ATTR_DISABLED = 2, + NL80211_HE_BSS_COLOR_ATTR_PARTIAL = 3, + __NL80211_HE_BSS_COLOR_ATTR_LAST = 4, + NL80211_HE_BSS_COLOR_ATTR_MAX = 3, +}; + +enum nl80211_iftype_akm_attributes { + __NL80211_IFTYPE_AKM_ATTR_INVALID = 0, + NL80211_IFTYPE_AKM_ATTR_IFTYPES = 1, + NL80211_IFTYPE_AKM_ATTR_SUITES = 2, + __NL80211_IFTYPE_AKM_ATTR_LAST = 3, + NL80211_IFTYPE_AKM_ATTR_MAX = 2, +}; + +enum nl80211_fils_discovery_attributes { + __NL80211_FILS_DISCOVERY_ATTR_INVALID = 0, + NL80211_FILS_DISCOVERY_ATTR_INT_MIN = 1, + NL80211_FILS_DISCOVERY_ATTR_INT_MAX = 2, + NL80211_FILS_DISCOVERY_ATTR_TMPL = 3, + __NL80211_FILS_DISCOVERY_ATTR_LAST = 4, + NL80211_FILS_DISCOVERY_ATTR_MAX = 3, +}; + +enum nl80211_unsol_bcast_probe_resp_attributes { + __NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INVALID = 0, + NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INT = 1, + NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_TMPL = 2, + __NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_LAST = 3, + NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_MAX = 2, +}; + +enum survey_info_flags { + SURVEY_INFO_NOISE_DBM = 1, + SURVEY_INFO_IN_USE = 2, + SURVEY_INFO_TIME = 4, + SURVEY_INFO_TIME_BUSY = 8, + SURVEY_INFO_TIME_EXT_BUSY = 16, + SURVEY_INFO_TIME_RX = 32, + SURVEY_INFO_TIME_TX = 64, + SURVEY_INFO_TIME_SCAN = 128, + SURVEY_INFO_TIME_BSS_RX = 256, +}; + +enum cfg80211_ap_settings_flags { + AP_SETTINGS_EXTERNAL_AUTH_SUPPORT = 1, +}; + +enum station_parameters_apply_mask { + STATION_PARAM_APPLY_UAPSD = 1, + STATION_PARAM_APPLY_CAPABILITY = 2, + STATION_PARAM_APPLY_PLINK_STATE = 4, + STATION_PARAM_APPLY_STA_TXPOWER = 8, +}; + +enum cfg80211_station_type { + CFG80211_STA_AP_CLIENT = 0, + CFG80211_STA_AP_CLIENT_UNASSOC = 1, + CFG80211_STA_AP_MLME_CLIENT = 2, + CFG80211_STA_AP_STA = 3, + CFG80211_STA_IBSS = 4, + CFG80211_STA_TDLS_PEER_SETUP = 5, + CFG80211_STA_TDLS_PEER_ACTIVE = 6, + CFG80211_STA_MESH_PEER_KERNEL = 7, + CFG80211_STA_MESH_PEER_USER = 8, +}; + +enum bss_param_flags { + BSS_PARAM_FLAGS_CTS_PROT = 1, + BSS_PARAM_FLAGS_SHORT_PREAMBLE = 2, + BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 4, +}; + +enum monitor_flags { + MONITOR_FLAG_CHANGED = 1, + MONITOR_FLAG_FCSFAIL = 2, + MONITOR_FLAG_PLCPFAIL = 4, + MONITOR_FLAG_CONTROL = 8, + MONITOR_FLAG_OTHER_BSS = 16, + MONITOR_FLAG_COOK_FRAMES = 32, + MONITOR_FLAG_ACTIVE = 64, +}; + +enum mpath_info_flags { + MPATH_INFO_FRAME_QLEN = 1, + MPATH_INFO_SN = 2, + MPATH_INFO_METRIC = 4, + MPATH_INFO_EXPTIME = 8, + MPATH_INFO_DISCOVERY_TIMEOUT = 16, + MPATH_INFO_DISCOVERY_RETRIES = 32, + MPATH_INFO_FLAGS = 64, + MPATH_INFO_HOP_COUNT = 128, + MPATH_INFO_PATH_CHANGE = 256, +}; + +enum cfg80211_assoc_req_flags { + ASSOC_REQ_DISABLE_HT = 1, + ASSOC_REQ_DISABLE_VHT = 2, + ASSOC_REQ_USE_RRM = 4, + CONNECT_REQ_EXTERNAL_AUTH_SUPPORT = 8, +}; + +enum cfg80211_connect_params_changed { + UPDATE_ASSOC_IES = 1, + UPDATE_FILS_ERP_INFO = 2, + UPDATE_AUTH_TYPE = 4, +}; + +enum wiphy_params_flags { + WIPHY_PARAM_RETRY_SHORT = 1, + WIPHY_PARAM_RETRY_LONG = 2, + WIPHY_PARAM_FRAG_THRESHOLD = 4, + WIPHY_PARAM_RTS_THRESHOLD = 8, + WIPHY_PARAM_COVERAGE_CLASS = 16, + WIPHY_PARAM_DYN_ACK = 32, + WIPHY_PARAM_TXQ_LIMIT = 64, + WIPHY_PARAM_TXQ_MEMORY_LIMIT = 128, + WIPHY_PARAM_TXQ_QUANTUM = 256, +}; + +struct cfg80211_wowlan_nd_match { + struct cfg80211_ssid ssid; + int n_channels; + u32 channels[0]; +}; + +struct cfg80211_wowlan_nd_info { + int n_matches; + struct cfg80211_wowlan_nd_match *matches[0]; +}; + +struct cfg80211_wowlan_wakeup { + bool disconnect; + bool magic_pkt; + bool gtk_rekey_failure; + bool eap_identity_req; + bool four_way_handshake; + bool rfkill_release; + bool packet_80211; + bool tcp_match; + bool tcp_connlost; + bool tcp_nomoretokens; + s32 pattern_idx; + u32 packet_present_len; + u32 packet_len; + const void *packet; + struct cfg80211_wowlan_nd_info *net_detect; +}; + +enum cfg80211_nan_conf_changes { + CFG80211_NAN_CONF_CHANGED_PREF = 1, + CFG80211_NAN_CONF_CHANGED_BANDS = 2, +}; + +enum wiphy_vendor_command_flags { + WIPHY_VENDOR_CMD_NEED_WDEV = 1, + WIPHY_VENDOR_CMD_NEED_NETDEV = 2, + WIPHY_VENDOR_CMD_NEED_RUNNING = 4, +}; + +enum wiphy_opmode_flag { + STA_OPMODE_MAX_BW_CHANGED = 1, + STA_OPMODE_SMPS_MODE_CHANGED = 2, + STA_OPMODE_N_SS_CHANGED = 4, +}; + +struct sta_opmode_info { + u32 changed; + enum nl80211_smps_mode smps_mode; + enum nl80211_chan_width bw; + u8 rx_nss; +}; + +struct cfg80211_ft_event_params { + const u8 *ies; + size_t ies_len; + const u8 *target_ap; + const u8 *ric_ies; + size_t ric_ies_len; +}; + +struct cfg80211_nan_match_params { + enum nl80211_nan_function_type type; + u8 inst_id; + u8 peer_inst_id; + const u8 *addr; + u8 info_len; + const u8 *info; + u64 cookie; +}; + +enum nl80211_multicast_groups { + NL80211_MCGRP_CONFIG = 0, + NL80211_MCGRP_SCAN = 1, + NL80211_MCGRP_REGULATORY = 2, + NL80211_MCGRP_MLME = 3, + NL80211_MCGRP_VENDOR = 4, + NL80211_MCGRP_NAN = 5, + NL80211_MCGRP_TESTMODE = 6, +}; + +struct key_parse { + struct key_params p; + int idx; + int type; + bool def; + bool defmgmt; + bool defbeacon; + bool def_uni; + bool def_multi; +}; + +struct nl80211_dump_wiphy_state { + s64 filter_wiphy; + long int start; + long int split_start; + long int band_start; + long int chan_start; + long int capa_start; + bool split; +}; + +struct get_key_cookie { + struct sk_buff *msg; + int error; + int idx; +}; + +enum ieee80211_category { + WLAN_CATEGORY_SPECTRUM_MGMT = 0, + WLAN_CATEGORY_QOS = 1, + WLAN_CATEGORY_DLS = 2, + WLAN_CATEGORY_BACK = 3, + WLAN_CATEGORY_PUBLIC = 4, + WLAN_CATEGORY_RADIO_MEASUREMENT = 5, + WLAN_CATEGORY_HT = 7, + WLAN_CATEGORY_SA_QUERY = 8, + WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9, + WLAN_CATEGORY_WNM = 10, + WLAN_CATEGORY_WNM_UNPROTECTED = 11, + WLAN_CATEGORY_TDLS = 12, + WLAN_CATEGORY_MESH_ACTION = 13, + WLAN_CATEGORY_MULTIHOP_ACTION = 14, + WLAN_CATEGORY_SELF_PROTECTED = 15, + WLAN_CATEGORY_DMG = 16, + WLAN_CATEGORY_WMM = 17, + WLAN_CATEGORY_FST = 18, + WLAN_CATEGORY_UNPROT_DMG = 20, + WLAN_CATEGORY_VHT = 21, + WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126, + WLAN_CATEGORY_VENDOR_SPECIFIC = 127, +}; + +struct cfg80211_mgmt_registration { + struct list_head list; + struct wireless_dev *wdev; + u32 nlportid; + int match_len; + __le16 frame_type; + bool multicast_rx; + u8 match[0]; +}; + +struct cfg80211_conn { + struct cfg80211_connect_params params; + enum { + CFG80211_CONN_SCANNING = 0, + CFG80211_CONN_SCAN_AGAIN = 1, + CFG80211_CONN_AUTHENTICATE_NEXT = 2, + CFG80211_CONN_AUTHENTICATING = 3, + CFG80211_CONN_AUTH_FAILED_TIMEOUT = 4, + CFG80211_CONN_ASSOCIATE_NEXT = 5, + CFG80211_CONN_ASSOCIATING = 6, + CFG80211_CONN_ASSOC_FAILED = 7, + CFG80211_CONN_ASSOC_FAILED_TIMEOUT = 8, + CFG80211_CONN_DEAUTH = 9, + CFG80211_CONN_ABANDON = 10, + CFG80211_CONN_CONNECTED = 11, + } state; + u8 bssid[6]; + u8 prev_bssid[6]; + const u8 *ie; + size_t ie_len; + bool auto_auth; + bool prev_bssid_valid; +}; + +enum cfg80211_chan_mode { + CHAN_MODE_UNDEFINED = 0, + CHAN_MODE_SHARED = 1, + CHAN_MODE_EXCLUSIVE = 2, +}; + +struct trace_event_raw_rdev_suspend { + struct trace_entry ent; + char wiphy_name[32]; + bool any; + bool disconnect; + bool magic_pkt; + bool gtk_rekey_failure; + bool eap_identity_req; + bool four_way_handshake; + bool rfkill_release; + bool valid_wow; + char __data[0]; +}; + +struct trace_event_raw_rdev_return_int { + struct trace_entry ent; + char wiphy_name[32]; + int ret; + char __data[0]; +}; + +struct trace_event_raw_rdev_scan { + struct trace_entry ent; + char wiphy_name[32]; + char __data[0]; +}; + +struct trace_event_raw_wiphy_only_evt { + struct trace_entry ent; + char wiphy_name[32]; + char __data[0]; +}; + +struct trace_event_raw_wiphy_enabled_evt { + struct trace_entry ent; + char wiphy_name[32]; + bool enabled; + char __data[0]; +}; + +struct trace_event_raw_rdev_add_virtual_intf { + struct trace_entry ent; + char wiphy_name[32]; + u32 __data_loc_vir_intf_name; + enum nl80211_iftype type; + char __data[0]; +}; + +struct trace_event_raw_wiphy_wdev_evt { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + char __data[0]; +}; + +struct trace_event_raw_wiphy_wdev_cookie_evt { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + u64 cookie; + char __data[0]; +}; + +struct trace_event_raw_rdev_change_virtual_intf { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + enum nl80211_iftype type; + char __data[0]; +}; + +struct trace_event_raw_key_handle { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 mac_addr[6]; + u8 key_index; + bool pairwise; + char __data[0]; +}; + +struct trace_event_raw_rdev_add_key { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 mac_addr[6]; + u8 key_index; + bool pairwise; + u8 mode; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_default_key { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 key_index; + bool unicast; + bool multicast; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_default_mgmt_key { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 key_index; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_default_beacon_key { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 key_index; + char __data[0]; +}; + +struct trace_event_raw_rdev_start_ap { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + int beacon_interval; + int dtim_period; + char ssid[33]; + enum nl80211_hidden_ssid hidden_ssid; + u32 wpa_ver; + bool privacy; + enum nl80211_auth_type auth_type; + int inactivity_timeout; + char __data[0]; +}; + +struct trace_event_raw_rdev_change_beacon { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u32 __data_loc_head; + u32 __data_loc_tail; + u32 __data_loc_beacon_ies; + u32 __data_loc_proberesp_ies; + u32 __data_loc_assocresp_ies; + u32 __data_loc_probe_resp; + char __data[0]; +}; + +struct trace_event_raw_wiphy_netdev_evt { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + char __data[0]; +}; + +struct trace_event_raw_station_add_change { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 sta_mac[6]; + u32 sta_flags_mask; + u32 sta_flags_set; + u32 sta_modify_mask; + int listen_interval; + u16 capability; + u16 aid; + u8 plink_action; + u8 plink_state; + u8 uapsd_queues; + u8 max_sp; + u8 opmode_notif; + bool opmode_notif_used; + u8 ht_capa[26]; + u8 vht_capa[12]; + char vlan[16]; + u32 __data_loc_supported_rates; + u32 __data_loc_ext_capab; + u32 __data_loc_supported_channels; + u32 __data_loc_supported_oper_classes; + char __data[0]; +}; + +struct trace_event_raw_wiphy_netdev_mac_evt { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 sta_mac[6]; + char __data[0]; +}; + +struct trace_event_raw_station_del { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 sta_mac[6]; + u8 subtype; + u16 reason_code; + char __data[0]; +}; + +struct trace_event_raw_rdev_dump_station { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 sta_mac[6]; + int idx; + char __data[0]; +}; + +struct trace_event_raw_rdev_return_int_station_info { + struct trace_entry ent; + char wiphy_name[32]; + int ret; + int generation; + u32 connected_time; + u32 inactive_time; + u32 rx_bytes; + u32 tx_bytes; + u32 rx_packets; + u32 tx_packets; + u32 tx_retries; + u32 tx_failed; + u32 rx_dropped_misc; + u32 beacon_loss_count; + u16 llid; + u16 plid; + u8 plink_state; + char __data[0]; +}; + +struct trace_event_raw_mpath_evt { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 dst[6]; + u8 next_hop[6]; + char __data[0]; +}; + +struct trace_event_raw_rdev_dump_mpath { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 dst[6]; + u8 next_hop[6]; + int idx; + char __data[0]; +}; + +struct trace_event_raw_rdev_get_mpp { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 dst[6]; + u8 mpp[6]; + char __data[0]; +}; + +struct trace_event_raw_rdev_dump_mpp { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 dst[6]; + u8 mpp[6]; + int idx; + char __data[0]; +}; + +struct trace_event_raw_rdev_return_int_mpath_info { + struct trace_entry ent; + char wiphy_name[32]; + int ret; + int generation; + u32 filled; + u32 frame_qlen; + u32 sn; + u32 metric; + u32 exptime; + u32 discovery_timeout; + u8 discovery_retries; + u8 flags; + char __data[0]; +}; + +struct trace_event_raw_rdev_return_int_mesh_config { + struct trace_entry ent; + char wiphy_name[32]; + u16 dot11MeshRetryTimeout; + u16 dot11MeshConfirmTimeout; + u16 dot11MeshHoldingTimeout; + u16 dot11MeshMaxPeerLinks; + u8 dot11MeshMaxRetries; + u8 dot11MeshTTL; + u8 element_ttl; + bool auto_open_plinks; + u32 dot11MeshNbrOffsetMaxNeighbor; + u8 dot11MeshHWMPmaxPREQretries; + u32 path_refresh_time; + u32 dot11MeshHWMPactivePathTimeout; + u16 min_discovery_timeout; + u16 dot11MeshHWMPpreqMinInterval; + u16 dot11MeshHWMPperrMinInterval; + u16 dot11MeshHWMPnetDiameterTraversalTime; + u8 dot11MeshHWMPRootMode; + u16 dot11MeshHWMPRannInterval; + bool dot11MeshGateAnnouncementProtocol; + bool dot11MeshForwarding; + s32 rssi_threshold; + u16 ht_opmode; + u32 dot11MeshHWMPactivePathToRootTimeout; + u16 dot11MeshHWMProotInterval; + u16 dot11MeshHWMPconfirmationInterval; + bool dot11MeshNolearn; + int ret; + char __data[0]; +}; + +struct trace_event_raw_rdev_update_mesh_config { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u16 dot11MeshRetryTimeout; + u16 dot11MeshConfirmTimeout; + u16 dot11MeshHoldingTimeout; + u16 dot11MeshMaxPeerLinks; + u8 dot11MeshMaxRetries; + u8 dot11MeshTTL; + u8 element_ttl; + bool auto_open_plinks; + u32 dot11MeshNbrOffsetMaxNeighbor; + u8 dot11MeshHWMPmaxPREQretries; + u32 path_refresh_time; + u32 dot11MeshHWMPactivePathTimeout; + u16 min_discovery_timeout; + u16 dot11MeshHWMPpreqMinInterval; + u16 dot11MeshHWMPperrMinInterval; + u16 dot11MeshHWMPnetDiameterTraversalTime; + u8 dot11MeshHWMPRootMode; + u16 dot11MeshHWMPRannInterval; + bool dot11MeshGateAnnouncementProtocol; + bool dot11MeshForwarding; + s32 rssi_threshold; + u16 ht_opmode; + u32 dot11MeshHWMPactivePathToRootTimeout; + u16 dot11MeshHWMProotInterval; + u16 dot11MeshHWMPconfirmationInterval; + bool dot11MeshNolearn; + u32 mask; + char __data[0]; +}; + +struct trace_event_raw_rdev_join_mesh { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u16 dot11MeshRetryTimeout; + u16 dot11MeshConfirmTimeout; + u16 dot11MeshHoldingTimeout; + u16 dot11MeshMaxPeerLinks; + u8 dot11MeshMaxRetries; + u8 dot11MeshTTL; + u8 element_ttl; + bool auto_open_plinks; + u32 dot11MeshNbrOffsetMaxNeighbor; + u8 dot11MeshHWMPmaxPREQretries; + u32 path_refresh_time; + u32 dot11MeshHWMPactivePathTimeout; + u16 min_discovery_timeout; + u16 dot11MeshHWMPpreqMinInterval; + u16 dot11MeshHWMPperrMinInterval; + u16 dot11MeshHWMPnetDiameterTraversalTime; + u8 dot11MeshHWMPRootMode; + u16 dot11MeshHWMPRannInterval; + bool dot11MeshGateAnnouncementProtocol; + bool dot11MeshForwarding; + s32 rssi_threshold; + u16 ht_opmode; + u32 dot11MeshHWMPactivePathToRootTimeout; + u16 dot11MeshHWMProotInterval; + u16 dot11MeshHWMPconfirmationInterval; + bool dot11MeshNolearn; + char __data[0]; +}; + +struct trace_event_raw_rdev_change_bss { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + int use_cts_prot; + int use_short_preamble; + int use_short_slot_time; + int ap_isolate; + int ht_opmode; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_txq_params { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + enum nl80211_ac ac; + u16 txop; + u16 cwmin; + u16 cwmax; + u8 aifs; + char __data[0]; +}; + +struct trace_event_raw_rdev_libertas_set_mesh_channel { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_monitor_channel { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + char __data[0]; +}; + +struct trace_event_raw_rdev_auth { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 bssid[6]; + enum nl80211_auth_type auth_type; + char __data[0]; +}; + +struct trace_event_raw_rdev_assoc { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 bssid[6]; + u8 prev_bssid[6]; + bool use_mfp; + u32 flags; + char __data[0]; +}; + +struct trace_event_raw_rdev_deauth { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 bssid[6]; + u16 reason_code; + char __data[0]; +}; + +struct trace_event_raw_rdev_disassoc { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 bssid[6]; + u16 reason_code; + bool local_state_change; + char __data[0]; +}; + +struct trace_event_raw_rdev_mgmt_tx_cancel_wait { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + u64 cookie; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_power_mgmt { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + bool enabled; + int timeout; + char __data[0]; +}; + +struct trace_event_raw_rdev_connect { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 bssid[6]; + char ssid[33]; + enum nl80211_auth_type auth_type; + bool privacy; + u32 wpa_versions; + u32 flags; + u8 prev_bssid[6]; + char __data[0]; +}; + +struct trace_event_raw_rdev_update_connect_params { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u32 changed; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_cqm_rssi_config { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + s32 rssi_thold; + u32 rssi_hyst; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_cqm_rssi_range_config { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + s32 rssi_low; + s32 rssi_high; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_cqm_txe_config { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u32 rate; + u32 pkts; + u32 intvl; + char __data[0]; +}; + +struct trace_event_raw_rdev_disconnect { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u16 reason_code; + char __data[0]; +}; + +struct trace_event_raw_rdev_join_ibss { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 bssid[6]; + char ssid[33]; + char __data[0]; +}; + +struct trace_event_raw_rdev_join_ocb { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_wiphy_params { + struct trace_entry ent; + char wiphy_name[32]; + u32 changed; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_tx_power { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + enum nl80211_tx_power_setting type; + int mbm; + char __data[0]; +}; + +struct trace_event_raw_rdev_return_int_int { + struct trace_entry ent; + char wiphy_name[32]; + int func_ret; + int func_fill; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_bitrate_mask { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 peer[6]; + char __data[0]; +}; + +struct trace_event_raw_rdev_update_mgmt_frame_registrations { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + u16 global_stypes; + u16 interface_stypes; + char __data[0]; +}; + +struct trace_event_raw_rdev_return_int_tx_rx { + struct trace_entry ent; + char wiphy_name[32]; + int ret; + u32 tx; + u32 rx; + char __data[0]; +}; + +struct trace_event_raw_rdev_return_void_tx_rx { + struct trace_entry ent; + char wiphy_name[32]; + u32 tx; + u32 tx_max; + u32 rx; + u32 rx_max; + char __data[0]; +}; + +struct trace_event_raw_tx_rx_evt { + struct trace_entry ent; + char wiphy_name[32]; + u32 tx; + u32 rx; + char __data[0]; +}; + +struct trace_event_raw_wiphy_netdev_id_evt { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u64 id; + char __data[0]; +}; + +struct trace_event_raw_rdev_tdls_mgmt { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 peer[6]; + u8 action_code; + u8 dialog_token; + u16 status_code; + u32 peer_capability; + bool initiator; + u32 __data_loc_buf; + char __data[0]; +}; + +struct trace_event_raw_rdev_dump_survey { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + int idx; + char __data[0]; +}; + +struct trace_event_raw_rdev_return_int_survey_info { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + int ret; + u64 time; + u64 time_busy; + u64 time_ext_busy; + u64 time_rx; + u64 time_tx; + u64 time_scan; + u32 filled; + s8 noise; + char __data[0]; +}; + +struct trace_event_raw_rdev_tdls_oper { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 peer[6]; + enum nl80211_tdls_operation oper; + char __data[0]; +}; + +struct trace_event_raw_rdev_pmksa { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 bssid[6]; + char __data[0]; +}; + +struct trace_event_raw_rdev_probe_client { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 peer[6]; + char __data[0]; +}; + +struct trace_event_raw_rdev_remain_on_channel { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + unsigned int duration; + char __data[0]; +}; + +struct trace_event_raw_rdev_return_int_cookie { + struct trace_entry ent; + char wiphy_name[32]; + int ret; + u64 cookie; + char __data[0]; +}; + +struct trace_event_raw_rdev_cancel_remain_on_channel { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + u64 cookie; + char __data[0]; +}; + +struct trace_event_raw_rdev_mgmt_tx { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + bool offchan; + unsigned int wait; + bool no_cck; + bool dont_wait_for_ack; + char __data[0]; +}; + +struct trace_event_raw_rdev_tx_control_port { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 dest[6]; + __be16 proto; + bool unencrypted; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_noack_map { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u16 noack_map; + char __data[0]; +}; + +struct trace_event_raw_rdev_return_chandef { + struct trace_entry ent; + char wiphy_name[32]; + int ret; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + char __data[0]; +}; + +struct trace_event_raw_rdev_start_nan { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + u8 master_pref; + u8 bands; + char __data[0]; +}; + +struct trace_event_raw_rdev_nan_change_conf { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + u8 master_pref; + u8 bands; + u32 changes; + char __data[0]; +}; + +struct trace_event_raw_rdev_add_nan_func { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + u8 func_type; + u64 cookie; + char __data[0]; +}; + +struct trace_event_raw_rdev_del_nan_func { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + u64 cookie; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_mac_acl { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u32 acl_policy; + char __data[0]; +}; + +struct trace_event_raw_rdev_update_ft_ies { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u16 md; + u32 __data_loc_ie; + char __data[0]; +}; + +struct trace_event_raw_rdev_crit_proto_start { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + u16 proto; + u16 duration; + char __data[0]; +}; + +struct trace_event_raw_rdev_crit_proto_stop { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + char __data[0]; +}; + +struct trace_event_raw_rdev_channel_switch { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + bool radar_required; + bool block_tx; + u8 count; + u32 __data_loc_bcn_ofs; + u32 __data_loc_pres_ofs; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_qos_map { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 num_des; + u8 dscp_exception[42]; + u8 up[16]; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_ap_chanwidth { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + char __data[0]; +}; + +struct trace_event_raw_rdev_add_tx_ts { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 peer[6]; + u8 tsid; + u8 user_prio; + u16 admitted_time; + char __data[0]; +}; + +struct trace_event_raw_rdev_del_tx_ts { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 peer[6]; + u8 tsid; + char __data[0]; +}; + +struct trace_event_raw_rdev_tdls_channel_switch { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 addr[6]; + u8 oper_class; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + char __data[0]; +}; + +struct trace_event_raw_rdev_tdls_cancel_channel_switch { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 addr[6]; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_pmk { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 aa[6]; + u8 pmk_len; + u8 pmk_r0_name_len; + u32 __data_loc_pmk; + u32 __data_loc_pmk_r0_name; + char __data[0]; +}; + +struct trace_event_raw_rdev_del_pmk { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 aa[6]; + char __data[0]; +}; + +struct trace_event_raw_rdev_external_auth { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 bssid[6]; + u8 ssid[33]; + u16 status; + char __data[0]; +}; + +struct trace_event_raw_rdev_start_radar_detection { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + u32 cac_time_ms; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_mcast_rate { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + int mcast_rate[5]; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_coalesce { + struct trace_entry ent; + char wiphy_name[32]; + int n_rules; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_multicast_to_unicast { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + bool enabled; + char __data[0]; +}; + +struct trace_event_raw_rdev_get_ftm_responder_stats { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u64 timestamp; + u32 success_num; + u32 partial_num; + u32 failed_num; + u32 asap_num; + u32 non_asap_num; + u64 duration; + u32 unknown_triggers; + u32 reschedule; + u32 out_of_window; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_return_bool { + struct trace_entry ent; + bool ret; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_netdev_mac_evt { + struct trace_entry ent; + char name[16]; + int ifindex; + u8 macaddr[6]; + char __data[0]; +}; + +struct trace_event_raw_netdev_evt_only { + struct trace_entry ent; + char name[16]; + int ifindex; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_send_rx_assoc { + struct trace_entry ent; + char name[16]; + int ifindex; + u8 bssid[6]; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + char __data[0]; +}; + +struct trace_event_raw_netdev_frame_event { + struct trace_entry ent; + char name[16]; + int ifindex; + u32 __data_loc_frame; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_tx_mlme_mgmt { + struct trace_entry ent; + char name[16]; + int ifindex; + u32 __data_loc_frame; + char __data[0]; +}; + +struct trace_event_raw_netdev_mac_evt { + struct trace_entry ent; + char name[16]; + int ifindex; + u8 mac[6]; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_michael_mic_failure { + struct trace_entry ent; + char name[16]; + int ifindex; + u8 addr[6]; + enum nl80211_key_type key_type; + int key_id; + u8 tsc[6]; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_ready_on_channel { + struct trace_entry ent; + u32 id; + u64 cookie; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + unsigned int duration; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_ready_on_channel_expired { + struct trace_entry ent; + u32 id; + u64 cookie; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_tx_mgmt_expired { + struct trace_entry ent; + u32 id; + u64 cookie; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_new_sta { + struct trace_entry ent; + char name[16]; + int ifindex; + u8 mac_addr[6]; + int generation; + u32 connected_time; + u32 inactive_time; + u32 rx_bytes; + u32 tx_bytes; + u32 rx_packets; + u32 tx_packets; + u32 tx_retries; + u32 tx_failed; + u32 rx_dropped_misc; + u32 beacon_loss_count; + u16 llid; + u16 plid; + u8 plink_state; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_rx_mgmt { + struct trace_entry ent; + u32 id; + int freq; + int sig_dbm; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_mgmt_tx_status { + struct trace_entry ent; + u32 id; + u64 cookie; + bool ack; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_control_port_tx_status { + struct trace_entry ent; + u32 id; + u64 cookie; + bool ack; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_rx_control_port { + struct trace_entry ent; + char name[16]; + int ifindex; + int len; + u8 from[6]; + u16 proto; + bool unencrypted; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_cqm_rssi_notify { + struct trace_entry ent; + char name[16]; + int ifindex; + enum nl80211_cqm_rssi_threshold_event rssi_event; + s32 rssi_level; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_reg_can_beacon { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + enum nl80211_iftype iftype; + bool check_no_ir; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_chandef_dfs_required { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_ch_switch_notify { + struct trace_entry ent; + char name[16]; + int ifindex; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_ch_switch_started_notify { + struct trace_entry ent; + char name[16]; + int ifindex; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_radar_event { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_band band; + u32 control_freq; + u32 freq_offset; + u32 width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_cac_event { + struct trace_entry ent; + char name[16]; + int ifindex; + enum nl80211_radar_event evt; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_rx_evt { + struct trace_entry ent; + char name[16]; + int ifindex; + u8 addr[6]; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_ibss_joined { + struct trace_entry ent; + char name[16]; + int ifindex; + u8 bssid[6]; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_probe_status { + struct trace_entry ent; + char name[16]; + int ifindex; + u8 addr[6]; + u64 cookie; + bool acked; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_cqm_pktloss_notify { + struct trace_entry ent; + char name[16]; + int ifindex; + u8 peer[6]; + u32 num_packets; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_pmksa_candidate_notify { + struct trace_entry ent; + char name[16]; + int ifindex; + int index; + u8 bssid[6]; + bool preauth; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_report_obss_beacon { + struct trace_entry ent; + char wiphy_name[32]; + int freq; + int sig_dbm; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_tdls_oper_request { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 peer[6]; + enum nl80211_tdls_operation oper; + u16 reason_code; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_scan_done { + struct trace_entry ent; + u32 n_channels; + u32 __data_loc_ie; + u32 rates[5]; + u32 wdev_id; + u8 wiphy_mac[6]; + bool no_cck; + bool aborted; + u64 scan_start_tsf; + u8 tsf_bssid[6]; + char __data[0]; +}; + +struct trace_event_raw_wiphy_id_evt { + struct trace_entry ent; + char wiphy_name[32]; + u64 id; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_get_bss { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + u8 bssid[6]; + u32 __data_loc_ssid; + enum ieee80211_bss_type bss_type; + enum ieee80211_privacy privacy; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_inform_bss_frame { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + enum nl80211_bss_scan_width scan_width; + u32 __data_loc_mgmt; + s32 signal; + u64 ts_boottime; + u64 parent_tsf; + u8 parent_bssid[6]; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_bss_evt { + struct trace_entry ent; + u8 bssid[6]; + enum nl80211_band band; + u32 center_freq; + u16 freq_offset; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_return_uint { + struct trace_entry ent; + unsigned int ret; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_return_u32 { + struct trace_entry ent; + u32 ret; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_report_wowlan_wakeup { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + bool non_wireless; + bool disconnect; + bool magic_pkt; + bool gtk_rekey_failure; + bool eap_identity_req; + bool four_way_handshake; + bool rfkill_release; + s32 pattern_idx; + u32 packet_len; + u32 __data_loc_packet; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_ft_event { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u32 __data_loc_ies; + u8 target_ap[6]; + u32 __data_loc_ric_ies; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_stop_iface { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_pmsr_report { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + u64 cookie; + u8 addr[6]; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_pmsr_complete { + struct trace_entry ent; + char wiphy_name[32]; + u32 id; + u64 cookie; + char __data[0]; +}; + +struct trace_event_raw_rdev_update_owe_info { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 peer[6]; + u16 status; + u32 __data_loc_ie; + char __data[0]; +}; + +struct trace_event_raw_cfg80211_update_owe_info_event { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 peer[6]; + u32 __data_loc_ie; + char __data[0]; +}; + +struct trace_event_raw_rdev_probe_mesh_link { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 dest[6]; + char __data[0]; +}; + +struct trace_event_raw_rdev_set_tid_config { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 peer[6]; + char __data[0]; +}; + +struct trace_event_raw_rdev_reset_tid_config { + struct trace_entry ent; + char wiphy_name[32]; + char name[16]; + int ifindex; + u8 peer[6]; + u8 tids; + char __data[0]; +}; + +struct trace_event_data_offsets_rdev_suspend {}; + +struct trace_event_data_offsets_rdev_return_int {}; + +struct trace_event_data_offsets_rdev_scan {}; + +struct trace_event_data_offsets_wiphy_only_evt {}; + +struct trace_event_data_offsets_wiphy_enabled_evt {}; + +struct trace_event_data_offsets_rdev_add_virtual_intf { + u32 vir_intf_name; +}; + +struct trace_event_data_offsets_wiphy_wdev_evt {}; + +struct trace_event_data_offsets_wiphy_wdev_cookie_evt {}; + +struct trace_event_data_offsets_rdev_change_virtual_intf {}; + +struct trace_event_data_offsets_key_handle {}; + +struct trace_event_data_offsets_rdev_add_key {}; + +struct trace_event_data_offsets_rdev_set_default_key {}; + +struct trace_event_data_offsets_rdev_set_default_mgmt_key {}; + +struct trace_event_data_offsets_rdev_set_default_beacon_key {}; + +struct trace_event_data_offsets_rdev_start_ap {}; + +struct trace_event_data_offsets_rdev_change_beacon { + u32 head; + u32 tail; + u32 beacon_ies; + u32 proberesp_ies; + u32 assocresp_ies; + u32 probe_resp; +}; + +struct trace_event_data_offsets_wiphy_netdev_evt {}; + +struct trace_event_data_offsets_station_add_change { + u32 supported_rates; + u32 ext_capab; + u32 supported_channels; + u32 supported_oper_classes; +}; + +struct trace_event_data_offsets_wiphy_netdev_mac_evt {}; + +struct trace_event_data_offsets_station_del {}; + +struct trace_event_data_offsets_rdev_dump_station {}; + +struct trace_event_data_offsets_rdev_return_int_station_info {}; + +struct trace_event_data_offsets_mpath_evt {}; + +struct trace_event_data_offsets_rdev_dump_mpath {}; + +struct trace_event_data_offsets_rdev_get_mpp {}; + +struct trace_event_data_offsets_rdev_dump_mpp {}; + +struct trace_event_data_offsets_rdev_return_int_mpath_info {}; + +struct trace_event_data_offsets_rdev_return_int_mesh_config {}; + +struct trace_event_data_offsets_rdev_update_mesh_config {}; + +struct trace_event_data_offsets_rdev_join_mesh {}; + +struct trace_event_data_offsets_rdev_change_bss {}; + +struct trace_event_data_offsets_rdev_set_txq_params {}; + +struct trace_event_data_offsets_rdev_libertas_set_mesh_channel {}; + +struct trace_event_data_offsets_rdev_set_monitor_channel {}; + +struct trace_event_data_offsets_rdev_auth {}; + +struct trace_event_data_offsets_rdev_assoc {}; + +struct trace_event_data_offsets_rdev_deauth {}; + +struct trace_event_data_offsets_rdev_disassoc {}; + +struct trace_event_data_offsets_rdev_mgmt_tx_cancel_wait {}; + +struct trace_event_data_offsets_rdev_set_power_mgmt {}; + +struct trace_event_data_offsets_rdev_connect {}; + +struct trace_event_data_offsets_rdev_update_connect_params {}; + +struct trace_event_data_offsets_rdev_set_cqm_rssi_config {}; + +struct trace_event_data_offsets_rdev_set_cqm_rssi_range_config {}; + +struct trace_event_data_offsets_rdev_set_cqm_txe_config {}; + +struct trace_event_data_offsets_rdev_disconnect {}; + +struct trace_event_data_offsets_rdev_join_ibss {}; + +struct trace_event_data_offsets_rdev_join_ocb {}; + +struct trace_event_data_offsets_rdev_set_wiphy_params {}; + +struct trace_event_data_offsets_rdev_set_tx_power {}; + +struct trace_event_data_offsets_rdev_return_int_int {}; + +struct trace_event_data_offsets_rdev_set_bitrate_mask {}; + +struct trace_event_data_offsets_rdev_update_mgmt_frame_registrations {}; + +struct trace_event_data_offsets_rdev_return_int_tx_rx {}; + +struct trace_event_data_offsets_rdev_return_void_tx_rx {}; + +struct trace_event_data_offsets_tx_rx_evt {}; + +struct trace_event_data_offsets_wiphy_netdev_id_evt {}; + +struct trace_event_data_offsets_rdev_tdls_mgmt { + u32 buf; +}; + +struct trace_event_data_offsets_rdev_dump_survey {}; + +struct trace_event_data_offsets_rdev_return_int_survey_info {}; + +struct trace_event_data_offsets_rdev_tdls_oper {}; + +struct trace_event_data_offsets_rdev_pmksa {}; + +struct trace_event_data_offsets_rdev_probe_client {}; + +struct trace_event_data_offsets_rdev_remain_on_channel {}; + +struct trace_event_data_offsets_rdev_return_int_cookie {}; + +struct trace_event_data_offsets_rdev_cancel_remain_on_channel {}; + +struct trace_event_data_offsets_rdev_mgmt_tx {}; + +struct trace_event_data_offsets_rdev_tx_control_port {}; + +struct trace_event_data_offsets_rdev_set_noack_map {}; + +struct trace_event_data_offsets_rdev_return_chandef {}; + +struct trace_event_data_offsets_rdev_start_nan {}; + +struct trace_event_data_offsets_rdev_nan_change_conf {}; + +struct trace_event_data_offsets_rdev_add_nan_func {}; + +struct trace_event_data_offsets_rdev_del_nan_func {}; + +struct trace_event_data_offsets_rdev_set_mac_acl {}; + +struct trace_event_data_offsets_rdev_update_ft_ies { + u32 ie; +}; + +struct trace_event_data_offsets_rdev_crit_proto_start {}; + +struct trace_event_data_offsets_rdev_crit_proto_stop {}; + +struct trace_event_data_offsets_rdev_channel_switch { + u32 bcn_ofs; + u32 pres_ofs; +}; + +struct trace_event_data_offsets_rdev_set_qos_map {}; + +struct trace_event_data_offsets_rdev_set_ap_chanwidth {}; + +struct trace_event_data_offsets_rdev_add_tx_ts {}; + +struct trace_event_data_offsets_rdev_del_tx_ts {}; + +struct trace_event_data_offsets_rdev_tdls_channel_switch {}; + +struct trace_event_data_offsets_rdev_tdls_cancel_channel_switch {}; + +struct trace_event_data_offsets_rdev_set_pmk { + u32 pmk; + u32 pmk_r0_name; +}; + +struct trace_event_data_offsets_rdev_del_pmk {}; + +struct trace_event_data_offsets_rdev_external_auth {}; + +struct trace_event_data_offsets_rdev_start_radar_detection {}; + +struct trace_event_data_offsets_rdev_set_mcast_rate {}; + +struct trace_event_data_offsets_rdev_set_coalesce {}; + +struct trace_event_data_offsets_rdev_set_multicast_to_unicast {}; + +struct trace_event_data_offsets_rdev_get_ftm_responder_stats {}; + +struct trace_event_data_offsets_cfg80211_return_bool {}; + +struct trace_event_data_offsets_cfg80211_netdev_mac_evt {}; + +struct trace_event_data_offsets_netdev_evt_only {}; + +struct trace_event_data_offsets_cfg80211_send_rx_assoc {}; + +struct trace_event_data_offsets_netdev_frame_event { + u32 frame; +}; + +struct trace_event_data_offsets_cfg80211_tx_mlme_mgmt { + u32 frame; +}; + +struct trace_event_data_offsets_netdev_mac_evt {}; + +struct trace_event_data_offsets_cfg80211_michael_mic_failure {}; + +struct trace_event_data_offsets_cfg80211_ready_on_channel {}; + +struct trace_event_data_offsets_cfg80211_ready_on_channel_expired {}; + +struct trace_event_data_offsets_cfg80211_tx_mgmt_expired {}; + +struct trace_event_data_offsets_cfg80211_new_sta {}; + +struct trace_event_data_offsets_cfg80211_rx_mgmt {}; + +struct trace_event_data_offsets_cfg80211_mgmt_tx_status {}; + +struct trace_event_data_offsets_cfg80211_control_port_tx_status {}; + +struct trace_event_data_offsets_cfg80211_rx_control_port {}; + +struct trace_event_data_offsets_cfg80211_cqm_rssi_notify {}; + +struct trace_event_data_offsets_cfg80211_reg_can_beacon {}; + +struct trace_event_data_offsets_cfg80211_chandef_dfs_required {}; + +struct trace_event_data_offsets_cfg80211_ch_switch_notify {}; + +struct trace_event_data_offsets_cfg80211_ch_switch_started_notify {}; + +struct trace_event_data_offsets_cfg80211_radar_event {}; + +struct trace_event_data_offsets_cfg80211_cac_event {}; + +struct trace_event_data_offsets_cfg80211_rx_evt {}; + +struct trace_event_data_offsets_cfg80211_ibss_joined {}; + +struct trace_event_data_offsets_cfg80211_probe_status {}; + +struct trace_event_data_offsets_cfg80211_cqm_pktloss_notify {}; + +struct trace_event_data_offsets_cfg80211_pmksa_candidate_notify {}; + +struct trace_event_data_offsets_cfg80211_report_obss_beacon {}; + +struct trace_event_data_offsets_cfg80211_tdls_oper_request {}; + +struct trace_event_data_offsets_cfg80211_scan_done { + u32 ie; +}; + +struct trace_event_data_offsets_wiphy_id_evt {}; + +struct trace_event_data_offsets_cfg80211_get_bss { + u32 ssid; +}; + +struct trace_event_data_offsets_cfg80211_inform_bss_frame { + u32 mgmt; +}; + +struct trace_event_data_offsets_cfg80211_bss_evt {}; + +struct trace_event_data_offsets_cfg80211_return_uint {}; + +struct trace_event_data_offsets_cfg80211_return_u32 {}; + +struct trace_event_data_offsets_cfg80211_report_wowlan_wakeup { + u32 packet; +}; + +struct trace_event_data_offsets_cfg80211_ft_event { + u32 ies; + u32 ric_ies; +}; + +struct trace_event_data_offsets_cfg80211_stop_iface {}; + +struct trace_event_data_offsets_cfg80211_pmsr_report {}; + +struct trace_event_data_offsets_cfg80211_pmsr_complete {}; + +struct trace_event_data_offsets_rdev_update_owe_info { + u32 ie; +}; + +struct trace_event_data_offsets_cfg80211_update_owe_info_event { + u32 ie; +}; + +struct trace_event_data_offsets_rdev_probe_mesh_link {}; + +struct trace_event_data_offsets_rdev_set_tid_config {}; + +struct trace_event_data_offsets_rdev_reset_tid_config {}; + +typedef void (*btf_trace_rdev_suspend)(void *, struct wiphy *, struct cfg80211_wowlan *); + +typedef void (*btf_trace_rdev_return_int)(void *, struct wiphy *, int); + +typedef void (*btf_trace_rdev_scan)(void *, struct wiphy *, struct cfg80211_scan_request *); + +typedef void (*btf_trace_rdev_resume)(void *, struct wiphy *); + +typedef void (*btf_trace_rdev_return_void)(void *, struct wiphy *); + +typedef void (*btf_trace_rdev_get_antenna)(void *, struct wiphy *); + +typedef void (*btf_trace_rdev_rfkill_poll)(void *, struct wiphy *); + +typedef void (*btf_trace_rdev_set_wakeup)(void *, struct wiphy *, bool); + +typedef void (*btf_trace_rdev_add_virtual_intf)(void *, struct wiphy *, char *, enum nl80211_iftype); + +typedef void (*btf_trace_rdev_return_wdev)(void *, struct wiphy *, struct wireless_dev *); + +typedef void (*btf_trace_rdev_del_virtual_intf)(void *, struct wiphy *, struct wireless_dev *); + +typedef void (*btf_trace_rdev_change_virtual_intf)(void *, struct wiphy *, struct net_device *, enum nl80211_iftype); + +typedef void (*btf_trace_rdev_get_key)(void *, struct wiphy *, struct net_device *, u8, bool, const u8 *); + +typedef void (*btf_trace_rdev_del_key)(void *, struct wiphy *, struct net_device *, u8, bool, const u8 *); + +typedef void (*btf_trace_rdev_add_key)(void *, struct wiphy *, struct net_device *, u8, bool, const u8 *, u8); + +typedef void (*btf_trace_rdev_set_default_key)(void *, struct wiphy *, struct net_device *, u8, bool, bool); + +typedef void (*btf_trace_rdev_set_default_mgmt_key)(void *, struct wiphy *, struct net_device *, u8); + +typedef void (*btf_trace_rdev_set_default_beacon_key)(void *, struct wiphy *, struct net_device *, u8); + +typedef void (*btf_trace_rdev_start_ap)(void *, struct wiphy *, struct net_device *, struct cfg80211_ap_settings *); + +typedef void (*btf_trace_rdev_change_beacon)(void *, struct wiphy *, struct net_device *, struct cfg80211_beacon_data *); + +typedef void (*btf_trace_rdev_stop_ap)(void *, struct wiphy *, struct net_device *); + +typedef void (*btf_trace_rdev_set_rekey_data)(void *, struct wiphy *, struct net_device *); + +typedef void (*btf_trace_rdev_get_mesh_config)(void *, struct wiphy *, struct net_device *); + +typedef void (*btf_trace_rdev_leave_mesh)(void *, struct wiphy *, struct net_device *); + +typedef void (*btf_trace_rdev_leave_ibss)(void *, struct wiphy *, struct net_device *); + +typedef void (*btf_trace_rdev_leave_ocb)(void *, struct wiphy *, struct net_device *); + +typedef void (*btf_trace_rdev_flush_pmksa)(void *, struct wiphy *, struct net_device *); + +typedef void (*btf_trace_rdev_end_cac)(void *, struct wiphy *, struct net_device *); + +typedef void (*btf_trace_rdev_add_station)(void *, struct wiphy *, struct net_device *, u8 *, struct station_parameters *); + +typedef void (*btf_trace_rdev_change_station)(void *, struct wiphy *, struct net_device *, u8 *, struct station_parameters *); + +typedef void (*btf_trace_rdev_del_station)(void *, struct wiphy *, struct net_device *, struct station_del_parameters *); + +typedef void (*btf_trace_rdev_get_station)(void *, struct wiphy *, struct net_device *, const u8 *); + +typedef void (*btf_trace_rdev_del_mpath)(void *, struct wiphy *, struct net_device *, const u8 *); + +typedef void (*btf_trace_rdev_dump_station)(void *, struct wiphy *, struct net_device *, int, u8 *); + +typedef void (*btf_trace_rdev_return_int_station_info)(void *, struct wiphy *, int, struct station_info *); + +typedef void (*btf_trace_rdev_add_mpath)(void *, struct wiphy *, struct net_device *, u8 *, u8 *); + +typedef void (*btf_trace_rdev_change_mpath)(void *, struct wiphy *, struct net_device *, u8 *, u8 *); + +typedef void (*btf_trace_rdev_get_mpath)(void *, struct wiphy *, struct net_device *, u8 *, u8 *); + +typedef void (*btf_trace_rdev_dump_mpath)(void *, struct wiphy *, struct net_device *, int, u8 *, u8 *); + +typedef void (*btf_trace_rdev_get_mpp)(void *, struct wiphy *, struct net_device *, u8 *, u8 *); + +typedef void (*btf_trace_rdev_dump_mpp)(void *, struct wiphy *, struct net_device *, int, u8 *, u8 *); + +typedef void (*btf_trace_rdev_return_int_mpath_info)(void *, struct wiphy *, int, struct mpath_info *); + +typedef void (*btf_trace_rdev_return_int_mesh_config)(void *, struct wiphy *, int, struct mesh_config *); + +typedef void (*btf_trace_rdev_update_mesh_config)(void *, struct wiphy *, struct net_device *, u32, const struct mesh_config *); + +typedef void (*btf_trace_rdev_join_mesh)(void *, struct wiphy *, struct net_device *, const struct mesh_config *, const struct mesh_setup *); + +typedef void (*btf_trace_rdev_change_bss)(void *, struct wiphy *, struct net_device *, struct bss_parameters *); + +typedef void (*btf_trace_rdev_set_txq_params)(void *, struct wiphy *, struct net_device *, struct ieee80211_txq_params *); + +typedef void (*btf_trace_rdev_libertas_set_mesh_channel)(void *, struct wiphy *, struct net_device *, struct ieee80211_channel *); + +typedef void (*btf_trace_rdev_set_monitor_channel)(void *, struct wiphy *, struct cfg80211_chan_def *); + +typedef void (*btf_trace_rdev_auth)(void *, struct wiphy *, struct net_device *, struct cfg80211_auth_request *); + +typedef void (*btf_trace_rdev_assoc)(void *, struct wiphy *, struct net_device *, struct cfg80211_assoc_request *); + +typedef void (*btf_trace_rdev_deauth)(void *, struct wiphy *, struct net_device *, struct cfg80211_deauth_request *); + +typedef void (*btf_trace_rdev_disassoc)(void *, struct wiphy *, struct net_device *, struct cfg80211_disassoc_request *); + +typedef void (*btf_trace_rdev_mgmt_tx_cancel_wait)(void *, struct wiphy *, struct wireless_dev *, u64); + +typedef void (*btf_trace_rdev_set_power_mgmt)(void *, struct wiphy *, struct net_device *, bool, int); + +typedef void (*btf_trace_rdev_connect)(void *, struct wiphy *, struct net_device *, struct cfg80211_connect_params *); + +typedef void (*btf_trace_rdev_update_connect_params)(void *, struct wiphy *, struct net_device *, struct cfg80211_connect_params *, u32); + +typedef void (*btf_trace_rdev_set_cqm_rssi_config)(void *, struct wiphy *, struct net_device *, s32, u32); + +typedef void (*btf_trace_rdev_set_cqm_rssi_range_config)(void *, struct wiphy *, struct net_device *, s32, s32); + +typedef void (*btf_trace_rdev_set_cqm_txe_config)(void *, struct wiphy *, struct net_device *, u32, u32, u32); + +typedef void (*btf_trace_rdev_disconnect)(void *, struct wiphy *, struct net_device *, u16); + +typedef void (*btf_trace_rdev_join_ibss)(void *, struct wiphy *, struct net_device *, struct cfg80211_ibss_params *); + +typedef void (*btf_trace_rdev_join_ocb)(void *, struct wiphy *, struct net_device *, const struct ocb_setup *); + +typedef void (*btf_trace_rdev_set_wiphy_params)(void *, struct wiphy *, u32); + +typedef void (*btf_trace_rdev_get_tx_power)(void *, struct wiphy *, struct wireless_dev *); + +typedef void (*btf_trace_rdev_set_tx_power)(void *, struct wiphy *, struct wireless_dev *, enum nl80211_tx_power_setting, int); + +typedef void (*btf_trace_rdev_return_int_int)(void *, struct wiphy *, int, int); + +typedef void (*btf_trace_rdev_set_bitrate_mask)(void *, struct wiphy *, struct net_device *, const u8 *, const struct cfg80211_bitrate_mask *); + +typedef void (*btf_trace_rdev_update_mgmt_frame_registrations)(void *, struct wiphy *, struct wireless_dev *, struct mgmt_frame_regs *); + +typedef void (*btf_trace_rdev_return_int_tx_rx)(void *, struct wiphy *, int, u32, u32); + +typedef void (*btf_trace_rdev_return_void_tx_rx)(void *, struct wiphy *, u32, u32, u32, u32); + +typedef void (*btf_trace_rdev_set_antenna)(void *, struct wiphy *, u32, u32); + +typedef void (*btf_trace_rdev_sched_scan_start)(void *, struct wiphy *, struct net_device *, u64); + +typedef void (*btf_trace_rdev_sched_scan_stop)(void *, struct wiphy *, struct net_device *, u64); + +typedef void (*btf_trace_rdev_tdls_mgmt)(void *, struct wiphy *, struct net_device *, u8 *, u8, u8, u16, u32, bool, const u8 *, size_t); + +typedef void (*btf_trace_rdev_dump_survey)(void *, struct wiphy *, struct net_device *, int); + +typedef void (*btf_trace_rdev_return_int_survey_info)(void *, struct wiphy *, int, struct survey_info *); + +typedef void (*btf_trace_rdev_tdls_oper)(void *, struct wiphy *, struct net_device *, u8 *, enum nl80211_tdls_operation); + +typedef void (*btf_trace_rdev_probe_client)(void *, struct wiphy *, struct net_device *, const u8 *); + +typedef void (*btf_trace_rdev_set_pmksa)(void *, struct wiphy *, struct net_device *, struct cfg80211_pmksa *); + +typedef void (*btf_trace_rdev_del_pmksa)(void *, struct wiphy *, struct net_device *, struct cfg80211_pmksa *); + +typedef void (*btf_trace_rdev_remain_on_channel)(void *, struct wiphy *, struct wireless_dev *, struct ieee80211_channel *, unsigned int); + +typedef void (*btf_trace_rdev_return_int_cookie)(void *, struct wiphy *, int, u64); + +typedef void (*btf_trace_rdev_cancel_remain_on_channel)(void *, struct wiphy *, struct wireless_dev *, u64); + +typedef void (*btf_trace_rdev_mgmt_tx)(void *, struct wiphy *, struct wireless_dev *, struct cfg80211_mgmt_tx_params *); + +typedef void (*btf_trace_rdev_tx_control_port)(void *, struct wiphy *, struct net_device *, const u8 *, size_t, const u8 *, __be16, bool); + +typedef void (*btf_trace_rdev_set_noack_map)(void *, struct wiphy *, struct net_device *, u16); + +typedef void (*btf_trace_rdev_get_channel)(void *, struct wiphy *, struct wireless_dev *); + +typedef void (*btf_trace_rdev_return_chandef)(void *, struct wiphy *, int, struct cfg80211_chan_def *); + +typedef void (*btf_trace_rdev_start_p2p_device)(void *, struct wiphy *, struct wireless_dev *); + +typedef void (*btf_trace_rdev_stop_p2p_device)(void *, struct wiphy *, struct wireless_dev *); + +typedef void (*btf_trace_rdev_start_nan)(void *, struct wiphy *, struct wireless_dev *, struct cfg80211_nan_conf *); + +typedef void (*btf_trace_rdev_nan_change_conf)(void *, struct wiphy *, struct wireless_dev *, struct cfg80211_nan_conf *, u32); + +typedef void (*btf_trace_rdev_stop_nan)(void *, struct wiphy *, struct wireless_dev *); + +typedef void (*btf_trace_rdev_add_nan_func)(void *, struct wiphy *, struct wireless_dev *, const struct cfg80211_nan_func *); + +typedef void (*btf_trace_rdev_del_nan_func)(void *, struct wiphy *, struct wireless_dev *, u64); + +typedef void (*btf_trace_rdev_set_mac_acl)(void *, struct wiphy *, struct net_device *, struct cfg80211_acl_data *); + +typedef void (*btf_trace_rdev_update_ft_ies)(void *, struct wiphy *, struct net_device *, struct cfg80211_update_ft_ies_params *); + +typedef void (*btf_trace_rdev_crit_proto_start)(void *, struct wiphy *, struct wireless_dev *, enum nl80211_crit_proto_id, u16); + +typedef void (*btf_trace_rdev_crit_proto_stop)(void *, struct wiphy *, struct wireless_dev *); + +typedef void (*btf_trace_rdev_channel_switch)(void *, struct wiphy *, struct net_device *, struct cfg80211_csa_settings *); + +typedef void (*btf_trace_rdev_set_qos_map)(void *, struct wiphy *, struct net_device *, struct cfg80211_qos_map *); + +typedef void (*btf_trace_rdev_set_ap_chanwidth)(void *, struct wiphy *, struct net_device *, struct cfg80211_chan_def *); + +typedef void (*btf_trace_rdev_add_tx_ts)(void *, struct wiphy *, struct net_device *, u8, const u8 *, u8, u16); + +typedef void (*btf_trace_rdev_del_tx_ts)(void *, struct wiphy *, struct net_device *, u8, const u8 *); + +typedef void (*btf_trace_rdev_tdls_channel_switch)(void *, struct wiphy *, struct net_device *, const u8 *, u8, struct cfg80211_chan_def *); + +typedef void (*btf_trace_rdev_tdls_cancel_channel_switch)(void *, struct wiphy *, struct net_device *, const u8 *); + +typedef void (*btf_trace_rdev_set_pmk)(void *, struct wiphy *, struct net_device *, struct cfg80211_pmk_conf *); + +typedef void (*btf_trace_rdev_del_pmk)(void *, struct wiphy *, struct net_device *, const u8 *); + +typedef void (*btf_trace_rdev_external_auth)(void *, struct wiphy *, struct net_device *, struct cfg80211_external_auth_params *); + +typedef void (*btf_trace_rdev_start_radar_detection)(void *, struct wiphy *, struct net_device *, struct cfg80211_chan_def *, u32); + +typedef void (*btf_trace_rdev_set_mcast_rate)(void *, struct wiphy *, struct net_device *, int *); + +typedef void (*btf_trace_rdev_set_coalesce)(void *, struct wiphy *, struct cfg80211_coalesce *); + +typedef void (*btf_trace_rdev_abort_scan)(void *, struct wiphy *, struct wireless_dev *); + +typedef void (*btf_trace_rdev_set_multicast_to_unicast)(void *, struct wiphy *, struct net_device *, const bool); + +typedef void (*btf_trace_rdev_get_txq_stats)(void *, struct wiphy *, struct wireless_dev *); + +typedef void (*btf_trace_rdev_get_ftm_responder_stats)(void *, struct wiphy *, struct net_device *, struct cfg80211_ftm_responder_stats *); + +typedef void (*btf_trace_rdev_start_pmsr)(void *, struct wiphy *, struct wireless_dev *, u64); + +typedef void (*btf_trace_rdev_abort_pmsr)(void *, struct wiphy *, struct wireless_dev *, u64); + +typedef void (*btf_trace_cfg80211_return_bool)(void *, bool); + +typedef void (*btf_trace_cfg80211_notify_new_peer_candidate)(void *, struct net_device *, const u8 *); + +typedef void (*btf_trace_cfg80211_send_rx_auth)(void *, struct net_device *); + +typedef void (*btf_trace_cfg80211_send_rx_assoc)(void *, struct net_device *, struct cfg80211_bss *); + +typedef void (*btf_trace_cfg80211_rx_unprot_mlme_mgmt)(void *, struct net_device *, const u8 *, int); + +typedef void (*btf_trace_cfg80211_rx_mlme_mgmt)(void *, struct net_device *, const u8 *, int); + +typedef void (*btf_trace_cfg80211_tx_mlme_mgmt)(void *, struct net_device *, const u8 *, int); + +typedef void (*btf_trace_cfg80211_send_auth_timeout)(void *, struct net_device *, const u8 *); + +typedef void (*btf_trace_cfg80211_send_assoc_timeout)(void *, struct net_device *, const u8 *); + +typedef void (*btf_trace_cfg80211_michael_mic_failure)(void *, struct net_device *, const u8 *, enum nl80211_key_type, int, const u8 *); + +typedef void (*btf_trace_cfg80211_ready_on_channel)(void *, struct wireless_dev *, u64, struct ieee80211_channel *, unsigned int); + +typedef void (*btf_trace_cfg80211_ready_on_channel_expired)(void *, struct wireless_dev *, u64, struct ieee80211_channel *); + +typedef void (*btf_trace_cfg80211_tx_mgmt_expired)(void *, struct wireless_dev *, u64, struct ieee80211_channel *); + +typedef void (*btf_trace_cfg80211_new_sta)(void *, struct net_device *, const u8 *, struct station_info *); + +typedef void (*btf_trace_cfg80211_del_sta)(void *, struct net_device *, const u8 *); + +typedef void (*btf_trace_cfg80211_rx_mgmt)(void *, struct wireless_dev *, int, int); + +typedef void (*btf_trace_cfg80211_mgmt_tx_status)(void *, struct wireless_dev *, u64, bool); + +typedef void (*btf_trace_cfg80211_control_port_tx_status)(void *, struct wireless_dev *, u64, bool); + +typedef void (*btf_trace_cfg80211_rx_control_port)(void *, struct net_device *, struct sk_buff *, bool); + +typedef void (*btf_trace_cfg80211_cqm_rssi_notify)(void *, struct net_device *, enum nl80211_cqm_rssi_threshold_event, s32); + +typedef void (*btf_trace_cfg80211_reg_can_beacon)(void *, struct wiphy *, struct cfg80211_chan_def *, enum nl80211_iftype, bool); + +typedef void (*btf_trace_cfg80211_chandef_dfs_required)(void *, struct wiphy *, struct cfg80211_chan_def *); + +typedef void (*btf_trace_cfg80211_ch_switch_notify)(void *, struct net_device *, struct cfg80211_chan_def *); + +typedef void (*btf_trace_cfg80211_ch_switch_started_notify)(void *, struct net_device *, struct cfg80211_chan_def *); + +typedef void (*btf_trace_cfg80211_radar_event)(void *, struct wiphy *, struct cfg80211_chan_def *); + +typedef void (*btf_trace_cfg80211_cac_event)(void *, struct net_device *, enum nl80211_radar_event); + +typedef void (*btf_trace_cfg80211_rx_spurious_frame)(void *, struct net_device *, const u8 *); + +typedef void (*btf_trace_cfg80211_rx_unexpected_4addr_frame)(void *, struct net_device *, const u8 *); + +typedef void (*btf_trace_cfg80211_ibss_joined)(void *, struct net_device *, const u8 *, struct ieee80211_channel *); + +typedef void (*btf_trace_cfg80211_probe_status)(void *, struct net_device *, const u8 *, u64, bool); + +typedef void (*btf_trace_cfg80211_cqm_pktloss_notify)(void *, struct net_device *, const u8 *, u32); + +typedef void (*btf_trace_cfg80211_gtk_rekey_notify)(void *, struct net_device *, const u8 *); + +typedef void (*btf_trace_cfg80211_pmksa_candidate_notify)(void *, struct net_device *, int, const u8 *, bool); + +typedef void (*btf_trace_cfg80211_report_obss_beacon)(void *, struct wiphy *, const u8 *, size_t, int, int); + +typedef void (*btf_trace_cfg80211_tdls_oper_request)(void *, struct wiphy *, struct net_device *, const u8 *, enum nl80211_tdls_operation, u16); + +typedef void (*btf_trace_cfg80211_scan_done)(void *, struct cfg80211_scan_request *, struct cfg80211_scan_info *); + +typedef void (*btf_trace_cfg80211_sched_scan_stopped)(void *, struct wiphy *, u64); + +typedef void (*btf_trace_cfg80211_sched_scan_results)(void *, struct wiphy *, u64); + +typedef void (*btf_trace_cfg80211_get_bss)(void *, struct wiphy *, struct ieee80211_channel *, const u8 *, const u8 *, size_t, enum ieee80211_bss_type, enum ieee80211_privacy); + +typedef void (*btf_trace_cfg80211_inform_bss_frame)(void *, struct wiphy *, struct cfg80211_inform_bss *, struct ieee80211_mgmt *, size_t); + +typedef void (*btf_trace_cfg80211_return_bss)(void *, struct cfg80211_bss *); + +typedef void (*btf_trace_cfg80211_return_uint)(void *, unsigned int); + +typedef void (*btf_trace_cfg80211_return_u32)(void *, u32); + +typedef void (*btf_trace_cfg80211_report_wowlan_wakeup)(void *, struct wiphy *, struct wireless_dev *, struct cfg80211_wowlan_wakeup *); + +typedef void (*btf_trace_cfg80211_ft_event)(void *, struct wiphy *, struct net_device *, struct cfg80211_ft_event_params *); + +typedef void (*btf_trace_cfg80211_stop_iface)(void *, struct wiphy *, struct wireless_dev *); + +typedef void (*btf_trace_cfg80211_pmsr_report)(void *, struct wiphy *, struct wireless_dev *, u64, const u8 *); + +typedef void (*btf_trace_cfg80211_pmsr_complete)(void *, struct wiphy *, struct wireless_dev *, u64); + +typedef void (*btf_trace_rdev_update_owe_info)(void *, struct wiphy *, struct net_device *, struct cfg80211_update_owe_info *); + +typedef void (*btf_trace_cfg80211_update_owe_info_event)(void *, struct wiphy *, struct net_device *, struct cfg80211_update_owe_info *); + +typedef void (*btf_trace_rdev_probe_mesh_link)(void *, struct wiphy *, struct net_device *, const u8 *, const u8 *, size_t); + +typedef void (*btf_trace_rdev_set_tid_config)(void *, struct wiphy *, struct net_device *, struct cfg80211_tid_config *); + +typedef void (*btf_trace_rdev_reset_tid_config)(void *, struct wiphy *, struct net_device *, const u8 *, u8); + +enum nl80211_peer_measurement_status { + NL80211_PMSR_STATUS_SUCCESS = 0, + NL80211_PMSR_STATUS_REFUSED = 1, + NL80211_PMSR_STATUS_TIMEOUT = 2, + NL80211_PMSR_STATUS_FAILURE = 3, +}; + +enum nl80211_peer_measurement_resp { + __NL80211_PMSR_RESP_ATTR_INVALID = 0, + NL80211_PMSR_RESP_ATTR_DATA = 1, + NL80211_PMSR_RESP_ATTR_STATUS = 2, + NL80211_PMSR_RESP_ATTR_HOST_TIME = 3, + NL80211_PMSR_RESP_ATTR_AP_TSF = 4, + NL80211_PMSR_RESP_ATTR_FINAL = 5, + NL80211_PMSR_RESP_ATTR_PAD = 6, + NUM_NL80211_PMSR_RESP_ATTRS = 7, + NL80211_PMSR_RESP_ATTR_MAX = 6, +}; + +enum nl80211_peer_measurement_ftm_failure_reasons { + NL80211_PMSR_FTM_FAILURE_UNSPECIFIED = 0, + NL80211_PMSR_FTM_FAILURE_NO_RESPONSE = 1, + NL80211_PMSR_FTM_FAILURE_REJECTED = 2, + NL80211_PMSR_FTM_FAILURE_WRONG_CHANNEL = 3, + NL80211_PMSR_FTM_FAILURE_PEER_NOT_CAPABLE = 4, + NL80211_PMSR_FTM_FAILURE_INVALID_TIMESTAMP = 5, + NL80211_PMSR_FTM_FAILURE_PEER_BUSY = 6, + NL80211_PMSR_FTM_FAILURE_BAD_CHANGED_PARAMS = 7, +}; + +enum nl80211_peer_measurement_ftm_resp { + __NL80211_PMSR_FTM_RESP_ATTR_INVALID = 0, + NL80211_PMSR_FTM_RESP_ATTR_FAIL_REASON = 1, + NL80211_PMSR_FTM_RESP_ATTR_BURST_INDEX = 2, + NL80211_PMSR_FTM_RESP_ATTR_NUM_FTMR_ATTEMPTS = 3, + NL80211_PMSR_FTM_RESP_ATTR_NUM_FTMR_SUCCESSES = 4, + NL80211_PMSR_FTM_RESP_ATTR_BUSY_RETRY_TIME = 5, + NL80211_PMSR_FTM_RESP_ATTR_NUM_BURSTS_EXP = 6, + NL80211_PMSR_FTM_RESP_ATTR_BURST_DURATION = 7, + NL80211_PMSR_FTM_RESP_ATTR_FTMS_PER_BURST = 8, + NL80211_PMSR_FTM_RESP_ATTR_RSSI_AVG = 9, + NL80211_PMSR_FTM_RESP_ATTR_RSSI_SPREAD = 10, + NL80211_PMSR_FTM_RESP_ATTR_TX_RATE = 11, + NL80211_PMSR_FTM_RESP_ATTR_RX_RATE = 12, + NL80211_PMSR_FTM_RESP_ATTR_RTT_AVG = 13, + NL80211_PMSR_FTM_RESP_ATTR_RTT_VARIANCE = 14, + NL80211_PMSR_FTM_RESP_ATTR_RTT_SPREAD = 15, + NL80211_PMSR_FTM_RESP_ATTR_DIST_AVG = 16, + NL80211_PMSR_FTM_RESP_ATTR_DIST_VARIANCE = 17, + NL80211_PMSR_FTM_RESP_ATTR_DIST_SPREAD = 18, + NL80211_PMSR_FTM_RESP_ATTR_LCI = 19, + NL80211_PMSR_FTM_RESP_ATTR_CIVICLOC = 20, + NL80211_PMSR_FTM_RESP_ATTR_PAD = 21, + NUM_NL80211_PMSR_FTM_RESP_ATTR = 22, + NL80211_PMSR_FTM_RESP_ATTR_MAX = 21, +}; + +struct cfg80211_pmsr_ftm_result { + const u8 *lci; + const u8 *civicloc; + unsigned int lci_len; + unsigned int civicloc_len; + enum nl80211_peer_measurement_ftm_failure_reasons failure_reason; + u32 num_ftmr_attempts; + u32 num_ftmr_successes; + s16 burst_index; + u8 busy_retry_time; + u8 num_bursts_exp; + u8 burst_duration; + u8 ftms_per_burst; + s32 rssi_avg; + s32 rssi_spread; + struct rate_info tx_rate; + struct rate_info rx_rate; + s64 rtt_avg; + s64 rtt_variance; + s64 rtt_spread; + s64 dist_avg; + s64 dist_variance; + s64 dist_spread; + u16 num_ftmr_attempts_valid: 1; + u16 num_ftmr_successes_valid: 1; + u16 rssi_avg_valid: 1; + u16 rssi_spread_valid: 1; + u16 tx_rate_valid: 1; + u16 rx_rate_valid: 1; + u16 rtt_avg_valid: 1; + u16 rtt_variance_valid: 1; + u16 rtt_spread_valid: 1; + u16 dist_avg_valid: 1; + u16 dist_variance_valid: 1; + u16 dist_spread_valid: 1; +}; + +struct cfg80211_pmsr_result { + u64 host_time; + u64 ap_tsf; + enum nl80211_peer_measurement_status status; + u8 addr[6]; + u8 final: 1; + u8 ap_tsf_valid: 1; + enum nl80211_peer_measurement_type type; + union { + struct cfg80211_pmsr_ftm_result ftm; + }; +}; + +struct ieee80211_channel_sw_ie { + u8 mode; + u8 new_ch_num; + u8 count; +}; + +struct ieee80211_sec_chan_offs_ie { + u8 sec_chan_offs; +}; + +struct ieee80211_mesh_chansw_params_ie { + u8 mesh_ttl; + u8 mesh_flags; + __le16 mesh_reason; + __le16 mesh_pre_value; +}; + +struct ieee80211_wide_bw_chansw_ie { + u8 new_channel_width; + u8 new_center_freq_seg0; + u8 new_center_freq_seg1; +}; + +struct ieee80211_tim_ie { + u8 dtim_count; + u8 dtim_period; + u8 bitmap_ctrl; + u8 virtual_map[1]; +}; + +struct ieee80211_meshconf_ie { + u8 meshconf_psel; + u8 meshconf_pmetric; + u8 meshconf_congest; + u8 meshconf_synch; + u8 meshconf_auth; + u8 meshconf_form; + u8 meshconf_cap; +}; + +struct ieee80211_rann_ie { + u8 rann_flags; + u8 rann_hopcount; + u8 rann_ttl; + u8 rann_addr[6]; + __le32 rann_seq; + __le32 rann_interval; + __le32 rann_metric; +} __attribute__((packed)); + +struct ieee80211_addba_ext_ie { + u8 data; +}; + +struct ieee80211_aid_response_ie { + __le16 aid; + u8 switch_count; + __le16 response_int; +} __attribute__((packed)); + +struct ieee80211_ch_switch_timing { + __le16 switch_time; + __le16 switch_timeout; +}; + +struct ieee80211_tdls_lnkie { + u8 ie_type; + u8 ie_len; + u8 bssid[6]; + u8 init_sta[6]; + u8 resp_sta[6]; +}; + +struct ieee80211_p2p_noa_desc { + u8 count; + __le32 duration; + __le32 interval; + __le32 start_time; +} __attribute__((packed)); + +struct ieee80211_p2p_noa_attr { + u8 index; + u8 oppps_ctwindow; + struct ieee80211_p2p_noa_desc desc[4]; +} __attribute__((packed)); + +struct ieee80211_vht_operation { + u8 chan_width; + u8 center_freq_seg0_idx; + u8 center_freq_seg1_idx; + __le16 basic_mcs_set; +} __attribute__((packed)); + +struct ieee80211_he_spr { + u8 he_sr_control; + u8 optional[0]; +}; + +struct ieee80211_he_mu_edca_param_ac_rec { + u8 aifsn; + u8 ecw_min_max; + u8 mu_edca_timer; +}; + +struct ieee80211_mu_edca_param_set { + u8 mu_qos_info; + struct ieee80211_he_mu_edca_param_ac_rec ac_be; + struct ieee80211_he_mu_edca_param_ac_rec ac_bk; + struct ieee80211_he_mu_edca_param_ac_rec ac_vi; + struct ieee80211_he_mu_edca_param_ac_rec ac_vo; +}; + +struct ieee80211_timeout_interval_ie { + u8 type; + __le32 value; +} __attribute__((packed)); + +struct ieee80211_bss_max_idle_period_ie { + __le16 max_idle_period; + u8 idle_options; +} __attribute__((packed)); + +struct ieee80211_bssid_index { + u8 bssid_index; + u8 dtim_period; + u8 dtim_count; +}; + +struct ieee80211_multiple_bssid_configuration { + u8 bssid_count; + u8 profile_periodicity; +}; + +enum ieee80211_radiotap_mcs_have { + IEEE80211_RADIOTAP_MCS_HAVE_BW = 1, + IEEE80211_RADIOTAP_MCS_HAVE_MCS = 2, + IEEE80211_RADIOTAP_MCS_HAVE_GI = 4, + IEEE80211_RADIOTAP_MCS_HAVE_FMT = 8, + IEEE80211_RADIOTAP_MCS_HAVE_FEC = 16, + IEEE80211_RADIOTAP_MCS_HAVE_STBC = 32, +}; + +enum ieee80211_radiotap_vht_known { + IEEE80211_RADIOTAP_VHT_KNOWN_STBC = 1, + IEEE80211_RADIOTAP_VHT_KNOWN_TXOP_PS_NA = 2, + IEEE80211_RADIOTAP_VHT_KNOWN_GI = 4, + IEEE80211_RADIOTAP_VHT_KNOWN_SGI_NSYM_DIS = 8, + IEEE80211_RADIOTAP_VHT_KNOWN_LDPC_EXTRA_OFDM_SYM = 16, + IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED = 32, + IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH = 64, + IEEE80211_RADIOTAP_VHT_KNOWN_GROUP_ID = 128, + IEEE80211_RADIOTAP_VHT_KNOWN_PARTIAL_AID = 256, +}; + +enum ieee80211_max_queues { + IEEE80211_MAX_QUEUES = 16, + IEEE80211_MAX_QUEUE_MAP = 65535, +}; + +struct ieee80211_tx_queue_params { + u16 txop; + u16 cw_min; + u16 cw_max; + u8 aifs; + bool acm; + bool uapsd; + bool mu_edca; + struct ieee80211_he_mu_edca_param_ac_rec mu_edca_param_rec; +}; + +struct ieee80211_low_level_stats { + unsigned int dot11ACKFailureCount; + unsigned int dot11RTSFailureCount; + unsigned int dot11FCSErrorCount; + unsigned int dot11RTSSuccessCount; +}; + +struct ieee80211_chanctx_conf { + struct cfg80211_chan_def def; + struct cfg80211_chan_def min_def; + u8 rx_chains_static; + u8 rx_chains_dynamic; + bool radar_enabled; + long: 40; + u8 drv_priv[0]; +}; + +enum ieee80211_chanctx_switch_mode { + CHANCTX_SWMODE_REASSIGN_VIF = 0, + CHANCTX_SWMODE_SWAP_CONTEXTS = 1, +}; + +struct ieee80211_vif; + +struct ieee80211_vif_chanctx_switch { + struct ieee80211_vif *vif; + struct ieee80211_chanctx_conf *old_ctx; + struct ieee80211_chanctx_conf *new_ctx; +}; + +struct ieee80211_mu_group_data { + u8 membership[8]; + u8 position[16]; +}; + +struct ieee80211_fils_discovery { + u32 min_interval; + u32 max_interval; +}; + +struct ieee80211_ftm_responder_params; + +struct ieee80211_bss_conf { + const u8 *bssid; + u8 htc_trig_based_pkt_ext; + bool multi_sta_back_32bit; + bool uora_exists; + bool ack_enabled; + u8 uora_ocw_range; + u16 frame_time_rts_th; + bool he_support; + bool twt_requester; + bool twt_responder; + bool twt_protected; + bool assoc; + bool ibss_joined; + bool ibss_creator; + u16 aid; + bool use_cts_prot; + bool use_short_preamble; + bool use_short_slot; + bool enable_beacon; + u8 dtim_period; + u16 beacon_int; + u16 assoc_capability; + u64 sync_tsf; + u32 sync_device_ts; + u8 sync_dtim_count; + u32 basic_rates; + struct ieee80211_rate *beacon_rate; + int mcast_rate[5]; + u16 ht_operation_mode; + s32 cqm_rssi_thold; + u32 cqm_rssi_hyst; + s32 cqm_rssi_low; + s32 cqm_rssi_high; + struct cfg80211_chan_def chandef; + struct ieee80211_mu_group_data mu_group; + __be32 arp_addr_list[4]; + int arp_addr_cnt; + bool qos; + bool idle; + bool ps; + u8 ssid[32]; + size_t ssid_len; + bool hidden_ssid; + int txpower; + enum nl80211_tx_power_setting txpower_type; + struct ieee80211_p2p_noa_attr p2p_noa_attr; + bool allow_p2p_go_ps; + u16 max_idle_period; + bool protected_keep_alive; + bool ftm_responder; + struct ieee80211_ftm_responder_params *ftmr_params; + bool nontransmitted; + u8 transmitter_bssid[6]; + u8 bssid_index; + u8 bssid_indicator; + bool ema_ap; + u8 profile_periodicity; + struct { + u32 params; + u16 nss_set; + } he_oper; + struct ieee80211_he_obss_pd he_obss_pd; + struct cfg80211_he_bss_color he_bss_color; + struct ieee80211_fils_discovery fils_discovery; + u32 unsol_bcast_probe_resp_interval; + bool s1g; + struct cfg80211_bitrate_mask beacon_tx_rate; +}; + +struct ieee80211_txq; + +struct ieee80211_vif { + enum nl80211_iftype type; + struct ieee80211_bss_conf bss_conf; + u8 addr[6]; + bool p2p; + bool csa_active; + bool mu_mimo_owner; + u8 cab_queue; + u8 hw_queue[4]; + struct ieee80211_txq *txq; + struct ieee80211_chanctx_conf *chanctx_conf; + u32 driver_flags; + u32 offload_flags; + bool probe_req_reg; + bool rx_mcast_action_reg; + bool txqs_stopped[4]; + short: 16; + u8 drv_priv[0]; +}; + +enum ieee80211_bss_change { + BSS_CHANGED_ASSOC = 1, + BSS_CHANGED_ERP_CTS_PROT = 2, + BSS_CHANGED_ERP_PREAMBLE = 4, + BSS_CHANGED_ERP_SLOT = 8, + BSS_CHANGED_HT = 16, + BSS_CHANGED_BASIC_RATES = 32, + BSS_CHANGED_BEACON_INT = 64, + BSS_CHANGED_BSSID = 128, + BSS_CHANGED_BEACON = 256, + BSS_CHANGED_BEACON_ENABLED = 512, + BSS_CHANGED_CQM = 1024, + BSS_CHANGED_IBSS = 2048, + BSS_CHANGED_ARP_FILTER = 4096, + BSS_CHANGED_QOS = 8192, + BSS_CHANGED_IDLE = 16384, + BSS_CHANGED_SSID = 32768, + BSS_CHANGED_AP_PROBE_RESP = 65536, + BSS_CHANGED_PS = 131072, + BSS_CHANGED_TXPOWER = 262144, + BSS_CHANGED_P2P_PS = 524288, + BSS_CHANGED_BEACON_INFO = 1048576, + BSS_CHANGED_BANDWIDTH = 2097152, + BSS_CHANGED_OCB = 4194304, + BSS_CHANGED_MU_GROUPS = 8388608, + BSS_CHANGED_KEEP_ALIVE = 16777216, + BSS_CHANGED_MCAST_RATE = 33554432, + BSS_CHANGED_FTM_RESPONDER = 67108864, + BSS_CHANGED_TWT = 134217728, + BSS_CHANGED_HE_OBSS_PD = 268435456, + BSS_CHANGED_HE_BSS_COLOR = 536870912, + BSS_CHANGED_FILS_DISCOVERY = 1073741824, + BSS_CHANGED_UNSOL_BCAST_PROBE_RESP = 2147483648, +}; + +enum ieee80211_event_type { + RSSI_EVENT = 0, + MLME_EVENT = 1, + BAR_RX_EVENT = 2, + BA_FRAME_TIMEOUT = 3, +}; + +enum ieee80211_rssi_event_data { + RSSI_EVENT_HIGH = 0, + RSSI_EVENT_LOW = 1, +}; + +struct ieee80211_rssi_event { + enum ieee80211_rssi_event_data data; +}; + +enum ieee80211_mlme_event_data { + AUTH_EVENT = 0, + ASSOC_EVENT = 1, + DEAUTH_RX_EVENT = 2, + DEAUTH_TX_EVENT = 3, +}; + +enum ieee80211_mlme_event_status { + MLME_SUCCESS = 0, + MLME_DENIED = 1, + MLME_TIMEOUT = 2, +}; + +struct ieee80211_mlme_event { + enum ieee80211_mlme_event_data data; + enum ieee80211_mlme_event_status status; + u16 reason; +}; + +struct ieee80211_sta; + +struct ieee80211_ba_event { + struct ieee80211_sta *sta; + u16 tid; + u16 ssn; +}; + +enum ieee80211_sta_rx_bandwidth { + IEEE80211_STA_RX_BW_20 = 0, + IEEE80211_STA_RX_BW_40 = 1, + IEEE80211_STA_RX_BW_80 = 2, + IEEE80211_STA_RX_BW_160 = 3, +}; + +enum ieee80211_smps_mode { + IEEE80211_SMPS_AUTOMATIC = 0, + IEEE80211_SMPS_OFF = 1, + IEEE80211_SMPS_STATIC = 2, + IEEE80211_SMPS_DYNAMIC = 3, + IEEE80211_SMPS_NUM_MODES = 4, +}; + +struct ieee80211_sta_txpwr { + s16 power; + enum nl80211_tx_power_setting type; +}; + +struct ieee80211_sta_rates; + +struct ieee80211_sta { + u32 supp_rates[5]; + u8 addr[6]; + u16 aid; + struct ieee80211_sta_ht_cap ht_cap; + short: 16; + struct ieee80211_sta_vht_cap vht_cap; + struct ieee80211_sta_he_cap he_cap; + struct ieee80211_he_6ghz_capa he_6ghz_capa; + char: 8; + u16 max_rx_aggregation_subframes; + bool wme; + u8 uapsd_queues; + u8 max_sp; + u8 rx_nss; + enum ieee80211_sta_rx_bandwidth bandwidth; + enum ieee80211_smps_mode smps_mode; + int: 32; + struct ieee80211_sta_rates *rates; + bool tdls; + bool tdls_initiator; + bool mfp; + u8 max_amsdu_subframes; + u16 max_amsdu_len; + bool support_p2p_ps; + char: 8; + u16 max_rc_amsdu_len; + u16 max_tid_amsdu_len[16]; + short: 16; + struct ieee80211_sta_txpwr txpwr; + int: 32; + struct ieee80211_txq *txq[17]; + u8 drv_priv[0]; +} __attribute__((packed)); + +struct ieee80211_event { + enum ieee80211_event_type type; + union { + struct ieee80211_rssi_event rssi; + struct ieee80211_mlme_event mlme; + struct ieee80211_ba_event ba; + } u; +}; + +struct ieee80211_ftm_responder_params { + const u8 *lci; + const u8 *civicloc; + size_t lci_len; + size_t civicloc_len; +}; + +struct ieee80211_tx_rate { + s8 idx; + u16 count: 5; + u16 flags: 11; +} __attribute__((packed)); + +struct ieee80211_key_conf { + atomic64_t tx_pn; + u32 cipher; + u8 icv_len; + u8 iv_len; + u8 hw_key_idx; + s8 keyidx; + u16 flags; + u8 keylen; + u8 key[0]; +}; + +struct ieee80211_tx_info { + u32 flags; + u32 band: 3; + u32 ack_frame_id: 13; + u32 hw_queue: 4; + u32 tx_time_est: 10; + union { + struct { + union { + struct { + struct ieee80211_tx_rate rates[4]; + s8 rts_cts_rate_idx; + u8 use_rts: 1; + u8 use_cts_prot: 1; + u8 short_preamble: 1; + u8 skip_table: 1; + }; + long unsigned int jiffies; + }; + struct ieee80211_vif *vif; + struct ieee80211_key_conf *hw_key; + u32 flags; + codel_time_t enqueue_time; + } control; + struct { + u64 cookie; + } ack; + struct { + struct ieee80211_tx_rate rates[4]; + s32 ack_signal; + u8 ampdu_ack_len; + u8 ampdu_len; + u8 antenna; + u16 tx_time; + bool is_valid_ack_signal; + void *status_driver_data[2]; + } status; + struct { + struct ieee80211_tx_rate driver_rates[4]; + u8 pad[4]; + void *rate_driver_data[3]; + }; + void *driver_data[5]; + }; +}; + +struct ieee80211_tx_status { + struct ieee80211_sta *sta; + struct ieee80211_tx_info *info; + struct sk_buff *skb; + struct rate_info *rate; + struct list_head *free_list; +}; + +struct ieee80211_scan_ies { + const u8 *ies[5]; + size_t len[5]; + const u8 *common_ies; + size_t common_ie_len; +}; + +struct ieee80211_rx_status { + u64 mactime; + u64 boottime_ns; + u32 device_timestamp; + u32 ampdu_reference; + u32 flag; + u16 freq: 13; + u16 freq_offset: 1; + u8 enc_flags; + u8 encoding: 2; + u8 bw: 3; + u8 he_ru: 3; + u8 he_gi: 2; + u8 he_dcm: 1; + u8 rate_idx; + u8 nss; + u8 rx_flags; + u8 band; + u8 antenna; + s8 signal; + u8 chains; + s8 chain_signal[4]; + u8 ampdu_delimiter_crc; + u8 zero_length_psdu_type; +}; + +enum ieee80211_conf_flags { + IEEE80211_CONF_MONITOR = 1, + IEEE80211_CONF_PS = 2, + IEEE80211_CONF_IDLE = 4, + IEEE80211_CONF_OFFCHANNEL = 8, +}; + +enum ieee80211_conf_changed { + IEEE80211_CONF_CHANGE_SMPS = 2, + IEEE80211_CONF_CHANGE_LISTEN_INTERVAL = 4, + IEEE80211_CONF_CHANGE_MONITOR = 8, + IEEE80211_CONF_CHANGE_PS = 16, + IEEE80211_CONF_CHANGE_POWER = 32, + IEEE80211_CONF_CHANGE_CHANNEL = 64, + IEEE80211_CONF_CHANGE_RETRY_LIMITS = 128, + IEEE80211_CONF_CHANGE_IDLE = 256, +}; + +struct ieee80211_conf { + u32 flags; + int power_level; + int dynamic_ps_timeout; + u16 listen_interval; + u8 ps_dtim_period; + u8 long_frame_max_tx_count; + u8 short_frame_max_tx_count; + struct cfg80211_chan_def chandef; + bool radar_enabled; + enum ieee80211_smps_mode smps_mode; +}; + +struct ieee80211_channel_switch { + u64 timestamp; + u32 device_timestamp; + bool block_tx; + struct cfg80211_chan_def chandef; + u8 count; + u32 delay; +}; + +struct ieee80211_txq { + struct ieee80211_vif *vif; + struct ieee80211_sta *sta; + u8 tid; + u8 ac; + long: 48; + u8 drv_priv[0]; +}; + +struct ieee80211_key_seq { + union { + struct { + u32 iv32; + u16 iv16; + } tkip; + struct { + u8 pn[6]; + } ccmp; + struct { + u8 pn[6]; + } aes_cmac; + struct { + u8 pn[6]; + } aes_gmac; + struct { + u8 pn[6]; + } gcmp; + struct { + u8 seq[16]; + u8 seq_len; + } hw; + }; +}; + +struct ieee80211_cipher_scheme { + u32 cipher; + u16 iftype; + u8 hdr_len; + u8 pn_len; + u8 pn_off; + u8 key_idx_off; + u8 key_idx_mask; + u8 key_idx_shift; + u8 mic_len; +}; + +enum set_key_cmd { + SET_KEY = 0, + DISABLE_KEY = 1, +}; + +enum ieee80211_sta_state { + IEEE80211_STA_NOTEXIST = 0, + IEEE80211_STA_NONE = 1, + IEEE80211_STA_AUTH = 2, + IEEE80211_STA_ASSOC = 3, + IEEE80211_STA_AUTHORIZED = 4, +}; + +struct ieee80211_sta_rates { + struct callback_head callback_head; + struct { + s8 idx; + u8 count; + u8 count_cts; + u8 count_rts; + u16 flags; + } rate[4]; +}; + +enum sta_notify_cmd { + STA_NOTIFY_SLEEP = 0, + STA_NOTIFY_AWAKE = 1, +}; + +struct ieee80211_tx_control { + struct ieee80211_sta *sta; +}; + +enum ieee80211_hw_flags { + IEEE80211_HW_HAS_RATE_CONTROL = 0, + IEEE80211_HW_RX_INCLUDES_FCS = 1, + IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING = 2, + IEEE80211_HW_SIGNAL_UNSPEC = 3, + IEEE80211_HW_SIGNAL_DBM = 4, + IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC = 5, + IEEE80211_HW_SPECTRUM_MGMT = 6, + IEEE80211_HW_AMPDU_AGGREGATION = 7, + IEEE80211_HW_SUPPORTS_PS = 8, + IEEE80211_HW_PS_NULLFUNC_STACK = 9, + IEEE80211_HW_SUPPORTS_DYNAMIC_PS = 10, + IEEE80211_HW_MFP_CAPABLE = 11, + IEEE80211_HW_WANT_MONITOR_VIF = 12, + IEEE80211_HW_NO_AUTO_VIF = 13, + IEEE80211_HW_SW_CRYPTO_CONTROL = 14, + IEEE80211_HW_SUPPORT_FAST_XMIT = 15, + IEEE80211_HW_REPORTS_TX_ACK_STATUS = 16, + IEEE80211_HW_CONNECTION_MONITOR = 17, + IEEE80211_HW_QUEUE_CONTROL = 18, + IEEE80211_HW_SUPPORTS_PER_STA_GTK = 19, + IEEE80211_HW_AP_LINK_PS = 20, + IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 21, + IEEE80211_HW_SUPPORTS_RC_TABLE = 22, + IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 23, + IEEE80211_HW_TIMING_BEACON_ONLY = 24, + IEEE80211_HW_SUPPORTS_HT_CCK_RATES = 25, + IEEE80211_HW_CHANCTX_STA_CSA = 26, + IEEE80211_HW_SUPPORTS_CLONED_SKBS = 27, + IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS = 28, + IEEE80211_HW_TDLS_WIDER_BW = 29, + IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU = 30, + IEEE80211_HW_BEACON_TX_STATUS = 31, + IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR = 32, + IEEE80211_HW_SUPPORTS_REORDERING_BUFFER = 33, + IEEE80211_HW_USES_RSS = 34, + IEEE80211_HW_TX_AMSDU = 35, + IEEE80211_HW_TX_FRAG_LIST = 36, + IEEE80211_HW_REPORTS_LOW_ACK = 37, + IEEE80211_HW_SUPPORTS_TX_FRAG = 38, + IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA = 39, + IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP = 40, + IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP = 41, + IEEE80211_HW_BUFF_MMPDU_TXQ = 42, + IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW = 43, + IEEE80211_HW_STA_MMPDU_TXQ = 44, + IEEE80211_HW_TX_STATUS_NO_AMPDU_LEN = 45, + IEEE80211_HW_SUPPORTS_MULTI_BSSID = 46, + IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID = 47, + IEEE80211_HW_AMPDU_KEYBORDER_SUPPORT = 48, + IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD = 49, + NUM_IEEE80211_HW_FLAGS = 50, +}; + +struct ieee80211_hw { + struct ieee80211_conf conf; + struct wiphy *wiphy; + const char *rate_control_algorithm; + void *priv; + long unsigned int flags[1]; + unsigned int extra_tx_headroom; + unsigned int extra_beacon_tailroom; + int vif_data_size; + int sta_data_size; + int chanctx_data_size; + int txq_data_size; + u16 queues; + u16 max_listen_interval; + s8 max_signal; + u8 max_rates; + u8 max_report_rates; + u8 max_rate_tries; + u16 max_rx_aggregation_subframes; + u16 max_tx_aggregation_subframes; + u8 max_tx_fragments; + u8 offchannel_tx_hw_queue; + u8 radiotap_mcs_details; + u16 radiotap_vht_details; + struct { + int units_pos; + s16 accuracy; + } radiotap_timestamp; + netdev_features_t netdev_features; + u8 uapsd_queues; + u8 uapsd_max_sp_len; + u8 n_cipher_schemes; + const struct ieee80211_cipher_scheme *cipher_schemes; + u8 max_nan_de_entries; + u8 tx_sk_pacing_shift; + u8 weight_multiplier; + u32 max_mtu; +}; + +struct ieee80211_scan_request { + struct ieee80211_scan_ies ies; + struct cfg80211_scan_request req; +}; + +struct ieee80211_tdls_ch_sw_params { + struct ieee80211_sta *sta; + struct cfg80211_chan_def *chandef; + u8 action_code; + u32 status; + u32 timestamp; + u16 switch_time; + u16 switch_timeout; + struct sk_buff *tmpl_skb; + u32 ch_sw_tm_ie; +}; + +enum ieee80211_filter_flags { + FIF_ALLMULTI = 2, + FIF_FCSFAIL = 4, + FIF_PLCPFAIL = 8, + FIF_BCN_PRBRESP_PROMISC = 16, + FIF_CONTROL = 32, + FIF_OTHER_BSS = 64, + FIF_PSPOLL = 128, + FIF_PROBE_REQ = 256, + FIF_MCAST_ACTION = 512, +}; + +enum ieee80211_ampdu_mlme_action { + IEEE80211_AMPDU_RX_START = 0, + IEEE80211_AMPDU_RX_STOP = 1, + IEEE80211_AMPDU_TX_START = 2, + IEEE80211_AMPDU_TX_STOP_CONT = 3, + IEEE80211_AMPDU_TX_STOP_FLUSH = 4, + IEEE80211_AMPDU_TX_STOP_FLUSH_CONT = 5, + IEEE80211_AMPDU_TX_OPERATIONAL = 6, +}; + +struct ieee80211_ampdu_params { + enum ieee80211_ampdu_mlme_action action; + struct ieee80211_sta *sta; + u16 tid; + u16 ssn; + u16 buf_size; + bool amsdu; + u16 timeout; +}; + +enum ieee80211_frame_release_type { + IEEE80211_FRAME_RELEASE_PSPOLL = 0, + IEEE80211_FRAME_RELEASE_UAPSD = 1, +}; + +enum ieee80211_roc_type { + IEEE80211_ROC_TYPE_NORMAL = 0, + IEEE80211_ROC_TYPE_MGMT_TX = 1, +}; + +enum ieee80211_reconfig_type { + IEEE80211_RECONFIG_TYPE_RESTART = 0, + IEEE80211_RECONFIG_TYPE_SUSPEND = 1, +}; + +struct ieee80211_ops { + void (*tx)(struct ieee80211_hw *, struct ieee80211_tx_control *, struct sk_buff *); + int (*start)(struct ieee80211_hw *); + void (*stop)(struct ieee80211_hw *); + int (*suspend)(struct ieee80211_hw *, struct cfg80211_wowlan *); + int (*resume)(struct ieee80211_hw *); + void (*set_wakeup)(struct ieee80211_hw *, bool); + int (*add_interface)(struct ieee80211_hw *, struct ieee80211_vif *); + int (*change_interface)(struct ieee80211_hw *, struct ieee80211_vif *, enum nl80211_iftype, bool); + void (*remove_interface)(struct ieee80211_hw *, struct ieee80211_vif *); + int (*config)(struct ieee80211_hw *, u32); + void (*bss_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u32); + int (*start_ap)(struct ieee80211_hw *, struct ieee80211_vif *); + void (*stop_ap)(struct ieee80211_hw *, struct ieee80211_vif *); + u64 (*prepare_multicast)(struct ieee80211_hw *, struct netdev_hw_addr_list *); + void (*configure_filter)(struct ieee80211_hw *, unsigned int, unsigned int *, u64); + void (*config_iface_filter)(struct ieee80211_hw *, struct ieee80211_vif *, unsigned int, unsigned int); + int (*set_tim)(struct ieee80211_hw *, struct ieee80211_sta *, bool); + int (*set_key)(struct ieee80211_hw *, enum set_key_cmd, struct ieee80211_vif *, struct ieee80211_sta *, struct ieee80211_key_conf *); + void (*update_tkip_key)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_key_conf *, struct ieee80211_sta *, u32, u16 *); + void (*set_rekey_data)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_gtk_rekey_data *); + void (*set_default_unicast_key)(struct ieee80211_hw *, struct ieee80211_vif *, int); + int (*hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_scan_request *); + void (*cancel_hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *); + int (*sched_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_sched_scan_request *, struct ieee80211_scan_ies *); + int (*sched_scan_stop)(struct ieee80211_hw *, struct ieee80211_vif *); + void (*sw_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, const u8 *); + void (*sw_scan_complete)(struct ieee80211_hw *, struct ieee80211_vif *); + int (*get_stats)(struct ieee80211_hw *, struct ieee80211_low_level_stats *); + void (*get_key_seq)(struct ieee80211_hw *, struct ieee80211_key_conf *, struct ieee80211_key_seq *); + int (*set_frag_threshold)(struct ieee80211_hw *, u32); + int (*set_rts_threshold)(struct ieee80211_hw *, u32); + int (*sta_add)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); + int (*sta_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); + void (*sta_notify)(struct ieee80211_hw *, struct ieee80211_vif *, enum sta_notify_cmd, struct ieee80211_sta *); + int (*sta_set_txpwr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); + int (*sta_state)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, enum ieee80211_sta_state, enum ieee80211_sta_state); + void (*sta_pre_rcu_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); + void (*sta_rc_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u32); + void (*sta_rate_tbl_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); + void (*sta_statistics)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct station_info *); + int (*conf_tx)(struct ieee80211_hw *, struct ieee80211_vif *, u16, const struct ieee80211_tx_queue_params *); + u64 (*get_tsf)(struct ieee80211_hw *, struct ieee80211_vif *); + void (*set_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, u64); + void (*offset_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, s64); + void (*reset_tsf)(struct ieee80211_hw *, struct ieee80211_vif *); + int (*tx_last_beacon)(struct ieee80211_hw *); + int (*ampdu_action)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_ampdu_params *); + int (*get_survey)(struct ieee80211_hw *, int, struct survey_info *); + void (*rfkill_poll)(struct ieee80211_hw *); + void (*set_coverage_class)(struct ieee80211_hw *, s16); + void (*flush)(struct ieee80211_hw *, struct ieee80211_vif *, u32, bool); + void (*channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *); + int (*set_antenna)(struct ieee80211_hw *, u32, u32); + int (*get_antenna)(struct ieee80211_hw *, u32 *, u32 *); + int (*remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel *, int, enum ieee80211_roc_type); + int (*cancel_remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *); + int (*set_ringparam)(struct ieee80211_hw *, u32, u32); + void (*get_ringparam)(struct ieee80211_hw *, u32 *, u32 *, u32 *, u32 *); + bool (*tx_frames_pending)(struct ieee80211_hw *); + int (*set_bitrate_mask)(struct ieee80211_hw *, struct ieee80211_vif *, const struct cfg80211_bitrate_mask *); + void (*event_callback)(struct ieee80211_hw *, struct ieee80211_vif *, const struct ieee80211_event *); + void (*allow_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool); + void (*release_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool); + int (*get_et_sset_count)(struct ieee80211_hw *, struct ieee80211_vif *, int); + void (*get_et_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct ethtool_stats *, u64 *); + void (*get_et_strings)(struct ieee80211_hw *, struct ieee80211_vif *, u32, u8 *); + void (*mgd_prepare_tx)(struct ieee80211_hw *, struct ieee80211_vif *, u16); + void (*mgd_protect_tdls_discover)(struct ieee80211_hw *, struct ieee80211_vif *); + int (*add_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *); + void (*remove_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *); + void (*change_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, u32); + int (*assign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_chanctx_conf *); + void (*unassign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_chanctx_conf *); + int (*switch_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif_chanctx_switch *, int, enum ieee80211_chanctx_switch_mode); + void (*reconfig_complete)(struct ieee80211_hw *, enum ieee80211_reconfig_type); + void (*ipv6_addr_change)(struct ieee80211_hw *, struct ieee80211_vif *, struct inet6_dev *); + void (*channel_switch_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_chan_def *); + int (*pre_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *); + int (*post_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *); + void (*abort_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *); + void (*channel_switch_rx_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *); + int (*join_ibss)(struct ieee80211_hw *, struct ieee80211_vif *); + void (*leave_ibss)(struct ieee80211_hw *, struct ieee80211_vif *); + u32 (*get_expected_throughput)(struct ieee80211_hw *, struct ieee80211_sta *); + int (*get_txpower)(struct ieee80211_hw *, struct ieee80211_vif *, int *); + int (*tdls_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8, struct cfg80211_chan_def *, struct sk_buff *, u32); + void (*tdls_cancel_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); + void (*tdls_recv_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_tdls_ch_sw_params *); + void (*wake_tx_queue)(struct ieee80211_hw *, struct ieee80211_txq *); + void (*sync_rx_queues)(struct ieee80211_hw *); + int (*start_nan)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_nan_conf *); + int (*stop_nan)(struct ieee80211_hw *, struct ieee80211_vif *); + int (*nan_change_conf)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_nan_conf *, u32); + int (*add_nan_func)(struct ieee80211_hw *, struct ieee80211_vif *, const struct cfg80211_nan_func *); + void (*del_nan_func)(struct ieee80211_hw *, struct ieee80211_vif *, u8); + bool (*can_aggregate_in_amsdu)(struct ieee80211_hw *, struct sk_buff *, struct sk_buff *); + int (*get_ftm_responder_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_ftm_responder_stats *); + int (*start_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *); + void (*abort_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *); + int (*set_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct cfg80211_tid_config *); + int (*reset_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8); + void (*update_vif_offload)(struct ieee80211_hw *, struct ieee80211_vif *); + void (*sta_set_4addr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, bool); +}; + +struct ieee80211_tx_rate_control { + struct ieee80211_hw *hw; + struct ieee80211_supported_band *sband; + struct ieee80211_bss_conf *bss_conf; + struct sk_buff *skb; + struct ieee80211_tx_rate reported_rate; + bool rts; + bool short_preamble; + u32 rate_idx_mask; + u8 *rate_idx_mcs_mask; + bool bss; +}; + +enum rate_control_capabilities { + RATE_CTRL_CAPA_VHT_EXT_NSS_BW = 1, +}; + +struct rate_control_ops { + long unsigned int capa; + const char *name; + void * (*alloc)(struct ieee80211_hw *); + void (*add_debugfs)(struct ieee80211_hw *, void *, struct dentry *); + void (*free)(void *); + void * (*alloc_sta)(void *, struct ieee80211_sta *, gfp_t); + void (*rate_init)(void *, struct ieee80211_supported_band *, struct cfg80211_chan_def *, struct ieee80211_sta *, void *); + void (*rate_update)(void *, struct ieee80211_supported_band *, struct cfg80211_chan_def *, struct ieee80211_sta *, void *, u32); + void (*free_sta)(void *, struct ieee80211_sta *, void *); + void (*tx_status_ext)(void *, struct ieee80211_supported_band *, void *, struct ieee80211_tx_status *); + void (*tx_status)(void *, struct ieee80211_supported_band *, struct ieee80211_sta *, void *, struct sk_buff *); + void (*get_rate)(void *, struct ieee80211_sta *, void *, struct ieee80211_tx_rate_control *); + void (*add_sta_debugfs)(void *, void *, struct dentry *); + u32 (*get_expected_throughput)(void *); +}; + +struct fq_tin; + +struct fq_flow___2 { + struct fq_tin *tin; + struct list_head flowchain; + struct list_head backlogchain; + struct sk_buff_head queue; + u32 backlog; + int deficit; +}; + +struct fq_tin { + struct list_head new_flows; + struct list_head old_flows; + u32 backlog_bytes; + u32 backlog_packets; + u32 overlimit; + u32 collisions; + u32 flows; + u32 tx_bytes; + u32 tx_packets; +}; + +struct fq { + struct fq_flow___2 *flows; + struct list_head backlogs; + spinlock_t lock; + u32 flows_cnt; + u32 limit; + u32 memory_limit; + u32 memory_usage; + u32 quantum; + u32 backlog; + u32 overlimit; + u32 overmemory; + u32 collisions; +}; + +enum ieee80211_internal_tkip_state { + TKIP_STATE_NOT_INIT = 0, + TKIP_STATE_PHASE1_DONE = 1, + TKIP_STATE_PHASE1_HW_UPLOADED = 2, +}; + +struct tkip_ctx { + u16 p1k[5]; + u32 p1k_iv32; + enum ieee80211_internal_tkip_state state; +}; + +struct tkip_ctx_rx { + struct tkip_ctx ctx; + u32 iv32; + u16 iv16; +}; + +struct ieee80211_local; + +struct ieee80211_sub_if_data; + +struct sta_info; + +struct ieee80211_key { + struct ieee80211_local *local; + struct ieee80211_sub_if_data *sdata; + struct sta_info *sta; + struct list_head list; + unsigned int flags; + union { + struct { + spinlock_t txlock; + struct tkip_ctx tx; + struct tkip_ctx_rx rx[16]; + u32 mic_failures; + } tkip; + struct { + u8 rx_pn[102]; + struct crypto_aead *tfm; + u32 replays; + } ccmp; + struct { + u8 rx_pn[6]; + struct crypto_shash *tfm; + u32 replays; + u32 icverrors; + } aes_cmac; + struct { + u8 rx_pn[6]; + struct crypto_aead *tfm; + u32 replays; + u32 icverrors; + } aes_gmac; + struct { + u8 rx_pn[102]; + struct crypto_aead *tfm; + u32 replays; + } gcmp; + struct { + u8 rx_pn[272]; + } gen; + } u; + struct ieee80211_key_conf conf; +}; + +enum mac80211_scan_state { + SCAN_DECISION = 0, + SCAN_SET_CHANNEL = 1, + SCAN_SEND_PROBE = 2, + SCAN_SUSPEND = 3, + SCAN_RESUME = 4, + SCAN_ABORT = 5, +}; + +struct rate_control_ref; + +struct ieee80211_local { + struct ieee80211_hw hw; + struct fq fq; + struct codel_vars *cvars; + struct codel_params cparams; + spinlock_t active_txq_lock[4]; + struct list_head active_txqs[4]; + u16 schedule_round[4]; + u16 airtime_flags; + u32 aql_txq_limit_low[4]; + u32 aql_txq_limit_high[4]; + u32 aql_threshold; + atomic_t aql_total_pending_airtime; + const struct ieee80211_ops *ops; + struct workqueue_struct *workqueue; + long unsigned int queue_stop_reasons[16]; + int q_stop_reasons[160]; + spinlock_t queue_stop_reason_lock; + int open_count; + int monitors; + int cooked_mntrs; + int fif_fcsfail; + int fif_plcpfail; + int fif_control; + int fif_other_bss; + int fif_pspoll; + int fif_probe_req; + bool probe_req_reg; + bool rx_mcast_action_reg; + unsigned int filter_flags; + bool wiphy_ciphers_allocated; + bool use_chanctx; + spinlock_t filter_lock; + struct work_struct reconfig_filter; + struct netdev_hw_addr_list mc_list; + bool tim_in_locked_section; + bool suspended; + bool resuming; + bool quiescing; + bool started; + bool in_reconfig; + bool wowlan; + struct work_struct radar_detected_work; + u8 rx_chains; + u8 sband_allocated; + int tx_headroom; + struct tasklet_struct tasklet; + struct sk_buff_head skb_queue; + struct sk_buff_head skb_queue_unreliable; + spinlock_t rx_path_lock; + struct mutex sta_mtx; + spinlock_t tim_lock; + long unsigned int num_sta; + struct list_head sta_list; + struct rhltable sta_hash; + struct timer_list sta_cleanup; + int sta_generation; + struct sk_buff_head pending[16]; + struct tasklet_struct tx_pending_tasklet; + struct tasklet_struct wake_txqs_tasklet; + atomic_t agg_queue_stop[16]; + atomic_t iff_allmultis; + struct rate_control_ref *rate_ctrl; + struct arc4_ctx wep_tx_ctx; + struct arc4_ctx wep_rx_ctx; + u32 wep_iv; + struct list_head interfaces; + struct list_head mon_list; + struct mutex iflist_mtx; + struct mutex key_mtx; + struct mutex mtx; + long unsigned int scanning; + struct cfg80211_ssid scan_ssid; + struct cfg80211_scan_request *int_scan_req; + struct cfg80211_scan_request *scan_req; + struct ieee80211_scan_request *hw_scan_req; + struct cfg80211_chan_def scan_chandef; + enum nl80211_band hw_scan_band; + int scan_channel_idx; + int scan_ies_len; + int hw_scan_ies_bufsize; + struct cfg80211_scan_info scan_info; + struct work_struct sched_scan_stopped_work; + struct ieee80211_sub_if_data *sched_scan_sdata; + struct cfg80211_sched_scan_request *sched_scan_req; + u8 scan_addr[6]; + long unsigned int leave_oper_channel_time; + enum mac80211_scan_state next_scan_state; + struct delayed_work scan_work; + struct ieee80211_sub_if_data *scan_sdata; + struct cfg80211_chan_def _oper_chandef; + struct ieee80211_channel *tmp_channel; + struct list_head chanctx_list; + struct mutex chanctx_mtx; + int total_ps_buffered; + bool pspolling; + struct ieee80211_sub_if_data *ps_sdata; + struct work_struct dynamic_ps_enable_work; + struct work_struct dynamic_ps_disable_work; + struct timer_list dynamic_ps_timer; + struct notifier_block ifa_notifier; + struct notifier_block ifa6_notifier; + int dynamic_ps_forced_timeout; + int user_power_level; + enum ieee80211_smps_mode smps_mode; + struct work_struct restart_work; + struct delayed_work roc_work; + struct list_head roc_list; + struct work_struct hw_roc_start; + struct work_struct hw_roc_done; + long unsigned int hw_roc_start_time; + u64 roc_cookie_counter; + struct idr ack_status_frames; + spinlock_t ack_status_lock; + struct ieee80211_sub_if_data *p2p_sdata; + struct ieee80211_sub_if_data *monitor_sdata; + struct cfg80211_chan_def monitor_chandef; + u8 ext_capa[8]; + struct work_struct tdls_chsw_work; + struct sk_buff_head skb_queue_tdls_chsw; +}; + +struct ieee80211_fragment_entry { + struct sk_buff_head skb_list; + long unsigned int first_frag_time; + u16 seq; + u16 extra_len; + u16 last_frag; + u8 rx_queue; + bool check_sequential_pn; + u8 last_pn[6]; +}; + +struct ps_data { + u8 tim[256]; + struct sk_buff_head bc_buf; + atomic_t num_sta_ps; + int dtim_count; + bool dtim_bc_mc; +}; + +struct beacon_data; + +struct probe_resp; + +struct fils_discovery_data; + +struct unsol_bcast_probe_resp_data; + +struct ieee80211_if_ap { + struct beacon_data *beacon; + struct probe_resp *probe_resp; + struct fils_discovery_data *fils_discovery; + struct unsol_bcast_probe_resp_data *unsol_bcast_probe_resp; + struct cfg80211_beacon_data *next_beacon; + struct list_head vlans; + struct ps_data ps; + atomic_t num_mcast_sta; + bool multicast_to_unicast; +}; + +struct ieee80211_if_vlan { + struct list_head list; + struct sta_info *sta; + atomic_t num_mcast_sta; +}; + +struct ewma_beacon_signal { + long unsigned int internal; +}; + +struct ieee80211_sta_tx_tspec { + long unsigned int time_slice_start; + u32 admitted_time; + u8 tsid; + s8 up; + u32 consumed_tx_time; + enum { + TX_TSPEC_ACTION_NONE = 0, + TX_TSPEC_ACTION_DOWNGRADE = 1, + TX_TSPEC_ACTION_STOP_DOWNGRADE = 2, + } action; + bool downgraded; +}; + +struct ieee80211_mgd_auth_data; + +struct ieee80211_mgd_assoc_data; + +struct ieee80211_if_managed { + struct timer_list timer; + struct timer_list conn_mon_timer; + struct timer_list bcn_mon_timer; + struct timer_list chswitch_timer; + struct work_struct monitor_work; + struct work_struct chswitch_work; + struct work_struct beacon_connection_loss_work; + struct work_struct csa_connection_drop_work; + long unsigned int beacon_timeout; + long unsigned int probe_timeout; + int probe_send_count; + bool nullfunc_failed; + bool connection_loss; + short: 16; + struct cfg80211_bss *associated; + struct ieee80211_mgd_auth_data *auth_data; + struct ieee80211_mgd_assoc_data *assoc_data; + u8 bssid[6]; + bool powersave; + bool broken_ap; + bool have_beacon; + u8 dtim_period; + short: 16; + enum ieee80211_smps_mode req_smps; + enum ieee80211_smps_mode driver_smps_mode; + int: 32; + struct work_struct request_smps_work; + unsigned int flags; + bool csa_waiting_bcn; + bool csa_ignored_same_chan; + bool beacon_crc_valid; + char: 8; + u32 beacon_crc; + bool status_acked; + bool status_received; + __le16 status_fc; + enum { + IEEE80211_MFP_DISABLED = 0, + IEEE80211_MFP_OPTIONAL = 1, + IEEE80211_MFP_REQUIRED = 2, + } mfp; + unsigned int uapsd_queues; + unsigned int uapsd_max_sp_len; + int wmm_last_param_set; + int mu_edca_last_param_set; + u8 use_4addr; + char: 8; + s16 p2p_noa_index; + struct ewma_beacon_signal ave_beacon_signal; + unsigned int count_beacon_signal; + unsigned int beacon_loss_count; + int last_cqm_event_signal; + int rssi_min_thold; + int rssi_max_thold; + int last_ave_beacon_signal; + struct ieee80211_ht_cap ht_capa; + struct ieee80211_ht_cap ht_capa_mask; + struct ieee80211_vht_cap vht_capa; + struct ieee80211_vht_cap vht_capa_mask; + struct ieee80211_s1g_cap s1g_capa; + struct ieee80211_s1g_cap s1g_capa_mask; + u8 tdls_peer[6]; + struct delayed_work tdls_peer_del_work; + struct sk_buff *orig_teardown_skb; + struct sk_buff *teardown_skb; + spinlock_t teardown_lock; + bool tdls_chan_switch_prohibited; + bool tdls_wider_bw_prohibited; + long: 48; + struct ieee80211_sta_tx_tspec tx_tspec[4]; + struct delayed_work tx_tspec_wk; + u8 *assoc_req_ies; + size_t assoc_req_ies_len; +} __attribute__((packed)); + +struct ieee80211_if_ibss { + struct timer_list timer; + struct work_struct csa_connection_drop_work; + long unsigned int last_scan_completed; + u32 basic_rates; + bool fixed_bssid; + bool fixed_channel; + bool privacy; + bool control_port; + bool userspace_handles_dfs; + char: 8; + u8 bssid[6]; + u8 ssid[32]; + u8 ssid_len; + u8 ie_len; + long: 48; + u8 *ie; + struct cfg80211_chan_def chandef; + long unsigned int ibss_join_req; + struct beacon_data *presp; + struct ieee80211_ht_cap ht_capa; + struct ieee80211_ht_cap ht_capa_mask; + int: 32; + spinlock_t incomplete_lock; + struct list_head incomplete_stations; + enum { + IEEE80211_IBSS_MLME_SEARCH = 0, + IEEE80211_IBSS_MLME_JOINED = 1, + } state; + int: 32; +} __attribute__((packed)); + +struct mesh_preq_queue { + struct list_head list; + u8 dst[6]; + u8 flags; +}; + +struct mesh_stats { + __u32 fwded_mcast; + __u32 fwded_unicast; + __u32 fwded_frames; + __u32 dropped_frames_ttl; + __u32 dropped_frames_no_route; + __u32 dropped_frames_congestion; +}; + +struct mesh_rmc; + +struct ieee80211_mesh_sync_ops; + +struct mesh_csa_settings; + +struct mesh_table; + +struct ieee80211_if_mesh { + struct timer_list housekeeping_timer; + struct timer_list mesh_path_timer; + struct timer_list mesh_path_root_timer; + long unsigned int wrkq_flags; + long unsigned int mbss_changed; + bool userspace_handles_dfs; + u8 mesh_id[32]; + size_t mesh_id_len; + u8 mesh_pp_id; + u8 mesh_pm_id; + u8 mesh_cc_id; + u8 mesh_sp_id; + u8 mesh_auth_id; + u32 sn; + u32 preq_id; + atomic_t mpaths; + long unsigned int last_sn_update; + long unsigned int next_perr; + long unsigned int last_preq; + struct mesh_rmc *rmc; + spinlock_t mesh_preq_queue_lock; + struct mesh_preq_queue preq_queue; + int preq_queue_len; + struct mesh_stats mshstats; + struct mesh_config mshcfg; + atomic_t estab_plinks; + u32 mesh_seqnum; + bool accepting_plinks; + int num_gates; + struct beacon_data *beacon; + const u8 *ie; + u8 ie_len; + enum { + IEEE80211_MESH_SEC_NONE = 0, + IEEE80211_MESH_SEC_AUTHED = 1, + IEEE80211_MESH_SEC_SECURED = 2, + } security; + bool user_mpm; + const struct ieee80211_mesh_sync_ops *sync_ops; + s64 sync_offset_clockdrift_max; + spinlock_t sync_offset_lock; + enum nl80211_mesh_power_mode nonpeer_pm; + int ps_peers_light_sleep; + int ps_peers_deep_sleep; + struct ps_data ps; + struct mesh_csa_settings *csa; + enum { + IEEE80211_MESH_CSA_ROLE_NONE = 0, + IEEE80211_MESH_CSA_ROLE_INIT = 1, + IEEE80211_MESH_CSA_ROLE_REPEATER = 2, + } csa_role; + u8 chsw_ttl; + u16 pre_value; + int meshconf_offset; + struct mesh_table *mesh_paths; + struct mesh_table *mpp_paths; + int mesh_paths_generation; + int mpp_paths_generation; +}; + +struct ieee80211_if_ocb { + struct timer_list housekeeping_timer; + long unsigned int wrkq_flags; + spinlock_t incomplete_lock; + struct list_head incomplete_stations; + bool joined; +}; + +struct ieee80211_if_mntr { + u32 flags; + u8 mu_follow_addr[6]; + struct list_head list; +}; + +struct ieee80211_if_nan { + struct cfg80211_nan_conf conf; + spinlock_t func_lock; + struct idr function_inst_ids; +}; + +struct mac80211_qos_map; + +struct ieee80211_chanctx; + +struct ieee80211_sub_if_data { + struct list_head list; + struct wireless_dev wdev; + struct list_head key_list; + int crypto_tx_tailroom_needed_cnt; + int crypto_tx_tailroom_pending_dec; + struct delayed_work dec_tailroom_needed_wk; + struct net_device *dev; + struct ieee80211_local *local; + unsigned int flags; + long unsigned int state; + char name[16]; + struct ieee80211_fragment_entry fragments[4]; + unsigned int fragment_next; + u16 noack_map; + u8 wmm_acm; + struct ieee80211_key *keys[8]; + struct ieee80211_key *default_unicast_key; + struct ieee80211_key *default_multicast_key; + struct ieee80211_key *default_mgmt_key; + struct ieee80211_key *default_beacon_key; + u16 sequence_number; + __be16 control_port_protocol; + bool control_port_no_encrypt; + bool control_port_no_preauth; + bool control_port_over_nl80211; + int encrypt_headroom; + atomic_t num_tx_queued; + struct ieee80211_tx_queue_params tx_conf[4]; + struct mac80211_qos_map *qos_map; + struct work_struct csa_finalize_work; + bool csa_block_tx; + struct cfg80211_chan_def csa_chandef; + struct list_head assigned_chanctx_list; + struct list_head reserved_chanctx_list; + struct ieee80211_chanctx *reserved_chanctx; + struct cfg80211_chan_def reserved_chandef; + bool reserved_radar_required; + bool reserved_ready; + struct work_struct recalc_smps; + struct work_struct work; + struct sk_buff_head skb_queue; + u8 needed_rx_chains; + enum ieee80211_smps_mode smps_mode; + int user_power_level; + int ap_power_level; + bool radar_required; + struct delayed_work dfs_cac_timer_work; + struct ieee80211_if_ap *bss; + u32 rc_rateidx_mask[5]; + bool rc_has_mcs_mask[5]; + u8 rc_rateidx_mcs_mask[50]; + bool rc_has_vht_mcs_mask[5]; + u16 rc_rateidx_vht_mcs_mask[40]; + u32 beacon_rateidx_mask[5]; + bool beacon_rate_set; + union { + struct ieee80211_if_ap ap; + struct ieee80211_if_vlan vlan; + struct ieee80211_if_managed mgd; + struct ieee80211_if_ibss ibss; + struct ieee80211_if_mesh mesh; + struct ieee80211_if_ocb ocb; + struct ieee80211_if_mntr mntr; + struct ieee80211_if_nan nan; + } u; + struct ieee80211_vif vif; +}; + +struct ieee80211_sta_rx_stats { + long unsigned int packets; + long unsigned int last_rx; + long unsigned int num_duplicates; + long unsigned int fragments; + long unsigned int dropped; + int last_signal; + u8 chains; + s8 chain_signal_last[4]; + u32 last_rate; + struct u64_stats_sync syncp; + u64 bytes; + u64 msdu[17]; +}; + +struct ewma_signal { + long unsigned int internal; +}; + +struct ewma_avg_signal { + long unsigned int internal; +}; + +struct airtime_info { + u64 rx_airtime; + u64 tx_airtime; + s64 deficit; + atomic_t aql_tx_pending; + u32 aql_limit_low; + u32 aql_limit_high; +}; + +struct tid_ampdu_rx; + +struct tid_ampdu_tx; + +struct sta_ampdu_mlme { + struct mutex mtx; + struct tid_ampdu_rx *tid_rx[16]; + u8 tid_rx_token[16]; + long unsigned int tid_rx_timer_expired[1]; + long unsigned int tid_rx_stop_requested[1]; + long unsigned int tid_rx_manage_offl[1]; + long unsigned int agg_session_valid[1]; + long unsigned int unexpected_agg[1]; + struct work_struct work; + struct tid_ampdu_tx *tid_tx[16]; + struct tid_ampdu_tx *tid_start_tx[16]; + long unsigned int last_addba_req_time[16]; + u8 addba_req_num[16]; + u8 dialog_token_allocator; +}; + +struct ieee80211_fast_tx; + +struct ieee80211_fast_rx; + +struct sta_info { + struct list_head list; + struct list_head free_list; + struct callback_head callback_head; + struct rhlist_head hash_node; + u8 addr[6]; + struct ieee80211_local *local; + struct ieee80211_sub_if_data *sdata; + struct ieee80211_key *gtk[8]; + struct ieee80211_key *ptk[4]; + u8 ptk_idx; + struct rate_control_ref *rate_ctrl; + void *rate_ctrl_priv; + spinlock_t rate_ctrl_lock; + spinlock_t lock; + struct ieee80211_fast_tx *fast_tx; + struct ieee80211_fast_rx *fast_rx; + struct ieee80211_sta_rx_stats *pcpu_rx_stats; + struct work_struct drv_deliver_wk; + u16 listen_interval; + bool dead; + bool removed; + bool uploaded; + enum ieee80211_sta_state sta_state; + long unsigned int _flags; + spinlock_t ps_lock; + struct sk_buff_head ps_tx_buf[4]; + struct sk_buff_head tx_filtered[4]; + long unsigned int driver_buffered_tids; + long unsigned int txq_buffered_tids; + u64 assoc_at; + long int last_connected; + struct ieee80211_sta_rx_stats rx_stats; + struct { + struct ewma_signal signal; + struct ewma_signal chain_signal[4]; + } rx_stats_avg; + __le16 last_seq_ctrl[17]; + struct { + long unsigned int filtered; + long unsigned int retry_failed; + long unsigned int retry_count; + unsigned int lost_packets; + long unsigned int last_pkt_time; + u64 msdu_retries[17]; + u64 msdu_failed[17]; + long unsigned int last_ack; + s8 last_ack_signal; + bool ack_signal_filled; + struct ewma_avg_signal avg_ack_signal; + } status_stats; + struct { + u64 packets[4]; + u64 bytes[4]; + struct ieee80211_tx_rate last_rate; + struct rate_info last_rate_info; + u64 msdu[17]; + } tx_stats; + u16 tid_seq[16]; + struct airtime_info airtime[4]; + u16 airtime_weight; + struct sta_ampdu_mlme ampdu_mlme; + enum ieee80211_sta_rx_bandwidth cur_max_bandwidth; + enum ieee80211_smps_mode known_smps_mode; + const struct ieee80211_cipher_scheme *cipher_scheme; + struct codel_params cparams; + u8 reserved_tid; + struct cfg80211_chan_def tdls_chandef; + struct ieee80211_sta sta; +}; + +struct tid_ampdu_tx { + struct callback_head callback_head; + struct timer_list session_timer; + struct timer_list addba_resp_timer; + struct sk_buff_head pending; + struct sta_info *sta; + long unsigned int state; + long unsigned int last_tx; + u16 timeout; + u8 dialog_token; + u8 stop_initiator; + bool tx_stop; + u16 buf_size; + u16 failed_bar_ssn; + bool bar_pending; + bool amsdu; + u8 tid; +}; + +struct tid_ampdu_rx { + struct callback_head callback_head; + spinlock_t reorder_lock; + u64 reorder_buf_filtered; + struct sk_buff_head *reorder_buf; + long unsigned int *reorder_time; + struct sta_info *sta; + struct timer_list session_timer; + struct timer_list reorder_timer; + long unsigned int last_rx; + u16 head_seq_num; + u16 stored_mpdu_num; + u16 ssn; + u16 buf_size; + u16 timeout; + u8 tid; + u8 auto_seq: 1; + u8 removed: 1; + u8 started: 1; +}; + +struct ieee80211_fast_tx { + struct ieee80211_key *key; + u8 hdr_len; + u8 sa_offs; + u8 da_offs; + u8 pn_offs; + u8 band; + char: 8; + u8 hdr[56]; + struct callback_head callback_head; +}; + +struct ieee80211_fast_rx { + struct net_device *dev; + enum nl80211_iftype vif_type; + u8 vif_addr[6]; + u8 rfc1042_hdr[6]; + __be16 control_port_protocol; + __le16 expected_ds_bits; + u8 icv_len; + u8 key: 1; + u8 internal_forward: 1; + u8 uses_rss: 1; + u8 da_offs; + u8 sa_offs; + struct callback_head callback_head; +}; + +struct rate_control_ref { + const struct rate_control_ops *ops; + void *priv; +}; + +struct beacon_data { + u8 *head; + u8 *tail; + int head_len; + int tail_len; + struct ieee80211_meshconf_ie *meshconf; + u16 cntdwn_counter_offsets[2]; + u8 cntdwn_current_counter; + struct callback_head callback_head; +}; + +struct probe_resp { + struct callback_head callback_head; + int len; + u16 cntdwn_counter_offsets[2]; + u8 data[0]; +}; + +struct fils_discovery_data { + struct callback_head callback_head; + int len; + u8 data[0]; +}; + +struct unsol_bcast_probe_resp_data { + struct callback_head callback_head; + int len; + u8 data[0]; +}; + +struct ieee80211_mgd_auth_data { + struct cfg80211_bss *bss; + long unsigned int timeout; + int tries; + u16 algorithm; + u16 expected_transaction; + u8 key[13]; + u8 key_len; + u8 key_idx; + bool done; + bool peer_confirmed; + bool timeout_started; + u16 sae_trans; + u16 sae_status; + size_t data_len; + u8 data[0]; +}; + +struct ieee80211_mgd_assoc_data { + struct cfg80211_bss *bss; + const u8 *supp_rates; + long unsigned int timeout; + int tries; + u16 capability; + u8 prev_bssid[6]; + u8 ssid[32]; + u8 ssid_len; + u8 supp_rates_len; + bool wmm; + bool uapsd; + bool need_beacon; + bool synced; + bool timeout_started; + u8 ap_ht_param; + struct ieee80211_vht_cap ap_vht_cap; + u8 fils_nonces[32]; + u8 fils_kek[64]; + size_t fils_kek_len; + size_t ie_len; + u8 ie[0]; +}; + +struct ieee802_11_elems; + +struct ieee80211_mesh_sync_ops { + void (*rx_bcn_presp)(struct ieee80211_sub_if_data *, u16, struct ieee80211_mgmt *, struct ieee802_11_elems *, struct ieee80211_rx_status *); + void (*adjust_tsf)(struct ieee80211_sub_if_data *, struct beacon_data *); +}; + +struct ieee802_11_elems { + const u8 *ie_start; + size_t total_len; + const struct ieee80211_tdls_lnkie *lnk_id; + const struct ieee80211_ch_switch_timing *ch_sw_timing; + const u8 *ext_capab; + const u8 *ssid; + const u8 *supp_rates; + const u8 *ds_params; + const struct ieee80211_tim_ie *tim; + const u8 *challenge; + const u8 *rsn; + const u8 *rsnx; + const u8 *erp_info; + const u8 *ext_supp_rates; + const u8 *wmm_info; + const u8 *wmm_param; + const struct ieee80211_ht_cap *ht_cap_elem; + const struct ieee80211_ht_operation *ht_operation; + const struct ieee80211_vht_cap *vht_cap_elem; + const struct ieee80211_vht_operation *vht_operation; + const struct ieee80211_meshconf_ie *mesh_config; + const u8 *he_cap; + const struct ieee80211_he_operation *he_operation; + const struct ieee80211_he_spr *he_spr; + const struct ieee80211_mu_edca_param_set *mu_edca_param_set; + const struct ieee80211_he_6ghz_capa *he_6ghz_capa; + const u8 *uora_element; + const u8 *mesh_id; + const u8 *peering; + const __le16 *awake_window; + const u8 *preq; + const u8 *prep; + const u8 *perr; + const struct ieee80211_rann_ie *rann; + const struct ieee80211_channel_sw_ie *ch_switch_ie; + const struct ieee80211_ext_chansw_ie *ext_chansw_ie; + const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie; + const u8 *max_channel_switch_time; + const u8 *country_elem; + const u8 *pwr_constr_elem; + const u8 *cisco_dtpc_elem; + const struct ieee80211_timeout_interval_ie *timeout_int; + const u8 *opmode_notif; + const struct ieee80211_sec_chan_offs_ie *sec_chan_offs; + struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie; + const struct ieee80211_bss_max_idle_period_ie *max_idle_period_ie; + const struct ieee80211_multiple_bssid_configuration *mbssid_config_ie; + const struct ieee80211_bssid_index *bssid_index; + u8 max_bssid_indicator; + u8 dtim_count; + u8 dtim_period; + const struct ieee80211_addba_ext_ie *addba_ext_ie; + const struct ieee80211_s1g_cap *s1g_capab; + const struct ieee80211_s1g_oper_ie *s1g_oper; + const struct ieee80211_s1g_bcn_compat_ie *s1g_bcn_compat; + const struct ieee80211_aid_response_ie *aid_resp; + u8 ext_capab_len; + u8 ssid_len; + u8 supp_rates_len; + u8 tim_len; + u8 challenge_len; + u8 rsn_len; + u8 rsnx_len; + u8 ext_supp_rates_len; + u8 wmm_info_len; + u8 wmm_param_len; + u8 he_cap_len; + u8 mesh_id_len; + u8 peering_len; + u8 preq_len; + u8 prep_len; + u8 perr_len; + u8 country_elem_len; + u8 bssid_index_len; + bool parse_error; +}; + +struct mesh_csa_settings { + struct callback_head callback_head; + struct cfg80211_csa_settings settings; +}; + +struct mesh_rmc { + struct hlist_head bucket[256]; + u32 idx_mask; +}; + +struct mesh_table { + struct hlist_head known_gates; + spinlock_t gates_lock; + struct rhashtable rhead; + struct hlist_head walk_head; + spinlock_t walk_lock; + atomic_t entries; +}; + +enum ieee80211_sub_if_data_flags { + IEEE80211_SDATA_ALLMULTI = 1, + IEEE80211_SDATA_OPERATING_GMODE = 4, + IEEE80211_SDATA_DONT_BRIDGE_PACKETS = 8, + IEEE80211_SDATA_DISCONNECT_RESUME = 16, + IEEE80211_SDATA_IN_DRIVER = 32, +}; + +enum ieee80211_chanctx_mode { + IEEE80211_CHANCTX_SHARED = 0, + IEEE80211_CHANCTX_EXCLUSIVE = 1, +}; + +enum ieee80211_chanctx_replace_state { + IEEE80211_CHANCTX_REPLACE_NONE = 0, + IEEE80211_CHANCTX_WILL_BE_REPLACED = 1, + IEEE80211_CHANCTX_REPLACES_OTHER = 2, +}; + +struct ieee80211_chanctx { + struct list_head list; + struct callback_head callback_head; + struct list_head assigned_vifs; + struct list_head reserved_vifs; + enum ieee80211_chanctx_replace_state replace_state; + struct ieee80211_chanctx *replace_ctx; + enum ieee80211_chanctx_mode mode; + bool driver_present; + struct ieee80211_chanctx_conf conf; +}; + +struct mac80211_qos_map { + struct cfg80211_qos_map qos_map; + struct callback_head callback_head; +}; + +enum { + IEEE80211_RX_MSG = 1, + IEEE80211_TX_STATUS_MSG = 2, +}; + +enum queue_stop_reason { + IEEE80211_QUEUE_STOP_REASON_DRIVER = 0, + IEEE80211_QUEUE_STOP_REASON_PS = 1, + IEEE80211_QUEUE_STOP_REASON_CSA = 2, + IEEE80211_QUEUE_STOP_REASON_AGGREGATION = 3, + IEEE80211_QUEUE_STOP_REASON_SUSPEND = 4, + IEEE80211_QUEUE_STOP_REASON_SKB_ADD = 5, + IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL = 6, + IEEE80211_QUEUE_STOP_REASON_FLUSH = 7, + IEEE80211_QUEUE_STOP_REASON_TDLS_TEARDOWN = 8, + IEEE80211_QUEUE_STOP_REASON_RESERVE_TID = 9, + IEEE80211_QUEUE_STOP_REASONS = 10, +}; + +enum { + SCAN_SW_SCANNING = 0, + SCAN_HW_SCANNING = 1, + SCAN_ONCHANNEL_SCANNING = 2, + SCAN_COMPLETED = 3, + SCAN_ABORTED = 4, + SCAN_HW_CANCELLED = 5, +}; + +struct ieee80211_bar { + __le16 frame_control; + __le16 duration; + __u8 ra[6]; + __u8 ta[6]; + __le16 control; + __le16 start_seq_num; +}; + +enum ieee80211_ht_actioncode { + WLAN_HT_ACTION_NOTIFY_CHANWIDTH = 0, + WLAN_HT_ACTION_SMPS = 1, + WLAN_HT_ACTION_PSMP = 2, + WLAN_HT_ACTION_PCO_PHASE = 3, + WLAN_HT_ACTION_CSI = 4, + WLAN_HT_ACTION_NONCOMPRESSED_BF = 5, + WLAN_HT_ACTION_COMPRESSED_BF = 6, + WLAN_HT_ACTION_ASEL_IDX_FEEDBACK = 7, +}; + +enum ieee80211_tdls_actioncode { + WLAN_TDLS_SETUP_REQUEST = 0, + WLAN_TDLS_SETUP_RESPONSE = 1, + WLAN_TDLS_SETUP_CONFIRM = 2, + WLAN_TDLS_TEARDOWN = 3, + WLAN_TDLS_PEER_TRAFFIC_INDICATION = 4, + WLAN_TDLS_CHANNEL_SWITCH_REQUEST = 5, + WLAN_TDLS_CHANNEL_SWITCH_RESPONSE = 6, + WLAN_TDLS_PEER_PSM_REQUEST = 7, + WLAN_TDLS_PEER_PSM_RESPONSE = 8, + WLAN_TDLS_PEER_TRAFFIC_RESPONSE = 9, + WLAN_TDLS_DISCOVERY_REQUEST = 10, +}; + +enum ieee80211_radiotap_tx_flags { + IEEE80211_RADIOTAP_F_TX_FAIL = 1, + IEEE80211_RADIOTAP_F_TX_CTS = 2, + IEEE80211_RADIOTAP_F_TX_RTS = 4, + IEEE80211_RADIOTAP_F_TX_NOACK = 8, + IEEE80211_RADIOTAP_F_TX_NOSEQNO = 16, + IEEE80211_RADIOTAP_F_TX_ORDER = 32, +}; + +enum ieee80211_radiotap_mcs_flags { + IEEE80211_RADIOTAP_MCS_BW_MASK = 3, + IEEE80211_RADIOTAP_MCS_BW_20 = 0, + IEEE80211_RADIOTAP_MCS_BW_40 = 1, + IEEE80211_RADIOTAP_MCS_BW_20L = 2, + IEEE80211_RADIOTAP_MCS_BW_20U = 3, + IEEE80211_RADIOTAP_MCS_SGI = 4, + IEEE80211_RADIOTAP_MCS_FMT_GF = 8, + IEEE80211_RADIOTAP_MCS_FEC_LDPC = 16, + IEEE80211_RADIOTAP_MCS_STBC_MASK = 96, + IEEE80211_RADIOTAP_MCS_STBC_1 = 1, + IEEE80211_RADIOTAP_MCS_STBC_2 = 2, + IEEE80211_RADIOTAP_MCS_STBC_3 = 3, + IEEE80211_RADIOTAP_MCS_STBC_SHIFT = 5, +}; + +enum ieee80211_radiotap_vht_flags { + IEEE80211_RADIOTAP_VHT_FLAG_STBC = 1, + IEEE80211_RADIOTAP_VHT_FLAG_TXOP_PS_NA = 2, + IEEE80211_RADIOTAP_VHT_FLAG_SGI = 4, + IEEE80211_RADIOTAP_VHT_FLAG_SGI_NSYM_M10_9 = 8, + IEEE80211_RADIOTAP_VHT_FLAG_LDPC_EXTRA_OFDM_SYM = 16, + IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED = 32, +}; + +struct ieee80211_radiotap_he { + __le16 data1; + __le16 data2; + __le16 data3; + __le16 data4; + __le16 data5; + __le16 data6; +}; + +enum ieee80211_radiotap_he_bits { + IEEE80211_RADIOTAP_HE_DATA1_FORMAT_MASK = 3, + IEEE80211_RADIOTAP_HE_DATA1_FORMAT_SU = 0, + IEEE80211_RADIOTAP_HE_DATA1_FORMAT_EXT_SU = 1, + IEEE80211_RADIOTAP_HE_DATA1_FORMAT_MU = 2, + IEEE80211_RADIOTAP_HE_DATA1_FORMAT_TRIG = 3, + IEEE80211_RADIOTAP_HE_DATA1_BSS_COLOR_KNOWN = 4, + IEEE80211_RADIOTAP_HE_DATA1_BEAM_CHANGE_KNOWN = 8, + IEEE80211_RADIOTAP_HE_DATA1_UL_DL_KNOWN = 16, + IEEE80211_RADIOTAP_HE_DATA1_DATA_MCS_KNOWN = 32, + IEEE80211_RADIOTAP_HE_DATA1_DATA_DCM_KNOWN = 64, + IEEE80211_RADIOTAP_HE_DATA1_CODING_KNOWN = 128, + IEEE80211_RADIOTAP_HE_DATA1_LDPC_XSYMSEG_KNOWN = 256, + IEEE80211_RADIOTAP_HE_DATA1_STBC_KNOWN = 512, + IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE_KNOWN = 1024, + IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE2_KNOWN = 2048, + IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE3_KNOWN = 4096, + IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE4_KNOWN = 8192, + IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN = 16384, + IEEE80211_RADIOTAP_HE_DATA1_DOPPLER_KNOWN = 32768, + IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_KNOWN = 1, + IEEE80211_RADIOTAP_HE_DATA2_GI_KNOWN = 2, + IEEE80211_RADIOTAP_HE_DATA2_NUM_LTF_SYMS_KNOWN = 4, + IEEE80211_RADIOTAP_HE_DATA2_PRE_FEC_PAD_KNOWN = 8, + IEEE80211_RADIOTAP_HE_DATA2_TXBF_KNOWN = 16, + IEEE80211_RADIOTAP_HE_DATA2_PE_DISAMBIG_KNOWN = 32, + IEEE80211_RADIOTAP_HE_DATA2_TXOP_KNOWN = 64, + IEEE80211_RADIOTAP_HE_DATA2_MIDAMBLE_KNOWN = 128, + IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET = 16128, + IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET_KNOWN = 16384, + IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_SEC = 32768, + IEEE80211_RADIOTAP_HE_DATA3_BSS_COLOR = 63, + IEEE80211_RADIOTAP_HE_DATA3_BEAM_CHANGE = 64, + IEEE80211_RADIOTAP_HE_DATA3_UL_DL = 128, + IEEE80211_RADIOTAP_HE_DATA3_DATA_MCS = 3840, + IEEE80211_RADIOTAP_HE_DATA3_DATA_DCM = 4096, + IEEE80211_RADIOTAP_HE_DATA3_CODING = 8192, + IEEE80211_RADIOTAP_HE_DATA3_LDPC_XSYMSEG = 16384, + IEEE80211_RADIOTAP_HE_DATA3_STBC = 32768, + IEEE80211_RADIOTAP_HE_DATA4_SU_MU_SPTL_REUSE = 15, + IEEE80211_RADIOTAP_HE_DATA4_MU_STA_ID = 32752, + IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE1 = 15, + IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE2 = 240, + IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE3 = 3840, + IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE4 = 61440, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC = 15, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_20MHZ = 0, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_40MHZ = 1, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_80MHZ = 2, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_160MHZ = 3, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_26T = 4, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_52T = 5, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_106T = 6, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_242T = 7, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_484T = 8, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_996T = 9, + IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_2x996T = 10, + IEEE80211_RADIOTAP_HE_DATA5_GI = 48, + IEEE80211_RADIOTAP_HE_DATA5_GI_0_8 = 0, + IEEE80211_RADIOTAP_HE_DATA5_GI_1_6 = 1, + IEEE80211_RADIOTAP_HE_DATA5_GI_3_2 = 2, + IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE = 192, + IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_UNKNOWN = 0, + IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_1X = 1, + IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_2X = 2, + IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X = 3, + IEEE80211_RADIOTAP_HE_DATA5_NUM_LTF_SYMS = 1792, + IEEE80211_RADIOTAP_HE_DATA5_PRE_FEC_PAD = 12288, + IEEE80211_RADIOTAP_HE_DATA5_TXBF = 16384, + IEEE80211_RADIOTAP_HE_DATA5_PE_DISAMBIG = 32768, + IEEE80211_RADIOTAP_HE_DATA6_NSTS = 15, + IEEE80211_RADIOTAP_HE_DATA6_DOPPLER = 16, + IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_KNOWN = 32, + IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW = 192, + IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_20MHZ = 0, + IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_40MHZ = 1, + IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_80MHZ = 2, + IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_160MHZ = 3, + IEEE80211_RADIOTAP_HE_DATA6_TXOP = 32512, + IEEE80211_RADIOTAP_HE_DATA6_MIDAMBLE_PDCTY = 32768, +}; + +enum ieee80211_ac_numbers { + IEEE80211_AC_VO = 0, + IEEE80211_AC_VI = 1, + IEEE80211_AC_BE = 2, + IEEE80211_AC_BK = 3, +}; + +enum mac80211_tx_info_flags { + IEEE80211_TX_CTL_REQ_TX_STATUS = 1, + IEEE80211_TX_CTL_ASSIGN_SEQ = 2, + IEEE80211_TX_CTL_NO_ACK = 4, + IEEE80211_TX_CTL_CLEAR_PS_FILT = 8, + IEEE80211_TX_CTL_FIRST_FRAGMENT = 16, + IEEE80211_TX_CTL_SEND_AFTER_DTIM = 32, + IEEE80211_TX_CTL_AMPDU = 64, + IEEE80211_TX_CTL_INJECTED = 128, + IEEE80211_TX_STAT_TX_FILTERED = 256, + IEEE80211_TX_STAT_ACK = 512, + IEEE80211_TX_STAT_AMPDU = 1024, + IEEE80211_TX_STAT_AMPDU_NO_BACK = 2048, + IEEE80211_TX_CTL_RATE_CTRL_PROBE = 4096, + IEEE80211_TX_INTFL_OFFCHAN_TX_OK = 8192, + IEEE80211_TX_CTL_HW_80211_ENCAP = 16384, + IEEE80211_TX_INTFL_RETRIED = 32768, + IEEE80211_TX_INTFL_DONT_ENCRYPT = 65536, + IEEE80211_TX_CTL_NO_PS_BUFFER = 131072, + IEEE80211_TX_CTL_MORE_FRAMES = 262144, + IEEE80211_TX_INTFL_RETRANSMISSION = 524288, + IEEE80211_TX_INTFL_MLME_CONN_TX = 1048576, + IEEE80211_TX_INTFL_NL80211_FRAME_TX = 2097152, + IEEE80211_TX_CTL_LDPC = 4194304, + IEEE80211_TX_CTL_STBC = 25165824, + IEEE80211_TX_CTL_TX_OFFCHAN = 33554432, + IEEE80211_TX_INTFL_TKIP_MIC_FAILURE = 67108864, + IEEE80211_TX_CTL_NO_CCK_RATE = 134217728, + IEEE80211_TX_STATUS_EOSP = 268435456, + IEEE80211_TX_CTL_USE_MINRATE = 536870912, + IEEE80211_TX_CTL_DONTFRAG = 1073741824, + IEEE80211_TX_STAT_NOACK_TRANSMITTED = 2147483648, +}; + +enum mac80211_tx_control_flags { + IEEE80211_TX_CTRL_PORT_CTRL_PROTO = 1, + IEEE80211_TX_CTRL_PS_RESPONSE = 2, + IEEE80211_TX_CTRL_RATE_INJECT = 4, + IEEE80211_TX_CTRL_AMSDU = 8, + IEEE80211_TX_CTRL_FAST_XMIT = 16, + IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP = 32, + IEEE80211_TX_INTCFL_NEED_TXPROCESSING = 64, + IEEE80211_TX_CTRL_NO_SEQNO = 128, + IEEE80211_TX_CTRL_DONT_REORDER = 256, +}; + +enum mac80211_rate_control_flags { + IEEE80211_TX_RC_USE_RTS_CTS = 1, + IEEE80211_TX_RC_USE_CTS_PROTECT = 2, + IEEE80211_TX_RC_USE_SHORT_PREAMBLE = 4, + IEEE80211_TX_RC_MCS = 8, + IEEE80211_TX_RC_GREEN_FIELD = 16, + IEEE80211_TX_RC_40_MHZ_WIDTH = 32, + IEEE80211_TX_RC_DUP_DATA = 64, + IEEE80211_TX_RC_SHORT_GI = 128, + IEEE80211_TX_RC_VHT_MCS = 256, + IEEE80211_TX_RC_80_MHZ_WIDTH = 512, + IEEE80211_TX_RC_160_MHZ_WIDTH = 1024, +}; + +enum ieee80211_sta_info_flags { + WLAN_STA_AUTH = 0, + WLAN_STA_ASSOC = 1, + WLAN_STA_PS_STA = 2, + WLAN_STA_AUTHORIZED = 3, + WLAN_STA_SHORT_PREAMBLE = 4, + WLAN_STA_WDS = 5, + WLAN_STA_CLEAR_PS_FILT = 6, + WLAN_STA_MFP = 7, + WLAN_STA_BLOCK_BA = 8, + WLAN_STA_PS_DRIVER = 9, + WLAN_STA_PSPOLL = 10, + WLAN_STA_TDLS_PEER = 11, + WLAN_STA_TDLS_PEER_AUTH = 12, + WLAN_STA_TDLS_INITIATOR = 13, + WLAN_STA_TDLS_CHAN_SWITCH = 14, + WLAN_STA_TDLS_OFF_CHANNEL = 15, + WLAN_STA_TDLS_WIDER_BW = 16, + WLAN_STA_UAPSD = 17, + WLAN_STA_SP = 18, + WLAN_STA_4ADDR_EVENT = 19, + WLAN_STA_INSERTED = 20, + WLAN_STA_RATE_CONTROL = 21, + WLAN_STA_TOFFSET_KNOWN = 22, + WLAN_STA_MPSP_OWNER = 23, + WLAN_STA_MPSP_RECIPIENT = 24, + WLAN_STA_PS_DELIVER = 25, + WLAN_STA_USES_ENCRYPTION = 26, + NUM_WLAN_STA_FLAGS = 27, +}; + +enum ieee80211_sta_flags { + IEEE80211_STA_CONNECTION_POLL = 2, + IEEE80211_STA_CONTROL_PORT = 4, + IEEE80211_STA_DISABLE_HT = 16, + IEEE80211_STA_MFP_ENABLED = 64, + IEEE80211_STA_UAPSD_ENABLED = 128, + IEEE80211_STA_NULLFUNC_ACKED = 256, + IEEE80211_STA_RESET_SIGNAL_AVE = 512, + IEEE80211_STA_DISABLE_40MHZ = 1024, + IEEE80211_STA_DISABLE_VHT = 2048, + IEEE80211_STA_DISABLE_80P80MHZ = 4096, + IEEE80211_STA_DISABLE_160MHZ = 8192, + IEEE80211_STA_DISABLE_WMM = 16384, + IEEE80211_STA_ENABLE_RRM = 32768, + IEEE80211_STA_DISABLE_HE = 65536, +}; + +enum ieee80211_sdata_state_bits { + SDATA_STATE_RUNNING = 0, + SDATA_STATE_OFFCHANNEL = 1, + SDATA_STATE_OFFCHANNEL_BEACON_STOPPED = 2, +}; + +enum ieee80211_rate_control_changed { + IEEE80211_RC_BW_CHANGED = 1, + IEEE80211_RC_SMPS_CHANGED = 2, + IEEE80211_RC_SUPP_RATES_CHANGED = 4, + IEEE80211_RC_NSS_CHANGED = 8, +}; + +struct ieee80211_qos_hdr { + __le16 frame_control; + __le16 duration_id; + u8 addr1[6]; + u8 addr2[6]; + u8 addr3[6]; + __le16 seq_ctrl; + __le16 qos_ctrl; +}; + +enum ieee80211_vif_flags { + IEEE80211_VIF_BEACON_FILTER = 1, + IEEE80211_VIF_SUPPORTS_CQM_RSSI = 2, + IEEE80211_VIF_SUPPORTS_UAPSD = 4, + IEEE80211_VIF_GET_NOA_UPDATE = 8, +}; + +enum ieee80211_agg_stop_reason { + AGG_STOP_DECLINED = 0, + AGG_STOP_LOCAL_REQUEST = 1, + AGG_STOP_PEER_REQUEST = 2, + AGG_STOP_DESTROY_STA = 3, +}; + +enum sta_stats_type { + STA_STATS_RATE_TYPE_INVALID = 0, + STA_STATS_RATE_TYPE_LEGACY = 1, + STA_STATS_RATE_TYPE_HT = 2, + STA_STATS_RATE_TYPE_VHT = 3, + STA_STATS_RATE_TYPE_HE = 4, + STA_STATS_RATE_TYPE_S1G = 5, +}; + +struct txq_info { + struct fq_tin tin; + struct fq_flow___2 def_flow; + struct codel_vars def_cvars; + struct codel_stats cstats; + struct sk_buff_head frags; + struct list_head schedule_order; + u16 schedule_round; + long unsigned int flags; + struct ieee80211_txq txq; +}; + +enum mac80211_rx_flags { + RX_FLAG_MMIC_ERROR = 1, + RX_FLAG_DECRYPTED = 2, + RX_FLAG_MACTIME_PLCP_START = 4, + RX_FLAG_MMIC_STRIPPED = 8, + RX_FLAG_IV_STRIPPED = 16, + RX_FLAG_FAILED_FCS_CRC = 32, + RX_FLAG_FAILED_PLCP_CRC = 64, + RX_FLAG_MACTIME_START = 128, + RX_FLAG_NO_SIGNAL_VAL = 256, + RX_FLAG_AMPDU_DETAILS = 512, + RX_FLAG_PN_VALIDATED = 1024, + RX_FLAG_DUP_VALIDATED = 2048, + RX_FLAG_AMPDU_LAST_KNOWN = 4096, + RX_FLAG_AMPDU_IS_LAST = 8192, + RX_FLAG_AMPDU_DELIM_CRC_ERROR = 16384, + RX_FLAG_AMPDU_DELIM_CRC_KNOWN = 32768, + RX_FLAG_MACTIME_END = 65536, + RX_FLAG_ONLY_MONITOR = 131072, + RX_FLAG_SKIP_MONITOR = 262144, + RX_FLAG_AMSDU_MORE = 524288, + RX_FLAG_RADIOTAP_VENDOR_DATA = 1048576, + RX_FLAG_MIC_STRIPPED = 2097152, + RX_FLAG_ALLOW_SAME_PN = 4194304, + RX_FLAG_ICV_STRIPPED = 8388608, + RX_FLAG_AMPDU_EOF_BIT = 16777216, + RX_FLAG_AMPDU_EOF_BIT_KNOWN = 33554432, + RX_FLAG_RADIOTAP_HE = 67108864, + RX_FLAG_RADIOTAP_HE_MU = 134217728, + RX_FLAG_RADIOTAP_LSIG = 268435456, + RX_FLAG_NO_PSDU = 536870912, +}; + +enum ieee80211_key_flags { + IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = 1, + IEEE80211_KEY_FLAG_GENERATE_IV = 2, + IEEE80211_KEY_FLAG_GENERATE_MMIC = 4, + IEEE80211_KEY_FLAG_PAIRWISE = 8, + IEEE80211_KEY_FLAG_SW_MGMT_TX = 16, + IEEE80211_KEY_FLAG_PUT_IV_SPACE = 32, + IEEE80211_KEY_FLAG_RX_MGMT = 64, + IEEE80211_KEY_FLAG_RESERVE_TAILROOM = 128, + IEEE80211_KEY_FLAG_PUT_MIC_SPACE = 256, + IEEE80211_KEY_FLAG_NO_AUTO_TX = 512, + IEEE80211_KEY_FLAG_GENERATE_MMIE = 1024, +}; + +typedef unsigned int ieee80211_tx_result; + +struct ieee80211_tx_data { + struct sk_buff *skb; + struct sk_buff_head skbs; + struct ieee80211_local *local; + struct ieee80211_sub_if_data *sdata; + struct sta_info *sta; + struct ieee80211_key *key; + struct ieee80211_tx_rate rate; + unsigned int flags; +}; + +typedef unsigned int ieee80211_rx_result; + +struct ieee80211_rx_data { + struct list_head *list; + struct sk_buff *skb; + struct ieee80211_local *local; + struct ieee80211_sub_if_data *sdata; + struct sta_info *sta; + struct ieee80211_key *key; + unsigned int flags; + int seqno_idx; + int security_idx; + u32 tkip_iv32; + u16 tkip_iv16; +}; + +struct ieee80211_mmie { + u8 element_id; + u8 length; + __le16 key_id; + u8 sequence_number[6]; + u8 mic[8]; +}; + +struct ieee80211_mmie_16 { + u8 element_id; + u8 length; + __le16 key_id; + u8 sequence_number[6]; + u8 mic[16]; +}; + +enum ieee80211_internal_key_flags { + KEY_FLAG_UPLOADED_TO_HARDWARE = 1, + KEY_FLAG_TAINTED = 2, + KEY_FLAG_CIPHER_SCHEME = 4, +}; + +enum { + TKIP_DECRYPT_OK = 0, + TKIP_DECRYPT_NO_EXT_IV = 4294967295, + TKIP_DECRYPT_INVALID_KEYIDX = 4294967294, + TKIP_DECRYPT_REPLAY = 4294967293, +}; + +enum mac80211_rx_encoding { + RX_ENC_LEGACY = 0, + RX_ENC_HT = 1, + RX_ENC_VHT = 2, + RX_ENC_HE = 3, +}; + +struct ieee80211_bss { + u32 device_ts_beacon; + u32 device_ts_presp; + bool wmm_used; + bool uapsd_supported; + u8 supp_rates[32]; + size_t supp_rates_len; + struct ieee80211_rate *beacon_rate; + u32 vht_cap_info; + bool has_erp_value; + u8 erp_value; + u8 corrupt_data; + u8 valid_data; +}; + +enum ieee80211_bss_corrupt_data_flags { + IEEE80211_BSS_CORRUPT_BEACON = 1, + IEEE80211_BSS_CORRUPT_PROBE_RESP = 2, +}; + +enum ieee80211_bss_valid_data_flags { + IEEE80211_BSS_VALID_WMM = 2, + IEEE80211_BSS_VALID_RATES = 4, + IEEE80211_BSS_VALID_ERP = 8, +}; + +enum { + IEEE80211_PROBE_FLAG_DIRECTED = 1, + IEEE80211_PROBE_FLAG_MIN_CONTENT = 2, + IEEE80211_PROBE_FLAG_RANDOM_SN = 4, +}; + +struct ieee80211_roc_work { + struct list_head list; + struct ieee80211_sub_if_data *sdata; + struct ieee80211_channel *chan; + bool started; + bool abort; + bool hw_begun; + bool notified; + bool on_channel; + long unsigned int start_time; + u32 duration; + u32 req_duration; + struct sk_buff *frame; + u64 cookie; + u64 mgmt_tx_cookie; + enum ieee80211_roc_type type; +}; + +enum ieee80211_back_actioncode { + WLAN_ACTION_ADDBA_REQ = 0, + WLAN_ACTION_ADDBA_RESP = 1, + WLAN_ACTION_DELBA = 2, +}; + +enum ieee80211_back_parties { + WLAN_BACK_RECIPIENT = 0, + WLAN_BACK_INITIATOR = 1, +}; + +enum txq_info_flags { + IEEE80211_TXQ_STOP = 0, + IEEE80211_TXQ_AMPDU = 1, + IEEE80211_TXQ_NO_AMSDU = 2, + IEEE80211_TXQ_STOP_NETIF_TX = 3, +}; + +enum ieee80211_vht_opmode_bits { + IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK = 3, + IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ = 0, + IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ = 1, + IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ = 2, + IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ = 3, + IEEE80211_OPMODE_NOTIF_BW_160_80P80 = 4, + IEEE80211_OPMODE_NOTIF_RX_NSS_MASK = 112, + IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT = 4, + IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF = 128, +}; + +enum ieee80211_spectrum_mgmt_actioncode { + WLAN_ACTION_SPCT_MSR_REQ = 0, + WLAN_ACTION_SPCT_MSR_RPRT = 1, + WLAN_ACTION_SPCT_TPC_REQ = 2, + WLAN_ACTION_SPCT_TPC_RPRT = 3, + WLAN_ACTION_SPCT_CHL_SWITCH = 4, +}; + +struct ieee80211_csa_ie { + struct cfg80211_chan_def chandef; + u8 mode; + u8 count; + u8 ttl; + u16 pre_value; + u16 reason_code; + u32 max_switch_time; +}; + +enum ieee80211_vht_actioncode { + WLAN_VHT_ACTION_COMPRESSED_BF = 0, + WLAN_VHT_ACTION_GROUPID_MGMT = 1, + WLAN_VHT_ACTION_OPMODE_NOTIF = 2, +}; + +enum ieee80211_offload_flags { + IEEE80211_OFFLOAD_ENCAP_ENABLED = 1, + IEEE80211_OFFLOAD_ENCAP_4ADDR = 2, +}; + +enum ieee80211_tpt_led_trigger_flags { + IEEE80211_TPT_LEDTRIG_FL_RADIO = 1, + IEEE80211_TPT_LEDTRIG_FL_WORK = 2, + IEEE80211_TPT_LEDTRIG_FL_CONNECTED = 4, +}; + +struct rate_control_alg { + struct list_head list; + const struct rate_control_ops *ops; +}; + +struct michael_mic_ctx { + u32 l; + u32 r; +}; + +struct ieee80211_csa_settings { + const u16 *counter_offsets_beacon; + const u16 *counter_offsets_presp; + int n_counter_offsets_beacon; + int n_counter_offsets_presp; + u8 count; +}; + +struct ieee80211_hdr_3addr { + __le16 frame_control; + __le16 duration_id; + u8 addr1[6]; + u8 addr2[6]; + u8 addr3[6]; + __le16 seq_ctrl; +}; + +enum ieee80211_ht_chanwidth_values { + IEEE80211_HT_CHANWIDTH_20MHZ = 0, + IEEE80211_HT_CHANWIDTH_ANY = 1, +}; + +struct ieee80211_tdls_data { + u8 da[6]; + u8 sa[6]; + __be16 ether_type; + u8 payload_type; + u8 category; + u8 action_code; + union { + struct { + u8 dialog_token; + __le16 capability; + u8 variable[0]; + } __attribute__((packed)) setup_req; + struct { + __le16 status_code; + u8 dialog_token; + __le16 capability; + u8 variable[0]; + } __attribute__((packed)) setup_resp; + struct { + __le16 status_code; + u8 dialog_token; + u8 variable[0]; + } __attribute__((packed)) setup_cfm; + struct { + __le16 reason_code; + u8 variable[0]; + } teardown; + struct { + u8 dialog_token; + u8 variable[0]; + } discover_req; + struct { + u8 target_channel; + u8 oper_class; + u8 variable[0]; + } chan_switch_req; + struct { + __le16 status_code; + u8 variable[0]; + } chan_switch_resp; + } u; +} __attribute__((packed)); + +enum ieee80211_self_protected_actioncode { + WLAN_SP_RESERVED = 0, + WLAN_SP_MESH_PEERING_OPEN = 1, + WLAN_SP_MESH_PEERING_CONFIRM = 2, + WLAN_SP_MESH_PEERING_CLOSE = 3, + WLAN_SP_MGK_INFORM = 4, + WLAN_SP_MGK_ACK = 5, +}; + +enum ieee80211_pub_actioncode { + WLAN_PUB_ACTION_20_40_BSS_COEX = 0, + WLAN_PUB_ACTION_DSE_ENABLEMENT = 1, + WLAN_PUB_ACTION_DSE_DEENABLEMENT = 2, + WLAN_PUB_ACTION_DSE_REG_LOC_ANN = 3, + WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4, + WLAN_PUB_ACTION_DSE_MSMT_REQ = 5, + WLAN_PUB_ACTION_DSE_MSMT_RESP = 6, + WLAN_PUB_ACTION_MSMT_PILOT = 7, + WLAN_PUB_ACTION_DSE_PC = 8, + WLAN_PUB_ACTION_VENDOR_SPECIFIC = 9, + WLAN_PUB_ACTION_GAS_INITIAL_REQ = 10, + WLAN_PUB_ACTION_GAS_INITIAL_RESP = 11, + WLAN_PUB_ACTION_GAS_COMEBACK_REQ = 12, + WLAN_PUB_ACTION_GAS_COMEBACK_RESP = 13, + WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14, + WLAN_PUB_ACTION_LOC_TRACK_NOTI = 15, + WLAN_PUB_ACTION_QAB_REQUEST_FRAME = 16, + WLAN_PUB_ACTION_QAB_RESPONSE_FRAME = 17, + WLAN_PUB_ACTION_QMF_POLICY = 18, + WLAN_PUB_ACTION_QMF_POLICY_CHANGE = 19, + WLAN_PUB_ACTION_QLOAD_REQUEST = 20, + WLAN_PUB_ACTION_QLOAD_REPORT = 21, + WLAN_PUB_ACTION_HCCA_TXOP_ADVERT = 22, + WLAN_PUB_ACTION_HCCA_TXOP_RESPONSE = 23, + WLAN_PUB_ACTION_PUBLIC_KEY = 24, + WLAN_PUB_ACTION_CHANNEL_AVAIL_QUERY = 25, + WLAN_PUB_ACTION_CHANNEL_SCHEDULE_MGMT = 26, + WLAN_PUB_ACTION_CONTACT_VERI_SIGNAL = 27, + WLAN_PUB_ACTION_GDD_ENABLEMENT_REQ = 28, + WLAN_PUB_ACTION_GDD_ENABLEMENT_RESP = 29, + WLAN_PUB_ACTION_NETWORK_CHANNEL_CONTROL = 30, + WLAN_PUB_ACTION_WHITE_SPACE_MAP_ANN = 31, + WLAN_PUB_ACTION_FTM_REQUEST = 32, + WLAN_PUB_ACTION_FTM = 33, + WLAN_PUB_ACTION_FILS_DISCOVERY = 34, +}; + +enum ieee80211_sa_query_action { + WLAN_ACTION_SA_QUERY_REQUEST = 0, + WLAN_ACTION_SA_QUERY_RESPONSE = 1, +}; + +enum ieee80211_radiotap_flags { + IEEE80211_RADIOTAP_F_CFP = 1, + IEEE80211_RADIOTAP_F_SHORTPRE = 2, + IEEE80211_RADIOTAP_F_WEP = 4, + IEEE80211_RADIOTAP_F_FRAG = 8, + IEEE80211_RADIOTAP_F_FCS = 16, + IEEE80211_RADIOTAP_F_DATAPAD = 32, + IEEE80211_RADIOTAP_F_BADFCS = 64, +}; + +enum ieee80211_radiotap_channel_flags { + IEEE80211_CHAN_CCK = 32, + IEEE80211_CHAN_OFDM = 64, + IEEE80211_CHAN_2GHZ = 128, + IEEE80211_CHAN_5GHZ = 256, + IEEE80211_CHAN_DYN = 1024, + IEEE80211_CHAN_HALF = 16384, + IEEE80211_CHAN_QUARTER = 32768, +}; + +enum ieee80211_radiotap_rx_flags { + IEEE80211_RADIOTAP_F_RX_BADPLCP = 2, +}; + +enum ieee80211_radiotap_ampdu_flags { + IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN = 1, + IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN = 2, + IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN = 4, + IEEE80211_RADIOTAP_AMPDU_IS_LAST = 8, + IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR = 16, + IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN = 32, + IEEE80211_RADIOTAP_AMPDU_EOF = 64, + IEEE80211_RADIOTAP_AMPDU_EOF_KNOWN = 128, +}; + +enum ieee80211_radiotap_vht_coding { + IEEE80211_RADIOTAP_CODING_LDPC_USER0 = 1, + IEEE80211_RADIOTAP_CODING_LDPC_USER1 = 2, + IEEE80211_RADIOTAP_CODING_LDPC_USER2 = 4, + IEEE80211_RADIOTAP_CODING_LDPC_USER3 = 8, +}; + +enum ieee80211_radiotap_timestamp_flags { + IEEE80211_RADIOTAP_TIMESTAMP_FLAG_64BIT = 0, + IEEE80211_RADIOTAP_TIMESTAMP_FLAG_32BIT = 1, + IEEE80211_RADIOTAP_TIMESTAMP_FLAG_ACCURACY = 2, +}; + +struct ieee80211_radiotap_he_mu { + __le16 flags1; + __le16 flags2; + u8 ru_ch1[4]; + u8 ru_ch2[4]; +}; + +struct ieee80211_radiotap_lsig { + __le16 data1; + __le16 data2; +}; + +enum mac80211_rx_encoding_flags { + RX_ENC_FLAG_SHORTPRE = 1, + RX_ENC_FLAG_SHORT_GI = 4, + RX_ENC_FLAG_HT_GF = 8, + RX_ENC_FLAG_STBC_MASK = 48, + RX_ENC_FLAG_LDPC = 64, + RX_ENC_FLAG_BF = 128, +}; + +struct ieee80211_vendor_radiotap { + u32 present; + u8 align; + u8 oui[3]; + u8 subns; + u8 pad; + u16 len; + u8 data[0]; +}; + +enum ieee80211_packet_rx_flags { + IEEE80211_RX_AMSDU = 8, + IEEE80211_RX_MALFORMED_ACTION_FRM = 16, + IEEE80211_RX_DEFERRED_RELEASE = 32, +}; + +enum ieee80211_rx_flags { + IEEE80211_RX_CMNTR = 1, + IEEE80211_RX_BEACON_REPORTED = 2, +}; + +struct ieee80211_rts { + __le16 frame_control; + __le16 duration; + u8 ra[6]; + u8 ta[6]; +}; + +struct ieee80211_cts { + __le16 frame_control; + __le16 duration; + u8 ra[6]; +}; + +struct ieee80211_pspoll { + __le16 frame_control; + __le16 aid; + u8 bssid[6]; + u8 ta[6]; +}; + +struct ieee80211_mutable_offsets { + u16 tim_offset; + u16 tim_length; + u16 cntdwn_counter_offs[2]; +}; + +typedef struct sk_buff *fq_tin_dequeue_t(struct fq *, struct fq_tin *, struct fq_flow___2 *); + +typedef void fq_skb_free_t(struct fq *, struct fq_tin *, struct fq_flow___2 *, struct sk_buff *); + +typedef bool fq_skb_filter_t(struct fq *, struct fq_tin *, struct fq_flow___2 *, struct sk_buff *, void *); + +typedef struct fq_flow___2 *fq_flow_get_default_t(struct fq *, struct fq_tin *, int, struct sk_buff *); + +enum mesh_path_flags { + MESH_PATH_ACTIVE = 1, + MESH_PATH_RESOLVING = 2, + MESH_PATH_SN_VALID = 4, + MESH_PATH_FIXED = 8, + MESH_PATH_RESOLVED = 16, + MESH_PATH_REQ_QUEUED = 32, + MESH_PATH_DELETED = 64, +}; + +struct mesh_path { + u8 dst[6]; + u8 mpp[6]; + struct rhash_head rhash; + struct hlist_node walk_list; + struct hlist_node gate_list; + struct ieee80211_sub_if_data *sdata; + struct sta_info *next_hop; + struct timer_list timer; + struct sk_buff_head frame_queue; + struct callback_head rcu; + u32 sn; + u32 metric; + u8 hop_count; + long unsigned int exp_time; + u32 discovery_timeout; + u8 discovery_retries; + enum mesh_path_flags flags; + spinlock_t state_lock; + u8 rann_snd_addr[6]; + u32 rann_metric; + long unsigned int last_preq_to_root; + bool is_root; + bool is_gate; + u32 path_change_count; +}; + +enum ieee80211_encrypt { + ENCRYPT_NO = 0, + ENCRYPT_MGMT = 1, + ENCRYPT_DATA = 2, +}; + +enum ieee80211_s1g_chanwidth { + IEEE80211_S1G_CHANWIDTH_1MHZ = 0, + IEEE80211_S1G_CHANWIDTH_2MHZ = 1, + IEEE80211_S1G_CHANWIDTH_4MHZ = 3, + IEEE80211_S1G_CHANWIDTH_8MHZ = 7, + IEEE80211_S1G_CHANWIDTH_16MHZ = 15, +}; + +struct ieee80211_he_6ghz_oper { + u8 primary; + u8 control; + u8 ccfs0; + u8 ccfs1; + u8 minrate; +}; + +enum ieee80211_interface_iteration_flags { + IEEE80211_IFACE_ITER_NORMAL = 0, + IEEE80211_IFACE_ITER_RESUME_ALL = 1, + IEEE80211_IFACE_ITER_ACTIVE = 2, + IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER = 4, +}; + +struct ieee80211_noa_data { + u32 next_tsf; + bool has_next_tsf; + u8 absent; + u8 count[4]; + struct { + u32 start; + u32 duration; + u32 interval; + } desc[4]; +}; + +enum ieee80211_chanctx_change { + IEEE80211_CHANCTX_CHANGE_WIDTH = 1, + IEEE80211_CHANCTX_CHANGE_RX_CHAINS = 2, + IEEE80211_CHANCTX_CHANGE_RADAR = 4, + IEEE80211_CHANCTX_CHANGE_CHANNEL = 8, + IEEE80211_CHANCTX_CHANGE_MIN_WIDTH = 16, +}; + +struct trace_vif_entry { + enum nl80211_iftype vif_type; + bool p2p; + char vif_name[16]; +} __attribute__((packed)); + +struct trace_chandef_entry { + u32 control_freq; + u32 freq_offset; + u32 chan_width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; +}; + +struct trace_switch_entry { + struct trace_vif_entry vif; + struct trace_chandef_entry old_chandef; + struct trace_chandef_entry new_chandef; +} __attribute__((packed)); + +struct trace_event_raw_local_only_evt { + struct trace_entry ent; + char wiphy_name[32]; + char __data[0]; +}; + +struct trace_event_raw_local_sdata_addr_evt { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char addr[6]; + char __data[0]; +}; + +struct trace_event_raw_local_u32_evt { + struct trace_entry ent; + char wiphy_name[32]; + u32 value; + char __data[0]; +}; + +struct trace_event_raw_local_sdata_evt { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char __data[0]; +}; + +struct trace_event_raw_drv_return_int { + struct trace_entry ent; + char wiphy_name[32]; + int ret; + char __data[0]; +}; + +struct trace_event_raw_drv_return_bool { + struct trace_entry ent; + char wiphy_name[32]; + bool ret; + char __data[0]; +}; + +struct trace_event_raw_drv_return_u32 { + struct trace_entry ent; + char wiphy_name[32]; + u32 ret; + char __data[0]; +}; + +struct trace_event_raw_drv_return_u64 { + struct trace_entry ent; + char wiphy_name[32]; + u64 ret; + char __data[0]; +}; + +struct trace_event_raw_drv_set_wakeup { + struct trace_entry ent; + char wiphy_name[32]; + bool enabled; + char __data[0]; +}; + +struct trace_event_raw_drv_change_interface { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u32 new_type; + bool new_p2p; + char __data[0]; +}; + +struct trace_event_raw_drv_config { + struct trace_entry ent; + char wiphy_name[32]; + u32 changed; + u32 flags; + int power_level; + int dynamic_ps_timeout; + u16 listen_interval; + u8 long_frame_max_tx_count; + u8 short_frame_max_tx_count; + u32 control_freq; + u32 freq_offset; + u32 chan_width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + int smps; + char __data[0]; +}; + +struct trace_event_raw_drv_bss_info_changed { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u32 changed; + bool assoc; + bool ibss_joined; + bool ibss_creator; + u16 aid; + bool cts; + bool shortpre; + bool shortslot; + bool enable_beacon; + u8 dtimper; + u16 bcnint; + u16 assoc_cap; + u64 sync_tsf; + u32 sync_device_ts; + u8 sync_dtim_count; + u32 basic_rates; + int mcast_rate[5]; + u16 ht_operation_mode; + s32 cqm_rssi_thold; + s32 cqm_rssi_hyst; + u32 channel_width; + u32 channel_cfreq1; + u32 channel_cfreq1_offset; + u32 __data_loc_arp_addr_list; + int arp_addr_cnt; + bool qos; + bool idle; + bool ps; + u32 __data_loc_ssid; + bool hidden_ssid; + int txpower; + u8 p2p_oppps_ctwindow; + char __data[0]; +}; + +struct trace_event_raw_drv_prepare_multicast { + struct trace_entry ent; + char wiphy_name[32]; + int mc_count; + char __data[0]; +}; + +struct trace_event_raw_drv_configure_filter { + struct trace_entry ent; + char wiphy_name[32]; + unsigned int changed; + unsigned int total; + u64 multicast; + char __data[0]; +}; + +struct trace_event_raw_drv_config_iface_filter { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + unsigned int filter_flags; + unsigned int changed_flags; + char __data[0]; +}; + +struct trace_event_raw_drv_set_tim { + struct trace_entry ent; + char wiphy_name[32]; + char sta_addr[6]; + bool set; + char __data[0]; +}; + +struct trace_event_raw_drv_set_key { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char sta_addr[6]; + u32 cipher; + u8 hw_key_idx; + u8 flags; + s8 keyidx; + char __data[0]; +}; + +struct trace_event_raw_drv_update_tkip_key { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char sta_addr[6]; + u32 iv32; + char __data[0]; +}; + +struct trace_event_raw_drv_sw_scan_start { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char mac_addr[6]; + char __data[0]; +}; + +struct trace_event_raw_drv_get_stats { + struct trace_entry ent; + char wiphy_name[32]; + int ret; + unsigned int ackfail; + unsigned int rtsfail; + unsigned int fcserr; + unsigned int rtssucc; + char __data[0]; +}; + +struct trace_event_raw_drv_get_key_seq { + struct trace_entry ent; + char wiphy_name[32]; + u32 cipher; + u8 hw_key_idx; + u8 flags; + s8 keyidx; + char __data[0]; +}; + +struct trace_event_raw_drv_set_coverage_class { + struct trace_entry ent; + char wiphy_name[32]; + s16 value; + char __data[0]; +}; + +struct trace_event_raw_drv_sta_notify { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char sta_addr[6]; + u32 cmd; + char __data[0]; +}; + +struct trace_event_raw_drv_sta_state { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char sta_addr[6]; + u32 old_state; + u32 new_state; + char __data[0]; +}; + +struct trace_event_raw_drv_sta_set_txpwr { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char sta_addr[6]; + s16 txpwr; + u8 type; + char __data[0]; +}; + +struct trace_event_raw_drv_sta_rc_update { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char sta_addr[6]; + u32 changed; + char __data[0]; +}; + +struct trace_event_raw_sta_event { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char sta_addr[6]; + char __data[0]; +}; + +struct trace_event_raw_drv_conf_tx { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u16 ac; + u16 txop; + u16 cw_min; + u16 cw_max; + u8 aifs; + bool uapsd; + char __data[0]; +}; + +struct trace_event_raw_drv_set_tsf { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u64 tsf; + char __data[0]; +}; + +struct trace_event_raw_drv_offset_tsf { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + s64 tsf_offset; + char __data[0]; +}; + +struct trace_event_raw_drv_ampdu_action { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + enum ieee80211_ampdu_mlme_action ieee80211_ampdu_mlme_action; + char sta_addr[6]; + u16 tid; + u16 ssn; + u16 buf_size; + bool amsdu; + u16 timeout; + u16 action; + char __data[0]; +}; + +struct trace_event_raw_drv_get_survey { + struct trace_entry ent; + char wiphy_name[32]; + int idx; + char __data[0]; +}; + +struct trace_event_raw_drv_flush { + struct trace_entry ent; + char wiphy_name[32]; + bool drop; + u32 queues; + char __data[0]; +}; + +struct trace_event_raw_drv_channel_switch { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u32 control_freq; + u32 freq_offset; + u32 chan_width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + u64 timestamp; + u32 device_timestamp; + bool block_tx; + u8 count; + char __data[0]; +}; + +struct trace_event_raw_drv_set_antenna { + struct trace_entry ent; + char wiphy_name[32]; + u32 tx_ant; + u32 rx_ant; + int ret; + char __data[0]; +}; + +struct trace_event_raw_drv_get_antenna { + struct trace_entry ent; + char wiphy_name[32]; + u32 tx_ant; + u32 rx_ant; + int ret; + char __data[0]; +}; + +struct trace_event_raw_drv_remain_on_channel { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + int center_freq; + int freq_offset; + unsigned int duration; + u32 type; + char __data[0]; +}; + +struct trace_event_raw_drv_set_ringparam { + struct trace_entry ent; + char wiphy_name[32]; + u32 tx; + u32 rx; + char __data[0]; +}; + +struct trace_event_raw_drv_get_ringparam { + struct trace_entry ent; + char wiphy_name[32]; + u32 tx; + u32 tx_max; + u32 rx; + u32 rx_max; + char __data[0]; +}; + +struct trace_event_raw_drv_set_bitrate_mask { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u32 legacy_2g; + u32 legacy_5g; + char __data[0]; +}; + +struct trace_event_raw_drv_set_rekey_data { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u8 kek[16]; + u8 kck[16]; + u8 replay_ctr[8]; + char __data[0]; +}; + +struct trace_event_raw_drv_event_callback { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u32 type; + char __data[0]; +}; + +struct trace_event_raw_release_evt { + struct trace_entry ent; + char wiphy_name[32]; + char sta_addr[6]; + u16 tids; + int num_frames; + int reason; + bool more_data; + char __data[0]; +}; + +struct trace_event_raw_drv_mgd_prepare_tx { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u32 duration; + char __data[0]; +}; + +struct trace_event_raw_local_chanctx { + struct trace_entry ent; + char wiphy_name[32]; + u32 control_freq; + u32 freq_offset; + u32 chan_width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + u32 min_control_freq; + u32 min_freq_offset; + u32 min_chan_width; + u32 min_center_freq1; + u32 min_freq1_offset; + u32 min_center_freq2; + u8 rx_chains_static; + u8 rx_chains_dynamic; + char __data[0]; +}; + +struct trace_event_raw_drv_change_chanctx { + struct trace_entry ent; + char wiphy_name[32]; + u32 control_freq; + u32 freq_offset; + u32 chan_width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + u32 min_control_freq; + u32 min_freq_offset; + u32 min_chan_width; + u32 min_center_freq1; + u32 min_freq1_offset; + u32 min_center_freq2; + u8 rx_chains_static; + u8 rx_chains_dynamic; + u32 changed; + char __data[0]; +}; + +struct trace_event_raw_drv_switch_vif_chanctx { + struct trace_entry ent; + char wiphy_name[32]; + int n_vifs; + u32 mode; + u32 __data_loc_vifs; + char __data[0]; +}; + +struct trace_event_raw_local_sdata_chanctx { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u32 control_freq; + u32 freq_offset; + u32 chan_width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + u32 min_control_freq; + u32 min_freq_offset; + u32 min_chan_width; + u32 min_center_freq1; + u32 min_freq1_offset; + u32 min_center_freq2; + u8 rx_chains_static; + u8 rx_chains_dynamic; + char __data[0]; +}; + +struct trace_event_raw_drv_start_ap { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u8 dtimper; + u16 bcnint; + u32 __data_loc_ssid; + bool hidden_ssid; + char __data[0]; +}; + +struct trace_event_raw_drv_reconfig_complete { + struct trace_entry ent; + char wiphy_name[32]; + u8 reconfig_type; + char __data[0]; +}; + +struct trace_event_raw_drv_join_ibss { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u8 dtimper; + u16 bcnint; + u32 __data_loc_ssid; + char __data[0]; +}; + +struct trace_event_raw_drv_get_expected_throughput { + struct trace_entry ent; + char sta_addr[6]; + char __data[0]; +}; + +struct trace_event_raw_drv_start_nan { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u8 master_pref; + u8 bands; + char __data[0]; +}; + +struct trace_event_raw_drv_stop_nan { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char __data[0]; +}; + +struct trace_event_raw_drv_nan_change_conf { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u8 master_pref; + u8 bands; + u32 changes; + char __data[0]; +}; + +struct trace_event_raw_drv_add_nan_func { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u8 type; + u8 inst_id; + char __data[0]; +}; + +struct trace_event_raw_drv_del_nan_func { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u8 instance_id; + char __data[0]; +}; + +struct trace_event_raw_api_start_tx_ba_session { + struct trace_entry ent; + char sta_addr[6]; + u16 tid; + char __data[0]; +}; + +struct trace_event_raw_api_start_tx_ba_cb { + struct trace_entry ent; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u8 ra[6]; + u16 tid; + char __data[0]; +}; + +struct trace_event_raw_api_stop_tx_ba_session { + struct trace_entry ent; + char sta_addr[6]; + u16 tid; + char __data[0]; +}; + +struct trace_event_raw_api_stop_tx_ba_cb { + struct trace_entry ent; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u8 ra[6]; + u16 tid; + char __data[0]; +}; + +struct trace_event_raw_api_beacon_loss { + struct trace_entry ent; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char __data[0]; +}; + +struct trace_event_raw_api_connection_loss { + struct trace_entry ent; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char __data[0]; +}; + +struct trace_event_raw_api_cqm_rssi_notify { + struct trace_entry ent; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u32 rssi_event; + s32 rssi_level; + char __data[0]; +}; + +struct trace_event_raw_api_scan_completed { + struct trace_entry ent; + char wiphy_name[32]; + bool aborted; + char __data[0]; +}; + +struct trace_event_raw_api_sched_scan_results { + struct trace_entry ent; + char wiphy_name[32]; + char __data[0]; +}; + +struct trace_event_raw_api_sched_scan_stopped { + struct trace_entry ent; + char wiphy_name[32]; + char __data[0]; +}; + +struct trace_event_raw_api_sta_block_awake { + struct trace_entry ent; + char wiphy_name[32]; + char sta_addr[6]; + bool block; + char __data[0]; +}; + +struct trace_event_raw_api_chswitch_done { + struct trace_entry ent; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + bool success; + char __data[0]; +}; + +struct trace_event_raw_api_gtk_rekey_notify { + struct trace_entry ent; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u8 bssid[6]; + u8 replay_ctr[8]; + char __data[0]; +}; + +struct trace_event_raw_api_enable_rssi_reports { + struct trace_entry ent; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + int rssi_min_thold; + int rssi_max_thold; + char __data[0]; +}; + +struct trace_event_raw_api_eosp { + struct trace_entry ent; + char wiphy_name[32]; + char sta_addr[6]; + char __data[0]; +}; + +struct trace_event_raw_api_send_eosp_nullfunc { + struct trace_entry ent; + char wiphy_name[32]; + char sta_addr[6]; + u8 tid; + char __data[0]; +}; + +struct trace_event_raw_api_sta_set_buffered { + struct trace_entry ent; + char wiphy_name[32]; + char sta_addr[6]; + u8 tid; + bool buffered; + char __data[0]; +}; + +struct trace_event_raw_wake_queue { + struct trace_entry ent; + char wiphy_name[32]; + u16 queue; + u32 reason; + char __data[0]; +}; + +struct trace_event_raw_stop_queue { + struct trace_entry ent; + char wiphy_name[32]; + u16 queue; + u32 reason; + char __data[0]; +}; + +struct trace_event_raw_drv_set_default_unicast_key { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + int key_idx; + char __data[0]; +}; + +struct trace_event_raw_api_radar_detected { + struct trace_entry ent; + char wiphy_name[32]; + char __data[0]; +}; + +struct trace_event_raw_drv_channel_switch_beacon { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u32 control_freq; + u32 freq_offset; + u32 chan_width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + char __data[0]; +}; + +struct trace_event_raw_drv_pre_channel_switch { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u32 control_freq; + u32 freq_offset; + u32 chan_width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + u64 timestamp; + u32 device_timestamp; + bool block_tx; + u8 count; + char __data[0]; +}; + +struct trace_event_raw_drv_channel_switch_rx_beacon { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u32 control_freq; + u32 freq_offset; + u32 chan_width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + u64 timestamp; + u32 device_timestamp; + bool block_tx; + u8 count; + char __data[0]; +}; + +struct trace_event_raw_drv_get_txpower { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + int dbm; + int ret; + char __data[0]; +}; + +struct trace_event_raw_drv_tdls_channel_switch { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char sta_addr[6]; + u8 oper_class; + u32 control_freq; + u32 freq_offset; + u32 chan_width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + char __data[0]; +}; + +struct trace_event_raw_drv_tdls_cancel_channel_switch { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char sta_addr[6]; + char __data[0]; +}; + +struct trace_event_raw_drv_tdls_recv_channel_switch { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + u8 action_code; + char sta_addr[6]; + u32 control_freq; + u32 freq_offset; + u32 chan_width; + u32 center_freq1; + u32 freq1_offset; + u32 center_freq2; + u32 status; + bool peer_initiator; + u32 timestamp; + u16 switch_time; + u16 switch_timeout; + char __data[0]; +}; + +struct trace_event_raw_drv_wake_tx_queue { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char sta_addr[6]; + u8 ac; + u8 tid; + char __data[0]; +}; + +struct trace_event_raw_drv_get_ftm_responder_stats { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char __data[0]; +}; + +struct trace_event_raw_drv_sta_set_4addr { + struct trace_entry ent; + char wiphy_name[32]; + enum nl80211_iftype vif_type; + void *sdata; + bool p2p; + u32 __data_loc_vif_name; + char sta_addr[6]; + bool enabled; + char __data[0]; +}; + +struct trace_event_data_offsets_local_only_evt {}; + +struct trace_event_data_offsets_local_sdata_addr_evt { + u32 vif_name; +}; + +struct trace_event_data_offsets_local_u32_evt {}; + +struct trace_event_data_offsets_local_sdata_evt { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_return_int {}; + +struct trace_event_data_offsets_drv_return_bool {}; + +struct trace_event_data_offsets_drv_return_u32 {}; + +struct trace_event_data_offsets_drv_return_u64 {}; + +struct trace_event_data_offsets_drv_set_wakeup {}; + +struct trace_event_data_offsets_drv_change_interface { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_config {}; + +struct trace_event_data_offsets_drv_bss_info_changed { + u32 vif_name; + u32 arp_addr_list; + u32 ssid; +}; + +struct trace_event_data_offsets_drv_prepare_multicast {}; + +struct trace_event_data_offsets_drv_configure_filter {}; + +struct trace_event_data_offsets_drv_config_iface_filter { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_set_tim {}; + +struct trace_event_data_offsets_drv_set_key { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_update_tkip_key { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_sw_scan_start { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_get_stats {}; + +struct trace_event_data_offsets_drv_get_key_seq {}; + +struct trace_event_data_offsets_drv_set_coverage_class {}; + +struct trace_event_data_offsets_drv_sta_notify { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_sta_state { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_sta_set_txpwr { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_sta_rc_update { + u32 vif_name; +}; + +struct trace_event_data_offsets_sta_event { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_conf_tx { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_set_tsf { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_offset_tsf { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_ampdu_action { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_get_survey {}; + +struct trace_event_data_offsets_drv_flush {}; + +struct trace_event_data_offsets_drv_channel_switch { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_set_antenna {}; + +struct trace_event_data_offsets_drv_get_antenna {}; + +struct trace_event_data_offsets_drv_remain_on_channel { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_set_ringparam {}; + +struct trace_event_data_offsets_drv_get_ringparam {}; + +struct trace_event_data_offsets_drv_set_bitrate_mask { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_set_rekey_data { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_event_callback { + u32 vif_name; +}; + +struct trace_event_data_offsets_release_evt {}; + +struct trace_event_data_offsets_drv_mgd_prepare_tx { + u32 vif_name; +}; + +struct trace_event_data_offsets_local_chanctx {}; + +struct trace_event_data_offsets_drv_change_chanctx {}; + +struct trace_event_data_offsets_drv_switch_vif_chanctx { + u32 vifs; +}; + +struct trace_event_data_offsets_local_sdata_chanctx { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_start_ap { + u32 vif_name; + u32 ssid; +}; + +struct trace_event_data_offsets_drv_reconfig_complete {}; + +struct trace_event_data_offsets_drv_join_ibss { + u32 vif_name; + u32 ssid; +}; + +struct trace_event_data_offsets_drv_get_expected_throughput {}; + +struct trace_event_data_offsets_drv_start_nan { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_stop_nan { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_nan_change_conf { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_add_nan_func { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_del_nan_func { + u32 vif_name; +}; + +struct trace_event_data_offsets_api_start_tx_ba_session {}; + +struct trace_event_data_offsets_api_start_tx_ba_cb { + u32 vif_name; +}; + +struct trace_event_data_offsets_api_stop_tx_ba_session {}; + +struct trace_event_data_offsets_api_stop_tx_ba_cb { + u32 vif_name; +}; + +struct trace_event_data_offsets_api_beacon_loss { + u32 vif_name; +}; + +struct trace_event_data_offsets_api_connection_loss { + u32 vif_name; +}; + +struct trace_event_data_offsets_api_cqm_rssi_notify { + u32 vif_name; +}; + +struct trace_event_data_offsets_api_scan_completed {}; + +struct trace_event_data_offsets_api_sched_scan_results {}; + +struct trace_event_data_offsets_api_sched_scan_stopped {}; + +struct trace_event_data_offsets_api_sta_block_awake {}; + +struct trace_event_data_offsets_api_chswitch_done { + u32 vif_name; +}; + +struct trace_event_data_offsets_api_gtk_rekey_notify { + u32 vif_name; +}; + +struct trace_event_data_offsets_api_enable_rssi_reports { + u32 vif_name; +}; + +struct trace_event_data_offsets_api_eosp {}; + +struct trace_event_data_offsets_api_send_eosp_nullfunc {}; + +struct trace_event_data_offsets_api_sta_set_buffered {}; + +struct trace_event_data_offsets_wake_queue {}; + +struct trace_event_data_offsets_stop_queue {}; + +struct trace_event_data_offsets_drv_set_default_unicast_key { + u32 vif_name; +}; + +struct trace_event_data_offsets_api_radar_detected {}; + +struct trace_event_data_offsets_drv_channel_switch_beacon { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_pre_channel_switch { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_channel_switch_rx_beacon { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_get_txpower { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_tdls_channel_switch { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_tdls_cancel_channel_switch { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_tdls_recv_channel_switch { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_wake_tx_queue { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_get_ftm_responder_stats { + u32 vif_name; +}; + +struct trace_event_data_offsets_drv_sta_set_4addr { + u32 vif_name; +}; + +typedef void (*btf_trace_drv_return_void)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_drv_return_int)(void *, struct ieee80211_local *, int); + +typedef void (*btf_trace_drv_return_bool)(void *, struct ieee80211_local *, bool); + +typedef void (*btf_trace_drv_return_u32)(void *, struct ieee80211_local *, u32); + +typedef void (*btf_trace_drv_return_u64)(void *, struct ieee80211_local *, u64); + +typedef void (*btf_trace_drv_start)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_drv_get_et_strings)(void *, struct ieee80211_local *, u32); + +typedef void (*btf_trace_drv_get_et_sset_count)(void *, struct ieee80211_local *, u32); + +typedef void (*btf_trace_drv_get_et_stats)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_drv_suspend)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_drv_resume)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_drv_set_wakeup)(void *, struct ieee80211_local *, bool); + +typedef void (*btf_trace_drv_stop)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_drv_add_interface)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_change_interface)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, enum nl80211_iftype, bool); + +typedef void (*btf_trace_drv_remove_interface)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_config)(void *, struct ieee80211_local *, u32); + +typedef void (*btf_trace_drv_bss_info_changed)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_bss_conf *, u32); + +typedef void (*btf_trace_drv_prepare_multicast)(void *, struct ieee80211_local *, int); + +typedef void (*btf_trace_drv_configure_filter)(void *, struct ieee80211_local *, unsigned int, unsigned int *, u64); + +typedef void (*btf_trace_drv_config_iface_filter)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, unsigned int, unsigned int); + +typedef void (*btf_trace_drv_set_tim)(void *, struct ieee80211_local *, struct ieee80211_sta *, bool); + +typedef void (*btf_trace_drv_set_key)(void *, struct ieee80211_local *, enum set_key_cmd, struct ieee80211_sub_if_data *, struct ieee80211_sta *, struct ieee80211_key_conf *); + +typedef void (*btf_trace_drv_update_tkip_key)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_key_conf *, struct ieee80211_sta *, u32); + +typedef void (*btf_trace_drv_hw_scan)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_cancel_hw_scan)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_sched_scan_start)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_sched_scan_stop)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_sw_scan_start)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, const u8 *); + +typedef void (*btf_trace_drv_sw_scan_complete)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_get_stats)(void *, struct ieee80211_local *, struct ieee80211_low_level_stats *, int); + +typedef void (*btf_trace_drv_get_key_seq)(void *, struct ieee80211_local *, struct ieee80211_key_conf *); + +typedef void (*btf_trace_drv_set_frag_threshold)(void *, struct ieee80211_local *, u32); + +typedef void (*btf_trace_drv_set_rts_threshold)(void *, struct ieee80211_local *, u32); + +typedef void (*btf_trace_drv_set_coverage_class)(void *, struct ieee80211_local *, s16); + +typedef void (*btf_trace_drv_sta_notify)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, enum sta_notify_cmd, struct ieee80211_sta *); + +typedef void (*btf_trace_drv_sta_state)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *, enum ieee80211_sta_state, enum ieee80211_sta_state); + +typedef void (*btf_trace_drv_sta_set_txpwr)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *); + +typedef void (*btf_trace_drv_sta_rc_update)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *, u32); + +typedef void (*btf_trace_drv_sta_statistics)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *); + +typedef void (*btf_trace_drv_sta_add)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *); + +typedef void (*btf_trace_drv_sta_remove)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *); + +typedef void (*btf_trace_drv_sta_pre_rcu_remove)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *); + +typedef void (*btf_trace_drv_sync_rx_queues)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *); + +typedef void (*btf_trace_drv_sta_rate_tbl_update)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *); + +typedef void (*btf_trace_drv_conf_tx)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, u16, const struct ieee80211_tx_queue_params *); + +typedef void (*btf_trace_drv_get_tsf)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_set_tsf)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, u64); + +typedef void (*btf_trace_drv_offset_tsf)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, s64); + +typedef void (*btf_trace_drv_reset_tsf)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_tx_last_beacon)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_drv_ampdu_action)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_ampdu_params *); + +typedef void (*btf_trace_drv_get_survey)(void *, struct ieee80211_local *, int, struct survey_info *); + +typedef void (*btf_trace_drv_flush)(void *, struct ieee80211_local *, u32, bool); + +typedef void (*btf_trace_drv_channel_switch)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_channel_switch *); + +typedef void (*btf_trace_drv_set_antenna)(void *, struct ieee80211_local *, u32, u32, int); + +typedef void (*btf_trace_drv_get_antenna)(void *, struct ieee80211_local *, u32, u32, int); + +typedef void (*btf_trace_drv_remain_on_channel)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_channel *, unsigned int, enum ieee80211_roc_type); + +typedef void (*btf_trace_drv_cancel_remain_on_channel)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_set_ringparam)(void *, struct ieee80211_local *, u32, u32); + +typedef void (*btf_trace_drv_get_ringparam)(void *, struct ieee80211_local *, u32 *, u32 *, u32 *, u32 *); + +typedef void (*btf_trace_drv_tx_frames_pending)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_drv_offchannel_tx_cancel_wait)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_drv_set_bitrate_mask)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, const struct cfg80211_bitrate_mask *); + +typedef void (*btf_trace_drv_set_rekey_data)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct cfg80211_gtk_rekey_data *); + +typedef void (*btf_trace_drv_event_callback)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, const struct ieee80211_event *); + +typedef void (*btf_trace_drv_release_buffered_frames)(void *, struct ieee80211_local *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool); + +typedef void (*btf_trace_drv_allow_buffered_frames)(void *, struct ieee80211_local *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool); + +typedef void (*btf_trace_drv_mgd_prepare_tx)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, u16); + +typedef void (*btf_trace_drv_mgd_protect_tdls_discover)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_add_chanctx)(void *, struct ieee80211_local *, struct ieee80211_chanctx *); + +typedef void (*btf_trace_drv_remove_chanctx)(void *, struct ieee80211_local *, struct ieee80211_chanctx *); + +typedef void (*btf_trace_drv_change_chanctx)(void *, struct ieee80211_local *, struct ieee80211_chanctx *, u32); + +typedef void (*btf_trace_drv_switch_vif_chanctx)(void *, struct ieee80211_local *, struct ieee80211_vif_chanctx_switch *, int, enum ieee80211_chanctx_switch_mode); + +typedef void (*btf_trace_drv_assign_vif_chanctx)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_chanctx *); + +typedef void (*btf_trace_drv_unassign_vif_chanctx)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_chanctx *); + +typedef void (*btf_trace_drv_start_ap)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_bss_conf *); + +typedef void (*btf_trace_drv_stop_ap)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_reconfig_complete)(void *, struct ieee80211_local *, enum ieee80211_reconfig_type); + +typedef void (*btf_trace_drv_ipv6_addr_change)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_join_ibss)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_bss_conf *); + +typedef void (*btf_trace_drv_leave_ibss)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_get_expected_throughput)(void *, struct ieee80211_sta *); + +typedef void (*btf_trace_drv_start_nan)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct cfg80211_nan_conf *); + +typedef void (*btf_trace_drv_stop_nan)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_nan_change_conf)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct cfg80211_nan_conf *, u32); + +typedef void (*btf_trace_drv_add_nan_func)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, const struct cfg80211_nan_func *); + +typedef void (*btf_trace_drv_del_nan_func)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, u8); + +typedef void (*btf_trace_drv_start_pmsr)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_abort_pmsr)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_api_start_tx_ba_session)(void *, struct ieee80211_sta *, u16); + +typedef void (*btf_trace_api_start_tx_ba_cb)(void *, struct ieee80211_sub_if_data *, const u8 *, u16); + +typedef void (*btf_trace_api_stop_tx_ba_session)(void *, struct ieee80211_sta *, u16); + +typedef void (*btf_trace_api_stop_tx_ba_cb)(void *, struct ieee80211_sub_if_data *, const u8 *, u16); + +typedef void (*btf_trace_api_restart_hw)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_api_beacon_loss)(void *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_api_connection_loss)(void *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_api_cqm_rssi_notify)(void *, struct ieee80211_sub_if_data *, enum nl80211_cqm_rssi_threshold_event, s32); + +typedef void (*btf_trace_api_cqm_beacon_loss_notify)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_api_scan_completed)(void *, struct ieee80211_local *, bool); + +typedef void (*btf_trace_api_sched_scan_results)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_api_sched_scan_stopped)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_api_sta_block_awake)(void *, struct ieee80211_local *, struct ieee80211_sta *, bool); + +typedef void (*btf_trace_api_chswitch_done)(void *, struct ieee80211_sub_if_data *, bool); + +typedef void (*btf_trace_api_ready_on_channel)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_api_remain_on_channel_expired)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_api_gtk_rekey_notify)(void *, struct ieee80211_sub_if_data *, const u8 *, const u8 *); + +typedef void (*btf_trace_api_enable_rssi_reports)(void *, struct ieee80211_sub_if_data *, int, int); + +typedef void (*btf_trace_api_eosp)(void *, struct ieee80211_local *, struct ieee80211_sta *); + +typedef void (*btf_trace_api_send_eosp_nullfunc)(void *, struct ieee80211_local *, struct ieee80211_sta *, u8); + +typedef void (*btf_trace_api_sta_set_buffered)(void *, struct ieee80211_local *, struct ieee80211_sta *, u8, bool); + +typedef void (*btf_trace_wake_queue)(void *, struct ieee80211_local *, u16, enum queue_stop_reason); + +typedef void (*btf_trace_stop_queue)(void *, struct ieee80211_local *, u16, enum queue_stop_reason); + +typedef void (*btf_trace_drv_set_default_unicast_key)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, int); + +typedef void (*btf_trace_api_radar_detected)(void *, struct ieee80211_local *); + +typedef void (*btf_trace_drv_channel_switch_beacon)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct cfg80211_chan_def *); + +typedef void (*btf_trace_drv_pre_channel_switch)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_channel_switch *); + +typedef void (*btf_trace_drv_post_channel_switch)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_abort_channel_switch)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_channel_switch_rx_beacon)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_channel_switch *); + +typedef void (*btf_trace_drv_get_txpower)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, int, int); + +typedef void (*btf_trace_drv_tdls_channel_switch)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *, u8, struct cfg80211_chan_def *); + +typedef void (*btf_trace_drv_tdls_cancel_channel_switch)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *); + +typedef void (*btf_trace_drv_tdls_recv_channel_switch)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_tdls_ch_sw_params *); + +typedef void (*btf_trace_drv_wake_tx_queue)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct txq_info *); + +typedef void (*btf_trace_drv_get_ftm_responder_stats)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct cfg80211_ftm_responder_stats *); + +typedef void (*btf_trace_drv_update_vif_offload)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *); + +typedef void (*btf_trace_drv_sta_set_4addr)(void *, struct ieee80211_local *, struct ieee80211_sub_if_data *, struct ieee80211_sta *, bool); + +struct ieee80211_country_ie_triplet { + union { + struct { + u8 first_channel; + u8 num_channels; + s8 max_power; + } chans; + struct { + u8 reg_extension_id; + u8 reg_class; + u8 coverage_class; + } ext; + }; +}; + +enum ieee80211_timeout_interval_type { + WLAN_TIMEOUT_REASSOC_DEADLINE = 1, + WLAN_TIMEOUT_KEY_LIFETIME = 2, + WLAN_TIMEOUT_ASSOC_COMEBACK = 3, +}; + +enum ieee80211_idle_options { + WLAN_IDLE_OPTIONS_PROTECTED_KEEP_ALIVE = 1, +}; + +struct ieee80211_wmm_ac_param { + u8 aci_aifsn; + u8 cw; + __le16 txop_limit; +}; + +struct ieee80211_wmm_param_ie { + u8 element_id; + u8 len; + u8 oui[3]; + u8 oui_type; + u8 oui_subtype; + u8 version; + u8 qos_info; + u8 reserved; + struct ieee80211_wmm_ac_param ac[4]; +}; + +enum ocb_deferred_task_flags { + OCB_WORK_HOUSEKEEPING = 0, +}; + +struct mcs_group { + u8 shift; + u16 duration[12]; +}; + +struct netlbl_af4list { + __be32 addr; + __be32 mask; + u32 valid; + struct list_head list; +}; + +struct netlbl_af6list { + struct in6_addr addr; + struct in6_addr mask; + u32 valid; + struct list_head list; +}; + +struct netlbl_domaddr_map { + struct list_head list4; + struct list_head list6; +}; + +struct netlbl_dommap_def { + u32 type; + union { + struct netlbl_domaddr_map *addrsel; + struct cipso_v4_doi *cipso; + struct calipso_doi *calipso; + }; +}; + +struct netlbl_domaddr4_map { + struct netlbl_dommap_def def; + struct netlbl_af4list list; +}; + +struct netlbl_domaddr6_map { + struct netlbl_dommap_def def; + struct netlbl_af6list list; +}; + +struct netlbl_dom_map { + char *domain; + u16 family; + struct netlbl_dommap_def def; + u32 valid; + struct list_head list; + struct callback_head rcu; +}; + +struct netlbl_domhsh_tbl { + struct list_head *tbl; + u32 size; +}; + +enum { + NLBL_MGMT_C_UNSPEC = 0, + NLBL_MGMT_C_ADD = 1, + NLBL_MGMT_C_REMOVE = 2, + NLBL_MGMT_C_LISTALL = 3, + NLBL_MGMT_C_ADDDEF = 4, + NLBL_MGMT_C_REMOVEDEF = 5, + NLBL_MGMT_C_LISTDEF = 6, + NLBL_MGMT_C_PROTOCOLS = 7, + NLBL_MGMT_C_VERSION = 8, + __NLBL_MGMT_C_MAX = 9, +}; + +enum { + NLBL_MGMT_A_UNSPEC = 0, + NLBL_MGMT_A_DOMAIN = 1, + NLBL_MGMT_A_PROTOCOL = 2, + NLBL_MGMT_A_VERSION = 3, + NLBL_MGMT_A_CV4DOI = 4, + NLBL_MGMT_A_IPV6ADDR = 5, + NLBL_MGMT_A_IPV6MASK = 6, + NLBL_MGMT_A_IPV4ADDR = 7, + NLBL_MGMT_A_IPV4MASK = 8, + NLBL_MGMT_A_ADDRSELECTOR = 9, + NLBL_MGMT_A_SELECTORLIST = 10, + NLBL_MGMT_A_FAMILY = 11, + NLBL_MGMT_A_CLPDOI = 12, + __NLBL_MGMT_A_MAX = 13, +}; + +struct netlbl_domhsh_walk_arg { + struct netlink_callback *nl_cb; + struct sk_buff *skb; + u32 seq; +}; + +enum { + NLBL_UNLABEL_C_UNSPEC = 0, + NLBL_UNLABEL_C_ACCEPT = 1, + NLBL_UNLABEL_C_LIST = 2, + NLBL_UNLABEL_C_STATICADD = 3, + NLBL_UNLABEL_C_STATICREMOVE = 4, + NLBL_UNLABEL_C_STATICLIST = 5, + NLBL_UNLABEL_C_STATICADDDEF = 6, + NLBL_UNLABEL_C_STATICREMOVEDEF = 7, + NLBL_UNLABEL_C_STATICLISTDEF = 8, + __NLBL_UNLABEL_C_MAX = 9, +}; + +enum { + NLBL_UNLABEL_A_UNSPEC = 0, + NLBL_UNLABEL_A_ACPTFLG = 1, + NLBL_UNLABEL_A_IPV6ADDR = 2, + NLBL_UNLABEL_A_IPV6MASK = 3, + NLBL_UNLABEL_A_IPV4ADDR = 4, + NLBL_UNLABEL_A_IPV4MASK = 5, + NLBL_UNLABEL_A_IFACE = 6, + NLBL_UNLABEL_A_SECCTX = 7, + __NLBL_UNLABEL_A_MAX = 8, +}; + +struct netlbl_unlhsh_tbl { + struct list_head *tbl; + u32 size; +}; + +struct netlbl_unlhsh_addr4 { + u32 secid; + struct netlbl_af4list list; + struct callback_head rcu; +}; + +struct netlbl_unlhsh_addr6 { + u32 secid; + struct netlbl_af6list list; + struct callback_head rcu; +}; + +struct netlbl_unlhsh_iface { + int ifindex; + struct list_head addr4_list; + struct list_head addr6_list; + u32 valid; + struct list_head list; + struct callback_head rcu; +}; + +struct netlbl_unlhsh_walk_arg { + struct netlink_callback *nl_cb; + struct sk_buff *skb; + u32 seq; +}; + +enum { + NLBL_CIPSOV4_C_UNSPEC = 0, + NLBL_CIPSOV4_C_ADD = 1, + NLBL_CIPSOV4_C_REMOVE = 2, + NLBL_CIPSOV4_C_LIST = 3, + NLBL_CIPSOV4_C_LISTALL = 4, + __NLBL_CIPSOV4_C_MAX = 5, +}; + +enum { + NLBL_CIPSOV4_A_UNSPEC = 0, + NLBL_CIPSOV4_A_DOI = 1, + NLBL_CIPSOV4_A_MTYPE = 2, + NLBL_CIPSOV4_A_TAG = 3, + NLBL_CIPSOV4_A_TAGLST = 4, + NLBL_CIPSOV4_A_MLSLVLLOC = 5, + NLBL_CIPSOV4_A_MLSLVLREM = 6, + NLBL_CIPSOV4_A_MLSLVL = 7, + NLBL_CIPSOV4_A_MLSLVLLST = 8, + NLBL_CIPSOV4_A_MLSCATLOC = 9, + NLBL_CIPSOV4_A_MLSCATREM = 10, + NLBL_CIPSOV4_A_MLSCAT = 11, + NLBL_CIPSOV4_A_MLSCATLST = 12, + __NLBL_CIPSOV4_A_MAX = 13, +}; + +struct netlbl_cipsov4_doiwalk_arg { + struct netlink_callback *nl_cb; + struct sk_buff *skb; + u32 seq; +}; + +struct netlbl_domhsh_walk_arg___2 { + struct netlbl_audit *audit_info; + u32 doi; +}; + +enum { + NLBL_CALIPSO_C_UNSPEC = 0, + NLBL_CALIPSO_C_ADD = 1, + NLBL_CALIPSO_C_REMOVE = 2, + NLBL_CALIPSO_C_LIST = 3, + NLBL_CALIPSO_C_LISTALL = 4, + __NLBL_CALIPSO_C_MAX = 5, +}; + +enum { + NLBL_CALIPSO_A_UNSPEC = 0, + NLBL_CALIPSO_A_DOI = 1, + NLBL_CALIPSO_A_MTYPE = 2, + __NLBL_CALIPSO_A_MAX = 3, +}; + +struct netlbl_calipso_doiwalk_arg { + struct netlink_callback *nl_cb; + struct sk_buff *skb; + u32 seq; +}; + +enum p9_msg_t { + P9_TLERROR = 6, + P9_RLERROR = 7, + P9_TSTATFS = 8, + P9_RSTATFS = 9, + P9_TLOPEN = 12, + P9_RLOPEN = 13, + P9_TLCREATE = 14, + P9_RLCREATE = 15, + P9_TSYMLINK = 16, + P9_RSYMLINK = 17, + P9_TMKNOD = 18, + P9_RMKNOD = 19, + P9_TRENAME = 20, + P9_RRENAME = 21, + P9_TREADLINK = 22, + P9_RREADLINK = 23, + P9_TGETATTR = 24, + P9_RGETATTR = 25, + P9_TSETATTR = 26, + P9_RSETATTR = 27, + P9_TXATTRWALK = 30, + P9_RXATTRWALK = 31, + P9_TXATTRCREATE = 32, + P9_RXATTRCREATE = 33, + P9_TREADDIR = 40, + P9_RREADDIR = 41, + P9_TFSYNC = 50, + P9_RFSYNC = 51, + P9_TLOCK = 52, + P9_RLOCK = 53, + P9_TGETLOCK = 54, + P9_RGETLOCK = 55, + P9_TLINK = 70, + P9_RLINK = 71, + P9_TMKDIR = 72, + P9_RMKDIR = 73, + P9_TRENAMEAT = 74, + P9_RRENAMEAT = 75, + P9_TUNLINKAT = 76, + P9_RUNLINKAT = 77, + P9_TVERSION = 100, + P9_RVERSION = 101, + P9_TAUTH = 102, + P9_RAUTH = 103, + P9_TATTACH = 104, + P9_RATTACH = 105, + P9_TERROR = 106, + P9_RERROR = 107, + P9_TFLUSH = 108, + P9_RFLUSH = 109, + P9_TWALK = 110, + P9_RWALK = 111, + P9_TOPEN = 112, + P9_ROPEN = 113, + P9_TCREATE = 114, + P9_RCREATE = 115, + P9_TREAD = 116, + P9_RREAD = 117, + P9_TWRITE = 118, + P9_RWRITE = 119, + P9_TCLUNK = 120, + P9_RCLUNK = 121, + P9_TREMOVE = 122, + P9_RREMOVE = 123, + P9_TSTAT = 124, + P9_RSTAT = 125, + P9_TWSTAT = 126, + P9_RWSTAT = 127, +}; + +enum p9_proto_versions { + p9_proto_legacy = 0, + p9_proto_2000u = 1, + p9_proto_2000L = 2, +}; + +enum p9_req_status_t { + REQ_STATUS_ALLOC = 0, + REQ_STATUS_UNSENT = 1, + REQ_STATUS_SENT = 2, + REQ_STATUS_RCVD = 3, + REQ_STATUS_FLSHD = 4, + REQ_STATUS_ERROR = 5, +}; + +struct trace_event_raw_9p_client_req { + struct trace_entry ent; + void *clnt; + __u8 type; + __u32 tag; + char __data[0]; +}; + +struct trace_event_raw_9p_client_res { + struct trace_entry ent; + void *clnt; + __u8 type; + __u32 tag; + __u32 err; + char __data[0]; +}; + +struct trace_event_raw_9p_protocol_dump { + struct trace_entry ent; + void *clnt; + __u8 type; + __u16 tag; + unsigned char line[32]; + char __data[0]; +}; + +struct trace_event_data_offsets_9p_client_req {}; + +struct trace_event_data_offsets_9p_client_res {}; + +struct trace_event_data_offsets_9p_protocol_dump {}; + +typedef void (*btf_trace_9p_client_req)(void *, struct p9_client *, int8_t, int); + +typedef void (*btf_trace_9p_client_res)(void *, struct p9_client *, int8_t, int, int); + +typedef void (*btf_trace_9p_protocol_dump)(void *, struct p9_client *, struct p9_fcall *); + +enum { + Opt_msize = 0, + Opt_trans = 1, + Opt_legacy = 2, + Opt_version = 3, + Opt_err___10 = 4, +}; + +struct errormap { + char *name; + int val; + int namelen; + struct hlist_node list; +}; + +struct p9_fd_opts { + int rfd; + int wfd; + u16 port; + bool privport; +}; + +enum { + Opt_port___2 = 0, + Opt_rfdno = 1, + Opt_wfdno = 2, + Opt_err___11 = 3, + Opt_privport = 4, +}; + +enum { + Rworksched = 1, + Rpending = 2, + Wworksched = 4, + Wpending = 8, +}; + +struct p9_conn; + +struct p9_poll_wait { + struct p9_conn *conn; + wait_queue_entry_t wait; + wait_queue_head_t *wait_addr; +}; + +struct p9_conn { + struct list_head mux_list; + struct p9_client *client; + int err; + struct list_head req_list; + struct list_head unsent_req_list; + struct p9_req_t *rreq; + struct p9_req_t *wreq; + char tmp_buf[7]; + struct p9_fcall rc; + int wpos; + int wsize; + char *wbuf; + struct list_head poll_pending_link; + struct p9_poll_wait poll_wait[2]; + poll_table pt; + struct work_struct rq; + struct work_struct wq; + long unsigned int wsched; +}; + +struct p9_trans_fd { + struct file *rd; + struct file *wr; + struct p9_conn conn; +}; + +struct virtio_9p_config { + __virtio16 tag_len; + __u8 tag[0]; +}; + +struct virtio_chan { + bool inuse; + spinlock_t lock; + struct p9_client *client; + struct virtio_device *vdev; + struct virtqueue *vq; + int ring_bufs_avail; + wait_queue_head_t *vc_wq; + long unsigned int p9_max_pages; + struct scatterlist sg[128]; + char *tag; + struct list_head chan_list; +}; + +struct dcbmsg { + __u8 dcb_family; + __u8 cmd; + __u16 dcb_pad; +}; + +enum dcbnl_commands { + DCB_CMD_UNDEFINED = 0, + DCB_CMD_GSTATE = 1, + DCB_CMD_SSTATE = 2, + DCB_CMD_PGTX_GCFG = 3, + DCB_CMD_PGTX_SCFG = 4, + DCB_CMD_PGRX_GCFG = 5, + DCB_CMD_PGRX_SCFG = 6, + DCB_CMD_PFC_GCFG = 7, + DCB_CMD_PFC_SCFG = 8, + DCB_CMD_SET_ALL = 9, + DCB_CMD_GPERM_HWADDR = 10, + DCB_CMD_GCAP = 11, + DCB_CMD_GNUMTCS = 12, + DCB_CMD_SNUMTCS = 13, + DCB_CMD_PFC_GSTATE = 14, + DCB_CMD_PFC_SSTATE = 15, + DCB_CMD_BCN_GCFG = 16, + DCB_CMD_BCN_SCFG = 17, + DCB_CMD_GAPP = 18, + DCB_CMD_SAPP = 19, + DCB_CMD_IEEE_SET = 20, + DCB_CMD_IEEE_GET = 21, + DCB_CMD_GDCBX = 22, + DCB_CMD_SDCBX = 23, + DCB_CMD_GFEATCFG = 24, + DCB_CMD_SFEATCFG = 25, + DCB_CMD_CEE_GET = 26, + DCB_CMD_IEEE_DEL = 27, + __DCB_CMD_ENUM_MAX = 28, + DCB_CMD_MAX = 27, +}; + +enum dcbnl_attrs { + DCB_ATTR_UNDEFINED = 0, + DCB_ATTR_IFNAME = 1, + DCB_ATTR_STATE = 2, + DCB_ATTR_PFC_STATE = 3, + DCB_ATTR_PFC_CFG = 4, + DCB_ATTR_NUM_TC = 5, + DCB_ATTR_PG_CFG = 6, + DCB_ATTR_SET_ALL = 7, + DCB_ATTR_PERM_HWADDR = 8, + DCB_ATTR_CAP = 9, + DCB_ATTR_NUMTCS = 10, + DCB_ATTR_BCN = 11, + DCB_ATTR_APP = 12, + DCB_ATTR_IEEE = 13, + DCB_ATTR_DCBX = 14, + DCB_ATTR_FEATCFG = 15, + DCB_ATTR_CEE = 16, + __DCB_ATTR_ENUM_MAX = 17, + DCB_ATTR_MAX = 16, +}; + +enum ieee_attrs { + DCB_ATTR_IEEE_UNSPEC = 0, + DCB_ATTR_IEEE_ETS = 1, + DCB_ATTR_IEEE_PFC = 2, + DCB_ATTR_IEEE_APP_TABLE = 3, + DCB_ATTR_IEEE_PEER_ETS = 4, + DCB_ATTR_IEEE_PEER_PFC = 5, + DCB_ATTR_IEEE_PEER_APP = 6, + DCB_ATTR_IEEE_MAXRATE = 7, + DCB_ATTR_IEEE_QCN = 8, + DCB_ATTR_IEEE_QCN_STATS = 9, + DCB_ATTR_DCB_BUFFER = 10, + __DCB_ATTR_IEEE_MAX = 11, +}; + +enum ieee_attrs_app { + DCB_ATTR_IEEE_APP_UNSPEC = 0, + DCB_ATTR_IEEE_APP = 1, + __DCB_ATTR_IEEE_APP_MAX = 2, +}; + +enum cee_attrs { + DCB_ATTR_CEE_UNSPEC = 0, + DCB_ATTR_CEE_PEER_PG = 1, + DCB_ATTR_CEE_PEER_PFC = 2, + DCB_ATTR_CEE_PEER_APP_TABLE = 3, + DCB_ATTR_CEE_TX_PG = 4, + DCB_ATTR_CEE_RX_PG = 5, + DCB_ATTR_CEE_PFC = 6, + DCB_ATTR_CEE_APP_TABLE = 7, + DCB_ATTR_CEE_FEAT = 8, + __DCB_ATTR_CEE_MAX = 9, +}; + +enum peer_app_attr { + DCB_ATTR_CEE_PEER_APP_UNSPEC = 0, + DCB_ATTR_CEE_PEER_APP_INFO = 1, + DCB_ATTR_CEE_PEER_APP = 2, + __DCB_ATTR_CEE_PEER_APP_MAX = 3, +}; + +enum dcbnl_tc_attrs { + DCB_TC_ATTR_PARAM_UNDEFINED = 0, + DCB_TC_ATTR_PARAM_PGID = 1, + DCB_TC_ATTR_PARAM_UP_MAPPING = 2, + DCB_TC_ATTR_PARAM_STRICT_PRIO = 3, + DCB_TC_ATTR_PARAM_BW_PCT = 4, + DCB_TC_ATTR_PARAM_ALL = 5, + __DCB_TC_ATTR_PARAM_ENUM_MAX = 6, + DCB_TC_ATTR_PARAM_MAX = 5, +}; + +enum dcbnl_bcn_attrs { + DCB_BCN_ATTR_UNDEFINED = 0, + DCB_BCN_ATTR_RP_0 = 1, + DCB_BCN_ATTR_RP_1 = 2, + DCB_BCN_ATTR_RP_2 = 3, + DCB_BCN_ATTR_RP_3 = 4, + DCB_BCN_ATTR_RP_4 = 5, + DCB_BCN_ATTR_RP_5 = 6, + DCB_BCN_ATTR_RP_6 = 7, + DCB_BCN_ATTR_RP_7 = 8, + DCB_BCN_ATTR_RP_ALL = 9, + DCB_BCN_ATTR_BCNA_0 = 10, + DCB_BCN_ATTR_BCNA_1 = 11, + DCB_BCN_ATTR_ALPHA = 12, + DCB_BCN_ATTR_BETA = 13, + DCB_BCN_ATTR_GD = 14, + DCB_BCN_ATTR_GI = 15, + DCB_BCN_ATTR_TMAX = 16, + DCB_BCN_ATTR_TD = 17, + DCB_BCN_ATTR_RMIN = 18, + DCB_BCN_ATTR_W = 19, + DCB_BCN_ATTR_RD = 20, + DCB_BCN_ATTR_RU = 21, + DCB_BCN_ATTR_WRTT = 22, + DCB_BCN_ATTR_RI = 23, + DCB_BCN_ATTR_C = 24, + DCB_BCN_ATTR_ALL = 25, + __DCB_BCN_ATTR_ENUM_MAX = 26, + DCB_BCN_ATTR_MAX = 25, +}; + +enum dcbnl_app_attrs { + DCB_APP_ATTR_UNDEFINED = 0, + DCB_APP_ATTR_IDTYPE = 1, + DCB_APP_ATTR_ID = 2, + DCB_APP_ATTR_PRIORITY = 3, + __DCB_APP_ATTR_ENUM_MAX = 4, + DCB_APP_ATTR_MAX = 3, +}; + +enum dcbnl_featcfg_attrs { + DCB_FEATCFG_ATTR_UNDEFINED = 0, + DCB_FEATCFG_ATTR_ALL = 1, + DCB_FEATCFG_ATTR_PG = 2, + DCB_FEATCFG_ATTR_PFC = 3, + DCB_FEATCFG_ATTR_APP = 4, + __DCB_FEATCFG_ATTR_ENUM_MAX = 5, + DCB_FEATCFG_ATTR_MAX = 4, +}; + +struct dcb_app_type { + int ifindex; + struct dcb_app app; + struct list_head list; + u8 dcbx; +}; + +struct dcb_ieee_app_prio_map { + u64 map[8]; +}; + +struct dcb_ieee_app_dscp_map { + u8 map[64]; +}; + +enum dcbevent_notif_type { + DCB_APP_EVENT = 1, +}; + +struct reply_func { + int type; + int (*cb)(struct net_device *, struct nlmsghdr *, u32, struct nlattr **, struct sk_buff *); +}; + +enum dns_payload_content_type { + DNS_PAYLOAD_IS_SERVER_LIST = 0, +}; + +struct dns_payload_header { + __u8 zero; + __u8 content; + __u8 version; +}; + +enum { + dns_key_data = 0, + dns_key_error = 1, +}; + +struct sockaddr_xdp { + __u16 sxdp_family; + __u16 sxdp_flags; + __u32 sxdp_ifindex; + __u32 sxdp_queue_id; + __u32 sxdp_shared_umem_fd; +}; + +struct xdp_ring_offset { + __u64 producer; + __u64 consumer; + __u64 desc; + __u64 flags; +}; + +struct xdp_mmap_offsets { + struct xdp_ring_offset rx; + struct xdp_ring_offset tx; + struct xdp_ring_offset fr; + struct xdp_ring_offset cr; +}; + +struct xdp_umem_reg { + __u64 addr; + __u64 len; + __u32 chunk_size; + __u32 headroom; + __u32 flags; +}; + +struct xdp_statistics { + __u64 rx_dropped; + __u64 rx_invalid_descs; + __u64 tx_invalid_descs; + __u64 rx_ring_full; + __u64 rx_fill_ring_empty_descs; + __u64 tx_ring_empty_descs; +}; + +struct xdp_options { + __u32 flags; +}; + +struct xdp_ring; + +struct xsk_queue { + u32 ring_mask; + u32 nentries; + u32 cached_prod; + u32 cached_cons; + struct xdp_ring *ring; + u64 invalid_descs; + u64 queue_empty_descs; +}; + +struct xdp_ring_offset_v1 { + __u64 producer; + __u64 consumer; + __u64 desc; +}; + +struct xdp_mmap_offsets_v1 { + struct xdp_ring_offset_v1 rx; + struct xdp_ring_offset_v1 tx; + struct xdp_ring_offset_v1 fr; + struct xdp_ring_offset_v1 cr; +}; + +struct xsk_map_node { + struct list_head node; + struct xsk_map *map; + struct xdp_sock **map_entry; +}; + +struct xdp_ring { + u32 producer; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + u32 pad1; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + u32 consumer; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + u32 pad2; + u32 flags; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + u32 pad3; + long: 32; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; + long: 64; +}; + +struct xdp_rxtx_ring { + struct xdp_ring ptrs; + struct xdp_desc desc[0]; +}; + +struct xdp_umem_ring { + struct xdp_ring ptrs; + u64 desc[0]; +}; + +struct xsk_dma_map { + dma_addr_t *dma_pages; + struct device *dev; + struct net_device *netdev; + refcount_t users; + struct list_head list; + u32 dma_pages_cnt; + bool dma_need_sync; +}; + +struct xdp_diag_req { + __u8 sdiag_family; + __u8 sdiag_protocol; + __u16 pad; + __u32 xdiag_ino; + __u32 xdiag_show; + __u32 xdiag_cookie[2]; +}; + +struct xdp_diag_msg { + __u8 xdiag_family; + __u8 xdiag_type; + __u16 pad; + __u32 xdiag_ino; + __u32 xdiag_cookie[2]; +}; + +enum { + XDP_DIAG_NONE = 0, + XDP_DIAG_INFO = 1, + XDP_DIAG_UID = 2, + XDP_DIAG_RX_RING = 3, + XDP_DIAG_TX_RING = 4, + XDP_DIAG_UMEM = 5, + XDP_DIAG_UMEM_FILL_RING = 6, + XDP_DIAG_UMEM_COMPLETION_RING = 7, + XDP_DIAG_MEMINFO = 8, + XDP_DIAG_STATS = 9, + __XDP_DIAG_MAX = 10, +}; + +struct xdp_diag_info { + __u32 ifindex; + __u32 queue_id; +}; + +struct xdp_diag_ring { + __u32 entries; +}; + +struct xdp_diag_umem { + __u64 size; + __u32 id; + __u32 num_pages; + __u32 chunk_size; + __u32 headroom; + __u32 ifindex; + __u32 queue_id; + __u32 flags; + __u32 refs; +}; + +struct xdp_diag_stats { + __u64 n_rx_dropped; + __u64 n_rx_invalid; + __u64 n_rx_full; + __u64 n_fill_ring_empty; + __u64 n_tx_invalid; + __u64 n_tx_ring_empty; +}; + +struct pcibios_fwaddrmap { + struct list_head list; + struct pci_dev *dev; + resource_size_t fw_addr[17]; +}; + +struct pci_check_idx_range { + int start; + int end; +}; + +struct pci_raw_ops { + int (*read)(unsigned int, unsigned int, unsigned int, int, int, u32 *); + int (*write)(unsigned int, unsigned int, unsigned int, int, int, u32); +}; + +struct pci_mmcfg_region { + struct list_head list; + struct resource res; + u64 address; + char *virt; + u16 segment; + u8 start_bus; + u8 end_bus; + char name[30]; +}; + +struct acpi_table_mcfg { + struct acpi_table_header header; + u8 reserved[8]; +}; + +struct acpi_mcfg_allocation { + u64 address; + u16 pci_segment; + u8 start_bus_number; + u8 end_bus_number; + u32 reserved; +}; + +struct pci_mmcfg_hostbridge_probe { + u32 bus; + u32 devfn; + u32 vendor; + u32 device; + const char * (*probe)(); +}; + +typedef bool (*check_reserved_t)(u64, u64, unsigned int); + +struct pci_root_info { + struct acpi_pci_root_info common; + struct pci_sysdata sd; + bool mcfg_added; + u8 start_bus; + u8 end_bus; +}; + +struct irq_info___2 { + u8 bus; + u8 devfn; + struct { + u8 link; + u16 bitmap; + } __attribute__((packed)) irq[4]; + u8 slot; + u8 rfu; +}; + +struct irq_routing_table { + u32 signature; + u16 version; + u16 size; + u8 rtr_bus; + u8 rtr_devfn; + u16 exclusive_irqs; + u16 rtr_vendor; + u16 rtr_device; + u32 miniport_data; + u8 rfu[11]; + u8 checksum; + struct irq_info___2 slots[0]; +}; + +struct irq_router { + char *name; + u16 vendor; + u16 device; + int (*get)(struct pci_dev *, struct pci_dev *, int); + int (*set)(struct pci_dev *, struct pci_dev *, int, int); +}; + +struct irq_router_handler { + u16 vendor; + int (*probe)(struct irq_router *, struct pci_dev *, u16); +}; + +struct pci_setup_rom { + struct setup_data data; + uint16_t vendor; + uint16_t devid; + uint64_t pcilen; + long unsigned int segment; + long unsigned int bus; + long unsigned int device; + long unsigned int function; + uint8_t romdata[0]; +}; + +enum pci_bf_sort_state { + pci_bf_sort_default = 0, + pci_force_nobf = 1, + pci_force_bf = 2, + pci_dmi_bf = 3, +}; + +struct pci_root_res { + struct list_head list; + struct resource res; +}; + +struct pci_root_info___2 { + struct list_head list; + char name[12]; + struct list_head resources; + struct resource busn; + int node; + int link; +}; + +struct amd_hostbridge { + u32 bus; + u32 slot; + u32 device; +}; + +struct saved_msr { + bool valid; + struct msr_info info; +}; + +struct saved_msrs { + unsigned int num; + struct saved_msr *array; +}; + +struct saved_context { + struct pt_regs regs; + u16 ds; + u16 es; + u16 fs; + u16 gs; + long unsigned int kernelmode_gs_base; + long unsigned int usermode_gs_base; + long unsigned int fs_base; + long unsigned int cr0; + long unsigned int cr2; + long unsigned int cr3; + long unsigned int cr4; + u64 misc_enable; + bool misc_enable_saved; + struct saved_msrs saved_msrs; + long unsigned int efer; + u16 gdt_pad; + struct desc_ptr gdt_desc; + u16 idt_pad; + struct desc_ptr idt; + u16 ldt; + u16 tss; + long unsigned int tr; + long unsigned int safety; + long unsigned int return_address; +} __attribute__((packed)); + +typedef int (*pm_cpu_match_t)(const struct x86_cpu_id *); + +#ifndef BPF_NO_PRESERVE_ACCESS_INDEX +#pragma clang attribute pop +#endif + +#endif /* __VMLINUX_H__ */ diff -Nru dwarves-dfsg-1.10/lib/bpf/.travis.yml dwarves-dfsg-1.21/lib/bpf/.travis.yml --- dwarves-dfsg-1.10/lib/bpf/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/lib/bpf/.travis.yml 2021-03-10 16:36:28.000000000 +0000 @@ -0,0 +1,130 @@ +sudo: required +language: bash +dist: bionic +services: + - docker + +env: + global: + - PROJECT_NAME='libbpf' + - AUTHOR_EMAIL="$(git log -1 --pretty=\"%aE\")" + - REPO_ROOT="$TRAVIS_BUILD_DIR" + - CI_ROOT="$REPO_ROOT/travis-ci" + - VMTEST_ROOT="$CI_ROOT/vmtest" + +addons: + apt: + packages: + - qemu-kvm + - zstd + - binutils-dev + - elfutils + - libcap-dev + - libelf-dev + - libdw-dev + +stages: + # Run Coverity periodically instead of for each PR for following reasons: + # 1) Coverity jobs are heavily rate-limited + # 2) Due to security restrictions of encrypted environment variables + # in Travis CI, pull requests made from forks can't access encrypted + # env variables, making Coverity unusable + # See: https://docs.travis-ci.com/user/pull-requests#pull-requests-and-security-restrictions + - name: Coverity + if: type = cron + +jobs: + include: + - stage: Builds & Tests + name: Kernel LATEST + selftests + language: bash + env: KERNEL=LATEST + script: $CI_ROOT/vmtest/run_vmtest.sh || travis_terminate 1 + + - name: Kernel 4.9.0 + selftests + language: bash + env: KERNEL=4.9.0 + script: $CI_ROOT/vmtest/run_vmtest.sh || travis_terminate 1 + + - name: Kernel 5.5.0 + selftests + language: bash + env: KERNEL=5.5.0 + script: $CI_ROOT/vmtest/run_vmtest.sh || travis_terminate 1 + + - name: Debian Build + language: bash + install: $CI_ROOT/managers/debian.sh SETUP + script: $CI_ROOT/managers/debian.sh RUN || travis_terminate 1 + after_script: $CI_ROOT/managers/debian.sh CLEANUP + + - name: Debian Build (ASan+UBSan) + language: bash + install: $CI_ROOT/managers/debian.sh SETUP + script: $CI_ROOT/managers/debian.sh RUN_ASAN || travis_terminate 1 + after_script: $CI_ROOT/managers/debian.sh CLEANUP + + - name: Debian Build (clang) + language: bash + install: $CI_ROOT/managers/debian.sh SETUP + script: $CI_ROOT/managers/debian.sh RUN_CLANG || travis_terminate 1 + after_script: $CI_ROOT/managers/debian.sh CLEANUP + + - name: Debian Build (clang ASan+UBSan) + language: bash + install: $CI_ROOT/managers/debian.sh SETUP + script: $CI_ROOT/managers/debian.sh RUN_CLANG_ASAN || travis_terminate 1 + after_script: $CI_ROOT/managers/debian.sh CLEANUP + + - name: Debian Build (gcc-10) + language: bash + install: $CI_ROOT/managers/debian.sh SETUP + script: $CI_ROOT/managers/debian.sh RUN_GCC10 || travis_terminate 1 + after_script: $CI_ROOT/managers/debian.sh CLEANUP + + - name: Debian Build (gcc-10 ASan+UBSan) + language: bash + install: $CI_ROOT/managers/debian.sh SETUP + script: $CI_ROOT/managers/debian.sh RUN_GCC10_ASAN || travis_terminate 1 + after_script: $CI_ROOT/managers/debian.sh CLEANUP + + - name: Ubuntu Bionic Build + language: bash + script: sudo $CI_ROOT/managers/ubuntu.sh || travis_terminate 1 + + - name: Ubuntu Bionic Build (arm) + arch: arm64 + language: bash + script: sudo $CI_ROOT/managers/ubuntu.sh || travis_terminate 1 + + - name: Ubuntu Bionic Build (s390x) + arch: s390x + language: bash + script: sudo $CI_ROOT/managers/ubuntu.sh || travis_terminate 1 + + - name: Ubuntu Bionic Build (ppc64le) + arch: ppc64le + language: bash + script: sudo $CI_ROOT/managers/ubuntu.sh || travis_terminate 1 + + - stage: Coverity + language: bash + env: + # Coverity configuration + # COVERITY_SCAN_TOKEN=xxx + # Encrypted using `travis encrypt --repo libbpf/libbpf COVERITY_SCAN_TOKEN=xxx` + - secure: "I9OsMRHbb82IUivDp+I+w/jEQFOJgBDAqYqf1ollqCM1QhocxMcS9bwIAgfPhdXi2hohV7sRrVMZstahY67FAvJLGxNopi4tAPDIAaIFxgO0yDxMhaTMx5xDfMwlIm2FOP/9gB9BQsd6M7CmoQZgXYwBIv7xd1ooxoQrh2rOK1YrRl7UQu3+c3zPTjDfIYZzR3bFttMqZ9/c4U0v8Ry5IFXrel3hCshndHA1TtttJrUSrILlZcmVc1ch7JIy6zCbCU/2lGv0B/7rWXfF8MT7O9jPtFOhJ1DEcd2zhw2n4j9YT3a8OhtnM61LA6ask632mwCOsxpFLTun7AzuR1Cb5mdPHsxhxnCHcXXARa2mJjem0QG1NhwxwJE8sbRDapojexxCvweYlEN40ofwMDSnj/qNt95XIcrk0tiIhGFx0gVNWvAdmZwx+N4mwGPMTAN0AEOFjpgI+ZdB89m+tL/CbEgE1flc8QxUxJhcp5OhH6yR0z9qYOp0nXIbHsIaCiRvt/7LqFRQfheifztWVz4mdQlCdKS9gcOQ09oKicPevKO1L0Ue3cb7Ug7jOpMs+cdh3XokJtUeYEr1NijMHT9+CTAhhO5RToWXIZRon719z3fwoUBNDREATwVFMlVxqSO/pbYgaKminigYbl785S89YYaZ6E5UvaKRHM6KHKMDszs=" + - COVERITY_SCAN_PROJECT_NAME="libbpf" + - COVERITY_SCAN_NOTIFICATION_EMAIL="${AUTHOR_EMAIL}" + - COVERITY_SCAN_BRANCH_PATTERN="$TRAVIS_BRANCH" + # Note: `make -C src/` as a BUILD_COMMAND will not work here + - COVERITY_SCAN_BUILD_COMMAND_PREPEND="cd src/" + - COVERITY_SCAN_BUILD_COMMAND="make" + install: + - sudo echo 'deb-src http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse' >>/etc/apt/sources.list + - sudo apt-get update + - sudo apt-get -y build-dep libelf-dev + - sudo apt-get install -y libelf-dev pkg-config + script: + - scripts/coverity.sh || travis_terminate 1 + allow_failures: + - env: KERNEL=x.x.x diff -Nru dwarves-dfsg-1.10/libbtf.c dwarves-dfsg-1.21/libbtf.c --- dwarves-dfsg-1.10/libbtf.c 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/libbtf.c 2021-03-12 17:28:52.000000000 +0000 @@ -0,0 +1,906 @@ +/* + SPDX-License-Identifier: GPL-2.0-only + + Copyright (C) 2019 Facebook + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libbtf.h" +#include "lib/bpf/include/uapi/linux/btf.h" +#include "lib/bpf/include/linux/err.h" +#include "lib/bpf/src/btf.h" +#include "lib/bpf/src/libbpf.h" +#include "dutil.h" +#include "gobuffer.h" +#include "dwarves.h" +#include "elf_symtab.h" + +/* + * This depends on the GNU extension to eliminate the stray comma in the zero + * arguments case. + * + * The difference between elf_errmsg(-1) and elf_errmsg(elf_errno()) is that the + * latter clears the current error. + */ +#define elf_error(fmt, ...) \ + fprintf(stderr, "%s: " fmt ": %s.\n", __func__, ##__VA_ARGS__, elf_errmsg(-1)) + +struct btf *base_btf; +uint8_t btf_elf__verbose; +uint8_t btf_elf__force; +bool btf_gen_floats = false; + +static int btf_var_secinfo_cmp(const void *a, const void *b) +{ + const struct btf_var_secinfo *av = a; + const struct btf_var_secinfo *bv = b; + + return av->offset - bv->offset; +} + +static int libbpf_log(enum libbpf_print_level level, const char *format, va_list args) +{ + return vfprintf(stderr, format, args); +} + +int btf_elf__load(struct btf_elf *btfe) +{ + int err; + + libbpf_set_print(libbpf_log); + + /* free initial empty BTF */ + btf__free(btfe->btf); + if (btfe->raw_btf) + btfe->btf = btf__parse_raw_split(btfe->filename, btfe->base_btf); + else + btfe->btf = btf__parse_elf_split(btfe->filename, btfe->base_btf); + + err = libbpf_get_error(btfe->btf); + if (err) + return err; + + return 0; +} + +struct btf_elf *btf_elf__new(const char *filename, Elf *elf, struct btf *base_btf) +{ + struct btf_elf *btfe = zalloc(sizeof(*btfe)); + GElf_Shdr shdr; + Elf_Scn *sec; + + if (!btfe) + return NULL; + + btfe->in_fd = -1; + btfe->filename = strdup(filename); + if (btfe->filename == NULL) + goto errout; + + btfe->base_btf = base_btf; + btfe->btf = btf__new_empty_split(base_btf); + if (libbpf_get_error(btfe->btf)) { + fprintf(stderr, "%s: failed to create empty BTF.\n", __func__); + goto errout; + } + + if (strstarts(filename, "/sys/kernel/btf/")) { +try_as_raw_btf: + btfe->raw_btf = true; + btfe->wordsize = sizeof(long); + btfe->is_big_endian = BYTE_ORDER == BIG_ENDIAN; + btf__set_endianness(btfe->btf, + btfe->is_big_endian ? BTF_BIG_ENDIAN : BTF_LITTLE_ENDIAN); + return btfe; + } + + if (elf != NULL) { + btfe->elf = elf; + } else { + btfe->in_fd = open(filename, O_RDONLY); + if (btfe->in_fd < 0) + goto errout; + + if (elf_version(EV_CURRENT) == EV_NONE) { + elf_error("cannot set libelf version"); + goto errout; + } + + btfe->elf = elf_begin(btfe->in_fd, ELF_C_READ_MMAP, NULL); + if (!btfe->elf) { + elf_error("cannot read %s ELF file", filename); + goto errout; + } + } + + if (gelf_getehdr(btfe->elf, &btfe->ehdr) == NULL) { + struct btf_header hdr; + if (lseek(btfe->in_fd, 0, SEEK_SET) == 0 && + read(btfe->in_fd, &hdr, sizeof(hdr)) == sizeof(hdr) && + hdr.magic == BTF_MAGIC) { + close(btfe->in_fd); + elf_end(btfe->elf); + btfe->in_fd = -1; + goto try_as_raw_btf; + } + if (btf_elf__verbose) + elf_error("cannot get ELF header"); + goto errout; + } + + switch (btfe->ehdr.e_ident[EI_DATA]) { + case ELFDATA2LSB: + btfe->is_big_endian = false; + btf__set_endianness(btfe->btf, BTF_LITTLE_ENDIAN); + break; + case ELFDATA2MSB: + btfe->is_big_endian = true; + btf__set_endianness(btfe->btf, BTF_BIG_ENDIAN); + break; + default: + fprintf(stderr, "%s: unknown ELF endianness.\n", __func__); + goto errout; + } + + switch (btfe->ehdr.e_ident[EI_CLASS]) { + case ELFCLASS32: btfe->wordsize = 4; break; + case ELFCLASS64: btfe->wordsize = 8; break; + default: btfe->wordsize = 0; break; + } + + btfe->symtab = elf_symtab__new(NULL, btfe->elf, &btfe->ehdr); + if (!btfe->symtab) { + if (btf_elf__verbose) + printf("%s: '%s' doesn't have symtab.\n", __func__, + btfe->filename); + return btfe; + } + + /* find percpu section's shndx */ + sec = elf_section_by_name(btfe->elf, &btfe->ehdr, &shdr, PERCPU_SECTION, + NULL); + if (!sec) { + if (btf_elf__verbose) + printf("%s: '%s' doesn't have '%s' section\n", __func__, + btfe->filename, PERCPU_SECTION); + return btfe; + } + btfe->percpu_shndx = elf_ndxscn(sec); + btfe->percpu_base_addr = shdr.sh_addr; + btfe->percpu_sec_sz = shdr.sh_size; + + return btfe; + +errout: + btf_elf__delete(btfe); + return NULL; +} + +void btf_elf__delete(struct btf_elf *btfe) +{ + if (!btfe) + return; + + if (btfe->in_fd != -1) { + close(btfe->in_fd); + if (btfe->elf) + elf_end(btfe->elf); + } + + elf_symtab__delete(btfe->symtab); + __gobuffer__delete(&btfe->percpu_secinfo); + btf__free(btfe->btf); + free(btfe->filename); + free(btfe); +} + +const char *btf_elf__string(struct btf_elf *btfe, uint32_t ref) +{ + const char *s = btf__str_by_offset(btfe->btf, ref); + + return s && s[0] == '\0' ? NULL : s; +} + +#define BITS_PER_BYTE 8 +#define BITS_PER_BYTE_MASK (BITS_PER_BYTE - 1) +#define BITS_PER_BYTE_MASKED(bits) ((bits) & BITS_PER_BYTE_MASK) +#define BITS_ROUNDDOWN_BYTES(bits) ((bits) >> 3) +#define BITS_ROUNDUP_BYTES(bits) (BITS_ROUNDDOWN_BYTES(bits) + !!BITS_PER_BYTE_MASKED(bits)) + +static const char * const btf_kind_str[NR_BTF_KINDS] = { + [BTF_KIND_UNKN] = "UNKNOWN", + [BTF_KIND_INT] = "INT", + [BTF_KIND_PTR] = "PTR", + [BTF_KIND_ARRAY] = "ARRAY", + [BTF_KIND_STRUCT] = "STRUCT", + [BTF_KIND_UNION] = "UNION", + [BTF_KIND_ENUM] = "ENUM", + [BTF_KIND_FWD] = "FWD", + [BTF_KIND_TYPEDEF] = "TYPEDEF", + [BTF_KIND_VOLATILE] = "VOLATILE", + [BTF_KIND_CONST] = "CONST", + [BTF_KIND_RESTRICT] = "RESTRICT", + [BTF_KIND_FUNC] = "FUNC", + [BTF_KIND_FUNC_PROTO] = "FUNC_PROTO", + [BTF_KIND_VAR] = "VAR", + [BTF_KIND_DATASEC] = "DATASEC", + [BTF_KIND_FLOAT] = "FLOAT", +}; + +static const char *btf_elf__printable_name(const struct btf_elf *btfe, uint32_t offset) +{ + if (!offset) + return "(anon)"; + else + return btf__str_by_offset(btfe->btf, offset); +} + +static const char * btf_elf__int_encoding_str(uint8_t encoding) +{ + if (encoding == 0) + return "(none)"; + else if (encoding == BTF_INT_SIGNED) + return "SIGNED"; + else if (encoding == BTF_INT_CHAR) + return "CHAR"; + else if (encoding == BTF_INT_BOOL) + return "BOOL"; + else + return "UNKN"; +} + + +__attribute ((format (printf, 5, 6))) +static void btf_elf__log_err(const struct btf_elf *btfe, int kind, const char *name, + bool output_cr, const char *fmt, ...) +{ + fprintf(stderr, "[%u] %s %s", btf__get_nr_types(btfe->btf) + 1, + btf_kind_str[kind], name ?: "(anon)"); + + if (fmt && *fmt) { + va_list ap; + + fprintf(stderr, " "); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + } + + if (output_cr) + fprintf(stderr, "\n"); +} + +__attribute ((format (printf, 5, 6))) +static void btf_elf__log_type(const struct btf_elf *btfe, const struct btf_type *t, + bool err, bool output_cr, const char *fmt, ...) +{ + uint8_t kind; + FILE *out; + + if (!btf_elf__verbose && !err) + return; + + kind = BTF_INFO_KIND(t->info); + out = err ? stderr : stdout; + + fprintf(out, "[%u] %s %s", + btf__get_nr_types(btfe->btf), btf_kind_str[kind], + btf_elf__printable_name(btfe, t->name_off)); + + if (fmt && *fmt) { + va_list ap; + + fprintf(out, " "); + va_start(ap, fmt); + vfprintf(out, fmt, ap); + va_end(ap); + } + + if (output_cr) + fprintf(out, "\n"); +} + +__attribute ((format (printf, 5, 6))) +static void btf_log_member(const struct btf_elf *btfe, + const struct btf_type *t, + const struct btf_member *member, + bool err, const char *fmt, ...) +{ + FILE *out; + + if (!btf_elf__verbose && !err) + return; + + out = err ? stderr : stdout; + + if (btf_kflag(t)) + fprintf(out, "\t%s type_id=%u bitfield_size=%u bits_offset=%u", + btf_elf__printable_name(btfe, member->name_off), + member->type, + BTF_MEMBER_BITFIELD_SIZE(member->offset), + BTF_MEMBER_BIT_OFFSET(member->offset)); + else + fprintf(out, "\t%s type_id=%u bits_offset=%u", + btf_elf__printable_name(btfe, member->name_off), + member->type, + member->offset); + + if (fmt && *fmt) { + va_list ap; + + fprintf(out, " "); + va_start(ap, fmt); + vfprintf(out, fmt, ap); + va_end(ap); + } + + fprintf(out, "\n"); +} + +__attribute ((format (printf, 6, 7))) +static void btf_log_func_param(const struct btf_elf *btfe, + const char *name, uint32_t type, + bool err, bool is_last_param, + const char *fmt, ...) +{ + FILE *out; + + if (!btf_elf__verbose && !err) + return; + + out = err ? stderr : stdout; + + if (is_last_param && !type) + fprintf(out, "vararg)\n"); + else + fprintf(out, "%u %s%s", type, name, is_last_param ? ")\n" : ", "); + + if (fmt && *fmt) { + va_list ap; + + fprintf(out, " "); + va_start(ap, fmt); + vfprintf(out, fmt, ap); + va_end(ap); + } +} + +static int32_t btf_elf__add_float_type(struct btf_elf *btfe, + const struct base_type *bt, + const char *name) +{ + int32_t id; + + id = btf__add_float(btfe->btf, name, BITS_ROUNDUP_BYTES(bt->bit_size)); + if (id < 0) { + btf_elf__log_err(btfe, BTF_KIND_FLOAT, name, true, "Error emitting BTF type"); + } else { + const struct btf_type *t; + + t = btf__type_by_id(btfe->btf, id); + btf_elf__log_type(btfe, t, false, true, + "size=%u nr_bits=%u", + t->size, bt->bit_size); + } + + return id; +} + +int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, + const char *name) +{ + struct btf *btf = btfe->btf; + const struct btf_type *t; + uint8_t encoding = 0; + uint16_t byte_sz; + int32_t id; + + if (bt->is_signed) { + encoding = BTF_INT_SIGNED; + } else if (bt->is_bool) { + encoding = BTF_INT_BOOL; + } else if (bt->float_type && btf_gen_floats) { + /* + * Encode floats as BTF_KIND_FLOAT if allowed, otherwise (in + * compatibility mode) encode them as BTF_KIND_INT - that's not + * fully correct, but that's what it used to be. + */ + if (bt->float_type == BT_FP_SINGLE || + bt->float_type == BT_FP_DOUBLE || + bt->float_type == BT_FP_LDBL) + return btf_elf__add_float_type(btfe, bt, name); + fprintf(stderr, "Complex, interval and imaginary float types are not supported\n"); + return -1; + } + + /* dwarf5 may emit DW_ATE_[un]signed_{num} base types where + * {num} is not power of 2 and may exceed 128. Such attributes + * are mostly used to record operation for an actual parameter + * or variable. + * For example, + * DW_AT_location (indexed (0x3c) loclist = 0x00008fb0: + * [0xffffffff82808812, 0xffffffff82808817): + * DW_OP_breg0 RAX+0, + * DW_OP_convert (0x000e97d5) "DW_ATE_unsigned_64", + * DW_OP_convert (0x000e97df) "DW_ATE_unsigned_8", + * DW_OP_stack_value, + * DW_OP_piece 0x1, + * DW_OP_breg0 RAX+0, + * DW_OP_convert (0x000e97d5) "DW_ATE_unsigned_64", + * DW_OP_convert (0x000e97da) "DW_ATE_unsigned_32", + * DW_OP_lit8, + * DW_OP_shr, + * DW_OP_convert (0x000e97da) "DW_ATE_unsigned_32", + * DW_OP_convert (0x000e97e4) "DW_ATE_unsigned_24", + * DW_OP_stack_value, DW_OP_piece 0x3 + * DW_AT_name ("ebx") + * DW_AT_decl_file ("/linux/arch/x86/events/intel/core.c") + * + * In the above example, at some point, one unsigned_32 value + * is right shifted by 8 and the result is converted to unsigned_32 + * and then unsigned_24. + * + * BTF does not need such DW_OP_* information so let us sanitize + * these non-regular int types to avoid libbpf/kernel complaints. + */ + byte_sz = BITS_ROUNDUP_BYTES(bt->bit_size); + if (!byte_sz || (byte_sz & (byte_sz - 1))) { + name = "__SANITIZED_FAKE_INT__"; + byte_sz = 4; + } + + id = btf__add_int(btf, name, byte_sz, encoding); + if (id < 0) { + btf_elf__log_err(btfe, BTF_KIND_INT, name, true, "Error emitting BTF type"); + } else { + t = btf__type_by_id(btf, id); + btf_elf__log_type(btfe, t, false, true, + "size=%u nr_bits=%u encoding=%s%s", + t->size, bt->bit_size, + btf_elf__int_encoding_str(encoding), + id < 0 ? " Error in emitting BTF" : "" ); + } + + return id; +} + +int32_t btf_elf__add_ref_type(struct btf_elf *btfe, uint16_t kind, uint32_t type, + const char *name, bool kind_flag) +{ + struct btf *btf = btfe->btf; + const struct btf_type *t; + int32_t id; + + switch (kind) { + case BTF_KIND_PTR: + id = btf__add_ptr(btf, type); + break; + case BTF_KIND_VOLATILE: + id = btf__add_volatile(btf, type); + break; + case BTF_KIND_CONST: + id = btf__add_const(btf, type); + break; + case BTF_KIND_RESTRICT: + id = btf__add_restrict(btf, type); + break; + case BTF_KIND_TYPEDEF: + id = btf__add_typedef(btf, name, type); + break; + case BTF_KIND_FWD: + id = btf__add_fwd(btf, name, kind_flag); + break; + case BTF_KIND_FUNC: + id = btf__add_func(btf, name, BTF_FUNC_STATIC, type); + break; + default: + btf_elf__log_err(btfe, kind, name, true, "Unexpected kind for reference"); + return -1; + } + + if (id > 0) { + t = btf__type_by_id(btf, id); + if (kind == BTF_KIND_FWD) + btf_elf__log_type(btfe, t, false, true, "%s", kind_flag ? "union" : "struct"); + else + btf_elf__log_type(btfe, t, false, true, "type_id=%u", t->type); + } else { + btf_elf__log_err(btfe, kind, name, true, "Error emitting BTF type"); + } + return id; +} + +int32_t btf_elf__add_array(struct btf_elf *btfe, uint32_t type, uint32_t index_type, uint32_t nelems) +{ + struct btf *btf = btfe->btf; + const struct btf_type *t; + const struct btf_array *array; + int32_t id; + + id = btf__add_array(btf, index_type, type, nelems); + if (id > 0) { + t = btf__type_by_id(btf, id); + array = btf_array(t); + btf_elf__log_type(btfe, t, false, true, + "type_id=%u index_type_id=%u nr_elems=%u", + array->type, array->index_type, array->nelems); + } else { + btf_elf__log_err(btfe, BTF_KIND_ARRAY, NULL, true, + "type_id=%u index_type_id=%u nr_elems=%u Error emitting BTF type", + type, index_type, nelems); + } + return id; +} + +int btf_elf__add_member(struct btf_elf *btfe, const char *name, uint32_t type, + uint32_t bitfield_size, uint32_t offset) +{ + struct btf *btf = btfe->btf; + const struct btf_type *t; + const struct btf_member *m; + int err; + + err = btf__add_field(btf, name, type, offset, bitfield_size); + t = btf__type_by_id(btf, btf__get_nr_types(btf)); + if (err) { + fprintf(stderr, "[%u] %s %s's field '%s' offset=%u bit_size=%u type=%u Error emitting field\n", + btf__get_nr_types(btf), btf_kind_str[btf_kind(t)], + btf_elf__printable_name(btfe, t->name_off), + name, offset, bitfield_size, type); + } else { + m = &btf_members(t)[btf_vlen(t) - 1]; + btf_log_member(btfe, t, m, false, NULL); + } + return err; +} + +int32_t btf_elf__add_struct(struct btf_elf *btfe, uint8_t kind, const char *name, uint32_t size) +{ + struct btf *btf = btfe->btf; + const struct btf_type *t; + int32_t id; + + switch (kind) { + case BTF_KIND_STRUCT: + id = btf__add_struct(btf, name, size); + break; + case BTF_KIND_UNION: + id = btf__add_union(btf, name, size); + break; + default: + btf_elf__log_err(btfe, kind, name, true, "Unexpected kind of struct"); + return -1; + } + + if (id < 0) { + btf_elf__log_err(btfe, kind, name, true, "Error emitting BTF type"); + } else { + t = btf__type_by_id(btf, id); + btf_elf__log_type(btfe, t, false, true, "size=%u", t->size); + } + + return id; +} + +int32_t btf_elf__add_enum(struct btf_elf *btfe, const char *name, uint32_t bit_size) +{ + struct btf *btf = btfe->btf; + const struct btf_type *t; + int32_t id, size; + + size = BITS_ROUNDUP_BYTES(bit_size); + id = btf__add_enum(btf, name, size); + if (id > 0) { + t = btf__type_by_id(btf, id); + btf_elf__log_type(btfe, t, false, true, "size=%u", t->size); + } else { + btf_elf__log_err(btfe, BTF_KIND_ENUM, name, true, + "size=%u Error emitting BTF type", size); + } + return id; +} + +int btf_elf__add_enum_val(struct btf_elf *btfe, const char *name, int32_t value) +{ + struct btf *btf = btfe->btf; + int err; + + err = btf__add_enum_value(btf, name, value); + if (!err) { + if (btf_elf__verbose) + printf("\t%s val=%d\n", name, value); + } else { + fprintf(stderr, "\t%s val=%d Error emitting BTF enum value\n", + name, value); + } + return err; +} + +static int32_t btf_elf__add_func_proto_param(struct btf_elf *btfe, const char *name, + uint32_t type, bool is_last_param) +{ + int err; + + err = btf__add_func_param(btfe->btf, name, type); + if (!err) { + btf_log_func_param(btfe, name, type, false, is_last_param, NULL); + return 0; + } else { + btf_log_func_param(btfe, name, type, true, is_last_param, + "Error adding func param"); + return -1; + } +} + +extern struct debug_fmt_ops *dwarves__active_loader; + +int32_t btf_elf__add_func_proto(struct btf_elf *btfe, struct cu *cu, struct ftype *ftype, uint32_t type_id_off) +{ + struct btf *btf = btfe->btf; + const struct btf_type *t; + struct parameter *param; + uint16_t nr_params, param_idx; + int32_t id, type_id; + + /* add btf_type for func_proto */ + nr_params = ftype->nr_parms + (ftype->unspec_parms ? 1 : 0); + type_id = ftype->tag.type == 0 ? 0 : type_id_off + ftype->tag.type; + + id = btf__add_func_proto(btf, type_id); + if (id > 0) { + t = btf__type_by_id(btf, id); + btf_elf__log_type(btfe, t, false, false, "return=%u args=(%s", + t->type, !nr_params ? "void)\n" : ""); + } else { + btf_elf__log_err(btfe, BTF_KIND_FUNC_PROTO, NULL, true, + "return=%u vlen=%u Error emitting BTF type", + type_id, nr_params); + return id; + } + + /* add parameters */ + param_idx = 0; + ftype__for_each_parameter(ftype, param) { + const char *name = dwarves__active_loader->strings__ptr(cu, param->name); + + type_id = param->tag.type == 0 ? 0 : type_id_off + param->tag.type; + ++param_idx; + if (btf_elf__add_func_proto_param(btfe, name, type_id, param_idx == nr_params)) + return -1; + } + + ++param_idx; + if (ftype->unspec_parms) + if (btf_elf__add_func_proto_param(btfe, NULL, 0, param_idx == nr_params)) + return -1; + + return id; +} + +int32_t btf_elf__add_var_type(struct btf_elf *btfe, uint32_t type, const char *name, + uint32_t linkage) +{ + struct btf *btf = btfe->btf; + const struct btf_type *t; + int32_t id; + + id = btf__add_var(btf, name, linkage, type); + if (id > 0) { + t = btf__type_by_id(btf, id); + btf_elf__log_type(btfe, t, false, true, "type=%u linkage=%u", + t->type, btf_var(t)->linkage); + } else { + btf_elf__log_err(btfe, BTF_KIND_VAR, name, true, + "type=%u linkage=%u Error emitting BTF type", + type, linkage); + } + return id; +} + +int32_t btf_elf__add_var_secinfo(struct gobuffer *buf, uint32_t type, + uint32_t offset, uint32_t size) +{ + struct btf_var_secinfo si = { + .type = type, + .offset = offset, + .size = size, + }; + return gobuffer__add(buf, &si, sizeof(si)); +} + +int32_t btf_elf__add_datasec_type(struct btf_elf *btfe, const char *section_name, + struct gobuffer *var_secinfo_buf) +{ + struct btf *btf = btfe->btf; + size_t sz = gobuffer__size(var_secinfo_buf); + uint16_t nr_var_secinfo = sz / sizeof(struct btf_var_secinfo); + struct btf_var_secinfo *last_vsi, *vsi; + const struct btf_type *t; + uint32_t datasec_sz; + int32_t err, id, i; + + qsort(var_secinfo_buf->entries, nr_var_secinfo, + sizeof(struct btf_var_secinfo), btf_var_secinfo_cmp); + + last_vsi = (struct btf_var_secinfo *)var_secinfo_buf->entries + nr_var_secinfo - 1; + datasec_sz = last_vsi->offset + last_vsi->size; + + id = btf__add_datasec(btf, section_name, datasec_sz); + if (id < 0) { + btf_elf__log_err(btfe, BTF_KIND_DATASEC, section_name, true, + "size=%u vlen=%u Error emitting BTF type", + datasec_sz, nr_var_secinfo); + } else { + t = btf__type_by_id(btf, id); + btf_elf__log_type(btfe, t, false, true, "size=%u vlen=%u", + t->size, nr_var_secinfo); + } + + for (i = 0; i < nr_var_secinfo; i++) { + vsi = (struct btf_var_secinfo *)var_secinfo_buf->entries + i; + err = btf__add_datasec_var_info(btf, vsi->type, vsi->offset, vsi->size); + if (!err) { + if (btf_elf__verbose) + printf("\ttype=%u offset=%u size=%u\n", + vsi->type, vsi->offset, vsi->size); + } else { + fprintf(stderr, "\ttype=%u offset=%u size=%u Error emitting BTF datasec var info\n", + vsi->type, vsi->offset, vsi->size); + return -1; + } + } + + return id; +} + +static int btf_elf__write(const char *filename, struct btf *btf) +{ + GElf_Shdr shdr_mem, *shdr; + GElf_Ehdr ehdr_mem, *ehdr; + Elf_Data *btf_data = NULL; + Elf_Scn *scn = NULL; + Elf *elf = NULL; + const void *raw_btf_data; + uint32_t raw_btf_size; + int fd, err = -1; + size_t strndx; + + fd = open(filename, O_RDWR); + if (fd < 0) { + fprintf(stderr, "Cannot open %s\n", filename); + return -1; + } + + if (elf_version(EV_CURRENT) == EV_NONE) { + elf_error("Cannot set libelf version"); + goto out; + } + + elf = elf_begin(fd, ELF_C_RDWR, NULL); + if (elf == NULL) { + elf_error("Cannot update ELF file"); + goto out; + } + + elf_flagelf(elf, ELF_C_SET, ELF_F_DIRTY); + + ehdr = gelf_getehdr(elf, &ehdr_mem); + if (ehdr == NULL) { + elf_error("elf_getehdr failed"); + goto out; + } + + switch (ehdr_mem.e_ident[EI_DATA]) { + case ELFDATA2LSB: + btf__set_endianness(btf, BTF_LITTLE_ENDIAN); + break; + case ELFDATA2MSB: + btf__set_endianness(btf, BTF_BIG_ENDIAN); + break; + default: + fprintf(stderr, "%s: unknown ELF endianness.\n", __func__); + goto out; + } + + /* + * First we look if there was already a .BTF section to overwrite. + */ + + elf_getshdrstrndx(elf, &strndx); + while ((scn = elf_nextscn(elf, scn)) != NULL) { + shdr = gelf_getshdr(scn, &shdr_mem); + if (shdr == NULL) + continue; + char *secname = elf_strptr(elf, strndx, shdr->sh_name); + if (strcmp(secname, ".BTF") == 0) { + btf_data = elf_getdata(scn, btf_data); + break; + } + } + + raw_btf_data = btf__get_raw_data(btf, &raw_btf_size); + + if (btf_data) { + /* Exisiting .BTF section found */ + btf_data->d_buf = (void *)raw_btf_data; + btf_data->d_size = raw_btf_size; + elf_flagdata(btf_data, ELF_C_SET, ELF_F_DIRTY); + + if (elf_update(elf, ELF_C_NULL) >= 0 && + elf_update(elf, ELF_C_WRITE) >= 0) + err = 0; + else + elf_error("elf_update failed"); + } else { + const char *llvm_objcopy; + char tmp_fn[PATH_MAX]; + char cmd[PATH_MAX * 2]; + + llvm_objcopy = getenv("LLVM_OBJCOPY"); + if (!llvm_objcopy) + llvm_objcopy = "llvm-objcopy"; + + /* Use objcopy to add a .BTF section */ + snprintf(tmp_fn, sizeof(tmp_fn), "%s.btf", filename); + close(fd); + fd = creat(tmp_fn, S_IRUSR | S_IWUSR); + if (fd == -1) { + fprintf(stderr, "%s: open(%s) failed!\n", __func__, + tmp_fn); + goto out; + } + + if (write(fd, raw_btf_data, raw_btf_size) != raw_btf_size) { + fprintf(stderr, "%s: write of %d bytes to '%s' failed: %d!\n", + __func__, raw_btf_size, tmp_fn, errno); + goto unlink; + } + + snprintf(cmd, sizeof(cmd), "%s --add-section .BTF=%s %s", + llvm_objcopy, tmp_fn, filename); + if (system(cmd)) { + fprintf(stderr, "%s: failed to add .BTF section to '%s': %d!\n", + __func__, filename, errno); + goto unlink; + } + + err = 0; + unlink: + unlink(tmp_fn); + } + +out: + if (fd != -1) + close(fd); + if (elf) + elf_end(elf); + return err; +} + +int btf_elf__encode(struct btf_elf *btfe, uint8_t flags) +{ + struct btf *btf = btfe->btf; + + /* Empty file, nothing to do, so... done! */ + if (btf__get_nr_types(btf) == 0) + return 0; + + if (btf__dedup(btf, NULL, NULL)) { + fprintf(stderr, "%s: btf__dedup failed!\n", __func__); + return -1; + } + + return btf_elf__write(btfe->filename, btf); +} diff -Nru dwarves-dfsg-1.10/libbtf.h dwarves-dfsg-1.21/libbtf.h --- dwarves-dfsg-1.10/libbtf.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/libbtf.h 2021-03-12 17:28:52.000000000 +0000 @@ -0,0 +1,73 @@ +/* + SPDX-License-Identifier: GPL-2.0-only + + Copyright (C) 2019 Facebook + */ + +#ifndef _LIBBTF_H +#define _LIBBTF_H + +#include "gobuffer.h" + +#include +#include +#include "lib/bpf/src/btf.h" + +struct btf_elf { + void *priv; + Elf *elf; + GElf_Ehdr ehdr; + struct elf_symtab *symtab; + struct gobuffer percpu_secinfo; + char *filename; + int in_fd; + uint8_t wordsize; + bool is_big_endian; + bool raw_btf; // "/sys/kernel/btf/vmlinux" + uint32_t percpu_shndx; + uint64_t percpu_base_addr; + uint64_t percpu_sec_sz; + struct btf *btf; + struct btf *base_btf; +}; + +extern struct btf *base_btf; +extern uint8_t btf_elf__verbose; +extern uint8_t btf_elf__force; +#define btf_elf__verbose_log(fmt, ...) { if (btf_elf__verbose) printf(fmt, __VA_ARGS__); } +extern bool btf_gen_floats; + +#define PERCPU_SECTION ".data..percpu" + +struct cu; +struct base_type; +struct ftype; + +struct btf_elf *btf_elf__new(const char *filename, Elf *elf, struct btf *base_btf); +void btf_elf__delete(struct btf_elf *btf); + +int32_t btf_elf__add_base_type(struct btf_elf *btf, const struct base_type *bt, + const char *name); +int32_t btf_elf__add_ref_type(struct btf_elf *btf, uint16_t kind, uint32_t type, + const char *name, bool kind_flag); +int btf_elf__add_member(struct btf_elf *btf, const char *name, uint32_t type, + uint32_t bitfield_size, uint32_t bit_offset); +int32_t btf_elf__add_struct(struct btf_elf *btf, uint8_t kind, const char *name, uint32_t size); +int32_t btf_elf__add_array(struct btf_elf *btf, uint32_t type, uint32_t index_type, + uint32_t nelems); +int32_t btf_elf__add_enum(struct btf_elf *btf, const char *name, uint32_t size); +int btf_elf__add_enum_val(struct btf_elf *btf, const char *name, int32_t value); +int32_t btf_elf__add_func_proto(struct btf_elf *btf, struct cu *cu, struct ftype *ftype, + uint32_t type_id_off); +int32_t btf_elf__add_var_type(struct btf_elf *btfe, uint32_t type, const char *name, + uint32_t linkage); +int32_t btf_elf__add_var_secinfo(struct gobuffer *buf, uint32_t type, + uint32_t offset, uint32_t size); +int32_t btf_elf__add_datasec_type(struct btf_elf *btfe, const char *section_name, + struct gobuffer *var_secinfo_buf); +int btf_elf__encode(struct btf_elf *btf, uint8_t flags); + +const char *btf_elf__string(struct btf_elf *btf, uint32_t ref); +int btf_elf__load(struct btf_elf *btf); + +#endif /* _LIBBTF_H */ diff -Nru dwarves-dfsg-1.10/libctf.c dwarves-dfsg-1.21/libctf.c --- dwarves-dfsg-1.10/libctf.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/libctf.c 2021-03-07 13:51:27.000000000 +0000 @@ -1,3 +1,9 @@ +/* + SPDX-License-Identifier: GPL-2.0-only + + Copyright (C) 2019 Arnaldo Carvalho de Melo + */ + #include #include #include @@ -13,6 +19,7 @@ #include "ctf.h" #include "dutil.h" #include "gobuffer.h" +#include "pahole_strings.h" bool ctf__ignore_symtab_function(const GElf_Sym *sym, const char *sym_name) { @@ -30,20 +37,20 @@ strchr(sym_name, '.') != NULL); } -uint16_t ctf__get16(struct ctf *self, uint16_t *p) +uint16_t ctf__get16(struct ctf *ctf, uint16_t *p) { uint16_t val = *p; - if (self->swapped) + if (ctf->swapped) val = ((val >> 8) | (val << 8)); return val; } -uint32_t ctf__get32(struct ctf *self, uint32_t *p) +uint32_t ctf__get32(struct ctf *ctf, uint32_t *p) { uint32_t val = *p; - if (self->swapped) + if (ctf->swapped) val = ((val >> 24) | ((val >> 8) & 0x0000ff00) | ((val << 8) & 0x00ff0000) | @@ -51,16 +58,16 @@ return val; } -void ctf__put16(struct ctf *self, uint16_t *p, uint16_t val) +void ctf__put16(struct ctf *ctf, uint16_t *p, uint16_t val) { - if (self->swapped) + if (ctf->swapped) val = ((val >> 8) | (val << 8)); *p = val; } -void ctf__put32(struct ctf *self, uint32_t *p, uint32_t val) +void ctf__put32(struct ctf *ctf, uint32_t *p, uint32_t val) { - if (self->swapped) + if (ctf->swapped) val = ((val >> 24) | ((val >> 8) & 0x0000ff00) | ((val << 8) & 0x00ff0000) | @@ -68,7 +75,7 @@ *p = val; } -static int ctf__decompress(struct ctf *self, void *orig_buf, size_t orig_size) +static int ctf__decompress(struct ctf *ctf, void *orig_buf, size_t orig_size) { struct ctf_header *hp = orig_buf; const char *err_str; @@ -76,8 +83,8 @@ size_t len; void *new; - len = (ctf__get32(self, &hp->ctf_str_off) + - ctf__get32(self, &hp->ctf_str_len)); + len = (ctf__get32(ctf, &hp->ctf_str_off) + + ctf__get32(ctf, &hp->ctf_str_len)); new = malloc(len + sizeof(*hp)); if (!new) { fprintf(stderr, "CTF decompression allocation failure.\n"); @@ -111,8 +118,8 @@ goto err; } - self->buf = new; - self->size = len + sizeof(*hp); + ctf->buf = new; + ctf->size = len + sizeof(*hp); return 0; @@ -122,11 +129,11 @@ return -EINVAL; } -int ctf__load(struct ctf *self) +int ctf__load(struct ctf *ctf) { int err = -ENOTSUP; GElf_Shdr shdr; - Elf_Scn *sec = elf_section_by_name(self->elf, &self->ehdr, + Elf_Scn *sec = elf_section_by_name(ctf->elf, &ctf->ehdr, &shdr, ".SUNW_ctf", NULL); if (sec == NULL) @@ -147,42 +154,44 @@ err = -EINVAL; if (hp->ctf_magic == CTF_MAGIC) - self->swapped = 0; + ctf->swapped = 0; else if (hp->ctf_magic == CTF_MAGIC_SWAP) - self->swapped = 1; + ctf->swapped = 1; else goto out; if (!(hp->ctf_flags & CTF_FLAGS_COMPR)) { err = -ENOMEM; - self->buf = malloc(orig_size); - if (self->buf != NULL) { - memcpy(self->buf, hp, orig_size); - self->size = orig_size; + ctf->buf = malloc(orig_size); + if (ctf->buf != NULL) { + memcpy(ctf->buf, hp, orig_size); + ctf->size = orig_size; err = 0; } } else - err = ctf__decompress(self, hp, orig_size); + err = ctf__decompress(ctf, hp, orig_size); out: return err; } +bool ctf__verbose; + struct ctf *ctf__new(const char *filename, Elf *elf) { - struct ctf *self = zalloc(sizeof(*self)); + struct ctf *ctf = zalloc(sizeof(*ctf)); - if (self != NULL) { - self->filename = strdup(filename); - if (self->filename == NULL) + if (ctf != NULL) { + ctf->filename = strdup(filename); + if (ctf->filename == NULL) goto out_delete; if (elf != NULL) { - self->in_fd = -1; - self->elf = elf; + ctf->in_fd = -1; + ctf->elf = elf; } else { - self->in_fd = open(filename, O_RDONLY); - if (self->in_fd < 0) + ctf->in_fd = open(filename, O_RDONLY); + if (ctf->in_fd < 0) goto out_delete_filename; if (elf_version(EV_CURRENT) == EV_NONE) { @@ -191,99 +200,100 @@ goto out_close; } - self->elf = elf_begin(self->in_fd, ELF_C_READ_MMAP, NULL); - if (!self->elf) { + ctf->elf = elf_begin(ctf->in_fd, ELF_C_READ_MMAP, NULL); + if (!ctf->elf) { fprintf(stderr, "%s: cannot read %s ELF file.\n", __func__, filename); goto out_close; } } - if (gelf_getehdr(self->elf, &self->ehdr) == NULL) { - fprintf(stderr, "%s: cannot get elf header.\n", __func__); + if (gelf_getehdr(ctf->elf, &ctf->ehdr) == NULL) { + if (ctf__verbose) + fprintf(stderr, "%s: cannot get elf header.\n", __func__); goto out_elf_end; } - switch (self->ehdr.e_ident[EI_CLASS]) { - case ELFCLASS32: self->wordsize = 4; break; - case ELFCLASS64: self->wordsize = 8; break; - default: self->wordsize = 0; break; + switch (ctf->ehdr.e_ident[EI_CLASS]) { + case ELFCLASS32: ctf->wordsize = 4; break; + case ELFCLASS64: ctf->wordsize = 8; break; + default: ctf->wordsize = 0; break; } } - return self; + return ctf; out_elf_end: if (elf == NULL) - elf_end(self->elf); + elf_end(ctf->elf); out_close: if (elf == NULL) - close(self->in_fd); + close(ctf->in_fd); out_delete_filename: - free(self->filename); + free(ctf->filename); out_delete: - free(self); + free(ctf); return NULL; } -void ctf__delete(struct ctf *self) +void ctf__delete(struct ctf *ctf) { - if (self != NULL) { - if (self->in_fd != -1) { - elf_end(self->elf); - close(self->in_fd); + if (ctf != NULL) { + if (ctf->in_fd != -1) { + elf_end(ctf->elf); + close(ctf->in_fd); } - __gobuffer__delete(&self->objects); - __gobuffer__delete(&self->types); - __gobuffer__delete(&self->funcs); - elf_symtab__delete(self->symtab); - free(self->filename); - free(self->buf); - free(self); + __gobuffer__delete(&ctf->objects); + __gobuffer__delete(&ctf->types); + __gobuffer__delete(&ctf->funcs); + elf_symtab__delete(ctf->symtab); + free(ctf->filename); + free(ctf->buf); + free(ctf); } } -char *ctf__string(struct ctf *self, uint32_t ref) +char *ctf__string(struct ctf *ctf, uint32_t ref) { - struct ctf_header *hp = self->buf; + struct ctf_header *hp = ctf->buf; uint32_t off = CTF_REF_OFFSET(ref); char *name; if (CTF_REF_TBL_ID(ref) != CTF_STR_TBL_ID_0) return "(external ref)"; - if (off >= ctf__get32(self, &hp->ctf_str_len)) + if (off >= ctf__get32(ctf, &hp->ctf_str_len)) return "(ref out-of-bounds)"; - if ((off + ctf__get32(self, &hp->ctf_str_off)) >= self->size) + if ((off + ctf__get32(ctf, &hp->ctf_str_off)) >= ctf->size) return "(string table truncated)"; - name = ((char *)(hp + 1) + ctf__get32(self, &hp->ctf_str_off) + off); + name = ((char *)(hp + 1) + ctf__get32(ctf, &hp->ctf_str_off) + off); return name[0] == '\0' ? NULL : name; } -void *ctf__get_buffer(struct ctf *self) +void *ctf__get_buffer(struct ctf *ctf) { - return self->buf; + return ctf->buf; } -size_t ctf__get_size(struct ctf *self) +size_t ctf__get_size(struct ctf *ctf) { - return self->size; + return ctf->size; } -int ctf__load_symtab(struct ctf *self) +int ctf__load_symtab(struct ctf *ctf) { - self->symtab = elf_symtab__new(".symtab", self->elf, &self->ehdr); - return self->symtab == NULL ? -1 : 0; + ctf->symtab = elf_symtab__new(".symtab", ctf->elf, &ctf->ehdr); + return ctf->symtab == NULL ? -1 : 0; } -void ctf__set_strings(struct ctf *self, struct gobuffer *strings) +void ctf__set_strings(struct ctf *ctf, struct strings *strings) { - self->strings = strings; + ctf->strings = strings; } -int ctf__add_base_type(struct ctf *self, uint32_t name, uint16_t size) +uint32_t ctf__add_base_type(struct ctf *ctf, uint32_t name, uint16_t size) { struct ctf_full_type t; @@ -292,12 +302,11 @@ t.base.ctf_size = size; t.ctf_size_high = CTF_TYPE_INT_ENCODE(0, 0, size); - gobuffer__add(&self->types, &t, sizeof(t) - sizeof(uint32_t)); - return ++self->type_index; + gobuffer__add(&ctf->types, &t, sizeof(t) - sizeof(uint32_t)); + return ++ctf->type_index; } -int ctf__add_short_type(struct ctf *self, uint16_t kind, uint16_t type, - uint32_t name) +uint32_t ctf__add_short_type(struct ctf *ctf, uint16_t kind, uint16_t type, uint32_t name) { struct ctf_short_type t; @@ -305,17 +314,16 @@ t.ctf_info = CTF_INFO_ENCODE(kind, 0, 0); t.ctf_type = type; - gobuffer__add(&self->types, &t, sizeof(t)); - return ++self->type_index; + gobuffer__add(&ctf->types, &t, sizeof(t)); + return ++ctf->type_index; } -int ctf__add_fwd_decl(struct ctf *self, uint32_t name) +uint32_t ctf__add_fwd_decl(struct ctf *ctf, uint32_t name) { - return ctf__add_short_type(self, CTF_TYPE_KIND_FWD, 0, name); + return ctf__add_short_type(ctf, CTF_TYPE_KIND_FWD, 0, name); } -int ctf__add_array(struct ctf *self, uint16_t type, uint16_t index_type, - uint32_t nelems) +uint32_t ctf__add_array(struct ctf *ctf, uint16_t type, uint16_t index_type, uint32_t nelems) { struct { struct ctf_short_type t; @@ -329,11 +337,11 @@ array.a.ctf_array_index_type = index_type; array.a.ctf_array_nelems = nelems; - gobuffer__add(&self->types, &array, sizeof(array)); - return ++self->type_index; + gobuffer__add(&ctf->types, &array, sizeof(array)); + return ++ctf->type_index; } -void ctf__add_short_member(struct ctf *self, uint32_t name, uint16_t type, +void ctf__add_short_member(struct ctf *ctf, uint32_t name, uint16_t type, uint16_t offset, int64_t *position) { struct ctf_short_member m = { @@ -342,11 +350,11 @@ .ctf_member_offset = offset, }; - memcpy(gobuffer__ptr(&self->types, *position), &m, sizeof(m)); + memcpy(gobuffer__ptr(&ctf->types, *position), &m, sizeof(m)); *position += sizeof(m); } -void ctf__add_full_member(struct ctf *self, uint32_t name, uint16_t type, +void ctf__add_full_member(struct ctf *ctf, uint32_t name, uint16_t type, uint64_t offset, int64_t *position) { struct ctf_full_member m = { @@ -356,12 +364,12 @@ .ctf_member_offset_low = offset & 0xffffffffl, }; - memcpy(gobuffer__ptr(&self->types, *position), &m, sizeof(m)); + memcpy(gobuffer__ptr(&ctf->types, *position), &m, sizeof(m)); *position += sizeof(m); } -int ctf__add_struct(struct ctf *self, uint16_t kind, uint32_t name, - uint64_t size, uint16_t nr_members, int64_t *position) +uint32_t ctf__add_struct(struct ctf *ctf, uint16_t kind, uint32_t name, + uint64_t size, uint16_t nr_members, int64_t *position) { const bool is_short = size < CTF_SHORT_MEMBER_LIMIT; uint32_t members_len = ((is_short ? sizeof(struct ctf_short_member) : @@ -382,21 +390,21 @@ t.ctf_size_low = size & 0xffffffff; } - gobuffer__add(&self->types, &t, len); - *position = gobuffer__allocate(&self->types, members_len); - return ++self->type_index; + gobuffer__add(&ctf->types, &t, len); + *position = gobuffer__allocate(&ctf->types, members_len); + return ++ctf->type_index; } -void ctf__add_parameter(struct ctf *self, uint16_t type, int64_t *position) +void ctf__add_parameter(struct ctf *ctf, uint16_t type, int64_t *position) { - uint16_t *parm = gobuffer__ptr(&self->types, *position); + uint16_t *parm = gobuffer__ptr(&ctf->types, *position); *parm = type; *position += sizeof(*parm); } -int ctf__add_function_type(struct ctf *self, uint16_t type, uint16_t nr_parms, - bool varargs, int64_t *position) +uint32_t ctf__add_function_type(struct ctf *ctf, uint16_t type, uint16_t nr_parms, + bool varargs, int64_t *position) { struct ctf_short_type t; int len = sizeof(uint16_t) * (nr_parms + !!varargs); @@ -412,19 +420,19 @@ nr_parms + !!varargs, 0); t.ctf_type = type; - gobuffer__add(&self->types, &t, sizeof(t)); - *position = gobuffer__allocate(&self->types, len); + gobuffer__add(&ctf->types, &t, sizeof(t)); + *position = gobuffer__allocate(&ctf->types, len); if (varargs) { unsigned int pos = *position + (nr_parms * sizeof(uint16_t)); - uint16_t *end_of_args = gobuffer__ptr(&self->types, pos); + uint16_t *end_of_args = gobuffer__ptr(&ctf->types, pos); *end_of_args = 0; } - return ++self->type_index; + return ++ctf->type_index; } -int ctf__add_enumeration_type(struct ctf *self, uint32_t name, uint16_t size, - uint16_t nr_entries, int64_t *position) +uint32_t ctf__add_enumeration_type(struct ctf *ctf, uint32_t name, uint16_t size, + uint16_t nr_entries, int64_t *position) { struct ctf_short_type e; @@ -432,13 +440,13 @@ e.ctf_info = CTF_INFO_ENCODE(CTF_TYPE_KIND_ENUM, nr_entries, 0); e.ctf_size = size; - gobuffer__add(&self->types, &e, sizeof(e)); - *position = gobuffer__allocate(&self->types, + gobuffer__add(&ctf->types, &e, sizeof(e)); + *position = gobuffer__allocate(&ctf->types, nr_entries * sizeof(struct ctf_enum)); - return ++self->type_index; + return ++ctf->type_index; } -void ctf__add_enumerator(struct ctf *self, uint32_t name, uint32_t value, +void ctf__add_enumerator(struct ctf *ctf, uint32_t name, uint32_t value, int64_t *position) { struct ctf_enum m = { @@ -446,20 +454,20 @@ .ctf_enum_val = value, }; - memcpy(gobuffer__ptr(&self->types, *position), &m, sizeof(m)); + memcpy(gobuffer__ptr(&ctf->types, *position), &m, sizeof(m)); *position += sizeof(m); } -void ctf__add_function_parameter(struct ctf *self, uint16_t type, +void ctf__add_function_parameter(struct ctf *ctf, uint16_t type, int64_t *position) { - uint16_t *parm = gobuffer__ptr(&self->funcs, *position); + uint16_t *parm = gobuffer__ptr(&ctf->funcs, *position); *parm = type; *position += sizeof(*parm); } -int ctf__add_function(struct ctf *self, uint16_t type, uint16_t nr_parms, +int ctf__add_function(struct ctf *ctf, uint16_t type, uint16_t nr_parms, bool varargs, int64_t *position) { struct ctf_short_type func; @@ -479,21 +487,21 @@ * We don't store the name for the function, it comes from the * symtab. */ - gobuffer__add(&self->funcs, &func.ctf_info, + gobuffer__add(&ctf->funcs, &func.ctf_info, sizeof(func) - sizeof(func.ctf_name)); - *position = gobuffer__allocate(&self->funcs, len); + *position = gobuffer__allocate(&ctf->funcs, len); if (varargs) { unsigned int pos = *position + (nr_parms * sizeof(uint16_t)); - uint16_t *end_of_args = gobuffer__ptr(&self->funcs, pos); + uint16_t *end_of_args = gobuffer__ptr(&ctf->funcs, pos); *end_of_args = 0; } return 0; } -int ctf__add_object(struct ctf *self, uint16_t type) +int ctf__add_object(struct ctf *ctf, uint16_t type) { - return gobuffer__add(&self->objects, &type, + return gobuffer__add(&ctf->objects, &type, sizeof(type)) >= 0 ? 0 : -ENOMEM; } @@ -549,7 +557,7 @@ goto out; } -int ctf__encode(struct ctf *self, uint8_t flags) +int ctf__encode(struct ctf *ctf, uint8_t flags) { struct ctf_header *hdr; unsigned int size; @@ -557,23 +565,23 @@ int err = -1; /* Empty file, nothing to do, so... done! */ - if (gobuffer__size(&self->types) == 0) + if (gobuffer__size(&ctf->types) == 0) return 0; - size = (gobuffer__size(&self->types) + - gobuffer__size(&self->objects) + - gobuffer__size(&self->funcs) + - gobuffer__size(self->strings)); + size = (gobuffer__size(&ctf->types) + + gobuffer__size(&ctf->objects) + + gobuffer__size(&ctf->funcs) + + strings__size(ctf->strings)); - self->size = sizeof(*hdr) + size; - self->buf = malloc(self->size); + ctf->size = sizeof(*hdr) + size; + ctf->buf = malloc(ctf->size); - if (self->buf == NULL) { + if (ctf->buf == NULL) { fprintf(stderr, "%s: malloc failed!\n", __func__); return -ENOMEM; } - hdr = self->buf; + hdr = ctf->buf; memset(hdr, 0, sizeof(*hdr)); hdr->ctf_magic = CTF_MAGIC; hdr->ctf_version = 2; @@ -581,23 +589,23 @@ uint32_t offset = 0; hdr->ctf_object_off = offset; - offset += gobuffer__size(&self->objects); + offset += gobuffer__size(&ctf->objects); hdr->ctf_func_off = offset; - offset += gobuffer__size(&self->funcs); + offset += gobuffer__size(&ctf->funcs); hdr->ctf_type_off = offset; - offset += gobuffer__size(&self->types); + offset += gobuffer__size(&ctf->types); hdr->ctf_str_off = offset; - hdr->ctf_str_len = gobuffer__size(self->strings); + hdr->ctf_str_len = strings__size(ctf->strings); - void *payload = self->buf + sizeof(*hdr); - gobuffer__copy(&self->objects, payload + hdr->ctf_object_off); - gobuffer__copy(&self->funcs, payload + hdr->ctf_func_off); - gobuffer__copy(&self->types, payload + hdr->ctf_type_off); - gobuffer__copy(self->strings, payload + hdr->ctf_str_off); + void *payload = ctf->buf + sizeof(*hdr); + gobuffer__copy(&ctf->objects, payload + hdr->ctf_object_off); + gobuffer__copy(&ctf->funcs, payload + hdr->ctf_func_off); + gobuffer__copy(&ctf->types, payload + hdr->ctf_type_off); + strings__copy(ctf->strings, payload + hdr->ctf_str_off); - *(char *)(self->buf + sizeof(*hdr) + hdr->ctf_str_off) = '\0'; + *(char *)(ctf->buf + sizeof(*hdr) + hdr->ctf_str_off) = '\0'; if (flags & CTF_FLAGS_COMPR) { - bf = (void *)ctf__compress(self->buf + sizeof(*hdr), &size); + bf = (void *)ctf__compress(ctf->buf + sizeof(*hdr), &size); if (bf == NULL) { printf("%s: ctf__compress failed!\n", __func__); return -ENOMEM; @@ -611,20 +619,19 @@ bf = new_bf; size += sizeof(*hdr); } else { - bf = self->buf; - size = self->size; + bf = ctf->buf; + size = ctf->size; } #if 0 printf("\n\ntypes:\n entries: %d\n size: %u" - "\nstrings:\n entries: %u\n size: %u\ncompressed size: %d\n", - self->type_index, - gobuffer__size(&self->types), - gobuffer__nr_entries(self->strings), - gobuffer__size(self->strings), size); + "\nstrings:\n size: %u\ncompressed size: %d\n", + ctf->type_index, + gobuffer__size(&ctf->types), + strings__size(ctf->strings), size); #endif - int fd = open(self->filename, O_RDWR); + int fd = open(ctf->filename, O_RDWR); if (fd < 0) { - fprintf(stderr, "Cannot open %s\n", self->filename); + fprintf(stderr, "Cannot open %s\n", ctf->filename); return -1; } @@ -724,7 +731,7 @@ elf_flagshdr(newscn, ELF_C_SET, ELF_F_DIRTY); #else char pathname[PATH_MAX]; - snprintf(pathname, sizeof(pathname), "%s.SUNW_ctf", self->filename); + snprintf(pathname, sizeof(pathname), "%s.SUNW_ctf", ctf->filename); fd = creat(pathname, S_IRUSR | S_IWUSR); if (fd == -1) { fprintf(stderr, "%s: open(%s) failed!\n", __func__, pathname); @@ -736,9 +743,9 @@ if (close(fd) < 0) goto out_unlink; - char cmd[PATH_MAX]; + char cmd[PATH_MAX * 2]; snprintf(cmd, sizeof(cmd), "objcopy --add-section .SUNW_ctf=%s %s", - pathname, self->filename); + pathname, ctf->filename); if (system(cmd) == 0) err = 0; out_unlink: @@ -758,7 +765,7 @@ elf_end(elf); err = 0; out_close: - if (bf != self->buf) + if (bf != ctf->buf) free(bf); close(fd); return err; diff -Nru dwarves-dfsg-1.10/libctf.h dwarves-dfsg-1.21/libctf.h --- dwarves-dfsg-1.10/libctf.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/libctf.h 2021-03-07 13:51:27.000000000 +0000 @@ -1,3 +1,9 @@ +/* + SPDX-License-Identifier: GPL-2.0-only + + Copyright (C) 2019 Arnaldo Carvalho de Melo + */ + #ifndef _LIBCTF_H #define _LIBCTF_H @@ -18,13 +24,13 @@ struct gobuffer objects; /* data/variables */ struct gobuffer types; struct gobuffer funcs; - struct gobuffer *strings; + struct strings *strings; char *filename; size_t size; int swapped; int in_fd; uint8_t wordsize; - unsigned int type_index; + uint32_t type_index; }; struct ctf *ctf__new(const char *filename, Elf *elf); @@ -33,77 +39,75 @@ bool ctf__ignore_symtab_function(const GElf_Sym *sym, const char *sym_name); bool ctf__ignore_symtab_object(const GElf_Sym *sym, const char *sym_name); -int ctf__load(struct ctf *self); +int ctf__load(struct ctf *ctf); -uint16_t ctf__get16(struct ctf *self, uint16_t *p); -uint32_t ctf__get32(struct ctf *self, uint32_t *p); -void ctf__put16(struct ctf *self, uint16_t *p, uint16_t val); -void ctf__put32(struct ctf *self, uint32_t *p, uint32_t val); - -void *ctf__get_buffer(struct ctf *self); -size_t ctf__get_size(struct ctf *self); - -int ctf__load_symtab(struct ctf *self); - -int ctf__add_base_type(struct ctf *self, uint32_t name, uint16_t size); -int ctf__add_fwd_decl(struct ctf *self, uint32_t name); -int ctf__add_short_type(struct ctf *self, uint16_t kind, uint16_t type, - uint32_t name); -void ctf__add_short_member(struct ctf *self, uint32_t name, uint16_t type, +uint16_t ctf__get16(struct ctf *ctf, uint16_t *p); +uint32_t ctf__get32(struct ctf *ctf, uint32_t *p); +void ctf__put16(struct ctf *ctf, uint16_t *p, uint16_t val); +void ctf__put32(struct ctf *ctf, uint32_t *p, uint32_t val); + +void *ctf__get_buffer(struct ctf *ctf); +size_t ctf__get_size(struct ctf *ctf); + +int ctf__load_symtab(struct ctf *ctf); + +uint32_t ctf__add_base_type(struct ctf *ctf, uint32_t name, uint16_t size); +uint32_t ctf__add_fwd_decl(struct ctf *ctf, uint32_t name); +uint32_t ctf__add_short_type(struct ctf *ctf, uint16_t kind, uint16_t type, uint32_t name); +void ctf__add_short_member(struct ctf *ctf, uint32_t name, uint16_t type, uint16_t offset, int64_t *position); -void ctf__add_full_member(struct ctf *self, uint32_t name, uint16_t type, +void ctf__add_full_member(struct ctf *ctf, uint32_t name, uint16_t type, uint64_t offset, int64_t *position); -int ctf__add_struct(struct ctf *self, uint16_t kind, uint32_t name, - uint64_t size, uint16_t nr_members, int64_t *position); -int ctf__add_array(struct ctf *self, uint16_t type, uint16_t index_type, - uint32_t nelems); -void ctf__add_parameter(struct ctf *self, uint16_t type, int64_t *position); -int ctf__add_function_type(struct ctf *self, uint16_t type, - uint16_t nr_parms, bool varargs, int64_t *position); -int ctf__add_enumeration_type(struct ctf *self, uint32_t name, uint16_t size, - uint16_t nr_entries, int64_t *position); -void ctf__add_enumerator(struct ctf *self, uint32_t name, uint32_t value, +uint32_t ctf__add_struct(struct ctf *ctf, uint16_t kind, uint32_t name, + uint64_t size, uint16_t nr_members, int64_t *position); +uint32_t ctf__add_array(struct ctf *ctf, uint16_t type, uint16_t index_type, uint32_t nelems); +void ctf__add_parameter(struct ctf *ctf, uint16_t type, int64_t *position); +uint32_t ctf__add_function_type(struct ctf *ctf, uint16_t type, + uint16_t nr_parms, bool varargs, int64_t *position); +uint32_t ctf__add_enumeration_type(struct ctf *ctf, uint32_t name, uint16_t size, + uint16_t nr_entries, int64_t *position); +void ctf__add_enumerator(struct ctf *ctf, uint32_t name, uint32_t value, int64_t *position); -void ctf__add_function_parameter(struct ctf *self, uint16_t type, +void ctf__add_function_parameter(struct ctf *ctf, uint16_t type, int64_t *position); -int ctf__add_function(struct ctf *self, uint16_t type, uint16_t nr_parms, +int ctf__add_function(struct ctf *ctf, uint16_t type, uint16_t nr_parms, bool varargs, int64_t *position); -int ctf__add_object(struct ctf *self, uint16_t type); +int ctf__add_object(struct ctf *ctf, uint16_t type); -void ctf__set_strings(struct ctf *self, struct gobuffer *strings); -int ctf__encode(struct ctf *self, uint8_t flags); +void ctf__set_strings(struct ctf *ctf, struct strings *strings); +int ctf__encode(struct ctf *ctf, uint8_t flags); -char *ctf__string(struct ctf *self, uint32_t ref); +char *ctf__string(struct ctf *ctf, uint32_t ref); /** * ctf__for_each_symtab_function - iterate thru all the symtab functions * - * @self: struct ctf instance to iterate + * @ctf: struct ctf instance to iterate * @index: uint32_t index * @sym: GElf_Sym iterator */ -#define ctf__for_each_symtab_function(self, index, sym) \ - elf_symtab__for_each_symbol(self->symtab, index, sym) \ +#define ctf__for_each_symtab_function(ctf, index, sym) \ + elf_symtab__for_each_symbol(ctf->symtab, index, sym) \ if (ctf__ignore_symtab_function(&sym, \ elf_sym__name(&sym, \ - self->symtab))) \ + ctf->symtab))) \ continue; \ else /** * ctf__for_each_symtab_object - iterate thru all the symtab objects * - * @self: struct ctf instance to iterate + * @ctf: struct ctf instance to iterate * @index: uint32_t index * @sym: GElf_Sym iterator */ -#define ctf__for_each_symtab_object(self, index, sym) \ - elf_symtab__for_each_symbol(self->symtab, index, sym) \ +#define ctf__for_each_symtab_object(ctf, index, sym) \ + elf_symtab__for_each_symbol(ctf->symtab, index, sym) \ if (ctf__ignore_symtab_object(&sym, \ elf_sym__name(&sym, \ - self->symtab))) \ + ctf->symtab))) \ continue; \ else diff -Nru dwarves-dfsg-1.10/list.h dwarves-dfsg-1.21/list.h --- dwarves-dfsg-1.10/list.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/list.h 2019-05-01 15:06:45.000000000 +0000 @@ -1,11 +1,9 @@ #ifndef _LINUX_LIST_H #define _LINUX_LIST_H /* - Copyright (C) Cast of dozens, comes from the Linux kernel + SPDX-License-Identifier: GPL-2.0-only - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. + Copyright (C) Cast of dozens, comes from the Linux kernel */ #include diff -Nru dwarves-dfsg-1.10/MANIFEST dwarves-dfsg-1.21/MANIFEST --- dwarves-dfsg-1.10/MANIFEST 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/MANIFEST 2021-04-09 19:10:58.000000000 +0000 @@ -1,4 +1,8 @@ config.h.cmake +btfdiff +btf_encoder.c +btf_encoder.h +btf_loader.c ctf_encoder.c ctf_encoder.h ctf_loader.c @@ -19,9 +23,12 @@ elfcreator.h elf_symtab.c elf_symtab.h +fullcircle gobuffer.c gobuffer.h hash.h +libbtf.c +libbtf.h list.h MANIFEST man-pages/pahole.1 @@ -35,12 +42,23 @@ scncopy.c syscse.c strings.c -strings.h +pahole_strings.h dutil.c dutil.h +changes-v1.13 +changes-v1.16 +changes-v1.17 +changes-v1.18 +changes-v1.19 +changes-v1.20 +changes-v1.21 +COPYING NEWS README +README.DEBUG +README.btf README.ctracer +README.tarball rpm/SPECS/dwarves.spec lib/Makefile lib/ctracer_relay.c @@ -52,3 +70,4 @@ libctf.c libctf.h regtest +lib/bpf/ diff -Nru dwarves-dfsg-1.10/man-pages/pahole.1 dwarves-dfsg-1.21/man-pages/pahole.1 --- dwarves-dfsg-1.10/man-pages/pahole.1 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/man-pages/pahole.1 2021-03-12 17:28:52.000000000 +0000 @@ -1,30 +1,57 @@ .\" Man page for pahole .\" Arnaldo Carvalho de Melo, 2009 .\" Licensed under version 2 of the GNU General Public License. -.TH pahole 1 "February 13, 2009" "dwarves" "dwarves" +.TH pahole 1 "January 16, 2020" "dwarves" "dwarves" .\" .SH NAME -pahole \- Shows and manipulates data structure layout. +pahole \- Shows, manipulates data structure layout and pretty prints raw data. .SH SYNOPSIS \fBpahole\fR [\fIoptions\fR] \fIfiles\fR .SH DESCRIPTION .B pahole shows data structure layouts encoded in debugging information formats, -DWARF and CTF being supported. +DWARF, CTF and BTF being supported. This is useful for, among other things: optimizing important data structures by reducing its size, figuring out what is the field sitting at an offset from the start of a data structure, investigating ABI changes and more generally understanding a new codebase you have to work with. +It also uses these structure layouts to pretty print data feed to its standard +input, e.g.: +.PP +.nf +$ pahole --header elf64_hdr < /lib/modules/5.8.0-rc6+/build/vmlinux +{ + .e_ident = { 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + .e_type = 2, + .e_machine = 62, + .e_version = 1, + .e_entry = 16777216, + .e_phoff = 64, + .e_shoff = 604653784, + .e_flags = 0, + .e_ehsize = 64, + .e_phentsize = 56, + .e_phnum = 5, + .e_shentsize = 64, + .e_shnum = 80, + .e_shstrndx = 79, +}, +$ +.fi + +See the PRETTY PRINTING section for further examples and documentation. + The files must have associated debugging information. This information may be inside the file itself, in ELF sections, or in another file. One way to have this information is to specify the \fB\-g\fR option to the compiler when building it. When this is done the information will be stored in an ELF section. For the DWARF debugging information format this, adds, among -others, the \fB.debug_info\fR ELF section. For CTF it is found in just one -ELF section, \fB.SUNW_ctf\fR. +others, the \fB.debug_info\fR ELF section. For CTF it is found in just one ELF +section, \fB.SUNW_ctf\fR. BTF comes in at least the \fB.BTF\fR ELF section, and +may come also with the \fB.BTF.ext\fR ELF section. The \fBdebuginfo\fR packages available in most Linux distributions are also supported by \fBpahole\fR, where the debugging information is available in a @@ -33,6 +60,34 @@ By default, \fBpahole\fR shows the layout of all named structs in the files specified. +If no files are specified, then it will look if the /sys/kernel/btf/vmlinux +is present, using the BTF information present in it about the running kernel, +i.e. this works: +.PP +.nf +$ pahole list_head +struct list_head { + struct list_head * next; /* 0 8 */ + struct list_head * prev; /* 8 8 */ + + /* size: 16, cachelines: 1, members: 2 */ + /* last cacheline: 16 bytes */ +}; +$ +.fi + +If BTF is not present and no file is passed, then a vmlinux that matches the +build-id for the running kernel will be looked up in the usual places, +including where the kernel debuginfo packages put it, looking for DWARF info +instead. + +See the EXAMPLES section for more usage suggestions. + +It also pretty prints whatever is fed to its standard input, according to the +type specified, see the EXAMPLE session. + +Use --count to state how many records should be pretty printed. + .SH OPTIONS pahole supports the following options. @@ -46,6 +101,14 @@ Set cacheline size to SIZE bytes. .TP +.B \-\-count=COUNT +Pretty print the first COUNT records from input. + +.TP +.B \-\-skip=COUNT +Skip COUNT input records. + +.TP .B \-E, \-\-expand_types Expand class members. Useful to find in what member of inner structs where an offset from the beginning of a struct is. @@ -57,6 +120,10 @@ "-F dwarf,ctf". .TP +.B \-\-hex +Print offsets and sizes in hexadecimal. + +.TP .B \-r, \-\-rel_offset Show relative offsets of members in inner structs. @@ -111,6 +178,37 @@ the debugging information. .TP +.B \-\-skip_encoding_btf_vars +Do not encode VARs in BTF. + +.TP +.B \-J, \-\-btf_encode +Encode BTF information from DWARF, used in the Linux kernel build process when +CONFIG_DEBUG_INFO_BTF=y is present, introduced in Linux v5.2. Used to implement +features such as BPF CO-RE (Compile Once - Run Everywhere). + +See \fIhttps://nakryiko.com/posts/bpf-portability-and-co-re/\fR. + +.TP +.B \-\-btf_encode_force +Ignore those symbols found invalid when encoding BTF. + +.TP +.B \-\-btf_base=PATH +Path to the base BTF file, for instance: vmlinux when encoding kernel module BTF information. +This may be inferred when asking for a /sys/kernel/btf/MODULE, when it will be autoconfigured +to "/sys/kernel/btf/vmlinux". + +.TP +.B \-\-btf_gen_floats +Allow producing BTF_KIND_FLOAT entries in systems where the vmlinux DWARF +information has float types. + +.TP +.B \-\-btf_gen_all +Allow using all the BTF features supported by pahole. + +.TP .B \-l, \-\-show_first_biggest_size_base_type_member Show first biggest size base_type member. @@ -163,10 +261,30 @@ .TP .B \-\-flat_arrays Flatten arrays, so that array[10][2] becomes array[20]. -Useful when generating from both CTF and DWARF encodings +Useful when generating from both CTF/BTF and DWARF encodings for the same binary for testing purposes. .TP +.B \-\-suppress_aligned_attribute +Suppress forced alignment markers, so that one can compare BTF or +CTF output, that don't have that info, to output from DWARF >= 5. + +.TP +.B \-\-suppress_force_paddings + +Suppress bitfield forced padding at the end of structs, as this requires +something like DWARF's DW_AT_alignment, so that one can compare BTF or CTF +output, that don't have that info. + +.TP +.B \-\-suppress_packed + +Suppress the output of the inference of __attribute__((__packed__)), so that +one can compare BTF or CTF output, the inference algorithm uses things like +DW_AT_alignment, so until it is improved to infer that as well for BTF, allow +disabling this output. + +.TP .B \-\-fixup_silly_bitfields Converts silly bitfields such as "int foo:32" to plain "int foo". @@ -194,25 +312,661 @@ .B \-z, \-\-hole_size_ge=HOLE_SIZE Show only structs with at least one hole greater or equal to HOLE_SIZE. +.TP +.B \-\-structs +Show only structs, all the other filters apply, i.e. to show just the sizes of all structs +combine --structs with --sizes, etc. + +.TP +.B \-\-packed +Show only packed structs, all the other filters apply, i.e. to show just the +sizes of all packed structs combine --packed with --sizes, etc. + +.TP +.B \-\-unions +Show only unions, all the other filters apply, i.e. to show just the sizes of all unions +combine --union with --sizes, etc. + +.TP +.B \-\-version +Show a traditional string version, i.e.: "v1.18". + +.TP +.B \-\-numeric_version +Show a numeric only version, suitable for use in Makefiles and scripts where +one wants to know what if the installed version has some feature, i.e.: 118 instead of "v1.18". + .SH NOTES To enable the generation of debugging information in the Linux kernel build process select CONFIG_DEBUG_INFO. This can be done using make menuconfig by -this path: "Kernel Hacking" -> "Kernel Debugging" -> "Compile the kernel with -debug info". +this path: "Kernel Hacking" -> "Compile-time checks and compiler options" -> +"Compile the kernel with debug info". Consider as well enabling +CONFIG_DEBUG_INFO_BTF by going thru the aforementioned menuconfig path and then +selecting "Generate BTF typeinfo". Most modern distributions with eBPF support +should come with that in all its kernels, greatly facilitating the use of +pahole. Many distributions also come with debuginfo packages, so just enable it in your package manager repository configuration and install the kernel-debuginfo, or any other userspace program written in a language that the compiler generates debuginfo (C, C++, for instance). +.SH EXAMPLES + +All the examples here use either /sys/kernel/btf/vmlinux, if present, or lookup +a vmlinux file matching the running kernel, using the build-id info found in +/sys/kernel/notes to make sure it matches. +.P +Show a type: +.PP +.nf +$ pahole -C __u64 +typedef long long unsigned int __u64; +$ +.fi + +.P +Works as well if the only argument is a type name: +.PP +.nf +$ pahole raw_spinlock_t +typedef struct raw_spinlock raw_spinlock_t; +$ +.fi + +.P +Multiple types can be passed, separated by commas: +.PP +.nf +$ pahole raw_spinlock_t,raw_spinlock +struct raw_spinlock { + arch_spinlock_t raw_lock; /* 0 4 */ + + /* size: 4, cachelines: 1, members: 1 */ + /* last cacheline: 4 bytes */ +}; +typedef struct raw_spinlock raw_spinlock_t; +$ +.fi + +.P +Types can be expanded: +.PP +.nf +$ pahole -E raw_spinlock +struct raw_spinlock { + /* typedef arch_spinlock_t */ struct qspinlock { + union { + /* typedef atomic_t */ struct { + int counter; /* 0 4 */ + } val; /* 0 4 */ + struct { + /* typedef u8 -> __u8 */ unsigned char locked; /* 0 1 */ + /* typedef u8 -> __u8 */ unsigned char pending; /* 1 1 */ + }; /* 0 2 */ + struct { + /* typedef u16 -> __u16 */ short unsigned int locked_pending; /* 0 2 */ + /* typedef u16 -> __u16 */ short unsigned int tail; /* 2 2 */ + }; /* 0 4 */ + }; /* 0 4 */ + } raw_lock; /* 0 4 */ + + /* size: 4, cachelines: 1, members: 1 */ + /* last cacheline: 4 bytes */ +}; +$ +.fi + +.P +When decoding OOPSes you may want to see the offsets and sizes in hexadecimal: +.PP +.nf +$ pahole --hex thread_struct +struct thread_struct { + struct desc_struct tls_array[3]; /* 0 0x18 */ + long unsigned int sp; /* 0x18 0x8 */ + short unsigned int es; /* 0x20 0x2 */ + short unsigned int ds; /* 0x22 0x2 */ + short unsigned int fsindex; /* 0x24 0x2 */ + short unsigned int gsindex; /* 0x26 0x2 */ + long unsigned int fsbase; /* 0x28 0x8 */ + long unsigned int gsbase; /* 0x30 0x8 */ + struct perf_event * ptrace_bps[4]; /* 0x38 0x20 */ + /* --- cacheline 1 boundary (64 bytes) was 24 bytes ago --- */ + long unsigned int debugreg6; /* 0x58 0x8 */ + long unsigned int ptrace_dr7; /* 0x60 0x8 */ + long unsigned int cr2; /* 0x68 0x8 */ + long unsigned int trap_nr; /* 0x70 0x8 */ + long unsigned int error_code; /* 0x78 0x8 */ + /* --- cacheline 2 boundary (128 bytes) --- */ + struct io_bitmap * io_bitmap; /* 0x80 0x8 */ + long unsigned int iopl_emul; /* 0x88 0x8 */ + mm_segment_t addr_limit; /* 0x90 0x8 */ + unsigned int sig_on_uaccess_err:1; /* 0x98: 0 0x4 */ + unsigned int uaccess_err:1; /* 0x98:0x1 0x4 */ + + /* XXX 30 bits hole, try to pack */ + /* XXX 36 bytes hole, try to pack */ + + /* --- cacheline 3 boundary (192 bytes) --- */ + struct fpu fpu; /* 0xc0 0x1040 */ + + /* size: 4352, cachelines: 68, members: 20 */ + /* sum members: 4312, holes: 1, sum holes: 36 */ + /* sum bitfield members: 2 bits, bit holes: 1, sum bit holes: 30 bits */ +}; +$ +.fi + +.P +OK, I know the offset that causes its a 'struct thread_struct' and that the offset is 0x178, +so must be in that 'fpu' struct... No problem, expand 'struct thread_struct' and combine with \fBgrep\fR: +.PP +.nf +$ pahole --hex -E thread_struct | egrep '(0x178|struct fpu)' -B4 -A4 + /* XXX 30 bits hole, try to pack */ + /* XXX 36 bytes hole, try to pack */ + + /* --- cacheline 3 boundary (192 bytes) --- */ + struct fpu { + unsigned int last_cpu; /* 0xc0 0x4 */ + + /* XXX 4 bytes hole, try to pack */ + +-- + /* typedef u8 -> __u8 */ unsigned char alimit; /* 0x171 0x1 */ + + /* XXX 6 bytes hole, try to pack */ + + struct math_emu_info * info; /* \fI0x178\fR 0x8 */ + /* --- cacheline 6 boundary (384 bytes) --- */ + /* typedef u32 -> __u32 */ unsigned int entry_eip; /* 0x180 0x4 */ + } soft; /* 0x100 0x88 */ + struct xregs_state { +$ +.fi + +.P +Want to know where 'struct thread_struct' is defined in the kernel sources? +.PP +.nf +$ pahole -I thread_struct | head -2 +/* Used at: /sys/kernel/btf/vmlinux */ +/* <0> (null):0 */ +$ +.fi + +.P +Not present in BTF, so use DWARF, takes a little bit longer, and assuming it finds the matching vmlinux file: +.PP +.nf +$ pahole -Fdwarf -I thread_struct | head -2 +/* Used at: /home/acme/git/linux/arch/x86/kernel/head64.c */ +/* <3333> /home/acme/git/linux/arch/x86/include/asm/processor.h:485 */ +$ +.fi + +.P +To find the biggest data structures in the Linux kernel: +.PP +.nf +$ pahole -s | sort -k2 -nr | head -5 +cmp_data 290904 1 +dec_datas 274520 1 +cpu_entry_area 217088 0 +pglist_data 172928 4 +saved_cmdlines_buffer 131104 1 +$ +.fi +.P +The second column is the size in bytes and the third is the number of alignment holes in +that structure. +.P +Show data structures that have a raw spinlock and are related to the RCU mechanism: +.PP +.nf +$ pahole --contains raw_spinlock_t --prefix rcu +rcu_node +rcu_data +rcu_state +$ +.fi +.P +To see that in context, combine it with \fIgrep\fR: +.PP +.nf +$ pahole rcu_state | grep raw_spinlock_t -B1 -A5 + /* --- cacheline 52 boundary (3328 bytes) --- */ + raw_spinlock_t ofl_lock; /* 3328 4 */ + + /* size: 3392, cachelines: 53, members: 35 */ + /* sum members: 3250, holes: 7, sum holes: 82 */ + /* padding: 60 */ +}; +$ +.fi +.P +It can also pretty print raw data from stdin according to the type specified: +.PP +.nf +$ pahole -C modversion_info drivers/scsi/sg.ko +struct modversion_info { + long unsigned int crc; /* 0 8 */ + char name[56]; /* 8 56 */ + + /* size: 64, cachelines: 1, members: 2 */ +}; +$ +$ objcopy -O binary --only-section=__versions drivers/scsi/sg.ko versions +$ +$ ls -la versions +-rw-rw-r--. 1 acme acme 7616 Jun 25 11:33 versions +$ +$ pahole --count 3 -C modversion_info drivers/scsi/sg.ko < versions +{ + .crc = 0x8dabd84, + .name = "module_layout", +}, +{ + .crc = 0x45e4617b, + .name = "no_llseek", +}, +{ + .crc = 0xa23fae8c, + .name = "param_ops_int", +}, +$ +$ pahole --skip 1 --count 2 -C modversion_info drivers/scsi/sg.ko < versions +{ + .crc = 0x45e4617b, + .name = "no_llseek", +}, +{ + .crc = 0xa23fae8c, + .name = "param_ops_int", +}, +$ +This is equivalent to: + +$ pahole --seek_bytes 64 --count 1 -C modversion_info drivers/scsi/sg.ko < versions +{ + .crc = 0x45e4617b, + .name = "no_llseek", +}, +$ +.fi +.P + +.SH PRETTY PRINTING +.P +pahole can also use the data structure types to pretty print raw data coming +from its standard input. + +.TP +.B \-C, \-\-class_name=CLASS_NAME +Pretty print according to this class. Arguments may be passed to it to affect how +the pretty printing is performed, e.g.: + +.PP +.nf + -C 'perf_event_header(sizeof,type,type_enum=perf_event_type,filter=type==PERF_RECORD_EXIT)' +.fi + +This would select the 'struct perf_event_header' as the type to use to pretty print records +states that the 'size' field in that struct should be used to figure out the size of the record +(variable sized records), that the 'enum perf_event_type' should be used to pretty print the +numeric value in perf_event_header->type and furthermore that it should be used to heuristically +look for structs with the same name (lowercase) of the enum entry that is converted from the +type field, using it to pretty print instead of the base 'perf_event_header' type. See the +PRETTY PRINTING EXAMPLES section below. +.P + +Furthermore the 'filter=' part can be used, so far with only the '==' operator to filter based +on the 'type' field and converting the string 'PERF_RECORD_EXIT' to a number according to +type_enum. +.P + +The 'sizeof' arg defaults to the 'size' member name, if the name is different, one can use + 'sizeof=sz' form, ditto for 'type=other_member_name' field, that defaults to 'type'. + +.SH PRETTY PRINTING EXAMPLES + +.P +Looking at the ELF header for a vmlinux file, using BTF, first lets discover the ELF header type: +.PP +.nf +$ pahole --sizes | grep -i elf | grep -i _h +elf64_hdr 64 0 +elf32_hdr 52 0 +$ +.fi +.P +Now we can use this to show the first record from offset zero: +.PP +.nf +$ pahole -C elf64_hdr --count 1 < /lib/modules/5.8.0-rc3+/build/vmlinux +{ + .e_ident = { 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + .e_type = 2, + .e_machine = 62, + .e_version = 1, + .e_entry = 16777216, + .e_phoff = 64, + .e_shoff = 775923840, + .e_flags = 0, + .e_ehsize = 64, + .e_phentsize = 56, + .e_phnum = 5, + .e_shentsize = 64, + .e_shnum = 80, + .e_shstrndx = 79, +}, +$ +.fi +.P +This is equivalent to: +.PP +.nf +$ pahole --header elf64_hdr < /lib/modules/5.8.0-rc3+/build/vmlinux +.fi +.P +The --header option also allows reference in other command line options to fields in the header. +This is useful when one wants to show multiple records in a file and the range where those fields +are located is specified in header fields, such as for perf.data files: +.PP +.nf +$ pahole --hex ~/bin/perf --header perf_file_header < perf.data +{ + .magic = 0x32454c4946524550, + .size = 0x68, + .attr_size = 0x88, + .attrs = { + .offset = 0xa8, + .size = 0x88, + }, + .data = { + .offset = 0x130, + .size = 0x588, + }, + .event_types = { + .offset = 0, + .size = 0, + }, + .adds_features = { 0x16717ffc, 0, 0, 0 }, +}, +$ +.fi +.P +So to display the cgroups records in the perf_file_header.data section we can use: +.PP +.nf +$ pahole ~/bin/perf --header=perf_file_header --seek_bytes '$header.data.offset' --size_bytes='$header.data.size' -C 'perf_event_header(sizeof,type,type_enum=perf_event_type,filter=type==PERF_RECORD_CGROUP)' < perf.data +{ + .header = { + .type = PERF_RECORD_CGROUP, + .misc = 0, + .size = 40, + }, + .id = 1, + .path = "/", +}, +{ + .header = { + .type = PERF_RECORD_CGROUP, + .misc = 0, + .size = 48, + }, + .id = 1553, + .path = "/system.slice", +}, +{ + .header = { + .type = PERF_RECORD_CGROUP, + .misc = 0, + .size = 48, + }, + .id = 8, + .path = "/machine.slice", +}, +{ + .header = { + .type = PERF_RECORD_CGROUP, + .misc = 0, + .size = 128, + }, + .id = 7828, + .path = "/machine.slice/libpod-42be8e8d4eb9d22405845005f0d04ea398548dccc934a150fbaa3c1f1f9492c2.scope", +}, +{ + .header = { + .type = PERF_RECORD_CGROUP, + .misc = 0, + .size = 88, + }, + .id = 13, + .path = "/machine.slice/machine-qemu\x2d1\x2drhel6.sandy.scope", +}, +$ +.fi +.P +For the common case of the header having a member that has the 'offset' and 'size' members, it is possible to use this more compact form: +.PP +.nf +$ pahole ~/bin/perf --header=perf_file_header --range=data -C 'perf_event_header(sizeof,type,type_enum=perf_event_type,filter=type==PERF_RECORD_CGROUP)' < perf.data +.fi +.P +This uses ~/bin/perf to get the type definitions, the defines 'struct perf_file_header' as the header, +then seeks '$header.data.offset' bytes from the start of the file, and considers '$header.data.size' bytes +worth of such records. The filter expression may omit a common prefix, in this case it could additonally be +equivalently written as both 'filter=type==CGROUP' or the 'filter=' can also be omitted, getting as compact +as 'type==CGROUP': +.P +If we look at: +.PP +.nf +$ pahole ~/bin/perf -C perf_event_header +struct perf_event_header { + __u32 type; /* 0 4 */ + __u16 misc; /* 4 2 */ + __u16 size; /* 6 2 */ + + /* size: 8, cachelines: 1, members: 3 */ + /* last cacheline: 8 bytes */ +}; +$ +.fi +.P +And: +.PP +.nf +$ pahole ~/bin/perf -C perf_event_type +enum perf_event_type { + PERF_RECORD_MMAP = 1, + PERF_RECORD_LOST = 2, + PERF_RECORD_COMM = 3, + PERF_RECORD_EXIT = 4, + PERF_RECORD_THROTTLE = 5, + PERF_RECORD_UNTHROTTLE = 6, + PERF_RECORD_FORK = 7, + PERF_RECORD_READ = 8, + PERF_RECORD_SAMPLE = 9, + PERF_RECORD_MMAP2 = 10, + PERF_RECORD_AUX = 11, + PERF_RECORD_ITRACE_START = 12, + PERF_RECORD_LOST_SAMPLES = 13, + PERF_RECORD_SWITCH = 14, + PERF_RECORD_SWITCH_CPU_WIDE = 15, + PERF_RECORD_NAMESPACES = 16, + PERF_RECORD_KSYMBOL = 17, + PERF_RECORD_BPF_EVENT = 18, + PERF_RECORD_CGROUP = 19, + PERF_RECORD_TEXT_POKE = 20, + PERF_RECORD_MAX = 21, +}; +$ +.fi +.P +And furthermore: +.PP +.nf +$ pahole ~/bin/perf -C perf_record_cgroup +struct perf_record_cgroup { + struct perf_event_header header; /* 0 8 */ + __u64 id; /* 8 8 */ + char path[4096]; /* 16 4096 */ + + /* size: 4112, cachelines: 65, members: 3 */ + /* last cacheline: 16 bytes */ +}; +$ +.fi +.P +Then we can see how the perf_event_header.type could be converted from a __u32 to a string (PERF_RECORD_CGROUP). +If we remove that type_enum=perf_event_type, we will lose the conversion of 'struct perf_event_header' to the +more descriptive 'struct perf_record_cgroup', and also the beautification of the header.type field: +.PP +.nf +$ pahole ~/bin/perf --header=perf_file_header --seek_bytes '$header.data.offset' --size_bytes='$header.data.size' -C 'perf_event_header(sizeof,type,filter=type==19)' < perf.data +{ + .type = 19, + .misc = 0, + .size = 40, +}, +{ + .type = 19, + .misc = 0, + .size = 48, +}, +{ + .type = 19, + .misc = 0, + .size = 48, +}, +{ + .type = 19, + .misc = 0, + .size = 128, +}, +{ + .type = 19, + .misc = 0, + .size = 88, +}, +$ +.fi +.P +Some of the records are not found in 'type_enum=perf_event_type' so some of the records don't get converted to a type that fully shows its contents. For perf we know that those are in another enumeration, 'enum perf_user_event_type', so, for these cases, we can create a 'virtual enum', i.e. the sum of two enums and then get all those entries decoded and properly casted, first few records with just 'enum perf_event_type': +.PP +.nf +$ pahole ~/bin/perf --header=perf_file_header --seek_bytes '$header.data.offset' --size_bytes='$header.data.size' -C 'perf_event_header(sizeof,type,type_enum=perf_event_type)' --count 4 < perf.data +{ + .type = 79, + .misc = 0, + .size = 32, +}, +{ + .type = 73, + .misc = 0, + .size = 40, +}, +{ + .type = 74, + .misc = 0, + .size = 32, +}, +{ + .header = { + .type = PERF_RECORD_CGROUP, + .misc = 0, + .size = 40, + }, + .id = 1, + .path = "/", +}, +$ +.fi +.P +Now with both enumerations, i.e. with 'type_enum=perf_event_type+perf_user_event_type': +.PP +.nf +$ pahole ~/bin/perf --header=perf_file_header --seek_bytes '$header.data.offset' --size_bytes='$header.data.size' -C 'perf_event_header(sizeof,type,type_enum=perf_event_type+perf_user_event_type)' --count 5 < perf.data +{ + .header = { + .type = PERF_RECORD_TIME_CONV, + .misc = 0, + .size = 32, + }, + .time_shift = 31, + .time_mult = 1016803377, + .time_zero = 435759009518382, +}, +{ + .header = { + .type = PERF_RECORD_THREAD_MAP, + .misc = 0, + .size = 40, + }, + .nr = 1, + .entries = 0x50 0x7e 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00, +}, +{ + .header = { + .type = PERF_RECORD_CPU_MAP, + .misc = 0, + .size = 32, + }, + .data = { + .type = 1, + .data = "", + }, +}, +{ + .header = { + .type = PERF_RECORD_CGROUP, + .misc = 0, + .size = 40, + }, + .id = 1, + .path = "/", +}, +{ + .header = { + .type = PERF_RECORD_CGROUP, + .misc = 0, + .size = 48, + }, + .id = 1553, + .path = "/system.slice", +}, +$ +.fi +.P +It is possible to pass multiple types, one has only to make sure they appear in the file +in sequence, i.e. for the perf.data example, see the perf_file_header dump above, one can print +the perf_file_attr structs in the header attrs range, then the perf_event_header in the +data range with the following command: +.PP +.nf +pahole ~/bin/perf --header=perf_file_header \ + -C 'perf_file_attr(range=attrs),perf_event_header(range=data,sizeof,type,type_enum=perf_event_type+perf_user_event_type)' < perf.data +.fi + .SH SEE ALSO \fIeu-readelf\fR(1), \fIreadelf\fR(1), \fIobjdump\fR(1). .P -\fIhttp://oops.ghostprotocols.net:81/acme/7dwarves.pdf\fR. +\fIhttps://www.kernel.org/doc/ols/2007/ols2007v2-pages-35-44.pdf\fR. .SH AUTHOR -\fBpahole\fR was written by Arnaldo Carvalho de Melo . - +\fBpahole\fR was written and is maintained by Arnaldo Carvalho de Melo . +.P +Thanks to Andrii Nakryiko and Martin KaFai Lau for providing the BTF encoder +and improving the codebase while making sure the BTF encoder works as needed +to be used in encoding the Linux kernel .BTF section from the DWARF info +generated by gcc. For that Andrii wrote a BTF deduplicator in libbpf that is +used by \fBpahole\fR. +.P +Also thanks to Conectiva, Mandriva and Red Hat for allowing me to work on these tools. +.P Please send bug reports to . .P -No\ subscription is required. +No subscription is required. diff -Nru dwarves-dfsg-1.10/NEWS dwarves-dfsg-1.21/NEWS --- dwarves-dfsg-1.10/NEWS 2012-05-30 18:39:32.000000000 +0000 +++ dwarves-dfsg-1.21/NEWS 2021-04-09 19:10:33.000000000 +0000 @@ -1,3 +1,545 @@ +v1.21: + +Fri Apr 9 2021 + +ae0b7dde1fd50b12 dwarf_loader: Handle DWARF5 DW_OP_addrx properly +9adb014930f31c66 dwarf_loader: Handle subprogram ret type with abstract_origin properly +5752d1951d081a80 dwarf_loader: Check .notes section for LTO build info +209e45424ff4a22d dwarf_loader: Check .debug_abbrev for cross-CU references +39227909db3cc2c2 dwarf_loader: Permit merging all DWARF CU's for clang LTO built binary +763475ca1101ccfe dwarf_loader: Factor out common code to initialize a cu +d0d3fbd4744953e8 dwarf_loader: Permit a flexible HASHTAGS__BITS +ffe0ef4d73906c18 btf: Add --btf_gen_all flag +de708b33114d42c2 btf: Add support for the floating-point types +4b7f8c04d009942b fprintf: Honour conf_fprintf.hex when printing enumerations +f2889ff163726336 Avoid warning when building with NDEBUG +8e1f8c904e303d5d btf_encoder: Match ftrace addresses within ELF functions +9fecc77ed82d429f dwarf_loader: Use a better hashing function, from libbpf +0125de3a4c055cdf btf_encoder: Funnel ELF error reporting through a macro +7d8e829f636f47ab btf_encoder: Sanitize non-regular int base type + +v1.20: + +Tue Feb 2 2021 + +8d6f06f053a06829 (HEAD -> master, seventh/master, quaco/master, origin/master, origin/HEAD) dwarf_loader: Add conditional DW_FORM_implicit_const definition for older systems +66d12e4790b7c5e5 dtagnames: Stop using the deprecated mallinfo() function +1279e439b622aeb5 cmake: Bump minimum required version to 2.8.12 as per upstream support warning +b1eaf0da6d1f72b2 dwarves: Make enum prefix search more robust +d783117162c0212d dwarf_loader: Handle DWARF5 DW_TAG_call_site like DW_TAG_GNU_call_site +3ff98a6396e91d0a dwarf_loader: Support DW_FORM_implicit_const in __attr_offset() +b91b19840b0062b8 dwarf_loader: Support DW_AT_data_bit_offset +c692e8ac5ccbab99 dwarf_loader: Optimize a bit the reading of DW_AT_data_member_location +65917b24942ce620 dwarf_loader: Fix typo +77205a119c85e396 dwarf_loader: Introduce __attr_offset() to reuse call to dwarf_attr() +8ec231f6b0c8aaef dwarf_loader: Support DW_FORM_implicit_const in attr_numeric() +7453895e01edb535 btf_encoder: Improve ELF error reporting +1bb49897dd2b65b0 bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values +3f8aad340bf1a188 elf_symtab: Handle SHN_XINDEX index in elf_section_by_name() +e32b9800e650a6eb btf_encoder: Add extra checks for symbol names +82749180b23d3c9c libbpf: allow to use packaged version +452dbcf35f1a7bf9 btf_encoder: Improve error-handling around objcopy +cf381f9a3822d68b btf_encoder: Fix handling of restrict qualifier +b688e35970600c15 btf_encoder: fix skipping per-CPU variables at offset 0 +8c009d6ce762dfc9 btf_encoder: fix BTF variable generation for kernel modules +b94e97e015a94e6b dwarves: Fix compilation on 32-bit architectures +17df51c700248f02 btf_encoder: Detect kernel module ftrace addresses +06ca639505fc56c6 btf_encoder: Use address size based on ELF's class +aff60970d16b909e btf_encoder: Factor filter_functions function +1e6a3fed6e52d365 rpm: Fix changelog date + +v1.19: + +Fri Nov 20 2020 + +bf21da407593f104 fprintf: Make typedef__fprintf print anonymous enums +9c4bdf9331bf06a7 fprintf: Align enumerators +89cf28228a8ab55e fprintf: Add enumeration__max_entry_name_len() +932b84eb45a9b8ba fprintf: Make typedef__fprintf print anonymous structs +4a1479305b53933d pahole: Add heuristic to auto-add --btf_base for /sys/kernel/btf/ prefixed files +e1d01045828a5c4c btf: Fallback to raw BTF mode if the header magic matches +24cea890abedb15b pahole: Force '-F btf' with --btf_base +cfad738682506ce4 libbtf: Assume its raw_btf if filename starts with "/sys/kernel/btf/" +7293c7fceac36844 pahole: The --btf_base option receives a PATH, not a SIZE +b3dd4f3c3d5ea59e btf_encoder: Use better fallback message +d06048c53094d9d2 btf_encoder: Move btf_elf__verbose/btf_elf__force setup +8156bec8aedb685b btf_encoder: Fix function generation +d0cd007339ee509e btf_encoder: Generate also .init functions +25753e0396abea25 pfunct: Use load stealer to speed up --class +aa8fb8c091446467 man-pages: Add entry for -J/--btf_encode to pahole's man page +ace05ba9414c1fe4 btf: Add support for split BTF loading and encoding +7290d08b4a6e5876 libbpf: Update libbpf submodule reference to latest master +344f2483cfcd4952 libbtf: Improve variable naming and error reporting when writing out BTF +94a7535939f92e91 btf_encoder: Fix array index type numbering +9fa3a100f71e7a13 pfunct: Use a load stealer to stop as soon as a function is found +de18bd5fe3515358 pfunct: Try sole argument as a function name, just like pahole +bc1afd458562f21e pahole: Introduce --numeric_version for use in scripts and Makefiles +784c3dfbd63d5bcf dwarves: Switch from a string based version to major/minor numbers +fc06ee1b6e9dc14a pahole: Check if the sole arg is a file, not considering it a type if so +f47b3a2df3622204 dwarf_loader: Fix partial unit warning +5a22c2de79fb9edf btf_encoder: Change functions check due to broken dwarf +7b1af3f4844b36b9 btf_encoder: Move find_all_percpu_vars in generic collect_symbols +863e6f0f2cc08592 btf_encoder: Check var type after checking var addr. +5e7ab5b9e064a3eb btf_loader: Handle union forward declaration properly +ec3f944102a71241 cmake: Make libbpf's Linux UAPI headers available to all binaries +8cac1c54c83c346b btf_encoder: Ignore zero-sized ELF symbols +040fd7f585c9b9fc btf_encoder: Support cross-compiled ELF binaries with different endianness +29fce8dc8571c6af strings: use BTF's string APIs for strings management +75f3520fedf6afdb strings: Rename strings.h to avoid clashing with /usr/include/strings.h +bba7151e0fd2fb3a dwarf_loader: increase the size of lookup hash map +2e719cca66721284 btf_encoder: revamp how per-CPU variables are encoded +0258a47ef99500db btf_encoder: Discard CUs after BTF encoding +3c913e18b2702a9e btf_encoder: Fix emitting __ARRAY_SIZE_TYPE__ as index range type +48efa92933e81d28 btf_encoder: Use libbpf APIs to encode BTF type info +5d863aa7ce539e86 btf_loader: Use libbpf to load BTF +0a9b89910e711951 dwarves: Expose and maintain active debug info loader operations +7bc2dd07d51cb5ee btf_encoder: detect BTF encoding errors and exit +c35b7fa52cb8112a libbpf: Update to latest libbpf version +ef4f971a9cf745fc dwarf_loader: Conditionally define DW_AT_alignment +cc3f9dce3378280f pahole: Implement --packed +08f49262f474370a man-pages: Fix 'coimbine' typo + +v1.18: + +Fri 02 Oct 2020 + +aee6808c478b760f btf_loader: Initialize function->lexblock.tags to fix segfault in pdwtags +c815d26689313d8d btf_encoder: Handle DW_TAG_variable that has DW_AT_specification +b8068e7373cc1592 pahole: Only try using a single file name as a type name if not encoding BTF or CTF +8b1c63283194ebe1 libctf: Make can't get header message to appear only in verbose mode +63e11400e80f6ac4 libbtf: Make can't get header message to appear only in verbose mode +fc2b317db0bdc1a9 dwarf_loader: Check for unsupported_tag return in last two missing places +2b5f4895e8968e83 dwarf_loader: Warn user about unsupported TAGs +010a71e181b450d7 dwarf_loader: Handle unsupported_tag return in die__process_class() +3d616609ee0fd6df dwarf_loader: Add minimal handling of DW_TAG_subrange_type +2e8cd6a435d96335 dwarf_loader: Ignore DW_TAG_variant_part for now to fix a segfault +e9e6285fd0d63ed0 dwarf_loader: Skip empty CUs +1abc001417b579b8 btf_encoder: Introduce option '--btf_encode_force' +da4ad2f65028e321 btf_encoder: Allow disabling BTF var encoding. +f5847773d94d4875 fprintf: Support DW_TAG_string_type +8b00a5cd677df778 dwarf_loader: Support DW_TAG_string_type +0d9c3c9835659fb7 dwarves: Check if a member type wasn't found and avoid a NULL deref +2ecc308518edfe05 dwarf_loader: Bail out at DW_TAG_imported_unit tags +8c92fd298101171d dwarf_loader: Ignore entries in a DW_TAG_partial_unit, for now +4cfd420f7ef13af4 README: Add instructions to do a cross build +9e495f68c683574f dwarf_loader: Move vaddr to conditional where it is used +69fce762074a5483 pahole: Use "%s" in a snprintf call +22f93766cf02f4e0 pahole: Support multiple types for pretty printing +78f2177d904902c6 pahole: Print the evaluated range= per class +5c32b9d5c7ac8fff pahole: Count the total number of bytes read from stdin +e3e5a4626c94d9c5 pahole: Make sure the header is read only once +208bcd9873442013 pahole: Introduce 'range=member' as a class argument for pretty printing +b9e406311990c2d5 pahole: Cache the type_enum lookups into struct enumerator +fda1825f0b9f1c9f dwarves: Introduce tag_cu_node, so that we can have the leaner tag_cu +47d4dd4c8a2cf9fd pahole: Optimize --header processing by keeping the first successfull instance +fdfc64ec44f4ad53 pahole: Introduce --range +f63d3677e31d88a3 pahole: Support multiple enums in type_enum= +c50b6d37e99fddec pahole: Add infrastructure to have multiple concatenated type_enum +671ea22ca18dd41f pahole: Move finding type_enum to a separate function +dd3c0e9eb0cbc77f dwarves: Move the common initialization of fields for 'struct type' +aa7ab3e8755a4c12 pahole: Allow for more compact enum filters by suppressing common prefix +4ece15c37b028a80 dwarves: Find common enumerators prefix +d28bc97b5c12736b man-pages: Document pretty printing capabilities and provide examples +a345691f08f04f19 pahole: Make --header without -C to be equivalent to -C header-arg --count=1 +eba4ac6b2c1dcb11 pahole: Fallback to pretty printing using types in multiple CUs +7c12b234ee30f6d2 dwarves: Introduce cus__find_type_by_name() +c6f3386e3364486d pahole: Make the type_instance constructor receive the looked up type + its CU +30297256e1f27de5 pahole: Pass the header type_instance to tag__stdio_fprintf_value() +ead8084d3ffcda1f pahole: Store the CU in the type_instance struct +2c886fff0af13510 pahole: Store the CU where type_enum was found +526b116bfec71054 pahole: If pretty printing, don't discard CUs, keep them +a1b8fddb4dcd90d9 pahole: Show which classes were not processed and why +bc6a3cac50cdbdf6 pahole: Fixup the --class_name parsing wrt class args (type=, sizeof=, etc) +363c37340521debe pahole: Remope pretty printed classes from the prototypes list +9f675e7fdbf525fb cmake: Use -O0 for debug builds +4e5b02beea24656d pahole: Don't stop when not finding the type_enum +823739b56f2b5230 pahole: Convert class_names into a list of struct prototypes +0a97d6c143fcc92a pahole: Factor out parsing class prototypes +80af0fbbf3a3f1f6 dutils: Allow for having a priv area per strlist +04b6547e7343410e pahole: Honour --hex_fmt when pretty printing +266c0255984ddbe7 pahole: Support filters without 'filter=' +6c683ce0e11d6c1c pahole: Allow for a 'type' boolean class arg meaning 'type=type' +1c68f41bb87f7718 pahole: Allow for a 'sizeof' boolean class arg meaning 'sizeof=size' +b4b3fb0a3aeb9686 pahole: First look for ',' then '=' to allow for boolean args +446b85f7276bda4c pahole: Add support for --size_bytes, accepts header variables +0f10fa7529d4a9c7 pahole: Move reading the header to outside the --seek_bytes code +9310b04854a8b709 pahole: Add support for referencing header variables when pretty printing +611f5e8bd7eb760d pahole: Add == class member filtering +f2987224beb2b496 pahole: Do the 'type_enum' class argument validation as soon as we parse it +02ca176c6290ff96 pahole: Do the 'type' class argument validation earlier +172d743d9ce3f3a1 pahole: Do the 'sizeof' class argument validation earlier +9a30c101d7c019ee pahole: As soon as a attribute is found, check if the type is a struct or class +a38ccf47237298dc pahole: Allow filter=expression as a class argument for pretty printing +3c4ee1d91f5311ac pahole: Pretty print bitfields +451d66ec02e94492 pahole: Pretty print unions too, cope with unnamed ones +48c7704b49ffa6b1 pahole: Check if the type with arguments is present in the current CU +472519ac2c49d340 pahole: Support nested structs +ae43029363ee2c53 dwarves_fprintf: Export the 'tabs' variable +ab714acec86841b7 pahole: Support zero sized base type arrays +ff7815a0f823a676 pahole: Add missing space before '}' in array__fprintf_base_type_value() +5f2502274e1097db pahole: Support zero sized arrays in array__fprintf_base_type_value() +3aadfbdd72e32016 pahole: Follow array type typedefs to find real sizeof(entry) +7309039aa7510eec pahole: Make 'type' + 'type_enum' select a type to cast a variable sized record +42b7a759f37e5d45 dutil: Add a strlwr() helper to lowercase a string, returning it +a5bb31b86fbe5362 pahole: Fix --skip for variable sized records +f4df384d77312867 pahole: Decouple reading ->sizeof_member from printing +78cdde5cb7200555 pahole: Introduce 'type_enum' class argument +163c330d3138e56f dwarves: Introduce cu__find_enumeration_by_name() +20051b7157fce20c pahole: Add the 'type' modifier to make a struct member be used to find a cast type +210dffe0d13d171b pahole: Iterate classes in the order specified in the command line: +37a5c7c5ba0e1e7d strlist: Allow iterating a strlist in the original order +6b5d938d99b2e457 pahole: Support multiple class/struct args +affbebf04bcaa1ec pahole: Make the class splitter take into account per-class parameters +84387de4a5cf141d pahole: Allow specifying a struct member based sizeof() override +e0773683fa3edd61 dwarves: Allow setting a struct/class member as the source of sizeof() +f399db09a0d5b069 pahole: Allow simple parser for arguments to classes +04d957ba3cdf1047 pahole: Add variable for class name when traversing list of classes +f3d9054ba8ff1df0 btf_encoder: Teach pahole to store percpu variables in vmlinux BTF. +fe284221448c950d pahole: Introduce --seek_bytes +44af7c02b5d0a7f2 pahole: Implement --skip, just like dd +5631fdcea1bbe2bc pahole: Introduce --count, just like dd's +272bc75024b4f08c man-pages: Add information about stdin raw data pretty printing +66835f9e190ce77e pahole: Add support for base type arrays +1a67d6e70090953d pahole: Factor out base_type__fprintf_value() +6fb98aa1209f02b5 pahole: Support char arrays when dumping from stdin +a231d00f8d08825e pahole: Print comma at the end of field name + field value +1b2cdda38c0a6f5e dwarves: Introduce tag__is_array() +a83313fb22520d8d pahole: Pretty print base types in structs from stdin +cc65946e3068f7b6 dwarves: Adopt tag__is_base_type() from ctrace.c +d8079c6d373a5754 pahole: Hex dump a type from stdio when it isn't a tty +38109ab45fe0307d spec: Fix date + +v1.17: + +Fri 13 Mar 2020 + +f14426e41046 docs: Add command line to generate tarball with a prefix +0b2621d426ea dwarves: Avoid truncation when concatenating paths for dir entries +d7b351079583 dwarves: Don't use conf if its NULL in cus__load_running_kernel() +dde3eb086dd3 dwarves: Make list__for_all_tags() more robust +081f3618a795 dwarves: Add -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 to build libbpf +e8f43a4963bf libbpf: Get latest libbpf +de84ae36c738 cmake: libebl was merged into libdw +290b8fdbdab7 pahole: Improve --contains --recursive a bit +3d5be866e55f pahole: Fill 'tab' with spaces earlier +88674f039551 gobuffer: Do not crash on object without any public symbols +cb17f94f46a0 Add changes-v1.16 to the MANIFEST file +32a19e044c93 pahole: Fix changelog date in dwarves.spec +9b09f578b7d1 pahole: Initialize var to silence -Werror=maybe-uninitialized on gcc version 4.8.5 20150623 +277c2b3d1b4a man-pages: Add section about --hex + -E to locate offsets deep into sub structs +812c980b3f76 man-pages: Update some info, expand BTF info, add some EXAMPLES +e0942c7b031f pahole: Add support for finding pointers to void +6a326e93088e pahole: Make --contains and --find_pointers_to to work with base types +3c1a9a3329d9 pahole: Make --contains look for more than just unions, structs +ded5d36f9cf5 dwarves: Introduce cu__find_type_by_name +88d99562e55c pahole: Add --structs to ask just for structs, counterpart of --unions +0b444cf1118c pahole: Make --contains and --find_pointers_to honour --unions +a8a7e605bb45 pahole: Make --find_pointers_to consider unions +0dc327e382f8 pahole: Consider unions when looking for classes containing some class +3661f17d0b2c pahole: Introduce --unions to consider just unions +2dd09c617101 pahole: union have no holes, fix --sizes formatter +6c29cca8c28f pahole: Don't consider unions for options that only make sense for structs +dcba200367f7 pahole: When the sole argument passed isn't a file, take it as a class name +1944de0c93e6 pahole: Use function__for_each_parameter() +66e640508e4d dwarves: Make function__for_each_parameter receive 'cu' arg +252b0fcc91cc pahole: Fix -m/--nr_methods - Number of functions operating on a type pointer +202c8d5f5bd5 pahole: Do not require a class name to operate without a file name +617f5ac2e6c9 dwarves: Move BTF loader ahead of the CTF one +cdd5e1399b9c btf loader: Support raw BTF as available in /sys/kernel/btf/vmlinux + +v1.16: + +Mon Dec 16 2019 + +69df73444c69 (HEAD -> master, acme.korg/master) dwarves: Add -O2 to CFLAGS +6d11dd157f75 elfcreator: Address initialization warning emitted by 'gcc -O6' +1bc63a4cffa7 fprintf: Fixup truncation possibility pointed out by gcc -O2 +5c590fc29d06 ptr_table: Zero out new id ranges +644466dce77f fprintf: Remove extraneous sizeof operator +a59459bb80e7 fprintf: Account inline type __aligned__ member types for spacing +56547f133a5b fprintf: Fix alignment of class members that are structs/enums/unions +be37b64aef38 dwarves: Ignore static members for alignment +cca018e495a8 SPEC: Add dwarves dependency on libdwarves1 +ccf3eebfcd9c btf_loader: Add support for BTF_KIND_FUNC +f95fd85f7b53 pfunct: type->type == 0 is void, fix --compile for that +3e8f09e304ba (origin/master, origin/HEAD) pdwtags: Print DW_TAG_subroutine_type as well +3c5f2a224aa1 btf_encoder: Preserve and encode exported functions as BTF_KIND_FUNC +910e060b5c4b btf_loader: Skip BTF_KIND_DATASEC entries +96235a74a34d btf_loader: Replace if/else series with a proper switch {} +a4ba2234ff58 btf_loader: Support BTF_KIND_VAR +5965ce015eab dwarves: Fix ptr_table__add_with_id() handling of pt->nr_entries +173911ac38ea btf_loader: Show the unknown kind numbers +0d8e11e8568e pglobal: Allow passing the format path specifier, to use with BTF +ba27df9f2f94 CMakeLists: Use lib/bpf/include/uapi when building libdwarves +95517e1d995e libbpf: Get latest libbpf +ca294eebfc47 MANIFEST: Add missing files +d5e01d10e515 fprintf: Set tconf.type_spacing earlier +c6a9a0eb6ac7 fprintf: Fix up decrementing recursivity level in type__fprintf() +93c3cdf89715 cmake: Add -Wall to CFLAGS +7360f0528ff3 elfcreator: Remove unused 'machine' variable +0f52b11f911c prefcnt: Avoid ambiguous else with for_each macro +608813d0affa pglobal: Avoid ambiguous else +77d06c2d305d reorganize: Enclose bitfield routines under ifdef +2221ae30bce9 reorganize: Ditch unused variable +c419c513eae5 libbtf: Enlarge the 'cmd' buffer to not possibly truncate the pathname +092fffe56701 btf_loader: Enum values are s32, cast before calling btf_elf__get32() +7bfb1aa80f9a libctf: Enlarge the 'cmd' buffer to not possibly truncate the pathname +f67c281f9841 fprintf: Correct the type for the 'cacheline' variable, it should be uint32_t +7b36fab5a8df fprintf: Add guard against unlikely overlapping copy +e737976c09d9 fprintf: Do not scrub type when looking up its type +e95dacb704bf fprintf: Remove unused printf arg when printing enumerations +71c4f83f2828 emit: Remove unused 'is_pointer' variable +fe87354c31bb dwarves: Ditch unused asprintf() function +60c73a769882 dwarves: We need to consistently check if 'conf was specified +5fdfd09a6bbe dwarves: Fix check in type__find_first_biggest_size_base_type_member() +24ced5be8a75 dwarf_loader: Fix array overrun access +33e2d7aa35a7 ctf_loader: Plug leak when bailing out due to unknown tag +aefa9303818b codiff: Remove unused filenames variable +de5e72bc15fb btf_loader: Plug leak when bailing out due to unknown tag +511a79129494 dwarves: Remove unused variable +b1412a88bb61 fprintf: Fixup handling classes with no members +[acme@quaco pahole]$ + +v1.15 + +Thu Jun 27 2019 + +3ed9a67967cf fprintf: Avoid null dereference with NULL configs +568dae4bd498 printf: Fixup printing "const" early with "const void" +68f261d8dfff fprintf: Fix recursively printing named structs in --expand_types +139a3b337381 ostra: Initial python3 conversion +01276a7e8966 spec: Sync spec with fedora's +9f1f0628b9ad rpm: Add missing devel headers +989dc3f1ba0d cmake: Install missing devel headers + +v1.13 + +Tue Apr 16 2019 + +See changes-v1.13 for a more verbose description of the changes. + +0fb727166a0e pfunct: Strip inlines in the code generated for --compile +7b967744db7b emit: Emit the types for inline structs defined in pointer members +30526e2848db fprintf: Print relative offsets for inner pointer structs +cfa377c238f8 emit: Do not emit a forward declararion to a nameless struct +cf459ca16fb2 fprintf: Pretty print struct members that are pointers to nameless structs +09ed2e78befe pfunct: Emit definitions for pointers inside pointer to function args +e9fc2f647026 fullcircle: Check that we found the CFLAGS +05921c47f557 emit: Handle typedefs that are a pointer to typedefs +87af9839bf63 fullcircle: Try building from pfunct --compile and check types +c7fd9cc1fe97 pfunct: Fixup more return types +56c50b8dbe9b emit: Make find_fwd_decl a bit more robust +2bcb01fc2f9d fprintf: Handle single zero sized array member structs +0987266cd9e2 fprintf: Deal with zero sized arrays in the midle of a union +1101337a7450 fprintf: Deal with zero sized arrays in the middle of a struct +13aa13eb0ca4 fprintf: Don't reuse 'type' in multiple scopes in the same function +c8fc6f5a7a46 core: Use unnatural alignment of struct embedded in another to infer __packed__ +6f0f9a881589 fprintf: Fixup multi-dimensional zero sized arrays const handling +9a4d71930467 fprintf: Allow suppressing the inferred __attribute__((__packed__)) +ec935ee422b0 fprintf: Allow suppressing the output of force paddings at the end of structs +8471736f3c6c core: Cope with zero sized types when looking for natural alignment +986a3b58a869 fprintf: Only add bitfield forced paddings when alignment info available +49c27bdd6663 core: Allow the loaders to advertise features they have +dc6b9437a3a0 emit: Handle structs with DW_AT_alignment=1 meaning __packed__ +f78633cfb949 core: Infer __packed__ for union struct members +75c52de9c6df core: Move packed_attribute_inferred from 'class' to 'type' class +1bb4527220f4 fprintf: Fixup const pointers +dc3d44196103 core: Improve the natural alignment calculation +ac32e5e908ba codiff: Fix comparision of multi-cu against single-cu files +f2641ce169d6 core: Take arrays into account when inferring if a struct is packed +85c99369631a fprintf: Do not add explicit padding when struct has __aligned__ attr +b5e8fab596d3 emit: Cover void ** as a function parameter +28a3bc7addad fprintf: Support packed enums +f77a442f09e3 fprintf: Do not print the __aligned__ attribute if asked +ea583dac52f0 fprintf: Print zero sized flat arrays as [], not [0] +f909f13dd724 fprintf: Fixup handling of unnamed bitfields +3247a777dcfc core: Infer if a struct is packed by the offsets/natural alignments +13e5b9fc00ee fprintf: Add unnamed bitfield padding at the end to rebuild original type +ccd67bdb205b fprintf: Print "const" for class members more early, in type__fprintf() +b42d77b0bbda fprintf: Print __attribute__((__aligned__(N))) for structs/classes +1c9c1d6bbd45 dwarf_loader: Store DW_AT_alignment if available in DW_TAG_{structure,union,class}_type +41c55858daf4 codiff: Add --quiet option +a104eb1ea11d fprintf: Notice explicit bitfield alignment modifications +75f32a24c7c7 codiff: Improve the comparision of anonymous struct members +6b1e43f2c1ac codiff: When comparing against a file with just one CU don't bother finding by name +15a754f224f7 core: Add nr_entries member to 'struct cus' +99750f244cb8 pfunct: Generate a valid return type for the --compile bodies +881aabd6fc22 reorganize: Introduce class__for_each_member_from_safe() +1b2e3389f304 reorganize: Introduce class__for_each_member_reverse() +10fef2916dce reorganize: Introduce class__for_each_member_continue() +e7a56ee8cc69 reorganize: Introduce class__for_each_member_from() +9a79bb6ced23 tag: Introduce tag__is_pointer_to() +45ad54594442 tag: Introduce tag__is_pointer() +89ce57a02e3a pdwtags: Find holes in structs +ce6f393bc9ea fprintf: Fixup the printing of const parameters +7aec7dd6c29c pfunct: Do not reconstruct external functions +163b873f81c8 pfunct: Do not reconstruct inline expansions of functions +ea83b780eca0 pfunct: Handle unnamed struct typedefs +e7ebc05d12e1 emit: Unwind the definitions for typedefs in type__emit_definitions() +093135b0bfd5 pfunct: Do not emit a type multiple times +3ce2c5216612 pfunct: Ask for generating compilable output that generates DWARF for types +e7a786540d83 pfunct: Make --expand_types/-b without -f expand types for all functions +9b2eadf97b44 pfunct: Follow const, restrict, volatile in --expand_types +f3f86f2f89b0 pfunct: Reconstruct function return types for --expand_types +a7d9c58cb81a fprintf: Add missing closing parens to the align attribute +d83d9f578fa0 dwarf_loader: Handle DW_TAG_label in inline expansions +73e545b144b4 dwarf_loader: Handle unsupported_tag in die__process_inline_expansion +fe590758cb3f class__find_holes: Zero out bit_hole/hole on member +863c2af6e9d7 reorganize: Disable the bitfield coalescing/moving steps +b95961db697a fprintf: Show statistics about holes due to forced alignments +ec772f21f681 fprintf: Show the number of forced alignments in a class +52d1c75ea437 btfdiff: Use --suppress_aligned_attribute with -F dwarf +6cd6a6bd8787 dwarves_fprintf: Allow suppressing the __attribute__((__aligned__(N)) +f31ea292e3cb dwarf_loader: Store the DW_AT_alignment if available +c002873c4479 dwarves_fprintf: Move invariant printing of ; to outside if block +8ce85a1ad7f0 reorganize: Use class__find_holes() to recalculate holes +5d1c4029bd45 dwarves: Fix classification of byte/bit hole for aligned bitfield +78c110a7ea24 dwarves: Revert semantics of member bit/byte hole +b56fed297e5f dwarves_fprintf: Count bitfield member sizes separately +c0fdc5e685e9 dwarf_loader: Use DWARF recommended uniform bit offset scheme +5104d1bef384 loaders: Record CU's endianness in dwarf/btf/ctf loaders +975757bc8867 dwarves: Use bit sizes and bit/byte hole info in __class__fprintf +1838d3d7623e dwarves: Revamp bit/byte holes detection logic +03d9b6ebcac7 dwarf_loader: Fix bitfield fixup logic for DWARF +4abc59553918 btf_loader: Adjust negative bitfield offsets early on +41cf0e3cba0c dwarf_loader: Don't recode enums and use real enum size in calculations +55c96aaed8ce loaders: Strip away volatile/const/restrict when fixing bitfields +7005757fd573 libbpf: Sync in latest libbpf sources +69970fc77ec5 pahole: Filter out unions when looking for packable structs +fa963e1a8698 dwarves_fprintf: Print the bit_offset for inline enum bitfield class members +bb8350acf52f dwarves: Switch type_id_t from uint16_t to uint32_t +5375d06faf26 dwarves: Introduce type_id_t for use with the type IDs +f601f6725890 libctf: The type_ids returned are uint32_t fixup where it was uint16_t +c9b2ef034f89 dwarf: Add cu__add_tag_with_id() to stop using id == -1 to allocate id +762e7b58f447 dwarves: Change ptr_table__add() signature to allow for uint32_t returns +079e6890b788 dwarf_loader: Mark tag__recode_dwarf_bitfield() static +3526ebebd3ab pahole: Use 32-bit integers for type ID iterations within CU +3bd8da5202e4 libbpf: update reference to bring in btf_dedup fixes +a9afcc65fc8f btf_encoder: Don't special case packed enums +8f4f280163b7 btf_loader: Simplify fixup code by relying on BTF data more +be5173b4df0f dwarves: Fixup sizeof(long double) in bits in base_type_name_to_size table +5081ed507095 dwarves: Add _Float128 base_type +d52c9f9b9455 dwarf_loader: Fixup bitfield entry with same number of bits as its base_type +6586e423d4fa btf_loader: Fix bitfield fixup code +7daa4300d230 pahole: Complete list of base type names +6bcf0bd70305 btfdiff: Support specifying custom pahole location +88028b5d0c32 btfdiff: Use --show_private_classes with DWARF +e6c59bd11d3d libbpf: Build as PIC and statically link into libdwarves +cf4f3e282d64 cmake: Bump miminum required version to use OBJECT feature +5148be53dc65 btfdiff: Rename tmp files to contain the format used +dd3a7d3ab3e8 btf_encoder: run BTF deduplication before writing out to ELF +54106025cd14 libbtf: Fixup temp filename to .btf, not .btfe +e6dfd10bcbf3 libbpf: Build as shared lib +c234b6ca6e55 libbpf: Pull latest libbpf +fe4e1f799c55 btf_elf: Rename btf_elf__free() to btf_elf__delete() +6780c4334d55 btf: Rename 'struct btf' to 'struct btf_elf' +ca86e9416b8b pahole: use btf.h directly from libbpf +21507cd3e97b pahole: add libbpf as submodule under lib/bpf +c25ada500ddc pahole: Add build dir, config.h to .gitignore +a58c746c4c7e Fixup copyright notices for BTF files authored by Facebook engineers +e714d2eaa150 Adopt SPDX-License-Identifier +c86960dce55d btf_loader: We can set class_member->type_offset earlier +278b64c3eee0 btfdiff: Use diff's -p option to show the struct/union +1182664d6aa6 dwarves_fprintf: Handle negative bit_offsets in packed structs with bitfields +b0cf845e02c6 dwarves: Change type of bitfield_offset from uint8_t to int8_t +06e364bc62e7 btfdiff: Add utility to compare pahole output produced from DWARF and BTF +b79db4cab41c dwarves: add __int128 types in base_type_name_to_size +de3459cc0ebe btf_loader: BTF encodes the size of enums as bytes not bits +693347f8def7 btf_encoder: Fix void handling in FUNC_PROTO. +2d0b70664f3e dwarves_fprintf: Separate basic type stats into separate type__fprintf() method +18f5910f96e0 dwarves: Add type to tag helper +f2092f56586a btf: recognize BTF_KIND_FUNC in btf_loader +11766614096c btf: Fix kind_flag usage in btf_loader +68b93e6858ae dutil: Add missing string.h header include +851ef335e328 dutil: Drop 'noreturn' attribute for ____ilog2_NaN() +ab0cb33e54e8 btf_loader: Fixup class_member->bit_offset for !big_endian files +b24718fe27d3 dwarves: Fix documentation for class_memer->bitfield_size +3ffe5ba93b63 pahole: Do not apply 'struct class' filters to 'struct type' +da18bb340bee dwarves: Check if the tag is a 'struct class' in class__find_holes() +2a82d593be81 btf: Add kind_flag support for btf_loader +472256d3c57b btf_loader: Introduce a loader for the BTF format +93d6d0016523 dwarves: No need to print the "signed ", the name has it already +0a9bac9a3e8e dwarves: Relookup when searching for signed base types +a2cdc6c2a0a3 dutil: Adopt strstart() from the linux perf tools sources +3aa3fd506e6c btf: add func_proto support +8630ce404287 btf: fix struct/union/fwd types with kind_flag +65bd17abc72c btf: Allow multiple cu's in dwarf->btf conversion +d843945ba514 pahole: Search for unions as well with '-C' +da632a36862c dwarves: Introduce {cu,cus}__find_struct_or_union_by_name() methods +31664d60ad41 pahole: Show tagged enums as well when no class is specified +b18354f64cc2 btf: Generate correct struct bitfield member types +70ef8c7f07ff dwarves_fprintf: Set conf.cachelinep in union__fprintf() too +bfdea37668c6 dwarves_fprintf: Print the scope of variables +465110ec99d3 dwarves: Add the DWARF location to struct variable +c65f2cf4361e dwarves: Rename variable->location to ->scope +0d2511fd1d8e btf: Fix bitfield encoding +92417082aad3 MANIFEST: Add missing COPYING file +eb6bd05766f5 dwarf_loader: Process DW_AT_count in DW_TAG_subrange_type + +v1.12 + +Thu Aug 16 2018 + +1ca2e351dfa1 README.btf: Add section on validating the .BTF section via the kernel +9eda5e8163ce README.btf: No need to use 'llvm.opts = -mattr=dwarfris' with elfutils >= 0.173 +7818af53f64a dwarves: Add a README.btf file with steps to test the BTF encoder +f727c22191d0 dwarf_loader: Initial support for DW_TAG_partial_unit +e975ff247aa8 dwarves_fprintf: Print cacheline boundaries in multiple union members +68645f7facc2 btf: Add BTF support +81466af0d4f8 pahole: Show the file where a struct was used +2dd87be78bb2 dwarves_fprintf: Show offsets at union members +66cf3983e1ac README.DEBUG: Add an extra step to make the instructions cut'n'exec +2a092d61453c dwarves: Fix cus__load_files() success return value +02a456f5f54c pahole: Search and use running kernel vmlinux when no file is passed +5f057919a0c0 man-pages: Add entry for --hex + +v1.11 + +Wed Jun 2017 + +5a57eb074170 man-pages: Update URL to the dwarves paper +b52386d041fa dwarves_fprintf: Find holes when expanding types +103e89bb257d dwarves_fprintf: Find holes on structs embedded in other structs +ab97c07a7ebe dwarves_fprintf: Fixup cacheline boundary printing on expanded structs +046ad67af383 dwarves_fprintf: Shorten class__fprintf() sig +44130bf70e1c dwarves: Update e-mail address +327757975b94 dwarf_loader: Add URL for template tags description +f4d5e21fd1b2 dwarf_loader: Tidy up template tags usage +e12bf9999944 dwarf_loader: Do not hash unsupported tags +3afcfbec9e08 dwarf_loader: Add DW_TAG_GNU_formal_parameter_pack stub in process_function +55d9b20dbaf6 dwarf_loader: Ignore DW_TAG_dwarf_procedure when processing functions +45618c7ec122 dwarf_loader: Initial support for DW_TAG_unspecified_type +658a238b9890 dwarf_loader: Stop emitting warnings about DW_TAG_call_site +0fbb39291d59 dwarf_loader: Add support for DW_TAG_restrict_type +9df42c68265d dwarves: Initial support for rvalue_reference_type +8af5ccd86d21 dwarves: Use cus__fprintf_load_files_err() in the remaining tools +10515a7c4db7 dwarves: Introduce cus__fprintf_load_files_err() +0e6463635082 pahole: Show more informative message when errno is properly set on error +2566cc2c8715 pdwtags: Show proper error messages for files it can't handle +9f3f67e78679 dwarves: Fix cus__load_files() error return +ae3a2720c3d3 dutil: Add ____ilog2_NaN declaration to silence compiler warning +0b81b5ad4743 Update version in CMakeLists.txt +79536f4f9587 cmake: Use INTERFACE_LINK_LIBRARIES +1decb1bc4a41 dwarf_loader: Check cu__find_type_by_ref result +956343d05a41 Add instructions on how to build with debug info +e71353c3fa0a dwarf_loader: Ignore DW_TAG_dwarf_procedure +189695907242 dwarves_fprintf: Add the missing GNU_ suffix to DWARF_TAG_ created by the GNU project +d973b1d5daf0 dwarf_fprintf: Handle DW_TAG_GNU_call_site{_parameter} +c23eab4b1253 dwarf_loader: Print unknown tags as an hex number +943a0de0679a dwarves_fprintf: DW_TAG_mutable_type doesn't exist. +a8e562a15767 dwarf_loader: Use obstack_zalloc when allocating tag +fd3838ae9aa3 dwarves: Stop using 'self' +5ecf1aab9e10 dwarf_loader: Support DW_FORM_data{4,8} for reading class member offsets +c4ccdd5ae63b dwarves_reorganize: Fix member type fixup +e31fda3063e3 dwarves_reorganize: Fixup calculation of bytes needed for bitfield +1e461ec7e0e8 dwarves_fprintf: Fix printf types on 64bit linux +222f0067a9c3 dwarves_fprintf: Don't ignore virtual data members +e512e3f9b36b dwarves: Update git url +8c6378fd8834 dwarves: Support static class data members +a54515fa6ee4 dwarves: Stop using 'self' +6035b0d91f19 rpm: Add missing BuildRequires: zlib-devel +be7b691756ff dwarf_loader: Don't stop processing after finding unsupported tag + v1.10 Wed May 30 2012 @@ -27,7 +569,7 @@ For full details please take a look at the git changesets, repo available at: -http://git.kernel.org/?p=linux/kernel/git/acme/pahole.git +http://git.kernel.org/cgit/devel/pahole/pahole.git - Arnaldo diff -Nru dwarves-dfsg-1.10/ostra/ostra-cg dwarves-dfsg-1.21/ostra/ostra-cg --- dwarves-dfsg-1.10/ostra/ostra-cg 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/ostra/ostra-cg 2019-05-01 18:23:10.000000000 +0000 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # ostra-cg - generate callgraphs from encoded trace # # Arnaldo Carvalho de Melo @@ -386,7 +386,7 @@ if __name__ == '__main__': if len(sys.argv) not in [ 3, 4 ]: - print "usage: ostra-cg [object]" + print("usage: ostra-cg [object]") sys.exit(1) gen_html = True @@ -402,9 +402,9 @@ class_def = ostra.class_definition(class_def_file = "%s.fields" % traced_class, class_methods_file = "%s.functions" % traced_class) new_callgraph_file(traced_class) - class_def.parse_file(encoded_trace, verbose = verbose, - process_record = process_record, - my_object = my_object) + class_def.parse_file(encoded_trace, verbose = verbose, + process_record = process_record, + my_object = my_object) if gen_html: print_where_fields_changed() close_callgraph_file() diff -Nru dwarves-dfsg-1.10/ostra/python/ostra.py dwarves-dfsg-1.21/ostra/python/ostra.py --- dwarves-dfsg-1.10/ostra/python/ostra.py 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/ostra/python/ostra.py 2019-05-01 18:23:10.000000000 +0000 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # Copyright (C) 2005, 2006, 2007 Arnaldo Carvalho de Melo # @@ -206,7 +206,7 @@ break if verbose: nr_lines += 1 - print "\r%d" % nr_lines, + print("\r%d" % nr_lines,) self.parse_record(line) @@ -245,8 +245,8 @@ continue if verbose: - print "plot_methods: plotting %s method (%d samples)" % \ - (current_method.name, nr_samples) + print("plot_methods: plotting %s method (%d samples)" % \ + (current_method.name, nr_samples)) entries = [float("%d.0" % entry) for entry in range(nr_samples)] samples = current_method.times @@ -323,11 +323,11 @@ if current_plot_fmt == "filter_dev": std = std_deviation(samples) * 2 if verbose: - print "filter_dev(%s) std=%d" % (name, std) + print("filter_dev(%s) std=%d" % (name, std)) for i in range(nr_samples): if samples[i] > std: if verbose: - print "%s: filtering out %d" % (name, samples[i]) + print("%s: filtering out %d" % (name, samples[i])) samples[i] = 0 field_mean = mean(samples) yaxis_plot_fmt = FuncFormatter(pylab_formatter) @@ -376,7 +376,7 @@ continue if verbose: - print "ostra-plot: plotting %s field (%d samples)" % (current_field.name, nr_samples) + print("ostra-plot: plotting %s field (%d samples)" % (current_field.name, nr_samples)) tstamps = [float("%d.%06d" % (entry.tstamp.seconds, entry.tstamp.microseconds)) \ for entry in current_field.changes] @@ -392,6 +392,6 @@ import sys c = class_definition(sys.argv[1], sys.argv[2]) for field in c.fields.values(): - print "%s: %s" % (field, field.table) + print("%s: %s" % (field, field.table)) for method in c.methods.values(): - print "%d: %s" % (method.function_id, method.name) + print("%d: %s" % (method.function_id, method.name)) diff -Nru dwarves-dfsg-1.10/pahole.c dwarves-dfsg-1.21/pahole.c --- dwarves-dfsg-1.10/pahole.c 2012-05-14 22:41:11.000000000 +0000 +++ dwarves-dfsg-1.21/pahole.c 2021-03-12 17:28:52.000000000 +0000 @@ -1,29 +1,36 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo - Copyright (C) 2007-2008 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. + Copyright (C) 2007- Arnaldo Carvalho de Melo */ #include #include #include #include +#include #include #include #include #include +#include #include "dwarves_reorganize.h" #include "dwarves.h" #include "dutil.h" #include "ctf_encoder.h" +#include "btf_encoder.h" +#include "libbtf.h" +#include "lib/bpf/src/libbpf.h" +static bool btf_encode; static bool ctf_encode; static bool first_obj_only; +static bool skip_encoding_btf_vars; +static bool btf_encode_force; +static const char *base_btf_file; static uint8_t class__include_anonymous; static uint8_t class__include_nested_anonymous; @@ -53,16 +60,21 @@ static int reorganize; static bool show_private_classes; static bool defined_in; +static bool just_unions; +static bool just_structs; +static bool just_packed_structs; static int show_reorg_steps; -static char *class_name; -static struct strlist *class_names; +static const char *class_name; +static LIST_HEAD(class_names); static char separator = '\t'; static struct conf_fprintf conf = { .emit_stats = 1, }; -static struct conf_load conf_load; +static struct conf_load conf_load = { + .conf_fprintf = &conf, +}; struct structure { struct list_head node; @@ -74,25 +86,25 @@ static struct structure *structure__new(const char *name) { - struct structure *self = malloc(sizeof(*self)); + struct structure *st = malloc(sizeof(*st)); - if (self != NULL) { - self->name = strdup(name); - if (self->name == NULL) { - free(self); + if (st != NULL) { + st->name = strdup(name); + if (st->name == NULL) { + free(st); return NULL; } - self->nr_files = 1; - self->nr_methods = 0; + st->nr_files = 1; + st->nr_methods = 0; } - return self; + return st; } -static void structure__delete(struct structure *self) +static void structure__delete(struct structure *st) { - free(self->name); - free(self); + free(st->name); + free(st); } static struct rb_root structures__tree = RB_ROOT; @@ -150,48 +162,48 @@ } } -static void nr_definitions_formatter(struct structure *self) +static void nr_definitions_formatter(struct structure *st) { - printf("%s%c%u\n", self->name, separator, self->nr_files); + printf("%s%c%u\n", st->name, separator, st->nr_files); } -static void nr_members_formatter(struct class *self, - struct cu *cu, uint16_t id __unused) +static void nr_members_formatter(struct class *class, + struct cu *cu, uint32_t id __unused) { - printf("%s%c%u\n", class__name(self, cu), separator, - class__nr_members(self)); + printf("%s%c%u\n", class__name(class, cu), separator, + class__nr_members(class)); } -static void nr_methods_formatter(struct structure *self) +static void nr_methods_formatter(struct structure *st) { - printf("%s%c%u\n", self->name, separator, self->nr_methods); + printf("%s%c%u\n", st->name, separator, st->nr_methods); } -static void size_formatter(struct class *self, - struct cu *cu, uint16_t id __unused) +static void size_formatter(struct class *class, + struct cu *cu, uint32_t id __unused) { - printf("%s%c%d%c%u\n", class__name(self, cu), separator, - class__size(self), separator, self->nr_holes); + printf("%s%c%d%c%u\n", class__name(class, cu), separator, + class__size(class), separator, tag__is_union(class__tag(class)) ? 0 : class->nr_holes); } -static void class_name_len_formatter(struct class *self, struct cu *cu, - uint16_t id __unused) +static void class_name_len_formatter(struct class *class, struct cu *cu, + uint32_t id __unused) { - const char *name = class__name(self, cu); + const char *name = class__name(class, cu); printf("%s%c%zd\n", name, separator, strlen(name)); } -static void class_name_formatter(struct class *self, - struct cu *cu, uint16_t id __unused) +static void class_name_formatter(struct class *class, + struct cu *cu, uint32_t id __unused) { - puts(class__name(self, cu)); + puts(class__name(class, cu)); } -static void class_formatter(struct class *self, struct cu *cu, uint16_t id) +static void class_formatter(struct class *class, struct cu *cu, uint32_t id) { struct tag *typedef_alias = NULL; - struct tag *tag = class__tag(self); - const char *name = class__name(self, cu); + struct tag *tag = class__tag(class); + const char *name = class__name(class, cu); if (name == NULL) { /* @@ -224,7 +236,7 @@ putchar('\n'); } -static void print_packable_info(struct class *c, struct cu *cu, uint16_t id) +static void print_packable_info(struct class *c, struct cu *cu, uint32_t id) { const struct tag *t = class__tag(c); const size_t orig_size = class__size(c); @@ -256,7 +268,7 @@ savings); } -static void (*stats_formatter)(struct structure *self) = NULL; +static void (*stats_formatter)(struct structure *st); static void print_stats(void) { @@ -267,17 +279,17 @@ } static struct class *class__filter(struct class *class, struct cu *cu, - uint16_t tag_id); + uint32_t tag_id); -static void (*formatter)(struct class *self, - struct cu *cu, uint16_t id) = class_formatter; +static void (*formatter)(struct class *class, + struct cu *cu, uint32_t id) = class_formatter; static void print_classes(struct cu *cu) { - uint16_t id; + uint32_t id; struct class *pos; - cu__for_each_struct(cu, id, pos) { + cu__for_each_struct_or_union(cu, id, pos) { bool existing_entry; struct structure *str; @@ -329,19 +341,19 @@ return cu; } -static int class__packable(struct class *self, struct cu *cu) +static int class__packable(struct class *class, struct cu *cu) { struct class *clone; - if (self->nr_holes == 0 && self->nr_bit_holes == 0) + if (class->nr_holes == 0 && class->nr_bit_holes == 0) return 0; - clone = class__clone(self, NULL, cu); + clone = class__clone(class, NULL, cu); if (clone == NULL) return 0; class__reorganize(clone, cu, 0, stdout); - if (class__size(self) > class__size(clone)) { - self->priv = clone; + if (class__size(class) > class__size(clone)) { + class->priv = clone; return 1; } /* FIXME: we need to free in the right order, @@ -352,11 +364,23 @@ } static struct class *class__filter(struct class *class, struct cu *cu, - uint16_t tag_id) + uint32_t tag_id) { struct tag *tag = class__tag(class); const char *name; + if (just_unions && !tag__is_union(tag)) + return NULL; + + if (just_structs && !tag__is_struct(tag)) + return NULL; + + if (just_packed_structs) { + /* Is it not packed? */ + if (!class__infer_packed_attributes(class, cu)) + return NULL; + } + if (!tag->top_level) { class__find_holes(class); @@ -407,6 +431,20 @@ strncmp(decl_exclude_prefix, tag__decl_file(tag, cu), decl_exclude_prefix_len) == 0)) return NULL; + /* + * if --unions was used and we got here, its a union and we satisfy the other + * filters/options, so don't filter it. + */ + if (just_unions) + return class; + /* + * The following only make sense for structs, i.e. 'struct class', + * and as we can get here with a union, that is represented by a 'struct type', + * bail out if we get here with an union and we are not looking for things + * that need finding holes, like --packable, --nr_holes, etc + */ + if (!tag__is_struct(tag)) + return (just_structs || show_packable || nr_holes || nr_bit_holes || hole_size_ge) ? NULL : class; if (tag->top_level) class__find_holes(class); @@ -427,9 +465,9 @@ static void class__resize_LP(struct tag *tag, struct cu *cu) { struct tag *tag_pos; - struct class *self = tag__class(tag); + struct class *class = tag__class(tag); size_t word_size_diff; - size_t orig_size = self->type.size; + size_t orig_size = class->type.size; if (tag__type(tag)->resized) return; @@ -496,36 +534,36 @@ if (diff != 0) { struct class_member *m = tag__class_member(tag_pos); if (original_word_size > word_size) { - self->type.size -= diff; - class__subtract_offsets_from(self, m, diff); + class->type.size -= diff; + class__subtract_offsets_from(class, m, diff); } else { - self->type.size += diff; - class__add_offsets_from(self, m, diff); + class->type.size += diff; + class__add_offsets_from(class, m, diff); } } } if (original_word_size > word_size) - tag__type(tag)->size_diff = orig_size - self->type.size; + tag__type(tag)->size_diff = orig_size - class->type.size; else - tag__type(tag)->size_diff = self->type.size - orig_size; + tag__type(tag)->size_diff = class->type.size - orig_size; - class__find_holes(self); - class__fixup_alignment(self, cu); + class__find_holes(class); + class__fixup_alignment(class, cu); } static void union__find_new_size(struct tag *tag, struct cu *cu) { struct tag *tag_pos; - struct type *self = tag__type(tag); + struct type *type = tag__type(tag); size_t max_size = 0; - if (self->resized) + if (type->resized) return; - self->resized = 1; + type->resized = 1; - type__for_each_tag(self, tag_pos) { + type__for_each_tag(type, tag_pos) { struct tag *type; size_t size; @@ -549,12 +587,12 @@ max_size = size; } - if (max_size > self->size) - self->size_diff = max_size - self->size; + if (max_size > type->size) + type->size_diff = max_size - type->size; else - self->size_diff = self->size - max_size; + type->size_diff = type->size - max_size; - self->size = max_size; + type->size = max_size; } static void tag__fixup_word_size(struct tag *tag, struct cu *cu) @@ -601,27 +639,28 @@ original_word_size = cu->addr_size; cu->addr_size = word_size; - uint16_t id; + uint32_t id; struct tag *pos; cu__for_each_type(cu, id, pos) tag__fixup_word_size(pos, cu); } -static void cu__account_nr_methods(struct cu *self) +static void cu__account_nr_methods(struct cu *cu) { struct function *pos_function; struct structure *str; uint32_t id; - cu__for_each_function(self, id, pos_function) { + cu__for_each_function(cu, id, pos_function) { struct class_member *pos; - list_for_each_entry(pos, &pos_function->proto.parms, tag.node) { - struct tag *type = cu__type(self, pos->tag.type); - if (type == NULL || type->tag != DW_TAG_pointer_type) + function__for_each_parameter(pos_function, cu, pos) { + struct tag *type = cu__type(cu, pos->tag.type); + + if (type == NULL || !tag__is_pointer(type)) continue; - type = cu__type(self, type->type); + type = cu__type(cu, type->type); if (type == NULL || !tag__is_struct(type)) continue; @@ -631,15 +670,15 @@ struct class *class = tag__class(type); - if (!class__filter(class, self, 0)) + if (!class__filter(class, cu, 0)) continue; bool existing_entry; - str = structures__add(class, self, &existing_entry); + str = structures__add(class, cu, &existing_entry); if (str == NULL) { fprintf(stderr, "pahole: insufficient memory " "for processing %s, skipping it...\n", - self->name); + cu->name); return; } @@ -652,24 +691,33 @@ static char tab[128]; -static void print_structs_with_pointer_to(const struct cu *cu, uint16_t type) +static void print_structs_with_pointer_to(struct cu *cu, uint32_t type) { struct class *pos; struct class_member *pos_member; - uint16_t id; + uint32_t id; - cu__for_each_struct(cu, id, pos) { + cu__for_each_struct_or_union(cu, id, pos) { bool looked = false; - struct structure *str; + /* + * Set it to NULL just to silence the compiler, as the printf + * at the end of the type__for_each_member() loop is only reached + * after str _is_ set, as looked starts as false, str is used with + * structures_add and if it is NULL, we return. + */ + struct structure *str = NULL; if (pos->type.namespace.name == 0) continue; + if (!class__filter(pos, cu, id)) + continue; + type__for_each_member(&pos->type, pos_member) { struct tag *ctype = cu__type(cu, pos_member->tag.type); tag__assert_search_result(ctype); - if (ctype->tag != DW_TAG_pointer_type || ctype->type != type) + if (!tag__is_pointer_to(ctype, type)) continue; if (!looked) { @@ -695,41 +743,60 @@ } } -static void print_containers(const struct cu *cu, uint16_t type, int ident) +static int type__print_containers(struct type *type, struct cu *cu, uint32_t contained_type_id, int ident) +{ + const uint32_t n = type__nr_members_of_type(type, contained_type_id); + if (n == 0) + return 0; + + if (ident == 0) { + bool existing_entry; + struct structure *str = structures__add(type__class(type), cu, &existing_entry); + if (str == NULL) { + fprintf(stderr, "pahole: insufficient memory for " + "processing %s, skipping it...\n", + cu->name); + return -1; + } + /* + * We already printed this struct in another CU + */ + if (existing_entry) + return 0; + } + + printf("%.*s%s", ident * 2, tab, type__name(type, cu)); + if (global_verbose) + printf(": %u", n); + putchar('\n'); + if (recursive) { + struct class_member *member; + + type__for_each_member(type, member) { + struct tag *member_type = cu__type(cu, member->tag.type); + + if (tag__is_struct(member_type) || tag__is_union(member_type)) + type__print_containers(tag__type(member_type), cu, contained_type_id, ident + 1); + } + } + + return 0; +} + +static void print_containers(struct cu *cu, uint32_t type, int ident) { struct class *pos; - uint16_t id; + uint32_t id; - cu__for_each_struct(cu, id, pos) { + cu__for_each_struct_or_union(cu, id, pos) { if (pos->type.namespace.name == 0) continue; - const uint32_t n = type__nr_members_of_type(&pos->type, type); - if (n == 0) + if (!class__filter(pos, cu, id)) continue; - if (ident == 0) { - bool existing_entry; - struct structure *str = structures__add(pos, cu, &existing_entry); - if (str == NULL) { - fprintf(stderr, "pahole: insufficient memory for " - "processing %s, skipping it...\n", - cu->name); - return; - } - /* - * We already printed this struct in another CU - */ - if (existing_entry) - break; - } - - printf("%.*s%s", ident * 2, tab, class__name(pos, cu)); - if (global_verbose) - printf(": %u", n); - putchar('\n'); - if (recursive) - print_containers(cu, id, ident + 1); + if (type__print_containers(&pos->type, cu, type, ident)) + break; } } @@ -742,6 +809,24 @@ #define ARGP_first_obj_only 303 #define ARGP_classes_as_structs 304 #define ARGP_hex_fmt 305 +#define ARGP_suppress_aligned_attribute 306 +#define ARGP_suppress_force_paddings 307 +#define ARGP_suppress_packed 308 +#define ARGP_just_unions 309 +#define ARGP_just_structs 310 +#define ARGP_count 311 +#define ARGP_skip 312 +#define ARGP_seek_bytes 313 +#define ARGP_header_type 314 +#define ARGP_size_bytes 315 +#define ARGP_range 316 +#define ARGP_skip_encoding_btf_vars 317 +#define ARGP_btf_encode_force 318 +#define ARGP_just_packed_structs 319 +#define ARGP_numeric_version 320 +#define ARGP_btf_base 321 +#define ARGP_btf_gen_floats 322 +#define ARGP_btf_gen_all 323 static const struct argp_option pahole__options[] = { { @@ -763,6 +848,42 @@ .doc = "Show just this class" }, { + .name = "count", + .key = ARGP_count, + .arg = "COUNT", + .doc = "Print only COUNT input records" + }, + { + .name = "skip", + .key = ARGP_skip, + .arg = "COUNT", + .doc = "Skip COUNT input records" + }, + { + .name = "seek_bytes", + .key = ARGP_seek_bytes, + .arg = "BYTES", + .doc = "Seek COUNT input records" + }, + { + .name = "size_bytes", + .key = ARGP_size_bytes, + .arg = "BYTES", + .doc = "Read only this number of bytes from this point onwards" + }, + { + .name = "range", + .key = ARGP_range, + .arg = "STRUCT", + .doc = "Data struct with 'offset' and 'size' fields to determine --seek_bytes and --size_bytes" + }, + { + .name = "header_type", + .key = ARGP_header_type, + .arg = "TYPE", + .doc = "File header type" + }, + { .name = "find_pointers_to", .key = 'f', .arg = "CLASS_NAME", @@ -940,6 +1061,21 @@ .doc = "Flat arrays", }, { + .name = "suppress_aligned_attribute", + .key = ARGP_suppress_aligned_attribute, + .doc = "Suppress __attribute__((aligned(N))", + }, + { + .name = "suppress_force_paddings", + .key = ARGP_suppress_force_paddings, + .doc = "Suppress int :N paddings at the end", + }, + { + .name = "suppress_packed", + .key = ARGP_suppress_packed, + .doc = "Suppress output of inferred __attribute__((__packed__))", + }, + { .name = "show_private_classes", .key = ARGP_show_private_classes, .doc = "Show classes that are defined inside other classes or in functions", @@ -965,6 +1101,57 @@ .doc = "Print offsets and sizes in hexadecimal", }, { + .name = "btf_base", + .key = ARGP_btf_base, + .arg = "PATH", + .doc = "Path to the base BTF file", + }, + { + .name = "btf_encode", + .key = 'J', + .doc = "Encode as BTF", + }, + { + .name = "skip_encoding_btf_vars", + .key = ARGP_skip_encoding_btf_vars, + .doc = "Do not encode VARs in BTF." + }, + { + .name = "btf_encode_force", + .key = ARGP_btf_encode_force, + .doc = "Ignore those symbols found invalid when encoding BTF." + }, + { + .name = "btf_gen_floats", + .key = ARGP_btf_gen_floats, + .doc = "Allow producing BTF_KIND_FLOAT entries." + }, + { + .name = "btf_gen_all", + .key = ARGP_btf_gen_all, + .doc = "Allow using all the BTF features supported by pahole." + }, + { + .name = "structs", + .key = ARGP_just_structs, + .doc = "Show just structs", + }, + { + .name = "unions", + .key = ARGP_just_unions, + .doc = "Show just unions", + }, + { + .name = "packed", + .key = ARGP_just_packed_structs, + .doc = "Show just packed structs", + }, + { + .name = "numeric_version", + .key = ARGP_numeric_version, + .doc = "Print a numeric version, i.e. 119 instead of v1.19" + }, + { .name = NULL, } }; @@ -995,6 +1182,9 @@ conf_load.extra_dbg_info = 1; break; case 'i': find_containers = 1; class_name = arg; break; + case 'J': btf_encode = 1; + conf_load.get_addr_info = true; + no_bitfield_type_recode = true; break; case 'l': conf.show_first_biggest_size_base_type_member = 1; break; case 'M': conf.show_only_data_members = 1; break; case 'm': stats_formatter = nr_methods_formatter; break; @@ -1032,6 +1222,12 @@ break; case 'Z': ctf_encode = 1; break; case ARGP_flat_arrays: conf.flat_arrays = 1; break; + case ARGP_suppress_aligned_attribute: + conf.suppress_aligned_attribute = 1; break; + case ARGP_suppress_force_paddings: + conf.suppress_force_paddings = 1; break; + case ARGP_suppress_packed: + conf.suppress_packed = 1; break; case ARGP_show_private_classes: show_private_classes = true; conf.show_only_data_members = 1; break; @@ -1043,6 +1239,37 @@ conf.classes_as_structs = 1; break; case ARGP_hex_fmt: conf.hex_fmt = 1; break; + case ARGP_just_unions: + just_unions = true; break; + case ARGP_just_structs: + just_structs = true; break; + case ARGP_just_packed_structs: + just_structs = true; + just_packed_structs = true; break; + case ARGP_count: + conf.count = atoi(arg); break; + case ARGP_skip: + conf.skip = atoi(arg); break; + case ARGP_seek_bytes: + conf.seek_bytes = arg; break; + case ARGP_size_bytes: + conf.size_bytes = arg; break; + case ARGP_range: + conf.range = arg; break; + case ARGP_header_type: + conf.header_type = arg; break; + case ARGP_skip_encoding_btf_vars: + skip_encoding_btf_vars = true; break; + case ARGP_btf_encode_force: + btf_encode_force = true; break; + case ARGP_btf_base: + base_btf_file = arg; break; + case ARGP_numeric_version: + print_numeric_version = true; break; + case ARGP_btf_gen_floats: + btf_gen_floats = true; break; + case ARGP_btf_gen_all: + btf_gen_floats = true; break; default: return ARGP_ERR_UNKNOWN; } @@ -1097,160 +1324,1514 @@ */ } -static enum load_steal_kind pahole_stealer(struct cu *cu, - struct conf_load *conf_load __unused) +static int tag__fprintf_hexdump_value(struct tag *type, struct cu *cu, void *instance, int _sizeof, FILE *fp) { - int ret = LSK__DELETE; + uint8_t *contents = instance; + int i, printed = 0; - if (!cu__filter(cu)) - goto filter_it; + for (i = 0; i < _sizeof; ++i) { + if (i != 0) { + fputc(' ', fp); + ++printed; + } - if (ctf_encode) { - cu__encode_ctf(cu, global_verbose); - /* - * We still have to get the type signature code merged to eliminate - * dups, reference another CTF file, etc, so for now just encode the - * first cu that is let thru by cu__filter. - */ - goto dump_and_stop; + printed += fprintf(fp, "0x%02x", contents[i]); } - if (class_name == NULL) { - if (stats_formatter == nr_methods_formatter) { - cu__account_nr_methods(cu); - goto dump_it; - } + return printed; +} - if (word_size != 0) - cu_fixup_word_size_iterator(cu); +static uint64_t base_type__value(void *instance, int _sizeof) +{ + if (_sizeof == sizeof(int)) + return *(int *)instance; + else if (_sizeof == sizeof(long)) + return *(long *)instance; + else if (_sizeof == sizeof(long long)) + return *(long long *)instance; + else if (_sizeof == sizeof(char)) + return *(char *)instance; + else if (_sizeof == sizeof(short)) + return *(short *)instance; - memset(tab, ' ', sizeof(tab) - 1); + return 0; +} - print_classes(cu); - goto dump_it; +static int fprintf__value(FILE* fp, uint64_t value) +{ + const char *format = conf.hex_fmt ? "%#" PRIx64 : "%" PRIi64; + + return fprintf(fp, format, value); +} + +static int base_type__fprintf_value(void *instance, int _sizeof, FILE *fp) +{ + uint64_t value = base_type__value(instance, _sizeof); + return fprintf__value(fp, value); +} + +static uint64_t class_member__bitfield_value(struct class_member *member, void *instance) +{ + int byte_size = member->byte_size; + uint64_t value = base_type__value(instance, byte_size); + uint64_t mask = 0; + int bits = member->bitfield_size; + + while (bits) { + mask |= 1; + if (--bits) + mask <<= 1; } - struct str_node *pos; - struct rb_node *next = rb_first(&class_names->entries); + mask <<= member->bitfield_offset; - while (next) { - pos = rb_entry(next, struct str_node, rb_node); - next = rb_next(&pos->rb_node); + return (value & mask) >> member->bitfield_offset; +} - static uint16_t class_id; - bool include_decls = find_pointers_in_structs != 0 || - stats_formatter == nr_methods_formatter; - struct tag *class = cu__find_struct_by_name(cu, pos->s, - include_decls, - &class_id); - if (class == NULL) - continue; +static int class_member__fprintf_bitfield_value(struct class_member *member, void *instance, FILE *fp) +{ + const char *format = conf.hex_fmt ? "%#" PRIx64 : "%" PRIi64; + return fprintf(fp, format, class_member__bitfield_value(member, instance)); +} - if (defined_in) { - puts(cu->name); - goto dump_it; - } - /* - * Ok, found it, so remove from the list to avoid printing it - * twice, in another CU. - */ - strlist__remove(class_names, pos); +static const char *enumeration__lookup_value(struct type *enumeration, struct cu *cu, uint64_t value) +{ + struct enumerator *entry; - class__find_holes(tag__class(class)); - if (reorganize) - do_reorg(class, cu); - else if (find_containers) - print_containers(cu, class_id, 0); - else if (find_pointers_in_structs) - print_structs_with_pointer_to(cu, class_id); - else { - /* - * We don't need to print it for every compile unit - * but the previous options need - */ - tag__fprintf(class, cu, &conf, stdout); - putchar('\n'); - } + type__for_each_enumerator(enumeration, entry) { + if (entry->value == value) + return enumerator__name(entry, cu); } - /* - * If we found all the entries in --class_name, stop - */ - if (strlist__empty(class_names)) { -dump_and_stop: - ret = LSK__STOP_LOADING; + return NULL; +} + +static const char *enumerations__lookup_value(struct list_head *enumerations, uint64_t value) +{ + struct tag_cu_node *pos; + + list_for_each_entry(pos, enumerations, node) { + const char *s = enumeration__lookup_value(tag__type(pos->tc.tag), pos->tc.cu, value); + if (s) + return s; } -dump_it: - if (first_obj_only) - ret = LSK__STOP_LOADING; -filter_it: - return ret; + + return NULL; } -static int add_class_name_entry(const char *s) +static struct enumerator *enumeration__lookup_entry_from_value(struct type *enumeration, struct cu *cu, uint64_t value) { - if (strncmp(s, "file://", 7) == 0) { - if (strlist__load(class_names, s + 7)) - return -1; - } else switch (strlist__add(class_names, s)) { - case -EEXIST: - if (global_verbose) - fprintf(stderr, - "pahole: %s dup in -C, ignoring\n", s); - break; - case -ENOMEM: - return -1; + struct enumerator *entry; + + type__for_each_enumerator(enumeration, entry) { + if (entry->value == value) + return entry; } - return 0; + + return NULL; } -static int populate_class_names(void) +static struct enumerator *enumerations__lookup_entry_from_value(struct list_head *enumerations, struct cu **cup, uint64_t value) { - char *s = class_name, *sep; + struct tag_cu_node *pos; - while ((sep = strchr(s, ',')) != NULL) { - *sep = '\0'; - if (add_class_name_entry(s)) - return -1; - *sep = ','; - s = sep + 1; + list_for_each_entry(pos, enumerations, node) { + struct enumerator *enumerator = enumeration__lookup_entry_from_value(tag__type(pos->tc.tag), pos->tc.cu, value); + if (enumerator) { + *cup = pos->tc.cu; + return enumerator; + } } - return *s ? add_class_name_entry(s) : 0; + return NULL; } -int main(int argc, char *argv[]) +static int64_t enumeration__lookup_enumerator(struct type *enumeration, struct cu *cu, const char *enumerator) { - int err, remaining, rc = EXIT_FAILURE; + struct enumerator *entry; - if (argp_parse(&pahole__argp, argc, argv, 0, &remaining, NULL) || - remaining == argc) { - argp_help(&pahole__argp, stderr, ARGP_HELP_SEE, argv[0]); - goto out; + type__for_each_enumerator(enumeration, entry) { + const char *entry_name = enumerator__name(entry, cu); + + if (!strcmp(entry_name, enumerator)) + return entry->value; + + if (enumeration->member_prefix_len && + !strcmp(entry_name + enumeration->member_prefix_len, enumerator)) + return entry->value; } - class_names = strlist__new(true); + return -1; +} + +static int64_t enumerations__lookup_enumerator(struct list_head *enumerations, const char *enumerator) +{ + struct tag_cu_node *pos; - if (class_names == NULL || dwarves__init(cacheline_size)) { - fputs("pahole: insufficient memory\n", stderr); - goto out; + list_for_each_entry(pos, enumerations, node) { + int64_t value = enumeration__lookup_enumerator(tag__type(pos->tc.tag), pos->tc.cu, enumerator); + if (value != -1) + return value; } - if (class_name && populate_class_names()) - goto out_dwarves_exit; + return -1; +} - struct cus *cus = cus__new(); - if (cus == NULL) { - fputs("pahole: insufficient memory\n", stderr); - goto out_dwarves_exit; +static int base_type__fprintf_enum_value(void *instance, int _sizeof, struct list_head *enumerations, FILE *fp) +{ + uint64_t value = base_type__value(instance, _sizeof); + + const char *entry = enumerations__lookup_value(enumerations, value); + + if (entry) + return fprintf(fp, "%s", entry); + + return fprintf__value(fp, value); +} + +static int string__fprintf_value(char *instance, int _sizeof, FILE *fp) +{ + return fprintf(fp, "\"%-.*s\"", _sizeof, instance); +} + +static int array__fprintf_base_type_value(struct tag *tag, struct cu *cu, void *instance, int _sizeof, FILE *fp) +{ + struct array_type *array = tag__array_type(tag); + struct tag *array_type = cu__type(cu, tag->type); + void *contents = instance; + + if (array->dimensions != 1) { + // Support multi dimensional arrays later + return tag__fprintf_hexdump_value(tag, cu, instance, _sizeof, fp); } - conf_load.steal = pahole_stealer; + if (tag__is_typedef(array_type)) + array_type = tag__follow_typedef(array_type, cu); - err = cus__load_files(cus, &conf_load, argv + remaining); - if (err != 0) { - fputs("pahole: No debugging information found\n", stderr); - goto out_cus_delete; + int i, printed = 0, sizeof_entry = base_type__size(array_type); + + printed += fprintf(fp, "{ "); + + int nr_entries = array->nr_entries[0]; + + // Look for zero sized arrays + if (nr_entries == 0) + nr_entries = _sizeof / sizeof_entry; + + for (i = 0; i < nr_entries; ++i) { + if (i > 0) + printed += fprintf(fp, ", "); + printed += base_type__fprintf_value(contents, sizeof_entry, fp); + contents += sizeof_entry; + } + + return printed + fprintf(fp, " }"); +} + +static int array__fprintf_value(struct tag *tag, struct cu *cu, void *instance, int _sizeof, FILE *fp) +{ + struct tag *array_type = cu__type(cu, tag->type); + char type_name[1024]; + + if (strcmp(tag__name(array_type, cu, type_name, sizeof(type_name), NULL), "char") == 0) + return string__fprintf_value(instance, _sizeof, fp); + + if (tag__is_base_type(array_type, cu)) + return array__fprintf_base_type_value(tag, cu, instance, _sizeof, fp); + + return tag__fprintf_hexdump_value(tag, cu, instance, _sizeof, fp); +} + +static int __class__fprintf_value(struct tag *tag, struct cu *cu, void *instance, int _sizeof, int indent, bool brackets, FILE *fp) +{ + struct type *type = tag__type(tag); + struct class_member *member; + int printed = 0; + + if (brackets) + printed += fprintf(fp, "{"); + + type__for_each_member(type, member) { + void *member_contents = instance + member->byte_offset; + struct tag *member_type = cu__type(cu, member->tag.type); + const char *name = class_member__name(member, cu); + + if (name) + printed += fprintf(fp, "\n%.*s\t.%s = ", indent, tabs, name); + + if (member == type->type_member && !list_empty(&type->type_enum)) { + printed += base_type__fprintf_enum_value(member_contents, member->byte_size, &type->type_enum, fp); + } else if (member->bitfield_size) { + printed += class_member__fprintf_bitfield_value(member, member_contents, fp); + } else if (tag__is_base_type(member_type, cu)) { + printed += base_type__fprintf_value(member_contents, member->byte_size, fp); + } else if (tag__is_array(member_type, cu)) { + int sizeof_member = member->byte_size; + + // zero sized array, at the end of the struct? + if (sizeof_member == 0 && list_is_last(&member->tag.node, &type->namespace.tags)) + sizeof_member = _sizeof - member->byte_offset; + printed += array__fprintf_value(member_type, cu, member_contents, sizeof_member, fp); + } else if (tag__is_struct(member_type)) { + printed += __class__fprintf_value(member_type, cu, member_contents, member->byte_size, indent + 1, true, fp); + } else if (tag__is_union(member_type)) { + printed += __class__fprintf_value(member_type, cu, member_contents, member->byte_size, indent + (name ? 1 : 0), !!name, fp); + if (!name) + continue; + } else { + printed += tag__fprintf_hexdump_value(member_type, cu, member_contents, member->byte_size, fp); + } + + fputc(',', fp); + ++printed; + } + + if (brackets) + printed += fprintf(fp, "\n%.*s}", indent, tabs); + return printed; +} + +static int class__fprintf_value(struct tag *tag, struct cu *cu, void *instance, int _sizeof, int indent, FILE *fp) +{ + return __class__fprintf_value(tag, cu, instance, _sizeof, indent, true, fp); +} + +static int tag__fprintf_value(struct tag *type, struct cu *cu, void *instance, int _sizeof, FILE *fp) +{ + if (tag__is_struct(type)) + return class__fprintf_value(type, cu, instance, _sizeof, 0, fp); + + return tag__fprintf_hexdump_value(type, cu, instance, _sizeof, fp); +} + +static int pipe_seek(FILE *fp, off_t offset) +{ + char bf[4096]; + int chunk = sizeof(bf); + + if (chunk > offset) + chunk = offset; + + while (fread(bf, chunk, 1, stdin) == 1) { + offset -= chunk; + if (offset == 0) + return 0; + if (chunk > offset) + chunk = offset; + } + + return offset == 0 ? 0 : -1; +} + +static uint64_t tag__real_sizeof(struct tag *tag, struct cu *cu, int _sizeof, void *instance) +{ + if (tag__is_struct(tag)) { + struct type *type = tag__type(tag); + + if (type->sizeof_member) { + struct class_member *member = type->sizeof_member; + return base_type__value(instance + member->byte_offset, member->byte_size); + } + } + + return _sizeof; +} + +/* + * Classes should start close to where they are needed, then moved elsewhere, remember: + * "Premature optimization is the root of all evil" (Knuth till unproven). + * + * So far just the '==' operator is supported, so just a struct member + a value are + * needed, no, strings are not supported so far. + * + * If the class member is the 'type=' and we have a 'type_enum=' in place, then we will + * resolve that at parse time and convert that to an uint64_t and it'll do the trick. + * + * More to come, when needed. + */ +struct class_member_filter { + struct class_member *left; + uint64_t right; +}; + +static bool type__filter_value(struct tag *tag, void *instance) +{ + // this has to be a type, otherwise we'd not have a type->filter + struct type *type = tag__type(tag); + struct class_member_filter *filter = type->filter; + struct class_member *member = filter->left; + uint64_t value = base_type__value(instance + member->byte_offset, member->byte_size); + + // Only operator supported so far is '==' + return value != filter->right; +} + +static struct tag *tag__real_type(struct tag *tag, struct cu **cup, void *instance) +{ + if (tag__is_struct(tag)) { + struct type *type = tag__type(tag); + + if (!list_empty(&type->type_enum) && type->type_member) { + struct class_member *member = type->type_member; + uint64_t value = base_type__value(instance + member->byte_offset, member->byte_size); + struct cu *cu_enumerator; + struct enumerator *enumerator = enumerations__lookup_entry_from_value(&type->type_enum, &cu_enumerator, value); + char name[1024]; + + if (!enumerator) + return tag; + + if (enumerator->type_enum.tag) { + *cup = enumerator->type_enum.cu; + return enumerator->type_enum.tag; + } + + snprintf(name, sizeof(name), "%s", enumerator__name(enumerator, cu_enumerator)); + strlwr(name); + + struct tag *real_type = cu__find_type_by_name(*cup, name, false, NULL); + + if (!real_type) + return NULL; + + if (tag__is_struct(real_type)) { + enumerator->type_enum.tag = real_type; + enumerator->type_enum.cu = *cup; + return real_type; + } + } + } + + return tag; +} + +struct type_instance { + struct type *type; + struct cu *cu; + bool read_already; + char instance[0]; +}; + +static struct type_instance *type_instance__new(struct type *type, struct cu *cu) +{ + if (type == NULL) + return NULL; + + struct type_instance *instance = malloc(sizeof(*instance) + type->size); + + if (instance) { + instance->type = type; + instance->cu = cu; + instance->read_already = false; + } + + return instance; +} + +static void type_instance__delete(struct type_instance *instance) +{ + if (!instance) + return; + instance->type = NULL; + free(instance); +} + +static int64_t type_instance__int_value(struct type_instance *instance, const char *member_name_orig) +{ + struct cu *cu = instance->cu; + struct class_member *member = type__find_member_by_name(instance->type, cu, member_name_orig); + int byte_offset = 0; + + if (!member) { + char *sep = strchr(member_name_orig, '.'); + + if (!sep) + return -1; + + char *member_name_alloc = strdup(member_name_orig); + + if (!member_name_alloc) + return -1; + + char *member_name = member_name_alloc; + struct type *type = instance->type; + + sep = member_name_alloc + (sep - member_name_orig); + *sep = 0; + + while (1) { + member = type__find_member_by_name(type, cu, member_name); + if (!member) { +out_free_member_name: + free(member_name_alloc); + return -1; + } + byte_offset += member->byte_offset; + type = tag__type(cu__type(cu, member->tag.type)); + if (type == NULL) + goto out_free_member_name; + member_name = sep + 1; + sep = strchr(member_name, '.'); + if (!sep) + break; + + } + + member = type__find_member_by_name(type, cu, member_name); + free(member_name_alloc); + if (member == NULL) + return -1; + } + + byte_offset += member->byte_offset; + + struct tag *member_type = cu__type(cu, member->tag.type); + + if (!tag__is_base_type(member_type, cu)) + return -1; + + return base_type__value(&instance->instance[byte_offset], member->byte_size); +} + +static int64_t type__instance_read_once(struct type_instance *instance, FILE *fp) +{ + if (!instance || instance->read_already) + return 0; + + instance->read_already = true; + + return fread(instance->instance, instance->type->size, 1, stdin) != 1 ? -1 : instance->type->size; +} + +/* + * struct prototype - split arguments to a type + * + * @name - type name + * @type - name of the member containing a type id + * @type_enum - translate @type into a enum entry/string + * @type_enum_resolved - if this was already resolved, i.e. if the enums were find in some CU + * @size - the member with the size for variable sized records + * @filter - filter expression using record contents and values or enum entries + * @range - from where to get seek_bytes and size_bytes where to pretty print this specific class + */ +struct prototype { + struct list_head node; + struct tag *class; + struct cu *cu; + const char *type, + *type_enum, + *size, + *range; + char *filter; + uint16_t nr_args; + bool type_enum_resolved; + char name[0]; + +}; + +static int prototype__stdio_fprintf_value(struct prototype *prototype, struct type_instance *header, FILE *fp) +{ + struct tag *type = prototype->class; + struct cu *cu = prototype->cu; + int _sizeof = tag__size(type, cu), printed = 0; + int max_sizeof = _sizeof; + void *instance = malloc(_sizeof); + uint64_t size_bytes = ULLONG_MAX; + uint32_t count = 0; + uint32_t skip = conf.skip; + + if (instance == NULL) + return -ENOMEM; + + if (type__instance_read_once(header, stdin) < 0) { + int err = --errno; + fprintf(stderr, "pahole: --header (%s) type not be read\n", conf.header_type); + return err; + } + + if (conf.range || prototype->range) { + off_t seek_bytes; + const char *range = conf.range ?: prototype->range; + + if (!header) { + if (conf.header_type) + fprintf(stderr, "pahole: --header_type=%s not found\n", conf.header_type); + else + fprintf(stderr, "pahole: range (%s) requires --header\n", range); + return -ESRCH; + } + + char *member_name = NULL; + + if (asprintf(&member_name, "%s.%s", range, "offset") == -1) { + fprintf(stderr, "pahole: not enough memory for range=%s\n", range); + return -ENOMEM; + } + + int64_t value = type_instance__int_value(header, member_name); + + if (value < 0) { + fprintf(stderr, "pahole: couldn't read the '%s' member of '%s' for evaluating range=%s\n", + member_name, conf.header_type, range); + free(member_name); + return -ESRCH; + } + + seek_bytes = value; + + free(member_name); + + off_t total_read_bytes = ftell(stdin); + + // Since we're reading stdin, we need to account for what we already read + if (seek_bytes < total_read_bytes) { + fprintf(stderr, "pahole: can't go back in stdin, already read %" PRIu64 " bytes, can't go to position %#" PRIx64 "\n", + total_read_bytes, seek_bytes); + return -ENOMEM; + } + + if (global_verbose) { + fprintf(fp, "pahole: range.seek_bytes evaluated from range=%s is %#" PRIx64 " \n", + range, seek_bytes); + } + + seek_bytes -= total_read_bytes; + + if (asprintf(&member_name, "%s.%s", range, "size") == -1) { + fprintf(stderr, "pahole: not enough memory for range=%s\n", range); + return -ENOMEM; + } + + value = type_instance__int_value(header, member_name); + + if (value < 0) { + fprintf(stderr, "pahole: couldn't read the '%s' member of '%s' for evaluating range=%s\n", + member_name, conf.header_type, range); + free(member_name); + return -ESRCH; + } + + size_bytes = value; + if (global_verbose) { + fprintf(fp, "pahole: range.size_bytes evaluated from range=%s is %#" PRIx64 " \n", + range, size_bytes); + } + + free(member_name); + + if (pipe_seek(stdin, seek_bytes) < 0) { + int err = --errno; + fprintf(stderr, "Couldn't --seek_bytes %s (%" PRIu64 "\n", conf.seek_bytes, seek_bytes); + return err; + } + + goto do_read; + } + + if (conf.seek_bytes) { + off_t seek_bytes; + + if (strstarts(conf.seek_bytes, "$header.")) { + if (!header) { + fprintf(stderr, "pahole: --seek_bytes (%s) makes reference to --header but it wasn't specified\n", + conf.seek_bytes); + return -ESRCH; + } + + const char *member_name = conf.seek_bytes + sizeof("$header.") - 1; + int64_t value = type_instance__int_value(header, member_name); + if (value < 0) { + fprintf(stderr, "pahole: couldn't read the '%s' member of '%s' for evaluating --seek_bytes=%s\n", + member_name, conf.header_type, conf.seek_bytes); + return -ESRCH; + } + + seek_bytes = value; + + if (global_verbose) + fprintf(stdout, "pahole: seek bytes evaluated from --seek_bytes=%s is %#" PRIx64 " \n", + conf.seek_bytes, seek_bytes); + + if (seek_bytes < header->type->size) { + fprintf(stderr, "pahole: seek bytes evaluated from --seek_bytes=%s is less than the header type size\n", + conf.seek_bytes); + return -EINVAL; + } + } else { + seek_bytes = strtol(conf.seek_bytes, NULL, 0); + } + + + if (header) { + // Since we're reading stdin, we need to account for already read header: + seek_bytes -= ftell(stdin); + } + + if (pipe_seek(stdin, seek_bytes) < 0) { + int err = --errno; + fprintf(stderr, "Couldn't --seek_bytes %s (%" PRIu64 "\n", conf.seek_bytes, seek_bytes); + return err; + } + } + + if (conf.size_bytes) { + if (strstarts(conf.size_bytes, "$header.")) { + if (!header) { + fprintf(stderr, "pahole: --size_bytes (%s) makes reference to --header but it wasn't specified\n", + conf.size_bytes); + return -ESRCH; + } + + const char *member_name = conf.size_bytes + sizeof("$header.") - 1; + int64_t value = type_instance__int_value(header, member_name); + if (value < 0) { + fprintf(stderr, "pahole: couldn't read the '%s' member of '%s' for evaluating --size_bytes=%s\n", + member_name, conf.header_type, conf.size_bytes); + return -ESRCH; + } + + size_bytes = value; + + if (global_verbose) + fprintf(stdout, "pahole: size bytes evaluated from --size_bytes=%s is %#" PRIx64 " \n", + conf.size_bytes, size_bytes); + } else { + size_bytes = strtol(conf.size_bytes, NULL, 0); + } + } +do_read: +{ + uint64_t read_bytes = 0; + off_t record_offset = ftell(stdin); + + while (fread(instance, _sizeof, 1, stdin) == 1) { + // Read it from each record/instance + int real_sizeof = tag__real_sizeof(type, cu, _sizeof, instance); + + if (real_sizeof > _sizeof) { + if (real_sizeof > max_sizeof) { + void *new_instance = realloc(instance, real_sizeof); + if (!new_instance) { + fprintf(stderr, "Couldn't allocate space for a record, too big: %d bytes\n", real_sizeof); + printed = -1; + goto out; + } + instance = new_instance; + max_sizeof = real_sizeof; + } + if (fread(instance + _sizeof, real_sizeof - _sizeof, 1, stdin) != 1) { + fprintf(stderr, "Couldn't read record: %d bytes\n", real_sizeof); + printed = -1; + goto out; + } + } + + read_bytes += real_sizeof; + + if (tag__type(type)->filter && type__filter_value(type, instance)) + goto next_record; + + if (skip) { + --skip; + goto next_record; + } + + /* + * pahole -C 'perf_event_header(sizeof=size,typeid=type,enum2type=perf_event_type) + * + * So that it gets the 'type' field as the type id, look this + * up in the 'enum perf_event_type' and find the type to cast the + * whole shebang, i.e.: + * + + $ pahole ~/bin/perf -C perf_event_header + struct perf_event_header { + __u32 type; / * 0 4 * / + __u16 misc; / * 4 2 * / + __u16 size; / * 6 2 * / + + / * size: 8, cachelines: 1, members: 3 * / + / * last cacheline: 8 bytes * / + }; + $ + + enum perf_event_type { + PERF_RECORD_MMAP = 1, + PERF_RECORD_LOST = 2, + PERF_RECORD_COMM = 3, + PERF_RECORD_EXIT = 4, + + } + + * So from the type field get the lookup into the enum and from the result, look + * for a type with that name as-is or in lower case, which will produce, when type = 3: + + $ pahole -C perf_record_comm ~/bin/perf + struct perf_record_comm { + struct perf_event_header header; / * 0 8 * / + __u32 pid; / * 8 4 * / + __u32 tid; / * 12 4 * / + char comm[16]; / * 16 16 * / + + / * size: 32, cachelines: 1, members: 4 * / + / * last cacheline: 32 bytes * / + }; + $ + */ + + struct cu *real_type_cu = cu; + struct tag *real_type = tag__real_type(type, &real_type_cu, instance); + + if (real_type == NULL) + real_type = type; + + if (global_verbose) { + printed += fprintf(fp, "// type=%s, offset=%#" PRIx64 ", sizeof=%d", type__name(tag__type(type), cu), record_offset, _sizeof); + if (real_sizeof != _sizeof) + printed += fprintf(fp, ", real_sizeof=%d\n", real_sizeof); + else + printed += fprintf(fp, "\n"); + } + printed += tag__fprintf_value(real_type, real_type_cu, instance, real_sizeof, fp); + printed += fprintf(fp, ",\n"); + + if (conf.count && ++count == conf.count) + break; +next_record: + if (read_bytes >= size_bytes) + break; + + record_offset = ftell(stdin); + } +} +out: + free(instance); + return printed; +} + +static int class_member_filter__parse(struct class_member_filter *filter, struct type *type, struct cu *cu, char *sfilter) +{ + const char *member_name = sfilter; + char *sep = strstr(sfilter, "=="); + + if (!sep) { + if (global_verbose) + fprintf(stderr, "No supported operator ('==' so far) found in filter '%s'\n", sfilter); + return -1; + } + + char *value = sep + 2, *s = sep; + + while (isspace(*--s)) + if (s == sfilter) { + if (global_verbose) + fprintf(stderr, "No left operand (struct field) found in filter '%s'\n", sfilter); + return -1; // nothing before == + } + + char before = s[1]; + s[1] = '\0'; + + filter->left = type__find_member_by_name(type, cu, member_name); + + if (!filter->left) { + if (global_verbose) + fprintf(stderr, "The '%s' member wasn't found in '%s'\n", member_name, type__name(type, cu)); + s[1] = before; + return -1; + } + + s[1] = before; + + while (isspace(*value)) + if (*++value == '\0') { + if (global_verbose) + fprintf(stderr, "The '%s' member was asked without a value to filter '%s'\n", member_name, type__name(type, cu)); + return -1; // no value + } + + char *endptr; + filter->right = strtoll(value, &endptr, 0); + + if (endptr > value && (*endptr == '\0' || isspace(*endptr))) + return 0; + + // If t he filter member is the 'type=' one: + + if (list_empty(&type->type_enum) || type->type_member != filter->left) { + if (global_verbose) + fprintf(stderr, "Symbolic right operand in '%s' but no way to resolve it to a number (type= + type_enum= so far)\n", sfilter); + return -1; + } + + enumerations__calc_prefix(&type->type_enum); + + int64_t enumerator_value = enumerations__lookup_enumerator(&type->type_enum, value); + + if (enumerator_value < 0) { + if (global_verbose) + fprintf(stderr, "Couldn't resolve right operand ('%s') in '%s' with the specified 'type=%s' and type_enum' \n", + value, sfilter, class_member__name(type->type_member, cu)); + return -1; + } + + filter->right = enumerator_value; + + return 0; +} + +static struct class_member_filter *class_member_filter__new(struct type *type, struct cu *cu, char *sfilter) +{ + struct class_member_filter *filter = malloc(sizeof(*filter)); + + if (filter && class_member_filter__parse(filter, type, cu, sfilter)) { + free(filter); + filter = NULL; + } + + return filter; +} + +static struct prototype *prototype__new(const char *expression) +{ + struct prototype *prototype = zalloc(sizeof(*prototype) + strlen(expression) + 1); + + if (prototype == NULL) + goto out_enomem; + + strcpy(prototype->name, expression); + + const char *name = prototype->name; + + prototype->nr_args = 0; + + char *args_open = strchr(name, '('); + + if (!args_open) + goto out; + + char *args_close = strchr(args_open, ')'); + + if (args_close == NULL) + goto out_no_closing_parens; + + char *args = args_open; + + *args++ = *args_close = '\0'; + + while (isspace(*args)) + ++args; + + if (args == args_close) + goto out; // empty args, just ignore the parens, i.e. 'foo()' +next_arg: +{ + char *comma = strchr(args, ','), *value; + + if (comma) + *comma = '\0'; + + char *assign = strchr(args, '='); + + if (assign == NULL) { + if (strcmp(args, "sizeof") == 0) { + value = "size"; + goto do_sizeof; + } else if (strcmp(args, "type") == 0) { + value = "type"; + goto do_type; + } + goto out_missing_assign; + } + + // accept foo==bar as filter=foo==bar + if (assign[1] == '=') { + value = args; + goto do_filter; + } + + *assign = 0; + + value = assign + 1; + + while (isspace(*value)) + ++value; + + if (value == args_close) + goto out_missing_value; + + if (strcmp(args, "sizeof") == 0) { +do_sizeof: + if (global_verbose) + printf("pahole: sizeof_operator for '%s' is '%s'\n", name, value); + + prototype->size = value; + } else if (strcmp(args, "type") == 0) { +do_type: + if (global_verbose) + printf("pahole: type member for '%s' is '%s'\n", name, value); + + prototype->type = value; + } else if (strcmp(args, "type_enum") == 0) { + if (global_verbose) + printf("pahole: type enum for '%s' is '%s'\n", name, value); + prototype->type_enum = value; + } else if (strcmp(args, "filter") == 0) { +do_filter: + if (global_verbose) + printf("pahole: filter for '%s' is '%s'\n", name, value); + + prototype->filter = value; + } else if (strcmp(args, "range") == 0) { + if (global_verbose) + printf("pahole: range for '%s' is '%s'\n", name, value); + prototype->range = value; + } else + goto out_invalid_arg; + + ++prototype->nr_args; + + if (comma) { + args = comma + 1; + goto next_arg; + } +} +out: + return prototype; + +out_enomem: + fprintf(stderr, "pahole: not enough memory for '%s'\n", expression); + goto out; + +out_invalid_arg: + fprintf(stderr, "pahole: invalid arg '%s' in '%s' (known args: sizeof=member, type=member, type_enum=enum)\n", args, expression); + goto out_free; + +out_missing_value: + fprintf(stderr, "pahole: invalid, missing value in '%s'\n", expression); + goto out_free; + +out_no_closing_parens: + fprintf(stderr, "pahole: invalid, no closing parens in '%s'\n", expression); + goto out_free; + +out_missing_assign: + fprintf(stderr, "pahole: invalid, missing '=' in '%s'\n", args); + goto out_free; + +out_free: + free(prototype); + return NULL; +} + +#ifdef DEBUG_CHECK_LEAKS +static void prototype__delete(struct prototype *prototype) +{ + if (prototype) { + memset(prototype, 0xff, sizeof(*prototype)); + free(prototype); + } +} +#endif + +static struct tag_cu_node *tag_cu_node__new(struct tag *tag, struct cu *cu) +{ + struct tag_cu_node *tc = malloc(sizeof(*tc)); + + if (tc) { + tc->tc.tag = tag; + tc->tc.cu = cu; + } + + return tc; +} + +static int type__add_type_enum(struct type *type, struct tag *type_enum, struct cu *cu) +{ + struct tag_cu_node *tc = tag_cu_node__new(type_enum, cu); + + if (!tc) + return -1; + + list_add_tail(&tc->node, &type->type_enum); + return 0; +} + +static int type__find_type_enum(struct type *type, struct cu *cu, const char *type_enum) +{ + struct tag *te = cu__find_enumeration_by_name(cu, type_enum, NULL); + + if (te) + return type__add_type_enum(type, te, cu); + + // Now look at a 'virtual enum', i.e. the concatenation of multiple enums + char *sep = strchr(type_enum, '+'); + + if (!sep) + return -1; + + char *type_enums = strdup(type_enum); + + if (!type_enums) + return -1; + + int ret = -1; + + sep = type_enums + (sep - type_enum); + + type_enum = type_enums; + *sep = '\0'; + + while (1) { + te = cu__find_enumeration_by_name(cu, type_enum, NULL); + + if (!te) + goto out; + + ret = type__add_type_enum(type, te, cu); + if (ret) + goto out; + + if (sep == NULL) + break; + type_enum = sep + 1; + sep = strchr(type_enum, '+'); + } + + ret = 0; +out: + free(type_enums); + return ret; +} + +static struct type_instance *header; + +static enum load_steal_kind pahole_stealer(struct cu *cu, + struct conf_load *conf_load __unused) +{ + int ret = LSK__DELETE; + + if (!cu__filter(cu)) + goto filter_it; + + if (btf_encode) { + if (cu__encode_btf(cu, global_verbose, btf_encode_force, + skip_encoding_btf_vars)) { + fprintf(stderr, "Encountered error while encoding BTF.\n"); + exit(1); + } + return LSK__DELETE; + } + + if (ctf_encode) { + cu__encode_ctf(cu, global_verbose); + /* + * We still have to get the type signature code merged to eliminate + * dups, reference another CTF file, etc, so for now just encode the + * first cu that is let thru by cu__filter. + */ + goto dump_and_stop; + } + + if (class_name == NULL) { + if (stats_formatter == nr_methods_formatter) { + cu__account_nr_methods(cu); + goto dump_it; + } + + if (word_size != 0) + cu_fixup_word_size_iterator(cu); + + print_classes(cu); + goto dump_it; + } + + if (header == NULL && conf.header_type) { + header = type_instance__new(tag__type(cu__find_type_by_name(cu, conf.header_type, false, NULL)), cu); + if (header) + ret = LSK__KEEPIT; + } + + bool include_decls = find_pointers_in_structs != 0 || stats_formatter == nr_methods_formatter; + struct prototype *prototype, *n; + + list_for_each_entry_safe(prototype, n, &class_names, node) { + + /* See if we already found it */ + if (prototype->class) { + if (prototype->type_enum && !prototype->type_enum_resolved) + prototype->type_enum_resolved = type__find_type_enum(tag__type(prototype->class), cu, prototype->type_enum) == 0; + continue; + } + + static type_id_t class_id; + struct tag *class = cu__find_type_by_name(cu, prototype->name, include_decls, &class_id); + + if (class == NULL) + return ret; // couldn't find that class name in this CU, continue to the next one. + + if (prototype->nr_args != 0 && !tag__is_struct(class)) { + fprintf(stderr, "pahole: attributes are only supported with 'class' and 'struct' types\n"); + goto dump_and_stop; + } + + struct type *type = tag__type(class); + + if (prototype->size) { + type->sizeof_member = type__find_member_by_name(type, cu, prototype->size); + if (type->sizeof_member == NULL) { + fprintf(stderr, "pahole: the sizeof member '%s' wasn't found in the '%s' type\n", + prototype->size, prototype->name); + goto dump_and_stop; + } + } + + if (prototype->type) { + type->type_member = type__find_member_by_name(type, cu, prototype->type); + if (type->type_member == NULL) { + fprintf(stderr, "pahole: the type member '%s' wasn't found in the '%s' type\n", + prototype->type, prototype->name); + goto dump_and_stop; + } + } + + if (prototype->type_enum) { + prototype->type_enum_resolved = type__find_type_enum(type, cu, prototype->type_enum) == 0; + } + + if (prototype->filter) { + type->filter = class_member_filter__new(type, cu, prototype->filter); + if (type->filter == NULL) { + fprintf(stderr, "pahole: invalid filter '%s' for '%s'\n", + prototype->filter, prototype->name); + goto dump_and_stop; + } + } + + if (class == NULL) { + if (strcmp(prototype->name, "void")) + continue; + class_id = 0; + } + + if (!isatty(0)) { + prototype->class = class; + prototype->cu = cu; + continue; + } + + /* + * Ok, found it, so remove from the list to avoid printing it + * twice, in another CU. + */ + list_del_init(&prototype->node); + + if (defined_in) { + puts(cu->name); + goto dump_it; + } + + if (class) + class__find_holes(tag__class(class)); + if (reorganize) { + if (class && tag__is_struct(class)) + do_reorg(class, cu); + } else if (find_containers) + print_containers(cu, class_id, 0); + else if (find_pointers_in_structs) + print_structs_with_pointer_to(cu, class_id); + else if (class) { + /* + * We don't need to print it for every compile unit + * but the previous options need + */ + tag__fprintf(class, cu, &conf, stdout); + putchar('\n'); + } + } + + // If we got here with pretty printing is because we have everything solved except for type_enum + + if (!isatty(0)) { + // Check if we need to continue loading CUs to get those type_enum= resolved + list_for_each_entry(prototype, &class_names, node) { + if (prototype->type_enum && !prototype->type_enum_resolved) + return LSK__KEEPIT; + } + + // All set, pretty print it! + list_for_each_entry_safe(prototype, n, &class_names, node) { + list_del_init(&prototype->node); + if (prototype__stdio_fprintf_value(prototype, header, stdout) < 0) + break; + } + + return LSK__STOP_LOADING; + } + + /* + * If we found all the entries in --class_name, stop + */ + if (list_empty(&class_names)) { +dump_and_stop: + ret = LSK__STOP_LOADING; + } +dump_it: + if (first_obj_only) + ret = LSK__STOP_LOADING; +filter_it: + return ret; +} + +static int prototypes__add(struct list_head *prototypes, const char *entry) +{ + struct prototype *prototype = prototype__new(entry); + + if (prototype == NULL) + return -ENOMEM; + + list_add_tail(&prototype->node, prototypes); + return 0; +} + +#ifdef DEBUG_CHECK_LEAKS +static void prototypes__delete(struct list_head *prototypes) +{ + struct prototype *prototype, *n; + + list_for_each_entry_safe(prototype, n, prototypes, node) { + list_del_init(&prototype->node); + prototype__delete(prototype); + } +} +#endif + +static int prototypes__load(struct list_head *prototypes, const char *filename) +{ + char entry[1024]; + int err = -1; + FILE *fp = fopen(filename, "r"); + + if (fp == NULL) + return -1; + + while (fgets(entry, sizeof(entry), fp) != NULL) { + const size_t len = strlen(entry); + + if (len == 0) + continue; + entry[len - 1] = '\0'; + if (prototypes__add(&class_names, entry)) + goto out; + } + + err = 0; +out: + fclose(fp); + return err; +} + +static int add_class_name_entry(const char *s) +{ + if (strncmp(s, "file://", 7) == 0) { + if (prototypes__load(&class_names, s + 7)) + return -1; + } else switch (prototypes__add(&class_names, s)) { + case -EEXIST: + if (global_verbose) + fprintf(stderr, + "pahole: %s dup in -C, ignoring\n", s); + break; + case -ENOMEM: + return -1; + } + return 0; +} + +static int populate_class_names(void) +{ + char *s = strdup(class_name), *sep; + char *sdup = s, *end = s + strlen(s); + int ret = 0; + + if (!s) { + fprintf(stderr, "Not enough memory for populating class names ('%s')\n", class_name); + return -1; + } + + /* + * Commas inside parameters shouldn't be considered, as those don't + * separate classes, but arguments to a particular class hack a simple + * parser, but really this will end up needing lex/yacc... + */ + while ((sep = strchr(s, ',')) != NULL) { + char *parens = strchr(s, '('); + + // perf_event_header(sizeof=size),a + + if (parens && parens < sep) { + char *close_parens = strchr(parens, ')'); + ret = -1; + if (!close_parens) { + fprintf(stderr, "Unterminated '(' in '%s'\n", class_name); + fprintf(stderr, " %*.s^\n", (int)(parens - sdup), ""); + goto out_free; + } + if (close_parens > sep) + sep = close_parens + 1; + } + + *sep = '\0'; + ret = add_class_name_entry(s); + if (ret) + goto out_free; + + while (isspace(*sep)) + ++sep; + + if (sep == end) + goto out_free; + + s = sep + 1; + } + + ret = add_class_name_entry(s); +out_free: + free(sdup); + return ret; +} + +int main(int argc, char *argv[]) +{ + int err, remaining, rc = EXIT_FAILURE; + + if (!isatty(0)) + conf.hex_fmt = 0; + + if (argp_parse(&pahole__argp, argc, argv, 0, &remaining, NULL)) { + argp_help(&pahole__argp, stderr, ARGP_HELP_SEE, argv[0]); + goto out; + } + + if (print_numeric_version) { + dwarves_print_numeric_version(stdout); + return 0; + } + + if (dwarves__init(cacheline_size)) { + fputs("pahole: insufficient memory\n", stderr); + goto out; + } + + if (base_btf_file) { + base_btf = btf__parse(base_btf_file, NULL); + if (libbpf_get_error(base_btf)) { + fprintf(stderr, "Failed to parse base BTF '%s': %ld\n", + base_btf_file, libbpf_get_error(base_btf)); + goto out; + } + if (!btf_encode && !ctf_encode) { + // Force "btf" since a btf_base is being informed + conf_load.format_path = "btf"; + } + } + + struct cus *cus = cus__new(); + if (cus == NULL) { + fputs("pahole: insufficient memory\n", stderr); + goto out_dwarves_exit; + } + + memset(tab, ' ', sizeof(tab) - 1); + + conf_load.steal = pahole_stealer; + + // Make 'pahole --header type < file' a shorter form of 'pahole -C type --count 1 < file' + if (conf.header_type && !class_name && !isatty(0)) { + conf.count = 1; + class_name = conf.header_type; + conf.header_type = 0; // so that we don't read it and then try to read the -C type + } + +try_sole_arg_as_class_names: + if (class_name && populate_class_names()) + goto out_dwarves_exit; + + if (base_btf_file == NULL) { + const char *filename = argv[remaining]; + + if (filename && + strstarts(filename, "/sys/kernel/btf/") && + strstr(filename, "/vmlinux") == NULL) { + base_btf_file = "/sys/kernel/btf/vmlinux"; + base_btf = btf__parse(base_btf_file, NULL); + if (libbpf_get_error(base_btf)) { + fprintf(stderr, "Failed to parse base BTF '%s': %ld\n", + base_btf_file, libbpf_get_error(base_btf)); + goto out; + } + } + } + + err = cus__load_files(cus, &conf_load, argv + remaining); + if (err != 0) { + if (class_name == NULL && !btf_encode && !ctf_encode) { + class_name = argv[remaining]; + if (access(class_name, R_OK) == 0) { + fprintf(stderr, "pahole: file '%s' has no %s type information.\n", + class_name, conf_load.format_path ?: "supported"); + goto out_dwarves_exit; + } + remaining = argc; + goto try_sole_arg_as_class_names; + } + cus__fprintf_load_files_err(cus, "pahole", argv + remaining, err, stderr); + goto out_cus_delete; + } + + if (!list_empty(&class_names)) { + struct prototype *prototype; + + list_for_each_entry(prototype, &class_names, node) { + if (prototype->class == NULL) { + fprintf(stderr, "pahole: type '%s' not found%s\n", prototype->name, + prototype->nr_args ? " or arguments not validated" : ""); + break; + } else { + struct type *type = tag__type(prototype->class); + + if (prototype->type && !type->type_member) { + fprintf(stderr, "pahole: member 'type=%s' not found in '%s' type\n", + prototype->type, prototype->name); + } + + if (prototype->size && !type->sizeof_member) { + fprintf(stderr, "pahole: member 'sizeof=%s' not found in '%s' type\n", + prototype->size, prototype->name); + } + + if (prototype->filter && !type->filter) { + fprintf(stderr, "pahole: filter 'filter=%s' couldn't be evaluated for '%s' type\n", + prototype->filter, prototype->name); + } + + if (prototype->type_enum && !prototype->type_enum_resolved) { + fprintf(stderr, "pahole: 'type_enum=%s' couldn't be evaluated for '%s' type\n", + prototype->type_enum, prototype->name); + } + } + } + } + + type_instance__delete(header); + header = NULL; + + if (btf_encode) { + err = btf_encoder__encode(); + if (err) { + fputs("Failed to encode BTF\n", stderr); + goto out_cus_delete; + } } if (stats_formatter != NULL) @@ -1260,6 +2841,7 @@ #ifdef DEBUG_CHECK_LEAKS cus__delete(cus); structures__delete(); + btf__free(base_btf); #endif out_dwarves_exit: #ifdef DEBUG_CHECK_LEAKS @@ -1267,7 +2849,7 @@ #endif out: #ifdef DEBUG_CHECK_LEAKS - strlist__delete(class_names); + prototypes__delete(&class_names); #endif return rc; } diff -Nru dwarves-dfsg-1.10/pahole_strings.h dwarves-dfsg-1.21/pahole_strings.h --- dwarves-dfsg-1.10/pahole_strings.h 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/pahole_strings.h 2021-03-07 13:51:27.000000000 +0000 @@ -0,0 +1,31 @@ +#ifndef _STRINGS_H_ +#define _STRINGS_H_ 1 +/* + SPDX-License-Identifier: GPL-2.0-only + + Copyright (C) 2008 Arnaldo Carvalho de Melo +*/ + +#include "lib/bpf/src/btf.h" + +typedef unsigned int strings_t; + +struct strings { + struct btf *btf; +}; + +struct strings *strings__new(void); + +void strings__delete(struct strings *strings); + +strings_t strings__add(struct strings *strings, const char *str); +strings_t strings__find(struct strings *strings, const char *str); +strings_t strings__size(const struct strings *strings); +int strings__copy(const struct strings *strings, void *dst); + +static inline const char *strings__ptr(const struct strings *strings, strings_t s) +{ + return btf__str_by_offset(strings->btf, s); +} + +#endif /* _STRINGS_H_ */ diff -Nru dwarves-dfsg-1.10/pdwtags.c dwarves-dfsg-1.21/pdwtags.c --- dwarves-dfsg-1.10/pdwtags.c 2012-05-14 22:41:11.000000000 +0000 +++ dwarves-dfsg-1.21/pdwtags.c 2019-05-01 18:23:10.000000000 +0000 @@ -1,9 +1,7 @@ /* - Copyright (C) 2007 Arnaldo Carvalho de Melo + SPDX-License-Identifier: GPL-2.0-only - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. + Copyright (C) 2007-2016 Arnaldo Carvalho de Melo */ #include @@ -18,53 +16,56 @@ .emit_stats = 1, }; -static void emit_tag(struct tag *self, uint32_t tag_id, struct cu *cu) +static void emit_tag(struct tag *tag, uint32_t tag_id, struct cu *cu) { printf("/* %d */\n", tag_id); - if (self->tag == DW_TAG_base_type) { + if (tag__is_struct(tag)) + class__find_holes(tag__class(tag)); + + if (tag->tag == DW_TAG_base_type) { char bf[64]; - const char *name = base_type__name(tag__base_type(self), cu, + const char *name = base_type__name(tag__base_type(tag), cu, bf, sizeof(bf)); if (name == NULL) printf("anonymous base_type\n"); else puts(name); - } else if (self->tag == DW_TAG_pointer_type) - printf(" /* pointer to %lld */\n", (unsigned long long)self->type); + } else if (tag__is_pointer(tag)) + printf(" /* pointer to %lld */\n", (unsigned long long)tag->type); else - tag__fprintf(self, cu, &conf, stdout); + tag__fprintf(tag, cu, &conf, stdout); - printf(" /* size: %zd */\n\n", tag__size(self, cu)); + printf(" /* size: %zd */\n\n", tag__size(tag, cu)); } -static int cu__emit_tags(struct cu *self) +static int cu__emit_tags(struct cu *cu) { uint32_t i; struct tag *tag; puts("/* Types: */\n"); - cu__for_each_type(self, i, tag) - emit_tag(tag, i, self); + cu__for_each_type(cu, i, tag) + emit_tag(tag, i, cu); puts("/* Functions: */\n"); conf.no_semicolon = true; struct function *function; - cu__for_each_function(self, i, function) { - tag__fprintf(function__tag(function), self, &conf, stdout); + cu__for_each_function(cu, i, function) { + tag__fprintf(function__tag(function), cu, &conf, stdout); putchar('\n'); - lexblock__fprintf(&function->lexblock, self, function, 0, + lexblock__fprintf(&function->lexblock, cu, function, 0, &conf, stdout); printf(" /* size: %zd */\n\n", - tag__size(function__tag(function), self)); + tag__size(function__tag(function), cu)); } conf.no_semicolon = false; puts("\n\n/* Variables: */\n"); - cu__for_each_variable(self, i, tag) { - tag__fprintf(tag, self, NULL, stdout); - printf(" /* size: %zd */\n\n", tag__size(tag, self)); + cu__for_each_variable(cu, i, tag) { + tag__fprintf(tag, cu, NULL, stdout); + printf(" /* size: %zd */\n\n", tag__size(tag, cu)); } @@ -80,6 +81,7 @@ static struct conf_load pdwtags_conf_load = { .steal = pdwtags_stealer, + .conf_fprintf = &conf, }; /* Name and version of program. */ @@ -127,7 +129,7 @@ int main(int argc, char *argv[]) { - int remaining, rc = EXIT_FAILURE; + int remaining, rc = EXIT_FAILURE, err; struct cus *cus = cus__new(); if (dwarves__init(0) || cus == NULL) { @@ -141,8 +143,13 @@ goto out; } - if (cus__load_files(cus, &pdwtags_conf_load, argv + remaining) == 0) + err = cus__load_files(cus, &pdwtags_conf_load, argv + remaining); + if (err == 0) { rc = EXIT_SUCCESS; + goto out; + } + + cus__fprintf_load_files_err(cus, "pdwtags", argv + remaining, err, stderr); out: cus__delete(cus); dwarves__exit(); diff -Nru dwarves-dfsg-1.10/pfunct.c dwarves-dfsg-1.21/pfunct.c --- dwarves-dfsg-1.10/pfunct.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/pfunct.c 2021-03-07 13:51:27.000000000 +0000 @@ -1,11 +1,9 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo Copyright (C) 2007 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include @@ -32,12 +30,17 @@ static char *symtab_name; static bool show_prototypes; static bool expand_types; +static bool compilable_output; static struct type_emissions emissions; static uint64_t addr; +static char *class_name; +static char *function_name; static struct conf_fprintf conf; -static struct conf_load conf_load; +static struct conf_load conf_load = { + .conf_fprintf = &conf, +}; struct fn_stats { struct list_head node; @@ -50,24 +53,24 @@ static struct fn_stats *fn_stats__new(struct tag *tag, const struct cu *cu) { - struct fn_stats *self = malloc(sizeof(*self)); + struct fn_stats *stats = malloc(sizeof(*stats)); - if (self != NULL) { + if (stats != NULL) { const struct function *fn = tag__function(tag); - self->tag = tag; - self->cu = cu; - self->nr_files = 1; - self->nr_expansions = fn->cu_total_nr_inline_expansions; - self->size_expansions = fn->cu_total_size_inline_expansions; + stats->tag = tag; + stats->cu = cu; + stats->nr_files = 1; + stats->nr_expansions = fn->cu_total_nr_inline_expansions; + stats->size_expansions = fn->cu_total_size_inline_expansions; } - return self; + return stats; } -static void fn_stats__delete(struct fn_stats *self) +static void fn_stats__delete(struct fn_stats *stats) { - free(self); + free(stats); } static LIST_HEAD(fn_stats__list); @@ -100,68 +103,68 @@ list_add(&fns->node, &fn_stats__list); } -static void fn_stats_inline_exps_fmtr(const struct fn_stats *self) +static void fn_stats_inline_exps_fmtr(const struct fn_stats *stats) { - struct function *fn = tag__function(self->tag); + struct function *fn = tag__function(stats->tag); if (fn->lexblock.nr_inline_expansions > 0) - printf("%s: %u %d\n", function__name(fn, self->cu), + printf("%s: %u %d\n", function__name(fn, stats->cu), fn->lexblock.nr_inline_expansions, fn->lexblock.size_inline_expansions); } -static void fn_stats_labels_fmtr(const struct fn_stats *self) +static void fn_stats_labels_fmtr(const struct fn_stats *stats) { - struct function *fn = tag__function(self->tag); + struct function *fn = tag__function(stats->tag); if (fn->lexblock.nr_labels > 0) - printf("%s: %u\n", function__name(fn, self->cu), + printf("%s: %u\n", function__name(fn, stats->cu), fn->lexblock.nr_labels); } -static void fn_stats_variables_fmtr(const struct fn_stats *self) +static void fn_stats_variables_fmtr(const struct fn_stats *stats) { - struct function *fn = tag__function(self->tag); + struct function *fn = tag__function(stats->tag); if (fn->lexblock.nr_variables > 0) - printf("%s: %u\n", function__name(fn, self->cu), + printf("%s: %u\n", function__name(fn, stats->cu), fn->lexblock.nr_variables); } -static void fn_stats_nr_parms_fmtr(const struct fn_stats *self) +static void fn_stats_nr_parms_fmtr(const struct fn_stats *stats) { - struct function *fn = tag__function(self->tag); - printf("%s: %u\n", function__name(fn, self->cu), + struct function *fn = tag__function(stats->tag); + printf("%s: %u\n", function__name(fn, stats->cu), fn->proto.nr_parms); } -static void fn_stats_name_len_fmtr(const struct fn_stats *self) +static void fn_stats_name_len_fmtr(const struct fn_stats *stats) { - struct function *fn = tag__function(self->tag); - const char *name = function__name(fn, self->cu); + struct function *fn = tag__function(stats->tag); + const char *name = function__name(fn, stats->cu); printf("%s: %zd\n", name, strlen(name)); } -static void fn_stats_size_fmtr(const struct fn_stats *self) +static void fn_stats_size_fmtr(const struct fn_stats *stats) { - struct function *fn = tag__function(self->tag); + struct function *fn = tag__function(stats->tag); const size_t size = function__size(fn); if (size != 0) - printf("%s: %zd\n", function__name(fn, self->cu), size); + printf("%s: %zd\n", function__name(fn, stats->cu), size); } -static void fn_stats_fmtr(const struct fn_stats *self) +static void fn_stats_fmtr(const struct fn_stats *stats) { if (verbose || show_prototypes) { - tag__fprintf(self->tag, self->cu, &conf, stdout); + tag__fprintf(stats->tag, stats->cu, &conf, stdout); putchar('\n'); if (show_prototypes) return; if (show_variables || show_inline_expansions) - function__fprintf_stats(self->tag, self->cu, &conf, stdout); - printf("/* definitions: %u */\n", self->nr_files); + function__fprintf_stats(stats->tag, stats->cu, &conf, stdout); + printf("/* definitions: %u */\n", stats->nr_files); putchar('\n'); } else { - struct function *fn = tag__function(self->tag); - puts(function__name(fn, self->cu)); + struct function *fn = tag__function(stats->tag); + puts(function__name(fn, stats->cu)); } } @@ -173,14 +176,14 @@ formatter(pos); } -static void fn_stats_inline_stats_fmtr(const struct fn_stats *self) +static void fn_stats_inline_stats_fmtr(const struct fn_stats *stats) { - if (self->nr_expansions > 1) + if (stats->nr_expansions > 1) printf("%-31.31s %6u %7u %6u %6u\n", - function__name(tag__function(self->tag), self->cu), - self->size_expansions, self->nr_expansions, - self->size_expansions / self->nr_expansions, - self->nr_files); + function__name(tag__function(stats->tag), stats->cu), + stats->size_expansions, stats->nr_expansions, + stats->size_expansions / stats->nr_expansions, + stats->nr_files); } static void print_total_inline_stats(void) @@ -190,8 +193,8 @@ print_fn_stats(fn_stats_inline_stats_fmtr); } -static void fn_stats__dupmsg(struct function *self, - const struct cu *self_cu, +static void fn_stats__dupmsg(struct function *func, + const struct cu *func_cu, struct function *dup __unused, const struct cu *dup_cu, char *hdr, const char *fmt, ...) @@ -200,8 +203,8 @@ if (!*hdr) printf("function: %s\nfirst: %s\ncurrent: %s\n", - function__name(self, self_cu), - self_cu->name, + function__name(func, func_cu), + func_cu->name, dup_cu->name); va_start(args, fmt); @@ -210,24 +213,24 @@ *hdr = 1; } -static void fn_stats__chkdupdef(struct function *self, - const struct cu *self_cu, +static void fn_stats__chkdupdef(struct function *func, + const struct cu *func_cu, struct function *dup, const struct cu *dup_cu) { char hdr = 0; - const size_t self_size = function__size(self); + const size_t func_size = function__size(func); const size_t dup_size = function__size(dup); - if (self_size != dup_size) - fn_stats__dupmsg(self, self_cu, dup, dup_cu, + if (func_size != dup_size) + fn_stats__dupmsg(func, func_cu, dup, dup_cu, &hdr, "size: %zd != %zd\n", - self_size, dup_size); + func_size, dup_size); - if (self->proto.nr_parms != dup->proto.nr_parms) - fn_stats__dupmsg(self, self_cu, dup, dup_cu, + if (func->proto.nr_parms != dup->proto.nr_parms) + fn_stats__dupmsg(func, func_cu, dup, dup_cu, &hdr, "nr_parms: %u != %u\n", - self->proto.nr_parms, dup->proto.nr_parms); + func->proto.nr_parms, dup->proto.nr_parms); /* XXX put more checks here: member types, member ordering, etc */ @@ -294,7 +297,7 @@ static int cu_class_iterator(struct cu *cu, void *cookie) { - uint16_t target_id; + type_id_t target_id; struct tag *target = cu__find_struct_by_name(cu, cookie, 0, &target_id); if (target == NULL) @@ -318,25 +321,45 @@ return 0; } -static int function__emit_type_definitions(struct function *self, +static int function__emit_type_definitions(struct function *func, struct cu *cu, FILE *fp) { struct parameter *pos; + struct ftype *proto = func->btf ? tag__ftype(cu__type(cu, func->proto.tag.type)) : &func->proto; + struct tag *type = cu__type(cu, proto->tag.type); - function__for_each_parameter(self, pos) { - struct tag *type = cu__type(cu, pos->tag.type); +retry_return_type: + /* type == NULL means the return is void */ + if (type == NULL) + goto do_parameters; + + if (tag__is_pointer(type) || tag__is_modifier(type)) { + type = cu__type(cu, type->type); + goto retry_return_type; + } + + if (tag__is_type(type) && !tag__type(type)->definition_emitted) { + type__emit_definitions(type, cu, &emissions, fp); + type__emit(type, cu, NULL, NULL, fp); + } +do_parameters: + ftype__for_each_parameter(proto, pos) { + type = cu__type(cu, pos->tag.type); try_again: if (type == NULL) continue; - if (type->tag == DW_TAG_pointer_type) { + if (tag__is_pointer(type) || tag__is_modifier(type)) { type = cu__type(cu, type->type); goto try_again; } - if (tag__is_type(type)) { + if (type->tag == DW_TAG_subroutine_type) { + ftype__emit_definitions(tag__ftype(type), cu, &emissions, fp); + } else if (tag__is_type(type) && !tag__type(type)->definition_emitted) { type__emit_definitions(type, cu, &emissions, fp); - type__emit(type, cu, NULL, NULL, fp); + if (!tag__is_typedef(type)) + type__emit(type, cu, NULL, NULL, fp); putchar('\n'); } } @@ -344,13 +367,34 @@ return 0; } -static void function__show(struct function *self, struct cu *cu) +static void function__show(struct function *func, struct cu *cu) { - struct tag *tag = function__tag(self); + struct tag *tag = function__tag(func); + + if (func->abstract_origin || func->external) + return; if (expand_types) - function__emit_type_definitions(self, cu, stdout); + function__emit_type_definitions(func, cu, stdout); tag__fprintf(tag, cu, &conf, stdout); + if (compilable_output) { + struct tag *type = cu__type(cu, func->proto.tag.type); + + fprintf(stdout, "\n{"); + if (type != NULL && type->type != 0) { /* NULL == void */ + if (tag__is_pointer(type)) + fprintf(stdout, "\n\treturn (void *)0;"); + else if (tag__is_struct(type)) + fprintf(stdout, "\n\treturn *(struct %s *)1;", class__name(tag__class(type), cu)); + else if (tag__is_union(type)) + fprintf(stdout, "\n\treturn *(union %s *)1;", type__name(tag__type(type), cu)); + else if (tag__is_typedef(type)) + fprintf(stdout, "\n\treturn *(%s *)1;", type__name(tag__type(type), cu)); + else + fprintf(stdout, "\n\treturn 0;"); + } + fprintf(stdout, "\n}\n"); + } putchar('\n'); if (show_variables || show_inline_expansions) function__fprintf_stats(tag, cu, &conf, stdout); @@ -362,10 +406,11 @@ uint32_t id; cu__for_each_function(cu, id, function) { - if (strcmp(function__name(function, cu), cookie) != 0) + if (cookie && strcmp(function__name(function, cu), cookie) != 0) continue; function__show(function, cu); - return 1; + if (!expand_types) + return 1; } return 0; } @@ -451,11 +496,29 @@ return EXIT_SUCCESS; } +static enum load_steal_kind pfunct_stealer(struct cu *cu, struct conf_load *conf_load __unused) +{ + + if (function_name) { + struct tag *tag = cu__find_function_by_name(cu, function_name); + + if (tag) { + function__show(tag__function(tag), cu); + return LSK__STOP_LOADING; + } + } else if (class_name) { + cu_class_iterator(cu, class_name); + } + + return LSK__DELETE; +} + /* Name and version of program. */ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version; #define ARGP_symtab 300 #define ARGP_no_parm_names 301 +#define ARGP_compile 302 static const struct argp_option pfunct__options[] = { { @@ -570,6 +633,13 @@ .doc = "show symbol table NAME (Default .symtab)", }, { + .name = "compile", + .key = ARGP_compile, + .arg = "FUNCTION", + .flags = OPTION_ARG_OPTIONAL, + .doc = "Generate compilable source code with types expanded (Default all functions)", + }, + { .name = "no_parm_names", .key = ARGP_no_parm_names, .doc = "Don't show parameter names", @@ -580,8 +650,6 @@ }; static void (*formatter)(const struct fn_stats *f) = fn_stats_fmtr; -static char *class_name; -static char *function_name; static int show_total_inline_expansion_stats; static error_t pfunct__options_parser(int key, char *arg, @@ -624,6 +692,15 @@ conf_load.get_addr_info = true; break; case ARGP_symtab: symtab_name = arg ?: ".symtab"; break; case ARGP_no_parm_names: conf.no_parm_names = 1; break; + case ARGP_compile: + expand_types = true; + type_emissions__init(&emissions); + compilable_output = true; + conf.no_semicolon = true; + conf.strip_inline = true; + if (arg) + function_name = arg; + break; default: return ARGP_ERR_UNKNOWN; } @@ -643,7 +720,7 @@ int err, remaining, rc = EXIT_FAILURE; if (argp_parse(&pfunct__argp, argc, argv, 0, &remaining, NULL) || - remaining == argc) { + (remaining == argc && class_name == NULL && function_name == NULL)) { argp_help(&pfunct__argp, stderr, ARGP_HELP_SEE, argv[0]); goto out; } @@ -662,9 +739,27 @@ goto out_dwarves_exit; } + if (function_name || class_name) + conf_load.steal = pfunct_stealer; + +try_sole_arg_as_function_name: err = cus__load_files(cus, &conf_load, argv + remaining); - if (err != 0) + if (err != 0) { + if (function_name == NULL) { + function_name = argv[remaining]; + if (access(function_name, R_OK) == 0) { + fprintf(stderr, "pfunct: file '%s' has no %s type information.\n", + function_name, conf_load.format_path ?: "supported"); + goto out_dwarves_exit; + } + conf_load.steal = pfunct_stealer; + remaining = argc; + goto try_sole_arg_as_function_name; + } + cus__fprintf_load_files_err(cus, "pfunct", argv + remaining, err, stderr); goto out_cus_delete; + } + cus__for_each_cu(cus, cu_unique_iterator, NULL, NULL); @@ -680,9 +775,7 @@ function__show(f, cu); } else if (show_total_inline_expansion_stats) print_total_inline_stats(); - else if (class_name != NULL) - cus__for_each_cu(cus, cu_class_iterator, class_name, NULL); - else if (function_name != NULL) + else if (function_name != NULL || expand_types) cus__for_each_cu(cus, cu_function_iterator, function_name, NULL); else diff -Nru dwarves-dfsg-1.10/pglobal.c dwarves-dfsg-1.21/pglobal.c --- dwarves-dfsg-1.10/pglobal.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/pglobal.c 2019-12-13 14:41:01.000000000 +0000 @@ -1,10 +1,7 @@ /* + * SPDX-License-Identifier: GPL-2.0-only * * Copyright (C) 2007 Davi E. M. Arnaut - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as published - * by the Free Software Foundation. */ #include @@ -20,6 +17,14 @@ static int verbose; +static struct conf_fprintf conf = { + .emit_stats = 1, +}; + +static struct conf_load conf_load = { + .conf_fprintf = &conf, +}; + struct extvar { struct extvar *next; const char *name; @@ -92,7 +97,7 @@ nodep = tsearch(gvar, &tree, extvar__compare); if (nodep == NULL) oom("tsearch"); - else if (*nodep != gvar) + else if (*nodep != gvar) { if (gvar->var->declaration) { gvar->next = (*nodep)->next; (*nodep)->next = gvar; @@ -100,6 +105,7 @@ gvar->next = *nodep; *nodep = gvar; } + } } } @@ -245,6 +251,12 @@ .doc = "show global functions", }, { + .name = "format_path", + .key = 'F', + .arg = "FORMAT_LIST", + .doc = "List of debugging formats to try" + }, + { .key = 'V', .name = "verbose", .doc = "be verbose", @@ -267,6 +279,7 @@ case 'v': walk_var = 1; break; case 'f': walk_fun = 1; break; case 'V': verbose = 1; break; + case 'F': conf_load.format_path = arg; break; default: return ARGP_ERR_UNKNOWN; } return 0; @@ -301,9 +314,11 @@ goto out_dwarves_exit; } - err = cus__load_files(cus, NULL, argv + remaining); - if (err != 0) + err = cus__load_files(cus, &conf_load, argv + remaining); + if (err != 0) { + cus__fprintf_load_files_err(cus, "pglobal", argv + remaining, err, stderr); goto out_cus_delete; + } if (walk_var) { cus__for_each_cu(cus, cu_extvar_iterator, NULL, NULL); diff -Nru dwarves-dfsg-1.10/prefcnt.c dwarves-dfsg-1.21/prefcnt.c --- dwarves-dfsg-1.10/prefcnt.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/prefcnt.c 2019-12-13 14:40:33.000000000 +0000 @@ -1,10 +1,8 @@ /* + SPDX-License-Identifier: GPL-2.0-only + Copyright (C) 2006 Mandriva Conectiva S.A. Copyright (C) 2006 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. */ #include @@ -66,9 +64,10 @@ tag->visited = 1; - if (tag__is_struct(tag) || tag__is_union(tag)) + if (tag__is_struct(tag) || tag__is_union(tag)) { type__for_each_member(tag__type(tag), member) refcnt_member(member, cu); + } } static void refcnt_lexblock(const struct lexblock *lexblock, const struct cu *cu) @@ -143,8 +142,10 @@ } err = cus__load_files(cus, NULL, argv + 1); - if (err != 0) + if (err != 0) { + cus__fprintf_load_files_err(cus, "prefcnt", argv + 1, err, stderr); return EXIT_FAILURE; + } cus__for_each_cu(cus, cu_refcnt_iterator, NULL, NULL); cus__for_each_cu(cus, cu_lost_iterator, NULL, NULL); diff -Nru dwarves-dfsg-1.10/rbtree.c dwarves-dfsg-1.21/rbtree.c --- dwarves-dfsg-1.10/rbtree.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/rbtree.c 2019-05-01 15:06:45.000000000 +0000 @@ -1,22 +1,10 @@ /* + SPDX-License-Identifier: GPL-2.0-or-later + Red Black Trees (C) 1999 Andrea Arcangeli (C) 2002 David Woodhouse - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - linux/lib/rbtree.c */ diff -Nru dwarves-dfsg-1.10/rbtree.h dwarves-dfsg-1.21/rbtree.h --- dwarves-dfsg-1.10/rbtree.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/rbtree.h 2019-05-01 15:06:45.000000000 +0000 @@ -1,21 +1,9 @@ /* + SPDX-License-Identifier: GPL-2.0-or-later + Red Black Trees (C) 1999 Andrea Arcangeli - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - linux/include/linux/rbtree.h To use rbtrees you'll have to implement your own insert and search cores. diff -Nru dwarves-dfsg-1.10/README.btf dwarves-dfsg-1.21/README.btf --- dwarves-dfsg-1.10/README.btf 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/README.btf 2019-05-01 18:23:10.000000000 +0000 @@ -0,0 +1,598 @@ +We'll test the BTF encoder using perf's eBPF integration, but really we can plain +use clang directly, setting up all its options. + +Using perf's integration will save some time here, to see all it does, use +'perf trace -vv' plus the options used below, then all the steps will be shown. + +Build perf from the latest kernel sources, use it with clang/llvm like: + + [root@seventh ~]# clang --version + clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566eefef9c3777bd780ec4cbb9efa764633b76c) + Target: x86_64-unknown-linux-gnu + Thread model: posix + InstalledDir: /usr/local/bin + [root@seventh ~]# llc --version | head -17 + LLVM (http://llvm.org/): + LLVM version 8.0.0svn + DEBUG build with assertions. + Default target: x86_64-unknown-linux-gnu + Host CPU: skylake + + Registered Targets: + aarch64 - AArch64 (little endian) + aarch64_be - AArch64 (big endian) + amdgcn - AMD GCN GPUs + arm - ARM + arm64 - ARM64 (little endian) + armeb - ARM (big endian) + bpf - BPF (host endian) + bpfeb - BPF (big endian) + bpfel - BPF (little endian) + hexagon - Hexagon + [root@seventh ~]# + +Then enable saving the object file build as part of perf's handling of foo.c type +events, i.e. eBPF programs that will be compiled with clang and then loaded with +sys_bpf() to possibly insert events in perf's ring buffer via bpf_perf_event_output(), +or interact with the system via bpf_trace_printk() or just work as filters, etc: + + # cat ~/.perfconfig + [llvm] + dump-obj = true + +Then run a simple example, found in the kernel sources: + + # perf trace -e tools/perf/examples/bpf/hello.c cat /etc/passwd > /dev/null + LLVM: dumping tools/perf/examples/bpf/hello.o + 0.000 __bpf_stdout__:Hello, world + 0.028 __bpf_stdout__:Hello, world + 0.291 __bpf_stdout__:Hello, world + # + +Notice that "LLVM: dumping..." line, look at the ELF sections in that file: + + [root@seventh perf]# readelf -SW tools/perf/examples/bpf/hello.o + There are 11 section headers, starting at offset 0x220: + + Section Headers: + [Nr] Name Type Address Off Size ES Flg Lk Inf Al + [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 + [ 1] .strtab STRTAB 0000000000000000 00018c 00008d 00 0 0 1 + [ 2] .text PROGBITS 0000000000000000 000040 000000 00 AX 0 0 4 + [ 3] syscalls:sys_enter_openat PROGBITS 0000000000000000 000040 000088 00 AX 0 0 8 + [ 4] .relsyscalls:sys_enter_openat REL 0000000000000000 000178 000010 10 10 3 8 + [ 5] maps PROGBITS 0000000000000000 0000c8 00001c 00 WA 0 0 4 + [ 6] .rodata.str1.1 PROGBITS 0000000000000000 0000e4 00000e 01 AMS 0 0 1 + [ 7] license PROGBITS 0000000000000000 0000f2 000004 00 WA 0 0 1 + [ 8] version PROGBITS 0000000000000000 0000f8 000004 00 WA 0 0 4 + [ 9] .llvm_addrsig LOOS+0xfff4c03 0000000000000000 000188 000004 00 E 10 0 1 + [10] .symtab SYMTAB 0000000000000000 000100 000078 18 1 1 8 + Key to Flags: + W (write), A (alloc), X (execute), M (merge), S (strings), I (info), + L (link order), O (extra OS processing required), G (group), T (TLS), + C (compressed), x (unknown), o (OS specific), E (exclude), + p (processor specific) + [root@seventh perf]# + +No DWARF debugging info, so we need to further customize ~/.perfconfig LLVM section: + + [root@seventh perf]# cat ~/.perfconfig + [llvm] + dump-obj = true + clang-opt = -g + [root@seventh perf]# perf trace -e tools/perf/examples/bpf/hello.c cat /etc/passwd > /dev/null + LLVM: dumping tools/perf/examples/bpf/hello.o + 0.000 __bpf_stdout__:Hello, world + 0.015 __bpf_stdout__:Hello, world + 0.184 __bpf_stdout__:Hello, world + [root@seventh perf]# + [root@seventh perf]# readelf -SW tools/perf/examples/bpf/hello.o + There are 26 section headers, starting at offset 0xe20: + + Section Headers: + [Nr] Name Type Address Off Size ES Flg Lk Inf Al + [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 + [ 1] .strtab STRTAB 0000000000000000 000cf4 000127 00 0 0 1 + [ 2] .text PROGBITS 0000000000000000 000040 000000 00 AX 0 0 4 + [ 3] syscalls:sys_enter_openat PROGBITS 0000000000000000 000040 000088 00 AX 0 0 8 + [ 4] .relsyscalls:sys_enter_openat REL 0000000000000000 000a80 000010 10 25 3 8 + [ 5] maps PROGBITS 0000000000000000 0000c8 00001c 00 WA 0 0 4 + [ 6] .rodata.str1.1 PROGBITS 0000000000000000 0000e4 00000e 01 AMS 0 0 1 + [ 7] license PROGBITS 0000000000000000 0000f2 000004 00 WA 0 0 1 + [ 8] version PROGBITS 0000000000000000 0000f8 000004 00 WA 0 0 4 + [ 9] .debug_str PROGBITS 0000000000000000 0000fc 0001d2 01 MS 0 0 1 + [10] .debug_loc PROGBITS 0000000000000000 0002ce 000023 00 0 0 1 + [11] .debug_abbrev PROGBITS 0000000000000000 0002f1 0000e3 00 0 0 1 + [12] .debug_info PROGBITS 0000000000000000 0003d4 000182 00 0 0 1 + [13] .rel.debug_info REL 0000000000000000 000a90 000210 10 25 12 8 + [14] .debug_ranges PROGBITS 0000000000000000 000556 000030 00 0 0 1 + [15] .debug_macinfo PROGBITS 0000000000000000 000586 000001 00 0 0 1 + [16] .debug_pubnames PROGBITS 0000000000000000 000587 00006e 00 0 0 1 + [17] .rel.debug_pubnames REL 0000000000000000 000ca0 000010 10 25 16 8 + [18] .debug_pubtypes PROGBITS 0000000000000000 0005f5 000056 00 0 0 1 + [19] .rel.debug_pubtypes REL 0000000000000000 000cb0 000010 10 25 18 8 + [20] .debug_frame PROGBITS 0000000000000000 000650 000028 00 0 0 8 + [21] .rel.debug_frame REL 0000000000000000 000cc0 000020 10 25 20 8 + [22] .debug_line PROGBITS 0000000000000000 000678 0000a7 00 0 0 1 + [23] .rel.debug_line REL 0000000000000000 000ce0 000010 10 25 22 8 + [24] .llvm_addrsig LOOS+0xfff4c03 0000000000000000 000cf0 000004 00 E 25 0 1 + [25] .symtab SYMTAB 0000000000000000 000720 000360 18 1 32 8 + Key to Flags: + W (write), A (alloc), X (execute), M (merge), S (strings), I (info), + L (link order), O (extra OS processing required), G (group), T (TLS), + C (compressed), x (unknown), o (OS specific), E (exclude), + p (processor specific) + [root@seventh perf]# + +Now lets use 'pahole --btf_encode' (or 'pahole -J') to add an ELF section to that object +file with the conversion from the DWARF sections to a new one, for BTF: + + [root@seventh perf]# pahole --btf_encode tools/perf/examples/bpf/hello.o + + [root@seventh perf]# readelf -SW tools/perf/examples/bpf/hello.o + There are 27 section headers, starting at offset 0x1080: + + Section Headers: + [Nr] Name Type Address Off Size ES Flg Lk Inf Al + [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 + [ 1] .text PROGBITS 0000000000000000 000040 000000 00 AX 0 0 4 + [ 2] syscalls:sys_enter_openat PROGBITS 0000000000000000 000040 000088 00 AX 0 0 8 + [ 3] maps PROGBITS 0000000000000000 0000c8 00001c 00 WA 0 0 4 + [ 4] .rodata.str1.1 PROGBITS 0000000000000000 0000e4 00000e 01 AMS 0 0 1 + [ 5] license PROGBITS 0000000000000000 0000f2 000004 00 WA 0 0 1 + [ 6] version PROGBITS 0000000000000000 0000f8 000004 00 WA 0 0 4 + [ 7] .debug_str PROGBITS 0000000000000000 0000fc 0001d2 01 MS 0 0 1 + [ 8] .debug_loc PROGBITS 0000000000000000 0002ce 000023 00 0 0 1 + [ 9] .debug_abbrev PROGBITS 0000000000000000 0002f1 0000e3 00 0 0 1 + [10] .debug_info PROGBITS 0000000000000000 0003d4 000182 00 0 0 1 + [11] .debug_ranges PROGBITS 0000000000000000 000556 000030 00 0 0 1 + [12] .debug_macinfo PROGBITS 0000000000000000 000586 000001 00 0 0 1 + [13] .debug_pubnames PROGBITS 0000000000000000 000587 00006e 00 0 0 1 + [14] .debug_pubtypes PROGBITS 0000000000000000 0005f5 000056 00 0 0 1 + [15] .debug_frame PROGBITS 0000000000000000 000650 000028 00 0 0 8 + [16] .debug_line PROGBITS 0000000000000000 000678 0000a7 00 0 0 1 + [17] .symtab SYMTAB 0000000000000000 000720 000360 18 25 32 8 + [18] .relsyscalls:sys_enter_openat REL 0000000000000000 000a80 000010 10 17 2 8 + [19] .rel.debug_info REL 0000000000000000 000a90 000210 10 17 10 8 + [20] .rel.debug_pubnames REL 0000000000000000 000ca0 000010 10 17 13 8 + [21] .rel.debug_pubtypes REL 0000000000000000 000cb0 000010 10 17 14 8 + [22] .rel.debug_frame REL 0000000000000000 000cc0 000020 10 17 15 8 + [23] .rel.debug_line REL 0000000000000000 000ce0 000010 10 17 16 8 + [24] .llvm_addrsig LOOS+0xfff4c03 0000000000000000 000cf0 000004 00 E 0 0 1 + [25] .strtab STRTAB 0000000000000000 000cf4 00019c 00 0 0 1 + [26] .BTF PROGBITS 0000000000000000 000e90 0001ea 00 0 0 1 + Key to Flags: + W (write), A (alloc), X (execute), M (merge), S (strings), I (info), + L (link order), O (extra OS processing required), G (group), T (TLS), + C (compressed), x (unknown), o (OS specific), E (exclude), + p (processor specific) + readelf: tools/perf/examples/bpf/hello.o: Warning: possibly corrupt ELF header - it has a non-zero program header offset, but no program headers + [root@seventh perf]# + +That new ".BTF" section should then be parseable by the kernel, that has a BTF +decoder, something not available for pahole at this time, but that will come in +a later version. + +When pahole tries to read the DWARF info in that BPF ELF file, hello.o, we can se +a problem that will require us to add another option to the .perfconfig llvm section: + + # pahole tools/perf/examples/bpf/hello.o + struct clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566eefef9c3777bd780ec4cbb9efa764633b76c) { + clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566ec377 clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566eefef9c3777bd780ec4cbb9efa764633b76c); /* 0 4 */ + clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566ec377 clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566eefef9c3777bd780ec4cbb9efa764633b76c); /* 4 4 */ + clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566ec377 clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566eefef9c3777bd780ec4cbb9efa764633b76c); /* 8 4 */ + clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566ec377 clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566eefef9c3777bd780ec4cbb9efa764633b76c); /* 12 4 */ + clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566ec377 clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566eefef9c3777bd780ec4cbb9efa764633b76c); /* 16 4 */ + clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566ec377 clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566eefef9c3777bd780ec4cbb9efa764633b76c); /* 20 4 */ + clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566ec377 clang version 8.0.0 (http://llvm.org/git/clang.git 8587270a739ee30c926a76d5657e65e85b560f6e) (http://llvm.org/git/llvm.git 0566eefef9c3777bd780ec4cbb9efa764633b76c); /* 24 4 */ + + /* size: 28, cachelines: 1, members: 7 */ + /* last cacheline: 28 bytes */ + }; +# + +We need to pass some options to llvm, via the llvm.opts variable in ~/.perfconfig: + + [root@seventh perf]# cat ~/.perfconfig + [llvm] + dump-obj = true + clang-opt = -g + opts = -mattr=dwarfris + [root@seventh perf]# perf trace -e tools/perf/examples/bpf/hello.c cat /etc/passwd > /dev/null + LLVM: dumping tools/perf/examples/bpf/hello.o + 0.000 __bpf_stdout__:Hello, world + 0.018 __bpf_stdout__:Hello, world + 0.209 __bpf_stdout__:Hello, world + [root@seventh perf]# pahole tools/perf/examples/bpf/hello.o + struct bpf_map { + unsigned int type; /* 0 4 */ + unsigned int key_size; /* 4 4 */ + unsigned int value_size; /* 8 4 */ + unsigned int max_entries; /* 12 4 */ + unsigned int map_flags; /* 16 4 */ + unsigned int inner_map_idx; /* 20 4 */ + unsigned int numa_node; /* 24 4 */ + + /* size: 28, cachelines: 1, members: 7 */ + /* last cacheline: 28 bytes */ + }; + [root@seventh perf]# + +This is not needed when using elfutils >= 0.173, pahole will just work as above. + +Now we need to go test the kernel, and to load that file with a BTF section we +can also use perf, passing the .o file instead of the .c one, skipping the +compilation phase and using the modified .o file, we will also run in system +wide mode, so taht we can keep that BPF object loaded and attached to the +tracepoint, so that we can use the kernel facilities to inspect the BTF file as +read and processed by the kernel: + + # perf trace -e tools/perf/examples/bpf/hello.c 2> /dev/null + +Now to look if the kernel has the bpf filesystem: + + [acme@jouet perf]$ grep bpf /proc/filesystems + nodev bpf + [acme@jouet perf]$ + [root@jouet ~]# mount -t bpf nodev /sys/fs/bpf + [root@jouet ~]# mount | grep bpf + nodev on /sys/fs/bpf type bpf (rw,relatime) + [root@jouet ~]# cd /sys/fs/bpf + [root@jouet bpf]# ls -la + total 0 + drwxrwxrwt. 2 root root 0 Aug 15 17:42 . + drwxr-xr-x. 10 root root 0 Aug 13 15:04 .. + [root@jouet bpf]# + +Work is planned to allow using BTF info to pretty print from the bpf fs, see: + + https://www.spinics.net/lists/netdev/msg518606.html + Date: Sat, 11 Aug 2018 + + +For bpftool, BTF pretty print support is missing +for per-cpu maps. bpffs print for per-cpu hash/array maps +need to be added as well. Will add them later. + +Acked-by: Yonghong Song + + +To see what libbpf and its users, like perf, does when a ".BTF" ELF section is +found in a BPF object being loaded via sys_bpf(), we can use 'perf ftrace' to +show the sequence of events inside the kernel to load, validade and initialize +data structures related to the request: + + # perf ftrace -G *btf* perf trace -e tools/perf/examples/bpf/hello.o cat /etc/passwd + 3) | bpf_btf_load() { + 3) | capable() { + 3) | ns_capable_common() { + 3) | security_capable() { + 3) 0.048 us | cap_capable(); + 3) | selinux_capable() { + 3) 0.092 us | cred_has_capability(); + 3) 0.444 us | } + 3) 1.387 us | } + 3) 1.764 us | } + 3) 2.168 us | } + 3) | btf_new_fd() { + 3) | kmem_cache_alloc_trace() { + 3) | _cond_resched() { + 3) 0.041 us | rcu_all_qs(); + 3) 0.407 us | } + 3) 0.040 us | should_failslab(); + 3) 0.161 us | prefetch_freepointer(); + 3) 0.097 us | memcg_kmem_put_cache(); + 3) 2.719 us | } + 3) | kmem_cache_alloc_trace() { + 3) | _cond_resched() { + 3) 0.040 us | rcu_all_qs(); + 3) 0.409 us | } + 3) 0.040 us | should_failslab(); + 3) 0.110 us | prefetch_freepointer(); + 3) 0.099 us | memcg_kmem_put_cache(); + 3) 2.296 us | } + 3) 0.054 us | bpf_check_uarg_tail_zero(); + 3) | __check_object_size() { + 3) 0.152 us | __virt_addr_valid(); + 3) 0.047 us | __check_heap_object(); + 3) 0.040 us | check_stack_object(); + 3) 1.465 us | } + 3) 0.041 us | btf_sec_info_cmp(); + 3) | kvmalloc_node() { + 3) | __kmalloc_node() { + 3) 0.051 us | kmalloc_slab(); + 3) | _cond_resched() { + 3) 0.042 us | rcu_all_qs(); + 3) 0.401 us | } + 3) 0.038 us | should_failslab(); + 3) 0.040 us | memcg_kmem_put_cache(); + 3) 2.168 us | } + 3) 2.591 us | } + 3) | __check_object_size() { + 3) 0.108 us | __virt_addr_valid(); + 3) 0.050 us | __check_heap_object(); + 3) 0.039 us | check_stack_object(); + 3) 1.469 us | } + 3) | btf_struct_check_meta() { + 3) 0.057 us | __btf_verifier_log_type(); + 3) 0.057 us | btf_verifier_log_member(); + 3) 0.043 us | btf_verifier_log_member(); + 3) 0.042 us | btf_verifier_log_member(); + 3) 0.043 us | btf_verifier_log_member(); + 3) 0.043 us | btf_verifier_log_member(); + 3) | btf_verifier_log_member() { + 3) ==========> | + 3) | smp_irq_work_interrupt() { + 3) | irq_enter() { + 3) | rcu_irq_enter() { + 3) 0.038 us | rcu_nmi_enter(); + 3) 0.412 us | } + 3) 0.054 us | irqtime_account_irq(); + 3) 1.409 us | } + 3) | __wake_up() { + 3) | __wake_up_common_lock() { + 3) 0.040 us | _raw_spin_lock_irqsave(); + 3) 0.051 us | __wake_up_common(); + 3) 0.044 us | _raw_spin_unlock_irqrestore(); + 3) 1.155 us | } + 3) 1.508 us | } + 3) | irq_exit() { + 3) 0.062 us | irqtime_account_irq(); + 3) 0.038 us | idle_cpu(); + 3) | rcu_irq_exit() { + 3) 0.038 us | rcu_nmi_exit(); + 3) 0.419 us | } + 3) 1.601 us | } + 3) 6.230 us | } + 3) <========== | + 3) 0.088 us | } /* btf_verifier_log_member */ + 3) 0.041 us | btf_verifier_log_member(); + 3) + 10.759 us | } + 3) | kvmalloc_node() { + 3) | __kmalloc_node() { + 3) 0.043 us | kmalloc_slab(); + 3) | _cond_resched() { + 3) 0.037 us | rcu_all_qs(); + 3) 0.455 us | } + 3) 0.040 us | should_failslab(); + 3) 0.037 us | memcg_kmem_put_cache(); + 3) 2.227 us | } + 3) 2.624 us | } /* kvmalloc_node */ + 3) | kvfree() { + 3) 0.048 us | kfree(); + 3) 0.662 us | } + 3) | btf_int_check_meta() { + 3) 0.043 us | __btf_verifier_log_type(); + 3) 0.457 us | } + 3) | btf_array_check_meta() { + 3) 0.041 us | __btf_verifier_log_type(); + 3) 0.393 us | } + 3) | btf_int_check_meta() { + 3) 0.094 us | __btf_verifier_log_type(); + 3) 0.447 us | } + 3) | btf_int_check_meta() { + 3) 0.043 us | __btf_verifier_log_type(); + 3) 0.573 us | } + 3) | btf_int_check_meta() { + 3) 0.085 us | __btf_verifier_log_type(); + 3) 0.446 us | } + 3) | btf_ref_type_check_meta() { + 3) 0.042 us | __btf_verifier_log_type(); + 3) 0.451 us | } + 3) | btf_ref_type_check_meta() { + 3) 0.042 us | __btf_verifier_log_type(); + 3) 0.427 us | } + 3) | btf_ref_type_check_meta() { + 3) 0.042 us | __btf_verifier_log_type(); + 3) 0.397 us | } + 3) | btf_ref_type_check_meta() { + 3) 0.041 us | __btf_verifier_log_type(); + 3) 0.399 us | } + 3) | btf_int_check_meta() { + 3) 0.043 us | __btf_verifier_log_type(); + 3) 0.602 us | } + 3) | btf_ref_type_check_meta() { + 3) 0.040 us | __btf_verifier_log_type(); + 3) 0.733 us | } + 3) | btf_array_check_meta() { + 3) 0.094 us | __btf_verifier_log_type(); + 3) 0.452 us | } + 3) | kvmalloc_node() { + 3) | __kmalloc_node() { + 3) 0.039 us | kmalloc_slab(); + 3) | _cond_resched() { + 3) 0.041 us | rcu_all_qs(); + 3) 0.579 us | } + 3) 0.039 us | should_failslab(); + 3) 0.042 us | memcg_kmem_put_cache(); + 3) 2.538 us | } + 3) 2.886 us | } + 3) | kvmalloc_node() { + 3) | __kmalloc_node() { + 3) 0.041 us | kmalloc_slab(); + 3) | _cond_resched() { + 3) 0.038 us | rcu_all_qs(); + 3) 0.708 us | } + 3) 0.038 us | should_failslab(); + 3) 0.040 us | memcg_kmem_put_cache(); + 3) 2.483 us | } + 3) 2.829 us | } + 3) | kvmalloc_node() { + 3) | __kmalloc_node() { + 3) 0.057 us | kmalloc_slab(); + 3) | _cond_resched() { + 3) 0.040 us | rcu_all_qs(); + 3) 0.533 us | } + 3) 0.039 us | should_failslab(); + 3) 0.038 us | memcg_kmem_put_cache(); + 3) 2.680 us | } + 3) 3.171 us | } + 3) 0.054 us | env_stack_push(); + 3) | btf_struct_resolve() { + 3) 0.051 us | env_type_is_resolve_sink.isra.19(); + 3) 0.039 us | btf_int_check_member(); + 3) 0.039 us | env_type_is_resolve_sink.isra.19(); + 3) 0.039 us | btf_int_check_member(); + 3) 0.040 us | env_type_is_resolve_sink.isra.19(); + 3) 0.040 us | btf_int_check_member(); + 3) 0.039 us | env_type_is_resolve_sink.isra.19(); + 3) 0.099 us | btf_int_check_member(); + 3) 0.040 us | env_type_is_resolve_sink.isra.19(); + 3) 0.042 us | btf_int_check_member(); + 3) 0.040 us | env_type_is_resolve_sink.isra.19(); + 3) 0.038 us | btf_int_check_member(); + 3) 0.038 us | env_type_is_resolve_sink.isra.19(); + 3) 0.039 us | btf_int_check_member(); + 3) 6.545 us | } + 3) 0.053 us | env_stack_push(); + 3) | btf_array_resolve() { + 3) 0.039 us | env_type_is_resolve_sink.isra.19(); + 3) 0.090 us | btf_type_id_size(); + 3) 0.060 us | btf_type_int_is_regular(); + 3) 0.058 us | env_type_is_resolve_sink.isra.19(); + 3) 0.051 us | btf_type_id_size(); + 3) 0.055 us | btf_type_int_is_regular(); + 3) 3.414 us | } + 3) 0.041 us | btf_type_id_size(); + 3) 0.057 us | env_stack_push(); + 3) | btf_ptr_resolve() { + 3) 0.056 us | env_type_is_resolve_sink.isra.19(); + 3) 0.054 us | env_stack_push(); + 3) 1.056 us | } + 3) 0.063 us | btf_ptr_resolve(); + 3) | btf_ptr_resolve() { + 3) 0.049 us | env_type_is_resolve_sink.isra.19(); + 3) 0.086 us | btf_type_id_size(); + 3) 1.052 us | } + 3) 0.045 us | env_stack_push(); + 3) 0.060 us | btf_ptr_resolve(); + 3) 0.045 us | env_stack_push(); + 3) | btf_ptr_resolve() { + 3) 0.039 us | env_type_is_resolve_sink.isra.19(); + 3) 0.062 us | btf_type_id_size(); + 3) 1.325 us | } + 3) 0.054 us | env_stack_push(); + 3) | btf_modifier_resolve() { + 3) 0.061 us | env_type_is_resolve_sink.isra.19(); + 3) 0.043 us | btf_type_id_size(); + 3) 0.877 us | } + 3) 0.052 us | env_stack_push(); + 3) | btf_array_resolve() { + 3) 0.060 us | env_type_is_resolve_sink.isra.19(); + 3) 0.051 us | btf_type_id_size(); + 3) 0.042 us | btf_type_int_is_regular(); + 3) 0.040 us | env_type_is_resolve_sink.isra.19(); + 3) 0.042 us | btf_type_id_size(); + 3) 0.041 us | btf_type_int_is_regular(); + 3) 2.822 us | } + 3) 0.048 us | btf_type_id_size(); + 3) | kvfree() { + 3) 0.148 us | kfree(); + 3) 0.685 us | } + 3) 0.287 us | kfree(); + 3) 0.042 us | _raw_spin_lock_bh(); + 3) | kmem_cache_alloc() { + 3) 0.040 us | should_failslab(); + 3) 0.111 us | prefetch_freepointer(); + 3) 0.094 us | memcg_kmem_put_cache(); + 3) 2.139 us | } + 3) | _raw_spin_unlock_bh() { + 3) 0.079 us | __local_bh_enable_ip(); + 3) 0.460 us | } + 3) | anon_inode_getfd() { + 3) | get_unused_fd_flags() { + 3) | __alloc_fd() { + 3) 0.040 us | _raw_spin_lock(); + 3) 0.041 us | expand_files(); + 3) 1.374 us | } + 3) 1.759 us | } + 3) | anon_inode_getfile() { + 3) | d_alloc_pseudo() { + 3) | __d_alloc() { + 3) | kmem_cache_alloc() { + 3) | _cond_resched() { + 3) 0.035 us | rcu_all_qs(); + 3) 0.507 us | } + 3) 0.040 us | should_failslab(); + 3) | memcg_kmem_get_cache() { + 3) 0.091 us | get_mem_cgroup_from_mm(); + 3) 0.633 us | } + 3) 0.111 us | prefetch_freepointer(); + 3) 0.082 us | memcg_kmem_put_cache(); + 3) 4.178 us | } + 3) 0.162 us | d_set_d_op(); + 3) 5.545 us | } + 3) 6.270 us | } + 3) 0.112 us | mntget(); + 3) 0.125 us | ihold(); + 3) | d_instantiate() { + 3) 0.120 us | security_d_instantiate(); + 3) 0.106 us | _raw_spin_lock(); + 3) | __d_instantiate() { + 3) 0.069 us | d_flags_for_inode(); + 3) 0.090 us | _raw_spin_lock(); + 3) 1.483 us | } + 3) 2.767 us | } + 3) | alloc_file() { + 3) | get_empty_filp() { + 3) | kmem_cache_alloc() { + 3) | _cond_resched() { + 3) 0.039 us | rcu_all_qs(); + 3)root:x:0:0:root:/root:/bin/bash + bin:x:1:1:bin:/bin:/sbin/nologin + daemon:x:2:2:daemon:/sbin:/sbin/nologin + adm:x:3:4:adm:/var/adm:/sbin/nologin + + 0.382 us | } + 3) 0.040 us | should_failslab(); + 3) | memcg_kmem_get_cache() { + 3) 0.039 us | get_mem_cgroup_from_mm(); + 3) 0.626 us | } + 3) 0.050 us | prefetch_freepointer(); + 3) 0.059 us | memcg_kmem_put_cache(); + 3) 3.280 us | } + 3) | security_file_alloc() { + 3) | selinux_file_alloc_security() { + 3) | kmem_cache_alloc() { + 3) | _cond_resched() { + 3) 0.038 us | rcu_all_qs(); + 3) 0.422 us | } + 3) 0.040 us | should_failslab(); + 3) 0.051 us | prefetch_freepointer(); + 3) 0.054 us | memcg_kmem_put_cache(); + 3) 2.660 us | } + 3) 3.062 us | } + 3) 3.548 us | } + 3) 0.039 us | __mutex_init(); + 3) 8.091 us | } + 3) 8.617 us | } + 3) + 20.810 us | } + 3) | fd_install() { + 3) 0.054 us | __fd_install(); + 3) 0.723 us | } + 3) + 24.438 us | } + 3) ! 109.639 us | } + 3) ! 112.925 us | } + 3) | btf_release() { + 3) | btf_put() { + 3) 0.145 us | _raw_spin_lock_irqsave(); + 3) | call_rcu_sched() { + 3) | __call_rcu() { + 3) 0.082 us | rcu_segcblist_enqueue(); + 3) 1.323 us | } + 3) 1.782 us | } + 3) 0.069 us | _raw_spin_unlock_irqrestore(); + 3) | call_rcu_sched() { + 3) | __call_rcu() { + 3) 0.069 us | rcu_segcblist_enqueue(); + 3) 0.541 us | } + 3) 0.984 us | } + 3) 5.210 us | } + 3) 5.954 us | } + +This should be enough for us to validate pahole's BTF encoder, and now one can +use 'pahole -F btf' to obtain mostly the same results as with the default use +of '-F dwarf', modulo things like explicit alignments that are not present in +BTF and need some work to be inferred from existing non-natural alignment holes. + +- Arnaldo diff -Nru dwarves-dfsg-1.10/README.DEBUG dwarves-dfsg-1.21/README.DEBUG --- dwarves-dfsg-1.10/README.DEBUG 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/README.DEBUG 2019-04-02 18:39:50.000000000 +0000 @@ -0,0 +1,6 @@ +rm -rf build +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Debug .. +cd .. +make -C build diff -Nru dwarves-dfsg-1.10/README.tarball dwarves-dfsg-1.21/README.tarball --- dwarves-dfsg-1.10/README.tarball 1970-01-01 00:00:00.000000000 +0000 +++ dwarves-dfsg-1.21/README.tarball 2020-03-12 19:55:08.000000000 +0000 @@ -0,0 +1 @@ +tar cvfJ ~/rpmbuild/SOURCES/dwarves-1.17.tar.xz --transform 's,^,dwarves-1.17/,' `cat MANIFEST` diff -Nru dwarves-dfsg-1.10/rpm/SPECS/dwarves.spec dwarves-dfsg-1.21/rpm/SPECS/dwarves.spec --- dwarves-dfsg-1.10/rpm/SPECS/dwarves.spec 2012-05-30 18:34:50.000000000 +0000 +++ dwarves-dfsg-1.21/rpm/SPECS/dwarves.spec 2021-04-09 19:10:33.000000000 +0000 @@ -2,16 +2,17 @@ %define libver 1 Name: dwarves -Version: 1.10 +Version: 1.21 Release: 1%{?dist} License: GPLv2 -Summary: Debugging Information Manipulation Tools -Group: Development/Tools +Summary: Debugging Information Manipulation Tools (pahole & friends) URL: http://acmel.wordpress.com -Source: http://fedorapeople.org/~acme/dwarves/%{name}-%{version}.tar.bz2 -BuildRequires: cmake +Source: http://fedorapeople.org/~acme/dwarves/%{name}-%{version}.tar.xz +Requires: %{libname}%{libver} = %{version}-%{release} +BuildRequires: gcc +BuildRequires: cmake >= 2.8.12 +BuildRequires: zlib-devel BuildRequires: elfutils-devel >= 0.130 -BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) %description dwarves is a set of tools that use the debugging information inserted in @@ -25,53 +26,66 @@ It also extracts other information such as CPU cacheline alignment, helping pack those structures to achieve more cache hits. +These tools can also be used to encode and read the BTF type information format +used with the Linux kernel bpf syscall, using 'pahole -J' and 'pahole -F btf'. + A diff like tool, codiff can be used to compare the effects changes in source code generate on the resulting binaries. Another tool is pfunct, that can be used to find all sorts of information about functions, inlines, decisions made by the compiler about inlining, etc. +One example of pfunct usage is in the fullcircle tool, a shell that drivers +pfunct to generate compileable code out of a .o file and then build it using +gcc, with the same compiler flags, and then use codiff to make sure the +original .o file and the new one generated from debug info produces the same +debug info. + +Pahole also can be used to use all this type information to pretty print raw data +according to command line directions. + +Headers can have its data format described from debugging info and offsets from +it can be used to further format a number of records. + +The btfdiff utility compares the output of pahole from BTF and DWARF to make +sure they produce the same results. + %package -n %{libname}%{libver} Summary: Debugging information processing library -Group: Development/Libraries %description -n %{libname}%{libver} Debugging information processing library. %package -n %{libname}%{libver}-devel Summary: Debugging information library development files -Group: Development/Libraries Requires: %{libname}%{libver} = %{version}-%{release} %description -n %{libname}%{libver}-devel Debugging information processing library development files. %prep -%setup -q -c -n %{name}-%{version} +%setup -q %build -%cmake . -make VERBOSE=1 %{?_smp_mflags} +%cmake -DCMAKE_BUILD_TYPE=Release . +%cmake_build %install rm -Rf %{buildroot} -make install DESTDIR=%{buildroot} - -%post -n %{libname}%{libver} -p /sbin/ldconfig - -%postun -n %{libname}%{libver} -p /sbin/ldconfig +%cmake_install -%clean -rm -rf %{buildroot} +%ldconfig_scriptlets -n %{libname}%{libver} %files -%defattr(0644,root,root,0755) %doc README.ctracer +%doc README.btf +%doc changes-v1.21 %doc NEWS -%defattr(0755,root,root,0755) +%{_bindir}/btfdiff %{_bindir}/codiff %{_bindir}/ctracer %{_bindir}/dtagnames +%{_bindir}/fullcircle %{_bindir}/pahole %{_bindir}/pdwtags %{_bindir}/pfunct @@ -92,33 +106,218 @@ %attr(0755,root,root) %{_datadir}/dwarves/runtime/python/ostra.py* %files -n %{libname}%{libver} -%defattr(0644,root,root,0755) %{_libdir}/%{libname}.so.* %{_libdir}/%{libname}_emit.so.* %{_libdir}/%{libname}_reorganize.so.* %files -n %{libname}%{libver}-devel -%defattr(0644,root,root,0755) %doc MANIFEST README +%{_includedir}/dwarves/btf_encoder.h +%{_includedir}/dwarves/config.h +%{_includedir}/dwarves/ctf_encoder.h +%{_includedir}/dwarves/ctf.h +%{_includedir}/dwarves/dutil.h %{_includedir}/dwarves/dwarves.h %{_includedir}/dwarves/dwarves_emit.h %{_includedir}/dwarves/dwarves_reorganize.h -%{_includedir}/dwarves/dutil.h +%{_includedir}/dwarves/elfcreator.h +%{_includedir}/dwarves/elf_symtab.h %{_includedir}/dwarves/gobuffer.h +%{_includedir}/dwarves/hash.h +%{_includedir}/dwarves/libbtf.h +%{_includedir}/dwarves/libctf.h %{_includedir}/dwarves/list.h %{_includedir}/dwarves/rbtree.h -%{_includedir}/dwarves/strings.h +%{_includedir}/dwarves/pahole_strings.h %{_libdir}/%{libname}.so %{_libdir}/%{libname}_emit.so %{_libdir}/%{libname}_reorganize.so %changelog +* Fri Apr 9 2021 Arnaldo Carvalho de Melo - 1.21-1 +- New release: v1.21 +- DWARF loader: +- Handle DWARF5 DW_OP_addrx properly +- Handle subprogram ret type with abstract_origin properly +- Check .notes section for LTO build info +- Check .debug_abbrev for cross-CU references +- Permit merging all DWARF CU's for clang LTO built binary +- Factor out common code to initialize a cu +- Permit a flexible HASHTAGS__BITS +- Use a better hashing function, from libbpf +- btf_encoder: +- Add --btf_gen_all flag +- Match ftrace addresses within ELF functions +- Funnel ELF error reporting through a macro +- Sanitize non-regular int base type +- Add support for the floating-point types +- Pretty printer: +- Honour conf_fprintf.hex when printing enumerations + +* Tue Feb 2 2021 Arnaldo Carvalho de Melo - 1.20-1 +- New release: v1.20 +- btf_encoder: +- Improve ELF error reporting using elf_errmsg(elf_errno()) +- Improve objcopy error handling. +- Fix handling of 'restrict' qualifier, that was being treated as a 'const'. +- Support SHN_XINDEX in st_shndx symbol indexes +- Cope with functions without a name +- Fix BTF variable generation for kernel modules +- Fix address size to match what is in the ELF file being processed. +- Use kernel module ftrace addresses when finding which functions to encode. +- libbpf: +- Allow use of packaged version. +- dwarf_loader: +- Support DW_AT_data_bit_offset +- DW_FORM_implicit_const in attr_numeric() and attr_offset() +- Support DW_TAG_GNU_call_site, standardized rename of DW_TAG_GNU_call_site. +- build: +- Fix compilation on 32-bit architectures. + +* Fri Nov 20 2020 Arnaldo Carvalho de Melo - 1.19-1 +- New release: 1.19 +- Split BTF +- DWARF workarounds for DW_AT_declaration +- Support cross-compiled ELF binaries with different endianness +- Support showing typedefs for anonymous types +- Speedups using libbpf algorithms +- See changes-v1.19 for a complete and more detailed list of changes + +* Fri Oct 02 2020 Arnaldo Carvalho de Melo - 1.18-1 +- New release: 1.18 +- Use debugging info to pretty print raw data +- Store percpu variables in vmlinux BTF. +- Fixes to address segfaults on the gdb testsuite binaries +- Bail out on partial units for now, avoiding segfaults and providing warning to user. + +* Mon Aug 31 2020 - Zamir SUN - 1.17-4 +- Fix FTBFS +- Resolves: bug 1863459 + +* Sat Aug 01 2020 Fedora Release Engineering - 1.17-3 +- Second attempt - Rebuilt for + https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Mon Jul 27 2020 Fedora Release Engineering - 1.17-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Fri Mar 13 2020 Arnaldo Carvalho de Melo - 1.17-1 +- New release: 1.17 +- Support raw BTF as available in /sys/kernel/btf/vmlinux. +- When the sole argument passed isn't a file, take it as a class name: +- Do not require a class name to operate without a file name. +- Make --find_pointers_to consider unions: +- Make --contains and --find_pointers_to honour --unions +- Add support for finding pointers to void: +- Make --contains and --find_pointers_to to work with base types: +- Make --contains look for more than just unions, structs: +- Consider unions when looking for classes containing some class: +- Introduce --unions to consider just unions: +- Fix -m/--nr_methods - Number of functions operating on a type pointer + +* Wed Feb 12 2020 Arnaldo Carvalho de Melo - 1.16-1 +- New release: 1.16 +- BTF encoder: Preserve and encode exported functions as BTF_KIND_FUNC. +- BTF loader: Add support for BTF_KIND_FUNC +- Pretty printer: Account inline type __aligned__ member types for spacing +- Pretty printer: Fix alignment of class members that are structs/enums/unions +- Pretty printer: Avoid infinite loop trying to determine type with static data member of its own type. +- RPM spec file: Add dwarves dependency on libdwarves1. +- pfunct: type->type == 0 is void, fix --compile for that +- pdwtags: Print DW_TAG_subroutine_type as well +- core: Fix ptr_table__add_with_id() handling of pt->nr_entries +- pglobal: Allow passing the format path specifier, to use with BTF +- Tree wide: Fixup issues pointed out by various coverity reports. + +* Tue Jan 28 2020 Fedora Release Engineering - 1.15-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Wed Jul 24 2019 Fedora Release Engineering - 1.15-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Mon Jul 1 2019 Arnaldo Carvalho de Melo - 1.15-2 +- Fix bug when processing classes without members + +* Thu Jun 27 2019 Arnaldo Carvalho de Melo - 1.15-1 +- New release: 1.15 +- Fix --expand_types/-E segfault +- Fixup endless printing named structs inside structs in --expand_types +- Avoid NULL deref with num config in __class__fprintf() + +* Tue Apr 23 2019 Arnaldo Carvalho de Melo - 1.13-1 +- New release: 1.13 +- Infer __packed__ attributes, i.e. __attribute__((__packed__)) +- Support DW_AT_alignment, i.e. __attribute__((__aligned__(N))) +- Decode BTF type format and pretty print it +- BTF encoding fixes +- Use libbpf's BTF deduplication +- Support unions as arguments to -C/--class +- New 'pfunct --compile' generates compilable output with type definitions + +* Thu Jan 31 2019 Fedora Release Engineering - 1.12-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Aug 31 2018 Arnaldo Carvalho de Melo - 1.12-1 +- New release: 1.12 +- union member cacheline boundaries for all inner structs +- print union member offsets +- Document 'pahole --hex' +- Encode BTF type format for use with eBPF + +* Thu Jul 12 2018 Fedora Release Engineering - 1.10-15 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Wed Feb 07 2018 Fedora Release Engineering - 1.10-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Wed Aug 02 2017 Fedora Release Engineering - 1.10-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 1.10-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Fri Feb 10 2017 Fedora Release Engineering - 1.10-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Wed Aug 03 2016 Cole Robinson - 1.10-9%{?dist} +- pdwtags: don't fail on unhandled tags (bz 1348200) + +* Wed Feb 03 2016 Fedora Release Engineering - 1.10-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Jun 17 2015 Fedora Release Engineering - 1.10-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Fri Sep 05 2014 Marcin Juszkiewicz - 1.10-7 +- backport removal of DW_TAG_mutable_type + +* Sat Aug 16 2014 Fedora Release Engineering - 1.10-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Sat Jun 07 2014 Fedora Release Engineering - 1.10-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sat Aug 03 2013 Fedora Release Engineering - 1.10-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Wed Feb 13 2013 Fedora Release Engineering - 1.10-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Wed Jul 18 2012 Fedora Release Engineering - 1.10-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + * Wed May 30 2012 Arnaldo Carvalho de Melo - 1.10-1 - New release +* Fri Jan 13 2012 Fedora Release Engineering - 1.9-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + * Sat Nov 20 2010 Arnaldo Carvalho de Melo - 1.9-1 - New release +* Mon Feb 08 2010 Fedora Release Engineering - 1.8-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + * Fri Dec 4 2009 Arnaldo Carvalho de Melo - 1.8-1 - New release @@ -267,7 +466,7 @@ - Fix emission of arrays of structs, unions, etc - use sysconf for the default cacheline size -* Wed Jan 18 2007 Arnaldo Carvalho de Melo +* Thu Jan 18 2007 Arnaldo Carvalho de Melo - fab0db03ea9046893ca110bb2b7d71b764f61033 - pdwtags added diff -Nru dwarves-dfsg-1.10/scncopy.c dwarves-dfsg-1.21/scncopy.c --- dwarves-dfsg-1.10/scncopy.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/scncopy.c 2019-05-01 15:06:45.000000000 +0000 @@ -1,9 +1,7 @@ /* - * Copyright 2009 Red Hat, Inc. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. + * Copyright 2009 Red Hat, Inc. * * Author: Peter Jones */ diff -Nru dwarves-dfsg-1.10/strings.c dwarves-dfsg-1.21/strings.c --- dwarves-dfsg-1.10/strings.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/strings.c 2021-03-07 13:51:27.000000000 +0000 @@ -1,12 +1,10 @@ /* - Copyright (C) 2008 Arnaldo Carvalho de Melo + SPDX-License-Identifier: GPL-2.0-only - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. + Copyright (C) 2008 Arnaldo Carvalho de Melo */ -#include "strings.h" +#include "pahole_strings.h" #include "gobuffer.h" #include @@ -17,97 +15,74 @@ #include #include "dutil.h" +#include "lib/bpf/src/libbpf.h" struct strings *strings__new(void) { - struct strings *self = malloc(sizeof(*self)); + struct strings *strs = malloc(sizeof(*strs)); - if (self != NULL) { - self->tree = NULL; - gobuffer__init(&self->gb); - } + if (!strs) + return NULL; - return self; + strs->btf = btf__new_empty(); + if (libbpf_get_error(strs->btf)) { + free(strs); + return NULL; + } + return strs; } -static void do_nothing(void *ptr __unused) +void strings__delete(struct strings *strs) { -} - -void strings__delete(struct strings *self) -{ - if (self == NULL) + if (strs == NULL) return; - tdestroy(self->tree, do_nothing); - __gobuffer__delete(&self->gb); - free(self); -} - -static strings_t strings__insert(struct strings *self, const char *s) -{ - return gobuffer__add(&self->gb, s, strlen(s) + 1); -} - -struct search_key { - struct strings *self; - const char *str; -}; - -static int strings__compare(const void *a, const void *b) -{ - const struct search_key *key = a; - - return strcmp(key->str, key->self->gb.entries + (unsigned long)b); + btf__free(strs->btf); + free(strs); } -strings_t strings__add(struct strings *self, const char *str) +strings_t strings__add(struct strings *strs, const char *str) { - unsigned long *s; strings_t index; - struct search_key key = { - .self = self, - .str = str, - }; if (str == NULL) return 0; - s = tsearch(&key, &self->tree, strings__compare); - if (s != NULL) { - if (*(struct search_key **)s == (void *)&key) { /* Not found, replace with the right key */ - index = strings__insert(self, str); - if (index != 0) - *s = (unsigned long)index; - else { - tdelete(&key, &self->tree, strings__compare); - return 0; - } - } else /* Found! */ - index = *s; - } else + index = btf__add_str(strs->btf, str); + if (index < 0) return 0; return index; } -strings_t strings__find(struct strings *self, const char *str) +strings_t strings__find(struct strings *strs, const char *str) { - strings_t *s; - struct search_key key = { - .self = self, - .str = str, - }; + return btf__find_str(strs->btf, str); +} - if (str == NULL) - return 0; +/* a horrible and inefficient hack to get string section size out of BTF */ +strings_t strings__size(const struct strings *strs) +{ + const struct btf_header *p; + uint32_t sz; + + p = btf__get_raw_data(strs->btf, &sz); + if (!p) + return -1; - s = tfind(&key, &self->tree, strings__compare); - return s ? *s : 0; + return p->str_len; } -int strings__cmp(const struct strings *self, strings_t a, strings_t b) +/* similarly horrible hack to copy out string section out of BTF */ +int strings__copy(const struct strings *strs, void *dst) { - return a == b ? 0 : strcmp(strings__ptr(self, a), - strings__ptr(self, b)); + const struct btf_header *p; + uint32_t sz; + + p = btf__get_raw_data(strs->btf, &sz); + if (!p) + return -1; + + memcpy(dst, (void *)p + p->str_off, p->str_len); + return 0; } diff -Nru dwarves-dfsg-1.10/strings.h dwarves-dfsg-1.21/strings.h --- dwarves-dfsg-1.10/strings.h 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/strings.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -#ifndef _STRINGS_H_ -#define _STRINGS_H_ 1 -/* - Copyright (C) 2008 Arnaldo Carvalho de Melo - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. -*/ - -#include "gobuffer.h" - -typedef unsigned int strings_t; - -struct strings { - void *tree; - struct gobuffer gb; -}; - -struct strings *strings__new(void); - -void strings__delete(struct strings *self); - -strings_t strings__add(struct strings *self, const char *str); -strings_t strings__find(struct strings *self, const char *str); - -int strings__cmp(const struct strings *self, strings_t a, strings_t b); - -static inline const char *strings__ptr(const struct strings *self, strings_t s) -{ - return gobuffer__ptr(&self->gb, s); -} - -static inline const char *strings__entries(const struct strings *self) -{ - return gobuffer__entries(&self->gb); -} - -static inline unsigned int strings__nr_entries(const struct strings *self) -{ - return gobuffer__nr_entries(&self->gb); -} - -static inline strings_t strings__size(const struct strings *self) -{ - return gobuffer__size(&self->gb); -} - -static inline const char *strings__compress(struct strings *self, - unsigned int *size) -{ - return gobuffer__compress(&self->gb, size); -} - -#endif /* _STRINGS_H_ */ diff -Nru dwarves-dfsg-1.10/syscse.c dwarves-dfsg-1.21/syscse.c --- dwarves-dfsg-1.10/syscse.c 2012-03-20 16:17:25.000000000 +0000 +++ dwarves-dfsg-1.21/syscse.c 2020-01-09 17:14:10.000000000 +0000 @@ -1,11 +1,9 @@ /* - Copyright (C) 2007 Arnaldo Carvalho de Melo + SPDX-License-Identifier: GPL-2.0-only - System call sign extender + Copyright (C) 2007-2016 Arnaldo Carvalho de Melo - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. + System call sign extender */ #include @@ -63,8 +61,8 @@ const char *name = function__name(f, cu); int regparm = 0, needs_wrapper = 0; - function__for_each_parameter(f, parm) { - const uint16_t type_id = parm->tag.type; + function__for_each_parameter(f, cu, parm) { + const type_id_t type_id = parm->tag.type; struct tag *type = cu__type(cu, type_id); tag__assert_search_result(type); @@ -90,20 +88,20 @@ printf("\tj\t%s\n\n", name); } -static int cu__emit_wrapper(struct cu *self, void *cookie __unused) +static int cu__emit_wrapper(struct cu *cu, void *cookie __unused) { struct function *pos; uint32_t id; - cu__for_each_function(self, id, pos) - if (!filter(pos, self)) - emit_wrapper(pos, self); + cu__for_each_function(cu, id, pos) + if (!filter(pos, cu)) + emit_wrapper(pos, cu); return 0; } -static void cus__emit_wrapper(struct cus *self) +static void cus__emit_wrapper(struct cus *cu) { - cus__for_each_cu(self, cu__emit_wrapper, NULL, NULL); + cus__for_each_cu(cu, cu__emit_wrapper, NULL, NULL); } /* Name and version of program. */ @@ -162,8 +160,10 @@ return EXIT_FAILURE; } err = cus__load_files(cus, NULL, argv + remaining); - if (err != 0) + if (err != 0) { + cus__fprintf_load_files_err(cus, "syscse", argv + remaining, err, stderr); return EXIT_FAILURE; + } cus__emit_wrapper(cus); return EXIT_SUCCESS;