58 #define KLUDGE_FOR_4GB_BOUNDARY 1
59 #define DEBUG_MICROCODE 1
61 #define SLIC_INTERRUPT_PROCESS_LIMIT 1
62 #define SLIC_OFFLOAD_IP_CHECKSUM 1
63 #define STATS_TIMER_INTERVAL 2
64 #define PING_TIMER_INTERVAL 1
66 #include <linux/kernel.h>
67 #include <linux/string.h>
68 #include <linux/errno.h>
70 #include <linux/slab.h>
73 #include <linux/pci.h>
76 #include <linux/bitops.h>
78 #include <linux/netdevice.h>
85 #include <linux/module.h>
89 #include <linux/types.h>
91 #include <linux/mii.h>
92 #include <linux/if_vlan.h>
93 #include <asm/unaligned.h>
95 #include <linux/ethtool.h>
100 static uint slic_first_init = 1;
101 static char *slic_banner =
"Alacritech SLIC Technology(tm) Server "\
102 "and Storage Accelerator (Non-Accelerated)";
104 static char *slic_proc_version =
"2.0.351 2006/07/14 12:26:00";
105 static char *slic_product_name =
"SLIC Technology(tm) Server "\
106 "and Storage Accelerator (Non-Accelerated)";
107 static char *slic_vendor =
"Alacritech, Inc.";
109 static int slic_debug = 1;
110 static int debug = -1;
114 static int intagg_delay = 100;
116 static unsigned int rcv_count;
117 static struct dentry *slic_debugfs;
119 #define DRV_NAME "slicoss"
120 #define DRV_VERSION "2.0.1"
121 #define DRV_AUTHOR "Alacritech, Inc. Engineering"
122 #define DRV_DESCRIPTION "Alacritech SLIC Techonology(tm) "\
123 "Non-Accelerated Driver"
124 #define DRV_COPYRIGHT "Copyright 2000-2006 Alacritech, Inc. "\
125 "All rights reserved."
126 #define PFX DRV_NAME " "
149 static void slic_assert_fail(
void)
157 __func__, cpuid, curr_pid);
161 #define ASSERT(a) do { \
163 printk(KERN_ERR "slicoss ASSERT() Failure: function %s" \
164 "line %d\n", __func__, __LINE__); \
165 slic_assert_fail(); \
171 #define SLIC_GET_SLIC_HANDLE(_adapter, _pslic_handle) \
173 spin_lock_irqsave(&_adapter->handle_lock.lock, \
174 _adapter->handle_lock.flags); \
175 _pslic_handle = _adapter->pfree_slic_handles; \
176 if (_pslic_handle) { \
177 ASSERT(_pslic_handle->type == SLIC_HANDLE_FREE); \
178 _adapter->pfree_slic_handles = _pslic_handle->next; \
180 spin_unlock_irqrestore(&_adapter->handle_lock.lock, \
181 _adapter->handle_lock.flags); \
184 #define SLIC_FREE_SLIC_HANDLE(_adapter, _pslic_handle) \
186 _pslic_handle->type = SLIC_HANDLE_FREE; \
187 spin_lock_irqsave(&_adapter->handle_lock.lock, \
188 _adapter->handle_lock.flags); \
189 _pslic_handle->next = _adapter->pfree_slic_handles; \
190 _adapter->pfree_slic_handles = _pslic_handle; \
191 spin_unlock_irqrestore(&_adapter->handle_lock.lock, \
192 _adapter->handle_lock.flags); \
231 static u32 slic_crc_table[256];
232 static u32 slic_crc_init;
237 static void slic_mcast_init_crc32(
void)
244 static int p[] = { 0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26 };
247 e |= 1L << (31 - p[i]);
249 for (i = 1; i < 256; i++) {
252 c = c & 1 ? (c >> 1) ^ e : c >> 1;
253 slic_crc_table[
i] =
c;
260 static unsigned char slic_mcast_get_mac_hash(
char *
macaddr)
265 unsigned char machash = 0;
267 if (!slic_crc_init) {
268 slic_mcast_init_crc32();
273 for (i = 0, p = macaddr; i < 6; ++
p, ++
i)
274 crc = (crc >> 8) ^ slic_crc_table[(crc ^ *
p) & 0xFF];
277 for (i = 1; i < 9; i++)
278 machash |= (((crc >> i) & 1) << (8 -
i));
283 static void slic_mcast_set_bit(
struct adapter *adapter,
char *
address)
285 unsigned char crcpoly;
288 crcpoly = slic_mcast_get_mac_hash(address);
299 static void slic_mcast_set_mask(
struct adapter *adapter)
323 static void slic_timer_ping(
ulong dev)
329 adapter = netdev_priv((
struct net_device *)dev);
331 card = adapter->
card;
338 static void slic_unmap_mmio_space(
struct adapter *adapter)
351 static void slic_link_config(
struct adapter *adapter,
352 u32 linkspeed,
u32 linkduplex)
384 slic_reg32_write(wphy, phy_advreg,
FLUSH);
392 slic_reg32_write(wphy, phy_config,
FLUSH);
397 slic_reg32_write(wphy, phy_config,
FLUSH);
408 slic_reg32_write(wphy, phy_config,
FLUSH);
432 slic_reg32_write(wphy, phy_advreg,
FLUSH);
435 slic_reg32_write(wphy, phy_gctlreg,
FLUSH);
442 slic_reg32_write(wphy, phy_config,
FLUSH);
449 slic_reg32_write(wphy, phy_config,
FLUSH);
455 slic_reg32_write(wphy, phy_config,
FLUSH);
473 slic_reg32_write(wphy, phy_config,
FLUSH);
478 slic_reg32_write(wphy, phy_config,
FLUSH);
489 slic_reg32_write(wphy, phy_config,
FLUSH);
493 slic_reg32_write(wphy, phy_config,
FLUSH);
498 static int slic_card_download_gbrcv(
struct adapter *adapter)
501 const char *
file =
"";
509 switch (adapter->
devid) {
511 file =
"slicoss/oasisrcvucode.sys";
514 file =
"slicoss/gbrcvucode.sys";
523 "SLICOSS: Failed to load firmware %s\n", file);
527 rcvucodelen = *(
u32 *)(fw->
data + index);
529 switch (adapter->
devid) {
531 if (rcvucodelen != OasisRcvUCodeLen) {
537 if (rcvucodelen != GBRcvUCodeLen) {
546 for (codeaddr = 0; codeaddr < rcvucodelen; codeaddr++) {
550 instruction = *(
u32 *)(fw->
data + index);
555 instruction = *(
u8 *)(fw->
data + index);
571 static int slic_card_download(
struct adapter *adapter)
574 const char *file =
"";
586 int ucode_start, index = 0;
588 switch (adapter->
devid) {
590 file =
"slicoss/oasisdownload.sys";
593 file =
"slicoss/gbdownload.sys";
602 "SLICOSS: Failed to load firmware %s\n", file);
605 numsects = *(
u32 *)(fw->
data + index);
608 for (i = 0; i < numsects; i++) {
609 sectsize[
i] = *(
u32 *)(fw->
data + index);
612 for (i = 0; i < numsects; i++) {
613 sectstart[
i] = *(
u32 *)(fw->
data + index);
617 instruction = *(
u32 *)(fw->
data + index);
619 for (section = 0; section < numsects; section++) {
620 baseaddress = sectstart[section];
621 thissectionsize = sectsize[section] >> 3;
623 for (codeaddr = 0; codeaddr < thissectionsize; codeaddr++) {
625 slic_reg32_write(&slic_regs->
slic_wcs,
626 baseaddress + codeaddr,
FLUSH);
629 instruction = *(
u32 *)(fw->
data + index);
634 instruction = *(
u32 *)(fw->
data + index);
639 for (section = 0; section < numsects; section++) {
640 instruction = *(
u32 *)(fw->
data + index);
641 baseaddress = sectstart[section];
642 if (baseaddress < 0x8000)
644 thissectionsize = sectsize[section] >> 3;
646 for (codeaddr = 0; codeaddr < thissectionsize; codeaddr++) {
648 slic_reg32_write(&slic_regs->
slic_wcs,
652 slic_reg32_write(&slic_regs->
slic_wcs, instruction,
654 instruction = *(
u32 *)(fw->
data + index);
657 slic_reg32_write(&slic_regs->
slic_wcs, instruction,
659 instruction = *(
u32 *)(fw->
data + index);
685 static void slic_adapter_set_hwaddr(
struct adapter *adapter)
705 static void slic_intagg_set(
struct adapter *adapter,
u32 value)
708 adapter->
card->loadlevel_current =
value;
711 static void slic_soft_reset(
struct adapter *adapter)
723 static void slic_mac_address_config(
struct adapter *adapter)
730 value =
ntohl(value);
743 slic_mcast_set_mask(adapter);
746 static void slic_mac_config(
struct adapter *adapter)
776 slic_mac_address_config(adapter);
779 static void slic_config_set(
struct adapter *adapter,
bool linkchange)
787 slic_mac_config(adapter);
790 slic_mac_address_config(adapter);
836 static void slic_config_clear(
struct adapter *adapter)
860 static bool slic_mac_filter(
struct adapter *adapter,
871 if ((*dhost4 == 0xFFFFFFFF) && (*dhost2 == 0xFFFF)) {
883 netdev->
stats.multicast++;
890 if (!compare_ether_addr(mcaddr->
address,
893 netdev->
stats.multicast++;
896 mcaddr = mcaddr->
next;
911 static int slic_mac_set_address(
struct net_device *dev,
void *
ptr)
913 struct adapter *adapter = netdev_priv(dev);
916 if (netif_running(dev))
921 if (!is_valid_ether_addr(addr->
sa_data))
927 slic_config_set(adapter,
true);
931 static void slic_timer_load_check(
ulong cardaddr)
934 struct adapter *adapter = card->
master;
939 intagg = &adapter->
slic_regs->slic_intagg;
962 slic_reg32_write(intagg, level,
FLUSH);
979 slic_reg32_write(intagg, level,
FLUSH);
988 static int slic_upr_queue_request(
struct adapter *adapter,
992 u32 upr_buffer,
u32 upr_buffer_h)
1011 while (uprqueue->
next)
1012 uprqueue = uprqueue->
next;
1013 uprqueue->
next = upr;
1020 static void slic_upr_start(
struct adapter *adapter)
1068 static int slic_upr_request(
struct adapter *adapter,
1072 u32 upr_buffer,
u32 upr_buffer_h)
1077 rc = slic_upr_queue_request(adapter,
1080 upr_data_h, upr_buffer, upr_buffer_h);
1082 goto err_unlock_irq;
1084 slic_upr_start(adapter);
1086 spin_unlock_irqrestore(&adapter->
upr_lock.lock,
1091 static void slic_link_upr_complete(
struct adapter *adapter,
u32 isr)
1093 u32 linkstatus = adapter->
pshmem->linkstatus;
1095 unsigned char linkspeed;
1096 unsigned char linkduplex;
1103 slic_upr_queue_request(adapter,
1109 slic_upr_queue_request(adapter,
1112 SLIC_GET_ADDR_HIGH(pshmem), 0, 0);
1159 slic_config_set(adapter,
true);
1161 netif_start_queue(adapter->
netdev);
1165 static void slic_upr_request_complete(
struct adapter *adapter,
u32 isr)
1174 spin_unlock_irqrestore(&adapter->
upr_lock.lock,
1191 if (isr & ISR_UPCERR) {
1193 "SLIC_UPR_STATS command failed isr[%x]\n",
1199 newstats->xmit_tcp_segs_gb,
1200 old->xmit_tcp_segs_gb);
1203 newstats->xmit_tcp_bytes_gb,
1204 old->xmit_tcp_bytes_gb);
1207 newstats->rcv_tcp_segs_gb,
1208 old->rcv_tcp_segs_gb);
1211 newstats->rcv_tcp_bytes_gb,
1212 old->rcv_tcp_bytes_gb);
1215 newstats->xmit_bytes_gb,
1216 old->xmit_bytes_gb);
1219 newstats->xmit_unicasts_gb,
1220 old->xmit_unicasts_gb);
1223 newstats->rcv_bytes_gb,
1227 newstats->rcv_unicasts_gb,
1228 old->rcv_unicasts_gb);
1231 newstats->xmit_collisions_gb,
1232 old->xmit_collisions_gb);
1235 newstats->xmit_excess_collisions_gb,
1236 old->xmit_excess_collisions_gb);
1239 newstats->xmit_other_error_gb,
1240 old->xmit_other_error_gb);
1243 newstats->rcv_other_error_gb,
1244 old->rcv_other_error_gb);
1247 newstats->rcv_drops_gb,
1250 if (newstats->rcv_drops_gb > old->rcv_drops_gb) {
1252 (newstats->rcv_drops_gb -
1259 slic_link_upr_complete(adapter, isr);
1282 slic_upr_start(adapter);
1283 spin_unlock_irqrestore(&adapter->
upr_lock.lock,
1287 static void slic_config_get(
struct adapter *adapter,
u32 config,
1292 status = slic_upr_request(adapter,
1294 (
u32) config, (
u32) config_h, 0, 0);
1303 static ushort slic_eeprom_cksum(
char *
m,
int len)
1305 #define ADDCARRY(x) (x > 65535 ? x -= 65535 : x)
1306 #define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);\
1311 u32 byte_swapped = 0;
1328 #if BITS_PER_LONG == 64
1329 w_int = (
u32) ((
ulong) w & 0x00000000FFFFFFFF);
1333 if ((1 & w_int) && (len > 0)) {
1336 s_util.c[0] = *(
unsigned char *)w;
1337 w = (
u16 *)((
char *)w + 1);
1343 while ((len -= 32) >= 0) {
1363 while ((len -= 8) >= 0) {
1371 if (len != 0 || byte_swapped != 0) {
1373 while ((len -= 2) >= 0)
1380 s_util.c[1] = *(
char *) w;
1387 }
else if (len == -1) {
1388 s_util.c[0] = *(
char *) w;
1400 static void slic_rspqueue_free(
struct adapter *adapter)
1406 if (rspq->
vaddr[i]) {
1418 static int slic_rspqueue_init(
struct adapter *adapter)
1434 if (!rspq->
vaddr[i]) {
1436 "pci_alloc_consistent failed\n");
1437 slic_rspqueue_free(adapter);
1443 #ifndef CONFIG_X86_64
1457 slic_reg64_write(adapter, &slic_regs->
slic_rbar64,
1469 static struct slic_rspbuf *slic_rspqueue_getnext(
struct adapter *adapter)
1474 if (!(rspq->
rspbuf->status))
1478 #if BITS_PER_LONG == 32
1484 #if BITS_PER_LONG == 32
1490 slic_reg64_write(adapter, &adapter->
slic_regs->slic_rbar64,
1497 #if BITS_PER_LONG == 32
1502 #if BITS_PER_LONG == 32
1508 static void slic_cmdqmem_init(
struct adapter *adapter)
1515 static void slic_cmdqmem_free(
struct adapter *adapter)
1521 if (cmdqmem->
pages[i]) {
1524 (
void *) cmdqmem->
pages[i],
1531 static u32 *slic_cmdqmem_addpage(
struct adapter *adapter)
1536 if (cmdqmem->
pagecnt >= SLIC_CMDQ_MAXPAGES)
1543 #if BITS_PER_LONG == 32
1544 ASSERT(((
u32) pageaddr & 0xFFFFF000) == (
u32) pageaddr);
1551 static void slic_cmdq_free(
struct adapter *adapter)
1571 slic_cmdqmem_free(adapter);
1574 static void slic_cmdq_addcmdpage(
struct adapter *adapter,
u32 *
page)
1592 phys_addrl = SLIC_GET_ADDR_LOW(phys_addr);
1593 phys_addrh = SLIC_GET_ADDR_HIGH(phys_addr);
1601 if (pslic_handle ==
NULL)
1607 pslic_handle->
address = (
void *) cmd;
1613 cmd->
cmd64.hosthandle = pslic_handle->
token.handle_token;
1615 cmd->
paddrl = phys_addrl;
1616 cmd->
paddrh = phys_addrh;
1628 cmdq->
count += cmdcnt;
1633 cmdq->
count += cmdcnt;
1636 spin_unlock_irqrestore(&cmdq->
lock.lock, cmdq->
lock.flags);
1639 static int slic_cmdq_init(
struct adapter *adapter)
1651 slic_cmdqmem_init(adapter);
1654 pageaddr = slic_cmdqmem_addpage(adapter);
1655 #if BITS_PER_LONG == 32
1656 ASSERT(((
u32) pageaddr & 0xFFFFF000) == (
u32) pageaddr);
1659 slic_cmdq_free(adapter);
1662 slic_cmdq_addcmdpage(adapter, pageaddr);
1669 static void slic_cmdq_reset(
struct adapter *adapter)
1680 outstanding -= adapter->
cmdq_free.count;
1707 "free_count %d != all count %d\n",
1710 spin_unlock_irqrestore(&adapter->
cmdq_done.lock.lock,
1712 spin_unlock_irqrestore(&adapter->
cmdq_free.lock.lock,
1716 static void slic_cmdq_getdone(
struct adapter *adapter)
1728 done_cmdq->
count = 0;
1729 spin_unlock_irqrestore(&done_cmdq->
lock.lock, done_cmdq->
lock.flags);
1732 static struct slic_hostcmd *slic_cmdq_getfree(
struct adapter *adapter)
1744 spin_unlock_irqrestore(&cmdq->
lock.lock, cmdq->
lock.flags);
1746 slic_cmdq_getdone(adapter);
1753 spin_unlock_irqrestore(&cmdq->
lock.lock,
1755 pageaddr = slic_cmdqmem_addpage(adapter);
1757 slic_cmdq_addcmdpage(adapter, pageaddr);
1758 goto lock_and_retry;
1765 static void slic_cmdq_putdone_irq(
struct adapter *adapter,
1770 spin_lock(&cmdq->
lock.lock);
1776 netif_wake_queue(adapter->
netdev);
1777 spin_unlock(&cmdq->
lock.lock);
1780 static int slic_rcvqueue_fill(
struct adapter *adapter)
1792 #ifdef KLUDGE_FOR_4GB_BOUNDARY
1797 paddr = (
void *)pci_map_single(adapter->
pcidev,
1801 paddrl = SLIC_GET_ADDR_LOW(paddr);
1802 paddrh = SLIC_GET_ADDR_HIGH(paddr);
1810 dev_err(dev,
"%s: LOW 32bits PHYSICAL ADDRESS == 0\n",
1812 dev_err(dev,
"skb[%p] PROBLEM\n", skb);
1815 dev_err(dev,
" paddr[%p]\n", paddr);
1816 dev_err(dev,
" paddrl[%x]\n", paddrl);
1817 dev_err(dev,
" paddrh[%x]\n", paddrh);
1821 dev_err(dev,
"SKIP THIS SKB!!!!!!!!\n");
1822 goto retry_rcvqfill;
1826 dev_err(dev,
"%s: LOW 32bits PHYSICAL ADDRESS == 0\n",
1828 dev_err(dev,
"skb[%p] PROBLEM\n", skb);
1831 dev_err(dev,
" paddr[%p]\n", paddr);
1832 dev_err(dev,
" paddrl[%x]\n", paddrl);
1833 dev_err(dev,
" paddrh[%x]\n", paddrh);
1837 dev_err(dev,
"GIVE TO CARD ANYWAY\n");
1841 slic_reg32_write(&adapter->
slic_regs->slic_hbar,
1844 slic_reg64_write(adapter,
1859 "slic_rcvqueue_fill could only get [%d] skbuffs\n",
1867 static void slic_rcvqueue_free(
struct adapter *adapter)
1872 while (rcvq->
head) {
1882 static int slic_rcvqueue_init(
struct adapter *adapter)
1896 count += slic_rcvqueue_fill(adapter);
1900 slic_rcvqueue_free(adapter);
1906 static struct sk_buff *slic_rcvqueue_getnext(
struct adapter *adapter)
1927 "RcvQ Empty!! rcvq[%p] count[%x]\n", rcvq, rcvq->
count);
1931 count = slic_rcvqueue_fill(adapter);
1940 static u32 slic_rcvqueue_reinsert(
struct adapter *adapter,
struct sk_buff *skb)
1951 paddr = (
void *)pci_map_single(adapter->
pcidev, skb->
head,
1956 paddrl = SLIC_GET_ADDR_LOW(paddr);
1957 paddrh = SLIC_GET_ADDR_HIGH(paddr);
1960 dev = &adapter->
netdev->dev;
1961 dev_err(dev,
"%s: LOW 32bits PHYSICAL ADDRESS == 0\n",
1963 dev_err(dev,
"skb[%p] PROBLEM\n", skb);
1966 dev_err(dev,
" paddr[%p]\n", paddr);
1967 dev_err(dev,
" paddrl[%x]\n", paddrl);
1968 dev_err(dev,
" paddrh[%x]\n", paddrh);
1974 slic_reg32_write(&adapter->
slic_regs->slic_hbar, (
u32)paddrl,
1977 slic_reg64_write(adapter, &adapter->
slic_regs->slic_hbar64,
1978 paddrl, &adapter->
slic_regs->slic_addr_upper,
1990 static int slic_debug_card_show(
struct seq_file *seq,
void *
v)
1996 unsigned char *fru = (
unsigned char *)(&card->
config.atk_fru);
1997 unsigned char *
oemfru = (
unsigned char *)(&card->
config.OemFru);
2000 seq_printf(seq,
"driver_version : %s\n", slic_proc_version);
2004 seq_printf(seq,
" Gigabit Receiver : %s %s\n",
2006 seq_printf(seq,
"Vendor : %s\n", slic_vendor);
2007 seq_printf(seq,
"Product Name : %s\n", slic_product_name);
2014 config->RevisionId);
2025 " MAC%d : %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X\n",
2026 i, config->macinfo[i].macaddrA[0],
2027 config->macinfo[i].macaddrA[1],
2028 config->macinfo[i].macaddrA[2],
2029 config->macinfo[i].macaddrA[3],
2030 config->macinfo[i].macaddrA[4],
2031 config->macinfo[i].macaddrA[5]);
2033 seq_printf(seq,
" IF Init State Duplex/Speed irq\n");
2034 seq_printf(seq,
" -------------------------------\n");
2041 " %d %d %s %s %s 0x%X\n",
2050 seq_printf(seq,
"RcvQ max entries : %4.4X\n",
2056 seq_printf(seq,
"Maximum Latency : %2.2x\n", config->MaxLat);
2061 seq_printf(seq,
"DRAM ROM Function : %4.4x\n",
2063 seq_printf(seq,
"Network interface Pin 1 : %2.2x\n",
2064 config->NetIntPin1);
2065 seq_printf(seq,
"Network interface Pin 2 : %2.2x\n",
2066 config->NetIntPin1);
2067 seq_printf(seq,
"Network interface Pin 3 : %2.2x\n",
2068 config->NetIntPin1);
2071 seq_printf(seq,
"Network Clock Controls : %4.4X\n",
2072 config->NwClkCtrls);
2078 "Vendor : Alacritech, Inc.\n");
2080 "Assembly # : %c%c%c%c%c%c\n",
2081 fru[0], fru[1], fru[2], fru[3], fru[4],
2084 "Revision # : %c%c\n",
2090 "%c%c%c%c%c%c%c%c%c%c%c%c\n",
2091 fru[8], fru[9], fru[10],
2092 fru[11], fru[12], fru[13],
2093 fru[16], fru[17], fru[18],
2094 fru[19], fru[20], fru[21]);
2098 "%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
2099 fru[8], fru[9], fru[10],
2100 fru[11], fru[12], fru[13],
2101 fru[14], fru[15], fru[16],
2102 fru[17], fru[18], fru[19],
2111 "Vendor : Alacritech, Inc.\n");
2113 "Serial # : Empty FRU\n");
2118 switch (config->OEMFruFormat) {
2125 " Assembly # : %c%c%c%c\n",
2126 oemfru[1], oemfru[2], oemfru[3], oemfru[4]);
2128 " Revision # : %c%c\n",
2129 oemfru[5], oemfru[6]);
2131 " Supplier # : %c%c\n",
2132 oemfru[7], oemfru[8]);
2135 oemfru[9], oemfru[10]);
2137 " Sequence # : %c%c%c\n",
2138 oemfru[11], oemfru[12], oemfru[13]);
2147 "%c%c%c%c%c%c%c%c\n",
2148 oemfru[0], oemfru[1], oemfru[2],
2149 oemfru[3], oemfru[4], oemfru[5],
2150 oemfru[6], oemfru[7]);
2152 " Supplier # : %c%c%c%c%c\n",
2153 oemfru[8], oemfru[9], oemfru[10],
2154 oemfru[11], oemfru[12]);
2157 oemfru[13], oemfru[14], oemfru[15]);
2159 " Sequence # : %c%c%c%c\n",
2160 oemfru[16], oemfru[17], oemfru[18],
2175 "%c%c%c%c%c%c%c%c\n",
2176 oemfru[0], oemfru[1], oemfru[2],
2177 oemfru[3], oemfru[4], oemfru[5],
2178 oemfru[6], oemfru[7]);
2181 "%c%c%c%c%c%c%c%c\n",
2182 oemfru[8], oemfru[9], oemfru[10],
2183 oemfru[11], oemfru[12], oemfru[13],
2184 oemfru[14], oemfru[15]);
2187 "%c%c%c%c%c%c%c%c\n",
2188 oemfru[16], oemfru[17], oemfru[18],
2189 oemfru[19], oemfru[20], oemfru[21],
2190 oemfru[22], oemfru[23]);
2202 static int slic_debug_adapter_show(
struct seq_file *seq,
void *v)
2204 struct adapter *adapter = seq->
private;
2219 seq_printf(seq,
"info: Interrupt Agg Delay: %d usec\n",
2220 adapter->
card->loadlevel_current);
2221 seq_printf(seq,
"info: RcvQ max entries : %4.4X\n",
2223 seq_printf(seq,
"info: RcvQ current : %4.4X\n",
2225 seq_printf(seq,
"rx stats: packets : %8.8lX\n",
2226 netdev->
stats.rx_packets);
2227 seq_printf(seq,
"rx stats: bytes : %8.8lX\n",
2228 netdev->
stats.rx_bytes);
2229 seq_printf(seq,
"rx stats: broadcasts : %8.8X\n",
2231 seq_printf(seq,
"rx stats: multicasts : %8.8X\n",
2233 seq_printf(seq,
"rx stats: unicasts : %8.8X\n",
2235 seq_printf(seq,
"rx stats: errors : %8.8X\n",
2237 seq_printf(seq,
"rx stats: Missed errors : %8.8X\n",
2241 seq_printf(seq,
"tx stats: packets : %8.8lX\n",
2242 netdev->
stats.tx_packets);
2243 seq_printf(seq,
"tx stats: bytes : %8.8lX\n",
2244 netdev->
stats.tx_bytes);
2245 seq_printf(seq,
"tx stats: errors : %8.8X\n",
2247 seq_printf(seq,
"rx stats: multicasts : %8.8lX\n",
2248 netdev->
stats.multicast);
2249 seq_printf(seq,
"tx stats: collision errors : %8.8X\n",
2251 seq_printf(seq,
"perf: Max rcv frames/isr : %8.8X\n",
2253 seq_printf(seq,
"perf: Rcv interrupt yields : %8.8X\n",
2255 seq_printf(seq,
"perf: Max xmit complete/isr : %8.8X\n",
2257 seq_printf(seq,
"perf: error interrupts : %8.8X\n",
2259 seq_printf(seq,
"perf: error rmiss interrupts : %8.8X\n",
2261 seq_printf(seq,
"perf: rcv interrupts : %8.8X\n",
2263 seq_printf(seq,
"perf: xmit interrupts : %8.8X\n",
2265 seq_printf(seq,
"perf: link event interrupts : %8.8X\n",
2267 seq_printf(seq,
"perf: UPR interrupts : %8.8X\n",
2269 seq_printf(seq,
"perf: interrupt count : %8.8X\n",
2271 seq_printf(seq,
"perf: false interrupts : %8.8X\n",
2273 seq_printf(seq,
"perf: All register writes : %8.8X\n",
2275 seq_printf(seq,
"perf: ICR register writes : %8.8X\n",
2277 seq_printf(seq,
"perf: ISR register writes : %8.8X\n",
2279 seq_printf(seq,
"ifevents: overflow 802 errors : %8.8X\n",
2281 seq_printf(seq,
"ifevents: transport overflow errors: %8.8X\n",
2283 seq_printf(seq,
"ifevents: underflow errors : %8.8X\n",
2285 seq_printf(seq,
"ifevents: receive early : %8.8X\n",
2287 seq_printf(seq,
"ifevents: buffer overflows : %8.8X\n",
2289 seq_printf(seq,
"ifevents: carrier errors : %8.8X\n",
2293 seq_printf(seq,
"ifevents: invalid preambles : %8.8X\n",
2295 seq_printf(seq,
"ifevents: CRC errors : %8.8X\n",
2297 seq_printf(seq,
"ifevents: dribble nibbles : %8.8X\n",
2299 seq_printf(seq,
"ifevents: Code violations : %8.8X\n",
2301 seq_printf(seq,
"ifevents: TCP checksum errors : %8.8X\n",
2303 seq_printf(seq,
"ifevents: TCP header short errors : %8.8X\n",
2305 seq_printf(seq,
"ifevents: IP checksum errors : %8.8X\n",
2307 seq_printf(seq,
"ifevents: IP frame incompletes : %8.8X\n",
2309 seq_printf(seq,
"ifevents: IP headers shorts : %8.8X\n",
2314 static int slic_debug_adapter_open(
struct inode *
inode,
struct file *file)
2319 static int slic_debug_card_open(
struct inode *
inode,
struct file *file)
2326 .open = slic_debug_adapter_open,
2334 .open = slic_debug_card_open,
2340 static void slic_debug_adapter_create(
struct adapter *adapter)
2352 &slic_debug_adapter_fops);
2353 if (!d || IS_ERR(d))
2354 pr_info(
PFX "%s: debugfs create failed\n", name);
2359 static void slic_debug_adapter_destroy(
struct adapter *adapter)
2365 static void slic_debug_card_create(
struct sliccard *card)
2372 if (!d || IS_ERR(d))
2373 pr_info(
PFX "%s: debugfs create dir failed\n",
2379 &slic_debug_card_fops);
2380 if (!d || IS_ERR(d))
2388 static void slic_debug_card_destroy(
struct sliccard *card)
2397 slic_debug_adapter_destroy(adapter);
2409 static void slic_debug_init(
void)
2414 if (!ent || IS_ERR(ent)) {
2415 pr_info(
PFX "debugfs create directory failed\n");
2422 static void slic_debug_cleanup(
void)
2426 slic_debugfs =
NULL;
2440 static void slic_link_event_handler(
struct adapter *adapter)
2453 status = slic_upr_request(adapter,
2466 static void slic_init_cleanup(
struct adapter *adapter)
2486 slic_rspqueue_free(adapter);
2487 slic_cmdq_free(adapter);
2488 slic_rcvqueue_free(adapter);
2495 static int slic_mcast_add_list(
struct adapter *adapter,
char *
address)
2502 if (!compare_ether_addr(mlist->
address, address))
2504 mlist = mlist->
next;
2520 static void slic_mcast_set_list(
struct net_device *dev)
2522 struct adapter *adapter = netdev_priv(dev);
2530 addresses = (
char *) &ha->
addr;
2531 status = slic_mcast_add_list(adapter, addresses);
2534 slic_mcast_set_bit(adapter, addresses);
2550 slic_config_set(adapter,
true);
2553 slic_mcast_set_mask(adapter);
2557 #define XMIT_FAIL_LINK_STATE 1
2558 #define XMIT_FAIL_ZERO_LENGTH 2
2559 #define XMIT_FAIL_HOSTCMD_FAIL 3
2561 static void slic_xmit_build_request(
struct adapter *adapter,
2567 ihcmd = &hcmd->
cmd64;
2572 phys_addr = pci_map_single(adapter->
pcidev, skb->
data, skb->
len,
2574 ihcmd->
u.
slic_buffers.bufs[0].paddrl = SLIC_GET_ADDR_LOW(phys_addr);
2575 ihcmd->
u.
slic_buffers.bufs[0].paddrh = SLIC_GET_ADDR_HIGH(phys_addr);
2577 #if BITS_PER_LONG == 64
2579 (
u64) hcmd) + 31) >> 5);
2582 (
u32) hcmd) + 31) >> 5);
2586 static void slic_xmit_fail(
struct adapter *adapter,
2588 void *cmd,
u32 skbtype,
u32 status)
2591 netif_stop_queue(adapter->
netdev);
2596 "reject xmit skb[%p: %x] linkstate[%s] "
2597 "adapter[%s:%d] card[%s:%d]\n",
2603 adapter->
card->state);
2607 "xmit_start skb->len == 0 skb[%p] type[%x]\n",
2612 "xmit_start skb[%p] type[%x] No host commands "
2613 "available\n", skb, skb->
pkt_type);
2620 adapter->
netdev->stats.tx_dropped++;
2623 static void slic_rcv_handle_error(
struct adapter *adapter,
2638 netdev->
stats.rx_fifo_errors++;
2642 netdev->
stats.rx_over_errors++;
2646 netdev->
stats.tx_carrier_errors++;
2654 netdev->
stats.rx_crc_errors++;
2715 #define TCP_OFFLOAD_FRAME_PUSHFLAG 0x10000000
2716 #define M_FAST_PATH 0x0040
2718 static void slic_rcv_handler(
struct adapter *adapter)
2725 while ((skb = slic_rcvqueue_getnext(adapter))) {
2730 adapter->
card->events++;
2733 slic_rcv_handle_error(adapter, rcvbuf);
2734 slic_rcvqueue_reinsert(adapter, skb);
2740 slic_rcvqueue_reinsert(adapter, skb);
2746 netdev->
stats.rx_packets++;
2748 #if SLIC_OFFLOAD_IP_CHECKSUM
2757 #if SLIC_INTERRUPT_PROCESS_LIMIT
2767 static void slic_xmit_complete(
struct adapter *adapter)
2775 rspbuf = slic_rspqueue_getnext(adapter);
2779 adapter->
card->events++;
2797 slic_cmdq_putdone_irq(adapter, hcmd);
2809 struct adapter *adapter = netdev_priv(dev);
2813 slic_reg32_write(&adapter->
slic_regs->slic_icr,
2816 adapter->
pshmem->isr = 0;
2818 switch (adapter->
card->state) {
2832 error_rmiss_interrupts++;
2834 rcv_count = rcvq->
count;
2835 pre_count = rcvq->
count;
2838 while (rcvq->
count <
2848 "isr & ISR_ERR [%x] "
2849 "ISR_XDROP \n", isr);
2852 "isr & ISR_ERR [%x]\n",
2859 slic_link_event_handler(adapter);
2863 (isr & ISR_UPCERR) || (isr & ISR_UPCBSY)) {
2865 slic_upr_request_complete(adapter, isr);
2871 slic_rcv_handler(adapter);
2876 slic_xmit_complete(adapter);
2881 if ((isr & ISR_UPC) ||
2882 (isr & ISR_UPCERR) || (isr & ISR_UPCBSY)) {
2884 slic_upr_request_complete(adapter, isr);
2902 #define NORMAL_ETHFRAME 0
2907 struct adapter *adapter = netdev_priv(dev);
2911 void *offloadcmd =
NULL;
2913 card = adapter->
card;
2920 }
else if (skb->
len == 0) {
2926 hcmd = slic_cmdq_getfree(adapter);
2939 slic_xmit_build_request(adapter, hcmd, skb);
2941 dev->
stats.tx_packets++;
2945 if (adapter->kill_card) {
2948 ihcmd = &hcmd->
cmd64;
2950 ihcmd->flags |= 0x40;
2951 adapter->kill_card = 0;
2955 slic_reg32_write(&adapter->
slic_regs->slic_cbar,
2958 slic_reg64_write(adapter, &adapter->
slic_regs->slic_cbar64,
2966 slic_xmit_fail(adapter, skb, offloadcmd, skbtype, status);
2971 static void slic_adapter_freeresources(
struct adapter *adapter)
2973 slic_init_cleanup(adapter);
2986 static int slic_adapter_allocresources(
struct adapter *adapter)
2991 spin_unlock_irqrestore(&slic_global.
driver_lock.lock,
3004 "request_irq (%s) FAILED [%x]\n",
3005 adapter->
netdev->name, retval);
3019 static int slic_if_init(
struct adapter *adapter)
3031 dev_err(&dev->
dev,
"%s: adapter->state != ADAPT_DOWN\n",
3050 rc = slic_adapter_allocresources(adapter);
3053 "%s: slic_adapter_allocresources FAILED %x\n",
3055 slic_adapter_freeresources(adapter);
3060 if ((rc = slic_rspqueue_init(adapter)))
3062 if ((rc = slic_cmdq_init(adapter)))
3064 if ((rc = slic_rcvqueue_init(adapter)))
3078 #if BITS_PER_LONG == 64
3081 slic_reg32_write(&slic_regs->
slic_isp,
3082 SLIC_GET_ADDR_LOW(&pshmem->
isr),
FLUSH);
3098 card->
loadtimer.function = &slic_timer_load_check;
3109 adapter->
pingtimer.function = &slic_timer_ping;
3119 adapter->
pshmem->isr = 0;
3124 slic_link_event_handler(adapter);
3130 static int slic_entry_open(
struct net_device *dev)
3132 struct adapter *adapter = netdev_priv(dev);
3139 netif_stop_queue(adapter->
netdev);
3148 status = slic_if_init(adapter);
3162 spin_unlock_irqrestore(&slic_global.
driver_lock.lock,
3167 static void slic_card_cleanup(
struct sliccard *card)
3174 slic_debug_card_destroy(card);
3181 struct net_device *dev = pci_get_drvdata(pcidev);
3184 struct adapter *adapter = netdev_priv(dev);
3188 slic_adapter_freeresources(adapter);
3189 slic_unmap_mmio_space(adapter);
3202 mlist = mlist->
next;
3206 card = adapter->
card;
3212 if (curr_card == card) {
3215 while (curr_card->
next != card)
3216 curr_card = curr_card->
next;
3222 slic_card_cleanup(card);
3229 static int slic_entry_halt(
struct net_device *dev)
3231 struct adapter *adapter = netdev_priv(dev);
3238 netif_stop_queue(adapter->
netdev);
3248 slic_config_clear(adapter);
3254 #ifdef AUTOMATIC_RESET
3260 slic_cmdq_reset(adapter);
3262 #ifdef AUTOMATIC_RESET
3264 slic_card_init(card, adapter);
3267 spin_unlock_irqrestore(&slic_global.
driver_lock.lock,
3274 struct adapter *adapter = netdev_priv(dev);
3281 dev->
stats.tx_heartbeat_errors = 0;
3282 dev->
stats.tx_aborted_errors = 0;
3283 dev->
stats.tx_window_errors = 0;
3284 dev->
stats.tx_fifo_errors = 0;
3285 dev->
stats.rx_frame_errors = 0;
3286 dev->
stats.rx_length_errors = 0;
3293 struct adapter *adapter = netdev_priv(dev);
3305 dev_err(&dev->
dev,
"%s: set interrupt aggregation to %d\n",
3307 slic_intagg_set(adapter, intagg);
3310 #ifdef SLIC_TRACE_DUMP_ENABLED
3314 DBG_IOCTL(
"slic_ioctl SIOCSLIC_TRACE_DUMP\n");
3318 (
"slic: copy_from_user FAILED getting initial simba param\n");
3323 if (tracemon_request == SLIC_DUMP_DONE) {
3325 (
"ATK Diagnostic Trace Dump Requested\n");
3326 tracemon_request = SLIC_DUMP_REQUESTED;
3327 tracemon_request_type =
value;
3329 }
else if ((tracemon_request == SLIC_DUMP_REQUESTED) ||
3330 (tracemon_request ==
3331 SLIC_DUMP_IN_PROGRESS)) {
3333 (
"ATK Diagnostic Trace Dump Requested but already in progress... ignore\n");
3336 (
"ATK Diagnostic Trace Dump Requested\n");
3337 tracemon_request = SLIC_DUMP_REQUESTED;
3338 tracemon_request_type =
value;
3357 edata.phy_address = 0;
3395 if ((ecmd.speed !=
edata.speed) ||
3396 (ecmd.duplex !=
edata.duplex)) {
3408 slic_link_config(adapter, speed, duplex);
3409 slic_link_event_handler(adapter);
3418 static void slic_config_pci(
struct pci_dev *pcidev)
3423 pci_read_config_word(pcidev,
PCI_COMMAND, &pci_command);
3429 if (pci_command != new_command)
3430 pci_write_config_word(pcidev,
PCI_COMMAND, new_command);
3433 static int slic_card_init(
struct sliccard *card,
struct adapter *adapter)
3450 unsigned char fruformat;
3451 unsigned char oemfruformat;
3453 union oemfru *poemfru;
3456 slic_soft_reset(adapter);
3459 status = slic_card_download(adapter);
3463 "download failed bus %d slot %d\n",
3473 phys_configl = SLIC_GET_ADDR_LOW(phys_config);
3474 phys_configh = SLIC_GET_ADDR_HIGH(phys_config);
3478 "eeprom read failed to get memory "
3492 slic_reg32_write(&slic_regs->
slic_isp,
3493 SLIC_GET_ADDR_LOW(&pshmem->
isr),
FLUSH);
3497 slic_config_get(adapter, phys_configl, phys_configh);
3500 if (adapter->
pshmem->isr) {
3501 if (adapter->
pshmem->isr & ISR_UPC) {
3502 adapter->
pshmem->isr = 0;
3503 slic_reg64_write(adapter,
3507 slic_reg32_write(&slic_regs->
slic_isr,
3510 slic_upr_request_complete(adapter, 0);
3513 adapter->
pshmem->isr = 0;
3514 slic_reg32_write(&slic_regs->
slic_isr,
3522 "%d config data fetch timed out!\n",
3524 slic_reg64_write(adapter,
3533 switch (adapter->
devid) {
3542 patkfru = &pOeeprom->
AtkFru;
3544 poemfru = &pOeeprom->
OemFru;
3555 pmac = peeprom->
u2.
mac.MacInfo;
3557 patkfru = &peeprom->
AtkFru;
3559 poemfru = &peeprom->
OemFru;
3563 card->
config.EepromValid =
false;
3570 *(
u16 *) ((
char *) peeprom + (eecodesize - 2));
3575 ~slic_eeprom_cksum((
char *) peeprom,
3581 if (ee_chksum == calc_chksum)
3582 card->
config.EepromValid =
true;
3585 card->
config.DramSize = dramsize;
3588 for (i = 0; i < macaddrs; i++) {
3594 card->
config.FruFormat = fruformat;
3600 peeprom, phys_config);
3602 if ((!card->
config.EepromValid) &&
3604 slic_reg64_write(adapter, &slic_regs->
slic_isp, 0,
3608 "unsupported CONFIGURATION EEPROM invalid\n");
3615 if (slic_card_download_gbrcv(adapter)) {
3617 "unable to download GB receive microcode\n");
3622 slic_intagg_set(adapter, 0);
3624 slic_intagg_set(adapter, intagg_delay);
3640 static void slic_init_driver(
void)
3642 if (slic_first_init) {
3643 slic_first_init = 0;
3649 static void slic_init_adapter(
struct net_device *netdev,
3656 struct adapter *adapter = netdev_priv(netdev);
3667 adapter->
irq = pcidev->
irq;
3670 head_netdevice = netdev;
3671 adapter->
chipid = chip_idx;
3689 for (index = 1, pslic_handle = &adapter->
slic_handles[1];
3709 .ndo_open = slic_entry_open,
3710 .ndo_stop = slic_entry_halt,
3711 .ndo_start_xmit = slic_xmit_start,
3712 .ndo_do_ioctl = slic_ioctl,
3713 .ndo_set_mac_address = slic_mac_set_address,
3714 .ndo_get_stats = slic_get_stats,
3715 .ndo_set_rx_mode = slic_mcast_set_list,
3720 static u32 slic_card_locate(
struct adapter *adapter)
3727 uint rdhostid_offset = 0;
3729 switch (adapter->
devid) {
3768 slic_debug_card_create(card);
3772 if (card->
cardnum == card_hostid)
3797 ASSERT(i != SLIC_MAX_PORTS);
3800 physcard = physcard->
next;
3804 physcard = kzalloc(
sizeof(
struct physcard),
GFP_ATOMIC);
3826 static int cards_found;
3827 static int did_version;
3833 ulong mmio_start = 0;
3836 int pci_using_dac = 0;
3845 if (slic_debug > 0 && did_version++ == 0) {
3852 if (pci_set_consistent_dma_mask(pcidev,
DMA_BIT_MASK(64))) {
3853 dev_err(&pcidev->
dev,
"unable to obtain 64-bit DMA for "
3854 "consistent allocations\n");
3855 goto err_out_disable_pci;
3857 }
else if (pci_set_dma_mask(pcidev,
DMA_BIT_MASK(32))) {
3861 dev_err(&pcidev->
dev,
"no usable DMA configuration\n");
3862 goto err_out_disable_pci;
3867 dev_err(&pcidev->
dev,
"can't obtain PCI resources\n");
3868 goto err_out_disable_pci;
3873 netdev = alloc_etherdev(
sizeof(
struct adapter));
3876 goto err_out_exit_slic_probe;
3881 pci_set_drvdata(pcidev, netdev);
3882 adapter = netdev_priv(netdev);
3883 adapter->
netdev = netdev;
3893 memmapped_ioaddr =
ioremap(mmio_start, mmio_len);
3894 if (!memmapped_ioaddr) {
3895 dev_err(&pcidev->
dev,
"cannot remap MMIO region %lx @ %lx\n",
3896 mmio_len, mmio_start);
3897 goto err_out_free_netdev;
3900 slic_config_pci(pcidev);
3904 slic_init_adapter(netdev,
3905 pcidev, pci_tbl_entry, memmapped_ioaddr, cards_found);
3907 status = slic_card_locate(adapter);
3909 dev_err(&pcidev->
dev,
"cannot locate card\n");
3910 goto err_out_free_mmio_region;
3913 card = adapter->
card;
3920 status = slic_card_init(card, adapter);
3926 dev_err(&pcidev->
dev,
"FAILED status[%x]\n", status);
3928 slic_adapter_set_hwaddr(adapter);
3932 netdev->
irq = adapter->
irq;
3935 slic_debug_adapter_create(adapter);
3940 dev_err(&pcidev->
dev,
"Cannot register net device, aborting.\n");
3950 err_out_free_mmio_region:
3952 err_out_free_netdev:
3954 err_out_exit_slic_probe:
3956 err_out_disable_pci:
3963 .id_table = slic_pci_tbl,
3964 .probe = slic_entry_probe,
3968 static int __init slic_module_init(
void)
3978 return pci_register_driver(&slic_driver);
3981 static void __exit slic_module_cleanup(
void)
3984 slic_debug_cleanup();