aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-02-15 11:00:11 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-02-15 11:00:11 -0500
commit6e7bd3b5494620265d39463b9289b7ba872f6df1 (patch)
tree3824614d3be8e208dcf9c1410485121ad6057809 /drivers
parent02d75040897f37e43cc6df9a7084ecdd20526f1a (diff)
parentf9bcc9f3ee4fbbe8f11dfec76745476f5780517e (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Fix MAC address setting in mac80211 pmsr code, from Johannes Berg. 2) Probe SFP modules after being attached, from Russell King. 3) Byte ordering bug in SMC rx_curs_confirmed code, from Ursula Braun. 4) Revert some r8169 changes that are causing regressions, from Heiner Kallweit. 5) Fix spurious connection timeouts in netfilter nat code, from Florian Westphal. 6) SKB leak in tipc, from Hoang Le. 7) Short packet checkum issue in mlx4, similar to a previous mlx5 change, from Saeed Mahameed. The issue is that whilst padding bytes are usually zero, it is not guarateed and the hardware doesn't take the padding bytes into consideration when generating the checksum. 8) Fix various races in cls_tcindex, from Cong Wang. 9) Need to set stream ext to NULL before freeing in SCTP code, from Xin Long. 10) Fix locking in phy_is_started, from Heiner Kallweit. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (54 commits) net: ethernet: freescale: set FEC ethtool regs version net: hns: Fix object reference leaks in hns_dsaf_roce_reset() mm: page_alloc: fix ref bias in page_frag_alloc() for 1-byte allocs net: phy: fix potential race in the phylib state machine net: phy: don't use locking in phy_is_started selftests: fix timestamping Makefile net: dsa: bcm_sf2: potential array overflow in bcm_sf2_sw_suspend() net: fix possible overflow in __sk_mem_raise_allocated() dsa: mv88e6xxx: Ensure all pending interrupts are handled prior to exit net: phy: fix interrupt handling in non-started states sctp: set stream ext to NULL after freeing it in sctp_stream_outq_migrate sctp: call gso_reset_checksum when computing checksum in sctp_gso_segment net/mlx5e: XDP, fix redirect resources availability check net/mlx5: Fix a compilation warning in events.c net/mlx5: No command allowed when command interface is not ready net/mlx5e: Fix NULL pointer derefernce in set channels error flow netfilter: nft_compat: use-after-free when deleting targets team: avoid complex list operations in team_nl_cmd_options_set() net_sched: fix two more memory leaks in cls_tcindex net_sched: fix a memory leak in cls_tcindex ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/Kconfig4
-rw-r--r--drivers/net/dsa/bcm_sf2.c2
-rw-r--r--drivers/net/dsa/mv88e6xxx/chip.c28
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_netdev.c10
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_netdev.h2
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c4
-rw-r--r--drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c22
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/cmd.c18
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h17
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/events.c17
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/health.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h1
-rw-r--r--drivers/net/ethernet/realtek/r8169.c21
-rw-r--r--drivers/net/ethernet/sfc/ef10.c2
-rw-r--r--drivers/net/phy/phy.c16
-rw-r--r--drivers/net/phy/phylink.c19
-rw-r--r--drivers/net/phy/sfp-bus.c2
-rw-r--r--drivers/net/phy/sfp.c30
-rw-r--r--drivers/net/phy/sfp.h2
-rw-r--r--drivers/net/team/team.c27
-rw-r--r--drivers/net/vxlan.c14
26 files changed, 188 insertions, 90 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index edb1c023a753..21bf8ac78380 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -197,9 +197,9 @@ config VXLAN
197 197
198config GENEVE 198config GENEVE
199 tristate "Generic Network Virtualization Encapsulation" 199 tristate "Generic Network Virtualization Encapsulation"
200 depends on INET && NET_UDP_TUNNEL 200 depends on INET
201 depends on IPV6 || !IPV6 201 depends on IPV6 || !IPV6
202 select NET_IP_TUNNEL 202 select NET_UDP_TUNNEL
203 select GRO_CELLS 203 select GRO_CELLS
204 ---help--- 204 ---help---
205 This allows one to create geneve virtual interfaces that provide 205 This allows one to create geneve virtual interfaces that provide
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 361fbde76654..17ec32b0a1cc 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -690,7 +690,7 @@ static int bcm_sf2_sw_suspend(struct dsa_switch *ds)
690 * port, the other ones have already been disabled during 690 * port, the other ones have already been disabled during
691 * bcm_sf2_sw_setup 691 * bcm_sf2_sw_setup
692 */ 692 */
693 for (port = 0; port < DSA_MAX_PORTS; port++) { 693 for (port = 0; port < ds->num_ports; port++) {
694 if (dsa_is_user_port(ds, port) || dsa_is_cpu_port(ds, port)) 694 if (dsa_is_user_port(ds, port) || dsa_is_cpu_port(ds, port))
695 bcm_sf2_port_disable(ds, port, NULL); 695 bcm_sf2_port_disable(ds, port, NULL);
696 } 696 }
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 8dca2c949e73..12fd7ce3f1ff 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -261,6 +261,7 @@ static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
261 unsigned int sub_irq; 261 unsigned int sub_irq;
262 unsigned int n; 262 unsigned int n;
263 u16 reg; 263 u16 reg;
264 u16 ctl1;
264 int err; 265 int err;
265 266
266 mutex_lock(&chip->reg_lock); 267 mutex_lock(&chip->reg_lock);
@@ -270,13 +271,28 @@ static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
270 if (err) 271 if (err)
271 goto out; 272 goto out;
272 273
273 for (n = 0; n < chip->g1_irq.nirqs; ++n) { 274 do {
274 if (reg & (1 << n)) { 275 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
275 sub_irq = irq_find_mapping(chip->g1_irq.domain, n); 276 if (reg & (1 << n)) {
276 handle_nested_irq(sub_irq); 277 sub_irq = irq_find_mapping(chip->g1_irq.domain,
277 ++nhandled; 278 n);
279 handle_nested_irq(sub_irq);
280 ++nhandled;
281 }
278 } 282 }
279 } 283
284 mutex_lock(&chip->reg_lock);
285 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
286 if (err)
287 goto unlock;
288 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
289unlock:
290 mutex_unlock(&chip->reg_lock);
291 if (err)
292 goto out;
293 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
294 } while (reg & ctl1);
295
280out: 296out:
281 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE); 297 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
282} 298}
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index a70bb1bb90e7..a6eacf2099c3 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -2663,11 +2663,6 @@ static int ena_restore_device(struct ena_adapter *adapter)
2663 goto err_device_destroy; 2663 goto err_device_destroy;
2664 } 2664 }
2665 2665
2666 clear_bit(ENA_FLAG_ONGOING_RESET, &adapter->flags);
2667 /* Make sure we don't have a race with AENQ Links state handler */
2668 if (test_bit(ENA_FLAG_LINK_UP, &adapter->flags))
2669 netif_carrier_on(adapter->netdev);
2670
2671 rc = ena_enable_msix_and_set_admin_interrupts(adapter, 2666 rc = ena_enable_msix_and_set_admin_interrupts(adapter,
2672 adapter->num_queues); 2667 adapter->num_queues);
2673 if (rc) { 2668 if (rc) {
@@ -2684,6 +2679,11 @@ static int ena_restore_device(struct ena_adapter *adapter)
2684 } 2679 }
2685 2680
2686 set_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags); 2681 set_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags);
2682
2683 clear_bit(ENA_FLAG_ONGOING_RESET, &adapter->flags);
2684 if (test_bit(ENA_FLAG_LINK_UP, &adapter->flags))
2685 netif_carrier_on(adapter->netdev);
2686
2687 mod_timer(&adapter->timer_service, round_jiffies(jiffies + HZ)); 2687 mod_timer(&adapter->timer_service, round_jiffies(jiffies + HZ));
2688 dev_err(&pdev->dev, 2688 dev_err(&pdev->dev,
2689 "Device reset completed successfully, Driver info: %s\n", 2689 "Device reset completed successfully, Driver info: %s\n",
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index dc8b6173d8d8..63870072cbbd 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -45,7 +45,7 @@
45 45
46#define DRV_MODULE_VER_MAJOR 2 46#define DRV_MODULE_VER_MAJOR 2
47#define DRV_MODULE_VER_MINOR 0 47#define DRV_MODULE_VER_MINOR 0
48#define DRV_MODULE_VER_SUBMINOR 2 48#define DRV_MODULE_VER_SUBMINOR 3
49 49
50#define DRV_MODULE_NAME "ena" 50#define DRV_MODULE_NAME "ena"
51#ifndef DRV_MODULE_VERSION 51#ifndef DRV_MODULE_VERSION
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 2370dc204202..697c2427f2b7 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2098,6 +2098,7 @@ static int fec_enet_get_regs_len(struct net_device *ndev)
2098#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ 2098#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
2099 defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) || \ 2099 defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) || \
2100 defined(CONFIG_ARM64) || defined(CONFIG_COMPILE_TEST) 2100 defined(CONFIG_ARM64) || defined(CONFIG_COMPILE_TEST)
2101static __u32 fec_enet_register_version = 2;
2101static u32 fec_enet_register_offset[] = { 2102static u32 fec_enet_register_offset[] = {
2102 FEC_IEVENT, FEC_IMASK, FEC_R_DES_ACTIVE_0, FEC_X_DES_ACTIVE_0, 2103 FEC_IEVENT, FEC_IMASK, FEC_R_DES_ACTIVE_0, FEC_X_DES_ACTIVE_0,
2103 FEC_ECNTRL, FEC_MII_DATA, FEC_MII_SPEED, FEC_MIB_CTRLSTAT, FEC_R_CNTRL, 2104 FEC_ECNTRL, FEC_MII_DATA, FEC_MII_SPEED, FEC_MIB_CTRLSTAT, FEC_R_CNTRL,
@@ -2128,6 +2129,7 @@ static u32 fec_enet_register_offset[] = {
2128 IEEE_R_FDXFC, IEEE_R_OCTETS_OK 2129 IEEE_R_FDXFC, IEEE_R_OCTETS_OK
2129}; 2130};
2130#else 2131#else
2132static __u32 fec_enet_register_version = 1;
2131static u32 fec_enet_register_offset[] = { 2133static u32 fec_enet_register_offset[] = {
2132 FEC_ECNTRL, FEC_IEVENT, FEC_IMASK, FEC_IVEC, FEC_R_DES_ACTIVE_0, 2134 FEC_ECNTRL, FEC_IEVENT, FEC_IMASK, FEC_IVEC, FEC_R_DES_ACTIVE_0,
2133 FEC_R_DES_ACTIVE_1, FEC_R_DES_ACTIVE_2, FEC_X_DES_ACTIVE_0, 2135 FEC_R_DES_ACTIVE_1, FEC_R_DES_ACTIVE_2, FEC_X_DES_ACTIVE_0,
@@ -2149,6 +2151,8 @@ static void fec_enet_get_regs(struct net_device *ndev,
2149 u32 *buf = (u32 *)regbuf; 2151 u32 *buf = (u32 *)regbuf;
2150 u32 i, off; 2152 u32 i, off;
2151 2153
2154 regs->version = fec_enet_register_version;
2155
2152 memset(buf, 0, regs->len); 2156 memset(buf, 0, regs->len);
2153 2157
2154 for (i = 0; i < ARRAY_SIZE(fec_enet_register_offset); i++) { 2158 for (i = 0; i < ARRAY_SIZE(fec_enet_register_offset); i++) {
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 3b9e74be5fbd..b8155f5e71b4 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -3081,6 +3081,7 @@ int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, bool dereset)
3081 dsaf_dev = dev_get_drvdata(&pdev->dev); 3081 dsaf_dev = dev_get_drvdata(&pdev->dev);
3082 if (!dsaf_dev) { 3082 if (!dsaf_dev) {
3083 dev_err(&pdev->dev, "dsaf_dev is NULL\n"); 3083 dev_err(&pdev->dev, "dsaf_dev is NULL\n");
3084 put_device(&pdev->dev);
3084 return -ENODEV; 3085 return -ENODEV;
3085 } 3086 }
3086 3087
@@ -3088,6 +3089,7 @@ int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, bool dereset)
3088 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { 3089 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) {
3089 dev_err(dsaf_dev->dev, "%s v1 chip doesn't support RoCE!\n", 3090 dev_err(dsaf_dev->dev, "%s v1 chip doesn't support RoCE!\n",
3090 dsaf_dev->ae_dev.name); 3091 dsaf_dev->ae_dev.name);
3092 put_device(&pdev->dev);
3091 return -ENODEV; 3093 return -ENODEV;
3092 } 3094 }
3093 3095
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 9a0881cb7f51..6c01314e87b0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -617,6 +617,8 @@ static int get_fixed_ipv6_csum(__wsum hw_checksum, struct sk_buff *skb,
617} 617}
618#endif 618#endif
619 619
620#define short_frame(size) ((size) <= ETH_ZLEN + ETH_FCS_LEN)
621
620/* We reach this function only after checking that any of 622/* We reach this function only after checking that any of
621 * the (IPv4 | IPv6) bits are set in cqe->status. 623 * the (IPv4 | IPv6) bits are set in cqe->status.
622 */ 624 */
@@ -624,9 +626,20 @@ static int check_csum(struct mlx4_cqe *cqe, struct sk_buff *skb, void *va,
624 netdev_features_t dev_features) 626 netdev_features_t dev_features)
625{ 627{
626 __wsum hw_checksum = 0; 628 __wsum hw_checksum = 0;
629 void *hdr;
630
631 /* CQE csum doesn't cover padding octets in short ethernet
632 * frames. And the pad field is appended prior to calculating
633 * and appending the FCS field.
634 *
635 * Detecting these padded frames requires to verify and parse
636 * IP headers, so we simply force all those small frames to skip
637 * checksum complete.
638 */
639 if (short_frame(skb->len))
640 return -EINVAL;
627 641
628 void *hdr = (u8 *)va + sizeof(struct ethhdr); 642 hdr = (u8 *)va + sizeof(struct ethhdr);
629
630 hw_checksum = csum_unfold((__force __sum16)cqe->checksum); 643 hw_checksum = csum_unfold((__force __sum16)cqe->checksum);
631 644
632 if (cqe->vlan_my_qpn & cpu_to_be32(MLX4_CQE_CVLAN_PRESENT_MASK) && 645 if (cqe->vlan_my_qpn & cpu_to_be32(MLX4_CQE_CVLAN_PRESENT_MASK) &&
@@ -819,6 +832,11 @@ xdp_drop_no_cnt:
819 skb_record_rx_queue(skb, cq_ring); 832 skb_record_rx_queue(skb, cq_ring);
820 833
821 if (likely(dev->features & NETIF_F_RXCSUM)) { 834 if (likely(dev->features & NETIF_F_RXCSUM)) {
835 /* TODO: For IP non TCP/UDP packets when csum complete is
836 * not an option (not supported or any other reason) we can
837 * actually check cqe IPOK status bit and report
838 * CHECKSUM_UNNECESSARY rather than CHECKSUM_NONE
839 */
822 if ((cqe->status & cpu_to_be16(MLX4_CQE_STATUS_TCP | 840 if ((cqe->status & cpu_to_be16(MLX4_CQE_STATUS_TCP |
823 MLX4_CQE_STATUS_UDP)) && 841 MLX4_CQE_STATUS_UDP)) &&
824 (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPOK)) && 842 (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPOK)) &&
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 3e0fa8a8077b..e267ff93e8a8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1583,6 +1583,24 @@ no_trig:
1583 spin_unlock_irqrestore(&dev->cmd.alloc_lock, flags); 1583 spin_unlock_irqrestore(&dev->cmd.alloc_lock, flags);
1584} 1584}
1585 1585
1586void mlx5_cmd_flush(struct mlx5_core_dev *dev)
1587{
1588 struct mlx5_cmd *cmd = &dev->cmd;
1589 int i;
1590
1591 for (i = 0; i < cmd->max_reg_cmds; i++)
1592 while (down_trylock(&cmd->sem))
1593 mlx5_cmd_trigger_completions(dev);
1594
1595 while (down_trylock(&cmd->pages_sem))
1596 mlx5_cmd_trigger_completions(dev);
1597
1598 /* Unlock cmdif */
1599 up(&cmd->pages_sem);
1600 for (i = 0; i < cmd->max_reg_cmds; i++)
1601 up(&cmd->sem);
1602}
1603
1586static int status_to_err(u8 status) 1604static int status_to_err(u8 status)
1587{ 1605{
1588 return status ? -1 : 0; /* TBD more meaningful codes */ 1606 return status ? -1 : 0; /* TBD more meaningful codes */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 8fa8fdd30b85..448a92561567 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -657,6 +657,7 @@ struct mlx5e_channel_stats {
657enum { 657enum {
658 MLX5E_STATE_OPENED, 658 MLX5E_STATE_OPENED,
659 MLX5E_STATE_DESTROYING, 659 MLX5E_STATE_DESTROYING,
660 MLX5E_STATE_XDP_TX_ENABLED,
660}; 661};
661 662
662struct mlx5e_rqt { 663struct mlx5e_rqt {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
index 3740177eed09..03b2a9f9c589 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
@@ -365,7 +365,8 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
365 int sq_num; 365 int sq_num;
366 int i; 366 int i;
367 367
368 if (unlikely(!test_bit(MLX5E_STATE_OPENED, &priv->state))) 368 /* this flag is sufficient, no need to test internal sq state */
369 if (unlikely(!mlx5e_xdp_tx_is_enabled(priv)))
369 return -ENETDOWN; 370 return -ENETDOWN;
370 371
371 if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK)) 372 if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
@@ -378,9 +379,6 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
378 379
379 sq = &priv->channels.c[sq_num]->xdpsq; 380 sq = &priv->channels.c[sq_num]->xdpsq;
380 381
381 if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
382 return -ENETDOWN;
383
384 for (i = 0; i < n; i++) { 382 for (i = 0; i < n; i++) {
385 struct xdp_frame *xdpf = frames[i]; 383 struct xdp_frame *xdpf = frames[i];
386 struct mlx5e_xdp_info xdpi; 384 struct mlx5e_xdp_info xdpi;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h
index 3a67cb3cd179..ee27a7c8cd87 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h
@@ -50,6 +50,23 @@ void mlx5e_xdp_rx_poll_complete(struct mlx5e_rq *rq);
50int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames, 50int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
51 u32 flags); 51 u32 flags);
52 52
53static inline void mlx5e_xdp_tx_enable(struct mlx5e_priv *priv)
54{
55 set_bit(MLX5E_STATE_XDP_TX_ENABLED, &priv->state);
56}
57
58static inline void mlx5e_xdp_tx_disable(struct mlx5e_priv *priv)
59{
60 clear_bit(MLX5E_STATE_XDP_TX_ENABLED, &priv->state);
61 /* let other device's napi(s) see our new state */
62 synchronize_rcu();
63}
64
65static inline bool mlx5e_xdp_tx_is_enabled(struct mlx5e_priv *priv)
66{
67 return test_bit(MLX5E_STATE_XDP_TX_ENABLED, &priv->state);
68}
69
53static inline void mlx5e_xmit_xdp_doorbell(struct mlx5e_xdpsq *sq) 70static inline void mlx5e_xmit_xdp_doorbell(struct mlx5e_xdpsq *sq)
54{ 71{
55 if (sq->doorbell_cseg) { 72 if (sq->doorbell_cseg) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 3bbccead2f63..47233b9a4f81 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -354,9 +354,6 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
354 354
355 new_channels.params = priv->channels.params; 355 new_channels.params = priv->channels.params;
356 new_channels.params.num_channels = count; 356 new_channels.params.num_channels = count;
357 if (!netif_is_rxfh_configured(priv->netdev))
358 mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
359 MLX5E_INDIR_RQT_SIZE, count);
360 357
361 if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) { 358 if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
362 priv->channels.params = new_channels.params; 359 priv->channels.params = new_channels.params;
@@ -372,6 +369,10 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
372 if (arfs_enabled) 369 if (arfs_enabled)
373 mlx5e_arfs_disable(priv); 370 mlx5e_arfs_disable(priv);
374 371
372 if (!netif_is_rxfh_configured(priv->netdev))
373 mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
374 MLX5E_INDIR_RQT_SIZE, count);
375
375 /* Switch to new channels, set new parameters and close old ones */ 376 /* Switch to new channels, set new parameters and close old ones */
376 mlx5e_switch_priv_channels(priv, &new_channels, NULL); 377 mlx5e_switch_priv_channels(priv, &new_channels, NULL);
377 378
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 01819e5c9975..93e50ccd44c3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2938,6 +2938,7 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
2938 2938
2939 mlx5e_build_tx2sq_maps(priv); 2939 mlx5e_build_tx2sq_maps(priv);
2940 mlx5e_activate_channels(&priv->channels); 2940 mlx5e_activate_channels(&priv->channels);
2941 mlx5e_xdp_tx_enable(priv);
2941 netif_tx_start_all_queues(priv->netdev); 2942 netif_tx_start_all_queues(priv->netdev);
2942 2943
2943 if (mlx5e_is_vport_rep(priv)) 2944 if (mlx5e_is_vport_rep(priv))
@@ -2959,6 +2960,7 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
2959 */ 2960 */
2960 netif_tx_stop_all_queues(priv->netdev); 2961 netif_tx_stop_all_queues(priv->netdev);
2961 netif_tx_disable(priv->netdev); 2962 netif_tx_disable(priv->netdev);
2963 mlx5e_xdp_tx_disable(priv);
2962 mlx5e_deactivate_channels(&priv->channels); 2964 mlx5e_deactivate_channels(&priv->channels);
2963} 2965}
2964 2966
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/events.c b/drivers/net/ethernet/mellanox/mlx5/core/events.c
index fbc42b7252a9..503035469d2d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/events.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/events.c
@@ -211,11 +211,10 @@ static int port_module(struct notifier_block *nb, unsigned long type, void *data
211 enum port_module_event_status_type module_status; 211 enum port_module_event_status_type module_status;
212 enum port_module_event_error_type error_type; 212 enum port_module_event_error_type error_type;
213 struct mlx5_eqe_port_module *module_event_eqe; 213 struct mlx5_eqe_port_module *module_event_eqe;
214 const char *status_str, *error_str; 214 const char *status_str;
215 u8 module_num; 215 u8 module_num;
216 216
217 module_event_eqe = &eqe->data.port_module; 217 module_event_eqe = &eqe->data.port_module;
218 module_num = module_event_eqe->module;
219 module_status = module_event_eqe->module_status & 218 module_status = module_event_eqe->module_status &
220 PORT_MODULE_EVENT_MODULE_STATUS_MASK; 219 PORT_MODULE_EVENT_MODULE_STATUS_MASK;
221 error_type = module_event_eqe->error_type & 220 error_type = module_event_eqe->error_type &
@@ -223,25 +222,27 @@ static int port_module(struct notifier_block *nb, unsigned long type, void *data
223 222
224 if (module_status < MLX5_MODULE_STATUS_NUM) 223 if (module_status < MLX5_MODULE_STATUS_NUM)
225 events->pme_stats.status_counters[module_status]++; 224 events->pme_stats.status_counters[module_status]++;
226 status_str = mlx5_pme_status_to_string(module_status);
227 225
228 if (module_status == MLX5_MODULE_STATUS_ERROR) { 226 if (module_status == MLX5_MODULE_STATUS_ERROR)
229 if (error_type < MLX5_MODULE_EVENT_ERROR_NUM) 227 if (error_type < MLX5_MODULE_EVENT_ERROR_NUM)
230 events->pme_stats.error_counters[error_type]++; 228 events->pme_stats.error_counters[error_type]++;
231 error_str = mlx5_pme_error_to_string(error_type);
232 }
233 229
234 if (!printk_ratelimit()) 230 if (!printk_ratelimit())
235 return NOTIFY_OK; 231 return NOTIFY_OK;
236 232
237 if (module_status == MLX5_MODULE_STATUS_ERROR) 233 module_num = module_event_eqe->module;
234 status_str = mlx5_pme_status_to_string(module_status);
235 if (module_status == MLX5_MODULE_STATUS_ERROR) {
236 const char *error_str = mlx5_pme_error_to_string(error_type);
237
238 mlx5_core_err(events->dev, 238 mlx5_core_err(events->dev,
239 "Port module event[error]: module %u, %s, %s\n", 239 "Port module event[error]: module %u, %s, %s\n",
240 module_num, status_str, error_str); 240 module_num, status_str, error_str);
241 else 241 } else {
242 mlx5_core_info(events->dev, 242 mlx5_core_info(events->dev,
243 "Port module event: module %u, %s\n", 243 "Port module event: module %u, %s\n",
244 module_num, status_str); 244 module_num, status_str);
245 }
245 246
246 return NOTIFY_OK; 247 return NOTIFY_OK;
247} 248}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 196c07383082..cb9fa3430c53 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -103,7 +103,7 @@ void mlx5_enter_error_state(struct mlx5_core_dev *dev, bool force)
103 mlx5_core_err(dev, "start\n"); 103 mlx5_core_err(dev, "start\n");
104 if (pci_channel_offline(dev->pdev) || in_fatal(dev) || force) { 104 if (pci_channel_offline(dev->pdev) || in_fatal(dev) || force) {
105 dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR; 105 dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR;
106 mlx5_cmd_trigger_completions(dev); 106 mlx5_cmd_flush(dev);
107 } 107 }
108 108
109 mlx5_notifier_call_chain(dev->priv.events, MLX5_DEV_EVENT_SYS_ERROR, (void *)1); 109 mlx5_notifier_call_chain(dev->priv.events, MLX5_DEV_EVENT_SYS_ERROR, (void *)1);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index 5300b0b6d836..4fdac020b795 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -126,6 +126,7 @@ u64 mlx5_read_internal_timer(struct mlx5_core_dev *dev,
126 struct ptp_system_timestamp *sts); 126 struct ptp_system_timestamp *sts);
127 127
128void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev); 128void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev);
129void mlx5_cmd_flush(struct mlx5_core_dev *dev);
129int mlx5_cq_debugfs_init(struct mlx5_core_dev *dev); 130int mlx5_cq_debugfs_init(struct mlx5_core_dev *dev);
130void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev); 131void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev);
131 132
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index abb94c543aa2..6e36b88ca7c9 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1286,11 +1286,13 @@ static u16 rtl_get_events(struct rtl8169_private *tp)
1286static void rtl_ack_events(struct rtl8169_private *tp, u16 bits) 1286static void rtl_ack_events(struct rtl8169_private *tp, u16 bits)
1287{ 1287{
1288 RTL_W16(tp, IntrStatus, bits); 1288 RTL_W16(tp, IntrStatus, bits);
1289 mmiowb();
1289} 1290}
1290 1291
1291static void rtl_irq_disable(struct rtl8169_private *tp) 1292static void rtl_irq_disable(struct rtl8169_private *tp)
1292{ 1293{
1293 RTL_W16(tp, IntrMask, 0); 1294 RTL_W16(tp, IntrMask, 0);
1295 mmiowb();
1294} 1296}
1295 1297
1296#define RTL_EVENT_NAPI_RX (RxOK | RxErr) 1298#define RTL_EVENT_NAPI_RX (RxOK | RxErr)
@@ -6072,7 +6074,6 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
6072 struct device *d = tp_to_dev(tp); 6074 struct device *d = tp_to_dev(tp);
6073 dma_addr_t mapping; 6075 dma_addr_t mapping;
6074 u32 opts[2], len; 6076 u32 opts[2], len;
6075 bool stop_queue;
6076 int frags; 6077 int frags;
6077 6078
6078 if (unlikely(!rtl_tx_slots_avail(tp, skb_shinfo(skb)->nr_frags))) { 6079 if (unlikely(!rtl_tx_slots_avail(tp, skb_shinfo(skb)->nr_frags))) {
@@ -6114,6 +6115,8 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
6114 6115
6115 txd->opts2 = cpu_to_le32(opts[1]); 6116 txd->opts2 = cpu_to_le32(opts[1]);
6116 6117
6118 netdev_sent_queue(dev, skb->len);
6119
6117 skb_tx_timestamp(skb); 6120 skb_tx_timestamp(skb);
6118 6121
6119 /* Force memory writes to complete before releasing descriptor */ 6122 /* Force memory writes to complete before releasing descriptor */
@@ -6126,14 +6129,16 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
6126 6129
6127 tp->cur_tx += frags + 1; 6130 tp->cur_tx += frags + 1;
6128 6131
6129 stop_queue = !rtl_tx_slots_avail(tp, MAX_SKB_FRAGS); 6132 RTL_W8(tp, TxPoll, NPQ);
6130 if (unlikely(stop_queue))
6131 netif_stop_queue(dev);
6132 6133
6133 if (__netdev_sent_queue(dev, skb->len, skb->xmit_more)) 6134 mmiowb();
6134 RTL_W8(tp, TxPoll, NPQ);
6135 6135
6136 if (unlikely(stop_queue)) { 6136 if (!rtl_tx_slots_avail(tp, MAX_SKB_FRAGS)) {
6137 /* Avoid wrongly optimistic queue wake-up: rtl_tx thread must
6138 * not miss a ring update when it notices a stopped queue.
6139 */
6140 smp_wmb();
6141 netif_stop_queue(dev);
6137 /* Sync with rtl_tx: 6142 /* Sync with rtl_tx:
6138 * - publish queue status and cur_tx ring index (write barrier) 6143 * - publish queue status and cur_tx ring index (write barrier)
6139 * - refresh dirty_tx ring index (read barrier). 6144 * - refresh dirty_tx ring index (read barrier).
@@ -6483,7 +6488,9 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
6483 6488
6484 if (work_done < budget) { 6489 if (work_done < budget) {
6485 napi_complete_done(napi, work_done); 6490 napi_complete_done(napi, work_done);
6491
6486 rtl_irq_enable(tp); 6492 rtl_irq_enable(tp);
6493 mmiowb();
6487 } 6494 }
6488 6495
6489 return work_done; 6496 return work_done;
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 2f2bda68d861..c08034154a9a 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -6115,7 +6115,7 @@ static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
6115static int efx_ef10_mtd_probe(struct efx_nic *efx) 6115static int efx_ef10_mtd_probe(struct efx_nic *efx)
6116{ 6116{
6117 MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_PARTITIONS_OUT_LENMAX); 6117 MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_PARTITIONS_OUT_LENMAX);
6118 DECLARE_BITMAP(found, EF10_NVRAM_PARTITION_COUNT); 6118 DECLARE_BITMAP(found, EF10_NVRAM_PARTITION_COUNT) = { 0 };
6119 struct efx_mcdi_mtd_partition *parts; 6119 struct efx_mcdi_mtd_partition *parts;
6120 size_t outlen, n_parts_total, i, n_parts; 6120 size_t outlen, n_parts_total, i, n_parts;
6121 unsigned int type; 6121 unsigned int type;
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 189cd2048c3a..c5675df5fc6f 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -553,7 +553,7 @@ int phy_start_aneg(struct phy_device *phydev)
553 if (err < 0) 553 if (err < 0)
554 goto out_unlock; 554 goto out_unlock;
555 555
556 if (__phy_is_started(phydev)) { 556 if (phy_is_started(phydev)) {
557 if (phydev->autoneg == AUTONEG_ENABLE) { 557 if (phydev->autoneg == AUTONEG_ENABLE) {
558 err = phy_check_link_status(phydev); 558 err = phy_check_link_status(phydev);
559 } else { 559 } else {
@@ -709,7 +709,7 @@ void phy_stop_machine(struct phy_device *phydev)
709 cancel_delayed_work_sync(&phydev->state_queue); 709 cancel_delayed_work_sync(&phydev->state_queue);
710 710
711 mutex_lock(&phydev->lock); 711 mutex_lock(&phydev->lock);
712 if (__phy_is_started(phydev)) 712 if (phy_is_started(phydev))
713 phydev->state = PHY_UP; 713 phydev->state = PHY_UP;
714 mutex_unlock(&phydev->lock); 714 mutex_unlock(&phydev->lock);
715} 715}
@@ -762,9 +762,6 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
762{ 762{
763 struct phy_device *phydev = phy_dat; 763 struct phy_device *phydev = phy_dat;
764 764
765 if (!phy_is_started(phydev))
766 return IRQ_NONE; /* It can't be ours. */
767
768 if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt(phydev)) 765 if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt(phydev))
769 return IRQ_NONE; 766 return IRQ_NONE;
770 767
@@ -842,15 +839,14 @@ EXPORT_SYMBOL(phy_stop_interrupts);
842 */ 839 */
843void phy_stop(struct phy_device *phydev) 840void phy_stop(struct phy_device *phydev)
844{ 841{
845 mutex_lock(&phydev->lock); 842 if (!phy_is_started(phydev)) {
846
847 if (!__phy_is_started(phydev)) {
848 WARN(1, "called from state %s\n", 843 WARN(1, "called from state %s\n",
849 phy_state_to_str(phydev->state)); 844 phy_state_to_str(phydev->state));
850 mutex_unlock(&phydev->lock);
851 return; 845 return;
852 } 846 }
853 847
848 mutex_lock(&phydev->lock);
849
854 if (phy_interrupt_is_valid(phydev)) 850 if (phy_interrupt_is_valid(phydev))
855 phy_disable_interrupts(phydev); 851 phy_disable_interrupts(phydev);
856 852
@@ -989,8 +985,10 @@ void phy_state_machine(struct work_struct *work)
989 * state machine would be pointless and possibly error prone when 985 * state machine would be pointless and possibly error prone when
990 * called from phy_disconnect() synchronously. 986 * called from phy_disconnect() synchronously.
991 */ 987 */
988 mutex_lock(&phydev->lock);
992 if (phy_polling_mode(phydev) && phy_is_started(phydev)) 989 if (phy_polling_mode(phydev) && phy_is_started(phydev))
993 phy_queue_state_machine(phydev, PHY_STATE_TIME); 990 phy_queue_state_machine(phydev, PHY_STATE_TIME);
991 mutex_unlock(&phydev->lock);
994} 992}
995 993
996/** 994/**
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index e7becc7379d7..938803237d7f 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -474,6 +474,17 @@ static void phylink_run_resolve(struct phylink *pl)
474 queue_work(system_power_efficient_wq, &pl->resolve); 474 queue_work(system_power_efficient_wq, &pl->resolve);
475} 475}
476 476
477static void phylink_run_resolve_and_disable(struct phylink *pl, int bit)
478{
479 unsigned long state = pl->phylink_disable_state;
480
481 set_bit(bit, &pl->phylink_disable_state);
482 if (state == 0) {
483 queue_work(system_power_efficient_wq, &pl->resolve);
484 flush_work(&pl->resolve);
485 }
486}
487
477static void phylink_fixed_poll(struct timer_list *t) 488static void phylink_fixed_poll(struct timer_list *t)
478{ 489{
479 struct phylink *pl = container_of(t, struct phylink, link_poll); 490 struct phylink *pl = container_of(t, struct phylink, link_poll);
@@ -924,9 +935,7 @@ void phylink_stop(struct phylink *pl)
924 if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio)) 935 if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio))
925 del_timer_sync(&pl->link_poll); 936 del_timer_sync(&pl->link_poll);
926 937
927 set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); 938 phylink_run_resolve_and_disable(pl, PHYLINK_DISABLE_STOPPED);
928 queue_work(system_power_efficient_wq, &pl->resolve);
929 flush_work(&pl->resolve);
930} 939}
931EXPORT_SYMBOL_GPL(phylink_stop); 940EXPORT_SYMBOL_GPL(phylink_stop);
932 941
@@ -1632,9 +1641,7 @@ static void phylink_sfp_link_down(void *upstream)
1632 1641
1633 ASSERT_RTNL(); 1642 ASSERT_RTNL();
1634 1643
1635 set_bit(PHYLINK_DISABLE_LINK, &pl->phylink_disable_state); 1644 phylink_run_resolve_and_disable(pl, PHYLINK_DISABLE_LINK);
1636 queue_work(system_power_efficient_wq, &pl->resolve);
1637 flush_work(&pl->resolve);
1638} 1645}
1639 1646
1640static void phylink_sfp_link_up(void *upstream) 1647static void phylink_sfp_link_up(void *upstream)
diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
index ad9db652874d..fef701bfad62 100644
--- a/drivers/net/phy/sfp-bus.c
+++ b/drivers/net/phy/sfp-bus.c
@@ -347,6 +347,7 @@ static int sfp_register_bus(struct sfp_bus *bus)
347 return ret; 347 return ret;
348 } 348 }
349 } 349 }
350 bus->socket_ops->attach(bus->sfp);
350 if (bus->started) 351 if (bus->started)
351 bus->socket_ops->start(bus->sfp); 352 bus->socket_ops->start(bus->sfp);
352 bus->netdev->sfp_bus = bus; 353 bus->netdev->sfp_bus = bus;
@@ -362,6 +363,7 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
362 if (bus->registered) { 363 if (bus->registered) {
363 if (bus->started) 364 if (bus->started)
364 bus->socket_ops->stop(bus->sfp); 365 bus->socket_ops->stop(bus->sfp);
366 bus->socket_ops->detach(bus->sfp);
365 if (bus->phydev && ops && ops->disconnect_phy) 367 if (bus->phydev && ops && ops->disconnect_phy)
366 ops->disconnect_phy(bus->upstream); 368 ops->disconnect_phy(bus->upstream);
367 } 369 }
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index fd8bb998ae52..68c8fbf099f8 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -184,6 +184,7 @@ struct sfp {
184 184
185 struct gpio_desc *gpio[GPIO_MAX]; 185 struct gpio_desc *gpio[GPIO_MAX];
186 186
187 bool attached;
187 unsigned int state; 188 unsigned int state;
188 struct delayed_work poll; 189 struct delayed_work poll;
189 struct delayed_work timeout; 190 struct delayed_work timeout;
@@ -1475,7 +1476,7 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
1475 */ 1476 */
1476 switch (sfp->sm_mod_state) { 1477 switch (sfp->sm_mod_state) {
1477 default: 1478 default:
1478 if (event == SFP_E_INSERT) { 1479 if (event == SFP_E_INSERT && sfp->attached) {
1479 sfp_module_tx_disable(sfp); 1480 sfp_module_tx_disable(sfp);
1480 sfp_sm_ins_next(sfp, SFP_MOD_PROBE, T_PROBE_INIT); 1481 sfp_sm_ins_next(sfp, SFP_MOD_PROBE, T_PROBE_INIT);
1481 } 1482 }
@@ -1607,6 +1608,19 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
1607 mutex_unlock(&sfp->sm_mutex); 1608 mutex_unlock(&sfp->sm_mutex);
1608} 1609}
1609 1610
1611static void sfp_attach(struct sfp *sfp)
1612{
1613 sfp->attached = true;
1614 if (sfp->state & SFP_F_PRESENT)
1615 sfp_sm_event(sfp, SFP_E_INSERT);
1616}
1617
1618static void sfp_detach(struct sfp *sfp)
1619{
1620 sfp->attached = false;
1621 sfp_sm_event(sfp, SFP_E_REMOVE);
1622}
1623
1610static void sfp_start(struct sfp *sfp) 1624static void sfp_start(struct sfp *sfp)
1611{ 1625{
1612 sfp_sm_event(sfp, SFP_E_DEV_UP); 1626 sfp_sm_event(sfp, SFP_E_DEV_UP);
@@ -1667,6 +1681,8 @@ static int sfp_module_eeprom(struct sfp *sfp, struct ethtool_eeprom *ee,
1667} 1681}
1668 1682
1669static const struct sfp_socket_ops sfp_module_ops = { 1683static const struct sfp_socket_ops sfp_module_ops = {
1684 .attach = sfp_attach,
1685 .detach = sfp_detach,
1670 .start = sfp_start, 1686 .start = sfp_start,
1671 .stop = sfp_stop, 1687 .stop = sfp_stop,
1672 .module_info = sfp_module_info, 1688 .module_info = sfp_module_info,
@@ -1834,10 +1850,6 @@ static int sfp_probe(struct platform_device *pdev)
1834 dev_info(sfp->dev, "Host maximum power %u.%uW\n", 1850 dev_info(sfp->dev, "Host maximum power %u.%uW\n",
1835 sfp->max_power_mW / 1000, (sfp->max_power_mW / 100) % 10); 1851 sfp->max_power_mW / 1000, (sfp->max_power_mW / 100) % 10);
1836 1852
1837 sfp->sfp_bus = sfp_register_socket(sfp->dev, sfp, &sfp_module_ops);
1838 if (!sfp->sfp_bus)
1839 return -ENOMEM;
1840
1841 /* Get the initial state, and always signal TX disable, 1853 /* Get the initial state, and always signal TX disable,
1842 * since the network interface will not be up. 1854 * since the network interface will not be up.
1843 */ 1855 */
@@ -1848,10 +1860,6 @@ static int sfp_probe(struct platform_device *pdev)
1848 sfp->state |= SFP_F_RATE_SELECT; 1860 sfp->state |= SFP_F_RATE_SELECT;
1849 sfp_set_state(sfp, sfp->state); 1861 sfp_set_state(sfp, sfp->state);
1850 sfp_module_tx_disable(sfp); 1862 sfp_module_tx_disable(sfp);
1851 rtnl_lock();
1852 if (sfp->state & SFP_F_PRESENT)
1853 sfp_sm_event(sfp, SFP_E_INSERT);
1854 rtnl_unlock();
1855 1863
1856 for (i = 0; i < GPIO_MAX; i++) { 1864 for (i = 0; i < GPIO_MAX; i++) {
1857 if (gpio_flags[i] != GPIOD_IN || !sfp->gpio[i]) 1865 if (gpio_flags[i] != GPIOD_IN || !sfp->gpio[i])
@@ -1884,6 +1892,10 @@ static int sfp_probe(struct platform_device *pdev)
1884 dev_warn(sfp->dev, 1892 dev_warn(sfp->dev,
1885 "No tx_disable pin: SFP modules will always be emitting.\n"); 1893 "No tx_disable pin: SFP modules will always be emitting.\n");
1886 1894
1895 sfp->sfp_bus = sfp_register_socket(sfp->dev, sfp, &sfp_module_ops);
1896 if (!sfp->sfp_bus)
1897 return -ENOMEM;
1898
1887 return 0; 1899 return 0;
1888} 1900}
1889 1901
diff --git a/drivers/net/phy/sfp.h b/drivers/net/phy/sfp.h
index 31b0acf337e2..64f54b0bbd8c 100644
--- a/drivers/net/phy/sfp.h
+++ b/drivers/net/phy/sfp.h
@@ -7,6 +7,8 @@
7struct sfp; 7struct sfp;
8 8
9struct sfp_socket_ops { 9struct sfp_socket_ops {
10 void (*attach)(struct sfp *sfp);
11 void (*detach)(struct sfp *sfp);
10 void (*start)(struct sfp *sfp); 12 void (*start)(struct sfp *sfp);
11 void (*stop)(struct sfp *sfp); 13 void (*stop)(struct sfp *sfp);
12 int (*module_info)(struct sfp *sfp, struct ethtool_modinfo *modinfo); 14 int (*module_info)(struct sfp *sfp, struct ethtool_modinfo *modinfo);
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index afd9d25d1992..958f1cf67282 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -256,17 +256,6 @@ static void __team_option_inst_mark_removed_port(struct team *team,
256 } 256 }
257} 257}
258 258
259static bool __team_option_inst_tmp_find(const struct list_head *opts,
260 const struct team_option_inst *needle)
261{
262 struct team_option_inst *opt_inst;
263
264 list_for_each_entry(opt_inst, opts, tmp_list)
265 if (opt_inst == needle)
266 return true;
267 return false;
268}
269
270static int __team_options_register(struct team *team, 259static int __team_options_register(struct team *team,
271 const struct team_option *option, 260 const struct team_option *option,
272 size_t option_count) 261 size_t option_count)
@@ -2460,7 +2449,6 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
2460 int err = 0; 2449 int err = 0;
2461 int i; 2450 int i;
2462 struct nlattr *nl_option; 2451 struct nlattr *nl_option;
2463 LIST_HEAD(opt_inst_list);
2464 2452
2465 rtnl_lock(); 2453 rtnl_lock();
2466 2454
@@ -2480,6 +2468,7 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
2480 struct nlattr *opt_attrs[TEAM_ATTR_OPTION_MAX + 1]; 2468 struct nlattr *opt_attrs[TEAM_ATTR_OPTION_MAX + 1];
2481 struct nlattr *attr; 2469 struct nlattr *attr;
2482 struct nlattr *attr_data; 2470 struct nlattr *attr_data;
2471 LIST_HEAD(opt_inst_list);
2483 enum team_option_type opt_type; 2472 enum team_option_type opt_type;
2484 int opt_port_ifindex = 0; /* != 0 for per-port options */ 2473 int opt_port_ifindex = 0; /* != 0 for per-port options */
2485 u32 opt_array_index = 0; 2474 u32 opt_array_index = 0;
@@ -2584,23 +2573,17 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
2584 if (err) 2573 if (err)
2585 goto team_put; 2574 goto team_put;
2586 opt_inst->changed = true; 2575 opt_inst->changed = true;
2587
2588 /* dumb/evil user-space can send us duplicate opt,
2589 * keep only the last one
2590 */
2591 if (__team_option_inst_tmp_find(&opt_inst_list,
2592 opt_inst))
2593 continue;
2594
2595 list_add(&opt_inst->tmp_list, &opt_inst_list); 2576 list_add(&opt_inst->tmp_list, &opt_inst_list);
2596 } 2577 }
2597 if (!opt_found) { 2578 if (!opt_found) {
2598 err = -ENOENT; 2579 err = -ENOENT;
2599 goto team_put; 2580 goto team_put;
2600 } 2581 }
2601 }
2602 2582
2603 err = team_nl_send_event_options_get(team, &opt_inst_list); 2583 err = team_nl_send_event_options_get(team, &opt_inst_list);
2584 if (err)
2585 break;
2586 }
2604 2587
2605team_put: 2588team_put:
2606 team_nl_team_put(team); 2589 team_nl_team_put(team);
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 5209ee9aac47..2aae11feff0c 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2219,7 +2219,7 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
2219 struct pcpu_sw_netstats *tx_stats, *rx_stats; 2219 struct pcpu_sw_netstats *tx_stats, *rx_stats;
2220 union vxlan_addr loopback; 2220 union vxlan_addr loopback;
2221 union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip; 2221 union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip;
2222 struct net_device *dev = skb->dev; 2222 struct net_device *dev;
2223 int len = skb->len; 2223 int len = skb->len;
2224 2224
2225 tx_stats = this_cpu_ptr(src_vxlan->dev->tstats); 2225 tx_stats = this_cpu_ptr(src_vxlan->dev->tstats);
@@ -2239,9 +2239,15 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
2239#endif 2239#endif
2240 } 2240 }
2241 2241
2242 rcu_read_lock();
2243 dev = skb->dev;
2244 if (unlikely(!(dev->flags & IFF_UP))) {
2245 kfree_skb(skb);
2246 goto drop;
2247 }
2248
2242 if (dst_vxlan->cfg.flags & VXLAN_F_LEARN) 2249 if (dst_vxlan->cfg.flags & VXLAN_F_LEARN)
2243 vxlan_snoop(skb->dev, &loopback, eth_hdr(skb)->h_source, 0, 2250 vxlan_snoop(dev, &loopback, eth_hdr(skb)->h_source, 0, vni);
2244 vni);
2245 2251
2246 u64_stats_update_begin(&tx_stats->syncp); 2252 u64_stats_update_begin(&tx_stats->syncp);
2247 tx_stats->tx_packets++; 2253 tx_stats->tx_packets++;
@@ -2254,8 +2260,10 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
2254 rx_stats->rx_bytes += len; 2260 rx_stats->rx_bytes += len;
2255 u64_stats_update_end(&rx_stats->syncp); 2261 u64_stats_update_end(&rx_stats->syncp);
2256 } else { 2262 } else {
2263drop:
2257 dev->stats.rx_dropped++; 2264 dev->stats.rx_dropped++;
2258 } 2265 }
2266 rcu_read_unlock();
2259} 2267}
2260 2268
2261static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev, 2269static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev,