Skip to content

Commit 31ab733

Browse files
ahduyckkuba-moo
authored andcommitted
eth: fbnic: support setting RSS configuration
Let the user program the RSS indirection table and the RSS key. Straightforward implementation. Track the changes and don't bother poking the HW if user asked for a config identical to what's already programmed. The device only supports Toeplitz hash. Similarly to the GET support - all the real code that does the programming was part of initial driver submission, already. Signed-off-by: Alexander Duyck <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ef1c288 commit 31ab733

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,60 @@ fbnic_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)
201201
return 0;
202202
}
203203

204+
static unsigned int
205+
fbnic_set_indir(struct fbnic_net *fbn, unsigned int idx, const u32 *indir)
206+
{
207+
unsigned int i, changes = 0;
208+
209+
for (i = 0; i < FBNIC_RPC_RSS_TBL_SIZE; i++) {
210+
if (fbn->indir_tbl[idx][i] == indir[i])
211+
continue;
212+
213+
fbn->indir_tbl[idx][i] = indir[i];
214+
changes++;
215+
}
216+
217+
return changes;
218+
}
219+
220+
static int
221+
fbnic_set_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh,
222+
struct netlink_ext_ack *extack)
223+
{
224+
struct fbnic_net *fbn = netdev_priv(netdev);
225+
unsigned int i, changes = 0;
226+
227+
if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
228+
rxfh->hfunc != ETH_RSS_HASH_TOP)
229+
return -EINVAL;
230+
231+
if (rxfh->key) {
232+
u32 rss_key = 0;
233+
234+
for (i = FBNIC_RPC_RSS_KEY_BYTE_LEN; i--;) {
235+
rss_key >>= 8;
236+
rss_key |= (u32)(rxfh->key[i]) << 24;
237+
238+
if (i % 4)
239+
continue;
240+
241+
if (fbn->rss_key[i / 4] == rss_key)
242+
continue;
243+
244+
fbn->rss_key[i / 4] = rss_key;
245+
changes++;
246+
}
247+
}
248+
249+
if (rxfh->indir)
250+
changes += fbnic_set_indir(fbn, 0, rxfh->indir);
251+
252+
if (changes && netif_running(netdev))
253+
fbnic_rss_reinit_hw(fbn->fbd, fbn);
254+
255+
return 0;
256+
}
257+
204258
static int
205259
fbnic_get_ts_info(struct net_device *netdev,
206260
struct kernel_ethtool_ts_info *tsinfo)
@@ -312,6 +366,7 @@ static const struct ethtool_ops fbnic_ethtool_ops = {
312366
.get_rxfh_key_size = fbnic_get_rxfh_key_size,
313367
.get_rxfh_indir_size = fbnic_get_rxfh_indir_size,
314368
.get_rxfh = fbnic_get_rxfh,
369+
.set_rxfh = fbnic_set_rxfh,
315370
.get_ts_info = fbnic_get_ts_info,
316371
.get_ts_stats = fbnic_get_ts_stats,
317372
.get_eth_mac_stats = fbnic_get_eth_mac_stats,

0 commit comments

Comments
 (0)