From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEEEDC10F0E for ; Tue, 9 Apr 2019 17:27:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AEB2B20857 for ; Tue, 9 Apr 2019 17:27:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IGg1GUgM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726812AbfDIR1q (ORCPT ); Tue, 9 Apr 2019 13:27:46 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:55407 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726694AbfDIR1p (ORCPT ); Tue, 9 Apr 2019 13:27:45 -0400 Received: by mail-pg1-f202.google.com with SMTP id 14so13067166pgf.22 for ; Tue, 09 Apr 2019 10:27:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=TPX6cTYh61RNjrelF8pt2tCkW6NVS4y5gHCKwdw0Nmw=; b=IGg1GUgMMSodCHRwQqKLG2MneJ5zjtfIC/bgrXbXc1qKkcftCYsNpKVS2eVbs0ozJz QsoHChVuRyA1mIU9D0pedAs3JftXdx9mbNwbvBENL0iL2ZljaRKa4sQwxnmTfpKcpfKl v2wZ9HI4ICOkONjcoD3EZ60pGIi+n9D5Z3mrwRLVhDxBK32FbbPMkhB0T924NsAXDdGL GyO1pQ1ouwi8u1AH+pnxZtOsJmqMwXTXjGh9I/wmCQ6vVuwIADuYmS0EPcpdblw6iOJh esrYCgycU8bWxQdcGJbp3hJez9N8IDyccg2Jzst2MIcDmyUsClzSB45w/BKq5/Xns4WU Q3Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=TPX6cTYh61RNjrelF8pt2tCkW6NVS4y5gHCKwdw0Nmw=; b=hgpGGxqOY08131Ys8LfRzH5kBJeHOg3Qg3DReFangk8vjvLVZJJ7c0En8LsWgKIP54 cNChsq1WWBm02HNnEKCu7jAEE8ZuO3jR3zRVYPJGT6merX6pWCXUTUQtV0bbPO997jBX imGp6sKahFEWZIsuk5udsPghUEf+mKuHZuDA0hcuLtv0bTPe3V/5vqNZ9sIcZpHJ7XgE jRcKf8Clw6B8hnoOhQm67UnPAXLmg1/jVfOVbJScvcB2K2n3TeHCArhRUbVfMUwNXzYh ahaz/DwyFqjZt2x2dKNS8lC4oMqVbJ7bgv9J5HMXSQTLPKyBLumVumO/h/dAYaCmM8NO SYSw== X-Gm-Message-State: APjAAAW77Es1Zn6RkyMXJYlfLeEFdPXrJRRk1/aZ0YEDVW6rNe1uW6vu qKz8AveLo/7NRvgMcuDaLweFweIIKlyH+6HtcYlaItBYockICkdVzcybT5o85tT5Iml8WmjoOxM ik5LtGLbWjIQJrK5+3u5AE2JbxtXUWJiTNxCrWs0BUJAZF7O9PzXDHg== X-Google-Smtp-Source: APXvYqwThwQ3T5W4utchgxzLL7cXC/7GRSkSRrHuGOGYEuhN3grWGshTmvep22riZyJUwaEJY4H1KyQ= X-Received: by 2002:a63:42c5:: with SMTP id p188mr805360pga.47.1554830863696; Tue, 09 Apr 2019 10:27:43 -0700 (PDT) Date: Tue, 9 Apr 2019 10:27:38 -0700 In-Reply-To: <20190409172739.242389-1-sdf@google.com> Message-Id: <20190409172739.242389-2-sdf@google.com> Mime-Version: 1.0 References: <20190409172739.242389-1-sdf@google.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH bpf-next v3 2/3] libbpf: add support for ctx_{size,}_{in,out} in BPF_PROG_TEST_RUN From: Stanislav Fomichev To: netdev@vger.kernel.org, bpf@vger.kernel.org Cc: davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, Stanislav Fomichev , Martin Lau Content-Type: text/plain; charset="UTF-8" Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Support recently introduced input/output context for test runs. We extend only bpf_prog_test_run_xattr. bpf_prog_test_run is unextendable and left as is. Cc: Martin Lau Signed-off-by: Stanislav Fomichev --- tools/include/uapi/linux/bpf.h | 7 +++++++ tools/lib/bpf/bpf.c | 5 +++++ tools/lib/bpf/bpf.h | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 837024512baf..8e96f99cebf8 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -396,6 +396,13 @@ union bpf_attr { __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; } test; struct { /* anonymous struct used by BPF_*_GET_*_ID */ diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index a1db869a6fda..d740da7ae1d3 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -545,10 +545,15 @@ int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr) 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; diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index e2c0df7b831f..385418a6d54b 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h @@ -135,6 +135,11 @@ struct bpf_prog_test_run_attr { * 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); -- 2.21.0.392.gf8f6787159e-goog