Skip to content

Commit 7cb06a6

Browse files
ahduyckkuba-moo
authored andcommitted
eth: fbnic: support querying RSS config
The initial driver submission already added all the RSS state, as part of multi-queue support. Expose the configuration via the ethtool APIs. Signed-off-by: Alexander Duyck <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7d0bf49 commit 7cb06a6

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

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

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,105 @@ static int fbnic_get_sset_count(struct net_device *dev, int sset)
102102
}
103103
}
104104

105+
static int fbnic_get_rss_hash_idx(u32 flow_type)
106+
{
107+
switch (flow_type & ~(FLOW_EXT | FLOW_MAC_EXT | FLOW_RSS)) {
108+
case TCP_V4_FLOW:
109+
return FBNIC_TCP4_HASH_OPT;
110+
case TCP_V6_FLOW:
111+
return FBNIC_TCP6_HASH_OPT;
112+
case UDP_V4_FLOW:
113+
return FBNIC_UDP4_HASH_OPT;
114+
case UDP_V6_FLOW:
115+
return FBNIC_UDP6_HASH_OPT;
116+
case AH_V4_FLOW:
117+
case ESP_V4_FLOW:
118+
case AH_ESP_V4_FLOW:
119+
case SCTP_V4_FLOW:
120+
case IPV4_FLOW:
121+
case IPV4_USER_FLOW:
122+
return FBNIC_IPV4_HASH_OPT;
123+
case AH_V6_FLOW:
124+
case ESP_V6_FLOW:
125+
case AH_ESP_V6_FLOW:
126+
case SCTP_V6_FLOW:
127+
case IPV6_FLOW:
128+
case IPV6_USER_FLOW:
129+
return FBNIC_IPV6_HASH_OPT;
130+
case ETHER_FLOW:
131+
return FBNIC_ETHER_HASH_OPT;
132+
}
133+
134+
return -1;
135+
}
136+
137+
static int
138+
fbnic_get_rss_hash_opts(struct fbnic_net *fbn, struct ethtool_rxnfc *cmd)
139+
{
140+
int hash_opt_idx = fbnic_get_rss_hash_idx(cmd->flow_type);
141+
142+
if (hash_opt_idx < 0)
143+
return -EINVAL;
144+
145+
/* Report options from rss_en table in fbn */
146+
cmd->data = fbn->rss_flow_hash[hash_opt_idx];
147+
148+
return 0;
149+
}
150+
151+
static int fbnic_get_rxnfc(struct net_device *netdev,
152+
struct ethtool_rxnfc *cmd, u32 *rule_locs)
153+
{
154+
struct fbnic_net *fbn = netdev_priv(netdev);
155+
int ret = -EOPNOTSUPP;
156+
157+
switch (cmd->cmd) {
158+
case ETHTOOL_GRXRINGS:
159+
cmd->data = fbn->num_rx_queues;
160+
ret = 0;
161+
break;
162+
case ETHTOOL_GRXFH:
163+
ret = fbnic_get_rss_hash_opts(fbn, cmd);
164+
break;
165+
}
166+
167+
return ret;
168+
}
169+
170+
static u32 fbnic_get_rxfh_key_size(struct net_device *netdev)
171+
{
172+
return FBNIC_RPC_RSS_KEY_BYTE_LEN;
173+
}
174+
175+
static u32 fbnic_get_rxfh_indir_size(struct net_device *netdev)
176+
{
177+
return FBNIC_RPC_RSS_TBL_SIZE;
178+
}
179+
180+
static int
181+
fbnic_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)
182+
{
183+
struct fbnic_net *fbn = netdev_priv(netdev);
184+
unsigned int i;
185+
186+
rxfh->hfunc = ETH_RSS_HASH_TOP;
187+
188+
if (rxfh->key) {
189+
for (i = 0; i < FBNIC_RPC_RSS_KEY_BYTE_LEN; i++) {
190+
u32 rss_key = fbn->rss_key[i / 4] << ((i % 4) * 8);
191+
192+
rxfh->key[i] = rss_key >> 24;
193+
}
194+
}
195+
196+
if (rxfh->indir) {
197+
for (i = 0; i < FBNIC_RPC_RSS_TBL_SIZE; i++)
198+
rxfh->indir[i] = fbn->indir_tbl[0][i];
199+
}
200+
201+
return 0;
202+
}
203+
105204
static int
106205
fbnic_get_ts_info(struct net_device *netdev,
107206
struct kernel_ethtool_ts_info *tsinfo)
@@ -209,6 +308,10 @@ static const struct ethtool_ops fbnic_ethtool_ops = {
209308
.get_strings = fbnic_get_strings,
210309
.get_ethtool_stats = fbnic_get_ethtool_stats,
211310
.get_sset_count = fbnic_get_sset_count,
311+
.get_rxnfc = fbnic_get_rxnfc,
312+
.get_rxfh_key_size = fbnic_get_rxfh_key_size,
313+
.get_rxfh_indir_size = fbnic_get_rxfh_indir_size,
314+
.get_rxfh = fbnic_get_rxfh,
212315
.get_ts_info = fbnic_get_ts_info,
213316
.get_ts_stats = fbnic_get_ts_stats,
214317
.get_eth_mac_stats = fbnic_get_eth_mac_stats,

0 commit comments

Comments
 (0)