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

1 // SPDX-License-Identifier: GPL-2.0-only
31 /* Information for net-next */
674 #define RTL_ADV2_5G_F_R BIT(5) /* Advertise 2.5GBASE-T fast-retrain */
757 #define size_to_mtu(s) ((s) - VLAN_ETH_HLEN - ETH_FCS_LEN)
881 int (*enable)(struct r8152 *tp); member
890 void (*autosuspend_en)(struct r8152 *tp, bool enable);
898 u32 aldps:1; member
954 * struct fw_block - block type and total length
965 * struct fw_header - header of the firmware file
1039 * struct fw_mac - a firmware block used by RTL_FW_PLA and RTL_FW_USB.
1080 * struct fw_phy_patch_key - a firmware block used by RTL_FW_PHY_START.
1095 * struct fw_phy_nc - a firmware block used by RTL_FW_PHY_NC.
1190 /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
1196 #define RTL_LIMITED_TSO_SIZE (size_to_mtu(agg_buf_sz) - sizeof(struct tx_desc))
1206 return -ENOMEM; in get_registers()
1208 ret = usb_control_msg(tp->udev, tp->pipe_ctrl_in, in get_registers()
1229 return -ENOMEM; in set_registers()
1231 ret = usb_control_msg(tp->udev, tp->pipe_ctrl_out, in set_registers()
1242 if (tp->udev->state == USB_STATE_NOTATTACHED) { in rtl_set_unplug()
1243 set_bit(RTL8152_UNPLUG, &tp->flags); in rtl_set_unplug()
1254 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in generic_ocp_read()
1255 return -ENODEV; in generic_ocp_read()
1259 return -EPERM; in generic_ocp_read()
1262 return -EPERM; in generic_ocp_read()
1272 size -= limit; in generic_ocp_read()
1285 if (ret == -ENODEV) in generic_ocp_read()
1298 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in generic_ocp_write()
1299 return -ENODEV; in generic_ocp_write()
1303 return -EPERM; in generic_ocp_write()
1306 return -EPERM; in generic_ocp_write()
1318 size -= 4; in generic_ocp_write()
1321 size -= 4; in generic_ocp_write()
1333 size -= limit; in generic_ocp_write()
1355 if (ret == -ENODEV) in generic_ocp_write()
1478 if (ocp_base != tp->ocp_base) { in ocp_reg_read()
1480 tp->ocp_base = ocp_base; in ocp_reg_read()
1492 if (ocp_base != tp->ocp_base) { in ocp_reg_write()
1494 tp->ocp_base = ocp_base; in ocp_reg_write()
1528 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in read_mii_word()
1529 return -ENODEV; in read_mii_word()
1532 return -EINVAL; in read_mii_word()
1544 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in write_mii_word()
1565 int ret = -EADDRNOTAVAIL; in __rtl8152_set_mac_address()
1567 if (!is_valid_ether_addr(addr->sa_data)) in __rtl8152_set_mac_address()
1571 ret = usb_autopm_get_interface(tp->intf); in __rtl8152_set_mac_address()
1576 mutex_lock(&tp->control); in __rtl8152_set_mac_address()
1578 eth_hw_addr_set(netdev, addr->sa_data); in __rtl8152_set_mac_address()
1581 pla_ocp_write(tp, PLA_IDR, BYTE_EN_SIX_BYTES, 8, addr->sa_data); in __rtl8152_set_mac_address()
1584 mutex_unlock(&tp->control); in __rtl8152_set_mac_address()
1587 usb_autopm_put_interface(tp->intf); in __rtl8152_set_mac_address()
1606 int ret = -EINVAL; in vendor_mac_passthru_addr_read()
1613 if (tp->lenovo_macpassthru) { in vendor_mac_passthru_addr_read()
1618 /* test for -AD variant of RTL8153 */ in vendor_mac_passthru_addr_read()
1621 /* test for MAC address pass-through bit */ in vendor_mac_passthru_addr_read()
1624 netif_dbg(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1625 "No efuse for RTL8153-AD MAC pass through\n"); in vendor_mac_passthru_addr_read()
1626 return -ENODEV; in vendor_mac_passthru_addr_read()
1629 /* test for RTL8153-BND and RTL8153-BD */ in vendor_mac_passthru_addr_read()
1632 netif_dbg(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1634 return -ENODEV; in vendor_mac_passthru_addr_read()
1647 return -ENODEV; in vendor_mac_passthru_addr_read()
1648 if (obj->type != mac_obj_type || obj->string.length != mac_strlen) { in vendor_mac_passthru_addr_read()
1649 netif_warn(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1650 "Invalid buffer for pass-thru MAC addr: (%d, %d)\n", in vendor_mac_passthru_addr_read()
1651 obj->type, obj->string.length); in vendor_mac_passthru_addr_read()
1655 if (strncmp(obj->string.pointer, "_AUXMAC_#", 9) != 0 || in vendor_mac_passthru_addr_read()
1656 strncmp(obj->string.pointer + 0x15, "#", 1) != 0) { in vendor_mac_passthru_addr_read()
1657 netif_warn(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1658 "Invalid header when reading pass-thru MAC addr\n"); in vendor_mac_passthru_addr_read()
1661 ret = hex2bin(buf, obj->string.pointer + 9, 6); in vendor_mac_passthru_addr_read()
1663 netif_warn(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1664 "Invalid MAC for pass-thru MAC addr: %d, %pM\n", in vendor_mac_passthru_addr_read()
1666 ret = -EINVAL; in vendor_mac_passthru_addr_read()
1669 memcpy(sa->sa_data, buf, 6); in vendor_mac_passthru_addr_read()
1670 netif_info(tp, probe, tp->netdev, in vendor_mac_passthru_addr_read()
1671 "Using pass-thru MAC addr %pM\n", sa->sa_data); in vendor_mac_passthru_addr_read()
1680 struct net_device *dev = tp->netdev; in determine_ethernet_addr()
1683 sa->sa_family = dev->type; in determine_ethernet_addr()
1685 ret = eth_platform_get_mac_address(&tp->udev->dev, sa->sa_data); in determine_ethernet_addr()
1687 if (tp->version == RTL_VER_01) { in determine_ethernet_addr()
1688 ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data); in determine_ethernet_addr()
1691 * be expected to be non-zero in determine_ethernet_addr()
1696 sa->sa_data); in determine_ethernet_addr()
1702 } else if (!is_valid_ether_addr(sa->sa_data)) { in determine_ethernet_addr()
1704 sa->sa_data); in determine_ethernet_addr()
1706 ether_addr_copy(sa->sa_data, dev->dev_addr); in determine_ethernet_addr()
1708 sa->sa_data); in determine_ethernet_addr()
1717 struct net_device *dev = tp->netdev; in set_ethernet_addr()
1725 if (tp->version == RTL_VER_01) in set_ethernet_addr()
1736 int status = urb->status; in read_bulk_callback()
1741 agg = urb->context; in read_bulk_callback()
1745 tp = agg->context; in read_bulk_callback()
1749 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in read_bulk_callback()
1752 if (!test_bit(WORK_ENABLE, &tp->flags)) in read_bulk_callback()
1755 netdev = tp->netdev; in read_bulk_callback()
1758 /* This avoid the re-submitting bulk */ in read_bulk_callback()
1762 usb_mark_last_busy(tp->udev); in read_bulk_callback()
1766 if (urb->actual_length < ETH_ZLEN) in read_bulk_callback()
1769 spin_lock_irqsave(&tp->rx_lock, flags); in read_bulk_callback()
1770 list_add_tail(&agg->list, &tp->rx_done); in read_bulk_callback()
1771 spin_unlock_irqrestore(&tp->rx_lock, flags); in read_bulk_callback()
1772 napi_schedule(&tp->napi); in read_bulk_callback()
1774 case -ESHUTDOWN: in read_bulk_callback()
1776 netif_device_detach(tp->netdev); in read_bulk_callback()
1778 case -EPROTO: in read_bulk_callback()
1779 urb->actual_length = 0; in read_bulk_callback()
1780 spin_lock_irqsave(&tp->rx_lock, flags); in read_bulk_callback()
1781 list_add_tail(&agg->list, &tp->rx_done); in read_bulk_callback()
1782 spin_unlock_irqrestore(&tp->rx_lock, flags); in read_bulk_callback()
1783 set_bit(RX_EPROTO, &tp->flags); in read_bulk_callback()
1784 schedule_delayed_work(&tp->schedule, 1); in read_bulk_callback()
1786 case -ENOENT: in read_bulk_callback()
1788 case -ETIME: in read_bulk_callback()
1808 int status = urb->status; in write_bulk_callback()
1810 agg = urb->context; in write_bulk_callback()
1814 tp = agg->context; in write_bulk_callback()
1818 netdev = tp->netdev; in write_bulk_callback()
1819 stats = &netdev->stats; in write_bulk_callback()
1823 stats->tx_errors += agg->skb_num; in write_bulk_callback()
1825 stats->tx_packets += agg->skb_num; in write_bulk_callback()
1826 stats->tx_bytes += agg->skb_len; in write_bulk_callback()
1829 spin_lock_irqsave(&tp->tx_lock, flags); in write_bulk_callback()
1830 list_add_tail(&agg->list, &tp->tx_free); in write_bulk_callback()
1831 spin_unlock_irqrestore(&tp->tx_lock, flags); in write_bulk_callback()
1833 usb_autopm_put_interface_async(tp->intf); in write_bulk_callback()
1838 if (!test_bit(WORK_ENABLE, &tp->flags)) in write_bulk_callback()
1841 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in write_bulk_callback()
1844 if (!skb_queue_empty(&tp->tx_queue)) in write_bulk_callback()
1845 tasklet_schedule(&tp->tx_tl); in write_bulk_callback()
1852 int status = urb->status; in intr_callback()
1855 tp = urb->context; in intr_callback()
1859 if (!test_bit(WORK_ENABLE, &tp->flags)) in intr_callback()
1862 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in intr_callback()
1868 case -ECONNRESET: /* unlink */ in intr_callback()
1869 case -ESHUTDOWN: in intr_callback()
1870 netif_device_detach(tp->netdev); in intr_callback()
1872 case -ENOENT: in intr_callback()
1873 case -EPROTO: in intr_callback()
1874 netif_info(tp, intr, tp->netdev, in intr_callback()
1877 case -EOVERFLOW: in intr_callback()
1879 netif_info(tp, intr, tp->netdev, in intr_callback()
1880 "intr status -EOVERFLOW\n"); in intr_callback()
1882 /* -EPIPE: should clear the halt */ in intr_callback()
1884 netif_info(tp, intr, tp->netdev, "intr status %d\n", status); in intr_callback()
1888 d = urb->transfer_buffer; in intr_callback()
1890 if (!netif_carrier_ok(tp->netdev)) { in intr_callback()
1891 set_bit(RTL8152_LINK_CHG, &tp->flags); in intr_callback()
1892 schedule_delayed_work(&tp->schedule, 0); in intr_callback()
1895 if (netif_carrier_ok(tp->netdev)) { in intr_callback()
1896 netif_stop_queue(tp->netdev); in intr_callback()
1897 set_bit(RTL8152_LINK_CHG, &tp->flags); in intr_callback()
1898 schedule_delayed_work(&tp->schedule, 0); in intr_callback()
1904 if (res == -ENODEV) { in intr_callback()
1906 netif_device_detach(tp->netdev); in intr_callback()
1908 netif_err(tp, intr, tp->netdev, in intr_callback()
1925 list_del(&agg->info_list); in free_rx_agg()
1927 usb_free_urb(agg->urb); in free_rx_agg()
1928 put_page(agg->page); in free_rx_agg()
1931 atomic_dec(&tp->rx_count); in free_rx_agg()
1936 struct net_device *netdev = tp->netdev; in alloc_rx_agg()
1937 int node = netdev->dev.parent ? dev_to_node(netdev->dev.parent) : -1; in alloc_rx_agg()
1938 unsigned int order = get_order(tp->rx_buf_sz); in alloc_rx_agg()
1946 rx_agg->page = alloc_pages(mflags | __GFP_COMP, order); in alloc_rx_agg()
1947 if (!rx_agg->page) in alloc_rx_agg()
1950 rx_agg->buffer = page_address(rx_agg->page); in alloc_rx_agg()
1952 rx_agg->urb = usb_alloc_urb(0, mflags); in alloc_rx_agg()
1953 if (!rx_agg->urb) in alloc_rx_agg()
1956 rx_agg->context = tp; in alloc_rx_agg()
1958 INIT_LIST_HEAD(&rx_agg->list); in alloc_rx_agg()
1959 INIT_LIST_HEAD(&rx_agg->info_list); in alloc_rx_agg()
1960 spin_lock_irqsave(&tp->rx_lock, flags); in alloc_rx_agg()
1961 list_add_tail(&rx_agg->info_list, &tp->rx_info); in alloc_rx_agg()
1962 spin_unlock_irqrestore(&tp->rx_lock, flags); in alloc_rx_agg()
1964 atomic_inc(&tp->rx_count); in alloc_rx_agg()
1969 __free_pages(rx_agg->page, order); in alloc_rx_agg()
1981 spin_lock_irqsave(&tp->rx_lock, flags); in free_all_mem()
1983 list_for_each_entry_safe(agg, agg_next, &tp->rx_info, info_list) in free_all_mem()
1986 spin_unlock_irqrestore(&tp->rx_lock, flags); in free_all_mem()
1988 WARN_ON(atomic_read(&tp->rx_count)); in free_all_mem()
1991 usb_free_urb(tp->tx_info[i].urb); in free_all_mem()
1992 tp->tx_info[i].urb = NULL; in free_all_mem()
1994 kfree(tp->tx_info[i].buffer); in free_all_mem()
1995 tp->tx_info[i].buffer = NULL; in free_all_mem()
1996 tp->tx_info[i].head = NULL; in free_all_mem()
1999 usb_free_urb(tp->intr_urb); in free_all_mem()
2000 tp->intr_urb = NULL; in free_all_mem()
2002 kfree(tp->intr_buff); in free_all_mem()
2003 tp->intr_buff = NULL; in free_all_mem()
2008 struct net_device *netdev = tp->netdev; in alloc_all_mem()
2009 struct usb_interface *intf = tp->intf; in alloc_all_mem()
2010 struct usb_host_interface *alt = intf->cur_altsetting; in alloc_all_mem()
2011 struct usb_host_endpoint *ep_intr = alt->endpoint + 2; in alloc_all_mem()
2014 node = netdev->dev.parent ? dev_to_node(netdev->dev.parent) : -1; in alloc_all_mem()
2016 spin_lock_init(&tp->rx_lock); in alloc_all_mem()
2017 spin_lock_init(&tp->tx_lock); in alloc_all_mem()
2018 INIT_LIST_HEAD(&tp->rx_info); in alloc_all_mem()
2019 INIT_LIST_HEAD(&tp->tx_free); in alloc_all_mem()
2020 INIT_LIST_HEAD(&tp->rx_done); in alloc_all_mem()
2021 skb_queue_head_init(&tp->tx_queue); in alloc_all_mem()
2022 skb_queue_head_init(&tp->rx_queue); in alloc_all_mem()
2023 atomic_set(&tp->rx_count, 0); in alloc_all_mem()
2052 INIT_LIST_HEAD(&tp->tx_info[i].list); in alloc_all_mem()
2053 tp->tx_info[i].context = tp; in alloc_all_mem()
2054 tp->tx_info[i].urb = urb; in alloc_all_mem()
2055 tp->tx_info[i].buffer = buf; in alloc_all_mem()
2056 tp->tx_info[i].head = tx_agg_align(buf); in alloc_all_mem()
2058 list_add_tail(&tp->tx_info[i].list, &tp->tx_free); in alloc_all_mem()
2061 tp->intr_urb = usb_alloc_urb(0, GFP_KERNEL); in alloc_all_mem()
2062 if (!tp->intr_urb) in alloc_all_mem()
2065 tp->intr_buff = kmalloc(INTBUFSIZE, GFP_KERNEL); in alloc_all_mem()
2066 if (!tp->intr_buff) in alloc_all_mem()
2069 tp->intr_interval = (int)ep_intr->desc.bInterval; in alloc_all_mem()
2070 usb_fill_int_urb(tp->intr_urb, tp->udev, tp->pipe_intr, in alloc_all_mem()
2071 tp->intr_buff, INTBUFSIZE, intr_callback, in alloc_all_mem()
2072 tp, tp->intr_interval); in alloc_all_mem()
2078 return -ENOMEM; in alloc_all_mem()
2086 if (list_empty(&tp->tx_free)) in r8152_get_tx_agg()
2089 spin_lock_irqsave(&tp->tx_lock, flags); in r8152_get_tx_agg()
2090 if (!list_empty(&tp->tx_free)) { in r8152_get_tx_agg()
2093 cursor = tp->tx_free.next; in r8152_get_tx_agg()
2097 spin_unlock_irqrestore(&tp->tx_lock, flags); in r8152_get_tx_agg()
2109 if (skb_shinfo(skb)->gso_size) { in r8152_csum_workaround()
2110 netdev_features_t features = tp->netdev->features; in r8152_csum_workaround()
2128 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in r8152_csum_workaround()
2137 stats = &tp->netdev->stats; in r8152_csum_workaround()
2138 stats->tx_dropped++; in r8152_csum_workaround()
2149 desc->opts2 |= cpu_to_le32(opts2); in rtl_tx_vlan_tag()
2155 u32 opts2 = le32_to_cpu(desc->opts2); in rtl_rx_vlan_tag()
2165 u32 mss = skb_shinfo(skb)->gso_size; in r8152_tx_csum()
2177 netif_warn(tp, tx_err, tp->netdev, in r8152_tx_csum()
2205 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in r8152_tx_csum()
2210 netif_warn(tp, tx_err, tp->netdev, in r8152_tx_csum()
2220 ip_protocol = ip_hdr(skb)->protocol; in r8152_tx_csum()
2225 ip_protocol = ipv6_hdr(skb)->nexthdr; in r8152_tx_csum()
2243 desc->opts2 = cpu_to_le32(opts2); in r8152_tx_csum()
2244 desc->opts1 = cpu_to_le32(opts1); in r8152_tx_csum()
2252 struct sk_buff_head skb_head, *tx_queue = &tp->tx_queue; in r8152_tx_agg_fill()
2257 spin_lock(&tx_queue->lock); in r8152_tx_agg_fill()
2259 spin_unlock(&tx_queue->lock); in r8152_tx_agg_fill()
2261 tx_data = agg->head; in r8152_tx_agg_fill()
2262 agg->skb_num = 0; in r8152_tx_agg_fill()
2263 agg->skb_len = 0; in r8152_tx_agg_fill()
2275 len = skb->len + sizeof(*tx_desc); in r8152_tx_agg_fill()
2285 if (r8152_tx_csum(tp, tx_desc, skb, skb->len)) { in r8152_tx_agg_fill()
2294 len = skb->len; in r8152_tx_agg_fill()
2296 struct net_device_stats *stats = &tp->netdev->stats; in r8152_tx_agg_fill()
2298 stats->tx_dropped++; in r8152_tx_agg_fill()
2300 tx_data -= sizeof(*tx_desc); in r8152_tx_agg_fill()
2305 agg->skb_len += len; in r8152_tx_agg_fill()
2306 agg->skb_num += skb_shinfo(skb)->gso_segs ?: 1; in r8152_tx_agg_fill()
2310 remain = agg_buf_sz - (int)(tx_agg_align(tx_data) - agg->head); in r8152_tx_agg_fill()
2312 if (tp->dell_tb_rx_agg_bug) in r8152_tx_agg_fill()
2317 spin_lock(&tx_queue->lock); in r8152_tx_agg_fill()
2319 spin_unlock(&tx_queue->lock); in r8152_tx_agg_fill()
2322 netif_tx_lock(tp->netdev); in r8152_tx_agg_fill()
2324 if (netif_queue_stopped(tp->netdev) && in r8152_tx_agg_fill()
2325 skb_queue_len(&tp->tx_queue) < tp->tx_qlen) in r8152_tx_agg_fill()
2326 netif_wake_queue(tp->netdev); in r8152_tx_agg_fill()
2328 netif_tx_unlock(tp->netdev); in r8152_tx_agg_fill()
2330 ret = usb_autopm_get_interface_async(tp->intf); in r8152_tx_agg_fill()
2334 usb_fill_bulk_urb(agg->urb, tp->udev, tp->pipe_out, in r8152_tx_agg_fill()
2335 agg->head, (int)(tx_data - (u8 *)agg->head), in r8152_tx_agg_fill()
2338 ret = usb_submit_urb(agg->urb, GFP_ATOMIC); in r8152_tx_agg_fill()
2340 usb_autopm_put_interface_async(tp->intf); in r8152_tx_agg_fill()
2351 if (!(tp->netdev->features & NETIF_F_RXCSUM)) in r8152_rx_csum()
2354 opts2 = le32_to_cpu(rx_desc->opts2); in r8152_rx_csum()
2355 opts3 = le32_to_cpu(rx_desc->opts3); in r8152_rx_csum()
2377 return atomic_read(&tp->rx_count) > RTL8152_MAX_RX; in rx_count_exceed()
2382 return (int)(addr - agg->buffer); in agg_offset()
2390 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_get_free_rx()
2392 list_for_each_entry_safe(agg, agg_next, &tp->rx_used, list) { in rtl_get_free_rx()
2393 if (page_count(agg->page) == 1) { in rtl_get_free_rx()
2395 list_del_init(&agg->list); in rtl_get_free_rx()
2400 list_del_init(&agg->list); in rtl_get_free_rx()
2407 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_get_free_rx()
2409 if (!agg_free && atomic_read(&tp->rx_count) < tp->rx_pending) in rtl_get_free_rx()
2420 struct napi_struct *napi = &tp->napi; in rx_bottom()
2422 if (!skb_queue_empty(&tp->rx_queue)) { in rx_bottom()
2424 struct sk_buff *skb = __skb_dequeue(&tp->rx_queue); in rx_bottom()
2425 struct net_device *netdev = tp->netdev; in rx_bottom()
2426 struct net_device_stats *stats = &netdev->stats; in rx_bottom()
2432 pkt_len = skb->len; in rx_bottom()
2435 stats->rx_packets++; in rx_bottom()
2436 stats->rx_bytes += pkt_len; in rx_bottom()
2440 if (list_empty(&tp->rx_done)) in rx_bottom()
2443 clear_bit(RX_EPROTO, &tp->flags); in rx_bottom()
2445 spin_lock_irqsave(&tp->rx_lock, flags); in rx_bottom()
2446 list_splice_init(&tp->rx_done, &rx_queue); in rx_bottom()
2447 spin_unlock_irqrestore(&tp->rx_lock, flags); in rx_bottom()
2459 urb = agg->urb; in rx_bottom()
2460 if (urb->status != 0 || urb->actual_length < ETH_ZLEN) in rx_bottom()
2465 rx_desc = agg->buffer; in rx_bottom()
2466 rx_data = agg->buffer; in rx_bottom()
2469 while (urb->actual_length > len_used) { in rx_bottom()
2470 struct net_device *netdev = tp->netdev; in rx_bottom()
2471 struct net_device_stats *stats = &netdev->stats; in rx_bottom()
2476 if (unlikely(skb_queue_len(&tp->rx_queue) >= 1000)) in rx_bottom()
2479 pkt_len = le32_to_cpu(rx_desc->opts1) & RX_LEN_MASK; in rx_bottom()
2484 if (urb->actual_length < len_used) in rx_bottom()
2487 pkt_len -= ETH_FCS_LEN; in rx_bottom()
2490 if (!agg_free || tp->rx_copybreak > pkt_len) in rx_bottom()
2493 rx_frag_head_sz = tp->rx_copybreak; in rx_bottom()
2497 stats->rx_dropped++; in rx_bottom()
2501 skb->ip_summed = r8152_rx_csum(tp, rx_desc); in rx_bottom()
2502 memcpy(skb->data, rx_data, rx_frag_head_sz); in rx_bottom()
2504 pkt_len -= rx_frag_head_sz; in rx_bottom()
2507 skb_add_rx_frag(skb, 0, agg->page, in rx_bottom()
2511 get_page(agg->page); in rx_bottom()
2514 skb->protocol = eth_type_trans(skb, netdev); in rx_bottom()
2518 stats->rx_packets++; in rx_bottom()
2519 stats->rx_bytes += skb->len; in rx_bottom()
2522 __skb_queue_tail(&tp->rx_queue, skb); in rx_bottom()
2532 WARN_ON(!agg_free && page_count(agg->page) > 1); in rx_bottom()
2535 spin_lock_irqsave(&tp->rx_lock, flags); in rx_bottom()
2536 if (page_count(agg->page) == 1) { in rx_bottom()
2537 list_add(&agg_free->list, &tp->rx_used); in rx_bottom()
2539 list_add_tail(&agg->list, &tp->rx_used); in rx_bottom()
2541 urb = agg->urb; in rx_bottom()
2543 spin_unlock_irqrestore(&tp->rx_lock, flags); in rx_bottom()
2550 urb->actual_length = 0; in rx_bottom()
2551 list_add_tail(&agg->list, next); in rx_bottom()
2556 spin_lock_irqsave(&tp->rx_lock, flags); in rx_bottom()
2557 list_splice_tail(&rx_queue, &tp->rx_done); in rx_bottom()
2558 spin_unlock_irqrestore(&tp->rx_lock, flags); in rx_bottom()
2570 struct net_device *netdev = tp->netdev; in tx_bottom()
2573 if (skb_queue_empty(&tp->tx_queue)) in tx_bottom()
2584 if (res == -ENODEV) { in tx_bottom()
2588 struct net_device_stats *stats = &netdev->stats; in tx_bottom()
2593 stats->tx_dropped += agg->skb_num; in tx_bottom()
2595 spin_lock_irqsave(&tp->tx_lock, flags); in tx_bottom()
2596 list_add_tail(&agg->list, &tp->tx_free); in tx_bottom()
2597 spin_unlock_irqrestore(&tp->tx_lock, flags); in tx_bottom()
2606 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in bottom_half()
2609 if (!test_bit(WORK_ENABLE, &tp->flags)) in bottom_half()
2613 /* This avoid the re-submitting bulk */ in bottom_half()
2614 if (!netif_carrier_ok(tp->netdev)) in bottom_half()
2617 clear_bit(SCHEDULE_TASKLET, &tp->flags); in bottom_half()
2632 if (!list_empty(&tp->rx_done)) in r8152_poll()
2646 if (test_bit(RTL8152_UNPLUG, &tp->flags) || in r8152_submit_rx()
2647 !test_bit(WORK_ENABLE, &tp->flags) || !netif_carrier_ok(tp->netdev)) in r8152_submit_rx()
2650 usb_fill_bulk_urb(agg->urb, tp->udev, tp->pipe_in, in r8152_submit_rx()
2651 agg->buffer, tp->rx_buf_sz, in r8152_submit_rx()
2654 ret = usb_submit_urb(agg->urb, mem_flags); in r8152_submit_rx()
2655 if (ret == -ENODEV) { in r8152_submit_rx()
2657 netif_device_detach(tp->netdev); in r8152_submit_rx()
2659 struct urb *urb = agg->urb; in r8152_submit_rx()
2662 urb->actual_length = 0; in r8152_submit_rx()
2663 spin_lock_irqsave(&tp->rx_lock, flags); in r8152_submit_rx()
2664 list_add_tail(&agg->list, &tp->rx_done); in r8152_submit_rx()
2665 spin_unlock_irqrestore(&tp->rx_lock, flags); in r8152_submit_rx()
2667 netif_err(tp, rx_err, tp->netdev, in r8152_submit_rx()
2670 napi_schedule(&tp->napi); in r8152_submit_rx()
2678 struct net_device_stats *stats = &tp->netdev->stats; in rtl_drop_queued_tx()
2679 struct sk_buff_head skb_head, *tx_queue = &tp->tx_queue; in rtl_drop_queued_tx()
2686 spin_lock_bh(&tx_queue->lock); in rtl_drop_queued_tx()
2688 spin_unlock_bh(&tx_queue->lock); in rtl_drop_queued_tx()
2692 stats->tx_dropped++; in rtl_drop_queued_tx()
2702 usb_queue_reset_device(tp->intf); in rtl8152_tx_timeout()
2710 set_bit(RTL8152_SET_RX_MODE, &tp->flags); in rtl8152_set_rx_mode()
2711 schedule_delayed_work(&tp->schedule, 0); in rtl8152_set_rx_mode()
2727 if (netdev->flags & IFF_PROMISC) { in _rtl8152_set_rx_mode()
2733 } else if ((netdev->flags & IFF_MULTICAST && in _rtl8152_set_rx_mode()
2735 (netdev->flags & IFF_ALLMULTI)) { in _rtl8152_set_rx_mode()
2736 /* Too many to filter perfectly -- accept all multicasts. */ in _rtl8152_set_rx_mode()
2744 if (netdev->flags & IFF_MULTICAST) { in _rtl8152_set_rx_mode()
2748 int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; in _rtl8152_set_rx_mode()
2768 u32 mss = skb_shinfo(skb)->gso_size; in rtl8152_features_check()
2771 if ((mss || skb->ip_summed == CHECKSUM_PARTIAL) && in rtl8152_features_check()
2774 else if ((skb->len + sizeof(struct tx_desc)) > agg_buf_sz) in rtl8152_features_check()
2787 skb_queue_tail(&tp->tx_queue, skb); in rtl8152_start_xmit()
2789 if (!list_empty(&tp->tx_free)) { in rtl8152_start_xmit()
2790 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { in rtl8152_start_xmit()
2791 set_bit(SCHEDULE_TASKLET, &tp->flags); in rtl8152_start_xmit()
2792 schedule_delayed_work(&tp->schedule, 0); in rtl8152_start_xmit()
2794 usb_mark_last_busy(tp->udev); in rtl8152_start_xmit()
2795 tasklet_schedule(&tp->tx_tl); in rtl8152_start_xmit()
2797 } else if (skb_queue_len(&tp->tx_queue) > tp->tx_qlen) { in rtl8152_start_xmit()
2820 switch (tp->version) { in rtl8152_nic_reset()
2863 tp->tx_qlen = agg_buf_sz / (mtu_to_size(tp->netdev->mtu) + sizeof(struct tx_desc)); in set_tx_qlen()
2871 static void rtl_eee_plus_en(struct r8152 *tp, bool enable) in rtl_eee_plus_en() argument
2876 if (enable) in rtl_eee_plus_en()
2891 static void rxdy_gated_en(struct r8152 *tp, bool enable) in rxdy_gated_en() argument
2896 if (enable) in rxdy_gated_en()
2912 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_start_rx()
2914 INIT_LIST_HEAD(&tp->rx_done); in rtl_start_rx()
2915 INIT_LIST_HEAD(&tp->rx_used); in rtl_start_rx()
2917 list_splice_init(&tp->rx_info, &tmp_list); in rtl_start_rx()
2919 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_start_rx()
2922 INIT_LIST_HEAD(&agg->list); in rtl_start_rx()
2926 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_start_rx()
2927 list_add_tail(&agg->list, &tp->rx_used); in rtl_start_rx()
2928 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_start_rx()
2930 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_start_rx()
2931 list_add_tail(&agg->list, &tp->rx_done); in rtl_start_rx()
2932 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_start_rx()
2938 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_start_rx()
2939 WARN_ON(!list_empty(&tp->rx_info)); in rtl_start_rx()
2940 list_splice(&tmp_list, &tp->rx_info); in rtl_start_rx()
2941 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_start_rx()
2960 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_stop_rx()
2961 list_splice_init(&tp->rx_info, &tmp_list); in rtl_stop_rx()
2962 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_stop_rx()
2968 if (page_count(agg->page) > 1) in rtl_stop_rx()
2971 usb_kill_urb(agg->urb); in rtl_stop_rx()
2975 spin_lock_irqsave(&tp->rx_lock, flags); in rtl_stop_rx()
2976 WARN_ON(!list_empty(&tp->rx_info)); in rtl_stop_rx()
2977 list_splice(&tmp_list, &tp->rx_info); in rtl_stop_rx()
2978 spin_unlock_irqrestore(&tp->rx_lock, flags); in rtl_stop_rx()
2980 while (!skb_queue_empty(&tp->rx_queue)) in rtl_stop_rx()
2981 dev_kfree_skb(__skb_dequeue(&tp->rx_queue)); in rtl_stop_rx()
3025 switch (tp->version) { in rtl_enable()
3042 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8152_enable()
3043 return -ENODEV; in rtl8152_enable()
3053 u32 ocp_data = tp->coalesce / 8; in r8153_set_rx_early_timeout()
3055 switch (tp->version) { in r8153_set_rx_early_timeout()
3095 u32 ocp_data = tp->rx_buf_sz - rx_reserved_size(tp->netdev->mtu); in r8153_set_rx_early_size()
3097 switch (tp->version) { in r8153_set_rx_early_size()
3131 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8153_enable()
3132 return -ENODEV; in rtl8153_enable()
3141 switch (tp->version) { in rtl8153_enable()
3163 if (test_bit(RTL8152_UNPLUG, &tp->flags)) { in rtl_disable()
3175 usb_kill_urb(tp->tx_info[i].urb); in rtl_disable()
3197 static void r8152_power_cut_en(struct r8152 *tp, bool enable) in r8152_power_cut_en() argument
3202 if (enable) in r8152_power_cut_en()
3213 static void rtl_rx_vlan_en(struct r8152 *tp, bool enable) in rtl_rx_vlan_en() argument
3217 switch (tp->version) { in rtl_rx_vlan_en()
3229 if (enable) in rtl_rx_vlan_en()
3244 if (enable) in rtl_rx_vlan_en()
3256 netdev_features_t changed = features ^ dev->features; in rtl8152_set_features()
3260 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_features()
3264 mutex_lock(&tp->control); in rtl8152_set_features()
3273 mutex_unlock(&tp->control); in rtl8152_set_features()
3275 usb_autopm_put_interface(tp->intf); in rtl8152_set_features()
3338 device_set_wakeup_enable(&tp->udev->dev, true); in __rtl_set_wol()
3340 device_set_wakeup_enable(&tp->udev->dev, false); in __rtl_set_wol()
3343 static void r8153_mac_clk_speed_down(struct r8152 *tp, bool enable) in r8153_mac_clk_speed_down() argument
3348 if (enable) in r8153_mac_clk_speed_down()
3356 static void r8156_mac_clk_spd(struct r8152 *tp, bool enable) in r8156_mac_clk_spd() argument
3361 if (enable) { in r8156_mac_clk_spd()
3377 static void r8153_u1u2en(struct r8152 *tp, bool enable) in r8153_u1u2en() argument
3381 if (enable) in r8153_u1u2en()
3389 static void r8153b_u1u2en(struct r8152 *tp, bool enable) in r8153b_u1u2en() argument
3394 if (enable) in r8153b_u1u2en()
3402 static void r8153_u2p3en(struct r8152 *tp, bool enable) in r8153_u2p3en() argument
3407 if (enable) in r8153_u2p3en()
3418 if (tp->ups_info.green) in r8153b_ups_flags()
3421 if (tp->ups_info.aldps) in r8153b_ups_flags()
3424 if (tp->ups_info.eee) in r8153b_ups_flags()
3427 if (tp->ups_info.flow_control) in r8153b_ups_flags()
3430 if (tp->ups_info.eee_ckdiv) in r8153b_ups_flags()
3433 if (tp->ups_info.eee_cmod_lv) in r8153b_ups_flags()
3436 if (tp->ups_info.r_tune) in r8153b_ups_flags()
3439 if (tp->ups_info._10m_ckdiv) in r8153b_ups_flags()
3442 if (tp->ups_info.eee_plloff_100) in r8153b_ups_flags()
3445 if (tp->ups_info.eee_plloff_giga) in r8153b_ups_flags()
3448 if (tp->ups_info._250m_ckdiv) in r8153b_ups_flags()
3451 if (tp->ups_info.ctap_short_off) in r8153b_ups_flags()
3454 switch (tp->ups_info.speed_duplex) { in r8153b_ups_flags()
3493 if (tp->ups_info.green) in r8156_ups_flags()
3496 if (tp->ups_info.aldps) in r8156_ups_flags()
3499 if (tp->ups_info.eee) in r8156_ups_flags()
3502 if (tp->ups_info.flow_control) in r8156_ups_flags()
3505 if (tp->ups_info.eee_ckdiv) in r8156_ups_flags()
3508 if (tp->ups_info._10m_ckdiv) in r8156_ups_flags()
3511 if (tp->ups_info.eee_plloff_100) in r8156_ups_flags()
3514 if (tp->ups_info.eee_plloff_giga) in r8156_ups_flags()
3517 if (tp->ups_info._250m_ckdiv) in r8156_ups_flags()
3520 switch (tp->ups_info.speed_duplex) { in r8156_ups_flags()
3555 switch (tp->ups_info.lite_mode) { in r8156_ups_flags()
3571 static void rtl_green_en(struct r8152 *tp, bool enable) in rtl_green_en() argument
3576 if (enable) in rtl_green_en()
3582 tp->ups_info.green = enable; in rtl_green_en()
3585 static void r8153b_green_en(struct r8152 *tp, bool enable) in r8153b_green_en() argument
3587 if (enable) { in r8153b_green_en()
3617 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8153_phy_status()
3624 static void r8153b_ups_en(struct r8152 *tp, bool enable) in r8153b_ups_en() argument
3628 if (enable) { in r8153b_ups_en()
3655 tp->rtl_ops.hw_phy_cfg(tp); in r8153b_ups_en()
3657 rtl8152_set_speed(tp, tp->autoneg, tp->speed, in r8153b_ups_en()
3658 tp->duplex, tp->advertising); in r8153b_ups_en()
3663 static void r8153c_ups_en(struct r8152 *tp, bool enable) in r8153c_ups_en() argument
3667 if (enable) { in r8153c_ups_en()
3695 tp->rtl_ops.hw_phy_cfg(tp); in r8153c_ups_en()
3697 rtl8152_set_speed(tp, tp->autoneg, tp->speed, in r8153c_ups_en()
3698 tp->duplex, tp->advertising); in r8153c_ups_en()
3711 static void r8156_ups_en(struct r8152 *tp, bool enable) in r8156_ups_en() argument
3715 if (enable) { in r8156_ups_en()
3725 switch (tp->version) { in r8156_ups_en()
3744 tp->rtl_ops.hw_phy_cfg(tp); in r8156_ups_en()
3746 rtl8152_set_speed(tp, tp->autoneg, tp->speed, in r8156_ups_en()
3747 tp->duplex, tp->advertising); in r8156_ups_en()
3752 static void r8153_power_cut_en(struct r8152 *tp, bool enable) in r8153_power_cut_en() argument
3757 if (enable) in r8153_power_cut_en()
3768 static void r8153b_power_cut_en(struct r8152 *tp, bool enable) in r8153b_power_cut_en() argument
3773 if (enable) in r8153b_power_cut_en()
3784 static void r8153_queue_wake(struct r8152 *tp, bool enable) in r8153_queue_wake() argument
3789 if (enable) in r8153_queue_wake()
3806 struct usb_device *udev = tp->udev; in rtl_can_wakeup()
3808 return (udev->actconfig->desc.bmAttributes & USB_CONFIG_ATT_WAKEUP); in rtl_can_wakeup()
3811 static void rtl_runtime_suspend_enable(struct r8152 *tp, bool enable) in rtl_runtime_suspend_enable() argument
3813 if (enable) { in rtl_runtime_suspend_enable()
3828 __rtl_set_wol(tp, tp->saved_wolopts); in rtl_runtime_suspend_enable()
3840 static void rtl8153_runtime_enable(struct r8152 *tp, bool enable) in rtl8153_runtime_enable() argument
3842 if (enable) { in rtl8153_runtime_enable()
3849 switch (tp->version) { in rtl8153_runtime_enable()
3864 static void rtl8153b_runtime_enable(struct r8152 *tp, bool enable) in rtl8153b_runtime_enable() argument
3866 if (enable) { in rtl8153b_runtime_enable()
3876 if (tp->udev->speed >= USB_SPEED_SUPER) in rtl8153b_runtime_enable()
3881 static void rtl8153c_runtime_enable(struct r8152 *tp, bool enable) in rtl8153c_runtime_enable() argument
3883 if (enable) { in rtl8153c_runtime_enable()
3897 static void rtl8156_runtime_enable(struct r8152 *tp, bool enable) in rtl8156_runtime_enable() argument
3899 if (enable) { in rtl8156_runtime_enable()
3908 if (tp->udev->speed >= USB_SPEED_SUPER) in rtl8156_runtime_enable()
3917 switch (tp->version) { in r8153_teredo_off()
3967 switch (tp->version) { in rtl_clear_bp()
4031 tp->ocp_base = -1; in rtl_reset_ocp_base()
4060 dev_err(&tp->intf->dev, "PHY patch request fail\n"); in rtl_phy_patch_request()
4062 return -ETIME; in rtl_phy_patch_request()
4092 return -ETIME; in rtl_pre_ram_code()
4114 switch (tp->version) { in rtl8152_is_fw_phy_speed_up_ok()
4135 fw_offset = __le16_to_cpu(phy->fw_offset); in rtl8152_is_fw_phy_speed_up_ok()
4136 length = __le32_to_cpu(phy->blk_hdr.length); in rtl8152_is_fw_phy_speed_up_ok()
4138 dev_err(&tp->intf->dev, "invalid fw_offset\n"); in rtl8152_is_fw_phy_speed_up_ok()
4142 length -= fw_offset; in rtl8152_is_fw_phy_speed_up_ok()
4144 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_phy_speed_up_ok()
4148 if (__le16_to_cpu(phy->fw_reg) != 0x9A00) { in rtl8152_is_fw_phy_speed_up_ok()
4149 dev_err(&tp->intf->dev, "invalid register to load firmware\n"); in rtl8152_is_fw_phy_speed_up_ok()
4162 switch (tp->version) { in rtl8152_is_fw_phy_ver_ok()
4173 if (__le32_to_cpu(ver->blk_hdr.length) != sizeof(*ver)) { in rtl8152_is_fw_phy_ver_ok()
4174 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_phy_ver_ok()
4178 if (__le16_to_cpu(ver->ver.addr) != SRAM_GPHY_FW_VER) { in rtl8152_is_fw_phy_ver_ok()
4179 dev_err(&tp->intf->dev, "invalid phy ver addr\n"); in rtl8152_is_fw_phy_ver_ok()
4192 switch (tp->version) { in rtl8152_is_fw_phy_fixup_ok()
4203 if (__le32_to_cpu(fix->blk_hdr.length) != sizeof(*fix)) { in rtl8152_is_fw_phy_fixup_ok()
4204 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_phy_fixup_ok()
4208 if (__le16_to_cpu(fix->setting.addr) != OCP_PHY_PATCH_CMD || in rtl8152_is_fw_phy_fixup_ok()
4209 __le16_to_cpu(fix->setting.data) != BIT(7)) { in rtl8152_is_fw_phy_fixup_ok()
4210 dev_err(&tp->intf->dev, "invalid phy fixup\n"); in rtl8152_is_fw_phy_fixup_ok()
4225 switch (tp->version) { in rtl8152_is_fw_phy_union_ok()
4236 fw_offset = __le16_to_cpu(phy->fw_offset); in rtl8152_is_fw_phy_union_ok()
4237 length = __le32_to_cpu(phy->blk_hdr.length); in rtl8152_is_fw_phy_union_ok()
4239 dev_err(&tp->intf->dev, "invalid fw_offset\n"); in rtl8152_is_fw_phy_union_ok()
4243 length -= fw_offset; in rtl8152_is_fw_phy_union_ok()
4245 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_phy_union_ok()
4249 if (phy->pre_num > 2) { in rtl8152_is_fw_phy_union_ok()
4250 dev_err(&tp->intf->dev, "invalid pre_num %d\n", phy->pre_num); in rtl8152_is_fw_phy_union_ok()
4254 if (phy->bp_num > 8) { in rtl8152_is_fw_phy_union_ok()
4255 dev_err(&tp->intf->dev, "invalid bp_num %d\n", phy->bp_num); in rtl8152_is_fw_phy_union_ok()
4270 switch (tp->version) { in rtl8152_is_fw_phy_nc_ok()
4284 fw_offset = __le16_to_cpu(phy->fw_offset); in rtl8152_is_fw_phy_nc_ok()
4286 dev_err(&tp->intf->dev, "fw_offset too small\n"); in rtl8152_is_fw_phy_nc_ok()
4290 length = __le32_to_cpu(phy->blk_hdr.length); in rtl8152_is_fw_phy_nc_ok()
4292 dev_err(&tp->intf->dev, "invalid fw_offset\n"); in rtl8152_is_fw_phy_nc_ok()
4296 length -= __le16_to_cpu(phy->fw_offset); in rtl8152_is_fw_phy_nc_ok()
4298 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_phy_nc_ok()
4302 if (__le16_to_cpu(phy->fw_reg) != fw_reg) { in rtl8152_is_fw_phy_nc_ok()
4303 dev_err(&tp->intf->dev, "invalid register to load firmware\n"); in rtl8152_is_fw_phy_nc_ok()
4307 if (__le16_to_cpu(phy->ba_reg) != ba_reg) { in rtl8152_is_fw_phy_nc_ok()
4308 dev_err(&tp->intf->dev, "invalid base address register\n"); in rtl8152_is_fw_phy_nc_ok()
4312 if (__le16_to_cpu(phy->patch_en_addr) != patch_en_addr) { in rtl8152_is_fw_phy_nc_ok()
4313 dev_err(&tp->intf->dev, in rtl8152_is_fw_phy_nc_ok()
4318 if (__le16_to_cpu(phy->mode_reg) != mode_reg) { in rtl8152_is_fw_phy_nc_ok()
4319 dev_err(&tp->intf->dev, in rtl8152_is_fw_phy_nc_ok()
4324 if (__le16_to_cpu(phy->bp_start) != bp_start) { in rtl8152_is_fw_phy_nc_ok()
4325 dev_err(&tp->intf->dev, in rtl8152_is_fw_phy_nc_ok()
4330 if (__le16_to_cpu(phy->bp_num) > 4) { in rtl8152_is_fw_phy_nc_ok()
4331 dev_err(&tp->intf->dev, "invalid break point number\n"); in rtl8152_is_fw_phy_nc_ok()
4347 type = __le32_to_cpu(mac->blk_hdr.type); in rtl8152_is_fw_mac_ok()
4349 switch (tp->version) { in rtl8152_is_fw_mac_ok()
4386 switch (tp->version) { in rtl8152_is_fw_mac_ok()
4420 fw_offset = __le16_to_cpu(mac->fw_offset); in rtl8152_is_fw_mac_ok()
4422 dev_err(&tp->intf->dev, "fw_offset too small\n"); in rtl8152_is_fw_mac_ok()
4426 length = __le32_to_cpu(mac->blk_hdr.length); in rtl8152_is_fw_mac_ok()
4428 dev_err(&tp->intf->dev, "invalid fw_offset\n"); in rtl8152_is_fw_mac_ok()
4432 length -= fw_offset; in rtl8152_is_fw_mac_ok()
4434 dev_err(&tp->intf->dev, "invalid block length\n"); in rtl8152_is_fw_mac_ok()
4438 if (__le16_to_cpu(mac->fw_reg) != fw_reg) { in rtl8152_is_fw_mac_ok()
4439 dev_err(&tp->intf->dev, "invalid register to load firmware\n"); in rtl8152_is_fw_mac_ok()
4443 if (__le16_to_cpu(mac->bp_ba_addr) != bp_ba_addr) { in rtl8152_is_fw_mac_ok()
4444 dev_err(&tp->intf->dev, "invalid base address register\n"); in rtl8152_is_fw_mac_ok()
4448 if (__le16_to_cpu(mac->bp_en_addr) != bp_en_addr) { in rtl8152_is_fw_mac_ok()
4449 dev_err(&tp->intf->dev, "invalid enabled mask register\n"); in rtl8152_is_fw_mac_ok()
4453 if (__le16_to_cpu(mac->bp_start) != bp_start) { in rtl8152_is_fw_mac_ok()
4454 dev_err(&tp->intf->dev, in rtl8152_is_fw_mac_ok()
4459 if (__le16_to_cpu(mac->bp_num) > max_bp) { in rtl8152_is_fw_mac_ok()
4460 dev_err(&tp->intf->dev, "invalid break point number\n"); in rtl8152_is_fw_mac_ok()
4464 for (i = __le16_to_cpu(mac->bp_num); i < max_bp; i++) { in rtl8152_is_fw_mac_ok()
4465 if (mac->bp[i]) { in rtl8152_is_fw_mac_ok()
4466 dev_err(&tp->intf->dev, "unused bp%u is not zero\n", i); in rtl8152_is_fw_mac_ok()
4483 unsigned char checksum[sizeof(fw_hdr->checksum)]; in rtl8152_fw_verify_checksum()
4495 if (crypto_shash_digestsize(alg) != sizeof(fw_hdr->checksum)) { in rtl8152_fw_verify_checksum()
4496 rc = -EFAULT; in rtl8152_fw_verify_checksum()
4497 dev_err(&tp->intf->dev, "digestsize incorrect (%u)\n", in rtl8152_fw_verify_checksum()
4505 rc = -ENOMEM; in rtl8152_fw_verify_checksum()
4508 sdesc->tfm = alg; in rtl8152_fw_verify_checksum()
4510 len = size - sizeof(fw_hdr->checksum); in rtl8152_fw_verify_checksum()
4511 rc = crypto_shash_digest(sdesc, fw_hdr->version, len, checksum); in rtl8152_fw_verify_checksum()
4516 if (memcmp(fw_hdr->checksum, checksum, sizeof(fw_hdr->checksum))) { in rtl8152_fw_verify_checksum()
4517 dev_err(&tp->intf->dev, "checksum fail\n"); in rtl8152_fw_verify_checksum()
4518 rc = -EFAULT; in rtl8152_fw_verify_checksum()
4529 const struct firmware *fw = rtl_fw->fw; in rtl8152_check_firmware()
4530 struct fw_header *fw_hdr = (struct fw_header *)fw->data; in rtl8152_check_firmware()
4532 long ret = -EFAULT; in rtl8152_check_firmware()
4535 if (fw->size < sizeof(*fw_hdr)) { in rtl8152_check_firmware()
4536 dev_err(&tp->intf->dev, "file too small\n"); in rtl8152_check_firmware()
4540 ret = rtl8152_fw_verify_checksum(tp, fw_hdr, fw->size); in rtl8152_check_firmware()
4544 ret = -EFAULT; in rtl8152_check_firmware()
4546 for (i = sizeof(*fw_hdr); i < fw->size;) { in rtl8152_check_firmware()
4547 struct fw_block *block = (struct fw_block *)&fw->data[i]; in rtl8152_check_firmware()
4550 if ((i + sizeof(*block)) > fw->size) in rtl8152_check_firmware()
4553 type = __le32_to_cpu(block->type); in rtl8152_check_firmware()
4556 if (__le32_to_cpu(block->length) != sizeof(*block)) in rtl8152_check_firmware()
4561 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4567 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4575 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4581 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4595 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4600 if (__le32_to_cpu(block->length) != sizeof(struct fw_phy_patch_key)) { in rtl8152_check_firmware()
4601 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4610 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4615 if (__le32_to_cpu(block->length) != sizeof(*block)) { in rtl8152_check_firmware()
4616 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4625 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4631 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4637 dev_err(&tp->intf->dev, in rtl8152_check_firmware()
4650 dev_err(&tp->intf->dev, "PHY_UNION_NC out of order\n"); in rtl8152_check_firmware()
4655 dev_err(&tp->intf->dev, "multiple PHY_UNION_NC encountered\n"); in rtl8152_check_firmware()
4660 dev_err(&tp->intf->dev, "check PHY_UNION_NC failed\n"); in rtl8152_check_firmware()
4671 dev_err(&tp->intf->dev, "PHY_UNION_NC1 out of order\n"); in rtl8152_check_firmware()
4676 dev_err(&tp->intf->dev, "multiple PHY NC1 encountered\n"); in rtl8152_check_firmware()
4681 dev_err(&tp->intf->dev, "check PHY_UNION_NC1 failed\n"); in rtl8152_check_firmware()
4691 dev_err(&tp->intf->dev, "PHY_UNION_NC2 out of order\n"); in rtl8152_check_firmware()
4696 dev_err(&tp->intf->dev, "multiple PHY NC2 encountered\n"); in rtl8152_check_firmware()
4701 dev_err(&tp->intf->dev, "check PHY_UNION_NC2 failed\n"); in rtl8152_check_firmware()
4710 dev_err(&tp->intf->dev, "PHY_UNION_UC2 out of order\n"); in rtl8152_check_firmware()
4715 dev_err(&tp->intf->dev, "multiple PHY UC2 encountered\n"); in rtl8152_check_firmware()
4720 dev_err(&tp->intf->dev, "check PHY_UNION_UC2 failed\n"); in rtl8152_check_firmware()
4728 dev_err(&tp->intf->dev, "PHY_UNION_UC out of order\n"); in rtl8152_check_firmware()
4733 dev_err(&tp->intf->dev, "multiple PHY UC encountered\n"); in rtl8152_check_firmware()
4738 dev_err(&tp->intf->dev, "check PHY_UNION_UC failed\n"); in rtl8152_check_firmware()
4745 dev_err(&tp->intf->dev, "check RTL_FW_PHY_UNION_MISC failed\n"); in rtl8152_check_firmware()
4751 dev_err(&tp->intf->dev, "check PHY fixup failed\n"); in rtl8152_check_firmware()
4757 dev_err(&tp->intf->dev, "multiple PHY firmware encountered"); in rtl8152_check_firmware()
4762 dev_err(&tp->intf->dev, "check PHY speed up failed\n"); in rtl8152_check_firmware()
4775 dev_err(&tp->intf->dev, "Invalid order to set PHY version\n"); in rtl8152_check_firmware()
4780 dev_err(&tp->intf->dev, "multiple PHY version encountered"); in rtl8152_check_firmware()
4785 dev_err(&tp->intf->dev, "check PHY version failed\n"); in rtl8152_check_firmware()
4791 dev_warn(&tp->intf->dev, "Unknown type %u is found\n", in rtl8152_check_firmware()
4797 i += ALIGN(__le32_to_cpu(block->length), 8); in rtl8152_check_firmware()
4802 dev_err(&tp->intf->dev, "without PHY_STOP\n"); in rtl8152_check_firmware()
4818 if (sram_read(tp, SRAM_GPHY_FW_VER) >= __le16_to_cpu(phy->version)) { in rtl_ram_code_speed_up()
4819 dev_dbg(&tp->intf->dev, "PHY firmware has been the newest\n"); in rtl_ram_code_speed_up()
4823 len = __le32_to_cpu(phy->blk_hdr.length); in rtl_ram_code_speed_up()
4824 len -= __le16_to_cpu(phy->fw_offset); in rtl_ram_code_speed_up()
4825 data = (u8 *)phy + __le16_to_cpu(phy->fw_offset); in rtl_ram_code_speed_up()
4843 generic_ocp_write(tp, __le16_to_cpu(phy->fw_reg), 0xff, size, data, MCU_TYPE_USB); in rtl_ram_code_speed_up()
4846 len -= size; in rtl_ram_code_speed_up()
4858 dev_err(&tp->intf->dev, "ram code speedup mode timeout\n"); in rtl_ram_code_speed_up()
4867 if (sram_read(tp, SRAM_GPHY_FW_VER) == __le16_to_cpu(phy->version)) in rtl_ram_code_speed_up()
4868 dev_dbg(&tp->intf->dev, "successfully applied %s\n", phy->info); in rtl_ram_code_speed_up()
4870 dev_err(&tp->intf->dev, "ram code speedup mode fail\n"); in rtl_ram_code_speed_up()
4877 ver_addr = __le16_to_cpu(phy_ver->ver.addr); in rtl8152_fw_phy_ver()
4878 ver = __le16_to_cpu(phy_ver->ver.data); in rtl8152_fw_phy_ver()
4883 dev_dbg(&tp->intf->dev, "PHY firmware has been the newest\n"); in rtl8152_fw_phy_ver()
4889 dev_dbg(&tp->intf->dev, "PHY firmware version %x\n", ver); in rtl8152_fw_phy_ver()
4900 addr = __le16_to_cpu(fix->setting.addr); in rtl8152_fw_phy_fixup()
4903 switch (__le16_to_cpu(fix->bit_cmd)) { in rtl8152_fw_phy_fixup()
4905 data &= __le16_to_cpu(fix->setting.data); in rtl8152_fw_phy_fixup()
4908 data |= __le16_to_cpu(fix->setting.data); in rtl8152_fw_phy_fixup()
4911 data &= ~__le16_to_cpu(fix->setting.data); in rtl8152_fw_phy_fixup()
4914 data ^= __le16_to_cpu(fix->setting.data); in rtl8152_fw_phy_fixup()
4922 dev_dbg(&tp->intf->dev, "applied ocp %x %x\n", addr, data); in rtl8152_fw_phy_fixup()
4933 num = phy->pre_num; in rtl8152_fw_phy_union_apply()
4935 sram_write(tp, __le16_to_cpu(phy->pre_set[i].addr), in rtl8152_fw_phy_union_apply()
4936 __le16_to_cpu(phy->pre_set[i].data)); in rtl8152_fw_phy_union_apply()
4938 length = __le32_to_cpu(phy->blk_hdr.length); in rtl8152_fw_phy_union_apply()
4939 length -= __le16_to_cpu(phy->fw_offset); in rtl8152_fw_phy_union_apply()
4941 data = (__le16 *)((u8 *)phy + __le16_to_cpu(phy->fw_offset)); in rtl8152_fw_phy_union_apply()
4943 ocp_reg_write(tp, OCP_SRAM_ADDR, __le16_to_cpu(phy->fw_reg)); in rtl8152_fw_phy_union_apply()
4947 num = phy->bp_num; in rtl8152_fw_phy_union_apply()
4949 sram_write(tp, __le16_to_cpu(phy->bp[i].addr), __le16_to_cpu(phy->bp[i].data)); in rtl8152_fw_phy_union_apply()
4951 if (phy->bp_num && phy->bp_en.addr) in rtl8152_fw_phy_union_apply()
4952 sram_write(tp, __le16_to_cpu(phy->bp_en.addr), __le16_to_cpu(phy->bp_en.data)); in rtl8152_fw_phy_union_apply()
4954 dev_dbg(&tp->intf->dev, "successfully applied %s\n", phy->info); in rtl8152_fw_phy_union_apply()
4965 mode_reg = __le16_to_cpu(phy->mode_reg); in rtl8152_fw_phy_nc_apply()
4966 sram_write(tp, mode_reg, __le16_to_cpu(phy->mode_pre)); in rtl8152_fw_phy_nc_apply()
4967 sram_write(tp, __le16_to_cpu(phy->ba_reg), in rtl8152_fw_phy_nc_apply()
4968 __le16_to_cpu(phy->ba_data)); in rtl8152_fw_phy_nc_apply()
4970 length = __le32_to_cpu(phy->blk_hdr.length); in rtl8152_fw_phy_nc_apply()
4971 length -= __le16_to_cpu(phy->fw_offset); in rtl8152_fw_phy_nc_apply()
4973 data = (__le16 *)((u8 *)phy + __le16_to_cpu(phy->fw_offset)); in rtl8152_fw_phy_nc_apply()
4975 ocp_reg_write(tp, OCP_SRAM_ADDR, __le16_to_cpu(phy->fw_reg)); in rtl8152_fw_phy_nc_apply()
4979 sram_write(tp, __le16_to_cpu(phy->patch_en_addr), in rtl8152_fw_phy_nc_apply()
4980 __le16_to_cpu(phy->patch_en_value)); in rtl8152_fw_phy_nc_apply()
4982 bp_index = __le16_to_cpu(phy->bp_start); in rtl8152_fw_phy_nc_apply()
4983 num = __le16_to_cpu(phy->bp_num); in rtl8152_fw_phy_nc_apply()
4985 sram_write(tp, bp_index, __le16_to_cpu(phy->bp[i])); in rtl8152_fw_phy_nc_apply()
4989 sram_write(tp, mode_reg, __le16_to_cpu(phy->mode_post)); in rtl8152_fw_phy_nc_apply()
4991 dev_dbg(&tp->intf->dev, "successfully applied %s\n", phy->info); in rtl8152_fw_phy_nc_apply()
5001 switch (__le32_to_cpu(mac->blk_hdr.type)) { in rtl8152_fw_mac_apply()
5012 fw_ver_reg = __le16_to_cpu(mac->fw_ver_reg); in rtl8152_fw_mac_apply()
5013 if (fw_ver_reg && ocp_read_byte(tp, MCU_TYPE_USB, fw_ver_reg) >= mac->fw_ver_data) { in rtl8152_fw_mac_apply()
5014 dev_dbg(&tp->intf->dev, "%s firmware has been the newest\n", type ? "PLA" : "USB"); in rtl8152_fw_mac_apply()
5020 /* Enable backup/restore of MACDBG. This is required after clearing PLA in rtl8152_fw_mac_apply()
5023 if (tp->version == RTL_VER_04 && type == MCU_TYPE_PLA && in rtl8152_fw_mac_apply()
5029 length = __le32_to_cpu(mac->blk_hdr.length); in rtl8152_fw_mac_apply()
5030 length -= __le16_to_cpu(mac->fw_offset); in rtl8152_fw_mac_apply()
5033 data += __le16_to_cpu(mac->fw_offset); in rtl8152_fw_mac_apply()
5035 generic_ocp_write(tp, __le16_to_cpu(mac->fw_reg), 0xff, length, data, in rtl8152_fw_mac_apply()
5038 ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr), in rtl8152_fw_mac_apply()
5039 __le16_to_cpu(mac->bp_ba_value)); in rtl8152_fw_mac_apply()
5041 bp_index = __le16_to_cpu(mac->bp_start); in rtl8152_fw_mac_apply()
5042 bp_num = __le16_to_cpu(mac->bp_num); in rtl8152_fw_mac_apply()
5044 ocp_write_word(tp, type, bp_index, __le16_to_cpu(mac->bp[i])); in rtl8152_fw_mac_apply()
5048 bp_en_addr = __le16_to_cpu(mac->bp_en_addr); in rtl8152_fw_mac_apply()
5051 __le16_to_cpu(mac->bp_en_value)); in rtl8152_fw_mac_apply()
5055 mac->fw_ver_data); in rtl8152_fw_mac_apply()
5057 dev_dbg(&tp->intf->dev, "successfully applied %s\n", mac->info); in rtl8152_fw_mac_apply()
5062 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl8152_apply_firmware()
5069 if (IS_ERR_OR_NULL(rtl_fw->fw)) in rtl8152_apply_firmware()
5072 fw = rtl_fw->fw; in rtl8152_apply_firmware()
5073 fw_hdr = (struct fw_header *)fw->data; in rtl8152_apply_firmware()
5075 if (rtl_fw->pre_fw) in rtl8152_apply_firmware()
5076 rtl_fw->pre_fw(tp); in rtl8152_apply_firmware()
5078 for (i = offsetof(struct fw_header, blocks); i < fw->size;) { in rtl8152_apply_firmware()
5079 struct fw_block *block = (struct fw_block *)&fw->data[i]; in rtl8152_apply_firmware()
5081 switch (__le32_to_cpu(block->type)) { in rtl8152_apply_firmware()
5092 key_addr = __le16_to_cpu(key->key_reg); in rtl8152_apply_firmware()
5093 rtl_pre_ram_code(tp, key_addr, __le16_to_cpu(key->key_data), !power_cut); in rtl8152_apply_firmware()
5127 i += ALIGN(__le32_to_cpu(block->length), 8); in rtl8152_apply_firmware()
5131 if (rtl_fw->post_fw) in rtl8152_apply_firmware()
5132 rtl_fw->post_fw(tp); in rtl8152_apply_firmware()
5135 strscpy(rtl_fw->version, fw_hdr->version, RTL_VER_SIZE); in rtl8152_apply_firmware()
5136 dev_info(&tp->intf->dev, "load %s successfully\n", rtl_fw->version); in rtl8152_apply_firmware()
5141 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl8152_release_firmware()
5143 if (!IS_ERR_OR_NULL(rtl_fw->fw)) { in rtl8152_release_firmware()
5144 release_firmware(rtl_fw->fw); in rtl8152_release_firmware()
5145 rtl_fw->fw = NULL; in rtl8152_release_firmware()
5151 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl8152_request_firmware()
5154 if (rtl_fw->fw || !rtl_fw->fw_name) { in rtl8152_request_firmware()
5155 dev_info(&tp->intf->dev, "skip request firmware\n"); in rtl8152_request_firmware()
5160 rc = request_firmware(&rtl_fw->fw, rtl_fw->fw_name, &tp->intf->dev); in rtl8152_request_firmware()
5166 release_firmware(rtl_fw->fw); in rtl8152_request_firmware()
5170 rtl_fw->fw = ERR_PTR(rc); in rtl8152_request_firmware()
5172 dev_warn(&tp->intf->dev, in rtl8152_request_firmware()
5174 rtl_fw->fw_name, rc); in rtl8152_request_firmware()
5180 static void r8152_aldps_en(struct r8152 *tp, bool enable) in r8152_aldps_en() argument
5182 if (enable) { in r8152_aldps_en()
5217 static void r8152_eee_en(struct r8152 *tp, bool enable) in r8152_eee_en() argument
5227 if (enable) { in r8152_eee_en()
5248 static void r8153_eee_en(struct r8152 *tp, bool enable) in r8153_eee_en() argument
5256 if (enable) { in r8153_eee_en()
5267 tp->ups_info.eee = enable; in r8153_eee_en()
5270 static void r8156_eee_en(struct r8152 *tp, bool enable) in r8156_eee_en() argument
5274 r8153_eee_en(tp, enable); in r8156_eee_en()
5278 if (enable) in r8156_eee_en()
5286 static void rtl_eee_enable(struct r8152 *tp, bool enable) in rtl_eee_enable() argument
5288 switch (tp->version) { in rtl_eee_enable()
5292 if (enable) { in rtl_eee_enable()
5295 tp->eee_adv); in rtl_eee_enable()
5308 if (enable) { in rtl_eee_enable()
5310 ocp_reg_write(tp, OCP_EEE_ADV, tp->eee_adv); in rtl_eee_enable()
5321 if (enable) { in rtl_eee_enable()
5323 ocp_reg_write(tp, OCP_EEE_ADV, tp->eee_adv); in rtl_eee_enable()
5342 tp->ups_info.flow_control = true; in r8152b_enable_fc()
5355 rtl_eee_enable(tp, tp->eee_en); in r8152b_hw_phy_cfg()
5359 set_bit(PHY_RESET, &tp->flags); in r8152b_hw_phy_cfg()
5423 if (tp->udev->speed == USB_SPEED_FULL || in r8152b_exit_oob()
5424 tp->udev->speed == USB_SPEED_LOW) { in r8152b_exit_oob()
5446 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in r8152b_exit_oob()
5541 /* enable bp0 if support USB_SPEED_SUPER only */ in r8153_post_firmware_2()
5551 /* enable U3P3 check, set the counter to 4 */ in r8153_post_firmware_2()
5582 /* enable fc timer and set timer to 1 second. */ in r8153b_pre_firmware_1()
5593 /* enable bp0 for RTL8153-BND */ in r8153b_post_firmware_1()
5646 static void r8153_aldps_en(struct r8152 *tp, bool enable) in r8153_aldps_en() argument
5651 if (enable) { in r8153_aldps_en()
5666 tp->ups_info.aldps = enable; in r8153_aldps_en()
5674 /* disable ALDPS before updating the PHY parameters */ in r8153_hw_phy_cfg()
5682 if (tp->version == RTL_VER_03) { in r8153_hw_phy_cfg()
5704 /* Enable LPF corner auto tune */ in r8153_hw_phy_cfg()
5711 if (tp->eee_en) in r8153_hw_phy_cfg()
5717 switch (tp->version) { in r8153_hw_phy_cfg()
5728 set_bit(PHY_RESET, &tp->flags); in r8153_hw_phy_cfg()
5754 /* disable ALDPS before updating the PHY parameters */ in r8153b_hw_phy_cfg()
5780 r8153b_green_en(tp, test_bit(GREEN_ETHERNET, &tp->flags)); in r8153b_hw_phy_cfg()
5790 * read efuse offset 0x7d to get a 17-bit data. Remove the dummy/fake in r8153b_hw_phy_cfg()
5791 * bit (bit3) to rebuild the real 16-bit data. Write the data to the in r8153b_hw_phy_cfg()
5799 /* ups mode tx-link-pulse timing adjustment: in r8153b_hw_phy_cfg()
5823 tp->ups_info.eee_ckdiv = true; in r8153b_hw_phy_cfg()
5828 tp->ups_info.eee_cmod_lv = true; in r8153b_hw_phy_cfg()
5829 tp->ups_info._10m_ckdiv = true; in r8153b_hw_phy_cfg()
5830 tp->ups_info.eee_plloff_giga = true; in r8153b_hw_phy_cfg()
5834 tp->ups_info._250m_ckdiv = true; in r8153b_hw_phy_cfg()
5839 if (tp->eee_en) in r8153b_hw_phy_cfg()
5845 set_bit(PHY_RESET, &tp->flags); in r8153b_hw_phy_cfg()
5852 tp->ups_info.r_tune = true; in r8153c_hw_phy_cfg()
5857 ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, mtu_to_size(tp->netdev->mtu)); in rtl8153_change_mtu()
5891 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in r8153_first_init()
5936 switch (tp->version) { in r8153_enter_oob()
5994 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8156_enable()
5995 return -ENODEV; in rtl8156_enable()
6017 if (tp->udev->speed == USB_SPEED_HIGH) { in rtl8156_enable()
6036 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8156b_enable()
6037 return -ENODEV; in rtl8156b_enable()
6059 if (tp->udev->speed == USB_SPEED_HIGH) { in rtl8156b_enable()
6087 return -EINVAL; in rtl8152_set_speed()
6094 tp->ups_info.speed_duplex = FORCE_10M_FULL; in rtl8152_set_speed()
6096 tp->ups_info.speed_duplex = FORCE_10M_HALF; in rtl8152_set_speed()
6103 tp->ups_info.speed_duplex = FORCE_100M_FULL; in rtl8152_set_speed()
6105 tp->ups_info.speed_duplex = FORCE_100M_HALF; in rtl8152_set_speed()
6109 if (tp->mii.supports_gmii) { in rtl8152_set_speed()
6111 tp->ups_info.speed_duplex = NWAY_1000M_FULL; in rtl8152_set_speed()
6116 ret = -EINVAL; in rtl8152_set_speed()
6121 tp->mii.full_duplex = 1; in rtl8152_set_speed()
6123 tp->mii.full_duplex = 0; in rtl8152_set_speed()
6125 tp->mii.force_media = 1; in rtl8152_set_speed()
6133 if (tp->mii.supports_gmii) { in rtl8152_set_speed()
6136 if (tp->support_2500full) in rtl8152_set_speed()
6141 return -EINVAL; in rtl8152_set_speed()
6148 tp->ups_info.speed_duplex = NWAY_10M_HALF; in rtl8152_set_speed()
6152 tp->ups_info.speed_duplex = NWAY_10M_FULL; in rtl8152_set_speed()
6157 tp->ups_info.speed_duplex = NWAY_100M_HALF; in rtl8152_set_speed()
6161 tp->ups_info.speed_duplex = NWAY_100M_FULL; in rtl8152_set_speed()
6166 tp->mii.advertising = new1; in rtl8152_set_speed()
6169 if (tp->mii.supports_gmii) { in rtl8152_set_speed()
6176 tp->ups_info.speed_duplex = NWAY_1000M_FULL; in rtl8152_set_speed()
6183 if (tp->support_2500full) { in rtl8152_set_speed()
6189 tp->ups_info.speed_duplex = NWAY_2500M_FULL; in rtl8152_set_speed()
6198 tp->mii.force_media = 0; in rtl8152_set_speed()
6201 if (test_and_clear_bit(PHY_RESET, &tp->flags)) in rtl8152_set_speed()
6222 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8152_up()
6232 if (test_bit(RTL8152_UNPLUG, &tp->flags)) { in rtl8152_down()
6247 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8153_up()
6269 switch (tp->version) { in rtl8153_up()
6287 if (test_bit(RTL8152_UNPLUG, &tp->flags)) { in rtl8153_down()
6308 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8153b_up()
6324 if (tp->udev->speed >= USB_SPEED_SUPER) in rtl8153b_up()
6332 if (test_bit(RTL8152_UNPLUG, &tp->flags)) { in rtl8153b_down()
6351 ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, mtu_to_size(tp->netdev->mtu)); in rtl8153c_change_mtu()
6359 if (tp->netdev->mtu < 8000) in rtl8153c_change_mtu()
6369 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8153c_up()
6402 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in rtl8153c_up()
6434 return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 6 * 1024); in fc_pause_on_auto()
6439 return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 14 * 1024); in fc_pause_off_auto()
6444 u32 pause_on = tp->fc_pause_on ? tp->fc_pause_on : fc_pause_on_auto(tp); in r8156_fc_parameter()
6445 u32 pause_off = tp->fc_pause_off ? tp->fc_pause_off : fc_pause_off_auto(tp); in r8156_fc_parameter()
6453 u32 rx_max_size = mtu_to_size(tp->netdev->mtu); in rtl8156_change_mtu()
6469 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8156_up()
6494 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); in rtl8156_up()
6498 switch (tp->version) { in rtl8156_up()
6526 if (tp->saved_wolopts != __rtl_get_wol(tp)) { in rtl8156_up()
6527 netif_warn(tp, ifup, tp->netdev, "wol setting is changed\n"); in rtl8156_up()
6528 __rtl_set_wol(tp, tp->saved_wolopts); in rtl8156_up()
6534 if (tp->udev->speed >= USB_SPEED_SUPER) in rtl8156_up()
6542 if (test_bit(RTL8152_UNPLUG, &tp->flags)) { in rtl8156_down()
6600 tp->ocp_base = 0x2000; in rtl8152_in_nway()
6638 struct net_device *netdev = tp->netdev; in set_carrier()
6639 struct napi_struct *napi = &tp->napi; in set_carrier()
6646 tp->rtl_ops.enable(tp); in set_carrier()
6651 clear_bit(RTL8152_SET_RX_MODE, &tp->flags); in set_carrier()
6657 skb_queue_len(&tp->tx_queue) < tp->tx_qlen) { in set_carrier()
6663 tasklet_disable(&tp->tx_tl); in set_carrier()
6665 tp->rtl_ops.disable(tp); in set_carrier()
6667 tasklet_enable(&tp->tx_tl); in set_carrier()
6680 if (test_bit(RTL8152_UNPLUG, &tp->flags) || !netif_running(tp->netdev)) in rtl_work_func_t()
6683 if (usb_autopm_get_interface(tp->intf) < 0) in rtl_work_func_t()
6686 if (!test_bit(WORK_ENABLE, &tp->flags)) in rtl_work_func_t()
6689 if (!mutex_trylock(&tp->control)) { in rtl_work_func_t()
6690 schedule_delayed_work(&tp->schedule, 0); in rtl_work_func_t()
6694 if (test_and_clear_bit(RTL8152_LINK_CHG, &tp->flags)) in rtl_work_func_t()
6697 if (test_and_clear_bit(RTL8152_SET_RX_MODE, &tp->flags)) in rtl_work_func_t()
6698 _rtl8152_set_rx_mode(tp->netdev); in rtl_work_func_t()
6701 if (test_and_clear_bit(SCHEDULE_TASKLET, &tp->flags) && in rtl_work_func_t()
6702 netif_carrier_ok(tp->netdev)) in rtl_work_func_t()
6703 tasklet_schedule(&tp->tx_tl); in rtl_work_func_t()
6705 if (test_and_clear_bit(RX_EPROTO, &tp->flags) && in rtl_work_func_t()
6706 !list_empty(&tp->rx_done)) in rtl_work_func_t()
6707 napi_schedule(&tp->napi); in rtl_work_func_t()
6709 mutex_unlock(&tp->control); in rtl_work_func_t()
6712 usb_autopm_put_interface(tp->intf); in rtl_work_func_t()
6719 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl_hw_phy_work_func_t()
6722 if (usb_autopm_get_interface(tp->intf) < 0) in rtl_hw_phy_work_func_t()
6725 mutex_lock(&tp->control); in rtl_hw_phy_work_func_t()
6727 if (rtl8152_request_firmware(tp) == -ENODEV && tp->rtl_fw.retry) { in rtl_hw_phy_work_func_t()
6728 tp->rtl_fw.retry = false; in rtl_hw_phy_work_func_t()
6729 tp->rtl_fw.fw = NULL; in rtl_hw_phy_work_func_t()
6733 queue_delayed_work(system_long_wq, &tp->hw_phy_work, HZ * 10); in rtl_hw_phy_work_func_t()
6737 tp->rtl_ops.hw_phy_cfg(tp); in rtl_hw_phy_work_func_t()
6739 rtl8152_set_speed(tp, tp->autoneg, tp->speed, tp->duplex, in rtl_hw_phy_work_func_t()
6740 tp->advertising); in rtl_hw_phy_work_func_t()
6743 mutex_unlock(&tp->control); in rtl_hw_phy_work_func_t()
6745 usb_autopm_put_interface(tp->intf); in rtl_hw_phy_work_func_t()
6757 usb_autopm_get_interface(tp->intf); in rtl_notifier()
6762 usb_autopm_put_interface(tp->intf); in rtl_notifier()
6780 if (work_busy(&tp->hw_phy_work.work) & WORK_BUSY_PENDING) { in rtl8152_open()
6781 cancel_delayed_work_sync(&tp->hw_phy_work); in rtl8152_open()
6782 rtl_hw_phy_work_func_t(&tp->hw_phy_work.work); in rtl8152_open()
6789 res = usb_autopm_get_interface(tp->intf); in rtl8152_open()
6793 mutex_lock(&tp->control); in rtl8152_open()
6795 tp->rtl_ops.up(tp); in rtl8152_open()
6799 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_open()
6801 res = usb_submit_urb(tp->intr_urb, GFP_KERNEL); in rtl8152_open()
6803 if (res == -ENODEV) in rtl8152_open()
6804 netif_device_detach(tp->netdev); in rtl8152_open()
6809 napi_enable(&tp->napi); in rtl8152_open()
6810 tasklet_enable(&tp->tx_tl); in rtl8152_open()
6812 mutex_unlock(&tp->control); in rtl8152_open()
6814 usb_autopm_put_interface(tp->intf); in rtl8152_open()
6816 tp->pm_notifier.notifier_call = rtl_notifier; in rtl8152_open()
6817 register_pm_notifier(&tp->pm_notifier); in rtl8152_open()
6822 mutex_unlock(&tp->control); in rtl8152_open()
6823 usb_autopm_put_interface(tp->intf); in rtl8152_open()
6836 unregister_pm_notifier(&tp->pm_notifier); in rtl8152_close()
6838 tasklet_disable(&tp->tx_tl); in rtl8152_close()
6839 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_close()
6840 usb_kill_urb(tp->intr_urb); in rtl8152_close()
6841 cancel_delayed_work_sync(&tp->schedule); in rtl8152_close()
6842 napi_disable(&tp->napi); in rtl8152_close()
6845 res = usb_autopm_get_interface(tp->intf); in rtl8152_close()
6846 if (res < 0 || test_bit(RTL8152_UNPLUG, &tp->flags)) { in rtl8152_close()
6850 mutex_lock(&tp->control); in rtl8152_close()
6852 tp->rtl_ops.down(tp); in rtl8152_close()
6854 mutex_unlock(&tp->control); in rtl8152_close()
6858 usb_autopm_put_interface(tp->intf); in rtl8152_close()
6879 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8152b_init()
6890 if (tp->version == RTL_VER_01) { in r8152b_init()
6911 /* enable rx aggregation */ in r8152b_init()
6923 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8153_init()
6934 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8153_init()
6940 if (tp->version == RTL_VER_03 || tp->version == RTL_VER_04 || in r8153_init()
6941 tp->version == RTL_VER_05) in r8153_init()
6954 if (tp->version == RTL_VER_04) { in r8153_init()
6963 } else if (tp->version == RTL_VER_05) { in r8153_init()
6974 } else if (tp->version == RTL_VER_06) { in r8153_init()
7006 if (tp->version == RTL_VER_04 && tp->udev->speed < USB_SPEED_SUPER) in r8153_init()
7023 usb_enable_lpm(tp->udev); in r8153_init()
7036 if (tp->dell_tb_rx_agg_bug) in r8153_init()
7043 switch (tp->udev->speed) { in r8153_init()
7046 tp->coalesce = COALESCE_SUPER; in r8153_init()
7049 tp->coalesce = COALESCE_HIGH; in r8153_init()
7052 tp->coalesce = COALESCE_SLOW; in r8153_init()
7063 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8153b_init()
7074 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8153b_init()
7106 if (tp->udev->speed >= USB_SPEED_SUPER) in r8153b_init()
7109 usb_enable_lpm(tp->udev); in r8153b_init()
7118 if (tp->version == RTL_VER_09) { in r8153b_init()
7127 set_bit(GREEN_ETHERNET, &tp->flags); in r8153b_init()
7136 tp->coalesce = 15000; /* 15 us */ in r8153b_init()
7145 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8153c_init()
7165 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8153c_init()
7200 usb_enable_lpm(tp->udev); in r8153c_init()
7209 set_bit(GREEN_ETHERNET, &tp->flags); in r8153c_init()
7218 tp->coalesce = 15000; /* 15 us */ in r8153c_init()
7248 /* disable ALDPS before updating the PHY parameters */ in r8156_hw_phy_cfg()
7261 switch (tp->version) { in r8156_hw_phy_cfg()
7439 tp->ups_info._10m_ckdiv = true; in r8156_hw_phy_cfg()
7440 tp->ups_info.eee_plloff_100 = false; in r8156_hw_phy_cfg()
7441 tp->ups_info.eee_plloff_giga = false; in r8156_hw_phy_cfg()
7446 tp->ups_info.eee_ckdiv = false; in r8156_hw_phy_cfg()
7450 tp->ups_info._250m_ckdiv = false; in r8156_hw_phy_cfg()
7454 /* enable ADC Ibias Cal */ in r8156_hw_phy_cfg()
7459 /* enable Thermal Sensor */ in r8156_hw_phy_cfg()
7546 rtl_green_en(tp, test_bit(GREEN_ETHERNET, &tp->flags)); in r8156_hw_phy_cfg()
7554 tp->ups_info.lite_mode = 0; in r8156_hw_phy_cfg()
7556 if (tp->eee_en) in r8156_hw_phy_cfg()
7563 set_bit(PHY_RESET, &tp->flags); in r8156_hw_phy_cfg()
7571 switch (tp->version) { in r8156b_hw_phy_cfg()
7630 /* disable ALDPS before updating the PHY parameters */ in r8156b_hw_phy_cfg()
7643 switch (tp->version) { in r8156b_hw_phy_cfg()
7914 /* Green Table-PGA, 1G full viterbi */ in r8156b_hw_phy_cfg()
7947 tp->ups_info._10m_ckdiv = true; in r8156b_hw_phy_cfg()
7948 tp->ups_info.eee_plloff_100 = false; in r8156b_hw_phy_cfg()
7949 tp->ups_info.eee_plloff_giga = false; in r8156b_hw_phy_cfg()
7954 tp->ups_info.eee_ckdiv = false; in r8156b_hw_phy_cfg()
7958 rtl_green_en(tp, test_bit(GREEN_ETHERNET, &tp->flags)); in r8156b_hw_phy_cfg()
7966 tp->ups_info.lite_mode = 0; in r8156b_hw_phy_cfg()
7968 if (tp->eee_en) in r8156b_hw_phy_cfg()
7975 set_bit(PHY_RESET, &tp->flags); in r8156b_hw_phy_cfg()
7984 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8156_init()
8005 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8156_init()
8038 if (tp->udev->speed >= USB_SPEED_SUPER) in r8156_init()
8041 usb_enable_lpm(tp->udev); in r8156_init()
8057 set_bit(GREEN_ETHERNET, &tp->flags); in r8156_init()
8071 tp->coalesce = 15000; /* 15 us */ in r8156_init()
8080 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8156b_init()
8099 switch (tp->version) { in r8156b_init()
8114 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in r8156b_init()
8150 if (tp->udev->speed >= USB_SPEED_SUPER) in r8156b_init()
8153 usb_enable_lpm(tp->udev); in r8156b_init()
8163 /* enable fc timer and set timer to 600 ms. */ in r8156b_init()
8191 set_bit(GREEN_ETHERNET, &tp->flags); in r8156b_init()
8201 tp->coalesce = 15000; /* 15 us */ in r8156b_init()
8206 struct usb_host_interface *alt = intf->cur_altsetting; in rtl_check_vendor_ok()
8210 dev_err(&intf->dev, "Expected endpoints are not found\n"); in rtl_check_vendor_ok()
8216 dev_err(&intf->dev, "Invalid Rx endpoint address\n"); in rtl_check_vendor_ok()
8222 dev_err(&intf->dev, "Invalid Tx endpoint address\n"); in rtl_check_vendor_ok()
8228 dev_err(&intf->dev, "Invalid interrupt endpoint address\n"); in rtl_check_vendor_ok()
8237 struct usb_host_interface *alt = intf->cur_altsetting; in rtl_vendor_mode()
8242 if (alt->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) in rtl_vendor_mode()
8247 c = udev->config; in rtl_vendor_mode()
8248 num_configs = udev->descriptor.bNumConfigurations; in rtl_vendor_mode()
8255 if (c->desc.bNumInterfaces > 0) in rtl_vendor_mode()
8256 desc = &c->intf_cache[0]->altsetting->desc; in rtl_vendor_mode()
8260 if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC) { in rtl_vendor_mode()
8261 usb_driver_set_configuration(udev, c->desc.bConfigurationValue); in rtl_vendor_mode()
8267 dev_err(&intf->dev, "Unexpected Device\n"); in rtl_vendor_mode()
8280 netdev = tp->netdev; in rtl8152_pre_reset()
8285 tasklet_disable(&tp->tx_tl); in rtl8152_pre_reset()
8286 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_pre_reset()
8287 usb_kill_urb(tp->intr_urb); in rtl8152_pre_reset()
8288 cancel_delayed_work_sync(&tp->schedule); in rtl8152_pre_reset()
8289 napi_disable(&tp->napi); in rtl8152_pre_reset()
8291 mutex_lock(&tp->control); in rtl8152_pre_reset()
8292 tp->rtl_ops.disable(tp); in rtl8152_pre_reset()
8293 mutex_unlock(&tp->control); in rtl8152_pre_reset()
8311 dev_set_mac_address (tp->netdev, &sa, NULL); in rtl8152_post_reset()
8315 netdev = tp->netdev; in rtl8152_post_reset()
8319 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_post_reset()
8321 mutex_lock(&tp->control); in rtl8152_post_reset()
8322 tp->rtl_ops.enable(tp); in rtl8152_post_reset()
8325 mutex_unlock(&tp->control); in rtl8152_post_reset()
8328 napi_enable(&tp->napi); in rtl8152_post_reset()
8329 tasklet_enable(&tp->tx_tl); in rtl8152_post_reset()
8331 usb_submit_urb(tp->intr_urb, GFP_KERNEL); in rtl8152_post_reset()
8333 if (!list_empty(&tp->rx_done)) in rtl8152_post_reset()
8334 napi_schedule(&tp->napi); in rtl8152_post_reset()
8341 bool sw_linking = !!netif_carrier_ok(tp->netdev); in delay_autosuspend()
8348 if (work_busy(&tp->schedule.work) || sw_linking != hw_linking) in delay_autosuspend()
8354 if (!sw_linking && tp->rtl_ops.in_nway(tp)) in delay_autosuspend()
8356 else if (!skb_queue_empty(&tp->tx_queue)) in delay_autosuspend()
8364 struct net_device *netdev = tp->netdev; in rtl8152_runtime_resume()
8366 if (netif_running(netdev) && netdev->flags & IFF_UP) { in rtl8152_runtime_resume()
8367 struct napi_struct *napi = &tp->napi; in rtl8152_runtime_resume()
8369 tp->rtl_ops.autosuspend_en(tp, false); in rtl8152_runtime_resume()
8371 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_runtime_resume()
8378 tp->rtl_ops.disable(tp); in rtl8152_runtime_resume()
8384 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_resume()
8387 if (!list_empty(&tp->rx_done)) in rtl8152_runtime_resume()
8388 napi_schedule(&tp->napi); in rtl8152_runtime_resume()
8390 usb_submit_urb(tp->intr_urb, GFP_NOIO); in rtl8152_runtime_resume()
8392 if (netdev->flags & IFF_UP) in rtl8152_runtime_resume()
8393 tp->rtl_ops.autosuspend_en(tp, false); in rtl8152_runtime_resume()
8395 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_resume()
8403 struct net_device *netdev = tp->netdev; in rtl8152_system_resume()
8407 if (netif_running(netdev) && (netdev->flags & IFF_UP)) { in rtl8152_system_resume()
8408 tp->rtl_ops.up(tp); in rtl8152_system_resume()
8410 set_bit(WORK_ENABLE, &tp->flags); in rtl8152_system_resume()
8411 usb_submit_urb(tp->intr_urb, GFP_NOIO); in rtl8152_system_resume()
8419 struct net_device *netdev = tp->netdev; in rtl8152_runtime_suspend()
8422 if (!tp->rtl_ops.autosuspend_en) in rtl8152_runtime_suspend()
8423 return -EBUSY; in rtl8152_runtime_suspend()
8425 set_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_suspend()
8428 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { in rtl8152_runtime_suspend()
8443 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_runtime_suspend()
8445 ret = -EBUSY; in rtl8152_runtime_suspend()
8450 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_runtime_suspend()
8451 usb_kill_urb(tp->intr_urb); in rtl8152_runtime_suspend()
8453 tp->rtl_ops.autosuspend_en(tp, true); in rtl8152_runtime_suspend()
8456 struct napi_struct *napi = &tp->napi; in rtl8152_runtime_suspend()
8467 ret = -EBUSY; in rtl8152_runtime_suspend()
8477 struct net_device *netdev = tp->netdev; in rtl8152_system_suspend()
8481 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { in rtl8152_system_suspend()
8482 struct napi_struct *napi = &tp->napi; in rtl8152_system_suspend()
8484 clear_bit(WORK_ENABLE, &tp->flags); in rtl8152_system_suspend()
8485 usb_kill_urb(tp->intr_urb); in rtl8152_system_suspend()
8486 tasklet_disable(&tp->tx_tl); in rtl8152_system_suspend()
8488 cancel_delayed_work_sync(&tp->schedule); in rtl8152_system_suspend()
8489 tp->rtl_ops.down(tp); in rtl8152_system_suspend()
8491 tasklet_enable(&tp->tx_tl); in rtl8152_system_suspend()
8502 mutex_lock(&tp->control); in rtl8152_suspend()
8509 mutex_unlock(&tp->control); in rtl8152_suspend()
8519 mutex_lock(&tp->control); in rtl8152_resume()
8523 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) in rtl8152_resume()
8528 mutex_unlock(&tp->control); in rtl8152_resume()
8537 clear_bit(SELECTIVE_SUSPEND, &tp->flags); in rtl8152_reset_resume()
8539 tp->rtl_ops.init(tp); in rtl8152_reset_resume()
8540 queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0); in rtl8152_reset_resume()
8549 if (usb_autopm_get_interface(tp->intf) < 0) in rtl8152_get_wol()
8553 wol->supported = 0; in rtl8152_get_wol()
8554 wol->wolopts = 0; in rtl8152_get_wol()
8556 mutex_lock(&tp->control); in rtl8152_get_wol()
8557 wol->supported = WAKE_ANY; in rtl8152_get_wol()
8558 wol->wolopts = __rtl_get_wol(tp); in rtl8152_get_wol()
8559 mutex_unlock(&tp->control); in rtl8152_get_wol()
8562 usb_autopm_put_interface(tp->intf); in rtl8152_get_wol()
8571 return -EOPNOTSUPP; in rtl8152_set_wol()
8573 if (wol->wolopts & ~WAKE_ANY) in rtl8152_set_wol()
8574 return -EINVAL; in rtl8152_set_wol()
8576 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_wol()
8580 mutex_lock(&tp->control); in rtl8152_set_wol()
8582 __rtl_set_wol(tp, wol->wolopts); in rtl8152_set_wol()
8583 tp->saved_wolopts = wol->wolopts & WAKE_ANY; in rtl8152_set_wol()
8585 mutex_unlock(&tp->control); in rtl8152_set_wol()
8587 usb_autopm_put_interface(tp->intf); in rtl8152_set_wol()
8597 return tp->msg_enable; in rtl8152_get_msglevel()
8604 tp->msg_enable = value; in rtl8152_set_msglevel()
8612 strscpy(info->driver, MODULENAME, sizeof(info->driver)); in rtl8152_get_drvinfo()
8613 strscpy(info->version, DRIVER_VERSION, sizeof(info->version)); in rtl8152_get_drvinfo()
8614 usb_make_path(tp->udev, info->bus_info, sizeof(info->bus_info)); in rtl8152_get_drvinfo()
8615 if (!IS_ERR_OR_NULL(tp->rtl_fw.fw)) in rtl8152_get_drvinfo()
8616 strscpy(info->fw_version, tp->rtl_fw.version, in rtl8152_get_drvinfo()
8617 sizeof(info->fw_version)); in rtl8152_get_drvinfo()
8627 if (!tp->mii.mdio_read) in rtl8152_get_link_ksettings()
8628 return -EOPNOTSUPP; in rtl8152_get_link_ksettings()
8630 ret = usb_autopm_get_interface(tp->intf); in rtl8152_get_link_ksettings()
8634 mutex_lock(&tp->control); in rtl8152_get_link_ksettings()
8636 mii_ethtool_get_link_ksettings(&tp->mii, cmd); in rtl8152_get_link_ksettings()
8639 cmd->link_modes.supported, tp->support_2500full); in rtl8152_get_link_ksettings()
8641 if (tp->support_2500full) { in rtl8152_get_link_ksettings()
8643 cmd->link_modes.advertising, in rtl8152_get_link_ksettings()
8647 cmd->link_modes.lp_advertising, in rtl8152_get_link_ksettings()
8651 cmd->base.speed = SPEED_2500; in rtl8152_get_link_ksettings()
8654 mutex_unlock(&tp->control); in rtl8152_get_link_ksettings()
8656 usb_autopm_put_interface(tp->intf); in rtl8152_get_link_ksettings()
8669 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_link_ksettings()
8674 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8678 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8682 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8686 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8690 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8694 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8698 cmd->link_modes.advertising)) in rtl8152_set_link_ksettings()
8701 mutex_lock(&tp->control); in rtl8152_set_link_ksettings()
8703 ret = rtl8152_set_speed(tp, cmd->base.autoneg, cmd->base.speed, in rtl8152_set_link_ksettings()
8704 cmd->base.duplex, advertising); in rtl8152_set_link_ksettings()
8706 tp->autoneg = cmd->base.autoneg; in rtl8152_set_link_ksettings()
8707 tp->speed = cmd->base.speed; in rtl8152_set_link_ksettings()
8708 tp->duplex = cmd->base.duplex; in rtl8152_set_link_ksettings()
8709 tp->advertising = advertising; in rtl8152_set_link_ksettings()
8712 mutex_unlock(&tp->control); in rtl8152_set_link_ksettings()
8714 usb_autopm_put_interface(tp->intf); in rtl8152_set_link_ksettings()
8742 return -EOPNOTSUPP; in rtl8152_get_sset_count()
8752 if (usb_autopm_get_interface(tp->intf) < 0) in rtl8152_get_ethtool_stats()
8757 usb_autopm_put_interface(tp->intf); in rtl8152_get_ethtool_stats()
8797 eee->eee_enabled = tp->eee_en; in r8152_get_eee()
8798 eee->eee_active = !!(supported & adv & lp); in r8152_get_eee()
8799 eee->supported = supported; in r8152_get_eee()
8800 eee->advertised = tp->eee_adv; in r8152_get_eee()
8801 eee->lp_advertised = lp; in r8152_get_eee()
8808 u16 val = ethtool_adv_to_mmd_eee_adv_t(eee->advertised); in r8152_set_eee()
8810 tp->eee_en = eee->eee_enabled; in r8152_set_eee()
8811 tp->eee_adv = val; in r8152_set_eee()
8813 rtl_eee_enable(tp, tp->eee_en); in r8152_set_eee()
8832 eee->eee_enabled = tp->eee_en; in r8153_get_eee()
8833 eee->eee_active = !!(supported & adv & lp); in r8153_get_eee()
8834 eee->supported = supported; in r8153_get_eee()
8835 eee->advertised = tp->eee_adv; in r8153_get_eee()
8836 eee->lp_advertised = lp; in r8153_get_eee()
8847 if (!tp->rtl_ops.eee_get) { in rtl_ethtool_get_eee()
8848 ret = -EOPNOTSUPP; in rtl_ethtool_get_eee()
8852 ret = usb_autopm_get_interface(tp->intf); in rtl_ethtool_get_eee()
8856 mutex_lock(&tp->control); in rtl_ethtool_get_eee()
8858 ret = tp->rtl_ops.eee_get(tp, edata); in rtl_ethtool_get_eee()
8860 mutex_unlock(&tp->control); in rtl_ethtool_get_eee()
8862 usb_autopm_put_interface(tp->intf); in rtl_ethtool_get_eee()
8874 if (!tp->rtl_ops.eee_set) { in rtl_ethtool_set_eee()
8875 ret = -EOPNOTSUPP; in rtl_ethtool_set_eee()
8879 ret = usb_autopm_get_interface(tp->intf); in rtl_ethtool_set_eee()
8883 mutex_lock(&tp->control); in rtl_ethtool_set_eee()
8885 ret = tp->rtl_ops.eee_set(tp, edata); in rtl_ethtool_set_eee()
8887 ret = mii_nway_restart(&tp->mii); in rtl_ethtool_set_eee()
8889 mutex_unlock(&tp->control); in rtl_ethtool_set_eee()
8891 usb_autopm_put_interface(tp->intf); in rtl_ethtool_set_eee()
8902 ret = usb_autopm_get_interface(tp->intf); in rtl8152_nway_reset()
8906 mutex_lock(&tp->control); in rtl8152_nway_reset()
8908 ret = mii_nway_restart(&tp->mii); in rtl8152_nway_reset()
8910 mutex_unlock(&tp->control); in rtl8152_nway_reset()
8912 usb_autopm_put_interface(tp->intf); in rtl8152_nway_reset()
8925 switch (tp->version) { in rtl8152_get_coalesce()
8929 return -EOPNOTSUPP; in rtl8152_get_coalesce()
8934 coalesce->rx_coalesce_usecs = tp->coalesce; in rtl8152_get_coalesce()
8947 switch (tp->version) { in rtl8152_set_coalesce()
8951 return -EOPNOTSUPP; in rtl8152_set_coalesce()
8956 if (coalesce->rx_coalesce_usecs > COALESCE_SLOW) in rtl8152_set_coalesce()
8957 return -EINVAL; in rtl8152_set_coalesce()
8959 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_coalesce()
8963 mutex_lock(&tp->control); in rtl8152_set_coalesce()
8965 if (tp->coalesce != coalesce->rx_coalesce_usecs) { in rtl8152_set_coalesce()
8966 tp->coalesce = coalesce->rx_coalesce_usecs; in rtl8152_set_coalesce()
8970 napi_disable(&tp->napi); in rtl8152_set_coalesce()
8971 tp->rtl_ops.disable(tp); in rtl8152_set_coalesce()
8972 tp->rtl_ops.enable(tp); in rtl8152_set_coalesce()
8974 clear_bit(RTL8152_SET_RX_MODE, &tp->flags); in rtl8152_set_coalesce()
8976 napi_enable(&tp->napi); in rtl8152_set_coalesce()
8981 mutex_unlock(&tp->control); in rtl8152_set_coalesce()
8983 usb_autopm_put_interface(tp->intf); in rtl8152_set_coalesce()
8993 switch (tunable->id) { in rtl8152_get_tunable()
8995 *(u32 *)d = tp->rx_copybreak; in rtl8152_get_tunable()
8998 return -EOPNOTSUPP; in rtl8152_get_tunable()
9011 switch (tunable->id) { in rtl8152_set_tunable()
9017 return -EINVAL; in rtl8152_set_tunable()
9020 if (tp->rx_copybreak != val) { in rtl8152_set_tunable()
9021 if (netdev->flags & IFF_UP) { in rtl8152_set_tunable()
9022 mutex_lock(&tp->control); in rtl8152_set_tunable()
9023 napi_disable(&tp->napi); in rtl8152_set_tunable()
9024 tp->rx_copybreak = val; in rtl8152_set_tunable()
9025 napi_enable(&tp->napi); in rtl8152_set_tunable()
9026 mutex_unlock(&tp->control); in rtl8152_set_tunable()
9028 tp->rx_copybreak = val; in rtl8152_set_tunable()
9033 return -EOPNOTSUPP; in rtl8152_set_tunable()
9046 ring->rx_max_pending = RTL8152_RX_MAX_PENDING; in rtl8152_get_ringparam()
9047 ring->rx_pending = tp->rx_pending; in rtl8152_get_ringparam()
9057 if (ring->rx_pending < (RTL8152_MAX_RX * 2)) in rtl8152_set_ringparam()
9058 return -EINVAL; in rtl8152_set_ringparam()
9060 if (tp->rx_pending != ring->rx_pending) { in rtl8152_set_ringparam()
9061 if (netdev->flags & IFF_UP) { in rtl8152_set_ringparam()
9062 mutex_lock(&tp->control); in rtl8152_set_ringparam()
9063 napi_disable(&tp->napi); in rtl8152_set_ringparam()
9064 tp->rx_pending = ring->rx_pending; in rtl8152_set_ringparam()
9065 napi_enable(&tp->napi); in rtl8152_set_ringparam()
9066 mutex_unlock(&tp->control); in rtl8152_set_ringparam()
9068 tp->rx_pending = ring->rx_pending; in rtl8152_set_ringparam()
9081 if (usb_autopm_get_interface(tp->intf) < 0) in rtl8152_get_pauseparam()
9084 mutex_lock(&tp->control); in rtl8152_get_pauseparam()
9090 mutex_unlock(&tp->control); in rtl8152_get_pauseparam()
9092 usb_autopm_put_interface(tp->intf); in rtl8152_get_pauseparam()
9095 pause->autoneg = 0; in rtl8152_get_pauseparam()
9096 pause->rx_pause = 0; in rtl8152_get_pauseparam()
9097 pause->tx_pause = 0; in rtl8152_get_pauseparam()
9101 pause->autoneg = 1; in rtl8152_get_pauseparam()
9106 pause->rx_pause = 1; in rtl8152_get_pauseparam()
9109 pause->tx_pause = 1; in rtl8152_get_pauseparam()
9119 ret = usb_autopm_get_interface(tp->intf); in rtl8152_set_pauseparam()
9123 mutex_lock(&tp->control); in rtl8152_set_pauseparam()
9125 if (pause->autoneg && !(r8152_mdio_read(tp, MII_BMCR) & BMCR_ANENABLE)) { in rtl8152_set_pauseparam()
9126 ret = -EINVAL; in rtl8152_set_pauseparam()
9130 if (pause->rx_pause) in rtl8152_set_pauseparam()
9133 if (pause->tx_pause) in rtl8152_set_pauseparam()
9142 mutex_unlock(&tp->control); in rtl8152_set_pauseparam()
9143 usb_autopm_put_interface(tp->intf); in rtl8152_set_pauseparam()
9180 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8152_ioctl()
9181 return -ENODEV; in rtl8152_ioctl()
9183 res = usb_autopm_get_interface(tp->intf); in rtl8152_ioctl()
9189 data->phy_id = R8152_PHY_ID; /* Internal PHY */ in rtl8152_ioctl()
9193 mutex_lock(&tp->control); in rtl8152_ioctl()
9194 data->val_out = r8152_mdio_read(tp, data->reg_num); in rtl8152_ioctl()
9195 mutex_unlock(&tp->control); in rtl8152_ioctl()
9200 res = -EPERM; in rtl8152_ioctl()
9203 mutex_lock(&tp->control); in rtl8152_ioctl()
9204 r8152_mdio_write(tp, data->reg_num, data->val_in); in rtl8152_ioctl()
9205 mutex_unlock(&tp->control); in rtl8152_ioctl()
9209 res = -EOPNOTSUPP; in rtl8152_ioctl()
9212 usb_autopm_put_interface(tp->intf); in rtl8152_ioctl()
9223 switch (tp->version) { in rtl8152_change_mtu()
9227 dev->mtu = new_mtu; in rtl8152_change_mtu()
9233 ret = usb_autopm_get_interface(tp->intf); in rtl8152_change_mtu()
9237 mutex_lock(&tp->control); in rtl8152_change_mtu()
9239 dev->mtu = new_mtu; in rtl8152_change_mtu()
9242 if (tp->rtl_ops.change_mtu) in rtl8152_change_mtu()
9243 tp->rtl_ops.change_mtu(tp); in rtl8152_change_mtu()
9247 napi_disable(&tp->napi); in rtl8152_change_mtu()
9248 tasklet_disable(&tp->tx_tl); in rtl8152_change_mtu()
9249 tp->rtl_ops.disable(tp); in rtl8152_change_mtu()
9250 tp->rtl_ops.enable(tp); in rtl8152_change_mtu()
9252 tasklet_enable(&tp->tx_tl); in rtl8152_change_mtu()
9253 napi_enable(&tp->napi); in rtl8152_change_mtu()
9259 mutex_unlock(&tp->control); in rtl8152_change_mtu()
9261 usb_autopm_put_interface(tp->intf); in rtl8152_change_mtu()
9282 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8152_unload()
9285 if (tp->version != RTL_VER_01) in rtl8152_unload()
9291 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8153_unload()
9299 if (test_bit(RTL8152_UNPLUG, &tp->flags)) in rtl8153b_unload()
9307 struct rtl_ops *ops = &tp->rtl_ops; in rtl_ops_init()
9310 switch (tp->version) { in rtl_ops_init()
9314 ops->init = r8152b_init; in rtl_ops_init()
9315 ops->enable = rtl8152_enable; in rtl_ops_init()
9316 ops->disable = rtl8152_disable; in rtl_ops_init()
9317 ops->up = rtl8152_up; in rtl_ops_init()
9318 ops->down = rtl8152_down; in rtl_ops_init()
9319 ops->unload = rtl8152_unload; in rtl_ops_init()
9320 ops->eee_get = r8152_get_eee; in rtl_ops_init()
9321 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9322 ops->in_nway = rtl8152_in_nway; in rtl_ops_init()
9323 ops->hw_phy_cfg = r8152b_hw_phy_cfg; in rtl_ops_init()
9324 ops->autosuspend_en = rtl_runtime_suspend_enable; in rtl_ops_init()
9325 tp->rx_buf_sz = 16 * 1024; in rtl_ops_init()
9326 tp->eee_en = true; in rtl_ops_init()
9327 tp->eee_adv = MDIO_EEE_100TX; in rtl_ops_init()
9334 ops->init = r8153_init; in rtl_ops_init()
9335 ops->enable = rtl8153_enable; in rtl_ops_init()
9336 ops->disable = rtl8153_disable; in rtl_ops_init()
9337 ops->up = rtl8153_up; in rtl_ops_init()
9338 ops->down = rtl8153_down; in rtl_ops_init()
9339 ops->unload = rtl8153_unload; in rtl_ops_init()
9340 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9341 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9342 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9343 ops->hw_phy_cfg = r8153_hw_phy_cfg; in rtl_ops_init()
9344 ops->autosuspend_en = rtl8153_runtime_enable; in rtl_ops_init()
9345 ops->change_mtu = rtl8153_change_mtu; in rtl_ops_init()
9346 if (tp->udev->speed < USB_SPEED_SUPER) in rtl_ops_init()
9347 tp->rx_buf_sz = 16 * 1024; in rtl_ops_init()
9349 tp->rx_buf_sz = 32 * 1024; in rtl_ops_init()
9350 tp->eee_en = true; in rtl_ops_init()
9351 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9356 ops->init = r8153b_init; in rtl_ops_init()
9357 ops->enable = rtl8153_enable; in rtl_ops_init()
9358 ops->disable = rtl8153_disable; in rtl_ops_init()
9359 ops->up = rtl8153b_up; in rtl_ops_init()
9360 ops->down = rtl8153b_down; in rtl_ops_init()
9361 ops->unload = rtl8153b_unload; in rtl_ops_init()
9362 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9363 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9364 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9365 ops->hw_phy_cfg = r8153b_hw_phy_cfg; in rtl_ops_init()
9366 ops->autosuspend_en = rtl8153b_runtime_enable; in rtl_ops_init()
9367 ops->change_mtu = rtl8153_change_mtu; in rtl_ops_init()
9368 tp->rx_buf_sz = 32 * 1024; in rtl_ops_init()
9369 tp->eee_en = true; in rtl_ops_init()
9370 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9374 tp->eee_en = true; in rtl_ops_init()
9375 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9378 ops->init = r8156_init; in rtl_ops_init()
9379 ops->enable = rtl8156_enable; in rtl_ops_init()
9380 ops->disable = rtl8153_disable; in rtl_ops_init()
9381 ops->up = rtl8156_up; in rtl_ops_init()
9382 ops->down = rtl8156_down; in rtl_ops_init()
9383 ops->unload = rtl8153_unload; in rtl_ops_init()
9384 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9385 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9386 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9387 ops->hw_phy_cfg = r8156_hw_phy_cfg; in rtl_ops_init()
9388 ops->autosuspend_en = rtl8156_runtime_enable; in rtl_ops_init()
9389 ops->change_mtu = rtl8156_change_mtu; in rtl_ops_init()
9390 tp->rx_buf_sz = 48 * 1024; in rtl_ops_init()
9391 tp->support_2500full = 1; in rtl_ops_init()
9396 tp->support_2500full = 1; in rtl_ops_init()
9399 tp->eee_en = true; in rtl_ops_init()
9400 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9401 ops->init = r8156b_init; in rtl_ops_init()
9402 ops->enable = rtl8156b_enable; in rtl_ops_init()
9403 ops->disable = rtl8153_disable; in rtl_ops_init()
9404 ops->up = rtl8156_up; in rtl_ops_init()
9405 ops->down = rtl8156_down; in rtl_ops_init()
9406 ops->unload = rtl8153_unload; in rtl_ops_init()
9407 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9408 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9409 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9410 ops->hw_phy_cfg = r8156b_hw_phy_cfg; in rtl_ops_init()
9411 ops->autosuspend_en = rtl8156_runtime_enable; in rtl_ops_init()
9412 ops->change_mtu = rtl8156_change_mtu; in rtl_ops_init()
9413 tp->rx_buf_sz = 48 * 1024; in rtl_ops_init()
9417 ops->init = r8153c_init; in rtl_ops_init()
9418 ops->enable = rtl8153_enable; in rtl_ops_init()
9419 ops->disable = rtl8153_disable; in rtl_ops_init()
9420 ops->up = rtl8153c_up; in rtl_ops_init()
9421 ops->down = rtl8153b_down; in rtl_ops_init()
9422 ops->unload = rtl8153_unload; in rtl_ops_init()
9423 ops->eee_get = r8153_get_eee; in rtl_ops_init()
9424 ops->eee_set = r8152_set_eee; in rtl_ops_init()
9425 ops->in_nway = rtl8153_in_nway; in rtl_ops_init()
9426 ops->hw_phy_cfg = r8153c_hw_phy_cfg; in rtl_ops_init()
9427 ops->autosuspend_en = rtl8153c_runtime_enable; in rtl_ops_init()
9428 ops->change_mtu = rtl8153c_change_mtu; in rtl_ops_init()
9429 tp->rx_buf_sz = 32 * 1024; in rtl_ops_init()
9430 tp->eee_en = true; in rtl_ops_init()
9431 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; in rtl_ops_init()
9435 ret = -ENODEV; in rtl_ops_init()
9436 dev_err(&tp->intf->dev, "Unknown Device\n"); in rtl_ops_init()
9443 #define FIRMWARE_8153A_2 "rtl_nic/rtl8153a-2.fw"
9444 #define FIRMWARE_8153A_3 "rtl_nic/rtl8153a-3.fw"
9445 #define FIRMWARE_8153A_4 "rtl_nic/rtl8153a-4.fw"
9446 #define FIRMWARE_8153B_2 "rtl_nic/rtl8153b-2.fw"
9447 #define FIRMWARE_8153C_1 "rtl_nic/rtl8153c-1.fw"
9448 #define FIRMWARE_8156A_2 "rtl_nic/rtl8156a-2.fw"
9449 #define FIRMWARE_8156B_2 "rtl_nic/rtl8156b-2.fw"
9461 struct rtl_fw *rtl_fw = &tp->rtl_fw; in rtl_fw_init()
9463 switch (tp->version) { in rtl_fw_init()
9465 rtl_fw->fw_name = FIRMWARE_8153A_2; in rtl_fw_init()
9466 rtl_fw->pre_fw = r8153_pre_firmware_1; in rtl_fw_init()
9467 rtl_fw->post_fw = r8153_post_firmware_1; in rtl_fw_init()
9470 rtl_fw->fw_name = FIRMWARE_8153A_3; in rtl_fw_init()
9471 rtl_fw->pre_fw = r8153_pre_firmware_2; in rtl_fw_init()
9472 rtl_fw->post_fw = r8153_post_firmware_2; in rtl_fw_init()
9475 rtl_fw->fw_name = FIRMWARE_8153A_4; in rtl_fw_init()
9476 rtl_fw->post_fw = r8153_post_firmware_3; in rtl_fw_init()
9479 rtl_fw->fw_name = FIRMWARE_8153B_2; in rtl_fw_init()
9480 rtl_fw->pre_fw = r8153b_pre_firmware_1; in rtl_fw_init()
9481 rtl_fw->post_fw = r8153b_post_firmware_1; in rtl_fw_init()
9484 rtl_fw->fw_name = FIRMWARE_8156A_2; in rtl_fw_init()
9485 rtl_fw->post_fw = r8156a_post_firmware_1; in rtl_fw_init()
9489 rtl_fw->fw_name = FIRMWARE_8156B_2; in rtl_fw_init()
9492 rtl_fw->fw_name = FIRMWARE_8153C_1; in rtl_fw_init()
9493 rtl_fw->pre_fw = r8153b_pre_firmware_1; in rtl_fw_init()
9494 rtl_fw->post_fw = r8153c_post_firmware_1; in rtl_fw_init()
9574 dev_info(&intf->dev, "Unknown version 0x%04x\n", ocp_data); in rtl8152_get_version()
9578 dev_dbg(&intf->dev, "Detected version 0x%04x\n", version); in rtl8152_get_version()
9586 int parent_vendor_id = le16_to_cpu(udev->parent->descriptor.idVendor); in rtl8152_supports_lenovo_macpassthru()
9587 int product_id = le16_to_cpu(udev->descriptor.idProduct); in rtl8152_supports_lenovo_macpassthru()
9588 int vendor_id = le16_to_cpu(udev->descriptor.idVendor); in rtl8152_supports_lenovo_macpassthru()
9619 return -ENODEV; in rtl8152_probe()
9622 return -ENODEV; in rtl8152_probe()
9627 dev_err(&intf->dev, "Out of memory\n"); in rtl8152_probe()
9628 return -ENOMEM; in rtl8152_probe()
9631 SET_NETDEV_DEV(netdev, &intf->dev); in rtl8152_probe()
9633 tp->msg_enable = 0x7FFF; in rtl8152_probe()
9635 tp->udev = udev; in rtl8152_probe()
9636 tp->netdev = netdev; in rtl8152_probe()
9637 tp->intf = intf; in rtl8152_probe()
9638 tp->version = version; in rtl8152_probe()
9640 tp->pipe_ctrl_in = usb_rcvctrlpipe(udev, 0); in rtl8152_probe()
9641 tp->pipe_ctrl_out = usb_sndctrlpipe(udev, 0); in rtl8152_probe()
9642 tp->pipe_in = usb_rcvbulkpipe(udev, 1); in rtl8152_probe()
9643 tp->pipe_out = usb_sndbulkpipe(udev, 2); in rtl8152_probe()
9644 tp->pipe_intr = usb_rcvintpipe(udev, 3); in rtl8152_probe()
9650 tp->mii.supports_gmii = 0; in rtl8152_probe()
9653 tp->mii.supports_gmii = 1; in rtl8152_probe()
9663 mutex_init(&tp->control); in rtl8152_probe()
9664 INIT_DELAYED_WORK(&tp->schedule, rtl_work_func_t); in rtl8152_probe()
9665 INIT_DELAYED_WORK(&tp->hw_phy_work, rtl_hw_phy_work_func_t); in rtl8152_probe()
9666 tasklet_setup(&tp->tx_tl, bottom_half); in rtl8152_probe()
9667 tasklet_disable(&tp->tx_tl); in rtl8152_probe()
9669 netdev->netdev_ops = &rtl8152_netdev_ops; in rtl8152_probe()
9670 netdev->watchdog_timeo = RTL8152_TX_TIMEOUT; in rtl8152_probe()
9672 netdev->features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG | in rtl8152_probe()
9676 netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG | in rtl8152_probe()
9680 netdev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | in rtl8152_probe()
9684 if (tp->version == RTL_VER_01) { in rtl8152_probe()
9685 netdev->features &= ~NETIF_F_RXCSUM; in rtl8152_probe()
9686 netdev->hw_features &= ~NETIF_F_RXCSUM; in rtl8152_probe()
9689 tp->lenovo_macpassthru = rtl8152_supports_lenovo_macpassthru(udev); in rtl8152_probe()
9691 if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial && in rtl8152_probe()
9692 (!strcmp(udev->serial, "000001000000") || in rtl8152_probe()
9693 !strcmp(udev->serial, "000002000000"))) { in rtl8152_probe()
9694 dev_info(&udev->dev, "Dell TB16 Dock, disable RX aggregation"); in rtl8152_probe()
9695 tp->dell_tb_rx_agg_bug = 1; in rtl8152_probe()
9698 netdev->ethtool_ops = &ops; in rtl8152_probe()
9701 /* MTU range: 68 - 1500 or 9194 */ in rtl8152_probe()
9702 netdev->min_mtu = ETH_MIN_MTU; in rtl8152_probe()
9703 switch (tp->version) { in rtl8152_probe()
9711 netdev->max_mtu = size_to_mtu(9 * 1024); in rtl8152_probe()
9715 netdev->max_mtu = size_to_mtu(15 * 1024); in rtl8152_probe()
9720 netdev->max_mtu = size_to_mtu(16 * 1024); in rtl8152_probe()
9726 netdev->max_mtu = ETH_DATA_LEN; in rtl8152_probe()
9730 tp->mii.dev = netdev; in rtl8152_probe()
9731 tp->mii.mdio_read = read_mii_word; in rtl8152_probe()
9732 tp->mii.mdio_write = write_mii_word; in rtl8152_probe()
9733 tp->mii.phy_id_mask = 0x3f; in rtl8152_probe()
9734 tp->mii.reg_num_mask = 0x1f; in rtl8152_probe()
9735 tp->mii.phy_id = R8152_PHY_ID; in rtl8152_probe()
9737 tp->autoneg = AUTONEG_ENABLE; in rtl8152_probe()
9738 tp->speed = SPEED_100; in rtl8152_probe()
9739 tp->advertising = RTL_ADVERTISED_10_HALF | RTL_ADVERTISED_10_FULL | in rtl8152_probe()
9741 if (tp->mii.supports_gmii) { in rtl8152_probe()
9742 if (tp->support_2500full && in rtl8152_probe()
9743 tp->udev->speed >= USB_SPEED_SUPER) { in rtl8152_probe()
9744 tp->speed = SPEED_2500; in rtl8152_probe()
9745 tp->advertising |= RTL_ADVERTISED_2500_FULL; in rtl8152_probe()
9747 tp->speed = SPEED_1000; in rtl8152_probe()
9749 tp->advertising |= RTL_ADVERTISED_1000_FULL; in rtl8152_probe()
9751 tp->duplex = DUPLEX_FULL; in rtl8152_probe()
9753 tp->rx_copybreak = RTL8152_RXFG_HEADSZ; in rtl8152_probe()
9754 tp->rx_pending = 10 * RTL8152_MAX_RX; in rtl8152_probe()
9756 intf->needs_remote_wakeup = 1; in rtl8152_probe()
9761 tp->saved_wolopts = __rtl_get_wol(tp); in rtl8152_probe()
9763 tp->rtl_ops.init(tp); in rtl8152_probe()
9766 tp->rtl_fw.retry = true; in rtl8152_probe()
9768 queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0); in rtl8152_probe()
9773 netif_napi_add_weight(netdev, &tp->napi, r8152_poll, in rtl8152_probe()
9774 tp->support_2500full ? 256 : 64); in rtl8152_probe()
9778 dev_err(&intf->dev, "couldn't register the device\n"); in rtl8152_probe()
9782 if (tp->saved_wolopts) in rtl8152_probe()
9783 device_set_wakeup_enable(&udev->dev, true); in rtl8152_probe()
9785 device_set_wakeup_enable(&udev->dev, false); in rtl8152_probe()
9792 tasklet_kill(&tp->tx_tl); in rtl8152_probe()
9807 unregister_netdev(tp->netdev); in rtl8152_disconnect()
9808 tasklet_kill(&tp->tx_tl); in rtl8152_disconnect()
9809 cancel_delayed_work_sync(&tp->hw_phy_work); in rtl8152_disconnect()
9810 if (tp->rtl_ops.unload) in rtl8152_disconnect()
9811 tp->rtl_ops.unload(tp); in rtl8152_disconnect()
9813 free_netdev(tp->netdev); in rtl8152_disconnect()