iPXE
Macros | Functions | Variables
sky2.c File Reference
#include <stdint.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/iobuf.h>
#include <ipxe/malloc.h>
#include <ipxe/pci.h>
#include <byteswap.h>
#include <mii.h>
#include "sky2.h"

Go to the source code of this file.

Macros

#define DRV_NAME   "sky2"
 
#define DRV_VERSION   "1.22"
 
#define PFX   DRV_NAME " "
 
#define RX_LE_SIZE   128
 
#define RX_LE_BYTES   (RX_LE_SIZE*sizeof(struct sky2_rx_le))
 
#define RX_RING_ALIGN   4096
 
#define RX_PENDING   (RX_LE_SIZE/6 - 2)
 
#define TX_RING_SIZE   128
 
#define TX_PENDING   (TX_RING_SIZE - 1)
 
#define TX_RING_ALIGN   4096
 
#define MAX_SKB_TX_LE   4
 
#define STATUS_RING_SIZE   512 /* 2 ports * (TX + RX) */
 
#define STATUS_LE_BYTES   (STATUS_RING_SIZE*sizeof(struct sky2_status_le))
 
#define STATUS_RING_ALIGN   4096
 
#define PHY_RETRIES   1000
 
#define SKY2_EEPROM_MAGIC   0x9955aabb
 
#define RING_NEXT(x, s)   (((x)+1) & ((s)-1))
 

Functions

 FILE_LICENCE (GPL2_ONLY)
 
static void sky2_set_multicast (struct net_device *dev)
 
static int gm_phy_write (struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
 
static int __gm_phy_read (struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
 
static u16 gm_phy_read (struct sky2_hw *hw, unsigned port, u16 reg)
 
static void sky2_power_on (struct sky2_hw *hw)
 
static void sky2_power_aux (struct sky2_hw *hw)
 
static void sky2_gmac_reset (struct sky2_hw *hw, unsigned port)
 
static void sky2_phy_init (struct sky2_hw *hw, unsigned port)
 
static void sky2_phy_power_up (struct sky2_hw *hw, unsigned port)
 
static void sky2_phy_power_down (struct sky2_hw *hw, unsigned port)
 
static void sky2_set_tx_stfwd (struct sky2_hw *hw, unsigned port)
 
static void sky2_mac_init (struct sky2_hw *hw, unsigned port)
 
static void sky2_ramset (struct sky2_hw *hw, u16 q, u32 start, u32 space)
 
static void sky2_qset (struct sky2_hw *hw, u16 q)
 
static void sky2_prefetch_init (struct sky2_hw *hw, u32 qaddr, u64 addr, u32 last)
 
static struct sky2_tx_leget_tx_le (struct sky2_port *sky2)
 
static void tx_init (struct sky2_port *sky2)
 
static struct tx_ring_infotx_le_re (struct sky2_port *sky2, struct sky2_tx_le *le)
 
static void sky2_put_idx (struct sky2_hw *hw, unsigned q, u16 idx)
 
static struct sky2_rx_lesky2_next_rx (struct sky2_port *sky2)
 
static void sky2_rx_add (struct sky2_port *sky2, u8 op, u32 map, unsigned len)
 
static void sky2_rx_submit (struct sky2_port *sky2, const struct rx_ring_info *re)
 
static void sky2_rx_map_iob (struct pci_device *pdev __unused, struct rx_ring_info *re, unsigned size __unused)
 
static void rx_set_checksum (struct sky2_port *sky2)
 
static void sky2_rx_stop (struct sky2_port *sky2)
 
static void sky2_rx_clean (struct sky2_port *sky2)
 
static struct io_buffersky2_rx_alloc (struct sky2_port *sky2)
 
static void sky2_rx_update (struct sky2_port *sky2, unsigned rxq)
 
static int sky2_rx_start (struct sky2_port *sky2)
 
static void sky2_free_rings (struct sky2_port *sky2)
 
static int sky2_up (struct net_device *dev)
 
static int tx_dist (unsigned tail, unsigned head)
 
static int tx_avail (const struct sky2_port *sky2)
 
static int sky2_xmit_frame (struct net_device *dev, struct io_buffer *iob)
 
static void sky2_tx_complete (struct sky2_port *sky2, u16 done)
 
static void sky2_tx_clean (struct net_device *dev)
 
static void sky2_down (struct net_device *dev)
 
static u16 sky2_phy_speed (const struct sky2_hw *hw, u16 aux)
 
static void sky2_link_up (struct sky2_port *sky2)
 
static void sky2_link_down (struct sky2_port *sky2)
 
static int sky2_autoneg_done (struct sky2_port *sky2, u16 aux)
 
static void sky2_phy_intr (struct sky2_hw *hw, unsigned port)
 
static struct io_bufferreceive_new (struct sky2_port *sky2, struct rx_ring_info *re, unsigned int length)
 
static struct io_buffersky2_receive (struct net_device *dev, u16 length, u32 status)
 
static void sky2_tx_done (struct net_device *dev, u16 last)
 
static void sky2_status_intr (struct sky2_hw *hw, u16 idx)
 
static void sky2_hw_error (struct sky2_hw *hw, unsigned port, u32 status)
 
static void sky2_hw_intr (struct sky2_hw *hw)
 
static void sky2_mac_intr (struct sky2_hw *hw, unsigned port)
 
static void sky2_le_error (struct sky2_hw *hw, unsigned port, u16 q, unsigned ring_size __unused)
 
static void sky2_err_intr (struct sky2_hw *hw, u32 status)
 
static void sky2_poll (struct net_device *dev)
 
static u32 sky2_mhz (const struct sky2_hw *hw)
 
static u32 sky2_us2clk (const struct sky2_hw *hw, u32 us)
 
static u32 sky2_clk2us (const struct sky2_hw *hw, u32 clk)
 
static int sky2_init (struct sky2_hw *hw)
 
static void sky2_reset (struct sky2_hw *hw)
 
static u32 sky2_supported_modes (const struct sky2_hw *hw)
 
static struct net_devicesky2_init_netdev (struct sky2_hw *hw, unsigned port)
 
static void sky2_show_addr (struct net_device *dev)
 
static void sky2_net_irq (struct net_device *dev, int enable)
 
static int sky2_probe (struct pci_device *pdev)
 
static void sky2_remove (struct pci_device *pdev)
 

Variables

static struct pci_device_id sky2_id_table []
 
static const unsigned txqaddr [] = { Q_XA1, Q_XA2 }
 
static const unsigned rxqaddr [] = { Q_R1, Q_R2 }
 
static const u32 portirq_msk [] = { Y2_IS_PORT_1, Y2_IS_PORT_2 }
 
static const u16 copper_fc_adv []
 
static const u16 fiber_fc_adv []
 
static const u16 gm_fc_disable []
 
static const u32 phy_power [] = { PCI_Y2_PHY1_POWD, PCI_Y2_PHY2_POWD }
 
static const u32 coma_mode [] = { PCI_Y2_PHY1_COMA, PCI_Y2_PHY2_COMA }
 
static struct net_device_operations sky2_operations
 
struct pci_driver sky2_driver __pci_driver
 

Macro Definition Documentation

◆ DRV_NAME

#define DRV_NAME   "sky2"

Definition at line 44 of file sky2.c.

◆ DRV_VERSION

#define DRV_VERSION   "1.22"

Definition at line 45 of file sky2.c.

◆ PFX

#define PFX   DRV_NAME " "

Definition at line 46 of file sky2.c.

◆ RX_LE_SIZE

#define RX_LE_SIZE   128

Definition at line 61 of file sky2.c.

◆ RX_LE_BYTES

#define RX_LE_BYTES   (RX_LE_SIZE*sizeof(struct sky2_rx_le))

Definition at line 62 of file sky2.c.

◆ RX_RING_ALIGN

#define RX_RING_ALIGN   4096

Definition at line 63 of file sky2.c.

◆ RX_PENDING

#define RX_PENDING   (RX_LE_SIZE/6 - 2)

Definition at line 64 of file sky2.c.

◆ TX_RING_SIZE

#define TX_RING_SIZE   128

Definition at line 66 of file sky2.c.

◆ TX_PENDING

#define TX_PENDING   (TX_RING_SIZE - 1)

Definition at line 67 of file sky2.c.

◆ TX_RING_ALIGN

#define TX_RING_ALIGN   4096

Definition at line 68 of file sky2.c.

◆ MAX_SKB_TX_LE

#define MAX_SKB_TX_LE   4

Definition at line 69 of file sky2.c.

◆ STATUS_RING_SIZE

#define STATUS_RING_SIZE   512 /* 2 ports * (TX + RX) */

Definition at line 71 of file sky2.c.

◆ STATUS_LE_BYTES

#define STATUS_LE_BYTES   (STATUS_RING_SIZE*sizeof(struct sky2_status_le))

Definition at line 72 of file sky2.c.

◆ STATUS_RING_ALIGN

#define STATUS_RING_ALIGN   4096

Definition at line 73 of file sky2.c.

◆ PHY_RETRIES

#define PHY_RETRIES   1000

Definition at line 74 of file sky2.c.

◆ SKY2_EEPROM_MAGIC

#define SKY2_EEPROM_MAGIC   0x9955aabb

Definition at line 76 of file sky2.c.

◆ RING_NEXT

#define RING_NEXT (   x,
 
)    (((x)+1) & ((s)-1))

Definition at line 79 of file sky2.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_ONLY  )

◆ sky2_set_multicast()

static void sky2_set_multicast ( struct net_device dev)
static

Definition at line 2153 of file sky2.c.

2154 {
2155  struct sky2_port *sky2 = dev->priv;
2156  struct sky2_hw *hw = sky2->hw;
2157  unsigned port = sky2->port;
2158  u16 reg;
2159  u8 filter[8];
2160 
2162  reg |= GM_RXCR_UCF_ENA;
2163 
2164  memset(filter, 0xff, sizeof(filter));
2165 
2167  (u16) filter[0] | ((u16) filter[1] << 8));
2169  (u16) filter[2] | ((u16) filter[3] << 8));
2171  (u16) filter[4] | ((u16) filter[5] << 8));
2173  (u16) filter[6] | ((u16) filter[7] << 8));
2174 
2176 }
uint16_t u16
Definition: stdint.h:21
struct sky2_hw * hw
Definition: sky2.h:2040
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
Definition: skge.h:2607
static unsigned int unsigned int reg
Definition: myson.h:162
UINT8_t filter
Receive packet filter.
Definition: pxe_api.h:68
Definition: hw.c:16
u8 port
Port number.
Definition: CIB_PRM.h:31
void * priv
Driver private data.
Definition: netdevice.h:431
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
Definition: skge.h:2596
Definition: sky2.h:2066
unsigned port
Definition: sky2.h:2042
uint8_t u8
Definition: stdint.h:19
void * memset(void *dest, int character, size_t len) __nonnull

References filter, GM_MC_ADDR_H1, GM_MC_ADDR_H2, GM_MC_ADDR_H3, GM_MC_ADDR_H4, GM_RX_CTRL, GM_RXCR_UCF_ENA, gma_read16(), gma_write16(), sky2_port::hw, memset(), port, sky2_port::port, net_device::priv, and reg.

Referenced by sky2_up().

◆ gm_phy_write()

static int gm_phy_write ( struct sky2_hw hw,
unsigned  port,
u16  reg,
u16  val 
)
static

Definition at line 131 of file sky2.c.

132 {
133  int i;
134 
138 
139  for (i = 0; i < PHY_RETRIES; i++) {
141  if (ctrl == 0xffff)
142  goto io_error;
143 
144  if (!(ctrl & GM_SMI_CT_BUSY))
145  return 0;
146 
147  udelay(10);
148  }
149 
150  DBG(PFX "%s: phy write timeout\n", hw->dev[port]->name);
151  return -ETIMEDOUT;
152 
153 io_error:
154  DBG(PFX "%s: phy I/O error\n", hw->dev[port]->name);
155  return -EIO;
156 }
uint16_t u16
Definition: stdint.h:21
#define PFX
Definition: sky2.c:46
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
Definition: skge.h:2607
static unsigned int unsigned int reg
Definition: myson.h:162
#define GM_SMI_CT_PHY_AD(x)
Definition: skge.h:1869
#define PHY_RETRIES
Definition: sky2.c:74
Definition: hw.c:16
u8 port
Port number.
Definition: CIB_PRM.h:31
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
void __asmcall int val
Definition: setjmp.h:28
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
Definition: skge.h:2596
#define EIO
Input/output error.
Definition: errno.h:433
u8 ctrl
Definition: sky2.h:10
#define GM_SMI_CT_REG_AD(x)
Definition: skge.h:1870
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669

References ctrl, DBG, EIO, ETIMEDOUT, GM_SMI_CT_BUSY, GM_SMI_CT_PHY_AD, GM_SMI_CT_REG_AD, GM_SMI_CTRL, GM_SMI_DATA, gma_read16(), gma_write16(), PFX, PHY_ADDR_MARV, PHY_RETRIES, port, reg, udelay(), and val.

Referenced by sky2_link_down(), sky2_link_up(), sky2_phy_init(), sky2_phy_power_down(), and sky2_phy_power_up().

◆ __gm_phy_read()

static int __gm_phy_read ( struct sky2_hw hw,
unsigned  port,
u16  reg,
u16 val 
)
static

Definition at line 158 of file sky2.c.

159 {
160  int i;
161 
164 
165  for (i = 0; i < PHY_RETRIES; i++) {
167  if (ctrl == 0xffff)
168  goto io_error;
169 
170  if (ctrl & GM_SMI_CT_RD_VAL) {
172  return 0;
173  }
174 
175  udelay(10);
176  }
177 
178  DBG(PFX "%s: phy read timeout\n", hw->dev[port]->name);
179  return -ETIMEDOUT;
180 io_error:
181  DBG(PFX "%s: phy I/O error\n", hw->dev[port]->name);
182  return -EIO;
183 }
uint16_t u16
Definition: stdint.h:21
#define PFX
Definition: sky2.c:46
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
Definition: skge.h:2607
static unsigned int unsigned int reg
Definition: myson.h:162
#define GM_SMI_CT_PHY_AD(x)
Definition: skge.h:1869
#define PHY_RETRIES
Definition: sky2.c:74
Definition: hw.c:16
u8 port
Port number.
Definition: CIB_PRM.h:31
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
void __asmcall int val
Definition: setjmp.h:28
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
Definition: skge.h:2596
#define EIO
Input/output error.
Definition: errno.h:433
u8 ctrl
Definition: sky2.h:10
#define GM_SMI_CT_REG_AD(x)
Definition: skge.h:1870
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669

References ctrl, DBG, EIO, ETIMEDOUT, GM_SMI_CT_OP_RD, GM_SMI_CT_PHY_AD, GM_SMI_CT_RD_VAL, GM_SMI_CT_REG_AD, GM_SMI_CTRL, GM_SMI_DATA, gma_read16(), gma_write16(), PFX, PHY_ADDR_MARV, PHY_RETRIES, port, reg, udelay(), and val.

Referenced by gm_phy_read().

◆ gm_phy_read()

static u16 gm_phy_read ( struct sky2_hw hw,
unsigned  port,
u16  reg 
)
inlinestatic

Definition at line 185 of file sky2.c.

186 {
187  u16 v = 0;
188  __gm_phy_read(hw, port, reg, &v);
189  return v;
190 }
uint16_t u16
Definition: stdint.h:21
static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
Definition: sky2.c:158
static unsigned int unsigned int reg
Definition: myson.h:162
Definition: hw.c:16
u8 port
Port number.
Definition: CIB_PRM.h:31

References __gm_phy_read(), port, and reg.

Referenced by sky2_autoneg_done(), sky2_mac_init(), sky2_phy_init(), sky2_phy_intr(), and sky2_phy_power_down().

◆ sky2_power_on()

static void sky2_power_on ( struct sky2_hw hw)
static

Definition at line 193 of file sky2.c.

194 {
195  /* switch power to VCC (WA for VAUX problem) */
198 
199  /* disable Core Clock Division, */
201 
202  if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
203  /* enable bits are inverted */
208  else
210 
211  if (hw->flags & SKY2_HW_ADV_POWER_CTL) {
212  u32 reg;
213 
215 
217  /* set all bits to 0 except bits 15..12 and 8 */
220 
222  /* set all bits to 0 except bits 28 & 27 */
225 
227 
228  /* Enable workaround for dev 4.107 on Yukon-Ultra & Extreme */
232 
234  }
235 }
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
static unsigned int unsigned int reg
Definition: myson.h:162
#define SKY2_HW_ADV_POWER_CTL
Definition: sky2.h:2078
static u32 sky2_pci_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2157
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2096
Definition: hw.c:16
Definition: skge.h:128
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
static void sky2_pci_write32(struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2167
uint32_t u32
Definition: stdint.h:23

References B0_POWER_CTRL, B2_GP_IO, B2_Y2_CLK_CTRL, B2_Y2_CLK_GATE, CHIP_ID_YUKON_XL, GLB_GPIO_STAT_RACE_DIS, P_ASPM_CONTROL_MSK, P_CTL_TIM_VMAIN_AV_MSK, PC_VAUX_ENA, PC_VAUX_OFF, PC_VCC_ENA, PC_VCC_ON, PCI_CFG_REG_1, PCI_DEV_REG3, PCI_DEV_REG4, PCI_DEV_REG5, reg, SKY2_HW_ADV_POWER_CTL, sky2_pci_read32(), sky2_pci_write32(), sky2_read32(), sky2_write32(), sky2_write8(), Y2_CLK_DIV_DIS, Y2_CLK_GAT_LNK1_DIS, Y2_CLK_GAT_LNK2_DIS, Y2_COR_CLK_LNK1_DIS, Y2_COR_CLK_LNK2_DIS, Y2_PCI_CLK_LNK1_DIS, and Y2_PCI_CLK_LNK2_DIS.

Referenced by sky2_reset().

◆ sky2_power_aux()

static void sky2_power_aux ( struct sky2_hw hw)
static

Definition at line 237 of file sky2.c.

238 {
239  if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
241  else
242  /* enable bits are inverted */
247 
248  /* switch power to VAUX */
253 }
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2096
Definition: hw.c:16
Definition: skge.h:78
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121

References B0_CTST, B0_POWER_CTRL, B2_Y2_CLK_GATE, CHIP_ID_YUKON_XL, PC_VAUX_ENA, PC_VAUX_ON, PC_VCC_ENA, PC_VCC_OFF, sky2_read32(), sky2_write8(), Y2_CLK_GAT_LNK1_DIS, Y2_CLK_GAT_LNK2_DIS, Y2_COR_CLK_LNK1_DIS, Y2_COR_CLK_LNK2_DIS, Y2_PCI_CLK_LNK1_DIS, Y2_PCI_CLK_LNK2_DIS, and Y2_VAUX_AVAIL.

Referenced by sky2_remove().

◆ sky2_gmac_reset()

static void sky2_gmac_reset ( struct sky2_hw hw,
unsigned  port 
)
static

Definition at line 255 of file sky2.c.

256 {
257  u16 reg;
258 
259  /* disable all GMAC IRQ's */
261 
262  gma_write16(hw, port, GM_MC_ADDR_H1, 0); /* clear MC hash */
266 
270 }
uint16_t u16
Definition: stdint.h:21
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
Definition: skge.h:2607
static unsigned int unsigned int reg
Definition: myson.h:162
Definition: hw.c:16
u8 port
Port number.
Definition: CIB_PRM.h:31
#define SK_REG(port, reg)
Definition: skge.h:2548
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
Definition: skge.h:2596
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121

References GM_MC_ADDR_H1, GM_MC_ADDR_H2, GM_MC_ADDR_H3, GM_MC_ADDR_H4, GM_RX_CTRL, GM_RXCR_MCF_ENA, GM_RXCR_UCF_ENA, gma_read16(), gma_write16(), GMAC_IRQ_MSK, port, reg, SK_REG, and sky2_write8().

Referenced by sky2_down(), and sky2_reset().

◆ sky2_phy_init()

static void sky2_phy_init ( struct sky2_hw hw,
unsigned  port 
)
static

Definition at line 297 of file sky2.c.

298 {
299  struct sky2_port *sky2 = hw->dev[port]->priv;
300  u16 ctrl, ct1000, adv, pg, ledctrl, ledover, reg;
301 
302  if (sky2->autoneg == AUTONEG_ENABLE &&
303  !(hw->flags & SKY2_HW_NEWER_PHY)) {
305 
309 
310  /* on PHY 88E1040 Rev.D0 (and newer) downshift control changed */
311  if (hw->chip_id == CHIP_ID_YUKON_EC)
312  /* set downshift counter to 3x and enable downshift */
313  ectrl |= PHY_M_EC_DSC_2(2) | PHY_M_EC_DOWN_S_ENA;
314  else
315  /* set master & slave downshift counter to 1x */
316  ectrl |= PHY_M_EC_M_DSC(0) | PHY_M_EC_S_DSC(1);
317 
319  }
320 
322  if (sky2_is_copper(hw)) {
323  if (!(hw->flags & SKY2_HW_GIGABIT)) {
324  /* enable automatic crossover */
326 
327  if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
328  hw->chip_rev == CHIP_REV_YU_FE2_A0) {
329  u16 spec;
330 
331  /* Enable Class A driver for FE+ A0 */
335  }
336  } else {
337  /* disable energy detect */
339 
340  /* enable automatic crossover */
342 
343  /* downshift on PHY 88E1112 and 88E1149 is changed */
344  if (sky2->autoneg == AUTONEG_ENABLE
345  && (hw->flags & SKY2_HW_NEWER_PHY)) {
346  /* set downshift counter to 3x and enable downshift */
349  }
350  }
351  } else {
352  /* workaround for deviation #4.88 (CRC errors) */
353  /* disable Automatic Crossover */
354 
356  }
357 
359 
360  /* special setup for PHY 88E1112 Fiber */
361  if (hw->chip_id == CHIP_ID_YUKON_XL && (hw->flags & SKY2_HW_FIBRE_PHY)) {
363 
364  /* Fiber: select 1000BASE-X only mode MAC Specific Ctrl Reg. */
370 
371  if (hw->pmd_type == 'P') {
372  /* select page 1 to access Fiber registers */
374 
375  /* for SFP-module set SIGDET polarity to low */
379  }
380 
382  }
383 
384  ctrl = PHY_CT_RESET;
385  ct1000 = 0;
386  adv = PHY_AN_CSMA;
387  reg = 0;
388 
389  if (sky2->autoneg == AUTONEG_ENABLE) {
390  if (sky2_is_copper(hw)) {
392  ct1000 |= PHY_M_1000C_AFD;
394  ct1000 |= PHY_M_1000C_AHD;
396  adv |= PHY_M_AN_100_FD;
398  adv |= PHY_M_AN_100_HD;
400  adv |= PHY_M_AN_10_FD;
402  adv |= PHY_M_AN_10_HD;
403 
404  adv |= copper_fc_adv[sky2->flow_mode];
405  } else { /* special defines for FIBER (88E1040S only) */
407  adv |= PHY_M_AN_1000X_AFD;
409  adv |= PHY_M_AN_1000X_AHD;
410 
411  adv |= fiber_fc_adv[sky2->flow_mode];
412  }
413 
414  /* Restart Auto-negotiation */
416  } else {
417  /* forced speed/duplex settings */
418  ct1000 = PHY_M_1000C_MSE;
419 
420  /* Disable auto update for duplex flow control and speed */
422 
423  switch (sky2->speed) {
424  case SPEED_1000:
425  ctrl |= PHY_CT_SP1000;
427  break;
428  case SPEED_100:
429  ctrl |= PHY_CT_SP100;
431  break;
432  }
433 
434  if (sky2->duplex == DUPLEX_FULL) {
436  ctrl |= PHY_CT_DUP_MD;
437  } else if (sky2->speed < SPEED_1000)
438  sky2->flow_mode = FC_NONE;
439 
440 
441  reg |= gm_fc_disable[sky2->flow_mode];
442 
443  /* Forward pause packets to GMAC? */
444  if (sky2->flow_mode & FC_RX)
446  else
448  }
449 
451 
452  if (hw->flags & SKY2_HW_GIGABIT)
454 
457 
458  /* Setup Phy LED's */
459  ledctrl = PHY_M_LED_PULS_DUR(PULS_170MS);
460  ledover = 0;
461 
462  switch (hw->chip_id) {
463  case CHIP_ID_YUKON_FE:
464  /* on 88E3082 these bits are at 11..9 (shifted left) */
465  ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) << 1;
466 
468 
469  /* delete ACT LED control bits */
471  /* change ACT LED control to blink mode */
474  break;
475 
476  case CHIP_ID_YUKON_FE_P:
477  /* Enable Link Partner Next Page */
480 
481  /* disable Energy Detect and enable scrambler */
484 
485  /* set LED2 -> ACT, LED1 -> LINK, LED0 -> SPEED */
489 
491  break;
492 
493  case CHIP_ID_YUKON_XL:
495 
496  /* select page 3 to access LED control register */
498 
499  /* set LED Function Control register */
501  (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */
502  PHY_M_LEDC_INIT_CTRL(7) | /* 10 Mbps */
503  PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */
504  PHY_M_LEDC_STA0_CTRL(7))); /* 1000 Mbps */
505 
506  /* set Polarity Control register */
514 
515  /* restore page register */
517  break;
518 
519  case CHIP_ID_YUKON_EC_U:
520  case CHIP_ID_YUKON_EX:
521  case CHIP_ID_YUKON_SUPR:
523 
524  /* select page 3 to access LED control register */
526 
527  /* set LED Function Control register */
529  (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */
530  PHY_M_LEDC_INIT_CTRL(8) | /* 10 Mbps */
531  PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */
532  PHY_M_LEDC_STA0_CTRL(7)));/* 1000 Mbps */
533 
534  /* set Blink Rate in LED Timer Control Register */
536  ledctrl | PHY_M_LED_BLINK_RT(BLINK_84MS));
537  /* restore page register */
539  break;
540 
541  default:
542  /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */
544 
545  /* turn off the Rx LED (LED_RX) */
546  ledover |= PHY_M_LED_MO_RX(MO_LED_OFF);
547  }
548 
549  if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_UL_2) {
550  /* apply fixes in PHY AFE */
552 
553  /* increase differential signal amplitude in 10BASE-T */
554  gm_phy_write(hw, port, 0x18, 0xaa99);
555  gm_phy_write(hw, port, 0x17, 0x2011);
556 
557  if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
558  /* fix for IEEE A/B Symmetry failure in 1000BASE-T */
559  gm_phy_write(hw, port, 0x18, 0xa204);
560  gm_phy_write(hw, port, 0x17, 0x2002);
561  }
562 
563  /* set page register to 0 */
565  } else if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
566  hw->chip_rev == CHIP_REV_YU_FE2_A0) {
567  /* apply workaround for integrated resistors calibration */
570  } else if (hw->chip_id != CHIP_ID_YUKON_EX &&
571  hw->chip_id < CHIP_ID_YUKON_SUPR) {
572  /* no effect on Yukon-XL */
574 
575  if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
576  /* turn on 100 Mbps LED (LED_LINK100) */
577  ledover |= PHY_M_LED_MO_100(MO_LED_ON);
578  }
579 
580  if (ledover)
582 
583  }
584 
585  /* Enable phy interrupt on auto-negotiation complete (or link up) */
586  if (sky2->autoneg == AUTONEG_ENABLE)
588  else
590 }
#define SPEED_1000
Definition: atl1e.h:52
uint16_t u16
Definition: stdint.h:21
#define PHY_M_POLC_LS1_P_MIX(x)
Definition: sky2.h:1346
#define SKY2_HW_NEWER_PHY
Definition: sky2.h:2074
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 const u16 copper_fc_adv[]
Definition: sky2.c:273
static unsigned int unsigned int reg
Definition: myson.h:162
#define PHY_M_LED_MO_RX(x)
Definition: skge.h:1567
uint16_t spec
ENA specification version.
Definition: ena.h:26
#define ADVERTISED_100baseT_Half
Definition: bnx2.h:44
#define AUTONEG_ENABLE
Definition: bnx2.h:4584
static const u16 gm_fc_disable[]
Definition: sky2.c:289
#define PHY_M_LEDC_INIT_CTRL(x)
Definition: skge.h:1670
#define PHY_M_MAC_MODE_SEL(x)
Definition: sky2.h:1472
Definition: hw.c:16
#define PHY_M_FELP_LED2_CTRL(x)
Definition: skge.h:1630
u16 speed
Definition: sky2.h:2059
#define ADVERTISED_1000baseT_Half
Definition: bnx2.h:46
#define PHY_M_POLC_STA0_CTRL(x)
Definition: sky2.h:1351
#define SPEED_100
Definition: atl1e.h:51
u8 duplex
Definition: sky2.h:2061
#define GM_GPCR_SPEED_1000
Definition: skge.h:1807
#define PHY_M_EC_DSC_2(x)
Definition: sky2.h:1291
u8 port
Port number.
Definition: CIB_PRM.h:31
static const u16 fiber_fc_adv[]
Definition: sky2.c:281
#define PHY_M_LEDC_STA0_CTRL(x)
Definition: skge.h:1672
#define PHY_M_LED_BLINK_RT(x)
Definition: skge.h:1528
#define PHY_M_EC_M_DSC(x)
Definition: skge.h:1504
#define PHY_M_FELP_LED1_CTRL(x)
Definition: skge.h:1631
#define PHY_M_EC_S_DSC(x)
Definition: skge.h:1505
#define DUPLEX_FULL
Definition: bnx2.h:111
u8 autoneg
Definition: sky2.h:2060
#define PHY_M_POLC_IS0_P_MIX(x)
Definition: sky2.h:1347
#define PHY_M_LED_PULS_DUR(x)
Definition: skge.h:1527
#define SKY2_HW_GIGABIT
Definition: sky2.h:2073
static int sky2_is_copper(const struct sky2_hw *hw)
Definition: sky2.h:2090
#define SK_REG(port, reg)
Definition: skge.h:2548
#define PHY_M_POLC_LOS_CTRL(x)
Definition: sky2.h:1348
enum flow_control flow_mode
Definition: sky2.h:2062
#define PHY_M_FELP_LED0_CTRL(x)
Definition: skge.h:1632
#define PHY_M_LEDC_STA1_CTRL(x)
Definition: skge.h:1671
Definition: sky2.h:2035
#define PHY_M_POLC_STA1_CTRL(x)
Definition: sky2.h:1350
u8 ctrl
Definition: sky2.h:10
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
#define ADVERTISED_10baseT_Full
Definition: bnx2.h:43
#define AUTONEG_DISABLE
Definition: bnx2.h:4583
#define PHY_M_EC_MAC_S(x)
Definition: skge.h:1506
u16 advertising
Definition: sky2.h:2058
#define SKY2_HW_FIBRE_PHY
Definition: sky2.h:2072
#define PHY_M_LEDC_LOS_CTRL(x)
Definition: skge.h:1669
#define PHY_M_PC_MDI_XMODE(x)
Definition: sky2.h:1185
#define GM_GPCR_AU_ALL_DIS
Definition: skge.h:1808
#define PHY_M_LED_MO_100(x)
Definition: skge.h:1565
#define ADVERTISED_1000baseT_Full
Definition: bnx2.h:47
#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:131
#define ADVERTISED_10baseT_Half
Definition: bnx2.h:42
Definition: sky2.h:2033
#define PHY_M_POLC_INIT_CTRL(x)
Definition: sky2.h:1349
static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
Definition: sky2.c:185

References ADVERTISED_1000baseT_Full, ADVERTISED_1000baseT_Half, ADVERTISED_100baseT_Full, ADVERTISED_100baseT_Half, ADVERTISED_10baseT_Full, ADVERTISED_10baseT_Half, sky2_port::advertising, sky2_port::autoneg, AUTONEG_DISABLE, AUTONEG_ENABLE, BLINK_84MS, CHIP_ID_YUKON_EC, CHIP_ID_YUKON_EC_U, CHIP_ID_YUKON_EX, CHIP_ID_YUKON_FE, CHIP_ID_YUKON_FE_P, CHIP_ID_YUKON_SUPR, CHIP_ID_YUKON_UL_2, CHIP_ID_YUKON_XL, CHIP_REV_YU_FE2_A0, copper_fc_adv, ctrl, sky2_port::duplex, DUPLEX_FULL, FC_NONE, FC_RX, fiber_fc_adv, sky2_port::flow_mode, gm_fc_disable, GM_GP_CTRL, GM_GPCR_AU_ALL_DIS, GM_GPCR_DUP_FULL, GM_GPCR_SPEED_100, GM_GPCR_SPEED_1000, gm_phy_read(), gm_phy_write(), gma_write16(), GMAC_CTRL, GMC_PAUSE_OFF, GMC_PAUSE_ON, LED_PAR_CTRL_ACT_BL, LED_PAR_CTRL_LINK, LED_PAR_CTRL_SPEED, MAC_TX_CLK_25_MHZ, MO_LED_OFF, MO_LED_ON, PHY_AN_CSMA, PHY_CT_ANE, PHY_CT_DUP_MD, PHY_CT_RE_CFG, PHY_CT_RESET, PHY_CT_SP100, PHY_CT_SP1000, PHY_M_1000C_AFD, PHY_M_1000C_AHD, PHY_M_1000C_MSE, PHY_M_AN_1000X_AFD, PHY_M_AN_1000X_AHD, PHY_M_AN_100_FD, PHY_M_AN_100_HD, PHY_M_AN_10_FD, PHY_M_AN_10_HD, PHY_M_DEF_MSK, PHY_M_EC_DOWN_S_ENA, PHY_M_EC_DSC_2, PHY_M_EC_M_DSC, PHY_M_EC_M_DSC_MSK, PHY_M_EC_MAC_S, PHY_M_EC_MAC_S_MSK, PHY_M_EC_S_DSC, PHY_M_EC_S_DSC_MSK, PHY_M_FELP_LED0_CTRL, PHY_M_FELP_LED1_CTRL, PHY_M_FELP_LED1_MSK, PHY_M_FELP_LED2_CTRL, PHY_M_FESC_SEL_CL_A, PHY_M_FIB_SIGD_POL, PHY_M_IS_AN_COMPL, PHY_M_LED_BLINK_RT, PHY_M_LED_MO_100, PHY_M_LED_MO_RX, PHY_M_LED_PULS_DUR, PHY_M_LEDC_INIT_CTRL, PHY_M_LEDC_LOS_CTRL, PHY_M_LEDC_STA0_CTRL, PHY_M_LEDC_STA1_CTRL, PHY_M_LEDC_TX_CTRL, PHY_M_MAC_MD_1000BX, PHY_M_MAC_MD_MSK, PHY_M_MAC_MODE_SEL, PHY_M_PC_DIS_SCRAMB, PHY_M_PC_DOWN_S_ENA, PHY_M_PC_DSC, PHY_M_PC_DSC_MSK, PHY_M_PC_EN_DET_MSK, PHY_M_PC_ENA_AUTO, PHY_M_PC_ENA_ENE_DT, PHY_M_PC_ENA_LIP_NP, PHY_M_PC_MDI_XMODE, PHY_M_PC_MDIX_MSK, PHY_M_POLC_INIT_CTRL, PHY_M_POLC_IS0_P_MIX, PHY_M_POLC_LOS_CTRL, PHY_M_POLC_LS1_P_MIX, PHY_M_POLC_STA0_CTRL, PHY_M_POLC_STA1_CTRL, PHY_MARV_1000T_CTRL, PHY_MARV_AUNE_ADV, PHY_MARV_CTRL, PHY_MARV_EXT_ADR, PHY_MARV_EXT_CTRL, PHY_MARV_FE_LED_PAR, PHY_MARV_FE_SPEC_2, PHY_MARV_INT_MASK, PHY_MARV_LED_CTRL, PHY_MARV_LED_OVER, PHY_MARV_PAGE_ADDR, PHY_MARV_PAGE_DATA, PHY_MARV_PHY_CTRL, PHY_MARV_PHY_STAT, port, PULS_170MS, reg, SK_REG, SKY2_HW_FIBRE_PHY, SKY2_HW_GIGABIT, SKY2_HW_NEWER_PHY, sky2_is_copper(), sky2_write8(), spec, sky2_port::speed, SPEED_100, and SPEED_1000.

Referenced by sky2_link_down(), and sky2_mac_init().

◆ sky2_phy_power_up()

static void sky2_phy_power_up ( struct sky2_hw hw,
unsigned  port 
)
static

Definition at line 595 of file sky2.c.

596 {
597  u32 reg1;
598 
601  reg1 &= ~phy_power[port];
602 
603  if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
604  reg1 |= coma_mode[port];
605 
609 
610  if (hw->chip_id == CHIP_ID_YUKON_FE)
612  else if (hw->flags & SKY2_HW_ADV_POWER_CTL)
614 }
#define SKY2_HW_ADV_POWER_CTL
Definition: sky2.h:2078
static u32 sky2_pci_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2157
Definition: hw.c:16
u8 port
Port number.
Definition: CIB_PRM.h:31
#define SK_REG(port, reg)
Definition: skge.h:2548
static const u32 coma_mode[]
Definition: sky2.c:593
static const u32 phy_power[]
Definition: sky2.c:592
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
Definition: sky2.c:131
static void sky2_pci_write32(struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2167
uint32_t u32
Definition: stdint.h:23

References B2_TST_CTRL1, CHIP_ID_YUKON_FE, CHIP_ID_YUKON_XL, coma_mode, gm_phy_write(), GPC_RST_CLR, GPHY_CTRL, PCI_DEV_REG1, PHY_CT_ANE, PHY_MARV_CTRL, phy_power, port, SK_REG, SKY2_HW_ADV_POWER_CTL, sky2_pci_read32(), sky2_pci_write32(), sky2_write8(), TST_CFG_WRITE_OFF, and TST_CFG_WRITE_ON.

Referenced by sky2_mac_init().

◆ sky2_phy_power_down()

static void sky2_phy_power_down ( struct sky2_hw hw,
unsigned  port 
)
static

Definition at line 616 of file sky2.c.

617 {
618  u32 reg1;
619  u16 ctrl;
620 
621  /* release GPHY Control reset */
623 
624  /* release GMAC reset */
626 
627  if (hw->flags & SKY2_HW_NEWER_PHY) {
628  /* select page 2 to access MAC control register */
630 
632  /* allow GMII Power Down */
635 
636  /* set page register back to 0 */
638  }
639 
640  /* setup General Purpose Control Register */
643 
644  if (hw->chip_id != CHIP_ID_YUKON_EC) {
645  if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
646  /* select page 2 to access MAC control register */
648 
650  /* enable Power Down */
653 
654  /* set page register back to 0 */
656  }
657 
658  /* set IEEE compatible Power Down Mode (dev. #4.99) */
660  }
661 
664  reg1 |= phy_power[port]; /* set PHY to PowerDown/COMA Mode */
667 }
uint16_t u16
Definition: stdint.h:21
#define SKY2_HW_NEWER_PHY
Definition: sky2.h:2074
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
Definition: skge.h:2607
static u32 sky2_pci_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2157
Definition: hw.c:16
u8 port
Port number.
Definition: CIB_PRM.h:31
#define SK_REG(port, reg)
Definition: skge.h:2548
static const u32 phy_power[]
Definition: sky2.c:592
u8 ctrl
Definition: sky2.h:10
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
#define GM_GPCR_AU_ALL_DIS
Definition: skge.h:1808
static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
Definition: sky2.c:131
static void sky2_pci_write32(struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2167
uint32_t u32
Definition: stdint.h:23
static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
Definition: sky2.c:185

References B2_TST_CTRL1, CHIP_ID_YUKON_EC, CHIP_ID_YUKON_EC_U, ctrl, GM_GP_CTRL, GM_GPCR_AU_ALL_DIS, GM_GPCR_FL_PASS, GM_GPCR_SPEED_100, gm_phy_read(), gm_phy_write(), gma_write16(), GMAC_CTRL, GMC_RST_CLR, GPC_RST_CLR, GPHY_CTRL, PCI_DEV_REG1, PHY_CT_PDOWN, PHY_M_MAC_GMIF_PUP, PHY_M_PC_POW_D_ENA, PHY_MARV_CTRL, PHY_MARV_EXT_ADR, PHY_MARV_PHY_CTRL, phy_power, port, SK_REG, SKY2_HW_NEWER_PHY, sky2_pci_read32(), sky2_pci_write32(), sky2_write8(), TST_CFG_WRITE_OFF, and TST_CFG_WRITE_ON.

Referenced by sky2_down().

◆ sky2_set_tx_stfwd()

static void sky2_set_tx_stfwd ( struct sky2_hw hw,
unsigned  port 
)
static

Definition at line 669 of file sky2.c.

670 {
671  if ( (hw->chip_id == CHIP_ID_YUKON_EX &&
672  hw->chip_rev != CHIP_REV_YU_EX_A0) ||
673  hw->chip_id == CHIP_ID_YUKON_FE_P ||
674  hw->chip_id == CHIP_ID_YUKON_SUPR) {
675  /* disable jumbo frames on devices that support them */
678  } else {
680  }
681 }
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
Definition: hw.c:16
u8 port
Port number.
Definition: CIB_PRM.h:31
#define SK_REG(port, reg)
Definition: skge.h:2548

References CHIP_ID_YUKON_EX, CHIP_ID_YUKON_FE_P, CHIP_ID_YUKON_SUPR, CHIP_REV_YU_EX_A0, port, SK_REG, sky2_write32(), TX_GMF_CTRL_T, TX_JUMBO_DIS, and TX_STFW_ENA.

Referenced by sky2_mac_init().

◆ sky2_mac_init()

static void sky2_mac_init ( struct sky2_hw hw,
unsigned  port 
)
static

Definition at line 683 of file sky2.c.

684 {
685  u16 reg;
686  u32 rx_reg;
687  int i;
688  const u8 *addr = hw->dev[port]->ll_addr;
689 
692 
694 
695  if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0 && port == 1) {
696  /* WA DEV_472 -- looks like crossed wires on port 2 */
697  /* clear GMAC 1 Control reset */
699  do {
702  } while (gm_phy_read(hw, 1, PHY_MARV_ID0) != PHY_MARV_ID0_VAL ||
704  gm_phy_read(hw, 1, PHY_MARV_INT_MASK) != 0);
705  }
706 
708 
709  /* Enable Transmit FIFO Underrun */
711 
714 
715  /* MIB clear */
718 
719  for (i = GM_MIB_CNT_BASE; i <= GM_MIB_CNT_END; i += 4)
720  gma_read16(hw, port, i);
722 
723  /* transmit control */
725 
726  /* receive control reg: unicast + multicast + no FCS */
729 
730  /* transmit flow control */
731  gma_write16(hw, port, GM_TX_FLOW_CTRL, 0xffff);
732 
733  /* transmit parameter */
739 
740  /* serial mode register */
743 
745 
746  /* virtual address for data */
748 
749  /* physical address: used for pause frames */
751 
752  /* ignore counter overflows */
756 
757  /* Configure Rx MAC FIFO */
759  rx_reg = GMF_OPER_ON | GMF_RX_F_FL_ON;
760  if (hw->chip_id == CHIP_ID_YUKON_EX ||
761  hw->chip_id == CHIP_ID_YUKON_FE_P)
762  rx_reg |= GMF_RX_OVER_ON;
763 
765 
766  if (hw->chip_id == CHIP_ID_YUKON_XL) {
767  /* Hardware errata - clear flush mask */
769  } else {
770  /* Flush Rx MAC FIFO on any flow control or error */
772  }
773 
774  /* Set threshold to 0xa (64 bytes) + 1 to workaround pause bug */
775  reg = RX_GMF_FL_THR_DEF + 1;
776  /* Another magic mystery workaround from sk98lin */
777  if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
778  hw->chip_rev == CHIP_REV_YU_FE2_A0)
779  reg = 0x178;
781 
782  /* Configure Tx MAC FIFO */
785 
786  /* On chips without ram buffer, pause is controlled by MAC level */
787  if (!(hw->flags & SKY2_HW_RAM_BUFFER)) {
789  sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
790 
792  }
793 
794  if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
795  hw->chip_rev == CHIP_REV_YU_FE2_A0) {
796  /* disable dynamic watermark */
798  reg &= ~TX_DYN_WM_ENA;
800  }
801 }
uint16_t u16
Definition: stdint.h:21
static u16 sky2_read16(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2101
#define IPG_DATA_DEF
Definition: skge.h:1858
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
Definition: skge.h:2607
static unsigned int unsigned int reg
Definition: myson.h:162
#define TX_COL_THR(x)
Definition: skge.h:1818
#define TX_BACK_OFF_LIM(x)
Definition: sky2.h:1657
Definition: hw.c:16
#define TX_JAM_IPG_VAL(x)
Definition: skge.h:1841
u8 port
Port number.
Definition: CIB_PRM.h:31
#define GMAC_DEF_MSK
Definition: skge.h:2021
#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:669
#define IPG_DATA_VAL(x)
Definition: skge.h:1857
static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:297
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2116
#define TX_JAM_LEN_VAL(x)
Definition: skge.h:1840
u32 addr
Definition: sky2.h:8
#define SK_REG(port, reg)
Definition: skge.h:2548
#define SKY2_HW_RAM_BUFFER
Definition: sky2.h:2075
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
Definition: skge.h:2596
static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:595
#define TX_COL_DEF
Definition: skge.h:1819
#define DATA_BLIND_DEF
Definition: skge.h:1855
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
#define DATA_BLIND_VAL(x)
Definition: skge.h:1854
static void gma_set_addr(struct skge_hw *hw, int port, int reg, const u8 *addr)
Definition: skge.h:2612
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
Definition: sky2.c:185

References addr, CHIP_ID_YUKON_EX, CHIP_ID_YUKON_FE_P, CHIP_ID_YUKON_XL, CHIP_REV_YU_FE2_A0, DATA_BLIND_DEF, DATA_BLIND_VAL, GM_MIB_CNT_BASE, GM_MIB_CNT_END, GM_PAR_MIB_CLR, GM_PHY_ADDR, gm_phy_read(), GM_RX_CTRL, GM_RX_IRQ_MSK, GM_RXCR_CRC_DIS, GM_RXCR_MCF_ENA, GM_RXCR_UCF_ENA, GM_SERIAL_MODE, GM_SMOD_VLAN_ENA, GM_SRC_ADDR_1L, GM_SRC_ADDR_2L, GM_TR_IRQ_MSK, GM_TX_CTRL, GM_TX_FLOW_CTRL, GM_TX_IRQ_MSK, GM_TX_PARAM, gma_read16(), gma_set_addr(), gma_write16(), GMAC_CTRL, GMAC_DEF_MSK, GMAC_IRQ_MSK, GMAC_IRQ_SRC, GMC_RST_CLR, GMC_RST_SET, GMF_OPER_ON, GMF_RST_CLR, GMF_RX_F_FL_ON, GMF_RX_OVER_ON, GMR_FS_ANY_ERR, GPC_RST_CLR, GPC_RST_SET, GPHY_CTRL, IPG_DATA_DEF, IPG_DATA_VAL, PHY_MARV_ID0, PHY_MARV_ID0_VAL, PHY_MARV_ID1, PHY_MARV_ID1_Y2, PHY_MARV_INT_MASK, port, reg, RX_GMF_CTRL_T, RX_GMF_FL_MSK, RX_GMF_FL_THR, RX_GMF_FL_THR_DEF, RX_GMF_LP_THR, RX_GMF_UP_THR, SK_REG, SKY2_HW_RAM_BUFFER, sky2_phy_init(), sky2_phy_power_up(), sky2_read16(), sky2_set_tx_stfwd(), sky2_write16(), sky2_write32(), sky2_write8(), TX_BACK_OFF_LIM, TX_BOF_LIM_DEF, TX_COL_DEF, TX_COL_THR, TX_DYN_WM_ENA, TX_GMF_CTRL_T, TX_GMF_EA, TX_IPG_JAM_DATA, TX_IPG_JAM_DEF, TX_JAM_IPG_DEF, TX_JAM_IPG_VAL, TX_JAM_LEN_DEF, and TX_JAM_LEN_VAL.

Referenced by sky2_up().

◆ sky2_ramset()

static void sky2_ramset ( struct sky2_hw hw,
u16  q,
u32  start,
u32  space 
)
static

Definition at line 804 of file sky2.c.

805 {
806  u32 end;
807 
808  /* convert from K bytes to qwords used for hw register */
809  start *= 1024/8;
810  space *= 1024/8;
811  end = start + space - 1;
812 
818 
819  if (q == Q_R1 || q == Q_R2) {
820  u32 tp = space - space/4;
821 
822  /* On receive queue's set the thresholds
823  * give receiver priority when > 3/4 full
824  * send pause when down to 2K
825  */
827  sky2_write32(hw, RB_ADDR(q, RB_RX_LTHP), space/2);
828 
829  tp = space - 2048/8;
831  sky2_write32(hw, RB_ADDR(q, RB_RX_LTPP), space/4);
832  } else {
833  /* Enable store & forward on Tx queue's because
834  * Tx FIFO is only 1K on Yukon
835  */
837  }
838 
841 }
Definition: skge.h:558
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
Definition: skge.h:550
Definition: hw.c:16
#define RB_ADDR(offs, queue)
Definition: skge.h:590
uint32_t start
Starting offset.
Definition: netvsc.h:12
Definition: skge.h:539
Definition: skge.h:541
static struct tulip_private * tp
Definition: tulip.c:441
Definition: skge.h:557
Definition: skge.h:542
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
static u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2106
Definition: skge.h:540
uint32_t u32
Definition: stdint.h:23

References end, Q_R1, Q_R2, RB_ADDR, RB_CTRL, RB_ENA_OP_MD, RB_ENA_STFWD, RB_END, RB_RP, RB_RST_CLR, RB_RX_LTHP, RB_RX_LTPP, RB_RX_UTHP, RB_RX_UTPP, RB_START, RB_WP, sky2_read8(), sky2_write32(), sky2_write8(), start, and tp.

Referenced by sky2_up().

◆ sky2_qset()

static void sky2_qset ( struct sky2_hw hw,
u16  q 
)
static

Definition at line 844 of file sky2.c.

845 {
850 }
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
Definition: skge.h:523
Definition: hw.c:16
Definition: sky2.h:637
#define Q_ADDR(reg, offs)
Definition: skge.h:534

References BMU_CLR_RESET, BMU_FIFO_OP_ON, BMU_OPER_INIT, BMU_WM_DEFAULT, Q_ADDR, Q_CSR, Q_WM, and sky2_write32().

Referenced by sky2_rx_start(), and sky2_up().

◆ sky2_prefetch_init()

static void sky2_prefetch_init ( struct sky2_hw hw,
u32  qaddr,
u64  addr,
u32  last 
)
static

Definition at line 855 of file sky2.c.

857 {
860  sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_ADDR_HI), addr >> 32);
864 
866 }
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2096
Definition: hw.c:16
#define Y2_QADDR(q, reg)
Definition: sky2.h:679
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2116
u32 addr
Definition: sky2.h:8
uint32_t last
Length to read in last segment, or zero.
Definition: pccrc.h:30
uint32_t u32
Definition: stdint.h:23

References addr, last, PREF_UNIT_ADDR_HI, PREF_UNIT_ADDR_LO, PREF_UNIT_CTRL, PREF_UNIT_LAST_IDX, PREF_UNIT_OP_ON, PREF_UNIT_RST_CLR, PREF_UNIT_RST_SET, sky2_read32(), sky2_write16(), sky2_write32(), and Y2_QADDR.

Referenced by sky2_rx_start(), and sky2_up().

◆ get_tx_le()

static struct sky2_tx_le* get_tx_le ( struct sky2_port sky2)
inlinestatic

Definition at line 868 of file sky2.c.

869 {
870  struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod;
871 
872  sky2->tx_prod = RING_NEXT(sky2->tx_prod, TX_RING_SIZE);
873  le->ctrl = 0;
874  return le;
875 }
#define RING_NEXT(x, s)
Definition: sky2.c:79
struct sky2_tx_le * tx_le
Definition: sky2.h:2045
#define TX_RING_SIZE
Definition: sky2.c:66
u8 ctrl
Definition: sky2.h:2002
u16 tx_prod
Definition: sky2.h:2047

References sky2_tx_le::ctrl, RING_NEXT, sky2_port::tx_le, sky2_port::tx_prod, and TX_RING_SIZE.

Referenced by sky2_xmit_frame(), and tx_init().

◆ tx_init()

static void tx_init ( struct sky2_port sky2)
static

Definition at line 877 of file sky2.c.

878 {
879  struct sky2_tx_le *le;
880 
881  sky2->tx_prod = sky2->tx_cons = 0;
882 
883  le = get_tx_le(sky2);
884  le->addr = 0;
885  le->opcode = OP_ADDR64 | HW_OWNER;
886 }
static struct sky2_tx_le * get_tx_le(struct sky2_port *sky2)
Definition: sky2.c:868
u8 opcode
Definition: sky2.h:2003
u16 tx_cons
Definition: sky2.h:2046
u32 addr
Definition: sky2.h:2000
u16 tx_prod
Definition: sky2.h:2047

References sky2_tx_le::addr, get_tx_le(), HW_OWNER, OP_ADDR64, sky2_tx_le::opcode, sky2_port::tx_cons, and sky2_port::tx_prod.

Referenced by sky2_up().

◆ tx_le_re()

static struct tx_ring_info* tx_le_re ( struct sky2_port sky2,
struct sky2_tx_le le 
)
inlinestatic

Definition at line 888 of file sky2.c.

890 {
891  return sky2->tx_ring + (le - sky2->tx_le);
892 }
struct sky2_tx_le * tx_le
Definition: sky2.h:2045
struct tx_ring_info * tx_ring
Definition: sky2.h:2044

References sky2_port::tx_le, and sky2_port::tx_ring.

Referenced by sky2_xmit_frame().

◆ sky2_put_idx()

static void sky2_put_idx ( struct sky2_hw hw,
unsigned  q,
u16  idx 
)
inlinestatic

Definition at line 895 of file sky2.c.

896 {
897  /* Make sure write' to descriptors are complete before we tell hardware */
898  wmb();
900  DBGIO(PFX "queue %#x idx <- %d\n", q, idx);
901 }
#define PFX
Definition: sky2.c:46
wmb()
Definition: hw.c:16
#define Y2_QADDR(q, reg)
Definition: sky2.h:679
#define DBGIO(...)
Definition: compiler.h:549
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2116

References DBGIO, PFX, PREF_UNIT_PUT_IDX, sky2_write16(), wmb(), and Y2_QADDR.

Referenced by sky2_rx_update(), and sky2_xmit_frame().

◆ sky2_next_rx()

static struct sky2_rx_le* sky2_next_rx ( struct sky2_port sky2)
inlinestatic

Definition at line 904 of file sky2.c.

905 {
906  struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put;
907 
908  sky2->rx_put = RING_NEXT(sky2->rx_put, RX_LE_SIZE);
909  le->ctrl = 0;
910  return le;
911 }
u8 ctrl
Definition: sky2.h:2009
u16 rx_put
Definition: sky2.h:2053
#define RING_NEXT(x, s)
Definition: sky2.c:79
#define RX_LE_SIZE
Definition: sky2.c:61
struct sky2_rx_le * rx_le
Definition: sky2.h:2050

References sky2_rx_le::ctrl, RING_NEXT, sky2_port::rx_le, RX_LE_SIZE, and sky2_port::rx_put.

Referenced by rx_set_checksum(), and sky2_rx_add().

◆ sky2_rx_add()

static void sky2_rx_add ( struct sky2_port sky2,
u8  op,
u32  map,
unsigned  len 
)
static

Definition at line 914 of file sky2.c.

916 {
917  struct sky2_rx_le *le;
918 
919  le = sky2_next_rx(sky2);
920  le->addr = cpu_to_le32(map);
921  le->length = cpu_to_le16(len);
922  le->opcode = op | HW_OWNER;
923 }
u16 length
Definition: sky2.h:2008
static struct sky2_rx_le * sky2_next_rx(struct sky2_port *sky2)
Definition: sky2.c:904
#define cpu_to_le32(value)
Definition: byteswap.h:107
u8 opcode
Definition: sky2.h:2010
static __always_inline int struct dma_mapping * map
Definition: dma.h:181
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
uint32_t len
Length.
Definition: ena.h:14
#define cpu_to_le16(value)
Definition: byteswap.h:106
u32 addr
Definition: sky2.h:2007

References sky2_rx_le::addr, cpu_to_le16, cpu_to_le32, HW_OWNER, len, sky2_rx_le::length, map, op, sky2_rx_le::opcode, and sky2_next_rx().

Referenced by sky2_rx_submit().

◆ sky2_rx_submit()

static void sky2_rx_submit ( struct sky2_port sky2,
const struct rx_ring_info re 
)
static

Definition at line 926 of file sky2.c.

928 {
929  sky2_rx_add(sky2, OP_PACKET, re->data_addr, sky2->rx_data_size);
930 }
static void sky2_rx_add(struct sky2_port *sky2, u8 op, u32 map, unsigned len)
Definition: sky2.c:914
u16 rx_data_size
Definition: sky2.h:2054
u32 data_addr
Definition: sky2.h:2028

References rx_ring_info::data_addr, OP_PACKET, sky2_port::rx_data_size, and sky2_rx_add().

Referenced by sky2_receive(), and sky2_rx_start().

◆ sky2_rx_map_iob()

static void sky2_rx_map_iob ( struct pci_device *pdev  __unused,
struct rx_ring_info re,
unsigned size  __unused 
)
static

Definition at line 933 of file sky2.c.

936 {
937  struct io_buffer *iob = re->iob;
938  re->data_addr = virt_to_bus(iob->data);
939 }
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
u32 data_addr
Definition: sky2.h:2028
struct io_buffer * iob
Definition: sky2.h:2027
void * data
Start of data.
Definition: iobuf.h:48
A persistent I/O buffer.
Definition: iobuf.h:33

References io_buffer::data, rx_ring_info::data_addr, rx_ring_info::iob, and virt_to_bus().

Referenced by receive_new(), and sky2_rx_start().

◆ rx_set_checksum()

static void rx_set_checksum ( struct sky2_port sky2)
static

Definition at line 943 of file sky2.c.

944 {
945  struct sky2_rx_le *le = sky2_next_rx(sky2);
946 
947  le->addr = cpu_to_le32((ETH_HLEN << 16) | ETH_HLEN);
948  le->ctrl = 0;
949  le->opcode = OP_TCPSTART | HW_OWNER;
950 
951  sky2_write32(sky2->hw,
952  Q_ADDR(rxqaddr[sky2->port], Q_CSR),
954 }
struct sky2_hw * hw
Definition: sky2.h:2040
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
u8 ctrl
Definition: sky2.h:2009
Definition: skge.h:523
#define ETH_HLEN
Definition: if_ether.h:9
static struct sky2_rx_le * sky2_next_rx(struct sky2_port *sky2)
Definition: sky2.c:904
#define cpu_to_le32(value)
Definition: byteswap.h:107
u8 opcode
Definition: sky2.h:2010
unsigned port
Definition: sky2.h:2042
#define Q_ADDR(reg, offs)
Definition: skge.h:534
u32 addr
Definition: sky2.h:2007
static const unsigned rxqaddr[]
Definition: sky2.c:125

References sky2_rx_le::addr, BMU_DIS_RX_CHKSUM, cpu_to_le32, sky2_rx_le::ctrl, ETH_HLEN, sky2_port::hw, HW_OWNER, OP_TCPSTART, sky2_rx_le::opcode, sky2_port::port, Q_ADDR, Q_CSR, rxqaddr, sky2_next_rx(), and sky2_write32().

Referenced by sky2_rx_start().

◆ sky2_rx_stop()

static void sky2_rx_stop ( struct sky2_port sky2)
static

Definition at line 966 of file sky2.c.

967 {
968  struct sky2_hw *hw = sky2->hw;
969  unsigned rxq = rxqaddr[sky2->port];
970  int i;
971 
972  /* disable the RAM Buffer receive queue */
974 
975  for (i = 0; i < 0xffff; i++)
976  if (sky2_read8(hw, RB_ADDR(rxq, Q_RSL))
977  == sky2_read8(hw, RB_ADDR(rxq, Q_RL)))
978  goto stopped;
979 
980  DBG(PFX "%s: receiver stop failed\n", sky2->netdev->name);
981 stopped:
983 
984  /* reset the Rx prefetch unit */
986  wmb();
987 }
#define PFX
Definition: sky2.c:46
struct sky2_hw * hw
Definition: sky2.h:2040
wmb()
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
Definition: skge.h:550
Definition: skge.h:523
Definition: hw.c:16
#define RB_ADDR(offs, queue)
Definition: skge.h:590
struct net_device * netdev
Definition: sky2.h:2041
#define Y2_QADDR(q, reg)
Definition: sky2.h:679
Definition: sky2.h:640
Definition: sky2.h:2066
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
unsigned port
Definition: sky2.h:2042
#define Q_ADDR(reg, offs)
Definition: skge.h:534
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2106
static const unsigned rxqaddr[]
Definition: sky2.c:125
Definition: sky2.h:642

References BMU_FIFO_RST, BMU_RST_SET, DBG, sky2_port::hw, net_device::name, sky2_port::netdev, PFX, sky2_port::port, PREF_UNIT_CTRL, PREF_UNIT_RST_SET, Q_ADDR, Q_CSR, Q_RL, Q_RSL, RB_ADDR, RB_CTRL, RB_DIS_OP_MD, rxqaddr, sky2_read8(), sky2_write32(), sky2_write8(), wmb(), and Y2_QADDR.

Referenced by sky2_down().

◆ sky2_rx_clean()

static void sky2_rx_clean ( struct sky2_port sky2)
static

Definition at line 990 of file sky2.c.

991 {
992  unsigned i;
993 
994  memset(sky2->rx_le, 0, RX_LE_BYTES);
995  for (i = 0; i < RX_PENDING; i++) {
996  struct rx_ring_info *re = sky2->rx_ring + i;
997 
998  if (re->iob) {
999  free_iob(re->iob);
1000  re->iob = NULL;
1001  }
1002  }
1003 }
#define RX_PENDING
Definition: sky2.c:64
#define RX_LE_BYTES
Definition: sky2.c:62
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
struct rx_ring_info * rx_ring
Definition: sky2.h:2049
struct io_buffer * iob
Definition: sky2.h:2027
struct sky2_rx_le * rx_le
Definition: sky2.h:2050
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void * memset(void *dest, int character, size_t len) __nonnull

References free_iob(), rx_ring_info::iob, memset(), NULL, sky2_port::rx_le, RX_LE_BYTES, RX_PENDING, and sky2_port::rx_ring.

Referenced by sky2_down(), and sky2_rx_start().

◆ sky2_rx_alloc()

static struct io_buffer* sky2_rx_alloc ( struct sky2_port sky2)
static

Definition at line 1008 of file sky2.c.

1009 {
1010  struct io_buffer *iob;
1011 
1012  iob = alloc_iob(sky2->rx_data_size + ETH_DATA_ALIGN);
1013  if (!iob)
1014  return NULL;
1015 
1016  /*
1017  * Cards with a RAM buffer hang in the rx FIFO if the
1018  * receive buffer isn't aligned to (Linux module comments say
1019  * 64 bytes, Linux module code says 8 bytes). Since io_buffers
1020  * are always 2kb-aligned under iPXE, just leave it be
1021  * without ETH_DATA_ALIGN in those cases.
1022  *
1023  * XXX This causes unaligned access to the IP header,
1024  * which is undesirable, but it's less undesirable than the
1025  * card hanging.
1026  */
1027  if (!(sky2->hw->flags & SKY2_HW_RAM_BUFFER)) {
1029  }
1030 
1031  return iob;
1032 }
struct sky2_hw * hw
Definition: sky2.h:2040
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:129
u16 rx_data_size
Definition: sky2.h:2054
#define ETH_DATA_ALIGN
Definition: if_ether.h:12
unsigned long flags
Definition: sky2.h:2070
#define SKY2_HW_RAM_BUFFER
Definition: sky2.h:2075
#define iob_reserve(iobuf, len)
Definition: iobuf.h:67
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A persistent I/O buffer.
Definition: iobuf.h:33

References alloc_iob(), ETH_DATA_ALIGN, sky2_hw::flags, sky2_port::hw, iob_reserve, NULL, sky2_port::rx_data_size, and SKY2_HW_RAM_BUFFER.

Referenced by receive_new(), and sky2_rx_start().

◆ sky2_rx_update()

static void sky2_rx_update ( struct sky2_port sky2,
unsigned  rxq 
)
inlinestatic

Definition at line 1034 of file sky2.c.

1035 {
1036  sky2_put_idx(sky2->hw, rxq, sky2->rx_put);
1037 }
struct sky2_hw * hw
Definition: sky2.h:2040
u16 rx_put
Definition: sky2.h:2053
static void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx)
Definition: sky2.c:895

References sky2_port::hw, sky2_port::rx_put, and sky2_put_idx().

Referenced by sky2_rx_start(), and sky2_status_intr().

◆ sky2_rx_start()

static int sky2_rx_start ( struct sky2_port sky2)
static

Definition at line 1045 of file sky2.c.

1046 {
1047  struct sky2_hw *hw = sky2->hw;
1048  struct rx_ring_info *re;
1049  unsigned rxq = rxqaddr[sky2->port];
1050  unsigned i, size, thresh;
1051 
1052  sky2->rx_put = sky2->rx_next = 0;
1053  sky2_qset(hw, rxq);
1054 
1055  /* On PCI express lowering the watermark gives better performance */
1058 
1059  /* These chips have no ram buffer?
1060  * MAC Rx RAM Read is controlled by hardware */
1061  if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
1062  (hw->chip_rev == CHIP_REV_YU_EC_U_A1
1063  || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
1065 
1066  sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
1067 
1068  if (!(hw->flags & SKY2_HW_NEW_LE))
1069  rx_set_checksum(sky2);
1070 
1071  /* Space needed for frame data + headers rounded up */
1072  size = (ETH_FRAME_LEN + 8) & ~7;
1073 
1074  /* Stopping point for hardware truncation */
1075  thresh = (size - 8) / sizeof(u32);
1076 
1077  sky2->rx_data_size = size;
1078 
1079  /* Fill Rx ring */
1080  for (i = 0; i < RX_PENDING; i++) {
1081  re = sky2->rx_ring + i;
1082 
1083  re->iob = sky2_rx_alloc(sky2);
1084  if (!re->iob)
1085  goto nomem;
1086 
1087  sky2_rx_map_iob(hw->pdev, re, sky2->rx_data_size);
1088  sky2_rx_submit(sky2, re);
1089  }
1090 
1091  /*
1092  * The receiver hangs if it receives frames larger than the
1093  * packet buffer. As a workaround, truncate oversize frames, but
1094  * the register is limited to 9 bits, so if you do frames > 2052
1095  * you better get the MTU right!
1096  */
1097  if (thresh > 0x1ff)
1099  else {
1100  sky2_write16(hw, SK_REG(sky2->port, RX_GMF_TR_THR), thresh);
1102  }
1103 
1104  /* Tell chip about available buffers */
1105  sky2_rx_update(sky2, rxq);
1106  return 0;
1107 nomem:
1108  sky2_rx_clean(sky2);
1109  return -ENOMEM;
1110 }
u32 rx_le_map
Definition: sky2.h:2056
struct sky2_hw * hw
Definition: sky2.h:2040
static void sky2_rx_update(struct sky2_port *sky2, unsigned rxq)
Definition: sky2.c:1034
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
int pci_find_capability(struct pci_device *pci, int cap)
Look for a PCI capability.
Definition: pciextra.c:38
#define RX_PENDING
Definition: sky2.c:64
u16 rx_put
Definition: sky2.h:2053
static void sky2_rx_clean(struct sky2_port *sky2)
Definition: sky2.c:990
Definition: hw.c:16
static void sky2_rx_submit(struct sky2_port *sky2, const struct rx_ring_info *re)
Definition: sky2.c:926
#define ENOMEM
Not enough space.
Definition: errno.h:534
static void sky2_prefetch_init(struct sky2_hw *hw, u32 qaddr, u64 addr, u32 last)
Definition: sky2.c:855
static struct io_buffer * sky2_rx_alloc(struct sky2_port *sky2)
Definition: sky2.c:1008
#define ETH_FRAME_LEN
Definition: if_ether.h:11
u16 rx_data_size
Definition: sky2.h:2054
#define RX_LE_SIZE
Definition: sky2.c:61
struct rx_ring_info * rx_ring
Definition: sky2.h:2049
static void sky2_rx_map_iob(struct pci_device *pdev __unused, struct rx_ring_info *re, unsigned size __unused)
Definition: sky2.c:933
u16 rx_next
Definition: sky2.h:2052
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2116
#define SK_REG(port, reg)
Definition: skge.h:2548
static void rx_set_checksum(struct sky2_port *sky2)
Definition: sky2.c:943
Definition: sky2.h:637
Definition: sky2.h:634
#define PCI_CAP_ID_EXP
PCI Express.
Definition: pci.h:97
struct io_buffer * iob
Definition: sky2.h:2027
Definition: sky2.h:2066
unsigned port
Definition: sky2.h:2042
#define Q_ADDR(reg, offs)
Definition: skge.h:534
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
static void sky2_qset(struct sky2_hw *hw, u16 q)
Definition: sky2.c:844
static const unsigned rxqaddr[]
Definition: sky2.c:125
uint32_t u32
Definition: stdint.h:23
#define SKY2_HW_NEW_LE
Definition: sky2.h:2076

References BMU_WM_PEX, CHIP_ID_YUKON_EC_U, CHIP_REV_YU_EC_U_A1, CHIP_REV_YU_EC_U_B0, ENOMEM, ETH_FRAME_LEN, F_M_RX_RAM_DIS, sky2_port::hw, rx_ring_info::iob, PCI_CAP_ID_EXP, pci_find_capability(), sky2_port::port, Q_ADDR, Q_TEST, Q_WM, sky2_port::rx_data_size, RX_GMF_CTRL_T, RX_GMF_TR_THR, sky2_port::rx_le_map, RX_LE_SIZE, sky2_port::rx_next, RX_PENDING, sky2_port::rx_put, sky2_port::rx_ring, rx_set_checksum(), RX_TRUNC_OFF, RX_TRUNC_ON, rxqaddr, size, SK_REG, SKY2_HW_NEW_LE, sky2_prefetch_init(), sky2_qset(), sky2_rx_alloc(), sky2_rx_clean(), sky2_rx_map_iob(), sky2_rx_submit(), sky2_rx_update(), sky2_write16(), and sky2_write32().

Referenced by sky2_up().

◆ sky2_free_rings()

static void sky2_free_rings ( struct sky2_port sky2)
static

Definition at line 1113 of file sky2.c.

1114 {
1115  free_phys(sky2->rx_le, RX_LE_BYTES);
1116  free(sky2->rx_ring);
1117 
1118  free_phys(sky2->tx_le, TX_RING_SIZE * sizeof(struct sky2_tx_le));
1119  free(sky2->tx_ring);
1120 
1121  sky2->tx_le = NULL;
1122  sky2->rx_le = NULL;
1123 
1124  sky2->rx_ring = NULL;
1125  sky2->tx_ring = NULL;
1126 }
#define RX_LE_BYTES
Definition: sky2.c:62
struct sky2_tx_le * tx_le
Definition: sky2.h:2045
struct tx_ring_info * tx_ring
Definition: sky2.h:2044
#define TX_RING_SIZE
Definition: sky2.c:66
struct rx_ring_info * rx_ring
Definition: sky2.h:2049
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct sky2_rx_le * rx_le
Definition: sky2.h:2050
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References free, free_phys(), NULL, sky2_port::rx_le, RX_LE_BYTES, sky2_port::rx_ring, sky2_port::tx_le, sky2_port::tx_ring, and TX_RING_SIZE.

Referenced by sky2_down(), and sky2_up().

◆ sky2_up()

static int sky2_up ( struct net_device dev)
static

Definition at line 1129 of file sky2.c.

1130 {
1131  struct sky2_port *sky2 = dev->priv;
1132  struct sky2_hw *hw = sky2->hw;
1133  unsigned port = sky2->port;
1134  u32 imask, ramsize;
1135  int err = -ENOMEM;
1136 
1138 
1139  /* must be power of 2 */
1140  sky2->tx_le = malloc_phys(TX_RING_SIZE * sizeof(struct sky2_tx_le), TX_RING_ALIGN);
1141  sky2->tx_le_map = virt_to_bus(sky2->tx_le);
1142  if (!sky2->tx_le)
1143  goto err_out;
1144  memset(sky2->tx_le, 0, TX_RING_SIZE * sizeof(struct sky2_tx_le));
1145 
1146  sky2->tx_ring = zalloc(TX_RING_SIZE * sizeof(struct tx_ring_info));
1147  if (!sky2->tx_ring)
1148  goto err_out;
1149 
1150  tx_init(sky2);
1151 
1153  sky2->rx_le_map = virt_to_bus(sky2->rx_le);
1154  if (!sky2->rx_le)
1155  goto err_out;
1156  memset(sky2->rx_le, 0, RX_LE_BYTES);
1157 
1158  sky2->rx_ring = zalloc(RX_PENDING * sizeof(struct rx_ring_info));
1159  if (!sky2->rx_ring)
1160  goto err_out;
1161 
1162  sky2_mac_init(hw, port);
1163 
1164  /* Register is number of 4K blocks on internal RAM buffer. */
1165  ramsize = sky2_read8(hw, B2_E_0) * 4;
1166  if (ramsize > 0) {
1167  u32 rxspace;
1168 
1169  hw->flags |= SKY2_HW_RAM_BUFFER;
1170  DBG2(PFX "%s: ram buffer %dK\n", dev->name, ramsize);
1171  if (ramsize < 16)
1172  rxspace = ramsize / 2;
1173  else
1174  rxspace = 8 + (2*(ramsize - 16))/3;
1175 
1176  sky2_ramset(hw, rxqaddr[port], 0, rxspace);
1177  sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace);
1178 
1179  /* Make sure SyncQ is disabled */
1181  RB_RST_SET);
1182  }
1183 
1184  sky2_qset(hw, txqaddr[port]);
1185 
1186  /* This is copied from sk98lin 10.0.5.3; no one tells me about erratta's */
1187  if (hw->chip_id == CHIP_ID_YUKON_EX && hw->chip_rev == CHIP_REV_YU_EX_B0)
1189 
1190  /* Set almost empty threshold */
1191  if (hw->chip_id == CHIP_ID_YUKON_EC_U
1192  && hw->chip_rev == CHIP_REV_YU_EC_U_A0)
1194 
1196  TX_RING_SIZE - 1);
1197 
1198  err = sky2_rx_start(sky2);
1199  if (err)
1200  goto err_out;
1201 
1202  /* Enable interrupts from phy/mac for port */
1203  imask = sky2_read32(hw, B0_IMSK);
1204  imask |= portirq_msk[port];
1205  sky2_write32(hw, B0_IMSK, imask);
1206 
1207  DBGIO(PFX "%s: le bases: st %p [%x], rx %p [%x], tx %p [%x]\n",
1208  dev->name, hw->st_le, hw->st_dma, sky2->rx_le, sky2->rx_le_map,
1209  sky2->tx_le, sky2->tx_le_map);
1210 
1212  return 0;
1213 
1214 err_out:
1215  sky2_free_rings(sky2);
1216  return err;
1217 }
u32 rx_le_map
Definition: sky2.h:2056
Definition: skge.h:108
#define PFX
Definition: sky2.c:46
static void sky2_free_rings(struct sky2_port *sky2)
Definition: sky2.c:1113
struct sky2_hw * hw
Definition: sky2.h:2040
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
Definition: skge.h:550
#define RX_PENDING
Definition: sky2.c:64
#define RX_LE_BYTES
Definition: sky2.c:62
static const u32 portirq_msk[]
Definition: sky2.c:126
Definition: skge.h:559
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.h:62
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2096
static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:683
Definition: hw.c:16
static const unsigned txqaddr[]
Definition: sky2.c:124
struct sky2_tx_le * tx_le
Definition: sky2.h:2045
#define RB_ADDR(offs, queue)
Definition: skge.h:590
#define ENOMEM
Not enough space.
Definition: errno.h:534
Definition: skge.h:82
u8 port
Port number.
Definition: CIB_PRM.h:31
static void sky2_set_multicast(struct net_device *dev)
Definition: sky2.c:2153
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:855
void * priv
Driver private data.
Definition: netdevice.h:431
struct tx_ring_info * tx_ring
Definition: sky2.h:2044
#define TX_RING_SIZE
Definition: sky2.c:66
#define DBGIO(...)
Definition: compiler.h:549
struct rx_ring_info * rx_ring
Definition: sky2.h:2049
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
Definition: sky2.h:638
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2116
Definition: sky2.h:634
#define SKY2_HW_RAM_BUFFER
Definition: sky2.h:2075
Definition: skge.h:561
Definition: sky2.h:2066
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
unsigned port
Definition: sky2.h:2042
#define TX_RING_ALIGN
Definition: sky2.c:68
#define Q_ADDR(reg, offs)
Definition: skge.h:534
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
struct sky2_rx_le * rx_le
Definition: sky2.h:2050
#define RX_RING_ALIGN
Definition: sky2.c:63
static void tx_init(struct sky2_port *sky2)
Definition: sky2.c:877
static void sky2_qset(struct sky2_hw *hw, u16 q)
Definition: sky2.c:844
static int sky2_rx_start(struct sky2_port *sky2)
Definition: sky2.c:1045
struct net_device * dev[2]
Definition: sky2.h:2069
static u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2106
static const unsigned rxqaddr[]
Definition: sky2.c:125
u32 tx_le_map
Definition: sky2.h:2057
uint32_t u32
Definition: stdint.h:23
static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space)
Definition: sky2.c:804
#define DBG2(...)
Definition: compiler.h:515
void * memset(void *dest, int character, size_t len) __nonnull

References B0_IMSK, B2_E_0, CHIP_ID_YUKON_EC_U, CHIP_ID_YUKON_EX, CHIP_REV_YU_EC_U_A0, CHIP_REV_YU_EX_B0, DBG2, DBGIO, sky2_hw::dev, ECU_TXFF_LEV, ENOMEM, F_TX_CHK_AUTO_OFF, sky2_port::hw, malloc_phys(), memset(), net_device::name, netdev_link_down(), PFX, port, sky2_port::port, portirq_msk, net_device::priv, Q_ADDR, Q_AL, Q_TEST, Q_XS1, Q_XS2, RB_ADDR, RB_CTRL, RB_RST_SET, sky2_port::rx_le, RX_LE_BYTES, sky2_port::rx_le_map, RX_PENDING, sky2_port::rx_ring, RX_RING_ALIGN, rxqaddr, sky2_free_rings(), SKY2_HW_RAM_BUFFER, sky2_mac_init(), sky2_prefetch_init(), sky2_qset(), sky2_ramset(), sky2_read32(), sky2_read8(), sky2_rx_start(), sky2_set_multicast(), sky2_write16(), sky2_write32(), sky2_write8(), tx_init(), sky2_port::tx_le, sky2_port::tx_le_map, sky2_port::tx_ring, TX_RING_ALIGN, TX_RING_SIZE, txqaddr, virt_to_bus(), and zalloc().

◆ tx_dist()

static int tx_dist ( unsigned  tail,
unsigned  head 
)
inlinestatic

Definition at line 1220 of file sky2.c.

1221 {
1222  return (head - tail) & (TX_RING_SIZE - 1);
1223 }
uint8_t head
Head number.
Definition: int13.h:34
#define TX_RING_SIZE
Definition: sky2.c:66

References head, and TX_RING_SIZE.

Referenced by tx_avail().

◆ tx_avail()

static int tx_avail ( const struct sky2_port sky2)
inlinestatic

Definition at line 1226 of file sky2.c.

1227 {
1228  return TX_PENDING - tx_dist(sky2->tx_cons, sky2->tx_prod);
1229 }
#define TX_PENDING
Definition: sky2.c:67
u16 tx_cons
Definition: sky2.h:2046
static int tx_dist(unsigned tail, unsigned head)
Definition: sky2.c:1220
u16 tx_prod
Definition: sky2.h:2047

References sky2_port::tx_cons, tx_dist(), TX_PENDING, and sky2_port::tx_prod.

Referenced by sky2_xmit_frame().

◆ sky2_xmit_frame()

static int sky2_xmit_frame ( struct net_device dev,
struct io_buffer iob 
)
static

Definition at line 1238 of file sky2.c.

1239 {
1240  struct sky2_port *sky2 = dev->priv;
1241  struct sky2_hw *hw = sky2->hw;
1242  struct sky2_tx_le *le = NULL;
1243  struct tx_ring_info *re;
1244  unsigned len;
1245  u32 mapping;
1246  u8 ctrl;
1247 
1248  if (tx_avail(sky2) < 1)
1249  return -EBUSY;
1250 
1251  len = iob_len(iob);
1252  mapping = virt_to_bus(iob->data);
1253 
1254  DBGIO(PFX "%s: tx queued, slot %d, len %d\n", dev->name,
1255  sky2->tx_prod, len);
1256 
1257  ctrl = 0;
1258 
1259  le = get_tx_le(sky2);
1260  le->addr = cpu_to_le32((u32) mapping);
1261  le->length = cpu_to_le16(len);
1262  le->ctrl = ctrl;
1263  le->opcode = (OP_PACKET | HW_OWNER);
1264 
1265  re = tx_le_re(sky2, le);
1266  re->iob = iob;
1267 
1268  le->ctrl |= EOP;
1269 
1270  sky2_put_idx(hw, txqaddr[sky2->port], sky2->tx_prod);
1271 
1272  return 0;
1273 }
#define PFX
Definition: sky2.c:46
struct sky2_hw * hw
Definition: sky2.h:2040
static struct sky2_tx_le * get_tx_le(struct sky2_port *sky2)
Definition: sky2.c:868
#define EBUSY
Device or resource busy.
Definition: errno.h:338
static struct tx_ring_info * tx_le_re(struct sky2_port *sky2, struct sky2_tx_le *le)
Definition: sky2.c:888
Definition: sky2.h:1946
u8 opcode
Definition: sky2.h:2003
Definition: hw.c:16
static const unsigned txqaddr[]
Definition: sky2.c:124
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_put_idx(struct sky2_hw *hw, unsigned q, u16 idx)
Definition: sky2.c:895
void * priv
Driver private data.
Definition: netdevice.h:431
u32 addr
Definition: sky2.h:2000
#define DBGIO(...)
Definition: compiler.h:549
#define cpu_to_le32(value)
Definition: byteswap.h:107
u8 ctrl
Definition: sky2.h:2002
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
Definition: sky2.h:2066
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
uint32_t len
Length.
Definition: ena.h:14
unsigned port
Definition: sky2.h:2042
void * data
Start of data.
Definition: iobuf.h:48
u16 tx_prod
Definition: sky2.h:2047
u8 ctrl
Definition: sky2.h:10
#define cpu_to_le16(value)
Definition: byteswap.h:106
struct io_buffer * iob
Definition: sky2.h:2021
u16 length
Definition: sky2.h:2001
static int tx_avail(const struct sky2_port *sky2)
Definition: sky2.c:1226
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23

References sky2_tx_le::addr, cpu_to_le16, cpu_to_le32, ctrl, sky2_tx_le::ctrl, io_buffer::data, DBGIO, EBUSY, EOP, get_tx_le(), sky2_port::hw, HW_OWNER, tx_ring_info::iob, iob_len(), len, sky2_tx_le::length, net_device::name, NULL, OP_PACKET, sky2_tx_le::opcode, PFX, sky2_port::port, net_device::priv, sky2_put_idx(), tx_avail(), tx_le_re(), sky2_port::tx_prod, txqaddr, and virt_to_bus().

◆ sky2_tx_complete()

static void sky2_tx_complete ( struct sky2_port sky2,
u16  done 
)
static

Definition at line 1281 of file sky2.c.

1282 {
1283  struct net_device *dev = sky2->netdev;
1284  unsigned idx;
1285 
1287 
1288  for (idx = sky2->tx_cons; idx != done;
1289  idx = RING_NEXT(idx, TX_RING_SIZE)) {
1290  struct sky2_tx_le *le = sky2->tx_le + idx;
1291  struct tx_ring_info *re = sky2->tx_ring + idx;
1292 
1293  if (le->ctrl & EOP) {
1294  DBGIO(PFX "%s: tx done %d\n", dev->name, idx);
1295  netdev_tx_complete(dev, re->iob);
1296  }
1297  }
1298 
1299  sky2->tx_cons = idx;
1300  mb();
1301 }
#define PFX
Definition: sky2.c:46
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition: netdevice.h:752
Definition: sky2.h:1946
#define RING_NEXT(x, s)
Definition: sky2.c:79
struct sky2_tx_le * tx_le
Definition: sky2.h:2045
u16 tx_cons
Definition: sky2.h:2046
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct net_device * netdev
Definition: sky2.h:2041
struct tx_ring_info * tx_ring
Definition: sky2.h:2044
#define TX_RING_SIZE
Definition: sky2.c:66
#define DBGIO(...)
Definition: compiler.h:549
u8 ctrl
Definition: sky2.h:2002
A network device.
Definition: netdevice.h:352
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
struct io_buffer * iob
Definition: sky2.h:2021
void mb(void)
Memory barrier.
struct bofm_section_header done
Definition: bofm_test.c:46

References assert(), sky2_tx_le::ctrl, DBGIO, net_device::dev, done, EOP, tx_ring_info::iob, mb(), net_device::name, sky2_port::netdev, netdev_tx_complete(), PFX, RING_NEXT, sky2_port::tx_cons, sky2_port::tx_le, sky2_port::tx_ring, and TX_RING_SIZE.

Referenced by sky2_tx_clean(), and sky2_tx_done().

◆ sky2_tx_clean()

static void sky2_tx_clean ( struct net_device dev)
static

Definition at line 1304 of file sky2.c.

1305 {
1306  struct sky2_port *sky2 = dev->priv;
1307 
1308  sky2_tx_complete(sky2, sky2->tx_prod);
1309 }
static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
Definition: sky2.c:1281
void * priv
Driver private data.
Definition: netdevice.h:431
u16 tx_prod
Definition: sky2.h:2047

References net_device::priv, sky2_tx_complete(), and sky2_port::tx_prod.

Referenced by sky2_down().

◆ sky2_down()

static void sky2_down ( struct net_device dev)
static

Definition at line 1312 of file sky2.c.

1313 {
1314  struct sky2_port *sky2 = dev->priv;
1315  struct sky2_hw *hw = sky2->hw;
1316  unsigned port = sky2->port;
1317  u16 ctrl;
1318  u32 imask;
1319 
1320  /* Never really got started! */
1321  if (!sky2->tx_le)
1322  return;
1323 
1324  DBG2(PFX "%s: disabling interface\n", dev->name);
1325 
1326  /* Disable port IRQ */
1327  imask = sky2_read32(hw, B0_IMSK);
1328  imask &= ~portirq_msk[port];
1329  sky2_write32(hw, B0_IMSK, imask);
1330 
1332 
1333  /* Stop transmitter */
1336 
1339 
1343 
1345 
1346  /* Workaround shared GMAC reset */
1347  if (!(hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0
1348  && port == 0 && hw->dev[1]))
1350 
1351  /* Disable Force Sync bit and Enable Alloc bit */
1354 
1355  /* Stop Interval Timer and Limit Counter of Tx Arbiter */
1358 
1359  /* Reset the PCI FIFO of the async Tx queue */
1362 
1363  /* Reset the Tx prefetch units */
1366 
1368 
1369  sky2_rx_stop(sky2);
1370 
1373 
1375 
1376  /* turn off LED's */
1378 
1379  sky2_tx_clean(dev);
1380  sky2_rx_clean(sky2);
1381 
1382  sky2_free_rings(sky2);
1383 
1384  return;
1385 }
uint16_t u16
Definition: stdint.h:21
#define PFX
Definition: sky2.c:46
static void sky2_free_rings(struct sky2_port *sky2)
Definition: sky2.c:1113
struct sky2_hw * hw
Definition: sky2.h:2040
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
Definition: skge.h:2607
Definition: skge.h:550
static const u32 portirq_msk[]
Definition: sky2.c:126
static void sky2_tx_clean(struct net_device *dev)
Definition: sky2.c:1304
Definition: sky2.h:771
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2096
Definition: skge.h:523
static void sky2_rx_clean(struct sky2_port *sky2)
Definition: sky2.c:990
Definition: hw.c:16
static const unsigned txqaddr[]
Definition: sky2.c:124
struct sky2_tx_le * tx_le
Definition: sky2.h:2045
#define RB_ADDR(offs, queue)
Definition: skge.h:590
Definition: skge.h:82
u8 port
Port number.
Definition: CIB_PRM.h:31
void * priv
Driver private data.
Definition: netdevice.h:431
Definition: skge.h:496
#define Y2_QADDR(q, reg)
Definition: sky2.h:679
static void sky2_rx_stop(struct sky2_port *sky2)
Definition: sky2.c:966
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2116
Definition: sky2.h:192
#define SK_REG(port, reg)
Definition: skge.h:2548
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
Definition: skge.h:2596
Definition: sky2.h:2066
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
unsigned port
Definition: sky2.h:2042
#define Q_ADDR(reg, offs)
Definition: skge.h:534
u8 ctrl
Definition: sky2.h:10
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:255
struct net_device * dev[2]
Definition: sky2.h:2069
static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:616
uint32_t u32
Definition: stdint.h:23
#define DBG2(...)
Definition: compiler.h:515

References B0_IMSK, B0_Y2LED, BMU_FIFO_RST, BMU_RST_SET, BMU_STOP, CHIP_ID_YUKON_XL, ctrl, DBG2, sky2_hw::dev, GM_GP_CTRL, GM_GPCR_RX_ENA, GM_GPCR_TX_ENA, gma_read16(), gma_write16(), GMAC_CTRL, GMC_RST_SET, GMF_RST_SET, GPC_RST_SET, GPHY_CTRL, sky2_port::hw, LED_STAT_OFF, net_device::name, PFX, port, sky2_port::port, portirq_msk, PREF_UNIT_CTRL, PREF_UNIT_RST_SET, net_device::priv, Q_ADDR, Q_CSR, RB_ADDR, RB_CTRL, RB_DIS_OP_MD, RB_RST_SET, RX_GMF_CTRL_T, SK_REG, sky2_free_rings(), sky2_gmac_reset(), sky2_phy_power_down(), sky2_read32(), sky2_rx_clean(), sky2_rx_stop(), sky2_tx_clean(), sky2_write16(), sky2_write32(), sky2_write8(), TX_GMF_CTRL_T, sky2_port::tx_le, TXA_CTRL, TXA_DIS_ALLOC, TXA_DIS_FSYNC, TXA_ITI_INI, TXA_LIM_INI, TXA_STOP_RC, txqaddr, and Y2_QADDR.

◆ sky2_phy_speed()

static u16 sky2_phy_speed ( const struct sky2_hw hw,
u16  aux 
)
static

Definition at line 1387 of file sky2.c.

1388 {
1389  if (hw->flags & SKY2_HW_FIBRE_PHY)
1390  return SPEED_1000;
1391 
1392  if (!(hw->flags & SKY2_HW_GIGABIT)) {
1393  if (aux & PHY_M_PS_SPEED_100)
1394  return SPEED_100;
1395  else
1396  return SPEED_10;
1397  }
1398 
1399  switch (aux & PHY_M_PS_SPEED_MSK) {
1400  case PHY_M_PS_SPEED_1000:
1401  return SPEED_1000;
1402  case PHY_M_PS_SPEED_100:
1403  return SPEED_100;
1404  default:
1405  return SPEED_10;
1406  }
1407 }
#define SPEED_1000
Definition: atl1e.h:52
#define SPEED_10
Definition: atl1e.h:50
Definition: hw.c:16
#define SPEED_100
Definition: atl1e.h:51
#define SKY2_HW_GIGABIT
Definition: sky2.h:2073
#define SKY2_HW_FIBRE_PHY
Definition: sky2.h:2072

References PHY_M_PS_SPEED_100, PHY_M_PS_SPEED_1000, PHY_M_PS_SPEED_MSK, SKY2_HW_FIBRE_PHY, SKY2_HW_GIGABIT, SPEED_10, SPEED_100, and SPEED_1000.

Referenced by sky2_autoneg_done(), and sky2_phy_intr().

◆ sky2_link_up()

static void sky2_link_up ( struct sky2_port sky2)
static

Definition at line 1409 of file sky2.c.

1410 {
1411  struct sky2_hw *hw = sky2->hw;
1412  unsigned port = sky2->port;
1413  u16 reg;
1414  static const char *fc_name[] = {
1415  [FC_NONE] = "none",
1416  [FC_TX] = "tx",
1417  [FC_RX] = "rx",
1418  [FC_BOTH] = "both",
1419  };
1420 
1421  /* enable Rx/Tx */
1425 
1427 
1428  netdev_link_up(sky2->netdev);
1429 
1430  /* Turn on link LED */
1433 
1434  DBG(PFX "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
1435  sky2->netdev->name, sky2->speed,
1436  sky2->duplex == DUPLEX_FULL ? "full" : "half",
1437  fc_name[sky2->flow_status]);
1438 }
uint16_t u16
Definition: stdint.h:21
#define PFX
Definition: sky2.c:46
struct sky2_hw * hw
Definition: sky2.h:2040
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
Definition: skge.h:2607
static unsigned int unsigned int reg
Definition: myson.h:162
Definition: sky2.h:2036
Definition: sky2.h:2034
Definition: hw.c:16
u16 speed
Definition: sky2.h:2059
u8 duplex
Definition: sky2.h:2061
u8 port
Port number.
Definition: CIB_PRM.h:31
struct net_device * netdev
Definition: sky2.h:2041
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:774
#define DUPLEX_FULL
Definition: bnx2.h:111
#define SK_REG(port, reg)
Definition: skge.h:2548
A Fibre Channel name.
Definition: fc.h:29
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
Definition: skge.h:2596
Definition: sky2.h:2066
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
unsigned port
Definition: sky2.h:2042
Definition: sky2.h:2035
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
Definition: sky2.c:131
Definition: sky2.h:2033
enum flow_control flow_status
Definition: sky2.h:2063

References DBG, sky2_port::duplex, DUPLEX_FULL, FC_BOTH, FC_NONE, FC_RX, FC_TX, sky2_port::flow_status, GM_GP_CTRL, GM_GPCR_RX_ENA, GM_GPCR_TX_ENA, gm_phy_write(), gma_read16(), gma_write16(), sky2_port::hw, LINKLED_BLINK_OFF, LINKLED_LINKSYNC_OFF, LINKLED_ON, LNK_LED_REG, net_device::name, sky2_port::netdev, netdev_link_up(), PFX, PHY_M_DEF_MSK, PHY_MARV_INT_MASK, port, sky2_port::port, reg, SK_REG, sky2_write8(), and sky2_port::speed.

Referenced by sky2_phy_intr().

◆ sky2_link_down()

static void sky2_link_down ( struct sky2_port sky2)
static

Definition at line 1440 of file sky2.c.

1441 {
1442  struct sky2_hw *hw = sky2->hw;
1443  unsigned port = sky2->port;
1444  u16 reg;
1445 
1447 
1451 
1452  netdev_link_down(sky2->netdev);
1453 
1454  /* Turn on link LED */
1456 
1457  DBG(PFX "%s: Link is down.\n", sky2->netdev->name);
1458 
1459  sky2_phy_init(hw, port);
1460 }
uint16_t u16
Definition: stdint.h:21
#define PFX
Definition: sky2.c:46
struct sky2_hw * hw
Definition: sky2.h:2040
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
Definition: skge.h:2607
static unsigned int unsigned int reg
Definition: myson.h:162
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
Definition: hw.c:16
u8 port
Port number.
Definition: CIB_PRM.h:31
struct net_device * netdev
Definition: sky2.h:2041
static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:297
#define SK_REG(port, reg)
Definition: skge.h:2548
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
Definition: skge.h:2596
Definition: sky2.h:2066
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
unsigned port
Definition: sky2.h:2042
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
Definition: sky2.c:131

References DBG, GM_GP_CTRL, GM_GPCR_RX_ENA, GM_GPCR_TX_ENA, gm_phy_write(), gma_read16(), gma_write16(), sky2_port::hw, LINKLED_OFF, LNK_LED_REG, net_device::name, sky2_port::netdev, netdev_link_down(), PFX, PHY_MARV_INT_MASK, port, sky2_port::port, reg, SK_REG, sky2_phy_init(), and sky2_write8().

Referenced by sky2_phy_intr().

◆ sky2_autoneg_done()

static int sky2_autoneg_done ( struct sky2_port sky2,
u16  aux 
)
static

Definition at line 1462 of file sky2.c.

1463 {
1464  struct sky2_hw *hw = sky2->hw;
1465  unsigned port = sky2->port;
1466  u16 advert, lpa;
1467 
1468  advert = gm_phy_read(hw, port, PHY_MARV_AUNE_ADV);
1470  if (lpa & PHY_M_AN_RF) {
1471  DBG(PFX "%s: remote fault\n", sky2->netdev->name);
1472  return -1;
1473  }
1474 
1475  if (!(aux & PHY_M_PS_SPDUP_RES)) {
1476  DBG(PFX "%s: speed/duplex mismatch\n", sky2->netdev->name);
1477  return -1;
1478  }
1479 
1480  sky2->speed = sky2_phy_speed(hw, aux);
1481  sky2->duplex = (aux & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF;
1482 
1483  /* Since the pause result bits seem to in different positions on
1484  * different chips. look at registers.
1485  */
1486 
1487  sky2->flow_status = FC_NONE;
1488  if (advert & ADVERTISE_PAUSE_CAP) {
1489  if (lpa & LPA_PAUSE_CAP)
1490  sky2->flow_status = FC_BOTH;
1491  else if (advert & ADVERTISE_PAUSE_ASYM)
1492  sky2->flow_status = FC_RX;
1493  } else if (advert & ADVERTISE_PAUSE_ASYM) {
1494  if ((lpa & LPA_PAUSE_CAP) && (lpa & LPA_PAUSE_ASYM))
1495  sky2->flow_status = FC_TX;
1496  }
1497 
1498  if (sky2->duplex == DUPLEX_HALF && sky2->speed < SPEED_1000
1499  && !(hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX))
1500  sky2->flow_status = FC_NONE;
1501 
1502  if (sky2->flow_status & FC_TX)
1504  else
1506 
1507  return 0;
1508 }
#define SPEED_1000
Definition: atl1e.h:52
uint16_t u16
Definition: stdint.h:21
#define LPA_PAUSE_CAP
Definition: mii.h:106
#define PFX
Definition: sky2.c:46
struct sky2_hw * hw
Definition: sky2.h:2040
Definition: sky2.h:2036
Definition: sky2.h:2034
Definition: hw.c:16
u16 speed
Definition: sky2.h:2059
u8 duplex
Definition: sky2.h:2061
u8 port
Port number.
Definition: CIB_PRM.h:31
struct net_device * netdev
Definition: sky2.h:2041
#define DUPLEX_FULL
Definition: bnx2.h:111
#define ADVERTISE_PAUSE_ASYM
Definition: mii.h:84
#define LPA_PAUSE_ASYM
Definition: mii.h:107
#define SK_REG(port, reg)
Definition: skge.h:2548
Definition: sky2.h:2066
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
unsigned port
Definition: sky2.h:2042
Definition: sky2.h:2035
static u16 sky2_phy_speed(const struct sky2_hw *hw, u16 aux)
Definition: sky2.c:1387
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
#define ADVERTISE_PAUSE_CAP
Definition: mii.h:83
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
Definition: sky2.h:2033
enum flow_control flow_status
Definition: sky2.h:2063
if(natsemi->flags &NATSEMI_64BIT) return 1
#define DUPLEX_HALF
Definition: bnx2.h:110
static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
Definition: sky2.c:185

References ADVERTISE_PAUSE_ASYM, ADVERTISE_PAUSE_CAP, CHIP_ID_YUKON_EC_U, CHIP_ID_YUKON_EX, DBG, sky2_port::duplex, DUPLEX_FULL, DUPLEX_HALF, FC_BOTH, FC_NONE, FC_RX, FC_TX, sky2_port::flow_status, gm_phy_read(), GMAC_CTRL, GMC_PAUSE_OFF, GMC_PAUSE_ON, sky2_port::hw, if(), LPA_PAUSE_ASYM, LPA_PAUSE_CAP, net_device::name, sky2_port::netdev, PFX, PHY_M_AN_RF, PHY_M_PS_FULL_DUP, PHY_M_PS_SPDUP_RES, PHY_MARV_AUNE_ADV, PHY_MARV_AUNE_LP, port, sky2_port::port, SK_REG, sky2_phy_speed(), sky2_write8(), sky2_port::speed, and SPEED_1000.

Referenced by sky2_phy_intr().

◆ sky2_phy_intr()

static void sky2_phy_intr ( struct sky2_hw hw,
unsigned  port 
)
static

Definition at line 1511 of file sky2.c.

1512 {
1513  struct net_device *dev = hw->dev[port];
1514  struct sky2_port *sky2 = dev->priv;
1515  u16 istatus, phystat;
1516 
1517  istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT);
1518  phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT);
1519 
1520  DBGIO(PFX "%s: phy interrupt status 0x%x 0x%x\n",
1521  sky2->netdev->name, istatus, phystat);
1522 
1523  if (sky2->autoneg == AUTONEG_ENABLE && (istatus & PHY_M_IS_AN_COMPL)) {
1524  if (sky2_autoneg_done(sky2, phystat) == 0)
1525  sky2_link_up(sky2);
1526  return;
1527  }
1528 
1529  if (istatus & PHY_M_IS_LSP_CHANGE)
1530  sky2->speed = sky2_phy_speed(hw, phystat);
1531 
1532  if (istatus & PHY_M_IS_DUP_CHANGE)
1533  sky2->duplex =
1534  (phystat & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF;
1535 
1536  if (istatus & PHY_M_IS_LST_CHANGE) {
1537  if (phystat & PHY_M_PS_LINK_UP)
1538  sky2_link_up(sky2);
1539  else
1540  sky2_link_down(sky2);
1541  }
1542 }
uint16_t u16
Definition: stdint.h:21
#define PFX
Definition: sky2.c:46
static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
Definition: sky2.c:1462
#define AUTONEG_ENABLE
Definition: bnx2.h:4584
static void sky2_link_down(struct sky2_port *sky2)
Definition: sky2.c:1440
Definition: hw.c:16
u16 speed
Definition: sky2.h:2059
u8 duplex
Definition: sky2.h:2061
u8 port
Port number.
Definition: CIB_PRM.h:31
struct net_device * netdev
Definition: sky2.h:2041
void * priv
Driver private data.
Definition: netdevice.h:431
#define DUPLEX_FULL
Definition: bnx2.h:111
u8 autoneg
Definition: sky2.h:2060
#define DBGIO(...)
Definition: compiler.h:549
A network device.
Definition: netdevice.h:352
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
static u16 sky2_phy_speed(const struct sky2_hw *hw, u16 aux)
Definition: sky2.c:1387
static void sky2_link_up(struct sky2_port *sky2)
Definition: sky2.c:1409
#define DUPLEX_HALF
Definition: bnx2.h:110
static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
Definition: sky2.c:185

References sky2_port::autoneg, AUTONEG_ENABLE, DBGIO, net_device::dev, sky2_port::duplex, DUPLEX_FULL, DUPLEX_HALF, gm_phy_read(), net_device::name, sky2_port::netdev, PFX, PHY_M_IS_AN_COMPL, PHY_M_IS_DUP_CHANGE, PHY_M_IS_LSP_CHANGE, PHY_M_IS_LST_CHANGE, PHY_M_PS_FULL_DUP, PHY_M_PS_LINK_UP, PHY_MARV_INT_STAT, PHY_MARV_PHY_STAT, port, net_device::priv, sky2_autoneg_done(), sky2_link_down(), sky2_link_up(), sky2_phy_speed(), and sky2_port::speed.

Referenced by sky2_poll().

◆ receive_new()

static struct io_buffer* receive_new ( struct sky2_port sky2,
struct rx_ring_info re,
unsigned int  length 
)
static

Definition at line 1545 of file sky2.c.

1548 {
1549  struct io_buffer *iob, *niob;
1550  unsigned hdr_space = sky2->rx_data_size;
1551 
1552  /* Don't be tricky about reusing pages (yet) */
1553  niob = sky2_rx_alloc(sky2);
1554  if (!niob)
1555  return NULL;
1556 
1557  iob = re->iob;
1558 
1559  re->iob = niob;
1560  sky2_rx_map_iob(sky2->hw->pdev, re, hdr_space);
1561 
1562  iob_put(iob, length);
1563  return iob;
1564 }
u16 length
Definition: sky2.h:9
struct sky2_hw * hw
Definition: sky2.h:2040
#define iob_put(iobuf, len)
Definition: iobuf.h:120
struct pci_device * pdev
Definition: sky2.h:2068
static struct io_buffer * sky2_rx_alloc(struct sky2_port *sky2)
Definition: sky2.c:1008
u16 rx_data_size
Definition: sky2.h:2054
static void sky2_rx_map_iob(struct pci_device *pdev __unused, struct rx_ring_info *re, unsigned size __unused)
Definition: sky2.c:933
struct io_buffer * iob
Definition: sky2.h:2027
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A persistent I/O buffer.
Definition: iobuf.h:33

References sky2_port::hw, rx_ring_info::iob, iob_put, length, NULL, sky2_hw::pdev, sky2_port::rx_data_size, sky2_rx_alloc(), and sky2_rx_map_iob().

Referenced by sky2_receive().

◆ sky2_receive()

static struct io_buffer* sky2_receive ( struct net_device dev,
u16  length,
u32  status 
)
static

Definition at line 1570 of file sky2.c.

1572 {
1573  struct sky2_port *sky2 = dev->priv;
1574  struct rx_ring_info *re = sky2->rx_ring + sky2->rx_next;
1575  struct io_buffer *iob = NULL;
1576  u16 count = (status & GMR_FS_LEN) >> 16;
1577 
1578  DBGIO(PFX "%s: rx slot %d status 0x%x len %d\n",
1579  dev->name, sky2->rx_next, status, length);
1580 
1581  sky2->rx_next = (sky2->rx_next + 1) % RX_PENDING;
1582 
1583  /* This chip has hardware problems that generates bogus status.
1584  * So do only marginal checking and expect higher level protocols
1585  * to handle crap frames.
1586  */
1587  if (sky2->hw->chip_id == CHIP_ID_YUKON_FE_P &&
1588  sky2->hw->chip_rev == CHIP_REV_YU_FE2_A0 &&
1589  length == count)
1590  goto okay;
1591 
1592  if (status & GMR_FS_ANY_ERR)
1593  goto error;
1594 
1595  if (!(status & GMR_FS_RX_OK))
1596  goto resubmit;
1597 
1598  /* if length reported by DMA does not match PHY, packet was truncated */
1599  if (length != count)
1600  goto len_error;
1601 
1602 okay:
1603  iob = receive_new(sky2, re, length);
1604 resubmit:
1605  sky2_rx_submit(sky2, re);
1606 
1607  return iob;
1608 
1609 len_error:
1610  /* Truncation of overlength packets
1611  causes PHY length to not match MAC length */
1612  DBG2(PFX "%s: rx length error: status %#x length %d\n",
1613  dev->name, status, length);
1614 
1615  /* Pass NULL as iob because we want to keep our iob in the
1616  ring for the next packet. */
1617  netdev_rx_err(dev, NULL, -EINVAL);
1618  goto resubmit;
1619 
1620 error:
1621  if (status & GMR_FS_RX_FF_OV) {
1622  DBG2(PFX "%s: FIFO overflow error\n", dev->name);
1623  netdev_rx_err(dev, NULL, -EBUSY);
1624  goto resubmit;
1625  }
1626 
1627  DBG2(PFX "%s: rx error, status 0x%x length %d\n",
1628  dev->name, status, length);
1629  netdev_rx_err(dev, NULL, -EIO);
1630 
1631  goto resubmit;
1632 }
uint16_t u16
Definition: stdint.h:21
#define EINVAL
Invalid argument.
Definition: errno.h:428
u16 length
Definition: sky2.h:9
#define PFX
Definition: sky2.c:46
struct sky2_hw * hw
Definition: sky2.h:2040
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
u8 chip_rev
Definition: sky2.h:2081
#define EBUSY
Device or resource busy.
Definition: errno.h:338
#define RX_PENDING
Definition: sky2.c:64
struct arbelprm_completion_with_error error
Definition: arbel.h:12
static void sky2_rx_submit(struct sky2_port *sky2, const struct rx_ring_info *re)
Definition: sky2.c:926
static struct io_buffer * receive_new(struct sky2_port *sky2, struct rx_ring_info *re, unsigned int length)
Definition: sky2.c:1545
uint8_t status
Status.
Definition: ena.h:16
void * priv
Driver private data.
Definition: netdevice.h:431
#define DBGIO(...)
Definition: compiler.h:549
struct rx_ring_info * rx_ring
Definition: sky2.h:2049
u16 rx_next
Definition: sky2.h:2052
u8 chip_id
Definition: sky2.h:2080
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
#define EIO
Input/output error.
Definition: errno.h:433
uint16_t count
Number of entries.
Definition: ena.h:22
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define DBG2(...)
Definition: compiler.h:515
A persistent I/O buffer.
Definition: iobuf.h:33

References sky2_hw::chip_id, CHIP_ID_YUKON_FE_P, sky2_hw::chip_rev, CHIP_REV_YU_FE2_A0, count, DBG2, DBGIO, EBUSY, EINVAL, EIO, error, GMR_FS_ANY_ERR, GMR_FS_LEN, GMR_FS_RX_FF_OV, GMR_FS_RX_OK, sky2_port::hw, length, net_device::name, netdev_rx_err(), NULL, PFX, net_device::priv, receive_new(), sky2_port::rx_next, RX_PENDING, sky2_port::rx_ring, sky2_rx_submit(), and status.

Referenced by sky2_status_intr().

◆ sky2_tx_done()

static void sky2_tx_done ( struct net_device dev,
u16  last 
)
inlinestatic

Definition at line 1635 of file sky2.c.

1636 {
1637  struct sky2_port *sky2 = dev->priv;
1638 
1639  sky2_tx_complete(sky2, last);
1640 }
static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
Definition: sky2.c:1281
void * priv
Driver private data.
Definition: netdevice.h:431
uint32_t last
Length to read in last segment, or zero.
Definition: pccrc.h:30

References last, net_device::priv, and sky2_tx_complete().

Referenced by sky2_status_intr().

◆ sky2_status_intr()

static void sky2_status_intr ( struct sky2_hw hw,
u16  idx 
)
static

Definition at line 1643 of file sky2.c.

1644 {
1645  unsigned rx[2] = { 0, 0 };
1646 
1647  rmb();
1648  do {
1649  struct sky2_status_le *le = hw->st_le + hw->st_idx;
1650  unsigned port;
1651  struct net_device *dev;
1652  struct io_buffer *iob;
1653  u32 status;
1654  u16 length;
1655  u8 opcode = le->opcode;
1656 
1657  if (!(opcode & HW_OWNER))
1658  break;
1659 
1660  port = le->css & CSS_LINK_BIT;
1661  dev = hw->dev[port];
1662  length = le16_to_cpu(le->length);
1663  status = le32_to_cpu(le->status);
1664 
1665  hw->st_idx = RING_NEXT(hw->st_idx, STATUS_RING_SIZE);
1666 
1667  le->opcode = 0;
1668  switch (opcode & ~HW_OWNER) {
1669  case OP_RXSTAT:
1670  ++rx[port];
1671  iob = sky2_receive(dev, length, status);
1672  if (!iob) {
1673  netdev_rx_err(dev, NULL, -ENOMEM);
1674  break;
1675  }
1676 
1677  netdev_rx(dev, iob);
1678  break;
1679 
1680  case OP_RXCHKS:
1681  DBG2(PFX "status OP_RXCHKS but checksum offloading disabled\n");
1682  break;
1683 
1684  case OP_TXINDEXLE:
1685  /* TX index reports status for both ports */
1686  assert(TX_RING_SIZE <= 0x1000);
1687  sky2_tx_done(hw->dev[0], status & 0xfff);
1688  if (hw->dev[1])
1689  sky2_tx_done(hw->dev[1],
1690  ((status >> 24) & 0xff)
1691  | (u16)(length & 0xf) << 8);
1692  break;
1693 
1694  default:
1695  DBG(PFX "unknown status opcode 0x%x\n", opcode);
1696  }
1697  } while (hw->st_idx != idx);
1698 
1699  /* Fully processed status ring so clear irq */
1701 
1702  if (rx[0])
1703  sky2_rx_update(hw->dev[0]->priv, Q_R1);
1704 
1705  if (rx[1])
1706  sky2_rx_update(hw->dev[1]->priv, Q_R2);
1707 }
uint16_t u16
Definition: stdint.h:21
u16 length
Definition: sky2.h:9
#define PFX
Definition: sky2.c:46
static void sky2_rx_update(struct sky2_port *sky2, unsigned rxq)
Definition: sky2.c:1034
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
Definition: skge.h:558
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
#define le32_to_cpu(value)
Definition: byteswap.h:113
uint8_t opcode
Opcode.
Definition: ena.h:16
#define RING_NEXT(x, s)
Definition: sky2.c:79
Definition: hw.c:16
uint8_t status
Status.
Definition: ena.h:16
#define rmb()
Definition: io.h:484
#define ENOMEM
Not enough space.
Definition: errno.h:534
u8 port
Port number.
Definition: CIB_PRM.h:31
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define TX_RING_SIZE
Definition: sky2.c:66
A network device.
Definition: netdevice.h:352
static void sky2_tx_done(struct net_device *dev, u16 last)
Definition: sky2.c:1635
Definition: skge.h:557
#define le16_to_cpu(value)
Definition: byteswap.h:112
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:548
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
#define STATUS_RING_SIZE
Definition: sky2.c:71
u16 length
Definition: sky2.h:2015
u32 status
Definition: sky2.h:2014
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition: wpa.h:234
static struct io_buffer * sky2_receive(struct net_device *dev, u16 length, u32 status)
Definition: sky2.c:1570
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
#define DBG2(...)
Definition: compiler.h:515
A persistent I/O buffer.
Definition: iobuf.h:33

References assert(), sky2_status_le::css, CSS_LINK_BIT, DBG, DBG2, net_device::dev, ENOMEM, HW_OWNER, le16_to_cpu, le32_to_cpu, length, sky2_status_le::length, netdev_rx(), netdev_rx_err(), NULL, OP_RXCHKS, OP_RXSTAT, OP_TXINDEXLE, opcode, sky2_status_le::opcode, PFX, port, Q_R1, Q_R2, RING_NEXT, rmb, rx, SC_STAT_CLR_IRQ, sky2_receive(), sky2_rx_update(), sky2_tx_done(), sky2_write32(), STAT_CTRL, status, sky2_status_le::status, STATUS_RING_SIZE, and TX_RING_SIZE.

Referenced by sky2_poll().

◆ sky2_hw_error()

static void sky2_hw_error ( struct sky2_hw hw,
unsigned  port,
u32  status 
)
static

Definition at line 1709 of file sky2.c.

1710 {
1711  struct net_device *dev = hw->dev[port];
1712 
1713  DBGIO(PFX "%s: hw error interrupt status 0x%x\n", dev->name, status);
1714 
1715  if (status & Y2_IS_PAR_RD1) {
1716  DBG(PFX "%s: ram data read parity error\n", dev->name);
1717  /* Clear IRQ */
1719  }
1720 
1721  if (status & Y2_IS_PAR_WR1) {
1722  DBG(PFX "%s: ram data write parity error\n", dev->name);
1724  }
1725 
1726  if (status & Y2_IS_PAR_MAC1) {
1727  DBG(PFX "%s: MAC parity error\n", dev->name);
1729  }
1730 
1731  if (status & Y2_IS_PAR_RX1) {
1732  DBG(PFX "%s: RX parity error\n", dev->name);
1734  }
1735 
1736  if (status & Y2_IS_TCP_TXA1) {
1737  DBG(PFX "%s: TCP segmentation error\n", dev->name);
1739  }
1740 }
#define PFX
Definition: sky2.c:46
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
char name[40]
Name.
Definition: device.h:75
Definition: skge.h:523
Definition: hw.c:16
static const unsigned txqaddr[]
Definition: sky2.c:124
uint8_t status
Status.
Definition: ena.h:16
u8 port
Port number.
Definition: CIB_PRM.h:31
#define DBGIO(...)
Definition: compiler.h:549
A network device.
Definition: netdevice.h:352
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2116
#define SK_REG(port, reg)
Definition: skge.h:2548
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
#define Q_ADDR(reg, offs)
Definition: skge.h:534
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
#define RAM_BUFFER(port, reg)
Definition: sky2.h:245
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static const unsigned rxqaddr[]
Definition: sky2.c:125

References B3_RI_CTRL, BMU_CLR_IRQ_PAR, BMU_CLR_IRQ_TCP, DBG, DBGIO, net_device::dev, GMF_CLI_TX_PE, device::name, PFX, port, Q_ADDR, Q_CSR, RAM_BUFFER, RI_CLR_RD_PERR, RI_CLR_WR_PERR, rxqaddr, SK_REG, sky2_write16(), sky2_write32(), sky2_write8(), status, TX_GMF_CTRL_T, txqaddr, Y2_IS_PAR_MAC1, Y2_IS_PAR_RD1, Y2_IS_PAR_RX1, Y2_IS_PAR_WR1, and Y2_IS_TCP_TXA1.

Referenced by sky2_hw_intr().

◆ sky2_hw_intr()

static void sky2_hw_intr ( struct sky2_hw hw)
static

Definition at line 1742 of file sky2.c.

1743 {
1745  u32 hwmsk = sky2_read32(hw, B0_HWE_IMSK);
1746 
1747  status &= hwmsk;
1748 
1749  if (status & Y2_IS_TIST_OV)
1751 
1752  if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
1753  u16 pci_err;
1754 
1756  pci_err = sky2_pci_read16(hw, PCI_STATUS);
1757  DBG(PFX "PCI hardware error (0x%x)\n", pci_err);
1758 
1760  pci_err | PCI_STATUS_ERROR_BITS);
1762  }
1763 
1764  if (status & Y2_IS_PCI_EXP) {
1765  /* PCI-Express uncorrectable Error occurred */
1766  u32 err;
1767 
1771  0xfffffffful);
1772  DBG(PFX "PCI-Express error (0x%x)\n", err);
1773 
1776  }
1777 
1778  if (status & Y2_HWE_L1_MASK)
1779  sky2_hw_error(hw, 0, status);
1780  status >>= 8;
1781  if (status & Y2_HWE_L1_MASK)
1782  sky2_hw_error(hw, 1, status);
1783 }
uint16_t u16
Definition: stdint.h:21
#define PFX
Definition: sky2.c:46
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
static u16 sky2_pci_read16(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2162
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2096
Definition: hw.c:16
#define PCI_ERR_UNCOR_STATUS
Uncorrectable error status.
Definition: pci.h:125
uint8_t status
Status.
Definition: ena.h:16
static void sky2_pci_write16(struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2172
#define PCI_STATUS_ERROR_BITS
Definition: skge.h:70
#define PCI_STATUS
PCI status.
Definition: pci.h:35
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status)
Definition: sky2.c:1709
uint32_t u32
Definition: stdint.h:23

References B0_HWE_IMSK, B0_HWE_ISRC, B2_TST_CTRL1, DBG, GMAC_TI_ST_CTRL, GMT_ST_CLR_IRQ, PCI_ERR_UNCOR_STATUS, PCI_STATUS, PCI_STATUS_ERROR_BITS, PFX, sky2_hw_error(), sky2_pci_read16(), sky2_pci_write16(), sky2_read32(), sky2_write32(), sky2_write8(), status, TST_CFG_WRITE_OFF, TST_CFG_WRITE_ON, Y2_CFG_AER, Y2_HWE_L1_MASK, Y2_IS_IRQ_STAT, Y2_IS_MST_ERR, Y2_IS_PCI_EXP, and Y2_IS_TIST_OV.

Referenced by sky2_err_intr().

◆ sky2_mac_intr()

static void sky2_mac_intr ( struct sky2_hw hw,
unsigned  port 
)
static

Definition at line 1785 of file sky2.c.

1786 {
1787  struct net_device *dev = hw->dev[port];
1789 
1790  DBGIO(PFX "%s: mac interrupt status 0x%x\n", dev->name, status);
1791 
1792  if (status & GM_IS_RX_CO_OV)
1794 
1795  if (status & GM_IS_TX_CO_OV)
1797 
1798  if (status & GM_IS_RX_FF_OR) {
1800  }
1801 
1802  if (status & GM_IS_TX_FF_UR) {
1804  }
1805 }
#define PFX
Definition: sky2.c:46
char name[40]
Name.
Definition: device.h:75
Definition: hw.c:16
uint8_t status
Status.
Definition: ena.h:16
u8 port
Port number.
Definition: CIB_PRM.h:31
#define DBGIO(...)
Definition: compiler.h:549
A network device.
Definition: netdevice.h:352
#define SK_REG(port, reg)
Definition: skge.h:2548
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
Definition: skge.h:2596
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
static u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2106
uint8_t u8
Definition: stdint.h:19

References DBGIO, net_device::dev, GM_IS_RX_CO_OV, GM_IS_RX_FF_OR, GM_IS_TX_CO_OV, GM_IS_TX_FF_UR, GM_RX_IRQ_SRC, GM_TX_IRQ_SRC, gma_read16(), GMAC_IRQ_SRC, GMF_CLI_RX_FO, GMF_CLI_TX_FU, device::name, PFX, port, RX_GMF_CTRL_T, SK_REG, sky2_read8(), sky2_write8(), status, and TX_GMF_CTRL_T.

Referenced by sky2_err_intr().

◆ sky2_le_error()

static void sky2_le_error ( struct sky2_hw hw,
unsigned  port,
u16  q,
unsigned ring_size  __unused 
)
static

Definition at line 1808 of file sky2.c.

1810 {
1811  struct net_device *dev = hw->dev[port];
1812  struct sky2_port *sky2 = dev->priv;
1813  int idx;
1814  const u64 *le = (q == Q_R1 || q == Q_R2)
1815  ? (u64 *) sky2->rx_le : (u64 *) sky2->tx_le;
1816 
1818  DBG(PFX "%s: descriptor error q=%#x get=%d [%llx] last=%d put=%d should be %d\n",
1819  dev->name, (unsigned) q, idx, (unsigned long long) le[idx],
1822  le == (u64 *)sky2->rx_le? sky2->rx_put : sky2->tx_prod);
1823 
1825 }
static u16 sky2_read16(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2101
#define PFX
Definition: sky2.c:46
Definition: skge.h:558
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
u16 rx_put
Definition: sky2.h:2053
Definition: skge.h:523
Definition: hw.c:16
struct sky2_tx_le * tx_le
Definition: sky2.h:2045
u8 port
Port number.
Definition: CIB_PRM.h:31
void * priv
Driver private data.
Definition: netdevice.h:431
uint64_t u64
Definition: stdint.h:25
#define Y2_QADDR(q, reg)
Definition: sky2.h:679
A network device.
Definition: netdevice.h:352
Definition: skge.h:557
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
u16 tx_prod
Definition: sky2.h:2047
#define Q_ADDR(reg, offs)
Definition: skge.h:534
struct sky2_rx_le * rx_le
Definition: sky2.h:2050
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References BMU_CLR_IRQ_CHK, DBG, net_device::dev, net_device::name, PFX, port, PREF_UNIT_GET_IDX, PREF_UNIT_LAST_IDX, PREF_UNIT_PUT_IDX, net_device::priv, Q_ADDR, Q_CSR, Q_R1, Q_R2, sky2_port::rx_le, sky2_port::rx_put, sky2_read16(), sky2_write32(), sky2_port::tx_le, sky2_port::tx_prod, and Y2_QADDR.

Referenced by sky2_err_intr().

◆ sky2_err_intr()

static void sky2_err_intr ( struct sky2_hw hw,
u32  status 
)
static

Definition at line 1828 of file sky2.c.

1829 {
1830  DBG(PFX "error interrupt status=%#x\n", status);
1831 
1832  if (status & Y2_IS_HW_ERR)
1833  sky2_hw_intr(hw);
1834 
1835  if (status & Y2_IS_IRQ_MAC1)
1836  sky2_mac_intr(hw, 0);
1837 
1838  if (status & Y2_IS_IRQ_MAC2)
1839  sky2_mac_intr(hw, 1);
1840 
1841  if (status & Y2_IS_CHK_RX1)
1843 
1844  if (status & Y2_IS_CHK_RX2)
1846 
1847  if (status & Y2_IS_CHK_TXA1)
1849 
1850  if (status & Y2_IS_CHK_TXA2)
1852 }
#define PFX
Definition: sky2.c:46
Definition: skge.h:558
static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:1785
Definition: hw.c:16
uint8_t status
Status.
Definition: ena.h:16
#define RX_LE_SIZE
Definition: sky2.c:61
#define TX_RING_SIZE
Definition: sky2.c:66
Definition: skge.h:557
static void sky2_le_error(struct sky2_hw *hw, unsigned port, u16 q, unsigned ring_size __unused)
Definition: sky2.c:1808
Definition: skge.h:560
static void sky2_hw_intr(struct sky2_hw *hw)
Definition: sky2.c:1742
Definition: skge.h:562
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References DBG, PFX, Q_R1, Q_R2, Q_XA1, Q_XA2, RX_LE_SIZE, sky2_hw_intr(), sky2_le_error(), sky2_mac_intr(), status, TX_RING_SIZE, Y2_IS_CHK_RX1, Y2_IS_CHK_RX2, Y2_IS_CHK_TXA1, Y2_IS_CHK_TXA2, Y2_IS_HW_ERR, Y2_IS_IRQ_MAC1, and Y2_IS_IRQ_MAC2.

Referenced by sky2_poll().

◆ sky2_poll()

static void sky2_poll ( struct net_device dev)
static

Definition at line 1854 of file sky2.c.

1855 {
1856  struct sky2_port *sky2 = dev->priv;
1857  struct sky2_hw *hw = sky2->hw;
1859  u16 idx;
1860 
1861  if (status & Y2_IS_ERROR)
1863 
1864  if (status & Y2_IS_IRQ_PHY1)
1865  sky2_phy_intr(hw, 0);
1866 
1867  if (status & Y2_IS_IRQ_PHY2)
1868  sky2_phy_intr(hw, 1);
1869 
1870  while ((idx = sky2_read16(hw, STAT_PUT_IDX)) != hw->st_idx) {
1871  sky2_status_intr(hw, idx);
1872  }
1873 
1874  /* Bug/Errata workaround?
1875  * Need to kick the TX irq moderation timer.
1876  */
1880  }
1882 }
uint16_t u16
Definition: stdint.h:21
static u16 sky2_read16(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2101
struct sky2_hw * hw
Definition: sky2.h:2040
static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:1511
static void sky2_status_intr(struct sky2_hw *hw, u16 idx)
Definition: sky2.c:1643
static void sky2_err_intr(struct sky2_hw *hw, u32 status)
Definition: sky2.c:1828
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2096
Definition: hw.c:16
uint8_t status
Status.
Definition: ena.h:16
void * priv
Driver private data.
Definition: netdevice.h:431
Definition: sky2.h:2066
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
static u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2106
Definition: skge.h:334
uint32_t u32
Definition: stdint.h:23

References B0_Y2_SP_EISR, B0_Y2_SP_LISR, sky2_port::hw, net_device::priv, sky2_err_intr(), sky2_phy_intr(), sky2_read16(), sky2_read32(), sky2_read8(), sky2_status_intr(), sky2_write8(), STAT_PUT_IDX, STAT_TX_TIMER_CTRL, status, TIM_START, TIM_STOP, Y2_IS_ERROR, Y2_IS_IRQ_PHY1, and Y2_IS_IRQ_PHY2.

◆ sky2_mhz()

static u32 sky2_mhz ( const struct sky2_hw hw)
static

Definition at line 1885 of file sky2.c.

1886 {
1887  switch (hw->chip_id) {
1888  case CHIP_ID_YUKON_EC:
1889  case CHIP_ID_YUKON_EC_U:
1890  case CHIP_ID_YUKON_EX:
1891  case CHIP_ID_YUKON_SUPR:
1892  case CHIP_ID_YUKON_UL_2:
1893  return 125;
1894 
1895  case CHIP_ID_YUKON_FE:
1896  return 100;
1897 
1898  case CHIP_ID_YUKON_FE_P:
1899  return 50;
1900 
1901  case CHIP_ID_YUKON_XL:
1902  return 156;
1903 
1904  default:
1905  DBG(PFX "unknown chip ID!\n");
1906  return 100; /* bogus */
1907  }
1908 }
#define PFX
Definition: sky2.c:46
Definition: hw.c:16
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References CHIP_ID_YUKON_EC, CHIP_ID_YUKON_EC_U, CHIP_ID_YUKON_EX, CHIP_ID_YUKON_FE, CHIP_ID_YUKON_FE_P, CHIP_ID_YUKON_SUPR, CHIP_ID_YUKON_UL_2, CHIP_ID_YUKON_XL, DBG, and PFX.

Referenced by sky2_clk2us(), and sky2_us2clk().

◆ sky2_us2clk()

static u32 sky2_us2clk ( const struct sky2_hw hw,
u32  us 
)
inlinestatic

Definition at line 1910 of file sky2.c.

1911 {
1912  return sky2_mhz(hw) * us;
1913 }
static u32 sky2_mhz(const struct sky2_hw *hw)
Definition: sky2.c:1885
Definition: hw.c:16

References sky2_mhz().

Referenced by sky2_reset().

◆ sky2_clk2us()

static u32 sky2_clk2us ( const struct sky2_hw hw,
u32  clk 
)
inlinestatic

Definition at line 1915 of file sky2.c.

1916 {
1917  return clk / sky2_mhz(hw);
1918 }
static u32 sky2_mhz(const struct sky2_hw *hw)
Definition: sky2.c:1885
Definition: hw.c:16

References sky2_mhz().

◆ sky2_init()

static int sky2_init ( struct sky2_hw hw)
static

Definition at line 1920 of file sky2.c.

1921 {
1922  u8 t8;
1923 
1924  /* Enable all clocks and check for bad PCI access */
1926 
1928 
1929  hw->chip_id = sky2_read8(hw, B2_CHIP_ID);
1930  hw->chip_rev = (sky2_read8(hw, B2_MAC_CFG) & CFG_CHIP_R_MSK) >> 4;
1931 
1932  switch(hw->chip_id) {
1933  case CHIP_ID_YUKON_XL:
1935  break;
1936 
1937  case CHIP_ID_YUKON_EC_U:
1938  hw->flags = SKY2_HW_GIGABIT
1941  break;
1942 
1943  case CHIP_ID_YUKON_EX:
1944  hw->flags = SKY2_HW_GIGABIT
1946  | SKY2_HW_NEW_LE
1948  break;
1949 
1950  case CHIP_ID_YUKON_EC:
1951  /* This rev is really old, and requires untested workarounds */
1952  if (hw->chip_rev == CHIP_REV_YU_EC_A1) {
1953  DBG(PFX "unsupported revision Yukon-EC rev A1\n");
1954  return -EOPNOTSUPP;
1955  }
1956  hw->flags = SKY2_HW_GIGABIT;
1957  break;
1958 
1959  case CHIP_ID_YUKON_FE:
1960  break;
1961 
1962  case CHIP_ID_YUKON_FE_P:
1963  hw->flags = SKY2_HW_NEWER_PHY
1964  | SKY2_HW_NEW_LE
1967  break;
1968 
1969  case CHIP_ID_YUKON_SUPR:
1970  hw->flags = SKY2_HW_GIGABIT
1972  | SKY2_HW_NEW_LE
1975  break;
1976 
1977  case CHIP_ID_YUKON_UL_2:
1978  hw->flags = SKY2_HW_GIGABIT
1980  break;
1981 
1982  default:
1983  DBG(PFX "unsupported chip type 0x%x\n", hw->chip_id);
1984  return -EOPNOTSUPP;
1985  }
1986 
1987  hw->pmd_type = sky2_read8(hw, B2_PMD_TYP);
1988  if (hw->pmd_type == 'L' || hw->pmd_type == 'S' || hw->pmd_type == 'P')
1989  hw->flags |= SKY2_HW_FIBRE_PHY;
1990 
1991  hw->ports = 1;
1992  t8 = sky2_read8(hw, B2_Y2_HW_RES);
1993  if ((t8 & CFG_DUAL_MAC_MSK) == CFG_DUAL_MAC_MSK) {
1995  ++hw->ports;
1996  }
1997 
1998  return 0;
1999 }
#define PFX
Definition: sky2.c:46
#define SKY2_HW_NEWER_PHY
Definition: sky2.h:2074
#define SKY2_HW_ADV_POWER_CTL
Definition: sky2.h:2078
Definition: hw.c:16
#define SKY2_HW_GIGABIT
Definition: sky2.h:2073
#define EOPNOTSUPP
Operation not supported on socket.
Definition: errno.h:604
Definition: skge.h:78
#define SKY2_HW_AUTO_TX_SUM
Definition: sky2.h:2077
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
#define SKY2_HW_FIBRE_PHY
Definition: sky2.h:2072
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2106
static void sky2_pci_write32(struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2167
uint8_t u8
Definition: stdint.h:19
#define CFG_DUAL_MAC_MSK
Definition: sky2.h:525
#define SKY2_HW_NEW_LE
Definition: sky2.h:2076

References B0_CTST, B2_CHIP_ID, B2_MAC_CFG, B2_PMD_TYP, B2_Y2_CLK_GATE, B2_Y2_HW_RES, CFG_CHIP_R_MSK, CFG_DUAL_MAC_MSK, CHIP_ID_YUKON_EC, CHIP_ID_YUKON_EC_U, CHIP_ID_YUKON_EX, CHIP_ID_YUKON_FE, CHIP_ID_YUKON_FE_P, CHIP_ID_YUKON_SUPR, CHIP_ID_YUKON_UL_2, CHIP_ID_YUKON_XL, CHIP_REV_YU_EC_A1, CS_RST_CLR, DBG, EOPNOTSUPP, PCI_DEV_REG3, PFX, SKY2_HW_ADV_POWER_CTL, SKY2_HW_AUTO_TX_SUM, SKY2_HW_FIBRE_PHY, SKY2_HW_GIGABIT, SKY2_HW_NEW_LE, SKY2_HW_NEWER_PHY, sky2_pci_write32(), sky2_read8(), sky2_write8(), and Y2_STATUS_LNK2_INAC.

Referenced by sky2_probe().

◆ sky2_reset()

static void sky2_reset ( struct sky2_hw hw)
static

Definition at line 2001 of file sky2.c.

2002 {
2003  u16 status;
2004  int i, cap;
2005  u32 hwe_mask = Y2_HWE_ALL_MASK;
2006 
2007  /* disable ASF */
2008  if (hw->chip_id == CHIP_ID_YUKON_EX) {
2013  } else
2016 
2017  /* do a SW reset */
2020 
2021  /* allow writes to PCI config */
2023 
2024  /* clear PCI errors, if any */
2028 
2030 
2031  cap = pci_find_capability(hw->pdev, PCI_CAP_ID_EXP);
2032  if (cap) {
2034  0xfffffffful);
2035 
2036  /* If an error bit is stuck on ignore it */
2038  DBG(PFX "ignoring stuck error report bit\n");
2039  else
2040  hwe_mask |= Y2_IS_PCI_EXP;
2041  }
2042 
2043  sky2_power_on(hw);
2045 
2046  for (i = 0; i < hw->ports; i++) {
2049 
2050  if (hw->chip_id == CHIP_ID_YUKON_EX ||
2051  hw->chip_id == CHIP_ID_YUKON_SUPR)
2054  | GMC_BYP_RETR_ON);
2055  }
2056 
2057  /* Clear I2C IRQ noise */
2058  sky2_write32(hw, B2_I2C_IRQ, 1);
2059 
2060  /* turn off hardware timer (unused) */
2063 
2065 
2066  /* Turn off descriptor polling */
2068 
2069  /* Turn off receive timestamp */
2072 
2073  /* enable the Tx Arbiters */
2074  for (i = 0; i < hw->ports; i++)
2076 
2077  /* Initialize ram interface */
2078  for (i = 0; i < hw->ports; i++) {
2080 
2093  }
2094 
2095  sky2_write32(hw, B0_HWE_IMSK, hwe_mask);
2096 
2097  for (i = 0; i < hw->ports; i++)
2098  sky2_gmac_reset(hw, i);
2099 
2100  memset(hw->st_le, 0, STATUS_LE_BYTES);
2101  hw->st_idx = 0;
2102 
2105 
2106  sky2_write32(hw, STAT_LIST_ADDR_LO, hw->st_dma);
2107  sky2_write32(hw, STAT_LIST_ADDR_HI, (u64) hw->st_dma >> 32);
2108 
2109  /* Set the list last index */
2111 
2113  sky2_write8(hw, STAT_FIFO_WM, 16);
2114 
2115  /* set Status-FIFO ISR watermark */
2116  if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0)
2118  else
2120 
2124 
2125  /* enable status unit */
2127 
2131 }
uint16_t u16
Definition: stdint.h:21
static u16 sky2_read16(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2101
#define PFX
Definition: sky2.c:46
Definition: sky2.h:893
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
int pci_find_capability(struct pci_device *pci, int cap)
Look for a PCI capability.
Definition: pciextra.c:38
static u16 sky2_pci_read16(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2162
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2096
Definition: hw.c:16
#define PCI_ERR_UNCOR_STATUS
Uncorrectable error status.
Definition: pci.h:125
uint8_t status
Status.
Definition: ena.h:16
static void sky2_pci_write16(struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2172
#define PCI_STATUS_ERROR_BITS
Definition: skge.h:70
uint64_t u64
Definition: stdint.h:25
Definition: sky2.h:432
Definition: skge.h:496
static void sky2_power_on(struct sky2_hw *hw)
Definition: sky2.c:193
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2116
Definition: sky2.h:192
#define SK_REG(port, reg)
Definition: skge.h:2548
#define PCI_STATUS
PCI status.
Definition: pci.h:35
Definition: skge.h:78
#define PCI_CAP_ID_EXP
PCI Express.
Definition: pci.h:97
#define STATUS_LE_BYTES
Definition: sky2.c:72
#define SK_RI_TO_53
Definition: skge.h:442
#define STATUS_RING_SIZE
Definition: sky2.c:71
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition: sky2.h:2121
static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:255
#define RAM_BUFFER(port, reg)
Definition: sky2.h:245
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static u32 sky2_us2clk(const struct sky2_hw *hw, u32 us)
Definition: sky2.c:1910
Definition: skge.h:334
uint32_t u32
Definition: stdint.h:23
void * memset(void *dest, int character, size_t len) __nonnull

References B0_CTST, B0_HWE_IMSK, B0_HWE_ISRC, B0_Y2LED, B28_DPT_CTRL, B28_Y2_ASF_STAT_CMD, B2_I2C_IRQ, B2_TI_CTRL, B2_TST_CTRL1, B3_RI_CTRL, B3_RI_RTO_R1, B3_RI_RTO_R2, B3_RI_RTO_XA1, B3_RI_RTO_XA2, B3_RI_RTO_XS1, B3_RI_RTO_XS2, B3_RI_WTO_R1, B3_RI_WTO_R2, B3_RI_WTO_XA1, B3_RI_WTO_XA2, B3_RI_WTO_XS1, B3_RI_WTO_XS2, CHIP_ID_YUKON_EX, CHIP_ID_YUKON_SUPR, CHIP_ID_YUKON_XL, CS_MRST_CLR, CS_RST_CLR, CS_RST_SET, DBG, DPT_STOP, GMAC_CTRL, GMAC_LINK_CTRL, GMAC_TI_ST_CTRL, GMC_BYP_MACSECRX_ON, GMC_BYP_MACSECTX_ON, GMC_BYP_RETR_ON, GMLC_RST_CLR, GMLC_RST_SET, GMT_ST_CLR_IRQ, GMT_ST_STOP, HCU_CCSR, HCU_CCSR_AHB_RST, HCU_CCSR_CPU_RST_MODE, HCU_CCSR_UC_STATE_MSK, LED_STAT_ON, memset(), PCI_CAP_ID_EXP, PCI_ERR_UNCOR_STATUS, pci_find_capability(), PCI_STATUS, PCI_STATUS_ERROR_BITS, PFX, RAM_BUFFER, RI_RST_CLR, SC_STAT_OP_ON, SC_STAT_RST_CLR, SC_STAT_RST_SET, SK_REG, SK_RI_TO_53, sky2_gmac_reset(), sky2_pci_read16(), sky2_pci_write16(), sky2_power_on(), sky2_read16(), sky2_read32(), sky2_us2clk(), sky2_write16(), sky2_write32(), sky2_write8(), STAT_CTRL, STAT_FIFO_ISR_WM, STAT_FIFO_WM, STAT_ISR_TIMER_CTRL, STAT_ISR_TIMER_INI, STAT_LAST_IDX, STAT_LEV_TIMER_CTRL, STAT_LEV_TIMER_INI, STAT_LIST_ADDR_HI, STAT_LIST_ADDR_LO, STAT_TX_IDX_TH, STAT_TX_TIMER_CTRL, STAT_TX_TIMER_INI, status, STATUS_LE_BYTES, STATUS_RING_SIZE, TIM_CLR_IRQ, TIM_START, TIM_STOP, TST_CFG_WRITE_OFF, TST_CFG_WRITE_ON, TXA_CTRL, TXA_ENA_ARB, Y2_ASF_DISABLE, Y2_ASF_RESET, Y2_CFG_AER, Y2_HWE_ALL_MASK, and Y2_IS_PCI_EXP.

Referenced by sky2_probe().

◆ sky2_supported_modes()

static u32 sky2_supported_modes ( const struct sky2_hw hw)
static

Definition at line 2133 of file sky2.c.

2134 {
2135  if (sky2_is_copper(hw)) {
2136  u32 modes = SUPPORTED_10baseT_Half
2141 
2142  if (hw->flags & SKY2_HW_GIGABIT)
2143  modes |= SUPPORTED_1000baseT_Half
2145  return modes;
2146  } else
2150  | SUPPORTED_FIBRE;
2151 }
#define SUPPORTED_1000baseT_Half
Definition: skge.h:62
#define SUPPORTED_Autoneg
Definition: skge.h:64
#define SUPPORTED_100baseT_Full
Definition: skge.h:61
Definition: hw.c:16
#define SUPPORTED_10baseT_Half
Definition: skge.h:58
#define SUPPORTED_TP
Definition: skge.h:65
#define SKY2_HW_GIGABIT
Definition: sky2.h:2073
static int sky2_is_copper(const struct sky2_hw *hw)
Definition: sky2.h:2090
#define SUPPORTED_10baseT_Full
Definition: skge.h:59
#define SUPPORTED_100baseT_Half
Definition: skge.h:60
#define SUPPORTED_FIBRE
Definition: skge.h:66
#define SUPPORTED_1000baseT_Full
Definition: skge.h:63
uint32_t u32
Definition: stdint.h:23

References SKY2_HW_GIGABIT, sky2_is_copper(), SUPPORTED_1000baseT_Full, SUPPORTED_1000baseT_Half, SUPPORTED_100baseT_Full, SUPPORTED_100baseT_Half, SUPPORTED_10baseT_Full, SUPPORTED_10baseT_Half, SUPPORTED_Autoneg, SUPPORTED_FIBRE, and SUPPORTED_TP.

Referenced by sky2_init_netdev().

◆ sky2_init_netdev()

static struct net_device* sky2_init_netdev ( struct sky2_hw hw,
unsigned  port 
)
static

Definition at line 2179 of file sky2.c.

2181 {
2182  struct sky2_port *sky2;
2183  struct net_device *dev = alloc_etherdev(sizeof(*sky2));
2184 
2185  if (!dev) {
2186  DBG(PFX "etherdev alloc failed\n");
2187  return NULL;
2188  }
2189 
2190  dev->dev = &hw->pdev->dev;
2191 
2192  sky2 = dev->priv;
2193  sky2->netdev = dev;
2194  sky2->hw = hw;
2195 
2196  /* Auto speed and flow control */
2197  sky2->autoneg = AUTONEG_ENABLE;
2198  sky2->flow_mode = FC_BOTH;
2199 
2200  sky2->duplex = -1;
2201  sky2->speed = -1;
2203 
2204  hw->dev[port] = dev;
2205 
2206  sky2->port = port;
2207 
2208  /* read the mac address */
2209  memcpy(dev->hw_addr, (void *)(hw->regs + B2_MAC_1 + port * 8), ETH_ALEN);
2210 
2211  return dev;
2212 }
#define PFX
Definition: sky2.c:46
struct sky2_hw * hw
Definition: sky2.h:2040
static u32 sky2_supported_modes(const struct sky2_hw *hw)
Definition: sky2.c:2133
Definition: sky2.h:2036
#define AUTONEG_ENABLE
Definition: bnx2.h:4584
Definition: hw.c:16
u16 speed
Definition: sky2.h:2059
u8 duplex
Definition: sky2.h:2061
void * memcpy(void *dest, const void *src, size_t len) __nonnull
u8 port
Port number.
Definition: CIB_PRM.h:31
struct net_device * netdev
Definition: sky2.h:2041
u8 autoneg
Definition: sky2.h:2060
A network device.
Definition: netdevice.h:352
#define ETH_ALEN
Definition: if_ether.h:8
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
enum flow_control flow_mode
Definition: sky2.h:2062
unsigned port
Definition: sky2.h:2042
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
u16 advertising
Definition: sky2.h:2058
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
Definition: skge.h:101

References sky2_port::advertising, alloc_etherdev(), sky2_port::autoneg, AUTONEG_ENABLE, B2_MAC_1, DBG, net_device::dev, sky2_port::duplex, ETH_ALEN, FC_BOTH, sky2_port::flow_mode, sky2_port::hw, memcpy(), sky2_port::netdev, NULL, PFX, port, sky2_port::port, sky2_supported_modes(), and sky2_port::speed.

Referenced by sky2_probe().

◆ sky2_show_addr()

static void sky2_show_addr ( struct net_device dev)
static

Definition at line 2214 of file sky2.c.

2215 {
2216  DBG2(PFX "%s: addr %s\n", dev->name, netdev_addr(dev));
2217 }
#define PFX
Definition: sky2.c:46
char name[40]
Name.
Definition: device.h:75
static const char * netdev_addr(struct net_device *netdev)
Get printable network device link-layer address.
Definition: netdevice.h:538
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
#define DBG2(...)
Definition: compiler.h:515

References DBG2, net_device::dev, device::name, netdev_addr(), and PFX.

Referenced by sky2_probe().

◆ sky2_net_irq()

static void sky2_net_irq ( struct net_device dev,
int  enable 
)
static

Definition at line 2242 of file sky2.c.

2243 {
2244  struct sky2_port *sky2 = dev->priv;
2245  struct sky2_hw *hw = sky2->hw;
2246 
2247  u32 imask = sky2_read32(hw, B0_IMSK);
2248  if (enable)
2249  imask |= portirq_msk[sky2->port];
2250  else
2251  imask &= ~portirq_msk[sky2->port];
2252  sky2_write32(hw, B0_IMSK, imask);
2253 }
struct sky2_hw * hw
Definition: sky2.h:2040
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
static const u32 portirq_msk[]
Definition: sky2.c:126
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2096
Definition: hw.c:16
Definition: skge.h:82
void * priv
Driver private data.
Definition: netdevice.h:431
Definition: sky2.h:2066
unsigned port
Definition: sky2.h:2042
uint32_t u32
Definition: stdint.h:23

References B0_IMSK, sky2_port::hw, sky2_port::port, portirq_msk, net_device::priv, sky2_read32(), and sky2_write32().

◆ sky2_probe()

static int sky2_probe ( struct pci_device pdev)
static

Definition at line 2263 of file sky2.c.

2264 {
2265  struct net_device *dev;
2266  struct sky2_hw *hw;
2267  int err;
2268  char buf1[16] __unused; /* only for debugging */
2269 
2271 
2272  err = -ENOMEM;
2273  hw = zalloc(sizeof(*hw));
2274  if (!hw) {
2275  DBG(PFX "cannot allocate hardware struct\n");
2276  goto err_out;
2277  }
2278 
2279  hw->pdev = pdev;
2280 
2281  hw->regs = (unsigned long)pci_ioremap(pdev, pci_bar_start(pdev, PCI_BASE_ADDRESS_0), 0x4000);
2282  if (!hw->regs) {
2283  DBG(PFX "cannot map device registers\n");
2284  goto err_out_free_hw;
2285  }
2286 
2287  /* ring for status responses */
2289  if (!hw->st_le)
2290  goto err_out_iounmap;
2291  hw->st_dma = virt_to_bus(hw->st_le);
2292  memset(hw->st_le, 0, STATUS_LE_BYTES);
2293 
2294  err = sky2_init(hw);
2295  if (err)
2296  goto err_out_iounmap;
2297 
2298 #if DBGLVL_MAX
2299  DBG2(PFX "Yukon-2 %s chip revision %d\n",
2300  sky2_name(hw->chip_id, buf1, sizeof(buf1)), hw->chip_rev);
2301 #endif
2302 
2303  sky2_reset(hw);
2304 
2305  dev = sky2_init_netdev(hw, 0);
2306  if (!dev) {
2307  err = -ENOMEM;
2308  goto err_out_free_pci;
2309  }
2310 
2312 
2313  err = register_netdev(dev);
2314  if (err) {
2315  DBG(PFX "cannot register net device\n");
2316  goto err_out_free_netdev;
2317  }
2318 
2320 
2322 
2323  if (hw->ports > 1) {
2324  struct net_device *dev1;
2325 
2326  dev1 = sky2_init_netdev(hw, 1);
2327  if (!dev1)
2328  DBG(PFX "allocation for second device failed\n");
2329  else if ((err = register_netdev(dev1))) {
2330  DBG(PFX "register of second port failed (%d)\n", err);
2331  hw->dev[1] = NULL;
2332  netdev_nullify(dev1);
2333  netdev_put(dev1);
2334  } else
2335  sky2_show_addr(dev1);
2336  }
2337 
2338  pci_set_drvdata(pdev, hw);
2339 
2340  return 0;
2341 
2342 err_out_free_netdev:
2344  netdev_put(dev);
2345 err_out_free_pci:
2347  free_phys(hw->st_le, STATUS_LE_BYTES);
2348 err_out_iounmap:
2349  iounmap((void *)hw->regs);
2350 err_out_free_hw:
2351  free(hw);
2352 err_out:
2353  pci_set_drvdata(pdev, NULL);
2354  return err;
2355 }
#define PFX
Definition: sky2.c:46
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.h:62
#define PCI_BASE_ADDRESS_0
Definition: pci.h:62
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:154
struct pci_device * pdev
Definition: sky2.h:2068
Definition: hw.c:16
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:515
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:359
#define ENOMEM
Not enough space.
Definition: errno.h:534
Definition: skge.h:82
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 netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition: pci.c:96
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
static struct net_device * sky2_init_netdev(struct sky2_hw *hw, unsigned port)
Definition: sky2.c:2179
A network device.
Definition: netdevice.h:352
static void sky2_reset(struct sky2_hw *hw)
Definition: sky2.c:2001
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
Definition: skge.h:78
static void sky2_show_addr(struct net_device *dev)
Definition: sky2.c:2214
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
static int sky2_init(struct sky2_hw *hw)
Definition: sky2.c:1920
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
#define STATUS_LE_BYTES
Definition: sky2.c:72
Definition: sky2.h:2066
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 struct net_device_operations sky2_operations
Definition: sky2.c:2255
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
#define STATUS_RING_ALIGN
Definition: sky2.c:73
struct net_device * dev[2]
Definition: sky2.h:2069
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define DBG2(...)
Definition: compiler.h:515
void * memset(void *dest, int character, size_t len) __nonnull

References __unused, adjust_pci_device(), B0_CTST, B0_IMSK, CS_RST_SET, DBG, DBG2, net_device::dev, sky2_hw::dev, ENOMEM, free, free_phys(), iounmap(), malloc_phys(), memset(), netdev_init(), netdev_nullify(), netdev_put(), NULL, pci_bar_start(), PCI_BASE_ADDRESS_0, pci_ioremap(), pci_set_drvdata(), sky2_hw::pdev, PFX, register_netdev(), sky2_init(), sky2_init_netdev(), sky2_operations, sky2_reset(), sky2_show_addr(), sky2_write32(), sky2_write8(), STATUS_LE_BYTES, STATUS_RING_ALIGN, virt_to_bus(), Y2_IS_BASE, and zalloc().

◆ sky2_remove()

static void sky2_remove ( struct pci_device pdev)
static

Definition at line 2357 of file sky2.c.

2358 {
2359  struct sky2_hw *hw = pci_get_drvdata(pdev);
2360  int i;
2361 
2362  if (!hw)
2363  return;
2364 
2365  for (i = hw->ports-1; i >= 0; --i)
2366  unregister_netdev(hw->dev[i]);
2367 
2368  sky2_write32(hw, B0_IMSK, 0);
2369 
2370  sky2_power_aux(hw);
2371 
2374  sky2_read8(hw, B0_CTST);
2375 
2376  free_phys(hw->st_le, STATUS_LE_BYTES);
2377 
2378  for (i = hw->ports-1; i >= 0; --i) {
2379  netdev_nullify(hw->dev[i]);
2380  netdev_put(hw->dev[i]);
2381  }
2382 
2383  iounmap((void *)hw->regs);
2384  free(hw);
2385 
2387 }
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition: sky2.h:2111
struct pci_device * pdev
Definition: sky2.h:2068
Definition: hw.c:16
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:359
Definition: skge.h:82
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
Definition: sky2.h:2116
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
Definition: sky2.h:192
Definition: skge.h:78
#define STATUS_LE_BYTES
Definition: sky2.c:72
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:369
Definition: sky2.h:2066
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 free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
static u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
Definition: sky2.h:2106
static void sky2_power_aux(struct sky2_hw *hw)
Definition: sky2.c:237
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References B0_CTST, B0_IMSK, B0_Y2LED, CS_RST_SET, free, free_phys(), iounmap(), LED_STAT_OFF, netdev_nullify(), netdev_put(), NULL, pci_get_drvdata(), pci_set_drvdata(), sky2_hw::pdev, sky2_power_aux(), sky2_read8(), sky2_write16(), sky2_write32(), sky2_write8(), STATUS_LE_BYTES, and unregister_netdev().

Variable Documentation

◆ sky2_id_table

struct pci_device_id sky2_id_table[]
static

Definition at line 81 of file sky2.c.

◆ txqaddr

const unsigned txqaddr[] = { Q_XA1, Q_XA2 }
static

Definition at line 124 of file sky2.c.

Referenced by sky2_down(), sky2_hw_error(), sky2_up(), and sky2_xmit_frame().

◆ rxqaddr

const unsigned rxqaddr[] = { Q_R1, Q_R2 }
static

Definition at line 125 of file sky2.c.

Referenced by rx_set_checksum(), sky2_hw_error(), sky2_rx_start(), sky2_rx_stop(), and sky2_up().

◆ portirq_msk

const u32 portirq_msk[] = { Y2_IS_PORT_1, Y2_IS_PORT_2 }
static

Definition at line 126 of file sky2.c.

Referenced by sky2_down(), sky2_net_irq(), and sky2_up().

◆ copper_fc_adv

const u16 copper_fc_adv[]
static
Initial value:

Definition at line 273 of file sky2.c.

Referenced by sky2_phy_init().

◆ fiber_fc_adv

const u16 fiber_fc_adv[]
static

◆ gm_fc_disable

const u16 gm_fc_disable[]
static
Initial value:

Definition at line 289 of file sky2.c.

Referenced by sky2_phy_init().

◆ phy_power

const u32 phy_power[] = { PCI_Y2_PHY1_POWD, PCI_Y2_PHY2_POWD }
static

Definition at line 592 of file sky2.c.

Referenced by sky2_phy_power_down(), and sky2_phy_power_up().

◆ coma_mode

const u32 coma_mode[] = { PCI_Y2_PHY1_COMA, PCI_Y2_PHY2_COMA }
static

Definition at line 593 of file sky2.c.

Referenced by sky2_phy_power_up().

◆ sky2_operations

struct net_device_operations sky2_operations
static
Initial value:
= {
.open = sky2_up,
.close = sky2_down,
.transmit = sky2_xmit_frame,
.poll = sky2_poll,
.irq = sky2_net_irq
}
static void sky2_net_irq(struct net_device *dev, int enable)
Definition: sky2.c:2242
static int sky2_up(struct net_device *dev)
Definition: sky2.c:1129
static void sky2_poll(struct net_device *dev)
Definition: sky2.c:1854
static void sky2_down(struct net_device *dev)
Definition: sky2.c:1312
static int sky2_xmit_frame(struct net_device *dev, struct io_buffer *iob)
Definition: sky2.c:1238

Definition at line 2255 of file sky2.c.

Referenced by sky2_probe().

◆ __pci_driver

struct pci_driver sky2_driver __pci_driver
Initial value:
= {
.ids = sky2_id_table,
.id_count = (sizeof (sky2_id_table) / sizeof (sky2_id_table[0])),
.probe = sky2_probe,
}
static void sky2_remove(struct pci_device *pdev)
Definition: sky2.c:2357
static int sky2_probe(struct pci_device *pdev)
Definition: sky2.c:2263
static struct pci_device_id sky2_id_table[]
Definition: sky2.c:81
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39

Definition at line 2389 of file sky2.c.