@@ -207,22 +207,37 @@ static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = {
207
207
208
208
#define I40E_TEST_LEN (sizeof(i40e_gstrings_test) / ETH_GSTRING_LEN)
209
209
210
- static const char i40e_priv_flags_strings [][ETH_GSTRING_LEN ] = {
211
- "MFP" ,
212
- "LinkPolling" ,
213
- "flow-director-atr" ,
214
- "veb-stats" ,
215
- "hw-atr-eviction" ,
210
+ struct i40e_priv_flags {
211
+ char flag_string [ETH_GSTRING_LEN ];
212
+ u64 flag ;
213
+ bool read_only ;
216
214
};
217
215
218
- #define I40E_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_priv_flags_strings)
216
+ #define I40E_PRIV_FLAG (_name , _flag , _read_only ) { \
217
+ .flag_string = _name, \
218
+ .flag = _flag, \
219
+ .read_only = _read_only, \
220
+ }
221
+
222
+ static const struct i40e_priv_flags i40e_gstrings_priv_flags [] = {
223
+ /* NOTE: MFP setting cannot be changed */
224
+ I40E_PRIV_FLAG ("MFP" , I40E_FLAG_MFP_ENABLED , 1 ),
225
+ I40E_PRIV_FLAG ("LinkPolling" , I40E_FLAG_LINK_POLLING_ENABLED , 0 ),
226
+ I40E_PRIV_FLAG ("flow-director-atr" , I40E_FLAG_FD_ATR_ENABLED , 0 ),
227
+ I40E_PRIV_FLAG ("veb-stats" , I40E_FLAG_VEB_STATS_ENABLED , 0 ),
228
+ I40E_PRIV_FLAG ("hw-atr-eviction" , I40E_FLAG_HW_ATR_EVICT_CAPABLE , 0 ),
229
+ I40E_PRIV_FLAG ("legacy-rx" , I40E_FLAG_LEGACY_RX , 0 ),
230
+ };
231
+
232
+ #define I40E_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_gstrings_priv_flags)
219
233
220
234
/* Private flags with a global effect, restricted to PF 0 */
221
- static const char i40e_gl_priv_flags_strings [][ETH_GSTRING_LEN ] = {
222
- "vf-true-promisc-support" ,
235
+ static const struct i40e_priv_flags i40e_gl_gstrings_priv_flags [] = {
236
+ I40E_PRIV_FLAG ("vf-true-promisc-support" ,
237
+ I40E_FLAG_TRUE_PROMISC_SUPPORT , 0 ),
223
238
};
224
239
225
- #define I40E_GL_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_gl_priv_flags_strings )
240
+ #define I40E_GL_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_gl_gstrings_priv_flags )
226
241
227
242
/**
228
243
* i40e_partition_setting_complaint - generic complaint for MFP restriction
@@ -1660,12 +1675,18 @@ static void i40e_get_strings(struct net_device *netdev, u32 stringset,
1660
1675
/* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */
1661
1676
break ;
1662
1677
case ETH_SS_PRIV_FLAGS :
1663
- memcpy (data , i40e_priv_flags_strings ,
1664
- I40E_PRIV_FLAGS_STR_LEN * ETH_GSTRING_LEN );
1665
- data += I40E_PRIV_FLAGS_STR_LEN * ETH_GSTRING_LEN ;
1666
- if (pf -> hw .pf_id == 0 )
1667
- memcpy (data , i40e_gl_priv_flags_strings ,
1668
- I40E_GL_PRIV_FLAGS_STR_LEN * ETH_GSTRING_LEN );
1678
+ for (i = 0 ; i < I40E_PRIV_FLAGS_STR_LEN ; i ++ ) {
1679
+ snprintf (p , ETH_GSTRING_LEN , "%s" ,
1680
+ i40e_gstrings_priv_flags [i ].flag_string );
1681
+ p += ETH_GSTRING_LEN ;
1682
+ }
1683
+ if (pf -> hw .pf_id != 0 )
1684
+ break ;
1685
+ for (i = 0 ; i < I40E_GL_PRIV_FLAGS_STR_LEN ; i ++ ) {
1686
+ snprintf (p , ETH_GSTRING_LEN , "%s" ,
1687
+ i40e_gl_gstrings_priv_flags [i ].flag_string );
1688
+ p += ETH_GSTRING_LEN ;
1689
+ }
1669
1690
break ;
1670
1691
default :
1671
1692
break ;
@@ -3952,7 +3973,7 @@ static int i40e_set_rxfh(struct net_device *netdev, const u32 *indir,
3952
3973
* @dev: network interface device structure
3953
3974
*
3954
3975
* The get string set count and the string set should be matched for each
3955
- * flag returned. Add new strings for each flag to the i40e_priv_flags_strings
3976
+ * flag returned. Add new strings for each flag to the i40e_gstrings_priv_flags
3956
3977
* array.
3957
3978
*
3958
3979
* Returns a u32 bitmap of flags.
@@ -3962,19 +3983,27 @@ static u32 i40e_get_priv_flags(struct net_device *dev)
3962
3983
struct i40e_netdev_priv * np = netdev_priv (dev );
3963
3984
struct i40e_vsi * vsi = np -> vsi ;
3964
3985
struct i40e_pf * pf = vsi -> back ;
3965
- u32 ret_flags = 0 ;
3966
-
3967
- ret_flags |= pf -> flags & I40E_FLAG_LINK_POLLING_ENABLED ?
3968
- I40E_PRIV_FLAGS_LINKPOLL_FLAG : 0 ;
3969
- ret_flags |= pf -> flags & I40E_FLAG_FD_ATR_ENABLED ?
3970
- I40E_PRIV_FLAGS_FD_ATR : 0 ;
3971
- ret_flags |= pf -> flags & I40E_FLAG_VEB_STATS_ENABLED ?
3972
- I40E_PRIV_FLAGS_VEB_STATS : 0 ;
3973
- ret_flags |= pf -> hw_disabled_flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE ?
3974
- 0 : I40E_PRIV_FLAGS_HW_ATR_EVICT ;
3975
- if (pf -> hw .pf_id == 0 ) {
3976
- ret_flags |= pf -> flags & I40E_FLAG_TRUE_PROMISC_SUPPORT ?
3977
- I40E_PRIV_FLAGS_TRUE_PROMISC_SUPPORT : 0 ;
3986
+ u32 i , j , ret_flags = 0 ;
3987
+
3988
+ for (i = 0 ; i < I40E_PRIV_FLAGS_STR_LEN ; i ++ ) {
3989
+ const struct i40e_priv_flags * priv_flags ;
3990
+
3991
+ priv_flags = & i40e_gstrings_priv_flags [i ];
3992
+
3993
+ if (priv_flags -> flag & pf -> flags )
3994
+ ret_flags |= BIT (i );
3995
+ }
3996
+
3997
+ if (pf -> hw .pf_id != 0 )
3998
+ return ret_flags ;
3999
+
4000
+ for (j = 0 ; j < I40E_GL_PRIV_FLAGS_STR_LEN ; j ++ ) {
4001
+ const struct i40e_priv_flags * priv_flags ;
4002
+
4003
+ priv_flags = & i40e_gl_gstrings_priv_flags [j ];
4004
+
4005
+ if (priv_flags -> flag & pf -> flags )
4006
+ ret_flags |= BIT (i + j );
3978
4007
}
3979
4008
3980
4009
return ret_flags ;
@@ -3990,54 +4019,66 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
3990
4019
struct i40e_netdev_priv * np = netdev_priv (dev );
3991
4020
struct i40e_vsi * vsi = np -> vsi ;
3992
4021
struct i40e_pf * pf = vsi -> back ;
3993
- u16 sw_flags = 0 , valid_flags = 0 ;
3994
- bool reset_required = false;
3995
- bool promisc_change = false;
3996
- int ret ;
4022
+ u64 changed_flags ;
4023
+ u32 i , j ;
3997
4024
3998
- /* NOTE: MFP is not settable */
4025
+ changed_flags = pf -> flags ;
3999
4026
4000
- if (flags & I40E_PRIV_FLAGS_LINKPOLL_FLAG )
4001
- pf -> flags |= I40E_FLAG_LINK_POLLING_ENABLED ;
4002
- else
4003
- pf -> flags &= ~I40E_FLAG_LINK_POLLING_ENABLED ;
4027
+ for (i = 0 ; i < I40E_PRIV_FLAGS_STR_LEN ; i ++ ) {
4028
+ const struct i40e_priv_flags * priv_flags ;
4004
4029
4005
- /* allow the user to control the state of the Flow
4006
- * Director ATR (Application Targeted Routing) feature
4007
- * of the driver
4008
- */
4009
- if (flags & I40E_PRIV_FLAGS_FD_ATR ) {
4010
- pf -> flags |= I40E_FLAG_FD_ATR_ENABLED ;
4011
- } else {
4012
- pf -> flags &= ~I40E_FLAG_FD_ATR_ENABLED ;
4013
- pf -> hw_disabled_flags |= I40E_FLAG_FD_ATR_ENABLED ;
4030
+ priv_flags = & i40e_gstrings_priv_flags [i ];
4014
4031
4015
- /* flush current ATR settings */
4016
- set_bit (__I40E_FD_FLUSH_REQUESTED , & pf -> state );
4032
+ if (priv_flags -> read_only )
4033
+ continue ;
4034
+
4035
+ if (flags & BIT (i ))
4036
+ pf -> flags |= priv_flags -> flag ;
4037
+ else
4038
+ pf -> flags &= ~(priv_flags -> flag );
4017
4039
}
4018
4040
4019
- if ((flags & I40E_PRIV_FLAGS_VEB_STATS ) &&
4020
- !(pf -> flags & I40E_FLAG_VEB_STATS_ENABLED )) {
4021
- pf -> flags |= I40E_FLAG_VEB_STATS_ENABLED ;
4022
- reset_required = true;
4023
- } else if (!(flags & I40E_PRIV_FLAGS_VEB_STATS ) &&
4024
- (pf -> flags & I40E_FLAG_VEB_STATS_ENABLED )) {
4025
- pf -> flags &= ~I40E_FLAG_VEB_STATS_ENABLED ;
4026
- reset_required = true;
4041
+ if (pf -> hw .pf_id != 0 )
4042
+ goto flags_complete ;
4043
+
4044
+ for (j = 0 ; j < I40E_GL_PRIV_FLAGS_STR_LEN ; j ++ ) {
4045
+ const struct i40e_priv_flags * priv_flags ;
4046
+
4047
+ priv_flags = & i40e_gl_gstrings_priv_flags [j ];
4048
+
4049
+ if (priv_flags -> read_only )
4050
+ continue ;
4051
+
4052
+ if (flags & BIT (i + j ))
4053
+ pf -> flags |= priv_flags -> flag ;
4054
+ else
4055
+ pf -> flags &= ~(priv_flags -> flag );
4027
4056
}
4028
4057
4029
- if (pf -> hw .pf_id == 0 ) {
4030
- if ((flags & I40E_PRIV_FLAGS_TRUE_PROMISC_SUPPORT ) &&
4031
- !(pf -> flags & I40E_FLAG_TRUE_PROMISC_SUPPORT )) {
4032
- pf -> flags |= I40E_FLAG_TRUE_PROMISC_SUPPORT ;
4033
- promisc_change = true;
4034
- } else if (!(flags & I40E_PRIV_FLAGS_TRUE_PROMISC_SUPPORT ) &&
4035
- (pf -> flags & I40E_FLAG_TRUE_PROMISC_SUPPORT )) {
4036
- pf -> flags &= ~I40E_FLAG_TRUE_PROMISC_SUPPORT ;
4037
- promisc_change = true;
4038
- }
4058
+ flags_complete :
4059
+ /* check for flags that changed */
4060
+ changed_flags ^= pf -> flags ;
4061
+
4062
+ /* Process any additional changes needed as a result of flag changes.
4063
+ * The changed_flags value reflects the list of bits that were
4064
+ * changed in the code above.
4065
+ */
4066
+
4067
+ /* Flush current ATR settings if ATR was disabled */
4068
+ if ((changed_flags & I40E_FLAG_FD_ATR_ENABLED ) &&
4069
+ !(pf -> flags & I40E_FLAG_FD_ATR_ENABLED )) {
4070
+ pf -> hw_disabled_flags |= I40E_FLAG_FD_ATR_ENABLED ;
4071
+ set_bit (__I40E_FD_FLUSH_REQUESTED , & pf -> state );
4039
4072
}
4040
- if (promisc_change ) {
4073
+
4074
+ /* Only allow ATR evict on hardware that is capable of handling it */
4075
+ if (pf -> hw_disabled_flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE )
4076
+ pf -> flags &= ~I40E_FLAG_HW_ATR_EVICT_CAPABLE ;
4077
+
4078
+ if (changed_flags & I40E_FLAG_TRUE_PROMISC_SUPPORT ) {
4079
+ u16 sw_flags = 0 , valid_flags = 0 ;
4080
+ int ret ;
4081
+
4041
4082
if (!(pf -> flags & I40E_FLAG_TRUE_PROMISC_SUPPORT ))
4042
4083
sw_flags = I40E_AQ_SET_SWITCH_CFG_PROMISC ;
4043
4084
valid_flags = I40E_AQ_SET_SWITCH_CFG_PROMISC ;
@@ -4053,14 +4094,11 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
4053
4094
}
4054
4095
}
4055
4096
4056
- if ((flags & I40E_PRIV_FLAGS_HW_ATR_EVICT ) &&
4057
- (pf -> flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE ))
4058
- pf -> hw_disabled_flags &= ~I40E_FLAG_HW_ATR_EVICT_CAPABLE ;
4059
- else
4060
- pf -> hw_disabled_flags |= I40E_FLAG_HW_ATR_EVICT_CAPABLE ;
4061
-
4062
- /* if needed, issue reset to cause things to take effect */
4063
- if (reset_required )
4097
+ /* Issue reset to cause things to take effect, as additional bits
4098
+ * are added we will need to create a mask of bits requiring reset
4099
+ */
4100
+ if ((changed_flags & I40E_FLAG_VEB_STATS_ENABLED ) ||
4101
+ ((changed_flags & I40E_FLAG_LEGACY_RX ) && netif_running (dev )))
4064
4102
i40e_do_reset (pf , BIT (__I40E_PF_RESET_REQUESTED ));
4065
4103
4066
4104
return 0 ;
0 commit comments