aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-08-01 01:36:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-08-01 01:36:42 -0400
commitbc78d646e708dabd1744ca98744dea316f459497 (patch)
treedf6b415574bb8fddc04e97e1cec92d108281bc13
parent2e7ca2064cbb070834233ea540ac9c2ff0d09894 (diff)
parentcc75f8514db6a3aec517760fccaf954e5b46478c (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Handle notifier registry failures properly in tun/tap driver, from Tonghao Zhang. 2) Fix bpf verifier handling of subtraction bounds and add a testcase for this, from Edward Cree. 3) Increase reset timeout in ftgmac100 driver, from Ben Herrenschmidt. 4) Fix use after free in prd_retire_rx_blk_timer_exired() in AF_PACKET, from Cong Wang. 5) Fix SElinux regression due to recent UDP optimizations, from Paolo Abeni. 6) We accidently increment IPSTATS_MIB_FRAGFAILS in the ipv6 code paths, fix from Stefano Brivio. 7) Fix some mem leaks in dccp, from Xin Long. 8) Adjust MDIO_BUS kconfig deps to avoid build errors, from Arnd Bergmann. 9) Mac address length check and buffer size fixes from Cong Wang. 10) Don't leak sockets in ipv6 udp early demux, from Paolo Abeni. 11) Fix return value when copy_from_user() fails in bpf_prog_get_info_by_fd(), from Daniel Borkmann. 12) Handle PHY_HALTED properly in phy library state machine, from Florian Fainelli. 13) Fix OOPS in fib_sync_down_dev(), from Ido Schimmel. 14) Fix truesize calculation in virtio_net which led to performance regressions, from Michael S Tsirkin. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (76 commits) samples/bpf: fix bpf tunnel cleanup udp6: fix jumbogram reception ppp: Fix a scheduling-while-atomic bug in del_chan Revert "net: bcmgenet: Remove init parameter from bcmgenet_mii_config" virtio_net: fix truesize for mergeable buffers mv643xx_eth: fix of_irq_to_resource() error check MAINTAINERS: Add more files to the PHY LIBRARY section ipv4: fib: Fix NULL pointer deref during fib_sync_down_dev() net: phy: Correctly process PHY_HALTED in phy_stop_machine() sunhme: fix up GREG_STAT and GREG_IMASK register offsets bpf: fix bpf_prog_get_info_by_fd to dump correct xlated_prog_len tcp: avoid bogus gcc-7 array-bounds warning net: tc35815: fix spelling mistake: "Intterrupt" -> "Interrupt" bpf: don't indicate success when copy_from_user fails udp6: fix socket leak on early demux net: thunderx: Fix BGX transmit stall due to underflow Revert "vhost: cache used event for better performance" team: use a larger struct for mac address net: check dev->addr_len for dev_set_mac_address() phy: bcm-ns-usb3: fix MDIO_BUS dependency ...
-rw-r--r--MAINTAINERS14
-rw-r--r--drivers/net/bonding/bond_main.c2
-rw-r--r--drivers/net/ethernet/aurora/nb8800.c9
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.c2
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.h2
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmmii.c7
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.c27
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.h2
-rw-r--r--drivers/net/ethernet/faraday/ftgmac100.c7
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c2
-rw-r--r--drivers/net/ethernet/mediatek/mtk_eth_soc.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/cmd.c25
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h10
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_clock.c222
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eq.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c16
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/lag.c25
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h5
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/sriov.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c7
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c5
-rw-r--r--drivers/net/ethernet/sun/sunhme.h6
-rw-r--r--drivers/net/ethernet/toshiba/tc35815.c2
-rw-r--r--drivers/net/hyperv/netvsc_drv.c43
-rw-r--r--drivers/net/irda/mcs7780.c16
-rw-r--r--drivers/net/phy/Kconfig13
-rw-r--r--drivers/net/phy/phy.c3
-rw-r--r--drivers/net/ppp/pptp.c2
-rw-r--r--drivers/net/team/team.c8
-rw-r--r--drivers/net/tun.c10
-rw-r--r--drivers/net/virtio_net.c5
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c2
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c8
-rw-r--r--drivers/net/wireless/intel/iwlwifi/dvm/tx.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-devtrace.h4
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c8
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mvm.h2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/ops.c6
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/sta.c15
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/trans.c3
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/tx.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/wifi.h1
-rw-r--r--drivers/phy/broadcom/Kconfig2
-rw-r--r--drivers/vhost/vhost.c28
-rw-r--r--drivers/vhost/vhost.h3
-rw-r--r--include/linux/ipv6.h6
-rw-r--r--include/linux/mlx5/mlx5_ifc.h10
-rw-r--r--include/linux/phy.h2
-rw-r--r--include/net/sctp/sctp.h4
-rw-r--r--include/net/udp.h34
-rw-r--r--kernel/bpf/syscall.c4
-rw-r--r--kernel/bpf/verifier.c21
-rw-r--r--lib/test_rhashtable.c57
-rw-r--r--net/core/dev_ioctl.c2
-rw-r--r--net/core/netpoll.c2
-rw-r--r--net/dccp/feat.c7
-rw-r--r--net/dccp/ipv4.c1
-rw-r--r--net/dccp/ipv6.c1
-rw-r--r--net/dsa/dsa2.c13
-rw-r--r--net/ipv4/fib_semantics.c2
-rw-r--r--net/ipv4/tcp_output.c5
-rw-r--r--net/ipv4/udp.c41
-rw-r--r--net/ipv6/exthdrs.c1
-rw-r--r--net/ipv6/ip6_output.c4
-rw-r--r--net/ipv6/udp.c38
-rw-r--r--net/openvswitch/conntrack.c7
-rw-r--r--net/packet/af_packet.c2
-rw-r--r--net/socket.c5
-rw-r--r--samples/bpf/tcbpf2_kern.c4
-rwxr-xr-xsamples/bpf/test_tunnel_bpf.sh1
-rw-r--r--tools/lib/bpf/bpf.c1
-rw-r--r--tools/testing/selftests/bpf/test_progs.c8
-rw-r--r--tools/testing/selftests/bpf/test_verifier.c28
80 files changed, 629 insertions, 296 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index f66488dfdbc9..567343b8ffaa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5090,12 +5090,20 @@ M: Andrew Lunn <andrew@lunn.ch>
5090M: Florian Fainelli <f.fainelli@gmail.com> 5090M: Florian Fainelli <f.fainelli@gmail.com>
5091L: netdev@vger.kernel.org 5091L: netdev@vger.kernel.org
5092S: Maintained 5092S: Maintained
5093F: include/linux/phy.h 5093F: Documentation/ABI/testing/sysfs-bus-mdio
5094F: include/linux/phy_fixed.h 5094F: Documentation/devicetree/bindings/net/mdio*
5095F: drivers/net/phy/
5096F: Documentation/networking/phy.txt 5095F: Documentation/networking/phy.txt
5096F: drivers/net/phy/
5097F: drivers/of/of_mdio.c 5097F: drivers/of/of_mdio.c
5098F: drivers/of/of_net.c 5098F: drivers/of/of_net.c
5099F: include/linux/*mdio*.h
5100F: include/linux/of_net.h
5101F: include/linux/phy.h
5102F: include/linux/phy_fixed.h
5103F: include/linux/platform_data/mdio-gpio.h
5104F: include/trace/events/mdio.h
5105F: include/uapi/linux/mdio.h
5106F: include/uapi/linux/mii.h
5099 5107
5100EXT2 FILE SYSTEM 5108EXT2 FILE SYSTEM
5101M: Jan Kara <jack@suse.com> 5109M: Jan Kara <jack@suse.com>
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 181839d6fbea..9bee6c1c70cc 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2050,6 +2050,7 @@ static int bond_miimon_inspect(struct bonding *bond)
2050 continue; 2050 continue;
2051 2051
2052 bond_propose_link_state(slave, BOND_LINK_FAIL); 2052 bond_propose_link_state(slave, BOND_LINK_FAIL);
2053 commit++;
2053 slave->delay = bond->params.downdelay; 2054 slave->delay = bond->params.downdelay;
2054 if (slave->delay) { 2055 if (slave->delay) {
2055 netdev_info(bond->dev, "link status down for %sinterface %s, disabling it in %d ms\n", 2056 netdev_info(bond->dev, "link status down for %sinterface %s, disabling it in %d ms\n",
@@ -2088,6 +2089,7 @@ static int bond_miimon_inspect(struct bonding *bond)
2088 continue; 2089 continue;
2089 2090
2090 bond_propose_link_state(slave, BOND_LINK_BACK); 2091 bond_propose_link_state(slave, BOND_LINK_BACK);
2092 commit++;
2091 slave->delay = bond->params.updelay; 2093 slave->delay = bond->params.updelay;
2092 2094
2093 if (slave->delay) { 2095 if (slave->delay) {
diff --git a/drivers/net/ethernet/aurora/nb8800.c b/drivers/net/ethernet/aurora/nb8800.c
index 041cfb7952f8..e94159507847 100644
--- a/drivers/net/ethernet/aurora/nb8800.c
+++ b/drivers/net/ethernet/aurora/nb8800.c
@@ -609,7 +609,7 @@ static void nb8800_mac_config(struct net_device *dev)
609 mac_mode |= HALF_DUPLEX; 609 mac_mode |= HALF_DUPLEX;
610 610
611 if (gigabit) { 611 if (gigabit) {
612 if (priv->phy_mode == PHY_INTERFACE_MODE_RGMII) 612 if (phy_interface_is_rgmii(dev->phydev))
613 mac_mode |= RGMII_MODE; 613 mac_mode |= RGMII_MODE;
614 614
615 mac_mode |= GMAC_MODE; 615 mac_mode |= GMAC_MODE;
@@ -1268,11 +1268,10 @@ static int nb8800_tangox_init(struct net_device *dev)
1268 break; 1268 break;
1269 1269
1270 case PHY_INTERFACE_MODE_RGMII: 1270 case PHY_INTERFACE_MODE_RGMII:
1271 pad_mode = PAD_MODE_RGMII; 1271 case PHY_INTERFACE_MODE_RGMII_ID:
1272 break; 1272 case PHY_INTERFACE_MODE_RGMII_RXID:
1273
1274 case PHY_INTERFACE_MODE_RGMII_TXID: 1273 case PHY_INTERFACE_MODE_RGMII_TXID:
1275 pad_mode = PAD_MODE_RGMII | PAD_MODE_GTX_CLK_DELAY; 1274 pad_mode = PAD_MODE_RGMII;
1276 break; 1275 break;
1277 1276
1278 default: 1277 default:
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 7b0b399aaedd..a981c4ee9d72 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -3669,7 +3669,7 @@ static int bcmgenet_resume(struct device *d)
3669 3669
3670 phy_init_hw(priv->phydev); 3670 phy_init_hw(priv->phydev);
3671 /* Speed settings must be restored */ 3671 /* Speed settings must be restored */
3672 bcmgenet_mii_config(priv->dev); 3672 bcmgenet_mii_config(priv->dev, false);
3673 3673
3674 /* disable ethernet MAC while updating its registers */ 3674 /* disable ethernet MAC while updating its registers */
3675 umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, false); 3675 umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, false);
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
index b9344de669f8..3a34fdba5301 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
@@ -698,7 +698,7 @@ GENET_IO_MACRO(rbuf, GENET_RBUF_OFF);
698 698
699/* MDIO routines */ 699/* MDIO routines */
700int bcmgenet_mii_init(struct net_device *dev); 700int bcmgenet_mii_init(struct net_device *dev);
701int bcmgenet_mii_config(struct net_device *dev); 701int bcmgenet_mii_config(struct net_device *dev, bool init);
702int bcmgenet_mii_probe(struct net_device *dev); 702int bcmgenet_mii_probe(struct net_device *dev);
703void bcmgenet_mii_exit(struct net_device *dev); 703void bcmgenet_mii_exit(struct net_device *dev);
704void bcmgenet_mii_reset(struct net_device *dev); 704void bcmgenet_mii_reset(struct net_device *dev);
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 071fcbd14e6a..30cb97b4a1d7 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -238,7 +238,7 @@ static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv)
238 bcmgenet_fixed_phy_link_update); 238 bcmgenet_fixed_phy_link_update);
239} 239}
240 240
241int bcmgenet_mii_config(struct net_device *dev) 241int bcmgenet_mii_config(struct net_device *dev, bool init)
242{ 242{
243 struct bcmgenet_priv *priv = netdev_priv(dev); 243 struct bcmgenet_priv *priv = netdev_priv(dev);
244 struct phy_device *phydev = priv->phydev; 244 struct phy_device *phydev = priv->phydev;
@@ -327,7 +327,8 @@ int bcmgenet_mii_config(struct net_device *dev)
327 bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL); 327 bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL);
328 } 328 }
329 329
330 dev_info_once(kdev, "configuring instance for %s\n", phy_name); 330 if (init)
331 dev_info(kdev, "configuring instance for %s\n", phy_name);
331 332
332 return 0; 333 return 0;
333} 334}
@@ -375,7 +376,7 @@ int bcmgenet_mii_probe(struct net_device *dev)
375 * PHY speed which is needed for bcmgenet_mii_config() to configure 376 * PHY speed which is needed for bcmgenet_mii_config() to configure
376 * things appropriately. 377 * things appropriately.
377 */ 378 */
378 ret = bcmgenet_mii_config(dev); 379 ret = bcmgenet_mii_config(dev, true);
379 if (ret) { 380 if (ret) {
380 phy_disconnect(priv->phydev); 381 phy_disconnect(priv->phydev);
381 return ret; 382 return ret;
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 79112563a25a..5e5c4d7796b8 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -292,11 +292,30 @@ static void bgx_sgmii_change_link_state(struct lmac *lmac)
292 u64 cmr_cfg; 292 u64 cmr_cfg;
293 u64 port_cfg = 0; 293 u64 port_cfg = 0;
294 u64 misc_ctl = 0; 294 u64 misc_ctl = 0;
295 bool tx_en, rx_en;
295 296
296 cmr_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_CMRX_CFG); 297 cmr_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_CMRX_CFG);
297 cmr_cfg &= ~CMR_EN; 298 tx_en = cmr_cfg & CMR_PKT_TX_EN;
299 rx_en = cmr_cfg & CMR_PKT_RX_EN;
300 cmr_cfg &= ~(CMR_PKT_RX_EN | CMR_PKT_TX_EN);
298 bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg); 301 bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg);
299 302
303 /* Wait for BGX RX to be idle */
304 if (bgx_poll_reg(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG,
305 GMI_PORT_CFG_RX_IDLE, false)) {
306 dev_err(&bgx->pdev->dev, "BGX%d LMAC%d GMI RX not idle\n",
307 bgx->bgx_id, lmac->lmacid);
308 return;
309 }
310
311 /* Wait for BGX TX to be idle */
312 if (bgx_poll_reg(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG,
313 GMI_PORT_CFG_TX_IDLE, false)) {
314 dev_err(&bgx->pdev->dev, "BGX%d LMAC%d GMI TX not idle\n",
315 bgx->bgx_id, lmac->lmacid);
316 return;
317 }
318
300 port_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG); 319 port_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG);
301 misc_ctl = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_PCS_MISCX_CTL); 320 misc_ctl = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_PCS_MISCX_CTL);
302 321
@@ -347,10 +366,8 @@ static void bgx_sgmii_change_link_state(struct lmac *lmac)
347 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_PCS_MISCX_CTL, misc_ctl); 366 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_PCS_MISCX_CTL, misc_ctl);
348 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG, port_cfg); 367 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG, port_cfg);
349 368
350 port_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG); 369 /* Restore CMR config settings */
351 370 cmr_cfg |= (rx_en ? CMR_PKT_RX_EN : 0) | (tx_en ? CMR_PKT_TX_EN : 0);
352 /* Re-enable lmac */
353 cmr_cfg |= CMR_EN;
354 bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg); 371 bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg);
355 372
356 if (bgx->is_rgx && (cmr_cfg & (CMR_PKT_RX_EN | CMR_PKT_TX_EN))) 373 if (bgx->is_rgx && (cmr_cfg & (CMR_PKT_RX_EN | CMR_PKT_TX_EN)))
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
index 6b7fe6fdd13b..23acdc5ab896 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
@@ -170,6 +170,8 @@
170#define GMI_PORT_CFG_DUPLEX BIT_ULL(2) 170#define GMI_PORT_CFG_DUPLEX BIT_ULL(2)
171#define GMI_PORT_CFG_SLOT_TIME BIT_ULL(3) 171#define GMI_PORT_CFG_SLOT_TIME BIT_ULL(3)
172#define GMI_PORT_CFG_SPEED_MSB BIT_ULL(8) 172#define GMI_PORT_CFG_SPEED_MSB BIT_ULL(8)
173#define GMI_PORT_CFG_RX_IDLE BIT_ULL(12)
174#define GMI_PORT_CFG_TX_IDLE BIT_ULL(13)
173#define BGX_GMP_GMI_RXX_JABBER 0x38038 175#define BGX_GMP_GMI_RXX_JABBER 0x38038
174#define BGX_GMP_GMI_TXX_THRESH 0x38210 176#define BGX_GMP_GMI_TXX_THRESH 0x38210
175#define BGX_GMP_GMI_TXX_APPEND 0x38218 177#define BGX_GMP_GMI_TXX_APPEND 0x38218
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 95bf5e89cfd1..34dae51effd4 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -125,7 +125,7 @@ static int ftgmac100_reset_mac(struct ftgmac100 *priv, u32 maccr)
125 iowrite32(maccr, priv->base + FTGMAC100_OFFSET_MACCR); 125 iowrite32(maccr, priv->base + FTGMAC100_OFFSET_MACCR);
126 iowrite32(maccr | FTGMAC100_MACCR_SW_RST, 126 iowrite32(maccr | FTGMAC100_MACCR_SW_RST,
127 priv->base + FTGMAC100_OFFSET_MACCR); 127 priv->base + FTGMAC100_OFFSET_MACCR);
128 for (i = 0; i < 50; i++) { 128 for (i = 0; i < 200; i++) {
129 unsigned int maccr; 129 unsigned int maccr;
130 130
131 maccr = ioread32(priv->base + FTGMAC100_OFFSET_MACCR); 131 maccr = ioread32(priv->base + FTGMAC100_OFFSET_MACCR);
@@ -392,7 +392,7 @@ static int ftgmac100_alloc_rx_buf(struct ftgmac100 *priv, unsigned int entry,
392 struct net_device *netdev = priv->netdev; 392 struct net_device *netdev = priv->netdev;
393 struct sk_buff *skb; 393 struct sk_buff *skb;
394 dma_addr_t map; 394 dma_addr_t map;
395 int err; 395 int err = 0;
396 396
397 skb = netdev_alloc_skb_ip_align(netdev, RX_BUF_SIZE); 397 skb = netdev_alloc_skb_ip_align(netdev, RX_BUF_SIZE);
398 if (unlikely(!skb)) { 398 if (unlikely(!skb)) {
@@ -428,7 +428,7 @@ static int ftgmac100_alloc_rx_buf(struct ftgmac100 *priv, unsigned int entry,
428 else 428 else
429 rxdes->rxdes0 = 0; 429 rxdes->rxdes0 = 0;
430 430
431 return 0; 431 return err;
432} 432}
433 433
434static unsigned int ftgmac100_next_rx_pointer(struct ftgmac100 *priv, 434static unsigned int ftgmac100_next_rx_pointer(struct ftgmac100 *priv,
@@ -1682,6 +1682,7 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
1682 priv->mii_bus->name = "ftgmac100_mdio"; 1682 priv->mii_bus->name = "ftgmac100_mdio";
1683 snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%d", 1683 snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%d",
1684 pdev->name, pdev->id); 1684 pdev->name, pdev->id);
1685 priv->mii_bus->parent = priv->dev;
1685 priv->mii_bus->priv = priv->netdev; 1686 priv->mii_bus->priv = priv->netdev;
1686 priv->mii_bus->read = ftgmac100_mdiobus_read; 1687 priv->mii_bus->read = ftgmac100_mdiobus_read;
1687 priv->mii_bus->write = ftgmac100_mdiobus_write; 1688 priv->mii_bus->write = ftgmac100_mdiobus_write;
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 5794d98d946f..9c94ea9b2b80 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2734,7 +2734,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
2734 ppd.shared = pdev; 2734 ppd.shared = pdev;
2735 2735
2736 memset(&res, 0, sizeof(res)); 2736 memset(&res, 0, sizeof(res));
2737 if (!of_irq_to_resource(pnp, 0, &res)) { 2737 if (of_irq_to_resource(pnp, 0, &res) <= 0) {
2738 dev_err(&pdev->dev, "missing interrupt on %s\n", pnp->name); 2738 dev_err(&pdev->dev, "missing interrupt on %s\n", pnp->name);
2739 return -EINVAL; 2739 return -EINVAL;
2740 } 2740 }
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index b3d0c2e6347a..e588a0cdb074 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -22,6 +22,7 @@
22#include <linux/if_vlan.h> 22#include <linux/if_vlan.h>
23#include <linux/reset.h> 23#include <linux/reset.h>
24#include <linux/tcp.h> 24#include <linux/tcp.h>
25#include <linux/interrupt.h>
25 26
26#include "mtk_eth_soc.h" 27#include "mtk_eth_soc.h"
27 28
@@ -947,6 +948,10 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
947 RX_DMA_FPORT_MASK; 948 RX_DMA_FPORT_MASK;
948 mac--; 949 mac--;
949 950
951 if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
952 !eth->netdev[mac]))
953 goto release_desc;
954
950 netdev = eth->netdev[mac]; 955 netdev = eth->netdev[mac];
951 956
952 if (unlikely(test_bit(MTK_RESETTING, &eth->state))) 957 if (unlikely(test_bit(MTK_RESETTING, &eth->state)))
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index f5a2c605749f..31cbe5e86a01 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -786,6 +786,10 @@ static void cb_timeout_handler(struct work_struct *work)
786 mlx5_cmd_comp_handler(dev, 1UL << ent->idx, true); 786 mlx5_cmd_comp_handler(dev, 1UL << ent->idx, true);
787} 787}
788 788
789static void free_msg(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *msg);
790static void mlx5_free_cmd_msg(struct mlx5_core_dev *dev,
791 struct mlx5_cmd_msg *msg);
792
789static void cmd_work_handler(struct work_struct *work) 793static void cmd_work_handler(struct work_struct *work)
790{ 794{
791 struct mlx5_cmd_work_ent *ent = container_of(work, struct mlx5_cmd_work_ent, work); 795 struct mlx5_cmd_work_ent *ent = container_of(work, struct mlx5_cmd_work_ent, work);
@@ -796,17 +800,28 @@ static void cmd_work_handler(struct work_struct *work)
796 struct semaphore *sem; 800 struct semaphore *sem;
797 unsigned long flags; 801 unsigned long flags;
798 bool poll_cmd = ent->polling; 802 bool poll_cmd = ent->polling;
803 int alloc_ret;
799 804
800 805
801 sem = ent->page_queue ? &cmd->pages_sem : &cmd->sem; 806 sem = ent->page_queue ? &cmd->pages_sem : &cmd->sem;
802 down(sem); 807 down(sem);
803 if (!ent->page_queue) { 808 if (!ent->page_queue) {
804 ent->idx = alloc_ent(cmd); 809 alloc_ret = alloc_ent(cmd);
805 if (ent->idx < 0) { 810 if (alloc_ret < 0) {
806 mlx5_core_err(dev, "failed to allocate command entry\n"); 811 mlx5_core_err(dev, "failed to allocate command entry\n");
812 if (ent->callback) {
813 ent->callback(-EAGAIN, ent->context);
814 mlx5_free_cmd_msg(dev, ent->out);
815 free_msg(dev, ent->in);
816 free_cmd(ent);
817 } else {
818 ent->ret = -EAGAIN;
819 complete(&ent->done);
820 }
807 up(sem); 821 up(sem);
808 return; 822 return;
809 } 823 }
824 ent->idx = alloc_ret;
810 } else { 825 } else {
811 ent->idx = cmd->max_reg_cmds; 826 ent->idx = cmd->max_reg_cmds;
812 spin_lock_irqsave(&cmd->alloc_lock, flags); 827 spin_lock_irqsave(&cmd->alloc_lock, flags);
@@ -967,7 +982,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
967 982
968 err = wait_func(dev, ent); 983 err = wait_func(dev, ent);
969 if (err == -ETIMEDOUT) 984 if (err == -ETIMEDOUT)
970 goto out_free; 985 goto out;
971 986
972 ds = ent->ts2 - ent->ts1; 987 ds = ent->ts2 - ent->ts1;
973 op = MLX5_GET(mbox_in, in->first.data, opcode); 988 op = MLX5_GET(mbox_in, in->first.data, opcode);
@@ -1430,6 +1445,7 @@ void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool forced)
1430 mlx5_core_err(dev, "Command completion arrived after timeout (entry idx = %d).\n", 1445 mlx5_core_err(dev, "Command completion arrived after timeout (entry idx = %d).\n",
1431 ent->idx); 1446 ent->idx);
1432 free_ent(cmd, ent->idx); 1447 free_ent(cmd, ent->idx);
1448 free_cmd(ent);
1433 } 1449 }
1434 continue; 1450 continue;
1435 } 1451 }
@@ -1488,7 +1504,8 @@ void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool forced)
1488 free_msg(dev, ent->in); 1504 free_msg(dev, ent->in);
1489 1505
1490 err = err ? err : ent->status; 1506 err = err ? err : ent->status;
1491 free_cmd(ent); 1507 if (!forced)
1508 free_cmd(ent);
1492 callback(err, context); 1509 callback(err, context);
1493 } else { 1510 } else {
1494 complete(&ent->done); 1511 complete(&ent->done);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index e1b7ddfecd01..0039b4725405 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -266,6 +266,14 @@ struct mlx5e_dcbx {
266}; 266};
267#endif 267#endif
268 268
269#define MAX_PIN_NUM 8
270struct mlx5e_pps {
271 u8 pin_caps[MAX_PIN_NUM];
272 struct work_struct out_work;
273 u64 start[MAX_PIN_NUM];
274 u8 enabled;
275};
276
269struct mlx5e_tstamp { 277struct mlx5e_tstamp {
270 rwlock_t lock; 278 rwlock_t lock;
271 struct cyclecounter cycles; 279 struct cyclecounter cycles;
@@ -277,7 +285,7 @@ struct mlx5e_tstamp {
277 struct mlx5_core_dev *mdev; 285 struct mlx5_core_dev *mdev;
278 struct ptp_clock *ptp; 286 struct ptp_clock *ptp;
279 struct ptp_clock_info ptp_info; 287 struct ptp_clock_info ptp_info;
280 u8 *pps_pin_caps; 288 struct mlx5e_pps pps_info;
281}; 289};
282 290
283enum { 291enum {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
index 66f432385dbb..84dd63e74041 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
@@ -53,6 +53,15 @@ enum {
53 MLX5E_EVENT_MODE_ONCE_TILL_ARM = 0x2, 53 MLX5E_EVENT_MODE_ONCE_TILL_ARM = 0x2,
54}; 54};
55 55
56enum {
57 MLX5E_MTPPS_FS_ENABLE = BIT(0x0),
58 MLX5E_MTPPS_FS_PATTERN = BIT(0x2),
59 MLX5E_MTPPS_FS_PIN_MODE = BIT(0x3),
60 MLX5E_MTPPS_FS_TIME_STAMP = BIT(0x4),
61 MLX5E_MTPPS_FS_OUT_PULSE_DURATION = BIT(0x5),
62 MLX5E_MTPPS_FS_ENH_OUT_PER_ADJ = BIT(0x7),
63};
64
56void mlx5e_fill_hwstamp(struct mlx5e_tstamp *tstamp, u64 timestamp, 65void mlx5e_fill_hwstamp(struct mlx5e_tstamp *tstamp, u64 timestamp,
57 struct skb_shared_hwtstamps *hwts) 66 struct skb_shared_hwtstamps *hwts)
58{ 67{
@@ -73,17 +82,46 @@ static u64 mlx5e_read_internal_timer(const struct cyclecounter *cc)
73 return mlx5_read_internal_timer(tstamp->mdev) & cc->mask; 82 return mlx5_read_internal_timer(tstamp->mdev) & cc->mask;
74} 83}
75 84
85static void mlx5e_pps_out(struct work_struct *work)
86{
87 struct mlx5e_pps *pps_info = container_of(work, struct mlx5e_pps,
88 out_work);
89 struct mlx5e_tstamp *tstamp = container_of(pps_info, struct mlx5e_tstamp,
90 pps_info);
91 u32 in[MLX5_ST_SZ_DW(mtpps_reg)] = {0};
92 unsigned long flags;
93 int i;
94
95 for (i = 0; i < tstamp->ptp_info.n_pins; i++) {
96 u64 tstart;
97
98 write_lock_irqsave(&tstamp->lock, flags);
99 tstart = tstamp->pps_info.start[i];
100 tstamp->pps_info.start[i] = 0;
101 write_unlock_irqrestore(&tstamp->lock, flags);
102 if (!tstart)
103 continue;
104
105 MLX5_SET(mtpps_reg, in, pin, i);
106 MLX5_SET64(mtpps_reg, in, time_stamp, tstart);
107 MLX5_SET(mtpps_reg, in, field_select, MLX5E_MTPPS_FS_TIME_STAMP);
108 mlx5_set_mtpps(tstamp->mdev, in, sizeof(in));
109 }
110}
111
76static void mlx5e_timestamp_overflow(struct work_struct *work) 112static void mlx5e_timestamp_overflow(struct work_struct *work)
77{ 113{
78 struct delayed_work *dwork = to_delayed_work(work); 114 struct delayed_work *dwork = to_delayed_work(work);
79 struct mlx5e_tstamp *tstamp = container_of(dwork, struct mlx5e_tstamp, 115 struct mlx5e_tstamp *tstamp = container_of(dwork, struct mlx5e_tstamp,
80 overflow_work); 116 overflow_work);
117 struct mlx5e_priv *priv = container_of(tstamp, struct mlx5e_priv, tstamp);
81 unsigned long flags; 118 unsigned long flags;
82 119
83 write_lock_irqsave(&tstamp->lock, flags); 120 write_lock_irqsave(&tstamp->lock, flags);
84 timecounter_read(&tstamp->clock); 121 timecounter_read(&tstamp->clock);
85 write_unlock_irqrestore(&tstamp->lock, flags); 122 write_unlock_irqrestore(&tstamp->lock, flags);
86 schedule_delayed_work(&tstamp->overflow_work, tstamp->overflow_period); 123 queue_delayed_work(priv->wq, &tstamp->overflow_work,
124 msecs_to_jiffies(tstamp->overflow_period * 1000));
87} 125}
88 126
89int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr) 127int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr)
@@ -213,18 +251,6 @@ static int mlx5e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 delta)
213 int neg_adj = 0; 251 int neg_adj = 0;
214 struct mlx5e_tstamp *tstamp = container_of(ptp, struct mlx5e_tstamp, 252 struct mlx5e_tstamp *tstamp = container_of(ptp, struct mlx5e_tstamp,
215 ptp_info); 253 ptp_info);
216 struct mlx5e_priv *priv =
217 container_of(tstamp, struct mlx5e_priv, tstamp);
218
219 if (MLX5_CAP_GEN(priv->mdev, pps_modify)) {
220 u32 in[MLX5_ST_SZ_DW(mtpps_reg)] = {0};
221
222 /* For future use need to add a loop for finding all 1PPS out pins */
223 MLX5_SET(mtpps_reg, in, pin_mode, MLX5E_PIN_MODE_OUT);
224 MLX5_SET(mtpps_reg, in, out_periodic_adjustment, delta & 0xFFFF);
225
226 mlx5_set_mtpps(priv->mdev, in, sizeof(in));
227 }
228 254
229 if (delta < 0) { 255 if (delta < 0) {
230 neg_adj = 1; 256 neg_adj = 1;
@@ -253,12 +279,13 @@ static int mlx5e_extts_configure(struct ptp_clock_info *ptp,
253 struct mlx5e_priv *priv = 279 struct mlx5e_priv *priv =
254 container_of(tstamp, struct mlx5e_priv, tstamp); 280 container_of(tstamp, struct mlx5e_priv, tstamp);
255 u32 in[MLX5_ST_SZ_DW(mtpps_reg)] = {0}; 281 u32 in[MLX5_ST_SZ_DW(mtpps_reg)] = {0};
282 u32 field_select = 0;
283 u8 pin_mode = 0;
256 u8 pattern = 0; 284 u8 pattern = 0;
257 int pin = -1; 285 int pin = -1;
258 int err = 0; 286 int err = 0;
259 287
260 if (!MLX5_CAP_GEN(priv->mdev, pps) || 288 if (!MLX5_PPS_CAP(priv->mdev))
261 !MLX5_CAP_GEN(priv->mdev, pps_modify))
262 return -EOPNOTSUPP; 289 return -EOPNOTSUPP;
263 290
264 if (rq->extts.index >= tstamp->ptp_info.n_pins) 291 if (rq->extts.index >= tstamp->ptp_info.n_pins)
@@ -268,15 +295,21 @@ static int mlx5e_extts_configure(struct ptp_clock_info *ptp,
268 pin = ptp_find_pin(tstamp->ptp, PTP_PF_EXTTS, rq->extts.index); 295 pin = ptp_find_pin(tstamp->ptp, PTP_PF_EXTTS, rq->extts.index);
269 if (pin < 0) 296 if (pin < 0)
270 return -EBUSY; 297 return -EBUSY;
298 pin_mode = MLX5E_PIN_MODE_IN;
299 pattern = !!(rq->extts.flags & PTP_FALLING_EDGE);
300 field_select = MLX5E_MTPPS_FS_PIN_MODE |
301 MLX5E_MTPPS_FS_PATTERN |
302 MLX5E_MTPPS_FS_ENABLE;
303 } else {
304 pin = rq->extts.index;
305 field_select = MLX5E_MTPPS_FS_ENABLE;
271 } 306 }
272 307
273 if (rq->extts.flags & PTP_FALLING_EDGE)
274 pattern = 1;
275
276 MLX5_SET(mtpps_reg, in, pin, pin); 308 MLX5_SET(mtpps_reg, in, pin, pin);
277 MLX5_SET(mtpps_reg, in, pin_mode, MLX5E_PIN_MODE_IN); 309 MLX5_SET(mtpps_reg, in, pin_mode, pin_mode);
278 MLX5_SET(mtpps_reg, in, pattern, pattern); 310 MLX5_SET(mtpps_reg, in, pattern, pattern);
279 MLX5_SET(mtpps_reg, in, enable, on); 311 MLX5_SET(mtpps_reg, in, enable, on);
312 MLX5_SET(mtpps_reg, in, field_select, field_select);
280 313
281 err = mlx5_set_mtpps(priv->mdev, in, sizeof(in)); 314 err = mlx5_set_mtpps(priv->mdev, in, sizeof(in));
282 if (err) 315 if (err)
@@ -295,14 +328,18 @@ static int mlx5e_perout_configure(struct ptp_clock_info *ptp,
295 struct mlx5e_priv *priv = 328 struct mlx5e_priv *priv =
296 container_of(tstamp, struct mlx5e_priv, tstamp); 329 container_of(tstamp, struct mlx5e_priv, tstamp);
297 u32 in[MLX5_ST_SZ_DW(mtpps_reg)] = {0}; 330 u32 in[MLX5_ST_SZ_DW(mtpps_reg)] = {0};
298 u64 nsec_now, nsec_delta, time_stamp; 331 u64 nsec_now, nsec_delta, time_stamp = 0;
299 u64 cycles_now, cycles_delta; 332 u64 cycles_now, cycles_delta;
300 struct timespec64 ts; 333 struct timespec64 ts;
301 unsigned long flags; 334 unsigned long flags;
335 u32 field_select = 0;
336 u8 pin_mode = 0;
337 u8 pattern = 0;
302 int pin = -1; 338 int pin = -1;
339 int err = 0;
303 s64 ns; 340 s64 ns;
304 341
305 if (!MLX5_CAP_GEN(priv->mdev, pps_modify)) 342 if (!MLX5_PPS_CAP(priv->mdev))
306 return -EOPNOTSUPP; 343 return -EOPNOTSUPP;
307 344
308 if (rq->perout.index >= tstamp->ptp_info.n_pins) 345 if (rq->perout.index >= tstamp->ptp_info.n_pins)
@@ -313,32 +350,60 @@ static int mlx5e_perout_configure(struct ptp_clock_info *ptp,
313 rq->perout.index); 350 rq->perout.index);
314 if (pin < 0) 351 if (pin < 0)
315 return -EBUSY; 352 return -EBUSY;
316 }
317 353
318 ts.tv_sec = rq->perout.period.sec; 354 pin_mode = MLX5E_PIN_MODE_OUT;
319 ts.tv_nsec = rq->perout.period.nsec; 355 pattern = MLX5E_OUT_PATTERN_PERIODIC;
320 ns = timespec64_to_ns(&ts); 356 ts.tv_sec = rq->perout.period.sec;
321 if (on) 357 ts.tv_nsec = rq->perout.period.nsec;
358 ns = timespec64_to_ns(&ts);
359
322 if ((ns >> 1) != 500000000LL) 360 if ((ns >> 1) != 500000000LL)
323 return -EINVAL; 361 return -EINVAL;
324 ts.tv_sec = rq->perout.start.sec; 362
325 ts.tv_nsec = rq->perout.start.nsec; 363 ts.tv_sec = rq->perout.start.sec;
326 ns = timespec64_to_ns(&ts); 364 ts.tv_nsec = rq->perout.start.nsec;
327 cycles_now = mlx5_read_internal_timer(tstamp->mdev); 365 ns = timespec64_to_ns(&ts);
328 write_lock_irqsave(&tstamp->lock, flags); 366 cycles_now = mlx5_read_internal_timer(tstamp->mdev);
329 nsec_now = timecounter_cyc2time(&tstamp->clock, cycles_now); 367 write_lock_irqsave(&tstamp->lock, flags);
330 nsec_delta = ns - nsec_now; 368 nsec_now = timecounter_cyc2time(&tstamp->clock, cycles_now);
331 cycles_delta = div64_u64(nsec_delta << tstamp->cycles.shift, 369 nsec_delta = ns - nsec_now;
332 tstamp->cycles.mult); 370 cycles_delta = div64_u64(nsec_delta << tstamp->cycles.shift,
333 write_unlock_irqrestore(&tstamp->lock, flags); 371 tstamp->cycles.mult);
334 time_stamp = cycles_now + cycles_delta; 372 write_unlock_irqrestore(&tstamp->lock, flags);
373 time_stamp = cycles_now + cycles_delta;
374 field_select = MLX5E_MTPPS_FS_PIN_MODE |
375 MLX5E_MTPPS_FS_PATTERN |
376 MLX5E_MTPPS_FS_ENABLE |
377 MLX5E_MTPPS_FS_TIME_STAMP;
378 } else {
379 pin = rq->perout.index;
380 field_select = MLX5E_MTPPS_FS_ENABLE;
381 }
382
335 MLX5_SET(mtpps_reg, in, pin, pin); 383 MLX5_SET(mtpps_reg, in, pin, pin);
336 MLX5_SET(mtpps_reg, in, pin_mode, MLX5E_PIN_MODE_OUT); 384 MLX5_SET(mtpps_reg, in, pin_mode, pin_mode);
337 MLX5_SET(mtpps_reg, in, pattern, MLX5E_OUT_PATTERN_PERIODIC); 385 MLX5_SET(mtpps_reg, in, pattern, pattern);
338 MLX5_SET(mtpps_reg, in, enable, on); 386 MLX5_SET(mtpps_reg, in, enable, on);
339 MLX5_SET64(mtpps_reg, in, time_stamp, time_stamp); 387 MLX5_SET64(mtpps_reg, in, time_stamp, time_stamp);
388 MLX5_SET(mtpps_reg, in, field_select, field_select);
389
390 err = mlx5_set_mtpps(priv->mdev, in, sizeof(in));
391 if (err)
392 return err;
340 393
341 return mlx5_set_mtpps(priv->mdev, in, sizeof(in)); 394 return mlx5_set_mtppse(priv->mdev, pin, 0,
395 MLX5E_EVENT_MODE_REPETETIVE & on);
396}
397
398static int mlx5e_pps_configure(struct ptp_clock_info *ptp,
399 struct ptp_clock_request *rq,
400 int on)
401{
402 struct mlx5e_tstamp *tstamp =
403 container_of(ptp, struct mlx5e_tstamp, ptp_info);
404
405 tstamp->pps_info.enabled = !!on;
406 return 0;
342} 407}
343 408
344static int mlx5e_ptp_enable(struct ptp_clock_info *ptp, 409static int mlx5e_ptp_enable(struct ptp_clock_info *ptp,
@@ -350,6 +415,8 @@ static int mlx5e_ptp_enable(struct ptp_clock_info *ptp,
350 return mlx5e_extts_configure(ptp, rq, on); 415 return mlx5e_extts_configure(ptp, rq, on);
351 case PTP_CLK_REQ_PEROUT: 416 case PTP_CLK_REQ_PEROUT:
352 return mlx5e_perout_configure(ptp, rq, on); 417 return mlx5e_perout_configure(ptp, rq, on);
418 case PTP_CLK_REQ_PPS:
419 return mlx5e_pps_configure(ptp, rq, on);
353 default: 420 default:
354 return -EOPNOTSUPP; 421 return -EOPNOTSUPP;
355 } 422 }
@@ -395,6 +462,7 @@ static int mlx5e_init_pin_config(struct mlx5e_tstamp *tstamp)
395 return -ENOMEM; 462 return -ENOMEM;
396 tstamp->ptp_info.enable = mlx5e_ptp_enable; 463 tstamp->ptp_info.enable = mlx5e_ptp_enable;
397 tstamp->ptp_info.verify = mlx5e_ptp_verify; 464 tstamp->ptp_info.verify = mlx5e_ptp_verify;
465 tstamp->ptp_info.pps = 1;
398 466
399 for (i = 0; i < tstamp->ptp_info.n_pins; i++) { 467 for (i = 0; i < tstamp->ptp_info.n_pins; i++) {
400 snprintf(tstamp->ptp_info.pin_config[i].name, 468 snprintf(tstamp->ptp_info.pin_config[i].name,
@@ -422,22 +490,56 @@ static void mlx5e_get_pps_caps(struct mlx5e_priv *priv,
422 tstamp->ptp_info.n_per_out = MLX5_GET(mtpps_reg, out, 490 tstamp->ptp_info.n_per_out = MLX5_GET(mtpps_reg, out,
423 cap_max_num_of_pps_out_pins); 491 cap_max_num_of_pps_out_pins);
424 492
425 tstamp->pps_pin_caps[0] = MLX5_GET(mtpps_reg, out, cap_pin_0_mode); 493 tstamp->pps_info.pin_caps[0] = MLX5_GET(mtpps_reg, out, cap_pin_0_mode);
426 tstamp->pps_pin_caps[1] = MLX5_GET(mtpps_reg, out, cap_pin_1_mode); 494 tstamp->pps_info.pin_caps[1] = MLX5_GET(mtpps_reg, out, cap_pin_1_mode);
427 tstamp->pps_pin_caps[2] = MLX5_GET(mtpps_reg, out, cap_pin_2_mode); 495 tstamp->pps_info.pin_caps[2] = MLX5_GET(mtpps_reg, out, cap_pin_2_mode);
428 tstamp->pps_pin_caps[3] = MLX5_GET(mtpps_reg, out, cap_pin_3_mode); 496 tstamp->pps_info.pin_caps[3] = MLX5_GET(mtpps_reg, out, cap_pin_3_mode);
429 tstamp->pps_pin_caps[4] = MLX5_GET(mtpps_reg, out, cap_pin_4_mode); 497 tstamp->pps_info.pin_caps[4] = MLX5_GET(mtpps_reg, out, cap_pin_4_mode);
430 tstamp->pps_pin_caps[5] = MLX5_GET(mtpps_reg, out, cap_pin_5_mode); 498 tstamp->pps_info.pin_caps[5] = MLX5_GET(mtpps_reg, out, cap_pin_5_mode);
431 tstamp->pps_pin_caps[6] = MLX5_GET(mtpps_reg, out, cap_pin_6_mode); 499 tstamp->pps_info.pin_caps[6] = MLX5_GET(mtpps_reg, out, cap_pin_6_mode);
432 tstamp->pps_pin_caps[7] = MLX5_GET(mtpps_reg, out, cap_pin_7_mode); 500 tstamp->pps_info.pin_caps[7] = MLX5_GET(mtpps_reg, out, cap_pin_7_mode);
433} 501}
434 502
435void mlx5e_pps_event_handler(struct mlx5e_priv *priv, 503void mlx5e_pps_event_handler(struct mlx5e_priv *priv,
436 struct ptp_clock_event *event) 504 struct ptp_clock_event *event)
437{ 505{
506 struct net_device *netdev = priv->netdev;
438 struct mlx5e_tstamp *tstamp = &priv->tstamp; 507 struct mlx5e_tstamp *tstamp = &priv->tstamp;
508 struct timespec64 ts;
509 u64 nsec_now, nsec_delta;
510 u64 cycles_now, cycles_delta;
511 int pin = event->index;
512 s64 ns;
513 unsigned long flags;
439 514
440 ptp_clock_event(tstamp->ptp, event); 515 switch (tstamp->ptp_info.pin_config[pin].func) {
516 case PTP_PF_EXTTS:
517 if (tstamp->pps_info.enabled) {
518 event->type = PTP_CLOCK_PPSUSR;
519 event->pps_times.ts_real = ns_to_timespec64(event->timestamp);
520 } else {
521 event->type = PTP_CLOCK_EXTTS;
522 }
523 ptp_clock_event(tstamp->ptp, event);
524 break;
525 case PTP_PF_PEROUT:
526 mlx5e_ptp_gettime(&tstamp->ptp_info, &ts);
527 cycles_now = mlx5_read_internal_timer(tstamp->mdev);
528 ts.tv_sec += 1;
529 ts.tv_nsec = 0;
530 ns = timespec64_to_ns(&ts);
531 write_lock_irqsave(&tstamp->lock, flags);
532 nsec_now = timecounter_cyc2time(&tstamp->clock, cycles_now);
533 nsec_delta = ns - nsec_now;
534 cycles_delta = div64_u64(nsec_delta << tstamp->cycles.shift,
535 tstamp->cycles.mult);
536 tstamp->pps_info.start[pin] = cycles_now + cycles_delta;
537 queue_work(priv->wq, &tstamp->pps_info.out_work);
538 write_unlock_irqrestore(&tstamp->lock, flags);
539 break;
540 default:
541 netdev_err(netdev, "%s: Unhandled event\n", __func__);
542 }
441} 543}
442 544
443void mlx5e_timestamp_init(struct mlx5e_priv *priv) 545void mlx5e_timestamp_init(struct mlx5e_priv *priv)
@@ -473,9 +575,10 @@ void mlx5e_timestamp_init(struct mlx5e_priv *priv)
473 do_div(ns, NSEC_PER_SEC / 2 / HZ); 575 do_div(ns, NSEC_PER_SEC / 2 / HZ);
474 tstamp->overflow_period = ns; 576 tstamp->overflow_period = ns;
475 577
578 INIT_WORK(&tstamp->pps_info.out_work, mlx5e_pps_out);
476 INIT_DELAYED_WORK(&tstamp->overflow_work, mlx5e_timestamp_overflow); 579 INIT_DELAYED_WORK(&tstamp->overflow_work, mlx5e_timestamp_overflow);
477 if (tstamp->overflow_period) 580 if (tstamp->overflow_period)
478 schedule_delayed_work(&tstamp->overflow_work, 0); 581 queue_delayed_work(priv->wq, &tstamp->overflow_work, 0);
479 else 582 else
480 mlx5_core_warn(priv->mdev, "invalid overflow period, overflow_work is not scheduled\n"); 583 mlx5_core_warn(priv->mdev, "invalid overflow period, overflow_work is not scheduled\n");
481 584
@@ -484,16 +587,10 @@ void mlx5e_timestamp_init(struct mlx5e_priv *priv)
484 snprintf(tstamp->ptp_info.name, 16, "mlx5 ptp"); 587 snprintf(tstamp->ptp_info.name, 16, "mlx5 ptp");
485 588
486 /* Initialize 1PPS data structures */ 589 /* Initialize 1PPS data structures */
487#define MAX_PIN_NUM 8 590 if (MLX5_PPS_CAP(priv->mdev))
488 tstamp->pps_pin_caps = kzalloc(sizeof(u8) * MAX_PIN_NUM, GFP_KERNEL); 591 mlx5e_get_pps_caps(priv, tstamp);
489 if (tstamp->pps_pin_caps) { 592 if (tstamp->ptp_info.n_pins)
490 if (MLX5_CAP_GEN(priv->mdev, pps)) 593 mlx5e_init_pin_config(tstamp);
491 mlx5e_get_pps_caps(priv, tstamp);
492 if (tstamp->ptp_info.n_pins)
493 mlx5e_init_pin_config(tstamp);
494 } else {
495 mlx5_core_warn(priv->mdev, "1PPS initialization failed\n");
496 }
497 594
498 tstamp->ptp = ptp_clock_register(&tstamp->ptp_info, 595 tstamp->ptp = ptp_clock_register(&tstamp->ptp_info,
499 &priv->mdev->pdev->dev); 596 &priv->mdev->pdev->dev);
@@ -516,8 +613,7 @@ void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv)
516 priv->tstamp.ptp = NULL; 613 priv->tstamp.ptp = NULL;
517 } 614 }
518 615
519 kfree(tstamp->pps_pin_caps); 616 cancel_work_sync(&tstamp->pps_info.out_work);
520 kfree(tstamp->ptp_info.pin_config);
521
522 cancel_delayed_work_sync(&tstamp->overflow_work); 617 cancel_delayed_work_sync(&tstamp->overflow_work);
618 kfree(tstamp->ptp_info.pin_config);
523} 619}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
index bdd82c9b3992..eafc59280ada 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
@@ -276,7 +276,7 @@ static void add_rule_to_list(struct mlx5e_priv *priv,
276 276
277static bool outer_header_zero(u32 *match_criteria) 277static bool outer_header_zero(u32 *match_criteria)
278{ 278{
279 int size = MLX5_ST_SZ_BYTES(fte_match_param); 279 int size = MLX5_FLD_SZ_BYTES(fte_match_param, outer_headers);
280 char *outer_headers_c = MLX5_ADDR_OF(fte_match_param, match_criteria, 280 char *outer_headers_c = MLX5_ADDR_OF(fte_match_param, match_criteria,
281 outer_headers); 281 outer_headers);
282 282
@@ -320,7 +320,7 @@ add_ethtool_flow_rule(struct mlx5e_priv *priv,
320 320
321 spec->match_criteria_enable = (!outer_header_zero(spec->match_criteria)); 321 spec->match_criteria_enable = (!outer_header_zero(spec->match_criteria));
322 flow_act.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG; 322 flow_act.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG;
323 rule = mlx5_add_flow_rules(ft, spec, &flow_act, dst, 1); 323 rule = mlx5_add_flow_rules(ft, spec, &flow_act, dst, dst ? 1 : 0);
324 if (IS_ERR(rule)) { 324 if (IS_ERR(rule)) {
325 err = PTR_ERR(rule); 325 err = PTR_ERR(rule);
326 netdev_err(priv->netdev, "%s: failed to add ethtool steering rule: %d\n", 326 netdev_err(priv->netdev, "%s: failed to add ethtool steering rule: %d\n",
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 1eac5003084f..57f31fa478ce 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -377,7 +377,6 @@ static void mlx5e_async_event(struct mlx5_core_dev *mdev, void *vpriv,
377 break; 377 break;
378 case MLX5_DEV_EVENT_PPS: 378 case MLX5_DEV_EVENT_PPS:
379 eqe = (struct mlx5_eqe *)param; 379 eqe = (struct mlx5_eqe *)param;
380 ptp_event.type = PTP_CLOCK_EXTTS;
381 ptp_event.index = eqe->data.pps.pin; 380 ptp_event.index = eqe->data.pps.pin;
382 ptp_event.timestamp = 381 ptp_event.timestamp =
383 timecounter_cyc2time(&priv->tstamp.clock, 382 timecounter_cyc2time(&priv->tstamp.clock,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
index af51a5d2b912..52b9a64cd3a2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
@@ -698,7 +698,7 @@ int mlx5_start_eqs(struct mlx5_core_dev *dev)
698 else 698 else
699 mlx5_core_dbg(dev, "port_module_event is not set\n"); 699 mlx5_core_dbg(dev, "port_module_event is not set\n");
700 700
701 if (MLX5_CAP_GEN(dev, pps)) 701 if (MLX5_PPS_CAP(dev))
702 async_event_mask |= (1ull << MLX5_EVENT_TYPE_PPS_EVENT); 702 async_event_mask |= (1ull << MLX5_EVENT_TYPE_PPS_EVENT);
703 703
704 if (MLX5_CAP_GEN(dev, fpga)) 704 if (MLX5_CAP_GEN(dev, fpga))
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 89bfda419efe..8b18cc9ec026 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1668,7 +1668,8 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw)
1668 int i; 1668 int i;
1669 1669
1670 if (!esw || !MLX5_CAP_GEN(esw->dev, vport_group_manager) || 1670 if (!esw || !MLX5_CAP_GEN(esw->dev, vport_group_manager) ||
1671 MLX5_CAP_GEN(esw->dev, port_type) != MLX5_CAP_PORT_TYPE_ETH) 1671 MLX5_CAP_GEN(esw->dev, port_type) != MLX5_CAP_PORT_TYPE_ETH ||
1672 esw->mode == SRIOV_NONE)
1672 return; 1673 return;
1673 1674
1674 esw_info(esw->dev, "disable SRIOV: active vports(%d) mode(%d)\n", 1675 esw_info(esw->dev, "disable SRIOV: active vports(%d) mode(%d)\n",
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
index 1ee5bce85901..85298051a3e4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
@@ -178,8 +178,6 @@ out:
178 178
179static void mlx5i_destroy_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core_qp *qp) 179static void mlx5i_destroy_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core_qp *qp)
180{ 180{
181 mlx5_fs_remove_rx_underlay_qpn(mdev, qp->qpn);
182
183 mlx5_core_destroy_qp(mdev, qp); 181 mlx5_core_destroy_qp(mdev, qp);
184} 182}
185 183
@@ -194,8 +192,6 @@ static int mlx5i_init_tx(struct mlx5e_priv *priv)
194 return err; 192 return err;
195 } 193 }
196 194
197 mlx5_fs_add_rx_underlay_qpn(priv->mdev, ipriv->qp.qpn);
198
199 err = mlx5e_create_tis(priv->mdev, 0 /* tc */, ipriv->qp.qpn, &priv->tisn[0]); 195 err = mlx5e_create_tis(priv->mdev, 0 /* tc */, ipriv->qp.qpn, &priv->tisn[0]);
200 if (err) { 196 if (err) {
201 mlx5_core_warn(priv->mdev, "create tis failed, %d\n", err); 197 mlx5_core_warn(priv->mdev, "create tis failed, %d\n", err);
@@ -253,6 +249,7 @@ static void mlx5i_destroy_flow_steering(struct mlx5e_priv *priv)
253 249
254static int mlx5i_init_rx(struct mlx5e_priv *priv) 250static int mlx5i_init_rx(struct mlx5e_priv *priv)
255{ 251{
252 struct mlx5i_priv *ipriv = priv->ppriv;
256 int err; 253 int err;
257 254
258 err = mlx5e_create_indirect_rqt(priv); 255 err = mlx5e_create_indirect_rqt(priv);
@@ -271,12 +268,18 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv)
271 if (err) 268 if (err)
272 goto err_destroy_indirect_tirs; 269 goto err_destroy_indirect_tirs;
273 270
274 err = mlx5i_create_flow_steering(priv); 271 err = mlx5_fs_add_rx_underlay_qpn(priv->mdev, ipriv->qp.qpn);
275 if (err) 272 if (err)
276 goto err_destroy_direct_tirs; 273 goto err_destroy_direct_tirs;
277 274
275 err = mlx5i_create_flow_steering(priv);
276 if (err)
277 goto err_remove_rx_underlay_qpn;
278
278 return 0; 279 return 0;
279 280
281err_remove_rx_underlay_qpn:
282 mlx5_fs_remove_rx_underlay_qpn(priv->mdev, ipriv->qp.qpn);
280err_destroy_direct_tirs: 283err_destroy_direct_tirs:
281 mlx5e_destroy_direct_tirs(priv); 284 mlx5e_destroy_direct_tirs(priv);
282err_destroy_indirect_tirs: 285err_destroy_indirect_tirs:
@@ -290,6 +293,9 @@ err_destroy_indirect_rqts:
290 293
291static void mlx5i_cleanup_rx(struct mlx5e_priv *priv) 294static void mlx5i_cleanup_rx(struct mlx5e_priv *priv)
292{ 295{
296 struct mlx5i_priv *ipriv = priv->ppriv;
297
298 mlx5_fs_remove_rx_underlay_qpn(priv->mdev, ipriv->qp.qpn);
293 mlx5i_destroy_flow_steering(priv); 299 mlx5i_destroy_flow_steering(priv);
294 mlx5e_destroy_direct_tirs(priv); 300 mlx5e_destroy_direct_tirs(priv);
295 mlx5e_destroy_indirect_tirs(priv); 301 mlx5e_destroy_indirect_tirs(priv);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
index a3a836bdcfd2..f26f97fe4666 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
@@ -162,22 +162,17 @@ static bool mlx5_lag_is_bonded(struct mlx5_lag *ldev)
162static void mlx5_infer_tx_affinity_mapping(struct lag_tracker *tracker, 162static void mlx5_infer_tx_affinity_mapping(struct lag_tracker *tracker,
163 u8 *port1, u8 *port2) 163 u8 *port1, u8 *port2)
164{ 164{
165 if (tracker->tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP) { 165 *port1 = 1;
166 if (tracker->netdev_state[0].tx_enabled) { 166 *port2 = 2;
167 *port1 = 1; 167 if (!tracker->netdev_state[0].tx_enabled ||
168 *port2 = 1; 168 !tracker->netdev_state[0].link_up) {
169 } else { 169 *port1 = 2;
170 *port1 = 2; 170 return;
171 *port2 = 2;
172 }
173 } else {
174 *port1 = 1;
175 *port2 = 2;
176 if (!tracker->netdev_state[0].link_up)
177 *port1 = 2;
178 else if (!tracker->netdev_state[1].link_up)
179 *port2 = 1;
180 } 171 }
172
173 if (!tracker->netdev_state[1].tx_enabled ||
174 !tracker->netdev_state[1].link_up)
175 *port2 = 1;
181} 176}
182 177
183static void mlx5_activate_lag(struct mlx5_lag *ldev, 178static void mlx5_activate_lag(struct mlx5_lag *ldev,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index 6a3d6bef7dd4..6a263e8d883a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -154,6 +154,11 @@ int mlx5_set_mtpps(struct mlx5_core_dev *mdev, u32 *mtpps, u32 mtpps_size);
154int mlx5_query_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 *arm, u8 *mode); 154int mlx5_query_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 *arm, u8 *mode);
155int mlx5_set_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 arm, u8 mode); 155int mlx5_set_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 arm, u8 mode);
156 156
157#define MLX5_PPS_CAP(mdev) (MLX5_CAP_GEN((mdev), pps) && \
158 MLX5_CAP_GEN((mdev), pps_modify) && \
159 MLX5_CAP_MCAM_FEATURE((mdev), mtpps_fs) && \
160 MLX5_CAP_MCAM_FEATURE((mdev), mtpps_enh_out_per_adj))
161
157int mlx5_firmware_flash(struct mlx5_core_dev *dev, const struct firmware *fw); 162int mlx5_firmware_flash(struct mlx5_core_dev *dev, const struct firmware *fw);
158 163
159void mlx5e_init(void); 164void mlx5e_init(void);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
index bcdf7779c48d..bf99d40e30b4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
@@ -88,7 +88,11 @@ static void mlx5_device_disable_sriov(struct mlx5_core_dev *dev)
88 int vf; 88 int vf;
89 89
90 if (!sriov->enabled_vfs) 90 if (!sriov->enabled_vfs)
91#ifdef CONFIG_MLX5_CORE_EN
92 goto disable_sriov_resources;
93#else
91 return; 94 return;
95#endif
92 96
93 for (vf = 0; vf < sriov->num_vfs; vf++) { 97 for (vf = 0; vf < sriov->num_vfs; vf++) {
94 if (!sriov->vfs_ctx[vf].enabled) 98 if (!sriov->vfs_ctx[vf].enabled)
@@ -103,6 +107,7 @@ static void mlx5_device_disable_sriov(struct mlx5_core_dev *dev)
103 } 107 }
104 108
105#ifdef CONFIG_MLX5_CORE_EN 109#ifdef CONFIG_MLX5_CORE_EN
110disable_sriov_resources:
106 mlx5_eswitch_disable_sriov(dev->priv.eswitch); 111 mlx5_eswitch_disable_sriov(dev->priv.eswitch);
107#endif 112#endif
108 113
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 383fef5a8e24..4b2e0fd7d51e 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -1512,6 +1512,10 @@ mlxsw_sp_nexthop_group_mac_update(struct mlxsw_sp *mlxsw_sp,
1512static int mlxsw_sp_fib_entry_update(struct mlxsw_sp *mlxsw_sp, 1512static int mlxsw_sp_fib_entry_update(struct mlxsw_sp *mlxsw_sp,
1513 struct mlxsw_sp_fib_entry *fib_entry); 1513 struct mlxsw_sp_fib_entry *fib_entry);
1514 1514
1515static bool
1516mlxsw_sp_fib_node_entry_is_first(const struct mlxsw_sp_fib_node *fib_node,
1517 const struct mlxsw_sp_fib_entry *fib_entry);
1518
1515static int 1519static int
1516mlxsw_sp_nexthop_fib_entries_update(struct mlxsw_sp *mlxsw_sp, 1520mlxsw_sp_nexthop_fib_entries_update(struct mlxsw_sp *mlxsw_sp,
1517 struct mlxsw_sp_nexthop_group *nh_grp) 1521 struct mlxsw_sp_nexthop_group *nh_grp)
@@ -1520,6 +1524,9 @@ mlxsw_sp_nexthop_fib_entries_update(struct mlxsw_sp *mlxsw_sp,
1520 int err; 1524 int err;
1521 1525
1522 list_for_each_entry(fib_entry, &nh_grp->fib_list, nexthop_group_node) { 1526 list_for_each_entry(fib_entry, &nh_grp->fib_list, nexthop_group_node) {
1527 if (!mlxsw_sp_fib_node_entry_is_first(fib_entry->fib_node,
1528 fib_entry))
1529 continue;
1523 err = mlxsw_sp_fib_entry_update(mlxsw_sp, fib_entry); 1530 err = mlxsw_sp_fib_entry_update(mlxsw_sp, fib_entry);
1524 if (err) 1531 if (err)
1525 return err; 1532 return err;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
index 22cf6353ba04..7ecf549c7f1c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
@@ -205,7 +205,7 @@ static void dwmac1000_dump_dma_regs(void __iomem *ioaddr, u32 *reg_space)
205{ 205{
206 int i; 206 int i;
207 207
208 for (i = 0; i < 23; i++) 208 for (i = 0; i < NUM_DWMAC1000_DMA_REGS; i++)
209 if ((i < 12) || (i > 17)) 209 if ((i < 12) || (i > 17))
210 reg_space[DMA_BUS_MODE / 4 + i] = 210 reg_space[DMA_BUS_MODE / 4 + i] =
211 readl(ioaddr + DMA_BUS_MODE + i * 4); 211 readl(ioaddr + DMA_BUS_MODE + i * 4);
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
index eef2f222ce9a..6502b9aa3bf5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
@@ -70,7 +70,7 @@ static void dwmac100_dump_dma_regs(void __iomem *ioaddr, u32 *reg_space)
70{ 70{
71 int i; 71 int i;
72 72
73 for (i = 0; i < 9; i++) 73 for (i = 0; i < NUM_DWMAC100_DMA_REGS; i++)
74 reg_space[DMA_BUS_MODE / 4 + i] = 74 reg_space[DMA_BUS_MODE / 4 + i] =
75 readl(ioaddr + DMA_BUS_MODE + i * 4); 75 readl(ioaddr + DMA_BUS_MODE + i * 4);
76 76
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
index 9091df86723a..adc54006f884 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
@@ -136,6 +136,9 @@
136#define DMA_STATUS_TI 0x00000001 /* Transmit Interrupt */ 136#define DMA_STATUS_TI 0x00000001 /* Transmit Interrupt */
137#define DMA_CONTROL_FTF 0x00100000 /* Flush transmit FIFO */ 137#define DMA_CONTROL_FTF 0x00100000 /* Flush transmit FIFO */
138 138
139#define NUM_DWMAC100_DMA_REGS 9
140#define NUM_DWMAC1000_DMA_REGS 23
141
139void dwmac_enable_dma_transmission(void __iomem *ioaddr); 142void dwmac_enable_dma_transmission(void __iomem *ioaddr);
140void dwmac_enable_dma_irq(void __iomem *ioaddr, u32 chan); 143void dwmac_enable_dma_irq(void __iomem *ioaddr, u32 chan);
141void dwmac_disable_dma_irq(void __iomem *ioaddr, u32 chan); 144void dwmac_disable_dma_irq(void __iomem *ioaddr, u32 chan);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index babb39c646ff..af30b4857c3b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -33,6 +33,8 @@
33#define MAC100_ETHTOOL_NAME "st_mac100" 33#define MAC100_ETHTOOL_NAME "st_mac100"
34#define GMAC_ETHTOOL_NAME "st_gmac" 34#define GMAC_ETHTOOL_NAME "st_gmac"
35 35
36#define ETHTOOL_DMA_OFFSET 55
37
36struct stmmac_stats { 38struct stmmac_stats {
37 char stat_string[ETH_GSTRING_LEN]; 39 char stat_string[ETH_GSTRING_LEN];
38 int sizeof_stat; 40 int sizeof_stat;
@@ -442,6 +444,9 @@ static void stmmac_ethtool_gregs(struct net_device *dev,
442 444
443 priv->hw->mac->dump_regs(priv->hw, reg_space); 445 priv->hw->mac->dump_regs(priv->hw, reg_space);
444 priv->hw->dma->dump_regs(priv->ioaddr, reg_space); 446 priv->hw->dma->dump_regs(priv->ioaddr, reg_space);
447 /* Copy DMA registers to where ethtool expects them */
448 memcpy(&reg_space[ETHTOOL_DMA_OFFSET], &reg_space[DMA_BUS_MODE / 4],
449 NUM_DWMAC1000_DMA_REGS * 4);
445} 450}
446 451
447static void 452static void
diff --git a/drivers/net/ethernet/sun/sunhme.h b/drivers/net/ethernet/sun/sunhme.h
index 3af540adb3c5..fca1bca7f69d 100644
--- a/drivers/net/ethernet/sun/sunhme.h
+++ b/drivers/net/ethernet/sun/sunhme.h
@@ -13,9 +13,9 @@
13/* Happy Meal global registers. */ 13/* Happy Meal global registers. */
14#define GREG_SWRESET 0x000UL /* Software Reset */ 14#define GREG_SWRESET 0x000UL /* Software Reset */
15#define GREG_CFG 0x004UL /* Config Register */ 15#define GREG_CFG 0x004UL /* Config Register */
16#define GREG_STAT 0x108UL /* Status */ 16#define GREG_STAT 0x100UL /* Status */
17#define GREG_IMASK 0x10cUL /* Interrupt Mask */ 17#define GREG_IMASK 0x104UL /* Interrupt Mask */
18#define GREG_REG_SIZE 0x110UL 18#define GREG_REG_SIZE 0x108UL
19 19
20/* Global reset register. */ 20/* Global reset register. */
21#define GREG_RESET_ETX 0x01 21#define GREG_RESET_ETX 0x01
diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c
index d9db8a06afd2..cce9c9ed46aa 100644
--- a/drivers/net/ethernet/toshiba/tc35815.c
+++ b/drivers/net/ethernet/toshiba/tc35815.c
@@ -1338,7 +1338,7 @@ static int tc35815_send_packet(struct sk_buff *skb, struct net_device *dev)
1338static void tc35815_fatal_error_interrupt(struct net_device *dev, u32 status) 1338static void tc35815_fatal_error_interrupt(struct net_device *dev, u32 status)
1339{ 1339{
1340 static int count; 1340 static int count;
1341 printk(KERN_WARNING "%s: Fatal Error Intterrupt (%#x):", 1341 printk(KERN_WARNING "%s: Fatal Error Interrupt (%#x):",
1342 dev->name, status); 1342 dev->name, status);
1343 if (status & Int_IntPCI) 1343 if (status & Int_IntPCI)
1344 printk(" IntPCI"); 1344 printk(" IntPCI");
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 63c98bbbc596..0d78727f1a14 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -315,14 +315,34 @@ static u32 init_page_array(void *hdr, u32 len, struct sk_buff *skb,
315 return slots_used; 315 return slots_used;
316} 316}
317 317
318/* Estimate number of page buffers neede to transmit 318static int count_skb_frag_slots(struct sk_buff *skb)
319 * Need at most 2 for RNDIS header plus skb body and fragments. 319{
320 */ 320 int i, frags = skb_shinfo(skb)->nr_frags;
321static unsigned int netvsc_get_slots(const struct sk_buff *skb) 321 int pages = 0;
322
323 for (i = 0; i < frags; i++) {
324 skb_frag_t *frag = skb_shinfo(skb)->frags + i;
325 unsigned long size = skb_frag_size(frag);
326 unsigned long offset = frag->page_offset;
327
328 /* Skip unused frames from start of page */
329 offset &= ~PAGE_MASK;
330 pages += PFN_UP(offset + size);
331 }
332 return pages;
333}
334
335static int netvsc_get_slots(struct sk_buff *skb)
322{ 336{
323 return PFN_UP(offset_in_page(skb->data) + skb_headlen(skb)) 337 char *data = skb->data;
324 + skb_shinfo(skb)->nr_frags 338 unsigned int offset = offset_in_page(data);
325 + 2; 339 unsigned int len = skb_headlen(skb);
340 int slots;
341 int frag_slots;
342
343 slots = DIV_ROUND_UP(offset + len, PAGE_SIZE);
344 frag_slots = count_skb_frag_slots(skb);
345 return slots + frag_slots;
326} 346}
327 347
328static u32 net_checksum_info(struct sk_buff *skb) 348static u32 net_checksum_info(struct sk_buff *skb)
@@ -360,18 +380,21 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
360 struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT]; 380 struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT];
361 struct hv_page_buffer *pb = page_buf; 381 struct hv_page_buffer *pb = page_buf;
362 382
363 /* We can only transmit MAX_PAGE_BUFFER_COUNT number 383 /* We will atmost need two pages to describe the rndis
384 * header. We can only transmit MAX_PAGE_BUFFER_COUNT number
364 * of pages in a single packet. If skb is scattered around 385 * of pages in a single packet. If skb is scattered around
365 * more pages we try linearizing it. 386 * more pages we try linearizing it.
366 */ 387 */
367 num_data_pgs = netvsc_get_slots(skb); 388
389 num_data_pgs = netvsc_get_slots(skb) + 2;
390
368 if (unlikely(num_data_pgs > MAX_PAGE_BUFFER_COUNT)) { 391 if (unlikely(num_data_pgs > MAX_PAGE_BUFFER_COUNT)) {
369 ++net_device_ctx->eth_stats.tx_scattered; 392 ++net_device_ctx->eth_stats.tx_scattered;
370 393
371 if (skb_linearize(skb)) 394 if (skb_linearize(skb))
372 goto no_memory; 395 goto no_memory;
373 396
374 num_data_pgs = netvsc_get_slots(skb); 397 num_data_pgs = netvsc_get_slots(skb) + 2;
375 if (num_data_pgs > MAX_PAGE_BUFFER_COUNT) { 398 if (num_data_pgs > MAX_PAGE_BUFFER_COUNT) {
376 ++net_device_ctx->eth_stats.tx_too_big; 399 ++net_device_ctx->eth_stats.tx_too_big;
377 goto drop; 400 goto drop;
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index 6f6ed75b63c9..765de3bedb88 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -141,9 +141,19 @@ static int mcs_set_reg(struct mcs_cb *mcs, __u16 reg, __u16 val)
141static int mcs_get_reg(struct mcs_cb *mcs, __u16 reg, __u16 * val) 141static int mcs_get_reg(struct mcs_cb *mcs, __u16 reg, __u16 * val)
142{ 142{
143 struct usb_device *dev = mcs->usbdev; 143 struct usb_device *dev = mcs->usbdev;
144 int ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 144 void *dmabuf;
145 MCS_RD_RTYPE, 0, reg, val, 2, 145 int ret;
146 msecs_to_jiffies(MCS_CTRL_TIMEOUT)); 146
147 dmabuf = kmalloc(sizeof(__u16), GFP_KERNEL);
148 if (!dmabuf)
149 return -ENOMEM;
150
151 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
152 MCS_RD_RTYPE, 0, reg, dmabuf, 2,
153 msecs_to_jiffies(MCS_CTRL_TIMEOUT));
154
155 memcpy(val, dmabuf, sizeof(__u16));
156 kfree(dmabuf);
147 157
148 return ret; 158 return ret;
149} 159}
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 2dda72004a7d..928fd892f167 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -7,7 +7,16 @@ menuconfig MDIO_DEVICE
7 help 7 help
8 MDIO devices and driver infrastructure code. 8 MDIO devices and driver infrastructure code.
9 9
10if MDIO_DEVICE 10config MDIO_BUS
11 tristate
12 default m if PHYLIB=m
13 default MDIO_DEVICE
14 help
15 This internal symbol is used for link time dependencies and it
16 reflects whether the mdio_bus/mdio_device code is built as a
17 loadable module or built-in.
18
19if MDIO_BUS
11 20
12config MDIO_BCM_IPROC 21config MDIO_BCM_IPROC
13 tristate "Broadcom iProc MDIO bus controller" 22 tristate "Broadcom iProc MDIO bus controller"
@@ -28,7 +37,6 @@ config MDIO_BCM_UNIMAC
28 37
29config MDIO_BITBANG 38config MDIO_BITBANG
30 tristate "Bitbanged MDIO buses" 39 tristate "Bitbanged MDIO buses"
31 depends on !(MDIO_DEVICE=y && PHYLIB=m)
32 help 40 help
33 This module implements the MDIO bus protocol in software, 41 This module implements the MDIO bus protocol in software,
34 for use by low level drivers that export the ability to 42 for use by low level drivers that export the ability to
@@ -127,7 +135,6 @@ config MDIO_THUNDER
127 tristate "ThunderX SOCs MDIO buses" 135 tristate "ThunderX SOCs MDIO buses"
128 depends on 64BIT 136 depends on 64BIT
129 depends on PCI 137 depends on PCI
130 depends on !(MDIO_DEVICE=y && PHYLIB=m)
131 select MDIO_CAVIUM 138 select MDIO_CAVIUM
132 help 139 help
133 This driver supports the MDIO interfaces found on Cavium 140 This driver supports the MDIO interfaces found on Cavium
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index d0626bf5c540..5068c582d502 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -749,6 +749,9 @@ void phy_stop_machine(struct phy_device *phydev)
749 if (phydev->state > PHY_UP && phydev->state != PHY_HALTED) 749 if (phydev->state > PHY_UP && phydev->state != PHY_HALTED)
750 phydev->state = PHY_UP; 750 phydev->state = PHY_UP;
751 mutex_unlock(&phydev->lock); 751 mutex_unlock(&phydev->lock);
752
753 /* Now we can run the state machine synchronously */
754 phy_state_machine(&phydev->state_queue.work);
752} 755}
753 756
754/** 757/**
diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index eac499c58aa7..6dde9a0cfe76 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -131,7 +131,6 @@ static void del_chan(struct pppox_sock *sock)
131 clear_bit(sock->proto.pptp.src_addr.call_id, callid_bitmap); 131 clear_bit(sock->proto.pptp.src_addr.call_id, callid_bitmap);
132 RCU_INIT_POINTER(callid_sock[sock->proto.pptp.src_addr.call_id], NULL); 132 RCU_INIT_POINTER(callid_sock[sock->proto.pptp.src_addr.call_id], NULL);
133 spin_unlock(&chan_lock); 133 spin_unlock(&chan_lock);
134 synchronize_rcu();
135} 134}
136 135
137static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb) 136static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
@@ -520,6 +519,7 @@ static int pptp_release(struct socket *sock)
520 519
521 po = pppox_sk(sk); 520 po = pppox_sk(sk);
522 del_chan(po); 521 del_chan(po);
522 synchronize_rcu();
523 523
524 pppox_unbind_sock(sk); 524 pppox_unbind_sock(sk);
525 sk->sk_state = PPPOX_DEAD; 525 sk->sk_state = PPPOX_DEAD;
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 464570409796..ae53e899259f 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -60,11 +60,11 @@ static struct team_port *team_port_get_rtnl(const struct net_device *dev)
60static int __set_port_dev_addr(struct net_device *port_dev, 60static int __set_port_dev_addr(struct net_device *port_dev,
61 const unsigned char *dev_addr) 61 const unsigned char *dev_addr)
62{ 62{
63 struct sockaddr addr; 63 struct sockaddr_storage addr;
64 64
65 memcpy(addr.sa_data, dev_addr, port_dev->addr_len); 65 memcpy(addr.__data, dev_addr, port_dev->addr_len);
66 addr.sa_family = port_dev->type; 66 addr.ss_family = port_dev->type;
67 return dev_set_mac_address(port_dev, &addr); 67 return dev_set_mac_address(port_dev, (struct sockaddr *)&addr);
68} 68}
69 69
70static int team_port_set_orig_dev_addr(struct team_port *port) 70static int team_port_set_orig_dev_addr(struct team_port *port)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 3d4c24572ecd..32ad87345f57 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2598,8 +2598,16 @@ static int __init tun_init(void)
2598 goto err_misc; 2598 goto err_misc;
2599 } 2599 }
2600 2600
2601 register_netdevice_notifier(&tun_notifier_block); 2601 ret = register_netdevice_notifier(&tun_notifier_block);
2602 if (ret) {
2603 pr_err("Can't register netdevice notifier\n");
2604 goto err_notifier;
2605 }
2606
2602 return 0; 2607 return 0;
2608
2609err_notifier:
2610 misc_deregister(&tun_miscdev);
2603err_misc: 2611err_misc:
2604 rtnl_link_unregister(&tun_link_ops); 2612 rtnl_link_unregister(&tun_link_ops);
2605err_linkops: 2613err_linkops:
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index f41ab0ea942a..98f17b05c68b 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -889,21 +889,20 @@ static int add_recvbuf_mergeable(struct virtnet_info *vi,
889 889
890 buf = (char *)page_address(alloc_frag->page) + alloc_frag->offset; 890 buf = (char *)page_address(alloc_frag->page) + alloc_frag->offset;
891 buf += headroom; /* advance address leaving hole at front of pkt */ 891 buf += headroom; /* advance address leaving hole at front of pkt */
892 ctx = (void *)(unsigned long)len;
893 get_page(alloc_frag->page); 892 get_page(alloc_frag->page);
894 alloc_frag->offset += len + headroom; 893 alloc_frag->offset += len + headroom;
895 hole = alloc_frag->size - alloc_frag->offset; 894 hole = alloc_frag->size - alloc_frag->offset;
896 if (hole < len + headroom) { 895 if (hole < len + headroom) {
897 /* To avoid internal fragmentation, if there is very likely not 896 /* To avoid internal fragmentation, if there is very likely not
898 * enough space for another buffer, add the remaining space to 897 * enough space for another buffer, add the remaining space to
899 * the current buffer. This extra space is not included in 898 * the current buffer.
900 * the truesize stored in ctx.
901 */ 899 */
902 len += hole; 900 len += hole;
903 alloc_frag->offset += hole; 901 alloc_frag->offset += hole;
904 } 902 }
905 903
906 sg_init_one(rq->sg, buf, len); 904 sg_init_one(rq->sg, buf, len);
905 ctx = (void *)(unsigned long)len;
907 err = virtqueue_add_inbuf_ctx(rq->vq, rq->sg, 1, buf, ctx, gfp); 906 err = virtqueue_add_inbuf_ctx(rq->vq, rq->sg, 1, buf, ctx, gfp);
908 if (err < 0) 907 if (err < 0)
909 put_page(virt_to_head_page(buf)); 908 put_page(virt_to_head_page(buf));
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 2153e8062b4c..5cc3a07dda9e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -214,7 +214,7 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb,
214 214
215 /* Make sure there's enough writeable headroom */ 215 /* Make sure there's enough writeable headroom */
216 if (skb_headroom(skb) < drvr->hdrlen || skb_header_cloned(skb)) { 216 if (skb_headroom(skb) < drvr->hdrlen || skb_header_cloned(skb)) {
217 head_delta = drvr->hdrlen - skb_headroom(skb); 217 head_delta = max_t(int, drvr->hdrlen - skb_headroom(skb), 0);
218 218
219 brcmf_dbg(INFO, "%s: insufficient headroom (%d)\n", 219 brcmf_dbg(INFO, "%s: insufficient headroom (%d)\n",
220 brcmf_ifname(ifp), head_delta); 220 brcmf_ifname(ifp), head_delta);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index fbcbb4325936..f3556122c6ac 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -2053,12 +2053,13 @@ static int brcmf_sdio_txpkt_hdalign(struct brcmf_sdio *bus, struct sk_buff *pkt)
2053 atomic_inc(&stats->pktcow_failed); 2053 atomic_inc(&stats->pktcow_failed);
2054 return -ENOMEM; 2054 return -ENOMEM;
2055 } 2055 }
2056 head_pad = 0;
2056 } 2057 }
2057 skb_push(pkt, head_pad); 2058 skb_push(pkt, head_pad);
2058 dat_buf = (u8 *)(pkt->data); 2059 dat_buf = (u8 *)(pkt->data);
2059 } 2060 }
2060 memset(dat_buf, 0, head_pad + bus->tx_hdrlen); 2061 memset(dat_buf, 0, head_pad + bus->tx_hdrlen);
2061 return 0; 2062 return head_pad;
2062} 2063}
2063 2064
2064/** 2065/**
@@ -4174,11 +4175,6 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
4174 goto fail; 4175 goto fail;
4175 } 4176 }
4176 4177
4177 /* allocate scatter-gather table. sg support
4178 * will be disabled upon allocation failure.
4179 */
4180 brcmf_sdiod_sgtable_alloc(bus->sdiodev);
4181
4182 /* Query the F2 block size, set roundup accordingly */ 4178 /* Query the F2 block size, set roundup accordingly */
4183 bus->blocksize = bus->sdiodev->func[2]->cur_blksize; 4179 bus->blocksize = bus->sdiodev->func[2]->cur_blksize;
4184 bus->roundup = min(max_roundup, bus->blocksize); 4180 bus->roundup = min(max_roundup, bus->blocksize);
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/tx.c b/drivers/net/wireless/intel/iwlwifi/dvm/tx.c
index adaa2f0097cc..fb40ddfced99 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/tx.c
@@ -1189,11 +1189,11 @@ void iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb)
1189 next_reclaimed; 1189 next_reclaimed;
1190 IWL_DEBUG_TX_REPLY(priv, "Next reclaimed packet:%d\n", 1190 IWL_DEBUG_TX_REPLY(priv, "Next reclaimed packet:%d\n",
1191 next_reclaimed); 1191 next_reclaimed);
1192 iwlagn_check_ratid_empty(priv, sta_id, tid);
1192 } 1193 }
1193 1194
1194 iwl_trans_reclaim(priv->trans, txq_id, ssn, &skbs); 1195 iwl_trans_reclaim(priv->trans, txq_id, ssn, &skbs);
1195 1196
1196 iwlagn_check_ratid_empty(priv, sta_id, tid);
1197 freed = 0; 1197 freed = 0;
1198 1198
1199 /* process frames */ 1199 /* process frames */
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.h
index 545d14b0bc92..f5c1127253cb 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.h
@@ -55,8 +55,8 @@ static inline bool iwl_trace_data(struct sk_buff *skb)
55 /* also account for the RFC 1042 header, of course */ 55 /* also account for the RFC 1042 header, of course */
56 offs += 6; 56 offs += 6;
57 57
58 return skb->len > offs + 2 && 58 return skb->len <= offs + 2 ||
59 *(__be16 *)(skb->data + offs) == cpu_to_be16(ETH_P_PAE); 59 *(__be16 *)(skb->data + offs) != cpu_to_be16(ETH_P_PAE);
60} 60}
61 61
62static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans, 62static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index bcde1ba0f1c8..c7b1e58e3384 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -1084,7 +1084,13 @@ int __iwl_mvm_mac_start(struct iwl_mvm *mvm)
1084 1084
1085 lockdep_assert_held(&mvm->mutex); 1085 lockdep_assert_held(&mvm->mutex);
1086 1086
1087 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { 1087 if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status)) {
1088 /*
1089 * Now convert the HW_RESTART_REQUESTED flag to IN_HW_RESTART
1090 * so later code will - from now on - see that we're doing it.
1091 */
1092 set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1093 clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status);
1088 /* Clean up some internal and mac80211 state on restart */ 1094 /* Clean up some internal and mac80211 state on restart */
1089 iwl_mvm_restart_cleanup(mvm); 1095 iwl_mvm_restart_cleanup(mvm);
1090 } else { 1096 } else {
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index eaacfaf37206..ddd8719f27b8 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -1090,6 +1090,7 @@ struct iwl_mvm {
1090 * @IWL_MVM_STATUS_HW_RFKILL: HW RF-kill is asserted 1090 * @IWL_MVM_STATUS_HW_RFKILL: HW RF-kill is asserted
1091 * @IWL_MVM_STATUS_HW_CTKILL: CT-kill is active 1091 * @IWL_MVM_STATUS_HW_CTKILL: CT-kill is active
1092 * @IWL_MVM_STATUS_ROC_RUNNING: remain-on-channel is running 1092 * @IWL_MVM_STATUS_ROC_RUNNING: remain-on-channel is running
1093 * @IWL_MVM_STATUS_HW_RESTART_REQUESTED: HW restart was requested
1093 * @IWL_MVM_STATUS_IN_HW_RESTART: HW restart is active 1094 * @IWL_MVM_STATUS_IN_HW_RESTART: HW restart is active
1094 * @IWL_MVM_STATUS_IN_D0I3: NIC is in D0i3 1095 * @IWL_MVM_STATUS_IN_D0I3: NIC is in D0i3
1095 * @IWL_MVM_STATUS_ROC_AUX_RUNNING: AUX remain-on-channel is running 1096 * @IWL_MVM_STATUS_ROC_AUX_RUNNING: AUX remain-on-channel is running
@@ -1101,6 +1102,7 @@ enum iwl_mvm_status {
1101 IWL_MVM_STATUS_HW_RFKILL, 1102 IWL_MVM_STATUS_HW_RFKILL,
1102 IWL_MVM_STATUS_HW_CTKILL, 1103 IWL_MVM_STATUS_HW_CTKILL,
1103 IWL_MVM_STATUS_ROC_RUNNING, 1104 IWL_MVM_STATUS_ROC_RUNNING,
1105 IWL_MVM_STATUS_HW_RESTART_REQUESTED,
1104 IWL_MVM_STATUS_IN_HW_RESTART, 1106 IWL_MVM_STATUS_IN_HW_RESTART,
1105 IWL_MVM_STATUS_IN_D0I3, 1107 IWL_MVM_STATUS_IN_D0I3,
1106 IWL_MVM_STATUS_ROC_AUX_RUNNING, 1108 IWL_MVM_STATUS_ROC_AUX_RUNNING,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 4d1188b8736a..9c175d5e9d67 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -1235,9 +1235,8 @@ void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error)
1235 */ 1235 */
1236 if (!mvm->fw_restart && fw_error) { 1236 if (!mvm->fw_restart && fw_error) {
1237 iwl_mvm_fw_dbg_collect_desc(mvm, &iwl_mvm_dump_desc_assert, 1237 iwl_mvm_fw_dbg_collect_desc(mvm, &iwl_mvm_dump_desc_assert,
1238 NULL); 1238 NULL);
1239 } else if (test_and_set_bit(IWL_MVM_STATUS_IN_HW_RESTART, 1239 } else if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) {
1240 &mvm->status)) {
1241 struct iwl_mvm_reprobe *reprobe; 1240 struct iwl_mvm_reprobe *reprobe;
1242 1241
1243 IWL_ERR(mvm, 1242 IWL_ERR(mvm,
@@ -1268,6 +1267,7 @@ void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error)
1268 1267
1269 if (fw_error && mvm->fw_restart > 0) 1268 if (fw_error && mvm->fw_restart > 0)
1270 mvm->fw_restart--; 1269 mvm->fw_restart--;
1270 set_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status);
1271 ieee80211_restart_hw(mvm->hw); 1271 ieee80211_restart_hw(mvm->hw);
1272 } 1272 }
1273} 1273}
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index 4df5f13fcdae..ab66b4394dfc 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -277,6 +277,18 @@ static void iwl_mvm_rx_agg_session_expired(unsigned long data)
277 277
278 /* Timer expired */ 278 /* Timer expired */
279 sta = rcu_dereference(ba_data->mvm->fw_id_to_mac_id[ba_data->sta_id]); 279 sta = rcu_dereference(ba_data->mvm->fw_id_to_mac_id[ba_data->sta_id]);
280
281 /*
282 * sta should be valid unless the following happens:
283 * The firmware asserts which triggers a reconfig flow, but
284 * the reconfig fails before we set the pointer to sta into
285 * the fw_id_to_mac_id pointer table. Mac80211 can't stop
286 * A-MDPU and hence the timer continues to run. Then, the
287 * timer expires and sta is NULL.
288 */
289 if (!sta)
290 goto unlock;
291
280 mvm_sta = iwl_mvm_sta_from_mac80211(sta); 292 mvm_sta = iwl_mvm_sta_from_mac80211(sta);
281 ieee80211_stop_rx_ba_session_offl(mvm_sta->vif, 293 ieee80211_stop_rx_ba_session_offl(mvm_sta->vif,
282 sta->addr, ba_data->tid); 294 sta->addr, ba_data->tid);
@@ -2015,7 +2027,8 @@ int iwl_mvm_send_add_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2015 IWL_MAX_TID_COUNT, 2027 IWL_MAX_TID_COUNT,
2016 wdg_timeout); 2028 wdg_timeout);
2017 2029
2018 if (vif->type == NL80211_IFTYPE_AP) 2030 if (vif->type == NL80211_IFTYPE_AP ||
2031 vif->type == NL80211_IFTYPE_ADHOC)
2019 mvm->probe_queue = queue; 2032 mvm->probe_queue = queue;
2020 else if (vif->type == NL80211_IFTYPE_P2P_DEVICE) 2033 else if (vif->type == NL80211_IFTYPE_P2P_DEVICE)
2021 mvm->p2p_dev_queue = queue; 2034 mvm->p2p_dev_queue = queue;
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 92b3a55d0fbc..f95eec52508e 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -3150,7 +3150,8 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
3150 init_waitqueue_head(&trans_pcie->d0i3_waitq); 3150 init_waitqueue_head(&trans_pcie->d0i3_waitq);
3151 3151
3152 if (trans_pcie->msix_enabled) { 3152 if (trans_pcie->msix_enabled) {
3153 if (iwl_pcie_init_msix_handler(pdev, trans_pcie)) 3153 ret = iwl_pcie_init_msix_handler(pdev, trans_pcie);
3154 if (ret)
3154 goto out_no_pci; 3155 goto out_no_pci;
3155 } else { 3156 } else {
3156 ret = iwl_pcie_alloc_ict(trans); 3157 ret = iwl_pcie_alloc_ict(trans);
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
index de50418adae5..034bdb4a0b06 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
@@ -298,6 +298,9 @@ void iwl_pcie_txq_check_wrptrs(struct iwl_trans *trans)
298 for (i = 0; i < trans->cfg->base_params->num_of_queues; i++) { 298 for (i = 0; i < trans->cfg->base_params->num_of_queues; i++) {
299 struct iwl_txq *txq = trans_pcie->txq[i]; 299 struct iwl_txq *txq = trans_pcie->txq[i];
300 300
301 if (!test_bit(i, trans_pcie->queue_used))
302 continue;
303
301 spin_lock_bh(&txq->lock); 304 spin_lock_bh(&txq->lock);
302 if (txq->need_update) { 305 if (txq->need_update) {
303 iwl_pcie_txq_inc_wr_ptr(trans, txq); 306 iwl_pcie_txq_inc_wr_ptr(trans, txq);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index 2a7ad5ffe997..cd5dc6dcb19f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -846,9 +846,6 @@ static bool _rtl8723be_init_mac(struct ieee80211_hw *hw)
846 return false; 846 return false;
847 } 847 }
848 848
849 if (rtlpriv->cfg->ops->get_btc_status())
850 rtlpriv->btcoexist.btc_ops->btc_power_on_setting(rtlpriv);
851
852 bytetmp = rtl_read_byte(rtlpriv, REG_MULTI_FUNC_CTRL); 849 bytetmp = rtl_read_byte(rtlpriv, REG_MULTI_FUNC_CTRL);
853 rtl_write_byte(rtlpriv, REG_MULTI_FUNC_CTRL, bytetmp | BIT(3)); 850 rtl_write_byte(rtlpriv, REG_MULTI_FUNC_CTRL, bytetmp | BIT(3));
854 851
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index fb1ebb01133f..70723e67b7d7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -2547,7 +2547,6 @@ struct bt_coexist_info {
2547struct rtl_btc_ops { 2547struct rtl_btc_ops {
2548 void (*btc_init_variables) (struct rtl_priv *rtlpriv); 2548 void (*btc_init_variables) (struct rtl_priv *rtlpriv);
2549 void (*btc_init_hal_vars) (struct rtl_priv *rtlpriv); 2549 void (*btc_init_hal_vars) (struct rtl_priv *rtlpriv);
2550 void (*btc_power_on_setting)(struct rtl_priv *rtlpriv);
2551 void (*btc_init_hw_config) (struct rtl_priv *rtlpriv); 2550 void (*btc_init_hw_config) (struct rtl_priv *rtlpriv);
2552 void (*btc_ips_notify) (struct rtl_priv *rtlpriv, u8 type); 2551 void (*btc_ips_notify) (struct rtl_priv *rtlpriv, u8 type);
2553 void (*btc_lps_notify)(struct rtl_priv *rtlpriv, u8 type); 2552 void (*btc_lps_notify)(struct rtl_priv *rtlpriv, u8 type);
diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
index 37371b89b14f..64fc59c3ae6d 100644
--- a/drivers/phy/broadcom/Kconfig
+++ b/drivers/phy/broadcom/Kconfig
@@ -30,8 +30,8 @@ config PHY_BCM_NS_USB3
30 tristate "Broadcom Northstar USB 3.0 PHY Driver" 30 tristate "Broadcom Northstar USB 3.0 PHY Driver"
31 depends on ARCH_BCM_IPROC || COMPILE_TEST 31 depends on ARCH_BCM_IPROC || COMPILE_TEST
32 depends on HAS_IOMEM && OF 32 depends on HAS_IOMEM && OF
33 depends on MDIO_BUS
33 select GENERIC_PHY 34 select GENERIC_PHY
34 select MDIO_DEVICE
35 help 35 help
36 Enable this to support Broadcom USB 3.0 PHY connected to the USB 36 Enable this to support Broadcom USB 3.0 PHY connected to the USB
37 controller on Northstar family. 37 controller on Northstar family.
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index e4613a3c362d..9cb3f722dce1 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -308,7 +308,6 @@ static void vhost_vq_reset(struct vhost_dev *dev,
308 vq->avail = NULL; 308 vq->avail = NULL;
309 vq->used = NULL; 309 vq->used = NULL;
310 vq->last_avail_idx = 0; 310 vq->last_avail_idx = 0;
311 vq->last_used_event = 0;
312 vq->avail_idx = 0; 311 vq->avail_idx = 0;
313 vq->last_used_idx = 0; 312 vq->last_used_idx = 0;
314 vq->signalled_used = 0; 313 vq->signalled_used = 0;
@@ -1402,7 +1401,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
1402 r = -EINVAL; 1401 r = -EINVAL;
1403 break; 1402 break;
1404 } 1403 }
1405 vq->last_avail_idx = vq->last_used_event = s.num; 1404 vq->last_avail_idx = s.num;
1406 /* Forget the cached index value. */ 1405 /* Forget the cached index value. */
1407 vq->avail_idx = vq->last_avail_idx; 1406 vq->avail_idx = vq->last_avail_idx;
1408 break; 1407 break;
@@ -2241,6 +2240,10 @@ static bool vhost_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
2241 __u16 old, new; 2240 __u16 old, new;
2242 __virtio16 event; 2241 __virtio16 event;
2243 bool v; 2242 bool v;
2243 /* Flush out used index updates. This is paired
2244 * with the barrier that the Guest executes when enabling
2245 * interrupts. */
2246 smp_mb();
2244 2247
2245 if (vhost_has_feature(vq, VIRTIO_F_NOTIFY_ON_EMPTY) && 2248 if (vhost_has_feature(vq, VIRTIO_F_NOTIFY_ON_EMPTY) &&
2246 unlikely(vq->avail_idx == vq->last_avail_idx)) 2249 unlikely(vq->avail_idx == vq->last_avail_idx))
@@ -2248,10 +2251,6 @@ static bool vhost_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
2248 2251
2249 if (!vhost_has_feature(vq, VIRTIO_RING_F_EVENT_IDX)) { 2252 if (!vhost_has_feature(vq, VIRTIO_RING_F_EVENT_IDX)) {
2250 __virtio16 flags; 2253 __virtio16 flags;
2251 /* Flush out used index updates. This is paired
2252 * with the barrier that the Guest executes when enabling
2253 * interrupts. */
2254 smp_mb();
2255 if (vhost_get_avail(vq, flags, &vq->avail->flags)) { 2254 if (vhost_get_avail(vq, flags, &vq->avail->flags)) {
2256 vq_err(vq, "Failed to get flags"); 2255 vq_err(vq, "Failed to get flags");
2257 return true; 2256 return true;
@@ -2266,26 +2265,11 @@ static bool vhost_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
2266 if (unlikely(!v)) 2265 if (unlikely(!v))
2267 return true; 2266 return true;
2268 2267
2269 /* We're sure if the following conditions are met, there's no
2270 * need to notify guest:
2271 * 1) cached used event is ahead of new
2272 * 2) old to new updating does not cross cached used event. */
2273 if (vring_need_event(vq->last_used_event, new + vq->num, new) &&
2274 !vring_need_event(vq->last_used_event, new, old))
2275 return false;
2276
2277 /* Flush out used index updates. This is paired
2278 * with the barrier that the Guest executes when enabling
2279 * interrupts. */
2280 smp_mb();
2281
2282 if (vhost_get_avail(vq, event, vhost_used_event(vq))) { 2268 if (vhost_get_avail(vq, event, vhost_used_event(vq))) {
2283 vq_err(vq, "Failed to get used event idx"); 2269 vq_err(vq, "Failed to get used event idx");
2284 return true; 2270 return true;
2285 } 2271 }
2286 vq->last_used_event = vhost16_to_cpu(vq, event); 2272 return vring_need_event(vhost16_to_cpu(vq, event), new, old);
2287
2288 return vring_need_event(vq->last_used_event, new, old);
2289} 2273}
2290 2274
2291/* This actually signals the guest, using eventfd. */ 2275/* This actually signals the guest, using eventfd. */
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index f72095868b93..bb7c29b8b9fc 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -115,9 +115,6 @@ struct vhost_virtqueue {
115 /* Last index we used. */ 115 /* Last index we used. */
116 u16 last_used_idx; 116 u16 last_used_idx;
117 117
118 /* Last used evet we've seen */
119 u16 last_used_event;
120
121 /* Used flags */ 118 /* Used flags */
122 u16 used_flags; 119 u16 used_flags;
123 120
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index e1b442996f81..474d6bbc158c 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -128,6 +128,7 @@ struct inet6_skb_parm {
128#define IP6SKB_FRAGMENTED 16 128#define IP6SKB_FRAGMENTED 16
129#define IP6SKB_HOPBYHOP 32 129#define IP6SKB_HOPBYHOP 32
130#define IP6SKB_L3SLAVE 64 130#define IP6SKB_L3SLAVE 64
131#define IP6SKB_JUMBOGRAM 128
131}; 132};
132 133
133#if defined(CONFIG_NET_L3_MASTER_DEV) 134#if defined(CONFIG_NET_L3_MASTER_DEV)
@@ -152,6 +153,11 @@ static inline int inet6_iif(const struct sk_buff *skb)
152 return l3_slave ? skb->skb_iif : IP6CB(skb)->iif; 153 return l3_slave ? skb->skb_iif : IP6CB(skb)->iif;
153} 154}
154 155
156static inline bool inet6_is_jumbogram(const struct sk_buff *skb)
157{
158 return !!(IP6CB(skb)->flags & IP6SKB_JUMBOGRAM);
159}
160
155/* can not be used in TCP layer after tcp_v6_fill_cb */ 161/* can not be used in TCP layer after tcp_v6_fill_cb */
156static inline bool inet6_exact_dif_match(struct net *net, struct sk_buff *skb) 162static inline bool inet6_exact_dif_match(struct net *net, struct sk_buff *skb)
157{ 163{
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 87869c04849a..3030121b4746 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -7749,8 +7749,10 @@ struct mlx5_ifc_pcam_reg_bits {
7749}; 7749};
7750 7750
7751struct mlx5_ifc_mcam_enhanced_features_bits { 7751struct mlx5_ifc_mcam_enhanced_features_bits {
7752 u8 reserved_at_0[0x7f]; 7752 u8 reserved_at_0[0x7d];
7753 7753
7754 u8 mtpps_enh_out_per_adj[0x1];
7755 u8 mtpps_fs[0x1];
7754 u8 pcie_performance_group[0x1]; 7756 u8 pcie_performance_group[0x1];
7755}; 7757};
7756 7758
@@ -8159,7 +8161,8 @@ struct mlx5_ifc_mtpps_reg_bits {
8159 u8 reserved_at_78[0x4]; 8161 u8 reserved_at_78[0x4];
8160 u8 cap_pin_4_mode[0x4]; 8162 u8 cap_pin_4_mode[0x4];
8161 8163
8162 u8 reserved_at_80[0x80]; 8164 u8 field_select[0x20];
8165 u8 reserved_at_a0[0x60];
8163 8166
8164 u8 enable[0x1]; 8167 u8 enable[0x1];
8165 u8 reserved_at_101[0xb]; 8168 u8 reserved_at_101[0xb];
@@ -8174,8 +8177,9 @@ struct mlx5_ifc_mtpps_reg_bits {
8174 8177
8175 u8 out_pulse_duration[0x10]; 8178 u8 out_pulse_duration[0x10];
8176 u8 out_periodic_adjustment[0x10]; 8179 u8 out_periodic_adjustment[0x10];
8180 u8 enhanced_out_periodic_adjustment[0x20];
8177 8181
8178 u8 reserved_at_1a0[0x60]; 8182 u8 reserved_at_1c0[0x20];
8179}; 8183};
8180 8184
8181struct mlx5_ifc_mtppse_reg_bits { 8185struct mlx5_ifc_mtppse_reg_bits {
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 2a9567bb8186..0bb5b212ab42 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -830,7 +830,7 @@ static inline int phy_read_status(struct phy_device *phydev)
830 dev_err(&_phydev->mdio.dev, format, ##args) 830 dev_err(&_phydev->mdio.dev, format, ##args)
831 831
832#define phydev_dbg(_phydev, format, args...) \ 832#define phydev_dbg(_phydev, format, args...) \
833 dev_dbg(&_phydev->mdio.dev, format, ##args); 833 dev_dbg(&_phydev->mdio.dev, format, ##args)
834 834
835static inline const char *phydev_name(const struct phy_device *phydev) 835static inline const char *phydev_name(const struct phy_device *phydev)
836{ 836{
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 980807d7506f..45fd4c6056b5 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -469,7 +469,7 @@ _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member)
469 469
470#define _sctp_walk_params(pos, chunk, end, member)\ 470#define _sctp_walk_params(pos, chunk, end, member)\
471for (pos.v = chunk->member;\ 471for (pos.v = chunk->member;\
472 (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <\ 472 (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <=\
473 (void *)chunk + end) &&\ 473 (void *)chunk + end) &&\
474 pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\ 474 pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\
475 ntohs(pos.p->length) >= sizeof(struct sctp_paramhdr);\ 475 ntohs(pos.p->length) >= sizeof(struct sctp_paramhdr);\
@@ -481,7 +481,7 @@ _sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length))
481#define _sctp_walk_errors(err, chunk_hdr, end)\ 481#define _sctp_walk_errors(err, chunk_hdr, end)\
482for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \ 482for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \
483 sizeof(struct sctp_chunkhdr));\ 483 sizeof(struct sctp_chunkhdr));\
484 ((void *)err + offsetof(sctp_errhdr_t, length) + sizeof(err->length) <\ 484 ((void *)err + offsetof(sctp_errhdr_t, length) + sizeof(err->length) <=\
485 (void *)chunk_hdr + end) &&\ 485 (void *)chunk_hdr + end) &&\
486 (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\ 486 (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\
487 ntohs(err->length) >= sizeof(sctp_errhdr_t); \ 487 ntohs(err->length) >= sizeof(sctp_errhdr_t); \
diff --git a/include/net/udp.h b/include/net/udp.h
index 972ce4baab6b..cc8036987dcb 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -260,6 +260,7 @@ static inline struct sk_buff *skb_recv_udp(struct sock *sk, unsigned int flags,
260} 260}
261 261
262void udp_v4_early_demux(struct sk_buff *skb); 262void udp_v4_early_demux(struct sk_buff *skb);
263void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst);
263int udp_get_port(struct sock *sk, unsigned short snum, 264int udp_get_port(struct sock *sk, unsigned short snum,
264 int (*saddr_cmp)(const struct sock *, 265 int (*saddr_cmp)(const struct sock *,
265 const struct sock *)); 266 const struct sock *));
@@ -305,33 +306,44 @@ struct sock *udp6_lib_lookup_skb(struct sk_buff *skb,
305/* UDP uses skb->dev_scratch to cache as much information as possible and avoid 306/* UDP uses skb->dev_scratch to cache as much information as possible and avoid
306 * possibly multiple cache miss on dequeue() 307 * possibly multiple cache miss on dequeue()
307 */ 308 */
308#if BITS_PER_LONG == 64
309
310/* truesize, len and the bit needed to compute skb_csum_unnecessary will be on
311 * cold cache lines at recvmsg time.
312 * skb->len can be stored on 16 bits since the udp header has been already
313 * validated and pulled.
314 */
315struct udp_dev_scratch { 309struct udp_dev_scratch {
316 u32 truesize; 310 /* skb->truesize and the stateless bit are embedded in a single field;
311 * do not use a bitfield since the compiler emits better/smaller code
312 * this way
313 */
314 u32 _tsize_state;
315
316#if BITS_PER_LONG == 64
317 /* len and the bit needed to compute skb_csum_unnecessary
318 * will be on cold cache lines at recvmsg time.
319 * skb->len can be stored on 16 bits since the udp header has been
320 * already validated and pulled.
321 */
317 u16 len; 322 u16 len;
318 bool is_linear; 323 bool is_linear;
319 bool csum_unnecessary; 324 bool csum_unnecessary;
325#endif
320}; 326};
321 327
328static inline struct udp_dev_scratch *udp_skb_scratch(struct sk_buff *skb)
329{
330 return (struct udp_dev_scratch *)&skb->dev_scratch;
331}
332
333#if BITS_PER_LONG == 64
322static inline unsigned int udp_skb_len(struct sk_buff *skb) 334static inline unsigned int udp_skb_len(struct sk_buff *skb)
323{ 335{
324 return ((struct udp_dev_scratch *)&skb->dev_scratch)->len; 336 return udp_skb_scratch(skb)->len;
325} 337}
326 338
327static inline bool udp_skb_csum_unnecessary(struct sk_buff *skb) 339static inline bool udp_skb_csum_unnecessary(struct sk_buff *skb)
328{ 340{
329 return ((struct udp_dev_scratch *)&skb->dev_scratch)->csum_unnecessary; 341 return udp_skb_scratch(skb)->csum_unnecessary;
330} 342}
331 343
332static inline bool udp_skb_is_linear(struct sk_buff *skb) 344static inline bool udp_skb_is_linear(struct sk_buff *skb)
333{ 345{
334 return ((struct udp_dev_scratch *)&skb->dev_scratch)->is_linear; 346 return udp_skb_scratch(skb)->is_linear;
335} 347}
336 348
337#else 349#else
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 045646da97cc..6c772adabad2 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1289,7 +1289,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
1289 info_len = min_t(u32, sizeof(info), info_len); 1289 info_len = min_t(u32, sizeof(info), info_len);
1290 1290
1291 if (copy_from_user(&info, uinfo, info_len)) 1291 if (copy_from_user(&info, uinfo, info_len))
1292 return err; 1292 return -EFAULT;
1293 1293
1294 info.type = prog->type; 1294 info.type = prog->type;
1295 info.id = prog->aux->id; 1295 info.id = prog->aux->id;
@@ -1312,7 +1312,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
1312 } 1312 }
1313 1313
1314 ulen = info.xlated_prog_len; 1314 ulen = info.xlated_prog_len;
1315 info.xlated_prog_len = bpf_prog_size(prog->len); 1315 info.xlated_prog_len = bpf_prog_insn_size(prog);
1316 if (info.xlated_prog_len && ulen) { 1316 if (info.xlated_prog_len && ulen) {
1317 uinsns = u64_to_user_ptr(info.xlated_prog_insns); 1317 uinsns = u64_to_user_ptr(info.xlated_prog_insns);
1318 ulen = min_t(u32, info.xlated_prog_len, ulen); 1318 ulen = min_t(u32, info.xlated_prog_len, ulen);
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index af9e84a4944e..664d93972373 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1865,10 +1865,12 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
1865 * do our normal operations to the register, we need to set the values 1865 * do our normal operations to the register, we need to set the values
1866 * to the min/max since they are undefined. 1866 * to the min/max since they are undefined.
1867 */ 1867 */
1868 if (min_val == BPF_REGISTER_MIN_RANGE) 1868 if (opcode != BPF_SUB) {
1869 dst_reg->min_value = BPF_REGISTER_MIN_RANGE; 1869 if (min_val == BPF_REGISTER_MIN_RANGE)
1870 if (max_val == BPF_REGISTER_MAX_RANGE) 1870 dst_reg->min_value = BPF_REGISTER_MIN_RANGE;
1871 dst_reg->max_value = BPF_REGISTER_MAX_RANGE; 1871 if (max_val == BPF_REGISTER_MAX_RANGE)
1872 dst_reg->max_value = BPF_REGISTER_MAX_RANGE;
1873 }
1872 1874
1873 switch (opcode) { 1875 switch (opcode) {
1874 case BPF_ADD: 1876 case BPF_ADD:
@@ -1879,10 +1881,17 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
1879 dst_reg->min_align = min(src_align, dst_align); 1881 dst_reg->min_align = min(src_align, dst_align);
1880 break; 1882 break;
1881 case BPF_SUB: 1883 case BPF_SUB:
1884 /* If one of our values was at the end of our ranges, then the
1885 * _opposite_ value in the dst_reg goes to the end of our range.
1886 */
1887 if (min_val == BPF_REGISTER_MIN_RANGE)
1888 dst_reg->max_value = BPF_REGISTER_MAX_RANGE;
1889 if (max_val == BPF_REGISTER_MAX_RANGE)
1890 dst_reg->min_value = BPF_REGISTER_MIN_RANGE;
1882 if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE) 1891 if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE)
1883 dst_reg->min_value -= min_val; 1892 dst_reg->min_value -= max_val;
1884 if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE) 1893 if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
1885 dst_reg->max_value -= max_val; 1894 dst_reg->max_value -= min_val;
1886 dst_reg->min_align = min(src_align, dst_align); 1895 dst_reg->min_align = min(src_align, dst_align);
1887 break; 1896 break;
1888 case BPF_MUL: 1897 case BPF_MUL:
diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
index 64e899b63337..0ffca990a833 100644
--- a/lib/test_rhashtable.c
+++ b/lib/test_rhashtable.c
@@ -56,8 +56,13 @@ static bool enomem_retry = false;
56module_param(enomem_retry, bool, 0); 56module_param(enomem_retry, bool, 0);
57MODULE_PARM_DESC(enomem_retry, "Retry insert even if -ENOMEM was returned (default: off)"); 57MODULE_PARM_DESC(enomem_retry, "Retry insert even if -ENOMEM was returned (default: off)");
58 58
59struct test_obj_val {
60 int id;
61 int tid;
62};
63
59struct test_obj { 64struct test_obj {
60 int value; 65 struct test_obj_val value;
61 struct rhash_head node; 66 struct rhash_head node;
62}; 67};
63 68
@@ -72,7 +77,7 @@ static struct test_obj array[MAX_ENTRIES];
72static struct rhashtable_params test_rht_params = { 77static struct rhashtable_params test_rht_params = {
73 .head_offset = offsetof(struct test_obj, node), 78 .head_offset = offsetof(struct test_obj, node),
74 .key_offset = offsetof(struct test_obj, value), 79 .key_offset = offsetof(struct test_obj, value),
75 .key_len = sizeof(int), 80 .key_len = sizeof(struct test_obj_val),
76 .hashfn = jhash, 81 .hashfn = jhash,
77 .nulls_base = (3U << RHT_BASE_SHIFT), 82 .nulls_base = (3U << RHT_BASE_SHIFT),
78}; 83};
@@ -109,24 +114,26 @@ static int __init test_rht_lookup(struct rhashtable *ht)
109 for (i = 0; i < entries * 2; i++) { 114 for (i = 0; i < entries * 2; i++) {
110 struct test_obj *obj; 115 struct test_obj *obj;
111 bool expected = !(i % 2); 116 bool expected = !(i % 2);
112 u32 key = i; 117 struct test_obj_val key = {
118 .id = i,
119 };
113 120
114 if (array[i / 2].value == TEST_INSERT_FAIL) 121 if (array[i / 2].value.id == TEST_INSERT_FAIL)
115 expected = false; 122 expected = false;
116 123
117 obj = rhashtable_lookup_fast(ht, &key, test_rht_params); 124 obj = rhashtable_lookup_fast(ht, &key, test_rht_params);
118 125
119 if (expected && !obj) { 126 if (expected && !obj) {
120 pr_warn("Test failed: Could not find key %u\n", key); 127 pr_warn("Test failed: Could not find key %u\n", key.id);
121 return -ENOENT; 128 return -ENOENT;
122 } else if (!expected && obj) { 129 } else if (!expected && obj) {
123 pr_warn("Test failed: Unexpected entry found for key %u\n", 130 pr_warn("Test failed: Unexpected entry found for key %u\n",
124 key); 131 key.id);
125 return -EEXIST; 132 return -EEXIST;
126 } else if (expected && obj) { 133 } else if (expected && obj) {
127 if (obj->value != i) { 134 if (obj->value.id != i) {
128 pr_warn("Test failed: Lookup value mismatch %u!=%u\n", 135 pr_warn("Test failed: Lookup value mismatch %u!=%u\n",
129 obj->value, i); 136 obj->value.id, i);
130 return -EINVAL; 137 return -EINVAL;
131 } 138 }
132 } 139 }
@@ -195,7 +202,7 @@ static s64 __init test_rhashtable(struct rhashtable *ht)
195 for (i = 0; i < entries; i++) { 202 for (i = 0; i < entries; i++) {
196 struct test_obj *obj = &array[i]; 203 struct test_obj *obj = &array[i];
197 204
198 obj->value = i * 2; 205 obj->value.id = i * 2;
199 err = insert_retry(ht, &obj->node, test_rht_params); 206 err = insert_retry(ht, &obj->node, test_rht_params);
200 if (err > 0) 207 if (err > 0)
201 insert_retries += err; 208 insert_retries += err;
@@ -216,9 +223,11 @@ static s64 __init test_rhashtable(struct rhashtable *ht)
216 223
217 pr_info(" Deleting %d keys\n", entries); 224 pr_info(" Deleting %d keys\n", entries);
218 for (i = 0; i < entries; i++) { 225 for (i = 0; i < entries; i++) {
219 u32 key = i * 2; 226 struct test_obj_val key = {
227 .id = i * 2,
228 };
220 229
221 if (array[i].value != TEST_INSERT_FAIL) { 230 if (array[i].value.id != TEST_INSERT_FAIL) {
222 obj = rhashtable_lookup_fast(ht, &key, test_rht_params); 231 obj = rhashtable_lookup_fast(ht, &key, test_rht_params);
223 BUG_ON(!obj); 232 BUG_ON(!obj);
224 233
@@ -242,18 +251,21 @@ static int thread_lookup_test(struct thread_data *tdata)
242 251
243 for (i = 0; i < entries; i++) { 252 for (i = 0; i < entries; i++) {
244 struct test_obj *obj; 253 struct test_obj *obj;
245 int key = (tdata->id << 16) | i; 254 struct test_obj_val key = {
255 .id = i,
256 .tid = tdata->id,
257 };
246 258
247 obj = rhashtable_lookup_fast(&ht, &key, test_rht_params); 259 obj = rhashtable_lookup_fast(&ht, &key, test_rht_params);
248 if (obj && (tdata->objs[i].value == TEST_INSERT_FAIL)) { 260 if (obj && (tdata->objs[i].value.id == TEST_INSERT_FAIL)) {
249 pr_err(" found unexpected object %d\n", key); 261 pr_err(" found unexpected object %d-%d\n", key.tid, key.id);
250 err++; 262 err++;
251 } else if (!obj && (tdata->objs[i].value != TEST_INSERT_FAIL)) { 263 } else if (!obj && (tdata->objs[i].value.id != TEST_INSERT_FAIL)) {
252 pr_err(" object %d not found!\n", key); 264 pr_err(" object %d-%d not found!\n", key.tid, key.id);
253 err++; 265 err++;
254 } else if (obj && (obj->value != key)) { 266 } else if (obj && memcmp(&obj->value, &key, sizeof(key))) {
255 pr_err(" wrong object returned (got %d, expected %d)\n", 267 pr_err(" wrong object returned (got %d-%d, expected %d-%d)\n",
256 obj->value, key); 268 obj->value.tid, obj->value.id, key.tid, key.id);
257 err++; 269 err++;
258 } 270 }
259 271
@@ -272,7 +284,8 @@ static int threadfunc(void *data)
272 pr_err(" thread[%d]: down_interruptible failed\n", tdata->id); 284 pr_err(" thread[%d]: down_interruptible failed\n", tdata->id);
273 285
274 for (i = 0; i < entries; i++) { 286 for (i = 0; i < entries; i++) {
275 tdata->objs[i].value = (tdata->id << 16) | i; 287 tdata->objs[i].value.id = i;
288 tdata->objs[i].value.tid = tdata->id;
276 err = insert_retry(&ht, &tdata->objs[i].node, test_rht_params); 289 err = insert_retry(&ht, &tdata->objs[i].node, test_rht_params);
277 if (err > 0) { 290 if (err > 0) {
278 insert_retries += err; 291 insert_retries += err;
@@ -295,7 +308,7 @@ static int threadfunc(void *data)
295 308
296 for (step = 10; step > 0; step--) { 309 for (step = 10; step > 0; step--) {
297 for (i = 0; i < entries; i += step) { 310 for (i = 0; i < entries; i += step) {
298 if (tdata->objs[i].value == TEST_INSERT_FAIL) 311 if (tdata->objs[i].value.id == TEST_INSERT_FAIL)
299 continue; 312 continue;
300 err = rhashtable_remove_fast(&ht, &tdata->objs[i].node, 313 err = rhashtable_remove_fast(&ht, &tdata->objs[i].node,
301 test_rht_params); 314 test_rht_params);
@@ -304,7 +317,7 @@ static int threadfunc(void *data)
304 tdata->id); 317 tdata->id);
305 goto out; 318 goto out;
306 } 319 }
307 tdata->objs[i].value = TEST_INSERT_FAIL; 320 tdata->objs[i].value.id = TEST_INSERT_FAIL;
308 321
309 cond_resched(); 322 cond_resched();
310 } 323 }
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 06b147d7d9e2..709a4e6fb447 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -263,6 +263,8 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
263 return dev_set_mtu(dev, ifr->ifr_mtu); 263 return dev_set_mtu(dev, ifr->ifr_mtu);
264 264
265 case SIOCSIFHWADDR: 265 case SIOCSIFHWADDR:
266 if (dev->addr_len > sizeof(struct sockaddr))
267 return -EINVAL;
266 return dev_set_mac_address(dev, &ifr->ifr_hwaddr); 268 return dev_set_mac_address(dev, &ifr->ifr_hwaddr);
267 269
268 case SIOCSIFHWBROADCAST: 270 case SIOCSIFHWBROADCAST:
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 8357f164c660..912731bed7b7 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -666,7 +666,7 @@ int netpoll_setup(struct netpoll *np)
666 int err; 666 int err;
667 667
668 rtnl_lock(); 668 rtnl_lock();
669 if (np->dev_name) { 669 if (np->dev_name[0]) {
670 struct net *net = current->nsproxy->net_ns; 670 struct net *net = current->nsproxy->net_ns;
671 ndev = __dev_get_by_name(net, np->dev_name); 671 ndev = __dev_get_by_name(net, np->dev_name);
672 } 672 }
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index 1704948e6a12..f227f002c73d 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -1471,9 +1471,12 @@ int dccp_feat_init(struct sock *sk)
1471 * singleton values (which always leads to failure). 1471 * singleton values (which always leads to failure).
1472 * These settings can still (later) be overridden via sockopts. 1472 * These settings can still (later) be overridden via sockopts.
1473 */ 1473 */
1474 if (ccid_get_builtin_ccids(&tx.val, &tx.len) || 1474 if (ccid_get_builtin_ccids(&tx.val, &tx.len))
1475 ccid_get_builtin_ccids(&rx.val, &rx.len))
1476 return -ENOBUFS; 1475 return -ENOBUFS;
1476 if (ccid_get_builtin_ccids(&rx.val, &rx.len)) {
1477 kfree(tx.val);
1478 return -ENOBUFS;
1479 }
1477 1480
1478 if (!dccp_feat_prefer(sysctl_dccp_tx_ccid, tx.val, tx.len) || 1481 if (!dccp_feat_prefer(sysctl_dccp_tx_ccid, tx.val, tx.len) ||
1479 !dccp_feat_prefer(sysctl_dccp_rx_ccid, rx.val, rx.len)) 1482 !dccp_feat_prefer(sysctl_dccp_rx_ccid, rx.val, rx.len))
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index f85d901f4e3f..1b202f16531f 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -631,6 +631,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
631 goto drop_and_free; 631 goto drop_and_free;
632 632
633 inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT); 633 inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
634 reqsk_put(req);
634 return 0; 635 return 0;
635 636
636drop_and_free: 637drop_and_free:
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index c376af5bfdfb..1b58eac8aad3 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -380,6 +380,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
380 goto drop_and_free; 380 goto drop_and_free;
381 381
382 inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT); 382 inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
383 reqsk_put(req);
383 return 0; 384 return 0;
384 385
385drop_and_free: 386drop_and_free:
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 56e46090526b..c442051d5a55 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -509,21 +509,22 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
509 dst->cpu_dp->netdev = ethernet_dev; 509 dst->cpu_dp->netdev = ethernet_dev;
510 } 510 }
511 511
512 /* Initialize cpu_port_mask now for drv->setup()
513 * to have access to a correct value, just like what
514 * net/dsa/dsa.c::dsa_switch_setup_one does.
515 */
516 ds->cpu_port_mask |= BIT(index);
517
512 tag_protocol = ds->ops->get_tag_protocol(ds); 518 tag_protocol = ds->ops->get_tag_protocol(ds);
513 dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol); 519 dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol);
514 if (IS_ERR(dst->tag_ops)) { 520 if (IS_ERR(dst->tag_ops)) {
515 dev_warn(ds->dev, "No tagger for this switch\n"); 521 dev_warn(ds->dev, "No tagger for this switch\n");
522 ds->cpu_port_mask &= ~BIT(index);
516 return PTR_ERR(dst->tag_ops); 523 return PTR_ERR(dst->tag_ops);
517 } 524 }
518 525
519 dst->rcv = dst->tag_ops->rcv; 526 dst->rcv = dst->tag_ops->rcv;
520 527
521 /* Initialize cpu_port_mask now for drv->setup()
522 * to have access to a correct value, just like what
523 * net/dsa/dsa.c::dsa_switch_setup_one does.
524 */
525 ds->cpu_port_mask |= BIT(index);
526
527 return 0; 528 return 0;
528} 529}
529 530
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 222100103808..b8d18171cca3 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1452,7 +1452,7 @@ static int call_fib_nh_notifiers(struct fib_nh *fib_nh,
1452 return call_fib_notifiers(dev_net(fib_nh->nh_dev), event_type, 1452 return call_fib_notifiers(dev_net(fib_nh->nh_dev), event_type,
1453 &info.info); 1453 &info.info);
1454 case FIB_EVENT_NH_DEL: 1454 case FIB_EVENT_NH_DEL:
1455 if ((IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev) && 1455 if ((in_dev && IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev) &&
1456 fib_nh->nh_flags & RTNH_F_LINKDOWN) || 1456 fib_nh->nh_flags & RTNH_F_LINKDOWN) ||
1457 (fib_nh->nh_flags & RTNH_F_DEAD)) 1457 (fib_nh->nh_flags & RTNH_F_DEAD))
1458 return call_fib_notifiers(dev_net(fib_nh->nh_dev), 1458 return call_fib_notifiers(dev_net(fib_nh->nh_dev),
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 4e985dea1dd2..2f1588bf73da 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2202,9 +2202,10 @@ static bool tcp_small_queue_check(struct sock *sk, const struct sk_buff *skb,
2202static void tcp_chrono_set(struct tcp_sock *tp, const enum tcp_chrono new) 2202static void tcp_chrono_set(struct tcp_sock *tp, const enum tcp_chrono new)
2203{ 2203{
2204 const u32 now = tcp_jiffies32; 2204 const u32 now = tcp_jiffies32;
2205 enum tcp_chrono old = tp->chrono_type;
2205 2206
2206 if (tp->chrono_type > TCP_CHRONO_UNSPEC) 2207 if (old > TCP_CHRONO_UNSPEC)
2207 tp->chrono_stat[tp->chrono_type - 1] += now - tp->chrono_start; 2208 tp->chrono_stat[old - 1] += now - tp->chrono_start;
2208 tp->chrono_start = now; 2209 tp->chrono_start = now;
2209 tp->chrono_type = new; 2210 tp->chrono_type = new;
2210} 2211}
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index b057653ceca9..e6276fa3750b 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1163,34 +1163,32 @@ out:
1163 return ret; 1163 return ret;
1164} 1164}
1165 1165
1166#if BITS_PER_LONG == 64 1166#define UDP_SKB_IS_STATELESS 0x80000000
1167
1167static void udp_set_dev_scratch(struct sk_buff *skb) 1168static void udp_set_dev_scratch(struct sk_buff *skb)
1168{ 1169{
1169 struct udp_dev_scratch *scratch; 1170 struct udp_dev_scratch *scratch = udp_skb_scratch(skb);
1170 1171
1171 BUILD_BUG_ON(sizeof(struct udp_dev_scratch) > sizeof(long)); 1172 BUILD_BUG_ON(sizeof(struct udp_dev_scratch) > sizeof(long));
1172 scratch = (struct udp_dev_scratch *)&skb->dev_scratch; 1173 scratch->_tsize_state = skb->truesize;
1173 scratch->truesize = skb->truesize; 1174#if BITS_PER_LONG == 64
1174 scratch->len = skb->len; 1175 scratch->len = skb->len;
1175 scratch->csum_unnecessary = !!skb_csum_unnecessary(skb); 1176 scratch->csum_unnecessary = !!skb_csum_unnecessary(skb);
1176 scratch->is_linear = !skb_is_nonlinear(skb); 1177 scratch->is_linear = !skb_is_nonlinear(skb);
1178#endif
1179 if (likely(!skb->_skb_refdst))
1180 scratch->_tsize_state |= UDP_SKB_IS_STATELESS;
1177} 1181}
1178 1182
1179static int udp_skb_truesize(struct sk_buff *skb) 1183static int udp_skb_truesize(struct sk_buff *skb)
1180{ 1184{
1181 return ((struct udp_dev_scratch *)&skb->dev_scratch)->truesize; 1185 return udp_skb_scratch(skb)->_tsize_state & ~UDP_SKB_IS_STATELESS;
1182}
1183#else
1184static void udp_set_dev_scratch(struct sk_buff *skb)
1185{
1186 skb->dev_scratch = skb->truesize;
1187} 1186}
1188 1187
1189static int udp_skb_truesize(struct sk_buff *skb) 1188static bool udp_skb_has_head_state(struct sk_buff *skb)
1190{ 1189{
1191 return skb->dev_scratch; 1190 return !(udp_skb_scratch(skb)->_tsize_state & UDP_SKB_IS_STATELESS);
1192} 1191}
1193#endif
1194 1192
1195/* fully reclaim rmem/fwd memory allocated for skb */ 1193/* fully reclaim rmem/fwd memory allocated for skb */
1196static void udp_rmem_release(struct sock *sk, int size, int partial, 1194static void udp_rmem_release(struct sock *sk, int size, int partial,
@@ -1388,10 +1386,10 @@ void skb_consume_udp(struct sock *sk, struct sk_buff *skb, int len)
1388 unlock_sock_fast(sk, slow); 1386 unlock_sock_fast(sk, slow);
1389 } 1387 }
1390 1388
1391 /* we cleared the head states previously only if the skb lacks any IP 1389 /* In the more common cases we cleared the head states previously,
1392 * options, see __udp_queue_rcv_skb(). 1390 * see __udp_queue_rcv_skb().
1393 */ 1391 */
1394 if (unlikely(IPCB(skb)->opt.optlen > 0)) 1392 if (unlikely(udp_skb_has_head_state(skb)))
1395 skb_release_head_state(skb); 1393 skb_release_head_state(skb);
1396 consume_stateless_skb(skb); 1394 consume_stateless_skb(skb);
1397} 1395}
@@ -1784,11 +1782,11 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1784 sk_mark_napi_id_once(sk, skb); 1782 sk_mark_napi_id_once(sk, skb);
1785 } 1783 }
1786 1784
1787 /* At recvmsg() time we need skb->dst to process IP options-related 1785 /* At recvmsg() time we may access skb->dst or skb->sp depending on
1788 * cmsg, elsewhere can we clear all pending head states while they are 1786 * the IP options and the cmsg flags, elsewhere can we clear all
1789 * hot in the cache 1787 * pending head states while they are hot in the cache
1790 */ 1788 */
1791 if (likely(IPCB(skb)->opt.optlen == 0)) 1789 if (likely(IPCB(skb)->opt.optlen == 0 && !skb_sec_path(skb)))
1792 skb_release_head_state(skb); 1790 skb_release_head_state(skb);
1793 1791
1794 rc = __udp_enqueue_schedule_skb(sk, skb); 1792 rc = __udp_enqueue_schedule_skb(sk, skb);
@@ -1930,7 +1928,7 @@ drop:
1930/* For TCP sockets, sk_rx_dst is protected by socket lock 1928/* For TCP sockets, sk_rx_dst is protected by socket lock
1931 * For UDP, we use xchg() to guard against concurrent changes. 1929 * For UDP, we use xchg() to guard against concurrent changes.
1932 */ 1930 */
1933static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst) 1931void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
1934{ 1932{
1935 struct dst_entry *old; 1933 struct dst_entry *old;
1936 1934
@@ -1939,6 +1937,7 @@ static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
1939 dst_release(old); 1937 dst_release(old);
1940 } 1938 }
1941} 1939}
1940EXPORT_SYMBOL(udp_sk_rx_dst_set);
1942 1941
1943/* 1942/*
1944 * Multicasts and broadcasts go to each listener. 1943 * Multicasts and broadcasts go to each listener.
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 4996d734f1d2..3cec529c6113 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -756,6 +756,7 @@ static bool ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
756 if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr))) 756 if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))
757 goto drop; 757 goto drop;
758 758
759 IP6CB(skb)->flags |= IP6SKB_JUMBOGRAM;
759 return true; 760 return true;
760 761
761drop: 762drop:
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 1422d6c08377..162efba0d0cd 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -673,8 +673,6 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
673 *prevhdr = NEXTHDR_FRAGMENT; 673 *prevhdr = NEXTHDR_FRAGMENT;
674 tmp_hdr = kmemdup(skb_network_header(skb), hlen, GFP_ATOMIC); 674 tmp_hdr = kmemdup(skb_network_header(skb), hlen, GFP_ATOMIC);
675 if (!tmp_hdr) { 675 if (!tmp_hdr) {
676 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
677 IPSTATS_MIB_FRAGFAILS);
678 err = -ENOMEM; 676 err = -ENOMEM;
679 goto fail; 677 goto fail;
680 } 678 }
@@ -789,8 +787,6 @@ slow_path:
789 frag = alloc_skb(len + hlen + sizeof(struct frag_hdr) + 787 frag = alloc_skb(len + hlen + sizeof(struct frag_hdr) +
790 hroom + troom, GFP_ATOMIC); 788 hroom + troom, GFP_ATOMIC);
791 if (!frag) { 789 if (!frag) {
792 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
793 IPSTATS_MIB_FRAGFAILS);
794 err = -ENOMEM; 790 err = -ENOMEM;
795 goto fail; 791 goto fail;
796 } 792 }
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 4a3e65626e8b..578142b7ca3e 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -291,11 +291,7 @@ static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb,
291 struct udp_table *udptable) 291 struct udp_table *udptable)
292{ 292{
293 const struct ipv6hdr *iph = ipv6_hdr(skb); 293 const struct ipv6hdr *iph = ipv6_hdr(skb);
294 struct sock *sk;
295 294
296 sk = skb_steal_sock(skb);
297 if (unlikely(sk))
298 return sk;
299 return __udp6_lib_lookup(dev_net(skb->dev), &iph->saddr, sport, 295 return __udp6_lib_lookup(dev_net(skb->dev), &iph->saddr, sport,
300 &iph->daddr, dport, inet6_iif(skb), 296 &iph->daddr, dport, inet6_iif(skb),
301 udptable, skb); 297 udptable, skb);
@@ -332,6 +328,15 @@ struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be
332EXPORT_SYMBOL_GPL(udp6_lib_lookup); 328EXPORT_SYMBOL_GPL(udp6_lib_lookup);
333#endif 329#endif
334 330
331/* do not use the scratch area len for jumbogram: their length execeeds the
332 * scratch area space; note that the IP6CB flags is still in the first
333 * cacheline, so checking for jumbograms is cheap
334 */
335static int udp6_skb_len(struct sk_buff *skb)
336{
337 return unlikely(inet6_is_jumbogram(skb)) ? skb->len : udp_skb_len(skb);
338}
339
335/* 340/*
336 * This should be easy, if there is something there we 341 * This should be easy, if there is something there we
337 * return it, otherwise we block. 342 * return it, otherwise we block.
@@ -362,7 +367,7 @@ try_again:
362 if (!skb) 367 if (!skb)
363 return err; 368 return err;
364 369
365 ulen = udp_skb_len(skb); 370 ulen = udp6_skb_len(skb);
366 copied = len; 371 copied = len;
367 if (copied > ulen - off) 372 if (copied > ulen - off)
368 copied = ulen - off; 373 copied = ulen - off;
@@ -804,6 +809,24 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
804 if (udp6_csum_init(skb, uh, proto)) 809 if (udp6_csum_init(skb, uh, proto))
805 goto csum_error; 810 goto csum_error;
806 811
812 /* Check if the socket is already available, e.g. due to early demux */
813 sk = skb_steal_sock(skb);
814 if (sk) {
815 struct dst_entry *dst = skb_dst(skb);
816 int ret;
817
818 if (unlikely(sk->sk_rx_dst != dst))
819 udp_sk_rx_dst_set(sk, dst);
820
821 ret = udpv6_queue_rcv_skb(sk, skb);
822 sock_put(sk);
823
824 /* a return value > 0 means to resubmit the input */
825 if (ret > 0)
826 return ret;
827 return 0;
828 }
829
807 /* 830 /*
808 * Multicast receive code 831 * Multicast receive code
809 */ 832 */
@@ -812,11 +835,6 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
812 saddr, daddr, udptable, proto); 835 saddr, daddr, udptable, proto);
813 836
814 /* Unicast */ 837 /* Unicast */
815
816 /*
817 * check socket cache ... must talk to Alan about his plans
818 * for sock caches... i'll skip this for now.
819 */
820 sk = __udp6_lib_lookup_skb(skb, uh->source, uh->dest, udptable); 838 sk = __udp6_lib_lookup_skb(skb, uh->source, uh->dest, udptable);
821 if (sk) { 839 if (sk) {
822 int ret; 840 int ret;
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index e3c4c6c3fef7..03859e386b47 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -1310,8 +1310,8 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
1310 1310
1311 nla_for_each_nested(a, attr, rem) { 1311 nla_for_each_nested(a, attr, rem) {
1312 int type = nla_type(a); 1312 int type = nla_type(a);
1313 int maxlen = ovs_ct_attr_lens[type].maxlen; 1313 int maxlen;
1314 int minlen = ovs_ct_attr_lens[type].minlen; 1314 int minlen;
1315 1315
1316 if (type > OVS_CT_ATTR_MAX) { 1316 if (type > OVS_CT_ATTR_MAX) {
1317 OVS_NLERR(log, 1317 OVS_NLERR(log,
@@ -1319,6 +1319,9 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
1319 type, OVS_CT_ATTR_MAX); 1319 type, OVS_CT_ATTR_MAX);
1320 return -EINVAL; 1320 return -EINVAL;
1321 } 1321 }
1322
1323 maxlen = ovs_ct_attr_lens[type].maxlen;
1324 minlen = ovs_ct_attr_lens[type].minlen;
1322 if (nla_len(a) < minlen || nla_len(a) > maxlen) { 1325 if (nla_len(a) < minlen || nla_len(a) > maxlen) {
1323 OVS_NLERR(log, 1326 OVS_NLERR(log,
1324 "Conntrack attr type has unexpected length (type=%d, length=%d, expected=%d)", 1327 "Conntrack attr type has unexpected length (type=%d, length=%d, expected=%d)",
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 008bb34ee324..0615c2a950fa 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -4329,7 +4329,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
4329 register_prot_hook(sk); 4329 register_prot_hook(sk);
4330 } 4330 }
4331 spin_unlock(&po->bind_lock); 4331 spin_unlock(&po->bind_lock);
4332 if (closing && (po->tp_version > TPACKET_V2)) { 4332 if (pg_vec && (po->tp_version > TPACKET_V2)) {
4333 /* Because we don't support block-based V3 on tx-ring */ 4333 /* Because we don't support block-based V3 on tx-ring */
4334 if (!tx_ring) 4334 if (!tx_ring)
4335 prb_shutdown_retire_blk_timer(po, rb_queue); 4335 prb_shutdown_retire_blk_timer(po, rb_queue);
diff --git a/net/socket.c b/net/socket.c
index bf2122691fba..ad22df1ffbd1 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1916,7 +1916,7 @@ static int copy_msghdr_from_user(struct msghdr *kmsg,
1916 if (copy_from_user(&msg, umsg, sizeof(*umsg))) 1916 if (copy_from_user(&msg, umsg, sizeof(*umsg)))
1917 return -EFAULT; 1917 return -EFAULT;
1918 1918
1919 kmsg->msg_control = msg.msg_control; 1919 kmsg->msg_control = (void __force *)msg.msg_control;
1920 kmsg->msg_controllen = msg.msg_controllen; 1920 kmsg->msg_controllen = msg.msg_controllen;
1921 kmsg->msg_flags = msg.msg_flags; 1921 kmsg->msg_flags = msg.msg_flags;
1922 1922
@@ -1935,7 +1935,8 @@ static int copy_msghdr_from_user(struct msghdr *kmsg,
1935 1935
1936 if (msg.msg_name && kmsg->msg_namelen) { 1936 if (msg.msg_name && kmsg->msg_namelen) {
1937 if (!save_addr) { 1937 if (!save_addr) {
1938 err = move_addr_to_kernel(msg.msg_name, kmsg->msg_namelen, 1938 err = move_addr_to_kernel(msg.msg_name,
1939 kmsg->msg_namelen,
1939 kmsg->msg_name); 1940 kmsg->msg_name);
1940 if (err < 0) 1941 if (err < 0)
1941 return err; 1942 return err;
diff --git a/samples/bpf/tcbpf2_kern.c b/samples/bpf/tcbpf2_kern.c
index 9c823a609e75..270edcc149a1 100644
--- a/samples/bpf/tcbpf2_kern.c
+++ b/samples/bpf/tcbpf2_kern.c
@@ -147,9 +147,9 @@ int _geneve_set_tunnel(struct __sk_buff *skb)
147 __builtin_memset(&gopt, 0x0, sizeof(gopt)); 147 __builtin_memset(&gopt, 0x0, sizeof(gopt));
148 gopt.opt_class = 0x102; /* Open Virtual Networking (OVN) */ 148 gopt.opt_class = 0x102; /* Open Virtual Networking (OVN) */
149 gopt.type = 0x08; 149 gopt.type = 0x08;
150 gopt.r1 = 1; 150 gopt.r1 = 0;
151 gopt.r2 = 0; 151 gopt.r2 = 0;
152 gopt.r3 = 1; 152 gopt.r3 = 0;
153 gopt.length = 2; /* 4-byte multiple */ 153 gopt.length = 2; /* 4-byte multiple */
154 *(int *) &gopt.opt_data = 0xdeadbeef; 154 *(int *) &gopt.opt_data = 0xdeadbeef;
155 155
diff --git a/samples/bpf/test_tunnel_bpf.sh b/samples/bpf/test_tunnel_bpf.sh
index 1ff634f187b7..a70d2ea90313 100755
--- a/samples/bpf/test_tunnel_bpf.sh
+++ b/samples/bpf/test_tunnel_bpf.sh
@@ -149,6 +149,7 @@ function cleanup {
149 ip link del veth1 149 ip link del veth1
150 ip link del ipip11 150 ip link del ipip11
151 ip link del gretap11 151 ip link del gretap11
152 ip link del vxlan11
152 ip link del geneve11 153 ip link del geneve11
153 pkill tcpdump 154 pkill tcpdump
154 pkill cat 155 pkill cat
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 412a7c82995a..256f571f2ab5 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -314,7 +314,6 @@ int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len)
314 int err; 314 int err;
315 315
316 bzero(&attr, sizeof(attr)); 316 bzero(&attr, sizeof(attr));
317 bzero(info, *info_len);
318 attr.info.bpf_fd = prog_fd; 317 attr.info.bpf_fd = prog_fd;
319 attr.info.info_len = *info_len; 318 attr.info.info_len = *info_len;
320 attr.info.info = ptr_to_u64(info); 319 attr.info.info = ptr_to_u64(info);
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index 5855cd3d3d45..1f7dd35551b9 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -340,6 +340,7 @@ static void test_bpf_obj_id(void)
340 340
341 /* Check getting prog info */ 341 /* Check getting prog info */
342 info_len = sizeof(struct bpf_prog_info) * 2; 342 info_len = sizeof(struct bpf_prog_info) * 2;
343 bzero(&prog_infos[i], info_len);
343 prog_infos[i].jited_prog_insns = ptr_to_u64(jited_insns); 344 prog_infos[i].jited_prog_insns = ptr_to_u64(jited_insns);
344 prog_infos[i].jited_prog_len = sizeof(jited_insns); 345 prog_infos[i].jited_prog_len = sizeof(jited_insns);
345 prog_infos[i].xlated_prog_insns = ptr_to_u64(xlated_insns); 346 prog_infos[i].xlated_prog_insns = ptr_to_u64(xlated_insns);
@@ -369,6 +370,7 @@ static void test_bpf_obj_id(void)
369 370
370 /* Check getting map info */ 371 /* Check getting map info */
371 info_len = sizeof(struct bpf_map_info) * 2; 372 info_len = sizeof(struct bpf_map_info) * 2;
373 bzero(&map_infos[i], info_len);
372 err = bpf_obj_get_info_by_fd(map_fds[i], &map_infos[i], 374 err = bpf_obj_get_info_by_fd(map_fds[i], &map_infos[i],
373 &info_len); 375 &info_len);
374 if (CHECK(err || 376 if (CHECK(err ||
@@ -394,7 +396,7 @@ static void test_bpf_obj_id(void)
394 nr_id_found = 0; 396 nr_id_found = 0;
395 next_id = 0; 397 next_id = 0;
396 while (!bpf_prog_get_next_id(next_id, &next_id)) { 398 while (!bpf_prog_get_next_id(next_id, &next_id)) {
397 struct bpf_prog_info prog_info; 399 struct bpf_prog_info prog_info = {};
398 int prog_fd; 400 int prog_fd;
399 401
400 info_len = sizeof(prog_info); 402 info_len = sizeof(prog_info);
@@ -418,6 +420,8 @@ static void test_bpf_obj_id(void)
418 nr_id_found++; 420 nr_id_found++;
419 421
420 err = bpf_obj_get_info_by_fd(prog_fd, &prog_info, &info_len); 422 err = bpf_obj_get_info_by_fd(prog_fd, &prog_info, &info_len);
423 prog_infos[i].jited_prog_insns = 0;
424 prog_infos[i].xlated_prog_insns = 0;
421 CHECK(err || info_len != sizeof(struct bpf_prog_info) || 425 CHECK(err || info_len != sizeof(struct bpf_prog_info) ||
422 memcmp(&prog_info, &prog_infos[i], info_len), 426 memcmp(&prog_info, &prog_infos[i], info_len),
423 "get-prog-info(next_id->fd)", 427 "get-prog-info(next_id->fd)",
@@ -436,7 +440,7 @@ static void test_bpf_obj_id(void)
436 nr_id_found = 0; 440 nr_id_found = 0;
437 next_id = 0; 441 next_id = 0;
438 while (!bpf_map_get_next_id(next_id, &next_id)) { 442 while (!bpf_map_get_next_id(next_id, &next_id)) {
439 struct bpf_map_info map_info; 443 struct bpf_map_info map_info = {};
440 int map_fd; 444 int map_fd;
441 445
442 info_len = sizeof(map_info); 446 info_len = sizeof(map_info);
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index af7d173910f4..addea82f76c9 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -5980,6 +5980,34 @@ static struct bpf_test tests[] = {
5980 .result = REJECT, 5980 .result = REJECT,
5981 .result_unpriv = REJECT, 5981 .result_unpriv = REJECT,
5982 }, 5982 },
5983 {
5984 "subtraction bounds (map value)",
5985 .insns = {
5986 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
5987 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
5988 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
5989 BPF_LD_MAP_FD(BPF_REG_1, 0),
5990 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
5991 BPF_FUNC_map_lookup_elem),
5992 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9),
5993 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
5994 BPF_JMP_IMM(BPF_JGT, BPF_REG_1, 0xff, 7),
5995 BPF_LDX_MEM(BPF_B, BPF_REG_3, BPF_REG_0, 1),
5996 BPF_JMP_IMM(BPF_JGT, BPF_REG_3, 0xff, 5),
5997 BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_3),
5998 BPF_ALU64_IMM(BPF_RSH, BPF_REG_1, 56),
5999 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
6000 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_0, 0),
6001 BPF_EXIT_INSN(),
6002 BPF_MOV64_IMM(BPF_REG_0, 0),
6003 BPF_EXIT_INSN(),
6004 },
6005 .fixup_map1 = { 3 },
6006 .errstr_unpriv = "R0 pointer arithmetic prohibited",
6007 .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.",
6008 .result = REJECT,
6009 .result_unpriv = REJECT,
6010 },
5983}; 6011};
5984 6012
5985static int probe_filter_length(const struct bpf_insn *fp) 6013static int probe_filter_length(const struct bpf_insn *fp)