History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Pull networking fixes from David Miller: "Several networking final fixes and tidies for the merge window: 1) Changes during the merge window unintentionally took away the ability to build bluetooth modular, fix from Geert Uytterhoeven. 2) Several phy_node reference count bug fixes from Uwe Kleine-König. 3) Fix ucc_geth build failures, also from Uwe Kleine-König. 4) Fix klog false positivies when netlink messages go to network taps, by properly resetting the network header. Fix from Daniel Borkmann. 5) Sizing estimate of VF netlink messages is too small, from Jiri Benc. 6) New APM X-Gene SoC ethernet driver, from Iyappan Subramanian. 7) VLAN untagging is erroneously dependent upon whether the VLAN module is loaded or not, but there are generic dependencies that matter wrt what can be expected as the SKB enters the stack. Make the basic untagging generic code, and do it unconditionally. From Vlad Yasevich. 8) xen-netfront only has so many slots in it's transmit queue so linearize packets that have too many frags. From Zoltan Kiss. 9) Fix suspend/resume PHY handling in bcmgenet driver, from Florian Fainelli" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (55 commits) net: bcmgenet: correctly resume adapter from Wake-on-LAN net: bcmgenet: update UMAC_CMD only when link is detected net: bcmgenet: correctly suspend and resume PHY device net: bcmgenet: request and enable main clock earlier net: ethernet: myricom: myri10ge: myri10ge.c: Cleaning up missing null-terminate after strncpy call xen-netfront: Fix handling packets on compound pages with skb_linearize net: fec: Support phys probed from devicetree and fixed-link smsc: replace WARN_ON() with WARN_ON_SMP() xen-netback: Don't deschedule NAPI when carrier off net: ethernet: qlogic: qlcnic: Remove duplicate object file from Makefile wan: wanxl: Remove typedefs from struct names m68k/atari: EtherNEC - ethernet support (ne) net: ethernet: ti: cpmac.c: Cleaning up missing null-terminate after strncpy call hdlc: Remove typedefs from struct names airo_cs: Remove typedef local_info_t atmel: Remove typedef atmel_priv_ioctl com20020_cs: Remove typedef com20020_dev_t ethernet: amd: Remove typedef local_info_t net: Always untag vlan-tagged traffic on input. drivers: net: Add APM X-Gene SoC ethernet driver support. ...

Linus Torvalds committed 12 years ago

Commit f0094b22 parents 13b102b 61dac4372 files · +3114 −531Browse files

Unified · Split

72 files
  1. Documentation/devicetree/bindings/net/apm-xgene-enet.txt +66 −0
  2. Documentation/devicetree/bindings/net/fsl-fec.txt +28 −1
  3. MAINTAINERS +8 −0
  4. arch/arm64/boot/dts/apm-mustang.dts +4 −0
  5. arch/arm64/boot/dts/apm-storm.dtsi +27 −3
  6. drivers/atm/atmtcp.c +1 −0
  7. drivers/atm/solos-pci.c +1 −0
  8. drivers/net/arcnet/com20020_cs.c +8 −8
  9. drivers/net/ethernet/8390/Kconfig +2 −1
  10. drivers/net/ethernet/8390/axnet_cs.c +13 −13
  11. drivers/net/ethernet/8390/ne.c +2 −0
  12. drivers/net/ethernet/8390/pcnet_cs.c +34 −34
  13. drivers/net/ethernet/Kconfig +1 −0
  14. drivers/net/ethernet/Makefile +1 −0
  15. drivers/net/ethernet/amd/xgbe/xgbe-drv.c +0 −1
  16. drivers/net/ethernet/apm/Kconfig +1 −0
  17. drivers/net/ethernet/apm/Makefile +5 −0
  18. drivers/net/ethernet/apm/xgene/Kconfig +9 −0
  19. drivers/net/ethernet/apm/xgene/Makefile +6 −0
  20. drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c +125 −0
  21. drivers/net/ethernet/apm/xgene/xgene_enet_hw.c +728 −0
  22. drivers/net/ethernet/apm/xgene/xgene_enet_hw.h +337 −0
  23. drivers/net/ethernet/apm/xgene/xgene_enet_main.c +951 −0
  24. drivers/net/ethernet/apm/xgene/xgene_enet_main.h +135 −0
  25. drivers/net/ethernet/broadcom/genet/bcmgenet.c +24 −13
  26. drivers/net/ethernet/broadcom/genet/bcmmii.c +10 −4
  27. drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +7 −4
  28. drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c +190 −70
  29. drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h +10 −0
  30. drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +2 −0
  31. drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +11 −1
  32. drivers/net/ethernet/davicom/dm9000.c +46 −46
  33. drivers/net/ethernet/freescale/fec.h +1 −0
  34. drivers/net/ethernet/freescale/fec_main.c +55 −21
  35. drivers/net/ethernet/freescale/fec_mpc52xx.c +1 −2
  36. drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +1 −1
  37. drivers/net/ethernet/freescale/gianfar.c +6 −10
  38. drivers/net/ethernet/freescale/ucc_geth.c +15 −9
  39. drivers/net/ethernet/fujitsu/fmvj18x_cs.c +17 −17
  40. drivers/net/ethernet/marvell/mvneta.c +6 −3
  41. drivers/net/ethernet/myricom/myri10ge/myri10ge.c +1 −0
  42. drivers/net/ethernet/qlogic/qlcnic/Makefile +1 −1
  43. drivers/net/ethernet/smsc/smsc911x.h +1 −1
  44. drivers/net/ethernet/ti/cpmac.c +1 −0
  45. drivers/net/ethernet/xilinx/ll_temac_main.c +1 −2
  46. drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1 −2
  47. drivers/net/ethernet/xircom/xirc2ps_cs.c +20 −20
  48. drivers/net/wan/hdlc_fr.c +32 −31
  49. drivers/net/wan/wanxl.c +32 −31
  50. drivers/net/wireless/airo_cs.c +13 −12
  51. drivers/net/wireless/atmel.c +4 −4
  52. drivers/net/xen-netback/interface.c +1 −5
  53. drivers/net/xen-netback/netback.c +8 −2
  54. drivers/net/xen-netfront.c +4 −3
  55. include/linux/if_vlan.h +0 −6
  56. include/linux/skbuff.h +1 −0
  57. net/6lowpan/Kconfig +1 −1
  58. net/8021q/vlan_core.c +0 −53
  59. net/batman-adv/multicast.c +0 −1
  60. net/bridge/br_vlan.c +1 −1
  61. net/bridge/netfilter/ebtables.c +2 −8
  62. net/core/dev.c +1 −1
  63. net/core/rtnetlink.c +2 −1
  64. net/core/skbuff.c +53 −0
  65. net/ipv4/route.c +0 −2
  66. net/netfilter/core.c +2 −9
  67. net/netfilter/ipvs/ip_vs_ctl.c +4 −15
  68. net/netfilter/nf_sockopt.c +2 −6
  69. net/netfilter/nf_tables_api.c +17 −13
  70. net/netfilter/x_tables.c +12 −35
  71. net/netlink/af_netlink.c +1 −1
  72. net/openvswitch/datapath.c +0 −2
Documentation/devicetree/bindings/net/apm-xgene-enet.txt+66−0
@@ -0,0 +1,66 @@
1+APM X-Gene SoC Ethernet nodes
2+
3+Ethernet nodes are defined to describe on-chip ethernet interfaces in
4+APM X-Gene SoC.
5+
6+Required properties:
7+- compatible: Should be "apm,xgene-enet"
8+- reg: Address and length of the register set for the device. It contains the
9+ information of registers in the same order as described by reg-names
10+- reg-names: Should contain the register set names
11+ - "enet_csr": Ethernet control and status register address space
12+ - "ring_csr": Descriptor ring control and status register address space
13+ - "ring_cmd": Descriptor ring command register address space
14+- interrupts: Ethernet main interrupt
15+- clocks: Reference to the clock entry.
16+- local-mac-address: MAC address assigned to this device
17+- phy-connection-type: Interface type between ethernet device and PHY device
18+- phy-handle: Reference to a PHY node connected to this device
19+
20+- mdio: Device tree subnode with the following required properties:
21+ - compatible: Must be "apm,xgene-mdio".
22+ - #address-cells: Must be <1>.
23+ - #size-cells: Must be <0>.
24+
25+ For the phy on the mdio bus, there must be a node with the following fields:
26+ - compatible: PHY identifier. Please refer ./phy.txt for the format.
27+ - reg: The ID number for the phy.
28+
29+Optional properties:
30+- status: Should be "ok" or "disabled" for enabled/disabled. Default is "ok".
31+
32+Example:
33+ menetclk: menetclk {
34+ compatible = "apm,xgene-device-clock";
35+ clock-output-names = "menetclk";
36+ status = "ok";
37+ };
38+
39+ menet: ethernet@17020000 {
40+ compatible = "apm,xgene-enet";
41+ status = "disabled";
42+ reg = <0x0 0x17020000 0x0 0xd100>,
43+ <0x0 0X17030000 0x0 0X400>,
44+ <0x0 0X10000000 0x0 0X200>;
45+ reg-names = "enet_csr", "ring_csr", "ring_cmd";
46+ interrupts = <0x0 0x3c 0x4>;
47+ clocks = <&menetclk 0>;
48+ local-mac-address = [00 01 73 00 00 01];
49+ phy-connection-type = "rgmii";
50+ phy-handle = <&menetphy>;
51+ mdio {
52+ compatible = "apm,xgene-mdio";
53+ #address-cells = <1>;
54+ #size-cells = <0>;
55+ menetphy: menetphy@3 {
56+ compatible = "ethernet-phy-id001c.c915";
57+ reg = <0x3>;
58+ };
59+
60+ };
61+ };
62+
63+/* Board-specific peripheral configurations */
64+&menet {
65+ status = "ok";
66+};
Documentation/devicetree/bindings/net/fsl-fec.txt+28−1
@@ -12,7 +12,14 @@ Optional properties: · 11 unmodified lines
1212 only if property "phy-reset-gpios" is available. Missing the property
1313 will have the duration be 1 millisecond. Numbers greater than 1000 are
1414 invalid and 1 millisecond will be used instead.
15−- phy-supply: regulator that powers the Ethernet PHY.
15+- phy-supply : regulator that powers the Ethernet PHY.
16+- phy-handle : phandle to the PHY device connected to this device.
17+- fixed-link : Assume a fixed link. See fixed-link.txt in the same directory.
18+ Use instead of phy-handle.
19+
20+Optional subnodes:
21+- mdio : specifies the mdio bus in the FEC, used as a container for phy nodes
22+ according to phy.txt in the same directory
1623
1724 Example:
1825
@@ -25,3 +32,23 @@ ethernet@83fec000 { · 6 unmodified lines
2532 local-mac-address = [00 04 9F 01 1B B9];
2633 phy-supply = <&reg_fec_supply>;
2734 };
35+
36+Example with phy specified:
37+
38+ethernet@83fec000 {
39+ compatible = "fsl,imx51-fec", "fsl,imx27-fec";
40+ reg = <0x83fec000 0x4000>;
41+ interrupts = <87>;
42+ phy-mode = "mii";
43+ phy-reset-gpios = <&gpio2 14 0>; /* GPIO2_14 */
44+ local-mac-address = [00 04 9F 01 1B B9];
45+ phy-supply = <&reg_fec_supply>;
46+ phy-handle = <&ethphy>;
47+ mdio {
48+ ethphy: ethernet-phy@6 {
49+ compatible = "ethernet-phy-ieee802.3-c22";
50+ reg = <6>;
51+ max-speed = <100>;
52+ };
53+ };
54+};
MAINTAINERS+8−0
@@ -719,6 +719,14 @@ S: Maintained · 718 unmodified lines
719719 F: drivers/net/appletalk/
720720 F: net/appletalk/
721721
722+APPLIED MICRO (APM) X-GENE SOC ETHERNET DRIVER
723+M: Iyappan Subramanian <isubramanian@apm.com>
724+M: Keyur Chudgar <kchudgar@apm.com>
725+M: Ravi Patel <rapatel@apm.com>
726+S: Supported
727+F: drivers/net/ethernet/apm/xgene/
728+F: Documentation/devicetree/bindings/net/apm-xgene-enet.txt
729+
722730 APTINA CAMERA SENSOR PLL
723731 M: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
724732 L: linux-media@vger.kernel.org
arch/arm64/boot/dts/apm-mustang.dts+4−0
@@ -28,3 +28,7 @@ · 27 unmodified lines
2828 &serial0 {
2929 status = "ok";
3030 };
31+
32+&menet {
33+ status = "ok";
34+};
arch/arm64/boot/dts/apm-storm.dtsi+27−3
@@ -167,14 +167,13 @@ · 166 unmodified lines
167167 clock-output-names = "ethclk";
168168 };
169169
170− eth8clk: eth8clk {
170+ menetclk: menetclk {
171171 compatible = "apm,xgene-device-clock";
172172 #clock-cells = <1>;
173173 clocks = <&ethclk 0>;
174− clock-names = "eth8clk";
175174 reg = <0x0 0x1702C000 0x0 0x1000>;
176175 reg-names = "csr-reg";
177− clock-output-names = "eth8clk";
176+ clock-output-names = "menetclk";
178177 };
179178
180179 sataphy1clk: sataphy1clk@1f21c000 {
@@ -397,5 +396,30 @@ · 216 unmodified lines
397396 #clock-cells = <1>;
398397 clocks = <&rtcclk 0>;
399398 };
399+
400+ menet: ethernet@17020000 {
401+ compatible = "apm,xgene-enet";
402+ status = "disabled";
403+ reg = <0x0 0x17020000 0x0 0xd100>,
404+ <0x0 0X17030000 0x0 0X400>,
405+ <0x0 0X10000000 0x0 0X200>;
406+ reg-names = "enet_csr", "ring_csr", "ring_cmd";
407+ interrupts = <0x0 0x3c 0x4>;
408+ dma-coherent;
409+ clocks = <&menetclk 0>;
410+ local-mac-address = [00 01 73 00 00 01];
411+ phy-connection-type = "rgmii";
412+ phy-handle = <&menetphy>;
413+ mdio {
414+ compatible = "apm,xgene-mdio";
415+ #address-cells = <1>;
416+ #size-cells = <0>;
417+ menetphy: menetphy@3 {
418+ compatible = "ethernet-phy-id001c.c915";
419+ reg = <0x3>;
420+ };
421+
422+ };
423+ };
400424 };
401425 };
drivers/atm/atmtcp.c+1−0
@@ -299,6 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb) · 298 unmodified lines
299299 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
300300 read_unlock(&vcc_sklist_lock);
301301 if (!out_vcc) {
302+ result = -EUNATCH;
302303 atomic_inc(&vcc->stats->tx_err);
303304 goto done;
304305 }
drivers/atm/solos-pci.c+1−0
@@ -1278,6 +1278,7 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id) · 1277 unmodified lines
12781278 card->dma_bounce = kmalloc(card->nr_ports * BUF_SIZE, GFP_KERNEL);
12791279 if (!card->dma_bounce) {
12801280 dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n");
1281+ err = -ENOMEM;
12811282 /* Fallback to MMIO doesn't work */
12821283 goto out_unmap_both;
12831284 }
drivers/net/arcnet/com20020_cs.c+8−8
@@ -112,20 +112,20 @@ static void com20020_detach(struct pcmcia_device *p_dev); · 111 unmodified lines
112112
113113 /*====================================================================*/
114114
115−typedef struct com20020_dev_t {
115+struct com20020_dev {
116116 struct net_device *dev;
117−} com20020_dev_t;
117+};
118118
119119 static int com20020_probe(struct pcmcia_device *p_dev)
120120 {
121− com20020_dev_t *info;
121+ struct com20020_dev *info;
122122 struct net_device *dev;
123123 struct arcnet_local *lp;
124124
125125 dev_dbg(&p_dev->dev, "com20020_attach()\n");
126126
127127 /* Create new network device */
128− info = kzalloc(sizeof(struct com20020_dev_t), GFP_KERNEL);
128+ info = kzalloc(sizeof(*info), GFP_KERNEL);
129129 if (!info)
130130 goto fail_alloc_info;
131131
@@ -160,7 +160,7 @@ fail_alloc_info: · 28 unmodified lines
160160
161161 static void com20020_detach(struct pcmcia_device *link)
162162 {
163− struct com20020_dev_t *info = link->priv;
163+ struct com20020_dev *info = link->priv;
164164 struct net_device *dev = info->dev;
165165
166166 dev_dbg(&link->dev, "detach...\n");
@@ -199,7 +199,7 @@ static void com20020_detach(struct pcmcia_device *link) · 32 unmodified lines
199199 static int com20020_config(struct pcmcia_device *link)
200200 {
201201 struct arcnet_local *lp;
202− com20020_dev_t *info;
202+ struct com20020_dev *info;
203203 struct net_device *dev;
204204 int i, ret;
205205 int ioaddr;
@@ -291,7 +291,7 @@ static void com20020_release(struct pcmcia_device *link) · 85 unmodified lines
291291
292292 static int com20020_suspend(struct pcmcia_device *link)
293293 {
294− com20020_dev_t *info = link->priv;
294+ struct com20020_dev *info = link->priv;
295295 struct net_device *dev = info->dev;
296296
297297 if (link->open)
@@ -302,7 +302,7 @@ static int com20020_suspend(struct pcmcia_device *link) · 4 unmodified lines
302302
303303 static int com20020_resume(struct pcmcia_device *link)
304304 {
305− com20020_dev_t *info = link->priv;
305+ struct com20020_dev *info = link->priv;
306306 struct net_device *dev = info->dev;
307307
308308 if (link->open) {
drivers/net/ethernet/8390/Kconfig+2−1
@@ -91,7 +91,8 @@ config MCF8390 · 90 unmodified lines
9191
9292 config NE2000
9393 tristate "NE2000/NE1000 support"
94− depends on (ISA || (Q40 && m) || M32R || MACH_TX49XX)
94+ depends on (ISA || (Q40 && m) || M32R || MACH_TX49XX || \
95+ ATARI_ETHERNEC)
9596 select CRC32
9697 ---help---
9798 If you have a network (Ethernet) card of this type, say Y and read
drivers/net/ethernet/8390/axnet_cs.c+13−13
@@ -108,7 +108,7 @@ static u32 axnet_msg_enable; · 107 unmodified lines
108108
109109 /*====================================================================*/
110110
111−typedef struct axnet_dev_t {
111+struct axnet_dev {
112112 struct pcmcia_device *p_dev;
113113 caddr_t base;
114114 struct timer_list watchdog;
@@ -118,9 +118,9 @@ typedef struct axnet_dev_t { · 3 unmodified lines
118118 int phy_id;
119119 int flags;
120120 int active_low;
121−} axnet_dev_t;
121+};
122122
123−static inline axnet_dev_t *PRIV(struct net_device *dev)
123+static inline struct axnet_dev *PRIV(struct net_device *dev)
124124 {
125125 void *p = (char *)netdev_priv(dev) + sizeof(struct ei_device);
126126 return p;
@@ -141,13 +141,13 @@ static const struct net_device_ops axnet_netdev_ops = { · 14 unmodified lines
141141
142142 static int axnet_probe(struct pcmcia_device *link)
143143 {
144− axnet_dev_t *info;
144+ struct axnet_dev *info;
145145 struct net_device *dev;
146146 struct ei_device *ei_local;
147147
148148 dev_dbg(&link->dev, "axnet_attach()\n");
149149
150− dev = alloc_etherdev(sizeof(struct ei_device) + sizeof(axnet_dev_t));
150+ dev = alloc_etherdev(sizeof(struct ei_device) + sizeof(struct axnet_dev));
151151 if (!dev)
152152 return -ENOMEM;
153153
@@ -274,7 +274,7 @@ static int axnet_configcheck(struct pcmcia_device *p_dev, void *priv_data) · 120 unmodified lines
274274 static int axnet_config(struct pcmcia_device *link)
275275 {
276276 struct net_device *dev = link->priv;
277− axnet_dev_t *info = PRIV(dev);
277+ struct axnet_dev *info = PRIV(dev);
278278 int i, j, j2, ret;
279279
280280 dev_dbg(&link->dev, "axnet_config(0x%p)\n", link);
@@ -389,7 +389,7 @@ static int axnet_suspend(struct pcmcia_device *link) · 108 unmodified lines
389389 static int axnet_resume(struct pcmcia_device *link)
390390 {
391391 struct net_device *dev = link->priv;
392− axnet_dev_t *info = PRIV(dev);
392+ struct axnet_dev *info = PRIV(dev);
393393
394394 if (link->open) {
395395 if (info->active_low == 1)
@@ -467,7 +467,7 @@ static void mdio_write(unsigned int addr, int phy_id, int loc, int value) · 71 unmodified lines
467467 static int axnet_open(struct net_device *dev)
468468 {
469469 int ret;
470− axnet_dev_t *info = PRIV(dev);
470+ struct axnet_dev *info = PRIV(dev);
471471 struct pcmcia_device *link = info->p_dev;
472472 unsigned int nic_base = dev->base_addr;
473473
@@ -497,7 +497,7 @@ static int axnet_open(struct net_device *dev) · 23 unmodified lines
497497
498498 static int axnet_close(struct net_device *dev)
499499 {
500− axnet_dev_t *info = PRIV(dev);
500+ struct axnet_dev *info = PRIV(dev);
501501 struct pcmcia_device *link = info->p_dev;
502502
503503 dev_dbg(&link->dev, "axnet_close('%s')\n", dev->name);
@@ -554,7 +554,7 @@ static irqreturn_t ei_irq_wrapper(int irq, void *dev_id) · 50 unmodified lines
554554 static void ei_watchdog(u_long arg)
555555 {
556556 struct net_device *dev = (struct net_device *)(arg);
557− axnet_dev_t *info = PRIV(dev);
557+ struct axnet_dev *info = PRIV(dev);
558558 unsigned int nic_base = dev->base_addr;
559559 unsigned int mii_addr = nic_base + AXNET_MII_EEP;
560560 u_short link;
@@ -610,7 +610,7 @@ reschedule: · 49 unmodified lines
610610
611611 static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
612612 {
613− axnet_dev_t *info = PRIV(dev);
613+ struct axnet_dev *info = PRIV(dev);
614614 struct mii_ioctl_data *data = if_mii(rq);
615615 unsigned int mii_addr = dev->base_addr + AXNET_MII_EEP;
616616 switch (cmd) {
@@ -1452,7 +1452,7 @@ static void ei_receive(struct net_device *dev) · 835 unmodified lines
14521452
14531453 static void ei_rx_overrun(struct net_device *dev)
14541454 {
1455− axnet_dev_t *info = PRIV(dev);
1455+ struct axnet_dev *info = PRIV(dev);
14561456 long e8390_base = dev->base_addr;
14571457 unsigned char was_txing, must_resend = 0;
14581458 struct ei_device *ei_local = netdev_priv(dev);
@@ -1624,7 +1624,7 @@ static void set_multicast_list(struct net_device *dev) · 165 unmodified lines
16241624
16251625 static void AX88190_init(struct net_device *dev, int startp)
16261626 {
1627− axnet_dev_t *info = PRIV(dev);
1627+ struct axnet_dev *info = PRIV(dev);
16281628 long e8390_base = dev->base_addr;
16291629 struct ei_device *ei_local = netdev_priv(dev);
16301630 int i;
drivers/net/ethernet/8390/ne.c+2−0
@@ -169,6 +169,8 @@ bad_clone_list[] __initdata = { · 168 unmodified lines
169169 #elif defined(CONFIG_PLAT_OAKS32R) || \
170170 defined(CONFIG_MACH_TX49XX)
171171 # define DCR_VAL 0x48 /* 8-bit mode */
172+#elif defined(CONFIG_ATARI) /* 8-bit mode on Atari, normal on Q40 */
173+# define DCR_VAL (MACH_IS_ATARI ? 0x48 : 0x49)
172174 #else
173175 # define DCR_VAL 0x49
174176 #endif
drivers/net/ethernet/8390/pcnet_cs.c+34−34
@@ -111,11 +111,11 @@ static void pcnet_detach(struct pcmcia_device *p_dev); · 110 unmodified lines
111111
112112 /*====================================================================*/
113113
114−typedef struct hw_info_t {
114+struct hw_info {
115115 u_int offset;
116116 u_char a0, a1, a2;
117117 u_int flags;
118−} hw_info_t;
118+};
119119
120120 #define DELAY_OUTPUT 0x01
121121 #define HAS_MISC_REG 0x02
@@ -132,7 +132,7 @@ typedef struct hw_info_t { · 10 unmodified lines
132132 #define MII_PHYID_REG1 0x02
133133 #define MII_PHYID_REG2 0x03
134134
135−static hw_info_t hw_info[] = {
135+static struct hw_info hw_info[] = {
136136 { /* Accton EN2212 */ 0x0ff0, 0x00, 0x00, 0xe8, DELAY_OUTPUT },
137137 { /* Allied Telesis LA-PCM */ 0x0ff0, 0x00, 0x00, 0xf4, 0 },
138138 { /* APEX MultiCard */ 0x03f4, 0x00, 0x20, 0xe5, 0 },
@@ -196,11 +196,11 @@ static hw_info_t hw_info[] = { · 57 unmodified lines
196196
197197 #define NR_INFO ARRAY_SIZE(hw_info)
198198
199−static hw_info_t default_info = { 0, 0, 0, 0, 0 };
200−static hw_info_t dl10019_info = { 0, 0, 0, 0, IS_DL10019|HAS_MII };
201−static hw_info_t dl10022_info = { 0, 0, 0, 0, IS_DL10022|HAS_MII };
199+static struct hw_info default_info = { 0, 0, 0, 0, 0 };
200+static struct hw_info dl10019_info = { 0, 0, 0, 0, IS_DL10019|HAS_MII };
201+static struct hw_info dl10022_info = { 0, 0, 0, 0, IS_DL10022|HAS_MII };
202202
203−typedef struct pcnet_dev_t {
203+struct pcnet_dev {
204204 struct pcmcia_device *p_dev;
205205 u_int flags;
206206 void __iomem *base;
@@ -210,12 +210,12 @@ typedef struct pcnet_dev_t { · 3 unmodified lines
210210 u_char eth_phy, pna_phy;
211211 u_short link_status;
212212 u_long mii_reset;
213−} pcnet_dev_t;
213+};
214214
215−static inline pcnet_dev_t *PRIV(struct net_device *dev)
215+static inline struct pcnet_dev *PRIV(struct net_device *dev)
216216 {
217217 char *p = netdev_priv(dev);
218− return (pcnet_dev_t *)(p + sizeof(struct ei_device));
218+ return (struct pcnet_dev *)(p + sizeof(struct ei_device));
219219 }
220220
221221 static const struct net_device_ops pcnet_netdev_ops = {
@@ -237,13 +237,13 @@ static const struct net_device_ops pcnet_netdev_ops = { · 15 unmodified lines
237237
238238 static int pcnet_probe(struct pcmcia_device *link)
239239 {
240− pcnet_dev_t *info;
240+ struct pcnet_dev *info;
241241 struct net_device *dev;
242242
243243 dev_dbg(&link->dev, "pcnet_attach()\n");
244244
245245 /* Create new ethernet device */
246− dev = __alloc_ei_netdev(sizeof(pcnet_dev_t));
246+ dev = __alloc_ei_netdev(sizeof(struct pcnet_dev));
247247 if (!dev) return -ENOMEM;
248248 info = PRIV(dev);
249249 info->p_dev = link;
@@ -276,7 +276,7 @@ static void pcnet_detach(struct pcmcia_device *link) · 26 unmodified lines
276276
277277 ======================================================================*/
278278
279−static hw_info_t *get_hwinfo(struct pcmcia_device *link)
279+static struct hw_info *get_hwinfo(struct pcmcia_device *link)
280280 {
281281 struct net_device *dev = link->priv;
282282 u_char __iomem *base, *virt;
@@ -317,7 +317,7 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link) · 34 unmodified lines
317317
318318 ======================================================================*/
319319
320−static hw_info_t *get_prom(struct pcmcia_device *link)
320+static struct hw_info *get_prom(struct pcmcia_device *link)
321321 {
322322 struct net_device *dev = link->priv;
323323 unsigned int ioaddr = dev->base_addr;
@@ -371,7 +371,7 @@ static hw_info_t *get_prom(struct pcmcia_device *link) · 47 unmodified lines
371371
372372 ======================================================================*/
373373
374−static hw_info_t *get_dl10019(struct pcmcia_device *link)
374+static struct hw_info *get_dl10019(struct pcmcia_device *link)
375375 {
376376 struct net_device *dev = link->priv;
377377 int i;
@@ -393,7 +393,7 @@ static hw_info_t *get_dl10019(struct pcmcia_device *link) · 15 unmodified lines
393393
394394 ======================================================================*/
395395
396−static hw_info_t *get_ax88190(struct pcmcia_device *link)
396+static struct hw_info *get_ax88190(struct pcmcia_device *link)
397397 {
398398 struct net_device *dev = link->priv;
399399 unsigned int ioaddr = dev->base_addr;
@@ -424,7 +424,7 @@ static hw_info_t *get_ax88190(struct pcmcia_device *link) · 24 unmodified lines
424424
425425 ======================================================================*/
426426
427−static hw_info_t *get_hwired(struct pcmcia_device *link)
427+static struct hw_info *get_hwired(struct pcmcia_device *link)
428428 {
429429 struct net_device *dev = link->priv;
430430 int i;
@@ -489,12 +489,12 @@ static int pcnet_confcheck(struct pcmcia_device *p_dev, void *priv_data) · 58 unmodified lines
489489 return try_io_port(p_dev);
490490 }
491491
492−static hw_info_t *pcnet_try_config(struct pcmcia_device *link,
493− int *has_shmem, int try)
492+static struct hw_info *pcnet_try_config(struct pcmcia_device *link,
493+ int *has_shmem, int try)
494494 {
495495 struct net_device *dev = link->priv;
496− hw_info_t *local_hw_info;
497− pcnet_dev_t *info = PRIV(dev);
496+ struct hw_info *local_hw_info;
497+ struct pcnet_dev *info = PRIV(dev);
498498 int priv = try;
499499 int ret;
500500
@@ -553,10 +553,10 @@ static hw_info_t *pcnet_try_config(struct pcmcia_device *link, · 52 unmodified lines
553553 static int pcnet_config(struct pcmcia_device *link)
554554 {
555555 struct net_device *dev = link->priv;
556− pcnet_dev_t *info = PRIV(dev);
556+ struct pcnet_dev *info = PRIV(dev);
557557 int start_pg, stop_pg, cm_offset;
558558 int has_shmem = 0;
559− hw_info_t *local_hw_info;
559+ struct hw_info *local_hw_info;
560560 struct ei_device *ei_local;
561561
562562 dev_dbg(&link->dev, "pcnet_config\n");
@@ -639,7 +639,7 @@ failed: · 76 unmodified lines
639639
640640 static void pcnet_release(struct pcmcia_device *link)
641641 {
642− pcnet_dev_t *info = PRIV(link->priv);
642+ struct pcnet_dev *info = PRIV(link->priv);
643643
644644 dev_dbg(&link->dev, "pcnet_release\n");
645645
@@ -836,7 +836,7 @@ static void write_asic(unsigned int ioaddr, int location, short asic_data) · 190 unmodified lines
836836 static void set_misc_reg(struct net_device *dev)
837837 {
838838 unsigned int nic_base = dev->base_addr;
839− pcnet_dev_t *info = PRIV(dev);
839+ struct pcnet_dev *info = PRIV(dev);
840840 u_char tmp;
841841
842842 if (info->flags & HAS_MISC_REG) {
@@ -873,7 +873,7 @@ static void set_misc_reg(struct net_device *dev) · 30 unmodified lines
873873
874874 static void mii_phy_probe(struct net_device *dev)
875875 {
876− pcnet_dev_t *info = PRIV(dev);
876+ struct pcnet_dev *info = PRIV(dev);
877877 unsigned int mii_addr = dev->base_addr + DLINK_GPIO;
878878 int i;
879879 u_int tmp, phyid;
@@ -898,7 +898,7 @@ static void mii_phy_probe(struct net_device *dev) · 18 unmodified lines
898898 static int pcnet_open(struct net_device *dev)
899899 {
900900 int ret;
901− pcnet_dev_t *info = PRIV(dev);
901+ struct pcnet_dev *info = PRIV(dev);
902902 struct pcmcia_device *link = info->p_dev;
903903 unsigned int nic_base = dev->base_addr;
904904
@@ -931,7 +931,7 @@ static int pcnet_open(struct net_device *dev) · 26 unmodified lines
931931
932932 static int pcnet_close(struct net_device *dev)
933933 {
934− pcnet_dev_t *info = PRIV(dev);
934+ struct pcnet_dev *info = PRIV(dev);
935935 struct pcmcia_device *link = info->p_dev;
936936
937937 dev_dbg(&link->dev, "pcnet_close('%s')\n", dev->name);
@@ -982,7 +982,7 @@ static void pcnet_reset_8390(struct net_device *dev) · 44 unmodified lines
982982
983983 static int set_config(struct net_device *dev, struct ifmap *map)
984984 {
985− pcnet_dev_t *info = PRIV(dev);
985+ struct pcnet_dev *info = PRIV(dev);
986986 if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) {
987987 if (!(info->flags & HAS_MISC_REG))
988988 return -EOPNOTSUPP;
@@ -1000,7 +1000,7 @@ static int set_config(struct net_device *dev, struct ifmap *map) · 11 unmodified lines
10001000 static irqreturn_t ei_irq_wrapper(int irq, void *dev_id)
10011001 {
10021002 struct net_device *dev = dev_id;
1003− pcnet_dev_t *info;
1003+ struct pcnet_dev *info;
10041004 irqreturn_t ret = ei_interrupt(irq, dev_id);
10051005
10061006 if (ret == IRQ_HANDLED) {
@@ -1013,7 +1013,7 @@ static irqreturn_t ei_irq_wrapper(int irq, void *dev_id) · 6 unmodified lines
10131013 static void ei_watchdog(u_long arg)
10141014 {
10151015 struct net_device *dev = (struct net_device *)arg;
1016− pcnet_dev_t *info = PRIV(dev);
1016+ struct pcnet_dev *info = PRIV(dev);
10171017 unsigned int nic_base = dev->base_addr;
10181018 unsigned int mii_addr = nic_base + DLINK_GPIO;
10191019 u_short link;
@@ -1101,7 +1101,7 @@ reschedule: · 81 unmodified lines
11011101
11021102 static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
11031103 {
1104− pcnet_dev_t *info = PRIV(dev);
1104+ struct pcnet_dev *info = PRIV(dev);
11051105 struct mii_ioctl_data *data = if_mii(rq);
11061106 unsigned int mii_addr = dev->base_addr + DLINK_GPIO;
11071107
@@ -1214,7 +1214,7 @@ static void dma_block_output(struct net_device *dev, int count, · 106 unmodified lines
12141214 const u_char *buf, const int start_page)
12151215 {
12161216 unsigned int nic_base = dev->base_addr;
1217− pcnet_dev_t *info = PRIV(dev);
1217+ struct pcnet_dev *info = PRIV(dev);
12181218 #ifdef PCMCIA_DEBUG
12191219 int retries = 0;
12201220 struct ei_device *ei_local = netdev_priv(dev);
@@ -1403,7 +1403,7 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg, · 182 unmodified lines
14031403 int stop_pg, int cm_offset)
14041404 {
14051405 struct net_device *dev = link->priv;
1406− pcnet_dev_t *info = PRIV(dev);
1406+ struct pcnet_dev *info = PRIV(dev);
14071407 int i, window_size, offset, ret;
14081408
14091409 window_size = (stop_pg - start_pg) << 8;
drivers/net/ethernet/Kconfig+1−0
@@ -24,6 +24,7 @@ source "drivers/net/ethernet/allwinner/Kconfig" · 23 unmodified lines
2424 source "drivers/net/ethernet/alteon/Kconfig"
2525 source "drivers/net/ethernet/altera/Kconfig"
2626 source "drivers/net/ethernet/amd/Kconfig"
27+source "drivers/net/ethernet/apm/Kconfig"
2728 source "drivers/net/ethernet/apple/Kconfig"
2829 source "drivers/net/ethernet/arc/Kconfig"
2930 source "drivers/net/ethernet/atheros/Kconfig"
drivers/net/ethernet/Makefile+1−0
@@ -10,6 +10,7 @@ obj-$(CONFIG_NET_VENDOR_ALLWINNER) += allwinner/ · 9 unmodified lines
1010 obj-$(CONFIG_NET_VENDOR_ALTEON) += alteon/
1111 obj-$(CONFIG_ALTERA_TSE) += altera/
1212 obj-$(CONFIG_NET_VENDOR_AMD) += amd/
13+obj-$(CONFIG_NET_XGENE) += apm/
1314 obj-$(CONFIG_NET_VENDOR_APPLE) += apple/
1415 obj-$(CONFIG_NET_VENDOR_ARC) += arc/
1516 obj-$(CONFIG_NET_VENDOR_ATHEROS) += atheros/
drivers/net/ethernet/amd/xgbe/xgbe-drv.c+0−1
@@ -117,7 +117,6 @@ · 116 unmodified lines
117117 #include <linux/spinlock.h>
118118 #include <linux/tcp.h>
119119 #include <linux/if_vlan.h>
120−#include <linux/phy.h>
121120 #include <net/busy_poll.h>
122121 #include <linux/clk.h>
123122 #include <linux/if_ether.h>
drivers/net/ethernet/apm/Kconfig+1−0
@@ -0,0 +1 @@
1+source "drivers/net/ethernet/apm/xgene/Kconfig"
drivers/net/ethernet/apm/Makefile+5−0
@@ -0,0 +1,5 @@
1+#
2+# Makefile for APM X-GENE Ethernet driver.
3+#
4+
5+obj-$(CONFIG_NET_XGENE) += xgene/
drivers/net/ethernet/apm/xgene/Kconfig+9−0
@@ -0,0 +1,9 @@
1+config NET_XGENE
2+ tristate "APM X-Gene SoC Ethernet Driver"
3+ select PHYLIB
4+ help
5+ This is the Ethernet driver for the on-chip ethernet interface on the
6+ APM X-Gene SoC.
7+
8+ To compile this driver as a module, choose M here. This module will
9+ be called xgene_enet.
drivers/net/ethernet/apm/xgene/Makefile+6−0
@@ -0,0 +1,6 @@
1+#
2+# Makefile for APM X-Gene Ethernet Driver.
3+#
4+
5+xgene-enet-objs := xgene_enet_hw.o xgene_enet_main.o xgene_enet_ethtool.o
6+obj-$(CONFIG_NET_XGENE) += xgene-enet.o
drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c+125−0
@@ -0,0 +1,125 @@
1+/* Applied Micro X-Gene SoC Ethernet Driver
2+ *
3+ * Copyright (c) 2014, Applied Micro Circuits Corporation
4+ * Authors: Iyappan Subramanian <isubramanian@apm.com>
5+ *
6+ * This program is free software; you can redistribute it and/or modify it
7+ * under the terms of the GNU General Public License as published by the
8+ * Free Software Foundation; either version 2 of the License, or (at your
9+ * option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+#include <linux/ethtool.h>
21+#include "xgene_enet_main.h"
22+
23+struct xgene_gstrings_stats {
24+ char name[ETH_GSTRING_LEN];
25+ int offset;
26+};
27+
28+#define XGENE_STAT(m) { #m, offsetof(struct xgene_enet_pdata, stats.m) }
29+
30+static const struct xgene_gstrings_stats gstrings_stats[] = {
31+ XGENE_STAT(rx_packets),
32+ XGENE_STAT(tx_packets),
33+ XGENE_STAT(rx_bytes),
34+ XGENE_STAT(tx_bytes),
35+ XGENE_STAT(rx_errors),
36+ XGENE_STAT(tx_errors),
37+ XGENE_STAT(rx_length_errors),
38+ XGENE_STAT(rx_crc_errors),
39+ XGENE_STAT(rx_frame_errors),
40+ XGENE_STAT(rx_fifo_errors)
41+};
42+
43+#define XGENE_STATS_LEN ARRAY_SIZE(gstrings_stats)
44+
45+static void xgene_get_drvinfo(struct net_device *ndev,
46+ struct ethtool_drvinfo *info)
47+{
48+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
49+ struct platform_device *pdev = pdata->pdev;
50+
51+ strcpy(info->driver, "xgene_enet");
52+ strcpy(info->version, XGENE_DRV_VERSION);
53+ snprintf(info->fw_version, ETHTOOL_FWVERS_LEN, "N/A");
54+ sprintf(info->bus_info, "%s", pdev->name);
55+}
56+
57+static int xgene_get_settings(struct net_device *ndev, struct ethtool_cmd *cmd)
58+{
59+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
60+ struct phy_device *phydev = pdata->phy_dev;
61+
62+ if (phydev == NULL)
63+ return -ENODEV;
64+
65+ return phy_ethtool_gset(phydev, cmd);
66+}
67+
68+static int xgene_set_settings(struct net_device *ndev, struct ethtool_cmd *cmd)
69+{
70+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
71+ struct phy_device *phydev = pdata->phy_dev;
72+
73+ if (phydev == NULL)
74+ return -ENODEV;
75+
76+ return phy_ethtool_sset(phydev, cmd);
77+}
78+
79+static void xgene_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
80+{
81+ int i;
82+ u8 *p = data;
83+
84+ if (stringset != ETH_SS_STATS)
85+ return;
86+
87+ for (i = 0; i < XGENE_STATS_LEN; i++) {
88+ memcpy(p, gstrings_stats[i].name, ETH_GSTRING_LEN);
89+ p += ETH_GSTRING_LEN;
90+ }
91+}
92+
93+static int xgene_get_sset_count(struct net_device *ndev, int sset)
94+{
95+ if (sset != ETH_SS_STATS)
96+ return -EINVAL;
97+
98+ return XGENE_STATS_LEN;
99+}
100+
101+static void xgene_get_ethtool_stats(struct net_device *ndev,
102+ struct ethtool_stats *dummy,
103+ u64 *data)
104+{
105+ void *pdata = netdev_priv(ndev);
106+ int i;
107+
108+ for (i = 0; i < XGENE_STATS_LEN; i++)
109+ *data++ = *(u64 *)(pdata + gstrings_stats[i].offset);
110+}
111+
112+static const struct ethtool_ops xgene_ethtool_ops = {
113+ .get_drvinfo = xgene_get_drvinfo,
114+ .get_settings = xgene_get_settings,
115+ .set_settings = xgene_set_settings,
116+ .get_link = ethtool_op_get_link,
117+ .get_strings = xgene_get_strings,
118+ .get_sset_count = xgene_get_sset_count,
119+ .get_ethtool_stats = xgene_get_ethtool_stats
120+};
121+
122+void xgene_enet_set_ethtool_ops(struct net_device *ndev)
123+{
124+ ndev->ethtool_ops = &xgene_ethtool_ops;
125+}
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c+728−0
@@ -0,0 +1,728 @@
1+/* Applied Micro X-Gene SoC Ethernet Driver
2+ *
3+ * Copyright (c) 2014, Applied Micro Circuits Corporation
4+ * Authors: Iyappan Subramanian <isubramanian@apm.com>
5+ * Ravi Patel <rapatel@apm.com>
6+ * Keyur Chudgar <kchudgar@apm.com>
7+ *
8+ * This program is free software; you can redistribute it and/or modify it
9+ * under the terms of the GNU General Public License as published by the
10+ * Free Software Foundation; either version 2 of the License, or (at your
11+ * option) any later version.
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 "xgene_enet_main.h"
23+#include "xgene_enet_hw.h"
24+
25+static void xgene_enet_ring_init(struct xgene_enet_desc_ring *ring)
26+{
27+ u32 *ring_cfg = ring->state;
28+ u64 addr = ring->dma;
29+ enum xgene_enet_ring_cfgsize cfgsize = ring->cfgsize;
30+
31+ ring_cfg[4] |= (1 << SELTHRSH_POS) &
32+ CREATE_MASK(SELTHRSH_POS, SELTHRSH_LEN);
33+ ring_cfg[3] |= ACCEPTLERR;
34+ ring_cfg[2] |= QCOHERENT;
35+
36+ addr >>= 8;
37+ ring_cfg[2] |= (addr << RINGADDRL_POS) &
38+ CREATE_MASK_ULL(RINGADDRL_POS, RINGADDRL_LEN);
39+ addr >>= RINGADDRL_LEN;
40+ ring_cfg[3] |= addr & CREATE_MASK_ULL(RINGADDRH_POS, RINGADDRH_LEN);
41+ ring_cfg[3] |= ((u32)cfgsize << RINGSIZE_POS) &
42+ CREATE_MASK(RINGSIZE_POS, RINGSIZE_LEN);
43+}
44+
45+static void xgene_enet_ring_set_type(struct xgene_enet_desc_ring *ring)
46+{
47+ u32 *ring_cfg = ring->state;
48+ bool is_bufpool;
49+ u32 val;
50+
51+ is_bufpool = xgene_enet_is_bufpool(ring->id);
52+ val = (is_bufpool) ? RING_BUFPOOL : RING_REGULAR;
53+ ring_cfg[4] |= (val << RINGTYPE_POS) &
54+ CREATE_MASK(RINGTYPE_POS, RINGTYPE_LEN);
55+
56+ if (is_bufpool) {
57+ ring_cfg[3] |= (BUFPOOL_MODE << RINGMODE_POS) &
58+ CREATE_MASK(RINGMODE_POS, RINGMODE_LEN);
59+ }
60+}
61+
62+static void xgene_enet_ring_set_recombbuf(struct xgene_enet_desc_ring *ring)
63+{
64+ u32 *ring_cfg = ring->state;
65+
66+ ring_cfg[3] |= RECOMBBUF;
67+ ring_cfg[3] |= (0xf << RECOMTIMEOUTL_POS) &
68+ CREATE_MASK(RECOMTIMEOUTL_POS, RECOMTIMEOUTL_LEN);
69+ ring_cfg[4] |= 0x7 & CREATE_MASK(RECOMTIMEOUTH_POS, RECOMTIMEOUTH_LEN);
70+}
71+
72+static void xgene_enet_ring_wr32(struct xgene_enet_desc_ring *ring,
73+ u32 offset, u32 data)
74+{
75+ struct xgene_enet_pdata *pdata = netdev_priv(ring->ndev);
76+
77+ iowrite32(data, pdata->ring_csr_addr + offset);
78+}
79+
80+static void xgene_enet_ring_rd32(struct xgene_enet_desc_ring *ring,
81+ u32 offset, u32 *data)
82+{
83+ struct xgene_enet_pdata *pdata = netdev_priv(ring->ndev);
84+
85+ *data = ioread32(pdata->ring_csr_addr + offset);
86+}
87+
88+static void xgene_enet_write_ring_state(struct xgene_enet_desc_ring *ring)
89+{
90+ int i;
91+
92+ xgene_enet_ring_wr32(ring, CSR_RING_CONFIG, ring->num);
93+ for (i = 0; i < NUM_RING_CONFIG; i++) {
94+ xgene_enet_ring_wr32(ring, CSR_RING_WR_BASE + (i * 4),
95+ ring->state[i]);
96+ }
97+}
98+
99+static void xgene_enet_clr_ring_state(struct xgene_enet_desc_ring *ring)
100+{
101+ memset(ring->state, 0, sizeof(u32) * NUM_RING_CONFIG);
102+ xgene_enet_write_ring_state(ring);
103+}
104+
105+static void xgene_enet_set_ring_state(struct xgene_enet_desc_ring *ring)
106+{
107+ xgene_enet_ring_set_type(ring);
108+
109+ if (xgene_enet_ring_owner(ring->id) == RING_OWNER_ETH0)
110+ xgene_enet_ring_set_recombbuf(ring);
111+
112+ xgene_enet_ring_init(ring);
113+ xgene_enet_write_ring_state(ring);
114+}
115+
116+static void xgene_enet_set_ring_id(struct xgene_enet_desc_ring *ring)
117+{
118+ u32 ring_id_val, ring_id_buf;
119+ bool is_bufpool;
120+
121+ is_bufpool = xgene_enet_is_bufpool(ring->id);
122+
123+ ring_id_val = ring->id & GENMASK(9, 0);
124+ ring_id_val |= OVERWRITE;
125+
126+ ring_id_buf = (ring->num << 9) & GENMASK(18, 9);
127+ ring_id_buf |= PREFETCH_BUF_EN;
128+ if (is_bufpool)
129+ ring_id_buf |= IS_BUFFER_POOL;
130+
131+ xgene_enet_ring_wr32(ring, CSR_RING_ID, ring_id_val);
132+ xgene_enet_ring_wr32(ring, CSR_RING_ID_BUF, ring_id_buf);
133+}
134+
135+static void xgene_enet_clr_desc_ring_id(struct xgene_enet_desc_ring *ring)
136+{
137+ u32 ring_id;
138+
139+ ring_id = ring->id | OVERWRITE;
140+ xgene_enet_ring_wr32(ring, CSR_RING_ID, ring_id);
141+ xgene_enet_ring_wr32(ring, CSR_RING_ID_BUF, 0);
142+}
143+
144+struct xgene_enet_desc_ring *xgene_enet_setup_ring(
145+ struct xgene_enet_desc_ring *ring)
146+{
147+ u32 size = ring->size;
148+ u32 i, data;
149+ bool is_bufpool;
150+
151+ xgene_enet_clr_ring_state(ring);
152+ xgene_enet_set_ring_state(ring);
153+ xgene_enet_set_ring_id(ring);
154+
155+ ring->slots = xgene_enet_get_numslots(ring->id, size);
156+
157+ is_bufpool = xgene_enet_is_bufpool(ring->id);
158+ if (is_bufpool || xgene_enet_ring_owner(ring->id) != RING_OWNER_CPU)
159+ return ring;
160+
161+ for (i = 0; i < ring->slots; i++)
162+ xgene_enet_mark_desc_slot_empty(&ring->raw_desc[i]);
163+
164+ xgene_enet_ring_rd32(ring, CSR_RING_NE_INT_MODE, &data);
165+ data |= BIT(31 - xgene_enet_ring_bufnum(ring->id));
166+ xgene_enet_ring_wr32(ring, CSR_RING_NE_INT_MODE, data);
167+
168+ return ring;
169+}
170+
171+void xgene_enet_clear_ring(struct xgene_enet_desc_ring *ring)
172+{
173+ u32 data;
174+ bool is_bufpool;
175+
176+ is_bufpool = xgene_enet_is_bufpool(ring->id);
177+ if (is_bufpool || xgene_enet_ring_owner(ring->id) != RING_OWNER_CPU)
178+ goto out;
179+
180+ xgene_enet_ring_rd32(ring, CSR_RING_NE_INT_MODE, &data);
181+ data &= ~BIT(31 - xgene_enet_ring_bufnum(ring->id));
182+ xgene_enet_ring_wr32(ring, CSR_RING_NE_INT_MODE, data);
183+
184+out:
185+ xgene_enet_clr_desc_ring_id(ring);
186+ xgene_enet_clr_ring_state(ring);
187+}
188+
189+void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
190+ struct xgene_enet_pdata *pdata,
191+ enum xgene_enet_err_code status)
192+{
193+ struct rtnl_link_stats64 *stats = &pdata->stats;
194+
195+ switch (status) {
196+ case INGRESS_CRC:
197+ stats->rx_crc_errors++;
198+ break;
199+ case INGRESS_CHECKSUM:
200+ case INGRESS_CHECKSUM_COMPUTE:
201+ stats->rx_errors++;
202+ break;
203+ case INGRESS_TRUNC_FRAME:
204+ stats->rx_frame_errors++;
205+ break;
206+ case INGRESS_PKT_LEN:
207+ stats->rx_length_errors++;
208+ break;
209+ case INGRESS_PKT_UNDER:
210+ stats->rx_frame_errors++;
211+ break;
212+ case INGRESS_FIFO_OVERRUN:
213+ stats->rx_fifo_errors++;
214+ break;
215+ default:
216+ break;
217+ }
218+}
219+
220+static void xgene_enet_wr_csr(struct xgene_enet_pdata *pdata,
221+ u32 offset, u32 val)
222+{
223+ void __iomem *addr = pdata->eth_csr_addr + offset;
224+
225+ iowrite32(val, addr);
226+}
227+
228+static void xgene_enet_wr_ring_if(struct xgene_enet_pdata *pdata,
229+ u32 offset, u32 val)
230+{
231+ void __iomem *addr = pdata->eth_ring_if_addr + offset;
232+
233+ iowrite32(val, addr);
234+}
235+
236+static void xgene_enet_wr_diag_csr(struct xgene_enet_pdata *pdata,
237+ u32 offset, u32 val)
238+{
239+ void __iomem *addr = pdata->eth_diag_csr_addr + offset;
240+
241+ iowrite32(val, addr);
242+}
243+
244+static void xgene_enet_wr_mcx_csr(struct xgene_enet_pdata *pdata,
245+ u32 offset, u32 val)
246+{
247+ void __iomem *addr = pdata->mcx_mac_csr_addr + offset;
248+
249+ iowrite32(val, addr);
250+}
251+
252+static bool xgene_enet_wr_indirect(void __iomem *addr, void __iomem *wr,
253+ void __iomem *cmd, void __iomem *cmd_done,
254+ u32 wr_addr, u32 wr_data)
255+{
256+ u32 done;
257+ u8 wait = 10;
258+
259+ iowrite32(wr_addr, addr);
260+ iowrite32(wr_data, wr);
261+ iowrite32(XGENE_ENET_WR_CMD, cmd);
262+
263+ /* wait for write command to complete */
264+ while (!(done = ioread32(cmd_done)) && wait--)
265+ udelay(1);
266+
267+ if (!done)
268+ return false;
269+
270+ iowrite32(0, cmd);
271+
272+ return true;
273+}
274+
275+static void xgene_enet_wr_mcx_mac(struct xgene_enet_pdata *pdata,
276+ u32 wr_addr, u32 wr_data)
277+{
278+ void __iomem *addr, *wr, *cmd, *cmd_done;
279+
280+ addr = pdata->mcx_mac_addr + MAC_ADDR_REG_OFFSET;
281+ wr = pdata->mcx_mac_addr + MAC_WRITE_REG_OFFSET;
282+ cmd = pdata->mcx_mac_addr + MAC_COMMAND_REG_OFFSET;
283+ cmd_done = pdata->mcx_mac_addr + MAC_COMMAND_DONE_REG_OFFSET;
284+
285+ if (!xgene_enet_wr_indirect(addr, wr, cmd, cmd_done, wr_addr, wr_data))
286+ netdev_err(pdata->ndev, "MCX mac write failed, addr: %04x\n",
287+ wr_addr);
288+}
289+
290+static void xgene_enet_rd_csr(struct xgene_enet_pdata *pdata,
291+ u32 offset, u32 *val)
292+{
293+ void __iomem *addr = pdata->eth_csr_addr + offset;
294+
295+ *val = ioread32(addr);
296+}
297+
298+static void xgene_enet_rd_diag_csr(struct xgene_enet_pdata *pdata,
299+ u32 offset, u32 *val)
300+{
301+ void __iomem *addr = pdata->eth_diag_csr_addr + offset;
302+
303+ *val = ioread32(addr);
304+}
305+
306+static void xgene_enet_rd_mcx_csr(struct xgene_enet_pdata *pdata,
307+ u32 offset, u32 *val)
308+{
309+ void __iomem *addr = pdata->mcx_mac_csr_addr + offset;
310+
311+ *val = ioread32(addr);
312+}
313+
314+static bool xgene_enet_rd_indirect(void __iomem *addr, void __iomem *rd,
315+ void __iomem *cmd, void __iomem *cmd_done,
316+ u32 rd_addr, u32 *rd_data)
317+{
318+ u32 done;
319+ u8 wait = 10;
320+
321+ iowrite32(rd_addr, addr);
322+ iowrite32(XGENE_ENET_RD_CMD, cmd);
323+
324+ /* wait for read command to complete */
325+ while (!(done = ioread32(cmd_done)) && wait--)
326+ udelay(1);
327+
328+ if (!done)
329+ return false;
330+
331+ *rd_data = ioread32(rd);
332+ iowrite32(0, cmd);
333+
334+ return true;
335+}
336+
337+static void xgene_enet_rd_mcx_mac(struct xgene_enet_pdata *pdata,
338+ u32 rd_addr, u32 *rd_data)
339+{
340+ void __iomem *addr, *rd, *cmd, *cmd_done;
341+
342+ addr = pdata->mcx_mac_addr + MAC_ADDR_REG_OFFSET;
343+ rd = pdata->mcx_mac_addr + MAC_READ_REG_OFFSET;
344+ cmd = pdata->mcx_mac_addr + MAC_COMMAND_REG_OFFSET;
345+ cmd_done = pdata->mcx_mac_addr + MAC_COMMAND_DONE_REG_OFFSET;
346+
347+ if (!xgene_enet_rd_indirect(addr, rd, cmd, cmd_done, rd_addr, rd_data))
348+ netdev_err(pdata->ndev, "MCX mac read failed, addr: %04x\n",
349+ rd_addr);
350+}
351+
352+static int xgene_mii_phy_write(struct xgene_enet_pdata *pdata, int phy_id,
353+ u32 reg, u16 data)
354+{
355+ u32 addr = 0, wr_data = 0;
356+ u32 done;
357+ u8 wait = 10;
358+
359+ PHY_ADDR_SET(&addr, phy_id);
360+ REG_ADDR_SET(&addr, reg);
361+ xgene_enet_wr_mcx_mac(pdata, MII_MGMT_ADDRESS_ADDR, addr);
362+
363+ PHY_CONTROL_SET(&wr_data, data);
364+ xgene_enet_wr_mcx_mac(pdata, MII_MGMT_CONTROL_ADDR, wr_data);
365+ do {
366+ usleep_range(5, 10);
367+ xgene_enet_rd_mcx_mac(pdata, MII_MGMT_INDICATORS_ADDR, &done);
368+ } while ((done & BUSY_MASK) && wait--);
369+
370+ if (done & BUSY_MASK) {
371+ netdev_err(pdata->ndev, "MII_MGMT write failed\n");
372+ return -EBUSY;
373+ }
374+
375+ return 0;
376+}
377+
378+static int xgene_mii_phy_read(struct xgene_enet_pdata *pdata,
379+ u8 phy_id, u32 reg)
380+{
381+ u32 addr = 0;
382+ u32 data, done;
383+ u8 wait = 10;
384+
385+ PHY_ADDR_SET(&addr, phy_id);
386+ REG_ADDR_SET(&addr, reg);
387+ xgene_enet_wr_mcx_mac(pdata, MII_MGMT_ADDRESS_ADDR, addr);
388+ xgene_enet_wr_mcx_mac(pdata, MII_MGMT_COMMAND_ADDR, READ_CYCLE_MASK);
389+ do {
390+ usleep_range(5, 10);
391+ xgene_enet_rd_mcx_mac(pdata, MII_MGMT_INDICATORS_ADDR, &done);
392+ } while ((done & BUSY_MASK) && wait--);
393+
394+ if (done & BUSY_MASK) {
395+ netdev_err(pdata->ndev, "MII_MGMT read failed\n");
396+ return -EBUSY;
397+ }
398+
399+ xgene_enet_rd_mcx_mac(pdata, MII_MGMT_STATUS_ADDR, &data);
400+ xgene_enet_wr_mcx_mac(pdata, MII_MGMT_COMMAND_ADDR, 0);
401+
402+ return data;
403+}
404+
405+void xgene_gmac_set_mac_addr(struct xgene_enet_pdata *pdata)
406+{
407+ u32 addr0, addr1;
408+ u8 *dev_addr = pdata->ndev->dev_addr;
409+
410+ addr0 = (dev_addr[3] << 24) | (dev_addr[2] << 16) |
411+ (dev_addr[1] << 8) | dev_addr[0];
412+ addr1 = (dev_addr[5] << 24) | (dev_addr[4] << 16);
413+ addr1 |= pdata->phy_addr & 0xFFFF;
414+
415+ xgene_enet_wr_mcx_mac(pdata, STATION_ADDR0_ADDR, addr0);
416+ xgene_enet_wr_mcx_mac(pdata, STATION_ADDR1_ADDR, addr1);
417+}
418+
419+static int xgene_enet_ecc_init(struct xgene_enet_pdata *pdata)
420+{
421+ struct net_device *ndev = pdata->ndev;
422+ u32 data;
423+ u8 wait = 10;
424+
425+ xgene_enet_wr_diag_csr(pdata, ENET_CFG_MEM_RAM_SHUTDOWN_ADDR, 0x0);
426+ do {
427+ usleep_range(100, 110);
428+ xgene_enet_rd_diag_csr(pdata, ENET_BLOCK_MEM_RDY_ADDR, &data);
429+ } while ((data != 0xffffffff) && wait--);
430+
431+ if (data != 0xffffffff) {
432+ netdev_err(ndev, "Failed to release memory from shutdown\n");
433+ return -ENODEV;
434+ }
435+
436+ return 0;
437+}
438+
439+void xgene_gmac_reset(struct xgene_enet_pdata *pdata)
440+{
441+ xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, SOFT_RESET1);
442+ xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, 0);
443+}
444+
445+void xgene_gmac_init(struct xgene_enet_pdata *pdata, int speed)
446+{
447+ u32 value, mc2;
448+ u32 intf_ctl, rgmii;
449+ u32 icm0, icm2;
450+
451+ xgene_gmac_reset(pdata);
452+
453+ xgene_enet_rd_mcx_csr(pdata, ICM_CONFIG0_REG_0_ADDR, &icm0);
454+ xgene_enet_rd_mcx_csr(pdata, ICM_CONFIG2_REG_0_ADDR, &icm2);
455+ xgene_enet_rd_mcx_mac(pdata, MAC_CONFIG_2_ADDR, &mc2);
456+ xgene_enet_rd_mcx_mac(pdata, INTERFACE_CONTROL_ADDR, &intf_ctl);
457+ xgene_enet_rd_csr(pdata, RGMII_REG_0_ADDR, &rgmii);
458+
459+ switch (speed) {
460+ case SPEED_10:
461+ ENET_INTERFACE_MODE2_SET(&mc2, 1);
462+ CFG_MACMODE_SET(&icm0, 0);
463+ CFG_WAITASYNCRD_SET(&icm2, 500);
464+ rgmii &= ~CFG_SPEED_1250;
465+ break;
466+ case SPEED_100:
467+ ENET_INTERFACE_MODE2_SET(&mc2, 1);
468+ intf_ctl |= ENET_LHD_MODE;
469+ CFG_MACMODE_SET(&icm0, 1);
470+ CFG_WAITASYNCRD_SET(&icm2, 80);
471+ rgmii &= ~CFG_SPEED_1250;
472+ break;
473+ default:
474+ ENET_INTERFACE_MODE2_SET(&mc2, 2);
475+ intf_ctl |= ENET_GHD_MODE;
476+ CFG_TXCLK_MUXSEL0_SET(&rgmii, 4);
477+ xgene_enet_rd_csr(pdata, DEBUG_REG_ADDR, &value);
478+ value |= CFG_BYPASS_UNISEC_TX | CFG_BYPASS_UNISEC_RX;
479+ xgene_enet_wr_csr(pdata, DEBUG_REG_ADDR, value);
480+ break;
481+ }
482+
483+ mc2 |= FULL_DUPLEX2;
484+ xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_2_ADDR, mc2);
485+ xgene_enet_wr_mcx_mac(pdata, INTERFACE_CONTROL_ADDR, intf_ctl);
486+
487+ xgene_gmac_set_mac_addr(pdata);
488+
489+ /* Adjust MDC clock frequency */
490+ xgene_enet_rd_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, &value);
491+ MGMT_CLOCK_SEL_SET(&value, 7);
492+ xgene_enet_wr_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, value);
493+
494+ /* Enable drop if bufpool not available */
495+ xgene_enet_rd_csr(pdata, RSIF_CONFIG_REG_ADDR, &value);
496+ value |= CFG_RSIF_FPBUFF_TIMEOUT_EN;
497+ xgene_enet_wr_csr(pdata, RSIF_CONFIG_REG_ADDR, value);
498+
499+ /* Rtype should be copied from FP */
500+ xgene_enet_wr_csr(pdata, RSIF_RAM_DBG_REG0_ADDR, 0);
501+ xgene_enet_wr_csr(pdata, RGMII_REG_0_ADDR, rgmii);
502+
503+ /* Rx-Tx traffic resume */
504+ xgene_enet_wr_csr(pdata, CFG_LINK_AGGR_RESUME_0_ADDR, TX_PORT0);
505+
506+ xgene_enet_wr_mcx_csr(pdata, ICM_CONFIG0_REG_0_ADDR, icm0);
507+ xgene_enet_wr_mcx_csr(pdata, ICM_CONFIG2_REG_0_ADDR, icm2);
508+
509+ xgene_enet_rd_mcx_csr(pdata, RX_DV_GATE_REG_0_ADDR, &value);
510+ value &= ~TX_DV_GATE_EN0;
511+ value &= ~RX_DV_GATE_EN0;
512+ value |= RESUME_RX0;
513+ xgene_enet_wr_mcx_csr(pdata, RX_DV_GATE_REG_0_ADDR, value);
514+
515+ xgene_enet_wr_csr(pdata, CFG_BYPASS_ADDR, RESUME_TX);
516+}
517+
518+static void xgene_enet_config_ring_if_assoc(struct xgene_enet_pdata *pdata)
519+{
520+ u32 val = 0xffffffff;
521+
522+ xgene_enet_wr_ring_if(pdata, ENET_CFGSSQMIWQASSOC_ADDR, val);
523+ xgene_enet_wr_ring_if(pdata, ENET_CFGSSQMIFPQASSOC_ADDR, val);
524+ xgene_enet_wr_ring_if(pdata, ENET_CFGSSQMIQMLITEWQASSOC_ADDR, val);
525+ xgene_enet_wr_ring_if(pdata, ENET_CFGSSQMIQMLITEFPQASSOC_ADDR, val);
526+}
527+
528+void xgene_enet_cle_bypass(struct xgene_enet_pdata *pdata,
529+ u32 dst_ring_num, u16 bufpool_id)
530+{
531+ u32 cb;
532+ u32 fpsel;
533+
534+ fpsel = xgene_enet_ring_bufnum(bufpool_id) - 0x20;
535+
536+ xgene_enet_rd_csr(pdata, CLE_BYPASS_REG0_0_ADDR, &cb);
537+ cb |= CFG_CLE_BYPASS_EN0;
538+ CFG_CLE_IP_PROTOCOL0_SET(&cb, 3);
539+ xgene_enet_wr_csr(pdata, CLE_BYPASS_REG0_0_ADDR, cb);
540+
541+ xgene_enet_rd_csr(pdata, CLE_BYPASS_REG1_0_ADDR, &cb);
542+ CFG_CLE_DSTQID0_SET(&cb, dst_ring_num);
543+ CFG_CLE_FPSEL0_SET(&cb, fpsel);
544+ xgene_enet_wr_csr(pdata, CLE_BYPASS_REG1_0_ADDR, cb);
545+}
546+
547+void xgene_gmac_rx_enable(struct xgene_enet_pdata *pdata)
548+{
549+ u32 data;
550+
551+ xgene_enet_rd_mcx_mac(pdata, MAC_CONFIG_1_ADDR, &data);
552+ xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data | RX_EN);
553+}
554+
555+void xgene_gmac_tx_enable(struct xgene_enet_pdata *pdata)
556+{
557+ u32 data;
558+
559+ xgene_enet_rd_mcx_mac(pdata, MAC_CONFIG_1_ADDR, &data);
560+ xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data | TX_EN);
561+}
562+
563+void xgene_gmac_rx_disable(struct xgene_enet_pdata *pdata)
564+{
565+ u32 data;
566+
567+ xgene_enet_rd_mcx_mac(pdata, MAC_CONFIG_1_ADDR, &data);
568+ xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data & ~RX_EN);
569+}
570+
571+void xgene_gmac_tx_disable(struct xgene_enet_pdata *pdata)
572+{
573+ u32 data;
574+
575+ xgene_enet_rd_mcx_mac(pdata, MAC_CONFIG_1_ADDR, &data);
576+ xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data & ~TX_EN);
577+}
578+
579+void xgene_enet_reset(struct xgene_enet_pdata *pdata)
580+{
581+ u32 val;
582+
583+ clk_prepare_enable(pdata->clk);
584+ clk_disable_unprepare(pdata->clk);
585+ clk_prepare_enable(pdata->clk);
586+ xgene_enet_ecc_init(pdata);
587+ xgene_enet_config_ring_if_assoc(pdata);
588+
589+ /* Enable auto-incr for scanning */
590+ xgene_enet_rd_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, &val);
591+ val |= SCAN_AUTO_INCR;
592+ MGMT_CLOCK_SEL_SET(&val, 1);
593+ xgene_enet_wr_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, val);
594+}
595+
596+void xgene_gport_shutdown(struct xgene_enet_pdata *pdata)
597+{
598+ clk_disable_unprepare(pdata->clk);
599+}
600+
601+static int xgene_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
602+{
603+ struct xgene_enet_pdata *pdata = bus->priv;
604+ u32 val;
605+
606+ val = xgene_mii_phy_read(pdata, mii_id, regnum);
607+ netdev_dbg(pdata->ndev, "mdio_rd: bus=%d reg=%d val=%x\n",
608+ mii_id, regnum, val);
609+
610+ return val;
611+}
612+
613+static int xgene_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
614+ u16 val)
615+{
616+ struct xgene_enet_pdata *pdata = bus->priv;
617+
618+ netdev_dbg(pdata->ndev, "mdio_wr: bus=%d reg=%d val=%x\n",
619+ mii_id, regnum, val);
620+ return xgene_mii_phy_write(pdata, mii_id, regnum, val);
621+}
622+
623+static void xgene_enet_adjust_link(struct net_device *ndev)
624+{
625+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
626+ struct phy_device *phydev = pdata->phy_dev;
627+
628+ if (phydev->link) {
629+ if (pdata->phy_speed != phydev->speed) {
630+ xgene_gmac_init(pdata, phydev->speed);
631+ xgene_gmac_rx_enable(pdata);
632+ xgene_gmac_tx_enable(pdata);
633+ pdata->phy_speed = phydev->speed;
634+ phy_print_status(phydev);
635+ }
636+ } else {
637+ xgene_gmac_rx_disable(pdata);
638+ xgene_gmac_tx_disable(pdata);
639+ pdata->phy_speed = SPEED_UNKNOWN;
640+ phy_print_status(phydev);
641+ }
642+}
643+
644+static int xgene_enet_phy_connect(struct net_device *ndev)
645+{
646+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
647+ struct device_node *phy_np;
648+ struct phy_device *phy_dev;
649+ struct device *dev = &pdata->pdev->dev;
650+
651+ phy_np = of_parse_phandle(dev->of_node, "phy-handle", 0);
652+ if (!phy_np) {
653+ netdev_dbg(ndev, "No phy-handle found\n");
654+ return -ENODEV;
655+ }
656+
657+ phy_dev = of_phy_connect(ndev, phy_np, &xgene_enet_adjust_link,
658+ 0, pdata->phy_mode);
659+ if (!phy_dev) {
660+ netdev_err(ndev, "Could not connect to PHY\n");
661+ return -ENODEV;
662+ }
663+
664+ pdata->phy_speed = SPEED_UNKNOWN;
665+ phy_dev->supported &= ~SUPPORTED_10baseT_Half &
666+ ~SUPPORTED_100baseT_Half &
667+ ~SUPPORTED_1000baseT_Half;
668+ phy_dev->advertising = phy_dev->supported;
669+ pdata->phy_dev = phy_dev;
670+
671+ return 0;
672+}
673+
674+int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata)
675+{
676+ struct net_device *ndev = pdata->ndev;
677+ struct device *dev = &pdata->pdev->dev;
678+ struct device_node *child_np;
679+ struct device_node *mdio_np = NULL;
680+ struct mii_bus *mdio_bus;
681+ int ret;
682+
683+ for_each_child_of_node(dev->of_node, child_np) {
684+ if (of_device_is_compatible(child_np, "apm,xgene-mdio")) {
685+ mdio_np = child_np;
686+ break;
687+ }
688+ }
689+
690+ if (!mdio_np) {
691+ netdev_dbg(ndev, "No mdio node in the dts\n");
692+ return -ENXIO;
693+ }
694+
695+ mdio_bus = mdiobus_alloc();
696+ if (!mdio_bus)
697+ return -ENOMEM;
698+
699+ mdio_bus->name = "APM X-Gene MDIO bus";
700+ mdio_bus->read = xgene_enet_mdio_read;
701+ mdio_bus->write = xgene_enet_mdio_write;
702+ snprintf(mdio_bus->id, MII_BUS_ID_SIZE, "%s-%s", "xgene-mii",
703+ ndev->name);
704+
705+ mdio_bus->priv = pdata;
706+ mdio_bus->parent = &ndev->dev;
707+
708+ ret = of_mdiobus_register(mdio_bus, mdio_np);
709+ if (ret) {
710+ netdev_err(ndev, "Failed to register MDIO bus\n");
711+ mdiobus_free(mdio_bus);
712+ return ret;
713+ }
714+ pdata->mdio_bus = mdio_bus;
715+
716+ ret = xgene_enet_phy_connect(ndev);
717+ if (ret)
718+ xgene_enet_mdio_remove(pdata);
719+
720+ return ret;
721+}
722+
723+void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata)
724+{
725+ mdiobus_unregister(pdata->mdio_bus);
726+ mdiobus_free(pdata->mdio_bus);
727+ pdata->mdio_bus = NULL;
728+}
drivers/net/ethernet/apm/xgene/xgene_enet_hw.h+337−0
@@ -0,0 +1,337 @@
1+/* Applied Micro X-Gene SoC Ethernet Driver
2+ *
3+ * Copyright (c) 2014, Applied Micro Circuits Corporation
4+ * Authors: Iyappan Subramanian <isubramanian@apm.com>
5+ * Ravi Patel <rapatel@apm.com>
6+ * Keyur Chudgar <kchudgar@apm.com>
7+ *
8+ * This program is free software; you can redistribute it and/or modify it
9+ * under the terms of the GNU General Public License as published by the
10+ * Free Software Foundation; either version 2 of the License, or (at your
11+ * option) any later version.
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+#ifndef __XGENE_ENET_HW_H__
23+#define __XGENE_ENET_HW_H__
24+
25+#include "xgene_enet_main.h"
26+
27+struct xgene_enet_pdata;
28+struct xgene_enet_stats;
29+
30+/* clears and then set bits */
31+static inline void xgene_set_bits(u32 *dst, u32 val, u32 start, u32 len)
32+{
33+ u32 end = start + len - 1;
34+ u32 mask = GENMASK(end, start);
35+
36+ *dst &= ~mask;
37+ *dst |= (val << start) & mask;
38+}
39+
40+static inline u32 xgene_get_bits(u32 val, u32 start, u32 end)
41+{
42+ return (val & GENMASK(end, start)) >> start;
43+}
44+
45+#define CSR_RING_ID 0x0008
46+#define OVERWRITE BIT(31)
47+#define IS_BUFFER_POOL BIT(20)
48+#define PREFETCH_BUF_EN BIT(21)
49+#define CSR_RING_ID_BUF 0x000c
50+#define CSR_RING_NE_INT_MODE 0x017c
51+#define CSR_RING_CONFIG 0x006c
52+#define CSR_RING_WR_BASE 0x0070
53+#define NUM_RING_CONFIG 5
54+#define BUFPOOL_MODE 3
55+#define RM3 3
56+#define INC_DEC_CMD_ADDR 0x002c
57+#define UDP_HDR_SIZE 2
58+#define BUF_LEN_CODE_2K 0x5000
59+
60+#define CREATE_MASK(pos, len) GENMASK((pos)+(len)-1, (pos))
61+#define CREATE_MASK_ULL(pos, len) GENMASK_ULL((pos)+(len)-1, (pos))
62+
63+/* Empty slot soft signature */
64+#define EMPTY_SLOT_INDEX 1
65+#define EMPTY_SLOT ~0ULL
66+
67+#define WORK_DESC_SIZE 32
68+#define BUFPOOL_DESC_SIZE 16
69+
70+#define RING_OWNER_MASK GENMASK(9, 6)
71+#define RING_BUFNUM_MASK GENMASK(5, 0)
72+
73+#define SELTHRSH_POS 3
74+#define SELTHRSH_LEN 3
75+#define RINGADDRL_POS 5
76+#define RINGADDRL_LEN 27
77+#define RINGADDRH_POS 0
78+#define RINGADDRH_LEN 6
79+#define RINGSIZE_POS 23
80+#define RINGSIZE_LEN 3
81+#define RINGTYPE_POS 19
82+#define RINGTYPE_LEN 2
83+#define RINGMODE_POS 20
84+#define RINGMODE_LEN 3
85+#define RECOMTIMEOUTL_POS 28
86+#define RECOMTIMEOUTL_LEN 3
87+#define RECOMTIMEOUTH_POS 0
88+#define RECOMTIMEOUTH_LEN 2
89+#define NUMMSGSINQ_POS 1
90+#define NUMMSGSINQ_LEN 16
91+#define ACCEPTLERR BIT(19)
92+#define QCOHERENT BIT(4)
93+#define RECOMBBUF BIT(27)
94+
95+#define BLOCK_ETH_CSR_OFFSET 0x2000
96+#define BLOCK_ETH_RING_IF_OFFSET 0x9000
97+#define BLOCK_ETH_CLKRST_CSR_OFFSET 0xC000
98+#define BLOCK_ETH_DIAG_CSR_OFFSET 0xD000
99+
100+#define BLOCK_ETH_MAC_OFFSET 0x0000
101+#define BLOCK_ETH_STATS_OFFSET 0x0014
102+#define BLOCK_ETH_MAC_CSR_OFFSET 0x2800
103+
104+#define MAC_ADDR_REG_OFFSET 0x00
105+#define MAC_COMMAND_REG_OFFSET 0x04
106+#define MAC_WRITE_REG_OFFSET 0x08
107+#define MAC_READ_REG_OFFSET 0x0c
108+#define MAC_COMMAND_DONE_REG_OFFSET 0x10
109+
110+#define STAT_ADDR_REG_OFFSET 0x00
111+#define STAT_COMMAND_REG_OFFSET 0x04
112+#define STAT_WRITE_REG_OFFSET 0x08
113+#define STAT_READ_REG_OFFSET 0x0c
114+#define STAT_COMMAND_DONE_REG_OFFSET 0x10
115+
116+#define MII_MGMT_CONFIG_ADDR 0x20
117+#define MII_MGMT_COMMAND_ADDR 0x24
118+#define MII_MGMT_ADDRESS_ADDR 0x28
119+#define MII_MGMT_CONTROL_ADDR 0x2c
120+#define MII_MGMT_STATUS_ADDR 0x30
121+#define MII_MGMT_INDICATORS_ADDR 0x34
122+
123+#define BUSY_MASK BIT(0)
124+#define READ_CYCLE_MASK BIT(0)
125+#define PHY_CONTROL_SET(dst, val) xgene_set_bits(dst, val, 0, 16)
126+
127+#define ENET_SPARE_CFG_REG_ADDR 0x0750
128+#define RSIF_CONFIG_REG_ADDR 0x0010
129+#define RSIF_RAM_DBG_REG0_ADDR 0x0048
130+#define RGMII_REG_0_ADDR 0x07e0
131+#define CFG_LINK_AGGR_RESUME_0_ADDR 0x07c8
132+#define DEBUG_REG_ADDR 0x0700
133+#define CFG_BYPASS_ADDR 0x0294
134+#define CLE_BYPASS_REG0_0_ADDR 0x0490
135+#define CLE_BYPASS_REG1_0_ADDR 0x0494
136+#define CFG_RSIF_FPBUFF_TIMEOUT_EN BIT(31)
137+#define RESUME_TX BIT(0)
138+#define CFG_SPEED_1250 BIT(24)
139+#define TX_PORT0 BIT(0)
140+#define CFG_BYPASS_UNISEC_TX BIT(2)
141+#define CFG_BYPASS_UNISEC_RX BIT(1)
142+#define CFG_CLE_BYPASS_EN0 BIT(31)
143+#define CFG_TXCLK_MUXSEL0_SET(dst, val) xgene_set_bits(dst, val, 29, 3)
144+
145+#define CFG_CLE_IP_PROTOCOL0_SET(dst, val) xgene_set_bits(dst, val, 16, 2)
146+#define CFG_CLE_DSTQID0_SET(dst, val) xgene_set_bits(dst, val, 0, 12)
147+#define CFG_CLE_FPSEL0_SET(dst, val) xgene_set_bits(dst, val, 16, 4)
148+#define CFG_MACMODE_SET(dst, val) xgene_set_bits(dst, val, 18, 2)
149+#define CFG_WAITASYNCRD_SET(dst, val) xgene_set_bits(dst, val, 0, 16)
150+#define ICM_CONFIG0_REG_0_ADDR 0x0400
151+#define ICM_CONFIG2_REG_0_ADDR 0x0410
152+#define RX_DV_GATE_REG_0_ADDR 0x05fc
153+#define TX_DV_GATE_EN0 BIT(2)
154+#define RX_DV_GATE_EN0 BIT(1)
155+#define RESUME_RX0 BIT(0)
156+#define ENET_CFGSSQMIWQASSOC_ADDR 0xe0
157+#define ENET_CFGSSQMIFPQASSOC_ADDR 0xdc
158+#define ENET_CFGSSQMIQMLITEFPQASSOC_ADDR 0xf0
159+#define ENET_CFGSSQMIQMLITEWQASSOC_ADDR 0xf4
160+#define ENET_CFG_MEM_RAM_SHUTDOWN_ADDR 0x70
161+#define ENET_BLOCK_MEM_RDY_ADDR 0x74
162+#define MAC_CONFIG_1_ADDR 0x00
163+#define MAC_CONFIG_2_ADDR 0x04
164+#define MAX_FRAME_LEN_ADDR 0x10
165+#define INTERFACE_CONTROL_ADDR 0x38
166+#define STATION_ADDR0_ADDR 0x40
167+#define STATION_ADDR1_ADDR 0x44
168+#define PHY_ADDR_SET(dst, val) xgene_set_bits(dst, val, 8, 5)
169+#define REG_ADDR_SET(dst, val) xgene_set_bits(dst, val, 0, 5)
170+#define ENET_INTERFACE_MODE2_SET(dst, val) xgene_set_bits(dst, val, 8, 2)
171+#define MGMT_CLOCK_SEL_SET(dst, val) xgene_set_bits(dst, val, 0, 3)
172+#define SOFT_RESET1 BIT(31)
173+#define TX_EN BIT(0)
174+#define RX_EN BIT(2)
175+#define ENET_LHD_MODE BIT(25)
176+#define ENET_GHD_MODE BIT(26)
177+#define FULL_DUPLEX2 BIT(0)
178+#define SCAN_AUTO_INCR BIT(5)
179+#define TBYT_ADDR 0x38
180+#define TPKT_ADDR 0x39
181+#define TDRP_ADDR 0x45
182+#define TFCS_ADDR 0x47
183+#define TUND_ADDR 0x4a
184+
185+#define TSO_IPPROTO_TCP 1
186+#define FULL_DUPLEX 2
187+
188+#define USERINFO_POS 0
189+#define USERINFO_LEN 32
190+#define FPQNUM_POS 32
191+#define FPQNUM_LEN 12
192+#define LERR_POS 60
193+#define LERR_LEN 3
194+#define STASH_POS 52
195+#define STASH_LEN 2
196+#define BUFDATALEN_POS 48
197+#define BUFDATALEN_LEN 12
198+#define DATAADDR_POS 0
199+#define DATAADDR_LEN 42
200+#define COHERENT_POS 63
201+#define HENQNUM_POS 48
202+#define HENQNUM_LEN 12
203+#define TYPESEL_POS 44
204+#define TYPESEL_LEN 4
205+#define ETHHDR_POS 12
206+#define ETHHDR_LEN 8
207+#define IC_POS 35 /* Insert CRC */
208+#define TCPHDR_POS 0
209+#define TCPHDR_LEN 6
210+#define IPHDR_POS 6
211+#define IPHDR_LEN 6
212+#define EC_POS 22 /* Enable checksum */
213+#define EC_LEN 1
214+#define IS_POS 24 /* IP protocol select */
215+#define IS_LEN 1
216+#define TYPE_ETH_WORK_MESSAGE_POS 44
217+
218+struct xgene_enet_raw_desc {
219+ __le64 m0;
220+ __le64 m1;
221+ __le64 m2;
222+ __le64 m3;
223+};
224+
225+struct xgene_enet_raw_desc16 {
226+ __le64 m0;
227+ __le64 m1;
228+};
229+
230+static inline void xgene_enet_mark_desc_slot_empty(void *desc_slot_ptr)
231+{
232+ __le64 *desc_slot = desc_slot_ptr;
233+
234+ desc_slot[EMPTY_SLOT_INDEX] = cpu_to_le64(EMPTY_SLOT);
235+}
236+
237+static inline bool xgene_enet_is_desc_slot_empty(void *desc_slot_ptr)
238+{
239+ __le64 *desc_slot = desc_slot_ptr;
240+
241+ return (desc_slot[EMPTY_SLOT_INDEX] == cpu_to_le64(EMPTY_SLOT));
242+}
243+
244+enum xgene_enet_ring_cfgsize {
245+ RING_CFGSIZE_512B,
246+ RING_CFGSIZE_2KB,
247+ RING_CFGSIZE_16KB,
248+ RING_CFGSIZE_64KB,
249+ RING_CFGSIZE_512KB,
250+ RING_CFGSIZE_INVALID
251+};
252+
253+enum xgene_enet_ring_type {
254+ RING_DISABLED,
255+ RING_REGULAR,
256+ RING_BUFPOOL
257+};
258+
259+enum xgene_ring_owner {
260+ RING_OWNER_ETH0,
261+ RING_OWNER_CPU = 15,
262+ RING_OWNER_INVALID
263+};
264+
265+enum xgene_enet_ring_bufnum {
266+ RING_BUFNUM_REGULAR = 0x0,
267+ RING_BUFNUM_BUFPOOL = 0x20,
268+ RING_BUFNUM_INVALID
269+};
270+
271+enum xgene_enet_cmd {
272+ XGENE_ENET_WR_CMD = BIT(31),
273+ XGENE_ENET_RD_CMD = BIT(30)
274+};
275+
276+enum xgene_enet_err_code {
277+ HBF_READ_DATA = 3,
278+ HBF_LL_READ = 4,
279+ BAD_WORK_MSG = 6,
280+ BUFPOOL_TIMEOUT = 15,
281+ INGRESS_CRC = 16,
282+ INGRESS_CHECKSUM = 17,
283+ INGRESS_TRUNC_FRAME = 18,
284+ INGRESS_PKT_LEN = 19,
285+ INGRESS_PKT_UNDER = 20,
286+ INGRESS_FIFO_OVERRUN = 21,
287+ INGRESS_CHECKSUM_COMPUTE = 26,
288+ ERR_CODE_INVALID
289+};
290+
291+static inline enum xgene_ring_owner xgene_enet_ring_owner(u16 id)
292+{
293+ return (id & RING_OWNER_MASK) >> 6;
294+}
295+
296+static inline u8 xgene_enet_ring_bufnum(u16 id)
297+{
298+ return id & RING_BUFNUM_MASK;
299+}
300+
301+static inline bool xgene_enet_is_bufpool(u16 id)
302+{
303+ return ((id & RING_BUFNUM_MASK) >= 0x20) ? true : false;
304+}
305+
306+static inline u16 xgene_enet_get_numslots(u16 id, u32 size)
307+{
308+ bool is_bufpool = xgene_enet_is_bufpool(id);
309+
310+ return (is_bufpool) ? size / BUFPOOL_DESC_SIZE :
311+ size / WORK_DESC_SIZE;
312+}
313+
314+struct xgene_enet_desc_ring *xgene_enet_setup_ring(
315+ struct xgene_enet_desc_ring *ring);
316+void xgene_enet_clear_ring(struct xgene_enet_desc_ring *ring);
317+void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
318+ struct xgene_enet_pdata *pdata,
319+ enum xgene_enet_err_code status);
320+
321+void xgene_enet_reset(struct xgene_enet_pdata *priv);
322+void xgene_gmac_reset(struct xgene_enet_pdata *priv);
323+void xgene_gmac_init(struct xgene_enet_pdata *priv, int speed);
324+void xgene_gmac_tx_enable(struct xgene_enet_pdata *priv);
325+void xgene_gmac_rx_enable(struct xgene_enet_pdata *priv);
326+void xgene_gmac_tx_disable(struct xgene_enet_pdata *priv);
327+void xgene_gmac_rx_disable(struct xgene_enet_pdata *priv);
328+void xgene_gmac_set_mac_addr(struct xgene_enet_pdata *pdata);
329+void xgene_enet_cle_bypass(struct xgene_enet_pdata *pdata,
330+ u32 dst_ring_num, u16 bufpool_id);
331+void xgene_gport_shutdown(struct xgene_enet_pdata *priv);
332+void xgene_gmac_get_tx_stats(struct xgene_enet_pdata *pdata);
333+
334+int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata);
335+void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata);
336+
337+#endif /* __XGENE_ENET_HW_H__ */
drivers/net/ethernet/apm/xgene/xgene_enet_main.c+951−0
@@ -0,0 +1,951 @@
1+/* Applied Micro X-Gene SoC Ethernet Driver
2+ *
3+ * Copyright (c) 2014, Applied Micro Circuits Corporation
4+ * Authors: Iyappan Subramanian <isubramanian@apm.com>
5+ * Ravi Patel <rapatel@apm.com>
6+ * Keyur Chudgar <kchudgar@apm.com>
7+ *
8+ * This program is free software; you can redistribute it and/or modify it
9+ * under the terms of the GNU General Public License as published by the
10+ * Free Software Foundation; either version 2 of the License, or (at your
11+ * option) any later version.
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 "xgene_enet_main.h"
23+#include "xgene_enet_hw.h"
24+
25+static void xgene_enet_init_bufpool(struct xgene_enet_desc_ring *buf_pool)
26+{
27+ struct xgene_enet_raw_desc16 *raw_desc;
28+ int i;
29+
30+ for (i = 0; i < buf_pool->slots; i++) {
31+ raw_desc = &buf_pool->raw_desc16[i];
32+
33+ /* Hardware expects descriptor in little endian format */
34+ raw_desc->m0 = cpu_to_le64(i |
35+ SET_VAL(FPQNUM, buf_pool->dst_ring_num) |
36+ SET_VAL(STASH, 3));
37+ }
38+}
39+
40+static int xgene_enet_refill_bufpool(struct xgene_enet_desc_ring *buf_pool,
41+ u32 nbuf)
42+{
43+ struct sk_buff *skb;
44+ struct xgene_enet_raw_desc16 *raw_desc;
45+ struct net_device *ndev;
46+ struct device *dev;
47+ dma_addr_t dma_addr;
48+ u32 tail = buf_pool->tail;
49+ u32 slots = buf_pool->slots - 1;
50+ u16 bufdatalen, len;
51+ int i;
52+
53+ ndev = buf_pool->ndev;
54+ dev = ndev_to_dev(buf_pool->ndev);
55+ bufdatalen = BUF_LEN_CODE_2K | (SKB_BUFFER_SIZE & GENMASK(11, 0));
56+ len = XGENE_ENET_MAX_MTU;
57+
58+ for (i = 0; i < nbuf; i++) {
59+ raw_desc = &buf_pool->raw_desc16[tail];
60+
61+ skb = netdev_alloc_skb_ip_align(ndev, len);
62+ if (unlikely(!skb))
63+ return -ENOMEM;
64+ buf_pool->rx_skb[tail] = skb;
65+
66+ dma_addr = dma_map_single(dev, skb->data, len, DMA_FROM_DEVICE);
67+ if (dma_mapping_error(dev, dma_addr)) {
68+ netdev_err(ndev, "DMA mapping error\n");
69+ dev_kfree_skb_any(skb);
70+ return -EINVAL;
71+ }
72+
73+ raw_desc->m1 = cpu_to_le64(SET_VAL(DATAADDR, dma_addr) |
74+ SET_VAL(BUFDATALEN, bufdatalen) |
75+ SET_BIT(COHERENT));
76+ tail = (tail + 1) & slots;
77+ }
78+
79+ iowrite32(nbuf, buf_pool->cmd);
80+ buf_pool->tail = tail;
81+
82+ return 0;
83+}
84+
85+static u16 xgene_enet_dst_ring_num(struct xgene_enet_desc_ring *ring)
86+{
87+ struct xgene_enet_pdata *pdata = netdev_priv(ring->ndev);
88+
89+ return ((u16)pdata->rm << 10) | ring->num;
90+}
91+
92+static u8 xgene_enet_hdr_len(const void *data)
93+{
94+ const struct ethhdr *eth = data;
95+
96+ return (eth->h_proto == htons(ETH_P_8021Q)) ? VLAN_ETH_HLEN : ETH_HLEN;
97+}
98+
99+static u32 xgene_enet_ring_len(struct xgene_enet_desc_ring *ring)
100+{
101+ u32 __iomem *cmd_base = ring->cmd_base;
102+ u32 ring_state, num_msgs;
103+
104+ ring_state = ioread32(&cmd_base[1]);
105+ num_msgs = ring_state & CREATE_MASK(NUMMSGSINQ_POS, NUMMSGSINQ_LEN);
106+
107+ return num_msgs >> NUMMSGSINQ_POS;
108+}
109+
110+static void xgene_enet_delete_bufpool(struct xgene_enet_desc_ring *buf_pool)
111+{
112+ struct xgene_enet_raw_desc16 *raw_desc;
113+ u32 slots = buf_pool->slots - 1;
114+ u32 tail = buf_pool->tail;
115+ u32 userinfo;
116+ int i, len;
117+
118+ len = xgene_enet_ring_len(buf_pool);
119+ for (i = 0; i < len; i++) {
120+ tail = (tail - 1) & slots;
121+ raw_desc = &buf_pool->raw_desc16[tail];
122+
123+ /* Hardware stores descriptor in little endian format */
124+ userinfo = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0));
125+ dev_kfree_skb_any(buf_pool->rx_skb[userinfo]);
126+ }
127+
128+ iowrite32(-len, buf_pool->cmd);
129+ buf_pool->tail = tail;
130+}
131+
132+static irqreturn_t xgene_enet_rx_irq(const int irq, void *data)
133+{
134+ struct xgene_enet_desc_ring *rx_ring = data;
135+
136+ if (napi_schedule_prep(&rx_ring->napi)) {
137+ disable_irq_nosync(irq);
138+ __napi_schedule(&rx_ring->napi);
139+ }
140+
141+ return IRQ_HANDLED;
142+}
143+
144+static int xgene_enet_tx_completion(struct xgene_enet_desc_ring *cp_ring,
145+ struct xgene_enet_raw_desc *raw_desc)
146+{
147+ struct sk_buff *skb;
148+ struct device *dev;
149+ u16 skb_index;
150+ u8 status;
151+ int ret = 0;
152+
153+ skb_index = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0));
154+ skb = cp_ring->cp_skb[skb_index];
155+
156+ dev = ndev_to_dev(cp_ring->ndev);
157+ dma_unmap_single(dev, GET_VAL(DATAADDR, le64_to_cpu(raw_desc->m1)),
158+ GET_VAL(BUFDATALEN, le64_to_cpu(raw_desc->m1)),
159+ DMA_TO_DEVICE);
160+
161+ /* Checking for error */
162+ status = GET_VAL(LERR, le64_to_cpu(raw_desc->m0));
163+ if (unlikely(status > 2)) {
164+ xgene_enet_parse_error(cp_ring, netdev_priv(cp_ring->ndev),
165+ status);
166+ ret = -EIO;
167+ }
168+
169+ if (likely(skb)) {
170+ dev_kfree_skb_any(skb);
171+ } else {
172+ netdev_err(cp_ring->ndev, "completion skb is NULL\n");
173+ ret = -EIO;
174+ }
175+
176+ return ret;
177+}
178+
179+static u64 xgene_enet_work_msg(struct sk_buff *skb)
180+{
181+ struct iphdr *iph;
182+ u8 l3hlen, l4hlen = 0;
183+ u8 csum_enable = 0;
184+ u8 proto = 0;
185+ u8 ethhdr;
186+ u64 hopinfo;
187+
188+ if (unlikely(skb->protocol != htons(ETH_P_IP)) &&
189+ unlikely(skb->protocol != htons(ETH_P_8021Q)))
190+ goto out;
191+
192+ if (unlikely(!(skb->dev->features & NETIF_F_IP_CSUM)))
193+ goto out;
194+
195+ iph = ip_hdr(skb);
196+ if (unlikely(ip_is_fragment(iph)))
197+ goto out;
198+
199+ if (likely(iph->protocol == IPPROTO_TCP)) {
200+ l4hlen = tcp_hdrlen(skb) >> 2;
201+ csum_enable = 1;
202+ proto = TSO_IPPROTO_TCP;
203+ } else if (iph->protocol == IPPROTO_UDP) {
204+ l4hlen = UDP_HDR_SIZE;
205+ csum_enable = 1;
206+ }
207+out:
208+ l3hlen = ip_hdrlen(skb) >> 2;
209+ ethhdr = xgene_enet_hdr_len(skb->data);
210+ hopinfo = SET_VAL(TCPHDR, l4hlen) |
211+ SET_VAL(IPHDR, l3hlen) |
212+ SET_VAL(ETHHDR, ethhdr) |
213+ SET_VAL(EC, csum_enable) |
214+ SET_VAL(IS, proto) |
215+ SET_BIT(IC) |
216+ SET_BIT(TYPE_ETH_WORK_MESSAGE);
217+
218+ return hopinfo;
219+}
220+
221+static int xgene_enet_setup_tx_desc(struct xgene_enet_desc_ring *tx_ring,
222+ struct sk_buff *skb)
223+{
224+ struct device *dev = ndev_to_dev(tx_ring->ndev);
225+ struct xgene_enet_raw_desc *raw_desc;
226+ dma_addr_t dma_addr;
227+ u16 tail = tx_ring->tail;
228+ u64 hopinfo;
229+
230+ raw_desc = &tx_ring->raw_desc[tail];
231+ memset(raw_desc, 0, sizeof(struct xgene_enet_raw_desc));
232+
233+ dma_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
234+ if (dma_mapping_error(dev, dma_addr)) {
235+ netdev_err(tx_ring->ndev, "DMA mapping error\n");
236+ return -EINVAL;
237+ }
238+
239+ /* Hardware expects descriptor in little endian format */
240+ raw_desc->m0 = cpu_to_le64(tail);
241+ raw_desc->m1 = cpu_to_le64(SET_VAL(DATAADDR, dma_addr) |
242+ SET_VAL(BUFDATALEN, skb->len) |
243+ SET_BIT(COHERENT));
244+ hopinfo = xgene_enet_work_msg(skb);
245+ raw_desc->m3 = cpu_to_le64(SET_VAL(HENQNUM, tx_ring->dst_ring_num) |
246+ hopinfo);
247+ tx_ring->cp_ring->cp_skb[tail] = skb;
248+
249+ return 0;
250+}
251+
252+static netdev_tx_t xgene_enet_start_xmit(struct sk_buff *skb,
253+ struct net_device *ndev)
254+{
255+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
256+ struct xgene_enet_desc_ring *tx_ring = pdata->tx_ring;
257+ struct xgene_enet_desc_ring *cp_ring = tx_ring->cp_ring;
258+ u32 tx_level, cq_level;
259+
260+ tx_level = xgene_enet_ring_len(tx_ring);
261+ cq_level = xgene_enet_ring_len(cp_ring);
262+ if (unlikely(tx_level > pdata->tx_qcnt_hi ||
263+ cq_level > pdata->cp_qcnt_hi)) {
264+ netif_stop_queue(ndev);
265+ return NETDEV_TX_BUSY;
266+ }
267+
268+ if (xgene_enet_setup_tx_desc(tx_ring, skb)) {
269+ dev_kfree_skb_any(skb);
270+ return NETDEV_TX_OK;
271+ }
272+
273+ iowrite32(1, tx_ring->cmd);
274+ skb_tx_timestamp(skb);
275+ tx_ring->tail = (tx_ring->tail + 1) & (tx_ring->slots - 1);
276+
277+ pdata->stats.tx_packets++;
278+ pdata->stats.tx_bytes += skb->len;
279+
280+ return NETDEV_TX_OK;
281+}
282+
283+static void xgene_enet_skip_csum(struct sk_buff *skb)
284+{
285+ struct iphdr *iph = ip_hdr(skb);
286+
287+ if (!ip_is_fragment(iph) ||
288+ (iph->protocol != IPPROTO_TCP && iph->protocol != IPPROTO_UDP)) {
289+ skb->ip_summed = CHECKSUM_UNNECESSARY;
290+ }
291+}
292+
293+static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
294+ struct xgene_enet_raw_desc *raw_desc)
295+{
296+ struct net_device *ndev;
297+ struct xgene_enet_pdata *pdata;
298+ struct device *dev;
299+ struct xgene_enet_desc_ring *buf_pool;
300+ u32 datalen, skb_index;
301+ struct sk_buff *skb;
302+ u8 status;
303+ int ret = 0;
304+
305+ ndev = rx_ring->ndev;
306+ pdata = netdev_priv(ndev);
307+ dev = ndev_to_dev(rx_ring->ndev);
308+ buf_pool = rx_ring->buf_pool;
309+
310+ dma_unmap_single(dev, GET_VAL(DATAADDR, le64_to_cpu(raw_desc->m1)),
311+ XGENE_ENET_MAX_MTU, DMA_FROM_DEVICE);
312+ skb_index = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0));
313+ skb = buf_pool->rx_skb[skb_index];
314+
315+ /* checking for error */
316+ status = GET_VAL(LERR, le64_to_cpu(raw_desc->m0));
317+ if (unlikely(status > 2)) {
318+ dev_kfree_skb_any(skb);
319+ xgene_enet_parse_error(rx_ring, netdev_priv(rx_ring->ndev),
320+ status);
321+ pdata->stats.rx_dropped++;
322+ ret = -EIO;
323+ goto out;
324+ }
325+
326+ /* strip off CRC as HW isn't doing this */
327+ datalen = GET_VAL(BUFDATALEN, le64_to_cpu(raw_desc->m1));
328+ datalen -= 4;
329+ prefetch(skb->data - NET_IP_ALIGN);
330+ skb_put(skb, datalen);
331+
332+ skb_checksum_none_assert(skb);
333+ skb->protocol = eth_type_trans(skb, ndev);
334+ if (likely((ndev->features & NETIF_F_IP_CSUM) &&
335+ skb->protocol == htons(ETH_P_IP))) {
336+ xgene_enet_skip_csum(skb);
337+ }
338+
339+ pdata->stats.rx_packets++;
340+ pdata->stats.rx_bytes += datalen;
341+ napi_gro_receive(&rx_ring->napi, skb);
342+out:
343+ if (--rx_ring->nbufpool == 0) {
344+ ret = xgene_enet_refill_bufpool(buf_pool, NUM_BUFPOOL);
345+ rx_ring->nbufpool = NUM_BUFPOOL;
346+ }
347+
348+ return ret;
349+}
350+
351+static bool is_rx_desc(struct xgene_enet_raw_desc *raw_desc)
352+{
353+ return GET_VAL(FPQNUM, le64_to_cpu(raw_desc->m0)) ? true : false;
354+}
355+
356+static int xgene_enet_process_ring(struct xgene_enet_desc_ring *ring,
357+ int budget)
358+{
359+ struct xgene_enet_pdata *pdata = netdev_priv(ring->ndev);
360+ struct xgene_enet_raw_desc *raw_desc;
361+ u16 head = ring->head;
362+ u16 slots = ring->slots - 1;
363+ int ret, count = 0;
364+
365+ do {
366+ raw_desc = &ring->raw_desc[head];
367+ if (unlikely(xgene_enet_is_desc_slot_empty(raw_desc)))
368+ break;
369+
370+ if (is_rx_desc(raw_desc))
371+ ret = xgene_enet_rx_frame(ring, raw_desc);
372+ else
373+ ret = xgene_enet_tx_completion(ring, raw_desc);
374+ xgene_enet_mark_desc_slot_empty(raw_desc);
375+
376+ head = (head + 1) & slots;
377+ count++;
378+
379+ if (ret)
380+ break;
381+ } while (--budget);
382+
383+ if (likely(count)) {
384+ iowrite32(-count, ring->cmd);
385+ ring->head = head;
386+
387+ if (netif_queue_stopped(ring->ndev)) {
388+ if (xgene_enet_ring_len(ring) < pdata->cp_qcnt_low)
389+ netif_wake_queue(ring->ndev);
390+ }
391+ }
392+
393+ return budget;
394+}
395+
396+static int xgene_enet_napi(struct napi_struct *napi, const int budget)
397+{
398+ struct xgene_enet_desc_ring *ring;
399+ int processed;
400+
401+ ring = container_of(napi, struct xgene_enet_desc_ring, napi);
402+ processed = xgene_enet_process_ring(ring, budget);
403+
404+ if (processed != budget) {
405+ napi_complete(napi);
406+ enable_irq(ring->irq);
407+ }
408+
409+ return processed;
410+}
411+
412+static void xgene_enet_timeout(struct net_device *ndev)
413+{
414+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
415+
416+ xgene_gmac_reset(pdata);
417+}
418+
419+static int xgene_enet_register_irq(struct net_device *ndev)
420+{
421+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
422+ struct device *dev = ndev_to_dev(ndev);
423+ int ret;
424+
425+ ret = devm_request_irq(dev, pdata->rx_ring->irq, xgene_enet_rx_irq,
426+ IRQF_SHARED, ndev->name, pdata->rx_ring);
427+ if (ret) {
428+ netdev_err(ndev, "rx%d interrupt request failed\n",
429+ pdata->rx_ring->irq);
430+ }
431+
432+ return ret;
433+}
434+
435+static void xgene_enet_free_irq(struct net_device *ndev)
436+{
437+ struct xgene_enet_pdata *pdata;
438+ struct device *dev;
439+
440+ pdata = netdev_priv(ndev);
441+ dev = ndev_to_dev(ndev);
442+ devm_free_irq(dev, pdata->rx_ring->irq, pdata->rx_ring);
443+}
444+
445+static int xgene_enet_open(struct net_device *ndev)
446+{
447+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
448+ int ret;
449+
450+ xgene_gmac_tx_enable(pdata);
451+ xgene_gmac_rx_enable(pdata);
452+
453+ ret = xgene_enet_register_irq(ndev);
454+ if (ret)
455+ return ret;
456+ napi_enable(&pdata->rx_ring->napi);
457+
458+ if (pdata->phy_dev)
459+ phy_start(pdata->phy_dev);
460+
461+ netif_start_queue(ndev);
462+
463+ return ret;
464+}
465+
466+static int xgene_enet_close(struct net_device *ndev)
467+{
468+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
469+
470+ netif_stop_queue(ndev);
471+
472+ if (pdata->phy_dev)
473+ phy_stop(pdata->phy_dev);
474+
475+ napi_disable(&pdata->rx_ring->napi);
476+ xgene_enet_free_irq(ndev);
477+ xgene_enet_process_ring(pdata->rx_ring, -1);
478+
479+ xgene_gmac_tx_disable(pdata);
480+ xgene_gmac_rx_disable(pdata);
481+
482+ return 0;
483+}
484+
485+static void xgene_enet_delete_ring(struct xgene_enet_desc_ring *ring)
486+{
487+ struct xgene_enet_pdata *pdata;
488+ struct device *dev;
489+
490+ pdata = netdev_priv(ring->ndev);
491+ dev = ndev_to_dev(ring->ndev);
492+
493+ xgene_enet_clear_ring(ring);
494+ dma_free_coherent(dev, ring->size, ring->desc_addr, ring->dma);
495+}
496+
497+static void xgene_enet_delete_desc_rings(struct xgene_enet_pdata *pdata)
498+{
499+ struct xgene_enet_desc_ring *buf_pool;
500+
501+ if (pdata->tx_ring) {
502+ xgene_enet_delete_ring(pdata->tx_ring);
503+ pdata->tx_ring = NULL;
504+ }
505+
506+ if (pdata->rx_ring) {
507+ buf_pool = pdata->rx_ring->buf_pool;
508+ xgene_enet_delete_bufpool(buf_pool);
509+ xgene_enet_delete_ring(buf_pool);
510+ xgene_enet_delete_ring(pdata->rx_ring);
511+ pdata->rx_ring = NULL;
512+ }
513+}
514+
515+static int xgene_enet_get_ring_size(struct device *dev,
516+ enum xgene_enet_ring_cfgsize cfgsize)
517+{
518+ int size = -EINVAL;
519+
520+ switch (cfgsize) {
521+ case RING_CFGSIZE_512B:
522+ size = 0x200;
523+ break;
524+ case RING_CFGSIZE_2KB:
525+ size = 0x800;
526+ break;
527+ case RING_CFGSIZE_16KB:
528+ size = 0x4000;
529+ break;
530+ case RING_CFGSIZE_64KB:
531+ size = 0x10000;
532+ break;
533+ case RING_CFGSIZE_512KB:
534+ size = 0x80000;
535+ break;
536+ default:
537+ dev_err(dev, "Unsupported cfg ring size %d\n", cfgsize);
538+ break;
539+ }
540+
541+ return size;
542+}
543+
544+static void xgene_enet_free_desc_ring(struct xgene_enet_desc_ring *ring)
545+{
546+ struct device *dev;
547+
548+ if (!ring)
549+ return;
550+
551+ dev = ndev_to_dev(ring->ndev);
552+
553+ if (ring->desc_addr) {
554+ xgene_enet_clear_ring(ring);
555+ dma_free_coherent(dev, ring->size, ring->desc_addr, ring->dma);
556+ }
557+ devm_kfree(dev, ring);
558+}
559+
560+static void xgene_enet_free_desc_rings(struct xgene_enet_pdata *pdata)
561+{
562+ struct device *dev = &pdata->pdev->dev;
563+ struct xgene_enet_desc_ring *ring;
564+
565+ ring = pdata->tx_ring;
566+ if (ring && ring->cp_ring && ring->cp_ring->cp_skb)
567+ devm_kfree(dev, ring->cp_ring->cp_skb);
568+ xgene_enet_free_desc_ring(ring);
569+
570+ ring = pdata->rx_ring;
571+ if (ring && ring->buf_pool && ring->buf_pool->rx_skb)
572+ devm_kfree(dev, ring->buf_pool->rx_skb);
573+ xgene_enet_free_desc_ring(ring->buf_pool);
574+ xgene_enet_free_desc_ring(ring);
575+}
576+
577+static struct xgene_enet_desc_ring *xgene_enet_create_desc_ring(
578+ struct net_device *ndev, u32 ring_num,
579+ enum xgene_enet_ring_cfgsize cfgsize, u32 ring_id)
580+{
581+ struct xgene_enet_desc_ring *ring;
582+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
583+ struct device *dev = ndev_to_dev(ndev);
584+ u32 size;
585+
586+ ring = devm_kzalloc(dev, sizeof(struct xgene_enet_desc_ring),
587+ GFP_KERNEL);
588+ if (!ring)
589+ return NULL;
590+
591+ ring->ndev = ndev;
592+ ring->num = ring_num;
593+ ring->cfgsize = cfgsize;
594+ ring->id = ring_id;
595+
596+ size = xgene_enet_get_ring_size(dev, cfgsize);
597+ ring->desc_addr = dma_zalloc_coherent(dev, size, &ring->dma,
598+ GFP_KERNEL);
599+ if (!ring->desc_addr) {
600+ devm_kfree(dev, ring);
601+ return NULL;
602+ }
603+ ring->size = size;
604+
605+ ring->cmd_base = pdata->ring_cmd_addr + (ring->num << 6);
606+ ring->cmd = ring->cmd_base + INC_DEC_CMD_ADDR;
607+ pdata->rm = RM3;
608+ ring = xgene_enet_setup_ring(ring);
609+ netdev_dbg(ndev, "ring info: num=%d size=%d id=%d slots=%d\n",
610+ ring->num, ring->size, ring->id, ring->slots);
611+
612+ return ring;
613+}
614+
615+static u16 xgene_enet_get_ring_id(enum xgene_ring_owner owner, u8 bufnum)
616+{
617+ return (owner << 6) | (bufnum & GENMASK(5, 0));
618+}
619+
620+static int xgene_enet_create_desc_rings(struct net_device *ndev)
621+{
622+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
623+ struct device *dev = ndev_to_dev(ndev);
624+ struct xgene_enet_desc_ring *rx_ring, *tx_ring, *cp_ring;
625+ struct xgene_enet_desc_ring *buf_pool = NULL;
626+ u8 cpu_bufnum = 0, eth_bufnum = 0;
627+ u8 bp_bufnum = 0x20;
628+ u16 ring_id, ring_num = 0;
629+ int ret;
630+
631+ /* allocate rx descriptor ring */
632+ ring_id = xgene_enet_get_ring_id(RING_OWNER_CPU, cpu_bufnum++);
633+ rx_ring = xgene_enet_create_desc_ring(ndev, ring_num++,
634+ RING_CFGSIZE_16KB, ring_id);
635+ if (!rx_ring) {
636+ ret = -ENOMEM;
637+ goto err;
638+ }
639+
640+ /* allocate buffer pool for receiving packets */
641+ ring_id = xgene_enet_get_ring_id(RING_OWNER_ETH0, bp_bufnum++);
642+ buf_pool = xgene_enet_create_desc_ring(ndev, ring_num++,
643+ RING_CFGSIZE_2KB, ring_id);
644+ if (!buf_pool) {
645+ ret = -ENOMEM;
646+ goto err;
647+ }
648+
649+ rx_ring->nbufpool = NUM_BUFPOOL;
650+ rx_ring->buf_pool = buf_pool;
651+ rx_ring->irq = pdata->rx_irq;
652+ buf_pool->rx_skb = devm_kcalloc(dev, buf_pool->slots,
653+ sizeof(struct sk_buff *), GFP_KERNEL);
654+ if (!buf_pool->rx_skb) {
655+ ret = -ENOMEM;
656+ goto err;
657+ }
658+
659+ buf_pool->dst_ring_num = xgene_enet_dst_ring_num(buf_pool);
660+ rx_ring->buf_pool = buf_pool;
661+ pdata->rx_ring = rx_ring;
662+
663+ /* allocate tx descriptor ring */
664+ ring_id = xgene_enet_get_ring_id(RING_OWNER_ETH0, eth_bufnum++);
665+ tx_ring = xgene_enet_create_desc_ring(ndev, ring_num++,
666+ RING_CFGSIZE_16KB, ring_id);
667+ if (!tx_ring) {
668+ ret = -ENOMEM;
669+ goto err;
670+ }
671+ pdata->tx_ring = tx_ring;
672+
673+ cp_ring = pdata->rx_ring;
674+ cp_ring->cp_skb = devm_kcalloc(dev, tx_ring->slots,
675+ sizeof(struct sk_buff *), GFP_KERNEL);
676+ if (!cp_ring->cp_skb) {
677+ ret = -ENOMEM;
678+ goto err;
679+ }
680+ pdata->tx_ring->cp_ring = cp_ring;
681+ pdata->tx_ring->dst_ring_num = xgene_enet_dst_ring_num(cp_ring);
682+
683+ pdata->tx_qcnt_hi = pdata->tx_ring->slots / 2;
684+ pdata->cp_qcnt_hi = pdata->rx_ring->slots / 2;
685+ pdata->cp_qcnt_low = pdata->cp_qcnt_hi / 2;
686+
687+ return 0;
688+
689+err:
690+ xgene_enet_free_desc_rings(pdata);
691+ return ret;
692+}
693+
694+static struct rtnl_link_stats64 *xgene_enet_get_stats64(
695+ struct net_device *ndev,
696+ struct rtnl_link_stats64 *storage)
697+{
698+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
699+ struct rtnl_link_stats64 *stats = &pdata->stats;
700+
701+ stats->rx_errors += stats->rx_length_errors +
702+ stats->rx_crc_errors +
703+ stats->rx_frame_errors +
704+ stats->rx_fifo_errors;
705+ memcpy(storage, &pdata->stats, sizeof(struct rtnl_link_stats64));
706+
707+ return storage;
708+}
709+
710+static int xgene_enet_set_mac_address(struct net_device *ndev, void *addr)
711+{
712+ struct xgene_enet_pdata *pdata = netdev_priv(ndev);
713+ int ret;
714+
715+ ret = eth_mac_addr(ndev, addr);
716+ if (ret)
717+ return ret;
718+ xgene_gmac_set_mac_addr(pdata);
719+
720+ return ret;
721+}
722+
723+static const struct net_device_ops xgene_ndev_ops = {
724+ .ndo_open = xgene_enet_open,
725+ .ndo_stop = xgene_enet_close,
726+ .ndo_start_xmit = xgene_enet_start_xmit,
727+ .ndo_tx_timeout = xgene_enet_timeout,
728+ .ndo_get_stats64 = xgene_enet_get_stats64,
729+ .ndo_change_mtu = eth_change_mtu,
730+ .ndo_set_mac_address = xgene_enet_set_mac_address,
731+};
732+
733+static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
734+{
735+ struct platform_device *pdev;
736+ struct net_device *ndev;
737+ struct device *dev;
738+ struct resource *res;
739+ void __iomem *base_addr;
740+ const char *mac;
741+ int ret;
742+
743+ pdev = pdata->pdev;
744+ dev = &pdev->dev;
745+ ndev = pdata->ndev;
746+
747+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "enet_csr");
748+ if (!res) {
749+ dev_err(dev, "Resource enet_csr not defined\n");
750+ return -ENODEV;
751+ }
752+ pdata->base_addr = devm_ioremap_resource(dev, res);
753+ if (IS_ERR(pdata->base_addr)) {
754+ dev_err(dev, "Unable to retrieve ENET Port CSR region\n");
755+ return PTR_ERR(pdata->base_addr);
756+ }
757+
758+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ring_csr");
759+ if (!res) {
760+ dev_err(dev, "Resource ring_csr not defined\n");
761+ return -ENODEV;
762+ }
763+ pdata->ring_csr_addr = devm_ioremap_resource(dev, res);
764+ if (IS_ERR(pdata->ring_csr_addr)) {
765+ dev_err(dev, "Unable to retrieve ENET Ring CSR region\n");
766+ return PTR_ERR(pdata->ring_csr_addr);
767+ }
768+
769+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ring_cmd");
770+ if (!res) {
771+ dev_err(dev, "Resource ring_cmd not defined\n");
772+ return -ENODEV;
773+ }
774+ pdata->ring_cmd_addr = devm_ioremap_resource(dev, res);
775+ if (IS_ERR(pdata->ring_cmd_addr)) {
776+ dev_err(dev, "Unable to retrieve ENET Ring command region\n");
777+ return PTR_ERR(pdata->ring_cmd_addr);
778+ }
779+
780+ ret = platform_get_irq(pdev, 0);
781+ if (ret <= 0) {
782+ dev_err(dev, "Unable to get ENET Rx IRQ\n");
783+ ret = ret ? : -ENXIO;
784+ return ret;
785+ }
786+ pdata->rx_irq = ret;
787+
788+ mac = of_get_mac_address(dev->of_node);
789+ if (mac)
790+ memcpy(ndev->dev_addr, mac, ndev->addr_len);
791+ else
792+ eth_hw_addr_random(ndev);
793+ memcpy(ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
794+
795+ pdata->phy_mode = of_get_phy_mode(pdev->dev.of_node);
796+ if (pdata->phy_mode < 0) {
797+ dev_err(dev, "Incorrect phy-connection-type in DTS\n");
798+ return -EINVAL;
799+ }
800+
801+ pdata->clk = devm_clk_get(&pdev->dev, NULL);
802+ ret = IS_ERR(pdata->clk);
803+ if (IS_ERR(pdata->clk)) {
804+ dev_err(&pdev->dev, "can't get clock\n");
805+ ret = PTR_ERR(pdata->clk);
806+ return ret;
807+ }
808+
809+ base_addr = pdata->base_addr;
810+ pdata->eth_csr_addr = base_addr + BLOCK_ETH_CSR_OFFSET;
811+ pdata->eth_ring_if_addr = base_addr + BLOCK_ETH_RING_IF_OFFSET;
812+ pdata->eth_diag_csr_addr = base_addr + BLOCK_ETH_DIAG_CSR_OFFSET;
813+ pdata->mcx_mac_addr = base_addr + BLOCK_ETH_MAC_OFFSET;
814+ pdata->mcx_stats_addr = base_addr + BLOCK_ETH_STATS_OFFSET;
815+ pdata->mcx_mac_csr_addr = base_addr + BLOCK_ETH_MAC_CSR_OFFSET;
816+ pdata->rx_buff_cnt = NUM_PKT_BUF;
817+
818+ return ret;
819+}
820+
821+static int xgene_enet_init_hw(struct xgene_enet_pdata *pdata)
822+{
823+ struct net_device *ndev = pdata->ndev;
824+ struct xgene_enet_desc_ring *buf_pool;
825+ u16 dst_ring_num;
826+ int ret;
827+
828+ xgene_gmac_tx_disable(pdata);
829+ xgene_gmac_rx_disable(pdata);
830+
831+ ret = xgene_enet_create_desc_rings(ndev);
832+ if (ret) {
833+ netdev_err(ndev, "Error in ring configuration\n");
834+ return ret;
835+ }
836+
837+ /* setup buffer pool */
838+ buf_pool = pdata->rx_ring->buf_pool;
839+ xgene_enet_init_bufpool(buf_pool);
840+ ret = xgene_enet_refill_bufpool(buf_pool, pdata->rx_buff_cnt);
841+ if (ret) {
842+ xgene_enet_delete_desc_rings(pdata);
843+ return ret;
844+ }
845+
846+ dst_ring_num = xgene_enet_dst_ring_num(pdata->rx_ring);
847+ xgene_enet_cle_bypass(pdata, dst_ring_num, buf_pool->id);
848+
849+ return ret;
850+}
851+
852+static int xgene_enet_probe(struct platform_device *pdev)
853+{
854+ struct net_device *ndev;
855+ struct xgene_enet_pdata *pdata;
856+ struct device *dev = &pdev->dev;
857+ struct napi_struct *napi;
858+ int ret;
859+
860+ ndev = alloc_etherdev(sizeof(struct xgene_enet_pdata));
861+ if (!ndev)
862+ return -ENOMEM;
863+
864+ pdata = netdev_priv(ndev);
865+
866+ pdata->pdev = pdev;
867+ pdata->ndev = ndev;
868+ SET_NETDEV_DEV(ndev, dev);
869+ platform_set_drvdata(pdev, pdata);
870+ ndev->netdev_ops = &xgene_ndev_ops;
871+ xgene_enet_set_ethtool_ops(ndev);
872+ ndev->features |= NETIF_F_IP_CSUM |
873+ NETIF_F_GSO |
874+ NETIF_F_GRO;
875+
876+ ret = xgene_enet_get_resources(pdata);
877+ if (ret)
878+ goto err;
879+
880+ xgene_enet_reset(pdata);
881+ xgene_gmac_init(pdata, SPEED_1000);
882+
883+ ret = register_netdev(ndev);
884+ if (ret) {
885+ netdev_err(ndev, "Failed to register netdev\n");
886+ goto err;
887+ }
888+
889+ ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
890+ if (ret) {
891+ netdev_err(ndev, "No usable DMA configuration\n");
892+ goto err;
893+ }
894+
895+ ret = xgene_enet_init_hw(pdata);
896+ if (ret)
897+ goto err;
898+
899+ napi = &pdata->rx_ring->napi;
900+ netif_napi_add(ndev, napi, xgene_enet_napi, NAPI_POLL_WEIGHT);
901+ ret = xgene_enet_mdio_config(pdata);
902+
903+ return ret;
904+err:
905+ free_netdev(ndev);
906+ return ret;
907+}
908+
909+static int xgene_enet_remove(struct platform_device *pdev)
910+{
911+ struct xgene_enet_pdata *pdata;
912+ struct net_device *ndev;
913+
914+ pdata = platform_get_drvdata(pdev);
915+ ndev = pdata->ndev;
916+
917+ xgene_gmac_rx_disable(pdata);
918+ xgene_gmac_tx_disable(pdata);
919+
920+ netif_napi_del(&pdata->rx_ring->napi);
921+ xgene_enet_mdio_remove(pdata);
922+ xgene_enet_delete_desc_rings(pdata);
923+ unregister_netdev(ndev);
924+ xgene_gport_shutdown(pdata);
925+ free_netdev(ndev);
926+
927+ return 0;
928+}
929+
930+static struct of_device_id xgene_enet_match[] = {
931+ {.compatible = "apm,xgene-enet",},
932+ {},
933+};
934+
935+MODULE_DEVICE_TABLE(of, xgene_enet_match);
936+
937+static struct platform_driver xgene_enet_driver = {
938+ .driver = {
939+ .name = "xgene-enet",
940+ .of_match_table = xgene_enet_match,
941+ },
942+ .probe = xgene_enet_probe,
943+ .remove = xgene_enet_remove,
944+};
945+
946+module_platform_driver(xgene_enet_driver);
947+
948+MODULE_DESCRIPTION("APM X-Gene SoC Ethernet driver");
949+MODULE_VERSION(XGENE_DRV_VERSION);
950+MODULE_AUTHOR("Keyur Chudgar <kchudgar@apm.com>");
951+MODULE_LICENSE("GPL");
drivers/net/ethernet/apm/xgene/xgene_enet_main.h+135−0
@@ -0,0 +1,135 @@
1+/* Applied Micro X-Gene SoC Ethernet Driver
2+ *
3+ * Copyright (c) 2014, Applied Micro Circuits Corporation
4+ * Authors: Iyappan Subramanian <isubramanian@apm.com>
5+ * Ravi Patel <rapatel@apm.com>
6+ * Keyur Chudgar <kchudgar@apm.com>
7+ *
8+ * This program is free software; you can redistribute it and/or modify it
9+ * under the terms of the GNU General Public License as published by the
10+ * Free Software Foundation; either version 2 of the License, or (at your
11+ * option) any later version.
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+#ifndef __XGENE_ENET_MAIN_H__
23+#define __XGENE_ENET_MAIN_H__
24+
25+#include <linux/clk.h>
26+#include <linux/of_platform.h>
27+#include <linux/of_net.h>
28+#include <linux/of_mdio.h>
29+#include <linux/module.h>
30+#include <net/ip.h>
31+#include <linux/prefetch.h>
32+#include <linux/if_vlan.h>
33+#include <linux/phy.h>
34+#include "xgene_enet_hw.h"
35+
36+#define XGENE_DRV_VERSION "v1.0"
37+#define XGENE_ENET_MAX_MTU 1536
38+#define SKB_BUFFER_SIZE (XGENE_ENET_MAX_MTU - NET_IP_ALIGN)
39+#define NUM_PKT_BUF 64
40+#define NUM_BUFPOOL 32
41+
42+/* software context of a descriptor ring */
43+struct xgene_enet_desc_ring {
44+ struct net_device *ndev;
45+ u16 id;
46+ u16 num;
47+ u16 head;
48+ u16 tail;
49+ u16 slots;
50+ u16 irq;
51+ u32 size;
52+ u32 state[NUM_RING_CONFIG];
53+ void __iomem *cmd_base;
54+ void __iomem *cmd;
55+ dma_addr_t dma;
56+ u16 dst_ring_num;
57+ u8 nbufpool;
58+ struct sk_buff *(*rx_skb);
59+ struct sk_buff *(*cp_skb);
60+ enum xgene_enet_ring_cfgsize cfgsize;
61+ struct xgene_enet_desc_ring *cp_ring;
62+ struct xgene_enet_desc_ring *buf_pool;
63+ struct napi_struct napi;
64+ union {
65+ void *desc_addr;
66+ struct xgene_enet_raw_desc *raw_desc;
67+ struct xgene_enet_raw_desc16 *raw_desc16;
68+ };
69+};
70+
71+/* ethernet private data */
72+struct xgene_enet_pdata {
73+ struct net_device *ndev;
74+ struct mii_bus *mdio_bus;
75+ struct phy_device *phy_dev;
76+ int phy_speed;
77+ struct clk *clk;
78+ struct platform_device *pdev;
79+ struct xgene_enet_desc_ring *tx_ring;
80+ struct xgene_enet_desc_ring *rx_ring;
81+ char *dev_name;
82+ u32 rx_buff_cnt;
83+ u32 tx_qcnt_hi;
84+ u32 cp_qcnt_hi;
85+ u32 cp_qcnt_low;
86+ u32 rx_irq;
87+ void __iomem *eth_csr_addr;
88+ void __iomem *eth_ring_if_addr;
89+ void __iomem *eth_diag_csr_addr;
90+ void __iomem *mcx_mac_addr;
91+ void __iomem *mcx_stats_addr;
92+ void __iomem *mcx_mac_csr_addr;
93+ void __iomem *base_addr;
94+ void __iomem *ring_csr_addr;
95+ void __iomem *ring_cmd_addr;
96+ u32 phy_addr;
97+ int phy_mode;
98+ u32 speed;
99+ u16 rm;
100+ struct rtnl_link_stats64 stats;
101+};
102+
103+/* Set the specified value into a bit-field defined by its starting position
104+ * and length within a single u64.
105+ */
106+static inline u64 xgene_enet_set_field_value(int pos, int len, u64 val)
107+{
108+ return (val & ((1ULL << len) - 1)) << pos;
109+}
110+
111+#define SET_VAL(field, val) \
112+ xgene_enet_set_field_value(field ## _POS, field ## _LEN, val)
113+
114+#define SET_BIT(field) \
115+ xgene_enet_set_field_value(field ## _POS, 1, 1)
116+
117+/* Get the value from a bit-field defined by its starting position
118+ * and length within the specified u64.
119+ */
120+static inline u64 xgene_enet_get_field_value(int pos, int len, u64 src)
121+{
122+ return (src >> pos) & ((1ULL << len) - 1);
123+}
124+
125+#define GET_VAL(field, src) \
126+ xgene_enet_get_field_value(field ## _POS, field ## _LEN, src)
127+
128+static inline struct device *ndev_to_dev(struct net_device *ndev)
129+{
130+ return ndev->dev.parent;
131+}
132+
133+void xgene_enet_set_ethtool_ops(struct net_device *netdev);
134+
135+#endif /* __XGENE_ENET_MAIN_H__ */
drivers/net/ethernet/broadcom/genet/bcmgenet.c+24−13
@@ -739,7 +739,6 @@ static void bcmgenet_power_down(struct bcmgenet_priv *priv, · 738 unmodified lines
739739
740740 case GENET_POWER_PASSIVE:
741741 /* Power down LED */
742− bcmgenet_mii_reset(priv->dev);
743742 if (priv->hw_params->flags & GENET_HAS_EXT) {
744743 reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT);
745744 reg |= (EXT_PWR_DOWN_PHY |
@@ -779,7 +778,9 @@ static void bcmgenet_power_up(struct bcmgenet_priv *priv, · 33 unmodified lines
779778 }
780779
781780 bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
782− bcmgenet_mii_reset(priv->dev);
781+
782+ if (mode == GENET_POWER_PASSIVE)
783+ bcmgenet_mii_reset(priv->dev);
783784 }
784785
785786 /* ioctl handle special commands that are not present in ethtool. */
@@ -1961,7 +1962,8 @@ static void bcmgenet_set_hw_addr(struct bcmgenet_priv *priv, · 1175 unmodified lines
19611962 static int bcmgenet_wol_resume(struct bcmgenet_priv *priv)
19621963 {
19631964 /* From WOL-enabled suspend, switch to regular clock */
1964− clk_disable_unprepare(priv->clk_wol);
1965+ if (priv->wolopts)
1966+ clk_disable_unprepare(priv->clk_wol);
19651967
19661968 phy_init_hw(priv->phydev);
19671969 /* Speed settings must be restored */
@@ -2164,6 +2166,10 @@ static void bcmgenet_netif_stop(struct net_device *dev) · 196 unmodified lines
21642166 * disabled no new work will be scheduled.
21652167 */
21662168 cancel_work_sync(&priv->bcmgenet_irq_work);
2169+
2170+ priv->old_pause = -1;
2171+ priv->old_link = -1;
2172+ priv->old_duplex = -1;
21672173 }
21682174
21692175 static int bcmgenet_close(struct net_device *dev)
@@ -2533,6 +2539,13 @@ static int bcmgenet_probe(struct platform_device *pdev) · 363 unmodified lines
25332539 priv->pdev = pdev;
25342540 priv->version = (enum bcmgenet_version)of_id->data;
25352541
2542+ priv->clk = devm_clk_get(&priv->pdev->dev, "enet");
2543+ if (IS_ERR(priv->clk))
2544+ dev_warn(&priv->pdev->dev, "failed to get enet clock\n");
2545+
2546+ if (!IS_ERR(priv->clk))
2547+ clk_prepare_enable(priv->clk);
2548+
25362549 bcmgenet_set_hw_params(priv);
25372550
25382551 /* Mii wait queue */
@@ -2541,17 +2554,10 @@ static int bcmgenet_probe(struct platform_device *pdev) · 2 unmodified lines
25412554 priv->rx_buf_len = RX_BUF_LENGTH;
25422555 INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task);
25432556
2544− priv->clk = devm_clk_get(&priv->pdev->dev, "enet");
2545− if (IS_ERR(priv->clk))
2546− dev_warn(&priv->pdev->dev, "failed to get enet clock\n");
2547−
25482557 priv->clk_wol = devm_clk_get(&priv->pdev->dev, "enet-wol");
25492558 if (IS_ERR(priv->clk_wol))
25502559 dev_warn(&priv->pdev->dev, "failed to get enet-wol clock\n");
25512560
2552− if (!IS_ERR(priv->clk))
2553− clk_prepare_enable(priv->clk);
2554−
25552561 err = reset_umac(priv);
25562562 if (err)
25572563 goto err_clk_disable;
@@ -2611,6 +2617,8 @@ static int bcmgenet_suspend(struct device *d) · 53 unmodified lines
26112617
26122618 bcmgenet_netif_stop(dev);
26132619
2620+ phy_suspend(priv->phydev);
2621+
26142622 netif_device_detach(dev);
26152623
26162624 /* Disable MAC receive */
@@ -2661,9 +2669,7 @@ static int bcmgenet_resume(struct device *d) · 44 unmodified lines
26612669 if (ret)
26622670 goto out_clk_disable;
26632671
2664− if (priv->wolopts)
2665− ret = bcmgenet_wol_resume(priv);
2666−
2672+ ret = bcmgenet_wol_resume(priv);
26672673 if (ret)
26682674 goto out_clk_disable;
26692675
@@ -2678,6 +2684,9 @@ static int bcmgenet_resume(struct device *d) · 8 unmodified lines
26782684 bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
26792685 }
26802686
2687+ if (priv->wolopts)
2688+ bcmgenet_power_up(priv, GENET_POWER_WOL_MAGIC);
2689+
26812690 /* Disable RX/TX DMA and flush TX queues */
26822691 dma_ctrl = bcmgenet_dma_disable(priv);
26832692
@@ -2693,6 +2702,8 @@ static int bcmgenet_resume(struct device *d) · 9 unmodified lines
26932702
26942703 netif_device_attach(dev);
26952704
2705+ phy_resume(priv->phydev);
2706+
26962707 bcmgenet_netif_start(dev);
26972708
26982709 return 0;
drivers/net/ethernet/broadcom/genet/bcmmii.c+10−4
@@ -129,7 +129,10 @@ static void bcmgenet_mii_setup(struct net_device *dev) · 128 unmodified lines
129129 cmd_bits |= CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE;
130130 }
131131
132− if (status_changed) {
132+ if (!status_changed)
133+ return;
134+
135+ if (phydev->link) {
133136 reg = bcmgenet_umac_readl(priv, UMAC_CMD);
134137 reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
135138 CMD_HD_EN |
@@ -137,8 +140,9 @@ static void bcmgenet_mii_setup(struct net_device *dev) · 1 unmodified line
137140 reg |= cmd_bits;
138141 bcmgenet_umac_writel(priv, reg, UMAC_CMD);
139142
140− phy_print_status(phydev);
141143 }
144+
145+ phy_print_status(phydev);
142146 }
143147
144148 void bcmgenet_mii_reset(struct net_device *dev)
@@ -303,12 +307,12 @@ static int bcmgenet_mii_probe(struct net_device *dev) · 158 unmodified lines
303307 /* In the case of a fixed PHY, the DT node associated
304308 * to the PHY is the Ethernet MAC DT node.
305309 */
306− if (of_phy_is_fixed_link(dn)) {
310+ if (!priv->phy_dn && of_phy_is_fixed_link(dn)) {
307311 ret = of_phy_register_fixed_link(dn);
308312 if (ret)
309313 return ret;
310314
311− priv->phy_dn = dn;
315+ priv->phy_dn = of_node_get(dn);
312316 }
313317
314318 phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup, 0,
@@ -444,6 +448,7 @@ int bcmgenet_mii_init(struct net_device *dev) · 129 unmodified lines
444448 return 0;
445449
446450 out:
451+ of_node_put(priv->phy_dn);
447452 mdiobus_unregister(priv->mii_bus);
448453 out_free:
449454 kfree(priv->mii_bus->irq);
@@ -455,6 +460,7 @@ void bcmgenet_mii_exit(struct net_device *dev) · 5 unmodified lines
455460 {
456461 struct bcmgenet_priv *priv = netdev_priv(dev);
457462
463+ of_node_put(priv->phy_dn);
458464 mdiobus_unregister(priv->mii_bus);
459465 kfree(priv->mii_bus->irq);
460466 mdiobus_free(priv->mii_bus);
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h+7−4
@@ -50,13 +50,13 @@ · 49 unmodified lines
5050 #include "cxgb4_uld.h"
5151
5252 #define T4FW_VERSION_MAJOR 0x01
53−#define T4FW_VERSION_MINOR 0x09
54−#define T4FW_VERSION_MICRO 0x17
53+#define T4FW_VERSION_MINOR 0x0B
54+#define T4FW_VERSION_MICRO 0x1B
5555 #define T4FW_VERSION_BUILD 0x00
5656
5757 #define T5FW_VERSION_MAJOR 0x01
58−#define T5FW_VERSION_MINOR 0x09
59−#define T5FW_VERSION_MICRO 0x17
58+#define T5FW_VERSION_MINOR 0x0B
59+#define T5FW_VERSION_MICRO 0x1B
6060 #define T5FW_VERSION_BUILD 0x00
6161
6262 #define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
@@ -522,6 +522,9 @@ struct sge_txq { · 459 unmodified lines
522522 struct sge_eth_txq { /* state for an SGE Ethernet Tx queue */
523523 struct sge_txq q;
524524 struct netdev_queue *txq; /* associated netdev TX queue */
525+#ifdef CONFIG_CHELSIO_T4_DCB
526+ u8 dcb_prio; /* DCB Priority bound to queue */
527+#endif
525528 unsigned long tso; /* # of TSO requests */
526529 unsigned long tx_cso; /* # of Tx checksum offloads */
527530 unsigned long vlan_ins; /* # of Tx VLAN insertions */
drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c+190−70
@@ -20,6 +20,17 @@ · 19 unmodified lines
2020
2121 #include "cxgb4.h"
2222
23+/* DCBx version control
24+ */
25+char *dcb_ver_array[] = {
26+ "Unknown",
27+ "DCBx-CIN",
28+ "DCBx-CEE 1.01",
29+ "DCBx-IEEE",
30+ "", "", "",
31+ "Auto Negotiated"
32+};
33+
2334 /* Initialize a port's Data Center Bridging state. Typically used after a
2435 * Link Down event.
2536 */
@@ -27,25 +38,45 @@ void cxgb4_dcb_state_init(struct net_device *dev) · 1 unmodified line
2738 {
2839 struct port_info *pi = netdev2pinfo(dev);
2940 struct port_dcb_info *dcb = &pi->dcb;
41+ int version_temp = dcb->dcb_version;
3042
3143 memset(dcb, 0, sizeof(struct port_dcb_info));
3244 dcb->state = CXGB4_DCB_STATE_START;
45+ if (version_temp)
46+ dcb->dcb_version = version_temp;
47+
48+ netdev_dbg(dev, "%s: Initializing DCB state for port[%d]\n",
49+ __func__, pi->port_id);
50+}
51+
52+void cxgb4_dcb_version_init(struct net_device *dev)
53+{
54+ struct port_info *pi = netdev2pinfo(dev);
55+ struct port_dcb_info *dcb = &pi->dcb;
56+
57+ /* Any writes here are only done on kernels that exlicitly need
58+ * a specific version, say < 2.6.38 which only support CEE
59+ */
60+ dcb->dcb_version = FW_PORT_DCB_VER_AUTO;
3361 }
3462
3563 /* Finite State machine for Data Center Bridging.
3664 */
3765 void cxgb4_dcb_state_fsm(struct net_device *dev,
38− enum cxgb4_dcb_state_input input)
66+ enum cxgb4_dcb_state_input transition_to)
3967 {
4068 struct port_info *pi = netdev2pinfo(dev);
4169 struct port_dcb_info *dcb = &pi->dcb;
4270 struct adapter *adap = pi->adapter;
71+ enum cxgb4_dcb_state current_state = dcb->state;
4372
44− switch (input) {
45− case CXGB4_DCB_INPUT_FW_DISABLED: {
46− /* Firmware tells us it's not doing DCB */
47− switch (dcb->state) {
48− case CXGB4_DCB_STATE_START: {
73+ netdev_dbg(dev, "%s: State change from %d to %d for %s\n",
74+ __func__, dcb->state, transition_to, dev->name);
75+
76+ switch (current_state) {
77+ case CXGB4_DCB_STATE_START: {
78+ switch (transition_to) {
79+ case CXGB4_DCB_INPUT_FW_DISABLED: {
4980 /* we're going to use Host DCB */
5081 dcb->state = CXGB4_DCB_STATE_HOST;
5182 dcb->supported = CXGB4_DCBX_HOST_SUPPORT;
@@ -53,48 +84,62 @@ void cxgb4_dcb_state_fsm(struct net_device *dev, · 1 unmodified line
5384 break;
5485 }
5586
56− case CXGB4_DCB_STATE_HOST: {
57− /* we're alreaady in Host DCB mode */
87+ case CXGB4_DCB_INPUT_FW_ENABLED: {
88+ /* we're going to use Firmware DCB */
89+ dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE;
90+ dcb->supported = CXGB4_DCBX_FW_SUPPORT;
91+ break;
92+ }
93+
94+ case CXGB4_DCB_INPUT_FW_INCOMPLETE: {
95+ /* expected transition */
96+ break;
97+ }
98+
99+ case CXGB4_DCB_INPUT_FW_ALLSYNCED: {
100+ dcb->state = CXGB4_DCB_STATE_FW_ALLSYNCED;
58101 break;
59102 }
60103
61104 default:
62− goto bad_state_transition;
105+ goto bad_state_input;
63106 }
64107 break;
65108 }
66109
67− case CXGB4_DCB_INPUT_FW_ENABLED: {
68− /* Firmware tells us that it is doing DCB */
69− switch (dcb->state) {
70− case CXGB4_DCB_STATE_START: {
71− /* we're going to use Firmware DCB */
72− dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE;
73− dcb->supported = CXGB4_DCBX_FW_SUPPORT;
110+ case CXGB4_DCB_STATE_FW_INCOMPLETE: {
111+ switch (transition_to) {
112+ case CXGB4_DCB_INPUT_FW_ENABLED: {
113+ /* we're alreaady in firmware DCB mode */
74114 break;
75115 }
76116
77− case CXGB4_DCB_STATE_FW_INCOMPLETE:
78− case CXGB4_DCB_STATE_FW_ALLSYNCED: {
79− /* we're alreaady in firmware DCB mode */
117+ case CXGB4_DCB_INPUT_FW_INCOMPLETE: {
118+ /* we're already incomplete */
119+ break;
120+ }
121+
122+ case CXGB4_DCB_INPUT_FW_ALLSYNCED: {
123+ dcb->state = CXGB4_DCB_STATE_FW_ALLSYNCED;
124+ dcb->enabled = 1;
125+ linkwatch_fire_event(dev);
80126 break;
81127 }
82128
83129 default:
84− goto bad_state_transition;
130+ goto bad_state_input;
85131 }
86132 break;
87133 }
88134
89− case CXGB4_DCB_INPUT_FW_INCOMPLETE: {
90− /* Firmware tells us that its DCB state is incomplete */
91− switch (dcb->state) {
92− case CXGB4_DCB_STATE_FW_INCOMPLETE: {
93− /* we're already incomplete */
135+ case CXGB4_DCB_STATE_FW_ALLSYNCED: {
136+ switch (transition_to) {
137+ case CXGB4_DCB_INPUT_FW_ENABLED: {
138+ /* we're alreaady in firmware DCB mode */
94139 break;
95140 }
96141
97− case CXGB4_DCB_STATE_FW_ALLSYNCED: {
142+ case CXGB4_DCB_INPUT_FW_INCOMPLETE: {
98143 /* We were successfully running with firmware DCB but
99144 * now it's telling us that it's in an "incomplete
100145 * state. We need to reset back to a ground state
@@ -107,46 +152,48 @@ void cxgb4_dcb_state_fsm(struct net_device *dev, · 6 unmodified lines
107152 break;
108153 }
109154
110− default:
111− goto bad_state_transition;
112− }
113− break;
114− }
115−
116− case CXGB4_DCB_INPUT_FW_ALLSYNCED: {
117− /* Firmware tells us that its DCB state is complete */
118− switch (dcb->state) {
119− case CXGB4_DCB_STATE_FW_INCOMPLETE: {
120− dcb->state = CXGB4_DCB_STATE_FW_ALLSYNCED;
155+ case CXGB4_DCB_INPUT_FW_ALLSYNCED: {
156+ /* we're already all sync'ed
157+ * this is only applicable for IEEE or
158+ * when another VI already completed negotiaton
159+ */
121160 dcb->enabled = 1;
122161 linkwatch_fire_event(dev);
123162 break;
124163 }
125164
126− case CXGB4_DCB_STATE_FW_ALLSYNCED: {
127− /* we're already all sync'ed */
165+ default:
166+ goto bad_state_input;
167+ }
168+ break;
169+ }
170+
171+ case CXGB4_DCB_STATE_HOST: {
172+ switch (transition_to) {
173+ case CXGB4_DCB_INPUT_FW_DISABLED: {
174+ /* we're alreaady in Host DCB mode */
128175 break;
129176 }
130177
131178 default:
132− goto bad_state_transition;
179+ goto bad_state_input;
133180 }
134181 break;
135182 }
136183
137184 default:
138− goto bad_state_input;
185+ goto bad_state_transition;
139186 }
140187 return;
141188
142189 bad_state_input:
143190 dev_err(adap->pdev_dev, "cxgb4_dcb_state_fsm: illegal input symbol %d\n",
144− input);
191+ transition_to);
145192 return;
146193
147194 bad_state_transition:
148195 dev_err(adap->pdev_dev, "cxgb4_dcb_state_fsm: bad state transition, state = %d, input = %d\n",
149− dcb->state, input);
196+ current_state, transition_to);
150197 }
151198
152199 /* Handle a DCB/DCBX update message from the firmware.
@@ -160,6 +207,7 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap, · 7 unmodified lines
160207 struct port_info *pi = netdev_priv(dev);
161208 struct port_dcb_info *dcb = &pi->dcb;
162209 int dcb_type = pcmd->u.dcb.pgid.type;
210+ int dcb_running_version;
163211
164212 /* Handle Firmware DCB Control messages separately since they drive
165213 * our state machine.
@@ -171,6 +219,25 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap, · 5 unmodified lines
171219 ? CXGB4_DCB_STATE_FW_ALLSYNCED
172220 : CXGB4_DCB_STATE_FW_INCOMPLETE);
173221
222+ if (dcb->dcb_version != FW_PORT_DCB_VER_UNKNOWN) {
223+ dcb_running_version = FW_PORT_CMD_DCB_VERSION_GET(
224+ be16_to_cpu(
225+ pcmd->u.dcb.control.dcb_version_to_app_state));
226+ if (dcb_running_version == FW_PORT_DCB_VER_CEE1D01 ||
227+ dcb_running_version == FW_PORT_DCB_VER_IEEE) {
228+ dcb->dcb_version = dcb_running_version;
229+ dev_warn(adap->pdev_dev, "Interface %s is running %s\n",
230+ dev->name,
231+ dcb_ver_array[dcb->dcb_version]);
232+ } else {
233+ dev_warn(adap->pdev_dev,
234+ "Something screwed up, requested firmware for %s, but firmware returned %s instead\n",
235+ dcb_ver_array[dcb->dcb_version],
236+ dcb_ver_array[dcb_running_version]);
237+ dcb->dcb_version = FW_PORT_DCB_VER_UNKNOWN;
238+ }
239+ }
240+
174241 cxgb4_dcb_state_fsm(dev, input);
175242 return;
176243 }
@@ -199,7 +266,11 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap, · 22 unmodified lines
199266 dcb->pg_num_tcs_supported = fwdcb->pgrate.num_tcs_supported;
200267 memcpy(dcb->pgrate, &fwdcb->pgrate.pgrate,
201268 sizeof(dcb->pgrate));
269+ memcpy(dcb->tsa, &fwdcb->pgrate.tsa,
270+ sizeof(dcb->tsa));
202271 dcb->msgs |= CXGB4_DCB_FW_PGRATE;
272+ if (dcb->msgs & CXGB4_DCB_FW_PGID)
273+ IEEE_FAUX_SYNC(dev, dcb);
203274 break;
204275
205276 case FW_PORT_DCB_TYPE_PRIORATE:
@@ -212,6 +283,7 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap, · 6 unmodified lines
212283 dcb->pfcen = fwdcb->pfc.pfcen;
213284 dcb->pfc_num_tcs_supported = fwdcb->pfc.max_pfc_tcs;
214285 dcb->msgs |= CXGB4_DCB_FW_PFC;
286+ IEEE_FAUX_SYNC(dev, dcb);
215287 break;
216288
217289 case FW_PORT_DCB_TYPE_APP_ID: {
@@ -220,13 +292,25 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap, · 2 unmodified lines
220292 struct app_priority *ap = &dcb->app_priority[idx];
221293
222294 struct dcb_app app = {
223− .selector = fwap->sel_field,
224295 .protocol = be16_to_cpu(fwap->protocolid),
225− .priority = fwap->user_prio_map,
226296 };
227297 int err;
228298
229− err = dcb_setapp(dev, &app);
299+ /* Convert from firmware format to relevant format
300+ * when using app selector
301+ */
302+ if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
303+ app.selector = (fwap->sel_field + 1);
304+ app.priority = ffs(fwap->user_prio_map) - 1;
305+ err = dcb_ieee_setapp(dev, &app);
306+ IEEE_FAUX_SYNC(dev, dcb);
307+ } else {
308+ /* Default is CEE */
309+ app.selector = !!(fwap->sel_field);
310+ app.priority = fwap->user_prio_map;
311+ err = dcb_setapp(dev, &app);
312+ }
313+
230314 if (err)
231315 dev_err(adap->pdev_dev,
232316 "Failed DCB Set Application Priority: sel=%d, prot=%d, prio=%d, err=%d\n",
@@ -408,9 +492,10 @@ static void cxgb4_getpgbwgcfg(struct net_device *dev, int pgid, u8 *bw_per, · 175 unmodified lines
408492 if (err != FW_PORT_DCB_CFG_SUCCESS) {
409493 dev_err(adap->pdev_dev, "DCB read PGRATE failed with %d\n",
410494 -err);
411− } else {
412− *bw_per = pcmd.u.dcb.pgrate.pgrate[pgid];
495+ return;
413496 }
497+
498+ *bw_per = pcmd.u.dcb.pgrate.pgrate[pgid];
414499 }
415500
416501 static void cxgb4_getpgbwgcfg_tx(struct net_device *dev, int pgid, u8 *bw_per)
@@ -637,7 +722,8 @@ static int __cxgb4_getapp(struct net_device *dev, u8 app_idtype, u16 app_id, · 220 unmodified lines
637722 return err;
638723 }
639724 if (be16_to_cpu(pcmd.u.dcb.app_priority.protocolid) == app_id)
640− return pcmd.u.dcb.app_priority.user_prio_map;
725+ if (pcmd.u.dcb.app_priority.sel_field == app_idtype)
726+ return pcmd.u.dcb.app_priority.user_prio_map;
641727
642728 /* exhausted app list */
643729 if (!pcmd.u.dcb.app_priority.protocolid)
@@ -657,8 +743,8 @@ static int cxgb4_getapp(struct net_device *dev, u8 app_idtype, u16 app_id) · 13 unmodified lines
657743
658744 /* Write a new Application User Priority Map for the specified Application ID
659745 */
660−static int cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id,
661− u8 app_prio)
746+static int __cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id,
747+ u8 app_prio)
662748 {
663749 struct fw_port_cmd pcmd;
664750 struct port_info *pi = netdev2pinfo(dev);
@@ -673,10 +759,6 @@ static int cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id, · 8 unmodified lines
673759 if (!netif_carrier_ok(dev))
674760 return -ENOLINK;
675761
676− if (app_idtype != DCB_APP_IDTYPE_ETHTYPE &&
677− app_idtype != DCB_APP_IDTYPE_PORTNUM)
678− return -EINVAL;
679−
680762 for (i = 0; i < CXGB4_MAX_DCBX_APP_SUPPORTED; i++) {
681763 INIT_PORT_DCB_READ_LOCAL_CMD(pcmd, pi->port_id);
682764 pcmd.u.dcb.app_priority.type = FW_PORT_DCB_TYPE_APP_ID;
@@ -725,6 +807,30 @@ static int cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id, · 42 unmodified lines
725807 return 0;
726808 }
727809
810+/* Priority for CEE inside dcb_app is bitmask, with 0 being an invalid value */
811+static int cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id,
812+ u8 app_prio)
813+{
814+ int ret;
815+ struct dcb_app app = {
816+ .selector = app_idtype,
817+ .protocol = app_id,
818+ .priority = app_prio,
819+ };
820+
821+ if (app_idtype != DCB_APP_IDTYPE_ETHTYPE &&
822+ app_idtype != DCB_APP_IDTYPE_PORTNUM)
823+ return -EINVAL;
824+
825+ /* Convert app_idtype to a format that firmware understands */
826+ ret = __cxgb4_setapp(dev, app_idtype == DCB_APP_IDTYPE_ETHTYPE ?
827+ app_idtype : 3, app_id, app_prio);
828+ if (ret)
829+ return ret;
830+
831+ return dcb_setapp(dev, &app);
832+}
833+
728834 /* Return whether IEEE Data Center Bridging has been negotiated.
729835 */
730836 static inline int cxgb4_ieee_negotiation_complete(struct net_device *dev)
@@ -738,6 +844,7 @@ static inline int cxgb4_ieee_negotiation_complete(struct net_device *dev) · 7 unmodified lines
738844
739845 /* Fill in the Application User Priority Map associated with the
740846 * specified Application.
847+ * Priority for IEEE dcb_app is an integer, with 0 being a valid value
741848 */
742849 static int cxgb4_ieee_getapp(struct net_device *dev, struct dcb_app *app)
743850 {
@@ -748,28 +855,39 @@ static int cxgb4_ieee_getapp(struct net_device *dev, struct dcb_app *app) · 4 unmodified lines
748855 if (!(app->selector && app->protocol))
749856 return -EINVAL;
750857
751− prio = dcb_getapp(dev, app);
752− if (prio == 0) {
753− /* If app doesn't exist in dcb_app table, try firmware
754− * directly.
755− */
756− prio = __cxgb4_getapp(dev, app->selector, app->protocol, 0);
757− }
858+ /* Try querying firmware first, use firmware format */
859+ prio = __cxgb4_getapp(dev, app->selector - 1, app->protocol, 0);
860+
861+ if (prio < 0)
862+ prio = dcb_ieee_getapp_mask(dev, app);
758863
759− app->priority = prio;
864+ app->priority = ffs(prio) - 1;
760865 return 0;
761866 }
762867
763−/* Write a new Application User Priority Map for the specified App id. */
868+/* Write a new Application User Priority Map for the specified Application ID.
869+ * Priority for IEEE dcb_app is an integer, with 0 being a valid value
870+ */
764871 static int cxgb4_ieee_setapp(struct net_device *dev, struct dcb_app *app)
765872 {
873+ int ret;
874+
766875 if (!cxgb4_ieee_negotiation_complete(dev))
767876 return -EINVAL;
768− if (!(app->selector && app->protocol && app->priority))
877+ if (!(app->selector && app->protocol))
878+ return -EINVAL;
879+
880+ if (!(app->selector > IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
881+ app->selector < IEEE_8021QAZ_APP_SEL_ANY))
769882 return -EINVAL;
770883
771− cxgb4_setapp(dev, app->selector, app->protocol, app->priority);
772− return dcb_setapp(dev, app);
884+ /* change selector to a format that firmware understands */
885+ ret = __cxgb4_setapp(dev, app->selector - 1, app->protocol,
886+ (1 << app->priority));
887+ if (ret)
888+ return ret;
889+
890+ return dcb_ieee_setapp(dev, app);
773891 }
774892
775893 /* Return our DCBX parameters.
@@ -794,8 +912,9 @@ static u8 cxgb4_setdcbx(struct net_device *dev, u8 dcb_request) · 18 unmodified lines
794912 != dcb_request)
795913 return 1;
796914
797− /* Can't set DCBX capabilities if DCBX isn't enabled. */
798− if (!pi->dcb.state)
915+ /* Can't enable DCB if we haven't successfully negotiated it.
916+ */
917+ if (pi->dcb.state != CXGB4_DCB_STATE_FW_ALLSYNCED)
799918 return 1;
800919
801920 /* There's currently no mechanism to allow for the firmware DCBX
@@ -874,7 +993,8 @@ static int cxgb4_getpeerapp_tbl(struct net_device *dev, struct dcb_app *table) · 72 unmodified lines
874993 table[i].selector = pcmd.u.dcb.app_priority.sel_field;
875994 table[i].protocol =
876995 be16_to_cpu(pcmd.u.dcb.app_priority.protocolid);
877− table[i].priority = pcmd.u.dcb.app_priority.user_prio_map;
996+ table[i].priority =
997+ ffs(pcmd.u.dcb.app_priority.user_prio_map) - 1;
878998 }
879999 return err;
8801000 }
drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h+10−0
@@ -63,6 +63,13 @@ · 62 unmodified lines
6363 #define INIT_PORT_DCB_WRITE_CMD(__pcmd, __port) \
6464 INIT_PORT_DCB_CMD(__pcmd, __port, EXEC, FW_PORT_ACTION_L2_DCB_CFG)
6565
66+#define IEEE_FAUX_SYNC(__dev, __dcb) \
67+ do { \
68+ if ((__dcb)->dcb_version == FW_PORT_DCB_VER_IEEE) \
69+ cxgb4_dcb_state_fsm((__dev), \
70+ CXGB4_DCB_STATE_FW_ALLSYNCED); \
71+ } while (0)
72+
6673 /* States we can be in for a port's Data Center Bridging.
6774 */
6875 enum cxgb4_dcb_state {
@@ -108,11 +115,13 @@ struct port_dcb_info { · 39 unmodified lines
108115 * Native Endian format).
109116 */
110117 u32 pgid; /* Priority Group[0..7] */
118+ u8 dcb_version; /* Running DCBx version */
111119 u8 pfcen; /* Priority Flow Control[0..7] */
112120 u8 pg_num_tcs_supported; /* max PG Traffic Classes */
113121 u8 pfc_num_tcs_supported; /* max PFC Traffic Classes */
114122 u8 pgrate[8]; /* Priority Group Rate[0..7] */
115123 u8 priorate[8]; /* Priority Rate[0..7] */
124+ u8 tsa[8]; /* TSA Algorithm[0..7] */
116125 struct app_priority { /* Application Information */
117126 u8 user_prio_map; /* Priority Map bitfield */
118127 u8 sel_field; /* Protocol ID interpretation */
@@ -121,6 +130,7 @@ struct port_dcb_info { · 2 unmodified lines
121130 };
122131
123132 void cxgb4_dcb_state_init(struct net_device *);
133+void cxgb4_dcb_version_init(struct net_device *);
124134 void cxgb4_dcb_state_fsm(struct net_device *, enum cxgb4_dcb_state_input);
125135 void cxgb4_dcb_handle_fw_update(struct adapter *, const struct fw_port_cmd *);
126136 void cxgb4_dcb_set_caps(struct adapter *, const struct fw_port_cmd *);
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c+2−0
@@ -522,6 +522,8 @@ static void dcb_tx_queue_prio_enable(struct net_device *dev, int enable) · 521 unmodified lines
522522 dev_err(adap->pdev_dev,
523523 "Can't %s DCB Priority on port %d, TX Queue %d: err=%d\n",
524524 enable ? "set" : "unset", pi->port_id, i, -err);
525+ else
526+ txq->dcb_prio = value;
525527 }
526528 }
527529 #endif /* CONFIG_CHELSIO_T4_DCB */
drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h+11−1
@@ -1629,6 +1629,14 @@ enum fw_port_l2cfg_ctlbf { · 1628 unmodified lines
16291629 FW_PORT_L2_CTLBF_TXIPG = 0x20
16301630 };
16311631
1632+enum fw_port_dcb_versions {
1633+ FW_PORT_DCB_VER_UNKNOWN,
1634+ FW_PORT_DCB_VER_CEE1D0,
1635+ FW_PORT_DCB_VER_CEE1D01,
1636+ FW_PORT_DCB_VER_IEEE,
1637+ FW_PORT_DCB_VER_AUTO = 7
1638+};
1639+
16321640 enum fw_port_dcb_cfg {
16331641 FW_PORT_DCB_CFG_PG = 0x01,
16341642 FW_PORT_DCB_CFG_PFC = 0x02,
@@ -1709,6 +1717,7 @@ struct fw_port_cmd { · 74 unmodified lines
17091717 __u8 r10_lo[5];
17101718 __u8 num_tcs_supported;
17111719 __u8 pgrate[8];
1720+ __u8 tsa[8];
17121721 } pgrate;
17131722 struct fw_port_dcb_priorate {
17141723 __u8 type;
@@ -1735,7 +1744,7 @@ struct fw_port_cmd { · 20 unmodified lines
17351744 struct fw_port_dcb_control {
17361745 __u8 type;
17371746 __u8 all_syncd_pkd;
1738− __be16 pfc_state_to_app_state;
1747+ __be16 dcb_version_to_app_state;
17391748 __be32 r11;
17401749 __be64 r12;
17411750 } control;
@@ -1778,6 +1787,7 @@ struct fw_port_cmd { · 36 unmodified lines
17781787 #define FW_PORT_CMD_DCBXDIS (1U << 7)
17791788 #define FW_PORT_CMD_APPLY (1U << 7)
17801789 #define FW_PORT_CMD_ALL_SYNCD (1U << 7)
1790+#define FW_PORT_CMD_DCB_VERSION_GET(x) (((x) >> 8) & 0xf)
17811791
17821792 #define FW_PORT_CMD_PPPEN(x) ((x) << 31)
17831793 #define FW_PORT_CMD_TPSRC(x) ((x) << 28)
drivers/net/ethernet/davicom/dm9000.c+46−46
@@ -93,7 +93,7 @@ enum dm9000_type { · 92 unmodified lines
9393 };
9494
9595 /* Structure/enum declaration ------------------------------- */
96−typedef struct board_info {
96+struct board_info {
9797
9898 void __iomem *io_addr; /* Register I/O base address */
9999 void __iomem *io_data; /* Data I/O address */
@@ -141,7 +141,7 @@ typedef struct board_info { · 41 unmodified lines
141141 u32 wake_state;
142142
143143 int ip_summed;
144−} board_info_t;
144+};
145145
146146 /* debug code */
147147
@@ -151,7 +151,7 @@ typedef struct board_info { · 3 unmodified lines
151151 } \
152152 } while (0)
153153
154−static inline board_info_t *to_dm9000_board(struct net_device *dev)
154+static inline struct board_info *to_dm9000_board(struct net_device *dev)
155155 {
156156 return netdev_priv(dev);
157157 }
@@ -162,7 +162,7 @@ static inline board_info_t *to_dm9000_board(struct net_device *dev) · 4 unmodified lines
162162 * Read a byte from I/O port
163163 */
164164 static u8
165−ior(board_info_t *db, int reg)
165+ior(struct board_info *db, int reg)
166166 {
167167 writeb(reg, db->io_addr);
168168 return readb(db->io_data);
@@ -173,14 +173,14 @@ ior(board_info_t *db, int reg) · 4 unmodified lines
173173 */
174174
175175 static void
176−iow(board_info_t *db, int reg, int value)
176+iow(struct board_info *db, int reg, int value)
177177 {
178178 writeb(reg, db->io_addr);
179179 writeb(value, db->io_data);
180180 }
181181
182182 static void
183−dm9000_reset(board_info_t *db)
183+dm9000_reset(struct board_info *db)
184184 {
185185 dev_dbg(db->dev, "resetting device\n");
186186
@@ -272,7 +272,7 @@ static void dm9000_dumpblk_32bit(void __iomem *reg, int count) · 85 unmodified lines
272272 * Sleep, either by using msleep() or if we are suspending, then
273273 * use mdelay() to sleep.
274274 */
275−static void dm9000_msleep(board_info_t *db, unsigned int ms)
275+static void dm9000_msleep(struct board_info *db, unsigned int ms)
276276 {
277277 if (db->in_suspend || db->in_timeout)
278278 mdelay(ms);
@@ -284,7 +284,7 @@ static void dm9000_msleep(board_info_t *db, unsigned int ms) · 5 unmodified lines
284284 static int
285285 dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
286286 {
287− board_info_t *db = netdev_priv(dev);
287+ struct board_info *db = netdev_priv(dev);
288288 unsigned long flags;
289289 unsigned int reg_save;
290290 int ret;
@@ -330,7 +330,7 @@ static void · 39 unmodified lines
330330 dm9000_phy_write(struct net_device *dev,
331331 int phyaddr_unused, int reg, int value)
332332 {
333− board_info_t *db = netdev_priv(dev);
333+ struct board_info *db = netdev_priv(dev);
334334 unsigned long flags;
335335 unsigned long reg_save;
336336
@@ -408,7 +408,7 @@ static void dm9000_set_io(struct board_info *db, int byte_width) · 71 unmodified lines
408408 }
409409 }
410410
411−static void dm9000_schedule_poll(board_info_t *db)
411+static void dm9000_schedule_poll(struct board_info *db)
412412 {
413413 if (db->type == TYPE_DM9000E)
414414 schedule_delayed_work(&db->phy_poll, HZ * 2);
@@ -416,7 +416,7 @@ static void dm9000_schedule_poll(board_info_t *db) · 1 unmodified line
416416
417417 static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
418418 {
419− board_info_t *dm = to_dm9000_board(dev);
419+ struct board_info *dm = to_dm9000_board(dev);
420420
421421 if (!netif_running(dev))
422422 return -EINVAL;
@@ -425,7 +425,7 @@ static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd) · 2 unmodified lines
425425 }
426426
427427 static unsigned int
428−dm9000_read_locked(board_info_t *db, int reg)
428+dm9000_read_locked(struct board_info *db, int reg)
429429 {
430430 unsigned long flags;
431431 unsigned int ret;
@@ -437,7 +437,7 @@ dm9000_read_locked(board_info_t *db, int reg) · 5 unmodified lines
437437 return ret;
438438 }
439439
440−static int dm9000_wait_eeprom(board_info_t *db)
440+static int dm9000_wait_eeprom(struct board_info *db)
441441 {
442442 unsigned int status;
443443 int timeout = 8; /* wait max 8msec */
@@ -474,7 +474,7 @@ static int dm9000_wait_eeprom(board_info_t *db) · 30 unmodified lines
474474 * Read a word data from EEPROM
475475 */
476476 static void
477−dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
477+dm9000_read_eeprom(struct board_info *db, int offset, u8 *to)
478478 {
479479 unsigned long flags;
480480
@@ -514,7 +514,7 @@ dm9000_read_eeprom(board_info_t *db, int offset, u8 *to) · 33 unmodified lines
514514 * Write a word data to SROM
515515 */
516516 static void
517−dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
517+dm9000_write_eeprom(struct board_info *db, int offset, u8 *data)
518518 {
519519 unsigned long flags;
520520
@@ -546,7 +546,7 @@ dm9000_write_eeprom(board_info_t *db, int offset, u8 *data) · 25 unmodified lines
546546 static void dm9000_get_drvinfo(struct net_device *dev,
547547 struct ethtool_drvinfo *info)
548548 {
549− board_info_t *dm = to_dm9000_board(dev);
549+ struct board_info *dm = to_dm9000_board(dev);
550550
551551 strlcpy(info->driver, CARDNAME, sizeof(info->driver));
552552 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
@@ -556,21 +556,21 @@ static void dm9000_get_drvinfo(struct net_device *dev, · 3 unmodified lines
556556
557557 static u32 dm9000_get_msglevel(struct net_device *dev)
558558 {
559− board_info_t *dm = to_dm9000_board(dev);
559+ struct board_info *dm = to_dm9000_board(dev);
560560
561561 return dm->msg_enable;
562562 }
563563
564564 static void dm9000_set_msglevel(struct net_device *dev, u32 value)
565565 {
566− board_info_t *dm = to_dm9000_board(dev);
566+ struct board_info *dm = to_dm9000_board(dev);
567567
568568 dm->msg_enable = value;
569569 }
570570
571571 static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
572572 {
573− board_info_t *dm = to_dm9000_board(dev);
573+ struct board_info *dm = to_dm9000_board(dev);
574574
575575 mii_ethtool_gset(&dm->mii, cmd);
576576 return 0;
@@ -578,21 +578,21 @@ static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) · 1 unmodified line
578578
579579 static int dm9000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
580580 {
581− board_info_t *dm = to_dm9000_board(dev);
581+ struct board_info *dm = to_dm9000_board(dev);
582582
583583 return mii_ethtool_sset(&dm->mii, cmd);
584584 }
585585
586586 static int dm9000_nway_reset(struct net_device *dev)
587587 {
588− board_info_t *dm = to_dm9000_board(dev);
588+ struct board_info *dm = to_dm9000_board(dev);
589589 return mii_nway_restart(&dm->mii);
590590 }
591591
592592 static int dm9000_set_features(struct net_device *dev,
593593 netdev_features_t features)
594594 {
595− board_info_t *dm = to_dm9000_board(dev);
595+ struct board_info *dm = to_dm9000_board(dev);
596596 netdev_features_t changed = dev->features ^ features;
597597 unsigned long flags;
598598
@@ -608,7 +608,7 @@ static int dm9000_set_features(struct net_device *dev, · 9 unmodified lines
608608
609609 static u32 dm9000_get_link(struct net_device *dev)
610610 {
611− board_info_t *dm = to_dm9000_board(dev);
611+ struct board_info *dm = to_dm9000_board(dev);
612612 u32 ret;
613613
614614 if (dm->flags & DM9000_PLATF_EXT_PHY)
@@ -629,7 +629,7 @@ static int dm9000_get_eeprom_len(struct net_device *dev) · 14 unmodified lines
629629 static int dm9000_get_eeprom(struct net_device *dev,
630630 struct ethtool_eeprom *ee, u8 *data)
631631 {
632− board_info_t *dm = to_dm9000_board(dev);
632+ struct board_info *dm = to_dm9000_board(dev);
633633 int offset = ee->offset;
634634 int len = ee->len;
635635 int i;
@@ -653,7 +653,7 @@ static int dm9000_get_eeprom(struct net_device *dev, · 17 unmodified lines
653653 static int dm9000_set_eeprom(struct net_device *dev,
654654 struct ethtool_eeprom *ee, u8 *data)
655655 {
656− board_info_t *dm = to_dm9000_board(dev);
656+ struct board_info *dm = to_dm9000_board(dev);
657657 int offset = ee->offset;
658658 int len = ee->len;
659659 int done;
@@ -691,7 +691,7 @@ static int dm9000_set_eeprom(struct net_device *dev, · 31 unmodified lines
691691
692692 static void dm9000_get_wol(struct net_device *dev, struct ethtool_wolinfo *w)
693693 {
694− board_info_t *dm = to_dm9000_board(dev);
694+ struct board_info *dm = to_dm9000_board(dev);
695695
696696 memset(w, 0, sizeof(struct ethtool_wolinfo));
697697
@@ -702,7 +702,7 @@ static void dm9000_get_wol(struct net_device *dev, struct ethtool_wolinfo *w) · 4 unmodified lines
702702
703703 static int dm9000_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
704704 {
705− board_info_t *dm = to_dm9000_board(dev);
705+ struct board_info *dm = to_dm9000_board(dev);
706706 unsigned long flags;
707707 u32 opts = w->wolopts;
708708 u32 wcr = 0;
@@ -752,7 +752,7 @@ static const struct ethtool_ops dm9000_ethtool_ops = { · 43 unmodified lines
752752 .set_eeprom = dm9000_set_eeprom,
753753 };
754754
755−static void dm9000_show_carrier(board_info_t *db,
755+static void dm9000_show_carrier(struct board_info *db,
756756 unsigned carrier, unsigned nsr)
757757 {
758758 int lpa;
@@ -775,7 +775,7 @@ static void · 16 unmodified lines
775775 dm9000_poll_work(struct work_struct *w)
776776 {
777777 struct delayed_work *dw = to_delayed_work(w);
778− board_info_t *db = container_of(dw, board_info_t, phy_poll);
778+ struct board_info *db = container_of(dw, struct board_info, phy_poll);
779779 struct net_device *ndev = db->ndev;
780780
781781 if (db->flags & DM9000_PLATF_SIMPLE_PHY &&
@@ -843,7 +843,7 @@ static unsigned char dm9000_type_to_char(enum dm9000_type type) · 61 unmodified lines
843843 static void
844844 dm9000_hash_table_unlocked(struct net_device *dev)
845845 {
846− board_info_t *db = netdev_priv(dev);
846+ struct board_info *db = netdev_priv(dev);
847847 struct netdev_hw_addr *ha;
848848 int i, oft;
849849 u32 hash_val;
@@ -879,7 +879,7 @@ dm9000_hash_table_unlocked(struct net_device *dev) · 29 unmodified lines
879879 static void
880880 dm9000_hash_table(struct net_device *dev)
881881 {
882− board_info_t *db = netdev_priv(dev);
882+ struct board_info *db = netdev_priv(dev);
883883 unsigned long flags;
884884
885885 spin_lock_irqsave(&db->lock, flags);
@@ -888,13 +888,13 @@ dm9000_hash_table(struct net_device *dev) · 2 unmodified lines
888888 }
889889
890890 static void
891−dm9000_mask_interrupts(board_info_t *db)
891+dm9000_mask_interrupts(struct board_info *db)
892892 {
893893 iow(db, DM9000_IMR, IMR_PAR);
894894 }
895895
896896 static void
897−dm9000_unmask_interrupts(board_info_t *db)
897+dm9000_unmask_interrupts(struct board_info *db)
898898 {
899899 iow(db, DM9000_IMR, db->imr_all);
900900 }
@@ -905,7 +905,7 @@ dm9000_unmask_interrupts(board_info_t *db) · 4 unmodified lines
905905 static void
906906 dm9000_init_dm9000(struct net_device *dev)
907907 {
908− board_info_t *db = netdev_priv(dev);
908+ struct board_info *db = netdev_priv(dev);
909909 unsigned int imr;
910910 unsigned int ncr;
911911
@@ -970,7 +970,7 @@ dm9000_init_dm9000(struct net_device *dev) · 58 unmodified lines
970970 /* Our watchdog timed out. Called by the networking layer */
971971 static void dm9000_timeout(struct net_device *dev)
972972 {
973− board_info_t *db = netdev_priv(dev);
973+ struct board_info *db = netdev_priv(dev);
974974 u8 reg_save;
975975 unsigned long flags;
976976
@@ -996,7 +996,7 @@ static void dm9000_send_packet(struct net_device *dev, · 19 unmodified lines
996996 int ip_summed,
997997 u16 pkt_len)
998998 {
999− board_info_t *dm = to_dm9000_board(dev);
999+ struct board_info *dm = to_dm9000_board(dev);
10001000
10011001 /* The DM9000 is not smart enough to leave fragmented packets alone. */
10021002 if (dm->ip_summed != ip_summed) {
@@ -1023,7 +1023,7 @@ static int · 20 unmodified lines
10231023 dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
10241024 {
10251025 unsigned long flags;
1026− board_info_t *db = netdev_priv(dev);
1026+ struct board_info *db = netdev_priv(dev);
10271027
10281028 dm9000_dbg(db, 3, "%s:\n", __func__);
10291029
@@ -1062,7 +1062,7 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev) · 32 unmodified lines
10621062 * receive the packet to upper layer, free the transmitted packet
10631063 */
10641064
1065−static void dm9000_tx_done(struct net_device *dev, board_info_t *db)
1065+static void dm9000_tx_done(struct net_device *dev, struct board_info *db)
10661066 {
10671067 int tx_status = ior(db, DM9000_NSR); /* Got TX status */
10681068
@@ -1094,7 +1094,7 @@ struct dm9000_rxhdr { · 25 unmodified lines
10941094 static void
10951095 dm9000_rx(struct net_device *dev)
10961096 {
1097− board_info_t *db = netdev_priv(dev);
1097+ struct board_info *db = netdev_priv(dev);
10981098 struct dm9000_rxhdr rxhdr;
10991099 struct sk_buff *skb;
11001100 u8 rxbyte, *rdptr;
@@ -1196,7 +1196,7 @@ dm9000_rx(struct net_device *dev) · 95 unmodified lines
11961196 static irqreturn_t dm9000_interrupt(int irq, void *dev_id)
11971197 {
11981198 struct net_device *dev = dev_id;
1199− board_info_t *db = netdev_priv(dev);
1199+ struct board_info *db = netdev_priv(dev);
12001200 int int_status;
12011201 unsigned long flags;
12021202 u8 reg_save;
@@ -1246,7 +1246,7 @@ static irqreturn_t dm9000_interrupt(int irq, void *dev_id) · 43 unmodified lines
12461246 static irqreturn_t dm9000_wol_interrupt(int irq, void *dev_id)
12471247 {
12481248 struct net_device *dev = dev_id;
1249− board_info_t *db = netdev_priv(dev);
1249+ struct board_info *db = netdev_priv(dev);
12501250 unsigned long flags;
12511251 unsigned nsr, wcr;
12521252
@@ -1296,7 +1296,7 @@ static void dm9000_poll_controller(struct net_device *dev) · 43 unmodified lines
12961296 static int
12971297 dm9000_open(struct net_device *dev)
12981298 {
1299− board_info_t *db = netdev_priv(dev);
1299+ struct board_info *db = netdev_priv(dev);
13001300 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
13011301
13021302 if (netif_msg_ifup(db))
@@ -1342,7 +1342,7 @@ dm9000_open(struct net_device *dev) · 39 unmodified lines
13421342 static void
13431343 dm9000_shutdown(struct net_device *dev)
13441344 {
1345− board_info_t *db = netdev_priv(dev);
1345+ struct board_info *db = netdev_priv(dev);
13461346
13471347 /* RESET device */
13481348 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
@@ -1358,7 +1358,7 @@ dm9000_shutdown(struct net_device *dev) · 9 unmodified lines
13581358 static int
13591359 dm9000_stop(struct net_device *ndev)
13601360 {
1361− board_info_t *db = netdev_priv(ndev);
1361+ struct board_info *db = netdev_priv(ndev);
13621362
13631363 if (netif_msg_ifdown(db))
13641364 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
@@ -1681,7 +1681,7 @@ dm9000_drv_suspend(struct device *dev) · 316 unmodified lines
16811681 {
16821682 struct platform_device *pdev = to_platform_device(dev);
16831683 struct net_device *ndev = platform_get_drvdata(pdev);
1684− board_info_t *db;
1684+ struct board_info *db;
16851685
16861686 if (ndev) {
16871687 db = netdev_priv(ndev);
@@ -1704,7 +1704,7 @@ dm9000_drv_resume(struct device *dev) · 16 unmodified lines
17041704 {
17051705 struct platform_device *pdev = to_platform_device(dev);
17061706 struct net_device *ndev = platform_get_drvdata(pdev);
1707− board_info_t *db = netdev_priv(ndev);
1707+ struct board_info *db = netdev_priv(ndev);
17081708
17091709 if (ndev) {
17101710 if (netif_running(ndev)) {
drivers/net/ethernet/freescale/fec.h+1−0
@@ -310,6 +310,7 @@ struct fec_enet_private { · 309 unmodified lines
310310 int mii_timeout;
311311 uint phy_speed;
312312 phy_interface_t phy_interface;
313+ struct device_node *phy_node;
313314 int link;
314315 int full_duplex;
315316 int speed;
drivers/net/ethernet/freescale/fec_main.c+55−21
@@ -52,6 +52,7 @@ · 51 unmodified lines
5252 #include <linux/of.h>
5353 #include <linux/of_device.h>
5454 #include <linux/of_gpio.h>
55+#include <linux/of_mdio.h>
5556 #include <linux/of_net.h>
5657 #include <linux/regulator/consumer.h>
5758 #include <linux/if_vlan.h>
@@ -1648,29 +1649,37 @@ static int fec_enet_mii_probe(struct net_device *ndev) · 1590 unmodified lines
16481649
16491650 fep->phy_dev = NULL;
16501651
1651− /* check for attached phy */
1652− for (phy_id = 0; (phy_id < PHY_MAX_ADDR); phy_id++) {
1653− if ((fep->mii_bus->phy_mask & (1 << phy_id)))
1654− continue;
1655− if (fep->mii_bus->phy_map[phy_id] == NULL)
1656− continue;
1657− if (fep->mii_bus->phy_map[phy_id]->phy_id == 0)
1658− continue;
1659− if (dev_id--)
1660− continue;
1661− strncpy(mdio_bus_id, fep->mii_bus->id, MII_BUS_ID_SIZE);
1662− break;
1663− }
1652+ if (fep->phy_node) {
1653+ phy_dev = of_phy_connect(ndev, fep->phy_node,
1654+ &fec_enet_adjust_link, 0,
1655+ fep->phy_interface);
1656+ } else {
1657+ /* check for attached phy */
1658+ for (phy_id = 0; (phy_id < PHY_MAX_ADDR); phy_id++) {
1659+ if ((fep->mii_bus->phy_mask & (1 << phy_id)))
1660+ continue;
1661+ if (fep->mii_bus->phy_map[phy_id] == NULL)
1662+ continue;
1663+ if (fep->mii_bus->phy_map[phy_id]->phy_id == 0)
1664+ continue;
1665+ if (dev_id--)
1666+ continue;
1667+ strncpy(mdio_bus_id, fep->mii_bus->id, MII_BUS_ID_SIZE);
1668+ break;
1669+ }
16641670
1665− if (phy_id >= PHY_MAX_ADDR) {
1666− netdev_info(ndev, "no PHY, assuming direct connection to switch\n");
1667− strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE);
1668− phy_id = 0;
1671+ if (phy_id >= PHY_MAX_ADDR) {
1672+ netdev_info(ndev, "no PHY, assuming direct connection to switch\n");
1673+ strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE);
1674+ phy_id = 0;
1675+ }
1676+
1677+ snprintf(phy_name, sizeof(phy_name),
1678+ PHY_ID_FMT, mdio_bus_id, phy_id);
1679+ phy_dev = phy_connect(ndev, phy_name, &fec_enet_adjust_link,
1680+ fep->phy_interface);
16691681 }
16701682
1671− snprintf(phy_name, sizeof(phy_name), PHY_ID_FMT, mdio_bus_id, phy_id);
1672− phy_dev = phy_connect(ndev, phy_name, &fec_enet_adjust_link,
1673− fep->phy_interface);
16741683 if (IS_ERR(phy_dev)) {
16751684 netdev_err(ndev, "could not attach to PHY\n");
16761685 return PTR_ERR(phy_dev);
@@ -1707,6 +1716,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) · 30 unmodified lines
17071716 struct fec_enet_private *fep = netdev_priv(ndev);
17081717 const struct platform_device_id *id_entry =
17091718 platform_get_device_id(fep->pdev);
1719+ struct device_node *node;
17101720 int err = -ENXIO, i;
17111721
17121722 /*
@@ -1774,7 +1784,15 @@ static int fec_enet_mii_init(struct platform_device *pdev) · 61 unmodified lines
17741784 for (i = 0; i < PHY_MAX_ADDR; i++)
17751785 fep->mii_bus->irq[i] = PHY_POLL;
17761786
1777− if (mdiobus_register(fep->mii_bus))
1787+ node = of_get_child_by_name(pdev->dev.of_node, "mdio");
1788+ if (node) {
1789+ err = of_mdiobus_register(fep->mii_bus, node);
1790+ of_node_put(node);
1791+ } else {
1792+ err = mdiobus_register(fep->mii_bus);
1793+ }
1794+
1795+ if (err)
17781796 goto err_out_free_mdio_irq;
17791797
17801798 mii_cnt++;
@@ -2527,6 +2545,7 @@ fec_probe(struct platform_device *pdev) · 746 unmodified lines
25272545 struct resource *r;
25282546 const struct of_device_id *of_id;
25292547 static int dev_id;
2548+ struct device_node *np = pdev->dev.of_node, *phy_node;
25302549
25312550 of_id = of_match_device(fec_dt_ids, &pdev->dev);
25322551 if (of_id)
@@ -2566,6 +2585,18 @@ fec_probe(struct platform_device *pdev) · 33 unmodified lines
25662585
25672586 platform_set_drvdata(pdev, ndev);
25682587
2588+ phy_node = of_parse_phandle(np, "phy-handle", 0);
2589+ if (!phy_node && of_phy_is_fixed_link(np)) {
2590+ ret = of_phy_register_fixed_link(np);
2591+ if (ret < 0) {
2592+ dev_err(&pdev->dev,
2593+ "broken fixed-link specification\n");
2594+ goto failed_phy;
2595+ }
2596+ phy_node = of_node_get(np);
2597+ }
2598+ fep->phy_node = phy_node;
2599+
25692600 ret = of_get_phy_mode(pdev->dev.of_node);
25702601 if (ret < 0) {
25712602 pdata = dev_get_platdata(&pdev->dev);
@@ -2670,6 +2701,8 @@ failed_init: · 98 unmodified lines
26702701 failed_regulator:
26712702 fec_enet_clk_enable(ndev, false);
26722703 failed_clk:
2704+failed_phy:
2705+ of_node_put(phy_node);
26732706 failed_ioremap:
26742707 free_netdev(ndev);
26752708
@@ -2691,6 +2724,7 @@ fec_drv_remove(struct platform_device *pdev) · 15 unmodified lines
26912724 if (fep->ptp_clock)
26922725 ptp_clock_unregister(fep->ptp_clock);
26932726 fec_enet_clk_enable(ndev, false);
2727+ of_node_put(fep->phy_node);
26942728 free_netdev(ndev);
26952729
26962730 return 0;
drivers/net/ethernet/freescale/fec_mpc52xx.c+1−2
@@ -1015,8 +1015,7 @@ mpc52xx_fec_remove(struct platform_device *op) · 1014 unmodified lines
10151015
10161016 unregister_netdev(ndev);
10171017
1018− if (priv->phy_node)
1019− of_node_put(priv->phy_node);
1018+ of_node_put(priv->phy_node);
10201019 priv->phy_node = NULL;
10211020
10221021 irq_dispose_mapping(ndev->irq);
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c+1−1
@@ -1033,7 +1033,7 @@ static int fs_enet_probe(struct platform_device *ofdev) · 1032 unmodified lines
10331033 /* In the case of a fixed PHY, the DT node associated
10341034 * to the PHY is the Ethernet MAC DT node.
10351035 */
1036− fpi->phy_node = ofdev->dev.of_node;
1036+ fpi->phy_node = of_node_get(ofdev->dev.of_node);
10371037 }
10381038
10391039 if (of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc5125-fec")) {
drivers/net/ethernet/freescale/gianfar.c+6−10
@@ -892,12 +892,12 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) · 891 unmodified lines
892892 /* In the case of a fixed PHY, the DT node associated
893893 * to the PHY is the Ethernet MAC DT node.
894894 */
895− if (of_phy_is_fixed_link(np)) {
895+ if (!priv->phy_node && of_phy_is_fixed_link(np)) {
896896 err = of_phy_register_fixed_link(np);
897897 if (err)
898898 goto err_grp_init;
899899
900− priv->phy_node = np;
900+ priv->phy_node = of_node_get(np);
901901 }
902902
903903 /* Find the TBI PHY. If it's not there, we don't support SGMII */
@@ -1435,10 +1435,8 @@ register_fail: · 531 unmodified lines
14351435 unmap_group_regs(priv);
14361436 gfar_free_rx_queues(priv);
14371437 gfar_free_tx_queues(priv);
1438− if (priv->phy_node)
1439− of_node_put(priv->phy_node);
1440− if (priv->tbi_node)
1441− of_node_put(priv->tbi_node);
1438+ of_node_put(priv->phy_node);
1439+ of_node_put(priv->tbi_node);
14421440 free_gfar_dev(priv);
14431441 return err;
14441442 }
@@ -1447,10 +1445,8 @@ static int gfar_remove(struct platform_device *ofdev) · 2 unmodified lines
14471445 {
14481446 struct gfar_private *priv = platform_get_drvdata(ofdev);
14491447
1450− if (priv->phy_node)
1451− of_node_put(priv->phy_node);
1452− if (priv->tbi_node)
1453− of_node_put(priv->tbi_node);
1448+ of_node_put(priv->phy_node);
1449+ of_node_put(priv->tbi_node);
14541450
14551451 unregister_netdev(priv->ndev);
14561452 unmap_group_regs(priv);
drivers/net/ethernet/freescale/ucc_geth.c+15−9
@@ -3785,16 +3785,15 @@ static int ucc_geth_probe(struct platform_device* ofdev) · 3784 unmodified lines
37853785 ug_info->uf_info.irq = irq_of_parse_and_map(np, 0);
37863786
37873787 ug_info->phy_node = of_parse_phandle(np, "phy-handle", 0);
3788− if (!ug_info->phy_node) {
3789− /* In the case of a fixed PHY, the DT node associated
3788+ if (!ug_info->phy_node && of_phy_is_fixed_link(np)) {
3789+ /*
3790+ * In the case of a fixed PHY, the DT node associated
37903791 * to the PHY is the Ethernet MAC DT node.
37913792 */
3792− if (of_phy_is_fixed_link(np)) {
3793− err = of_phy_register_fixed_link(np);
3794− if (err)
3795− return err;
3796− }
3797− ug_info->phy_node = np;
3793+ err = of_phy_register_fixed_link(np);
3794+ if (err)
3795+ return err;
3796+ ug_info->phy_node = of_node_get(np);
37983797 }
37993798
38003799 /* Find the TBI PHY node. If it's not there, we don't support SGMII */
@@ -3862,8 +3861,11 @@ static int ucc_geth_probe(struct platform_device* ofdev) · 61 unmodified lines
38623861 /* Create an ethernet device instance */
38633862 dev = alloc_etherdev(sizeof(*ugeth));
38643863
3865− if (dev == NULL)
3864+ if (dev == NULL) {
3865+ of_node_put(ug_info->tbi_node);
3866+ of_node_put(ug_info->phy_node);
38663867 return -ENOMEM;
3868+ }
38673869
38683870 ugeth = netdev_priv(dev);
38693871 spin_lock_init(&ugeth->lock);
@@ -3897,6 +3899,8 @@ static int ucc_geth_probe(struct platform_device* ofdev) · 27 unmodified lines
38973899 pr_err("%s: Cannot register net device, aborting\n",
38983900 dev->name);
38993901 free_netdev(dev);
3902+ of_node_put(ug_info->tbi_node);
3903+ of_node_put(ug_info->phy_node);
39003904 return err;
39013905 }
39023906
@@ -3920,6 +3924,8 @@ static int ucc_geth_remove(struct platform_device* ofdev) · 17 unmodified lines
39203924 unregister_netdev(dev);
39213925 free_netdev(dev);
39223926 ucc_geth_memclean(ugeth);
3927+ of_node_put(ugeth->ug_info->tbi_node);
3928+ of_node_put(ugeth->ug_info->phy_node);
39233929
39243930 return 0;
39253931 }
drivers/net/ethernet/fujitsu/fmvj18x_cs.c+17−17
@@ -99,23 +99,23 @@ static const struct ethtool_ops netdev_ethtool_ops; · 98 unmodified lines
9999 /*
100100 card type
101101 */
102−typedef enum { MBH10302, MBH10304, TDK, CONTEC, LA501, UNGERMANN,
102+enum cardtype { MBH10302, MBH10304, TDK, CONTEC, LA501, UNGERMANN,
103103 XXX10304, NEC, KME
104−} cardtype_t;
104+};
105105
106106 /*
107107 driver specific data structure
108108 */
109−typedef struct local_info_t {
109+struct local_info {
110110 struct pcmcia_device *p_dev;
111111 long open_time;
112112 uint tx_started:1;
113113 uint tx_queue;
114114 u_short tx_queue_len;
115− cardtype_t cardtype;
115+ enum cardtype cardtype;
116116 u_short sent;
117117 u_char __iomem *base;
118−} local_info_t;
118+};
119119
120120 #define MC_FILTERBREAK 64
121121
@@ -232,13 +232,13 @@ static const struct net_device_ops fjn_netdev_ops = { · 110 unmodified lines
232232
233233 static int fmvj18x_probe(struct pcmcia_device *link)
234234 {
235− local_info_t *lp;
235+ struct local_info *lp;
236236 struct net_device *dev;
237237
238238 dev_dbg(&link->dev, "fmvj18x_attach()\n");
239239
240240 /* Make up a FMVJ18x specific data structure */
241− dev = alloc_etherdev(sizeof(local_info_t));
241+ dev = alloc_etherdev(sizeof(struct local_info));
242242 if (!dev)
243243 return -ENOMEM;
244244 lp = netdev_priv(dev);
@@ -327,10 +327,10 @@ static int fmvj18x_ioprobe(struct pcmcia_device *p_dev, void *priv_data) · 82 unmodified lines
327327 static int fmvj18x_config(struct pcmcia_device *link)
328328 {
329329 struct net_device *dev = link->priv;
330− local_info_t *lp = netdev_priv(dev);
330+ struct local_info *lp = netdev_priv(dev);
331331 int i, ret;
332332 unsigned int ioaddr;
333− cardtype_t cardtype;
333+ enum cardtype cardtype;
334334 char *card_name = "unknown";
335335 u8 *buf;
336336 size_t len;
@@ -584,7 +584,7 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link) · 247 unmodified lines
584584 int i;
585585 struct net_device *dev = link->priv;
586586 unsigned int ioaddr;
587− local_info_t *lp = netdev_priv(dev);
587+ struct local_info *lp = netdev_priv(dev);
588588
589589 /* Allocate a small memory window */
590590 link->resource[3]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
@@ -626,7 +626,7 @@ static void fmvj18x_release(struct pcmcia_device *link) · 35 unmodified lines
626626 {
627627
628628 struct net_device *dev = link->priv;
629− local_info_t *lp = netdev_priv(dev);
629+ struct local_info *lp = netdev_priv(dev);
630630 u_char __iomem *tmp;
631631
632632 dev_dbg(&link->dev, "fmvj18x_release\n");
@@ -711,7 +711,7 @@ module_pcmcia_driver(fmvj18x_cs_driver); · 78 unmodified lines
711711 static irqreturn_t fjn_interrupt(int dummy, void *dev_id)
712712 {
713713 struct net_device *dev = dev_id;
714− local_info_t *lp = netdev_priv(dev);
714+ struct local_info *lp = netdev_priv(dev);
715715 unsigned int ioaddr;
716716 unsigned short tx_stat, rx_stat;
717717
@@ -772,7 +772,7 @@ static irqreturn_t fjn_interrupt(int dummy, void *dev_id) · 54 unmodified lines
772772
773773 static void fjn_tx_timeout(struct net_device *dev)
774774 {
775− struct local_info_t *lp = netdev_priv(dev);
775+ struct local_info *lp = netdev_priv(dev);
776776 unsigned int ioaddr = dev->base_addr;
777777
778778 netdev_notice(dev, "transmit timed out with status %04x, %s?\n",
@@ -802,7 +802,7 @@ static void fjn_tx_timeout(struct net_device *dev) · 23 unmodified lines
802802 static netdev_tx_t fjn_start_xmit(struct sk_buff *skb,
803803 struct net_device *dev)
804804 {
805− struct local_info_t *lp = netdev_priv(dev);
805+ struct local_info *lp = netdev_priv(dev);
806806 unsigned int ioaddr = dev->base_addr;
807807 short length = skb->len;
808808
@@ -874,7 +874,7 @@ static netdev_tx_t fjn_start_xmit(struct sk_buff *skb, · 65 unmodified lines
874874
875875 static void fjn_reset(struct net_device *dev)
876876 {
877− struct local_info_t *lp = netdev_priv(dev);
877+ struct local_info *lp = netdev_priv(dev);
878878 unsigned int ioaddr = dev->base_addr;
879879 int i;
880880
@@ -1058,7 +1058,7 @@ static int fjn_config(struct net_device *dev, struct ifmap *map){ · 177 unmodified lines
10581058
10591059 static int fjn_open(struct net_device *dev)
10601060 {
1061− struct local_info_t *lp = netdev_priv(dev);
1061+ struct local_info *lp = netdev_priv(dev);
10621062 struct pcmcia_device *link = lp->p_dev;
10631063
10641064 pr_debug("fjn_open('%s').\n", dev->name);
@@ -1083,7 +1083,7 @@ static int fjn_open(struct net_device *dev) · 18 unmodified lines
10831083
10841084 static int fjn_close(struct net_device *dev)
10851085 {
1086− struct local_info_t *lp = netdev_priv(dev);
1086+ struct local_info *lp = netdev_priv(dev);
10871087 struct pcmcia_device *link = lp->p_dev;
10881088 unsigned int ioaddr = dev->base_addr;
10891089
drivers/net/ethernet/marvell/mvneta.c+6−3
@@ -2969,14 +2969,14 @@ static int mvneta_probe(struct platform_device *pdev) · 2968 unmodified lines
29692969 /* In the case of a fixed PHY, the DT node associated
29702970 * to the PHY is the Ethernet MAC DT node.
29712971 */
2972− phy_node = dn;
2972+ phy_node = of_node_get(dn);
29732973 }
29742974
29752975 phy_mode = of_get_phy_mode(dn);
29762976 if (phy_mode < 0) {
29772977 dev_err(&pdev->dev, "incorrect phy-mode\n");
29782978 err = -EINVAL;
2979− goto err_free_irq;
2979+ goto err_put_phy_node;
29802980 }
29812981
29822982 dev->tx_queue_len = MVNETA_MAX_TXD;
@@ -2992,7 +2992,7 @@ static int mvneta_probe(struct platform_device *pdev) · 9 unmodified lines
29922992 pp->clk = devm_clk_get(&pdev->dev, NULL);
29932993 if (IS_ERR(pp->clk)) {
29942994 err = PTR_ERR(pp->clk);
2995− goto err_free_irq;
2995+ goto err_put_phy_node;
29962996 }
29972997
29982998 clk_prepare_enable(pp->clk);
@@ -3071,6 +3071,8 @@ err_free_stats: · 72 unmodified lines
30713071 free_percpu(pp->stats);
30723072 err_clk:
30733073 clk_disable_unprepare(pp->clk);
3074+err_put_phy_node:
3075+ of_node_put(phy_node);
30743076 err_free_irq:
30753077 irq_dispose_mapping(dev->irq);
30763078 err_free_netdev:
@@ -3088,6 +3090,7 @@ static int mvneta_remove(struct platform_device *pdev) · 11 unmodified lines
30883090 clk_disable_unprepare(pp->clk);
30893091 free_percpu(pp->stats);
30903092 irq_dispose_mapping(dev->irq);
3093+ of_node_put(pp->phy_node);
30913094 free_netdev(dev);
30923095
30933096 return 0;
drivers/net/ethernet/myricom/myri10ge/myri10ge.c+1−0
@@ -574,6 +574,7 @@ myri10ge_validate_firmware(struct myri10ge_priv *mgp, · 573 unmodified lines
574574
575575 /* save firmware version for ethtool */
576576 strncpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version));
577+ mgp->fw_version[sizeof(mgp->fw_version) - 1] = '\0';
577578
578579 sscanf(mgp->fw_version, "%d.%d.%d", &mgp->fw_ver_major,
579580 &mgp->fw_ver_minor, &mgp->fw_ver_tiny);
drivers/net/ethernet/qlogic/qlcnic/Makefile+1−1
@@ -8,7 +8,7 @@ qlcnic-y := qlcnic_hw.o qlcnic_main.o qlcnic_init.o \ · 7 unmodified lines
88 qlcnic_ethtool.o qlcnic_ctx.o qlcnic_io.o \
99 qlcnic_sysfs.o qlcnic_minidump.o qlcnic_83xx_hw.o \
1010 qlcnic_83xx_init.o qlcnic_83xx_vnic.o \
11− qlcnic_minidump.o qlcnic_sriov_common.o
11+ qlcnic_sriov_common.o
1212
1313 qlcnic-$(CONFIG_QLCNIC_SRIOV) += qlcnic_sriov_pf.o
1414
drivers/net/ethernet/smsc/smsc911x.h+1−1
@@ -51,7 +51,7 @@ · 50 unmodified lines
5151
5252 #ifdef CONFIG_DEBUG_SPINLOCK
5353 #define SMSC_ASSERT_MAC_LOCK(pdata) \
54− WARN_ON(!spin_is_locked(&pdata->mac_lock))
54+ WARN_ON_SMP(!spin_is_locked(&pdata->mac_lock))
5555 #else
5656 #define SMSC_ASSERT_MAC_LOCK(pdata) do {} while (0)
5757 #endif /* CONFIG_DEBUG_SPINLOCK */
drivers/net/ethernet/ti/cpmac.c+1−0
@@ -1130,6 +1130,7 @@ static int cpmac_probe(struct platform_device *pdev) · 1129 unmodified lines
11301130 strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); /* fixed phys bus */
11311131 phy_id = pdev->id;
11321132 }
1133+ mdio_bus_id[sizeof(mdio_bus_id) - 1] = '\0';
11331134
11341135 dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES);
11351136 if (!dev)
drivers/net/ethernet/xilinx/ll_temac_main.c+1−2
@@ -1148,8 +1148,7 @@ static int temac_of_remove(struct platform_device *op) · 1147 unmodified lines
11481148 temac_mdio_teardown(lp);
11491149 unregister_netdev(ndev);
11501150 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group);
1151− if (lp->phy_node)
1152− of_node_put(lp->phy_node);
1151+ of_node_put(lp->phy_node);
11531152 lp->phy_node = NULL;
11541153 iounmap(lp->regs);
11551154 if (lp->sdma_regs)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c+1−2
@@ -1630,8 +1630,7 @@ static int axienet_of_remove(struct platform_device *op) · 1629 unmodified lines
16301630 axienet_mdio_teardown(lp);
16311631 unregister_netdev(ndev);
16321632
1633− if (lp->phy_node)
1634− of_node_put(lp->phy_node);
1633+ of_node_put(lp->phy_node);
16351634 lp->phy_node = NULL;
16361635
16371636 iounmap(lp->regs);
drivers/net/ethernet/xircom/xirc2ps_cs.c+20−20
@@ -266,7 +266,7 @@ static void xirc2ps_detach(struct pcmcia_device *p_dev); · 265 unmodified lines
266266
267267 static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id);
268268
269−typedef struct local_info_t {
269+struct local_info {
270270 struct net_device *dev;
271271 struct pcmcia_device *p_dev;
272272
@@ -281,7 +281,7 @@ typedef struct local_info_t { · 8 unmodified lines
281281 unsigned last_ptr_value; /* last packets transmitted value */
282282 const char *manf_str;
283283 struct work_struct tx_timeout_task;
284−} local_info_t;
284+};
285285
286286 /****************
287287 * Some more prototypes
@@ -475,12 +475,12 @@ static int · 187 unmodified lines
475475 xirc2ps_probe(struct pcmcia_device *link)
476476 {
477477 struct net_device *dev;
478− local_info_t *local;
478+ struct local_info *local;
479479
480480 dev_dbg(&link->dev, "attach()\n");
481481
482482 /* Allocate the device structure */
483− dev = alloc_etherdev(sizeof(local_info_t));
483+ dev = alloc_etherdev(sizeof(struct local_info));
484484 if (!dev)
485485 return -ENOMEM;
486486 local = netdev_priv(dev);
@@ -536,7 +536,7 @@ static int · 49 unmodified lines
536536 set_card_type(struct pcmcia_device *link)
537537 {
538538 struct net_device *dev = link->priv;
539− local_info_t *local = netdev_priv(dev);
539+ struct local_info *local = netdev_priv(dev);
540540 u8 *buf;
541541 unsigned int cisrev, mediaid, prodid;
542542 size_t len;
@@ -690,7 +690,7 @@ static int · 147 unmodified lines
690690 xirc2ps_config(struct pcmcia_device * link)
691691 {
692692 struct net_device *dev = link->priv;
693− local_info_t *local = netdev_priv(dev);
693+ struct local_info *local = netdev_priv(dev);
694694 unsigned int ioaddr;
695695 int err;
696696 u8 *buf;
@@ -931,7 +931,7 @@ xirc2ps_release(struct pcmcia_device *link) · 234 unmodified lines
931931
932932 if (link->resource[2]->end) {
933933 struct net_device *dev = link->priv;
934− local_info_t *local = netdev_priv(dev);
934+ struct local_info *local = netdev_priv(dev);
935935 if (local->dingo)
936936 iounmap(local->dingo_ccr - 0x0800);
937937 }
@@ -975,7 +975,7 @@ static irqreturn_t · 37 unmodified lines
975975 xirc2ps_interrupt(int irq, void *dev_id)
976976 {
977977 struct net_device *dev = (struct net_device *)dev_id;
978− local_info_t *lp = netdev_priv(dev);
978+ struct local_info *lp = netdev_priv(dev);
979979 unsigned int ioaddr;
980980 u_char saved_page;
981981 unsigned bytes_rcvd;
@@ -1194,8 +1194,8 @@ xirc2ps_interrupt(int irq, void *dev_id) · 212 unmodified lines
11941194 static void
11951195 xirc2ps_tx_timeout_task(struct work_struct *work)
11961196 {
1197− local_info_t *local =
1198− container_of(work, local_info_t, tx_timeout_task);
1197+ struct local_info *local =
1198+ container_of(work, struct local_info, tx_timeout_task);
11991199 struct net_device *dev = local->dev;
12001200 /* reset the card */
12011201 do_reset(dev,1);
@@ -1206,7 +1206,7 @@ xirc2ps_tx_timeout_task(struct work_struct *work) · 4 unmodified lines
12061206 static void
12071207 xirc_tx_timeout(struct net_device *dev)
12081208 {
1209− local_info_t *lp = netdev_priv(dev);
1209+ struct local_info *lp = netdev_priv(dev);
12101210 dev->stats.tx_errors++;
12111211 netdev_notice(dev, "transmit timed out\n");
12121212 schedule_work(&lp->tx_timeout_task);
@@ -1215,7 +1215,7 @@ xirc_tx_timeout(struct net_device *dev) · 2 unmodified lines
12151215 static netdev_tx_t
12161216 do_start_xmit(struct sk_buff *skb, struct net_device *dev)
12171217 {
1218− local_info_t *lp = netdev_priv(dev);
1218+ struct local_info *lp = netdev_priv(dev);
12191219 unsigned int ioaddr = dev->base_addr;
12201220 int okay;
12211221 unsigned freespace;
@@ -1300,7 +1300,7 @@ static void set_address(struct set_address_info *sa_info, char *addr) · 78 unmodified lines
13001300 static void set_addresses(struct net_device *dev)
13011301 {
13021302 unsigned int ioaddr = dev->base_addr;
1303− local_info_t *lp = netdev_priv(dev);
1303+ struct local_info *lp = netdev_priv(dev);
13041304 struct netdev_hw_addr *ha;
13051305 struct set_address_info sa_info;
13061306 int i;
@@ -1362,7 +1362,7 @@ set_multicast_list(struct net_device *dev) · 55 unmodified lines
13621362 static int
13631363 do_config(struct net_device *dev, struct ifmap *map)
13641364 {
1365− local_info_t *local = netdev_priv(dev);
1365+ struct local_info *local = netdev_priv(dev);
13661366
13671367 pr_debug("do_config(%p)\n", dev);
13681368 if (map->port != 255 && map->port != dev->if_port) {
@@ -1387,7 +1387,7 @@ do_config(struct net_device *dev, struct ifmap *map) · 18 unmodified lines
13871387 static int
13881388 do_open(struct net_device *dev)
13891389 {
1390− local_info_t *lp = netdev_priv(dev);
1390+ struct local_info *lp = netdev_priv(dev);
13911391 struct pcmcia_device *link = lp->p_dev;
13921392
13931393 dev_dbg(&link->dev, "do_open(%p)\n", dev);
@@ -1421,7 +1421,7 @@ static const struct ethtool_ops netdev_ethtool_ops = { · 27 unmodified lines
14211421 static int
14221422 do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
14231423 {
1424− local_info_t *local = netdev_priv(dev);
1424+ struct local_info *local = netdev_priv(dev);
14251425 unsigned int ioaddr = dev->base_addr;
14261426 struct mii_ioctl_data *data = if_mii(rq);
14271427
@@ -1453,7 +1453,7 @@ do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) · 25 unmodified lines
14531453 static void
14541454 hardreset(struct net_device *dev)
14551455 {
1456− local_info_t *local = netdev_priv(dev);
1456+ struct local_info *local = netdev_priv(dev);
14571457 unsigned int ioaddr = dev->base_addr;
14581458
14591459 SelectPage(4);
@@ -1470,7 +1470,7 @@ hardreset(struct net_device *dev) · 10 unmodified lines
14701470 static void
14711471 do_reset(struct net_device *dev, int full)
14721472 {
1473− local_info_t *local = netdev_priv(dev);
1473+ struct local_info *local = netdev_priv(dev);
14741474 unsigned int ioaddr = dev->base_addr;
14751475 unsigned value;
14761476
@@ -1631,7 +1631,7 @@ do_reset(struct net_device *dev, int full) · 154 unmodified lines
16311631 static int
16321632 init_mii(struct net_device *dev)
16331633 {
1634− local_info_t *local = netdev_priv(dev);
1634+ struct local_info *local = netdev_priv(dev);
16351635 unsigned int ioaddr = dev->base_addr;
16361636 unsigned control, status, linkpartner;
16371637 int i;
@@ -1715,7 +1715,7 @@ static int · 77 unmodified lines
17151715 do_stop(struct net_device *dev)
17161716 {
17171717 unsigned int ioaddr = dev->base_addr;
1718− local_info_t *lp = netdev_priv(dev);
1718+ struct local_info *lp = netdev_priv(dev);
17191719 struct pcmcia_device *link = lp->p_dev;
17201720
17211721 dev_dbg(&link->dev, "do_stop(%p)\n", dev);
drivers/net/wan/hdlc_fr.c+32−31
@@ -90,7 +90,7 @@ · 89 unmodified lines
9090 #define LMI_ANSI_LENGTH 14
9191
9292
93−typedef struct {
93+struct fr_hdr {
9494 #if defined(__LITTLE_ENDIAN_BITFIELD)
9595 unsigned ea1: 1;
9696 unsigned cr: 1;
@@ -112,14 +112,14 @@ typedef struct { · 15 unmodified lines
112112 unsigned de: 1;
113113 unsigned ea2: 1;
114114 #endif
115−}__packed fr_hdr;
115+} __packed;
116116
117117
118−typedef struct pvc_device_struct {
118+struct pvc_device {
119119 struct net_device *frad;
120120 struct net_device *main;
121121 struct net_device *ether; /* bridged Ethernet interface */
122− struct pvc_device_struct *next; /* Sorted in ascending DLCI order */
122+ struct pvc_device *next; /* Sorted in ascending DLCI order */
123123 int dlci;
124124 int open_count;
125125
@@ -132,11 +132,11 @@ typedef struct pvc_device_struct { · 6 unmodified lines
132132 unsigned int becn: 1;
133133 unsigned int bandwidth; /* Cisco LMI reporting only */
134134 }state;
135−}pvc_device;
135+};
136136
137137 struct frad_state {
138138 fr_proto settings;
139− pvc_device *first_pvc;
139+ struct pvc_device *first_pvc;
140140 int dce_pvc_count;
141141
142142 struct timer_list timer;
@@ -174,9 +174,9 @@ static inline struct frad_state* state(hdlc_device *hdlc) · 31 unmodified lines
174174 }
175175
176176
177−static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci)
177+static inline struct pvc_device *find_pvc(hdlc_device *hdlc, u16 dlci)
178178 {
179− pvc_device *pvc = state(hdlc)->first_pvc;
179+ struct pvc_device *pvc = state(hdlc)->first_pvc;
180180
181181 while (pvc) {
182182 if (pvc->dlci == dlci)
@@ -190,10 +190,10 @@ static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci) · 7 unmodified lines
190190 }
191191
192192
193−static pvc_device* add_pvc(struct net_device *dev, u16 dlci)
193+static struct pvc_device *add_pvc(struct net_device *dev, u16 dlci)
194194 {
195195 hdlc_device *hdlc = dev_to_hdlc(dev);
196− pvc_device *pvc, **pvc_p = &state(hdlc)->first_pvc;
196+ struct pvc_device *pvc, **pvc_p = &state(hdlc)->first_pvc;
197197
198198 while (*pvc_p) {
199199 if ((*pvc_p)->dlci == dlci)
@@ -203,7 +203,7 @@ static pvc_device* add_pvc(struct net_device *dev, u16 dlci) · 3 unmodified lines
203203 pvc_p = &(*pvc_p)->next;
204204 }
205205
206− pvc = kzalloc(sizeof(pvc_device), GFP_ATOMIC);
206+ pvc = kzalloc(sizeof(*pvc), GFP_ATOMIC);
207207 #ifdef DEBUG_PVC
208208 printk(KERN_DEBUG "add_pvc: allocated pvc %p, frad %p\n", pvc, dev);
209209 #endif
@@ -218,13 +218,13 @@ static pvc_device* add_pvc(struct net_device *dev, u16 dlci) · 8 unmodified lines
218218 }
219219
220220
221−static inline int pvc_is_used(pvc_device *pvc)
221+static inline int pvc_is_used(struct pvc_device *pvc)
222222 {
223223 return pvc->main || pvc->ether;
224224 }
225225
226226
227−static inline void pvc_carrier(int on, pvc_device *pvc)
227+static inline void pvc_carrier(int on, struct pvc_device *pvc)
228228 {
229229 if (on) {
230230 if (pvc->main)
@@ -246,11 +246,11 @@ static inline void pvc_carrier(int on, pvc_device *pvc) · 15 unmodified lines
246246
247247 static inline void delete_unused_pvcs(hdlc_device *hdlc)
248248 {
249− pvc_device **pvc_p = &state(hdlc)->first_pvc;
249+ struct pvc_device **pvc_p = &state(hdlc)->first_pvc;
250250
251251 while (*pvc_p) {
252252 if (!pvc_is_used(*pvc_p)) {
253− pvc_device *pvc = *pvc_p;
253+ struct pvc_device *pvc = *pvc_p;
254254 #ifdef DEBUG_PVC
255255 printk(KERN_DEBUG "freeing unused pvc: %p\n", pvc);
256256 #endif
@@ -263,7 +263,8 @@ static inline void delete_unused_pvcs(hdlc_device *hdlc) · 6 unmodified lines
263263 }
264264
265265
266−static inline struct net_device** get_dev_p(pvc_device *pvc, int type)
266+static inline struct net_device **get_dev_p(struct pvc_device *pvc,
267+ int type)
267268 {
268269 if (type == ARPHRD_ETHER)
269270 return &pvc->ether;
@@ -342,7 +343,7 @@ static int fr_hard_header(struct sk_buff **skb_p, u16 dlci) · 72 unmodified lines
342343
343344 static int pvc_open(struct net_device *dev)
344345 {
345− pvc_device *pvc = dev->ml_priv;
346+ struct pvc_device *pvc = dev->ml_priv;
346347
347348 if ((pvc->frad->flags & IFF_UP) == 0)
348349 return -EIO; /* Frad must be UP in order to activate PVC */
@@ -362,7 +363,7 @@ static int pvc_open(struct net_device *dev) · 13 unmodified lines
362363
363364 static int pvc_close(struct net_device *dev)
364365 {
365− pvc_device *pvc = dev->ml_priv;
366+ struct pvc_device *pvc = dev->ml_priv;
366367
367368 if (--pvc->open_count == 0) {
368369 hdlc_device *hdlc = dev_to_hdlc(pvc->frad);
@@ -381,7 +382,7 @@ static int pvc_close(struct net_device *dev) · 12 unmodified lines
381382
382383 static int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
383384 {
384− pvc_device *pvc = dev->ml_priv;
385+ struct pvc_device *pvc = dev->ml_priv;
385386 fr_proto_pvc_info info;
386387
387388 if (ifr->ifr_settings.type == IF_GET_PROTO) {
@@ -409,7 +410,7 @@ static int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) · 21 unmodified lines
409410
410411 static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev)
411412 {
412− pvc_device *pvc = dev->ml_priv;
413+ struct pvc_device *pvc = dev->ml_priv;
413414
414415 if (pvc->state.active) {
415416 if (dev->type == ARPHRD_ETHER) {
@@ -444,7 +445,7 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev) · 28 unmodified lines
444445 return NETDEV_TX_OK;
445446 }
446447
447−static inline void fr_log_dlci_active(pvc_device *pvc)
448+static inline void fr_log_dlci_active(struct pvc_device *pvc)
448449 {
449450 netdev_info(pvc->frad, "DLCI %d [%s%s%s]%s %s\n",
450451 pvc->dlci,
@@ -469,7 +470,7 @@ static void fr_lmi_send(struct net_device *dev, int fullrep) · 18 unmodified lines
469470 {
470471 hdlc_device *hdlc = dev_to_hdlc(dev);
471472 struct sk_buff *skb;
472− pvc_device *pvc = state(hdlc)->first_pvc;
473+ struct pvc_device *pvc = state(hdlc)->first_pvc;
473474 int lmi = state(hdlc)->settings.lmi;
474475 int dce = state(hdlc)->settings.dce;
475476 int len = lmi == LMI_ANSI ? LMI_ANSI_LENGTH : LMI_CCITT_CISCO_LENGTH;
@@ -566,7 +567,7 @@ static void fr_lmi_send(struct net_device *dev, int fullrep) · 90 unmodified lines
566567 static void fr_set_link_state(int reliable, struct net_device *dev)
567568 {
568569 hdlc_device *hdlc = dev_to_hdlc(dev);
569− pvc_device *pvc = state(hdlc)->first_pvc;
570+ struct pvc_device *pvc = state(hdlc)->first_pvc;
570571
571572 state(hdlc)->reliable = reliable;
572573 if (reliable) {
@@ -652,7 +653,7 @@ static void fr_timer(unsigned long arg) · 79 unmodified lines
652653 static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb)
653654 {
654655 hdlc_device *hdlc = dev_to_hdlc(dev);
655− pvc_device *pvc;
656+ struct pvc_device *pvc;
656657 u8 rxseq, txseq;
657658 int lmi = state(hdlc)->settings.lmi;
658659 int dce = state(hdlc)->settings.dce;
@@ -869,10 +870,10 @@ static int fr_rx(struct sk_buff *skb) · 210 unmodified lines
869870 {
870871 struct net_device *frad = skb->dev;
871872 hdlc_device *hdlc = dev_to_hdlc(frad);
872− fr_hdr *fh = (fr_hdr*)skb->data;
873+ struct fr_hdr *fh = (struct fr_hdr *)skb->data;
873874 u8 *data = skb->data;
874875 u16 dlci;
875− pvc_device *pvc;
876+ struct pvc_device *pvc;
876877 struct net_device *dev = NULL;
877878
878879 if (skb->len <= 4 || fh->ea1 || data[2] != FR_UI)
@@ -1028,7 +1029,7 @@ static void fr_stop(struct net_device *dev) · 149 unmodified lines
10281029 static void fr_close(struct net_device *dev)
10291030 {
10301031 hdlc_device *hdlc = dev_to_hdlc(dev);
1031− pvc_device *pvc = state(hdlc)->first_pvc;
1032+ struct pvc_device *pvc = state(hdlc)->first_pvc;
10321033
10331034 while (pvc) { /* Shutdown all PVCs for this FRAD */
10341035 if (pvc->main)
@@ -1060,7 +1061,7 @@ static const struct net_device_ops pvc_ops = { · 25 unmodified lines
10601061 static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
10611062 {
10621063 hdlc_device *hdlc = dev_to_hdlc(frad);
1063− pvc_device *pvc;
1064+ struct pvc_device *pvc;
10641065 struct net_device *dev;
10651066 int used;
10661067
@@ -1117,7 +1118,7 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) · 50 unmodified lines
11171118
11181119 static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type)
11191120 {
1120− pvc_device *pvc;
1121+ struct pvc_device *pvc;
11211122 struct net_device *dev;
11221123
11231124 if ((pvc = find_pvc(hdlc, dlci)) == NULL)
@@ -1145,13 +1146,13 @@ static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type) · 21 unmodified lines
11451146 static void fr_destroy(struct net_device *frad)
11461147 {
11471148 hdlc_device *hdlc = dev_to_hdlc(frad);
1148− pvc_device *pvc = state(hdlc)->first_pvc;
1149+ struct pvc_device *pvc = state(hdlc)->first_pvc;
11491150 state(hdlc)->first_pvc = NULL; /* All PVCs destroyed */
11501151 state(hdlc)->dce_pvc_count = 0;
11511152 state(hdlc)->dce_changed = 1;
11521153
11531154 while (pvc) {
1154− pvc_device *next = pvc->next;
1155+ struct pvc_device *next = pvc->next;
11551156 /* destructors will free_netdev() main and ether */
11561157 if (pvc->main)
11571158 unregister_netdevice(pvc->main);
drivers/net/wan/wanxl.c+32−31
@@ -54,24 +54,24 @@ static const char* version = "wanXL serial card driver version: 0.48"; · 53 unmodified lines
5454 #define MBX2_MEMSZ_MASK 0xFFFF0000 /* PUTS Memory Size Register mask */
5555
5656
57−typedef struct {
57+struct port {
5858 struct net_device *dev;
59− struct card_t *card;
59+ struct card *card;
6060 spinlock_t lock; /* for wanxl_xmit */
6161 int node; /* physical port #0 - 3 */
6262 unsigned int clock_type;
6363 int tx_in, tx_out;
6464 struct sk_buff *tx_skbs[TX_BUFFERS];
65−}port_t;
65+};
6666
6767
68−typedef struct {
68+struct card_status {
6969 desc_t rx_descs[RX_QUEUE_LENGTH];
7070 port_status_t port_status[4];
71−}card_status_t;
71+};
7272
7373
74−typedef struct card_t {
74+struct card {
7575 int n_ports; /* 1, 2 or 4 ports */
7676 u8 irq;
7777
@@ -79,20 +79,20 @@ typedef struct card_t { · 1 unmodified line
7979 struct pci_dev *pdev; /* for pci_name(pdev) */
8080 int rx_in;
8181 struct sk_buff *rx_skbs[RX_QUEUE_LENGTH];
82− card_status_t *status; /* shared between host and card */
82+ struct card_status *status; /* shared between host and card */
8383 dma_addr_t status_address;
84− port_t ports[0]; /* 1 - 4 port_t structures follow */
85−}card_t;
84+ struct port ports[0]; /* 1 - 4 port structures follow */
85+};
8686
8787
8888
89−static inline port_t* dev_to_port(struct net_device *dev)
89+static inline struct port *dev_to_port(struct net_device *dev)
9090 {
91− return (port_t *)dev_to_hdlc(dev)->priv;
91+ return (struct port *)dev_to_hdlc(dev)->priv;
9292 }
9393
9494
95−static inline port_status_t* get_status(port_t *port)
95+static inline port_status_t *get_status(struct port *port)
9696 {
9797 return &port->card->status->port_status[port->node];
9898 }
@@ -115,7 +115,7 @@ static inline dma_addr_t pci_map_single_debug(struct pci_dev *pdev, void *ptr, · 16 unmodified lines
115115
116116
117117 /* Cable and/or personality module change interrupt service */
118−static inline void wanxl_cable_intr(port_t *port)
118+static inline void wanxl_cable_intr(struct port *port)
119119 {
120120 u32 value = get_status(port)->cable;
121121 int valid = 1;
@@ -160,7 +160,7 @@ static inline void wanxl_cable_intr(port_t *port) · 38 unmodified lines
160160
161161
162162 /* Transmit complete interrupt service */
163−static inline void wanxl_tx_intr(port_t *port)
163+static inline void wanxl_tx_intr(struct port *port)
164164 {
165165 struct net_device *dev = port->dev;
166166 while (1) {
@@ -193,7 +193,7 @@ static inline void wanxl_tx_intr(port_t *port) · 26 unmodified lines
193193
194194
195195 /* Receive complete interrupt service */
196−static inline void wanxl_rx_intr(card_t *card)
196+static inline void wanxl_rx_intr(struct card *card)
197197 {
198198 desc_t *desc;
199199 while (desc = &card->status->rx_descs[card->rx_in],
@@ -203,7 +203,7 @@ static inline void wanxl_rx_intr(card_t *card) · 3 unmodified lines
203203 pci_name(card->pdev));
204204 else {
205205 struct sk_buff *skb = card->rx_skbs[card->rx_in];
206− port_t *port = &card->ports[desc->stat &
206+ struct port *port = &card->ports[desc->stat &
207207 PACKET_PORT_MASK];
208208 struct net_device *dev = port->dev;
209209
@@ -245,7 +245,7 @@ static inline void wanxl_rx_intr(card_t *card) · 35 unmodified lines
245245
246246 static irqreturn_t wanxl_intr(int irq, void* dev_id)
247247 {
248− card_t *card = dev_id;
248+ struct card *card = dev_id;
249249 int i;
250250 u32 stat;
251251 int handled = 0;
@@ -272,7 +272,7 @@ static irqreturn_t wanxl_intr(int irq, void* dev_id) · 20 unmodified lines
272272
273273 static netdev_tx_t wanxl_xmit(struct sk_buff *skb, struct net_device *dev)
274274 {
275− port_t *port = dev_to_port(dev);
275+ struct port *port = dev_to_port(dev);
276276 desc_t *desc;
277277
278278 spin_lock(&port->lock);
@@ -319,7 +319,7 @@ static netdev_tx_t wanxl_xmit(struct sk_buff *skb, struct net_device *dev) · 40 unmodified lines
319319 static int wanxl_attach(struct net_device *dev, unsigned short encoding,
320320 unsigned short parity)
321321 {
322− port_t *port = dev_to_port(dev);
322+ struct port *port = dev_to_port(dev);
323323
324324 if (encoding != ENCODING_NRZ &&
325325 encoding != ENCODING_NRZI)
@@ -343,7 +343,7 @@ static int wanxl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) · 17 unmodified lines
343343 {
344344 const size_t size = sizeof(sync_serial_settings);
345345 sync_serial_settings line;
346− port_t *port = dev_to_port(dev);
346+ struct port *port = dev_to_port(dev);
347347
348348 if (cmd != SIOCWANDEV)
349349 return hdlc_ioctl(dev, ifr, cmd);
@@ -393,7 +393,7 @@ static int wanxl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) · 43 unmodified lines
393393
394394 static int wanxl_open(struct net_device *dev)
395395 {
396− port_t *port = dev_to_port(dev);
396+ struct port *port = dev_to_port(dev);
397397 u8 __iomem *dbr = port->card->plx + PLX_DOORBELL_TO_CARD;
398398 unsigned long timeout;
399399 int i;
@@ -429,7 +429,7 @@ static int wanxl_open(struct net_device *dev) · 29 unmodified lines
429429
430430 static int wanxl_close(struct net_device *dev)
431431 {
432− port_t *port = dev_to_port(dev);
432+ struct port *port = dev_to_port(dev);
433433 unsigned long timeout;
434434 int i;
435435
@@ -467,7 +467,7 @@ static int wanxl_close(struct net_device *dev) · 31 unmodified lines
467467
468468 static struct net_device_stats *wanxl_get_stats(struct net_device *dev)
469469 {
470− port_t *port = dev_to_port(dev);
470+ struct port *port = dev_to_port(dev);
471471
472472 dev->stats.rx_over_errors = get_status(port)->rx_overruns;
473473 dev->stats.rx_frame_errors = get_status(port)->rx_frame_errors;
@@ -478,7 +478,7 @@ static struct net_device_stats *wanxl_get_stats(struct net_device *dev) · 4 unmodified lines
478478
479479
480480
481−static int wanxl_puts_command(card_t *card, u32 cmd)
481+static int wanxl_puts_command(struct card *card, u32 cmd)
482482 {
483483 unsigned long timeout = jiffies + 5 * HZ;
484484
@@ -495,7 +495,7 @@ static int wanxl_puts_command(card_t *card, u32 cmd) · 10 unmodified lines
495495
496496
497497
498−static void wanxl_reset(card_t *card)
498+static void wanxl_reset(struct card *card)
499499 {
500500 u32 old_value = readl(card->plx + PLX_CONTROL) & ~PLX_CTL_RESET;
501501
@@ -511,7 +511,7 @@ static void wanxl_reset(card_t *card) · 9 unmodified lines
511511
512512 static void wanxl_pci_remove_one(struct pci_dev *pdev)
513513 {
514− card_t *card = pci_get_drvdata(pdev);
514+ struct card *card = pci_get_drvdata(pdev);
515515 int i;
516516
517517 for (i = 0; i < card->n_ports; i++) {
@@ -537,7 +537,7 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev) · 19 unmodified lines
537537 iounmap(card->plx);
538538
539539 if (card->status)
540− pci_free_consistent(pdev, sizeof(card_status_t),
540+ pci_free_consistent(pdev, sizeof(struct card_status),
541541 card->status, card->status_address);
542542
543543 pci_release_regions(pdev);
@@ -560,7 +560,7 @@ static const struct net_device_ops wanxl_ops = { · 16 unmodified lines
560560 static int wanxl_pci_init_one(struct pci_dev *pdev,
561561 const struct pci_device_id *ent)
562562 {
563− card_t *card;
563+ struct card *card;
564564 u32 ramsize, stat;
565565 unsigned long timeout;
566566 u32 plx_phy; /* PLX PCI base address */
@@ -601,7 +601,7 @@ static int wanxl_pci_init_one(struct pci_dev *pdev, · 34 unmodified lines
601601 default: ports = 4;
602602 }
603603
604− alloc_size = sizeof(card_t) + ports * sizeof(port_t);
604+ alloc_size = sizeof(struct card) + ports * sizeof(struct port);
605605 card = kzalloc(alloc_size, GFP_KERNEL);
606606 if (card == NULL) {
607607 pci_release_regions(pdev);
@@ -612,7 +612,8 @@ static int wanxl_pci_init_one(struct pci_dev *pdev, · 4 unmodified lines
612612 pci_set_drvdata(pdev, card);
613613 card->pdev = pdev;
614614
615− card->status = pci_alloc_consistent(pdev, sizeof(card_status_t),
615+ card->status = pci_alloc_consistent(pdev,
616+ sizeof(struct card_status),
616617 &card->status_address);
617618 if (card->status == NULL) {
618619 wanxl_pci_remove_one(pdev);
@@ -766,7 +767,7 @@ static int wanxl_pci_init_one(struct pci_dev *pdev, · 147 unmodified lines
766767
767768 for (i = 0; i < ports; i++) {
768769 hdlc_device *hdlc;
769− port_t *port = &card->ports[i];
770+ struct port *port = &card->ports[i];
770771 struct net_device *dev = alloc_hdlcdev(port);
771772 if (!dev) {
772773 pr_err("%s: unable to allocate memory\n",
drivers/net/wireless/airo_cs.c+13−12
@@ -56,18 +56,18 @@ static void airo_release(struct pcmcia_device *link); · 55 unmodified lines
5656
5757 static void airo_detach(struct pcmcia_device *p_dev);
5858
59−typedef struct local_info_t {
59+struct local_info {
6060 struct net_device *eth_dev;
61−} local_info_t;
61+};
6262
6363 static int airo_probe(struct pcmcia_device *p_dev)
6464 {
65− local_info_t *local;
65+ struct local_info *local;
6666
6767 dev_dbg(&p_dev->dev, "airo_attach()\n");
6868
6969 /* Allocate space for private device-specific data */
70− local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
70+ local = kzalloc(sizeof(*local), GFP_KERNEL);
7171 if (!local)
7272 return -ENOMEM;
7373
@@ -82,10 +82,11 @@ static void airo_detach(struct pcmcia_device *link) · 8 unmodified lines
8282
8383 airo_release(link);
8484
85− if (((local_info_t *)link->priv)->eth_dev) {
86− stop_airo_card(((local_info_t *)link->priv)->eth_dev, 0);
85+ if (((struct local_info *)link->priv)->eth_dev) {
86+ stop_airo_card(((struct local_info *)link->priv)->eth_dev,
87+ 0);
8788 }
88− ((local_info_t *)link->priv)->eth_dev = NULL;
89+ ((struct local_info *)link->priv)->eth_dev = NULL;
8990
9091 kfree(link->priv);
9192 } /* airo_detach */
@@ -101,7 +102,7 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev, void *priv_data) · 9 unmodified lines
101102
102103 static int airo_config(struct pcmcia_device *link)
103104 {
104− local_info_t *dev;
105+ struct local_info *dev;
105106 int ret;
106107
107108 dev = link->priv;
@@ -121,10 +122,10 @@ static int airo_config(struct pcmcia_device *link) · 13 unmodified lines
121122 ret = pcmcia_enable_device(link);
122123 if (ret)
123124 goto failed;
124− ((local_info_t *)link->priv)->eth_dev =
125+ ((struct local_info *)link->priv)->eth_dev =
125126 init_airo_card(link->irq,
126127 link->resource[0]->start, 1, &link->dev);
127− if (!((local_info_t *)link->priv)->eth_dev)
128+ if (!((struct local_info *)link->priv)->eth_dev)
128129 goto failed;
129130
130131 return 0;
@@ -142,7 +143,7 @@ static void airo_release(struct pcmcia_device *link) · 11 unmodified lines
142143
143144 static int airo_suspend(struct pcmcia_device *link)
144145 {
145− local_info_t *local = link->priv;
146+ struct local_info *local = link->priv;
146147
147148 netif_device_detach(local->eth_dev);
148149
@@ -151,7 +152,7 @@ static int airo_suspend(struct pcmcia_device *link) · 2 unmodified lines
151152
152153 static int airo_resume(struct pcmcia_device *link)
153154 {
154− local_info_t *local = link->priv;
155+ struct local_info *local = link->priv;
155156
156157 if (link->open) {
157158 reset_airo_card(local->eth_dev);
drivers/net/wireless/atmel.c+4−4
@@ -2598,11 +2598,11 @@ static const iw_handler atmel_private_handler[] = · 2597 unmodified lines
25982598 NULL, /* SIOCIWFIRSTPRIV */
25992599 };
26002600
2601−typedef struct atmel_priv_ioctl {
2601+struct atmel_priv_ioctl {
26022602 char id[32];
26032603 unsigned char __user *data;
26042604 unsigned short len;
2605−} atmel_priv_ioctl;
2605+};
26062606
26072607 #define ATMELFWL SIOCIWFIRSTPRIV
26082608 #define ATMELIDIFC ATMELFWL + 1
@@ -2615,7 +2615,7 @@ static const struct iw_priv_args atmel_private_args[] = { · 6 unmodified lines
26152615 .cmd = ATMELFWL,
26162616 .set_args = IW_PRIV_TYPE_BYTE
26172617 | IW_PRIV_SIZE_FIXED
2618− | sizeof (atmel_priv_ioctl),
2618+ | sizeof(struct atmel_priv_ioctl),
26192619 .get_args = IW_PRIV_TYPE_NONE,
26202620 .name = "atmelfwl"
26212621 }, {
@@ -2645,7 +2645,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) · 23 unmodified lines
26452645 {
26462646 int i, rc = 0;
26472647 struct atmel_private *priv = netdev_priv(dev);
2648− atmel_priv_ioctl com;
2648+ struct atmel_priv_ioctl com;
26492649 struct iwreq *wrq = (struct iwreq *) rq;
26502650 unsigned char *new_firmware;
26512651 char domain[REGDOMAINSZ + 1];
drivers/net/xen-netback/interface.c+1−5
@@ -78,12 +78,8 @@ int xenvif_poll(struct napi_struct *napi, int budget) · 77 unmodified lines
7878 /* This vif is rogue, we pretend we've there is nothing to do
7979 * for this vif to deschedule it from NAPI. But this interface
8080 * will be turned off in thread context later.
81− * Also, if a guest doesn't post enough slots to receive data on one of
82− * its queues, the carrier goes down and NAPI is descheduled here so
83− * the guest can't send more packets until it's ready to receive.
8481 */
85− if (unlikely(queue->vif->disabled ||
86− !netif_carrier_ok(queue->vif->dev))) {
82+ if (unlikely(queue->vif->disabled)) {
8783 napi_complete(napi);
8884 return 0;
8985 }
drivers/net/xen-netback/netback.c+8−2
@@ -2025,9 +2025,15 @@ int xenvif_kthread_guest_rx(void *data) · 2024 unmodified lines
20252025 * context so we defer it here, if this thread is
20262026 * associated with queue 0.
20272027 */
2028− if (unlikely(queue->vif->disabled && queue->id == 0))
2028+ if (unlikely(queue->vif->disabled && queue->id == 0)) {
20292029 xenvif_carrier_off(queue->vif);
2030− else if (unlikely(test_and_clear_bit(QUEUE_STATUS_RX_PURGE_EVENT,
2030+ } else if (unlikely(queue->vif->disabled)) {
2031+ /* kthread_stop() would be called upon this thread soon,
2032+ * be a bit proactive
2033+ */
2034+ skb_queue_purge(&queue->rx_queue);
2035+ queue->rx_last_skb_slots = 0;
2036+ } else if (unlikely(test_and_clear_bit(QUEUE_STATUS_RX_PURGE_EVENT,
20312037 &queue->status))) {
20322038 xenvif_rx_purge_event(queue);
20332039 } else if (!netif_carrier_ok(queue->vif->dev)) {
drivers/net/xen-netfront.c+4−3
@@ -628,9 +628,10 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) · 627 unmodified lines
628628 slots = DIV_ROUND_UP(offset + len, PAGE_SIZE) +
629629 xennet_count_skb_frag_slots(skb);
630630 if (unlikely(slots > MAX_SKB_FRAGS + 1)) {
631− net_alert_ratelimited(
632− "xennet: skb rides the rocket: %d slots\n", slots);
633− goto drop;
631+ net_dbg_ratelimited("xennet: skb rides the rocket: %d slots, %d bytes\n",
632+ slots, skb->len);
633+ if (skb_linearize(skb))
634+ goto drop;
634635 }
635636
636637 spin_lock_irqsave(&queue->tx_lock, flags);
include/linux/if_vlan.h+0−6
@@ -187,7 +187,6 @@ vlan_dev_get_egress_qos_mask(struct net_device *dev, u32 skprio) · 186 unmodified lines
187187 }
188188
189189 extern bool vlan_do_receive(struct sk_buff **skb);
190−extern struct sk_buff *vlan_untag(struct sk_buff *skb);
191190
192191 extern int vlan_vid_add(struct net_device *dev, __be16 proto, u16 vid);
193192 extern void vlan_vid_del(struct net_device *dev, __be16 proto, u16 vid);
@@ -241,11 +240,6 @@ static inline bool vlan_do_receive(struct sk_buff **skb) · 47 unmodified lines
241240 return false;
242241 }
243242
244−static inline struct sk_buff *vlan_untag(struct sk_buff *skb)
245−{
246− return skb;
247−}
248−
249243 static inline int vlan_vid_add(struct net_device *dev, __be16 proto, u16 vid)
250244 {
251245 return 0;
include/linux/skbuff.h+1−0
@@ -2555,6 +2555,7 @@ int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen); · 2554 unmodified lines
25552555 void skb_scrub_packet(struct sk_buff *skb, bool xnet);
25562556 unsigned int skb_gso_transport_seglen(const struct sk_buff *skb);
25572557 struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features);
2558+struct sk_buff *skb_vlan_untag(struct sk_buff *skb);
25582559
25592560 struct skb_checksum_ops {
25602561 __wsum (*update)(const void *mem, int len, __wsum wsum);
net/6lowpan/Kconfig+1−1
@@ -1,5 +1,5 @@
11 config 6LOWPAN
2− bool "6LoWPAN Support"
2+ tristate "6LoWPAN Support"
33 depends on IPV6
44 ---help---
55 This enables IPv6 over Low power Wireless Personal Area Network -
net/8021q/vlan_core.c+0−53
@@ -112,59 +112,6 @@ __be16 vlan_dev_vlan_proto(const struct net_device *dev) · 111 unmodified lines
112112 }
113113 EXPORT_SYMBOL(vlan_dev_vlan_proto);
114114
115−static struct sk_buff *vlan_reorder_header(struct sk_buff *skb)
116−{
117− if (skb_cow(skb, skb_headroom(skb)) < 0) {
118− kfree_skb(skb);
119− return NULL;
120− }
121−
122− memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN);
123− skb->mac_header += VLAN_HLEN;
124− return skb;
125−}
126−
127−struct sk_buff *vlan_untag(struct sk_buff *skb)
128−{
129− struct vlan_hdr *vhdr;
130− u16 vlan_tci;
131−
132− if (unlikely(vlan_tx_tag_present(skb))) {
133− /* vlan_tci is already set-up so leave this for another time */
134− return skb;
135− }
136−
137− skb = skb_share_check(skb, GFP_ATOMIC);
138− if (unlikely(!skb))
139− goto err_free;
140−
141− if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
142− goto err_free;
143−
144− vhdr = (struct vlan_hdr *) skb->data;
145− vlan_tci = ntohs(vhdr->h_vlan_TCI);
146− __vlan_hwaccel_put_tag(skb, skb->protocol, vlan_tci);
147−
148− skb_pull_rcsum(skb, VLAN_HLEN);
149− vlan_set_encap_proto(skb, vhdr);
150−
151− skb = vlan_reorder_header(skb);
152− if (unlikely(!skb))
153− goto err_free;
154−
155− skb_reset_network_header(skb);
156− skb_reset_transport_header(skb);
157− skb_reset_mac_len(skb);
158−
159− return skb;
160−
161−err_free:
162− kfree_skb(skb);
163− return NULL;
164−}
165−EXPORT_SYMBOL(vlan_untag);
166−
167−
168115 /*
169116 * vlan info and vid list
170117 */
net/batman-adv/multicast.c+0−1
@@ -20,7 +20,6 @@ · 19 unmodified lines
2020 #include "originator.h"
2121 #include "hard-interface.h"
2222 #include "translation-table.h"
23−#include "multicast.h"
2423
2524 /**
2625 * batadv_mcast_mla_softif_get - get softif multicast listeners
net/bridge/br_vlan.c+1−1
@@ -181,7 +181,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v, · 180 unmodified lines
181181 */
182182 if (unlikely(!vlan_tx_tag_present(skb) &&
183183 skb->protocol == proto)) {
184− skb = vlan_untag(skb);
184+ skb = skb_vlan_untag(skb);
185185 if (unlikely(!skb))
186186 return false;
187187 }
net/bridge/netfilter/ebtables.c+2−8
@@ -327,10 +327,7 @@ find_inlist_lock_noload(struct list_head *head, const char *name, int *error, · 326 unmodified lines
327327 char name[EBT_FUNCTION_MAXNAMELEN];
328328 } *e;
329329
330− *error = mutex_lock_interruptible(mutex);
331− if (*error != 0)
332− return NULL;
333−
330+ mutex_lock(mutex);
334331 list_for_each_entry(e, head, list) {
335332 if (strcmp(e->name, name) == 0)
336333 return e;
@@ -1203,10 +1200,7 @@ ebt_register_table(struct net *net, const struct ebt_table *input_table) · 866 unmodified lines
12031200
12041201 table->private = newinfo;
12051202 rwlock_init(&table->lock);
1206− ret = mutex_lock_interruptible(&ebt_mutex);
1207− if (ret != 0)
1208− goto free_chainstack;
1209−
1203+ mutex_lock(&ebt_mutex);
12101204 list_for_each_entry(t, &net->xt.tables[NFPROTO_BRIDGE], list) {
12111205 if (strcmp(t->name, table->name) == 0) {
12121206 ret = -EEXIST;
net/core/dev.c+1−1
@@ -3602,7 +3602,7 @@ another_round: · 3601 unmodified lines
36023602
36033603 if (skb->protocol == cpu_to_be16(ETH_P_8021Q) ||
36043604 skb->protocol == cpu_to_be16(ETH_P_8021AD)) {
3605− skb = vlan_untag(skb);
3605+ skb = skb_vlan_untag(skb);
36063606 if (unlikely(!skb))
36073607 goto unlock;
36083608 }
net/core/rtnetlink.c+2−1
@@ -804,7 +804,8 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev, · 803 unmodified lines
804804 (nla_total_size(sizeof(struct ifla_vf_mac)) +
805805 nla_total_size(sizeof(struct ifla_vf_vlan)) +
806806 nla_total_size(sizeof(struct ifla_vf_spoofchk)) +
807− nla_total_size(sizeof(struct ifla_vf_rate)));
807+ nla_total_size(sizeof(struct ifla_vf_rate)) +
808+ nla_total_size(sizeof(struct ifla_vf_link_state)));
808809 return size;
809810 } else
810811 return 0;
net/core/skbuff.c+53−0
@@ -62,6 +62,7 @@ · 61 unmodified lines
6262 #include <linux/scatterlist.h>
6363 #include <linux/errqueue.h>
6464 #include <linux/prefetch.h>
65+#include <linux/if_vlan.h>
6566
6667 #include <net/protocol.h>
6768 #include <net/dst.h>
@@ -3973,3 +3974,55 @@ unsigned int skb_gso_transport_seglen(const struct sk_buff *skb) · 3905 unmodified lines
39733974 return shinfo->gso_size;
39743975 }
39753976 EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);
3977+
3978+static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb)
3979+{
3980+ if (skb_cow(skb, skb_headroom(skb)) < 0) {
3981+ kfree_skb(skb);
3982+ return NULL;
3983+ }
3984+
3985+ memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN);
3986+ skb->mac_header += VLAN_HLEN;
3987+ return skb;
3988+}
3989+
3990+struct sk_buff *skb_vlan_untag(struct sk_buff *skb)
3991+{
3992+ struct vlan_hdr *vhdr;
3993+ u16 vlan_tci;
3994+
3995+ if (unlikely(vlan_tx_tag_present(skb))) {
3996+ /* vlan_tci is already set-up so leave this for another time */
3997+ return skb;
3998+ }
3999+
4000+ skb = skb_share_check(skb, GFP_ATOMIC);
4001+ if (unlikely(!skb))
4002+ goto err_free;
4003+
4004+ if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
4005+ goto err_free;
4006+
4007+ vhdr = (struct vlan_hdr *)skb->data;
4008+ vlan_tci = ntohs(vhdr->h_vlan_TCI);
4009+ __vlan_hwaccel_put_tag(skb, skb->protocol, vlan_tci);
4010+
4011+ skb_pull_rcsum(skb, VLAN_HLEN);
4012+ vlan_set_encap_proto(skb, vhdr);
4013+
4014+ skb = skb_reorder_vlan_header(skb);
4015+ if (unlikely(!skb))
4016+ goto err_free;
4017+
4018+ skb_reset_network_header(skb);
4019+ skb_reset_transport_header(skb);
4020+ skb_reset_mac_len(skb);
4021+
4022+ return skb;
4023+
4024+err_free:
4025+ kfree_skb(skb);
4026+ return NULL;
4027+}
4028+EXPORT_SYMBOL(skb_vlan_untag);
net/ipv4/route.c+0−2
@@ -1798,8 +1798,6 @@ local_input: · 1797 unmodified lines
17981798 no_route:
17991799 RT_CACHE_STAT_INC(in_no_route);
18001800 res.type = RTN_UNREACHABLE;
1801− if (err == -ESRCH)
1802− err = -ENETUNREACH;
18031801 goto local_input;
18041802
18051803 /*
net/netfilter/core.c+2−9
@@ -35,11 +35,7 @@ EXPORT_SYMBOL_GPL(nf_ipv6_ops); · 34 unmodified lines
3535
3636 int nf_register_afinfo(const struct nf_afinfo *afinfo)
3737 {
38− int err;
39−
40− err = mutex_lock_interruptible(&afinfo_mutex);
41− if (err < 0)
42− return err;
38+ mutex_lock(&afinfo_mutex);
4339 RCU_INIT_POINTER(nf_afinfo[afinfo->family], afinfo);
4440 mutex_unlock(&afinfo_mutex);
4541 return 0;
@@ -68,11 +64,8 @@ static DEFINE_MUTEX(nf_hook_mutex); · 22 unmodified lines
6864 int nf_register_hook(struct nf_hook_ops *reg)
6965 {
7066 struct nf_hook_ops *elem;
71− int err;
7267
73− err = mutex_lock_interruptible(&nf_hook_mutex);
74− if (err < 0)
75− return err;
68+ mutex_lock(&nf_hook_mutex);
7669 list_for_each_entry(elem, &nf_hooks[reg->pf][reg->hooknum], list) {
7770 if (reg->priority < elem->priority)
7871 break;
net/netfilter/ipvs/ip_vs_ctl.c+4−15
@@ -2271,10 +2271,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) · 2270 unmodified lines
22712271 cmd == IP_VS_SO_SET_STOPDAEMON) {
22722272 struct ip_vs_daemon_user *dm = (struct ip_vs_daemon_user *)arg;
22732273
2274− if (mutex_lock_interruptible(&ipvs->sync_mutex)) {
2275− ret = -ERESTARTSYS;
2276− goto out_dec;
2277− }
2274+ mutex_lock(&ipvs->sync_mutex);
22782275 if (cmd == IP_VS_SO_SET_STARTDAEMON)
22792276 ret = start_sync_thread(net, dm->state, dm->mcast_ifn,
22802277 dm->syncid);
@@ -2284,11 +2281,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) · 3 unmodified lines
22842281 goto out_dec;
22852282 }
22862283
2287− if (mutex_lock_interruptible(&__ip_vs_mutex)) {
2288− ret = -ERESTARTSYS;
2289− goto out_dec;
2290− }
2291−
2284+ mutex_lock(&__ip_vs_mutex);
22922285 if (cmd == IP_VS_SO_SET_FLUSH) {
22932286 /* Flush the virtual service */
22942287 ret = ip_vs_flush(net, false);
@@ -2573,9 +2566,7 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) · 278 unmodified lines
25732566 struct ip_vs_daemon_user d[2];
25742567
25752568 memset(&d, 0, sizeof(d));
2576− if (mutex_lock_interruptible(&ipvs->sync_mutex))
2577− return -ERESTARTSYS;
2578−
2569+ mutex_lock(&ipvs->sync_mutex);
25792570 if (ipvs->sync_state & IP_VS_STATE_MASTER) {
25802571 d[0].state = IP_VS_STATE_MASTER;
25812572 strlcpy(d[0].mcast_ifn, ipvs->master_mcast_ifn,
@@ -2594,9 +2585,7 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) · 12 unmodified lines
25942585 return ret;
25952586 }
25962587
2597− if (mutex_lock_interruptible(&__ip_vs_mutex))
2598− return -ERESTARTSYS;
2599−
2588+ mutex_lock(&__ip_vs_mutex);
26002589 switch (cmd) {
26012590 case IP_VS_SO_GET_VERSION:
26022591 {
net/netfilter/nf_sockopt.c+2−6
@@ -26,9 +26,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg) · 25 unmodified lines
2626 struct nf_sockopt_ops *ops;
2727 int ret = 0;
2828
29− if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0)
30− return -EINTR;
31−
29+ mutex_lock(&nf_sockopt_mutex);
3230 list_for_each_entry(ops, &nf_sockopts, list) {
3331 if (ops->pf == reg->pf
3432 && (overlap(ops->set_optmin, ops->set_optmax,
@@ -65,9 +63,7 @@ static struct nf_sockopt_ops *nf_sockopt_find(struct sock *sk, u_int8_t pf, · 30 unmodified lines
6563 {
6664 struct nf_sockopt_ops *ops;
6765
68− if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0)
69− return ERR_PTR(-EINTR);
70−
66+ mutex_lock(&nf_sockopt_mutex);
7167 list_for_each_entry(ops, &nf_sockopts, list) {
7268 if (ops->pf == pf) {
7369 if (!try_module_get(ops->owner))
net/netfilter/nf_tables_api.c+17−13
@@ -899,6 +899,9 @@ static struct nft_stats __percpu *nft_stats_alloc(const struct nlattr *attr) · 898 unmodified lines
899899 static void nft_chain_stats_replace(struct nft_base_chain *chain,
900900 struct nft_stats __percpu *newstats)
901901 {
902+ if (newstats == NULL)
903+ return;
904+
902905 if (chain->stats) {
903906 struct nft_stats __percpu *oldstats =
904907 nft_dereference(chain->stats);
@@ -3134,16 +3137,13 @@ static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set, · 2229 unmodified lines
31343137 goto err2;
31353138
31363139 trans = nft_trans_elem_alloc(ctx, NFT_MSG_DELSETELEM, set);
3137− if (trans == NULL)
3140+ if (trans == NULL) {
3141+ err = -ENOMEM;
31383142 goto err2;
3143+ }
31393144
31403145 nft_trans_elem(trans) = elem;
31413146 list_add_tail(&trans->list, &ctx->net->nft.commit_list);
3142−
3143− nft_data_uninit(&elem.key, NFT_DATA_VALUE);
3144− if (set->flags & NFT_SET_MAP)
3145− nft_data_uninit(&elem.data, set->dtype);
3146−
31473147 return 0;
31483148 err2:
31493149 nft_data_uninit(&elem.key, desc.type);
@@ -3310,7 +3310,7 @@ static int nf_tables_commit(struct sk_buff *skb) · 160 unmodified lines
33103310 {
33113311 struct net *net = sock_net(skb->sk);
33123312 struct nft_trans *trans, *next;
3313− struct nft_set *set;
3313+ struct nft_trans_elem *te;
33143314
33153315 /* Bump generation counter, invalidate any dump in progress */
33163316 while (++net->nft.base_seq == 0);
@@ -3396,13 +3396,17 @@ static int nf_tables_commit(struct sk_buff *skb) · 79 unmodified lines
33963396 nft_trans_destroy(trans);
33973397 break;
33983398 case NFT_MSG_DELSETELEM:
3399− nf_tables_setelem_notify(&trans->ctx,
3400− nft_trans_elem_set(trans),
3401− &nft_trans_elem(trans),
3399+ te = (struct nft_trans_elem *)trans->data;
3400+ nf_tables_setelem_notify(&trans->ctx, te->set,
3401+ &te->elem,
34023402 NFT_MSG_DELSETELEM, 0);
3403− set = nft_trans_elem_set(trans);
3404− set->ops->get(set, &nft_trans_elem(trans));
3405− set->ops->remove(set, &nft_trans_elem(trans));
3403+ te->set->ops->get(te->set, &te->elem);
3404+ te->set->ops->remove(te->set, &te->elem);
3405+ nft_data_uninit(&te->elem.key, NFT_DATA_VALUE);
3406+ if (te->elem.flags & NFT_SET_MAP) {
3407+ nft_data_uninit(&te->elem.data,
3408+ te->set->dtype);
3409+ }
34063410 nft_trans_destroy(trans);
34073411 break;
34083412 }
net/netfilter/x_tables.c+12−35
@@ -71,18 +71,14 @@ static const char *const xt_prefix[NFPROTO_NUMPROTO] = { · 70 unmodified lines
7171 static const unsigned int xt_jumpstack_multiplier = 2;
7272
7373 /* Registration hooks for targets. */
74−int
75−xt_register_target(struct xt_target *target)
74+int xt_register_target(struct xt_target *target)
7675 {
7776 u_int8_t af = target->family;
78− int ret;
7977
80− ret = mutex_lock_interruptible(&xt[af].mutex);
81− if (ret != 0)
82− return ret;
78+ mutex_lock(&xt[af].mutex);
8379 list_add(&target->list, &xt[af].target);
8480 mutex_unlock(&xt[af].mutex);
85− return ret;
81+ return 0;
8682 }
8783 EXPORT_SYMBOL(xt_register_target);
8884
@@ -125,20 +121,14 @@ xt_unregister_targets(struct xt_target *target, unsigned int n) · 36 unmodified lines
125121 }
126122 EXPORT_SYMBOL(xt_unregister_targets);
127123
128−int
129−xt_register_match(struct xt_match *match)
124+int xt_register_match(struct xt_match *match)
130125 {
131126 u_int8_t af = match->family;
132− int ret;
133−
134− ret = mutex_lock_interruptible(&xt[af].mutex);
135− if (ret != 0)
136− return ret;
137127
128+ mutex_lock(&xt[af].mutex);
138129 list_add(&match->list, &xt[af].match);
139130 mutex_unlock(&xt[af].mutex);
140−
141− return ret;
131+ return 0;
142132 }
143133 EXPORT_SYMBOL(xt_register_match);
144134
@@ -194,9 +184,7 @@ struct xt_match *xt_find_match(u8 af, const char *name, u8 revision) · 49 unmodified lines
194184 struct xt_match *m;
195185 int err = -ENOENT;
196186
197− if (mutex_lock_interruptible(&xt[af].mutex) != 0)
198− return ERR_PTR(-EINTR);
199−
187+ mutex_lock(&xt[af].mutex);
200188 list_for_each_entry(m, &xt[af].match, list) {
201189 if (strcmp(m->name, name) == 0) {
202190 if (m->revision == revision) {
@@ -239,9 +227,7 @@ struct xt_target *xt_find_target(u8 af, const char *name, u8 revision) · 36 unmodified lines
239227 struct xt_target *t;
240228 int err = -ENOENT;
241229
242− if (mutex_lock_interruptible(&xt[af].mutex) != 0)
243− return ERR_PTR(-EINTR);
244−
230+ mutex_lock(&xt[af].mutex);
245231 list_for_each_entry(t, &xt[af].target, list) {
246232 if (strcmp(t->name, name) == 0) {
247233 if (t->revision == revision) {
@@ -323,10 +309,7 @@ int xt_find_revision(u8 af, const char *name, u8 revision, int target, · 75 unmodified lines
323309 {
324310 int have_rev, best = -1;
325311
326− if (mutex_lock_interruptible(&xt[af].mutex) != 0) {
327− *err = -EINTR;
328− return 1;
329− }
312+ mutex_lock(&xt[af].mutex);
330313 if (target == 1)
331314 have_rev = target_revfn(af, name, revision, &best);
332315 else
@@ -732,9 +715,7 @@ struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af, · 399 unmodified lines
732715 {
733716 struct xt_table *t;
734717
735− if (mutex_lock_interruptible(&xt[af].mutex) != 0)
736− return ERR_PTR(-EINTR);
737−
718+ mutex_lock(&xt[af].mutex);
738719 list_for_each_entry(t, &net->xt.tables[af], list)
739720 if (strcmp(t->name, name) == 0 && try_module_get(t->me))
740721 return t;
@@ -883,10 +864,7 @@ struct xt_table *xt_register_table(struct net *net, · 142 unmodified lines
883864 goto out;
884865 }
885866
886− ret = mutex_lock_interruptible(&xt[table->af].mutex);
887− if (ret != 0)
888− goto out_free;
889−
867+ mutex_lock(&xt[table->af].mutex);
890868 /* Don't autoload: we'd eat our tail... */
891869 list_for_each_entry(t, &net->xt.tables[table->af], list) {
892870 if (strcmp(t->name, table->name) == 0) {
@@ -911,9 +889,8 @@ struct xt_table *xt_register_table(struct net *net, · 18 unmodified lines
911889 mutex_unlock(&xt[table->af].mutex);
912890 return table;
913891
914− unlock:
892+unlock:
915893 mutex_unlock(&xt[table->af].mutex);
916−out_free:
917894 kfree(table);
918895 out:
919896 return ERR_PTR(ret);
net/netlink/af_netlink.c+1−1
@@ -213,7 +213,7 @@ static int __netlink_deliver_tap_skb(struct sk_buff *skb, · 212 unmodified lines
213213 nskb->protocol = htons((u16) sk->sk_protocol);
214214 nskb->pkt_type = netlink_is_kernel(sk) ?
215215 PACKET_KERNEL : PACKET_USER;
216−
216+ skb_reset_network_header(nskb);
217217 ret = dev_queue_xmit(nskb);
218218 if (unlikely(ret > 0))
219219 ret = net_xmit_errno(ret);
net/openvswitch/datapath.c+0−2
@@ -47,8 +47,6 @@ · 46 unmodified lines
4747 #include <linux/openvswitch.h>
4848 #include <linux/rculist.h>
4949 #include <linux/dmi.h>
50−#include <linux/genetlink.h>
51−#include <net/genetlink.h>
5250 #include <net/genetlink.h>
5351 #include <net/net_namespace.h>
5452 #include <net/netns/generic.h>