Re: [PATCH v5 06/11] net: ethernet: mtk-star-emac: new driver
On Wed, May 27, 2020 at 1:49 PM Bartosz Golaszewski wrote: > > śr., 27 maj 2020 o 13:33 Arnd Bergmann napisał(a): > > > > On Wed, May 27, 2020 at 10:46 AM Bartosz Golaszewski wrote: > > > Thanks for reporting this! I have a fix ready and will send it shortly. > > > > I already have a workaround for this bug as well as another one > > in my tree that I'll send later today after some more testing. > > > > Feel free to wait for that, or just ignore mine if you already have a fix. > > > > I already posted a fix[1]. Sorry for omitting you, but somehow your > name didn't pop up in get_maintainers.pl. I'm not a maintainer for this, I just do a lot of build fixes on the side, as I verify the stuff that I merge myself ;-) > [1] https://lkml.org/lkml/2020/5/27/378 Ok, perfect, that is indeed the correct fix and mine was wrong. I'll just send a fix for the other bug (unused-function warning) then. Arnd
Re: [PATCH v5 06/11] net: ethernet: mtk-star-emac: new driver
śr., 27 maj 2020 o 13:33 Arnd Bergmann napisał(a): > > On Wed, May 27, 2020 at 10:46 AM Bartosz Golaszewski wrote: > > > > I don't know if there should be a new label that excludes that > > > assignment for those particular gotos or if new_dma_addr should > > > be initialized to something at the top. Please take a look at > > > addressing this when you get a chance. > > > > > > Cheers, > > > Nathan > > > > Hi Nathan, > > > > Thanks for reporting this! I have a fix ready and will send it shortly. > > I already have a workaround for this bug as well as another one > in my tree that I'll send later today after some more testing. > > Feel free to wait for that, or just ignore mine if you already have a fix. > >Arnd Hi Arnd! I already posted a fix[1]. Sorry for omitting you, but somehow your name didn't pop up in get_maintainers.pl. Bartosz [1] https://lkml.org/lkml/2020/5/27/378
Re: [PATCH v5 06/11] net: ethernet: mtk-star-emac: new driver
On Wed, May 27, 2020 at 10:46 AM Bartosz Golaszewski wrote: > > I don't know if there should be a new label that excludes that > > assignment for those particular gotos or if new_dma_addr should > > be initialized to something at the top. Please take a look at > > addressing this when you get a chance. > > > > Cheers, > > Nathan > > Hi Nathan, > > Thanks for reporting this! I have a fix ready and will send it shortly. I already have a workaround for this bug as well as another one in my tree that I'll send later today after some more testing. Feel free to wait for that, or just ignore mine if you already have a fix. Arnd
Re: [PATCH v5 06/11] net: ethernet: mtk-star-emac: new driver
śr., 27 maj 2020 o 09:31 Nathan Chancellor napisał(a): > > On Fri, May 22, 2020 at 02:06:55PM +0200, Bartosz Golaszewski wrote: > > > > > diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c > > b/drivers/net/ethernet/mediatek/mtk_star_emac.c > > new file mode 100644 > > index ..789c77af501f > > --- /dev/null > > +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c > > @@ -0,0 +1,1678 @@ > > > > I've searched netdev and I cannot find any reports from others but this > function introduces a clang warning: > > drivers/net/ethernet/mediatek/mtk_star_emac.c:1296:6: warning: variable > 'new_dma_addr' is used uninitialized whenever 'if' condition is true > [-Wsometimes-uninitialized] > if (!new_skb) { > ^~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1321:23: note: uninitialized > use occurs here > desc_data.dma_addr = new_dma_addr; > ^~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1296:2: note: remove the 'if' > if its condition is always false > if (!new_skb) { > ^~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:6: warning: variable > 'new_dma_addr' is used uninitialized whenever 'if' condition is true > [-Wsometimes-uninitialized] > if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || > ^~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1321:23: note: uninitialized > use occurs here > desc_data.dma_addr = new_dma_addr; > ^~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:2: note: remove the 'if' > if its condition is always false > if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || > ^~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:6: warning: variable > 'new_dma_addr' is used uninitialized whenever '||' condition is true > [-Wsometimes-uninitialized] > if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || > ^ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1321:23: note: uninitialized > use occurs here > desc_data.dma_addr = new_dma_addr; > ^~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:6: note: remove the '||' > if its condition is always false > if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || > ^~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1274:25: note: initialize the > variable 'new_dma_addr' to silence this warning > dma_addr_t new_dma_addr; >^ > = 0 > 3 warnings generated. > > > +static int mtk_star_receive_packet(struct mtk_star_priv *priv) > > +{ > > + struct mtk_star_ring *ring = &priv->rx_ring; > > + struct device *dev = mtk_star_get_dev(priv); > > + struct mtk_star_ring_desc_data desc_data; > > + struct net_device *ndev = priv->ndev; > > + struct sk_buff *curr_skb, *new_skb; > > + dma_addr_t new_dma_addr; > > Uninitialized here > > > + int ret; > > + > > + spin_lock(&priv->lock); > > + ret = mtk_star_ring_pop_tail(ring, &desc_data); > > + spin_unlock(&priv->lock); > > + if (ret) > > + return -1; > > + > > + curr_skb = desc_data.skb; > > + > > + if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || > > + (desc_data.flags & MTK_STAR_DESC_BIT_RX_OSIZE)) { > > + /* Error packet -> drop and reuse skb. */ > > + new_skb = curr_skb; > > + goto push_new_skb; > > this goto > > > + } > > + > > + /* Prepare new skb before receiving the current one. Reuse the current > > + * skb if we fail at any point. > > + */ > > + new_skb = mtk_star_alloc_skb(ndev); > > + if (!new_skb) { > > + ndev->stats.rx_dropped++; > > + new_skb = curr_skb; > > + goto push_new_skb; > > and this goto > > > + } > > + > > + new_dma_addr = mtk_star_dma_map_rx(priv, new_skb); > > + if (dma_mapping_error(dev, new_dma_addr)) { > > + ndev->stats.rx_dropped++; > > + dev_kfree_skb(new_skb); > > + new_skb = curr_skb; > > + netdev_err(ndev, "DMA mapping error of RX descriptor\n"); > > + goto push_new_skb; > > + } > > + > > + /* We can't fail anymore at this point: it's safe to unmap the skb. */ > > + mtk_star_dma_unmap_rx(priv, &desc_data); > > + > > + skb_put(desc_data.skb, desc_data.len); > > + desc_data.skb->ip_summed = CHECKSUM_NONE; > > + desc_data.skb->protocol = eth_type_trans(desc_data.skb, ndev); > > + desc_data.skb->dev = ndev; > > + netif_receive_skb(desc_data.skb); > > + > > +push_new_skb: > > + desc_data.dma_addr = new_dma_addr; > > assign it uninitialized here. > >
Re: [PATCH v5 06/11] net: ethernet: mtk-star-emac: new driver
On Fri, May 22, 2020 at 02:06:55PM +0200, Bartosz Golaszewski wrote: > diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c > b/drivers/net/ethernet/mediatek/mtk_star_emac.c > new file mode 100644 > index ..789c77af501f > --- /dev/null > +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c > @@ -0,0 +1,1678 @@ I've searched netdev and I cannot find any reports from others but this function introduces a clang warning: drivers/net/ethernet/mediatek/mtk_star_emac.c:1296:6: warning: variable 'new_dma_addr' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (!new_skb) { ^~~~ drivers/net/ethernet/mediatek/mtk_star_emac.c:1321:23: note: uninitialized use occurs here desc_data.dma_addr = new_dma_addr; ^~~~ drivers/net/ethernet/mediatek/mtk_star_emac.c:1296:2: note: remove the 'if' if its condition is always false if (!new_skb) { ^~~ drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:6: warning: variable 'new_dma_addr' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || ^~~~ drivers/net/ethernet/mediatek/mtk_star_emac.c:1321:23: note: uninitialized use occurs here desc_data.dma_addr = new_dma_addr; ^~~~ drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:2: note: remove the 'if' if its condition is always false if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || ^~~~ drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:6: warning: variable 'new_dma_addr' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized] if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || ^ drivers/net/ethernet/mediatek/mtk_star_emac.c:1321:23: note: uninitialized use occurs here desc_data.dma_addr = new_dma_addr; ^~~~ drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:6: note: remove the '||' if its condition is always false if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || ^~~~ drivers/net/ethernet/mediatek/mtk_star_emac.c:1274:25: note: initialize the variable 'new_dma_addr' to silence this warning dma_addr_t new_dma_addr; ^ = 0 3 warnings generated. > +static int mtk_star_receive_packet(struct mtk_star_priv *priv) > +{ > + struct mtk_star_ring *ring = &priv->rx_ring; > + struct device *dev = mtk_star_get_dev(priv); > + struct mtk_star_ring_desc_data desc_data; > + struct net_device *ndev = priv->ndev; > + struct sk_buff *curr_skb, *new_skb; > + dma_addr_t new_dma_addr; Uninitialized here > + int ret; > + > + spin_lock(&priv->lock); > + ret = mtk_star_ring_pop_tail(ring, &desc_data); > + spin_unlock(&priv->lock); > + if (ret) > + return -1; > + > + curr_skb = desc_data.skb; > + > + if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || > + (desc_data.flags & MTK_STAR_DESC_BIT_RX_OSIZE)) { > + /* Error packet -> drop and reuse skb. */ > + new_skb = curr_skb; > + goto push_new_skb; this goto > + } > + > + /* Prepare new skb before receiving the current one. Reuse the current > + * skb if we fail at any point. > + */ > + new_skb = mtk_star_alloc_skb(ndev); > + if (!new_skb) { > + ndev->stats.rx_dropped++; > + new_skb = curr_skb; > + goto push_new_skb; and this goto > + } > + > + new_dma_addr = mtk_star_dma_map_rx(priv, new_skb); > + if (dma_mapping_error(dev, new_dma_addr)) { > + ndev->stats.rx_dropped++; > + dev_kfree_skb(new_skb); > + new_skb = curr_skb; > + netdev_err(ndev, "DMA mapping error of RX descriptor\n"); > + goto push_new_skb; > + } > + > + /* We can't fail anymore at this point: it's safe to unmap the skb. */ > + mtk_star_dma_unmap_rx(priv, &desc_data); > + > + skb_put(desc_data.skb, desc_data.len); > + desc_data.skb->ip_summed = CHECKSUM_NONE; > + desc_data.skb->protocol = eth_type_trans(desc_data.skb, ndev); > + desc_data.skb->dev = ndev; > + netif_receive_skb(desc_data.skb); > + > +push_new_skb: > + desc_data.dma_addr = new_dma_addr; assign it uninitialized here. > + desc_data.len = skb_tailroom(new_skb); > + desc_data.skb = new_skb; > + > + spin_lock(&priv->lock); > + mtk_star_ring_push_head_rx(ring, &desc_data); > + spin_unlock(&priv->lock); > + > + return 0; > +} I don't know if there should be a new label that excludes that assignment
Re: [PATCH v5 06/11] net: ethernet: mtk-star-emac: new driver
On Fri, May 22, 2020 at 05:06:34PM +0200, Matthias Brugger wrote: > > > On 22/05/2020 14:06, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > This adds the driver for the MediaTek STAR Ethernet MAC currently used > > on the MT8* SoC family. For now we only support full-duplex. > > MT85** SoC family, AFAIU it's not used on MT81** devices. Correct? > > > > > Signed-off-by: Bartosz Golaszewski > > --- > > drivers/net/ethernet/mediatek/Kconfig |7 + > > drivers/net/ethernet/mediatek/Makefile|1 + > > drivers/net/ethernet/mediatek/mtk_star_emac.c | 1678 + > > 3 files changed, 1686 insertions(+) > > create mode 100644 drivers/net/ethernet/mediatek/mtk_star_emac.c > > > > diff --git a/drivers/net/ethernet/mediatek/Kconfig > > b/drivers/net/ethernet/mediatek/Kconfig > > index 5079b8090f16..500c15e7ea4a 100644 > > --- a/drivers/net/ethernet/mediatek/Kconfig > > +++ b/drivers/net/ethernet/mediatek/Kconfig > > @@ -14,4 +14,11 @@ config NET_MEDIATEK_SOC > > This driver supports the gigabit ethernet MACs in the > > MediaTek SoC family. > > > > +config NET_MEDIATEK_STAR_EMAC > > + tristate "MediaTek STAR Ethernet MAC support" > > + select PHYLIB > > + help > > + This driver supports the ethernet MAC IP first used on > > + MediaTek MT85** SoCs. > > + > > endif #NET_VENDOR_MEDIATEK > > diff --git a/drivers/net/ethernet/mediatek/Makefile > > b/drivers/net/ethernet/mediatek/Makefile > > index 3362fb7ef859..3a777b4a6cd3 100644 > > --- a/drivers/net/ethernet/mediatek/Makefile > > +++ b/drivers/net/ethernet/mediatek/Makefile > > @@ -5,3 +5,4 @@ > > > > obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o > > mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o > > +obj-$(CONFIG_NET_MEDIATEK_STAR_EMAC) += mtk_star_emac.o > > diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c > > b/drivers/net/ethernet/mediatek/mtk_star_emac.c > > new file mode 100644 > > index ..789c77af501f > > --- /dev/null > > +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c > > @@ -0,0 +1,1678 @@ > > +// SPDX-License-Identifier: GPL-2.0-only > > +/* > > + * Copyright (c) 2020 MediaTek Corporation > > + * Copyright (c) 2020 BayLibre SAS > > + * > > + * Author: Bartosz Golaszewski > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define MTK_STAR_DRVNAME "mtk_star_emac" > > + > > +#define MTK_STAR_WAIT_TIMEOUT 300 > > +#define MTK_STAR_MAX_FRAME_SIZE1514 > > +#define MTK_STAR_SKB_ALIGNMENT 16 > > +#define MTK_STAR_NAPI_WEIGHT 64 > > +#define MTK_STAR_HASHTABLE_MC_LIMIT256 > > +#define MTK_STAR_HASHTABLE_SIZE_MAX512 > > + > > +/* Normally we'd use NET_IP_ALIGN but on arm64 its value is 0 and it > > doesn't > > + * work for this controller. > > + */ > > +#define MTK_STAR_IP_ALIGN 2 > > + > > +static const char *const mtk_star_clk_names[] = { "core", "reg", "trans" }; > > +#define MTK_STAR_NCLKS ARRAY_SIZE(mtk_star_clk_names) > > + > > +/* PHY Control Register 0 */ > > +#define MTK_STAR_REG_PHY_CTRL0 0x > > +#define MTK_STAR_BIT_PHY_CTRL0_WTCMD BIT(13) > > +#define MTK_STAR_BIT_PHY_CTRL0_RDCMD BIT(14) > > +#define MTK_STAR_BIT_PHY_CTRL0_RWOKBIT(15) > > +#define MTK_STAR_MSK_PHY_CTRL0_PREGGENMASK(12, 8) > > +#define MTK_STAR_OFF_PHY_CTRL0_PREG8 > > +#define MTK_STAR_MSK_PHY_CTRL0_RWDATA GENMASK(31, 16) > > +#define MTK_STAR_OFF_PHY_CTRL0_RWDATA 16 > > + > > +/* PHY Control Register 1 */ > > +#define MTK_STAR_REG_PHY_CTRL1 0x0004 > > +#define MTK_STAR_BIT_PHY_CTRL1_LINK_ST BIT(0) > > +#define MTK_STAR_BIT_PHY_CTRL1_AN_EN BIT(8) > > +#define MTK_STAR_OFF_PHY_CTRL1_FORCE_SPD 9 > > +#define MTK_STAR_VAL_PHY_CTRL1_FORCE_SPD_10M 0x00 > > +#define MTK_STAR_VAL_PHY_CTRL1_FORCE_SPD_100M 0x01 > > +#define MTK_STAR_VAL_PHY_CTRL1_FORCE_SPD_1000M 0x02 > > +#define MTK_STAR_BIT_PHY_CTRL1_FORCE_DPX BIT(11) > > +#define MTK_STAR_BIT_PHY_CTRL1_FORCE_FC_RX BIT(12) > > +#define MTK_STAR_BIT_PHY_CTRL1_FORCE_FC_TX BIT(13) > > + > > +/* MAC Configuration Register */ > > +#define MTK_STAR_REG_MAC_CFG 0x0008 > > +#define MTK_STAR_OFF_MAC_CFG_IPG 10 > > +#define MTK_STAR_VAL_MAC_CFG_IPG_96BIT GENMASK(4, 0) > > +#define MTK_STAR_BIT_MAC_CFG_MAXLEN_1522 BIT(16) > > +#define MTK_STAR_BIT_MAC_CFG_AUTO_PAD BIT(19) > > +#define MTK_STAR_BIT_MAC_CFG_CRC_STRIP BIT(20) > > +#define MTK_STAR_BIT_MAC_CFG_VLAN_STRIP
Re: [PATCH v5 06/11] net: ethernet: mtk-star-emac: new driver
pt., 22 maj 2020 o 17:06 Matthias Brugger napisał(a): > > > > On 22/05/2020 14:06, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > This adds the driver for the MediaTek STAR Ethernet MAC currently used > > on the MT8* SoC family. For now we only support full-duplex. > > MT85** SoC family, AFAIU it's not used on MT81** devices. Correct? > It's used on MT81**, MT83** and MT85**. What's wrong with the description anyway? Bart
Re: [PATCH v5 06/11] net: ethernet: mtk-star-emac: new driver
pt., 22 maj 2020 o 17:06 Matthias Brugger napisał(a): > > On 22/05/2020 14:06, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > This adds the driver for the MediaTek STAR Ethernet MAC currently used > > on the MT8* SoC family. For now we only support full-duplex. > > MT85** SoC family, AFAIU it's not used on MT81** devices. Correct? > MT81** and MT85** are very closely related. This IP is currently used on MT85**, MT81** and MT83**. It may be used in new designs in the future too. Bart
Re: [PATCH v5 06/11] net: ethernet: mtk-star-emac: new driver
On 22/05/2020 14:06, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > This adds the driver for the MediaTek STAR Ethernet MAC currently used > on the MT8* SoC family. For now we only support full-duplex. MT85** SoC family, AFAIU it's not used on MT81** devices. Correct? > > Signed-off-by: Bartosz Golaszewski > --- > drivers/net/ethernet/mediatek/Kconfig |7 + > drivers/net/ethernet/mediatek/Makefile|1 + > drivers/net/ethernet/mediatek/mtk_star_emac.c | 1678 + > 3 files changed, 1686 insertions(+) > create mode 100644 drivers/net/ethernet/mediatek/mtk_star_emac.c > > diff --git a/drivers/net/ethernet/mediatek/Kconfig > b/drivers/net/ethernet/mediatek/Kconfig > index 5079b8090f16..500c15e7ea4a 100644 > --- a/drivers/net/ethernet/mediatek/Kconfig > +++ b/drivers/net/ethernet/mediatek/Kconfig > @@ -14,4 +14,11 @@ config NET_MEDIATEK_SOC > This driver supports the gigabit ethernet MACs in the > MediaTek SoC family. > > +config NET_MEDIATEK_STAR_EMAC > + tristate "MediaTek STAR Ethernet MAC support" > + select PHYLIB > + help > + This driver supports the ethernet MAC IP first used on > + MediaTek MT85** SoCs. > + > endif #NET_VENDOR_MEDIATEK > diff --git a/drivers/net/ethernet/mediatek/Makefile > b/drivers/net/ethernet/mediatek/Makefile > index 3362fb7ef859..3a777b4a6cd3 100644 > --- a/drivers/net/ethernet/mediatek/Makefile > +++ b/drivers/net/ethernet/mediatek/Makefile > @@ -5,3 +5,4 @@ > > obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o > mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o > +obj-$(CONFIG_NET_MEDIATEK_STAR_EMAC) += mtk_star_emac.o > diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c > b/drivers/net/ethernet/mediatek/mtk_star_emac.c > new file mode 100644 > index ..789c77af501f > --- /dev/null > +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c > @@ -0,0 +1,1678 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (c) 2020 MediaTek Corporation > + * Copyright (c) 2020 BayLibre SAS > + * > + * Author: Bartosz Golaszewski > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define MTK_STAR_DRVNAME "mtk_star_emac" > + > +#define MTK_STAR_WAIT_TIMEOUT300 > +#define MTK_STAR_MAX_FRAME_SIZE 1514 > +#define MTK_STAR_SKB_ALIGNMENT 16 > +#define MTK_STAR_NAPI_WEIGHT 64 > +#define MTK_STAR_HASHTABLE_MC_LIMIT 256 > +#define MTK_STAR_HASHTABLE_SIZE_MAX 512 > + > +/* Normally we'd use NET_IP_ALIGN but on arm64 its value is 0 and it doesn't > + * work for this controller. > + */ > +#define MTK_STAR_IP_ALIGN2 > + > +static const char *const mtk_star_clk_names[] = { "core", "reg", "trans" }; > +#define MTK_STAR_NCLKS ARRAY_SIZE(mtk_star_clk_names) > + > +/* PHY Control Register 0 */ > +#define MTK_STAR_REG_PHY_CTRL0 0x > +#define MTK_STAR_BIT_PHY_CTRL0_WTCMD BIT(13) > +#define MTK_STAR_BIT_PHY_CTRL0_RDCMD BIT(14) > +#define MTK_STAR_BIT_PHY_CTRL0_RWOK BIT(15) > +#define MTK_STAR_MSK_PHY_CTRL0_PREG GENMASK(12, 8) > +#define MTK_STAR_OFF_PHY_CTRL0_PREG 8 > +#define MTK_STAR_MSK_PHY_CTRL0_RWDATAGENMASK(31, 16) > +#define MTK_STAR_OFF_PHY_CTRL0_RWDATA16 > + > +/* PHY Control Register 1 */ > +#define MTK_STAR_REG_PHY_CTRL1 0x0004 > +#define MTK_STAR_BIT_PHY_CTRL1_LINK_ST BIT(0) > +#define MTK_STAR_BIT_PHY_CTRL1_AN_EN BIT(8) > +#define MTK_STAR_OFF_PHY_CTRL1_FORCE_SPD 9 > +#define MTK_STAR_VAL_PHY_CTRL1_FORCE_SPD_10M 0x00 > +#define MTK_STAR_VAL_PHY_CTRL1_FORCE_SPD_100M0x01 > +#define MTK_STAR_VAL_PHY_CTRL1_FORCE_SPD_1000M 0x02 > +#define MTK_STAR_BIT_PHY_CTRL1_FORCE_DPX BIT(11) > +#define MTK_STAR_BIT_PHY_CTRL1_FORCE_FC_RX BIT(12) > +#define MTK_STAR_BIT_PHY_CTRL1_FORCE_FC_TX BIT(13) > + > +/* MAC Configuration Register */ > +#define MTK_STAR_REG_MAC_CFG 0x0008 > +#define MTK_STAR_OFF_MAC_CFG_IPG 10 > +#define MTK_STAR_VAL_MAC_CFG_IPG_96BIT GENMASK(4, 0) > +#define MTK_STAR_BIT_MAC_CFG_MAXLEN_1522 BIT(16) > +#define MTK_STAR_BIT_MAC_CFG_AUTO_PADBIT(19) > +#define MTK_STAR_BIT_MAC_CFG_CRC_STRIP BIT(20) > +#define MTK_STAR_BIT_MAC_CFG_VLAN_STRIP BIT(22) > +#define MTK_STAR_BIT_MAC_CFG_NIC_PD BIT(31) > + > +/* Flow-Control Configuration Register */ > +#define MTK_STAR_REG_FC_CFG 0x000c > +#define MTK_STAR_BIT_FC_CFG_BP_ENBIT(7) > +#define MTK_STAR_BIT_FC_CFG_UC_PAUSE_DIR BIT(8) > +#define MTK_STAR_OFF_FC_CFG_SEND_PAUSE_TH1