File tree Expand file tree Collapse file tree 6 files changed +23
-12
lines changed
tools/testing/selftests/bpf Expand file tree Collapse file tree 6 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -273,6 +273,8 @@ static int verify_xsk_metadata(struct xsk *xsk)
273
273
if (!ASSERT_NEQ (meta -> rx_hash , 0 , "rx_hash" ))
274
274
return -1 ;
275
275
276
+ ASSERT_EQ (meta -> rx_hash_type , 0 , "rx_hash_type" );
277
+
276
278
xsk_ring_cons__release (& xsk -> rx , 1 );
277
279
refill_rx (xsk , comp_addr );
278
280
Original file line number Diff line number Diff line change @@ -18,8 +18,8 @@ __u64 pkts_redir = 0;
18
18
19
19
extern int bpf_xdp_metadata_rx_timestamp (const struct xdp_md * ctx ,
20
20
__u64 * timestamp ) __ksym ;
21
- extern int bpf_xdp_metadata_rx_hash (const struct xdp_md * ctx ,
22
- __u32 * hash ) __ksym ;
21
+ extern int bpf_xdp_metadata_rx_hash (const struct xdp_md * ctx , __u32 * hash ,
22
+ enum xdp_rss_hash_type * rss_type ) __ksym ;
23
23
24
24
SEC ("xdp" )
25
25
int rx (struct xdp_md * ctx )
@@ -80,9 +80,9 @@ int rx(struct xdp_md *ctx)
80
80
if (err )
81
81
meta -> rx_timestamp = 0 ; /* Used by AF_XDP as not avail signal */
82
82
83
- err = bpf_xdp_metadata_rx_hash (ctx , & meta -> rx_hash );
84
- if (err )
85
- meta -> rx_hash = 0 ; /* Used by AF_XDP as not avail signal */
83
+ err = bpf_xdp_metadata_rx_hash (ctx , & meta -> rx_hash , & meta -> rx_hash_type );
84
+ if (err < 0 )
85
+ meta -> rx_hash_err = err ; /* Used by AF_XDP as no hash signal */
86
86
87
87
__sync_add_and_fetch (& pkts_redir , 1 );
88
88
return bpf_redirect_map (& xsk , ctx -> rx_queue_index , XDP_PASS );
Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ struct {
21
21
22
22
extern int bpf_xdp_metadata_rx_timestamp (const struct xdp_md * ctx ,
23
23
__u64 * timestamp ) __ksym ;
24
- extern int bpf_xdp_metadata_rx_hash (const struct xdp_md * ctx ,
25
- __u32 * hash ) __ksym ;
24
+ extern int bpf_xdp_metadata_rx_hash (const struct xdp_md * ctx , __u32 * hash ,
25
+ enum xdp_rss_hash_type * rss_type ) __ksym ;
26
26
27
27
SEC ("xdp" )
28
28
int rx (struct xdp_md * ctx )
@@ -56,7 +56,7 @@ int rx(struct xdp_md *ctx)
56
56
if (timestamp == 0 )
57
57
meta -> rx_timestamp = 1 ;
58
58
59
- bpf_xdp_metadata_rx_hash (ctx , & meta -> rx_hash );
59
+ bpf_xdp_metadata_rx_hash (ctx , & meta -> rx_hash , & meta -> rx_hash_type );
60
60
61
61
return bpf_redirect_map (& xsk , ctx -> rx_queue_index , XDP_PASS );
62
62
}
Original file line number Diff line number Diff line change 5
5
#include <bpf/bpf_helpers.h>
6
6
#include <bpf/bpf_endian.h>
7
7
8
- extern int bpf_xdp_metadata_rx_hash (const struct xdp_md * ctx ,
9
- __u32 * hash ) __ksym ;
8
+ extern int bpf_xdp_metadata_rx_hash (const struct xdp_md * ctx , __u32 * hash ,
9
+ enum xdp_rss_hash_type * rss_type ) __ksym ;
10
10
11
11
int called ;
12
12
13
13
SEC ("freplace/rx" )
14
14
int freplace_rx (struct xdp_md * ctx )
15
15
{
16
+ enum xdp_rss_hash_type type = 0 ;
16
17
u32 hash = 0 ;
17
18
/* Call _any_ metadata function to make sure we don't crash. */
18
- bpf_xdp_metadata_rx_hash (ctx , & hash );
19
+ bpf_xdp_metadata_rx_hash (ctx , & hash , & type );
19
20
called ++ ;
20
21
return XDP_PASS ;
21
22
}
Original file line number Diff line number Diff line change @@ -141,7 +141,11 @@ static void verify_xdp_metadata(void *data)
141
141
meta = data - sizeof (* meta );
142
142
143
143
printf ("rx_timestamp: %llu\n" , meta -> rx_timestamp );
144
- printf ("rx_hash: %u\n" , meta -> rx_hash );
144
+ if (meta -> rx_hash_err < 0 )
145
+ printf ("No rx_hash err=%d\n" , meta -> rx_hash_err );
146
+ else
147
+ printf ("rx_hash: 0x%X with RSS type:0x%X\n" ,
148
+ meta -> rx_hash , meta -> rx_hash_type );
145
149
}
146
150
147
151
static void verify_skb_metadata (int fd )
Original file line number Diff line number Diff line change 12
12
struct xdp_meta {
13
13
__u64 rx_timestamp ;
14
14
__u32 rx_hash ;
15
+ union {
16
+ __u32 rx_hash_type ;
17
+ __s32 rx_hash_err ;
18
+ };
15
19
};
You can’t perform that action at this time.
0 commit comments