44 #define DRV_NAME "sky2" 45 #define DRV_VERSION "1.22" 46 #define PFX DRV_NAME " " 61 #define RX_LE_SIZE 128 62 #define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le)) 63 #define RX_RING_ALIGN 4096 64 #define RX_PENDING (RX_LE_SIZE/6 - 2) 66 #define TX_RING_SIZE 128 67 #define TX_PENDING (TX_RING_SIZE - 1) 68 #define TX_RING_ALIGN 4096 69 #define MAX_SKB_TX_LE 4 71 #define STATUS_RING_SIZE 512 72 #define STATUS_LE_BYTES (STATUS_RING_SIZE*sizeof(struct sky2_status_le)) 73 #define STATUS_RING_ALIGN 4096 74 #define PHY_RETRIES 1000 76 #define SKY2_EEPROM_MAGIC 0x9955aabb 79 #define RING_NEXT(x,s) (((x)+1) & ((s)-1)) 82 PCI_ROM(0x1148, 0x9000,
"sk9sxx",
"Syskonnect SK-9Sxx", 0),
83 PCI_ROM(0x1148, 0x9e00,
"sk9exx",
"Syskonnect SK-9Exx", 0),
84 PCI_ROM(0x1186, 0x4001,
"dge550sx",
"D-Link DGE-550SX", 0),
85 PCI_ROM(0x1186, 0x4b00,
"dge560t",
"D-Link DGE-560T", 0),
86 PCI_ROM(0x1186, 0x4b02,
"dge560sx",
"D-Link DGE-560SX", 0),
87 PCI_ROM(0x1186, 0x4b03,
"dge550t",
"D-Link DGE-550T", 0),
88 PCI_ROM(0x11ab, 0x4340,
"m88e8021",
"Marvell 88E8021", 0),
89 PCI_ROM(0x11ab, 0x4341,
"m88e8022",
"Marvell 88E8022", 0),
90 PCI_ROM(0x11ab, 0x4342,
"m88e8061",
"Marvell 88E8061", 0),
91 PCI_ROM(0x11ab, 0x4343,
"m88e8062",
"Marvell 88E8062", 0),
92 PCI_ROM(0x11ab, 0x4344,
"m88e8021b",
"Marvell 88E8021", 0),
93 PCI_ROM(0x11ab, 0x4345,
"m88e8022b",
"Marvell 88E8022", 0),
94 PCI_ROM(0x11ab, 0x4346,
"m88e8061b",
"Marvell 88E8061", 0),
95 PCI_ROM(0x11ab, 0x4347,
"m88e8062b",
"Marvell 88E8062", 0),
96 PCI_ROM(0x11ab, 0x4350,
"m88e8035",
"Marvell 88E8035", 0),
97 PCI_ROM(0x11ab, 0x4351,
"m88e8036",
"Marvell 88E8036", 0),
98 PCI_ROM(0x11ab, 0x4352,
"m88e8038",
"Marvell 88E8038", 0),
99 PCI_ROM(0x11ab, 0x4353,
"m88e8039",
"Marvell 88E8039", 0),
100 PCI_ROM(0x11ab, 0x4354,
"m88e8040",
"Marvell 88E8040", 0),
101 PCI_ROM(0x11ab, 0x4355,
"m88e8040t",
"Marvell 88E8040T", 0),
102 PCI_ROM(0x11ab, 0x4356,
"m88ec033",
"Marvel 88EC033", 0),
103 PCI_ROM(0x11ab, 0x4357,
"m88e8042",
"Marvell 88E8042", 0),
104 PCI_ROM(0x11ab, 0x435a,
"m88e8048",
"Marvell 88E8048", 0),
105 PCI_ROM(0x11ab, 0x4360,
"m88e8052",
"Marvell 88E8052", 0),
106 PCI_ROM(0x11ab, 0x4361,
"m88e8050",
"Marvell 88E8050", 0),
107 PCI_ROM(0x11ab, 0x4362,
"m88e8053",
"Marvell 88E8053", 0),
108 PCI_ROM(0x11ab, 0x4363,
"m88e8055",
"Marvell 88E8055", 0),
109 PCI_ROM(0x11ab, 0x4364,
"m88e8056",
"Marvell 88E8056", 0),
110 PCI_ROM(0x11ab, 0x4365,
"m88e8070",
"Marvell 88E8070", 0),
111 PCI_ROM(0x11ab, 0x4366,
"m88ec036",
"Marvell 88EC036", 0),
112 PCI_ROM(0x11ab, 0x4367,
"m88ec032",
"Marvell 88EC032", 0),
113 PCI_ROM(0x11ab, 0x4368,
"m88ec034",
"Marvell 88EC034", 0),
114 PCI_ROM(0x11ab, 0x4369,
"m88ec042",
"Marvell 88EC042", 0),
115 PCI_ROM(0x11ab, 0x436a,
"m88e8058",
"Marvell 88E8058", 0),
116 PCI_ROM(0x11ab, 0x436b,
"m88e8071",
"Marvell 88E8071", 0),
117 PCI_ROM(0x11ab, 0x436c,
"m88e8072",
"Marvell 88E8072", 0),
118 PCI_ROM(0x11ab, 0x436d,
"m88e8055b",
"Marvell 88E8055", 0),
119 PCI_ROM(0x11ab, 0x4370,
"m88e8075",
"Marvell 88E8075", 0),
120 PCI_ROM(0x11ab, 0x4380,
"m88e8057",
"Marvell 88E8057", 0)
150 DBG(
PFX "%s: phy write timeout\n",
hw->dev[
port]->name);
300 u16 ctrl, ct1000, adv, pg, ledctrl, ledover,
reg;
371 if (
hw->pmd_type ==
'P') {
423 switch (sky2->
speed) {
462 switch (
hw->chip_id) {
820 u32 tp = space - space/4;
900 DBGIO(
PFX "queue %#x idx <- %d\n", q, idx);
975 for (i = 0; i < 0xffff; i++)
1050 unsigned i,
size, thresh;
1075 thresh = (
size - 8) /
sizeof(
u32);
1172 rxspace = ramsize / 2;
1174 rxspace = 8 + (2*(ramsize - 16))/3;
1207 DBGIO(
PFX "%s: le bases: st %p [%x], rx %p [%x], tx %p [%x]\n",
1254 DBGIO(
PFX "%s: tx queued, slot %d, len %d\n", dev->
name,
1348 &&
port == 0 &&
hw->dev[1]))
1414 static const char *
fc_name[] = {
1434 DBG(
PFX "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
1515 u16 istatus, phystat;
1520 DBGIO(
PFX "%s: phy interrupt status 0x%x 0x%x\n",
1578 DBGIO(
PFX "%s: rx slot %d status 0x%x len %d\n",
1612 DBG2(
PFX "%s: rx length error: status %#x length %d\n",
1627 DBG2(
PFX "%s: rx error, status 0x%x length %d\n",
1645 unsigned rx[2] = { 0, 0 };
1681 DBG2(
PFX "status OP_RXCHKS but checksum offloading disabled\n");
1697 }
while (
hw->st_idx != idx);
1757 DBG(
PFX "PCI hardware error (0x%x)\n", pci_err);
1772 DBG(
PFX "PCI-Express error (0x%x)\n", err);
1818 DBG(
PFX "%s: descriptor error q=%#x get=%d [%llx] last=%d put=%d should be %d\n",
1819 dev->
name, (
unsigned) q, idx, (
unsigned long long) le[idx],
1887 switch (
hw->chip_id) {
1905 DBG(
PFX "unknown chip ID!\n");
1932 switch(
hw->chip_id) {
1953 DBG(
PFX "unsupported revision Yukon-EC rev A1\n");
1983 DBG(
PFX "unsupported chip type 0x%x\n",
hw->chip_id);
1988 if (
hw->pmd_type ==
'L' ||
hw->pmd_type ==
'S' ||
hw->pmd_type ==
'P')
2038 DBG(
PFX "ignoring stuck error report bit\n");
2046 for (i = 0; i <
hw->ports; i++) {
2074 for (i = 0; i <
hw->ports; i++)
2078 for (i = 0; i <
hw->ports; i++) {
2097 for (i = 0; i <
hw->ports; i++)
2186 DBG(
PFX "etherdev alloc failed\n");
2190 dev->dev = &
hw->pdev->dev;
2221 static const char *sky2_name(
u8 chipid,
char *buf,
int sz)
2223 const char *
name[] = {
2237 snprintf(buf, sz,
"(chip %#x)", chipid);
2275 DBG(
PFX "cannot allocate hardware struct\n");
2283 DBG(
PFX "cannot map device registers\n");
2284 goto err_out_free_hw;
2290 goto err_out_iounmap;
2296 goto err_out_iounmap;
2299 DBG2(
PFX "Yukon-2 %s chip revision %d\n",
2300 sky2_name(
hw->chip_id, buf1,
sizeof(buf1)),
hw->chip_rev);
2308 goto err_out_free_pci;
2315 DBG(
PFX "cannot register net device\n");
2316 goto err_out_free_netdev;
2323 if (
hw->ports > 1) {
2328 DBG(
PFX "allocation for second device failed\n");
2330 DBG(
PFX "register of second port failed (%d)\n", err);
2342 err_out_free_netdev:
2365 for (i =
hw->ports-1; i >= 0; --i)
2378 for (i =
hw->ports-1; i >= 0; --i) {
#define EINVAL
Invalid argument.
#define PHY_M_POLC_LS1_P_MIX(x)
static u16 sky2_read16(const struct sky2_hw *hw, unsigned reg)
static void sky2_free_rings(struct sky2_port *sky2)
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
#define SKY2_HW_NEWER_PHY
static void sky2_rx_update(struct sky2_port *sky2, unsigned rxq)
static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
static struct sky2_tx_le * get_tx_le(struct sky2_port *sky2)
#define iob_put(iobuf, len)
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
static void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
#define EBUSY
Device or resource busy.
static void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
static u32 sky2_supported_modes(const struct sky2_hw *hw)
static const u16 copper_fc_adv[]
static unsigned int unsigned int reg
#define GM_SMI_CT_PHY_AD(x)
#define PHY_M_LED_MO_RX(x)
#define SUPPORTED_1000baseT_Half
static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
#define le32_to_cpu(value)
int(* open)(struct net_device *netdev)
Open network device.
#define SKY2_HW_ADV_POWER_CTL
uint16_t spec
ENA specification version.
static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
static const u32 portirq_msk[]
UINT8_t filter
Receive packet filter.
#define SUPPORTED_Autoneg
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
static struct tx_ring_info * tx_le_re(struct sky2_port *sky2, struct sky2_tx_le *le)
struct pci_device_id * ids
PCI ID table.
#define ADVERTISED_100baseT_Half
static u32 sky2_pci_read32(const struct sky2_hw *hw, unsigned reg)
struct arbelprm_completion_with_error error
#define SUPPORTED_100baseT_Full
#define TX_BACK_OFF_LIM(x)
static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
static u16 sky2_pci_read16(const struct sky2_hw *hw, unsigned reg)
static void sky2_net_irq(struct net_device *dev, int enable)
static void sky2_tx_clean(struct net_device *dev)
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
#define PCI_BASE_ADDRESS_0
static const u16 gm_fc_disable[]
#define PHY_M_LEDC_INIT_CTRL(x)
static void sky2_link_down(struct sky2_port *sky2)
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
static void sky2_remove(struct pci_device *pdev)
static void sky2_status_intr(struct sky2_hw *hw, u16 idx)
static u32 sky2_mhz(const struct sky2_hw *hw)
static void sky2_err_intr(struct sky2_hw *hw, u32 status)
#define PHY_M_MAC_MODE_SEL(x)
static u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
static void sky2_rx_clean(struct sky2_port *sky2)
static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
static const char * netdev_addr(struct net_device *netdev)
Get printable network device link-layer address.
static const unsigned txqaddr[]
#define PHY_M_FELP_LED2_CTRL(x)
#define SUPPORTED_10baseT_Half
struct sky2_tx_le * tx_le
static void sky2_rx_submit(struct sky2_port *sky2, const struct rx_ring_info *re)
static struct io_buffer * receive_new(struct sky2_port *sky2, struct rx_ring_info *re, unsigned int length)
static u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk)
static int sky2_probe(struct pci_device *pdev)
static struct pci_device_id sky2_id_table[]
Dynamic memory allocation.
#define ADVERTISED_1000baseT_Half
#define RB_ADDR(offs, queue)
#define PHY_M_POLC_STA0_CTRL(x)
uint32_t start
Starting offset.
#define PCI_ERR_UNCOR_STATUS
Uncorrectable error status.
static void sky2_rx_add(struct sky2_port *sky2, u8 op, u32 map, unsigned len)
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
char * strncpy(char *dest, const char *src, size_t max)
Copy string.
static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
#define TX_JAM_IPG_VAL(x)
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
#define ENOMEM
Not enough space.
static void sky2_pci_write16(struct sky2_hw *hw, unsigned reg, u16 val)
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define GM_GPCR_SPEED_1000
#define PHY_M_EC_DSC_2(x)
static const u16 fiber_fc_adv[]
#define __unused
Declare a variable or data structure as unused.
static void sky2_set_multicast(struct net_device *dev)
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
static void sky2_prefetch_init(struct sky2_hw *hw, u32 qaddr, u64 addr, u32 last)
static struct sky2_rx_le * sky2_next_rx(struct sky2_port *sky2)
static void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx)
#define PHY_M_LEDC_STA0_CTRL(x)
#define PHY_M_LED_BLINK_RT(x)
static struct io_buffer * sky2_rx_alloc(struct sky2_port *sky2)
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
struct net_device * netdev
#define PHY_M_EC_M_DSC(x)
#define PCI_STATUS_ERROR_BITS
void * priv
Driver private data.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
#define PHY_M_FELP_LED1_CTRL(x)
#define PHY_M_EC_S_DSC(x)
static int sky2_up(struct net_device *dev)
struct tx_ring_info * tx_ring
uint16_t count
Number of entries.
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
static struct tulip_private * tp
#define TX_IPG_JAM_DATA(x)
static void sky2_set_tx_stfwd(struct sky2_hw *hw, unsigned port)
void unregister_netdev(struct net_device *netdev)
Unregister network device.
static void sky2_poll(struct net_device *dev)
#define cpu_to_le32(value)
struct rx_ring_info * rx_ring
static void sky2_rx_stop(struct sky2_port *sky2)
static void sky2_power_on(struct sky2_hw *hw)
#define ADVERTISE_PAUSE_ASYM
static void(* free)(struct refcnt *refcnt))
#define PHY_M_POLC_IS0_P_MIX(x)
void * zalloc(size_t size)
Allocate cleared memory.
static int tx_dist(unsigned tail, unsigned head)
static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
#define PHY_M_LED_PULS_DUR(x)
int register_netdev(struct net_device *netdev)
Register network device.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
static struct net_device * sky2_init_netdev(struct sky2_hw *hw, unsigned port)
static void sky2_rx_map_iob(struct pci_device *pdev __unused, struct rx_ring_info *re, unsigned size __unused)
#define EOPNOTSUPP
Operation not supported on socket.
static void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
static void sky2_reset(struct sky2_hw *hw)
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
#define TX_JAM_LEN_VAL(x)
static int sky2_is_copper(const struct sky2_hw *hw)
#define SK_REG(port, reg)
static void rx_set_checksum(struct sky2_port *sky2)
static void sky2_tx_done(struct net_device *dev, u16 last)
#define PCI_STATUS
PCI status.
#define SUPPORTED_10baseT_Full
#define PHY_M_POLC_LOS_CTRL(x)
static __always_inline int struct dma_mapping * map
A PCI device ID list entry.
#define SUPPORTED_100baseT_Half
#define le16_to_cpu(value)
static void sky2_down(struct net_device *dev)
static void sky2_show_addr(struct net_device *dev)
static struct xen_remove_from_physmap * remove
#define PCI_CAP_ID_EXP
PCI Express.
struct pci_driver sky2_driver __pci_driver
Network device operations.
#define SKY2_HW_AUTO_TX_SUM
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
struct device * dev
Underlying hardware device.
enum flow_control flow_mode
#define PHY_M_FELP_LED0_CTRL(x)
static void sky2_le_error(struct sky2_hw *hw, unsigned port, u16 q, unsigned ring_size __unused)
static int sky2_init(struct sky2_hw *hw)
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
#define SKY2_HW_RAM_BUFFER
#define PHY_M_LEDC_STA1_CTRL(x)
static u16 gma_read16(const struct skge_hw *hw, int port, int reg)
#define iob_reserve(iobuf, len)
static uint16_t struct vmbus_xfer_pages_operations * op
char name[NETDEV_NAME_LEN]
Name of this network device.
static int sky2_xmit_frame(struct net_device *dev, struct io_buffer *iob)
static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
Media Independent Interface constants.
int(* probe)(struct pci_device *pci)
Probe device.
static u16 sky2_phy_speed(const struct sky2_hw *hw, u16 aux)
static const u32 coma_mode[]
static const u32 phy_power[]
void * data
Start of data.
#define PHY_M_POLC_STA1_CTRL(x)
#define EIO
Input/output error.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
#define Q_ADDR(reg, offs)
#define cpu_to_le16(value)
uint32_t end
Ending offset.
uint8_t size
Entry size (in 32-bit words)
static void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
void iounmap(volatile const void *io_addr)
Unmap I/O address.
static void sky2_link_up(struct sky2_port *sky2)
struct sky2_rx_le * rx_le
#define SUPPORTED_1000baseT_Full
#define ADVERTISED_10baseT_Full
static struct net_device_operations sky2_operations
#define GM_SMI_CT_REG_AD(x)
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port)
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
#define PHY_M_EC_MAC_S(x)
void mb(void)
Memory barrier.
static struct io_buffer * sky2_receive(struct net_device *dev, u16 length, u32 status)
#define ADVERTISE_PAUSE_CAP
#define DATA_BLIND_VAL(x)
#define STATUS_RING_ALIGN
static void tx_init(struct sky2_port *sky2)
static void gma_set_addr(struct skge_hw *hw, int port, int reg, const u8 *addr)
#define SKY2_HW_FIBRE_PHY
static void sky2_qset(struct sky2_hw *hw, u16 q)
#define PHY_M_LEDC_LOS_CTRL(x)
#define RAM_BUFFER(port, reg)
static int sky2_rx_start(struct sky2_port *sky2)
struct net_device * dev[2]
#define PHY_M_PC_MDI_XMODE(x)
static int tx_avail(const struct sky2_port *sky2)
static void sky2_hw_intr(struct sky2_hw *hw)
#define DBG(...)
Print a debugging message.
#define GM_GPCR_AU_ALL_DIS
static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status)
static u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
static void sky2_power_aux(struct sky2_hw *hw)
#define PHY_M_LED_MO_100(x)
static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port)
#define ADVERTISED_1000baseT_Full
static const unsigned rxqaddr[]
static u32 sky2_us2clk(const struct sky2_hw *hw, u32 us)
#define NULL
NULL pointer (VOID *)
#define ADVERTISED_100baseT_Full
static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
#define ETIMEDOUT
Connection timed out.
#define PCI_ROM(_vendor, _device, _name, _description, _data)
static void sky2_pci_write32(struct sky2_hw *hw, unsigned reg, u32 val)
struct bofm_section_header done
#define ADVERTISED_10baseT_Half
#define PHY_M_POLC_INIT_CTRL(x)
static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space)
enum flow_control flow_status
if(natsemi->flags &NATSEMI_64BIT) return 1
void * memset(void *dest, int character, size_t len) __nonnull
static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)