xref: /linux/drivers/net/ethernet/intel/ice/devlink/health.h (revision 0ad9617c78acbc71373fb341a6f75d4012b01d69)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2024, Intel Corporation. */
3 
4 #ifndef _HEALTH_H_
5 #define _HEALTH_H_
6 
7 #include <linux/types.h>
8 
9 /**
10  * DOC: health.h
11  *
12  * This header file stores everything that is needed for broadly understood
13  * devlink health mechanism for ice driver.
14  */
15 
16 struct ice_aqc_health_status_elem;
17 struct ice_pf;
18 struct ice_tx_ring;
19 struct ice_rq_event_info;
20 
21 enum ice_mdd_src {
22 	ICE_MDD_SRC_TX_PQM,
23 	ICE_MDD_SRC_TX_TCLAN,
24 	ICE_MDD_SRC_TX_TDPU,
25 	ICE_MDD_SRC_RX,
26 };
27 
28 /**
29  * struct ice_health - stores ice devlink health reporters and accompanied data
30  * @fw: devlink health reporter for FW Health Status events
31  * @mdd: devlink health reporter for MDD detection event
32  * @port: devlink health reporter for Port Health Status events
33  * @tx_hang: devlink health reporter for tx_hang event
34  * @tx_hang_buf: pre-allocated place to put info for Tx hang reporter from
35  *               non-sleeping context
36  * @tx_ring: ring that the hang occurred on
37  * @head: descriptor head
38  * @intr: interrupt register value
39  * @vsi_num: VSI owning the queue that the hang occurred on
40  * @fw_status: buffer for last received FW Status event
41  * @port_status: buffer for last received Port Status event
42  */
43 struct ice_health {
44 	struct devlink_health_reporter *fw;
45 	struct devlink_health_reporter *mdd;
46 	struct devlink_health_reporter *port;
47 	struct devlink_health_reporter *tx_hang;
48 	struct_group_tagged(ice_health_tx_hang_buf, tx_hang_buf,
49 		struct ice_tx_ring *tx_ring;
50 		u32 head;
51 		u32 intr;
52 		u16 vsi_num;
53 	);
54 	struct ice_aqc_health_status_elem fw_status;
55 	struct ice_aqc_health_status_elem port_status;
56 };
57 
58 void ice_process_health_status_event(struct ice_pf *pf,
59 				     struct ice_rq_event_info *event);
60 
61 void ice_health_init(struct ice_pf *pf);
62 void ice_health_deinit(struct ice_pf *pf);
63 void ice_health_clear(struct ice_pf *pf);
64 
65 void ice_prep_tx_hang_report(struct ice_pf *pf, struct ice_tx_ring *tx_ring,
66 			     u16 vsi_num, u32 head, u32 intr);
67 void ice_report_mdd_event(struct ice_pf *pf, enum ice_mdd_src src, u8 pf_num,
68 			  u16 vf_num, u8 event, u16 queue);
69 void ice_report_tx_hang(struct ice_pf *pf);
70 
71 #endif /* _HEALTH_H_ */
72