提交 d28d7413 编写于 作者: W wangpeiyang 提交者: Jiantao Xiao

net: hns3: add support set mac state

driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I6YE0O
CVE: NA

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

The patch provides a customized interface to modify the MAC mode.
Signed-off-by: Nwangpeiyang <wangpeiyang1@huawei.com>
Signed-off-by: Nshaojijie <shaojijie@huawei.com>
Signed-off-by: NJiantao Xiao <xiaojiantao1@h-partners.com>
上级 ad7b67e7
...@@ -47,6 +47,7 @@ enum hnae3_ext_opcode { ...@@ -47,6 +47,7 @@ enum hnae3_ext_opcode {
HNAE3_EXT_OPC_GET_HILINK_REF_LOS, HNAE3_EXT_OPC_GET_HILINK_REF_LOS,
HNAE3_EXT_OPC_GET_PORT_FAULT_STATUS, HNAE3_EXT_OPC_GET_PORT_FAULT_STATUS,
HNAE3_EXT_OPC_GET_PORT_TYPE, HNAE3_EXT_OPC_GET_PORT_TYPE,
HNAE3_EXT_OPC_SET_MAC_STATE,
}; };
struct hnae3_pfc_storm_para { struct hnae3_pfc_storm_para {
......
...@@ -468,3 +468,10 @@ int nic_get_port_wire_type(struct net_device *ndev, u32 *wire_type) ...@@ -468,3 +468,10 @@ int nic_get_port_wire_type(struct net_device *ndev, u32 *wire_type)
wire_type, sizeof(*wire_type)); wire_type, sizeof(*wire_type));
} }
EXPORT_SYMBOL(nic_get_port_wire_type); EXPORT_SYMBOL(nic_get_port_wire_type);
int nic_set_mac_state(struct net_device *ndev, int enable)
{
return nic_invoke_pri_ops(ndev, HNAE3_EXT_OPC_SET_MAC_STATE,
&enable, sizeof(enable));
}
EXPORT_SYMBOL(nic_set_mac_state);
...@@ -49,4 +49,5 @@ int nic_disable_clock(struct net_device *ndev); ...@@ -49,4 +49,5 @@ int nic_disable_clock(struct net_device *ndev);
int nic_set_pfc_time_cfg(struct net_device *ndev, u16 time); 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); int nic_get_port_fault_status(struct net_device *ndev, u32 fault_type, u32 *status);
int nic_get_port_wire_type(struct net_device *ndev, u32 *wire_type); int nic_get_port_wire_type(struct net_device *ndev, u32 *wire_type);
int nic_set_mac_state(struct net_device *ndev, int enable);
#endif #endif
...@@ -645,6 +645,37 @@ static int hclge_get_port_wire_type(struct hclge_dev *hdev, void *data, ...@@ -645,6 +645,37 @@ static int hclge_get_port_wire_type(struct hclge_dev *hdev, void *data,
return 0; return 0;
} }
static void hclge_set_phy_state(struct hclge_dev *hdev, bool enable)
{
struct phy_device *phydev = hdev->hw.mac.phydev;
if (!phydev)
return;
if (enable && (phydev->state == PHY_READY || phydev->state == PHY_HALTED))
phy_start(phydev);
else if (!enable && (phy_is_started(phydev) || phydev->state == PHY_DOWN))
phy_stop(phydev);
}
static int hclge_set_mac_state(struct hclge_dev *hdev, void *data,
size_t length)
{
bool enable;
int ret;
if (length != sizeof(int))
return -EINVAL;
enable = !!*(int *)data;
ret = hclge_cfg_mac_mode(hdev, enable);
if (!ret && !hclge_comm_dev_phy_imp_supported(hdev->ae_dev))
hclge_set_phy_state(hdev, enable);
return ret;
}
static void hclge_ext_resotre_config(struct hclge_dev *hdev) static void hclge_ext_resotre_config(struct hclge_dev *hdev)
{ {
if (hdev->reset_type != HNAE3_IMP_RESET && if (hdev->reset_type != HNAE3_IMP_RESET &&
...@@ -815,6 +846,7 @@ static const hclge_priv_ops_fn hclge_ext_func_arr[] = { ...@@ -815,6 +846,7 @@ static const hclge_priv_ops_fn hclge_ext_func_arr[] = {
[HNAE3_EXT_OPC_GET_HILINK_REF_LOS] = hclge_get_hilink_ref_los, [HNAE3_EXT_OPC_GET_HILINK_REF_LOS] = hclge_get_hilink_ref_los,
[HNAE3_EXT_OPC_GET_PORT_FAULT_STATUS] = hclge_get_port_fault_status, [HNAE3_EXT_OPC_GET_PORT_FAULT_STATUS] = hclge_get_port_fault_status,
[HNAE3_EXT_OPC_GET_PORT_TYPE] = hclge_get_port_wire_type, [HNAE3_EXT_OPC_GET_PORT_TYPE] = hclge_get_port_wire_type,
[HNAE3_EXT_OPC_SET_MAC_STATE] = hclge_set_mac_state,
}; };
int hclge_ext_ops_handle(struct hnae3_handle *handle, int opcode, int hclge_ext_ops_handle(struct hnae3_handle *handle, int opcode,
......
...@@ -7977,7 +7977,7 @@ static void hclge_enable_fd(struct hnae3_handle *handle, bool enable) ...@@ -7977,7 +7977,7 @@ static void hclge_enable_fd(struct hnae3_handle *handle, bool enable)
hclge_task_schedule(hdev, 0); hclge_task_schedule(hdev, 0);
} }
static void hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable) int hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable)
{ {
struct hclge_desc desc; struct hclge_desc desc;
struct hclge_config_mac_mode_cmd *req = struct hclge_config_mac_mode_cmd *req =
...@@ -8004,8 +8004,10 @@ static void hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable) ...@@ -8004,8 +8004,10 @@ static void hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable)
ret = hclge_cmd_send(&hdev->hw, &desc, 1); ret = hclge_cmd_send(&hdev->hw, &desc, 1);
if (ret) if (ret)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev, "failed to %s mac, ret = %d.\n",
"mac enable fail, ret =%d.\n", ret); enable ? "enable" : "disable", ret);
return ret;
} }
static int hclge_config_switch_param(struct hclge_dev *hdev, int vfid, static int hclge_config_switch_param(struct hclge_dev *hdev, int vfid,
......
...@@ -1169,4 +1169,5 @@ void hclge_reset_task_schedule(struct hclge_dev *hdev); ...@@ -1169,4 +1169,5 @@ void hclge_reset_task_schedule(struct hclge_dev *hdev);
void hclge_reset_event(struct pci_dev *pdev, struct hnae3_handle *handle); void hclge_reset_event(struct pci_dev *pdev, struct hnae3_handle *handle);
void hclge_get_media_type(struct hnae3_handle *handle, u8 *media_type, void hclge_get_media_type(struct hnae3_handle *handle, u8 *media_type,
u8 *module_type); u8 *module_type);
int hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册