• Home
  • Raw
  • Download

Lines Matching +full:aldps +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0-only
32 /* Information for net-next */
679 #define RTL_ADV2_5G_F_R BIT(5) /* Advertise 2.5GBASE-T fast-retrain */
762 #define size_to_mtu(s) ((s) - VLAN_ETH_HLEN - ETH_FCS_LEN)
889 int (*enable)(struct r8152 *tp); member
898 void (*autosuspend_en)(struct r8152 *tp, bool enable);
906 u32 aldps:1; member
964 * struct fw_block - block type and total length
975 * struct fw_header - header of the firmware file
1049 * struct fw_mac - a firmware block used by RTL_FW_PLA and RTL_FW_USB.
1090 * struct fw_phy_patch_key - a firmware block used by RTL_FW_PHY_START.
1105 * struct fw_phy_nc - a firmware block used by RTL_FW_PHY_NC.
1200 /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
1206 #define RTL_LIMITED_TSO_SIZE (size_to_mtu(agg_buf_sz) - sizeof(struct tx_desc))
1216 set_bit(RTL8152_INACCESSIBLE, &tp->flags); in rtl_set_inaccessible()
1222 clear_bit(RTL8152_INACCESSIBLE, &tp->flags); in rtl_set_accessible()
1231 struct usb_device *udev = tp->udev; in r8152_control_msg()
1234 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8152_control_msg()
1235 return -ENODEV; in r8152_control_msg()
1244 if (ret == -ENODEV) in r8152_control_msg()
1249 tp->reg_access_reset_count = 0; in r8152_control_msg()
1253 dev_err(&udev->dev, in r8152_control_msg()
1270 if (!test_bit(PROBED_WITH_NO_ERRORS, &tp->flags)) { in r8152_control_msg()
1271 set_bit(PROBE_SHOULD_RETRY, &tp->flags); in r8152_control_msg()
1275 /* Failing to access registers in pre-reset is not surprising since we in r8152_control_msg()
1277 * access we do in pre-reset isn't truly mandatory--we're just reusing in r8152_control_msg()
1279 * adapter down before resetting it. Thus, if we're in pre-reset, in r8152_control_msg()
1281 * We know the post-reset is already coming. in r8152_control_msg()
1283 if (test_bit(IN_PRE_RESET, &tp->flags)) in r8152_control_msg()
1286 if (tp->reg_access_reset_count < REGISTER_ACCESS_MAX_RESETS) { in r8152_control_msg()
1287 usb_queue_reset_device(tp->intf); in r8152_control_msg()
1288 tp->reg_access_reset_count++; in r8152_control_msg()
1289 } else if (tp->reg_access_reset_count == REGISTER_ACCESS_MAX_RESETS) { in r8152_control_msg()
1290 dev_err(&udev->dev, in r8152_control_msg()
1306 return -ENOMEM; in get_registers()
1308 ret = r8152_control_msg(tp, tp->pipe_ctrl_in, in get_registers()
1330 return -ENOMEM; in set_registers()
1332 ret = r8152_control_msg(tp, tp->pipe_ctrl_out, in set_registers()
1343 if (tp->udev->state == USB_STATE_NOTATTACHED) in rtl_set_unplug()
1353 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in generic_ocp_read()
1354 return -ENODEV; in generic_ocp_read()
1358 return -EPERM; in generic_ocp_read()
1361 return -EPERM; in generic_ocp_read()
1371 size -= limit; in generic_ocp_read()
1384 if (ret == -ENODEV) in generic_ocp_read()
1397 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in generic_ocp_write()
1398 return -ENODEV; in generic_ocp_write()
1402 return -EPERM; in generic_ocp_write()
1405 return -EPERM; in generic_ocp_write()
1420 size -= 4; in generic_ocp_write()
1428 size -= 4; in generic_ocp_write()
1440 size -= limit; in generic_ocp_write()
1461 if (ret == -ENODEV) in generic_ocp_write()
1584 if (ocp_base != tp->ocp_base) { in ocp_reg_read()
1586 tp->ocp_base = ocp_base; in ocp_reg_read()
1598 if (ocp_base != tp->ocp_base) { in ocp_reg_write()
1600 tp->ocp_base = ocp_base; in ocp_reg_write()
1634 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in read_mii_word()
1635 return -ENODEV; in read_mii_word()
1638 return -EINVAL; in read_mii_word()
1650 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in write_mii_word()
1671 int ret = -EADDRNOTAVAIL; in __rtl8152_set_mac_address()
1673 if (!is_valid_ether_addr(addr->sa_data)) in __rtl8152_set_mac_address()
1677 ret = usb_autopm_get_interface(tp->intf); in __rtl8152_set_mac_address()
1682 mutex_lock(&tp->control); in __rtl8152_set_mac_address()
1684 eth_hw_addr_set(netdev, addr->sa_data); in __rtl8152_set_mac_address()
1687 pla_ocp_write(tp, PLA_IDR, BYTE_EN_SIX_BYTES, 8, addr->sa_data); in __rtl8152_set_mac_address()
1690 mutex_unlock(&tp->control); in __rtl8152_set_mac_address()
1693 usb_autopm_put_interface(tp->intf); in __rtl8152_set_mac_address()
1712 int ret = -EINVAL; in vendor_mac_passthru_addr_read()
1719 if (tp->lenovo_macpassthru) { in vendor_mac_passthru_addr_read()
1724 /* test for -AD variant of RTL8153 */ in vendor_mac_passthru_addr_read()
1727 /* test for MAC address pass-through bit */ in vendor_mac_passthru_addr_read()
1730 netif_dbg(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1731 "No efuse for RTL8153-AD MAC pass through\n"); in vendor_mac_passthru_addr_read()
1732 return -ENODEV; in vendor_mac_passthru_addr_read()
1735 /* test for RTL8153-BND and RTL8153-BD */ in vendor_mac_passthru_addr_read()
1738 netif_dbg(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1740 return -ENODEV; in vendor_mac_passthru_addr_read()
1753 return -ENODEV; in vendor_mac_passthru_addr_read()
1754 if (obj->type != mac_obj_type || obj->string.length != mac_strlen) { in vendor_mac_passthru_addr_read()
1755 netif_warn(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1756 "Invalid buffer for pass-thru MAC addr: (%d, %d)\n", in vendor_mac_passthru_addr_read()
1757 obj->type, obj->string.length); in vendor_mac_passthru_addr_read()
1761 if (strncmp(obj->string.pointer, "_AUXMAC_#", 9) != 0 || in vendor_mac_passthru_addr_read()
1762 strncmp(obj->string.pointer + 0x15, "#", 1) != 0) { in vendor_mac_passthru_addr_read()
1763 netif_warn(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1764 "Invalid header when reading pass-thru MAC addr\n"); in vendor_mac_passthru_addr_read()
1767 ret = hex2bin(buf, obj->string.pointer + 9, 6); in vendor_mac_passthru_addr_read()
1769 netif_warn(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1770 "Invalid MAC for pass-thru MAC addr: %d, %pM\n", in vendor_mac_passthru_addr_read()
1772 ret = -EINVAL; in vendor_mac_passthru_addr_read()
1775 memcpy(sa->sa_data, buf, 6); in vendor_mac_passthru_addr_read()
1776 netif_info(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1777 "Using pass-thru MAC addr %pM\n", sa->sa_data); in vendor_mac_passthru_addr_read()
1786 struct net_device *dev = tp->netdev; in determine_ethernet_addr()
1789 sa->sa_family = dev->type; in determine_ethernet_addr()
1791 ret = eth_platform_get_mac_address(&tp->udev->dev, sa->sa_data); in determine_ethernet_addr()
1793 if (tp->version == RTL_VER_01) { in determine_ethernet_addr()
1794 ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data); in determine_ethernet_addr()
1797 * be expected to be non-zero in determine_ethernet_addr()
1802 sa->sa_data); in determine_ethernet_addr()
1808 } else if (!is_valid_ether_addr(sa->sa_data)) { in determine_ethernet_addr()
1810 sa->sa_data); in determine_ethernet_addr()
1812 ether_addr_copy(sa->sa_data, dev->dev_addr); in determine_ethernet_addr()
1814 sa->sa_data); in determine_ethernet_addr()
1823 struct net_device *dev = tp->netdev; in set_ethernet_addr()
1831 if (tp->version == RTL_VER_01) in set_ethernet_addr()
1842 int status = urb->status; in read_bulk_callback()
1847 agg = urb->context; in read_bulk_callback()
1851 tp = agg->context; in read_bulk_callback()
1855 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in read_bulk_callback()
1858 if (!test_bit(WORK_ENABLE, &tp->flags)) in read_bulk_callback()
1861 netdev = tp->netdev; in read_bulk_callback()
1864 /* This avoid the re-submitting bulk */ in read_bulk_callback()
1868 usb_mark_last_busy(tp->udev); in read_bulk_callback()
1872 if (urb->actual_length < ETH_ZLEN) in read_bulk_callback()
1875 spin_lock_irqsave(&tp->rx_lock, flags); in read_bulk_callback()
1876 list_add_tail(&agg->list, &tp->rx_done); in read_bulk_callback()
1877 spin_unlock_irqrestore(&tp->rx_lock, flags); in read_bulk_callback()
1878 napi_schedule(&tp->napi); in read_bulk_callback()
1880 case -ESHUTDOWN: in read_bulk_callback()
1882 netif_device_detach(tp->netdev); in read_bulk_callback()
1884 case -EPROTO: in read_bulk_callback()
1885 urb->actual_length = 0; in read_bulk_callback()
1886 spin_lock_irqsave(&tp->rx_lock, flags); in read_bulk_callback()
1887 list_add_tail(&agg->list, &tp->rx_done); in read_bulk_callback()
1888 spin_unlock_irqrestore(&tp->rx_lock, flags); in read_bulk_callback()
1889 set_bit(RX_EPROTO, &tp->flags); in read_bulk_callback()
1890 schedule_delayed_work(&tp->schedule, 1); in read_bulk_callback()
1892 case -ENOENT: in read_bulk_callback()
1894 case -ETIME: in read_bulk_callback()
1914 int status = urb->status; in write_bulk_callback()
1916 agg = urb->context; in write_bulk_callback()
1920 tp = agg->context; in write_bulk_callback()
1924 netdev = tp->netdev; in write_bulk_callback()
1925 stats = &netdev->stats; in write_bulk_callback()
1929 stats->tx_errors += agg->skb_num; in write_bulk_callback()
1931 stats->tx_packets += agg->skb_num; in write_bulk_callback()
1932 stats->tx_bytes += agg->skb_len; in write_bulk_callback()
1935 spin_lock_irqsave(&tp->tx_lock, flags); in write_bulk_callback()
1936 list_add_tail(&agg->list, &tp->tx_free); in write_bulk_callback()
1937 spin_unlock_irqrestore(&tp->tx_lock, flags); in write_bulk_callback()
1939 usb_autopm_put_interface_async(tp->intf); in write_bulk_callback()
1944 if (!test_bit(WORK_ENABLE, &tp->flags)) in write_bulk_callback()
1947 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in write_bulk_callback()
1950 if (!skb_queue_empty(&tp->tx_queue)) in write_bulk_callback()
1951 tasklet_schedule(&tp->tx_tl); in write_bulk_callback()
1958 int status = urb->status; in intr_callback()
1961 tp = urb->context; in intr_callback()
1965 if (!test_bit(WORK_ENABLE, &tp->flags)) in intr_callback()
1968 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in intr_callback()
1974 case -ECONNRESET: /* unlink */ in intr_callback()
1975 case -ESHUTDOWN: in intr_callback()
1976 netif_device_detach(tp->netdev); in intr_callback()
1978 case -ENOENT: in intr_callback()
1979 case -EPROTO: in intr_callback()
1980 netif_info(tp, intr, tp->netdev, in intr_callback()
1983 case -EOVERFLOW: in intr_callback()
1985 netif_info(tp, intr, tp->netdev, in intr_callback()
1986 "intr status -EOVERFLOW\n"); in intr_callback()
1988 /* -EPIPE: should clear the halt */ in intr_callback()
1990 netif_info(tp, intr, tp->netdev, "intr status %d\n", status); in intr_callback()
1994 d = urb->transfer_buffer; in intr_callback()
1996 if (!netif_carrier_ok(tp->netdev)) { in intr_callback()
1997 set_bit(RTL8152_LINK_CHG, &tp->flags); in intr_callback()
1998 schedule_delayed_work(&tp->schedule, 0); in intr_callback()
2001 if (netif_carrier_ok(tp->netdev)) { in intr_callback()
2002 netif_stop_queue(tp->netdev); in intr_callback()
2003 set_bit(RTL8152_LINK_CHG, &tp->flags); in intr_callback()
2004 schedule_delayed_work(&tp->schedule, 0); in intr_callback()
2010 if (res == -ENODEV) { in intr_callback()
2012 netif_device_detach(tp->netdev); in intr_callback()
2014 netif_err(tp, intr, tp->netdev, in intr_callback()
2031 list_del(&agg->info_list); in free_rx_agg()
2033 usb_free_urb(agg->urb); in free_rx_agg()
2034 put_page(agg->page); in free_rx_agg()
2037 atomic_dec(&tp->rx_count); in free_rx_agg()
2042 struct net_device *netdev = tp->netdev; in alloc_rx_agg()
2043 int node = netdev->dev.parent ? dev_to_node(netdev->dev.parent) : -1; in alloc_rx_agg()
2044 unsigned int order = get_order(tp->rx_buf_sz); in alloc_rx_agg()
2052 rx_agg->page = alloc_pages(mflags | __GFP_COMP | __GFP_NOWARN, order); in alloc_rx_agg()
2053 if (!rx_agg->page) in alloc_rx_agg()
2056 rx_agg->buffer = page_address(rx_agg->page); in alloc_rx_agg()
2058 rx_agg->urb = usb_alloc_urb(0, mflags); in alloc_rx_agg()
2059 if (!rx_agg->urb) in alloc_rx_agg()
2062 rx_agg->context = tp; in alloc_rx_agg()
2064 INIT_LIST_HEAD(&rx_agg->list); in alloc_rx_agg()
2065 INIT_LIST_HEAD(&rx_agg->info_list); in alloc_rx_agg()
2066 spin_lock_irqsave(&tp->rx_lock, flags); in alloc_rx_agg()
2067 list_add_tail(&rx_agg->info_list, &tp->rx_info); in alloc_rx_agg()
2068 spin_unlock_irqrestore(&tp->rx_lock, flags); in alloc_rx_agg()
2070 atomic_inc(&tp->rx_count); in alloc_rx_agg()
2075 __free_pages(rx_agg->page, order); in alloc_rx_agg()
2087 spin_lock_irqsave(&tp->rx_lock, flags); in free_all_mem()
2089 list_for_each_entry_safe(agg, agg_next, &tp->rx_info, info_list) in free_all_mem()
2092 spin_unlock_irqrestore(&tp->rx_lock, flags); in free_all_mem()
2094 WARN_ON(atomic_read(&tp->rx_count)); in free_all_mem()
2097 usb_free_urb(tp->tx_info[i].urb); in free_all_mem()
2098 tp->tx_info[i].urb = NULL; in free_all_mem()
2100 kfree(tp->tx_info[i].buffer); in free_all_mem()
2101 tp->tx_info[i].buffer = NULL; in free_all_mem()
2102 tp->tx_info[i].head = NULL; in free_all_mem()
2105 usb_free_urb(tp->intr_urb); in free_all_mem()
2106 tp->intr_urb = NULL; in free_all_mem()
2108 kfree(tp->intr_buff); in free_all_mem()
2109 tp->intr_buff = NULL; in free_all_mem()
2114 struct net_device *netdev = tp->netdev; in alloc_all_mem()
2115 struct usb_interface *intf = tp->intf; in alloc_all_mem()
2116 struct usb_host_interface *alt = intf->cur_altsetting; in alloc_all_mem()
2117 struct usb_host_endpoint *ep_intr = alt->endpoint + 2; in alloc_all_mem()
2120 node = netdev->dev.parent ? dev_to_node(netdev->dev.parent) : -1; in alloc_all_mem()
2122 spin_lock_init(&tp->rx_lock); in alloc_all_mem()
2123 spin_lock_init(&tp->tx_lock); in alloc_all_mem()
2124 INIT_LIST_HEAD(&tp->rx_info); in alloc_all_mem()
2125 INIT_LIST_HEAD(&tp->tx_free); in alloc_all_mem()
2126 INIT_LIST_HEAD(&tp->rx_done); in alloc_all_mem()
2127 skb_queue_head_init(&tp->tx_queue); in alloc_all_mem()
2128 skb_queue_head_init(&tp->rx_queue); in alloc_all_mem()
2129 atomic_set(&tp->rx_count, 0); in alloc_all_mem()
2158 INIT_LIST_HEAD(&tp->tx_info[i].list); in alloc_all_mem()
2159 tp->tx_info[i].context = tp; in alloc_all_mem()
2160 tp->tx_info[i].urb = urb; in alloc_all_mem()
2161 tp->tx_info[i].buffer = buf; in alloc_all_mem()
2162 tp->tx_info[i].head = tx_agg_align(buf); in alloc_all_mem()
2164 list_add_tail(&tp->tx_info[i].list, &tp->tx_free); in alloc_all_mem()
2167 tp->intr_urb = usb_alloc_urb(0, GFP_KERNEL); in alloc_all_mem()
2168 if (!tp->intr_urb) in alloc_all_mem()
2171 tp->intr_buff = kmalloc(INTBUFSIZE, GFP_KERNEL); in alloc_all_mem()
2172 if (!tp->intr_buff) in alloc_all_mem()
2175 tp->intr_interval = (int)ep_intr->desc.bInterval; in alloc_all_mem()
2176 usb_fill_int_urb(tp->intr_urb, tp->udev, tp->pipe_intr, in alloc_all_mem()
2177 tp->intr_buff, INTBUFSIZE, intr_callback, in alloc_all_mem()
2178 tp, tp->intr_interval); in alloc_all_mem()
2184 return -ENOMEM; in alloc_all_mem()
2192 if (list_empty(&tp->tx_free)) in r8152_get_tx_agg()
2195 spin_lock_irqsave(&tp->tx_lock, flags); in r8152_get_tx_agg()
2196 if (!list_empty(&tp->tx_free)) { in r8152_get_tx_agg()
2199 cursor = tp->tx_free.next; in r8152_get_tx_agg()
2203 spin_unlock_irqrestore(&tp->tx_lock, flags); in r8152_get_tx_agg()
2215 if (skb_shinfo(skb)->gso_size) { in r8152_csum_workaround()
2216 netdev_features_t features = tp->netdev->features; in r8152_csum_workaround()
2234 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in r8152_csum_workaround()
2243 stats = &tp->netdev->stats; in r8152_csum_workaround()
2244 stats->tx_dropped++; in r8152_csum_workaround()
2255 desc->opts2 |= cpu_to_le32(opts2); in rtl_tx_vlan_tag()
2261 u32 opts2 = le32_to_cpu(desc->opts2); in rtl_rx_vlan_tag()
2271 u32 mss = skb_shinfo(skb)->gso_size; in r8152_tx_csum()
2283 netif_warn(tp, tx_err, tp->netdev, in r8152_tx_csum()
2311 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in r8152_tx_csum()
2316 netif_warn(tp, tx_err, tp->netdev, in r8152_tx_csum()
2326 ip_protocol = ip_hdr(skb)->protocol; in r8152_tx_csum()
2331 ip_protocol = ipv6_hdr(skb)->nexthdr; in r8152_tx_csum()
2349 desc->opts2 = cpu_to_le32(opts2); in r8152_tx_csum()
2350 desc->opts1 = cpu_to_le32(opts1); in r8152_tx_csum()
2358 struct sk_buff_head skb_head, *tx_queue = &tp->tx_queue; in r8152_tx_agg_fill()
2363 spin_lock(&tx_queue->lock); in r8152_tx_agg_fill()
2365 spin_unlock(&tx_queue->lock); in r8152_tx_agg_fill()
2367 tx_data = agg->head; in r8152_tx_agg_fill()
2368 agg->skb_num = 0; in r8152_tx_agg_fill()
2369 agg->skb_len = 0; in r8152_tx_agg_fill()
2381 len = skb->len + sizeof(*tx_desc); in r8152_tx_agg_fill()
2391 if (r8152_tx_csum(tp, tx_desc, skb, skb->len)) { in r8152_tx_agg_fill()
2400 len = skb->len; in r8152_tx_agg_fill()
2402 struct net_device_stats *stats = &tp->netdev->stats; in r8152_tx_agg_fill()
2404 stats->tx_dropped++; in r8152_tx_agg_fill()
2406 tx_data -= sizeof(*tx_desc); in r8152_tx_agg_fill()
2411 agg->skb_len += len; in r8152_tx_agg_fill()
2412 agg->skb_num += skb_shinfo(skb)->gso_segs ?: 1; in r8152_tx_agg_fill()
2416 remain = agg_buf_sz - (int)(tx_agg_align(tx_data) - agg->head); in r8152_tx_agg_fill()
2418 if (tp->dell_tb_rx_agg_bug) in r8152_tx_agg_fill()
2423 spin_lock(&tx_queue->lock); in r8152_tx_agg_fill()
2425 spin_unlock(&tx_queue->lock); in r8152_tx_agg_fill()
2428 netif_tx_lock(tp->netdev); in r8152_tx_agg_fill()
2430 if (netif_queue_stopped(tp->netdev) && in r8152_tx_agg_fill()
2431 skb_queue_len(&tp->tx_queue) < tp->tx_qlen) in r8152_tx_agg_fill()
2432 netif_wake_queue(tp->netdev); in r8152_tx_agg_fill()
2434 netif_tx_unlock(tp->netdev); in r8152_tx_agg_fill()
2436 ret = usb_autopm_get_interface_async(tp->intf); in r8152_tx_agg_fill()
2440 usb_fill_bulk_urb(agg->urb, tp->udev, tp->pipe_out, in r8152_tx_agg_fill()
2441 agg->head, (int)(tx_data - (u8 *)agg->head), in r8152_tx_agg_fill()
2444 ret = usb_submit_urb(agg->urb, GFP_ATOMIC); in r8152_tx_agg_fill()
2446 usb_autopm_put_interface_async(tp->intf); in r8152_tx_agg_fill()
2457 if (!(tp->netdev->features & NETIF_F_RXCSUM)) in r8152_rx_csum()
2460 opts2 = le32_to_cpu(rx_desc->opts2); in r8152_rx_csum()
2461 opts3 = le32_to_cpu(rx_desc->opts3); in r8152_rx_csum()
2483 return atomic_read(&tp->rx_count) > RTL8152_MAX_RX; in rx_count_exceed()
2488 return (int)(addr - agg->buffer); in agg_offset()
2496 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_get_free_rx()
2498 list_for_each_entry_safe(agg, agg_next, &tp->rx_used, list) { in rtl_get_free_rx()
2499 if (page_count(agg->page) == 1) { in rtl_get_free_rx()
2501 list_del_init(&agg->list); in rtl_get_free_rx()
2506 list_del_init(&agg->list); in rtl_get_free_rx()
2513 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_get_free_rx()
2515 if (!agg_free && atomic_read(&tp->rx_count) < tp->rx_pending) in rtl_get_free_rx()
2526 struct napi_struct *napi = &tp->napi; in rx_bottom()
2528 if (!skb_queue_empty(&tp->rx_queue)) { in rx_bottom()
2530 struct sk_buff *skb = __skb_dequeue(&tp->rx_queue); in rx_bottom()
2531 struct net_device *netdev = tp->netdev; in rx_bottom()
2532 struct net_device_stats *stats = &netdev->stats; in rx_bottom()
2538 pkt_len = skb->len; in rx_bottom()
2541 stats->rx_packets++; in rx_bottom()
2542 stats->rx_bytes += pkt_len; in rx_bottom()
2546 if (list_empty(&tp->rx_done) || work_done >= budget) in rx_bottom()
2549 clear_bit(RX_EPROTO, &tp->flags); in rx_bottom()
2551 spin_lock_irqsave(&tp->rx_lock, flags); in rx_bottom()
2552 list_splice_init(&tp->rx_done, &rx_queue); in rx_bottom()
2553 spin_unlock_irqrestore(&tp->rx_lock, flags); in rx_bottom()
2574 urb = agg->urb; in rx_bottom()
2575 if (urb->status != 0 || urb->actual_length < ETH_ZLEN) in rx_bottom()
2580 rx_desc = agg->buffer; in rx_bottom()
2581 rx_data = agg->buffer; in rx_bottom()
2584 while (urb->actual_length > len_used) { in rx_bottom()
2585 struct net_device *netdev = tp->netdev; in rx_bottom()
2586 struct net_device_stats *stats = &netdev->stats; in rx_bottom()
2590 WARN_ON_ONCE(skb_queue_len(&tp->rx_queue) >= 1000); in rx_bottom()
2592 pkt_len = le32_to_cpu(rx_desc->opts1) & RX_LEN_MASK; in rx_bottom()
2597 if (urb->actual_length < len_used) in rx_bottom()
2600 pkt_len -= ETH_FCS_LEN; in rx_bottom()
2603 if (!agg_free || tp->rx_copybreak > pkt_len) in rx_bottom()
2606 rx_frag_head_sz = tp->rx_copybreak; in rx_bottom()
2610 stats->rx_dropped++; in rx_bottom()
2614 skb->ip_summed = r8152_rx_csum(tp, rx_desc); in rx_bottom()
2615 memcpy(skb->data, rx_data, rx_frag_head_sz); in rx_bottom()
2617 pkt_len -= rx_frag_head_sz; in rx_bottom()
2620 skb_add_rx_frag(skb, 0, agg->page, in rx_bottom()
2624 get_page(agg->page); in rx_bottom()
2627 skb->protocol = eth_type_trans(skb, netdev); in rx_bottom()
2631 stats->rx_packets++; in rx_bottom()
2632 stats->rx_bytes += skb->len; in rx_bottom()
2635 __skb_queue_tail(&tp->rx_queue, skb); in rx_bottom()
2645 WARN_ON(!agg_free && page_count(agg->page) > 1); in rx_bottom()
2648 spin_lock_irqsave(&tp->rx_lock, flags); in rx_bottom()
2649 if (page_count(agg->page) == 1) { in rx_bottom()
2650 list_add(&agg_free->list, &tp->rx_used); in rx_bottom()
2652 list_add_tail(&agg->list, &tp->rx_used); in rx_bottom()
2654 urb = agg->urb; in rx_bottom()
2656 spin_unlock_irqrestore(&tp->rx_lock, flags); in rx_bottom()
2663 urb->actual_length = 0; in rx_bottom()
2664 list_add_tail(&agg->list, next); in rx_bottom()
2670 spin_lock_irqsave(&tp->rx_lock, flags); in rx_bottom()
2671 list_splice(&rx_queue, &tp->rx_done); in rx_bottom()
2672 spin_unlock_irqrestore(&tp->rx_lock, flags); in rx_bottom()
2684 struct net_device *netdev = tp->netdev; in tx_bottom()
2687 if (skb_queue_empty(&tp->tx_queue)) in tx_bottom()
2698 if (res == -ENODEV) { in tx_bottom()
2702 struct net_device_stats *stats = &netdev->stats; in tx_bottom()
2707 stats->tx_dropped += agg->skb_num; in tx_bottom()
2709 spin_lock_irqsave(&tp->tx_lock, flags); in tx_bottom()
2710 list_add_tail(&agg->list, &tp->tx_free); in tx_bottom()
2711 spin_unlock_irqrestore(&tp->tx_lock, flags); in tx_bottom()
2720 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in bottom_half()
2723 if (!test_bit(WORK_ENABLE, &tp->flags)) in bottom_half()
2727 /* This avoid the re-submitting bulk */ in bottom_half()
2728 if (!netif_carrier_ok(tp->netdev)) in bottom_half()
2731 clear_bit(SCHEDULE_TASKLET, &tp->flags); in bottom_half()
2749 if (!list_empty(&tp->rx_done)) in r8152_poll()
2763 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags) || in r8152_submit_rx()
2764 !test_bit(WORK_ENABLE, &tp->flags) || !netif_carrier_ok(tp->netdev)) in r8152_submit_rx()
2767 usb_fill_bulk_urb(agg->urb, tp->udev, tp->pipe_in, in r8152_submit_rx()
2768 agg->buffer, tp->rx_buf_sz, in r8152_submit_rx()
2771 ret = usb_submit_urb(agg->urb, mem_flags); in r8152_submit_rx()
2772 if (ret == -ENODEV) { in r8152_submit_rx()
2774 netif_device_detach(tp->netdev); in r8152_submit_rx()
2776 struct urb *urb = agg->urb; in r8152_submit_rx()
2779 urb->actual_length = 0; in r8152_submit_rx()
2780 spin_lock_irqsave(&tp->rx_lock, flags); in r8152_submit_rx()
2781 list_add_tail(&agg->list, &tp->rx_done); in r8152_submit_rx()
2782 spin_unlock_irqrestore(&tp->rx_lock, flags); in r8152_submit_rx()
2784 netif_err(tp, rx_err, tp->netdev, in r8152_submit_rx()
2787 napi_schedule(&tp->napi); in r8152_submit_rx()
2795 struct net_device_stats *stats = &tp->netdev->stats; in rtl_drop_queued_tx()
2796 struct sk_buff_head skb_head, *tx_queue = &tp->tx_queue; in rtl_drop_queued_tx()
2803 spin_lock_bh(&tx_queue->lock); in rtl_drop_queued_tx()
2805 spin_unlock_bh(&tx_queue->lock); in rtl_drop_queued_tx()
2809 stats->tx_dropped++; in rtl_drop_queued_tx()
2819 usb_queue_reset_device(tp->intf); in rtl8152_tx_timeout()
2827 set_bit(RTL8152_SET_RX_MODE, &tp->flags); in rtl8152_set_rx_mode()
2828 schedule_delayed_work(&tp->schedule, 0); in rtl8152_set_rx_mode()
2844 if (netdev->flags & IFF_PROMISC) { in _rtl8152_set_rx_mode()
2850 } else if ((netdev->flags & IFF_MULTICAST && in _rtl8152_set_rx_mode()
2852 (netdev->flags & IFF_ALLMULTI)) { in _rtl8152_set_rx_mode()
2853 /* Too many to filter perfectly -- accept all multicasts. */ in _rtl8152_set_rx_mode()
2861 if (netdev->flags & IFF_MULTICAST) { in _rtl8152_set_rx_mode()
2865 int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; in _rtl8152_set_rx_mode()
2885 u32 mss = skb_shinfo(skb)->gso_size; in rtl8152_features_check()
2888 if ((mss || skb->ip_summed == CHECKSUM_PARTIAL) && in rtl8152_features_check()
2891 else if ((skb->len + sizeof(struct tx_desc)) > agg_buf_sz) in rtl8152_features_check()
2904 skb_queue_tail(&tp->tx_queue, skb); in rtl8152_start_xmit()
2906 if (!list_empty(&tp->tx_free)) { in rtl8152_start_xmit()
2907 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { in rtl8152_start_xmit()
2908 set_bit(SCHEDULE_TASKLET, &tp->flags); in rtl8152_start_xmit()
2909 schedule_delayed_work(&tp->schedule, 0); in rtl8152_start_xmit()
2911 usb_mark_last_busy(tp->udev); in rtl8152_start_xmit()
2912 tasklet_schedule(&tp->tx_tl); in rtl8152_start_xmit()
2914 } else if (skb_queue_len(&tp->tx_queue) > tp->tx_qlen) { in rtl8152_start_xmit()
2937 switch (tp->version) { in rtl8152_nic_reset()
2970 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8152_nic_reset()
2982 tp->tx_qlen = agg_buf_sz / (mtu_to_size(tp->netdev->mtu) + sizeof(struct tx_desc)); in set_tx_qlen()
2990 static void rtl_eee_plus_en(struct r8152 *tp, bool enable) in rtl_eee_plus_en() argument
2995 if (enable) in rtl_eee_plus_en()
3010 static void rxdy_gated_en(struct r8152 *tp, bool enable) in rxdy_gated_en() argument
3015 if (enable) in rxdy_gated_en()
3031 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_start_rx()
3033 INIT_LIST_HEAD(&tp->rx_done); in rtl_start_rx()
3034 INIT_LIST_HEAD(&tp->rx_used); in rtl_start_rx()
3036 list_splice_init(&tp->rx_info, &tmp_list); in rtl_start_rx()
3038 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_start_rx()
3041 INIT_LIST_HEAD(&agg->list); in rtl_start_rx()
3045 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_start_rx()
3046 list_add_tail(&agg->list, &tp->rx_used); in rtl_start_rx()
3047 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_start_rx()
3049 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_start_rx()
3050 list_add_tail(&agg->list, &tp->rx_done); in rtl_start_rx()
3051 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_start_rx()
3057 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_start_rx()
3058 WARN_ON(!list_empty(&tp->rx_info)); in rtl_start_rx()
3059 list_splice(&tmp_list, &tp->rx_info); in rtl_start_rx()
3060 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_start_rx()
3079 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_stop_rx()
3080 list_splice_init(&tp->rx_info, &tmp_list); in rtl_stop_rx()
3081 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_stop_rx()
3087 if (page_count(agg->page) > 1) in rtl_stop_rx()
3090 usb_kill_urb(agg->urb); in rtl_stop_rx()
3094 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_stop_rx()
3095 WARN_ON(!list_empty(&tp->rx_info)); in rtl_stop_rx()
3096 list_splice(&tmp_list, &tp->rx_info); in rtl_stop_rx()
3097 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_stop_rx()
3099 while (!skb_queue_empty(&tp->rx_queue)) in rtl_stop_rx()
3100 dev_kfree_skb(__skb_dequeue(&tp->rx_queue)); in rtl_stop_rx()
3144 switch (tp->version) { in rtl_enable()
3165 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8152_enable()
3166 return -ENODEV; in rtl8152_enable()
3176 u32 ocp_data = tp->coalesce / 8; in r8153_set_rx_early_timeout()
3178 switch (tp->version) { in r8153_set_rx_early_timeout()
3217 u32 ocp_data = tp->rx_buf_sz - rx_reserved_size(tp->netdev->mtu); in r8153_set_rx_early_size()
3219 switch (tp->version) { in r8153_set_rx_early_size()
3252 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8153_enable()
3253 return -ENODEV; in rtl8153_enable()
3262 switch (tp->version) { in rtl8153_enable()
3284 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) { in rtl_disable()
3296 usb_kill_urb(tp->tx_info[i].urb); in rtl_disable()
3301 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl_disable()
3310 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl_disable()
3322 static void r8152_power_cut_en(struct r8152 *tp, bool enable) in r8152_power_cut_en() argument
3327 if (enable) in r8152_power_cut_en()
3338 static void rtl_rx_vlan_en(struct r8152 *tp, bool enable) in rtl_rx_vlan_en() argument
3342 switch (tp->version) { in rtl_rx_vlan_en()
3354 if (enable) in rtl_rx_vlan_en()
3369 if (enable) in rtl_rx_vlan_en()
3381 netdev_features_t changed = features ^ dev->features; in rtl8152_set_features()
3385 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_features()
3389 mutex_lock(&tp->control); in rtl8152_set_features()
3398 mutex_unlock(&tp->control); in rtl8152_set_features()
3400 usb_autopm_put_interface(tp->intf); in rtl8152_set_features()
3463 device_set_wakeup_enable(&tp->udev->dev, true); in __rtl_set_wol()
3465 device_set_wakeup_enable(&tp->udev->dev, false); in __rtl_set_wol()
3468 static void r8153_mac_clk_speed_down(struct r8152 *tp, bool enable) in r8153_mac_clk_speed_down() argument
3473 if (enable) in r8153_mac_clk_speed_down()
3481 static void r8156_mac_clk_spd(struct r8152 *tp, bool enable) in r8156_mac_clk_spd() argument
3486 if (enable) { in r8156_mac_clk_spd()
3502 static void r8153_u1u2en(struct r8152 *tp, bool enable) in r8153_u1u2en() argument
3506 if (enable) in r8153_u1u2en()
3514 static void r8153b_u1u2en(struct r8152 *tp, bool enable) in r8153b_u1u2en() argument
3519 if (enable) in r8153b_u1u2en()
3527 static void r8153_u2p3en(struct r8152 *tp, bool enable) in r8153_u2p3en() argument
3532 if (enable) in r8153_u2p3en()
3543 if (tp->ups_info.green) in r8153b_ups_flags()
3546 if (tp->ups_info.aldps) in r8153b_ups_flags()
3549 if (tp->ups_info.eee) in r8153b_ups_flags()
3552 if (tp->ups_info.flow_control) in r8153b_ups_flags()
3555 if (tp->ups_info.eee_ckdiv) in r8153b_ups_flags()
3558 if (tp->ups_info.eee_cmod_lv) in r8153b_ups_flags()
3561 if (tp->ups_info.r_tune) in r8153b_ups_flags()
3564 if (tp->ups_info._10m_ckdiv) in r8153b_ups_flags()
3567 if (tp->ups_info.eee_plloff_100) in r8153b_ups_flags()
3570 if (tp->ups_info.eee_plloff_giga) in r8153b_ups_flags()
3573 if (tp->ups_info._250m_ckdiv) in r8153b_ups_flags()
3576 if (tp->ups_info.ctap_short_off) in r8153b_ups_flags()
3579 switch (tp->ups_info.speed_duplex) { in r8153b_ups_flags()
3618 if (tp->ups_info.green) in r8156_ups_flags()
3621 if (tp->ups_info.aldps) in r8156_ups_flags()
3624 if (tp->ups_info.eee) in r8156_ups_flags()
3627 if (tp->ups_info.flow_control) in r8156_ups_flags()
3630 if (tp->ups_info.eee_ckdiv) in r8156_ups_flags()
3633 if (tp->ups_info._10m_ckdiv) in r8156_ups_flags()
3636 if (tp->ups_info.eee_plloff_100) in r8156_ups_flags()
3639 if (tp->ups_info.eee_plloff_giga) in r8156_ups_flags()
3642 if (tp->ups_info._250m_ckdiv) in r8156_ups_flags()
3645 switch (tp->ups_info.speed_duplex) { in r8156_ups_flags()
3680 switch (tp->ups_info.lite_mode) { in r8156_ups_flags()
3696 static void rtl_green_en(struct r8152 *tp, bool enable) in rtl_green_en() argument
3701 if (enable) in rtl_green_en()
3707 tp->ups_info.green = enable; in rtl_green_en()
3710 static void r8153b_green_en(struct r8152 *tp, bool enable) in r8153b_green_en() argument
3712 if (enable) { in r8153b_green_en()
3742 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153_phy_status()
3749 static void r8153b_ups_en(struct r8152 *tp, bool enable) in r8153b_ups_en() argument
3753 if (enable) { in r8153b_ups_en()
3774 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153b_ups_en()
3782 tp->rtl_ops.hw_phy_cfg(tp); in r8153b_ups_en()
3784 rtl8152_set_speed(tp, tp->autoneg, tp->speed, in r8153b_ups_en()
3785 tp->duplex, tp->advertising); in r8153b_ups_en()
3790 static void r8153c_ups_en(struct r8152 *tp, bool enable) in r8153c_ups_en() argument
3794 if (enable) { in r8153c_ups_en()
3816 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153c_ups_en()
3824 tp->rtl_ops.hw_phy_cfg(tp); in r8153c_ups_en()
3826 rtl8152_set_speed(tp, tp->autoneg, tp->speed, in r8153c_ups_en()
3827 tp->duplex, tp->advertising); in r8153c_ups_en()
3840 static void r8156_ups_en(struct r8152 *tp, bool enable) in r8156_ups_en() argument
3844 if (enable) { in r8156_ups_en()
3854 switch (tp->version) { in r8156_ups_en()
3873 tp->rtl_ops.hw_phy_cfg(tp); in r8156_ups_en()
3875 rtl8152_set_speed(tp, tp->autoneg, tp->speed, in r8156_ups_en()
3876 tp->duplex, tp->advertising); in r8156_ups_en()
3881 static void r8153_power_cut_en(struct r8152 *tp, bool enable) in r8153_power_cut_en() argument
3886 if (enable) in r8153_power_cut_en()
3897 static void r8153b_power_cut_en(struct r8152 *tp, bool enable) in r8153b_power_cut_en() argument
3902 if (enable) in r8153b_power_cut_en()
3913 static void r8153_queue_wake(struct r8152 *tp, bool enable) in r8153_queue_wake() argument
3918 if (enable) in r8153_queue_wake()
3935 struct usb_device *udev = tp->udev; in rtl_can_wakeup()
3937 return (udev->actconfig->desc.bmAttributes & USB_CONFIG_ATT_WAKEUP); in rtl_can_wakeup()
3940 static void rtl_runtime_suspend_enable(struct r8152 *tp, bool enable) in rtl_runtime_suspend_enable() argument
3942 if (enable) { in rtl_runtime_suspend_enable()
3957 __rtl_set_wol(tp, tp->saved_wolopts); in rtl_runtime_suspend_enable()
3969 static void rtl8153_runtime_enable(struct r8152 *tp, bool enable) in rtl8153_runtime_enable() argument
3971 if (enable) { in rtl8153_runtime_enable()
3978 switch (tp->version) { in rtl8153_runtime_enable()
3993 static void rtl8153b_runtime_enable(struct r8152 *tp, bool enable) in rtl8153b_runtime_enable() argument
3995 if (enable) { in rtl8153b_runtime_enable()
4005 if (tp->udev->speed >= USB_SPEED_SUPER) in rtl8153b_runtime_enable()
4010 static void rtl8153c_runtime_enable(struct r8152 *tp, bool enable) in rtl8153c_runtime_enable() argument
4012 if (enable) { in rtl8153c_runtime_enable()
4026 static void rtl8156_runtime_enable(struct r8152 *tp, bool enable) in rtl8156_runtime_enable() argument
4028 if (enable) { in rtl8156_runtime_enable()
4037 if (tp->udev->speed >= USB_SPEED_SUPER) in rtl8156_runtime_enable()
4046 switch (tp->version) { in r8153_teredo_off()
4099 switch (tp->version) { in rtl_clear_bp()
4140 tp->ocp_base = -1; in rtl_reset_ocp_base()
4161 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl_phy_patch_request()
4162 return -ENODEV; in rtl_phy_patch_request()
4172 dev_err(&tp->intf->dev, "PHY patch request fail\n"); in rtl_phy_patch_request()
4174 return -ETIME; in rtl_phy_patch_request()
4204 return -ETIME; in rtl_pre_ram_code()
4226 switch (tp->version) { in rtl8152_is_fw_phy_speed_up_ok()
4247 fw_offset = __le16_to_cpu(phy->fw_offset); in rtl8152_is_fw_phy_speed_up_ok()
4248 length = __le32_to_cpu(phy->blk_hdr.length); in rtl8152_is_fw_phy_speed_up_ok()
4250 dev_err(&tp->intf->dev, "invalid fw_offset\n"); in rtl8152_is_fw_phy_speed_up_ok()
4254 length -= fw_offset; in rtl8152_is_fw_phy_speed_up_ok()
4256 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_phy_speed_up_ok()
4260 if (__le16_to_cpu(phy->fw_reg) != 0x9A00) { in rtl8152_is_fw_phy_speed_up_ok()
4261 dev_err(&tp->intf->dev, "invalid register to load firmware\n"); in rtl8152_is_fw_phy_speed_up_ok()
4274 switch (tp->version) { in rtl8152_is_fw_phy_ver_ok()
4285 if (__le32_to_cpu(ver->blk_hdr.length) != sizeof(*ver)) { in rtl8152_is_fw_phy_ver_ok()
4286 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_phy_ver_ok()
4290 if (__le16_to_cpu(ver->ver.addr) != SRAM_GPHY_FW_VER) { in rtl8152_is_fw_phy_ver_ok()
4291 dev_err(&tp->intf->dev, "invalid phy ver addr\n"); in rtl8152_is_fw_phy_ver_ok()
4304 switch (tp->version) { in rtl8152_is_fw_phy_fixup_ok()
4315 if (__le32_to_cpu(fix->blk_hdr.length) != sizeof(*fix)) { in rtl8152_is_fw_phy_fixup_ok()
4316 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_phy_fixup_ok()
4320 if (__le16_to_cpu(fix->setting.addr) != OCP_PHY_PATCH_CMD || in rtl8152_is_fw_phy_fixup_ok()
4321 __le16_to_cpu(fix->setting.data) != BIT(7)) { in rtl8152_is_fw_phy_fixup_ok()
4322 dev_err(&tp->intf->dev, "invalid phy fixup\n"); in rtl8152_is_fw_phy_fixup_ok()
4337 switch (tp->version) { in rtl8152_is_fw_phy_union_ok()
4348 fw_offset = __le16_to_cpu(phy->fw_offset); in rtl8152_is_fw_phy_union_ok()
4349 length = __le32_to_cpu(phy->blk_hdr.length); in rtl8152_is_fw_phy_union_ok()
4351 dev_err(&tp->intf->dev, "invalid fw_offset\n"); in rtl8152_is_fw_phy_union_ok()
4355 length -= fw_offset; in rtl8152_is_fw_phy_union_ok()
4357 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_phy_union_ok()
4361 if (phy->pre_num > 2) { in rtl8152_is_fw_phy_union_ok()
4362 dev_err(&tp->intf->dev, "invalid pre_num %d\n", phy->pre_num); in rtl8152_is_fw_phy_union_ok()
4366 if (phy->bp_num > 8) { in rtl8152_is_fw_phy_union_ok()
4367 dev_err(&tp->intf->dev, "invalid bp_num %d\n", phy->bp_num); in rtl8152_is_fw_phy_union_ok()
4382 switch (tp->version) { in rtl8152_is_fw_phy_nc_ok()
4396 fw_offset = __le16_to_cpu(phy->fw_offset); in rtl8152_is_fw_phy_nc_ok()
4398 dev_err(&tp->intf->dev, "fw_offset too small\n"); in rtl8152_is_fw_phy_nc_ok()
4402 length = __le32_to_cpu(phy->blk_hdr.length); in rtl8152_is_fw_phy_nc_ok()
4404 dev_err(&tp->intf->dev, "invalid fw_offset\n"); in rtl8152_is_fw_phy_nc_ok()
4408 length -= __le16_to_cpu(phy->fw_offset); in rtl8152_is_fw_phy_nc_ok()
4410 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_phy_nc_ok()
4414 if (__le16_to_cpu(phy->fw_reg) != fw_reg) { in rtl8152_is_fw_phy_nc_ok()
4415 dev_err(&tp->intf->dev, "invalid register to load firmware\n"); in rtl8152_is_fw_phy_nc_ok()
4419 if (__le16_to_cpu(phy->ba_reg) != ba_reg) { in rtl8152_is_fw_phy_nc_ok()
4420 dev_err(&tp->intf->dev, "invalid base address register\n"); in rtl8152_is_fw_phy_nc_ok()
4424 if (__le16_to_cpu(phy->patch_en_addr) != patch_en_addr) { in rtl8152_is_fw_phy_nc_ok()
4425 dev_err(&tp->intf->dev, in rtl8152_is_fw_phy_nc_ok()
4430 if (__le16_to_cpu(phy->mode_reg) != mode_reg) { in rtl8152_is_fw_phy_nc_ok()
4431 dev_err(&tp->intf->dev, in rtl8152_is_fw_phy_nc_ok()
4436 if (__le16_to_cpu(phy->bp_start) != bp_start) { in rtl8152_is_fw_phy_nc_ok()
4437 dev_err(&tp->intf->dev, in rtl8152_is_fw_phy_nc_ok()
4442 if (__le16_to_cpu(phy->bp_num) > 4) { in rtl8152_is_fw_phy_nc_ok()
4443 dev_err(&tp->intf->dev, "invalid break point number\n"); in rtl8152_is_fw_phy_nc_ok()
4459 type = __le32_to_cpu(mac->blk_hdr.type); in rtl8152_is_fw_mac_ok()
4461 switch (tp->version) { in rtl8152_is_fw_mac_ok()
4498 switch (tp->version) { in rtl8152_is_fw_mac_ok()
4532 fw_offset = __le16_to_cpu(mac->fw_offset); in rtl8152_is_fw_mac_ok()
4534 dev_err(&tp->intf->dev, "fw_offset too small\n"); in rtl8152_is_fw_mac_ok()
4538 length = __le32_to_cpu(mac->blk_hdr.length); in rtl8152_is_fw_mac_ok()
4540 dev_err(&tp->intf->dev, "invalid fw_offset\n"); in rtl8152_is_fw_mac_ok()
4544 length -= fw_offset; in rtl8152_is_fw_mac_ok()
4546 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_mac_ok()
4550 if (__le16_to_cpu(mac->fw_reg) != fw_reg) { in rtl8152_is_fw_mac_ok()
4551 dev_err(&tp->intf->dev, "invalid register to load firmware\n"); in rtl8152_is_fw_mac_ok()
4555 if (__le16_to_cpu(mac->bp_ba_addr) != bp_ba_addr) { in rtl8152_is_fw_mac_ok()
4556 dev_err(&tp->intf->dev, "invalid base address register\n"); in rtl8152_is_fw_mac_ok()
4560 if (__le16_to_cpu(mac->bp_en_addr) != bp_en_addr) { in rtl8152_is_fw_mac_ok()
4561 dev_err(&tp->intf->dev, "invalid enabled mask register\n"); in rtl8152_is_fw_mac_ok()
4565 if (__le16_to_cpu(mac->bp_start) != bp_start) { in rtl8152_is_fw_mac_ok()
4566 dev_err(&tp->intf->dev, in rtl8152_is_fw_mac_ok()
4571 if (__le16_to_cpu(mac->bp_num) > max_bp) { in rtl8152_is_fw_mac_ok()
4572 dev_err(&tp->intf->dev, "invalid break point number\n"); in rtl8152_is_fw_mac_ok()
4576 for (i = __le16_to_cpu(mac->bp_num); i < max_bp; i++) { in rtl8152_is_fw_mac_ok()
4577 if (mac->bp[i]) { in rtl8152_is_fw_mac_ok()
4578 dev_err(&tp->intf->dev, "unused bp%u is not zero\n", i); in rtl8152_is_fw_mac_ok()
4595 unsigned char checksum[sizeof(fw_hdr->checksum)]; in rtl8152_fw_verify_checksum()
4607 if (crypto_shash_digestsize(alg) != sizeof(fw_hdr->checksum)) { in rtl8152_fw_verify_checksum()
4608 rc = -EFAULT; in rtl8152_fw_verify_checksum()
4609 dev_err(&tp->intf->dev, "digestsize incorrect (%u)\n", in rtl8152_fw_verify_checksum()
4617 rc = -ENOMEM; in rtl8152_fw_verify_checksum()
4620 sdesc->tfm = alg; in rtl8152_fw_verify_checksum()
4622 len = size - sizeof(fw_hdr->checksum); in rtl8152_fw_verify_checksum()
4623 rc = crypto_shash_digest(sdesc, fw_hdr->version, len, checksum); in rtl8152_fw_verify_checksum()
4628 if (memcmp(fw_hdr->checksum, checksum, sizeof(fw_hdr->checksum))) { in rtl8152_fw_verify_checksum()
4629 dev_err(&tp->intf->dev, "checksum fail\n"); in rtl8152_fw_verify_checksum()
4630 rc = -EFAULT; in rtl8152_fw_verify_checksum()
4641 const struct firmware *fw = rtl_fw->fw; in rtl8152_check_firmware()
4642 struct fw_header *fw_hdr = (struct fw_header *)fw->data; in rtl8152_check_firmware()
4644 long ret = -EFAULT; in rtl8152_check_firmware()
4647 if (fw->size < sizeof(*fw_hdr)) { in rtl8152_check_firmware()
4648 dev_err(&tp->intf->dev, "file too small\n"); in rtl8152_check_firmware()
4652 ret = rtl8152_fw_verify_checksum(tp, fw_hdr, fw->size); in rtl8152_check_firmware()
4656 ret = -EFAULT; in rtl8152_check_firmware()
4658 for (i = sizeof(*fw_hdr); i < fw->size;) { in rtl8152_check_firmware()
4659 struct fw_block *block = (struct fw_block *)&fw->data[i]; in rtl8152_check_firmware()
4662 if ((i + sizeof(*block)) > fw->size) in rtl8152_check_firmware()
4665 type = __le32_to_cpu(block->type); in rtl8152_check_firmware()
4668 if (__le32_to_cpu(block->length) != sizeof(*block)) in rtl8152_check_firmware()
4673 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4679 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4687 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4693 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4707 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4712 if (__le32_to_cpu(block->length) != sizeof(struct fw_phy_patch_key)) { in rtl8152_check_firmware()
4713 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4722 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4727 if (__le32_to_cpu(block->length) != sizeof(*block)) { in rtl8152_check_firmware()
4728 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4737 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4743 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4749 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4762 dev_err(&tp->intf->dev, "PHY_UNION_NC out of order\n"); in rtl8152_check_firmware()
4767 dev_err(&tp->intf->dev, "multiple PHY_UNION_NC encountered\n"); in rtl8152_check_firmware()
4772 dev_err(&tp->intf->dev, "check PHY_UNION_NC failed\n"); in rtl8152_check_firmware()
4783 dev_err(&tp->intf->dev, "PHY_UNION_NC1 out of order\n"); in rtl8152_check_firmware()
4788 dev_err(&tp->intf->dev, "multiple PHY NC1 encountered\n"); in rtl8152_check_firmware()
4793 dev_err(&tp->intf->dev, "check PHY_UNION_NC1 failed\n"); in rtl8152_check_firmware()
4803 dev_err(&tp->intf->dev, "PHY_UNION_NC2 out of order\n"); in rtl8152_check_firmware()
4808 dev_err(&tp->intf->dev, "multiple PHY NC2 encountered\n"); in rtl8152_check_firmware()
4813 dev_err(&tp->intf->dev, "check PHY_UNION_NC2 failed\n"); in rtl8152_check_firmware()
4822 dev_err(&tp->intf->dev, "PHY_UNION_UC2 out of order\n"); in rtl8152_check_firmware()
4827 dev_err(&tp->intf->dev, "multiple PHY UC2 encountered\n"); in rtl8152_check_firmware()
4832 dev_err(&tp->intf->dev, "check PHY_UNION_UC2 failed\n"); in rtl8152_check_firmware()
4840 dev_err(&tp->intf->dev, "PHY_UNION_UC out of order\n"); in rtl8152_check_firmware()
4845 dev_err(&tp->intf->dev, "multiple PHY UC encountered\n"); in rtl8152_check_firmware()
4850 dev_err(&tp->intf->dev, "check PHY_UNION_UC failed\n"); in rtl8152_check_firmware()
4857 dev_err(&tp->intf->dev, "check RTL_FW_PHY_UNION_MISC failed\n"); in rtl8152_check_firmware()
4863 dev_err(&tp->intf->dev, "check PHY fixup failed\n"); in rtl8152_check_firmware()
4869 dev_err(&tp->intf->dev, "multiple PHY firmware encountered"); in rtl8152_check_firmware()
4874 dev_err(&tp->intf->dev, "check PHY speed up failed\n"); in rtl8152_check_firmware()
4887 dev_err(&tp->intf->dev, "Invalid order to set PHY version\n"); in rtl8152_check_firmware()
4892 dev_err(&tp->intf->dev, "multiple PHY version encountered"); in rtl8152_check_firmware()
4897 dev_err(&tp->intf->dev, "check PHY version failed\n"); in rtl8152_check_firmware()
4903 dev_warn(&tp->intf->dev, "Unknown type %u is found\n", in rtl8152_check_firmware()
4909 i += ALIGN(__le32_to_cpu(block->length), 8); in rtl8152_check_firmware()
4914 dev_err(&tp->intf->dev, "without PHY_STOP\n"); in rtl8152_check_firmware()
4930 if (sram_read(tp, SRAM_GPHY_FW_VER) >= __le16_to_cpu(phy->version)) { in rtl_ram_code_speed_up()
4931 dev_dbg(&tp->intf->dev, "PHY firmware has been the newest\n"); in rtl_ram_code_speed_up()
4935 len = __le32_to_cpu(phy->blk_hdr.length); in rtl_ram_code_speed_up()
4936 len -= __le16_to_cpu(phy->fw_offset); in rtl_ram_code_speed_up()
4937 data = (u8 *)phy + __le16_to_cpu(phy->fw_offset); in rtl_ram_code_speed_up()
4955 generic_ocp_write(tp, __le16_to_cpu(phy->fw_reg), 0xff, size, data, MCU_TYPE_USB); in rtl_ram_code_speed_up()
4958 len -= size; in rtl_ram_code_speed_up()
4970 dev_err(&tp->intf->dev, "ram code speedup mode timeout\n"); in rtl_ram_code_speed_up()
4979 if (sram_read(tp, SRAM_GPHY_FW_VER) == __le16_to_cpu(phy->version)) in rtl_ram_code_speed_up()
4980 dev_dbg(&tp->intf->dev, "successfully applied %s\n", phy->info); in rtl_ram_code_speed_up()
4982 dev_err(&tp->intf->dev, "ram code speedup mode fail\n"); in rtl_ram_code_speed_up()
4989 ver_addr = __le16_to_cpu(phy_ver->ver.addr); in rtl8152_fw_phy_ver()
4990 ver = __le16_to_cpu(phy_ver->ver.data); in rtl8152_fw_phy_ver()
4995 dev_dbg(&tp->intf->dev, "PHY firmware has been the newest\n"); in rtl8152_fw_phy_ver()
5001 dev_dbg(&tp->intf->dev, "PHY firmware version %x\n", ver); in rtl8152_fw_phy_ver()
5012 addr = __le16_to_cpu(fix->setting.addr); in rtl8152_fw_phy_fixup()
5015 switch (__le16_to_cpu(fix->bit_cmd)) { in rtl8152_fw_phy_fixup()
5017 data &= __le16_to_cpu(fix->setting.data); in rtl8152_fw_phy_fixup()
5020 data |= __le16_to_cpu(fix->setting.data); in rtl8152_fw_phy_fixup()
5023 data &= ~__le16_to_cpu(fix->setting.data); in rtl8152_fw_phy_fixup()
5026 data ^= __le16_to_cpu(fix->setting.data); in rtl8152_fw_phy_fixup()
5034 dev_dbg(&tp->intf->dev, "applied ocp %x %x\n", addr, data); in rtl8152_fw_phy_fixup()
5045 num = phy->pre_num; in rtl8152_fw_phy_union_apply()
5047 sram_write(tp, __le16_to_cpu(phy->pre_set[i].addr), in rtl8152_fw_phy_union_apply()
5048 __le16_to_cpu(phy->pre_set[i].data)); in rtl8152_fw_phy_union_apply()
5050 length = __le32_to_cpu(phy->blk_hdr.length); in rtl8152_fw_phy_union_apply()
5051 length -= __le16_to_cpu(phy->fw_offset); in rtl8152_fw_phy_union_apply()
5053 data = (__le16 *)((u8 *)phy + __le16_to_cpu(phy->fw_offset)); in rtl8152_fw_phy_union_apply()
5055 ocp_reg_write(tp, OCP_SRAM_ADDR, __le16_to_cpu(phy->fw_reg)); in rtl8152_fw_phy_union_apply()
5059 num = phy->bp_num; in rtl8152_fw_phy_union_apply()
5061 sram_write(tp, __le16_to_cpu(phy->bp[i].addr), __le16_to_cpu(phy->bp[i].data)); in rtl8152_fw_phy_union_apply()
5063 if (phy->bp_num && phy->bp_en.addr) in rtl8152_fw_phy_union_apply()
5064 sram_write(tp, __le16_to_cpu(phy->bp_en.addr), __le16_to_cpu(phy->bp_en.data)); in rtl8152_fw_phy_union_apply()
5066 dev_dbg(&tp->intf->dev, "successfully applied %s\n", phy->info); in rtl8152_fw_phy_union_apply()
5077 mode_reg = __le16_to_cpu(phy->mode_reg); in rtl8152_fw_phy_nc_apply()
5078 sram_write(tp, mode_reg, __le16_to_cpu(phy->mode_pre)); in rtl8152_fw_phy_nc_apply()
5079 sram_write(tp, __le16_to_cpu(phy->ba_reg), in rtl8152_fw_phy_nc_apply()
5080 __le16_to_cpu(phy->ba_data)); in rtl8152_fw_phy_nc_apply()
5082 length = __le32_to_cpu(phy->blk_hdr.length); in rtl8152_fw_phy_nc_apply()
5083 length -= __le16_to_cpu(phy->fw_offset); in rtl8152_fw_phy_nc_apply()
5085 data = (__le16 *)((u8 *)phy + __le16_to_cpu(phy->fw_offset)); in rtl8152_fw_phy_nc_apply()
5087 ocp_reg_write(tp, OCP_SRAM_ADDR, __le16_to_cpu(phy->fw_reg)); in rtl8152_fw_phy_nc_apply()
5091 sram_write(tp, __le16_to_cpu(phy->patch_en_addr), in rtl8152_fw_phy_nc_apply()
5092 __le16_to_cpu(phy->patch_en_value)); in rtl8152_fw_phy_nc_apply()
5094 bp_index = __le16_to_cpu(phy->bp_start); in rtl8152_fw_phy_nc_apply()
5095 num = __le16_to_cpu(phy->bp_num); in rtl8152_fw_phy_nc_apply()
5097 sram_write(tp, bp_index, __le16_to_cpu(phy->bp[i])); in rtl8152_fw_phy_nc_apply()
5101 sram_write(tp, mode_reg, __le16_to_cpu(phy->mode_post)); in rtl8152_fw_phy_nc_apply()
5103 dev_dbg(&tp->intf->dev, "successfully applied %s\n", phy->info); in rtl8152_fw_phy_nc_apply()
5112 switch (__le32_to_cpu(mac->blk_hdr.type)) { in rtl8152_fw_mac_apply()
5123 fw_ver_reg = __le16_to_cpu(mac->fw_ver_reg); in rtl8152_fw_mac_apply()
5124 if (fw_ver_reg && ocp_read_byte(tp, MCU_TYPE_USB, fw_ver_reg) >= mac->fw_ver_data) { in rtl8152_fw_mac_apply()
5125 dev_dbg(&tp->intf->dev, "%s firmware has been the newest\n", type ? "PLA" : "USB"); in rtl8152_fw_mac_apply()
5131 /* Enable backup/restore of MACDBG. This is required after clearing PLA in rtl8152_fw_mac_apply()
5134 if (tp->version == RTL_VER_04 && type == MCU_TYPE_PLA && in rtl8152_fw_mac_apply()
5140 length = __le32_to_cpu(mac->blk_hdr.length); in rtl8152_fw_mac_apply()
5141 length -= __le16_to_cpu(mac->fw_offset); in rtl8152_fw_mac_apply()
5144 data += __le16_to_cpu(mac->fw_offset); in rtl8152_fw_mac_apply()
5146 generic_ocp_write(tp, __le16_to_cpu(mac->fw_reg), 0xff, length, data, in rtl8152_fw_mac_apply()
5149 ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr), in rtl8152_fw_mac_apply()
5150 __le16_to_cpu(mac->bp_ba_value)); in rtl8152_fw_mac_apply()
5152 generic_ocp_write(tp, __le16_to_cpu(mac->bp_start), BYTE_EN_DWORD, in rtl8152_fw_mac_apply()
5153 __le16_to_cpu(mac->bp_num) << 1, mac->bp, type); in rtl8152_fw_mac_apply()
5155 bp_en_addr = __le16_to_cpu(mac->bp_en_addr); in rtl8152_fw_mac_apply()
5158 __le16_to_cpu(mac->bp_en_value)); in rtl8152_fw_mac_apply()
5162 mac->fw_ver_data); in rtl8152_fw_mac_apply()
5164 dev_dbg(&tp->intf->dev, "successfully applied %s\n", mac->info); in rtl8152_fw_mac_apply()
5169 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl8152_apply_firmware()
5176 if (IS_ERR_OR_NULL(rtl_fw->fw)) in rtl8152_apply_firmware()
5179 fw = rtl_fw->fw; in rtl8152_apply_firmware()
5180 fw_hdr = (struct fw_header *)fw->data; in rtl8152_apply_firmware()
5182 if (rtl_fw->pre_fw) in rtl8152_apply_firmware()
5183 rtl_fw->pre_fw(tp); in rtl8152_apply_firmware()
5185 for (i = offsetof(struct fw_header, blocks); i < fw->size;) { in rtl8152_apply_firmware()
5186 struct fw_block *block = (struct fw_block *)&fw->data[i]; in rtl8152_apply_firmware()
5188 switch (__le32_to_cpu(block->type)) { in rtl8152_apply_firmware()
5199 key_addr = __le16_to_cpu(key->key_reg); in rtl8152_apply_firmware()
5200 rtl_pre_ram_code(tp, key_addr, __le16_to_cpu(key->key_data), !power_cut); in rtl8152_apply_firmware()
5234 i += ALIGN(__le32_to_cpu(block->length), 8); in rtl8152_apply_firmware()
5238 if (rtl_fw->post_fw) in rtl8152_apply_firmware()
5239 rtl_fw->post_fw(tp); in rtl8152_apply_firmware()
5242 strscpy(rtl_fw->version, fw_hdr->version, RTL_VER_SIZE); in rtl8152_apply_firmware()
5243 dev_info(&tp->intf->dev, "load %s successfully\n", rtl_fw->version); in rtl8152_apply_firmware()
5248 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl8152_release_firmware()
5250 if (!IS_ERR_OR_NULL(rtl_fw->fw)) { in rtl8152_release_firmware()
5251 release_firmware(rtl_fw->fw); in rtl8152_release_firmware()
5252 rtl_fw->fw = NULL; in rtl8152_release_firmware()
5258 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl8152_request_firmware()
5261 if (rtl_fw->fw || !rtl_fw->fw_name) { in rtl8152_request_firmware()
5262 dev_info(&tp->intf->dev, "skip request firmware\n"); in rtl8152_request_firmware()
5267 rc = request_firmware(&rtl_fw->fw, rtl_fw->fw_name, &tp->intf->dev); in rtl8152_request_firmware()
5273 release_firmware(rtl_fw->fw); in rtl8152_request_firmware()
5277 rtl_fw->fw = ERR_PTR(rc); in rtl8152_request_firmware()
5279 dev_warn(&tp->intf->dev, in rtl8152_request_firmware()
5281 rtl_fw->fw_name, rc); in rtl8152_request_firmware()
5287 static void r8152_aldps_en(struct r8152 *tp, bool enable) in r8152_aldps_en() argument
5289 if (enable) { in r8152_aldps_en()
5324 static void r8152_eee_en(struct r8152 *tp, bool enable) in r8152_eee_en() argument
5334 if (enable) { in r8152_eee_en()
5355 static void r8153_eee_en(struct r8152 *tp, bool enable) in r8153_eee_en() argument
5363 if (enable) { in r8153_eee_en()
5374 tp->ups_info.eee = enable; in r8153_eee_en()
5377 static void r8156_eee_en(struct r8152 *tp, bool enable) in r8156_eee_en() argument
5381 r8153_eee_en(tp, enable); in r8156_eee_en()
5385 if (enable) in r8156_eee_en()
5393 static void rtl_eee_enable(struct r8152 *tp, bool enable) in rtl_eee_enable() argument
5395 switch (tp->version) { in rtl_eee_enable()
5399 if (enable) { in rtl_eee_enable()
5402 tp->eee_adv); in rtl_eee_enable()
5415 if (enable) { in rtl_eee_enable()
5417 ocp_reg_write(tp, OCP_EEE_ADV, tp->eee_adv); in rtl_eee_enable()
5428 if (enable) { in rtl_eee_enable()
5430 ocp_reg_write(tp, OCP_EEE_ADV, tp->eee_adv); in rtl_eee_enable()
5449 tp->ups_info.flow_control = true; in r8152b_enable_fc()
5462 rtl_eee_enable(tp, tp->eee_en); in r8152b_hw_phy_cfg()
5466 set_bit(PHY_RESET, &tp->flags); in r8152b_hw_phy_cfg()
5475 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in wait_oob_link_list_ready()
5491 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8156b_wait_loading_flash()
5534 if (tp->udev->speed == USB_SPEED_FULL || in r8152b_exit_oob()
5535 tp->udev->speed == USB_SPEED_LOW) { in r8152b_exit_oob()
5557 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in r8152b_exit_oob()
5615 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153_pre_firmware_1()
5616 return -ENODEV; in r8153_pre_firmware_1()
5654 /* enable bp0 if support USB_SPEED_SUPER only */ in r8153_post_firmware_2()
5664 /* enable U3P3 check, set the counter to 4 */ in r8153_post_firmware_2()
5695 /* enable fc timer and set timer to 1 second. */ in r8153b_pre_firmware_1()
5706 /* enable bp0 for RTL8153-BND */ in r8153b_post_firmware_1()
5759 static void r8153_aldps_en(struct r8152 *tp, bool enable) in r8153_aldps_en() argument
5764 if (enable) { in r8153_aldps_en()
5773 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153_aldps_en()
5781 tp->ups_info.aldps = enable; in r8153_aldps_en()
5789 /* disable ALDPS before updating the PHY parameters */ in r8153_hw_phy_cfg()
5797 if (tp->version == RTL_VER_03) { in r8153_hw_phy_cfg()
5819 /* Enable LPF corner auto tune */ in r8153_hw_phy_cfg()
5826 if (tp->eee_en) in r8153_hw_phy_cfg()
5832 switch (tp->version) { in r8153_hw_phy_cfg()
5843 set_bit(PHY_RESET, &tp->flags); in r8153_hw_phy_cfg()
5869 /* disable ALDPS before updating the PHY parameters */ in r8153b_hw_phy_cfg()
5895 r8153b_green_en(tp, test_bit(GREEN_ETHERNET, &tp->flags)); in r8153b_hw_phy_cfg()
5905 * read efuse offset 0x7d to get a 17-bit data. Remove the dummy/fake in r8153b_hw_phy_cfg()
5906 * bit (bit3) to rebuild the real 16-bit data. Write the data to the in r8153b_hw_phy_cfg()
5914 /* ups mode tx-link-pulse timing adjustment: in r8153b_hw_phy_cfg()
5938 tp->ups_info.eee_ckdiv = true; in r8153b_hw_phy_cfg()
5943 tp->ups_info.eee_cmod_lv = true; in r8153b_hw_phy_cfg()
5944 tp->ups_info._10m_ckdiv = true; in r8153b_hw_phy_cfg()
5945 tp->ups_info.eee_plloff_giga = true; in r8153b_hw_phy_cfg()
5949 tp->ups_info._250m_ckdiv = true; in r8153b_hw_phy_cfg()
5954 if (tp->eee_en) in r8153b_hw_phy_cfg()
5960 set_bit(PHY_RESET, &tp->flags); in r8153b_hw_phy_cfg()
5967 tp->ups_info.r_tune = true; in r8153c_hw_phy_cfg()
5972 ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, mtu_to_size(tp->netdev->mtu)); in rtl8153_change_mtu()
6006 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in r8153_first_init()
6051 switch (tp->version) { in r8153_enter_oob()
6106 return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 6 * 1024); in fc_pause_on_auto()
6111 return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 14 * 1024); in fc_pause_off_auto()
6116 u32 pause_on = tp->fc_pause_on ? tp->fc_pause_on : fc_pause_on_auto(tp); in r8156_fc_parameter()
6117 u32 pause_off = tp->fc_pause_off ? tp->fc_pause_off : fc_pause_off_auto(tp); in r8156_fc_parameter()
6128 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8156_enable()
6129 return -ENODEV; in rtl8156_enable()
6152 if (tp->udev->speed == USB_SPEED_HIGH) { in rtl8156_enable()
6186 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8156b_enable()
6187 return -ENODEV; in rtl8156b_enable()
6209 if (tp->udev->speed == USB_SPEED_HIGH) { in rtl8156b_enable()
6237 return -EINVAL; in rtl8152_set_speed()
6244 tp->ups_info.speed_duplex = FORCE_10M_FULL; in rtl8152_set_speed()
6246 tp->ups_info.speed_duplex = FORCE_10M_HALF; in rtl8152_set_speed()
6253 tp->ups_info.speed_duplex = FORCE_100M_FULL; in rtl8152_set_speed()
6255 tp->ups_info.speed_duplex = FORCE_100M_HALF; in rtl8152_set_speed()
6259 if (tp->mii.supports_gmii) { in rtl8152_set_speed()
6261 tp->ups_info.speed_duplex = NWAY_1000M_FULL; in rtl8152_set_speed()
6266 ret = -EINVAL; in rtl8152_set_speed()
6271 tp->mii.full_duplex = 1; in rtl8152_set_speed()
6273 tp->mii.full_duplex = 0; in rtl8152_set_speed()
6275 tp->mii.force_media = 1; in rtl8152_set_speed()
6283 if (tp->mii.supports_gmii) { in rtl8152_set_speed()
6286 if (tp->support_2500full) in rtl8152_set_speed()
6291 return -EINVAL; in rtl8152_set_speed()
6298 tp->ups_info.speed_duplex = NWAY_10M_HALF; in rtl8152_set_speed()
6302 tp->ups_info.speed_duplex = NWAY_10M_FULL; in rtl8152_set_speed()
6307 tp->ups_info.speed_duplex = NWAY_100M_HALF; in rtl8152_set_speed()
6311 tp->ups_info.speed_duplex = NWAY_100M_FULL; in rtl8152_set_speed()
6316 tp->mii.advertising = new1; in rtl8152_set_speed()
6319 if (tp->mii.supports_gmii) { in rtl8152_set_speed()
6326 tp->ups_info.speed_duplex = NWAY_1000M_FULL; in rtl8152_set_speed()
6333 if (tp->support_2500full) { in rtl8152_set_speed()
6339 tp->ups_info.speed_duplex = NWAY_2500M_FULL; in rtl8152_set_speed()
6348 tp->mii.force_media = 0; in rtl8152_set_speed()
6351 if (test_and_clear_bit(PHY_RESET, &tp->flags)) in rtl8152_set_speed()
6372 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8152_up()
6382 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) { in rtl8152_down()
6397 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8153_up()
6419 switch (tp->version) { in rtl8153_up()
6437 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) { in rtl8153_down()
6458 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8153b_up()
6474 if (tp->udev->speed >= USB_SPEED_SUPER) in rtl8153b_up()
6482 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) { in rtl8153b_down()
6501 ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, mtu_to_size(tp->netdev->mtu)); in rtl8153c_change_mtu()
6509 if (tp->netdev->mtu < 8000) in rtl8153c_change_mtu()
6519 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8153c_up()
6552 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in rtl8153c_up()
6584 u32 rx_max_size = mtu_to_size(tp->netdev->mtu); in rtl8156_change_mtu()
6600 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8156_up()
6625 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in rtl8156_up()
6629 switch (tp->version) { in rtl8156_up()
6657 if (tp->saved_wolopts != __rtl_get_wol(tp)) { in rtl8156_up()
6658 netif_warn(tp, ifup, tp->netdev, "wol setting is changed\n"); in rtl8156_up()
6659 __rtl_set_wol(tp, tp->saved_wolopts); in rtl8156_up()
6665 if (tp->udev->speed >= USB_SPEED_SUPER) in rtl8156_up()
6673 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) { in rtl8156_down()
6731 tp->ocp_base = 0x2000; in rtl8152_in_nway()
6769 struct net_device *netdev = tp->netdev; in set_carrier()
6770 struct napi_struct *napi = &tp->napi; in set_carrier()
6777 tp->rtl_ops.enable(tp); in set_carrier()
6782 clear_bit(RTL8152_SET_RX_MODE, &tp->flags); in set_carrier()
6788 skb_queue_len(&tp->tx_queue) < tp->tx_qlen) { in set_carrier()
6794 tasklet_disable(&tp->tx_tl); in set_carrier()
6796 tp->rtl_ops.disable(tp); in set_carrier()
6798 tasklet_enable(&tp->tx_tl); in set_carrier()
6811 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags) || !netif_running(tp->netdev)) in rtl_work_func_t()
6814 if (usb_autopm_get_interface(tp->intf) < 0) in rtl_work_func_t()
6817 if (!test_bit(WORK_ENABLE, &tp->flags)) in rtl_work_func_t()
6820 if (!mutex_trylock(&tp->control)) { in rtl_work_func_t()
6821 schedule_delayed_work(&tp->schedule, 0); in rtl_work_func_t()
6825 if (test_and_clear_bit(RTL8152_LINK_CHG, &tp->flags)) in rtl_work_func_t()
6828 if (test_and_clear_bit(RTL8152_SET_RX_MODE, &tp->flags)) in rtl_work_func_t()
6829 _rtl8152_set_rx_mode(tp->netdev); in rtl_work_func_t()
6832 if (test_and_clear_bit(SCHEDULE_TASKLET, &tp->flags) && in rtl_work_func_t()
6833 netif_carrier_ok(tp->netdev)) in rtl_work_func_t()
6834 tasklet_schedule(&tp->tx_tl); in rtl_work_func_t()
6836 if (test_and_clear_bit(RX_EPROTO, &tp->flags) && in rtl_work_func_t()
6837 !list_empty(&tp->rx_done)) in rtl_work_func_t()
6838 napi_schedule(&tp->napi); in rtl_work_func_t()
6840 mutex_unlock(&tp->control); in rtl_work_func_t()
6843 usb_autopm_put_interface(tp->intf); in rtl_work_func_t()
6850 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl_hw_phy_work_func_t()
6853 if (usb_autopm_get_interface(tp->intf) < 0) in rtl_hw_phy_work_func_t()
6856 mutex_lock(&tp->control); in rtl_hw_phy_work_func_t()
6858 if (rtl8152_request_firmware(tp) == -ENODEV && tp->rtl_fw.retry) { in rtl_hw_phy_work_func_t()
6859 tp->rtl_fw.retry = false; in rtl_hw_phy_work_func_t()
6860 tp->rtl_fw.fw = NULL; in rtl_hw_phy_work_func_t()
6864 queue_delayed_work(system_long_wq, &tp->hw_phy_work, HZ * 10); in rtl_hw_phy_work_func_t()
6868 tp->rtl_ops.hw_phy_cfg(tp); in rtl_hw_phy_work_func_t()
6870 rtl8152_set_speed(tp, tp->autoneg, tp->speed, tp->duplex, in rtl_hw_phy_work_func_t()
6871 tp->advertising); in rtl_hw_phy_work_func_t()
6874 mutex_unlock(&tp->control); in rtl_hw_phy_work_func_t()
6876 usb_autopm_put_interface(tp->intf); in rtl_hw_phy_work_func_t()
6888 usb_autopm_get_interface(tp->intf); in rtl_notifier()
6893 usb_autopm_put_interface(tp->intf); in rtl_notifier()
6911 if (work_busy(&tp->hw_phy_work.work) & WORK_BUSY_PENDING) { in rtl8152_open()
6912 cancel_delayed_work_sync(&tp->hw_phy_work); in rtl8152_open()
6913 rtl_hw_phy_work_func_t(&tp->hw_phy_work.work); in rtl8152_open()
6920 res = usb_autopm_get_interface(tp->intf); in rtl8152_open()
6924 mutex_lock(&tp->control); in rtl8152_open()
6926 tp->rtl_ops.up(tp); in rtl8152_open()
6930 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_open()
6932 res = usb_submit_urb(tp->intr_urb, GFP_KERNEL); in rtl8152_open()
6934 if (res == -ENODEV) in rtl8152_open()
6935 netif_device_detach(tp->netdev); in rtl8152_open()
6940 napi_enable(&tp->napi); in rtl8152_open()
6941 tasklet_enable(&tp->tx_tl); in rtl8152_open()
6943 mutex_unlock(&tp->control); in rtl8152_open()
6945 usb_autopm_put_interface(tp->intf); in rtl8152_open()
6947 tp->pm_notifier.notifier_call = rtl_notifier; in rtl8152_open()
6948 register_pm_notifier(&tp->pm_notifier); in rtl8152_open()
6953 mutex_unlock(&tp->control); in rtl8152_open()
6954 usb_autopm_put_interface(tp->intf); in rtl8152_open()
6967 unregister_pm_notifier(&tp->pm_notifier); in rtl8152_close()
6969 tasklet_disable(&tp->tx_tl); in rtl8152_close()
6970 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_close()
6971 usb_kill_urb(tp->intr_urb); in rtl8152_close()
6972 cancel_delayed_work_sync(&tp->schedule); in rtl8152_close()
6973 napi_disable(&tp->napi); in rtl8152_close()
6976 res = usb_autopm_get_interface(tp->intf); in rtl8152_close()
6977 if (res < 0 || test_bit(RTL8152_INACCESSIBLE, &tp->flags)) { in rtl8152_close()
6981 mutex_lock(&tp->control); in rtl8152_close()
6983 tp->rtl_ops.down(tp); in rtl8152_close()
6985 mutex_unlock(&tp->control); in rtl8152_close()
6989 usb_autopm_put_interface(tp->intf); in rtl8152_close()
7010 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8152b_init()
7021 if (tp->version == RTL_VER_01) { in r8152b_init()
7042 /* enable rx aggregation */ in r8152b_init()
7054 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153_init()
7065 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153_init()
7071 if (tp->version == RTL_VER_03 || tp->version == RTL_VER_04 || in r8153_init()
7072 tp->version == RTL_VER_05) in r8153_init()
7085 if (tp->version == RTL_VER_04) { in r8153_init()
7094 } else if (tp->version == RTL_VER_05) { in r8153_init()
7105 } else if (tp->version == RTL_VER_06) { in r8153_init()
7137 if (tp->version == RTL_VER_04 && tp->udev->speed < USB_SPEED_SUPER) in r8153_init()
7154 usb_enable_lpm(tp->udev); in r8153_init()
7167 if (tp->dell_tb_rx_agg_bug) in r8153_init()
7174 switch (tp->udev->speed) { in r8153_init()
7177 tp->coalesce = COALESCE_SUPER; in r8153_init()
7180 tp->coalesce = COALESCE_HIGH; in r8153_init()
7183 tp->coalesce = COALESCE_SLOW; in r8153_init()
7194 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153b_init()
7205 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153b_init()
7237 if (tp->udev->speed >= USB_SPEED_SUPER) in r8153b_init()
7240 usb_enable_lpm(tp->udev); in r8153b_init()
7249 if (tp->version == RTL_VER_09) { in r8153b_init()
7258 set_bit(GREEN_ETHERNET, &tp->flags); in r8153b_init()
7267 tp->coalesce = 15000; /* 15 us */ in r8153b_init()
7276 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153c_init()
7296 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153c_init()
7331 usb_enable_lpm(tp->udev); in r8153c_init()
7340 set_bit(GREEN_ETHERNET, &tp->flags); in r8153c_init()
7349 tp->coalesce = 15000; /* 15 us */ in r8153c_init()
7379 /* disable ALDPS before updating the PHY parameters */ in r8156_hw_phy_cfg()
7392 switch (tp->version) { in r8156_hw_phy_cfg()
7570 tp->ups_info._10m_ckdiv = true; in r8156_hw_phy_cfg()
7571 tp->ups_info.eee_plloff_100 = false; in r8156_hw_phy_cfg()
7572 tp->ups_info.eee_plloff_giga = false; in r8156_hw_phy_cfg()
7577 tp->ups_info.eee_ckdiv = false; in r8156_hw_phy_cfg()
7581 tp->ups_info._250m_ckdiv = false; in r8156_hw_phy_cfg()
7585 /* enable ADC Ibias Cal */ in r8156_hw_phy_cfg()
7590 /* enable Thermal Sensor */ in r8156_hw_phy_cfg()
7682 rtl_green_en(tp, test_bit(GREEN_ETHERNET, &tp->flags)); in r8156_hw_phy_cfg()
7690 tp->ups_info.lite_mode = 0; in r8156_hw_phy_cfg()
7692 if (tp->eee_en) in r8156_hw_phy_cfg()
7699 set_bit(PHY_RESET, &tp->flags); in r8156_hw_phy_cfg()
7707 switch (tp->version) { in r8156b_hw_phy_cfg()
7766 /* disable ALDPS before updating the PHY parameters */ in r8156b_hw_phy_cfg()
7779 switch (tp->version) { in r8156b_hw_phy_cfg()
8050 /* Green Table-PGA, 1G full viterbi */ in r8156b_hw_phy_cfg()
8088 tp->ups_info._10m_ckdiv = true; in r8156b_hw_phy_cfg()
8089 tp->ups_info.eee_plloff_100 = false; in r8156b_hw_phy_cfg()
8090 tp->ups_info.eee_plloff_giga = false; in r8156b_hw_phy_cfg()
8095 tp->ups_info.eee_ckdiv = false; in r8156b_hw_phy_cfg()
8099 rtl_green_en(tp, test_bit(GREEN_ETHERNET, &tp->flags)); in r8156b_hw_phy_cfg()
8107 tp->ups_info.lite_mode = 0; in r8156b_hw_phy_cfg()
8109 if (tp->eee_en) in r8156b_hw_phy_cfg()
8116 set_bit(PHY_RESET, &tp->flags); in r8156b_hw_phy_cfg()
8125 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8156_init()
8146 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8156_init()
8179 if (tp->udev->speed >= USB_SPEED_SUPER) in r8156_init()
8182 usb_enable_lpm(tp->udev); in r8156_init()
8198 set_bit(GREEN_ETHERNET, &tp->flags); in r8156_init()
8212 tp->coalesce = 15000; /* 15 us */ in r8156_init()
8221 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8156b_init()
8240 switch (tp->version) { in r8156b_init()
8255 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8156b_init()
8291 if (tp->udev->speed >= USB_SPEED_SUPER) in r8156b_init()
8294 usb_enable_lpm(tp->udev); in r8156b_init()
8304 /* enable fc timer and set timer to 600 ms. */ in r8156b_init()
8332 set_bit(GREEN_ETHERNET, &tp->flags); in r8156b_init()
8342 tp->coalesce = 15000; /* 15 us */ in r8156b_init()
8347 struct usb_host_interface *alt = intf->cur_altsetting; in rtl_check_vendor_ok()
8351 dev_err(&intf->dev, "Expected endpoints are not found\n"); in rtl_check_vendor_ok()
8357 dev_err(&intf->dev, "Invalid Rx endpoint address\n"); in rtl_check_vendor_ok()
8363 dev_err(&intf->dev, "Invalid Tx endpoint address\n"); in rtl_check_vendor_ok()
8369 dev_err(&intf->dev, "Invalid interrupt endpoint address\n"); in rtl_check_vendor_ok()
8383 if (!tp || !test_bit(PROBED_WITH_NO_ERRORS, &tp->flags)) in rtl8152_pre_reset()
8386 netdev = tp->netdev; in rtl8152_pre_reset()
8391 tasklet_disable(&tp->tx_tl); in rtl8152_pre_reset()
8392 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_pre_reset()
8393 usb_kill_urb(tp->intr_urb); in rtl8152_pre_reset()
8394 cancel_delayed_work_sync(&tp->schedule); in rtl8152_pre_reset()
8395 napi_disable(&tp->napi); in rtl8152_pre_reset()
8397 mutex_lock(&tp->control); in rtl8152_pre_reset()
8398 set_bit(IN_PRE_RESET, &tp->flags); in rtl8152_pre_reset()
8399 tp->rtl_ops.disable(tp); in rtl8152_pre_reset()
8400 clear_bit(IN_PRE_RESET, &tp->flags); in rtl8152_pre_reset()
8401 mutex_unlock(&tp->control); in rtl8152_pre_reset()
8413 if (!tp || !test_bit(PROBED_WITH_NO_ERRORS, &tp->flags)) in rtl8152_post_reset()
8420 dev_set_mac_address (tp->netdev, &sa, NULL); in rtl8152_post_reset()
8422 netdev = tp->netdev; in rtl8152_post_reset()
8426 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_post_reset()
8428 mutex_lock(&tp->control); in rtl8152_post_reset()
8429 tp->rtl_ops.enable(tp); in rtl8152_post_reset()
8432 mutex_unlock(&tp->control); in rtl8152_post_reset()
8435 napi_enable(&tp->napi); in rtl8152_post_reset()
8436 tasklet_enable(&tp->tx_tl); in rtl8152_post_reset()
8438 usb_submit_urb(tp->intr_urb, GFP_KERNEL); in rtl8152_post_reset()
8440 if (!list_empty(&tp->rx_done)) in rtl8152_post_reset()
8441 napi_schedule(&tp->napi); in rtl8152_post_reset()
8450 bool sw_linking = !!netif_carrier_ok(tp->netdev); in delay_autosuspend()
8457 if (work_busy(&tp->schedule.work) || sw_linking != hw_linking) in delay_autosuspend()
8463 if (!sw_linking && tp->rtl_ops.in_nway(tp)) in delay_autosuspend()
8465 else if (!skb_queue_empty(&tp->tx_queue)) in delay_autosuspend()
8473 struct net_device *netdev = tp->netdev; in rtl8152_runtime_resume()
8475 if (netif_running(netdev) && netdev->flags & IFF_UP) { in rtl8152_runtime_resume()
8476 struct napi_struct *napi = &tp->napi; in rtl8152_runtime_resume()
8478 tp->rtl_ops.autosuspend_en(tp, false); in rtl8152_runtime_resume()
8480 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_runtime_resume()
8487 tp->rtl_ops.disable(tp); in rtl8152_runtime_resume()
8493 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_resume()
8496 if (!list_empty(&tp->rx_done)) in rtl8152_runtime_resume()
8497 napi_schedule(&tp->napi); in rtl8152_runtime_resume()
8499 usb_submit_urb(tp->intr_urb, GFP_NOIO); in rtl8152_runtime_resume()
8501 if (netdev->flags & IFF_UP) in rtl8152_runtime_resume()
8502 tp->rtl_ops.autosuspend_en(tp, false); in rtl8152_runtime_resume()
8504 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_resume()
8512 struct net_device *netdev = tp->netdev; in rtl8152_system_resume()
8516 if (netif_running(netdev) && (netdev->flags & IFF_UP)) { in rtl8152_system_resume()
8517 tp->rtl_ops.up(tp); in rtl8152_system_resume()
8519 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_system_resume()
8520 usb_submit_urb(tp->intr_urb, GFP_NOIO); in rtl8152_system_resume()
8528 struct net_device *netdev = tp->netdev; in rtl8152_runtime_suspend()
8531 if (!tp->rtl_ops.autosuspend_en) in rtl8152_runtime_suspend()
8532 return -EBUSY; in rtl8152_runtime_suspend()
8534 set_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_suspend()
8537 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { in rtl8152_runtime_suspend()
8552 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_suspend()
8554 ret = -EBUSY; in rtl8152_runtime_suspend()
8559 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_runtime_suspend()
8560 usb_kill_urb(tp->intr_urb); in rtl8152_runtime_suspend()
8562 tp->rtl_ops.autosuspend_en(tp, true); in rtl8152_runtime_suspend()
8565 struct napi_struct *napi = &tp->napi; in rtl8152_runtime_suspend()
8576 ret = -EBUSY; in rtl8152_runtime_suspend()
8586 struct net_device *netdev = tp->netdev; in rtl8152_system_suspend()
8590 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { in rtl8152_system_suspend()
8591 struct napi_struct *napi = &tp->napi; in rtl8152_system_suspend()
8593 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_system_suspend()
8594 usb_kill_urb(tp->intr_urb); in rtl8152_system_suspend()
8595 tasklet_disable(&tp->tx_tl); in rtl8152_system_suspend()
8597 cancel_delayed_work_sync(&tp->schedule); in rtl8152_system_suspend()
8598 tp->rtl_ops.down(tp); in rtl8152_system_suspend()
8600 tasklet_enable(&tp->tx_tl); in rtl8152_system_suspend()
8611 mutex_lock(&tp->control); in rtl8152_suspend()
8618 mutex_unlock(&tp->control); in rtl8152_suspend()
8628 mutex_lock(&tp->control); in rtl8152_resume()
8632 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) in rtl8152_resume()
8637 mutex_unlock(&tp->control); in rtl8152_resume()
8646 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_reset_resume()
8648 tp->rtl_ops.init(tp); in rtl8152_reset_resume()
8649 queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0); in rtl8152_reset_resume()
8658 if (usb_autopm_get_interface(tp->intf) < 0) in rtl8152_get_wol()
8662 wol->supported = 0; in rtl8152_get_wol()
8663 wol->wolopts = 0; in rtl8152_get_wol()
8665 mutex_lock(&tp->control); in rtl8152_get_wol()
8666 wol->supported = WAKE_ANY; in rtl8152_get_wol()
8667 wol->wolopts = __rtl_get_wol(tp); in rtl8152_get_wol()
8668 mutex_unlock(&tp->control); in rtl8152_get_wol()
8671 usb_autopm_put_interface(tp->intf); in rtl8152_get_wol()
8680 return -EOPNOTSUPP; in rtl8152_set_wol()
8682 if (wol->wolopts & ~WAKE_ANY) in rtl8152_set_wol()
8683 return -EINVAL; in rtl8152_set_wol()
8685 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_wol()
8689 mutex_lock(&tp->control); in rtl8152_set_wol()
8691 __rtl_set_wol(tp, wol->wolopts); in rtl8152_set_wol()
8692 tp->saved_wolopts = wol->wolopts & WAKE_ANY; in rtl8152_set_wol()
8694 mutex_unlock(&tp->control); in rtl8152_set_wol()
8696 usb_autopm_put_interface(tp->intf); in rtl8152_set_wol()
8706 return tp->msg_enable; in rtl8152_get_msglevel()
8713 tp->msg_enable = value; in rtl8152_set_msglevel()
8721 strscpy(info->driver, MODULENAME, sizeof(info->driver)); in rtl8152_get_drvinfo()
8722 strscpy(info->version, DRIVER_VERSION, sizeof(info->version)); in rtl8152_get_drvinfo()
8723 usb_make_path(tp->udev, info->bus_info, sizeof(info->bus_info)); in rtl8152_get_drvinfo()
8724 if (!IS_ERR_OR_NULL(tp->rtl_fw.fw)) in rtl8152_get_drvinfo()
8725 strscpy(info->fw_version, tp->rtl_fw.version, in rtl8152_get_drvinfo()
8726 sizeof(info->fw_version)); in rtl8152_get_drvinfo()
8736 if (!tp->mii.mdio_read) in rtl8152_get_link_ksettings()
8737 return -EOPNOTSUPP; in rtl8152_get_link_ksettings()
8739 ret = usb_autopm_get_interface(tp->intf); in rtl8152_get_link_ksettings()
8743 mutex_lock(&tp->control); in rtl8152_get_link_ksettings()
8745 mii_ethtool_get_link_ksettings(&tp->mii, cmd); in rtl8152_get_link_ksettings()
8748 cmd->link_modes.supported, tp->support_2500full); in rtl8152_get_link_ksettings()
8750 if (tp->support_2500full) { in rtl8152_get_link_ksettings()
8752 cmd->link_modes.advertising, in rtl8152_get_link_ksettings()
8756 cmd->link_modes.lp_advertising, in rtl8152_get_link_ksettings()
8760 cmd->base.speed = SPEED_2500; in rtl8152_get_link_ksettings()
8763 mutex_unlock(&tp->control); in rtl8152_get_link_ksettings()
8765 usb_autopm_put_interface(tp->intf); in rtl8152_get_link_ksettings()
8778 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_link_ksettings()
8783 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8787 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8791 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8795 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8799 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8803 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8807 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8810 mutex_lock(&tp->control); in rtl8152_set_link_ksettings()
8812 ret = rtl8152_set_speed(tp, cmd->base.autoneg, cmd->base.speed, in rtl8152_set_link_ksettings()
8813 cmd->base.duplex, advertising); in rtl8152_set_link_ksettings()
8815 tp->autoneg = cmd->base.autoneg; in rtl8152_set_link_ksettings()
8816 tp->speed = cmd->base.speed; in rtl8152_set_link_ksettings()
8817 tp->duplex = cmd->base.duplex; in rtl8152_set_link_ksettings()
8818 tp->advertising = advertising; in rtl8152_set_link_ksettings()
8821 mutex_unlock(&tp->control); in rtl8152_set_link_ksettings()
8823 usb_autopm_put_interface(tp->intf); in rtl8152_set_link_ksettings()
8851 return -EOPNOTSUPP; in rtl8152_get_sset_count()
8861 if (usb_autopm_get_interface(tp->intf) < 0) in rtl8152_get_ethtool_stats()
8866 usb_autopm_put_interface(tp->intf); in rtl8152_get_ethtool_stats()
8906 eee->eee_enabled = tp->eee_en; in r8152_get_eee()
8907 eee->eee_active = !!(supported & adv & lp); in r8152_get_eee()
8908 eee->supported = supported; in r8152_get_eee()
8909 eee->advertised = tp->eee_adv; in r8152_get_eee()
8910 eee->lp_advertised = lp; in r8152_get_eee()
8917 u16 val = ethtool_adv_to_mmd_eee_adv_t(eee->advertised); in r8152_set_eee()
8919 tp->eee_en = eee->eee_enabled; in r8152_set_eee()
8920 tp->eee_adv = val; in r8152_set_eee()
8922 rtl_eee_enable(tp, tp->eee_en); in r8152_set_eee()
8941 eee->eee_enabled = tp->eee_en; in r8153_get_eee()
8942 eee->eee_active = !!(supported & adv & lp); in r8153_get_eee()
8943 eee->supported = supported; in r8153_get_eee()
8944 eee->advertised = tp->eee_adv; in r8153_get_eee()
8945 eee->lp_advertised = lp; in r8153_get_eee()
8956 if (!tp->rtl_ops.eee_get) { in rtl_ethtool_get_eee()
8957 ret = -EOPNOTSUPP; in rtl_ethtool_get_eee()
8961 ret = usb_autopm_get_interface(tp->intf); in rtl_ethtool_get_eee()
8965 mutex_lock(&tp->control); in rtl_ethtool_get_eee()
8967 ret = tp->rtl_ops.eee_get(tp, edata); in rtl_ethtool_get_eee()
8969 mutex_unlock(&tp->control); in rtl_ethtool_get_eee()
8971 usb_autopm_put_interface(tp->intf); in rtl_ethtool_get_eee()
8983 if (!tp->rtl_ops.eee_set) { in rtl_ethtool_set_eee()
8984 ret = -EOPNOTSUPP; in rtl_ethtool_set_eee()
8988 ret = usb_autopm_get_interface(tp->intf); in rtl_ethtool_set_eee()
8992 mutex_lock(&tp->control); in rtl_ethtool_set_eee()
8994 ret = tp->rtl_ops.eee_set(tp, edata); in rtl_ethtool_set_eee()
8996 ret = mii_nway_restart(&tp->mii); in rtl_ethtool_set_eee()
8998 mutex_unlock(&tp->control); in rtl_ethtool_set_eee()
9000 usb_autopm_put_interface(tp->intf); in rtl_ethtool_set_eee()
9011 ret = usb_autopm_get_interface(tp->intf); in rtl8152_nway_reset()
9015 mutex_lock(&tp->control); in rtl8152_nway_reset()
9017 ret = mii_nway_restart(&tp->mii); in rtl8152_nway_reset()
9019 mutex_unlock(&tp->control); in rtl8152_nway_reset()
9021 usb_autopm_put_interface(tp->intf); in rtl8152_nway_reset()
9034 switch (tp->version) { in rtl8152_get_coalesce()
9038 return -EOPNOTSUPP; in rtl8152_get_coalesce()
9043 coalesce->rx_coalesce_usecs = tp->coalesce; in rtl8152_get_coalesce()
9056 switch (tp->version) { in rtl8152_set_coalesce()
9060 return -EOPNOTSUPP; in rtl8152_set_coalesce()
9065 if (coalesce->rx_coalesce_usecs > COALESCE_SLOW) in rtl8152_set_coalesce()
9066 return -EINVAL; in rtl8152_set_coalesce()
9068 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_coalesce()
9072 mutex_lock(&tp->control); in rtl8152_set_coalesce()
9074 if (tp->coalesce != coalesce->rx_coalesce_usecs) { in rtl8152_set_coalesce()
9075 tp->coalesce = coalesce->rx_coalesce_usecs; in rtl8152_set_coalesce()
9079 napi_disable(&tp->napi); in rtl8152_set_coalesce()
9080 tp->rtl_ops.disable(tp); in rtl8152_set_coalesce()
9081 tp->rtl_ops.enable(tp); in rtl8152_set_coalesce()
9083 clear_bit(RTL8152_SET_RX_MODE, &tp->flags); in rtl8152_set_coalesce()
9085 napi_enable(&tp->napi); in rtl8152_set_coalesce()
9090 mutex_unlock(&tp->control); in rtl8152_set_coalesce()
9092 usb_autopm_put_interface(tp->intf); in rtl8152_set_coalesce()
9102 switch (tunable->id) { in rtl8152_get_tunable()
9104 *(u32 *)d = tp->rx_copybreak; in rtl8152_get_tunable()
9107 return -EOPNOTSUPP; in rtl8152_get_tunable()
9120 switch (tunable->id) { in rtl8152_set_tunable()
9126 return -EINVAL; in rtl8152_set_tunable()
9129 if (tp->rx_copybreak != val) { in rtl8152_set_tunable()
9130 if (netdev->flags & IFF_UP) { in rtl8152_set_tunable()
9131 mutex_lock(&tp->control); in rtl8152_set_tunable()
9132 napi_disable(&tp->napi); in rtl8152_set_tunable()
9133 tp->rx_copybreak = val; in rtl8152_set_tunable()
9134 napi_enable(&tp->napi); in rtl8152_set_tunable()
9135 mutex_unlock(&tp->control); in rtl8152_set_tunable()
9137 tp->rx_copybreak = val; in rtl8152_set_tunable()
9142 return -EOPNOTSUPP; in rtl8152_set_tunable()
9155 ring->rx_max_pending = RTL8152_RX_MAX_PENDING; in rtl8152_get_ringparam()
9156 ring->rx_pending = tp->rx_pending; in rtl8152_get_ringparam()
9166 if (ring->rx_pending < (RTL8152_MAX_RX * 2)) in rtl8152_set_ringparam()
9167 return -EINVAL; in rtl8152_set_ringparam()
9169 if (tp->rx_pending != ring->rx_pending) { in rtl8152_set_ringparam()
9170 if (netdev->flags & IFF_UP) { in rtl8152_set_ringparam()
9171 mutex_lock(&tp->control); in rtl8152_set_ringparam()
9172 napi_disable(&tp->napi); in rtl8152_set_ringparam()
9173 tp->rx_pending = ring->rx_pending; in rtl8152_set_ringparam()
9174 napi_enable(&tp->napi); in rtl8152_set_ringparam()
9175 mutex_unlock(&tp->control); in rtl8152_set_ringparam()
9177 tp->rx_pending = ring->rx_pending; in rtl8152_set_ringparam()
9190 if (usb_autopm_get_interface(tp->intf) < 0) in rtl8152_get_pauseparam()
9193 mutex_lock(&tp->control); in rtl8152_get_pauseparam()
9199 mutex_unlock(&tp->control); in rtl8152_get_pauseparam()
9201 usb_autopm_put_interface(tp->intf); in rtl8152_get_pauseparam()
9204 pause->autoneg = 0; in rtl8152_get_pauseparam()
9205 pause->rx_pause = 0; in rtl8152_get_pauseparam()
9206 pause->tx_pause = 0; in rtl8152_get_pauseparam()
9210 pause->autoneg = 1; in rtl8152_get_pauseparam()
9215 pause->rx_pause = 1; in rtl8152_get_pauseparam()
9218 pause->tx_pause = 1; in rtl8152_get_pauseparam()
9228 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_pauseparam()
9232 mutex_lock(&tp->control); in rtl8152_set_pauseparam()
9234 if (pause->autoneg && !(r8152_mdio_read(tp, MII_BMCR) & BMCR_ANENABLE)) { in rtl8152_set_pauseparam()
9235 ret = -EINVAL; in rtl8152_set_pauseparam()
9239 if (pause->rx_pause) in rtl8152_set_pauseparam()
9242 if (pause->tx_pause) in rtl8152_set_pauseparam()
9251 mutex_unlock(&tp->control); in rtl8152_set_pauseparam()
9252 usb_autopm_put_interface(tp->intf); in rtl8152_set_pauseparam()
9289 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8152_ioctl()
9290 return -ENODEV; in rtl8152_ioctl()
9292 res = usb_autopm_get_interface(tp->intf); in rtl8152_ioctl()
9298 data->phy_id = R8152_PHY_ID; /* Internal PHY */ in rtl8152_ioctl()
9302 mutex_lock(&tp->control); in rtl8152_ioctl()
9303 data->val_out = r8152_mdio_read(tp, data->reg_num); in rtl8152_ioctl()
9304 mutex_unlock(&tp->control); in rtl8152_ioctl()
9309 res = -EPERM; in rtl8152_ioctl()
9312 mutex_lock(&tp->control); in rtl8152_ioctl()
9313 r8152_mdio_write(tp, data->reg_num, data->val_in); in rtl8152_ioctl()
9314 mutex_unlock(&tp->control); in rtl8152_ioctl()
9318 res = -EOPNOTSUPP; in rtl8152_ioctl()
9321 usb_autopm_put_interface(tp->intf); in rtl8152_ioctl()
9332 switch (tp->version) { in rtl8152_change_mtu()
9336 dev->mtu = new_mtu; in rtl8152_change_mtu()
9342 ret = usb_autopm_get_interface(tp->intf); in rtl8152_change_mtu()
9346 mutex_lock(&tp->control); in rtl8152_change_mtu()
9348 dev->mtu = new_mtu; in rtl8152_change_mtu()
9351 if (tp->rtl_ops.change_mtu) in rtl8152_change_mtu()
9352 tp->rtl_ops.change_mtu(tp); in rtl8152_change_mtu()
9356 napi_disable(&tp->napi); in rtl8152_change_mtu()
9357 tasklet_disable(&tp->tx_tl); in rtl8152_change_mtu()
9358 tp->rtl_ops.disable(tp); in rtl8152_change_mtu()
9359 tp->rtl_ops.enable(tp); in rtl8152_change_mtu()
9361 tasklet_enable(&tp->tx_tl); in rtl8152_change_mtu()
9362 napi_enable(&tp->napi); in rtl8152_change_mtu()
9368 mutex_unlock(&tp->control); in rtl8152_change_mtu()
9370 usb_autopm_put_interface(tp->intf); in rtl8152_change_mtu()
9391 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8152_unload()
9394 if (tp->version != RTL_VER_01) in rtl8152_unload()
9400 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8153_unload()
9408 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8153b_unload()
9416 struct rtl_ops *ops = &tp->rtl_ops; in rtl_ops_init()
9419 switch (tp->version) { in rtl_ops_init()
9423 ops->init = r8152b_init; in rtl_ops_init()
9424 ops->enable = rtl8152_enable; in rtl_ops_init()
9425 ops->disable = rtl8152_disable; in rtl_ops_init()
9426 ops->up = rtl8152_up; in rtl_ops_init()
9427 ops->down = rtl8152_down; in rtl_ops_init()
9428 ops->unload = rtl8152_unload; in rtl_ops_init()
9429 ops->eee_get = r8152_get_eee; in rtl_ops_init()
9430 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9431 ops->in_nway = rtl8152_in_nway; in rtl_ops_init()
9432 ops->hw_phy_cfg = r8152b_hw_phy_cfg; in rtl_ops_init()
9433 ops->autosuspend_en = rtl_runtime_suspend_enable; in rtl_ops_init()
9434 tp->rx_buf_sz = 16 * 1024; in rtl_ops_init()
9435 tp->eee_en = true; in rtl_ops_init()
9436 tp->eee_adv = MDIO_EEE_100TX; in rtl_ops_init()
9443 ops->init = r8153_init; in rtl_ops_init()
9444 ops->enable = rtl8153_enable; in rtl_ops_init()
9445 ops->disable = rtl8153_disable; in rtl_ops_init()
9446 ops->up = rtl8153_up; in rtl_ops_init()
9447 ops->down = rtl8153_down; in rtl_ops_init()
9448 ops->unload = rtl8153_unload; in rtl_ops_init()
9449 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9450 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9451 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9452 ops->hw_phy_cfg = r8153_hw_phy_cfg; in rtl_ops_init()
9453 ops->autosuspend_en = rtl8153_runtime_enable; in rtl_ops_init()
9454 ops->change_mtu = rtl8153_change_mtu; in rtl_ops_init()
9455 if (tp->udev->speed < USB_SPEED_SUPER) in rtl_ops_init()
9456 tp->rx_buf_sz = 16 * 1024; in rtl_ops_init()
9458 tp->rx_buf_sz = 32 * 1024; in rtl_ops_init()
9459 tp->eee_en = true; in rtl_ops_init()
9460 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9465 ops->init = r8153b_init; in rtl_ops_init()
9466 ops->enable = rtl8153_enable; in rtl_ops_init()
9467 ops->disable = rtl8153_disable; in rtl_ops_init()
9468 ops->up = rtl8153b_up; in rtl_ops_init()
9469 ops->down = rtl8153b_down; in rtl_ops_init()
9470 ops->unload = rtl8153b_unload; in rtl_ops_init()
9471 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9472 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9473 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9474 ops->hw_phy_cfg = r8153b_hw_phy_cfg; in rtl_ops_init()
9475 ops->autosuspend_en = rtl8153b_runtime_enable; in rtl_ops_init()
9476 ops->change_mtu = rtl8153_change_mtu; in rtl_ops_init()
9477 tp->rx_buf_sz = 32 * 1024; in rtl_ops_init()
9478 tp->eee_en = true; in rtl_ops_init()
9479 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9483 tp->eee_en = true; in rtl_ops_init()
9484 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9487 ops->init = r8156_init; in rtl_ops_init()
9488 ops->enable = rtl8156_enable; in rtl_ops_init()
9489 ops->disable = rtl8156_disable; in rtl_ops_init()
9490 ops->up = rtl8156_up; in rtl_ops_init()
9491 ops->down = rtl8156_down; in rtl_ops_init()
9492 ops->unload = rtl8153_unload; in rtl_ops_init()
9493 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9494 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9495 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9496 ops->hw_phy_cfg = r8156_hw_phy_cfg; in rtl_ops_init()
9497 ops->autosuspend_en = rtl8156_runtime_enable; in rtl_ops_init()
9498 ops->change_mtu = rtl8156_change_mtu; in rtl_ops_init()
9499 tp->rx_buf_sz = 48 * 1024; in rtl_ops_init()
9500 tp->support_2500full = 1; in rtl_ops_init()
9505 tp->support_2500full = 1; in rtl_ops_init()
9508 tp->eee_en = true; in rtl_ops_init()
9509 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9510 ops->init = r8156b_init; in rtl_ops_init()
9511 ops->enable = rtl8156b_enable; in rtl_ops_init()
9512 ops->disable = rtl8153_disable; in rtl_ops_init()
9513 ops->up = rtl8156_up; in rtl_ops_init()
9514 ops->down = rtl8156_down; in rtl_ops_init()
9515 ops->unload = rtl8153_unload; in rtl_ops_init()
9516 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9517 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9518 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9519 ops->hw_phy_cfg = r8156b_hw_phy_cfg; in rtl_ops_init()
9520 ops->autosuspend_en = rtl8156_runtime_enable; in rtl_ops_init()
9521 ops->change_mtu = rtl8156_change_mtu; in rtl_ops_init()
9522 tp->rx_buf_sz = 48 * 1024; in rtl_ops_init()
9526 ops->init = r8153c_init; in rtl_ops_init()
9527 ops->enable = rtl8153_enable; in rtl_ops_init()
9528 ops->disable = rtl8153_disable; in rtl_ops_init()
9529 ops->up = rtl8153c_up; in rtl_ops_init()
9530 ops->down = rtl8153b_down; in rtl_ops_init()
9531 ops->unload = rtl8153_unload; in rtl_ops_init()
9532 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9533 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9534 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9535 ops->hw_phy_cfg = r8153c_hw_phy_cfg; in rtl_ops_init()
9536 ops->autosuspend_en = rtl8153c_runtime_enable; in rtl_ops_init()
9537 ops->change_mtu = rtl8153c_change_mtu; in rtl_ops_init()
9538 tp->rx_buf_sz = 32 * 1024; in rtl_ops_init()
9539 tp->eee_en = true; in rtl_ops_init()
9540 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9544 ret = -ENODEV; in rtl_ops_init()
9545 dev_err(&tp->intf->dev, "Unknown Device\n"); in rtl_ops_init()
9552 #define FIRMWARE_8153A_2 "rtl_nic/rtl8153a-2.fw"
9553 #define FIRMWARE_8153A_3 "rtl_nic/rtl8153a-3.fw"
9554 #define FIRMWARE_8153A_4 "rtl_nic/rtl8153a-4.fw"
9555 #define FIRMWARE_8153B_2 "rtl_nic/rtl8153b-2.fw"
9556 #define FIRMWARE_8153C_1 "rtl_nic/rtl8153c-1.fw"
9557 #define FIRMWARE_8156A_2 "rtl_nic/rtl8156a-2.fw"
9558 #define FIRMWARE_8156B_2 "rtl_nic/rtl8156b-2.fw"
9570 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl_fw_init()
9572 switch (tp->version) { in rtl_fw_init()
9574 rtl_fw->fw_name = FIRMWARE_8153A_2; in rtl_fw_init()
9575 rtl_fw->pre_fw = r8153_pre_firmware_1; in rtl_fw_init()
9576 rtl_fw->post_fw = r8153_post_firmware_1; in rtl_fw_init()
9579 rtl_fw->fw_name = FIRMWARE_8153A_3; in rtl_fw_init()
9580 rtl_fw->pre_fw = r8153_pre_firmware_2; in rtl_fw_init()
9581 rtl_fw->post_fw = r8153_post_firmware_2; in rtl_fw_init()
9584 rtl_fw->fw_name = FIRMWARE_8153A_4; in rtl_fw_init()
9585 rtl_fw->post_fw = r8153_post_firmware_3; in rtl_fw_init()
9588 rtl_fw->fw_name = FIRMWARE_8153B_2; in rtl_fw_init()
9589 rtl_fw->pre_fw = r8153b_pre_firmware_1; in rtl_fw_init()
9590 rtl_fw->post_fw = r8153b_post_firmware_1; in rtl_fw_init()
9593 rtl_fw->fw_name = FIRMWARE_8156A_2; in rtl_fw_init()
9594 rtl_fw->post_fw = r8156a_post_firmware_1; in rtl_fw_init()
9598 rtl_fw->fw_name = FIRMWARE_8156B_2; in rtl_fw_init()
9601 rtl_fw->fw_name = FIRMWARE_8153C_1; in rtl_fw_init()
9602 rtl_fw->pre_fw = r8153b_pre_firmware_1; in rtl_fw_init()
9603 rtl_fw->post_fw = r8153c_post_firmware_1; in rtl_fw_init()
9640 dev_warn(&udev->dev, "Needed %d retries to read version\n", i); in __rtl_get_hw_ver()
9695 dev_info(&udev->dev, "Unknown version 0x%04x\n", ocp_data); in __rtl_get_hw_ver()
9708 dev_dbg(&intf->dev, "Detected version 0x%04x\n", version); in rtl8152_get_version()
9716 int parent_vendor_id = le16_to_cpu(udev->parent->descriptor.idVendor); in rtl8152_supports_lenovo_macpassthru()
9717 int product_id = le16_to_cpu(udev->descriptor.idProduct); in rtl8152_supports_lenovo_macpassthru()
9718 int vendor_id = le16_to_cpu(udev->descriptor.idVendor); in rtl8152_supports_lenovo_macpassthru()
9750 dev_err(&intf->dev, "Out of memory\n"); in rtl8152_probe_once()
9751 return -ENOMEM; in rtl8152_probe_once()
9754 SET_NETDEV_DEV(netdev, &intf->dev); in rtl8152_probe_once()
9756 tp->msg_enable = 0x7FFF; in rtl8152_probe_once()
9758 tp->udev = udev; in rtl8152_probe_once()
9759 tp->netdev = netdev; in rtl8152_probe_once()
9760 tp->intf = intf; in rtl8152_probe_once()
9761 tp->version = version; in rtl8152_probe_once()
9763 tp->pipe_ctrl_in = usb_rcvctrlpipe(udev, 0); in rtl8152_probe_once()
9764 tp->pipe_ctrl_out = usb_sndctrlpipe(udev, 0); in rtl8152_probe_once()
9765 tp->pipe_in = usb_rcvbulkpipe(udev, 1); in rtl8152_probe_once()
9766 tp->pipe_out = usb_sndbulkpipe(udev, 2); in rtl8152_probe_once()
9767 tp->pipe_intr = usb_rcvintpipe(udev, 3); in rtl8152_probe_once()
9773 tp->mii.supports_gmii = 0; in rtl8152_probe_once()
9776 tp->mii.supports_gmii = 1; in rtl8152_probe_once()
9786 mutex_init(&tp->control); in rtl8152_probe_once()
9787 INIT_DELAYED_WORK(&tp->schedule, rtl_work_func_t); in rtl8152_probe_once()
9788 INIT_DELAYED_WORK(&tp->hw_phy_work, rtl_hw_phy_work_func_t); in rtl8152_probe_once()
9789 tasklet_setup(&tp->tx_tl, bottom_half); in rtl8152_probe_once()
9790 tasklet_disable(&tp->tx_tl); in rtl8152_probe_once()
9792 netdev->netdev_ops = &rtl8152_netdev_ops; in rtl8152_probe_once()
9793 netdev->watchdog_timeo = RTL8152_TX_TIMEOUT; in rtl8152_probe_once()
9795 netdev->features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG | in rtl8152_probe_once()
9799 netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG | in rtl8152_probe_once()
9803 netdev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | in rtl8152_probe_once()
9807 if (tp->version == RTL_VER_01) { in rtl8152_probe_once()
9808 netdev->features &= ~NETIF_F_RXCSUM; in rtl8152_probe_once()
9809 netdev->hw_features &= ~NETIF_F_RXCSUM; in rtl8152_probe_once()
9812 tp->lenovo_macpassthru = rtl8152_supports_lenovo_macpassthru(udev); in rtl8152_probe_once()
9814 if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial && in rtl8152_probe_once()
9815 (!strcmp(udev->serial, "000001000000") || in rtl8152_probe_once()
9816 !strcmp(udev->serial, "000002000000"))) { in rtl8152_probe_once()
9817 dev_info(&udev->dev, "Dell TB16 Dock, disable RX aggregation"); in rtl8152_probe_once()
9818 tp->dell_tb_rx_agg_bug = 1; in rtl8152_probe_once()
9821 netdev->ethtool_ops = &ops; in rtl8152_probe_once()
9824 /* MTU range: 68 - 1500 or 9194 */ in rtl8152_probe_once()
9825 netdev->min_mtu = ETH_MIN_MTU; in rtl8152_probe_once()
9826 switch (tp->version) { in rtl8152_probe_once()
9834 netdev->max_mtu = size_to_mtu(9 * 1024); in rtl8152_probe_once()
9838 netdev->max_mtu = size_to_mtu(15 * 1024); in rtl8152_probe_once()
9843 netdev->max_mtu = size_to_mtu(16 * 1024); in rtl8152_probe_once()
9849 netdev->max_mtu = ETH_DATA_LEN; in rtl8152_probe_once()
9853 tp->mii.dev = netdev; in rtl8152_probe_once()
9854 tp->mii.mdio_read = read_mii_word; in rtl8152_probe_once()
9855 tp->mii.mdio_write = write_mii_word; in rtl8152_probe_once()
9856 tp->mii.phy_id_mask = 0x3f; in rtl8152_probe_once()
9857 tp->mii.reg_num_mask = 0x1f; in rtl8152_probe_once()
9858 tp->mii.phy_id = R8152_PHY_ID; in rtl8152_probe_once()
9860 tp->autoneg = AUTONEG_ENABLE; in rtl8152_probe_once()
9861 tp->speed = SPEED_100; in rtl8152_probe_once()
9862 tp->advertising = RTL_ADVERTISED_10_HALF | RTL_ADVERTISED_10_FULL | in rtl8152_probe_once()
9864 if (tp->mii.supports_gmii) { in rtl8152_probe_once()
9865 if (tp->support_2500full && in rtl8152_probe_once()
9866 tp->udev->speed >= USB_SPEED_SUPER) { in rtl8152_probe_once()
9867 tp->speed = SPEED_2500; in rtl8152_probe_once()
9868 tp->advertising |= RTL_ADVERTISED_2500_FULL; in rtl8152_probe_once()
9870 tp->speed = SPEED_1000; in rtl8152_probe_once()
9872 tp->advertising |= RTL_ADVERTISED_1000_FULL; in rtl8152_probe_once()
9874 tp->duplex = DUPLEX_FULL; in rtl8152_probe_once()
9876 tp->rx_copybreak = RTL8152_RXFG_HEADSZ; in rtl8152_probe_once()
9877 tp->rx_pending = 10 * RTL8152_MAX_RX; in rtl8152_probe_once()
9879 intf->needs_remote_wakeup = 1; in rtl8152_probe_once()
9884 tp->saved_wolopts = __rtl_get_wol(tp); in rtl8152_probe_once()
9886 tp->rtl_ops.init(tp); in rtl8152_probe_once()
9889 tp->rtl_fw.retry = true; in rtl8152_probe_once()
9891 queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0); in rtl8152_probe_once()
9896 netif_napi_add(netdev, &tp->napi, r8152_poll); in rtl8152_probe_once()
9900 dev_err(&intf->dev, "couldn't register the device\n"); in rtl8152_probe_once()
9904 if (tp->saved_wolopts) in rtl8152_probe_once()
9905 device_set_wakeup_enable(&udev->dev, true); in rtl8152_probe_once()
9907 device_set_wakeup_enable(&udev->dev, false); in rtl8152_probe_once()
9912 if (test_bit(PROBE_SHOULD_RETRY, &tp->flags)) in rtl8152_probe_once()
9915 set_bit(PROBED_WITH_NO_ERRORS, &tp->flags); in rtl8152_probe_once()
9924 tasklet_kill(&tp->tx_tl); in rtl8152_probe_once()
9925 cancel_delayed_work_sync(&tp->hw_phy_work); in rtl8152_probe_once()
9926 if (tp->rtl_ops.unload) in rtl8152_probe_once()
9927 tp->rtl_ops.unload(tp); in rtl8152_probe_once()
9931 if (test_bit(PROBE_SHOULD_RETRY, &tp->flags)) in rtl8152_probe_once()
9932 ret = -EAGAIN; in rtl8152_probe_once()
9947 if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC) in rtl8152_probe()
9948 return -ENODEV; in rtl8152_probe()
9951 return -ENODEV; in rtl8152_probe()
9955 return -ENODEV; in rtl8152_probe()
9959 if (ret != -EAGAIN) in rtl8152_probe()
9962 if (ret == -EAGAIN) { in rtl8152_probe()
9963 dev_err(&intf->dev, in rtl8152_probe()
9965 return -ENODEV; in rtl8152_probe()
9979 unregister_netdev(tp->netdev); in rtl8152_disconnect()
9980 tasklet_kill(&tp->tx_tl); in rtl8152_disconnect()
9981 cancel_delayed_work_sync(&tp->hw_phy_work); in rtl8152_disconnect()
9982 if (tp->rtl_ops.unload) in rtl8152_disconnect()
9983 tp->rtl_ops.unload(tp); in rtl8152_disconnect()
9985 free_netdev(tp->netdev); in rtl8152_disconnect()
10051 c = udev->config; in rtl8152_cfgselector_probe()
10052 num_configs = udev->descriptor.bNumConfigurations; in rtl8152_cfgselector_probe()
10056 if (!c->desc.bNumInterfaces) in rtl8152_cfgselector_probe()
10058 desc = &c->intf_cache[0]->altsetting->desc; in rtl8152_cfgselector_probe()
10059 if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC) in rtl8152_cfgselector_probe()
10064 return -ENODEV; in rtl8152_cfgselector_probe()
10066 if (usb_set_configuration(udev, c->desc.bConfigurationValue)) { in rtl8152_cfgselector_probe()
10067 dev_err(&udev->dev, "Failed to set configuration %d\n", in rtl8152_cfgselector_probe()
10068 c->desc.bConfigurationValue); in rtl8152_cfgselector_probe()
10069 return -ENODEV; in rtl8152_cfgselector_probe()
10076 .name = MODULENAME "-cfgselector",