1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Facebook
3 #include <linux/bpf.h>
4 #include <bpf/bpf_helpers.h>
5 #define ATTR __attribute__((noinline))
6 #include "test_jhash.h"
7 
8 SEC("scale90_noinline32")
9 int balancer_ingress(struct __sk_buff *ctx)
10 {
11 	void *data_end = (void *)(long)ctx->data_end;
12 	void *data = (void *)(long)ctx->data;
13 	void *ptr;
14 	int ret = 0, nh_off, i = 0;
15 
16 	nh_off = 32;
17 
18 	/* pragma unroll doesn't work on large loops */
19 
20 #define C do { \
21 	ptr = data + i; \
22 	if (ptr + nh_off > data_end) \
23 		break; \
24 	ctx->tc_index = jhash(ptr, nh_off, ctx->cb[0] + i++); \
25 	} while (0);
26 #define C30 C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;C;
27 	C30;C30;C30; /* 90 calls */
28 	return 0;
29 }
30 char _license[] SEC("license") = "GPL";
31