AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/08/10 13:58 flow patch-triage
16m Args:
null

Results:
{
  "EnableConfigs": [
    "USB_NET_AX88179",
    "AX88796B_PHY"
  ],
  "FocusSymbols": [
    "ax88179a_bind",
    "ax88179a_rx_fixup",
    "ax88179a_tx_fixup",
    "ax88179a_reset",
    "ax88179a_set_features",
    "ax88179a_vlan_rx_add_vid",
    "ax88179a_vlan_rx_kill_vid",
    "ax88179a_mac_link_up",
    "ax88179_read_cmd",
    "ax88179_write_cmd",
    "ax88179_set_eeprom",
    "ax88179_get_eeprom",
    "ax88179_set_features",
    "ax88179_change_mtu",
    "asix_ax88279_read_status",
    "asix_ax88279_config_aneg",
    "asix_ax88279_get_features",
    "asix_ax88279_config_init",
    "asix_read_mmd",
    "asix_write_mmd",
    "asix_ax88772D_get_features"
  ],
  "KMSANReasoning": "The patch introduces several new functions in `ax88179a_devices.c` that read 1-byte registers from the USB device using `ax88179_read_cmd(..., size=1, \u0026var)`. If the USB control message fails (e.g., due to a device error or disconnect), `ax88179_read_cmd` returns an error code but leaves the 1-byte local variable uninitialized.\n\nThe code then proceeds to use these uninitialized variables without checking the return value of `ax88179_read_cmd`. Examples include:\n1. `ax88179a_mac_link_up()`: reads into `link_sts` and passes it to `ax88179a_bulkin_config()`, which branches on `link_sts \u0026 AX_USB_SS`.\n2. `ax88179a_resume()`: reads into `reg8` and branches on `!(reg8 \u0026 AX_PHY_POWER)`.\n3. `ax88179a_set_features()`: reads into `tmp`, XORs it, and writes it back to the device.\n4. `ax88179a_vlan_rx_kill_vid()` / `ax88179a_vlan_rx_add_vid()`: reads into `reg8`, assigns to `vlan_ctrl`, and writes it back.\n5. `ax88179a_suspend()`: reads into `tmp8`, modifies it, and writes it back.\n\nThese are classic uninitialized memory uses (branching on uninitialized values and writing uninitialized stack memory to the device). KASAN cannot detect these because they are not out-of-bounds accesses or use-after-frees. Only KMSAN tracks the initialization state of stack variables and can catch these bugs. Therefore, a dedicated KMSAN fuzzing session is highly justified.",
  "NeedsKMSAN": true,
  "Reasoning": "The patch adds support for ASIX AX88179A, AX88279, and AX88772D/E USB Ethernet adapters. It splits the existing driver into a library and device-specific files, and adds new PHY drivers. USB devices can be emulated in virtualized environments using the USB gadget subsystem (dummy_hcd), making this code reachable and worth fuzzing.",
  "WorthFuzzing": true
}

1/1 2026/08/10 13:58 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 5440b5325da5dcdfedc4cd25fb52b0c4e64c4c81\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Mon Aug 10 13:58:33 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/MAINTAINERS b/MAINTAINERS\nindex 15011f5752a99..d43d58b417e58 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -3987,6 +3987,12 @@ S:\tMaintained\n F:\tDocumentation/devicetree/bindings/net/asix,ax88796c.yaml\n F:\tdrivers/net/ethernet/asix/ax88796c_*\n \n+ASIX AX88179 USB ETHERNET DRIVER\n+M:\tBirger Koblitz \u003cmail@birger-koblitz.de\u003e\n+L:\tnetdev@vger.kernel.org\n+S:\tMaintained\n+F:\tdrivers/net/usb/ax88179*\n+\n ASIX PHY DRIVER [RUST]\n M:\tFUJITA Tomonori \u003cfujita.tomonori@gmail.com\u003e\n R:\tTrevor Gross \u003ctmgross@umich.edu\u003e\ndiff --git a/drivers/net/phy/ax88796b.c b/drivers/net/phy/ax88796b.c\nindex f20ddf6491499..1298e46ad9e16 100644\n--- a/drivers/net/phy/ax88796b.c\n+++ b/drivers/net/phy/ax88796b.c\n@@ -13,6 +13,19 @@\n #define PHY_ID_ASIX_AX88772A\t\t0x003b1861\n #define PHY_ID_ASIX_AX88772C\t\t0x003b1881\n #define PHY_ID_ASIX_AX88796B\t\t0x003b1841\n+#define PHY_ID_ASIX_AX88772D\t\t0x003b772d\n+#define PHY_ID_ASIX_AX88179A\t\t0x003b179a\n+#define PHY_ID_ASIX_AX88279\t\t0x003b2790\n+\n+#define AX_ADVERTISE_2500\t\t0x1000\n+\n+/* MII Vendor registers */\n+#define AX_CTRL_STATUS\t\t\t0x1d\n+#define AX_CTRL_STATUS_SPEED_MASK\t0x0c\n+#define   AX_CTRL_STATUS_SPEED_10\t0x0\n+#define   AX_CTRL_STATUS_SPEED_100\t0x4\n+#define   AX_CTRL_STATUS_SPEED_1000\t0x8\n+#define   AX_CTRL_STATUS_SPEED_2500\t0xc\n \n MODULE_DESCRIPTION(\"Asix PHY driver\");\n MODULE_AUTHOR(\"Michael Schmitz \u003cschmitzmic@gmail.com\u003e\");\n@@ -83,6 +96,122 @@ static int asix_ax88772a_read_status(struct phy_device *phydev)\n \treturn 0;\n }\n \n+static int asix_ax88279_read_status(struct phy_device *phydev)\n+{\n+\tint ret, val;\n+\n+\tret = genphy_read_status(phydev);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* Read actual speed from vendor register */\n+\tval = phy_read(phydev, AX_CTRL_STATUS);\n+\tswitch (val \u0026 AX_CTRL_STATUS_SPEED_MASK) {\n+\tcase AX_CTRL_STATUS_SPEED_2500:\n+\t\tphydev-\u003espeed = SPEED_2500;\n+\t\tbreak;\n+\tcase AX_CTRL_STATUS_SPEED_1000:\n+\t\tphydev-\u003espeed = SPEED_1000;\n+\t\tbreak;\n+\tcase AX_CTRL_STATUS_SPEED_100:\n+\t\tphydev-\u003espeed = SPEED_100;\n+\t\tbreak;\n+\tcase AX_CTRL_STATUS_SPEED_10:\n+\t\tphydev-\u003espeed = SPEED_10;\n+\t}\n+\n+\t/* MDIO_AN_10GBT_STAT_LP2_5G is broken, but we can deduce that\n+\t * the link-partner advertised 2500M if remotely AN succceded\n+\t * for link speed \u003e 1000M and we locally have a link speed of\n+\t * 2500M\n+\t */\n+\tval = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_STAT);\n+\tif (val \u003e= 0 \u0026\u0026 val \u0026 MDIO_AN_10GBT_STAT_REMOK) {\n+\t\tlinkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,\n+\t\t\t\t phydev-\u003elp_advertising,\n+\t\t\t\t phydev-\u003espeed == SPEED_2500);\n+\t}\n+\t/* Only supports full duplex */\n+\tphydev-\u003eduplex = DUPLEX_FULL;\n+\n+\t/* PHY switches interface between 2.5GBit and slower modes */\n+\tif (phydev-\u003espeed == SPEED_2500)\n+\t\tphydev-\u003einterface = PHY_INTERFACE_MODE_2500BASEX;\n+\telse\n+\t\tphydev-\u003einterface = PHY_INTERFACE_MODE_SGMII;\n+\n+\treturn 0;\n+}\n+\n+static int asix_ax88279_config_aneg(struct phy_device *phydev)\n+{\n+\tbool adv_2500;\n+\tint ret;\n+\n+\tif (phydev-\u003eautoneg == AUTONEG_DISABLE) {\n+\t\tphydev_warn(phydev, \"Disabling autoneg is not supported\\n\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\tret = genphy_config_aneg(phydev);\n+\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tadv_2500 = linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev-\u003eadvertising);\n+\tret = phy_modify(phydev, MII_ADVERTISE, AX_ADVERTISE_2500,\n+\t\t\t adv_2500 ? AX_ADVERTISE_2500 : 0);\n+\n+\treturn ret;\n+}\n+\n+static int asix_ax88279_get_features(struct phy_device *phydev)\n+{\n+\tint ret;\n+\n+\t/* MDIO_DEVS1/2 empty, so set mmds_present bits to allow reading abilities */\n+\tphydev-\u003ec45_ids.mmds_present |= MDIO_DEVS_PMAPMD | MDIO_DEVS_AN;\n+\n+\tlinkmode_set_bit_array(phy_basic_ports_array, ARRAY_SIZE(phy_basic_ports_array),\n+\t\t\t       phydev-\u003esupported);\n+\n+\tret = genphy_c45_pma_read_abilities(phydev);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* AX88279 does not support reported 100baseT-half duplex mode */\n+\tlinkmode_clear_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, phydev-\u003esupported);\n+\n+\treturn 0;\n+}\n+\n+static int asix_ax88279_config_init(struct phy_device *phydev)\n+{\n+\t__set_bit(PHY_INTERFACE_MODE_2500BASEX, phydev-\u003epossible_interfaces);\n+\t__set_bit(PHY_INTERFACE_MODE_SGMII, phydev-\u003epossible_interfaces);\n+\n+\treturn 0;\n+}\n+\n+/* AX88179A-based PHYs cannot access MMD registers via MII_MMD_CTRL/MII_MMD_DATA\n+ * Make sure to use c45 access instead.\n+ */\n+static int asix_read_mmd(struct phy_device *phydev, int devnum, u16 reg)\n+{\n+\tstruct mii_bus *bus = phydev-\u003emdio.bus;\n+\tint addr = phydev-\u003emdio.addr;\n+\n+\treturn __mdiobus_c45_read(bus, addr, devnum, reg);\n+}\n+\n+static int asix_write_mmd(struct phy_device *phydev, int devnum, u16 reg, u16 val)\n+{\n+\tstruct mii_bus *bus = phydev-\u003emdio.bus;\n+\tint addr = phydev-\u003emdio.addr;\n+\n+\treturn __mdiobus_c45_write(bus, addr, devnum, reg, val);\n+}\n+\n static void asix_ax88772a_link_change_notify(struct phy_device *phydev)\n {\n \t/* Reset PHY, otherwise MII_LPA will provide outdated information.\n@@ -94,6 +223,25 @@ static void asix_ax88772a_link_change_notify(struct phy_device *phydev)\n \t}\n }\n \n+static int asix_ax88772D_get_features(struct phy_device *phydev)\n+{\n+\tint ret;\n+\t__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = {};\n+\n+\t/* MDIO_DEVS1/2 empty, so set mmds_present bits to allow reading abilities */\n+\tphydev-\u003ec45_ids.mmds_present |= MDIO_DEVS_PMAPMD | MDIO_DEVS_AN;\n+\n+\tret = genphy_read_abilities(phydev);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* AX88772D does not support reported 1000baseT mode */\n+\tlinkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, mask);\n+\tlinkmode_andnot(phydev-\u003esupported, phydev-\u003esupported, mask);\n+\n+\treturn 0;\n+}\n+\n static struct phy_driver asix_driver[] = {\n {\n \tPHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772A),\n@@ -111,6 +259,35 @@ static struct phy_driver asix_driver[] = {\n \t.suspend\t= genphy_suspend,\n \t.resume\t\t= genphy_resume,\n \t.soft_reset\t= asix_soft_reset,\n+}, {\n+\tPHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772D),\n+\t.name\t\t= \"Asix Electronics AX88772D\",\n+\t.flags\t\t= PHY_IS_INTERNAL,\n+\t.get_features\t= asix_ax88772D_get_features,\n+\t.read_mmd\t= asix_read_mmd,\n+\t.write_mmd\t= asix_write_mmd,\n+\t.suspend\t= genphy_suspend,\n+\t.resume\t\t= genphy_resume,\n+}, {\n+\tPHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88179A),\n+\t.name\t\t= \"Asix Electronics AX88179A\",\n+\t.flags\t\t= PHY_IS_INTERNAL,\n+\t.suspend\t= genphy_suspend,\n+\t.resume\t\t= genphy_resume,\n+\t.read_mmd\t= asix_read_mmd,\n+\t.write_mmd\t= asix_write_mmd,\n+}, {\n+\tPHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88279),\n+\t.name\t\t= \"Asix Electronics AX88279\",\n+\t.flags\t\t= PHY_IS_INTERNAL,\n+\t.get_features\t= asix_ax88279_get_features,\n+\t.read_status\t= asix_ax88279_read_status,\n+\t.config_aneg\t= asix_ax88279_config_aneg,\n+\t.config_init\t= asix_ax88279_config_init,\n+\t.read_mmd\t= asix_read_mmd,\n+\t.write_mmd\t= asix_write_mmd,\n+\t.suspend\t= genphy_suspend,\n+\t.resume\t\t= genphy_resume,\n }, {\n \tPHY_ID_MATCH_MODEL(PHY_ID_ASIX_AX88796B),\n \t.name\t\t= \"Asix Electronics AX88796B\",\n@@ -124,6 +301,9 @@ static const struct mdio_device_id __maybe_unused asix_tbl[] = {\n \t{ PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772A) },\n \t{ PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772C) },\n \t{ PHY_ID_MATCH_MODEL(PHY_ID_ASIX_AX88796B) },\n+\t{ PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772D) },\n+\t{ PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88179A) },\n+\t{ PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88279) },\n \t{ }\n };\n \ndiff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c\nindex 087ac63f9193d..2ba1d76872a23 100644\n--- a/drivers/net/phy/phylink.c\n+++ b/drivers/net/phy/phylink.c\n@@ -1612,6 +1612,22 @@ static bool phylink_link_is_up(struct phylink *pl)\n \treturn pl-\u003enetdev ? netif_carrier_ok(pl-\u003enetdev) : pl-\u003eold_link_state;\n }\n \n+/**\n+ * phylink_mac_interrupt() - wrapper for phy_mac_interrupt()\n+ * @pl: a pointer to a \u0026struct phylink returned from phylink_create()\n+ *\n+ * Passes a link-change interrupt received by the MAC to phylib.\n+ */\n+void phylink_mac_interrupt(struct phylink *pl)\n+{\n+\tstruct phy_device *phy;\n+\n+\tphy = pl-\u003ephydev;\n+\tif (phy)\n+\t\tphy_mac_interrupt(phy);\n+}\n+EXPORT_SYMBOL_GPL(phylink_mac_interrupt);\n+\n static void phylink_resolve(struct work_struct *w)\n {\n \tstruct phylink *pl = container_of(w, struct phylink, resolve);\ndiff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig\nindex 52a5c0922c79f..4158455a2da76 100644\n--- a/drivers/net/usb/Kconfig\n+++ b/drivers/net/usb/Kconfig\n@@ -195,11 +195,12 @@ config USB_NET_AX8817X\n \t  This driver creates an interface named \"ethX\", where X depends on\n \t  what other networking devices you have in use.\n \n-config USB_NET_AX88179_178A\n-\ttristate \"ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet\"\n+config USB_NET_AX88179\n+\ttristate \"ASIX AX88179/179A/178A USB 3.0/2.0 to Gigabit Ethernet\"\n \tdepends on USB_USBNET\n+\tselect PHYLINK\n+\tselect AX88796B_PHY\n \tselect CRC32\n-\tselect PHYLIB\n \tdefault y\n \thelp\n \t  This option adds support for ASIX AX88179 based USB 3.0/2.0\n@@ -207,6 +208,9 @@ config USB_NET_AX88179_178A\n \n \t  This driver should work with at least the following devices:\n \t    * ASIX AX88179\n+\t    * ASIX AX88179A/B\n+\t    * ASIX AX88279\n+\t    * ASIX AX88772D/E\n \t    * ASIX AX88178A\n \t    * Sitcomm LN-032\n \ndiff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile\nindex 4964f7b326fbc..4026f19ecb826 100644\n--- a/drivers/net/usb/Makefile\n+++ b/drivers/net/usb/Makefile\n@@ -12,7 +12,8 @@ obj-$(CONFIG_USB_HSO)\t\t+= hso.o\n obj-$(CONFIG_USB_LAN78XX)\t+= lan78xx.o\n obj-$(CONFIG_USB_NET_AX8817X)\t+= asix.o\n asix-y := asix_devices.o asix_common.o ax88172a.o\n-obj-$(CONFIG_USB_NET_AX88179_178A)      += ax88179_178a.o\n+obj-$(CONFIG_USB_NET_AX88179)      += ax88179.o\n+ax88179-y := ax88179_178a.o ax88179a_devices.o ax88179_lib.o\n obj-$(CONFIG_USB_NET_CDCETHER)\t+= cdc_ether.o\n obj-$(CONFIG_USB_NET_CDC_EEM)\t+= cdc_eem.o\n obj-$(CONFIG_USB_NET_DM9601)\t+= dm9601.o\ndiff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c\nindex 98f899ea2e946..be72ed955b6b8 100644\n--- a/drivers/net/usb/ax88179_178a.c\n+++ b/drivers/net/usb/ax88179_178a.c\n@@ -8,179 +8,12 @@\n #include \u003clinux/module.h\u003e\n #include \u003clinux/etherdevice.h\u003e\n #include \u003clinux/mii.h\u003e\n-#include \u003clinux/usb.h\u003e\n-#include \u003clinux/crc32.h\u003e\n-#include \u003clinux/usb/usbnet.h\u003e\n #include \u003cuapi/linux/mdio.h\u003e\n #include \u003clinux/mdio.h\u003e\n-\n-#define AX88179_PHY_ID\t\t\t\t0x03\n-#define AX_EEPROM_LEN\t\t\t\t0x100\n-#define AX88179_EEPROM_MAGIC\t\t\t0x17900b95\n-#define AX_MCAST_FLTSIZE\t\t\t8\n-#define AX_MAX_MCAST\t\t\t\t64\n-#define AX_INT_PPLS_LINK\t\t\t((u32)BIT(16))\n-#define AX_RXHDR_L4_TYPE_MASK\t\t\t0x1c\n-#define AX_RXHDR_L4_TYPE_UDP\t\t\t4\n-#define AX_RXHDR_L4_TYPE_TCP\t\t\t16\n-#define AX_RXHDR_L3CSUM_ERR\t\t\t2\n-#define AX_RXHDR_L4CSUM_ERR\t\t\t1\n-#define AX_RXHDR_CRC_ERR\t\t\t((u32)BIT(29))\n-#define AX_RXHDR_DROP_ERR\t\t\t((u32)BIT(31))\n-#define AX_ACCESS_MAC\t\t\t\t0x01\n-#define AX_ACCESS_PHY\t\t\t\t0x02\n-#define AX_ACCESS_EEPROM\t\t\t0x04\n-#define AX_ACCESS_EFUS\t\t\t\t0x05\n-#define AX_RELOAD_EEPROM_EFUSE\t\t\t0x06\n-#define AX_PAUSE_WATERLVL_HIGH\t\t\t0x54\n-#define AX_PAUSE_WATERLVL_LOW\t\t\t0x55\n-\n-#define PHYSICAL_LINK_STATUS\t\t\t0x02\n-\t#define\tAX_USB_SS\t\t0x04\n-\t#define\tAX_USB_HS\t\t0x02\n-\n-#define GENERAL_STATUS\t\t\t\t0x03\n-/* Check AX88179 version. UA1:Bit2 = 0,  UA2:Bit2 = 1 */\n-\t#define\tAX_SECLD\t\t0x04\n-\n-#define AX_SROM_ADDR\t\t\t\t0x07\n-#define AX_SROM_CMD\t\t\t\t0x0a\n-\t#define EEP_RD\t\t\t0x04\n-\t#define EEP_BUSY\t\t0x10\n-\n-#define AX_SROM_DATA_LOW\t\t\t0x08\n-#define AX_SROM_DATA_HIGH\t\t\t0x09\n-\n-#define AX_RX_CTL\t\t\t\t0x0b\n-\t#define AX_RX_CTL_DROPCRCERR\t0x0100\n-\t#define AX_RX_CTL_IPE\t\t0x0200\n-\t#define AX_RX_CTL_START\t\t0x0080\n-\t#define AX_RX_CTL_AP\t\t0x0020\n-\t#define AX_RX_CTL_AM\t\t0x0010\n-\t#define AX_RX_CTL_AB\t\t0x0008\n-\t#define AX_RX_CTL_AMALL\t\t0x0002\n-\t#define AX_RX_CTL_PRO\t\t0x0001\n-\t#define AX_RX_CTL_STOP\t\t0x0000\n-\n-#define AX_NODE_ID\t\t\t\t0x10\n-#define AX_MULFLTARY\t\t\t\t0x16\n-\n-#define AX_MEDIUM_STATUS_MODE\t\t\t0x22\n-\t#define AX_MEDIUM_GIGAMODE\t0x01\n-\t#define AX_MEDIUM_FULL_DUPLEX\t0x02\n-\t#define AX_MEDIUM_EN_125MHZ\t0x08\n-\t#define AX_MEDIUM_RXFLOW_CTRLEN\t0x10\n-\t#define AX_MEDIUM_TXFLOW_CTRLEN\t0x20\n-\t#define AX_MEDIUM_RECEIVE_EN\t0x100\n-\t#define AX_MEDIUM_PS\t\t0x200\n-\t#define AX_MEDIUM_JUMBO_EN\t0x8040\n-\n-#define AX_MONITOR_MOD\t\t\t\t0x24\n-\t#define AX_MONITOR_MODE_RWLC\t0x02\n-\t#define AX_MONITOR_MODE_RWMP\t0x04\n-\t#define AX_MONITOR_MODE_PMEPOL\t0x20\n-\t#define AX_MONITOR_MODE_PMETYPE\t0x40\n-\n-#define AX_GPIO_CTRL\t\t\t\t0x25\n-\t#define AX_GPIO_CTRL_GPIO3EN\t0x80\n-\t#define AX_GPIO_CTRL_GPIO2EN\t0x40\n-\t#define AX_GPIO_CTRL_GPIO1EN\t0x20\n-\n-#define AX_PHYPWR_RSTCTL\t\t\t0x26\n-\t#define AX_PHYPWR_RSTCTL_BZ\t0x0010\n-\t#define AX_PHYPWR_RSTCTL_IPRL\t0x0020\n-\t#define AX_PHYPWR_RSTCTL_AT\t0x1000\n-\n-#define AX_RX_BULKIN_QCTRL\t\t\t0x2e\n-#define AX_CLK_SELECT\t\t\t\t0x33\n-\t#define AX_CLK_SELECT_BCS\t0x01\n-\t#define AX_CLK_SELECT_ACS\t0x02\n-\t#define AX_CLK_SELECT_ULR\t0x08\n-\n-#define AX_RXCOE_CTL\t\t\t\t0x34\n-\t#define AX_RXCOE_IP\t\t0x01\n-\t#define AX_RXCOE_TCP\t\t0x02\n-\t#define AX_RXCOE_UDP\t\t0x04\n-\t#define AX_RXCOE_TCPV6\t\t0x20\n-\t#define AX_RXCOE_UDPV6\t\t0x40\n-\n-#define AX_TXCOE_CTL\t\t\t\t0x35\n-\t#define AX_TXCOE_IP\t\t0x01\n-\t#define AX_TXCOE_TCP\t\t0x02\n-\t#define AX_TXCOE_UDP\t\t0x04\n-\t#define AX_TXCOE_TCPV6\t\t0x20\n-\t#define AX_TXCOE_UDPV6\t\t0x40\n-\n-#define AX_LEDCTRL\t\t\t\t0x73\n-\n-#define GMII_PHY_PHYSR\t\t\t\t0x11\n-\t#define GMII_PHY_PHYSR_SMASK\t0xc000\n-\t#define GMII_PHY_PHYSR_GIGA\t0x8000\n-\t#define GMII_PHY_PHYSR_100\t0x4000\n-\t#define GMII_PHY_PHYSR_FULL\t0x2000\n-\t#define GMII_PHY_PHYSR_LINK\t0x400\n-\n-#define GMII_LED_ACT\t\t\t\t0x1a\n-\t#define\tGMII_LED_ACTIVE_MASK\t0xff8f\n-\t#define\tGMII_LED0_ACTIVE\tBIT(4)\n-\t#define\tGMII_LED1_ACTIVE\tBIT(5)\n-\t#define\tGMII_LED2_ACTIVE\tBIT(6)\n-\n-#define GMII_LED_LINK\t\t\t\t0x1c\n-\t#define\tGMII_LED_LINK_MASK\t0xf888\n-\t#define\tGMII_LED0_LINK_10\tBIT(0)\n-\t#define\tGMII_LED0_LINK_100\tBIT(1)\n-\t#define\tGMII_LED0_LINK_1000\tBIT(2)\n-\t#define\tGMII_LED1_LINK_10\tBIT(4)\n-\t#define\tGMII_LED1_LINK_100\tBIT(5)\n-\t#define\tGMII_LED1_LINK_1000\tBIT(6)\n-\t#define\tGMII_LED2_LINK_10\tBIT(8)\n-\t#define\tGMII_LED2_LINK_100\tBIT(9)\n-\t#define\tGMII_LED2_LINK_1000\tBIT(10)\n-\t#define\tLED0_ACTIVE\t\tBIT(0)\n-\t#define\tLED0_LINK_10\t\tBIT(1)\n-\t#define\tLED0_LINK_100\t\tBIT(2)\n-\t#define\tLED0_LINK_1000\t\tBIT(3)\n-\t#define\tLED0_FD\t\t\tBIT(4)\n-\t#define\tLED0_USB3_MASK\t\t0x001f\n-\t#define\tLED1_ACTIVE\t\tBIT(5)\n-\t#define\tLED1_LINK_10\t\tBIT(6)\n-\t#define\tLED1_LINK_100\t\tBIT(7)\n-\t#define\tLED1_LINK_1000\t\tBIT(8)\n-\t#define\tLED1_FD\t\t\tBIT(9)\n-\t#define\tLED1_USB3_MASK\t\t0x03e0\n-\t#define\tLED2_ACTIVE\t\tBIT(10)\n-\t#define\tLED2_LINK_1000\t\tBIT(13)\n-\t#define\tLED2_LINK_100\t\tBIT(12)\n-\t#define\tLED2_LINK_10\t\tBIT(11)\n-\t#define\tLED2_FD\t\t\tBIT(14)\n-\t#define\tLED_VALID\t\tBIT(15)\n-\t#define\tLED2_USB3_MASK\t\t0x7c00\n-\n-#define GMII_PHYPAGE\t\t\t\t0x1e\n-#define GMII_PHY_PAGE_SELECT\t\t\t0x1f\n-\t#define GMII_PHY_PGSEL_EXT\t0x0007\n-\t#define GMII_PHY_PGSEL_PAGE0\t0x0000\n-\t#define GMII_PHY_PGSEL_PAGE3\t0x0003\n-\t#define GMII_PHY_PGSEL_PAGE5\t0x0005\n+#include \"ax88179_lib.h\"\n \n static int ax88179_reset(struct usbnet *dev);\n \n-struct ax88179_data {\n-\tu8  eee_enabled;\n-\tu8  eee_active;\n-\tu16 rxctl;\n-\tu8 in_pm;\n-\tu32 wol_supported;\n-\tu32 wolopts;\n-\tu8 disconnecting;\n-};\n-\n-struct ax88179_int_data {\n-\t__le32 intdata1;\n-\t__le32 intdata2;\n-};\n-\n static const struct {\n \tunsigned char ctrl, timer_l, timer_h, size, ifg;\n } AX88179_BULKIN_SIZE[] =\t{\n@@ -190,165 +23,6 @@ static const struct {\n \t{7, 0xcc, 0x4c, 0x18, 8},\n };\n \n-static void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode)\n-{\n-\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n-\n-\tax179_data-\u003ein_pm = pm_mode;\n-}\n-\n-static int ax88179_in_pm(struct usbnet *dev)\n-{\n-\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n-\n-\treturn ax179_data-\u003ein_pm;\n-}\n-\n-static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,\n-\t\t\t      u16 size, void *data)\n-{\n-\tint ret;\n-\tint (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16);\n-\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n-\n-\tBUG_ON(!dev);\n-\n-\tif (!ax88179_in_pm(dev))\n-\t\tfn = usbnet_read_cmd;\n-\telse\n-\t\tfn = usbnet_read_cmd_nopm;\n-\n-\tret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,\n-\t\t value, index, data, size);\n-\n-\tif (unlikely((ret \u003c 0) \u0026\u0026 !(ret == -ENODEV \u0026\u0026 ax179_data-\u003edisconnecting)))\n-\t\tnetdev_warn(dev-\u003enet, \"Failed to read reg index 0x%04x: %d\\n\",\n-\t\t\t    index, ret);\n-\n-\treturn ret;\n-}\n-\n-static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,\n-\t\t\t       u16 size, const void *data)\n-{\n-\tint ret;\n-\tint (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16);\n-\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n-\n-\tBUG_ON(!dev);\n-\n-\tif (!ax88179_in_pm(dev))\n-\t\tfn = usbnet_write_cmd;\n-\telse\n-\t\tfn = usbnet_write_cmd_nopm;\n-\n-\tret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,\n-\t\t value, index, data, size);\n-\n-\tif (unlikely((ret \u003c 0) \u0026\u0026 !(ret == -ENODEV \u0026\u0026 ax179_data-\u003edisconnecting)))\n-\t\tnetdev_warn(dev-\u003enet, \"Failed to write reg index 0x%04x: %d\\n\",\n-\t\t\t    index, ret);\n-\n-\treturn ret;\n-}\n-\n-static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value,\n-\t\t\t\t    u16 index, u16 size, void *data)\n-{\n-\tu16 buf;\n-\n-\tif (2 == size) {\n-\t\tbuf = *((u16 *)data);\n-\t\tcpu_to_le16s(\u0026buf);\n-\t\tusbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |\n-\t\t\t\t       USB_RECIP_DEVICE, value, index, \u0026buf,\n-\t\t\t\t       size);\n-\t} else {\n-\t\tusbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |\n-\t\t\t\t       USB_RECIP_DEVICE, value, index, data,\n-\t\t\t\t       size);\n-\t}\n-}\n-\n-static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,\n-\t\t\t    u16 size, void *data)\n-{\n-\tint ret;\n-\n-\tif (2 == size) {\n-\t\tu16 buf = 0;\n-\t\tret = __ax88179_read_cmd(dev, cmd, value, index, size, \u0026buf);\n-\t\tle16_to_cpus(\u0026buf);\n-\t\t*((u16 *)data) = buf;\n-\t} else if (4 == size) {\n-\t\tu32 buf = 0;\n-\t\tret = __ax88179_read_cmd(dev, cmd, value, index, size, \u0026buf);\n-\t\tle32_to_cpus(\u0026buf);\n-\t\t*((u32 *)data) = buf;\n-\t} else {\n-\t\tret = __ax88179_read_cmd(dev, cmd, value, index, size, data);\n-\t}\n-\n-\treturn ret;\n-}\n-\n-static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,\n-\t\t\t     u16 size, const void *data)\n-{\n-\tint ret;\n-\n-\tif (2 == size) {\n-\t\tu16 buf;\n-\t\tbuf = *((u16 *)data);\n-\t\tcpu_to_le16s(\u0026buf);\n-\t\tret = __ax88179_write_cmd(dev, cmd, value, index,\n-\t\t\t\t\t  size, \u0026buf);\n-\t} else {\n-\t\tret = __ax88179_write_cmd(dev, cmd, value, index,\n-\t\t\t\t\t  size, data);\n-\t}\n-\n-\treturn ret;\n-}\n-\n-static void ax88179_status(struct usbnet *dev, struct urb *urb)\n-{\n-\tstruct ax88179_int_data *event;\n-\tu32 link;\n-\n-\tif (urb-\u003eactual_length \u003c 8)\n-\t\treturn;\n-\n-\tevent = urb-\u003etransfer_buffer;\n-\tle32_to_cpus((void *)\u0026event-\u003eintdata1);\n-\n-\tlink = (((__force u32)event-\u003eintdata1) \u0026 AX_INT_PPLS_LINK) \u003e\u003e 16;\n-\n-\tif (netif_carrier_ok(dev-\u003enet) != link) {\n-\t\tusbnet_link_change(dev, link, 1);\n-\t\tif (!link)\n-\t\t\tnetdev_info(dev-\u003enet, \"ax88179 - Link status is: 0\\n\");\n-\t}\n-}\n-\n-static int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc)\n-{\n-\tstruct usbnet *dev = netdev_priv(netdev);\n-\tu16 res;\n-\n-\tax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, \u0026res);\n-\treturn res;\n-}\n-\n-static void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc,\n-\t\t\t       int val)\n-{\n-\tstruct usbnet *dev = netdev_priv(netdev);\n-\tu16 res = (u16) val;\n-\n-\tax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, \u0026res);\n-}\n-\n static inline int ax88179_phy_mmd_indirect(struct usbnet *dev, u16 prtad,\n \t\t\t\t\t   u16 devad)\n {\n@@ -510,146 +184,11 @@ static void ax88179_disconnect(struct usb_interface *intf)\n \tusbnet_disconnect(intf);\n }\n \n-static void\n-ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)\n-{\n-\tstruct usbnet *dev = netdev_priv(net);\n-\tstruct ax88179_data *priv = dev-\u003edriver_priv;\n-\n-\twolinfo-\u003esupported = priv-\u003ewol_supported;\n-\twolinfo-\u003ewolopts = priv-\u003ewolopts;\n-}\n-\n-static int\n-ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)\n-{\n-\tstruct usbnet *dev = netdev_priv(net);\n-\tstruct ax88179_data *priv = dev-\u003edriver_priv;\n-\n-\tif (wolinfo-\u003ewolopts \u0026 ~(priv-\u003ewol_supported))\n-\t\treturn -EINVAL;\n-\n-\tpriv-\u003ewolopts = wolinfo-\u003ewolopts;\n-\n-\treturn 0;\n-}\n-\n static int ax88179_get_eeprom_len(struct net_device *net)\n {\n \treturn AX_EEPROM_LEN;\n }\n \n-static int\n-ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,\n-\t\t   u8 *data)\n-{\n-\tstruct usbnet *dev = netdev_priv(net);\n-\tu16 *eeprom_buff;\n-\tint first_word, last_word;\n-\tint i, ret;\n-\n-\tif (eeprom-\u003elen == 0)\n-\t\treturn -EINVAL;\n-\n-\teeprom-\u003emagic = AX88179_EEPROM_MAGIC;\n-\n-\tfirst_word = eeprom-\u003eoffset \u003e\u003e 1;\n-\tlast_word = (eeprom-\u003eoffset + eeprom-\u003elen - 1) \u003e\u003e 1;\n-\teeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),\n-\t\t\t\t    GFP_KERNEL);\n-\tif (!eeprom_buff)\n-\t\treturn -ENOMEM;\n-\n-\t/* ax88179/178A returns 2 bytes from eeprom on read */\n-\tfor (i = first_word; i \u003c= last_word; i++) {\n-\t\tret = __ax88179_read_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2,\n-\t\t\t\t\t \u0026eeprom_buff[i - first_word]);\n-\t\tif (ret \u003c 0) {\n-\t\t\tkfree(eeprom_buff);\n-\t\t\treturn -EIO;\n-\t\t}\n-\t}\n-\n-\tmemcpy(data, (u8 *)eeprom_buff + (eeprom-\u003eoffset \u0026 1), eeprom-\u003elen);\n-\tkfree(eeprom_buff);\n-\treturn 0;\n-}\n-\n-static int\n-ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,\n-\t\t   u8 *data)\n-{\n-\tstruct usbnet *dev = netdev_priv(net);\n-\tu16 *eeprom_buff;\n-\tint first_word;\n-\tint last_word;\n-\tint ret;\n-\tint i;\n-\n-\tnetdev_dbg(net, \"write EEPROM len %d, offset %d, magic 0x%x\\n\",\n-\t\t   eeprom-\u003elen, eeprom-\u003eoffset, eeprom-\u003emagic);\n-\n-\tif (eeprom-\u003elen == 0)\n-\t\treturn -EINVAL;\n-\n-\tif (eeprom-\u003emagic != AX88179_EEPROM_MAGIC)\n-\t\treturn -EINVAL;\n-\n-\tfirst_word = eeprom-\u003eoffset \u003e\u003e 1;\n-\tlast_word = (eeprom-\u003eoffset + eeprom-\u003elen - 1) \u003e\u003e 1;\n-\n-\teeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),\n-\t\t\t\t    GFP_KERNEL);\n-\tif (!eeprom_buff)\n-\t\treturn -ENOMEM;\n-\n-\t/* align data to 16 bit boundaries, read the missing data from\n-\t   the EEPROM */\n-\tif (eeprom-\u003eoffset \u0026 1) {\n-\t\tret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, first_word, 1, 2,\n-\t\t\t\t       \u0026eeprom_buff[0]);\n-\t\tif (ret \u003c 0) {\n-\t\t\tnetdev_err(net, \"Failed to read EEPROM at offset 0x%02x.\\n\", first_word);\n-\t\t\tgoto free;\n-\t\t}\n-\t}\n-\n-\tif ((eeprom-\u003eoffset + eeprom-\u003elen) \u0026 1) {\n-\t\tret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, last_word, 1, 2,\n-\t\t\t\t       \u0026eeprom_buff[last_word - first_word]);\n-\t\tif (ret \u003c 0) {\n-\t\t\tnetdev_err(net, \"Failed to read EEPROM at offset 0x%02x.\\n\", last_word);\n-\t\t\tgoto free;\n-\t\t}\n-\t}\n-\n-\tmemcpy((u8 *)eeprom_buff + (eeprom-\u003eoffset \u0026 1), data, eeprom-\u003elen);\n-\n-\tfor (i = first_word; i \u003c= last_word; i++) {\n-\t\tnetdev_dbg(net, \"write to EEPROM at offset 0x%02x, data 0x%04x\\n\",\n-\t\t\t   i, eeprom_buff[i - first_word]);\n-\t\tret = ax88179_write_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2,\n-\t\t\t\t\t\u0026eeprom_buff[i - first_word]);\n-\t\tif (ret \u003c 0) {\n-\t\t\tnetdev_err(net, \"Failed to write EEPROM at offset 0x%02x.\\n\", i);\n-\t\t\tgoto free;\n-\t\t}\n-\t\tmsleep(20);\n-\t}\n-\n-\t/* reload EEPROM data */\n-\tret = ax88179_write_cmd(dev, AX_RELOAD_EEPROM_EFUSE, 0x0000, 0, 0, NULL);\n-\tif (ret \u003c 0) {\n-\t\tnetdev_err(net, \"Failed to reload EEPROM data\\n\");\n-\t\tgoto free;\n-\t}\n-\n-\tret = 0;\n-free:\n-\tkfree(eeprom_buff);\n-\treturn ret;\n-}\n-\n static int ax88179_get_link_ksettings(struct net_device *net,\n \t\t\t\t      struct ethtool_link_ksettings *cmd)\n {\n@@ -864,125 +403,6 @@ static const struct ethtool_ops ax88179_ethtool_ops = {\n \t.get_ts_info\t\t= ethtool_op_get_ts_info,\n };\n \n-static void ax88179_set_multicast(struct net_device *net)\n-{\n-\tstruct usbnet *dev = netdev_priv(net);\n-\tstruct ax88179_data *data = dev-\u003edriver_priv;\n-\tu8 *m_filter = ((u8 *)dev-\u003edata);\n-\n-\tdata-\u003erxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE);\n-\n-\tif (net-\u003eflags \u0026 IFF_PROMISC) {\n-\t\tdata-\u003erxctl |= AX_RX_CTL_PRO;\n-\t} else if (net-\u003eflags \u0026 IFF_ALLMULTI ||\n-\t\t   netdev_mc_count(net) \u003e AX_MAX_MCAST) {\n-\t\tdata-\u003erxctl |= AX_RX_CTL_AMALL;\n-\t} else if (netdev_mc_empty(net)) {\n-\t\t/* just broadcast and directed */\n-\t} else {\n-\t\t/* We use dev-\u003edata for our 8 byte filter buffer\n-\t\t * to avoid allocating memory that is tricky to free later\n-\t\t */\n-\t\tu32 crc_bits;\n-\t\tstruct netdev_hw_addr *ha;\n-\n-\t\tmemset(m_filter, 0, AX_MCAST_FLTSIZE);\n-\n-\t\tnetdev_for_each_mc_addr(ha, net) {\n-\t\t\tcrc_bits = ether_crc(ETH_ALEN, ha-\u003eaddr) \u003e\u003e 26;\n-\t\t\t*(m_filter + (crc_bits \u003e\u003e 3)) |= (1 \u003c\u003c (crc_bits \u0026 7));\n-\t\t}\n-\n-\t\tax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_MULFLTARY,\n-\t\t\t\t\tAX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE,\n-\t\t\t\t\tm_filter);\n-\n-\t\tdata-\u003erxctl |= AX_RX_CTL_AM;\n-\t}\n-\n-\tax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL,\n-\t\t\t\t2, 2, \u0026data-\u003erxctl);\n-}\n-\n-static int\n-ax88179_set_features(struct net_device *net, netdev_features_t features)\n-{\n-\tu8 tmp;\n-\tstruct usbnet *dev = netdev_priv(net);\n-\tnetdev_features_t changed = net-\u003efeatures ^ features;\n-\n-\tif (changed \u0026 NETIF_F_IP_CSUM) {\n-\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, \u0026tmp);\n-\t\ttmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP;\n-\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, \u0026tmp);\n-\t}\n-\n-\tif (changed \u0026 NETIF_F_IPV6_CSUM) {\n-\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, \u0026tmp);\n-\t\ttmp ^= AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6;\n-\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, \u0026tmp);\n-\t}\n-\n-\tif (changed \u0026 NETIF_F_RXCSUM) {\n-\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, \u0026tmp);\n-\t\ttmp ^= AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |\n-\t\t       AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6;\n-\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, \u0026tmp);\n-\t}\n-\n-\treturn 0;\n-}\n-\n-static int ax88179_change_mtu(struct net_device *net, int new_mtu)\n-{\n-\tstruct usbnet *dev = netdev_priv(net);\n-\tu16 tmp16;\n-\n-\tWRITE_ONCE(net-\u003emtu, new_mtu);\n-\tdev-\u003ehard_mtu = net-\u003emtu + net-\u003ehard_header_len;\n-\n-\tif (net-\u003emtu \u003e 1500) {\n-\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,\n-\t\t\t\t 2, 2, \u0026tmp16);\n-\t\ttmp16 |= AX_MEDIUM_JUMBO_EN;\n-\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,\n-\t\t\t\t  2, 2, \u0026tmp16);\n-\t} else {\n-\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,\n-\t\t\t\t 2, 2, \u0026tmp16);\n-\t\ttmp16 \u0026= ~AX_MEDIUM_JUMBO_EN;\n-\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,\n-\t\t\t\t  2, 2, \u0026tmp16);\n-\t}\n-\n-\t/* max qlen depend on hard_mtu and rx_urb_size */\n-\tusbnet_update_max_qlen(dev);\n-\n-\treturn 0;\n-}\n-\n-static int ax88179_set_mac_addr(struct net_device *net, void *p)\n-{\n-\tstruct usbnet *dev = netdev_priv(net);\n-\tstruct sockaddr *addr = p;\n-\tint ret;\n-\n-\tif (netif_running(net))\n-\t\treturn -EBUSY;\n-\tif (!is_valid_ether_addr(addr-\u003esa_data))\n-\t\treturn -EADDRNOTAVAIL;\n-\n-\teth_hw_addr_set(net, addr-\u003esa_data);\n-\n-\t/* Set the MAC address */\n-\tret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,\n-\t\t\t\t ETH_ALEN, net-\u003edev_addr);\n-\tif (ret \u003c 0)\n-\t\treturn ret;\n-\n-\treturn 0;\n-}\n-\n static const struct net_device_ops ax88179_netdev_ops = {\n \t.ndo_open\t\t= usbnet_open,\n \t.ndo_stop\t\t= usbnet_stop,\n@@ -1249,35 +669,6 @@ static int ax88179_led_setting(struct usbnet *dev)\n \treturn 0;\n }\n \n-static void ax88179_get_mac_addr(struct usbnet *dev)\n-{\n-\tu8 mac[ETH_ALEN];\n-\n-\tmemset(mac, 0, sizeof(mac));\n-\n-\t/* Maybe the boot loader passed the MAC address via device tree */\n-\tif (!eth_platform_get_mac_address(\u0026dev-\u003eudev-\u003edev, mac)) {\n-\t\tnetif_dbg(dev, ifup, dev-\u003enet,\n-\t\t\t  \"MAC address read from device tree\");\n-\t} else {\n-\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,\n-\t\t\t\t ETH_ALEN, mac);\n-\t\tnetif_dbg(dev, ifup, dev-\u003enet,\n-\t\t\t  \"MAC address read from ASIX chip\");\n-\t}\n-\n-\tif (is_valid_ether_addr(mac)) {\n-\t\teth_hw_addr_set(dev-\u003enet, mac);\n-\t\tif (!is_local_ether_addr(mac))\n-\t\t\tdev-\u003enet-\u003eaddr_assign_type = NET_ADDR_PERM;\n-\t} else {\n-\t\tnetdev_info(dev-\u003enet, \"invalid MAC address, using random\\n\");\n-\t}\n-\n-\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN,\n-\t\t\t  dev-\u003enet-\u003edev_addr);\n-}\n-\n static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)\n {\n \tstruct ax88179_data *ax179_data;\n@@ -1293,6 +684,22 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)\n \n \tdev-\u003edriver_priv = ax179_data;\n \n+\tax179_data-\u003eresume = ax88179_resume;\n+\tax179_data-\u003esuspend = ax88179_suspend;\n+\n+\tret = ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_CHIP_STATUS,\n+\t\t\t       1, 1, \u0026ax179_data-\u003echip_version);\n+\tif (ret \u003c 0)\n+\t\tgoto err_nodev;\n+\n+\tax179_data-\u003echip_version = (ax179_data-\u003echip_version \u0026 0xf0) \u003e\u003e 4;\n+\tax179_data-\u003eis_ax88772d = 0;\n+\tax179_data-\u003eip_align = 1;\n+\tax179_data-\u003eeeprom_read_cmd = AX_ACCESS_EEPROM;\n+\tax179_data-\u003eeeprom_write_cmd = AX_ACCESS_EEPROM;\n+\tax179_data-\u003eeeprom_block = 2;\n+\tax179_data-\u003eeeprom_wen = 0;\n+\n \tdev-\u003enet-\u003enetdev_ops = \u0026ax88179_netdev_ops;\n \tdev-\u003enet-\u003eethtool_ops = \u0026ax88179_ethtool_ops;\n \tdev-\u003enet-\u003eneeded_headroom = 8;\n@@ -1317,6 +724,12 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)\n \tax88179_reset(dev);\n \n \treturn 0;\n+\n+err_nodev:\n+\tkfree(ax179_data);\n+\tax179_data = NULL;\n+\n+\treturn ret;\n }\n \n static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf)\n@@ -1617,11 +1030,10 @@ static int ax88179_reset(struct usbnet *dev)\n \tdev-\u003erx_urb_size = 1024 * 20;\n \n \t*tmp = 0x34;\n-\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp);\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, 1, 1, tmp);\n \n \t*tmp = 0x52;\n-\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH,\n-\t\t\t  1, 1, tmp);\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp);\n \n \t/* Enable checksum offload */\n \t*tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |\n@@ -1878,6 +1290,18 @@ static const struct driver_info at_umc2000sp_info = {\n \n static const struct usb_device_id products[] = {\n {\n+\t/* ASIX AX88179A USB 3.2 1000Mbit Ethernet */\n+\tUSB_DEVICE_VER(0x0b95, 0x1790, 0, 0x0200),\n+\t.driver_info = (unsigned long)\u0026ax88179a_info,\n+}, {\n+\t/* ASIX AX88772D USB 2.0 100Mbit Ethernet */\n+\tUSB_DEVICE_VER(0x0b95, 0x1790, 0x0300, 0x0300),\n+\t.driver_info = (unsigned long)\u0026ax88772d_info,\n+}, {\n+\t/* ASIX AX88279 USB 3.2 2500Mbit Ethernet */\n+\tUSB_DEVICE_VER(0x0b95, 0x1790, 0, 0x0400),\n+\t.driver_info = (unsigned long)\u0026ax88279_info,\n+}, {\n \t/* ASIX AX88179 10/100/1000 */\n \tUSB_DEVICE_AND_INTERFACE_INFO(0x0b95, 0x1790, 0xff, 0xff, 0),\n \t.driver_info = (unsigned long)\u0026ax88179_info,\n@@ -1934,19 +1358,19 @@ static const struct usb_device_id products[] = {\n };\n MODULE_DEVICE_TABLE(usb, products);\n \n-static struct usb_driver ax88179_178a_driver = {\n-\t.name =\t\t\"ax88179_178a\",\n+static struct usb_driver ax88179_driver = {\n+\t.name =\t\t\"ax88179\",\n \t.id_table =\tproducts,\n \t.probe =\tusbnet_probe,\n-\t.suspend =\tax88179_suspend,\n-\t.resume =\tax88179_resume,\n-\t.reset_resume =\tax88179_resume,\n+\t.suspend =\tax88179_suspend_wrapper,\n+\t.resume =\tax88179_resume_wrapper,\n+\t.reset_resume =\tax88179_resume_wrapper,\n \t.disconnect =\tax88179_disconnect,\n \t.supports_autosuspend = 1,\n \t.disable_hub_initiated_lpm = 1,\n };\n \n-module_usb_driver(ax88179_178a_driver);\n+module_usb_driver(ax88179_driver);\n \n-MODULE_DESCRIPTION(\"ASIX AX88179/178A based USB 3.0/2.0 Gigabit Ethernet Devices\");\n+MODULE_DESCRIPTION(\"ASIX AX88179/179A/178A based USB 3.0/2.0 Gigabit Ethernet Devices\");\n MODULE_LICENSE(\"GPL\");\ndiff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c\nnew file mode 100644\nindex 0000000000000..9b91ad831333e\n--- /dev/null\n+++ b/drivers/net/usb/ax88179_lib.c\n@@ -0,0 +1,515 @@\n+// SPDX-License-Identifier: GPL-2.0-or-later\n+/*\n+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices\n+ *\n+ * Copyright (C) 2011-2013 ASIX\n+ */\n+\n+#include \u003clinux/etherdevice.h\u003e\n+#include \"ax88179_lib.h\"\n+\n+void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode)\n+{\n+\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n+\n+\tax179_data-\u003ein_pm = pm_mode;\n+}\n+\n+static int ax88179_in_pm(struct usbnet *dev)\n+{\n+\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n+\n+\treturn ax179_data-\u003ein_pm;\n+}\n+\n+int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,\n+\t\t       u16 size, void *data)\n+{\n+\tint ret;\n+\tint (*fn)(struct usbnet *dev, u8 cmd, u8 rtype, u16 val, u16 i, void *d, u16 size);\n+\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n+\n+\tif (!dev) {\n+\t\tnetdev_err(dev-\u003enet, \"No net device.\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tif (!ax88179_in_pm(dev))\n+\t\tfn = usbnet_read_cmd;\n+\telse\n+\t\tfn = usbnet_read_cmd_nopm;\n+\n+\tret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,\n+\t\t value, index, data, size);\n+\n+\tif (unlikely(ret \u003c 0 \u0026\u0026 !(ret == -ENODEV \u0026\u0026 ax179_data-\u003edisconnecting)))\n+\t\tnetdev_warn(dev-\u003enet, \"Failed to read reg index 0x%04x: %d\\n\",\n+\t\t\t    index, ret);\n+\n+\treturn ret;\n+}\n+\n+static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,\n+\t\t\t       u16 size, const void *data)\n+{\n+\tint ret;\n+\tint (*fn)(struct usbnet *dev, u8 cmd, u8 rtype, u16 val, u16 i, const void *d, u16 size);\n+\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n+\n+\tif (!dev) {\n+\t\tnetdev_err(dev-\u003enet, \"No net device.\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tif (!ax88179_in_pm(dev))\n+\t\tfn = usbnet_write_cmd;\n+\telse\n+\t\tfn = usbnet_write_cmd_nopm;\n+\n+\tret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,\n+\t\t value, index, data, size);\n+\n+\tif (unlikely(ret \u003c 0 \u0026\u0026 !(ret == -ENODEV \u0026\u0026 ax179_data-\u003edisconnecting)))\n+\t\tnetdev_warn(dev-\u003enet, \"Failed to write reg index 0x%04x: %d\\n\",\n+\t\t\t    index, ret);\n+\n+\treturn ret;\n+}\n+\n+void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size,\n+\t\t\t     void *data)\n+{\n+\tu16 buf;\n+\n+\tif (size == 2) {\n+\t\tbuf = *((u16 *)data);\n+\t\tcpu_to_le16s(\u0026buf);\n+\t\tusbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |\n+\t\t\t\t       USB_RECIP_DEVICE, value, index, \u0026buf,\n+\t\t\t\t       size);\n+\t} else {\n+\t\tusbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |\n+\t\t\t\t       USB_RECIP_DEVICE, value, index, data,\n+\t\t\t\t       size);\n+\t}\n+}\n+\n+int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data)\n+{\n+\tint ret;\n+\n+\tif (size == 2) {\n+\t\tu16 buf = 0;\n+\n+\t\tret = __ax88179_read_cmd(dev, cmd, value, index, size, \u0026buf);\n+\t\tle16_to_cpus(\u0026buf);\n+\t\t*((u16 *)data) = buf;\n+\t} else if (size == 4) {\n+\t\tu32 buf = 0;\n+\n+\t\tret = __ax88179_read_cmd(dev, cmd, value, index, size, \u0026buf);\n+\t\tle32_to_cpus(\u0026buf);\n+\t\t*((u32 *)data) = buf;\n+\t} else {\n+\t\tret = __ax88179_read_cmd(dev, cmd, value, index, size, data);\n+\t}\n+\n+\treturn ret;\n+}\n+\n+int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size,\n+\t\t      const void *data)\n+{\n+\tint ret;\n+\n+\tif (size == 2) {\n+\t\tu16 buf;\n+\n+\t\tbuf = *((u16 *)data);\n+\t\tcpu_to_le16s(\u0026buf);\n+\t\tret = __ax88179_write_cmd(dev, cmd, value, index,\n+\t\t\t\t\t  size, \u0026buf);\n+\t} else {\n+\t\tret = __ax88179_write_cmd(dev, cmd, value, index,\n+\t\t\t\t\t  size, data);\n+\t}\n+\n+\treturn ret;\n+}\n+\n+struct ax88179_data *netdev2data(struct net_device *net)\n+{\n+\tstruct usbnet *dev = netdev_priv(net);\n+\n+\treturn dev-\u003edriver_priv;\n+}\n+\n+void ax88179_status(struct usbnet *dev, struct urb *urb)\n+{\n+\tstruct ax88179_int_data *event;\n+\tu32 link;\n+\n+\tif (urb-\u003eactual_length \u003c 8)\n+\t\treturn;\n+\n+\tevent = urb-\u003etransfer_buffer;\n+\tle32_to_cpus((void *)\u0026event-\u003eintdata1);\n+\n+\tlink = (((__force u32)event-\u003eintdata1) \u0026 AX_INT_PPLS_LINK) \u003e\u003e 16;\n+\n+\tif (netif_carrier_ok(dev-\u003enet) != link) {\n+\t\tusbnet_link_change(dev, link, 1);\n+\t\tif (!link)\n+\t\t\tnetdev_info(dev-\u003enet, \"ax88179 - Link status is: 0\\n\");\n+\t}\n+}\n+\n+int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc)\n+{\n+\tstruct usbnet *dev = netdev_priv(netdev);\n+\tu16 res;\n+\n+\tax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, \u0026res);\n+\treturn res;\n+}\n+\n+void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)\n+{\n+\tstruct usbnet *dev = netdev_priv(netdev);\n+\tu16 res = (u16)val;\n+\n+\tax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, \u0026res);\n+}\n+\n+void ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)\n+{\n+\tstruct usbnet *dev = netdev_priv(net);\n+\tstruct ax88179_data *priv = dev-\u003edriver_priv;\n+\n+\twolinfo-\u003esupported = priv-\u003ewol_supported;\n+\twolinfo-\u003ewolopts = priv-\u003ewolopts;\n+}\n+\n+int ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)\n+{\n+\tstruct usbnet *dev = netdev_priv(net);\n+\tstruct ax88179_data *priv = dev-\u003edriver_priv;\n+\n+\tif (wolinfo-\u003ewolopts \u0026 ~(priv-\u003ewol_supported))\n+\t\treturn -EINVAL;\n+\n+\tpriv-\u003ewolopts = wolinfo-\u003ewolopts;\n+\n+\treturn 0;\n+}\n+\n+static void\n+ax88179_eeprom_access_params(struct ax88179_data *ax179_data, int i, u16 *value, u16 *idx)\n+{\n+\t/* AX88179 has a word-addressable EEPROM\n+\t * AX88179A uses EFUSES with 20 bytes length\n+\t * AX88279 has an EEPROM addressable in 256 byte blocks\n+\t */\n+\tif (ax179_data-\u003echip_version \u003c AX_VERSION_AX88179A) {\n+\t\t*value = i;\n+\t\t*idx = 1;\n+\t} else if (ax179_data-\u003echip_version \u003e= AX_VERSION_AX88279) {\n+\t\t*value = (i * ax179_data-\u003eeeprom_block) \u003e\u003e 16;\n+\t\t*idx = (i * ax179_data-\u003eeeprom_block) \u0026 0xffff;\n+\t} else {\n+\t\t*value = i \u003c\u003c 4;\n+\t\t*idx = 0;\n+\t}\n+}\n+\n+int ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 *data)\n+{\n+\tstruct usbnet *dev = netdev_priv(net);\n+\tstruct ax88179_data *ax179_data;\n+\tint first, last, i, ret;\n+\tu8 *eeprom_buff;\n+\n+\tax179_data = dev-\u003edriver_priv;\n+\n+\tif (eeprom-\u003elen == 0)\n+\t\treturn -EINVAL;\n+\n+\teeprom-\u003emagic = AX88179_EEPROM_MAGIC;\n+\n+\tfirst = eeprom-\u003eoffset / ax179_data-\u003eeeprom_block;\n+\tlast = (eeprom-\u003eoffset + eeprom-\u003elen - 1) / ax179_data-\u003eeeprom_block;\n+\n+\teeprom_buff = kzalloc((last - first + 1) * ax179_data-\u003eeeprom_block, GFP_KERNEL);\n+\tif (!eeprom_buff)\n+\t\treturn -ENOMEM;\n+\n+\tfor (i = first; i \u003c= last; i++) {\n+\t\tu16 value, idx;\n+\n+\t\tax88179_eeprom_access_params(ax179_data, i, \u0026value, \u0026idx);\n+\t\tret = __ax88179_read_cmd(dev, ax179_data-\u003eeeprom_read_cmd,\n+\t\t\t\t\t value, idx, ax179_data-\u003eeeprom_block,\n+\t\t\t\t\t eeprom_buff + (i - first) * ax179_data-\u003eeeprom_block);\n+\n+\t\tif (ret \u003c 0) {\n+\t\t\tkfree(eeprom_buff);\n+\t\t\treturn -EIO;\n+\t\t}\n+\t}\n+\n+\tmemcpy(data, eeprom_buff + eeprom-\u003eoffset % ax179_data-\u003eeeprom_block, eeprom-\u003elen);\n+\tkfree(eeprom_buff);\n+\treturn 0;\n+}\n+\n+int ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 *data)\n+{\n+\tstruct usbnet *dev = netdev_priv(net);\n+\tstruct ax88179_data *ax179_data;\n+\tu16 *eeprom_buff;\n+\tint first_word;\n+\tint last_word;\n+\tint ret;\n+\tint i;\n+\n+\tax179_data = dev-\u003edriver_priv;\n+\tif (ax179_data-\u003echip_version \u003e= AX_VERSION_AX88179A)\n+\t\treturn -EOPNOTSUPP;\n+\n+\tnetdev_dbg(net, \"write EEPROM len %d, offset %d, magic 0x%x\\n\",\n+\t\t   eeprom-\u003elen, eeprom-\u003eoffset, eeprom-\u003emagic);\n+\n+\tif (eeprom-\u003elen == 0)\n+\t\treturn -EINVAL;\n+\n+\tif (eeprom-\u003emagic != AX88179_EEPROM_MAGIC)\n+\t\treturn -EINVAL;\n+\n+\tfirst_word = eeprom-\u003eoffset \u003e\u003e 1;\n+\tlast_word = (eeprom-\u003eoffset + eeprom-\u003elen - 1) \u003e\u003e 1;\n+\n+\teeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),\n+\t\t\t\t    GFP_KERNEL);\n+\tif (!eeprom_buff)\n+\t\treturn -ENOMEM;\n+\n+\t/* align data to 16 bit boundaries, read the missing data from\n+\t * the EEPROM\n+\t */\n+\tif (eeprom-\u003eoffset \u0026 1) {\n+\t\tret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, first_word, 1, 2,\n+\t\t\t\t       \u0026eeprom_buff[0]);\n+\t\tif (ret \u003c 0) {\n+\t\t\tnetdev_err(net, \"Failed to read EEPROM at offset 0x%02x.\\n\", first_word);\n+\t\t\tgoto free;\n+\t\t}\n+\t}\n+\n+\tif ((eeprom-\u003eoffset + eeprom-\u003elen) \u0026 1) {\n+\t\tret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, last_word, 1, 2,\n+\t\t\t\t       \u0026eeprom_buff[last_word - first_word]);\n+\t\tif (ret \u003c 0) {\n+\t\t\tnetdev_err(net, \"Failed to read EEPROM at offset 0x%02x.\\n\", last_word);\n+\t\t\tgoto free;\n+\t\t}\n+\t}\n+\n+\tmemcpy((u8 *)eeprom_buff + (eeprom-\u003eoffset \u0026 1), data, eeprom-\u003elen);\n+\n+\tfor (i = first_word; i \u003c= last_word; i++) {\n+\t\tnetdev_dbg(net, \"write to EEPROM at offset 0x%02x, data 0x%04x\\n\",\n+\t\t\t   i, eeprom_buff[i - first_word]);\n+\t\tret = ax88179_write_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2,\n+\t\t\t\t\t\u0026eeprom_buff[i - first_word]);\n+\t\tif (ret \u003c 0) {\n+\t\t\tnetdev_err(net, \"Failed to write EEPROM at offset 0x%02x.\\n\", i);\n+\t\t\tgoto free;\n+\t\t}\n+\t\tmsleep(20);\n+\t}\n+\n+\t/* reload EEPROM data */\n+\tret = ax88179_write_cmd(dev, AX_RELOAD_EEPROM_EFUSE, 0x0000, 0, 0, NULL);\n+\tif (ret \u003c 0) {\n+\t\tnetdev_err(net, \"Failed to reload EEPROM data\\n\");\n+\t\tgoto free;\n+\t}\n+\n+\tret = 0;\n+free:\n+\tkfree(eeprom_buff);\n+\treturn ret;\n+}\n+\n+void ax88179_set_multicast(struct net_device *net)\n+{\n+\tstruct usbnet *dev = netdev_priv(net);\n+\tu8 *m_filter = ((u8 *)dev-\u003edata);\n+\tstruct ax88179_data *data;\n+\n+\tdata = dev-\u003edriver_priv;\n+\n+\tdata-\u003erxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR);\n+\tif (data-\u003eip_align)\n+\t\tdata-\u003erxctl |= AX_RX_CTL_IPE;\n+\n+\tif (net-\u003eflags \u0026 IFF_PROMISC) {\n+\t\tdata-\u003erxctl |= AX_RX_CTL_PRO;\n+\t} else if (net-\u003eflags \u0026 IFF_ALLMULTI ||\n+\t\t   netdev_mc_count(net) \u003e AX_MAX_MCAST) {\n+\t\tdata-\u003erxctl |= AX_RX_CTL_AMALL;\n+\t} else if (netdev_mc_empty(net)) {\n+\t\t/* just broadcast and directed */\n+\t} else {\n+\t\t/* We use dev-\u003edata for our 8 byte filter buffer\n+\t\t * to avoid allocating memory that is tricky to free later\n+\t\t */\n+\t\tu32 crc_bits;\n+\t\tstruct netdev_hw_addr *ha;\n+\n+\t\tmemset(m_filter, 0, AX_MCAST_FLTSIZE);\n+\n+\t\tnetdev_for_each_mc_addr(ha, net) {\n+\t\t\tcrc_bits = ether_crc(ETH_ALEN, ha-\u003eaddr) \u003e\u003e 26;\n+\t\t\t*(m_filter + (crc_bits \u003e\u003e 3)) |= (1 \u003c\u003c (crc_bits \u0026 7));\n+\t\t}\n+\n+\t\tax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_MULFLTARY,\n+\t\t\t\t\tAX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE,\n+\t\t\t\t\tm_filter);\n+\n+\t\tdata-\u003erxctl |= AX_RX_CTL_AM;\n+\t}\n+\n+\tax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL,\n+\t\t\t\t2, 2, \u0026data-\u003erxctl);\n+}\n+\n+int ax88179_set_features(struct net_device *net, netdev_features_t features)\n+{\n+\tu8 tmp;\n+\tstruct usbnet *dev = netdev_priv(net);\n+\tstruct ax88179_data *data = dev-\u003edriver_priv;\n+\tnetdev_features_t changed = net-\u003efeatures ^ features;\n+\n+\tif (changed \u0026 NETIF_F_IP_CSUM) {\n+\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, \u0026tmp);\n+\t\ttmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, \u0026tmp);\n+\t}\n+\n+\tif (changed \u0026 NETIF_F_IPV6_CSUM) {\n+\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, \u0026tmp);\n+\t\ttmp ^= AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, \u0026tmp);\n+\t}\n+\n+\tif (changed \u0026 NETIF_F_RXCSUM) {\n+\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, \u0026tmp);\n+\t\ttmp ^= AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |\n+\t\t       AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, \u0026tmp);\n+\t\tdata-\u003erx_checksum = !!(features \u0026 NETIF_F_RXCSUM);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+void ax88179_get_mac_addr(struct usbnet *dev)\n+{\n+\tu8 mac[ETH_ALEN];\n+\n+\tmemset(mac, 0, sizeof(mac));\n+\n+\t/* Maybe the boot loader passed the MAC address via device tree */\n+\tif (!eth_platform_get_mac_address(\u0026dev-\u003eudev-\u003edev, mac)) {\n+\t\tnetif_dbg(dev, ifup, dev-\u003enet,\n+\t\t\t  \"MAC address read from device tree\");\n+\t} else {\n+\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,\n+\t\t\t\t ETH_ALEN, mac);\n+\t\tnetif_dbg(dev, ifup, dev-\u003enet,\n+\t\t\t  \"MAC address read from ASIX chip\");\n+\t}\n+\n+\tif (is_valid_ether_addr(mac)) {\n+\t\teth_hw_addr_set(dev-\u003enet, mac);\n+\t\tif (!is_local_ether_addr(mac))\n+\t\t\tdev-\u003enet-\u003eaddr_assign_type = NET_ADDR_PERM;\n+\t} else {\n+\t\tnetdev_info(dev-\u003enet, \"invalid MAC address, using random\\n\");\n+\t}\n+\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN,\n+\t\t\t  dev-\u003enet-\u003edev_addr);\n+}\n+\n+int ax88179_change_mtu(struct net_device *net, int new_mtu)\n+{\n+\tstruct usbnet *dev = netdev_priv(net);\n+\tu16 tmp16;\n+\n+\tWRITE_ONCE(net-\u003emtu, new_mtu);\n+\tdev-\u003ehard_mtu = net-\u003emtu + net-\u003ehard_header_len;\n+\n+\tif (net-\u003emtu \u003e 1500) {\n+\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,\n+\t\t\t\t 2, 2, \u0026tmp16);\n+\t\ttmp16 |= AX_MEDIUM_JUMBO_EN;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,\n+\t\t\t\t  2, 2, \u0026tmp16);\n+\t} else {\n+\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,\n+\t\t\t\t 2, 2, \u0026tmp16);\n+\t\ttmp16 \u0026= ~AX_MEDIUM_JUMBO_EN;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,\n+\t\t\t\t  2, 2, \u0026tmp16);\n+\t}\n+\n+\t/* max qlen depend on hard_mtu and rx_urb_size */\n+\tusbnet_update_max_qlen(dev);\n+\n+\treturn 0;\n+}\n+\n+int ax88179_set_mac_addr(struct net_device *net, void *p)\n+{\n+\tstruct usbnet *dev = netdev_priv(net);\n+\tstruct sockaddr *addr = p;\n+\tint ret;\n+\n+\tif (netif_running(net))\n+\t\treturn -EBUSY;\n+\tif (!is_valid_ether_addr(addr-\u003esa_data))\n+\t\treturn -EADDRNOTAVAIL;\n+\n+\teth_hw_addr_set(net, addr-\u003esa_data);\n+\n+\t/* Set the MAC address */\n+\tret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,\n+\t\t\t\tETH_ALEN, net-\u003edev_addr);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\n+\n+int ax88179_suspend_wrapper(struct usb_interface *intf, pm_message_t message)\n+{\n+\tstruct usbnet *dev = usb_get_intfdata(intf);\n+\tstruct ax88179_data *priv;\n+\n+\tpriv = dev-\u003edriver_priv;\n+\n+\treturn priv-\u003esuspend(intf, message);\n+}\n+\n+int ax88179_resume_wrapper(struct usb_interface *intf)\n+{\n+\tstruct usbnet *dev = usb_get_intfdata(intf);\n+\tstruct ax88179_data *priv;\n+\n+\tpriv = dev-\u003edriver_priv;\n+\treturn priv-\u003eresume(intf);\n+}\n+\ndiff --git a/drivers/net/usb/ax88179_lib.h b/drivers/net/usb/ax88179_lib.h\nnew file mode 100644\nindex 0000000000000..16a6dcbd6e66e\n--- /dev/null\n+++ b/drivers/net/usb/ax88179_lib.h\n@@ -0,0 +1,358 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+\n+#include \u003clinux/usb.h\u003e\n+#include \u003clinux/crc32.h\u003e\n+#include \u003clinux/phylink.h\u003e\n+#include \u003clinux/usb/usbnet.h\u003e\n+\n+#ifndef __LINUX_USBNET_AX88179_H\n+#define __LINUX_USBNET_AX88179_H\n+\n+#define AX88179_PHY_ID\t\t\t\t0x03\n+#define AX_EEPROM_LEN\t\t\t\t0x100\n+#define AX88179_EEPROM_MAGIC\t\t\t0x17900b95\n+#define AX_MCAST_FLTSIZE\t\t\t8\n+#define AX_MAX_MCAST\t\t\t\t64\n+#define AX_INT_PPLS_LINK\t\t\t((u32)BIT(16))\n+#define AX_RXHDR_L4_TYPE_MASK\t\t\t0x1c\n+#define AX_RXHDR_L4_TYPE_UDP\t\t\t4\n+#define AX_RXHDR_L4_TYPE_TCP\t\t\t16\n+#define AX_RXHDR_L3CSUM_ERR\t\t\t2\n+#define AX_RXHDR_L4CSUM_ERR\t\t\t1\n+#define AX_RXHDR_CRC_ERR\t\t\t((u32)BIT(29))\n+#define AX_RXHDR_DROP_ERR\t\t\t((u32)BIT(31))\n+#define AX_ACCESS_MAC\t\t\t\t0x01\n+#define AX_ACCESS_PHY\t\t\t\t0x02\n+#define AX_ACCESS_EEPROM\t\t\t0x04\n+#define AX_ACCESS_EFUS\t\t\t\t0x05\n+#define AX_RELOAD_EEPROM_EFUSE\t\t\t0x06\n+#define AX88179A_WAKEUP_SETTING\t\t\t0x07\n+#define AX_FW_MODE\t\t\t\t0x08\n+#define AX_GPHY_CTL\t\t\t\t0x0F\n+#define AX88179A_FLASH_READ\t\t\t0x21\n+#define AX88179A_FLASH_WEN\t\t\t0x22\n+#define AX88179A_FLASH_WDIS\t\t\t0x23\n+#define AX88179A_FLASH_WRITE\t\t\t0x24\n+#define AX88179A_PHY_CLAUSE45\t\t\t0x27\n+#define AX88179A_FLASH_ERASE_SECTION\t\t0x28\n+#define AX88179A_ACCESS_BL\t\t\t0x2A\n+#define AX88179A_PHY_POWER\t\t\t0x31\n+#define AX88179A_AUTODETACH\t\t\t0xC0\n+\n+#define AX_PAUSE_WATERLVL_LOW\t\t\t0x54\n+#define AX_PAUSE_WATERLVL_HIGH\t\t\t0x55\n+\n+#define AX_FW_MODE_179A\t\t\t\t0x01\n+#define PHYSICAL_LINK_STATUS\t\t\t0x02\n+\t#define\tAX_USB_SS\t\t0x04\n+\t#define\tAX_USB_HS\t\t0x02\n+\t#define AX_USB_FS\t\t0x01\n+\n+#define GENERAL_STATUS\t\t\t\t0x03\n+/* Check AX88179 version. UA1:Bit2 = 0,  UA2:Bit2 = 1 */\n+\t#define\tAX_SECLD\t\t0x04\n+\n+#define AX_CHIP_STATUS\t\t\t\t0x05\n+\n+#define AX_SROM_ADDR\t\t\t\t0x07\n+#define AX_SROM_CMD\t\t\t\t0x0a\n+\t#define EEP_RD\t\t\t0x04\n+\t#define EEP_BUSY\t\t0x10\n+\n+#define AX_SROM_DATA_LOW\t\t\t0x08\n+#define AX_SROM_DATA_HIGH\t\t\t0x09\n+\n+#define AX_RX_CTL\t\t\t\t0x0b\n+\t#define AX_RX_CTL_DROPCRCERR\t0x0100\n+\t#define AX_RX_CTL_IPE\t\t0x0200\n+\t#define AX_RX_CTL_START\t\t0x0080\n+\t#define AX_RX_CTL_AP\t\t0x0020\n+\t#define AX_RX_CTL_AM\t\t0x0010\n+\t#define AX_RX_CTL_AB\t\t0x0008\n+\t#define AX_RX_CTL_AMALL\t\t0x0002\n+\t#define AX_RX_CTL_PRO\t\t0x0001\n+\t#define AX_RX_CTL_STOP\t\t0x0000\n+\n+#define AX88179A_ETH_TX_GAP\t\t\t0x0D\n+\n+#define AX88179A_BFM_DATA\t\t\t0x0E\n+\t#define AX_TX_QUEUE_CFG\t\t0x02\n+\t#define AX_TX_QUEUE_SET\t\t0x08\n+\t#define AX_TX_Q1_AHB_FC_EN\t0x10\n+\t#define AX_TX_Q2_AHB_FC_EN\t0x20\n+\t#define AX_XGMII_EN\t\t0x80\n+\n+#define AX_NODE_ID\t\t\t\t0x10\n+#define AX_MULFLTARY\t\t\t\t0x16\n+\n+#define AX_MEDIUM_STATUS_MODE\t\t\t0x22\n+\t#define AX_MEDIUM_GIGAMODE\t0x01\n+\t#define AX_MEDIUM_FULL_DUPLEX\t0x02\n+\t#define AX_MEDIUM_EN_125MHZ\t0x08\n+\t#define AX_MEDIUM_RXFLOW_CTRLEN\t0x10\n+\t#define AX_MEDIUM_TXFLOW_CTRLEN\t0x20\n+\t#define AX_MEDIUM_RECEIVE_EN\t0x100\n+\t#define AX_MEDIUM_PS\t\t0x200\n+\t#define AX_MEDIUM_JUMBO_EN\t0x8040\n+\n+#define AX_MONITOR_MOD\t\t\t\t0x24\n+\t#define AX_MONITOR_MODE_RWLC\t0x02\n+\t#define AX_MONITOR_MODE_RWMP\t0x04\n+\t#define AX_MONITOR_MODE_PMEPOL\t0x20\n+\t#define AX_MONITOR_MODE_PMETYPE\t0x40\n+\n+#define AX_GPIO_CTRL\t\t\t\t0x25\n+\t#define AX_GPIO_CTRL_GPIO3EN\t0x80\n+\t#define AX_GPIO_CTRL_GPIO2EN\t0x40\n+\t#define AX_GPIO_CTRL_GPIO1EN\t0x20\n+\n+#define AX_PHYPWR_RSTCTL\t\t\t0x26\n+\t#define AX_PHYPWR_RSTCTL_BZ\t0x0010\n+\t#define AX_PHYPWR_RSTCTL_IPRL\t0x0020\n+\t#define AX_PHYPWR_RSTCTL_AT\t0x1000\n+\n+#define AX88179A_VLAN_ID_ADDRESS\t\t0x2A\n+\n+#define AX88179A_VLAN_ID_CONTROL\t\t0x2B\n+\t#define AX_VLAN_CONTROL_WE\t0x0001\n+\t#define AX_VLAN_CONTROL_RD\t0x0002\n+\t#define AX_VLAN_CONTROL_VSO\t0x0010\n+\t#define AX_VLAN_CONTROL_VFE\t0x0020\n+\n+#define AX88179A_VLAN_ID_DATA0\t\t\t0x2C\n+#define AX88179A_VLAN_ID_DATA1\t\t\t0x2D\n+\n+#define AX_RX_BULKIN_QCTRL\t\t\t0x2e\n+#define AX_GPHY_EEE_CTRL\t\t\t0x01\n+\n+#define AX_CLK_SELECT\t\t\t\t0x33\n+\t#define AX_CLK_SELECT_BCS\t0x01\n+\t#define AX_CLK_SELECT_ACS\t0x02\n+\t#define AX_CLK_SELECT_ULR\t0x08\n+\n+#define AX_RXCOE_CTL\t\t\t\t0x34\n+\t#define AX_RXCOE_IP\t\t0x01\n+\t#define AX_RXCOE_TCP\t\t0x02\n+\t#define AX_RXCOE_UDP\t\t0x04\n+\t#define AX_RXCOE_TCPV6\t\t0x20\n+\t#define AX_RXCOE_UDPV6\t\t0x40\n+\n+#define AX_TXCOE_CTL\t\t\t\t0x35\n+\t#define AX_TXCOE_IP\t\t0x01\n+\t#define AX_TXCOE_TCP\t\t0x02\n+\t#define AX_TXCOE_UDP\t\t0x04\n+\t#define AX_TXCOE_TCPV6\t\t0x20\n+\t#define AX_TXCOE_UDPV6\t\t0x40\n+\n+#define AX88179A_MAC_BM_INT_MASK\t\t0x41\n+#define AX88179A_MAC_BM_RX_DMA_CTL\t\t0x43\n+#define AX88179A_MAC_BM_TX_DMA_CTL\t\t0x46\n+\n+#define AX88179A_MAC_RX_STATUS_CDC\t\t0x6D\n+\t#define AX_LSOFC_WCNT_7_ACCESS\t0x03\n+\t#define AX_GMII_CRC_APPEND\t0x10\n+\n+#define AX_LEDCTRL\t\t\t\t0x73\n+#define AX88179A_MAC_ARC_CTRL\t\t\t0x9E\n+#define AX88179A_MAC_SWP_CTRL\t\t\t0xB1\n+\n+#define AX88179A_MAC_TX_PAUSE\t\t\t0xB2\n+\n+#define AX88179A_MAC_CDC_DELAY_TX\t\t0xB5\n+\n+#define AX88179A_MAC_PATH\t\t\t0xB7\n+\t#define AX_MAC_RX_PATH_READY\t0x01\n+\t#define AX_MAC_TX_PATH_READY\t0x02\n+\n+#define AX88179A_NEW_PAUSE_CTRL\t\t\t0xB8\n+\t#define AX_NEW_PAUSE_EN\t\t0x01\n+\n+#define AX88179A_MAC_BULK_OUT_CTRL\t\t0xB9\n+\t#define AX_MAC_EFF_EN\t\t0x02\n+\n+#define AX88179A_MAC_RX_DATA_CDC_CNT\t\t0xC0\n+\t#define AX_MAC_LSO_ERR_EN\t0x04\n+\t#define AX_MAC_MIQFFCTRL_FORMAT\t0x10\n+\t#define AX_MAC_MIQFFCTRL_DROP_CRC 0x20\n+\n+#define AX88179A_AUTODETACH_DELAY\t(5UL \u003c\u003c 8)\n+#define AX88179A_AUTODETACH_EN\t\t1\n+\n+#define AX88179A_MAC_LSO_ENHANCE_CTRL\t\t0xC3\n+\t#define AX_LSO_ENHANCE_EN\t0x01\n+\n+#define AX88179A_MAC_TX_HDR_CKSUM\t\t0xCC\n+#define AX88179A_EP5_EHR\t\t\t0xF9\n+\n+#define AX_PHY_POWER\t\t\t\t0x02\n+\n+#define EPHY_LOW_POWER_EN\t\t\t0x01\n+#define S5_WOL_EN\t\t\t\t0x04\n+#define S5_WOL_LOW_POWER\t\t\t0x20\n+\n+#define GMII_PHY_PHYSR\t\t\t\t0x11\n+\t#define GMII_PHY_PHYSR_SMASK\t0xc000\n+\t#define GMII_PHY_PHYSR_GIGA\t0x8000\n+\t#define GMII_PHY_PHYSR_100\t0x4000\n+\t#define GMII_PHY_PHYSR_FULL\t0x2000\n+\t#define GMII_PHY_PHYSR_LINK\t0x400\n+\n+#define GMII_LED_ACT\t\t\t\t0x1a\n+\t#define\tGMII_LED_ACTIVE_MASK\t0xff8f\n+\t#define\tGMII_LED0_ACTIVE\tBIT(4)\n+\t#define\tGMII_LED1_ACTIVE\tBIT(5)\n+\t#define\tGMII_LED2_ACTIVE\tBIT(6)\n+\n+#define GMII_LED_LINK\t\t\t\t0x1c\n+\t#define\tGMII_LED_LINK_MASK\t0xf888\n+\t#define\tGMII_LED0_LINK_10\tBIT(0)\n+\t#define\tGMII_LED0_LINK_100\tBIT(1)\n+\t#define\tGMII_LED0_LINK_1000\tBIT(2)\n+\t#define\tGMII_LED1_LINK_10\tBIT(4)\n+\t#define\tGMII_LED1_LINK_100\tBIT(5)\n+\t#define\tGMII_LED1_LINK_1000\tBIT(6)\n+\t#define\tGMII_LED2_LINK_10\tBIT(8)\n+\t#define\tGMII_LED2_LINK_100\tBIT(9)\n+\t#define\tGMII_LED2_LINK_1000\tBIT(10)\n+\t#define\tLED0_ACTIVE\t\tBIT(0)\n+\t#define\tLED0_LINK_10\t\tBIT(1)\n+\t#define\tLED0_LINK_100\t\tBIT(2)\n+\t#define\tLED0_LINK_1000\t\tBIT(3)\n+\t#define\tLED0_FD\t\t\tBIT(4)\n+\t#define\tLED0_USB3_MASK\t\t0x001f\n+\t#define\tLED1_ACTIVE\t\tBIT(5)\n+\t#define\tLED1_LINK_10\t\tBIT(6)\n+\t#define\tLED1_LINK_100\t\tBIT(7)\n+\t#define\tLED1_LINK_1000\t\tBIT(8)\n+\t#define\tLED1_FD\t\t\tBIT(9)\n+\t#define\tLED1_USB3_MASK\t\t0x03e0\n+\t#define\tLED2_ACTIVE\t\tBIT(10)\n+\t#define\tLED2_LINK_1000\t\tBIT(13)\n+\t#define\tLED2_LINK_100\t\tBIT(12)\n+\t#define\tLED2_LINK_10\t\tBIT(11)\n+\t#define\tLED2_FD\t\t\tBIT(14)\n+\t#define\tLED_VALID\t\tBIT(15)\n+\t#define\tLED2_USB3_MASK\t\t0x7c00\n+\n+#define GMII_PHYPAGE\t\t\t\t0x1e\n+#define GMII_PHY_PAGE_SELECT\t\t\t0x1f\n+\t#define GMII_PHY_PGSEL_EXT\t0x0007\n+\t#define GMII_PHY_PGSEL_PAGE0\t0x0000\n+\t#define GMII_PHY_PGSEL_PAGE3\t0x0003\n+\t#define GMII_PHY_PGSEL_PAGE5\t0x0005\n+\n+/* TX Descriptor */\n+#define AX179A_TX_DESC_LEN_MASK\t\t0x1FFFFF\n+#define AX179A_TX_DESC_DROP_PADD\tBIT(28)\n+#define AX179A_TX_DESC_VLAN\t\tBIT(29)\n+#define AX179A_TX_DESC_MSS_MASK\t\t0x7FFF\n+#define AX179A_TX_DESC_MSS_SHIFT\t0x20\n+#define AX179A_TX_DESC_VLAN_MASK\t0xFFFF\n+#define AX179A_TX_DESC_VLAN_SHIFT\t0x30\n+\n+/* RX Packet Descriptor */\n+#define AX179A_RX_PD_L4_ERR\t\tBIT(0)\n+#define AX179A_RX_PD_L3_ERR\t\tBIT(1)\n+#define AX179A_RX_PD_L4_TYPE_MASK\t0x1C\n+#define AX179A_RX_PD_L4_UDP\t\t0x04\n+#define AX179A_RX_PD_L4_TCP\t\t0x10\n+#define AX179A_RX_PD_L3_TYPE_MASK\t0x60\n+#define AX179A_RX_PD_L3_IP\t\t0x20\n+#define AX179A_RX_PD_L3_IP6\t\t0x40\n+\n+#define AX179A_RX_PD_VLAN\t\tBIT(10)\n+#define AX179A_RX_PD_RX_OK\t\tBIT(11)\n+#define AX179A_RX_PD_DROP\t\tBIT(31)\n+#define AX179A_RX_PD_LEN_MASK\t0x7FFF0000\n+#define AX179A_RX_PD_LEN_SHIFT\t0x10\n+#define AX179A_RX_PD_VLAN_SHIFT\t0x20\n+\n+/* RX Descriptor header */\n+#define AX179A_RX_DH_PKT_CNT_MASK\t\t0x1FFF\n+#define AX179A_RX_DH_DESC_OFFSET_MASK\t0xFFFFE000\n+#define AX179A_RX_DH_DESC_OFFSET_SHIFT\t0x0D\n+\n+#define AX179A_RX_HW_PAD\t\t\t0x02\n+\n+#define AX_ADVERTISE_2500\t\t0x1000\n+\n+enum ax_ether_link_speed {\n+\tETHER_LINK_NONE = 0,\n+\tETHER_LINK_10   = 1,\n+\tETHER_LINK_100  = 2,\n+\tETHER_LINK_1000 = 3,\n+\tETHER_LINK_2500 = 4,\n+};\n+\n+enum ax_chip_version {\n+\tAX_VERSION_INVALID\t\t= 0x0,\n+\tAX_VERSION_AX88179\t\t= 0x4,\n+\tAX_VERSION_AX88179A\t\t= 0x6,\t/* Also AX88772D */\n+\tAX_VERSION_AX88279\t\t= 0x7,\n+};\n+\n+struct ax88179_data {\n+\tu8  eee_enabled;\n+\tu8  eee_active;\n+\tu16 rxctl;\n+\tu8 in_pm;\n+\tu32 wol_supported;\n+\tu32 wolopts;\n+\tu8 disconnecting;\n+\tu8 chip_version;\n+\tu8 fw_version[4];\n+\tu8 is_ax88772d;\n+\tu8 ip_align;\n+\tu8 link;\n+\tu8 speed;\n+\tu8 full_duplex;\n+\tu8 rx_checksum;\n+\tu8 eeprom_read_cmd;\n+\tu8 eeprom_write_cmd;\n+\tu8 eeprom_wen;\n+\tu16 eeprom_block;\n+\tstruct mii_bus *mdio;\n+\tstruct phy_device *phydev;\n+\tstruct phylink *phylink;\n+\tstruct phylink_config phylink_config;\n+\tint (*resume)(struct usb_interface *intf);\n+\tint (*suspend)(struct usb_interface *intf, pm_message_t message);\n+};\n+\n+struct ax88179_int_data {\n+\t__le32 intdata1;\n+\t__le32 intdata2;\n+};\n+\n+struct ax_bulkin_settings {\n+\tunsigned char ctrl, timer_l, timer_h, size, ifg;\n+};\n+\n+void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode);\n+int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data);\n+int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data);\n+int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size,\n+\t\t      const void *data);\n+void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,\n+\t\t\t     u16 size, void *data);\n+int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc);\n+void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc, int val);\n+struct ax88179_data *netdev2data(struct net_device *net);\n+void ax88179_status(struct usbnet *dev, struct urb *urb);\n+void ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo);\n+int ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo);\n+int ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 *data);\n+int ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 *data);\n+void ax88179_set_multicast(struct net_device *net);\n+int ax88179_set_features(struct net_device *net, netdev_features_t features);\n+void ax88179_get_mac_addr(struct usbnet *dev);\n+int ax88179_change_mtu(struct net_device *net, int new_mtu);\n+int ax88179_set_mac_addr(struct net_device *net, void *p);\n+int ax88179_suspend_wrapper(struct usb_interface *intf, pm_message_t message);\n+int ax88179_resume_wrapper(struct usb_interface *intf);\n+\n+extern const struct driver_info ax88179a_info;\n+extern const struct driver_info ax88772d_info;\n+extern const struct driver_info ax88279_info;\n+\n+#endif /*__LINUX_USBNET_AX88179_H */\ndiff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c\nnew file mode 100644\nindex 0000000000000..6b57111a0e05a\n--- /dev/null\n+++ b/drivers/net/usb/ax88179a_devices.c\n@@ -0,0 +1,1222 @@\n+// SPDX-License-Identifier: GPL-2.0-or-later\n+\n+#include \u003clinux/module.h\u003e\n+#include \u003clinux/phylink.h\u003e\n+#include \u003clinux/if_vlan.h\u003e\n+#include \"ax88179_lib.h\"\n+\n+static int ax88179a_reset(struct usbnet *dev);\n+\n+#define AX88279_EEPROM_LEN\t\t\t0x4000\n+#define AX88179A_EEPROM_LEN\t\t\t(32 * 20)\n+\n+enum ax_bulk_in_speeds {\n+\tBULK_IN_SPEED_2G5 = 0,\n+\tBULK_IN_SPEED_1G_SS = 1,\n+\tBULK_IN_SPEED_1G_HS   = 2,\n+\tBULK_IN_SPEED_100_FULL_SS = 3,\n+\tBULK_IN_SPEED_100_HALF_SS = 4,\n+\tBULK_IN_SPEED_100_FULL_HS = 5,\n+\tBULK_IN_SPEED_100_HALF_HS = 6,\n+\tBULK_IN_SPEED_FS = 7,\n+};\n+\n+static const struct ax_bulkin_settings AX88179A_BULKIN_SIZE[] = {\n+\t[BULK_IN_SPEED_1G_SS]\t\t= {5, 0x7B, 0x00, 0x17, 0x0F},\n+\t[BULK_IN_SPEED_1G_HS]\t\t= {5, 0xC0, 0x02, 0x06, 0x0F},\n+\t[BULK_IN_SPEED_100_FULL_SS]\t= {7, 0xF0, 0x00, 0x0C, 0x0F},\n+\t[BULK_IN_SPEED_100_HALF_SS]\t= {6, 0x00, 0x00, 0x06, 0x0F},\n+\t[BULK_IN_SPEED_100_FULL_HS]\t= {5, 0xC0, 0x04, 0x06, 0x0F},\n+\t[BULK_IN_SPEED_100_HALF_HS]\t= {7, 0xC0, 0x04, 0x06, 0x0F},\n+\t[BULK_IN_SPEED_FS]\t\t= {7, 0x00, 0x00, 0x03, 0x3F},\n+};\n+\n+static const struct ax_bulkin_settings AX88772D_BULKIN_SIZE[] = {\n+\t[BULK_IN_SPEED_100_FULL_HS]\t= {5, 0xC0, 0x04, 0x06, 0x0F},\n+\t[BULK_IN_SPEED_100_HALF_HS]\t= {7, 0xC0, 0x04, 0x06, 0x0F},\n+\t[BULK_IN_SPEED_FS]\t\t= {7, 0x00, 0x00, 0x03, 0x3F},\n+};\n+\n+static const struct ax_bulkin_settings AX88279_BULKIN_SIZE[] = {\n+\t[BULK_IN_SPEED_2G5]\t\t= {5, 0x10, 0x01, 0x11, 0x0F},\n+\t[BULK_IN_SPEED_1G_SS]\t\t= {7, 0xB3, 0x01, 0x11, 0x0F},\n+\t[BULK_IN_SPEED_1G_HS]\t\t= {7, 0xC0, 0x02, 0x06, 0x0F},\n+\t[BULK_IN_SPEED_100_FULL_SS]\t= {7, 0x80, 0x01, 0x03, 0x0F},\n+\t[BULK_IN_SPEED_100_HALF_SS]\t= {7, 0x80, 0x01, 0x03, 0x0F},\n+\t[BULK_IN_SPEED_100_FULL_HS]\t= {7, 0x80, 0x01, 0x03, 0x0F},\n+\t[BULK_IN_SPEED_100_HALF_HS]\t= {7, 0x80, 0x01, 0x03, 0x0F},\n+\t[BULK_IN_SPEED_FS]\t\t= {7, 0x00, 0x00, 0x03, 0x3F},\n+};\n+\n+static int ax88179_mdiobus_read(struct mii_bus *bus, int phy_id, int regnum)\n+{\n+\tstruct usbnet *dev = bus-\u003epriv;\n+\tstruct ax88179_data *priv;\n+\tu16 res;\n+\n+\tpriv = dev-\u003edriver_priv;\n+\t/* When reading PHYSID, return unused PHY-IDs from the ASIX vendor range */\n+\tif (phy_id == AX88179_PHY_ID \u0026\u0026 regnum == MII_PHYSID1)\n+\t\treturn 0x003b;\n+\tif (phy_id == AX88179_PHY_ID \u0026\u0026 regnum == MII_PHYSID2) {\n+\t\tif (priv-\u003echip_version == AX_VERSION_AX88179A \u0026\u0026 priv-\u003eis_ax88772d)\n+\t\t\treturn 0x772d;\n+\t\telse if (priv-\u003echip_version == AX_VERSION_AX88179A)\n+\t\t\treturn 0x179a;\n+\t\telse if (priv-\u003echip_version == AX_VERSION_AX88279)\n+\t\t\treturn 0x2790;\n+\t}\n+\n+\tax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)regnum, 2, \u0026res);\n+\treturn res;\n+}\n+\n+static int ax88179_mdiobus_write(struct mii_bus *bus, int phy_id, int regnum, u16 val)\n+{\n+\tstruct usbnet *dev = bus-\u003epriv;\n+\n+\treturn ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)regnum, 2, \u0026val);\n+}\n+\n+static int ax179a_read_mmd(struct usbnet *dev, u16 dev_addr, u16 reg)\n+{\n+\tu16 res;\n+\tint ret;\n+\n+\tret = ax88179_read_cmd(dev, AX88179A_PHY_CLAUSE45, dev_addr, reg, 2, \u0026res);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\treturn res;\n+}\n+\n+static int ax179a_write_mmd(struct usbnet *dev, u16 dev_addr, u16 reg, u16 data)\n+{\n+\treturn ax88179_write_cmd(dev, AX88179A_PHY_CLAUSE45, dev_addr, reg, 2, \u0026data);\n+}\n+\n+static int ax88179_mdiobus_read_c45(struct mii_bus *bus, int addr, int devnum, int regnum)\n+{\n+\tstruct usbnet *dev = bus-\u003epriv;\n+\n+\tif (addr != AX88179_PHY_ID)\n+\t\treturn -EINVAL;\n+\n+\treturn ax179a_read_mmd(dev, devnum, regnum);\n+}\n+\n+static int ax88179_mdiobus_write_c45(struct mii_bus *bus, int addr, int devnum,\n+\t\t\t\t     int regnum, u16 val)\n+{\n+\tstruct usbnet *dev = bus-\u003epriv;\n+\n+\tif (addr != AX88179_PHY_ID)\n+\t\treturn -EINVAL;\n+\n+\treturn ax179a_write_mmd(dev, devnum, regnum, val);\n+}\n+\n+static void ax88179a_status(struct usbnet *dev, struct urb *urb)\n+{\n+\tstruct ax88179_data *data = dev-\u003edriver_priv;\n+\tstruct ax88179_int_data *event;\n+\tu32 link;\n+\n+\tif (urb-\u003eactual_length \u003c 8)\n+\t\treturn;\n+\n+\tevent = urb-\u003etransfer_buffer;\n+\tle32_to_cpus((void *)\u0026event-\u003eintdata1);\n+\n+\tlink = (((__force u32)event-\u003eintdata1) \u0026 AX_INT_PPLS_LINK) \u003e\u003e 16;\n+\n+\tif (netif_carrier_ok(dev-\u003enet) != link) {\n+\t\tusbnet_link_change(dev, link, 1);\n+\t\tphylink_mac_interrupt(data-\u003ephylink);\n+\t}\n+}\n+\n+static int ax88179a_suspend(struct usb_interface *intf, pm_message_t message)\n+{\n+\tstruct usbnet *dev = usb_get_intfdata(intf);\n+\tstruct ax88179_data *priv;\n+\tu16 tmp16;\n+\tu8 tmp8;\n+\n+\tpriv = dev-\u003edriver_priv;\n+\tax88179_set_pm_mode(dev, true);\n+\n+\tif (netif_running(dev-\u003enet)) {\n+\t\trtnl_lock();\n+\t\tphylink_suspend(priv-\u003ephylink, !!priv-\u003ewolopts);\n+\t\trtnl_unlock();\n+\t}\n+\n+\t/* Enable WoL */\n+\tif (priv-\u003ewolopts) {\n+\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, \u0026tmp8);\n+\t\tif (priv-\u003ewolopts \u0026 WAKE_PHY)\n+\t\t\ttmp8 |= AX_MONITOR_MODE_RWLC;\n+\t\tif (priv-\u003ewolopts \u0026 WAKE_MAGIC)\n+\t\t\ttmp8 |= AX_MONITOR_MODE_RWMP;\n+\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, \u0026tmp8);\n+\n+\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, \u0026tmp16);\n+\t\ttmp16 |= AX_MEDIUM_RECEIVE_EN;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, \u0026tmp16);\n+\n+\t\tif (priv-\u003echip_version == AX_VERSION_AX88279)\n+\t\t\tax88179_write_cmd(dev, AX88179A_WAKEUP_SETTING, 8,\n+\t\t\t\t\t  EPHY_LOW_POWER_EN | S5_WOL_EN\n+\t\t\t\t\t  | S5_WOL_LOW_POWER | 0x8000, 0, NULL);\n+\t\telse\n+\t\t\tax88179_write_cmd(dev, AX88179A_WAKEUP_SETTING, 0,\n+\t\t\t\t\t  EPHY_LOW_POWER_EN, 0, NULL);\n+\n+\t} else if (priv-\u003echip_version == AX_VERSION_AX88279) {\n+\t\tax88179_write_cmd(dev, AX88179A_WAKEUP_SETTING, 8, 0x8000, 0, NULL);\n+\t}\n+\n+\tusbnet_suspend(intf, message);\n+\tax88179_set_pm_mode(dev, false);\n+\treturn 0;\n+}\n+\n+static int ax88179a_auto_detach(struct usbnet *dev)\n+{\n+\tu16 tmp16;\n+\n+\ttmp16 = AX88179A_AUTODETACH_DELAY;\n+\tax88179_write_cmd(dev, AX88179A_AUTODETACH, tmp16, 0, 0, NULL);\n+\treturn 0;\n+}\n+\n+static int ax88179a_resume(struct usb_interface *intf)\n+{\n+\tstruct usbnet *dev = usb_get_intfdata(intf);\n+\tstruct ax88179_data *ax179_data;\n+\tu8 reg8;\n+\n+\tax179_data = dev-\u003edriver_priv;\n+\tax88179_set_pm_mode(dev, true);\n+\n+\tax88179_read_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, \u0026reg8);\n+\tif (!(reg8 \u0026 AX_PHY_POWER)) {\n+\t\treg8 = AX_PHY_POWER;\n+\t\tax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, \u0026reg8);\n+\t\tmsleep(250);\n+\t}\n+\tax88179_write_cmd(dev, AX_FW_MODE, AX_FW_MODE_179A, 0, 0, NULL);\n+\n+\t/* Now, that AX_FW_MODE_179A is enabled, the PHY needs a power-cycle.\n+\t * PHY-power is re-enabled in ax88179_reset()\n+\t */\n+\treg8 = 0;\n+\tax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, \u0026reg8);\n+\tmsleep(250);\n+\n+\tif (netif_running(dev-\u003enet)) {\n+\t\trtnl_lock();\n+\t\tphylink_resume(ax179_data-\u003ephylink);\n+\t\trtnl_unlock();\n+\t}\n+\n+\tax88179a_reset(dev);\n+\n+\tax88179_set_pm_mode(dev, false);\n+\n+\treturn usbnet_resume(intf);\n+}\n+\n+static void ax88179a_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)\n+{\n+\tstruct ax88179_data *priv = netdev2data(net);\n+\n+\t/* Inherit standard device info */\n+\tusbnet_get_drvinfo(net, info);\n+\tif (priv-\u003echip_version \u003c AX_VERSION_AX88179A)\n+\t\treturn;\n+\n+\tsnprintf(info-\u003efw_version, sizeof(info-\u003efw_version), \"%d.%d.%d.%d\",\n+\t\t priv-\u003efw_version[0], priv-\u003efw_version[1],\n+\t\t priv-\u003efw_version[2], priv-\u003efw_version[3]);\n+}\n+\n+static void ax88179a_bulkin_config(struct usbnet *dev, u8 link_sts, u8 speed, bool full_duplex)\n+{\n+\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n+\tconst struct ax_bulkin_settings *bulkin_data;\n+\tint index = 0;\n+\n+\tswitch (speed) {\n+\tcase ETHER_LINK_2500:\t/* AX88279 only */\n+\t\tindex = BULK_IN_SPEED_2G5;\n+\t\tbreak;\n+\n+\tcase ETHER_LINK_1000:\t/* AX88279 \u0026 AX88178A */\n+\t\tif (link_sts \u0026 AX_USB_SS)\n+\t\t\tindex = BULK_IN_SPEED_1G_SS;\n+\t\telse if (link_sts \u0026 AX_USB_HS)\n+\t\t\tindex = BULK_IN_SPEED_1G_HS;\n+\t\tbreak;\n+\n+\tcase ETHER_LINK_100:\n+\t\tif (link_sts \u0026 AX_USB_SS)\n+\t\t\tindex = BULK_IN_SPEED_100_FULL_SS;\n+\t\telse if (link_sts \u0026 AX_USB_HS)\n+\t\t\tindex = BULK_IN_SPEED_100_FULL_HS;\n+\t\tif (!full_duplex)\n+\t\t\tindex++;\n+\t\tbreak;\n+\n+\tcase ETHER_LINK_10:\n+\t\tindex = BULK_IN_SPEED_FS;\n+\t\tbreak;\n+\n+\tdefault:\t/* No link */\n+\t\tindex = BULK_IN_SPEED_FS;\n+\t}\n+\n+\tif (ax179_data-\u003echip_version == AX_VERSION_AX88279 \u0026\u0026 (link_sts \u0026 AX_USB_FS))\n+\t\tindex = BULK_IN_SPEED_FS;\n+\n+\tif (ax179_data-\u003echip_version == AX_VERSION_AX88279) {\n+\t\tbulkin_data = AX88279_BULKIN_SIZE;\n+\t} else {\n+\t\tif (ax179_data-\u003eis_ax88772d)\n+\t\t\tbulkin_data = AX88772D_BULKIN_SIZE;\n+\t\telse\n+\t\t\tbulkin_data = AX88179A_BULKIN_SIZE;\n+\t}\n+\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, \u0026bulkin_data[index]);\n+}\n+\n+static void ax88179a_get_pauseparam(struct net_device *net, struct ethtool_pauseparam *pause)\n+{\n+\tstruct ax88179_data *data = netdev2data(net);\n+\n+\tphylink_ethtool_get_pauseparam(data-\u003ephylink, pause);\n+}\n+\n+static int ax88179a_set_pauseparam(struct net_device *net, struct ethtool_pauseparam *pause)\n+{\n+\tstruct ax88179_data *data = netdev2data(net);\n+\n+\treturn phylink_ethtool_set_pauseparam(data-\u003ephylink, pause);\n+}\n+\n+static int ax88179a_get_eeprom_len(struct net_device *net)\n+{\n+\tstruct ax88179_data *ax179_data = netdev2data(net);\n+\n+\tif (ax179_data-\u003echip_version \u003e= AX_VERSION_AX88279)\n+\t\treturn AX88279_EEPROM_LEN;\n+\telse\n+\t\treturn AX88179A_EEPROM_LEN;\n+}\n+\n+static int ax88179a_get_eee(struct net_device *net, struct ethtool_keee *edata)\n+{\n+\tstruct ax88179_data *ax179_data = netdev2data(net);\n+\n+\treturn phylink_ethtool_get_eee(ax179_data-\u003ephylink, edata);\n+}\n+\n+static int ax88179a_set_eee(struct net_device *net, struct ethtool_keee *edata)\n+{\n+\tstruct ax88179_data *ax179_data = netdev2data(net);\n+\n+\treturn phylink_ethtool_set_eee(ax179_data-\u003ephylink, edata);\n+}\n+\n+static const struct ethtool_ops ax88179a_ethtool_ops = {\n+\t.get_drvinfo            = ax88179a_get_drvinfo,\n+\t.get_link\t\t= ethtool_op_get_link,\n+\t.get_msglevel\t\t= usbnet_get_msglevel,\n+\t.set_msglevel\t\t= usbnet_set_msglevel,\n+\t.get_wol\t\t= ax88179_get_wol,\n+\t.set_wol\t\t= ax88179_set_wol,\n+\t.get_eeprom_len\t\t= ax88179a_get_eeprom_len,\n+\t.get_eeprom\t\t= ax88179_get_eeprom,\n+\t.set_eeprom\t\t= ax88179_set_eeprom,\n+\t.get_eee\t\t= ax88179a_get_eee,\n+\t.set_eee\t\t= ax88179a_set_eee,\n+\t.nway_reset\t\t= usbnet_nway_reset,\n+\t.get_link_ksettings\t= phy_ethtool_get_link_ksettings,\n+\t.set_link_ksettings\t= phy_ethtool_set_link_ksettings,\n+\t.get_pauseparam\t\t= ax88179a_get_pauseparam,\n+\t.set_pauseparam\t\t= ax88179a_set_pauseparam,\n+\t.get_ts_info\t\t= ethtool_op_get_ts_info,\n+};\n+\n+static int ax88179a_vlan_rx_kill_vid(struct net_device *net, __be16 proto, u16 vid)\n+{\n+\tstruct usbnet *dev = netdev_priv(net);\n+\tu8 vlan_ctrl;\n+\tu16 reg16;\n+\tu8 reg8;\n+\n+\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, \u0026reg8);\n+\tvlan_ctrl = reg8;\n+\n+\t/* Address */\n+\treg8 = (vid / 16);\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_ADDRESS, 1, 1, \u0026reg8);\n+\n+\t/* Data */\n+\treg8 = vlan_ctrl | AX_VLAN_CONTROL_RD;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, \u0026reg8);\n+\n+\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, \u0026reg16);\n+\treg16 \u0026= ~(1 \u003c\u003c (vid % 16));\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, \u0026reg16);\n+\n+\treg8 = vlan_ctrl | AX_VLAN_CONTROL_WE;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, \u0026reg8);\n+\n+\treturn 0;\n+}\n+\n+static int ax88179a_vlan_rx_add_vid(struct net_device *net, __be16 proto, u16 vid)\n+{\n+\tstruct usbnet *dev = netdev_priv(net);\n+\tu8 vlan_ctrl;\n+\tu16 reg16;\n+\tu8 reg8;\n+\n+\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, \u0026reg8);\n+\tvlan_ctrl = reg8;\n+\n+\t/* Address */\n+\treg8 = (vid / 16);\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_ADDRESS, 1, 1, \u0026reg8);\n+\n+\t/* Data */\n+\treg8 = vlan_ctrl | AX_VLAN_CONTROL_RD;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, \u0026reg8);\n+\n+\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, \u0026reg16);\n+\treg16 |= (1 \u003c\u003c (vid % 16));\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, \u0026reg16);\n+\n+\treg8 = vlan_ctrl | AX_VLAN_CONTROL_WE;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, \u0026reg8);\n+\n+\treturn 0;\n+}\n+\n+static void ax88179a_mdio_unregister(struct ax88179_data *data)\n+{\n+\tmdiobus_unregister(data-\u003emdio);\n+\tmdiobus_free(data-\u003emdio);\n+}\n+\n+static int ax88179a_init_phy(struct usbnet *dev)\n+{\n+\tstruct ax88179_data *data = dev-\u003edriver_priv;\n+\tint ret;\n+\n+\tdata-\u003ephydev = mdiobus_get_phy(data-\u003emdio, AX88179_PHY_ID);\n+\tif (!data-\u003ephydev) {\n+\t\tnetdev_err(dev-\u003enet, \"Could not find PHY\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tdata-\u003ephydev-\u003eirq = PHY_MAC_INTERRUPT;\n+\tret = phylink_connect_phy(data-\u003ephylink, data-\u003ephydev);\n+\tif (ret) {\n+\t\tnetdev_err(dev-\u003enet, \"Could not connect PHY\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tphy_suspend(data-\u003ephydev);\n+\tdata-\u003ephydev-\u003emac_managed_pm = true;\n+\n+\tphy_attached_info(data-\u003ephydev);\n+\n+\treturn 0;\n+}\n+\n+static void ax88179a_mac_config(struct phylink_config *config, unsigned int mode,\n+\t\t\t\tconst struct phylink_link_state *state)\n+{\n+\t/* Nothing to do */\n+}\n+\n+static void ax88179a_mac_link_down(struct phylink_config *config,\n+\t\t\t\t   unsigned int mode, phy_interface_t interface)\n+{\n+\t/* Nothing to do */\n+}\n+\n+static void ax88179a_mac_link_up(struct phylink_config *config,\n+\t\t\t\t struct phy_device *phy,\n+\t\t\t\t unsigned int phy_mode, phy_interface_t interface,\n+\t\t\t\t int speed, int duplex,\n+\t\t\t\t bool tx_pause, bool rx_pause)\n+{\n+\tstruct usbnet *dev = netdev_priv(to_net_dev(config-\u003edev));\n+\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n+\tu8 tmp8, link_sts, reg8[3];\n+\tu8 bulk_config_speed = 0;\n+\tu16 tmp16, mode;\n+\n+\t/* Stop RX/TX for link configuration */\n+\ttmp16 = AX_RX_CTL_STOP;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, \u0026tmp16);\n+\ttmp8 = 0;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_PATH, 1, 1, \u0026tmp8);\n+\n+\ttmp8 = 0xa5;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_CDC_DELAY_TX, 1, 1, \u0026tmp8);\n+\n+\ttmp16 = 0x0410;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 2, 2, \u0026tmp16);\n+\n+\ttmp8 = 0;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_ETH_TX_GAP, 1, 1, \u0026tmp8);\n+\n+\ttmp8 = 0x07;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_EP5_EHR, 1, 1, \u0026tmp8);\n+\n+\ttmp8 = 0x28 | AX_NEW_PAUSE_EN;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_NEW_PAUSE_CTRL, 1, 1, \u0026tmp8);\n+\n+\tmode = AX_MEDIUM_RECEIVE_EN;\n+\tif (tx_pause)\n+\t\tmode |= AX_MEDIUM_TXFLOW_CTRLEN;\n+\tif (rx_pause)\n+\t\tmode |= AX_MEDIUM_RXFLOW_CTRLEN;\n+\n+\tswitch (speed) {\n+\tcase SPEED_2500:\n+\t\treg8[0] = 0x00;\n+\t\treg8[1] = 0xF8;\n+\t\treg8[2] = 0x07;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_TX_PAUSE, 3, 3, reg8);\n+\n+\t\treg8[0] = 0x78;\n+\t\treg8[1] = (AX_LSOFC_WCNT_7_ACCESS \u003c\u003c 5);\n+\t\treg8[2] = 0;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_STATUS_CDC, 3, 3, reg8);\n+\n+\t\treg8[0] = 0x40;\n+\t\treg8[1] = AX_MAC_MIQFFCTRL_FORMAT | AX_MAC_MIQFFCTRL_DROP_CRC | AX_MAC_LSO_ERR_EN;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_DATA_CDC_CNT, 2, 2, reg8);\n+\n+\t\ttmp8 = AX_XGMII_EN;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_BFM_DATA, 1, 1, \u0026tmp8);\n+\n+\t\ttmp8 = 0x1C | AX_LSO_ENHANCE_EN;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_LSO_ENHANCE_CTRL, 1, 1, \u0026tmp8);\n+\n+\t\tmode |= AX_MEDIUM_GIGAMODE | AX_MEDIUM_FULL_DUPLEX;\n+\t\tbulk_config_speed = ETHER_LINK_2500;\n+\n+\t\tbreak;\n+\n+\tcase SPEED_1000:\n+\t\tmode |= AX_MEDIUM_GIGAMODE;\n+\t\tbulk_config_speed = ETHER_LINK_1000;\n+\t\tfallthrough;\n+\n+\tcase SPEED_100:\n+\t\treg8[0] = 0x78;\n+\t\treg8[1] = (AX_LSOFC_WCNT_7_ACCESS \u003c\u003c 5) | AX_GMII_CRC_APPEND;\n+\t\treg8[2] = 0;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_STATUS_CDC, 3, 3, reg8);\n+\n+\t\ttmp8 = 0x40;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_DATA_CDC_CNT, 1, 1, \u0026tmp8);\n+\t\tif (!bulk_config_speed)\n+\t\t\tbulk_config_speed = ETHER_LINK_100;\n+\t\tbreak;\n+\n+\tcase SPEED_10:\n+\t\treg8[0] = 0xFA;\n+\t\treg8[1] = (AX_LSOFC_WCNT_7_ACCESS \u003c\u003c 5) | AX_GMII_CRC_APPEND;\n+\t\treg8[2] = 0xFF;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_STATUS_CDC, 3, 3, reg8);\n+\n+\t\ttmp8 = 0xFA;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_RX_DATA_CDC_CNT, 1, 1, \u0026tmp8);\n+\n+\t\tbulk_config_speed = ETHER_LINK_10;\n+\t\tbreak;\n+\t}\n+\n+\tax88179_read_cmd(dev, AX_ACCESS_MAC, PHYSICAL_LINK_STATUS, 1, 1, \u0026link_sts);\n+\tax88179a_bulkin_config(dev, link_sts, bulk_config_speed, !!duplex);\n+\n+\tif (ax179_data-\u003echip_version \u003c AX_VERSION_AX88279) {\n+\t\ttmp8 = 0;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_BFM_DATA, 1, 1, \u0026tmp8);\n+\t}\n+\n+\tif (duplex)\n+\t\tmode |= AX_MEDIUM_FULL_DUPLEX;\n+\n+\tif (dev-\u003enet-\u003emtu \u003e 1500)\n+\t\tmode |= AX_MEDIUM_JUMBO_EN;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, \u0026mode);\n+\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, \u0026ax179_data-\u003erxctl);\n+\n+\ttmp8 = AX_MAC_RX_PATH_READY | AX_MAC_TX_PATH_READY;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_PATH, 1, 1, \u0026tmp8);\n+}\n+\n+static void ax88179a_mac_disable_tx_lpi(struct phylink_config *config)\n+{\n+\tstruct usbnet *dev = netdev_priv(to_net_dev(config-\u003edev));\n+\n+\tax88179_write_cmd(dev, AX_GPHY_CTL, AX_GPHY_EEE_CTRL, false, 0, NULL);\n+}\n+\n+static int ax88179a_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, bool tx_clk_stop)\n+{\n+\tstruct usbnet *dev = netdev_priv(to_net_dev(config-\u003edev));\n+\n+\t/* AX88179A does not provide LPI timer registers */\n+\treturn ax88179_write_cmd(dev, AX_GPHY_CTL, AX_GPHY_EEE_CTRL, true, 0, NULL);\n+}\n+\n+static const struct phylink_mac_ops ax88179a_phylink_mac_ops = {\n+\t.mac_config = ax88179a_mac_config,\n+\t.mac_link_down = ax88179a_mac_link_down,\n+\t.mac_link_up = ax88179a_mac_link_up,\n+\t.mac_disable_tx_lpi = ax88179a_mac_disable_tx_lpi,\n+\t.mac_enable_tx_lpi = ax88179a_mac_enable_tx_lpi,\n+};\n+\n+static int ax88179a_phylink_setup(struct usbnet *dev)\n+{\n+\tstruct ax88179_data *data = dev-\u003edriver_priv;\n+\tphy_interface_t phy_if_mode;\n+\tstruct phylink *phylink;\n+\n+\tdata-\u003ephylink_config.dev = \u0026dev-\u003enet-\u003edev;\n+\tdata-\u003ephylink_config.type = PHYLINK_NETDEV;\n+\tdata-\u003ephylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | MAC_100;\n+\tif (data-\u003eis_ax88772d)\n+\t\tdata-\u003ephylink_config.mac_capabilities |= MAC_10;\n+\telse if (data-\u003echip_version \u003c AX_VERSION_AX88279)\n+\t\tdata-\u003ephylink_config.mac_capabilities |= MAC_10 | MAC_1000;\n+\telse\n+\t\tdata-\u003ephylink_config.mac_capabilities |= MAC_1000 | MAC_2500FD;\n+\n+\tif (!data-\u003eis_ax88772d) {\n+\t\tdata-\u003ephylink_config.lpi_capabilities = MAC_100FD | MAC_1000FD;\n+\t\tdata-\u003ephylink_config.eee_enabled_default = false;\n+\t}\n+\n+\tif (data-\u003echip_version == AX_VERSION_AX88279) {\n+\t\t__set_bit(PHY_INTERFACE_MODE_2500BASEX,\n+\t\t\t  data-\u003ephylink_config.supported_interfaces);\n+\t\t__set_bit(PHY_INTERFACE_MODE_SGMII,\n+\t\t\t  data-\u003ephylink_config.supported_interfaces);\n+\t\tphy_if_mode = PHY_INTERFACE_MODE_2500BASEX;\n+\t} else {\n+\t\t__set_bit(PHY_INTERFACE_MODE_SGMII,\n+\t\t\t  data-\u003ephylink_config.supported_interfaces);\n+\t\tphy_if_mode = PHY_INTERFACE_MODE_SGMII;\n+\t}\n+\n+\tmemcpy(data-\u003ephylink_config.lpi_interfaces,\n+\t       data-\u003ephylink_config.supported_interfaces,\n+\t       sizeof(data-\u003ephylink_config.lpi_interfaces));\n+\n+\tphylink = phylink_create(\u0026data-\u003ephylink_config, dev-\u003enet-\u003edev.fwnode,\n+\t\t\t\t phy_if_mode, \u0026ax88179a_phylink_mac_ops);\n+\tif (IS_ERR(phylink))\n+\t\treturn PTR_ERR(phylink);\n+\n+\tdata-\u003ephylink = phylink;\n+\treturn 0;\n+}\n+\n+static int ax88179a_init_mdio(struct usbnet *dev)\n+{\n+\tstruct ax88179_data *data = dev-\u003edriver_priv;\n+\tint ret;\n+\n+\tdata-\u003emdio = mdiobus_alloc();\n+\tif (!data-\u003emdio)\n+\t\treturn -ENOMEM;\n+\n+\tdata-\u003emdio-\u003epriv = dev;\n+\tdata-\u003emdio-\u003eread = ax88179_mdiobus_read;\n+\tdata-\u003emdio-\u003ewrite = ax88179_mdiobus_write;\n+\tdata-\u003emdio-\u003eread_c45 = ax88179_mdiobus_read_c45;\n+\tdata-\u003emdio-\u003ewrite_c45 = ax88179_mdiobus_write_c45;\n+\tdata-\u003emdio-\u003ename = \"AX88179A MDIO Bus\";\n+\tdata-\u003emdio-\u003ephy_mask = ~(1 \u003c\u003c AX88179_PHY_ID);\n+\t/* mii bus name is usb-\u003cusb bus number\u003e-\u003cusb device number\u003e */\n+\tsnprintf(data-\u003emdio-\u003eid, MII_BUS_ID_SIZE, \"usb-%03d:%03d\",\n+\t\t dev-\u003eudev-\u003ebus-\u003ebusnum, dev-\u003eudev-\u003edevnum);\n+\n+\tret = mdiobus_register(data-\u003emdio);\n+\tif (ret) {\n+\t\tnetdev_err(dev-\u003enet, \"Could not register MDIO bus (err %d)\\n\", ret);\n+\t\tmdiobus_free(data-\u003emdio);\n+\t\tdata-\u003emdio = NULL;\n+\t}\n+\n+\treturn ret;\n+}\n+\n+static int ax88179a_set_features(struct net_device *net, netdev_features_t features)\n+{\n+\tstruct usbnet *dev = netdev_priv(net);\n+\tnetdev_features_t changed;\n+\tint ret;\n+\tu8 tmp;\n+\n+\tchanged = net-\u003efeatures ^ features;\n+\n+\tret = ax88179_set_features(net, features);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (changed \u0026 NETIF_F_HW_VLAN_CTAG_FILTER) {\n+\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, \u0026tmp);\n+\t\ttmp ^= AX_VLAN_CONTROL_VFE;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, \u0026tmp);\n+\t\tif (features \u0026 NETIF_F_HW_VLAN_CTAG_FILTER) {\n+\t\t\tfor (int i = 0; i \u003c 256; i++) {\n+\t\t\t\tu16 tmp16 = 0;\n+\t\t\t\t/* Address */\n+\t\t\t\ttmp = i;\n+\t\t\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_ADDRESS,\n+\t\t\t\t\t\t  1, 1, \u0026tmp);\n+\t\t\t\t/* Data */\n+\t\t\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0,\n+\t\t\t\t\t\t  2, 2, \u0026tmp16);\n+\t\t\t\ttmp = AX_VLAN_CONTROL_WE;\n+\t\t\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL,\n+\t\t\t\t\t\t  1, 1, \u0026tmp);\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\tif (changed \u0026 NETIF_F_HW_VLAN_CTAG_RX) {\n+\t\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, \u0026tmp);\n+\t\ttmp ^= AX_VLAN_CONTROL_VSO;\n+\t\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, \u0026tmp);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static const struct net_device_ops ax88179a_netdev_ops = {\n+\t.ndo_open\t\t= usbnet_open,\n+\t.ndo_stop\t\t= usbnet_stop,\n+\t.ndo_start_xmit\t\t= usbnet_start_xmit,\n+\t.ndo_tx_timeout\t\t= usbnet_tx_timeout,\n+\t.ndo_get_stats64\t= dev_get_tstats64,\n+\t.ndo_change_mtu\t\t= ax88179_change_mtu,\n+\t.ndo_set_mac_address\t= ax88179_set_mac_addr,\n+\t.ndo_validate_addr\t= eth_validate_addr,\n+\t.ndo_eth_ioctl\t\t= usbnet_mii_ioctl,\n+\t.ndo_set_rx_mode\t= ax88179_set_multicast,\n+\t.ndo_set_features\t= ax88179a_set_features,\n+\t.ndo_vlan_rx_add_vid\t= ax88179a_vlan_rx_add_vid,\n+\t.ndo_vlan_rx_kill_vid\t= ax88179a_vlan_rx_kill_vid,\n+};\n+\n+static int ax88179a_bind(struct usbnet *dev, struct usb_interface *intf)\n+{\n+\tstruct usb_device *udev = interface_to_usbdev(intf);\n+\tstruct ax88179_data *ax179_data;\n+\tint ret;\n+\tu8 reg8;\n+\n+\t/* Check if vendor configuration */\n+\tif (udev-\u003eactconfig-\u003edesc.bConfigurationValue != 1) {\n+\t\tnetdev_info(dev-\u003enet, \"Switching to vendor mode\\n\");\n+\t\tusb_driver_set_configuration(udev, 1);\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tret = usbnet_get_endpoints(dev, intf);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tax179_data = kzalloc_obj(*ax179_data);\n+\tif (!ax179_data)\n+\t\treturn -ENOMEM;\n+\n+\tdev-\u003edriver_priv = ax179_data;\n+\n+\tret = ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_CHIP_STATUS,\n+\t\t\t       1, 1, \u0026ax179_data-\u003echip_version);\n+\tif (ret \u003c 0)\n+\t\tgoto err_nodev;\n+\n+\tax179_data-\u003echip_version = (ax179_data-\u003echip_version \u0026 0xf0) \u003e\u003e 4;\n+\tax179_data-\u003eis_ax88772d = 0;\n+\tif (ax179_data-\u003echip_version == AX_VERSION_AX88179A) {\n+\t\tif (udev-\u003edescriptor.bcdDevice == 0x300)\n+\t\t\tax179_data-\u003eis_ax88772d = 1;\n+\t}\n+\n+\tfor (int i = 0; i \u003c 3; i++) {\n+\t\tret = ax88179_read_cmd(dev, AX88179A_ACCESS_BL, (0xFD + i),\n+\t\t\t\t       1, 1, \u0026ax179_data-\u003efw_version[i]);\n+\t\tif (ret \u003c 0)\n+\t\t\tax179_data-\u003efw_version[i] = 0xff;\n+\t}\n+\tnetdev_info(dev-\u003enet, \"AX88179A/279/772D Chip Version: %x, FW: %d.%d.%d.%d\\n\",\n+\t\t    ax179_data-\u003echip_version,\n+\t\t    ax179_data-\u003efw_version[0], ax179_data-\u003efw_version[1],\n+\t\t    ax179_data-\u003efw_version[2], ax179_data-\u003efw_version[3]);\n+\n+\t/* The AX88279 requires both the AX_RX_CTL_IPE and AX_RX_CTL_DROPCRCERR\n+\t * bits set in AX_RX_CTL for creating correct RX-URBs. AX_RX_CTL_DROPCRCERR\n+\t * is anyway set for all chips, make sure AX_RX_CTL_IPE is set via ip_align.\n+\t * Also configure eeprom access parameters.\n+\t */\n+\tif (ax179_data-\u003echip_version == AX_VERSION_AX88279) {\n+\t\tax179_data-\u003eip_align = 1;\n+\t\tax179_data-\u003eeeprom_read_cmd = AX88179A_FLASH_READ;\n+\t\tax179_data-\u003eeeprom_write_cmd = AX88179A_FLASH_WRITE;\n+\t\tax179_data-\u003eeeprom_block = 256;\n+\t\tax179_data-\u003eeeprom_wen = 1;\n+\t} else {\n+\t\tax179_data-\u003eip_align = 0;\n+\t\tax179_data-\u003eeeprom_read_cmd = AX_ACCESS_EFUS;\n+\t\tax179_data-\u003eeeprom_write_cmd = AX_ACCESS_EFUS;\n+\t\tax179_data-\u003eeeprom_block = 20;\n+\t\tax179_data-\u003eeeprom_wen = 0;\n+\t}\n+\n+\tax179_data-\u003eresume = ax88179a_resume;\n+\tax179_data-\u003esuspend = ax88179a_suspend;\n+\n+\tdev-\u003enet-\u003enetdev_ops = \u0026ax88179a_netdev_ops;\n+\tdev-\u003enet-\u003eethtool_ops = \u0026ax88179a_ethtool_ops;\n+\tdev-\u003enet-\u003eneeded_headroom = 8;\n+\tdev-\u003enet-\u003eneeded_tailroom = 8;\n+\tdev-\u003enet-\u003emin_mtu = ETH_MIN_MTU;\n+\tdev-\u003ehard_mtu = 9 * 1024;\n+\tdev-\u003enet-\u003emax_mtu = dev-\u003ehard_mtu - dev-\u003enet-\u003ehard_header_len;\n+\n+\tif (!ax179_data-\u003eis_ax88772d)\n+\t\tdev-\u003emii.supports_gmii = 1;\n+\n+\tdev-\u003enet-\u003efeatures |= NETIF_F_SG | NETIF_F_IP_CSUM |\n+\t\t\t      NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | NETIF_F_TSO |\n+\t\t\t      NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |\n+\t\t\t      NETIF_F_HW_VLAN_CTAG_FILTER;\n+\n+\tdev-\u003enet-\u003ehw_features |= dev-\u003enet-\u003efeatures;\n+\n+\tdev-\u003enet-\u003evlan_features = NETIF_F_SG | NETIF_F_IP_CSUM |\n+\t\t\t\t  NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | NETIF_F_TSO;\n+\n+\tnetif_set_tso_max_size(dev-\u003enet, 16384);\n+\n+\t/* Enable Transmission of Link Speed byte in interrupt URB */\n+\tax88179_write_cmd(dev, AX_FW_MODE, AX_FW_MODE_179A, 0, 0, NULL);\n+\tax88179_write_cmd(dev, AX_RELOAD_EEPROM_EFUSE, 0, 0, 0, NULL);\n+\n+\t/* Read MAC address from DTB or ASIX chip */\n+\tax88179_get_mac_addr(dev);\n+\tmemcpy(dev-\u003enet-\u003eperm_addr, dev-\u003enet-\u003edev_addr, ETH_ALEN);\n+\n+\t/* Power PHY for probing */\n+\treg8 = AX_PHY_POWER;\n+\tax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, \u0026reg8);\n+\tmsleep(250);\n+\n+\tret = ax88179a_init_mdio(dev);\n+\tif (ret)\n+\t\tgoto err_nodev;\n+\n+\tret = ax88179a_phylink_setup(dev);\n+\tif (ret)\n+\t\tgoto phylink_err;\n+\n+\tret = ax88179a_init_phy(dev);\n+\tif (ret)\n+\t\tgoto initphy_err;\n+\n+\treturn 0;\n+\n+initphy_err:\n+\tphylink_destroy(ax179_data-\u003ephylink);\n+phylink_err:\n+\tax88179a_mdio_unregister(ax179_data);\n+err_nodev:\n+\tkfree(ax179_data);\n+\tax179_data = NULL;\n+\n+\treturn ret;\n+}\n+\n+static void ax88179a_unbind(struct usbnet *dev, struct usb_interface *intf)\n+{\n+\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n+\tu16 tmp16;\n+\tu8 tmp8;\n+\n+\t/* Configure RX control register =\u003e stop operation */\n+\ttmp16 = AX_RX_CTL_STOP;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, \u0026tmp16);\n+\n+\trtnl_lock();\n+\tphylink_disconnect_phy(ax179_data-\u003ephylink);\n+\trtnl_unlock();\n+\tphylink_destroy(ax179_data-\u003ephylink);\n+\tax88179a_mdio_unregister(ax179_data);\n+\n+\ttmp8 = 0;\n+\tax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, \u0026tmp8);\n+\n+\tkfree(ax179_data);\n+}\n+\n+static void ax88179a_rx_checksum(struct sk_buff *skb, u64 pkt_desc)\n+{\n+\tu32 pkt_type;\n+\n+\tskb-\u003eip_summed = CHECKSUM_NONE;\n+\t/* checksum error bit is set */\n+\tif (pkt_desc \u0026 AX179A_RX_PD_L4_ERR || pkt_desc \u0026 AX179A_RX_PD_L3_ERR)\n+\t\treturn;\n+\n+\tpkt_type = pkt_desc \u0026 AX179A_RX_PD_L4_TYPE_MASK;\n+\t/* It must be a TCP or UDP packet with a valid checksum */\n+\tif (pkt_type == AX179A_RX_PD_L4_TCP || pkt_type == AX179A_RX_PD_L4_UDP)\n+\t\tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n+}\n+\n+static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)\n+{\n+\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n+\tstruct sk_buff *ax_skb;\n+\tu32 hdr_off, pkt_end;\n+\tu64 *pkt_desc_ptr;\n+\tu16 vlan_tag;\n+\tu16 pkt_cnt;\n+\tu64 rx_hdr;\n+\n+\t/* SKB contents for AX179A-based chips:\n+\t *   \u003cpacket 1\u003e\n+\t *   ...\n+\t *   \u003cpacket N\u003e\n+\t *   \u003cper-packet metadata entry 1\u003e\n+\t *   ...\n+\t *   \u003cper-packet metadata entry N\u003e\n+\t *   \u003crx_hdr\u003e\n+\t *\n+\t * where:\n+\t *   \u003cpacket N\u003e contains pkt_len data bytes and padding:\n+\t *\t\t2 bytes of IP alignment (optional, depends on AX_RX_CTL_IPE flag)\n+\t *\t\tpacket data received\n+\t *\t\toptional padding to 8-bytes boundary\n+\t *   \u003cper-packet metadata entry N\u003e contains 8 bytes:\n+\t *\t\tpkt_len and fields AX_RXHDR_*\n+\t *   \u003crx-hdr\u003e\tcontains 8 bytes:\n+\t *\t\tpkt_cnt and hdr_off (offset of \u003cper-packet metadata entry 1\u003e)\n+\t *\n+\t * pkt_cnt is number of entries in the per-packet metadata array.\n+\t */\n+\n+\tif (!skb || skb-\u003elen \u003c sizeof(rx_hdr))\n+\t\tgoto err;\n+\n+\t/* RX Descriptor Header */\n+\tskb_trim(skb, skb-\u003elen - sizeof(rx_hdr));\n+\trx_hdr = le64_to_cpup((u64 *)skb_tail_pointer(skb));\n+\n+\t/* Check these packets */\n+\thdr_off = (rx_hdr \u0026 AX179A_RX_DH_DESC_OFFSET_MASK) \u003e\u003e AX179A_RX_DH_DESC_OFFSET_SHIFT;\n+\tpkt_cnt = rx_hdr \u0026 AX179A_RX_DH_PKT_CNT_MASK;\n+\n+\t/* Consistency check header position */\n+\tif (hdr_off != skb-\u003elen - (pkt_cnt * sizeof(rx_hdr)))\n+\t\tgoto err;\n+\n+\t/* Make sure that the bounds of the metadata array are inside the SKB\n+\t * (and in front of the counter at the end).\n+\t */\n+\tif (pkt_cnt * 8 + hdr_off \u003e skb-\u003elen)\n+\t\tgoto err;\n+\n+\t/* Packets must not overlap the metadata array */\n+\tskb_trim(skb, hdr_off);\n+\n+\tif (!pkt_cnt)\n+\t\tgoto err;\n+\n+\t/* Get the first RX packet descriptor */\n+\tpkt_desc_ptr = (u64 *)(skb-\u003edata + hdr_off);\n+\n+\tpkt_end = 0;\n+\twhile (pkt_cnt--) {\n+\t\tu64 pkt_desc = le64_to_cpup(pkt_desc_ptr);\n+\t\tu32 pkt_len_plus_padd;\n+\t\tu32 pkt_len;\n+\n+\t\tpkt_len = (u32)((pkt_desc \u0026 AX179A_RX_PD_LEN_MASK) \u003e\u003e AX179A_RX_PD_LEN_SHIFT)\n+\t\t\t  - (ax179_data-\u003eip_align ? 2 : 0);\n+\t\tpkt_len_plus_padd = ((pkt_len + 7 + (ax179_data-\u003eip_align ? 2 : 0)) \u0026 0x7FFF8);\n+\n+\t\tpkt_end += pkt_len_plus_padd;\n+\t\tif (pkt_end \u003e hdr_off || (pkt_cnt == 0 \u0026\u0026 pkt_end != hdr_off))\n+\t\t\tgoto err;\n+\n+\t\tif (pkt_desc \u0026 AX179A_RX_PD_DROP || !(pkt_desc \u0026 AX179A_RX_PD_RX_OK) ||\n+\t\t    pkt_len \u003e (dev-\u003ehard_mtu + AX179A_RX_HW_PAD)) {\n+\t\t\tskb_pull(skb, pkt_len_plus_padd);\n+\n+\t\t\t/* Next RX Packet Descriptor */\n+\t\t\tpkt_desc_ptr++;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tax_skb = netdev_alloc_skb_ip_align(dev-\u003enet, pkt_len);\n+\t\tif (!ax_skb)\n+\t\t\tgoto err;\n+\n+\t\tskb_put(ax_skb, pkt_len);\n+\t\tmemcpy(ax_skb-\u003edata, skb-\u003edata + (ax179_data-\u003eip_align ? AX179A_RX_HW_PAD : 0),\n+\t\t       pkt_len);\n+\n+\t\tif (ax179_data-\u003erx_checksum)\n+\t\t\tax88179a_rx_checksum(ax_skb, pkt_desc);\n+\n+\t\tif (pkt_desc \u0026 AX179A_RX_PD_VLAN) {\n+\t\t\tvlan_tag = pkt_desc \u003e\u003e AX179A_RX_PD_VLAN_SHIFT;\n+\t\t\t__vlan_hwaccel_put_tag(ax_skb, htons(ETH_P_8021Q),\n+\t\t\t\t\t       vlan_tag \u0026 VLAN_VID_MASK);\n+\t\t}\n+\n+\t\tusbnet_skb_return(dev, ax_skb);\n+\t\tskb_pull(skb, pkt_len_plus_padd);\n+\n+\t\t/* Next RX Packet Header */\n+\t\tpkt_desc_ptr++;\n+\t}\n+\n+\treturn 1;\n+\n+err:\n+\treturn 0;\n+}\n+\n+static struct sk_buff *ax88179a_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)\n+{\n+\tu64 tx_desc = skb-\u003elen \u0026 AX179A_TX_DESC_LEN_MASK;\n+\tint frame_size = dev-\u003emaxpacket;\n+\tstruct sk_buff *ax_skb;\n+\tu64 *tx_desc_ptr;\n+\tint padding_size;\n+\tint headroom;\n+\tint tailroom;\n+\tu16 tci = 0;\n+\n+\t/* TSO MSS */\n+\ttx_desc |= ((u64)(skb_shinfo(skb)-\u003egso_size \u0026 AX179A_TX_DESC_MSS_MASK)) \u003c\u003c\n+\t\t   AX179A_TX_DESC_MSS_SHIFT;\n+\n+\theadroom = (skb-\u003elen + sizeof(tx_desc)) % 8;\n+\tpadding_size = headroom ? 8 - headroom : 0;\n+\n+\tif (((skb-\u003elen + sizeof(tx_desc) + padding_size) % frame_size) == 0) {\n+\t\tpadding_size += 8;\n+\t\ttx_desc |= AX179A_TX_DESC_DROP_PADD;\n+\t}\n+\n+\tif ((dev-\u003enet-\u003efeatures \u0026 NETIF_F_HW_VLAN_CTAG_TX) \u0026\u0026 (vlan_get_tag(skb, \u0026tci) \u003e= 0)) {\n+\t\ttx_desc |= AX179A_TX_DESC_VLAN;\n+\t\ttx_desc |= ((u64)tci \u0026 AX179A_TX_DESC_VLAN_MASK) \u003c\u003c AX179A_TX_DESC_VLAN_SHIFT;\n+\t}\n+\n+\tif (!dev-\u003ecan_dma_sg \u0026\u0026 (dev-\u003enet-\u003efeatures \u0026 NETIF_F_SG) \u0026\u0026 skb_linearize(skb))\n+\t\treturn NULL;\n+\n+\theadroom = skb_headroom(skb);\n+\ttailroom = skb_tailroom(skb);\n+\n+\tif (!(headroom \u003e= sizeof(tx_desc) \u0026\u0026 tailroom \u003e= padding_size)) {\n+\t\tax_skb = skb_copy_expand(skb, sizeof(tx_desc), padding_size, flags);\n+\t\tdev_kfree_skb_any(skb);\n+\t\tskb = ax_skb;\n+\t\tif (!skb)\n+\t\t\treturn NULL;\n+\t}\n+\tif (padding_size != 0)\n+\t\tskb_put_zero(skb, padding_size);\n+\t/* Copy TX header */\n+\ttx_desc_ptr = skb_push(skb, sizeof(tx_desc));\n+\t*tx_desc_ptr = cpu_to_le64(tx_desc);\n+\n+\tusbnet_set_skb_tx_stats(skb, 1, 0);\n+\n+\treturn skb;\n+}\n+\n+static int ax88179a_reset(struct usbnet *dev)\n+{\n+\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n+\tu16 *tmp16;\n+\tu8 buf[5];\n+\tu8 *tmp;\n+\n+\ttmp16 = (u16 *)buf;\n+\ttmp = (u8 *)buf;\n+\n+\t/* Power up ethernet PHY */\n+\t*tmp = AX_PHY_POWER;\n+\tax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, tmp);\n+\tmsleep(250);\n+\n+\t/* Ethernet PHY Auto Detach*/\n+\tax88179a_auto_detach(dev);\n+\n+\t*tmp = AX_MAC_EFF_EN;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_BULK_OUT_CTRL, 1, 1, tmp);\n+\n+\t*tmp16 = 0;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16);\n+\n+\t*tmp = 0x04;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp);\n+\t*tmp = 0x10;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, 1, 1, tmp);\n+\n+\t*tmp = 0;\n+\tif (dev-\u003enet-\u003efeatures \u0026 NETIF_F_HW_VLAN_CTAG_FILTER)\n+\t\t*tmp |= AX_VLAN_CONTROL_VFE;\n+\tif (dev-\u003enet-\u003efeatures \u0026 NETIF_F_HW_VLAN_CTAG_RX)\n+\t\t*tmp |= AX_VLAN_CONTROL_VSO;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, tmp);\n+\n+\t*tmp = 0xff;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_BM_INT_MASK, 1, 1, tmp);\n+\n+\t*tmp = 0;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_BM_RX_DMA_CTL, 1, 1, tmp);\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_BM_TX_DMA_CTL, 1, 1, tmp);\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_ARC_CTRL, 1, 1, tmp);\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_SWP_CTRL, 1, 1, tmp);\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_MAC_TX_HDR_CKSUM, 1, 1, tmp);\n+\n+\t/* Read MAC address from DTB or asix chip */\n+\tax88179_get_mac_addr(dev);\n+\tmemcpy(dev-\u003enet-\u003eperm_addr, dev-\u003enet-\u003edev_addr, ETH_ALEN);\n+\n+\t/* The Bulk-Register configuration for the AX88179A is done in\n+\t * ax88179a_mac_link_up(), once the link is up for a given link and USB-speed.\n+\t */\n+\tif (ax179_data-\u003eis_ax88772d)\n+\t\tdev-\u003erx_urb_size = 1024 * 24;\n+\telse\n+\t\tdev-\u003erx_urb_size = 1024 * 48;\n+\n+\t/* Enable checksum offload */\n+\t*tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |\n+\t       AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, tmp);\n+\tax179_data-\u003erx_checksum = 1;\n+\n+\t*tmp = AX_TXCOE_IP | AX_TXCOE_TCP | AX_TXCOE_UDP |\n+\t       AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp);\n+\n+\t/* Configure RX control register =\u003e start operation */\n+\tax179_data-\u003erxctl = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START |\n+\t\t\t    AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB;\n+\tif (ax179_data-\u003eip_align)\n+\t\tax179_data-\u003erxctl |= AX_RX_CTL_IPE;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, \u0026ax179_data-\u003erxctl);\n+\n+\tif (ax179_data-\u003echip_version \u003c AX_VERSION_AX88179A)\n+\t\t*tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL | AX_MONITOR_MODE_RWMP;\n+\telse\n+\t\t*tmp = AX_MONITOR_MODE_RWMP;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, tmp);\n+\n+\t/* Configure default medium type =\u003e giga */\n+\t*tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN |\n+\t\t AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX;\n+\tif (!ax179_data-\u003eis_ax88772d)\n+\t\t*tmp16 |= AX_MEDIUM_GIGAMODE;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, tmp16);\n+\n+\t/* Check if WoL is supported */\n+\tax179_data-\u003ewol_supported = 0;\n+\tif (ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD,\n+\t\t\t     1, 1, \u0026tmp) \u003e 0)\n+\t\tax179_data-\u003ewol_supported = WAKE_MAGIC | WAKE_PHY;\n+\n+\t/* ax88179a_reset() may also be called from resume context, phylink\n+\t * is already started, then.\n+\t */\n+\tif (!ax179_data-\u003ein_pm)\n+\t\tphylink_start(ax179_data-\u003ephylink);\n+\n+\tusbnet_link_change(dev, 0, 0);\n+\n+\treturn 0;\n+}\n+\n+static int ax88179a_stop(struct usbnet *dev)\n+{\n+\tstruct ax88179_data *ax179_data = dev-\u003edriver_priv;\n+\tu16 reg16;\n+\tu8 reg8;\n+\n+\tax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, \u0026reg16);\n+\treg16 \u0026= ~AX_MEDIUM_RECEIVE_EN;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, \u0026reg16);\n+\n+\treg16 = 0;\n+\tax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, \u0026reg16);\n+\n+\treg8 = 0;\n+\tax88179_read_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, \u0026reg8);\n+\n+\tphylink_stop(ax179_data-\u003ephylink);\n+\n+\treturn 0;\n+}\n+\n+const struct driver_info ax88179a_info = {\n+\t.description = \"ASIX AX88179A USB 3.2 Gigabit Ethernet\",\n+\t.bind = ax88179a_bind,\n+\t.unbind = ax88179a_unbind,\n+\t.status = ax88179a_status,\n+\t.reset = ax88179a_reset,\n+\t.stop = ax88179a_stop,\n+\t.flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_MULTI_PACKET | FLAG_AVOID_UNLINK_URBS,\n+\t.rx_fixup = ax88179a_rx_fixup,\n+\t.tx_fixup = ax88179a_tx_fixup,\n+};\n+\n+const struct driver_info ax88772d_info = {\n+\t.description = \"ASIX AX88772D/E USB 2.0 Fast Ethernet\",\n+\t.bind = ax88179a_bind,\n+\t.unbind = ax88179a_unbind,\n+\t.status = ax88179a_status,\n+\t.reset = ax88179a_reset,\n+\t.stop = ax88179a_stop,\n+\t.flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_MULTI_PACKET | FLAG_AVOID_UNLINK_URBS,\n+\t.rx_fixup = ax88179a_rx_fixup,\n+\t.tx_fixup = ax88179a_tx_fixup,\n+};\n+\n+const struct driver_info ax88279_info = {\n+\t.description = \"ASIX AX88279 USB 3.2 2.5Gigabit Ethernet\",\n+\t.bind = ax88179a_bind,\n+\t.unbind = ax88179a_unbind,\n+\t.status = ax88179a_status,\n+\t.reset = ax88179a_reset,\n+\t.stop = ax88179a_stop,\n+\t.flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_MULTI_PACKET | FLAG_AVOID_UNLINK_URBS,\n+\t.rx_fixup = ax88179a_rx_fixup,\n+\t.tx_fixup = ax88179a_tx_fixup,\n+};\ndiff --git a/include/linux/phylink.h b/include/linux/phylink.h\nindex 2bc0db3d52ac8..21f960a827b6f 100644\n--- a/include/linux/phylink.h\n+++ b/include/linux/phylink.h\n@@ -768,6 +768,7 @@ int phylink_ethtool_set_eee(struct phylink *link, struct ethtool_keee *eee);\n int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);\n int phylink_speed_down(struct phylink *pl, bool sync);\n int phylink_speed_up(struct phylink *pl);\n+void phylink_mac_interrupt(struct phylink *pl);\n \n #define phylink_zero(bm) \\\n \tbitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS)\n"
}

2/1 2026/08/10 13:58 agent patch-evaluator
0m Model:
best-expensive

Args:
null

Results:
{
  "EnableConfigs": [
    "USB_NET_AX88179",
    "AX88796B_PHY"
  ],
  "FocusSymbols": [
    "ax88179a_bind",
    "ax88179a_rx_fixup",
    "ax88179a_tx_fixup",
    "ax88179a_reset",
    "ax88179a_set_features",
    "ax88179a_vlan_rx_add_vid",
    "ax88179a_vlan_rx_kill_vid",
    "ax88179a_mac_link_up",
    "ax88179_read_cmd",
    "ax88179_write_cmd",
    "ax88179_set_eeprom",
    "ax88179_get_eeprom",
    "ax88179_set_features",
    "ax88179_change_mtu",
    "asix_ax88279_read_status",
    "asix_ax88279_config_aneg",
    "asix_ax88279_get_features",
    "asix_ax88279_config_init",
    "asix_read_mmd",
    "asix_write_mmd",
    "asix_ax88772D_get_features"
  ],
  "Reasoning": "The patch adds support for ASIX AX88179A, AX88279, and AX88772D/E USB Ethernet adapters. It splits the existing driver into a library and device-specific files, and adds new PHY drivers. USB devices can be emulated in virtualized environments using the USB gadget subsystem (dummy_hcd), making this code reachable and worth fuzzing.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer.
Your job is to review a provided patch series and determine
if it makes functional changes to the kernel that should be fuzzed.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively
use your code access tools to examine the actual source code and confirm any assumptions.

Return WorthFuzzing=false if the patch only contains:
- Modifications to Documentation/, Kconfig files, or code comments.
- Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints.
- Changes to numeric constants or macros that do not functionally alter execution flow.
- Code paths that are impossible to reach in virtualized environments like GCE or QEMU,
  even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim).
- Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed,
  ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU.
- Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove)
  that are executed only during PCI hot-unplug or sysfs driver unbind operations.

If it modifies reachable core kernel logic, drivers, or architectures, use your code search
tools to verify the code can be executed, then return WorthFuzzing=true.

When returning WorthFuzzing=true, you MUST ALSO:
1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols.
   Avoid listing generic hot-path functions to prevent skewed test distributions.
   Prefer non-static, non-inlined API entrypoint functions over internal static helper functions
   (which are inlined by the compiler and do not have distinct symbol addresses).
2. Identify any specific CONFIG_ options required to properly test this new/modified feature.
   Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions.
   Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs
   needed for Kbuild to compile the code statically into vmlinux. List them in the EnableConfigs
   output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
For your convenience, here is the diff of the changes:
commit 5440b5325da5dcdfedc4cd25fb52b0c4e64c4c81
Author: syz-cluster <triage@syzkaller.com>
Date:   Mon Aug 10 13:58:33 2026 +0000

    syz-cluster: applied patch under review

diff --git a/MAINTAINERS b/MAINTAINERS
index 15011f5752a99..d43d58b417e58 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3987,6 +3987,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/net/asix,ax88796c.yaml
 F:	drivers/net/ethernet/asix/ax88796c_*
 
+ASIX AX88179 USB ETHERNET DRIVER
+M:	Birger Koblitz <mail@birger-koblitz.de>
+L:	netdev@vger.kernel.org
+S:	Maintained
+F:	drivers/net/usb/ax88179*
+
 ASIX PHY DRIVER [RUST]
 M:	FUJITA Tomonori <fujita.tomonori@gmail.com>
 R:	Trevor Gross <tmgross@umich.edu>
diff --git a/drivers/net/phy/ax88796b.c b/drivers/net/phy/ax88796b.c
index f20ddf6491499..1298e46ad9e16 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,122 @@ 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_read_status(phydev);
+	if (ret)
+		return ret;
+
+	/* 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;
+
+	/* PHY switches interface between 2.5GBit and slower modes */
+	if (phydev->speed == SPEED_2500)
+		phydev->interface = PHY_INTERFACE_MODE_2500BASEX;
+	else
+		phydev->interface = PHY_INTERFACE_MODE_SGMII;
+
+	return 0;
+}
+
+static int asix_ax88279_config_aneg(struct phy_device *phydev)
+{
+	bool adv_2500;
+	int ret;
+
+	if (phydev->autoneg == AUTONEG_DISABLE) {
+		phydev_warn(phydev, "Disabling autoneg is not supported\n");
+		return -EOPNOTSUPP;
+	}
+
+	ret = genphy_config_aneg(phydev);
+
+	if (ret < 0)
+		return ret;
+
+	adv_2500 = linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising);
+	ret = phy_modify(phydev, MII_ADVERTISE, AX_ADVERTISE_2500,
+			 adv_2500 ? AX_ADVERTISE_2500 : 0);
+
+	return ret;
+}
+
+static int asix_ax88279_get_features(struct phy_device *phydev)
+{
+	int ret;
+
+	/* 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_clear_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, phydev->supported);
+
+	return 0;
+}
+
+static int asix_ax88279_config_init(struct phy_device *phydev)
+{
+	__set_bit(PHY_INTERFACE_MODE_2500BASEX, phydev->possible_interfaces);
+	__set_bit(PHY_INTERFACE_MODE_SGMII, phydev->possible_interfaces);
+
+	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 +223,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 +259,35 @@ 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,
+	.config_init	= asix_ax88279_config_init,
+	.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 +301,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) },
 	{ }
 };
 
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 087ac63f9193d..2ba1d76872a23 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1612,6 +1612,22 @@ static bool phylink_link_is_up(struct phylink *pl)
 	return pl->netdev ? netif_carrier_ok(pl->netdev) : pl->old_link_state;
 }
 
+/**
+ * phylink_mac_interrupt() - wrapper for phy_mac_interrupt()
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
+ *
+ * Passes a link-change interrupt received by the MAC to phylib.
+ */
+void phylink_mac_interrupt(struct phylink *pl)
+{
+	struct phy_device *phy;
+
+	phy = pl->phydev;
+	if (phy)
+		phy_mac_interrupt(phy);
+}
+EXPORT_SYMBOL_GPL(phylink_mac_interrupt);
+
 static void phylink_resolve(struct work_struct *w)
 {
 	struct phylink *pl = container_of(w, struct phylink, resolve);
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index 52a5c0922c79f..4158455a2da76 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -195,11 +195,12 @@ config USB_NET_AX8817X
 	  This driver creates an interface named "ethX", where X depends on
 	  what other networking devices you have in use.
 
-config USB_NET_AX88179_178A
-	tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet"
+config USB_NET_AX88179
+	tristate "ASIX AX88179/179A/178A USB 3.0/2.0 to Gigabit Ethernet"
 	depends on USB_USBNET
+	select PHYLINK
+	select AX88796B_PHY
 	select CRC32
-	select PHYLIB
 	default y
 	help
 	  This option adds support for ASIX AX88179 based USB 3.0/2.0
@@ -207,6 +208,9 @@ config USB_NET_AX88179_178A
 
 	  This driver should work with at least the following devices:
 	    * ASIX AX88179
+	    * ASIX AX88179A/B
+	    * ASIX AX88279
+	    * ASIX AX88772D/E
 	    * ASIX AX88178A
 	    * Sitcomm LN-032
 
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 4964f7b326fbc..4026f19ecb826 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -12,7 +12,8 @@ obj-$(CONFIG_USB_HSO)		+= hso.o
 obj-$(CONFIG_USB_LAN78XX)	+= lan78xx.o
 obj-$(CONFIG_USB_NET_AX8817X)	+= asix.o
 asix-y := asix_devices.o asix_common.o ax88172a.o
-obj-$(CONFIG_USB_NET_AX88179_178A)      += ax88179_178a.o
+obj-$(CONFIG_USB_NET_AX88179)      += ax88179.o
+ax88179-y := ax88179_178a.o ax88179a_devices.o ax88179_lib.o
 obj-$(CONFIG_USB_NET_CDCETHER)	+= cdc_ether.o
 obj-$(CONFIG_USB_NET_CDC_EEM)	+= cdc_eem.o
 obj-$(CONFIG_USB_NET_DM9601)	+= dm9601.o
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 98f899ea2e946..be72ed955b6b8 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -8,179 +8,12 @@
 #include <linux/module.h>
 #include <linux/etherdevice.h>
 #include <linux/mii.h>
-#include <linux/usb.h>
-#include <linux/crc32.h>
-#include <linux/usb/usbnet.h>
 #include <uapi/linux/mdio.h>
 #include <linux/mdio.h>
-
-#define AX88179_PHY_ID				0x03
-#define AX_EEPROM_LEN				0x100
-#define AX88179_EEPROM_MAGIC			0x17900b95
-#define AX_MCAST_FLTSIZE			8
-#define AX_MAX_MCAST				64
-#define AX_INT_PPLS_LINK			((u32)BIT(16))
-#define AX_RXHDR_L4_TYPE_MASK			0x1c
-#define AX_RXHDR_L4_TYPE_UDP			4
-#define AX_RXHDR_L4_TYPE_TCP			16
-#define AX_RXHDR_L3CSUM_ERR			2
-#define AX_RXHDR_L4CSUM_ERR			1
-#define AX_RXHDR_CRC_ERR			((u32)BIT(29))
-#define AX_RXHDR_DROP_ERR			((u32)BIT(31))
-#define AX_ACCESS_MAC				0x01
-#define AX_ACCESS_PHY				0x02
-#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 PHYSICAL_LINK_STATUS			0x02
-	#define	AX_USB_SS		0x04
-	#define	AX_USB_HS		0x02
-
-#define GENERAL_STATUS				0x03
-/* Check AX88179 version. UA1:Bit2 = 0,  UA2:Bit2 = 1 */
-	#define	AX_SECLD		0x04
-
-#define AX_SROM_ADDR				0x07
-#define AX_SROM_CMD				0x0a
-	#define EEP_RD			0x04
-	#define EEP_BUSY		0x10
-
-#define AX_SROM_DATA_LOW			0x08
-#define AX_SROM_DATA_HIGH			0x09
-
-#define AX_RX_CTL				0x0b
-	#define AX_RX_CTL_DROPCRCERR	0x0100
-	#define AX_RX_CTL_IPE		0x0200
-	#define AX_RX_CTL_START		0x0080
-	#define AX_RX_CTL_AP		0x0020
-	#define AX_RX_CTL_AM		0x0010
-	#define AX_RX_CTL_AB		0x0008
-	#define AX_RX_CTL_AMALL		0x0002
-	#define AX_RX_CTL_PRO		0x0001
-	#define AX_RX_CTL_STOP		0x0000
-
-#define AX_NODE_ID				0x10
-#define AX_MULFLTARY				0x16
-
-#define AX_MEDIUM_STATUS_MODE			0x22
-	#define AX_MEDIUM_GIGAMODE	0x01
-	#define AX_MEDIUM_FULL_DUPLEX	0x02
-	#define AX_MEDIUM_EN_125MHZ	0x08
-	#define AX_MEDIUM_RXFLOW_CTRLEN	0x10
-	#define AX_MEDIUM_TXFLOW_CTRLEN	0x20
-	#define AX_MEDIUM_RECEIVE_EN	0x100
-	#define AX_MEDIUM_PS		0x200
-	#define AX_MEDIUM_JUMBO_EN	0x8040
-
-#define AX_MONITOR_MOD				0x24
-	#define AX_MONITOR_MODE_RWLC	0x02
-	#define AX_MONITOR_MODE_RWMP	0x04
-	#define AX_MONITOR_MODE_PMEPOL	0x20
-	#define AX_MONITOR_MODE_PMETYPE	0x40
-
-#define AX_GPIO_CTRL				0x25
-	#define AX_GPIO_CTRL_GPIO3EN	0x80
-	#define AX_GPIO_CTRL_GPIO2EN	0x40
-	#define AX_GPIO_CTRL_GPIO1EN	0x20
-
-#define AX_PHYPWR_RSTCTL			0x26
-	#define AX_PHYPWR_RSTCTL_BZ	0x0010
-	#define AX_PHYPWR_RSTCTL_IPRL	0x0020
-	#define AX_PHYPWR_RSTCTL_AT	0x1000
-
-#define AX_RX_BULKIN_QCTRL			0x2e
-#define AX_CLK_SELECT				0x33
-	#define AX_CLK_SELECT_BCS	0x01
-	#define AX_CLK_SELECT_ACS	0x02
-	#define AX_CLK_SELECT_ULR	0x08
-
-#define AX_RXCOE_CTL				0x34
-	#define AX_RXCOE_IP		0x01
-	#define AX_RXCOE_TCP		0x02
-	#define AX_RXCOE_UDP		0x04
-	#define AX_RXCOE_TCPV6		0x20
-	#define AX_RXCOE_UDPV6		0x40
-
-#define AX_TXCOE_CTL				0x35
-	#define AX_TXCOE_IP		0x01
-	#define AX_TXCOE_TCP		0x02
-	#define AX_TXCOE_UDP		0x04
-	#define AX_TXCOE_TCPV6		0x20
-	#define AX_TXCOE_UDPV6		0x40
-
-#define AX_LEDCTRL				0x73
-
-#define GMII_PHY_PHYSR				0x11
-	#define GMII_PHY_PHYSR_SMASK	0xc000
-	#define GMII_PHY_PHYSR_GIGA	0x8000
-	#define GMII_PHY_PHYSR_100	0x4000
-	#define GMII_PHY_PHYSR_FULL	0x2000
-	#define GMII_PHY_PHYSR_LINK	0x400
-
-#define GMII_LED_ACT				0x1a
-	#define	GMII_LED_ACTIVE_MASK	0xff8f
-	#define	GMII_LED0_ACTIVE	BIT(4)
-	#define	GMII_LED1_ACTIVE	BIT(5)
-	#define	GMII_LED2_ACTIVE	BIT(6)
-
-#define GMII_LED_LINK				0x1c
-	#define	GMII_LED_LINK_MASK	0xf888
-	#define	GMII_LED0_LINK_10	BIT(0)
-	#define	GMII_LED0_LINK_100	BIT(1)
-	#define	GMII_LED0_LINK_1000	BIT(2)
-	#define	GMII_LED1_LINK_10	BIT(4)
-	#define	GMII_LED1_LINK_100	BIT(5)
-	#define	GMII_LED1_LINK_1000	BIT(6)
-	#define	GMII_LED2_LINK_10	BIT(8)
-	#define	GMII_LED2_LINK_100	BIT(9)
-	#define	GMII_LED2_LINK_1000	BIT(10)
-	#define	LED0_ACTIVE		BIT(0)
-	#define	LED0_LINK_10		BIT(1)
-	#define	LED0_LINK_100		BIT(2)
-	#define	LED0_LINK_1000		BIT(3)
-	#define	LED0_FD			BIT(4)
-	#define	LED0_USB3_MASK		0x001f
-	#define	LED1_ACTIVE		BIT(5)
-	#define	LED1_LINK_10		BIT(6)
-	#define	LED1_LINK_100		BIT(7)
-	#define	LED1_LINK_1000		BIT(8)
-	#define	LED1_FD			BIT(9)
-	#define	LED1_USB3_MASK		0x03e0
-	#define	LED2_ACTIVE		BIT(10)
-	#define	LED2_LINK_1000		BIT(13)
-	#define	LED2_LINK_100		BIT(12)
-	#define	LED2_LINK_10		BIT(11)
-	#define	LED2_FD			BIT(14)
-	#define	LED_VALID		BIT(15)
-	#define	LED2_USB3_MASK		0x7c00
-
-#define GMII_PHYPAGE				0x1e
-#define GMII_PHY_PAGE_SELECT			0x1f
-	#define GMII_PHY_PGSEL_EXT	0x0007
-	#define GMII_PHY_PGSEL_PAGE0	0x0000
-	#define GMII_PHY_PGSEL_PAGE3	0x0003
-	#define GMII_PHY_PGSEL_PAGE5	0x0005
+#include "ax88179_lib.h"
 
 static int ax88179_reset(struct usbnet *dev);
 
-struct ax88179_data {
-	u8  eee_enabled;
-	u8  eee_active;
-	u16 rxctl;
-	u8 in_pm;
-	u32 wol_supported;
-	u32 wolopts;
-	u8 disconnecting;
-};
-
-struct ax88179_int_data {
-	__le32 intdata1;
-	__le32 intdata2;
-};
-
 static const struct {
 	unsigned char ctrl, timer_l, timer_h, size, ifg;
 } AX88179_BULKIN_SIZE[] =	{
@@ -190,165 +23,6 @@ static const struct {
 	{7, 0xcc, 0x4c, 0x18, 8},
 };
 
-static void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode)
-{
-	struct ax88179_data *ax179_data = dev->driver_priv;
-
-	ax179_data->in_pm = pm_mode;
-}
-
-static int ax88179_in_pm(struct usbnet *dev)
-{
-	struct ax88179_data *ax179_data = dev->driver_priv;
-
-	return ax179_data->in_pm;
-}
-
-static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
-			      u16 size, void *data)
-{
-	int ret;
-	int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16);
-	struct ax88179_data *ax179_data = dev->driver_priv;
-
-	BUG_ON(!dev);
-
-	if (!ax88179_in_pm(dev))
-		fn = usbnet_read_cmd;
-	else
-		fn = usbnet_read_cmd_nopm;
-
-	ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-		 value, index, data, size);
-
-	if (unlikely((ret < 0) && !(ret == -ENODEV && ax179_data->disconnecting)))
-		netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n",
-			    index, ret);
-
-	return ret;
-}
-
-static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
-			       u16 size, const void *data)
-{
-	int ret;
-	int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16);
-	struct ax88179_data *ax179_data = dev->driver_priv;
-
-	BUG_ON(!dev);
-
-	if (!ax88179_in_pm(dev))
-		fn = usbnet_write_cmd;
-	else
-		fn = usbnet_write_cmd_nopm;
-
-	ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-		 value, index, data, size);
-
-	if (unlikely((ret < 0) && !(ret == -ENODEV && ax179_data->disconnecting)))
-		netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n",
-			    index, ret);
-
-	return ret;
-}
-
-static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value,
-				    u16 index, u16 size, void *data)
-{
-	u16 buf;
-
-	if (2 == size) {
-		buf = *((u16 *)data);
-		cpu_to_le16s(&buf);
-		usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |
-				       USB_RECIP_DEVICE, value, index, &buf,
-				       size);
-	} else {
-		usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |
-				       USB_RECIP_DEVICE, value, index, data,
-				       size);
-	}
-}
-
-static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
-			    u16 size, void *data)
-{
-	int ret;
-
-	if (2 == size) {
-		u16 buf = 0;
-		ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf);
-		le16_to_cpus(&buf);
-		*((u16 *)data) = buf;
-	} else if (4 == size) {
-		u32 buf = 0;
-		ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf);
-		le32_to_cpus(&buf);
-		*((u32 *)data) = buf;
-	} else {
-		ret = __ax88179_read_cmd(dev, cmd, value, index, size, data);
-	}
-
-	return ret;
-}
-
-static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
-			     u16 size, const void *data)
-{
-	int ret;
-
-	if (2 == size) {
-		u16 buf;
-		buf = *((u16 *)data);
-		cpu_to_le16s(&buf);
-		ret = __ax88179_write_cmd(dev, cmd, value, index,
-					  size, &buf);
-	} else {
-		ret = __ax88179_write_cmd(dev, cmd, value, index,
-					  size, data);
-	}
-
-	return ret;
-}
-
-static void ax88179_status(struct usbnet *dev, struct urb *urb)
-{
-	struct ax88179_int_data *event;
-	u32 link;
-
-	if (urb->actual_length < 8)
-		return;
-
-	event = urb->transfer_buffer;
-	le32_to_cpus((void *)&event->intdata1);
-
-	link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16;
-
-	if (netif_carrier_ok(dev->net) != link) {
-		usbnet_link_change(dev, link, 1);
-		if (!link)
-			netdev_info(dev->net, "ax88179 - Link status is: 0\n");
-	}
-}
-
-static int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc)
-{
-	struct usbnet *dev = netdev_priv(netdev);
-	u16 res;
-
-	ax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res);
-	return res;
-}
-
-static void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc,
-			       int val)
-{
-	struct usbnet *dev = netdev_priv(netdev);
-	u16 res = (u16) val;
-
-	ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res);
-}
-
 static inline int ax88179_phy_mmd_indirect(struct usbnet *dev, u16 prtad,
 					   u16 devad)
 {
@@ -510,146 +184,11 @@ static void ax88179_disconnect(struct usb_interface *intf)
 	usbnet_disconnect(intf);
 }
 
-static void
-ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
-{
-	struct usbnet *dev = netdev_priv(net);
-	struct ax88179_data *priv = dev->driver_priv;
-
-	wolinfo->supported = priv->wol_supported;
-	wolinfo->wolopts = priv->wolopts;
-}
-
-static int
-ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
-{
-	struct usbnet *dev = netdev_priv(net);
-	struct ax88179_data *priv = dev->driver_priv;
-
-	if (wolinfo->wolopts & ~(priv->wol_supported))
-		return -EINVAL;
-
-	priv->wolopts = wolinfo->wolopts;
-
-	return 0;
-}
-
 static int ax88179_get_eeprom_len(struct net_device *net)
 {
 	return AX_EEPROM_LEN;
 }
 
-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;
-
-	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);
-	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]);
-		if (ret < 0) {
-			kfree(eeprom_buff);
-			return -EIO;
-		}
-	}
-
-	memcpy(data, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len);
-	kfree(eeprom_buff);
-	return 0;
-}
-
-static int
-ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
-		   u8 *data)
-{
-	struct usbnet *dev = netdev_priv(net);
-	u16 *eeprom_buff;
-	int first_word;
-	int last_word;
-	int ret;
-	int i;
-
-	netdev_dbg(net, "write EEPROM len %d, offset %d, magic 0x%x\n",
-		   eeprom->len, eeprom->offset, eeprom->magic);
-
-	if (eeprom->len == 0)
-		return -EINVAL;
-
-	if (eeprom->magic != AX88179_EEPROM_MAGIC)
-		return -EINVAL;
-
-	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);
-	if (!eeprom_buff)
-		return -ENOMEM;
-
-	/* align data to 16 bit boundaries, read the missing data from
-	   the EEPROM */
-	if (eeprom->offset & 1) {
-		ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, first_word, 1, 2,
-				       &eeprom_buff[0]);
-		if (ret < 0) {
-			netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", first_word);
-			goto free;
-		}
-	}
-
-	if ((eeprom->offset + eeprom->len) & 1) {
-		ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, last_word, 1, 2,
-				       &eeprom_buff[last_word - first_word]);
-		if (ret < 0) {
-			netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", last_word);
-			goto free;
-		}
-	}
-
-	memcpy((u8 *)eeprom_buff + (eeprom->offset & 1), data, eeprom->len);
-
-	for (i = first_word; i <= last_word; i++) {
-		netdev_dbg(net, "write to EEPROM at offset 0x%02x, data 0x%04x\n",
-			   i, eeprom_buff[i - first_word]);
-		ret = ax88179_write_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2,
-					&eeprom_buff[i - first_word]);
-		if (ret < 0) {
-			netdev_err(net, "Failed to write EEPROM at offset 0x%02x.\n", i);
-			goto free;
-		}
-		msleep(20);
-	}
-
-	/* reload EEPROM data */
-	ret = ax88179_write_cmd(dev, AX_RELOAD_EEPROM_EFUSE, 0x0000, 0, 0, NULL);
-	if (ret < 0) {
-		netdev_err(net, "Failed to reload EEPROM data\n");
-		goto free;
-	}
-
-	ret = 0;
-free:
-	kfree(eeprom_buff);
-	return ret;
-}
-
 static int ax88179_get_link_ksettings(struct net_device *net,
 				      struct ethtool_link_ksettings *cmd)
 {
@@ -864,125 +403,6 @@ static const struct ethtool_ops ax88179_ethtool_ops = {
 	.get_ts_info		= ethtool_op_get_ts_info,
 };
 
-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);
-
-	data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE);
-
-	if (net->flags & IFF_PROMISC) {
-		data->rxctl |= AX_RX_CTL_PRO;
-	} else if (net->flags & IFF_ALLMULTI ||
-		   netdev_mc_count(net) > AX_MAX_MCAST) {
-		data->rxctl |= AX_RX_CTL_AMALL;
-	} else if (netdev_mc_empty(net)) {
-		/* just broadcast and directed */
-	} else {
-		/* We use dev->data for our 8 byte filter buffer
-		 * to avoid allocating memory that is tricky to free later
-		 */
-		u32 crc_bits;
-		struct netdev_hw_addr *ha;
-
-		memset(m_filter, 0, AX_MCAST_FLTSIZE);
-
-		netdev_for_each_mc_addr(ha, net) {
-			crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
-			*(m_filter + (crc_bits >> 3)) |= (1 << (crc_bits & 7));
-		}
-
-		ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_MULFLTARY,
-					AX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE,
-					m_filter);
-
-		data->rxctl |= AX_RX_CTL_AM;
-	}
-
-	ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL,
-				2, 2, &data->rxctl);
-}
-
-static int
-ax88179_set_features(struct net_device *net, netdev_features_t features)
-{
-	u8 tmp;
-	struct usbnet *dev = netdev_priv(net);
-	netdev_features_t changed = net->features ^ features;
-
-	if (changed & NETIF_F_IP_CSUM) {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
-		tmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP;
-		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
-	}
-
-	if (changed & NETIF_F_IPV6_CSUM) {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
-		tmp ^= AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6;
-		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
-	}
-
-	if (changed & NETIF_F_RXCSUM) {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp);
-		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);
-	}
-
-	return 0;
-}
-
-static int ax88179_change_mtu(struct net_device *net, int new_mtu)
-{
-	struct usbnet *dev = netdev_priv(net);
-	u16 tmp16;
-
-	WRITE_ONCE(net->mtu, new_mtu);
-	dev->hard_mtu = net->mtu + net->hard_header_len;
-
-	if (net->mtu > 1500) {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
-				 2, 2, &tmp16);
-		tmp16 |= AX_MEDIUM_JUMBO_EN;
-		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
-				  2, 2, &tmp16);
-	} else {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
-				 2, 2, &tmp16);
-		tmp16 &= ~AX_MEDIUM_JUMBO_EN;
-		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
-				  2, 2, &tmp16);
-	}
-
-	/* max qlen depend on hard_mtu and rx_urb_size */
-	usbnet_update_max_qlen(dev);
-
-	return 0;
-}
-
-static int ax88179_set_mac_addr(struct net_device *net, void *p)
-{
-	struct usbnet *dev = netdev_priv(net);
-	struct sockaddr *addr = p;
-	int ret;
-
-	if (netif_running(net))
-		return -EBUSY;
-	if (!is_valid_ether_addr(addr->sa_data))
-		return -EADDRNOTAVAIL;
-
-	eth_hw_addr_set(net, addr->sa_data);
-
-	/* Set the MAC address */
-	ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
-				 ETH_ALEN, net->dev_addr);
-	if (ret < 0)
-		return ret;
-
-	return 0;
-}
-
 static const struct net_device_ops ax88179_netdev_ops = {
 	.ndo_open		= usbnet_open,
 	.ndo_stop		= usbnet_stop,
@@ -1249,35 +669,6 @@ static int ax88179_led_setting(struct usbnet *dev)
 	return 0;
 }
 
-static void ax88179_get_mac_addr(struct usbnet *dev)
-{
-	u8 mac[ETH_ALEN];
-
-	memset(mac, 0, sizeof(mac));
-
-	/* Maybe the boot loader passed the MAC address via device tree */
-	if (!eth_platform_get_mac_address(&dev->udev->dev, mac)) {
-		netif_dbg(dev, ifup, dev->net,
-			  "MAC address read from device tree");
-	} else {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
-				 ETH_ALEN, mac);
-		netif_dbg(dev, ifup, dev->net,
-			  "MAC address read from ASIX chip");
-	}
-
-	if (is_valid_ether_addr(mac)) {
-		eth_hw_addr_set(dev->net, mac);
-		if (!is_local_ether_addr(mac))
-			dev->net->addr_assign_type = NET_ADDR_PERM;
-	} else {
-		netdev_info(dev->net, "invalid MAC address, using random\n");
-	}
-
-	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN,
-			  dev->net->dev_addr);
-}
-
 static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
 {
 	struct ax88179_data *ax179_data;
@@ -1293,6 +684,22 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
 
 	dev->driver_priv = ax179_data;
 
+	ax179_data->resume = ax88179_resume;
+	ax179_data->suspend = ax88179_suspend;
+
+	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_write_cmd = AX_ACCESS_EEPROM;
+	ax179_data->eeprom_block = 2;
+	ax179_data->eeprom_wen = 0;
+
 	dev->net->netdev_ops = &ax88179_netdev_ops;
 	dev->net->ethtool_ops = &ax88179_ethtool_ops;
 	dev->net->needed_headroom = 8;
@@ -1317,6 +724,12 @@ 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 ax88179_unbind(struct usbnet *dev, struct usb_interface *intf)
@@ -1617,11 +1030,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 |
@@ -1878,6 +1290,18 @@ static const struct driver_info at_umc2000sp_info = {
 
 static const struct usb_device_id products[] = {
 {
+	/* ASIX AX88179A USB 3.2 1000Mbit Ethernet */
+	USB_DEVICE_VER(0x0b95, 0x1790, 0, 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 2500Mbit Ethernet */
+	USB_DEVICE_VER(0x0b95, 0x1790, 0, 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,
@@ -1934,19 +1358,19 @@ static const struct usb_device_id products[] = {
 };
 MODULE_DEVICE_TABLE(usb, products);
 
-static struct usb_driver ax88179_178a_driver = {
-	.name =		"ax88179_178a",
+static struct usb_driver ax88179_driver = {
+	.name =		"ax88179",
 	.id_table =	products,
 	.probe =	usbnet_probe,
-	.suspend =	ax88179_suspend,
-	.resume =	ax88179_resume,
-	.reset_resume =	ax88179_resume,
+	.suspend =	ax88179_suspend_wrapper,
+	.resume =	ax88179_resume_wrapper,
+	.reset_resume =	ax88179_resume_wrapper,
 	.disconnect =	ax88179_disconnect,
 	.supports_autosuspend = 1,
 	.disable_hub_initiated_lpm = 1,
 };
 
-module_usb_driver(ax88179_178a_driver);
+module_usb_driver(ax88179_driver);
 
-MODULE_DESCRIPTION("ASIX AX88179/178A based USB 3.0/2.0 Gigabit Ethernet Devices");
+MODULE_DESCRIPTION("ASIX AX88179/179A/178A based USB 3.0/2.0 Gigabit Ethernet Devices");
 MODULE_LICENSE("GPL");
diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c
new file mode 100644
index 0000000000000..9b91ad831333e
--- /dev/null
+++ b/drivers/net/usb/ax88179_lib.c
@@ -0,0 +1,515 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices
+ *
+ * Copyright (C) 2011-2013 ASIX
+ */
+
+#include <linux/etherdevice.h>
+#include "ax88179_lib.h"
+
+void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode)
+{
+	struct ax88179_data *ax179_data = dev->driver_priv;
+
+	ax179_data->in_pm = pm_mode;
+}
+
+static int ax88179_in_pm(struct usbnet *dev)
+{
+	struct ax88179_data *ax179_data = dev->driver_priv;
+
+	return ax179_data->in_pm;
+}
+
+int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
+		       u16 size, void *data)
+{
+	int ret;
+	int (*fn)(struct usbnet *dev, u8 cmd, u8 rtype, u16 val, u16 i, void *d, u16 size);
+	struct ax88179_data *ax179_data = dev->driver_priv;
+
+	if (!dev) {
+		netdev_err(dev->net, "No net device.\n");
+		return -ENODEV;
+	}
+
+	if (!ax88179_in_pm(dev))
+		fn = usbnet_read_cmd;
+	else
+		fn = usbnet_read_cmd_nopm;
+
+	ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+		 value, index, data, size);
+
+	if (unlikely(ret < 0 && !(ret == -ENODEV && ax179_data->disconnecting)))
+		netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n",
+			    index, ret);
+
+	return ret;
+}
+
+static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
+			       u16 size, const void *data)
+{
+	int ret;
+	int (*fn)(struct usbnet *dev, u8 cmd, u8 rtype, u16 val, u16 i, const void *d, u16 size);
+	struct ax88179_data *ax179_data = dev->driver_priv;
+
+	if (!dev) {
+		netdev_err(dev->net, "No net device.\n");
+		return -ENODEV;
+	}
+
+	if (!ax88179_in_pm(dev))
+		fn = usbnet_write_cmd;
+	else
+		fn = usbnet_write_cmd_nopm;
+
+	ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+		 value, index, data, size);
+
+	if (unlikely(ret < 0 && !(ret == -ENODEV && ax179_data->disconnecting)))
+		netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n",
+			    index, ret);
+
+	return ret;
+}
+
+void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size,
+			     void *data)
+{
+	u16 buf;
+
+	if (size == 2) {
+		buf = *((u16 *)data);
+		cpu_to_le16s(&buf);
+		usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |
+				       USB_RECIP_DEVICE, value, index, &buf,
+				       size);
+	} else {
+		usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |
+				       USB_RECIP_DEVICE, value, index, data,
+				       size);
+	}
+}
+
+int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data)
+{
+	int ret;
+
+	if (size == 2) {
+		u16 buf = 0;
+
+		ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf);
+		le16_to_cpus(&buf);
+		*((u16 *)data) = buf;
+	} else if (size == 4) {
+		u32 buf = 0;
+
+		ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf);
+		le32_to_cpus(&buf);
+		*((u32 *)data) = buf;
+	} else {
+		ret = __ax88179_read_cmd(dev, cmd, value, index, size, data);
+	}
+
+	return ret;
+}
+
+int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size,
+		      const void *data)
+{
+	int ret;
+
+	if (size == 2) {
+		u16 buf;
+
+		buf = *((u16 *)data);
+		cpu_to_le16s(&buf);
+		ret = __ax88179_write_cmd(dev, cmd, value, index,
+					  size, &buf);
+	} else {
+		ret = __ax88179_write_cmd(dev, cmd, value, index,
+					  size, data);
+	}
+
+	return ret;
+}
+
+struct ax88179_data *netdev2data(struct net_device *net)
+{
+	struct usbnet *dev = netdev_priv(net);
+
+	return dev->driver_priv;
+}
+
+void ax88179_status(struct usbnet *dev, struct urb *urb)
+{
+	struct ax88179_int_data *event;
+	u32 link;
+
+	if (urb->actual_length < 8)
+		return;
+
+	event = urb->transfer_buffer;
+	le32_to_cpus((void *)&event->intdata1);
+
+	link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16;
+
+	if (netif_carrier_ok(dev->net) != link) {
+		usbnet_link_change(dev, link, 1);
+		if (!link)
+			netdev_info(dev->net, "ax88179 - Link status is: 0\n");
+	}
+}
+
+int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc)
+{
+	struct usbnet *dev = netdev_priv(netdev);
+	u16 res;
+
+	ax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res);
+	return res;
+}
+
+void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
+{
+	struct usbnet *dev = netdev_priv(netdev);
+	u16 res = (u16)val;
+
+	ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res);
+}
+
+void ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
+{
+	struct usbnet *dev = netdev_priv(net);
+	struct ax88179_data *priv = dev->driver_priv;
+
+	wolinfo->supported = priv->wol_supported;
+	wolinfo->wolopts = priv->wolopts;
+}
+
+int ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
+{
+	struct usbnet *dev = netdev_priv(net);
+	struct ax88179_data *priv = dev->driver_priv;
+
+	if (wolinfo->wolopts & ~(priv->wol_supported))
+		return -EINVAL;
+
+	priv->wolopts = wolinfo->wolopts;
+
+	return 0;
+}
+
+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;
+	}
+}
+
+int ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 *data)
+{
+	struct usbnet *dev = netdev_priv(net);
+	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 = 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;
+
+	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, eeprom_buff + eeprom->offset % ax179_data->eeprom_block, eeprom->len);
+	kfree(eeprom_buff);
+	return 0;
+}
+
+int 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);
+
+	if (eeprom->len == 0)
+		return -EINVAL;
+
+	if (eeprom->magic != AX88179_EEPROM_MAGIC)
+		return -EINVAL;
+
+	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);
+	if (!eeprom_buff)
+		return -ENOMEM;
+
+	/* align data to 16 bit boundaries, read the missing data from
+	 * the EEPROM
+	 */
+	if (eeprom->offset & 1) {
+		ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, first_word, 1, 2,
+				       &eeprom_buff[0]);
+		if (ret < 0) {
+			netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", first_word);
+			goto free;
+		}
+	}
+
+	if ((eeprom->offset + eeprom->len) & 1) {
+		ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, last_word, 1, 2,
+				       &eeprom_buff[last_word - first_word]);
+		if (ret < 0) {
+			netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", last_word);
+			goto free;
+		}
+	}
+
+	memcpy((u8 *)eeprom_buff + (eeprom->offset & 1), data, eeprom->len);
+
+	for (i = first_word; i <= last_word; i++) {
+		netdev_dbg(net, "write to EEPROM at offset 0x%02x, data 0x%04x\n",
+			   i, eeprom_buff[i - first_word]);
+		ret = ax88179_write_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2,
+					&eeprom_buff[i - first_word]);
+		if (ret < 0) {
+			netdev_err(net, "Failed to write EEPROM at offset 0x%02x.\n", i);
+			goto free;
+		}
+		msleep(20);
+	}
+
+	/* reload EEPROM data */
+	ret = ax88179_write_cmd(dev, AX_RELOAD_EEPROM_EFUSE, 0x0000, 0, 0, NULL);
+	if (ret < 0) {
+		netdev_err(net, "Failed to reload EEPROM data\n");
+		goto free;
+	}
+
+	ret = 0;
+free:
+	kfree(eeprom_buff);
+	return ret;
+}
+
+void ax88179_set_multicast(struct net_device *net)
+{
+	struct usbnet *dev = netdev_priv(net);
+	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_DROPCRCERR);
+	if (data->ip_align)
+		data->rxctl |= AX_RX_CTL_IPE;
+
+	if (net->flags & IFF_PROMISC) {
+		data->rxctl |= AX_RX_CTL_PRO;
+	} else if (net->flags & IFF_ALLMULTI ||
+		   netdev_mc_count(net) > AX_MAX_MCAST) {
+		data->rxctl |= AX_RX_CTL_AMALL;
+	} else if (netdev_mc_empty(net)) {
+		/* just broadcast and directed */
+	} else {
+		/* We use dev->data for our 8 byte filter buffer
+		 * to avoid allocating memory that is tricky to free later
+		 */
+		u32 crc_bits;
+		struct netdev_hw_addr *ha;
+
+		memset(m_filter, 0, AX_MCAST_FLTSIZE);
+
+		netdev_for_each_mc_addr(ha, net) {
+			crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
+			*(m_filter + (crc_bits >> 3)) |= (1 << (crc_bits & 7));
+		}
+
+		ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_MULFLTARY,
+					AX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE,
+					m_filter);
+
+		data->rxctl |= AX_RX_CTL_AM;
+	}
+
+	ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL,
+				2, 2, &data->rxctl);
+}
+
+int 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) {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
+		tmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
+	}
+
+	if (changed & NETIF_F_IPV6_CSUM) {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
+		tmp ^= AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
+	}
+
+	if (changed & NETIF_F_RXCSUM) {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp);
+		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);
+	}
+
+	return 0;
+}
+
+void ax88179_get_mac_addr(struct usbnet *dev)
+{
+	u8 mac[ETH_ALEN];
+
+	memset(mac, 0, sizeof(mac));
+
+	/* Maybe the boot loader passed the MAC address via device tree */
+	if (!eth_platform_get_mac_address(&dev->udev->dev, mac)) {
+		netif_dbg(dev, ifup, dev->net,
+			  "MAC address read from device tree");
+	} else {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
+				 ETH_ALEN, mac);
+		netif_dbg(dev, ifup, dev->net,
+			  "MAC address read from ASIX chip");
+	}
+
+	if (is_valid_ether_addr(mac)) {
+		eth_hw_addr_set(dev->net, mac);
+		if (!is_local_ether_addr(mac))
+			dev->net->addr_assign_type = NET_ADDR_PERM;
+	} else {
+		netdev_info(dev->net, "invalid MAC address, using random\n");
+	}
+
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN,
+			  dev->net->dev_addr);
+}
+
+int ax88179_change_mtu(struct net_device *net, int new_mtu)
+{
+	struct usbnet *dev = netdev_priv(net);
+	u16 tmp16;
+
+	WRITE_ONCE(net->mtu, new_mtu);
+	dev->hard_mtu = net->mtu + net->hard_header_len;
+
+	if (net->mtu > 1500) {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+				 2, 2, &tmp16);
+		tmp16 |= AX_MEDIUM_JUMBO_EN;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+				  2, 2, &tmp16);
+	} else {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+				 2, 2, &tmp16);
+		tmp16 &= ~AX_MEDIUM_JUMBO_EN;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+				  2, 2, &tmp16);
+	}
+
+	/* max qlen depend on hard_mtu and rx_urb_size */
+	usbnet_update_max_qlen(dev);
+
+	return 0;
+}
+
+int ax88179_set_mac_addr(struct net_device *net, void *p)
+{
+	struct usbnet *dev = netdev_priv(net);
+	struct sockaddr *addr = p;
+	int ret;
+
+	if (netif_running(net))
+		return -EBUSY;
+	if (!is_valid_ether_addr(addr->sa_data))
+		return -EADDRNOTAVAIL;
+
+	eth_hw_addr_set(net, addr->sa_data);
+
+	/* Set the MAC address */
+	ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
+				ETH_ALEN, net->dev_addr);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+int ax88179_suspend_wrapper(struct usb_interface *intf, pm_message_t message)
+{
+	struct usbnet *dev = usb_get_intfdata(intf);
+	struct ax88179_data *priv;
+
+	priv = dev->driver_priv;
+
+	return priv->suspend(intf, message);
+}
+
+int ax88179_resume_wrapper(struct usb_interface *intf)
+{
+	struct usbnet *dev = usb_get_intfdata(intf);
+	struct ax88179_data *priv;
+
+	priv = dev->driver_priv;
+	return priv->resume(intf);
+}
+
diff --git a/drivers/net/usb/ax88179_lib.h b/drivers/net/usb/ax88179_lib.h
new file mode 100644
index 0000000000000..16a6dcbd6e66e
--- /dev/null
+++ b/drivers/net/usb/ax88179_lib.h
@@ -0,0 +1,358 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include <linux/usb.h>
+#include <linux/crc32.h>
+#include <linux/phylink.h>
+#include <linux/usb/usbnet.h>
+
+#ifndef __LINUX_USBNET_AX88179_H
+#define __LINUX_USBNET_AX88179_H
+
+#define AX88179_PHY_ID				0x03
+#define AX_EEPROM_LEN				0x100
+#define AX88179_EEPROM_MAGIC			0x17900b95
+#define AX_MCAST_FLTSIZE			8
+#define AX_MAX_MCAST				64
+#define AX_INT_PPLS_LINK			((u32)BIT(16))
+#define AX_RXHDR_L4_TYPE_MASK			0x1c
+#define AX_RXHDR_L4_TYPE_UDP			4
+#define AX_RXHDR_L4_TYPE_TCP			16
+#define AX_RXHDR_L3CSUM_ERR			2
+#define AX_RXHDR_L4CSUM_ERR			1
+#define AX_RXHDR_CRC_ERR			((u32)BIT(29))
+#define AX_RXHDR_DROP_ERR			((u32)BIT(31))
+#define AX_ACCESS_MAC				0x01
+#define AX_ACCESS_PHY				0x02
+#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 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
+#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
+	#define EEP_BUSY		0x10
+
+#define AX_SROM_DATA_LOW			0x08
+#define AX_SROM_DATA_HIGH			0x09
+
+#define AX_RX_CTL				0x0b
+	#define AX_RX_CTL_DROPCRCERR	0x0100
+	#define AX_RX_CTL_IPE		0x0200
+	#define AX_RX_CTL_START		0x0080
+	#define AX_RX_CTL_AP		0x0020
+	#define AX_RX_CTL_AM		0x0010
+	#define AX_RX_CTL_AB		0x0008
+	#define AX_RX_CTL_AMALL		0x0002
+	#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
+
+#define AX_MEDIUM_STATUS_MODE			0x22
+	#define AX_MEDIUM_GIGAMODE	0x01
+	#define AX_MEDIUM_FULL_DUPLEX	0x02
+	#define AX_MEDIUM_EN_125MHZ	0x08
+	#define AX_MEDIUM_RXFLOW_CTRLEN	0x10
+	#define AX_MEDIUM_TXFLOW_CTRLEN	0x20
+	#define AX_MEDIUM_RECEIVE_EN	0x100
+	#define AX_MEDIUM_PS		0x200
+	#define AX_MEDIUM_JUMBO_EN	0x8040
+
+#define AX_MONITOR_MOD				0x24
+	#define AX_MONITOR_MODE_RWLC	0x02
+	#define AX_MONITOR_MODE_RWMP	0x04
+	#define AX_MONITOR_MODE_PMEPOL	0x20
+	#define AX_MONITOR_MODE_PMETYPE	0x40
+
+#define AX_GPIO_CTRL				0x25
+	#define AX_GPIO_CTRL_GPIO3EN	0x80
+	#define AX_GPIO_CTRL_GPIO2EN	0x40
+	#define AX_GPIO_CTRL_GPIO1EN	0x20
+
+#define AX_PHYPWR_RSTCTL			0x26
+	#define AX_PHYPWR_RSTCTL_BZ	0x0010
+	#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_GPHY_EEE_CTRL			0x01
+
+#define AX_CLK_SELECT				0x33
+	#define AX_CLK_SELECT_BCS	0x01
+	#define AX_CLK_SELECT_ACS	0x02
+	#define AX_CLK_SELECT_ULR	0x08
+
+#define AX_RXCOE_CTL				0x34
+	#define AX_RXCOE_IP		0x01
+	#define AX_RXCOE_TCP		0x02
+	#define AX_RXCOE_UDP		0x04
+	#define AX_RXCOE_TCPV6		0x20
+	#define AX_RXCOE_UDPV6		0x40
+
+#define AX_TXCOE_CTL				0x35
+	#define AX_TXCOE_IP		0x01
+	#define AX_TXCOE_TCP		0x02
+	#define AX_TXCOE_UDP		0x04
+	#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
+	#define GMII_PHY_PHYSR_GIGA	0x8000
+	#define GMII_PHY_PHYSR_100	0x4000
+	#define GMII_PHY_PHYSR_FULL	0x2000
+	#define GMII_PHY_PHYSR_LINK	0x400
+
+#define GMII_LED_ACT				0x1a
+	#define	GMII_LED_ACTIVE_MASK	0xff8f
+	#define	GMII_LED0_ACTIVE	BIT(4)
+	#define	GMII_LED1_ACTIVE	BIT(5)
+	#define	GMII_LED2_ACTIVE	BIT(6)
+
+#define GMII_LED_LINK				0x1c
+	#define	GMII_LED_LINK_MASK	0xf888
+	#define	GMII_LED0_LINK_10	BIT(0)
+	#define	GMII_LED0_LINK_100	BIT(1)
+	#define	GMII_LED0_LINK_1000	BIT(2)
+	#define	GMII_LED1_LINK_10	BIT(4)
+	#define	GMII_LED1_LINK_100	BIT(5)
+	#define	GMII_LED1_LINK_1000	BIT(6)
+	#define	GMII_LED2_LINK_10	BIT(8)
+	#define	GMII_LED2_LINK_100	BIT(9)
+	#define	GMII_LED2_LINK_1000	BIT(10)
+	#define	LED0_ACTIVE		BIT(0)
+	#define	LED0_LINK_10		BIT(1)
+	#define	LED0_LINK_100		BIT(2)
+	#define	LED0_LINK_1000		BIT(3)
+	#define	LED0_FD			BIT(4)
+	#define	LED0_USB3_MASK		0x001f
+	#define	LED1_ACTIVE		BIT(5)
+	#define	LED1_LINK_10		BIT(6)
+	#define	LED1_LINK_100		BIT(7)
+	#define	LED1_LINK_1000		BIT(8)
+	#define	LED1_FD			BIT(9)
+	#define	LED1_USB3_MASK		0x03e0
+	#define	LED2_ACTIVE		BIT(10)
+	#define	LED2_LINK_1000		BIT(13)
+	#define	LED2_LINK_100		BIT(12)
+	#define	LED2_LINK_10		BIT(11)
+	#define	LED2_FD			BIT(14)
+	#define	LED_VALID		BIT(15)
+	#define	LED2_USB3_MASK		0x7c00
+
+#define GMII_PHYPAGE				0x1e
+#define GMII_PHY_PAGE_SELECT			0x1f
+	#define GMII_PHY_PGSEL_EXT	0x0007
+	#define GMII_PHY_PGSEL_PAGE0	0x0000
+	#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
+
+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;
+	u16 rxctl;
+	u8 in_pm;
+	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;
+	u8 rx_checksum;
+	u8 eeprom_read_cmd;
+	u8 eeprom_write_cmd;
+	u8 eeprom_wen;
+	u16 eeprom_block;
+	struct mii_bus *mdio;
+	struct phy_device *phydev;
+	struct phylink *phylink;
+	struct phylink_config phylink_config;
+	int (*resume)(struct usb_interface *intf);
+	int (*suspend)(struct usb_interface *intf, pm_message_t message);
+};
+
+struct ax88179_int_data {
+	__le32 intdata1;
+	__le32 intdata2;
+};
+
+struct ax_bulkin_settings {
+	unsigned char ctrl, timer_l, timer_h, size, ifg;
+};
+
+void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode);
+int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data);
+int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data);
+int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size,
+		      const void *data);
+void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
+			     u16 size, void *data);
+int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc);
+void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc, int val);
+struct ax88179_data *netdev2data(struct net_device *net);
+void ax88179_status(struct usbnet *dev, struct urb *urb);
+void ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo);
+int ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo);
+int ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 *data);
+int ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 *data);
+void ax88179_set_multicast(struct net_device *net);
+int ax88179_set_features(struct net_device *net, netdev_features_t features);
+void ax88179_get_mac_addr(struct usbnet *dev);
+int ax88179_change_mtu(struct net_device *net, int new_mtu);
+int ax88179_set_mac_addr(struct net_device *net, void *p);
+int ax88179_suspend_wrapper(struct usb_interface *intf, pm_message_t message);
+int ax88179_resume_wrapper(struct usb_interface *intf);
+
+extern const struct driver_info ax88179a_info;
+extern const struct driver_info ax88772d_info;
+extern const struct driver_info ax88279_info;
+
+#endif /*__LINUX_USBNET_AX88179_H */
diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
new file mode 100644
index 0000000000000..6b57111a0e05a
--- /dev/null
+++ b/drivers/net/usb/ax88179a_devices.c
@@ -0,0 +1,1222 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/module.h>
+#include <linux/phylink.h>
+#include <linux/if_vlan.h>
+#include "ax88179_lib.h"
+
+static int ax88179a_reset(struct usbnet *dev);
+
+#define AX88279_EEPROM_LEN			0x4000
+#define AX88179A_EEPROM_LEN			(32 * 20)
+
+enum ax_bulk_in_speeds {
+	BULK_IN_SPEED_2G5 = 0,
+	BULK_IN_SPEED_1G_SS = 1,
+	BULK_IN_SPEED_1G_HS   = 2,
+	BULK_IN_SPEED_100_FULL_SS = 3,
+	BULK_IN_SPEED_100_HALF_SS = 4,
+	BULK_IN_SPEED_100_FULL_HS = 5,
+	BULK_IN_SPEED_100_HALF_HS = 6,
+	BULK_IN_SPEED_FS = 7,
+};
+
+static const struct ax_bulkin_settings AX88179A_BULKIN_SIZE[] = {
+	[BULK_IN_SPEED_1G_SS]		= {5, 0x7B, 0x00, 0x17, 0x0F},
+	[BULK_IN_SPEED_1G_HS]		= {5, 0xC0, 0x02, 0x06, 0x0F},
+	[BULK_IN_SPEED_100_FULL_SS]	= {7, 0xF0, 0x00, 0x0C, 0x0F},
+	[BULK_IN_SPEED_100_HALF_SS]	= {6, 0x00, 0x00, 0x06, 0x0F},
+	[BULK_IN_SPEED_100_FULL_HS]	= {5, 0xC0, 0x04, 0x06, 0x0F},
+	[BULK_IN_SPEED_100_HALF_HS]	= {7, 0xC0, 0x04, 0x06, 0x0F},
+	[BULK_IN_SPEED_FS]		= {7, 0x00, 0x00, 0x03, 0x3F},
+};
+
+static const struct ax_bulkin_settings AX88772D_BULKIN_SIZE[] = {
+	[BULK_IN_SPEED_100_FULL_HS]	= {5, 0xC0, 0x04, 0x06, 0x0F},
+	[BULK_IN_SPEED_100_HALF_HS]	= {7, 0xC0, 0x04, 0x06, 0x0F},
+	[BULK_IN_SPEED_FS]		= {7, 0x00, 0x00, 0x03, 0x3F},
+};
+
+static const struct ax_bulkin_settings AX88279_BULKIN_SIZE[] = {
+	[BULK_IN_SPEED_2G5]		= {5, 0x10, 0x01, 0x11, 0x0F},
+	[BULK_IN_SPEED_1G_SS]		= {7, 0xB3, 0x01, 0x11, 0x0F},
+	[BULK_IN_SPEED_1G_HS]		= {7, 0xC0, 0x02, 0x06, 0x0F},
+	[BULK_IN_SPEED_100_FULL_SS]	= {7, 0x80, 0x01, 0x03, 0x0F},
+	[BULK_IN_SPEED_100_HALF_SS]	= {7, 0x80, 0x01, 0x03, 0x0F},
+	[BULK_IN_SPEED_100_FULL_HS]	= {7, 0x80, 0x01, 0x03, 0x0F},
+	[BULK_IN_SPEED_100_HALF_HS]	= {7, 0x80, 0x01, 0x03, 0x0F},
+	[BULK_IN_SPEED_FS]		= {7, 0x00, 0x00, 0x03, 0x3F},
+};
+
+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;
+
+	return ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)regnum, 2, &val);
+}
+
+static int ax179a_read_mmd(struct usbnet *dev, u16 dev_addr, u16 reg)
+{
+	u16 res;
+	int ret;
+
+	ret = ax88179_read_cmd(dev, AX88179A_PHY_CLAUSE45, dev_addr, reg, 2, &res);
+	if (ret < 0)
+		return ret;
+	return res;
+}
+
+static int ax179a_write_mmd(struct usbnet *dev, u16 dev_addr, u16 reg, u16 data)
+{
+	return ax88179_write_cmd(dev, AX88179A_PHY_CLAUSE45, dev_addr, reg, 2, &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 ax179a_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 ax179a_write_mmd(dev, devnum, regnum, val);
+}
+
+static void ax88179a_status(struct usbnet *dev, struct urb *urb)
+{
+	struct ax88179_data *data = dev->driver_priv;
+	struct ax88179_int_data *event;
+	u32 link;
+
+	if (urb->actual_length < 8)
+		return;
+
+	event = urb->transfer_buffer;
+	le32_to_cpus((void *)&event->intdata1);
+
+	link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16;
+
+	if (netif_carrier_ok(dev->net) != link) {
+		usbnet_link_change(dev, link, 1);
+		phylink_mac_interrupt(data->phylink);
+	}
+}
+
+static int ax88179a_suspend(struct usb_interface *intf, pm_message_t message)
+{
+	struct usbnet *dev = usb_get_intfdata(intf);
+	struct ax88179_data *priv;
+	u16 tmp16;
+	u8 tmp8;
+
+	priv = dev->driver_priv;
+	ax88179_set_pm_mode(dev, true);
+
+	if (netif_running(dev->net)) {
+		rtnl_lock();
+		phylink_suspend(priv->phylink, !!priv->wolopts);
+		rtnl_unlock();
+	}
+
+	/* Enable WoL */
+	if (priv->wolopts) {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, &tmp8);
+		if (priv->wolopts & WAKE_PHY)
+			tmp8 |= AX_MONITOR_MODE_RWLC;
+		if (priv->wolopts & WAKE_MAGIC)
+			tmp8 |= AX_MONITOR_MODE_RWMP;
+
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, &tmp8);
+
+		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
+			ax88179_write_cmd(dev, AX88179A_WAKEUP_SETTING, 0,
+					  EPHY_LOW_POWER_EN, 0, NULL);
+
+	} else if (priv->chip_version == AX_VERSION_AX88279) {
+		ax88179_write_cmd(dev, AX88179A_WAKEUP_SETTING, 8, 0x8000, 0, NULL);
+	}
+
+	usbnet_suspend(intf, message);
+	ax88179_set_pm_mode(dev, false);
+	return 0;
+}
+
+static int ax88179a_auto_detach(struct usbnet *dev)
+{
+	u16 tmp16;
+
+	tmp16 = AX88179A_AUTODETACH_DELAY;
+	ax88179_write_cmd(dev, AX88179A_AUTODETACH, tmp16, 0, 0, NULL);
+	return 0;
+}
+
+static int ax88179a_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);
+
+	ax88179_read_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, &reg8);
+	if (!(reg8 & AX_PHY_POWER)) {
+		reg8 = AX_PHY_POWER;
+		ax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, &reg8);
+		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, &reg8);
+	msleep(250);
+
+	if (netif_running(dev->net)) {
+		rtnl_lock();
+		phylink_resume(ax179_data->phylink);
+		rtnl_unlock();
+	}
+
+	ax88179a_reset(dev);
+
+	ax88179_set_pm_mode(dev, false);
+
+	return usbnet_resume(intf);
+}
+
+static void ax88179a_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
+{
+	struct ax88179_data *priv = netdev2data(net);
+
+	/* 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 ax88179a_bulkin_config(struct usbnet *dev, u8 link_sts, u8 speed, bool full_duplex)
+{
+	struct ax88179_data *ax179_data = dev->driver_priv;
+	const struct ax_bulkin_settings *bulkin_data;
+	int index = 0;
+
+	switch (speed) {
+	case ETHER_LINK_2500:	/* AX88279 only */
+		index = BULK_IN_SPEED_2G5;
+		break;
+
+	case ETHER_LINK_1000:	/* AX88279 & AX88178A */
+		if (link_sts & AX_USB_SS)
+			index = BULK_IN_SPEED_1G_SS;
+		else if (link_sts & AX_USB_HS)
+			index = BULK_IN_SPEED_1G_HS;
+		break;
+
+	case ETHER_LINK_100:
+		if (link_sts & AX_USB_SS)
+			index = BULK_IN_SPEED_100_FULL_SS;
+		else if (link_sts & AX_USB_HS)
+			index = BULK_IN_SPEED_100_FULL_HS;
+		if (!full_duplex)
+			index++;
+		break;
+
+	case ETHER_LINK_10:
+		index = BULK_IN_SPEED_FS;
+		break;
+
+	default:	/* No link */
+		index = BULK_IN_SPEED_FS;
+	}
+
+	if (ax179_data->chip_version == AX_VERSION_AX88279 && (link_sts & AX_USB_FS))
+		index = BULK_IN_SPEED_FS;
+
+	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_get_pauseparam(struct net_device *net, struct ethtool_pauseparam *pause)
+{
+	struct ax88179_data *data = netdev2data(net);
+
+	phylink_ethtool_get_pauseparam(data->phylink, pause);
+}
+
+static int ax88179a_set_pauseparam(struct net_device *net, struct ethtool_pauseparam *pause)
+{
+	struct ax88179_data *data = netdev2data(net);
+
+	return phylink_ethtool_set_pauseparam(data->phylink, pause);
+}
+
+static int ax88179a_get_eeprom_len(struct net_device *net)
+{
+	struct ax88179_data *ax179_data = netdev2data(net);
+
+	if (ax179_data->chip_version >= AX_VERSION_AX88279)
+		return AX88279_EEPROM_LEN;
+	else
+		return AX88179A_EEPROM_LEN;
+}
+
+static int ax88179a_get_eee(struct net_device *net, struct ethtool_keee *edata)
+{
+	struct ax88179_data *ax179_data = netdev2data(net);
+
+	return phylink_ethtool_get_eee(ax179_data->phylink, edata);
+}
+
+static int ax88179a_set_eee(struct net_device *net, struct ethtool_keee *edata)
+{
+	struct ax88179_data *ax179_data = netdev2data(net);
+
+	return phylink_ethtool_set_eee(ax179_data->phylink, edata);
+}
+
+static const struct ethtool_ops ax88179a_ethtool_ops = {
+	.get_drvinfo            = ax88179a_get_drvinfo,
+	.get_link		= ethtool_op_get_link,
+	.get_msglevel		= usbnet_get_msglevel,
+	.set_msglevel		= usbnet_set_msglevel,
+	.get_wol		= ax88179_get_wol,
+	.set_wol		= ax88179_set_wol,
+	.get_eeprom_len		= ax88179a_get_eeprom_len,
+	.get_eeprom		= ax88179_get_eeprom,
+	.set_eeprom		= ax88179_set_eeprom,
+	.get_eee		= ax88179a_get_eee,
+	.set_eee		= ax88179a_set_eee,
+	.nway_reset		= usbnet_nway_reset,
+	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
+	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
+	.get_pauseparam		= ax88179a_get_pauseparam,
+	.set_pauseparam		= ax88179a_set_pauseparam,
+	.get_ts_info		= ethtool_op_get_ts_info,
+};
+
+static int ax88179a_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, &reg8);
+	vlan_ctrl = reg8;
+
+	/* Address */
+	reg8 = (vid / 16);
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_ADDRESS, 1, 1, &reg8);
+
+	/* Data */
+	reg8 = vlan_ctrl | AX_VLAN_CONTROL_RD;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &reg8);
+
+	ax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, &reg16);
+	reg16 &= ~(1 << (vid % 16));
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, &reg16);
+
+	reg8 = vlan_ctrl | AX_VLAN_CONTROL_WE;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &reg8);
+
+	return 0;
+}
+
+static int ax88179a_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, &reg8);
+	vlan_ctrl = reg8;
+
+	/* Address */
+	reg8 = (vid / 16);
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_ADDRESS, 1, 1, &reg8);
+
+	/* Data */
+	reg8 = vlan_ctrl | AX_VLAN_CONTROL_RD;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &reg8);
+
+	ax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, &reg16);
+	reg16 |= (1 << (vid % 16));
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, &reg16);
+
+	reg8 = vlan_ctrl | AX_VLAN_CONTROL_WE;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &reg8);
+
+	return 0;
+}
+
+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;
+	}
+
+	data->phydev->irq = PHY_MAC_INTERRUPT;
+	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];
+	u8 bulk_config_speed = 0;
+	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;
+	if (tx_pause)
+		mode |= AX_MEDIUM_TXFLOW_CTRLEN;
+	if (rx_pause)
+		mode |= 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;
+		bulk_config_speed = ETHER_LINK_2500;
+
+		break;
+
+	case SPEED_1000:
+		mode |= AX_MEDIUM_GIGAMODE;
+		bulk_config_speed = ETHER_LINK_1000;
+		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);
+		if (!bulk_config_speed)
+			bulk_config_speed = ETHER_LINK_100;
+		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);
+
+		bulk_config_speed = ETHER_LINK_10;
+		break;
+	}
+
+	ax88179_read_cmd(dev, AX_ACCESS_MAC, PHYSICAL_LINK_STATUS, 1, 1, &link_sts);
+	ax88179a_bulkin_config(dev, link_sts, bulk_config_speed, !!duplex);
+
+	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);
+}
+
+static void ax88179a_mac_disable_tx_lpi(struct phylink_config *config)
+{
+	struct usbnet *dev = netdev_priv(to_net_dev(config->dev));
+
+	ax88179_write_cmd(dev, AX_GPHY_CTL, AX_GPHY_EEE_CTRL, false, 0, NULL);
+}
+
+static int ax88179a_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, bool tx_clk_stop)
+{
+	struct usbnet *dev = netdev_priv(to_net_dev(config->dev));
+
+	/* AX88179A does not provide LPI timer registers */
+	return ax88179_write_cmd(dev, AX_GPHY_CTL, AX_GPHY_EEE_CTRL, true, 0, NULL);
+}
+
+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,
+	.mac_disable_tx_lpi = ax88179a_mac_disable_tx_lpi,
+	.mac_enable_tx_lpi = ax88179a_mac_enable_tx_lpi,
+};
+
+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;
+
+	if (!data->is_ax88772d) {
+		data->phylink_config.lpi_capabilities = MAC_100FD | MAC_1000FD;
+		data->phylink_config.eee_enabled_default = false;
+	}
+
+	if (data->chip_version == AX_VERSION_AX88279) {
+		__set_bit(PHY_INTERFACE_MODE_2500BASEX,
+			  data->phylink_config.supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_SGMII,
+			  data->phylink_config.supported_interfaces);
+		phy_if_mode = PHY_INTERFACE_MODE_2500BASEX;
+	} else {
+		__set_bit(PHY_INTERFACE_MODE_SGMII,
+			  data->phylink_config.supported_interfaces);
+		phy_if_mode = PHY_INTERFACE_MODE_SGMII;
+	}
+
+	memcpy(data->phylink_config.lpi_interfaces,
+	       data->phylink_config.supported_interfaces,
+	       sizeof(data->phylink_config.lpi_interfaces));
+
+	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);
+
+	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_set_features(struct net_device *net, netdev_features_t features)
+{
+	struct usbnet *dev = netdev_priv(net);
+	netdev_features_t changed;
+	int ret;
+	u8 tmp;
+
+	changed = net->features ^ features;
+
+	ret = ax88179_set_features(net, features);
+	if (ret)
+		return ret;
+
+	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;
+}
+
+static const struct net_device_ops ax88179a_netdev_ops = {
+	.ndo_open		= usbnet_open,
+	.ndo_stop		= usbnet_stop,
+	.ndo_start_xmit		= usbnet_start_xmit,
+	.ndo_tx_timeout		= usbnet_tx_timeout,
+	.ndo_get_stats64	= dev_get_tstats64,
+	.ndo_change_mtu		= ax88179_change_mtu,
+	.ndo_set_mac_address	= ax88179_set_mac_addr,
+	.ndo_validate_addr	= eth_validate_addr,
+	.ndo_eth_ioctl		= usbnet_mii_ioctl,
+	.ndo_set_rx_mode	= ax88179_set_multicast,
+	.ndo_set_features	= ax88179a_set_features,
+	.ndo_vlan_rx_add_vid	= ax88179a_vlan_rx_add_vid,
+	.ndo_vlan_rx_kill_vid	= ax88179a_vlan_rx_kill_vid,
+};
+
+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_write_cmd = AX88179A_FLASH_WRITE;
+		ax179_data->eeprom_block = 256;
+		ax179_data->eeprom_wen = 1;
+	} else {
+		ax179_data->ip_align = 0;
+		ax179_data->eeprom_read_cmd = AX_ACCESS_EFUS;
+		ax179_data->eeprom_write_cmd = AX_ACCESS_EFUS;
+		ax179_data->eeprom_block = 20;
+		ax179_data->eeprom_wen = 0;
+	}
+
+	ax179_data->resume = ax88179a_resume;
+	ax179_data->suspend = ax88179a_suspend;
+
+	dev->net->netdev_ops = &ax88179a_netdev_ops;
+	dev->net->ethtool_ops = &ax88179a_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;
+
+	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, &reg8);
+	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 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 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 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 *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 ax88179a_reset(struct usbnet *dev)
+{
+	struct ax88179_data *ax179_data = dev->driver_priv;
+	u16 *tmp16;
+	u8 buf[5];
+	u8 *tmp;
+
+	tmp16 = (u16 *)buf;
+	tmp = (u8 *)buf;
+
+	/* Power up ethernet PHY */
+	*tmp = AX_PHY_POWER;
+	ax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, tmp);
+	msleep(250);
+
+	/* Ethernet PHY Auto Detach*/
+	ax88179a_auto_detach(dev);
+
+	*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);
+
+	/* The Bulk-Register configuration for the AX88179A is done in
+	 * ax88179a_mac_link_up(), 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 */
+	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;
+	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;
+	if (ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD,
+			     1, 1, &tmp) > 0)
+		ax179_data->wol_supported = WAKE_MAGIC | WAKE_PHY;
+
+	/* ax88179a_reset() may also be called from resume context, phylink
+	 * is already started, then.
+	 */
+	if (!ax179_data->in_pm)
+		phylink_start(ax179_data->phylink);
+
+	usbnet_link_change(dev, 0, 0);
+
+	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, &reg16);
+	reg16 &= ~AX_MEDIUM_RECEIVE_EN;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, &reg16);
+
+	reg16 = 0;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &reg16);
+
+	reg8 = 0;
+	ax88179_read_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, &reg8);
+
+	phylink_stop(ax179_data->phylink);
+
+	return 0;
+}
+
+const struct driver_info ax88179a_info = {
+	.description = "ASIX AX88179A USB 3.2 Gigabit Ethernet",
+	.bind = ax88179a_bind,
+	.unbind = ax88179a_unbind,
+	.status = ax88179a_status,
+	.reset = ax88179a_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,
+};
+
+const struct driver_info ax88772d_info = {
+	.description = "ASIX AX88772D/E USB 2.0 Fast Ethernet",
+	.bind = ax88179a_bind,
+	.unbind = ax88179a_unbind,
+	.status = ax88179a_status,
+	.reset = ax88179a_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,
+};
+
+const struct driver_info ax88279_info = {
+	.description = "ASIX AX88279 USB 3.2 2.5Gigabit Ethernet",
+	.bind = ax88179a_bind,
+	.unbind = ax88179a_unbind,
+	.status = ax88179a_status,
+	.reset = ax88179a_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,
+};
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 2bc0db3d52ac8..21f960a827b6f 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -768,6 +768,7 @@ int phylink_ethtool_set_eee(struct phylink *link, struct ethtool_keee *eee);
 int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);
 int phylink_speed_down(struct phylink *pl, bool sync);
 int phylink_speed_up(struct phylink *pl);
+void phylink_mac_interrupt(struct phylink *pl);
 
 #define phylink_zero(bm) \
 	bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS)

3/2 2026/08/10 13:58 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 48325
							output: 445
							thoughts: 1939
						

Thoughts:
**Fuzzing Target Identification: ASIX AX88179/A USB Ethernet Driver**

Okay, so we have a patch that adds support for ASIX AX88179A, AX88279, and AX88772D/E USB Ethernet adapters. The code's been reorganized, splitting `ax88179_178a.c` into multiple files. It's a USB network driver, so it's good for fuzzing, especially given that we can emulate USB devices in syzkaller.

First things first, let's verify the configuration options required. It looks like `CONFIG_USB_NET_AX88179` is the main one. I needed to double-check because the name seems to have changed from the older `USB_NET_AX88179_178A`. Looking into `drivers/net/usb/Kconfig`, I confirm `USB_NET_AX88179`, which also selects `PHYLINK` and `AX88796B_PHY`. This means we'll also need `CONFIG_AX88796B_PHY` as it is selected by `AX88796B_PHY`. Finally, `USB_USBNET` is a dependency, so we're going to need `CONFIG_USB_USBNET`.

Now, the crucial step – identifying the functions we'll want to focus on for fuzzing. We have new code in `ax88179a_devices.c` and `ax88179_lib.c`, so that's where we'll start. And the phy changes also need attention.

In `ax88179a_devices.c`, even though many are static, several are assigned to ops structures, so we will still consider those for fuzzing. These include: `ax88179a_bind`, `ax88179a_rx_fixup`, `ax88179a_tx_fixup`, `ax88179a_reset`, `ax88179a_set_features`, `ax88179a_vlan_rx_add_vid`, `ax88179a_vlan_rx_kill_vid`, `ax88179a_mac_link_up`, `ax88179a_suspend`, and `ax88179a_resume`.

The code in `ax88179_lib.c` contains functions that aren't static, so are automatically considered for the focus list: `ax88179_read_cmd`, `ax88179_write_cmd`, `ax88179_status`, `ax88179_mdio_read`, `ax88179_mdio_write`, `ax88179_get_wol`, `ax88179_set_wol`, `ax88179_get_eeprom`, `ax88179_set_eeprom`, `ax88179_set_multicast`, `ax88179_set_features`, `ax88179_get_mac_addr`, `ax88179_change_mtu`, `ax88179_set_mac_addr`, `ax88179_suspend_wrapper`, and `ax88179_resume_wrapper`.

Finally, from `ax88796b.c`, we'll focus on the PHY-related functions: `asix_ax88279_read_status`, `asix_ax88279_config_aneg`, `asix_ax88279_get_features`, `asix_ax88279_config_init`, `asix_read_mmd`, `asix_write_mmd`, and `asix_ax88772D_get_features`.

I'll double-check `CONFIG_USB_NET_AX88179` and then the target is ready for fuzzing.



4/2 2026/08/10 13:58 tool set-results
0m Args:
{
  "EnableConfigs": [
    "USB_NET_AX88179",
    "AX88796B_PHY"
  ],
  "FocusSymbols": [
    "ax88179a_bind",
    "ax88179a_rx_fixup",
    "ax88179a_tx_fixup",
    "ax88179a_reset",
    "ax88179a_set_features",
    "ax88179a_vlan_rx_add_vid",
    "ax88179a_vlan_rx_kill_vid",
    "ax88179a_mac_link_up",
    "ax88179_read_cmd",
    "ax88179_write_cmd",
    "ax88179_set_eeprom",
    "ax88179_get_eeprom",
    "ax88179_set_features",
    "ax88179_change_mtu",
    "asix_ax88279_read_status",
    "asix_ax88279_config_aneg",
    "asix_ax88279_get_features",
    "asix_ax88279_config_init",
    "asix_read_mmd",
    "asix_write_mmd",
    "asix_ax88772D_get_features"
  ],
  "Reasoning": "The patch adds support for ASIX AX88179A, AX88279, and AX88772D/E USB Ethernet adapters. It splits the existing driver into a library and device-specific files, and adds new PHY drivers. USB devices can be emulated in virtualized environments using the USB gadget subsystem (dummy_hcd), making this code reachable and worth fuzzing.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "USB_NET_AX88179",
    "AX88796B_PHY"
  ],
  "FocusSymbols": [
    "ax88179a_bind",
    "ax88179a_rx_fixup",
    "ax88179a_tx_fixup",
    "ax88179a_reset",
    "ax88179a_set_features",
    "ax88179a_vlan_rx_add_vid",
    "ax88179a_vlan_rx_kill_vid",
    "ax88179a_mac_link_up",
    "ax88179_read_cmd",
    "ax88179_write_cmd",
    "ax88179_set_eeprom",
    "ax88179_get_eeprom",
    "ax88179_set_features",
    "ax88179_change_mtu",
    "asix_ax88279_read_status",
    "asix_ax88279_config_aneg",
    "asix_ax88279_get_features",
    "asix_ax88279_config_init",
    "asix_read_mmd",
    "asix_write_mmd",
    "asix_ax88772D_get_features"
  ],
  "Reasoning": "The patch adds support for ASIX AX88179A, AX88279, and AX88772D/E USB Ethernet adapters. It splits the existing driver into a library and device-specific files, and adds new PHY drivers. USB devices can be emulated in virtualized environments using the USB gadget subsystem (dummy_hcd), making this code reachable and worth fuzzing.",
  "WorthFuzzing": true
}

5/1 2026/08/10 13:58 action If
16m Args:
{
  "WorthFuzzing": true
}

Results:
null

6/2 2026/08/10 13:58 agent kmsan-evaluator
16m Model:
best-expensive

Args:
null

Results:
{
  "KMSANReasoning": "The patch introduces several new functions in `ax88179a_devices.c` that read 1-byte registers from the USB device using `ax88179_read_cmd(..., size=1, \u0026var)`. If the USB control message fails (e.g., due to a device error or disconnect), `ax88179_read_cmd` returns an error code but leaves the 1-byte local variable uninitialized.\n\nThe code then proceeds to use these uninitialized variables without checking the return value of `ax88179_read_cmd`. Examples include:\n1. `ax88179a_mac_link_up()`: reads into `link_sts` and passes it to `ax88179a_bulkin_config()`, which branches on `link_sts \u0026 AX_USB_SS`.\n2. `ax88179a_resume()`: reads into `reg8` and branches on `!(reg8 \u0026 AX_PHY_POWER)`.\n3. `ax88179a_set_features()`: reads into `tmp`, XORs it, and writes it back to the device.\n4. `ax88179a_vlan_rx_kill_vid()` / `ax88179a_vlan_rx_add_vid()`: reads into `reg8`, assigns to `vlan_ctrl`, and writes it back.\n5. `ax88179a_suspend()`: reads into `tmp8`, modifies it, and writes it back.\n\nThese are classic uninitialized memory uses (branching on uninitialized values and writing uninitialized stack memory to the device). KASAN cannot detect these because they are not out-of-bounds accesses or use-after-frees. Only KMSAN tracks the initialization state of stack variables and can catch these bugs. Therefore, a dedicated KMSAN fuzzing session is highly justified.",
  "NeedsKMSAN": true
}

Instruction:
You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.

CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
  a comprehensive suite of debugging tools and sanitizers, including KASAN
  (out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
  (locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
  or page allocations) and kernel-to-user memory info-leaks.

Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.

Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.

Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
   attributes, ioctl output arguments, socket options, or BPF buffers) where fields
   or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
   or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
   could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
   uninitialized bytes of existing buffers.

Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
  dereferences, locking deadlocks, or use-after-free bugs (these are already caught
  by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
  or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.

Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
For your convenience, here is the diff of the changes:
commit 5440b5325da5dcdfedc4cd25fb52b0c4e64c4c81
Author: syz-cluster <triage@syzkaller.com>
Date:   Mon Aug 10 13:58:33 2026 +0000

    syz-cluster: applied patch under review

diff --git a/MAINTAINERS b/MAINTAINERS
index 15011f5752a99..d43d58b417e58 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3987,6 +3987,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/net/asix,ax88796c.yaml
 F:	drivers/net/ethernet/asix/ax88796c_*
 
+ASIX AX88179 USB ETHERNET DRIVER
+M:	Birger Koblitz <mail@birger-koblitz.de>
+L:	netdev@vger.kernel.org
+S:	Maintained
+F:	drivers/net/usb/ax88179*
+
 ASIX PHY DRIVER [RUST]
 M:	FUJITA Tomonori <fujita.tomonori@gmail.com>
 R:	Trevor Gross <tmgross@umich.edu>
diff --git a/drivers/net/phy/ax88796b.c b/drivers/net/phy/ax88796b.c
index f20ddf6491499..1298e46ad9e16 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,122 @@ 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_read_status(phydev);
+	if (ret)
+		return ret;
+
+	/* 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;
+
+	/* PHY switches interface between 2.5GBit and slower modes */
+	if (phydev->speed == SPEED_2500)
+		phydev->interface = PHY_INTERFACE_MODE_2500BASEX;
+	else
+		phydev->interface = PHY_INTERFACE_MODE_SGMII;
+
+	return 0;
+}
+
+static int asix_ax88279_config_aneg(struct phy_device *phydev)
+{
+	bool adv_2500;
+	int ret;
+
+	if (phydev->autoneg == AUTONEG_DISABLE) {
+		phydev_warn(phydev, "Disabling autoneg is not supported\n");
+		return -EOPNOTSUPP;
+	}
+
+	ret = genphy_config_aneg(phydev);
+
+	if (ret < 0)
+		return ret;
+
+	adv_2500 = linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising);
+	ret = phy_modify(phydev, MII_ADVERTISE, AX_ADVERTISE_2500,
+			 adv_2500 ? AX_ADVERTISE_2500 : 0);
+
+	return ret;
+}
+
+static int asix_ax88279_get_features(struct phy_device *phydev)
+{
+	int ret;
+
+	/* 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_clear_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, phydev->supported);
+
+	return 0;
+}
+
+static int asix_ax88279_config_init(struct phy_device *phydev)
+{
+	__set_bit(PHY_INTERFACE_MODE_2500BASEX, phydev->possible_interfaces);
+	__set_bit(PHY_INTERFACE_MODE_SGMII, phydev->possible_interfaces);
+
+	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 +223,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 +259,35 @@ 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,
+	.config_init	= asix_ax88279_config_init,
+	.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 +301,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) },
 	{ }
 };
 
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 087ac63f9193d..2ba1d76872a23 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1612,6 +1612,22 @@ static bool phylink_link_is_up(struct phylink *pl)
 	return pl->netdev ? netif_carrier_ok(pl->netdev) : pl->old_link_state;
 }
 
+/**
+ * phylink_mac_interrupt() - wrapper for phy_mac_interrupt()
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
+ *
+ * Passes a link-change interrupt received by the MAC to phylib.
+ */
+void phylink_mac_interrupt(struct phylink *pl)
+{
+	struct phy_device *phy;
+
+	phy = pl->phydev;
+	if (phy)
+		phy_mac_interrupt(phy);
+}
+EXPORT_SYMBOL_GPL(phylink_mac_interrupt);
+
 static void phylink_resolve(struct work_struct *w)
 {
 	struct phylink *pl = container_of(w, struct phylink, resolve);
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index 52a5c0922c79f..4158455a2da76 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -195,11 +195,12 @@ config USB_NET_AX8817X
 	  This driver creates an interface named "ethX", where X depends on
 	  what other networking devices you have in use.
 
-config USB_NET_AX88179_178A
-	tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet"
+config USB_NET_AX88179
+	tristate "ASIX AX88179/179A/178A USB 3.0/2.0 to Gigabit Ethernet"
 	depends on USB_USBNET
+	select PHYLINK
+	select AX88796B_PHY
 	select CRC32
-	select PHYLIB
 	default y
 	help
 	  This option adds support for ASIX AX88179 based USB 3.0/2.0
@@ -207,6 +208,9 @@ config USB_NET_AX88179_178A
 
 	  This driver should work with at least the following devices:
 	    * ASIX AX88179
+	    * ASIX AX88179A/B
+	    * ASIX AX88279
+	    * ASIX AX88772D/E
 	    * ASIX AX88178A
 	    * Sitcomm LN-032
 
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 4964f7b326fbc..4026f19ecb826 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -12,7 +12,8 @@ obj-$(CONFIG_USB_HSO)		+= hso.o
 obj-$(CONFIG_USB_LAN78XX)	+= lan78xx.o
 obj-$(CONFIG_USB_NET_AX8817X)	+= asix.o
 asix-y := asix_devices.o asix_common.o ax88172a.o
-obj-$(CONFIG_USB_NET_AX88179_178A)      += ax88179_178a.o
+obj-$(CONFIG_USB_NET_AX88179)      += ax88179.o
+ax88179-y := ax88179_178a.o ax88179a_devices.o ax88179_lib.o
 obj-$(CONFIG_USB_NET_CDCETHER)	+= cdc_ether.o
 obj-$(CONFIG_USB_NET_CDC_EEM)	+= cdc_eem.o
 obj-$(CONFIG_USB_NET_DM9601)	+= dm9601.o
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 98f899ea2e946..be72ed955b6b8 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -8,179 +8,12 @@
 #include <linux/module.h>
 #include <linux/etherdevice.h>
 #include <linux/mii.h>
-#include <linux/usb.h>
-#include <linux/crc32.h>
-#include <linux/usb/usbnet.h>
 #include <uapi/linux/mdio.h>
 #include <linux/mdio.h>
-
-#define AX88179_PHY_ID				0x03
-#define AX_EEPROM_LEN				0x100
-#define AX88179_EEPROM_MAGIC			0x17900b95
-#define AX_MCAST_FLTSIZE			8
-#define AX_MAX_MCAST				64
-#define AX_INT_PPLS_LINK			((u32)BIT(16))
-#define AX_RXHDR_L4_TYPE_MASK			0x1c
-#define AX_RXHDR_L4_TYPE_UDP			4
-#define AX_RXHDR_L4_TYPE_TCP			16
-#define AX_RXHDR_L3CSUM_ERR			2
-#define AX_RXHDR_L4CSUM_ERR			1
-#define AX_RXHDR_CRC_ERR			((u32)BIT(29))
-#define AX_RXHDR_DROP_ERR			((u32)BIT(31))
-#define AX_ACCESS_MAC				0x01
-#define AX_ACCESS_PHY				0x02
-#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 PHYSICAL_LINK_STATUS			0x02
-	#define	AX_USB_SS		0x04
-	#define	AX_USB_HS		0x02
-
-#define GENERAL_STATUS				0x03
-/* Check AX88179 version. UA1:Bit2 = 0,  UA2:Bit2 = 1 */
-	#define	AX_SECLD		0x04
-
-#define AX_SROM_ADDR				0x07
-#define AX_SROM_CMD				0x0a
-	#define EEP_RD			0x04
-	#define EEP_BUSY		0x10
-
-#define AX_SROM_DATA_LOW			0x08
-#define AX_SROM_DATA_HIGH			0x09
-
-#define AX_RX_CTL				0x0b
-	#define AX_RX_CTL_DROPCRCERR	0x0100
-	#define AX_RX_CTL_IPE		0x0200
-	#define AX_RX_CTL_START		0x0080
-	#define AX_RX_CTL_AP		0x0020
-	#define AX_RX_CTL_AM		0x0010
-	#define AX_RX_CTL_AB		0x0008
-	#define AX_RX_CTL_AMALL		0x0002
-	#define AX_RX_CTL_PRO		0x0001
-	#define AX_RX_CTL_STOP		0x0000
-
-#define AX_NODE_ID				0x10
-#define AX_MULFLTARY				0x16
-
-#define AX_MEDIUM_STATUS_MODE			0x22
-	#define AX_MEDIUM_GIGAMODE	0x01
-	#define AX_MEDIUM_FULL_DUPLEX	0x02
-	#define AX_MEDIUM_EN_125MHZ	0x08
-	#define AX_MEDIUM_RXFLOW_CTRLEN	0x10
-	#define AX_MEDIUM_TXFLOW_CTRLEN	0x20
-	#define AX_MEDIUM_RECEIVE_EN	0x100
-	#define AX_MEDIUM_PS		0x200
-	#define AX_MEDIUM_JUMBO_EN	0x8040
-
-#define AX_MONITOR_MOD				0x24
-	#define AX_MONITOR_MODE_RWLC	0x02
-	#define AX_MONITOR_MODE_RWMP	0x04
-	#define AX_MONITOR_MODE_PMEPOL	0x20
-	#define AX_MONITOR_MODE_PMETYPE	0x40
-
-#define AX_GPIO_CTRL				0x25
-	#define AX_GPIO_CTRL_GPIO3EN	0x80
-	#define AX_GPIO_CTRL_GPIO2EN	0x40
-	#define AX_GPIO_CTRL_GPIO1EN	0x20
-
-#define AX_PHYPWR_RSTCTL			0x26
-	#define AX_PHYPWR_RSTCTL_BZ	0x0010
-	#define AX_PHYPWR_RSTCTL_IPRL	0x0020
-	#define AX_PHYPWR_RSTCTL_AT	0x1000
-
-#define AX_RX_BULKIN_QCTRL			0x2e
-#define AX_CLK_SELECT				0x33
-	#define AX_CLK_SELECT_BCS	0x01
-	#define AX_CLK_SELECT_ACS	0x02
-	#define AX_CLK_SELECT_ULR	0x08
-
-#define AX_RXCOE_CTL				0x34
-	#define AX_RXCOE_IP		0x01
-	#define AX_RXCOE_TCP		0x02
-	#define AX_RXCOE_UDP		0x04
-	#define AX_RXCOE_TCPV6		0x20
-	#define AX_RXCOE_UDPV6		0x40
-
-#define AX_TXCOE_CTL				0x35
-	#define AX_TXCOE_IP		0x01
-	#define AX_TXCOE_TCP		0x02
-	#define AX_TXCOE_UDP		0x04
-	#define AX_TXCOE_TCPV6		0x20
-	#define AX_TXCOE_UDPV6		0x40
-
-#define AX_LEDCTRL				0x73
-
-#define GMII_PHY_PHYSR				0x11
-	#define GMII_PHY_PHYSR_SMASK	0xc000
-	#define GMII_PHY_PHYSR_GIGA	0x8000
-	#define GMII_PHY_PHYSR_100	0x4000
-	#define GMII_PHY_PHYSR_FULL	0x2000
-	#define GMII_PHY_PHYSR_LINK	0x400
-
-#define GMII_LED_ACT				0x1a
-	#define	GMII_LED_ACTIVE_MASK	0xff8f
-	#define	GMII_LED0_ACTIVE	BIT(4)
-	#define	GMII_LED1_ACTIVE	BIT(5)
-	#define	GMII_LED2_ACTIVE	BIT(6)
-
-#define GMII_LED_LINK				0x1c
-	#define	GMII_LED_LINK_MASK	0xf888
-	#define	GMII_LED0_LINK_10	BIT(0)
-	#define	GMII_LED0_LINK_100	BIT(1)
-	#define	GMII_LED0_LINK_1000	BIT(2)
-	#define	GMII_LED1_LINK_10	BIT(4)
-	#define	GMII_LED1_LINK_100	BIT(5)
-	#define	GMII_LED1_LINK_1000	BIT(6)
-	#define	GMII_LED2_LINK_10	BIT(8)
-	#define	GMII_LED2_LINK_100	BIT(9)
-	#define	GMII_LED2_LINK_1000	BIT(10)
-	#define	LED0_ACTIVE		BIT(0)
-	#define	LED0_LINK_10		BIT(1)
-	#define	LED0_LINK_100		BIT(2)
-	#define	LED0_LINK_1000		BIT(3)
-	#define	LED0_FD			BIT(4)
-	#define	LED0_USB3_MASK		0x001f
-	#define	LED1_ACTIVE		BIT(5)
-	#define	LED1_LINK_10		BIT(6)
-	#define	LED1_LINK_100		BIT(7)
-	#define	LED1_LINK_1000		BIT(8)
-	#define	LED1_FD			BIT(9)
-	#define	LED1_USB3_MASK		0x03e0
-	#define	LED2_ACTIVE		BIT(10)
-	#define	LED2_LINK_1000		BIT(13)
-	#define	LED2_LINK_100		BIT(12)
-	#define	LED2_LINK_10		BIT(11)
-	#define	LED2_FD			BIT(14)
-	#define	LED_VALID		BIT(15)
-	#define	LED2_USB3_MASK		0x7c00
-
-#define GMII_PHYPAGE				0x1e
-#define GMII_PHY_PAGE_SELECT			0x1f
-	#define GMII_PHY_PGSEL_EXT	0x0007
-	#define GMII_PHY_PGSEL_PAGE0	0x0000
-	#define GMII_PHY_PGSEL_PAGE3	0x0003
-	#define GMII_PHY_PGSEL_PAGE5	0x0005
+#include "ax88179_lib.h"
 
 static int ax88179_reset(struct usbnet *dev);
 
-struct ax88179_data {
-	u8  eee_enabled;
-	u8  eee_active;
-	u16 rxctl;
-	u8 in_pm;
-	u32 wol_supported;
-	u32 wolopts;
-	u8 disconnecting;
-};
-
-struct ax88179_int_data {
-	__le32 intdata1;
-	__le32 intdata2;
-};
-
 static const struct {
 	unsigned char ctrl, timer_l, timer_h, size, ifg;
 } AX88179_BULKIN_SIZE[] =	{
@@ -190,165 +23,6 @@ static const struct {
 	{7, 0xcc, 0x4c, 0x18, 8},
 };
 
-static void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode)
-{
-	struct ax88179_data *ax179_data = dev->driver_priv;
-
-	ax179_data->in_pm = pm_mode;
-}
-
-static int ax88179_in_pm(struct usbnet *dev)
-{
-	struct ax88179_data *ax179_data = dev->driver_priv;
-
-	return ax179_data->in_pm;
-}
-
-static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
-			      u16 size, void *data)
-{
-	int ret;
-	int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16);
-	struct ax88179_data *ax179_data = dev->driver_priv;
-
-	BUG_ON(!dev);
-
-	if (!ax88179_in_pm(dev))
-		fn = usbnet_read_cmd;
-	else
-		fn = usbnet_read_cmd_nopm;
-
-	ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-		 value, index, data, size);
-
-	if (unlikely((ret < 0) && !(ret == -ENODEV && ax179_data->disconnecting)))
-		netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n",
-			    index, ret);
-
-	return ret;
-}
-
-static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
-			       u16 size, const void *data)
-{
-	int ret;
-	int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16);
-	struct ax88179_data *ax179_data = dev->driver_priv;
-
-	BUG_ON(!dev);
-
-	if (!ax88179_in_pm(dev))
-		fn = usbnet_write_cmd;
-	else
-		fn = usbnet_write_cmd_nopm;
-
-	ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-		 value, index, data, size);
-
-	if (unlikely((ret < 0) && !(ret == -ENODEV && ax179_data->disconnecting)))
-		netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n",
-			    index, ret);
-
-	return ret;
-}
-
-static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value,
-				    u16 index, u16 size, void *data)
-{
-	u16 buf;
-
-	if (2 == size) {
-		buf = *((u16 *)data);
-		cpu_to_le16s(&buf);
-		usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |
-				       USB_RECIP_DEVICE, value, index, &buf,
-				       size);
-	} else {
-		usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |
-				       USB_RECIP_DEVICE, value, index, data,
-				       size);
-	}
-}
-
-static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
-			    u16 size, void *data)
-{
-	int ret;
-
-	if (2 == size) {
-		u16 buf = 0;
-		ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf);
-		le16_to_cpus(&buf);
-		*((u16 *)data) = buf;
-	} else if (4 == size) {
-		u32 buf = 0;
-		ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf);
-		le32_to_cpus(&buf);
-		*((u32 *)data) = buf;
-	} else {
-		ret = __ax88179_read_cmd(dev, cmd, value, index, size, data);
-	}
-
-	return ret;
-}
-
-static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
-			     u16 size, const void *data)
-{
-	int ret;
-
-	if (2 == size) {
-		u16 buf;
-		buf = *((u16 *)data);
-		cpu_to_le16s(&buf);
-		ret = __ax88179_write_cmd(dev, cmd, value, index,
-					  size, &buf);
-	} else {
-		ret = __ax88179_write_cmd(dev, cmd, value, index,
-					  size, data);
-	}
-
-	return ret;
-}
-
-static void ax88179_status(struct usbnet *dev, struct urb *urb)
-{
-	struct ax88179_int_data *event;
-	u32 link;
-
-	if (urb->actual_length < 8)
-		return;
-
-	event = urb->transfer_buffer;
-	le32_to_cpus((void *)&event->intdata1);
-
-	link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16;
-
-	if (netif_carrier_ok(dev->net) != link) {
-		usbnet_link_change(dev, link, 1);
-		if (!link)
-			netdev_info(dev->net, "ax88179 - Link status is: 0\n");
-	}
-}
-
-static int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc)
-{
-	struct usbnet *dev = netdev_priv(netdev);
-	u16 res;
-
-	ax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res);
-	return res;
-}
-
-static void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc,
-			       int val)
-{
-	struct usbnet *dev = netdev_priv(netdev);
-	u16 res = (u16) val;
-
-	ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res);
-}
-
 static inline int ax88179_phy_mmd_indirect(struct usbnet *dev, u16 prtad,
 					   u16 devad)
 {
@@ -510,146 +184,11 @@ static void ax88179_disconnect(struct usb_interface *intf)
 	usbnet_disconnect(intf);
 }
 
-static void
-ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
-{
-	struct usbnet *dev = netdev_priv(net);
-	struct ax88179_data *priv = dev->driver_priv;
-
-	wolinfo->supported = priv->wol_supported;
-	wolinfo->wolopts = priv->wolopts;
-}
-
-static int
-ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
-{
-	struct usbnet *dev = netdev_priv(net);
-	struct ax88179_data *priv = dev->driver_priv;
-
-	if (wolinfo->wolopts & ~(priv->wol_supported))
-		return -EINVAL;
-
-	priv->wolopts = wolinfo->wolopts;
-
-	return 0;
-}
-
 static int ax88179_get_eeprom_len(struct net_device *net)
 {
 	return AX_EEPROM_LEN;
 }
 
-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;
-
-	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);
-	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]);
-		if (ret < 0) {
-			kfree(eeprom_buff);
-			return -EIO;
-		}
-	}
-
-	memcpy(data, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len);
-	kfree(eeprom_buff);
-	return 0;
-}
-
-static int
-ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
-		   u8 *data)
-{
-	struct usbnet *dev = netdev_priv(net);
-	u16 *eeprom_buff;
-	int first_word;
-	int last_word;
-	int ret;
-	int i;
-
-	netdev_dbg(net, "write EEPROM len %d, offset %d, magic 0x%x\n",
-		   eeprom->len, eeprom->offset, eeprom->magic);
-
-	if (eeprom->len == 0)
-		return -EINVAL;
-
-	if (eeprom->magic != AX88179_EEPROM_MAGIC)
-		return -EINVAL;
-
-	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);
-	if (!eeprom_buff)
-		return -ENOMEM;
-
-	/* align data to 16 bit boundaries, read the missing data from
-	   the EEPROM */
-	if (eeprom->offset & 1) {
-		ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, first_word, 1, 2,
-				       &eeprom_buff[0]);
-		if (ret < 0) {
-			netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", first_word);
-			goto free;
-		}
-	}
-
-	if ((eeprom->offset + eeprom->len) & 1) {
-		ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, last_word, 1, 2,
-				       &eeprom_buff[last_word - first_word]);
-		if (ret < 0) {
-			netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", last_word);
-			goto free;
-		}
-	}
-
-	memcpy((u8 *)eeprom_buff + (eeprom->offset & 1), data, eeprom->len);
-
-	for (i = first_word; i <= last_word; i++) {
-		netdev_dbg(net, "write to EEPROM at offset 0x%02x, data 0x%04x\n",
-			   i, eeprom_buff[i - first_word]);
-		ret = ax88179_write_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2,
-					&eeprom_buff[i - first_word]);
-		if (ret < 0) {
-			netdev_err(net, "Failed to write EEPROM at offset 0x%02x.\n", i);
-			goto free;
-		}
-		msleep(20);
-	}
-
-	/* reload EEPROM data */
-	ret = ax88179_write_cmd(dev, AX_RELOAD_EEPROM_EFUSE, 0x0000, 0, 0, NULL);
-	if (ret < 0) {
-		netdev_err(net, "Failed to reload EEPROM data\n");
-		goto free;
-	}
-
-	ret = 0;
-free:
-	kfree(eeprom_buff);
-	return ret;
-}
-
 static int ax88179_get_link_ksettings(struct net_device *net,
 				      struct ethtool_link_ksettings *cmd)
 {
@@ -864,125 +403,6 @@ static const struct ethtool_ops ax88179_ethtool_ops = {
 	.get_ts_info		= ethtool_op_get_ts_info,
 };
 
-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);
-
-	data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE);
-
-	if (net->flags & IFF_PROMISC) {
-		data->rxctl |= AX_RX_CTL_PRO;
-	} else if (net->flags & IFF_ALLMULTI ||
-		   netdev_mc_count(net) > AX_MAX_MCAST) {
-		data->rxctl |= AX_RX_CTL_AMALL;
-	} else if (netdev_mc_empty(net)) {
-		/* just broadcast and directed */
-	} else {
-		/* We use dev->data for our 8 byte filter buffer
-		 * to avoid allocating memory that is tricky to free later
-		 */
-		u32 crc_bits;
-		struct netdev_hw_addr *ha;
-
-		memset(m_filter, 0, AX_MCAST_FLTSIZE);
-
-		netdev_for_each_mc_addr(ha, net) {
-			crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
-			*(m_filter + (crc_bits >> 3)) |= (1 << (crc_bits & 7));
-		}
-
-		ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_MULFLTARY,
-					AX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE,
-					m_filter);
-
-		data->rxctl |= AX_RX_CTL_AM;
-	}
-
-	ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL,
-				2, 2, &data->rxctl);
-}
-
-static int
-ax88179_set_features(struct net_device *net, netdev_features_t features)
-{
-	u8 tmp;
-	struct usbnet *dev = netdev_priv(net);
-	netdev_features_t changed = net->features ^ features;
-
-	if (changed & NETIF_F_IP_CSUM) {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
-		tmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP;
-		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
-	}
-
-	if (changed & NETIF_F_IPV6_CSUM) {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
-		tmp ^= AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6;
-		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
-	}
-
-	if (changed & NETIF_F_RXCSUM) {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp);
-		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);
-	}
-
-	return 0;
-}
-
-static int ax88179_change_mtu(struct net_device *net, int new_mtu)
-{
-	struct usbnet *dev = netdev_priv(net);
-	u16 tmp16;
-
-	WRITE_ONCE(net->mtu, new_mtu);
-	dev->hard_mtu = net->mtu + net->hard_header_len;
-
-	if (net->mtu > 1500) {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
-				 2, 2, &tmp16);
-		tmp16 |= AX_MEDIUM_JUMBO_EN;
-		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
-				  2, 2, &tmp16);
-	} else {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
-				 2, 2, &tmp16);
-		tmp16 &= ~AX_MEDIUM_JUMBO_EN;
-		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
-				  2, 2, &tmp16);
-	}
-
-	/* max qlen depend on hard_mtu and rx_urb_size */
-	usbnet_update_max_qlen(dev);
-
-	return 0;
-}
-
-static int ax88179_set_mac_addr(struct net_device *net, void *p)
-{
-	struct usbnet *dev = netdev_priv(net);
-	struct sockaddr *addr = p;
-	int ret;
-
-	if (netif_running(net))
-		return -EBUSY;
-	if (!is_valid_ether_addr(addr->sa_data))
-		return -EADDRNOTAVAIL;
-
-	eth_hw_addr_set(net, addr->sa_data);
-
-	/* Set the MAC address */
-	ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
-				 ETH_ALEN, net->dev_addr);
-	if (ret < 0)
-		return ret;
-
-	return 0;
-}
-
 static const struct net_device_ops ax88179_netdev_ops = {
 	.ndo_open		= usbnet_open,
 	.ndo_stop		= usbnet_stop,
@@ -1249,35 +669,6 @@ static int ax88179_led_setting(struct usbnet *dev)
 	return 0;
 }
 
-static void ax88179_get_mac_addr(struct usbnet *dev)
-{
-	u8 mac[ETH_ALEN];
-
-	memset(mac, 0, sizeof(mac));
-
-	/* Maybe the boot loader passed the MAC address via device tree */
-	if (!eth_platform_get_mac_address(&dev->udev->dev, mac)) {
-		netif_dbg(dev, ifup, dev->net,
-			  "MAC address read from device tree");
-	} else {
-		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
-				 ETH_ALEN, mac);
-		netif_dbg(dev, ifup, dev->net,
-			  "MAC address read from ASIX chip");
-	}
-
-	if (is_valid_ether_addr(mac)) {
-		eth_hw_addr_set(dev->net, mac);
-		if (!is_local_ether_addr(mac))
-			dev->net->addr_assign_type = NET_ADDR_PERM;
-	} else {
-		netdev_info(dev->net, "invalid MAC address, using random\n");
-	}
-
-	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN,
-			  dev->net->dev_addr);
-}
-
 static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
 {
 	struct ax88179_data *ax179_data;
@@ -1293,6 +684,22 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
 
 	dev->driver_priv = ax179_data;
 
+	ax179_data->resume = ax88179_resume;
+	ax179_data->suspend = ax88179_suspend;
+
+	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_write_cmd = AX_ACCESS_EEPROM;
+	ax179_data->eeprom_block = 2;
+	ax179_data->eeprom_wen = 0;
+
 	dev->net->netdev_ops = &ax88179_netdev_ops;
 	dev->net->ethtool_ops = &ax88179_ethtool_ops;
 	dev->net->needed_headroom = 8;
@@ -1317,6 +724,12 @@ 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 ax88179_unbind(struct usbnet *dev, struct usb_interface *intf)
@@ -1617,11 +1030,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 |
@@ -1878,6 +1290,18 @@ static const struct driver_info at_umc2000sp_info = {
 
 static const struct usb_device_id products[] = {
 {
+	/* ASIX AX88179A USB 3.2 1000Mbit Ethernet */
+	USB_DEVICE_VER(0x0b95, 0x1790, 0, 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 2500Mbit Ethernet */
+	USB_DEVICE_VER(0x0b95, 0x1790, 0, 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,
@@ -1934,19 +1358,19 @@ static const struct usb_device_id products[] = {
 };
 MODULE_DEVICE_TABLE(usb, products);
 
-static struct usb_driver ax88179_178a_driver = {
-	.name =		"ax88179_178a",
+static struct usb_driver ax88179_driver = {
+	.name =		"ax88179",
 	.id_table =	products,
 	.probe =	usbnet_probe,
-	.suspend =	ax88179_suspend,
-	.resume =	ax88179_resume,
-	.reset_resume =	ax88179_resume,
+	.suspend =	ax88179_suspend_wrapper,
+	.resume =	ax88179_resume_wrapper,
+	.reset_resume =	ax88179_resume_wrapper,
 	.disconnect =	ax88179_disconnect,
 	.supports_autosuspend = 1,
 	.disable_hub_initiated_lpm = 1,
 };
 
-module_usb_driver(ax88179_178a_driver);
+module_usb_driver(ax88179_driver);
 
-MODULE_DESCRIPTION("ASIX AX88179/178A based USB 3.0/2.0 Gigabit Ethernet Devices");
+MODULE_DESCRIPTION("ASIX AX88179/179A/178A based USB 3.0/2.0 Gigabit Ethernet Devices");
 MODULE_LICENSE("GPL");
diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c
new file mode 100644
index 0000000000000..9b91ad831333e
--- /dev/null
+++ b/drivers/net/usb/ax88179_lib.c
@@ -0,0 +1,515 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices
+ *
+ * Copyright (C) 2011-2013 ASIX
+ */
+
+#include <linux/etherdevice.h>
+#include "ax88179_lib.h"
+
+void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode)
+{
+	struct ax88179_data *ax179_data = dev->driver_priv;
+
+	ax179_data->in_pm = pm_mode;
+}
+
+static int ax88179_in_pm(struct usbnet *dev)
+{
+	struct ax88179_data *ax179_data = dev->driver_priv;
+
+	return ax179_data->in_pm;
+}
+
+int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
+		       u16 size, void *data)
+{
+	int ret;
+	int (*fn)(struct usbnet *dev, u8 cmd, u8 rtype, u16 val, u16 i, void *d, u16 size);
+	struct ax88179_data *ax179_data = dev->driver_priv;
+
+	if (!dev) {
+		netdev_err(dev->net, "No net device.\n");
+		return -ENODEV;
+	}
+
+	if (!ax88179_in_pm(dev))
+		fn = usbnet_read_cmd;
+	else
+		fn = usbnet_read_cmd_nopm;
+
+	ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+		 value, index, data, size);
+
+	if (unlikely(ret < 0 && !(ret == -ENODEV && ax179_data->disconnecting)))
+		netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n",
+			    index, ret);
+
+	return ret;
+}
+
+static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
+			       u16 size, const void *data)
+{
+	int ret;
+	int (*fn)(struct usbnet *dev, u8 cmd, u8 rtype, u16 val, u16 i, const void *d, u16 size);
+	struct ax88179_data *ax179_data = dev->driver_priv;
+
+	if (!dev) {
+		netdev_err(dev->net, "No net device.\n");
+		return -ENODEV;
+	}
+
+	if (!ax88179_in_pm(dev))
+		fn = usbnet_write_cmd;
+	else
+		fn = usbnet_write_cmd_nopm;
+
+	ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+		 value, index, data, size);
+
+	if (unlikely(ret < 0 && !(ret == -ENODEV && ax179_data->disconnecting)))
+		netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n",
+			    index, ret);
+
+	return ret;
+}
+
+void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size,
+			     void *data)
+{
+	u16 buf;
+
+	if (size == 2) {
+		buf = *((u16 *)data);
+		cpu_to_le16s(&buf);
+		usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |
+				       USB_RECIP_DEVICE, value, index, &buf,
+				       size);
+	} else {
+		usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR |
+				       USB_RECIP_DEVICE, value, index, data,
+				       size);
+	}
+}
+
+int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data)
+{
+	int ret;
+
+	if (size == 2) {
+		u16 buf = 0;
+
+		ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf);
+		le16_to_cpus(&buf);
+		*((u16 *)data) = buf;
+	} else if (size == 4) {
+		u32 buf = 0;
+
+		ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf);
+		le32_to_cpus(&buf);
+		*((u32 *)data) = buf;
+	} else {
+		ret = __ax88179_read_cmd(dev, cmd, value, index, size, data);
+	}
+
+	return ret;
+}
+
+int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size,
+		      const void *data)
+{
+	int ret;
+
+	if (size == 2) {
+		u16 buf;
+
+		buf = *((u16 *)data);
+		cpu_to_le16s(&buf);
+		ret = __ax88179_write_cmd(dev, cmd, value, index,
+					  size, &buf);
+	} else {
+		ret = __ax88179_write_cmd(dev, cmd, value, index,
+					  size, data);
+	}
+
+	return ret;
+}
+
+struct ax88179_data *netdev2data(struct net_device *net)
+{
+	struct usbnet *dev = netdev_priv(net);
+
+	return dev->driver_priv;
+}
+
+void ax88179_status(struct usbnet *dev, struct urb *urb)
+{
+	struct ax88179_int_data *event;
+	u32 link;
+
+	if (urb->actual_length < 8)
+		return;
+
+	event = urb->transfer_buffer;
+	le32_to_cpus((void *)&event->intdata1);
+
+	link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16;
+
+	if (netif_carrier_ok(dev->net) != link) {
+		usbnet_link_change(dev, link, 1);
+		if (!link)
+			netdev_info(dev->net, "ax88179 - Link status is: 0\n");
+	}
+}
+
+int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc)
+{
+	struct usbnet *dev = netdev_priv(netdev);
+	u16 res;
+
+	ax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res);
+	return res;
+}
+
+void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
+{
+	struct usbnet *dev = netdev_priv(netdev);
+	u16 res = (u16)val;
+
+	ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res);
+}
+
+void ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
+{
+	struct usbnet *dev = netdev_priv(net);
+	struct ax88179_data *priv = dev->driver_priv;
+
+	wolinfo->supported = priv->wol_supported;
+	wolinfo->wolopts = priv->wolopts;
+}
+
+int ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
+{
+	struct usbnet *dev = netdev_priv(net);
+	struct ax88179_data *priv = dev->driver_priv;
+
+	if (wolinfo->wolopts & ~(priv->wol_supported))
+		return -EINVAL;
+
+	priv->wolopts = wolinfo->wolopts;
+
+	return 0;
+}
+
+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;
+	}
+}
+
+int ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 *data)
+{
+	struct usbnet *dev = netdev_priv(net);
+	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 = 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;
+
+	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, eeprom_buff + eeprom->offset % ax179_data->eeprom_block, eeprom->len);
+	kfree(eeprom_buff);
+	return 0;
+}
+
+int 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);
+
+	if (eeprom->len == 0)
+		return -EINVAL;
+
+	if (eeprom->magic != AX88179_EEPROM_MAGIC)
+		return -EINVAL;
+
+	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);
+	if (!eeprom_buff)
+		return -ENOMEM;
+
+	/* align data to 16 bit boundaries, read the missing data from
+	 * the EEPROM
+	 */
+	if (eeprom->offset & 1) {
+		ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, first_word, 1, 2,
+				       &eeprom_buff[0]);
+		if (ret < 0) {
+			netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", first_word);
+			goto free;
+		}
+	}
+
+	if ((eeprom->offset + eeprom->len) & 1) {
+		ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, last_word, 1, 2,
+				       &eeprom_buff[last_word - first_word]);
+		if (ret < 0) {
+			netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", last_word);
+			goto free;
+		}
+	}
+
+	memcpy((u8 *)eeprom_buff + (eeprom->offset & 1), data, eeprom->len);
+
+	for (i = first_word; i <= last_word; i++) {
+		netdev_dbg(net, "write to EEPROM at offset 0x%02x, data 0x%04x\n",
+			   i, eeprom_buff[i - first_word]);
+		ret = ax88179_write_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2,
+					&eeprom_buff[i - first_word]);
+		if (ret < 0) {
+			netdev_err(net, "Failed to write EEPROM at offset 0x%02x.\n", i);
+			goto free;
+		}
+		msleep(20);
+	}
+
+	/* reload EEPROM data */
+	ret = ax88179_write_cmd(dev, AX_RELOAD_EEPROM_EFUSE, 0x0000, 0, 0, NULL);
+	if (ret < 0) {
+		netdev_err(net, "Failed to reload EEPROM data\n");
+		goto free;
+	}
+
+	ret = 0;
+free:
+	kfree(eeprom_buff);
+	return ret;
+}
+
+void ax88179_set_multicast(struct net_device *net)
+{
+	struct usbnet *dev = netdev_priv(net);
+	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_DROPCRCERR);
+	if (data->ip_align)
+		data->rxctl |= AX_RX_CTL_IPE;
+
+	if (net->flags & IFF_PROMISC) {
+		data->rxctl |= AX_RX_CTL_PRO;
+	} else if (net->flags & IFF_ALLMULTI ||
+		   netdev_mc_count(net) > AX_MAX_MCAST) {
+		data->rxctl |= AX_RX_CTL_AMALL;
+	} else if (netdev_mc_empty(net)) {
+		/* just broadcast and directed */
+	} else {
+		/* We use dev->data for our 8 byte filter buffer
+		 * to avoid allocating memory that is tricky to free later
+		 */
+		u32 crc_bits;
+		struct netdev_hw_addr *ha;
+
+		memset(m_filter, 0, AX_MCAST_FLTSIZE);
+
+		netdev_for_each_mc_addr(ha, net) {
+			crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
+			*(m_filter + (crc_bits >> 3)) |= (1 << (crc_bits & 7));
+		}
+
+		ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_MULFLTARY,
+					AX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE,
+					m_filter);
+
+		data->rxctl |= AX_RX_CTL_AM;
+	}
+
+	ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL,
+				2, 2, &data->rxctl);
+}
+
+int 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) {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
+		tmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
+	}
+
+	if (changed & NETIF_F_IPV6_CSUM) {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
+		tmp ^= AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
+	}
+
+	if (changed & NETIF_F_RXCSUM) {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp);
+		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);
+	}
+
+	return 0;
+}
+
+void ax88179_get_mac_addr(struct usbnet *dev)
+{
+	u8 mac[ETH_ALEN];
+
+	memset(mac, 0, sizeof(mac));
+
+	/* Maybe the boot loader passed the MAC address via device tree */
+	if (!eth_platform_get_mac_address(&dev->udev->dev, mac)) {
+		netif_dbg(dev, ifup, dev->net,
+			  "MAC address read from device tree");
+	} else {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
+				 ETH_ALEN, mac);
+		netif_dbg(dev, ifup, dev->net,
+			  "MAC address read from ASIX chip");
+	}
+
+	if (is_valid_ether_addr(mac)) {
+		eth_hw_addr_set(dev->net, mac);
+		if (!is_local_ether_addr(mac))
+			dev->net->addr_assign_type = NET_ADDR_PERM;
+	} else {
+		netdev_info(dev->net, "invalid MAC address, using random\n");
+	}
+
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN,
+			  dev->net->dev_addr);
+}
+
+int ax88179_change_mtu(struct net_device *net, int new_mtu)
+{
+	struct usbnet *dev = netdev_priv(net);
+	u16 tmp16;
+
+	WRITE_ONCE(net->mtu, new_mtu);
+	dev->hard_mtu = net->mtu + net->hard_header_len;
+
+	if (net->mtu > 1500) {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+				 2, 2, &tmp16);
+		tmp16 |= AX_MEDIUM_JUMBO_EN;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+				  2, 2, &tmp16);
+	} else {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+				 2, 2, &tmp16);
+		tmp16 &= ~AX_MEDIUM_JUMBO_EN;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+				  2, 2, &tmp16);
+	}
+
+	/* max qlen depend on hard_mtu and rx_urb_size */
+	usbnet_update_max_qlen(dev);
+
+	return 0;
+}
+
+int ax88179_set_mac_addr(struct net_device *net, void *p)
+{
+	struct usbnet *dev = netdev_priv(net);
+	struct sockaddr *addr = p;
+	int ret;
+
+	if (netif_running(net))
+		return -EBUSY;
+	if (!is_valid_ether_addr(addr->sa_data))
+		return -EADDRNOTAVAIL;
+
+	eth_hw_addr_set(net, addr->sa_data);
+
+	/* Set the MAC address */
+	ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
+				ETH_ALEN, net->dev_addr);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+int ax88179_suspend_wrapper(struct usb_interface *intf, pm_message_t message)
+{
+	struct usbnet *dev = usb_get_intfdata(intf);
+	struct ax88179_data *priv;
+
+	priv = dev->driver_priv;
+
+	return priv->suspend(intf, message);
+}
+
+int ax88179_resume_wrapper(struct usb_interface *intf)
+{
+	struct usbnet *dev = usb_get_intfdata(intf);
+	struct ax88179_data *priv;
+
+	priv = dev->driver_priv;
+	return priv->resume(intf);
+}
+
diff --git a/drivers/net/usb/ax88179_lib.h b/drivers/net/usb/ax88179_lib.h
new file mode 100644
index 0000000000000..16a6dcbd6e66e
--- /dev/null
+++ b/drivers/net/usb/ax88179_lib.h
@@ -0,0 +1,358 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include <linux/usb.h>
+#include <linux/crc32.h>
+#include <linux/phylink.h>
+#include <linux/usb/usbnet.h>
+
+#ifndef __LINUX_USBNET_AX88179_H
+#define __LINUX_USBNET_AX88179_H
+
+#define AX88179_PHY_ID				0x03
+#define AX_EEPROM_LEN				0x100
+#define AX88179_EEPROM_MAGIC			0x17900b95
+#define AX_MCAST_FLTSIZE			8
+#define AX_MAX_MCAST				64
+#define AX_INT_PPLS_LINK			((u32)BIT(16))
+#define AX_RXHDR_L4_TYPE_MASK			0x1c
+#define AX_RXHDR_L4_TYPE_UDP			4
+#define AX_RXHDR_L4_TYPE_TCP			16
+#define AX_RXHDR_L3CSUM_ERR			2
+#define AX_RXHDR_L4CSUM_ERR			1
+#define AX_RXHDR_CRC_ERR			((u32)BIT(29))
+#define AX_RXHDR_DROP_ERR			((u32)BIT(31))
+#define AX_ACCESS_MAC				0x01
+#define AX_ACCESS_PHY				0x02
+#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 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
+#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
+	#define EEP_BUSY		0x10
+
+#define AX_SROM_DATA_LOW			0x08
+#define AX_SROM_DATA_HIGH			0x09
+
+#define AX_RX_CTL				0x0b
+	#define AX_RX_CTL_DROPCRCERR	0x0100
+	#define AX_RX_CTL_IPE		0x0200
+	#define AX_RX_CTL_START		0x0080
+	#define AX_RX_CTL_AP		0x0020
+	#define AX_RX_CTL_AM		0x0010
+	#define AX_RX_CTL_AB		0x0008
+	#define AX_RX_CTL_AMALL		0x0002
+	#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
+
+#define AX_MEDIUM_STATUS_MODE			0x22
+	#define AX_MEDIUM_GIGAMODE	0x01
+	#define AX_MEDIUM_FULL_DUPLEX	0x02
+	#define AX_MEDIUM_EN_125MHZ	0x08
+	#define AX_MEDIUM_RXFLOW_CTRLEN	0x10
+	#define AX_MEDIUM_TXFLOW_CTRLEN	0x20
+	#define AX_MEDIUM_RECEIVE_EN	0x100
+	#define AX_MEDIUM_PS		0x200
+	#define AX_MEDIUM_JUMBO_EN	0x8040
+
+#define AX_MONITOR_MOD				0x24
+	#define AX_MONITOR_MODE_RWLC	0x02
+	#define AX_MONITOR_MODE_RWMP	0x04
+	#define AX_MONITOR_MODE_PMEPOL	0x20
+	#define AX_MONITOR_MODE_PMETYPE	0x40
+
+#define AX_GPIO_CTRL				0x25
+	#define AX_GPIO_CTRL_GPIO3EN	0x80
+	#define AX_GPIO_CTRL_GPIO2EN	0x40
+	#define AX_GPIO_CTRL_GPIO1EN	0x20
+
+#define AX_PHYPWR_RSTCTL			0x26
+	#define AX_PHYPWR_RSTCTL_BZ	0x0010
+	#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_GPHY_EEE_CTRL			0x01
+
+#define AX_CLK_SELECT				0x33
+	#define AX_CLK_SELECT_BCS	0x01
+	#define AX_CLK_SELECT_ACS	0x02
+	#define AX_CLK_SELECT_ULR	0x08
+
+#define AX_RXCOE_CTL				0x34
+	#define AX_RXCOE_IP		0x01
+	#define AX_RXCOE_TCP		0x02
+	#define AX_RXCOE_UDP		0x04
+	#define AX_RXCOE_TCPV6		0x20
+	#define AX_RXCOE_UDPV6		0x40
+
+#define AX_TXCOE_CTL				0x35
+	#define AX_TXCOE_IP		0x01
+	#define AX_TXCOE_TCP		0x02
+	#define AX_TXCOE_UDP		0x04
+	#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
+	#define GMII_PHY_PHYSR_GIGA	0x8000
+	#define GMII_PHY_PHYSR_100	0x4000
+	#define GMII_PHY_PHYSR_FULL	0x2000
+	#define GMII_PHY_PHYSR_LINK	0x400
+
+#define GMII_LED_ACT				0x1a
+	#define	GMII_LED_ACTIVE_MASK	0xff8f
+	#define	GMII_LED0_ACTIVE	BIT(4)
+	#define	GMII_LED1_ACTIVE	BIT(5)
+	#define	GMII_LED2_ACTIVE	BIT(6)
+
+#define GMII_LED_LINK				0x1c
+	#define	GMII_LED_LINK_MASK	0xf888
+	#define	GMII_LED0_LINK_10	BIT(0)
+	#define	GMII_LED0_LINK_100	BIT(1)
+	#define	GMII_LED0_LINK_1000	BIT(2)
+	#define	GMII_LED1_LINK_10	BIT(4)
+	#define	GMII_LED1_LINK_100	BIT(5)
+	#define	GMII_LED1_LINK_1000	BIT(6)
+	#define	GMII_LED2_LINK_10	BIT(8)
+	#define	GMII_LED2_LINK_100	BIT(9)
+	#define	GMII_LED2_LINK_1000	BIT(10)
+	#define	LED0_ACTIVE		BIT(0)
+	#define	LED0_LINK_10		BIT(1)
+	#define	LED0_LINK_100		BIT(2)
+	#define	LED0_LINK_1000		BIT(3)
+	#define	LED0_FD			BIT(4)
+	#define	LED0_USB3_MASK		0x001f
+	#define	LED1_ACTIVE		BIT(5)
+	#define	LED1_LINK_10		BIT(6)
+	#define	LED1_LINK_100		BIT(7)
+	#define	LED1_LINK_1000		BIT(8)
+	#define	LED1_FD			BIT(9)
+	#define	LED1_USB3_MASK		0x03e0
+	#define	LED2_ACTIVE		BIT(10)
+	#define	LED2_LINK_1000		BIT(13)
+	#define	LED2_LINK_100		BIT(12)
+	#define	LED2_LINK_10		BIT(11)
+	#define	LED2_FD			BIT(14)
+	#define	LED_VALID		BIT(15)
+	#define	LED2_USB3_MASK		0x7c00
+
+#define GMII_PHYPAGE				0x1e
+#define GMII_PHY_PAGE_SELECT			0x1f
+	#define GMII_PHY_PGSEL_EXT	0x0007
+	#define GMII_PHY_PGSEL_PAGE0	0x0000
+	#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
+
+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;
+	u16 rxctl;
+	u8 in_pm;
+	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;
+	u8 rx_checksum;
+	u8 eeprom_read_cmd;
+	u8 eeprom_write_cmd;
+	u8 eeprom_wen;
+	u16 eeprom_block;
+	struct mii_bus *mdio;
+	struct phy_device *phydev;
+	struct phylink *phylink;
+	struct phylink_config phylink_config;
+	int (*resume)(struct usb_interface *intf);
+	int (*suspend)(struct usb_interface *intf, pm_message_t message);
+};
+
+struct ax88179_int_data {
+	__le32 intdata1;
+	__le32 intdata2;
+};
+
+struct ax_bulkin_settings {
+	unsigned char ctrl, timer_l, timer_h, size, ifg;
+};
+
+void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode);
+int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data);
+int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data);
+int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size,
+		      const void *data);
+void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
+			     u16 size, void *data);
+int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc);
+void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc, int val);
+struct ax88179_data *netdev2data(struct net_device *net);
+void ax88179_status(struct usbnet *dev, struct urb *urb);
+void ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo);
+int ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo);
+int ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 *data);
+int ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 *data);
+void ax88179_set_multicast(struct net_device *net);
+int ax88179_set_features(struct net_device *net, netdev_features_t features);
+void ax88179_get_mac_addr(struct usbnet *dev);
+int ax88179_change_mtu(struct net_device *net, int new_mtu);
+int ax88179_set_mac_addr(struct net_device *net, void *p);
+int ax88179_suspend_wrapper(struct usb_interface *intf, pm_message_t message);
+int ax88179_resume_wrapper(struct usb_interface *intf);
+
+extern const struct driver_info ax88179a_info;
+extern const struct driver_info ax88772d_info;
+extern const struct driver_info ax88279_info;
+
+#endif /*__LINUX_USBNET_AX88179_H */
diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
new file mode 100644
index 0000000000000..6b57111a0e05a
--- /dev/null
+++ b/drivers/net/usb/ax88179a_devices.c
@@ -0,0 +1,1222 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/module.h>
+#include <linux/phylink.h>
+#include <linux/if_vlan.h>
+#include "ax88179_lib.h"
+
+static int ax88179a_reset(struct usbnet *dev);
+
+#define AX88279_EEPROM_LEN			0x4000
+#define AX88179A_EEPROM_LEN			(32 * 20)
+
+enum ax_bulk_in_speeds {
+	BULK_IN_SPEED_2G5 = 0,
+	BULK_IN_SPEED_1G_SS = 1,
+	BULK_IN_SPEED_1G_HS   = 2,
+	BULK_IN_SPEED_100_FULL_SS = 3,
+	BULK_IN_SPEED_100_HALF_SS = 4,
+	BULK_IN_SPEED_100_FULL_HS = 5,
+	BULK_IN_SPEED_100_HALF_HS = 6,
+	BULK_IN_SPEED_FS = 7,
+};
+
+static const struct ax_bulkin_settings AX88179A_BULKIN_SIZE[] = {
+	[BULK_IN_SPEED_1G_SS]		= {5, 0x7B, 0x00, 0x17, 0x0F},
+	[BULK_IN_SPEED_1G_HS]		= {5, 0xC0, 0x02, 0x06, 0x0F},
+	[BULK_IN_SPEED_100_FULL_SS]	= {7, 0xF0, 0x00, 0x0C, 0x0F},
+	[BULK_IN_SPEED_100_HALF_SS]	= {6, 0x00, 0x00, 0x06, 0x0F},
+	[BULK_IN_SPEED_100_FULL_HS]	= {5, 0xC0, 0x04, 0x06, 0x0F},
+	[BULK_IN_SPEED_100_HALF_HS]	= {7, 0xC0, 0x04, 0x06, 0x0F},
+	[BULK_IN_SPEED_FS]		= {7, 0x00, 0x00, 0x03, 0x3F},
+};
+
+static const struct ax_bulkin_settings AX88772D_BULKIN_SIZE[] = {
+	[BULK_IN_SPEED_100_FULL_HS]	= {5, 0xC0, 0x04, 0x06, 0x0F},
+	[BULK_IN_SPEED_100_HALF_HS]	= {7, 0xC0, 0x04, 0x06, 0x0F},
+	[BULK_IN_SPEED_FS]		= {7, 0x00, 0x00, 0x03, 0x3F},
+};
+
+static const struct ax_bulkin_settings AX88279_BULKIN_SIZE[] = {
+	[BULK_IN_SPEED_2G5]		= {5, 0x10, 0x01, 0x11, 0x0F},
+	[BULK_IN_SPEED_1G_SS]		= {7, 0xB3, 0x01, 0x11, 0x0F},
+	[BULK_IN_SPEED_1G_HS]		= {7, 0xC0, 0x02, 0x06, 0x0F},
+	[BULK_IN_SPEED_100_FULL_SS]	= {7, 0x80, 0x01, 0x03, 0x0F},
+	[BULK_IN_SPEED_100_HALF_SS]	= {7, 0x80, 0x01, 0x03, 0x0F},
+	[BULK_IN_SPEED_100_FULL_HS]	= {7, 0x80, 0x01, 0x03, 0x0F},
+	[BULK_IN_SPEED_100_HALF_HS]	= {7, 0x80, 0x01, 0x03, 0x0F},
+	[BULK_IN_SPEED_FS]		= {7, 0x00, 0x00, 0x03, 0x3F},
+};
+
+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;
+
+	return ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)regnum, 2, &val);
+}
+
+static int ax179a_read_mmd(struct usbnet *dev, u16 dev_addr, u16 reg)
+{
+	u16 res;
+	int ret;
+
+	ret = ax88179_read_cmd(dev, AX88179A_PHY_CLAUSE45, dev_addr, reg, 2, &res);
+	if (ret < 0)
+		return ret;
+	return res;
+}
+
+static int ax179a_write_mmd(struct usbnet *dev, u16 dev_addr, u16 reg, u16 data)
+{
+	return ax88179_write_cmd(dev, AX88179A_PHY_CLAUSE45, dev_addr, reg, 2, &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 ax179a_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 ax179a_write_mmd(dev, devnum, regnum, val);
+}
+
+static void ax88179a_status(struct usbnet *dev, struct urb *urb)
+{
+	struct ax88179_data *data = dev->driver_priv;
+	struct ax88179_int_data *event;
+	u32 link;
+
+	if (urb->actual_length < 8)
+		return;
+
+	event = urb->transfer_buffer;
+	le32_to_cpus((void *)&event->intdata1);
+
+	link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16;
+
+	if (netif_carrier_ok(dev->net) != link) {
+		usbnet_link_change(dev, link, 1);
+		phylink_mac_interrupt(data->phylink);
+	}
+}
+
+static int ax88179a_suspend(struct usb_interface *intf, pm_message_t message)
+{
+	struct usbnet *dev = usb_get_intfdata(intf);
+	struct ax88179_data *priv;
+	u16 tmp16;
+	u8 tmp8;
+
+	priv = dev->driver_priv;
+	ax88179_set_pm_mode(dev, true);
+
+	if (netif_running(dev->net)) {
+		rtnl_lock();
+		phylink_suspend(priv->phylink, !!priv->wolopts);
+		rtnl_unlock();
+	}
+
+	/* Enable WoL */
+	if (priv->wolopts) {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, &tmp8);
+		if (priv->wolopts & WAKE_PHY)
+			tmp8 |= AX_MONITOR_MODE_RWLC;
+		if (priv->wolopts & WAKE_MAGIC)
+			tmp8 |= AX_MONITOR_MODE_RWMP;
+
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, &tmp8);
+
+		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
+			ax88179_write_cmd(dev, AX88179A_WAKEUP_SETTING, 0,
+					  EPHY_LOW_POWER_EN, 0, NULL);
+
+	} else if (priv->chip_version == AX_VERSION_AX88279) {
+		ax88179_write_cmd(dev, AX88179A_WAKEUP_SETTING, 8, 0x8000, 0, NULL);
+	}
+
+	usbnet_suspend(intf, message);
+	ax88179_set_pm_mode(dev, false);
+	return 0;
+}
+
+static int ax88179a_auto_detach(struct usbnet *dev)
+{
+	u16 tmp16;
+
+	tmp16 = AX88179A_AUTODETACH_DELAY;
+	ax88179_write_cmd(dev, AX88179A_AUTODETACH, tmp16, 0, 0, NULL);
+	return 0;
+}
+
+static int ax88179a_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);
+
+	ax88179_read_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, &reg8);
+	if (!(reg8 & AX_PHY_POWER)) {
+		reg8 = AX_PHY_POWER;
+		ax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, &reg8);
+		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, &reg8);
+	msleep(250);
+
+	if (netif_running(dev->net)) {
+		rtnl_lock();
+		phylink_resume(ax179_data->phylink);
+		rtnl_unlock();
+	}
+
+	ax88179a_reset(dev);
+
+	ax88179_set_pm_mode(dev, false);
+
+	return usbnet_resume(intf);
+}
+
+static void ax88179a_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
+{
+	struct ax88179_data *priv = netdev2data(net);
+
+	/* 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 ax88179a_bulkin_config(struct usbnet *dev, u8 link_sts, u8 speed, bool full_duplex)
+{
+	struct ax88179_data *ax179_data = dev->driver_priv;
+	const struct ax_bulkin_settings *bulkin_data;
+	int index = 0;
+
+	switch (speed) {
+	case ETHER_LINK_2500:	/* AX88279 only */
+		index = BULK_IN_SPEED_2G5;
+		break;
+
+	case ETHER_LINK_1000:	/* AX88279 & AX88178A */
+		if (link_sts & AX_USB_SS)
+			index = BULK_IN_SPEED_1G_SS;
+		else if (link_sts & AX_USB_HS)
+			index = BULK_IN_SPEED_1G_HS;
+		break;
+
+	case ETHER_LINK_100:
+		if (link_sts & AX_USB_SS)
+			index = BULK_IN_SPEED_100_FULL_SS;
+		else if (link_sts & AX_USB_HS)
+			index = BULK_IN_SPEED_100_FULL_HS;
+		if (!full_duplex)
+			index++;
+		break;
+
+	case ETHER_LINK_10:
+		index = BULK_IN_SPEED_FS;
+		break;
+
+	default:	/* No link */
+		index = BULK_IN_SPEED_FS;
+	}
+
+	if (ax179_data->chip_version == AX_VERSION_AX88279 && (link_sts & AX_USB_FS))
+		index = BULK_IN_SPEED_FS;
+
+	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_get_pauseparam(struct net_device *net, struct ethtool_pauseparam *pause)
+{
+	struct ax88179_data *data = netdev2data(net);
+
+	phylink_ethtool_get_pauseparam(data->phylink, pause);
+}
+
+static int ax88179a_set_pauseparam(struct net_device *net, struct ethtool_pauseparam *pause)
+{
+	struct ax88179_data *data = netdev2data(net);
+
+	return phylink_ethtool_set_pauseparam(data->phylink, pause);
+}
+
+static int ax88179a_get_eeprom_len(struct net_device *net)
+{
+	struct ax88179_data *ax179_data = netdev2data(net);
+
+	if (ax179_data->chip_version >= AX_VERSION_AX88279)
+		return AX88279_EEPROM_LEN;
+	else
+		return AX88179A_EEPROM_LEN;
+}
+
+static int ax88179a_get_eee(struct net_device *net, struct ethtool_keee *edata)
+{
+	struct ax88179_data *ax179_data = netdev2data(net);
+
+	return phylink_ethtool_get_eee(ax179_data->phylink, edata);
+}
+
+static int ax88179a_set_eee(struct net_device *net, struct ethtool_keee *edata)
+{
+	struct ax88179_data *ax179_data = netdev2data(net);
+
+	return phylink_ethtool_set_eee(ax179_data->phylink, edata);
+}
+
+static const struct ethtool_ops ax88179a_ethtool_ops = {
+	.get_drvinfo            = ax88179a_get_drvinfo,
+	.get_link		= ethtool_op_get_link,
+	.get_msglevel		= usbnet_get_msglevel,
+	.set_msglevel		= usbnet_set_msglevel,
+	.get_wol		= ax88179_get_wol,
+	.set_wol		= ax88179_set_wol,
+	.get_eeprom_len		= ax88179a_get_eeprom_len,
+	.get_eeprom		= ax88179_get_eeprom,
+	.set_eeprom		= ax88179_set_eeprom,
+	.get_eee		= ax88179a_get_eee,
+	.set_eee		= ax88179a_set_eee,
+	.nway_reset		= usbnet_nway_reset,
+	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
+	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
+	.get_pauseparam		= ax88179a_get_pauseparam,
+	.set_pauseparam		= ax88179a_set_pauseparam,
+	.get_ts_info		= ethtool_op_get_ts_info,
+};
+
+static int ax88179a_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, &reg8);
+	vlan_ctrl = reg8;
+
+	/* Address */
+	reg8 = (vid / 16);
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_ADDRESS, 1, 1, &reg8);
+
+	/* Data */
+	reg8 = vlan_ctrl | AX_VLAN_CONTROL_RD;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &reg8);
+
+	ax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, &reg16);
+	reg16 &= ~(1 << (vid % 16));
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, &reg16);
+
+	reg8 = vlan_ctrl | AX_VLAN_CONTROL_WE;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &reg8);
+
+	return 0;
+}
+
+static int ax88179a_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, &reg8);
+	vlan_ctrl = reg8;
+
+	/* Address */
+	reg8 = (vid / 16);
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_ADDRESS, 1, 1, &reg8);
+
+	/* Data */
+	reg8 = vlan_ctrl | AX_VLAN_CONTROL_RD;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &reg8);
+
+	ax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, &reg16);
+	reg16 |= (1 << (vid % 16));
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0, 2, 2, &reg16);
+
+	reg8 = vlan_ctrl | AX_VLAN_CONTROL_WE;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL, 1, 1, &reg8);
+
+	return 0;
+}
+
+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;
+	}
+
+	data->phydev->irq = PHY_MAC_INTERRUPT;
+	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];
+	u8 bulk_config_speed = 0;
+	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;
+	if (tx_pause)
+		mode |= AX_MEDIUM_TXFLOW_CTRLEN;
+	if (rx_pause)
+		mode |= 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;
+		bulk_config_speed = ETHER_LINK_2500;
+
+		break;
+
+	case SPEED_1000:
+		mode |= AX_MEDIUM_GIGAMODE;
+		bulk_config_speed = ETHER_LINK_1000;
+		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);
+		if (!bulk_config_speed)
+			bulk_config_speed = ETHER_LINK_100;
+		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);
+
+		bulk_config_speed = ETHER_LINK_10;
+		break;
+	}
+
+	ax88179_read_cmd(dev, AX_ACCESS_MAC, PHYSICAL_LINK_STATUS, 1, 1, &link_sts);
+	ax88179a_bulkin_config(dev, link_sts, bulk_config_speed, !!duplex);
+
+	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);
+}
+
+static void ax88179a_mac_disable_tx_lpi(struct phylink_config *config)
+{
+	struct usbnet *dev = netdev_priv(to_net_dev(config->dev));
+
+	ax88179_write_cmd(dev, AX_GPHY_CTL, AX_GPHY_EEE_CTRL, false, 0, NULL);
+}
+
+static int ax88179a_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, bool tx_clk_stop)
+{
+	struct usbnet *dev = netdev_priv(to_net_dev(config->dev));
+
+	/* AX88179A does not provide LPI timer registers */
+	return ax88179_write_cmd(dev, AX_GPHY_CTL, AX_GPHY_EEE_CTRL, true, 0, NULL);
+}
+
+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,
+	.mac_disable_tx_lpi = ax88179a_mac_disable_tx_lpi,
+	.mac_enable_tx_lpi = ax88179a_mac_enable_tx_lpi,
+};
+
+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;
+
+	if (!data->is_ax88772d) {
+		data->phylink_config.lpi_capabilities = MAC_100FD | MAC_1000FD;
+		data->phylink_config.eee_enabled_default = false;
+	}
+
+	if (data->chip_version == AX_VERSION_AX88279) {
+		__set_bit(PHY_INTERFACE_MODE_2500BASEX,
+			  data->phylink_config.supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_SGMII,
+			  data->phylink_config.supported_interfaces);
+		phy_if_mode = PHY_INTERFACE_MODE_2500BASEX;
+	} else {
+		__set_bit(PHY_INTERFACE_MODE_SGMII,
+			  data->phylink_config.supported_interfaces);
+		phy_if_mode = PHY_INTERFACE_MODE_SGMII;
+	}
+
+	memcpy(data->phylink_config.lpi_interfaces,
+	       data->phylink_config.supported_interfaces,
+	       sizeof(data->phylink_config.lpi_interfaces));
+
+	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);
+
+	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_set_features(struct net_device *net, netdev_features_t features)
+{
+	struct usbnet *dev = netdev_priv(net);
+	netdev_features_t changed;
+	int ret;
+	u8 tmp;
+
+	changed = net->features ^ features;
+
+	ret = ax88179_set_features(net, features);
+	if (ret)
+		return ret;
+
+	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;
+}
+
+static const struct net_device_ops ax88179a_netdev_ops = {
+	.ndo_open		= usbnet_open,
+	.ndo_stop		= usbnet_stop,
+	.ndo_start_xmit		= usbnet_start_xmit,
+	.ndo_tx_timeout		= usbnet_tx_timeout,
+	.ndo_get_stats64	= dev_get_tstats64,
+	.ndo_change_mtu		= ax88179_change_mtu,
+	.ndo_set_mac_address	= ax88179_set_mac_addr,
+	.ndo_validate_addr	= eth_validate_addr,
+	.ndo_eth_ioctl		= usbnet_mii_ioctl,
+	.ndo_set_rx_mode	= ax88179_set_multicast,
+	.ndo_set_features	= ax88179a_set_features,
+	.ndo_vlan_rx_add_vid	= ax88179a_vlan_rx_add_vid,
+	.ndo_vlan_rx_kill_vid	= ax88179a_vlan_rx_kill_vid,
+};
+
+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_write_cmd = AX88179A_FLASH_WRITE;
+		ax179_data->eeprom_block = 256;
+		ax179_data->eeprom_wen = 1;
+	} else {
+		ax179_data->ip_align = 0;
+		ax179_data->eeprom_read_cmd = AX_ACCESS_EFUS;
+		ax179_data->eeprom_write_cmd = AX_ACCESS_EFUS;
+		ax179_data->eeprom_block = 20;
+		ax179_data->eeprom_wen = 0;
+	}
+
+	ax179_data->resume = ax88179a_resume;
+	ax179_data->suspend = ax88179a_suspend;
+
+	dev->net->netdev_ops = &ax88179a_netdev_ops;
+	dev->net->ethtool_ops = &ax88179a_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;
+
+	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, &reg8);
+	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 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 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 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 *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 ax88179a_reset(struct usbnet *dev)
+{
+	struct ax88179_data *ax179_data = dev->driver_priv;
+	u16 *tmp16;
+	u8 buf[5];
+	u8 *tmp;
+
+	tmp16 = (u16 *)buf;
+	tmp = (u8 *)buf;
+
+	/* Power up ethernet PHY */
+	*tmp = AX_PHY_POWER;
+	ax88179_write_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, tmp);
+	msleep(250);
+
+	/* Ethernet PHY Auto Detach*/
+	ax88179a_auto_detach(dev);
+
+	*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);
+
+	/* The Bulk-Register configuration for the AX88179A is done in
+	 * ax88179a_mac_link_up(), 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 */
+	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;
+	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;
+	if (ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD,
+			     1, 1, &tmp) > 0)
+		ax179_data->wol_supported = WAKE_MAGIC | WAKE_PHY;
+
+	/* ax88179a_reset() may also be called from resume context, phylink
+	 * is already started, then.
+	 */
+	if (!ax179_data->in_pm)
+		phylink_start(ax179_data->phylink);
+
+	usbnet_link_change(dev, 0, 0);
+
+	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, &reg16);
+	reg16 &= ~AX_MEDIUM_RECEIVE_EN;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, &reg16);
+
+	reg16 = 0;
+	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &reg16);
+
+	reg8 = 0;
+	ax88179_read_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, &reg8);
+
+	phylink_stop(ax179_data->phylink);
+
+	return 0;
+}
+
+const struct driver_info ax88179a_info = {
+	.description = "ASIX AX88179A USB 3.2 Gigabit Ethernet",
+	.bind = ax88179a_bind,
+	.unbind = ax88179a_unbind,
+	.status = ax88179a_status,
+	.reset = ax88179a_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,
+};
+
+const struct driver_info ax88772d_info = {
+	.description = "ASIX AX88772D/E USB 2.0 Fast Ethernet",
+	.bind = ax88179a_bind,
+	.unbind = ax88179a_unbind,
+	.status = ax88179a_status,
+	.reset = ax88179a_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,
+};
+
+const struct driver_info ax88279_info = {
+	.description = "ASIX AX88279 USB 3.2 2.5Gigabit Ethernet",
+	.bind = ax88179a_bind,
+	.unbind = ax88179a_unbind,
+	.status = ax88179a_status,
+	.reset = ax88179a_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,
+};
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 2bc0db3d52ac8..21f960a827b6f 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -768,6 +768,7 @@ int phylink_ethtool_set_eee(struct phylink *link, struct ethtool_keee *eee);
 int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);
 int phylink_speed_down(struct phylink *pl, bool sync);
 int phylink_speed_up(struct phylink *pl);
+void phylink_mac_interrupt(struct phylink *pl);
 
 #define phylink_zero(bm) \
 	bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS)

7/3 2026/08/10 13:58 llm kmsan-evaluator
6m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 48322
							output: 18
							thoughts: 62914
						

8/3 2026/08/10 14:05 tool grepper
0m Args:
{
  "Expression": "kzalloc_obj"
}

Results:
{
  "Output": "\nFull output is too long, showing 500 out of 79118 lines.\nUse more precise expression if possible.\n\nDocumentation/core-api/list.rst=103=list:\n--\nDocumentation/core-api/list.rst-114-\nDocumentation/core-api/list.rst:115:          grock = kzalloc_obj(*grock);\nDocumentation/core-api/list.rst-116-          if (!grock)\n--\nDocumentation/core-api/list.rst-125-\nDocumentation/core-api/list.rst:126:          dimitri = kzalloc_obj(*dimitri);\nDocumentation/core-api/list.rst-127-          if (!dimitri)\n--\nDocumentation/driver-api/mailbox.rst=45=a message and a callback function to the API and return immediately).\n--\nDocumentation/driver-api/mailbox.rst-89-\nDocumentation/driver-api/mailbox.rst:90:\t\tdc_sync = kzalloc_obj(*dc_sync);\nDocumentation/driver-api/mailbox.rst:91:\t\tdc_async = kzalloc_obj(*dc_async);\nDocumentation/driver-api/mailbox.rst-92-\n--\nDocumentation/driver-api/media/v4l2-fh.rst=26=Example:\n--\nDocumentation/driver-api/media/v4l2-fh.rst-44-\nDocumentation/driver-api/media/v4l2-fh.rst:45:\t\tmy_fh = kzalloc_obj(*my_fh);\nDocumentation/driver-api/media/v4l2-fh.rst-46-\n--\nDocumentation/process/coding-style.rst=938=The kernel provides the following general purpose memory allocators:\nDocumentation/process/coding-style.rst:939:kmalloc(), kzalloc(), kmalloc_objs(), kzalloc_objs(), vmalloc(), and\nDocumentation/process/coding-style.rst-940-vzalloc().  Please refer to the API documentation for further information\n--\nDocumentation/process/coding-style.rst=964=The preferred form for allocating a zeroed array is the following:\n--\nDocumentation/process/coding-style.rst-967-\nDocumentation/process/coding-style.rst:968:\tp = kzalloc_objs(*p, n, ...);\nDocumentation/process/coding-style.rst-969-\n--\nDocumentation/process/deprecated.rst=398=become, respectively::\n--\nDocumentation/process/deprecated.rst-400-\tptr = kmalloc_obj(*ptr [, gfp] );\nDocumentation/process/deprecated.rst:401:\tptr = kzalloc_obj(*ptr [, gfp] );\nDocumentation/process/deprecated.rst-402-\tptr = kmalloc_objs(*ptr, count [, gfp] );\nDocumentation/process/deprecated.rst:403:\tptr = kzalloc_objs(*ptr, count [, gfp] );\nDocumentation/process/deprecated.rst-404-\tptr = kmalloc_flex(*ptr, flex_member, count [, gfp] );\n--\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst=208=to details explained in the following section.\n--\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst-268-              /* allocate a chip-specific data with zero filled */\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst:269:              chip = kzalloc_obj(*chip);\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst-270-              if (chip == NULL)\n--\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst=623=After allocating a card instance via :c:func:`snd_card_new()`\n--\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst-630-  .....\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst:631:  chip = kzalloc_obj(*chip);\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst-632-\n--\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst=698=destructor and PCI entries. Example code is shown first, below::\n--\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst-749-\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst:750:              chip = kzalloc_obj(*chip);\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst-751-              if (chip == NULL) {\n--\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst=3823=chip data individually::\n--\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst-3835-          ....\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst:3836:          chip = kzalloc_obj(*chip);\nDocumentation/sound/kernel-api/writing-an-alsa-driver.rst-3837-          ....\n--\nDocumentation/translations/zh_CN/video4linux/v4l2-framework.txt=794=int my_open(struct file *file)\n--\nDocumentation/translations/zh_CN/video4linux/v4l2-framework.txt-801-\nDocumentation/translations/zh_CN/video4linux/v4l2-framework.txt:802:\tmy_fh = kzalloc_obj(*my_fh);\nDocumentation/translations/zh_CN/video4linux/v4l2-framework.txt-803-\n--\narch/alpha/kernel/module.c=64=module_frob_arch_sections(Elf64_Ehdr *hdr, Elf64_Shdr *sechdrs,\n--\narch/alpha/kernel/module.c-95-\tnsyms = symtab-\u003esh_size / sizeof(Elf64_Sym);\narch/alpha/kernel/module.c:96:\tchains = kzalloc_objs(struct got_entry, nsyms);\narch/alpha/kernel/module.c-97-\tif (!chains) {\n--\narch/alpha/kernel/setup.c=390=register_cpus(void)\n--\narch/alpha/kernel/setup.c-394-\tfor_each_possible_cpu(i) {\narch/alpha/kernel/setup.c:395:\t\tstruct cpu *p = kzalloc_obj(*p);\narch/alpha/kernel/setup.c-396-\t\tif (!p)\n--\narch/arc/net/bpf_jit_core.c=1120=static int jit_prepare_final_mem_alloc(struct jit_context *ctx)\n--\narch/arc/net/bpf_jit_core.c-1131-\tif (ctx-\u003eneed_extra_pass) {\narch/arc/net/bpf_jit_core.c:1132:\t\tctx-\u003ejit_data = kzalloc_obj(*ctx-\u003ejit_data);\narch/arc/net/bpf_jit_core.c-1133-\t\tif (!ctx-\u003ejit_data)\n--\narch/arm/common/locomo.c=220=locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info)\n--\narch/arm/common/locomo.c-224-\narch/arm/common/locomo.c:225:\tdev = kzalloc_obj(struct locomo_dev);\narch/arm/common/locomo.c-226-\tif (!dev) {\n--\narch/arm/common/locomo.c=356=__locomo_probe(struct device *me, struct resource *mem, int irq)\n--\narch/arm/common/locomo.c-362-\narch/arm/common/locomo.c:363:\tlchip = kzalloc_obj(struct locomo);\narch/arm/common/locomo.c-364-\tif (!lchip)\n--\narch/arm/common/sa1111.c=733=sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,\n--\narch/arm/common/sa1111.c-739-\narch/arm/common/sa1111.c:740:\tdev = kzalloc_obj(struct sa1111_dev);\narch/arm/common/sa1111.c-741-\tif (!dev) {\n--\narch/arm/common/scoop.c=178=static int scoop_probe(struct platform_device *pdev)\n--\narch/arm/common/scoop.c-187-\narch/arm/common/scoop.c:188:\tdevptr = kzalloc_obj(struct scoop_dev);\narch/arm/common/scoop.c-189-\tif (!devptr)\n--\narch/arm/kernel/smp.c=108=static int secondary_biglittle_prepare(unsigned int cpu)\n--\narch/arm/kernel/smp.c-110-\tif (!cpu_vtable[cpu])\narch/arm/kernel/smp.c:111:\t\tcpu_vtable[cpu] = kzalloc_obj(*cpu_vtable[cpu]);\narch/arm/kernel/smp.c-112-\n--\narch/arm/kernel/vdso.c=169=static int __init vdso_init(void)\n--\narch/arm/kernel/vdso.c-181-\t/* Allocate the VDSO text pagelist */\narch/arm/kernel/vdso.c:182:\tvdso_text_pagelist = kzalloc_objs(struct page *, text_pages);\narch/arm/kernel/vdso.c-183-\tif (vdso_text_pagelist == NULL)\n--\narch/arm/mach-footbridge/dc21285.c=261=int __init dc21285_setup(int nr, struct pci_sys_data *sys)\n--\narch/arm/mach-footbridge/dc21285.c-264-\narch/arm/mach-footbridge/dc21285.c:265:\tres = kzalloc_objs(struct resource, 2);\narch/arm/mach-footbridge/dc21285.c-266-\tif (!res) {\n--\narch/arm/mach-footbridge/ebsa285.c=69=static int __init ebsa285_leds_init(void)\n--\narch/arm/mach-footbridge/ebsa285.c-86-\narch/arm/mach-footbridge/ebsa285.c:87:\t\tled = kzalloc_obj(*led);\narch/arm/mach-footbridge/ebsa285.c-88-\t\tif (!led)\n--\narch/arm/mach-footbridge/netwinder-hw.c=720=static int __init netwinder_leds_init(void)\n--\narch/arm/mach-footbridge/netwinder-hw.c-729-\narch/arm/mach-footbridge/netwinder-hw.c:730:\t\tled = kzalloc_obj(*led);\narch/arm/mach-footbridge/netwinder-hw.c-731-\t\tif (!led)\n--\narch/arm/mach-imx/mmdc.c=473=static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_base,\n--\narch/arm/mach-imx/mmdc.c-479-\narch/arm/mach-imx/mmdc.c:480:\tpmu_mmdc = kzalloc_obj(*pmu_mmdc);\narch/arm/mach-imx/mmdc.c-481-\tif (!pmu_mmdc) {\n--\narch/arm/mach-mvebu/board-v7.c=114=static void __init i2c_quirk(void)\n--\narch/arm/mach-mvebu/board-v7.c-129-\narch/arm/mach-mvebu/board-v7.c:130:\t\tnew_compat = kzalloc_obj(*new_compat);\narch/arm/mach-mvebu/board-v7.c-131-\n--\narch/arm/mach-mvebu/coherency.c=163=static void __init armada_375_380_coherency_init(struct device_node *np)\n--\narch/arm/mach-mvebu/coherency.c-187-\narch/arm/mach-mvebu/coherency.c:188:\t\tp = kzalloc_obj(*p);\narch/arm/mach-mvebu/coherency.c-189-\t\tp-\u003ename = kstrdup(\"arm,io-coherent\", GFP_KERNEL);\n--\narch/arm/mach-mvebu/mvebu-soc-id.c=148=static int __init mvebu_soc_device(void)\n--\narch/arm/mach-mvebu/mvebu-soc-id.c-156-\narch/arm/mach-mvebu/mvebu-soc-id.c:157:\tsoc_dev_attr = kzalloc_obj(*soc_dev_attr);\narch/arm/mach-mvebu/mvebu-soc-id.c-158-\tif (!soc_dev_attr)\n--\narch/arm/mach-mxs/mach-mxs.c=380=static void __init mxs_machine_init(void)\n--\narch/arm/mach-mxs/mach-mxs.c-389-\narch/arm/mach-mxs/mach-mxs.c:390:\tsoc_dev_attr = kzalloc_obj(*soc_dev_attr);\narch/arm/mach-mxs/mach-mxs.c-391-\tif (!soc_dev_attr)\n--\narch/arm/mach-omap1/dma.c=294=static int __init omap1_system_dma_init(void)\n--\narch/arm/mach-omap1/dma.c-321-\narch/arm/mach-omap1/dma.c:322:\td = kzalloc_obj(*d);\narch/arm/mach-omap1/dma.c-323-\tif (!d) {\n--\narch/arm/mach-omap1/mcbsp.c=292=static void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,\n--\narch/arm/mach-omap1/mcbsp.c-296-\narch/arm/mach-omap1/mcbsp.c:297:\tomap_mcbsp_devices = kzalloc_objs(struct platform_device *, size);\narch/arm/mach-omap1/mcbsp.c-298-\tif (!omap_mcbsp_devices) {\n--\narch/arm/mach-omap1/timer.c=51=static int __init omap1_dm_timer_init(void)\n--\narch/arm/mach-omap1/timer.c-127-\narch/arm/mach-omap1/timer.c:128:\t\tpdata = kzalloc_obj(*pdata);\narch/arm/mach-omap1/timer.c-129-\t\tif (!pdata) {\n--\narch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c=230=void omap2xxx_clkt_vps_init(void)\n--\narch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c-239-\narch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c:240:\thw = kzalloc_obj(*hw);\narch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c-241-\tif (!hw)\n--\narch/arm/mach-omap2/id.c=786=void __init omap_soc_device_init(void)\n--\narch/arm/mach-omap2/id.c-790-\narch/arm/mach-omap2/id.c:791:\tsoc_dev_attr = kzalloc_obj(*soc_dev_attr);\narch/arm/mach-omap2/id.c-792-\tif (!soc_dev_attr)\n--\narch/arm/mach-omap2/omap_device.c=131=static int omap_device_build_from_dt(struct platform_device *pdev)\n--\narch/arm/mach-omap2/omap_device.c-158-\narch/arm/mach-omap2/omap_device.c:159:\thwmods = kzalloc_objs(struct omap_hwmod *, oh_cnt);\narch/arm/mach-omap2/omap_device.c-160-\tif (!hwmods) {\n--\narch/arm/mach-omap2/omap_hwmod.c=3381=static int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh,\n--\narch/arm/mach-omap2/omap_hwmod.c-3394-\narch/arm/mach-omap2/omap_hwmod.c:3395:\tsysc = kzalloc_obj(*sysc);\narch/arm/mach-omap2/omap_hwmod.c-3396-\tif (!sysc)\n--\narch/arm/mach-omap2/omap_hwmod.c-3424-\tif (list_empty(\u0026oh-\u003eslave_ports)) {\narch/arm/mach-omap2/omap_hwmod.c:3425:\t\toi = kzalloc_obj(*oi);\narch/arm/mach-omap2/omap_hwmod.c-3426-\t\tif (!oi)\n--\narch/arm/mach-omap2/omap_hwmod.c=3513=int omap_hwmod_init_module(struct device *dev,\n--\narch/arm/mach-omap2/omap_hwmod.c-3527-\tif (!oh) {\narch/arm/mach-omap2/omap_hwmod.c:3528:\t\toh = kzalloc_obj(*oh);\narch/arm/mach-omap2/omap_hwmod.c-3529-\t\tif (!oh)\n--\narch/arm/mach-omap2/omap_hwmod.c-3538-\narch/arm/mach-omap2/omap_hwmod.c:3539:\t\toh-\u003eclass = kzalloc_obj(*oh-\u003eclass);\narch/arm/mach-omap2/omap_hwmod.c-3540-\t\tif (!oh-\u003eclass) {\n--\narch/arm/mach-omap2/pm33xx-core.c=379=static int __init amx3_idle_init(struct device_node *cpu_node, int cpu)\n--\narch/arm/mach-omap2/pm33xx-core.c-412-\narch/arm/mach-omap2/pm33xx-core.c:413:\tidle_states = kzalloc_objs(*idle_states, state_count);\narch/arm/mach-omap2/pm33xx-core.c-414-\tif (!idle_states)\n--\narch/arm/mach-omap2/sr_device.c=30=static void __init sr_set_nvalues(struct omap_volt_data *volt_data,\n--\narch/arm/mach-omap2/sr_device.c-41-\narch/arm/mach-omap2/sr_device.c:42:\tnvalue_table = kzalloc_objs(*nvalue_table, count);\narch/arm/mach-omap2/sr_device.c-43-\tif (!nvalue_table)\n--\narch/arm/mach-orion5x/pci.c=139=static int __init pcie_setup(struct pci_sys_data *sys)\n--\narch/arm/mach-orion5x/pci.c-171-\t */\narch/arm/mach-orion5x/pci.c:172:\tres = kzalloc_obj(struct resource);\narch/arm/mach-orion5x/pci.c-173-\tif (!res)\n--\narch/arm/mach-orion5x/pci.c=466=static int __init pci_setup(struct pci_sys_data *sys)\n--\narch/arm/mach-orion5x/pci.c-492-\t */\narch/arm/mach-orion5x/pci.c:493:\tres = kzalloc_obj(struct resource);\narch/arm/mach-orion5x/pci.c-494-\tif (!res)\n--\narch/arm/mach-rpc/ecard.c=689=static struct expansion_card *__init ecard_alloc_card(int type, int slot)\n--\narch/arm/mach-rpc/ecard.c-694-\narch/arm/mach-rpc/ecard.c:695:\tec = kzalloc_obj(ecard_t);\narch/arm/mach-rpc/ecard.c-696-\tif (!ec) {\n--\narch/arm/mach-sa1100/clock.c=93=int __init sa11xx_clk_init(void)\n--\narch/arm/mach-sa1100/clock.c-109-\narch/arm/mach-sa1100/clock.c:110:\thw = kzalloc_obj(*hw);\narch/arm/mach-sa1100/clock.c-111-\tif (!hw)\n--\narch/arm/mach-sa1100/clock.c-131-\narch/arm/mach-sa1100/clock.c:132:\thw = kzalloc_obj(*hw);\narch/arm/mach-sa1100/clock.c-133-\tif (!hw)\n--\narch/arm/mach-sa1100/generic.c=317=int __init sa11x0_register_fixed_regulator(int n,\n--\narch/arm/mach-sa1100/generic.c-323-\narch/arm/mach-sa1100/generic.c:324:\tcfg-\u003einit_data = id = kzalloc_obj(*cfg-\u003einit_data);\narch/arm/mach-sa1100/generic.c-325-\tif (!cfg-\u003einit_data)\n--\narch/arm/mach-sa1100/neponset.c=225=static int neponset_probe(struct platform_device *dev)\n--\narch/arm/mach-sa1100/neponset.c-278-\narch/arm/mach-sa1100/neponset.c:279:\td = kzalloc_obj(*d);\narch/arm/mach-sa1100/neponset.c-280-\tif (!d) {\n--\narch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c=141=static int __init rcar_gen2_regulator_quirk(void)\n--\narch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c-166-\narch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c:167:\t\tquirk = kzalloc_obj(*quirk);\narch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c-168-\t\tif (!quirk) {\n--\narch/arm/mach-versatile/spc.c=393=static int ve_spc_populate_opps(uint32_t cluster)\n--\narch/arm/mach-versatile/spc.c-397-\narch/arm/mach-versatile/spc.c:398:\topps = kzalloc_objs(*opps, MAX_OPPS);\narch/arm/mach-versatile/spc.c-399-\tif (!opps)\n--\narch/arm/mach-versatile/spc.c=442=int __init ve_spc_init(void __iomem *baseaddr, u32 a15_clusid, int irq)\n--\narch/arm/mach-versatile/spc.c-444-\tint ret;\narch/arm/mach-versatile/spc.c:445:\tinfo = kzalloc_obj(*info);\narch/arm/mach-versatile/spc.c-446-\tif (!info)\n--\narch/arm/mach-versatile/spc.c=523=static struct clk *ve_spc_clk_register(struct device *cpu_dev)\n--\narch/arm/mach-versatile/spc.c-527-\narch/arm/mach-versatile/spc.c:528:\tspc = kzalloc_obj(*spc);\narch/arm/mach-versatile/spc.c-529-\tif (!spc)\n--\narch/arm/mach-versatile/versatile.c=123=static void __init versatile_dt_pci_init(void)\n--\narch/arm/mach-versatile/versatile.c-144-\narch/arm/mach-versatile/versatile.c:145:\tnewprop = kzalloc_obj(*newprop);\narch/arm/mach-versatile/versatile.c-146-\tif (!newprop)\n--\narch/arm/mach-zynq/common.c=105=static void __init zynq_init_machine(void)\n--\narch/arm/mach-zynq/common.c-110-\narch/arm/mach-zynq/common.c:111:\tsoc_dev_attr = kzalloc_obj(*soc_dev_attr);\narch/arm/mach-zynq/common.c-112-\tif (!soc_dev_attr)\n--\narch/arm/mm/cache-l2x0-pmu.c=503=static __init int l2x0_pmu_init(void)\n--\narch/arm/mm/cache-l2x0-pmu.c-509-\narch/arm/mm/cache-l2x0-pmu.c:510:\tl2x0_pmu = kzalloc_obj(*l2x0_pmu);\narch/arm/mm/cache-l2x0-pmu.c-511-\tif (!l2x0_pmu) {\n--\narch/arm/mm/cache-uniphier.c=315=static int __init __uniphier_cache_init(struct device_node *np,\n--\narch/arm/mm/cache-uniphier.c-344-\narch/arm/mm/cache-uniphier.c:345:\tdata = kzalloc_obj(*data);\narch/arm/mm/cache-uniphier.c-346-\tif (!data)\n--\narch/arm/mm/dma-mapping.c=533=static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,\n--\narch/arm/mm/dma-mapping.c-560-\narch/arm/mm/dma-mapping.c:561:\tbuf = kzalloc_obj(*buf,\narch/arm/mm/dma-mapping.c-562-\t\t\t  gfp \u0026 ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM));\n--\narch/arm/mm/dma-mapping.c=1487=arm_iommu_create_mapping(struct device *dev, dma_addr_t base, u64 size)\n--\narch/arm/mm/dma-mapping.c-1506-\narch/arm/mm/dma-mapping.c:1507:\tmapping = kzalloc_obj(struct dma_iommu_mapping);\narch/arm/mm/dma-mapping.c-1508-\tif (!mapping)\n--\narch/arm/xen/enlighten.c=316=int __init arch_xen_unpopulated_init(struct resource **res)\n--\narch/arm/xen/enlighten.c-343-\narch/arm/xen/enlighten.c:344:\tregs = kzalloc_objs(*regs, nr_reg);\narch/arm/xen/enlighten.c-345-\tif (!regs) {\n--\narch/arm/xen/enlighten.c-387-\narch/arm/xen/enlighten.c:388:\t\ttmp_res = kzalloc_obj(*tmp_res);\narch/arm/xen/enlighten.c-389-\t\tif (!tmp_res) {\n--\narch/arm/xen/p2m.c=150=bool __set_phys_to_machine_multi(unsigned long pfn,\n--\narch/arm/xen/p2m.c-178-\narch/arm/xen/p2m.c:179:\tp2m_entry = kzalloc_obj(*p2m_entry, GFP_NOWAIT);\narch/arm/xen/p2m.c-180-\tif (!p2m_entry)\n--\narch/arm64/kernel/vdso.c=68=static int __init __vdso_init(enum vdso_abi abi)\n--\narch/arm64/kernel/vdso.c-83-\narch/arm64/kernel/vdso.c:84:\tvdso_pagelist = kzalloc_objs(struct page *, vdso_info[abi].vdso_pages);\narch/arm64/kernel/vdso.c-85-\tif (vdso_pagelist == NULL)\n--\narch/arm64/kvm/mmu.c=480=static int share_pfn_hyp(u64 pfn)\n--\narch/arm64/kvm/mmu.c-492-\narch/arm64/kvm/mmu.c:493:\tthis = kzalloc_obj(*this);\narch/arm64/kvm/mmu.c-494-\tif (!this) {\n--\narch/arm64/kvm/mmu.c=981=int kvm_init_stage2_mmu(struct kvm *kvm, struct kvm_s2_mmu *mmu, unsigned long type)\n--\narch/arm64/kvm/mmu.c-1007-\narch/arm64/kvm/mmu.c:1008:\tpgt = kzalloc_obj(*pgt, GFP_KERNEL_ACCOUNT);\narch/arm64/kvm/mmu.c-1009-\tif (!pgt)\n--\narch/arm64/kvm/mmu.c=1180=int topup_hyp_memcache(struct kvm_hyp_memcache *mc, unsigned long min_pages)\n--\narch/arm64/kvm/mmu.c-1185-\tif (!mc-\u003emapping) {\narch/arm64/kvm/mmu.c:1186:\t\tmc-\u003emapping = kzalloc_obj(struct pkvm_mapping,\narch/arm64/kvm/mmu.c-1187-\t\t\t\t\t  GFP_KERNEL_ACCOUNT);\n--\narch/arm64/kvm/mmu.c=2510=int __init kvm_mmu_init(u32 hyp_va_bits)\n--\narch/arm64/kvm/mmu.c-2543-\narch/arm64/kvm/mmu.c:2544:\thyp_pgtable = kzalloc_obj(*hyp_pgtable);\narch/arm64/kvm/mmu.c-2545-\tif (!hyp_pgtable) {\n--\narch/arm64/kvm/nested.c=1327=int kvm_vcpu_allocate_vncr_tlb(struct kvm_vcpu *vcpu)\n--\narch/arm64/kvm/nested.c-1332-\tif (!vcpu-\u003earch.vncr_tlb) {\narch/arm64/kvm/nested.c:1333:\t\tstruct vncr_tlb *vt = kzalloc_obj(*vcpu-\u003earch.vncr_tlb,\narch/arm64/kvm/nested.c-1334-\t\t\t\t\t\t  GFP_KERNEL_ACCOUNT);\n--\narch/arm64/kvm/nested.c=1791=int kvm_init_nv_sysregs(struct kvm_vcpu *vcpu)\n--\narch/arm64/kvm/nested.c-1800-\narch/arm64/kvm/nested.c:1801:\tkvm-\u003earch.sysreg_masks = kzalloc_obj(*(kvm-\u003earch.sysreg_masks),\narch/arm64/kvm/nested.c-1802-\t\t\t\t\t     GFP_KERNEL_ACCOUNT);\n--\narch/arm64/kvm/ptdump.c=116=static struct kvm_ptdump_guest_state *kvm_ptdump_parser_create(struct kvm_s2_mmu *mmu)\n--\narch/arm64/kvm/ptdump.c-121-\narch/arm64/kvm/ptdump.c:122:\tst = kzalloc_obj(struct kvm_ptdump_guest_state, GFP_KERNEL_ACCOUNT);\narch/arm64/kvm/ptdump.c-123-\tif (!st)\n--\narch/arm64/kvm/vgic/vgic-init.c=207=static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)\n--\narch/arm64/kvm/vgic/vgic-init.c-213-\tdist-\u003eactive_spis = (atomic_t)ATOMIC_INIT(0);\narch/arm64/kvm/vgic/vgic-init.c:214:\tdist-\u003espis = kzalloc_objs(struct vgic_irq, nr_spis, GFP_KERNEL_ACCOUNT);\narch/arm64/kvm/vgic/vgic-init.c-215-\tif (!dist-\u003espis)\n--\narch/arm64/kvm/vgic/vgic-init.c=316=static int vgic_allocate_private_irqs_locked(struct kvm_vcpu *vcpu, u32 type)\n--\narch/arm64/kvm/vgic/vgic-init.c-331-\narch/arm64/kvm/vgic/vgic-init.c:332:\tvgic_cpu-\u003eprivate_irqs = kzalloc_objs(struct vgic_irq,\narch/arm64/kvm/vgic/vgic-init.c-333-\t\t\t\t\t      num_private_irqs,\n--\narch/arm64/kvm/vgic/vgic-irqfd.c=142=int kvm_vgic_setup_default_irq_routing(struct kvm *kvm)\n--\narch/arm64/kvm/vgic/vgic-irqfd.c-148-\narch/arm64/kvm/vgic/vgic-irqfd.c:149:\tentries = kzalloc_objs(*entries, nr, GFP_KERNEL_ACCOUNT);\narch/arm64/kvm/vgic/vgic-irqfd.c-150-\tif (!entries)\n--\narch/arm64/kvm/vgic/vgic-its.c=76=static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,\n--\narch/arm64/kvm/vgic/vgic-its.c-87-\narch/arm64/kvm/vgic/vgic-its.c:88:\tirq = kzalloc_obj(struct vgic_irq, GFP_KERNEL_ACCOUNT);\narch/arm64/kvm/vgic/vgic-its.c-89-\tif (!irq)\n--\narch/arm64/kvm/vgic/vgic-its.c=960=static int vgic_its_alloc_collection(struct vgic_its *its,\n--\narch/arm64/kvm/vgic/vgic-its.c-965-\narch/arm64/kvm/vgic/vgic-its.c:966:\tcollection = kzalloc_obj(*collection, GFP_KERNEL_ACCOUNT);\narch/arm64/kvm/vgic/vgic-its.c-967-\tif (!collection)\n--\narch/arm64/kvm/vgic/vgic-its.c=1004=static struct its_ite *vgic_its_alloc_ite(struct its_device *device,\n--\narch/arm64/kvm/vgic/vgic-its.c-1009-\narch/arm64/kvm/vgic/vgic-its.c:1010:\tite = kzalloc_obj(*ite, GFP_KERNEL_ACCOUNT);\narch/arm64/kvm/vgic/vgic-its.c-1011-\tif (!ite)\n--\narch/arm64/kvm/vgic/vgic-its.c=1131=static struct its_device *vgic_its_alloc_device(struct vgic_its *its,\n--\narch/arm64/kvm/vgic/vgic-its.c-1136-\narch/arm64/kvm/vgic/vgic-its.c:1137:\tdevice = kzalloc_obj(*device, GFP_KERNEL_ACCOUNT);\narch/arm64/kvm/vgic/vgic-its.c-1138-\tif (!device)\n--\narch/arm64/kvm/vgic/vgic-its.c=1844=static int vgic_its_create(struct kvm_device *dev, u32 type)\n--\narch/arm64/kvm/vgic/vgic-its.c-1851-\narch/arm64/kvm/vgic/vgic-its.c:1852:\tits = kzalloc_obj(struct vgic_its, GFP_KERNEL_ACCOUNT);\narch/arm64/kvm/vgic/vgic-its.c-1853-\tif (!its)\n--\narch/arm64/kvm/vgic/vgic-mmio-v3.c=886=static int vgic_v3_alloc_redist_region(struct kvm *kvm, uint32_t index,\n--\narch/arm64/kvm/vgic/vgic-mmio-v3.c-931-\narch/arm64/kvm/vgic/vgic-mmio-v3.c:932:\trdreg = kzalloc_obj(*rdreg, GFP_KERNEL_ACCOUNT);\narch/arm64/kvm/vgic/vgic-mmio-v3.c-933-\tif (!rdreg)\n--\narch/arm64/kvm/vgic/vgic-v4.c=242=int vgic_v4_init(struct kvm *kvm)\n--\narch/arm64/kvm/vgic/vgic-v4.c-258-\narch/arm64/kvm/vgic/vgic-v4.c:259:\tdist-\u003eits_vm.vpes = kzalloc_objs(*dist-\u003eits_vm.vpes, nr_vcpus,\narch/arm64/kvm/vgic/vgic-v4.c-260-\t\t\t\t\t GFP_KERNEL_ACCOUNT);\n--\narch/arm64/net/bpf_jit_comp.c=2080=struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_prog *prog)\n--\narch/arm64/net/bpf_jit_comp.c-2101-\tif (!jit_data) {\narch/arm64/net/bpf_jit_comp.c:2102:\t\tjit_data = kzalloc_obj(*jit_data);\narch/arm64/net/bpf_jit_comp.c-2103-\t\tif (!jit_data)\n--\narch/csky/kernel/vdso.c=17=static int __init vdso_init(void)\n--\narch/csky/kernel/vdso.c-22-\tvdso_pagelist =\narch/csky/kernel/vdso.c:23:\t\tkzalloc_objs(struct page *, vdso_pages);\narch/csky/kernel/vdso.c-24-\tif (unlikely(vdso_pagelist == NULL)) {\n--\narch/loongarch/kernel/setup.c=466=static int __init add_legacy_isa_io(struct fwnode_handle *fwnode,\n--\narch/loongarch/kernel/setup.c-472-\narch/loongarch/kernel/setup.c:473:\trange = kzalloc_obj(*range, GFP_ATOMIC);\narch/loongarch/kernel/setup.c-474-\tif (!range)\n--\narch/loongarch/kernel/vdso.c=45=static int __init init_vdso(void)\n--\narch/loongarch/kernel/vdso.c-55-\tvdso_info.code_mapping.pages =\narch/loongarch/kernel/vdso.c:56:\t\tkzalloc_objs(struct page *, vdso_info.size / PAGE_SIZE);\narch/loongarch/kernel/vdso.c-57-\n--\narch/loongarch/kvm/intc/eiointc.c=614=static int kvm_eiointc_create(struct kvm_device *dev, u32 type)\n--\narch/loongarch/kvm/intc/eiointc.c-624-\narch/loongarch/kvm/intc/eiointc.c:625:\ts = kzalloc_obj(struct loongarch_eiointc);\narch/loongarch/kvm/intc/eiointc.c-626-\tif (!s)\n--\narch/loongarch/kvm/intc/ipi.c=394=static int kvm_ipi_create(struct kvm_device *dev, u32 type)\n--\narch/loongarch/kvm/intc/ipi.c-411-\narch/loongarch/kvm/intc/ipi.c:412:\ts = kzalloc_obj(struct loongarch_ipi);\narch/loongarch/kvm/intc/ipi.c-413-\tif (!s)\n\n"
}

9/3 2026/08/10 14:05 llm kmsan-evaluator
7m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 122171
							output: 30
							thoughts: 62915
						

10/3 2026/08/10 14:13 tool grepper
0m Args:
{
  "Expression": "kzalloc_obj",
  "PathPrefix": "drivers/net/usb/"
}

Results:
{
  "Output": "drivers/net/usb/aqc111.c=685=static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/aqc111.c-705-\ndrivers/net/usb/aqc111.c:706:\taqc111_data = kzalloc_obj(*aqc111_data);\ndrivers/net/usb/aqc111.c-707-\tif (!aqc111_data)\n--\ndrivers/net/usb/asix_devices.c=1271=static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/asix_devices.c-1318-\ndrivers/net/usb/asix_devices.c:1319:\tdev-\u003edriver_priv = kzalloc_obj(struct asix_common_private);\ndrivers/net/usb/asix_devices.c-1320-\tif (!dev-\u003edriver_priv)\n--\ndrivers/net/usb/ax88172a.c=158=static int ax88172a_bind(struct usbnet *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/ax88172a.c-167-\ndrivers/net/usb/ax88172a.c:168:\tpriv = kzalloc_obj(*priv);\ndrivers/net/usb/ax88172a.c-169-\tif (!priv)\n--\ndrivers/net/usb/ax88179_178a.c=672=static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/ax88179_178a.c-680-\ndrivers/net/usb/ax88179_178a.c:681:\tax179_data = kzalloc_obj(*ax179_data);\ndrivers/net/usb/ax88179_178a.c-682-\tif (!ax179_data)\n--\ndrivers/net/usb/ax88179a_devices.c=728=static int ax88179a_bind(struct usbnet *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/ax88179a_devices.c-745-\ndrivers/net/usb/ax88179a_devices.c:746:\tax179_data = kzalloc_obj(*ax179_data);\ndrivers/net/usb/ax88179a_devices.c-747-\tif (!ax179_data)\n--\ndrivers/net/usb/cdc_ncm.c=820=int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting, int drvflags)\n--\ndrivers/net/usb/cdc_ncm.c-829-\ndrivers/net/usb/cdc_ncm.c:830:\tctx = kzalloc_obj(*ctx);\ndrivers/net/usb/cdc_ncm.c-831-\tif (!ctx)\n--\ndrivers/net/usb/cx82310_eth.c=141=static int cx82310_bind(struct usbnet *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/cx82310_eth.c-175-\ndrivers/net/usb/cx82310_eth.c:176:\tpriv = kzalloc_obj(*priv);\ndrivers/net/usb/cx82310_eth.c-177-\tif (!priv) {\n--\ndrivers/net/usb/hso.c=2309=static struct hso_device *hso_create_device(struct usb_interface *intf,\n--\ndrivers/net/usb/hso.c-2313-\ndrivers/net/usb/hso.c:2314:\thso_dev = kzalloc_obj(*hso_dev);\ndrivers/net/usb/hso.c-2315-\tif (!hso_dev)\n--\ndrivers/net/usb/hso.c=2601=static struct hso_device *hso_create_bulk_serial_device(\n--\ndrivers/net/usb/hso.c-2614-\ndrivers/net/usb/hso.c:2615:\tserial = kzalloc_obj(*serial);\ndrivers/net/usb/hso.c-2616-\tif (!serial)\n--\ndrivers/net/usb/hso.c-2623-\t\tnum_urbs = 2;\ndrivers/net/usb/hso.c:2624:\t\tserial-\u003etiocmget = kzalloc_obj(struct hso_tiocmget);\ndrivers/net/usb/hso.c-2625-\t\tif (!serial-\u003etiocmget)\n--\ndrivers/net/usb/hso.c-2627-\t\tserial-\u003etiocmget-\u003eserial_state_notification\ndrivers/net/usb/hso.c:2628:\t\t\t= kzalloc_obj(struct hso_serial_state_notification);\ndrivers/net/usb/hso.c-2629-\t\tif (!serial-\u003etiocmget-\u003eserial_state_notification)\n--\ndrivers/net/usb/hso.c=2679=struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface,\n--\ndrivers/net/usb/hso.c-2697-\ndrivers/net/usb/hso.c:2698:\tserial = kzalloc_obj(*serial);\ndrivers/net/usb/hso.c-2699-\tif (!serial)\n--\ndrivers/net/usb/hso.c=2740=struct hso_shared_int *hso_create_shared_int(struct usb_interface *interface)\ndrivers/net/usb/hso.c-2741-{\ndrivers/net/usb/hso.c:2742:\tstruct hso_shared_int *mux = kzalloc_obj(*mux);\ndrivers/net/usb/hso.c-2743-\tint ret;\n--\ndrivers/net/usb/lan78xx.c=3752=static int lan78xx_bind(struct lan78xx_net *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/lan78xx.c-3757-\ndrivers/net/usb/lan78xx.c:3758:\tdev-\u003edata[0] = (unsigned long) kzalloc_obj(*pdata);\ndrivers/net/usb/lan78xx.c-3759-\n--\ndrivers/net/usb/lg-vl600.c=56=static int vl600_bind(struct usbnet *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/lg-vl600.c-58-\tint ret;\ndrivers/net/usb/lg-vl600.c:59:\tstruct vl600_state *s = kzalloc_obj(struct vl600_state);\ndrivers/net/usb/lg-vl600.c-60-\n--\ndrivers/net/usb/sierra_net.c=650=static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/sierra_net.c-685-\t/* Initialize sierra private data */\ndrivers/net/usb/sierra_net.c:686:\tpriv = kzalloc_obj(*priv);\ndrivers/net/usb/sierra_net.c-687-\tif (!priv)\n--\ndrivers/net/usb/smsc75xx.c=1442=static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/smsc75xx.c-1452-\ndrivers/net/usb/smsc75xx.c:1453:\tdev-\u003edata[0] = (unsigned long) kzalloc_obj(struct smsc75xx_priv);\ndrivers/net/usb/smsc75xx.c-1454-\n--\ndrivers/net/usb/smsc95xx.c=1147=static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/smsc95xx.c-1159-\ndrivers/net/usb/smsc95xx.c:1160:\tpdata = kzalloc_obj(*pdata);\ndrivers/net/usb/smsc95xx.c-1161-\tif (!pdata)\n"
}

11/3 2026/08/10 14:13 llm kmsan-evaluator
1m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 187378
							output: 454
							thoughts: 9479
						

Thoughts:
**Uninitialized Memory Vulnerabilities in USB Network Driver**

Okay, after carefully examining this code, it's clear that the primary concern here revolves around potential uses of uninitialized memory, specifically within the newly introduced `ax88179a_devices.c` functions. The `ax88179_read_cmd` function, when reading 1-byte register values from the USB device (size=1), presents a critical vulnerability. If the USB control message fails—and this could easily happen due to a device disconnect, temporary communication issues, or device-side errors—the `ax88179_read_cmd` function returns an error, but crucially, it *doesn't* initialize the 1-byte local variable. The subsequent code then proceeds to use these uninitialized variables as if they hold valid data, without checking the return value of `ax88179_read_cmd` to see if a failure occurred.

Several functions demonstrate this dangerous pattern:

*   `ax88179a_mac_link_up()`: The code reads into the `link_sts` variable and uses it within `ax88179a_bulkin_config()`. This function then branches based on bits in `link_sts`, which are essentially random garbage if the read fails. This is a classic example of branching on uninitialized memory.
*   `ax88179a_resume()`: The code reads into the `reg8` variable, and then branches using `!(reg8 & AX_PHY_POWER)`. Again, if the read fails, this branch condition depends on undefined values.
*   `ax88179a_set_features()`: This reads into `tmp`, XORs the uninitialized value with constants, and then attempts to *write* this junk to the device. This could lead to unpredictable device behavior.
*   `ax88179a_vlan_rx_kill_vid()` and `ax88179a_vlan_rx_add_vid()`: These similar functions read into `reg8` (size 1). It uses this to compute the `vlan_ctrl` value, which is then written to a register. The `vlan_ctrl` value would contain garbage, if `ax88179_read_cmd` fails.
*   `ax88179a_suspend()`: Reads to `tmp8`, it modifies this variable (which could be uninitialized) and writes it back to a device register.

KASAN will not detect these memory safety violations, since this is not an out-of-bounds access or use-after-free issue. Instead, this bug is use of uninitialized stack memory. KMSAN is the correct tool to detect such issues. Since the error-handling path is the source of the issue, we expect this KMSAN issue to be easily reached by unplugging and plugging the network adapter.

Given these findings, a focused KMSAN fuzzing session is mandatory.



12/3 2026/08/10 14:15 tool set-results
0m Args:
{
  "KMSANReasoning": "The patch introduces several new functions in `ax88179a_devices.c` that read 1-byte registers from the USB device using `ax88179_read_cmd(..., size=1, \u0026var)`. If the USB control message fails (e.g., due to a device error or disconnect), `ax88179_read_cmd` returns an error code but leaves the 1-byte local variable uninitialized.\n\nThe code then proceeds to use these uninitialized variables without checking the return value of `ax88179_read_cmd`. Examples include:\n1. `ax88179a_mac_link_up()`: reads into `link_sts` and passes it to `ax88179a_bulkin_config()`, which branches on `link_sts \u0026 AX_USB_SS`.\n2. `ax88179a_resume()`: reads into `reg8` and branches on `!(reg8 \u0026 AX_PHY_POWER)`.\n3. `ax88179a_set_features()`: reads into `tmp`, XORs it, and writes it back to the device.\n4. `ax88179a_vlan_rx_kill_vid()` / `ax88179a_vlan_rx_add_vid()`: reads into `reg8`, assigns to `vlan_ctrl`, and writes it back.\n5. `ax88179a_suspend()`: reads into `tmp8`, modifies it, and writes it back.\n\nThese are classic uninitialized memory uses (branching on uninitialized values and writing uninitialized stack memory to the device). KASAN cannot detect these because they are not out-of-bounds accesses or use-after-frees. Only KMSAN tracks the initialization state of stack variables and can catch these bugs. Therefore, a dedicated KMSAN fuzzing session is highly justified.",
  "NeedsKMSAN": true
}

Results:
{
  "KMSANReasoning": "The patch introduces several new functions in `ax88179a_devices.c` that read 1-byte registers from the USB device using `ax88179_read_cmd(..., size=1, \u0026var)`. If the USB control message fails (e.g., due to a device error or disconnect), `ax88179_read_cmd` returns an error code but leaves the 1-byte local variable uninitialized.\n\nThe code then proceeds to use these uninitialized variables without checking the return value of `ax88179_read_cmd`. Examples include:\n1. `ax88179a_mac_link_up()`: reads into `link_sts` and passes it to `ax88179a_bulkin_config()`, which branches on `link_sts \u0026 AX_USB_SS`.\n2. `ax88179a_resume()`: reads into `reg8` and branches on `!(reg8 \u0026 AX_PHY_POWER)`.\n3. `ax88179a_set_features()`: reads into `tmp`, XORs it, and writes it back to the device.\n4. `ax88179a_vlan_rx_kill_vid()` / `ax88179a_vlan_rx_add_vid()`: reads into `reg8`, assigns to `vlan_ctrl`, and writes it back.\n5. `ax88179a_suspend()`: reads into `tmp8`, modifies it, and writes it back.\n\nThese are classic uninitialized memory uses (branching on uninitialized values and writing uninitialized stack memory to the device). KASAN cannot detect these because they are not out-of-bounds accesses or use-after-frees. Only KMSAN tracks the initialization state of stack variables and can catch these bugs. Therefore, a dedicated KMSAN fuzzing session is highly justified.",
  "NeedsKMSAN": true
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)