• Yonghong Song's avatar
    tools/bpf: implement libbpf btf__get_map_kv_tids() API function · 96408c43
    Yonghong Song authored
    Currently, to get map key/value type id's, the macro
      BPF_ANNOTATE_KV_PAIR(<map_name>, <key_type>, <value_type>)
    needs to be defined in the bpf program for the
    corresponding map.
    
    During program/map loading time,
    the local static function bpf_map_find_btf_info()
    in libbpf.c is implemented to retrieve the key/value
    type ids given the map name.
    
    The patch refactored function bpf_map_find_btf_info()
    to create an API btf__get_map_kv_tids() which includes
    the bulk of implementation for the original function.
    The API btf__get_map_kv_tids() can be used by bcc,
    a JIT based bpf compilation system, which uses the
    same BPF_ANNOTATE_KV_PAIR to record map key/value types.
    Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
    Signed-off-by: default avatarYonghong Song <yhs@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    96408c43
btf.c 18.8 KB