提交 27be587d 编写于 作者: J Jiantao Xiao

Revert "net: hns3: sync linux kernel hns3 wol to openeuler"

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7ON9Y
CVE: NA

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

This reverts commit 92c6f2cf.
Signed-off-by: NJiantao Xiao <xiaojiantao1@h-partners.com>
上级 644997ef
......@@ -755,12 +755,6 @@ static inline unsigned int hns3_page_order(struct hns3_enet_ring *ring)
#define hns3_get_handle(ndev) \
(((struct hns3_nic_priv *)netdev_priv(ndev))->ae_handle)
#define hns3_get_ae_dev(handle) \
(pci_get_drvdata((handle)->pdev))
#define hns3_get_ops(handle) \
((handle)->ae_algo->ops)
#define hns3_gl_usec_to_reg(int_gl) ((int_gl) >> 1)
#define hns3_gl_round_down(int_gl) round_down(int_gl, 2)
......
......@@ -2045,10 +2045,10 @@ static int hns3_get_link_ext_state(struct net_device *netdev,
static void hns3_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
{
struct hnae3_handle *handle = hns3_get_handle(netdev);
const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
if (!hnae3_ae_dev_wol_supported(ae_dev))
if (!hnae3_ae_dev_wol_supported(ae_dev) || !ops->get_wol)
return;
ops->get_wol(handle, wol);
......@@ -2058,10 +2058,10 @@ static int hns3_set_wol(struct net_device *netdev,
struct ethtool_wolinfo *wol)
{
struct hnae3_handle *handle = hns3_get_handle(netdev);
const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
if (!hnae3_ae_dev_wol_supported(ae_dev))
if (!hnae3_ae_dev_wol_supported(ae_dev) || !ops->set_wol)
return -EOPNOTSUPP;
return ops->set_wol(handle, wol);
......
......@@ -898,6 +898,18 @@ struct hclge_phy_reg_cmd {
u8 rsv2[12];
};
enum HCLGE_WOL_MODE {
HCLGE_WOL_PHY = BIT(0),
HCLGE_WOL_UNICAST = BIT(1),
HCLGE_WOL_MULTICAST = BIT(2),
HCLGE_WOL_BROADCAST = BIT(3),
HCLGE_WOL_ARP = BIT(4),
HCLGE_WOL_MAGIC = BIT(5),
HCLGE_WOL_MAGICSECURED = BIT(6),
HCLGE_WOL_FILTER = BIT(7),
HCLGE_WOL_DISABLE = 0,
};
struct hclge_wol_cfg_cmd {
__le32 wake_on_lan_mode;
u8 sopass[SOPASS_MAX];
......
......@@ -2515,29 +2515,29 @@ static int hclge_dbg_dump_mac_mc(struct hclge_dev *hdev, char *buf, int len)
static void hclge_dump_wol_mode(u32 mode, char *buf, int len, int *pos)
{
if (mode & WAKE_PHY)
if (mode & HCLGE_WOL_PHY)
*pos += scnprintf(buf + *pos, len - *pos, " [p]phy\n");
if (mode & WAKE_UCAST)
if (mode & HCLGE_WOL_UNICAST)
*pos += scnprintf(buf + *pos, len - *pos, " [u]unicast\n");
if (mode & WAKE_MCAST)
if (mode & HCLGE_WOL_MULTICAST)
*pos += scnprintf(buf + *pos, len - *pos, " [m]multicast\n");
if (mode & WAKE_BCAST)
if (mode & HCLGE_WOL_BROADCAST)
*pos += scnprintf(buf + *pos, len - *pos, " [b]broadcast\n");
if (mode & WAKE_ARP)
if (mode & HCLGE_WOL_ARP)
*pos += scnprintf(buf + *pos, len - *pos, " [a]arp\n");
if (mode & WAKE_MAGIC)
if (mode & HCLGE_WOL_MAGIC)
*pos += scnprintf(buf + *pos, len - *pos, " [g]magic\n");
if (mode & WAKE_MAGICSECURE)
if (mode & HCLGE_WOL_MAGICSECURED)
*pos += scnprintf(buf + *pos, len - *pos,
" [s]magic secured\n");
if (mode & WAKE_FILTER)
if (mode & HCLGE_WOL_FILTER)
*pos += scnprintf(buf + *pos, len - *pos, " [f]filter\n");
}
......
......@@ -12074,15 +12074,69 @@ static void hclge_uninit_rxd_adv_layout(struct hclge_dev *hdev)
hclge_write_dev(&hdev->hw, HCLGE_RXD_ADV_LAYOUT_EN_REG, 0);
}
static struct hclge_wol_info *hclge_get_wol_info(struct hnae3_handle *handle)
static __u32 hclge_wol_mode_to_ethtool(u32 mode)
{
struct hclge_vport *vport = hclge_get_vport(handle);
__u32 ret = 0;
if (mode & HCLGE_WOL_PHY)
ret |= WAKE_PHY;
if (mode & HCLGE_WOL_UNICAST)
ret |= WAKE_UCAST;
if (mode & HCLGE_WOL_MULTICAST)
ret |= WAKE_MCAST;
if (mode & HCLGE_WOL_BROADCAST)
ret |= WAKE_BCAST;
if (mode & HCLGE_WOL_ARP)
ret |= WAKE_ARP;
if (mode & HCLGE_WOL_MAGIC)
ret |= WAKE_MAGIC;
if (mode & HCLGE_WOL_MAGICSECURED)
ret |= WAKE_MAGICSECURE;
if (mode & HCLGE_WOL_FILTER)
ret |= WAKE_FILTER;
return &vport->back->hw.mac.wol;
return ret;
}
int hclge_get_wol_supported_mode(struct hclge_dev *hdev,
u32 *wol_supported)
static u32 hclge_wol_mode_from_ethtool(__u32 mode)
{
u32 ret = HCLGE_WOL_DISABLE;
if (mode & WAKE_PHY)
ret |= HCLGE_WOL_PHY;
if (mode & WAKE_UCAST)
ret |= HCLGE_WOL_UNICAST;
if (mode & WAKE_MCAST)
ret |= HCLGE_WOL_MULTICAST;
if (mode & WAKE_BCAST)
ret |= HCLGE_WOL_BROADCAST;
if (mode & WAKE_ARP)
ret |= HCLGE_WOL_ARP;
if (mode & WAKE_MAGIC)
ret |= HCLGE_WOL_MAGIC;
if (mode & WAKE_MAGICSECURE)
ret |= HCLGE_WOL_MAGICSECURED;
if (mode & WAKE_FILTER)
ret |= HCLGE_WOL_FILTER;
return ret;
}
int hclge_get_wol_supported_mode(struct hclge_dev *hdev, u32 *wol_supported)
{
struct hclge_query_wol_supported_cmd *wol_supported_cmd;
struct hclge_desc desc;
......@@ -12167,7 +12221,7 @@ static int hclge_init_wol(struct hclge_dev *hdev)
ret = hclge_get_wol_supported_mode(hdev,
&wol_info->wol_support_mode);
if (ret) {
wol_info->wol_support_mode = 0;
wol_info->wol_support_mode = HCLGE_WOL_DISABLE;
return ret;
}
......@@ -12177,39 +12231,38 @@ static int hclge_init_wol(struct hclge_dev *hdev)
static void hclge_get_wol(struct hnae3_handle *handle,
struct ethtool_wolinfo *wol)
{
struct hclge_wol_info *wol_info = hclge_get_wol_info(handle);
struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back;
struct hclge_wol_info *wol_info = &hdev->hw.mac.wol;
wol->supported = wol_info->wol_support_mode;
wol->wolopts = wol_info->wol_current_mode;
if (wol_info->wol_current_mode & WAKE_MAGICSECURE)
memcpy(wol->sopass, wol_info->wol_sopass, SOPASS_MAX);
wol->supported = hclge_wol_mode_to_ethtool(wol_info->wol_support_mode);
wol->wolopts =
hclge_wol_mode_to_ethtool(wol_info->wol_current_mode);
if (wol_info->wol_current_mode & HCLGE_WOL_MAGICSECURED)
memcpy(&wol->sopass, wol_info->wol_sopass, SOPASS_MAX);
}
static int hclge_set_wol(struct hnae3_handle *handle,
struct ethtool_wolinfo *wol)
{
struct hclge_wol_info *wol_info = hclge_get_wol_info(handle);
struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back;
struct hclge_wol_info *wol_info = &hdev->hw.mac.wol;
u32 wol_mode;
int ret;
wol_mode = wol->wolopts;
wol_mode = hclge_wol_mode_from_ethtool(wol->wolopts);
if (wol_mode & ~wol_info->wol_support_mode)
return -EINVAL;
wol_info->wol_current_mode = wol_mode;
if (wol_mode & WAKE_MAGICSECURE) {
memcpy(wol_info->wol_sopass, wol->sopass, SOPASS_MAX);
if (wol_mode & HCLGE_WOL_MAGICSECURED) {
memcpy(wol_info->wol_sopass, &wol->sopass, SOPASS_MAX);
wol_info->wol_sopass_size = SOPASS_MAX;
} else {
wol_info->wol_sopass_size = 0;
}
ret = hclge_set_wol_cfg(vport->back, wol_info);
if (ret)
wol_info->wol_current_mode = 0;
return ret;
return hclge_set_wol_cfg(hdev, wol_info);
}
static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册