@@ -979,7 +979,7 @@ efx_ethtool_get_rxnfc(struct net_device *net_dev,
979
979
{
980
980
struct efx_nic * efx = netdev_priv (net_dev );
981
981
u32 rss_context = 0 ;
982
- s32 rc ;
982
+ s32 rc = 0 ;
983
983
984
984
switch (info -> cmd ) {
985
985
case ETHTOOL_GRXRINGS :
@@ -989,15 +989,17 @@ efx_ethtool_get_rxnfc(struct net_device *net_dev,
989
989
case ETHTOOL_GRXFH : {
990
990
struct efx_rss_context * ctx = & efx -> rss_context ;
991
991
992
+ mutex_lock (& efx -> rss_lock );
992
993
if (info -> flow_type & FLOW_RSS && info -> rss_context ) {
993
- ctx = efx_find_rss_context_entry (info -> rss_context ,
994
- & efx -> rss_context .list );
995
- if (!ctx )
996
- return - ENOENT ;
994
+ ctx = efx_find_rss_context_entry (efx , info -> rss_context );
995
+ if (!ctx ) {
996
+ rc = - ENOENT ;
997
+ goto out_unlock ;
998
+ }
997
999
}
998
1000
info -> data = 0 ;
999
1001
if (!efx_rss_active (ctx )) /* No RSS */
1000
- return 0 ;
1002
+ goto out_unlock ;
1001
1003
switch (info -> flow_type & ~FLOW_RSS ) {
1002
1004
case UDP_V4_FLOW :
1003
1005
if (ctx -> rx_hash_udp_4tuple )
@@ -1024,7 +1026,9 @@ efx_ethtool_get_rxnfc(struct net_device *net_dev,
1024
1026
default :
1025
1027
break ;
1026
1028
}
1027
- return 0 ;
1029
+ out_unlock :
1030
+ mutex_unlock (& efx -> rss_lock );
1031
+ return rc ;
1028
1032
}
1029
1033
1030
1034
case ETHTOOL_GRXCLSRLCNT :
@@ -1084,6 +1088,7 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx,
1084
1088
struct ethtool_tcpip6_spec * ip6_mask = & rule -> m_u .tcp_ip6_spec ;
1085
1089
struct ethtool_usrip6_spec * uip6_entry = & rule -> h_u .usr_ip6_spec ;
1086
1090
struct ethtool_usrip6_spec * uip6_mask = & rule -> m_u .usr_ip6_spec ;
1091
+ u32 flow_type = rule -> flow_type & ~(FLOW_EXT | FLOW_RSS );
1087
1092
struct ethhdr * mac_entry = & rule -> h_u .ether_spec ;
1088
1093
struct ethhdr * mac_mask = & rule -> m_u .ether_spec ;
1089
1094
enum efx_filter_flags flags = 0 ;
@@ -1117,14 +1122,14 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx,
1117
1122
if (rule -> flow_type & FLOW_RSS )
1118
1123
spec .rss_context = rss_context ;
1119
1124
1120
- switch (rule -> flow_type & ~( FLOW_EXT | FLOW_RSS ) ) {
1125
+ switch (flow_type ) {
1121
1126
case TCP_V4_FLOW :
1122
1127
case UDP_V4_FLOW :
1123
1128
spec .match_flags = (EFX_FILTER_MATCH_ETHER_TYPE |
1124
1129
EFX_FILTER_MATCH_IP_PROTO );
1125
1130
spec .ether_type = htons (ETH_P_IP );
1126
- spec .ip_proto = (( rule -> flow_type & ~ FLOW_EXT ) == TCP_V4_FLOW ?
1127
- IPPROTO_TCP : IPPROTO_UDP ) ;
1131
+ spec .ip_proto = flow_type == TCP_V4_FLOW ? IPPROTO_TCP
1132
+ : IPPROTO_UDP ;
1128
1133
if (ip_mask -> ip4dst ) {
1129
1134
if (ip_mask -> ip4dst != IP4_ADDR_FULL_MASK )
1130
1135
return - EINVAL ;
@@ -1158,8 +1163,8 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx,
1158
1163
spec .match_flags = (EFX_FILTER_MATCH_ETHER_TYPE |
1159
1164
EFX_FILTER_MATCH_IP_PROTO );
1160
1165
spec .ether_type = htons (ETH_P_IPV6 );
1161
- spec .ip_proto = (( rule -> flow_type & ~ FLOW_EXT ) == TCP_V6_FLOW ?
1162
- IPPROTO_TCP : IPPROTO_UDP ) ;
1166
+ spec .ip_proto = flow_type == TCP_V6_FLOW ? IPPROTO_TCP
1167
+ : IPPROTO_UDP ;
1163
1168
if (!ip6_mask_is_empty (ip6_mask -> ip6dst )) {
1164
1169
if (!ip6_mask_is_full (ip6_mask -> ip6dst ))
1165
1170
return - EINVAL ;
@@ -1366,24 +1371,30 @@ static int efx_ethtool_get_rxfh_context(struct net_device *net_dev, u32 *indir,
1366
1371
{
1367
1372
struct efx_nic * efx = netdev_priv (net_dev );
1368
1373
struct efx_rss_context * ctx ;
1369
- int rc ;
1374
+ int rc = 0 ;
1370
1375
1371
1376
if (!efx -> type -> rx_pull_rss_context_config )
1372
1377
return - EOPNOTSUPP ;
1373
- ctx = efx_find_rss_context_entry (rss_context , & efx -> rss_context .list );
1374
- if (!ctx )
1375
- return - ENOENT ;
1378
+
1379
+ mutex_lock (& efx -> rss_lock );
1380
+ ctx = efx_find_rss_context_entry (efx , rss_context );
1381
+ if (!ctx ) {
1382
+ rc = - ENOENT ;
1383
+ goto out_unlock ;
1384
+ }
1376
1385
rc = efx -> type -> rx_pull_rss_context_config (efx , ctx );
1377
1386
if (rc )
1378
- return rc ;
1387
+ goto out_unlock ;
1379
1388
1380
1389
if (hfunc )
1381
1390
* hfunc = ETH_RSS_HASH_TOP ;
1382
1391
if (indir )
1383
1392
memcpy (indir , ctx -> rx_indir_table , sizeof (ctx -> rx_indir_table ));
1384
1393
if (key )
1385
1394
memcpy (key , ctx -> rx_hash_key , efx -> type -> rx_hash_key_size );
1386
- return 0 ;
1395
+ out_unlock :
1396
+ mutex_unlock (& efx -> rss_lock );
1397
+ return rc ;
1387
1398
}
1388
1399
1389
1400
static int efx_ethtool_set_rxfh_context (struct net_device * net_dev ,
@@ -1401,31 +1412,39 @@ static int efx_ethtool_set_rxfh_context(struct net_device *net_dev,
1401
1412
/* Hash function is Toeplitz, cannot be changed */
1402
1413
if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP )
1403
1414
return - EOPNOTSUPP ;
1415
+
1416
+ mutex_lock (& efx -> rss_lock );
1417
+
1404
1418
if (* rss_context == ETH_RXFH_CONTEXT_ALLOC ) {
1405
- if (delete )
1419
+ if (delete ) {
1406
1420
/* alloc + delete == Nothing to do */
1407
- return - EINVAL ;
1408
- ctx = efx_alloc_rss_context_entry (& efx -> rss_context .list );
1409
- if (!ctx )
1410
- return - ENOMEM ;
1421
+ rc = - EINVAL ;
1422
+ goto out_unlock ;
1423
+ }
1424
+ ctx = efx_alloc_rss_context_entry (efx );
1425
+ if (!ctx ) {
1426
+ rc = - ENOMEM ;
1427
+ goto out_unlock ;
1428
+ }
1411
1429
ctx -> context_id = EFX_EF10_RSS_CONTEXT_INVALID ;
1412
1430
/* Initialise indir table and key to defaults */
1413
1431
efx_set_default_rx_indir_table (efx , ctx );
1414
1432
netdev_rss_key_fill (ctx -> rx_hash_key , sizeof (ctx -> rx_hash_key ));
1415
1433
allocated = true;
1416
1434
} else {
1417
- ctx = efx_find_rss_context_entry (* rss_context ,
1418
- & efx -> rss_context .list );
1419
- if (!ctx )
1420
- return - ENOENT ;
1435
+ ctx = efx_find_rss_context_entry (efx , * rss_context );
1436
+ if (!ctx ) {
1437
+ rc = - ENOENT ;
1438
+ goto out_unlock ;
1439
+ }
1421
1440
}
1422
1441
1423
1442
if (delete ) {
1424
1443
/* delete this context */
1425
1444
rc = efx -> type -> rx_push_rss_context_config (efx , ctx , NULL , NULL );
1426
1445
if (!rc )
1427
1446
efx_free_rss_context_entry (ctx );
1428
- return rc ;
1447
+ goto out_unlock ;
1429
1448
}
1430
1449
1431
1450
if (!key )
@@ -1438,6 +1457,8 @@ static int efx_ethtool_set_rxfh_context(struct net_device *net_dev,
1438
1457
efx_free_rss_context_entry (ctx );
1439
1458
else
1440
1459
* rss_context = ctx -> user_id ;
1460
+ out_unlock :
1461
+ mutex_unlock (& efx -> rss_lock );
1441
1462
return rc ;
1442
1463
}
1443
1464
0 commit comments