aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-07-13 14:18:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-07-13 14:18:25 -0400
commitf760b87f8f12eb262f14603e65042996fe03720e (patch)
treedb0aa64596ca9f130c58893e8fd4e5d09d2909ad
parent34bef46e786ca6f884b8ed4be89e07b62f28ec3c (diff)
parentcee9f6d0186a586c8023bc91c8a4cf8a088855e5 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Missing list head init in bluetooth hidp session creation, from Tedd Ho-Jeong An. 2) Don't leak SKB in bridge netfilter error paths, from Florian Westphal. 3) ipv6 netdevice private leak in netfilter bridging, fixed by Julien Grall. 4) Fix regression in IP over hamradio bpq encapsulation, from Ralf Baechle. 5) Fix race between rhashtable resize events and table walks, from Phil Sutter. 6) Missing validation of IFLA_VF_INFO netlink attributes, fix from Daniel Borkmann. 7) Missing security layer socket state initialization in tipc code, from Stephen Smalley. 8) Fix shared IRQ handling in boomerang 3c59x interrupt handler, from Denys Vlasenko. 9) Missing minor_idr destroy on module unload on macvtap driver, from Johannes Thumshirn. 10) Various pktgen kernel thread races, from Oleg Nesterov. 11) Fix races that can cause packets to be processed in the backlog even after a device attached to that SKB has been fully unregistered. From Julian Anastasov. 12) bcmgenet driver doesn't account packet drops vs. errors properly, fix from Petri Gynther. 13) Array index validation and off by one fix in DSA layer from Florian Fainelli * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (66 commits) can: replace timestamp as unique skb attribute ARM: dts: dra7x-evm: Prevent glitch on DCAN1 pinmux can: c_can: Fix default pinmux glitch at init can: rcar_can: unify error messages can: rcar_can: print request_irq() error code can: rcar_can: fix typo in error message can: rcar_can: print signed IRQ # can: rcar_can: fix IRQ check net: dsa: Fix off-by-one in switch address parsing net: dsa: Test array index before use net: switchdev: don't abort unsupported operations net: bcmgenet: fix accounting of packet drops vs errors cdc_ncm: update specs URL Doc: z8530book: Fix typo in API-z8530-sync-txdma-open.html net: inet_diag: always export IPV6_V6ONLY sockopt for listening sockets bridge: mdb: allow the user to delete mdb entry if there's a querier net: call rcu_read_lock early in process_backlog net: do not process device backlog during unregistration bridge: fix potential crash in __netdev_pick_tx() net: axienet: Fix devm_ioremap_resource return value check ...
-rw-r--r--MAINTAINERS1
-rw-r--r--arch/arm/boot/dts/dra7-evm.dts5
-rw-r--r--arch/arm/boot/dts/dra72-evm.dts5
-rw-r--r--drivers/net/bonding/bond_main.c51
-rw-r--r--drivers/net/can/c_can/c_can.c10
-rw-r--r--drivers/net/can/dev.c7
-rw-r--r--drivers/net/can/rcar_can.c16
-rw-r--r--drivers/net/can/slcan.c2
-rw-r--r--drivers/net/can/vcan.c3
-rw-r--r--drivers/net/ethernet/3com/3c59x.c4
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-desc.c3
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-dev.c11
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-drv.c17
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe.h3
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c2
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.c4
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c25
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_main.c4
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c88
-rw-r--r--drivers/net/ethernet/sfc/ef10.c172
-rw-r--r--drivers/net/ethernet/sfc/ef10_sriov.c59
-rw-r--r--drivers/net/ethernet/sfc/ef10_sriov.h6
-rw-r--r--drivers/net/ethernet/sfc/efx.c14
-rw-r--r--drivers/net/ethernet/sfc/net_driver.h2
-rw-r--r--drivers/net/ethernet/sfc/tx.c3
-rw-r--r--drivers/net/ethernet/ti/cpsw.c25
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c8
-rw-r--r--drivers/net/hamradio/bpqether.c1
-rw-r--r--drivers/net/macvtap.c1
-rw-r--r--drivers/net/phy/Kconfig2
-rw-r--r--drivers/net/usb/cdc_ether.c8
-rw-r--r--drivers/net/usb/cdc_mbim.c2
-rw-r--r--drivers/net/usb/cdc_ncm.c63
-rw-r--r--drivers/net/usb/huawei_cdc_ncm.c7
-rw-r--r--drivers/net/usb/r8152.c2
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c8
-rw-r--r--drivers/net/wan/z85230.c2
-rw-r--r--include/linux/can/skb.h2
-rw-r--r--include/linux/usb/cdc_ncm.h7
-rw-r--r--include/uapi/linux/netconf.h1
-rw-r--r--lib/rhashtable.c4
-rw-r--r--net/bridge/br_forward.c1
-rw-r--r--net/bridge/br_mdb.c16
-rw-r--r--net/bridge/br_netfilter_hooks.c16
-rw-r--r--net/bridge/br_netfilter_ipv6.c2
-rw-r--r--net/bridge/br_netlink.c2
-rw-r--r--net/can/af_can.c12
-rw-r--r--net/can/bcm.c2
-rw-r--r--net/can/raw.c7
-rw-r--r--net/core/dev.c45
-rw-r--r--net/core/gen_estimator.c13
-rw-r--r--net/core/pktgen.c9
-rw-r--r--net/core/rtnetlink.c187
-rw-r--r--net/dsa/dsa.c6
-rw-r--r--net/ipv4/devinet.c13
-rw-r--r--net/ipv4/inet_diag.c4
-rw-r--r--net/ipv4/ip_tunnel.c8
-rw-r--r--net/ipv4/netfilter/arp_tables.c25
-rw-r--r--net/ipv6/ip6_input.c6
-rw-r--r--net/ipv6/route.c5
-rw-r--r--net/netfilter/nf_queue.c2
-rw-r--r--net/netfilter/nfnetlink.c38
-rw-r--r--net/netlink/af_netlink.c2
-rw-r--r--net/rds/transport.c2
-rw-r--r--net/switchdev/switchdev.c12
-rw-r--r--net/tipc/socket.c1
66 files changed, 702 insertions, 394 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index fd6078443083..2d3d55c8f5be 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7019,6 +7019,7 @@ F: include/uapi/linux/netfilter/
7019F: net/*/netfilter.c 7019F: net/*/netfilter.c
7020F: net/*/netfilter/ 7020F: net/*/netfilter/
7021F: net/netfilter/ 7021F: net/netfilter/
7022F: net/bridge/br_netfilter*.c
7022 7023
7023NETLABEL 7024NETLABEL
7024M: Paul Moore <paul@paul-moore.com> 7025M: Paul Moore <paul@paul-moore.com>
diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts
index aa465904f6cc..096f68be99e2 100644
--- a/arch/arm/boot/dts/dra7-evm.dts
+++ b/arch/arm/boot/dts/dra7-evm.dts
@@ -686,7 +686,8 @@
686 686
687&dcan1 { 687&dcan1 {
688 status = "ok"; 688 status = "ok";
689 pinctrl-names = "default", "sleep"; 689 pinctrl-names = "default", "sleep", "active";
690 pinctrl-0 = <&dcan1_pins_default>; 690 pinctrl-0 = <&dcan1_pins_sleep>;
691 pinctrl-1 = <&dcan1_pins_sleep>; 691 pinctrl-1 = <&dcan1_pins_sleep>;
692 pinctrl-2 = <&dcan1_pins_default>;
692}; 693};
diff --git a/arch/arm/boot/dts/dra72-evm.dts b/arch/arm/boot/dts/dra72-evm.dts
index 4e1b60581782..803738414086 100644
--- a/arch/arm/boot/dts/dra72-evm.dts
+++ b/arch/arm/boot/dts/dra72-evm.dts
@@ -587,9 +587,10 @@
587 587
588&dcan1 { 588&dcan1 {
589 status = "ok"; 589 status = "ok";
590 pinctrl-names = "default", "sleep"; 590 pinctrl-names = "default", "sleep", "active";
591 pinctrl-0 = <&dcan1_pins_default>; 591 pinctrl-0 = <&dcan1_pins_sleep>;
592 pinctrl-1 = <&dcan1_pins_sleep>; 592 pinctrl-1 = <&dcan1_pins_sleep>;
593 pinctrl-2 = <&dcan1_pins_default>;
593}; 594};
594 595
595&qspi { 596&qspi {
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 19eb990d398c..317a49480475 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -689,40 +689,57 @@ out:
689 689
690} 690}
691 691
692static bool bond_should_change_active(struct bonding *bond) 692static struct slave *bond_choose_primary_or_current(struct bonding *bond)
693{ 693{
694 struct slave *prim = rtnl_dereference(bond->primary_slave); 694 struct slave *prim = rtnl_dereference(bond->primary_slave);
695 struct slave *curr = rtnl_dereference(bond->curr_active_slave); 695 struct slave *curr = rtnl_dereference(bond->curr_active_slave);
696 696
697 if (!prim || !curr || curr->link != BOND_LINK_UP) 697 if (!prim || prim->link != BOND_LINK_UP) {
698 return true; 698 if (!curr || curr->link != BOND_LINK_UP)
699 return NULL;
700 return curr;
701 }
702
699 if (bond->force_primary) { 703 if (bond->force_primary) {
700 bond->force_primary = false; 704 bond->force_primary = false;
701 return true; 705 return prim;
706 }
707
708 if (!curr || curr->link != BOND_LINK_UP)
709 return prim;
710
711 /* At this point, prim and curr are both up */
712 switch (bond->params.primary_reselect) {
713 case BOND_PRI_RESELECT_ALWAYS:
714 return prim;
715 case BOND_PRI_RESELECT_BETTER:
716 if (prim->speed < curr->speed)
717 return curr;
718 if (prim->speed == curr->speed && prim->duplex <= curr->duplex)
719 return curr;
720 return prim;
721 case BOND_PRI_RESELECT_FAILURE:
722 return curr;
723 default:
724 netdev_err(bond->dev, "impossible primary_reselect %d\n",
725 bond->params.primary_reselect);
726 return curr;
702 } 727 }
703 if (bond->params.primary_reselect == BOND_PRI_RESELECT_BETTER &&
704 (prim->speed < curr->speed ||
705 (prim->speed == curr->speed && prim->duplex <= curr->duplex)))
706 return false;
707 if (bond->params.primary_reselect == BOND_PRI_RESELECT_FAILURE)
708 return false;
709 return true;
710} 728}
711 729
712/** 730/**
713 * find_best_interface - select the best available slave to be the active one 731 * bond_find_best_slave - select the best available slave to be the active one
714 * @bond: our bonding struct 732 * @bond: our bonding struct
715 */ 733 */
716static struct slave *bond_find_best_slave(struct bonding *bond) 734static struct slave *bond_find_best_slave(struct bonding *bond)
717{ 735{
718 struct slave *slave, *bestslave = NULL, *primary; 736 struct slave *slave, *bestslave = NULL;
719 struct list_head *iter; 737 struct list_head *iter;
720 int mintime = bond->params.updelay; 738 int mintime = bond->params.updelay;
721 739
722 primary = rtnl_dereference(bond->primary_slave); 740 slave = bond_choose_primary_or_current(bond);
723 if (primary && primary->link == BOND_LINK_UP && 741 if (slave)
724 bond_should_change_active(bond)) 742 return slave;
725 return primary;
726 743
727 bond_for_each_slave(bond, slave, iter) { 744 bond_for_each_slave(bond, slave, iter) {
728 if (slave->link == BOND_LINK_UP) 745 if (slave->link == BOND_LINK_UP)
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 041525d2595c..5d214d135332 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -592,6 +592,7 @@ static int c_can_start(struct net_device *dev)
592{ 592{
593 struct c_can_priv *priv = netdev_priv(dev); 593 struct c_can_priv *priv = netdev_priv(dev);
594 int err; 594 int err;
595 struct pinctrl *p;
595 596
596 /* basic c_can configuration */ 597 /* basic c_can configuration */
597 err = c_can_chip_config(dev); 598 err = c_can_chip_config(dev);
@@ -604,8 +605,13 @@ static int c_can_start(struct net_device *dev)
604 605
605 priv->can.state = CAN_STATE_ERROR_ACTIVE; 606 priv->can.state = CAN_STATE_ERROR_ACTIVE;
606 607
607 /* activate pins */ 608 /* Attempt to use "active" if available else use "default" */
608 pinctrl_pm_select_default_state(dev->dev.parent); 609 p = pinctrl_get_select(priv->device, "active");
610 if (!IS_ERR(p))
611 pinctrl_put(p);
612 else
613 pinctrl_pm_select_default_state(priv->device);
614
609 return 0; 615 return 0;
610} 616}
611 617
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index e9b1810d319f..aede704605c6 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -440,9 +440,6 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
440 struct can_frame *cf = (struct can_frame *)skb->data; 440 struct can_frame *cf = (struct can_frame *)skb->data;
441 u8 dlc = cf->can_dlc; 441 u8 dlc = cf->can_dlc;
442 442
443 if (!(skb->tstamp.tv64))
444 __net_timestamp(skb);
445
446 netif_rx(priv->echo_skb[idx]); 443 netif_rx(priv->echo_skb[idx]);
447 priv->echo_skb[idx] = NULL; 444 priv->echo_skb[idx] = NULL;
448 445
@@ -578,7 +575,6 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
578 if (unlikely(!skb)) 575 if (unlikely(!skb))
579 return NULL; 576 return NULL;
580 577
581 __net_timestamp(skb);
582 skb->protocol = htons(ETH_P_CAN); 578 skb->protocol = htons(ETH_P_CAN);
583 skb->pkt_type = PACKET_BROADCAST; 579 skb->pkt_type = PACKET_BROADCAST;
584 skb->ip_summed = CHECKSUM_UNNECESSARY; 580 skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -589,6 +585,7 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
589 585
590 can_skb_reserve(skb); 586 can_skb_reserve(skb);
591 can_skb_prv(skb)->ifindex = dev->ifindex; 587 can_skb_prv(skb)->ifindex = dev->ifindex;
588 can_skb_prv(skb)->skbcnt = 0;
592 589
593 *cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame)); 590 *cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
594 memset(*cf, 0, sizeof(struct can_frame)); 591 memset(*cf, 0, sizeof(struct can_frame));
@@ -607,7 +604,6 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
607 if (unlikely(!skb)) 604 if (unlikely(!skb))
608 return NULL; 605 return NULL;
609 606
610 __net_timestamp(skb);
611 skb->protocol = htons(ETH_P_CANFD); 607 skb->protocol = htons(ETH_P_CANFD);
612 skb->pkt_type = PACKET_BROADCAST; 608 skb->pkt_type = PACKET_BROADCAST;
613 skb->ip_summed = CHECKSUM_UNNECESSARY; 609 skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -618,6 +614,7 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
618 614
619 can_skb_reserve(skb); 615 can_skb_reserve(skb);
620 can_skb_prv(skb)->ifindex = dev->ifindex; 616 can_skb_prv(skb)->ifindex = dev->ifindex;
617 can_skb_prv(skb)->skbcnt = 0;
621 618
622 *cfd = (struct canfd_frame *)skb_put(skb, sizeof(struct canfd_frame)); 619 *cfd = (struct canfd_frame *)skb_put(skb, sizeof(struct canfd_frame));
623 memset(*cfd, 0, sizeof(struct canfd_frame)); 620 memset(*cfd, 0, sizeof(struct canfd_frame));
diff --git a/drivers/net/can/rcar_can.c b/drivers/net/can/rcar_can.c
index 7deb80dcbe8c..7bd54191f962 100644
--- a/drivers/net/can/rcar_can.c
+++ b/drivers/net/can/rcar_can.c
@@ -508,7 +508,8 @@ static int rcar_can_open(struct net_device *ndev)
508 508
509 err = clk_prepare_enable(priv->clk); 509 err = clk_prepare_enable(priv->clk);
510 if (err) { 510 if (err) {
511 netdev_err(ndev, "failed to enable periperal clock, error %d\n", 511 netdev_err(ndev,
512 "failed to enable peripheral clock, error %d\n",
512 err); 513 err);
513 goto out; 514 goto out;
514 } 515 }
@@ -526,7 +527,8 @@ static int rcar_can_open(struct net_device *ndev)
526 napi_enable(&priv->napi); 527 napi_enable(&priv->napi);
527 err = request_irq(ndev->irq, rcar_can_interrupt, 0, ndev->name, ndev); 528 err = request_irq(ndev->irq, rcar_can_interrupt, 0, ndev->name, ndev);
528 if (err) { 529 if (err) {
529 netdev_err(ndev, "error requesting interrupt %x\n", ndev->irq); 530 netdev_err(ndev, "request_irq(%d) failed, error %d\n",
531 ndev->irq, err);
530 goto out_close; 532 goto out_close;
531 } 533 }
532 can_led_event(ndev, CAN_LED_EVENT_OPEN); 534 can_led_event(ndev, CAN_LED_EVENT_OPEN);
@@ -758,8 +760,9 @@ static int rcar_can_probe(struct platform_device *pdev)
758 } 760 }
759 761
760 irq = platform_get_irq(pdev, 0); 762 irq = platform_get_irq(pdev, 0);
761 if (!irq) { 763 if (irq < 0) {
762 dev_err(&pdev->dev, "No IRQ resource\n"); 764 dev_err(&pdev->dev, "No IRQ resource\n");
765 err = irq;
763 goto fail; 766 goto fail;
764 } 767 }
765 768
@@ -782,7 +785,8 @@ static int rcar_can_probe(struct platform_device *pdev)
782 priv->clk = devm_clk_get(&pdev->dev, "clkp1"); 785 priv->clk = devm_clk_get(&pdev->dev, "clkp1");
783 if (IS_ERR(priv->clk)) { 786 if (IS_ERR(priv->clk)) {
784 err = PTR_ERR(priv->clk); 787 err = PTR_ERR(priv->clk);
785 dev_err(&pdev->dev, "cannot get peripheral clock: %d\n", err); 788 dev_err(&pdev->dev, "cannot get peripheral clock, error %d\n",
789 err);
786 goto fail_clk; 790 goto fail_clk;
787 } 791 }
788 792
@@ -794,7 +798,7 @@ static int rcar_can_probe(struct platform_device *pdev)
794 priv->can_clk = devm_clk_get(&pdev->dev, clock_names[clock_select]); 798 priv->can_clk = devm_clk_get(&pdev->dev, clock_names[clock_select]);
795 if (IS_ERR(priv->can_clk)) { 799 if (IS_ERR(priv->can_clk)) {
796 err = PTR_ERR(priv->can_clk); 800 err = PTR_ERR(priv->can_clk);
797 dev_err(&pdev->dev, "cannot get CAN clock: %d\n", err); 801 dev_err(&pdev->dev, "cannot get CAN clock, error %d\n", err);
798 goto fail_clk; 802 goto fail_clk;
799 } 803 }
800 804
@@ -823,7 +827,7 @@ static int rcar_can_probe(struct platform_device *pdev)
823 827
824 devm_can_led_init(ndev); 828 devm_can_led_init(ndev);
825 829
826 dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%u)\n", 830 dev_info(&pdev->dev, "device registered (regs @ %p, IRQ%d)\n",
827 priv->regs, ndev->irq); 831 priv->regs, ndev->irq);
828 832
829 return 0; 833 return 0;
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index f64f5290d6f8..a23a7af8eb9a 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -207,7 +207,6 @@ static void slc_bump(struct slcan *sl)
207 if (!skb) 207 if (!skb)
208 return; 208 return;
209 209
210 __net_timestamp(skb);
211 skb->dev = sl->dev; 210 skb->dev = sl->dev;
212 skb->protocol = htons(ETH_P_CAN); 211 skb->protocol = htons(ETH_P_CAN);
213 skb->pkt_type = PACKET_BROADCAST; 212 skb->pkt_type = PACKET_BROADCAST;
@@ -215,6 +214,7 @@ static void slc_bump(struct slcan *sl)
215 214
216 can_skb_reserve(skb); 215 can_skb_reserve(skb);
217 can_skb_prv(skb)->ifindex = sl->dev->ifindex; 216 can_skb_prv(skb)->ifindex = sl->dev->ifindex;
217 can_skb_prv(skb)->skbcnt = 0;
218 218
219 memcpy(skb_put(skb, sizeof(struct can_frame)), 219 memcpy(skb_put(skb, sizeof(struct can_frame)),
220 &cf, sizeof(struct can_frame)); 220 &cf, sizeof(struct can_frame));
diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
index 0ce868de855d..674f367087c5 100644
--- a/drivers/net/can/vcan.c
+++ b/drivers/net/can/vcan.c
@@ -78,9 +78,6 @@ static void vcan_rx(struct sk_buff *skb, struct net_device *dev)
78 skb->dev = dev; 78 skb->dev = dev;
79 skb->ip_summed = CHECKSUM_UNNECESSARY; 79 skb->ip_summed = CHECKSUM_UNNECESSARY;
80 80
81 if (!(skb->tstamp.tv64))
82 __net_timestamp(skb);
83
84 netif_rx_ni(skb); 81 netif_rx_ni(skb);
85} 82}
86 83
diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c
index 41095ebad97f..2d1ce3c5d0dd 100644
--- a/drivers/net/ethernet/3com/3c59x.c
+++ b/drivers/net/ethernet/3com/3c59x.c
@@ -2382,6 +2382,7 @@ boomerang_interrupt(int irq, void *dev_id)
2382 void __iomem *ioaddr; 2382 void __iomem *ioaddr;
2383 int status; 2383 int status;
2384 int work_done = max_interrupt_work; 2384 int work_done = max_interrupt_work;
2385 int handled = 0;
2385 2386
2386 ioaddr = vp->ioaddr; 2387 ioaddr = vp->ioaddr;
2387 2388
@@ -2400,6 +2401,7 @@ boomerang_interrupt(int irq, void *dev_id)
2400 2401
2401 if ((status & IntLatch) == 0) 2402 if ((status & IntLatch) == 0)
2402 goto handler_exit; /* No interrupt: shared IRQs can cause this */ 2403 goto handler_exit; /* No interrupt: shared IRQs can cause this */
2404 handled = 1;
2403 2405
2404 if (status == 0xffff) { /* h/w no longer present (hotplug)? */ 2406 if (status == 0xffff) { /* h/w no longer present (hotplug)? */
2405 if (vortex_debug > 1) 2407 if (vortex_debug > 1)
@@ -2501,7 +2503,7 @@ boomerang_interrupt(int irq, void *dev_id)
2501handler_exit: 2503handler_exit:
2502 vp->handling_irq = 0; 2504 vp->handling_irq = 0;
2503 spin_unlock(&vp->lock); 2505 spin_unlock(&vp->lock);
2504 return IRQ_HANDLED; 2506 return IRQ_RETVAL(handled);
2505} 2507}
2506 2508
2507static int vortex_rx(struct net_device *dev) 2509static int vortex_rx(struct net_device *dev)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
index 661cdaa7ea96..b3bc87fe3764 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
@@ -303,7 +303,8 @@ static void xgbe_set_buffer_data(struct xgbe_buffer_data *bd,
303 get_page(pa->pages); 303 get_page(pa->pages);
304 bd->pa = *pa; 304 bd->pa = *pa;
305 305
306 bd->dma = pa->pages_dma + pa->pages_offset; 306 bd->dma_base = pa->pages_dma;
307 bd->dma_off = pa->pages_offset;
307 bd->dma_len = len; 308 bd->dma_len = len;
308 309
309 pa->pages_offset += len; 310 pa->pages_offset += len;
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
index 506e832c9e9a..a4473d8ff4fa 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
@@ -1110,6 +1110,7 @@ static void xgbe_rx_desc_reset(struct xgbe_prv_data *pdata,
1110 unsigned int rx_usecs = pdata->rx_usecs; 1110 unsigned int rx_usecs = pdata->rx_usecs;
1111 unsigned int rx_frames = pdata->rx_frames; 1111 unsigned int rx_frames = pdata->rx_frames;
1112 unsigned int inte; 1112 unsigned int inte;
1113 dma_addr_t hdr_dma, buf_dma;
1113 1114
1114 if (!rx_usecs && !rx_frames) { 1115 if (!rx_usecs && !rx_frames) {
1115 /* No coalescing, interrupt for every descriptor */ 1116 /* No coalescing, interrupt for every descriptor */
@@ -1129,10 +1130,12 @@ static void xgbe_rx_desc_reset(struct xgbe_prv_data *pdata,
1129 * Set buffer 2 (hi) address to buffer dma address (hi) and 1130 * Set buffer 2 (hi) address to buffer dma address (hi) and
1130 * set control bits OWN and INTE 1131 * set control bits OWN and INTE
1131 */ 1132 */
1132 rdesc->desc0 = cpu_to_le32(lower_32_bits(rdata->rx.hdr.dma)); 1133 hdr_dma = rdata->rx.hdr.dma_base + rdata->rx.hdr.dma_off;
1133 rdesc->desc1 = cpu_to_le32(upper_32_bits(rdata->rx.hdr.dma)); 1134 buf_dma = rdata->rx.buf.dma_base + rdata->rx.buf.dma_off;
1134 rdesc->desc2 = cpu_to_le32(lower_32_bits(rdata->rx.buf.dma)); 1135 rdesc->desc0 = cpu_to_le32(lower_32_bits(hdr_dma));
1135 rdesc->desc3 = cpu_to_le32(upper_32_bits(rdata->rx.buf.dma)); 1136 rdesc->desc1 = cpu_to_le32(upper_32_bits(hdr_dma));
1137 rdesc->desc2 = cpu_to_le32(lower_32_bits(buf_dma));
1138 rdesc->desc3 = cpu_to_le32(upper_32_bits(buf_dma));
1136 1139
1137 XGMAC_SET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, INTE, inte); 1140 XGMAC_SET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, INTE, inte);
1138 1141
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 1e9c28d19ef8..aae9d5ecd182 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -1765,8 +1765,9 @@ static struct sk_buff *xgbe_create_skb(struct xgbe_prv_data *pdata,
1765 /* Start with the header buffer which may contain just the header 1765 /* Start with the header buffer which may contain just the header
1766 * or the header plus data 1766 * or the header plus data
1767 */ 1767 */
1768 dma_sync_single_for_cpu(pdata->dev, rdata->rx.hdr.dma, 1768 dma_sync_single_range_for_cpu(pdata->dev, rdata->rx.hdr.dma_base,
1769 rdata->rx.hdr.dma_len, DMA_FROM_DEVICE); 1769 rdata->rx.hdr.dma_off,
1770 rdata->rx.hdr.dma_len, DMA_FROM_DEVICE);
1770 1771
1771 packet = page_address(rdata->rx.hdr.pa.pages) + 1772 packet = page_address(rdata->rx.hdr.pa.pages) +
1772 rdata->rx.hdr.pa.pages_offset; 1773 rdata->rx.hdr.pa.pages_offset;
@@ -1778,8 +1779,11 @@ static struct sk_buff *xgbe_create_skb(struct xgbe_prv_data *pdata,
1778 len -= copy_len; 1779 len -= copy_len;
1779 if (len) { 1780 if (len) {
1780 /* Add the remaining data as a frag */ 1781 /* Add the remaining data as a frag */
1781 dma_sync_single_for_cpu(pdata->dev, rdata->rx.buf.dma, 1782 dma_sync_single_range_for_cpu(pdata->dev,
1782 rdata->rx.buf.dma_len, DMA_FROM_DEVICE); 1783 rdata->rx.buf.dma_base,
1784 rdata->rx.buf.dma_off,
1785 rdata->rx.buf.dma_len,
1786 DMA_FROM_DEVICE);
1783 1787
1784 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, 1788 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
1785 rdata->rx.buf.pa.pages, 1789 rdata->rx.buf.pa.pages,
@@ -1945,8 +1949,9 @@ read_again:
1945 if (!skb) 1949 if (!skb)
1946 error = 1; 1950 error = 1;
1947 } else if (rdesc_len) { 1951 } else if (rdesc_len) {
1948 dma_sync_single_for_cpu(pdata->dev, 1952 dma_sync_single_range_for_cpu(pdata->dev,
1949 rdata->rx.buf.dma, 1953 rdata->rx.buf.dma_base,
1954 rdata->rx.buf.dma_off,
1950 rdata->rx.buf.dma_len, 1955 rdata->rx.buf.dma_len,
1951 DMA_FROM_DEVICE); 1956 DMA_FROM_DEVICE);
1952 1957
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
index 63d72a140053..717ce21b6077 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
@@ -337,7 +337,8 @@ struct xgbe_buffer_data {
337 struct xgbe_page_alloc pa; 337 struct xgbe_page_alloc pa;
338 struct xgbe_page_alloc pa_unmap; 338 struct xgbe_page_alloc pa_unmap;
339 339
340 dma_addr_t dma; 340 dma_addr_t dma_base;
341 unsigned long dma_off;
341 unsigned int dma_len; 342 unsigned int dma_len;
342}; 343};
343 344
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 909ad7a0d480..4566cdf0bc39 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1793,7 +1793,7 @@ static int bcm_sysport_probe(struct platform_device *pdev)
1793 macaddr = of_get_mac_address(dn); 1793 macaddr = of_get_mac_address(dn);
1794 if (!macaddr || !is_valid_ether_addr(macaddr)) { 1794 if (!macaddr || !is_valid_ether_addr(macaddr)) {
1795 dev_warn(&pdev->dev, "using random Ethernet MAC\n"); 1795 dev_warn(&pdev->dev, "using random Ethernet MAC\n");
1796 random_ether_addr(dev->dev_addr); 1796 eth_hw_addr_random(dev);
1797 } else { 1797 } else {
1798 ether_addr_copy(dev->dev_addr, macaddr); 1798 ether_addr_copy(dev->dev_addr, macaddr);
1799 } 1799 }
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index b43b2cb9b830..64c1e9db6b0b 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1230,7 +1230,6 @@ static struct sk_buff *bcmgenet_put_tx_csum(struct net_device *dev,
1230 new_skb = skb_realloc_headroom(skb, sizeof(*status)); 1230 new_skb = skb_realloc_headroom(skb, sizeof(*status));
1231 dev_kfree_skb(skb); 1231 dev_kfree_skb(skb);
1232 if (!new_skb) { 1232 if (!new_skb) {
1233 dev->stats.tx_errors++;
1234 dev->stats.tx_dropped++; 1233 dev->stats.tx_dropped++;
1235 return NULL; 1234 return NULL;
1236 } 1235 }
@@ -1465,7 +1464,6 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
1465 1464
1466 if (unlikely(!skb)) { 1465 if (unlikely(!skb)) {
1467 dev->stats.rx_dropped++; 1466 dev->stats.rx_dropped++;
1468 dev->stats.rx_errors++;
1469 goto next; 1467 goto next;
1470 } 1468 }
1471 1469
@@ -1493,7 +1491,6 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
1493 if (unlikely(!(dma_flag & DMA_EOP) || !(dma_flag & DMA_SOP))) { 1491 if (unlikely(!(dma_flag & DMA_EOP) || !(dma_flag & DMA_SOP))) {
1494 netif_err(priv, rx_status, dev, 1492 netif_err(priv, rx_status, dev,
1495 "dropping fragmented packet!\n"); 1493 "dropping fragmented packet!\n");
1496 dev->stats.rx_dropped++;
1497 dev->stats.rx_errors++; 1494 dev->stats.rx_errors++;
1498 dev_kfree_skb_any(skb); 1495 dev_kfree_skb_any(skb);
1499 goto next; 1496 goto next;
@@ -1515,7 +1512,6 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
1515 dev->stats.rx_frame_errors++; 1512 dev->stats.rx_frame_errors++;
1516 if (dma_flag & DMA_RX_LG) 1513 if (dma_flag & DMA_RX_LG)
1517 dev->stats.rx_length_errors++; 1514 dev->stats.rx_length_errors++;
1518 dev->stats.rx_dropped++;
1519 dev->stats.rx_errors++; 1515 dev->stats.rx_errors++;
1520 dev_kfree_skb_any(skb); 1516 dev_kfree_skb_any(skb);
1521 goto next; 1517 goto next;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index 484eb8c37489..a11485fbb33f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -952,16 +952,23 @@ static int devlog_show(struct seq_file *seq, void *v)
952 * eventually have to put a format interpreter in here ... 952 * eventually have to put a format interpreter in here ...
953 */ 953 */
954 seq_printf(seq, "%10d %15llu %8s %8s ", 954 seq_printf(seq, "%10d %15llu %8s %8s ",
955 e->seqno, e->timestamp, 955 be32_to_cpu(e->seqno),
956 be64_to_cpu(e->timestamp),
956 (e->level < ARRAY_SIZE(devlog_level_strings) 957 (e->level < ARRAY_SIZE(devlog_level_strings)
957 ? devlog_level_strings[e->level] 958 ? devlog_level_strings[e->level]
958 : "UNKNOWN"), 959 : "UNKNOWN"),
959 (e->facility < ARRAY_SIZE(devlog_facility_strings) 960 (e->facility < ARRAY_SIZE(devlog_facility_strings)
960 ? devlog_facility_strings[e->facility] 961 ? devlog_facility_strings[e->facility]
961 : "UNKNOWN")); 962 : "UNKNOWN"));
962 seq_printf(seq, e->fmt, e->params[0], e->params[1], 963 seq_printf(seq, e->fmt,
963 e->params[2], e->params[3], e->params[4], 964 be32_to_cpu(e->params[0]),
964 e->params[5], e->params[6], e->params[7]); 965 be32_to_cpu(e->params[1]),
966 be32_to_cpu(e->params[2]),
967 be32_to_cpu(e->params[3]),
968 be32_to_cpu(e->params[4]),
969 be32_to_cpu(e->params[5]),
970 be32_to_cpu(e->params[6]),
971 be32_to_cpu(e->params[7]));
965 } 972 }
966 return 0; 973 return 0;
967} 974}
@@ -1043,23 +1050,17 @@ static int devlog_open(struct inode *inode, struct file *file)
1043 return ret; 1050 return ret;
1044 } 1051 }
1045 1052
1046 /* Translate log multi-byte integral elements into host native format 1053 /* Find the earliest (lowest Sequence Number) log entry in the
1047 * and determine where the first entry in the log is. 1054 * circular Device Log.
1048 */ 1055 */
1049 for (fseqno = ~((u32)0), index = 0; index < dinfo->nentries; index++) { 1056 for (fseqno = ~((u32)0), index = 0; index < dinfo->nentries; index++) {
1050 struct fw_devlog_e *e = &dinfo->log[index]; 1057 struct fw_devlog_e *e = &dinfo->log[index];
1051 int i;
1052 __u32 seqno; 1058 __u32 seqno;
1053 1059
1054 if (e->timestamp == 0) 1060 if (e->timestamp == 0)
1055 continue; 1061 continue;
1056 1062
1057 e->timestamp = (__force __be64)be64_to_cpu(e->timestamp);
1058 seqno = be32_to_cpu(e->seqno); 1063 seqno = be32_to_cpu(e->seqno);
1059 for (i = 0; i < 8; i++)
1060 e->params[i] =
1061 (__force __be32)be32_to_cpu(e->params[i]);
1062
1063 if (seqno < fseqno) { 1064 if (seqno < fseqno) {
1064 fseqno = seqno; 1065 fseqno = seqno;
1065 dinfo->first = index; 1066 dinfo->first = index;
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index da2004e2a741..918a8e42139b 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1170,7 +1170,7 @@ static int enic_poll(struct napi_struct *napi, int budget)
1170 wq_work_done, 1170 wq_work_done,
1171 0 /* dont unmask intr */, 1171 0 /* dont unmask intr */,
1172 0 /* dont reset intr timer */); 1172 0 /* dont reset intr timer */);
1173 return rq_work_done; 1173 return budget;
1174 } 1174 }
1175 1175
1176 if (budget > 0) 1176 if (budget > 0)
@@ -1191,6 +1191,7 @@ static int enic_poll(struct napi_struct *napi, int budget)
1191 0 /* don't reset intr timer */); 1191 0 /* don't reset intr timer */);
1192 1192
1193 err = vnic_rq_fill(&enic->rq[0], enic_rq_alloc_buf); 1193 err = vnic_rq_fill(&enic->rq[0], enic_rq_alloc_buf);
1194 enic_poll_unlock_napi(&enic->rq[cq_rq], napi);
1194 1195
1195 /* Buffer allocation failed. Stay in polling 1196 /* Buffer allocation failed. Stay in polling
1196 * mode so we can try to fill the ring again. 1197 * mode so we can try to fill the ring again.
@@ -1208,7 +1209,6 @@ static int enic_poll(struct napi_struct *napi, int budget)
1208 napi_complete(napi); 1209 napi_complete(napi);
1209 vnic_intr_unmask(&enic->intr[intr]); 1210 vnic_intr_unmask(&enic->intr[intr]);
1210 } 1211 }
1211 enic_poll_unlock_napi(&enic->rq[cq_rq], napi);
1212 1212
1213 return rq_work_done; 1213 return rq_work_done;
1214} 1214}
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 1f89c59b4353..42e20e5385ac 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -24,6 +24,7 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/string.h> 26#include <linux/string.h>
27#include <linux/pm_runtime.h>
27#include <linux/ptrace.h> 28#include <linux/ptrace.h>
28#include <linux/errno.h> 29#include <linux/errno.h>
29#include <linux/ioport.h> 30#include <linux/ioport.h>
@@ -77,6 +78,7 @@ static void fec_enet_itr_coal_init(struct net_device *ndev);
77#define FEC_ENET_RAEM_V 0x8 78#define FEC_ENET_RAEM_V 0x8
78#define FEC_ENET_RAFL_V 0x8 79#define FEC_ENET_RAFL_V 0x8
79#define FEC_ENET_OPD_V 0xFFF0 80#define FEC_ENET_OPD_V 0xFFF0
81#define FEC_MDIO_PM_TIMEOUT 100 /* ms */
80 82
81static struct platform_device_id fec_devtype[] = { 83static struct platform_device_id fec_devtype[] = {
82 { 84 {
@@ -1767,7 +1769,13 @@ static void fec_enet_adjust_link(struct net_device *ndev)
1767static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum) 1769static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
1768{ 1770{
1769 struct fec_enet_private *fep = bus->priv; 1771 struct fec_enet_private *fep = bus->priv;
1772 struct device *dev = &fep->pdev->dev;
1770 unsigned long time_left; 1773 unsigned long time_left;
1774 int ret = 0;
1775
1776 ret = pm_runtime_get_sync(dev);
1777 if (IS_ERR_VALUE(ret))
1778 return ret;
1771 1779
1772 fep->mii_timeout = 0; 1780 fep->mii_timeout = 0;
1773 init_completion(&fep->mdio_done); 1781 init_completion(&fep->mdio_done);
@@ -1783,18 +1791,30 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
1783 if (time_left == 0) { 1791 if (time_left == 0) {
1784 fep->mii_timeout = 1; 1792 fep->mii_timeout = 1;
1785 netdev_err(fep->netdev, "MDIO read timeout\n"); 1793 netdev_err(fep->netdev, "MDIO read timeout\n");
1786 return -ETIMEDOUT; 1794 ret = -ETIMEDOUT;
1795 goto out;
1787 } 1796 }
1788 1797
1789 /* return value */ 1798 ret = FEC_MMFR_DATA(readl(fep->hwp + FEC_MII_DATA));
1790 return FEC_MMFR_DATA(readl(fep->hwp + FEC_MII_DATA)); 1799
1800out:
1801 pm_runtime_mark_last_busy(dev);
1802 pm_runtime_put_autosuspend(dev);
1803
1804 return ret;
1791} 1805}
1792 1806
1793static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum, 1807static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
1794 u16 value) 1808 u16 value)
1795{ 1809{
1796 struct fec_enet_private *fep = bus->priv; 1810 struct fec_enet_private *fep = bus->priv;
1811 struct device *dev = &fep->pdev->dev;
1797 unsigned long time_left; 1812 unsigned long time_left;
1813 int ret = 0;
1814
1815 ret = pm_runtime_get_sync(dev);
1816 if (IS_ERR_VALUE(ret))
1817 return ret;
1798 1818
1799 fep->mii_timeout = 0; 1819 fep->mii_timeout = 0;
1800 init_completion(&fep->mdio_done); 1820 init_completion(&fep->mdio_done);
@@ -1811,10 +1831,13 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
1811 if (time_left == 0) { 1831 if (time_left == 0) {
1812 fep->mii_timeout = 1; 1832 fep->mii_timeout = 1;
1813 netdev_err(fep->netdev, "MDIO write timeout\n"); 1833 netdev_err(fep->netdev, "MDIO write timeout\n");
1814 return -ETIMEDOUT; 1834 ret = -ETIMEDOUT;
1815 } 1835 }
1816 1836
1817 return 0; 1837 pm_runtime_mark_last_busy(dev);
1838 pm_runtime_put_autosuspend(dev);
1839
1840 return ret;
1818} 1841}
1819 1842
1820static int fec_enet_clk_enable(struct net_device *ndev, bool enable) 1843static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
@@ -1826,9 +1849,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
1826 ret = clk_prepare_enable(fep->clk_ahb); 1849 ret = clk_prepare_enable(fep->clk_ahb);
1827 if (ret) 1850 if (ret)
1828 return ret; 1851 return ret;
1829 ret = clk_prepare_enable(fep->clk_ipg);
1830 if (ret)
1831 goto failed_clk_ipg;
1832 if (fep->clk_enet_out) { 1852 if (fep->clk_enet_out) {
1833 ret = clk_prepare_enable(fep->clk_enet_out); 1853 ret = clk_prepare_enable(fep->clk_enet_out);
1834 if (ret) 1854 if (ret)
@@ -1852,7 +1872,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
1852 } 1872 }
1853 } else { 1873 } else {
1854 clk_disable_unprepare(fep->clk_ahb); 1874 clk_disable_unprepare(fep->clk_ahb);
1855 clk_disable_unprepare(fep->clk_ipg);
1856 if (fep->clk_enet_out) 1875 if (fep->clk_enet_out)
1857 clk_disable_unprepare(fep->clk_enet_out); 1876 clk_disable_unprepare(fep->clk_enet_out);
1858 if (fep->clk_ptp) { 1877 if (fep->clk_ptp) {
@@ -1874,8 +1893,6 @@ failed_clk_ptp:
1874 if (fep->clk_enet_out) 1893 if (fep->clk_enet_out)
1875 clk_disable_unprepare(fep->clk_enet_out); 1894 clk_disable_unprepare(fep->clk_enet_out);
1876failed_clk_enet_out: 1895failed_clk_enet_out:
1877 clk_disable_unprepare(fep->clk_ipg);
1878failed_clk_ipg:
1879 clk_disable_unprepare(fep->clk_ahb); 1896 clk_disable_unprepare(fep->clk_ahb);
1880 1897
1881 return ret; 1898 return ret;
@@ -2847,10 +2864,14 @@ fec_enet_open(struct net_device *ndev)
2847 struct fec_enet_private *fep = netdev_priv(ndev); 2864 struct fec_enet_private *fep = netdev_priv(ndev);
2848 int ret; 2865 int ret;
2849 2866
2867 ret = pm_runtime_get_sync(&fep->pdev->dev);
2868 if (IS_ERR_VALUE(ret))
2869 return ret;
2870
2850 pinctrl_pm_select_default_state(&fep->pdev->dev); 2871 pinctrl_pm_select_default_state(&fep->pdev->dev);
2851 ret = fec_enet_clk_enable(ndev, true); 2872 ret = fec_enet_clk_enable(ndev, true);
2852 if (ret) 2873 if (ret)
2853 return ret; 2874 goto clk_enable;
2854 2875
2855 /* I should reset the ring buffers here, but I don't yet know 2876 /* I should reset the ring buffers here, but I don't yet know
2856 * a simple way to do that. 2877 * a simple way to do that.
@@ -2881,6 +2902,9 @@ err_enet_mii_probe:
2881 fec_enet_free_buffers(ndev); 2902 fec_enet_free_buffers(ndev);
2882err_enet_alloc: 2903err_enet_alloc:
2883 fec_enet_clk_enable(ndev, false); 2904 fec_enet_clk_enable(ndev, false);
2905clk_enable:
2906 pm_runtime_mark_last_busy(&fep->pdev->dev);
2907 pm_runtime_put_autosuspend(&fep->pdev->dev);
2884 pinctrl_pm_select_sleep_state(&fep->pdev->dev); 2908 pinctrl_pm_select_sleep_state(&fep->pdev->dev);
2885 return ret; 2909 return ret;
2886} 2910}
@@ -2903,6 +2927,9 @@ fec_enet_close(struct net_device *ndev)
2903 2927
2904 fec_enet_clk_enable(ndev, false); 2928 fec_enet_clk_enable(ndev, false);
2905 pinctrl_pm_select_sleep_state(&fep->pdev->dev); 2929 pinctrl_pm_select_sleep_state(&fep->pdev->dev);
2930 pm_runtime_mark_last_busy(&fep->pdev->dev);
2931 pm_runtime_put_autosuspend(&fep->pdev->dev);
2932
2906 fec_enet_free_buffers(ndev); 2933 fec_enet_free_buffers(ndev);
2907 2934
2908 return 0; 2935 return 0;
@@ -3388,6 +3415,10 @@ fec_probe(struct platform_device *pdev)
3388 if (ret) 3415 if (ret)
3389 goto failed_clk; 3416 goto failed_clk;
3390 3417
3418 ret = clk_prepare_enable(fep->clk_ipg);
3419 if (ret)
3420 goto failed_clk_ipg;
3421
3391 fep->reg_phy = devm_regulator_get(&pdev->dev, "phy"); 3422 fep->reg_phy = devm_regulator_get(&pdev->dev, "phy");
3392 if (!IS_ERR(fep->reg_phy)) { 3423 if (!IS_ERR(fep->reg_phy)) {
3393 ret = regulator_enable(fep->reg_phy); 3424 ret = regulator_enable(fep->reg_phy);
@@ -3434,6 +3465,8 @@ fec_probe(struct platform_device *pdev)
3434 netif_carrier_off(ndev); 3465 netif_carrier_off(ndev);
3435 fec_enet_clk_enable(ndev, false); 3466 fec_enet_clk_enable(ndev, false);
3436 pinctrl_pm_select_sleep_state(&pdev->dev); 3467 pinctrl_pm_select_sleep_state(&pdev->dev);
3468 pm_runtime_set_active(&pdev->dev);
3469 pm_runtime_enable(&pdev->dev);
3437 3470
3438 ret = register_netdev(ndev); 3471 ret = register_netdev(ndev);
3439 if (ret) 3472 if (ret)
@@ -3447,6 +3480,12 @@ fec_probe(struct platform_device *pdev)
3447 3480
3448 fep->rx_copybreak = COPYBREAK_DEFAULT; 3481 fep->rx_copybreak = COPYBREAK_DEFAULT;
3449 INIT_WORK(&fep->tx_timeout_work, fec_enet_timeout_work); 3482 INIT_WORK(&fep->tx_timeout_work, fec_enet_timeout_work);
3483
3484 pm_runtime_set_autosuspend_delay(&pdev->dev, FEC_MDIO_PM_TIMEOUT);
3485 pm_runtime_use_autosuspend(&pdev->dev);
3486 pm_runtime_mark_last_busy(&pdev->dev);
3487 pm_runtime_put_autosuspend(&pdev->dev);
3488
3450 return 0; 3489 return 0;
3451 3490
3452failed_register: 3491failed_register:
@@ -3457,6 +3496,8 @@ failed_init:
3457 if (fep->reg_phy) 3496 if (fep->reg_phy)
3458 regulator_disable(fep->reg_phy); 3497 regulator_disable(fep->reg_phy);
3459failed_regulator: 3498failed_regulator:
3499 clk_disable_unprepare(fep->clk_ipg);
3500failed_clk_ipg:
3460 fec_enet_clk_enable(ndev, false); 3501 fec_enet_clk_enable(ndev, false);
3461failed_clk: 3502failed_clk:
3462failed_phy: 3503failed_phy:
@@ -3568,7 +3609,28 @@ failed_clk:
3568 return ret; 3609 return ret;
3569} 3610}
3570 3611
3571static SIMPLE_DEV_PM_OPS(fec_pm_ops, fec_suspend, fec_resume); 3612static int __maybe_unused fec_runtime_suspend(struct device *dev)
3613{
3614 struct net_device *ndev = dev_get_drvdata(dev);
3615 struct fec_enet_private *fep = netdev_priv(ndev);
3616
3617 clk_disable_unprepare(fep->clk_ipg);
3618
3619 return 0;
3620}
3621
3622static int __maybe_unused fec_runtime_resume(struct device *dev)
3623{
3624 struct net_device *ndev = dev_get_drvdata(dev);
3625 struct fec_enet_private *fep = netdev_priv(ndev);
3626
3627 return clk_prepare_enable(fep->clk_ipg);
3628}
3629
3630static const struct dev_pm_ops fec_pm_ops = {
3631 SET_SYSTEM_SLEEP_PM_OPS(fec_suspend, fec_resume)
3632 SET_RUNTIME_PM_OPS(fec_runtime_suspend, fec_runtime_resume, NULL)
3633};
3572 3634
3573static struct platform_driver fec_driver = { 3635static struct platform_driver fec_driver = {
3574 .driver = { 3636 .driver = {
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 847643455468..605cc8948594 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -101,6 +101,11 @@ static unsigned int efx_ef10_mem_map_size(struct efx_nic *efx)
101 return resource_size(&efx->pci_dev->resource[bar]); 101 return resource_size(&efx->pci_dev->resource[bar]);
102} 102}
103 103
104static bool efx_ef10_is_vf(struct efx_nic *efx)
105{
106 return efx->type->is_vf;
107}
108
104static int efx_ef10_get_pf_index(struct efx_nic *efx) 109static int efx_ef10_get_pf_index(struct efx_nic *efx)
105{ 110{
106 MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_FUNCTION_INFO_OUT_LEN); 111 MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_FUNCTION_INFO_OUT_LEN);
@@ -677,6 +682,48 @@ static int efx_ef10_probe_pf(struct efx_nic *efx)
677 return efx_ef10_probe(efx); 682 return efx_ef10_probe(efx);
678} 683}
679 684
685int efx_ef10_vadaptor_alloc(struct efx_nic *efx, unsigned int port_id)
686{
687 MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_ALLOC_IN_LEN);
688
689 MCDI_SET_DWORD(inbuf, VADAPTOR_ALLOC_IN_UPSTREAM_PORT_ID, port_id);
690 return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_ALLOC, inbuf, sizeof(inbuf),
691 NULL, 0, NULL);
692}
693
694int efx_ef10_vadaptor_free(struct efx_nic *efx, unsigned int port_id)
695{
696 MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_FREE_IN_LEN);
697
698 MCDI_SET_DWORD(inbuf, VADAPTOR_FREE_IN_UPSTREAM_PORT_ID, port_id);
699 return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_FREE, inbuf, sizeof(inbuf),
700 NULL, 0, NULL);
701}
702
703int efx_ef10_vport_add_mac(struct efx_nic *efx,
704 unsigned int port_id, u8 *mac)
705{
706 MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_ADD_MAC_ADDRESS_IN_LEN);
707
708 MCDI_SET_DWORD(inbuf, VPORT_ADD_MAC_ADDRESS_IN_VPORT_ID, port_id);
709 ether_addr_copy(MCDI_PTR(inbuf, VPORT_ADD_MAC_ADDRESS_IN_MACADDR), mac);
710
711 return efx_mcdi_rpc(efx, MC_CMD_VPORT_ADD_MAC_ADDRESS, inbuf,
712 sizeof(inbuf), NULL, 0, NULL);
713}
714
715int efx_ef10_vport_del_mac(struct efx_nic *efx,
716 unsigned int port_id, u8 *mac)
717{
718 MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_DEL_MAC_ADDRESS_IN_LEN);
719
720 MCDI_SET_DWORD(inbuf, VPORT_DEL_MAC_ADDRESS_IN_VPORT_ID, port_id);
721 ether_addr_copy(MCDI_PTR(inbuf, VPORT_DEL_MAC_ADDRESS_IN_MACADDR), mac);
722
723 return efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf,
724 sizeof(inbuf), NULL, 0, NULL);
725}
726
680#ifdef CONFIG_SFC_SRIOV 727#ifdef CONFIG_SFC_SRIOV
681static int efx_ef10_probe_vf(struct efx_nic *efx) 728static int efx_ef10_probe_vf(struct efx_nic *efx)
682{ 729{
@@ -3804,6 +3851,72 @@ static void efx_ef10_filter_sync_rx_mode(struct efx_nic *efx)
3804 WARN_ON(remove_failed); 3851 WARN_ON(remove_failed);
3805} 3852}
3806 3853
3854static int efx_ef10_vport_set_mac_address(struct efx_nic *efx)
3855{
3856 struct efx_ef10_nic_data *nic_data = efx->nic_data;
3857 u8 mac_old[ETH_ALEN];
3858 int rc, rc2;
3859
3860 /* Only reconfigure a PF-created vport */
3861 if (is_zero_ether_addr(nic_data->vport_mac))
3862 return 0;
3863
3864 efx_device_detach_sync(efx);
3865 efx_net_stop(efx->net_dev);
3866 down_write(&efx->filter_sem);
3867 efx_ef10_filter_table_remove(efx);
3868 up_write(&efx->filter_sem);
3869
3870 rc = efx_ef10_vadaptor_free(efx, nic_data->vport_id);
3871 if (rc)
3872 goto restore_filters;
3873
3874 ether_addr_copy(mac_old, nic_data->vport_mac);
3875 rc = efx_ef10_vport_del_mac(efx, nic_data->vport_id,
3876 nic_data->vport_mac);
3877 if (rc)
3878 goto restore_vadaptor;
3879
3880 rc = efx_ef10_vport_add_mac(efx, nic_data->vport_id,
3881 efx->net_dev->dev_addr);
3882 if (!rc) {
3883 ether_addr_copy(nic_data->vport_mac, efx->net_dev->dev_addr);
3884 } else {
3885 rc2 = efx_ef10_vport_add_mac(efx, nic_data->vport_id, mac_old);
3886 if (rc2) {
3887 /* Failed to add original MAC, so clear vport_mac */
3888 eth_zero_addr(nic_data->vport_mac);
3889 goto reset_nic;
3890 }
3891 }
3892
3893restore_vadaptor:
3894 rc2 = efx_ef10_vadaptor_alloc(efx, nic_data->vport_id);
3895 if (rc2)
3896 goto reset_nic;
3897restore_filters:
3898 down_write(&efx->filter_sem);
3899 rc2 = efx_ef10_filter_table_probe(efx);
3900 up_write(&efx->filter_sem);
3901 if (rc2)
3902 goto reset_nic;
3903
3904 rc2 = efx_net_open(efx->net_dev);
3905 if (rc2)
3906 goto reset_nic;
3907
3908 netif_device_attach(efx->net_dev);
3909
3910 return rc;
3911
3912reset_nic:
3913 netif_err(efx, drv, efx->net_dev,
3914 "Failed to restore when changing MAC address - scheduling reset\n");
3915 efx_schedule_reset(efx, RESET_TYPE_DATAPATH);
3916
3917 return rc ? rc : rc2;
3918}
3919
3807static int efx_ef10_set_mac_address(struct efx_nic *efx) 3920static int efx_ef10_set_mac_address(struct efx_nic *efx)
3808{ 3921{
3809 MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_SET_MAC_IN_LEN); 3922 MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_SET_MAC_IN_LEN);
@@ -3820,8 +3933,8 @@ static int efx_ef10_set_mac_address(struct efx_nic *efx)
3820 efx->net_dev->dev_addr); 3933 efx->net_dev->dev_addr);
3821 MCDI_SET_DWORD(inbuf, VADAPTOR_SET_MAC_IN_UPSTREAM_PORT_ID, 3934 MCDI_SET_DWORD(inbuf, VADAPTOR_SET_MAC_IN_UPSTREAM_PORT_ID,
3822 nic_data->vport_id); 3935 nic_data->vport_id);
3823 rc = efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_SET_MAC, inbuf, 3936 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_VADAPTOR_SET_MAC, inbuf,
3824 sizeof(inbuf), NULL, 0, NULL); 3937 sizeof(inbuf), NULL, 0, NULL);
3825 3938
3826 efx_ef10_filter_table_probe(efx); 3939 efx_ef10_filter_table_probe(efx);
3827 up_write(&efx->filter_sem); 3940 up_write(&efx->filter_sem);
@@ -3829,38 +3942,27 @@ static int efx_ef10_set_mac_address(struct efx_nic *efx)
3829 efx_net_open(efx->net_dev); 3942 efx_net_open(efx->net_dev);
3830 netif_device_attach(efx->net_dev); 3943 netif_device_attach(efx->net_dev);
3831 3944
3832#if !defined(CONFIG_SFC_SRIOV) 3945#ifdef CONFIG_SFC_SRIOV
3833 if (rc == -EPERM) 3946 if (efx->pci_dev->is_virtfn && efx->pci_dev->physfn) {
3834 netif_err(efx, drv, efx->net_dev,
3835 "Cannot change MAC address; use sfboot to enable mac-spoofing"
3836 " on this interface\n");
3837#else
3838 if (rc == -EPERM) {
3839 struct pci_dev *pci_dev_pf = efx->pci_dev->physfn; 3947 struct pci_dev *pci_dev_pf = efx->pci_dev->physfn;
3840 3948
3841 /* Switch to PF and change MAC address on vport */ 3949 if (rc == -EPERM) {
3842 if (efx->pci_dev->is_virtfn && pci_dev_pf) { 3950 struct efx_nic *efx_pf;
3843 struct efx_nic *efx_pf = pci_get_drvdata(pci_dev_pf);
3844 3951
3845 if (!efx_ef10_sriov_set_vf_mac(efx_pf, 3952 /* Switch to PF and change MAC address on vport */
3846 nic_data->vf_index, 3953 efx_pf = pci_get_drvdata(pci_dev_pf);
3847 efx->net_dev->dev_addr))
3848 return 0;
3849 }
3850 netif_err(efx, drv, efx->net_dev,
3851 "Cannot change MAC address; use sfboot to enable mac-spoofing"
3852 " on this interface\n");
3853 } else if (efx->pci_dev->is_virtfn) {
3854 /* Successfully changed by VF (with MAC spoofing), so update the
3855 * parent PF if possible.
3856 */
3857 struct pci_dev *pci_dev_pf = efx->pci_dev->physfn;
3858 3954
3859 if (pci_dev_pf) { 3955 rc = efx_ef10_sriov_set_vf_mac(efx_pf,
3956 nic_data->vf_index,
3957 efx->net_dev->dev_addr);
3958 } else if (!rc) {
3860 struct efx_nic *efx_pf = pci_get_drvdata(pci_dev_pf); 3959 struct efx_nic *efx_pf = pci_get_drvdata(pci_dev_pf);
3861 struct efx_ef10_nic_data *nic_data = efx_pf->nic_data; 3960 struct efx_ef10_nic_data *nic_data = efx_pf->nic_data;
3862 unsigned int i; 3961 unsigned int i;
3863 3962
3963 /* MAC address successfully changed by VF (with MAC
3964 * spoofing) so update the parent PF if possible.
3965 */
3864 for (i = 0; i < efx_pf->vf_count; ++i) { 3966 for (i = 0; i < efx_pf->vf_count; ++i) {
3865 struct ef10_vf *vf = nic_data->vf + i; 3967 struct ef10_vf *vf = nic_data->vf + i;
3866 3968
@@ -3871,8 +3973,24 @@ static int efx_ef10_set_mac_address(struct efx_nic *efx)
3871 } 3973 }
3872 } 3974 }
3873 } 3975 }
3874 } 3976 } else
3875#endif 3977#endif
3978 if (rc == -EPERM) {
3979 netif_err(efx, drv, efx->net_dev,
3980 "Cannot change MAC address; use sfboot to enable"
3981 " mac-spoofing on this interface\n");
3982 } else if (rc == -ENOSYS && !efx_ef10_is_vf(efx)) {
3983 /* If the active MCFW does not support MC_CMD_VADAPTOR_SET_MAC
3984 * fall-back to the method of changing the MAC address on the
3985 * vport. This only applies to PFs because such versions of
3986 * MCFW do not support VFs.
3987 */
3988 rc = efx_ef10_vport_set_mac_address(efx);
3989 } else {
3990 efx_mcdi_display_error(efx, MC_CMD_VADAPTOR_SET_MAC,
3991 sizeof(inbuf), NULL, 0, rc);
3992 }
3993
3876 return rc; 3994 return rc;
3877} 3995}
3878 3996
diff --git a/drivers/net/ethernet/sfc/ef10_sriov.c b/drivers/net/ethernet/sfc/ef10_sriov.c
index 6c9b6e45509a..3c17f274e802 100644
--- a/drivers/net/ethernet/sfc/ef10_sriov.c
+++ b/drivers/net/ethernet/sfc/ef10_sriov.c
@@ -29,30 +29,6 @@ static int efx_ef10_evb_port_assign(struct efx_nic *efx, unsigned int port_id,
29 NULL, 0, NULL); 29 NULL, 0, NULL);
30} 30}
31 31
32static int efx_ef10_vport_add_mac(struct efx_nic *efx,
33 unsigned int port_id, u8 *mac)
34{
35 MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_ADD_MAC_ADDRESS_IN_LEN);
36
37 MCDI_SET_DWORD(inbuf, VPORT_ADD_MAC_ADDRESS_IN_VPORT_ID, port_id);
38 ether_addr_copy(MCDI_PTR(inbuf, VPORT_ADD_MAC_ADDRESS_IN_MACADDR), mac);
39
40 return efx_mcdi_rpc(efx, MC_CMD_VPORT_ADD_MAC_ADDRESS, inbuf,
41 sizeof(inbuf), NULL, 0, NULL);
42}
43
44static int efx_ef10_vport_del_mac(struct efx_nic *efx,
45 unsigned int port_id, u8 *mac)
46{
47 MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_DEL_MAC_ADDRESS_IN_LEN);
48
49 MCDI_SET_DWORD(inbuf, VPORT_DEL_MAC_ADDRESS_IN_VPORT_ID, port_id);
50 ether_addr_copy(MCDI_PTR(inbuf, VPORT_DEL_MAC_ADDRESS_IN_MACADDR), mac);
51
52 return efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf,
53 sizeof(inbuf), NULL, 0, NULL);
54}
55
56static int efx_ef10_vswitch_alloc(struct efx_nic *efx, unsigned int port_id, 32static int efx_ef10_vswitch_alloc(struct efx_nic *efx, unsigned int port_id,
57 unsigned int vswitch_type) 33 unsigned int vswitch_type)
58{ 34{
@@ -136,24 +112,6 @@ static int efx_ef10_vport_free(struct efx_nic *efx, unsigned int port_id)
136 NULL, 0, NULL); 112 NULL, 0, NULL);
137} 113}
138 114
139static int efx_ef10_vadaptor_alloc(struct efx_nic *efx, unsigned int port_id)
140{
141 MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_ALLOC_IN_LEN);
142
143 MCDI_SET_DWORD(inbuf, VADAPTOR_ALLOC_IN_UPSTREAM_PORT_ID, port_id);
144 return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_ALLOC, inbuf, sizeof(inbuf),
145 NULL, 0, NULL);
146}
147
148static int efx_ef10_vadaptor_free(struct efx_nic *efx, unsigned int port_id)
149{
150 MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_FREE_IN_LEN);
151
152 MCDI_SET_DWORD(inbuf, VADAPTOR_FREE_IN_UPSTREAM_PORT_ID, port_id);
153 return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_FREE, inbuf, sizeof(inbuf),
154 NULL, 0, NULL);
155}
156
157static void efx_ef10_sriov_free_vf_vports(struct efx_nic *efx) 115static void efx_ef10_sriov_free_vf_vports(struct efx_nic *efx)
158{ 116{
159 struct efx_ef10_nic_data *nic_data = efx->nic_data; 117 struct efx_ef10_nic_data *nic_data = efx->nic_data;
@@ -640,21 +598,21 @@ int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan,
640 MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_NORMAL, 598 MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_NORMAL,
641 vf->vlan, &vf->vport_id); 599 vf->vlan, &vf->vport_id);
642 if (rc) 600 if (rc)
643 goto reset_nic; 601 goto reset_nic_up_write;
644 602
645restore_mac: 603restore_mac:
646 if (!is_zero_ether_addr(vf->mac)) { 604 if (!is_zero_ether_addr(vf->mac)) {
647 rc2 = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac); 605 rc2 = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac);
648 if (rc2) { 606 if (rc2) {
649 eth_zero_addr(vf->mac); 607 eth_zero_addr(vf->mac);
650 goto reset_nic; 608 goto reset_nic_up_write;
651 } 609 }
652 } 610 }
653 611
654restore_evb_port: 612restore_evb_port:
655 rc2 = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); 613 rc2 = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
656 if (rc2) 614 if (rc2)
657 goto reset_nic; 615 goto reset_nic_up_write;
658 else 616 else
659 vf->vport_assigned = 1; 617 vf->vport_assigned = 1;
660 618
@@ -662,14 +620,16 @@ restore_vadaptor:
662 if (vf->efx) { 620 if (vf->efx) {
663 rc2 = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); 621 rc2 = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED);
664 if (rc2) 622 if (rc2)
665 goto reset_nic; 623 goto reset_nic_up_write;
666 } 624 }
667 625
668restore_filters: 626restore_filters:
669 if (vf->efx) { 627 if (vf->efx) {
670 rc2 = vf->efx->type->filter_table_probe(vf->efx); 628 rc2 = vf->efx->type->filter_table_probe(vf->efx);
671 if (rc2) 629 if (rc2)
672 goto reset_nic; 630 goto reset_nic_up_write;
631
632 up_write(&vf->efx->filter_sem);
673 633
674 up_write(&vf->efx->filter_sem); 634 up_write(&vf->efx->filter_sem);
675 635
@@ -681,9 +641,12 @@ restore_filters:
681 } 641 }
682 return rc; 642 return rc;
683 643
644reset_nic_up_write:
645 if (vf->efx)
646 up_write(&vf->efx->filter_sem);
647
684reset_nic: 648reset_nic:
685 if (vf->efx) { 649 if (vf->efx) {
686 up_write(&vf->efx->filter_sem);
687 netif_err(efx, drv, efx->net_dev, 650 netif_err(efx, drv, efx->net_dev,
688 "Failed to restore VF - scheduling reset.\n"); 651 "Failed to restore VF - scheduling reset.\n");
689 efx_schedule_reset(vf->efx, RESET_TYPE_DATAPATH); 652 efx_schedule_reset(vf->efx, RESET_TYPE_DATAPATH);
diff --git a/drivers/net/ethernet/sfc/ef10_sriov.h b/drivers/net/ethernet/sfc/ef10_sriov.h
index db4ef537c610..6d25b92cb45e 100644
--- a/drivers/net/ethernet/sfc/ef10_sriov.h
+++ b/drivers/net/ethernet/sfc/ef10_sriov.h
@@ -65,5 +65,11 @@ int efx_ef10_vswitching_restore_pf(struct efx_nic *efx);
65int efx_ef10_vswitching_restore_vf(struct efx_nic *efx); 65int efx_ef10_vswitching_restore_vf(struct efx_nic *efx);
66void efx_ef10_vswitching_remove_pf(struct efx_nic *efx); 66void efx_ef10_vswitching_remove_pf(struct efx_nic *efx);
67void efx_ef10_vswitching_remove_vf(struct efx_nic *efx); 67void efx_ef10_vswitching_remove_vf(struct efx_nic *efx);
68int efx_ef10_vport_add_mac(struct efx_nic *efx,
69 unsigned int port_id, u8 *mac);
70int efx_ef10_vport_del_mac(struct efx_nic *efx,
71 unsigned int port_id, u8 *mac);
72int efx_ef10_vadaptor_alloc(struct efx_nic *efx, unsigned int port_id);
73int efx_ef10_vadaptor_free(struct efx_nic *efx, unsigned int port_id);
68 74
69#endif /* EF10_SRIOV_H */ 75#endif /* EF10_SRIOV_H */
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index 804b9ad553d3..03bc03b67f08 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -245,11 +245,17 @@ static int efx_check_disabled(struct efx_nic *efx)
245 */ 245 */
246static int efx_process_channel(struct efx_channel *channel, int budget) 246static int efx_process_channel(struct efx_channel *channel, int budget)
247{ 247{
248 struct efx_tx_queue *tx_queue;
248 int spent; 249 int spent;
249 250
250 if (unlikely(!channel->enabled)) 251 if (unlikely(!channel->enabled))
251 return 0; 252 return 0;
252 253
254 efx_for_each_channel_tx_queue(tx_queue, channel) {
255 tx_queue->pkts_compl = 0;
256 tx_queue->bytes_compl = 0;
257 }
258
253 spent = efx_nic_process_eventq(channel, budget); 259 spent = efx_nic_process_eventq(channel, budget);
254 if (spent && efx_channel_has_rx_queue(channel)) { 260 if (spent && efx_channel_has_rx_queue(channel)) {
255 struct efx_rx_queue *rx_queue = 261 struct efx_rx_queue *rx_queue =
@@ -259,6 +265,14 @@ static int efx_process_channel(struct efx_channel *channel, int budget)
259 efx_fast_push_rx_descriptors(rx_queue, true); 265 efx_fast_push_rx_descriptors(rx_queue, true);
260 } 266 }
261 267
268 /* Update BQL */
269 efx_for_each_channel_tx_queue(tx_queue, channel) {
270 if (tx_queue->bytes_compl) {
271 netdev_tx_completed_queue(tx_queue->core_txq,
272 tx_queue->pkts_compl, tx_queue->bytes_compl);
273 }
274 }
275
262 return spent; 276 return spent;
263} 277}
264 278
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
index d72f522bf9c3..47d1e3a96522 100644
--- a/drivers/net/ethernet/sfc/net_driver.h
+++ b/drivers/net/ethernet/sfc/net_driver.h
@@ -241,6 +241,8 @@ struct efx_tx_queue {
241 unsigned int read_count ____cacheline_aligned_in_smp; 241 unsigned int read_count ____cacheline_aligned_in_smp;
242 unsigned int old_write_count; 242 unsigned int old_write_count;
243 unsigned int merge_events; 243 unsigned int merge_events;
244 unsigned int bytes_compl;
245 unsigned int pkts_compl;
244 246
245 /* Members used only on the xmit path */ 247 /* Members used only on the xmit path */
246 unsigned int insert_count ____cacheline_aligned_in_smp; 248 unsigned int insert_count ____cacheline_aligned_in_smp;
diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c
index aaf2987512b5..1833a0146571 100644
--- a/drivers/net/ethernet/sfc/tx.c
+++ b/drivers/net/ethernet/sfc/tx.c
@@ -617,7 +617,8 @@ void efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index)
617 EFX_BUG_ON_PARANOID(index > tx_queue->ptr_mask); 617 EFX_BUG_ON_PARANOID(index > tx_queue->ptr_mask);
618 618
619 efx_dequeue_buffers(tx_queue, index, &pkts_compl, &bytes_compl); 619 efx_dequeue_buffers(tx_queue, index, &pkts_compl, &bytes_compl);
620 netdev_tx_completed_queue(tx_queue->core_txq, pkts_compl, bytes_compl); 620 tx_queue->pkts_compl += pkts_compl;
621 tx_queue->bytes_compl += bytes_compl;
621 622
622 if (pkts_compl > 1) 623 if (pkts_compl > 1)
623 ++tx_queue->merge_events; 624 ++tx_queue->merge_events;
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 462820514fae..f335bf119ab5 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -138,19 +138,6 @@ do { \
138#define CPSW_CMINTMAX_INTVL (1000 / CPSW_CMINTMIN_CNT) 138#define CPSW_CMINTMAX_INTVL (1000 / CPSW_CMINTMIN_CNT)
139#define CPSW_CMINTMIN_INTVL ((1000 / CPSW_CMINTMAX_CNT) + 1) 139#define CPSW_CMINTMIN_INTVL ((1000 / CPSW_CMINTMAX_CNT) + 1)
140 140
141#define cpsw_enable_irq(priv) \
142 do { \
143 u32 i; \
144 for (i = 0; i < priv->num_irqs; i++) \
145 enable_irq(priv->irqs_table[i]); \
146 } while (0)
147#define cpsw_disable_irq(priv) \
148 do { \
149 u32 i; \
150 for (i = 0; i < priv->num_irqs; i++) \
151 disable_irq_nosync(priv->irqs_table[i]); \
152 } while (0)
153
154#define cpsw_slave_index(priv) \ 141#define cpsw_slave_index(priv) \
155 ((priv->data.dual_emac) ? priv->emac_port : \ 142 ((priv->data.dual_emac) ? priv->emac_port : \
156 priv->data.active_slave) 143 priv->data.active_slave)
@@ -509,9 +496,11 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = {
509 (func)(slave++, ##arg); \ 496 (func)(slave++, ##arg); \
510 } while (0) 497 } while (0)
511#define cpsw_get_slave_ndev(priv, __slave_no__) \ 498#define cpsw_get_slave_ndev(priv, __slave_no__) \
512 (priv->slaves[__slave_no__].ndev) 499 ((__slave_no__ < priv->data.slaves) ? \
500 priv->slaves[__slave_no__].ndev : NULL)
513#define cpsw_get_slave_priv(priv, __slave_no__) \ 501#define cpsw_get_slave_priv(priv, __slave_no__) \
514 ((priv->slaves[__slave_no__].ndev) ? \ 502 (((__slave_no__ < priv->data.slaves) && \
503 (priv->slaves[__slave_no__].ndev)) ? \
515 netdev_priv(priv->slaves[__slave_no__].ndev) : NULL) \ 504 netdev_priv(priv->slaves[__slave_no__].ndev) : NULL) \
516 505
517#define cpsw_dual_emac_src_port_detect(status, priv, ndev, skb) \ 506#define cpsw_dual_emac_src_port_detect(status, priv, ndev, skb) \
@@ -781,7 +770,7 @@ static irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id)
781 770
782 cpsw_intr_disable(priv); 771 cpsw_intr_disable(priv);
783 if (priv->irq_enabled == true) { 772 if (priv->irq_enabled == true) {
784 cpsw_disable_irq(priv); 773 disable_irq_nosync(priv->irqs_table[0]);
785 priv->irq_enabled = false; 774 priv->irq_enabled = false;
786 } 775 }
787 776
@@ -817,7 +806,7 @@ static int cpsw_poll(struct napi_struct *napi, int budget)
817 prim_cpsw = cpsw_get_slave_priv(priv, 0); 806 prim_cpsw = cpsw_get_slave_priv(priv, 0);
818 if (prim_cpsw->irq_enabled == false) { 807 if (prim_cpsw->irq_enabled == false) {
819 prim_cpsw->irq_enabled = true; 808 prim_cpsw->irq_enabled = true;
820 cpsw_enable_irq(priv); 809 enable_irq(priv->irqs_table[0]);
821 } 810 }
822 } 811 }
823 812
@@ -1333,7 +1322,7 @@ static int cpsw_ndo_open(struct net_device *ndev)
1333 if (prim_cpsw->irq_enabled == false) { 1322 if (prim_cpsw->irq_enabled == false) {
1334 if ((priv == prim_cpsw) || !netif_running(prim_cpsw->ndev)) { 1323 if ((priv == prim_cpsw) || !netif_running(prim_cpsw->ndev)) {
1335 prim_cpsw->irq_enabled = true; 1324 prim_cpsw->irq_enabled = true;
1336 cpsw_enable_irq(prim_cpsw); 1325 enable_irq(prim_cpsw->irqs_table[0]);
1337 } 1326 }
1338 } 1327 }
1339 1328
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 4208dd7ef101..d95f9aae95e7 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -1530,9 +1530,9 @@ static int axienet_probe(struct platform_device *pdev)
1530 /* Map device registers */ 1530 /* Map device registers */
1531 ethres = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1531 ethres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1532 lp->regs = devm_ioremap_resource(&pdev->dev, ethres); 1532 lp->regs = devm_ioremap_resource(&pdev->dev, ethres);
1533 if (!lp->regs) { 1533 if (IS_ERR(lp->regs)) {
1534 dev_err(&pdev->dev, "could not map Axi Ethernet regs.\n"); 1534 dev_err(&pdev->dev, "could not map Axi Ethernet regs.\n");
1535 ret = -ENOMEM; 1535 ret = PTR_ERR(lp->regs);
1536 goto free_netdev; 1536 goto free_netdev;
1537 } 1537 }
1538 1538
@@ -1599,9 +1599,9 @@ static int axienet_probe(struct platform_device *pdev)
1599 goto free_netdev; 1599 goto free_netdev;
1600 } 1600 }
1601 lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares); 1601 lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares);
1602 if (!lp->dma_regs) { 1602 if (IS_ERR(lp->dma_regs)) {
1603 dev_err(&pdev->dev, "could not map DMA regs\n"); 1603 dev_err(&pdev->dev, "could not map DMA regs\n");
1604 ret = -ENOMEM; 1604 ret = PTR_ERR(lp->dma_regs);
1605 goto free_netdev; 1605 goto free_netdev;
1606 } 1606 }
1607 lp->rx_irq = irq_of_parse_and_map(np, 1); 1607 lp->rx_irq = irq_of_parse_and_map(np, 1);
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index 7856b6ccf5c5..d95a50ae996d 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -482,6 +482,7 @@ static void bpq_setup(struct net_device *dev)
482 memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN); 482 memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN);
483 483
484 dev->flags = 0; 484 dev->flags = 0;
485 dev->features = NETIF_F_LLTX; /* Allow recursion */
485 486
486#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 487#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
487 dev->header_ops = &ax25_header_ops; 488 dev->header_ops = &ax25_header_ops;
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index f8370808a018..3b933bb5a8d5 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -1355,6 +1355,7 @@ static void macvtap_exit(void)
1355 class_unregister(macvtap_class); 1355 class_unregister(macvtap_class);
1356 cdev_del(&macvtap_cdev); 1356 cdev_del(&macvtap_cdev);
1357 unregister_chrdev_region(macvtap_major, MACVTAP_NUM_DEVS); 1357 unregister_chrdev_region(macvtap_major, MACVTAP_NUM_DEVS);
1358 idr_destroy(&minor_idr);
1358} 1359}
1359module_exit(macvtap_exit); 1360module_exit(macvtap_exit);
1360 1361
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index cf18940f4e84..cb86d7a01542 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -191,7 +191,7 @@ config MDIO_BUS_MUX_GPIO
191 191
192config MDIO_BUS_MUX_MMIOREG 192config MDIO_BUS_MUX_MMIOREG
193 tristate "Support for MMIO device-controlled MDIO bus multiplexers" 193 tristate "Support for MMIO device-controlled MDIO bus multiplexers"
194 depends on OF_MDIO 194 depends on OF_MDIO && HAS_IOMEM
195 select MDIO_BUS_MUX 195 select MDIO_BUS_MUX
196 help 196 help
197 This module provides a driver for MDIO bus multiplexers that 197 This module provides a driver for MDIO bus multiplexers that
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 4545e78840b0..35a2bffe848a 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -523,6 +523,7 @@ static const struct driver_info wwan_info = {
523#define REALTEK_VENDOR_ID 0x0bda 523#define REALTEK_VENDOR_ID 0x0bda
524#define SAMSUNG_VENDOR_ID 0x04e8 524#define SAMSUNG_VENDOR_ID 0x04e8
525#define LENOVO_VENDOR_ID 0x17ef 525#define LENOVO_VENDOR_ID 0x17ef
526#define NVIDIA_VENDOR_ID 0x0955
526 527
527static const struct usb_device_id products[] = { 528static const struct usb_device_id products[] = {
528/* BLACKLIST !! 529/* BLACKLIST !!
@@ -710,6 +711,13 @@ static const struct usb_device_id products[] = {
710 .driver_info = 0, 711 .driver_info = 0,
711}, 712},
712 713
714/* NVIDIA Tegra USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */
715{
716 USB_DEVICE_AND_INTERFACE_INFO(NVIDIA_VENDOR_ID, 0x09ff, USB_CLASS_COMM,
717 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
718 .driver_info = 0,
719},
720
713/* WHITELIST!!! 721/* WHITELIST!!!
714 * 722 *
715 * CDC Ether uses two interfaces, not necessarily consecutive. 723 * CDC Ether uses two interfaces, not necessarily consecutive.
diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
index e4b7a47a825c..efc18e05af0a 100644
--- a/drivers/net/usb/cdc_mbim.c
+++ b/drivers/net/usb/cdc_mbim.c
@@ -158,7 +158,7 @@ static int cdc_mbim_bind(struct usbnet *dev, struct usb_interface *intf)
158 if (!cdc_ncm_comm_intf_is_mbim(intf->cur_altsetting)) 158 if (!cdc_ncm_comm_intf_is_mbim(intf->cur_altsetting))
159 goto err; 159 goto err;
160 160
161 ret = cdc_ncm_bind_common(dev, intf, data_altsetting); 161 ret = cdc_ncm_bind_common(dev, intf, data_altsetting, 0);
162 if (ret) 162 if (ret)
163 goto err; 163 goto err;
164 164
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 8067b8fbb0ee..db40175b1a0b 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -6,7 +6,7 @@
6 * Original author: Hans Petter Selasky <hans.petter.selasky@stericsson.com> 6 * Original author: Hans Petter Selasky <hans.petter.selasky@stericsson.com>
7 * 7 *
8 * USB Host Driver for Network Control Model (NCM) 8 * USB Host Driver for Network Control Model (NCM)
9 * http://www.usb.org/developers/devclass_docs/NCM10.zip 9 * http://www.usb.org/developers/docs/devclass_docs/NCM10_012011.zip
10 * 10 *
11 * The NCM encoding, decoding and initialization logic 11 * The NCM encoding, decoding and initialization logic
12 * derives from FreeBSD 8.x. if_cdce.c and if_cdcereg.h 12 * derives from FreeBSD 8.x. if_cdce.c and if_cdcereg.h
@@ -684,10 +684,12 @@ static void cdc_ncm_free(struct cdc_ncm_ctx *ctx)
684 ctx->tx_curr_skb = NULL; 684 ctx->tx_curr_skb = NULL;
685 } 685 }
686 686
687 kfree(ctx->delayed_ndp16);
688
687 kfree(ctx); 689 kfree(ctx);
688} 690}
689 691
690int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting) 692int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting, int drvflags)
691{ 693{
692 const struct usb_cdc_union_desc *union_desc = NULL; 694 const struct usb_cdc_union_desc *union_desc = NULL;
693 struct cdc_ncm_ctx *ctx; 695 struct cdc_ncm_ctx *ctx;
@@ -855,6 +857,17 @@ advance:
855 /* finish setting up the device specific data */ 857 /* finish setting up the device specific data */
856 cdc_ncm_setup(dev); 858 cdc_ncm_setup(dev);
857 859
860 /* Device-specific flags */
861 ctx->drvflags = drvflags;
862
863 /* Allocate the delayed NDP if needed. */
864 if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) {
865 ctx->delayed_ndp16 = kzalloc(ctx->max_ndp_size, GFP_KERNEL);
866 if (!ctx->delayed_ndp16)
867 goto error2;
868 dev_info(&intf->dev, "NDP will be placed at end of frame for this device.");
869 }
870
858 /* override ethtool_ops */ 871 /* override ethtool_ops */
859 dev->net->ethtool_ops = &cdc_ncm_ethtool_ops; 872 dev->net->ethtool_ops = &cdc_ncm_ethtool_ops;
860 873
@@ -954,8 +967,11 @@ static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf)
954 if (cdc_ncm_select_altsetting(intf) != CDC_NCM_COMM_ALTSETTING_NCM) 967 if (cdc_ncm_select_altsetting(intf) != CDC_NCM_COMM_ALTSETTING_NCM)
955 return -ENODEV; 968 return -ENODEV;
956 969
957 /* The NCM data altsetting is fixed */ 970 /* The NCM data altsetting is fixed, so we hard-coded it.
958 ret = cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM); 971 * Additionally, generic NCM devices are assumed to accept arbitrarily
972 * placed NDP.
973 */
974 ret = cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM, 0);
959 975
960 /* 976 /*
961 * We should get an event when network connection is "connected" or 977 * We should get an event when network connection is "connected" or
@@ -986,6 +1002,14 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_
986 struct usb_cdc_ncm_nth16 *nth16 = (void *)skb->data; 1002 struct usb_cdc_ncm_nth16 *nth16 = (void *)skb->data;
987 size_t ndpoffset = le16_to_cpu(nth16->wNdpIndex); 1003 size_t ndpoffset = le16_to_cpu(nth16->wNdpIndex);
988 1004
1005 /* If NDP should be moved to the end of the NCM package, we can't follow the
1006 * NTH16 header as we would normally do. NDP isn't written to the SKB yet, and
1007 * the wNdpIndex field in the header is actually not consistent with reality. It will be later.
1008 */
1009 if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END)
1010 if (ctx->delayed_ndp16->dwSignature == sign)
1011 return ctx->delayed_ndp16;
1012
989 /* follow the chain of NDPs, looking for a match */ 1013 /* follow the chain of NDPs, looking for a match */
990 while (ndpoffset) { 1014 while (ndpoffset) {
991 ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb->data + ndpoffset); 1015 ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb->data + ndpoffset);
@@ -995,7 +1019,8 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_
995 } 1019 }
996 1020
997 /* align new NDP */ 1021 /* align new NDP */
998 cdc_ncm_align_tail(skb, ctx->tx_ndp_modulus, 0, ctx->tx_max); 1022 if (!(ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END))
1023 cdc_ncm_align_tail(skb, ctx->tx_ndp_modulus, 0, ctx->tx_max);
999 1024
1000 /* verify that there is room for the NDP and the datagram (reserve) */ 1025 /* verify that there is room for the NDP and the datagram (reserve) */
1001 if ((ctx->tx_max - skb->len - reserve) < ctx->max_ndp_size) 1026 if ((ctx->tx_max - skb->len - reserve) < ctx->max_ndp_size)
@@ -1008,7 +1033,11 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_
1008 nth16->wNdpIndex = cpu_to_le16(skb->len); 1033 nth16->wNdpIndex = cpu_to_le16(skb->len);
1009 1034
1010 /* push a new empty NDP */ 1035 /* push a new empty NDP */
1011 ndp16 = (struct usb_cdc_ncm_ndp16 *)memset(skb_put(skb, ctx->max_ndp_size), 0, ctx->max_ndp_size); 1036 if (!(ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END))
1037 ndp16 = (struct usb_cdc_ncm_ndp16 *)memset(skb_put(skb, ctx->max_ndp_size), 0, ctx->max_ndp_size);
1038 else
1039 ndp16 = ctx->delayed_ndp16;
1040
1012 ndp16->dwSignature = sign; 1041 ndp16->dwSignature = sign;
1013 ndp16->wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16)); 1042 ndp16->wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16));
1014 return ndp16; 1043 return ndp16;
@@ -1023,6 +1052,15 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
1023 struct sk_buff *skb_out; 1052 struct sk_buff *skb_out;
1024 u16 n = 0, index, ndplen; 1053 u16 n = 0, index, ndplen;
1025 u8 ready2send = 0; 1054 u8 ready2send = 0;
1055 u32 delayed_ndp_size;
1056
1057 /* When our NDP gets written in cdc_ncm_ndp(), then skb_out->len gets updated
1058 * accordingly. Otherwise, we should check here.
1059 */
1060 if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END)
1061 delayed_ndp_size = ctx->max_ndp_size;
1062 else
1063 delayed_ndp_size = 0;
1026 1064
1027 /* if there is a remaining skb, it gets priority */ 1065 /* if there is a remaining skb, it gets priority */
1028 if (skb != NULL) { 1066 if (skb != NULL) {
@@ -1077,7 +1115,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
1077 cdc_ncm_align_tail(skb_out, ctx->tx_modulus, ctx->tx_remainder, ctx->tx_max); 1115 cdc_ncm_align_tail(skb_out, ctx->tx_modulus, ctx->tx_remainder, ctx->tx_max);
1078 1116
1079 /* check if we had enough room left for both NDP and frame */ 1117 /* check if we had enough room left for both NDP and frame */
1080 if (!ndp16 || skb_out->len + skb->len > ctx->tx_max) { 1118 if (!ndp16 || skb_out->len + skb->len + delayed_ndp_size > ctx->tx_max) {
1081 if (n == 0) { 1119 if (n == 0) {
1082 /* won't fit, MTU problem? */ 1120 /* won't fit, MTU problem? */
1083 dev_kfree_skb_any(skb); 1121 dev_kfree_skb_any(skb);
@@ -1150,6 +1188,17 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
1150 /* variables will be reset at next call */ 1188 /* variables will be reset at next call */
1151 } 1189 }
1152 1190
1191 /* If requested, put NDP at end of frame. */
1192 if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) {
1193 nth16 = (struct usb_cdc_ncm_nth16 *)skb_out->data;
1194 cdc_ncm_align_tail(skb_out, ctx->tx_ndp_modulus, 0, ctx->tx_max);
1195 nth16->wNdpIndex = cpu_to_le16(skb_out->len);
1196 memcpy(skb_put(skb_out, ctx->max_ndp_size), ctx->delayed_ndp16, ctx->max_ndp_size);
1197
1198 /* Zero out delayed NDP - signature checking will naturally fail. */
1199 ndp16 = memset(ctx->delayed_ndp16, 0, ctx->max_ndp_size);
1200 }
1201
1153 /* If collected data size is less or equal ctx->min_tx_pkt 1202 /* If collected data size is less or equal ctx->min_tx_pkt
1154 * bytes, we send buffers as it is. If we get more data, it 1203 * bytes, we send buffers as it is. If we get more data, it
1155 * would be more efficient for USB HS mobile device with DMA 1204 * would be more efficient for USB HS mobile device with DMA
diff --git a/drivers/net/usb/huawei_cdc_ncm.c b/drivers/net/usb/huawei_cdc_ncm.c
index 735f7dadb9a0..2680a65cd5e4 100644
--- a/drivers/net/usb/huawei_cdc_ncm.c
+++ b/drivers/net/usb/huawei_cdc_ncm.c
@@ -73,11 +73,14 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,
73 struct usb_driver *subdriver = ERR_PTR(-ENODEV); 73 struct usb_driver *subdriver = ERR_PTR(-ENODEV);
74 int ret = -ENODEV; 74 int ret = -ENODEV;
75 struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data; 75 struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
76 int drvflags = 0;
76 77
77 /* altsetting should always be 1 for NCM devices - so we hard-coded 78 /* altsetting should always be 1 for NCM devices - so we hard-coded
78 * it here 79 * it here. Some huawei devices will need the NDP part of the NCM package to
80 * be at the end of the frame.
79 */ 81 */
80 ret = cdc_ncm_bind_common(usbnet_dev, intf, 1); 82 drvflags |= CDC_NCM_FLAG_NDP_TO_END;
83 ret = cdc_ncm_bind_common(usbnet_dev, intf, 1, drvflags);
81 if (ret) 84 if (ret)
82 goto err; 85 goto err;
83 86
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index aafa1a1898e4..7f6419ebb5e1 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -494,6 +494,7 @@ enum rtl8152_flags {
494#define VENDOR_ID_REALTEK 0x0bda 494#define VENDOR_ID_REALTEK 0x0bda
495#define VENDOR_ID_SAMSUNG 0x04e8 495#define VENDOR_ID_SAMSUNG 0x04e8
496#define VENDOR_ID_LENOVO 0x17ef 496#define VENDOR_ID_LENOVO 0x17ef
497#define VENDOR_ID_NVIDIA 0x0955
497 498
498#define MCU_TYPE_PLA 0x0100 499#define MCU_TYPE_PLA 0x0100
499#define MCU_TYPE_USB 0x0000 500#define MCU_TYPE_USB 0x0000
@@ -4117,6 +4118,7 @@ static struct usb_device_id rtl8152_table[] = {
4117 {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)}, 4118 {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)},
4118 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)}, 4119 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)},
4119 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)}, 4120 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)},
4121 {REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff)},
4120 {} 4122 {}
4121}; 4123};
4122 4124
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index da11bb5e9c7f..46f4caddccbe 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1216,7 +1216,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
1216 static const u32 rxprod_reg[2] = { 1216 static const u32 rxprod_reg[2] = {
1217 VMXNET3_REG_RXPROD, VMXNET3_REG_RXPROD2 1217 VMXNET3_REG_RXPROD, VMXNET3_REG_RXPROD2
1218 }; 1218 };
1219 u32 num_rxd = 0; 1219 u32 num_pkts = 0;
1220 bool skip_page_frags = false; 1220 bool skip_page_frags = false;
1221 struct Vmxnet3_RxCompDesc *rcd; 1221 struct Vmxnet3_RxCompDesc *rcd;
1222 struct vmxnet3_rx_ctx *ctx = &rq->rx_ctx; 1222 struct vmxnet3_rx_ctx *ctx = &rq->rx_ctx;
@@ -1235,13 +1235,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
1235 struct Vmxnet3_RxDesc *rxd; 1235 struct Vmxnet3_RxDesc *rxd;
1236 u32 idx, ring_idx; 1236 u32 idx, ring_idx;
1237 struct vmxnet3_cmd_ring *ring = NULL; 1237 struct vmxnet3_cmd_ring *ring = NULL;
1238 if (num_rxd >= quota) { 1238 if (num_pkts >= quota) {
1239 /* we may stop even before we see the EOP desc of 1239 /* we may stop even before we see the EOP desc of
1240 * the current pkt 1240 * the current pkt
1241 */ 1241 */
1242 break; 1242 break;
1243 } 1243 }
1244 num_rxd++;
1245 BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2); 1244 BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2);
1246 idx = rcd->rxdIdx; 1245 idx = rcd->rxdIdx;
1247 ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1; 1246 ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1;
@@ -1413,6 +1412,7 @@ not_lro:
1413 napi_gro_receive(&rq->napi, skb); 1412 napi_gro_receive(&rq->napi, skb);
1414 1413
1415 ctx->skb = NULL; 1414 ctx->skb = NULL;
1415 num_pkts++;
1416 } 1416 }
1417 1417
1418rcd_done: 1418rcd_done:
@@ -1443,7 +1443,7 @@ rcd_done:
1443 &rq->comp_ring.base[rq->comp_ring.next2proc].rcd, &rxComp); 1443 &rq->comp_ring.base[rq->comp_ring.next2proc].rcd, &rxComp);
1444 } 1444 }
1445 1445
1446 return num_rxd; 1446 return num_pkts;
1447} 1447}
1448 1448
1449 1449
diff --git a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c
index feacc3b994b7..2f0bd6955f33 100644
--- a/drivers/net/wan/z85230.c
+++ b/drivers/net/wan/z85230.c
@@ -1044,7 +1044,7 @@ EXPORT_SYMBOL(z8530_sync_dma_close);
1044 * @dev: The network device to attach 1044 * @dev: The network device to attach
1045 * @c: The Z8530 channel to configure in sync DMA mode. 1045 * @c: The Z8530 channel to configure in sync DMA mode.
1046 * 1046 *
1047 * Set up a Z85x30 device for synchronous DMA tranmission. One 1047 * Set up a Z85x30 device for synchronous DMA transmission. One
1048 * ISA DMA channel must be available for this to work. The receive 1048 * ISA DMA channel must be available for this to work. The receive
1049 * side is run in PIO mode, but then it has the bigger FIFO. 1049 * side is run in PIO mode, but then it has the bigger FIFO.
1050 */ 1050 */
diff --git a/include/linux/can/skb.h b/include/linux/can/skb.h
index b6a52a4b457a..51bb6532785c 100644
--- a/include/linux/can/skb.h
+++ b/include/linux/can/skb.h
@@ -27,10 +27,12 @@
27/** 27/**
28 * struct can_skb_priv - private additional data inside CAN sk_buffs 28 * struct can_skb_priv - private additional data inside CAN sk_buffs
29 * @ifindex: ifindex of the first interface the CAN frame appeared on 29 * @ifindex: ifindex of the first interface the CAN frame appeared on
30 * @skbcnt: atomic counter to have an unique id together with skb pointer
30 * @cf: align to the following CAN frame at skb->data 31 * @cf: align to the following CAN frame at skb->data
31 */ 32 */
32struct can_skb_priv { 33struct can_skb_priv {
33 int ifindex; 34 int ifindex;
35 int skbcnt;
34 struct can_frame cf[0]; 36 struct can_frame cf[0];
35}; 37};
36 38
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h
index 7c9b484735c5..1f6526c76ee8 100644
--- a/include/linux/usb/cdc_ncm.h
+++ b/include/linux/usb/cdc_ncm.h
@@ -80,6 +80,9 @@
80#define CDC_NCM_TIMER_INTERVAL_MIN 5UL 80#define CDC_NCM_TIMER_INTERVAL_MIN 5UL
81#define CDC_NCM_TIMER_INTERVAL_MAX (U32_MAX / NSEC_PER_USEC) 81#define CDC_NCM_TIMER_INTERVAL_MAX (U32_MAX / NSEC_PER_USEC)
82 82
83/* Driver flags */
84#define CDC_NCM_FLAG_NDP_TO_END 0x02 /* NDP is placed at end of frame */
85
83#define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \ 86#define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \
84 (x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE) 87 (x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE)
85#define cdc_ncm_data_intf_is_mbim(x) ((x)->desc.bInterfaceProtocol == USB_CDC_MBIM_PROTO_NTB) 88#define cdc_ncm_data_intf_is_mbim(x) ((x)->desc.bInterfaceProtocol == USB_CDC_MBIM_PROTO_NTB)
@@ -103,9 +106,11 @@ struct cdc_ncm_ctx {
103 106
104 spinlock_t mtx; 107 spinlock_t mtx;
105 atomic_t stop; 108 atomic_t stop;
109 int drvflags;
106 110
107 u32 timer_interval; 111 u32 timer_interval;
108 u32 max_ndp_size; 112 u32 max_ndp_size;
113 struct usb_cdc_ncm_ndp16 *delayed_ndp16;
109 114
110 u32 tx_timer_pending; 115 u32 tx_timer_pending;
111 u32 tx_curr_frame_num; 116 u32 tx_curr_frame_num;
@@ -133,7 +138,7 @@ struct cdc_ncm_ctx {
133}; 138};
134 139
135u8 cdc_ncm_select_altsetting(struct usb_interface *intf); 140u8 cdc_ncm_select_altsetting(struct usb_interface *intf);
136int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting); 141int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting, int drvflags);
137void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf); 142void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf);
138struct sk_buff *cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign); 143struct sk_buff *cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign);
139int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in); 144int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in);
diff --git a/include/uapi/linux/netconf.h b/include/uapi/linux/netconf.h
index 669a1f0b1d97..23cbd34e4ac7 100644
--- a/include/uapi/linux/netconf.h
+++ b/include/uapi/linux/netconf.h
@@ -15,6 +15,7 @@ enum {
15 NETCONFA_RP_FILTER, 15 NETCONFA_RP_FILTER,
16 NETCONFA_MC_FORWARDING, 16 NETCONFA_MC_FORWARDING,
17 NETCONFA_PROXY_NEIGH, 17 NETCONFA_PROXY_NEIGH,
18 NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
18 __NETCONFA_MAX 19 __NETCONFA_MAX
19}; 20};
20#define NETCONFA_MAX (__NETCONFA_MAX - 1) 21#define NETCONFA_MAX (__NETCONFA_MAX - 1)
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index a60a6d335a91..cc0c69710dcf 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -610,6 +610,8 @@ next:
610 iter->skip = 0; 610 iter->skip = 0;
611 } 611 }
612 612
613 iter->p = NULL;
614
613 /* Ensure we see any new tables. */ 615 /* Ensure we see any new tables. */
614 smp_rmb(); 616 smp_rmb();
615 617
@@ -620,8 +622,6 @@ next:
620 return ERR_PTR(-EAGAIN); 622 return ERR_PTR(-EAGAIN);
621 } 623 }
622 624
623 iter->p = NULL;
624
625 return NULL; 625 return NULL;
626} 626}
627EXPORT_SYMBOL_GPL(rhashtable_walk_next); 627EXPORT_SYMBOL_GPL(rhashtable_walk_next);
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index e97572b5d2cc..0ff6e1bbca91 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -42,6 +42,7 @@ int br_dev_queue_push_xmit(struct sock *sk, struct sk_buff *skb)
42 } else { 42 } else {
43 skb_push(skb, ETH_HLEN); 43 skb_push(skb, ETH_HLEN);
44 br_drop_fake_rtable(skb); 44 br_drop_fake_rtable(skb);
45 skb_sender_cpu_clear(skb);
45 dev_queue_xmit(skb); 46 dev_queue_xmit(skb);
46 } 47 }
47 48
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index e29ad70b3000..c11cf2611db0 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -323,6 +323,7 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
323 struct net_bridge_port_group *p; 323 struct net_bridge_port_group *p;
324 struct net_bridge_port_group __rcu **pp; 324 struct net_bridge_port_group __rcu **pp;
325 struct net_bridge_mdb_htable *mdb; 325 struct net_bridge_mdb_htable *mdb;
326 unsigned long now = jiffies;
326 int err; 327 int err;
327 328
328 mdb = mlock_dereference(br->mdb, br); 329 mdb = mlock_dereference(br->mdb, br);
@@ -347,6 +348,8 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
347 if (unlikely(!p)) 348 if (unlikely(!p))
348 return -ENOMEM; 349 return -ENOMEM;
349 rcu_assign_pointer(*pp, p); 350 rcu_assign_pointer(*pp, p);
351 if (state == MDB_TEMPORARY)
352 mod_timer(&p->timer, now + br->multicast_membership_interval);
350 353
351 br_mdb_notify(br->dev, port, group, RTM_NEWMDB); 354 br_mdb_notify(br->dev, port, group, RTM_NEWMDB);
352 return 0; 355 return 0;
@@ -371,6 +374,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br,
371 if (!p || p->br != br || p->state == BR_STATE_DISABLED) 374 if (!p || p->br != br || p->state == BR_STATE_DISABLED)
372 return -EINVAL; 375 return -EINVAL;
373 376
377 memset(&ip, 0, sizeof(ip));
374 ip.proto = entry->addr.proto; 378 ip.proto = entry->addr.proto;
375 if (ip.proto == htons(ETH_P_IP)) 379 if (ip.proto == htons(ETH_P_IP))
376 ip.u.ip4 = entry->addr.u.ip4; 380 ip.u.ip4 = entry->addr.u.ip4;
@@ -417,20 +421,14 @@ static int __br_mdb_del(struct net_bridge *br, struct br_mdb_entry *entry)
417 if (!netif_running(br->dev) || br->multicast_disabled) 421 if (!netif_running(br->dev) || br->multicast_disabled)
418 return -EINVAL; 422 return -EINVAL;
419 423
424 memset(&ip, 0, sizeof(ip));
420 ip.proto = entry->addr.proto; 425 ip.proto = entry->addr.proto;
421 if (ip.proto == htons(ETH_P_IP)) { 426 if (ip.proto == htons(ETH_P_IP))
422 if (timer_pending(&br->ip4_other_query.timer))
423 return -EBUSY;
424
425 ip.u.ip4 = entry->addr.u.ip4; 427 ip.u.ip4 = entry->addr.u.ip4;
426#if IS_ENABLED(CONFIG_IPV6) 428#if IS_ENABLED(CONFIG_IPV6)
427 } else { 429 else
428 if (timer_pending(&br->ip6_other_query.timer))
429 return -EBUSY;
430
431 ip.u.ip6 = entry->addr.u.ip6; 430 ip.u.ip6 = entry->addr.u.ip6;
432#endif 431#endif
433 }
434 432
435 spin_lock_bh(&br->multicast_lock); 433 spin_lock_bh(&br->multicast_lock);
436 mdb = mlock_dereference(br->mdb, br); 434 mdb = mlock_dereference(br->mdb, br);
diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c
index d89f4fac0bc5..c8b9bcfe997e 100644
--- a/net/bridge/br_netfilter_hooks.c
+++ b/net/bridge/br_netfilter_hooks.c
@@ -111,7 +111,7 @@ static inline __be16 pppoe_proto(const struct sk_buff *skb)
111/* largest possible L2 header, see br_nf_dev_queue_xmit() */ 111/* largest possible L2 header, see br_nf_dev_queue_xmit() */
112#define NF_BRIDGE_MAX_MAC_HEADER_LENGTH (PPPOE_SES_HLEN + ETH_HLEN) 112#define NF_BRIDGE_MAX_MAC_HEADER_LENGTH (PPPOE_SES_HLEN + ETH_HLEN)
113 113
114#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4) 114#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4) || IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
115struct brnf_frag_data { 115struct brnf_frag_data {
116 char mac[NF_BRIDGE_MAX_MAC_HEADER_LENGTH]; 116 char mac[NF_BRIDGE_MAX_MAC_HEADER_LENGTH];
117 u8 encap_size; 117 u8 encap_size;
@@ -694,6 +694,7 @@ static int br_nf_push_frag_xmit(struct sock *sk, struct sk_buff *skb)
694} 694}
695#endif 695#endif
696 696
697#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4)
697static int br_nf_ip_fragment(struct sock *sk, struct sk_buff *skb, 698static int br_nf_ip_fragment(struct sock *sk, struct sk_buff *skb,
698 int (*output)(struct sock *, struct sk_buff *)) 699 int (*output)(struct sock *, struct sk_buff *))
699{ 700{
@@ -712,6 +713,7 @@ static int br_nf_ip_fragment(struct sock *sk, struct sk_buff *skb,
712 713
713 return ip_do_fragment(sk, skb, output); 714 return ip_do_fragment(sk, skb, output);
714} 715}
716#endif
715 717
716static unsigned int nf_bridge_mtu_reduction(const struct sk_buff *skb) 718static unsigned int nf_bridge_mtu_reduction(const struct sk_buff *skb)
717{ 719{
@@ -742,7 +744,7 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
742 struct brnf_frag_data *data; 744 struct brnf_frag_data *data;
743 745
744 if (br_validate_ipv4(skb)) 746 if (br_validate_ipv4(skb))
745 return NF_DROP; 747 goto drop;
746 748
747 IPCB(skb)->frag_max_size = nf_bridge->frag_max_size; 749 IPCB(skb)->frag_max_size = nf_bridge->frag_max_size;
748 750
@@ -767,7 +769,7 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
767 struct brnf_frag_data *data; 769 struct brnf_frag_data *data;
768 770
769 if (br_validate_ipv6(skb)) 771 if (br_validate_ipv6(skb))
770 return NF_DROP; 772 goto drop;
771 773
772 IP6CB(skb)->frag_max_size = nf_bridge->frag_max_size; 774 IP6CB(skb)->frag_max_size = nf_bridge->frag_max_size;
773 775
@@ -782,12 +784,16 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
782 784
783 if (v6ops) 785 if (v6ops)
784 return v6ops->fragment(sk, skb, br_nf_push_frag_xmit); 786 return v6ops->fragment(sk, skb, br_nf_push_frag_xmit);
785 else 787
786 return -EMSGSIZE; 788 kfree_skb(skb);
789 return -EMSGSIZE;
787 } 790 }
788#endif 791#endif
789 nf_bridge_info_free(skb); 792 nf_bridge_info_free(skb);
790 return br_dev_queue_push_xmit(sk, skb); 793 return br_dev_queue_push_xmit(sk, skb);
794 drop:
795 kfree_skb(skb);
796 return 0;
791} 797}
792 798
793/* PF_BRIDGE/POST_ROUTING ********************************************/ 799/* PF_BRIDGE/POST_ROUTING ********************************************/
diff --git a/net/bridge/br_netfilter_ipv6.c b/net/bridge/br_netfilter_ipv6.c
index 6d12d2675c80..13b7d1e3d185 100644
--- a/net/bridge/br_netfilter_ipv6.c
+++ b/net/bridge/br_netfilter_ipv6.c
@@ -104,7 +104,7 @@ int br_validate_ipv6(struct sk_buff *skb)
104{ 104{
105 const struct ipv6hdr *hdr; 105 const struct ipv6hdr *hdr;
106 struct net_device *dev = skb->dev; 106 struct net_device *dev = skb->dev;
107 struct inet6_dev *idev = in6_dev_get(skb->dev); 107 struct inet6_dev *idev = __in6_dev_get(skb->dev);
108 u32 pkt_len; 108 u32 pkt_len;
109 u8 ip6h_len = sizeof(struct ipv6hdr); 109 u8 ip6h_len = sizeof(struct ipv6hdr);
110 110
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 6b67ed3831de..364bdc98bd9b 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -457,6 +457,8 @@ static int br_afspec(struct net_bridge *br,
457 if (nla_len(attr) != sizeof(struct bridge_vlan_info)) 457 if (nla_len(attr) != sizeof(struct bridge_vlan_info))
458 return -EINVAL; 458 return -EINVAL;
459 vinfo = nla_data(attr); 459 vinfo = nla_data(attr);
460 if (!vinfo->vid || vinfo->vid >= VLAN_VID_MASK)
461 return -EINVAL;
460 if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) { 462 if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) {
461 if (vinfo_start) 463 if (vinfo_start)
462 return -EINVAL; 464 return -EINVAL;
diff --git a/net/can/af_can.c b/net/can/af_can.c
index 7933e62a7318..166d436196c1 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -89,6 +89,8 @@ struct timer_list can_stattimer; /* timer for statistics update */
89struct s_stats can_stats; /* packet statistics */ 89struct s_stats can_stats; /* packet statistics */
90struct s_pstats can_pstats; /* receive list statistics */ 90struct s_pstats can_pstats; /* receive list statistics */
91 91
92static atomic_t skbcounter = ATOMIC_INIT(0);
93
92/* 94/*
93 * af_can socket functions 95 * af_can socket functions
94 */ 96 */
@@ -310,12 +312,8 @@ int can_send(struct sk_buff *skb, int loop)
310 return err; 312 return err;
311 } 313 }
312 314
313 if (newskb) { 315 if (newskb)
314 if (!(newskb->tstamp.tv64))
315 __net_timestamp(newskb);
316
317 netif_rx_ni(newskb); 316 netif_rx_ni(newskb);
318 }
319 317
320 /* update statistics */ 318 /* update statistics */
321 can_stats.tx_frames++; 319 can_stats.tx_frames++;
@@ -683,6 +681,10 @@ static void can_receive(struct sk_buff *skb, struct net_device *dev)
683 can_stats.rx_frames++; 681 can_stats.rx_frames++;
684 can_stats.rx_frames_delta++; 682 can_stats.rx_frames_delta++;
685 683
684 /* create non-zero unique skb identifier together with *skb */
685 while (!(can_skb_prv(skb)->skbcnt))
686 can_skb_prv(skb)->skbcnt = atomic_inc_return(&skbcounter);
687
686 rcu_read_lock(); 688 rcu_read_lock();
687 689
688 /* deliver the packet to sockets listening on all devices */ 690 /* deliver the packet to sockets listening on all devices */
diff --git a/net/can/bcm.c b/net/can/bcm.c
index b523453585be..a1ba6875c2a2 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -261,6 +261,7 @@ static void bcm_can_tx(struct bcm_op *op)
261 261
262 can_skb_reserve(skb); 262 can_skb_reserve(skb);
263 can_skb_prv(skb)->ifindex = dev->ifindex; 263 can_skb_prv(skb)->ifindex = dev->ifindex;
264 can_skb_prv(skb)->skbcnt = 0;
264 265
265 memcpy(skb_put(skb, CFSIZ), cf, CFSIZ); 266 memcpy(skb_put(skb, CFSIZ), cf, CFSIZ);
266 267
@@ -1217,6 +1218,7 @@ static int bcm_tx_send(struct msghdr *msg, int ifindex, struct sock *sk)
1217 } 1218 }
1218 1219
1219 can_skb_prv(skb)->ifindex = dev->ifindex; 1220 can_skb_prv(skb)->ifindex = dev->ifindex;
1221 can_skb_prv(skb)->skbcnt = 0;
1220 skb->dev = dev; 1222 skb->dev = dev;
1221 can_skb_set_owner(skb, sk); 1223 can_skb_set_owner(skb, sk);
1222 err = can_send(skb, 1); /* send with loopback */ 1224 err = can_send(skb, 1); /* send with loopback */
diff --git a/net/can/raw.c b/net/can/raw.c
index 31b9748cbb4e..2e67b1423cd3 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -75,7 +75,7 @@ MODULE_ALIAS("can-proto-1");
75 */ 75 */
76 76
77struct uniqframe { 77struct uniqframe {
78 ktime_t tstamp; 78 int skbcnt;
79 const struct sk_buff *skb; 79 const struct sk_buff *skb;
80 unsigned int join_rx_count; 80 unsigned int join_rx_count;
81}; 81};
@@ -133,7 +133,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
133 133
134 /* eliminate multiple filter matches for the same skb */ 134 /* eliminate multiple filter matches for the same skb */
135 if (this_cpu_ptr(ro->uniq)->skb == oskb && 135 if (this_cpu_ptr(ro->uniq)->skb == oskb &&
136 ktime_equal(this_cpu_ptr(ro->uniq)->tstamp, oskb->tstamp)) { 136 this_cpu_ptr(ro->uniq)->skbcnt == can_skb_prv(oskb)->skbcnt) {
137 if (ro->join_filters) { 137 if (ro->join_filters) {
138 this_cpu_inc(ro->uniq->join_rx_count); 138 this_cpu_inc(ro->uniq->join_rx_count);
139 /* drop frame until all enabled filters matched */ 139 /* drop frame until all enabled filters matched */
@@ -144,7 +144,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
144 } 144 }
145 } else { 145 } else {
146 this_cpu_ptr(ro->uniq)->skb = oskb; 146 this_cpu_ptr(ro->uniq)->skb = oskb;
147 this_cpu_ptr(ro->uniq)->tstamp = oskb->tstamp; 147 this_cpu_ptr(ro->uniq)->skbcnt = can_skb_prv(oskb)->skbcnt;
148 this_cpu_ptr(ro->uniq)->join_rx_count = 1; 148 this_cpu_ptr(ro->uniq)->join_rx_count = 1;
149 /* drop first frame to check all enabled filters? */ 149 /* drop first frame to check all enabled filters? */
150 if (ro->join_filters && ro->count > 1) 150 if (ro->join_filters && ro->count > 1)
@@ -749,6 +749,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
749 749
750 can_skb_reserve(skb); 750 can_skb_reserve(skb);
751 can_skb_prv(skb)->ifindex = dev->ifindex; 751 can_skb_prv(skb)->ifindex = dev->ifindex;
752 can_skb_prv(skb)->skbcnt = 0;
752 753
753 err = memcpy_from_msg(skb_put(skb, size), msg, size); 754 err = memcpy_from_msg(skb_put(skb, size), msg, size);
754 if (err < 0) 755 if (err < 0)
diff --git a/net/core/dev.c b/net/core/dev.c
index 6778a9999d52..a8e4dd430285 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -677,10 +677,6 @@ int dev_get_iflink(const struct net_device *dev)
677 if (dev->netdev_ops && dev->netdev_ops->ndo_get_iflink) 677 if (dev->netdev_ops && dev->netdev_ops->ndo_get_iflink)
678 return dev->netdev_ops->ndo_get_iflink(dev); 678 return dev->netdev_ops->ndo_get_iflink(dev);
679 679
680 /* If dev->rtnl_link_ops is set, it's a virtual interface. */
681 if (dev->rtnl_link_ops)
682 return 0;
683
684 return dev->ifindex; 680 return dev->ifindex;
685} 681}
686EXPORT_SYMBOL(dev_get_iflink); 682EXPORT_SYMBOL(dev_get_iflink);
@@ -3452,6 +3448,8 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu,
3452 local_irq_save(flags); 3448 local_irq_save(flags);
3453 3449
3454 rps_lock(sd); 3450 rps_lock(sd);
3451 if (!netif_running(skb->dev))
3452 goto drop;
3455 qlen = skb_queue_len(&sd->input_pkt_queue); 3453 qlen = skb_queue_len(&sd->input_pkt_queue);
3456 if (qlen <= netdev_max_backlog && !skb_flow_limit(skb, qlen)) { 3454 if (qlen <= netdev_max_backlog && !skb_flow_limit(skb, qlen)) {
3457 if (qlen) { 3455 if (qlen) {
@@ -3473,6 +3471,7 @@ enqueue:
3473 goto enqueue; 3471 goto enqueue;
3474 } 3472 }
3475 3473
3474drop:
3476 sd->dropped++; 3475 sd->dropped++;
3477 rps_unlock(sd); 3476 rps_unlock(sd);
3478 3477
@@ -3775,8 +3774,6 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
3775 3774
3776 pt_prev = NULL; 3775 pt_prev = NULL;
3777 3776
3778 rcu_read_lock();
3779
3780another_round: 3777another_round:
3781 skb->skb_iif = skb->dev->ifindex; 3778 skb->skb_iif = skb->dev->ifindex;
3782 3779
@@ -3786,7 +3783,7 @@ another_round:
3786 skb->protocol == cpu_to_be16(ETH_P_8021AD)) { 3783 skb->protocol == cpu_to_be16(ETH_P_8021AD)) {
3787 skb = skb_vlan_untag(skb); 3784 skb = skb_vlan_untag(skb);
3788 if (unlikely(!skb)) 3785 if (unlikely(!skb))
3789 goto unlock; 3786 goto out;
3790 } 3787 }
3791 3788
3792#ifdef CONFIG_NET_CLS_ACT 3789#ifdef CONFIG_NET_CLS_ACT
@@ -3816,10 +3813,10 @@ skip_taps:
3816 if (static_key_false(&ingress_needed)) { 3813 if (static_key_false(&ingress_needed)) {
3817 skb = handle_ing(skb, &pt_prev, &ret, orig_dev); 3814 skb = handle_ing(skb, &pt_prev, &ret, orig_dev);
3818 if (!skb) 3815 if (!skb)
3819 goto unlock; 3816 goto out;
3820 3817
3821 if (nf_ingress(skb, &pt_prev, &ret, orig_dev) < 0) 3818 if (nf_ingress(skb, &pt_prev, &ret, orig_dev) < 0)
3822 goto unlock; 3819 goto out;
3823 } 3820 }
3824#endif 3821#endif
3825#ifdef CONFIG_NET_CLS_ACT 3822#ifdef CONFIG_NET_CLS_ACT
@@ -3837,7 +3834,7 @@ ncls:
3837 if (vlan_do_receive(&skb)) 3834 if (vlan_do_receive(&skb))
3838 goto another_round; 3835 goto another_round;
3839 else if (unlikely(!skb)) 3836 else if (unlikely(!skb))
3840 goto unlock; 3837 goto out;
3841 } 3838 }
3842 3839
3843 rx_handler = rcu_dereference(skb->dev->rx_handler); 3840 rx_handler = rcu_dereference(skb->dev->rx_handler);
@@ -3849,7 +3846,7 @@ ncls:
3849 switch (rx_handler(&skb)) { 3846 switch (rx_handler(&skb)) {
3850 case RX_HANDLER_CONSUMED: 3847 case RX_HANDLER_CONSUMED:
3851 ret = NET_RX_SUCCESS; 3848 ret = NET_RX_SUCCESS;
3852 goto unlock; 3849 goto out;
3853 case RX_HANDLER_ANOTHER: 3850 case RX_HANDLER_ANOTHER:
3854 goto another_round; 3851 goto another_round;
3855 case RX_HANDLER_EXACT: 3852 case RX_HANDLER_EXACT:
@@ -3903,8 +3900,7 @@ drop:
3903 ret = NET_RX_DROP; 3900 ret = NET_RX_DROP;
3904 } 3901 }
3905 3902
3906unlock: 3903out:
3907 rcu_read_unlock();
3908 return ret; 3904 return ret;
3909} 3905}
3910 3906
@@ -3935,29 +3931,30 @@ static int __netif_receive_skb(struct sk_buff *skb)
3935 3931
3936static int netif_receive_skb_internal(struct sk_buff *skb) 3932static int netif_receive_skb_internal(struct sk_buff *skb)
3937{ 3933{
3934 int ret;
3935
3938 net_timestamp_check(netdev_tstamp_prequeue, skb); 3936 net_timestamp_check(netdev_tstamp_prequeue, skb);
3939 3937
3940 if (skb_defer_rx_timestamp(skb)) 3938 if (skb_defer_rx_timestamp(skb))
3941 return NET_RX_SUCCESS; 3939 return NET_RX_SUCCESS;
3942 3940
3941 rcu_read_lock();
3942
3943#ifdef CONFIG_RPS 3943#ifdef CONFIG_RPS
3944 if (static_key_false(&rps_needed)) { 3944 if (static_key_false(&rps_needed)) {
3945 struct rps_dev_flow voidflow, *rflow = &voidflow; 3945 struct rps_dev_flow voidflow, *rflow = &voidflow;
3946 int cpu, ret; 3946 int cpu = get_rps_cpu(skb->dev, skb, &rflow);
3947
3948 rcu_read_lock();
3949
3950 cpu = get_rps_cpu(skb->dev, skb, &rflow);
3951 3947
3952 if (cpu >= 0) { 3948 if (cpu >= 0) {
3953 ret = enqueue_to_backlog(skb, cpu, &rflow->last_qtail); 3949 ret = enqueue_to_backlog(skb, cpu, &rflow->last_qtail);
3954 rcu_read_unlock(); 3950 rcu_read_unlock();
3955 return ret; 3951 return ret;
3956 } 3952 }
3957 rcu_read_unlock();
3958 } 3953 }
3959#endif 3954#endif
3960 return __netif_receive_skb(skb); 3955 ret = __netif_receive_skb(skb);
3956 rcu_read_unlock();
3957 return ret;
3961} 3958}
3962 3959
3963/** 3960/**
@@ -4502,8 +4499,10 @@ static int process_backlog(struct napi_struct *napi, int quota)
4502 struct sk_buff *skb; 4499 struct sk_buff *skb;
4503 4500
4504 while ((skb = __skb_dequeue(&sd->process_queue))) { 4501 while ((skb = __skb_dequeue(&sd->process_queue))) {
4502 rcu_read_lock();
4505 local_irq_enable(); 4503 local_irq_enable();
4506 __netif_receive_skb(skb); 4504 __netif_receive_skb(skb);
4505 rcu_read_unlock();
4507 local_irq_disable(); 4506 local_irq_disable();
4508 input_queue_head_incr(sd); 4507 input_queue_head_incr(sd);
4509 if (++work >= quota) { 4508 if (++work >= quota) {
@@ -6139,6 +6138,7 @@ static void rollback_registered_many(struct list_head *head)
6139 unlist_netdevice(dev); 6138 unlist_netdevice(dev);
6140 6139
6141 dev->reg_state = NETREG_UNREGISTERING; 6140 dev->reg_state = NETREG_UNREGISTERING;
6141 on_each_cpu(flush_backlog, dev, 1);
6142 } 6142 }
6143 6143
6144 synchronize_net(); 6144 synchronize_net();
@@ -6409,7 +6409,8 @@ static int netif_alloc_netdev_queues(struct net_device *dev)
6409 struct netdev_queue *tx; 6409 struct netdev_queue *tx;
6410 size_t sz = count * sizeof(*tx); 6410 size_t sz = count * sizeof(*tx);
6411 6411
6412 BUG_ON(count < 1 || count > 0xffff); 6412 if (count < 1 || count > 0xffff)
6413 return -EINVAL;
6413 6414
6414 tx = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT); 6415 tx = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
6415 if (!tx) { 6416 if (!tx) {
@@ -6773,8 +6774,6 @@ void netdev_run_todo(void)
6773 6774
6774 dev->reg_state = NETREG_UNREGISTERED; 6775 dev->reg_state = NETREG_UNREGISTERED;
6775 6776
6776 on_each_cpu(flush_backlog, dev, 1);
6777
6778 netdev_wait_allrefs(dev); 6777 netdev_wait_allrefs(dev);
6779 6778
6780 /* paranoia */ 6779 /* paranoia */
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c
index 9dfb88a933e7..92d886f4adcb 100644
--- a/net/core/gen_estimator.c
+++ b/net/core/gen_estimator.c
@@ -66,7 +66,7 @@
66 66
67 NOTES. 67 NOTES.
68 68
69 * avbps is scaled by 2^5, avpps is scaled by 2^10. 69 * avbps and avpps are scaled by 2^5.
70 * both values are reported as 32 bit unsigned values. bps can 70 * both values are reported as 32 bit unsigned values. bps can
71 overflow for fast links : max speed being 34360Mbit/sec 71 overflow for fast links : max speed being 34360Mbit/sec
72 * Minimal interval is HZ/4=250msec (it is the greatest common divisor 72 * Minimal interval is HZ/4=250msec (it is the greatest common divisor
@@ -85,10 +85,10 @@ struct gen_estimator
85 struct gnet_stats_rate_est64 *rate_est; 85 struct gnet_stats_rate_est64 *rate_est;
86 spinlock_t *stats_lock; 86 spinlock_t *stats_lock;
87 int ewma_log; 87 int ewma_log;
88 u32 last_packets;
89 unsigned long avpps;
88 u64 last_bytes; 90 u64 last_bytes;
89 u64 avbps; 91 u64 avbps;
90 u32 last_packets;
91 u32 avpps;
92 struct rcu_head e_rcu; 92 struct rcu_head e_rcu;
93 struct rb_node node; 93 struct rb_node node;
94 struct gnet_stats_basic_cpu __percpu *cpu_bstats; 94 struct gnet_stats_basic_cpu __percpu *cpu_bstats;
@@ -118,8 +118,8 @@ static void est_timer(unsigned long arg)
118 rcu_read_lock(); 118 rcu_read_lock();
119 list_for_each_entry_rcu(e, &elist[idx].list, list) { 119 list_for_each_entry_rcu(e, &elist[idx].list, list) {
120 struct gnet_stats_basic_packed b = {0}; 120 struct gnet_stats_basic_packed b = {0};
121 unsigned long rate;
121 u64 brate; 122 u64 brate;
122 u32 rate;
123 123
124 spin_lock(e->stats_lock); 124 spin_lock(e->stats_lock);
125 read_lock(&est_lock); 125 read_lock(&est_lock);
@@ -133,10 +133,11 @@ static void est_timer(unsigned long arg)
133 e->avbps += (brate >> e->ewma_log) - (e->avbps >> e->ewma_log); 133 e->avbps += (brate >> e->ewma_log) - (e->avbps >> e->ewma_log);
134 e->rate_est->bps = (e->avbps+0xF)>>5; 134 e->rate_est->bps = (e->avbps+0xF)>>5;
135 135
136 rate = (b.packets - e->last_packets)<<(12 - idx); 136 rate = b.packets - e->last_packets;
137 rate <<= (7 - idx);
137 e->last_packets = b.packets; 138 e->last_packets = b.packets;
138 e->avpps += (rate >> e->ewma_log) - (e->avpps >> e->ewma_log); 139 e->avpps += (rate >> e->ewma_log) - (e->avpps >> e->ewma_log);
139 e->rate_est->pps = (e->avpps+0x1FF)>>10; 140 e->rate_est->pps = (e->avpps + 0xF) >> 5;
140skip: 141skip:
141 read_unlock(&est_lock); 142 read_unlock(&est_lock);
142 spin_unlock(e->stats_lock); 143 spin_unlock(e->stats_lock);
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 05badbb58865..1ebdf1c0d118 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3571,13 +3571,6 @@ static int pktgen_thread_worker(void *arg)
3571 pr_debug("%s removing thread\n", t->tsk->comm); 3571 pr_debug("%s removing thread\n", t->tsk->comm);
3572 pktgen_rem_thread(t); 3572 pktgen_rem_thread(t);
3573 3573
3574 /* Wait for kthread_stop */
3575 while (!kthread_should_stop()) {
3576 set_current_state(TASK_INTERRUPTIBLE);
3577 schedule();
3578 }
3579 __set_current_state(TASK_RUNNING);
3580
3581 return 0; 3574 return 0;
3582} 3575}
3583 3576
@@ -3769,6 +3762,7 @@ static int __net_init pktgen_create_thread(int cpu, struct pktgen_net *pn)
3769 } 3762 }
3770 3763
3771 t->net = pn; 3764 t->net = pn;
3765 get_task_struct(p);
3772 wake_up_process(p); 3766 wake_up_process(p);
3773 wait_for_completion(&t->start_done); 3767 wait_for_completion(&t->start_done);
3774 3768
@@ -3891,6 +3885,7 @@ static void __net_exit pg_net_exit(struct net *net)
3891 t = list_entry(q, struct pktgen_thread, th_list); 3885 t = list_entry(q, struct pktgen_thread, th_list);
3892 list_del(&t->th_list); 3886 list_del(&t->th_list);
3893 kthread_stop(t->tsk); 3887 kthread_stop(t->tsk);
3888 put_task_struct(t->tsk);
3894 kfree(t); 3889 kfree(t);
3895 } 3890 }
3896 3891
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 01ced4a889e0..9e433d58d265 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1328,10 +1328,6 @@ static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
1328 [IFLA_INFO_SLAVE_DATA] = { .type = NLA_NESTED }, 1328 [IFLA_INFO_SLAVE_DATA] = { .type = NLA_NESTED },
1329}; 1329};
1330 1330
1331static const struct nla_policy ifla_vfinfo_policy[IFLA_VF_INFO_MAX+1] = {
1332 [IFLA_VF_INFO] = { .type = NLA_NESTED },
1333};
1334
1335static const struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = { 1331static const struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = {
1336 [IFLA_VF_MAC] = { .len = sizeof(struct ifla_vf_mac) }, 1332 [IFLA_VF_MAC] = { .len = sizeof(struct ifla_vf_mac) },
1337 [IFLA_VF_VLAN] = { .len = sizeof(struct ifla_vf_vlan) }, 1333 [IFLA_VF_VLAN] = { .len = sizeof(struct ifla_vf_vlan) },
@@ -1488,96 +1484,98 @@ static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[])
1488 return 0; 1484 return 0;
1489} 1485}
1490 1486
1491static int do_setvfinfo(struct net_device *dev, struct nlattr *attr) 1487static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
1492{ 1488{
1493 int rem, err = -EINVAL;
1494 struct nlattr *vf;
1495 const struct net_device_ops *ops = dev->netdev_ops; 1489 const struct net_device_ops *ops = dev->netdev_ops;
1490 int err = -EINVAL;
1496 1491
1497 nla_for_each_nested(vf, attr, rem) { 1492 if (tb[IFLA_VF_MAC]) {
1498 switch (nla_type(vf)) { 1493 struct ifla_vf_mac *ivm = nla_data(tb[IFLA_VF_MAC]);
1499 case IFLA_VF_MAC: {
1500 struct ifla_vf_mac *ivm;
1501 ivm = nla_data(vf);
1502 err = -EOPNOTSUPP;
1503 if (ops->ndo_set_vf_mac)
1504 err = ops->ndo_set_vf_mac(dev, ivm->vf,
1505 ivm->mac);
1506 break;
1507 }
1508 case IFLA_VF_VLAN: {
1509 struct ifla_vf_vlan *ivv;
1510 ivv = nla_data(vf);
1511 err = -EOPNOTSUPP;
1512 if (ops->ndo_set_vf_vlan)
1513 err = ops->ndo_set_vf_vlan(dev, ivv->vf,
1514 ivv->vlan,
1515 ivv->qos);
1516 break;
1517 }
1518 case IFLA_VF_TX_RATE: {
1519 struct ifla_vf_tx_rate *ivt;
1520 struct ifla_vf_info ivf;
1521 ivt = nla_data(vf);
1522 err = -EOPNOTSUPP;
1523 if (ops->ndo_get_vf_config)
1524 err = ops->ndo_get_vf_config(dev, ivt->vf,
1525 &ivf);
1526 if (err)
1527 break;
1528 err = -EOPNOTSUPP;
1529 if (ops->ndo_set_vf_rate)
1530 err = ops->ndo_set_vf_rate(dev, ivt->vf,
1531 ivf.min_tx_rate,
1532 ivt->rate);
1533 break;
1534 }
1535 case IFLA_VF_RATE: {
1536 struct ifla_vf_rate *ivt;
1537 ivt = nla_data(vf);
1538 err = -EOPNOTSUPP;
1539 if (ops->ndo_set_vf_rate)
1540 err = ops->ndo_set_vf_rate(dev, ivt->vf,
1541 ivt->min_tx_rate,
1542 ivt->max_tx_rate);
1543 break;
1544 }
1545 case IFLA_VF_SPOOFCHK: {
1546 struct ifla_vf_spoofchk *ivs;
1547 ivs = nla_data(vf);
1548 err = -EOPNOTSUPP;
1549 if (ops->ndo_set_vf_spoofchk)
1550 err = ops->ndo_set_vf_spoofchk(dev, ivs->vf,
1551 ivs->setting);
1552 break;
1553 }
1554 case IFLA_VF_LINK_STATE: {
1555 struct ifla_vf_link_state *ivl;
1556 ivl = nla_data(vf);
1557 err = -EOPNOTSUPP;
1558 if (ops->ndo_set_vf_link_state)
1559 err = ops->ndo_set_vf_link_state(dev, ivl->vf,
1560 ivl->link_state);
1561 break;
1562 }
1563 case IFLA_VF_RSS_QUERY_EN: {
1564 struct ifla_vf_rss_query_en *ivrssq_en;
1565 1494
1566 ivrssq_en = nla_data(vf); 1495 err = -EOPNOTSUPP;
1567 err = -EOPNOTSUPP; 1496 if (ops->ndo_set_vf_mac)
1568 if (ops->ndo_set_vf_rss_query_en) 1497 err = ops->ndo_set_vf_mac(dev, ivm->vf,
1569 err = ops->ndo_set_vf_rss_query_en(dev, 1498 ivm->mac);
1570 ivrssq_en->vf, 1499 if (err < 0)
1571 ivrssq_en->setting); 1500 return err;
1572 break; 1501 }
1573 } 1502
1574 default: 1503 if (tb[IFLA_VF_VLAN]) {
1575 err = -EINVAL; 1504 struct ifla_vf_vlan *ivv = nla_data(tb[IFLA_VF_VLAN]);
1576 break; 1505
1577 } 1506 err = -EOPNOTSUPP;
1578 if (err) 1507 if (ops->ndo_set_vf_vlan)
1579 break; 1508 err = ops->ndo_set_vf_vlan(dev, ivv->vf, ivv->vlan,
1509 ivv->qos);
1510 if (err < 0)
1511 return err;
1512 }
1513
1514 if (tb[IFLA_VF_TX_RATE]) {
1515 struct ifla_vf_tx_rate *ivt = nla_data(tb[IFLA_VF_TX_RATE]);
1516 struct ifla_vf_info ivf;
1517
1518 err = -EOPNOTSUPP;
1519 if (ops->ndo_get_vf_config)
1520 err = ops->ndo_get_vf_config(dev, ivt->vf, &ivf);
1521 if (err < 0)
1522 return err;
1523
1524 err = -EOPNOTSUPP;
1525 if (ops->ndo_set_vf_rate)
1526 err = ops->ndo_set_vf_rate(dev, ivt->vf,
1527 ivf.min_tx_rate,
1528 ivt->rate);
1529 if (err < 0)
1530 return err;
1531 }
1532
1533 if (tb[IFLA_VF_RATE]) {
1534 struct ifla_vf_rate *ivt = nla_data(tb[IFLA_VF_RATE]);
1535
1536 err = -EOPNOTSUPP;
1537 if (ops->ndo_set_vf_rate)
1538 err = ops->ndo_set_vf_rate(dev, ivt->vf,
1539 ivt->min_tx_rate,
1540 ivt->max_tx_rate);
1541 if (err < 0)
1542 return err;
1580 } 1543 }
1544
1545 if (tb[IFLA_VF_SPOOFCHK]) {
1546 struct ifla_vf_spoofchk *ivs = nla_data(tb[IFLA_VF_SPOOFCHK]);
1547
1548 err = -EOPNOTSUPP;
1549 if (ops->ndo_set_vf_spoofchk)
1550 err = ops->ndo_set_vf_spoofchk(dev, ivs->vf,
1551 ivs->setting);
1552 if (err < 0)
1553 return err;
1554 }
1555
1556 if (tb[IFLA_VF_LINK_STATE]) {
1557 struct ifla_vf_link_state *ivl = nla_data(tb[IFLA_VF_LINK_STATE]);
1558
1559 err = -EOPNOTSUPP;
1560 if (ops->ndo_set_vf_link_state)
1561 err = ops->ndo_set_vf_link_state(dev, ivl->vf,
1562 ivl->link_state);
1563 if (err < 0)
1564 return err;
1565 }
1566
1567 if (tb[IFLA_VF_RSS_QUERY_EN]) {
1568 struct ifla_vf_rss_query_en *ivrssq_en;
1569
1570 err = -EOPNOTSUPP;
1571 ivrssq_en = nla_data(tb[IFLA_VF_RSS_QUERY_EN]);
1572 if (ops->ndo_set_vf_rss_query_en)
1573 err = ops->ndo_set_vf_rss_query_en(dev, ivrssq_en->vf,
1574 ivrssq_en->setting);
1575 if (err < 0)
1576 return err;
1577 }
1578
1581 return err; 1579 return err;
1582} 1580}
1583 1581
@@ -1773,14 +1771,21 @@ static int do_setlink(const struct sk_buff *skb,
1773 } 1771 }
1774 1772
1775 if (tb[IFLA_VFINFO_LIST]) { 1773 if (tb[IFLA_VFINFO_LIST]) {
1774 struct nlattr *vfinfo[IFLA_VF_MAX + 1];
1776 struct nlattr *attr; 1775 struct nlattr *attr;
1777 int rem; 1776 int rem;
1777
1778 nla_for_each_nested(attr, tb[IFLA_VFINFO_LIST], rem) { 1778 nla_for_each_nested(attr, tb[IFLA_VFINFO_LIST], rem) {
1779 if (nla_type(attr) != IFLA_VF_INFO) { 1779 if (nla_type(attr) != IFLA_VF_INFO ||
1780 nla_len(attr) < NLA_HDRLEN) {
1780 err = -EINVAL; 1781 err = -EINVAL;
1781 goto errout; 1782 goto errout;
1782 } 1783 }
1783 err = do_setvfinfo(dev, attr); 1784 err = nla_parse_nested(vfinfo, IFLA_VF_MAX, attr,
1785 ifla_vf_policy);
1786 if (err < 0)
1787 goto errout;
1788 err = do_setvfinfo(dev, vfinfo);
1784 if (err < 0) 1789 if (err < 0)
1785 goto errout; 1790 goto errout;
1786 status |= DO_SETLINK_NOTIFY; 1791 status |= DO_SETLINK_NOTIFY;
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 392e29a0227d..b445d492c115 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -630,7 +630,7 @@ static int dsa_of_probe(struct device *dev)
630 continue; 630 continue;
631 631
632 cd->sw_addr = be32_to_cpup(sw_addr); 632 cd->sw_addr = be32_to_cpup(sw_addr);
633 if (cd->sw_addr > PHY_MAX_ADDR) 633 if (cd->sw_addr >= PHY_MAX_ADDR)
634 continue; 634 continue;
635 635
636 if (!of_property_read_u32(child, "eeprom-length", &eeprom_len)) 636 if (!of_property_read_u32(child, "eeprom-length", &eeprom_len))
@@ -642,6 +642,8 @@ static int dsa_of_probe(struct device *dev)
642 continue; 642 continue;
643 643
644 port_index = be32_to_cpup(port_reg); 644 port_index = be32_to_cpup(port_reg);
645 if (port_index >= DSA_MAX_PORTS)
646 break;
645 647
646 port_name = of_get_property(port, "label", NULL); 648 port_name = of_get_property(port, "label", NULL);
647 if (!port_name) 649 if (!port_name)
@@ -666,8 +668,6 @@ static int dsa_of_probe(struct device *dev)
666 goto out_free_chip; 668 goto out_free_chip;
667 } 669 }
668 670
669 if (port_index == DSA_MAX_PORTS)
670 break;
671 } 671 }
672 } 672 }
673 673
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 7498716e8f54..e813196c91c7 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1740,6 +1740,8 @@ static int inet_netconf_msgsize_devconf(int type)
1740 size += nla_total_size(4); 1740 size += nla_total_size(4);
1741 if (type == -1 || type == NETCONFA_PROXY_NEIGH) 1741 if (type == -1 || type == NETCONFA_PROXY_NEIGH)
1742 size += nla_total_size(4); 1742 size += nla_total_size(4);
1743 if (type == -1 || type == NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN)
1744 size += nla_total_size(4);
1743 1745
1744 return size; 1746 return size;
1745} 1747}
@@ -1780,6 +1782,10 @@ static int inet_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
1780 nla_put_s32(skb, NETCONFA_PROXY_NEIGH, 1782 nla_put_s32(skb, NETCONFA_PROXY_NEIGH,
1781 IPV4_DEVCONF(*devconf, PROXY_ARP)) < 0) 1783 IPV4_DEVCONF(*devconf, PROXY_ARP)) < 0)
1782 goto nla_put_failure; 1784 goto nla_put_failure;
1785 if ((type == -1 || type == NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN) &&
1786 nla_put_s32(skb, NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
1787 IPV4_DEVCONF(*devconf, IGNORE_ROUTES_WITH_LINKDOWN)) < 0)
1788 goto nla_put_failure;
1783 1789
1784 nlmsg_end(skb, nlh); 1790 nlmsg_end(skb, nlh);
1785 return 0; 1791 return 0;
@@ -1819,6 +1825,7 @@ static const struct nla_policy devconf_ipv4_policy[NETCONFA_MAX+1] = {
1819 [NETCONFA_FORWARDING] = { .len = sizeof(int) }, 1825 [NETCONFA_FORWARDING] = { .len = sizeof(int) },
1820 [NETCONFA_RP_FILTER] = { .len = sizeof(int) }, 1826 [NETCONFA_RP_FILTER] = { .len = sizeof(int) },
1821 [NETCONFA_PROXY_NEIGH] = { .len = sizeof(int) }, 1827 [NETCONFA_PROXY_NEIGH] = { .len = sizeof(int) },
1828 [NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN] = { .len = sizeof(int) },
1822}; 1829};
1823 1830
1824static int inet_netconf_get_devconf(struct sk_buff *in_skb, 1831static int inet_netconf_get_devconf(struct sk_buff *in_skb,
@@ -2048,6 +2055,12 @@ static int devinet_conf_proc(struct ctl_table *ctl, int write,
2048 inet_netconf_notify_devconf(net, NETCONFA_PROXY_NEIGH, 2055 inet_netconf_notify_devconf(net, NETCONFA_PROXY_NEIGH,
2049 ifindex, cnf); 2056 ifindex, cnf);
2050 } 2057 }
2058 if (i == IPV4_DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN - 1 &&
2059 new_value != old_value) {
2060 ifindex = devinet_conf_ifindex(net, cnf);
2061 inet_netconf_notify_devconf(net, NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
2062 ifindex, cnf);
2063 }
2051 } 2064 }
2052 2065
2053 return ret; 2066 return ret;
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 9bc26677058e..c3b1f3a0f4cf 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -152,8 +152,8 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
152 inet6_sk(sk)->tclass) < 0) 152 inet6_sk(sk)->tclass) < 0)
153 goto errout; 153 goto errout;
154 154
155 if (ipv6_only_sock(sk) && 155 if (((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE)) &&
156 nla_put_u8(skb, INET_DIAG_SKV6ONLY, 1)) 156 nla_put_u8(skb, INET_DIAG_SKV6ONLY, ipv6_only_sock(sk)))
157 goto errout; 157 goto errout;
158 } 158 }
159#endif 159#endif
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 4c2c3ba4ba65..626d9e56a6bd 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -586,7 +586,8 @@ int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t,
586EXPORT_SYMBOL(ip_tunnel_encap); 586EXPORT_SYMBOL(ip_tunnel_encap);
587 587
588static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb, 588static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
589 struct rtable *rt, __be16 df) 589 struct rtable *rt, __be16 df,
590 const struct iphdr *inner_iph)
590{ 591{
591 struct ip_tunnel *tunnel = netdev_priv(dev); 592 struct ip_tunnel *tunnel = netdev_priv(dev);
592 int pkt_size = skb->len - tunnel->hlen - dev->hard_header_len; 593 int pkt_size = skb->len - tunnel->hlen - dev->hard_header_len;
@@ -603,7 +604,8 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
603 604
604 if (skb->protocol == htons(ETH_P_IP)) { 605 if (skb->protocol == htons(ETH_P_IP)) {
605 if (!skb_is_gso(skb) && 606 if (!skb_is_gso(skb) &&
606 (df & htons(IP_DF)) && mtu < pkt_size) { 607 (inner_iph->frag_off & htons(IP_DF)) &&
608 mtu < pkt_size) {
607 memset(IPCB(skb), 0, sizeof(*IPCB(skb))); 609 memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
608 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu)); 610 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu));
609 return -E2BIG; 611 return -E2BIG;
@@ -737,7 +739,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
737 goto tx_error; 739 goto tx_error;
738 } 740 }
739 741
740 if (tnl_update_pmtu(dev, skb, rt, tnl_params->frag_off)) { 742 if (tnl_update_pmtu(dev, skb, rt, tnl_params->frag_off, inner_iph)) {
741 ip_rt_put(rt); 743 ip_rt_put(rt);
742 goto tx_error; 744 goto tx_error;
743 } 745 }
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 95c9b6eece25..92305a1a021a 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -254,9 +254,10 @@ unsigned int arpt_do_table(struct sk_buff *skb,
254 static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long)))); 254 static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
255 unsigned int verdict = NF_DROP; 255 unsigned int verdict = NF_DROP;
256 const struct arphdr *arp; 256 const struct arphdr *arp;
257 struct arpt_entry *e, *back; 257 struct arpt_entry *e, **jumpstack;
258 const char *indev, *outdev; 258 const char *indev, *outdev;
259 const void *table_base; 259 const void *table_base;
260 unsigned int cpu, stackidx = 0;
260 const struct xt_table_info *private; 261 const struct xt_table_info *private;
261 struct xt_action_param acpar; 262 struct xt_action_param acpar;
262 unsigned int addend; 263 unsigned int addend;
@@ -270,15 +271,16 @@ unsigned int arpt_do_table(struct sk_buff *skb,
270 local_bh_disable(); 271 local_bh_disable();
271 addend = xt_write_recseq_begin(); 272 addend = xt_write_recseq_begin();
272 private = table->private; 273 private = table->private;
274 cpu = smp_processor_id();
273 /* 275 /*
274 * Ensure we load private-> members after we've fetched the base 276 * Ensure we load private-> members after we've fetched the base
275 * pointer. 277 * pointer.
276 */ 278 */
277 smp_read_barrier_depends(); 279 smp_read_barrier_depends();
278 table_base = private->entries; 280 table_base = private->entries;
281 jumpstack = (struct arpt_entry **)private->jumpstack[cpu];
279 282
280 e = get_entry(table_base, private->hook_entry[hook]); 283 e = get_entry(table_base, private->hook_entry[hook]);
281 back = get_entry(table_base, private->underflow[hook]);
282 284
283 acpar.in = state->in; 285 acpar.in = state->in;
284 acpar.out = state->out; 286 acpar.out = state->out;
@@ -312,18 +314,23 @@ unsigned int arpt_do_table(struct sk_buff *skb,
312 verdict = (unsigned int)(-v) - 1; 314 verdict = (unsigned int)(-v) - 1;
313 break; 315 break;
314 } 316 }
315 e = back; 317 if (stackidx == 0) {
316 back = get_entry(table_base, back->comefrom); 318 e = get_entry(table_base,
319 private->underflow[hook]);
320 } else {
321 e = jumpstack[--stackidx];
322 e = arpt_next_entry(e);
323 }
317 continue; 324 continue;
318 } 325 }
319 if (table_base + v 326 if (table_base + v
320 != arpt_next_entry(e)) { 327 != arpt_next_entry(e)) {
321 /* Save old back ptr in next entry */
322 struct arpt_entry *next = arpt_next_entry(e);
323 next->comefrom = (void *)back - table_base;
324 328
325 /* set back pointer to next entry */ 329 if (stackidx >= private->stacksize) {
326 back = next; 330 verdict = NF_DROP;
331 break;
332 }
333 jumpstack[stackidx++] = e;
327 } 334 }
328 335
329 e = get_entry(table_base, v); 336 e = get_entry(table_base, v);
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index f2e464eba5ef..57990c929cd8 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -331,10 +331,10 @@ int ip6_mc_input(struct sk_buff *skb)
331 if (offset < 0) 331 if (offset < 0)
332 goto out; 332 goto out;
333 333
334 if (!ipv6_is_mld(skb, nexthdr, offset)) 334 if (ipv6_is_mld(skb, nexthdr, offset))
335 goto out; 335 deliver = true;
336 336
337 deliver = true; 337 goto out;
338 } 338 }
339 /* unknown RA - process it normally */ 339 /* unknown RA - process it normally */
340 } 340 }
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 1a1122a6bbf5..6090969937f8 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -369,10 +369,7 @@ static void ip6_dst_destroy(struct dst_entry *dst)
369 struct inet6_dev *idev; 369 struct inet6_dev *idev;
370 370
371 dst_destroy_metrics_generic(dst); 371 dst_destroy_metrics_generic(dst);
372 372 free_percpu(rt->rt6i_pcpu);
373 if (rt->rt6i_pcpu)
374 free_percpu(rt->rt6i_pcpu);
375
376 rt6_uncached_list_del(rt); 373 rt6_uncached_list_del(rt);
377 374
378 idev = rt->rt6i_idev; 375 idev = rt->rt6i_idev;
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index cd60d397fe05..8a8b2abc35ff 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -213,7 +213,7 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
213 213
214 if (verdict == NF_ACCEPT) { 214 if (verdict == NF_ACCEPT) {
215 next_hook: 215 next_hook:
216 verdict = nf_iterate(&nf_hooks[entry->state.pf][entry->state.hook], 216 verdict = nf_iterate(entry->state.hook_list,
217 skb, &entry->state, &elem); 217 skb, &entry->state, &elem);
218 } 218 }
219 219
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 8b117c90ecd7..0c0e8ecf02ab 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -269,6 +269,12 @@ static void nfnl_err_deliver(struct list_head *err_list, struct sk_buff *skb)
269 } 269 }
270} 270}
271 271
272enum {
273 NFNL_BATCH_FAILURE = (1 << 0),
274 NFNL_BATCH_DONE = (1 << 1),
275 NFNL_BATCH_REPLAY = (1 << 2),
276};
277
272static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh, 278static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
273 u_int16_t subsys_id) 279 u_int16_t subsys_id)
274{ 280{
@@ -276,13 +282,15 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
276 struct net *net = sock_net(skb->sk); 282 struct net *net = sock_net(skb->sk);
277 const struct nfnetlink_subsystem *ss; 283 const struct nfnetlink_subsystem *ss;
278 const struct nfnl_callback *nc; 284 const struct nfnl_callback *nc;
279 bool success = true, done = false;
280 static LIST_HEAD(err_list); 285 static LIST_HEAD(err_list);
286 u32 status;
281 int err; 287 int err;
282 288
283 if (subsys_id >= NFNL_SUBSYS_COUNT) 289 if (subsys_id >= NFNL_SUBSYS_COUNT)
284 return netlink_ack(skb, nlh, -EINVAL); 290 return netlink_ack(skb, nlh, -EINVAL);
285replay: 291replay:
292 status = 0;
293
286 skb = netlink_skb_clone(oskb, GFP_KERNEL); 294 skb = netlink_skb_clone(oskb, GFP_KERNEL);
287 if (!skb) 295 if (!skb)
288 return netlink_ack(oskb, nlh, -ENOMEM); 296 return netlink_ack(oskb, nlh, -ENOMEM);
@@ -336,10 +344,10 @@ replay:
336 if (type == NFNL_MSG_BATCH_BEGIN) { 344 if (type == NFNL_MSG_BATCH_BEGIN) {
337 /* Malformed: Batch begin twice */ 345 /* Malformed: Batch begin twice */
338 nfnl_err_reset(&err_list); 346 nfnl_err_reset(&err_list);
339 success = false; 347 status |= NFNL_BATCH_FAILURE;
340 goto done; 348 goto done;
341 } else if (type == NFNL_MSG_BATCH_END) { 349 } else if (type == NFNL_MSG_BATCH_END) {
342 done = true; 350 status |= NFNL_BATCH_DONE;
343 goto done; 351 goto done;
344 } else if (type < NLMSG_MIN_TYPE) { 352 } else if (type < NLMSG_MIN_TYPE) {
345 err = -EINVAL; 353 err = -EINVAL;
@@ -382,11 +390,8 @@ replay:
382 * original skb. 390 * original skb.
383 */ 391 */
384 if (err == -EAGAIN) { 392 if (err == -EAGAIN) {
385 nfnl_err_reset(&err_list); 393 status |= NFNL_BATCH_REPLAY;
386 ss->abort(oskb); 394 goto next;
387 nfnl_unlock(subsys_id);
388 kfree_skb(skb);
389 goto replay;
390 } 395 }
391 } 396 }
392ack: 397ack:
@@ -402,7 +407,7 @@ ack:
402 */ 407 */
403 nfnl_err_reset(&err_list); 408 nfnl_err_reset(&err_list);
404 netlink_ack(skb, nlmsg_hdr(oskb), -ENOMEM); 409 netlink_ack(skb, nlmsg_hdr(oskb), -ENOMEM);
405 success = false; 410 status |= NFNL_BATCH_FAILURE;
406 goto done; 411 goto done;
407 } 412 }
408 /* We don't stop processing the batch on errors, thus, 413 /* We don't stop processing the batch on errors, thus,
@@ -410,19 +415,26 @@ ack:
410 * triggers. 415 * triggers.
411 */ 416 */
412 if (err) 417 if (err)
413 success = false; 418 status |= NFNL_BATCH_FAILURE;
414 } 419 }
415 420next:
416 msglen = NLMSG_ALIGN(nlh->nlmsg_len); 421 msglen = NLMSG_ALIGN(nlh->nlmsg_len);
417 if (msglen > skb->len) 422 if (msglen > skb->len)
418 msglen = skb->len; 423 msglen = skb->len;
419 skb_pull(skb, msglen); 424 skb_pull(skb, msglen);
420 } 425 }
421done: 426done:
422 if (success && done) 427 if (status & NFNL_BATCH_REPLAY) {
428 ss->abort(oskb);
429 nfnl_err_reset(&err_list);
430 nfnl_unlock(subsys_id);
431 kfree_skb(skb);
432 goto replay;
433 } else if (status == NFNL_BATCH_DONE) {
423 ss->commit(oskb); 434 ss->commit(oskb);
424 else 435 } else {
425 ss->abort(oskb); 436 ss->abort(oskb);
437 }
426 438
427 nfnl_err_deliver(&err_list, oskb); 439 nfnl_err_deliver(&err_list, oskb);
428 nfnl_unlock(subsys_id); 440 nfnl_unlock(subsys_id);
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index dea925388a5b..9a0ae7172f92 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -158,7 +158,7 @@ static int __netlink_remove_tap(struct netlink_tap *nt)
158out: 158out:
159 spin_unlock(&netlink_tap_lock); 159 spin_unlock(&netlink_tap_lock);
160 160
161 if (found && nt->module) 161 if (found)
162 module_put(nt->module); 162 module_put(nt->module);
163 163
164 return found ? 0 : -ENODEV; 164 return found ? 0 : -ENODEV;
diff --git a/net/rds/transport.c b/net/rds/transport.c
index 8b4a6cd2c3a7..83498e1c75b8 100644
--- a/net/rds/transport.c
+++ b/net/rds/transport.c
@@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(rds_trans_unregister);
73 73
74void rds_trans_put(struct rds_transport *trans) 74void rds_trans_put(struct rds_transport *trans)
75{ 75{
76 if (trans && trans->t_owner) 76 if (trans)
77 module_put(trans->t_owner); 77 module_put(trans->t_owner);
78} 78}
79 79
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 84f77a054025..9f2add3cba26 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -171,8 +171,10 @@ int switchdev_port_attr_set(struct net_device *dev, struct switchdev_attr *attr)
171 * released. 171 * released.
172 */ 172 */
173 173
174 attr->trans = SWITCHDEV_TRANS_ABORT; 174 if (err != -EOPNOTSUPP) {
175 __switchdev_port_attr_set(dev, attr); 175 attr->trans = SWITCHDEV_TRANS_ABORT;
176 __switchdev_port_attr_set(dev, attr);
177 }
176 178
177 return err; 179 return err;
178 } 180 }
@@ -249,8 +251,10 @@ int switchdev_port_obj_add(struct net_device *dev, struct switchdev_obj *obj)
249 * released. 251 * released.
250 */ 252 */
251 253
252 obj->trans = SWITCHDEV_TRANS_ABORT; 254 if (err != -EOPNOTSUPP) {
253 __switchdev_port_obj_add(dev, obj); 255 obj->trans = SWITCHDEV_TRANS_ABORT;
256 __switchdev_port_obj_add(dev, obj);
257 }
254 258
255 return err; 259 return err;
256 } 260 }
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 46b6ed534ef2..3a7567f690f3 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2007,6 +2007,7 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags)
2007 res = tipc_sk_create(sock_net(sock->sk), new_sock, 0, 1); 2007 res = tipc_sk_create(sock_net(sock->sk), new_sock, 0, 1);
2008 if (res) 2008 if (res)
2009 goto exit; 2009 goto exit;
2010 security_sk_clone(sock->sk, new_sock->sk);
2010 2011
2011 new_sk = new_sock->sk; 2012 new_sk = new_sock->sk;
2012 new_tsock = tipc_sk(new_sk); 2013 new_tsock = tipc_sk(new_sk);