* [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips
@ 2026-07-24 7:36 Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 01/13] ax88179_178a: Fix endianness of pause watermark register Birger Koblitz
` (12 more replies)
0 siblings, 13 replies; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
This adds support for the current generation of ASIX network adapter chips,
which are based on the AX88179A. This includes the AX88179A/B (1GBit-PHY),
AX88772D/E (100MBit) and AX88279 (2.5GBit).
The AX179A-based chips all provide both a CDC-NCM compatible USB interface,
and a proprietary vendor interface with more features. By default, the
proprietary vendor interface is not active and Linux will load the CDC-NCM
driver to support the devices. If the ax88179_178a module is configured by
the OS to have precedence over CDC-NCM, then this driver will switch the
device to use the vendor interface, and the device will be controlled by
the ax88179_178a driver when the device is probed again after an automatic
reset of the device bringing up the vendor interface.
The following hardware was tested:
Delock 66046 2.5GBit adapter (AX88279, FW: 1.2.0.0)
TP-Link UE306 1GBit adapter (AX88179B, FW: 1.3.0.0)
Renkforce RF-4708614 1GBit adapter (AX88179A, FW: 1.0.4.0)
UGREEN CR110 100MBit adapter (AX88722E, FW: 1.3.0.0)
The driver supports the following features
- EEE
- TCP segmentation offload
- VLAN filtering/tagging offload
(NETIF_F_HW_VLAN_CTAG_FILTER, NETIF_F_HW_VLAN_CTAG_RX/TX)
- RX/TX checksum offload
- FC/Pause configuration
- EEPROM read access
The code is based on the ASIX 4.1.0 out-of-tree driver published under
the GPL,, the aqc111 driver which provides support for the AX88279A,
and some tracing of USB-transfers of the Windows-driver.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
Changes in v3:
- Add PHY drivers for the PHYs of the AX88179A-based controllers
- Use phylink for the AX88179A-based chips
- Link to v2: https://lore.kernel.org/r/20260708-ax88179a-v2-0-0800fedb2e16@birger-koblitz.de
Changes in v2:
- Correctly use net-next prefix
- Fix compilation issue in HW support patch
- Split MMD support patch into patches for EEE/new chip support
- Do not use ADVERTISE_RESV but private flag definition
- Fix pause configuration to keep track of settings when autoneg disabled
- Fix issue with unitialized variable reported by kernel test robot <lkp@intel.com>
- Avoid white-space changes
- Link to v1: https://lore.kernel.org/r/20260701-ax88179a-v1-0-13685df67515@birger-koblitz.de
---
Birger Koblitz (13):
ax88179_178a: Fix endianness of pause watermark register
ax88179_178a: Add HW support for AX179A-based chips
ax88179_178a: Use MMD accessor functions for AX88179A
ax88179_178a: Add EEE HW configuration support for AX88179A
ax88179_178a: Use phylink in get/set_link_ksettings
ax88179_178a: EEE setup for AX88179A-based chips
ax88179_178a: Obtain speed and duplex from Interrupt URB
ax88179_178a: Add support for ethtool pause parameter configuration
ax88179_178a: Add VLAN offload support for AX88179A
ax88179_178a: Add ethtool get_drvinfo
ax88179_178a: Add support for AX88179A/772D/279 EEPROM access
ax88179_178a: Add AX179A/AX279 multicast configuration
ax88796b: Add support for AX88772D, AX88179A and AX88279
drivers/net/phy/ax88796b.c | 194 +++++
drivers/net/usb/ax88179_178a.c | 1596 ++++++++++++++++++++++++++++++++++++----
2 files changed, 1630 insertions(+), 160 deletions(-)
---
base-commit: 1a9edf8be190decb17227e3cba540513d93ebb85
change-id: 20260630-ax88179a-a1d89fe21730
Best regards,
--
Birger Koblitz <mail@birger-koblitz.de>
^ permalink raw reply [flat|nested] 34+ messages in thread
* [PATCH net-next v3 01/13] ax88179_178a: Fix endianness of pause watermark register
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 13:22 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 02/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
` (11 subsequent siblings)
12 siblings, 1 reply; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
The 16-bit pause watermark register is little endian as
described in the ASIX 4.1.0 out-of-tree driver. Correct the
register byte sequence but also swap the configuration values
used in the code in order to keep the current behaviour.
The endianness is relevant for 16-bit writes to the register.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 98f899ea2e9462f1ba99281a875385241745458b..945c071dfd1d2f0816c779e1a401ac158adc8d99 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -32,8 +32,8 @@
#define AX_ACCESS_EEPROM 0x04
#define AX_ACCESS_EFUS 0x05
#define AX_RELOAD_EEPROM_EFUSE 0x06
-#define AX_PAUSE_WATERLVL_HIGH 0x54
-#define AX_PAUSE_WATERLVL_LOW 0x55
+#define AX_PAUSE_WATERLVL_LOW 0x54
+#define AX_PAUSE_WATERLVL_HIGH 0x55
#define PHYSICAL_LINK_STATUS 0x02
#define AX_USB_SS 0x04
@@ -1617,11 +1617,10 @@ static int ax88179_reset(struct usbnet *dev)
dev->rx_urb_size = 1024 * 20;
*tmp = 0x34;
- ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp);
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, 1, 1, tmp);
*tmp = 0x52;
- ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH,
- 1, 1, tmp);
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp);
/* Enable checksum offload */
*tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 02/13] ax88179_178a: Add HW support for AX179A-based chips
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 01/13] ax88179_178a: Fix endianness of pause watermark register Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 16:22 ` Andrew Lunn
2026-07-24 16:37 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 03/13] ax88179_178a: Use MMD accessor functions for AX88179A Birger Koblitz
` (10 subsequent siblings)
12 siblings, 2 replies; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
This adds bindings and HW support for AX179A-based USB-Ethernet
controllers. The AX179A-family of chips consists of the
AX88279 (2.5GBit PHY)
AX88179A/B (1GBit PHY, B variant has wider temperature range)
AX772D/E (100Mbit PHY)
The controllers all have the same vendor and device ID
(0x0b95, 0x1790) and are distinguished by their BCD device versions,
which are
2.00 AX88179A/B
3.00 AX88772D/E
4.00 AX88279
For all chips, the driver calls the same ax88179a_bind() function
and the chips are then distinguished by the chip version and
BCD device ID. The AX179A-based chips all provide both a CDC-NCM
compatible USB interface, and a proprietary vendor interface. By default,
the proprietary vendor interface is not active and Linux will load the
CDC-NCM driver to support the devices. If the ax88179_178a module is
configured by the OS to have precedence over CDC-NCM, then this driver
will switch the device to use the vendor interface, and the device will
be controlled by the ax88179_178a driver when the device is probed again
after an automatic reset by the device.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 1159 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 1124 insertions(+), 35 deletions(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 945c071dfd1d2f0816c779e1a401ac158adc8d99..b90a75a11024c58192bdb4a9436636bc9312148c 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -11,8 +11,10 @@
#include <linux/usb.h>
#include <linux/crc32.h>
#include <linux/usb/usbnet.h>
+#include <linux/phylink.h>
#include <uapi/linux/mdio.h>
#include <linux/mdio.h>
+#include <linux/if_vlan.h>
#define AX88179_PHY_ID 0x03
#define AX_EEPROM_LEN 0x100
@@ -32,17 +34,30 @@
#define AX_ACCESS_EEPROM 0x04
#define AX_ACCESS_EFUS 0x05
#define AX_RELOAD_EEPROM_EFUSE 0x06
+#define AX88179A_WAKEUP_SETTING 0x07
+#define AX_FW_MODE 0x08
+#define AX88179A_FLASH_READ 0x21
+#define AX88179A_FLASH_WRITE 0x24
+#define AX88179A_PHY_CLAUSE45 0x27
+#define AX88179A_FLASH_ERASE_SECTION 0x28
+#define AX88179A_ACCESS_BL 0x2A
+#define AX88179A_PHY_POWER 0x31
+#define AX88179A_AUTODETACH 0xC0
#define AX_PAUSE_WATERLVL_LOW 0x54
#define AX_PAUSE_WATERLVL_HIGH 0x55
+#define AX_FW_MODE_179A 0x01
#define PHYSICAL_LINK_STATUS 0x02
#define AX_USB_SS 0x04
#define AX_USB_HS 0x02
+ #define AX_USB_FS 0x01
#define GENERAL_STATUS 0x03
/* Check AX88179 version. UA1:Bit2 = 0, UA2:Bit2 = 1 */
#define AX_SECLD 0x04
+#define AX_CHIP_STATUS 0x05
+
#define AX_SROM_ADDR 0x07
#define AX_SROM_CMD 0x0a
#define EEP_RD 0x04
@@ -62,6 +77,15 @@
#define AX_RX_CTL_PRO 0x0001
#define AX_RX_CTL_STOP 0x0000
+#define AX88179A_ETH_TX_GAP 0x0D
+
+#define AX88179A_BFM_DATA 0x0E
+ #define AX_TX_QUEUE_CFG 0x02
+ #define AX_TX_QUEUE_SET 0x08
+ #define AX_TX_Q1_AHB_FC_EN 0x10
+ #define AX_TX_Q2_AHB_FC_EN 0x20
+ #define AX_XGMII_EN 0x80
+
#define AX_NODE_ID 0x10
#define AX_MULFLTARY 0x16
@@ -91,6 +115,17 @@
#define AX_PHYPWR_RSTCTL_IPRL 0x0020
#define AX_PHYPWR_RSTCTL_AT 0x1000
+#define AX88179A_VLAN_ID_ADDRESS 0x2A
+
+#define AX88179A_VLAN_ID_CONTROL 0x2B
+ #define AX_VLAN_CONTROL_WE 0x0001
+ #define AX_VLAN_CONTROL_RD 0x0002
+ #define AX_VLAN_CONTROL_VSO 0x0010
+ #define AX_VLAN_CONTROL_VFE 0x0020
+
+#define AX88179A_VLAN_ID_DATA0 0x2C
+#define AX88179A_VLAN_ID_DATA1 0x2D
+
#define AX_RX_BULKIN_QCTRL 0x2e
#define AX_CLK_SELECT 0x33
#define AX_CLK_SELECT_BCS 0x01
@@ -111,7 +146,51 @@
#define AX_TXCOE_TCPV6 0x20
#define AX_TXCOE_UDPV6 0x40
+#define AX88179A_MAC_BM_INT_MASK 0x41
+#define AX88179A_MAC_BM_RX_DMA_CTL 0x43
+#define AX88179A_MAC_BM_TX_DMA_CTL 0x46
+
+#define AX88179A_MAC_RX_STATUS_CDC 0x6D
+ #define AX_LSOFC_WCNT_7_ACCESS 0x03
+ #define AX_GMII_CRC_APPEND 0x10
+
#define AX_LEDCTRL 0x73
+#define AX88179A_MAC_ARC_CTRL 0x9E
+#define AX88179A_MAC_SWP_CTRL 0xB1
+
+#define AX88179A_MAC_TX_PAUSE 0xB2
+
+#define AX88179A_MAC_CDC_DELAY_TX 0xB5
+
+#define AX88179A_MAC_PATH 0xB7
+ #define AX_MAC_RX_PATH_READY 0x01
+ #define AX_MAC_TX_PATH_READY 0x02
+
+#define AX88179A_NEW_PAUSE_CTRL 0xB8
+ #define AX_NEW_PAUSE_EN 0x01
+
+#define AX88179A_MAC_BULK_OUT_CTRL 0xB9
+ #define AX_MAC_EFF_EN 0x02
+
+#define AX88179A_MAC_RX_DATA_CDC_CNT 0xC0
+ #define AX_MAC_LSO_ERR_EN 0x04
+ #define AX_MAC_MIQFFCTRL_FORMAT 0x10
+ #define AX_MAC_MIQFFCTRL_DROP_CRC 0x20
+
+#define AX88179A_AUTODETACH_DELAY (5UL << 8)
+#define AX88179A_AUTODETACH_EN 1
+
+#define AX88179A_MAC_LSO_ENHANCE_CTRL 0xC3
+ #define AX_LSO_ENHANCE_EN 0x01
+
+#define AX88179A_MAC_TX_HDR_CKSUM 0xCC
+#define AX88179A_EP5_EHR 0xF9
+
+#define AX_PHY_POWER 0x02
+
+#define EPHY_LOW_POWER_EN 0x01
+#define S5_WOL_EN 0x04
+#define S5_WOL_LOW_POWER 0x20
#define GMII_PHY_PHYSR 0x11
#define GMII_PHY_PHYSR_SMASK 0xc000
@@ -164,8 +243,58 @@
#define GMII_PHY_PGSEL_PAGE3 0x0003
#define GMII_PHY_PGSEL_PAGE5 0x0005
+/* TX Descriptor */
+#define AX179A_TX_DESC_LEN_MASK 0x1FFFFF
+#define AX179A_TX_DESC_DROP_PADD BIT(28)
+#define AX179A_TX_DESC_VLAN BIT(29)
+#define AX179A_TX_DESC_MSS_MASK 0x7FFF
+#define AX179A_TX_DESC_MSS_SHIFT 0x20
+#define AX179A_TX_DESC_VLAN_MASK 0xFFFF
+#define AX179A_TX_DESC_VLAN_SHIFT 0x30
+
+/* RX Packet Descriptor */
+#define AX179A_RX_PD_L4_ERR BIT(0)
+#define AX179A_RX_PD_L3_ERR BIT(1)
+#define AX179A_RX_PD_L4_TYPE_MASK 0x1C
+#define AX179A_RX_PD_L4_UDP 0x04
+#define AX179A_RX_PD_L4_TCP 0x10
+#define AX179A_RX_PD_L3_TYPE_MASK 0x60
+#define AX179A_RX_PD_L3_IP 0x20
+#define AX179A_RX_PD_L3_IP6 0x40
+
+#define AX179A_RX_PD_VLAN BIT(10)
+#define AX179A_RX_PD_RX_OK BIT(11)
+#define AX179A_RX_PD_DROP BIT(31)
+#define AX179A_RX_PD_LEN_MASK 0x7FFF0000
+#define AX179A_RX_PD_LEN_SHIFT 0x10
+#define AX179A_RX_PD_VLAN_SHIFT 0x20
+
+/* RX Descriptor header */
+#define AX179A_RX_DH_PKT_CNT_MASK 0x1FFF
+#define AX179A_RX_DH_DESC_OFFSET_MASK 0xFFFFE000
+#define AX179A_RX_DH_DESC_OFFSET_SHIFT 0x0D
+
+#define AX179A_RX_HW_PAD 0x02
+
+#define AX_ADVERTISE_2500 0x1000
+
static int ax88179_reset(struct usbnet *dev);
+enum ax_ether_link_speed {
+ ETHER_LINK_NONE = 0,
+ ETHER_LINK_10 = 1,
+ ETHER_LINK_100 = 2,
+ ETHER_LINK_1000 = 3,
+ ETHER_LINK_2500 = 4,
+};
+
+enum ax_chip_version {
+ AX_VERSION_INVALID = 0x0,
+ AX_VERSION_AX88179 = 0x4,
+ AX_VERSION_AX88179A = 0x6, /* Also AX88772D */
+ AX_VERSION_AX88279 = 0x7,
+};
+
struct ax88179_data {
u8 eee_enabled;
u8 eee_active;
@@ -174,6 +303,23 @@ struct ax88179_data {
u32 wol_supported;
u32 wolopts;
u8 disconnecting;
+ u8 chip_version;
+ u8 fw_version[4];
+ u8 is_ax88772d;
+ u8 ip_align;
+ u8 link;
+ u8 speed;
+ u8 full_duplex;
+ bool pause_autoneg;
+ bool pause_tx;
+ bool pause_rx;
+ u8 rx_checksum;
+ u8 eeprom_read_cmd;
+ u16 eeprom_block;
+ struct mii_bus *mdio;
+ struct phy_device *phydev;
+ struct phylink *phylink;
+ struct phylink_config phylink_config;
};
struct ax88179_int_data {
@@ -181,15 +327,48 @@ struct ax88179_int_data {
__le32 intdata2;
};
-static const struct {
+struct ax_bulkin_settings {
unsigned char ctrl, timer_l, timer_h, size, ifg;
-} AX88179_BULKIN_SIZE[] = {
+};
+
+static const struct ax_bulkin_settings AX88179_BULKIN_SIZE[] = {
{7, 0x4f, 0, 0x12, 0xff},
{7, 0x20, 3, 0x16, 0xff},
{7, 0xae, 7, 0x18, 0xff},
{7, 0xcc, 0x4c, 0x18, 8},
};
+static const struct ax_bulkin_settings AX88179A_BULKIN_SIZE[] = {
+ {5, 0x7B, 0x00, 0x17, 0x0F}, /* 1G, SS */
+ {5, 0xC0, 0x02, 0x06, 0x0F}, /* 1G, HS */
+ {7, 0xF0, 0x00, 0x0C, 0x0F}, /* 100M, Full, SS */
+ {6, 0x00, 0x00, 0x06, 0x0F}, /* 100M, Half, SS */
+ {5, 0xC0, 0x04, 0x06, 0x0F}, /* 100M, Full, HS */
+ {7, 0xC0, 0x04, 0x06, 0x0F}, /* 100M, Half, HS */
+ {7, 0x00, 0x00, 0x03, 0x3F}, /* FS */
+};
+
+static const struct ax_bulkin_settings AX88772D_BULKIN_SIZE[] = {
+ {0, 0x00, 0x00, 0x00, 0x00}, /* 1G, SS (unused) */
+ {0, 0x00, 0x00, 0x00, 0x00}, /* 1G, HS (unused) */
+ {0, 0x00, 0x00, 0x00, 0x00}, /* 100M, Full, SS (unused) */
+ {0, 0x00, 0x00, 0x00, 0x00}, /* 100M, Half, SS (unused) */
+ {5, 0xC0, 0x04, 0x06, 0x0F}, /* 100M, Full, HS */
+ {7, 0xC0, 0x04, 0x06, 0x0F}, /* 100M, Half, HS */
+ {7, 0x00, 0x00, 0x03, 0x3F}, /* FS */
+};
+
+static const struct ax_bulkin_settings AX88279_BULKIN_SIZE[] = {
+ {5, 0x10, 0x01, 0x11, 0x0F}, /* 2.5G */
+ {7, 0xB3, 0x01, 0x11, 0x0F}, /* 1G, SS */
+ {7, 0xC0, 0x02, 0x06, 0x0F}, /* 1G, HS */
+ {7, 0x80, 0x01, 0x03, 0x0F}, /* 100M, Full, SS */
+ {7, 0x80, 0x01, 0x03, 0x0F}, /* 100M, Half, SS */
+ {7, 0x80, 0x01, 0x03, 0x0F}, /* 100M, Full, HS */
+ {7, 0x80, 0x01, 0x03, 0x0F}, /* 100M, Half, HS */
+ {7, 0x00, 0x00, 0x03, 0x3F}, /* FS */
+};
+
static void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode)
{
struct ax88179_data *ax179_data = dev->driver_priv;
@@ -349,6 +528,37 @@ static void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc,
ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res);
}
+static int ax88179_mdiobus_read(struct mii_bus *bus, int phy_id, int regnum)
+{
+ struct usbnet *dev = bus->priv;
+ struct ax88179_data *priv;
+ u16 res;
+
+ priv = dev->driver_priv;
+ /* When reading PHYSID, return unused PHY-IDs from the ASIX vendor range */
+ if (phy_id == AX88179_PHY_ID && regnum == MII_PHYSID1)
+ return 0x003b;
+ if (phy_id == AX88179_PHY_ID && regnum == MII_PHYSID2) {
+ if (priv->chip_version == AX_VERSION_AX88179A && priv->is_ax88772d)
+ return 0x772d;
+ else if (priv->chip_version == AX_VERSION_AX88179A)
+ return 0x179a;
+ else if (priv->chip_version == AX_VERSION_AX88279)
+ return 0x2790;
+ }
+
+ ax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)regnum, 2, &res);
+ return res;
+}
+
+static int ax88179_mdiobus_write(struct mii_bus *bus, int phy_id, int regnum, u16 val)
+{
+ struct usbnet *dev = bus->priv;
+ u16 res = (u16)val;
+
+ return ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)regnum, 2, &res);
+}
+
static inline int ax88179_phy_mmd_indirect(struct usbnet *dev, u16 prtad,
u16 devad)
{
@@ -403,6 +613,53 @@ ax88179_phy_write_mmd_indirect(struct usbnet *dev, u16 prtad, u16 devad,
return 0;
}
+static int ax_read_mmd(struct usbnet *dev, u16 dev_addr, u16 reg)
+{
+ struct ax88179_data *priv = dev->driver_priv;
+ u16 res;
+ int ret;
+
+ if (priv->chip_version >= AX_VERSION_AX88179A) {
+ ret = ax88179_read_cmd(dev, AX88179A_PHY_CLAUSE45, dev_addr, reg, 2, &res);
+ if (ret < 0)
+ return ret;
+ return res;
+ }
+
+ return ax88179_phy_read_mmd_indirect(dev, reg, dev_addr);
+}
+
+static int ax_write_mmd(struct usbnet *dev, u16 dev_addr, u16 reg, u16 data)
+{
+ struct ax88179_data *priv = dev->driver_priv;
+
+ if (priv->chip_version >= AX_VERSION_AX88179A)
+ return ax88179_write_cmd(dev, AX88179A_PHY_CLAUSE45, dev_addr, reg, 2, &data);
+
+ return ax88179_phy_write_mmd_indirect(dev, reg, dev_addr, data);
+}
+
+static int ax88179_mdiobus_read_c45(struct mii_bus *bus, int addr, int devnum, int regnum)
+{
+ struct usbnet *dev = bus->priv;
+
+ if (addr != AX88179_PHY_ID)
+ return -EINVAL;
+
+ return ax_read_mmd(dev, devnum, regnum);
+}
+
+static int ax88179_mdiobus_write_c45(struct mii_bus *bus, int addr, int devnum,
+ int regnum, u16 val)
+{
+ struct usbnet *dev = bus->priv;
+
+ if (addr != AX88179_PHY_ID)
+ return -EINVAL;
+
+ return ax_write_mmd(dev, devnum, regnum, val);
+}
+
static int ax88179_suspend(struct usb_interface *intf, pm_message_t message)
{
struct usbnet *dev = usb_get_intfdata(intf);
@@ -425,6 +682,29 @@ static int ax88179_suspend(struct usb_interface *intf, pm_message_t message)
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD,
1, 1, &tmp8);
+
+ if (priv->chip_version >= AX_VERSION_AX88179A) {
+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, &tmp16);
+ tmp16 |= AX_MEDIUM_RECEIVE_EN;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, &tmp16);
+ }
+
+ if (priv->chip_version == AX_VERSION_AX88279)
+ ax88179_write_cmd(dev, AX88179A_WAKEUP_SETTING, 8,
+ EPHY_LOW_POWER_EN | S5_WOL_EN
+ | S5_WOL_LOW_POWER | 0x8000, 0, NULL);
+
+ } else if (priv->chip_version == AX_VERSION_AX88279) {
+ ax88179_write_cmd(dev, AX88179A_WAKEUP_SETTING, 8, 0x8000, 0, NULL);
+ }
+
+ if (priv->chip_version >= AX_VERSION_AX88179A) {
+ rtnl_lock();
+ phylink_suspend(priv->phylink, !!priv->wolopts);
+ rtnl_unlock();
+ ax88179_write_cmd(dev, AX88179A_WAKEUP_SETTING, 0, EPHY_LOW_POWER_EN, 0, NULL);
+ ax88179_set_pm_mode(dev, false);
+ return 0;
}
/* Disable RX path */
@@ -456,12 +736,19 @@ static int ax88179_suspend(struct usb_interface *intf, pm_message_t message)
}
/* This function is used to enable the autodetach function. */
-/* This function is determined by offset 0x43 of EEPROM */
+/* This function is determined by offset 0x43 of EEPROM for the AX88179 */
static int ax88179_auto_detach(struct usbnet *dev)
{
+ struct ax88179_data *priv = dev->driver_priv;
u16 tmp16;
u8 tmp8;
+ if (priv->chip_version >= AX_VERSION_AX88179A) {
+ tmp16 = AX88179A_AUTODETACH_DELAY;
+ ax88179_write_cmd(dev, AX88179A_AUTODETACH, tmp16, 0, 0, NULL);
+ return 0;
+ }
+
if (ax88179_read_cmd(dev, AX_ACCESS_EEPROM, 0x43, 1, 2, &tmp16) < 0)
return 0;
@@ -484,15 +771,40 @@ static int ax88179_auto_detach(struct usbnet *dev)
static int ax88179_resume(struct usb_interface *intf)
{
struct usbnet *dev = usb_get_intfdata(intf);
+ struct ax88179_data *ax179_data;
+ u8 reg8;
+ ax179_data = dev->driver_priv;
ax88179_set_pm_mode(dev, true);
usbnet_link_change(dev, 0, 0);
+ if (ax179_data->chip_version >= AX_VERSION_AX88179A) {
+ ax88179_read_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, ®8);
+ if (!(reg8 & AX_PHY_POWER)) {
+ reg8 = AX_PHY_POWER;
+ ax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, ®8);
+ msleep(250);
+ }
+ ax88179_write_cmd(dev, AX_FW_MODE, AX_FW_MODE_179A, 0, 0, NULL);
+
+ /* Now, that AX_FW_MODE_179A is enabled, the PHY needs a power-cycle.
+ * PHY-power is re-enabled in ax88179_reset()
+ */
+ reg8 = 0;
+ ax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, ®8);
+ msleep(250);
+ }
+
ax88179_reset(dev);
ax88179_set_pm_mode(dev, false);
+ if (ax179_data->phylink) {
+ rtnl_lock();
+ phylink_resume(ax179_data->phylink);
+ rtnl_unlock();
+ }
return usbnet_resume(intf);
}
@@ -1293,6 +1605,17 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
dev->driver_priv = ax179_data;
+ ret = ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_CHIP_STATUS,
+ 1, 1, &ax179_data->chip_version);
+ if (ret < 0)
+ goto err_nodev;
+
+ ax179_data->chip_version = (ax179_data->chip_version & 0xf0) >> 4;
+ ax179_data->is_ax88772d = 0;
+ ax179_data->ip_align = 1;
+ ax179_data->eeprom_read_cmd = AX_ACCESS_EEPROM;
+ ax179_data->eeprom_block = 2;
+
dev->net->netdev_ops = &ax88179_netdev_ops;
dev->net->ethtool_ops = &ax88179_ethtool_ops;
dev->net->needed_headroom = 8;
@@ -1317,6 +1640,437 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
ax88179_reset(dev);
return 0;
+
+err_nodev:
+ kfree(ax179_data);
+ ax179_data = NULL;
+
+ return ret;
+}
+
+static void ax88179a_bulkin_config(struct usbnet *dev, u8 link_sts)
+{
+ struct ax88179_data *ax179_data = dev->driver_priv;
+ const struct ax_bulkin_settings *bulkin_data;
+ int index = 0;
+
+ switch (ax179_data->speed) {
+ case ETHER_LINK_2500: /* AX88279 only */
+ index = 0;
+ break;
+
+ case ETHER_LINK_1000: /* AX88279 & AX88178A */
+ if (ax179_data->chip_version == AX_VERSION_AX88279) {
+ if (link_sts & AX_USB_SS)
+ index = 1;
+ else if (link_sts & AX_USB_HS)
+ index = 2;
+ } else {
+ if (link_sts & AX_USB_SS)
+ index = 0;
+ else if (link_sts & AX_USB_HS)
+ index = 1;
+ }
+ break;
+
+ case ETHER_LINK_100:
+ if (ax179_data->chip_version == AX_VERSION_AX88279) {
+ if (link_sts & AX_USB_SS)
+ index = 3;
+ else if (link_sts & AX_USB_HS)
+ index = 5;
+ if (!ax179_data->full_duplex)
+ index++;
+ } else {
+ /* AX88279A & AX88277D */
+ if (link_sts & AX_USB_SS)
+ index = 2;
+ else if (link_sts & AX_USB_HS)
+ index = 4;
+ if (!ax179_data->full_duplex)
+ index++;
+ }
+ break;
+
+ case ETHER_LINK_10:
+ if (ax179_data->chip_version == AX_VERSION_AX88279)
+ index = 7;
+ else
+ index = 6;
+ break;
+
+ default: /* No link */
+ index = 0;
+ }
+
+ if (ax179_data->chip_version == AX_VERSION_AX88279 && (link_sts & AX_USB_FS))
+ index = 7;
+
+ if (ax179_data->chip_version == AX_VERSION_AX88279) {
+ bulkin_data = AX88279_BULKIN_SIZE;
+ } else {
+ if (ax179_data->is_ax88772d)
+ bulkin_data = AX88772D_BULKIN_SIZE;
+ else
+ bulkin_data = AX88179A_BULKIN_SIZE;
+ }
+
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, &bulkin_data[index]);
+}
+
+static void ax88179a_mdio_unregister(struct ax88179_data *data)
+{
+ mdiobus_unregister(data->mdio);
+ mdiobus_free(data->mdio);
+}
+
+static int ax88179a_init_phy(struct usbnet *dev)
+{
+ struct ax88179_data *data = dev->driver_priv;
+ int ret;
+
+ data->phydev = mdiobus_get_phy(data->mdio, AX88179_PHY_ID);
+ if (!data->phydev) {
+ netdev_err(dev->net, "Could not find PHY\n");
+ return -ENODEV;
+ }
+
+ ret = phylink_connect_phy(data->phylink, data->phydev);
+ if (ret) {
+ netdev_err(dev->net, "Could not connect PHY\n");
+ return ret;
+ }
+
+ phy_suspend(data->phydev);
+ data->phydev->mac_managed_pm = true;
+
+ phy_attached_info(data->phydev);
+
+ return 0;
+}
+
+static void ax88179a_mac_config(struct phylink_config *config, unsigned int mode,
+ const struct phylink_link_state *state)
+{
+ /* Nothing to do */
+}
+
+static void ax88179a_mac_link_down(struct phylink_config *config,
+ unsigned int mode, phy_interface_t interface)
+{
+ /* Nothing to do */
+}
+
+static void ax88179a_mac_link_up(struct phylink_config *config,
+ struct phy_device *phy,
+ unsigned int phy_mode, phy_interface_t interface,
+ int speed, int duplex,
+ bool tx_pause, bool rx_pause)
+{
+ struct usbnet *dev = netdev_priv(to_net_dev(config->dev));
+ struct ax88179_data *ax179_data = dev->driver_priv;
+ u8 tmp8, link_sts, reg8[3];
+ u16 tmp16, mode;
+
+ /* Stop RX/TX for link configuration */
+ tmp16 = AX_RX_CTL_STOP;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16);
+ tmp8 = 0;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_PATH, 1, 1, &tmp8);
+
+ tmp8 = 0xa5;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_CDC_DELAY_TX, 1, 1, &tmp8);
+
+ tmp16 = 0x0410;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 2, 2, &tmp16);
+
+ tmp8 = 0;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_ETH_TX_GAP, 1, 1, &tmp8);
+
+ tmp8 = 0x07;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_EP5_EHR, 1, 1, &tmp8);
+
+ tmp8 = 0x28 | AX_NEW_PAUSE_EN;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_NEW_PAUSE_CTRL, 1, 1, &tmp8);
+
+ mode = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | AX_MEDIUM_RXFLOW_CTRLEN;
+
+ switch (speed) {
+ case SPEED_2500:
+ reg8[0] = 0x00;
+ reg8[1] = 0xF8;
+ reg8[2] = 0x07;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_TX_PAUSE, 3, 3, reg8);
+
+ reg8[0] = 0x78;
+ reg8[1] = (AX_LSOFC_WCNT_7_ACCESS << 5);
+ reg8[2] = 0;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_STATUS_CDC, 3, 3, reg8);
+
+ reg8[0] = 0x40;
+ reg8[1] = AX_MAC_MIQFFCTRL_FORMAT | AX_MAC_MIQFFCTRL_DROP_CRC | AX_MAC_LSO_ERR_EN;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_DATA_CDC_CNT, 2, 2, reg8);
+
+ tmp8 = AX_XGMII_EN;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_BFM_DATA, 1, 1, &tmp8);
+
+ tmp8 = 0x1C | AX_LSO_ENHANCE_EN;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_LSO_ENHANCE_CTRL, 1, 1, &tmp8);
+
+ mode |= AX_MEDIUM_GIGAMODE | AX_MEDIUM_FULL_DUPLEX;
+
+ break;
+
+ case SPEED_1000:
+ mode |= AX_MEDIUM_GIGAMODE;
+ fallthrough;
+
+ case SPEED_100:
+ reg8[0] = 0x78;
+ reg8[1] = (AX_LSOFC_WCNT_7_ACCESS << 5) | AX_GMII_CRC_APPEND;
+ reg8[2] = 0;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_STATUS_CDC, 3, 3, reg8);
+
+ tmp8 = 0x40;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_DATA_CDC_CNT, 1, 1, &tmp8);
+ break;
+
+ case SPEED_10:
+ reg8[0] = 0xFA;
+ reg8[1] = (AX_LSOFC_WCNT_7_ACCESS << 5) | AX_GMII_CRC_APPEND;
+ reg8[2] = 0xFF;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_STATUS_CDC, 3, 3, reg8);
+
+ tmp8 = 0xFA;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_DATA_CDC_CNT, 1, 1, &tmp8);
+
+ speed = 10;
+ break;
+ }
+
+ ax88179_read_cmd(dev, AX_ACCESS_MAC, PHYSICAL_LINK_STATUS, 1, 1, &link_sts);
+ ax88179a_bulkin_config(dev, link_sts);
+
+ if (ax179_data->chip_version < AX_VERSION_AX88279) {
+ tmp8 = 0;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_BFM_DATA, 1, 1, &tmp8);
+ }
+
+ if (duplex)
+ mode |= AX_MEDIUM_FULL_DUPLEX;
+
+ if (dev->net->mtu > 1500)
+ mode |= AX_MEDIUM_JUMBO_EN;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, &mode);
+
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &ax179_data->rxctl);
+
+ tmp8 = AX_MAC_RX_PATH_READY | AX_MAC_TX_PATH_READY;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_PATH, 1, 1, &tmp8);
+
+ ax179_data->eee_enabled = ax88179_chk_eee(dev);
+
+ netif_carrier_on(dev->net);
+
+ netdev_info(dev->net, "ax88179a - Link status is: 1, Link speed: %d, Duplex: %d\n",
+ speed, duplex);
+}
+
+static const struct phylink_mac_ops ax88179a_phylink_mac_ops = {
+ .mac_config = ax88179a_mac_config,
+ .mac_link_down = ax88179a_mac_link_down,
+ .mac_link_up = ax88179a_mac_link_up,
+};
+
+static int ax88179a_phylink_setup(struct usbnet *dev)
+{
+ struct ax88179_data *data = dev->driver_priv;
+ phy_interface_t phy_if_mode;
+ struct phylink *phylink;
+
+ data->phylink_config.dev = &dev->net->dev;
+ data->phylink_config.type = PHYLINK_NETDEV;
+ data->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | MAC_100;
+ if (data->is_ax88772d)
+ data->phylink_config.mac_capabilities |= MAC_10;
+ else if (data->chip_version < AX_VERSION_AX88279)
+ data->phylink_config.mac_capabilities |= MAC_10 | MAC_1000;
+ else
+ data->phylink_config.mac_capabilities |= MAC_1000 | MAC_2500FD;
+
+ __set_bit(PHY_INTERFACE_MODE_INTERNAL,
+ data->phylink_config.supported_interfaces);
+ phy_if_mode = PHY_INTERFACE_MODE_INTERNAL;
+
+ phylink = phylink_create(&data->phylink_config, dev->net->dev.fwnode,
+ phy_if_mode, &ax88179a_phylink_mac_ops);
+ if (IS_ERR(phylink))
+ return PTR_ERR(phylink);
+
+ data->phylink = phylink;
+ return 0;
+}
+
+static int ax88179a_init_mdio(struct usbnet *dev)
+{
+ struct ax88179_data *data = dev->driver_priv;
+ int ret;
+
+ data->mdio = mdiobus_alloc();
+ if (!data->mdio)
+ return -ENOMEM;
+
+ data->mdio->priv = dev;
+ data->mdio->read = ax88179_mdiobus_read;
+ data->mdio->write = ax88179_mdiobus_write;
+ data->mdio->read_c45 = ax88179_mdiobus_read_c45;
+ data->mdio->write_c45 = ax88179_mdiobus_write_c45;
+ data->mdio->name = "AX88179A MDIO Bus";
+ data->mdio->phy_mask = ~(1 << AX88179_PHY_ID);
+ /* mii bus name is usb-<usb bus number>-<usb device number> */
+ snprintf(data->mdio->id, MII_BUS_ID_SIZE, "usb-%03d:%03d",
+ dev->udev->bus->busnum, dev->udev->devnum);
+
+ netdev_err(dev->net, "Registering MDIO bus\n");
+
+ ret = mdiobus_register(data->mdio);
+ if (ret) {
+ netdev_err(dev->net, "Could not register MDIO bus (err %d)\n", ret);
+ mdiobus_free(data->mdio);
+ data->mdio = NULL;
+ }
+
+ return ret;
+}
+
+static int ax88179a_bind(struct usbnet *dev, struct usb_interface *intf)
+{
+ struct usb_device *udev = interface_to_usbdev(intf);
+ struct ax88179_data *ax179_data;
+ int ret;
+ u8 reg8;
+
+ /* Check if vendor configuration */
+ if (udev->actconfig->desc.bConfigurationValue != 1) {
+ netdev_info(dev->net, "Switching to vendor mode\n");
+ usb_driver_set_configuration(udev, 1);
+ return -ENODEV;
+ }
+
+ ret = usbnet_get_endpoints(dev, intf);
+ if (ret < 0)
+ return ret;
+
+ ax179_data = kzalloc_obj(*ax179_data);
+ if (!ax179_data)
+ return -ENOMEM;
+
+ dev->driver_priv = ax179_data;
+
+ ret = ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_CHIP_STATUS,
+ 1, 1, &ax179_data->chip_version);
+ if (ret < 0)
+ goto err_nodev;
+
+ ax179_data->chip_version = (ax179_data->chip_version & 0xf0) >> 4;
+ ax179_data->is_ax88772d = 0;
+ if (ax179_data->chip_version == AX_VERSION_AX88179A) {
+ if (udev->descriptor.bcdDevice == 0x300)
+ ax179_data->is_ax88772d = 1;
+ }
+
+ for (int i = 0; i < 3; i++) {
+ ret = ax88179_read_cmd(dev, AX88179A_ACCESS_BL, (0xFD + i),
+ 1, 1, &ax179_data->fw_version[i]);
+ if (ret < 0)
+ ax179_data->fw_version[i] = 0xff;
+ }
+ netdev_info(dev->net, "AX88179A/279/772D Chip Version: %x, FW: %d.%d.%d.%d\n",
+ ax179_data->chip_version,
+ ax179_data->fw_version[0], ax179_data->fw_version[1],
+ ax179_data->fw_version[2], ax179_data->fw_version[3]);
+
+ /* The AX88279 requires both the AX_RX_CTL_IPE and AX_RX_CTL_DROPCRCERR
+ * bits set in AX_RX_CTL for creating correct RX-URBs. AX_RX_CTL_DROPCRCERR
+ * is anyway set for all chips, make sure AX_RX_CTL_IPE is set via ip_align.
+ * Also configure eeprom access parameters.
+ */
+ if (ax179_data->chip_version == AX_VERSION_AX88279) {
+ ax179_data->ip_align = 1;
+ ax179_data->eeprom_read_cmd = AX88179A_FLASH_READ;
+ ax179_data->eeprom_block = 256;
+ } else {
+ ax179_data->ip_align = 0;
+ ax179_data->eeprom_read_cmd = AX_ACCESS_EFUS;
+ ax179_data->eeprom_block = 20;
+ }
+
+ dev->net->netdev_ops = &ax88179_netdev_ops;
+ dev->net->ethtool_ops = &ax88179_ethtool_ops;
+ dev->net->needed_headroom = 8;
+ dev->net->needed_tailroom = 8;
+ dev->net->min_mtu = ETH_MIN_MTU;
+ dev->hard_mtu = 9 * 1024;
+ dev->net->max_mtu = dev->hard_mtu - dev->net->hard_header_len;
+
+ /* Initialize MII structure */
+ dev->mii.dev = dev->net;
+ dev->mii.mdio_read = ax88179_mdio_read;
+ dev->mii.mdio_write = ax88179_mdio_write;
+ dev->mii.phy_id_mask = 0xff;
+ dev->mii.reg_num_mask = 0xff;
+ dev->mii.phy_id = AX88179_PHY_ID;
+ if (!ax179_data->is_ax88772d)
+ dev->mii.supports_gmii = 1;
+
+ dev->net->features |= NETIF_F_SG | NETIF_F_IP_CSUM |
+ NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | NETIF_F_TSO |
+ NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
+ NETIF_F_HW_VLAN_CTAG_FILTER;
+
+ dev->net->hw_features |= dev->net->features;
+
+ dev->net->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM |
+ NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | NETIF_F_TSO;
+
+ netif_set_tso_max_size(dev->net, 16384);
+
+ /* Enable Transmission of Link Speed byte in interrupt URB */
+ ax88179_write_cmd(dev, AX_FW_MODE, AX_FW_MODE_179A, 0, 0, NULL);
+ ax88179_write_cmd(dev, AX_RELOAD_EEPROM_EFUSE, 0, 0, 0, NULL);
+
+ /* Read MAC address from DTB or ASIX chip */
+ ax88179_get_mac_addr(dev);
+ memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN);
+
+ /* Power PHY for probing */
+ reg8 = AX_PHY_POWER;
+ ax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, ®8);
+ msleep(250);
+
+ ret = ax88179a_init_mdio(dev);
+ if (ret)
+ goto err_nodev;
+
+ ret = ax88179a_phylink_setup(dev);
+ if (ret)
+ goto phylink_err;
+
+ ret = ax88179a_init_phy(dev);
+ if (ret)
+ goto initphy_err;
+
+ return 0;
+
+initphy_err:
+ phylink_destroy(ax179_data->phylink);
+phylink_err:
+ ax88179a_mdio_unregister(ax179_data);
+err_nodev:
+ kfree(ax179_data);
+ ax179_data = NULL;
+
+ return ret;
}
static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf)
@@ -1338,6 +2092,28 @@ static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf)
kfree(ax179_data);
}
+static void ax88179a_unbind(struct usbnet *dev, struct usb_interface *intf)
+{
+ struct ax88179_data *ax179_data = dev->driver_priv;
+ u16 tmp16;
+ u8 tmp8;
+
+ /* Configure RX control register => stop operation */
+ tmp16 = AX_RX_CTL_STOP;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16);
+
+ rtnl_lock();
+ phylink_disconnect_phy(ax179_data->phylink);
+ rtnl_unlock();
+ phylink_destroy(ax179_data->phylink);
+ ax88179a_mdio_unregister(ax179_data);
+
+ tmp8 = 0;
+ ax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, &tmp8);
+
+ kfree(ax179_data);
+}
+
static void
ax88179_rx_checksum(struct sk_buff *skb, u32 *pkt_hdr)
{
@@ -1354,6 +2130,21 @@ ax88179_rx_checksum(struct sk_buff *skb, u32 *pkt_hdr)
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
+static void ax88179a_rx_checksum(struct sk_buff *skb, u64 pkt_desc)
+{
+ u32 pkt_type;
+
+ skb->ip_summed = CHECKSUM_NONE;
+ /* checksum error bit is set */
+ if (pkt_desc & AX179A_RX_PD_L4_ERR || pkt_desc & AX179A_RX_PD_L3_ERR)
+ return;
+
+ pkt_type = pkt_desc & AX179A_RX_PD_L4_TYPE_MASK;
+ /* It must be a TCP or UDP packet with a valid checksum */
+ if (pkt_type == AX179A_RX_PD_L4_TCP || pkt_type == AX179A_RX_PD_L4_UDP)
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+}
+
static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
{
struct sk_buff *ax_skb;
@@ -1472,6 +2263,121 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
return 0;
}
+static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
+{
+ struct ax88179_data *ax179_data = dev->driver_priv;
+ struct sk_buff *ax_skb;
+ u32 hdr_off, pkt_end;
+ u64 *pkt_desc_ptr;
+ u16 vlan_tag;
+ u16 pkt_cnt;
+ u64 rx_hdr;
+
+ /* SKB contents for AX179A-based chips:
+ * <packet 1>
+ * ...
+ * <packet N>
+ * <per-packet metadata entry 1>
+ * ...
+ * <per-packet metadata entry N>
+ * <rx_hdr>
+ *
+ * where:
+ * <packet N> contains pkt_len data bytes and padding:
+ * 2 bytes of IP alignment (optional, depends on AX_RX_CTL_IPE flag)
+ * packet data received
+ * optional padding to 8-bytes boundary
+ * <per-packet metadata entry N> contains 8 bytes:
+ * pkt_len and fields AX_RXHDR_*
+ * <rx-hdr> contains 8 bytes:
+ * pkt_cnt and hdr_off (offset of <per-packet metadata entry 1>)
+ *
+ * pkt_cnt is number of entries in the per-packet metadata array.
+ */
+
+ if (!skb || skb->len < sizeof(rx_hdr))
+ goto err;
+
+ /* RX Descriptor Header */
+ skb_trim(skb, skb->len - sizeof(rx_hdr));
+ rx_hdr = le64_to_cpup((u64 *)skb_tail_pointer(skb));
+
+ /* Check these packets */
+ hdr_off = (rx_hdr & AX179A_RX_DH_DESC_OFFSET_MASK) >> AX179A_RX_DH_DESC_OFFSET_SHIFT;
+ pkt_cnt = rx_hdr & AX179A_RX_DH_PKT_CNT_MASK;
+
+ /* Consistency check header position */
+ if (hdr_off != skb->len - (pkt_cnt * sizeof(rx_hdr)))
+ goto err;
+
+ /* Make sure that the bounds of the metadata array are inside the SKB
+ * (and in front of the counter at the end).
+ */
+ if (pkt_cnt * 8 + hdr_off > skb->len)
+ goto err;
+
+ /* Packets must not overlap the metadata array */
+ skb_trim(skb, hdr_off);
+
+ if (!pkt_cnt)
+ goto err;
+
+ /* Get the first RX packet descriptor */
+ pkt_desc_ptr = (u64 *)(skb->data + hdr_off);
+
+ pkt_end = 0;
+ while (pkt_cnt--) {
+ u64 pkt_desc = le64_to_cpup(pkt_desc_ptr);
+ u32 pkt_len_plus_padd;
+ u32 pkt_len;
+
+ pkt_len = (u32)((pkt_desc & AX179A_RX_PD_LEN_MASK) >> AX179A_RX_PD_LEN_SHIFT)
+ - (ax179_data->ip_align ? 2 : 0);
+ pkt_len_plus_padd = ((pkt_len + 7 + (ax179_data->ip_align ? 2 : 0)) & 0x7FFF8);
+
+ pkt_end += pkt_len_plus_padd;
+ if (pkt_end > hdr_off || (pkt_cnt == 0 && pkt_end != hdr_off))
+ goto err;
+
+ if (pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK) ||
+ pkt_len > (dev->hard_mtu + AX179A_RX_HW_PAD)) {
+ skb_pull(skb, pkt_len_plus_padd);
+
+ /* Next RX Packet Descriptor */
+ pkt_desc_ptr++;
+ continue;
+ }
+
+ ax_skb = netdev_alloc_skb_ip_align(dev->net, pkt_len);
+ if (!ax_skb)
+ goto err;
+
+ skb_put(ax_skb, pkt_len);
+ memcpy(ax_skb->data, skb->data + (ax179_data->ip_align ? AX179A_RX_HW_PAD : 0),
+ pkt_len);
+
+ if (ax179_data->rx_checksum)
+ ax88179a_rx_checksum(ax_skb, pkt_desc);
+
+ if (pkt_desc & AX179A_RX_PD_VLAN) {
+ vlan_tag = pkt_desc >> AX179A_RX_PD_VLAN_SHIFT;
+ __vlan_hwaccel_put_tag(ax_skb, htons(ETH_P_8021Q),
+ vlan_tag & VLAN_VID_MASK);
+ }
+
+ usbnet_skb_return(dev, ax_skb);
+ skb_pull(skb, pkt_len_plus_padd);
+
+ /* Next RX Packet Header */
+ pkt_desc_ptr++;
+ }
+
+ return 1;
+
+err:
+ return 0;
+}
+
static struct sk_buff *
ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
{
@@ -1505,6 +2411,59 @@ ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
return skb;
}
+static struct sk_buff *
+ax88179a_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
+{
+ u64 tx_desc = skb->len & AX179A_TX_DESC_LEN_MASK;
+ int frame_size = dev->maxpacket;
+ struct sk_buff *ax_skb;
+ u64 *tx_desc_ptr;
+ int padding_size;
+ int headroom;
+ int tailroom;
+ u16 tci = 0;
+
+ /* TSO MSS */
+ tx_desc |= ((u64)(skb_shinfo(skb)->gso_size & AX179A_TX_DESC_MSS_MASK)) <<
+ AX179A_TX_DESC_MSS_SHIFT;
+
+ headroom = (skb->len + sizeof(tx_desc)) % 8;
+ padding_size = headroom ? 8 - headroom : 0;
+
+ if (((skb->len + sizeof(tx_desc) + padding_size) % frame_size) == 0) {
+ padding_size += 8;
+ tx_desc |= AX179A_TX_DESC_DROP_PADD;
+ }
+
+ if ((dev->net->features & NETIF_F_HW_VLAN_CTAG_TX) && (vlan_get_tag(skb, &tci) >= 0)) {
+ tx_desc |= AX179A_TX_DESC_VLAN;
+ tx_desc |= ((u64)tci & AX179A_TX_DESC_VLAN_MASK) << AX179A_TX_DESC_VLAN_SHIFT;
+ }
+
+ if (!dev->can_dma_sg && (dev->net->features & NETIF_F_SG) && skb_linearize(skb))
+ return NULL;
+
+ headroom = skb_headroom(skb);
+ tailroom = skb_tailroom(skb);
+
+ if (!(headroom >= sizeof(tx_desc) && tailroom >= padding_size)) {
+ ax_skb = skb_copy_expand(skb, sizeof(tx_desc), padding_size, flags);
+ dev_kfree_skb_any(skb);
+ skb = ax_skb;
+ if (!skb)
+ return NULL;
+ }
+ if (padding_size != 0)
+ skb_put_zero(skb, padding_size);
+ /* Copy TX header */
+ tx_desc_ptr = skb_push(skb, sizeof(tx_desc));
+ *tx_desc_ptr = cpu_to_le64(tx_desc);
+
+ usbnet_set_skb_tx_stats(skb, 1, 0);
+
+ return skb;
+}
+
static int ax88179_link_reset(struct usbnet *dev)
{
struct ax88179_data *ax179_data = dev->driver_priv;
@@ -1582,70 +2541,127 @@ static int ax88179_link_reset(struct usbnet *dev)
static int ax88179_reset(struct usbnet *dev)
{
- u8 buf[5];
- u16 *tmp16;
- u8 *tmp;
struct ax88179_data *ax179_data = dev->driver_priv;
struct ethtool_keee eee_data;
+ u16 *tmp16;
+ u8 buf[5];
+ u8 *tmp;
tmp16 = (u16 *)buf;
tmp = (u8 *)buf;
/* Power up ethernet PHY */
- *tmp16 = 0;
- ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16);
+ if (ax179_data->chip_version < AX_VERSION_AX88179A) {
+ *tmp16 = 0;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16);
+
+ *tmp16 = AX_PHYPWR_RSTCTL_IPRL;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16);
+ msleep(500);
- *tmp16 = AX_PHYPWR_RSTCTL_IPRL;
- ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16);
- msleep(500);
+ *tmp = AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, tmp);
+ msleep(200);
+ } else {
+ *tmp = AX_PHY_POWER;
+ ax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, tmp);
+ msleep(250);
+ }
- *tmp = AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS;
- ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, tmp);
- msleep(200);
+ if (ax179_data->chip_version == AX_VERSION_AX88279) {
+ *tmp16 = ax88179_mdio_read(dev->net, dev->mii.phy_id, MII_ADVERTISE);
+ *tmp16 &= ~(ADVERTISE_10FULL | ADVERTISE_10HALF);
+ *tmp16 |= AX_ADVERTISE_2500;
+ ax88179_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, *tmp16);
+ }
/* Ethernet PHY Auto Detach*/
ax88179_auto_detach(dev);
+ if (ax179_data->chip_version >= AX_VERSION_AX88179A) {
+ *tmp = AX_MAC_EFF_EN;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_BULK_OUT_CTRL, 1, 1, tmp);
+
+ *tmp16 = 0;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16);
+
+ *tmp = 0x04;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp);
+ *tmp = 0x10;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, 1, 1, tmp);
+
+ *tmp = 0;
+ if (dev->net->features & NETIF_F_HW_VLAN_CTAG_FILTER)
+ *tmp |= AX_VLAN_CONTROL_VFE;
+ if (dev->net->features & NETIF_F_HW_VLAN_CTAG_RX)
+ *tmp |= AX_VLAN_CONTROL_VSO;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, tmp);
+
+ *tmp = 0xff;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_BM_INT_MASK, 1, 1, tmp);
+
+ *tmp = 0;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_BM_RX_DMA_CTL, 1, 1, tmp);
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_BM_TX_DMA_CTL, 1, 1, tmp);
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_ARC_CTRL, 1, 1, tmp);
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_SWP_CTRL, 1, 1, tmp);
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_TX_HDR_CKSUM, 1, 1, tmp);
+ }
+
/* Read MAC address from DTB or asix chip */
ax88179_get_mac_addr(dev);
memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN);
/* RX bulk configuration */
- memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5);
- ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp);
-
- dev->rx_urb_size = 1024 * 20;
-
- *tmp = 0x34;
- ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, 1, 1, tmp);
-
- *tmp = 0x52;
- ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp);
+ if (ax179_data->chip_version < AX_VERSION_AX88179A) {
+ memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5);
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp);
+ *tmp = 0x34;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp);
+
+ *tmp = 0x52;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH,
+ 1, 1, tmp);
+ dev->rx_urb_size = 1024 * 20;
+ } else {
+ /* The Bulk-Register configuration for the AX88179A is done in
+ * ax88179a_link_reset(), once the link is up for a given link and USB-speed.
+ */
+ if (ax179_data->is_ax88772d)
+ dev->rx_urb_size = 1024 * 24;
+ else
+ dev->rx_urb_size = 1024 * 48;
+ }
/* Enable checksum offload */
*tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |
AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6;
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, tmp);
+ ax179_data->rx_checksum = 1;
*tmp = AX_TXCOE_IP | AX_TXCOE_TCP | AX_TXCOE_UDP |
AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6;
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp);
/* Configure RX control register => start operation */
- *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START |
- AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB;
- ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16);
-
- *tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL |
- AX_MONITOR_MODE_RWMP;
+ ax179_data->rxctl = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START |
+ AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB;
+ if (ax179_data->ip_align)
+ ax179_data->rxctl |= AX_RX_CTL_IPE;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &ax179_data->rxctl);
+
+ if (ax179_data->chip_version < AX_VERSION_AX88179A)
+ *tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL | AX_MONITOR_MODE_RWMP;
+ else
+ *tmp = AX_MONITOR_MODE_RWMP;
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, tmp);
/* Configure default medium type => giga */
*tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN |
- AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX |
- AX_MEDIUM_GIGAMODE;
- ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
- 2, 2, tmp16);
+ AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX;
+ if (!ax179_data->is_ax88772d)
+ *tmp16 |= AX_MEDIUM_GIGAMODE;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, tmp16);
/* Check if WoL is supported */
ax179_data->wol_supported = 0;
@@ -1653,7 +2669,11 @@ static int ax88179_reset(struct usbnet *dev)
1, 1, &tmp) > 0)
ax179_data->wol_supported = WAKE_MAGIC | WAKE_PHY;
- ax88179_led_setting(dev);
+ /* For chips starting with AX88179A, LEDS are configured by the adapter
+ * firmware directly from EEPROM/EFUSE values
+ */
+ if (ax179_data->chip_version < AX_VERSION_AX88179A)
+ ax88179_led_setting(dev);
ax179_data->eee_enabled = 0;
ax179_data->eee_active = 0;
@@ -1706,6 +2726,27 @@ static int ax88179_stop(struct usbnet *dev)
return 0;
}
+static int ax88179a_stop(struct usbnet *dev)
+{
+ struct ax88179_data *ax179_data = dev->driver_priv;
+ u16 reg16;
+ u8 reg8;
+
+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, ®16);
+ reg16 &= ~AX_MEDIUM_RECEIVE_EN;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, ®16);
+
+ reg16 = 0;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, ®16);
+
+ reg8 = 0;
+ ax88179_read_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, ®8);
+
+ phylink_stop(ax179_data->phylink);
+
+ return 0;
+}
+
static const struct driver_info ax88179_info = {
.description = "ASIX AX88179 USB 3.0 Gigabit Ethernet",
.bind = ax88179_bind,
@@ -1732,6 +2773,42 @@ static const struct driver_info ax88178a_info = {
.tx_fixup = ax88179_tx_fixup,
};
+static const struct driver_info ax88179a_info = {
+ .description = "ASIX AX88179A USB 3.2 Gigabit Ethernet",
+ .bind = ax88179a_bind,
+ .unbind = ax88179a_unbind,
+ .status = ax88179_status,
+ .reset = ax88179_reset,
+ .stop = ax88179a_stop,
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_MULTI_PACKET | FLAG_AVOID_UNLINK_URBS,
+ .rx_fixup = ax88179a_rx_fixup,
+ .tx_fixup = ax88179a_tx_fixup,
+};
+
+static const struct driver_info ax88772d_info = {
+ .description = "ASIX AX88772D/E USB 2.0 Fast Ethernet",
+ .bind = ax88179a_bind,
+ .unbind = ax88179a_unbind,
+ .status = ax88179_status,
+ .reset = ax88179_reset,
+ .stop = ax88179a_stop,
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_MULTI_PACKET | FLAG_AVOID_UNLINK_URBS,
+ .rx_fixup = ax88179a_rx_fixup,
+ .tx_fixup = ax88179a_tx_fixup,
+};
+
+static const struct driver_info ax88279_info = {
+ .description = "ASIX AX88279 USB 3.2 2.5Gigabit Ethernet",
+ .bind = ax88179a_bind,
+ .unbind = ax88179a_unbind,
+ .status = ax88179_status,
+ .reset = ax88179_reset,
+ .stop = ax88179a_stop,
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_MULTI_PACKET | FLAG_AVOID_UNLINK_URBS,
+ .rx_fixup = ax88179a_rx_fixup,
+ .tx_fixup = ax88179a_tx_fixup,
+};
+
static const struct driver_info cypress_GX3_info = {
.description = "Cypress GX3 SuperSpeed to Gigabit Ethernet Controller",
.bind = ax88179_bind,
@@ -1877,6 +2954,18 @@ static const struct driver_info at_umc2000sp_info = {
static const struct usb_device_id products[] = {
{
+ /* ASIX AX88179A/B USB 3.2 Gigabit Ethernet */
+ USB_DEVICE_VER(0x0b95, 0x1790, 0x0200, 0x0200),
+ .driver_info = (unsigned long)&ax88179a_info,
+}, {
+ /* ASIX AX88772D USB 2.0 100Mbit Ethernet */
+ USB_DEVICE_VER(0x0b95, 0x1790, 0x0300, 0x0300),
+ .driver_info = (unsigned long)&ax88772d_info,
+}, {
+ /* ASIX AX88279 USB 3.2 2.5GBit Ethernet */
+ USB_DEVICE_VER(0x0b95, 0x1790, 0x0400, 0x0400),
+ .driver_info = (unsigned long)&ax88279_info,
+}, {
/* ASIX AX88179 10/100/1000 */
USB_DEVICE_AND_INTERFACE_INFO(0x0b95, 0x1790, 0xff, 0xff, 0),
.driver_info = (unsigned long)&ax88179_info,
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 03/13] ax88179_178a: Use MMD accessor functions for AX88179A
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 01/13] ax88179_178a: Fix endianness of pause watermark register Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 02/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 13:25 ` Andrew Lunn
2026-07-24 16:44 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 04/13] ax88179_178a: Add EEE HW configuration support " Birger Koblitz
` (9 subsequent siblings)
12 siblings, 2 replies; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
The AX88179A uses a much simpler Clause-45 MMD access interface,
which are made available through ax_read_mmd() and ax_write_mmd(),
which in turn call the chips' respective implementation.
Make use of these functions for stract MMD read/write operations.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 39 +++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index b90a75a11024c58192bdb4a9436636bc9312148c..b7837c7a89f9b5ee520ef1ae91bbc7619d1a12bd 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -985,22 +985,19 @@ ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
int val;
/* Get Supported EEE */
- val = ax88179_phy_read_mmd_indirect(dev, MDIO_PCS_EEE_ABLE,
- MDIO_MMD_PCS);
+ val = ax_read_mmd(dev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
if (val < 0)
return val;
mii_eee_cap1_mod_linkmode_t(data->supported, val);
/* Get advertisement EEE */
- val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_ADV,
- MDIO_MMD_AN);
+ val = ax_read_mmd(dev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
if (val < 0)
return val;
mii_eee_cap1_mod_linkmode_t(data->advertised, val);
/* Get LP advertisement EEE */
- val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_LPABLE,
- MDIO_MMD_AN);
+ val = ax_read_mmd(dev, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE);
if (val < 0)
return val;
mii_eee_cap1_mod_linkmode_t(data->lp_advertised, val);
@@ -1013,8 +1010,7 @@ ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_keee *data)
{
u16 tmp16 = linkmode_to_mii_eee_cap1_t(data->advertised);
- return ax88179_phy_write_mmd_indirect(dev, MDIO_AN_EEE_ADV,
- MDIO_MMD_AN, tmp16);
+ return ax_write_mmd(dev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, tmp16);
}
static int ax88179_chk_eee(struct usbnet *dev)
@@ -1028,32 +1024,19 @@ static int ax88179_chk_eee(struct usbnet *dev)
int eee_lp, eee_cap, eee_adv;
u32 lp, cap, adv, supported = 0;
- eee_cap = ax88179_phy_read_mmd_indirect(dev,
- MDIO_PCS_EEE_ABLE,
- MDIO_MMD_PCS);
- if (eee_cap < 0) {
- priv->eee_active = 0;
+ eee_cap = ax_read_mmd(dev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
+ if (eee_cap < 0)
return false;
- }
cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap);
- if (!cap) {
- priv->eee_active = 0;
- return false;
- }
-
- eee_lp = ax88179_phy_read_mmd_indirect(dev,
- MDIO_AN_EEE_LPABLE,
- MDIO_MMD_AN);
- if (eee_lp < 0) {
- priv->eee_active = 0;
+ if (!cap)
return false;
- }
- eee_adv = ax88179_phy_read_mmd_indirect(dev,
- MDIO_AN_EEE_ADV,
- MDIO_MMD_AN);
+ eee_lp = ax_read_mmd(dev, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE);
+ if (eee_lp < 0)
+ return true;
+ eee_adv = ax_read_mmd(dev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
if (eee_adv < 0) {
priv->eee_active = 0;
return false;
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 04/13] ax88179_178a: Add EEE HW configuration support for AX88179A
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
` (2 preceding siblings ...)
2026-07-24 7:36 ` [PATCH net-next v3 03/13] ax88179_178a: Use MMD accessor functions for AX88179A Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 13:32 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings Birger Koblitz
` (8 subsequent siblings)
12 siblings, 1 reply; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
The AX88179A uses a much simpler HW configuration for EEE
via a single EEE configuration register. Add support for
this register and replace the EEE enable/disable functions
with a single EEE configuration function which enables/disables
EEE in the hardware.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 71 +++++++++++++++++++-----------------------
1 file changed, 32 insertions(+), 39 deletions(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index b7837c7a89f9b5ee520ef1ae91bbc7619d1a12bd..2e2f96a97b8398ece7d70cf349c7db973959629f 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -36,6 +36,7 @@
#define AX_RELOAD_EEPROM_EFUSE 0x06
#define AX88179A_WAKEUP_SETTING 0x07
#define AX_FW_MODE 0x08
+#define AX_GPHY_CTL 0x0F
#define AX88179A_FLASH_READ 0x21
#define AX88179A_FLASH_WRITE 0x24
#define AX88179A_PHY_CLAUSE45 0x27
@@ -127,6 +128,9 @@
#define AX88179A_VLAN_ID_DATA1 0x2D
#define AX_RX_BULKIN_QCTRL 0x2e
+
+#define AX_GPHY_EEE_CTRL 0x01
+
#define AX_CLK_SELECT 0x33
#define AX_CLK_SELECT_BCS 0x01
#define AX_CLK_SELECT_ACS 0x02
@@ -1061,46 +1065,35 @@ static int ax88179_chk_eee(struct usbnet *dev)
return false;
}
-static void ax88179_disable_eee(struct usbnet *dev)
-{
- u16 tmp16;
-
- tmp16 = GMII_PHY_PGSEL_PAGE3;
- ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
- GMII_PHY_PAGE_SELECT, 2, &tmp16);
-
- tmp16 = 0x3246;
- ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
- MII_PHYADDR, 2, &tmp16);
-
- tmp16 = GMII_PHY_PGSEL_PAGE0;
- ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
- GMII_PHY_PAGE_SELECT, 2, &tmp16);
-}
-
-static void ax88179_enable_eee(struct usbnet *dev)
+static void ax88179_eee_config(struct usbnet *dev, bool enable)
{
+ struct ax88179_data *priv = dev->driver_priv;
u16 tmp16;
- tmp16 = GMII_PHY_PGSEL_PAGE3;
- ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
- GMII_PHY_PAGE_SELECT, 2, &tmp16);
-
- tmp16 = 0x3247;
- ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
- MII_PHYADDR, 2, &tmp16);
-
- tmp16 = GMII_PHY_PGSEL_PAGE5;
- ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
- GMII_PHY_PAGE_SELECT, 2, &tmp16);
-
- tmp16 = 0x0680;
- ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
- MII_BMSR, 2, &tmp16);
+ if (priv->chip_version < AX_VERSION_AX88179A) {
+ tmp16 = GMII_PHY_PGSEL_PAGE3;
+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
+ GMII_PHY_PAGE_SELECT, 2, &tmp16);
+
+ tmp16 = enable ? 0x3247 : 0x3246;
+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
+ MII_PHYADDR, 2, &tmp16);
+ if (enable) {
+ tmp16 = GMII_PHY_PGSEL_PAGE5;
+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
+ GMII_PHY_PAGE_SELECT, 2, &tmp16);
+
+ tmp16 = 0x0680;
+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
+ MII_BMSR, 2, &tmp16);
+ }
- tmp16 = GMII_PHY_PGSEL_PAGE0;
- ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
- GMII_PHY_PAGE_SELECT, 2, &tmp16);
+ tmp16 = GMII_PHY_PGSEL_PAGE0;
+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
+ GMII_PHY_PAGE_SELECT, 2, &tmp16);
+ } else {
+ ax88179_write_cmd(dev, AX_GPHY_CTL, AX_GPHY_EEE_CTRL, enable, 0, NULL);
+ }
}
static int ax88179_get_eee(struct net_device *net, struct ethtool_keee *edata)
@@ -1122,13 +1115,13 @@ static int ax88179_set_eee(struct net_device *net, struct ethtool_keee *edata)
priv->eee_enabled = edata->eee_enabled;
if (!priv->eee_enabled) {
- ax88179_disable_eee(dev);
+ ax88179_eee_config(dev, false);
} else {
priv->eee_enabled = ax88179_chk_eee(dev);
if (!priv->eee_enabled)
return -EOPNOTSUPP;
- ax88179_enable_eee(dev);
+ ax88179_eee_config(dev, true);
}
ret = ax88179_ethtool_set_eee(dev, edata);
@@ -2661,7 +2654,7 @@ static int ax88179_reset(struct usbnet *dev)
ax179_data->eee_enabled = 0;
ax179_data->eee_active = 0;
- ax88179_disable_eee(dev);
+ ax88179_eee_config(dev, false);
ax88179_ethtool_get_eee(dev, &eee_data);
linkmode_zero(eee_data.advertised);
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
` (3 preceding siblings ...)
2026-07-24 7:36 ` [PATCH net-next v3 04/13] ax88179_178a: Add EEE HW configuration support " Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 13:38 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 06/13] ax88179_178a: EEE setup for AX88179A-based chips Birger Koblitz
` (7 subsequent siblings)
12 siblings, 1 reply; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
The PHYs in the AX179A-based USB-Ethernet controllers can be configured
via phylink. Use this for link configuration.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 2e2f96a97b8398ece7d70cf349c7db973959629f..136d1d39bf78658758d35372d4a9486e21befd87 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -967,9 +967,15 @@ ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
}
static int ax88179_get_link_ksettings(struct net_device *net,
- struct ethtool_link_ksettings *cmd)
+ struct ethtool_link_ksettings *cmd)
{
struct usbnet *dev = netdev_priv(net);
+ struct ax88179_data *data;
+
+ data = dev->driver_priv;
+
+ if (data->phylink)
+ return phy_ethtool_get_link_ksettings(net, cmd);
mii_ethtool_get_link_ksettings(&dev->mii, cmd);
@@ -980,6 +986,13 @@ static int ax88179_set_link_ksettings(struct net_device *net,
const struct ethtool_link_ksettings *cmd)
{
struct usbnet *dev = netdev_priv(net);
+ struct ax88179_data *data;
+
+ data = dev->driver_priv;
+
+ if (data->phylink)
+ return phy_ethtool_set_link_ksettings(net, cmd);
+
return mii_ethtool_set_link_ksettings(&dev->mii, cmd);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 06/13] ax88179_178a: EEE setup for AX88179A-based chips
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
` (4 preceding siblings ...)
2026-07-24 7:36 ` [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 16:31 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 07/13] ax88179_178a: Obtain speed and duplex from Interrupt URB Birger Koblitz
` (6 subsequent siblings)
12 siblings, 1 reply; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
Add EEE setup for AX88179A-based chips. For these
chips we enable EEE by default. Adapt the ax88179_chk_eee()
EEE status verification function to also support AX88179A-based
chips in order to make sure the initial setup leads to
a correctly identified EEE status.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 60 +++++++++++++++++++++++++++++-------------
1 file changed, 42 insertions(+), 18 deletions(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 136d1d39bf78658758d35372d4a9486e21befd87..8ea16d1231037832e12f74e2c5304ee4b7a54389 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -999,7 +999,17 @@ static int ax88179_set_link_ksettings(struct net_device *net,
static int
ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
{
- int val;
+ struct ax88179_data *ax179_data = dev->driver_priv;
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = {};
+ int val, ret;
+
+ if (ax179_data->phylink) {
+ ret = phylink_ethtool_get_eee(ax179_data->phylink, data);
+ /* AX88279 MAC does not support 2500Mbit EEE */
+ linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, mask);
+ linkmode_andnot(data->supported, data->supported, mask);
+ return ret;
+ }
/* Get Supported EEE */
val = ax_read_mmd(dev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
@@ -1025,9 +1035,14 @@ ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
static int
ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_keee *data)
{
- u16 tmp16 = linkmode_to_mii_eee_cap1_t(data->advertised);
+ struct ax88179_data *priv = dev->driver_priv;
+ u16 tmp16;
- return ax_write_mmd(dev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, tmp16);
+ if (priv->phylink)
+ return phylink_ethtool_set_eee(priv->phylink, data);
+
+ tmp16 = linkmode_to_mii_eee_cap2_t(data->advertised);
+ return ax_write_mmd(dev, MDIO_MMD_AN, MDIO_AN_EEE_ADV2, tmp16);
}
static int ax88179_chk_eee(struct usbnet *dev)
@@ -1037,6 +1052,7 @@ static int ax88179_chk_eee(struct usbnet *dev)
mii_ethtool_gset(&dev->mii, &ecmd);
+ priv->eee_active = 0;
if (ecmd.duplex & DUPLEX_FULL) {
int eee_lp, eee_cap, eee_adv;
u32 lp, cap, adv, supported = 0;
@@ -1054,10 +1070,8 @@ static int ax88179_chk_eee(struct usbnet *dev)
return true;
eee_adv = ax_read_mmd(dev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
- if (eee_adv < 0) {
- priv->eee_active = 0;
- return false;
- }
+ if (eee_adv < 0)
+ return true;
adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv);
lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp);
@@ -1065,16 +1079,13 @@ static int ax88179_chk_eee(struct usbnet *dev)
SUPPORTED_1000baseT_Full :
SUPPORTED_100baseT_Full;
- if (!(lp & adv & supported)) {
- priv->eee_active = 0;
- return false;
- }
+ if (!(lp & adv & supported))
+ return true;
priv->eee_active = 1;
return true;
}
- priv->eee_active = 0;
return false;
}
@@ -2667,14 +2678,27 @@ static int ax88179_reset(struct usbnet *dev)
ax179_data->eee_enabled = 0;
ax179_data->eee_active = 0;
- ax88179_eee_config(dev, false);
+ if (ax179_data->chip_version < AX_VERSION_AX88179A) {
+ ax88179_eee_config(dev, false);
- ax88179_ethtool_get_eee(dev, &eee_data);
- linkmode_zero(eee_data.advertised);
- ax88179_ethtool_set_eee(dev, &eee_data);
+ ax88179_ethtool_get_eee(dev, &eee_data);
+ linkmode_zero(eee_data.advertised);
+ ax88179_ethtool_set_eee(dev, &eee_data);
+ } else {
+ ax88179_eee_config(dev, true);
+ ax88179_ethtool_get_eee(dev, &eee_data);
+ linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, eee_data.advertised);
+ if (ax179_data->chip_version >= AX_VERSION_AX88279)
+ linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, eee_data.advertised);
+ ax88179_ethtool_set_eee(dev, &eee_data);
+ }
- /* Restart autoneg */
- mii_nway_restart(&dev->mii);
+ if (ax179_data->phylink) {
+ phylink_start(ax179_data->phylink);
+ } else {
+ /* Restart autoneg */
+ mii_nway_restart(&dev->mii);
+ }
usbnet_link_change(dev, 0, 0);
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 07/13] ax88179_178a: Obtain speed and duplex from Interrupt URB
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
` (5 preceding siblings ...)
2026-07-24 7:36 ` [PATCH net-next v3 06/13] ax88179_178a: EEE setup for AX88179A-based chips Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 17:01 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 08/13] ax88179_178a: Add support for ethtool pause parameter configuration Birger Koblitz
` (5 subsequent siblings)
12 siblings, 1 reply; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
For newer AX179A/772D firmwares and the AX88279, the
interrupt URB response also contains information on the Ethernet
speed and duplex status. Read this in order to use it to configure
the link.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 8ea16d1231037832e12f74e2c5304ee4b7a54389..02c015847eea3dfbdfa73f3d59a7d5b0dd1bc339 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -496,6 +496,7 @@ static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
static void ax88179_status(struct usbnet *dev, struct urb *urb)
{
+ struct ax88179_data *data = dev->driver_priv;
struct ax88179_int_data *event;
u32 link;
@@ -506,6 +507,9 @@ static void ax88179_status(struct usbnet *dev, struct urb *urb)
le32_to_cpus((void *)&event->intdata1);
link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16;
+ data->speed = (((__force u32)event->intdata1) >> 8) & 0x7;
+ data->full_duplex = (((__force u32)event->intdata1) >> 12) & 0x1;
+ data->link = link;
if (netif_carrier_ok(dev->net) != link) {
usbnet_link_change(dev, link, 1);
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 08/13] ax88179_178a: Add support for ethtool pause parameter configuration
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
` (6 preceding siblings ...)
2026-07-24 7:36 ` [PATCH net-next v3 07/13] ax88179_178a: Obtain speed and duplex from Interrupt URB Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 09/13] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
` (4 subsequent siblings)
12 siblings, 0 replies; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
The AX179A-based chips support pause parameter configuration.
Make it available through ethtool ops.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 02c015847eea3dfbdfa73f3d59a7d5b0dd1bc339..cc9a3ef4fa03ac36f89f78d2909a84d9b11d336c 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -314,9 +314,6 @@ struct ax88179_data {
u8 link;
u8 speed;
u8 full_duplex;
- bool pause_autoneg;
- bool pause_tx;
- bool pause_rx;
u8 rx_checksum;
u8 eeprom_read_cmd;
u16 eeprom_block;
@@ -1000,6 +997,29 @@ static int ax88179_set_link_ksettings(struct net_device *net,
return mii_ethtool_set_link_ksettings(&dev->mii, cmd);
}
+static void ax88179a_get_pauseparam(struct net_device *net, struct ethtool_pauseparam *pause)
+{
+ struct usbnet *dev = netdev_priv(net);
+ struct ax88179_data *data;
+
+ data = dev->driver_priv;
+
+ phylink_ethtool_get_pauseparam(data->phylink, pause);
+}
+
+static int ax88179a_set_pauseparam(struct net_device *net, struct ethtool_pauseparam *pause)
+{
+ struct usbnet *dev = netdev_priv(net);
+ struct ax88179_data *data;
+ int ret;
+
+ data = dev->driver_priv;
+
+ ret = phylink_ethtool_set_pauseparam(data->phylink, pause);
+
+ return ret;
+}
+
static int
ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
{
@@ -1177,6 +1197,8 @@ static const struct ethtool_ops ax88179_ethtool_ops = {
.nway_reset = usbnet_nway_reset,
.get_link_ksettings = ax88179_get_link_ksettings,
.set_link_ksettings = ax88179_set_link_ksettings,
+ .get_pauseparam = ax88179a_get_pauseparam,
+ .set_pauseparam = ax88179a_set_pauseparam,
.get_ts_info = ethtool_op_get_ts_info,
};
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 09/13] ax88179_178a: Add VLAN offload support for AX88179A
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
` (7 preceding siblings ...)
2026-07-24 7:36 ` [PATCH net-next v3 08/13] ax88179_178a: Add support for ethtool pause parameter configuration Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 10/13] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
` (3 subsequent siblings)
12 siblings, 0 replies; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
The AX88179A-based chips support VLAN offload. Add configuration
support in netdev_ops. Features supported are:
NETIF_F_HW_VLAN_CTAG_TX, NETIF_F_HW_VLAN_CTAG_RX
and NETIF_F_HW_VLAN_CTAG_FILTER.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 87 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index cc9a3ef4fa03ac36f89f78d2909a84d9b11d336c..d8617dad5990f38d39b4569a6347e219856c6f2a 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1202,6 +1202,62 @@ static const struct ethtool_ops ax88179_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};
+static int ax179a_vlan_rx_kill_vid(struct net_device *net, __be16 proto, u16 vid)
+{
+ struct usbnet *dev = netdev_priv(net);
+ u8 vlan_ctrl;
+ u16 reg16;
+ u8 reg8;
+
+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, ®8);
+ vlan_ctrl = reg8;
+
+ /* Address */
+ reg8 = (vid / 16);
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_ADDRESS, 1, 1, ®8);
+
+ /* Data */
+ reg8 = vlan_ctrl | AX_VLAN_CONTROL_RD;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, ®8);
+
+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, ®16);
+ reg16 &= ~(1 << (vid % 16));
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, ®16);
+
+ reg8 = vlan_ctrl | AX_VLAN_CONTROL_WE;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, ®8);
+
+ return 0;
+}
+
+static int ax179a_vlan_rx_add_vid(struct net_device *net, __be16 proto, u16 vid)
+{
+ struct usbnet *dev = netdev_priv(net);
+ u8 vlan_ctrl;
+ u16 reg16;
+ u8 reg8;
+
+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, ®8);
+ vlan_ctrl = reg8;
+
+ /* Address */
+ reg8 = (vid / 16);
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_ADDRESS, 1, 1, ®8);
+
+ /* Data */
+ reg8 = vlan_ctrl | AX_VLAN_CONTROL_RD;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, ®8);
+
+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, ®16);
+ reg16 |= (1 << (vid % 16));
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, ®16);
+
+ reg8 = vlan_ctrl | AX_VLAN_CONTROL_WE;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, ®8);
+
+ return 0;
+}
+
static void ax88179_set_multicast(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
@@ -1247,6 +1303,7 @@ ax88179_set_features(struct net_device *net, netdev_features_t features)
{
u8 tmp;
struct usbnet *dev = netdev_priv(net);
+ struct ax88179_data *data = dev->driver_priv;
netdev_features_t changed = net->features ^ features;
if (changed & NETIF_F_IP_CSUM) {
@@ -1266,6 +1323,34 @@ ax88179_set_features(struct net_device *net, netdev_features_t features)
tmp ^= AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |
AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6;
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp);
+ data->rx_checksum = !!(features & NETIF_F_RXCSUM);
+ }
+
+ if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) {
+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &tmp);
+ tmp ^= AX_VLAN_CONTROL_VFE;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &tmp);
+ if (features & NETIF_F_HW_VLAN_CTAG_FILTER) {
+ for (int i = 0; i < 256; i++) {
+ u16 tmp16 = 0;
+ /* Address */
+ tmp = i;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_ADDRESS,
+ 1, 1, &tmp);
+ /* Data */
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0,
+ 2, 2, &tmp16);
+ tmp = AX_VLAN_CONTROL_WE;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL,
+ 1, 1, &tmp);
+ }
+ }
+ }
+
+ if (changed & NETIF_F_HW_VLAN_CTAG_RX) {
+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &tmp);
+ tmp ^= AX_VLAN_CONTROL_VSO;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &tmp);
}
return 0;
@@ -1333,6 +1418,8 @@ static const struct net_device_ops ax88179_netdev_ops = {
.ndo_eth_ioctl = usbnet_mii_ioctl,
.ndo_set_rx_mode = ax88179_set_multicast,
.ndo_set_features = ax88179_set_features,
+ .ndo_vlan_rx_add_vid = ax179a_vlan_rx_add_vid,
+ .ndo_vlan_rx_kill_vid = ax179a_vlan_rx_kill_vid,
};
static int ax88179_check_eeprom(struct usbnet *dev)
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 10/13] ax88179_178a: Add ethtool get_drvinfo
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
` (8 preceding siblings ...)
2026-07-24 7:36 ` [PATCH net-next v3 09/13] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 11/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
` (2 subsequent siblings)
12 siblings, 0 replies; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
Add ax88179_get_drvinfo() as implementation of get_drvinfo, in order
to provide information about the device firmware.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index d8617dad5990f38d39b4569a6347e219856c6f2a..ae07bd1cf5eb1b15a089b3f67d2f89cf56c10f8f 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -827,6 +827,21 @@ static void ax88179_disconnect(struct usb_interface *intf)
usbnet_disconnect(intf);
}
+static void ax88179_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
+{
+ struct usbnet *dev = netdev_priv(net);
+ struct ax88179_data *priv = dev->driver_priv;
+
+ /* Inherit standard device info */
+ usbnet_get_drvinfo(net, info);
+ if (priv->chip_version < AX_VERSION_AX88179A)
+ return;
+
+ snprintf(info->fw_version, sizeof(info->fw_version), "%d.%d.%d.%d",
+ priv->fw_version[0], priv->fw_version[1],
+ priv->fw_version[2], priv->fw_version[3]);
+}
+
static void
ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
{
@@ -1184,6 +1199,7 @@ static int ax88179_set_eee(struct net_device *net, struct ethtool_keee *edata)
}
static const struct ethtool_ops ax88179_ethtool_ops = {
+ .get_drvinfo = ax88179_get_drvinfo,
.get_link = ethtool_op_get_link,
.get_msglevel = usbnet_get_msglevel,
.set_msglevel = usbnet_set_msglevel,
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 11/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
` (9 preceding siblings ...)
2026-07-24 7:36 ` [PATCH net-next v3 10/13] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 12/13] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
12 siblings, 0 replies; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
The AX88179A/772D devices have 32 efuses with 20 bytes each,
which can be randomly programmed. The AX88279 has 16K FLASH.
Provide ethtool read capability for these devices. However,
no write access is provided.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 74 +++++++++++++++++++++++++++++++++---------
1 file changed, 58 insertions(+), 16 deletions(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index ae07bd1cf5eb1b15a089b3f67d2f89cf56c10f8f..2b3393e7a3b2221b85bfb7c7b6b7ea6d92fc1deb 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -18,6 +18,8 @@
#define AX88179_PHY_ID 0x03
#define AX_EEPROM_LEN 0x100
+#define AX88279_EEPROM_LEN 0x4000
+#define AX88179A_EEPROM_LEN (32 * 20)
#define AX88179_EEPROM_MAGIC 0x17900b95
#define AX_MCAST_FLTSIZE 8
#define AX_MAX_MCAST 64
@@ -38,6 +40,8 @@
#define AX_FW_MODE 0x08
#define AX_GPHY_CTL 0x0F
#define AX88179A_FLASH_READ 0x21
+#define AX88179A_FLASH_WEN 0x22
+#define AX88179A_FLASH_WDIS 0x23
#define AX88179A_FLASH_WRITE 0x24
#define AX88179A_PHY_CLAUSE45 0x27
#define AX88179A_FLASH_ERASE_SECTION 0x28
@@ -868,41 +872,74 @@ ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
static int ax88179_get_eeprom_len(struct net_device *net)
{
- return AX_EEPROM_LEN;
+ struct usbnet *dev = netdev_priv(net);
+ struct ax88179_data *ax179_data;
+
+ ax179_data = dev->driver_priv;
+
+ if (ax179_data->chip_version < AX_VERSION_AX88179A)
+ return AX_EEPROM_LEN;
+ else if (ax179_data->chip_version >= AX_VERSION_AX88279)
+ return AX88279_EEPROM_LEN;
+ else
+ return AX88179A_EEPROM_LEN;
}
-static int
-ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
- u8 *data)
+static void
+ax88179_eeprom_access_params(struct ax88179_data *ax179_data, int i, u16 *value, u16 *idx)
+{
+ /* AX88179 has a word-addressable EEPROM
+ * AX88179A uses EFUSES with 20 bytes length
+ * AX88279 has an EEPROM addressable in 256 byte blocks
+ */
+ if (ax179_data->chip_version < AX_VERSION_AX88179A) {
+ *value = i;
+ *idx = 1;
+ } else if (ax179_data->chip_version >= AX_VERSION_AX88279) {
+ *value = (i * ax179_data->eeprom_block) >> 16;
+ *idx = (i * ax179_data->eeprom_block) & 0xffff;
+ } else {
+ *value = i << 4;
+ *idx = 0;
+ }
+}
+
+static int ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 *data)
{
struct usbnet *dev = netdev_priv(net);
- u16 *eeprom_buff;
- int first_word, last_word;
- int i, ret;
+ struct ax88179_data *ax179_data;
+ int first, last, i, ret;
+ u8 *eeprom_buff;
+
+ ax179_data = dev->driver_priv;
if (eeprom->len == 0)
return -EINVAL;
eeprom->magic = AX88179_EEPROM_MAGIC;
- first_word = eeprom->offset >> 1;
- last_word = (eeprom->offset + eeprom->len - 1) >> 1;
- eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
- GFP_KERNEL);
+ first = eeprom->offset / ax179_data->eeprom_block;
+ last = (eeprom->offset + eeprom->len - 1) / ax179_data->eeprom_block;
+
+ eeprom_buff = kzalloc((last - first + 1) * ax179_data->eeprom_block, GFP_KERNEL);
if (!eeprom_buff)
return -ENOMEM;
- /* ax88179/178A returns 2 bytes from eeprom on read */
- for (i = first_word; i <= last_word; i++) {
- ret = __ax88179_read_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2,
- &eeprom_buff[i - first_word]);
+ for (i = first; i <= last; i++) {
+ u16 value, idx;
+
+ ax88179_eeprom_access_params(ax179_data, i, &value, &idx);
+ ret = __ax88179_read_cmd(dev, ax179_data->eeprom_read_cmd,
+ value, idx, ax179_data->eeprom_block,
+ eeprom_buff + (i - first) * ax179_data->eeprom_block);
+
if (ret < 0) {
kfree(eeprom_buff);
return -EIO;
}
}
- memcpy(data, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len);
+ memcpy(data, eeprom_buff + eeprom->offset % ax179_data->eeprom_block, eeprom->len);
kfree(eeprom_buff);
return 0;
}
@@ -912,12 +949,17 @@ ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
u8 *data)
{
struct usbnet *dev = netdev_priv(net);
+ struct ax88179_data *ax179_data;
u16 *eeprom_buff;
int first_word;
int last_word;
int ret;
int i;
+ ax179_data = dev->driver_priv;
+ if (ax179_data->chip_version >= AX_VERSION_AX88179A)
+ return -EOPNOTSUPP;
+
netdev_dbg(net, "write EEPROM len %d, offset %d, magic 0x%x\n",
eeprom->len, eeprom->offset, eeprom->magic);
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 12/13] ax88179_178a: Add AX179A/AX279 multicast configuration
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
` (10 preceding siblings ...)
2026-07-24 7:36 ` [PATCH net-next v3 11/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
12 siblings, 0 replies; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
Add support for conditionally setting the ip_alignement flag
AX_RX_CTL_IPE in AX_RX_CTL and make sure that AX_RX_CTL_DROPCRCERR
is also set to be consistent with the initial configuration in
ax88179_reset()
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_178a.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 2b3393e7a3b2221b85bfb7c7b6b7ea6d92fc1deb..1e63d40de84364559a01d1fc02a652fcb7fa57e9 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1319,10 +1319,14 @@ static int ax179a_vlan_rx_add_vid(struct net_device *net, __be16 proto, u16 vid)
static void ax88179_set_multicast(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
- struct ax88179_data *data = dev->driver_priv;
u8 *m_filter = ((u8 *)dev->data);
+ struct ax88179_data *data;
+
+ data = dev->driver_priv;
- data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE);
+ data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR);
+ if (data->ip_align)
+ data->rxctl |= AX_RX_CTL_IPE;
if (net->flags & IFF_PROMISC) {
data->rxctl |= AX_RX_CTL_PRO;
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH net-next v3 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
` (11 preceding siblings ...)
2026-07-24 7:36 ` [PATCH net-next v3 12/13] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
@ 2026-07-24 7:36 ` Birger Koblitz
2026-07-24 13:51 ` Andrew Lunn
2026-07-24 17:18 ` Andrew Lunn
12 siblings, 2 replies; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 7:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Andrew Lunn, Heiner Kallweit
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
The AX88772D, AX88179A and AX88279 are 100MBit, 1GBit and respectively
2.5 GBit PHYs that are found in ASIX USB-Ethernet controllers of the
same name.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/phy/ax88796b.c | 194 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 194 insertions(+)
diff --git a/drivers/net/phy/ax88796b.c b/drivers/net/phy/ax88796b.c
index f20ddf64914993f7097070d1f56c1103ec1e40e8..871771fea64c9624ff78369084736db83350c846 100644
--- a/drivers/net/phy/ax88796b.c
+++ b/drivers/net/phy/ax88796b.c
@@ -13,6 +13,19 @@
#define PHY_ID_ASIX_AX88772A 0x003b1861
#define PHY_ID_ASIX_AX88772C 0x003b1881
#define PHY_ID_ASIX_AX88796B 0x003b1841
+#define PHY_ID_ASIX_AX88772D 0x003b772d
+#define PHY_ID_ASIX_AX88179A 0x003b179a
+#define PHY_ID_ASIX_AX88279 0x003b2790
+
+#define AX_ADVERTISE_2500 0x1000
+
+/* MII Vendor registers */
+#define AX_CTRL_STATUS 0x1d
+#define AX_CTRL_STATUS_SPEED_MASK 0x0c
+#define AX_CTRL_STATUS_SPEED_10 0x0
+#define AX_CTRL_STATUS_SPEED_100 0x4
+#define AX_CTRL_STATUS_SPEED_1000 0x8
+#define AX_CTRL_STATUS_SPEED_2500 0xc
MODULE_DESCRIPTION("Asix PHY driver");
MODULE_AUTHOR("Michael Schmitz <schmitzmic@gmail.com>");
@@ -83,6 +96,137 @@ static int asix_ax88772a_read_status(struct phy_device *phydev)
return 0;
}
+static int asix_ax88279_read_status(struct phy_device *phydev)
+{
+ int ret, val;
+
+ ret = genphy_update_link(phydev);
+ if (ret)
+ return ret;
+
+ phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED;
+ phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED;
+ phydev->speed = SPEED_UNKNOWN;
+ phydev->duplex = DUPLEX_UNKNOWN;
+ phydev->pause = 0;
+ phydev->asym_pause = 0;
+ phydev->rate_matching = RATE_MATCH_PAUSE;
+
+ if (!phydev->link)
+ return 0;
+
+ ret = genphy_read_master_slave(phydev);
+ if (ret < 0)
+ return ret;
+
+ ret = genphy_read_lpa(phydev);
+ if (ret < 0)
+ return ret;
+
+ val = phy_read(phydev, MII_ADVERTISE);
+ if (val < 0)
+ return val;
+
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
+ phydev->advertising, val & AX_ADVERTISE_2500);
+
+ /* Read actual speed from vendor register */
+ val = phy_read(phydev, AX_CTRL_STATUS);
+ switch (val & AX_CTRL_STATUS_SPEED_MASK) {
+ case AX_CTRL_STATUS_SPEED_2500:
+ phydev->speed = SPEED_2500;
+ break;
+ case AX_CTRL_STATUS_SPEED_1000:
+ phydev->speed = SPEED_1000;
+ break;
+ case AX_CTRL_STATUS_SPEED_100:
+ phydev->speed = SPEED_100;
+ break;
+ case AX_CTRL_STATUS_SPEED_10:
+ phydev->speed = SPEED_10;
+ }
+
+ /* MDIO_AN_10GBT_STAT_LP2_5G is broken, but we can deduce that
+ * the link-partner advertised 2500M if remotely AN succceded
+ * for link speed > 1000M and we locally have a link speed of
+ * 2500M
+ */
+ val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_STAT);
+ if (val >= 0 && val & MDIO_AN_10GBT_STAT_REMOK) {
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
+ phydev->lp_advertising,
+ phydev->speed == SPEED_2500);
+ }
+ /* Only supports full duplex */
+ phydev->duplex = DUPLEX_FULL;
+
+ return 0;
+}
+
+static int asix_ax88279_config_aneg(struct phy_device *phydev)
+{
+ bool changed = false;
+ int ret;
+ u32 adv;
+
+ if (phydev->autoneg == AUTONEG_DISABLE) {
+ phydev_warn(phydev, "Disabling autoneg is not supported\n");
+ return -EINVAL;
+ }
+
+ adv = linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising);
+
+ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
+ MDIO_AN_10GBT_CTRL_ADV2_5G, adv);
+ if (ret < 0)
+ return ret;
+ if (ret > 0)
+ changed = true;
+
+ return __genphy_config_aneg(phydev, changed);
+}
+
+static int asix_ax88279_get_features(struct phy_device *phydev)
+{
+ int ret;
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = {};
+
+ /* MDIO_DEVS1/2 empty, so set mmds_present bits to allow reading abilities */
+ phydev->c45_ids.mmds_present |= MDIO_DEVS_PMAPMD | MDIO_DEVS_AN;
+
+ linkmode_set_bit_array(phy_basic_ports_array, ARRAY_SIZE(phy_basic_ports_array),
+ phydev->supported);
+
+ ret = genphy_c45_pma_read_abilities(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* AX88279 does not support reported 100baseT-half duplex mode */
+ linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, mask);
+ linkmode_andnot(phydev->supported, phydev->supported, mask);
+
+ return 0;
+}
+
+/* AX88179A-based PHYs cannot access MMD registers via MII_MMD_CTRL/MII_MMD_DATA
+ * Make sure to use c45 access instead.
+ */
+static int asix_read_mmd(struct phy_device *phydev, int devnum, u16 reg)
+{
+ struct mii_bus *bus = phydev->mdio.bus;
+ int addr = phydev->mdio.addr;
+
+ return __mdiobus_c45_read(bus, addr, devnum, reg);
+}
+
+static int asix_write_mmd(struct phy_device *phydev, int devnum, u16 reg, u16 val)
+{
+ struct mii_bus *bus = phydev->mdio.bus;
+ int addr = phydev->mdio.addr;
+
+ return __mdiobus_c45_write(bus, addr, devnum, reg, val);
+}
+
static void asix_ax88772a_link_change_notify(struct phy_device *phydev)
{
/* Reset PHY, otherwise MII_LPA will provide outdated information.
@@ -94,6 +238,25 @@ static void asix_ax88772a_link_change_notify(struct phy_device *phydev)
}
}
+static int asix_ax88772D_get_features(struct phy_device *phydev)
+{
+ int ret;
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = {};
+
+ /* MDIO_DEVS1/2 empty, so set mmds_present bits to allow reading abilities */
+ phydev->c45_ids.mmds_present |= MDIO_DEVS_PMAPMD | MDIO_DEVS_AN;
+
+ ret = genphy_read_abilities(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* AX88772D does not support reported 1000baseT mode */
+ linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, mask);
+ linkmode_andnot(phydev->supported, phydev->supported, mask);
+
+ return 0;
+}
+
static struct phy_driver asix_driver[] = {
{
PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772A),
@@ -111,6 +274,34 @@ static struct phy_driver asix_driver[] = {
.suspend = genphy_suspend,
.resume = genphy_resume,
.soft_reset = asix_soft_reset,
+}, {
+ PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772D),
+ .name = "Asix Electronics AX88772D",
+ .flags = PHY_IS_INTERNAL,
+ .get_features = asix_ax88772D_get_features,
+ .read_mmd = asix_read_mmd,
+ .write_mmd = asix_write_mmd,
+ .suspend = genphy_suspend,
+ .resume = genphy_resume,
+}, {
+ PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88179A),
+ .name = "Asix Electronics AX88179A",
+ .flags = PHY_IS_INTERNAL,
+ .suspend = genphy_suspend,
+ .resume = genphy_resume,
+ .read_mmd = asix_read_mmd,
+ .write_mmd = asix_write_mmd,
+}, {
+ PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88279),
+ .name = "Asix Electronics AX88279",
+ .flags = PHY_IS_INTERNAL,
+ .get_features = asix_ax88279_get_features,
+ .read_status = asix_ax88279_read_status,
+ .config_aneg = asix_ax88279_config_aneg,
+ .read_mmd = asix_read_mmd,
+ .write_mmd = asix_write_mmd,
+ .suspend = genphy_suspend,
+ .resume = genphy_resume,
}, {
PHY_ID_MATCH_MODEL(PHY_ID_ASIX_AX88796B),
.name = "Asix Electronics AX88796B",
@@ -124,6 +315,9 @@ static const struct mdio_device_id __maybe_unused asix_tbl[] = {
{ PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772A) },
{ PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772C) },
{ PHY_ID_MATCH_MODEL(PHY_ID_ASIX_AX88796B) },
+ { PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772D) },
+ { PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88179A) },
+ { PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88279) },
{ }
};
--
2.47.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 01/13] ax88179_178a: Fix endianness of pause watermark register
2026-07-24 7:36 ` [PATCH net-next v3 01/13] ax88179_178a: Fix endianness of pause watermark register Birger Koblitz
@ 2026-07-24 13:22 ` Andrew Lunn
0 siblings, 0 replies; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 13:22 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
On Fri, Jul 24, 2026 at 09:36:44AM +0200, Birger Koblitz wrote:
> The 16-bit pause watermark register is little endian as
> described in the ASIX 4.1.0 out-of-tree driver. Correct the
> register byte sequence but also swap the configuration values
> used in the code in order to keep the current behaviour.
>
> The endianness is relevant for 16-bit writes to the register.
>
> Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 03/13] ax88179_178a: Use MMD accessor functions for AX88179A
2026-07-24 7:36 ` [PATCH net-next v3 03/13] ax88179_178a: Use MMD accessor functions for AX88179A Birger Koblitz
@ 2026-07-24 13:25 ` Andrew Lunn
2026-07-24 16:44 ` Andrew Lunn
1 sibling, 0 replies; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 13:25 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
On Fri, Jul 24, 2026 at 09:36:46AM +0200, Birger Koblitz wrote:
> The AX88179A uses a much simpler Clause-45 MMD access interface,
> which are made available through ax_read_mmd() and ax_write_mmd(),
> which in turn call the chips' respective implementation.
>
> Make use of these functions for stract MMD read/write operations.
>
> Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
I expect all this EEE code to go away once we have phylink code, and
phylib helpers accessing EEE registers. But as a step towards that,
this makes sense.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 04/13] ax88179_178a: Add EEE HW configuration support for AX88179A
2026-07-24 7:36 ` [PATCH net-next v3 04/13] ax88179_178a: Add EEE HW configuration support " Birger Koblitz
@ 2026-07-24 13:32 ` Andrew Lunn
0 siblings, 0 replies; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 13:32 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
On Fri, Jul 24, 2026 at 09:36:47AM +0200, Birger Koblitz wrote:
> The AX88179A uses a much simpler HW configuration for EEE
> via a single EEE configuration register. Add support for
> this register and replace the EEE enable/disable functions
> with a single EEE configuration function which enables/disables
> EEE in the hardware.
EEE is split between the MAC and the PHY. All the PHY parts will move
into the PHY driver when you convert to phylink.
It looks like this is about the PHY?
> +static void ax88179_eee_config(struct usbnet *dev, bool enable)
> {
> + struct ax88179_data *priv = dev->driver_priv;
> u16 tmp16;
>
> - tmp16 = GMII_PHY_PGSEL_PAGE3;
> - ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
> - GMII_PHY_PAGE_SELECT, 2, &tmp16);
> -
> - tmp16 = 0x3247;
> - ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
> - MII_PHYADDR, 2, &tmp16);
> -
> - tmp16 = GMII_PHY_PGSEL_PAGE5;
> - ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
> - GMII_PHY_PAGE_SELECT, 2, &tmp16);
> -
> - tmp16 = 0x0680;
> - ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
> - MII_BMSR, 2, &tmp16);
> + if (priv->chip_version < AX_VERSION_AX88179A) {
> + tmp16 = GMII_PHY_PGSEL_PAGE3;
> + ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
> + GMII_PHY_PAGE_SELECT, 2, &tmp16);
> +
> + tmp16 = enable ? 0x3247 : 0x3246;
> + ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
> + MII_PHYADDR, 2, &tmp16);
> + if (enable) {
> + tmp16 = GMII_PHY_PGSEL_PAGE5;
> + ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
> + GMII_PHY_PAGE_SELECT, 2, &tmp16);
> +
> + tmp16 = 0x0680;
> + ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
> + MII_BMSR, 2, &tmp16);
> + }
>
> - tmp16 = GMII_PHY_PGSEL_PAGE0;
> - ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
> - GMII_PHY_PAGE_SELECT, 2, &tmp16);
> + tmp16 = GMII_PHY_PGSEL_PAGE0;
> + ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
> + GMII_PHY_PAGE_SELECT, 2, &tmp16);
I would maybe put this into a helper. When this code gets moved in the
PHY driver it is probably going to be a function per PHY.
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings
2026-07-24 7:36 ` [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings Birger Koblitz
@ 2026-07-24 13:38 ` Andrew Lunn
2026-07-24 15:06 ` Birger Koblitz
0 siblings, 1 reply; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 13:38 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
On Fri, Jul 24, 2026 at 09:36:48AM +0200, Birger Koblitz wrote:
> The PHYs in the AX179A-based USB-Ethernet controllers can be configured
> via phylink. Use this for link configuration.
>
> Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
> ---
> drivers/net/usb/ax88179_178a.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
> index 2e2f96a97b8398ece7d70cf349c7db973959629f..136d1d39bf78658758d35372d4a9486e21befd87 100644
> --- a/drivers/net/usb/ax88179_178a.c
> +++ b/drivers/net/usb/ax88179_178a.c
> @@ -967,9 +967,15 @@ ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
> }
>
> static int ax88179_get_link_ksettings(struct net_device *net,
> - struct ethtool_link_ksettings *cmd)
> + struct ethtool_link_ksettings *cmd)
> {
> struct usbnet *dev = netdev_priv(net);
> + struct ax88179_data *data;
> +
> + data = dev->driver_priv;
> +
> + if (data->phylink)
When did this appear? Am i missing a patch somewhere?
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279
2026-07-24 7:36 ` [PATCH net-next v3 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
@ 2026-07-24 13:51 ` Andrew Lunn
2026-07-24 17:18 ` Andrew Lunn
1 sibling, 0 replies; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 13:51 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
> +static int asix_ax88279_read_status(struct phy_device *phydev)
> +{
> + int ret, val;
> +
> + ret = genphy_update_link(phydev);
> + if (ret)
> + return ret;
> +
> + phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED;
> + phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED;
> + phydev->speed = SPEED_UNKNOWN;
> + phydev->duplex = DUPLEX_UNKNOWN;
> + phydev->pause = 0;
> + phydev->asym_pause = 0;
Is it possible to call genphy_read_status(), and then do extra things?
That would save some code.
> +static int asix_ax88279_config_aneg(struct phy_device *phydev)
> +{
> + bool changed = false;
> + int ret;
> + u32 adv;
> +
> + if (phydev->autoneg == AUTONEG_DISABLE) {
> + phydev_warn(phydev, "Disabling autoneg is not supported\n");
> + return -EINVAL;
> + }
Does the PHY say it supports autoneg? genphy_read_abilities()? If it
does, you should clear the bit from supported.
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings
2026-07-24 13:38 ` Andrew Lunn
@ 2026-07-24 15:06 ` Birger Koblitz
2026-07-24 15:35 ` Andrew Lunn
0 siblings, 1 reply; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 15:06 UTC (permalink / raw)
To: Andrew Lunn
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
Thanks for reviewing the patch-series, Andrew!
On 7/24/26 15:38, Andrew Lunn wrote:
>> + if (data->phylink)
>
> When did this appear? Am i missing a patch somewhere?
>
In [PATCH net-next v3 02/13] ax88179_178a: Add HW support for AX179A-based chips:+ struct mii_bus *mdio;
+ struct phy_device *phydev;
+ struct phylink *phylink;
+ struct phylink_config phylink_config;
But admittedly, this is a rather big patch, which I was unable to break apart
due to in particular int ax88179a_bind() referencing most of the rest.
Birger
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings
2026-07-24 15:06 ` Birger Koblitz
@ 2026-07-24 15:35 ` Andrew Lunn
2026-07-24 15:53 ` Birger Koblitz
0 siblings, 1 reply; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 15:35 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
On Fri, Jul 24, 2026 at 05:06:07PM +0200, Birger Koblitz wrote:
>
> Thanks for reviewing the patch-series, Andrew!
> On 7/24/26 15:38, Andrew Lunn wrote:
> > > + if (data->phylink)
> >
> > When did this appear? Am i missing a patch somewhere?
> >
>
> In [PATCH net-next v3 02/13] ax88179_178a: Add HW support for AX179A-based chips:+ struct mii_bus *mdio;
> + struct phy_device *phydev;
> + struct phylink *phylink;
> + struct phylink_config phylink_config;
> But admittedly, this is a rather big patch, which I was unable to break apart
> due to in particular int ax88179a_bind() referencing most of the rest.
Ah, sorry. I took a quick look and assumed it was just adding new
devices.
Does it make sense to do the conversion without adding new devices?
That might make the patch smaller.
But i know converting to phylink often is one big patch. Sometimes you
can do some refactoring first to add helpers, but not always.
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings
2026-07-24 15:35 ` Andrew Lunn
@ 2026-07-24 15:53 ` Birger Koblitz
2026-07-24 16:25 ` Andrew Lunn
0 siblings, 1 reply; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 15:53 UTC (permalink / raw)
To: Andrew Lunn
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
On 7/24/26 17:35, Andrew Lunn wrote:
> On Fri, Jul 24, 2026 at 05:06:07PM +0200, Birger Koblitz wrote:
>>
>> Thanks for reviewing the patch-series, Andrew!
>> On 7/24/26 15:38, Andrew Lunn wrote:
>>>> + if (data->phylink)
>>>
>>> When did this appear? Am i missing a patch somewhere?
>>>
>>
>> In [PATCH net-next v3 02/13] ax88179_178a: Add HW support for AX179A-based chips:+ struct mii_bus *mdio;
>> + struct phy_device *phydev;
>> + struct phylink *phylink;
>> + struct phylink_config phylink_config;
>> But admittedly, this is a rather big patch, which I was unable to break apart
>> due to in particular int ax88179a_bind() referencing most of the rest.
>
> Ah, sorry. I took a quick look and assumed it was just adding new
> devices.
>
> Does it make sense to do the conversion without adding new devices?
> That might make the patch smaller.
Well, only the new devices use phylink, so it is not converting the existing
chips. That is why it likely needs to stay together. My handicap is really that I do not
have access to the older chips and from my experiences with writing the phy drivers,
it is absolutely necessary to have access to that for converting them since one
cannot make any assumptions about what is in the registers describing the PHY itself.
My hope is that the older devices can be also converted at a later point and then
remove all the MII stuff entirely.
Birger
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 02/13] ax88179_178a: Add HW support for AX179A-based chips
2026-07-24 7:36 ` [PATCH net-next v3 02/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
@ 2026-07-24 16:22 ` Andrew Lunn
2026-07-24 16:37 ` Andrew Lunn
1 sibling, 0 replies; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 16:22 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
> +static void ax88179a_mac_link_up(struct phylink_config *config,
> + struct phy_device *phy,
> + unsigned int phy_mode, phy_interface_t interface,
> + int speed, int duplex,
> + bool tx_pause, bool rx_pause)
> +{
> + ax179_data->eee_enabled = ax88179_chk_eee(dev);
With phylink, EEE works differently. You need to provide
.mac_disable_tx_lpi and .mac_enable_tx_lpi in phylink_mac_ops, and set
bp->phylink_config.lpi_capabilities etc. Take a look at
commit 0cc425f18f59f992c61c1802331d25ce689ff5d1
Author: Nicolai Buchwitz <nb@tipi-net.de>
Date: Wed Mar 4 11:54:29 2026 +0100
net: cadence: macb: implement EEE TX LPI support
and there are other examples.
> + netif_carrier_on(dev->net);
phylink devices never touch the carrier. Leave phylink to set it.
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings
2026-07-24 15:53 ` Birger Koblitz
@ 2026-07-24 16:25 ` Andrew Lunn
2026-07-24 17:02 ` Birger Koblitz
0 siblings, 1 reply; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 16:25 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
> Well, only the new devices use phylink, so it is not converting the existing
> chips.
O.K. I suggested you split the existing driver into two, a library of
code moving frames around, and then the glue to probe and use mii. You
can then add a new glue driver using phylink for the new devices.
I think it is a bad idea of have both phylink and mii for the same
device.
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 06/13] ax88179_178a: EEE setup for AX88179A-based chips
2026-07-24 7:36 ` [PATCH net-next v3 06/13] ax88179_178a: EEE setup for AX88179A-based chips Birger Koblitz
@ 2026-07-24 16:31 ` Andrew Lunn
0 siblings, 0 replies; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 16:31 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
> + if (ax179_data->phylink) {
> + ret = phylink_ethtool_get_eee(ax179_data->phylink, data);
> + /* AX88279 MAC does not support 2500Mbit EEE */
> + linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, mask);
> + linkmode_andnot(data->supported, data->supported, mask);
When you tell phylink the MACs EEE capabilities, this will go away.
> + return ret;
> + }
>
> /* Get Supported EEE */
> val = ax_read_mmd(dev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
> @@ -1025,9 +1035,14 @@ ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
> static int
> ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_keee *data)
> {
> - u16 tmp16 = linkmode_to_mii_eee_cap1_t(data->advertised);
> + struct ax88179_data *priv = dev->driver_priv;
> + u16 tmp16;
>
> - return ax_write_mmd(dev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, tmp16);
> + if (priv->phylink)
> + return phylink_ethtool_set_eee(priv->phylink, data);
> +
> + tmp16 = linkmode_to_mii_eee_cap2_t(data->advertised);
> + return ax_write_mmd(dev, MDIO_MMD_AN, MDIO_AN_EEE_ADV2, tmp16);
The phylib should do this. All the MAC driver needs is enable/disable
the LPI timer. Nothing more.
We have had lots of broken EEE implementations in MAC drivers. We
tried to solve this by moving as much as possible to core code. The
MAC drivers should now be KISS and much less likely to be broken.
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 02/13] ax88179_178a: Add HW support for AX179A-based chips
2026-07-24 7:36 ` [PATCH net-next v3 02/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-07-24 16:22 ` Andrew Lunn
@ 2026-07-24 16:37 ` Andrew Lunn
1 sibling, 0 replies; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 16:37 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
> +static void ax88179a_mac_link_up(struct phylink_config *config,
> + struct phy_device *phy,
> + unsigned int phy_mode, phy_interface_t interface,
> + int speed, int duplex,
> + bool tx_pause, bool rx_pause)
> +{
...
> +}
I don't see you doing anything with tx_pause and rx_pause.
This is another case where MAC drivers always got something wrong,
pause. We solved this by moving as much code into the core as
possible. You need to configure the hardware based on these two
values. Nothing more. KISS for MAC drivers.
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 03/13] ax88179_178a: Use MMD accessor functions for AX88179A
2026-07-24 7:36 ` [PATCH net-next v3 03/13] ax88179_178a: Use MMD accessor functions for AX88179A Birger Koblitz
2026-07-24 13:25 ` Andrew Lunn
@ 2026-07-24 16:44 ` Andrew Lunn
2026-07-24 17:07 ` Birger Koblitz
1 sibling, 1 reply; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 16:44 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
On Fri, Jul 24, 2026 at 09:36:46AM +0200, Birger Koblitz wrote:
> The AX88179A uses a much simpler Clause-45 MMD access interface,
> which are made available through ax_read_mmd() and ax_write_mmd(),
> which in turn call the chips' respective implementation.
>
> Make use of these functions for stract MMD read/write operations.
>
> Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
> ---
> drivers/net/usb/ax88179_178a.c | 39 +++++++++++----------------------------
> 1 file changed, 11 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
> index b90a75a11024c58192bdb4a9436636bc9312148c..b7837c7a89f9b5ee520ef1ae91bbc7619d1a12bd 100644
> --- a/drivers/net/usb/ax88179_178a.c
> +++ b/drivers/net/usb/ax88179_178a.c
> @@ -985,22 +985,19 @@ ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
> int val;
>
> /* Get Supported EEE */
> - val = ax88179_phy_read_mmd_indirect(dev, MDIO_PCS_EEE_ABLE,
> - MDIO_MMD_PCS);
> + val = ax_read_mmd(dev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
All these look to be standard EEE registers. phylib should be handling
this for you. Put a printk in genphy_c45_read_eee_cap1() and make sure
it is being called.
Basically, anything which is part of 802.3 clause 22 or clause 45
should have helpers in phylib, and in most cases, phylib itself will
take care of it. A MAC driver touching the PHY is generally a bad
design, a layer violation. So any driver using phylink or phylib, all
direct access to the PHY needs to be removed.
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 07/13] ax88179_178a: Obtain speed and duplex from Interrupt URB
2026-07-24 7:36 ` [PATCH net-next v3 07/13] ax88179_178a: Obtain speed and duplex from Interrupt URB Birger Koblitz
@ 2026-07-24 17:01 ` Andrew Lunn
0 siblings, 0 replies; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 17:01 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
> @@ -506,6 +507,9 @@ static void ax88179_status(struct usbnet *dev, struct urb *urb)
> le32_to_cpus((void *)&event->intdata1);
>
> link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16;
> + data->speed = (((__force u32)event->intdata1) >> 8) & 0x7;
> + data->full_duplex = (((__force u32)event->intdata1) >> 12) & 0x1;
> + data->link = link;
>
> if (netif_carrier_ok(dev->net) != link) {
> usbnet_link_change(dev, link, 1);
usbnet_link_change() calls netif_carrier_off(). With phylink, phylink
is in charge of the carrier.
I would also be careful with speed. What is it actually returning?
Think about when you turn autoneg off:
ethtool -s devname [speed N] [lanes N] [du‐
plex half|full] [port tp|aui|bnc|mii]
[mdix auto|on|off] [autoneg on|off]
If i do ethtool -s eth42 speed 100 autoneg off
The PHY does not have valid speed information in its advertise
registers. The LP values are probably also wrong. phylib will set the
speed the PHY is doing in its forced mode. Is the firmware clever
enough to understand this and return the correct thing?
The phylink link up callback will however tell you the truth. I would
trust it over firmware.
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings
2026-07-24 16:25 ` Andrew Lunn
@ 2026-07-24 17:02 ` Birger Koblitz
2026-07-24 18:22 ` Andrew Lunn
0 siblings, 1 reply; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 17:02 UTC (permalink / raw)
To: Andrew Lunn
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
On 7/24/26 18:25, Andrew Lunn wrote:
>> Well, only the new devices use phylink, so it is not converting the existing
>> chips.
>
> O.K. I suggested you split the existing driver into two, a library of
> code moving frames around, and then the glue to probe and use mii. You
> can then add a new glue driver using phylink for the new devices.
I replied to that earlier on. My argument was that the frame moving bits are
rather different since the older devices use 32 bit header structures, while
the newer ones use 64 and the structures also are somewhat different. The
library would contain rather a lot of duplicate functions that are specific to
the AX179 and AX179A.
Are you aware that the asix_devices.c and asix_common.c drivers do already
have this structure (including phylink), but target even older devices? And then,
there is a 3rd implementation of the ASIX frame moving, again a bit different,
in aqc111.c (no phylink). If one changes there aqc111_ to asix_ one gets basically
the same code as in asix_common at least for the USB stuff and similarities to the
code of ax88179_178a for the frame moving. I did not want to further contribute
to the mess, but it now looks like I do just that.
To summarize, you suggest to split ax88179_178a plus the new HW code into 3 parts:
- ax179_lib (frame moving, USB read/write support)
- ax179_devices (HW support for AX179-based chips using mii)
- ax179a_devices (HW support for AX179A based chips using phylink)
Does that change taking the other ASIX-code into account?
>
> I think it is a bad idea of have both phylink and mii for the same
> device.
I agree, but the argument would be that the mii stuff could go away eventually.
Birger
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 03/13] ax88179_178a: Use MMD accessor functions for AX88179A
2026-07-24 16:44 ` Andrew Lunn
@ 2026-07-24 17:07 ` Birger Koblitz
2026-07-24 17:27 ` Andrew Lunn
0 siblings, 1 reply; 34+ messages in thread
From: Birger Koblitz @ 2026-07-24 17:07 UTC (permalink / raw)
To: Andrew Lunn
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
On 7/24/26 18:44, Andrew Lunn wrote:
> On Fri, Jul 24, 2026 at 09:36:46AM +0200, Birger Koblitz wrote:
>> The AX88179A uses a much simpler Clause-45 MMD access interface,
>> which are made available through ax_read_mmd() and ax_write_mmd(),
>> which in turn call the chips' respective implementation.
>>
>> Make use of these functions for stract MMD read/write operations.
>>
>> Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
>> ---
>> drivers/net/usb/ax88179_178a.c | 39 +++++++++++----------------------------
>> 1 file changed, 11 insertions(+), 28 deletions(-)
>>
>> diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
>> index b90a75a11024c58192bdb4a9436636bc9312148c..b7837c7a89f9b5ee520ef1ae91bbc7619d1a12bd 100644
>> --- a/drivers/net/usb/ax88179_178a.c
>> +++ b/drivers/net/usb/ax88179_178a.c
>> @@ -985,22 +985,19 @@ ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
>> int val;
>>
>> /* Get Supported EEE */
>> - val = ax88179_phy_read_mmd_indirect(dev, MDIO_PCS_EEE_ABLE,
>> - MDIO_MMD_PCS);
>> + val = ax_read_mmd(dev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
>
> All these look to be standard EEE registers. phylib should be handling
> this for you. Put a printk in genphy_c45_read_eee_cap1() and make sure
> it is being called.
>
> Basically, anything which is part of 802.3 clause 22 or clause 45
> should have helpers in phylib, and in most cases, phylib itself will
> take care of it. A MAC driver touching the PHY is generally a bad
> design, a layer violation. So any driver using phylink or phylib, all
> direct access to the PHY needs to be removed.
>
This is again the existing code targeting the AX179, I just used the
new MMD accessor functions that target both architectures. I cannot convert
that with any confidence that it will work without having those devices.
One would need to write PHY drivers and use phylink to make the mess
go away.
Birger
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279
2026-07-24 7:36 ` [PATCH net-next v3 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-07-24 13:51 ` Andrew Lunn
@ 2026-07-24 17:18 ` Andrew Lunn
1 sibling, 0 replies; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 17:18 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
> +static int asix_ax88279_read_status(struct phy_device *phydev)
> +{
> + val = phy_read(phydev, MII_ADVERTISE);
> + if (val < 0)
> + return val;
> +
> + linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
> + phydev->advertising, val & AX_ADVERTISE_2500);
This looks wrong. A PHY driver should configure the hardware to
advertise what is in phydev->advertising. The PHY driver itself should
never change this value, especially in _read_status(). It is up to
user space to decide on what is advertised, and the phylib core will
sanitise the value to ensure it is within the PHYs capabilities.
> +static int asix_ax88279_config_aneg(struct phy_device *phydev)
> +{
> + bool changed = false;
> + int ret;
> + u32 adv;
> +
> + if (phydev->autoneg == AUTONEG_DISABLE) {
> + phydev_warn(phydev, "Disabling autoneg is not supported\n");
> + return -EINVAL;
> + }
> +
> + adv = linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising);
> +
> + ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
> + MDIO_AN_10GBT_CTRL_ADV2_5G, adv);
Can genphy_c45_an_config_aneg() be used here?
> +static int asix_ax88279_get_features(struct phy_device *phydev)
> +{
> + int ret;
> + __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = {};
> +
> + /* MDIO_DEVS1/2 empty, so set mmds_present bits to allow reading abilities */
> + phydev->c45_ids.mmds_present |= MDIO_DEVS_PMAPMD | MDIO_DEVS_AN;
I would do this in probe. If you do this early, phylib might be able
to call genphy_c45_pma_read_abilities() on its own. Maybe, i don't
know.
> + /* AX88279 does not support reported 100baseT-half duplex mode */
> + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, mask);
> + linkmode_andnot(phydev->supported, phydev->supported, mask);
If you are only changing one bit, it is simpler to use
linkmode_set_bit()/linkmode_clear_bit()
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 03/13] ax88179_178a: Use MMD accessor functions for AX88179A
2026-07-24 17:07 ` Birger Koblitz
@ 2026-07-24 17:27 ` Andrew Lunn
0 siblings, 0 replies; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 17:27 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
> > > - val = ax88179_phy_read_mmd_indirect(dev, MDIO_PCS_EEE_ABLE,
> > > - MDIO_MMD_PCS);
> > > + val = ax_read_mmd(dev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
> >
> > All these look to be standard EEE registers. phylib should be handling
> > this for you. Put a printk in genphy_c45_read_eee_cap1() and make sure
> > it is being called.
> >
> > Basically, anything which is part of 802.3 clause 22 or clause 45
> > should have helpers in phylib, and in most cases, phylib itself will
> > take care of it. A MAC driver touching the PHY is generally a bad
> > design, a layer violation. So any driver using phylink or phylib, all
> > direct access to the PHY needs to be removed.
> >
> This is again the existing code targeting the AX179, I just used the
> new MMD accessor functions that target both architectures. I cannot convert
> that with any confidence that it will work without having those devices.
> One would need to write PHY drivers and use phylink to make the mess
> go away.
This is where having a clean, separate driver will help.
You cannot have the MAC driver touching the PHY when using
phylink/phylib. You need to ensure none of this code is actually
used. And if it is not used, you don't need to touch it like this.
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings
2026-07-24 17:02 ` Birger Koblitz
@ 2026-07-24 18:22 ` Andrew Lunn
2026-07-25 3:59 ` Birger Koblitz
0 siblings, 1 reply; 34+ messages in thread
From: Andrew Lunn @ 2026-07-24 18:22 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
On Fri, Jul 24, 2026 at 07:02:48PM +0200, Birger Koblitz wrote:
>
> On 7/24/26 18:25, Andrew Lunn wrote:
> > > Well, only the new devices use phylink, so it is not converting the existing
> > > chips.
> >
> > O.K. I suggested you split the existing driver into two, a library of
> > code moving frames around, and then the glue to probe and use mii. You
> > can then add a new glue driver using phylink for the new devices.
> I replied to that earlier on. My argument was that the frame moving bits are
> rather different since the older devices use 32 bit header structures, while
> the newer ones use 64 and the structures also are somewhat different. The
> library would contain rather a lot of duplicate functions that are specific to
> the AX179 and AX179A.
>
> Are you aware that the asix_devices.c and asix_common.c drivers do already
> have this structure (including phylink), but target even older devices? And then,
> there is a 3rd implementation of the ASIX frame moving, again a bit different,
> in aqc111.c (no phylink). If one changes there aqc111_ to asix_ one gets basically
> the same code as in asix_common at least for the USB stuff and similarities to the
> code of ax88179_178a for the frame moving. I did not want to further contribute
> to the mess, but it now looks like I do just that.
Yes ASIX is a mess. It is lacking a Maintainer to look after it as a
whole, and say No to patches etc.
> To summarize, you suggest to split ax88179_178a plus the new HW code into 3 parts:
> - ax179_lib (frame moving, USB read/write support)
> - ax179_devices (HW support for AX179-based chips using mii)
> - ax179a_devices (HW support for AX179A based chips using phylink)
This seems like the best way to not make ax179 a worse of a mess.
When you look at what is actually needed for ax179a_devices, starting
from ax88179_178a.c and deleting stuff, there is not too much.
static void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode)
static int ax88179_in_pm(struct usbnet *dev)
static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
u16 size, void *data)
static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
u16 size, const void *data)
static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value,
u16 index, u16 size, void *data)
static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
u16 size, void *data)
static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
u16 size, const void *data)
All goes into the library.
I don't think
static void ax88179_status(struct usbnet *dev, struct urb *urb)
does anything useful with phylink.
The _mdio_ and _mmd_ functions all need ax179a_devices specific
versions.
phylink does WoL differently, so you need to look at
static int ax88179_suspend(struct usb_interface *intf, pm_message_t message)
and maybe split it into two and have a ax179a_devices wrapper. Same
for resume.
_set_wol and _get_wol just calls into phylink.
All the eeprom stuff goes into the library.
The ethtool ksetting and eee calls just become calls into phylink.
All the rest of the EEE code is ax179_devices specific.
You need a new ethtool_ops structure.
You have some changes to set_multicast. Maybe it can be shared, maybe
a specific version?
set_features, change_mtu, set_mac_addr all looks like library code.
Probably a new net_device_ops. The usbnet_mii_ioctl call maybe does
the wrong thing with phylink?
More eeprom code for the library.
efuses code for the library
I personally would make the LED code ax179_devices specific. That
would allow you to do a clean implementation of /sys/class LEDs.
_get_mac_addr() in the library.
_bind() and _unbind() is clearly ax179a_devices specific
_rx_checksum(), _rx_fixup(), _tx_fixup looks to be library.
_link_reset() needs closely looking at, there seems to be some PHY
bits in there.
_reset() needs splitting so there is a ax179a_devices specific part.
_net_reset() as well.
Andrew
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings
2026-07-24 18:22 ` Andrew Lunn
@ 2026-07-25 3:59 ` Birger Koblitz
0 siblings, 0 replies; 34+ messages in thread
From: Birger Koblitz @ 2026-07-25 3:59 UTC (permalink / raw)
To: Andrew Lunn
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Heiner Kallweit, linux-usb, netdev,
linux-kernel
On 24/07/2026 20:22, Andrew Lunn wrote:
> On Fri, Jul 24, 2026 at 07:02:48PM +0200, Birger Koblitz wrote:
>>
>> On 7/24/26 18:25, Andrew Lunn wrote:
>>>> Well, only the new devices use phylink, so it is not converting the existing
>>>> chips.
>>>
>>> O.K. I suggested you split the existing driver into two, a library of
>>> code moving frames around, and then the glue to probe and use mii. You
>>> can then add a new glue driver using phylink for the new devices.
>> I replied to that earlier on. My argument was that the frame moving bits are
>> rather different since the older devices use 32 bit header structures, while
>> the newer ones use 64 and the structures also are somewhat different. The
>> library would contain rather a lot of duplicate functions that are specific to
>> the AX179 and AX179A.
>>
>> Are you aware that the asix_devices.c and asix_common.c drivers do already
>> have this structure (including phylink), but target even older devices? And then,
>> there is a 3rd implementation of the ASIX frame moving, again a bit different,
>> in aqc111.c (no phylink). If one changes there aqc111_ to asix_ one gets basically
>> the same code as in asix_common at least for the USB stuff and similarities to the
>> code of ax88179_178a for the frame moving. I did not want to further contribute
>> to the mess, but it now looks like I do just that.
>
> Yes ASIX is a mess. It is lacking a Maintainer to look after it as a
> whole, and say No to patches etc.
>
>> To summarize, you suggest to split ax88179_178a plus the new HW code into 3 parts:
>> - ax179_lib (frame moving, USB read/write support)
>> - ax179_devices (HW support for AX179-based chips using mii)
>> - ax179a_devices (HW support for AX179A based chips using phylink)
>
> This seems like the best way to not make ax179 a worse of a mess.
>
> When you look at what is actually needed for ax179a_devices, starting
> from ax88179_178a.c and deleting stuff, there is not too much.
>
> static void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode)
> static int ax88179_in_pm(struct usbnet *dev)
> static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
> u16 size, void *data)
> static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
> u16 size, const void *data)
> static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value,
> u16 index, u16 size, void *data)
> static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
> u16 size, void *data)
> static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
> u16 size, const void *data)
>
> All goes into the library.
>
> I don't think
>
> static void ax88179_status(struct usbnet *dev, struct urb *urb)
>
> does anything useful with phylink.
>
> The _mdio_ and _mmd_ functions all need ax179a_devices specific
> versions.
>
> phylink does WoL differently, so you need to look at
> static int ax88179_suspend(struct usb_interface *intf, pm_message_t message)
>
> and maybe split it into two and have a ax179a_devices wrapper. Same
> for resume.
>
> _set_wol and _get_wol just calls into phylink.
>
> All the eeprom stuff goes into the library.
>
> The ethtool ksetting and eee calls just become calls into phylink.
>
> All the rest of the EEE code is ax179_devices specific.
>
> You need a new ethtool_ops structure.
>
> You have some changes to set_multicast. Maybe it can be shared, maybe
> a specific version?
>
> set_features, change_mtu, set_mac_addr all looks like library code.
>
> Probably a new net_device_ops. The usbnet_mii_ioctl call maybe does
> the wrong thing with phylink?
>
> More eeprom code for the library.
>
> efuses code for the library
>
> I personally would make the LED code ax179_devices specific. That
> would allow you to do a clean implementation of /sys/class LEDs.
>
> _get_mac_addr() in the library.
>
> _bind() and _unbind() is clearly ax179a_devices specific
>
> _rx_checksum(), _rx_fixup(), _tx_fixup looks to be library.
>
> _link_reset() needs closely looking at, there seems to be some PHY
> bits in there.
>
> _reset() needs splitting so there is a ax179a_devices specific part.
> _net_reset() as well.
That sounds like a plan. Thanks a lot for providing your insights!
I'll work on with that and send out a v4 when done.
Birger
^ permalink raw reply [flat|nested] 34+ messages in thread
end of thread, other threads:[~2026-07-25 3:59 UTC | newest]
Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 7:36 [PATCH net-next v3 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 01/13] ax88179_178a: Fix endianness of pause watermark register Birger Koblitz
2026-07-24 13:22 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 02/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-07-24 16:22 ` Andrew Lunn
2026-07-24 16:37 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 03/13] ax88179_178a: Use MMD accessor functions for AX88179A Birger Koblitz
2026-07-24 13:25 ` Andrew Lunn
2026-07-24 16:44 ` Andrew Lunn
2026-07-24 17:07 ` Birger Koblitz
2026-07-24 17:27 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 04/13] ax88179_178a: Add EEE HW configuration support " Birger Koblitz
2026-07-24 13:32 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 05/13] ax88179_178a: Use phylink in get/set_link_ksettings Birger Koblitz
2026-07-24 13:38 ` Andrew Lunn
2026-07-24 15:06 ` Birger Koblitz
2026-07-24 15:35 ` Andrew Lunn
2026-07-24 15:53 ` Birger Koblitz
2026-07-24 16:25 ` Andrew Lunn
2026-07-24 17:02 ` Birger Koblitz
2026-07-24 18:22 ` Andrew Lunn
2026-07-25 3:59 ` Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 06/13] ax88179_178a: EEE setup for AX88179A-based chips Birger Koblitz
2026-07-24 16:31 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 07/13] ax88179_178a: Obtain speed and duplex from Interrupt URB Birger Koblitz
2026-07-24 17:01 ` Andrew Lunn
2026-07-24 7:36 ` [PATCH net-next v3 08/13] ax88179_178a: Add support for ethtool pause parameter configuration Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 09/13] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 10/13] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 11/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 12/13] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-07-24 7:36 ` [PATCH net-next v3 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-07-24 13:51 ` Andrew Lunn
2026-07-24 17:18 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox