aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-23 11:41:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-23 11:41:27 -0400
commit71aa60f67f032dffe58999bd8ae4b2f38a9ea05e (patch)
tree4d755f640b3135b14bf482215609b22379b62554
parent79444df4e7f03843be78e4b9188d095931648842 (diff)
parent4e683f499a15cd777d3cb51aaebe48d72334c852 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Fix NAPI poll list corruption in enic driver, from Christian Lamparter. 2) Fix route use after free, from Eric Dumazet. 3) Fix regression in reuseaddr handling, from Josef Bacik. 4) Assert the size of control messages in compat handling since we copy it in from userspace twice. From Meng Xu. 5) SMC layer bug fixes (missing RCU locking, bad refcounting, etc.) from Ursula Braun. 6) Fix races in AF_PACKET fanout handling, from Willem de Bruijn. 7) Don't use ARRAY_SIZE on spinlock array which might have zero entries, from Geert Uytterhoeven. 8) Fix miscomputation of checksum in ipv6 udp code, from Subash Abhinov Kasiviswanathan. 9) Push the ipv6 header properly in ipv6 GRE tunnel driver, from Xin Long. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (75 commits) inet: fix improper empty comparison net: use inet6_rcv_saddr to compare sockets net: set tb->fast_sk_family net: orphan frags on stand-alone ptype in dev_queue_xmit_nit MAINTAINERS: update git tree locations for ieee802154 subsystem net: prevent dst uses after free net: phy: Fix truncation of large IRQ numbers in phy_attached_print() net/smc: no close wait in case of process shut down net/smc: introduce a delay net/smc: terminate link group if out-of-sync is received net/smc: longer delay for client link group removal net/smc: adapt send request completion notification net/smc: adjust net_device refcount net/smc: take RCU read lock for routing cache lookup net/smc: add receive timeout check net/smc: add missing dev_put net: stmmac: Cocci spatch "of_table" lan78xx: Use default values loaded from EEPROM/OTP after reset lan78xx: Allow EEPROM write for less than MAX_EEPROM_SIZE lan78xx: Fix for eeprom read/write when device auto suspend ...
-rw-r--r--Documentation/networking/ip-sysctl.txt18
-rw-r--r--Documentation/networking/switchdev.txt68
-rw-r--r--MAINTAINERS6
-rw-r--r--drivers/isdn/i4l/isdn_ppp.c37
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c52
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c4
-rw-r--r--drivers/net/ethernet/freescale/fec.h4
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c8
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hnae3.c43
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hnae3.h15
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h12
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c183
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h3
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c41
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h4
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c23
-rw-r--r--drivers/net/ethernet/ibm/emac/mal.c3
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac-ethtool.c30
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac-mac.c22
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac.c3
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac.h3
-rw-r--r--drivers/net/ethernet/realtek/8139too.c5
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c1
-rw-r--r--drivers/net/hyperv/hyperv_net.h2
-rw-r--r--drivers/net/hyperv/netvsc.c7
-rw-r--r--drivers/net/hyperv/netvsc_drv.c8
-rw-r--r--drivers/net/phy/Kconfig18
-rw-r--r--drivers/net/phy/phy.c3
-rw-r--r--drivers/net/phy/phy_device.c2
-rw-r--r--drivers/net/phy/xilinx_gmii2rgmii.c2
-rw-r--r--drivers/net/usb/lan78xx.c34
-rw-r--r--include/linux/trace_events.h1
-rw-r--r--include/net/dst.h22
-rw-r--r--include/net/route.h2
-rw-r--r--include/net/sock.h2
-rw-r--r--include/net/tcp.h1
-rw-r--r--include/uapi/linux/ethtool.h6
-rw-r--r--kernel/bpf/devmap.c6
-rw-r--r--kernel/bpf/syscall.c6
-rw-r--r--kernel/bpf/verifier.c7
-rw-r--r--kernel/events/core.c3
-rw-r--r--lib/rhashtable.c9
-rw-r--r--net/compat.c7
-rw-r--r--net/core/dev.c9
-rw-r--r--net/core/ethtool.c2
-rw-r--r--net/core/filter.c24
-rw-r--r--net/ipv4/inet_connection_sock.c6
-rw-r--r--net/ipv4/tcp_output.c43
-rw-r--r--net/ipv6/addrconf.c32
-rw-r--r--net/ipv6/ip6_gre.c21
-rw-r--r--net/ipv6/ip6_tunnel.c3
-rw-r--r--net/ipv6/udp.c1
-rw-r--r--net/netfilter/ipset/ip_set_hash_gen.h14
-rw-r--r--net/netfilter/nf_nat_core.c12
-rw-r--r--net/packet/af_packet.c16
-rw-r--r--net/sched/cls_flower.c15
-rw-r--r--net/sched/cls_matchall.c1
-rw-r--r--net/sched/sch_generic.c1
-rw-r--r--net/sched/sch_hfsc.c23
-rw-r--r--net/smc/af_smc.c16
-rw-r--r--net/smc/smc.h2
-rw-r--r--net/smc/smc_clc.c10
-rw-r--r--net/smc/smc_clc.h3
-rw-r--r--net/smc/smc_close.c27
-rw-r--r--net/smc/smc_core.c16
-rw-r--r--net/smc/smc_ib.c1
-rw-r--r--net/smc/smc_pnet.c4
-rw-r--r--net/smc/smc_rx.c2
-rw-r--r--net/smc/smc_tx.c12
-rw-r--r--net/smc/smc_wr.c2
-rw-r--r--net/wireless/nl80211.c6
71 files changed, 646 insertions, 414 deletions
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index b3345d0fe0a6..77f4de59dc9c 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -1680,6 +1680,9 @@ accept_dad - INTEGER
1680 2: Enable DAD, and disable IPv6 operation if MAC-based duplicate 1680 2: Enable DAD, and disable IPv6 operation if MAC-based duplicate
1681 link-local address has been found. 1681 link-local address has been found.
1682 1682
1683 DAD operation and mode on a given interface will be selected according
1684 to the maximum value of conf/{all,interface}/accept_dad.
1685
1683force_tllao - BOOLEAN 1686force_tllao - BOOLEAN
1684 Enable sending the target link-layer address option even when 1687 Enable sending the target link-layer address option even when
1685 responding to a unicast neighbor solicitation. 1688 responding to a unicast neighbor solicitation.
@@ -1727,16 +1730,23 @@ suppress_frag_ndisc - INTEGER
1727 1730
1728optimistic_dad - BOOLEAN 1731optimistic_dad - BOOLEAN
1729 Whether to perform Optimistic Duplicate Address Detection (RFC 4429). 1732 Whether to perform Optimistic Duplicate Address Detection (RFC 4429).
1730 0: disabled (default) 1733 0: disabled (default)
1731 1: enabled 1734 1: enabled
1735
1736 Optimistic Duplicate Address Detection for the interface will be enabled
1737 if at least one of conf/{all,interface}/optimistic_dad is set to 1,
1738 it will be disabled otherwise.
1732 1739
1733use_optimistic - BOOLEAN 1740use_optimistic - BOOLEAN
1734 If enabled, do not classify optimistic addresses as deprecated during 1741 If enabled, do not classify optimistic addresses as deprecated during
1735 source address selection. Preferred addresses will still be chosen 1742 source address selection. Preferred addresses will still be chosen
1736 before optimistic addresses, subject to other ranking in the source 1743 before optimistic addresses, subject to other ranking in the source
1737 address selection algorithm. 1744 address selection algorithm.
1738 0: disabled (default) 1745 0: disabled (default)
1739 1: enabled 1746 1: enabled
1747
1748 This will be enabled if at least one of
1749 conf/{all,interface}/use_optimistic is set to 1, disabled otherwise.
1740 1750
1741stable_secret - IPv6 address 1751stable_secret - IPv6 address
1742 This IPv6 address will be used as a secret to generate IPv6 1752 This IPv6 address will be used as a secret to generate IPv6
diff --git a/Documentation/networking/switchdev.txt b/Documentation/networking/switchdev.txt
index 5e40e1f68873..82236a17b5e6 100644
--- a/Documentation/networking/switchdev.txt
+++ b/Documentation/networking/switchdev.txt
@@ -13,42 +13,42 @@ an example setup using a data-center-class switch ASIC chip. Other setups
13with SR-IOV or soft switches, such as OVS, are possible. 13with SR-IOV or soft switches, such as OVS, are possible.
14 14
15 15
16                             User-spacetools 16 User-space tools
17 17
18       userspace                   | 18 user space |
19      +-------------------------------------------------------------------+ 19 +-------------------------------------------------------------------+
20       kernel                       |Netlink 20 kernel | Netlink
21                                    | 21 |
22                     +--------------+-------------------------------+ 22 +--------------+-------------------------------+
23                     |         Network stack                        | 23 | Network stack |
24                     |           (Linux)                            | 24 | (Linux) |
25                     |                                              | 25 | |
26                     +----------------------------------------------+ 26 +----------------------------------------------+
27 27
28 sw1p2 sw1p4 sw1p6 28 sw1p2 sw1p4 sw1p6
29                      sw1p1  + sw1p3 +  sw1p5 +         eth1 29 sw1p1 + sw1p3 + sw1p5 + eth1
30                        +    |    +    |    +    |            + 30 + | + | + | +
31                        |    |    |    |    |    |            | 31 | | | | | | |
32                     +--+----+----+----+-+--+----+---+  +-----+-----+ 32 +--+----+----+----+----+----+---+ +-----+-----+
33                     |         Switch driver         |  |    mgmt   | 33 | Switch driver | | mgmt |
34                     |        (this document)        |  |   driver  | 34 | (this document) | | driver |
35                     |                               |  |           | 35 | | | |
36                     +--------------+----------------+  +-----------+ 36 +--------------+----------------+ +-----------+
37                                    | 37 |
38       kernel                       |HWbus(egPCI) 38 kernel | HW bus (eg PCI)
39      +-------------------------------------------------------------------+ 39 +-------------------------------------------------------------------+
40       hardware                     | 40 hardware |
41                     +--------------+---+------------+ 41 +--------------+----------------+
42                     |         Switchdevice (sw1)   | 42 | Switch device (sw1) |
43                     |  +----+                       +--------+ 43 | +----+ +--------+
44                     |  |    v offloaded data path   | mgmt port 44 | | v offloaded data path | mgmt port
45                     |  |    |                       | 45 | | | |
46                     +--|----|----+----+----+----+---+ 46 +--|----|----+----+----+----+---+
47                        |    |    |    |    |    | 47 | | | | | |
48                        +    +    +    +    +    + 48 + + + + + +
49                       p1   p2   p3   p4   p5   p6 49 p1 p2 p3 p4 p5 p6
50 50
51                             front-panelports 51 front-panel ports
52 52
53 53
54 Fig 1. 54 Fig 1.
diff --git a/MAINTAINERS b/MAINTAINERS
index fa4e916b72e9..6671f375f7fc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2865,7 +2865,6 @@ S: Supported
2865F: drivers/scsi/bnx2i/ 2865F: drivers/scsi/bnx2i/
2866 2866
2867BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER 2867BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER
2868M: Yuval Mintz <Yuval.Mintz@cavium.com>
2869M: Ariel Elior <ariel.elior@cavium.com> 2868M: Ariel Elior <ariel.elior@cavium.com>
2870M: everest-linux-l2@cavium.com 2869M: everest-linux-l2@cavium.com
2871L: netdev@vger.kernel.org 2870L: netdev@vger.kernel.org
@@ -6655,8 +6654,8 @@ M: Alexander Aring <alex.aring@gmail.com>
6655M: Stefan Schmidt <stefan@osg.samsung.com> 6654M: Stefan Schmidt <stefan@osg.samsung.com>
6656L: linux-wpan@vger.kernel.org 6655L: linux-wpan@vger.kernel.org
6657W: http://wpan.cakelab.org/ 6656W: http://wpan.cakelab.org/
6658T: git git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git 6657T: git git://git.kernel.org/pub/scm/linux/kernel/git/sschmidt/wpan.git
6659T: git git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git 6658T: git git://git.kernel.org/pub/scm/linux/kernel/git/sschmidt/wpan-next.git
6660S: Maintained 6659S: Maintained
6661F: net/ieee802154/ 6660F: net/ieee802154/
6662F: net/mac802154/ 6661F: net/mac802154/
@@ -11059,7 +11058,6 @@ S: Supported
11059F: drivers/scsi/qedi/ 11058F: drivers/scsi/qedi/
11060 11059
11061QLOGIC QL4xxx ETHERNET DRIVER 11060QLOGIC QL4xxx ETHERNET DRIVER
11062M: Yuval Mintz <Yuval.Mintz@cavium.com>
11063M: Ariel Elior <Ariel.Elior@cavium.com> 11061M: Ariel Elior <Ariel.Elior@cavium.com>
11064M: everest-linux-l2@cavium.com 11062M: everest-linux-l2@cavium.com
11065L: netdev@vger.kernel.org 11063L: netdev@vger.kernel.org
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 6c44609fd83a..cd2b3c69771a 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -825,7 +825,6 @@ isdn_ppp_write(int min, struct file *file, const char __user *buf, int count)
825 isdn_net_local *lp; 825 isdn_net_local *lp;
826 struct ippp_struct *is; 826 struct ippp_struct *is;
827 int proto; 827 int proto;
828 unsigned char protobuf[4];
829 828
830 is = file->private_data; 829 is = file->private_data;
831 830
@@ -839,24 +838,28 @@ isdn_ppp_write(int min, struct file *file, const char __user *buf, int count)
839 if (!lp) 838 if (!lp)
840 printk(KERN_DEBUG "isdn_ppp_write: lp == NULL\n"); 839 printk(KERN_DEBUG "isdn_ppp_write: lp == NULL\n");
841 else { 840 else {
842 /* 841 if (lp->isdn_device < 0 || lp->isdn_channel < 0) {
843 * Don't reset huptimer for 842 unsigned char protobuf[4];
844 * LCP packets. (Echo requests). 843 /*
845 */ 844 * Don't reset huptimer for
846 if (copy_from_user(protobuf, buf, 4)) 845 * LCP packets. (Echo requests).
847 return -EFAULT; 846 */
848 proto = PPP_PROTOCOL(protobuf); 847 if (copy_from_user(protobuf, buf, 4))
849 if (proto != PPP_LCP) 848 return -EFAULT;
850 lp->huptimer = 0; 849
850 proto = PPP_PROTOCOL(protobuf);
851 if (proto != PPP_LCP)
852 lp->huptimer = 0;
851 853
852 if (lp->isdn_device < 0 || lp->isdn_channel < 0)
853 return 0; 854 return 0;
855 }
854 856
855 if ((dev->drv[lp->isdn_device]->flags & DRV_FLAG_RUNNING) && 857 if ((dev->drv[lp->isdn_device]->flags & DRV_FLAG_RUNNING) &&
856 lp->dialstate == 0 && 858 lp->dialstate == 0 &&
857 (lp->flags & ISDN_NET_CONNECTED)) { 859 (lp->flags & ISDN_NET_CONNECTED)) {
858 unsigned short hl; 860 unsigned short hl;
859 struct sk_buff *skb; 861 struct sk_buff *skb;
862 unsigned char *cpy_buf;
860 /* 863 /*
861 * we need to reserve enough space in front of 864 * we need to reserve enough space in front of
862 * sk_buff. old call to dev_alloc_skb only reserved 865 * sk_buff. old call to dev_alloc_skb only reserved
@@ -869,11 +872,21 @@ isdn_ppp_write(int min, struct file *file, const char __user *buf, int count)
869 return count; 872 return count;
870 } 873 }
871 skb_reserve(skb, hl); 874 skb_reserve(skb, hl);
872 if (copy_from_user(skb_put(skb, count), buf, count)) 875 cpy_buf = skb_put(skb, count);
876 if (copy_from_user(cpy_buf, buf, count))
873 { 877 {
874 kfree_skb(skb); 878 kfree_skb(skb);
875 return -EFAULT; 879 return -EFAULT;
876 } 880 }
881
882 /*
883 * Don't reset huptimer for
884 * LCP packets. (Echo requests).
885 */
886 proto = PPP_PROTOCOL(cpy_buf);
887 if (proto != PPP_LCP)
888 lp->huptimer = 0;
889
877 if (is->debug & 0x40) { 890 if (is->debug & 0x40) {
878 printk(KERN_DEBUG "ppp xmit: len %d\n", (int) skb->len); 891 printk(KERN_DEBUG "ppp xmit: len %d\n", (int) skb->len);
879 isdn_ppp_frame_log("xmit", skb->data, skb->len, 32, is->unit, lp->ppp_slot); 892 isdn_ppp_frame_log("xmit", skb->data, skb->len, 32, is->unit, lp->ppp_slot);
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index c3c53f6cd9e6..83eec9a8c275 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -432,6 +432,27 @@ static void bcm_sysport_update_mib_counters(struct bcm_sysport_priv *priv)
432 netif_dbg(priv, hw, priv->netdev, "updated MIB counters\n"); 432 netif_dbg(priv, hw, priv->netdev, "updated MIB counters\n");
433} 433}
434 434
435static void bcm_sysport_update_tx_stats(struct bcm_sysport_priv *priv,
436 u64 *tx_bytes, u64 *tx_packets)
437{
438 struct bcm_sysport_tx_ring *ring;
439 u64 bytes = 0, packets = 0;
440 unsigned int start;
441 unsigned int q;
442
443 for (q = 0; q < priv->netdev->num_tx_queues; q++) {
444 ring = &priv->tx_rings[q];
445 do {
446 start = u64_stats_fetch_begin_irq(&priv->syncp);
447 bytes = ring->bytes;
448 packets = ring->packets;
449 } while (u64_stats_fetch_retry_irq(&priv->syncp, start));
450
451 *tx_bytes += bytes;
452 *tx_packets += packets;
453 }
454}
455
435static void bcm_sysport_get_stats(struct net_device *dev, 456static void bcm_sysport_get_stats(struct net_device *dev,
436 struct ethtool_stats *stats, u64 *data) 457 struct ethtool_stats *stats, u64 *data)
437{ 458{
@@ -439,11 +460,16 @@ static void bcm_sysport_get_stats(struct net_device *dev,
439 struct bcm_sysport_stats64 *stats64 = &priv->stats64; 460 struct bcm_sysport_stats64 *stats64 = &priv->stats64;
440 struct u64_stats_sync *syncp = &priv->syncp; 461 struct u64_stats_sync *syncp = &priv->syncp;
441 struct bcm_sysport_tx_ring *ring; 462 struct bcm_sysport_tx_ring *ring;
463 u64 tx_bytes = 0, tx_packets = 0;
442 unsigned int start; 464 unsigned int start;
443 int i, j; 465 int i, j;
444 466
445 if (netif_running(dev)) 467 if (netif_running(dev)) {
446 bcm_sysport_update_mib_counters(priv); 468 bcm_sysport_update_mib_counters(priv);
469 bcm_sysport_update_tx_stats(priv, &tx_bytes, &tx_packets);
470 stats64->tx_bytes = tx_bytes;
471 stats64->tx_packets = tx_packets;
472 }
447 473
448 for (i = 0, j = 0; i < BCM_SYSPORT_STATS_LEN; i++) { 474 for (i = 0, j = 0; i < BCM_SYSPORT_STATS_LEN; i++) {
449 const struct bcm_sysport_stats *s; 475 const struct bcm_sysport_stats *s;
@@ -461,12 +487,13 @@ static void bcm_sysport_get_stats(struct net_device *dev,
461 continue; 487 continue;
462 p += s->stat_offset; 488 p += s->stat_offset;
463 489
464 if (s->stat_sizeof == sizeof(u64)) 490 if (s->stat_sizeof == sizeof(u64) &&
491 s->type == BCM_SYSPORT_STAT_NETDEV64) {
465 do { 492 do {
466 start = u64_stats_fetch_begin_irq(syncp); 493 start = u64_stats_fetch_begin_irq(syncp);
467 data[i] = *(u64 *)p; 494 data[i] = *(u64 *)p;
468 } while (u64_stats_fetch_retry_irq(syncp, start)); 495 } while (u64_stats_fetch_retry_irq(syncp, start));
469 else 496 } else
470 data[i] = *(u32 *)p; 497 data[i] = *(u32 *)p;
471 j++; 498 j++;
472 } 499 }
@@ -1716,27 +1743,12 @@ static void bcm_sysport_get_stats64(struct net_device *dev,
1716{ 1743{
1717 struct bcm_sysport_priv *priv = netdev_priv(dev); 1744 struct bcm_sysport_priv *priv = netdev_priv(dev);
1718 struct bcm_sysport_stats64 *stats64 = &priv->stats64; 1745 struct bcm_sysport_stats64 *stats64 = &priv->stats64;
1719 struct bcm_sysport_tx_ring *ring;
1720 u64 tx_packets = 0, tx_bytes = 0;
1721 unsigned int start; 1746 unsigned int start;
1722 unsigned int q;
1723 1747
1724 netdev_stats_to_stats64(stats, &dev->stats); 1748 netdev_stats_to_stats64(stats, &dev->stats);
1725 1749
1726 for (q = 0; q < dev->num_tx_queues; q++) { 1750 bcm_sysport_update_tx_stats(priv, &stats->tx_bytes,
1727 ring = &priv->tx_rings[q]; 1751 &stats->tx_packets);
1728 do {
1729 start = u64_stats_fetch_begin_irq(&priv->syncp);
1730 tx_bytes = ring->bytes;
1731 tx_packets = ring->packets;
1732 } while (u64_stats_fetch_retry_irq(&priv->syncp, start));
1733
1734 stats->tx_bytes += tx_bytes;
1735 stats->tx_packets += tx_packets;
1736 }
1737
1738 stats64->tx_bytes = stats->tx_bytes;
1739 stats64->tx_packets = stats->tx_packets;
1740 1752
1741 do { 1753 do {
1742 start = u64_stats_fetch_begin_irq(&priv->syncp); 1754 start = u64_stats_fetch_begin_irq(&priv->syncp);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
index ccd699fb2d70..7dd3d131043a 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
@@ -750,6 +750,10 @@ int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,
750{ 750{
751 int rc = 0; 751 int rc = 0;
752 752
753 if (!is_classid_clsact_ingress(cls_flower->common.classid) ||
754 cls_flower->common.chain_index)
755 return -EOPNOTSUPP;
756
753 switch (cls_flower->command) { 757 switch (cls_flower->command) {
754 case TC_CLSFLOWER_REPLACE: 758 case TC_CLSFLOWER_REPLACE:
755 rc = bnxt_tc_add_flow(bp, src_fid, cls_flower); 759 rc = bnxt_tc_add_flow(bp, src_fid, cls_flower);
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 38c7b21e5d63..ede1876a9a19 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -374,8 +374,8 @@ struct bufdesc_ex {
374#define FEC_ENET_TS_AVAIL ((uint)0x00010000) 374#define FEC_ENET_TS_AVAIL ((uint)0x00010000)
375#define FEC_ENET_TS_TIMER ((uint)0x00008000) 375#define FEC_ENET_TS_TIMER ((uint)0x00008000)
376 376
377#define FEC_DEFAULT_IMASK (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII | FEC_ENET_TS_TIMER) 377#define FEC_DEFAULT_IMASK (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII)
378#define FEC_NAPI_IMASK (FEC_ENET_MII | FEC_ENET_TS_TIMER) 378#define FEC_NAPI_IMASK FEC_ENET_MII
379#define FEC_RX_DISABLED_IMASK (FEC_DEFAULT_IMASK & (~FEC_ENET_RXF)) 379#define FEC_RX_DISABLED_IMASK (FEC_DEFAULT_IMASK & (~FEC_ENET_RXF))
380 380
381/* ENET interrupt coalescing macro define */ 381/* ENET interrupt coalescing macro define */
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 56f56d6ada9c..3dc2d771a222 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1559,14 +1559,14 @@ fec_enet_collect_events(struct fec_enet_private *fep, uint int_events)
1559 if (int_events == 0) 1559 if (int_events == 0)
1560 return false; 1560 return false;
1561 1561
1562 if (int_events & FEC_ENET_RXF) 1562 if (int_events & FEC_ENET_RXF_0)
1563 fep->work_rx |= (1 << 2); 1563 fep->work_rx |= (1 << 2);
1564 if (int_events & FEC_ENET_RXF_1) 1564 if (int_events & FEC_ENET_RXF_1)
1565 fep->work_rx |= (1 << 0); 1565 fep->work_rx |= (1 << 0);
1566 if (int_events & FEC_ENET_RXF_2) 1566 if (int_events & FEC_ENET_RXF_2)
1567 fep->work_rx |= (1 << 1); 1567 fep->work_rx |= (1 << 1);
1568 1568
1569 if (int_events & FEC_ENET_TXF) 1569 if (int_events & FEC_ENET_TXF_0)
1570 fep->work_tx |= (1 << 2); 1570 fep->work_tx |= (1 << 2);
1571 if (int_events & FEC_ENET_TXF_1) 1571 if (int_events & FEC_ENET_TXF_1)
1572 fep->work_tx |= (1 << 0); 1572 fep->work_tx |= (1 << 0);
@@ -1604,8 +1604,8 @@ fec_enet_interrupt(int irq, void *dev_id)
1604 } 1604 }
1605 1605
1606 if (fep->ptp_clock) 1606 if (fep->ptp_clock)
1607 fec_ptp_check_pps_event(fep); 1607 if (fec_ptp_check_pps_event(fep))
1608 1608 ret = IRQ_HANDLED;
1609 return ret; 1609 return ret;
1610} 1610}
1611 1611
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c
index 59efbd605416..5bcb2238acb2 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c
@@ -37,20 +37,15 @@ static bool hnae3_client_match(enum hnae3_client_type client_type,
37} 37}
38 38
39static int hnae3_match_n_instantiate(struct hnae3_client *client, 39static int hnae3_match_n_instantiate(struct hnae3_client *client,
40 struct hnae3_ae_dev *ae_dev, 40 struct hnae3_ae_dev *ae_dev, bool is_reg)
41 bool is_reg, bool *matched)
42{ 41{
43 int ret; 42 int ret;
44 43
45 *matched = false;
46
47 /* check if this client matches the type of ae_dev */ 44 /* check if this client matches the type of ae_dev */
48 if (!(hnae3_client_match(client->type, ae_dev->dev_type) && 45 if (!(hnae3_client_match(client->type, ae_dev->dev_type) &&
49 hnae_get_bit(ae_dev->flag, HNAE3_DEV_INITED_B))) { 46 hnae_get_bit(ae_dev->flag, HNAE3_DEV_INITED_B))) {
50 return 0; 47 return 0;
51 } 48 }
52 /* there is a match of client and dev */
53 *matched = true;
54 49
55 /* now, (un-)instantiate client by calling lower layer */ 50 /* now, (un-)instantiate client by calling lower layer */
56 if (is_reg) { 51 if (is_reg) {
@@ -69,7 +64,6 @@ int hnae3_register_client(struct hnae3_client *client)
69{ 64{
70 struct hnae3_client *client_tmp; 65 struct hnae3_client *client_tmp;
71 struct hnae3_ae_dev *ae_dev; 66 struct hnae3_ae_dev *ae_dev;
72 bool matched;
73 int ret = 0; 67 int ret = 0;
74 68
75 mutex_lock(&hnae3_common_lock); 69 mutex_lock(&hnae3_common_lock);
@@ -86,7 +80,7 @@ int hnae3_register_client(struct hnae3_client *client)
86 /* if the client could not be initialized on current port, for 80 /* if the client could not be initialized on current port, for
87 * any error reasons, move on to next available port 81 * any error reasons, move on to next available port
88 */ 82 */
89 ret = hnae3_match_n_instantiate(client, ae_dev, true, &matched); 83 ret = hnae3_match_n_instantiate(client, ae_dev, true);
90 if (ret) 84 if (ret)
91 dev_err(&ae_dev->pdev->dev, 85 dev_err(&ae_dev->pdev->dev,
92 "match and instantiation failed for port\n"); 86 "match and instantiation failed for port\n");
@@ -102,12 +96,11 @@ EXPORT_SYMBOL(hnae3_register_client);
102void hnae3_unregister_client(struct hnae3_client *client) 96void hnae3_unregister_client(struct hnae3_client *client)
103{ 97{
104 struct hnae3_ae_dev *ae_dev; 98 struct hnae3_ae_dev *ae_dev;
105 bool matched;
106 99
107 mutex_lock(&hnae3_common_lock); 100 mutex_lock(&hnae3_common_lock);
108 /* un-initialize the client on every matched port */ 101 /* un-initialize the client on every matched port */
109 list_for_each_entry(ae_dev, &hnae3_ae_dev_list, node) { 102 list_for_each_entry(ae_dev, &hnae3_ae_dev_list, node) {
110 hnae3_match_n_instantiate(client, ae_dev, false, &matched); 103 hnae3_match_n_instantiate(client, ae_dev, false);
111 } 104 }
112 105
113 list_del(&client->node); 106 list_del(&client->node);
@@ -124,7 +117,6 @@ int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo)
124 const struct pci_device_id *id; 117 const struct pci_device_id *id;
125 struct hnae3_ae_dev *ae_dev; 118 struct hnae3_ae_dev *ae_dev;
126 struct hnae3_client *client; 119 struct hnae3_client *client;
127 bool matched;
128 int ret = 0; 120 int ret = 0;
129 121
130 mutex_lock(&hnae3_common_lock); 122 mutex_lock(&hnae3_common_lock);
@@ -151,13 +143,10 @@ int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo)
151 * initialize the figure out client instance 143 * initialize the figure out client instance
152 */ 144 */
153 list_for_each_entry(client, &hnae3_client_list, node) { 145 list_for_each_entry(client, &hnae3_client_list, node) {
154 ret = hnae3_match_n_instantiate(client, ae_dev, true, 146 ret = hnae3_match_n_instantiate(client, ae_dev, true);
155 &matched);
156 if (ret) 147 if (ret)
157 dev_err(&ae_dev->pdev->dev, 148 dev_err(&ae_dev->pdev->dev,
158 "match and instantiation failed\n"); 149 "match and instantiation failed\n");
159 if (matched)
160 break;
161 } 150 }
162 } 151 }
163 152
@@ -175,7 +164,6 @@ void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo)
175 const struct pci_device_id *id; 164 const struct pci_device_id *id;
176 struct hnae3_ae_dev *ae_dev; 165 struct hnae3_ae_dev *ae_dev;
177 struct hnae3_client *client; 166 struct hnae3_client *client;
178 bool matched;
179 167
180 mutex_lock(&hnae3_common_lock); 168 mutex_lock(&hnae3_common_lock);
181 /* Check if there are matched ae_dev */ 169 /* Check if there are matched ae_dev */
@@ -187,12 +175,8 @@ void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo)
187 /* check the client list for the match with this ae_dev type and 175 /* check the client list for the match with this ae_dev type and
188 * un-initialize the figure out client instance 176 * un-initialize the figure out client instance
189 */ 177 */
190 list_for_each_entry(client, &hnae3_client_list, node) { 178 list_for_each_entry(client, &hnae3_client_list, node)
191 hnae3_match_n_instantiate(client, ae_dev, false, 179 hnae3_match_n_instantiate(client, ae_dev, false);
192 &matched);
193 if (matched)
194 break;
195 }
196 180
197 ae_algo->ops->uninit_ae_dev(ae_dev); 181 ae_algo->ops->uninit_ae_dev(ae_dev);
198 hnae_set_bit(ae_dev->flag, HNAE3_DEV_INITED_B, 0); 182 hnae_set_bit(ae_dev->flag, HNAE3_DEV_INITED_B, 0);
@@ -212,7 +196,6 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
212 const struct pci_device_id *id; 196 const struct pci_device_id *id;
213 struct hnae3_ae_algo *ae_algo; 197 struct hnae3_ae_algo *ae_algo;
214 struct hnae3_client *client; 198 struct hnae3_client *client;
215 bool matched;
216 int ret = 0; 199 int ret = 0;
217 200
218 mutex_lock(&hnae3_common_lock); 201 mutex_lock(&hnae3_common_lock);
@@ -246,13 +229,10 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
246 * initialize the figure out client instance 229 * initialize the figure out client instance
247 */ 230 */
248 list_for_each_entry(client, &hnae3_client_list, node) { 231 list_for_each_entry(client, &hnae3_client_list, node) {
249 ret = hnae3_match_n_instantiate(client, ae_dev, true, 232 ret = hnae3_match_n_instantiate(client, ae_dev, true);
250 &matched);
251 if (ret) 233 if (ret)
252 dev_err(&ae_dev->pdev->dev, 234 dev_err(&ae_dev->pdev->dev,
253 "match and instantiation failed\n"); 235 "match and instantiation failed\n");
254 if (matched)
255 break;
256 } 236 }
257 237
258out_err: 238out_err:
@@ -270,7 +250,6 @@ void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev)
270 const struct pci_device_id *id; 250 const struct pci_device_id *id;
271 struct hnae3_ae_algo *ae_algo; 251 struct hnae3_ae_algo *ae_algo;
272 struct hnae3_client *client; 252 struct hnae3_client *client;
273 bool matched;
274 253
275 mutex_lock(&hnae3_common_lock); 254 mutex_lock(&hnae3_common_lock);
276 /* Check if there are matched ae_algo */ 255 /* Check if there are matched ae_algo */
@@ -279,12 +258,8 @@ void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev)
279 if (!id) 258 if (!id)
280 continue; 259 continue;
281 260
282 list_for_each_entry(client, &hnae3_client_list, node) { 261 list_for_each_entry(client, &hnae3_client_list, node)
283 hnae3_match_n_instantiate(client, ae_dev, false, 262 hnae3_match_n_instantiate(client, ae_dev, false);
284 &matched);
285 if (matched)
286 break;
287 }
288 263
289 ae_algo->ops->uninit_ae_dev(ae_dev); 264 ae_algo->ops->uninit_ae_dev(ae_dev);
290 hnae_set_bit(ae_dev->flag, HNAE3_DEV_INITED_B, 0); 265 hnae_set_bit(ae_dev->flag, HNAE3_DEV_INITED_B, 0);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index b2f28ae81273..1a01cadfe5f3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -49,7 +49,17 @@
49#define HNAE3_CLASS_NAME_SIZE 16 49#define HNAE3_CLASS_NAME_SIZE 16
50 50
51#define HNAE3_DEV_INITED_B 0x0 51#define HNAE3_DEV_INITED_B 0x0
52#define HNAE_DEV_SUPPORT_ROCE_B 0x1 52#define HNAE3_DEV_SUPPORT_ROCE_B 0x1
53#define HNAE3_DEV_SUPPORT_DCB_B 0x2
54
55#define HNAE3_DEV_SUPPORT_ROCE_DCB_BITS (BIT(HNAE3_DEV_SUPPORT_DCB_B) |\
56 BIT(HNAE3_DEV_SUPPORT_ROCE_B))
57
58#define hnae3_dev_roce_supported(hdev) \
59 hnae_get_bit(hdev->ae_dev->flag, HNAE3_DEV_SUPPORT_ROCE_B)
60
61#define hnae3_dev_dcb_supported(hdev) \
62 hnae_get_bit(hdev->ae_dev->flag, HNAE3_DEV_SUPPORT_DCB_B)
53 63
54#define ring_ptr_move_fw(ring, p) \ 64#define ring_ptr_move_fw(ring, p) \
55 ((ring)->p = ((ring)->p + 1) % (ring)->desc_num) 65 ((ring)->p = ((ring)->p + 1) % (ring)->desc_num)
@@ -366,12 +376,12 @@ struct hnae3_ae_algo {
366struct hnae3_tc_info { 376struct hnae3_tc_info {
367 u16 tqp_offset; /* TQP offset from base TQP */ 377 u16 tqp_offset; /* TQP offset from base TQP */
368 u16 tqp_count; /* Total TQPs */ 378 u16 tqp_count; /* Total TQPs */
369 u8 up; /* user priority */
370 u8 tc; /* TC index */ 379 u8 tc; /* TC index */
371 bool enable; /* If this TC is enable or not */ 380 bool enable; /* If this TC is enable or not */
372}; 381};
373 382
374#define HNAE3_MAX_TC 8 383#define HNAE3_MAX_TC 8
384#define HNAE3_MAX_USER_PRIO 8
375struct hnae3_knic_private_info { 385struct hnae3_knic_private_info {
376 struct net_device *netdev; /* Set by KNIC client when init instance */ 386 struct net_device *netdev; /* Set by KNIC client when init instance */
377 u16 rss_size; /* Allocated RSS queues */ 387 u16 rss_size; /* Allocated RSS queues */
@@ -379,6 +389,7 @@ struct hnae3_knic_private_info {
379 u16 num_desc; 389 u16 num_desc;
380 390
381 u8 num_tc; /* Total number of enabled TCs */ 391 u8 num_tc; /* Total number of enabled TCs */
392 u8 prio_tc[HNAE3_MAX_USER_PRIO]; /* TC indexed by prio */
382 struct hnae3_tc_info tc_info[HNAE3_MAX_TC]; /* Idx of array is HW TC */ 393 struct hnae3_tc_info tc_info[HNAE3_MAX_TC]; /* Idx of array is HW TC */
383 394
384 u16 num_tqps; /* total number of TQPs in this handle */ 395 u16 num_tqps; /* total number of TQPs in this handle */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
index 91ae0135ee50..758cf3948131 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
@@ -238,7 +238,7 @@ struct hclge_tqp_map {
238 u8 rsv[18]; 238 u8 rsv[18];
239}; 239};
240 240
241#define HCLGE_VECTOR_ELEMENTS_PER_CMD 11 241#define HCLGE_VECTOR_ELEMENTS_PER_CMD 10
242 242
243enum hclge_int_type { 243enum hclge_int_type {
244 HCLGE_INT_TX, 244 HCLGE_INT_TX,
@@ -252,8 +252,12 @@ struct hclge_ctrl_vector_chain {
252#define HCLGE_INT_TYPE_S 0 252#define HCLGE_INT_TYPE_S 0
253#define HCLGE_INT_TYPE_M 0x3 253#define HCLGE_INT_TYPE_M 0x3
254#define HCLGE_TQP_ID_S 2 254#define HCLGE_TQP_ID_S 2
255#define HCLGE_TQP_ID_M (0x3fff << HCLGE_TQP_ID_S) 255#define HCLGE_TQP_ID_M (0x7ff << HCLGE_TQP_ID_S)
256#define HCLGE_INT_GL_IDX_S 13
257#define HCLGE_INT_GL_IDX_M (0x3 << HCLGE_INT_GL_IDX_S)
256 __le16 tqp_type_and_id[HCLGE_VECTOR_ELEMENTS_PER_CMD]; 258 __le16 tqp_type_and_id[HCLGE_VECTOR_ELEMENTS_PER_CMD];
259 u8 vfid;
260 u8 rsv;
257}; 261};
258 262
259#define HCLGE_TC_NUM 8 263#define HCLGE_TC_NUM 8
@@ -266,7 +270,8 @@ struct hclge_tx_buff_alloc {
266 270
267struct hclge_rx_priv_buff { 271struct hclge_rx_priv_buff {
268 __le16 buf_num[HCLGE_TC_NUM]; 272 __le16 buf_num[HCLGE_TC_NUM];
269 u8 rsv[8]; 273 __le16 shared_buf;
274 u8 rsv[6];
270}; 275};
271 276
272struct hclge_query_version { 277struct hclge_query_version {
@@ -684,6 +689,7 @@ struct hclge_reset_tqp_queue {
684#define HCLGE_DEFAULT_TX_BUF 0x4000 /* 16k bytes */ 689#define HCLGE_DEFAULT_TX_BUF 0x4000 /* 16k bytes */
685#define HCLGE_TOTAL_PKT_BUF 0x108000 /* 1.03125M bytes */ 690#define HCLGE_TOTAL_PKT_BUF 0x108000 /* 1.03125M bytes */
686#define HCLGE_DEFAULT_DV 0xA000 /* 40k byte */ 691#define HCLGE_DEFAULT_DV 0xA000 /* 40k byte */
692#define HCLGE_DEFAULT_NON_DCB_DV 0x7800 /* 30K byte */
687 693
688#define HCLGE_TYPE_CRQ 0 694#define HCLGE_TYPE_CRQ 0
689#define HCLGE_TYPE_CSQ 1 695#define HCLGE_TYPE_CSQ 1
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index bb45365fb817..e0685e630afe 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -46,17 +46,7 @@ static const struct pci_device_id ae_algo_pci_tbl[] = {
46 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA), 0}, 46 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA), 0},
47 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA_MACSEC), 0}, 47 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA_MACSEC), 0},
48 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC), 0}, 48 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC), 0},
49 /* Required last entry */ 49 /* required last entry */
50 {0, }
51};
52
53static const struct pci_device_id roce_pci_tbl[] = {
54 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA), 0},
55 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA_MACSEC), 0},
56 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA), 0},
57 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA_MACSEC), 0},
58 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC), 0},
59 /* Required last entry */
60 {0, } 50 {0, }
61}; 51};
62 52
@@ -894,7 +884,7 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev)
894 hdev->num_tqps = __le16_to_cpu(req->tqp_num); 884 hdev->num_tqps = __le16_to_cpu(req->tqp_num);
895 hdev->pkt_buf_size = __le16_to_cpu(req->buf_size) << HCLGE_BUF_UNIT_S; 885 hdev->pkt_buf_size = __le16_to_cpu(req->buf_size) << HCLGE_BUF_UNIT_S;
896 886
897 if (hnae_get_bit(hdev->ae_dev->flag, HNAE_DEV_SUPPORT_ROCE_B)) { 887 if (hnae3_dev_roce_supported(hdev)) {
898 hdev->num_roce_msix = 888 hdev->num_roce_msix =
899 hnae_get_field(__le16_to_cpu(req->pf_intr_vector_number), 889 hnae_get_field(__le16_to_cpu(req->pf_intr_vector_number),
900 HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S); 890 HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S);
@@ -1063,9 +1053,9 @@ static int hclge_configure(struct hclge_dev *hdev)
1063 hdev->base_tqp_pid = 0; 1053 hdev->base_tqp_pid = 0;
1064 hdev->rss_size_max = 1; 1054 hdev->rss_size_max = 1;
1065 hdev->rx_buf_len = cfg.rx_buf_len; 1055 hdev->rx_buf_len = cfg.rx_buf_len;
1066 for (i = 0; i < ETH_ALEN; i++) 1056 ether_addr_copy(hdev->hw.mac.mac_addr, cfg.mac_addr);
1067 hdev->hw.mac.mac_addr[i] = cfg.mac_addr[i];
1068 hdev->hw.mac.media_type = cfg.media_type; 1057 hdev->hw.mac.media_type = cfg.media_type;
1058 hdev->hw.mac.phy_addr = cfg.phy_addr;
1069 hdev->num_desc = cfg.tqp_desc_num; 1059 hdev->num_desc = cfg.tqp_desc_num;
1070 hdev->tm_info.num_pg = 1; 1060 hdev->tm_info.num_pg = 1;
1071 hdev->tm_info.num_tc = cfg.tc_num; 1061 hdev->tm_info.num_tc = cfg.tc_num;
@@ -1454,7 +1444,11 @@ static bool hclge_is_rx_buf_ok(struct hclge_dev *hdev, u32 rx_all)
1454 tc_num = hclge_get_tc_num(hdev); 1444 tc_num = hclge_get_tc_num(hdev);
1455 pfc_enable_num = hclge_get_pfc_enalbe_num(hdev); 1445 pfc_enable_num = hclge_get_pfc_enalbe_num(hdev);
1456 1446
1457 shared_buf_min = 2 * hdev->mps + HCLGE_DEFAULT_DV; 1447 if (hnae3_dev_dcb_supported(hdev))
1448 shared_buf_min = 2 * hdev->mps + HCLGE_DEFAULT_DV;
1449 else
1450 shared_buf_min = 2 * hdev->mps + HCLGE_DEFAULT_NON_DCB_DV;
1451
1458 shared_buf_tc = pfc_enable_num * hdev->mps + 1452 shared_buf_tc = pfc_enable_num * hdev->mps +
1459 (tc_num - pfc_enable_num) * hdev->mps / 2 + 1453 (tc_num - pfc_enable_num) * hdev->mps / 2 +
1460 hdev->mps; 1454 hdev->mps;
@@ -1495,6 +1489,16 @@ int hclge_rx_buffer_calc(struct hclge_dev *hdev, u32 tx_size)
1495 struct hclge_priv_buf *priv; 1489 struct hclge_priv_buf *priv;
1496 int i; 1490 int i;
1497 1491
1492 /* When DCB is not supported, rx private
1493 * buffer is not allocated.
1494 */
1495 if (!hnae3_dev_dcb_supported(hdev)) {
1496 if (!hclge_is_rx_buf_ok(hdev, rx_all))
1497 return -ENOMEM;
1498
1499 return 0;
1500 }
1501
1498 /* step 1, try to alloc private buffer for all enabled tc */ 1502 /* step 1, try to alloc private buffer for all enabled tc */
1499 for (i = 0; i < HCLGE_MAX_TC_NUM; i++) { 1503 for (i = 0; i < HCLGE_MAX_TC_NUM; i++) {
1500 priv = &hdev->priv_buf[i]; 1504 priv = &hdev->priv_buf[i];
@@ -1510,6 +1514,11 @@ int hclge_rx_buffer_calc(struct hclge_dev *hdev, u32 tx_size)
1510 priv->wl.high = 2 * hdev->mps; 1514 priv->wl.high = 2 * hdev->mps;
1511 priv->buf_size = priv->wl.high; 1515 priv->buf_size = priv->wl.high;
1512 } 1516 }
1517 } else {
1518 priv->enable = 0;
1519 priv->wl.low = 0;
1520 priv->wl.high = 0;
1521 priv->buf_size = 0;
1513 } 1522 }
1514 } 1523 }
1515 1524
@@ -1522,8 +1531,15 @@ int hclge_rx_buffer_calc(struct hclge_dev *hdev, u32 tx_size)
1522 for (i = 0; i < HCLGE_MAX_TC_NUM; i++) { 1531 for (i = 0; i < HCLGE_MAX_TC_NUM; i++) {
1523 priv = &hdev->priv_buf[i]; 1532 priv = &hdev->priv_buf[i];
1524 1533
1525 if (hdev->hw_tc_map & BIT(i)) 1534 priv->enable = 0;
1526 priv->enable = 1; 1535 priv->wl.low = 0;
1536 priv->wl.high = 0;
1537 priv->buf_size = 0;
1538
1539 if (!(hdev->hw_tc_map & BIT(i)))
1540 continue;
1541
1542 priv->enable = 1;
1527 1543
1528 if (hdev->tm_info.hw_pfc_map & BIT(i)) { 1544 if (hdev->tm_info.hw_pfc_map & BIT(i)) {
1529 priv->wl.low = 128; 1545 priv->wl.low = 128;
@@ -1616,6 +1632,10 @@ static int hclge_rx_priv_buf_alloc(struct hclge_dev *hdev)
1616 cpu_to_le16(true << HCLGE_TC0_PRI_BUF_EN_B); 1632 cpu_to_le16(true << HCLGE_TC0_PRI_BUF_EN_B);
1617 } 1633 }
1618 1634
1635 req->shared_buf =
1636 cpu_to_le16((hdev->s_buf.buf_size >> HCLGE_BUF_UNIT_S) |
1637 (1 << HCLGE_TC0_PRI_BUF_EN_B));
1638
1619 ret = hclge_cmd_send(&hdev->hw, &desc, 1); 1639 ret = hclge_cmd_send(&hdev->hw, &desc, 1);
1620 if (ret) { 1640 if (ret) {
1621 dev_err(&hdev->pdev->dev, 1641 dev_err(&hdev->pdev->dev,
@@ -1782,18 +1802,22 @@ int hclge_buffer_alloc(struct hclge_dev *hdev)
1782 return ret; 1802 return ret;
1783 } 1803 }
1784 1804
1785 ret = hclge_rx_priv_wl_config(hdev); 1805 if (hnae3_dev_dcb_supported(hdev)) {
1786 if (ret) { 1806 ret = hclge_rx_priv_wl_config(hdev);
1787 dev_err(&hdev->pdev->dev, 1807 if (ret) {
1788 "could not configure rx private waterline %d\n", ret); 1808 dev_err(&hdev->pdev->dev,
1789 return ret; 1809 "could not configure rx private waterline %d\n",
1790 } 1810 ret);
1811 return ret;
1812 }
1791 1813
1792 ret = hclge_common_thrd_config(hdev); 1814 ret = hclge_common_thrd_config(hdev);
1793 if (ret) { 1815 if (ret) {
1794 dev_err(&hdev->pdev->dev, 1816 dev_err(&hdev->pdev->dev,
1795 "could not configure common threshold %d\n", ret); 1817 "could not configure common threshold %d\n",
1796 return ret; 1818 ret);
1819 return ret;
1820 }
1797 } 1821 }
1798 1822
1799 ret = hclge_common_wl_config(hdev); 1823 ret = hclge_common_wl_config(hdev);
@@ -2582,6 +2606,7 @@ static int hclge_rss_init_hw(struct hclge_dev *hdev)
2582 u16 tc_valid[HCLGE_MAX_TC_NUM]; 2606 u16 tc_valid[HCLGE_MAX_TC_NUM];
2583 u16 tc_size[HCLGE_MAX_TC_NUM]; 2607 u16 tc_size[HCLGE_MAX_TC_NUM];
2584 u32 *rss_indir = NULL; 2608 u32 *rss_indir = NULL;
2609 u16 rss_size = 0, roundup_size;
2585 const u8 *key; 2610 const u8 *key;
2586 int i, ret, j; 2611 int i, ret, j;
2587 2612
@@ -2596,7 +2621,13 @@ static int hclge_rss_init_hw(struct hclge_dev *hdev)
2596 for (j = 0; j < hdev->num_vmdq_vport + 1; j++) { 2621 for (j = 0; j < hdev->num_vmdq_vport + 1; j++) {
2597 for (i = 0; i < HCLGE_RSS_IND_TBL_SIZE; i++) { 2622 for (i = 0; i < HCLGE_RSS_IND_TBL_SIZE; i++) {
2598 vport[j].rss_indirection_tbl[i] = 2623 vport[j].rss_indirection_tbl[i] =
2599 i % hdev->rss_size_max; 2624 i % vport[j].alloc_rss_size;
2625
2626 /* vport 0 is for PF */
2627 if (j != 0)
2628 continue;
2629
2630 rss_size = vport[j].alloc_rss_size;
2600 rss_indir[i] = vport[j].rss_indirection_tbl[i]; 2631 rss_indir[i] = vport[j].rss_indirection_tbl[i];
2601 } 2632 }
2602 } 2633 }
@@ -2613,42 +2644,31 @@ static int hclge_rss_init_hw(struct hclge_dev *hdev)
2613 if (ret) 2644 if (ret)
2614 goto err; 2645 goto err;
2615 2646
2647 /* Each TC have the same queue size, and tc_size set to hardware is
2648 * the log2 of roundup power of two of rss_size, the acutal queue
2649 * size is limited by indirection table.
2650 */
2651 if (rss_size > HCLGE_RSS_TC_SIZE_7 || rss_size == 0) {
2652 dev_err(&hdev->pdev->dev,
2653 "Configure rss tc size failed, invalid TC_SIZE = %d\n",
2654 rss_size);
2655 return -EINVAL;
2656 }
2657
2658 roundup_size = roundup_pow_of_two(rss_size);
2659 roundup_size = ilog2(roundup_size);
2660
2616 for (i = 0; i < HCLGE_MAX_TC_NUM; i++) { 2661 for (i = 0; i < HCLGE_MAX_TC_NUM; i++) {
2617 if (hdev->hw_tc_map & BIT(i)) 2662 tc_valid[i] = 0;
2618 tc_valid[i] = 1;
2619 else
2620 tc_valid[i] = 0;
2621 2663
2622 switch (hdev->rss_size_max) { 2664 if (!(hdev->hw_tc_map & BIT(i)))
2623 case HCLGE_RSS_TC_SIZE_0: 2665 continue;
2624 tc_size[i] = 0; 2666
2625 break; 2667 tc_valid[i] = 1;
2626 case HCLGE_RSS_TC_SIZE_1: 2668 tc_size[i] = roundup_size;
2627 tc_size[i] = 1; 2669 tc_offset[i] = rss_size * i;
2628 break;
2629 case HCLGE_RSS_TC_SIZE_2:
2630 tc_size[i] = 2;
2631 break;
2632 case HCLGE_RSS_TC_SIZE_3:
2633 tc_size[i] = 3;
2634 break;
2635 case HCLGE_RSS_TC_SIZE_4:
2636 tc_size[i] = 4;
2637 break;
2638 case HCLGE_RSS_TC_SIZE_5:
2639 tc_size[i] = 5;
2640 break;
2641 case HCLGE_RSS_TC_SIZE_6:
2642 tc_size[i] = 6;
2643 break;
2644 case HCLGE_RSS_TC_SIZE_7:
2645 tc_size[i] = 7;
2646 break;
2647 default:
2648 break;
2649 }
2650 tc_offset[i] = hdev->rss_size_max * i;
2651 } 2670 }
2671
2652 ret = hclge_set_rss_tc_mode(hdev, tc_valid, tc_size, tc_offset); 2672 ret = hclge_set_rss_tc_mode(hdev, tc_valid, tc_size, tc_offset);
2653 2673
2654err: 2674err:
@@ -2679,7 +2699,11 @@ int hclge_map_vport_ring_to_vector(struct hclge_vport *vport, int vector_id,
2679 hnae_get_bit(node->flag, HNAE3_RING_TYPE_B)); 2699 hnae_get_bit(node->flag, HNAE3_RING_TYPE_B));
2680 hnae_set_field(req->tqp_type_and_id[i], HCLGE_TQP_ID_M, 2700 hnae_set_field(req->tqp_type_and_id[i], HCLGE_TQP_ID_M,
2681 HCLGE_TQP_ID_S, node->tqp_index); 2701 HCLGE_TQP_ID_S, node->tqp_index);
2702 hnae_set_field(req->tqp_type_and_id[i], HCLGE_INT_GL_IDX_M,
2703 HCLGE_INT_GL_IDX_S,
2704 hnae_get_bit(node->flag, HNAE3_RING_TYPE_B));
2682 req->tqp_type_and_id[i] = cpu_to_le16(req->tqp_type_and_id[i]); 2705 req->tqp_type_and_id[i] = cpu_to_le16(req->tqp_type_and_id[i]);
2706 req->vfid = vport->vport_id;
2683 2707
2684 if (++i >= HCLGE_VECTOR_ELEMENTS_PER_CMD) { 2708 if (++i >= HCLGE_VECTOR_ELEMENTS_PER_CMD) {
2685 req->int_cause_num = HCLGE_VECTOR_ELEMENTS_PER_CMD; 2709 req->int_cause_num = HCLGE_VECTOR_ELEMENTS_PER_CMD;
@@ -2763,8 +2787,12 @@ static int hclge_unmap_ring_from_vector(
2763 hnae_get_bit(node->flag, HNAE3_RING_TYPE_B)); 2787 hnae_get_bit(node->flag, HNAE3_RING_TYPE_B));
2764 hnae_set_field(req->tqp_type_and_id[i], HCLGE_TQP_ID_M, 2788 hnae_set_field(req->tqp_type_and_id[i], HCLGE_TQP_ID_M,
2765 HCLGE_TQP_ID_S, node->tqp_index); 2789 HCLGE_TQP_ID_S, node->tqp_index);
2790 hnae_set_field(req->tqp_type_and_id[i], HCLGE_INT_GL_IDX_M,
2791 HCLGE_INT_GL_IDX_S,
2792 hnae_get_bit(node->flag, HNAE3_RING_TYPE_B));
2766 2793
2767 req->tqp_type_and_id[i] = cpu_to_le16(req->tqp_type_and_id[i]); 2794 req->tqp_type_and_id[i] = cpu_to_le16(req->tqp_type_and_id[i]);
2795 req->vfid = vport->vport_id;
2768 2796
2769 if (++i >= HCLGE_VECTOR_ELEMENTS_PER_CMD) { 2797 if (++i >= HCLGE_VECTOR_ELEMENTS_PER_CMD) {
2770 req->int_cause_num = HCLGE_VECTOR_ELEMENTS_PER_CMD; 2798 req->int_cause_num = HCLGE_VECTOR_ELEMENTS_PER_CMD;
@@ -2778,7 +2806,7 @@ static int hclge_unmap_ring_from_vector(
2778 } 2806 }
2779 i = 0; 2807 i = 0;
2780 hclge_cmd_setup_basic_desc(&desc, 2808 hclge_cmd_setup_basic_desc(&desc,
2781 HCLGE_OPC_ADD_RING_TO_VECTOR, 2809 HCLGE_OPC_DEL_RING_TO_VECTOR,
2782 false); 2810 false);
2783 req->int_vector_id = vector_id; 2811 req->int_vector_id = vector_id;
2784 } 2812 }
@@ -3665,6 +3693,7 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
3665{ 3693{
3666#define HCLGE_VLAN_TYPE_VF_TABLE 0 3694#define HCLGE_VLAN_TYPE_VF_TABLE 0
3667#define HCLGE_VLAN_TYPE_PORT_TABLE 1 3695#define HCLGE_VLAN_TYPE_PORT_TABLE 1
3696 struct hnae3_handle *handle;
3668 int ret; 3697 int ret;
3669 3698
3670 ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_VLAN_TYPE_VF_TABLE, 3699 ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_VLAN_TYPE_VF_TABLE,
@@ -3674,8 +3703,11 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
3674 3703
3675 ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_VLAN_TYPE_PORT_TABLE, 3704 ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_VLAN_TYPE_PORT_TABLE,
3676 true); 3705 true);
3706 if (ret)
3707 return ret;
3677 3708
3678 return ret; 3709 handle = &hdev->vport[0].nic;
3710 return hclge_set_port_vlan_filter(handle, htons(ETH_P_8021Q), 0, false);
3679} 3711}
3680 3712
3681static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu) 3713static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu)
@@ -3920,8 +3952,7 @@ static int hclge_init_client_instance(struct hnae3_client *client,
3920 goto err; 3952 goto err;
3921 3953
3922 if (hdev->roce_client && 3954 if (hdev->roce_client &&
3923 hnae_get_bit(hdev->ae_dev->flag, 3955 hnae3_dev_roce_supported(hdev)) {
3924 HNAE_DEV_SUPPORT_ROCE_B)) {
3925 struct hnae3_client *rc = hdev->roce_client; 3956 struct hnae3_client *rc = hdev->roce_client;
3926 3957
3927 ret = hclge_init_roce_base_info(vport); 3958 ret = hclge_init_roce_base_info(vport);
@@ -3944,8 +3975,7 @@ static int hclge_init_client_instance(struct hnae3_client *client,
3944 3975
3945 break; 3976 break;
3946 case HNAE3_CLIENT_ROCE: 3977 case HNAE3_CLIENT_ROCE:
3947 if (hnae_get_bit(hdev->ae_dev->flag, 3978 if (hnae3_dev_roce_supported(hdev)) {
3948 HNAE_DEV_SUPPORT_ROCE_B)) {
3949 hdev->roce_client = client; 3979 hdev->roce_client = client;
3950 vport->roce.client = client; 3980 vport->roce.client = client;
3951 } 3981 }
@@ -4057,7 +4087,6 @@ static void hclge_pci_uninit(struct hclge_dev *hdev)
4057static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) 4087static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
4058{ 4088{
4059 struct pci_dev *pdev = ae_dev->pdev; 4089 struct pci_dev *pdev = ae_dev->pdev;
4060 const struct pci_device_id *id;
4061 struct hclge_dev *hdev; 4090 struct hclge_dev *hdev;
4062 int ret; 4091 int ret;
4063 4092
@@ -4072,10 +4101,6 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
4072 hdev->ae_dev = ae_dev; 4101 hdev->ae_dev = ae_dev;
4073 ae_dev->priv = hdev; 4102 ae_dev->priv = hdev;
4074 4103
4075 id = pci_match_id(roce_pci_tbl, ae_dev->pdev);
4076 if (id)
4077 hnae_set_bit(ae_dev->flag, HNAE_DEV_SUPPORT_ROCE_B, 1);
4078
4079 ret = hclge_pci_init(hdev); 4104 ret = hclge_pci_init(hdev);
4080 if (ret) { 4105 if (ret) {
4081 dev_err(&pdev->dev, "PCI init failed\n"); 4106 dev_err(&pdev->dev, "PCI init failed\n");
@@ -4138,12 +4163,6 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
4138 return ret; 4163 return ret;
4139 } 4164 }
4140 4165
4141 ret = hclge_rss_init_hw(hdev);
4142 if (ret) {
4143 dev_err(&pdev->dev, "Rss init fail, ret =%d\n", ret);
4144 return ret;
4145 }
4146
4147 ret = hclge_init_vlan_config(hdev); 4166 ret = hclge_init_vlan_config(hdev);
4148 if (ret) { 4167 if (ret) {
4149 dev_err(&pdev->dev, "VLAN init fail, ret =%d\n", ret); 4168 dev_err(&pdev->dev, "VLAN init fail, ret =%d\n", ret);
@@ -4156,6 +4175,12 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
4156 return ret; 4175 return ret;
4157 } 4176 }
4158 4177
4178 ret = hclge_rss_init_hw(hdev);
4179 if (ret) {
4180 dev_err(&pdev->dev, "Rss init fail, ret =%d\n", ret);
4181 return ret;
4182 }
4183
4159 setup_timer(&hdev->service_timer, hclge_service_timer, 4184 setup_timer(&hdev->service_timer, hclge_service_timer,
4160 (unsigned long)hdev); 4185 (unsigned long)hdev);
4161 INIT_WORK(&hdev->service_task, hclge_service_task); 4186 INIT_WORK(&hdev->service_task, hclge_service_task);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index edb10ad075eb..9fcfd9395424 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -176,7 +176,6 @@ struct hclge_pg_info {
176struct hclge_tc_info { 176struct hclge_tc_info {
177 u8 tc_id; 177 u8 tc_id;
178 u8 tc_sch_mode; /* 0: sp; 1: dwrr */ 178 u8 tc_sch_mode; /* 0: sp; 1: dwrr */
179 u8 up;
180 u8 pgid; 179 u8 pgid;
181 u32 bw_limit; 180 u32 bw_limit;
182}; 181};
@@ -197,6 +196,7 @@ struct hclge_tm_info {
197 u8 num_tc; 196 u8 num_tc;
198 u8 num_pg; /* It must be 1 if vNET-Base schd */ 197 u8 num_pg; /* It must be 1 if vNET-Base schd */
199 u8 pg_dwrr[HCLGE_PG_NUM]; 198 u8 pg_dwrr[HCLGE_PG_NUM];
199 u8 prio_tc[HNAE3_MAX_USER_PRIO];
200 struct hclge_pg_info pg_info[HCLGE_PG_NUM]; 200 struct hclge_pg_info pg_info[HCLGE_PG_NUM];
201 struct hclge_tc_info tc_info[HNAE3_MAX_TC]; 201 struct hclge_tc_info tc_info[HNAE3_MAX_TC];
202 enum hclge_fc_mode fc_mode; 202 enum hclge_fc_mode fc_mode;
@@ -477,6 +477,7 @@ struct hclge_vport {
477 u8 rss_hash_key[HCLGE_RSS_KEY_SIZE]; /* User configured hash keys */ 477 u8 rss_hash_key[HCLGE_RSS_KEY_SIZE]; /* User configured hash keys */
478 /* User configured lookup table entries */ 478 /* User configured lookup table entries */
479 u8 rss_indirection_tbl[HCLGE_RSS_IND_TBL_SIZE]; 479 u8 rss_indirection_tbl[HCLGE_RSS_IND_TBL_SIZE];
480 u16 alloc_rss_size;
480 481
481 u16 qs_offset; 482 u16 qs_offset;
482 u16 bw_limit; /* VSI BW Limit (0 = disabled) */ 483 u16 bw_limit; /* VSI BW Limit (0 = disabled) */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
index 1c577d268f00..73a75d7cc551 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
@@ -128,9 +128,7 @@ static int hclge_fill_pri_array(struct hclge_dev *hdev, u8 *pri, u8 pri_id)
128{ 128{
129 u8 tc; 129 u8 tc;
130 130
131 for (tc = 0; tc < hdev->tm_info.num_tc; tc++) 131 tc = hdev->tm_info.prio_tc[pri_id];
132 if (hdev->tm_info.tc_info[tc].up == pri_id)
133 break;
134 132
135 if (tc >= hdev->tm_info.num_tc) 133 if (tc >= hdev->tm_info.num_tc)
136 return -EINVAL; 134 return -EINVAL;
@@ -158,7 +156,7 @@ static int hclge_up_to_tc_map(struct hclge_dev *hdev)
158 156
159 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_PRI_TO_TC_MAPPING, false); 157 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_PRI_TO_TC_MAPPING, false);
160 158
161 for (pri_id = 0; pri_id < hdev->tm_info.num_tc; pri_id++) { 159 for (pri_id = 0; pri_id < HNAE3_MAX_USER_PRIO; pri_id++) {
162 ret = hclge_fill_pri_array(hdev, pri, pri_id); 160 ret = hclge_fill_pri_array(hdev, pri, pri_id);
163 if (ret) 161 if (ret)
164 return ret; 162 return ret;
@@ -280,11 +278,11 @@ static int hclge_tm_pg_shapping_cfg(struct hclge_dev *hdev,
280 278
281 shap_cfg_cmd->pg_id = pg_id; 279 shap_cfg_cmd->pg_id = pg_id;
282 280
283 hclge_tm_set_feild(shap_cfg_cmd->pg_shapping_para, IR_B, ir_b); 281 hclge_tm_set_field(shap_cfg_cmd->pg_shapping_para, IR_B, ir_b);
284 hclge_tm_set_feild(shap_cfg_cmd->pg_shapping_para, IR_U, ir_u); 282 hclge_tm_set_field(shap_cfg_cmd->pg_shapping_para, IR_U, ir_u);
285 hclge_tm_set_feild(shap_cfg_cmd->pg_shapping_para, IR_S, ir_s); 283 hclge_tm_set_field(shap_cfg_cmd->pg_shapping_para, IR_S, ir_s);
286 hclge_tm_set_feild(shap_cfg_cmd->pg_shapping_para, BS_B, bs_b); 284 hclge_tm_set_field(shap_cfg_cmd->pg_shapping_para, BS_B, bs_b);
287 hclge_tm_set_feild(shap_cfg_cmd->pg_shapping_para, BS_S, bs_s); 285 hclge_tm_set_field(shap_cfg_cmd->pg_shapping_para, BS_S, bs_s);
288 286
289 return hclge_cmd_send(&hdev->hw, &desc, 1); 287 return hclge_cmd_send(&hdev->hw, &desc, 1);
290} 288}
@@ -307,11 +305,11 @@ static int hclge_tm_pri_shapping_cfg(struct hclge_dev *hdev,
307 305
308 shap_cfg_cmd->pri_id = pri_id; 306 shap_cfg_cmd->pri_id = pri_id;
309 307
310 hclge_tm_set_feild(shap_cfg_cmd->pri_shapping_para, IR_B, ir_b); 308 hclge_tm_set_field(shap_cfg_cmd->pri_shapping_para, IR_B, ir_b);
311 hclge_tm_set_feild(shap_cfg_cmd->pri_shapping_para, IR_U, ir_u); 309 hclge_tm_set_field(shap_cfg_cmd->pri_shapping_para, IR_U, ir_u);
312 hclge_tm_set_feild(shap_cfg_cmd->pri_shapping_para, IR_S, ir_s); 310 hclge_tm_set_field(shap_cfg_cmd->pri_shapping_para, IR_S, ir_s);
313 hclge_tm_set_feild(shap_cfg_cmd->pri_shapping_para, BS_B, bs_b); 311 hclge_tm_set_field(shap_cfg_cmd->pri_shapping_para, BS_B, bs_b);
314 hclge_tm_set_feild(shap_cfg_cmd->pri_shapping_para, BS_S, bs_s); 312 hclge_tm_set_field(shap_cfg_cmd->pri_shapping_para, BS_S, bs_s);
315 313
316 return hclge_cmd_send(&hdev->hw, &desc, 1); 314 return hclge_cmd_send(&hdev->hw, &desc, 1);
317} 315}
@@ -397,6 +395,7 @@ static void hclge_tm_vport_tc_info_update(struct hclge_vport *vport)
397 kinfo->num_tqps / kinfo->num_tc); 395 kinfo->num_tqps / kinfo->num_tc);
398 vport->qs_offset = hdev->tm_info.num_tc * vport->vport_id; 396 vport->qs_offset = hdev->tm_info.num_tc * vport->vport_id;
399 vport->dwrr = 100; /* 100 percent as init */ 397 vport->dwrr = 100; /* 100 percent as init */
398 vport->alloc_rss_size = kinfo->rss_size;
400 399
401 for (i = 0; i < kinfo->num_tc; i++) { 400 for (i = 0; i < kinfo->num_tc; i++) {
402 if (hdev->hw_tc_map & BIT(i)) { 401 if (hdev->hw_tc_map & BIT(i)) {
@@ -404,16 +403,17 @@ static void hclge_tm_vport_tc_info_update(struct hclge_vport *vport)
404 kinfo->tc_info[i].tqp_offset = i * kinfo->rss_size; 403 kinfo->tc_info[i].tqp_offset = i * kinfo->rss_size;
405 kinfo->tc_info[i].tqp_count = kinfo->rss_size; 404 kinfo->tc_info[i].tqp_count = kinfo->rss_size;
406 kinfo->tc_info[i].tc = i; 405 kinfo->tc_info[i].tc = i;
407 kinfo->tc_info[i].up = hdev->tm_info.tc_info[i].up;
408 } else { 406 } else {
409 /* Set to default queue if TC is disable */ 407 /* Set to default queue if TC is disable */
410 kinfo->tc_info[i].enable = false; 408 kinfo->tc_info[i].enable = false;
411 kinfo->tc_info[i].tqp_offset = 0; 409 kinfo->tc_info[i].tqp_offset = 0;
412 kinfo->tc_info[i].tqp_count = 1; 410 kinfo->tc_info[i].tqp_count = 1;
413 kinfo->tc_info[i].tc = 0; 411 kinfo->tc_info[i].tc = 0;
414 kinfo->tc_info[i].up = 0;
415 } 412 }
416 } 413 }
414
415 memcpy(kinfo->prio_tc, hdev->tm_info.prio_tc,
416 FIELD_SIZEOF(struct hnae3_knic_private_info, prio_tc));
417} 417}
418 418
419static void hclge_tm_vport_info_update(struct hclge_dev *hdev) 419static void hclge_tm_vport_info_update(struct hclge_dev *hdev)
@@ -435,12 +435,15 @@ static void hclge_tm_tc_info_init(struct hclge_dev *hdev)
435 for (i = 0; i < hdev->tm_info.num_tc; i++) { 435 for (i = 0; i < hdev->tm_info.num_tc; i++) {
436 hdev->tm_info.tc_info[i].tc_id = i; 436 hdev->tm_info.tc_info[i].tc_id = i;
437 hdev->tm_info.tc_info[i].tc_sch_mode = HCLGE_SCH_MODE_DWRR; 437 hdev->tm_info.tc_info[i].tc_sch_mode = HCLGE_SCH_MODE_DWRR;
438 hdev->tm_info.tc_info[i].up = i;
439 hdev->tm_info.tc_info[i].pgid = 0; 438 hdev->tm_info.tc_info[i].pgid = 0;
440 hdev->tm_info.tc_info[i].bw_limit = 439 hdev->tm_info.tc_info[i].bw_limit =
441 hdev->tm_info.pg_info[0].bw_limit; 440 hdev->tm_info.pg_info[0].bw_limit;
442 } 441 }
443 442
443 for (i = 0; i < HNAE3_MAX_USER_PRIO; i++)
444 hdev->tm_info.prio_tc[i] =
445 (i >= hdev->tm_info.num_tc) ? 0 : i;
446
444 hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE; 447 hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
445} 448}
446 449
@@ -976,6 +979,10 @@ int hclge_pause_setup_hw(struct hclge_dev *hdev)
976 if (ret) 979 if (ret)
977 return ret; 980 return ret;
978 981
982 /* Only DCB-supported dev supports qset back pressure setting */
983 if (!hnae3_dev_dcb_supported(hdev))
984 return 0;
985
979 for (i = 0; i < hdev->tm_info.num_tc; i++) { 986 for (i = 0; i < hdev->tm_info.num_tc; i++) {
980 ret = hclge_tm_qs_bp_cfg(hdev, i); 987 ret = hclge_tm_qs_bp_cfg(hdev, i);
981 if (ret) 988 if (ret)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
index 7e67337dfaf2..85158b0d73fe 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
@@ -94,10 +94,10 @@ struct hclge_bp_to_qs_map_cmd {
94 u32 rsvd1; 94 u32 rsvd1;
95}; 95};
96 96
97#define hclge_tm_set_feild(dest, string, val) \ 97#define hclge_tm_set_field(dest, string, val) \
98 hnae_set_field((dest), (HCLGE_TM_SHAP_##string##_MSK), \ 98 hnae_set_field((dest), (HCLGE_TM_SHAP_##string##_MSK), \
99 (HCLGE_TM_SHAP_##string##_LSH), val) 99 (HCLGE_TM_SHAP_##string##_LSH), val)
100#define hclge_tm_get_feild(src, string) \ 100#define hclge_tm_get_field(src, string) \
101 hnae_get_field((src), (HCLGE_TM_SHAP_##string##_MSK), \ 101 hnae_get_field((src), (HCLGE_TM_SHAP_##string##_MSK), \
102 (HCLGE_TM_SHAP_##string##_LSH)) 102 (HCLGE_TM_SHAP_##string##_LSH))
103 103
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
index 1c3e29447891..35369e1c8036 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
@@ -41,11 +41,16 @@ static struct hnae3_client client;
41static const struct pci_device_id hns3_pci_tbl[] = { 41static const struct pci_device_id hns3_pci_tbl[] = {
42 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_GE), 0}, 42 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_GE), 0},
43 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE), 0}, 43 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE), 0},
44 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA), 0}, 44 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA),
45 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA_MACSEC), 0}, 45 HNAE3_DEV_SUPPORT_ROCE_DCB_BITS},
46 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA), 0}, 46 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA_MACSEC),
47 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA_MACSEC), 0}, 47 HNAE3_DEV_SUPPORT_ROCE_DCB_BITS},
48 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC), 0}, 48 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA),
49 HNAE3_DEV_SUPPORT_ROCE_DCB_BITS},
50 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA_MACSEC),
51 HNAE3_DEV_SUPPORT_ROCE_DCB_BITS},
52 {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC),
53 HNAE3_DEV_SUPPORT_ROCE_DCB_BITS},
49 /* required last entry */ 54 /* required last entry */
50 {0, } 55 {0, }
51}; 56};
@@ -1348,6 +1353,7 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1348 } 1353 }
1349 1354
1350 ae_dev->pdev = pdev; 1355 ae_dev->pdev = pdev;
1356 ae_dev->flag = ent->driver_data;
1351 ae_dev->dev_type = HNAE3_DEV_KNIC; 1357 ae_dev->dev_type = HNAE3_DEV_KNIC;
1352 pci_set_drvdata(pdev, ae_dev); 1358 pci_set_drvdata(pdev, ae_dev);
1353 1359
@@ -2705,10 +2711,11 @@ static void hns3_init_mac_addr(struct net_device *netdev)
2705 eth_hw_addr_random(netdev); 2711 eth_hw_addr_random(netdev);
2706 dev_warn(priv->dev, "using random MAC address %pM\n", 2712 dev_warn(priv->dev, "using random MAC address %pM\n",
2707 netdev->dev_addr); 2713 netdev->dev_addr);
2708 /* Also copy this new MAC address into hdev */
2709 if (h->ae_algo->ops->set_mac_addr)
2710 h->ae_algo->ops->set_mac_addr(h, netdev->dev_addr);
2711 } 2714 }
2715
2716 if (h->ae_algo->ops->set_mac_addr)
2717 h->ae_algo->ops->set_mac_addr(h, netdev->dev_addr);
2718
2712} 2719}
2713 2720
2714static void hns3_nic_set_priv_ops(struct net_device *netdev) 2721static void hns3_nic_set_priv_ops(struct net_device *netdev)
diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm/emac/mal.c
index 2c74baa2398a..fff09dcf9e34 100644
--- a/drivers/net/ethernet/ibm/emac/mal.c
+++ b/drivers/net/ethernet/ibm/emac/mal.c
@@ -402,7 +402,7 @@ static int mal_poll(struct napi_struct *napi, int budget)
402 unsigned long flags; 402 unsigned long flags;
403 403
404 MAL_DBG2(mal, "poll(%d)" NL, budget); 404 MAL_DBG2(mal, "poll(%d)" NL, budget);
405 again: 405
406 /* Process TX skbs */ 406 /* Process TX skbs */
407 list_for_each(l, &mal->poll_list) { 407 list_for_each(l, &mal->poll_list) {
408 struct mal_commac *mc = 408 struct mal_commac *mc =
@@ -451,7 +451,6 @@ static int mal_poll(struct napi_struct *napi, int budget)
451 spin_lock_irqsave(&mal->lock, flags); 451 spin_lock_irqsave(&mal->lock, flags);
452 mal_disable_eob_irq(mal); 452 mal_disable_eob_irq(mal);
453 spin_unlock_irqrestore(&mal->lock, flags); 453 spin_unlock_irqrestore(&mal->lock, flags);
454 goto again;
455 } 454 }
456 mc->ops->poll_tx(mc->dev); 455 mc->ops->poll_tx(mc->dev);
457 } 456 }
diff --git a/drivers/net/ethernet/qualcomm/emac/emac-ethtool.c b/drivers/net/ethernet/qualcomm/emac/emac-ethtool.c
index bbe24639aa5a..c8c6231b87f3 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-ethtool.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-ethtool.c
@@ -88,6 +88,8 @@ static void emac_set_msglevel(struct net_device *netdev, u32 data)
88static int emac_get_sset_count(struct net_device *netdev, int sset) 88static int emac_get_sset_count(struct net_device *netdev, int sset)
89{ 89{
90 switch (sset) { 90 switch (sset) {
91 case ETH_SS_PRIV_FLAGS:
92 return 1;
91 case ETH_SS_STATS: 93 case ETH_SS_STATS:
92 return EMAC_STATS_LEN; 94 return EMAC_STATS_LEN;
93 default: 95 default:
@@ -100,6 +102,10 @@ static void emac_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
100 unsigned int i; 102 unsigned int i;
101 103
102 switch (stringset) { 104 switch (stringset) {
105 case ETH_SS_PRIV_FLAGS:
106 strcpy(data, "single-pause-mode");
107 break;
108
103 case ETH_SS_STATS: 109 case ETH_SS_STATS:
104 for (i = 0; i < EMAC_STATS_LEN; i++) { 110 for (i = 0; i < EMAC_STATS_LEN; i++) {
105 strlcpy(data, emac_ethtool_stat_strings[i], 111 strlcpy(data, emac_ethtool_stat_strings[i],
@@ -230,6 +236,27 @@ static int emac_get_regs_len(struct net_device *netdev)
230 return EMAC_MAX_REG_SIZE * sizeof(u32); 236 return EMAC_MAX_REG_SIZE * sizeof(u32);
231} 237}
232 238
239#define EMAC_PRIV_ENABLE_SINGLE_PAUSE BIT(0)
240
241static int emac_set_priv_flags(struct net_device *netdev, u32 flags)
242{
243 struct emac_adapter *adpt = netdev_priv(netdev);
244
245 adpt->single_pause_mode = !!(flags & EMAC_PRIV_ENABLE_SINGLE_PAUSE);
246
247 if (netif_running(netdev))
248 return emac_reinit_locked(adpt);
249
250 return 0;
251}
252
253static u32 emac_get_priv_flags(struct net_device *netdev)
254{
255 struct emac_adapter *adpt = netdev_priv(netdev);
256
257 return adpt->single_pause_mode ? EMAC_PRIV_ENABLE_SINGLE_PAUSE : 0;
258}
259
233static const struct ethtool_ops emac_ethtool_ops = { 260static const struct ethtool_ops emac_ethtool_ops = {
234 .get_link_ksettings = phy_ethtool_get_link_ksettings, 261 .get_link_ksettings = phy_ethtool_get_link_ksettings,
235 .set_link_ksettings = phy_ethtool_set_link_ksettings, 262 .set_link_ksettings = phy_ethtool_set_link_ksettings,
@@ -253,6 +280,9 @@ static const struct ethtool_ops emac_ethtool_ops = {
253 280
254 .get_regs_len = emac_get_regs_len, 281 .get_regs_len = emac_get_regs_len,
255 .get_regs = emac_get_regs, 282 .get_regs = emac_get_regs,
283
284 .set_priv_flags = emac_set_priv_flags,
285 .get_priv_flags = emac_get_priv_flags,
256}; 286};
257 287
258void emac_set_ethtool_ops(struct net_device *netdev) 288void emac_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/ethernet/qualcomm/emac/emac-mac.c b/drivers/net/ethernet/qualcomm/emac/emac-mac.c
index bcd4708b3745..0ea3ca09c689 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-mac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-mac.c
@@ -551,6 +551,28 @@ static void emac_mac_start(struct emac_adapter *adpt)
551 mac &= ~(HUGEN | VLAN_STRIP | TPAUSE | SIMR | HUGE | MULTI_ALL | 551 mac &= ~(HUGEN | VLAN_STRIP | TPAUSE | SIMR | HUGE | MULTI_ALL |
552 DEBUG_MODE | SINGLE_PAUSE_MODE); 552 DEBUG_MODE | SINGLE_PAUSE_MODE);
553 553
554 /* Enable single-pause-frame mode if requested.
555 *
556 * If enabled, the EMAC will send a single pause frame when the RX
557 * queue is full. This normally leads to packet loss because
558 * the pause frame disables the remote MAC only for 33ms (the quanta),
559 * and then the remote MAC continues sending packets even though
560 * the RX queue is still full.
561 *
562 * If disabled, the EMAC sends a pause frame every 31ms until the RX
563 * queue is no longer full. Normally, this is the preferred
564 * method of operation. However, when the system is hung (e.g.
565 * cores are halted), the EMAC interrupt handler is never called
566 * and so the RX queue fills up quickly and stays full. The resuling
567 * non-stop "flood" of pause frames sometimes has the effect of
568 * disabling nearby switches. In some cases, other nearby switches
569 * are also affected, shutting down the entire network.
570 *
571 * The user can enable or disable single-pause-frame mode
572 * via ethtool.
573 */
574 mac |= adpt->single_pause_mode ? SINGLE_PAUSE_MODE : 0;
575
554 writel_relaxed(csr1, adpt->csr + EMAC_EMAC_WRAPPER_CSR1); 576 writel_relaxed(csr1, adpt->csr + EMAC_EMAC_WRAPPER_CSR1);
555 577
556 writel_relaxed(mac, adpt->base + EMAC_MAC_CTRL); 578 writel_relaxed(mac, adpt->base + EMAC_MAC_CTRL);
diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c
index 60850bfa3d32..759543512117 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac.c
@@ -443,6 +443,9 @@ static void emac_init_adapter(struct emac_adapter *adpt)
443 443
444 /* default to automatic flow control */ 444 /* default to automatic flow control */
445 adpt->automatic = true; 445 adpt->automatic = true;
446
447 /* Disable single-pause-frame mode by default */
448 adpt->single_pause_mode = false;
446} 449}
447 450
448/* Get the clock */ 451/* Get the clock */
diff --git a/drivers/net/ethernet/qualcomm/emac/emac.h b/drivers/net/ethernet/qualcomm/emac/emac.h
index 8ee4ec6aef2e..d7c9f44209d4 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac.h
+++ b/drivers/net/ethernet/qualcomm/emac/emac.h
@@ -363,6 +363,9 @@ struct emac_adapter {
363 bool tx_flow_control; 363 bool tx_flow_control;
364 bool rx_flow_control; 364 bool rx_flow_control;
365 365
366 /* True == use single-pause-frame mode. */
367 bool single_pause_mode;
368
366 /* Ring parameter */ 369 /* Ring parameter */
367 u8 tpd_burst; 370 u8 tpd_burst;
368 u8 rfd_burst; 371 u8 rfd_burst;
diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c
index ca22f2898664..d24b47b8e0b2 100644
--- a/drivers/net/ethernet/realtek/8139too.c
+++ b/drivers/net/ethernet/realtek/8139too.c
@@ -2135,11 +2135,12 @@ static int rtl8139_poll(struct napi_struct *napi, int budget)
2135 if (likely(RTL_R16(IntrStatus) & RxAckBits)) 2135 if (likely(RTL_R16(IntrStatus) & RxAckBits))
2136 work_done += rtl8139_rx(dev, tp, budget); 2136 work_done += rtl8139_rx(dev, tp, budget);
2137 2137
2138 if (work_done < budget && napi_complete_done(napi, work_done)) { 2138 if (work_done < budget) {
2139 unsigned long flags; 2139 unsigned long flags;
2140 2140
2141 spin_lock_irqsave(&tp->lock, flags); 2141 spin_lock_irqsave(&tp->lock, flags);
2142 RTL_W16_F(IntrMask, rtl8139_intr_mask); 2142 if (napi_complete_done(napi, work_done))
2143 RTL_W16_F(IntrMask, rtl8139_intr_mask);
2143 spin_unlock_irqrestore(&tp->lock, flags); 2144 spin_unlock_irqrestore(&tp->lock, flags);
2144 } 2145 }
2145 spin_unlock(&tp->rx_lock); 2146 spin_unlock(&tp->rx_lock);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index a366b3747eeb..8a280b48e3a9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -315,6 +315,7 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
315 { .compatible = "allwinner,sun8i-h3-emac" }, 315 { .compatible = "allwinner,sun8i-h3-emac" },
316 { .compatible = "allwinner,sun8i-v3s-emac" }, 316 { .compatible = "allwinner,sun8i-v3s-emac" },
317 { .compatible = "allwinner,sun50i-a64-emac" }, 317 { .compatible = "allwinner,sun50i-a64-emac" },
318 {},
318 }; 319 };
319 320
320 /* If phy-handle property is passed from DT, use it as the PHY */ 321 /* If phy-handle property is passed from DT, use it as the PHY */
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index d98cdfb1536b..5176be76ca7d 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -150,6 +150,8 @@ struct netvsc_device_info {
150 u32 num_chn; 150 u32 num_chn;
151 u32 send_sections; 151 u32 send_sections;
152 u32 recv_sections; 152 u32 recv_sections;
153 u32 send_section_size;
154 u32 recv_section_size;
153}; 155};
154 156
155enum rndis_device_state { 157enum rndis_device_state {
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index a5511b7326af..8d5077fb0492 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -76,9 +76,6 @@ static struct netvsc_device *alloc_net_device(void)
76 net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT; 76 net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
77 net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT; 77 net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
78 78
79 net_device->recv_section_size = NETVSC_RECV_SECTION_SIZE;
80 net_device->send_section_size = NETVSC_SEND_SECTION_SIZE;
81
82 init_completion(&net_device->channel_init_wait); 79 init_completion(&net_device->channel_init_wait);
83 init_waitqueue_head(&net_device->subchan_open); 80 init_waitqueue_head(&net_device->subchan_open);
84 INIT_WORK(&net_device->subchan_work, rndis_set_subchannel); 81 INIT_WORK(&net_device->subchan_work, rndis_set_subchannel);
@@ -262,7 +259,7 @@ static int netvsc_init_buf(struct hv_device *device,
262 int ret = 0; 259 int ret = 0;
263 260
264 /* Get receive buffer area. */ 261 /* Get receive buffer area. */
265 buf_size = device_info->recv_sections * net_device->recv_section_size; 262 buf_size = device_info->recv_sections * device_info->recv_section_size;
266 buf_size = roundup(buf_size, PAGE_SIZE); 263 buf_size = roundup(buf_size, PAGE_SIZE);
267 264
268 net_device->recv_buf = vzalloc(buf_size); 265 net_device->recv_buf = vzalloc(buf_size);
@@ -344,7 +341,7 @@ static int netvsc_init_buf(struct hv_device *device,
344 goto cleanup; 341 goto cleanup;
345 342
346 /* Now setup the send buffer. */ 343 /* Now setup the send buffer. */
347 buf_size = device_info->send_sections * net_device->send_section_size; 344 buf_size = device_info->send_sections * device_info->send_section_size;
348 buf_size = round_up(buf_size, PAGE_SIZE); 345 buf_size = round_up(buf_size, PAGE_SIZE);
349 346
350 net_device->send_buf = vzalloc(buf_size); 347 net_device->send_buf = vzalloc(buf_size);
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index d4902ee5f260..a32ae02e1b6c 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -848,7 +848,9 @@ static int netvsc_set_channels(struct net_device *net,
848 device_info.num_chn = count; 848 device_info.num_chn = count;
849 device_info.ring_size = ring_size; 849 device_info.ring_size = ring_size;
850 device_info.send_sections = nvdev->send_section_cnt; 850 device_info.send_sections = nvdev->send_section_cnt;
851 device_info.send_section_size = nvdev->send_section_size;
851 device_info.recv_sections = nvdev->recv_section_cnt; 852 device_info.recv_sections = nvdev->recv_section_cnt;
853 device_info.recv_section_size = nvdev->recv_section_size;
852 854
853 rndis_filter_device_remove(dev, nvdev); 855 rndis_filter_device_remove(dev, nvdev);
854 856
@@ -963,7 +965,9 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
963 device_info.ring_size = ring_size; 965 device_info.ring_size = ring_size;
964 device_info.num_chn = nvdev->num_chn; 966 device_info.num_chn = nvdev->num_chn;
965 device_info.send_sections = nvdev->send_section_cnt; 967 device_info.send_sections = nvdev->send_section_cnt;
968 device_info.send_section_size = nvdev->send_section_size;
966 device_info.recv_sections = nvdev->recv_section_cnt; 969 device_info.recv_sections = nvdev->recv_section_cnt;
970 device_info.recv_section_size = nvdev->recv_section_size;
967 971
968 rndis_filter_device_remove(hdev, nvdev); 972 rndis_filter_device_remove(hdev, nvdev);
969 973
@@ -1485,7 +1489,9 @@ static int netvsc_set_ringparam(struct net_device *ndev,
1485 device_info.num_chn = nvdev->num_chn; 1489 device_info.num_chn = nvdev->num_chn;
1486 device_info.ring_size = ring_size; 1490 device_info.ring_size = ring_size;
1487 device_info.send_sections = new_tx; 1491 device_info.send_sections = new_tx;
1492 device_info.send_section_size = nvdev->send_section_size;
1488 device_info.recv_sections = new_rx; 1493 device_info.recv_sections = new_rx;
1494 device_info.recv_section_size = nvdev->recv_section_size;
1489 1495
1490 netif_device_detach(ndev); 1496 netif_device_detach(ndev);
1491 was_opened = rndis_filter_opened(nvdev); 1497 was_opened = rndis_filter_opened(nvdev);
@@ -1934,7 +1940,9 @@ static int netvsc_probe(struct hv_device *dev,
1934 device_info.ring_size = ring_size; 1940 device_info.ring_size = ring_size;
1935 device_info.num_chn = VRSS_CHANNEL_DEFAULT; 1941 device_info.num_chn = VRSS_CHANNEL_DEFAULT;
1936 device_info.send_sections = NETVSC_DEFAULT_TX; 1942 device_info.send_sections = NETVSC_DEFAULT_TX;
1943 device_info.send_section_size = NETVSC_SEND_SECTION_SIZE;
1937 device_info.recv_sections = NETVSC_DEFAULT_RX; 1944 device_info.recv_sections = NETVSC_DEFAULT_RX;
1945 device_info.recv_section_size = NETVSC_RECV_SECTION_SIZE;
1938 1946
1939 nvdev = rndis_filter_device_add(dev, &device_info); 1947 nvdev = rndis_filter_device_add(dev, &device_info);
1940 if (IS_ERR(nvdev)) { 1948 if (IS_ERR(nvdev)) {
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index a9d16a3af514..cd931cf9dcc2 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -160,15 +160,6 @@ config MDIO_XGENE
160 160
161endif 161endif
162 162
163menuconfig PHYLIB
164 tristate "PHY Device support and infrastructure"
165 depends on NETDEVICES
166 select MDIO_DEVICE
167 help
168 Ethernet controllers are usually attached to PHY
169 devices. This option provides infrastructure for
170 managing PHY devices.
171
172config PHYLINK 163config PHYLINK
173 tristate 164 tristate
174 depends on NETDEVICES 165 depends on NETDEVICES
@@ -179,6 +170,15 @@ config PHYLINK
179 configuration links, PHYs, and Serdes links with MAC level 170 configuration links, PHYs, and Serdes links with MAC level
180 autonegotiation modes. 171 autonegotiation modes.
181 172
173menuconfig PHYLIB
174 tristate "PHY Device support and infrastructure"
175 depends on NETDEVICES
176 select MDIO_DEVICE
177 help
178 Ethernet controllers are usually attached to PHY
179 devices. This option provides infrastructure for
180 managing PHY devices.
181
182if PHYLIB 182if PHYLIB
183 183
184config SWPHY 184config SWPHY
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index e842d2cd1ee7..2b1e67bc1e73 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -373,7 +373,8 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev,
373 cmd->base.port = PORT_BNC; 373 cmd->base.port = PORT_BNC;
374 else 374 else
375 cmd->base.port = PORT_MII; 375 cmd->base.port = PORT_MII;
376 376 cmd->base.transceiver = phy_is_internal(phydev) ?
377 XCVR_INTERNAL : XCVR_EXTERNAL;
377 cmd->base.phy_address = phydev->mdio.addr; 378 cmd->base.phy_address = phydev->mdio.addr;
378 cmd->base.autoneg = phydev->autoneg; 379 cmd->base.autoneg = phydev->autoneg;
379 cmd->base.eth_tp_mdix_ctrl = phydev->mdix_ctrl; 380 cmd->base.eth_tp_mdix_ctrl = phydev->mdix_ctrl;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 8cf0c5901f95..67f25ac29025 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -879,7 +879,7 @@ void phy_attached_print(struct phy_device *phydev, const char *fmt, ...)
879{ 879{
880 const char *drv_name = phydev->drv ? phydev->drv->name : "unbound"; 880 const char *drv_name = phydev->drv ? phydev->drv->name : "unbound";
881 char *irq_str; 881 char *irq_str;
882 char irq_num[4]; 882 char irq_num[8];
883 883
884 switch(phydev->irq) { 884 switch(phydev->irq) {
885 case PHY_POLL: 885 case PHY_POLL:
diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c
index d15dd3938ba8..2e5150b0b8d5 100644
--- a/drivers/net/phy/xilinx_gmii2rgmii.c
+++ b/drivers/net/phy/xilinx_gmii2rgmii.c
@@ -44,7 +44,7 @@ static int xgmiitorgmii_read_status(struct phy_device *phydev)
44 priv->phy_drv->read_status(phydev); 44 priv->phy_drv->read_status(phydev);
45 45
46 val = mdiobus_read(phydev->mdio.bus, priv->addr, XILINX_GMII2RGMII_REG); 46 val = mdiobus_read(phydev->mdio.bus, priv->addr, XILINX_GMII2RGMII_REG);
47 val &= XILINX_GMII2RGMII_SPEED_MASK; 47 val &= ~XILINX_GMII2RGMII_SPEED_MASK;
48 48
49 if (phydev->speed == SPEED_1000) 49 if (phydev->speed == SPEED_1000)
50 val |= BMCR_SPEED1000; 50 val |= BMCR_SPEED1000;
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index b99a7fb09f8e..0161f77641fa 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1265,30 +1265,45 @@ static int lan78xx_ethtool_get_eeprom(struct net_device *netdev,
1265 struct ethtool_eeprom *ee, u8 *data) 1265 struct ethtool_eeprom *ee, u8 *data)
1266{ 1266{
1267 struct lan78xx_net *dev = netdev_priv(netdev); 1267 struct lan78xx_net *dev = netdev_priv(netdev);
1268 int ret;
1269
1270 ret = usb_autopm_get_interface(dev->intf);
1271 if (ret)
1272 return ret;
1268 1273
1269 ee->magic = LAN78XX_EEPROM_MAGIC; 1274 ee->magic = LAN78XX_EEPROM_MAGIC;
1270 1275
1271 return lan78xx_read_raw_eeprom(dev, ee->offset, ee->len, data); 1276 ret = lan78xx_read_raw_eeprom(dev, ee->offset, ee->len, data);
1277
1278 usb_autopm_put_interface(dev->intf);
1279
1280 return ret;
1272} 1281}
1273 1282
1274static int lan78xx_ethtool_set_eeprom(struct net_device *netdev, 1283static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,
1275 struct ethtool_eeprom *ee, u8 *data) 1284 struct ethtool_eeprom *ee, u8 *data)
1276{ 1285{
1277 struct lan78xx_net *dev = netdev_priv(netdev); 1286 struct lan78xx_net *dev = netdev_priv(netdev);
1287 int ret;
1288
1289 ret = usb_autopm_get_interface(dev->intf);
1290 if (ret)
1291 return ret;
1278 1292
1279 /* Allow entire eeprom update only */ 1293 /* Invalid EEPROM_INDICATOR at offset zero will result in a failure
1280 if ((ee->magic == LAN78XX_EEPROM_MAGIC) && 1294 * to load data from EEPROM
1281 (ee->offset == 0) && 1295 */
1282 (ee->len == 512) && 1296 if (ee->magic == LAN78XX_EEPROM_MAGIC)
1283 (data[0] == EEPROM_INDICATOR)) 1297 ret = lan78xx_write_raw_eeprom(dev, ee->offset, ee->len, data);
1284 return lan78xx_write_raw_eeprom(dev, ee->offset, ee->len, data);
1285 else if ((ee->magic == LAN78XX_OTP_MAGIC) && 1298 else if ((ee->magic == LAN78XX_OTP_MAGIC) &&
1286 (ee->offset == 0) && 1299 (ee->offset == 0) &&
1287 (ee->len == 512) && 1300 (ee->len == 512) &&
1288 (data[0] == OTP_INDICATOR_1)) 1301 (data[0] == OTP_INDICATOR_1))
1289 return lan78xx_write_raw_otp(dev, ee->offset, ee->len, data); 1302 ret = lan78xx_write_raw_otp(dev, ee->offset, ee->len, data);
1303
1304 usb_autopm_put_interface(dev->intf);
1290 1305
1291 return -EINVAL; 1306 return ret;
1292} 1307}
1293 1308
1294static void lan78xx_get_strings(struct net_device *netdev, u32 stringset, 1309static void lan78xx_get_strings(struct net_device *netdev, u32 stringset,
@@ -2434,7 +2449,6 @@ static int lan78xx_reset(struct lan78xx_net *dev)
2434 /* LAN7801 only has RGMII mode */ 2449 /* LAN7801 only has RGMII mode */
2435 if (dev->chipid == ID_REV_CHIP_ID_7801_) 2450 if (dev->chipid == ID_REV_CHIP_ID_7801_)
2436 buf &= ~MAC_CR_GMII_EN_; 2451 buf &= ~MAC_CR_GMII_EN_;
2437 buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
2438 ret = lan78xx_write_reg(dev, MAC_CR, buf); 2452 ret = lan78xx_write_reg(dev, MAC_CR, buf);
2439 2453
2440 ret = lan78xx_read_reg(dev, MAC_TX, &buf); 2454 ret = lan78xx_read_reg(dev, MAC_TX, &buf);
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 7f11050746ae..2e0f22298fe9 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -272,6 +272,7 @@ struct trace_event_call {
272 int perf_refcount; 272 int perf_refcount;
273 struct hlist_head __percpu *perf_events; 273 struct hlist_head __percpu *perf_events;
274 struct bpf_prog *prog; 274 struct bpf_prog *prog;
275 struct perf_event *bpf_prog_owner;
275 276
276 int (*perf_perm)(struct trace_event_call *, 277 int (*perf_perm)(struct trace_event_call *,
277 struct perf_event *); 278 struct perf_event *);
diff --git a/include/net/dst.h b/include/net/dst.h
index 93568bd0a352..06a6765da074 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -271,7 +271,7 @@ static inline void dst_use_noref(struct dst_entry *dst, unsigned long time)
271static inline struct dst_entry *dst_clone(struct dst_entry *dst) 271static inline struct dst_entry *dst_clone(struct dst_entry *dst)
272{ 272{
273 if (dst) 273 if (dst)
274 atomic_inc(&dst->__refcnt); 274 dst_hold(dst);
275 return dst; 275 return dst;
276} 276}
277 277
@@ -312,21 +312,6 @@ static inline void skb_dst_copy(struct sk_buff *nskb, const struct sk_buff *oskb
312} 312}
313 313
314/** 314/**
315 * skb_dst_force - makes sure skb dst is refcounted
316 * @skb: buffer
317 *
318 * If dst is not yet refcounted, let's do it
319 */
320static inline void skb_dst_force(struct sk_buff *skb)
321{
322 if (skb_dst_is_noref(skb)) {
323 WARN_ON(!rcu_read_lock_held());
324 skb->_skb_refdst &= ~SKB_DST_NOREF;
325 dst_clone(skb_dst(skb));
326 }
327}
328
329/**
330 * dst_hold_safe - Take a reference on a dst if possible 315 * dst_hold_safe - Take a reference on a dst if possible
331 * @dst: pointer to dst entry 316 * @dst: pointer to dst entry
332 * 317 *
@@ -339,16 +324,17 @@ static inline bool dst_hold_safe(struct dst_entry *dst)
339} 324}
340 325
341/** 326/**
342 * skb_dst_force_safe - makes sure skb dst is refcounted 327 * skb_dst_force - makes sure skb dst is refcounted
343 * @skb: buffer 328 * @skb: buffer
344 * 329 *
345 * If dst is not yet refcounted and not destroyed, grab a ref on it. 330 * If dst is not yet refcounted and not destroyed, grab a ref on it.
346 */ 331 */
347static inline void skb_dst_force_safe(struct sk_buff *skb) 332static inline void skb_dst_force(struct sk_buff *skb)
348{ 333{
349 if (skb_dst_is_noref(skb)) { 334 if (skb_dst_is_noref(skb)) {
350 struct dst_entry *dst = skb_dst(skb); 335 struct dst_entry *dst = skb_dst(skb);
351 336
337 WARN_ON(!rcu_read_lock_held());
352 if (!dst_hold_safe(dst)) 338 if (!dst_hold_safe(dst))
353 dst = NULL; 339 dst = NULL;
354 340
diff --git a/include/net/route.h b/include/net/route.h
index 1b09a9368c68..57dfc6850d37 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -190,7 +190,7 @@ static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src,
190 rcu_read_lock(); 190 rcu_read_lock();
191 err = ip_route_input_noref(skb, dst, src, tos, devin); 191 err = ip_route_input_noref(skb, dst, src, tos, devin);
192 if (!err) { 192 if (!err) {
193 skb_dst_force_safe(skb); 193 skb_dst_force(skb);
194 if (!skb_dst(skb)) 194 if (!skb_dst(skb))
195 err = -EINVAL; 195 err = -EINVAL;
196 } 196 }
diff --git a/include/net/sock.h b/include/net/sock.h
index 03a362568357..a6b9a8d1a6df 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -856,7 +856,7 @@ void sk_stream_write_space(struct sock *sk);
856static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb) 856static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb)
857{ 857{
858 /* dont let skb dst not refcounted, we are going to leave rcu lock */ 858 /* dont let skb dst not refcounted, we are going to leave rcu lock */
859 skb_dst_force_safe(skb); 859 skb_dst_force(skb);
860 860
861 if (!sk->sk_backlog.tail) 861 if (!sk->sk_backlog.tail)
862 sk->sk_backlog.head = skb; 862 sk->sk_backlog.head = skb;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index b510f284427a..3bc910a9bfc6 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -544,7 +544,6 @@ u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now,
544 int min_tso_segs); 544 int min_tso_segs);
545void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss, 545void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss,
546 int nonagle); 546 int nonagle);
547bool tcp_may_send_now(struct sock *sk);
548int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs); 547int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs);
549int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs); 548int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs);
550void tcp_retransmit_timer(struct sock *sk); 549void tcp_retransmit_timer(struct sock *sk);
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 9c041dae8e2c..5bd1b1de4ea0 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -1753,6 +1753,8 @@ enum ethtool_reset_flags {
1753 * %ethtool_link_mode_bit_indices for the link modes, and other 1753 * %ethtool_link_mode_bit_indices for the link modes, and other
1754 * link features that the link partner advertised through 1754 * link features that the link partner advertised through
1755 * autonegotiation; 0 if unknown or not applicable. Read-only. 1755 * autonegotiation; 0 if unknown or not applicable. Read-only.
1756 * @transceiver: Used to distinguish different possible PHY types,
1757 * reported consistently by PHYLIB. Read-only.
1756 * 1758 *
1757 * If autonegotiation is disabled, the speed and @duplex represent the 1759 * If autonegotiation is disabled, the speed and @duplex represent the
1758 * fixed link mode and are writable if the driver supports multiple 1760 * fixed link mode and are writable if the driver supports multiple
@@ -1804,7 +1806,9 @@ struct ethtool_link_settings {
1804 __u8 eth_tp_mdix; 1806 __u8 eth_tp_mdix;
1805 __u8 eth_tp_mdix_ctrl; 1807 __u8 eth_tp_mdix_ctrl;
1806 __s8 link_mode_masks_nwords; 1808 __s8 link_mode_masks_nwords;
1807 __u32 reserved[8]; 1809 __u8 transceiver;
1810 __u8 reserved1[3];
1811 __u32 reserved[7];
1808 __u32 link_mode_masks[0]; 1812 __u32 link_mode_masks[0];
1809 /* layout of link_mode_masks fields: 1813 /* layout of link_mode_masks fields:
1810 * __u32 map_supported[link_mode_masks_nwords]; 1814 * __u32 map_supported[link_mode_masks_nwords];
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 959c9a07f318..e093d9a2c4dd 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -75,8 +75,8 @@ static u64 dev_map_bitmap_size(const union bpf_attr *attr)
75static struct bpf_map *dev_map_alloc(union bpf_attr *attr) 75static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
76{ 76{
77 struct bpf_dtab *dtab; 77 struct bpf_dtab *dtab;
78 int err = -EINVAL;
78 u64 cost; 79 u64 cost;
79 int err;
80 80
81 /* check sanity of attributes */ 81 /* check sanity of attributes */
82 if (attr->max_entries == 0 || attr->key_size != 4 || 82 if (attr->max_entries == 0 || attr->key_size != 4 ||
@@ -108,6 +108,8 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
108 if (err) 108 if (err)
109 goto free_dtab; 109 goto free_dtab;
110 110
111 err = -ENOMEM;
112
111 /* A per cpu bitfield with a bit per possible net device */ 113 /* A per cpu bitfield with a bit per possible net device */
112 dtab->flush_needed = __alloc_percpu(dev_map_bitmap_size(attr), 114 dtab->flush_needed = __alloc_percpu(dev_map_bitmap_size(attr),
113 __alignof__(unsigned long)); 115 __alignof__(unsigned long));
@@ -128,7 +130,7 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
128free_dtab: 130free_dtab:
129 free_percpu(dtab->flush_needed); 131 free_percpu(dtab->flush_needed);
130 kfree(dtab); 132 kfree(dtab);
131 return ERR_PTR(-ENOMEM); 133 return ERR_PTR(err);
132} 134}
133 135
134static void dev_map_free(struct bpf_map *map) 136static void dev_map_free(struct bpf_map *map)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index cb17e1cd1d43..25d074920a00 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -186,15 +186,17 @@ static int bpf_map_alloc_id(struct bpf_map *map)
186 186
187static void bpf_map_free_id(struct bpf_map *map, bool do_idr_lock) 187static void bpf_map_free_id(struct bpf_map *map, bool do_idr_lock)
188{ 188{
189 unsigned long flags;
190
189 if (do_idr_lock) 191 if (do_idr_lock)
190 spin_lock_bh(&map_idr_lock); 192 spin_lock_irqsave(&map_idr_lock, flags);
191 else 193 else
192 __acquire(&map_idr_lock); 194 __acquire(&map_idr_lock);
193 195
194 idr_remove(&map_idr, map->id); 196 idr_remove(&map_idr, map->id);
195 197
196 if (do_idr_lock) 198 if (do_idr_lock)
197 spin_unlock_bh(&map_idr_lock); 199 spin_unlock_irqrestore(&map_idr_lock, flags);
198 else 200 else
199 __release(&map_idr_lock); 201 __release(&map_idr_lock);
200} 202}
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 799b2451ef2d..b914fbe1383e 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -4205,7 +4205,12 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
4205 } 4205 }
4206 4206
4207 if (insn->imm == BPF_FUNC_redirect_map) { 4207 if (insn->imm == BPF_FUNC_redirect_map) {
4208 u64 addr = (unsigned long)prog; 4208 /* Note, we cannot use prog directly as imm as subsequent
4209 * rewrites would still change the prog pointer. The only
4210 * stable address we can use is aux, which also works with
4211 * prog clones during blinding.
4212 */
4213 u64 addr = (unsigned long)prog->aux;
4209 struct bpf_insn r4_ld[] = { 4214 struct bpf_insn r4_ld[] = {
4210 BPF_LD_IMM64(BPF_REG_4, addr), 4215 BPF_LD_IMM64(BPF_REG_4, addr),
4211 *insn, 4216 *insn,
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 3e691b75b2db..6bc21e202ae4 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8171,6 +8171,7 @@ static int perf_event_set_bpf_prog(struct perf_event *event, u32 prog_fd)
8171 } 8171 }
8172 } 8172 }
8173 event->tp_event->prog = prog; 8173 event->tp_event->prog = prog;
8174 event->tp_event->bpf_prog_owner = event;
8174 8175
8175 return 0; 8176 return 0;
8176} 8177}
@@ -8185,7 +8186,7 @@ static void perf_event_free_bpf_prog(struct perf_event *event)
8185 return; 8186 return;
8186 8187
8187 prog = event->tp_event->prog; 8188 prog = event->tp_event->prog;
8188 if (prog) { 8189 if (prog && event->tp_event->bpf_prog_owner == event) {
8189 event->tp_event->prog = NULL; 8190 event->tp_event->prog = NULL;
8190 bpf_prog_put(prog); 8191 bpf_prog_put(prog);
8191 } 8192 }
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 707ca5d677c6..ddd7dde87c3c 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -735,9 +735,9 @@ EXPORT_SYMBOL_GPL(rhashtable_walk_exit);
735 * rhashtable_walk_start - Start a hash table walk 735 * rhashtable_walk_start - Start a hash table walk
736 * @iter: Hash table iterator 736 * @iter: Hash table iterator
737 * 737 *
738 * Start a hash table walk. Note that we take the RCU lock in all 738 * Start a hash table walk at the current iterator position. Note that we take
739 * cases including when we return an error. So you must always call 739 * the RCU lock in all cases including when we return an error. So you must
740 * rhashtable_walk_stop to clean up. 740 * always call rhashtable_walk_stop to clean up.
741 * 741 *
742 * Returns zero if successful. 742 * Returns zero if successful.
743 * 743 *
@@ -846,7 +846,8 @@ EXPORT_SYMBOL_GPL(rhashtable_walk_next);
846 * rhashtable_walk_stop - Finish a hash table walk 846 * rhashtable_walk_stop - Finish a hash table walk
847 * @iter: Hash table iterator 847 * @iter: Hash table iterator
848 * 848 *
849 * Finish a hash table walk. 849 * Finish a hash table walk. Does not reset the iterator to the start of the
850 * hash table.
850 */ 851 */
851void rhashtable_walk_stop(struct rhashtable_iter *iter) 852void rhashtable_walk_stop(struct rhashtable_iter *iter)
852 __releases(RCU) 853 __releases(RCU)
diff --git a/net/compat.c b/net/compat.c
index 6ded6c821d7a..22381719718c 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -185,6 +185,13 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk,
185 ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); 185 ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen);
186 } 186 }
187 187
188 /*
189 * check the length of messages copied in is the same as the
190 * what we get from the first loop
191 */
192 if ((char *)kcmsg - (char *)kcmsg_base != kcmlen)
193 goto Einval;
194
188 /* Ok, looks like we made it. Hook it up and return success. */ 195 /* Ok, looks like we made it. Hook it up and return success. */
189 kmsg->msg_control = kcmsg_base; 196 kmsg->msg_control = kcmsg_base;
190 kmsg->msg_controllen = kcmlen; 197 kmsg->msg_controllen = kcmlen;
diff --git a/net/core/dev.c b/net/core/dev.c
index fb766d906148..588b473194a8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1948,8 +1948,12 @@ again:
1948 goto again; 1948 goto again;
1949 } 1949 }
1950out_unlock: 1950out_unlock:
1951 if (pt_prev) 1951 if (pt_prev) {
1952 pt_prev->func(skb2, skb->dev, pt_prev, skb->dev); 1952 if (!skb_orphan_frags_rx(skb2, GFP_ATOMIC))
1953 pt_prev->func(skb2, skb->dev, pt_prev, skb->dev);
1954 else
1955 kfree_skb(skb2);
1956 }
1953 rcu_read_unlock(); 1957 rcu_read_unlock();
1954} 1958}
1955EXPORT_SYMBOL_GPL(dev_queue_xmit_nit); 1959EXPORT_SYMBOL_GPL(dev_queue_xmit_nit);
@@ -3892,6 +3896,7 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
3892 __skb_pull(skb, off); 3896 __skb_pull(skb, off);
3893 else if (off < 0) 3897 else if (off < 0)
3894 __skb_push(skb, -off); 3898 __skb_push(skb, -off);
3899 skb->mac_header += off;
3895 3900
3896 switch (act) { 3901 switch (act) {
3897 case XDP_REDIRECT: 3902 case XDP_REDIRECT:
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 6a582ae4c5d9..3228411ada0f 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -525,6 +525,8 @@ convert_link_ksettings_to_legacy_settings(
525 = link_ksettings->base.eth_tp_mdix; 525 = link_ksettings->base.eth_tp_mdix;
526 legacy_settings->eth_tp_mdix_ctrl 526 legacy_settings->eth_tp_mdix_ctrl
527 = link_ksettings->base.eth_tp_mdix_ctrl; 527 = link_ksettings->base.eth_tp_mdix_ctrl;
528 legacy_settings->transceiver
529 = link_ksettings->base.transceiver;
528 return retval; 530 return retval;
529} 531}
530 532
diff --git a/net/core/filter.c b/net/core/filter.c
index 24dd33dd9f04..82edad58d066 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1794,7 +1794,7 @@ struct redirect_info {
1794 u32 flags; 1794 u32 flags;
1795 struct bpf_map *map; 1795 struct bpf_map *map;
1796 struct bpf_map *map_to_flush; 1796 struct bpf_map *map_to_flush;
1797 const struct bpf_prog *map_owner; 1797 unsigned long map_owner;
1798}; 1798};
1799 1799
1800static DEFINE_PER_CPU(struct redirect_info, redirect_info); 1800static DEFINE_PER_CPU(struct redirect_info, redirect_info);
@@ -2500,11 +2500,17 @@ void xdp_do_flush_map(void)
2500} 2500}
2501EXPORT_SYMBOL_GPL(xdp_do_flush_map); 2501EXPORT_SYMBOL_GPL(xdp_do_flush_map);
2502 2502
2503static inline bool xdp_map_invalid(const struct bpf_prog *xdp_prog,
2504 unsigned long aux)
2505{
2506 return (unsigned long)xdp_prog->aux != aux;
2507}
2508
2503static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp, 2509static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
2504 struct bpf_prog *xdp_prog) 2510 struct bpf_prog *xdp_prog)
2505{ 2511{
2506 struct redirect_info *ri = this_cpu_ptr(&redirect_info); 2512 struct redirect_info *ri = this_cpu_ptr(&redirect_info);
2507 const struct bpf_prog *map_owner = ri->map_owner; 2513 unsigned long map_owner = ri->map_owner;
2508 struct bpf_map *map = ri->map; 2514 struct bpf_map *map = ri->map;
2509 struct net_device *fwd = NULL; 2515 struct net_device *fwd = NULL;
2510 u32 index = ri->ifindex; 2516 u32 index = ri->ifindex;
@@ -2512,9 +2518,9 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
2512 2518
2513 ri->ifindex = 0; 2519 ri->ifindex = 0;
2514 ri->map = NULL; 2520 ri->map = NULL;
2515 ri->map_owner = NULL; 2521 ri->map_owner = 0;
2516 2522
2517 if (unlikely(map_owner != xdp_prog)) { 2523 if (unlikely(xdp_map_invalid(xdp_prog, map_owner))) {
2518 err = -EFAULT; 2524 err = -EFAULT;
2519 map = NULL; 2525 map = NULL;
2520 goto err; 2526 goto err;
@@ -2574,7 +2580,7 @@ int xdp_do_generic_redirect(struct net_device *dev, struct sk_buff *skb,
2574 struct bpf_prog *xdp_prog) 2580 struct bpf_prog *xdp_prog)
2575{ 2581{
2576 struct redirect_info *ri = this_cpu_ptr(&redirect_info); 2582 struct redirect_info *ri = this_cpu_ptr(&redirect_info);
2577 const struct bpf_prog *map_owner = ri->map_owner; 2583 unsigned long map_owner = ri->map_owner;
2578 struct bpf_map *map = ri->map; 2584 struct bpf_map *map = ri->map;
2579 struct net_device *fwd = NULL; 2585 struct net_device *fwd = NULL;
2580 u32 index = ri->ifindex; 2586 u32 index = ri->ifindex;
@@ -2583,10 +2589,10 @@ int xdp_do_generic_redirect(struct net_device *dev, struct sk_buff *skb,
2583 2589
2584 ri->ifindex = 0; 2590 ri->ifindex = 0;
2585 ri->map = NULL; 2591 ri->map = NULL;
2586 ri->map_owner = NULL; 2592 ri->map_owner = 0;
2587 2593
2588 if (map) { 2594 if (map) {
2589 if (unlikely(map_owner != xdp_prog)) { 2595 if (unlikely(xdp_map_invalid(xdp_prog, map_owner))) {
2590 err = -EFAULT; 2596 err = -EFAULT;
2591 map = NULL; 2597 map = NULL;
2592 goto err; 2598 goto err;
@@ -2632,7 +2638,7 @@ BPF_CALL_2(bpf_xdp_redirect, u32, ifindex, u64, flags)
2632 ri->ifindex = ifindex; 2638 ri->ifindex = ifindex;
2633 ri->flags = flags; 2639 ri->flags = flags;
2634 ri->map = NULL; 2640 ri->map = NULL;
2635 ri->map_owner = NULL; 2641 ri->map_owner = 0;
2636 2642
2637 return XDP_REDIRECT; 2643 return XDP_REDIRECT;
2638} 2644}
@@ -2646,7 +2652,7 @@ static const struct bpf_func_proto bpf_xdp_redirect_proto = {
2646}; 2652};
2647 2653
2648BPF_CALL_4(bpf_xdp_redirect_map, struct bpf_map *, map, u32, ifindex, u64, flags, 2654BPF_CALL_4(bpf_xdp_redirect_map, struct bpf_map *, map, u32, ifindex, u64, flags,
2649 const struct bpf_prog *, map_owner) 2655 unsigned long, map_owner)
2650{ 2656{
2651 struct redirect_info *ri = this_cpu_ptr(&redirect_info); 2657 struct redirect_info *ri = this_cpu_ptr(&redirect_info);
2652 2658
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index b9c64b40a83a..c039c937ba90 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -266,7 +266,7 @@ static inline int sk_reuseport_match(struct inet_bind_bucket *tb,
266#if IS_ENABLED(CONFIG_IPV6) 266#if IS_ENABLED(CONFIG_IPV6)
267 if (tb->fast_sk_family == AF_INET6) 267 if (tb->fast_sk_family == AF_INET6)
268 return ipv6_rcv_saddr_equal(&tb->fast_v6_rcv_saddr, 268 return ipv6_rcv_saddr_equal(&tb->fast_v6_rcv_saddr,
269 &sk->sk_v6_rcv_saddr, 269 inet6_rcv_saddr(sk),
270 tb->fast_rcv_saddr, 270 tb->fast_rcv_saddr,
271 sk->sk_rcv_saddr, 271 sk->sk_rcv_saddr,
272 tb->fast_ipv6_only, 272 tb->fast_ipv6_only,
@@ -321,13 +321,14 @@ tb_found:
321 goto fail_unlock; 321 goto fail_unlock;
322 } 322 }
323success: 323success:
324 if (!hlist_empty(&tb->owners)) { 324 if (hlist_empty(&tb->owners)) {
325 tb->fastreuse = reuse; 325 tb->fastreuse = reuse;
326 if (sk->sk_reuseport) { 326 if (sk->sk_reuseport) {
327 tb->fastreuseport = FASTREUSEPORT_ANY; 327 tb->fastreuseport = FASTREUSEPORT_ANY;
328 tb->fastuid = uid; 328 tb->fastuid = uid;
329 tb->fast_rcv_saddr = sk->sk_rcv_saddr; 329 tb->fast_rcv_saddr = sk->sk_rcv_saddr;
330 tb->fast_ipv6_only = ipv6_only_sock(sk); 330 tb->fast_ipv6_only = ipv6_only_sock(sk);
331 tb->fast_sk_family = sk->sk_family;
331#if IS_ENABLED(CONFIG_IPV6) 332#if IS_ENABLED(CONFIG_IPV6)
332 tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr; 333 tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
333#endif 334#endif
@@ -354,6 +355,7 @@ success:
354 tb->fastuid = uid; 355 tb->fastuid = uid;
355 tb->fast_rcv_saddr = sk->sk_rcv_saddr; 356 tb->fast_rcv_saddr = sk->sk_rcv_saddr;
356 tb->fast_ipv6_only = ipv6_only_sock(sk); 357 tb->fast_ipv6_only = ipv6_only_sock(sk);
358 tb->fast_sk_family = sk->sk_family;
357#if IS_ENABLED(CONFIG_IPV6) 359#if IS_ENABLED(CONFIG_IPV6)
358 tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr; 360 tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
359#endif 361#endif
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 1c839c99114c..0bc9e46a5369 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1806,40 +1806,6 @@ static bool tcp_snd_wnd_test(const struct tcp_sock *tp,
1806 return !after(end_seq, tcp_wnd_end(tp)); 1806 return !after(end_seq, tcp_wnd_end(tp));
1807} 1807}
1808 1808
1809/* This checks if the data bearing packet SKB (usually tcp_send_head(sk))
1810 * should be put on the wire right now. If so, it returns the number of
1811 * packets allowed by the congestion window.
1812 */
1813static unsigned int tcp_snd_test(const struct sock *sk, struct sk_buff *skb,
1814 unsigned int cur_mss, int nonagle)
1815{
1816 const struct tcp_sock *tp = tcp_sk(sk);
1817 unsigned int cwnd_quota;
1818
1819 tcp_init_tso_segs(skb, cur_mss);
1820
1821 if (!tcp_nagle_test(tp, skb, cur_mss, nonagle))
1822 return 0;
1823
1824 cwnd_quota = tcp_cwnd_test(tp, skb);
1825 if (cwnd_quota && !tcp_snd_wnd_test(tp, skb, cur_mss))
1826 cwnd_quota = 0;
1827
1828 return cwnd_quota;
1829}
1830
1831/* Test if sending is allowed right now. */
1832bool tcp_may_send_now(struct sock *sk)
1833{
1834 const struct tcp_sock *tp = tcp_sk(sk);
1835 struct sk_buff *skb = tcp_send_head(sk);
1836
1837 return skb &&
1838 tcp_snd_test(sk, skb, tcp_current_mss(sk),
1839 (tcp_skb_is_last(sk, skb) ?
1840 tp->nonagle : TCP_NAGLE_PUSH));
1841}
1842
1843/* Trim TSO SKB to LEN bytes, put the remaining data into a new packet 1809/* Trim TSO SKB to LEN bytes, put the remaining data into a new packet
1844 * which is put after SKB on the list. It is very much like 1810 * which is put after SKB on the list. It is very much like
1845 * tcp_fragment() except that it may make several kinds of assumptions 1811 * tcp_fragment() except that it may make several kinds of assumptions
@@ -3423,6 +3389,10 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
3423 goto done; 3389 goto done;
3424 } 3390 }
3425 3391
3392 /* data was not sent, this is our new send_head */
3393 sk->sk_send_head = syn_data;
3394 tp->packets_out -= tcp_skb_pcount(syn_data);
3395
3426fallback: 3396fallback:
3427 /* Send a regular SYN with Fast Open cookie request option */ 3397 /* Send a regular SYN with Fast Open cookie request option */
3428 if (fo->cookie.len > 0) 3398 if (fo->cookie.len > 0)
@@ -3475,6 +3445,11 @@ int tcp_connect(struct sock *sk)
3475 */ 3445 */
3476 tp->snd_nxt = tp->write_seq; 3446 tp->snd_nxt = tp->write_seq;
3477 tp->pushed_seq = tp->write_seq; 3447 tp->pushed_seq = tp->write_seq;
3448 buff = tcp_send_head(sk);
3449 if (unlikely(buff)) {
3450 tp->snd_nxt = TCP_SKB_CB(buff)->seq;
3451 tp->pushed_seq = TCP_SKB_CB(buff)->seq;
3452 }
3478 TCP_INC_STATS(sock_net(sk), TCP_MIB_ACTIVEOPENS); 3453 TCP_INC_STATS(sock_net(sk), TCP_MIB_ACTIVEOPENS);
3479 3454
3480 /* Timer for repeating the SYN until an answer. */ 3455 /* Timer for repeating the SYN until an answer. */
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index c2e2a78787ec..96861c702c06 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1399,10 +1399,18 @@ static inline int ipv6_saddr_preferred(int type)
1399 return 0; 1399 return 0;
1400} 1400}
1401 1401
1402static inline bool ipv6_use_optimistic_addr(struct inet6_dev *idev) 1402static bool ipv6_use_optimistic_addr(struct net *net,
1403 struct inet6_dev *idev)
1403{ 1404{
1404#ifdef CONFIG_IPV6_OPTIMISTIC_DAD 1405#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
1405 return idev && idev->cnf.optimistic_dad && idev->cnf.use_optimistic; 1406 if (!idev)
1407 return false;
1408 if (!net->ipv6.devconf_all->optimistic_dad && !idev->cnf.optimistic_dad)
1409 return false;
1410 if (!net->ipv6.devconf_all->use_optimistic && !idev->cnf.use_optimistic)
1411 return false;
1412
1413 return true;
1406#else 1414#else
1407 return false; 1415 return false;
1408#endif 1416#endif
@@ -1472,7 +1480,7 @@ static int ipv6_get_saddr_eval(struct net *net,
1472 /* Rule 3: Avoid deprecated and optimistic addresses */ 1480 /* Rule 3: Avoid deprecated and optimistic addresses */
1473 u8 avoid = IFA_F_DEPRECATED; 1481 u8 avoid = IFA_F_DEPRECATED;
1474 1482
1475 if (!ipv6_use_optimistic_addr(score->ifa->idev)) 1483 if (!ipv6_use_optimistic_addr(net, score->ifa->idev))
1476 avoid |= IFA_F_OPTIMISTIC; 1484 avoid |= IFA_F_OPTIMISTIC;
1477 ret = ipv6_saddr_preferred(score->addr_type) || 1485 ret = ipv6_saddr_preferred(score->addr_type) ||
1478 !(score->ifa->flags & avoid); 1486 !(score->ifa->flags & avoid);
@@ -2460,7 +2468,8 @@ int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
2460 int max_addresses = in6_dev->cnf.max_addresses; 2468 int max_addresses = in6_dev->cnf.max_addresses;
2461 2469
2462#ifdef CONFIG_IPV6_OPTIMISTIC_DAD 2470#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
2463 if (in6_dev->cnf.optimistic_dad && 2471 if ((net->ipv6.devconf_all->optimistic_dad ||
2472 in6_dev->cnf.optimistic_dad) &&
2464 !net->ipv6.devconf_all->forwarding && sllao) 2473 !net->ipv6.devconf_all->forwarding && sllao)
2465 addr_flags |= IFA_F_OPTIMISTIC; 2474 addr_flags |= IFA_F_OPTIMISTIC;
2466#endif 2475#endif
@@ -3051,7 +3060,8 @@ void addrconf_add_linklocal(struct inet6_dev *idev,
3051 u32 addr_flags = flags | IFA_F_PERMANENT; 3060 u32 addr_flags = flags | IFA_F_PERMANENT;
3052 3061
3053#ifdef CONFIG_IPV6_OPTIMISTIC_DAD 3062#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
3054 if (idev->cnf.optimistic_dad && 3063 if ((dev_net(idev->dev)->ipv6.devconf_all->optimistic_dad ||
3064 idev->cnf.optimistic_dad) &&
3055 !dev_net(idev->dev)->ipv6.devconf_all->forwarding) 3065 !dev_net(idev->dev)->ipv6.devconf_all->forwarding)
3056 addr_flags |= IFA_F_OPTIMISTIC; 3066 addr_flags |= IFA_F_OPTIMISTIC;
3057#endif 3067#endif
@@ -3810,6 +3820,7 @@ static void addrconf_dad_begin(struct inet6_ifaddr *ifp)
3810 goto out; 3820 goto out;
3811 3821
3812 if (dev->flags&(IFF_NOARP|IFF_LOOPBACK) || 3822 if (dev->flags&(IFF_NOARP|IFF_LOOPBACK) ||
3823 dev_net(dev)->ipv6.devconf_all->accept_dad < 1 ||
3813 idev->cnf.accept_dad < 1 || 3824 idev->cnf.accept_dad < 1 ||
3814 !(ifp->flags&IFA_F_TENTATIVE) || 3825 !(ifp->flags&IFA_F_TENTATIVE) ||
3815 ifp->flags & IFA_F_NODAD) { 3826 ifp->flags & IFA_F_NODAD) {
@@ -3841,7 +3852,7 @@ static void addrconf_dad_begin(struct inet6_ifaddr *ifp)
3841 */ 3852 */
3842 if (ifp->flags & IFA_F_OPTIMISTIC) { 3853 if (ifp->flags & IFA_F_OPTIMISTIC) {
3843 ip6_ins_rt(ifp->rt); 3854 ip6_ins_rt(ifp->rt);
3844 if (ipv6_use_optimistic_addr(idev)) { 3855 if (ipv6_use_optimistic_addr(dev_net(dev), idev)) {
3845 /* Because optimistic nodes can use this address, 3856 /* Because optimistic nodes can use this address,
3846 * notify listeners. If DAD fails, RTM_DELADDR is sent. 3857 * notify listeners. If DAD fails, RTM_DELADDR is sent.
3847 */ 3858 */
@@ -3897,7 +3908,9 @@ static void addrconf_dad_work(struct work_struct *w)
3897 action = DAD_ABORT; 3908 action = DAD_ABORT;
3898 ifp->state = INET6_IFADDR_STATE_POSTDAD; 3909 ifp->state = INET6_IFADDR_STATE_POSTDAD;
3899 3910
3900 if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6 && 3911 if ((dev_net(idev->dev)->ipv6.devconf_all->accept_dad > 1 ||
3912 idev->cnf.accept_dad > 1) &&
3913 !idev->cnf.disable_ipv6 &&
3901 !(ifp->flags & IFA_F_STABLE_PRIVACY)) { 3914 !(ifp->flags & IFA_F_STABLE_PRIVACY)) {
3902 struct in6_addr addr; 3915 struct in6_addr addr;
3903 3916
@@ -4940,9 +4953,10 @@ static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
4940 4953
4941 /* Don't send DELADDR notification for TENTATIVE address, 4954 /* Don't send DELADDR notification for TENTATIVE address,
4942 * since NEWADDR notification is sent only after removing 4955 * since NEWADDR notification is sent only after removing
4943 * TENTATIVE flag. 4956 * TENTATIVE flag, if DAD has not failed.
4944 */ 4957 */
4945 if (ifa->flags & IFA_F_TENTATIVE && event == RTM_DELADDR) 4958 if (ifa->flags & IFA_F_TENTATIVE && !(ifa->flags & IFA_F_DADFAILED) &&
4959 event == RTM_DELADDR)
4946 return; 4960 return;
4947 4961
4948 skb = nlmsg_new(inet6_ifaddr_msgsize(), GFP_ATOMIC); 4962 skb = nlmsg_new(inet6_ifaddr_msgsize(), GFP_ATOMIC);
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index b7a72d409334..20f66f4c9460 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -940,24 +940,25 @@ done:
940} 940}
941 941
942static int ip6gre_header(struct sk_buff *skb, struct net_device *dev, 942static int ip6gre_header(struct sk_buff *skb, struct net_device *dev,
943 unsigned short type, 943 unsigned short type, const void *daddr,
944 const void *daddr, const void *saddr, unsigned int len) 944 const void *saddr, unsigned int len)
945{ 945{
946 struct ip6_tnl *t = netdev_priv(dev); 946 struct ip6_tnl *t = netdev_priv(dev);
947 struct ipv6hdr *ipv6h = skb_push(skb, t->hlen); 947 struct ipv6hdr *ipv6h;
948 __be16 *p = (__be16 *)(ipv6h+1); 948 __be16 *p;
949 949
950 ip6_flow_hdr(ipv6h, 0, 950 ipv6h = skb_push(skb, t->hlen + sizeof(*ipv6h));
951 ip6_make_flowlabel(dev_net(dev), skb, 951 ip6_flow_hdr(ipv6h, 0, ip6_make_flowlabel(dev_net(dev), skb,
952 t->fl.u.ip6.flowlabel, true, 952 t->fl.u.ip6.flowlabel,
953 &t->fl.u.ip6)); 953 true, &t->fl.u.ip6));
954 ipv6h->hop_limit = t->parms.hop_limit; 954 ipv6h->hop_limit = t->parms.hop_limit;
955 ipv6h->nexthdr = NEXTHDR_GRE; 955 ipv6h->nexthdr = NEXTHDR_GRE;
956 ipv6h->saddr = t->parms.laddr; 956 ipv6h->saddr = t->parms.laddr;
957 ipv6h->daddr = t->parms.raddr; 957 ipv6h->daddr = t->parms.raddr;
958 958
959 p[0] = t->parms.o_flags; 959 p = (__be16 *)(ipv6h + 1);
960 p[1] = htons(type); 960 p[0] = t->parms.o_flags;
961 p[1] = htons(type);
961 962
962 /* 963 /*
963 * Set the source hardware address. 964 * Set the source hardware address.
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index ae73164559d5..f2f21c24915f 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -2259,6 +2259,9 @@ static int __init ip6_tunnel_init(void)
2259{ 2259{
2260 int err; 2260 int err;
2261 2261
2262 if (!ipv6_mod_enabled())
2263 return -EOPNOTSUPP;
2264
2262 err = register_pernet_device(&ip6_tnl_net_ops); 2265 err = register_pernet_device(&ip6_tnl_net_ops);
2263 if (err < 0) 2266 if (err < 0)
2264 goto out_pernet; 2267 goto out_pernet;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index e2ecfb137297..40d7234c27b9 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1015,6 +1015,7 @@ static void udp6_hwcsum_outgoing(struct sock *sk, struct sk_buff *skb,
1015 */ 1015 */
1016 offset = skb_transport_offset(skb); 1016 offset = skb_transport_offset(skb);
1017 skb->csum = skb_checksum(skb, offset, skb->len - offset, 0); 1017 skb->csum = skb_checksum(skb, offset, skb->len - offset, 0);
1018 csum = skb->csum;
1018 1019
1019 skb->ip_summed = CHECKSUM_NONE; 1020 skb->ip_summed = CHECKSUM_NONE;
1020 1021
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index f236c0bc7b3f..51063d9ed0f7 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -1041,12 +1041,24 @@ out:
1041static int 1041static int
1042mtype_head(struct ip_set *set, struct sk_buff *skb) 1042mtype_head(struct ip_set *set, struct sk_buff *skb)
1043{ 1043{
1044 const struct htype *h = set->data; 1044 struct htype *h = set->data;
1045 const struct htable *t; 1045 const struct htable *t;
1046 struct nlattr *nested; 1046 struct nlattr *nested;
1047 size_t memsize; 1047 size_t memsize;
1048 u8 htable_bits; 1048 u8 htable_bits;
1049 1049
1050 /* If any members have expired, set->elements will be wrong
1051 * mytype_expire function will update it with the right count.
1052 * we do not hold set->lock here, so grab it first.
1053 * set->elements can still be incorrect in the case of a huge set,
1054 * because elements might time out during the listing.
1055 */
1056 if (SET_WITH_TIMEOUT(set)) {
1057 spin_lock_bh(&set->lock);
1058 mtype_expire(set, h);
1059 spin_unlock_bh(&set->lock);
1060 }
1061
1050 rcu_read_lock_bh(); 1062 rcu_read_lock_bh();
1051 t = rcu_dereference_bh_nfnl(h->table); 1063 t = rcu_dereference_bh_nfnl(h->table);
1052 memsize = mtype_ahash_memsize(h, t) + set->ext_size; 1064 memsize = mtype_ahash_memsize(h, t) + set->ext_size;
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index f393a7086025..af8345fc4fbd 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -429,7 +429,7 @@ nf_nat_setup_info(struct nf_conn *ct,
429 429
430 srchash = hash_by_src(net, 430 srchash = hash_by_src(net,
431 &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); 431 &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
432 lock = &nf_nat_locks[srchash % ARRAY_SIZE(nf_nat_locks)]; 432 lock = &nf_nat_locks[srchash % CONNTRACK_LOCKS];
433 spin_lock_bh(lock); 433 spin_lock_bh(lock);
434 hlist_add_head_rcu(&ct->nat_bysource, 434 hlist_add_head_rcu(&ct->nat_bysource,
435 &nf_nat_bysource[srchash]); 435 &nf_nat_bysource[srchash]);
@@ -532,9 +532,9 @@ static void __nf_nat_cleanup_conntrack(struct nf_conn *ct)
532 unsigned int h; 532 unsigned int h;
533 533
534 h = hash_by_src(nf_ct_net(ct), &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); 534 h = hash_by_src(nf_ct_net(ct), &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
535 spin_lock_bh(&nf_nat_locks[h % ARRAY_SIZE(nf_nat_locks)]); 535 spin_lock_bh(&nf_nat_locks[h % CONNTRACK_LOCKS]);
536 hlist_del_rcu(&ct->nat_bysource); 536 hlist_del_rcu(&ct->nat_bysource);
537 spin_unlock_bh(&nf_nat_locks[h % ARRAY_SIZE(nf_nat_locks)]); 537 spin_unlock_bh(&nf_nat_locks[h % CONNTRACK_LOCKS]);
538} 538}
539 539
540static int nf_nat_proto_clean(struct nf_conn *ct, void *data) 540static int nf_nat_proto_clean(struct nf_conn *ct, void *data)
@@ -807,8 +807,8 @@ static int __init nf_nat_init(void)
807 807
808 /* Leave them the same for the moment. */ 808 /* Leave them the same for the moment. */
809 nf_nat_htable_size = nf_conntrack_htable_size; 809 nf_nat_htable_size = nf_conntrack_htable_size;
810 if (nf_nat_htable_size < ARRAY_SIZE(nf_nat_locks)) 810 if (nf_nat_htable_size < CONNTRACK_LOCKS)
811 nf_nat_htable_size = ARRAY_SIZE(nf_nat_locks); 811 nf_nat_htable_size = CONNTRACK_LOCKS;
812 812
813 nf_nat_bysource = nf_ct_alloc_hashtable(&nf_nat_htable_size, 0); 813 nf_nat_bysource = nf_ct_alloc_hashtable(&nf_nat_htable_size, 0);
814 if (!nf_nat_bysource) 814 if (!nf_nat_bysource)
@@ -821,7 +821,7 @@ static int __init nf_nat_init(void)
821 return ret; 821 return ret;
822 } 822 }
823 823
824 for (i = 0; i < ARRAY_SIZE(nf_nat_locks); i++) 824 for (i = 0; i < CONNTRACK_LOCKS; i++)
825 spin_lock_init(&nf_nat_locks[i]); 825 spin_lock_init(&nf_nat_locks[i]);
826 826
827 nf_ct_helper_expectfn_register(&follow_master_nat); 827 nf_ct_helper_expectfn_register(&follow_master_nat);
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index c26172995511..d288f52c53f7 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1684,10 +1684,6 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)
1684 1684
1685 mutex_lock(&fanout_mutex); 1685 mutex_lock(&fanout_mutex);
1686 1686
1687 err = -EINVAL;
1688 if (!po->running)
1689 goto out;
1690
1691 err = -EALREADY; 1687 err = -EALREADY;
1692 if (po->fanout) 1688 if (po->fanout)
1693 goto out; 1689 goto out;
@@ -1749,7 +1745,10 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)
1749 list_add(&match->list, &fanout_list); 1745 list_add(&match->list, &fanout_list);
1750 } 1746 }
1751 err = -EINVAL; 1747 err = -EINVAL;
1752 if (match->type == type && 1748
1749 spin_lock(&po->bind_lock);
1750 if (po->running &&
1751 match->type == type &&
1753 match->prot_hook.type == po->prot_hook.type && 1752 match->prot_hook.type == po->prot_hook.type &&
1754 match->prot_hook.dev == po->prot_hook.dev) { 1753 match->prot_hook.dev == po->prot_hook.dev) {
1755 err = -ENOSPC; 1754 err = -ENOSPC;
@@ -1761,6 +1760,13 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)
1761 err = 0; 1760 err = 0;
1762 } 1761 }
1763 } 1762 }
1763 spin_unlock(&po->bind_lock);
1764
1765 if (err && !refcount_read(&match->sk_ref)) {
1766 list_del(&match->list);
1767 kfree(match);
1768 }
1769
1764out: 1770out:
1765 if (err && rollover) { 1771 if (err && rollover) {
1766 kfree(rollover); 1772 kfree(rollover);
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 1a267e77c6de..d230cb4c8094 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -922,28 +922,28 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
922 922
923 if (!tc_flags_valid(fnew->flags)) { 923 if (!tc_flags_valid(fnew->flags)) {
924 err = -EINVAL; 924 err = -EINVAL;
925 goto errout; 925 goto errout_idr;
926 } 926 }
927 } 927 }
928 928
929 err = fl_set_parms(net, tp, fnew, &mask, base, tb, tca[TCA_RATE], ovr); 929 err = fl_set_parms(net, tp, fnew, &mask, base, tb, tca[TCA_RATE], ovr);
930 if (err) 930 if (err)
931 goto errout; 931 goto errout_idr;
932 932
933 err = fl_check_assign_mask(head, &mask); 933 err = fl_check_assign_mask(head, &mask);
934 if (err) 934 if (err)
935 goto errout; 935 goto errout_idr;
936 936
937 if (!tc_skip_sw(fnew->flags)) { 937 if (!tc_skip_sw(fnew->flags)) {
938 if (!fold && fl_lookup(head, &fnew->mkey)) { 938 if (!fold && fl_lookup(head, &fnew->mkey)) {
939 err = -EEXIST; 939 err = -EEXIST;
940 goto errout; 940 goto errout_idr;
941 } 941 }
942 942
943 err = rhashtable_insert_fast(&head->ht, &fnew->ht_node, 943 err = rhashtable_insert_fast(&head->ht, &fnew->ht_node,
944 head->ht_params); 944 head->ht_params);
945 if (err) 945 if (err)
946 goto errout; 946 goto errout_idr;
947 } 947 }
948 948
949 if (!tc_skip_hw(fnew->flags)) { 949 if (!tc_skip_hw(fnew->flags)) {
@@ -952,7 +952,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
952 &mask.key, 952 &mask.key,
953 fnew); 953 fnew);
954 if (err) 954 if (err)
955 goto errout; 955 goto errout_idr;
956 } 956 }
957 957
958 if (!tc_in_hw(fnew->flags)) 958 if (!tc_in_hw(fnew->flags))
@@ -981,6 +981,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
981 kfree(tb); 981 kfree(tb);
982 return 0; 982 return 0;
983 983
984errout_idr:
985 if (fnew->handle)
986 idr_remove_ext(&head->handle_idr, fnew->handle);
984errout: 987errout:
985 tcf_exts_destroy(&fnew->exts); 988 tcf_exts_destroy(&fnew->exts);
986 kfree(fnew); 989 kfree(fnew);
diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
index 21cc45caf842..eeac606c95ab 100644
--- a/net/sched/cls_matchall.c
+++ b/net/sched/cls_matchall.c
@@ -32,6 +32,7 @@ static int mall_classify(struct sk_buff *skb, const struct tcf_proto *tp,
32 if (tc_skip_sw(head->flags)) 32 if (tc_skip_sw(head->flags))
33 return -1; 33 return -1;
34 34
35 *res = head->res;
35 return tcf_exts_exec(skb, &head->exts, res); 36 return tcf_exts_exec(skb, &head->exts, res);
36} 37}
37 38
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 92237e75dbbc..bf8c81e07c70 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -685,6 +685,7 @@ void qdisc_reset(struct Qdisc *qdisc)
685 qdisc->gso_skb = NULL; 685 qdisc->gso_skb = NULL;
686 } 686 }
687 qdisc->q.qlen = 0; 687 qdisc->q.qlen = 0;
688 qdisc->qstats.backlog = 0;
688} 689}
689EXPORT_SYMBOL(qdisc_reset); 690EXPORT_SYMBOL(qdisc_reset);
690 691
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index daaf214e5201..3f88b75488b0 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -958,6 +958,8 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
958 } 958 }
959 959
960 if (cl != NULL) { 960 if (cl != NULL) {
961 int old_flags;
962
961 if (parentid) { 963 if (parentid) {
962 if (cl->cl_parent && 964 if (cl->cl_parent &&
963 cl->cl_parent->cl_common.classid != parentid) 965 cl->cl_parent->cl_common.classid != parentid)
@@ -978,6 +980,8 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
978 } 980 }
979 981
980 sch_tree_lock(sch); 982 sch_tree_lock(sch);
983 old_flags = cl->cl_flags;
984
981 if (rsc != NULL) 985 if (rsc != NULL)
982 hfsc_change_rsc(cl, rsc, cur_time); 986 hfsc_change_rsc(cl, rsc, cur_time);
983 if (fsc != NULL) 987 if (fsc != NULL)
@@ -986,10 +990,21 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
986 hfsc_change_usc(cl, usc, cur_time); 990 hfsc_change_usc(cl, usc, cur_time);
987 991
988 if (cl->qdisc->q.qlen != 0) { 992 if (cl->qdisc->q.qlen != 0) {
989 if (cl->cl_flags & HFSC_RSC) 993 int len = qdisc_peek_len(cl->qdisc);
990 update_ed(cl, qdisc_peek_len(cl->qdisc)); 994
991 if (cl->cl_flags & HFSC_FSC) 995 if (cl->cl_flags & HFSC_RSC) {
992 update_vf(cl, 0, cur_time); 996 if (old_flags & HFSC_RSC)
997 update_ed(cl, len);
998 else
999 init_ed(cl, len);
1000 }
1001
1002 if (cl->cl_flags & HFSC_FSC) {
1003 if (old_flags & HFSC_FSC)
1004 update_vf(cl, 0, cur_time);
1005 else
1006 init_vf(cl, len);
1007 }
993 } 1008 }
994 sch_tree_unlock(sch); 1009 sch_tree_unlock(sch);
995 1010
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 8c6d24b2995d..745f145d4c4d 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -282,6 +282,7 @@ int smc_netinfo_by_tcpsk(struct socket *clcsock,
282 __be32 *subnet, u8 *prefix_len) 282 __be32 *subnet, u8 *prefix_len)
283{ 283{
284 struct dst_entry *dst = sk_dst_get(clcsock->sk); 284 struct dst_entry *dst = sk_dst_get(clcsock->sk);
285 struct in_device *in_dev;
285 struct sockaddr_in addr; 286 struct sockaddr_in addr;
286 int rc = -ENOENT; 287 int rc = -ENOENT;
287 int len; 288 int len;
@@ -298,14 +299,17 @@ int smc_netinfo_by_tcpsk(struct socket *clcsock,
298 /* get address to which the internal TCP socket is bound */ 299 /* get address to which the internal TCP socket is bound */
299 kernel_getsockname(clcsock, (struct sockaddr *)&addr, &len); 300 kernel_getsockname(clcsock, (struct sockaddr *)&addr, &len);
300 /* analyze IPv4 specific data of net_device belonging to TCP socket */ 301 /* analyze IPv4 specific data of net_device belonging to TCP socket */
301 for_ifa(dst->dev->ip_ptr) { 302 rcu_read_lock();
302 if (ifa->ifa_address != addr.sin_addr.s_addr) 303 in_dev = __in_dev_get_rcu(dst->dev);
304 for_ifa(in_dev) {
305 if (!inet_ifa_match(addr.sin_addr.s_addr, ifa))
303 continue; 306 continue;
304 *prefix_len = inet_mask_len(ifa->ifa_mask); 307 *prefix_len = inet_mask_len(ifa->ifa_mask);
305 *subnet = ifa->ifa_address & ifa->ifa_mask; 308 *subnet = ifa->ifa_address & ifa->ifa_mask;
306 rc = 0; 309 rc = 0;
307 break; 310 break;
308 } endfor_ifa(dst->dev->ip_ptr); 311 } endfor_ifa(in_dev);
312 rcu_read_unlock();
309 313
310out_rel: 314out_rel:
311 dst_release(dst); 315 dst_release(dst);
@@ -509,7 +513,7 @@ decline_rdma:
509 /* RDMA setup failed, switch back to TCP */ 513 /* RDMA setup failed, switch back to TCP */
510 smc->use_fallback = true; 514 smc->use_fallback = true;
511 if (reason_code && (reason_code != SMC_CLC_DECL_REPLY)) { 515 if (reason_code && (reason_code != SMC_CLC_DECL_REPLY)) {
512 rc = smc_clc_send_decline(smc, reason_code, 0); 516 rc = smc_clc_send_decline(smc, reason_code);
513 if (rc < sizeof(struct smc_clc_msg_decline)) 517 if (rc < sizeof(struct smc_clc_msg_decline))
514 goto out_err; 518 goto out_err;
515 } 519 }
@@ -804,8 +808,6 @@ static void smc_listen_work(struct work_struct *work)
804 rc = local_contact; 808 rc = local_contact;
805 if (rc == -ENOMEM) 809 if (rc == -ENOMEM)
806 reason_code = SMC_CLC_DECL_MEM;/* insufficient memory*/ 810 reason_code = SMC_CLC_DECL_MEM;/* insufficient memory*/
807 else if (rc == -ENOLINK)
808 reason_code = SMC_CLC_DECL_SYNCERR; /* synchr. error */
809 goto decline_rdma; 811 goto decline_rdma;
810 } 812 }
811 link = &new_smc->conn.lgr->lnk[SMC_SINGLE_LINK]; 813 link = &new_smc->conn.lgr->lnk[SMC_SINGLE_LINK];
@@ -899,7 +901,7 @@ decline_rdma:
899 smc_conn_free(&new_smc->conn); 901 smc_conn_free(&new_smc->conn);
900 new_smc->use_fallback = true; 902 new_smc->use_fallback = true;
901 if (reason_code && (reason_code != SMC_CLC_DECL_REPLY)) { 903 if (reason_code && (reason_code != SMC_CLC_DECL_REPLY)) {
902 rc = smc_clc_send_decline(new_smc, reason_code, 0); 904 rc = smc_clc_send_decline(new_smc, reason_code);
903 if (rc < sizeof(struct smc_clc_msg_decline)) 905 if (rc < sizeof(struct smc_clc_msg_decline))
904 goto out_err; 906 goto out_err;
905 } 907 }
diff --git a/net/smc/smc.h b/net/smc/smc.h
index 6e44313e4467..0ccd6fa387ad 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -149,7 +149,7 @@ struct smc_connection {
149 atomic_t sndbuf_space; /* remaining space in sndbuf */ 149 atomic_t sndbuf_space; /* remaining space in sndbuf */
150 u16 tx_cdc_seq; /* sequence # for CDC send */ 150 u16 tx_cdc_seq; /* sequence # for CDC send */
151 spinlock_t send_lock; /* protect wr_sends */ 151 spinlock_t send_lock; /* protect wr_sends */
152 struct work_struct tx_work; /* retry of smc_cdc_msg_send */ 152 struct delayed_work tx_work; /* retry of smc_cdc_msg_send */
153 153
154 struct smc_host_cdc_msg local_rx_ctrl; /* filled during event_handl. 154 struct smc_host_cdc_msg local_rx_ctrl; /* filled during event_handl.
155 * .prod cf. TCP rcv_nxt 155 * .prod cf. TCP rcv_nxt
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
index 3934913ab835..b7dd2743fb5c 100644
--- a/net/smc/smc_clc.c
+++ b/net/smc/smc_clc.c
@@ -95,9 +95,10 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
95 } 95 }
96 if (clcm->type == SMC_CLC_DECLINE) { 96 if (clcm->type == SMC_CLC_DECLINE) {
97 reason_code = SMC_CLC_DECL_REPLY; 97 reason_code = SMC_CLC_DECL_REPLY;
98 if (ntohl(((struct smc_clc_msg_decline *)buf)->peer_diagnosis) 98 if (((struct smc_clc_msg_decline *)buf)->hdr.flag) {
99 == SMC_CLC_DECL_SYNCERR)
100 smc->conn.lgr->sync_err = true; 99 smc->conn.lgr->sync_err = true;
100 smc_lgr_terminate(smc->conn.lgr);
101 }
101 } 102 }
102 103
103out: 104out:
@@ -105,8 +106,7 @@ out:
105} 106}
106 107
107/* send CLC DECLINE message across internal TCP socket */ 108/* send CLC DECLINE message across internal TCP socket */
108int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info, 109int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info)
109 u8 out_of_sync)
110{ 110{
111 struct smc_clc_msg_decline dclc; 111 struct smc_clc_msg_decline dclc;
112 struct msghdr msg; 112 struct msghdr msg;
@@ -118,7 +118,7 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info,
118 dclc.hdr.type = SMC_CLC_DECLINE; 118 dclc.hdr.type = SMC_CLC_DECLINE;
119 dclc.hdr.length = htons(sizeof(struct smc_clc_msg_decline)); 119 dclc.hdr.length = htons(sizeof(struct smc_clc_msg_decline));
120 dclc.hdr.version = SMC_CLC_V1; 120 dclc.hdr.version = SMC_CLC_V1;
121 dclc.hdr.flag = out_of_sync ? 1 : 0; 121 dclc.hdr.flag = (peer_diag_info == SMC_CLC_DECL_SYNCERR) ? 1 : 0;
122 memcpy(dclc.id_for_peer, local_systemid, sizeof(local_systemid)); 122 memcpy(dclc.id_for_peer, local_systemid, sizeof(local_systemid));
123 dclc.peer_diagnosis = htonl(peer_diag_info); 123 dclc.peer_diagnosis = htonl(peer_diag_info);
124 memcpy(dclc.trl.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER)); 124 memcpy(dclc.trl.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h
index 13db8ce177c9..1c55414041d4 100644
--- a/net/smc/smc_clc.h
+++ b/net/smc/smc_clc.h
@@ -106,8 +106,7 @@ struct smc_ib_device;
106 106
107int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, 107int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
108 u8 expected_type); 108 u8 expected_type);
109int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info, 109int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info);
110 u8 out_of_sync);
111int smc_clc_send_proposal(struct smc_sock *smc, struct smc_ib_device *smcibdev, 110int smc_clc_send_proposal(struct smc_sock *smc, struct smc_ib_device *smcibdev,
112 u8 ibport); 111 u8 ibport);
113int smc_clc_send_confirm(struct smc_sock *smc); 112int smc_clc_send_confirm(struct smc_sock *smc);
diff --git a/net/smc/smc_close.c b/net/smc/smc_close.c
index 3c2e166b5d22..f0d16fb825f7 100644
--- a/net/smc/smc_close.c
+++ b/net/smc/smc_close.c
@@ -174,15 +174,15 @@ int smc_close_active(struct smc_sock *smc)
174{ 174{
175 struct smc_cdc_conn_state_flags *txflags = 175 struct smc_cdc_conn_state_flags *txflags =
176 &smc->conn.local_tx_ctrl.conn_state_flags; 176 &smc->conn.local_tx_ctrl.conn_state_flags;
177 long timeout = SMC_MAX_STREAM_WAIT_TIMEOUT;
178 struct smc_connection *conn = &smc->conn; 177 struct smc_connection *conn = &smc->conn;
179 struct sock *sk = &smc->sk; 178 struct sock *sk = &smc->sk;
180 int old_state; 179 int old_state;
180 long timeout;
181 int rc = 0; 181 int rc = 0;
182 182
183 if (sock_flag(sk, SOCK_LINGER) && 183 timeout = current->flags & PF_EXITING ?
184 !(current->flags & PF_EXITING)) 184 0 : sock_flag(sk, SOCK_LINGER) ?
185 timeout = sk->sk_lingertime; 185 sk->sk_lingertime : SMC_MAX_STREAM_WAIT_TIMEOUT;
186 186
187again: 187again:
188 old_state = sk->sk_state; 188 old_state = sk->sk_state;
@@ -208,7 +208,7 @@ again:
208 case SMC_ACTIVE: 208 case SMC_ACTIVE:
209 smc_close_stream_wait(smc, timeout); 209 smc_close_stream_wait(smc, timeout);
210 release_sock(sk); 210 release_sock(sk);
211 cancel_work_sync(&conn->tx_work); 211 cancel_delayed_work_sync(&conn->tx_work);
212 lock_sock(sk); 212 lock_sock(sk);
213 if (sk->sk_state == SMC_ACTIVE) { 213 if (sk->sk_state == SMC_ACTIVE) {
214 /* send close request */ 214 /* send close request */
@@ -234,7 +234,7 @@ again:
234 if (!smc_cdc_rxed_any_close(conn)) 234 if (!smc_cdc_rxed_any_close(conn))
235 smc_close_stream_wait(smc, timeout); 235 smc_close_stream_wait(smc, timeout);
236 release_sock(sk); 236 release_sock(sk);
237 cancel_work_sync(&conn->tx_work); 237 cancel_delayed_work_sync(&conn->tx_work);
238 lock_sock(sk); 238 lock_sock(sk);
239 if (sk->sk_err != ECONNABORTED) { 239 if (sk->sk_err != ECONNABORTED) {
240 /* confirm close from peer */ 240 /* confirm close from peer */
@@ -263,7 +263,9 @@ again:
263 /* peer sending PeerConnectionClosed will cause transition */ 263 /* peer sending PeerConnectionClosed will cause transition */
264 break; 264 break;
265 case SMC_PROCESSABORT: 265 case SMC_PROCESSABORT:
266 cancel_work_sync(&conn->tx_work); 266 release_sock(sk);
267 cancel_delayed_work_sync(&conn->tx_work);
268 lock_sock(sk);
267 smc_close_abort(conn); 269 smc_close_abort(conn);
268 sk->sk_state = SMC_CLOSED; 270 sk->sk_state = SMC_CLOSED;
269 smc_close_wait_tx_pends(smc); 271 smc_close_wait_tx_pends(smc);
@@ -411,13 +413,14 @@ void smc_close_sock_put_work(struct work_struct *work)
411int smc_close_shutdown_write(struct smc_sock *smc) 413int smc_close_shutdown_write(struct smc_sock *smc)
412{ 414{
413 struct smc_connection *conn = &smc->conn; 415 struct smc_connection *conn = &smc->conn;
414 long timeout = SMC_MAX_STREAM_WAIT_TIMEOUT;
415 struct sock *sk = &smc->sk; 416 struct sock *sk = &smc->sk;
416 int old_state; 417 int old_state;
418 long timeout;
417 int rc = 0; 419 int rc = 0;
418 420
419 if (sock_flag(sk, SOCK_LINGER)) 421 timeout = current->flags & PF_EXITING ?
420 timeout = sk->sk_lingertime; 422 0 : sock_flag(sk, SOCK_LINGER) ?
423 sk->sk_lingertime : SMC_MAX_STREAM_WAIT_TIMEOUT;
421 424
422again: 425again:
423 old_state = sk->sk_state; 426 old_state = sk->sk_state;
@@ -425,7 +428,7 @@ again:
425 case SMC_ACTIVE: 428 case SMC_ACTIVE:
426 smc_close_stream_wait(smc, timeout); 429 smc_close_stream_wait(smc, timeout);
427 release_sock(sk); 430 release_sock(sk);
428 cancel_work_sync(&conn->tx_work); 431 cancel_delayed_work_sync(&conn->tx_work);
429 lock_sock(sk); 432 lock_sock(sk);
430 /* send close wr request */ 433 /* send close wr request */
431 rc = smc_close_wr(conn); 434 rc = smc_close_wr(conn);
@@ -439,7 +442,7 @@ again:
439 if (!smc_cdc_rxed_any_close(conn)) 442 if (!smc_cdc_rxed_any_close(conn))
440 smc_close_stream_wait(smc, timeout); 443 smc_close_stream_wait(smc, timeout);
441 release_sock(sk); 444 release_sock(sk);
442 cancel_work_sync(&conn->tx_work); 445 cancel_delayed_work_sync(&conn->tx_work);
443 lock_sock(sk); 446 lock_sock(sk);
444 /* confirm close from peer */ 447 /* confirm close from peer */
445 rc = smc_close_wr(conn); 448 rc = smc_close_wr(conn);
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 1a16d51e2330..20b66e79c5d6 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -25,8 +25,9 @@
25#include "smc_cdc.h" 25#include "smc_cdc.h"
26#include "smc_close.h" 26#include "smc_close.h"
27 27
28#define SMC_LGR_NUM_INCR 256 28#define SMC_LGR_NUM_INCR 256
29#define SMC_LGR_FREE_DELAY (600 * HZ) 29#define SMC_LGR_FREE_DELAY_SERV (600 * HZ)
30#define SMC_LGR_FREE_DELAY_CLNT (SMC_LGR_FREE_DELAY_SERV + 10)
30 31
31static u32 smc_lgr_num; /* unique link group number */ 32static u32 smc_lgr_num; /* unique link group number */
32 33
@@ -107,8 +108,15 @@ static void smc_lgr_unregister_conn(struct smc_connection *conn)
107 __smc_lgr_unregister_conn(conn); 108 __smc_lgr_unregister_conn(conn);
108 } 109 }
109 write_unlock_bh(&lgr->conns_lock); 110 write_unlock_bh(&lgr->conns_lock);
110 if (reduced && !lgr->conns_num) 111 if (!reduced || lgr->conns_num)
111 schedule_delayed_work(&lgr->free_work, SMC_LGR_FREE_DELAY); 112 return;
113 /* client link group creation always follows the server link group
114 * creation. For client use a somewhat higher removal delay time,
115 * otherwise there is a risk of out-of-sync link groups.
116 */
117 mod_delayed_work(system_wq, &lgr->free_work,
118 lgr->role == SMC_CLNT ? SMC_LGR_FREE_DELAY_CLNT :
119 SMC_LGR_FREE_DELAY_SERV);
112} 120}
113 121
114static void smc_lgr_free_work(struct work_struct *work) 122static void smc_lgr_free_work(struct work_struct *work)
diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c
index 547e0e113b17..0b5852299158 100644
--- a/net/smc/smc_ib.c
+++ b/net/smc/smc_ib.c
@@ -380,6 +380,7 @@ static int smc_ib_fill_gid_and_mac(struct smc_ib_device *smcibdev, u8 ibport)
380 ndev = smcibdev->ibdev->get_netdev(smcibdev->ibdev, ibport); 380 ndev = smcibdev->ibdev->get_netdev(smcibdev->ibdev, ibport);
381 if (ndev) { 381 if (ndev) {
382 memcpy(&smcibdev->mac, ndev->dev_addr, ETH_ALEN); 382 memcpy(&smcibdev->mac, ndev->dev_addr, ETH_ALEN);
383 dev_put(ndev);
383 } else if (!rc) { 384 } else if (!rc) {
384 memcpy(&smcibdev->mac[ibport - 1][0], 385 memcpy(&smcibdev->mac[ibport - 1][0],
385 &smcibdev->gid[ibport - 1].raw[8], 3); 386 &smcibdev->gid[ibport - 1].raw[8], 3);
diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c
index 78f7af28ae4f..31f8453c25c5 100644
--- a/net/smc/smc_pnet.c
+++ b/net/smc/smc_pnet.c
@@ -181,8 +181,10 @@ static int smc_pnet_enter(struct smc_pnetentry *new_pnetelem)
181 sizeof(new_pnetelem->ndev->name)) || 181 sizeof(new_pnetelem->ndev->name)) ||
182 smc_pnet_same_ibname(pnetelem, 182 smc_pnet_same_ibname(pnetelem,
183 new_pnetelem->smcibdev->ibdev->name, 183 new_pnetelem->smcibdev->ibdev->name,
184 new_pnetelem->ib_port)) 184 new_pnetelem->ib_port)) {
185 dev_put(pnetelem->ndev);
185 goto found; 186 goto found;
187 }
186 } 188 }
187 list_add_tail(&new_pnetelem->list, &smc_pnettable.pnetlist); 189 list_add_tail(&new_pnetelem->list, &smc_pnettable.pnetlist);
188 rc = 0; 190 rc = 0;
diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c
index b17a333e9bb0..3e631ae4b6b6 100644
--- a/net/smc/smc_rx.c
+++ b/net/smc/smc_rx.c
@@ -148,6 +148,8 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg, size_t len,
148 read_done = sock_intr_errno(timeo); 148 read_done = sock_intr_errno(timeo);
149 break; 149 break;
150 } 150 }
151 if (!timeo)
152 return -EAGAIN;
151 } 153 }
152 154
153 if (!atomic_read(&conn->bytes_to_rcv)) { 155 if (!atomic_read(&conn->bytes_to_rcv)) {
diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
index 3c656beb8820..3866573288dd 100644
--- a/net/smc/smc_tx.c
+++ b/net/smc/smc_tx.c
@@ -24,6 +24,8 @@
24#include "smc_cdc.h" 24#include "smc_cdc.h"
25#include "smc_tx.h" 25#include "smc_tx.h"
26 26
27#define SMC_TX_WORK_DELAY HZ
28
27/***************************** sndbuf producer *******************************/ 29/***************************** sndbuf producer *******************************/
28 30
29/* callback implementation for sk.sk_write_space() 31/* callback implementation for sk.sk_write_space()
@@ -406,7 +408,8 @@ int smc_tx_sndbuf_nonempty(struct smc_connection *conn)
406 goto out_unlock; 408 goto out_unlock;
407 } 409 }
408 rc = 0; 410 rc = 0;
409 schedule_work(&conn->tx_work); 411 schedule_delayed_work(&conn->tx_work,
412 SMC_TX_WORK_DELAY);
410 } 413 }
411 goto out_unlock; 414 goto out_unlock;
412 } 415 }
@@ -430,7 +433,7 @@ out_unlock:
430 */ 433 */
431static void smc_tx_work(struct work_struct *work) 434static void smc_tx_work(struct work_struct *work)
432{ 435{
433 struct smc_connection *conn = container_of(work, 436 struct smc_connection *conn = container_of(to_delayed_work(work),
434 struct smc_connection, 437 struct smc_connection,
435 tx_work); 438 tx_work);
436 struct smc_sock *smc = container_of(conn, struct smc_sock, conn); 439 struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
@@ -468,7 +471,8 @@ void smc_tx_consumer_update(struct smc_connection *conn)
468 if (!rc) 471 if (!rc)
469 rc = smc_cdc_msg_send(conn, wr_buf, pend); 472 rc = smc_cdc_msg_send(conn, wr_buf, pend);
470 if (rc < 0) { 473 if (rc < 0) {
471 schedule_work(&conn->tx_work); 474 schedule_delayed_work(&conn->tx_work,
475 SMC_TX_WORK_DELAY);
472 return; 476 return;
473 } 477 }
474 smc_curs_write(&conn->rx_curs_confirmed, 478 smc_curs_write(&conn->rx_curs_confirmed,
@@ -487,6 +491,6 @@ void smc_tx_consumer_update(struct smc_connection *conn)
487void smc_tx_init(struct smc_sock *smc) 491void smc_tx_init(struct smc_sock *smc)
488{ 492{
489 smc->sk.sk_write_space = smc_tx_write_space; 493 smc->sk.sk_write_space = smc_tx_write_space;
490 INIT_WORK(&smc->conn.tx_work, smc_tx_work); 494 INIT_DELAYED_WORK(&smc->conn.tx_work, smc_tx_work);
491 spin_lock_init(&smc->conn.send_lock); 495 spin_lock_init(&smc->conn.send_lock);
492} 496}
diff --git a/net/smc/smc_wr.c b/net/smc/smc_wr.c
index ab56bda66783..525d91e0d57e 100644
--- a/net/smc/smc_wr.c
+++ b/net/smc/smc_wr.c
@@ -244,7 +244,7 @@ int smc_wr_tx_send(struct smc_link *link, struct smc_wr_tx_pend_priv *priv)
244 int rc; 244 int rc;
245 245
246 ib_req_notify_cq(link->smcibdev->roce_cq_send, 246 ib_req_notify_cq(link->smcibdev->roce_cq_send,
247 IB_CQ_SOLICITED_MASK | IB_CQ_REPORT_MISSED_EVENTS); 247 IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS);
248 pend = container_of(priv, struct smc_wr_tx_pend, priv); 248 pend = container_of(priv, struct smc_wr_tx_pend, priv);
249 rc = ib_post_send(link->roce_qp, &link->wr_tx_ibs[pend->idx], 249 rc = ib_post_send(link->roce_qp, &link->wr_tx_ibs[pend->idx],
250 &failed_wr); 250 &failed_wr);
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0df8023f480b..690874293cfc 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9987,6 +9987,9 @@ static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info)
9987 if (err) 9987 if (err)
9988 return err; 9988 return err;
9989 9989
9990 if (!setup.chandef.chan)
9991 return -EINVAL;
9992
9990 err = validate_beacon_tx_rate(rdev, setup.chandef.chan->band, 9993 err = validate_beacon_tx_rate(rdev, setup.chandef.chan->band,
9991 &setup.beacon_rate); 9994 &setup.beacon_rate);
9992 if (err) 9995 if (err)
@@ -10903,6 +10906,9 @@ static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info)
10903 if (err) 10906 if (err)
10904 return err; 10907 return err;
10905 10908
10909 if (!tb[NL80211_REKEY_DATA_REPLAY_CTR] || !tb[NL80211_REKEY_DATA_KEK] ||
10910 !tb[NL80211_REKEY_DATA_KCK])
10911 return -EINVAL;
10906 if (nla_len(tb[NL80211_REKEY_DATA_REPLAY_CTR]) != NL80211_REPLAY_CTR_LEN) 10912 if (nla_len(tb[NL80211_REKEY_DATA_REPLAY_CTR]) != NL80211_REPLAY_CTR_LEN)
10907 return -ERANGE; 10913 return -ERANGE;
10908 if (nla_len(tb[NL80211_REKEY_DATA_KEK]) != NL80211_KEK_LEN) 10914 if (nla_len(tb[NL80211_REKEY_DATA_KEK]) != NL80211_KEK_LEN)