From patchwork Wed Sep 23 21:33:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 1370097 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=fb.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=fb.com header.i=@fb.com header.a=rsa-sha256 header.s=facebook header.b=eHEDOkHY; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BxWdg5sdwz9sSC for ; Thu, 24 Sep 2020 07:33:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726689AbgIWVd7 (ORCPT ); Wed, 23 Sep 2020 17:33:59 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:64282 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726672AbgIWVd6 (ORCPT ); Wed, 23 Sep 2020 17:33:58 -0400 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08NLTDNw020678 for ; Wed, 23 Sep 2020 14:33:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=3Id3ojc2RukiHWW/9XJExViZYh9/vs8p8nDO/Zpu/5w=; b=eHEDOkHYHhP9zxip4rwrMb4/gcMfpWWoPT76C+kIo+k7Ri0sBnJR6Ok0UgNRQxABdxeg jCKiZ+L7W6SDnMLnrCS4UtefE4kZvly1BNcLialGMFVqN9tJpxmxrwi87uxvtrUR98KM x5mtRNOrKSDs3D8pmWTED80yC2YHbYBNUEI= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com with ESMTP id 33qsp4x3rp-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 23 Sep 2020 14:33:57 -0700 Received: from intmgw003.03.ash8.facebook.com (2620:10d:c085:108::8) by mail.thefacebook.com (2620:10d:c085:11d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 23 Sep 2020 14:33:56 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 3C78862E5235; Wed, 23 Sep 2020 14:33:54 -0700 (PDT) From: Song Liu To: , CC: , , , , , Song Liu Subject: [PATCH v3 bpf-next 2/3] libbpf: introduce bpf_prog_test_run_xattr_opts Date: Wed, 23 Sep 2020 14:33:36 -0700 Message-ID: <20200923213337.3432472-3-songliubraving@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200923213337.3432472-1-songliubraving@fb.com> References: <20200923213337.3432472-1-songliubraving@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-23_16:2020-09-23,2020-09-23 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=846 suspectscore=0 bulkscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009230162 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This API supports new field cpu_plus in bpf_attr.test. Acked-by: John Fastabend Signed-off-by: Song Liu --- tools/lib/bpf/bpf.c | 13 ++++++++++++- tools/lib/bpf/bpf.h | 11 +++++++++++ tools/lib/bpf/libbpf.map | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 2baa1308737c8..3228dd60fa32f 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -684,7 +684,8 @@ int bpf_prog_test_run(int prog_fd, int repeat, void *data, __u32 size, return ret; } -int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr) +int bpf_prog_test_run_xattr_opts(struct bpf_prog_test_run_attr *test_attr, + const struct bpf_prog_test_run_opts *opts) { union bpf_attr attr; int ret; @@ -693,6 +694,11 @@ int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr) return -EINVAL; memset(&attr, 0, sizeof(attr)); + if (opts) { + if (!OPTS_VALID(opts, bpf_prog_test_run_opts)) + return -EINVAL; + attr.test.cpu_plus = opts->cpu_plus; + } 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); @@ -712,6 +718,11 @@ int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr) return ret; } +int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr) +{ + return bpf_prog_test_run_xattr_opts(test_attr, NULL); +} + static int bpf_obj_get_next_id(__u32 start_id, __u32 *next_id, int cmd) { union bpf_attr attr; diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index 8c1ac4b42f908..61318f47c8e1b 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h @@ -251,6 +251,17 @@ struct bpf_prog_bind_opts { LIBBPF_API int bpf_prog_bind_map(int prog_fd, int map_fd, const struct bpf_prog_bind_opts *opts); + +struct bpf_prog_test_run_opts { + size_t sz; /* size of this struct for forward/backward compatibility */ + __u32 cpu_plus; +}; +#define bpf_prog_test_run_opts__last_field cpu_plus + +LIBBPF_API +int bpf_prog_test_run_xattr_opts(struct bpf_prog_test_run_attr *test_attr, + const struct bpf_prog_test_run_opts *opts); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map index 5f054dadf0829..c84a8bec57634 100644 --- a/tools/lib/bpf/libbpf.map +++ b/tools/lib/bpf/libbpf.map @@ -303,6 +303,7 @@ LIBBPF_0.1.0 { LIBBPF_0.2.0 { global: bpf_prog_bind_map; + bpf_prog_test_run_xattr_opts; bpf_program__section_name; perf_buffer__buffer_cnt; perf_buffer__buffer_fd;