@@ -1012,56 +1012,85 @@ static int bnxt_set_channels(struct net_device *dev,
1012
1012
}
1013
1013
1014
1014
#ifdef CONFIG_RFS_ACCEL
1015
- static int bnxt_grxclsrlall (struct bnxt * bp , struct ethtool_rxnfc * cmd ,
1016
- u32 * rule_locs )
1015
+ static u32 bnxt_get_all_fltr_ids_rcu (struct bnxt * bp , struct hlist_head tbl [],
1016
+ int tbl_size , u32 * ids , u32 start ,
1017
+ u32 id_cnt )
1017
1018
{
1018
- int i , j = 0 ;
1019
+ int i , j = start ;
1019
1020
1020
- cmd -> data = bp -> ntp_fltr_count ;
1021
- for (i = 0 ; i < BNXT_NTP_FLTR_HASH_SIZE ; i ++ ) {
1021
+ if (j >= id_cnt )
1022
+ return j ;
1023
+ for (i = 0 ; i < tbl_size ; i ++ ) {
1022
1024
struct hlist_head * head ;
1023
- struct bnxt_ntuple_filter * fltr ;
1025
+ struct bnxt_filter_base * fltr ;
1024
1026
1025
- head = & bp -> ntp_fltr_hash_tbl [i ];
1026
- rcu_read_lock ();
1027
- hlist_for_each_entry_rcu (fltr , head , base .hash ) {
1028
- if (j == cmd -> rule_cnt )
1029
- break ;
1030
- rule_locs [j ++ ] = fltr -> base .sw_id ;
1027
+ head = & tbl [i ];
1028
+ hlist_for_each_entry_rcu (fltr , head , hash ) {
1029
+ if (!fltr -> flags ||
1030
+ test_bit (BNXT_FLTR_FW_DELETED , & fltr -> state ))
1031
+ continue ;
1032
+ ids [j ++ ] = fltr -> sw_id ;
1033
+ if (j == id_cnt )
1034
+ return j ;
1031
1035
}
1032
- rcu_read_unlock ();
1033
- if (j == cmd -> rule_cnt )
1034
- break ;
1035
1036
}
1036
- cmd -> rule_cnt = j ;
1037
+ return j ;
1038
+ }
1039
+
1040
+ static struct bnxt_filter_base * bnxt_get_one_fltr_rcu (struct bnxt * bp ,
1041
+ struct hlist_head tbl [],
1042
+ int tbl_size , u32 id )
1043
+ {
1044
+ int i ;
1045
+
1046
+ for (i = 0 ; i < tbl_size ; i ++ ) {
1047
+ struct hlist_head * head ;
1048
+ struct bnxt_filter_base * fltr ;
1049
+
1050
+ head = & tbl [i ];
1051
+ hlist_for_each_entry_rcu (fltr , head , hash ) {
1052
+ if (fltr -> flags && fltr -> sw_id == id )
1053
+ return fltr ;
1054
+ }
1055
+ }
1056
+ return NULL ;
1057
+ }
1058
+
1059
+ static int bnxt_grxclsrlall (struct bnxt * bp , struct ethtool_rxnfc * cmd ,
1060
+ u32 * rule_locs )
1061
+ {
1062
+ cmd -> data = bp -> ntp_fltr_count ;
1063
+ rcu_read_lock ();
1064
+ cmd -> rule_cnt = bnxt_get_all_fltr_ids_rcu (bp , bp -> ntp_fltr_hash_tbl ,
1065
+ BNXT_NTP_FLTR_HASH_SIZE ,
1066
+ rule_locs , 0 , cmd -> rule_cnt );
1067
+ rcu_read_unlock ();
1068
+
1037
1069
return 0 ;
1038
1070
}
1039
1071
1040
1072
static int bnxt_grxclsrule (struct bnxt * bp , struct ethtool_rxnfc * cmd )
1041
1073
{
1042
1074
struct ethtool_rx_flow_spec * fs =
1043
1075
(struct ethtool_rx_flow_spec * )& cmd -> fs ;
1076
+ struct bnxt_filter_base * fltr_base ;
1044
1077
struct bnxt_ntuple_filter * fltr ;
1045
1078
struct flow_keys * fkeys ;
1046
- int i , rc = - EINVAL ;
1079
+ int rc = - EINVAL ;
1047
1080
1048
1081
if (fs -> location >= BNXT_NTP_FLTR_MAX_FLTR )
1049
1082
return rc ;
1050
1083
1051
- for (i = 0 ; i < BNXT_NTP_FLTR_HASH_SIZE ; i ++ ) {
1052
- struct hlist_head * head ;
1053
-
1054
- head = & bp -> ntp_fltr_hash_tbl [i ];
1055
- rcu_read_lock ();
1056
- hlist_for_each_entry_rcu (fltr , head , base .hash ) {
1057
- if (fltr -> base .sw_id == fs -> location )
1058
- goto fltr_found ;
1059
- }
1084
+ rcu_read_lock ();
1085
+ fltr_base = bnxt_get_one_fltr_rcu (bp , bp -> ntp_fltr_hash_tbl ,
1086
+ BNXT_NTP_FLTR_HASH_SIZE ,
1087
+ fs -> location );
1088
+ if (!fltr_base ) {
1060
1089
rcu_read_unlock ();
1090
+ return rc ;
1061
1091
}
1062
- return rc ;
1092
+ fltr = container_of ( fltr_base , struct bnxt_ntuple_filter , base ) ;
1063
1093
1064
- fltr_found :
1065
1094
fkeys = & fltr -> fkeys ;
1066
1095
if (fkeys -> basic .n_proto == htons (ETH_P_IP )) {
1067
1096
if (fkeys -> basic .ip_proto == IPPROTO_TCP )
0 commit comments