iPXE
sky2.c File Reference
#include <stdint.h>
#include <string.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)

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 45 of file sky2.c.

◆ DRV_VERSION

#define DRV_VERSION   "1.22"

Definition at line 46 of file sky2.c.

◆ PFX

#define PFX   DRV_NAME " "

Definition at line 47 of file sky2.c.

◆ RX_LE_SIZE

#define RX_LE_SIZE   128

Definition at line 62 of file sky2.c.

Referenced by sky2_err_intr(), sky2_next_rx(), and sky2_rx_start().

◆ RX_LE_BYTES

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

Definition at line 63 of file sky2.c.

Referenced by sky2_free_rings(), sky2_rx_clean(), and sky2_up().

◆ RX_RING_ALIGN

#define RX_RING_ALIGN   4096

Definition at line 64 of file sky2.c.

◆ RX_PENDING

#define RX_PENDING   (RX_LE_SIZE/6 - 2)

Definition at line 65 of file sky2.c.

Referenced by sky2_receive(), sky2_rx_clean(), sky2_rx_start(), and sky2_up().

◆ TX_RING_SIZE

#define TX_RING_SIZE   128

Definition at line 67 of file sky2.c.

◆ TX_PENDING

#define TX_PENDING   (TX_RING_SIZE - 1)

Definition at line 68 of file sky2.c.

Referenced by tx_avail().

◆ TX_RING_ALIGN

#define TX_RING_ALIGN   4096

Definition at line 69 of file sky2.c.

◆ MAX_SKB_TX_LE

#define MAX_SKB_TX_LE   4

Definition at line 70 of file sky2.c.

◆ STATUS_RING_SIZE

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

Definition at line 72 of file sky2.c.

Referenced by sky2_reset(), and sky2_status_intr().

◆ STATUS_LE_BYTES

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

Definition at line 73 of file sky2.c.

Referenced by sky2_probe(), sky2_remove(), and sky2_reset().

◆ STATUS_RING_ALIGN

#define STATUS_RING_ALIGN   4096

Definition at line 74 of file sky2.c.

Referenced by sky2_probe().

◆ PHY_RETRIES

#define PHY_RETRIES   1000

Definition at line 75 of file sky2.c.

◆ SKY2_EEPROM_MAGIC

#define SKY2_EEPROM_MAGIC   0x9955aabb

Definition at line 77 of file sky2.c.

◆ RING_NEXT

#define RING_NEXT ( x,
s )
Value:
(((x)+1) & ((s)-1))
static unsigned int x
Definition pixbuf.h:63

Definition at line 80 of file sky2.c.

Referenced by get_tx_le(), sky2_next_rx(), sky2_status_intr(), and sky2_tx_complete().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_ONLY )

◆ sky2_set_multicast()

void sky2_set_multicast ( struct net_device * dev)
static

Definition at line 2154 of file sky2.c.

2155{
2156 struct sky2_port *sky2 = dev->priv;
2157 struct sky2_hw *hw = sky2->hw;
2158 unsigned port = sky2->port;
2159 u16 reg;
2160 u8 filter[8];
2161
2164
2165 memset(filter, 0xff, sizeof(filter));
2166
2168 (u16) filter[0] | ((u16) filter[1] << 8));
2170 (u16) filter[2] | ((u16) filter[3] << 8));
2172 (u16) filter[4] | ((u16) filter[5] << 8));
2174 (u16) filter[6] | ((u16) filter[7] << 8));
2175
2177}
u8 port
Port number.
Definition CIB_PRM.h:3
#define u8
Definition igbvf_osdep.h:40
void * memset(void *dest, int character, size_t len) __nonnull
static unsigned int unsigned int reg
Definition myson.h:162
UINT8_t filter
Receive packet filter.
Definition pxe_api.h:11
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
Definition skge.h:2607
@ GM_RX_CTRL
Definition skge.h:1680
@ GM_MC_ADDR_H1
Definition skge.h:1693
@ GM_MC_ADDR_H4
Definition skge.h:1696
@ GM_MC_ADDR_H3
Definition skge.h:1695
@ GM_MC_ADDR_H2
Definition skge.h:1694
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
Definition skge.h:2596
@ GM_RXCR_UCF_ENA
Definition skge.h:1823
Definition hw.c:16
void * priv
Driver private data.
Definition netdevice.h:432
struct sky2_hw * hw
Definition sky2.h:2040
unsigned port
Definition sky2.h:2042
#define u16
Definition vga.h:20

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, reg, u16, and u8.

Referenced by sky2_up().

◆ gm_phy_write()

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

Definition at line 132 of file sky2.c.

133{
134 int i;
135
139
140 for (i = 0; i < PHY_RETRIES; i++) {
142 if (ctrl == 0xffff)
143 goto io_error;
144
145 if (!(ctrl & GM_SMI_CT_BUSY))
146 return 0;
147
148 udelay(10);
149 }
150
151 DBG(PFX "%s: phy write timeout\n", hw->dev[port]->name);
152 return -ETIMEDOUT;
153
154io_error:
155 DBG(PFX "%s: phy I/O error\n", hw->dev[port]->name);
156 return -EIO;
157}
uint8_t ctrl
Ring control.
Definition dwmac.h:7
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define ETIMEDOUT
Connection timed out.
Definition errno.h:670
#define EIO
Input/output error.
Definition errno.h:434
void __asmcall int val
Definition setjmp.h:12
#define PFX
Definition sis190.h:34
#define GM_SMI_CT_PHY_AD(x)
Definition skge.h:1869
@ GM_SMI_CT_BUSY
Definition skge.h:1866
@ GM_SMI_CTRL
Definition skge.h:1709
@ GM_SMI_DATA
Definition skge.h:1710
#define PHY_RETRIES
Definition skge.h:28
@ PHY_ADDR_MARV
Definition skge.h:587
#define GM_SMI_CT_REG_AD(x)
Definition skge.h:1870
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61

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, u16, 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()

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

Definition at line 159 of file sky2.c.

160{
161 int i;
162
165
166 for (i = 0; i < PHY_RETRIES; i++) {
168 if (ctrl == 0xffff)
169 goto io_error;
170
171 if (ctrl & GM_SMI_CT_RD_VAL) {
173 return 0;
174 }
175
176 udelay(10);
177 }
178
179 DBG(PFX "%s: phy read timeout\n", hw->dev[port]->name);
180 return -ETIMEDOUT;
181io_error:
182 DBG(PFX "%s: phy I/O error\n", hw->dev[port]->name);
183 return -EIO;
184}
@ GM_SMI_CT_OP_RD
Definition skge.h:1864
@ GM_SMI_CT_RD_VAL
Definition skge.h:1865

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, u16, udelay(), and val.

Referenced by gm_phy_read().

◆ gm_phy_read()

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

Definition at line 186 of file sky2.c.

187{
188 u16 v = 0;
189 __gm_phy_read(hw, port, reg, &v);
190 return v;
191}
static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
Definition sky2.c:159

References __gm_phy_read(), port, reg, and u16.

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

◆ sky2_power_on()

void sky2_power_on ( struct sky2_hw * hw)
static

Definition at line 194 of file sky2.c.

195{
196 /* switch power to VCC (WA for VAUX problem) */
199
200 /* disable Core Clock Division, */
202
203 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
204 /* enable bits are inverted */
209 else
211
212 if (hw->flags & SKY2_HW_ADV_POWER_CTL) {
213 u32 reg;
214
216
218 /* set all bits to 0 except bits 15..12 and 8 */
221
223 /* set all bits to 0 except bits 28 & 27 */
226
228
229 /* Enable workaround for dev 4.107 on Yukon-Ultra & Extreme */
233
235 }
236}
@ B2_GP_IO
Definition skge.h:128
@ B0_POWER_CTRL
Definition skge.h:80
@ CHIP_ID_YUKON_XL
Definition skge.h:322
@ PC_VCC_ENA
Definition skge.h:214
@ PC_VAUX_OFF
Definition skge.h:217
@ PC_VAUX_ENA
Definition skge.h:212
@ PC_VCC_ON
Definition skge.h:218
static u32 sky2_pci_read32(const struct sky2_hw *hw, unsigned reg)
Definition sky2.h:2157
@ P_CTL_TIM_VMAIN_AV_MSK
Definition sky2.h:114
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
Definition sky2.h:2096
@ P_ASPM_CONTROL_MSK
Definition sky2.h:104
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
Definition sky2.h:2111
@ B2_Y2_CLK_CTRL
Definition sky2.h:218
@ B2_Y2_CLK_GATE
Definition sky2.h:215
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
Definition sky2.h:2121
@ PCI_DEV_REG4
Definition sky2.h:49
@ PCI_DEV_REG3
Definition sky2.h:48
@ PCI_CFG_REG_1
Definition sky2.h:52
@ PCI_DEV_REG5
Definition sky2.h:50
static void sky2_pci_write32(struct sky2_hw *hw, unsigned reg, u32 val)
Definition sky2.h:2167
@ Y2_CLK_DIV_DIS
Definition sky2.h:537
@ GLB_GPIO_STAT_RACE_DIS
Definition sky2.h:454
@ Y2_COR_CLK_LNK2_DIS
Definition sky2.h:510
@ Y2_CLK_GAT_LNK2_DIS
Definition sky2.h:509
@ Y2_PCI_CLK_LNK2_DIS
Definition sky2.h:511
@ Y2_COR_CLK_LNK1_DIS
Definition sky2.h:514
@ Y2_PCI_CLK_LNK1_DIS
Definition sky2.h:515
@ Y2_CLK_GAT_LNK1_DIS
Definition sky2.h:513
#define SKY2_HW_ADV_POWER_CTL
Definition sky2.h:2078
#define u32
Definition vga.h:21

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(), u32, 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()

void sky2_power_aux ( struct sky2_hw * hw)
static

Definition at line 238 of file sky2.c.

239{
240 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
242 else
243 /* enable bits are inverted */
248
249 /* switch power to VAUX */
254}
@ B0_CTST
Definition skge.h:78
@ PC_VCC_OFF
Definition skge.h:219
@ PC_VAUX_ON
Definition skge.h:216
@ Y2_VAUX_AVAIL
Definition sky2.h:300

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()

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

Definition at line 256 of file sky2.c.

257{
258 u16 reg;
259
260 /* disable all GMAC IRQ's */
262
263 gma_write16(hw, port, GM_MC_ADDR_H1, 0); /* clear MC hash */
267
271}
@ GM_RXCR_MCF_ENA
Definition skge.h:1824
#define SK_REG(port, reg)
Definition skge.h:2548
@ GMAC_IRQ_MSK
Definition skge.h:911

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, sky2_write8(), and u16.

Referenced by sky2_down(), and sky2_reset().

◆ sky2_phy_init()

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

Definition at line 298 of file sky2.c.

299{
300 struct sky2_port *sky2 = hw->dev[port]->priv;
301 u16 ctrl, ct1000, adv, pg, ledctrl, ledover, reg;
302
303 if (sky2->autoneg == AUTONEG_ENABLE &&
304 !(hw->flags & SKY2_HW_NEWER_PHY)) {
306
310
311 /* on PHY 88E1040 Rev.D0 (and newer) downshift control changed */
312 if (hw->chip_id == CHIP_ID_YUKON_EC)
313 /* set downshift counter to 3x and enable downshift */
315 else
316 /* set master & slave downshift counter to 1x */
317 ectrl |= PHY_M_EC_M_DSC(0) | PHY_M_EC_S_DSC(1);
318
320 }
321
323 if (sky2_is_copper(hw)) {
324 if (!(hw->flags & SKY2_HW_GIGABIT)) {
325 /* enable automatic crossover */
327
328 if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
329 hw->chip_rev == CHIP_REV_YU_FE2_A0) {
330 u16 spec;
331
332 /* Enable Class A driver for FE+ A0 */
336 }
337 } else {
338 /* disable energy detect */
340
341 /* enable automatic crossover */
343
344 /* downshift on PHY 88E1112 and 88E1149 is changed */
345 if (sky2->autoneg == AUTONEG_ENABLE
346 && (hw->flags & SKY2_HW_NEWER_PHY)) {
347 /* set downshift counter to 3x and enable downshift */
350 }
351 }
352 } else {
353 /* workaround for deviation #4.88 (CRC errors) */
354 /* disable Automatic Crossover */
355
357 }
358
360
361 /* special setup for PHY 88E1112 Fiber */
362 if (hw->chip_id == CHIP_ID_YUKON_XL && (hw->flags & SKY2_HW_FIBRE_PHY)) {
364
365 /* Fiber: select 1000BASE-X only mode MAC Specific Ctrl Reg. */
371
372 if (hw->pmd_type == 'P') {
373 /* select page 1 to access Fiber registers */
375
376 /* for SFP-module set SIGDET polarity to low */
380 }
381
383 }
384
386 ct1000 = 0;
387 adv = PHY_AN_CSMA;
388 reg = 0;
389
390 if (sky2->autoneg == AUTONEG_ENABLE) {
391 if (sky2_is_copper(hw)) {
393 ct1000 |= PHY_M_1000C_AFD;
395 ct1000 |= PHY_M_1000C_AHD;
397 adv |= PHY_M_AN_100_FD;
399 adv |= PHY_M_AN_100_HD;
401 adv |= PHY_M_AN_10_FD;
403 adv |= PHY_M_AN_10_HD;
404
405 adv |= copper_fc_adv[sky2->flow_mode];
406 } else { /* special defines for FIBER (88E1040S only) */
408 adv |= PHY_M_AN_1000X_AFD;
410 adv |= PHY_M_AN_1000X_AHD;
411
412 adv |= fiber_fc_adv[sky2->flow_mode];
413 }
414
415 /* Restart Auto-negotiation */
417 } else {
418 /* forced speed/duplex settings */
419 ct1000 = PHY_M_1000C_MSE;
420
421 /* Disable auto update for duplex flow control and speed */
423
424 switch (sky2->speed) {
425 case SPEED_1000:
428 break;
429 case SPEED_100:
432 break;
433 }
434
435 if (sky2->duplex == DUPLEX_FULL) {
438 } else if (sky2->speed < SPEED_1000)
439 sky2->flow_mode = FC_NONE;
440
441
442 reg |= gm_fc_disable[sky2->flow_mode];
443
444 /* Forward pause packets to GMAC? */
445 if (sky2->flow_mode & FC_RX)
447 else
449 }
450
452
453 if (hw->flags & SKY2_HW_GIGABIT)
455
458
459 /* Setup Phy LED's */
461 ledover = 0;
462
463 switch (hw->chip_id) {
464 case CHIP_ID_YUKON_FE:
465 /* on 88E3082 these bits are at 11..9 (shifted left) */
466 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) << 1;
467
469
470 /* delete ACT LED control bits */
472 /* change ACT LED control to blink mode */
475 break;
476
478 /* Enable Link Partner Next Page */
481
482 /* disable Energy Detect and enable scrambler */
485
486 /* set LED2 -> ACT, LED1 -> LINK, LED0 -> SPEED */
490
492 break;
493
494 case CHIP_ID_YUKON_XL:
496
497 /* select page 3 to access LED control register */
499
500 /* set LED Function Control register */
502 (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */
503 PHY_M_LEDC_INIT_CTRL(7) | /* 10 Mbps */
504 PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */
505 PHY_M_LEDC_STA0_CTRL(7))); /* 1000 Mbps */
506
507 /* set Polarity Control register */
515
516 /* restore page register */
518 break;
519
521 case CHIP_ID_YUKON_EX:
524
525 /* select page 3 to access LED control register */
527
528 /* set LED Function Control register */
530 (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */
531 PHY_M_LEDC_INIT_CTRL(8) | /* 10 Mbps */
532 PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */
533 PHY_M_LEDC_STA0_CTRL(7)));/* 1000 Mbps */
534
535 /* set Blink Rate in LED Timer Control Register */
537 ledctrl | PHY_M_LED_BLINK_RT(BLINK_84MS));
538 /* restore page register */
540 break;
541
542 default:
543 /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */
545
546 /* turn off the Rx LED (LED_RX) */
547 ledover |= PHY_M_LED_MO_RX(MO_LED_OFF);
548 }
549
550 if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_UL_2) {
551 /* apply fixes in PHY AFE */
553
554 /* increase differential signal amplitude in 10BASE-T */
555 gm_phy_write(hw, port, 0x18, 0xaa99);
556 gm_phy_write(hw, port, 0x17, 0x2011);
557
558 if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
559 /* fix for IEEE A/B Symmetry failure in 1000BASE-T */
560 gm_phy_write(hw, port, 0x18, 0xa204);
561 gm_phy_write(hw, port, 0x17, 0x2002);
562 }
563
564 /* set page register to 0 */
566 } else if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
567 hw->chip_rev == CHIP_REV_YU_FE2_A0) {
568 /* apply workaround for integrated resistors calibration */
571 } else if (hw->chip_id != CHIP_ID_YUKON_EX &&
572 hw->chip_id < CHIP_ID_YUKON_SUPR) {
573 /* no effect on Yukon-XL */
575
576 if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
577 /* turn on 100 Mbps LED (LED_LINK100) */
578 ledover |= PHY_M_LED_MO_100(MO_LED_ON);
579 }
580
581 if (ledover)
583
584 }
585
586 /* Enable phy interrupt on auto-negotiation complete (or link up) */
587 if (sky2->autoneg == AUTONEG_ENABLE)
589 else
591}
#define SPEED_100
Definition atl1e.h:51
#define SPEED_1000
Definition atl1e.h:52
#define ADVERTISED_1000baseT_Full
Definition bnx2.h:47
#define AUTONEG_DISABLE
Definition bnx2.h:83
#define AUTONEG_ENABLE
Definition bnx2.h:84
#define DUPLEX_FULL
Definition bnx2.h:63
#define ADVERTISED_100baseT_Half
Definition bnx2.h:44
#define ADVERTISED_100baseT_Full
Definition bnx2.h:45
#define ADVERTISED_10baseT_Full
Definition bnx2.h:43
#define ADVERTISED_1000baseT_Half
Definition bnx2.h:46
#define ADVERTISED_10baseT_Half
Definition bnx2.h:42
uint16_t spec
ENA specification version.
Definition ena.h:15
#define PHY_M_LEDC_STA1_CTRL(x)
Definition skge.h:1671
@ PHY_M_EC_DOWN_S_ENA
Definition skge.h:1495
@ PHY_M_EC_M_DSC_MSK
Definition skge.h:1489
@ PHY_M_EC_S_DSC_MSK
Definition skge.h:1491
@ PHY_M_EC_MAC_S_MSK
Definition skge.h:1498
@ GM_GP_CTRL
Definition skge.h:1678
@ PHY_CT_RE_CFG
Definition skge.h:1078
@ PHY_CT_ANE
Definition skge.h:1075
@ PHY_CT_DUP_MD
Definition skge.h:1079
@ PHY_CT_RESET
Definition skge.h:1072
#define PHY_M_EC_M_DSC(x)
Definition skge.h:1504
#define PHY_M_LEDC_STA0_CTRL(x)
Definition skge.h:1672
#define PHY_M_EC_MAC_S(x)
Definition skge.h:1506
#define GM_GPCR_SPEED_1000
Definition skge.h:1807
@ PHY_M_AN_1000X_AHD
Definition skge.h:1367
@ PHY_M_AN_1000X_AFD
Definition skge.h:1368
#define PHY_M_LED_MO_RX(x)
Definition skge.h:1567
@ PULS_170MS
Definition skge.h:1545
@ PHY_M_FELP_LED1_MSK
Definition skge.h:1626
@ PHY_AN_CSMA
Definition skge.h:1138
@ PHY_MARV_INT_MASK
Definition skge.h:1049
@ PHY_MARV_1000T_CTRL
Definition skge.h:1044
@ PHY_MARV_CTRL
Definition skge.h:1034
@ PHY_MARV_LED_CTRL
Definition skge.h:1055
@ PHY_MARV_PHY_STAT
Definition skge.h:1048
@ PHY_MARV_FE_SPEC_2
Definition skge.h:1068
@ PHY_MARV_FE_LED_PAR
Definition skge.h:1064
@ PHY_MARV_PHY_CTRL
Definition skge.h:1047
@ PHY_MARV_AUNE_ADV
Definition skge.h:1038
@ PHY_MARV_PAGE_ADDR
Definition skge.h:1060
@ PHY_MARV_LED_OVER
Definition skge.h:1056
@ PHY_MARV_EXT_ADR
Definition skge.h:1053
@ PHY_MARV_PAGE_DATA
Definition skge.h:1061
@ PHY_MARV_EXT_CTRL
Definition skge.h:1051
@ GMC_PAUSE_ON
Definition skge.h:1954
@ GMC_PAUSE_OFF
Definition skge.h:1955
#define PHY_M_LEDC_INIT_CTRL(x)
Definition skge.h:1670
#define PHY_M_EC_S_DSC(x)
Definition skge.h:1505
@ LED_PAR_CTRL_SPEED
Definition skge.h:1639
@ LED_PAR_CTRL_LINK
Definition skge.h:1640
@ LED_PAR_CTRL_ACT_BL
Definition skge.h:1646
@ PHY_M_1000C_AHD
Definition skge.h:1386
@ PHY_M_1000C_MSE
Definition skge.h:1382
@ PHY_M_1000C_AFD
Definition skge.h:1385
#define PHY_M_LED_PULS_DUR(x)
Definition skge.h:1527
#define PHY_M_FELP_LED1_CTRL(x)
Definition skge.h:1631
#define GM_GPCR_AU_ALL_DIS
Definition skge.h:1808
#define PHY_M_LED_BLINK_RT(x)
Definition skge.h:1528
#define PHY_M_LED_MO_100(x)
Definition skge.h:1565
#define PHY_M_FELP_LED2_CTRL(x)
Definition skge.h:1630
@ PHY_M_IS_AN_COMPL
Definition skge.h:1464
@ PHY_M_LEDC_TX_CTRL
Definition skge.h:1536
@ MAC_TX_CLK_25_MHZ
Definition skge.h:1513
@ CHIP_ID_YUKON_EC
Definition skge.h:323
@ CHIP_ID_YUKON_FE
Definition skge.h:324
@ BLINK_84MS
Definition skge.h:1554
@ GMAC_CTRL
Definition skge.h:908
@ GM_GPCR_DUP_FULL
Definition skge.h:1799
@ GM_GPCR_SPEED_100
Definition skge.h:1801
@ PHY_CT_SP1000
Definition skge.h:1085
@ PHY_CT_SP100
Definition skge.h:1086
#define PHY_M_LEDC_LOS_CTRL(x)
Definition skge.h:1669
@ PHY_M_AN_10_HD
Definition skge.h:1359
@ PHY_M_AN_10_FD
Definition skge.h:1358
@ PHY_M_AN_100_HD
Definition skge.h:1357
@ PHY_M_AN_100_FD
Definition skge.h:1356
@ MO_LED_ON
Definition skge.h:1574
@ MO_LED_OFF
Definition skge.h:1573
@ PHY_M_PC_DIS_SCRAMB
Definition skge.h:1424
@ PHY_M_PC_ENA_LIP_NP
Definition skge.h:1421
@ PHY_M_PC_ENA_ENE_DT
Definition skge.h:1419
@ PHY_M_FESC_SEL_CL_A
Definition skge.h:1657
#define PHY_M_FELP_LED0_CTRL(x)
Definition skge.h:1632
@ PHY_M_PC_ENA_AUTO
Definition skge.h:1413
@ PHY_M_PC_EN_DET_MSK
Definition skge.h:1395
@ PHY_M_PC_MDIX_MSK
Definition skge.h:1397
static const u16 copper_fc_adv[]
Definition sky2.c:274
static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
Definition sky2.c:132
static const u16 gm_fc_disable[]
Definition sky2.c:290
static const u16 fiber_fc_adv[]
Definition sky2.c:282
static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
Definition sky2.c:186
#define PHY_M_PC_DSC(x)
Definition sky2.h:1304
@ CHIP_REV_YU_FE2_A0
Definition sky2.h:495
@ PHY_M_MAC_MD_MSK
Definition sky2.h:1466
@ PHY_M_MAC_MD_1000BX
Definition sky2.h:1470
#define PHY_M_POLC_LOS_CTRL(x)
Definition sky2.h:1348
#define SKY2_HW_NEWER_PHY
Definition sky2.h:2074
static int sky2_is_copper(const struct sky2_hw *hw)
Definition sky2.h:2090
@ PHY_M_PC_DSC_MSK
Definition sky2.h:1299
@ PHY_M_PC_DOWN_S_ENA
Definition sky2.h:1300
@ CHIP_ID_YUKON_SUPR
Definition sky2.h:477
@ CHIP_ID_YUKON_EX
Definition sky2.h:473
@ CHIP_ID_YUKON_UL_2
Definition sky2.h:478
@ CHIP_ID_YUKON_FE_P
Definition sky2.h:476
@ CHIP_ID_YUKON_EC_U
Definition sky2.h:472
#define PHY_M_POLC_STA1_CTRL(x)
Definition sky2.h:1350
#define PHY_M_POLC_STA0_CTRL(x)
Definition sky2.h:1351
#define PHY_M_POLC_LS1_P_MIX(x)
Definition sky2.h:1346
#define SKY2_HW_GIGABIT
Definition sky2.h:2073
@ PHY_M_DEF_MSK
Definition sky2.h:1260
#define SKY2_HW_FIBRE_PHY
Definition sky2.h:2072
@ FC_RX
Definition sky2.h:2035
@ FC_NONE
Definition sky2.h:2033
@ PHY_M_FIB_SIGD_POL
Definition sky2.h:1459
#define PHY_M_EC_DSC_2(x)
Definition sky2.h:1291
#define PHY_M_PC_MDI_XMODE(x)
Definition sky2.h:1185
#define PHY_M_MAC_MODE_SEL(x)
Definition sky2.h:1472
#define PHY_M_POLC_IS0_P_MIX(x)
Definition sky2.h:1347
#define PHY_M_POLC_INIT_CTRL(x)
Definition sky2.h:1349
u16 advertising
Definition sky2.h:2058
u8 autoneg
Definition sky2.h:2060
u16 speed
Definition sky2.h:2059
enum flow_control flow_mode
Definition sky2.h:2062
u8 duplex
Definition sky2.h:2061

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, SPEED_1000, and u16.

Referenced by sky2_link_down(), and sky2_mac_init().

◆ sky2_phy_power_up()

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

Definition at line 596 of file sky2.c.

597{
598 u32 reg1;
599
602 reg1 &= ~phy_power[port];
603
604 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
605 reg1 |= coma_mode[port];
606
610
611 if (hw->chip_id == CHIP_ID_YUKON_FE)
613 else if (hw->flags & SKY2_HW_ADV_POWER_CTL)
615}
#define PCI_DEV_REG1
Definition skge.h:10
@ B2_TST_CTRL1
Definition skge.h:126
@ GPHY_CTRL
Definition skge.h:909
@ TST_CFG_WRITE_ON
Definition skge.h:304
@ TST_CFG_WRITE_OFF
Definition skge.h:305
@ GPC_RST_CLR
Definition skge.h:1984
static const u32 phy_power[]
Definition sky2.c:593
static const u32 coma_mode[]
Definition sky2.c:594

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, TST_CFG_WRITE_ON, and u32.

Referenced by sky2_mac_init().

◆ sky2_phy_power_down()

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

Definition at line 617 of file sky2.c.

618{
619 u32 reg1;
620 u16 ctrl;
621
622 /* release GPHY Control reset */
624
625 /* release GMAC reset */
627
628 if (hw->flags & SKY2_HW_NEWER_PHY) {
629 /* select page 2 to access MAC control register */
631
633 /* allow GMII Power Down */
636
637 /* set page register back to 0 */
639 }
640
641 /* setup General Purpose Control Register */
644
645 if (hw->chip_id != CHIP_ID_YUKON_EC) {
646 if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
647 /* select page 2 to access MAC control register */
649
651 /* enable Power Down */
654
655 /* set page register back to 0 */
657 }
658
659 /* set IEEE compatible Power Down Mode (dev. #4.99) */
661 }
662
665 reg1 |= phy_power[port]; /* set PHY to PowerDown/COMA Mode */
668}
@ PHY_CT_PDOWN
Definition skge.h:1076
@ GMC_RST_CLR
Definition skge.h:1956
@ GM_GPCR_FL_PASS
Definition skge.h:1798
@ PHY_M_PC_POW_D_ENA
Definition sky2.h:1196
@ PHY_M_MAC_GMIF_PUP
Definition sky2.h:1467

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, TST_CFG_WRITE_ON, u16, and u32.

Referenced by sky2_down().

◆ sky2_set_tx_stfwd()

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

Definition at line 670 of file sky2.c.

671{
672 if ( (hw->chip_id == CHIP_ID_YUKON_EX &&
673 hw->chip_rev != CHIP_REV_YU_EX_A0) ||
674 hw->chip_id == CHIP_ID_YUKON_FE_P ||
675 hw->chip_id == CHIP_ID_YUKON_SUPR) {
676 /* disable jumbo frames on devices that support them */
679 } else {
681 }
682}
@ TX_GMF_CTRL_T
Definition skge.h:873
@ CHIP_REV_YU_EX_A0
Definition sky2.h:498
@ TX_STFW_ENA
Definition sky2.h:1764
@ TX_JUMBO_DIS
Definition sky2.h:1770

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()

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

Definition at line 684 of file sky2.c.

685{
686 u16 reg;
687 u32 rx_reg;
688 int i;
689 const u8 *addr = hw->dev[port]->ll_addr;
690
693
695
696 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0 && port == 1) {
697 /* WA DEV_472 -- looks like crossed wires on port 2 */
698 /* clear GMAC 1 Control reset */
700 do {
703 } while (gm_phy_read(hw, 1, PHY_MARV_ID0) != PHY_MARV_ID0_VAL ||
706 }
707
709
710 /* Enable Transmit FIFO Underrun */
712
715
716 /* MIB clear */
719
720 for (i = GM_MIB_CNT_BASE; i <= GM_MIB_CNT_END; i += 4)
721 gma_read16(hw, port, i);
723
724 /* transmit control */
726
727 /* receive control reg: unicast + multicast + no FCS */
730
731 /* transmit flow control */
733
734 /* transmit parameter */
740
741 /* serial mode register */
744
746
747 /* virtual address for data */
749
750 /* physical address: used for pause frames */
752
753 /* ignore counter overflows */
757
758 /* Configure Rx MAC FIFO */
760 rx_reg = GMF_OPER_ON | GMF_RX_F_FL_ON;
761 if (hw->chip_id == CHIP_ID_YUKON_EX ||
762 hw->chip_id == CHIP_ID_YUKON_FE_P)
763 rx_reg |= GMF_RX_OVER_ON;
764
766
767 if (hw->chip_id == CHIP_ID_YUKON_XL) {
768 /* Hardware errata - clear flush mask */
770 } else {
771 /* Flush Rx MAC FIFO on any flow control or error */
773 }
774
775 /* Set threshold to 0xa (64 bytes) + 1 to workaround pause bug */
777 /* Another magic mystery workaround from sk98lin */
778 if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
779 hw->chip_rev == CHIP_REV_YU_FE2_A0)
780 reg = 0x178;
782
783 /* Configure Tx MAC FIFO */
786
787 /* On chips without ram buffer, pause is controlled by MAC level */
788 if (!(hw->flags & SKY2_HW_RAM_BUFFER)) {
791
793 }
794
795 if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
796 hw->chip_rev == CHIP_REV_YU_FE2_A0) {
797 /* disable dynamic watermark */
801 }
802}
uint32_t addr
Buffer address.
Definition dwmac.h:9
#define IPG_DATA_DEF
Definition skge.h:1858
#define TX_COL_DEF
Definition skge.h:1819
@ GM_TX_CTRL
Definition skge.h:1679
@ GM_RX_IRQ_MSK
Definition skge.h:1705
@ GM_SRC_ADDR_2L
Definition skge.h:1688
@ GM_SRC_ADDR_1L
Definition skge.h:1685
@ GM_TR_IRQ_MSK
Definition skge.h:1706
@ GM_TX_IRQ_MSK
Definition skge.h:1704
@ GM_TX_FLOW_CTRL
Definition skge.h:1681
@ GM_PHY_ADDR
Definition skge.h:1711
@ GM_TX_PARAM
Definition skge.h:1682
@ GM_SERIAL_MODE
Definition skge.h:1683
#define TX_IPG_JAM_DATA(x)
Definition skge.h:1842
#define TX_JAM_IPG_VAL(x)
Definition skge.h:1841
@ RX_GMF_FL_THR_DEF
Definition skge.h:1926
@ GMF_RST_CLR
Definition skge.h:1923
@ GMF_OPER_ON
Definition skge.h:1921
@ GMF_RX_F_FL_ON
Definition skge.h:1917
#define GMAC_DEF_MSK
Definition skge.h:2021
@ PHY_MARV_ID1
Definition skge.h:1037
@ PHY_MARV_ID0
Definition skge.h:1036
@ GMC_RST_SET
Definition skge.h:1957
#define TX_JAM_LEN_VAL(x)
Definition skge.h:1840
#define TX_COL_THR(x)
Definition skge.h:1818
@ RX_GMF_CTRL_T
Definition skge.h:726
@ RX_GMF_FL_MSK
Definition skge.h:727
@ RX_GMF_FL_THR
Definition skge.h:728
@ TX_GMF_EA
Definition skge.h:871
static void gma_set_addr(struct skge_hw *hw, int port, int reg, const u8 *addr)
Definition skge.h:2612
#define IPG_DATA_VAL(x)
Definition skge.h:1857
@ GM_RXCR_CRC_DIS
Definition skge.h:1825
@ GM_SMOD_VLAN_ENA
Definition skge.h:1849
@ GMAC_IRQ_SRC
Definition skge.h:910
@ PHY_MARV_ID0_VAL
Definition skge.h:1118
@ PHY_MARV_ID1_Y2
Definition skge.h:1122
@ TX_JAM_LEN_DEF
Definition skge.h:1835
@ TX_JAM_IPG_DEF
Definition skge.h:1836
@ TX_IPG_JAM_DEF
Definition skge.h:1837
@ GPC_RST_SET
Definition skge.h:1985
#define DATA_BLIND_VAL(x)
Definition skge.h:1854
@ GM_PAR_MIB_CLR
Definition skge.h:1874
@ GMR_FS_ANY_ERR
Definition skge.h:1900
#define GM_MIB_CNT_BASE
Definition skge.h:1715
#define DATA_BLIND_DEF
Definition skge.h:1855
static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
Definition sky2.c:596
static void sky2_set_tx_stfwd(struct sky2_hw *hw, unsigned port)
Definition sky2.c:670
static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
Definition sky2.c:298
@ TX_BOF_LIM_DEF
Definition sky2.h:1651
@ GMF_RX_OVER_ON
Definition sky2.h:1729
@ TX_DYN_WM_ENA
Definition sky2.h:1758
static u16 sky2_read16(const struct sky2_hw *hw, unsigned reg)
Definition sky2.h:2101
@ RX_GMF_LP_THR
Definition sky2.h:735
@ RX_GMF_UP_THR
Definition sky2.h:734
#define SKY2_HW_RAM_BUFFER
Definition sky2.h:2075
#define TX_BACK_OFF_LIM(x)
Definition sky2.h:1657
@ GM_MIB_CNT_END
Definition sky2.h:1527
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
Definition sky2.h:2116

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, TX_JAM_LEN_VAL, u16, u32, and u8.

Referenced by sky2_up().

◆ sky2_ramset()

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

Definition at line 805 of file sky2.c.

806{
807 u32 end;
808
809 /* convert from K bytes to qwords used for hw register */
810 start *= 1024/8;
811 space *= 1024/8;
812 end = start + space - 1;
813
819
820 if (q == Q_R1 || q == Q_R2) {
821 u32 tp = space - space/4;
822
823 /* On receive queue's set the thresholds
824 * give receiver priority when > 3/4 full
825 * send pause when down to 2K
826 */
828 sky2_write32(hw, RB_ADDR(q, RB_RX_LTHP), space/2);
829
830 tp = space - 2048/8;
832 sky2_write32(hw, RB_ADDR(q, RB_RX_LTPP), space/4);
833 } else {
834 /* Enable store & forward on Tx queue's because
835 * Tx FIFO is only 1K on Yukon
836 */
838 }
839
842}
uint32_t start
Starting offset.
Definition netvsc.h:1
uint32_t end
Ending offset.
Definition netvsc.h:7
@ RB_ENA_OP_MD
Definition skge.h:828
@ RB_ENA_STFWD
Definition skge.h:826
@ RB_RST_CLR
Definition skge.h:830
@ RB_END
Definition skge.h:540
@ RB_RX_LTPP
Definition skge.h:544
@ RB_RX_LTHP
Definition skge.h:546
@ RB_RX_UTHP
Definition skge.h:545
@ RB_RP
Definition skge.h:542
@ RB_RX_UTPP
Definition skge.h:543
@ RB_CTRL
Definition skge.h:550
@ RB_WP
Definition skge.h:541
@ RB_START
Definition skge.h:539
#define RB_ADDR(offs, queue)
Definition skge.h:590
@ Q_R1
Definition skge.h:557
@ Q_R2
Definition skge.h:558
static u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
Definition sky2.h:2106
static struct tulip_private * tp
Definition tulip.c:442

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, tp, u16, and u32.

Referenced by sky2_up().

◆ sky2_qset()

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

Definition at line 845 of file sky2.c.

846{
851}
#define Q_ADDR(reg, offs)
Definition skge.h:534
@ Q_CSR
Definition skge.h:523
@ Q_WM
Definition sky2.h:637
@ BMU_FIFO_OP_ON
Definition sky2.h:773
@ BMU_OPER_INIT
Definition sky2.h:783
@ BMU_WM_DEFAULT
Definition sky2.h:786
@ BMU_CLR_RESET
Definition sky2.h:782

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

Referenced by sky2_rx_start(), and sky2_up().

◆ sky2_prefetch_init()

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

Definition at line 856 of file sky2.c.

858{
865
867}
@ PREF_UNIT_RST_SET
Definition sky2.h:804
@ PREF_UNIT_OP_ON
Definition sky2.h:801
@ PREF_UNIT_RST_CLR
Definition sky2.h:803
#define Y2_QADDR(q, reg)
Definition sky2.h:679
@ PREF_UNIT_LAST_IDX
Definition sky2.h:667
@ PREF_UNIT_ADDR_LO
Definition sky2.h:668
@ PREF_UNIT_ADDR_HI
Definition sky2.h:669
@ PREF_UNIT_CTRL
Definition sky2.h:666

References addr, 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(), u32, and Y2_QADDR.

Referenced by sky2_rx_start(), and sky2_up().

◆ get_tx_le()

struct sky2_tx_le * get_tx_le ( struct sky2_port * sky2)
inlinestatic

Definition at line 869 of file sky2.c.

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

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()

void tx_init ( struct sky2_port * sky2)
static

Definition at line 878 of file sky2.c.

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

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()

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

Definition at line 889 of file sky2.c.

891{
892 return sky2->tx_ring + (le - sky2->tx_le);
893}
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()

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

Definition at line 896 of file sky2.c.

897{
898 /* Make sure write' to descriptors are complete before we tell hardware */
899 wmb();
901 DBGIO(PFX "queue %#x idx <- %d\n", q, idx);
902}
#define DBGIO(...)
Definition compiler.h:549
#define wmb()
Definition io.h:546
@ PREF_UNIT_PUT_IDX
Definition sky2.h:671

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

Referenced by sky2_rx_update(), and sky2_xmit_frame().

◆ sky2_next_rx()

struct sky2_rx_le * sky2_next_rx ( struct sky2_port * sky2)
inlinestatic

Definition at line 905 of file sky2.c.

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

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()

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

Definition at line 915 of file sky2.c.

917{
918 struct sky2_rx_le *le;
919
920 le = sky2_next_rx(sky2);
921 le->addr = cpu_to_le32(map);
922 le->length = cpu_to_le16(len);
923 le->opcode = op | HW_OWNER;
924}
ring len
Length.
Definition dwmac.h:226
#define cpu_to_le32(value)
Definition byteswap.h:108
#define cpu_to_le16(value)
Definition byteswap.h:107
static __always_inline int struct dma_mapping * map
Definition dma.h:184
static uint16_t struct vmbus_xfer_pages_operations * op
Definition netvsc.h:327
static struct sky2_rx_le * sky2_next_rx(struct sky2_port *sky2)
Definition sky2.c:905
u16 length
Definition sky2.h:2008
u8 opcode
Definition sky2.h:2010
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, sky2_next_rx(), u32, and u8.

Referenced by sky2_rx_submit().

◆ sky2_rx_submit()

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

Definition at line 927 of file sky2.c.

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

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()

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

Definition at line 934 of file sky2.c.

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

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

Referenced by receive_new(), and sky2_rx_start().

◆ rx_set_checksum()

void rx_set_checksum ( struct sky2_port * sky2)
static

Definition at line 944 of file sky2.c.

945{
946 struct sky2_rx_le *le = sky2_next_rx(sky2);
947
948 le->addr = cpu_to_le32((ETH_HLEN << 16) | ETH_HLEN);
949 le->ctrl = 0;
951
952 sky2_write32(sky2->hw,
953 Q_ADDR(rxqaddr[sky2->port], Q_CSR),
955}
#define ETH_HLEN
Definition if_ether.h:10
static const int rxqaddr[]
Definition skge.c:87
@ BMU_DIS_RX_CHKSUM
Definition sky2.h:767
@ OP_TCPSTART
Definition sky2.h:1952

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()

void sky2_rx_stop ( struct sky2_port * sky2)
static

Definition at line 967 of file sky2.c.

968{
969 struct sky2_hw *hw = sky2->hw;
970 unsigned rxq = rxqaddr[sky2->port];
971 int i;
972
973 /* disable the RAM Buffer receive queue */
975
976 for (i = 0; i < 0xffff; i++)
977 if (sky2_read8(hw, RB_ADDR(rxq, Q_RSL))
978 == sky2_read8(hw, RB_ADDR(rxq, Q_RL)))
979 goto stopped;
980
981 DBG(PFX "%s: receiver stop failed\n", sky2->netdev->name);
982stopped:
984
985 /* reset the Rx prefetch unit */
987 wmb();
988}
@ RB_DIS_OP_MD
Definition skge.h:829
@ Q_RSL
Definition sky2.h:640
@ Q_RL
Definition sky2.h:642
@ BMU_RST_SET
Definition sky2.h:780
@ BMU_FIFO_RST
Definition sky2.h:776
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition netdevice.h:363
struct net_device * netdev
Definition sky2.h:2041

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()

void sky2_rx_clean ( struct sky2_port * sky2)
static

Definition at line 991 of file sky2.c.

992{
993 unsigned i;
994
995 memset(sky2->rx_le, 0, RX_LE_BYTES);
996 for (i = 0; i < RX_PENDING; i++) {
997 struct rx_ring_info *re = sky2->rx_ring + i;
998
999 if (re->iob) {
1000 free_iob(re->iob);
1001 re->iob = NULL;
1002 }
1003 }
1004}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition iobuf.c:153
#define RX_LE_BYTES
Definition sky2.c:63
#define RX_PENDING
Definition sky2.c:65
struct rx_ring_info * rx_ring
Definition sky2.h:2049

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()

struct io_buffer * sky2_rx_alloc ( struct sky2_port * sky2)
static

Definition at line 1009 of file sky2.c.

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

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()

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

Definition at line 1035 of file sky2.c.

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

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

Referenced by sky2_rx_start(), and sky2_status_intr().

◆ sky2_rx_start()

int sky2_rx_start ( struct sky2_port * sky2)
static

Definition at line 1046 of file sky2.c.

1047{
1048 struct sky2_hw *hw = sky2->hw;
1049 struct rx_ring_info *re;
1050 unsigned rxq = rxqaddr[sky2->port];
1051 unsigned i, size, thresh;
1052
1053 sky2->rx_put = sky2->rx_next = 0;
1054 sky2_qset(hw, rxq);
1055
1056 /* On PCI express lowering the watermark gives better performance */
1059
1060 /* These chips have no ram buffer?
1061 * MAC Rx RAM Read is controlled by hardware */
1062 if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
1063 (hw->chip_rev == CHIP_REV_YU_EC_U_A1
1064 || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
1066
1067 sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
1068
1069 if (!(hw->flags & SKY2_HW_NEW_LE))
1070 rx_set_checksum(sky2);
1071
1072 /* Space needed for frame data + headers rounded up */
1073 size = (ETH_FRAME_LEN + 8) & ~7;
1074
1075 /* Stopping point for hardware truncation */
1076 thresh = (size - 8) / sizeof(u32);
1077
1078 sky2->rx_data_size = size;
1079
1080 /* Fill Rx ring */
1081 for (i = 0; i < RX_PENDING; i++) {
1082 re = sky2->rx_ring + i;
1083
1084 re->iob = sky2_rx_alloc(sky2);
1085 if (!re->iob)
1086 goto nomem;
1087
1088 sky2_rx_map_iob(hw->pdev, re, sky2->rx_data_size);
1089 sky2_rx_submit(sky2, re);
1090 }
1091
1092 /*
1093 * The receiver hangs if it receives frames larger than the
1094 * packet buffer. As a workaround, truncate oversize frames, but
1095 * the register is limited to 9 bits, so if you do frames > 2052
1096 * you better get the MTU right!
1097 */
1098 if (thresh > 0x1ff)
1100 else {
1101 sky2_write16(hw, SK_REG(sky2->port, RX_GMF_TR_THR), thresh);
1103 }
1104
1105 /* Tell chip about available buffers */
1106 sky2_rx_update(sky2, rxq);
1107 return 0;
1108nomem:
1109 sky2_rx_clean(sky2);
1110 return -ENOMEM;
1111}
uint16_t size
Buffer size.
Definition dwmac.h:3
#define ENOMEM
Not enough space.
Definition errno.h:535
#define ETH_FRAME_LEN
Definition if_ether.h:12
#define PCI_CAP_ID_EXP
PCI Express.
Definition pci.h:98
int pci_find_capability(struct pci_device *pci, int cap)
Look for a PCI capability.
Definition pciextra.c:39
static void sky2_qset(struct sky2_hw *hw, u16 q)
Definition sky2.c:845
static void sky2_rx_clean(struct sky2_port *sky2)
Definition sky2.c:991
static void rx_set_checksum(struct sky2_port *sky2)
Definition sky2.c:944
static void sky2_rx_update(struct sky2_port *sky2, unsigned rxq)
Definition sky2.c:1035
static struct io_buffer * sky2_rx_alloc(struct sky2_port *sky2)
Definition sky2.c:1009
static void sky2_rx_submit(struct sky2_port *sky2, const struct rx_ring_info *re)
Definition sky2.c:927
static void sky2_prefetch_init(struct sky2_hw *hw, u32 qaddr, u64 addr, u32 last)
Definition sky2.c:856
static void sky2_rx_map_iob(struct pci_device *pdev __unused, struct rx_ring_info *re, unsigned size __unused)
Definition sky2.c:934
@ Q_TEST
Definition sky2.h:634
@ RX_TRUNC_OFF
Definition sky2.h:1720
@ RX_TRUNC_ON
Definition sky2.h:1719
#define SKY2_HW_NEW_LE
Definition sky2.h:2076
@ RX_GMF_TR_THR
Definition sky2.h:733
@ F_M_RX_RAM_DIS
Definition sky2.h:657
@ CHIP_REV_YU_EC_U_A1
Definition sky2.h:487
@ CHIP_REV_YU_EC_U_B0
Definition sky2.h:488
@ BMU_WM_PEX
Definition sky2.h:787
u16 rx_next
Definition sky2.h:2052
u32 rx_le_map
Definition sky2.h:2056

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(), sky2_write32(), and u32.

Referenced by sky2_up().

◆ sky2_free_rings()

void sky2_free_rings ( struct sky2_port * sky2)
static

Definition at line 1114 of file sky2.c.

1115{
1116 free_phys(sky2->rx_le, RX_LE_BYTES);
1117 free(sky2->rx_ring);
1118
1119 free_phys(sky2->tx_le, TX_RING_SIZE * sizeof(struct sky2_tx_le));
1120 free(sky2->tx_ring);
1121
1122 sky2->tx_le = NULL;
1123 sky2->rx_le = NULL;
1124
1125 sky2->rx_ring = NULL;
1126 sky2->tx_ring = NULL;
1127}
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition malloc.c:723
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55

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()

int sky2_up ( struct net_device * dev)
static

Definition at line 1130 of file sky2.c.

1131{
1132 struct sky2_port *sky2 = dev->priv;
1133 struct sky2_hw *hw = sky2->hw;
1134 unsigned port = sky2->port;
1135 u32 imask, ramsize;
1136 int err = -ENOMEM;
1137
1139
1140 /* must be power of 2 */
1141 sky2->tx_le = malloc_phys(TX_RING_SIZE * sizeof(struct sky2_tx_le), TX_RING_ALIGN);
1142 sky2->tx_le_map = virt_to_bus(sky2->tx_le);
1143 if (!sky2->tx_le)
1144 goto err_out;
1145 memset(sky2->tx_le, 0, TX_RING_SIZE * sizeof(struct sky2_tx_le));
1146
1147 sky2->tx_ring = zalloc(TX_RING_SIZE * sizeof(struct tx_ring_info));
1148 if (!sky2->tx_ring)
1149 goto err_out;
1150
1151 tx_init(sky2);
1152
1154 sky2->rx_le_map = virt_to_bus(sky2->rx_le);
1155 if (!sky2->rx_le)
1156 goto err_out;
1157 memset(sky2->rx_le, 0, RX_LE_BYTES);
1158
1159 sky2->rx_ring = zalloc(RX_PENDING * sizeof(struct rx_ring_info));
1160 if (!sky2->rx_ring)
1161 goto err_out;
1162
1164
1165 /* Register is number of 4K blocks on internal RAM buffer. */
1166 ramsize = sky2_read8(hw, B2_E_0) * 4;
1167 if (ramsize > 0) {
1168 u32 rxspace;
1169
1170 hw->flags |= SKY2_HW_RAM_BUFFER;
1171 DBG2(PFX "%s: ram buffer %dK\n", dev->name, ramsize);
1172 if (ramsize < 16)
1173 rxspace = ramsize / 2;
1174 else
1175 rxspace = 8 + (2*(ramsize - 16))/3;
1176
1177 sky2_ramset(hw, rxqaddr[port], 0, rxspace);
1178 sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace);
1179
1180 /* Make sure SyncQ is disabled */
1182 RB_RST_SET);
1183 }
1184
1186
1187 /* This is copied from sk98lin 10.0.5.3; no one tells me about erratta's */
1188 if (hw->chip_id == CHIP_ID_YUKON_EX && hw->chip_rev == CHIP_REV_YU_EX_B0)
1190
1191 /* Set almost empty threshold */
1192 if (hw->chip_id == CHIP_ID_YUKON_EC_U
1193 && hw->chip_rev == CHIP_REV_YU_EC_U_A0)
1195
1197 TX_RING_SIZE - 1);
1198
1199 err = sky2_rx_start(sky2);
1200 if (err)
1201 goto err_out;
1202
1203 /* Enable interrupts from phy/mac for port */
1204 imask = sky2_read32(hw, B0_IMSK);
1205 imask |= portirq_msk[port];
1206 sky2_write32(hw, B0_IMSK, imask);
1207
1208 DBGIO(PFX "%s: le bases: st %p [%x], rx %p [%x], tx %p [%x]\n",
1209 dev->name, hw->st_le, hw->st_dma, sky2->rx_le, sky2->rx_le_map,
1210 sky2->tx_le, sky2->tx_le_map);
1211
1213 return 0;
1214
1215err_out:
1216 sky2_free_rings(sky2);
1217 return err;
1218}
#define TX_RING_ALIGN
Definition 3c90x.h:267
#define RX_RING_ALIGN
Definition 3c90x.h:268
#define DBG2(...)
Definition compiler.h:515
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition malloc.c:707
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition netdevice.c:231
static const int txqaddr[]
Definition skge.c:86
@ RB_RST_SET
Definition skge.h:831
@ B0_IMSK
Definition skge.h:82
@ B2_E_0
Definition skge.h:108
@ Q_XS2
Definition skge.h:561
@ Q_XS1
Definition skge.h:559
static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
Definition sky2.c:684
static int sky2_rx_start(struct sky2_port *sky2)
Definition sky2.c:1046
static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space)
Definition sky2.c:805
static void sky2_free_rings(struct sky2_port *sky2)
Definition sky2.c:1114
static void sky2_set_multicast(struct net_device *dev)
Definition sky2.c:2154
static const u32 portirq_msk[]
Definition sky2.c:127
static void tx_init(struct sky2_port *sky2)
Definition sky2.c:878
@ Q_AL
Definition sky2.h:638
@ CHIP_REV_YU_EX_B0
Definition sky2.h:499
@ F_TX_CHK_AUTO_OFF
Definition sky2.h:653
@ ECU_TXFF_LEV
Definition sky2.h:850
@ CHIP_REV_YU_EC_U_A0
Definition sky2.h:486
struct net_device * dev[2]
Definition sky2.h:2069
u32 tx_le_map
Definition sky2.h:2057

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, u32, virt_to_bus(), and zalloc().

◆ tx_dist()

int tx_dist ( unsigned tail,
unsigned head )
inlinestatic

Definition at line 1221 of file sky2.c.

1222{
1223 return (head - tail) & (TX_RING_SIZE - 1);
1224}
uint8_t head
Head number.
Definition int13.h:23

References head, and TX_RING_SIZE.

Referenced by tx_avail().

◆ tx_avail()

int tx_avail ( const struct sky2_port * sky2)
inlinestatic

Definition at line 1227 of file sky2.c.

1228{
1229 return TX_PENDING - tx_dist(sky2->tx_cons, sky2->tx_prod);
1230}
#define TX_PENDING
Definition sky2.c:68
static int tx_dist(unsigned tail, unsigned head)
Definition sky2.c:1221

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

Referenced by sky2_xmit_frame().

◆ sky2_xmit_frame()

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

Definition at line 1239 of file sky2.c.

1240{
1241 struct sky2_port *sky2 = dev->priv;
1242 struct sky2_hw *hw = sky2->hw;
1243 struct sky2_tx_le *le = NULL;
1244 struct tx_ring_info *re;
1245 unsigned len;
1246 u32 mapping;
1247 u8 ctrl;
1248
1249 if (tx_avail(sky2) < 1)
1250 return -EBUSY;
1251
1252 len = iob_len(iob);
1253 mapping = virt_to_bus(iob->data);
1254
1255 DBGIO(PFX "%s: tx queued, slot %d, len %d\n", dev->name,
1256 sky2->tx_prod, len);
1257
1258 ctrl = 0;
1259
1260 le = get_tx_le(sky2);
1261 le->addr = cpu_to_le32((u32) mapping);
1262 le->length = cpu_to_le16(len);
1263 le->ctrl = ctrl;
1264 le->opcode = (OP_PACKET | HW_OWNER);
1265
1266 re = tx_le_re(sky2, le);
1267 re->iob = iob;
1268
1269 le->ctrl |= EOP;
1270
1271 sky2_put_idx(hw, txqaddr[sky2->port], sky2->tx_prod);
1272
1273 return 0;
1274}
#define EBUSY
Device or resource busy.
Definition errno.h:339
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
static struct tx_ring_info * tx_le_re(struct sky2_port *sky2, struct sky2_tx_le *le)
Definition sky2.c:889
static int tx_avail(const struct sky2_port *sky2)
Definition sky2.c:1227
@ EOP
Definition sky2.h:1946
u16 length
Definition sky2.h:2001
struct io_buffer * iob
Definition sky2.h:2021

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, u32, u8, and virt_to_bus().

◆ sky2_tx_complete()

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

Definition at line 1282 of file sky2.c.

1283{
1284 struct net_device *dev = sky2->netdev;
1285 unsigned idx;
1286
1288
1289 for (idx = sky2->tx_cons; idx != done;
1290 idx = RING_NEXT(idx, TX_RING_SIZE)) {
1291 struct sky2_tx_le *le = sky2->tx_le + idx;
1292 struct tx_ring_info *re = sky2->tx_ring + idx;
1293
1294 if (le->ctrl & EOP) {
1295 DBGIO(PFX "%s: tx done %d\n", dev->name, idx);
1296 netdev_tx_complete(dev, re->iob);
1297 }
1298 }
1299
1300 sky2->tx_cons = idx;
1301 mb();
1302}
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
struct bofm_section_header done
Definition bofm_test.c:46
void mb(void)
Memory barrier.
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition netdevice.h:767
A network device.
Definition netdevice.h:353
struct device * dev
Underlying hardware device.
Definition netdevice.h:365

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, TX_RING_SIZE, and u16.

Referenced by sky2_tx_clean(), and sky2_tx_done().

◆ sky2_tx_clean()

void sky2_tx_clean ( struct net_device * dev)
static

Definition at line 1305 of file sky2.c.

1306{
1307 struct sky2_port *sky2 = dev->priv;
1308
1309 sky2_tx_complete(sky2, sky2->tx_prod);
1310}
static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
Definition sky2.c:1282

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

Referenced by sky2_down().

◆ sky2_down()

void sky2_down ( struct net_device * dev)
static

Definition at line 1313 of file sky2.c.

1314{
1315 struct sky2_port *sky2 = dev->priv;
1316 struct sky2_hw *hw = sky2->hw;
1317 unsigned port = sky2->port;
1318 u16 ctrl;
1319 u32 imask;
1320
1321 /* Never really got started! */
1322 if (!sky2->tx_le)
1323 return;
1324
1325 DBG2(PFX "%s: disabling interface\n", dev->name);
1326
1327 /* Disable port IRQ */
1328 imask = sky2_read32(hw, B0_IMSK);
1329 imask &= ~portirq_msk[port];
1330 sky2_write32(hw, B0_IMSK, imask);
1331
1333
1334 /* Stop transmitter */
1337
1340
1344
1346
1347 /* Workaround shared GMAC reset */
1348 if (!(hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0
1349 && port == 0 && hw->dev[1]))
1351
1352 /* Disable Force Sync bit and Enable Alloc bit */
1355
1356 /* Stop Interval Timer and Limit Counter of Tx Arbiter */
1359
1360 /* Reset the PCI FIFO of the async Tx queue */
1363
1364 /* Reset the Tx prefetch units */
1367
1369
1370 sky2_rx_stop(sky2);
1371
1374
1376
1377 /* turn off LED's */
1379
1381 sky2_rx_clean(sky2);
1382
1383 sky2_free_rings(sky2);
1384
1385 return;
1386}
@ TXA_DIS_FSYNC
Definition skge.h:478
@ TXA_STOP_RC
Definition skge.h:482
@ TXA_DIS_ALLOC
Definition skge.h:480
@ GMF_RST_SET
Definition skge.h:1924
@ GM_GPCR_TX_ENA
Definition skge.h:1792
@ GM_GPCR_RX_ENA
Definition skge.h:1793
@ LED_STAT_OFF
Definition skge.h:209
@ TXA_ITI_INI
Definition skge.h:492
@ TXA_CTRL
Definition skge.h:496
@ TXA_LIM_INI
Definition skge.h:494
static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port)
Definition sky2.c:617
static void sky2_rx_stop(struct sky2_port *sky2)
Definition sky2.c:967
static void sky2_tx_clean(struct net_device *dev)
Definition sky2.c:1305
static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port)
Definition sky2.c:256
@ B0_Y2LED
Definition sky2.h:192
@ BMU_STOP
Definition sky2.h:771

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, u16, u32, and Y2_QADDR.

◆ sky2_phy_speed()

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

Definition at line 1388 of file sky2.c.

1389{
1390 if (hw->flags & SKY2_HW_FIBRE_PHY)
1391 return SPEED_1000;
1392
1393 if (!(hw->flags & SKY2_HW_GIGABIT)) {
1394 if (aux & PHY_M_PS_SPEED_100)
1395 return SPEED_100;
1396 else
1397 return SPEED_10;
1398 }
1399
1400 switch (aux & PHY_M_PS_SPEED_MSK) {
1402 return SPEED_1000;
1403 case PHY_M_PS_SPEED_100:
1404 return SPEED_100;
1405 default:
1406 return SPEED_10;
1407 }
1408}
#define SPEED_10
Definition atl1e.h:50
@ PHY_M_PS_SPEED_1000
Definition skge.h:1434
@ PHY_M_PS_SPEED_MSK
Definition skge.h:1433
@ PHY_M_PS_SPEED_100
Definition skge.h:1435

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, SPEED_1000, and u16.

Referenced by sky2_autoneg_done(), and sky2_phy_intr().

◆ sky2_link_up()

void sky2_link_up ( struct sky2_port * sky2)
static

Definition at line 1410 of file sky2.c.

1411{
1412 struct sky2_hw *hw = sky2->hw;
1413 unsigned port = sky2->port;
1414 u16 reg;
1415 static const char *fc_name[] = {
1416 [FC_NONE] = "none",
1417 [FC_TX] = "tx",
1418 [FC_RX] = "rx",
1419 [FC_BOTH] = "both",
1420 };
1421
1422 /* enable Rx/Tx */
1426
1428
1429 netdev_link_up(sky2->netdev);
1430
1431 /* Turn on link LED */
1434
1435 DBG(PFX "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
1436 sky2->netdev->name, sky2->speed,
1437 sky2->duplex == DUPLEX_FULL ? "full" : "half",
1438 fc_name[sky2->flow_status]);
1439}
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition netdevice.h:789
@ LINKLED_LINKSYNC_OFF
Definition skge.h:900
@ LINKLED_BLINK_OFF
Definition skge.h:902
@ LINKLED_ON
Definition skge.h:899
@ LNK_LED_REG
Definition skge.h:616
@ FC_TX
Definition sky2.h:2034
@ FC_BOTH
Definition sky2.h:2036
A Fibre Channel name.
Definition fc.h:30
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(), sky2_port::speed, and u16.

Referenced by sky2_phy_intr().

◆ sky2_link_down()

void sky2_link_down ( struct sky2_port * sky2)
static

Definition at line 1441 of file sky2.c.

1442{
1443 struct sky2_hw *hw = sky2->hw;
1444 unsigned port = sky2->port;
1445 u16 reg;
1446
1448
1452
1453 netdev_link_down(sky2->netdev);
1454
1455 /* Turn on link LED */
1457
1458 DBG(PFX "%s: Link is down.\n", sky2->netdev->name);
1459
1461}
@ LINKLED_OFF
Definition skge.h:898

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(), sky2_write8(), and u16.

Referenced by sky2_phy_intr().

◆ sky2_autoneg_done()

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

Definition at line 1463 of file sky2.c.

1464{
1465 struct sky2_hw *hw = sky2->hw;
1466 unsigned port = sky2->port;
1467 u16 advert, lpa;
1468
1471 if (lpa & PHY_M_AN_RF) {
1472 DBG(PFX "%s: remote fault\n", sky2->netdev->name);
1473 return -1;
1474 }
1475
1476 if (!(aux & PHY_M_PS_SPDUP_RES)) {
1477 DBG(PFX "%s: speed/duplex mismatch\n", sky2->netdev->name);
1478 return -1;
1479 }
1480
1481 sky2->speed = sky2_phy_speed(hw, aux);
1482 sky2->duplex = (aux & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF;
1483
1484 /* Since the pause result bits seem to in different positions on
1485 * different chips. look at registers.
1486 */
1487
1488 sky2->flow_status = FC_NONE;
1489 if (advert & ADVERTISE_PAUSE_CAP) {
1490 if (lpa & LPA_PAUSE_CAP)
1491 sky2->flow_status = FC_BOTH;
1492 else if (advert & ADVERTISE_PAUSE_ASYM)
1493 sky2->flow_status = FC_RX;
1494 } else if (advert & ADVERTISE_PAUSE_ASYM) {
1495 if ((lpa & LPA_PAUSE_CAP) && (lpa & LPA_PAUSE_ASYM))
1496 sky2->flow_status = FC_TX;
1497 }
1498
1499 if (sky2->duplex == DUPLEX_HALF && sky2->speed < SPEED_1000
1500 && !(hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX))
1501 sky2->flow_status = FC_NONE;
1502
1503 if (sky2->flow_status & FC_TX)
1505 else
1507
1508 return 0;
1509}
#define DUPLEX_HALF
Definition bnx2.h:62
#define ADVERTISE_PAUSE_ASYM
Definition mii.h:85
#define LPA_PAUSE_ASYM
Definition mii.h:108
#define LPA_PAUSE_CAP
Definition mii.h:107
#define ADVERTISE_PAUSE_CAP
Definition mii.h:84
@ PHY_MARV_AUNE_LP
Definition skge.h:1039
@ PHY_M_PS_FULL_DUP
Definition skge.h:1437
@ PHY_M_PS_SPDUP_RES
Definition skge.h:1439
@ PHY_M_AN_RF
Definition skge.h:1351
static u16 sky2_phy_speed(const struct sky2_hw *hw, u16 aux)
Definition sky2.c:1388

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, 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, SPEED_1000, and u16.

Referenced by sky2_phy_intr().

◆ sky2_phy_intr()

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

Definition at line 1512 of file sky2.c.

1513{
1514 struct net_device *dev = hw->dev[port];
1515 struct sky2_port *sky2 = dev->priv;
1516 u16 istatus, phystat;
1517
1518 istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT);
1519 phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT);
1520
1521 DBGIO(PFX "%s: phy interrupt status 0x%x 0x%x\n",
1522 sky2->netdev->name, istatus, phystat);
1523
1524 if (sky2->autoneg == AUTONEG_ENABLE && (istatus & PHY_M_IS_AN_COMPL)) {
1525 if (sky2_autoneg_done(sky2, phystat) == 0)
1526 sky2_link_up(sky2);
1527 return;
1528 }
1529
1530 if (istatus & PHY_M_IS_LSP_CHANGE)
1531 sky2->speed = sky2_phy_speed(hw, phystat);
1532
1533 if (istatus & PHY_M_IS_DUP_CHANGE)
1534 sky2->duplex =
1536
1537 if (istatus & PHY_M_IS_LST_CHANGE) {
1538 if (phystat & PHY_M_PS_LINK_UP)
1539 sky2_link_up(sky2);
1540 else
1541 sky2_link_down(sky2);
1542 }
1543}
@ PHY_MARV_INT_STAT
Definition skge.h:1050
@ PHY_M_IS_LST_CHANGE
Definition skge.h:1465
@ PHY_M_IS_DUP_CHANGE
Definition skge.h:1462
@ PHY_M_IS_LSP_CHANGE
Definition skge.h:1461
@ PHY_M_PS_LINK_UP
Definition skge.h:1440
static void sky2_link_down(struct sky2_port *sky2)
Definition sky2.c:1441
static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
Definition sky2.c:1463
static void sky2_link_up(struct sky2_port *sky2)
Definition sky2.c:1410

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(), sky2_port::speed, and u16.

Referenced by sky2_poll().

◆ receive_new()

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

Definition at line 1546 of file sky2.c.

1549{
1550 struct io_buffer *iob, *niob;
1551 unsigned hdr_space = sky2->rx_data_size;
1552
1553 /* Don't be tricky about reusing pages (yet) */
1554 niob = sky2_rx_alloc(sky2);
1555 if (!niob)
1556 return NULL;
1557
1558 iob = re->iob;
1559
1560 re->iob = niob;
1561 sky2_rx_map_iob(sky2->hw->pdev, re, hdr_space);
1562
1563 iob_put(iob, length);
1564 return iob;
1565}
#define iob_put(iobuf, len)
Definition iobuf.h:125
u16 length
Definition sky2.h:1
struct pci_device * pdev
Definition sky2.h:2068

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()

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

Definition at line 1571 of file sky2.c.

1573{
1574 struct sky2_port *sky2 = dev->priv;
1575 struct rx_ring_info *re = sky2->rx_ring + sky2->rx_next;
1576 struct io_buffer *iob = NULL;
1577 u16 count = (status & GMR_FS_LEN) >> 16;
1578
1579 DBGIO(PFX "%s: rx slot %d status 0x%x len %d\n",
1580 dev->name, sky2->rx_next, status, length);
1581
1582 sky2->rx_next = (sky2->rx_next + 1) % RX_PENDING;
1583
1584 /* This chip has hardware problems that generates bogus status.
1585 * So do only marginal checking and expect higher level protocols
1586 * to handle crap frames.
1587 */
1588 if (sky2->hw->chip_id == CHIP_ID_YUKON_FE_P &&
1589 sky2->hw->chip_rev == CHIP_REV_YU_FE2_A0 &&
1590 length == count)
1591 goto okay;
1592
1593 if (status & GMR_FS_ANY_ERR)
1594 goto error;
1595
1596 if (!(status & GMR_FS_RX_OK))
1597 goto resubmit;
1598
1599 /* if length reported by DMA does not match PHY, packet was truncated */
1600 if (length != count)
1601 goto len_error;
1602
1603okay:
1604 iob = receive_new(sky2, re, length);
1605resubmit:
1606 sky2_rx_submit(sky2, re);
1607
1608 return iob;
1609
1610len_error:
1611 /* Truncation of overlength packets
1612 causes PHY length to not match MAC length */
1613 DBG2(PFX "%s: rx length error: status %#x length %d\n",
1614 dev->name, status, length);
1615
1616 /* Pass NULL as iob because we want to keep our iob in the
1617 ring for the next packet. */
1618 netdev_rx_err(dev, NULL, -EINVAL);
1619 goto resubmit;
1620
1621error:
1622 if (status & GMR_FS_RX_FF_OV) {
1623 DBG2(PFX "%s: FIFO overflow error\n", dev->name);
1624 netdev_rx_err(dev, NULL, -EBUSY);
1625 goto resubmit;
1626 }
1627
1628 DBG2(PFX "%s: rx error, status 0x%x length %d\n",
1629 dev->name, status, length);
1630 netdev_rx_err(dev, NULL, -EIO);
1631
1632 goto resubmit;
1633}
struct arbelprm_completion_with_error error
Definition arbel.h:1
uint8_t status
Status.
Definition ena.h:5
static unsigned int count
Number of entries.
Definition dwmac.h:220
#define EINVAL
Invalid argument.
Definition errno.h:429
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition netdevice.c:587
@ GMR_FS_RX_OK
Definition skge.h:1887
@ GMR_FS_RX_FF_OV
Definition skge.h:1895
@ GMR_FS_LEN
Definition skge.h:1880
static struct io_buffer * receive_new(struct sky2_port *sky2, struct rx_ring_info *re, unsigned int length)
Definition sky2.c:1546
u8 chip_rev
Definition sky2.h:2081
u8 chip_id
Definition sky2.h:2080

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(), status, u16, and u32.

Referenced by sky2_status_intr().

◆ sky2_tx_done()

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

Definition at line 1636 of file sky2.c.

1637{
1638 struct sky2_port *sky2 = dev->priv;
1639
1640 sky2_tx_complete(sky2, last);
1641}

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

Referenced by sky2_status_intr().

◆ sky2_status_intr()

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

Definition at line 1644 of file sky2.c.

1645{
1646 unsigned rx[2] = { 0, 0 };
1647
1648 rmb();
1649 do {
1650 struct sky2_status_le *le = hw->st_le + hw->st_idx;
1651 unsigned port;
1652 struct net_device *dev;
1653 struct io_buffer *iob;
1654 u32 status;
1655 u16 length;
1656 u8 opcode = le->opcode;
1657
1658 if (!(opcode & HW_OWNER))
1659 break;
1660
1661 port = le->css & CSS_LINK_BIT;
1662 dev = hw->dev[port];
1663 length = le16_to_cpu(le->length);
1664 status = le32_to_cpu(le->status);
1665
1666 hw->st_idx = RING_NEXT(hw->st_idx, STATUS_RING_SIZE);
1667
1668 le->opcode = 0;
1669 switch (opcode & ~HW_OWNER) {
1670 case OP_RXSTAT:
1671 ++rx[port];
1672 iob = sky2_receive(dev, length, status);
1673 if (!iob) {
1674 netdev_rx_err(dev, NULL, -ENOMEM);
1675 break;
1676 }
1677
1678 netdev_rx(dev, iob);
1679 break;
1680
1681 case OP_RXCHKS:
1682 DBG2(PFX "status OP_RXCHKS but checksum offloading disabled\n");
1683 break;
1684
1685 case OP_TXINDEXLE:
1686 /* TX index reports status for both ports */
1687 assert(TX_RING_SIZE <= 0x1000);
1688 sky2_tx_done(hw->dev[0], status & 0xfff);
1689 if (hw->dev[1])
1690 sky2_tx_done(hw->dev[1],
1691 ((status >> 24) & 0xff)
1692 | (u16)(length & 0xf) << 8);
1693 break;
1694
1695 default:
1696 DBG(PFX "unknown status opcode 0x%x\n", opcode);
1697 }
1698 } while (hw->st_idx != idx);
1699
1700 /* Fully processed status ring so clear irq */
1702
1703 if (rx[0])
1704 sky2_rx_update(hw->dev[0]->priv, Q_R1);
1705
1706 if (rx[1])
1707 sky2_rx_update(hw->dev[1]->priv, Q_R2);
1708}
uint8_t opcode
Opcode.
Definition ena.h:5
#define le16_to_cpu(value)
Definition byteswap.h:113
#define le32_to_cpu(value)
Definition byteswap.h:114
#define rmb()
Definition io.h:545
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition netdevice.c:549
static void sky2_tx_done(struct net_device *dev, u16 last)
Definition sky2.c:1636
#define STATUS_RING_SIZE
Definition sky2.c:72
static struct io_buffer * sky2_receive(struct net_device *dev, u16 length, u32 status)
Definition sky2.c:1571
@ CSS_LINK_BIT
Definition sky2.h:1995
@ STAT_CTRL
Definition sky2.h:913
@ SC_STAT_CLR_IRQ
Definition sky2.h:1841
@ OP_RXSTAT
Definition sky2.h:1975
@ OP_TXINDEXLE
Definition sky2.h:1982
@ OP_RXCHKS
Definition sky2.h:1978
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition wpa.h:1

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, sky2_status_le::status, status, STATUS_RING_SIZE, TX_RING_SIZE, u16, u32, and u8.

Referenced by sky2_poll().

◆ sky2_hw_error()

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

Definition at line 1710 of file sky2.c.

1711{
1712 struct net_device *dev = hw->dev[port];
1713
1714 DBGIO(PFX "%s: hw error interrupt status 0x%x\n", dev->name, status);
1715
1716 if (status & Y2_IS_PAR_RD1) {
1717 DBG(PFX "%s: ram data read parity error\n", dev->name);
1718 /* Clear IRQ */
1720 }
1721
1722 if (status & Y2_IS_PAR_WR1) {
1723 DBG(PFX "%s: ram data write parity error\n", dev->name);
1725 }
1726
1727 if (status & Y2_IS_PAR_MAC1) {
1728 DBG(PFX "%s: MAC parity error\n", dev->name);
1730 }
1731
1732 if (status & Y2_IS_PAR_RX1) {
1733 DBG(PFX "%s: RX parity error\n", dev->name);
1735 }
1736
1737 if (status & Y2_IS_TCP_TXA1) {
1738 DBG(PFX "%s: TCP segmentation error\n", dev->name);
1740 }
1741}
@ B3_RI_CTRL
Definition skge.h:155
@ GMF_CLI_TX_PE
Definition skge.h:1938
@ RI_CLR_RD_PERR
Definition skge.h:421
@ RI_CLR_WR_PERR
Definition skge.h:422
@ Y2_IS_PAR_RX1
Definition sky2.h:416
@ Y2_IS_TCP_TXA1
Definition sky2.h:418
@ Y2_IS_PAR_WR1
Definition sky2.h:414
@ Y2_IS_PAR_MAC1
Definition sky2.h:415
@ Y2_IS_PAR_RD1
Definition sky2.h:413
@ BMU_CLR_IRQ_PAR
Definition sky2.h:768
@ BMU_CLR_IRQ_TCP
Definition sky2.h:769
#define RAM_BUFFER(port, reg)
Definition sky2.h:245
char name[40]
Name.
Definition device.h:79

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, u32, 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()

void sky2_hw_intr ( struct sky2_hw * hw)
static

Definition at line 1743 of file sky2.c.

1744{
1746 u32 hwmsk = sky2_read32(hw, B0_HWE_IMSK);
1747
1748 status &= hwmsk;
1749
1750 if (status & Y2_IS_TIST_OV)
1752
1754 u16 pci_err;
1755
1757 pci_err = sky2_pci_read16(hw, PCI_STATUS);
1758 DBG(PFX "PCI hardware error (0x%x)\n", pci_err);
1759
1761 pci_err | PCI_STATUS_ERROR_BITS);
1763 }
1764
1765 if (status & Y2_IS_PCI_EXP) {
1766 /* PCI-Express uncorrectable Error occurred */
1767 u32 err;
1768
1772 0xfffffffful);
1773 DBG(PFX "PCI-Express error (0x%x)\n", err);
1774
1777 }
1778
1779 if (status & Y2_HWE_L1_MASK)
1780 sky2_hw_error(hw, 0, status);
1781 status >>= 8;
1782 if (status & Y2_HWE_L1_MASK)
1783 sky2_hw_error(hw, 1, status);
1784}
#define PCI_STATUS
PCI status.
Definition pci.h:36
#define PCI_ERR_UNCOR_STATUS
Uncorrectable error status.
Definition pci.h:126
@ GMT_ST_CLR_IRQ
Definition skge.h:1945
@ B0_HWE_IMSK
Definition skge.h:84
@ B0_HWE_ISRC
Definition skge.h:83
@ GMAC_TI_ST_CTRL
Definition skge.h:892
#define PCI_STATUS_ERROR_BITS
Definition skge.h:70
static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status)
Definition sky2.c:1710
@ Y2_IS_TIST_OV
Definition sky2.h:399
@ Y2_HWE_L1_MASK
Definition sky2.h:420
@ Y2_IS_MST_ERR
Definition sky2.h:401
@ Y2_IS_IRQ_STAT
Definition sky2.h:402
@ Y2_IS_PCI_EXP
Definition sky2.h:403
@ Y2_CFG_AER
Definition sky2.h:294
static void sky2_pci_write16(struct sky2_hw *hw, unsigned reg, u16 val)
Definition sky2.h:2172
static u16 sky2_pci_read16(const struct sky2_hw *hw, unsigned reg)
Definition sky2.h:2162

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, u16, u32, 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()

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

Definition at line 1786 of file sky2.c.

1787{
1788 struct net_device *dev = hw->dev[port];
1790
1791 DBGIO(PFX "%s: mac interrupt status 0x%x\n", dev->name, status);
1792
1793 if (status & GM_IS_RX_CO_OV)
1795
1796 if (status & GM_IS_TX_CO_OV)
1798
1799 if (status & GM_IS_RX_FF_OR) {
1801 }
1802
1803 if (status & GM_IS_TX_FF_UR) {
1805 }
1806}
@ GM_RX_IRQ_SRC
Definition skge.h:1700
@ GM_TX_IRQ_SRC
Definition skge.h:1699
@ GMF_CLI_RX_FO
Definition skge.h:1919
@ GM_IS_RX_FF_OR
Definition skge.h:2018
@ GM_IS_TX_FF_UR
Definition skge.h:2016
@ GM_IS_TX_CO_OV
Definition skge.h:2014
@ GM_IS_RX_CO_OV
Definition skge.h:2015
@ GMF_CLI_TX_FU
Definition skge.h:1936

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, TX_GMF_CTRL_T, and u8.

Referenced by sky2_err_intr().

◆ sky2_le_error()

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

Definition at line 1809 of file sky2.c.

1811{
1812 struct net_device *dev = hw->dev[port];
1813 struct sky2_port *sky2 = dev->priv;
1814 int idx;
1815 const u64 *le = (q == Q_R1 || q == Q_R2)
1816 ? (u64 *) sky2->rx_le : (u64 *) sky2->tx_le;
1817
1819 DBG(PFX "%s: descriptor error q=%#x get=%d [%llx] last=%d put=%d should be %d\n",
1820 dev->name, (unsigned) q, idx, (unsigned long long) le[idx],
1823 le == (u64 *)sky2->rx_le? sky2->rx_put : sky2->tx_prod);
1824
1826}
uint64_t u64
Definition stdint.h:26
@ PREF_UNIT_GET_IDX
Definition sky2.h:670
@ BMU_CLR_IRQ_CHK
Definition sky2.h:770

References __unused, 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, u16, and Y2_QADDR.

Referenced by sky2_err_intr().

◆ sky2_err_intr()

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

Definition at line 1829 of file sky2.c.

1830{
1831 DBG(PFX "error interrupt status=%#x\n", status);
1832
1833 if (status & Y2_IS_HW_ERR)
1835
1836 if (status & Y2_IS_IRQ_MAC1)
1837 sky2_mac_intr(hw, 0);
1838
1839 if (status & Y2_IS_IRQ_MAC2)
1840 sky2_mac_intr(hw, 1);
1841
1842 if (status & Y2_IS_CHK_RX1)
1844
1845 if (status & Y2_IS_CHK_RX2)
1847
1848 if (status & Y2_IS_CHK_TXA1)
1850
1851 if (status & Y2_IS_CHK_TXA2)
1853}
@ Q_XA2
Definition skge.h:562
@ Q_XA1
Definition skge.h:560
static void sky2_le_error(struct sky2_hw *hw, unsigned port, u16 q, unsigned ring_size __unused)
Definition sky2.c:1809
static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
Definition sky2.c:1786
static void sky2_hw_intr(struct sky2_hw *hw)
Definition sky2.c:1743
@ Y2_IS_IRQ_MAC2
Definition sky2.h:356
@ Y2_IS_CHK_TXA1
Definition sky2.h:365
@ Y2_IS_IRQ_MAC1
Definition sky2.h:362
@ Y2_IS_CHK_RX2
Definition sky2.h:357
@ Y2_IS_HW_ERR
Definition sky2.h:346
@ Y2_IS_CHK_RX1
Definition sky2.h:363
@ Y2_IS_CHK_TXA2
Definition sky2.h:359

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, u32, 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()

void sky2_poll ( struct net_device * dev)
static

Definition at line 1855 of file sky2.c.

1856{
1857 struct sky2_port *sky2 = dev->priv;
1858 struct sky2_hw *hw = sky2->hw;
1860 u16 idx;
1861
1862 if (status & Y2_IS_ERROR)
1864
1865 if (status & Y2_IS_IRQ_PHY1)
1866 sky2_phy_intr(hw, 0);
1867
1868 if (status & Y2_IS_IRQ_PHY2)
1869 sky2_phy_intr(hw, 1);
1870
1871 while ((idx = sky2_read16(hw, STAT_PUT_IDX)) != hw->st_idx) {
1872 sky2_status_intr(hw, idx);
1873 }
1874
1875 /* Bug/Errata workaround?
1876 * Need to kick the TX irq moderation timer.
1877 */
1881 }
1883}
@ TIM_START
Definition skge.h:333
@ TIM_STOP
Definition skge.h:334
static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
Definition sky2.c:1512
static void sky2_status_intr(struct sky2_hw *hw, u16 idx)
Definition sky2.c:1644
static void sky2_err_intr(struct sky2_hw *hw, u32 status)
Definition sky2.c:1829
@ Y2_IS_ERROR
Definition sky2.h:372
@ Y2_IS_IRQ_PHY2
Definition sky2.h:355
@ Y2_IS_IRQ_PHY1
Definition sky2.h:361
@ B0_Y2_SP_EISR
Definition sky2.h:202
@ B0_Y2_SP_LISR
Definition sky2.h:203
@ STAT_PUT_IDX
Definition sky2.h:923
@ STAT_TX_TIMER_CTRL
Definition sky2.h:941

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, u16, u32, Y2_IS_ERROR, Y2_IS_IRQ_PHY1, and Y2_IS_IRQ_PHY2.

◆ sky2_mhz()

u32 sky2_mhz ( const struct sky2_hw * hw)
static

Definition at line 1886 of file sky2.c.

1887{
1888 switch (hw->chip_id) {
1889 case CHIP_ID_YUKON_EC:
1890 case CHIP_ID_YUKON_EC_U:
1891 case CHIP_ID_YUKON_EX:
1892 case CHIP_ID_YUKON_SUPR:
1893 case CHIP_ID_YUKON_UL_2:
1894 return 125;
1895
1896 case CHIP_ID_YUKON_FE:
1897 return 100;
1898
1899 case CHIP_ID_YUKON_FE_P:
1900 return 50;
1901
1902 case CHIP_ID_YUKON_XL:
1903 return 156;
1904
1905 default:
1906 DBG(PFX "unknown chip ID!\n");
1907 return 100; /* bogus */
1908 }
1909}

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, PFX, and u32.

Referenced by sky2_clk2us(), and sky2_us2clk().

◆ sky2_us2clk()

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

Definition at line 1911 of file sky2.c.

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

References sky2_mhz(), and u32.

Referenced by sky2_reset().

◆ sky2_clk2us()

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

Definition at line 1916 of file sky2.c.

1917{
1918 return clk / sky2_mhz(hw);
1919}

References sky2_mhz(), and u32.

◆ sky2_init()

int sky2_init ( struct sky2_hw * hw)
static

Definition at line 1921 of file sky2.c.

1922{
1923 u8 t8;
1924
1925 /* Enable all clocks and check for bad PCI access */
1927
1929
1930 hw->chip_id = sky2_read8(hw, B2_CHIP_ID);
1931 hw->chip_rev = (sky2_read8(hw, B2_MAC_CFG) & CFG_CHIP_R_MSK) >> 4;
1932
1933 switch(hw->chip_id) {
1934 case CHIP_ID_YUKON_XL:
1936 break;
1937
1938 case CHIP_ID_YUKON_EC_U:
1939 hw->flags = SKY2_HW_GIGABIT
1942 break;
1943
1944 case CHIP_ID_YUKON_EX:
1945 hw->flags = SKY2_HW_GIGABIT
1949 break;
1950
1951 case CHIP_ID_YUKON_EC:
1952 /* This rev is really old, and requires untested workarounds */
1953 if (hw->chip_rev == CHIP_REV_YU_EC_A1) {
1954 DBG(PFX "unsupported revision Yukon-EC rev A1\n");
1955 return -EOPNOTSUPP;
1956 }
1957 hw->flags = SKY2_HW_GIGABIT;
1958 break;
1959
1960 case CHIP_ID_YUKON_FE:
1961 break;
1962
1963 case CHIP_ID_YUKON_FE_P:
1964 hw->flags = SKY2_HW_NEWER_PHY
1968 break;
1969
1970 case CHIP_ID_YUKON_SUPR:
1971 hw->flags = SKY2_HW_GIGABIT
1976 break;
1977
1978 case CHIP_ID_YUKON_UL_2:
1979 hw->flags = SKY2_HW_GIGABIT
1981 break;
1982
1983 default:
1984 DBG(PFX "unsupported chip type 0x%x\n", hw->chip_id);
1985 return -EOPNOTSUPP;
1986 }
1987
1988 hw->pmd_type = sky2_read8(hw, B2_PMD_TYP);
1989 if (hw->pmd_type == 'L' || hw->pmd_type == 'S' || hw->pmd_type == 'P')
1990 hw->flags |= SKY2_HW_FIBRE_PHY;
1991
1992 hw->ports = 1;
1993 t8 = sky2_read8(hw, B2_Y2_HW_RES);
1994 if ((t8 & CFG_DUAL_MAC_MSK) == CFG_DUAL_MAC_MSK) {
1996 ++hw->ports;
1997 }
1998
1999 return 0;
2000}
#define EOPNOTSUPP
Operation not supported on socket.
Definition errno.h:605
@ CFG_CHIP_R_MSK
Definition skge.h:310
@ B2_MAC_CFG
Definition skge.h:106
@ B2_CHIP_ID
Definition skge.h:107
@ B2_PMD_TYP
Definition skge.h:105
@ CS_RST_CLR
Definition skge.h:203
@ CHIP_REV_YU_EC_A1
Definition sky2.h:481
#define SKY2_HW_AUTO_TX_SUM
Definition sky2.h:2077
@ B2_Y2_HW_RES
Definition sky2.h:216
@ Y2_STATUS_LNK2_INAC
Definition sky2.h:508
#define CFG_DUAL_MAC_MSK
Definition sky2.h:525

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(), u8, and Y2_STATUS_LNK2_INAC.

Referenced by sky2_probe().

◆ sky2_reset()

void sky2_reset ( struct sky2_hw * hw)
static

Definition at line 2002 of file sky2.c.

2003{
2004 u16 status;
2005 int i, cap;
2006 u32 hwe_mask = Y2_HWE_ALL_MASK;
2007
2008 /* disable ASF */
2009 if (hw->chip_id == CHIP_ID_YUKON_EX) {
2014 } else
2017
2018 /* do a SW reset */
2021
2022 /* allow writes to PCI config */
2024
2025 /* clear PCI errors, if any */
2029
2031
2033 if (cap) {
2035 0xfffffffful);
2036
2037 /* If an error bit is stuck on ignore it */
2039 DBG(PFX "ignoring stuck error report bit\n");
2040 else
2041 hwe_mask |= Y2_IS_PCI_EXP;
2042 }
2043
2046
2047 for (i = 0; i < hw->ports; i++) {
2050
2051 if (hw->chip_id == CHIP_ID_YUKON_EX ||
2052 hw->chip_id == CHIP_ID_YUKON_SUPR)
2055 | GMC_BYP_RETR_ON);
2056 }
2057
2058 /* Clear I2C IRQ noise */
2060
2061 /* turn off hardware timer (unused) */
2064
2066
2067 /* Turn off descriptor polling */
2069
2070 /* Turn off receive timestamp */
2073
2074 /* enable the Tx Arbiters */
2075 for (i = 0; i < hw->ports; i++)
2077
2078 /* Initialize ram interface */
2079 for (i = 0; i < hw->ports; i++) {
2081
2094 }
2095
2096 sky2_write32(hw, B0_HWE_IMSK, hwe_mask);
2097
2098 for (i = 0; i < hw->ports; i++)
2099 sky2_gmac_reset(hw, i);
2100
2101 memset(hw->st_le, 0, STATUS_LE_BYTES);
2102 hw->st_idx = 0;
2103
2106
2108 sky2_write32(hw, STAT_LIST_ADDR_HI, (u64) hw->st_dma >> 32);
2109
2110 /* Set the list last index */
2112
2115
2116 /* set Status-FIFO ISR watermark */
2117 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0)
2119 else
2121
2125
2126 /* enable status unit */
2128
2132}
@ TXA_ENA_ARB
Definition skge.h:483
@ GMT_ST_STOP
Definition skge.h:1944
@ B3_RI_WTO_XA1
Definition skge.h:143
@ B3_RI_RTO_XA2
Definition skge.h:152
@ B3_RI_WTO_XS1
Definition skge.h:144
@ B3_RI_WTO_R2
Definition skge.h:148
@ B3_RI_RTO_XA1
Definition skge.h:146
@ B3_RI_RTO_R1
Definition skge.h:145
@ B3_RI_RTO_XS1
Definition skge.h:147
@ B2_I2C_IRQ
Definition skge.h:131
@ B3_RI_WTO_R1
Definition skge.h:142
@ B3_RI_RTO_XS2
Definition skge.h:153
@ B3_RI_RTO_R2
Definition skge.h:151
@ B3_RI_WTO_XS2
Definition skge.h:150
@ B3_RI_WTO_XA2
Definition skge.h:149
@ B2_TI_CTRL
Definition skge.h:118
@ B28_DPT_CTRL
Definition skge.h:886
@ GMLC_RST_SET
Definition skge.h:2026
@ GMLC_RST_CLR
Definition skge.h:2025
@ RI_RST_CLR
Definition skge.h:424
#define SK_RI_TO_53
Definition skge.h:442
@ GMAC_LINK_CTRL
Definition skge.h:912
@ CS_MRST_CLR
Definition skge.h:201
@ LED_STAT_ON
Definition skge.h:208
@ CS_RST_SET
Definition skge.h:204
@ TIM_CLR_IRQ
Definition skge.h:335
static u32 sky2_us2clk(const struct sky2_hw *hw, u32 us)
Definition sky2.c:1911
#define STATUS_LE_BYTES
Definition sky2.c:73
static void sky2_power_on(struct sky2_hw *hw)
Definition sky2.c:194
@ Y2_ASF_RESET
Definition sky2.h:1791
@ DPT_STOP
Definition sky2.h:432
@ Y2_ASF_DISABLE
Definition sky2.h:304
@ Y2_HWE_ALL_MASK
Definition sky2.h:425
@ HCU_CCSR_UC_STATE_MSK
Definition sky2.h:1824
@ HCU_CCSR_AHB_RST
Definition sky2.h:1816
@ HCU_CCSR_CPU_RST_MODE
Definition sky2.h:1817
@ B28_Y2_ASF_STAT_CMD
Definition sky2.h:903
@ STAT_FIFO_WM
Definition sky2.h:931
@ STAT_LIST_ADDR_HI
Definition sky2.h:917
@ STAT_ISR_TIMER_CTRL
Definition sky2.h:945
@ STAT_ISR_TIMER_INI
Definition sky2.h:943
@ STAT_TX_IDX_TH
Definition sky2.h:922
@ STAT_LIST_ADDR_LO
Definition sky2.h:916
@ STAT_FIFO_ISR_WM
Definition sky2.h:932
@ STAT_LEV_TIMER_INI
Definition sky2.h:935
@ STAT_LAST_IDX
Definition sky2.h:914
@ STAT_TX_TIMER_INI
Definition sky2.h:939
@ STAT_LEV_TIMER_CTRL
Definition sky2.h:937
@ GMC_BYP_MACSECTX_ON
Definition sky2.h:1854
@ GMC_BYP_MACSECRX_ON
Definition sky2.h:1852
@ GMC_BYP_RETR_ON
Definition sky2.h:1856
@ SC_STAT_RST_CLR
Definition sky2.h:1844
@ SC_STAT_RST_SET
Definition sky2.h:1845
@ SC_STAT_OP_ON
Definition sky2.h:1842
@ HCU_CCSR
Definition sky2.h:893

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, u16, u32, 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()

u32 sky2_supported_modes ( const struct sky2_hw * hw)
static

Definition at line 2134 of file sky2.c.

2135{
2136 if (sky2_is_copper(hw)) {
2142
2143 if (hw->flags & SKY2_HW_GIGABIT)
2146 return modes;
2147 } else
2152}
#define SUPPORTED_FIBRE
Definition skge.h:66
#define SUPPORTED_TP
Definition skge.h:65
#define SUPPORTED_Autoneg
Definition skge.h:64
#define SUPPORTED_100baseT_Half
Definition skge.h:60
#define SUPPORTED_1000baseT_Full
Definition skge.h:63
#define SUPPORTED_10baseT_Full
Definition skge.h:59
#define SUPPORTED_100baseT_Full
Definition skge.h:61
#define SUPPORTED_1000baseT_Half
Definition skge.h:62
#define SUPPORTED_10baseT_Half
Definition skge.h:58

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, SUPPORTED_TP, and u32.

Referenced by sky2_init_netdev().

◆ sky2_init_netdev()

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

Definition at line 2180 of file sky2.c.

2182{
2183 struct sky2_port *sky2;
2184 struct net_device *dev = alloc_etherdev(sizeof(*sky2));
2185
2186 if (!dev) {
2187 DBG(PFX "etherdev alloc failed\n");
2188 return NULL;
2189 }
2190
2191 dev->dev = &hw->pdev->dev;
2192
2193 sky2 = dev->priv;
2194 sky2->netdev = dev;
2195 sky2->hw = hw;
2196
2197 /* Auto speed and flow control */
2198 sky2->autoneg = AUTONEG_ENABLE;
2199 sky2->flow_mode = FC_BOTH;
2200
2201 sky2->duplex = -1;
2202 sky2->speed = -1;
2204
2205 hw->dev[port] = dev;
2206
2207 sky2->port = port;
2208
2209 /* read the mac address */
2210 memcpy(dev->hw_addr, (void *)(hw->regs + B2_MAC_1 + port * 8), ETH_ALEN);
2211
2212 return dev;
2213}
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition ethernet.c:265
#define ETH_ALEN
Definition if_ether.h:9
void * memcpy(void *dest, const void *src, size_t len) __nonnull
@ B2_MAC_1
Definition skge.h:101
static u32 sky2_supported_modes(const struct sky2_hw *hw)
Definition sky2.c:2134

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()

void sky2_show_addr ( struct net_device * dev)
static

Definition at line 2215 of file sky2.c.

2216{
2217 DBG2(PFX "%s: addr %s\n", dev->name, netdev_addr(dev));
2218}
static const char * netdev_addr(struct net_device *netdev)
Get printable network device link-layer address.
Definition netdevice.h:542

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

Referenced by sky2_probe().

◆ sky2_net_irq()

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

Definition at line 2243 of file sky2.c.

2244{
2245 struct sky2_port *sky2 = dev->priv;
2246 struct sky2_hw *hw = sky2->hw;
2247
2248 u32 imask = sky2_read32(hw, B0_IMSK);
2249 if (enable)
2250 imask |= portirq_msk[sky2->port];
2251 else
2252 imask &= ~portirq_msk[sky2->port];
2253 sky2_write32(hw, B0_IMSK, imask);
2254}

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

◆ sky2_probe()

int sky2_probe ( struct pci_device * pdev)
static

Definition at line 2264 of file sky2.c.

2265{
2266 struct net_device *dev;
2267 struct sky2_hw *hw;
2268 int err;
2269 char buf1[16] __unused; /* only for debugging */
2270
2272
2273 err = -ENOMEM;
2274 hw = zalloc(sizeof(*hw));
2275 if (!hw) {
2276 DBG(PFX "cannot allocate hardware struct\n");
2277 goto err_out;
2278 }
2279
2280 hw->pdev = pdev;
2281
2282 hw->regs = (unsigned long)pci_ioremap(pdev, pci_bar_start(pdev, PCI_BASE_ADDRESS_0), 0x4000);
2283 if (!hw->regs) {
2284 DBG(PFX "cannot map device registers\n");
2285 goto err_out_free_hw;
2286 }
2287
2288 /* ring for status responses */
2290 if (!hw->st_le)
2291 goto err_out_iounmap;
2292 hw->st_dma = virt_to_bus(hw->st_le);
2293 memset(hw->st_le, 0, STATUS_LE_BYTES);
2294
2295 err = sky2_init(hw);
2296 if (err)
2297 goto err_out_iounmap;
2298
2299#if DBGLVL_MAX
2300 DBG2(PFX "Yukon-2 %s chip revision %d\n",
2301 sky2_name(hw->chip_id, buf1, sizeof(buf1)), hw->chip_rev);
2302#endif
2303
2304 sky2_reset(hw);
2305
2306 dev = sky2_init_netdev(hw, 0);
2307 if (!dev) {
2308 err = -ENOMEM;
2309 goto err_out_free_pci;
2310 }
2311
2313
2314 err = register_netdev(dev);
2315 if (err) {
2316 DBG(PFX "cannot register net device\n");
2317 goto err_out_free_netdev;
2318 }
2319
2321
2323
2324 if (hw->ports > 1) {
2325 struct net_device *dev1;
2326
2327 dev1 = sky2_init_netdev(hw, 1);
2328 if (!dev1)
2329 DBG(PFX "allocation for second device failed\n");
2330 else if ((err = register_netdev(dev1))) {
2331 DBG(PFX "register of second port failed (%d)\n", err);
2332 hw->dev[1] = NULL;
2333 netdev_nullify(dev1);
2334 netdev_put(dev1);
2335 } else
2336 sky2_show_addr(dev1);
2337 }
2338
2339 pci_set_drvdata(pdev, hw);
2340
2341 return 0;
2342
2343err_out_free_netdev:
2345 netdev_put(dev);
2346err_out_free_pci:
2348 free_phys(hw->st_le, STATUS_LE_BYTES);
2349err_out_iounmap:
2350 iounmap((void *)hw->regs);
2351err_out_free_hw:
2352 free(hw);
2353err_out:
2354 pci_set_drvdata(pdev, NULL);
2355 return err;
2356}
#define __unused
Declare a variable or data structure as unused.
Definition compiler.h:573
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
int register_netdev(struct net_device *netdev)
Register network device.
Definition netdevice.c:760
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition netdevice.h:519
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition netdevice.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:576
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition pci.c:97
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition pci.h:366
#define PCI_BASE_ADDRESS_0
Definition pci.h:63
static struct net_device_operations sky2_operations
Definition sky2.c:2256
static int sky2_init(struct sky2_hw *hw)
Definition sky2.c:1921
static void sky2_reset(struct sky2_hw *hw)
Definition sky2.c:2002
#define STATUS_RING_ALIGN
Definition sky2.c:74
static struct net_device * sky2_init_netdev(struct sky2_hw *hw, unsigned port)
Definition sky2.c:2180
static void sky2_show_addr(struct net_device *dev)
Definition sky2.c:2215
@ Y2_IS_BASE
Definition sky2.h:367

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()

void sky2_remove ( struct pci_device * pdev)
static

Definition at line 2358 of file sky2.c.

2359{
2360 struct sky2_hw *hw = pci_get_drvdata(pdev);
2361 int i;
2362
2363 if (!hw)
2364 return;
2365
2366 for (i = hw->ports-1; i >= 0; --i)
2367 unregister_netdev(hw->dev[i]);
2368
2369 sky2_write32(hw, B0_IMSK, 0);
2370
2372
2376
2377 free_phys(hw->st_le, STATUS_LE_BYTES);
2378
2379 for (i = hw->ports-1; i >= 0; --i) {
2380 netdev_nullify(hw->dev[i]);
2381 netdev_put(hw->dev[i]);
2382 }
2383
2384 iounmap((void *)hw->regs);
2385 free(hw);
2386
2388}
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition netdevice.c:942
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition pci.h:376
static void sky2_power_aux(struct sky2_hw *hw)
Definition sky2.c:238

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 82 of file sky2.c.

82 {
83 PCI_ROM(0x1148, 0x9000, "sk9sxx", "Syskonnect SK-9Sxx", 0),
84 PCI_ROM(0x1148, 0x9e00, "sk9exx", "Syskonnect SK-9Exx", 0),
85 PCI_ROM(0x1186, 0x4001, "dge550sx", "D-Link DGE-550SX", 0),
86 PCI_ROM(0x1186, 0x4b00, "dge560t", "D-Link DGE-560T", 0),
87 PCI_ROM(0x1186, 0x4b02, "dge560sx", "D-Link DGE-560SX", 0),
88 PCI_ROM(0x1186, 0x4b03, "dge550t", "D-Link DGE-550T", 0),
89 PCI_ROM(0x11ab, 0x4340, "m88e8021", "Marvell 88E8021", 0),
90 PCI_ROM(0x11ab, 0x4341, "m88e8022", "Marvell 88E8022", 0),
91 PCI_ROM(0x11ab, 0x4342, "m88e8061", "Marvell 88E8061", 0),
92 PCI_ROM(0x11ab, 0x4343, "m88e8062", "Marvell 88E8062", 0),
93 PCI_ROM(0x11ab, 0x4344, "m88e8021b", "Marvell 88E8021", 0),
94 PCI_ROM(0x11ab, 0x4345, "m88e8022b", "Marvell 88E8022", 0),
95 PCI_ROM(0x11ab, 0x4346, "m88e8061b", "Marvell 88E8061", 0),
96 PCI_ROM(0x11ab, 0x4347, "m88e8062b", "Marvell 88E8062", 0),
97 PCI_ROM(0x11ab, 0x4350, "m88e8035", "Marvell 88E8035", 0),
98 PCI_ROM(0x11ab, 0x4351, "m88e8036", "Marvell 88E8036", 0),
99 PCI_ROM(0x11ab, 0x4352, "m88e8038", "Marvell 88E8038", 0),
100 PCI_ROM(0x11ab, 0x4353, "m88e8039", "Marvell 88E8039", 0),
101 PCI_ROM(0x11ab, 0x4354, "m88e8040", "Marvell 88E8040", 0),
102 PCI_ROM(0x11ab, 0x4355, "m88e8040t", "Marvell 88E8040T", 0),
103 PCI_ROM(0x11ab, 0x4356, "m88ec033", "Marvel 88EC033", 0),
104 PCI_ROM(0x11ab, 0x4357, "m88e8042", "Marvell 88E8042", 0),
105 PCI_ROM(0x11ab, 0x435a, "m88e8048", "Marvell 88E8048", 0),
106 PCI_ROM(0x11ab, 0x4360, "m88e8052", "Marvell 88E8052", 0),
107 PCI_ROM(0x11ab, 0x4361, "m88e8050", "Marvell 88E8050", 0),
108 PCI_ROM(0x11ab, 0x4362, "m88e8053", "Marvell 88E8053", 0),
109 PCI_ROM(0x11ab, 0x4363, "m88e8055", "Marvell 88E8055", 0),
110 PCI_ROM(0x11ab, 0x4364, "m88e8056", "Marvell 88E8056", 0),
111 PCI_ROM(0x11ab, 0x4365, "m88e8070", "Marvell 88E8070", 0),
112 PCI_ROM(0x11ab, 0x4366, "m88ec036", "Marvell 88EC036", 0),
113 PCI_ROM(0x11ab, 0x4367, "m88ec032", "Marvell 88EC032", 0),
114 PCI_ROM(0x11ab, 0x4368, "m88ec034", "Marvell 88EC034", 0),
115 PCI_ROM(0x11ab, 0x4369, "m88ec042", "Marvell 88EC042", 0),
116 PCI_ROM(0x11ab, 0x436a, "m88e8058", "Marvell 88E8058", 0),
117 PCI_ROM(0x11ab, 0x436b, "m88e8071", "Marvell 88E8071", 0),
118 PCI_ROM(0x11ab, 0x436c, "m88e8072", "Marvell 88E8072", 0),
119 PCI_ROM(0x11ab, 0x436d, "m88e8055b", "Marvell 88E8055", 0),
120 PCI_ROM(0x11ab, 0x4370, "m88e8075", "Marvell 88E8075", 0),
121 PCI_ROM(0x11ab, 0x4380, "m88e8057", "Marvell 88E8057", 0)
122};
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition pci.h:308

◆ txqaddr

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

Definition at line 125 of file sky2.c.

125{ Q_XA1, Q_XA2 };

◆ rxqaddr

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

Definition at line 126 of file sky2.c.

126{ Q_R1, Q_R2 };

◆ portirq_msk

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

Definition at line 127 of file sky2.c.

@ Y2_IS_PORT_1
Definition sky2.h:368
@ Y2_IS_PORT_2
Definition sky2.h:370

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

◆ copper_fc_adv

const u16 copper_fc_adv[]
static
Initial value:
= {
[FC_NONE] = 0,
}
@ PHY_M_AN_ASP
Definition skge.h:1353
@ PHY_M_AN_PC
Definition skge.h:1354

Definition at line 274 of file sky2.c.

274 {
275 [FC_NONE] = 0,
277 [FC_RX] = PHY_M_AN_PC,
279};

Referenced by sky2_phy_init().

◆ fiber_fc_adv

const u16 fiber_fc_adv[]
static
Initial value:
= {
}
@ PHY_M_P_ASYM_MD_X
Definition skge.h:1375
@ PHY_M_P_NO_PAUSE_X
Definition skge.h:1373
@ PHY_M_P_SYM_MD_X
Definition skge.h:1374
@ PHY_M_P_BOTH_MD_X
Definition skge.h:1376

Definition at line 282 of file sky2.c.

Referenced by sky2_phy_init().

◆ gm_fc_disable

const u16 gm_fc_disable[]
static
Initial value:
= {
[FC_BOTH] = 0,
}
@ GM_GPCR_FC_RX_DIS
Definition skge.h:1800
@ GM_GPCR_FC_TX_DIS
Definition skge.h:1791

Definition at line 290 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 593 of file sky2.c.

@ PCI_Y2_PHY2_POWD
Definition sky2.h:62
@ PCI_Y2_PHY1_POWD
Definition sky2.h:63

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 594 of file sky2.c.

@ PCI_Y2_PHY1_COMA
Definition sky2.h:61
@ PCI_Y2_PHY2_COMA
Definition sky2.h:60

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_down(struct net_device *dev)
Definition sky2.c:1313
static void sky2_net_irq(struct net_device *dev, int enable)
Definition sky2.c:2243
static int sky2_xmit_frame(struct net_device *dev, struct io_buffer *iob)
Definition sky2.c:1239
static int sky2_up(struct net_device *dev)
Definition sky2.c:1130
static void sky2_poll(struct net_device *dev)
Definition sky2.c:1855

Definition at line 2256 of file sky2.c.

2256 {
2257 .open = sky2_up,
2258 .close = sky2_down,
2259 .transmit = sky2_xmit_frame,
2260 .poll = sky2_poll,
2261 .irq = sky2_net_irq
2262};

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 struct pci_device_id sky2_id_table[]
Definition sky2.c:82
static int sky2_probe(struct pci_device *pdev)
Definition sky2.c:2264
static void sky2_remove(struct pci_device *pdev)
Definition sky2.c:2358
static struct xen_remove_from_physmap * remove
Definition xenmem.h:40

Definition at line 2390 of file sky2.c.

2390 {
2391 .ids = sky2_id_table,
2392 .id_count = (sizeof (sky2_id_table) / sizeof (sky2_id_table[0])),
2393 .probe = sky2_probe,
2395};