Lines Matching +full:5 +full:gbase +full:- +full:x

1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Aquantia Corp. Aquantia AQtion USB to 5GbE Controller
3 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
5 * Copyright (C) 2002-2003 TiVo Inc.
6 * Copyright (C) 2017-2018 ASIX
34 netdev_warn(dev->net, in aqc111_read_cmd_nopm()
35 "Failed to read(0x%x) reg index 0x%04x: %d\n", in aqc111_read_cmd_nopm()
50 netdev_warn(dev->net, in aqc111_read_cmd()
51 "Failed to read(0x%x) reg index 0x%04x: %d\n", in aqc111_read_cmd()
82 int err = -ENOMEM; in __aqc111_write_cmd()
85 netdev_dbg(dev->net, in __aqc111_write_cmd()
86 "%s cmd=%#x reqtype=%#x value=%#x index=%#x size=%d\n", in __aqc111_write_cmd()
95 err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), in __aqc111_write_cmd()
101 netdev_warn(dev->net, in __aqc111_write_cmd()
102 "Failed to write(0x%x) reg index 0x%04x: %d\n", in __aqc111_write_cmd()
126 if (usb_autopm_get_interface(dev->intf) < 0) in aqc111_write_cmd()
127 return -ENODEV; in aqc111_write_cmd()
132 usb_autopm_put_interface(dev->intf); in aqc111_write_cmd()
200 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_get_drvinfo()
204 strscpy(info->driver, DRIVER_NAME, sizeof(info->driver)); in aqc111_get_drvinfo()
205 snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u.%u", in aqc111_get_drvinfo()
206 aqc111_data->fw_ver.major, in aqc111_get_drvinfo()
207 aqc111_data->fw_ver.minor, in aqc111_get_drvinfo()
208 aqc111_data->fw_ver.rev); in aqc111_get_drvinfo()
209 info->eedump_len = 0x00; in aqc111_get_drvinfo()
210 info->regdump_len = 0x00; in aqc111_get_drvinfo()
217 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_get_wol()
219 wolinfo->supported = WAKE_MAGIC; in aqc111_get_wol()
220 wolinfo->wolopts = 0; in aqc111_get_wol()
222 if (aqc111_data->wol_flags & AQ_WOL_FLAG_MP) in aqc111_get_wol()
223 wolinfo->wolopts |= WAKE_MAGIC; in aqc111_get_wol()
230 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_set_wol()
232 if (wolinfo->wolopts & ~WAKE_MAGIC) in aqc111_set_wol()
233 return -EINVAL; in aqc111_set_wol()
235 aqc111_data->wol_flags = 0; in aqc111_set_wol()
236 if (wolinfo->wolopts & WAKE_MAGIC) in aqc111_set_wol()
237 aqc111_data->wol_flags |= AQ_WOL_FLAG_MP; in aqc111_set_wol()
269 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_get_link_ksettings()
270 enum usb_device_speed usb_speed = dev->udev->speed; in aqc111_get_link_ksettings()
287 elk->base.port = PORT_TP; in aqc111_get_link_ksettings()
288 elk->base.transceiver = XCVR_INTERNAL; in aqc111_get_link_ksettings()
290 elk->base.mdio_support = 0x00; /*Not supported*/ in aqc111_get_link_ksettings()
292 if (aqc111_data->autoneg) in aqc111_get_link_ksettings()
293 linkmode_copy(elk->link_modes.advertising, in aqc111_get_link_ksettings()
294 elk->link_modes.supported); in aqc111_get_link_ksettings()
296 aqc111_speed_to_link_mode(aqc111_data->advertised_speed, elk); in aqc111_get_link_ksettings()
298 elk->base.autoneg = aqc111_data->autoneg; in aqc111_get_link_ksettings()
300 switch (aqc111_data->link_speed) { in aqc111_get_link_ksettings()
314 elk->base.duplex = DUPLEX_FULL; in aqc111_get_link_ksettings()
315 elk->base.speed = speed; in aqc111_get_link_ksettings()
322 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_set_phy_speed()
324 aqc111_data->phy_cfg &= ~AQ_ADV_MASK; in aqc111_set_phy_speed()
325 aqc111_data->phy_cfg |= AQ_PAUSE; in aqc111_set_phy_speed()
326 aqc111_data->phy_cfg |= AQ_ASYM_PAUSE; in aqc111_set_phy_speed()
327 aqc111_data->phy_cfg |= AQ_DOWNSHIFT; in aqc111_set_phy_speed()
328 aqc111_data->phy_cfg &= ~AQ_DSH_RETRIES_MASK; in aqc111_set_phy_speed()
329 aqc111_data->phy_cfg |= (3 << AQ_DSH_RETRIES_SHIFT) & in aqc111_set_phy_speed()
335 aqc111_data->phy_cfg |= AQ_ADV_5G; in aqc111_set_phy_speed()
338 aqc111_data->phy_cfg |= AQ_ADV_2G5; in aqc111_set_phy_speed()
341 aqc111_data->phy_cfg |= AQ_ADV_1G; in aqc111_set_phy_speed()
344 aqc111_data->phy_cfg |= AQ_ADV_100M; in aqc111_set_phy_speed()
345 /* fall-through */ in aqc111_set_phy_speed()
350 aqc111_data->phy_cfg |= AQ_ADV_5G; in aqc111_set_phy_speed()
353 aqc111_data->phy_cfg |= AQ_ADV_2G5; in aqc111_set_phy_speed()
356 aqc111_data->phy_cfg |= AQ_ADV_1G; in aqc111_set_phy_speed()
359 aqc111_data->phy_cfg |= AQ_ADV_100M; in aqc111_set_phy_speed()
364 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &aqc111_data->phy_cfg); in aqc111_set_phy_speed()
371 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_set_link_ksettings()
372 enum usb_device_speed usb_speed = dev->udev->speed; in aqc111_set_link_ksettings()
373 u8 autoneg = elk->base.autoneg; in aqc111_set_link_ksettings()
374 u32 speed = elk->base.speed; in aqc111_set_link_ksettings()
377 if (aqc111_data->autoneg != AUTONEG_ENABLE) { in aqc111_set_link_ksettings()
378 aqc111_data->autoneg = AUTONEG_ENABLE; in aqc111_set_link_ksettings()
379 aqc111_data->advertised_speed = in aqc111_set_link_ksettings()
382 aqc111_set_phy_speed(dev, aqc111_data->autoneg, in aqc111_set_link_ksettings()
383 aqc111_data->advertised_speed); in aqc111_set_link_ksettings()
391 return -EINVAL; in aqc111_set_link_ksettings()
393 if (elk->base.duplex != DUPLEX_FULL) in aqc111_set_link_ksettings()
394 return -EINVAL; in aqc111_set_link_ksettings()
397 return -EINVAL; in aqc111_set_link_ksettings()
399 aqc111_data->autoneg = AUTONEG_DISABLE; in aqc111_set_link_ksettings()
401 aqc111_data->advertised_speed = speed; in aqc111_set_link_ksettings()
403 aqc111_set_phy_speed(dev, aqc111_data->autoneg, in aqc111_set_link_ksettings()
404 aqc111_data->advertised_speed); in aqc111_set_link_ksettings()
425 u8 buf[5]; in aqc111_change_mtu()
427 WRITE_ONCE(net->mtu, new_mtu); in aqc111_change_mtu()
428 dev->hard_mtu = net->mtu + net->hard_header_len; in aqc111_change_mtu()
432 if (net->mtu > 1500) in aqc111_change_mtu()
440 if (dev->net->mtu > 12500) { in aqc111_change_mtu()
441 memcpy(buf, &AQC111_BULKIN_SIZE[2], 5); in aqc111_change_mtu()
444 5, 5, buf); in aqc111_change_mtu()
448 if (dev->net->mtu <= 4500) in aqc111_change_mtu()
450 else if (dev->net->mtu <= 9500) in aqc111_change_mtu()
452 else if (dev->net->mtu <= 12500) in aqc111_change_mtu()
474 ETH_ALEN, net->dev_addr); in aqc111_set_mac_addr()
531 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_set_rx_mode()
536 aqc111_data->rxctl &= ~(SFR_RX_CTL_PRO | SFR_RX_CTL_AMALL | in aqc111_set_rx_mode()
539 if (net->flags & IFF_PROMISC) { in aqc111_set_rx_mode()
540 aqc111_data->rxctl |= SFR_RX_CTL_PRO; in aqc111_set_rx_mode()
541 } else if ((net->flags & IFF_ALLMULTI) || mc_count > AQ_MAX_MCAST) { in aqc111_set_rx_mode()
542 aqc111_data->rxctl |= SFR_RX_CTL_AMALL; in aqc111_set_rx_mode()
549 crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; in aqc111_set_rx_mode()
558 aqc111_data->rxctl |= SFR_RX_CTL_AM; in aqc111_set_rx_mode()
562 2, &aqc111_data->rxctl); in aqc111_set_rx_mode()
569 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_set_features()
570 netdev_features_t changed = net->features ^ features; in aqc111_set_features()
591 aqc111_data->rx_checksum = 1; in aqc111_set_features()
595 aqc111_data->rx_checksum = 0; in aqc111_set_features()
663 ether_addr_copy(dev->net->perm_addr, buf); in aqc111_read_perm_mac()
674 1, 1, &aqc111_data->fw_ver.major); in aqc111_read_fw_version()
676 1, 1, &aqc111_data->fw_ver.minor); in aqc111_read_fw_version()
678 1, 1, &aqc111_data->fw_ver.rev); in aqc111_read_fw_version()
680 if (aqc111_data->fw_ver.major & 0x80) in aqc111_read_fw_version()
681 aqc111_data->fw_ver.major &= ~0x80; in aqc111_read_fw_version()
687 enum usb_device_speed usb_speed = udev->speed; in aqc111_bind()
692 if (udev->actconfig->desc.bConfigurationValue != 1) { in aqc111_bind()
694 return -ENODEV; in aqc111_bind()
697 usb_reset_configuration(dev->udev); in aqc111_bind()
701 netdev_dbg(dev->net, "usbnet_get_endpoints failed"); in aqc111_bind()
707 return -ENOMEM; in aqc111_bind()
710 dev->driver_priv = aqc111_data; in aqc111_bind()
717 eth_hw_addr_set(dev->net, dev->net->perm_addr); in aqc111_bind()
720 dev->rx_urb_size = URB_SIZE; in aqc111_bind()
723 dev->net->needed_headroom += sizeof(u64); in aqc111_bind()
724 dev->net->needed_tailroom += sizeof(u64); in aqc111_bind()
726 dev->net->max_mtu = 16334; in aqc111_bind()
728 dev->net->netdev_ops = &aqc111_netdev_ops; in aqc111_bind()
729 dev->net->ethtool_ops = &aqc111_ethtool_ops; in aqc111_bind()
731 if (usb_device_no_sg_constraint(dev->udev)) in aqc111_bind()
732 dev->can_dma_sg = 1; in aqc111_bind()
734 dev->net->hw_features |= AQ_SUPPORT_HW_FEATURE; in aqc111_bind()
735 dev->net->features |= AQ_SUPPORT_FEATURE; in aqc111_bind()
736 dev->net->vlan_features |= AQ_SUPPORT_VLAN_FEATURE; in aqc111_bind()
738 netif_set_tso_max_size(dev->net, 65535); in aqc111_bind()
741 aqc111_data->autoneg = AUTONEG_ENABLE; in aqc111_bind()
742 aqc111_data->advertised_speed = (usb_speed == USB_SPEED_SUPER) ? in aqc111_bind()
754 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_unbind()
766 aqc111_data->phy_cfg &= ~AQ_ADV_MASK; in aqc111_unbind()
767 aqc111_data->phy_cfg |= AQ_LOW_POWER; in aqc111_unbind()
768 aqc111_data->phy_cfg &= ~AQ_PHY_POWER_EN; in aqc111_unbind()
770 &aqc111_data->phy_cfg); in aqc111_unbind()
777 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_status()
781 if (urb->actual_length < sizeof(*event_data)) in aqc111_status()
784 event_data = urb->transfer_buffer; in aqc111_status()
792 aqc111_data->link_speed = (*event_data & AQ_SPEED_MASK) >> in aqc111_status()
794 aqc111_data->link = link; in aqc111_status()
796 if (netif_carrier_ok(dev->net) != link) in aqc111_status()
803 enum usb_device_speed usb_speed = dev->udev->speed; in aqc111_configure_rx()
805 u8 buf[5] = { 0 }; in aqc111_configure_rx()
813 switch (aqc111_data->link_speed) { in aqc111_configure_rx()
858 if (dev->net->mtu > 12500 && dev->net->mtu <= 16334) in aqc111_configure_rx()
861 memcpy(buf, &AQC111_BULKIN_SIZE[queue_num], 5); in aqc111_configure_rx()
863 aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_RX_BULKIN_QCTRL, 5, 5, buf); in aqc111_configure_rx()
866 if (dev->net->mtu <= 4500) in aqc111_configure_rx()
868 else if (dev->net->mtu <= 9500) in aqc111_configure_rx()
870 else if (dev->net->mtu <= 12500) in aqc111_configure_rx()
872 else if (dev->net->mtu <= 16334) in aqc111_configure_rx()
877 netdev_info(dev->net, "Link Speed %d, USB %d", link_speed, usb_host); in aqc111_configure_rx()
884 if (dev->net->features & NETIF_F_RXCSUM) { in aqc111_configure_csum_offload()
891 if (dev->net->features & NETIF_F_IP_CSUM) in aqc111_configure_csum_offload()
894 if (dev->net->features & NETIF_F_IPV6_CSUM) in aqc111_configure_csum_offload()
902 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_link_reset()
906 if (aqc111_data->link == 1) { /* Link up */ in aqc111_link_reset()
911 if (dev->net->features & NETIF_F_HW_VLAN_CTAG_FILTER) in aqc111_link_reset()
927 aqc111_data->rxctl = reg16; in aqc111_link_reset()
948 aqc111_set_rx_mode(dev->net); in aqc111_link_reset()
953 if (dev->net->mtu > 1500) in aqc111_link_reset()
961 aqc111_data->rxctl |= SFR_RX_CTL_START; in aqc111_link_reset()
963 2, &aqc111_data->rxctl); in aqc111_link_reset()
965 netif_carrier_on(dev->net); in aqc111_link_reset()
973 aqc111_data->rxctl &= ~SFR_RX_CTL_START; in aqc111_link_reset()
975 2, &aqc111_data->rxctl); in aqc111_link_reset()
984 netif_carrier_off(dev->net); in aqc111_link_reset()
991 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_reset()
994 dev->rx_urb_size = URB_SIZE; in aqc111_reset()
996 if (usb_device_no_sg_constraint(dev->udev)) in aqc111_reset()
997 dev->can_dma_sg = 1; in aqc111_reset()
999 dev->net->hw_features |= AQ_SUPPORT_HW_FEATURE; in aqc111_reset()
1000 dev->net->features |= AQ_SUPPORT_FEATURE; in aqc111_reset()
1001 dev->net->vlan_features |= AQ_SUPPORT_VLAN_FEATURE; in aqc111_reset()
1004 aqc111_data->phy_cfg = AQ_PHY_POWER_EN; in aqc111_reset()
1006 &aqc111_data->phy_cfg); in aqc111_reset()
1010 ETH_ALEN, dev->net->dev_addr); in aqc111_reset()
1024 netif_carrier_off(dev->net); in aqc111_reset()
1027 aqc111_set_phy_speed(dev, aqc111_data->autoneg, in aqc111_reset()
1028 aqc111_data->advertised_speed); in aqc111_reset()
1035 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_stop()
1047 aqc111_data->phy_cfg |= AQ_LOW_POWER; in aqc111_stop()
1049 &aqc111_data->phy_cfg); in aqc111_stop()
1051 netif_carrier_off(dev->net); in aqc111_stop()
1060 skb->ip_summed = CHECKSUM_NONE; in aqc111_rx_checksum()
1068 skb->ip_summed = CHECKSUM_UNNECESSARY; in aqc111_rx_checksum()
1073 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_rx_fixup()
1087 skb_len = skb->len; in aqc111_rx_fixup()
1092 skb_trim(skb, skb_len - sizeof(desc_hdr)); in aqc111_rx_fixup()
1099 start_of_descs = skb_len - ((pkt_count + 1) * sizeof(desc_hdr)); in aqc111_rx_fixup()
1118 pkt_desc_ptr = (u64 *)(skb->data + desc_offset); in aqc111_rx_fixup()
1120 while (pkt_count--) { in aqc111_rx_fixup()
1137 pkt_len > (dev->hard_mtu + AQ_RX_HW_PAD)) { in aqc111_rx_fixup()
1144 new_skb = netdev_alloc_skb_ip_align(dev->net, pkt_len); in aqc111_rx_fixup()
1150 memcpy(new_skb->data, skb->data, pkt_len); in aqc111_rx_fixup()
1153 if (aqc111_data->rx_checksum) in aqc111_rx_fixup()
1183 int frame_size = dev->maxpacket; in aqc111_tx_fixup()
1193 tx_desc |= skb->len & AQ_TX_DESC_LEN_MASK; in aqc111_tx_fixup()
1196 tx_desc |= ((u64)(skb_shinfo(skb)->gso_size & AQ_TX_DESC_MSS_MASK)) << in aqc111_tx_fixup()
1199 headroom = (skb->len + sizeof(tx_desc)) % 8; in aqc111_tx_fixup()
1201 padding_size = 8 - headroom; in aqc111_tx_fixup()
1203 if (((skb->len + sizeof(tx_desc) + padding_size) % frame_size) == 0) { in aqc111_tx_fixup()
1215 if (!dev->can_dma_sg && (dev->net->features & NETIF_F_SG) && in aqc111_tx_fixup()
1242 .description = "Aquantia AQtion USB to 5GbE Controller",
1256 "ASIX USB 3.1 Gen1 to 5G Multi-Gigabit Ethernet Adapter"
1275 "ASIX USB 3.1 Gen1 to 2.5G Multi-Gigabit Ethernet Adapter"
1294 .description = "USB-C 3.1 to 5GBASE-T Ethernet Adapter",
1308 .description = "QNAP QNA-UC5G1T USB to 5GbE Adapter",
1324 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_suspend()
1356 if (aqc111_data->wol_flags) { in aqc111_suspend()
1361 aqc111_data->phy_cfg |= AQ_WOL; in aqc111_suspend()
1362 ether_addr_copy(wol_cfg.hw_addr, dev->net->dev_addr); in aqc111_suspend()
1363 wol_cfg.flags = aqc111_data->wol_flags; in aqc111_suspend()
1400 &aqc111_data->phy_cfg); in aqc111_suspend()
1402 aqc111_data->phy_cfg |= AQ_LOW_POWER; in aqc111_suspend()
1404 &aqc111_data->phy_cfg); in aqc111_suspend()
1420 struct aqc111_data *aqc111_data = dev->driver_priv; in aqc111_resume()
1424 netif_carrier_off(dev->net); in aqc111_resume()
1427 aqc111_data->phy_cfg |= AQ_PHY_POWER_EN; in aqc111_resume()
1428 aqc111_data->phy_cfg &= ~AQ_LOW_POWER; in aqc111_resume()
1429 aqc111_data->phy_cfg &= ~AQ_WOL; in aqc111_resume()
1435 reg16 = aqc111_data->rxctl; in aqc111_resume()
1442 aqc111_set_phy_speed(dev, aqc111_data->autoneg, in aqc111_resume()
1443 aqc111_data->advertised_speed); in aqc111_resume()
1491 MODULE_DESCRIPTION("Aquantia AQtion USB to 5/2.5GbE Controllers");