Skip to content

Commit 0b28b70

Browse files
refactormanJeff Kirsher
authored andcommitted
ice: Support link events, reset and rebuild
Link events are posted to a PF's admin receive queue (ARQ). This patch adds the ability to detect and process link events. This patch also adds the ability to process resets. The driver can process the following resets: 1) EMP Reset (EMPR) 2) Global Reset (GLOBR) 3) Core Reset (CORER) 4) Physical Function Reset (PFR) EMPR is the largest level of reset that the driver can handle. An EMPR resets the manageability block and also the data path, including PHY and link for all the PFs. The affected PFs are notified of this event through a miscellaneous interrupt. GLOBR is a subset of EMPR. It does everything EMPR does except that it doesn't reset the manageability block. CORER is a subset of GLOBR. It does everything GLOBR does but doesn't reset PHY and link. PFR is a subset of CORER and affects only the given physical function. In other words, PFR can be thought of as a CORER for a single PF. Since only the issuing PF is affected, a PFR doesn't result in the miscellaneous interrupt being triggered. All the resets have the following in common: 1) Tx/Rx is halted and all queues are stopped. 2) All the VSIs and filters programmed for the PF are lost and have to be reprogrammed. 3) Control queue interfaces are reset and have to be reprogrammed. In the rebuild flow, control queues are reinitialized, VSIs are reallocated and filters are restored. Signed-off-by: Anirudh Venkataramanan <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 5513b92 commit 0b28b70

File tree

7 files changed

+681
-6
lines changed

7 files changed

+681
-6
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ extern const char ice_drv_ver[];
7878
#define ICE_RX_DESC(R, i) (&(((union ice_32b_rx_flex_desc *)((R)->desc))[i]))
7979
#define ICE_TX_CTX_DESC(R, i) (&(((struct ice_tx_ctx_desc *)((R)->desc))[i]))
8080

81+
/* Macro for each VSI in a PF */
82+
#define ice_for_each_vsi(pf, i) \
83+
for ((i) = 0; (i) < (pf)->num_alloc_vsi; (i)++)
84+
85+
/* Macros for each tx/rx ring in a VSI */
8186
#define ice_for_each_txq(vsi, i) \
8287
for ((i) = 0; (i) < (vsi)->num_txq; (i)++)
8388

@@ -109,7 +114,16 @@ struct ice_sw {
109114

110115
enum ice_state {
111116
__ICE_DOWN,
117+
__ICE_NEEDS_RESTART,
118+
__ICE_RESET_RECOVERY_PENDING, /* set by driver when reset starts */
112119
__ICE_PFR_REQ, /* set by driver and peers */
120+
__ICE_CORER_REQ, /* set by driver and peers */
121+
__ICE_GLOBR_REQ, /* set by driver and peers */
122+
__ICE_CORER_RECV, /* set by OICR handler */
123+
__ICE_GLOBR_RECV, /* set by OICR handler */
124+
__ICE_EMPR_RECV, /* set by OICR handler */
125+
__ICE_SUSPENDED, /* set on module remove path */
126+
__ICE_RESET_FAILED, /* set by reset/rebuild */
113127
__ICE_ADMINQ_EVENT_PENDING,
114128
__ICE_CFG_BUSY,
115129
__ICE_SERVICE_SCHED,
@@ -226,6 +240,11 @@ struct ice_pf {
226240
u16 q_left_rx; /* remaining num rx queues left unclaimed */
227241
u16 next_vsi; /* Next free slot in pf->vsi[] - 0-based! */
228242
u16 num_alloc_vsi;
243+
u16 corer_count; /* Core reset count */
244+
u16 globr_count; /* Global reset count */
245+
u16 empr_count; /* EMP reset count */
246+
u16 pfr_count; /* PF reset count */
247+
229248
struct ice_hw_port_stats stats;
230249
struct ice_hw_port_stats stats_prev;
231250
struct ice_hw hw;

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,23 @@ struct ice_aqc_get_link_status_data {
10091009
__le64 reserved4;
10101010
};
10111011

1012+
/* Set event mask command (direct 0x0613) */
1013+
struct ice_aqc_set_event_mask {
1014+
u8 lport_num;
1015+
u8 reserved[7];
1016+
__le16 event_mask;
1017+
#define ICE_AQ_LINK_EVENT_UPDOWN BIT(1)
1018+
#define ICE_AQ_LINK_EVENT_MEDIA_NA BIT(2)
1019+
#define ICE_AQ_LINK_EVENT_LINK_FAULT BIT(3)
1020+
#define ICE_AQ_LINK_EVENT_PHY_TEMP_ALARM BIT(4)
1021+
#define ICE_AQ_LINK_EVENT_EXCESSIVE_ERRORS BIT(5)
1022+
#define ICE_AQ_LINK_EVENT_SIGNAL_DETECT BIT(6)
1023+
#define ICE_AQ_LINK_EVENT_AN_COMPLETED BIT(7)
1024+
#define ICE_AQ_LINK_EVENT_MODULE_QUAL_FAIL BIT(8)
1025+
#define ICE_AQ_LINK_EVENT_PORT_TX_SUSPENDED BIT(9)
1026+
u8 reserved1[6];
1027+
};
1028+
10121029
/* NVM Read command (indirect 0x0701)
10131030
* NVM Erase commands (direct 0x0702)
10141031
* NVM Update commands (indirect 0x0703)
@@ -1215,6 +1232,7 @@ struct ice_aq_desc {
12151232
struct ice_aqc_dis_txqs dis_txqs;
12161233
struct ice_aqc_add_get_update_free_vsi vsi_cmd;
12171234
struct ice_aqc_alloc_free_res_cmd sw_res_ctrl;
1235+
struct ice_aqc_set_event_mask set_event_mask;
12181236
struct ice_aqc_get_link_status get_link_status;
12191237
} params;
12201238
};
@@ -1294,6 +1312,7 @@ enum ice_adminq_opc {
12941312
ice_aqc_opc_set_phy_cfg = 0x0601,
12951313
ice_aqc_opc_restart_an = 0x0605,
12961314
ice_aqc_opc_get_link_status = 0x0607,
1315+
ice_aqc_opc_set_event_mask = 0x0613,
12971316

12981317
/* NVM commands */
12991318
ice_aqc_opc_nvm_read = 0x0701,

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,39 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool atomic_restart)
14271427
return status;
14281428
}
14291429

1430+
/**
1431+
* ice_get_link_status - get status of the HW network link
1432+
* @pi: port information structure
1433+
* @link_up: pointer to bool (true/false = linkup/linkdown)
1434+
*
1435+
* Variable link_up is true if link is up, false if link is down.
1436+
* The variable link_up is invalid if status is non zero. As a
1437+
* result of this call, link status reporting becomes enabled
1438+
*/
1439+
enum ice_status ice_get_link_status(struct ice_port_info *pi, bool *link_up)
1440+
{
1441+
struct ice_phy_info *phy_info;
1442+
enum ice_status status = 0;
1443+
1444+
if (!pi)
1445+
return ICE_ERR_PARAM;
1446+
1447+
phy_info = &pi->phy;
1448+
1449+
if (phy_info->get_link_info) {
1450+
status = ice_update_link_info(pi);
1451+
1452+
if (status)
1453+
ice_debug(pi->hw, ICE_DBG_LINK,
1454+
"get link status error, status = %d\n",
1455+
status);
1456+
}
1457+
1458+
*link_up = phy_info->link_info.link_info & ICE_AQ_LINK_UP;
1459+
1460+
return status;
1461+
}
1462+
14301463
/**
14311464
* ice_aq_set_link_restart_an
14321465
* @pi: pointer to the port information structure
@@ -1456,6 +1489,33 @@ ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
14561489
return ice_aq_send_cmd(pi->hw, &desc, NULL, 0, cd);
14571490
}
14581491

1492+
/**
1493+
* ice_aq_set_event_mask
1494+
* @hw: pointer to the hw struct
1495+
* @port_num: port number of the physical function
1496+
* @mask: event mask to be set
1497+
* @cd: pointer to command details structure or NULL
1498+
*
1499+
* Set event mask (0x0613)
1500+
*/
1501+
enum ice_status
1502+
ice_aq_set_event_mask(struct ice_hw *hw, u8 port_num, u16 mask,
1503+
struct ice_sq_cd *cd)
1504+
{
1505+
struct ice_aqc_set_event_mask *cmd;
1506+
struct ice_aq_desc desc;
1507+
1508+
cmd = &desc.params.set_event_mask;
1509+
1510+
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_set_event_mask);
1511+
1512+
cmd->lport_num = port_num;
1513+
1514+
cmd->event_mask = cpu_to_le16(mask);
1515+
1516+
return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
1517+
}
1518+
14591519
/**
14601520
* __ice_aq_get_set_rss_lut
14611521
* @hw: pointer to the hardware structure

drivers/net/ethernet/intel/ice/ice_common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ enum ice_status
2020
ice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq,
2121
struct ice_rq_event_info *e, u16 *pending);
2222
enum ice_status
23+
ice_get_link_status(struct ice_port_info *pi, bool *link_up);
24+
enum ice_status
2325
ice_acquire_res(struct ice_hw *hw, enum ice_aq_res_ids res,
2426
enum ice_aq_res_access_type access);
2527
void ice_release_res(struct ice_hw *hw, enum ice_aq_res_ids res);
@@ -66,6 +68,9 @@ enum ice_status
6668
ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
6769
struct ice_link_status *link, struct ice_sq_cd *cd);
6870
enum ice_status
71+
ice_aq_set_event_mask(struct ice_hw *hw, u8 port_num, u16 mask,
72+
struct ice_sq_cd *cd);
73+
enum ice_status
6974
ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
7075
u32 *q_teids, struct ice_sq_cd *cmd_details);
7176
enum ice_status

drivers/net/ethernet/intel/ice/ice_hw_autogen.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
#define GLGEN_RSTCTL 0x000B8180
8686
#define GLGEN_RSTCTL_GRSTDEL_S 0
8787
#define GLGEN_RSTCTL_GRSTDEL_M ICE_M(0x3F, GLGEN_RSTCTL_GRSTDEL_S)
88+
#define GLGEN_RSTAT_RESET_TYPE_S 2
89+
#define GLGEN_RSTAT_RESET_TYPE_M ICE_M(0x3, GLGEN_RSTAT_RESET_TYPE_S)
8890
#define GLGEN_RTRIG 0x000B8190
8991
#define GLGEN_RTRIG_CORER_S 0
9092
#define GLGEN_RTRIG_CORER_M BIT(GLGEN_RTRIG_CORER_S)

0 commit comments

Comments
 (0)