Commit 13dc8adb authored by Jie Wang's avatar Jie Wang Committed by Jiantao Xiao
Browse files

net: hns3: add support PF provides customized interfaces to detect port faults.

driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I97T47


CVE: NA

----------------------------------------------------------------------

When the link status of the PF network port changes from up to down,
the IMP can quickly report the link down fault cause based on the
link status. If the hardware is faulty from the beginning and the
link is not up, the IMP does not report the link down event
because the status is not changed.

Therefore, an interface is provided to detect port faults.

Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
Signed-off-by: default avatarJiantao Xiao <xiaojiantao1@h-partners.com>
parent 1fdc2de7
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@ enum hnae3_ext_opcode {
	HNAE3_EXT_OPC_GET_LANE_STATUS,
	HNAE3_EXT_OPC_DISABLE_CLOCK,
	HNAE3_EXT_OPC_SET_PFC_TIME,
	HNAE3_EXT_OPC_GET_HILINK_REF_LOS,
	HNAE3_EXT_OPC_GET_PORT_FAULT_STATUS,
};

struct hnae3_pfc_storm_para {
@@ -55,6 +57,19 @@ struct hnae3_pfc_storm_para {
	u32 recovery_period_ms;
};

enum hnae3_port_fault_type {
	HNAE3_FAULT_TYPE_CDR_FLASH,
	HNAE3_FAULT_TYPE_9545_ERR,
	HNAE3_FAULT_TYPE_CDR_CORE,
	HNAE3_FAULT_TYPE_HILINK_REF_LOS,
	HNAE3_FAULT_TYPE_INVALID
};

struct hnae3_port_fault {
	u32 fault_type;
	u32 fault_status;
};

struct hnae3_notify_pkt_param {
	u32 ipg;     /* inter-packet gap of sending, the unit is one cycle of clock */
	u16 num;     /* packet number of sending */
+2 −0
Original line number Diff line number Diff line
@@ -322,6 +322,8 @@ enum hclge_opcode_type {
	HCLGE_OPC_GET_PORT_NUM = 0x7006,
	HCLGE_OPC_DISABLE_NET_LANE = 0x7008,
	HCLGE_OPC_CFG_PAUSE_STORM_PARA = 0x7019,
	HCLGE_OPC_CFG_GET_HILINK_REF_LOS = 0x701B,
	HCLGE_OPC_GET_PORT_FAULT_STATUS = 0x7023,
	HCLGE_OPC_SFP_GET_PRESENT = 0x7101,
	HCLGE_OPC_SFP_SET_STATUS = 0x7102,
};
+22 −0
Original line number Diff line number Diff line
@@ -446,3 +446,25 @@ int nic_set_pfc_time_cfg(struct net_device *ndev, u16 time)
				  &time, sizeof(time));
}
EXPORT_SYMBOL(nic_set_pfc_time_cfg);

int nic_get_port_fault_status(struct net_device *ndev, u32 fault_type, u32 *status)
{
	int opcode = HNAE3_EXT_OPC_GET_PORT_FAULT_STATUS;
	struct hnae3_port_fault fault_para;
	int ret;

	if (!status)
		return -EINVAL;

	if (fault_type == HNAE3_FAULT_TYPE_HILINK_REF_LOS)
		opcode = HNAE3_EXT_OPC_GET_HILINK_REF_LOS;

	fault_para.fault_type = fault_type;
	ret = nic_invoke_pri_ops(ndev, opcode, &fault_para, sizeof(fault_para));
	if (ret)
		return ret;

	*status = fault_para.fault_status;
	return 0;
}
EXPORT_SYMBOL(nic_get_port_fault_status);
+6 −0
Original line number Diff line number Diff line
@@ -15,6 +15,11 @@
#define HNS3_PFC_STORM_PARA_PERIOD_MAX 2000
#define HNS3_MAX_TX_TIMEOUT 600

#define nic_get_cdr_flash_status(ndev, status)	\
	nic_get_port_fault_status(ndev, HNAE3_FAULT_TYPE_CDR_FLASH, status)
#define nic_get_hilink_ref_los(ndev, status)	\
	nic_get_port_fault_status(ndev, HNAE3_FAULT_TYPE_HILINK_REF_LOS, status)

int nic_netdev_match_check(struct net_device *netdev);
void nic_chip_recover_handler(struct net_device *ndev,
			      enum hnae3_event_type_custom event_t);
@@ -43,4 +48,5 @@ int nic_disable_net_lane(struct net_device *ndev);
int nic_get_net_lane_status(struct net_device *ndev, u32 *status);
int nic_disable_clock(struct net_device *ndev);
int nic_set_pfc_time_cfg(struct net_device *ndev, u16 time);
int nic_get_port_fault_status(struct net_device *ndev, u32 fault_type, u32 *status);
#endif
+6 −0
Original line number Diff line number Diff line
@@ -354,6 +354,12 @@ struct hclge_sfp_info_cmd {
	u8 rsv[6];
};

struct hclge_port_fault_cmd {
	__le32 fault_status;
	__le32 port_type;
	u8 rsv[16];
};

#define HCLGE_MAC_CFG_FEC_AUTO_EN_B	0
#define HCLGE_MAC_CFG_FEC_MODE_S	1
#define HCLGE_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
Loading