aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MAINTAINERS6
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c32
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c32
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c32
-rw-r--r--drivers/isdn/hisax/config.c16
-rw-r--r--drivers/isdn/hisax/hisax.h4
-rw-r--r--drivers/isdn/i4l/isdn_concap.c6
-rw-r--r--drivers/isdn/i4l/isdn_x25iface.c16
-rw-r--r--drivers/net/dsa/mv88e6xxx/chip.c6
-rw-r--r--drivers/net/ethernet/3com/3c515.c15
-rw-r--r--drivers/net/ethernet/brocade/bna/bna_enet.c8
-rw-r--r--drivers/net/ethernet/cadence/Kconfig9
-rw-r--r--drivers/net/ethernet/cadence/Makefile1
-rw-r--r--drivers/net/ethernet/cadence/macb.c31
-rw-r--r--drivers/net/ethernet/cadence/macb_pci.c153
-rw-r--r--drivers/net/ethernet/chelsio/cxgb/cxgb2.c64
-rw-r--r--drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c65
-rw-r--r--drivers/net/ethernet/cirrus/ep93xx_eth.c14
-rw-r--r--drivers/net/ethernet/davicom/dm9000.c14
-rw-r--r--drivers/net/ethernet/freescale/dpaa/Kconfig2
-rw-r--r--drivers/net/ethernet/freescale/dpaa/dpaa_eth.c71
-rw-r--r--drivers/net/ethernet/hisilicon/hip04_eth.c2
-rw-r--r--drivers/net/ethernet/hisilicon/hisi_femac.c2
-rw-r--r--drivers/net/ethernet/ibm/ibmveth.c12
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum.c2
-rw-r--r--drivers/net/ethernet/microchip/encx24j600-regmap.c17
-rw-r--r--drivers/net/ethernet/microchip/encx24j600.c19
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_iscsi.c2
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac.c9
-rw-r--r--drivers/net/ethernet/rdc/r6040.c10
-rw-r--r--drivers/net/ethernet/sfc/ethtool.c35
-rw-r--r--drivers/net/ethernet/sfc/mcdi_port.c60
-rw-r--r--drivers/net/ethernet/sfc/net_driver.h12
-rw-r--r--drivers/net/gtp.c8
-rw-r--r--drivers/net/irda/w83977af_ir.c6
-rw-r--r--drivers/net/virtio_net.c369
-rw-r--r--drivers/net/vrf.c6
-rw-r--r--drivers/net/wan/lmc/lmc_media.c97
-rw-r--r--include/linux/bpf-cgroup.h2
-rw-r--r--include/linux/bpf.h13
-rw-r--r--include/linux/filter.h15
-rw-r--r--include/linux/miscdevice.h1
-rw-r--r--include/linux/platform_data/macb.h6
-rw-r--r--include/net/inet6_connection_sock.h3
-rw-r--r--include/net/inet_connection_sock.h6
-rw-r--r--include/net/netlink.h3
-rw-r--r--init/Kconfig3
-rw-r--r--kernel/bpf/core.c43
-rw-r--r--kernel/bpf/syscall.c38
-rw-r--r--kernel/bpf/verifier.c28
-rw-r--r--net/atm/lec.c6
-rw-r--r--net/atm/mpoa_caches.c43
-rw-r--r--net/core/filter.c6
-rw-r--r--net/decnet/dn_dev.c2
-rw-r--r--net/ipv4/inet_connection_sock.c16
-rw-r--r--net/ipv6/inet6_connection_sock.c7
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/irda/irnet/irnet.h1
-rw-r--r--net/irda/irnet/irnet_ppp.h11
-rw-r--r--net/irda/irproc.c1
-rw-r--r--net/mac80211/key.c3
-rw-r--r--net/mac80211/rx.c2
-rw-r--r--net/mac80211/sta_info.c14
-rw-r--r--net/sched/cls_flower.c6
-rw-r--r--net/sctp/endpointola.c5
-rw-r--r--net/sctp/socket.c7
-rw-r--r--net/vmw_vsock/vmci_transport_notify.c30
-rw-r--r--net/vmw_vsock/vmci_transport_notify_qstate.c30
-rw-r--r--net/x25/sysctl_net_x25.c2
-rw-r--r--tools/testing/selftests/bpf/test_verifier.c30
71 files changed, 1206 insertions, 446 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index bf8690d0a1e1..f39414662ab6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5163,6 +5163,12 @@ S: Maintained
5163F: drivers/net/ethernet/freescale/fman 5163F: drivers/net/ethernet/freescale/fman
5164F: Documentation/devicetree/bindings/powerpc/fsl/fman.txt 5164F: Documentation/devicetree/bindings/powerpc/fsl/fman.txt
5165 5165
5166FREESCALE QORIQ DPAA ETHERNET DRIVER
5167M: Madalin Bucur <madalin.bucur@nxp.com>
5168L: netdev@vger.kernel.org
5169S: Maintained
5170F: drivers/net/ethernet/freescale/dpaa
5171
5166FREESCALE SOC DRIVERS 5172FREESCALE SOC DRIVERS
5167M: Scott Wood <oss@buserror.net> 5173M: Scott Wood <oss@buserror.net>
5168L: linuxppc-dev@lists.ozlabs.org 5174L: linuxppc-dev@lists.ozlabs.org
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index aecec6d32463..11e13c56126f 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -2565,22 +2565,22 @@ static int gigaset_post_reset(struct usb_interface *intf)
2565 2565
2566 2566
2567static const struct gigaset_ops gigops = { 2567static const struct gigaset_ops gigops = {
2568 gigaset_write_cmd, 2568 .write_cmd = gigaset_write_cmd,
2569 gigaset_write_room, 2569 .write_room = gigaset_write_room,
2570 gigaset_chars_in_buffer, 2570 .chars_in_buffer = gigaset_chars_in_buffer,
2571 gigaset_brkchars, 2571 .brkchars = gigaset_brkchars,
2572 gigaset_init_bchannel, 2572 .init_bchannel = gigaset_init_bchannel,
2573 gigaset_close_bchannel, 2573 .close_bchannel = gigaset_close_bchannel,
2574 gigaset_initbcshw, 2574 .initbcshw = gigaset_initbcshw,
2575 gigaset_freebcshw, 2575 .freebcshw = gigaset_freebcshw,
2576 gigaset_reinitbcshw, 2576 .reinitbcshw = gigaset_reinitbcshw,
2577 gigaset_initcshw, 2577 .initcshw = gigaset_initcshw,
2578 gigaset_freecshw, 2578 .freecshw = gigaset_freecshw,
2579 gigaset_set_modem_ctrl, 2579 .set_modem_ctrl = gigaset_set_modem_ctrl,
2580 gigaset_baud_rate, 2580 .baud_rate = gigaset_baud_rate,
2581 gigaset_set_line_ctrl, 2581 .set_line_ctrl = gigaset_set_line_ctrl,
2582 gigaset_isoc_send_skb, 2582 .send_skb = gigaset_isoc_send_skb,
2583 gigaset_isoc_input, 2583 .handle_input = gigaset_isoc_input,
2584}; 2584};
2585 2585
2586/* bas_gigaset_init 2586/* bas_gigaset_init
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index b90776ef56ec..ab0b63a4d045 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -445,22 +445,22 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
445} 445}
446 446
447static const struct gigaset_ops ops = { 447static const struct gigaset_ops ops = {
448 gigaset_write_cmd, 448 .write_cmd = gigaset_write_cmd,
449 gigaset_write_room, 449 .write_room = gigaset_write_room,
450 gigaset_chars_in_buffer, 450 .chars_in_buffer = gigaset_chars_in_buffer,
451 gigaset_brkchars, 451 .brkchars = gigaset_brkchars,
452 gigaset_init_bchannel, 452 .init_bchannel = gigaset_init_bchannel,
453 gigaset_close_bchannel, 453 .close_bchannel = gigaset_close_bchannel,
454 gigaset_initbcshw, 454 .initbcshw = gigaset_initbcshw,
455 gigaset_freebcshw, 455 .freebcshw = gigaset_freebcshw,
456 gigaset_reinitbcshw, 456 .reinitbcshw = gigaset_reinitbcshw,
457 gigaset_initcshw, 457 .initcshw = gigaset_initcshw,
458 gigaset_freecshw, 458 .freecshw = gigaset_freecshw,
459 gigaset_set_modem_ctrl, 459 .set_modem_ctrl = gigaset_set_modem_ctrl,
460 gigaset_baud_rate, 460 .baud_rate = gigaset_baud_rate,
461 gigaset_set_line_ctrl, 461 .set_line_ctrl = gigaset_set_line_ctrl,
462 gigaset_m10x_send_skb, /* asyncdata.c */ 462 .send_skb = gigaset_m10x_send_skb, /* asyncdata.c */
463 gigaset_m10x_input, /* asyncdata.c */ 463 .handle_input = gigaset_m10x_input, /* asyncdata.c */
464}; 464};
465 465
466 466
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 5f306e2eece5..eade36dafa34 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -862,22 +862,22 @@ static int gigaset_pre_reset(struct usb_interface *intf)
862} 862}
863 863
864static const struct gigaset_ops ops = { 864static const struct gigaset_ops ops = {
865 gigaset_write_cmd, 865 .write_cmd = gigaset_write_cmd,
866 gigaset_write_room, 866 .write_room = gigaset_write_room,
867 gigaset_chars_in_buffer, 867 .chars_in_buffer = gigaset_chars_in_buffer,
868 gigaset_brkchars, 868 .brkchars = gigaset_brkchars,
869 gigaset_init_bchannel, 869 .init_bchannel = gigaset_init_bchannel,
870 gigaset_close_bchannel, 870 .close_bchannel = gigaset_close_bchannel,
871 gigaset_initbcshw, 871 .initbcshw = gigaset_initbcshw,
872 gigaset_freebcshw, 872 .freebcshw = gigaset_freebcshw,
873 gigaset_reinitbcshw, 873 .reinitbcshw = gigaset_reinitbcshw,
874 gigaset_initcshw, 874 .initcshw = gigaset_initcshw,
875 gigaset_freecshw, 875 .freecshw = gigaset_freecshw,
876 gigaset_set_modem_ctrl, 876 .set_modem_ctrl = gigaset_set_modem_ctrl,
877 gigaset_baud_rate, 877 .baud_rate = gigaset_baud_rate,
878 gigaset_set_line_ctrl, 878 .set_line_ctrl = gigaset_set_line_ctrl,
879 gigaset_m10x_send_skb, 879 .send_skb = gigaset_m10x_send_skb,
880 gigaset_m10x_input, 880 .handle_input = gigaset_m10x_input,
881}; 881};
882 882
883/* 883/*
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index bf04d2a3cf4a..2d12c6ceeb89 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -659,7 +659,7 @@ int jiftime(char *s, long mark)
659 659
660static u_char tmpbuf[HISAX_STATUS_BUFSIZE]; 660static u_char tmpbuf[HISAX_STATUS_BUFSIZE];
661 661
662void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, 662void VHiSax_putstatus(struct IsdnCardState *cs, char *head, const char *fmt,
663 va_list args) 663 va_list args)
664{ 664{
665 /* if head == NULL the fmt contains the full info */ 665 /* if head == NULL the fmt contains the full info */
@@ -669,23 +669,24 @@ void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
669 u_char *p; 669 u_char *p;
670 isdn_ctrl ic; 670 isdn_ctrl ic;
671 int len; 671 int len;
672 const u_char *data;
672 673
673 if (!cs) { 674 if (!cs) {
674 printk(KERN_WARNING "HiSax: No CardStatus for message"); 675 printk(KERN_WARNING "HiSax: No CardStatus for message");
675 return; 676 return;
676 } 677 }
677 spin_lock_irqsave(&cs->statlock, flags); 678 spin_lock_irqsave(&cs->statlock, flags);
678 p = tmpbuf;
679 if (head) { 679 if (head) {
680 p = tmpbuf;
680 p += jiftime(p, jiffies); 681 p += jiftime(p, jiffies);
681 p += sprintf(p, " %s", head); 682 p += sprintf(p, " %s", head);
682 p += vsprintf(p, fmt, args); 683 p += vsprintf(p, fmt, args);
683 *p++ = '\n'; 684 *p++ = '\n';
684 *p = 0; 685 *p = 0;
685 len = p - tmpbuf; 686 len = p - tmpbuf;
686 p = tmpbuf; 687 data = tmpbuf;
687 } else { 688 } else {
688 p = fmt; 689 data = fmt;
689 len = strlen(fmt); 690 len = strlen(fmt);
690 } 691 }
691 if (len > HISAX_STATUS_BUFSIZE) { 692 if (len > HISAX_STATUS_BUFSIZE) {
@@ -699,13 +700,12 @@ void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
699 if (i >= len) 700 if (i >= len)
700 i = len; 701 i = len;
701 len -= i; 702 len -= i;
702 memcpy(cs->status_write, p, i); 703 memcpy(cs->status_write, data, i);
703 cs->status_write += i; 704 cs->status_write += i;
704 if (cs->status_write > cs->status_end) 705 if (cs->status_write > cs->status_end)
705 cs->status_write = cs->status_buf; 706 cs->status_write = cs->status_buf;
706 p += i;
707 if (len) { 707 if (len) {
708 memcpy(cs->status_write, p, len); 708 memcpy(cs->status_write, data + i, len);
709 cs->status_write += len; 709 cs->status_write += len;
710 } 710 }
711#ifdef KERNELSTACK_DEBUG 711#ifdef KERNELSTACK_DEBUG
@@ -729,7 +729,7 @@ void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
729 } 729 }
730} 730}
731 731
732void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...) 732void HiSax_putstatus(struct IsdnCardState *cs, char *head, const char *fmt, ...)
733{ 733{
734 va_list args; 734 va_list args;
735 735
diff --git a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h
index 6ead6314e6d2..338d0408b377 100644
--- a/drivers/isdn/hisax/hisax.h
+++ b/drivers/isdn/hisax/hisax.h
@@ -1288,9 +1288,9 @@ int jiftime(char *s, long mark);
1288int HiSax_command(isdn_ctrl *ic); 1288int HiSax_command(isdn_ctrl *ic);
1289int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb); 1289int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb);
1290__printf(3, 4) 1290__printf(3, 4)
1291void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...); 1291void HiSax_putstatus(struct IsdnCardState *cs, char *head, const char *fmt, ...);
1292__printf(3, 0) 1292__printf(3, 0)
1293void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, va_list args); 1293void VHiSax_putstatus(struct IsdnCardState *cs, char *head, const char *fmt, va_list args);
1294void HiSax_reportcard(int cardnr, int sel); 1294void HiSax_reportcard(int cardnr, int sel);
1295int QuickHex(char *txt, u_char *p, int cnt); 1295int QuickHex(char *txt, u_char *p, int cnt);
1296void LogFrame(struct IsdnCardState *cs, u_char *p, int size); 1296void LogFrame(struct IsdnCardState *cs, u_char *p, int size);
diff --git a/drivers/isdn/i4l/isdn_concap.c b/drivers/isdn/i4l/isdn_concap.c
index 91d57304d4d3..336523ec077c 100644
--- a/drivers/isdn/i4l/isdn_concap.c
+++ b/drivers/isdn/i4l/isdn_concap.c
@@ -80,9 +80,9 @@ static int isdn_concap_dl_disconn_req(struct concap_proto *concap)
80} 80}
81 81
82struct concap_device_ops isdn_concap_reliable_dl_dops = { 82struct concap_device_ops isdn_concap_reliable_dl_dops = {
83 &isdn_concap_dl_data_req, 83 .data_req = &isdn_concap_dl_data_req,
84 &isdn_concap_dl_connect_req, 84 .connect_req = &isdn_concap_dl_connect_req,
85 &isdn_concap_dl_disconn_req 85 .disconn_req = &isdn_concap_dl_disconn_req
86}; 86};
87 87
88/* The following should better go into a dedicated source file such that 88/* The following should better go into a dedicated source file such that
diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
index 0c5d8de41b23..ba60076e0b95 100644
--- a/drivers/isdn/i4l/isdn_x25iface.c
+++ b/drivers/isdn/i4l/isdn_x25iface.c
@@ -53,14 +53,14 @@ static int isdn_x25iface_disconn_ind(struct concap_proto *);
53 53
54 54
55static struct concap_proto_ops ix25_pops = { 55static struct concap_proto_ops ix25_pops = {
56 &isdn_x25iface_proto_new, 56 .proto_new = &isdn_x25iface_proto_new,
57 &isdn_x25iface_proto_del, 57 .proto_del = &isdn_x25iface_proto_del,
58 &isdn_x25iface_proto_restart, 58 .restart = &isdn_x25iface_proto_restart,
59 &isdn_x25iface_proto_close, 59 .close = &isdn_x25iface_proto_close,
60 &isdn_x25iface_xmit, 60 .encap_and_xmit = &isdn_x25iface_xmit,
61 &isdn_x25iface_receive, 61 .data_ind = &isdn_x25iface_receive,
62 &isdn_x25iface_connect_ind, 62 .connect_ind = &isdn_x25iface_connect_ind,
63 &isdn_x25iface_disconn_ind 63 .disconn_ind = &isdn_x25iface_disconn_ind
64}; 64};
65 65
66/* error message helper function */ 66/* error message helper function */
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 4da379f28d5d..f7222dc6581d 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1775,6 +1775,9 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1775 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i)) 1775 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1776 continue; 1776 continue;
1777 1777
1778 if (!ds->ports[port].netdev)
1779 continue;
1780
1778 if (vlan.data[i] == 1781 if (vlan.data[i] ==
1779 GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER) 1782 GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER)
1780 continue; 1783 continue;
@@ -1783,6 +1786,9 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1783 chip->ports[port].bridge_dev) 1786 chip->ports[port].bridge_dev)
1784 break; /* same bridge, check next VLAN */ 1787 break; /* same bridge, check next VLAN */
1785 1788
1789 if (!chip->ports[i].bridge_dev)
1790 continue;
1791
1786 netdev_warn(ds->ports[port].netdev, 1792 netdev_warn(ds->ports[port].netdev,
1787 "hardware VLAN %d already used by %s\n", 1793 "hardware VLAN %d already used by %s\n",
1788 vlan.vid, 1794 vlan.vid,
diff --git a/drivers/net/ethernet/3com/3c515.c b/drivers/net/ethernet/3com/3c515.c
index b9f4c463e516..be5b80103bec 100644
--- a/drivers/net/ethernet/3com/3c515.c
+++ b/drivers/net/ethernet/3com/3c515.c
@@ -627,6 +627,8 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
627 627
628 spin_lock_init(&vp->lock); 628 spin_lock_init(&vp->lock);
629 629
630 setup_timer(&vp->timer, corkscrew_timer, (unsigned long) dev);
631
630 /* Read the station address from the EEPROM. */ 632 /* Read the station address from the EEPROM. */
631 EL3WINDOW(0); 633 EL3WINDOW(0);
632 for (i = 0; i < 0x18; i++) { 634 for (i = 0; i < 0x18; i++) {
@@ -707,6 +709,7 @@ static int corkscrew_open(struct net_device *dev)
707{ 709{
708 int ioaddr = dev->base_addr; 710 int ioaddr = dev->base_addr;
709 struct corkscrew_private *vp = netdev_priv(dev); 711 struct corkscrew_private *vp = netdev_priv(dev);
712 bool armtimer = false;
710 __u32 config; 713 __u32 config;
711 int i; 714 int i;
712 715
@@ -731,12 +734,7 @@ static int corkscrew_open(struct net_device *dev)
731 if (corkscrew_debug > 1) 734 if (corkscrew_debug > 1)
732 pr_debug("%s: Initial media type %s.\n", 735 pr_debug("%s: Initial media type %s.\n",
733 dev->name, media_tbl[dev->if_port].name); 736 dev->name, media_tbl[dev->if_port].name);
734 737 armtimer = true;
735 init_timer(&vp->timer);
736 vp->timer.expires = jiffies + media_tbl[dev->if_port].wait;
737 vp->timer.data = (unsigned long) dev;
738 vp->timer.function = corkscrew_timer; /* timer handler */
739 add_timer(&vp->timer);
740 } else 738 } else
741 dev->if_port = vp->default_media; 739 dev->if_port = vp->default_media;
742 740
@@ -776,6 +774,9 @@ static int corkscrew_open(struct net_device *dev)
776 return -EAGAIN; 774 return -EAGAIN;
777 } 775 }
778 776
777 if (armtimer)
778 mod_timer(&vp->timer, jiffies + media_tbl[dev->if_port].wait);
779
779 if (corkscrew_debug > 1) { 780 if (corkscrew_debug > 1) {
780 EL3WINDOW(4); 781 EL3WINDOW(4);
781 pr_debug("%s: corkscrew_open() irq %d media status %4.4x.\n", 782 pr_debug("%s: corkscrew_open() irq %d media status %4.4x.\n",
@@ -1426,7 +1427,7 @@ static int corkscrew_close(struct net_device *dev)
1426 dev->name, rx_nocopy, rx_copy, queued_packet); 1427 dev->name, rx_nocopy, rx_copy, queued_packet);
1427 } 1428 }
1428 1429
1429 del_timer(&vp->timer); 1430 del_timer_sync(&vp->timer);
1430 1431
1431 /* Turn off statistics ASAP. We update lp->stats below. */ 1432 /* Turn off statistics ASAP. We update lp->stats below. */
1432 outw(StatsDisable, ioaddr + EL3_CMD); 1433 outw(StatsDisable, ioaddr + EL3_CMD);
diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c b/drivers/net/ethernet/brocade/bna/bna_enet.c
index 4e5c3874a50f..bba81735ce87 100644
--- a/drivers/net/ethernet/brocade/bna/bna_enet.c
+++ b/drivers/net/ethernet/brocade/bna/bna_enet.c
@@ -1676,10 +1676,10 @@ bna_cb_ioceth_reset(void *arg)
1676} 1676}
1677 1677
1678static struct bfa_ioc_cbfn bna_ioceth_cbfn = { 1678static struct bfa_ioc_cbfn bna_ioceth_cbfn = {
1679 bna_cb_ioceth_enable, 1679 .enable_cbfn = bna_cb_ioceth_enable,
1680 bna_cb_ioceth_disable, 1680 .disable_cbfn = bna_cb_ioceth_disable,
1681 bna_cb_ioceth_hbfail, 1681 .hbfail_cbfn = bna_cb_ioceth_hbfail,
1682 bna_cb_ioceth_reset 1682 .reset_cbfn = bna_cb_ioceth_reset
1683}; 1683};
1684 1684
1685static void bna_attr_init(struct bna_ioceth *ioceth) 1685static void bna_attr_init(struct bna_ioceth *ioceth)
diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
index f0bcb15d3fec..608bea171956 100644
--- a/drivers/net/ethernet/cadence/Kconfig
+++ b/drivers/net/ethernet/cadence/Kconfig
@@ -31,4 +31,13 @@ config MACB
31 To compile this driver as a module, choose M here: the module 31 To compile this driver as a module, choose M here: the module
32 will be called macb. 32 will be called macb.
33 33
34config MACB_PCI
35 tristate "Cadence PCI MACB/GEM support"
36 depends on MACB && PCI && COMMON_CLK
37 ---help---
38 This is PCI wrapper for MACB driver.
39
40 To compile this driver as a module, choose M here: the module
41 will be called macb_pci.
42
34endif # NET_CADENCE 43endif # NET_CADENCE
diff --git a/drivers/net/ethernet/cadence/Makefile b/drivers/net/ethernet/cadence/Makefile
index 91f79b1f0505..4ba75594d5c5 100644
--- a/drivers/net/ethernet/cadence/Makefile
+++ b/drivers/net/ethernet/cadence/Makefile
@@ -3,3 +3,4 @@
3# 3#
4 4
5obj-$(CONFIG_MACB) += macb.o 5obj-$(CONFIG_MACB) += macb.o
6obj-$(CONFIG_MACB_PCI) += macb_pci.o
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 538544a7c642..c0fb80acc2da 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -404,6 +404,8 @@ static int macb_mii_probe(struct net_device *dev)
404 phy_irq = gpio_to_irq(pdata->phy_irq_pin); 404 phy_irq = gpio_to_irq(pdata->phy_irq_pin);
405 phydev->irq = (phy_irq < 0) ? PHY_POLL : phy_irq; 405 phydev->irq = (phy_irq < 0) ? PHY_POLL : phy_irq;
406 } 406 }
407 } else {
408 phydev->irq = PHY_POLL;
407 } 409 }
408 410
409 /* attach the mac to the phy */ 411 /* attach the mac to the phy */
@@ -482,6 +484,9 @@ static int macb_mii_init(struct macb *bp)
482 goto err_out_unregister_bus; 484 goto err_out_unregister_bus;
483 } 485 }
484 } else { 486 } else {
487 for (i = 0; i < PHY_MAX_ADDR; i++)
488 bp->mii_bus->irq[i] = PHY_POLL;
489
485 if (pdata) 490 if (pdata)
486 bp->mii_bus->phy_mask = pdata->phy_mask; 491 bp->mii_bus->phy_mask = pdata->phy_mask;
487 492
@@ -2523,16 +2528,24 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
2523 struct clk **hclk, struct clk **tx_clk, 2528 struct clk **hclk, struct clk **tx_clk,
2524 struct clk **rx_clk) 2529 struct clk **rx_clk)
2525{ 2530{
2531 struct macb_platform_data *pdata;
2526 int err; 2532 int err;
2527 2533
2528 *pclk = devm_clk_get(&pdev->dev, "pclk"); 2534 pdata = dev_get_platdata(&pdev->dev);
2535 if (pdata) {
2536 *pclk = pdata->pclk;
2537 *hclk = pdata->hclk;
2538 } else {
2539 *pclk = devm_clk_get(&pdev->dev, "pclk");
2540 *hclk = devm_clk_get(&pdev->dev, "hclk");
2541 }
2542
2529 if (IS_ERR(*pclk)) { 2543 if (IS_ERR(*pclk)) {
2530 err = PTR_ERR(*pclk); 2544 err = PTR_ERR(*pclk);
2531 dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err); 2545 dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err);
2532 return err; 2546 return err;
2533 } 2547 }
2534 2548
2535 *hclk = devm_clk_get(&pdev->dev, "hclk");
2536 if (IS_ERR(*hclk)) { 2549 if (IS_ERR(*hclk)) {
2537 err = PTR_ERR(*hclk); 2550 err = PTR_ERR(*hclk);
2538 dev_err(&pdev->dev, "failed to get hclk (%u)\n", err); 2551 dev_err(&pdev->dev, "failed to get hclk (%u)\n", err);
@@ -3107,15 +3120,23 @@ static const struct of_device_id macb_dt_ids[] = {
3107MODULE_DEVICE_TABLE(of, macb_dt_ids); 3120MODULE_DEVICE_TABLE(of, macb_dt_ids);
3108#endif /* CONFIG_OF */ 3121#endif /* CONFIG_OF */
3109 3122
3123static const struct macb_config default_gem_config = {
3124 .caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO,
3125 .dma_burst_length = 16,
3126 .clk_init = macb_clk_init,
3127 .init = macb_init,
3128 .jumbo_max_len = 10240,
3129};
3130
3110static int macb_probe(struct platform_device *pdev) 3131static int macb_probe(struct platform_device *pdev)
3111{ 3132{
3133 const struct macb_config *macb_config = &default_gem_config;
3112 int (*clk_init)(struct platform_device *, struct clk **, 3134 int (*clk_init)(struct platform_device *, struct clk **,
3113 struct clk **, struct clk **, struct clk **) 3135 struct clk **, struct clk **, struct clk **)
3114 = macb_clk_init; 3136 = macb_config->clk_init;
3115 int (*init)(struct platform_device *) = macb_init; 3137 int (*init)(struct platform_device *) = macb_config->init;
3116 struct device_node *np = pdev->dev.of_node; 3138 struct device_node *np = pdev->dev.of_node;
3117 struct device_node *phy_node; 3139 struct device_node *phy_node;
3118 const struct macb_config *macb_config = NULL;
3119 struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL; 3140 struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
3120 unsigned int queue_mask, num_queues; 3141 unsigned int queue_mask, num_queues;
3121 struct macb_platform_data *pdata; 3142 struct macb_platform_data *pdata;
diff --git a/drivers/net/ethernet/cadence/macb_pci.c b/drivers/net/ethernet/cadence/macb_pci.c
new file mode 100644
index 000000000000..92be2cd8f817
--- /dev/null
+++ b/drivers/net/ethernet/cadence/macb_pci.c
@@ -0,0 +1,153 @@
1/**
2 * macb_pci.c - Cadence GEM PCI wrapper.
3 *
4 * Copyright (C) 2016 Cadence Design Systems - http://www.cadence.com
5 *
6 * Authors: Rafal Ozieblo <rafalo@cadence.com>
7 * Bartosz Folta <bfolta@cadence.com>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <linux/clk.h>
23#include <linux/clk-provider.h>
24#include <linux/etherdevice.h>
25#include <linux/module.h>
26#include <linux/pci.h>
27#include <linux/platform_data/macb.h>
28#include <linux/platform_device.h>
29#include "macb.h"
30
31#define PCI_DRIVER_NAME "macb_pci"
32#define PLAT_DRIVER_NAME "macb"
33
34#define CDNS_VENDOR_ID 0x17cd
35#define CDNS_DEVICE_ID 0xe007
36
37#define GEM_PCLK_RATE 50000000
38#define GEM_HCLK_RATE 50000000
39
40static int macb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
41{
42 int err;
43 struct platform_device *plat_dev;
44 struct platform_device_info plat_info;
45 struct macb_platform_data plat_data;
46 struct resource res[2];
47
48 /* sanity check */
49 if (!id)
50 return -EINVAL;
51
52 /* enable pci device */
53 err = pci_enable_device(pdev);
54 if (err < 0) {
55 dev_err(&pdev->dev, "Enabling PCI device has failed: 0x%04X",
56 err);
57 return -EACCES;
58 }
59
60 pci_set_master(pdev);
61
62 /* set up resources */
63 memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));
64 res[0].start = pdev->resource[0].start;
65 res[0].end = pdev->resource[0].end;
66 res[0].name = PCI_DRIVER_NAME;
67 res[0].flags = IORESOURCE_MEM;
68 res[1].start = pdev->irq;
69 res[1].name = PCI_DRIVER_NAME;
70 res[1].flags = IORESOURCE_IRQ;
71
72 dev_info(&pdev->dev, "EMAC physical base addr = 0x%p\n",
73 (void *)(uintptr_t)pci_resource_start(pdev, 0));
74
75 /* set up macb platform data */
76 memset(&plat_data, 0, sizeof(plat_data));
77
78 /* initialize clocks */
79 plat_data.pclk = clk_register_fixed_rate(&pdev->dev, "pclk", NULL, 0,
80 GEM_PCLK_RATE);
81 if (IS_ERR(plat_data.pclk)) {
82 err = PTR_ERR(plat_data.pclk);
83 goto err_pclk_register;
84 }
85
86 plat_data.hclk = clk_register_fixed_rate(&pdev->dev, "hclk", NULL, 0,
87 GEM_HCLK_RATE);
88 if (IS_ERR(plat_data.hclk)) {
89 err = PTR_ERR(plat_data.hclk);
90 goto err_hclk_register;
91 }
92
93 /* set up platform device info */
94 memset(&plat_info, 0, sizeof(plat_info));
95 plat_info.parent = &pdev->dev;
96 plat_info.fwnode = pdev->dev.fwnode;
97 plat_info.name = PLAT_DRIVER_NAME;
98 plat_info.id = pdev->devfn;
99 plat_info.res = res;
100 plat_info.num_res = ARRAY_SIZE(res);
101 plat_info.data = &plat_data;
102 plat_info.size_data = sizeof(plat_data);
103 plat_info.dma_mask = DMA_BIT_MASK(32);
104
105 /* register platform device */
106 plat_dev = platform_device_register_full(&plat_info);
107 if (IS_ERR(plat_dev)) {
108 err = PTR_ERR(plat_dev);
109 goto err_plat_dev_register;
110 }
111
112 pci_set_drvdata(pdev, plat_dev);
113
114 return 0;
115
116err_plat_dev_register:
117 clk_unregister(plat_data.hclk);
118
119err_hclk_register:
120 clk_unregister(plat_data.pclk);
121
122err_pclk_register:
123 pci_disable_device(pdev);
124 return err;
125}
126
127static void macb_remove(struct pci_dev *pdev)
128{
129 struct platform_device *plat_dev = pci_get_drvdata(pdev);
130 struct macb_platform_data *plat_data = dev_get_platdata(&plat_dev->dev);
131
132 platform_device_unregister(plat_dev);
133 pci_disable_device(pdev);
134 clk_unregister(plat_data->pclk);
135 clk_unregister(plat_data->hclk);
136}
137
138static struct pci_device_id dev_id_table[] = {
139 { PCI_DEVICE(CDNS_VENDOR_ID, CDNS_DEVICE_ID), },
140 { 0, }
141};
142
143static struct pci_driver macb_pci_driver = {
144 .name = PCI_DRIVER_NAME,
145 .id_table = dev_id_table,
146 .probe = macb_probe,
147 .remove = macb_remove,
148};
149
150module_pci_driver(macb_pci_driver);
151MODULE_DEVICE_TABLE(pci, dev_id_table);
152MODULE_LICENSE("GPL");
153MODULE_DESCRIPTION("Cadence NIC PCI wrapper");
diff --git a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
index 81d1d0bc7553..3a05f9098e75 100644
--- a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
+++ b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
@@ -568,28 +568,33 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
568 reg_block_dump(ap, buf, A_MC5_CONFIG, A_MC5_MASK_WRITE_CMD); 568 reg_block_dump(ap, buf, A_MC5_CONFIG, A_MC5_MASK_WRITE_CMD);
569} 569}
570 570
571static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 571static int get_link_ksettings(struct net_device *dev,
572 struct ethtool_link_ksettings *cmd)
572{ 573{
573 struct adapter *adapter = dev->ml_priv; 574 struct adapter *adapter = dev->ml_priv;
574 struct port_info *p = &adapter->port[dev->if_port]; 575 struct port_info *p = &adapter->port[dev->if_port];
576 u32 supported, advertising;
575 577
576 cmd->supported = p->link_config.supported; 578 supported = p->link_config.supported;
577 cmd->advertising = p->link_config.advertising; 579 advertising = p->link_config.advertising;
578 580
579 if (netif_carrier_ok(dev)) { 581 if (netif_carrier_ok(dev)) {
580 ethtool_cmd_speed_set(cmd, p->link_config.speed); 582 cmd->base.speed = p->link_config.speed;
581 cmd->duplex = p->link_config.duplex; 583 cmd->base.duplex = p->link_config.duplex;
582 } else { 584 } else {
583 ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN); 585 cmd->base.speed = SPEED_UNKNOWN;
584 cmd->duplex = DUPLEX_UNKNOWN; 586 cmd->base.duplex = DUPLEX_UNKNOWN;
585 } 587 }
586 588
587 cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE; 589 cmd->base.port = (supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE;
588 cmd->phy_address = p->phy->mdio.prtad; 590 cmd->base.phy_address = p->phy->mdio.prtad;
589 cmd->transceiver = XCVR_EXTERNAL; 591 cmd->base.autoneg = p->link_config.autoneg;
590 cmd->autoneg = p->link_config.autoneg; 592
591 cmd->maxtxpkt = 0; 593 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
592 cmd->maxrxpkt = 0; 594 supported);
595 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
596 advertising);
597
593 return 0; 598 return 0;
594} 599}
595 600
@@ -628,36 +633,41 @@ static int speed_duplex_to_caps(int speed, int duplex)
628 ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full | \ 633 ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full | \
629 ADVERTISED_10000baseT_Full) 634 ADVERTISED_10000baseT_Full)
630 635
631static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 636static int set_link_ksettings(struct net_device *dev,
637 const struct ethtool_link_ksettings *cmd)
632{ 638{
633 struct adapter *adapter = dev->ml_priv; 639 struct adapter *adapter = dev->ml_priv;
634 struct port_info *p = &adapter->port[dev->if_port]; 640 struct port_info *p = &adapter->port[dev->if_port];
635 struct link_config *lc = &p->link_config; 641 struct link_config *lc = &p->link_config;
642 u32 advertising;
643
644 ethtool_convert_link_mode_to_legacy_u32(&advertising,
645 cmd->link_modes.advertising);
636 646
637 if (!(lc->supported & SUPPORTED_Autoneg)) 647 if (!(lc->supported & SUPPORTED_Autoneg))
638 return -EOPNOTSUPP; /* can't change speed/duplex */ 648 return -EOPNOTSUPP; /* can't change speed/duplex */
639 649
640 if (cmd->autoneg == AUTONEG_DISABLE) { 650 if (cmd->base.autoneg == AUTONEG_DISABLE) {
641 u32 speed = ethtool_cmd_speed(cmd); 651 u32 speed = cmd->base.speed;
642 int cap = speed_duplex_to_caps(speed, cmd->duplex); 652 int cap = speed_duplex_to_caps(speed, cmd->base.duplex);
643 653
644 if (!(lc->supported & cap) || (speed == SPEED_1000)) 654 if (!(lc->supported & cap) || (speed == SPEED_1000))
645 return -EINVAL; 655 return -EINVAL;
646 lc->requested_speed = speed; 656 lc->requested_speed = speed;
647 lc->requested_duplex = cmd->duplex; 657 lc->requested_duplex = cmd->base.duplex;
648 lc->advertising = 0; 658 lc->advertising = 0;
649 } else { 659 } else {
650 cmd->advertising &= ADVERTISED_MASK; 660 advertising &= ADVERTISED_MASK;
651 if (cmd->advertising & (cmd->advertising - 1)) 661 if (advertising & (advertising - 1))
652 cmd->advertising = lc->supported; 662 advertising = lc->supported;
653 cmd->advertising &= lc->supported; 663 advertising &= lc->supported;
654 if (!cmd->advertising) 664 if (!advertising)
655 return -EINVAL; 665 return -EINVAL;
656 lc->requested_speed = SPEED_INVALID; 666 lc->requested_speed = SPEED_INVALID;
657 lc->requested_duplex = DUPLEX_INVALID; 667 lc->requested_duplex = DUPLEX_INVALID;
658 lc->advertising = cmd->advertising | ADVERTISED_Autoneg; 668 lc->advertising = advertising | ADVERTISED_Autoneg;
659 } 669 }
660 lc->autoneg = cmd->autoneg; 670 lc->autoneg = cmd->base.autoneg;
661 if (netif_running(dev)) 671 if (netif_running(dev))
662 t1_link_start(p->phy, p->mac, lc); 672 t1_link_start(p->phy, p->mac, lc);
663 return 0; 673 return 0;
@@ -788,8 +798,6 @@ static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e,
788} 798}
789 799
790static const struct ethtool_ops t1_ethtool_ops = { 800static const struct ethtool_ops t1_ethtool_ops = {
791 .get_settings = get_settings,
792 .set_settings = set_settings,
793 .get_drvinfo = get_drvinfo, 801 .get_drvinfo = get_drvinfo,
794 .get_msglevel = get_msglevel, 802 .get_msglevel = get_msglevel,
795 .set_msglevel = set_msglevel, 803 .set_msglevel = set_msglevel,
@@ -807,6 +815,8 @@ static const struct ethtool_ops t1_ethtool_ops = {
807 .get_ethtool_stats = get_stats, 815 .get_ethtool_stats = get_stats,
808 .get_regs_len = get_regs_len, 816 .get_regs_len = get_regs_len,
809 .get_regs = get_regs, 817 .get_regs = get_regs,
818 .get_link_ksettings = get_link_ksettings,
819 .set_link_ksettings = set_link_ksettings,
810}; 820};
811 821
812static int t1_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 822static int t1_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index 092b3c16440b..7b2224ae72f2 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -1801,27 +1801,31 @@ static int set_phys_id(struct net_device *dev,
1801 return 0; 1801 return 0;
1802} 1802}
1803 1803
1804static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 1804static int get_link_ksettings(struct net_device *dev,
1805 struct ethtool_link_ksettings *cmd)
1805{ 1806{
1806 struct port_info *p = netdev_priv(dev); 1807 struct port_info *p = netdev_priv(dev);
1808 u32 supported;
1807 1809
1808 cmd->supported = p->link_config.supported; 1810 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
1809 cmd->advertising = p->link_config.advertising; 1811 p->link_config.supported);
1812 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
1813 p->link_config.advertising);
1810 1814
1811 if (netif_carrier_ok(dev)) { 1815 if (netif_carrier_ok(dev)) {
1812 ethtool_cmd_speed_set(cmd, p->link_config.speed); 1816 cmd->base.speed = p->link_config.speed;
1813 cmd->duplex = p->link_config.duplex; 1817 cmd->base.duplex = p->link_config.duplex;
1814 } else { 1818 } else {
1815 ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN); 1819 cmd->base.speed = SPEED_UNKNOWN;
1816 cmd->duplex = DUPLEX_UNKNOWN; 1820 cmd->base.duplex = DUPLEX_UNKNOWN;
1817 } 1821 }
1818 1822
1819 cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE; 1823 ethtool_convert_link_mode_to_legacy_u32(&supported,
1820 cmd->phy_address = p->phy.mdio.prtad; 1824 cmd->link_modes.supported);
1821 cmd->transceiver = XCVR_EXTERNAL; 1825
1822 cmd->autoneg = p->link_config.autoneg; 1826 cmd->base.port = (supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE;
1823 cmd->maxtxpkt = 0; 1827 cmd->base.phy_address = p->phy.mdio.prtad;
1824 cmd->maxrxpkt = 0; 1828 cmd->base.autoneg = p->link_config.autoneg;
1825 return 0; 1829 return 0;
1826} 1830}
1827 1831
@@ -1860,44 +1864,49 @@ static int speed_duplex_to_caps(int speed, int duplex)
1860 ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full | \ 1864 ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full | \
1861 ADVERTISED_10000baseT_Full) 1865 ADVERTISED_10000baseT_Full)
1862 1866
1863static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 1867static int set_link_ksettings(struct net_device *dev,
1868 const struct ethtool_link_ksettings *cmd)
1864{ 1869{
1865 struct port_info *p = netdev_priv(dev); 1870 struct port_info *p = netdev_priv(dev);
1866 struct link_config *lc = &p->link_config; 1871 struct link_config *lc = &p->link_config;
1872 u32 advertising;
1873
1874 ethtool_convert_link_mode_to_legacy_u32(&advertising,
1875 cmd->link_modes.advertising);
1867 1876
1868 if (!(lc->supported & SUPPORTED_Autoneg)) { 1877 if (!(lc->supported & SUPPORTED_Autoneg)) {
1869 /* 1878 /*
1870 * PHY offers a single speed/duplex. See if that's what's 1879 * PHY offers a single speed/duplex. See if that's what's
1871 * being requested. 1880 * being requested.
1872 */ 1881 */
1873 if (cmd->autoneg == AUTONEG_DISABLE) { 1882 if (cmd->base.autoneg == AUTONEG_DISABLE) {
1874 u32 speed = ethtool_cmd_speed(cmd); 1883 u32 speed = cmd->base.speed;
1875 int cap = speed_duplex_to_caps(speed, cmd->duplex); 1884 int cap = speed_duplex_to_caps(speed, cmd->base.duplex);
1876 if (lc->supported & cap) 1885 if (lc->supported & cap)
1877 return 0; 1886 return 0;
1878 } 1887 }
1879 return -EINVAL; 1888 return -EINVAL;
1880 } 1889 }
1881 1890
1882 if (cmd->autoneg == AUTONEG_DISABLE) { 1891 if (cmd->base.autoneg == AUTONEG_DISABLE) {
1883 u32 speed = ethtool_cmd_speed(cmd); 1892 u32 speed = cmd->base.speed;
1884 int cap = speed_duplex_to_caps(speed, cmd->duplex); 1893 int cap = speed_duplex_to_caps(speed, cmd->base.duplex);
1885 1894
1886 if (!(lc->supported & cap) || (speed == SPEED_1000)) 1895 if (!(lc->supported & cap) || (speed == SPEED_1000))
1887 return -EINVAL; 1896 return -EINVAL;
1888 lc->requested_speed = speed; 1897 lc->requested_speed = speed;
1889 lc->requested_duplex = cmd->duplex; 1898 lc->requested_duplex = cmd->base.duplex;
1890 lc->advertising = 0; 1899 lc->advertising = 0;
1891 } else { 1900 } else {
1892 cmd->advertising &= ADVERTISED_MASK; 1901 advertising &= ADVERTISED_MASK;
1893 cmd->advertising &= lc->supported; 1902 advertising &= lc->supported;
1894 if (!cmd->advertising) 1903 if (!advertising)
1895 return -EINVAL; 1904 return -EINVAL;
1896 lc->requested_speed = SPEED_INVALID; 1905 lc->requested_speed = SPEED_INVALID;
1897 lc->requested_duplex = DUPLEX_INVALID; 1906 lc->requested_duplex = DUPLEX_INVALID;
1898 lc->advertising = cmd->advertising | ADVERTISED_Autoneg; 1907 lc->advertising = advertising | ADVERTISED_Autoneg;
1899 } 1908 }
1900 lc->autoneg = cmd->autoneg; 1909 lc->autoneg = cmd->base.autoneg;
1901 if (netif_running(dev)) 1910 if (netif_running(dev))
1902 t3_link_start(&p->phy, &p->mac, lc); 1911 t3_link_start(&p->phy, &p->mac, lc);
1903 return 0; 1912 return 0;
@@ -2097,8 +2106,6 @@ static void get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2097} 2106}
2098 2107
2099static const struct ethtool_ops cxgb_ethtool_ops = { 2108static const struct ethtool_ops cxgb_ethtool_ops = {
2100 .get_settings = get_settings,
2101 .set_settings = set_settings,
2102 .get_drvinfo = get_drvinfo, 2109 .get_drvinfo = get_drvinfo,
2103 .get_msglevel = get_msglevel, 2110 .get_msglevel = get_msglevel,
2104 .set_msglevel = set_msglevel, 2111 .set_msglevel = set_msglevel,
@@ -2120,6 +2127,8 @@ static const struct ethtool_ops cxgb_ethtool_ops = {
2120 .get_regs_len = get_regs_len, 2127 .get_regs_len = get_regs_len,
2121 .get_regs = get_regs, 2128 .get_regs = get_regs,
2122 .get_wol = get_wol, 2129 .get_wol = get_wol,
2130 .get_link_ksettings = get_link_ksettings,
2131 .set_link_ksettings = set_link_ksettings,
2123}; 2132};
2124 2133
2125static int in_range(int val, int lo, int hi) 2134static int in_range(int val, int lo, int hi)
diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c
index a1de0d12927d..396c88678eab 100644
--- a/drivers/net/ethernet/cirrus/ep93xx_eth.c
+++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c
@@ -715,16 +715,18 @@ static void ep93xx_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i
715 strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); 715 strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
716} 716}
717 717
718static int ep93xx_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 718static int ep93xx_get_link_ksettings(struct net_device *dev,
719 struct ethtool_link_ksettings *cmd)
719{ 720{
720 struct ep93xx_priv *ep = netdev_priv(dev); 721 struct ep93xx_priv *ep = netdev_priv(dev);
721 return mii_ethtool_gset(&ep->mii, cmd); 722 return mii_ethtool_get_link_ksettings(&ep->mii, cmd);
722} 723}
723 724
724static int ep93xx_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 725static int ep93xx_set_link_ksettings(struct net_device *dev,
726 const struct ethtool_link_ksettings *cmd)
725{ 727{
726 struct ep93xx_priv *ep = netdev_priv(dev); 728 struct ep93xx_priv *ep = netdev_priv(dev);
727 return mii_ethtool_sset(&ep->mii, cmd); 729 return mii_ethtool_set_link_ksettings(&ep->mii, cmd);
728} 730}
729 731
730static int ep93xx_nway_reset(struct net_device *dev) 732static int ep93xx_nway_reset(struct net_device *dev)
@@ -741,10 +743,10 @@ static u32 ep93xx_get_link(struct net_device *dev)
741 743
742static const struct ethtool_ops ep93xx_ethtool_ops = { 744static const struct ethtool_ops ep93xx_ethtool_ops = {
743 .get_drvinfo = ep93xx_get_drvinfo, 745 .get_drvinfo = ep93xx_get_drvinfo,
744 .get_settings = ep93xx_get_settings,
745 .set_settings = ep93xx_set_settings,
746 .nway_reset = ep93xx_nway_reset, 746 .nway_reset = ep93xx_nway_reset,
747 .get_link = ep93xx_get_link, 747 .get_link = ep93xx_get_link,
748 .get_link_ksettings = ep93xx_get_link_ksettings,
749 .set_link_ksettings = ep93xx_set_link_ksettings,
748}; 750};
749 751
750static const struct net_device_ops ep93xx_netdev_ops = { 752static const struct net_device_ops ep93xx_netdev_ops = {
diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index f1a81c52afe3..008dc8161775 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -570,19 +570,21 @@ static void dm9000_set_msglevel(struct net_device *dev, u32 value)
570 dm->msg_enable = value; 570 dm->msg_enable = value;
571} 571}
572 572
573static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 573static int dm9000_get_link_ksettings(struct net_device *dev,
574 struct ethtool_link_ksettings *cmd)
574{ 575{
575 struct board_info *dm = to_dm9000_board(dev); 576 struct board_info *dm = to_dm9000_board(dev);
576 577
577 mii_ethtool_gset(&dm->mii, cmd); 578 mii_ethtool_get_link_ksettings(&dm->mii, cmd);
578 return 0; 579 return 0;
579} 580}
580 581
581static int dm9000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 582static int dm9000_set_link_ksettings(struct net_device *dev,
583 const struct ethtool_link_ksettings *cmd)
582{ 584{
583 struct board_info *dm = to_dm9000_board(dev); 585 struct board_info *dm = to_dm9000_board(dev);
584 586
585 return mii_ethtool_sset(&dm->mii, cmd); 587 return mii_ethtool_set_link_ksettings(&dm->mii, cmd);
586} 588}
587 589
588static int dm9000_nway_reset(struct net_device *dev) 590static int dm9000_nway_reset(struct net_device *dev)
@@ -741,8 +743,6 @@ static int dm9000_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
741 743
742static const struct ethtool_ops dm9000_ethtool_ops = { 744static const struct ethtool_ops dm9000_ethtool_ops = {
743 .get_drvinfo = dm9000_get_drvinfo, 745 .get_drvinfo = dm9000_get_drvinfo,
744 .get_settings = dm9000_get_settings,
745 .set_settings = dm9000_set_settings,
746 .get_msglevel = dm9000_get_msglevel, 746 .get_msglevel = dm9000_get_msglevel,
747 .set_msglevel = dm9000_set_msglevel, 747 .set_msglevel = dm9000_set_msglevel,
748 .nway_reset = dm9000_nway_reset, 748 .nway_reset = dm9000_nway_reset,
@@ -752,6 +752,8 @@ static const struct ethtool_ops dm9000_ethtool_ops = {
752 .get_eeprom_len = dm9000_get_eeprom_len, 752 .get_eeprom_len = dm9000_get_eeprom_len,
753 .get_eeprom = dm9000_get_eeprom, 753 .get_eeprom = dm9000_get_eeprom,
754 .set_eeprom = dm9000_set_eeprom, 754 .set_eeprom = dm9000_set_eeprom,
755 .get_link_ksettings = dm9000_get_link_ksettings,
756 .set_link_ksettings = dm9000_set_link_ksettings,
755}; 757};
756 758
757static void dm9000_show_carrier(struct board_info *db, 759static void dm9000_show_carrier(struct board_info *db,
diff --git a/drivers/net/ethernet/freescale/dpaa/Kconfig b/drivers/net/ethernet/freescale/dpaa/Kconfig
index f3a3454805f9..a654736237a9 100644
--- a/drivers/net/ethernet/freescale/dpaa/Kconfig
+++ b/drivers/net/ethernet/freescale/dpaa/Kconfig
@@ -1,6 +1,6 @@
1menuconfig FSL_DPAA_ETH 1menuconfig FSL_DPAA_ETH
2 tristate "DPAA Ethernet" 2 tristate "DPAA Ethernet"
3 depends on FSL_SOC && FSL_DPAA && FSL_FMAN 3 depends on FSL_DPAA && FSL_FMAN
4 select PHYLIB 4 select PHYLIB
5 select FSL_FMAN_MAC 5 select FSL_FMAN_MAC
6 ---help--- 6 ---help---
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 3c48a84dec86..624ba9058dc4 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -733,7 +733,7 @@ static int dpaa_eth_cgr_init(struct dpaa_priv *priv)
733 priv->cgr_data.cgr.cb = dpaa_eth_cgscn; 733 priv->cgr_data.cgr.cb = dpaa_eth_cgscn;
734 734
735 /* Enable Congestion State Change Notifications and CS taildrop */ 735 /* Enable Congestion State Change Notifications and CS taildrop */
736 initcgr.we_mask = QM_CGR_WE_CSCN_EN | QM_CGR_WE_CS_THRES; 736 initcgr.we_mask = cpu_to_be16(QM_CGR_WE_CSCN_EN | QM_CGR_WE_CS_THRES);
737 initcgr.cgr.cscn_en = QM_CGR_EN; 737 initcgr.cgr.cscn_en = QM_CGR_EN;
738 738
739 /* Set different thresholds based on the MAC speed. 739 /* Set different thresholds based on the MAC speed.
@@ -747,7 +747,7 @@ static int dpaa_eth_cgr_init(struct dpaa_priv *priv)
747 cs_th = DPAA_CS_THRESHOLD_1G; 747 cs_th = DPAA_CS_THRESHOLD_1G;
748 qm_cgr_cs_thres_set64(&initcgr.cgr.cs_thres, cs_th, 1); 748 qm_cgr_cs_thres_set64(&initcgr.cgr.cs_thres, cs_th, 1);
749 749
750 initcgr.we_mask |= QM_CGR_WE_CSTD_EN; 750 initcgr.we_mask |= cpu_to_be16(QM_CGR_WE_CSTD_EN);
751 initcgr.cgr.cstd_en = QM_CGR_EN; 751 initcgr.cgr.cstd_en = QM_CGR_EN;
752 752
753 err = qman_create_cgr(&priv->cgr_data.cgr, QMAN_CGR_FLAG_USE_INIT, 753 err = qman_create_cgr(&priv->cgr_data.cgr, QMAN_CGR_FLAG_USE_INIT,
@@ -896,18 +896,18 @@ static int dpaa_fq_init(struct dpaa_fq *dpaa_fq, bool td_enable)
896 if (dpaa_fq->init) { 896 if (dpaa_fq->init) {
897 memset(&initfq, 0, sizeof(initfq)); 897 memset(&initfq, 0, sizeof(initfq));
898 898
899 initfq.we_mask = QM_INITFQ_WE_FQCTRL; 899 initfq.we_mask = cpu_to_be16(QM_INITFQ_WE_FQCTRL);
900 /* Note: we may get to keep an empty FQ in cache */ 900 /* Note: we may get to keep an empty FQ in cache */
901 initfq.fqd.fq_ctrl = QM_FQCTRL_PREFERINCACHE; 901 initfq.fqd.fq_ctrl = cpu_to_be16(QM_FQCTRL_PREFERINCACHE);
902 902
903 /* Try to reduce the number of portal interrupts for 903 /* Try to reduce the number of portal interrupts for
904 * Tx Confirmation FQs. 904 * Tx Confirmation FQs.
905 */ 905 */
906 if (dpaa_fq->fq_type == FQ_TYPE_TX_CONFIRM) 906 if (dpaa_fq->fq_type == FQ_TYPE_TX_CONFIRM)
907 initfq.fqd.fq_ctrl |= QM_FQCTRL_HOLDACTIVE; 907 initfq.fqd.fq_ctrl |= cpu_to_be16(QM_FQCTRL_HOLDACTIVE);
908 908
909 /* FQ placement */ 909 /* FQ placement */
910 initfq.we_mask |= QM_INITFQ_WE_DESTWQ; 910 initfq.we_mask |= cpu_to_be16(QM_INITFQ_WE_DESTWQ);
911 911
912 qm_fqd_set_destwq(&initfq.fqd, dpaa_fq->channel, dpaa_fq->wq); 912 qm_fqd_set_destwq(&initfq.fqd, dpaa_fq->channel, dpaa_fq->wq);
913 913
@@ -920,8 +920,8 @@ static int dpaa_fq_init(struct dpaa_fq *dpaa_fq, bool td_enable)
920 if (dpaa_fq->fq_type == FQ_TYPE_TX || 920 if (dpaa_fq->fq_type == FQ_TYPE_TX ||
921 dpaa_fq->fq_type == FQ_TYPE_TX_CONFIRM || 921 dpaa_fq->fq_type == FQ_TYPE_TX_CONFIRM ||
922 dpaa_fq->fq_type == FQ_TYPE_TX_CONF_MQ) { 922 dpaa_fq->fq_type == FQ_TYPE_TX_CONF_MQ) {
923 initfq.we_mask |= QM_INITFQ_WE_CGID; 923 initfq.we_mask |= cpu_to_be16(QM_INITFQ_WE_CGID);
924 initfq.fqd.fq_ctrl |= QM_FQCTRL_CGE; 924 initfq.fqd.fq_ctrl |= cpu_to_be16(QM_FQCTRL_CGE);
925 initfq.fqd.cgid = (u8)priv->cgr_data.cgr.cgrid; 925 initfq.fqd.cgid = (u8)priv->cgr_data.cgr.cgrid;
926 /* Set a fixed overhead accounting, in an attempt to 926 /* Set a fixed overhead accounting, in an attempt to
927 * reduce the impact of fixed-size skb shells and the 927 * reduce the impact of fixed-size skb shells and the
@@ -932,7 +932,7 @@ static int dpaa_fq_init(struct dpaa_fq *dpaa_fq, bool td_enable)
932 * insufficient value, but even that is better than 932 * insufficient value, but even that is better than
933 * no overhead accounting at all. 933 * no overhead accounting at all.
934 */ 934 */
935 initfq.we_mask |= QM_INITFQ_WE_OAC; 935 initfq.we_mask |= cpu_to_be16(QM_INITFQ_WE_OAC);
936 qm_fqd_set_oac(&initfq.fqd, QM_OAC_CG); 936 qm_fqd_set_oac(&initfq.fqd, QM_OAC_CG);
937 qm_fqd_set_oal(&initfq.fqd, 937 qm_fqd_set_oal(&initfq.fqd,
938 min(sizeof(struct sk_buff) + 938 min(sizeof(struct sk_buff) +
@@ -941,9 +941,9 @@ static int dpaa_fq_init(struct dpaa_fq *dpaa_fq, bool td_enable)
941 } 941 }
942 942
943 if (td_enable) { 943 if (td_enable) {
944 initfq.we_mask |= QM_INITFQ_WE_TDTHRESH; 944 initfq.we_mask |= cpu_to_be16(QM_INITFQ_WE_TDTHRESH);
945 qm_fqd_set_taildrop(&initfq.fqd, DPAA_FQ_TD, 1); 945 qm_fqd_set_taildrop(&initfq.fqd, DPAA_FQ_TD, 1);
946 initfq.fqd.fq_ctrl = QM_FQCTRL_TDE; 946 initfq.fqd.fq_ctrl = cpu_to_be16(QM_FQCTRL_TDE);
947 } 947 }
948 948
949 if (dpaa_fq->fq_type == FQ_TYPE_TX) { 949 if (dpaa_fq->fq_type == FQ_TYPE_TX) {
@@ -951,7 +951,8 @@ static int dpaa_fq_init(struct dpaa_fq *dpaa_fq, bool td_enable)
951 if (queue_id >= 0) 951 if (queue_id >= 0)
952 confq = priv->conf_fqs[queue_id]; 952 confq = priv->conf_fqs[queue_id];
953 if (confq) { 953 if (confq) {
954 initfq.we_mask |= QM_INITFQ_WE_CONTEXTA; 954 initfq.we_mask |=
955 cpu_to_be16(QM_INITFQ_WE_CONTEXTA);
955 /* ContextA: OVOM=1(use contextA2 bits instead of ICAD) 956 /* ContextA: OVOM=1(use contextA2 bits instead of ICAD)
956 * A2V=1 (contextA A2 field is valid) 957 * A2V=1 (contextA A2 field is valid)
957 * A0V=1 (contextA A0 field is valid) 958 * A0V=1 (contextA A0 field is valid)
@@ -959,8 +960,8 @@ static int dpaa_fq_init(struct dpaa_fq *dpaa_fq, bool td_enable)
959 * ContextA A2: EBD=1 (deallocate buffers inside FMan) 960 * ContextA A2: EBD=1 (deallocate buffers inside FMan)
960 * ContextB B0(ASPID): 0 (absolute Virtual Storage ID) 961 * ContextB B0(ASPID): 0 (absolute Virtual Storage ID)
961 */ 962 */
962 initfq.fqd.context_a.hi = 0x1e000000; 963 qm_fqd_context_a_set64(&initfq.fqd,
963 initfq.fqd.context_a.lo = 0x80000000; 964 0x1e00000080000000ULL);
964 } 965 }
965 } 966 }
966 967
@@ -968,13 +969,13 @@ static int dpaa_fq_init(struct dpaa_fq *dpaa_fq, bool td_enable)
968 if (priv->use_ingress_cgr && 969 if (priv->use_ingress_cgr &&
969 (dpaa_fq->fq_type == FQ_TYPE_RX_DEFAULT || 970 (dpaa_fq->fq_type == FQ_TYPE_RX_DEFAULT ||
970 dpaa_fq->fq_type == FQ_TYPE_RX_ERROR)) { 971 dpaa_fq->fq_type == FQ_TYPE_RX_ERROR)) {
971 initfq.we_mask |= QM_INITFQ_WE_CGID; 972 initfq.we_mask |= cpu_to_be16(QM_INITFQ_WE_CGID);
972 initfq.fqd.fq_ctrl |= QM_FQCTRL_CGE; 973 initfq.fqd.fq_ctrl |= cpu_to_be16(QM_FQCTRL_CGE);
973 initfq.fqd.cgid = (u8)priv->ingress_cgr.cgrid; 974 initfq.fqd.cgid = (u8)priv->ingress_cgr.cgrid;
974 /* Set a fixed overhead accounting, just like for the 975 /* Set a fixed overhead accounting, just like for the
975 * egress CGR. 976 * egress CGR.
976 */ 977 */
977 initfq.we_mask |= QM_INITFQ_WE_OAC; 978 initfq.we_mask |= cpu_to_be16(QM_INITFQ_WE_OAC);
978 qm_fqd_set_oac(&initfq.fqd, QM_OAC_CG); 979 qm_fqd_set_oac(&initfq.fqd, QM_OAC_CG);
979 qm_fqd_set_oal(&initfq.fqd, 980 qm_fqd_set_oal(&initfq.fqd,
980 min(sizeof(struct sk_buff) + 981 min(sizeof(struct sk_buff) +
@@ -984,9 +985,8 @@ static int dpaa_fq_init(struct dpaa_fq *dpaa_fq, bool td_enable)
984 985
985 /* Initialization common to all ingress queues */ 986 /* Initialization common to all ingress queues */
986 if (dpaa_fq->flags & QMAN_FQ_FLAG_NO_ENQUEUE) { 987 if (dpaa_fq->flags & QMAN_FQ_FLAG_NO_ENQUEUE) {
987 initfq.we_mask |= QM_INITFQ_WE_CONTEXTA; 988 initfq.we_mask |= cpu_to_be16(QM_INITFQ_WE_CONTEXTA);
988 initfq.fqd.fq_ctrl |= 989 initfq.fqd.fq_ctrl |= cpu_to_be16(QM_FQCTRL_HOLDACTIVE);
989 QM_FQCTRL_HOLDACTIVE;
990 initfq.fqd.context_a.stashing.exclusive = 990 initfq.fqd.context_a.stashing.exclusive =
991 QM_STASHING_EXCL_DATA | QM_STASHING_EXCL_CTX | 991 QM_STASHING_EXCL_DATA | QM_STASHING_EXCL_CTX |
992 QM_STASHING_EXCL_ANNOTATION; 992 QM_STASHING_EXCL_ANNOTATION;
@@ -1350,7 +1350,7 @@ static int dpaa_enable_tx_csum(struct dpaa_priv *priv,
1350 parse_result->l4_off = (u8)skb_transport_offset(skb); 1350 parse_result->l4_off = (u8)skb_transport_offset(skb);
1351 1351
1352 /* Enable L3 (and L4, if TCP or UDP) HW checksum. */ 1352 /* Enable L3 (and L4, if TCP or UDP) HW checksum. */
1353 fd->cmd |= FM_FD_CMD_RPD | FM_FD_CMD_DTC; 1353 fd->cmd |= cpu_to_be32(FM_FD_CMD_RPD | FM_FD_CMD_DTC);
1354 1354
1355 /* On P1023 and similar platforms fd->cmd interpretation could 1355 /* On P1023 and similar platforms fd->cmd interpretation could
1356 * be disabled by setting CONTEXT_A bit ICMD; currently this bit 1356 * be disabled by setting CONTEXT_A bit ICMD; currently this bit
@@ -1732,7 +1732,7 @@ static int skb_to_contig_fd(struct dpaa_priv *priv,
1732 1732
1733 /* Fill in the rest of the FD fields */ 1733 /* Fill in the rest of the FD fields */
1734 qm_fd_set_contig(fd, priv->tx_headroom, skb->len); 1734 qm_fd_set_contig(fd, priv->tx_headroom, skb->len);
1735 fd->cmd |= FM_FD_CMD_FCO; 1735 fd->cmd |= cpu_to_be32(FM_FD_CMD_FCO);
1736 1736
1737 /* Map the entire buffer size that may be seen by FMan, but no more */ 1737 /* Map the entire buffer size that may be seen by FMan, but no more */
1738 addr = dma_map_single(dev, skbh, 1738 addr = dma_map_single(dev, skbh,
@@ -1840,7 +1840,7 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
1840 } 1840 }
1841 1841
1842 fd->bpid = FSL_DPAA_BPID_INV; 1842 fd->bpid = FSL_DPAA_BPID_INV;
1843 fd->cmd |= FM_FD_CMD_FCO; 1843 fd->cmd |= cpu_to_be32(FM_FD_CMD_FCO);
1844 qm_fd_addr_set64(fd, addr); 1844 qm_fd_addr_set64(fd, addr);
1845 1845
1846 return 0; 1846 return 0;
@@ -1867,7 +1867,7 @@ static inline int dpaa_xmit(struct dpaa_priv *priv,
1867 1867
1868 egress_fq = priv->egress_fqs[queue]; 1868 egress_fq = priv->egress_fqs[queue];
1869 if (fd->bpid == FSL_DPAA_BPID_INV) 1869 if (fd->bpid == FSL_DPAA_BPID_INV)
1870 fd->cmd |= qman_fq_fqid(priv->conf_fqs[queue]); 1870 fd->cmd |= cpu_to_be32(qman_fq_fqid(priv->conf_fqs[queue]));
1871 1871
1872 /* Trace this Tx fd */ 1872 /* Trace this Tx fd */
1873 trace_dpaa_tx_fd(priv->net_dev, egress_fq, fd); 1873 trace_dpaa_tx_fd(priv->net_dev, egress_fq, fd);
@@ -1960,17 +1960,17 @@ static void dpaa_rx_error(struct net_device *net_dev,
1960{ 1960{
1961 if (net_ratelimit()) 1961 if (net_ratelimit())
1962 netif_err(priv, hw, net_dev, "Err FD status = 0x%08x\n", 1962 netif_err(priv, hw, net_dev, "Err FD status = 0x%08x\n",
1963 fd->status & FM_FD_STAT_RX_ERRORS); 1963 be32_to_cpu(fd->status) & FM_FD_STAT_RX_ERRORS);
1964 1964
1965 percpu_priv->stats.rx_errors++; 1965 percpu_priv->stats.rx_errors++;
1966 1966
1967 if (fd->status & FM_FD_ERR_DMA) 1967 if (be32_to_cpu(fd->status) & FM_FD_ERR_DMA)
1968 percpu_priv->rx_errors.dme++; 1968 percpu_priv->rx_errors.dme++;
1969 if (fd->status & FM_FD_ERR_PHYSICAL) 1969 if (be32_to_cpu(fd->status) & FM_FD_ERR_PHYSICAL)
1970 percpu_priv->rx_errors.fpe++; 1970 percpu_priv->rx_errors.fpe++;
1971 if (fd->status & FM_FD_ERR_SIZE) 1971 if (be32_to_cpu(fd->status) & FM_FD_ERR_SIZE)
1972 percpu_priv->rx_errors.fse++; 1972 percpu_priv->rx_errors.fse++;
1973 if (fd->status & FM_FD_ERR_PRS_HDR_ERR) 1973 if (be32_to_cpu(fd->status) & FM_FD_ERR_PRS_HDR_ERR)
1974 percpu_priv->rx_errors.phe++; 1974 percpu_priv->rx_errors.phe++;
1975 1975
1976 dpaa_fd_release(net_dev, fd); 1976 dpaa_fd_release(net_dev, fd);
@@ -1986,7 +1986,7 @@ static void dpaa_tx_error(struct net_device *net_dev,
1986 1986
1987 if (net_ratelimit()) 1987 if (net_ratelimit())
1988 netif_warn(priv, hw, net_dev, "FD status = 0x%08x\n", 1988 netif_warn(priv, hw, net_dev, "FD status = 0x%08x\n",
1989 fd->status & FM_FD_STAT_TX_ERRORS); 1989 be32_to_cpu(fd->status) & FM_FD_STAT_TX_ERRORS);
1990 1990
1991 percpu_priv->stats.tx_errors++; 1991 percpu_priv->stats.tx_errors++;
1992 1992
@@ -2020,10 +2020,11 @@ static void dpaa_tx_conf(struct net_device *net_dev,
2020{ 2020{
2021 struct sk_buff *skb; 2021 struct sk_buff *skb;
2022 2022
2023 if (unlikely(fd->status & FM_FD_STAT_TX_ERRORS) != 0) { 2023 if (unlikely(be32_to_cpu(fd->status) & FM_FD_STAT_TX_ERRORS)) {
2024 if (net_ratelimit()) 2024 if (net_ratelimit())
2025 netif_warn(priv, hw, net_dev, "FD status = 0x%08x\n", 2025 netif_warn(priv, hw, net_dev, "FD status = 0x%08x\n",
2026 fd->status & FM_FD_STAT_TX_ERRORS); 2026 be32_to_cpu(fd->status) &
2027 FM_FD_STAT_TX_ERRORS);
2027 2028
2028 percpu_priv->stats.tx_errors++; 2029 percpu_priv->stats.tx_errors++;
2029 } 2030 }
@@ -2100,6 +2101,8 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal,
2100 struct sk_buff *skb; 2101 struct sk_buff *skb;
2101 int *count_ptr; 2102 int *count_ptr;
2102 2103
2104 fd_status = be32_to_cpu(fd->status);
2105 fd_format = qm_fd_get_format(fd);
2103 net_dev = ((struct dpaa_fq *)fq)->net_dev; 2106 net_dev = ((struct dpaa_fq *)fq)->net_dev;
2104 priv = netdev_priv(net_dev); 2107 priv = netdev_priv(net_dev);
2105 dpaa_bp = dpaa_bpid2pool(dq->fd.bpid); 2108 dpaa_bp = dpaa_bpid2pool(dq->fd.bpid);
@@ -2417,12 +2420,12 @@ static int dpaa_ingress_cgr_init(struct dpaa_priv *priv)
2417 } 2420 }
2418 2421
2419 /* Enable CS TD, but disable Congestion State Change Notifications. */ 2422 /* Enable CS TD, but disable Congestion State Change Notifications. */
2420 initcgr.we_mask = QM_CGR_WE_CS_THRES; 2423 initcgr.we_mask = cpu_to_be16(QM_CGR_WE_CS_THRES);
2421 initcgr.cgr.cscn_en = QM_CGR_EN; 2424 initcgr.cgr.cscn_en = QM_CGR_EN;
2422 cs_th = DPAA_INGRESS_CS_THRESHOLD; 2425 cs_th = DPAA_INGRESS_CS_THRESHOLD;
2423 qm_cgr_cs_thres_set64(&initcgr.cgr.cs_thres, cs_th, 1); 2426 qm_cgr_cs_thres_set64(&initcgr.cgr.cs_thres, cs_th, 1);
2424 2427
2425 initcgr.we_mask |= QM_CGR_WE_CSTD_EN; 2428 initcgr.we_mask |= cpu_to_be16(QM_CGR_WE_CSTD_EN);
2426 initcgr.cgr.cstd_en = QM_CGR_EN; 2429 initcgr.cgr.cstd_en = QM_CGR_EN;
2427 2430
2428 /* This CGR will be associated with the SWP affined to the current CPU. 2431 /* This CGR will be associated with the SWP affined to the current CPU.
diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c
index 854befde0a08..97b184774784 100644
--- a/drivers/net/ethernet/hisilicon/hip04_eth.c
+++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
@@ -828,6 +828,7 @@ static int hip04_mac_probe(struct platform_device *pdev)
828 priv = netdev_priv(ndev); 828 priv = netdev_priv(ndev);
829 priv->ndev = ndev; 829 priv->ndev = ndev;
830 platform_set_drvdata(pdev, ndev); 830 platform_set_drvdata(pdev, ndev);
831 SET_NETDEV_DEV(ndev, &pdev->dev);
831 832
832 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 833 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
833 priv->base = devm_ioremap_resource(d, res); 834 priv->base = devm_ioremap_resource(d, res);
@@ -903,7 +904,6 @@ static int hip04_mac_probe(struct platform_device *pdev)
903 ndev->priv_flags |= IFF_UNICAST_FLT; 904 ndev->priv_flags |= IFF_UNICAST_FLT;
904 ndev->irq = irq; 905 ndev->irq = irq;
905 netif_napi_add(ndev, &priv->napi, hip04_rx_poll, NAPI_POLL_WEIGHT); 906 netif_napi_add(ndev, &priv->napi, hip04_rx_poll, NAPI_POLL_WEIGHT);
906 SET_NETDEV_DEV(ndev, &pdev->dev);
907 907
908 hip04_reset_ppe(priv); 908 hip04_reset_ppe(priv);
909 if (priv->phy_mode == PHY_INTERFACE_MODE_MII) 909 if (priv->phy_mode == PHY_INTERFACE_MODE_MII)
diff --git a/drivers/net/ethernet/hisilicon/hisi_femac.c b/drivers/net/ethernet/hisilicon/hisi_femac.c
index 49863068c59e..979852d56f31 100644
--- a/drivers/net/ethernet/hisilicon/hisi_femac.c
+++ b/drivers/net/ethernet/hisilicon/hisi_femac.c
@@ -805,6 +805,7 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)
805 return -ENOMEM; 805 return -ENOMEM;
806 806
807 platform_set_drvdata(pdev, ndev); 807 platform_set_drvdata(pdev, ndev);
808 SET_NETDEV_DEV(ndev, &pdev->dev);
808 809
809 priv = netdev_priv(ndev); 810 priv = netdev_priv(ndev);
810 priv->dev = dev; 811 priv->dev = dev;
@@ -882,7 +883,6 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)
882 ndev->netdev_ops = &hisi_femac_netdev_ops; 883 ndev->netdev_ops = &hisi_femac_netdev_ops;
883 ndev->ethtool_ops = &hisi_femac_ethtools_ops; 884 ndev->ethtool_ops = &hisi_femac_ethtools_ops;
884 netif_napi_add(ndev, &priv->napi, hisi_femac_poll, FEMAC_POLL_WEIGHT); 885 netif_napi_add(ndev, &priv->napi, hisi_femac_poll, FEMAC_POLL_WEIGHT);
885 SET_NETDEV_DEV(ndev, &pdev->dev);
886 886
887 hisi_femac_port_init(priv); 887 hisi_femac_port_init(priv);
888 888
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index fbece63395a8..a831f947ca8c 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1181,7 +1181,9 @@ map_failed:
1181 1181
1182static void ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt) 1182static void ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)
1183{ 1183{
1184 struct tcphdr *tcph;
1184 int offset = 0; 1185 int offset = 0;
1186 int hdr_len;
1185 1187
1186 /* only TCP packets will be aggregated */ 1188 /* only TCP packets will be aggregated */
1187 if (skb->protocol == htons(ETH_P_IP)) { 1189 if (skb->protocol == htons(ETH_P_IP)) {
@@ -1208,14 +1210,20 @@ static void ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)
1208 /* if mss is not set through Large Packet bit/mss in rx buffer, 1210 /* if mss is not set through Large Packet bit/mss in rx buffer,
1209 * expect that the mss will be written to the tcp header checksum. 1211 * expect that the mss will be written to the tcp header checksum.
1210 */ 1212 */
1213 tcph = (struct tcphdr *)(skb->data + offset);
1211 if (lrg_pkt) { 1214 if (lrg_pkt) {
1212 skb_shinfo(skb)->gso_size = mss; 1215 skb_shinfo(skb)->gso_size = mss;
1213 } else if (offset) { 1216 } else if (offset) {
1214 struct tcphdr *tcph = (struct tcphdr *)(skb->data + offset);
1215
1216 skb_shinfo(skb)->gso_size = ntohs(tcph->check); 1217 skb_shinfo(skb)->gso_size = ntohs(tcph->check);
1217 tcph->check = 0; 1218 tcph->check = 0;
1218 } 1219 }
1220
1221 if (skb_shinfo(skb)->gso_size) {
1222 hdr_len = offset + tcph->doff * 4;
1223 skb_shinfo(skb)->gso_segs =
1224 DIV_ROUND_UP(skb->len - hdr_len,
1225 skb_shinfo(skb)->gso_size);
1226 }
1219} 1227}
1220 1228
1221static int ibmveth_poll(struct napi_struct *napi, int budget) 1229static int ibmveth_poll(struct napi_struct *napi, int budget)
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 5f62c3d70df9..1fa7c03edec2 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2713,7 +2713,7 @@ static const struct of_device_id mv643xx_eth_shared_ids[] = {
2713MODULE_DEVICE_TABLE(of, mv643xx_eth_shared_ids); 2713MODULE_DEVICE_TABLE(of, mv643xx_eth_shared_ids);
2714#endif 2714#endif
2715 2715
2716#if defined(CONFIG_OF) && !defined(CONFIG_MV64X60) 2716#if defined(CONFIG_OF_IRQ) && !defined(CONFIG_MV64X60)
2717#define mv643xx_eth_property(_np, _name, _v) \ 2717#define mv643xx_eth_property(_np, _name, _v) \
2718 do { \ 2718 do { \
2719 u32 tmp; \ 2719 u32 tmp; \
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index fece974b4edd..d768c7b6c6d6 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -2404,7 +2404,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
2404 local_port); 2404 local_port);
2405 return err; 2405 return err;
2406 } 2406 }
2407 err = __mlxsw_sp_port_create(mlxsw_sp, local_port, false, 2407 err = __mlxsw_sp_port_create(mlxsw_sp, local_port, split,
2408 module, width, lane); 2408 module, width, lane);
2409 if (err) 2409 if (err)
2410 goto err_port_create; 2410 goto err_port_create;
diff --git a/drivers/net/ethernet/microchip/encx24j600-regmap.c b/drivers/net/ethernet/microchip/encx24j600-regmap.c
index f3bb9055a292..44bb04d4d21b 100644
--- a/drivers/net/ethernet/microchip/encx24j600-regmap.c
+++ b/drivers/net/ethernet/microchip/encx24j600-regmap.c
@@ -26,11 +26,11 @@ static inline bool is_bits_set(int value, int mask)
26} 26}
27 27
28static int encx24j600_switch_bank(struct encx24j600_context *ctx, 28static int encx24j600_switch_bank(struct encx24j600_context *ctx,
29 int bank) 29 int bank)
30{ 30{
31 int ret = 0; 31 int ret = 0;
32
33 int bank_opcode = BANK_SELECT(bank); 32 int bank_opcode = BANK_SELECT(bank);
33
34 ret = spi_write(ctx->spi, &bank_opcode, 1); 34 ret = spi_write(ctx->spi, &bank_opcode, 1);
35 if (ret == 0) 35 if (ret == 0)
36 ctx->bank = bank; 36 ctx->bank = bank;
@@ -39,7 +39,7 @@ static int encx24j600_switch_bank(struct encx24j600_context *ctx,
39} 39}
40 40
41static int encx24j600_cmdn(struct encx24j600_context *ctx, u8 opcode, 41static int encx24j600_cmdn(struct encx24j600_context *ctx, u8 opcode,
42 const void *buf, size_t len) 42 const void *buf, size_t len)
43{ 43{
44 struct spi_message m; 44 struct spi_message m;
45 struct spi_transfer t[2] = { { .tx_buf = &opcode, .len = 1, }, 45 struct spi_transfer t[2] = { { .tx_buf = &opcode, .len = 1, },
@@ -54,12 +54,14 @@ static int encx24j600_cmdn(struct encx24j600_context *ctx, u8 opcode,
54static void regmap_lock_mutex(void *context) 54static void regmap_lock_mutex(void *context)
55{ 55{
56 struct encx24j600_context *ctx = context; 56 struct encx24j600_context *ctx = context;
57
57 mutex_lock(&ctx->mutex); 58 mutex_lock(&ctx->mutex);
58} 59}
59 60
60static void regmap_unlock_mutex(void *context) 61static void regmap_unlock_mutex(void *context)
61{ 62{
62 struct encx24j600_context *ctx = context; 63 struct encx24j600_context *ctx = context;
64
63 mutex_unlock(&ctx->mutex); 65 mutex_unlock(&ctx->mutex);
64} 66}
65 67
@@ -128,6 +130,7 @@ static int regmap_encx24j600_sfr_update(struct encx24j600_context *ctx,
128 130
129 if (reg < 0x80) { 131 if (reg < 0x80) {
130 int ret = 0; 132 int ret = 0;
133
131 cmd = banked_code | banked_reg; 134 cmd = banked_code | banked_reg;
132 if ((banked_reg < 0x16) && (ctx->bank != bank)) 135 if ((banked_reg < 0x16) && (ctx->bank != bank))
133 ret = encx24j600_switch_bank(ctx, bank); 136 ret = encx24j600_switch_bank(ctx, bank);
@@ -174,6 +177,7 @@ static int regmap_encx24j600_sfr_write(void *context, u8 reg, u8 *val,
174 size_t len) 177 size_t len)
175{ 178{
176 struct encx24j600_context *ctx = context; 179 struct encx24j600_context *ctx = context;
180
177 return regmap_encx24j600_sfr_update(ctx, reg, val, len, WCRU, WCRCODE); 181 return regmap_encx24j600_sfr_update(ctx, reg, val, len, WCRU, WCRCODE);
178} 182}
179 183
@@ -228,9 +232,9 @@ int regmap_encx24j600_spi_write(void *context, u8 reg, const u8 *data,
228 232
229 if (reg < 0xc0) 233 if (reg < 0xc0)
230 return encx24j600_cmdn(ctx, reg, data, count); 234 return encx24j600_cmdn(ctx, reg, data, count);
231 else 235
232 /* SPI 1-byte command. Ignore data */ 236 /* SPI 1-byte command. Ignore data */
233 return spi_write(ctx->spi, &reg, 1); 237 return spi_write(ctx->spi, &reg, 1);
234} 238}
235EXPORT_SYMBOL_GPL(regmap_encx24j600_spi_write); 239EXPORT_SYMBOL_GPL(regmap_encx24j600_spi_write);
236 240
@@ -495,6 +499,7 @@ static struct regmap_config phycfg = {
495 .writeable_reg = encx24j600_phymap_writeable, 499 .writeable_reg = encx24j600_phymap_writeable,
496 .volatile_reg = encx24j600_phymap_volatile, 500 .volatile_reg = encx24j600_phymap_volatile,
497}; 501};
502
498static struct regmap_bus phymap_encx24j600 = { 503static struct regmap_bus phymap_encx24j600 = {
499 .reg_write = regmap_encx24j600_phy_reg_write, 504 .reg_write = regmap_encx24j600_phy_reg_write,
500 .reg_read = regmap_encx24j600_phy_reg_read, 505 .reg_read = regmap_encx24j600_phy_reg_read,
diff --git a/drivers/net/ethernet/microchip/encx24j600.c b/drivers/net/ethernet/microchip/encx24j600.c
index b14f0305aa31..fbce6166504e 100644
--- a/drivers/net/ethernet/microchip/encx24j600.c
+++ b/drivers/net/ethernet/microchip/encx24j600.c
@@ -30,7 +30,7 @@
30 30
31#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK) 31#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
32static int debug = -1; 32static int debug = -1;
33module_param(debug, int, 0); 33module_param(debug, int, 0000);
34MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 34MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
35 35
36/* SRAM memory layout: 36/* SRAM memory layout:
@@ -105,6 +105,7 @@ static u16 encx24j600_read_reg(struct encx24j600_priv *priv, u8 reg)
105 struct net_device *dev = priv->ndev; 105 struct net_device *dev = priv->ndev;
106 unsigned int val = 0; 106 unsigned int val = 0;
107 int ret = regmap_read(priv->ctx.regmap, reg, &val); 107 int ret = regmap_read(priv->ctx.regmap, reg, &val);
108
108 if (unlikely(ret)) 109 if (unlikely(ret))
109 netif_err(priv, drv, dev, "%s: error %d reading reg %02x\n", 110 netif_err(priv, drv, dev, "%s: error %d reading reg %02x\n",
110 __func__, ret, reg); 111 __func__, ret, reg);
@@ -115,6 +116,7 @@ static void encx24j600_write_reg(struct encx24j600_priv *priv, u8 reg, u16 val)
115{ 116{
116 struct net_device *dev = priv->ndev; 117 struct net_device *dev = priv->ndev;
117 int ret = regmap_write(priv->ctx.regmap, reg, val); 118 int ret = regmap_write(priv->ctx.regmap, reg, val);
119
118 if (unlikely(ret)) 120 if (unlikely(ret))
119 netif_err(priv, drv, dev, "%s: error %d writing reg %02x=%04x\n", 121 netif_err(priv, drv, dev, "%s: error %d writing reg %02x=%04x\n",
120 __func__, ret, reg, val); 122 __func__, ret, reg, val);
@@ -125,6 +127,7 @@ static void encx24j600_update_reg(struct encx24j600_priv *priv, u8 reg,
125{ 127{
126 struct net_device *dev = priv->ndev; 128 struct net_device *dev = priv->ndev;
127 int ret = regmap_update_bits(priv->ctx.regmap, reg, mask, val); 129 int ret = regmap_update_bits(priv->ctx.regmap, reg, mask, val);
130
128 if (unlikely(ret)) 131 if (unlikely(ret))
129 netif_err(priv, drv, dev, "%s: error %d updating reg %02x=%04x~%04x\n", 132 netif_err(priv, drv, dev, "%s: error %d updating reg %02x=%04x~%04x\n",
130 __func__, ret, reg, val, mask); 133 __func__, ret, reg, val, mask);
@@ -135,6 +138,7 @@ static u16 encx24j600_read_phy(struct encx24j600_priv *priv, u8 reg)
135 struct net_device *dev = priv->ndev; 138 struct net_device *dev = priv->ndev;
136 unsigned int val = 0; 139 unsigned int val = 0;
137 int ret = regmap_read(priv->ctx.phymap, reg, &val); 140 int ret = regmap_read(priv->ctx.phymap, reg, &val);
141
138 if (unlikely(ret)) 142 if (unlikely(ret))
139 netif_err(priv, drv, dev, "%s: error %d reading %02x\n", 143 netif_err(priv, drv, dev, "%s: error %d reading %02x\n",
140 __func__, ret, reg); 144 __func__, ret, reg);
@@ -145,6 +149,7 @@ static void encx24j600_write_phy(struct encx24j600_priv *priv, u8 reg, u16 val)
145{ 149{
146 struct net_device *dev = priv->ndev; 150 struct net_device *dev = priv->ndev;
147 int ret = regmap_write(priv->ctx.phymap, reg, val); 151 int ret = regmap_write(priv->ctx.phymap, reg, val);
152
148 if (unlikely(ret)) 153 if (unlikely(ret))
149 netif_err(priv, drv, dev, "%s: error %d writing reg %02x=%04x\n", 154 netif_err(priv, drv, dev, "%s: error %d writing reg %02x=%04x\n",
150 __func__, ret, reg, val); 155 __func__, ret, reg, val);
@@ -164,6 +169,7 @@ static void encx24j600_cmd(struct encx24j600_priv *priv, u8 cmd)
164{ 169{
165 struct net_device *dev = priv->ndev; 170 struct net_device *dev = priv->ndev;
166 int ret = regmap_write(priv->ctx.regmap, cmd, 0); 171 int ret = regmap_write(priv->ctx.regmap, cmd, 0);
172
167 if (unlikely(ret)) 173 if (unlikely(ret))
168 netif_err(priv, drv, dev, "%s: error %d with cmd %02x\n", 174 netif_err(priv, drv, dev, "%s: error %d with cmd %02x\n",
169 __func__, ret, cmd); 175 __func__, ret, cmd);
@@ -173,6 +179,7 @@ static int encx24j600_raw_read(struct encx24j600_priv *priv, u8 reg, u8 *data,
173 size_t count) 179 size_t count)
174{ 180{
175 int ret; 181 int ret;
182
176 mutex_lock(&priv->ctx.mutex); 183 mutex_lock(&priv->ctx.mutex);
177 ret = regmap_encx24j600_spi_read(&priv->ctx, reg, data, count); 184 ret = regmap_encx24j600_spi_read(&priv->ctx, reg, data, count);
178 mutex_unlock(&priv->ctx.mutex); 185 mutex_unlock(&priv->ctx.mutex);
@@ -184,6 +191,7 @@ static int encx24j600_raw_write(struct encx24j600_priv *priv, u8 reg,
184 const u8 *data, size_t count) 191 const u8 *data, size_t count)
185{ 192{
186 int ret; 193 int ret;
194
187 mutex_lock(&priv->ctx.mutex); 195 mutex_lock(&priv->ctx.mutex);
188 ret = regmap_encx24j600_spi_write(&priv->ctx, reg, data, count); 196 ret = regmap_encx24j600_spi_write(&priv->ctx, reg, data, count);
189 mutex_unlock(&priv->ctx.mutex); 197 mutex_unlock(&priv->ctx.mutex);
@@ -194,6 +202,7 @@ static int encx24j600_raw_write(struct encx24j600_priv *priv, u8 reg,
194static void encx24j600_update_phcon1(struct encx24j600_priv *priv) 202static void encx24j600_update_phcon1(struct encx24j600_priv *priv)
195{ 203{
196 u16 phcon1 = encx24j600_read_phy(priv, PHCON1); 204 u16 phcon1 = encx24j600_read_phy(priv, PHCON1);
205
197 if (priv->autoneg == AUTONEG_ENABLE) { 206 if (priv->autoneg == AUTONEG_ENABLE) {
198 phcon1 |= ANEN | RENEG; 207 phcon1 |= ANEN | RENEG;
199 } else { 208 } else {
@@ -328,6 +337,7 @@ static int encx24j600_receive_packet(struct encx24j600_priv *priv,
328{ 337{
329 struct net_device *dev = priv->ndev; 338 struct net_device *dev = priv->ndev;
330 struct sk_buff *skb = netdev_alloc_skb(dev, rsv->len + NET_IP_ALIGN); 339 struct sk_buff *skb = netdev_alloc_skb(dev, rsv->len + NET_IP_ALIGN);
340
331 if (!skb) { 341 if (!skb) {
332 pr_err_ratelimited("RX: OOM: packet dropped\n"); 342 pr_err_ratelimited("RX: OOM: packet dropped\n");
333 dev->stats.rx_dropped++; 343 dev->stats.rx_dropped++;
@@ -346,7 +356,6 @@ static int encx24j600_receive_packet(struct encx24j600_priv *priv,
346 /* Maintain stats */ 356 /* Maintain stats */
347 dev->stats.rx_packets++; 357 dev->stats.rx_packets++;
348 dev->stats.rx_bytes += rsv->len; 358 dev->stats.rx_bytes += rsv->len;
349 priv->next_packet = rsv->next_packet;
350 359
351 netif_rx(skb); 360 netif_rx(skb);
352 361
@@ -383,6 +392,8 @@ static void encx24j600_rx_packets(struct encx24j600_priv *priv, u8 packet_count)
383 encx24j600_receive_packet(priv, &rsv); 392 encx24j600_receive_packet(priv, &rsv);
384 } 393 }
385 394
395 priv->next_packet = rsv.next_packet;
396
386 newrxtail = priv->next_packet - 2; 397 newrxtail = priv->next_packet - 2;
387 if (newrxtail == ENC_RX_BUF_START) 398 if (newrxtail == ENC_RX_BUF_START)
388 newrxtail = SRAM_SIZE - 2; 399 newrxtail = SRAM_SIZE - 2;
@@ -827,6 +838,7 @@ static void encx24j600_set_multicast_list(struct net_device *dev)
827static void encx24j600_hw_tx(struct encx24j600_priv *priv) 838static void encx24j600_hw_tx(struct encx24j600_priv *priv)
828{ 839{
829 struct net_device *dev = priv->ndev; 840 struct net_device *dev = priv->ndev;
841
830 netif_info(priv, tx_queued, dev, "TX Packet Len:%d\n", 842 netif_info(priv, tx_queued, dev, "TX Packet Len:%d\n",
831 priv->tx_skb->len); 843 priv->tx_skb->len);
832 844
@@ -894,7 +906,6 @@ static void encx24j600_tx_timeout(struct net_device *dev)
894 906
895 dev->stats.tx_errors++; 907 dev->stats.tx_errors++;
896 netif_wake_queue(dev); 908 netif_wake_queue(dev);
897 return;
898} 909}
899 910
900static int encx24j600_get_regs_len(struct net_device *dev) 911static int encx24j600_get_regs_len(struct net_device *dev)
@@ -957,12 +968,14 @@ static int encx24j600_set_settings(struct net_device *dev,
957static u32 encx24j600_get_msglevel(struct net_device *dev) 968static u32 encx24j600_get_msglevel(struct net_device *dev)
958{ 969{
959 struct encx24j600_priv *priv = netdev_priv(dev); 970 struct encx24j600_priv *priv = netdev_priv(dev);
971
960 return priv->msg_enable; 972 return priv->msg_enable;
961} 973}
962 974
963static void encx24j600_set_msglevel(struct net_device *dev, u32 val) 975static void encx24j600_set_msglevel(struct net_device *dev, u32 val)
964{ 976{
965 struct encx24j600_priv *priv = netdev_priv(dev); 977 struct encx24j600_priv *priv = netdev_priv(dev);
978
966 priv->msg_enable = val; 979 priv->msg_enable = val;
967} 980}
968 981
diff --git a/drivers/net/ethernet/qlogic/qed/qed_iscsi.c b/drivers/net/ethernet/qlogic/qed/qed_iscsi.c
index 00efb1c4c57e..17a70122df05 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iscsi.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iscsi.c
@@ -1265,7 +1265,7 @@ static const struct qed_iscsi_ops qed_iscsi_ops_pass = {
1265 .get_stats = &qed_iscsi_stats, 1265 .get_stats = &qed_iscsi_stats,
1266}; 1266};
1267 1267
1268const struct qed_iscsi_ops *qed_get_iscsi_ops() 1268const struct qed_iscsi_ops *qed_get_iscsi_ops(void)
1269{ 1269{
1270 return &qed_iscsi_ops_pass; 1270 return &qed_iscsi_ops_pass;
1271} 1271}
diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c
index ae32f855e31b..422289c232bc 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac.c
@@ -460,6 +460,12 @@ static int emac_clks_phase1_init(struct platform_device *pdev,
460{ 460{
461 int ret; 461 int ret;
462 462
463 /* On ACPI platforms, clocks are controlled by firmware and/or
464 * ACPI, not by drivers.
465 */
466 if (has_acpi_companion(&pdev->dev))
467 return 0;
468
463 ret = emac_clks_get(pdev, adpt); 469 ret = emac_clks_get(pdev, adpt);
464 if (ret) 470 if (ret)
465 return ret; 471 return ret;
@@ -485,6 +491,9 @@ static int emac_clks_phase2_init(struct platform_device *pdev,
485{ 491{
486 int ret; 492 int ret;
487 493
494 if (has_acpi_companion(&pdev->dev))
495 return 0;
496
488 ret = clk_set_rate(adpt->clk[EMAC_CLK_TX], 125000000); 497 ret = clk_set_rate(adpt->clk[EMAC_CLK_TX], 125000000);
489 if (ret) 498 if (ret)
490 return ret; 499 return ret;
diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
index 4ff4e0491406..aa11b70b9ca4 100644
--- a/drivers/net/ethernet/rdc/r6040.c
+++ b/drivers/net/ethernet/rdc/r6040.c
@@ -472,8 +472,6 @@ static void r6040_down(struct net_device *dev)
472 iowrite16(adrp[0], ioaddr + MID_0L); 472 iowrite16(adrp[0], ioaddr + MID_0L);
473 iowrite16(adrp[1], ioaddr + MID_0M); 473 iowrite16(adrp[1], ioaddr + MID_0M);
474 iowrite16(adrp[2], ioaddr + MID_0H); 474 iowrite16(adrp[2], ioaddr + MID_0H);
475
476 phy_stop(dev->phydev);
477} 475}
478 476
479static int r6040_close(struct net_device *dev) 477static int r6040_close(struct net_device *dev)
@@ -481,12 +479,12 @@ static int r6040_close(struct net_device *dev)
481 struct r6040_private *lp = netdev_priv(dev); 479 struct r6040_private *lp = netdev_priv(dev);
482 struct pci_dev *pdev = lp->pdev; 480 struct pci_dev *pdev = lp->pdev;
483 481
484 spin_lock_irq(&lp->lock); 482 phy_stop(dev->phydev);
485 napi_disable(&lp->napi); 483 napi_disable(&lp->napi);
486 netif_stop_queue(dev); 484 netif_stop_queue(dev);
487 r6040_down(dev);
488 485
489 free_irq(dev->irq, dev); 486 spin_lock_irq(&lp->lock);
487 r6040_down(dev);
490 488
491 /* Free RX buffer */ 489 /* Free RX buffer */
492 r6040_free_rxbufs(dev); 490 r6040_free_rxbufs(dev);
@@ -496,6 +494,8 @@ static int r6040_close(struct net_device *dev)
496 494
497 spin_unlock_irq(&lp->lock); 495 spin_unlock_irq(&lp->lock);
498 496
497 free_irq(dev->irq, dev);
498
499 /* Free Descriptor memory */ 499 /* Free Descriptor memory */
500 if (lp->rx_ring) { 500 if (lp->rx_ring) {
501 pci_free_consistent(pdev, 501 pci_free_consistent(pdev,
diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c
index f644216eda1b..87bdc56b4e3a 100644
--- a/drivers/net/ethernet/sfc/ethtool.c
+++ b/drivers/net/ethernet/sfc/ethtool.c
@@ -120,44 +120,53 @@ static int efx_ethtool_phys_id(struct net_device *net_dev,
120} 120}
121 121
122/* This must be called with rtnl_lock held. */ 122/* This must be called with rtnl_lock held. */
123static int efx_ethtool_get_settings(struct net_device *net_dev, 123static int
124 struct ethtool_cmd *ecmd) 124efx_ethtool_get_link_ksettings(struct net_device *net_dev,
125 struct ethtool_link_ksettings *cmd)
125{ 126{
126 struct efx_nic *efx = netdev_priv(net_dev); 127 struct efx_nic *efx = netdev_priv(net_dev);
127 struct efx_link_state *link_state = &efx->link_state; 128 struct efx_link_state *link_state = &efx->link_state;
129 u32 supported;
128 130
129 mutex_lock(&efx->mac_lock); 131 mutex_lock(&efx->mac_lock);
130 efx->phy_op->get_settings(efx, ecmd); 132 efx->phy_op->get_link_ksettings(efx, cmd);
131 mutex_unlock(&efx->mac_lock); 133 mutex_unlock(&efx->mac_lock);
132 134
133 /* Both MACs support pause frames (bidirectional and respond-only) */ 135 /* Both MACs support pause frames (bidirectional and respond-only) */
134 ecmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; 136 ethtool_convert_link_mode_to_legacy_u32(&supported,
137 cmd->link_modes.supported);
138
139 supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
140
141 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
142 supported);
135 143
136 if (LOOPBACK_INTERNAL(efx)) { 144 if (LOOPBACK_INTERNAL(efx)) {
137 ethtool_cmd_speed_set(ecmd, link_state->speed); 145 cmd->base.speed = link_state->speed;
138 ecmd->duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF; 146 cmd->base.duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF;
139 } 147 }
140 148
141 return 0; 149 return 0;
142} 150}
143 151
144/* This must be called with rtnl_lock held. */ 152/* This must be called with rtnl_lock held. */
145static int efx_ethtool_set_settings(struct net_device *net_dev, 153static int
146 struct ethtool_cmd *ecmd) 154efx_ethtool_set_link_ksettings(struct net_device *net_dev,
155 const struct ethtool_link_ksettings *cmd)
147{ 156{
148 struct efx_nic *efx = netdev_priv(net_dev); 157 struct efx_nic *efx = netdev_priv(net_dev);
149 int rc; 158 int rc;
150 159
151 /* GMAC does not support 1000Mbps HD */ 160 /* GMAC does not support 1000Mbps HD */
152 if ((ethtool_cmd_speed(ecmd) == SPEED_1000) && 161 if ((cmd->base.speed == SPEED_1000) &&
153 (ecmd->duplex != DUPLEX_FULL)) { 162 (cmd->base.duplex != DUPLEX_FULL)) {
154 netif_dbg(efx, drv, efx->net_dev, 163 netif_dbg(efx, drv, efx->net_dev,
155 "rejecting unsupported 1000Mbps HD setting\n"); 164 "rejecting unsupported 1000Mbps HD setting\n");
156 return -EINVAL; 165 return -EINVAL;
157 } 166 }
158 167
159 mutex_lock(&efx->mac_lock); 168 mutex_lock(&efx->mac_lock);
160 rc = efx->phy_op->set_settings(efx, ecmd); 169 rc = efx->phy_op->set_link_ksettings(efx, cmd);
161 mutex_unlock(&efx->mac_lock); 170 mutex_unlock(&efx->mac_lock);
162 return rc; 171 return rc;
163} 172}
@@ -1342,8 +1351,6 @@ static int efx_ethtool_get_module_info(struct net_device *net_dev,
1342} 1351}
1343 1352
1344const struct ethtool_ops efx_ethtool_ops = { 1353const struct ethtool_ops efx_ethtool_ops = {
1345 .get_settings = efx_ethtool_get_settings,
1346 .set_settings = efx_ethtool_set_settings,
1347 .get_drvinfo = efx_ethtool_get_drvinfo, 1354 .get_drvinfo = efx_ethtool_get_drvinfo,
1348 .get_regs_len = efx_ethtool_get_regs_len, 1355 .get_regs_len = efx_ethtool_get_regs_len,
1349 .get_regs = efx_ethtool_get_regs, 1356 .get_regs = efx_ethtool_get_regs,
@@ -1373,4 +1380,6 @@ const struct ethtool_ops efx_ethtool_ops = {
1373 .get_ts_info = efx_ethtool_get_ts_info, 1380 .get_ts_info = efx_ethtool_get_ts_info,
1374 .get_module_info = efx_ethtool_get_module_info, 1381 .get_module_info = efx_ethtool_get_module_info,
1375 .get_module_eeprom = efx_ethtool_get_module_eeprom, 1382 .get_module_eeprom = efx_ethtool_get_module_eeprom,
1383 .get_link_ksettings = efx_ethtool_get_link_ksettings,
1384 .set_link_ksettings = efx_ethtool_set_link_ksettings,
1376}; 1385};
diff --git a/drivers/net/ethernet/sfc/mcdi_port.c b/drivers/net/ethernet/sfc/mcdi_port.c
index 9dcd396784ae..c905971c5f3a 100644
--- a/drivers/net/ethernet/sfc/mcdi_port.c
+++ b/drivers/net/ethernet/sfc/mcdi_port.c
@@ -503,45 +503,59 @@ static void efx_mcdi_phy_remove(struct efx_nic *efx)
503 kfree(phy_data); 503 kfree(phy_data);
504} 504}
505 505
506static void efx_mcdi_phy_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) 506static void efx_mcdi_phy_get_link_ksettings(struct efx_nic *efx,
507 struct ethtool_link_ksettings *cmd)
507{ 508{
508 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; 509 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
509 MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_LINK_OUT_LEN); 510 MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_LINK_OUT_LEN);
510 int rc; 511 int rc;
511 512 u32 supported, advertising, lp_advertising;
512 ecmd->supported = 513
513 mcdi_to_ethtool_cap(phy_cfg->media, phy_cfg->supported_cap); 514 supported = mcdi_to_ethtool_cap(phy_cfg->media, phy_cfg->supported_cap);
514 ecmd->advertising = efx->link_advertising; 515 advertising = efx->link_advertising;
515 ethtool_cmd_speed_set(ecmd, efx->link_state.speed); 516 cmd->base.speed = efx->link_state.speed;
516 ecmd->duplex = efx->link_state.fd; 517 cmd->base.duplex = efx->link_state.fd;
517 ecmd->port = mcdi_to_ethtool_media(phy_cfg->media); 518 cmd->base.port = mcdi_to_ethtool_media(phy_cfg->media);
518 ecmd->phy_address = phy_cfg->port; 519 cmd->base.phy_address = phy_cfg->port;
519 ecmd->transceiver = XCVR_INTERNAL; 520 cmd->base.autoneg = !!(efx->link_advertising & ADVERTISED_Autoneg);
520 ecmd->autoneg = !!(efx->link_advertising & ADVERTISED_Autoneg); 521 cmd->base.mdio_support = (efx->mdio.mode_support &
521 ecmd->mdio_support = (efx->mdio.mode_support &
522 (MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22)); 522 (MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22));
523 523
524 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
525 supported);
526 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
527 advertising);
528
524 BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0); 529 BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
525 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, 530 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
526 outbuf, sizeof(outbuf), NULL); 531 outbuf, sizeof(outbuf), NULL);
527 if (rc) 532 if (rc)
528 return; 533 return;
529 ecmd->lp_advertising = 534 lp_advertising =
530 mcdi_to_ethtool_cap(phy_cfg->media, 535 mcdi_to_ethtool_cap(phy_cfg->media,
531 MCDI_DWORD(outbuf, GET_LINK_OUT_LP_CAP)); 536 MCDI_DWORD(outbuf, GET_LINK_OUT_LP_CAP));
537
538 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.lp_advertising,
539 lp_advertising);
532} 540}
533 541
534static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) 542static int
543efx_mcdi_phy_set_link_ksettings(struct efx_nic *efx,
544 const struct ethtool_link_ksettings *cmd)
535{ 545{
536 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; 546 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
537 u32 caps; 547 u32 caps;
538 int rc; 548 int rc;
549 u32 advertising;
550
551 ethtool_convert_link_mode_to_legacy_u32(&advertising,
552 cmd->link_modes.advertising);
539 553
540 if (ecmd->autoneg) { 554 if (cmd->base.autoneg) {
541 caps = (ethtool_to_mcdi_cap(ecmd->advertising) | 555 caps = (ethtool_to_mcdi_cap(advertising) |
542 1 << MC_CMD_PHY_CAP_AN_LBN); 556 1 << MC_CMD_PHY_CAP_AN_LBN);
543 } else if (ecmd->duplex) { 557 } else if (cmd->base.duplex) {
544 switch (ethtool_cmd_speed(ecmd)) { 558 switch (cmd->base.speed) {
545 case 10: caps = 1 << MC_CMD_PHY_CAP_10FDX_LBN; break; 559 case 10: caps = 1 << MC_CMD_PHY_CAP_10FDX_LBN; break;
546 case 100: caps = 1 << MC_CMD_PHY_CAP_100FDX_LBN; break; 560 case 100: caps = 1 << MC_CMD_PHY_CAP_100FDX_LBN; break;
547 case 1000: caps = 1 << MC_CMD_PHY_CAP_1000FDX_LBN; break; 561 case 1000: caps = 1 << MC_CMD_PHY_CAP_1000FDX_LBN; break;
@@ -550,7 +564,7 @@ static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ec
550 default: return -EINVAL; 564 default: return -EINVAL;
551 } 565 }
552 } else { 566 } else {
553 switch (ethtool_cmd_speed(ecmd)) { 567 switch (cmd->base.speed) {
554 case 10: caps = 1 << MC_CMD_PHY_CAP_10HDX_LBN; break; 568 case 10: caps = 1 << MC_CMD_PHY_CAP_10HDX_LBN; break;
555 case 100: caps = 1 << MC_CMD_PHY_CAP_100HDX_LBN; break; 569 case 100: caps = 1 << MC_CMD_PHY_CAP_100HDX_LBN; break;
556 case 1000: caps = 1 << MC_CMD_PHY_CAP_1000HDX_LBN; break; 570 case 1000: caps = 1 << MC_CMD_PHY_CAP_1000HDX_LBN; break;
@@ -563,9 +577,9 @@ static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ec
563 if (rc) 577 if (rc)
564 return rc; 578 return rc;
565 579
566 if (ecmd->autoneg) { 580 if (cmd->base.autoneg) {
567 efx_link_set_advertising( 581 efx_link_set_advertising(
568 efx, ecmd->advertising | ADVERTISED_Autoneg); 582 efx, advertising | ADVERTISED_Autoneg);
569 phy_cfg->forced_cap = 0; 583 phy_cfg->forced_cap = 0;
570 } else { 584 } else {
571 efx_link_set_advertising(efx, 0); 585 efx_link_set_advertising(efx, 0);
@@ -812,8 +826,8 @@ static const struct efx_phy_operations efx_mcdi_phy_ops = {
812 .poll = efx_mcdi_phy_poll, 826 .poll = efx_mcdi_phy_poll,
813 .fini = efx_port_dummy_op_void, 827 .fini = efx_port_dummy_op_void,
814 .remove = efx_mcdi_phy_remove, 828 .remove = efx_mcdi_phy_remove,
815 .get_settings = efx_mcdi_phy_get_settings, 829 .get_link_ksettings = efx_mcdi_phy_get_link_ksettings,
816 .set_settings = efx_mcdi_phy_set_settings, 830 .set_link_ksettings = efx_mcdi_phy_set_link_ksettings,
817 .test_alive = efx_mcdi_phy_test_alive, 831 .test_alive = efx_mcdi_phy_test_alive,
818 .run_tests = efx_mcdi_phy_run_tests, 832 .run_tests = efx_mcdi_phy_run_tests,
819 .test_name = efx_mcdi_phy_test_name, 833 .test_name = efx_mcdi_phy_test_name,
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
index 8692e829b40f..1a635ced62d0 100644
--- a/drivers/net/ethernet/sfc/net_driver.h
+++ b/drivers/net/ethernet/sfc/net_driver.h
@@ -720,8 +720,8 @@ static inline bool efx_link_state_equal(const struct efx_link_state *left,
720 * @reconfigure: Reconfigure PHY (e.g. for new link parameters) 720 * @reconfigure: Reconfigure PHY (e.g. for new link parameters)
721 * @poll: Update @link_state and report whether it changed. 721 * @poll: Update @link_state and report whether it changed.
722 * Serialised by the mac_lock. 722 * Serialised by the mac_lock.
723 * @get_settings: Get ethtool settings. Serialised by the mac_lock. 723 * @get_link_ksettings: Get ethtool settings. Serialised by the mac_lock.
724 * @set_settings: Set ethtool settings. Serialised by the mac_lock. 724 * @set_link_ksettings: Set ethtool settings. Serialised by the mac_lock.
725 * @set_npage_adv: Set abilities advertised in (Extended) Next Page 725 * @set_npage_adv: Set abilities advertised in (Extended) Next Page
726 * (only needed where AN bit is set in mmds) 726 * (only needed where AN bit is set in mmds)
727 * @test_alive: Test that PHY is 'alive' (online) 727 * @test_alive: Test that PHY is 'alive' (online)
@@ -736,10 +736,10 @@ struct efx_phy_operations {
736 void (*remove) (struct efx_nic *efx); 736 void (*remove) (struct efx_nic *efx);
737 int (*reconfigure) (struct efx_nic *efx); 737 int (*reconfigure) (struct efx_nic *efx);
738 bool (*poll) (struct efx_nic *efx); 738 bool (*poll) (struct efx_nic *efx);
739 void (*get_settings) (struct efx_nic *efx, 739 void (*get_link_ksettings)(struct efx_nic *efx,
740 struct ethtool_cmd *ecmd); 740 struct ethtool_link_ksettings *cmd);
741 int (*set_settings) (struct efx_nic *efx, 741 int (*set_link_ksettings)(struct efx_nic *efx,
742 struct ethtool_cmd *ecmd); 742 const struct ethtool_link_ksettings *cmd);
743 void (*set_npage_adv) (struct efx_nic *efx, u32); 743 void (*set_npage_adv) (struct efx_nic *efx, u32);
744 int (*test_alive) (struct efx_nic *efx); 744 int (*test_alive) (struct efx_nic *efx);
745 const char *(*test_name) (struct efx_nic *efx, unsigned int index); 745 const char *(*test_name) (struct efx_nic *efx, unsigned int index);
diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 98f10c216521..8b6810bad54b 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -158,9 +158,9 @@ static bool gtp_check_src_ms_ipv4(struct sk_buff *skb, struct pdp_ctx *pctx,
158 if (!pskb_may_pull(skb, hdrlen + sizeof(struct iphdr))) 158 if (!pskb_may_pull(skb, hdrlen + sizeof(struct iphdr)))
159 return false; 159 return false;
160 160
161 iph = (struct iphdr *)(skb->data + hdrlen + sizeof(struct iphdr)); 161 iph = (struct iphdr *)(skb->data + hdrlen);
162 162
163 return iph->saddr != pctx->ms_addr_ip4.s_addr; 163 return iph->saddr == pctx->ms_addr_ip4.s_addr;
164} 164}
165 165
166/* Check if the inner IP source address in this packet is assigned to any 166/* Check if the inner IP source address in this packet is assigned to any
@@ -423,11 +423,11 @@ static inline void gtp1_push_header(struct sk_buff *skb, struct pdp_ctx *pctx)
423 423
424 /* Bits 8 7 6 5 4 3 2 1 424 /* Bits 8 7 6 5 4 3 2 1
425 * +--+--+--+--+--+--+--+--+ 425 * +--+--+--+--+--+--+--+--+
426 * |version |PT| 1| E| S|PN| 426 * |version |PT| 0| E| S|PN|
427 * +--+--+--+--+--+--+--+--+ 427 * +--+--+--+--+--+--+--+--+
428 * 0 0 1 1 1 0 0 0 428 * 0 0 1 1 1 0 0 0
429 */ 429 */
430 gtp1->flags = 0x38; /* v1, GTP-non-prime. */ 430 gtp1->flags = 0x30; /* v1, GTP-non-prime. */
431 gtp1->type = GTP_TPDU; 431 gtp1->type = GTP_TPDU;
432 gtp1->length = htons(payload_len); 432 gtp1->length = htons(payload_len);
433 gtp1->tid = htonl(pctx->u.v1.o_tei); 433 gtp1->tid = htonl(pctx->u.v1.o_tei);
diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c
index f293d33fb28f..8d5b903d1d9d 100644
--- a/drivers/net/irda/w83977af_ir.c
+++ b/drivers/net/irda/w83977af_ir.c
@@ -517,9 +517,9 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
517 517
518 mtt = irda_get_mtt(skb); 518 mtt = irda_get_mtt(skb);
519 pr_debug("%s: %ld, mtt=%d\n", __func__, jiffies, mtt); 519 pr_debug("%s: %ld, mtt=%d\n", __func__, jiffies, mtt);
520 if (mtt > 1000) 520 if (mtt > 1000)
521 mdelay(mtt / 1000); 521 mdelay(mtt / 1000);
522 else if (mtt) 522 else if (mtt)
523 udelay(mtt); 523 udelay(mtt);
524 524
525 /* Enable DMA interrupt */ 525 /* Enable DMA interrupt */
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b425fa1013af..08327e005ccc 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -22,6 +22,7 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/virtio.h> 23#include <linux/virtio.h>
24#include <linux/virtio_net.h> 24#include <linux/virtio_net.h>
25#include <linux/bpf.h>
25#include <linux/scatterlist.h> 26#include <linux/scatterlist.h>
26#include <linux/if_vlan.h> 27#include <linux/if_vlan.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
@@ -81,6 +82,8 @@ struct receive_queue {
81 82
82 struct napi_struct napi; 83 struct napi_struct napi;
83 84
85 struct bpf_prog __rcu *xdp_prog;
86
84 /* Chain pages by the private ptr. */ 87 /* Chain pages by the private ptr. */
85 struct page *pages; 88 struct page *pages;
86 89
@@ -111,6 +114,9 @@ struct virtnet_info {
111 /* # of queue pairs currently used by the driver */ 114 /* # of queue pairs currently used by the driver */
112 u16 curr_queue_pairs; 115 u16 curr_queue_pairs;
113 116
117 /* # of XDP queue pairs currently used by the driver */
118 u16 xdp_queue_pairs;
119
114 /* I like... big packets and I cannot lie! */ 120 /* I like... big packets and I cannot lie! */
115 bool big_packets; 121 bool big_packets;
116 122
@@ -324,6 +330,90 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
324 return skb; 330 return skb;
325} 331}
326 332
333static void virtnet_xdp_xmit(struct virtnet_info *vi,
334 struct receive_queue *rq,
335 struct send_queue *sq,
336 struct xdp_buff *xdp)
337{
338 struct page *page = virt_to_head_page(xdp->data);
339 struct virtio_net_hdr_mrg_rxbuf *hdr;
340 unsigned int num_sg, len;
341 void *xdp_sent;
342 int err;
343
344 /* Free up any pending old buffers before queueing new ones. */
345 while ((xdp_sent = virtqueue_get_buf(sq->vq, &len)) != NULL) {
346 struct page *sent_page = virt_to_head_page(xdp_sent);
347
348 if (vi->mergeable_rx_bufs)
349 put_page(sent_page);
350 else
351 give_pages(rq, sent_page);
352 }
353
354 /* Zero header and leave csum up to XDP layers */
355 hdr = xdp->data;
356 memset(hdr, 0, vi->hdr_len);
357
358 num_sg = 1;
359 sg_init_one(sq->sg, xdp->data, xdp->data_end - xdp->data);
360 err = virtqueue_add_outbuf(sq->vq, sq->sg, num_sg,
361 xdp->data, GFP_ATOMIC);
362 if (unlikely(err)) {
363 if (vi->mergeable_rx_bufs)
364 put_page(page);
365 else
366 give_pages(rq, page);
367 return; // On error abort to avoid unnecessary kick
368 } else if (!vi->mergeable_rx_bufs) {
369 /* If not mergeable bufs must be big packets so cleanup pages */
370 give_pages(rq, (struct page *)page->private);
371 page->private = 0;
372 }
373
374 virtqueue_kick(sq->vq);
375}
376
377static u32 do_xdp_prog(struct virtnet_info *vi,
378 struct receive_queue *rq,
379 struct bpf_prog *xdp_prog,
380 struct page *page, int offset, int len)
381{
382 int hdr_padded_len;
383 struct xdp_buff xdp;
384 unsigned int qp;
385 u32 act;
386 u8 *buf;
387
388 buf = page_address(page) + offset;
389
390 if (vi->mergeable_rx_bufs)
391 hdr_padded_len = sizeof(struct virtio_net_hdr_mrg_rxbuf);
392 else
393 hdr_padded_len = sizeof(struct padded_vnet_hdr);
394
395 xdp.data = buf + hdr_padded_len;
396 xdp.data_end = xdp.data + (len - vi->hdr_len);
397
398 act = bpf_prog_run_xdp(xdp_prog, &xdp);
399 switch (act) {
400 case XDP_PASS:
401 return XDP_PASS;
402 case XDP_TX:
403 qp = vi->curr_queue_pairs -
404 vi->xdp_queue_pairs +
405 smp_processor_id();
406 xdp.data = buf + (vi->mergeable_rx_bufs ? 0 : 4);
407 virtnet_xdp_xmit(vi, rq, &vi->sq[qp], &xdp);
408 return XDP_TX;
409 default:
410 bpf_warn_invalid_xdp_action(act);
411 case XDP_ABORTED:
412 case XDP_DROP:
413 return XDP_DROP;
414 }
415}
416
327static struct sk_buff *receive_small(struct virtnet_info *vi, void *buf, unsigned int len) 417static struct sk_buff *receive_small(struct virtnet_info *vi, void *buf, unsigned int len)
328{ 418{
329 struct sk_buff * skb = buf; 419 struct sk_buff * skb = buf;
@@ -340,17 +430,102 @@ static struct sk_buff *receive_big(struct net_device *dev,
340 void *buf, 430 void *buf,
341 unsigned int len) 431 unsigned int len)
342{ 432{
433 struct bpf_prog *xdp_prog;
343 struct page *page = buf; 434 struct page *page = buf;
344 struct sk_buff *skb = page_to_skb(vi, rq, page, 0, len, PAGE_SIZE); 435 struct sk_buff *skb;
345 436
437 rcu_read_lock();
438 xdp_prog = rcu_dereference(rq->xdp_prog);
439 if (xdp_prog) {
440 struct virtio_net_hdr_mrg_rxbuf *hdr = buf;
441 u32 act;
442
443 if (unlikely(hdr->hdr.gso_type || hdr->hdr.flags))
444 goto err_xdp;
445 act = do_xdp_prog(vi, rq, xdp_prog, page, 0, len);
446 switch (act) {
447 case XDP_PASS:
448 break;
449 case XDP_TX:
450 rcu_read_unlock();
451 goto xdp_xmit;
452 case XDP_DROP:
453 default:
454 goto err_xdp;
455 }
456 }
457 rcu_read_unlock();
458
459 skb = page_to_skb(vi, rq, page, 0, len, PAGE_SIZE);
346 if (unlikely(!skb)) 460 if (unlikely(!skb))
347 goto err; 461 goto err;
348 462
349 return skb; 463 return skb;
350 464
465err_xdp:
466 rcu_read_unlock();
351err: 467err:
352 dev->stats.rx_dropped++; 468 dev->stats.rx_dropped++;
353 give_pages(rq, page); 469 give_pages(rq, page);
470xdp_xmit:
471 return NULL;
472}
473
474/* The conditions to enable XDP should preclude the underlying device from
475 * sending packets across multiple buffers (num_buf > 1). However per spec
476 * it does not appear to be illegal to do so but rather just against convention.
477 * So in order to avoid making a system unresponsive the packets are pushed
478 * into a page and the XDP program is run. This will be extremely slow and we
479 * push a warning to the user to fix this as soon as possible. Fixing this may
480 * require resolving the underlying hardware to determine why multiple buffers
481 * are being received or simply loading the XDP program in the ingress stack
482 * after the skb is built because there is no advantage to running it here
483 * anymore.
484 */
485static struct page *xdp_linearize_page(struct receive_queue *rq,
486 u16 num_buf,
487 struct page *p,
488 int offset,
489 unsigned int *len)
490{
491 struct page *page = alloc_page(GFP_ATOMIC);
492 unsigned int page_off = 0;
493
494 if (!page)
495 return NULL;
496
497 memcpy(page_address(page) + page_off, page_address(p) + offset, *len);
498 page_off += *len;
499
500 while (--num_buf) {
501 unsigned int buflen;
502 unsigned long ctx;
503 void *buf;
504 int off;
505
506 ctx = (unsigned long)virtqueue_get_buf(rq->vq, &buflen);
507 if (unlikely(!ctx))
508 goto err_buf;
509
510 /* guard against a misconfigured or uncooperative backend that
511 * is sending packet larger than the MTU.
512 */
513 if ((page_off + buflen) > PAGE_SIZE)
514 goto err_buf;
515
516 buf = mergeable_ctx_to_buf_address(ctx);
517 p = virt_to_head_page(buf);
518 off = buf - page_address(p);
519
520 memcpy(page_address(page) + page_off,
521 page_address(p) + off, buflen);
522 page_off += buflen;
523 }
524
525 *len = page_off;
526 return page;
527err_buf:
528 __free_pages(page, 0);
354 return NULL; 529 return NULL;
355} 530}
356 531
@@ -365,11 +540,67 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
365 u16 num_buf = virtio16_to_cpu(vi->vdev, hdr->num_buffers); 540 u16 num_buf = virtio16_to_cpu(vi->vdev, hdr->num_buffers);
366 struct page *page = virt_to_head_page(buf); 541 struct page *page = virt_to_head_page(buf);
367 int offset = buf - page_address(page); 542 int offset = buf - page_address(page);
368 unsigned int truesize = max(len, mergeable_ctx_to_buf_truesize(ctx)); 543 struct sk_buff *head_skb, *curr_skb;
544 struct bpf_prog *xdp_prog;
545 unsigned int truesize;
546
547 head_skb = NULL;
548
549 rcu_read_lock();
550 xdp_prog = rcu_dereference(rq->xdp_prog);
551 if (xdp_prog) {
552 struct page *xdp_page;
553 u32 act;
554
555 /* No known backend devices should send packets with
556 * more than a single buffer when XDP conditions are
557 * met. However it is not strictly illegal so the case
558 * is handled as an exception and a warning is thrown.
559 */
560 if (unlikely(num_buf > 1)) {
561 bpf_warn_invalid_xdp_buffer();
562
563 /* linearize data for XDP */
564 xdp_page = xdp_linearize_page(rq, num_buf,
565 page, offset, &len);
566 if (!xdp_page)
567 goto err_xdp;
568 offset = 0;
569 } else {
570 xdp_page = page;
571 }
572
573 /* Transient failure which in theory could occur if
574 * in-flight packets from before XDP was enabled reach
575 * the receive path after XDP is loaded. In practice I
576 * was not able to create this condition.
577 */
578 if (unlikely(hdr->hdr.gso_type || hdr->hdr.flags))
579 goto err_xdp;
580
581 act = do_xdp_prog(vi, rq, xdp_prog, page, offset, len);
582 switch (act) {
583 case XDP_PASS:
584 if (unlikely(xdp_page != page))
585 __free_pages(xdp_page, 0);
586 break;
587 case XDP_TX:
588 if (unlikely(xdp_page != page))
589 goto err_xdp;
590 rcu_read_unlock();
591 goto xdp_xmit;
592 case XDP_DROP:
593 default:
594 if (unlikely(xdp_page != page))
595 __free_pages(xdp_page, 0);
596 goto err_xdp;
597 }
598 }
599 rcu_read_unlock();
369 600
370 struct sk_buff *head_skb = page_to_skb(vi, rq, page, offset, len, 601 truesize = max(len, mergeable_ctx_to_buf_truesize(ctx));
371 truesize); 602 head_skb = page_to_skb(vi, rq, page, offset, len, truesize);
372 struct sk_buff *curr_skb = head_skb; 603 curr_skb = head_skb;
373 604
374 if (unlikely(!curr_skb)) 605 if (unlikely(!curr_skb))
375 goto err_skb; 606 goto err_skb;
@@ -423,6 +654,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
423 ewma_pkt_len_add(&rq->mrg_avg_pkt_len, head_skb->len); 654 ewma_pkt_len_add(&rq->mrg_avg_pkt_len, head_skb->len);
424 return head_skb; 655 return head_skb;
425 656
657err_xdp:
658 rcu_read_unlock();
426err_skb: 659err_skb:
427 put_page(page); 660 put_page(page);
428 while (--num_buf) { 661 while (--num_buf) {
@@ -439,6 +672,7 @@ err_skb:
439err_buf: 672err_buf:
440 dev->stats.rx_dropped++; 673 dev->stats.rx_dropped++;
441 dev_kfree_skb(head_skb); 674 dev_kfree_skb(head_skb);
675xdp_xmit:
442 return NULL; 676 return NULL;
443} 677}
444 678
@@ -1337,6 +1571,13 @@ static int virtnet_set_channels(struct net_device *dev,
1337 if (queue_pairs > vi->max_queue_pairs || queue_pairs == 0) 1571 if (queue_pairs > vi->max_queue_pairs || queue_pairs == 0)
1338 return -EINVAL; 1572 return -EINVAL;
1339 1573
1574 /* For now we don't support modifying channels while XDP is loaded
1575 * also when XDP is loaded all RX queues have XDP programs so we only
1576 * need to check a single RX queue.
1577 */
1578 if (vi->rq[0].xdp_prog)
1579 return -EINVAL;
1580
1340 get_online_cpus(); 1581 get_online_cpus();
1341 err = virtnet_set_queues(vi, queue_pairs); 1582 err = virtnet_set_queues(vi, queue_pairs);
1342 if (!err) { 1583 if (!err) {
@@ -1428,6 +1669,93 @@ static const struct ethtool_ops virtnet_ethtool_ops = {
1428 .set_settings = virtnet_set_settings, 1669 .set_settings = virtnet_set_settings,
1429}; 1670};
1430 1671
1672static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog)
1673{
1674 unsigned long int max_sz = PAGE_SIZE - sizeof(struct padded_vnet_hdr);
1675 struct virtnet_info *vi = netdev_priv(dev);
1676 struct bpf_prog *old_prog;
1677 u16 xdp_qp = 0, curr_qp;
1678 int i, err;
1679
1680 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO4) ||
1681 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6)) {
1682 netdev_warn(dev, "can't set XDP while host is implementing LRO, disable LRO first\n");
1683 return -EOPNOTSUPP;
1684 }
1685
1686 if (vi->mergeable_rx_bufs && !vi->any_header_sg) {
1687 netdev_warn(dev, "XDP expects header/data in single page, any_header_sg required\n");
1688 return -EINVAL;
1689 }
1690
1691 if (dev->mtu > max_sz) {
1692 netdev_warn(dev, "XDP requires MTU less than %lu\n", max_sz);
1693 return -EINVAL;
1694 }
1695
1696 curr_qp = vi->curr_queue_pairs - vi->xdp_queue_pairs;
1697 if (prog)
1698 xdp_qp = nr_cpu_ids;
1699
1700 /* XDP requires extra queues for XDP_TX */
1701 if (curr_qp + xdp_qp > vi->max_queue_pairs) {
1702 netdev_warn(dev, "request %i queues but max is %i\n",
1703 curr_qp + xdp_qp, vi->max_queue_pairs);
1704 return -ENOMEM;
1705 }
1706
1707 err = virtnet_set_queues(vi, curr_qp + xdp_qp);
1708 if (err) {
1709 dev_warn(&dev->dev, "XDP Device queue allocation failure.\n");
1710 return err;
1711 }
1712
1713 if (prog) {
1714 prog = bpf_prog_add(prog, vi->max_queue_pairs - 1);
1715 if (IS_ERR(prog)) {
1716 virtnet_set_queues(vi, curr_qp);
1717 return PTR_ERR(prog);
1718 }
1719 }
1720
1721 vi->xdp_queue_pairs = xdp_qp;
1722 netif_set_real_num_rx_queues(dev, curr_qp + xdp_qp);
1723
1724 for (i = 0; i < vi->max_queue_pairs; i++) {
1725 old_prog = rtnl_dereference(vi->rq[i].xdp_prog);
1726 rcu_assign_pointer(vi->rq[i].xdp_prog, prog);
1727 if (old_prog)
1728 bpf_prog_put(old_prog);
1729 }
1730
1731 return 0;
1732}
1733
1734static bool virtnet_xdp_query(struct net_device *dev)
1735{
1736 struct virtnet_info *vi = netdev_priv(dev);
1737 int i;
1738
1739 for (i = 0; i < vi->max_queue_pairs; i++) {
1740 if (vi->rq[i].xdp_prog)
1741 return true;
1742 }
1743 return false;
1744}
1745
1746static int virtnet_xdp(struct net_device *dev, struct netdev_xdp *xdp)
1747{
1748 switch (xdp->command) {
1749 case XDP_SETUP_PROG:
1750 return virtnet_xdp_set(dev, xdp->prog);
1751 case XDP_QUERY_PROG:
1752 xdp->prog_attached = virtnet_xdp_query(dev);
1753 return 0;
1754 default:
1755 return -EINVAL;
1756 }
1757}
1758
1431static const struct net_device_ops virtnet_netdev = { 1759static const struct net_device_ops virtnet_netdev = {
1432 .ndo_open = virtnet_open, 1760 .ndo_open = virtnet_open,
1433 .ndo_stop = virtnet_close, 1761 .ndo_stop = virtnet_close,
@@ -1444,6 +1772,7 @@ static const struct net_device_ops virtnet_netdev = {
1444#ifdef CONFIG_NET_RX_BUSY_POLL 1772#ifdef CONFIG_NET_RX_BUSY_POLL
1445 .ndo_busy_poll = virtnet_busy_poll, 1773 .ndo_busy_poll = virtnet_busy_poll,
1446#endif 1774#endif
1775 .ndo_xdp = virtnet_xdp,
1447}; 1776};
1448 1777
1449static void virtnet_config_changed_work(struct work_struct *work) 1778static void virtnet_config_changed_work(struct work_struct *work)
@@ -1505,12 +1834,20 @@ static void virtnet_free_queues(struct virtnet_info *vi)
1505 1834
1506static void free_receive_bufs(struct virtnet_info *vi) 1835static void free_receive_bufs(struct virtnet_info *vi)
1507{ 1836{
1837 struct bpf_prog *old_prog;
1508 int i; 1838 int i;
1509 1839
1840 rtnl_lock();
1510 for (i = 0; i < vi->max_queue_pairs; i++) { 1841 for (i = 0; i < vi->max_queue_pairs; i++) {
1511 while (vi->rq[i].pages) 1842 while (vi->rq[i].pages)
1512 __free_pages(get_a_page(&vi->rq[i], GFP_KERNEL), 0); 1843 __free_pages(get_a_page(&vi->rq[i], GFP_KERNEL), 0);
1844
1845 old_prog = rtnl_dereference(vi->rq[i].xdp_prog);
1846 RCU_INIT_POINTER(vi->rq[i].xdp_prog, NULL);
1847 if (old_prog)
1848 bpf_prog_put(old_prog);
1513 } 1849 }
1850 rtnl_unlock();
1514} 1851}
1515 1852
1516static void free_receive_page_frags(struct virtnet_info *vi) 1853static void free_receive_page_frags(struct virtnet_info *vi)
@@ -1521,6 +1858,16 @@ static void free_receive_page_frags(struct virtnet_info *vi)
1521 put_page(vi->rq[i].alloc_frag.page); 1858 put_page(vi->rq[i].alloc_frag.page);
1522} 1859}
1523 1860
1861static bool is_xdp_queue(struct virtnet_info *vi, int q)
1862{
1863 if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs))
1864 return false;
1865 else if (q < vi->curr_queue_pairs)
1866 return true;
1867 else
1868 return false;
1869}
1870
1524static void free_unused_bufs(struct virtnet_info *vi) 1871static void free_unused_bufs(struct virtnet_info *vi)
1525{ 1872{
1526 void *buf; 1873 void *buf;
@@ -1528,8 +1875,12 @@ static void free_unused_bufs(struct virtnet_info *vi)
1528 1875
1529 for (i = 0; i < vi->max_queue_pairs; i++) { 1876 for (i = 0; i < vi->max_queue_pairs; i++) {
1530 struct virtqueue *vq = vi->sq[i].vq; 1877 struct virtqueue *vq = vi->sq[i].vq;
1531 while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) 1878 while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) {
1532 dev_kfree_skb(buf); 1879 if (!is_xdp_queue(vi, i))
1880 dev_kfree_skb(buf);
1881 else
1882 put_page(virt_to_head_page(buf));
1883 }
1533 } 1884 }
1534 1885
1535 for (i = 0; i < vi->max_queue_pairs; i++) { 1886 for (i = 0; i < vi->max_queue_pairs; i++) {
@@ -1930,7 +2281,9 @@ static int virtnet_probe(struct virtio_device *vdev)
1930 goto free_unregister_netdev; 2281 goto free_unregister_netdev;
1931 } 2282 }
1932 2283
1933 virtnet_set_affinity(vi); 2284 rtnl_lock();
2285 virtnet_set_queues(vi, vi->curr_queue_pairs);
2286 rtnl_unlock();
1934 2287
1935 /* Assume link up if device can't report link status, 2288 /* Assume link up if device can't report link status,
1936 otherwise get link status from config. */ 2289 otherwise get link status from config. */
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 3bca24651dc0..7532646c3b7b 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -366,6 +366,8 @@ static int vrf_finish_output6(struct net *net, struct sock *sk,
366 struct in6_addr *nexthop; 366 struct in6_addr *nexthop;
367 int ret; 367 int ret;
368 368
369 nf_reset(skb);
370
369 skb->protocol = htons(ETH_P_IPV6); 371 skb->protocol = htons(ETH_P_IPV6);
370 skb->dev = dev; 372 skb->dev = dev;
371 373
@@ -547,6 +549,8 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
547 u32 nexthop; 549 u32 nexthop;
548 int ret = -EINVAL; 550 int ret = -EINVAL;
549 551
552 nf_reset(skb);
553
550 /* Be paranoid, rather than too clever. */ 554 /* Be paranoid, rather than too clever. */
551 if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) { 555 if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) {
552 struct sk_buff *skb2; 556 struct sk_buff *skb2;
@@ -849,8 +853,6 @@ static struct sk_buff *vrf_rcv_nfhook(u8 pf, unsigned int hook,
849{ 853{
850 struct net *net = dev_net(dev); 854 struct net *net = dev_net(dev);
851 855
852 nf_reset(skb);
853
854 if (NF_HOOK(pf, hook, net, NULL, skb, dev, NULL, vrf_rcv_finish) < 0) 856 if (NF_HOOK(pf, hook, net, NULL, skb, dev, NULL, vrf_rcv_finish) < 0)
855 skb = NULL; /* kfree_skb(skb) handled by nf code */ 857 skb = NULL; /* kfree_skb(skb) handled by nf code */
856 858
diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
index 5920c996fcdf..ff2e4a5654c7 100644
--- a/drivers/net/wan/lmc/lmc_media.c
+++ b/drivers/net/wan/lmc/lmc_media.c
@@ -95,62 +95,63 @@ static inline void write_av9110_bit (lmc_softc_t *, int);
95static void write_av9110(lmc_softc_t *, u32, u32, u32, u32, u32); 95static void write_av9110(lmc_softc_t *, u32, u32, u32, u32, u32);
96 96
97lmc_media_t lmc_ds3_media = { 97lmc_media_t lmc_ds3_media = {
98 lmc_ds3_init, /* special media init stuff */ 98 .init = lmc_ds3_init, /* special media init stuff */
99 lmc_ds3_default, /* reset to default state */ 99 .defaults = lmc_ds3_default, /* reset to default state */
100 lmc_ds3_set_status, /* reset status to state provided */ 100 .set_status = lmc_ds3_set_status, /* reset status to state provided */
101 lmc_dummy_set_1, /* set clock source */ 101 .set_clock_source = lmc_dummy_set_1, /* set clock source */
102 lmc_dummy_set2_1, /* set line speed */ 102 .set_speed = lmc_dummy_set2_1, /* set line speed */
103 lmc_ds3_set_100ft, /* set cable length */ 103 .set_cable_length = lmc_ds3_set_100ft, /* set cable length */
104 lmc_ds3_set_scram, /* set scrambler */ 104 .set_scrambler = lmc_ds3_set_scram, /* set scrambler */
105 lmc_ds3_get_link_status, /* get link status */ 105 .get_link_status = lmc_ds3_get_link_status, /* get link status */
106 lmc_dummy_set_1, /* set link status */ 106 .set_link_status = lmc_dummy_set_1, /* set link status */
107 lmc_ds3_set_crc_length, /* set CRC length */ 107 .set_crc_length = lmc_ds3_set_crc_length, /* set CRC length */
108 lmc_dummy_set_1, /* set T1 or E1 circuit type */ 108 .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
109 lmc_ds3_watchdog 109 .watchdog = lmc_ds3_watchdog
110}; 110};
111 111
112lmc_media_t lmc_hssi_media = { 112lmc_media_t lmc_hssi_media = {
113 lmc_hssi_init, /* special media init stuff */ 113 .init = lmc_hssi_init, /* special media init stuff */
114 lmc_hssi_default, /* reset to default state */ 114 .defaults = lmc_hssi_default, /* reset to default state */
115 lmc_hssi_set_status, /* reset status to state provided */ 115 .set_status = lmc_hssi_set_status, /* reset status to state provided */
116 lmc_hssi_set_clock, /* set clock source */ 116 .set_clock_source = lmc_hssi_set_clock, /* set clock source */
117 lmc_dummy_set2_1, /* set line speed */ 117 .set_speed = lmc_dummy_set2_1, /* set line speed */
118 lmc_dummy_set_1, /* set cable length */ 118 .set_cable_length = lmc_dummy_set_1, /* set cable length */
119 lmc_dummy_set_1, /* set scrambler */ 119 .set_scrambler = lmc_dummy_set_1, /* set scrambler */
120 lmc_hssi_get_link_status, /* get link status */ 120 .get_link_status = lmc_hssi_get_link_status, /* get link status */
121 lmc_hssi_set_link_status, /* set link status */ 121 .set_link_status = lmc_hssi_set_link_status, /* set link status */
122 lmc_hssi_set_crc_length, /* set CRC length */ 122 .set_crc_length = lmc_hssi_set_crc_length, /* set CRC length */
123 lmc_dummy_set_1, /* set T1 or E1 circuit type */ 123 .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
124 lmc_hssi_watchdog 124 .watchdog = lmc_hssi_watchdog
125}; 125};
126 126
127lmc_media_t lmc_ssi_media = { lmc_ssi_init, /* special media init stuff */ 127lmc_media_t lmc_ssi_media = {
128 lmc_ssi_default, /* reset to default state */ 128 .init = lmc_ssi_init, /* special media init stuff */
129 lmc_ssi_set_status, /* reset status to state provided */ 129 .defaults = lmc_ssi_default, /* reset to default state */
130 lmc_ssi_set_clock, /* set clock source */ 130 .set_status = lmc_ssi_set_status, /* reset status to state provided */
131 lmc_ssi_set_speed, /* set line speed */ 131 .set_clock_source = lmc_ssi_set_clock, /* set clock source */
132 lmc_dummy_set_1, /* set cable length */ 132 .set_speed = lmc_ssi_set_speed, /* set line speed */
133 lmc_dummy_set_1, /* set scrambler */ 133 .set_cable_length = lmc_dummy_set_1, /* set cable length */
134 lmc_ssi_get_link_status, /* get link status */ 134 .set_scrambler = lmc_dummy_set_1, /* set scrambler */
135 lmc_ssi_set_link_status, /* set link status */ 135 .get_link_status = lmc_ssi_get_link_status, /* get link status */
136 lmc_ssi_set_crc_length, /* set CRC length */ 136 .set_link_status = lmc_ssi_set_link_status, /* set link status */
137 lmc_dummy_set_1, /* set T1 or E1 circuit type */ 137 .set_crc_length = lmc_ssi_set_crc_length, /* set CRC length */
138 lmc_ssi_watchdog 138 .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
139 .watchdog = lmc_ssi_watchdog
139}; 140};
140 141
141lmc_media_t lmc_t1_media = { 142lmc_media_t lmc_t1_media = {
142 lmc_t1_init, /* special media init stuff */ 143 .init = lmc_t1_init, /* special media init stuff */
143 lmc_t1_default, /* reset to default state */ 144 .defaults = lmc_t1_default, /* reset to default state */
144 lmc_t1_set_status, /* reset status to state provided */ 145 .set_status = lmc_t1_set_status, /* reset status to state provided */
145 lmc_t1_set_clock, /* set clock source */ 146 .set_clock_source = lmc_t1_set_clock, /* set clock source */
146 lmc_dummy_set2_1, /* set line speed */ 147 .set_speed = lmc_dummy_set2_1, /* set line speed */
147 lmc_dummy_set_1, /* set cable length */ 148 .set_cable_length = lmc_dummy_set_1, /* set cable length */
148 lmc_dummy_set_1, /* set scrambler */ 149 .set_scrambler = lmc_dummy_set_1, /* set scrambler */
149 lmc_t1_get_link_status, /* get link status */ 150 .get_link_status = lmc_t1_get_link_status, /* get link status */
150 lmc_dummy_set_1, /* set link status */ 151 .set_link_status = lmc_dummy_set_1, /* set link status */
151 lmc_t1_set_crc_length, /* set CRC length */ 152 .set_crc_length = lmc_t1_set_crc_length, /* set CRC length */
152 lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */ 153 .set_circuit_type = lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
153 lmc_t1_watchdog 154 .watchdog = lmc_t1_watchdog
154}; 155};
155 156
156static void 157static void
diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
index 7b6e5d168c95..92bc89ae7e20 100644
--- a/include/linux/bpf-cgroup.h
+++ b/include/linux/bpf-cgroup.h
@@ -20,7 +20,7 @@ struct cgroup_bpf {
20 * when this cgroup is accessed. 20 * when this cgroup is accessed.
21 */ 21 */
22 struct bpf_prog *prog[MAX_BPF_ATTACH_TYPE]; 22 struct bpf_prog *prog[MAX_BPF_ATTACH_TYPE];
23 struct bpf_prog *effective[MAX_BPF_ATTACH_TYPE]; 23 struct bpf_prog __rcu *effective[MAX_BPF_ATTACH_TYPE];
24}; 24};
25 25
26void cgroup_bpf_put(struct cgroup *cgrp); 26void cgroup_bpf_put(struct cgroup *cgrp);
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 8796ff03f472..f74ae68086dc 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -216,7 +216,7 @@ u64 bpf_tail_call(u64 ctx, u64 r2, u64 index, u64 r4, u64 r5);
216u64 bpf_get_stackid(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); 216u64 bpf_get_stackid(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
217 217
218bool bpf_prog_array_compatible(struct bpf_array *array, const struct bpf_prog *fp); 218bool bpf_prog_array_compatible(struct bpf_array *array, const struct bpf_prog *fp);
219void bpf_prog_calc_digest(struct bpf_prog *fp); 219int bpf_prog_calc_digest(struct bpf_prog *fp);
220 220
221const struct bpf_func_proto *bpf_get_trace_printk_proto(void); 221const struct bpf_func_proto *bpf_get_trace_printk_proto(void);
222 222
@@ -238,6 +238,8 @@ struct bpf_prog * __must_check bpf_prog_add(struct bpf_prog *prog, int i);
238void bpf_prog_sub(struct bpf_prog *prog, int i); 238void bpf_prog_sub(struct bpf_prog *prog, int i);
239struct bpf_prog * __must_check bpf_prog_inc(struct bpf_prog *prog); 239struct bpf_prog * __must_check bpf_prog_inc(struct bpf_prog *prog);
240void bpf_prog_put(struct bpf_prog *prog); 240void bpf_prog_put(struct bpf_prog *prog);
241int __bpf_prog_charge(struct user_struct *user, u32 pages);
242void __bpf_prog_uncharge(struct user_struct *user, u32 pages);
241 243
242struct bpf_map *bpf_map_get_with_uref(u32 ufd); 244struct bpf_map *bpf_map_get_with_uref(u32 ufd);
243struct bpf_map *__bpf_map_get(struct fd f); 245struct bpf_map *__bpf_map_get(struct fd f);
@@ -318,6 +320,15 @@ static inline struct bpf_prog * __must_check bpf_prog_inc(struct bpf_prog *prog)
318{ 320{
319 return ERR_PTR(-EOPNOTSUPP); 321 return ERR_PTR(-EOPNOTSUPP);
320} 322}
323
324static inline int __bpf_prog_charge(struct user_struct *user, u32 pages)
325{
326 return 0;
327}
328
329static inline void __bpf_prog_uncharge(struct user_struct *user, u32 pages)
330{
331}
321#endif /* CONFIG_BPF_SYSCALL */ 332#endif /* CONFIG_BPF_SYSCALL */
322 333
323/* verifier prototypes for helper functions called from eBPF programs */ 334/* verifier prototypes for helper functions called from eBPF programs */
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 6a1658308612..702314253797 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -57,9 +57,6 @@ struct bpf_prog_aux;
57/* BPF program can access up to 512 bytes of stack space. */ 57/* BPF program can access up to 512 bytes of stack space. */
58#define MAX_BPF_STACK 512 58#define MAX_BPF_STACK 512
59 59
60/* Maximum BPF program size in bytes. */
61#define MAX_BPF_SIZE (BPF_MAXINSNS * sizeof(struct bpf_insn))
62
63/* Helper macros for filter block array initializers. */ 60/* Helper macros for filter block array initializers. */
64 61
65/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ 62/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */
@@ -517,6 +514,17 @@ static __always_inline u32 bpf_prog_run_xdp(const struct bpf_prog *prog,
517 return BPF_PROG_RUN(prog, xdp); 514 return BPF_PROG_RUN(prog, xdp);
518} 515}
519 516
517static inline u32 bpf_prog_insn_size(const struct bpf_prog *prog)
518{
519 return prog->len * sizeof(struct bpf_insn);
520}
521
522static inline u32 bpf_prog_digest_scratch_size(const struct bpf_prog *prog)
523{
524 return round_up(bpf_prog_insn_size(prog) +
525 sizeof(__be64) + 1, SHA_MESSAGE_BYTES);
526}
527
520static inline unsigned int bpf_prog_size(unsigned int proglen) 528static inline unsigned int bpf_prog_size(unsigned int proglen)
521{ 529{
522 return max(sizeof(struct bpf_prog), 530 return max(sizeof(struct bpf_prog),
@@ -602,6 +610,7 @@ bool bpf_helper_changes_pkt_data(void *func);
602struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off, 610struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off,
603 const struct bpf_insn *patch, u32 len); 611 const struct bpf_insn *patch, u32 len);
604void bpf_warn_invalid_xdp_action(u32 act); 612void bpf_warn_invalid_xdp_action(u32 act);
613void bpf_warn_invalid_xdp_buffer(void);
605 614
606#ifdef CONFIG_BPF_JIT 615#ifdef CONFIG_BPF_JIT
607extern int bpf_jit_enable; 616extern int bpf_jit_enable;
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index a426cb55dc43..ed30d5d713e3 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -32,6 +32,7 @@
32#define STORE_QUEUE_MINOR 155 /* unused */ 32#define STORE_QUEUE_MINOR 155 /* unused */
33#define I2O_MINOR 166 33#define I2O_MINOR 166
34#define MICROCODE_MINOR 184 34#define MICROCODE_MINOR 184
35#define IRNET_MINOR 187
35#define VFIO_MINOR 196 36#define VFIO_MINOR 196
36#define TUN_MINOR 200 37#define TUN_MINOR 200
37#define CUSE_MINOR 203 38#define CUSE_MINOR 203
diff --git a/include/linux/platform_data/macb.h b/include/linux/platform_data/macb.h
index 21b15f6fee25..7815d50c26ff 100644
--- a/include/linux/platform_data/macb.h
+++ b/include/linux/platform_data/macb.h
@@ -8,6 +8,8 @@
8#ifndef __MACB_PDATA_H__ 8#ifndef __MACB_PDATA_H__
9#define __MACB_PDATA_H__ 9#define __MACB_PDATA_H__
10 10
11#include <linux/clk.h>
12
11/** 13/**
12 * struct macb_platform_data - platform data for MACB Ethernet 14 * struct macb_platform_data - platform data for MACB Ethernet
13 * @phy_mask: phy mask passed when register the MDIO bus 15 * @phy_mask: phy mask passed when register the MDIO bus
@@ -15,12 +17,16 @@
15 * @phy_irq_pin: PHY IRQ 17 * @phy_irq_pin: PHY IRQ
16 * @is_rmii: using RMII interface? 18 * @is_rmii: using RMII interface?
17 * @rev_eth_addr: reverse Ethernet address byte order 19 * @rev_eth_addr: reverse Ethernet address byte order
20 * @pclk: platform clock
21 * @hclk: AHB clock
18 */ 22 */
19struct macb_platform_data { 23struct macb_platform_data {
20 u32 phy_mask; 24 u32 phy_mask;
21 int phy_irq_pin; 25 int phy_irq_pin;
22 u8 is_rmii; 26 u8 is_rmii;
23 u8 rev_eth_addr; 27 u8 rev_eth_addr;
28 struct clk *pclk;
29 struct clk *hclk;
24}; 30};
25 31
26#endif /* __MACB_PDATA_H__ */ 32#endif /* __MACB_PDATA_H__ */
diff --git a/include/net/inet6_connection_sock.h b/include/net/inet6_connection_sock.h
index 954ad6bfb56a..3212b39b5bfc 100644
--- a/include/net/inet6_connection_sock.h
+++ b/include/net/inet6_connection_sock.h
@@ -22,7 +22,8 @@ struct sock;
22struct sockaddr; 22struct sockaddr;
23 23
24int inet6_csk_bind_conflict(const struct sock *sk, 24int inet6_csk_bind_conflict(const struct sock *sk,
25 const struct inet_bind_bucket *tb, bool relax); 25 const struct inet_bind_bucket *tb, bool relax,
26 bool soreuseport_ok);
26 27
27struct dst_entry *inet6_csk_route_req(const struct sock *sk, struct flowi6 *fl6, 28struct dst_entry *inet6_csk_route_req(const struct sock *sk, struct flowi6 *fl6,
28 const struct request_sock *req, u8 proto); 29 const struct request_sock *req, u8 proto);
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 146054ceea8e..85ee3879499e 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -63,7 +63,8 @@ struct inet_connection_sock_af_ops {
63#endif 63#endif
64 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *); 64 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
65 int (*bind_conflict)(const struct sock *sk, 65 int (*bind_conflict)(const struct sock *sk,
66 const struct inet_bind_bucket *tb, bool relax); 66 const struct inet_bind_bucket *tb,
67 bool relax, bool soreuseport_ok);
67 void (*mtu_reduced)(struct sock *sk); 68 void (*mtu_reduced)(struct sock *sk);
68}; 69};
69 70
@@ -261,7 +262,8 @@ inet_csk_rto_backoff(const struct inet_connection_sock *icsk,
261struct sock *inet_csk_accept(struct sock *sk, int flags, int *err); 262struct sock *inet_csk_accept(struct sock *sk, int flags, int *err);
262 263
263int inet_csk_bind_conflict(const struct sock *sk, 264int inet_csk_bind_conflict(const struct sock *sk,
264 const struct inet_bind_bucket *tb, bool relax); 265 const struct inet_bind_bucket *tb, bool relax,
266 bool soreuseport_ok);
265int inet_csk_get_port(struct sock *sk, unsigned short snum); 267int inet_csk_get_port(struct sock *sk, unsigned short snum);
266 268
267struct dst_entry *inet_csk_route_req(const struct sock *sk, struct flowi4 *fl4, 269struct dst_entry *inet_csk_route_req(const struct sock *sk, struct flowi4 *fl4,
diff --git a/include/net/netlink.h b/include/net/netlink.h
index dd657a33f8c3..d3938f11ae52 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -698,7 +698,8 @@ static inline int nla_len(const struct nlattr *nla)
698 */ 698 */
699static inline int nla_ok(const struct nlattr *nla, int remaining) 699static inline int nla_ok(const struct nlattr *nla, int remaining)
700{ 700{
701 return nla->nla_len >= sizeof(*nla) && 701 return remaining >= (int) sizeof(*nla) &&
702 nla->nla_len >= sizeof(*nla) &&
702 nla->nla_len <= remaining; 703 nla->nla_len <= remaining;
703} 704}
704 705
diff --git a/init/Kconfig b/init/Kconfig
index aafafeb0c117..223b734abccd 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1156,7 +1156,8 @@ config CGROUP_PERF
1156 1156
1157config CGROUP_BPF 1157config CGROUP_BPF
1158 bool "Support for eBPF programs attached to cgroups" 1158 bool "Support for eBPF programs attached to cgroups"
1159 depends on BPF_SYSCALL && SOCK_CGROUP_DATA 1159 depends on BPF_SYSCALL
1160 select SOCK_CGROUP_DATA
1160 help 1161 help
1161 Allow attaching eBPF programs to a cgroup using the bpf(2) 1162 Allow attaching eBPF programs to a cgroup using the bpf(2)
1162 syscall command BPF_PROG_ATTACH. 1163 syscall command BPF_PROG_ATTACH.
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 83e0d153b0b4..1eb4f1303756 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -105,19 +105,29 @@ struct bpf_prog *bpf_prog_realloc(struct bpf_prog *fp_old, unsigned int size,
105 gfp_t gfp_flags = GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO | 105 gfp_t gfp_flags = GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO |
106 gfp_extra_flags; 106 gfp_extra_flags;
107 struct bpf_prog *fp; 107 struct bpf_prog *fp;
108 u32 pages, delta;
109 int ret;
108 110
109 BUG_ON(fp_old == NULL); 111 BUG_ON(fp_old == NULL);
110 112
111 size = round_up(size, PAGE_SIZE); 113 size = round_up(size, PAGE_SIZE);
112 if (size <= fp_old->pages * PAGE_SIZE) 114 pages = size / PAGE_SIZE;
115 if (pages <= fp_old->pages)
113 return fp_old; 116 return fp_old;
114 117
118 delta = pages - fp_old->pages;
119 ret = __bpf_prog_charge(fp_old->aux->user, delta);
120 if (ret)
121 return NULL;
122
115 fp = __vmalloc(size, gfp_flags, PAGE_KERNEL); 123 fp = __vmalloc(size, gfp_flags, PAGE_KERNEL);
116 if (fp != NULL) { 124 if (fp == NULL) {
125 __bpf_prog_uncharge(fp_old->aux->user, delta);
126 } else {
117 kmemcheck_annotate_bitfield(fp, meta); 127 kmemcheck_annotate_bitfield(fp, meta);
118 128
119 memcpy(fp, fp_old, fp_old->pages * PAGE_SIZE); 129 memcpy(fp, fp_old, fp_old->pages * PAGE_SIZE);
120 fp->pages = size / PAGE_SIZE; 130 fp->pages = pages;
121 fp->aux->prog = fp; 131 fp->aux->prog = fp;
122 132
123 /* We keep fp->aux from fp_old around in the new 133 /* We keep fp->aux from fp_old around in the new
@@ -136,28 +146,29 @@ void __bpf_prog_free(struct bpf_prog *fp)
136 vfree(fp); 146 vfree(fp);
137} 147}
138 148
139#define SHA_BPF_RAW_SIZE \ 149int bpf_prog_calc_digest(struct bpf_prog *fp)
140 round_up(MAX_BPF_SIZE + sizeof(__be64) + 1, SHA_MESSAGE_BYTES)
141
142/* Called under verifier mutex. */
143void bpf_prog_calc_digest(struct bpf_prog *fp)
144{ 150{
145 const u32 bits_offset = SHA_MESSAGE_BYTES - sizeof(__be64); 151 const u32 bits_offset = SHA_MESSAGE_BYTES - sizeof(__be64);
146 static u32 ws[SHA_WORKSPACE_WORDS]; 152 u32 raw_size = bpf_prog_digest_scratch_size(fp);
147 static u8 raw[SHA_BPF_RAW_SIZE]; 153 u32 ws[SHA_WORKSPACE_WORDS];
148 struct bpf_insn *dst = (void *)raw;
149 u32 i, bsize, psize, blocks; 154 u32 i, bsize, psize, blocks;
155 struct bpf_insn *dst;
150 bool was_ld_map; 156 bool was_ld_map;
151 u8 *todo = raw; 157 u8 *raw, *todo;
152 __be32 *result; 158 __be32 *result;
153 __be64 *bits; 159 __be64 *bits;
154 160
161 raw = vmalloc(raw_size);
162 if (!raw)
163 return -ENOMEM;
164
155 sha_init(fp->digest); 165 sha_init(fp->digest);
156 memset(ws, 0, sizeof(ws)); 166 memset(ws, 0, sizeof(ws));
157 167
158 /* We need to take out the map fd for the digest calculation 168 /* We need to take out the map fd for the digest calculation
159 * since they are unstable from user space side. 169 * since they are unstable from user space side.
160 */ 170 */
171 dst = (void *)raw;
161 for (i = 0, was_ld_map = false; i < fp->len; i++) { 172 for (i = 0, was_ld_map = false; i < fp->len; i++) {
162 dst[i] = fp->insnsi[i]; 173 dst[i] = fp->insnsi[i];
163 if (!was_ld_map && 174 if (!was_ld_map &&
@@ -177,12 +188,13 @@ void bpf_prog_calc_digest(struct bpf_prog *fp)
177 } 188 }
178 } 189 }
179 190
180 psize = fp->len * sizeof(struct bpf_insn); 191 psize = bpf_prog_insn_size(fp);
181 memset(&raw[psize], 0, sizeof(raw) - psize); 192 memset(&raw[psize], 0, raw_size - psize);
182 raw[psize++] = 0x80; 193 raw[psize++] = 0x80;
183 194
184 bsize = round_up(psize, SHA_MESSAGE_BYTES); 195 bsize = round_up(psize, SHA_MESSAGE_BYTES);
185 blocks = bsize / SHA_MESSAGE_BYTES; 196 blocks = bsize / SHA_MESSAGE_BYTES;
197 todo = raw;
186 if (bsize - psize >= sizeof(__be64)) { 198 if (bsize - psize >= sizeof(__be64)) {
187 bits = (__be64 *)(todo + bsize - sizeof(__be64)); 199 bits = (__be64 *)(todo + bsize - sizeof(__be64));
188 } else { 200 } else {
@@ -199,6 +211,9 @@ void bpf_prog_calc_digest(struct bpf_prog *fp)
199 result = (__force __be32 *)fp->digest; 211 result = (__force __be32 *)fp->digest;
200 for (i = 0; i < SHA_DIGEST_WORDS; i++) 212 for (i = 0; i < SHA_DIGEST_WORDS; i++)
201 result[i] = cpu_to_be32(fp->digest[i]); 213 result[i] = cpu_to_be32(fp->digest[i]);
214
215 vfree(raw);
216 return 0;
202} 217}
203 218
204static bool bpf_is_jmp_and_has_target(const struct bpf_insn *insn) 219static bool bpf_is_jmp_and_has_target(const struct bpf_insn *insn)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 4819ec9d95f6..e89acea22ecf 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -615,19 +615,39 @@ static void free_used_maps(struct bpf_prog_aux *aux)
615 kfree(aux->used_maps); 615 kfree(aux->used_maps);
616} 616}
617 617
618int __bpf_prog_charge(struct user_struct *user, u32 pages)
619{
620 unsigned long memlock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
621 unsigned long user_bufs;
622
623 if (user) {
624 user_bufs = atomic_long_add_return(pages, &user->locked_vm);
625 if (user_bufs > memlock_limit) {
626 atomic_long_sub(pages, &user->locked_vm);
627 return -EPERM;
628 }
629 }
630
631 return 0;
632}
633
634void __bpf_prog_uncharge(struct user_struct *user, u32 pages)
635{
636 if (user)
637 atomic_long_sub(pages, &user->locked_vm);
638}
639
618static int bpf_prog_charge_memlock(struct bpf_prog *prog) 640static int bpf_prog_charge_memlock(struct bpf_prog *prog)
619{ 641{
620 struct user_struct *user = get_current_user(); 642 struct user_struct *user = get_current_user();
621 unsigned long memlock_limit; 643 int ret;
622
623 memlock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
624 644
625 atomic_long_add(prog->pages, &user->locked_vm); 645 ret = __bpf_prog_charge(user, prog->pages);
626 if (atomic_long_read(&user->locked_vm) > memlock_limit) { 646 if (ret) {
627 atomic_long_sub(prog->pages, &user->locked_vm);
628 free_uid(user); 647 free_uid(user);
629 return -EPERM; 648 return ret;
630 } 649 }
650
631 prog->aux->user = user; 651 prog->aux->user = user;
632 return 0; 652 return 0;
633} 653}
@@ -636,7 +656,7 @@ static void bpf_prog_uncharge_memlock(struct bpf_prog *prog)
636{ 656{
637 struct user_struct *user = prog->aux->user; 657 struct user_struct *user = prog->aux->user;
638 658
639 atomic_long_sub(prog->pages, &user->locked_vm); 659 __bpf_prog_uncharge(user, prog->pages);
640 free_uid(user); 660 free_uid(user);
641} 661}
642 662
@@ -811,7 +831,7 @@ static int bpf_prog_load(union bpf_attr *attr)
811 831
812 err = -EFAULT; 832 err = -EFAULT;
813 if (copy_from_user(prog->insns, u64_to_user_ptr(attr->insns), 833 if (copy_from_user(prog->insns, u64_to_user_ptr(attr->insns),
814 prog->len * sizeof(struct bpf_insn)) != 0) 834 bpf_prog_insn_size(prog)) != 0)
815 goto free_prog; 835 goto free_prog;
816 836
817 prog->orig_prog = NULL; 837 prog->orig_prog = NULL;
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index d28f9a3380a9..83ed2f8f6f22 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -462,14 +462,19 @@ static void init_reg_state(struct bpf_reg_state *regs)
462 regs[BPF_REG_1].type = PTR_TO_CTX; 462 regs[BPF_REG_1].type = PTR_TO_CTX;
463} 463}
464 464
465static void mark_reg_unknown_value(struct bpf_reg_state *regs, u32 regno) 465static void __mark_reg_unknown_value(struct bpf_reg_state *regs, u32 regno)
466{ 466{
467 BUG_ON(regno >= MAX_BPF_REG);
468 regs[regno].type = UNKNOWN_VALUE; 467 regs[regno].type = UNKNOWN_VALUE;
469 regs[regno].id = 0; 468 regs[regno].id = 0;
470 regs[regno].imm = 0; 469 regs[regno].imm = 0;
471} 470}
472 471
472static void mark_reg_unknown_value(struct bpf_reg_state *regs, u32 regno)
473{
474 BUG_ON(regno >= MAX_BPF_REG);
475 __mark_reg_unknown_value(regs, regno);
476}
477
473static void reset_reg_range_values(struct bpf_reg_state *regs, u32 regno) 478static void reset_reg_range_values(struct bpf_reg_state *regs, u32 regno)
474{ 479{
475 regs[regno].min_value = BPF_REGISTER_MIN_RANGE; 480 regs[regno].min_value = BPF_REGISTER_MIN_RANGE;
@@ -1970,8 +1975,13 @@ static void mark_map_reg(struct bpf_reg_state *regs, u32 regno, u32 id,
1970 1975
1971 if (reg->type == PTR_TO_MAP_VALUE_OR_NULL && reg->id == id) { 1976 if (reg->type == PTR_TO_MAP_VALUE_OR_NULL && reg->id == id) {
1972 reg->type = type; 1977 reg->type = type;
1978 /* We don't need id from this point onwards anymore, thus we
1979 * should better reset it, so that state pruning has chances
1980 * to take effect.
1981 */
1982 reg->id = 0;
1973 if (type == UNKNOWN_VALUE) 1983 if (type == UNKNOWN_VALUE)
1974 mark_reg_unknown_value(regs, regno); 1984 __mark_reg_unknown_value(regs, regno);
1975 } 1985 }
1976} 1986}
1977 1987
@@ -1982,16 +1992,16 @@ static void mark_map_regs(struct bpf_verifier_state *state, u32 regno,
1982 enum bpf_reg_type type) 1992 enum bpf_reg_type type)
1983{ 1993{
1984 struct bpf_reg_state *regs = state->regs; 1994 struct bpf_reg_state *regs = state->regs;
1995 u32 id = regs[regno].id;
1985 int i; 1996 int i;
1986 1997
1987 for (i = 0; i < MAX_BPF_REG; i++) 1998 for (i = 0; i < MAX_BPF_REG; i++)
1988 mark_map_reg(regs, i, regs[regno].id, type); 1999 mark_map_reg(regs, i, id, type);
1989 2000
1990 for (i = 0; i < MAX_BPF_STACK; i += BPF_REG_SIZE) { 2001 for (i = 0; i < MAX_BPF_STACK; i += BPF_REG_SIZE) {
1991 if (state->stack_slot_type[i] != STACK_SPILL) 2002 if (state->stack_slot_type[i] != STACK_SPILL)
1992 continue; 2003 continue;
1993 mark_map_reg(state->spilled_regs, i / BPF_REG_SIZE, 2004 mark_map_reg(state->spilled_regs, i / BPF_REG_SIZE, id, type);
1994 regs[regno].id, type);
1995 } 2005 }
1996} 2006}
1997 2007
@@ -2926,6 +2936,10 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
2926 int insn_cnt = env->prog->len; 2936 int insn_cnt = env->prog->len;
2927 int i, j, err; 2937 int i, j, err;
2928 2938
2939 err = bpf_prog_calc_digest(env->prog);
2940 if (err)
2941 return err;
2942
2929 for (i = 0; i < insn_cnt; i++, insn++) { 2943 for (i = 0; i < insn_cnt; i++, insn++) {
2930 if (BPF_CLASS(insn->code) == BPF_LDX && 2944 if (BPF_CLASS(insn->code) == BPF_LDX &&
2931 (BPF_MODE(insn->code) != BPF_MEM || insn->imm != 0)) { 2945 (BPF_MODE(insn->code) != BPF_MEM || insn->imm != 0)) {
@@ -3173,8 +3187,6 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr)
3173 log_level = 0; 3187 log_level = 0;
3174 } 3188 }
3175 3189
3176 bpf_prog_calc_digest(env->prog);
3177
3178 ret = replace_map_fd_with_map_ptr(env); 3190 ret = replace_map_fd_with_map_ptr(env);
3179 if (ret < 0) 3191 if (ret < 0)
3180 goto skip_full_check; 3192 goto skip_full_check;
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 779b3fa6052d..019557d0a11d 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -111,9 +111,9 @@ static inline void lec_arp_put(struct lec_arp_table *entry)
111} 111}
112 112
113static struct lane2_ops lane2_ops = { 113static struct lane2_ops lane2_ops = {
114 lane2_resolve, /* resolve, spec 3.1.3 */ 114 .resolve = lane2_resolve, /* spec 3.1.3 */
115 lane2_associate_req, /* associate_req, spec 3.1.4 */ 115 .associate_req = lane2_associate_req, /* spec 3.1.4 */
116 NULL /* associate indicator, spec 3.1.5 */ 116 .associate_indicator = NULL /* spec 3.1.5 */
117}; 117};
118 118
119static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 119static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c
index 9e60e74c807d..a89fdebeffda 100644
--- a/net/atm/mpoa_caches.c
+++ b/net/atm/mpoa_caches.c
@@ -535,33 +535,32 @@ static void eg_destroy_cache(struct mpoa_client *mpc)
535 535
536 536
537static const struct in_cache_ops ingress_ops = { 537static const struct in_cache_ops ingress_ops = {
538 in_cache_add_entry, /* add_entry */ 538 .add_entry = in_cache_add_entry,
539 in_cache_get, /* get */ 539 .get = in_cache_get,
540 in_cache_get_with_mask, /* get_with_mask */ 540 .get_with_mask = in_cache_get_with_mask,
541 in_cache_get_by_vcc, /* get_by_vcc */ 541 .get_by_vcc = in_cache_get_by_vcc,
542 in_cache_put, /* put */ 542 .put = in_cache_put,
543 in_cache_remove_entry, /* remove_entry */ 543 .remove_entry = in_cache_remove_entry,
544 cache_hit, /* cache_hit */ 544 .cache_hit = cache_hit,
545 clear_count_and_expired, /* clear_count */ 545 .clear_count = clear_count_and_expired,
546 check_resolving_entries, /* check_resolving */ 546 .check_resolving = check_resolving_entries,
547 refresh_entries, /* refresh */ 547 .refresh = refresh_entries,
548 in_destroy_cache /* destroy_cache */ 548 .destroy_cache = in_destroy_cache
549}; 549};
550 550
551static const struct eg_cache_ops egress_ops = { 551static const struct eg_cache_ops egress_ops = {
552 eg_cache_add_entry, /* add_entry */ 552 .add_entry = eg_cache_add_entry,
553 eg_cache_get_by_cache_id, /* get_by_cache_id */ 553 .get_by_cache_id = eg_cache_get_by_cache_id,
554 eg_cache_get_by_tag, /* get_by_tag */ 554 .get_by_tag = eg_cache_get_by_tag,
555 eg_cache_get_by_vcc, /* get_by_vcc */ 555 .get_by_vcc = eg_cache_get_by_vcc,
556 eg_cache_get_by_src_ip, /* get_by_src_ip */ 556 .get_by_src_ip = eg_cache_get_by_src_ip,
557 eg_cache_put, /* put */ 557 .put = eg_cache_put,
558 eg_cache_remove_entry, /* remove_entry */ 558 .remove_entry = eg_cache_remove_entry,
559 update_eg_cache_entry, /* update */ 559 .update = update_eg_cache_entry,
560 clear_expired, /* clear_expired */ 560 .clear_expired = clear_expired,
561 eg_destroy_cache /* destroy_cache */ 561 .destroy_cache = eg_destroy_cache
562}; 562};
563 563
564
565void atm_mpoa_init_cache(struct mpoa_client *mpc) 564void atm_mpoa_init_cache(struct mpoa_client *mpc)
566{ 565{
567 mpc->in_ops = &ingress_ops; 566 mpc->in_ops = &ingress_ops;
diff --git a/net/core/filter.c b/net/core/filter.c
index b1461708a977..7190bd648154 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2972,6 +2972,12 @@ void bpf_warn_invalid_xdp_action(u32 act)
2972} 2972}
2973EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_action); 2973EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_action);
2974 2974
2975void bpf_warn_invalid_xdp_buffer(void)
2976{
2977 WARN_ONCE(1, "Illegal XDP buffer encountered, expect throughput degradation\n");
2978}
2979EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_buffer);
2980
2975static u32 sk_filter_convert_ctx_access(enum bpf_access_type type, int dst_reg, 2981static u32 sk_filter_convert_ctx_access(enum bpf_access_type type, int dst_reg,
2976 int src_reg, int ctx_off, 2982 int src_reg, int ctx_off,
2977 struct bpf_insn *insn_buf, 2983 struct bpf_insn *insn_buf,
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index b2c26b081134..41f803e35da3 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -201,7 +201,7 @@ static struct dn_dev_sysctl_table {
201 .extra1 = &min_t3, 201 .extra1 = &min_t3,
202 .extra2 = &max_t3 202 .extra2 = &max_t3
203 }, 203 },
204 {0} 204 { }
205 }, 205 },
206}; 206};
207 207
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index d5d3ead0a6c3..19ea045c50ed 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -45,11 +45,12 @@ void inet_get_local_port_range(struct net *net, int *low, int *high)
45EXPORT_SYMBOL(inet_get_local_port_range); 45EXPORT_SYMBOL(inet_get_local_port_range);
46 46
47int inet_csk_bind_conflict(const struct sock *sk, 47int inet_csk_bind_conflict(const struct sock *sk,
48 const struct inet_bind_bucket *tb, bool relax) 48 const struct inet_bind_bucket *tb, bool relax,
49 bool reuseport_ok)
49{ 50{
50 struct sock *sk2; 51 struct sock *sk2;
51 int reuse = sk->sk_reuse; 52 bool reuse = sk->sk_reuse;
52 int reuseport = sk->sk_reuseport; 53 bool reuseport = !!sk->sk_reuseport && reuseport_ok;
53 kuid_t uid = sock_i_uid((struct sock *)sk); 54 kuid_t uid = sock_i_uid((struct sock *)sk);
54 55
55 /* 56 /*
@@ -105,6 +106,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
105 struct inet_bind_bucket *tb; 106 struct inet_bind_bucket *tb;
106 kuid_t uid = sock_i_uid(sk); 107 kuid_t uid = sock_i_uid(sk);
107 u32 remaining, offset; 108 u32 remaining, offset;
109 bool reuseport_ok = !!snum;
108 110
109 if (port) { 111 if (port) {
110have_port: 112have_port:
@@ -165,7 +167,8 @@ other_parity_scan:
165 smallest_size = tb->num_owners; 167 smallest_size = tb->num_owners;
166 smallest_port = port; 168 smallest_port = port;
167 } 169 }
168 if (!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb, false)) 170 if (!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb, false,
171 reuseport_ok))
169 goto tb_found; 172 goto tb_found;
170 goto next_port; 173 goto next_port;
171 } 174 }
@@ -206,13 +209,14 @@ tb_found:
206 sk->sk_reuseport && uid_eq(tb->fastuid, uid))) && 209 sk->sk_reuseport && uid_eq(tb->fastuid, uid))) &&
207 smallest_size == -1) 210 smallest_size == -1)
208 goto success; 211 goto success;
209 if (inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb, true)) { 212 if (inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb, true,
213 reuseport_ok)) {
210 if ((reuse || 214 if ((reuse ||
211 (tb->fastreuseport > 0 && 215 (tb->fastreuseport > 0 &&
212 sk->sk_reuseport && 216 sk->sk_reuseport &&
213 !rcu_access_pointer(sk->sk_reuseport_cb) && 217 !rcu_access_pointer(sk->sk_reuseport_cb) &&
214 uid_eq(tb->fastuid, uid))) && 218 uid_eq(tb->fastuid, uid))) &&
215 smallest_size != -1 && --attempts >= 0) { 219 !snum && smallest_size != -1 && --attempts >= 0) {
216 spin_unlock_bh(&head->lock); 220 spin_unlock_bh(&head->lock);
217 goto again; 221 goto again;
218 } 222 }
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index 1c86c478f578..7396e75e161b 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -29,11 +29,12 @@
29#include <net/sock_reuseport.h> 29#include <net/sock_reuseport.h>
30 30
31int inet6_csk_bind_conflict(const struct sock *sk, 31int inet6_csk_bind_conflict(const struct sock *sk,
32 const struct inet_bind_bucket *tb, bool relax) 32 const struct inet_bind_bucket *tb, bool relax,
33 bool reuseport_ok)
33{ 34{
34 const struct sock *sk2; 35 const struct sock *sk2;
35 int reuse = sk->sk_reuse; 36 bool reuse = !!sk->sk_reuse;
36 int reuseport = sk->sk_reuseport; 37 bool reuseport = !!sk->sk_reuseport && reuseport_ok;
37 kuid_t uid = sock_i_uid((struct sock *)sk); 38 kuid_t uid = sock_i_uid((struct sock *)sk);
38 39
39 /* We must walk the whole port owner list in this case. -DaveM */ 40 /* We must walk the whole port owner list in this case. -DaveM */
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 2413a0637d99..890acace01d0 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2174,6 +2174,8 @@ static int ip6_route_del(struct fib6_config *cfg)
2174 continue; 2174 continue;
2175 if (cfg->fc_metric && cfg->fc_metric != rt->rt6i_metric) 2175 if (cfg->fc_metric && cfg->fc_metric != rt->rt6i_metric)
2176 continue; 2176 continue;
2177 if (cfg->fc_protocol && cfg->fc_protocol != rt->rt6i_protocol)
2178 continue;
2177 dst_hold(&rt->dst); 2179 dst_hold(&rt->dst);
2178 read_unlock_bh(&table->tb6_lock); 2180 read_unlock_bh(&table->tb6_lock);
2179 2181
diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h
index 8d65bb9477fc..c69f0f38f566 100644
--- a/net/irda/irnet/irnet.h
+++ b/net/irda/irnet/irnet.h
@@ -245,7 +245,6 @@
245#include <linux/tty.h> 245#include <linux/tty.h>
246#include <linux/proc_fs.h> 246#include <linux/proc_fs.h>
247#include <linux/netdevice.h> 247#include <linux/netdevice.h>
248#include <linux/miscdevice.h>
249#include <linux/poll.h> 248#include <linux/poll.h>
250#include <linux/capability.h> 249#include <linux/capability.h>
251#include <linux/ctype.h> /* isspace() */ 250#include <linux/ctype.h> /* isspace() */
diff --git a/net/irda/irnet/irnet_ppp.h b/net/irda/irnet/irnet_ppp.h
index 940225866da0..32061442cc8e 100644
--- a/net/irda/irnet/irnet_ppp.h
+++ b/net/irda/irnet/irnet_ppp.h
@@ -15,13 +15,10 @@
15/***************************** INCLUDES *****************************/ 15/***************************** INCLUDES *****************************/
16 16
17#include "irnet.h" /* Module global include */ 17#include "irnet.h" /* Module global include */
18#include <linux/miscdevice.h>
18 19
19/************************ CONSTANTS & MACROS ************************/ 20/************************ CONSTANTS & MACROS ************************/
20 21
21/* /dev/irnet file constants */
22#define IRNET_MAJOR 10 /* Misc range */
23#define IRNET_MINOR 187 /* Official allocation */
24
25/* IrNET control channel stuff */ 22/* IrNET control channel stuff */
26#define IRNET_MAX_COMMAND 256 /* Max length of a command line */ 23#define IRNET_MAX_COMMAND 256 /* Max length of a command line */
27 24
@@ -111,9 +108,9 @@ static const struct file_operations irnet_device_fops =
111/* Structure so that the misc major (drivers/char/misc.c) take care of us... */ 108/* Structure so that the misc major (drivers/char/misc.c) take care of us... */
112static struct miscdevice irnet_misc_device = 109static struct miscdevice irnet_misc_device =
113{ 110{
114 IRNET_MINOR, 111 .minor = IRNET_MINOR,
115 "irnet", 112 .name = "irnet",
116 &irnet_device_fops 113 .fops = &irnet_device_fops
117}; 114};
118 115
119#endif /* IRNET_PPP_H */ 116#endif /* IRNET_PPP_H */
diff --git a/net/irda/irproc.c b/net/irda/irproc.c
index b9ac598e2116..77cfdde9d82f 100644
--- a/net/irda/irproc.c
+++ b/net/irda/irproc.c
@@ -23,7 +23,6 @@
23 * 23 *
24 ********************************************************************/ 24 ********************************************************************/
25 25
26#include <linux/miscdevice.h>
27#include <linux/proc_fs.h> 26#include <linux/proc_fs.h>
28#include <linux/seq_file.h> 27#include <linux/seq_file.h>
29#include <linux/module.h> 28#include <linux/module.h>
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index edd6f2945f69..a98fc2b5e0dc 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -265,7 +265,8 @@ static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,
265 if (uni) { 265 if (uni) {
266 rcu_assign_pointer(sdata->default_unicast_key, key); 266 rcu_assign_pointer(sdata->default_unicast_key, key);
267 ieee80211_check_fast_xmit_iface(sdata); 267 ieee80211_check_fast_xmit_iface(sdata);
268 drv_set_default_unicast_key(sdata->local, sdata, idx); 268 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN)
269 drv_set_default_unicast_key(sdata->local, sdata, idx);
269 } 270 }
270 271
271 if (multi) 272 if (multi)
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index eeab7250f4b9..3e289a64ed43 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2472,7 +2472,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
2472 if (!ifmsh->mshcfg.dot11MeshForwarding) 2472 if (!ifmsh->mshcfg.dot11MeshForwarding)
2473 goto out; 2473 goto out;
2474 2474
2475 fwd_skb = skb_copy(skb, GFP_ATOMIC); 2475 fwd_skb = skb_copy_expand(skb, local->tx_headroom, 0, GFP_ATOMIC);
2476 if (!fwd_skb) { 2476 if (!fwd_skb) {
2477 net_info_ratelimited("%s: failed to clone mesh frame\n", 2477 net_info_ratelimited("%s: failed to clone mesh frame\n",
2478 sdata->name); 2478 sdata->name);
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 1711bae4abf2..b6cfcf038c11 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -1972,6 +1972,7 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u16 rate,
1972 u16 brate; 1972 u16 brate;
1973 unsigned int shift; 1973 unsigned int shift;
1974 1974
1975 rinfo->flags = 0;
1975 sband = local->hw.wiphy->bands[(rate >> 4) & 0xf]; 1976 sband = local->hw.wiphy->bands[(rate >> 4) & 0xf];
1976 brate = sband->bitrates[rate & 0xf].bitrate; 1977 brate = sband->bitrates[rate & 0xf].bitrate;
1977 if (rinfo->bw == RATE_INFO_BW_5) 1978 if (rinfo->bw == RATE_INFO_BW_5)
@@ -1987,14 +1988,15 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u16 rate,
1987 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; 1988 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
1988} 1989}
1989 1990
1990static void sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo) 1991static int sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
1991{ 1992{
1992 u16 rate = ACCESS_ONCE(sta_get_last_rx_stats(sta)->last_rate); 1993 u16 rate = ACCESS_ONCE(sta_get_last_rx_stats(sta)->last_rate);
1993 1994
1994 if (rate == STA_STATS_RATE_INVALID) 1995 if (rate == STA_STATS_RATE_INVALID)
1995 rinfo->flags = 0; 1996 return -EINVAL;
1996 else 1997
1997 sta_stats_decode_rate(sta->local, rate, rinfo); 1998 sta_stats_decode_rate(sta->local, rate, rinfo);
1999 return 0;
1998} 2000}
1999 2001
2000static void sta_set_tidstats(struct sta_info *sta, 2002static void sta_set_tidstats(struct sta_info *sta,
@@ -2199,8 +2201,8 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
2199 } 2201 }
2200 2202
2201 if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_BITRATE))) { 2203 if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_BITRATE))) {
2202 sta_set_rate_info_rx(sta, &sinfo->rxrate); 2204 if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0)
2203 sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE); 2205 sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE);
2204 } 2206 }
2205 2207
2206 sinfo->filled |= BIT(NL80211_STA_INFO_TID_STATS); 2208 sinfo->filled |= BIT(NL80211_STA_INFO_TID_STATS);
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index e040c5140f61..35ac28d0720c 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -252,7 +252,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,
252 offload.cookie = (unsigned long)f; 252 offload.cookie = (unsigned long)f;
253 offload.dissector = dissector; 253 offload.dissector = dissector;
254 offload.mask = mask; 254 offload.mask = mask;
255 offload.key = &f->key; 255 offload.key = &f->mkey;
256 offload.exts = &f->exts; 256 offload.exts = &f->exts;
257 257
258 tc->type = TC_SETUP_CLSFLOWER; 258 tc->type = TC_SETUP_CLSFLOWER;
@@ -509,6 +509,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
509 509
510 if (tb[TCA_FLOWER_KEY_IPV4_SRC] || tb[TCA_FLOWER_KEY_IPV4_DST]) { 510 if (tb[TCA_FLOWER_KEY_IPV4_SRC] || tb[TCA_FLOWER_KEY_IPV4_DST]) {
511 key->control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; 511 key->control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
512 mask->control.addr_type = ~0;
512 fl_set_key_val(tb, &key->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC, 513 fl_set_key_val(tb, &key->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC,
513 &mask->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC_MASK, 514 &mask->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC_MASK,
514 sizeof(key->ipv4.src)); 515 sizeof(key->ipv4.src));
@@ -517,6 +518,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
517 sizeof(key->ipv4.dst)); 518 sizeof(key->ipv4.dst));
518 } else if (tb[TCA_FLOWER_KEY_IPV6_SRC] || tb[TCA_FLOWER_KEY_IPV6_DST]) { 519 } else if (tb[TCA_FLOWER_KEY_IPV6_SRC] || tb[TCA_FLOWER_KEY_IPV6_DST]) {
519 key->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; 520 key->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
521 mask->control.addr_type = ~0;
520 fl_set_key_val(tb, &key->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC, 522 fl_set_key_val(tb, &key->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC,
521 &mask->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC_MASK, 523 &mask->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC_MASK,
522 sizeof(key->ipv6.src)); 524 sizeof(key->ipv6.src));
@@ -571,6 +573,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
571 if (tb[TCA_FLOWER_KEY_ENC_IPV4_SRC] || 573 if (tb[TCA_FLOWER_KEY_ENC_IPV4_SRC] ||
572 tb[TCA_FLOWER_KEY_ENC_IPV4_DST]) { 574 tb[TCA_FLOWER_KEY_ENC_IPV4_DST]) {
573 key->enc_control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; 575 key->enc_control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
576 mask->enc_control.addr_type = ~0;
574 fl_set_key_val(tb, &key->enc_ipv4.src, 577 fl_set_key_val(tb, &key->enc_ipv4.src,
575 TCA_FLOWER_KEY_ENC_IPV4_SRC, 578 TCA_FLOWER_KEY_ENC_IPV4_SRC,
576 &mask->enc_ipv4.src, 579 &mask->enc_ipv4.src,
@@ -586,6 +589,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
586 if (tb[TCA_FLOWER_KEY_ENC_IPV6_SRC] || 589 if (tb[TCA_FLOWER_KEY_ENC_IPV6_SRC] ||
587 tb[TCA_FLOWER_KEY_ENC_IPV6_DST]) { 590 tb[TCA_FLOWER_KEY_ENC_IPV6_DST]) {
588 key->enc_control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; 591 key->enc_control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
592 mask->enc_control.addr_type = ~0;
589 fl_set_key_val(tb, &key->enc_ipv6.src, 593 fl_set_key_val(tb, &key->enc_ipv6.src,
590 TCA_FLOWER_KEY_ENC_IPV6_SRC, 594 TCA_FLOWER_KEY_ENC_IPV6_SRC,
591 &mask->enc_ipv6.src, 595 &mask->enc_ipv6.src,
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 1f03065686fe..410ddc1e3443 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -331,7 +331,9 @@ struct sctp_association *sctp_endpoint_lookup_assoc(
331 * on this endpoint. 331 * on this endpoint.
332 */ 332 */
333 if (!ep->base.bind_addr.port) 333 if (!ep->base.bind_addr.port)
334 goto out; 334 return NULL;
335
336 rcu_read_lock();
335 t = sctp_epaddr_lookup_transport(ep, paddr); 337 t = sctp_epaddr_lookup_transport(ep, paddr);
336 if (!t) 338 if (!t)
337 goto out; 339 goto out;
@@ -339,6 +341,7 @@ struct sctp_association *sctp_endpoint_lookup_assoc(
339 *transport = t; 341 *transport = t;
340 asoc = t->asoc; 342 asoc = t->asoc;
341out: 343out:
344 rcu_read_unlock();
342 return asoc; 345 return asoc;
343} 346}
344 347
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index d5f4b4a8369b..318c6786d653 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4472,18 +4472,17 @@ int sctp_transport_lookup_process(int (*cb)(struct sctp_transport *, void *),
4472 const union sctp_addr *paddr, void *p) 4472 const union sctp_addr *paddr, void *p)
4473{ 4473{
4474 struct sctp_transport *transport; 4474 struct sctp_transport *transport;
4475 int err = -ENOENT; 4475 int err;
4476 4476
4477 rcu_read_lock(); 4477 rcu_read_lock();
4478 transport = sctp_addrs_lookup_transport(net, laddr, paddr); 4478 transport = sctp_addrs_lookup_transport(net, laddr, paddr);
4479 rcu_read_unlock();
4479 if (!transport) 4480 if (!transport)
4480 goto out; 4481 return -ENOENT;
4481 4482
4482 rcu_read_unlock();
4483 err = cb(transport, p); 4483 err = cb(transport, p);
4484 sctp_transport_put(transport); 4484 sctp_transport_put(transport);
4485 4485
4486out:
4487 return err; 4486 return err;
4488} 4487}
4489EXPORT_SYMBOL_GPL(sctp_transport_lookup_process); 4488EXPORT_SYMBOL_GPL(sctp_transport_lookup_process);
diff --git a/net/vmw_vsock/vmci_transport_notify.c b/net/vmw_vsock/vmci_transport_notify.c
index fd8cf0214d51..1406db4d97d1 100644
--- a/net/vmw_vsock/vmci_transport_notify.c
+++ b/net/vmw_vsock/vmci_transport_notify.c
@@ -662,19 +662,19 @@ static void vmci_transport_notify_pkt_process_negotiate(struct sock *sk)
662 662
663/* Socket control packet based operations. */ 663/* Socket control packet based operations. */
664const struct vmci_transport_notify_ops vmci_transport_notify_pkt_ops = { 664const struct vmci_transport_notify_ops vmci_transport_notify_pkt_ops = {
665 vmci_transport_notify_pkt_socket_init, 665 .socket_init = vmci_transport_notify_pkt_socket_init,
666 vmci_transport_notify_pkt_socket_destruct, 666 .socket_destruct = vmci_transport_notify_pkt_socket_destruct,
667 vmci_transport_notify_pkt_poll_in, 667 .poll_in = vmci_transport_notify_pkt_poll_in,
668 vmci_transport_notify_pkt_poll_out, 668 .poll_out = vmci_transport_notify_pkt_poll_out,
669 vmci_transport_notify_pkt_handle_pkt, 669 .handle_notify_pkt = vmci_transport_notify_pkt_handle_pkt,
670 vmci_transport_notify_pkt_recv_init, 670 .recv_init = vmci_transport_notify_pkt_recv_init,
671 vmci_transport_notify_pkt_recv_pre_block, 671 .recv_pre_block = vmci_transport_notify_pkt_recv_pre_block,
672 vmci_transport_notify_pkt_recv_pre_dequeue, 672 .recv_pre_dequeue = vmci_transport_notify_pkt_recv_pre_dequeue,
673 vmci_transport_notify_pkt_recv_post_dequeue, 673 .recv_post_dequeue = vmci_transport_notify_pkt_recv_post_dequeue,
674 vmci_transport_notify_pkt_send_init, 674 .send_init = vmci_transport_notify_pkt_send_init,
675 vmci_transport_notify_pkt_send_pre_block, 675 .send_pre_block = vmci_transport_notify_pkt_send_pre_block,
676 vmci_transport_notify_pkt_send_pre_enqueue, 676 .send_pre_enqueue = vmci_transport_notify_pkt_send_pre_enqueue,
677 vmci_transport_notify_pkt_send_post_enqueue, 677 .send_post_enqueue = vmci_transport_notify_pkt_send_post_enqueue,
678 vmci_transport_notify_pkt_process_request, 678 .process_request = vmci_transport_notify_pkt_process_request,
679 vmci_transport_notify_pkt_process_negotiate, 679 .process_negotiate = vmci_transport_notify_pkt_process_negotiate,
680}; 680};
diff --git a/net/vmw_vsock/vmci_transport_notify_qstate.c b/net/vmw_vsock/vmci_transport_notify_qstate.c
index 21e591dafb03..f3a0afc46208 100644
--- a/net/vmw_vsock/vmci_transport_notify_qstate.c
+++ b/net/vmw_vsock/vmci_transport_notify_qstate.c
@@ -420,19 +420,19 @@ vmci_transport_notify_pkt_send_pre_enqueue(
420 420
421/* Socket always on control packet based operations. */ 421/* Socket always on control packet based operations. */
422const struct vmci_transport_notify_ops vmci_transport_notify_pkt_q_state_ops = { 422const struct vmci_transport_notify_ops vmci_transport_notify_pkt_q_state_ops = {
423 vmci_transport_notify_pkt_socket_init, 423 .socket_init = vmci_transport_notify_pkt_socket_init,
424 vmci_transport_notify_pkt_socket_destruct, 424 .socket_destruct = vmci_transport_notify_pkt_socket_destruct,
425 vmci_transport_notify_pkt_poll_in, 425 .poll_in = vmci_transport_notify_pkt_poll_in,
426 vmci_transport_notify_pkt_poll_out, 426 .poll_out = vmci_transport_notify_pkt_poll_out,
427 vmci_transport_notify_pkt_handle_pkt, 427 .handle_notify_pkt = vmci_transport_notify_pkt_handle_pkt,
428 vmci_transport_notify_pkt_recv_init, 428 .recv_init = vmci_transport_notify_pkt_recv_init,
429 vmci_transport_notify_pkt_recv_pre_block, 429 .recv_pre_block = vmci_transport_notify_pkt_recv_pre_block,
430 vmci_transport_notify_pkt_recv_pre_dequeue, 430 .recv_pre_dequeue = vmci_transport_notify_pkt_recv_pre_dequeue,
431 vmci_transport_notify_pkt_recv_post_dequeue, 431 .recv_post_dequeue = vmci_transport_notify_pkt_recv_post_dequeue,
432 vmci_transport_notify_pkt_send_init, 432 .send_init = vmci_transport_notify_pkt_send_init,
433 vmci_transport_notify_pkt_send_pre_block, 433 .send_pre_block = vmci_transport_notify_pkt_send_pre_block,
434 vmci_transport_notify_pkt_send_pre_enqueue, 434 .send_pre_enqueue = vmci_transport_notify_pkt_send_pre_enqueue,
435 vmci_transport_notify_pkt_send_post_enqueue, 435 .send_post_enqueue = vmci_transport_notify_pkt_send_post_enqueue,
436 vmci_transport_notify_pkt_process_request, 436 .process_request = vmci_transport_notify_pkt_process_request,
437 vmci_transport_notify_pkt_process_negotiate, 437 .process_negotiate = vmci_transport_notify_pkt_process_negotiate,
438}; 438};
diff --git a/net/x25/sysctl_net_x25.c b/net/x25/sysctl_net_x25.c
index 43239527a205..a06dfe143c67 100644
--- a/net/x25/sysctl_net_x25.c
+++ b/net/x25/sysctl_net_x25.c
@@ -70,7 +70,7 @@ static struct ctl_table x25_table[] = {
70 .mode = 0644, 70 .mode = 0644,
71 .proc_handler = proc_dointvec, 71 .proc_handler = proc_dointvec,
72 }, 72 },
73 { 0, }, 73 { },
74}; 74};
75 75
76void __init x25_register_sysctl(void) 76void __init x25_register_sysctl(void)
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 0103bf2e0c0d..853d7e43434a 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -1059,7 +1059,7 @@ static struct bpf_test tests[] = {
1059 BPF_MOV64_IMM(BPF_REG_0, 0), 1059 BPF_MOV64_IMM(BPF_REG_0, 0),
1060 BPF_EXIT_INSN(), 1060 BPF_EXIT_INSN(),
1061 }, 1061 },
1062 .errstr_unpriv = "unknown func 6", 1062 .errstr_unpriv = "unknown func bpf_trace_printk#6",
1063 .result_unpriv = REJECT, 1063 .result_unpriv = REJECT,
1064 .result = ACCEPT, 1064 .result = ACCEPT,
1065 }, 1065 },
@@ -2661,6 +2661,34 @@ static struct bpf_test tests[] = {
2661 .prog_type = BPF_PROG_TYPE_SCHED_CLS 2661 .prog_type = BPF_PROG_TYPE_SCHED_CLS
2662 }, 2662 },
2663 { 2663 {
2664 "multiple registers share map_lookup_elem bad reg type",
2665 .insns = {
2666 BPF_MOV64_IMM(BPF_REG_1, 10),
2667 BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_1, -8),
2668 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
2669 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
2670 BPF_LD_MAP_FD(BPF_REG_1, 0),
2671 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
2672 BPF_FUNC_map_lookup_elem),
2673 BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
2674 BPF_MOV64_REG(BPF_REG_3, BPF_REG_0),
2675 BPF_MOV64_REG(BPF_REG_4, BPF_REG_0),
2676 BPF_MOV64_REG(BPF_REG_5, BPF_REG_0),
2677 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 1),
2678 BPF_MOV64_IMM(BPF_REG_1, 1),
2679 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 1),
2680 BPF_MOV64_IMM(BPF_REG_1, 2),
2681 BPF_JMP_IMM(BPF_JEQ, BPF_REG_3, 0, 1),
2682 BPF_ST_MEM(BPF_DW, BPF_REG_3, 0, 0),
2683 BPF_MOV64_IMM(BPF_REG_1, 3),
2684 BPF_EXIT_INSN(),
2685 },
2686 .fixup_map1 = { 4 },
2687 .result = REJECT,
2688 .errstr = "R3 invalid mem access 'inv'",
2689 .prog_type = BPF_PROG_TYPE_SCHED_CLS
2690 },
2691 {
2664 "invalid map access from else condition", 2692 "invalid map access from else condition",
2665 .insns = { 2693 .insns = {
2666 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), 2694 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),