@@ -19,6 +19,15 @@ def _rss_key_rand(length):
1919 return [random .randint (0 , 255 ) for _ in range (length )]
2020
2121
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+
2231def get_rss (cfg , context = 0 ):
2332 return ethtool (f"-x { cfg .ifname } context { context } " , json = True )[0 ]
2433
@@ -90,8 +99,9 @@ def _send_traffic_check(cfg, port, name, params):
9099def test_rss_key_indir (cfg ):
91100 """Test basics like updating the main RSS key and indirection table."""
92101
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)" )
95105
96106 data = get_rss (cfg )
97107 want_keys = ['rss-hash-key' , 'rss-hash-function' , 'rss-indirection-table' ]
@@ -101,6 +111,7 @@ def test_rss_key_indir(cfg):
101111 if not data [k ]:
102112 raise KsftFailEx (f"ethtool results empty for '{ k } ': { data [k ]} " )
103113
114+ _rss_key_check (cfg , data = data )
104115 key_len = len (data ['rss-hash-key' ])
105116
106117 # Set the key
@@ -110,9 +121,26 @@ def test_rss_key_indir(cfg):
110121 data = get_rss (cfg )
111122 ksft_eq (key , data ['rss-hash-key' ])
112123
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+
113142 # Set the indirection table
114143 ethtool (f"-X { cfg .ifname } equal 2" )
115- reset_indir = defer (ethtool , f"-X { cfg .ifname } default" )
116144 data = get_rss (cfg )
117145 ksft_eq (0 , min (data ['rss-indirection-table' ]))
118146 ksft_eq (1 , max (data ['rss-indirection-table' ]))
@@ -317,8 +345,11 @@ def test_rss_context(cfg, ctx_cnt=1, create_with_cfg=None):
317345 ctx_cnt = i
318346 break
319347
348+ _rss_key_check (cfg , context = ctx_id )
349+
320350 if not create_with_cfg :
321351 ethtool (f"-X { cfg .ifname } context { ctx_id } { want_cfg } " )
352+ _rss_key_check (cfg , context = ctx_id )
322353
323354 # Sanity check the context we just created
324355 data = get_rss (cfg , ctx_id )
0 commit comments