@@ -167,6 +167,55 @@ static int fbnic_get_rxnfc(struct net_device *netdev,
167
167
return ret ;
168
168
}
169
169
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
+
170
219
static u32 fbnic_get_rxfh_key_size (struct net_device * netdev )
171
220
{
172
221
return FBNIC_RPC_RSS_KEY_BYTE_LEN ;
@@ -363,6 +412,7 @@ static const struct ethtool_ops fbnic_ethtool_ops = {
363
412
.get_ethtool_stats = fbnic_get_ethtool_stats ,
364
413
.get_sset_count = fbnic_get_sset_count ,
365
414
.get_rxnfc = fbnic_get_rxnfc ,
415
+ .set_rxnfc = fbnic_set_rxnfc ,
366
416
.get_rxfh_key_size = fbnic_get_rxfh_key_size ,
367
417
.get_rxfh_indir_size = fbnic_get_rxfh_indir_size ,
368
418
.get_rxfh = fbnic_get_rxfh ,
0 commit comments