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)
273273 if (!ASSERT_NEQ (meta -> rx_hash , 0 , "rx_hash" ))
274274 return -1 ;
275275
276+ ASSERT_EQ (meta -> rx_hash_type , 0 , "rx_hash_type" );
277+
276278 xsk_ring_cons__release (& xsk -> rx , 1 );
277279 refill_rx (xsk , comp_addr );
278280
Original file line number Diff line number Diff line change @@ -18,8 +18,8 @@ __u64 pkts_redir = 0;
1818
1919extern int bpf_xdp_metadata_rx_timestamp (const struct xdp_md * ctx ,
2020 __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 ;
2323
2424SEC ("xdp" )
2525int rx (struct xdp_md * ctx )
@@ -80,9 +80,9 @@ int rx(struct xdp_md *ctx)
8080 if (err )
8181 meta -> rx_timestamp = 0 ; /* Used by AF_XDP as not avail signal */
8282
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 */
8686
8787 __sync_add_and_fetch (& pkts_redir , 1 );
8888 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 {
2121
2222extern int bpf_xdp_metadata_rx_timestamp (const struct xdp_md * ctx ,
2323 __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 ;
2626
2727SEC ("xdp" )
2828int rx (struct xdp_md * ctx )
@@ -56,7 +56,7 @@ int rx(struct xdp_md *ctx)
5656 if (timestamp == 0 )
5757 meta -> rx_timestamp = 1 ;
5858
59- bpf_xdp_metadata_rx_hash (ctx , & meta -> rx_hash );
59+ bpf_xdp_metadata_rx_hash (ctx , & meta -> rx_hash , & meta -> rx_hash_type );
6060
6161 return bpf_redirect_map (& xsk , ctx -> rx_queue_index , XDP_PASS );
6262}
Original file line number Diff line number Diff line change 55#include <bpf/bpf_helpers.h>
66#include <bpf/bpf_endian.h>
77
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 ;
1010
1111int called ;
1212
1313SEC ("freplace/rx" )
1414int freplace_rx (struct xdp_md * ctx )
1515{
16+ enum xdp_rss_hash_type type = 0 ;
1617 u32 hash = 0 ;
1718 /* 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 );
1920 called ++ ;
2021 return XDP_PASS ;
2122}
Original file line number Diff line number Diff line change @@ -141,7 +141,11 @@ static void verify_xdp_metadata(void *data)
141141 meta = data - sizeof (* meta );
142142
143143 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 );
145149}
146150
147151static void verify_skb_metadata (int fd )
Original file line number Diff line number Diff line change 1212struct xdp_meta {
1313 __u64 rx_timestamp ;
1414 __u32 rx_hash ;
15+ union {
16+ __u32 rx_hash_type ;
17+ __s32 rx_hash_err ;
18+ };
1519};
You can’t perform that action at this time.
0 commit comments