mirror of
				git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
				synced 2025-10-31 08:44:41 +00:00 
			
		
		
		
	 e754f5a6e3
			
		
	
	
		e754f5a6e3
		
	
	
	
	
		
			
			The xdp_perf is a dummy XDP test, only used to measure the the cost of jumping into a naive XDP program one million times. To build and run the program: $ cd tools/testing/selftests/bpf $ make $ ./test_progs -v -t xdp_perf Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20191213175112.30208-6-bjorn.topel@gmail.com
		
			
				
	
	
		
			25 lines
		
	
	
	
		
			592 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
	
		
			592 B
		
	
	
	
		
			C
		
	
	
	
	
	
| // SPDX-License-Identifier: GPL-2.0
 | |
| #include <test_progs.h>
 | |
| 
 | |
| void test_xdp_perf(void)
 | |
| {
 | |
| 	const char *file = "./xdp_dummy.o";
 | |
| 	__u32 duration, retval, size;
 | |
| 	struct bpf_object *obj;
 | |
| 	char in[128], out[128];
 | |
| 	int err, prog_fd;
 | |
| 
 | |
| 	err = bpf_prog_load(file, BPF_PROG_TYPE_XDP, &obj, &prog_fd);
 | |
| 	if (CHECK_FAIL(err))
 | |
| 		return;
 | |
| 
 | |
| 	err = bpf_prog_test_run(prog_fd, 1000000, &in[0], 128,
 | |
| 				out, &size, &retval, &duration);
 | |
| 
 | |
| 	CHECK(err || retval != XDP_PASS || size != 128,
 | |
| 	      "xdp-perf",
 | |
| 	      "err %d errno %d retval %d size %d\n",
 | |
| 	      err, errno, retval, size);
 | |
| 
 | |
| 	bpf_object__close(obj);
 | |
| }
 |