r8152.c (baf33d7a75642b4b38a87fdf1cd96b506df4849f) r8152.c (49ed8dde371522b2d330a7383aaa213748ad007e)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (c) 2014 Realtek Semiconductor Corp. All rights reserved.
4 */
5
6#include <linux/signal.h>
7#include <linux/slab.h>
8#include <linux/module.h>

--- 753 unchanged lines hidden (view full) ---

762 RTL8152_UNPLUG = 0,
763 RTL8152_SET_RX_MODE,
764 WORK_ENABLE,
765 RTL8152_LINK_CHG,
766 SELECTIVE_SUSPEND,
767 PHY_RESET,
768 SCHEDULE_TASKLET,
769 GREEN_ETHERNET,
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (c) 2014 Realtek Semiconductor Corp. All rights reserved.
4 */
5
6#include <linux/signal.h>
7#include <linux/slab.h>
8#include <linux/module.h>

--- 753 unchanged lines hidden (view full) ---

762 RTL8152_UNPLUG = 0,
763 RTL8152_SET_RX_MODE,
764 WORK_ENABLE,
765 RTL8152_LINK_CHG,
766 SELECTIVE_SUSPEND,
767 PHY_RESET,
768 SCHEDULE_TASKLET,
769 GREEN_ETHERNET,
770 RX_EPROTO,
771};
772
773#define DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2 0x3082
774#define DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2 0xa387
775
776struct tally_counter {
777 __le64 tx_packets;
778 __le64 rx_packets;

--- 787 unchanged lines hidden (view full) ---

1566 if (!in_resume) {
1567 ret = usb_autopm_get_interface(tp->intf);
1568 if (ret < 0)
1569 goto out1;
1570 }
1571
1572 mutex_lock(&tp->control);
1573
770};
771
772#define DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2 0x3082
773#define DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2 0xa387
774
775struct tally_counter {
776 __le64 tx_packets;
777 __le64 rx_packets;

--- 787 unchanged lines hidden (view full) ---

1565 if (!in_resume) {
1566 ret = usb_autopm_get_interface(tp->intf);
1567 if (ret < 0)
1568 goto out1;
1569 }
1570
1571 mutex_lock(&tp->control);
1572
1574 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
1573 eth_hw_addr_set(netdev, addr->sa_data);
1575
1576 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG);
1577 pla_ocp_write(tp, PLA_IDR, BYTE_EN_SIX_BYTES, 8, addr->sa_data);
1578 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML);
1579
1580 mutex_unlock(&tp->control);
1581
1582 if (!in_resume)

--- 131 unchanged lines hidden (view full) ---

1714 struct sockaddr sa;
1715 int ret;
1716
1717 ret = determine_ethernet_addr(tp, &sa);
1718 if (ret < 0)
1719 return ret;
1720
1721 if (tp->version == RTL_VER_01)
1574
1575 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG);
1576 pla_ocp_write(tp, PLA_IDR, BYTE_EN_SIX_BYTES, 8, addr->sa_data);
1577 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML);
1578
1579 mutex_unlock(&tp->control);
1580
1581 if (!in_resume)

--- 131 unchanged lines hidden (view full) ---

1713 struct sockaddr sa;
1714 int ret;
1715
1716 ret = determine_ethernet_addr(tp, &sa);
1717 if (ret < 0)
1718 return ret;
1719
1720 if (tp->version == RTL_VER_01)
1722 ether_addr_copy(dev->dev_addr, sa.sa_data);
1721 eth_hw_addr_set(dev, sa.sa_data);
1723 else
1724 ret = __rtl8152_set_mac_address(dev, &sa, in_resume);
1725
1726 return ret;
1727}
1728
1729static void read_bulk_callback(struct urb *urb)
1730{

--- 35 unchanged lines hidden (view full) ---

1766 list_add_tail(&agg->list, &tp->rx_done);
1767 spin_unlock_irqrestore(&tp->rx_lock, flags);
1768 napi_schedule(&tp->napi);
1769 return;
1770 case -ESHUTDOWN:
1771 rtl_set_unplug(tp);
1772 netif_device_detach(tp->netdev);
1773 return;
1722 else
1723 ret = __rtl8152_set_mac_address(dev, &sa, in_resume);
1724
1725 return ret;
1726}
1727
1728static void read_bulk_callback(struct urb *urb)
1729{

--- 35 unchanged lines hidden (view full) ---

1765 list_add_tail(&agg->list, &tp->rx_done);
1766 spin_unlock_irqrestore(&tp->rx_lock, flags);
1767 napi_schedule(&tp->napi);
1768 return;
1769 case -ESHUTDOWN:
1770 rtl_set_unplug(tp);
1771 netif_device_detach(tp->netdev);
1772 return;
1774 case -EPROTO:
1775 urb->actual_length = 0;
1776 spin_lock_irqsave(&tp->rx_lock, flags);
1777 list_add_tail(&agg->list, &tp->rx_done);
1778 spin_unlock_irqrestore(&tp->rx_lock, flags);
1779 set_bit(RX_EPROTO, &tp->flags);
1780 schedule_delayed_work(&tp->schedule, 1);
1781 return;
1782 case -ENOENT:
1783 return; /* the urb is in unlink state */
1784 case -ETIME:
1785 if (net_ratelimit())
1786 netdev_warn(netdev, "maybe reset is needed?\n");
1787 break;
1788 default:
1789 if (net_ratelimit())

--- 639 unchanged lines hidden (view full) ---

2429 stats->rx_packets++;
2430 stats->rx_bytes += pkt_len;
2431 }
2432 }
2433
2434 if (list_empty(&tp->rx_done))
2435 goto out1;
2436
1773 case -ENOENT:
1774 return; /* the urb is in unlink state */
1775 case -ETIME:
1776 if (net_ratelimit())
1777 netdev_warn(netdev, "maybe reset is needed?\n");
1778 break;
1779 default:
1780 if (net_ratelimit())

--- 639 unchanged lines hidden (view full) ---

2420 stats->rx_packets++;
2421 stats->rx_bytes += pkt_len;
2422 }
2423 }
2424
2425 if (list_empty(&tp->rx_done))
2426 goto out1;
2427
2437 clear_bit(RX_EPROTO, &tp->flags);
2438 INIT_LIST_HEAD(&rx_queue);
2439 spin_lock_irqsave(&tp->rx_lock, flags);
2440 list_splice_init(&tp->rx_done, &rx_queue);
2441 spin_unlock_irqrestore(&tp->rx_lock, flags);
2442
2443 list_for_each_safe(cursor, next, &rx_queue) {
2444 struct rx_desc *rx_desc;
2445 struct rx_agg *agg, *agg_free;
2446 int len_used = 0;
2447 struct urb *urb;
2448 u8 *rx_data;
2449
2450 list_del_init(cursor);
2451
2452 agg = list_entry(cursor, struct rx_agg, list);
2453 urb = agg->urb;
2428 INIT_LIST_HEAD(&rx_queue);
2429 spin_lock_irqsave(&tp->rx_lock, flags);
2430 list_splice_init(&tp->rx_done, &rx_queue);
2431 spin_unlock_irqrestore(&tp->rx_lock, flags);
2432
2433 list_for_each_safe(cursor, next, &rx_queue) {
2434 struct rx_desc *rx_desc;
2435 struct rx_agg *agg, *agg_free;
2436 int len_used = 0;
2437 struct urb *urb;
2438 u8 *rx_data;
2439
2440 list_del_init(cursor);
2441
2442 agg = list_entry(cursor, struct rx_agg, list);
2443 urb = agg->urb;
2454 if (urb->status != 0 || urb->actual_length < ETH_ZLEN)
2444 if (urb->actual_length < ETH_ZLEN)
2455 goto submit;
2456
2457 agg_free = rtl_get_free_rx(tp, GFP_ATOMIC);
2458
2459 rx_desc = agg->buffer;
2460 rx_data = agg->buffer;
2461 len_used += sizeof(struct rx_desc);
2462

--- 4185 unchanged lines hidden (view full) ---

6648 if (test_and_clear_bit(RTL8152_SET_RX_MODE, &tp->flags))
6649 _rtl8152_set_rx_mode(tp->netdev);
6650
6651 /* don't schedule tasket before linking */
6652 if (test_and_clear_bit(SCHEDULE_TASKLET, &tp->flags) &&
6653 netif_carrier_ok(tp->netdev))
6654 tasklet_schedule(&tp->tx_tl);
6655
2445 goto submit;
2446
2447 agg_free = rtl_get_free_rx(tp, GFP_ATOMIC);
2448
2449 rx_desc = agg->buffer;
2450 rx_data = agg->buffer;
2451 len_used += sizeof(struct rx_desc);
2452

--- 4185 unchanged lines hidden (view full) ---

6638 if (test_and_clear_bit(RTL8152_SET_RX_MODE, &tp->flags))
6639 _rtl8152_set_rx_mode(tp->netdev);
6640
6641 /* don't schedule tasket before linking */
6642 if (test_and_clear_bit(SCHEDULE_TASKLET, &tp->flags) &&
6643 netif_carrier_ok(tp->netdev))
6644 tasklet_schedule(&tp->tx_tl);
6645
6656 if (test_and_clear_bit(RX_EPROTO, &tp->flags) &&
6657 !list_empty(&tp->rx_done))
6658 napi_schedule(&tp->napi);
6659
6660 mutex_unlock(&tp->control);
6661
6662out1:
6663 usb_autopm_put_interface(tp->intf);
6664}
6665
6666static void rtl_hw_phy_work_func_t(struct work_struct *work)
6667{

--- 3134 unchanged lines hidden ---
6646 mutex_unlock(&tp->control);
6647
6648out1:
6649 usb_autopm_put_interface(tp->intf);
6650}
6651
6652static void rtl_hw_phy_work_func_t(struct work_struct *work)
6653{

--- 3134 unchanged lines hidden ---