Skip to content

Commit 70756d0

Browse files
Ivan Vecerakuba-moo
authored andcommitted
i40e: Use DECLARE_BITMAP for flags and hw_features fields in i40e_pf
Convert flags and hw_features fields from i40e_pf from u32 to bitmaps and their usage to use bit access functions. Changes: - Convert "pf_ptr->(flags|hw_features) & FL" to "test_bit(FL, ...)" - Convert "pf_ptr->(flags|hw_features) |= FL" to "set_bit(FL, ...)" - Convert "pf_ptr->(flags|hw_features) &= ~FL" to "clear_bit(FL, ...)" - Rename flag field to bitno in i40e_priv_flags and adjust ethtool callbacks to work with flags bitmap - Rename flag names where '_ENABLED'->'_ENA' and '_DISABLED'->'_DIS' like in ice driver Signed-off-by: Ivan Vecera <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent addca91 commit 70756d0

File tree

9 files changed

+544
-515
lines changed

9 files changed

+544
-515
lines changed

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 86 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
#define I40E_MIN_VSI_ALLOC 83 /* LAN, ATR, FCOE, 64 VF */
3535
/* max 16 qps */
3636
#define i40e_default_queues_per_vmdq(pf) \
37-
(((pf)->hw_features & I40E_HW_RSS_AQ_CAPABLE) ? 4 : 1)
37+
(test_bit(I40E_HW_RSS_AQ_CAPABLE, (pf)->hw_features) ? 4 : 1)
3838
#define I40E_DEFAULT_QUEUES_PER_VF 4
3939
#define I40E_MAX_VF_QUEUES 16
4040
#define i40e_pf_get_max_q_per_tc(pf) \
41-
(((pf)->hw_features & I40E_HW_128_QP_RSS_CAPABLE) ? 128 : 64)
41+
(test_bit(I40E_HW_128_QP_RSS_CAPABLE, (pf)->hw_features) ? 128 : 64)
4242
#define I40E_FDIR_RING_COUNT 32
4343
#define I40E_MAX_AQ_BUF_SIZE 4096
4444
#define I40E_AQ_LEN 256
@@ -139,6 +139,82 @@ enum i40e_vsi_state {
139139
__I40E_VSI_STATE_SIZE__,
140140
};
141141

142+
enum i40e_pf_hw_features {
143+
I40E_HW_RSS_AQ_CAPABLE,
144+
I40E_HW_128_QP_RSS_CAPABLE,
145+
I40E_HW_ATR_EVICT_CAPABLE,
146+
I40E_HW_WB_ON_ITR_CAPABLE,
147+
I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE,
148+
I40E_HW_NO_PCI_LINK_CHECK,
149+
I40E_HW_100M_SGMII_CAPABLE,
150+
I40E_HW_NO_DCB_SUPPORT,
151+
I40E_HW_USE_SET_LLDP_MIB,
152+
I40E_HW_GENEVE_OFFLOAD_CAPABLE,
153+
I40E_HW_PTP_L4_CAPABLE,
154+
I40E_HW_WOL_MC_MAGIC_PKT_WAKE,
155+
I40E_HW_HAVE_CRT_RETIMER,
156+
I40E_HW_OUTER_UDP_CSUM_CAPABLE,
157+
I40E_HW_PHY_CONTROLS_LEDS,
158+
I40E_HW_STOP_FW_LLDP,
159+
I40E_HW_PORT_ID_VALID,
160+
I40E_HW_RESTART_AUTONEG,
161+
I40E_PF_HW_FEATURES_NBITS, /* must be last */
162+
};
163+
164+
enum i40e_pf_flags {
165+
I40E_FLAG_MSI_ENA,
166+
I40E_FLAG_MSIX_ENA,
167+
I40E_FLAG_RSS_ENA,
168+
I40E_FLAG_VMDQ_ENA,
169+
I40E_FLAG_SRIOV_ENA,
170+
I40E_FLAG_DCB_CAPABLE,
171+
I40E_FLAG_DCB_ENA,
172+
I40E_FLAG_FD_SB_ENA,
173+
I40E_FLAG_FD_ATR_ENA,
174+
I40E_FLAG_MFP_ENA,
175+
I40E_FLAG_HW_ATR_EVICT_ENA,
176+
I40E_FLAG_VEB_MODE_ENA,
177+
I40E_FLAG_VEB_STATS_ENA,
178+
I40E_FLAG_LINK_POLLING_ENA,
179+
I40E_FLAG_TRUE_PROMISC_ENA,
180+
I40E_FLAG_LEGACY_RX_ENA,
181+
I40E_FLAG_PTP_ENA,
182+
I40E_FLAG_IWARP_ENA,
183+
I40E_FLAG_LINK_DOWN_ON_CLOSE_ENA,
184+
I40E_FLAG_SOURCE_PRUNING_DIS,
185+
I40E_FLAG_TC_MQPRIO_ENA,
186+
I40E_FLAG_FD_SB_INACTIVE,
187+
I40E_FLAG_FD_SB_TO_CLOUD_FILTER,
188+
I40E_FLAG_FW_LLDP_DIS,
189+
I40E_FLAG_RS_FEC,
190+
I40E_FLAG_BASE_R_FEC,
191+
/* TOTAL_PORT_SHUTDOWN_ENA
192+
* Allows to physically disable the link on the NIC's port.
193+
* If enabled, (after link down request from the OS)
194+
* no link, traffic or led activity is possible on that port.
195+
*
196+
* If I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENA is set, the
197+
* I40E_FLAG_LINK_DOWN_ON_CLOSE_ENA must be explicitly forced
198+
* to true and cannot be disabled by system admin at that time.
199+
* The functionalities are exclusive in terms of configuration, but
200+
* they also have similar behavior (allowing to disable physical
201+
* link of the port), with following differences:
202+
* - LINK_DOWN_ON_CLOSE_ENA is configurable at host OS run-time and
203+
* is supported by whole family of 7xx Intel Ethernet Controllers
204+
* - TOTAL_PORT_SHUTDOWN_ENA may be enabled only before OS loads
205+
* (in BIOS) only if motherboard's BIOS and NIC's FW has support of it
206+
* - when LINK_DOWN_ON_CLOSE_ENABLED is used, the link is being brought
207+
* down by sending phy_type=0 to NIC's FW
208+
* - when TOTAL_PORT_SHUTDOWN_ENA is used, phy_type is not altered,
209+
* instead the link is being brought down by clearing
210+
* bit (I40E_AQ_PHY_ENABLE_LINK) in abilities field of
211+
* i40e_aq_set_phy_config structure
212+
*/
213+
I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENA,
214+
I40E_FLAG_VF_VLAN_PRUNING_ENA,
215+
I40E_PF_FLAGS_NBITS, /* must be last */
216+
};
217+
142218
enum i40e_interrupt_policy {
143219
I40E_INTERRUPT_BEST_CASE,
144220
I40E_INTERRUPT_MEDIUM,
@@ -481,77 +557,8 @@ struct i40e_pf {
481557
struct timer_list service_timer;
482558
struct work_struct service_task;
483559

484-
u32 hw_features;
485-
#define I40E_HW_RSS_AQ_CAPABLE BIT(0)
486-
#define I40E_HW_128_QP_RSS_CAPABLE BIT(1)
487-
#define I40E_HW_ATR_EVICT_CAPABLE BIT(2)
488-
#define I40E_HW_WB_ON_ITR_CAPABLE BIT(3)
489-
#define I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE BIT(4)
490-
#define I40E_HW_NO_PCI_LINK_CHECK BIT(5)
491-
#define I40E_HW_100M_SGMII_CAPABLE BIT(6)
492-
#define I40E_HW_NO_DCB_SUPPORT BIT(7)
493-
#define I40E_HW_USE_SET_LLDP_MIB BIT(8)
494-
#define I40E_HW_GENEVE_OFFLOAD_CAPABLE BIT(9)
495-
#define I40E_HW_PTP_L4_CAPABLE BIT(10)
496-
#define I40E_HW_WOL_MC_MAGIC_PKT_WAKE BIT(11)
497-
#define I40E_HW_HAVE_CRT_RETIMER BIT(13)
498-
#define I40E_HW_OUTER_UDP_CSUM_CAPABLE BIT(14)
499-
#define I40E_HW_PHY_CONTROLS_LEDS BIT(15)
500-
#define I40E_HW_STOP_FW_LLDP BIT(16)
501-
#define I40E_HW_PORT_ID_VALID BIT(17)
502-
#define I40E_HW_RESTART_AUTONEG BIT(18)
503-
504-
u32 flags;
505-
#define I40E_FLAG_MSI_ENABLED BIT(0)
506-
#define I40E_FLAG_MSIX_ENABLED BIT(1)
507-
#define I40E_FLAG_RSS_ENABLED BIT(2)
508-
#define I40E_FLAG_VMDQ_ENABLED BIT(3)
509-
#define I40E_FLAG_SRIOV_ENABLED BIT(4)
510-
#define I40E_FLAG_DCB_CAPABLE BIT(5)
511-
#define I40E_FLAG_DCB_ENABLED BIT(6)
512-
#define I40E_FLAG_FD_SB_ENABLED BIT(7)
513-
#define I40E_FLAG_FD_ATR_ENABLED BIT(8)
514-
#define I40E_FLAG_MFP_ENABLED BIT(9)
515-
#define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT(10)
516-
#define I40E_FLAG_VEB_MODE_ENABLED BIT(11)
517-
#define I40E_FLAG_VEB_STATS_ENABLED BIT(12)
518-
#define I40E_FLAG_LINK_POLLING_ENABLED BIT(13)
519-
#define I40E_FLAG_TRUE_PROMISC_SUPPORT BIT(14)
520-
#define I40E_FLAG_LEGACY_RX BIT(15)
521-
#define I40E_FLAG_PTP BIT(16)
522-
#define I40E_FLAG_IWARP_ENABLED BIT(17)
523-
#define I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED BIT(18)
524-
#define I40E_FLAG_SOURCE_PRUNING_DISABLED BIT(19)
525-
#define I40E_FLAG_TC_MQPRIO BIT(20)
526-
#define I40E_FLAG_FD_SB_INACTIVE BIT(21)
527-
#define I40E_FLAG_FD_SB_TO_CLOUD_FILTER BIT(22)
528-
#define I40E_FLAG_DISABLE_FW_LLDP BIT(23)
529-
#define I40E_FLAG_RS_FEC BIT(24)
530-
#define I40E_FLAG_BASE_R_FEC BIT(25)
531-
/* TOTAL_PORT_SHUTDOWN
532-
* Allows to physically disable the link on the NIC's port.
533-
* If enabled, (after link down request from the OS)
534-
* no link, traffic or led activity is possible on that port.
535-
*
536-
* If I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENABLED is set, the
537-
* I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED must be explicitly forced to true
538-
* and cannot be disabled by system admin at that time.
539-
* The functionalities are exclusive in terms of configuration, but they also
540-
* have similar behavior (allowing to disable physical link of the port),
541-
* with following differences:
542-
* - LINK_DOWN_ON_CLOSE_ENABLED is configurable at host OS run-time and is
543-
* supported by whole family of 7xx Intel Ethernet Controllers
544-
* - TOTAL_PORT_SHUTDOWN may be enabled only before OS loads (in BIOS)
545-
* only if motherboard's BIOS and NIC's FW has support of it
546-
* - when LINK_DOWN_ON_CLOSE_ENABLED is used, the link is being brought down
547-
* by sending phy_type=0 to NIC's FW
548-
* - when TOTAL_PORT_SHUTDOWN is used, phy_type is not altered, instead
549-
* the link is being brought down by clearing bit (I40E_AQ_PHY_ENABLE_LINK)
550-
* in abilities field of i40e_aq_set_phy_config structure
551-
*/
552-
#define I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENABLED BIT(26)
553-
#define I40E_FLAG_VF_VLAN_PRUNING BIT(27)
554-
560+
DECLARE_BITMAP(hw_features, I40E_PF_HW_FEATURES_NBITS);
561+
DECLARE_BITMAP(flags, I40E_PF_FLAGS_NBITS);
555562
struct i40e_client_instance *cinst;
556563
bool stat_offsets_loaded;
557564
struct i40e_hw_port_stats stats;
@@ -1267,7 +1274,7 @@ struct i40e_mac_filter *i40e_find_mac(struct i40e_vsi *vsi, const u8 *macaddr);
12671274
void i40e_vlan_stripping_enable(struct i40e_vsi *vsi);
12681275
static inline bool i40e_is_sw_dcb(struct i40e_pf *pf)
12691276
{
1270-
return !!(pf->flags & I40E_FLAG_DISABLE_FW_LLDP);
1277+
return test_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags);
12711278
}
12721279

12731280
#ifdef CONFIG_I40E_DCB
@@ -1301,7 +1308,7 @@ int i40e_set_partition_bw_setting(struct i40e_pf *pf);
13011308
int i40e_commit_partition_bw_setting(struct i40e_pf *pf);
13021309
void i40e_print_link_message(struct i40e_vsi *vsi, bool isup);
13031310

1304-
void i40e_set_fec_in_flags(u8 fec_cfg, u32 *flags);
1311+
void i40e_set_fec_in_flags(u8 fec_cfg, unsigned long *flags);
13051312

13061313
static inline bool i40e_enabled_xdp_vsi(struct i40e_vsi *vsi)
13071314
{
@@ -1321,13 +1328,13 @@ int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,
13211328
* i40e_is_tc_mqprio_enabled - check if TC MQPRIO is enabled on PF
13221329
* @pf: pointer to a pf.
13231330
*
1324-
* Check and return value of flag I40E_FLAG_TC_MQPRIO.
1331+
* Check and return state of flag I40E_FLAG_TC_MQPRIO.
13251332
*
1326-
* Return: I40E_FLAG_TC_MQPRIO set state.
1333+
* Return: true/false if I40E_FLAG_TC_MQPRIO is set or not
13271334
**/
1328-
static inline u32 i40e_is_tc_mqprio_enabled(struct i40e_pf *pf)
1335+
static inline bool i40e_is_tc_mqprio_enabled(struct i40e_pf *pf)
13291336
{
1330-
return pf->flags & I40E_FLAG_TC_MQPRIO;
1337+
return test_bit(I40E_FLAG_TC_MQPRIO_ENA, pf->flags);
13311338
}
13321339

13331340
/**

drivers/net/ethernet/intel/i40e/i40e_dcb_nl.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ static u8 i40e_dcbnl_getstate(struct net_device *netdev)
310310
struct i40e_pf *pf = i40e_netdev_to_pf(netdev);
311311

312312
dev_dbg(&pf->pdev->dev, "DCB state=%d\n",
313-
!!(pf->flags & I40E_FLAG_DCB_ENABLED));
314-
return !!(pf->flags & I40E_FLAG_DCB_ENABLED);
313+
test_bit(I40E_FLAG_DCB_ENA, pf->flags) ? 1 : 0);
314+
return test_bit(I40E_FLAG_DCB_ENA, pf->flags) ? 1 : 0;
315315
}
316316

317317
/**
@@ -331,19 +331,19 @@ static u8 i40e_dcbnl_setstate(struct net_device *netdev, u8 state)
331331
return ret;
332332

333333
dev_dbg(&pf->pdev->dev, "new state=%d current state=%d\n",
334-
state, (pf->flags & I40E_FLAG_DCB_ENABLED) ? 1 : 0);
334+
state, test_bit(I40E_FLAG_DCB_ENA, pf->flags) ? 1 : 0);
335335
/* Nothing to do */
336-
if (!state == !(pf->flags & I40E_FLAG_DCB_ENABLED))
336+
if (!state == !test_bit(I40E_FLAG_DCB_ENA, pf->flags))
337337
return ret;
338338

339339
if (i40e_is_sw_dcb(pf)) {
340340
if (state) {
341-
pf->flags |= I40E_FLAG_DCB_ENABLED;
341+
set_bit(I40E_FLAG_DCB_ENA, pf->flags);
342342
memcpy(&pf->hw.desired_dcbx_config,
343343
&pf->hw.local_dcbx_config,
344344
sizeof(struct i40e_dcbx_config));
345345
} else {
346-
pf->flags &= ~I40E_FLAG_DCB_ENABLED;
346+
clear_bit(I40E_FLAG_DCB_ENA, pf->flags);
347347
}
348348
} else {
349349
/* Cannot directly manipulate FW LLDP Agent */
@@ -653,7 +653,7 @@ static u8 i40e_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
653653
{
654654
struct i40e_pf *pf = i40e_netdev_to_pf(netdev);
655655

656-
if (!(pf->flags & I40E_FLAG_DCB_CAPABLE))
656+
if (!test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags))
657657
return I40E_DCBNL_STATUS_ERROR;
658658

659659
switch (capid) {
@@ -693,7 +693,7 @@ static int i40e_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num)
693693
{
694694
struct i40e_pf *pf = i40e_netdev_to_pf(netdev);
695695

696-
if (!(pf->flags & I40E_FLAG_DCB_CAPABLE))
696+
if (!test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags))
697697
return -EINVAL;
698698

699699
*num = I40E_MAX_TRAFFIC_CLASS;
@@ -891,11 +891,11 @@ void i40e_dcbnl_set_all(struct i40e_vsi *vsi)
891891
return;
892892

893893
/* DCB not enabled */
894-
if (!(pf->flags & I40E_FLAG_DCB_ENABLED))
894+
if (!test_bit(I40E_FLAG_DCB_ENA, pf->flags))
895895
return;
896896

897897
/* MFP mode but not an iSCSI PF so return */
898-
if ((pf->flags & I40E_FLAG_MFP_ENABLED) && !(hw->func_caps.iscsi))
898+
if (test_bit(I40E_FLAG_MFP_ENA, pf->flags) && !(hw->func_caps.iscsi))
899899
return;
900900

901901
dcbxcfg = &hw->local_dcbx_config;
@@ -1002,7 +1002,7 @@ void i40e_dcbnl_flush_apps(struct i40e_pf *pf,
10021002
int i;
10031003

10041004
/* MFP mode but not an iSCSI PF so return */
1005-
if ((pf->flags & I40E_FLAG_MFP_ENABLED) && !(pf->hw.func_caps.iscsi))
1005+
if (test_bit(I40E_FLAG_MFP_ENA, pf->flags) && !(pf->hw.func_caps.iscsi))
10061006
return;
10071007

10081008
for (i = 0; i < old_cfg->numapps; i++) {
@@ -1025,7 +1025,7 @@ void i40e_dcbnl_setup(struct i40e_vsi *vsi)
10251025
struct i40e_pf *pf = i40e_netdev_to_pf(dev);
10261026

10271027
/* Not DCB capable */
1028-
if (!(pf->flags & I40E_FLAG_DCB_CAPABLE))
1028+
if (!test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags))
10291029
return;
10301030

10311031
dev->dcbnl_ops = &dcbnl_ops;

drivers/net/ethernet/intel/i40e/i40e_debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,8 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
820820
/* By default we are in VEPA mode, if this is the first VF/VMDq
821821
* VSI to be added switch to VEB mode.
822822
*/
823-
if (!(pf->flags & I40E_FLAG_VEB_MODE_ENABLED)) {
824-
pf->flags |= I40E_FLAG_VEB_MODE_ENABLED;
823+
if (!test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags)) {
824+
set_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags);
825825
i40e_do_reset_safe(pf, I40E_PF_RESET_FLAG);
826826
}
827827

0 commit comments

Comments
 (0)