101 lines
3.2 KiB
Diff
101 lines
3.2 KiB
Diff
From a61a2bd156aa74746068bcf8ac1cb7863f04527b Mon Sep 17 00:00:00 2001
|
|
From: Tian Jiang <jiangtian6@h-partners.com>
|
|
Date: Mon, 17 Apr 2023 14:31:28 +0800
|
|
Subject: [PATCH 199/283] net: hns3: add support query the presence of optical
|
|
module
|
|
|
|
driver inclusion
|
|
category: feature
|
|
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8EN3D
|
|
CVE: NA
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
The patch provides an interface to check whether the optical module
|
|
is inserted.
|
|
|
|
Signed-off-by: Tian Jiang <jiangtian6@h-partners.com>
|
|
Signed-off-by: shaojijie <shaojijie@huawei.com>
|
|
Signed-off-by: Jiantao Xiao <xiaojiantao1@h-partners.com>
|
|
Signed-off-by: Xiaodong Li <lixiaodong67@huawei.com>
|
|
|
|
Conflicts:
|
|
drivers/net/ethernet/hisilicon/hns3/hnae3_ext.h
|
|
drivers/net/ethernet/hisilicon/hns3/hns3_ext.c
|
|
drivers/net/ethernet/hisilicon/hns3/hns3_ext.h
|
|
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.c
|
|
---
|
|
.../hisilicon/hns3/hns3pf/hclge_ext.c | 24 +++++++++++++++++++
|
|
.../hisilicon/hns3/hns3pf/hclge_ext.h | 6 +++++
|
|
2 files changed, 30 insertions(+)
|
|
|
|
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.c
|
|
index 801737b11732..f63f558327f1 100644
|
|
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.c
|
|
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.c
|
|
@@ -428,6 +428,29 @@ static int hclge_set_pause_trans_time(struct hclge_dev *hdev, void *data,
|
|
}
|
|
|
|
hdev->tm_info.pause_time = pause_trans_time;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int hclge_get_sfp_present(struct hclge_dev *hdev, void *data,
|
|
+ size_t length)
|
|
+{
|
|
+ struct hclge_sfp_present_cmd *resp;
|
|
+ struct hclge_desc desc;
|
|
+ int ret;
|
|
+
|
|
+ if (length != sizeof(u32))
|
|
+ return -EINVAL;
|
|
+
|
|
+ ret = hclge_get_info_from_cmd(hdev, &desc, 1,
|
|
+ HCLGE_OPC_SFP_GET_PRESENT);
|
|
+ if (ret) {
|
|
+ dev_err(&hdev->pdev->dev, "failed to get sfp present, ret = %d\n", ret);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ resp = (struct hclge_sfp_present_cmd *)desc.data;
|
|
+ *(u32 *)data = le32_to_cpu(resp->sfp_present);
|
|
return 0;
|
|
}
|
|
|
|
@@ -591,6 +614,7 @@ static const hclge_priv_ops_fn hclge_ext_func_arr[] = {
|
|
[HNAE3_EXT_OPC_GET_PORT_EXT_NUM_INFO] = hclge_get_extend_port_num_info,
|
|
[HNAE3_EXT_OPC_GET_PORT_NUM] = hclge_get_port_num,
|
|
[HNAE3_EXT_OPC_SET_PFC_TIME] = hclge_set_pause_trans_time,
|
|
+ [HNAE3_EXT_OPC_GET_PRESENT] = hclge_get_sfp_present,
|
|
};
|
|
|
|
int hclge_ext_ops_handle(struct hnae3_handle *handle, int opcode,
|
|
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.h
|
|
index f840129572c8..ae6f0afef1f1 100644
|
|
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.h
|
|
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.h
|
|
@@ -73,6 +73,11 @@ struct hclge_torus_cfg_cmd {
|
|
__le32 torus_en;
|
|
};
|
|
|
|
+struct hclge_sfp_present_cmd {
|
|
+ __le32 sfp_present;
|
|
+ __le32 rsv[5];
|
|
+};
|
|
+
|
|
enum hclge_ext_opcode_type {
|
|
HCLGE_OPC_CONFIG_SWITCH_PARAM = 0x1033,
|
|
HCLGE_OPC_CONFIG_VLAN_FILTER = 0x1100,
|
|
@@ -82,6 +87,7 @@ enum hclge_ext_opcode_type {
|
|
HCLGE_OPC_GET_CHIP_NUM = 0x7005,
|
|
HCLGE_OPC_GET_PORT_NUM = 0x7006,
|
|
HCLGE_OPC_CFG_PAUSE_STORM_PARA = 0x7019,
|
|
+ HCLGE_OPC_SFP_GET_PRESENT = 0x7101,
|
|
};
|
|
|
|
struct hclge_reset_fail_type_map {
|
|
--
|
|
2.34.1
|
|
|