iPXE
sky2.c
Go to the documentation of this file.
1 /*
2  * iPXE driver for Marvell Yukon 2 chipset. Derived from Linux sky2 driver
3  * (v1.22), which was based on earlier sk98lin and skge drivers.
4  *
5  * This driver intentionally does not support all the features
6  * of the original driver such as link fail-over and link management because
7  * those should be done at higher levels.
8  *
9  * Copyright (C) 2005 Stephen Hemminger <shemminger@osdl.org>
10  *
11  * Modified for iPXE, April 2009 by Joshua Oreman
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25  * 02110-1301, USA.
26  */
27 
28 FILE_LICENCE ( GPL2_ONLY );
29 
30 #include <stdint.h>
31 #include <string.h>
32 #include <errno.h>
33 #include <stdio.h>
34 #include <unistd.h>
35 #include <ipxe/ethernet.h>
36 #include <ipxe/if_ether.h>
37 #include <ipxe/iobuf.h>
38 #include <ipxe/malloc.h>
39 #include <ipxe/pci.h>
40 #include <byteswap.h>
41 #include <mii.h>
42 
43 #include "sky2.h"
44 
45 #define DRV_NAME "sky2"
46 #define DRV_VERSION "1.22"
47 #define PFX DRV_NAME " "
48 
49 /*
50  * The Yukon II chipset takes 64 bit command blocks (called list elements)
51  * that are organized into three (receive, transmit, status) different rings
52  * similar to Tigon3.
53  *
54  * Each ring start must be aligned to a 4k boundary. You will get mysterious
55  * "invalid LE" errors if they're not.
56  *
57  * The card silently forces each ring size to be at least 128. If you
58  * act as though one of them is smaller (by setting the below
59  * #defines) you'll get bad bugs.
60  */
61 
62 #define RX_LE_SIZE 128
63 #define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le))
64 #define RX_RING_ALIGN 4096
65 #define RX_PENDING (RX_LE_SIZE/6 - 2)
66 
67 #define TX_RING_SIZE 128
68 #define TX_PENDING (TX_RING_SIZE - 1)
69 #define TX_RING_ALIGN 4096
70 #define MAX_SKB_TX_LE 4
71 
72 #define STATUS_RING_SIZE 512 /* 2 ports * (TX + RX) */
73 #define STATUS_LE_BYTES (STATUS_RING_SIZE*sizeof(struct sky2_status_le))
74 #define STATUS_RING_ALIGN 4096
75 #define PHY_RETRIES 1000
76 
77 #define SKY2_EEPROM_MAGIC 0x9955aabb
78 
79 
80 #define RING_NEXT(x,s) (((x)+1) & ((s)-1))
81 
82 static struct pci_device_id sky2_id_table[] = {
83  PCI_ROM(0x1148, 0x9000, "sk9sxx", "Syskonnect SK-9Sxx", 0),
84  PCI_ROM(0x1148, 0x9e00, "sk9exx", "Syskonnect SK-9Exx", 0),
85  PCI_ROM(0x1186, 0x4001, "dge550sx", "D-Link DGE-550SX", 0),
86  PCI_ROM(0x1186, 0x4b00, "dge560t", "D-Link DGE-560T", 0),
87  PCI_ROM(0x1186, 0x4b02, "dge560sx", "D-Link DGE-560SX", 0),
88  PCI_ROM(0x1186, 0x4b03, "dge550t", "D-Link DGE-550T", 0),
89  PCI_ROM(0x11ab, 0x4340, "m88e8021", "Marvell 88E8021", 0),
90  PCI_ROM(0x11ab, 0x4341, "m88e8022", "Marvell 88E8022", 0),
91  PCI_ROM(0x11ab, 0x4342, "m88e8061", "Marvell 88E8061", 0),
92  PCI_ROM(0x11ab, 0x4343, "m88e8062", "Marvell 88E8062", 0),
93  PCI_ROM(0x11ab, 0x4344, "m88e8021b", "Marvell 88E8021", 0),
94  PCI_ROM(0x11ab, 0x4345, "m88e8022b", "Marvell 88E8022", 0),
95  PCI_ROM(0x11ab, 0x4346, "m88e8061b", "Marvell 88E8061", 0),
96  PCI_ROM(0x11ab, 0x4347, "m88e8062b", "Marvell 88E8062", 0),
97  PCI_ROM(0x11ab, 0x4350, "m88e8035", "Marvell 88E8035", 0),
98  PCI_ROM(0x11ab, 0x4351, "m88e8036", "Marvell 88E8036", 0),
99  PCI_ROM(0x11ab, 0x4352, "m88e8038", "Marvell 88E8038", 0),
100  PCI_ROM(0x11ab, 0x4353, "m88e8039", "Marvell 88E8039", 0),
101  PCI_ROM(0x11ab, 0x4354, "m88e8040", "Marvell 88E8040", 0),
102  PCI_ROM(0x11ab, 0x4355, "m88e8040t", "Marvell 88E8040T", 0),
103  PCI_ROM(0x11ab, 0x4356, "m88ec033", "Marvel 88EC033", 0),
104  PCI_ROM(0x11ab, 0x4357, "m88e8042", "Marvell 88E8042", 0),
105  PCI_ROM(0x11ab, 0x435a, "m88e8048", "Marvell 88E8048", 0),
106  PCI_ROM(0x11ab, 0x4360, "m88e8052", "Marvell 88E8052", 0),
107  PCI_ROM(0x11ab, 0x4361, "m88e8050", "Marvell 88E8050", 0),
108  PCI_ROM(0x11ab, 0x4362, "m88e8053", "Marvell 88E8053", 0),
109  PCI_ROM(0x11ab, 0x4363, "m88e8055", "Marvell 88E8055", 0),
110  PCI_ROM(0x11ab, 0x4364, "m88e8056", "Marvell 88E8056", 0),
111  PCI_ROM(0x11ab, 0x4365, "m88e8070", "Marvell 88E8070", 0),
112  PCI_ROM(0x11ab, 0x4366, "m88ec036", "Marvell 88EC036", 0),
113  PCI_ROM(0x11ab, 0x4367, "m88ec032", "Marvell 88EC032", 0),
114  PCI_ROM(0x11ab, 0x4368, "m88ec034", "Marvell 88EC034", 0),
115  PCI_ROM(0x11ab, 0x4369, "m88ec042", "Marvell 88EC042", 0),
116  PCI_ROM(0x11ab, 0x436a, "m88e8058", "Marvell 88E8058", 0),
117  PCI_ROM(0x11ab, 0x436b, "m88e8071", "Marvell 88E8071", 0),
118  PCI_ROM(0x11ab, 0x436c, "m88e8072", "Marvell 88E8072", 0),
119  PCI_ROM(0x11ab, 0x436d, "m88e8055b", "Marvell 88E8055", 0),
120  PCI_ROM(0x11ab, 0x4370, "m88e8075", "Marvell 88E8075", 0),
121  PCI_ROM(0x11ab, 0x4380, "m88e8057", "Marvell 88E8057", 0)
122 };
123 
124 /* Avoid conditionals by using array */
125 static const unsigned txqaddr[] = { Q_XA1, Q_XA2 };
126 static const unsigned rxqaddr[] = { Q_R1, Q_R2 };
127 static const u32 portirq_msk[] = { Y2_IS_PORT_1, Y2_IS_PORT_2 };
128 
129 static void sky2_set_multicast(struct net_device *dev);
130 
131 /* Access to PHY via serial interconnect */
132 static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
133 {
134  int i;
135 
139 
140  for (i = 0; i < PHY_RETRIES; i++) {
142  if (ctrl == 0xffff)
143  goto io_error;
144 
145  if (!(ctrl & GM_SMI_CT_BUSY))
146  return 0;
147 
148  udelay(10);
149  }
150 
151  DBG(PFX "%s: phy write timeout\n", hw->dev[port]->name);
152  return -ETIMEDOUT;
153 
154 io_error:
155  DBG(PFX "%s: phy I/O error\n", hw->dev[port]->name);
156  return -EIO;
157 }
158 
159 static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
160 {
161  int i;
162 
165 
166  for (i = 0; i < PHY_RETRIES; i++) {
168  if (ctrl == 0xffff)
169  goto io_error;
170 
171  if (ctrl & GM_SMI_CT_RD_VAL) {
173  return 0;
174  }
175 
176  udelay(10);
177  }
178 
179  DBG(PFX "%s: phy read timeout\n", hw->dev[port]->name);
180  return -ETIMEDOUT;
181 io_error:
182  DBG(PFX "%s: phy I/O error\n", hw->dev[port]->name);
183  return -EIO;
184 }
185 
186 static inline u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
187 {
188  u16 v = 0;
189  __gm_phy_read(hw, port, reg, &v);
190  return v;
191 }
192 
193 
194 static void sky2_power_on(struct sky2_hw *hw)
195 {
196  /* switch power to VCC (WA for VAUX problem) */
199 
200  /* disable Core Clock Division, */
202 
203  if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
204  /* enable bits are inverted */
209  else
211 
212  if (hw->flags & SKY2_HW_ADV_POWER_CTL) {
213  u32 reg;
214 
216 
218  /* set all bits to 0 except bits 15..12 and 8 */
221 
223  /* set all bits to 0 except bits 28 & 27 */
226 
228 
229  /* Enable workaround for dev 4.107 on Yukon-Ultra & Extreme */
233 
235  }
236 }
237 
238 static void sky2_power_aux(struct sky2_hw *hw)
239 {
240  if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
242  else
243  /* enable bits are inverted */
248 
249  /* switch power to VAUX */
254 }
255 
256 static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port)
257 {
258  u16 reg;
259 
260  /* disable all GMAC IRQ's */
262 
263  gma_write16(hw, port, GM_MC_ADDR_H1, 0); /* clear MC hash */
267 
271 }
272 
273 /* flow control to advertise bits */
274 static const u16 copper_fc_adv[] = {
275  [FC_NONE] = 0,
276  [FC_TX] = PHY_M_AN_ASP,
277  [FC_RX] = PHY_M_AN_PC,
279 };
280 
281 /* flow control to advertise bits when using 1000BaseX */
282 static const u16 fiber_fc_adv[] = {
287 };
288 
289 /* flow control to GMA disable bits */
290 static const u16 gm_fc_disable[] = {
294  [FC_BOTH] = 0,
295 };
296 
297 
298 static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
299 {
300  struct sky2_port *sky2 = hw->dev[port]->priv;
301  u16 ctrl, ct1000, adv, pg, ledctrl, ledover, reg;
302 
303  if (sky2->autoneg == AUTONEG_ENABLE &&
304  !(hw->flags & SKY2_HW_NEWER_PHY)) {
306 
310 
311  /* on PHY 88E1040 Rev.D0 (and newer) downshift control changed */
312  if (hw->chip_id == CHIP_ID_YUKON_EC)
313  /* set downshift counter to 3x and enable downshift */
314  ectrl |= PHY_M_EC_DSC_2(2) | PHY_M_EC_DOWN_S_ENA;
315  else
316  /* set master & slave downshift counter to 1x */
317  ectrl |= PHY_M_EC_M_DSC(0) | PHY_M_EC_S_DSC(1);
318 
320  }
321 
323  if (sky2_is_copper(hw)) {
324  if (!(hw->flags & SKY2_HW_GIGABIT)) {
325  /* enable automatic crossover */
327 
328  if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
329  hw->chip_rev == CHIP_REV_YU_FE2_A0) {
330  u16 spec;
331 
332  /* Enable Class A driver for FE+ A0 */
336  }
337  } else {
338  /* disable energy detect */
340 
341  /* enable automatic crossover */
343 
344  /* downshift on PHY 88E1112 and 88E1149 is changed */
345  if (sky2->autoneg == AUTONEG_ENABLE
346  && (hw->flags & SKY2_HW_NEWER_PHY)) {
347  /* set downshift counter to 3x and enable downshift */
350  }
351  }
352  } else {
353  /* workaround for deviation #4.88 (CRC errors) */
354  /* disable Automatic Crossover */
355 
357  }
358 
360 
361  /* special setup for PHY 88E1112 Fiber */
362  if (hw->chip_id == CHIP_ID_YUKON_XL && (hw->flags & SKY2_HW_FIBRE_PHY)) {
364 
365  /* Fiber: select 1000BASE-X only mode MAC Specific Ctrl Reg. */
371 
372  if (hw->pmd_type == 'P') {
373  /* select page 1 to access Fiber registers */
375 
376  /* for SFP-module set SIGDET polarity to low */
380  }
381 
383  }
384 
385  ctrl = PHY_CT_RESET;
386  ct1000 = 0;
387  adv = PHY_AN_CSMA;
388  reg = 0;
389 
390  if (sky2->autoneg == AUTONEG_ENABLE) {
391  if (sky2_is_copper(hw)) {
393  ct1000 |= PHY_M_1000C_AFD;
395  ct1000 |= PHY_M_1000C_AHD;
397  adv |= PHY_M_AN_100_FD;
399  adv |= PHY_M_AN_100_HD;
401  adv |= PHY_M_AN_10_FD;
403  adv |= PHY_M_AN_10_HD;
404 
405  adv |= copper_fc_adv[sky2->flow_mode];
406  } else { /* special defines for FIBER (88E1040S only) */
408  adv |= PHY_M_AN_1000X_AFD;
410  adv |= PHY_M_AN_1000X_AHD;
411 
412  adv |= fiber_fc_adv[sky2->flow_mode];
413  }
414 
415  /* Restart Auto-negotiation */
417  } else {
418  /* forced speed/duplex settings */
419  ct1000 = PHY_M_1000C_MSE;
420 
421  /* Disable auto update for duplex flow control and speed */
423 
424  switch (sky2->speed) {
425  case SPEED_1000:
426  ctrl |= PHY_CT_SP1000;
428  break;
429  case SPEED_100:
430  ctrl |= PHY_CT_SP100;
432  break;
433  }
434 
435  if (sky2->duplex == DUPLEX_FULL) {
437  ctrl |= PHY_CT_DUP_MD;
438  } else if (sky2->speed < SPEED_1000)
439  sky2->flow_mode = FC_NONE;
440 
441 
442  reg |= gm_fc_disable[sky2->flow_mode];
443 
444  /* Forward pause packets to GMAC? */
445  if (sky2->flow_mode & FC_RX)
447  else
449  }
450 
452 
453  if (hw->flags & SKY2_HW_GIGABIT)
455 
458 
459  /* Setup Phy LED's */
460  ledctrl = PHY_M_LED_PULS_DUR(PULS_170MS);
461  ledover = 0;
462 
463  switch (hw->chip_id) {
464  case CHIP_ID_YUKON_FE:
465  /* on 88E3082 these bits are at 11..9 (shifted left) */
466  ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) << 1;
467 
469 
470  /* delete ACT LED control bits */
472  /* change ACT LED control to blink mode */
475  break;
476 
477  case CHIP_ID_YUKON_FE_P:
478  /* Enable Link Partner Next Page */
481 
482  /* disable Energy Detect and enable scrambler */
485 
486  /* set LED2 -> ACT, LED1 -> LINK, LED0 -> SPEED */
490 
492  break;
493 
494  case CHIP_ID_YUKON_XL:
496 
497  /* select page 3 to access LED control register */
499 
500  /* set LED Function Control register */
502  (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */
503  PHY_M_LEDC_INIT_CTRL(7) | /* 10 Mbps */
504  PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */
505  PHY_M_LEDC_STA0_CTRL(7))); /* 1000 Mbps */
506 
507  /* set Polarity Control register */
515 
516  /* restore page register */
518  break;
519 
520  case CHIP_ID_YUKON_EC_U:
521  case CHIP_ID_YUKON_EX:
522  case CHIP_ID_YUKON_SUPR:
524 
525  /* select page 3 to access LED control register */
527 
528  /* set LED Function Control register */
530  (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */
531  PHY_M_LEDC_INIT_CTRL(8) | /* 10 Mbps */
532  PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */
533  PHY_M_LEDC_STA0_CTRL(7)));/* 1000 Mbps */
534 
535  /* set Blink Rate in LED Timer Control Register */
537  ledctrl | PHY_M_LED_BLINK_RT(BLINK_84MS));
538  /* restore page register */
540  break;
541 
542  default:
543  /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */
545 
546  /* turn off the Rx LED (LED_RX) */
547  ledover |= PHY_M_LED_MO_RX(MO_LED_OFF);
548  }
549 
550  if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_UL_2) {
551  /* apply fixes in PHY AFE */
553 
554  /* increase differential signal amplitude in 10BASE-T */
555  gm_phy_write(hw, port, 0x18, 0xaa99);
556  gm_phy_write(hw, port, 0x17, 0x2011);
557 
558  if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
559  /* fix for IEEE A/B Symmetry failure in 1000BASE-T */
560  gm_phy_write(hw, port, 0x18, 0xa204);
561  gm_phy_write(hw, port, 0x17, 0x2002);
562  }
563 
564  /* set page register to 0 */
566  } else if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
567  hw->chip_rev == CHIP_REV_YU_FE2_A0) {
568  /* apply workaround for integrated resistors calibration */
571  } else if (hw->chip_id != CHIP_ID_YUKON_EX &&
572  hw->chip_id < CHIP_ID_YUKON_SUPR) {
573  /* no effect on Yukon-XL */
575 
576  if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
577  /* turn on 100 Mbps LED (LED_LINK100) */
578  ledover |= PHY_M_LED_MO_100(MO_LED_ON);
579  }
580 
581  if (ledover)
583 
584  }
585 
586  /* Enable phy interrupt on auto-negotiation complete (or link up) */
587  if (sky2->autoneg == AUTONEG_ENABLE)
589  else
591 }
592 
595 
596 static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
597 {
598  u32 reg1;
599 
602  reg1 &= ~phy_power[port];
603 
604  if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
605  reg1 |= coma_mode[port];
606 
610 
611  if (hw->chip_id == CHIP_ID_YUKON_FE)
613  else if (hw->flags & SKY2_HW_ADV_POWER_CTL)
615 }
616 
617 static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port)
618 {
619  u32 reg1;
620  u16 ctrl;
621 
622  /* release GPHY Control reset */
624 
625  /* release GMAC reset */
627 
628  if (hw->flags & SKY2_HW_NEWER_PHY) {
629  /* select page 2 to access MAC control register */
631 
633  /* allow GMII Power Down */
636 
637  /* set page register back to 0 */
639  }
640 
641  /* setup General Purpose Control Register */
644 
645  if (hw->chip_id != CHIP_ID_YUKON_EC) {
646  if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
647  /* select page 2 to access MAC control register */
649 
651  /* enable Power Down */
654 
655  /* set page register back to 0 */
657  }
658 
659  /* set IEEE compatible Power Down Mode (dev. #4.99) */
661  }
662 
665  reg1 |= phy_power[port]; /* set PHY to PowerDown/COMA Mode */
668 }
669 
670 static void sky2_set_tx_stfwd(struct sky2_hw *hw, unsigned port)
671 {
672  if ( (hw->chip_id == CHIP_ID_YUKON_EX &&
673  hw->chip_rev != CHIP_REV_YU_EX_A0) ||
674  hw->chip_id == CHIP_ID_YUKON_FE_P ||
675  hw->chip_id == CHIP_ID_YUKON_SUPR) {
676  /* disable jumbo frames on devices that support them */
679  } else {
681  }
682 }
683 
684 static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
685 {
686  u16 reg;
687  u32 rx_reg;
688  int i;
689  const u8 *addr = hw->dev[port]->ll_addr;
690 
693 
695 
696  if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0 && port == 1) {
697  /* WA DEV_472 -- looks like crossed wires on port 2 */
698  /* clear GMAC 1 Control reset */
700  do {
703  } while (gm_phy_read(hw, 1, PHY_MARV_ID0) != PHY_MARV_ID0_VAL ||
705  gm_phy_read(hw, 1, PHY_MARV_INT_MASK) != 0);
706  }
707 
709 
710  /* Enable Transmit FIFO Underrun */
712 
715 
716  /* MIB clear */
719 
720  for (i = GM_MIB_CNT_BASE; i <= GM_MIB_CNT_END; i += 4)
721  gma_read16(hw, port, i);
723 
724  /* transmit control */
726 
727  /* receive control reg: unicast + multicast + no FCS */
730 
731  /* transmit flow control */
732  gma_write16(hw, port, GM_TX_FLOW_CTRL, 0xffff);
733 
734  /* transmit parameter */
740 
741  /* serial mode register */
744 
746 
747  /* virtual address for data */
749 
750  /* physical address: used for pause frames */
752 
753  /* ignore counter overflows */
757 
758  /* Configure Rx MAC FIFO */
760  rx_reg = GMF_OPER_ON | GMF_RX_F_FL_ON;
761  if (hw->chip_id == CHIP_ID_YUKON_EX ||
762  hw->chip_id == CHIP_ID_YUKON_FE_P)
763  rx_reg |= GMF_RX_OVER_ON;
764 
766 
767  if (hw->chip_id == CHIP_ID_YUKON_XL) {
768  /* Hardware errata - clear flush mask */
770  } else {
771  /* Flush Rx MAC FIFO on any flow control or error */
773  }
774 
775  /* Set threshold to 0xa (64 bytes) + 1 to workaround pause bug */
776  reg = RX_GMF_FL_THR_DEF + 1;
777  /* Another magic mystery workaround from sk98lin */
778  if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
779  hw->chip_rev == CHIP_REV_YU_FE2_A0)
780  reg = 0x178;
782 
783  /* Configure Tx MAC FIFO */
786 
787  /* On chips without ram buffer, pause is controlled by MAC level */
788  if (!(hw->flags & SKY2_HW_RAM_BUFFER)) {
790  sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
791 
793  }
794 
795  if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
796  hw->chip_rev == CHIP_REV_YU_FE2_A0) {
797  /* disable dynamic watermark */
799  reg &= ~TX_DYN_WM_ENA;
801  }
802 }
803 
804 /* Assign Ram Buffer allocation to queue */
805 static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space)
806 {
807  u32 end;
808 
809  /* convert from K bytes to qwords used for hw register */
810  start *= 1024/8;
811  space *= 1024/8;
812  end = start + space - 1;
813 
819 
820  if (q == Q_R1 || q == Q_R2) {
821  u32 tp = space - space/4;
822 
823  /* On receive queue's set the thresholds
824  * give receiver priority when > 3/4 full
825  * send pause when down to 2K
826  */
828  sky2_write32(hw, RB_ADDR(q, RB_RX_LTHP), space/2);
829 
830  tp = space - 2048/8;
832  sky2_write32(hw, RB_ADDR(q, RB_RX_LTPP), space/4);
833  } else {
834  /* Enable store & forward on Tx queue's because
835  * Tx FIFO is only 1K on Yukon
836  */
838  }
839 
842 }
843 
844 /* Setup Bus Memory Interface */
845 static void sky2_qset(struct sky2_hw *hw, u16 q)
846 {
851 }
852 
853 /* Setup prefetch unit registers. This is the interface between
854  * hardware and driver list elements
855  */
856 static void sky2_prefetch_init(struct sky2_hw *hw, u32 qaddr,
857  u64 addr, u32 last)
858 {
861  sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_ADDR_HI), addr >> 32);
863  sky2_write16(hw, Y2_QADDR(qaddr, PREF_UNIT_LAST_IDX), last);
865 
867 }
868 
869 static inline struct sky2_tx_le *get_tx_le(struct sky2_port *sky2)
870 {
871  struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod;
872 
873  sky2->tx_prod = RING_NEXT(sky2->tx_prod, TX_RING_SIZE);
874  le->ctrl = 0;
875  return le;
876 }
877 
878 static void tx_init(struct sky2_port *sky2)
879 {
880  struct sky2_tx_le *le;
881 
882  sky2->tx_prod = sky2->tx_cons = 0;
883 
884  le = get_tx_le(sky2);
885  le->addr = 0;
886  le->opcode = OP_ADDR64 | HW_OWNER;
887 }
888 
889 static inline struct tx_ring_info *tx_le_re(struct sky2_port *sky2,
890  struct sky2_tx_le *le)
891 {
892  return sky2->tx_ring + (le - sky2->tx_le);
893 }
894 
895 /* Update chip's next pointer */
896 static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx)
897 {
898  /* Make sure write' to descriptors are complete before we tell hardware */
899  wmb();
901  DBGIO(PFX "queue %#x idx <- %d\n", q, idx);
902 }
903 
904 
905 static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2)
906 {
907  struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put;
908 
909  sky2->rx_put = RING_NEXT(sky2->rx_put, RX_LE_SIZE);
910  le->ctrl = 0;
911  return le;
912 }
913 
914 /* Build description to hardware for one receive segment */
915 static void sky2_rx_add(struct sky2_port *sky2, u8 op,
916  u32 map, unsigned len)
917 {
918  struct sky2_rx_le *le;
919 
920  le = sky2_next_rx(sky2);
921  le->addr = cpu_to_le32(map);
922  le->length = cpu_to_le16(len);
923  le->opcode = op | HW_OWNER;
924 }
925 
926 /* Build description to hardware for one possibly fragmented skb */
927 static void sky2_rx_submit(struct sky2_port *sky2,
928  const struct rx_ring_info *re)
929 {
930  sky2_rx_add(sky2, OP_PACKET, re->data_addr, sky2->rx_data_size);
931 }
932 
933 
934 static void sky2_rx_map_iob(struct pci_device *pdev __unused,
935  struct rx_ring_info *re,
936  unsigned size __unused)
937 {
938  struct io_buffer *iob = re->iob;
939  re->data_addr = virt_to_bus(iob->data);
940 }
941 
942 /* Diable the checksum offloading.
943  */
944 static void rx_set_checksum(struct sky2_port *sky2)
945 {
946  struct sky2_rx_le *le = sky2_next_rx(sky2);
947 
948  le->addr = cpu_to_le32((ETH_HLEN << 16) | ETH_HLEN);
949  le->ctrl = 0;
950  le->opcode = OP_TCPSTART | HW_OWNER;
951 
952  sky2_write32(sky2->hw,
953  Q_ADDR(rxqaddr[sky2->port], Q_CSR),
955 }
956 
957 /*
958  * The RX Stop command will not work for Yukon-2 if the BMU does not
959  * reach the end of packet and since we can't make sure that we have
960  * incoming data, we must reset the BMU while it is not doing a DMA
961  * transfer. Since it is possible that the RX path is still active,
962  * the RX RAM buffer will be stopped first, so any possible incoming
963  * data will not trigger a DMA. After the RAM buffer is stopped, the
964  * BMU is polled until any DMA in progress is ended and only then it
965  * will be reset.
966  */
967 static void sky2_rx_stop(struct sky2_port *sky2)
968 {
969  struct sky2_hw *hw = sky2->hw;
970  unsigned rxq = rxqaddr[sky2->port];
971  int i;
972 
973  /* disable the RAM Buffer receive queue */
975 
976  for (i = 0; i < 0xffff; i++)
977  if (sky2_read8(hw, RB_ADDR(rxq, Q_RSL))
978  == sky2_read8(hw, RB_ADDR(rxq, Q_RL)))
979  goto stopped;
980 
981  DBG(PFX "%s: receiver stop failed\n", sky2->netdev->name);
982 stopped:
984 
985  /* reset the Rx prefetch unit */
987  wmb();
988 }
989 
990 /* Clean out receive buffer area, assumes receiver hardware stopped */
991 static void sky2_rx_clean(struct sky2_port *sky2)
992 {
993  unsigned i;
994 
995  memset(sky2->rx_le, 0, RX_LE_BYTES);
996  for (i = 0; i < RX_PENDING; i++) {
997  struct rx_ring_info *re = sky2->rx_ring + i;
998 
999  if (re->iob) {
1000  free_iob(re->iob);
1001  re->iob = NULL;
1002  }
1003  }
1004 }
1005 
1006 /*
1007  * Allocate an iob for receiving.
1008  */
1009 static struct io_buffer *sky2_rx_alloc(struct sky2_port *sky2)
1010 {
1011  struct io_buffer *iob;
1012 
1013  iob = alloc_iob(sky2->rx_data_size + ETH_DATA_ALIGN);
1014  if (!iob)
1015  return NULL;
1016 
1017  /*
1018  * Cards with a RAM buffer hang in the rx FIFO if the
1019  * receive buffer isn't aligned to (Linux module comments say
1020  * 64 bytes, Linux module code says 8 bytes). Since io_buffers
1021  * are always 2kb-aligned under iPXE, just leave it be
1022  * without ETH_DATA_ALIGN in those cases.
1023  *
1024  * XXX This causes unaligned access to the IP header,
1025  * which is undesirable, but it's less undesirable than the
1026  * card hanging.
1027  */
1028  if (!(sky2->hw->flags & SKY2_HW_RAM_BUFFER)) {
1030  }
1031 
1032  return iob;
1033 }
1034 
1035 static inline void sky2_rx_update(struct sky2_port *sky2, unsigned rxq)
1036 {
1037  sky2_put_idx(sky2->hw, rxq, sky2->rx_put);
1038 }
1039 
1040 /*
1041  * Allocate and setup receiver buffer pool.
1042  * Normal case this ends up creating one list element for skb
1043  * in the receive ring. One element is used for checksum
1044  * enable/disable, and one extra to avoid wrap.
1045  */
1046 static int sky2_rx_start(struct sky2_port *sky2)
1047 {
1048  struct sky2_hw *hw = sky2->hw;
1049  struct rx_ring_info *re;
1050  unsigned rxq = rxqaddr[sky2->port];
1051  unsigned i, size, thresh;
1052 
1053  sky2->rx_put = sky2->rx_next = 0;
1054  sky2_qset(hw, rxq);
1055 
1056  /* On PCI express lowering the watermark gives better performance */
1059 
1060  /* These chips have no ram buffer?
1061  * MAC Rx RAM Read is controlled by hardware */
1062  if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
1063  (hw->chip_rev == CHIP_REV_YU_EC_U_A1
1064  || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
1066 
1067  sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
1068 
1069  if (!(hw->flags & SKY2_HW_NEW_LE))
1070  rx_set_checksum(sky2);
1071 
1072  /* Space needed for frame data + headers rounded up */
1073  size = (ETH_FRAME_LEN + 8) & ~7;
1074 
1075  /* Stopping point for hardware truncation */
1076  thresh = (size - 8) / sizeof(u32);
1077 
1078  sky2->rx_data_size = size;
1079 
1080  /* Fill Rx ring */
1081  for (i = 0; i < RX_PENDING; i++) {
1082  re = sky2->rx_ring + i;
1083 
1084  re->iob = sky2_rx_alloc(sky2);
1085  if (!re->iob)
1086  goto nomem;
1087 
1088  sky2_rx_map_iob(hw->pdev, re, sky2->rx_data_size);
1089  sky2_rx_submit(sky2, re);
1090  }
1091 
1092  /*
1093  * The receiver hangs if it receives frames larger than the
1094  * packet buffer. As a workaround, truncate oversize frames, but
1095  * the register is limited to 9 bits, so if you do frames > 2052
1096  * you better get the MTU right!
1097  */
1098  if (thresh > 0x1ff)
1100  else {
1101  sky2_write16(hw, SK_REG(sky2->port, RX_GMF_TR_THR), thresh);
1103  }
1104 
1105  /* Tell chip about available buffers */
1106  sky2_rx_update(sky2, rxq);
1107  return 0;
1108 nomem:
1109  sky2_rx_clean(sky2);
1110  return -ENOMEM;
1111 }
1112 
1113 /* Free the le and ring buffers */
1114 static void sky2_free_rings(struct sky2_port *sky2)
1115 {
1116  free_phys(sky2->rx_le, RX_LE_BYTES);
1117  free(sky2->rx_ring);
1118 
1119  free_phys(sky2->tx_le, TX_RING_SIZE * sizeof(struct sky2_tx_le));
1120  free(sky2->tx_ring);
1121 
1122  sky2->tx_le = NULL;
1123  sky2->rx_le = NULL;
1124 
1125  sky2->rx_ring = NULL;
1126  sky2->tx_ring = NULL;
1127 }
1128 
1129 /* Bring up network interface. */
1130 static int sky2_up(struct net_device *dev)
1131 {
1132  struct sky2_port *sky2 = dev->priv;
1133  struct sky2_hw *hw = sky2->hw;
1134  unsigned port = sky2->port;
1135  u32 imask, ramsize;
1136  int err = -ENOMEM;
1137 
1139 
1140  /* must be power of 2 */
1141  sky2->tx_le = malloc_phys(TX_RING_SIZE * sizeof(struct sky2_tx_le), TX_RING_ALIGN);
1142  sky2->tx_le_map = virt_to_bus(sky2->tx_le);
1143  if (!sky2->tx_le)
1144  goto err_out;
1145  memset(sky2->tx_le, 0, TX_RING_SIZE * sizeof(struct sky2_tx_le));
1146 
1147  sky2->tx_ring = zalloc(TX_RING_SIZE * sizeof(struct tx_ring_info));
1148  if (!sky2->tx_ring)
1149  goto err_out;
1150 
1151  tx_init(sky2);
1152 
1154  sky2->rx_le_map = virt_to_bus(sky2->rx_le);
1155  if (!sky2->rx_le)
1156  goto err_out;
1157  memset(sky2->rx_le, 0, RX_LE_BYTES);
1158 
1159  sky2->rx_ring = zalloc(RX_PENDING * sizeof(struct rx_ring_info));
1160  if (!sky2->rx_ring)
1161  goto err_out;
1162 
1163  sky2_mac_init(hw, port);
1164 
1165  /* Register is number of 4K blocks on internal RAM buffer. */
1166  ramsize = sky2_read8(hw, B2_E_0) * 4;
1167  if (ramsize > 0) {
1168  u32 rxspace;
1169 
1170  hw->flags |= SKY2_HW_RAM_BUFFER;
1171  DBG2(PFX "%s: ram buffer %dK\n", dev->name, ramsize);
1172  if (ramsize < 16)
1173  rxspace = ramsize / 2;
1174  else
1175  rxspace = 8 + (2*(ramsize - 16))/3;
1176 
1177  sky2_ramset(hw, rxqaddr[port], 0, rxspace);
1178  sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace);
1179 
1180  /* Make sure SyncQ is disabled */
1182  RB_RST_SET);
1183  }
1184 
1185  sky2_qset(hw, txqaddr[port]);
1186 
1187  /* This is copied from sk98lin 10.0.5.3; no one tells me about erratta's */
1188  if (hw->chip_id == CHIP_ID_YUKON_EX && hw->chip_rev == CHIP_REV_YU_EX_B0)
1190 
1191  /* Set almost empty threshold */
1192  if (hw->chip_id == CHIP_ID_YUKON_EC_U
1193  && hw->chip_rev == CHIP_REV_YU_EC_U_A0)
1195 
1197  TX_RING_SIZE - 1);
1198 
1199  err = sky2_rx_start(sky2);
1200  if (err)
1201  goto err_out;
1202 
1203  /* Enable interrupts from phy/mac for port */
1204  imask = sky2_read32(hw, B0_IMSK);
1205  imask |= portirq_msk[port];
1206  sky2_write32(hw, B0_IMSK, imask);
1207 
1208  DBGIO(PFX "%s: le bases: st %p [%x], rx %p [%x], tx %p [%x]\n",
1209  dev->name, hw->st_le, hw->st_dma, sky2->rx_le, sky2->rx_le_map,
1210  sky2->tx_le, sky2->tx_le_map);
1211 
1213  return 0;
1214 
1215 err_out:
1216  sky2_free_rings(sky2);
1217  return err;
1218 }
1219 
1220 /* Modular subtraction in ring */
1221 static inline int tx_dist(unsigned tail, unsigned head)
1222 {
1223  return (head - tail) & (TX_RING_SIZE - 1);
1224 }
1225 
1226 /* Number of list elements available for next tx */
1227 static inline int tx_avail(const struct sky2_port *sky2)
1228 {
1229  return TX_PENDING - tx_dist(sky2->tx_cons, sky2->tx_prod);
1230 }
1231 
1232 
1233 /*
1234  * Put one packet in ring for transmit.
1235  * A single packet can generate multiple list elements, and
1236  * the number of ring elements will probably be less than the number
1237  * of list elements used.
1238  */
1239 static int sky2_xmit_frame(struct net_device *dev, struct io_buffer *iob)
1240 {
1241  struct sky2_port *sky2 = dev->priv;
1242  struct sky2_hw *hw = sky2->hw;
1243  struct sky2_tx_le *le = NULL;
1244  struct tx_ring_info *re;
1245  unsigned len;
1246  u32 mapping;
1247  u8 ctrl;
1248 
1249  if (tx_avail(sky2) < 1)
1250  return -EBUSY;
1251 
1252  len = iob_len(iob);
1253  mapping = virt_to_bus(iob->data);
1254 
1255  DBGIO(PFX "%s: tx queued, slot %d, len %d\n", dev->name,
1256  sky2->tx_prod, len);
1257 
1258  ctrl = 0;
1259 
1260  le = get_tx_le(sky2);
1261  le->addr = cpu_to_le32((u32) mapping);
1262  le->length = cpu_to_le16(len);
1263  le->ctrl = ctrl;
1264  le->opcode = (OP_PACKET | HW_OWNER);
1265 
1266  re = tx_le_re(sky2, le);
1267  re->iob = iob;
1268 
1269  le->ctrl |= EOP;
1270 
1271  sky2_put_idx(hw, txqaddr[sky2->port], sky2->tx_prod);
1272 
1273  return 0;
1274 }
1275 
1276 /*
1277  * Free ring elements from starting at tx_cons until "done"
1278  *
1279  * NB: the hardware will tell us about partial completion of multi-part
1280  * buffers so make sure not to free iob too early.
1281  */
1282 static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
1283 {
1284  struct net_device *dev = sky2->netdev;
1285  unsigned idx;
1286 
1288 
1289  for (idx = sky2->tx_cons; idx != done;
1290  idx = RING_NEXT(idx, TX_RING_SIZE)) {
1291  struct sky2_tx_le *le = sky2->tx_le + idx;
1292  struct tx_ring_info *re = sky2->tx_ring + idx;
1293 
1294  if (le->ctrl & EOP) {
1295  DBGIO(PFX "%s: tx done %d\n", dev->name, idx);
1296  netdev_tx_complete(dev, re->iob);
1297  }
1298  }
1299 
1300  sky2->tx_cons = idx;
1301  mb();
1302 }
1303 
1304 /* Cleanup all untransmitted buffers, assume transmitter not running */
1305 static void sky2_tx_clean(struct net_device *dev)
1306 {
1307  struct sky2_port *sky2 = dev->priv;
1308 
1309  sky2_tx_complete(sky2, sky2->tx_prod);
1310 }
1311 
1312 /* Network shutdown */
1313 static void sky2_down(struct net_device *dev)
1314 {
1315  struct sky2_port *sky2 = dev->priv;
1316  struct sky2_hw *hw = sky2->hw;
1317  unsigned port = sky2->port;
1318  u16 ctrl;
1319  u32 imask;
1320 
1321  /* Never really got started! */
1322  if (!sky2->tx_le)
1323  return;
1324 
1325  DBG2(PFX "%s: disabling interface\n", dev->name);
1326 
1327  /* Disable port IRQ */
1328  imask = sky2_read32(hw, B0_IMSK);
1329  imask &= ~portirq_msk[port];
1330  sky2_write32(hw, B0_IMSK, imask);
1331 
1333 
1334  /* Stop transmitter */
1337 
1340 
1344 
1346 
1347  /* Workaround shared GMAC reset */
1348  if (!(hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0
1349  && port == 0 && hw->dev[1]))
1351 
1352  /* Disable Force Sync bit and Enable Alloc bit */
1355 
1356  /* Stop Interval Timer and Limit Counter of Tx Arbiter */
1359 
1360  /* Reset the PCI FIFO of the async Tx queue */
1363 
1364  /* Reset the Tx prefetch units */
1367 
1369 
1370  sky2_rx_stop(sky2);
1371 
1374 
1376 
1377  /* turn off LED's */
1379 
1380  sky2_tx_clean(dev);
1381  sky2_rx_clean(sky2);
1382 
1383  sky2_free_rings(sky2);
1384 
1385  return;
1386 }
1387 
1388 static u16 sky2_phy_speed(const struct sky2_hw *hw, u16 aux)
1389 {
1390  if (hw->flags & SKY2_HW_FIBRE_PHY)
1391  return SPEED_1000;
1392 
1393  if (!(hw->flags & SKY2_HW_GIGABIT)) {
1394  if (aux & PHY_M_PS_SPEED_100)
1395  return SPEED_100;
1396  else
1397  return SPEED_10;
1398  }
1399 
1400  switch (aux & PHY_M_PS_SPEED_MSK) {
1401  case PHY_M_PS_SPEED_1000:
1402  return SPEED_1000;
1403  case PHY_M_PS_SPEED_100:
1404  return SPEED_100;
1405  default:
1406  return SPEED_10;
1407  }
1408 }
1409 
1410 static void sky2_link_up(struct sky2_port *sky2)
1411 {
1412  struct sky2_hw *hw = sky2->hw;
1413  unsigned port = sky2->port;
1414  u16 reg;
1415  static const char *fc_name[] = {
1416  [FC_NONE] = "none",
1417  [FC_TX] = "tx",
1418  [FC_RX] = "rx",
1419  [FC_BOTH] = "both",
1420  };
1421 
1422  /* enable Rx/Tx */
1426 
1428 
1429  netdev_link_up(sky2->netdev);
1430 
1431  /* Turn on link LED */
1434 
1435  DBG(PFX "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
1436  sky2->netdev->name, sky2->speed,
1437  sky2->duplex == DUPLEX_FULL ? "full" : "half",
1438  fc_name[sky2->flow_status]);
1439 }
1440 
1441 static void sky2_link_down(struct sky2_port *sky2)
1442 {
1443  struct sky2_hw *hw = sky2->hw;
1444  unsigned port = sky2->port;
1445  u16 reg;
1446 
1448 
1452 
1453  netdev_link_down(sky2->netdev);
1454 
1455  /* Turn on link LED */
1457 
1458  DBG(PFX "%s: Link is down.\n", sky2->netdev->name);
1459 
1460  sky2_phy_init(hw, port);
1461 }
1462 
1463 static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
1464 {
1465  struct sky2_hw *hw = sky2->hw;
1466  unsigned port = sky2->port;
1467  u16 advert, lpa;
1468 
1469  advert = gm_phy_read(hw, port, PHY_MARV_AUNE_ADV);
1471  if (lpa & PHY_M_AN_RF) {
1472  DBG(PFX "%s: remote fault\n", sky2->netdev->name);
1473  return -1;
1474  }
1475 
1476  if (!(aux & PHY_M_PS_SPDUP_RES)) {
1477  DBG(PFX "%s: speed/duplex mismatch\n", sky2->netdev->name);
1478  return -1;
1479  }
1480 
1481  sky2->speed = sky2_phy_speed(hw, aux);
1482  sky2->duplex = (aux & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF;
1483 
1484  /* Since the pause result bits seem to in different positions on
1485  * different chips. look at registers.
1486  */
1487 
1488  sky2->flow_status = FC_NONE;
1489  if (advert & ADVERTISE_PAUSE_CAP) {
1490  if (lpa & LPA_PAUSE_CAP)
1491  sky2->flow_status = FC_BOTH;
1492  else if (advert & ADVERTISE_PAUSE_ASYM)
1493  sky2->flow_status = FC_RX;
1494  } else if (advert & ADVERTISE_PAUSE_ASYM) {
1495  if ((lpa & LPA_PAUSE_CAP) && (lpa & LPA_PAUSE_ASYM))
1496  sky2->flow_status = FC_TX;
1497  }
1498 
1499  if (sky2->duplex == DUPLEX_HALF && sky2->speed < SPEED_1000
1500  && !(hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX))
1501  sky2->flow_status = FC_NONE;
1502 
1503  if (sky2->flow_status & FC_TX)
1505  else
1507 
1508  return 0;
1509 }
1510 
1511 /* Interrupt from PHY */
1512 static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
1513 {
1514  struct net_device *dev = hw->dev[port];
1515  struct sky2_port *sky2 = dev->priv;
1516  u16 istatus, phystat;
1517 
1518  istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT);
1519  phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT);
1520 
1521  DBGIO(PFX "%s: phy interrupt status 0x%x 0x%x\n",
1522  sky2->netdev->name, istatus, phystat);
1523 
1524  if (sky2->autoneg == AUTONEG_ENABLE && (istatus & PHY_M_IS_AN_COMPL)) {
1525  if (sky2_autoneg_done(sky2, phystat) == 0)
1526  sky2_link_up(sky2);
1527  return;
1528  }
1529 
1530  if (istatus & PHY_M_IS_LSP_CHANGE)
1531  sky2->speed = sky2_phy_speed(hw, phystat);
1532 
1533  if (istatus & PHY_M_IS_DUP_CHANGE)
1534  sky2->duplex =
1535  (phystat & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF;
1536 
1537  if (istatus & PHY_M_IS_LST_CHANGE) {
1538  if (phystat & PHY_M_PS_LINK_UP)
1539  sky2_link_up(sky2);
1540  else
1541  sky2_link_down(sky2);
1542  }
1543 }
1544 
1545 /* Normal packet - take iob from ring element and put in a new one */
1546 static struct io_buffer *receive_new(struct sky2_port *sky2,
1547  struct rx_ring_info *re,
1548  unsigned int length)
1549 {
1550  struct io_buffer *iob, *niob;
1551  unsigned hdr_space = sky2->rx_data_size;
1552 
1553  /* Don't be tricky about reusing pages (yet) */
1554  niob = sky2_rx_alloc(sky2);
1555  if (!niob)
1556  return NULL;
1557 
1558  iob = re->iob;
1559 
1560  re->iob = niob;
1561  sky2_rx_map_iob(sky2->hw->pdev, re, hdr_space);
1562 
1563  iob_put(iob, length);
1564  return iob;
1565 }
1566 
1567 /*
1568  * Receive one packet.
1569  * For larger packets, get new buffer.
1570  */
1571 static struct io_buffer *sky2_receive(struct net_device *dev,
1572  u16 length, u32 status)
1573 {
1574  struct sky2_port *sky2 = dev->priv;
1575  struct rx_ring_info *re = sky2->rx_ring + sky2->rx_next;
1576  struct io_buffer *iob = NULL;
1577  u16 count = (status & GMR_FS_LEN) >> 16;
1578 
1579  DBGIO(PFX "%s: rx slot %d status 0x%x len %d\n",
1580  dev->name, sky2->rx_next, status, length);
1581 
1582  sky2->rx_next = (sky2->rx_next + 1) % RX_PENDING;
1583 
1584  /* This chip has hardware problems that generates bogus status.
1585  * So do only marginal checking and expect higher level protocols
1586  * to handle crap frames.
1587  */
1588  if (sky2->hw->chip_id == CHIP_ID_YUKON_FE_P &&
1589  sky2->hw->chip_rev == CHIP_REV_YU_FE2_A0 &&
1590  length == count)
1591  goto okay;
1592 
1593  if (status & GMR_FS_ANY_ERR)
1594  goto error;
1595 
1596  if (!(status & GMR_FS_RX_OK))
1597  goto resubmit;
1598 
1599  /* if length reported by DMA does not match PHY, packet was truncated */
1600  if (length != count)
1601  goto len_error;
1602 
1603 okay:
1604  iob = receive_new(sky2, re, length);
1605 resubmit:
1606  sky2_rx_submit(sky2, re);
1607 
1608  return iob;
1609 
1610 len_error:
1611  /* Truncation of overlength packets
1612  causes PHY length to not match MAC length */
1613  DBG2(PFX "%s: rx length error: status %#x length %d\n",
1614  dev->name, status, length);
1615 
1616  /* Pass NULL as iob because we want to keep our iob in the
1617  ring for the next packet. */
1618  netdev_rx_err(dev, NULL, -EINVAL);
1619  goto resubmit;
1620 
1621 error:
1622  if (status & GMR_FS_RX_FF_OV) {
1623  DBG2(PFX "%s: FIFO overflow error\n", dev->name);
1624  netdev_rx_err(dev, NULL, -EBUSY);
1625  goto resubmit;
1626  }
1627 
1628  DBG2(PFX "%s: rx error, status 0x%x length %d\n",
1629  dev->name, status, length);
1630  netdev_rx_err(dev, NULL, -EIO);
1631 
1632  goto resubmit;
1633 }
1634 
1635 /* Transmit complete */
1636 static inline void sky2_tx_done(struct net_device *dev, u16 last)
1637 {
1638  struct sky2_port *sky2 = dev->priv;
1639 
1640  sky2_tx_complete(sky2, last);
1641 }
1642 
1643 /* Process status response ring */
1644 static void sky2_status_intr(struct sky2_hw *hw, u16 idx)
1645 {
1646  unsigned rx[2] = { 0, 0 };
1647 
1648  rmb();
1649  do {
1650  struct sky2_status_le *le = hw->st_le + hw->st_idx;
1651  unsigned port;
1652  struct net_device *dev;
1653  struct io_buffer *iob;
1654  u32 status;
1655  u16 length;
1656  u8 opcode = le->opcode;
1657 
1658  if (!(opcode & HW_OWNER))
1659  break;
1660 
1661  port = le->css & CSS_LINK_BIT;
1662  dev = hw->dev[port];
1663  length = le16_to_cpu(le->length);
1664  status = le32_to_cpu(le->status);
1665 
1666  hw->st_idx = RING_NEXT(hw->st_idx, STATUS_RING_SIZE);
1667 
1668  le->opcode = 0;
1669  switch (opcode & ~HW_OWNER) {
1670  case OP_RXSTAT:
1671  ++rx[port];
1672  iob = sky2_receive(dev, length, status);
1673  if (!iob) {
1674  netdev_rx_err(dev, NULL, -ENOMEM);
1675  break;
1676  }
1677 
1678  netdev_rx(dev, iob);
1679  break;
1680 
1681  case OP_RXCHKS:
1682  DBG2(PFX "status OP_RXCHKS but checksum offloading disabled\n");
1683  break;
1684 
1685  case OP_TXINDEXLE:
1686  /* TX index reports status for both ports */
1687  assert(TX_RING_SIZE <= 0x1000);
1688  sky2_tx_done(hw->dev[0], status & 0xfff);
1689  if (hw->dev[1])
1690  sky2_tx_done(hw->dev[1],
1691  ((status >> 24) & 0xff)
1692  | (u16)(length & 0xf) << 8);
1693  break;
1694 
1695  default:
1696  DBG(PFX "unknown status opcode 0x%x\n", opcode);
1697  }
1698  } while (hw->st_idx != idx);
1699 
1700  /* Fully processed status ring so clear irq */
1702 
1703  if (rx[0])
1704  sky2_rx_update(hw->dev[0]->priv, Q_R1);
1705 
1706  if (rx[1])
1707  sky2_rx_update(hw->dev[1]->priv, Q_R2);
1708 }
1709 
1710 static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status)
1711 {
1712  struct net_device *dev = hw->dev[port];
1713 
1714  DBGIO(PFX "%s: hw error interrupt status 0x%x\n", dev->name, status);
1715 
1716  if (status & Y2_IS_PAR_RD1) {
1717  DBG(PFX "%s: ram data read parity error\n", dev->name);
1718  /* Clear IRQ */
1720  }
1721 
1722  if (status & Y2_IS_PAR_WR1) {
1723  DBG(PFX "%s: ram data write parity error\n", dev->name);
1725  }
1726 
1727  if (status & Y2_IS_PAR_MAC1) {
1728  DBG(PFX "%s: MAC parity error\n", dev->name);
1730  }
1731 
1732  if (status & Y2_IS_PAR_RX1) {
1733  DBG(PFX "%s: RX parity error\n", dev->name);
1735  }
1736 
1737  if (status & Y2_IS_TCP_TXA1) {
1738  DBG(PFX "%s: TCP segmentation error\n", dev->name);
1740  }
1741 }
1742 
1743 static void sky2_hw_intr(struct sky2_hw *hw)
1744 {
1746  u32 hwmsk = sky2_read32(hw, B0_HWE_IMSK);
1747 
1748  status &= hwmsk;
1749 
1750  if (status & Y2_IS_TIST_OV)
1752 
1753  if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
1754  u16 pci_err;
1755 
1757  pci_err = sky2_pci_read16(hw, PCI_STATUS);
1758  DBG(PFX "PCI hardware error (0x%x)\n", pci_err);
1759 
1761  pci_err | PCI_STATUS_ERROR_BITS);
1763  }
1764 
1765  if (status & Y2_IS_PCI_EXP) {
1766  /* PCI-Express uncorrectable Error occurred */
1767  u32 err;
1768 
1772  0xfffffffful);
1773  DBG(PFX "PCI-Express error (0x%x)\n", err);
1774 
1777  }
1778 
1779  if (status & Y2_HWE_L1_MASK)
1780  sky2_hw_error(hw, 0, status);
1781  status >>= 8;
1782  if (status & Y2_HWE_L1_MASK)
1783  sky2_hw_error(hw, 1, status);
1784 }
1785 
1786 static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
1787 {
1788  struct net_device *dev = hw->dev[port];
1790 
1791  DBGIO(PFX "%s: mac interrupt status 0x%x\n", dev->name, status);
1792 
1793  if (status & GM_IS_RX_CO_OV)
1795 
1796  if (status & GM_IS_TX_CO_OV)
1798 
1799  if (status & GM_IS_RX_FF_OR) {
1801  }
1802 
1803  if (status & GM_IS_TX_FF_UR) {
1805  }
1806 }
1807 
1808 /* This should never happen it is a bug. */
1809 static void sky2_le_error(struct sky2_hw *hw, unsigned port,
1810  u16 q, unsigned ring_size __unused)
1811 {
1812  struct net_device *dev = hw->dev[port];
1813  struct sky2_port *sky2 = dev->priv;
1814  int idx;
1815  const u64 *le = (q == Q_R1 || q == Q_R2)
1816  ? (u64 *) sky2->rx_le : (u64 *) sky2->tx_le;
1817 
1819  DBG(PFX "%s: descriptor error q=%#x get=%d [%llx] last=%d put=%d should be %d\n",
1820  dev->name, (unsigned) q, idx, (unsigned long long) le[idx],
1823  le == (u64 *)sky2->rx_le? sky2->rx_put : sky2->tx_prod);
1824 
1826 }
1827 
1828 /* Hardware/software error handling */
1829 static void sky2_err_intr(struct sky2_hw *hw, u32 status)
1830 {
1831  DBG(PFX "error interrupt status=%#x\n", status);
1832 
1833  if (status & Y2_IS_HW_ERR)
1834  sky2_hw_intr(hw);
1835 
1836  if (status & Y2_IS_IRQ_MAC1)
1837  sky2_mac_intr(hw, 0);
1838 
1839  if (status & Y2_IS_IRQ_MAC2)
1840  sky2_mac_intr(hw, 1);
1841 
1842  if (status & Y2_IS_CHK_RX1)
1844 
1845  if (status & Y2_IS_CHK_RX2)
1847 
1848  if (status & Y2_IS_CHK_TXA1)
1850 
1851  if (status & Y2_IS_CHK_TXA2)
1853 }
1854 
1855 static void sky2_poll(struct net_device *dev)
1856 {
1857  struct sky2_port *sky2 = dev->priv;
1858  struct sky2_hw *hw = sky2->hw;
1860  u16 idx;
1861 
1862  if (status & Y2_IS_ERROR)
1864 
1865  if (status & Y2_IS_IRQ_PHY1)
1866  sky2_phy_intr(hw, 0);
1867 
1868  if (status & Y2_IS_IRQ_PHY2)
1869  sky2_phy_intr(hw, 1);
1870 
1871  while ((idx = sky2_read16(hw, STAT_PUT_IDX)) != hw->st_idx) {
1872  sky2_status_intr(hw, idx);
1873  }
1874 
1875  /* Bug/Errata workaround?
1876  * Need to kick the TX irq moderation timer.
1877  */
1881  }
1883 }
1884 
1885 /* Chip internal frequency for clock calculations */
1886 static u32 sky2_mhz(const struct sky2_hw *hw)
1887 {
1888  switch (hw->chip_id) {
1889  case CHIP_ID_YUKON_EC:
1890  case CHIP_ID_YUKON_EC_U:
1891  case CHIP_ID_YUKON_EX:
1892  case CHIP_ID_YUKON_SUPR:
1893  case CHIP_ID_YUKON_UL_2:
1894  return 125;
1895 
1896  case CHIP_ID_YUKON_FE:
1897  return 100;
1898 
1899  case CHIP_ID_YUKON_FE_P:
1900  return 50;
1901 
1902  case CHIP_ID_YUKON_XL:
1903  return 156;
1904 
1905  default:
1906  DBG(PFX "unknown chip ID!\n");
1907  return 100; /* bogus */
1908  }
1909 }
1910 
1911 static inline u32 sky2_us2clk(const struct sky2_hw *hw, u32 us)
1912 {
1913  return sky2_mhz(hw) * us;
1914 }
1915 
1916 static inline u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk)
1917 {
1918  return clk / sky2_mhz(hw);
1919 }
1920 
1921 static int sky2_init(struct sky2_hw *hw)
1922 {
1923  u8 t8;
1924 
1925  /* Enable all clocks and check for bad PCI access */
1927 
1929 
1930  hw->chip_id = sky2_read8(hw, B2_CHIP_ID);
1931  hw->chip_rev = (sky2_read8(hw, B2_MAC_CFG) & CFG_CHIP_R_MSK) >> 4;
1932 
1933  switch(hw->chip_id) {
1934  case CHIP_ID_YUKON_XL:
1936  break;
1937 
1938  case CHIP_ID_YUKON_EC_U:
1939  hw->flags = SKY2_HW_GIGABIT
1942  break;
1943 
1944  case CHIP_ID_YUKON_EX:
1945  hw->flags = SKY2_HW_GIGABIT
1947  | SKY2_HW_NEW_LE
1949  break;
1950 
1951  case CHIP_ID_YUKON_EC:
1952  /* This rev is really old, and requires untested workarounds */
1953  if (hw->chip_rev == CHIP_REV_YU_EC_A1) {
1954  DBG(PFX "unsupported revision Yukon-EC rev A1\n");
1955  return -EOPNOTSUPP;
1956  }
1957  hw->flags = SKY2_HW_GIGABIT;
1958  break;
1959 
1960  case CHIP_ID_YUKON_FE:
1961  break;
1962 
1963  case CHIP_ID_YUKON_FE_P:
1964  hw->flags = SKY2_HW_NEWER_PHY
1965  | SKY2_HW_NEW_LE
1968  break;
1969 
1970  case CHIP_ID_YUKON_SUPR:
1971  hw->flags = SKY2_HW_GIGABIT
1973  | SKY2_HW_NEW_LE
1976  break;
1977 
1978  case CHIP_ID_YUKON_UL_2:
1979  hw->flags = SKY2_HW_GIGABIT
1981  break;
1982 
1983  default:
1984  DBG(PFX "unsupported chip type 0x%x\n", hw->chip_id);
1985  return -EOPNOTSUPP;
1986  }
1987 
1988  hw->pmd_type = sky2_read8(hw, B2_PMD_TYP);
1989  if (hw->pmd_type == 'L' || hw->pmd_type == 'S' || hw->pmd_type == 'P')
1990  hw->flags |= SKY2_HW_FIBRE_PHY;
1991 
1992  hw->ports = 1;
1993  t8 = sky2_read8(hw, B2_Y2_HW_RES);
1994  if ((t8 & CFG_DUAL_MAC_MSK) == CFG_DUAL_MAC_MSK) {
1996  ++hw->ports;
1997  }
1998 
1999  return 0;
2000 }
2001 
2002 static void sky2_reset(struct sky2_hw *hw)
2003 {
2004  u16 status;
2005  int i, cap;
2006  u32 hwe_mask = Y2_HWE_ALL_MASK;
2007 
2008  /* disable ASF */
2009  if (hw->chip_id == CHIP_ID_YUKON_EX) {
2014  } else
2017 
2018  /* do a SW reset */
2021 
2022  /* allow writes to PCI config */
2024 
2025  /* clear PCI errors, if any */
2029 
2031 
2032  cap = pci_find_capability(hw->pdev, PCI_CAP_ID_EXP);
2033  if (cap) {
2035  0xfffffffful);
2036 
2037  /* If an error bit is stuck on ignore it */
2039  DBG(PFX "ignoring stuck error report bit\n");
2040  else
2041  hwe_mask |= Y2_IS_PCI_EXP;
2042  }
2043 
2044  sky2_power_on(hw);
2046 
2047  for (i = 0; i < hw->ports; i++) {
2050 
2051  if (hw->chip_id == CHIP_ID_YUKON_EX ||
2052  hw->chip_id == CHIP_ID_YUKON_SUPR)
2055  | GMC_BYP_RETR_ON);
2056  }
2057 
2058  /* Clear I2C IRQ noise */
2059  sky2_write32(hw, B2_I2C_IRQ, 1);
2060 
2061  /* turn off hardware timer (unused) */
2064 
2066 
2067  /* Turn off descriptor polling */
2069 
2070  /* Turn off receive timestamp */
2073 
2074  /* enable the Tx Arbiters */
2075  for (i = 0; i < hw->ports; i++)
2077 
2078  /* Initialize ram interface */
2079  for (i = 0; i < hw->ports; i++) {
2081 
2094  }
2095 
2096  sky2_write32(hw, B0_HWE_IMSK, hwe_mask);
2097 
2098  for (i = 0; i < hw->ports; i++)
2099  sky2_gmac_reset(hw, i);
2100 
2101  memset(hw->st_le, 0, STATUS_LE_BYTES);
2102  hw->st_idx = 0;
2103 
2106 
2107  sky2_write32(hw, STAT_LIST_ADDR_LO, hw->st_dma);
2108  sky2_write32(hw, STAT_LIST_ADDR_HI, (u64) hw->st_dma >> 32);
2109 
2110  /* Set the list last index */
2112 
2114  sky2_write8(hw, STAT_FIFO_WM, 16);
2115 
2116  /* set Status-FIFO ISR watermark */
2117  if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0)
2119  else
2121 
2125 
2126  /* enable status unit */
2128 
2132 }
2133 
2134 static u32 sky2_supported_modes(const struct sky2_hw *hw)
2135 {
2136  if (sky2_is_copper(hw)) {
2137  u32 modes = SUPPORTED_10baseT_Half
2142 
2143  if (hw->flags & SKY2_HW_GIGABIT)
2144  modes |= SUPPORTED_1000baseT_Half
2146  return modes;
2147  } else
2151  | SUPPORTED_FIBRE;
2152 }
2153 
2154 static void sky2_set_multicast(struct net_device *dev)
2155 {
2156  struct sky2_port *sky2 = dev->priv;
2157  struct sky2_hw *hw = sky2->hw;
2158  unsigned port = sky2->port;
2159  u16 reg;
2160  u8 filter[8];
2161 
2163  reg |= GM_RXCR_UCF_ENA;
2164 
2165  memset(filter, 0xff, sizeof(filter));
2166 
2168  (u16) filter[0] | ((u16) filter[1] << 8));
2170  (u16) filter[2] | ((u16) filter[3] << 8));
2172  (u16) filter[4] | ((u16) filter[5] << 8));
2174  (u16) filter[6] | ((u16) filter[7] << 8));
2175 
2177 }
2178 
2179 /* Initialize network device */
2180 static struct net_device *sky2_init_netdev(struct sky2_hw *hw,
2181  unsigned port)
2182 {
2183  struct sky2_port *sky2;
2184  struct net_device *dev = alloc_etherdev(sizeof(*sky2));
2185 
2186  if (!dev) {
2187  DBG(PFX "etherdev alloc failed\n");
2188  return NULL;
2189  }
2190 
2191  dev->dev = &hw->pdev->dev;
2192 
2193  sky2 = dev->priv;
2194  sky2->netdev = dev;
2195  sky2->hw = hw;
2196 
2197  /* Auto speed and flow control */
2198  sky2->autoneg = AUTONEG_ENABLE;
2199  sky2->flow_mode = FC_BOTH;
2200 
2201  sky2->duplex = -1;
2202  sky2->speed = -1;
2204 
2205  hw->dev[port] = dev;
2206 
2207  sky2->port = port;
2208 
2209  /* read the mac address */
2210  memcpy(dev->hw_addr, (void *)(hw->regs + B2_MAC_1 + port * 8), ETH_ALEN);
2211 
2212  return dev;
2213 }
2214 
2215 static void sky2_show_addr(struct net_device *dev)
2216 {
2217  DBG2(PFX "%s: addr %s\n", dev->name, netdev_addr(dev));
2218 }
2219 
2220 #if DBGLVL_MAX
2221 /* This driver supports yukon2 chipset only */
2222 static const char *sky2_name(u8 chipid, char *buf, int sz)
2223 {
2224  const char *name[] = {
2225  "XL", /* 0xb3 */
2226  "EC Ultra", /* 0xb4 */
2227  "Extreme", /* 0xb5 */
2228  "EC", /* 0xb6 */
2229  "FE", /* 0xb7 */
2230  "FE+", /* 0xb8 */
2231  "Supreme", /* 0xb9 */
2232  "UL 2", /* 0xba */
2233  };
2234 
2235  if (chipid >= CHIP_ID_YUKON_XL && chipid <= CHIP_ID_YUKON_UL_2)
2236  strncpy(buf, name[chipid - CHIP_ID_YUKON_XL], sz);
2237  else
2238  snprintf(buf, sz, "(chip %#x)", chipid);
2239  return buf;
2240 }
2241 #endif
2242 
2243 static void sky2_net_irq(struct net_device *dev, int enable)
2244 {
2245  struct sky2_port *sky2 = dev->priv;
2246  struct sky2_hw *hw = sky2->hw;
2247 
2248  u32 imask = sky2_read32(hw, B0_IMSK);
2249  if (enable)
2250  imask |= portirq_msk[sky2->port];
2251  else
2252  imask &= ~portirq_msk[sky2->port];
2253  sky2_write32(hw, B0_IMSK, imask);
2254 }
2255 
2257  .open = sky2_up,
2258  .close = sky2_down,
2259  .transmit = sky2_xmit_frame,
2260  .poll = sky2_poll,
2261  .irq = sky2_net_irq
2262 };
2263 
2264 static int sky2_probe(struct pci_device *pdev)
2265 {
2266  struct net_device *dev;
2267  struct sky2_hw *hw;
2268  int err;
2269  char buf1[16] __unused; /* only for debugging */
2270 
2272 
2273  err = -ENOMEM;
2274  hw = zalloc(sizeof(*hw));
2275  if (!hw) {
2276  DBG(PFX "cannot allocate hardware struct\n");
2277  goto err_out;
2278  }
2279 
2280  hw->pdev = pdev;
2281 
2282  hw->regs = (unsigned long)pci_ioremap(pdev, pci_bar_start(pdev, PCI_BASE_ADDRESS_0), 0x4000);
2283  if (!hw->regs) {
2284  DBG(PFX "cannot map device registers\n");
2285  goto err_out_free_hw;
2286  }
2287 
2288  /* ring for status responses */
2290  if (!hw->st_le)
2291  goto err_out_iounmap;
2292  hw->st_dma = virt_to_bus(hw->st_le);
2293  memset(hw->st_le, 0, STATUS_LE_BYTES);
2294 
2295  err = sky2_init(hw);
2296  if (err)
2297  goto err_out_iounmap;
2298 
2299 #if DBGLVL_MAX
2300  DBG2(PFX "Yukon-2 %s chip revision %d\n",
2301  sky2_name(hw->chip_id, buf1, sizeof(buf1)), hw->chip_rev);
2302 #endif
2303 
2304  sky2_reset(hw);
2305 
2306  dev = sky2_init_netdev(hw, 0);
2307  if (!dev) {
2308  err = -ENOMEM;
2309  goto err_out_free_pci;
2310  }
2311 
2313 
2314  err = register_netdev(dev);
2315  if (err) {
2316  DBG(PFX "cannot register net device\n");
2317  goto err_out_free_netdev;
2318  }
2319 
2321 
2323 
2324  if (hw->ports > 1) {
2325  struct net_device *dev1;
2326 
2327  dev1 = sky2_init_netdev(hw, 1);
2328  if (!dev1)
2329  DBG(PFX "allocation for second device failed\n");
2330  else if ((err = register_netdev(dev1))) {
2331  DBG(PFX "register of second port failed (%d)\n", err);
2332  hw->dev[1] = NULL;
2333  netdev_nullify(dev1);
2334  netdev_put(dev1);
2335  } else
2336  sky2_show_addr(dev1);
2337  }
2338 
2339  pci_set_drvdata(pdev, hw);
2340 
2341  return 0;
2342 
2343 err_out_free_netdev:
2345  netdev_put(dev);
2346 err_out_free_pci:
2348  free_phys(hw->st_le, STATUS_LE_BYTES);
2349 err_out_iounmap:
2350  iounmap((void *)hw->regs);
2351 err_out_free_hw:
2352  free(hw);
2353 err_out:
2354  pci_set_drvdata(pdev, NULL);
2355  return err;
2356 }
2357 
2358 static void sky2_remove(struct pci_device *pdev)
2359 {
2360  struct sky2_hw *hw = pci_get_drvdata(pdev);
2361  int i;
2362 
2363  if (!hw)
2364  return;
2365 
2366  for (i = hw->ports-1; i >= 0; --i)
2367  unregister_netdev(hw->dev[i]);
2368 
2369  sky2_write32(hw, B0_IMSK, 0);
2370 
2371  sky2_power_aux(hw);
2372 
2375  sky2_read8(hw, B0_CTST);
2376 
2377  free_phys(hw->st_le, STATUS_LE_BYTES);
2378 
2379  for (i = hw->ports-1; i >= 0; --i) {
2380  netdev_nullify(hw->dev[i]);
2381  netdev_put(hw->dev[i]);
2382  }
2383 
2384  iounmap((void *)hw->regs);
2385  free(hw);
2386 
2388 }
2389 
2390 struct pci_driver sky2_driver __pci_driver = {
2391  .ids = sky2_id_table,
2392  .id_count = (sizeof (sky2_id_table) / sizeof (sky2_id_table[0])),
2393  .probe = sky2_probe,
2394  .remove = sky2_remove
2395 };
#define SPEED_1000
Definition: atl1e.h:52
u32 rx_le_map
Definition: sky2.h:2056
uint16_t u16
Definition: stdint.h:21
#define LPA_PAUSE_CAP
Definition: mii.h:106
Definition: skge.h:108
#define EINVAL
Invalid argument.
Definition: errno.h:428
u16 length
Definition: sky2.h:9
#define PHY_M_POLC_LS1_P_MIX(x)
Definition: sky2.h:1346
static u16 sky2_read16(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2101
#define PFX
Definition: sky2.c:47
Definition: skge.h:523
static void sky2_free_rings(struct sky2_port *sky2)
Definition: sky2.c:1114
const char * name
Definition: ath9k_hw.c:1984
struct sky2_hw * hw
Definition: sky2.h:2040
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition: netdevice.h:766
#define SKY2_HW_NEWER_PHY
Definition: sky2.h:2074
static void sky2_rx_update(struct sky2_port *sky2, unsigned rxq)
Definition: sky2.c:1035
wmb()
static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
Definition: sky2.c:159
static struct sky2_tx_le * get_tx_le(struct sky2_port *sky2)
Definition: sky2.c:869
#define iob_put(iobuf, len)
Definition: iobuf.h:124
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
#define IPG_DATA_DEF
Definition: skge.h:1858
u8 chip_rev
Definition: sky2.h:2081
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
A PCI driver.
Definition: pci.h:251
#define EBUSY
Device or resource busy.
Definition: errno.h:338
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
Definition: skge.h:2607
#define PHY_M_PC_DSC(x)
Definition: sky2.h:1304
static u32 sky2_supported_modes(const struct sky2_hw *hw)
Definition: sky2.c:2134
static const u16 copper_fc_adv[]
Definition: sky2.c:274
static unsigned int unsigned int reg
Definition: myson.h:162
#define GM_SMI_CT_PHY_AD(x)
Definition: skge.h:1869
void __asmcall int val
Definition: setjmp.h:12
#define PHY_M_LED_MO_RX(x)
Definition: skge.h:1567
#define SUPPORTED_1000baseT_Half
Definition: skge.h:62
static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:1786
Definition: sky2.h:2036
#define le32_to_cpu(value)
Definition: byteswap.h:113
int(* open)(struct net_device *netdev)
Open network device.
Definition: netdevice.h:222
int pci_find_capability(struct pci_device *pci, int cap)
Look for a PCI capability.
Definition: pciextra.c:38
#define SKY2_HW_ADV_POWER_CTL
Definition: sky2.h:2078
uint8_t opcode
Opcode.
Definition: ena.h:16
#define RX_PENDING
Definition: sky2.c:65
Definition: skge.h:334
#define RX_LE_BYTES
Definition: sky2.c:63
uint16_t spec
ENA specification version.
Definition: ena.h:26
static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
Definition: sky2.c:1463
static const u32 portirq_msk[]
Definition: sky2.c:127
UINT8_t filter
Receive packet filter.
Definition: pxe_api.h:68
Error codes.
#define SUPPORTED_Autoneg
Definition: skge.h:64
Definition: sky2.h:642
#define TX_COL_THR(x)
Definition: skge.h:1818
u8 ctrl
Definition: sky2.h:2009
Definition: skge.h:562
Definition: sky2.h:637
I/O buffers.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:152
static struct tx_ring_info * tx_le_re(struct sky2_port *sky2, struct sky2_tx_le *le)
Definition: sky2.c:889
struct pci_device_id * ids
PCI ID table.
Definition: pci.h:253
#define ADVERTISED_100baseT_Half
Definition: bnx2.h:44
static u32 sky2_pci_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2157
struct arbelprm_completion_with_error error
Definition: arbel.h:12
uint16_t size
Buffer size.
Definition: dwmac.h:14
#define SUPPORTED_100baseT_Full
Definition: skge.h:61
#define TX_BACK_OFF_LIM(x)
Definition: sky2.h:1657
static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:1512
static u16 sky2_pci_read16(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2162
char name[40]
Name.
Definition: device.h:78
#define TX_PENDING
Definition: sky2.c:68
u8 opcode
Definition: sky2.h:2003
#define AUTONEG_ENABLE
Definition: bnx2.h:4584
static void sky2_net_irq(struct net_device *dev, int enable)
Definition: sky2.c:2243
static void sky2_tx_clean(struct net_device *dev)
Definition: sky2.c:1305
#define PCI_BASE_ADDRESS_0
Definition: pci.h:62
Definition: sky2.h:2034
static const u16 gm_fc_disable[]
Definition: sky2.c:290
#define PHY_M_LEDC_INIT_CTRL(x)
Definition: skge.h:1670
static void sky2_link_down(struct sky2_port *sky2)
Definition: sky2.c:1441
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
static void sky2_remove(struct pci_device *pdev)
Definition: sky2.c:2358
u16 rx_put
Definition: sky2.h:2053
static void sky2_status_intr(struct sky2_hw *hw, u16 idx)
Definition: sky2.c:1644
uint8_t head
Head number.
Definition: int13.h:34
u16 length
Definition: sky2.h:2008
static u32 sky2_mhz(const struct sky2_hw *hw)
Definition: sky2.c:1886
#define SPEED_10
Definition: atl1e.h:50
static void sky2_err_intr(struct sky2_hw *hw, u32 status)
Definition: sky2.c:1829
#define PHY_M_MAC_MODE_SEL(x)
Definition: sky2.h:1472
#define RING_NEXT(x, s)
Definition: sky2.c:80
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2096
#define PHY_RETRIES
Definition: sky2.c:75
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:240
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:130
static void sky2_rx_clean(struct sky2_port *sky2)
Definition: sky2.c:991
static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:684
struct pci_device * pdev
Definition: sky2.h:2068
static const char * netdev_addr(struct net_device *netdev)
Get printable network device link-layer address.
Definition: netdevice.h:541
Definition: sky2.h:634
Definition: hw.c:16
static const unsigned txqaddr[]
Definition: sky2.c:125
#define PHY_M_FELP_LED2_CTRL(x)
Definition: skge.h:1630
u16 speed
Definition: sky2.h:2059
#define SUPPORTED_10baseT_Half
Definition: skge.h:58
struct sky2_tx_le * tx_le
Definition: sky2.h:2045
static void sky2_rx_submit(struct sky2_port *sky2, const struct rx_ring_info *re)
Definition: sky2.c:927
static struct io_buffer * receive_new(struct sky2_port *sky2, struct rx_ring_info *re, unsigned int length)
Definition: sky2.c:1546
static u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk)
Definition: sky2.c:1916
static int sky2_probe(struct pci_device *pdev)
Definition: sky2.c:2264
static struct pci_device_id sky2_id_table[]
Definition: sky2.c:82
Dynamic memory allocation.
#define ADVERTISED_1000baseT_Half
Definition: bnx2.h:46
#define RB_ADDR(offs, queue)
Definition: skge.h:590
#define PHY_M_POLC_STA0_CTRL(x)
Definition: sky2.h:1351
uint32_t start
Starting offset.
Definition: netvsc.h:12
#define PCI_ERR_UNCOR_STATUS
Uncorrectable error status.
Definition: pci.h:125
static void sky2_rx_add(struct sky2_port *sky2, u8 op, u32 map, unsigned len)
Definition: sky2.c:915
#define SPEED_100
Definition: atl1e.h:51
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:518
char * strncpy(char *dest, const char *src, size_t max)
Copy string.
Definition: string.c:360
static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
Definition: sky2.c:1282
#define TX_JAM_IPG_VAL(x)
Definition: skge.h:1841
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:365
u16 tx_cons
Definition: sky2.h:2046
#define rmb()
Definition: io.h:544
#define ENOMEM
Not enough space.
Definition: errno.h:534
u8 duplex
Definition: sky2.h:2061
static void sky2_pci_write16(struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2172
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define GM_GPCR_SPEED_1000
Definition: skge.h:1807
Definition: skge.h:82
#define PHY_M_EC_DSC_2(x)
Definition: sky2.h:1291
Definition: skge.h:542
u8 port
Port number.
Definition: CIB_PRM.h:31
static const u16 fiber_fc_adv[]
Definition: sky2.c:282
static void sky2_set_multicast(struct net_device *dev)
Definition: sky2.c:2154
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
static void sky2_prefetch_init(struct sky2_hw *hw, u32 qaddr, u64 addr, u32 last)
Definition: sky2.c:856
#define ETH_HLEN
Definition: if_ether.h:9
Definition: skge.h:559
static struct sky2_rx_le * sky2_next_rx(struct sky2_port *sky2)
Definition: sky2.c:905
static void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx)
Definition: sky2.c:896
#define PHY_M_LEDC_STA0_CTRL(x)
Definition: skge.h:1672
#define PHY_M_LED_BLINK_RT(x)
Definition: skge.h:1528
static struct io_buffer * sky2_rx_alloc(struct sky2_port *sky2)
Definition: sky2.c:1009
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:575
Ethernet protocol.
struct net_device * netdev
Definition: sky2.h:2041
Definition: sky2.h:640
#define PHY_M_EC_M_DSC(x)
Definition: skge.h:1504
#define PCI_STATUS_ERROR_BITS
Definition: skge.h:70
#define ETH_FRAME_LEN
Definition: if_ether.h:11
void * priv
Driver private data.
Definition: netdevice.h:431
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:788
ring len
Length.
Definition: dwmac.h:231
#define GMAC_DEF_MSK
Definition: skge.h:2021
u32 addr
Definition: sky2.h:2000
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
u16 rx_data_size
Definition: sky2.h:2054
#define PHY_M_FELP_LED1_CTRL(x)
Definition: skge.h:1631
Definition: skge.h:558
#define PHY_M_EC_S_DSC(x)
Definition: skge.h:1505
#define DUPLEX_FULL
Definition: bnx2.h:111
uint64_t u64
Definition: stdint.h:25
#define RX_LE_SIZE
Definition: sky2.c:62
static int sky2_up(struct net_device *dev)
Definition: sky2.c:1130
struct tx_ring_info * tx_ring
Definition: sky2.h:2044
static unsigned int count
Number of entries.
Definition: dwmac.h:225
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition: pci.c:96
Definition: skge.h:541
#define TX_RING_SIZE
Definition: sky2.c:67
static struct tulip_private * tp
Definition: tulip.c:442
#define SUPPORTED_TP
Definition: skge.h:65
u8 autoneg
Definition: sky2.h:2060
#define Y2_QADDR(q, reg)
Definition: sky2.h:679
#define TX_IPG_JAM_DATA(x)
Definition: skge.h:1842
static void sky2_set_tx_stfwd(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:670
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
static void sky2_poll(struct net_device *dev)
Definition: sky2.c:1855
#define DBGIO(...)
Definition: compiler.h:549
#define cpu_to_le32(value)
Definition: byteswap.h:107
struct rx_ring_info * rx_ring
Definition: sky2.h:2049
static void sky2_rx_stop(struct sky2_port *sky2)
Definition: sky2.c:967
static void sky2_power_on(struct sky2_hw *hw)
Definition: sky2.c:194
#define ADVERTISE_PAUSE_ASYM
Definition: mii.h:84
u8 ctrl
Definition: sky2.h:2002
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#define LPA_PAUSE_ASYM
Definition: mii.h:107
Definition: sky2.h:893
#define PHY_M_POLC_IS0_P_MIX(x)
Definition: sky2.h:1347
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:661
#define IPG_DATA_VAL(x)
Definition: skge.h:1857
static int tx_dist(unsigned tail, unsigned head)
Definition: sky2.c:1221
static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:298
PCI bus.
#define PHY_M_LED_PULS_DUR(x)
Definition: skge.h:1527
#define SKY2_HW_GIGABIT
Definition: sky2.h:2073
A PCI device.
Definition: pci.h:210
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:159
static struct net_device * sky2_init_netdev(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:2180
uint32_t addr
Buffer address.
Definition: dwmac.h:20
static void sky2_rx_map_iob(struct pci_device *pdev __unused, struct rx_ring_info *re, unsigned size __unused)
Definition: sky2.c:934
#define EOPNOTSUPP
Operation not supported on socket.
Definition: errno.h:604
u16 rx_next
Definition: sky2.h:2052
A network device.
Definition: netdevice.h:352
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2116
static void sky2_reset(struct sky2_hw *hw)
Definition: sky2.c:2002
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:531
#define TX_JAM_LEN_VAL(x)
Definition: skge.h:1840
static int sky2_is_copper(const struct sky2_hw *hw)
Definition: sky2.h:2090
Definition: sky2.h:192
#define SK_REG(port, reg)
Definition: skge.h:2548
Definition: sky2.h:771
static void rx_set_checksum(struct sky2_port *sky2)
Definition: sky2.c:944
static void sky2_tx_done(struct net_device *dev, u16 last)
Definition: sky2.c:1636
u8 opcode
Definition: sky2.h:2010
#define PCI_STATUS
PCI status.
Definition: pci.h:35
#define SUPPORTED_10baseT_Full
Definition: skge.h:59
#define PHY_M_POLC_LOS_CTRL(x)
Definition: sky2.h:1348
#define ETH_ALEN
Definition: if_ether.h:8
A PCI device ID list entry.
Definition: pci.h:174
#define SUPPORTED_100baseT_Half
Definition: skge.h:60
#define le16_to_cpu(value)
Definition: byteswap.h:112
Definition: skge.h:78
static void sky2_down(struct net_device *dev)
Definition: sky2.c:1313
static void sky2_show_addr(struct net_device *dev)
Definition: sky2.c:2215
Definition: skge.h:539
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39
#define PCI_CAP_ID_EXP
PCI Express.
Definition: pci.h:97
#define ETH_DATA_ALIGN
Definition: if_ether.h:12
FILE_LICENCE(GPL2_ONLY)
struct pci_driver sky2_driver __pci_driver
Definition: sky2.c:2390
uint8_t status
Status.
Definition: ena.h:16
u8 chip_id
Definition: sky2.h:2080
Network device operations.
Definition: netdevice.h:213
#define SKY2_HW_AUTO_TX_SUM
Definition: sky2.h:2077
Definition: sky2.h:638
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:548
unsigned long flags
Definition: sky2.h:2070
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
enum flow_control flow_mode
Definition: sky2.h:2062
#define PHY_M_FELP_LED0_CTRL(x)
Definition: skge.h:1632
A Fibre Channel name.
Definition: fc.h:29
static void sky2_le_error(struct sky2_hw *hw, unsigned port, u16 q, unsigned ring_size __unused)
Definition: sky2.c:1809
u32 data_addr
Definition: sky2.h:2028
static int sky2_init(struct sky2_hw *hw)
Definition: sky2.c:1921
#define STATUS_LE_BYTES
Definition: sky2.c:73
struct io_buffer * iob
Definition: sky2.h:2027
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:375
#define SKY2_HW_RAM_BUFFER
Definition: sky2.h:2075
#define SK_RI_TO_53
Definition: skge.h:442
#define PHY_M_LEDC_STA1_CTRL(x)
Definition: skge.h:1671
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
Definition: skge.h:2596
#define iob_reserve(iobuf, len)
Definition: iobuf.h:71
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define STATUS_RING_SIZE
Definition: sky2.c:72
Definition: sky2.h:2066
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
static int sky2_xmit_frame(struct net_device *dev, struct io_buffer *iob)
Definition: sky2.c:1239
static __always_inline int struct dma_mapping * map
Definition: dma.h:183
u16 length
Definition: sky2.h:2015
Definition: skge.h:561
static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:596
unsigned port
Definition: sky2.h:2042
Media Independent Interface constants.
int(* probe)(struct pci_device *pci)
Probe device.
Definition: pci.h:264
#define TX_COL_DEF
Definition: skge.h:1819
Definition: sky2.h:2035
static u16 sky2_phy_speed(const struct sky2_hw *hw, u16 aux)
Definition: sky2.c:1388
static const u32 coma_mode[]
Definition: sky2.c:594
static const u32 phy_power[]
Definition: sky2.c:593
u32 status
Definition: sky2.h:2014
#define TX_RING_ALIGN
Definition: sky2.c:69
Definition: skge.h:496
void * data
Start of data.
Definition: iobuf.h:52
#define PHY_M_POLC_STA1_CTRL(x)
Definition: sky2.h:1350
#define EIO
Input/output error.
Definition: errno.h:433
#define DATA_BLIND_DEF
Definition: skge.h:1855
#define SUPPORTED_FIBRE
Definition: skge.h:66
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.c:722
u16 tx_prod
Definition: sky2.h:2047
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition: wpa.h:234
#define Q_ADDR(reg, offs)
Definition: skge.h:534
uint8_t ctrl
Ring control.
Definition: dwmac.h:18
#define cpu_to_le16(value)
Definition: byteswap.h:106
Definition: skge.h:128
uint32_t end
Ending offset.
Definition: netvsc.h:18
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
void iounmap(volatile const void *io_addr)
Unmap I/O address.
static void sky2_link_up(struct sky2_port *sky2)
Definition: sky2.c:1410
struct sky2_rx_le * rx_le
Definition: sky2.h:2050
#define SUPPORTED_1000baseT_Full
Definition: skge.h:63
#define ADVERTISED_10baseT_Full
Definition: bnx2.h:43
struct io_buffer * iob
Definition: sky2.h:2021
u32 addr
Definition: sky2.h:2007
Definition: sky2.h:1946
static struct net_device_operations sky2_operations
Definition: sky2.c:2256
#define GM_SMI_CT_REG_AD(x)
Definition: skge.h:1870
#define AUTONEG_DISABLE
Definition: bnx2.h:4583
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:256
u16 length
Definition: sky2.h:2001
#define RX_RING_ALIGN
Definition: sky2.c:64
#define PHY_M_EC_MAC_S(x)
Definition: skge.h:1506
void mb(void)
Memory barrier.
static struct io_buffer * sky2_receive(struct net_device *dev, u16 length, u32 status)
Definition: sky2.c:1571
#define ADVERTISE_PAUSE_CAP
Definition: mii.h:83
u16 advertising
Definition: sky2.h:2058
#define DATA_BLIND_VAL(x)
Definition: skge.h:1854
Definition: sky2.h:432
#define STATUS_RING_ALIGN
Definition: sky2.c:74
static void tx_init(struct sky2_port *sky2)
Definition: sky2.c:878
static void gma_set_addr(struct skge_hw *hw, int port, int reg, const u8 *addr)
Definition: skge.h:2612
#define SKY2_HW_FIBRE_PHY
Definition: sky2.h:2072
static void sky2_qset(struct sky2_hw *hw, u16 q)
Definition: sky2.c:845
#define PHY_M_LEDC_LOS_CTRL(x)
Definition: skge.h:1669
#define RAM_BUFFER(port, reg)
Definition: sky2.h:245
static int sky2_rx_start(struct sky2_port *sky2)
Definition: sky2.c:1046
struct net_device * dev[2]
Definition: sky2.h:2069
#define PHY_M_PC_MDI_XMODE(x)
Definition: sky2.h:1185
static int tx_avail(const struct sky2_port *sky2)
Definition: sky2.c:1227
static void sky2_hw_intr(struct sky2_hw *hw)
Definition: sky2.c:1743
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define GM_GPCR_AU_ALL_DIS
Definition: skge.h:1808
static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status)
Definition: sky2.c:1710
static u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2106
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
static void sky2_power_aux(struct sky2_hw *hw)
Definition: sky2.c:238
#define PHY_M_LED_MO_100(x)
Definition: skge.h:1565
static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:617
#define ADVERTISED_1000baseT_Full
Definition: bnx2.h:47
static const unsigned rxqaddr[]
Definition: sky2.c:126
static u32 sky2_us2clk(const struct sky2_hw *hw, u32 us)
Definition: sky2.c:1911
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
Definition: skge.h:557
#define ADVERTISED_100baseT_Full
Definition: bnx2.h:45
static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
Definition: sky2.c:132
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
String functions.
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:307
static void sky2_pci_write32(struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2167
u32 tx_le_map
Definition: sky2.h:2057
struct bofm_section_header done
Definition: bofm_test.c:46
#define ADVERTISED_10baseT_Half
Definition: bnx2.h:42
uint8_t u8
Definition: stdint.h:19
Definition: sky2.h:2033
uint32_t u32
Definition: stdint.h:23
#define CFG_DUAL_MAC_MSK
Definition: sky2.h:525
Definition: skge.h:101
#define PHY_M_POLC_INIT_CTRL(x)
Definition: sky2.h:1349
Definition: skge.h:540
static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space)
Definition: sky2.c:805
Definition: skge.h:560
enum flow_control flow_status
Definition: sky2.h:2063
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.c:706
#define DBG2(...)
Definition: compiler.h:515
if(natsemi->flags &NATSEMI_64BIT) return 1
#define SKY2_HW_NEW_LE
Definition: sky2.h:2076
#define DUPLEX_HALF
Definition: bnx2.h:110
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:37
Definition: skge.h:550
static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
Definition: sky2.c:186