69 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
71 #include <linux/module.h>
72 #include <linux/kernel.h>
73 #include <linux/types.h>
74 #include <linux/compiler.h>
75 #include <linux/slab.h>
81 #include <linux/pci.h>
84 #include <linux/list.h>
87 #include <linux/netdevice.h>
90 #include <linux/ethtool.h>
92 #include <linux/random.h>
93 #include <linux/mii.h>
95 #include <linux/tcp.h>
103 #include <asm/byteorder.h>
104 #include <asm/uaccess.h>
106 #define cas_page_map(x) kmap_atomic((x))
107 #define cas_page_unmap(x) kunmap_atomic((x))
108 #define CAS_NCPUS num_online_cpus()
110 #define cas_skb_release(x) netif_rx(x)
113 #define USE_HP_WORKAROUND
114 #define HP_WORKAROUND_DEFAULT
115 #define CAS_HP_ALT_FIRMWARE cas_prog_null
119 #define USE_TX_COMPWB
120 #define USE_CSMA_CD_PROTO
122 #undef USE_ENTROPY_DEV
135 #define USE_PAGE_ORDER
136 #define RX_DONT_BATCH 0
137 #define RX_COPY_ALWAYS 0
138 #define RX_COPY_MIN 64
139 #undef RX_COUNT_BUFFERS
141 #define DRV_MODULE_NAME "cassini"
142 #define DRV_MODULE_VERSION "1.6"
143 #define DRV_MODULE_RELDATE "21 May 2008"
145 #define CAS_DEF_MSG_ENABLE \
158 #define CAS_TX_TIMEOUT (HZ)
159 #define CAS_LINK_TIMEOUT (22*HZ/10)
160 #define CAS_LINK_FAST_TIMEOUT (1)
165 #define STOP_TRIES_PHY 1000
166 #define STOP_TRIES 5000
172 #define CAS_MIN_FRAME 97
173 #define CAS_1000MB_MIN_FRAME 255
174 #define CAS_MIN_MTU 60
175 #define CAS_MAX_MTU min(((cp->page_size << 1) - 0x50), 9000)
183 #define CAS_RESET_MTU 1
184 #define CAS_RESET_ALL 2
185 #define CAS_RESET_SPARE 3
191 static int cassini_debug = -1;
192 static int link_mode;
199 MODULE_PARM_DESC(cassini_debug,
"Cassini bitmapped debugging message enable value");
207 #define DEFAULT_LINKDOWN_TIMEOUT 5
214 "min reset interval in sec. for PCS linkdown issue; disabled if not positive");
221 static int link_transition_timeout;
244 static void cas_set_link_modes(
struct cas *
cp);
246 static inline void cas_lock_tx(
struct cas *
cp)
254 static inline void cas_lock_all(
struct cas *cp)
256 spin_lock_irq(&cp->
lock);
268 #define cas_lock_all_save(cp, flags) \
270 struct cas *xxxcp = (cp); \
271 spin_lock_irqsave(&xxxcp->lock, flags); \
272 cas_lock_tx(xxxcp); \
275 static inline void cas_unlock_tx(
struct cas *cp)
279 for (i = N_TX_RINGS; i > 0; i--)
280 spin_unlock(&cp->
tx_lock[i - 1]);
283 static inline void cas_unlock_all(
struct cas *cp)
286 spin_unlock_irq(&cp->
lock);
289 #define cas_unlock_all_restore(cp, flags) \
291 struct cas *xxxcp = (cp); \
292 cas_unlock_tx(xxxcp); \
293 spin_unlock_irqrestore(&xxxcp->lock, flags); \
296 static void cas_disable_irq(
struct cas *cp,
const int ring)
307 #if defined (USE_PCI_INTB) || defined(USE_PCI_INTC) || defined(USE_PCI_INTD)
329 static inline void cas_mask_intr(
struct cas *cp)
334 cas_disable_irq(cp, i);
337 static void cas_enable_irq(
struct cas *cp,
const int ring)
346 #if defined (USE_PCI_INTB) || defined(USE_PCI_INTC) || defined(USE_PCI_INTD)
366 static inline void cas_unmask_intr(
struct cas *cp)
371 cas_enable_irq(cp, i);
374 static inline void cas_entropy_gather(
struct cas *cp)
376 #ifdef USE_ENTROPY_DEV
386 static inline void cas_entropy_reset(
struct cas *cp)
388 #ifdef USE_ENTROPY_DEV
406 static u16 cas_phy_read(
struct cas *cp,
int reg)
413 cmd |=
CAS_BASE(MIF_FRAME_REG_ADDR, reg);
418 while (limit-- > 0) {
427 static int cas_phy_write(
struct cas *cp,
int reg,
u16 val)
434 cmd |=
CAS_BASE(MIF_FRAME_REG_ADDR, reg);
440 while (limit-- > 0) {
449 static void cas_phy_powerup(
struct cas *cp)
459 static void cas_phy_powerdown(
struct cas *cp)
479 #ifdef RX_COUNT_BUFFERS
480 #define RX_USED_ADD(x, y) ((x)->used += (y))
481 #define RX_USED_SET(x, y) ((x)->used = (y))
483 #define RX_USED_ADD(x, y)
484 #define RX_USED_SET(x, y)
498 INIT_LIST_HEAD(&page->
list);
513 static void cas_spare_init(
struct cas *cp)
520 INIT_LIST_HEAD(&cp->rx_spare_list);
526 static void cas_spare_free(
struct cas *cp)
531 INIT_LIST_HEAD(&
list);
533 list_splice_init(&cp->rx_spare_list, &
list);
539 INIT_LIST_HEAD(&
list);
559 static void cas_spare_recover(
struct cas *cp,
const gfp_t flags)
569 INIT_LIST_HEAD(&
list);
589 if (page_count(page->
buffer) > 1)
595 list_add(elem, &cp->rx_spare_list);
600 cas_page_free(cp, page);
605 if (!list_empty(&
list)) {
618 INIT_LIST_HEAD(&
list);
629 list_splice(&
list, &cp->rx_spare_list);
641 if (list_empty(&cp->rx_spare_list)) {
646 if (list_empty(&cp->rx_spare_list)) {
648 "no spare buffers available\n");
654 entry = cp->rx_spare_list.next;
674 static void cas_mif_poll(
struct cas *cp,
const int enable)
696 static void cas_begin_auto_negotiation(
struct cas *cp,
struct ethtool_cmd *ep)
702 int oldstate = cp->
lstate;
703 int link_was_not_down = !(oldstate ==
link_down);
726 netdev_info(cp->
dev,
"PCS link down\n");
729 netdev_info(cp->
dev,
"link configuration changed\n");
744 if (changed && link_was_not_down) {
795 static int cas_reset_mii_phy(
struct cas *cp)
811 static int cas_saturn_firmware_init(
struct cas *cp)
814 const char fw_name[] =
"sun/cassini.bin";
822 pr_err(
"Failed to load firmware \"%s\"\n",
827 pr_err(
"bogus length %zu in \"%s\"\n",
845 static void cas_saturn_firmware_load(
struct cas *cp)
849 cas_phy_powerdown(cp);
867 for (i = 0; i < cp->
fw_size; i++)
877 static void cas_phy_init(
struct cas *cp)
887 cas_reset_mii_phy(cp);
892 cas_phy_write(cp,
MII_BMCR, 0x00f1);
928 cas_saturn_firmware_load(cp);
974 while (--limit > 0) {
981 netdev_warn(cp->
dev,
"PCS reset bit would not clear [%08x]\n",
1006 static int cas_pcs_link_check(
struct cas *cp)
1032 stat &= ~PCS_MII_STATUS_LINK_STATUS;
1037 if (stat & PCS_MII_STATUS_LINK_STATUS) {
1043 cas_set_link_modes(cp);
1049 if (link_transition_timeout != 0 &&
1090 if (link_transition_timeout != 0 &&
1117 return cas_pcs_link_check(cp);
1120 static int cas_txmac_interrupt(
struct net_device *dev,
1121 struct cas *cp,
u32 status)
1129 "txmac interrupt, txmac_stat: 0x%x\n", txmac_stat);
1135 !(txmac_stat & ~MAC_TX_DEFER_TIMER))
1140 netdev_err(dev,
"TX MAC xmit underrun\n");
1145 netdev_err(dev,
"TX MAC max packet size error\n");
1156 cp->
net_stats[0].tx_aborted_errors += 0x10000;
1161 cp->
net_stats[0].tx_aborted_errors += 0x10000;
1179 while ((inst = firmware) && inst->
note) {
1192 val |=
CAS_BASE(HP_INSTR_RAM_MID_OP, inst->
op);
1205 static void cas_init_rx_dma(
struct cas *cp)
1233 writel((desc_dma + val) & 0xffffffff, cp->
regs +
1252 writel((desc_dma + val) & 0xffffffff, cp->
regs +
1268 if (N_RX_COMP_RINGS > 1)
1278 val =
CAS_BASE(RX_PAUSE_THRESH_OFF,
1280 val |=
CAS_BASE(RX_PAUSE_THRESH_ON,
1285 for (i = 0; i < 64; i++) {
1333 size = cp->
dev->mtu + 64;
1339 else if (size <= 0x800)
1341 else if (size <= 0x1000)
1348 val |=
CAS_BASE(RX_PAGE_SIZE_MTU_STRIDE, i);
1350 val |=
CAS_BASE(RX_PAGE_SIZE_MTU_OFF, 0x1);
1354 if (CAS_HP_FIRMWARE == cas_prog_null)
1363 static inline void cas_rxc_init(
struct cas_rx_comp *rxc)
1365 memset(rxc, 0,
sizeof(*rxc));
1378 if (page_count(page->
buffer) == 1)
1381 new = cas_page_dequeue(cp);
1391 static cas_page_t *cas_page_swap(
struct cas *cp,
const int ring,
1398 if (page_count(page0[index]->
buffer) > 1) {
1406 return page0[
index];
1409 static void cas_clean_rxds(
struct cas *cp)
1418 while ((skb = __skb_dequeue(&cp->
rx_flows[i]))) {
1425 for (i = 0; i <
size; i++) {
1437 static void cas_clean_rxcs(
struct cas *cp)
1447 cas_rxc_init(rxc + j);
1459 static int cas_rxmac_reset(
struct cas *cp)
1467 for (limit = 0; limit <
STOP_TRIES; limit++) {
1472 if (limit == STOP_TRIES) {
1473 netdev_err(dev,
"RX MAC will not disable, resetting whole chip\n");
1479 for (limit = 0; limit <
STOP_TRIES; limit++) {
1484 if (limit == STOP_TRIES) {
1485 netdev_err(dev,
"RX DMA will not disable, resetting whole chip\n");
1493 for (limit = 0; limit <
STOP_TRIES; limit++) {
1498 if (limit == STOP_TRIES) {
1499 netdev_err(dev,
"RX reset command will not execute, resetting whole chip\n");
1508 cas_init_rx_dma(cp);
1520 static int cas_rxmac_interrupt(
struct net_device *dev,
struct cas *cp,
1533 cp->
net_stats[0].rx_frame_errors += 0x10000;
1536 cp->
net_stats[0].rx_crc_errors += 0x10000;
1539 cp->
net_stats[0].rx_length_errors += 0x10000;
1553 static int cas_mac_interrupt(
struct net_device *dev,
struct cas *cp,
1562 "mac interrupt, stat: 0x%x\n", stat);
1579 static inline int cas_mdio_link_not_up(
struct cas *cp)
1613 val &= ~CAS_BMCR_SPEED1000;
1621 val &= ~BMCR_FULLDPLX;
1623 val &= ~BMCR_SPEED100;
1636 static int cas_mii_link_check(
struct cas *cp,
const u16 bmsr)
1650 cas_mif_poll(cp, 0);
1655 "Got link after fallback, retrying autoneg once...\n");
1659 cas_mif_poll(cp, 1);
1666 cas_set_link_modes(cp);
1687 cas_mdio_link_not_up(cp);
1692 static int cas_mif_interrupt(
struct net_device *dev,
struct cas *cp,
1699 if (
CAS_VAL(MIF_STATUS_POLL_STATUS, stat) == 0)
1702 bmsr =
CAS_VAL(MIF_STATUS_POLL_DATA, stat);
1703 return cas_mii_link_check(cp, bmsr);
1706 static int cas_pci_interrupt(
struct net_device *dev,
struct cas *cp,
1714 netdev_err(dev,
"PCI error [%04x:%04x]",
1720 pr_cont(
" <No ACK64# during ABS64 cycle>");
1723 pr_cont(
" <Delayed transaction timeout>");
1727 pr_cont(
" <BIM DMA 0 write req>");
1729 pr_cont(
" <BIM DMA 0 read req>");
1732 if (stat & PCI_ERR_OTHER) {
1739 netdev_err(dev,
"Read PCI cfg space status [%04x]\n", cfg);
1741 netdev_err(dev,
"PCI parity error detected\n");
1743 netdev_err(dev,
"PCI target abort\n");
1745 netdev_err(dev,
"PCI master acks target abort\n");
1747 netdev_err(dev,
"PCI master abort\n");
1749 netdev_err(dev,
"PCI system error SERR#\n");
1751 netdev_err(dev,
"PCI parity error\n");
1754 cfg &= (PCI_STATUS_PARITY |
1755 PCI_STATUS_SIG_TARGET_ABORT |
1756 PCI_STATUS_REC_TARGET_ABORT |
1757 PCI_STATUS_REC_MASTER_ABORT |
1758 PCI_STATUS_SIG_SYSTEM_ERROR |
1772 static int cas_abnormal_irq(
struct net_device *dev,
struct cas *cp,
1778 "corrupt rx tag framing\n");
1788 "length mismatch for rx frame\n");
1796 if (cas_pcs_interrupt(dev, cp, status))
1801 if (cas_txmac_interrupt(dev, cp, status))
1806 if (cas_rxmac_interrupt(dev, cp, status))
1811 if (cas_mac_interrupt(dev, cp, status))
1816 if (cas_mif_interrupt(dev, cp, status))
1821 if (cas_pci_interrupt(dev, cp, status))
1830 netdev_err(dev,
"reset called in cas_abnormal_irq [0x%x]\n", status);
1834 netdev_err(dev,
"reset called in cas_abnormal_irq\n");
1843 #define CAS_TABORT(x) (((x)->cas_flags & CAS_FLAG_TARGET_ABORT) ? 2 : 1)
1844 #define CAS_ROUND_PAGE(x) (((x) + PAGE_SIZE - 1) & PAGE_MASK)
1845 static inline int cas_calc_tabort(
struct cas *cp,
const unsigned long addr,
1848 unsigned long off = addr + len;
1857 static inline void cas_tx_ringN(
struct cas *cp,
int ring,
int limit)
1864 spin_lock(&cp->
tx_lock[ring]);
1867 entry = cp->
tx_old[ring];
1870 while (entry != limit) {
1883 count -= skb_shinfo(skb)->nr_frags +
1889 "tx[%d] done, slot %d\n", ring, entry);
1894 for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) {
1898 dlen =
CAS_VAL(TX_DESC_BUFLEN,
1900 pci_unmap_page(cp->
pdev, daddr, dlen,
1923 if (netif_queue_stopped(dev) &&
1925 netif_wake_queue(dev);
1926 spin_unlock(&cp->
tx_lock[ring]);
1933 #ifdef USE_TX_COMPWB
1937 "tx interrupt, status: 0x%x, %llx\n",
1938 status, (
unsigned long long)compwb);
1941 #ifdef USE_TX_COMPWB
1943 limit = (
CAS_VAL(TX_COMPWB_MSB, compwb) << 8) |
1944 CAS_VAL(TX_COMPWB_LSB, compwb);
1949 if (cp->
tx_old[ring] != limit)
1950 cas_tx_ringN(cp, ring, limit);
1955 static int cas_rx_process_pkt(
struct cas *cp,
struct cas_rx_comp *rxc,
1956 int entry,
const u64 *words,
1963 void *
addr, *crcaddr;
1967 hlen =
CAS_VAL(RX_COMP2_HDR_SIZE, words[1]);
1968 dlen =
CAS_VAL(RX_COMP1_DATA_SIZE, words[0]);
1976 skb = netdev_alloc_skb(cp->
dev, alloclen + swivel + cp->
crc_size);
1981 skb_reserve(skb, swivel);
1984 addr = crcaddr =
NULL;
1986 i =
CAS_VAL(RX_COMP2_HDR_INDEX, words[1]);
1988 off =
CAS_VAL(RX_COMP2_HDR_OFF, words[1]) * 0x100 +
1994 pci_dma_sync_single_for_cpu(cp->
pdev, page->
dma_addr + off, i,
1997 memcpy(p, addr + off, i);
1998 pci_dma_sync_single_for_device(cp->
pdev, page->
dma_addr + off, i,
2007 if (alloclen < (hlen + dlen)) {
2011 i =
CAS_VAL(RX_COMP1_DATA_INDEX, words[0]);
2013 off =
CAS_VAL(RX_COMP1_DATA_OFF, words[0]) + swivel;
2018 "rx page overflow: %d\n", hlen);
2025 pci_dma_sync_single_for_cpu(cp->
pdev, page->
dma_addr + off, i,
2030 if (p == (
char *) skb->
data) {
2033 pci_dma_sync_single_for_device(cp->
pdev, page->
dma_addr + off, i,
2044 skb_shinfo(skb)->nr_frags++;
2047 skb->
len += hlen - swivel;
2049 __skb_frag_set_page(frag, page->
buffer);
2050 __skb_frag_ref(frag);
2052 skb_frag_size_set(frag, hlen - swivel);
2059 i =
CAS_VAL(RX_COMP2_NEXT_INDEX, words[1]);
2064 pci_dma_sync_single_for_device(cp->
pdev, page->
dma_addr,
2068 skb_shinfo(skb)->nr_frags++;
2073 __skb_frag_set_page(frag, page->
buffer);
2074 __skb_frag_ref(frag);
2076 skb_frag_size_set(frag, hlen);
2082 crcaddr = addr + off + hlen;
2090 i =
CAS_VAL(RX_COMP1_DATA_INDEX, words[0]);
2092 off =
CAS_VAL(RX_COMP1_DATA_OFF, words[0]) + swivel;
2096 "rx page overflow: %d\n", hlen);
2103 pci_dma_sync_single_for_cpu(cp->
pdev, page->
dma_addr + off, i,
2106 memcpy(p, addr + off, i);
2107 pci_dma_sync_single_for_device(cp->
pdev, page->
dma_addr + off, i,
2110 if (p == (
char *) skb->
data)
2116 if ((words[0] & RX_COMP1_SPLIT_PKT) && ((dlen -= hlen) > 0)) {
2118 i =
CAS_VAL(RX_COMP2_NEXT_INDEX, words[1]);
2125 pci_dma_sync_single_for_device(cp->
pdev, page->
dma_addr,
2134 crcaddr = skb->
data + alloclen;
2143 csum_unfold(csum)));
2149 skb->
csum = csum_unfold(~csum);
2152 skb_checksum_none_assert(skb);
2171 static inline void cas_rx_flow_pkt(
struct cas *cp,
const u64 *words,
2174 int flowid =
CAS_VAL(RX_COMP3_FLOWID, words[2]) & (N_RX_FLOWS - 1);
2181 __skb_queue_tail(flow, skb);
2183 while ((skb = __skb_dequeue(flow))) {
2192 static void cas_post_page(
struct cas *cp,
const int ring,
const int index)
2197 entry = cp->
rx_old[ring];
2199 new = cas_page_swap(cp, ring, index);
2220 static int cas_post_rxds_ringN(
struct cas *cp,
int ring,
int num)
2226 entry = cp->
rx_old[ring];
2229 "rxd[%d] interrupt, done: %d\n", ring, entry);
2232 count = entry & 0x3;
2233 last =
RX_DESC_ENTRY(ring, num ? entry + num - 4: entry - 4);
2235 while (entry != last) {
2237 if (page_count(page[entry]->
buffer) > 1) {
2248 cp->
rx_last[ring] = num ? num - released : 0;
2293 static int cas_rx_ringN(
struct cas *cp,
int ring,
int budget)
2300 "rx[%d] interrupt, done: %d/%d\n",
2304 entry = cp->
rx_new[ring];
2319 type =
CAS_VAL(RX_COMP1_TYPE, words[0]);
2346 len = cas_rx_process_pkt(cp, rxc, entry, words, &skb);
2359 cas_rx_flow_pkt(cp, words, skb);
2372 i =
CAS_VAL(RX_COMP2_HDR_INDEX, words[1]);
2373 dring =
CAS_VAL(RX_INDEX_RING, i);
2375 cas_post_page(cp, dring, i);
2379 i =
CAS_VAL(RX_COMP1_DATA_INDEX, words[0]);
2380 dring =
CAS_VAL(RX_INDEX_RING, i);
2382 cas_post_page(cp, dring, i);
2386 i =
CAS_VAL(RX_COMP2_NEXT_INDEX, words[1]);
2387 dring =
CAS_VAL(RX_INDEX_RING, i);
2389 cas_post_page(cp, dring, i);
2394 CAS_VAL(RX_COMP1_SKIP, words[0]));
2396 if (budget && (npackets >= budget))
2403 netdev_info(cp->
dev,
"Memory squeeze, deferring packet\n");
2409 static void cas_post_rxcs_ringN(
struct net_device *dev,
2410 struct cas *cp,
int ring)
2416 entry = cp->
rx_new[ring];
2418 "rxc[%d] interrupt, done: %d/%d\n",
2422 while (last != entry) {
2423 cas_rxc_init(rxc + last);
2439 #if defined(USE_PCI_INTC) || defined(USE_PCI_INTD)
2440 static inline void cas_handle_irqN(
struct net_device *dev,
2441 struct cas *cp,
const u32 status,
2445 cas_post_rxcs_ringN(dev, cp, ring);
2451 struct cas *cp = netdev_priv(dev);
2452 unsigned long flags;
2464 napi_schedule(&cp->
napi);
2466 cas_rx_ringN(cp, ring, 0);
2468 status &= ~INTR_RX_DONE_ALT;
2472 cas_handle_irqN(dev, cp, status, ring);
2473 spin_unlock_irqrestore(&cp->
lock, flags);
2480 static inline void cas_handle_irq1(
struct cas *cp,
const u32 status)
2485 cas_post_rxds_ringN(cp, 1, 0);
2496 cas_post_rxcs_ringN(cp, 1);
2500 static irqreturn_t cas_interrupt1(
int irq,
void *dev_id)
2503 struct cas *cp = netdev_priv(dev);
2504 unsigned long flags;
2512 if (status & INTR_RX_DONE_ALT) {
2515 napi_schedule(&cp->
napi);
2517 cas_rx_ringN(cp, 1, 0);
2519 status &= ~INTR_RX_DONE_ALT;
2522 cas_handle_irq1(cp, status);
2523 spin_unlock_irqrestore(&cp->
lock, flags);
2528 static inline void cas_handle_irq(
struct net_device *dev,
2529 struct cas *cp,
const u32 status)
2533 cas_abnormal_irq(dev, cp, status);
2539 cas_post_rxds_ringN(cp, 0, 0);
2549 cas_post_rxcs_ringN(dev, cp, 0);
2552 static irqreturn_t cas_interrupt(
int irq,
void *dev_id)
2555 struct cas *cp = netdev_priv(dev);
2556 unsigned long flags;
2564 cas_tx(dev, cp, status);
2571 napi_schedule(&cp->
napi);
2573 cas_rx_ringN(cp, 0, 0);
2575 status &= ~INTR_RX_DONE;
2579 cas_handle_irq(dev, cp, status);
2580 spin_unlock_irqrestore(&cp->
lock, flags);
2590 int i, enable_intr, credits;
2592 unsigned long flags;
2595 cas_tx(dev, cp, status);
2596 spin_unlock_irqrestore(&cp->
lock, flags);
2610 credits += cas_rx_ringN(cp, j, budget / N_RX_COMP_RINGS);
2611 if (credits >= budget) {
2622 cas_handle_irq(dev, cp, status);
2625 if (N_RX_COMP_RINGS > 1) {
2628 cas_handle_irq1(dev, cp, status);
2633 if (N_RX_COMP_RINGS > 2) {
2636 cas_handle_irqN(dev, cp, status, 2);
2641 if (N_RX_COMP_RINGS > 3) {
2644 cas_handle_irqN(dev, cp, status, 3);
2647 spin_unlock_irqrestore(&cp->
lock, flags);
2650 cas_unmask_intr(cp);
2656 #ifdef CONFIG_NET_POLL_CONTROLLER
2657 static void cas_netpoll(
struct net_device *dev)
2659 struct cas *cp = netdev_priv(dev);
2661 cas_disable_irq(cp, 0);
2662 cas_interrupt(cp->
pdev->irq, dev);
2663 cas_enable_irq(cp, 0);
2666 if (N_RX_COMP_RINGS > 1) {
2671 if (N_RX_COMP_RINGS > 2) {
2676 if (N_RX_COMP_RINGS > 3) {
2683 static void cas_tx_timeout(
struct net_device *dev)
2685 struct cas *cp = netdev_priv(dev);
2687 netdev_err(dev,
"transmit timed out, resetting\n");
2689 netdev_err(dev,
"hrm.. hw not running!\n");
2693 netdev_err(dev,
"MIF_STATE[%08x]\n",
2696 netdev_err(dev,
"MAC_STATE[%08x]\n",
2699 netdev_err(dev,
"TX_STATE[%08x:%08x:%08x] FIFO[%08x:%08x:%08x] SM1[%08x] SM2[%08x]\n",
2709 netdev_err(dev,
"RX_STATE[%08x:%08x:%08x]\n",
2714 netdev_err(dev,
"HP_STATE[%08x:%08x:%08x:%08x]\n",
2730 static inline int cas_intme(
int ring,
int entry)
2739 static void cas_write_txd(
struct cas *cp,
int ring,
int entry,
2744 ctrl |=
CAS_BASE(TX_DESC_BUFLEN, len);
2745 if (cas_intme(ring, entry))
2753 static inline void *tx_tiny_buf(
struct cas *cp,
const int ring,
2759 static inline dma_addr_t tx_tiny_map(
struct cas *cp,
const int ring,
2760 const int entry,
const int tentry)
2767 static inline int cas_xmit_tx_ringN(
struct cas *cp,
int ring,
2771 int entry, nr_frags,
frag, tabort, tentry;
2773 unsigned long flags;
2781 CAS_TABORT(cp)*(skb_shinfo(skb)->nr_frags + 1)) {
2782 netif_stop_queue(dev);
2783 spin_unlock_irqrestore(&cp->
tx_lock[ring], flags);
2784 netdev_err(dev,
"BUG! Tx Ring full when queue awake!\n");
2790 const u64 csum_start_off = skb_checksum_start_offset(skb);
2794 CAS_BASE(TX_DESC_CSUM_START, csum_start_off) |
2795 CAS_BASE(TX_DESC_CSUM_STUFF, csum_stuff_off);
2798 entry = cp->
tx_new[ring];
2801 nr_frags = skb_shinfo(skb)->nr_frags;
2802 len = skb_headlen(skb);
2808 tabort = cas_calc_tabort(cp, (
unsigned long) skb->
data, len);
2811 cas_write_txd(cp, ring, entry, mapping, len - tabort,
2815 skb_copy_from_linear_data_offset(skb, len - tabort,
2816 tx_tiny_buf(cp, ring, entry), tabort);
2817 mapping = tx_tiny_map(cp, ring, entry, tentry);
2818 cas_write_txd(cp, ring, entry, mapping, tabort, ctrl,
2821 cas_write_txd(cp, ring, entry, mapping, len, ctrl |
2826 for (frag = 0; frag < nr_frags; frag++) {
2829 len = skb_frag_size(fragp);
2830 mapping = skb_frag_dma_map(&cp->
pdev->dev, fragp, 0, len,
2833 tabort = cas_calc_tabort(cp, fragp->
page_offset, len);
2838 cas_write_txd(cp, ring, entry, mapping, len - tabort,
2843 memcpy(tx_tiny_buf(cp, ring, entry),
2847 mapping = tx_tiny_map(cp, ring, entry, tentry);
2851 cas_write_txd(cp, ring, entry, mapping, len, ctrl,
2852 (frag + 1 == nr_frags));
2858 netif_stop_queue(dev);
2861 "tx[%d] queued, slot %d, skblen %d, avail %d\n",
2864 spin_unlock_irqrestore(&cp->
tx_lock[ring], flags);
2870 struct cas *cp = netdev_priv(dev);
2888 static void cas_init_tx_dma(
struct cas *cp)
2896 #ifdef USE_TX_COMPWB
2917 writel((desc_dma + off) & 0xffffffff, cp->
regs +
2942 static inline void cas_init_dma(
struct cas *cp)
2944 cas_init_tx_dma(cp);
2945 cas_init_rx_dma(cp);
2948 static void cas_process_mc_list(
struct cas *cp)
2955 memset(hash_table, 0,
sizeof(hash_table));
2975 hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf));
2978 for (i = 0; i < 16; i++)
2983 static u32 cas_setup_multicast(
struct cas *cp)
2992 for (i=0; i < 16; i++)
2997 cas_process_mc_list(cp);
3005 static void cas_clear_mac_err(
struct cas *cp)
3021 static void cas_mac_reset(
struct cas *cp)
3047 netdev_err(cp->
dev,
"mac tx[%d]/rx[%d] reset failed [%08x]\n",
3055 static void cas_init_mac(
struct cas *cp)
3057 unsigned char *
e = &cp->
dev->dev_addr[0];
3065 #if !defined(CONFIG_SPARC64) && !defined(CONFIG_ALPHA)
3115 for (i = 0; i < 45; i++)
3129 cas_clear_mac_err(cp);
3130 spin_unlock(&cp->
stat_lock[N_TX_RINGS]);
3146 static void cas_init_pause_thresholds(
struct cas *cp)
3154 int max_frame = (cp->
dev->mtu +
ETH_HLEN + 4 + 4 + 64) & ~63;
3160 int on = off - max_frame;
3167 static int cas_vpd_match(
const void __iomem *p,
const char *
str)
3169 int len =
strlen(str) + 1;
3172 for (i = 0; i < len; i++) {
3173 if (
readb(p + i) != str[i])
3191 static int cas_get_vpd_info(
struct cas *cp,
unsigned char *dev_addr,
3198 #define VPD_FOUND_MAC 0x01
3199 #define VPD_FOUND_PHY 0x02
3204 #if defined(CONFIG_SPARC)
3205 const unsigned char *
addr;
3213 if (
readb(p) != 0x55 ||
readb(p + 1) != 0xaa)
3214 goto use_random_mac_addr;
3220 if ((
readb(p + i + 0) == 0x50) &&
3221 (
readb(p + i + 1) == 0x43) &&
3222 (
readb(p + i + 2) == 0x49) &&
3223 (
readb(p + i + 3) == 0x52)) {
3224 base = p + (
readb(p + i + 8) |
3225 (
readb(p + i + 9) << 8));
3230 if (!base || (
readb(base) != 0x82))
3231 goto use_random_mac_addr;
3233 i = (
readb(base + 1) | (
readb(base + 2) << 8)) + 3;
3234 while (i < EXPANSION_ROM_SIZE) {
3235 if (
readb(base + i) != 0x90)
3236 goto use_random_mac_addr;
3239 len =
readb(base + i + 1) | (
readb(base + i + 2) << 8);
3242 kstart = base + i + 3;
3244 while ((p - kstart) < len) {
3245 int klen =
readb(p + 2);
3288 if (
readb(p) !=
'I')
3292 type =
readb(p + 3);
3294 if ((klen == 29) &&
readb(p + 4) == 6 &&
3295 cas_vpd_match(p + 5,
3296 "local-mac-address")) {
3297 if (mac_off++ > offset)
3301 for (j = 0; j < 6; j++)
3311 #ifdef USE_ENTROPY_DEV
3313 cas_vpd_match(p + 5,
"entropy-dev") &&
3314 cas_vpd_match(p + 17,
"vms110")) {
3320 if (found & VPD_FOUND_PHY)
3323 if ((klen == 18) &&
readb(p + 4) == 4 &&
3324 cas_vpd_match(p + 5,
"phy-type")) {
3325 if (cas_vpd_match(p + 14,
"pcs")) {
3331 if ((klen == 23) &&
readb(p + 4) == 4 &&
3332 cas_vpd_match(p + 5,
"phy-interface")) {
3333 if (cas_vpd_match(p + 19,
"pcs")) {
3343 found |= VPD_FOUND_PHY;
3351 use_random_mac_addr:
3352 if (found & VPD_FOUND_MAC)
3355 #if defined(CONFIG_SPARC)
3358 memcpy(dev_addr, addr, 6);
3364 pr_info(
"MAC address not found in ROM VPD\n");
3376 static void cas_check_pci_invariants(
struct cas *cp)
3407 static int cas_check_invariants(
struct cas *cp)
3415 #ifdef USE_PAGE_ORDER
3438 cp->
phy_type = cas_get_vpd_info(cp, cp->
dev->dev_addr,
3453 cas_mif_poll(cp, 0);
3456 for (i = 0; i < 32; i++) {
3460 for (j = 0; j < 3; j++) {
3464 if (phy_id && (phy_id != 0xFFFFFFFF)) {
3470 pr_err(
"MII phy did not respond [%08x]\n",
3484 static inline void cas_start_dma(
struct cas *cp)
3509 if (i < 0) txfailed = 1;
3516 "enabling mac failed [tx:%08x:%08x]\n",
3520 goto enable_rx_done;
3524 netdev_err(cp->
dev,
"enabling mac failed [%s:%08x:%08x]\n",
3525 (txfailed ?
"tx,rx" :
"rx"),
3530 cas_unmask_intr(cp);
3545 static void cas_read_pcs_link_mode(
struct cas *cp,
int *
fd,
int *spd,
3557 static void cas_read_mii_link_mode(
struct cas *cp,
int *fd,
int *spd,
3567 val = cas_phy_read(cp,
MII_LPA);
3593 static void cas_set_link_modes(
struct cas *cp)
3596 int full_duplex, speed,
pause;
3603 cas_mif_poll(cp, 0);
3606 cas_read_mii_link_mode(cp, &full_duplex, &speed,
3614 else if (val & CAS_BMCR_SPEED1000)
3618 cas_mif_poll(cp, 1);
3622 cas_read_pcs_link_mode(cp, &full_duplex, &speed, &pause);
3630 speed, full_duplex ?
"full" :
"half");
3650 #ifndef USE_CSMA_CD_PROTO
3662 if ((speed == 1000) && !full_duplex) {
3700 netdev_info(cp->
dev,
"Pause is enabled (rxfifo: %d off: %d on: %d)\n",
3704 }
else if (pause & 0x10) {
3705 netdev_info(cp->
dev,
"TX pause enabled\n");
3707 netdev_info(cp->
dev,
"Pause is disabled\n");
3724 static void cas_init_hw(
struct cas *cp,
int restart_link)
3729 cas_init_pause_thresholds(cp);
3736 cas_begin_auto_negotiation(cp,
NULL);
3738 cas_set_link_modes(cp);
3747 static void cas_hard_reset(
struct cas *cp)
3755 static void cas_global_reset(
struct cas *cp,
int blkflag)
3777 while (limit-- > 0) {
3783 netdev_err(cp->
dev,
"sw reset failed\n");
3794 writel(0xFFFFFFFFU & ~(PCI_ERR_BADACK | PCI_ERR_DTRTO |
3795 PCI_ERR_OTHER | PCI_ERR_BIM_DMA_WRITE |
3796 PCI_ERR_BIM_DMA_READ), cp->
regs +
3805 static void cas_reset(
struct cas *cp,
int blkflag)
3810 cas_global_reset(cp, blkflag);
3812 cas_entropy_reset(cp);
3826 cas_load_firmware(cp, CAS_HP_FIRMWARE);
3833 cas_clear_mac_err(cp);
3834 spin_unlock(&cp->
stat_lock[N_TX_RINGS]);
3838 static void cas_shutdown(
struct cas *cp)
3840 unsigned long flags;
3862 cas_phy_powerdown(cp);
3866 static int cas_change_mtu(
struct net_device *dev,
int new_mtu)
3868 struct cas *cp = netdev_priv(dev);
3870 if (new_mtu < CAS_MIN_MTU || new_mtu >
CAS_MAX_MTU)
3874 if (!netif_running(dev) || !netif_device_present(dev))
3888 CAS_RESET_ALL : CAS_RESET_MTU);
3889 pr_err(
"reset called in cas_change_mtu\n");
3897 static void cas_clean_txd(
struct cas *cp,
int ring)
3905 for (i = 0; i <
size; i++) {
3908 if (skbs[i] ==
NULL)
3914 for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) {
3915 int ent = i & (size - 1);
3921 dlen =
CAS_VAL(TX_DESC_BUFLEN,
3923 pci_unmap_page(cp->
pdev, daddr, dlen,
3926 if (frag != skb_shinfo(skb)->nr_frags) {
3932 ent = i & (size - 1);
3945 static inline void cas_free_rx_desc(
struct cas *cp,
int ring)
3951 for (i = 0; i <
size; i++) {
3953 cas_page_free(cp, page[i]);
3959 static void cas_free_rxds(
struct cas *cp)
3964 cas_free_rx_desc(cp, i);
3968 static void cas_clean_rings(
struct cas *cp)
3976 cas_clean_txd(cp, i);
3985 static inline int cas_alloc_rx_desc(
struct cas *cp,
int ring)
3991 for (i = 0; i <
size; i++) {
3998 static int cas_alloc_rxds(
struct cas *cp)
4003 if (cas_alloc_rx_desc(cp, i) < 0) {
4021 if (pending_all == 0 && pending_spare == 0 && pending_mtu == 0) {
4034 unsigned long flags;
4049 if (!pending_all && !pending_mtu)
4052 if (pending == CAS_RESET_SPARE)
4063 cas_reset(cp, !(pending_all > 0));
4065 cas_clean_rings(cp);
4066 cas_init_hw(cp, (pending_all > 0));
4068 cas_reset(cp, !(pending == CAS_RESET_ALL));
4070 cas_clean_rings(cp);
4071 cas_init_hw(cp, pending == CAS_RESET_ALL);
4088 static void cas_link_timer(
unsigned long data)
4090 struct cas *cp = (
struct cas *) data;
4092 unsigned long flags;
4094 if (link_transition_timeout != 0 &&
4097 (link_transition_timeout))) {
4110 cas_entropy_gather(cp);
4131 if ((mask & rmask) == 0)
4135 if (cas_post_rxds_ringN(cp, i, cp->
rx_last[i]) < 0) {
4145 cas_mif_poll(cp, 0);
4153 cas_mif_poll(cp, 1);
4155 reset = cas_mii_link_check(cp, bmsr);
4157 reset = cas_pcs_link_check(cp);
4167 int tlm =
CAS_VAL(MAC_SM_TLM, val);
4169 if (((tlm == 0x5) || (tlm == 0x3)) &&
4170 (
CAS_VAL(MAC_SM_ENCAP_SM, val) == 0)) {
4172 "tx err: MAC_STATE[%08x]\n", val);
4180 if ((val == 0) && (wptr != rptr)) {
4182 "tx err: TX_FIFO[%08x:%08x:%08x]\n",
4199 pr_err(
"reset called in cas_link_timer\n");
4207 spin_unlock_irqrestore(&cp->
lock, flags);
4213 static void cas_tx_tiny_free(
struct cas *cp)
4229 static int cas_tx_tiny_alloc(
struct cas *cp)
4239 cas_tx_tiny_free(cp);
4249 struct cas *cp = netdev_priv(dev);
4251 unsigned long flags;
4274 if (cas_tx_tiny_alloc(cp) < 0)
4278 if (cas_alloc_rxds(cp) < 0)
4292 netdev_err(cp->
dev,
"failed to request irq !\n");
4298 napi_enable(&cp->
napi);
4302 cas_clean_rings(cp);
4303 cas_init_hw(cp, !hw_was_up);
4307 netif_start_queue(dev);
4315 cas_tx_tiny_free(cp);
4323 unsigned long flags;
4324 struct cas *cp = netdev_priv(dev);
4327 napi_disable(&cp->
napi);
4332 netif_stop_queue(dev);
4339 cas_begin_auto_negotiation(cp,
NULL);
4340 cas_clean_rings(cp);
4346 cas_tx_tiny_free(cp);
4353 } ethtool_cassini_statnames[] = {
4360 {
"rx_frame_errors"},
4361 {
"rx_length_errors"},
4364 {
"tx_aborted_errors"},
4371 #define CAS_NUM_STAT_KEYS ARRAY_SIZE(ethtool_cassini_statnames)
4375 } ethtool_register_table[] = {
4395 #define CAS_REG_LEN ARRAY_SIZE(ethtool_register_table)
4396 #define CAS_MAX_REGS (sizeof (u32)*CAS_REG_LEN)
4398 static void cas_read_regs(
struct cas *cp,
u8 *
ptr,
int len)
4402 unsigned long flags;
4405 for (i = 0, p = ptr; i < len ; i ++, p +=
sizeof(
u32)) {
4408 if (ethtool_register_table[i].
offsets < 0) {
4409 hval = cas_phy_read(cp,
4410 -ethtool_register_table[i].
offsets);
4413 val=
readl(cp->
regs+ethtool_register_table[i].offsets);
4417 spin_unlock_irqrestore(&cp->
lock, flags);
4422 struct cas *cp = netdev_priv(dev);
4424 unsigned long flags;
4459 cas_clear_mac_err(cp);
4487 spin_unlock_irqrestore(&cp->
stat_lock[N_TX_RINGS], flags);
4492 static void cas_set_multicast(
struct net_device *dev)
4494 struct cas *cp = netdev_priv(dev);
4496 unsigned long flags;
4524 cp->
mac_rx_cfg = rxcfg_new = cas_setup_multicast(cp);
4527 spin_unlock_irqrestore(&cp->
lock, flags);
4532 struct cas *cp = netdev_priv(dev);
4543 struct cas *cp = netdev_priv(dev);
4545 int full_duplex, speed,
pause;
4546 unsigned long flags;
4579 cas_mif_poll(cp, 0);
4581 cas_read_mii_link_mode(cp, &full_duplex,
4583 cas_mif_poll(cp, 1);
4596 cas_read_pcs_link_mode(cp, &full_duplex,
4600 spin_unlock_irqrestore(&cp->
lock, flags);
4602 if (bmcr & BMCR_ANENABLE) {
4605 ethtool_cmd_speed_set(cmd, ((speed == 10) ?
4612 ethtool_cmd_speed_set(cmd, ((bmcr & CAS_BMCR_SPEED1000) ?
4632 ethtool_cmd_speed_set(cmd, 0);
4635 ethtool_cmd_speed_set(cmd,
SPEED_10);
4638 }
else if (cp->
link_cntl & CAS_BMCR_SPEED1000) {
4650 struct cas *cp = netdev_priv(dev);
4651 unsigned long flags;
4652 u32 speed = ethtool_cmd_speed(cmd);
4669 cas_begin_auto_negotiation(cp, cmd);
4670 spin_unlock_irqrestore(&cp->
lock, flags);
4674 static int cas_nway_reset(
struct net_device *dev)
4676 struct cas *cp = netdev_priv(dev);
4677 unsigned long flags;
4679 if ((cp->
link_cntl & BMCR_ANENABLE) == 0)
4684 cas_begin_auto_negotiation(cp,
NULL);
4685 spin_unlock_irqrestore(&cp->
lock, flags);
4692 struct cas *cp = netdev_priv(dev);
4698 struct cas *cp = netdev_priv(dev);
4704 struct cas *cp = netdev_priv(dev);
4708 static int cas_get_regs_len(
struct net_device *dev)
4710 struct cas *cp = netdev_priv(dev);
4717 struct cas *cp = netdev_priv(dev);
4720 cas_read_regs(cp, p, regs->
len /
sizeof(
u32));
4723 static int cas_get_sset_count(
struct net_device *dev,
int sset)
4733 static void cas_get_strings(
struct net_device *dev,
u32 stringset,
u8 *data)
4735 memcpy(data, ðtool_cassini_statnames,
4739 static void cas_get_ethtool_stats(
struct net_device *dev,
4742 struct cas *cp = netdev_priv(dev);
4764 static const struct ethtool_ops cas_ethtool_ops = {
4765 .get_drvinfo = cas_get_drvinfo,
4766 .get_settings = cas_get_settings,
4767 .set_settings = cas_set_settings,
4768 .nway_reset = cas_nway_reset,
4769 .get_link = cas_get_link,
4770 .get_msglevel = cas_get_msglevel,
4771 .set_msglevel = cas_set_msglevel,
4772 .get_regs_len = cas_get_regs_len,
4773 .get_regs = cas_get_regs,
4774 .get_sset_count = cas_get_sset_count,
4775 .get_strings = cas_get_strings,
4776 .get_ethtool_stats = cas_get_ethtool_stats,
4779 static int cas_ioctl(
struct net_device *dev,
struct ifreq *ifr,
int cmd)
4781 struct cas *cp = netdev_priv(dev);
4783 unsigned long flags;
4797 cas_mif_poll(cp, 0);
4799 cas_mif_poll(cp, 1);
4800 spin_unlock_irqrestore(&cp->
lock, flags);
4806 cas_mif_poll(cp, 0);
4808 cas_mif_poll(cp, 1);
4809 spin_unlock_irqrestore(&cp->
lock, flags);
4839 pci_read_config_dword(pdev, 0x40, &val);
4841 pci_write_config_dword(pdev, 0x40, val);
4865 pci_write_config_word(pdev, 0x50, (5 << 10) | 0x3ff);
4887 pci_write_config_word(pdev, 0x52,
4904 .ndo_open = cas_open,
4905 .ndo_stop = cas_close,
4906 .ndo_start_xmit = cas_start_xmit,
4907 .ndo_get_stats = cas_get_stats,
4908 .ndo_set_rx_mode = cas_set_multicast,
4909 .ndo_do_ioctl = cas_ioctl,
4910 .ndo_tx_timeout = cas_tx_timeout,
4911 .ndo_change_mtu = cas_change_mtu,
4914 #ifdef CONFIG_NET_POLL_CONTROLLER
4915 .ndo_poll_controller = cas_netpoll,
4922 static int cas_version_printed = 0;
4923 unsigned long casreg_len;
4926 int i,
err, pci_using_dac;
4930 if (cas_version_printed++ == 0)
4935 dev_err(&pdev->
dev,
"Cannot enable PCI device, aborting\n");
4940 dev_err(&pdev->
dev,
"Cannot find proper PCI device "
4941 "base address, aborting\n");
4943 goto err_out_disable_pdev;
4946 dev = alloc_etherdev(
sizeof(*cp));
4949 goto err_out_disable_pdev;
4955 dev_err(&pdev->
dev,
"Cannot obtain PCI resources, aborting\n");
4956 goto err_out_free_netdev;
4964 pci_read_config_word(pdev,
PCI_COMMAND, &pci_cmd);
4967 pci_write_config_word(pdev,
PCI_COMMAND, pci_cmd);
4969 pr_warning(
"Could not enable MWI for %s\n", pci_name(pdev));
4971 cas_program_bridge(pdev);
4981 &orig_cacheline_size);
4983 cas_cacheline_size =
4986 if (pci_write_config_byte(pdev,
4988 cas_cacheline_size)) {
4989 dev_err(&pdev->
dev,
"Could not set PCI cache "
4991 goto err_write_cacheline;
5000 err = pci_set_consistent_dma_mask(pdev,
5003 dev_err(&pdev->
dev,
"Unable to obtain 64-bit DMA "
5004 "for consistent allocations\n");
5005 goto err_out_free_res;
5011 dev_err(&pdev->
dev,
"No usable DMA configuration, "
5013 goto err_out_free_res;
5020 cp = netdev_priv(dev);
5030 #if defined(CONFIG_SPARC)
5031 cp->of_node = pci_device_to_OF_node(pdev);
5063 if (link_mode >= 0 && link_mode < 6)
5073 cp->
regs = pci_iomap(pdev, 0, casreg_len);
5075 dev_err(&pdev->
dev,
"Cannot map device registers, aborting\n");
5076 goto err_out_free_res;
5081 cas_check_pci_invariants(cp);
5084 if (cas_check_invariants(cp))
5085 goto err_out_iounmap;
5087 if (cas_saturn_firmware_init(cp))
5088 goto err_out_iounmap;
5094 dev_err(&pdev->
dev,
"Cannot allocate init block, aborting\n");
5095 goto err_out_iounmap;
5108 skb_queue_head_init(&cp->
rx_flows[i]);
5128 dev_err(&pdev->
dev,
"Cannot register net device, aborting\n");
5129 goto err_out_free_consistent;
5133 netdev_info(dev,
"Sun Cassini%s (%sbit/%sMHz PCI/%s) Ethernet[%d] %pM\n",
5140 pci_set_drvdata(pdev, dev);
5142 cas_entropy_reset(cp);
5144 cas_begin_auto_negotiation(cp,
NULL);
5147 err_out_free_consistent:
5163 err_write_cacheline:
5169 err_out_free_netdev:
5172 err_out_disable_pdev:
5174 pci_set_drvdata(pdev,
NULL);
5180 struct net_device *dev = pci_get_drvdata(pdev);
5185 cp = netdev_priv(dev);
5212 pci_set_drvdata(pdev,
NULL);
5218 struct net_device *dev = pci_get_drvdata(pdev);
5219 struct cas *cp = netdev_priv(dev);
5220 unsigned long flags;
5236 cas_clean_rings(cp);
5247 static int cas_resume(
struct pci_dev *pdev)
5249 struct net_device *dev = pci_get_drvdata(pdev);
5250 struct cas *cp = netdev_priv(dev);
5252 netdev_info(dev,
"resuming\n");
5257 unsigned long flags;
5261 cas_clean_rings(cp);
5274 .id_table = cas_pci_tbl,
5275 .probe = cas_init_one,
5278 .suspend = cas_suspend,
5279 .resume = cas_resume
5283 static int __init cas_init(
void)
5285 if (linkdown_timeout > 0)
5286 link_transition_timeout = linkdown_timeout *
HZ;
5288 link_transition_timeout = 0;
5290 return pci_register_driver(&cas_driver);
5293 static void __exit cas_cleanup(
void)