mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-19 06:38:26 -05:00
Merge branch 'net-fec-add-some-optimizations'
Wei Fang says: ==================== net: fec: add some optimizations Add some optimizations to the fec driver, see each patch for details. v1: https://lore.kernel.org/20250710090902.1171180-1-wei.fang@nxp.com ==================== Link: https://patch.msgid.link/20250711091639.1374411-1-wei.fang@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -279,13 +279,15 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
|
||||
#define FEC_ECR_BYTESWP BIT(8)
|
||||
/* FEC RCR bits definition */
|
||||
#define FEC_RCR_LOOP BIT(0)
|
||||
#define FEC_RCR_HALFDPX BIT(1)
|
||||
#define FEC_RCR_DRT BIT(1)
|
||||
#define FEC_RCR_MII BIT(2)
|
||||
#define FEC_RCR_PROMISC BIT(3)
|
||||
#define FEC_RCR_BC_REJ BIT(4)
|
||||
#define FEC_RCR_FLOWCTL BIT(5)
|
||||
#define FEC_RCR_RGMII BIT(6)
|
||||
#define FEC_RCR_RMII BIT(8)
|
||||
#define FEC_RCR_10BASET BIT(9)
|
||||
#define FEC_RCR_NLC BIT(30)
|
||||
/* TX WMARK bits */
|
||||
#define FEC_TXWMRK_STRFWD BIT(8)
|
||||
|
||||
@@ -1121,6 +1123,17 @@ static void fec_ctrl_reset(struct fec_enet_private *fep, bool allow_wol)
|
||||
}
|
||||
}
|
||||
|
||||
static void fec_set_hw_mac_addr(struct net_device *ndev)
|
||||
{
|
||||
struct fec_enet_private *fep = netdev_priv(ndev);
|
||||
|
||||
writel(ndev->dev_addr[3] | (ndev->dev_addr[2] << 8) |
|
||||
(ndev->dev_addr[1] << 16) | (ndev->dev_addr[0] << 24),
|
||||
fep->hwp + FEC_ADDR_LOW);
|
||||
writel((ndev->dev_addr[5] << 16) | (ndev->dev_addr[4] << 24),
|
||||
fep->hwp + FEC_ADDR_HIGH);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called to start or restart the FEC during a link
|
||||
* change, transmit timeout, or to reconfigure the FEC. The network
|
||||
@@ -1130,8 +1143,7 @@ static void
|
||||
fec_restart(struct net_device *ndev)
|
||||
{
|
||||
struct fec_enet_private *fep = netdev_priv(ndev);
|
||||
u32 temp_mac[2];
|
||||
u32 rcntl = OPT_FRAME_SIZE | 0x04;
|
||||
u32 rcntl = OPT_FRAME_SIZE | FEC_RCR_MII;
|
||||
u32 ecntl = FEC_ECR_ETHEREN;
|
||||
|
||||
if (fep->bufdesc_ex)
|
||||
@@ -1143,11 +1155,7 @@ fec_restart(struct net_device *ndev)
|
||||
* enet-mac reset will reset mac address registers too,
|
||||
* so need to reconfigure it.
|
||||
*/
|
||||
memcpy(&temp_mac, ndev->dev_addr, ETH_ALEN);
|
||||
writel((__force u32)cpu_to_be32(temp_mac[0]),
|
||||
fep->hwp + FEC_ADDR_LOW);
|
||||
writel((__force u32)cpu_to_be32(temp_mac[1]),
|
||||
fep->hwp + FEC_ADDR_HIGH);
|
||||
fec_set_hw_mac_addr(ndev);
|
||||
|
||||
/* Clear any outstanding interrupt, except MDIO. */
|
||||
writel((0xffffffff & ~FEC_ENET_MII), fep->hwp + FEC_IEVENT);
|
||||
@@ -1162,7 +1170,7 @@ fec_restart(struct net_device *ndev)
|
||||
writel(0x04, fep->hwp + FEC_X_CNTRL);
|
||||
} else {
|
||||
/* No Rcv on Xmit */
|
||||
rcntl |= 0x02;
|
||||
rcntl |= FEC_RCR_DRT;
|
||||
writel(0x0, fep->hwp + FEC_X_CNTRL);
|
||||
}
|
||||
|
||||
@@ -1191,14 +1199,11 @@ fec_restart(struct net_device *ndev)
|
||||
*/
|
||||
if (fep->quirks & FEC_QUIRK_ENET_MAC) {
|
||||
/* Enable flow control and length check */
|
||||
rcntl |= 0x40000000 | 0x00000020;
|
||||
rcntl |= FEC_RCR_NLC | FEC_RCR_FLOWCTL;
|
||||
|
||||
/* RGMII, RMII or MII */
|
||||
if (fep->phy_interface == PHY_INTERFACE_MODE_RGMII ||
|
||||
fep->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
|
||||
fep->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID ||
|
||||
fep->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID)
|
||||
rcntl |= (1 << 6);
|
||||
if (phy_interface_mode_is_rgmii(fep->phy_interface))
|
||||
rcntl |= FEC_RCR_RGMII;
|
||||
else if (fep->phy_interface == PHY_INTERFACE_MODE_RMII)
|
||||
rcntl |= FEC_RCR_RMII;
|
||||
else
|
||||
@@ -3694,7 +3699,6 @@ static void set_multicast_list(struct net_device *ndev)
|
||||
static int
|
||||
fec_set_mac_address(struct net_device *ndev, void *p)
|
||||
{
|
||||
struct fec_enet_private *fep = netdev_priv(ndev);
|
||||
struct sockaddr *addr = p;
|
||||
|
||||
if (addr) {
|
||||
@@ -3711,11 +3715,8 @@ fec_set_mac_address(struct net_device *ndev, void *p)
|
||||
if (!netif_running(ndev))
|
||||
return 0;
|
||||
|
||||
writel(ndev->dev_addr[3] | (ndev->dev_addr[2] << 8) |
|
||||
(ndev->dev_addr[1] << 16) | (ndev->dev_addr[0] << 24),
|
||||
fep->hwp + FEC_ADDR_LOW);
|
||||
writel((ndev->dev_addr[5] << 16) | (ndev->dev_addr[4] << 24),
|
||||
fep->hwp + FEC_ADDR_HIGH);
|
||||
fec_set_hw_mac_addr(ndev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user