From: Andrew Lunn <andrew@lunn.ch>
To: Hao Lan <lanhao@huawei.com>
Cc: davem@davemloft.net, kuba@kernel.org, yisen.zhuang@huawei.com,
salil.mehta@huawei.com, edumazet@google.com, pabeni@redhat.com,
richardcochran@gmail.com, shenjian15@huawei.com,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next 1/2] net: hns3: support wake on lan configuration and query
Date: Wed, 4 Jan 2023 03:10:37 +0100 [thread overview]
Message-ID: <Y7TgHS8oGbE656v0@lunn.ch> (raw)
In-Reply-To: <20230104013405.65433-2-lanhao@huawei.com>
> +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,
> +};
These are the exact same values as WAKE_PHY, WAKE_CAST etc. Since they
are ABI, they will never change. So you may as well throw these away
and just use the Linux values.
> struct hclge_hw;
> int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num);
> enum hclge_comm_cmd_status hclge_cmd_mdio_write(struct hclge_hw *hw,
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> index 4e54f91f7a6c..88cb5c05bc43 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> @@ -11500,6 +11500,201 @@ static void hclge_uninit_rxd_adv_layout(struct hclge_dev *hdev)
> hclge_write_dev(&hdev->hw, HCLGE_RXD_ADV_LAYOUT_EN_REG, 0);
> }
>
> +static __u32 hclge_wol_mode_to_ethtool(u32 mode)
> +{
> + __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;
Once you throw away HCLGE_WOL_*, this function becomes much simpler.
> +
> + return ret;
> +}
> +
> +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;
This one two.
> @@ -12075,6 +12275,8 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev)
>
> hclge_init_rxd_adv_layout(hdev);
>
> + (void)hclge_update_wol(hdev);
Please avoid casts like this. If there is an error, you should not
ignore it. If it cannot fail, make it a void function.
Andrew
next prev parent reply other threads:[~2023-01-04 2:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-04 1:34 [PATCH net-next 0/2] net: hns3: support wake on lan for hns3 Hao Lan
2023-01-04 1:34 ` [PATCH net-next 1/2] net: hns3: support wake on lan configuration and query Hao Lan
2023-01-04 2:10 ` Andrew Lunn [this message]
2023-01-04 12:57 ` Hao Lan
2023-01-04 15:00 ` Andrew Lunn
2023-01-04 1:34 ` [PATCH net-next 2/2] net: hns3: support debugfs for wake on lan Hao Lan
2023-01-04 2:12 ` Andrew Lunn
-- strict thread matches above, loose matches on Subject: below --
2023-02-06 13:49 [PATCH net-next 0/2] net: hns3: support wake on lan for hns3 Hao Lan
2023-02-06 13:49 ` [PATCH net-next 1/2] net: hns3: support wake on lan configuration and query Hao Lan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y7TgHS8oGbE656v0@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=lanhao@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=salil.mehta@huawei.com \
--cc=shenjian15@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).