2 * Copyright (C) 2003 - 2009 NetXen, Inc.
3 * Copyright (C) 2009 - QLogic Corporation.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 * The full GNU General Public License is included in this distribution
22 * in the file called "COPYING".
26 #include <linux/slab.h>
27 #include "netxen_nic.h"
28 #include "netxen_nic_hw.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)
45 static void netxen_nic_io_write_128M(struct netxen_adapter
*adapter
,
46 void __iomem
*addr
, u32 data
);
47 static u32
netxen_nic_io_read_128M(struct netxen_adapter
*adapter
,
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 PCI_OFFSET_FIRST_RANGE(adapter, off) \
66 ((adapter)->ahw.pci_base0 + (off))
67 #define PCI_OFFSET_SECOND_RANGE(adapter, off) \
68 ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
69 #define PCI_OFFSET_THIRD_RANGE(adapter, off) \
70 ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
72 static void __iomem
*pci_base_offset(struct netxen_adapter
*adapter
,
75 if (ADDR_IN_RANGE(off
, FIRST_PAGE_GROUP_START
, FIRST_PAGE_GROUP_END
))
76 return PCI_OFFSET_FIRST_RANGE(adapter
, off
);
78 if (ADDR_IN_RANGE(off
, SECOND_PAGE_GROUP_START
, SECOND_PAGE_GROUP_END
))
79 return PCI_OFFSET_SECOND_RANGE(adapter
, off
);
81 if (ADDR_IN_RANGE(off
, THIRD_PAGE_GROUP_START
, THIRD_PAGE_GROUP_END
))
82 return PCI_OFFSET_THIRD_RANGE(adapter
, off
);
87 static crb_128M_2M_block_map_t
88 crb_128M_2M_map
[64] __cacheline_aligned_in_smp
= {
89 {{{0, 0, 0, 0} } }, /* 0: PCI */
90 {{{1, 0x0100000, 0x0102000, 0x120000}, /* 1: PCIE */
91 {1, 0x0110000, 0x0120000, 0x130000},
92 {1, 0x0120000, 0x0122000, 0x124000},
93 {1, 0x0130000, 0x0132000, 0x126000},
94 {1, 0x0140000, 0x0142000, 0x128000},
95 {1, 0x0150000, 0x0152000, 0x12a000},
96 {1, 0x0160000, 0x0170000, 0x110000},
97 {1, 0x0170000, 0x0172000, 0x12e000},
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 {0, 0x0000000, 0x0000000, 0x000000},
104 {1, 0x01e0000, 0x01e0800, 0x122000},
105 {0, 0x0000000, 0x0000000, 0x000000} } },
106 {{{1, 0x0200000, 0x0210000, 0x180000} } },/* 2: MN */
107 {{{0, 0, 0, 0} } }, /* 3: */
108 {{{1, 0x0400000, 0x0401000, 0x169000} } },/* 4: P2NR1 */
109 {{{1, 0x0500000, 0x0510000, 0x140000} } },/* 5: SRE */
110 {{{1, 0x0600000, 0x0610000, 0x1c0000} } },/* 6: NIU */
111 {{{1, 0x0700000, 0x0704000, 0x1b8000} } },/* 7: QM */
112 {{{1, 0x0800000, 0x0802000, 0x170000}, /* 8: SQM0 */
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 {0, 0x0000000, 0x0000000, 0x000000},
127 {1, 0x08f0000, 0x08f2000, 0x172000} } },
128 {{{1, 0x0900000, 0x0902000, 0x174000}, /* 9: SQM1*/
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 {0, 0x0000000, 0x0000000, 0x000000},
143 {1, 0x09f0000, 0x09f2000, 0x176000} } },
144 {{{0, 0x0a00000, 0x0a02000, 0x178000}, /* 10: SQM2*/
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 {0, 0x0000000, 0x0000000, 0x000000},
159 {1, 0x0af0000, 0x0af2000, 0x17a000} } },
160 {{{0, 0x0b00000, 0x0b02000, 0x17c000}, /* 11: SQM3*/
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 {0, 0x0000000, 0x0000000, 0x000000},
175 {1, 0x0bf0000, 0x0bf2000, 0x17e000} } },
176 {{{1, 0x0c00000, 0x0c04000, 0x1d4000} } },/* 12: I2Q */
177 {{{1, 0x0d00000, 0x0d04000, 0x1a4000} } },/* 13: TMR */
178 {{{1, 0x0e00000, 0x0e04000, 0x1a0000} } },/* 14: ROMUSB */
179 {{{1, 0x0f00000, 0x0f01000, 0x164000} } },/* 15: PEG4 */
180 {{{0, 0x1000000, 0x1004000, 0x1a8000} } },/* 16: XDMA */
181 {{{1, 0x1100000, 0x1101000, 0x160000} } },/* 17: PEG0 */
182 {{{1, 0x1200000, 0x1201000, 0x161000} } },/* 18: PEG1 */
183 {{{1, 0x1300000, 0x1301000, 0x162000} } },/* 19: PEG2 */
184 {{{1, 0x1400000, 0x1401000, 0x163000} } },/* 20: PEG3 */
185 {{{1, 0x1500000, 0x1501000, 0x165000} } },/* 21: P2ND */
186 {{{1, 0x1600000, 0x1601000, 0x166000} } },/* 22: P2NI */
187 {{{0, 0, 0, 0} } }, /* 23: */
188 {{{0, 0, 0, 0} } }, /* 24: */
189 {{{0, 0, 0, 0} } }, /* 25: */
190 {{{0, 0, 0, 0} } }, /* 26: */
191 {{{0, 0, 0, 0} } }, /* 27: */
192 {{{0, 0, 0, 0} } }, /* 28: */
193 {{{1, 0x1d00000, 0x1d10000, 0x190000} } },/* 29: MS */
194 {{{1, 0x1e00000, 0x1e01000, 0x16a000} } },/* 30: P2NR2 */
195 {{{1, 0x1f00000, 0x1f10000, 0x150000} } },/* 31: EPG */
196 {{{0} } }, /* 32: PCI */
197 {{{1, 0x2100000, 0x2102000, 0x120000}, /* 33: PCIE */
198 {1, 0x2110000, 0x2120000, 0x130000},
199 {1, 0x2120000, 0x2122000, 0x124000},
200 {1, 0x2130000, 0x2132000, 0x126000},
201 {1, 0x2140000, 0x2142000, 0x128000},
202 {1, 0x2150000, 0x2152000, 0x12a000},
203 {1, 0x2160000, 0x2170000, 0x110000},
204 {1, 0x2170000, 0x2172000, 0x12e000},
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 {0, 0x0000000, 0x0000000, 0x000000} } },
213 {{{1, 0x2200000, 0x2204000, 0x1b0000} } },/* 34: CAM */
219 {{{1, 0x2800000, 0x2804000, 0x1a4000} } },/* 40: TMR */
220 {{{1, 0x2900000, 0x2901000, 0x16b000} } },/* 41: P2NR3 */
221 {{{1, 0x2a00000, 0x2a00400, 0x1ac400} } },/* 42: RPMX1 */
222 {{{1, 0x2b00000, 0x2b00400, 0x1ac800} } },/* 43: RPMX2 */
223 {{{1, 0x2c00000, 0x2c00400, 0x1acc00} } },/* 44: RPMX3 */
224 {{{1, 0x2d00000, 0x2d00400, 0x1ad000} } },/* 45: RPMX4 */
225 {{{1, 0x2e00000, 0x2e00400, 0x1ad400} } },/* 46: RPMX5 */
226 {{{1, 0x2f00000, 0x2f00400, 0x1ad800} } },/* 47: RPMX6 */
227 {{{1, 0x3000000, 0x3000400, 0x1adc00} } },/* 48: RPMX7 */
228 {{{0, 0x3100000, 0x3104000, 0x1a8000} } },/* 49: XDMA */
229 {{{1, 0x3200000, 0x3204000, 0x1d4000} } },/* 50: I2Q */
230 {{{1, 0x3300000, 0x3304000, 0x1a0000} } },/* 51: ROMUSB */
232 {{{1, 0x3500000, 0x3500400, 0x1ac000} } },/* 53: RPMX0 */
233 {{{1, 0x3600000, 0x3600400, 0x1ae000} } },/* 54: RPMX8 */
234 {{{1, 0x3700000, 0x3700400, 0x1ae400} } },/* 55: RPMX9 */
235 {{{1, 0x3800000, 0x3804000, 0x1d0000} } },/* 56: OCM0 */
236 {{{1, 0x3900000, 0x3904000, 0x1b4000} } },/* 57: CRYPTO */
237 {{{1, 0x3a00000, 0x3a04000, 0x1d8000} } },/* 58: SMB */
238 {{{0} } }, /* 59: I2C0 */
239 {{{0} } }, /* 60: I2C1 */
240 {{{1, 0x3d00000, 0x3d04000, 0x1d8000} } },/* 61: LPC */
241 {{{1, 0x3e00000, 0x3e01000, 0x167000} } },/* 62: P2NC */
242 {{{1, 0x3f00000, 0x3f01000, 0x168000} } } /* 63: P2NR0 */
246 * top 12 bits of crb internal address (hub, agent)
248 static unsigned crb_hub_agt
[64] =
251 NETXEN_HW_CRB_HUB_AGT_ADR_PS
,
252 NETXEN_HW_CRB_HUB_AGT_ADR_MN
,
253 NETXEN_HW_CRB_HUB_AGT_ADR_MS
,
255 NETXEN_HW_CRB_HUB_AGT_ADR_SRE
,
256 NETXEN_HW_CRB_HUB_AGT_ADR_NIU
,
257 NETXEN_HW_CRB_HUB_AGT_ADR_QMN
,
258 NETXEN_HW_CRB_HUB_AGT_ADR_SQN0
,
259 NETXEN_HW_CRB_HUB_AGT_ADR_SQN1
,
260 NETXEN_HW_CRB_HUB_AGT_ADR_SQN2
,
261 NETXEN_HW_CRB_HUB_AGT_ADR_SQN3
,
262 NETXEN_HW_CRB_HUB_AGT_ADR_I2Q
,
263 NETXEN_HW_CRB_HUB_AGT_ADR_TIMR
,
264 NETXEN_HW_CRB_HUB_AGT_ADR_ROMUSB
,
265 NETXEN_HW_CRB_HUB_AGT_ADR_PGN4
,
266 NETXEN_HW_CRB_HUB_AGT_ADR_XDMA
,
267 NETXEN_HW_CRB_HUB_AGT_ADR_PGN0
,
268 NETXEN_HW_CRB_HUB_AGT_ADR_PGN1
,
269 NETXEN_HW_CRB_HUB_AGT_ADR_PGN2
,
270 NETXEN_HW_CRB_HUB_AGT_ADR_PGN3
,
271 NETXEN_HW_CRB_HUB_AGT_ADR_PGND
,
272 NETXEN_HW_CRB_HUB_AGT_ADR_PGNI
,
273 NETXEN_HW_CRB_HUB_AGT_ADR_PGS0
,
274 NETXEN_HW_CRB_HUB_AGT_ADR_PGS1
,
275 NETXEN_HW_CRB_HUB_AGT_ADR_PGS2
,
276 NETXEN_HW_CRB_HUB_AGT_ADR_PGS3
,
278 NETXEN_HW_CRB_HUB_AGT_ADR_PGSI
,
279 NETXEN_HW_CRB_HUB_AGT_ADR_SN
,
281 NETXEN_HW_CRB_HUB_AGT_ADR_EG
,
283 NETXEN_HW_CRB_HUB_AGT_ADR_PS
,
284 NETXEN_HW_CRB_HUB_AGT_ADR_CAM
,
290 NETXEN_HW_CRB_HUB_AGT_ADR_TIMR
,
292 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX1
,
293 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX2
,
294 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX3
,
295 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX4
,
296 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX5
,
297 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX6
,
298 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX7
,
299 NETXEN_HW_CRB_HUB_AGT_ADR_XDMA
,
300 NETXEN_HW_CRB_HUB_AGT_ADR_I2Q
,
301 NETXEN_HW_CRB_HUB_AGT_ADR_ROMUSB
,
303 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX0
,
304 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX8
,
305 NETXEN_HW_CRB_HUB_AGT_ADR_RPMX9
,
306 NETXEN_HW_CRB_HUB_AGT_ADR_OCM0
,
308 NETXEN_HW_CRB_HUB_AGT_ADR_SMB
,
309 NETXEN_HW_CRB_HUB_AGT_ADR_I2C0
,
310 NETXEN_HW_CRB_HUB_AGT_ADR_I2C1
,
312 NETXEN_HW_CRB_HUB_AGT_ADR_PGNC
,
316 /* PCI Windowing for DDR regions. */
318 #define NETXEN_WINDOW_ONE 0x2000000 /*CRB Window: bit 25 of CRB address */
320 #define NETXEN_PCIE_SEM_TIMEOUT 10000
322 static int netxen_nic_set_mtu_xgb(struct netxen_adapter
*adapter
, int new_mtu
);
325 netxen_pcie_sem_lock(struct netxen_adapter
*adapter
, int sem
, u32 id_reg
)
327 int done
= 0, timeout
= 0;
330 done
= NXRD32(adapter
, NETXEN_PCIE_REG(PCIE_SEM_LOCK(sem
)));
333 if (++timeout
>= NETXEN_PCIE_SEM_TIMEOUT
)
339 NXWR32(adapter
, id_reg
, adapter
->portnum
);
345 netxen_pcie_sem_unlock(struct netxen_adapter
*adapter
, int sem
)
347 NXRD32(adapter
, NETXEN_PCIE_REG(PCIE_SEM_UNLOCK(sem
)));
350 static int netxen_niu_xg_init_port(struct netxen_adapter
*adapter
, int port
)
352 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
353 NXWR32(adapter
, NETXEN_NIU_XGE_CONFIG_1
+(0x10000*port
), 0x1447);
354 NXWR32(adapter
, NETXEN_NIU_XGE_CONFIG_0
+(0x10000*port
), 0x5);
360 /* Disable an XG interface */
361 static int netxen_niu_disable_xg_port(struct netxen_adapter
*adapter
)
364 u32 port
= adapter
->physical_port
;
366 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
369 if (port
> NETXEN_NIU_MAX_XG_PORTS
)
374 NETXEN_NIU_XGE_CONFIG_0
+ (0x10000 * port
), mac_cfg
))
379 #define NETXEN_UNICAST_ADDR(port, index) \
380 (NETXEN_UNICAST_ADDR_BASE+(port*32)+(index*8))
381 #define NETXEN_MCAST_ADDR(port, index) \
382 (NETXEN_MULTICAST_ADDR_BASE+(port*0x80)+(index*8))
383 #define MAC_HI(addr) \
384 ((addr[2] << 16) | (addr[1] << 8) | (addr[0]))
385 #define MAC_LO(addr) \
386 ((addr[5] << 16) | (addr[4] << 8) | (addr[3]))
388 static int netxen_p2_nic_set_promisc(struct netxen_adapter
*adapter
, u32 mode
)
393 u32 port
= adapter
->physical_port
;
394 u16 board_type
= adapter
->ahw
.board_type
;
396 if (port
> NETXEN_NIU_MAX_XG_PORTS
)
399 mac_cfg
= NXRD32(adapter
, NETXEN_NIU_XGE_CONFIG_0
+ (0x10000 * port
));
401 NXWR32(adapter
, NETXEN_NIU_XGE_CONFIG_0
+ (0x10000 * port
), mac_cfg
);
403 if ((board_type
== NETXEN_BRDTYPE_P2_SB31_10G_IMEZ
) ||
404 (board_type
== NETXEN_BRDTYPE_P2_SB31_10G_HMEZ
))
405 reg
= (0x20 << port
);
407 NXWR32(adapter
, NETXEN_NIU_FRAME_COUNT_SELECT
, reg
);
411 while (NXRD32(adapter
, NETXEN_NIU_FRAME_COUNT
) && ++cnt
< 20)
416 reg
= NXRD32(adapter
,
417 NETXEN_NIU_XGE_CONFIG_1
+ (0x10000 * port
));
419 if (mode
== NETXEN_NIU_PROMISC_MODE
)
420 reg
= (reg
| 0x2000UL
);
422 reg
= (reg
& ~0x2000UL
);
424 if (mode
== NETXEN_NIU_ALLMULTI_MODE
)
425 reg
= (reg
| 0x1000UL
);
427 reg
= (reg
& ~0x1000UL
);
430 NETXEN_NIU_XGE_CONFIG_1
+ (0x10000 * port
), reg
);
434 NXWR32(adapter
, NETXEN_NIU_XGE_CONFIG_0
+ (0x10000 * port
), mac_cfg
);
439 static int netxen_p2_nic_set_mac_addr(struct netxen_adapter
*adapter
, u8
*addr
)
444 u8 phy
= adapter
->physical_port
;
446 if (phy
>= NETXEN_NIU_MAX_XG_PORTS
)
449 mac_lo
= ((u32
)addr
[0] << 16) | ((u32
)addr
[1] << 24);
450 mac_hi
= addr
[2] | ((u32
)addr
[3] << 8) |
451 ((u32
)addr
[4] << 16) | ((u32
)addr
[5] << 24);
453 reg_lo
= NETXEN_NIU_XGE_STATION_ADDR_0_1
+ (0x10000 * phy
);
454 reg_hi
= NETXEN_NIU_XGE_STATION_ADDR_0_HI
+ (0x10000 * phy
);
456 /* write twice to flush */
457 if (NXWR32(adapter
, reg_lo
, mac_lo
) || NXWR32(adapter
, reg_hi
, mac_hi
))
459 if (NXWR32(adapter
, reg_lo
, mac_lo
) || NXWR32(adapter
, reg_hi
, mac_hi
))
466 netxen_nic_enable_mcast_filter(struct netxen_adapter
*adapter
)
469 u16 port
= adapter
->physical_port
;
470 u8
*addr
= adapter
->mac_addr
;
472 if (adapter
->mc_enabled
)
475 val
= NXRD32(adapter
, NETXEN_MAC_ADDR_CNTL_REG
);
476 val
|= (1UL << (28+port
));
477 NXWR32(adapter
, NETXEN_MAC_ADDR_CNTL_REG
, val
);
479 /* add broadcast addr to filter */
481 NXWR32(adapter
, NETXEN_UNICAST_ADDR(port
, 0), val
);
482 NXWR32(adapter
, NETXEN_UNICAST_ADDR(port
, 0)+4, val
);
484 /* add station addr to filter */
486 NXWR32(adapter
, NETXEN_UNICAST_ADDR(port
, 1), val
);
488 NXWR32(adapter
, NETXEN_UNICAST_ADDR(port
, 1)+4, val
);
490 adapter
->mc_enabled
= 1;
495 netxen_nic_disable_mcast_filter(struct netxen_adapter
*adapter
)
498 u16 port
= adapter
->physical_port
;
499 u8
*addr
= adapter
->mac_addr
;
501 if (!adapter
->mc_enabled
)
504 val
= NXRD32(adapter
, NETXEN_MAC_ADDR_CNTL_REG
);
505 val
&= ~(1UL << (28+port
));
506 NXWR32(adapter
, NETXEN_MAC_ADDR_CNTL_REG
, val
);
509 NXWR32(adapter
, NETXEN_UNICAST_ADDR(port
, 0), val
);
511 NXWR32(adapter
, NETXEN_UNICAST_ADDR(port
, 0)+4, val
);
513 NXWR32(adapter
, NETXEN_UNICAST_ADDR(port
, 1), 0);
514 NXWR32(adapter
, NETXEN_UNICAST_ADDR(port
, 1)+4, 0);
516 adapter
->mc_enabled
= 0;
521 netxen_nic_set_mcast_addr(struct netxen_adapter
*adapter
,
525 u16 port
= adapter
->physical_port
;
530 NXWR32(adapter
, NETXEN_MCAST_ADDR(port
, index
), hi
);
531 NXWR32(adapter
, NETXEN_MCAST_ADDR(port
, index
)+4, lo
);
536 static void netxen_p2_nic_set_multi(struct net_device
*netdev
)
538 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
539 struct netdev_hw_addr
*ha
;
543 memset(null_addr
, 0, 6);
545 if (netdev
->flags
& IFF_PROMISC
) {
547 adapter
->set_promisc(adapter
,
548 NETXEN_NIU_PROMISC_MODE
);
550 /* Full promiscuous mode */
551 netxen_nic_disable_mcast_filter(adapter
);
556 if (netdev_mc_empty(netdev
)) {
557 adapter
->set_promisc(adapter
,
558 NETXEN_NIU_NON_PROMISC_MODE
);
559 netxen_nic_disable_mcast_filter(adapter
);
563 adapter
->set_promisc(adapter
, NETXEN_NIU_ALLMULTI_MODE
);
564 if (netdev
->flags
& IFF_ALLMULTI
||
565 netdev_mc_count(netdev
) > adapter
->max_mc_count
) {
566 netxen_nic_disable_mcast_filter(adapter
);
570 netxen_nic_enable_mcast_filter(adapter
);
573 netdev_for_each_mc_addr(ha
, netdev
)
574 netxen_nic_set_mcast_addr(adapter
, i
++, ha
->addr
);
576 /* Clear out remaining addresses */
577 while (i
< adapter
->max_mc_count
)
578 netxen_nic_set_mcast_addr(adapter
, i
++, null_addr
);
582 netxen_send_cmd_descs(struct netxen_adapter
*adapter
,
583 struct cmd_desc_type0
*cmd_desc_arr
, int nr_desc
)
585 u32 i
, producer
, consumer
;
586 struct netxen_cmd_buffer
*pbuf
;
587 struct cmd_desc_type0
*cmd_desc
;
588 struct nx_host_tx_ring
*tx_ring
;
592 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
595 tx_ring
= adapter
->tx_ring
;
596 __netif_tx_lock_bh(tx_ring
->txq
);
598 producer
= tx_ring
->producer
;
599 consumer
= tx_ring
->sw_consumer
;
601 if (nr_desc
>= netxen_tx_avail(tx_ring
)) {
602 netif_tx_stop_queue(tx_ring
->txq
);
604 if (netxen_tx_avail(tx_ring
) > nr_desc
) {
605 if (netxen_tx_avail(tx_ring
) > TX_STOP_THRESH
)
606 netif_tx_wake_queue(tx_ring
->txq
);
608 __netif_tx_unlock_bh(tx_ring
->txq
);
614 cmd_desc
= &cmd_desc_arr
[i
];
616 pbuf
= &tx_ring
->cmd_buf_arr
[producer
];
618 pbuf
->frag_count
= 0;
620 memcpy(&tx_ring
->desc_head
[producer
],
621 &cmd_desc_arr
[i
], sizeof(struct cmd_desc_type0
));
623 producer
= get_next_index(producer
, tx_ring
->num_desc
);
626 } while (i
!= nr_desc
);
628 tx_ring
->producer
= producer
;
630 netxen_nic_update_cmd_producer(adapter
, tx_ring
);
632 __netif_tx_unlock_bh(tx_ring
->txq
);
638 nx_p3_sre_macaddr_change(struct netxen_adapter
*adapter
, u8
*addr
, unsigned op
)
641 nx_mac_req_t
*mac_req
;
644 memset(&req
, 0, sizeof(nx_nic_req_t
));
645 req
.qhdr
= cpu_to_le64(NX_NIC_REQUEST
<< 23);
647 word
= NX_MAC_EVENT
| ((u64
)adapter
->portnum
<< 16);
648 req
.req_hdr
= cpu_to_le64(word
);
650 mac_req
= (nx_mac_req_t
*)&req
.words
[0];
652 memcpy(mac_req
->mac_addr
, addr
, 6);
654 return netxen_send_cmd_descs(adapter
, (struct cmd_desc_type0
*)&req
, 1);
657 static int nx_p3_nic_add_mac(struct netxen_adapter
*adapter
,
658 const u8
*addr
, struct list_head
*del_list
)
660 struct list_head
*head
;
663 /* look up if already exists */
664 list_for_each(head
, del_list
) {
665 cur
= list_entry(head
, nx_mac_list_t
, list
);
667 if (memcmp(addr
, cur
->mac_addr
, ETH_ALEN
) == 0) {
668 list_move_tail(head
, &adapter
->mac_list
);
673 cur
= kzalloc(sizeof(nx_mac_list_t
), GFP_ATOMIC
);
675 printk(KERN_ERR
"%s: failed to add mac address filter\n",
676 adapter
->netdev
->name
);
679 memcpy(cur
->mac_addr
, addr
, ETH_ALEN
);
680 list_add_tail(&cur
->list
, &adapter
->mac_list
);
681 return nx_p3_sre_macaddr_change(adapter
,
682 cur
->mac_addr
, NETXEN_MAC_ADD
);
685 static void netxen_p3_nic_set_multi(struct net_device
*netdev
)
687 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
688 struct netdev_hw_addr
*ha
;
689 static const u8 bcast_addr
[ETH_ALEN
] = {
690 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
692 u32 mode
= VPORT_MISS_MODE_DROP
;
694 struct list_head
*head
;
697 if (adapter
->is_up
!= NETXEN_ADAPTER_UP_MAGIC
)
700 list_splice_tail_init(&adapter
->mac_list
, &del_list
);
702 nx_p3_nic_add_mac(adapter
, adapter
->mac_addr
, &del_list
);
703 nx_p3_nic_add_mac(adapter
, bcast_addr
, &del_list
);
705 if (netdev
->flags
& IFF_PROMISC
) {
706 mode
= VPORT_MISS_MODE_ACCEPT_ALL
;
710 if ((netdev
->flags
& IFF_ALLMULTI
) ||
711 (netdev_mc_count(netdev
) > adapter
->max_mc_count
)) {
712 mode
= VPORT_MISS_MODE_ACCEPT_MULTI
;
716 if (!netdev_mc_empty(netdev
)) {
717 netdev_for_each_mc_addr(ha
, netdev
)
718 nx_p3_nic_add_mac(adapter
, ha
->addr
, &del_list
);
722 adapter
->set_promisc(adapter
, mode
);
724 while (!list_empty(head
)) {
725 cur
= list_entry(head
->next
, nx_mac_list_t
, list
);
727 nx_p3_sre_macaddr_change(adapter
,
728 cur
->mac_addr
, NETXEN_MAC_DEL
);
729 list_del(&cur
->list
);
734 static int netxen_p3_nic_set_promisc(struct netxen_adapter
*adapter
, u32 mode
)
739 memset(&req
, 0, sizeof(nx_nic_req_t
));
741 req
.qhdr
= cpu_to_le64(NX_HOST_REQUEST
<< 23);
743 word
= NX_NIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE
|
744 ((u64
)adapter
->portnum
<< 16);
745 req
.req_hdr
= cpu_to_le64(word
);
747 req
.words
[0] = cpu_to_le64(mode
);
749 return netxen_send_cmd_descs(adapter
,
750 (struct cmd_desc_type0
*)&req
, 1);
753 void netxen_p3_free_mac_list(struct netxen_adapter
*adapter
)
756 struct list_head
*head
= &adapter
->mac_list
;
758 while (!list_empty(head
)) {
759 cur
= list_entry(head
->next
, nx_mac_list_t
, list
);
760 nx_p3_sre_macaddr_change(adapter
,
761 cur
->mac_addr
, NETXEN_MAC_DEL
);
762 list_del(&cur
->list
);
767 static int netxen_p3_nic_set_mac_addr(struct netxen_adapter
*adapter
, u8
*addr
)
769 /* assuming caller has already copied new addr to netdev */
770 netxen_p3_nic_set_multi(adapter
->netdev
);
774 #define NETXEN_CONFIG_INTR_COALESCE 3
777 * Send the interrupt coalescing parameter set by ethtool to the card.
779 int netxen_config_intr_coalesce(struct netxen_adapter
*adapter
)
785 memset(&req
, 0, sizeof(nx_nic_req_t
));
786 memset(word
, 0, sizeof(word
));
788 req
.qhdr
= cpu_to_le64(NX_HOST_REQUEST
<< 23);
790 word
[0] = NETXEN_CONFIG_INTR_COALESCE
| ((u64
)adapter
->portnum
<< 16);
791 req
.req_hdr
= cpu_to_le64(word
[0]);
793 memcpy(&word
[0], &adapter
->coal
, sizeof(adapter
->coal
));
794 for (i
= 0; i
< 6; i
++)
795 req
.words
[i
] = cpu_to_le64(word
[i
]);
797 rv
= netxen_send_cmd_descs(adapter
, (struct cmd_desc_type0
*)&req
, 1);
799 printk(KERN_ERR
"ERROR. Could not send "
800 "interrupt coalescing parameters\n");
806 int netxen_config_hw_lro(struct netxen_adapter
*adapter
, int enable
)
812 memset(&req
, 0, sizeof(nx_nic_req_t
));
814 req
.qhdr
= cpu_to_le64(NX_HOST_REQUEST
<< 23);
816 word
= NX_NIC_H2C_OPCODE_CONFIG_HW_LRO
| ((u64
)adapter
->portnum
<< 16);
817 req
.req_hdr
= cpu_to_le64(word
);
819 req
.words
[0] = cpu_to_le64(enable
);
821 rv
= netxen_send_cmd_descs(adapter
, (struct cmd_desc_type0
*)&req
, 1);
823 printk(KERN_ERR
"ERROR. Could not send "
824 "configure hw lro request\n");
830 int netxen_config_bridged_mode(struct netxen_adapter
*adapter
, int enable
)
836 if (!!(adapter
->flags
& NETXEN_NIC_BRIDGE_ENABLED
) == enable
)
839 memset(&req
, 0, sizeof(nx_nic_req_t
));
841 req
.qhdr
= cpu_to_le64(NX_HOST_REQUEST
<< 23);
843 word
= NX_NIC_H2C_OPCODE_CONFIG_BRIDGING
|
844 ((u64
)adapter
->portnum
<< 16);
845 req
.req_hdr
= cpu_to_le64(word
);
847 req
.words
[0] = cpu_to_le64(enable
);
849 rv
= netxen_send_cmd_descs(adapter
, (struct cmd_desc_type0
*)&req
, 1);
851 printk(KERN_ERR
"ERROR. Could not send "
852 "configure bridge mode request\n");
855 adapter
->flags
^= NETXEN_NIC_BRIDGE_ENABLED
;
861 #define RSS_HASHTYPE_IP_TCP 0x3
863 int netxen_config_rss(struct netxen_adapter
*adapter
, int enable
)
869 static const u64 key
[] = {
870 0xbeac01fa6a42b73bULL
, 0x8030f20c77cb2da3ULL
,
871 0xae7b30b4d0ca2bcbULL
, 0x43a38fb04167253dULL
,
872 0x255b0ec26d5a56daULL
876 memset(&req
, 0, sizeof(nx_nic_req_t
));
877 req
.qhdr
= cpu_to_le64(NX_HOST_REQUEST
<< 23);
879 word
= NX_NIC_H2C_OPCODE_CONFIG_RSS
| ((u64
)adapter
->portnum
<< 16);
880 req
.req_hdr
= cpu_to_le64(word
);
884 * bits 3-0: hash_method
885 * 5-4: hash_type_ipv4
886 * 7-6: hash_type_ipv6
888 * 9: use indirection table
890 * 63-48: indirection table mask
892 word
= ((u64
)(RSS_HASHTYPE_IP_TCP
& 0x3) << 4) |
893 ((u64
)(RSS_HASHTYPE_IP_TCP
& 0x3) << 6) |
894 ((u64
)(enable
& 0x1) << 8) |
896 req
.words
[0] = cpu_to_le64(word
);
897 for (i
= 0; i
< ARRAY_SIZE(key
); i
++)
898 req
.words
[i
+1] = cpu_to_le64(key
[i
]);
901 rv
= netxen_send_cmd_descs(adapter
, (struct cmd_desc_type0
*)&req
, 1);
903 printk(KERN_ERR
"%s: could not configure RSS\n",
904 adapter
->netdev
->name
);
910 int netxen_config_ipaddr(struct netxen_adapter
*adapter
, u32 ip
, int cmd
)
916 memset(&req
, 0, sizeof(nx_nic_req_t
));
917 req
.qhdr
= cpu_to_le64(NX_HOST_REQUEST
<< 23);
919 word
= NX_NIC_H2C_OPCODE_CONFIG_IPADDR
| ((u64
)adapter
->portnum
<< 16);
920 req
.req_hdr
= cpu_to_le64(word
);
922 req
.words
[0] = cpu_to_le64(cmd
);
923 req
.words
[1] = cpu_to_le64(ip
);
925 rv
= netxen_send_cmd_descs(adapter
, (struct cmd_desc_type0
*)&req
, 1);
927 printk(KERN_ERR
"%s: could not notify %s IP 0x%x reuqest\n",
928 adapter
->netdev
->name
,
929 (cmd
== NX_IP_UP
) ? "Add" : "Remove", ip
);
934 int netxen_linkevent_request(struct netxen_adapter
*adapter
, int enable
)
940 memset(&req
, 0, sizeof(nx_nic_req_t
));
941 req
.qhdr
= cpu_to_le64(NX_HOST_REQUEST
<< 23);
943 word
= NX_NIC_H2C_OPCODE_GET_LINKEVENT
| ((u64
)adapter
->portnum
<< 16);
944 req
.req_hdr
= cpu_to_le64(word
);
945 req
.words
[0] = cpu_to_le64(enable
| (enable
<< 8));
947 rv
= netxen_send_cmd_descs(adapter
, (struct cmd_desc_type0
*)&req
, 1);
949 printk(KERN_ERR
"%s: could not configure link notification\n",
950 adapter
->netdev
->name
);
956 int netxen_send_lro_cleanup(struct netxen_adapter
*adapter
)
962 memset(&req
, 0, sizeof(nx_nic_req_t
));
963 req
.qhdr
= cpu_to_le64(NX_HOST_REQUEST
<< 23);
965 word
= NX_NIC_H2C_OPCODE_LRO_REQUEST
|
966 ((u64
)adapter
->portnum
<< 16) |
967 ((u64
)NX_NIC_LRO_REQUEST_CLEANUP
<< 56) ;
969 req
.req_hdr
= cpu_to_le64(word
);
971 rv
= netxen_send_cmd_descs(adapter
, (struct cmd_desc_type0
*)&req
, 1);
973 printk(KERN_ERR
"%s: could not cleanup lro flows\n",
974 adapter
->netdev
->name
);
980 * netxen_nic_change_mtu - Change the Maximum Transfer Unit
981 * @returns 0 on success, negative on failure
984 #define MTU_FUDGE_FACTOR 100
986 int netxen_nic_change_mtu(struct net_device
*netdev
, int mtu
)
988 struct netxen_adapter
*adapter
= netdev_priv(netdev
);
992 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
))
993 max_mtu
= P3_MAX_MTU
;
995 max_mtu
= P2_MAX_MTU
;
998 printk(KERN_ERR
"%s: mtu > %d bytes unsupported\n",
999 netdev
->name
, max_mtu
);
1003 if (adapter
->set_mtu
)
1004 rc
= adapter
->set_mtu(adapter
, mtu
);
1012 static int netxen_get_flash_block(struct netxen_adapter
*adapter
, int base
,
1013 int size
, __le32
* buf
)
1020 for (i
= 0; i
< size
/ sizeof(u32
); i
++) {
1021 if (netxen_rom_fast_read(adapter
, addr
, &v
) == -1)
1023 *ptr32
= cpu_to_le32(v
);
1025 addr
+= sizeof(u32
);
1027 if ((char *)buf
+ size
> (char *)ptr32
) {
1029 if (netxen_rom_fast_read(adapter
, addr
, &v
) == -1)
1031 local
= cpu_to_le32(v
);
1032 memcpy(ptr32
, &local
, (char *)buf
+ size
- (char *)ptr32
);
1038 int netxen_get_flash_mac_addr(struct netxen_adapter
*adapter
, u64
*mac
)
1040 __le32
*pmac
= (__le32
*) mac
;
1043 offset
= NX_FW_MAC_ADDR_OFFSET
+ (adapter
->portnum
* sizeof(u64
));
1045 if (netxen_get_flash_block(adapter
, offset
, sizeof(u64
), pmac
) == -1)
1048 if (*mac
== cpu_to_le64(~0ULL)) {
1050 offset
= NX_OLD_MAC_ADDR_OFFSET
+
1051 (adapter
->portnum
* sizeof(u64
));
1053 if (netxen_get_flash_block(adapter
,
1054 offset
, sizeof(u64
), pmac
) == -1)
1057 if (*mac
== cpu_to_le64(~0ULL))
1063 int netxen_p3_get_mac_addr(struct netxen_adapter
*adapter
, u64
*mac
)
1065 uint32_t crbaddr
, mac_hi
, mac_lo
;
1066 int pci_func
= adapter
->ahw
.pci_func
;
1068 crbaddr
= CRB_MAC_BLOCK_START
+
1069 (4 * ((pci_func
/2) * 3)) + (4 * (pci_func
& 1));
1071 mac_lo
= NXRD32(adapter
, crbaddr
);
1072 mac_hi
= NXRD32(adapter
, crbaddr
+4);
1075 *mac
= le64_to_cpu((mac_lo
>> 16) | ((u64
)mac_hi
<< 16));
1077 *mac
= le64_to_cpu((u64
)mac_lo
| ((u64
)mac_hi
<< 32));
1083 * Changes the CRB window to the specified window.
1086 netxen_nic_pci_set_crbwindow_128M(struct netxen_adapter
*adapter
,
1089 void __iomem
*offset
;
1091 u8 func
= adapter
->ahw
.pci_func
;
1093 if (adapter
->ahw
.crb_win
== window
)
1096 offset
= PCI_OFFSET_SECOND_RANGE(adapter
,
1097 NETXEN_PCIX_PH_REG(PCIE_CRB_WINDOW_REG(func
)));
1099 writel(window
, offset
);
1101 if (window
== readl(offset
))
1104 if (printk_ratelimit())
1105 dev_warn(&adapter
->pdev
->dev
,
1106 "failed to set CRB window to %d\n",
1107 (window
== NETXEN_WINDOW_ONE
));
1110 } while (--count
> 0);
1113 adapter
->ahw
.crb_win
= window
;
1117 * Returns < 0 if off is not valid,
1118 * 1 if window access is needed. 'off' is set to offset from
1119 * CRB space in 128M pci map
1120 * 0 if no window access is needed. 'off' is set to 2M addr
1121 * In: 'off' is offset from base in 128M pci map
1124 netxen_nic_pci_get_crb_addr_2M(struct netxen_adapter
*adapter
,
1125 ulong off
, void __iomem
**addr
)
1127 crb_128M_2M_sub_block_map_t
*m
;
1130 if ((off
>= NETXEN_CRB_MAX
) || (off
< NETXEN_PCI_CRBSPACE
))
1133 off
-= NETXEN_PCI_CRBSPACE
;
1138 m
= &crb_128M_2M_map
[CRB_BLK(off
)].sub_block
[CRB_SUBBLK(off
)];
1140 if (m
->valid
&& (m
->start_128M
<= off
) && (m
->end_128M
> off
)) {
1141 *addr
= adapter
->ahw
.pci_base0
+ m
->start_2M
+
1142 (off
- m
->start_128M
);
1147 * Not in direct map, use crb window
1149 *addr
= adapter
->ahw
.pci_base0
+ CRB_INDIRECT_2M
+
1155 * In: 'off' is offset from CRB space in 128M pci map
1156 * Out: 'off' is 2M pci map addr
1157 * side effect: lock crb window
1160 netxen_nic_pci_set_crbwindow_2M(struct netxen_adapter
*adapter
, ulong off
)
1163 void __iomem
*addr
= adapter
->ahw
.pci_base0
+ CRB_WINDOW_2M
;
1165 off
-= NETXEN_PCI_CRBSPACE
;
1167 window
= CRB_HI(off
);
1169 writel(window
, addr
);
1170 if (readl(addr
) != window
) {
1171 if (printk_ratelimit())
1172 dev_warn(&adapter
->pdev
->dev
,
1173 "failed to set CRB window to %d off 0x%lx\n",
1178 static void __iomem
*
1179 netxen_nic_map_indirect_address_128M(struct netxen_adapter
*adapter
,
1180 ulong win_off
, void __iomem
**mem_ptr
)
1182 ulong off
= win_off
;
1184 resource_size_t mem_base
;
1186 if (ADDR_IN_WINDOW1(win_off
))
1187 off
= NETXEN_CRB_NORMAL(win_off
);
1189 addr
= pci_base_offset(adapter
, off
);
1193 if (adapter
->ahw
.pci_len0
== 0)
1194 off
-= NETXEN_PCI_CRBSPACE
;
1196 mem_base
= pci_resource_start(adapter
->pdev
, 0);
1197 *mem_ptr
= ioremap(mem_base
+ (off
& PAGE_MASK
), PAGE_SIZE
);
1199 addr
= *mem_ptr
+ (off
& (PAGE_SIZE
- 1));
1205 netxen_nic_hw_write_wx_128M(struct netxen_adapter
*adapter
, ulong off
, u32 data
)
1207 unsigned long flags
;
1208 void __iomem
*addr
, *mem_ptr
= NULL
;
1210 addr
= netxen_nic_map_indirect_address_128M(adapter
, off
, &mem_ptr
);
1214 if (ADDR_IN_WINDOW1(off
)) { /* Window 1 */
1215 netxen_nic_io_write_128M(adapter
, addr
, data
);
1216 } else { /* Window 0 */
1217 write_lock_irqsave(&adapter
->ahw
.crb_lock
, flags
);
1218 netxen_nic_pci_set_crbwindow_128M(adapter
, 0);
1220 netxen_nic_pci_set_crbwindow_128M(adapter
,
1222 write_unlock_irqrestore(&adapter
->ahw
.crb_lock
, flags
);
1232 netxen_nic_hw_read_wx_128M(struct netxen_adapter
*adapter
, ulong off
)
1234 unsigned long flags
;
1235 void __iomem
*addr
, *mem_ptr
= NULL
;
1238 addr
= netxen_nic_map_indirect_address_128M(adapter
, off
, &mem_ptr
);
1242 if (ADDR_IN_WINDOW1(off
)) { /* Window 1 */
1243 data
= netxen_nic_io_read_128M(adapter
, addr
);
1244 } else { /* Window 0 */
1245 write_lock_irqsave(&adapter
->ahw
.crb_lock
, flags
);
1246 netxen_nic_pci_set_crbwindow_128M(adapter
, 0);
1248 netxen_nic_pci_set_crbwindow_128M(adapter
,
1250 write_unlock_irqrestore(&adapter
->ahw
.crb_lock
, flags
);
1260 netxen_nic_hw_write_wx_2M(struct netxen_adapter
*adapter
, ulong off
, u32 data
)
1262 unsigned long flags
;
1264 void __iomem
*addr
= NULL
;
1266 rv
= netxen_nic_pci_get_crb_addr_2M(adapter
, off
, &addr
);
1274 /* indirect access */
1275 write_lock_irqsave(&adapter
->ahw
.crb_lock
, flags
);
1276 crb_win_lock(adapter
);
1277 netxen_nic_pci_set_crbwindow_2M(adapter
, off
);
1279 crb_win_unlock(adapter
);
1280 write_unlock_irqrestore(&adapter
->ahw
.crb_lock
, flags
);
1284 dev_err(&adapter
->pdev
->dev
,
1285 "%s: invalid offset: 0x%016lx\n", __func__
, off
);
1291 netxen_nic_hw_read_wx_2M(struct netxen_adapter
*adapter
, ulong off
)
1293 unsigned long flags
;
1296 void __iomem
*addr
= NULL
;
1298 rv
= netxen_nic_pci_get_crb_addr_2M(adapter
, off
, &addr
);
1304 /* indirect access */
1305 write_lock_irqsave(&adapter
->ahw
.crb_lock
, flags
);
1306 crb_win_lock(adapter
);
1307 netxen_nic_pci_set_crbwindow_2M(adapter
, off
);
1309 crb_win_unlock(adapter
);
1310 write_unlock_irqrestore(&adapter
->ahw
.crb_lock
, flags
);
1314 dev_err(&adapter
->pdev
->dev
,
1315 "%s: invalid offset: 0x%016lx\n", __func__
, off
);
1320 /* window 1 registers only */
1321 static void netxen_nic_io_write_128M(struct netxen_adapter
*adapter
,
1322 void __iomem
*addr
, u32 data
)
1324 read_lock(&adapter
->ahw
.crb_lock
);
1326 read_unlock(&adapter
->ahw
.crb_lock
);
1329 static u32
netxen_nic_io_read_128M(struct netxen_adapter
*adapter
,
1334 read_lock(&adapter
->ahw
.crb_lock
);
1336 read_unlock(&adapter
->ahw
.crb_lock
);
1341 static void netxen_nic_io_write_2M(struct netxen_adapter
*adapter
,
1342 void __iomem
*addr
, u32 data
)
1347 static u32
netxen_nic_io_read_2M(struct netxen_adapter
*adapter
,
1354 netxen_get_ioaddr(struct netxen_adapter
*adapter
, u32 offset
)
1356 void __iomem
*addr
= NULL
;
1358 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
1359 if ((offset
< NETXEN_CRB_PCIX_HOST2
) &&
1360 (offset
> NETXEN_CRB_PCIX_HOST
))
1361 addr
= PCI_OFFSET_SECOND_RANGE(adapter
, offset
);
1363 addr
= NETXEN_CRB_NORMALIZE(adapter
, offset
);
1365 WARN_ON(netxen_nic_pci_get_crb_addr_2M(adapter
,
1373 netxen_nic_pci_set_window_128M(struct netxen_adapter
*adapter
,
1374 u64 addr
, u32
*start
)
1376 if (ADDR_IN_RANGE(addr
, NETXEN_ADDR_OCM0
, NETXEN_ADDR_OCM0_MAX
)) {
1377 *start
= (addr
- NETXEN_ADDR_OCM0
+ NETXEN_PCI_OCM0
);
1379 } else if (ADDR_IN_RANGE(addr
,
1380 NETXEN_ADDR_OCM1
, NETXEN_ADDR_OCM1_MAX
)) {
1381 *start
= (addr
- NETXEN_ADDR_OCM1
+ NETXEN_PCI_OCM1
);
1389 netxen_nic_pci_set_window_2M(struct netxen_adapter
*adapter
,
1390 u64 addr
, u32
*start
)
1394 window
= OCM_WIN(addr
);
1396 writel(window
, adapter
->ahw
.ocm_win_crb
);
1397 /* read back to flush */
1398 readl(adapter
->ahw
.ocm_win_crb
);
1400 adapter
->ahw
.ocm_win
= window
;
1401 *start
= NETXEN_PCI_OCM0_2M
+ GET_MEM_OFFS_2M(addr
);
1406 netxen_nic_pci_mem_access_direct(struct netxen_adapter
*adapter
, u64 off
,
1409 void __iomem
*addr
, *mem_ptr
= NULL
;
1410 resource_size_t mem_base
;
1414 spin_lock(&adapter
->ahw
.mem_lock
);
1416 ret
= adapter
->pci_set_window(adapter
, off
, &start
);
1420 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
1421 addr
= adapter
->ahw
.pci_base0
+ start
;
1423 addr
= pci_base_offset(adapter
, start
);
1427 mem_base
= pci_resource_start(adapter
->pdev
, 0) +
1428 (start
& PAGE_MASK
);
1429 mem_ptr
= ioremap(mem_base
, PAGE_SIZE
);
1430 if (mem_ptr
== NULL
) {
1435 addr
= mem_ptr
+ (start
& (PAGE_SIZE
-1));
1438 if (op
== 0) /* read */
1439 *data
= readq(addr
);
1441 writeq(*data
, addr
);
1444 spin_unlock(&adapter
->ahw
.mem_lock
);
1452 netxen_pci_camqm_read_2M(struct netxen_adapter
*adapter
, u64 off
, u64
*data
)
1454 void __iomem
*addr
= adapter
->ahw
.pci_base0
+
1455 NETXEN_PCI_CAMQM_2M_BASE
+ (off
- NETXEN_PCI_CAMQM
);
1457 spin_lock(&adapter
->ahw
.mem_lock
);
1458 *data
= readq(addr
);
1459 spin_unlock(&adapter
->ahw
.mem_lock
);
1463 netxen_pci_camqm_write_2M(struct netxen_adapter
*adapter
, u64 off
, u64 data
)
1465 void __iomem
*addr
= adapter
->ahw
.pci_base0
+
1466 NETXEN_PCI_CAMQM_2M_BASE
+ (off
- NETXEN_PCI_CAMQM
);
1468 spin_lock(&adapter
->ahw
.mem_lock
);
1470 spin_unlock(&adapter
->ahw
.mem_lock
);
1473 #define MAX_CTL_CHECK 1000
1476 netxen_nic_pci_mem_write_128M(struct netxen_adapter
*adapter
,
1480 u32 temp
, off_lo
, off_hi
, addr_hi
, data_hi
, data_lo
;
1481 void __iomem
*mem_crb
;
1483 /* Only 64-bit aligned access */
1487 /* P2 has different SIU and MIU test agent base addr */
1488 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_QDR_NET
,
1489 NETXEN_ADDR_QDR_NET_MAX_P2
)) {
1490 mem_crb
= pci_base_offset(adapter
,
1491 NETXEN_CRB_QDR_NET
+SIU_TEST_AGT_BASE
);
1492 addr_hi
= SIU_TEST_AGT_ADDR_HI
;
1493 data_lo
= SIU_TEST_AGT_WRDATA_LO
;
1494 data_hi
= SIU_TEST_AGT_WRDATA_HI
;
1495 off_lo
= off
& SIU_TEST_AGT_ADDR_MASK
;
1496 off_hi
= SIU_TEST_AGT_UPPER_ADDR(off
);
1500 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_DDR_NET
, NETXEN_ADDR_DDR_NET_MAX
)) {
1501 mem_crb
= pci_base_offset(adapter
,
1502 NETXEN_CRB_DDR_NET
+MIU_TEST_AGT_BASE
);
1503 addr_hi
= MIU_TEST_AGT_ADDR_HI
;
1504 data_lo
= MIU_TEST_AGT_WRDATA_LO
;
1505 data_hi
= MIU_TEST_AGT_WRDATA_HI
;
1506 off_lo
= off
& MIU_TEST_AGT_ADDR_MASK
;
1511 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_OCM0
, NETXEN_ADDR_OCM0_MAX
) ||
1512 ADDR_IN_RANGE(off
, NETXEN_ADDR_OCM1
, NETXEN_ADDR_OCM1_MAX
)) {
1513 if (adapter
->ahw
.pci_len0
!= 0) {
1514 return netxen_nic_pci_mem_access_direct(adapter
,
1522 spin_lock(&adapter
->ahw
.mem_lock
);
1523 netxen_nic_pci_set_crbwindow_128M(adapter
, 0);
1525 writel(off_lo
, (mem_crb
+ MIU_TEST_AGT_ADDR_LO
));
1526 writel(off_hi
, (mem_crb
+ addr_hi
));
1527 writel(data
& 0xffffffff, (mem_crb
+ data_lo
));
1528 writel((data
>> 32) & 0xffffffff, (mem_crb
+ data_hi
));
1529 writel((TA_CTL_ENABLE
| TA_CTL_WRITE
), (mem_crb
+ TEST_AGT_CTRL
));
1530 writel((TA_CTL_START
| TA_CTL_ENABLE
| TA_CTL_WRITE
),
1531 (mem_crb
+ TEST_AGT_CTRL
));
1533 for (j
= 0; j
< MAX_CTL_CHECK
; j
++) {
1534 temp
= readl((mem_crb
+ TEST_AGT_CTRL
));
1535 if ((temp
& TA_CTL_BUSY
) == 0)
1539 if (j
>= MAX_CTL_CHECK
) {
1540 if (printk_ratelimit())
1541 dev_err(&adapter
->pdev
->dev
,
1542 "failed to write through agent\n");
1547 netxen_nic_pci_set_crbwindow_128M(adapter
, NETXEN_WINDOW_ONE
);
1548 spin_unlock(&adapter
->ahw
.mem_lock
);
1553 netxen_nic_pci_mem_read_128M(struct netxen_adapter
*adapter
,
1557 u32 temp
, off_lo
, off_hi
, addr_hi
, data_hi
, data_lo
;
1559 void __iomem
*mem_crb
;
1561 /* Only 64-bit aligned access */
1565 /* P2 has different SIU and MIU test agent base addr */
1566 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_QDR_NET
,
1567 NETXEN_ADDR_QDR_NET_MAX_P2
)) {
1568 mem_crb
= pci_base_offset(adapter
,
1569 NETXEN_CRB_QDR_NET
+SIU_TEST_AGT_BASE
);
1570 addr_hi
= SIU_TEST_AGT_ADDR_HI
;
1571 data_lo
= SIU_TEST_AGT_RDDATA_LO
;
1572 data_hi
= SIU_TEST_AGT_RDDATA_HI
;
1573 off_lo
= off
& SIU_TEST_AGT_ADDR_MASK
;
1574 off_hi
= SIU_TEST_AGT_UPPER_ADDR(off
);
1578 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_DDR_NET
, NETXEN_ADDR_DDR_NET_MAX
)) {
1579 mem_crb
= pci_base_offset(adapter
,
1580 NETXEN_CRB_DDR_NET
+MIU_TEST_AGT_BASE
);
1581 addr_hi
= MIU_TEST_AGT_ADDR_HI
;
1582 data_lo
= MIU_TEST_AGT_RDDATA_LO
;
1583 data_hi
= MIU_TEST_AGT_RDDATA_HI
;
1584 off_lo
= off
& MIU_TEST_AGT_ADDR_MASK
;
1589 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_OCM0
, NETXEN_ADDR_OCM0_MAX
) ||
1590 ADDR_IN_RANGE(off
, NETXEN_ADDR_OCM1
, NETXEN_ADDR_OCM1_MAX
)) {
1591 if (adapter
->ahw
.pci_len0
!= 0) {
1592 return netxen_nic_pci_mem_access_direct(adapter
,
1600 spin_lock(&adapter
->ahw
.mem_lock
);
1601 netxen_nic_pci_set_crbwindow_128M(adapter
, 0);
1603 writel(off_lo
, (mem_crb
+ MIU_TEST_AGT_ADDR_LO
));
1604 writel(off_hi
, (mem_crb
+ addr_hi
));
1605 writel(TA_CTL_ENABLE
, (mem_crb
+ TEST_AGT_CTRL
));
1606 writel((TA_CTL_START
|TA_CTL_ENABLE
), (mem_crb
+ TEST_AGT_CTRL
));
1608 for (j
= 0; j
< MAX_CTL_CHECK
; j
++) {
1609 temp
= readl(mem_crb
+ TEST_AGT_CTRL
);
1610 if ((temp
& TA_CTL_BUSY
) == 0)
1614 if (j
>= MAX_CTL_CHECK
) {
1615 if (printk_ratelimit())
1616 dev_err(&adapter
->pdev
->dev
,
1617 "failed to read through agent\n");
1621 temp
= readl(mem_crb
+ data_hi
);
1622 val
= ((u64
)temp
<< 32);
1623 val
|= readl(mem_crb
+ data_lo
);
1628 netxen_nic_pci_set_crbwindow_128M(adapter
, NETXEN_WINDOW_ONE
);
1629 spin_unlock(&adapter
->ahw
.mem_lock
);
1635 netxen_nic_pci_mem_write_2M(struct netxen_adapter
*adapter
,
1640 void __iomem
*mem_crb
;
1642 /* Only 64-bit aligned access */
1646 /* P3 onward, test agent base for MIU and SIU is same */
1647 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_QDR_NET
,
1648 NETXEN_ADDR_QDR_NET_MAX_P3
)) {
1649 mem_crb
= netxen_get_ioaddr(adapter
,
1650 NETXEN_CRB_QDR_NET
+MIU_TEST_AGT_BASE
);
1654 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_DDR_NET
, NETXEN_ADDR_DDR_NET_MAX
)) {
1655 mem_crb
= netxen_get_ioaddr(adapter
,
1656 NETXEN_CRB_DDR_NET
+MIU_TEST_AGT_BASE
);
1660 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_OCM0
, NETXEN_ADDR_OCM0_MAX
))
1661 return netxen_nic_pci_mem_access_direct(adapter
, off
, &data
, 1);
1666 off8
= off
& 0xfffffff8;
1668 spin_lock(&adapter
->ahw
.mem_lock
);
1670 writel(off8
, (mem_crb
+ MIU_TEST_AGT_ADDR_LO
));
1671 writel(0, (mem_crb
+ MIU_TEST_AGT_ADDR_HI
));
1673 writel(data
& 0xffffffff,
1674 mem_crb
+ MIU_TEST_AGT_WRDATA_LO
);
1675 writel((data
>> 32) & 0xffffffff,
1676 mem_crb
+ MIU_TEST_AGT_WRDATA_HI
);
1678 writel((TA_CTL_ENABLE
| TA_CTL_WRITE
), (mem_crb
+ TEST_AGT_CTRL
));
1679 writel((TA_CTL_START
| TA_CTL_ENABLE
| TA_CTL_WRITE
),
1680 (mem_crb
+ TEST_AGT_CTRL
));
1682 for (j
= 0; j
< MAX_CTL_CHECK
; j
++) {
1683 temp
= readl(mem_crb
+ TEST_AGT_CTRL
);
1684 if ((temp
& TA_CTL_BUSY
) == 0)
1688 if (j
>= MAX_CTL_CHECK
) {
1689 if (printk_ratelimit())
1690 dev_err(&adapter
->pdev
->dev
,
1691 "failed to write through agent\n");
1696 spin_unlock(&adapter
->ahw
.mem_lock
);
1702 netxen_nic_pci_mem_read_2M(struct netxen_adapter
*adapter
,
1708 void __iomem
*mem_crb
;
1710 /* Only 64-bit aligned access */
1714 /* P3 onward, test agent base for MIU and SIU is same */
1715 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_QDR_NET
,
1716 NETXEN_ADDR_QDR_NET_MAX_P3
)) {
1717 mem_crb
= netxen_get_ioaddr(adapter
,
1718 NETXEN_CRB_QDR_NET
+MIU_TEST_AGT_BASE
);
1722 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_DDR_NET
, NETXEN_ADDR_DDR_NET_MAX
)) {
1723 mem_crb
= netxen_get_ioaddr(adapter
,
1724 NETXEN_CRB_DDR_NET
+MIU_TEST_AGT_BASE
);
1728 if (ADDR_IN_RANGE(off
, NETXEN_ADDR_OCM0
, NETXEN_ADDR_OCM0_MAX
)) {
1729 return netxen_nic_pci_mem_access_direct(adapter
,
1736 off8
= off
& 0xfffffff8;
1738 spin_lock(&adapter
->ahw
.mem_lock
);
1740 writel(off8
, (mem_crb
+ MIU_TEST_AGT_ADDR_LO
));
1741 writel(0, (mem_crb
+ MIU_TEST_AGT_ADDR_HI
));
1742 writel(TA_CTL_ENABLE
, (mem_crb
+ TEST_AGT_CTRL
));
1743 writel((TA_CTL_START
| TA_CTL_ENABLE
), (mem_crb
+ TEST_AGT_CTRL
));
1745 for (j
= 0; j
< MAX_CTL_CHECK
; j
++) {
1746 temp
= readl(mem_crb
+ TEST_AGT_CTRL
);
1747 if ((temp
& TA_CTL_BUSY
) == 0)
1751 if (j
>= MAX_CTL_CHECK
) {
1752 if (printk_ratelimit())
1753 dev_err(&adapter
->pdev
->dev
,
1754 "failed to read through agent\n");
1757 val
= (u64
)(readl(mem_crb
+ MIU_TEST_AGT_RDDATA_HI
)) << 32;
1758 val
|= readl(mem_crb
+ MIU_TEST_AGT_RDDATA_LO
);
1763 spin_unlock(&adapter
->ahw
.mem_lock
);
1769 netxen_setup_hwops(struct netxen_adapter
*adapter
)
1771 adapter
->init_port
= netxen_niu_xg_init_port
;
1772 adapter
->stop_port
= netxen_niu_disable_xg_port
;
1774 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
1775 adapter
->crb_read
= netxen_nic_hw_read_wx_128M
,
1776 adapter
->crb_write
= netxen_nic_hw_write_wx_128M
,
1777 adapter
->pci_set_window
= netxen_nic_pci_set_window_128M
,
1778 adapter
->pci_mem_read
= netxen_nic_pci_mem_read_128M
,
1779 adapter
->pci_mem_write
= netxen_nic_pci_mem_write_128M
,
1780 adapter
->io_read
= netxen_nic_io_read_128M
,
1781 adapter
->io_write
= netxen_nic_io_write_128M
,
1783 adapter
->macaddr_set
= netxen_p2_nic_set_mac_addr
;
1784 adapter
->set_multi
= netxen_p2_nic_set_multi
;
1785 adapter
->set_mtu
= netxen_nic_set_mtu_xgb
;
1786 adapter
->set_promisc
= netxen_p2_nic_set_promisc
;
1789 adapter
->crb_read
= netxen_nic_hw_read_wx_2M
,
1790 adapter
->crb_write
= netxen_nic_hw_write_wx_2M
,
1791 adapter
->pci_set_window
= netxen_nic_pci_set_window_2M
,
1792 adapter
->pci_mem_read
= netxen_nic_pci_mem_read_2M
,
1793 adapter
->pci_mem_write
= netxen_nic_pci_mem_write_2M
,
1794 adapter
->io_read
= netxen_nic_io_read_2M
,
1795 adapter
->io_write
= netxen_nic_io_write_2M
,
1797 adapter
->set_mtu
= nx_fw_cmd_set_mtu
;
1798 adapter
->set_promisc
= netxen_p3_nic_set_promisc
;
1799 adapter
->macaddr_set
= netxen_p3_nic_set_mac_addr
;
1800 adapter
->set_multi
= netxen_p3_nic_set_multi
;
1802 adapter
->phy_read
= nx_fw_cmd_query_phy
;
1803 adapter
->phy_write
= nx_fw_cmd_set_phy
;
1807 int netxen_nic_get_board_info(struct netxen_adapter
*adapter
)
1809 int offset
, board_type
, magic
;
1810 struct pci_dev
*pdev
= adapter
->pdev
;
1812 offset
= NX_FW_MAGIC_OFFSET
;
1813 if (netxen_rom_fast_read(adapter
, offset
, &magic
))
1816 if (magic
!= NETXEN_BDINFO_MAGIC
) {
1817 dev_err(&pdev
->dev
, "invalid board config, magic=%08x\n",
1822 offset
= NX_BRDTYPE_OFFSET
;
1823 if (netxen_rom_fast_read(adapter
, offset
, &board_type
))
1826 if (board_type
== NETXEN_BRDTYPE_P3_4_GB_MM
) {
1827 u32 gpio
= NXRD32(adapter
, NETXEN_ROMUSB_GLB_PAD_GPIO_I
);
1828 if ((gpio
& 0x8000) == 0)
1829 board_type
= NETXEN_BRDTYPE_P3_10G_TP
;
1832 adapter
->ahw
.board_type
= board_type
;
1834 switch (board_type
) {
1835 case NETXEN_BRDTYPE_P2_SB35_4G
:
1836 adapter
->ahw
.port_type
= NETXEN_NIC_GBE
;
1838 case NETXEN_BRDTYPE_P2_SB31_10G
:
1839 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ
:
1840 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ
:
1841 case NETXEN_BRDTYPE_P2_SB31_10G_CX4
:
1842 case NETXEN_BRDTYPE_P3_HMEZ
:
1843 case NETXEN_BRDTYPE_P3_XG_LOM
:
1844 case NETXEN_BRDTYPE_P3_10G_CX4
:
1845 case NETXEN_BRDTYPE_P3_10G_CX4_LP
:
1846 case NETXEN_BRDTYPE_P3_IMEZ
:
1847 case NETXEN_BRDTYPE_P3_10G_SFP_PLUS
:
1848 case NETXEN_BRDTYPE_P3_10G_SFP_CT
:
1849 case NETXEN_BRDTYPE_P3_10G_SFP_QT
:
1850 case NETXEN_BRDTYPE_P3_10G_XFP
:
1851 case NETXEN_BRDTYPE_P3_10000_BASE_T
:
1852 adapter
->ahw
.port_type
= NETXEN_NIC_XGBE
;
1854 case NETXEN_BRDTYPE_P1_BD
:
1855 case NETXEN_BRDTYPE_P1_SB
:
1856 case NETXEN_BRDTYPE_P1_SMAX
:
1857 case NETXEN_BRDTYPE_P1_SOCK
:
1858 case NETXEN_BRDTYPE_P3_REF_QG
:
1859 case NETXEN_BRDTYPE_P3_4_GB
:
1860 case NETXEN_BRDTYPE_P3_4_GB_MM
:
1861 adapter
->ahw
.port_type
= NETXEN_NIC_GBE
;
1863 case NETXEN_BRDTYPE_P3_10G_TP
:
1864 adapter
->ahw
.port_type
= (adapter
->portnum
< 2) ?
1865 NETXEN_NIC_XGBE
: NETXEN_NIC_GBE
;
1868 dev_err(&pdev
->dev
, "unknown board type %x\n", board_type
);
1869 adapter
->ahw
.port_type
= NETXEN_NIC_XGBE
;
1876 /* NIU access sections */
1877 static int netxen_nic_set_mtu_xgb(struct netxen_adapter
*adapter
, int new_mtu
)
1879 new_mtu
+= MTU_FUDGE_FACTOR
;
1880 if (adapter
->physical_port
== 0)
1881 NXWR32(adapter
, NETXEN_NIU_XGE_MAX_FRAME_SIZE
, new_mtu
);
1883 NXWR32(adapter
, NETXEN_NIU_XG1_MAX_FRAME_SIZE
, new_mtu
);
1887 void netxen_nic_set_link_parameters(struct netxen_adapter
*adapter
)
1893 if (!netif_carrier_ok(adapter
->netdev
)) {
1894 adapter
->link_speed
= 0;
1895 adapter
->link_duplex
= -1;
1896 adapter
->link_autoneg
= AUTONEG_ENABLE
;
1900 if (adapter
->ahw
.port_type
== NETXEN_NIC_GBE
) {
1901 port_mode
= NXRD32(adapter
, NETXEN_PORT_MODE_ADDR
);
1902 if (port_mode
== NETXEN_PORT_MODE_802_3_AP
) {
1903 adapter
->link_speed
= SPEED_1000
;
1904 adapter
->link_duplex
= DUPLEX_FULL
;
1905 adapter
->link_autoneg
= AUTONEG_DISABLE
;
1909 if (adapter
->phy_read
&&
1910 adapter
->phy_read(adapter
,
1911 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS
,
1913 if (netxen_get_phy_link(status
)) {
1914 switch (netxen_get_phy_speed(status
)) {
1916 adapter
->link_speed
= SPEED_10
;
1919 adapter
->link_speed
= SPEED_100
;
1922 adapter
->link_speed
= SPEED_1000
;
1925 adapter
->link_speed
= 0;
1928 switch (netxen_get_phy_duplex(status
)) {
1930 adapter
->link_duplex
= DUPLEX_HALF
;
1933 adapter
->link_duplex
= DUPLEX_FULL
;
1936 adapter
->link_duplex
= -1;
1939 if (adapter
->phy_read
&&
1940 adapter
->phy_read(adapter
,
1941 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG
,
1943 adapter
->link_autoneg
= autoneg
;
1948 adapter
->link_speed
= 0;
1949 adapter
->link_duplex
= -1;
1955 netxen_nic_wol_supported(struct netxen_adapter
*adapter
)
1959 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
))
1962 wol_cfg
= NXRD32(adapter
, NETXEN_WOL_CONFIG_NV
);
1963 if (wol_cfg
& (1UL << adapter
->portnum
)) {
1964 wol_cfg
= NXRD32(adapter
, NETXEN_WOL_CONFIG
);
1965 if (wol_cfg
& (1 << adapter
->portnum
))