Commit 67f118c3 authored by Jijie Shao's avatar Jijie Shao Committed by Hao Chen
Browse files

net: hibmcge: Add pauseparam supported in this module

maillist inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IBM1QO
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=3a03763f3876



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

The MAC can automatically send or respond to pause frames.
This patch supports the function of enabling pause frames
by using ethtool.

Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20241216040532.1566229-6-shaojijie@huawei.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarHao Chen <chenhao418@huawei.com>
parent 86006c6a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ struct hbg_mac {
	u32 duplex;
	u32 autoneg;
	u32 link_status;
	u32 pause_autoneg;
};

struct hbg_mac_table_entry {
+25 −0
Original line number Diff line number Diff line
@@ -143,12 +143,37 @@ static void hbg_ethtool_get_regs(struct net_device *netdev,
	}
}

static void hbg_ethtool_get_pauseparam(struct net_device *net_dev,
				       struct ethtool_pauseparam *param)
{
	struct hbg_priv *priv = netdev_priv(net_dev);

	param->autoneg = priv->mac.pause_autoneg;
	hbg_hw_get_pause_enable(priv, &param->tx_pause, &param->rx_pause);
}

static int hbg_ethtool_set_pauseparam(struct net_device *net_dev,
				      struct ethtool_pauseparam *param)
{
	struct hbg_priv *priv = netdev_priv(net_dev);

	priv->mac.pause_autoneg = param->autoneg;
	phy_set_asym_pause(priv->mac.phydev, param->rx_pause, param->tx_pause);

	if (!param->autoneg)
		hbg_hw_set_pause_enable(priv, param->tx_pause, param->rx_pause);

	return 0;
}

static const struct ethtool_ops hbg_ethtool_ops = {
	.get_link		= ethtool_op_get_link,
	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
	.get_regs_len		= hbg_ethtool_get_regs_len,
	.get_regs		= hbg_ethtool_get_regs,
	.get_pauseparam         = hbg_ethtool_get_pauseparam,
	.set_pauseparam         = hbg_ethtool_set_pauseparam,
};

void hbg_ethtool_set_ops(struct net_device *netdev)
+21 −0
Original line number Diff line number Diff line
@@ -220,6 +220,27 @@ void hbg_hw_set_mac_filter_enable(struct hbg_priv *priv, u32 enable)
			    HBG_REG_REC_FILT_CTRL_UC_MATCH_EN_B, enable);
}

void hbg_hw_set_pause_enable(struct hbg_priv *priv, u32 tx_en, u32 rx_en)
{
	hbg_reg_write_field(priv, HBG_REG_PAUSE_ENABLE_ADDR,
			    HBG_REG_PAUSE_ENABLE_TX_B, tx_en);
	hbg_reg_write_field(priv, HBG_REG_PAUSE_ENABLE_ADDR,
			    HBG_REG_PAUSE_ENABLE_RX_B, rx_en);
}

void hbg_hw_get_pause_enable(struct hbg_priv *priv, u32 *tx_en, u32 *rx_en)
{
	*tx_en = hbg_reg_read_field(priv, HBG_REG_PAUSE_ENABLE_ADDR,
				    HBG_REG_PAUSE_ENABLE_TX_B);
	*rx_en = hbg_reg_read_field(priv, HBG_REG_PAUSE_ENABLE_ADDR,
				    HBG_REG_PAUSE_ENABLE_RX_B);
}

void hbg_hw_set_rx_pause_mac_addr(struct hbg_priv *priv, u64 mac_addr)
{
	hbg_reg_write64(priv, HBG_REG_FD_FC_ADDR_LOW_ADDR, mac_addr);
}

static void hbg_hw_init_transmit_ctrl(struct hbg_priv *priv)
{
	u32 ctrl = 0;
+3 −0
Original line number Diff line number Diff line
@@ -56,5 +56,8 @@ u32 hbg_hw_get_fifo_used_num(struct hbg_priv *priv, enum hbg_dir dir);
void hbg_hw_set_tx_desc(struct hbg_priv *priv, struct hbg_tx_desc *tx_desc);
void hbg_hw_fill_buffer(struct hbg_priv *priv, u32 buffer_dma_addr);
void hbg_hw_set_mac_filter_enable(struct hbg_priv *priv, u32 enable);
void hbg_hw_set_pause_enable(struct hbg_priv *priv, u32 tx_en, u32 rx_en);
void hbg_hw_get_pause_enable(struct hbg_priv *priv, u32 *tx_en, u32 *rx_en);
void hbg_hw_set_rx_pause_mac_addr(struct hbg_priv *priv, u64 mac_addr);

#endif
+1 −0
Original line number Diff line number Diff line
@@ -191,6 +191,7 @@ static int hbg_net_set_mac_address(struct net_device *netdev, void *addr)
	if (exists)
		hbg_set_mac_to_mac_table(priv, index, NULL);

	hbg_hw_set_rx_pause_mac_addr(priv, ether_addr_to_u64(mac_addr));
	dev_addr_set(netdev, mac_addr);
	return 0;
}
Loading