@@ -19,6 +19,15 @@ def _rss_key_rand(length):
19
19
return [random .randint (0 , 255 ) for _ in range (length )]
20
20
21
21
22
+ def _rss_key_check (cfg , data = None , context = 0 ):
23
+ if data is None :
24
+ data = get_rss (cfg , context = context )
25
+ if 'rss-hash-key' not in data :
26
+ return
27
+ non_zero = [x for x in data ['rss-hash-key' ] if x != 0 ]
28
+ ksft_eq (bool (non_zero ), True , comment = f"RSS key is all zero { data ['rss-hash-key' ]} " )
29
+
30
+
22
31
def get_rss (cfg , context = 0 ):
23
32
return ethtool (f"-x { cfg .ifname } context { context } " , json = True )[0 ]
24
33
@@ -90,8 +99,9 @@ def _send_traffic_check(cfg, port, name, params):
90
99
def test_rss_key_indir (cfg ):
91
100
"""Test basics like updating the main RSS key and indirection table."""
92
101
93
- if len (_get_rx_cnts (cfg )) < 2 :
94
- KsftSkipEx ("Device has only one queue (or doesn't support queue stats)" )
102
+ qcnt = len (_get_rx_cnts (cfg ))
103
+ if qcnt < 3 :
104
+ KsftSkipEx ("Device has fewer than 3 queues (or doesn't support queue stats)" )
95
105
96
106
data = get_rss (cfg )
97
107
want_keys = ['rss-hash-key' , 'rss-hash-function' , 'rss-indirection-table' ]
@@ -101,6 +111,7 @@ def test_rss_key_indir(cfg):
101
111
if not data [k ]:
102
112
raise KsftFailEx (f"ethtool results empty for '{ k } ': { data [k ]} " )
103
113
114
+ _rss_key_check (cfg , data = data )
104
115
key_len = len (data ['rss-hash-key' ])
105
116
106
117
# Set the key
@@ -110,9 +121,26 @@ def test_rss_key_indir(cfg):
110
121
data = get_rss (cfg )
111
122
ksft_eq (key , data ['rss-hash-key' ])
112
123
124
+ # Set the indirection table and the key together
125
+ key = _rss_key_rand (key_len )
126
+ ethtool (f"-X { cfg .ifname } equal 3 hkey " + _rss_key_str (key ))
127
+ reset_indir = defer (ethtool , f"-X { cfg .ifname } default" )
128
+
129
+ data = get_rss (cfg )
130
+ _rss_key_check (cfg , data = data )
131
+ ksft_eq (0 , min (data ['rss-indirection-table' ]))
132
+ ksft_eq (2 , max (data ['rss-indirection-table' ]))
133
+
134
+ # Reset indirection table and set the key
135
+ key = _rss_key_rand (key_len )
136
+ ethtool (f"-X { cfg .ifname } default hkey " + _rss_key_str (key ))
137
+ data = get_rss (cfg )
138
+ _rss_key_check (cfg , data = data )
139
+ ksft_eq (0 , min (data ['rss-indirection-table' ]))
140
+ ksft_eq (qcnt - 1 , max (data ['rss-indirection-table' ]))
141
+
113
142
# Set the indirection table
114
143
ethtool (f"-X { cfg .ifname } equal 2" )
115
- reset_indir = defer (ethtool , f"-X { cfg .ifname } default" )
116
144
data = get_rss (cfg )
117
145
ksft_eq (0 , min (data ['rss-indirection-table' ]))
118
146
ksft_eq (1 , max (data ['rss-indirection-table' ]))
@@ -317,8 +345,11 @@ def test_rss_context(cfg, ctx_cnt=1, create_with_cfg=None):
317
345
ctx_cnt = i
318
346
break
319
347
348
+ _rss_key_check (cfg , context = ctx_id )
349
+
320
350
if not create_with_cfg :
321
351
ethtool (f"-X { cfg .ifname } context { ctx_id } { want_cfg } " )
352
+ _rss_key_check (cfg , context = ctx_id )
322
353
323
354
# Sanity check the context we just created
324
355
data = get_rss (cfg , ctx_id )
0 commit comments