Skip to content

Commit c23a146

Browse files
ahduyckkuba-moo
authored andcommitted
eth: fbnic: let user control the RSS hash fields
Support setting the fields over which RSS computes its hash. Signed-off-by: Alexander Duyck <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 31ab733 commit c23a146

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,55 @@ static int fbnic_get_rxnfc(struct net_device *netdev,
167167
return ret;
168168
}
169169

170+
#define FBNIC_L2_HASH_OPTIONS \
171+
(RXH_L2DA | RXH_DISCARD)
172+
#define FBNIC_L3_HASH_OPTIONS \
173+
(FBNIC_L2_HASH_OPTIONS | RXH_IP_SRC | RXH_IP_DST)
174+
#define FBNIC_L4_HASH_OPTIONS \
175+
(FBNIC_L3_HASH_OPTIONS | RXH_L4_B_0_1 | RXH_L4_B_2_3)
176+
177+
static int
178+
fbnic_set_rss_hash_opts(struct fbnic_net *fbn, const struct ethtool_rxnfc *cmd)
179+
{
180+
int hash_opt_idx;
181+
182+
/* Verify the type requested is correct */
183+
hash_opt_idx = fbnic_get_rss_hash_idx(cmd->flow_type);
184+
if (hash_opt_idx < 0)
185+
return -EINVAL;
186+
187+
/* Verify the fields asked for can actually be assigned based on type */
188+
if (cmd->data & ~FBNIC_L4_HASH_OPTIONS ||
189+
(hash_opt_idx > FBNIC_L4_HASH_OPT &&
190+
cmd->data & ~FBNIC_L3_HASH_OPTIONS) ||
191+
(hash_opt_idx > FBNIC_IP_HASH_OPT &&
192+
cmd->data & ~FBNIC_L2_HASH_OPTIONS))
193+
return -EINVAL;
194+
195+
fbn->rss_flow_hash[hash_opt_idx] = cmd->data;
196+
197+
if (netif_running(fbn->netdev)) {
198+
fbnic_rss_reinit(fbn->fbd, fbn);
199+
fbnic_write_rules(fbn->fbd);
200+
}
201+
202+
return 0;
203+
}
204+
205+
static int fbnic_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
206+
{
207+
struct fbnic_net *fbn = netdev_priv(netdev);
208+
int ret = -EOPNOTSUPP;
209+
210+
switch (cmd->cmd) {
211+
case ETHTOOL_SRXFH:
212+
ret = fbnic_set_rss_hash_opts(fbn, cmd);
213+
break;
214+
}
215+
216+
return ret;
217+
}
218+
170219
static u32 fbnic_get_rxfh_key_size(struct net_device *netdev)
171220
{
172221
return FBNIC_RPC_RSS_KEY_BYTE_LEN;
@@ -363,6 +412,7 @@ static const struct ethtool_ops fbnic_ethtool_ops = {
363412
.get_ethtool_stats = fbnic_get_ethtool_stats,
364413
.get_sset_count = fbnic_get_sset_count,
365414
.get_rxnfc = fbnic_get_rxnfc,
415+
.set_rxnfc = fbnic_set_rxnfc,
366416
.get_rxfh_key_size = fbnic_get_rxfh_key_size,
367417
.get_rxfh_indir_size = fbnic_get_rxfh_indir_size,
368418
.get_rxfh = fbnic_get_rxfh,

0 commit comments

Comments
 (0)