2 * Copyright (C) 2003 - 2009 NetXen, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
23 * Contact Information:
27 * Cupertino, CA 95014-0701
31 #include "netxen_nic.h"
32 #include "netxen_nic_hw.h"
33 #include "netxen_nic_phan_reg.h"
37 #define MASK(n) ((1ULL<<(n))-1)
38 #define MN_WIN(addr) (((addr & 0x1fc0000) >> 1) | ((addr >> 25) & 0x3ff))
39 #define OCM_WIN(addr) (((addr & 0x1ff0000) >> 1) | ((addr >> 25) & 0x3ff))
40 #define MS_WIN(addr) (addr & 0x0ffc0000)
42 #define GET_MEM_OFFS_2M(addr) (addr & MASK(18))
44 #define CRB_BLK(off) ((off >> 20) & 0x3f)
45 #define CRB_SUBBLK(off) ((off >> 16) & 0xf)
46 #define CRB_WINDOW_2M (0x130060)
47 #define CRB_HI(off) ((crb_hub_agt[CRB_BLK(off)] << 20) | ((off) & 0xf0000))
48 #define CRB_INDIRECT_2M (0x1e0000UL)
51 static inline u64 readq(void __iomem *addr)
53 return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
58 static inline void writeq(u64 val, void __iomem *addr)
60 writel(((u32) (val)), (addr));
61 writel(((u32) (val >> 32)), (addr + 4));
65 #define ADDR_IN_RANGE(addr, low, high) \
66 (((addr) < (high)) && ((addr) >= (low)))
68 #define PCI_OFFSET_FIRST_RANGE(adapter, off) \
69 ((adapter)->ahw.pci_base0 + (off))
70 #define PCI_OFFSET_SECOND_RANGE(adapter, off) \
71 ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
72 #define PCI_OFFSET_THIRD_RANGE(adapter, off) \
73 ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
75 static void __iomem *pci_base_offset(struct netxen_adapter *adapter,
78 if (ADDR_IN_RANGE(off, FIRST_PAGE_GROUP_START, FIRST_PAGE_GROUP_END))
79 return PCI_OFFSET_FIRST_RANGE(adapter, off);
81 if (ADDR_IN_RANGE(off, SECOND_PAGE_GROUP_START, SECOND_PAGE_GROUP_END))
82 return PCI_OFFSET_SECOND_RANGE(adapter, off);
84 if (ADDR_IN_RANGE(off, THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_END))
85 return PCI_OFFSET_THIRD_RANGE(adapter, off);
90 #define CRB_WIN_LOCK_TIMEOUT 100000000
91 static crb_128M_2M_block_map_t
92 crb_128M_2M_map[64] __cacheline_aligned_in_smp = {
93 {{{0, 0, 0, 0} } }, /* 0: PCI */
94 {{{1, 0x0100000, 0x0102000, 0x120000}, /* 1: PCIE */
95 {1, 0x0110000, 0x0120000, 0x130000},
96 {1, 0x0120000, 0x0122000, 0x124000},
97 {1, 0x0130000, 0x0132000, 0x126000},
98 {1, 0x0140000, 0x0142000, 0x128000},
99 {1, 0x0150000, 0x0152000, 0x12a000},
100 {1, 0x0160000, 0x0170000, 0x110000},
101 {1, 0x0170000, 0x0172000, 0x12e000},
102 {0, 0x0000000, 0x0000000, 0x000000},
103 {0, 0x0000000, 0x0000000, 0x000000},
104 {0, 0x0000000, 0x0000000, 0x000000},
105 {0, 0x0000000, 0x0000000, 0x000000},
106 {0, 0x0000000, 0x0000000, 0x000000},
107 {0, 0x0000000, 0x0000000, 0x000000},
108 {1, 0x01e0000, 0x01e0800, 0x122000},
109 {0, 0x0000000, 0x0000000, 0x000000} } },
110 {{{1, 0x0200000, 0x0210000, 0x180000} } },/* 2: MN */
111 {{{0, 0, 0, 0} } }, /* 3: */
112 {{{1, 0x0400000, 0x0401000, 0x169000} } },/* 4: P2NR1 */
113 {{{1, 0x0500000, 0x0510000, 0x140000} } },/* 5: SRE */
114 {{{1, 0x0600000, 0x0610000, 0x1c0000} } },/* 6: NIU */
115 {{{1, 0x0700000, 0x0704000, 0x1b8000} } },/* 7: QM */
116 {{{1, 0x0800000, 0x0802000, 0x170000}, /* 8: SQM0 */
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 {0, 0x0000000, 0x0000000, 0x000000},
127 {0, 0x0000000, 0x0000000, 0x000000},
128 {0, 0x0000000, 0x0000000, 0x000000},
129 {0, 0x0000000, 0x0000000, 0x000000},
130 {0, 0x0000000, 0x0000000, 0x000000},
131 {1, 0x08f0000, 0x08f2000, 0x172000} } },
132 {{{1, 0x0900000, 0x0902000, 0x174000}, /* 9: SQM1*/
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 {0, 0x0000000, 0x0000000, 0x000000},
143 {0, 0x0000000, 0x0000000, 0x000000},
144 {0, 0x0000000, 0x0000000, 0x000000},
145 {0, 0x0000000, 0x0000000, 0x000000},
146 {0, 0x0000000, 0x0000000, 0x000000},
147 {1, 0x09f0000, 0x09f2000, 0x176000} } },
148 {{{0, 0x0a00000, 0x0a02000, 0x178000}, /* 10: SQM2*/
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 {0, 0x0000000, 0x0000000, 0x000000},
159 {0, 0x0000000, 0x0000000, 0x000000},
160 {0, 0x0000000, 0x0000000, 0x000000},
161 {0, 0x0000000, 0x0000000, 0x000000},
162 {0, 0x0000000, 0x0000000, 0x000000},
163 {1, 0x0af0000, 0x0af2000, 0x17a000} } },
164 {{{0, 0x0b00000, 0x0b02000, 0x17c000}, /* 11: SQM3*/
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 {0, 0x0000000, 0x0000000, 0x000000},
175 {0, 0x0000000, 0x0000000, 0x000000},
176 {0, 0x0000000, 0x0000000, 0x000000},
177 {0, 0x0000000, 0x0000000, 0x000000},
178 {0, 0x0000000, 0x0000000, 0x000000},
179 {1, 0x0bf0000, 0x0bf2000, 0x17e000} } },
180 {{{1, 0x0c00000, 0x0c04000, 0x1d4000} } },/* 12: I2Q */
181 {{{1, 0x0d00000, 0x0d04000, 0x1a4000} } },/* 13: TMR */
182 {{{1, 0x0e00000, 0x0e04000, 0x1a0000} } },/* 14: ROMUSB */
183 {{{1, 0x0f00000, 0x0f01000, 0x164000} } },/* 15: PEG4 */
184 {{{0, 0x1000000, 0x1004000, 0x1a8000} } },/* 16: XDMA */
185 {{{1, 0x1100000, 0x1101000, 0x160000} } },/* 17: PEG0 */
186 {{{1, 0x1200000, 0x1201000, 0x161000} } },/* 18: PEG1 */
187 {{{1, 0x1300000, 0x1301000, 0x162000} } },/* 19: PEG2 */
188 {{{1, 0x1400000, 0x1401000, 0x163000} } },/* 20: PEG3 */
189 {{{1, 0x1500000, 0x1501000, 0x165000} } },/* 21: P2ND */
190 {{{1, 0x1600000, 0x1601000, 0x166000} } },/* 22: P2NI */
191 {{{0, 0, 0, 0} } }, /* 23: */
192 {{{0, 0, 0, 0} } }, /* 24: */
193 {{{0, 0, 0, 0} } }, /* 25: */
194 {{{0, 0, 0, 0} } }, /* 26: */
195 {{{0, 0, 0, 0} } }, /* 27: */
196 {{{0, 0, 0, 0} } }, /* 28: */
197 {{{1, 0x1d00000, 0x1d10000, 0x190000} } },/* 29: MS */
198 {{{1, 0x1e00000, 0x1e01000, 0x16a000} } },/* 30: P2NR2 */
199 {{{1, 0x1f00000, 0x1f10000, 0x150000} } },/* 31: EPG */
200 {{{0} } }, /* 32: PCI */
201 {{{1, 0x2100000, 0x2102000, 0x120000}, /* 33: PCIE */
202 {1, 0x2110000, 0x2120000, 0x130000},
203 {1, 0x2120000, 0x2122000, 0x124000},
204 {1, 0x2130000, 0x2132000, 0x126000},
205 {1, 0x2140000, 0x2142000, 0x128000},
206 {1, 0x2150000, 0x2152000, 0x12a000},
207 {1, 0x2160000, 0x2170000, 0x110000},
208 {1, 0x2170000, 0x2172000, 0x12e000},
209 {0, 0x0000000, 0x0000000, 0x000000},
210 {0, 0x0000000, 0x0000000, 0x000000},
211 {0, 0x0000000, 0x0000000, 0x000000},
212 {0, 0x0000000, 0x0000000, 0x000000},
213 {0, 0x0000000, 0x0000000, 0x000000},
214 {0, 0x0000000, 0x0000000, 0x000000},
215 {0, 0x0000000, 0x0000000, 0x000000},
216 {0, 0x0000000, 0x0000000, 0x000000} } },
217 {{{1, 0x2200000, 0x2204000, 0x1b0000} } },/* 34: CAM */
223 {{{1, 0x2800000, 0x2804000, 0x1a4000} } },/* 40: TMR */
224 {{{1, 0x2900000, 0x2901000, 0x16b000} } },/* 41: P2NR3 */
225 {{{1, 0x2a00000, 0x2a00400, 0x1ac400} } },/* 42: RPMX1 */
226 {{{1, 0x2b00000, 0x2b00400, 0x1ac800} } },/* 43: RPMX2 */
227 {{{1, 0x2c00000, 0x2c00400, 0x1acc00} } },/* 44: RPMX3 */
228 {{{1, 0x2d00000, 0x2d00400, 0x1ad000} } },/* 45: RPMX4 */
229 {{{1, 0x2e00000, 0x2e00400, 0x1ad400} } },/* 46: RPMX5 */
230 {{{1, 0x2f00000, 0x2f00400, 0x1ad800} } },/* 47: RPMX6 */
231 {{{1, 0x3000000, 0x3000400, 0x1adc00} } },/* 48: RPMX7 */
232 {{{0, 0x3100000, 0x3104000, 0x1a8000} } },/* 49: XDMA */
233 {{{1, 0x3200000, 0x3204000, 0x1d4000} } },/* 50: I2Q */
234 {{{1, 0x3300000, 0x3304000, 0x1a0000} } },/* 51: ROMUSB */
236 {{{1, 0x3500000, 0x3500400, 0x1ac000} } },/* 53: RPMX0 */
237 {{{1, 0x3600000, 0x3600400, 0x1ae000} } },/* 54: RPMX8 */
238 {{{1, 0x3700000, 0x3700400, 0x1ae400} } },/* 55: RPMX9 */
239 {{{1, 0x3800000, 0x3804000, 0x1d0000} } },/* 56: OCM0 */
240 {{{1, 0x3900000, 0x3904000, 0x1b4000} } },/* 57: CRYPTO */
241 {{{1, 0x3a00000, 0x3a04000, 0x1d8000} } },/* 58: SMB */
242 {{{0} } }, /* 59: I2C0 */
243 {{{0} } }, /* 60: I2C1 */
244 {{{1, 0x3d00000, 0x3d04000, 0x1d8000} } },/* 61: LPC */
245 {{{1, 0x3e00000, 0x3e01000, 0x167000} } },/* 62: P2NC */
246 {{{1, 0x3f00000, 0x3f01000, 0x168000} } } /* 63: P2NR0 */
250 * top 12 bits of crb internal address (hub, agent)
252 static unsigned crb_hub_agt[64] =
255 NETXEN_HW_CRB_HUB_AGT_ADR_PS,
256 NETXEN_HW_CRB_HUB_AGT_ADR_MN,
257 NETXEN_HW_CRB_HUB_AGT_ADR_MS,
259 NETXEN_HW_CRB_HUB_AGT_ADR_SRE,
260 NETXEN_HW_CRB_HUB_AGT_ADR_NIU,
261 NETXEN_HW_CRB_HUB_AGT_ADR_QMN,
262 NETXEN_HW_CRB_HUB_AGT_ADR_SQN0,
263 NETXEN_HW_CRB_HUB_AGT_ADR_SQN1,
264 NETXEN_HW_CRB_HUB_AGT_ADR_SQN2,
265 NETXEN_HW_CRB_HUB_AGT_ADR_SQN3,
266 NETXEN_HW_CRB_HUB_AGT_ADR_I2Q,
267 NETXEN_HW_CRB_HUB_AGT_ADR_TIMR,
268 NETXEN_HW_CRB_HUB_AGT_ADR_ROMUSB,
269 NETXEN_HW_CRB_HUB_AGT_ADR_PGN4,
270 NETXEN_HW_CRB_HUB_AGT_ADR_XDMA,
271 NETXEN_HW_CRB_HUB_AGT_ADR_PGN0,
272 NETXEN_HW_CRB_HUB_AGT_ADR_PGN1,
273 NETXEN_HW_CRB_HUB_AGT_ADR_PGN2,
274 NETXEN_HW_CRB_HUB_AGT_ADR_PGN3,
275 NETXEN_HW_CRB_HUB_AGT_ADR_PGND,
276 NETXEN_HW_CRB_HUB_AGT_ADR_PGNI,
277 NETXEN_HW_CRB_HUB_AGT_ADR_PGS0,
278 NETXEN_HW_CRB_HUB_AGT_ADR_PGS1,
279 NETXEN_HW_CRB_HUB_AGT_ADR_PGS2,
280 NETXEN_HW_CRB_HUB_AGT_ADR_PGS3,
282 NETXEN_HW_CRB_HUB_AGT_ADR_PGSI,
283 NETXEN_HW_CRB_HUB_AGT_ADR_SN,
285 NETXEN_HW_CRB_HUB_AGT_ADR_EG,
287 NETXEN_HW_CRB_HUB_AGT_ADR_PS,
288 NETXEN_HW_CRB_HUB_AGT_ADR_CAM,
294 NETXEN_HW_CRB_HUB_AGT_ADR_TIMR,
296 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX1,
297 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX2,
298 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX3,
299 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX4,
300 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX5,
301 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX6,
302 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX7,
303 NETXEN_HW_CRB_HUB_AGT_ADR_XDMA,
304 NETXEN_HW_CRB_HUB_AGT_ADR_I2Q,
305 NETXEN_HW_CRB_HUB_AGT_ADR_ROMUSB,
307 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX0,
308 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX8,
309 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX9,
310 NETXEN_HW_CRB_HUB_AGT_ADR_OCM0,
312 NETXEN_HW_CRB_HUB_AGT_ADR_SMB,
313 NETXEN_HW_CRB_HUB_AGT_ADR_I2C0,
314 NETXEN_HW_CRB_HUB_AGT_ADR_I2C1,
316 NETXEN_HW_CRB_HUB_AGT_ADR_PGNC,
320 /* PCI Windowing for DDR regions. */
322 #define NETXEN_WINDOW_ONE 0x2000000 /*CRB Window: bit 25 of CRB address */
324 #define NETXEN_UNICAST_ADDR(port, index) \
325 (NETXEN_UNICAST_ADDR_BASE+(port*32)+(index*8))
326 #define NETXEN_MCAST_ADDR(port, index) \
327 (NETXEN_MULTICAST_ADDR_BASE+(port*0x80)+(index*8))
328 #define MAC_HI(addr) \
329 ((addr[2] << 16) | (addr[1] << 8) | (addr[0]))
330 #define MAC_LO(addr) \
331 ((addr[5] << 16) | (addr[4] << 8) | (addr[3]))
334 netxen_nic_enable_mcast_filter(struct netxen_adapter *adapter)
337 u16 port = adapter->physical_port;
338 u8 *addr = adapter->netdev->dev_addr;
340 if (adapter->mc_enabled)
343 val = NXRD32(adapter, NETXEN_MAC_ADDR_CNTL_REG);
344 val |= (1UL << (28+port));
345 NXWR32(adapter, NETXEN_MAC_ADDR_CNTL_REG, val);
347 /* add broadcast addr to filter */
349 NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0), val);
350 NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0)+4, val);
352 /* add station addr to filter */
354 NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1), val);
356 NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1)+4, val);
358 adapter->mc_enabled = 1;
363 netxen_nic_disable_mcast_filter(struct netxen_adapter *adapter)
366 u16 port = adapter->physical_port;
367 u8 *addr = adapter->netdev->dev_addr;
369 if (!adapter->mc_enabled)
372 val = NXRD32(adapter, NETXEN_MAC_ADDR_CNTL_REG);
373 val &= ~(1UL << (28+port));
374 NXWR32(adapter, NETXEN_MAC_ADDR_CNTL_REG, val);
377 NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0), val);
379 NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0)+4, val);
381 NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1), 0);
382 NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1)+4, 0);
384 adapter->mc_enabled = 0;
389 netxen_nic_set_mcast_addr(struct netxen_adapter *adapter,
393 u16 port = adapter->physical_port;
398 NXWR32(adapter, NETXEN_MCAST_ADDR(port, index), hi);
399 NXWR32(adapter, NETXEN_MCAST_ADDR(port, index)+4, lo);
404 void netxen_p2_nic_set_multi(struct net_device *netdev)
406 struct netxen_adapter *adapter = netdev_priv(netdev);
407 struct dev_mc_list *mc_ptr;
411 memset(null_addr, 0, 6);
413 if (netdev->flags & IFF_PROMISC) {
415 adapter->set_promisc(adapter,
416 NETXEN_NIU_PROMISC_MODE);
418 /* Full promiscuous mode */
419 netxen_nic_disable_mcast_filter(adapter);
424 if (netdev->mc_count == 0) {
425 adapter->set_promisc(adapter,
426 NETXEN_NIU_NON_PROMISC_MODE);
427 netxen_nic_disable_mcast_filter(adapter);
431 adapter->set_promisc(adapter, NETXEN_NIU_ALLMULTI_MODE);
432 if (netdev->flags & IFF_ALLMULTI ||
433 netdev->mc_count > adapter->max_mc_count) {
434 netxen_nic_disable_mcast_filter(adapter);
438 netxen_nic_enable_mcast_filter(adapter);
440 for (mc_ptr = netdev->mc_list; mc_ptr; mc_ptr = mc_ptr->next, index++)
441 netxen_nic_set_mcast_addr(adapter, index, mc_ptr->dmi_addr);
443 if (index != netdev->mc_count)
444 printk(KERN_WARNING "%s: %s multicast address count mismatch\n",
445 netxen_nic_driver_name, netdev->name);
447 /* Clear out remaining addresses */
448 for (; index < adapter->max_mc_count; index++)
449 netxen_nic_set_mcast_addr(adapter, index, null_addr);
453 netxen_send_cmd_descs(struct netxen_adapter *adapter,
454 struct cmd_desc_type0 *cmd_desc_arr, int nr_desc)
456 u32 i, producer, consumer;
457 struct netxen_cmd_buffer *pbuf;
458 struct cmd_desc_type0 *cmd_desc;
459 struct nx_host_tx_ring *tx_ring;
463 tx_ring = adapter->tx_ring;
464 netif_tx_lock_bh(adapter->netdev);
466 producer = tx_ring->producer;
467 consumer = tx_ring->sw_consumer;
469 if (nr_desc >= find_diff_among(producer, consumer, tx_ring->num_desc)) {
470 netif_tx_unlock_bh(adapter->netdev);
475 cmd_desc = &cmd_desc_arr[i];
477 pbuf = &tx_ring->cmd_buf_arr[producer];
479 pbuf->frag_count = 0;
481 memcpy(&tx_ring->desc_head[producer],
482 &cmd_desc_arr[i], sizeof(struct cmd_desc_type0));
484 producer = get_next_index(producer, tx_ring->num_desc);
487 } while (i != nr_desc);
489 tx_ring->producer = producer;
491 netxen_nic_update_cmd_producer(adapter, tx_ring);
493 netif_tx_unlock_bh(adapter->netdev);
499 nx_p3_sre_macaddr_change(struct netxen_adapter *adapter, u8 *addr, unsigned op)
502 nx_mac_req_t *mac_req;
505 memset(&req, 0, sizeof(nx_nic_req_t));
506 req.qhdr = cpu_to_le64(NX_NIC_REQUEST << 23);
508 word = NX_MAC_EVENT | ((u64)adapter->portnum << 16);
509 req.req_hdr = cpu_to_le64(word);
511 mac_req = (nx_mac_req_t *)&req.words[0];
513 memcpy(mac_req->mac_addr, addr, 6);
515 return netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1);
518 static int nx_p3_nic_add_mac(struct netxen_adapter *adapter,
519 u8 *addr, struct list_head *del_list)
521 struct list_head *head;
524 /* look up if already exists */
525 list_for_each(head, del_list) {
526 cur = list_entry(head, nx_mac_list_t, list);
528 if (memcmp(addr, cur->mac_addr, ETH_ALEN) == 0) {
529 list_move_tail(head, &adapter->mac_list);
534 cur = kzalloc(sizeof(nx_mac_list_t), GFP_ATOMIC);
536 printk(KERN_ERR "%s: failed to add mac address filter\n",
537 adapter->netdev->name);
540 memcpy(cur->mac_addr, addr, ETH_ALEN);
541 list_add_tail(&cur->list, &adapter->mac_list);
542 return nx_p3_sre_macaddr_change(adapter,
543 cur->mac_addr, NETXEN_MAC_ADD);
546 void netxen_p3_nic_set_multi(struct net_device *netdev)
548 struct netxen_adapter *adapter = netdev_priv(netdev);
549 struct dev_mc_list *mc_ptr;
550 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
551 u32 mode = VPORT_MISS_MODE_DROP;
553 struct list_head *head;
556 list_splice_tail_init(&adapter->mac_list, &del_list);
558 nx_p3_nic_add_mac(adapter, netdev->dev_addr, &del_list);
559 nx_p3_nic_add_mac(adapter, bcast_addr, &del_list);
561 if (netdev->flags & IFF_PROMISC) {
562 mode = VPORT_MISS_MODE_ACCEPT_ALL;
566 if ((netdev->flags & IFF_ALLMULTI) ||
567 (netdev->mc_count > adapter->max_mc_count)) {
568 mode = VPORT_MISS_MODE_ACCEPT_MULTI;
572 if (netdev->mc_count > 0) {
573 for (mc_ptr = netdev->mc_list; mc_ptr;
574 mc_ptr = mc_ptr->next) {
575 nx_p3_nic_add_mac(adapter, mc_ptr->dmi_addr, &del_list);
580 adapter->set_promisc(adapter, mode);
582 while (!list_empty(head)) {
583 cur = list_entry(head->next, nx_mac_list_t, list);
585 nx_p3_sre_macaddr_change(adapter,
586 cur->mac_addr, NETXEN_MAC_DEL);
587 list_del(&cur->list);
592 int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32 mode)
597 memset(&req, 0, sizeof(nx_nic_req_t));
599 req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23);
601 word = NX_NIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE |
602 ((u64)adapter->portnum << 16);
603 req.req_hdr = cpu_to_le64(word);
605 req.words[0] = cpu_to_le64(mode);
607 return netxen_send_cmd_descs(adapter,
608 (struct cmd_desc_type0 *)&req, 1);
611 void netxen_p3_free_mac_list(struct netxen_adapter *adapter)
614 struct list_head *head = &adapter->mac_list;
616 while (!list_empty(head)) {
617 cur = list_entry(head->next, nx_mac_list_t, list);
618 nx_p3_sre_macaddr_change(adapter,
619 cur->mac_addr, NETXEN_MAC_DEL);
620 list_del(&cur->list);
625 int netxen_p3_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr)
627 /* assuming caller has already copied new addr to netdev */
628 netxen_p3_nic_set_multi(adapter->netdev);
632 #define NETXEN_CONFIG_INTR_COALESCE 3
635 * Send the interrupt coalescing parameter set by ethtool to the card.
637 int netxen_config_intr_coalesce(struct netxen_adapter *adapter)
643 memset(&req, 0, sizeof(nx_nic_req_t));
645 req.qhdr = cpu_to_le64(NX_NIC_REQUEST << 23);
647 word = NETXEN_CONFIG_INTR_COALESCE | ((u64)adapter->portnum << 16);
648 req.req_hdr = cpu_to_le64(word);
650 memcpy(&req.words[0], &adapter->coal, sizeof(adapter->coal));
652 rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1);
654 printk(KERN_ERR "ERROR. Could not send "
655 "interrupt coalescing parameters\n");
661 #define RSS_HASHTYPE_IP_TCP 0x3
663 int netxen_config_rss(struct netxen_adapter *adapter, int enable)
669 u64 key[] = { 0xbeac01fa6a42b73bULL, 0x8030f20c77cb2da3ULL,
670 0xae7b30b4d0ca2bcbULL, 0x43a38fb04167253dULL,
671 0x255b0ec26d5a56daULL };
674 memset(&req, 0, sizeof(nx_nic_req_t));
675 req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23);
677 word = NX_NIC_H2C_OPCODE_CONFIG_RSS | ((u64)adapter->portnum << 16);
678 req.req_hdr = cpu_to_le64(word);
682 * bits 3-0: hash_method
683 * 5-4: hash_type_ipv4
684 * 7-6: hash_type_ipv6
686 * 9: use indirection table
688 * 63-48: indirection table mask
690 word = ((u64)(RSS_HASHTYPE_IP_TCP & 0x3) << 4) |
691 ((u64)(RSS_HASHTYPE_IP_TCP & 0x3) << 6) |
692 ((u64)(enable & 0x1) << 8) |
694 req.words[0] = cpu_to_le64(word);
695 for (i = 0; i < 5; i++)
696 req.words[i+1] = cpu_to_le64(key[i]);
699 rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1);
701 printk(KERN_ERR "%s: could not configure RSS\n",
702 adapter->netdev->name);
708 int netxen_linkevent_request(struct netxen_adapter *adapter, int enable)
714 memset(&req, 0, sizeof(nx_nic_req_t));
715 req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23);
717 word = NX_NIC_H2C_OPCODE_GET_LINKEVENT | ((u64)adapter->portnum << 16);
718 req.req_hdr = cpu_to_le64(word);
719 req.words[0] = cpu_to_le64(enable | (enable << 8));
721 rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1);
723 printk(KERN_ERR "%s: could not configure link notification\n",
724 adapter->netdev->name);
731 * netxen_nic_change_mtu - Change the Maximum Transfer Unit
732 * @returns 0 on success, negative on failure
735 #define MTU_FUDGE_FACTOR 100
737 int netxen_nic_change_mtu(struct net_device *netdev, int mtu)
739 struct netxen_adapter *adapter = netdev_priv(netdev);
743 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
744 max_mtu = P3_MAX_MTU;
746 max_mtu = P2_MAX_MTU;
749 printk(KERN_ERR "%s: mtu > %d bytes unsupported\n",
750 netdev->name, max_mtu);
754 if (adapter->set_mtu)
755 rc = adapter->set_mtu(adapter, mtu);
763 static int netxen_get_flash_block(struct netxen_adapter *adapter, int base,
764 int size, __le32 * buf)
771 for (i = 0; i < size / sizeof(u32); i++) {
772 if (netxen_rom_fast_read(adapter, addr, &v) == -1)
774 *ptr32 = cpu_to_le32(v);
778 if ((char *)buf + size > (char *)ptr32) {
780 if (netxen_rom_fast_read(adapter, addr, &v) == -1)
782 local = cpu_to_le32(v);
783 memcpy(ptr32, &local, (char *)buf + size - (char *)ptr32);
789 int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, __le64 *mac)
791 __le32 *pmac = (__le32 *) mac;
794 offset = NETXEN_USER_START +
795 offsetof(struct netxen_new_user_info, mac_addr) +
796 adapter->portnum * sizeof(u64);
798 if (netxen_get_flash_block(adapter, offset, sizeof(u64), pmac) == -1)
801 if (*mac == cpu_to_le64(~0ULL)) {
803 offset = NETXEN_USER_START_OLD +
804 offsetof(struct netxen_user_old_info, mac_addr) +
805 adapter->portnum * sizeof(u64);
807 if (netxen_get_flash_block(adapter,
808 offset, sizeof(u64), pmac) == -1)
811 if (*mac == cpu_to_le64(~0ULL))
817 int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, __le64 *mac)
819 uint32_t crbaddr, mac_hi, mac_lo;
820 int pci_func = adapter->ahw.pci_func;
822 crbaddr = CRB_MAC_BLOCK_START +
823 (4 * ((pci_func/2) * 3)) + (4 * (pci_func & 1));
825 mac_lo = NXRD32(adapter, crbaddr);
826 mac_hi = NXRD32(adapter, crbaddr+4);
829 *mac = le64_to_cpu((mac_lo >> 16) | ((u64)mac_hi << 16));
831 *mac = le64_to_cpu((u64)mac_lo | ((u64)mac_hi << 32));
836 #define CRB_WIN_LOCK_TIMEOUT 100000000
838 static int crb_win_lock(struct netxen_adapter *adapter)
840 int done = 0, timeout = 0;
843 /* acquire semaphore3 from PCI HW block */
844 done = NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM7_LOCK));
847 if (timeout >= CRB_WIN_LOCK_TIMEOUT)
852 NXWR32(adapter, NETXEN_CRB_WIN_LOCK_ID, adapter->portnum);
856 static void crb_win_unlock(struct netxen_adapter *adapter)
860 val = NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM7_UNLOCK));
864 * Changes the CRB window to the specified window.
867 netxen_nic_pci_change_crbwindow_128M(struct netxen_adapter *adapter, u32 wndw)
869 void __iomem *offset;
872 uint8_t func = adapter->ahw.pci_func;
874 if (adapter->curr_window == wndw)
877 * Move the CRB window.
878 * We need to write to the "direct access" region of PCI
879 * to avoid a race condition where the window register has
880 * not been successfully written across CRB before the target
881 * register address is received by PCI. The direct region bypasses
884 offset = PCI_OFFSET_SECOND_RANGE(adapter,
885 NETXEN_PCIX_PH_REG(PCIE_CRB_WINDOW_REG(func)));
888 wndw = NETXEN_WINDOW_ONE;
890 writel(wndw, offset);
892 /* MUST make sure window is set before we forge on... */
893 while ((tmp = readl(offset)) != wndw) {
894 printk(KERN_WARNING "%s: %s WARNING: CRB window value not "
895 "registered properly: 0x%08x.\n",
896 netxen_nic_driver_name, __func__, tmp);
903 if (wndw == NETXEN_WINDOW_ONE)
904 adapter->curr_window = 1;
906 adapter->curr_window = 0;
910 * Return -1 if off is not valid,
911 * 1 if window access is needed. 'off' is set to offset from
912 * CRB space in 128M pci map
913 * 0 if no window access is needed. 'off' is set to 2M addr
914 * In: 'off' is offset from base in 128M pci map
917 netxen_nic_pci_get_crb_addr_2M(struct netxen_adapter *adapter, ulong *off)
919 crb_128M_2M_sub_block_map_t *m;
922 if (*off >= NETXEN_CRB_MAX)
925 if (*off >= NETXEN_PCI_CAMQM && (*off < NETXEN_PCI_CAMQM_2M_END)) {
926 *off = (*off - NETXEN_PCI_CAMQM) + NETXEN_PCI_CAMQM_2M_BASE +
927 (ulong)adapter->ahw.pci_base0;
931 if (*off < NETXEN_PCI_CRBSPACE)
934 *off -= NETXEN_PCI_CRBSPACE;
939 m = &crb_128M_2M_map[CRB_BLK(*off)].sub_block[CRB_SUBBLK(*off)];
941 if (m->valid && (m->start_128M <= *off) && (m->end_128M > *off)) {
942 *off = *off + m->start_2M - m->start_128M +
943 (ulong)adapter->ahw.pci_base0;
948 * Not in direct map, use crb window
954 * In: 'off' is offset from CRB space in 128M pci map
955 * Out: 'off' is 2M pci map addr
956 * side effect: lock crb window
959 netxen_nic_pci_set_crbwindow_2M(struct netxen_adapter *adapter, ulong *off)
963 adapter->crb_win = CRB_HI(*off);
964 writel(adapter->crb_win, (adapter->ahw.pci_base0 + CRB_WINDOW_2M));
966 * Read back value to make sure write has gone through before trying
969 win_read = readl(adapter->ahw.pci_base0 + CRB_WINDOW_2M);
970 if (win_read != adapter->crb_win) {
971 printk(KERN_ERR "%s: Written crbwin (0x%x) != "
972 "Read crbwin (0x%x), off=0x%lx\n",
973 __func__, adapter->crb_win, win_read, *off);
975 *off = (*off & MASK(16)) + CRB_INDIRECT_2M +
976 (ulong)adapter->ahw.pci_base0;
980 netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, ulong off, u32 data)
984 if (ADDR_IN_WINDOW1(off)) {
985 addr = NETXEN_CRB_NORMALIZE(adapter, off);
986 } else { /* Window 0 */
987 addr = pci_base_offset(adapter, off);
988 netxen_nic_pci_change_crbwindow_128M(adapter, 0);
992 netxen_nic_pci_change_crbwindow_128M(adapter, 1);
998 if (!ADDR_IN_WINDOW1(off))
999 netxen_nic_pci_change_crbwindow_128M(adapter, 1);
1005 netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off)
1010 if (ADDR_IN_WINDOW1(off)) { /* Window 1 */
1011 addr = NETXEN_CRB_NORMALIZE(adapter, off);
1012 } else { /* Window 0 */
1013 addr = pci_base_offset(adapter, off);
1014 netxen_nic_pci_change_crbwindow_128M(adapter, 0);
1018 netxen_nic_pci_change_crbwindow_128M(adapter, 1);
1024 if (!ADDR_IN_WINDOW1(off))
1025 netxen_nic_pci_change_crbwindow_128M(adapter, 1);
1031 netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter, ulong off, u32 data)
1033 unsigned long flags = 0;
1036 rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off);
1039 printk(KERN_ERR "%s: invalid offset: 0x%016lx\n",
1046 write_lock_irqsave(&adapter->adapter_lock, flags);
1047 crb_win_lock(adapter);
1048 netxen_nic_pci_set_crbwindow_2M(adapter, &off);
1049 writel(data, (void __iomem *)off);
1050 crb_win_unlock(adapter);
1051 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1053 writel(data, (void __iomem *)off);
1060 netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, ulong off)
1062 unsigned long flags = 0;
1066 rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off);
1069 printk(KERN_ERR "%s: invalid offset: 0x%016lx\n",
1076 write_lock_irqsave(&adapter->adapter_lock, flags);
1077 crb_win_lock(adapter);
1078 netxen_nic_pci_set_crbwindow_2M(adapter, &off);
1079 data = readl((void __iomem *)off);
1080 crb_win_unlock(adapter);
1081 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1083 data = readl((void __iomem *)off);
1089 * check memory access boundary.
1090 * used by test agent. support ddr access only for now
1092 static unsigned long
1093 netxen_nic_pci_mem_bound_check(struct netxen_adapter *adapter,
1094 unsigned long long addr, int size)
1096 if (!ADDR_IN_RANGE(addr,
1097 NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX) ||
1098 !ADDR_IN_RANGE(addr+size-1,
1099 NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX) ||
1100 ((size != 1) && (size != 2) && (size != 4) && (size != 8))) {
1107 static int netxen_pci_set_window_warning_count;
1110 netxen_nic_pci_set_window_128M(struct netxen_adapter *adapter,
1111 unsigned long long addr)
1113 void __iomem *offset;
1115 unsigned long long qdr_max;
1116 uint8_t func = adapter->ahw.pci_func;
1118 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
1119 qdr_max = NETXEN_ADDR_QDR_NET_MAX_P2;
1121 qdr_max = NETXEN_ADDR_QDR_NET_MAX_P3;
1124 if (ADDR_IN_RANGE(addr, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) {
1125 /* DDR network side */
1126 addr -= NETXEN_ADDR_DDR_NET;
1127 window = (addr >> 25) & 0x3ff;
1128 if (adapter->ahw.ddr_mn_window != window) {
1129 adapter->ahw.ddr_mn_window = window;
1130 offset = PCI_OFFSET_SECOND_RANGE(adapter,
1131 NETXEN_PCIX_PH_REG(PCIE_MN_WINDOW_REG(func)));
1132 writel(window, offset);
1133 /* MUST make sure window is set before we forge on... */
1136 addr -= (window * NETXEN_WINDOW_ONE);
1137 addr += NETXEN_PCI_DDR_NET;
1138 } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) {
1139 addr -= NETXEN_ADDR_OCM0;
1140 addr += NETXEN_PCI_OCM0;
1141 } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_OCM1, NETXEN_ADDR_OCM1_MAX)) {
1142 addr -= NETXEN_ADDR_OCM1;
1143 addr += NETXEN_PCI_OCM1;
1144 } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_QDR_NET, qdr_max)) {
1145 /* QDR network side */
1146 addr -= NETXEN_ADDR_QDR_NET;
1147 window = (addr >> 22) & 0x3f;
1148 if (adapter->ahw.qdr_sn_window != window) {
1149 adapter->ahw.qdr_sn_window = window;
1150 offset = PCI_OFFSET_SECOND_RANGE(adapter,
1151 NETXEN_PCIX_PH_REG(PCIE_SN_WINDOW_REG(func)));
1152 writel((window << 22), offset);
1153 /* MUST make sure window is set before we forge on... */
1156 addr -= (window * 0x400000);
1157 addr += NETXEN_PCI_QDR_NET;
1160 * peg gdb frequently accesses memory that doesn't exist,
1161 * this limits the chit chat so debugging isn't slowed down.
1163 if ((netxen_pci_set_window_warning_count++ < 8)
1164 || (netxen_pci_set_window_warning_count % 64 == 0))
1165 printk("%s: Warning:netxen_nic_pci_set_window()"
1166 " Unknown address range!\n",
1167 netxen_nic_driver_name);
1174 * Note : only 32-bit writes!
1176 int netxen_nic_pci_write_immediate_128M(struct netxen_adapter *adapter,
1179 writel(data, (void __iomem *)(PCI_OFFSET_SECOND_RANGE(adapter, off)));
1183 u32 netxen_nic_pci_read_immediate_128M(struct netxen_adapter *adapter, u64 off)
1185 return readl((void __iomem *)(pci_base_offset(adapter, off)));
1189 netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
1190 unsigned long long addr)
1195 if (ADDR_IN_RANGE(addr, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) {
1196 /* DDR network side */
1197 window = MN_WIN(addr);
1198 adapter->ahw.ddr_mn_window = window;
1199 NXWR32(adapter, adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE,
1201 win_read = NXRD32(adapter,
1202 adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE);
1203 if ((win_read << 17) != window) {
1204 printk(KERN_INFO "Written MNwin (0x%x) != "
1205 "Read MNwin (0x%x)\n", window, win_read);
1207 addr = GET_MEM_OFFS_2M(addr) + NETXEN_PCI_DDR_NET;
1208 } else if (ADDR_IN_RANGE(addr,
1209 NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) {
1210 if ((addr & 0x00ff800) == 0xff800) {
1211 printk("%s: QM access not handled.\n", __func__);
1215 window = OCM_WIN(addr);
1216 adapter->ahw.ddr_mn_window = window;
1217 NXWR32(adapter, adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE,
1219 win_read = NXRD32(adapter,
1220 adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE);
1221 if ((win_read >> 7) != window) {
1222 printk(KERN_INFO "%s: Written OCMwin (0x%x) != "
1223 "Read OCMwin (0x%x)\n",
1224 __func__, window, win_read);
1226 addr = GET_MEM_OFFS_2M(addr) + NETXEN_PCI_OCM0_2M;
1228 } else if (ADDR_IN_RANGE(addr,
1229 NETXEN_ADDR_QDR_NET, NETXEN_ADDR_QDR_NET_MAX_P3)) {
1230 /* QDR network side */
1231 window = MS_WIN(addr);
1232 adapter->ahw.qdr_sn_window = window;
1233 NXWR32(adapter, adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE,
1235 win_read = NXRD32(adapter,
1236 adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE);
1237 if (win_read != window) {
1238 printk(KERN_INFO "%s: Written MSwin (0x%x) != "
1239 "Read MSwin (0x%x)\n",
1240 __func__, window, win_read);
1242 addr = GET_MEM_OFFS_2M(addr) + NETXEN_PCI_QDR_NET;
1246 * peg gdb frequently accesses memory that doesn't exist,
1247 * this limits the chit chat so debugging isn't slowed down.
1249 if ((netxen_pci_set_window_warning_count++ < 8)
1250 || (netxen_pci_set_window_warning_count%64 == 0)) {
1251 printk("%s: Warning:%s Unknown address range!\n",
1252 __func__, netxen_nic_driver_name);
1259 static int netxen_nic_pci_is_same_window(struct netxen_adapter *adapter,
1260 unsigned long long addr)
1263 unsigned long long qdr_max;
1265 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
1266 qdr_max = NETXEN_ADDR_QDR_NET_MAX_P2;
1268 qdr_max = NETXEN_ADDR_QDR_NET_MAX_P3;
1270 if (ADDR_IN_RANGE(addr,
1271 NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) {
1272 /* DDR network side */
1273 BUG(); /* MN access can not come here */
1274 } else if (ADDR_IN_RANGE(addr,
1275 NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) {
1277 } else if (ADDR_IN_RANGE(addr,
1278 NETXEN_ADDR_OCM1, NETXEN_ADDR_OCM1_MAX)) {
1280 } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_QDR_NET, qdr_max)) {
1281 /* QDR network side */
1282 window = ((addr - NETXEN_ADDR_QDR_NET) >> 22) & 0x3f;
1283 if (adapter->ahw.qdr_sn_window == window)
1290 static int netxen_nic_pci_mem_read_direct(struct netxen_adapter *adapter,
1291 u64 off, void *data, int size)
1293 unsigned long flags;
1294 void __iomem *addr, *mem_ptr = NULL;
1297 unsigned long mem_base;
1298 unsigned long mem_page;
1300 write_lock_irqsave(&adapter->adapter_lock, flags);
1303 * If attempting to access unknown address or straddle hw windows,
1306 start = adapter->pci_set_window(adapter, off);
1307 if ((start == -1UL) ||
1308 (netxen_nic_pci_is_same_window(adapter, off+size-1) == 0)) {
1309 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1310 printk(KERN_ERR "%s out of bound pci memory access. "
1311 "offset is 0x%llx\n", netxen_nic_driver_name,
1312 (unsigned long long)off);
1316 addr = pci_base_offset(adapter, start);
1318 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1319 mem_base = pci_resource_start(adapter->pdev, 0);
1320 mem_page = start & PAGE_MASK;
1321 /* Map two pages whenever user tries to access addresses in two
1324 if (mem_page != ((start + size - 1) & PAGE_MASK))
1325 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1327 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE);
1328 if (mem_ptr == NULL) {
1329 *(uint8_t *)data = 0;
1333 addr += start & (PAGE_SIZE - 1);
1334 write_lock_irqsave(&adapter->adapter_lock, flags);
1339 *(uint8_t *)data = readb(addr);
1342 *(uint16_t *)data = readw(addr);
1345 *(uint32_t *)data = readl(addr);
1348 *(uint64_t *)data = readq(addr);
1354 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1362 netxen_nic_pci_mem_write_direct(struct netxen_adapter *adapter, u64 off,
1363 void *data, int size)
1365 unsigned long flags;
1366 void __iomem *addr, *mem_ptr = NULL;
1369 unsigned long mem_base;
1370 unsigned long mem_page;
1372 write_lock_irqsave(&adapter->adapter_lock, flags);
1375 * If attempting to access unknown address or straddle hw windows,
1378 start = adapter->pci_set_window(adapter, off);
1379 if ((start == -1UL) ||
1380 (netxen_nic_pci_is_same_window(adapter, off+size-1) == 0)) {
1381 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1382 printk(KERN_ERR "%s out of bound pci memory access. "
1383 "offset is 0x%llx\n", netxen_nic_driver_name,
1384 (unsigned long long)off);
1388 addr = pci_base_offset(adapter, start);
1390 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1391 mem_base = pci_resource_start(adapter->pdev, 0);
1392 mem_page = start & PAGE_MASK;
1393 /* Map two pages whenever user tries to access addresses in two
1394 * consecutive pages.
1396 if (mem_page != ((start + size - 1) & PAGE_MASK))
1397 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE*2);
1399 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE);
1400 if (mem_ptr == NULL)
1403 addr += start & (PAGE_SIZE - 1);
1404 write_lock_irqsave(&adapter->adapter_lock, flags);
1409 writeb(*(uint8_t *)data, addr);
1412 writew(*(uint16_t *)data, addr);
1415 writel(*(uint32_t *)data, addr);
1418 writeq(*(uint64_t *)data, addr);
1424 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1430 #define MAX_CTL_CHECK 1000
1433 netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter,
1434 u64 off, void *data, int size)
1436 unsigned long flags;
1437 int i, j, ret = 0, loop, sz[2], off0;
1439 uint64_t off8, tmpw, word[2] = {0, 0};
1440 void __iomem *mem_crb;
1443 * If not MN, go check for MS or invalid.
1445 if (netxen_nic_pci_mem_bound_check(adapter, off, size) == 0)
1446 return netxen_nic_pci_mem_write_direct(adapter,
1449 off8 = off & 0xfffffff8;
1451 sz[0] = (size < (8 - off0)) ? size : (8 - off0);
1452 sz[1] = size - sz[0];
1453 loop = ((off0 + size - 1) >> 3) + 1;
1454 mem_crb = pci_base_offset(adapter, NETXEN_CRB_DDR_NET);
1456 if ((size != 8) || (off0 != 0)) {
1457 for (i = 0; i < loop; i++) {
1458 if (adapter->pci_mem_read(adapter,
1459 off8 + (i << 3), &word[i], 8))
1466 tmpw = *((uint8_t *)data);
1469 tmpw = *((uint16_t *)data);
1472 tmpw = *((uint32_t *)data);
1476 tmpw = *((uint64_t *)data);
1479 word[0] &= ~((~(~0ULL << (sz[0] * 8))) << (off0 * 8));
1480 word[0] |= tmpw << (off0 * 8);
1483 word[1] &= ~(~0ULL << (sz[1] * 8));
1484 word[1] |= tmpw >> (sz[0] * 8);
1487 write_lock_irqsave(&adapter->adapter_lock, flags);
1488 netxen_nic_pci_change_crbwindow_128M(adapter, 0);
1490 for (i = 0; i < loop; i++) {
1491 writel((uint32_t)(off8 + (i << 3)),
1492 (mem_crb+MIU_TEST_AGT_ADDR_LO));
1494 (mem_crb+MIU_TEST_AGT_ADDR_HI));
1495 writel(word[i] & 0xffffffff,
1496 (mem_crb+MIU_TEST_AGT_WRDATA_LO));
1497 writel((word[i] >> 32) & 0xffffffff,
1498 (mem_crb+MIU_TEST_AGT_WRDATA_HI));
1499 writel(MIU_TA_CTL_ENABLE|MIU_TA_CTL_WRITE,
1500 (mem_crb+MIU_TEST_AGT_CTRL));
1501 writel(MIU_TA_CTL_START|MIU_TA_CTL_ENABLE|MIU_TA_CTL_WRITE,
1502 (mem_crb+MIU_TEST_AGT_CTRL));
1504 for (j = 0; j < MAX_CTL_CHECK; j++) {
1506 (mem_crb+MIU_TEST_AGT_CTRL));
1507 if ((temp & MIU_TA_CTL_BUSY) == 0)
1511 if (j >= MAX_CTL_CHECK) {
1512 if (printk_ratelimit())
1513 dev_err(&adapter->pdev->dev,
1514 "failed to write through agent\n");
1520 netxen_nic_pci_change_crbwindow_128M(adapter, 1);
1521 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1526 netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter,
1527 u64 off, void *data, int size)
1529 unsigned long flags;
1530 int i, j = 0, k, start, end, loop, sz[2], off0[2];
1532 uint64_t off8, val, word[2] = {0, 0};
1533 void __iomem *mem_crb;
1537 * If not MN, go check for MS or invalid.
1539 if (netxen_nic_pci_mem_bound_check(adapter, off, size) == 0)
1540 return netxen_nic_pci_mem_read_direct(adapter, off, data, size);
1542 off8 = off & 0xfffffff8;
1543 off0[0] = off & 0x7;
1545 sz[0] = (size < (8 - off0[0])) ? size : (8 - off0[0]);
1546 sz[1] = size - sz[0];
1547 loop = ((off0[0] + size - 1) >> 3) + 1;
1548 mem_crb = pci_base_offset(adapter, NETXEN_CRB_DDR_NET);
1550 write_lock_irqsave(&adapter->adapter_lock, flags);
1551 netxen_nic_pci_change_crbwindow_128M(adapter, 0);
1553 for (i = 0; i < loop; i++) {
1554 writel((uint32_t)(off8 + (i << 3)),
1555 (mem_crb+MIU_TEST_AGT_ADDR_LO));
1557 (mem_crb+MIU_TEST_AGT_ADDR_HI));
1558 writel(MIU_TA_CTL_ENABLE,
1559 (mem_crb+MIU_TEST_AGT_CTRL));
1560 writel(MIU_TA_CTL_START|MIU_TA_CTL_ENABLE,
1561 (mem_crb+MIU_TEST_AGT_CTRL));
1563 for (j = 0; j < MAX_CTL_CHECK; j++) {
1565 (mem_crb+MIU_TEST_AGT_CTRL));
1566 if ((temp & MIU_TA_CTL_BUSY) == 0)
1570 if (j >= MAX_CTL_CHECK) {
1571 if (printk_ratelimit())
1572 dev_err(&adapter->pdev->dev,
1573 "failed to read through agent\n");
1577 start = off0[i] >> 2;
1578 end = (off0[i] + sz[i] - 1) >> 2;
1579 for (k = start; k <= end; k++) {
1580 word[i] |= ((uint64_t) readl(
1582 MIU_TEST_AGT_RDDATA(k))) << (32*k));
1586 netxen_nic_pci_change_crbwindow_128M(adapter, 1);
1587 write_unlock_irqrestore(&adapter->adapter_lock, flags);
1589 if (j >= MAX_CTL_CHECK)
1595 val = ((word[0] >> (off0[0] * 8)) & (~(~0ULL << (sz[0] * 8)))) |
1596 ((word[1] & (~(~0ULL << (sz[1] * 8)))) << (sz[0] * 8));
1601 *(uint8_t *)data = val;
1604 *(uint16_t *)data = val;
1607 *(uint32_t *)data = val;
1610 *(uint64_t *)data = val;
1617 netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter,
1618 u64 off, void *data, int size)
1620 int i, j, ret = 0, loop, sz[2], off0;
1622 uint64_t off8, mem_crb, tmpw, word[2] = {0, 0};
1625 * If not MN, go check for MS or invalid.
1627 if (off >= NETXEN_ADDR_QDR_NET && off <= NETXEN_ADDR_QDR_NET_MAX_P3)
1628 mem_crb = NETXEN_CRB_QDR_NET;
1630 mem_crb = NETXEN_CRB_DDR_NET;
1631 if (netxen_nic_pci_mem_bound_check(adapter, off, size) == 0)
1632 return netxen_nic_pci_mem_write_direct(adapter,
1636 off8 = off & 0xfffffff8;
1638 sz[0] = (size < (8 - off0)) ? size : (8 - off0);
1639 sz[1] = size - sz[0];
1640 loop = ((off0 + size - 1) >> 3) + 1;
1642 if ((size != 8) || (off0 != 0)) {
1643 for (i = 0; i < loop; i++) {
1644 if (adapter->pci_mem_read(adapter, off8 + (i << 3),
1652 tmpw = *((uint8_t *)data);
1655 tmpw = *((uint16_t *)data);
1658 tmpw = *((uint32_t *)data);
1662 tmpw = *((uint64_t *)data);
1666 word[0] &= ~((~(~0ULL << (sz[0] * 8))) << (off0 * 8));
1667 word[0] |= tmpw << (off0 * 8);
1670 word[1] &= ~(~0ULL << (sz[1] * 8));
1671 word[1] |= tmpw >> (sz[0] * 8);
1675 * don't lock here - write_wx gets the lock if each time
1676 * write_lock_irqsave(&adapter->adapter_lock, flags);
1677 * netxen_nic_pci_change_crbwindow_128M(adapter, 0);
1680 for (i = 0; i < loop; i++) {
1681 temp = off8 + (i << 3);
1682 NXWR32(adapter, mem_crb+MIU_TEST_AGT_ADDR_LO, temp);
1684 NXWR32(adapter, mem_crb+MIU_TEST_AGT_ADDR_HI, temp);
1685 temp = word[i] & 0xffffffff;
1686 NXWR32(adapter, mem_crb+MIU_TEST_AGT_WRDATA_LO, temp);
1687 temp = (word[i] >> 32) & 0xffffffff;
1688 NXWR32(adapter, mem_crb+MIU_TEST_AGT_WRDATA_HI, temp);
1689 temp = MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE;
1690 NXWR32(adapter, mem_crb+MIU_TEST_AGT_CTRL, temp);
1691 temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE;
1692 NXWR32(adapter, mem_crb+MIU_TEST_AGT_CTRL, temp);
1694 for (j = 0; j < MAX_CTL_CHECK; j++) {
1695 temp = NXRD32(adapter, mem_crb + MIU_TEST_AGT_CTRL);
1696 if ((temp & MIU_TA_CTL_BUSY) == 0)
1700 if (j >= MAX_CTL_CHECK) {
1701 if (printk_ratelimit())
1702 dev_err(&adapter->pdev->dev,
1703 "failed to write through agent\n");
1710 * netxen_nic_pci_change_crbwindow_128M(adapter, 1);
1711 * write_unlock_irqrestore(&adapter->adapter_lock, flags);
1717 netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
1718 u64 off, void *data, int size)
1720 int i, j = 0, k, start, end, loop, sz[2], off0[2];
1722 uint64_t off8, val, mem_crb, word[2] = {0, 0};
1725 * If not MN, go check for MS or invalid.
1728 if (off >= NETXEN_ADDR_QDR_NET && off <= NETXEN_ADDR_QDR_NET_MAX_P3)
1729 mem_crb = NETXEN_CRB_QDR_NET;
1731 mem_crb = NETXEN_CRB_DDR_NET;
1732 if (netxen_nic_pci_mem_bound_check(adapter, off, size) == 0)
1733 return netxen_nic_pci_mem_read_direct(adapter,
1737 off8 = off & 0xfffffff8;
1738 off0[0] = off & 0x7;
1740 sz[0] = (size < (8 - off0[0])) ? size : (8 - off0[0]);
1741 sz[1] = size - sz[0];
1742 loop = ((off0[0] + size - 1) >> 3) + 1;
1745 * don't lock here - write_wx gets the lock if each time
1746 * write_lock_irqsave(&adapter->adapter_lock, flags);
1747 * netxen_nic_pci_change_crbwindow_128M(adapter, 0);
1750 for (i = 0; i < loop; i++) {
1751 temp = off8 + (i << 3);
1752 NXWR32(adapter, mem_crb + MIU_TEST_AGT_ADDR_LO, temp);
1754 NXWR32(adapter, mem_crb + MIU_TEST_AGT_ADDR_HI, temp);
1755 temp = MIU_TA_CTL_ENABLE;
1756 NXWR32(adapter, mem_crb + MIU_TEST_AGT_CTRL, temp);
1757 temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE;
1758 NXWR32(adapter, mem_crb + MIU_TEST_AGT_CTRL, temp);
1760 for (j = 0; j < MAX_CTL_CHECK; j++) {
1761 temp = NXRD32(adapter, mem_crb + MIU_TEST_AGT_CTRL);
1762 if ((temp & MIU_TA_CTL_BUSY) == 0)
1766 if (j >= MAX_CTL_CHECK) {
1767 if (printk_ratelimit())
1768 dev_err(&adapter->pdev->dev,
1769 "failed to read through agent\n");
1773 start = off0[i] >> 2;
1774 end = (off0[i] + sz[i] - 1) >> 2;
1775 for (k = start; k <= end; k++) {
1776 temp = NXRD32(adapter,
1777 mem_crb + MIU_TEST_AGT_RDDATA(k));
1778 word[i] |= ((uint64_t)temp << (32 * k));
1783 * netxen_nic_pci_change_crbwindow_128M(adapter, 1);
1784 * write_unlock_irqrestore(&adapter->adapter_lock, flags);
1787 if (j >= MAX_CTL_CHECK)
1793 val = ((word[0] >> (off0[0] * 8)) & (~(~0ULL << (sz[0] * 8)))) |
1794 ((word[1] & (~(~0ULL << (sz[1] * 8)))) << (sz[0] * 8));
1799 *(uint8_t *)data = val;
1802 *(uint16_t *)data = val;
1805 *(uint32_t *)data = val;
1808 *(uint64_t *)data = val;
1815 * Note : only 32-bit writes!
1817 int netxen_nic_pci_write_immediate_2M(struct netxen_adapter *adapter,
1820 NXWR32(adapter, off, data);
1825 u32 netxen_nic_pci_read_immediate_2M(struct netxen_adapter *adapter, u64 off)
1827 return NXRD32(adapter, off);
1830 int netxen_nic_get_board_info(struct netxen_adapter *adapter)
1832 int offset, board_type, magic, header_version;
1833 struct pci_dev *pdev = adapter->pdev;
1835 offset = NETXEN_BRDCFG_START +
1836 offsetof(struct netxen_board_info, magic);
1837 if (netxen_rom_fast_read(adapter, offset, &magic))
1840 offset = NETXEN_BRDCFG_START +
1841 offsetof(struct netxen_board_info, header_version);
1842 if (netxen_rom_fast_read(adapter, offset, &header_version))
1845 if (magic != NETXEN_BDINFO_MAGIC ||
1846 header_version != NETXEN_BDINFO_VERSION) {
1848 "invalid board config, magic=%08x, version=%08x\n",
1849 magic, header_version);
1853 offset = NETXEN_BRDCFG_START +
1854 offsetof(struct netxen_board_info, board_type);
1855 if (netxen_rom_fast_read(adapter, offset, &board_type))
1858 adapter->ahw.board_type = board_type;
1860 if (board_type == NETXEN_BRDTYPE_P3_4_GB_MM) {
1861 u32 gpio = NXRD32(adapter, NETXEN_ROMUSB_GLB_PAD_GPIO_I);
1862 if ((gpio & 0x8000) == 0)
1863 board_type = NETXEN_BRDTYPE_P3_10G_TP;
1866 switch (board_type) {
1867 case NETXEN_BRDTYPE_P2_SB35_4G:
1868 adapter->ahw.port_type = NETXEN_NIC_GBE;
1870 case NETXEN_BRDTYPE_P2_SB31_10G:
1871 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
1872 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
1873 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
1874 case NETXEN_BRDTYPE_P3_HMEZ:
1875 case NETXEN_BRDTYPE_P3_XG_LOM:
1876 case NETXEN_BRDTYPE_P3_10G_CX4:
1877 case NETXEN_BRDTYPE_P3_10G_CX4_LP:
1878 case NETXEN_BRDTYPE_P3_IMEZ:
1879 case NETXEN_BRDTYPE_P3_10G_SFP_PLUS:
1880 case NETXEN_BRDTYPE_P3_10G_SFP_CT:
1881 case NETXEN_BRDTYPE_P3_10G_SFP_QT:
1882 case NETXEN_BRDTYPE_P3_10G_XFP:
1883 case NETXEN_BRDTYPE_P3_10000_BASE_T:
1884 adapter->ahw.port_type = NETXEN_NIC_XGBE;
1886 case NETXEN_BRDTYPE_P1_BD:
1887 case NETXEN_BRDTYPE_P1_SB:
1888 case NETXEN_BRDTYPE_P1_SMAX:
1889 case NETXEN_BRDTYPE_P1_SOCK:
1890 case NETXEN_BRDTYPE_P3_REF_QG:
1891 case NETXEN_BRDTYPE_P3_4_GB:
1892 case NETXEN_BRDTYPE_P3_4_GB_MM:
1893 adapter->ahw.port_type = NETXEN_NIC_GBE;
1895 case NETXEN_BRDTYPE_P3_10G_TP:
1896 adapter->ahw.port_type = (adapter->portnum < 2) ?
1897 NETXEN_NIC_XGBE : NETXEN_NIC_GBE;
1900 dev_err(&pdev->dev, "unknown board type %x\n", board_type);
1901 adapter->ahw.port_type = NETXEN_NIC_XGBE;
1908 /* NIU access sections */
1910 int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu)
1912 new_mtu += MTU_FUDGE_FACTOR;
1913 NXWR32(adapter, NETXEN_NIU_GB_MAX_FRAME_SIZE(adapter->physical_port),
1918 int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu)
1920 new_mtu += MTU_FUDGE_FACTOR;
1921 if (adapter->physical_port == 0)
1922 NXWR32(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE, new_mtu);
1924 NXWR32(adapter, NETXEN_NIU_XG1_MAX_FRAME_SIZE, new_mtu);
1928 void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
1934 if (!netif_carrier_ok(adapter->netdev)) {
1935 adapter->link_speed = 0;
1936 adapter->link_duplex = -1;
1937 adapter->link_autoneg = AUTONEG_ENABLE;
1941 if (adapter->ahw.port_type == NETXEN_NIC_GBE) {
1942 port_mode = NXRD32(adapter, NETXEN_PORT_MODE_ADDR);
1943 if (port_mode == NETXEN_PORT_MODE_802_3_AP) {
1944 adapter->link_speed = SPEED_1000;
1945 adapter->link_duplex = DUPLEX_FULL;
1946 adapter->link_autoneg = AUTONEG_DISABLE;
1950 if (adapter->phy_read
1951 && adapter->phy_read(adapter,
1952 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
1954 if (netxen_get_phy_link(status)) {
1955 switch (netxen_get_phy_speed(status)) {
1957 adapter->link_speed = SPEED_10;
1960 adapter->link_speed = SPEED_100;
1963 adapter->link_speed = SPEED_1000;
1966 adapter->link_speed = 0;
1969 switch (netxen_get_phy_duplex(status)) {
1971 adapter->link_duplex = DUPLEX_HALF;
1974 adapter->link_duplex = DUPLEX_FULL;
1977 adapter->link_duplex = -1;
1980 if (adapter->phy_read
1981 && adapter->phy_read(adapter,
1982 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
1984 adapter->link_autoneg = autoneg;
1989 adapter->link_speed = 0;
1990 adapter->link_duplex = -1;
1995 void netxen_nic_get_firmware_info(struct netxen_adapter *adapter)
1997 u32 fw_major, fw_minor, fw_build;
1998 char brd_name[NETXEN_MAX_SHORT_NAME];
1999 char serial_num[32];
2002 struct pci_dev *pdev = adapter->pdev;
2004 adapter->driver_mismatch = 0;
2006 ptr32 = (int *)&serial_num;
2007 addr = NETXEN_USER_START +
2008 offsetof(struct netxen_new_user_info, serial_num);
2009 for (i = 0; i < 8; i++) {
2010 if (netxen_rom_fast_read(adapter, addr, &val) == -1) {
2011 dev_err(&pdev->dev, "error reading board info\n");
2012 adapter->driver_mismatch = 1;
2015 ptr32[i] = cpu_to_le32(val);
2016 addr += sizeof(u32);
2019 fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR);
2020 fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR);
2021 fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB);
2023 adapter->fw_major = fw_major;
2024 adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build);
2026 if (adapter->portnum == 0) {
2027 get_brd_name_by_type(adapter->ahw.board_type, brd_name);
2029 printk(KERN_INFO "NetXen %s Board S/N %s Chip rev 0x%x\n",
2030 brd_name, serial_num, adapter->ahw.revision_id);
2033 if (adapter->fw_version < NETXEN_VERSION_CODE(3, 4, 216)) {
2034 adapter->driver_mismatch = 1;
2035 dev_warn(&pdev->dev, "firmware version %d.%d.%d unsupported\n",
2036 fw_major, fw_minor, fw_build);
2040 dev_info(&pdev->dev, "firmware version %d.%d.%d\n",
2041 fw_major, fw_minor, fw_build);
2043 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
2044 i = NXRD32(adapter, NETXEN_SRE_MISC);
2045 adapter->ahw.cut_through = (i & 0x8000) ? 1 : 0;
2046 dev_info(&pdev->dev, "firmware running in %s mode\n",
2047 adapter->ahw.cut_through ? "cut-through" : "legacy");
2052 netxen_nic_wol_supported(struct netxen_adapter *adapter)
2056 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
2059 wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG_NV);
2060 if (wol_cfg & (1UL << adapter->portnum)) {
2061 wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG);
2062 if (wol_cfg & (1 << adapter->portnum))