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 if (generic_ocp_write(tp, __le16_to_cpu(mac->fw_reg), 0xff, length, in rtl8152_fw_mac_apply()
5148 dev_err(&tp->intf->dev, "Write %s fw fail\n", in rtl8152_fw_mac_apply()
5153 ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr), in rtl8152_fw_mac_apply()
5154 __le16_to_cpu(mac->bp_ba_value)); in rtl8152_fw_mac_apply()
5156 if (generic_ocp_write(tp, __le16_to_cpu(mac->bp_start), BYTE_EN_DWORD, in rtl8152_fw_mac_apply()
5157 ALIGN(__le16_to_cpu(mac->bp_num) << 1, 4), in rtl8152_fw_mac_apply()
5158 mac->bp, type) < 0) { in rtl8152_fw_mac_apply()
5159 dev_err(&tp->intf->dev, "Write %s bp fail\n", in rtl8152_fw_mac_apply()
5164 bp_en_addr = __le16_to_cpu(mac->bp_en_addr); in rtl8152_fw_mac_apply()
5167 __le16_to_cpu(mac->bp_en_value)); in rtl8152_fw_mac_apply()
5171 mac->fw_ver_data); in rtl8152_fw_mac_apply()
5173 dev_dbg(&tp->intf->dev, "successfully applied %s\n", mac->info); in rtl8152_fw_mac_apply()
5178 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl8152_apply_firmware()
5185 if (IS_ERR_OR_NULL(rtl_fw->fw)) in rtl8152_apply_firmware()
5188 fw = rtl_fw->fw; in rtl8152_apply_firmware()
5189 fw_hdr = (struct fw_header *)fw->data; in rtl8152_apply_firmware()
5191 if (rtl_fw->pre_fw) in rtl8152_apply_firmware()
5192 rtl_fw->pre_fw(tp); in rtl8152_apply_firmware()
5194 for (i = offsetof(struct fw_header, blocks); i < fw->size;) { in rtl8152_apply_firmware()
5195 struct fw_block *block = (struct fw_block *)&fw->data[i]; in rtl8152_apply_firmware()
5197 switch (__le32_to_cpu(block->type)) { in rtl8152_apply_firmware()
5208 key_addr = __le16_to_cpu(key->key_reg); in rtl8152_apply_firmware()
5209 rtl_pre_ram_code(tp, key_addr, __le16_to_cpu(key->key_data), !power_cut); in rtl8152_apply_firmware()
5243 i += ALIGN(__le32_to_cpu(block->length), 8); in rtl8152_apply_firmware()
5247 if (rtl_fw->post_fw) in rtl8152_apply_firmware()
5248 rtl_fw->post_fw(tp); in rtl8152_apply_firmware()
5251 strscpy(rtl_fw->version, fw_hdr->version, RTL_VER_SIZE); in rtl8152_apply_firmware()
5252 dev_info(&tp->intf->dev, "load %s successfully\n", rtl_fw->version); in rtl8152_apply_firmware()
5257 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl8152_release_firmware()
5259 if (!IS_ERR_OR_NULL(rtl_fw->fw)) { in rtl8152_release_firmware()
5260 release_firmware(rtl_fw->fw); in rtl8152_release_firmware()
5261 rtl_fw->fw = NULL; in rtl8152_release_firmware()
5267 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl8152_request_firmware()
5270 if (rtl_fw->fw || !rtl_fw->fw_name) { in rtl8152_request_firmware()
5271 dev_info(&tp->intf->dev, "skip request firmware\n"); in rtl8152_request_firmware()
5276 rc = request_firmware(&rtl_fw->fw, rtl_fw->fw_name, &tp->intf->dev); in rtl8152_request_firmware()
5282 release_firmware(rtl_fw->fw); in rtl8152_request_firmware()
5286 rtl_fw->fw = ERR_PTR(rc); in rtl8152_request_firmware()
5288 dev_warn(&tp->intf->dev, in rtl8152_request_firmware()
5290 rtl_fw->fw_name, rc); in rtl8152_request_firmware()
5296 static void r8152_aldps_en(struct r8152 *tp, bool enable) in r8152_aldps_en() argument
5298 if (enable) { in r8152_aldps_en()
5333 static void r8152_eee_en(struct r8152 *tp, bool enable) in r8152_eee_en() argument
5343 if (enable) { in r8152_eee_en()
5364 static void r8153_eee_en(struct r8152 *tp, bool enable) in r8153_eee_en() argument
5372 if (enable) { in r8153_eee_en()
5383 tp->ups_info.eee = enable; in r8153_eee_en()
5386 static void r8156_eee_en(struct r8152 *tp, bool enable) in r8156_eee_en() argument
5390 r8153_eee_en(tp, enable); in r8156_eee_en()
5394 if (enable) in r8156_eee_en()
5402 static void rtl_eee_enable(struct r8152 *tp, bool enable) in rtl_eee_enable() argument
5404 switch (tp->version) { in rtl_eee_enable()
5408 if (enable) { in rtl_eee_enable()
5411 tp->eee_adv); in rtl_eee_enable()
5424 if (enable) { in rtl_eee_enable()
5426 ocp_reg_write(tp, OCP_EEE_ADV, tp->eee_adv); in rtl_eee_enable()
5437 if (enable) { in rtl_eee_enable()
5439 ocp_reg_write(tp, OCP_EEE_ADV, tp->eee_adv); in rtl_eee_enable()
5458 tp->ups_info.flow_control = true; in r8152b_enable_fc()
5471 rtl_eee_enable(tp, tp->eee_en); in r8152b_hw_phy_cfg()
5475 set_bit(PHY_RESET, &tp->flags); in r8152b_hw_phy_cfg()
5484 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in wait_oob_link_list_ready()
5500 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8156b_wait_loading_flash()
5543 if (tp->udev->speed == USB_SPEED_FULL || in r8152b_exit_oob()
5544 tp->udev->speed == USB_SPEED_LOW) { in r8152b_exit_oob()
5566 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in r8152b_exit_oob()
5624 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153_pre_firmware_1()
5625 return -ENODEV; in r8153_pre_firmware_1()
5663 /* enable bp0 if support USB_SPEED_SUPER only */ in r8153_post_firmware_2()
5673 /* enable U3P3 check, set the counter to 4 */ in r8153_post_firmware_2()
5704 /* enable fc timer and set timer to 1 second. */ in r8153b_pre_firmware_1()
5715 /* enable bp0 for RTL8153-BND */ in r8153b_post_firmware_1()
5768 static void r8153_aldps_en(struct r8152 *tp, bool enable) in r8153_aldps_en() argument
5773 if (enable) { in r8153_aldps_en()
5782 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153_aldps_en()
5790 tp->ups_info.aldps = enable; in r8153_aldps_en()
5798 /* disable ALDPS before updating the PHY parameters */ in r8153_hw_phy_cfg()
5806 if (tp->version == RTL_VER_03) { in r8153_hw_phy_cfg()
5828 /* Enable LPF corner auto tune */ in r8153_hw_phy_cfg()
5835 if (tp->eee_en) in r8153_hw_phy_cfg()
5841 switch (tp->version) { in r8153_hw_phy_cfg()
5852 set_bit(PHY_RESET, &tp->flags); in r8153_hw_phy_cfg()
5878 /* disable ALDPS before updating the PHY parameters */ in r8153b_hw_phy_cfg()
5904 r8153b_green_en(tp, test_bit(GREEN_ETHERNET, &tp->flags)); in r8153b_hw_phy_cfg()
5914 * read efuse offset 0x7d to get a 17-bit data. Remove the dummy/fake in r8153b_hw_phy_cfg()
5915 * bit (bit3) to rebuild the real 16-bit data. Write the data to the in r8153b_hw_phy_cfg()
5923 /* ups mode tx-link-pulse timing adjustment: in r8153b_hw_phy_cfg()
5947 tp->ups_info.eee_ckdiv = true; in r8153b_hw_phy_cfg()
5952 tp->ups_info.eee_cmod_lv = true; in r8153b_hw_phy_cfg()
5953 tp->ups_info._10m_ckdiv = true; in r8153b_hw_phy_cfg()
5954 tp->ups_info.eee_plloff_giga = true; in r8153b_hw_phy_cfg()
5958 tp->ups_info._250m_ckdiv = true; in r8153b_hw_phy_cfg()
5963 if (tp->eee_en) in r8153b_hw_phy_cfg()
5969 set_bit(PHY_RESET, &tp->flags); in r8153b_hw_phy_cfg()
5976 tp->ups_info.r_tune = true; in r8153c_hw_phy_cfg()
5981 ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, mtu_to_size(tp->netdev->mtu)); in rtl8153_change_mtu()
6015 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in r8153_first_init()
6060 switch (tp->version) { in r8153_enter_oob()
6115 return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 6 * 1024); in fc_pause_on_auto()
6120 return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 14 * 1024); in fc_pause_off_auto()
6125 u32 pause_on = tp->fc_pause_on ? tp->fc_pause_on : fc_pause_on_auto(tp); in r8156_fc_parameter()
6126 u32 pause_off = tp->fc_pause_off ? tp->fc_pause_off : fc_pause_off_auto(tp); in r8156_fc_parameter()
6137 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8156_enable()
6138 return -ENODEV; in rtl8156_enable()
6161 if (tp->udev->speed == USB_SPEED_HIGH) { in rtl8156_enable()
6195 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8156b_enable()
6196 return -ENODEV; in rtl8156b_enable()
6218 if (tp->udev->speed == USB_SPEED_HIGH) { in rtl8156b_enable()
6246 return -EINVAL; in rtl8152_set_speed()
6253 tp->ups_info.speed_duplex = FORCE_10M_FULL; in rtl8152_set_speed()
6255 tp->ups_info.speed_duplex = FORCE_10M_HALF; in rtl8152_set_speed()
6262 tp->ups_info.speed_duplex = FORCE_100M_FULL; in rtl8152_set_speed()
6264 tp->ups_info.speed_duplex = FORCE_100M_HALF; in rtl8152_set_speed()
6268 if (tp->mii.supports_gmii) { in rtl8152_set_speed()
6270 tp->ups_info.speed_duplex = NWAY_1000M_FULL; in rtl8152_set_speed()
6275 ret = -EINVAL; in rtl8152_set_speed()
6280 tp->mii.full_duplex = 1; in rtl8152_set_speed()
6282 tp->mii.full_duplex = 0; in rtl8152_set_speed()
6284 tp->mii.force_media = 1; in rtl8152_set_speed()
6292 if (tp->mii.supports_gmii) { in rtl8152_set_speed()
6295 if (tp->support_2500full) in rtl8152_set_speed()
6300 return -EINVAL; in rtl8152_set_speed()
6307 tp->ups_info.speed_duplex = NWAY_10M_HALF; in rtl8152_set_speed()
6311 tp->ups_info.speed_duplex = NWAY_10M_FULL; in rtl8152_set_speed()
6316 tp->ups_info.speed_duplex = NWAY_100M_HALF; in rtl8152_set_speed()
6320 tp->ups_info.speed_duplex = NWAY_100M_FULL; in rtl8152_set_speed()
6325 tp->mii.advertising = new1; in rtl8152_set_speed()
6328 if (tp->mii.supports_gmii) { in rtl8152_set_speed()
6335 tp->ups_info.speed_duplex = NWAY_1000M_FULL; in rtl8152_set_speed()
6342 if (tp->support_2500full) { in rtl8152_set_speed()
6348 tp->ups_info.speed_duplex = NWAY_2500M_FULL; in rtl8152_set_speed()
6357 tp->mii.force_media = 0; in rtl8152_set_speed()
6360 if (test_and_clear_bit(PHY_RESET, &tp->flags)) in rtl8152_set_speed()
6381 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8152_up()
6391 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) { in rtl8152_down()
6406 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8153_up()
6428 switch (tp->version) { in rtl8153_up()
6446 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) { in rtl8153_down()
6467 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8153b_up()
6483 if (tp->udev->speed >= USB_SPEED_SUPER) in rtl8153b_up()
6491 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) { in rtl8153b_down()
6510 ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, mtu_to_size(tp->netdev->mtu)); in rtl8153c_change_mtu()
6518 if (tp->netdev->mtu < 8000) in rtl8153c_change_mtu()
6528 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8153c_up()
6561 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in rtl8153c_up()
6593 u32 rx_max_size = mtu_to_size(tp->netdev->mtu); in rtl8156_change_mtu()
6609 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8156_up()
6634 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in rtl8156_up()
6638 switch (tp->version) { in rtl8156_up()
6666 if (tp->saved_wolopts != __rtl_get_wol(tp)) { in rtl8156_up()
6667 netif_warn(tp, ifup, tp->netdev, "wol setting is changed\n"); in rtl8156_up()
6668 __rtl_set_wol(tp, tp->saved_wolopts); in rtl8156_up()
6674 if (tp->udev->speed >= USB_SPEED_SUPER) in rtl8156_up()
6682 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) { in rtl8156_down()
6740 tp->ocp_base = 0x2000; in rtl8152_in_nway()
6778 struct net_device *netdev = tp->netdev; in set_carrier()
6779 struct napi_struct *napi = &tp->napi; in set_carrier()
6786 tp->rtl_ops.enable(tp); in set_carrier()
6791 clear_bit(RTL8152_SET_RX_MODE, &tp->flags); in set_carrier()
6797 skb_queue_len(&tp->tx_queue) < tp->tx_qlen) { in set_carrier()
6803 tasklet_disable(&tp->tx_tl); in set_carrier()
6805 tp->rtl_ops.disable(tp); in set_carrier()
6807 tasklet_enable(&tp->tx_tl); in set_carrier()
6820 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags) || !netif_running(tp->netdev)) in rtl_work_func_t()
6823 if (usb_autopm_get_interface(tp->intf) < 0) in rtl_work_func_t()
6826 if (!test_bit(WORK_ENABLE, &tp->flags)) in rtl_work_func_t()
6829 if (!mutex_trylock(&tp->control)) { in rtl_work_func_t()
6830 schedule_delayed_work(&tp->schedule, 0); in rtl_work_func_t()
6834 if (test_and_clear_bit(RTL8152_LINK_CHG, &tp->flags)) in rtl_work_func_t()
6837 if (test_and_clear_bit(RTL8152_SET_RX_MODE, &tp->flags)) in rtl_work_func_t()
6838 _rtl8152_set_rx_mode(tp->netdev); in rtl_work_func_t()
6841 if (test_and_clear_bit(SCHEDULE_TASKLET, &tp->flags) && in rtl_work_func_t()
6842 netif_carrier_ok(tp->netdev)) in rtl_work_func_t()
6843 tasklet_schedule(&tp->tx_tl); in rtl_work_func_t()
6845 if (test_and_clear_bit(RX_EPROTO, &tp->flags) && in rtl_work_func_t()
6846 !list_empty(&tp->rx_done)) in rtl_work_func_t()
6847 napi_schedule(&tp->napi); in rtl_work_func_t()
6849 mutex_unlock(&tp->control); in rtl_work_func_t()
6852 usb_autopm_put_interface(tp->intf); in rtl_work_func_t()
6859 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl_hw_phy_work_func_t()
6862 if (usb_autopm_get_interface(tp->intf) < 0) in rtl_hw_phy_work_func_t()
6865 mutex_lock(&tp->control); in rtl_hw_phy_work_func_t()
6867 if (rtl8152_request_firmware(tp) == -ENODEV && tp->rtl_fw.retry) { in rtl_hw_phy_work_func_t()
6868 tp->rtl_fw.retry = false; in rtl_hw_phy_work_func_t()
6869 tp->rtl_fw.fw = NULL; in rtl_hw_phy_work_func_t()
6873 queue_delayed_work(system_long_wq, &tp->hw_phy_work, HZ * 10); in rtl_hw_phy_work_func_t()
6877 tp->rtl_ops.hw_phy_cfg(tp); in rtl_hw_phy_work_func_t()
6879 rtl8152_set_speed(tp, tp->autoneg, tp->speed, tp->duplex, in rtl_hw_phy_work_func_t()
6880 tp->advertising); in rtl_hw_phy_work_func_t()
6883 mutex_unlock(&tp->control); in rtl_hw_phy_work_func_t()
6885 usb_autopm_put_interface(tp->intf); in rtl_hw_phy_work_func_t()
6897 usb_autopm_get_interface(tp->intf); in rtl_notifier()
6902 usb_autopm_put_interface(tp->intf); in rtl_notifier()
6920 if (work_busy(&tp->hw_phy_work.work) & WORK_BUSY_PENDING) { in rtl8152_open()
6921 cancel_delayed_work_sync(&tp->hw_phy_work); in rtl8152_open()
6922 rtl_hw_phy_work_func_t(&tp->hw_phy_work.work); in rtl8152_open()
6929 res = usb_autopm_get_interface(tp->intf); in rtl8152_open()
6933 mutex_lock(&tp->control); in rtl8152_open()
6935 tp->rtl_ops.up(tp); in rtl8152_open()
6939 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_open()
6941 res = usb_submit_urb(tp->intr_urb, GFP_KERNEL); in rtl8152_open()
6943 if (res == -ENODEV) in rtl8152_open()
6944 netif_device_detach(tp->netdev); in rtl8152_open()
6949 napi_enable(&tp->napi); in rtl8152_open()
6950 tasklet_enable(&tp->tx_tl); in rtl8152_open()
6952 mutex_unlock(&tp->control); in rtl8152_open()
6954 usb_autopm_put_interface(tp->intf); in rtl8152_open()
6956 tp->pm_notifier.notifier_call = rtl_notifier; in rtl8152_open()
6957 register_pm_notifier(&tp->pm_notifier); in rtl8152_open()
6962 mutex_unlock(&tp->control); in rtl8152_open()
6963 usb_autopm_put_interface(tp->intf); in rtl8152_open()
6976 unregister_pm_notifier(&tp->pm_notifier); in rtl8152_close()
6978 tasklet_disable(&tp->tx_tl); in rtl8152_close()
6979 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_close()
6980 usb_kill_urb(tp->intr_urb); in rtl8152_close()
6981 cancel_delayed_work_sync(&tp->schedule); in rtl8152_close()
6982 napi_disable(&tp->napi); in rtl8152_close()
6985 res = usb_autopm_get_interface(tp->intf); in rtl8152_close()
6986 if (res < 0 || test_bit(RTL8152_INACCESSIBLE, &tp->flags)) { in rtl8152_close()
6990 mutex_lock(&tp->control); in rtl8152_close()
6992 tp->rtl_ops.down(tp); in rtl8152_close()
6994 mutex_unlock(&tp->control); in rtl8152_close()
6998 usb_autopm_put_interface(tp->intf); in rtl8152_close()
7019 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8152b_init()
7030 if (tp->version == RTL_VER_01) { in r8152b_init()
7051 /* enable rx aggregation */ in r8152b_init()
7063 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153_init()
7074 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153_init()
7080 if (tp->version == RTL_VER_03 || tp->version == RTL_VER_04 || in r8153_init()
7081 tp->version == RTL_VER_05) in r8153_init()
7094 if (tp->version == RTL_VER_04) { in r8153_init()
7103 } else if (tp->version == RTL_VER_05) { in r8153_init()
7114 } else if (tp->version == RTL_VER_06) { in r8153_init()
7146 if (tp->version == RTL_VER_04 && tp->udev->speed < USB_SPEED_SUPER) in r8153_init()
7163 usb_enable_lpm(tp->udev); in r8153_init()
7176 if (tp->dell_tb_rx_agg_bug) in r8153_init()
7183 switch (tp->udev->speed) { in r8153_init()
7186 tp->coalesce = COALESCE_SUPER; in r8153_init()
7189 tp->coalesce = COALESCE_HIGH; in r8153_init()
7192 tp->coalesce = COALESCE_SLOW; in r8153_init()
7203 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153b_init()
7214 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153b_init()
7246 if (tp->udev->speed >= USB_SPEED_SUPER) in r8153b_init()
7249 usb_enable_lpm(tp->udev); in r8153b_init()
7258 if (tp->version == RTL_VER_09) { in r8153b_init()
7267 set_bit(GREEN_ETHERNET, &tp->flags); in r8153b_init()
7276 tp->coalesce = 15000; /* 15 us */ in r8153b_init()
7285 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153c_init()
7305 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8153c_init()
7340 usb_enable_lpm(tp->udev); in r8153c_init()
7349 set_bit(GREEN_ETHERNET, &tp->flags); in r8153c_init()
7358 tp->coalesce = 15000; /* 15 us */ in r8153c_init()
7388 /* disable ALDPS before updating the PHY parameters */ in r8156_hw_phy_cfg()
7401 switch (tp->version) { in r8156_hw_phy_cfg()
7579 tp->ups_info._10m_ckdiv = true; in r8156_hw_phy_cfg()
7580 tp->ups_info.eee_plloff_100 = false; in r8156_hw_phy_cfg()
7581 tp->ups_info.eee_plloff_giga = false; in r8156_hw_phy_cfg()
7586 tp->ups_info.eee_ckdiv = false; in r8156_hw_phy_cfg()
7590 tp->ups_info._250m_ckdiv = false; in r8156_hw_phy_cfg()
7594 /* enable ADC Ibias Cal */ in r8156_hw_phy_cfg()
7599 /* enable Thermal Sensor */ in r8156_hw_phy_cfg()
7691 rtl_green_en(tp, test_bit(GREEN_ETHERNET, &tp->flags)); in r8156_hw_phy_cfg()
7699 tp->ups_info.lite_mode = 0; in r8156_hw_phy_cfg()
7701 if (tp->eee_en) in r8156_hw_phy_cfg()
7708 set_bit(PHY_RESET, &tp->flags); in r8156_hw_phy_cfg()
7716 switch (tp->version) { in r8156b_hw_phy_cfg()
7775 /* disable ALDPS before updating the PHY parameters */ in r8156b_hw_phy_cfg()
7788 switch (tp->version) { in r8156b_hw_phy_cfg()
8059 /* Green Table-PGA, 1G full viterbi */ in r8156b_hw_phy_cfg()
8097 tp->ups_info._10m_ckdiv = true; in r8156b_hw_phy_cfg()
8098 tp->ups_info.eee_plloff_100 = false; in r8156b_hw_phy_cfg()
8099 tp->ups_info.eee_plloff_giga = false; in r8156b_hw_phy_cfg()
8104 tp->ups_info.eee_ckdiv = false; in r8156b_hw_phy_cfg()
8108 rtl_green_en(tp, test_bit(GREEN_ETHERNET, &tp->flags)); in r8156b_hw_phy_cfg()
8116 tp->ups_info.lite_mode = 0; in r8156b_hw_phy_cfg()
8118 if (tp->eee_en) in r8156b_hw_phy_cfg()
8125 set_bit(PHY_RESET, &tp->flags); in r8156b_hw_phy_cfg()
8134 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8156_init()
8155 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8156_init()
8188 if (tp->udev->speed >= USB_SPEED_SUPER) in r8156_init()
8191 usb_enable_lpm(tp->udev); in r8156_init()
8207 set_bit(GREEN_ETHERNET, &tp->flags); in r8156_init()
8221 tp->coalesce = 15000; /* 15 us */ in r8156_init()
8230 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8156b_init()
8249 switch (tp->version) { in r8156b_init()
8264 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in r8156b_init()
8300 if (tp->udev->speed >= USB_SPEED_SUPER) in r8156b_init()
8303 usb_enable_lpm(tp->udev); in r8156b_init()
8313 /* enable fc timer and set timer to 600 ms. */ in r8156b_init()
8341 set_bit(GREEN_ETHERNET, &tp->flags); in r8156b_init()
8351 tp->coalesce = 15000; /* 15 us */ in r8156b_init()
8356 struct usb_host_interface *alt = intf->cur_altsetting; in rtl_check_vendor_ok()
8360 dev_err(&intf->dev, "Expected endpoints are not found\n"); in rtl_check_vendor_ok()
8366 dev_err(&intf->dev, "Invalid Rx endpoint address\n"); in rtl_check_vendor_ok()
8372 dev_err(&intf->dev, "Invalid Tx endpoint address\n"); in rtl_check_vendor_ok()
8378 dev_err(&intf->dev, "Invalid interrupt endpoint address\n"); in rtl_check_vendor_ok()
8392 if (!tp || !test_bit(PROBED_WITH_NO_ERRORS, &tp->flags)) in rtl8152_pre_reset()
8395 netdev = tp->netdev; in rtl8152_pre_reset()
8400 tasklet_disable(&tp->tx_tl); in rtl8152_pre_reset()
8401 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_pre_reset()
8402 usb_kill_urb(tp->intr_urb); in rtl8152_pre_reset()
8403 cancel_delayed_work_sync(&tp->schedule); in rtl8152_pre_reset()
8404 napi_disable(&tp->napi); in rtl8152_pre_reset()
8406 mutex_lock(&tp->control); in rtl8152_pre_reset()
8407 set_bit(IN_PRE_RESET, &tp->flags); in rtl8152_pre_reset()
8408 tp->rtl_ops.disable(tp); in rtl8152_pre_reset()
8409 clear_bit(IN_PRE_RESET, &tp->flags); in rtl8152_pre_reset()
8410 mutex_unlock(&tp->control); in rtl8152_pre_reset()
8422 if (!tp || !test_bit(PROBED_WITH_NO_ERRORS, &tp->flags)) in rtl8152_post_reset()
8429 dev_set_mac_address (tp->netdev, &sa, NULL); in rtl8152_post_reset()
8431 netdev = tp->netdev; in rtl8152_post_reset()
8435 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_post_reset()
8437 mutex_lock(&tp->control); in rtl8152_post_reset()
8438 tp->rtl_ops.enable(tp); in rtl8152_post_reset()
8441 mutex_unlock(&tp->control); in rtl8152_post_reset()
8444 napi_enable(&tp->napi); in rtl8152_post_reset()
8445 tasklet_enable(&tp->tx_tl); in rtl8152_post_reset()
8447 usb_submit_urb(tp->intr_urb, GFP_KERNEL); in rtl8152_post_reset()
8449 if (!list_empty(&tp->rx_done)) in rtl8152_post_reset()
8450 napi_schedule(&tp->napi); in rtl8152_post_reset()
8459 bool sw_linking = !!netif_carrier_ok(tp->netdev); in delay_autosuspend()
8466 if (work_busy(&tp->schedule.work) || sw_linking != hw_linking) in delay_autosuspend()
8472 if (!sw_linking && tp->rtl_ops.in_nway(tp)) in delay_autosuspend()
8474 else if (!skb_queue_empty(&tp->tx_queue)) in delay_autosuspend()
8482 struct net_device *netdev = tp->netdev; in rtl8152_runtime_resume()
8484 if (netif_running(netdev) && netdev->flags & IFF_UP) { in rtl8152_runtime_resume()
8485 struct napi_struct *napi = &tp->napi; in rtl8152_runtime_resume()
8487 tp->rtl_ops.autosuspend_en(tp, false); in rtl8152_runtime_resume()
8489 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_runtime_resume()
8496 tp->rtl_ops.disable(tp); in rtl8152_runtime_resume()
8502 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_resume()
8505 if (!list_empty(&tp->rx_done)) in rtl8152_runtime_resume()
8506 napi_schedule(&tp->napi); in rtl8152_runtime_resume()
8508 usb_submit_urb(tp->intr_urb, GFP_NOIO); in rtl8152_runtime_resume()
8510 if (netdev->flags & IFF_UP) in rtl8152_runtime_resume()
8511 tp->rtl_ops.autosuspend_en(tp, false); in rtl8152_runtime_resume()
8513 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_resume()
8521 struct net_device *netdev = tp->netdev; in rtl8152_system_resume()
8525 if (netif_running(netdev) && (netdev->flags & IFF_UP)) { in rtl8152_system_resume()
8526 tp->rtl_ops.up(tp); in rtl8152_system_resume()
8528 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_system_resume()
8529 usb_submit_urb(tp->intr_urb, GFP_NOIO); in rtl8152_system_resume()
8537 struct net_device *netdev = tp->netdev; in rtl8152_runtime_suspend()
8540 if (!tp->rtl_ops.autosuspend_en) in rtl8152_runtime_suspend()
8541 return -EBUSY; in rtl8152_runtime_suspend()
8543 set_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_suspend()
8546 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { in rtl8152_runtime_suspend()
8561 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_suspend()
8563 ret = -EBUSY; in rtl8152_runtime_suspend()
8568 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_runtime_suspend()
8569 usb_kill_urb(tp->intr_urb); in rtl8152_runtime_suspend()
8571 tp->rtl_ops.autosuspend_en(tp, true); in rtl8152_runtime_suspend()
8574 struct napi_struct *napi = &tp->napi; in rtl8152_runtime_suspend()
8585 ret = -EBUSY; in rtl8152_runtime_suspend()
8595 struct net_device *netdev = tp->netdev; in rtl8152_system_suspend()
8599 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { in rtl8152_system_suspend()
8600 struct napi_struct *napi = &tp->napi; in rtl8152_system_suspend()
8602 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_system_suspend()
8603 usb_kill_urb(tp->intr_urb); in rtl8152_system_suspend()
8604 tasklet_disable(&tp->tx_tl); in rtl8152_system_suspend()
8606 cancel_delayed_work_sync(&tp->schedule); in rtl8152_system_suspend()
8607 tp->rtl_ops.down(tp); in rtl8152_system_suspend()
8609 tasklet_enable(&tp->tx_tl); in rtl8152_system_suspend()
8620 mutex_lock(&tp->control); in rtl8152_suspend()
8627 mutex_unlock(&tp->control); in rtl8152_suspend()
8637 mutex_lock(&tp->control); in rtl8152_resume()
8641 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) in rtl8152_resume()
8646 mutex_unlock(&tp->control); in rtl8152_resume()
8655 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_reset_resume()
8657 tp->rtl_ops.init(tp); in rtl8152_reset_resume()
8658 queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0); in rtl8152_reset_resume()
8667 if (usb_autopm_get_interface(tp->intf) < 0) in rtl8152_get_wol()
8671 wol->supported = 0; in rtl8152_get_wol()
8672 wol->wolopts = 0; in rtl8152_get_wol()
8674 mutex_lock(&tp->control); in rtl8152_get_wol()
8675 wol->supported = WAKE_ANY; in rtl8152_get_wol()
8676 wol->wolopts = __rtl_get_wol(tp); in rtl8152_get_wol()
8677 mutex_unlock(&tp->control); in rtl8152_get_wol()
8680 usb_autopm_put_interface(tp->intf); in rtl8152_get_wol()
8689 return -EOPNOTSUPP; in rtl8152_set_wol()
8691 if (wol->wolopts & ~WAKE_ANY) in rtl8152_set_wol()
8692 return -EINVAL; in rtl8152_set_wol()
8694 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_wol()
8698 mutex_lock(&tp->control); in rtl8152_set_wol()
8700 __rtl_set_wol(tp, wol->wolopts); in rtl8152_set_wol()
8701 tp->saved_wolopts = wol->wolopts & WAKE_ANY; in rtl8152_set_wol()
8703 mutex_unlock(&tp->control); in rtl8152_set_wol()
8705 usb_autopm_put_interface(tp->intf); in rtl8152_set_wol()
8715 return tp->msg_enable; in rtl8152_get_msglevel()
8722 tp->msg_enable = value; in rtl8152_set_msglevel()
8730 strscpy(info->driver, MODULENAME, sizeof(info->driver)); in rtl8152_get_drvinfo()
8731 strscpy(info->version, DRIVER_VERSION, sizeof(info->version)); in rtl8152_get_drvinfo()
8732 usb_make_path(tp->udev, info->bus_info, sizeof(info->bus_info)); in rtl8152_get_drvinfo()
8733 if (!IS_ERR_OR_NULL(tp->rtl_fw.fw)) in rtl8152_get_drvinfo()
8734 strscpy(info->fw_version, tp->rtl_fw.version, in rtl8152_get_drvinfo()
8735 sizeof(info->fw_version)); in rtl8152_get_drvinfo()
8745 if (!tp->mii.mdio_read) in rtl8152_get_link_ksettings()
8746 return -EOPNOTSUPP; in rtl8152_get_link_ksettings()
8748 ret = usb_autopm_get_interface(tp->intf); in rtl8152_get_link_ksettings()
8752 mutex_lock(&tp->control); in rtl8152_get_link_ksettings()
8754 mii_ethtool_get_link_ksettings(&tp->mii, cmd); in rtl8152_get_link_ksettings()
8757 cmd->link_modes.supported, tp->support_2500full); in rtl8152_get_link_ksettings()
8759 if (tp->support_2500full) { in rtl8152_get_link_ksettings()
8761 cmd->link_modes.advertising, in rtl8152_get_link_ksettings()
8765 cmd->link_modes.lp_advertising, in rtl8152_get_link_ksettings()
8769 cmd->base.speed = SPEED_2500; in rtl8152_get_link_ksettings()
8772 mutex_unlock(&tp->control); in rtl8152_get_link_ksettings()
8774 usb_autopm_put_interface(tp->intf); in rtl8152_get_link_ksettings()
8787 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_link_ksettings()
8792 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8796 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8800 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8804 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8808 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8812 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8816 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8819 mutex_lock(&tp->control); in rtl8152_set_link_ksettings()
8821 ret = rtl8152_set_speed(tp, cmd->base.autoneg, cmd->base.speed, in rtl8152_set_link_ksettings()
8822 cmd->base.duplex, advertising); in rtl8152_set_link_ksettings()
8824 tp->autoneg = cmd->base.autoneg; in rtl8152_set_link_ksettings()
8825 tp->speed = cmd->base.speed; in rtl8152_set_link_ksettings()
8826 tp->duplex = cmd->base.duplex; in rtl8152_set_link_ksettings()
8827 tp->advertising = advertising; in rtl8152_set_link_ksettings()
8830 mutex_unlock(&tp->control); in rtl8152_set_link_ksettings()
8832 usb_autopm_put_interface(tp->intf); in rtl8152_set_link_ksettings()
8860 return -EOPNOTSUPP; in rtl8152_get_sset_count()
8870 if (usb_autopm_get_interface(tp->intf) < 0) in rtl8152_get_ethtool_stats()
8875 usb_autopm_put_interface(tp->intf); in rtl8152_get_ethtool_stats()
8915 eee->eee_enabled = tp->eee_en; in r8152_get_eee()
8916 eee->eee_active = !!(supported & adv & lp); in r8152_get_eee()
8917 eee->supported = supported; in r8152_get_eee()
8918 eee->advertised = tp->eee_adv; in r8152_get_eee()
8919 eee->lp_advertised = lp; in r8152_get_eee()
8926 u16 val = ethtool_adv_to_mmd_eee_adv_t(eee->advertised); in r8152_set_eee()
8928 tp->eee_en = eee->eee_enabled; in r8152_set_eee()
8929 tp->eee_adv = val; in r8152_set_eee()
8931 rtl_eee_enable(tp, tp->eee_en); in r8152_set_eee()
8950 eee->eee_enabled = tp->eee_en; in r8153_get_eee()
8951 eee->eee_active = !!(supported & adv & lp); in r8153_get_eee()
8952 eee->supported = supported; in r8153_get_eee()
8953 eee->advertised = tp->eee_adv; in r8153_get_eee()
8954 eee->lp_advertised = lp; in r8153_get_eee()
8965 if (!tp->rtl_ops.eee_get) { in rtl_ethtool_get_eee()
8966 ret = -EOPNOTSUPP; in rtl_ethtool_get_eee()
8970 ret = usb_autopm_get_interface(tp->intf); in rtl_ethtool_get_eee()
8974 mutex_lock(&tp->control); in rtl_ethtool_get_eee()
8976 ret = tp->rtl_ops.eee_get(tp, edata); in rtl_ethtool_get_eee()
8978 mutex_unlock(&tp->control); in rtl_ethtool_get_eee()
8980 usb_autopm_put_interface(tp->intf); in rtl_ethtool_get_eee()
8992 if (!tp->rtl_ops.eee_set) { in rtl_ethtool_set_eee()
8993 ret = -EOPNOTSUPP; in rtl_ethtool_set_eee()
8997 ret = usb_autopm_get_interface(tp->intf); in rtl_ethtool_set_eee()
9001 mutex_lock(&tp->control); in rtl_ethtool_set_eee()
9003 ret = tp->rtl_ops.eee_set(tp, edata); in rtl_ethtool_set_eee()
9005 ret = mii_nway_restart(&tp->mii); in rtl_ethtool_set_eee()
9007 mutex_unlock(&tp->control); in rtl_ethtool_set_eee()
9009 usb_autopm_put_interface(tp->intf); in rtl_ethtool_set_eee()
9020 ret = usb_autopm_get_interface(tp->intf); in rtl8152_nway_reset()
9024 mutex_lock(&tp->control); in rtl8152_nway_reset()
9026 ret = mii_nway_restart(&tp->mii); in rtl8152_nway_reset()
9028 mutex_unlock(&tp->control); in rtl8152_nway_reset()
9030 usb_autopm_put_interface(tp->intf); in rtl8152_nway_reset()
9043 switch (tp->version) { in rtl8152_get_coalesce()
9047 return -EOPNOTSUPP; in rtl8152_get_coalesce()
9052 coalesce->rx_coalesce_usecs = tp->coalesce; in rtl8152_get_coalesce()
9065 switch (tp->version) { in rtl8152_set_coalesce()
9069 return -EOPNOTSUPP; in rtl8152_set_coalesce()
9074 if (coalesce->rx_coalesce_usecs > COALESCE_SLOW) in rtl8152_set_coalesce()
9075 return -EINVAL; in rtl8152_set_coalesce()
9077 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_coalesce()
9081 mutex_lock(&tp->control); in rtl8152_set_coalesce()
9083 if (tp->coalesce != coalesce->rx_coalesce_usecs) { in rtl8152_set_coalesce()
9084 tp->coalesce = coalesce->rx_coalesce_usecs; in rtl8152_set_coalesce()
9088 napi_disable(&tp->napi); in rtl8152_set_coalesce()
9089 tp->rtl_ops.disable(tp); in rtl8152_set_coalesce()
9090 tp->rtl_ops.enable(tp); in rtl8152_set_coalesce()
9092 clear_bit(RTL8152_SET_RX_MODE, &tp->flags); in rtl8152_set_coalesce()
9094 napi_enable(&tp->napi); in rtl8152_set_coalesce()
9099 mutex_unlock(&tp->control); in rtl8152_set_coalesce()
9101 usb_autopm_put_interface(tp->intf); in rtl8152_set_coalesce()
9111 switch (tunable->id) { in rtl8152_get_tunable()
9113 *(u32 *)d = tp->rx_copybreak; in rtl8152_get_tunable()
9116 return -EOPNOTSUPP; in rtl8152_get_tunable()
9129 switch (tunable->id) { in rtl8152_set_tunable()
9135 return -EINVAL; in rtl8152_set_tunable()
9138 if (tp->rx_copybreak != val) { in rtl8152_set_tunable()
9139 if (netdev->flags & IFF_UP) { in rtl8152_set_tunable()
9140 mutex_lock(&tp->control); in rtl8152_set_tunable()
9141 napi_disable(&tp->napi); in rtl8152_set_tunable()
9142 tp->rx_copybreak = val; in rtl8152_set_tunable()
9143 napi_enable(&tp->napi); in rtl8152_set_tunable()
9144 mutex_unlock(&tp->control); in rtl8152_set_tunable()
9146 tp->rx_copybreak = val; in rtl8152_set_tunable()
9151 return -EOPNOTSUPP; in rtl8152_set_tunable()
9164 ring->rx_max_pending = RTL8152_RX_MAX_PENDING; in rtl8152_get_ringparam()
9165 ring->rx_pending = tp->rx_pending; in rtl8152_get_ringparam()
9175 if (ring->rx_pending < (RTL8152_MAX_RX * 2)) in rtl8152_set_ringparam()
9176 return -EINVAL; in rtl8152_set_ringparam()
9178 if (tp->rx_pending != ring->rx_pending) { in rtl8152_set_ringparam()
9179 if (netdev->flags & IFF_UP) { in rtl8152_set_ringparam()
9180 mutex_lock(&tp->control); in rtl8152_set_ringparam()
9181 napi_disable(&tp->napi); in rtl8152_set_ringparam()
9182 tp->rx_pending = ring->rx_pending; in rtl8152_set_ringparam()
9183 napi_enable(&tp->napi); in rtl8152_set_ringparam()
9184 mutex_unlock(&tp->control); in rtl8152_set_ringparam()
9186 tp->rx_pending = ring->rx_pending; in rtl8152_set_ringparam()
9199 if (usb_autopm_get_interface(tp->intf) < 0) in rtl8152_get_pauseparam()
9202 mutex_lock(&tp->control); in rtl8152_get_pauseparam()
9208 mutex_unlock(&tp->control); in rtl8152_get_pauseparam()
9210 usb_autopm_put_interface(tp->intf); in rtl8152_get_pauseparam()
9213 pause->autoneg = 0; in rtl8152_get_pauseparam()
9214 pause->rx_pause = 0; in rtl8152_get_pauseparam()
9215 pause->tx_pause = 0; in rtl8152_get_pauseparam()
9219 pause->autoneg = 1; in rtl8152_get_pauseparam()
9224 pause->rx_pause = 1; in rtl8152_get_pauseparam()
9227 pause->tx_pause = 1; in rtl8152_get_pauseparam()
9237 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_pauseparam()
9241 mutex_lock(&tp->control); in rtl8152_set_pauseparam()
9243 if (pause->autoneg && !(r8152_mdio_read(tp, MII_BMCR) & BMCR_ANENABLE)) { in rtl8152_set_pauseparam()
9244 ret = -EINVAL; in rtl8152_set_pauseparam()
9248 if (pause->rx_pause) in rtl8152_set_pauseparam()
9251 if (pause->tx_pause) in rtl8152_set_pauseparam()
9260 mutex_unlock(&tp->control); in rtl8152_set_pauseparam()
9261 usb_autopm_put_interface(tp->intf); in rtl8152_set_pauseparam()
9298 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8152_ioctl()
9299 return -ENODEV; in rtl8152_ioctl()
9301 res = usb_autopm_get_interface(tp->intf); in rtl8152_ioctl()
9307 data->phy_id = R8152_PHY_ID; /* Internal PHY */ in rtl8152_ioctl()
9311 mutex_lock(&tp->control); in rtl8152_ioctl()
9312 data->val_out = r8152_mdio_read(tp, data->reg_num); in rtl8152_ioctl()
9313 mutex_unlock(&tp->control); in rtl8152_ioctl()
9318 res = -EPERM; in rtl8152_ioctl()
9321 mutex_lock(&tp->control); in rtl8152_ioctl()
9322 r8152_mdio_write(tp, data->reg_num, data->val_in); in rtl8152_ioctl()
9323 mutex_unlock(&tp->control); in rtl8152_ioctl()
9327 res = -EOPNOTSUPP; in rtl8152_ioctl()
9330 usb_autopm_put_interface(tp->intf); in rtl8152_ioctl()
9341 switch (tp->version) { in rtl8152_change_mtu()
9345 dev->mtu = new_mtu; in rtl8152_change_mtu()
9351 ret = usb_autopm_get_interface(tp->intf); in rtl8152_change_mtu()
9355 mutex_lock(&tp->control); in rtl8152_change_mtu()
9357 dev->mtu = new_mtu; in rtl8152_change_mtu()
9360 if (tp->rtl_ops.change_mtu) in rtl8152_change_mtu()
9361 tp->rtl_ops.change_mtu(tp); in rtl8152_change_mtu()
9365 napi_disable(&tp->napi); in rtl8152_change_mtu()
9366 tasklet_disable(&tp->tx_tl); in rtl8152_change_mtu()
9367 tp->rtl_ops.disable(tp); in rtl8152_change_mtu()
9368 tp->rtl_ops.enable(tp); in rtl8152_change_mtu()
9370 tasklet_enable(&tp->tx_tl); in rtl8152_change_mtu()
9371 napi_enable(&tp->napi); in rtl8152_change_mtu()
9377 mutex_unlock(&tp->control); in rtl8152_change_mtu()
9379 usb_autopm_put_interface(tp->intf); in rtl8152_change_mtu()
9400 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8152_unload()
9403 if (tp->version != RTL_VER_01) in rtl8152_unload()
9409 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8153_unload()
9417 if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) in rtl8153b_unload()
9425 struct rtl_ops *ops = &tp->rtl_ops; in rtl_ops_init()
9428 switch (tp->version) { in rtl_ops_init()
9432 ops->init = r8152b_init; in rtl_ops_init()
9433 ops->enable = rtl8152_enable; in rtl_ops_init()
9434 ops->disable = rtl8152_disable; in rtl_ops_init()
9435 ops->up = rtl8152_up; in rtl_ops_init()
9436 ops->down = rtl8152_down; in rtl_ops_init()
9437 ops->unload = rtl8152_unload; in rtl_ops_init()
9438 ops->eee_get = r8152_get_eee; in rtl_ops_init()
9439 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9440 ops->in_nway = rtl8152_in_nway; in rtl_ops_init()
9441 ops->hw_phy_cfg = r8152b_hw_phy_cfg; in rtl_ops_init()
9442 ops->autosuspend_en = rtl_runtime_suspend_enable; in rtl_ops_init()
9443 tp->rx_buf_sz = 16 * 1024; in rtl_ops_init()
9444 tp->eee_en = true; in rtl_ops_init()
9445 tp->eee_adv = MDIO_EEE_100TX; in rtl_ops_init()
9452 ops->init = r8153_init; in rtl_ops_init()
9453 ops->enable = rtl8153_enable; in rtl_ops_init()
9454 ops->disable = rtl8153_disable; in rtl_ops_init()
9455 ops->up = rtl8153_up; in rtl_ops_init()
9456 ops->down = rtl8153_down; in rtl_ops_init()
9457 ops->unload = rtl8153_unload; in rtl_ops_init()
9458 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9459 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9460 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9461 ops->hw_phy_cfg = r8153_hw_phy_cfg; in rtl_ops_init()
9462 ops->autosuspend_en = rtl8153_runtime_enable; in rtl_ops_init()
9463 ops->change_mtu = rtl8153_change_mtu; in rtl_ops_init()
9464 if (tp->udev->speed < USB_SPEED_SUPER) in rtl_ops_init()
9465 tp->rx_buf_sz = 16 * 1024; in rtl_ops_init()
9467 tp->rx_buf_sz = 32 * 1024; in rtl_ops_init()
9468 tp->eee_en = true; in rtl_ops_init()
9469 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9474 ops->init = r8153b_init; in rtl_ops_init()
9475 ops->enable = rtl8153_enable; in rtl_ops_init()
9476 ops->disable = rtl8153_disable; in rtl_ops_init()
9477 ops->up = rtl8153b_up; in rtl_ops_init()
9478 ops->down = rtl8153b_down; in rtl_ops_init()
9479 ops->unload = rtl8153b_unload; in rtl_ops_init()
9480 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9481 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9482 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9483 ops->hw_phy_cfg = r8153b_hw_phy_cfg; in rtl_ops_init()
9484 ops->autosuspend_en = rtl8153b_runtime_enable; in rtl_ops_init()
9485 ops->change_mtu = rtl8153_change_mtu; in rtl_ops_init()
9486 tp->rx_buf_sz = 32 * 1024; in rtl_ops_init()
9487 tp->eee_en = true; in rtl_ops_init()
9488 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9492 tp->eee_en = true; in rtl_ops_init()
9493 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9496 ops->init = r8156_init; in rtl_ops_init()
9497 ops->enable = rtl8156_enable; in rtl_ops_init()
9498 ops->disable = rtl8156_disable; in rtl_ops_init()
9499 ops->up = rtl8156_up; in rtl_ops_init()
9500 ops->down = rtl8156_down; in rtl_ops_init()
9501 ops->unload = rtl8153_unload; in rtl_ops_init()
9502 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9503 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9504 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9505 ops->hw_phy_cfg = r8156_hw_phy_cfg; in rtl_ops_init()
9506 ops->autosuspend_en = rtl8156_runtime_enable; in rtl_ops_init()
9507 ops->change_mtu = rtl8156_change_mtu; in rtl_ops_init()
9508 tp->rx_buf_sz = 48 * 1024; in rtl_ops_init()
9509 tp->support_2500full = 1; in rtl_ops_init()
9514 tp->support_2500full = 1; in rtl_ops_init()
9517 tp->eee_en = true; in rtl_ops_init()
9518 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9519 ops->init = r8156b_init; in rtl_ops_init()
9520 ops->enable = rtl8156b_enable; in rtl_ops_init()
9521 ops->disable = rtl8153_disable; in rtl_ops_init()
9522 ops->up = rtl8156_up; in rtl_ops_init()
9523 ops->down = rtl8156_down; in rtl_ops_init()
9524 ops->unload = rtl8153_unload; in rtl_ops_init()
9525 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9526 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9527 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9528 ops->hw_phy_cfg = r8156b_hw_phy_cfg; in rtl_ops_init()
9529 ops->autosuspend_en = rtl8156_runtime_enable; in rtl_ops_init()
9530 ops->change_mtu = rtl8156_change_mtu; in rtl_ops_init()
9531 tp->rx_buf_sz = 48 * 1024; in rtl_ops_init()
9535 ops->init = r8153c_init; in rtl_ops_init()
9536 ops->enable = rtl8153_enable; in rtl_ops_init()
9537 ops->disable = rtl8153_disable; in rtl_ops_init()
9538 ops->up = rtl8153c_up; in rtl_ops_init()
9539 ops->down = rtl8153b_down; in rtl_ops_init()
9540 ops->unload = rtl8153_unload; in rtl_ops_init()
9541 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9542 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9543 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9544 ops->hw_phy_cfg = r8153c_hw_phy_cfg; in rtl_ops_init()
9545 ops->autosuspend_en = rtl8153c_runtime_enable; in rtl_ops_init()
9546 ops->change_mtu = rtl8153c_change_mtu; in rtl_ops_init()
9547 tp->rx_buf_sz = 32 * 1024; in rtl_ops_init()
9548 tp->eee_en = true; in rtl_ops_init()
9549 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9553 ret = -ENODEV; in rtl_ops_init()
9554 dev_err(&tp->intf->dev, "Unknown Device\n"); in rtl_ops_init()
9561 #define FIRMWARE_8153A_2 "rtl_nic/rtl8153a-2.fw"
9562 #define FIRMWARE_8153A_3 "rtl_nic/rtl8153a-3.fw"
9563 #define FIRMWARE_8153A_4 "rtl_nic/rtl8153a-4.fw"
9564 #define FIRMWARE_8153B_2 "rtl_nic/rtl8153b-2.fw"
9565 #define FIRMWARE_8153C_1 "rtl_nic/rtl8153c-1.fw"
9566 #define FIRMWARE_8156A_2 "rtl_nic/rtl8156a-2.fw"
9567 #define FIRMWARE_8156B_2 "rtl_nic/rtl8156b-2.fw"
9579 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl_fw_init()
9581 switch (tp->version) { in rtl_fw_init()
9583 rtl_fw->fw_name = FIRMWARE_8153A_2; in rtl_fw_init()
9584 rtl_fw->pre_fw = r8153_pre_firmware_1; in rtl_fw_init()
9585 rtl_fw->post_fw = r8153_post_firmware_1; in rtl_fw_init()
9588 rtl_fw->fw_name = FIRMWARE_8153A_3; in rtl_fw_init()
9589 rtl_fw->pre_fw = r8153_pre_firmware_2; in rtl_fw_init()
9590 rtl_fw->post_fw = r8153_post_firmware_2; in rtl_fw_init()
9593 rtl_fw->fw_name = FIRMWARE_8153A_4; in rtl_fw_init()
9594 rtl_fw->post_fw = r8153_post_firmware_3; in rtl_fw_init()
9597 rtl_fw->fw_name = FIRMWARE_8153B_2; in rtl_fw_init()
9598 rtl_fw->pre_fw = r8153b_pre_firmware_1; in rtl_fw_init()
9599 rtl_fw->post_fw = r8153b_post_firmware_1; in rtl_fw_init()
9602 rtl_fw->fw_name = FIRMWARE_8156A_2; in rtl_fw_init()
9603 rtl_fw->post_fw = r8156a_post_firmware_1; in rtl_fw_init()
9607 rtl_fw->fw_name = FIRMWARE_8156B_2; in rtl_fw_init()
9610 rtl_fw->fw_name = FIRMWARE_8153C_1; in rtl_fw_init()
9611 rtl_fw->pre_fw = r8153b_pre_firmware_1; in rtl_fw_init()
9612 rtl_fw->post_fw = r8153c_post_firmware_1; in rtl_fw_init()
9649 dev_warn(&udev->dev, "Needed %d retries to read version\n", i); in __rtl_get_hw_ver()
9704 dev_info(&udev->dev, "Unknown version 0x%04x\n", ocp_data); in __rtl_get_hw_ver()
9717 dev_dbg(&intf->dev, "Detected version 0x%04x\n", version); in rtl8152_get_version()
9725 int parent_vendor_id = le16_to_cpu(udev->parent->descriptor.idVendor); in rtl8152_supports_lenovo_macpassthru()
9726 int product_id = le16_to_cpu(udev->descriptor.idProduct); in rtl8152_supports_lenovo_macpassthru()
9727 int vendor_id = le16_to_cpu(udev->descriptor.idVendor); in rtl8152_supports_lenovo_macpassthru()
9759 dev_err(&intf->dev, "Out of memory\n"); in rtl8152_probe_once()
9760 return -ENOMEM; in rtl8152_probe_once()
9763 SET_NETDEV_DEV(netdev, &intf->dev); in rtl8152_probe_once()
9765 tp->msg_enable = 0x7FFF; in rtl8152_probe_once()
9767 tp->udev = udev; in rtl8152_probe_once()
9768 tp->netdev = netdev; in rtl8152_probe_once()
9769 tp->intf = intf; in rtl8152_probe_once()
9770 tp->version = version; in rtl8152_probe_once()
9772 tp->pipe_ctrl_in = usb_rcvctrlpipe(udev, 0); in rtl8152_probe_once()
9773 tp->pipe_ctrl_out = usb_sndctrlpipe(udev, 0); in rtl8152_probe_once()
9774 tp->pipe_in = usb_rcvbulkpipe(udev, 1); in rtl8152_probe_once()
9775 tp->pipe_out = usb_sndbulkpipe(udev, 2); in rtl8152_probe_once()
9776 tp->pipe_intr = usb_rcvintpipe(udev, 3); in rtl8152_probe_once()
9782 tp->mii.supports_gmii = 0; in rtl8152_probe_once()
9785 tp->mii.supports_gmii = 1; in rtl8152_probe_once()
9795 mutex_init(&tp->control); in rtl8152_probe_once()
9796 INIT_DELAYED_WORK(&tp->schedule, rtl_work_func_t); in rtl8152_probe_once()
9797 INIT_DELAYED_WORK(&tp->hw_phy_work, rtl_hw_phy_work_func_t); in rtl8152_probe_once()
9798 tasklet_setup(&tp->tx_tl, bottom_half); in rtl8152_probe_once()
9799 tasklet_disable(&tp->tx_tl); in rtl8152_probe_once()
9801 netdev->netdev_ops = &rtl8152_netdev_ops; in rtl8152_probe_once()
9802 netdev->watchdog_timeo = RTL8152_TX_TIMEOUT; in rtl8152_probe_once()
9804 netdev->features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG | in rtl8152_probe_once()
9808 netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG | in rtl8152_probe_once()
9812 netdev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | in rtl8152_probe_once()
9816 if (tp->version == RTL_VER_01) { in rtl8152_probe_once()
9817 netdev->features &= ~NETIF_F_RXCSUM; in rtl8152_probe_once()
9818 netdev->hw_features &= ~NETIF_F_RXCSUM; in rtl8152_probe_once()
9821 tp->lenovo_macpassthru = rtl8152_supports_lenovo_macpassthru(udev); in rtl8152_probe_once()
9823 if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial && in rtl8152_probe_once()
9824 (!strcmp(udev->serial, "000001000000") || in rtl8152_probe_once()
9825 !strcmp(udev->serial, "000002000000"))) { in rtl8152_probe_once()
9826 dev_info(&udev->dev, "Dell TB16 Dock, disable RX aggregation"); in rtl8152_probe_once()
9827 tp->dell_tb_rx_agg_bug = 1; in rtl8152_probe_once()
9830 netdev->ethtool_ops = &ops; in rtl8152_probe_once()
9833 /* MTU range: 68 - 1500 or 9194 */ in rtl8152_probe_once()
9834 netdev->min_mtu = ETH_MIN_MTU; in rtl8152_probe_once()
9835 switch (tp->version) { in rtl8152_probe_once()
9843 netdev->max_mtu = size_to_mtu(9 * 1024); in rtl8152_probe_once()
9847 netdev->max_mtu = size_to_mtu(15 * 1024); in rtl8152_probe_once()
9852 netdev->max_mtu = size_to_mtu(16 * 1024); in rtl8152_probe_once()
9858 netdev->max_mtu = ETH_DATA_LEN; in rtl8152_probe_once()
9862 tp->mii.dev = netdev; in rtl8152_probe_once()
9863 tp->mii.mdio_read = read_mii_word; in rtl8152_probe_once()
9864 tp->mii.mdio_write = write_mii_word; in rtl8152_probe_once()
9865 tp->mii.phy_id_mask = 0x3f; in rtl8152_probe_once()
9866 tp->mii.reg_num_mask = 0x1f; in rtl8152_probe_once()
9867 tp->mii.phy_id = R8152_PHY_ID; in rtl8152_probe_once()
9869 tp->autoneg = AUTONEG_ENABLE; in rtl8152_probe_once()
9870 tp->speed = SPEED_100; in rtl8152_probe_once()
9871 tp->advertising = RTL_ADVERTISED_10_HALF | RTL_ADVERTISED_10_FULL | in rtl8152_probe_once()
9873 if (tp->mii.supports_gmii) { in rtl8152_probe_once()
9874 if (tp->support_2500full && in rtl8152_probe_once()
9875 tp->udev->speed >= USB_SPEED_SUPER) { in rtl8152_probe_once()
9876 tp->speed = SPEED_2500; in rtl8152_probe_once()
9877 tp->advertising |= RTL_ADVERTISED_2500_FULL; in rtl8152_probe_once()
9879 tp->speed = SPEED_1000; in rtl8152_probe_once()
9881 tp->advertising |= RTL_ADVERTISED_1000_FULL; in rtl8152_probe_once()
9883 tp->duplex = DUPLEX_FULL; in rtl8152_probe_once()
9885 tp->rx_copybreak = RTL8152_RXFG_HEADSZ; in rtl8152_probe_once()
9886 tp->rx_pending = 10 * RTL8152_MAX_RX; in rtl8152_probe_once()
9888 intf->needs_remote_wakeup = 1; in rtl8152_probe_once()
9893 tp->saved_wolopts = __rtl_get_wol(tp); in rtl8152_probe_once()
9895 tp->rtl_ops.init(tp); in rtl8152_probe_once()
9898 tp->rtl_fw.retry = true; in rtl8152_probe_once()
9900 queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0); in rtl8152_probe_once()
9905 netif_napi_add(netdev, &tp->napi, r8152_poll); in rtl8152_probe_once()
9909 dev_err(&intf->dev, "couldn't register the device\n"); in rtl8152_probe_once()
9913 if (tp->saved_wolopts) in rtl8152_probe_once()
9914 device_set_wakeup_enable(&udev->dev, true); in rtl8152_probe_once()
9916 device_set_wakeup_enable(&udev->dev, false); in rtl8152_probe_once()
9921 if (test_bit(PROBE_SHOULD_RETRY, &tp->flags)) in rtl8152_probe_once()
9924 set_bit(PROBED_WITH_NO_ERRORS, &tp->flags); in rtl8152_probe_once()
9933 tasklet_kill(&tp->tx_tl); in rtl8152_probe_once()
9934 cancel_delayed_work_sync(&tp->hw_phy_work); in rtl8152_probe_once()
9935 if (tp->rtl_ops.unload) in rtl8152_probe_once()
9936 tp->rtl_ops.unload(tp); in rtl8152_probe_once()
9940 if (test_bit(PROBE_SHOULD_RETRY, &tp->flags)) in rtl8152_probe_once()
9941 ret = -EAGAIN; in rtl8152_probe_once()
9956 if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC) in rtl8152_probe()
9957 return -ENODEV; in rtl8152_probe()
9960 return -ENODEV; in rtl8152_probe()
9964 return -ENODEV; in rtl8152_probe()
9968 if (ret != -EAGAIN) in rtl8152_probe()
9971 if (ret == -EAGAIN) { in rtl8152_probe()
9972 dev_err(&intf->dev, in rtl8152_probe()
9974 return -ENODEV; in rtl8152_probe()
9988 unregister_netdev(tp->netdev); in rtl8152_disconnect()
9989 tasklet_kill(&tp->tx_tl); in rtl8152_disconnect()
9990 cancel_delayed_work_sync(&tp->hw_phy_work); in rtl8152_disconnect()
9991 if (tp->rtl_ops.unload) in rtl8152_disconnect()
9992 tp->rtl_ops.unload(tp); in rtl8152_disconnect()
9994 free_netdev(tp->netdev); in rtl8152_disconnect()
10061 c = udev->config; in rtl8152_cfgselector_probe()
10062 num_configs = udev->descriptor.bNumConfigurations; in rtl8152_cfgselector_probe()
10066 if (!c->desc.bNumInterfaces) in rtl8152_cfgselector_probe()
10068 desc = &c->intf_cache[0]->altsetting->desc; in rtl8152_cfgselector_probe()
10069 if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC) in rtl8152_cfgselector_probe()
10074 return -ENODEV; in rtl8152_cfgselector_probe()
10076 if (usb_set_configuration(udev, c->desc.bConfigurationValue)) { in rtl8152_cfgselector_probe()
10077 dev_err(&udev->dev, "Failed to set configuration %d\n", in rtl8152_cfgselector_probe()
10078 c->desc.bConfigurationValue); in rtl8152_cfgselector_probe()
10079 return -ENODEV; in rtl8152_cfgselector_probe()
10086 .name = MODULENAME "-cfgselector",