26 #include <linux/slab.h>
32 #define MASK(n) ((1ULL<<(n))-1)
33 #define MN_WIN(addr) (((addr & 0x1fc0000) >> 1) | ((addr >> 25) & 0x3ff))
34 #define OCM_WIN(addr) (((addr & 0x1ff0000) >> 1) | ((addr >> 25) & 0x3ff))
35 #define MS_WIN(addr) (addr & 0x0ffc0000)
37 #define GET_MEM_OFFS_2M(addr) (addr & MASK(18))
39 #define CRB_BLK(off) ((off >> 20) & 0x3f)
40 #define CRB_SUBBLK(off) ((off >> 16) & 0xf)
41 #define CRB_WINDOW_2M (0x130060)
42 #define CRB_HI(off) ((crb_hub_agt[CRB_BLK(off)] << 20) | ((off) & 0xf0000))
43 #define CRB_INDIRECT_2M (0x1e0000UL)
64 #define PCI_OFFSET_FIRST_RANGE(adapter, off) \
65 ((adapter)->ahw.pci_base0 + (off))
66 #define PCI_OFFSET_SECOND_RANGE(adapter, off) \
67 ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
68 #define PCI_OFFSET_THIRD_RANGE(adapter, off) \
69 ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
89 {{{1, 0x0100000, 0x0102000, 0x120000},
90 {1, 0x0110000, 0x0120000, 0x130000},
91 {1, 0x0120000, 0x0122000, 0x124000},
92 {1, 0x0130000, 0x0132000, 0x126000},
93 {1, 0x0140000, 0x0142000, 0x128000},
94 {1, 0x0150000, 0x0152000, 0x12a000},
95 {1, 0x0160000, 0x0170000, 0x110000},
96 {1, 0x0170000, 0x0172000, 0x12e000},
97 {0, 0x0000000, 0x0000000, 0x000000},
98 {0, 0x0000000, 0x0000000, 0x000000},
99 {0, 0x0000000, 0x0000000, 0x000000},
100 {0, 0x0000000, 0x0000000, 0x000000},
101 {0, 0x0000000, 0x0000000, 0x000000},
102 {0, 0x0000000, 0x0000000, 0x000000},
103 {1, 0x01e0000, 0x01e0800, 0x122000},
104 {0, 0x0000000, 0x0000000, 0x000000} } },
105 {{{1, 0x0200000, 0x0210000, 0x180000} } },
107 {{{1, 0x0400000, 0x0401000, 0x169000} } },
108 {{{1, 0x0500000, 0x0510000, 0x140000} } },
109 {{{1, 0x0600000, 0x0610000, 0x1c0000} } },
110 {{{1, 0x0700000, 0x0704000, 0x1b8000} } },
111 {{{1, 0x0800000, 0x0802000, 0x170000},
112 {0, 0x0000000, 0x0000000, 0x000000},
113 {0, 0x0000000, 0x0000000, 0x000000},
114 {0, 0x0000000, 0x0000000, 0x000000},
115 {0, 0x0000000, 0x0000000, 0x000000},
116 {0, 0x0000000, 0x0000000, 0x000000},
117 {0, 0x0000000, 0x0000000, 0x000000},
118 {0, 0x0000000, 0x0000000, 0x000000},
119 {0, 0x0000000, 0x0000000, 0x000000},
120 {0, 0x0000000, 0x0000000, 0x000000},
121 {0, 0x0000000, 0x0000000, 0x000000},
122 {0, 0x0000000, 0x0000000, 0x000000},
123 {0, 0x0000000, 0x0000000, 0x000000},
124 {0, 0x0000000, 0x0000000, 0x000000},
125 {0, 0x0000000, 0x0000000, 0x000000},
126 {1, 0x08f0000, 0x08f2000, 0x172000} } },
127 {{{1, 0x0900000, 0x0902000, 0x174000},
128 {0, 0x0000000, 0x0000000, 0x000000},
129 {0, 0x0000000, 0x0000000, 0x000000},
130 {0, 0x0000000, 0x0000000, 0x000000},
131 {0, 0x0000000, 0x0000000, 0x000000},
132 {0, 0x0000000, 0x0000000, 0x000000},
133 {0, 0x0000000, 0x0000000, 0x000000},
134 {0, 0x0000000, 0x0000000, 0x000000},
135 {0, 0x0000000, 0x0000000, 0x000000},
136 {0, 0x0000000, 0x0000000, 0x000000},
137 {0, 0x0000000, 0x0000000, 0x000000},
138 {0, 0x0000000, 0x0000000, 0x000000},
139 {0, 0x0000000, 0x0000000, 0x000000},
140 {0, 0x0000000, 0x0000000, 0x000000},
141 {0, 0x0000000, 0x0000000, 0x000000},
142 {1, 0x09f0000, 0x09f2000, 0x176000} } },
143 {{{0, 0x0a00000, 0x0a02000, 0x178000},
144 {0, 0x0000000, 0x0000000, 0x000000},
145 {0, 0x0000000, 0x0000000, 0x000000},
146 {0, 0x0000000, 0x0000000, 0x000000},
147 {0, 0x0000000, 0x0000000, 0x000000},
148 {0, 0x0000000, 0x0000000, 0x000000},
149 {0, 0x0000000, 0x0000000, 0x000000},
150 {0, 0x0000000, 0x0000000, 0x000000},
151 {0, 0x0000000, 0x0000000, 0x000000},
152 {0, 0x0000000, 0x0000000, 0x000000},
153 {0, 0x0000000, 0x0000000, 0x000000},
154 {0, 0x0000000, 0x0000000, 0x000000},
155 {0, 0x0000000, 0x0000000, 0x000000},
156 {0, 0x0000000, 0x0000000, 0x000000},
157 {0, 0x0000000, 0x0000000, 0x000000},
158 {1, 0x0af0000, 0x0af2000, 0x17a000} } },
159 {{{0, 0x0b00000, 0x0b02000, 0x17c000},
160 {0, 0x0000000, 0x0000000, 0x000000},
161 {0, 0x0000000, 0x0000000, 0x000000},
162 {0, 0x0000000, 0x0000000, 0x000000},
163 {0, 0x0000000, 0x0000000, 0x000000},
164 {0, 0x0000000, 0x0000000, 0x000000},
165 {0, 0x0000000, 0x0000000, 0x000000},
166 {0, 0x0000000, 0x0000000, 0x000000},
167 {0, 0x0000000, 0x0000000, 0x000000},
168 {0, 0x0000000, 0x0000000, 0x000000},
169 {0, 0x0000000, 0x0000000, 0x000000},
170 {0, 0x0000000, 0x0000000, 0x000000},
171 {0, 0x0000000, 0x0000000, 0x000000},
172 {0, 0x0000000, 0x0000000, 0x000000},
173 {0, 0x0000000, 0x0000000, 0x000000},
174 {1, 0x0bf0000, 0x0bf2000, 0x17e000} } },
175 {{{1, 0x0c00000, 0x0c04000, 0x1d4000} } },
176 {{{1, 0x0d00000, 0x0d04000, 0x1a4000} } },
177 {{{1, 0x0e00000, 0x0e04000, 0x1a0000} } },
178 {{{1, 0x0f00000, 0x0f01000, 0x164000} } },
179 {{{0, 0x1000000, 0x1004000, 0x1a8000} } },
180 {{{1, 0x1100000, 0x1101000, 0x160000} } },
181 {{{1, 0x1200000, 0x1201000, 0x161000} } },
182 {{{1, 0x1300000, 0x1301000, 0x162000} } },
183 {{{1, 0x1400000, 0x1401000, 0x163000} } },
184 {{{1, 0x1500000, 0x1501000, 0x165000} } },
185 {{{1, 0x1600000, 0x1601000, 0x166000} } },
192 {{{1, 0x1d00000, 0x1d10000, 0x190000} } },
193 {{{1, 0x1e00000, 0x1e01000, 0x16a000} } },
194 {{{1, 0x1f00000, 0x1f10000, 0x150000} } },
196 {{{1, 0x2100000, 0x2102000, 0x120000},
197 {1, 0x2110000, 0x2120000, 0x130000},
198 {1, 0x2120000, 0x2122000, 0x124000},
199 {1, 0x2130000, 0x2132000, 0x126000},
200 {1, 0x2140000, 0x2142000, 0x128000},
201 {1, 0x2150000, 0x2152000, 0x12a000},
202 {1, 0x2160000, 0x2170000, 0x110000},
203 {1, 0x2170000, 0x2172000, 0x12e000},
204 {0, 0x0000000, 0x0000000, 0x000000},
205 {0, 0x0000000, 0x0000000, 0x000000},
206 {0, 0x0000000, 0x0000000, 0x000000},
207 {0, 0x0000000, 0x0000000, 0x000000},
208 {0, 0x0000000, 0x0000000, 0x000000},
209 {0, 0x0000000, 0x0000000, 0x000000},
210 {0, 0x0000000, 0x0000000, 0x000000},
211 {0, 0x0000000, 0x0000000, 0x000000} } },
212 {{{1, 0x2200000, 0x2204000, 0x1b0000} } },
218 {{{1, 0x2800000, 0x2804000, 0x1a4000} } },
219 {{{1, 0x2900000, 0x2901000, 0x16b000} } },
220 {{{1, 0x2a00000, 0x2a00400, 0x1ac400} } },
221 {{{1, 0x2b00000, 0x2b00400, 0x1ac800} } },
222 {{{1, 0x2c00000, 0x2c00400, 0x1acc00} } },
223 {{{1, 0x2d00000, 0x2d00400, 0x1ad000} } },
224 {{{1, 0x2e00000, 0x2e00400, 0x1ad400} } },
225 {{{1, 0x2f00000, 0x2f00400, 0x1ad800} } },
226 {{{1, 0x3000000, 0x3000400, 0x1adc00} } },
227 {{{0, 0x3100000, 0x3104000, 0x1a8000} } },
228 {{{1, 0x3200000, 0x3204000, 0x1d4000} } },
229 {{{1, 0x3300000, 0x3304000, 0x1a0000} } },
231 {{{1, 0x3500000, 0x3500400, 0x1ac000} } },
232 {{{1, 0x3600000, 0x3600400, 0x1ae000} } },
233 {{{1, 0x3700000, 0x3700400, 0x1ae400} } },
234 {{{1, 0x3800000, 0x3804000, 0x1d0000} } },
235 {{{1, 0x3900000, 0x3904000, 0x1b4000} } },
236 {{{1, 0x3a00000, 0x3a04000, 0x1d8000} } },
239 {{{1, 0x3d00000, 0x3d04000, 0x1d8000} } },
240 {{{1, 0x3e00000, 0x3e01000, 0x167000} } },
241 {{{1, 0x3f00000, 0x3f01000, 0x168000} } }
247 static unsigned crb_hub_agt[64] =
317 #define NETXEN_WINDOW_ONE 0x2000000
319 #define NETXEN_PCIE_SEM_TIMEOUT 10000
360 static int netxen_niu_disable_xg_port(
struct netxen_adapter *adapter)
378 #define NETXEN_UNICAST_ADDR(port, index) \
379 (NETXEN_UNICAST_ADDR_BASE+(port*32)+(index*8))
380 #define NETXEN_MCAST_ADDR(port, index) \
381 (NETXEN_MULTICAST_ADDR_BASE+(port*0x80)+(index*8))
382 #define MAC_HI(addr) \
383 ((addr[2] << 16) | (addr[1] << 8) | (addr[0]))
384 #define MAC_LO(addr) \
385 ((addr[5] << 16) | (addr[4] << 8) | (addr[3]))
404 reg = (0x20 <<
port);
419 reg = (reg | 0x2000
UL);
421 reg = (reg & ~0x2000
UL);
424 reg = (reg | 0x1000
UL);
426 reg = (reg & ~0x1000
UL);
438 static int netxen_p2_nic_set_mac_addr(
struct netxen_adapter *adapter,
u8 *addr)
448 mac_lo = ((
u32)addr[0] << 16) | ((
u32)addr[1] << 24);
449 mac_hi = addr[2] | ((
u32)addr[3] << 8) |
450 ((
u32)addr[4] << 16) | ((
u32)addr[5] << 24);
456 if (
NXWR32(adapter, reg_lo, mac_lo) ||
NXWR32(adapter, reg_hi, mac_hi))
458 if (
NXWR32(adapter, reg_lo, mac_lo) ||
NXWR32(adapter, reg_hi, mac_hi))
475 val |= (1
UL << (28+
port));
504 val &= ~(1
UL << (28+
port));
535 static void netxen_p2_nic_set_multi(
struct net_device *netdev)
550 netxen_nic_disable_mcast_filter(adapter);
558 netxen_nic_disable_mcast_filter(adapter);
565 netxen_nic_disable_mcast_filter(adapter);
569 netxen_nic_enable_mcast_filter(adapter);
573 netxen_nic_set_mcast_addr(adapter, i++, ha->addr);
576 while (i < adapter->max_mc_count)
577 netxen_nic_set_mcast_addr(adapter, i++, null_addr);
584 u32 i, producer, consumer;
594 tx_ring = adapter->tx_ring;
595 __netif_tx_lock_bh(tx_ring->
txq);
600 if (nr_desc >= netxen_tx_avail(tx_ring)) {
601 netif_tx_stop_queue(tx_ring->
txq);
603 if (netxen_tx_avail(tx_ring) > nr_desc) {
605 netif_tx_wake_queue(tx_ring->
txq);
607 __netif_tx_unlock_bh(tx_ring->
txq);
613 cmd_desc = &cmd_desc_arr[
i];
625 }
while (i != nr_desc);
631 __netif_tx_unlock_bh(tx_ring->
txq);
653 return netxen_send_cmd_descs(adapter, (
struct cmd_desc_type0 *)&req, 1);
667 list_move_tail(head, &adapter->
mac_list);
680 return nx_p3_sre_macaddr_change(adapter,
684 static void netxen_p3_nic_set_multi(
struct net_device *netdev)
689 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
699 list_splice_tail_init(&adapter->
mac_list, &del_list);
701 nx_p3_nic_add_mac(adapter, adapter->
mac_addr, &del_list);
702 nx_p3_nic_add_mac(adapter, bcast_addr, &del_list);
717 nx_p3_nic_add_mac(adapter, ha->addr, &del_list);
721 adapter->set_promisc(adapter, mode);
723 while (!list_empty(head)) {
726 nx_p3_sre_macaddr_change(adapter,
748 return netxen_send_cmd_descs(adapter,
757 while (!list_empty(head)) {
759 nx_p3_sre_macaddr_change(adapter,
766 static int netxen_p3_nic_set_mac_addr(
struct netxen_adapter *adapter,
u8 *addr)
769 netxen_p3_nic_set_multi(adapter->
netdev);
773 #define NETXEN_CONFIG_INTR_COALESCE 3
785 memset(word, 0,
sizeof(word));
793 for (i = 0; i < 6; i++)
796 rv = netxen_send_cmd_descs(adapter, (
struct cmd_desc_type0 *)&req, 1);
799 "interrupt coalescing parameters\n");
823 rv = netxen_send_cmd_descs(adapter, (
struct cmd_desc_type0 *)&req, 1);
826 "configure hw lro request\n");
851 rv = netxen_send_cmd_descs(adapter, (
struct cmd_desc_type0 *)&req, 1);
854 "configure bridge mode request\n");
863 #define RSS_HASHTYPE_IP_TCP 0x3
871 static const u64 key[] = {
872 0xbeac01fa6a42b73bULL, 0x8030f20c77cb2da3ULL,
873 0xae7b30b4d0ca2bcbULL, 0x43a38fb04167253dULL,
874 0x255b0ec26d5a56daULL
896 ((
u64)(enable & 0x1) << 8) |
903 rv = netxen_send_cmd_descs(adapter, (
struct cmd_desc_type0 *)&req, 1);
927 rv = netxen_send_cmd_descs(adapter, (
struct cmd_desc_type0 *)&req, 1);
931 (cmd ==
NX_IP_UP) ?
"Add" :
"Remove", ip);
949 rv = netxen_send_cmd_descs(adapter, (
struct cmd_desc_type0 *)&req, 1);
976 rv = netxen_send_cmd_descs(adapter, (
struct cmd_desc_type0 *)&req, 1);
989 #define MTU_FUDGE_FACTOR 100
1002 if (mtu > max_mtu) {
1004 netdev->
name, max_mtu);
1009 rc = adapter->
set_mtu(adapter, mtu);
1017 static int netxen_get_flash_block(
struct netxen_adapter *adapter,
int base,
1025 for (i = 0; i < size /
sizeof(
u32); i++) {
1030 addr +=
sizeof(
u32);
1032 if ((
char *)buf + size > (
char *)ptr32) {
1037 memcpy(ptr32, &local, (
char *)buf + size - (
char *)ptr32);
1050 if (netxen_get_flash_block(adapter, offset,
sizeof(
u64), pmac) == -1)
1053 if (*mac == ~0ULL) {
1058 if (netxen_get_flash_block(adapter,
1059 offset,
sizeof(
u64), pmac) == -1)
1074 (4 * ((pci_func/2) * 3)) + (4 * (pci_func & 1));
1076 mac_lo =
NXRD32(adapter, crbaddr);
1077 mac_hi =
NXRD32(adapter, crbaddr+4);
1091 netxen_nic_pci_set_crbwindow_128M(
struct netxen_adapter *adapter,
1098 if (adapter->
ahw.crb_win == window)
1106 if (window ==
readl(offset))
1109 if (printk_ratelimit())
1111 "failed to set CRB window to %d\n",
1115 }
while (--count > 0);
1175 if (
readl(addr) != window) {
1176 if (printk_ratelimit())
1178 "failed to set CRB window to %d off 0x%lx\n",
1184 netxen_nic_map_indirect_address_128M(
struct netxen_adapter *adapter,
1187 ulong off = win_off;
1194 addr = pci_base_offset(adapter, off);
1198 if (adapter->
ahw.pci_len0 == 0)
1204 addr = *mem_ptr + (off & (
PAGE_SIZE - 1));
1212 unsigned long flags;
1215 addr = netxen_nic_map_indirect_address_128M(adapter, off, &mem_ptr);
1220 netxen_nic_io_write_128M(adapter, addr, data);
1223 netxen_nic_pci_set_crbwindow_128M(adapter, 0);
1225 netxen_nic_pci_set_crbwindow_128M(adapter,
1239 unsigned long flags;
1243 addr = netxen_nic_map_indirect_address_128M(adapter, off, &mem_ptr);
1248 data = netxen_nic_io_read_128M(adapter, addr);
1251 netxen_nic_pci_set_crbwindow_128M(adapter, 0);
1253 netxen_nic_pci_set_crbwindow_128M(adapter,
1267 unsigned long flags;
1271 rv = netxen_nic_pci_get_crb_addr_2M(adapter, off, &addr);
1282 netxen_nic_pci_set_crbwindow_2M(adapter, off);
1290 "%s: invalid offset: 0x%016lx\n", __func__, off);
1298 unsigned long flags;
1303 rv = netxen_nic_pci_get_crb_addr_2M(adapter, off, &addr);
1312 netxen_nic_pci_set_crbwindow_2M(adapter, off);
1320 "%s: invalid offset: 0x%016lx\n", __func__, off);
1326 static void netxen_nic_io_write_128M(
struct netxen_adapter *adapter,
1346 static void netxen_nic_io_write_2M(
struct netxen_adapter *adapter,
1370 WARN_ON(netxen_nic_pci_get_crb_addr_2M(adapter,
1401 writel(window, adapter->
ahw.ocm_win_crb);
1419 spin_lock(&adapter->
ahw.mem_lock);
1426 addr = adapter->
ahw.pci_base0 +
start;
1428 addr = pci_base_offset(adapter, start);
1435 if (mem_ptr ==
NULL) {
1440 addr = mem_ptr + (start & (
PAGE_SIZE-1));
1444 *data =
readq(addr);
1449 spin_unlock(&adapter->
ahw.mem_lock);
1459 void __iomem *addr = adapter->
ahw.pci_base0 +
1462 spin_lock(&adapter->
ahw.mem_lock);
1463 *data =
readq(addr);
1464 spin_unlock(&adapter->
ahw.mem_lock);
1470 void __iomem *addr = adapter->
ahw.pci_base0 +
1473 spin_lock(&adapter->
ahw.mem_lock);
1475 spin_unlock(&adapter->
ahw.mem_lock);
1478 #define MAX_CTL_CHECK 1000
1485 u32 temp, off_lo, off_hi, addr_hi, data_hi, data_lo;
1495 mem_crb = pci_base_offset(adapter,
1506 mem_crb = pci_base_offset(adapter,
1518 if (adapter->
ahw.pci_len0 != 0) {
1519 return netxen_nic_pci_mem_access_direct(adapter,
1527 spin_lock(&adapter->
ahw.mem_lock);
1528 netxen_nic_pci_set_crbwindow_128M(adapter, 0);
1531 writel(off_hi, (mem_crb + addr_hi));
1532 writel(data & 0xffffffff, (mem_crb + data_lo));
1533 writel((data >> 32) & 0xffffffff, (mem_crb + data_hi));
1544 if (j >= MAX_CTL_CHECK) {
1545 if (printk_ratelimit())
1547 "failed to write through agent\n");
1553 spin_unlock(&adapter->
ahw.mem_lock);
1562 u32 temp, off_lo, off_hi, addr_hi, data_hi, data_lo;
1573 mem_crb = pci_base_offset(adapter,
1584 mem_crb = pci_base_offset(adapter,
1596 if (adapter->
ahw.pci_len0 != 0) {
1597 return netxen_nic_pci_mem_access_direct(adapter,
1605 spin_lock(&adapter->
ahw.mem_lock);
1606 netxen_nic_pci_set_crbwindow_128M(adapter, 0);
1609 writel(off_hi, (mem_crb + addr_hi));
1619 if (j >= MAX_CTL_CHECK) {
1620 if (printk_ratelimit())
1622 "failed to read through agent\n");
1626 temp =
readl(mem_crb + data_hi);
1627 val = ((
u64)temp << 32);
1628 val |=
readl(mem_crb + data_lo);
1634 spin_unlock(&adapter->
ahw.mem_lock);
1666 return netxen_nic_pci_mem_access_direct(adapter, off, &data, 1);
1671 off8 = off & 0xfffffff8;
1673 spin_lock(&adapter->
ahw.mem_lock);
1678 writel(data & 0xffffffff,
1680 writel((data >> 32) & 0xffffffff,
1693 if (j >= MAX_CTL_CHECK) {
1694 if (printk_ratelimit())
1696 "failed to write through agent\n");
1701 spin_unlock(&adapter->
ahw.mem_lock);
1734 return netxen_nic_pci_mem_access_direct(adapter,
1741 off8 = off & 0xfffffff8;
1743 spin_lock(&adapter->
ahw.mem_lock);
1756 if (j >= MAX_CTL_CHECK) {
1757 if (printk_ratelimit())
1759 "failed to read through agent\n");
1768 spin_unlock(&adapter->
ahw.mem_lock);
1776 adapter->
init_port = netxen_niu_xg_init_port;
1777 adapter->
stop_port = netxen_niu_disable_xg_port;
1780 adapter->
crb_read = netxen_nic_hw_read_wx_128M,
1781 adapter->
crb_write = netxen_nic_hw_write_wx_128M,
1785 adapter->
io_read = netxen_nic_io_read_128M,
1786 adapter->
io_write = netxen_nic_io_write_128M,
1788 adapter->
macaddr_set = netxen_p2_nic_set_mac_addr;
1789 adapter->
set_multi = netxen_p2_nic_set_multi;
1790 adapter->
set_mtu = netxen_nic_set_mtu_xgb;
1794 adapter->
crb_read = netxen_nic_hw_read_wx_2M,
1795 adapter->
crb_write = netxen_nic_hw_write_wx_2M,
1799 adapter->
io_read = netxen_nic_io_read_2M,
1800 adapter->
io_write = netxen_nic_io_write_2M,
1804 adapter->
macaddr_set = netxen_p3_nic_set_mac_addr;
1805 adapter->
set_multi = netxen_p3_nic_set_multi;
1822 dev_err(&pdev->
dev,
"invalid board config, magic=%08x\n",
1833 if ((gpio & 0x8000) == 0)
1839 switch (board_type) {
1869 adapter->
ahw.port_type = (adapter->
portnum < 2) ?
1873 dev_err(&pdev->
dev,
"unknown board type %x\n", board_type);
1882 static int netxen_nic_set_mtu_xgb(
struct netxen_adapter *adapter,
int new_mtu)
1898 if (!netif_carrier_ok(adapter->
netdev)) {
1968 if (wol_cfg & (1
UL << adapter->
portnum)) {
1970 if (wol_cfg & (1 << adapter->
portnum))
1981 int loop_cnt,
i, rv = 0, timeout_flag;
1982 u32 op_count, stride;
1984 unsigned long timeout, timeout_jiffies;
1985 addr = crtEntry->
addr;
1989 for (loop_cnt = 0; loop_cnt < op_count; loop_cnt++) {
1990 for (i = 0; i <
sizeof(crtEntry->
opcode) * 8; i++) {
1991 opcode = (crtEntry->
opcode & (0x1 <<
i));
1996 adapter->
ahw.pci_base0,
2001 adapter->
ahw.pci_base0,
2004 adapter->
ahw.pci_base0,
2009 adapter->
ahw.pci_base0,
2011 read_value &= crtEntry->
value_2;
2013 adapter->
ahw.pci_base0,
2018 adapter->
ahw.pci_base0,
2020 read_value |= crtEntry->
value_3;
2022 adapter->
ahw.pci_base0,
2028 adapter->
ahw.pci_base0,
2032 for (timeout_flag = 0;
2034 && ((read_value & crtEntry->
value_2)
2040 adapter->
ahw.pci_base0,
2046 "Timeout in poll_crb control operation.\n"
2058 adapter->
ahw.pci_base0,
2071 read_value = crtEntry->
value_1;
2080 adapter->
ahw.pci_base0,
2087 read_value <<= crtEntry->
shl;
2088 read_value >>= crtEntry->
shr;
2092 read_value |= crtEntry->
value_3;
2093 read_value += crtEntry->
value_1;
2105 addr = addr + stride;
2114 *memEntry,
u64 *data_buff)
2117 int i = 0, loop_cnt;
2121 loop_cnt /=
sizeof(value);
2123 for (i = 0; i < loop_cnt; i++) {
2124 if (netxen_nic_pci_mem_read_2M(adapter, addr, &value))
2126 *data_buff++ =
value;
2127 addr +=
sizeof(
value);
2130 return i *
sizeof(
value);
2136 *crbEntry,
u32 *data_buff)
2141 addr = crbEntry->
addr;
2145 for (loop_cnt = 0; loop_cnt < op_count; loop_cnt++) {
2147 *data_buff++ =
addr;
2148 *data_buff++ =
value;
2149 addr = addr + stride;
2151 return loop_cnt * (2 *
sizeof(
u32));
2158 *romEntry,
__le32 *data_buff)
2169 if (!lck_val && count < MAX_CTL_CHECK) {
2176 for (i = 0; i <
size; i++) {
2177 waddr = fl_addr & 0xFFFF0000;
2182 fl_addr +=
sizeof(
val);
2192 *cacheEntry,
u32 *data_buff)
2194 int loop_cnt,
i,
k, timeout_flag = 0;
2195 u32 addr, read_addr, read_value, cntrl_addr, tag_reg_addr;
2196 u32 tag_value, read_cnt;
2197 u8 cntl_value_w, cntl_value_r;
2198 unsigned long timeout, timeout_jiffies;
2208 for (i = 0; i < loop_cnt; i++) {
2218 for (timeout_flag = 0; !timeout_flag &&
2219 ((cntl_value_r & cacheEntry->
poll_mask) != 0);) {
2223 adapter->
ahw.pci_base0,
2228 "Timeout in processing L2 Tag poll.\n");
2233 for (k = 0; k < read_cnt; k++) {
2236 *data_buff++ = read_value;
2241 return read_cnt * loop_cnt *
sizeof(read_value);
2248 *cacheEntry,
u32 *data_buff)
2251 u32 addr, read_addr, read_value, cntrl_addr, tag_reg_addr;
2252 u32 tag_value, read_cnt;
2263 for (i = 0; i < loop_cnt; i++) {
2266 (
u32) cntl_value_w);
2268 for (k = 0; k < read_cnt; k++) {
2270 adapter->
ahw.pci_base0,
2272 *data_buff++ = read_value;
2277 return read_cnt * loop_cnt *
sizeof(read_value);
2284 *ocmEntry,
u32 *data_buff)
2292 for (i = 0; i < loop_cnt; i++) {
2293 value =
readl(addr);
2294 *data_buff++ =
value;
2297 return i *
sizeof(
u32);
2303 *muxEntry,
u32 *data_buff)
2306 u32 read_addr, read_value, select_addr, sel_value;
2312 for (loop_cnt = 0; loop_cnt < muxEntry->
op_count; loop_cnt++) {
2315 *data_buff++ = sel_value;
2316 *data_buff++ = read_value;
2319 return loop_cnt * (2 *
sizeof(
u32));
2326 *queueEntry,
u32 *data_buff)
2329 u32 queue_id, read_addr, read_value, read_stride, select_addr, read_cnt;
2335 for (loop_cnt = 0, queue_id = 0; loop_cnt < queueEntry->
op_count;
2339 for (k = 0; k < read_cnt; k--) {
2342 *data_buff++ = read_value;
2343 read_addr += read_stride;
2347 return loop_cnt * (read_cnt *
sizeof(read_value));
2356 static int netxen_md_entry_err_chk(
struct netxen_adapter *adapter,
2363 if (esize != entry->
hdr.entry_capture_size) {
2364 entry->
hdr.entry_capture_size = esize;
2367 "Invalidate dump, Type:%d\tMask:%d\tSize:%dCap_size:%d\n",
2368 entry->
hdr.entry_type, entry->
hdr.entry_capture_mask,
2369 esize, entry->
hdr.entry_capture_size);
2370 dev_info(&adapter->
pdev->dev,
"Aborting further dump capture\n");
2375 static int netxen_parse_md_template(
struct netxen_adapter *adapter)
2377 int num_of_entries, buff_level, e_cnt, esize;
2378 int end_cnt = 0, rv = 0, sane_start = 0, sane_end = 0;
2380 void *template_buff = adapter->
mdump.md_template;
2381 char *dump_buff = adapter->
mdump.md_capture_buff;
2382 int capture_mask = adapter->
mdump.md_capture_mask;
2386 if ((capture_mask & 0x3) != 0x3) {
2387 dev_err(&adapter->
pdev->dev,
"Capture mask %02x below minimum needed "
2388 "for valid firmware dump\n", capture_mask);
2395 memcpy(dump_buff, template_buff, adapter->
mdump.md_template_size);
2396 dump_buff = dump_buff + adapter->
mdump.md_template_size;
2401 for (e_cnt = 0, buff_level = 0; e_cnt < num_of_entries; e_cnt++) {
2402 if (!(entry->
hdr.entry_capture_mask & capture_mask)) {
2405 ((
char *) entry + entry->
hdr.entry_size);
2408 switch (entry->
hdr.entry_type) {
2419 rv = netxen_md_cntrl(adapter,
2420 template_hdr, (
void *)entry);
2425 dbuff = dump_buff + buff_level;
2426 esize = netxen_md_rd_crb(adapter,
2427 (
void *) entry, (
void *) dbuff);
2428 rv = netxen_md_entry_err_chk
2429 (adapter, entry, esize);
2432 buff_level += esize;
2436 dbuff = dump_buff + buff_level;
2437 esize = netxen_md_rdmem(adapter,
2438 (
void *) entry, (
void *) dbuff);
2439 rv = netxen_md_entry_err_chk
2440 (adapter, entry, esize);
2443 buff_level += esize;
2447 dbuff = dump_buff + buff_level;
2448 esize = netxen_md_rdrom(adapter,
2449 (
void *) entry, (
void *) dbuff);
2450 rv = netxen_md_entry_err_chk
2451 (adapter, entry, esize);
2454 buff_level += esize;
2460 dbuff = dump_buff + buff_level;
2461 esize = netxen_md_L2Cache(adapter,
2462 (
void *) entry, (
void *) dbuff);
2463 rv = netxen_md_entry_err_chk
2464 (adapter, entry, esize);
2467 buff_level += esize;
2471 dbuff = dump_buff + buff_level;
2472 esize = netxen_md_L1Cache(adapter,
2473 (
void *) entry, (
void *) dbuff);
2474 rv = netxen_md_entry_err_chk
2475 (adapter, entry, esize);
2478 buff_level += esize;
2481 dbuff = dump_buff + buff_level;
2482 esize = netxen_md_rdocm(adapter,
2483 (
void *) entry, (
void *) dbuff);
2484 rv = netxen_md_entry_err_chk
2485 (adapter, entry, esize);
2488 buff_level += esize;
2491 dbuff = dump_buff + buff_level;
2492 esize = netxen_md_rdmux(adapter,
2493 (
void *) entry, (
void *) dbuff);
2494 rv = netxen_md_entry_err_chk
2495 (adapter, entry, esize);
2498 buff_level += esize;
2501 dbuff = dump_buff + buff_level;
2502 esize = netxen_md_rdqueue(adapter,
2503 (
void *) entry, (
void *) dbuff);
2504 rv = netxen_md_entry_err_chk
2505 (adapter, entry, esize);
2508 buff_level += esize;
2516 ((
char *) entry + entry->
hdr.entry_size);
2518 if (!sane_start || sane_end > 1) {
2520 "Firmware minidump template configuration error.\n");
2532 adapter->
mdump.md_template;
2533 hdr->driver_capture_mask = adapter->
mdump.md_capture_mask;
2535 hdr->driver_timestamp = (
u32) val.tv_sec;
2536 hdr->driver_info_word2 = adapter->
fw_version;
2538 ret = netxen_parse_md_template(adapter);
2553 adapter->
mdump.md_template;
2554 capture_mask = adapter->
mdump.md_capture_mask;
2557 if (i & capture_mask)
2562 "Invalid cap sizes for capture_mask=0x%x\n",
2563 adapter->
mdump.md_capture_mask);
2567 adapter->
mdump.md_dump_size = adapter->
mdump.md_template_size +
2568 adapter->
mdump.md_capture_size;
2569 if (!adapter->
mdump.md_capture_buff) {
2570 adapter->
mdump.md_capture_buff =
2572 if (!adapter->
mdump.md_capture_buff) {
2574 "Unable to allocate memory for minidump "
2575 "capture_buffer(%d bytes).\n",
2576 adapter->
mdump.md_dump_size);
2580 adapter->
mdump.md_dump_size);
2581 if (netxen_collect_minidump(adapter)) {
2582 adapter->
mdump.has_valid_dump = 0;
2583 adapter->
mdump.md_dump_size = 0;
2587 "Error in collecting firmware minidump.\n");
2590 adapter->
mdump.has_valid_dump = 1;
2593 "collected fw dump.\n", adapter->
netdev->name);
2598 "Cannot overwrite previously collected "
2599 "firmware minidump.\n");