Commit 32e6e17f authored by Hao Lan's avatar Hao Lan Committed by Jiantao Xiao
Browse files

net: hns3: support wake on lan configuration and query

mainline inclusion
from mainline-v6.4-rc1
commit 3b064f54
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I7ON9Y
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3b064f541be822dc095991c6dda20a75eb51db5e



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

The HNS3 driver supports Wake-on-LAN, which can wake up
the server from power off state to power on state by magic
packet or magic security packet.

ChangeLog:
v1->v2:
Deleted the debugfs function that overlaps with the ethtool function
from suggestion of Andrew Lunn.

v2->v3:
Return the wol configuration stored in driver,
suggested by Alexander H Duyck.

v3->v4:
Add a helper to go from netdev to the local struct,
suggested by Simon Horman and Jakub Kicinski.

Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarHao Lan <lanhao@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarJiantao Xiao <xiaojiantao1@h-partners.com>
parent be1c1521
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ enum HNAE3_DEV_CAP_BITS {
	HNAE3_DEV_SUPPORT_MC_MAC_MNG_B,
	HNAE3_DEV_SUPPORT_CQ_B,
	HNAE3_DEV_SUPPORT_LANE_NUM_B,
	HNAE3_DEV_SUPPORT_WOL_B,
	HNAE3_DEV_SUPPORT_VF_FAULT_B,
	HNAE3_DEV_SUPPORT_NOTIFY_PKT_B,
};
@@ -168,6 +169,9 @@ enum HNAE3_DEV_CAP_BITS {
#define hnae3_ae_dev_lane_num_supported(ae_dev) \
	test_bit(HNAE3_DEV_SUPPORT_LANE_NUM_B, (ae_dev)->caps)

#define hnae3_ae_dev_wol_supported(ae_dev) \
	test_bit(HNAE3_DEV_SUPPORT_WOL_B, (ae_dev)->caps)

#define hnae3_ae_dev_vf_fault_supported(ae_dev) \
	test_bit(HNAE3_DEV_SUPPORT_VF_FAULT_B, (ae_dev)->caps)

@@ -578,6 +582,10 @@ struct hnae3_ae_dev {
 *   Get phc info
 * clean_vf_config
 *   Clean residual vf info after disable sriov
 * get_wol
 *   Get wake on lan info
 * set_wol
 *   Config wake on lan
 */
struct hnae3_ae_ops {
	int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev);
@@ -775,6 +783,10 @@ struct hnae3_ae_ops {
	void (*clean_vf_config)(struct hnae3_ae_dev *ae_dev, int num_vfs);
	int (*get_dscp_prio)(struct hnae3_handle *handle, u8 dscp,
			     u8 *tc_map_mode, u8 *priority);
	void (*get_wol)(struct hnae3_handle *handle,
			struct ethtool_wolinfo *wol);
	int (*set_wol)(struct hnae3_handle *handle,
		       struct ethtool_wolinfo *wol);
	int (*priv_ops)(struct hnae3_handle *handle, int opcode,
			void *data, size_t length);
};
+1 −0
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@ static const struct hclge_comm_caps_bit_map hclge_pf_cmd_caps[] = {
	{HCLGE_COMM_CAP_GRO_B, HNAE3_DEV_SUPPORT_GRO_B},
	{HCLGE_COMM_CAP_FD_B, HNAE3_DEV_SUPPORT_FD_B},
	{HCLGE_COMM_CAP_LANE_NUM_B, HNAE3_DEV_SUPPORT_LANE_NUM_B},
	{HCLGE_COMM_CAP_WOL_B, HNAE3_DEV_SUPPORT_WOL_B},
	{HCLGE_COMM_CAP_VF_FAULT_B, HNAE3_DEV_SUPPORT_VF_FAULT_B},
	{HCLGE_COMM_CAP_NOTIFY_PKT_B, HNAE3_DEV_SUPPORT_NOTIFY_PKT_B},
};
+3 −0
Original line number Diff line number Diff line
@@ -295,6 +295,8 @@ enum hclge_opcode_type {
	HCLGE_PPP_CMD0_INT_CMD		= 0x2100,
	HCLGE_PPP_CMD1_INT_CMD		= 0x2101,
	HCLGE_MAC_ETHERTYPE_IDX_RD      = 0x2105,
	HCLGE_OPC_WOL_GET_SUPPORTED_MODE	= 0x2201,
	HCLGE_OPC_WOL_CFG		= 0x2202,
	HCLGE_NCSI_INT_EN		= 0x2401,

	/* ROH MAC commands */
@@ -346,6 +348,7 @@ enum HCLGE_COMM_CAP_BITS {
	HCLGE_COMM_CAP_FD_B = 21,
	HCLGE_COMM_CAP_VF_FAULT_B = 26,
	HCLGE_COMM_CAP_LANE_NUM_B = 27,
	HCLGE_COMM_CAP_WOL_B = 28,
	HCLGE_COMM_CAP_NOTIFY_PKT_B = 29,
};

+3 −0
Original line number Diff line number Diff line
@@ -402,6 +402,9 @@ static struct hns3_dbg_cap_info hns3_dbg_cap[] = {
	}, {
		.name = "support modify vlan filter state",
		.cap_bit = HNAE3_DEV_SUPPORT_VLAN_FLTR_MDF_B,
	}, {
		.name = "support wake on lan",
		.cap_bit = HNAE3_DEV_SUPPORT_WOL_B,
	}, {
		.name = "support vf fault detect",
		.cap_bit = HNAE3_DEV_SUPPORT_VF_FAULT_B,
+6 −0
Original line number Diff line number Diff line
@@ -755,6 +755,12 @@ 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)

Loading