hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/net/usb/r8152.c
....@@ -891,7 +891,7 @@
891891 struct fw_header {
892892 u8 checksum[32];
893893 char version[RTL_VER_SIZE];
894
- struct fw_block blocks[0];
894
+ struct fw_block blocks[];
895895 } __packed;
896896
897897 /**
....@@ -930,7 +930,7 @@
930930 __le32 reserved;
931931 __le16 fw_ver_reg;
932932 u8 fw_ver_data;
933
- char info[0];
933
+ char info[];
934934 } __packed;
935935
936936 /**
....@@ -982,7 +982,7 @@
982982 __le16 bp_start;
983983 __le16 bp_num;
984984 __le16 bp[4];
985
- char info[0];
985
+ char info[];
986986 } __packed;
987987
988988 enum rtl_fw_type {
....@@ -1504,15 +1504,19 @@
15041504
15051505 sa->sa_family = dev->type;
15061506
1507
- if (tp->version == RTL_VER_01) {
1508
- ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data);
1509
- } else {
1510
- /* if device doesn't support MAC pass through this will
1511
- * be expected to be non-zero
1512
- */
1513
- ret = vendor_mac_passthru_addr_read(tp, sa);
1514
- if (ret < 0)
1515
- ret = pla_ocp_read(tp, PLA_BACKUP, 8, sa->sa_data);
1507
+ ret = eth_platform_get_mac_address(&tp->udev->dev, sa->sa_data);
1508
+ if (ret < 0) {
1509
+ if (tp->version == RTL_VER_01) {
1510
+ ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data);
1511
+ } else {
1512
+ /* if device doesn't support MAC pass through this will
1513
+ * be expected to be non-zero
1514
+ */
1515
+ ret = vendor_mac_passthru_addr_read(tp, sa);
1516
+ if (ret < 0)
1517
+ ret = pla_ocp_read(tp, PLA_BACKUP, 8,
1518
+ sa->sa_data);
1519
+ }
15161520 }
15171521
15181522 if (ret < 0) {
....@@ -1678,14 +1682,16 @@
16781682 case -ECONNRESET: /* unlink */
16791683 case -ESHUTDOWN:
16801684 netif_device_detach(tp->netdev);
1681
- /* fall through */
1685
+ fallthrough;
16821686 case -ENOENT:
16831687 case -EPROTO:
16841688 netif_info(tp, intr, tp->netdev,
16851689 "Stop submitting intr, status %d\n", status);
16861690 return;
16871691 case -EOVERFLOW:
1688
- netif_info(tp, intr, tp->netdev, "intr status -EOVERFLOW\n");
1692
+ if (net_ratelimit())
1693
+ netif_info(tp, intr, tp->netdev,
1694
+ "intr status -EOVERFLOW\n");
16891695 goto resubmit;
16901696 /* -EPIPE: should clear the halt */
16911697 default:
....@@ -1916,8 +1922,8 @@
19161922 {
19171923 if (skb_shinfo(skb)->gso_size) {
19181924 netdev_features_t features = tp->netdev->features;
1925
+ struct sk_buff *segs, *seg, *next;
19191926 struct sk_buff_head seg_list;
1920
- struct sk_buff *segs, *nskb;
19211927
19221928 features &= ~(NETIF_F_SG | NETIF_F_IPV6_CSUM | NETIF_F_TSO6);
19231929 segs = skb_gso_segment(skb, features);
....@@ -1926,12 +1932,10 @@
19261932
19271933 __skb_queue_head_init(&seg_list);
19281934
1929
- do {
1930
- nskb = segs;
1931
- segs = segs->next;
1932
- nskb->next = NULL;
1933
- __skb_queue_tail(&seg_list, nskb);
1934
- } while (segs);
1935
+ skb_list_walk_safe(segs, seg, next) {
1936
+ skb_mark_not_on_list(seg);
1937
+ __skb_queue_tail(&seg_list, seg);
1938
+ }
19351939
19361940 skb_queue_splice(&seg_list, list);
19371941 dev_kfree_skb(skb);
....@@ -1948,29 +1952,6 @@
19481952 stats->tx_dropped++;
19491953 dev_kfree_skb(skb);
19501954 }
1951
-}
1952
-
1953
-/* msdn_giant_send_check()
1954
- * According to the document of microsoft, the TCP Pseudo Header excludes the
1955
- * packet length for IPv6 TCP large packets.
1956
- */
1957
-static int msdn_giant_send_check(struct sk_buff *skb)
1958
-{
1959
- const struct ipv6hdr *ipv6h;
1960
- struct tcphdr *th;
1961
- int ret;
1962
-
1963
- ret = skb_cow_head(skb, 0);
1964
- if (ret)
1965
- return ret;
1966
-
1967
- ipv6h = ipv6_hdr(skb);
1968
- th = tcp_hdr(skb);
1969
-
1970
- th->check = 0;
1971
- th->check = ~tcp_v6_check(0, &ipv6h->saddr, &ipv6h->daddr, 0);
1972
-
1973
- return ret;
19741955 }
19751956
19761957 static inline void rtl_tx_vlan_tag(struct tx_desc *desc, struct sk_buff *skb)
....@@ -2018,10 +1999,11 @@
20181999 break;
20192000
20202001 case htons(ETH_P_IPV6):
2021
- if (msdn_giant_send_check(skb)) {
2002
+ if (skb_cow_head(skb, 0)) {
20222003 ret = TX_CSUM_TSO;
20232004 goto unavailable;
20242005 }
2006
+ tcp_v6_gso_csum_prep(skb);
20252007 opts1 |= GTSENDV6;
20262008 break;
20272009
....@@ -2457,6 +2439,9 @@
24572439 struct r8152 *tp = container_of(napi, struct r8152, napi);
24582440 int work_done;
24592441
2442
+ if (!budget)
2443
+ return 0;
2444
+
24602445 work_done = rx_bottom(tp, budget);
24612446
24622447 if (work_done < budget) {
....@@ -2526,7 +2511,7 @@
25262511 }
25272512 }
25282513
2529
-static void rtl8152_tx_timeout(struct net_device *netdev)
2514
+static void rtl8152_tx_timeout(struct net_device *netdev, unsigned int txqueue)
25302515 {
25312516 struct r8152 *tp = netdev_priv(netdev);
25322517
....@@ -3248,7 +3233,7 @@
32483233 r8152_mdio_write(tp, MII_BMCR, data);
32493234
32503235 data = r8153_phy_status(tp, PHY_STAT_LAN_ON);
3251
- /* fall through */
3236
+ fallthrough;
32523237
32533238 default:
32543239 if (data != PHY_STAT_LAN_ON)
....@@ -3452,7 +3437,7 @@
34523437 case RTL_VER_09:
34533438 default:
34543439 if (type == MCU_TYPE_USB) {
3455
- ocp_write_byte(tp, MCU_TYPE_USB, USB_BP2_EN, 0);
3440
+ ocp_write_word(tp, MCU_TYPE_USB, USB_BP2_EN, 0);
34563441
34573442 ocp_write_word(tp, MCU_TYPE_USB, USB_BP_8, 0);
34583443 ocp_write_word(tp, MCU_TYPE_USB, USB_BP_9, 0);
....@@ -4841,7 +4826,7 @@
48414826 tp->ups_info.speed_duplex = NWAY_1000M_FULL;
48424827 break;
48434828 }
4844
- /* fall through */
4829
+ fallthrough;
48454830 default:
48464831 ret = -EINVAL;
48474832 goto out;
....@@ -5634,7 +5619,7 @@
56345619 /* reset the MAC adddress in case of policy change */
56355620 if (determine_ethernet_addr(tp, &sa) >= 0) {
56365621 rtnl_lock();
5637
- dev_set_mac_address (tp->netdev, &sa);
5622
+ dev_set_mac_address (tp->netdev, &sa, NULL);
56385623 rtnl_unlock();
56395624 }
56405625
....@@ -6355,6 +6340,7 @@
63556340 }
63566341
63576342 static const struct ethtool_ops ops = {
6343
+ .supported_coalesce_params = ETHTOOL_COALESCE_USECS,
63586344 .get_drvinfo = rtl8152_get_drvinfo,
63596345 .get_link = ethtool_op_get_link,
63606346 .nway_reset = rtl8152_nway_reset,
....@@ -6539,7 +6525,10 @@
65396525 ops->in_nway = rtl8153_in_nway;
65406526 ops->hw_phy_cfg = r8153_hw_phy_cfg;
65416527 ops->autosuspend_en = rtl8153_runtime_enable;
6542
- tp->rx_buf_sz = 32 * 1024;
6528
+ if (tp->udev->speed < USB_SPEED_SUPER)
6529
+ tp->rx_buf_sz = 16 * 1024;
6530
+ else
6531
+ tp->rx_buf_sz = 32 * 1024;
65436532 tp->eee_en = true;
65446533 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX;
65456534 break;
....@@ -6884,6 +6873,7 @@
68846873 {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927)},
68856874 {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)},
68866875 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)},
6876
+ {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3054)},
68876877 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062)},
68886878 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3069)},
68896879 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3082)},