blob: 42a64248ad86a374e68638cd1b1fa6ba9b87b975 [file] [log] [blame]
wdenk7152b1d2003-09-05 23:19:14 +00001/******************************************************************************
2 *
3 * Name: skgeinit.c
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.85 $
6 * Date: $Date: 2003/02/05 15:30:33 $
7 * Purpose: Contains functions to initialize the GE HW
8 *
9 ******************************************************************************/
10
11/******************************************************************************
12 *
13 * (C)Copyright 1998-2003 SysKonnect GmbH.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * The information in this file is provided "AS IS" without warranty.
21 *
22 ******************************************************************************/
23
24/******************************************************************************
25 *
26 * History:
27 *
28 * $Log: skgeinit.c,v $
29 * Revision 1.85 2003/02/05 15:30:33 rschmidt
30 * Corrected setting of GIHstClkFact (Host Clock Factor) and
31 * GIPollTimerVal (Descr. Poll Timer Init Value) for YUKON.
32 * Editorial changes.
33 *
34 * Revision 1.84 2003/01/28 09:57:25 rschmidt
35 * Added detection of YUKON-Lite Rev. A0 (stored in GIYukonLite).
36 * Disabled Rx GMAC FIFO Flush for YUKON-Lite Rev. A0.
37 * Added support for CLK_RUN (YUKON-Lite).
38 * Added additional check of PME from D3cold for setting GIVauxAvail.
39 * Editorial changes.
40 *
41 * Revision 1.83 2002/12/17 16:15:41 rschmidt
42 * Added default setting of PhyType (Copper) for YUKON.
43 * Added define around check for HW self test results.
44 * Editorial changes.
45 *
46 * Revision 1.82 2002/12/05 13:40:21 rschmidt
47 * Added setting of Rx GMAC FIFO Flush Mask register.
48 * Corrected PhyType with new define SK_PHY_MARV_FIBER when
49 * YUKON Fiber board was found.
50 * Editorial changes.
51 *
52 * Revision 1.81 2002/11/15 12:48:35 rschmidt
53 * Replaced message SKERR_HWI_E018 with SKERR_HWI_E024 for Rx queue error
54 * in SkGeStopPort().
55 * Added init for pAC->GIni.GIGenesis with SK_FALSE in YUKON-branch.
56 * Editorial changes.
57 *
58 * Revision 1.80 2002/11/12 17:28:30 rschmidt
59 * Initialized GIPciSlot64 and GIPciClock66 in SkGeInit1().
60 * Reduced PCI FIFO watermarks for 32bit/33MHz bus in SkGeInitBmu().
61 * Editorial changes.
62 *
63 * Revision 1.79 2002/10/21 09:31:02 mkarl
64 * Changed SkGeInitAssignRamToQueues(), removed call to
65 * SkGeInitAssignRamToQueues in SkGeInit1 and fixed compiler warning in
66 * SkGeInit1.
67 *
68 * Revision 1.78 2002/10/16 15:55:07 mkarl
69 * Fixed a bug in SkGeInitAssignRamToQueues.
70 *
71 * Revision 1.77 2002/10/14 15:07:22 rschmidt
72 * Corrected timeout handling for Rx queue in SkGeStopPort() (#10748)
73 * Editorial changes.
74 *
75 * Revision 1.76 2002/10/11 09:24:38 mkarl
76 * Added check for HW self test results.
77 *
78 * Revision 1.75 2002/10/09 16:56:44 mkarl
79 * Now call SkGeInitAssignRamToQueues() in Init Level 1 in order to assign
80 * the adapter memory to the queues. This default assignment is not suitable
81 * for dual net mode.
82 *
83 * Revision 1.74 2002/09/12 08:45:06 rwahl
84 * Set defaults for PMSCap, PLinkSpeed & PLinkSpeedCap dependent on PHY.
85 *
86 * Revision 1.73 2002/08/16 15:19:45 rschmidt
87 * Corrected check for Tx queues in SkGeCheckQSize().
88 * Added init for new entry GIGenesis and GICopperType
89 * Replaced all if(GIChipId == CHIP_ID_GENESIS) with new entry GIGenesis.
90 * Replaced wrong 1st para pAC with IoC in SK_IN/OUT macros.
91 *
92 * Revision 1.72 2002/08/12 13:38:55 rschmidt
93 * Added check if VAUX is available (stored in GIVauxAvail)
94 * Initialized PLinkSpeedCap in Port struct with SK_LSPEED_CAP_1000MBPS
95 * Editorial changes.
96 *
97 * Revision 1.71 2002/08/08 16:32:58 rschmidt
98 * Added check for Tx queues in SkGeCheckQSize().
99 * Added start of Time Stamp Timer (YUKON) in SkGeInit2().
100 * Editorial changes.
101 *
102 * Revision 1.70 2002/07/23 16:04:26 rschmidt
103 * Added init for GIWolOffs (HW-Bug in YUKON 1st rev.)
104 * Minor changes
105 *
106 * Revision 1.69 2002/07/17 17:07:08 rwahl
107 * - SkGeInit1(): fixed PHY type debug output; corrected init of GIFunc
108 * table & GIMacType.
109 * - Editorial changes.
110 *
111 * Revision 1.68 2002/07/15 18:38:31 rwahl
112 * Added initialization for MAC type dependent function table.
113 *
114 * Revision 1.67 2002/07/15 15:45:39 rschmidt
115 * Added Tx Store & Forward for YUKON (GMAC Tx FIFO is only 1 kB)
116 * Replaced SK_PHY_MARV by SK_PHY_MARV_COPPER
117 * Editorial changes
118 *
119 * Revision 1.66 2002/06/10 09:35:08 rschmidt
120 * Replaced C++ comments (//)
121 * Editorial changes
122 *
123 * Revision 1.65 2002/06/05 08:33:37 rschmidt
124 * Changed GIRamSize and Reset sequence for YUKON.
125 * SkMacInit() replaced by SkXmInitMac() resp. SkGmInitMac()
126 *
127 * Revision 1.64 2002/04/25 13:03:20 rschmidt
128 * Changes for handling YUKON.
129 * Removed reference to xmac_ii.h (not necessary).
130 * Moved all defines into header file.
131 * Replaced all SkXm...() functions with SkMac...() to handle also
132 * YUKON's GMAC.
133 * Added handling for GMAC FIFO in SkGeInitMacFifo(), SkGeStopPort().
134 * Removed 'goto'-directive from SkGeCfgSync(), SkGeCheckQSize().
135 * Replaced all XMAC-access macros by functions: SkMacRxTxDisable(),
136 * SkMacFlushTxFifo().
137 * Optimized timeout handling in SkGeStopPort().
138 * Initialized PLinkSpeed in Port struct with SK_LSPEED_AUTO.
139 * Release of GMAC Link Control reset in SkGeInit1().
140 * Initialized GIChipId and GIChipRev in GE Init structure.
141 * Added GIRamSize and PhyType values for YUKON.
142 * Removed use of PRxCmd to setup XMAC.
143 * Moved setting of XM_RX_DIS_CEXT to SkXmInitMac().
144 * Use of SkGeXmitLED() only for GENESIS.
145 * Changes for V-CPU support.
146 * Editorial changes.
147 *
148 * Revision 1.63 2001/04/05 11:02:09 rassmann
149 * Stop Port check of the STOP bit did not take 2/18 sec as wanted.
150 *
151 * Revision 1.62 2001/02/07 07:54:21 rassmann
152 * Corrected copyright.
153 *
154 * Revision 1.61 2001/01/31 15:31:40 gklug
155 * fix: problem with autosensing an SR8800 switch
156 *
157 * Revision 1.60 2000/10/18 12:22:21 cgoos
158 * Added workaround for half duplex hangup.
159 *
160 * Revision 1.59 2000/10/10 11:22:06 gklug
161 * add: in manual half duplex mode ignore carrier extension errors
162 *
163 * Revision 1.58 2000/10/02 14:10:27 rassmann
164 * Reading BCOM PHY after releasing reset until it returns a valid value.
165 *
166 * Revision 1.57 2000/08/03 14:55:28 rassmann
167 * Waiting for I2C to be ready before de-initializing adapter
168 * (prevents sensors from hanging up).
169 *
170 * Revision 1.56 2000/07/27 12:16:48 gklug
171 * fix: Stop Port check of the STOP bit does now take 2/18 sec as wanted
172 *
173 * Revision 1.55 1999/11/22 13:32:26 cgoos
174 * Changed license header to GPL.
175 *
176 * Revision 1.54 1999/10/26 07:32:54 malthoff
177 * Initialize PHWLinkUp with SK_FALSE. Required for Diagnostics.
178 *
179 * Revision 1.53 1999/08/12 19:13:50 malthoff
180 * Fix for 1000BT. Do not owerwrite XM_MMU_CMD when
181 * disabling receiver and transmitter. Other bits
182 * may be lost.
183 *
184 * Revision 1.52 1999/07/01 09:29:54 gklug
185 * fix: DoInitRamQueue needs pAC
186 *
187 * Revision 1.51 1999/07/01 08:42:21 gklug
188 * chg: use Store & forward for RAM buffer when Jumbos are used
189 *
190 * Revision 1.50 1999/05/27 13:19:38 cgoos
191 * Added Tx PCI watermark initialization.
192 * Removed Tx RAM queue Store & Forward setting.
193 *
194 * Revision 1.49 1999/05/20 14:32:45 malthoff
195 * SkGeLinkLED() is completly removed now.
196 *
197 * Revision 1.48 1999/05/19 07:28:24 cgoos
198 * SkGeLinkLED no more available for drivers.
199 * Changes for 1000Base-T.
200 *
201 * Revision 1.47 1999/04/08 13:57:45 gklug
202 * add: Init of new port struct fiels PLinkResCt
203 * chg: StopPort Timer check
204 *
205 * Revision 1.46 1999/03/25 07:42:15 malthoff
206 * SkGeStopPort(): Add workaround for cache incoherency.
207 * Create error log entry, disable port, and
208 * exit loop if it does not terminate.
209 * Add XM_RX_LENERR_OK to the default value for the
210 * XMAC receive command register.
211 *
212 * Revision 1.45 1999/03/12 16:24:47 malthoff
213 * Remove PPollRxD and PPollTxD.
214 * Add check for GIPollTimerVal.
215 *
216 * Revision 1.44 1999/03/12 13:40:23 malthoff
217 * Fix: SkGeXmitLED(), SK_LED_TST mode does not work.
218 * Add: Jumbo frame support.
219 * Chg: Resolution of parameter IntTime in SkGeCfgSync().
220 *
221 * Revision 1.43 1999/02/09 10:29:46 malthoff
222 * Bugfix: The previous modification again also for the second location.
223 *
224 * Revision 1.42 1999/02/09 09:35:16 malthoff
225 * Bugfix: The bits '66 MHz Capable' and 'NEWCAP are reset while
226 * clearing the error bits in the PCI status register.
227 *
228 * Revision 1.41 1999/01/18 13:07:02 malthoff
229 * Bugfix: Do not use CFG cycles after during Init- or Runtime, because
230 * they may not be available after Boottime.
231 *
232 * Revision 1.40 1999/01/11 12:40:49 malthoff
233 * Bug fix: PCI_STATUS: clearing error bits sets the UDF bit.
234 *
235 * Revision 1.39 1998/12/11 15:17:33 gklug
236 * chg: Init LipaAutoNeg with Unknown
237 *
238 * Revision 1.38 1998/12/10 11:02:57 malthoff
239 * Disable Error Log Message when calling SkGeInit(level 2)
240 * more than once.
241 *
242 * Revision 1.37 1998/12/07 12:18:25 gklug
243 * add: refinement of autosense mode: take into account the autoneg cap of LiPa
244 *
245 * Revision 1.36 1998/12/07 07:10:39 gklug
246 * fix: init values of LinkBroken/ Capabilities for management
247 *
248 * Revision 1.35 1998/12/02 10:56:20 gklug
249 * fix: do NOT init LoinkSync Counter.
250 *
251 * Revision 1.34 1998/12/01 10:53:21 gklug
252 * add: init of additional Counters for workaround
253 *
254 * Revision 1.33 1998/12/01 10:00:49 gklug
255 * add: init PIsave var in Port struct
256 *
257 * Revision 1.32 1998/11/26 14:50:40 gklug
258 * chg: Default is autosensing with AUTOFULL mode
259 *
260 * Revision 1.31 1998/11/25 15:36:16 gklug
261 * fix: do NOT stop LED Timer when port should be stopped
262 *
263 * Revision 1.30 1998/11/24 13:15:28 gklug
264 * add: Init PCkeckPar struct member
265 *
266 * Revision 1.29 1998/11/18 13:19:27 malthoff
267 * Disable packet arbiter timeouts on receive side.
268 * Use maximum timeout value for packet arbiter
269 * transmit timeouts.
270 * Add TestStopBit() function to handle stop RX/TX
271 * problem with active descriptor poll timers.
272 * Bug Fix: Descriptor Poll Timer not started, because
273 * GIPollTimerVal was initialized with 0.
274 *
275 * Revision 1.28 1998/11/13 14:24:26 malthoff
276 * Bug Fix: SkGeStopPort() may hang if a Packet Arbiter Timout
277 * is pending or occurs while waiting for TX_STOP and RX_STOP.
278 * The PA timeout is cleared now while waiting for TX- or RX_STOP.
279 *
280 * Revision 1.27 1998/11/02 11:04:36 malthoff
281 * fix the last fix
282 *
283 * Revision 1.26 1998/11/02 10:37:03 malthoff
284 * Fix: SkGePollTxD() enables always the synchronounous poll timer.
285 *
286 * Revision 1.25 1998/10/28 07:12:43 cgoos
287 * Fixed "LED_STOP" in SkGeLnkSyncCnt, "== SK_INIT_IO" in SkGeInit.
288 * Removed: Reset of RAM Interface in SkGeStopPort.
289 *
290 * Revision 1.24 1998/10/27 08:13:12 malthoff
291 * Remove temporary code.
292 *
293 * Revision 1.23 1998/10/26 07:45:03 malthoff
294 * Add Address Calculation Workaround: If the EPROM byte
295 * Id is 3, the address offset is 512 kB.
296 * Initialize default values for PLinkMode and PFlowCtrlMode.
297 *
298 * Revision 1.22 1998/10/22 09:46:47 gklug
299 * fix SysKonnectFileId typo
300 *
301 * Revision 1.21 1998/10/20 12:11:56 malthoff
302 * Don't dendy the Queue config if the size of the unused
303 * Rx qeueu is zero.
304 *
305 * Revision 1.20 1998/10/19 07:27:58 malthoff
306 * SkGeInitRamIface() is public to be called by diagnostics.
307 *
308 * Revision 1.19 1998/10/16 13:33:45 malthoff
309 * Fix: enabling descriptor polling is not allowed until
310 * the descriptor addresses are set. Descriptor polling
311 * must be handled by the driver.
312 *
313 * Revision 1.18 1998/10/16 10:58:27 malthoff
314 * Remove temp. code for Diag prototype.
315 * Remove lint warning for dummy reads.
316 * Call SkGeLoadLnkSyncCnt() during SkGeInitPort().
317 *
318 * Revision 1.17 1998/10/14 09:16:06 malthoff
319 * Change parameter LimCount and programming of
320 * the limit counter in SkGeCfgSync().
321 *
322 * Revision 1.16 1998/10/13 09:21:16 malthoff
323 * Don't set XM_RX_SELF_RX in RxCmd Reg, because it's
324 * like a Loopback Mode in half duplex.
325 *
326 * Revision 1.15 1998/10/09 06:47:40 malthoff
327 * SkGeInitMacArb(): set recovery counters init value
328 * to zero although this counters are not uesd.
329 * Bug fix in Rx Upper/Lower Pause Threshold calculation.
330 * Add XM_RX_SELF_RX to RxCmd.
331 *
332 * Revision 1.14 1998/10/06 15:15:53 malthoff
333 * Make sure no pending IRQ is cleared in SkGeLoadLnkSyncCnt().
334 *
335 * Revision 1.13 1998/10/06 14:09:36 malthoff
336 * Add SkGeLoadLnkSyncCnt(). Modify
337 * the 'port stopped' condition according
338 * to the current problem report.
339 *
340 * Revision 1.12 1998/10/05 08:17:21 malthoff
341 * Add functions: SkGePollRxD(), SkGePollTxD(),
342 * DoCalcAddr(), SkGeCheckQSize(),
343 * DoInitRamQueue(), and SkGeCfgSync().
344 * Add coding for SkGeInitMacArb(), SkGeInitPktArb(),
345 * SkGeInitMacFifo(), SkGeInitRamBufs(),
346 * SkGeInitRamIface(), and SkGeInitBmu().
347 *
348 * Revision 1.11 1998/09/29 08:26:29 malthoff
349 * bug fix: SkGeInit0() 'i' should be increment.
350 *
351 * Revision 1.10 1998/09/28 13:19:01 malthoff
352 * Coding time: Save the done work.
353 * Modify SkGeLinkLED(), add SkGeXmitLED(),
354 * define SkGeCheckQSize(), SkGeInitMacArb(),
355 * SkGeInitPktArb(), SkGeInitMacFifo(),
356 * SkGeInitRamBufs(), SkGeInitRamIface(),
357 * and SkGeInitBmu(). Do coding for SkGeStopPort(),
358 * SkGeInit1(), SkGeInit2(), and SkGeInit3().
359 * Do coding for SkGeDinit() and SkGeInitPort().
360 *
361 * Revision 1.9 1998/09/16 14:29:05 malthoff
362 * Some minor changes.
363 *
364 * Revision 1.8 1998/09/11 05:29:14 gklug
365 * add: init state of a port
366 *
367 * Revision 1.7 1998/09/04 09:26:25 malthoff
368 * Short temporary modification.
369 *
370 * Revision 1.6 1998/09/04 08:27:59 malthoff
371 * Remark the do-while in StopPort() because it never ends
372 * without a GE adapter.
373 *
374 * Revision 1.5 1998/09/03 14:05:45 malthoff
375 * Change comment for SkGeInitPort(). Do not
376 * repair the queue sizes if invalid.
377 *
378 * Revision 1.4 1998/09/03 10:03:19 malthoff
379 * Implement the new interface according to the
380 * reviewed interface specification.
381 *
382 * Revision 1.3 1998/08/19 09:11:25 gklug
383 * fix: struct are removed from c-source (see CCC)
384 *
385 * Revision 1.2 1998/07/28 12:33:58 malthoff
386 * Add 'IoC' parameter in function declaration and SK IO macros.
387 *
388 * Revision 1.1 1998/07/23 09:48:57 malthoff
389 * Creation. First dummy 'C' file.
390 * SkGeInit(Level 0) is card_start for GE.
391 * SkGeDeInit() is card_stop for GE.
392 *
393 *
394 ******************************************************************************/
395
396#include "h/skdrv1st.h"
397#include "h/skdrv2nd.h"
398
399/* global variables ***********************************************************/
400
401/* local variables ************************************************************/
402
403static const char SysKonnectFileId[] =
404 "@(#)$Id: skgeinit.c,v 1.85 2003/02/05 15:30:33 rschmidt Exp $ (C) SK ";
405
406struct s_QOffTab {
407 int RxQOff; /* Receive Queue Address Offset */
408 int XsQOff; /* Sync Tx Queue Address Offset */
409 int XaQOff; /* Async Tx Queue Address Offset */
410};
411static struct s_QOffTab QOffTab[] = {
412 {Q_R1, Q_XS1, Q_XA1}, {Q_R2, Q_XS2, Q_XA2}
413};
414
415
416/******************************************************************************
417 *
418 * SkGePollRxD() - Enable / Disable Descriptor Polling of RxD Ring
419 *
420 * Description:
421 * Enable or disable the descriptor polling of the receive descriptor
422 * ring (RxD) for port 'Port'.
423 * The new configuration is *not* saved over any SkGeStopPort() and
424 * SkGeInitPort() calls.
425 *
426 * Returns:
427 * nothing
428 */
429void SkGePollRxD(
430SK_AC *pAC, /* adapter context */
431SK_IOC IoC, /* IO context */
432int Port, /* Port Index (MAC_1 + n) */
433SK_BOOL PollRxD) /* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */
434{
435 SK_GEPORT *pPrt;
436
437 pPrt = &pAC->GIni.GP[Port];
438
439 SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), (PollRxD) ?
440 CSR_ENA_POL : CSR_DIS_POL);
441} /* SkGePollRxD */
442
443
444/******************************************************************************
445 *
446 * SkGePollTxD() - Enable / Disable Descriptor Polling of TxD Rings
447 *
448 * Description:
449 * Enable or disable the descriptor polling of the transmit descriptor
450 * ring(s) (TxD) for port 'Port'.
451 * The new configuration is *not* saved over any SkGeStopPort() and
452 * SkGeInitPort() calls.
453 *
454 * Returns:
455 * nothing
456 */
457void SkGePollTxD(
458SK_AC *pAC, /* adapter context */
459SK_IOC IoC, /* IO context */
460int Port, /* Port Index (MAC_1 + n) */
461SK_BOOL PollTxD) /* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */
462{
463 SK_GEPORT *pPrt;
464 SK_U32 DWord;
465
466 pPrt = &pAC->GIni.GP[Port];
467
468 DWord = (PollTxD) ? CSR_ENA_POL : CSR_DIS_POL;
469
470 if (pPrt->PXSQSize != 0) {
471 SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), DWord);
472 }
473
474 if (pPrt->PXAQSize != 0) {
475 SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), DWord);
476 }
477} /* SkGePollTxD */
478
479
480/******************************************************************************
481 *
482 * SkGeYellowLED() - Switch the yellow LED on or off.
483 *
484 * Description:
485 * Switch the yellow LED on or off.
486 *
487 * Note:
488 * This function may be called any time after SkGeInit(Level 1).
489 *
490 * Returns:
491 * nothing
492 */
493void SkGeYellowLED(
494SK_AC *pAC, /* adapter context */
495SK_IOC IoC, /* IO context */
496int State) /* yellow LED state, 0 = OFF, 0 != ON */
497{
498 if (State == 0) {
499 /* Switch yellow LED OFF */
500 SK_OUT8(IoC, B0_LED, LED_STAT_OFF);
501 }
502 else {
503 /* Switch yellow LED ON */
504 SK_OUT8(IoC, B0_LED, LED_STAT_ON);
505 }
506} /* SkGeYellowLED */
507
508
509/******************************************************************************
510 *
511 * SkGeXmitLED() - Modify the Operational Mode of a transmission LED.
512 *
513 * Description:
514 * The Rx or Tx LED which is specified by 'Led' will be
515 * enabled, disabled or switched on in test mode.
516 *
517 * Note:
518 * 'Led' must contain the address offset of the LEDs INI register.
519 *
520 * Usage:
521 * SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_ENA);
522 *
523 * Returns:
524 * nothing
525 */
526void SkGeXmitLED(
527SK_AC *pAC, /* adapter context */
528SK_IOC IoC, /* IO context */
529int Led, /* offset to the LED Init Value register */
530int Mode) /* Mode may be SK_LED_DIS, SK_LED_ENA, SK_LED_TST */
531{
532 SK_U32 LedIni;
533
534 switch (Mode) {
535 case SK_LED_ENA:
536 LedIni = SK_XMIT_DUR * (SK_U32)pAC->GIni.GIHstClkFact / 100;
537 SK_OUT32(IoC, Led + XMIT_LED_INI, LedIni);
538 SK_OUT8(IoC, Led + XMIT_LED_CTRL, LED_START);
539 break;
540 case SK_LED_TST:
541 SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_ON);
542 SK_OUT32(IoC, Led + XMIT_LED_CNT, 100);
543 SK_OUT8(IoC, Led + XMIT_LED_CTRL, LED_START);
544 break;
545 case SK_LED_DIS:
546 default:
547 /*
548 * Do NOT stop the LED Timer here. The LED might be
549 * in on state. But it needs to go off.
550 */
551 SK_OUT32(IoC, Led + XMIT_LED_CNT, 0);
552 SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_OFF);
553 break;
554 }
555
556 /*
557 * 1000BT: The Transmit LED is driven by the PHY.
558 * But the default LED configuration is used for
559 * Level One and Broadcom PHYs.
560 * (Broadcom: It may be that PHY_B_PEC_EN_LTR has to be set.)
561 * (In this case it has to be added here. But we will see. XXX)
562 */
563} /* SkGeXmitLED */
564
565
566/******************************************************************************
567 *
568 * DoCalcAddr() - Calculates the start and the end address of a queue.
569 *
570 * Description:
571 * This function calculates the start and the end address of a queue.
572 * Afterwards the 'StartVal' is incremented to the next start position.
573 * If the port is already initialized the calculated values
574 * will be checked against the configured values and an
575 * error will be returned, if they are not equal.
576 * If the port is not initialized the values will be written to
577 * *StartAdr and *EndAddr.
578 *
579 * Returns:
580 * 0: success
581 * 1: configuration error
582 */
583static int DoCalcAddr(
584SK_AC *pAC, /* adapter context */
585SK_GEPORT *pPrt, /* port index */
586int QuSize, /* size of the queue to configure in kB */
587SK_U32 *StartVal, /* start value for address calculation */
588SK_U32 *QuStartAddr, /* start addr to calculate */
589SK_U32 *QuEndAddr) /* end address to calculate */
590{
591 SK_U32 EndVal;
592 SK_U32 NextStart;
593 int Rtv;
594
595 Rtv = 0;
596 if (QuSize == 0) {
597 EndVal = *StartVal;
598 NextStart = EndVal;
599 }
600 else {
601 EndVal = *StartVal + ((SK_U32)QuSize * 1024) - 1;
602 NextStart = EndVal + 1;
603 }
604
605 if (pPrt->PState >= SK_PRT_INIT) {
606 if (*StartVal != *QuStartAddr || EndVal != *QuEndAddr) {
607 Rtv = 1;
608 }
609 }
610 else {
611 *QuStartAddr = *StartVal;
612 *QuEndAddr = EndVal;
613 }
614
615 *StartVal = NextStart;
616 return(Rtv);
617} /* DoCalcAddr */
618
619/******************************************************************************
620 *
621 * SkGeInitAssignRamToQueues() - allocate default queue sizes
622 *
623 * Description:
624 * This function assigns the memory to the different queues and ports.
625 * When DualNet is set to SK_TRUE all ports get the same amount of memory.
626 * Otherwise the first port gets most of the memory and all the
627 * other ports just the required minimum.
628 * This function can only be called when pAC->GIni.GIRamSize and
629 * pAC->GIni.GIMacsFound have been initialized, usually this happens
630 * at init level 1
631 *
632 * Returns:
633 * 0 - ok
634 * 1 - invalid input values
635 * 2 - not enough memory
636 */
637
638int SkGeInitAssignRamToQueues(
639SK_AC *pAC, /* Adapter context */
640int ActivePort, /* Active Port in RLMT mode */
641SK_BOOL DualNet) /* adapter context */
642{
643 int i;
644 int UsedKilobytes; /* memory already assigned */
645 int ActivePortKilobytes; /* memory available for active port */
646 SK_GEPORT *pGePort;
647
648 UsedKilobytes = 0;
649
650 if (ActivePort >= pAC->GIni.GIMacsFound) {
651 SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
652 ("SkGeInitAssignRamToQueues: ActivePort (%d) invalid\n",
653 ActivePort));
654 return(1);
655 }
656 if (((pAC->GIni.GIMacsFound * (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE)) +
657 ((RAM_QUOTA_SYNC == 0) ? 0 : SK_MIN_TXQ_SIZE)) > pAC->GIni.GIRamSize) {
658 SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
659 ("SkGeInitAssignRamToQueues: Not enough memory (%d)\n",
660 pAC->GIni.GIRamSize));
661 return(2);
662 }
663
664
665 if (DualNet) {
666 /* every port gets the same amount of memory */
667 ActivePortKilobytes = pAC->GIni.GIRamSize / pAC->GIni.GIMacsFound;
668 for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
669
670 pGePort = &pAC->GIni.GP[i];
671
672 /* take away the minimum memory for active queues */
673 ActivePortKilobytes -= (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE);
674
675 /* receive queue gets the minimum + 80% of the rest */
676 pGePort->PRxQSize = (int) (ROUND_QUEUE_SIZE_KB((
677 ActivePortKilobytes * (unsigned long) RAM_QUOTA_RX) / 100))
678 + SK_MIN_RXQ_SIZE;
679
680 ActivePortKilobytes -= (pGePort->PRxQSize - SK_MIN_RXQ_SIZE);
681
682 /* synchronous transmit queue */
683 pGePort->PXSQSize = 0;
684
685 /* asynchronous transmit queue */
686 pGePort->PXAQSize = (int) ROUND_QUEUE_SIZE_KB(ActivePortKilobytes +
687 SK_MIN_TXQ_SIZE);
688 }
689 }
690 else {
691 /* Rlmt Mode or single link adapter */
692
693 /* Set standby queue size defaults for all standby ports */
694 for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
695
696 if (i != ActivePort) {
697 pGePort = &pAC->GIni.GP[i];
698
699 pGePort->PRxQSize = SK_MIN_RXQ_SIZE;
700 pGePort->PXAQSize = SK_MIN_TXQ_SIZE;
701 pGePort->PXSQSize = 0;
702
703 /* Count used RAM */
704 UsedKilobytes += pGePort->PRxQSize + pGePort->PXAQSize;
705 }
706 }
707 /* what's left? */
708 ActivePortKilobytes = pAC->GIni.GIRamSize - UsedKilobytes;
709
710 /* assign it to the active port */
711 /* first take away the minimum memory */
712 ActivePortKilobytes -= (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE);
713 pGePort = &pAC->GIni.GP[ActivePort];
714
715 /* receive queue get's the minimum + 80% of the rest */
716 pGePort->PRxQSize = (int) (ROUND_QUEUE_SIZE_KB((ActivePortKilobytes *
717 (unsigned long) RAM_QUOTA_RX) / 100)) + SK_MIN_RXQ_SIZE;
718
719 ActivePortKilobytes -= (pGePort->PRxQSize - SK_MIN_RXQ_SIZE);
720
721 /* synchronous transmit queue */
722 pGePort->PXSQSize = 0;
723
724 /* asynchronous transmit queue */
725 pGePort->PXAQSize = (int) ROUND_QUEUE_SIZE_KB(ActivePortKilobytes) +
726 SK_MIN_TXQ_SIZE;
727 }
728#ifdef VCPU
729 VCPUprintf(0, "PRxQSize=%u, PXSQSize=%u, PXAQSize=%u\n",
730 pGePort->PRxQSize, pGePort->PXSQSize, pGePort->PXAQSize);
731#endif /* VCPU */
732
733 return(0);
734} /* SkGeInitAssignRamToQueues */
735
736/******************************************************************************
737 *
738 * SkGeCheckQSize() - Checks the Adapters Queue Size Configuration
739 *
740 * Description:
741 * This function verifies the Queue Size Configuration specified
742 * in the variables PRxQSize, PXSQSize, and PXAQSize of all
743 * used ports.
744 * This requirements must be fullfilled to have a valid configuration:
745 * - The size of all queues must not exceed GIRamSize.
746 * - The queue sizes must be specified in units of 8 kB.
747 * - The size of Rx queues of available ports must not be
748 * smaller than 16 kB.
749 * - The size of at least one Tx queue (synch. or asynch.)
750 * of available ports must not be smaller than 16 kB
751 * when Jumbo Frames are used.
752 * - The RAM start and end addresses must not be changed
753 * for ports which are already initialized.
754 * Furthermore SkGeCheckQSize() defines the Start and End Addresses
755 * of all ports and stores them into the HWAC port structure.
756 *
757 * Returns:
758 * 0: Queue Size Configuration valid
759 * 1: Queue Size Configuration invalid
760 */
761static int SkGeCheckQSize(
762SK_AC *pAC, /* adapter context */
763int Port) /* port index */
764{
765 SK_GEPORT *pPrt;
766 int UsedMem; /* total memory used (max. found ports) */
767 int i;
768 int Rtv;
769 int Rtv2;
770 SK_U32 StartAddr;
771
772 UsedMem = 0;
773 Rtv = 0;
774 for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
775 pPrt = &pAC->GIni.GP[i];
776
777 if ((pPrt->PRxQSize & QZ_UNITS) != 0 ||
778 (pPrt->PXSQSize & QZ_UNITS) != 0 ||
779 (pPrt->PXAQSize & QZ_UNITS) != 0) {
780
781 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E012, SKERR_HWI_E012MSG);
782 return(1);
783 }
784
785 if (i == Port && pPrt->PRxQSize < SK_MIN_RXQ_SIZE) {
786 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E011, SKERR_HWI_E011MSG);
787 return(1);
788 }
789
790 /*
791 * the size of at least one Tx queue (synch. or asynch.) has to be > 0.
792 * if Jumbo Frames are used, this size has to be >= 16 kB.
793 */
794 if ((i == Port && pPrt->PXSQSize == 0 && pPrt->PXAQSize == 0) ||
795 (pAC->GIni.GIPortUsage == SK_JUMBO_LINK &&
796 ((pPrt->PXSQSize > 0 && pPrt->PXSQSize < SK_MIN_TXQ_SIZE) ||
797 (pPrt->PXAQSize > 0 && pPrt->PXAQSize < SK_MIN_TXQ_SIZE)))) {
798 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E023, SKERR_HWI_E023MSG);
799 return(1);
800 }
801
802 UsedMem += pPrt->PRxQSize + pPrt->PXSQSize + pPrt->PXAQSize;
803 }
804
805 if (UsedMem > pAC->GIni.GIRamSize) {
806 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E012, SKERR_HWI_E012MSG);
807 return(1);
808 }
809
810 /* Now start address calculation */
811 StartAddr = pAC->GIni.GIRamOffs;
812 for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
813 pPrt = &pAC->GIni.GP[i];
814
815 /* Calculate/Check values for the receive queue */
816 Rtv2 = DoCalcAddr(pAC, pPrt, pPrt->PRxQSize, &StartAddr,
817 &pPrt->PRxQRamStart, &pPrt->PRxQRamEnd);
818 Rtv |= Rtv2;
819
820 /* Calculate/Check values for the synchronous Tx queue */
821 Rtv2 = DoCalcAddr(pAC, pPrt, pPrt->PXSQSize, &StartAddr,
822 &pPrt->PXsQRamStart, &pPrt->PXsQRamEnd);
823 Rtv |= Rtv2;
824
825 /* Calculate/Check values for the asynchronous Tx queue */
826 Rtv2 = DoCalcAddr(pAC, pPrt, pPrt->PXAQSize, &StartAddr,
827 &pPrt->PXaQRamStart, &pPrt->PXaQRamEnd);
828 Rtv |= Rtv2;
829
830 if (Rtv) {
831 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E013, SKERR_HWI_E013MSG);
832 return(1);
833 }
834 }
835
836 return(0);
837} /* SkGeCheckQSize */
838
839
840/******************************************************************************
841 *
842 * SkGeInitMacArb() - Initialize the MAC Arbiter
843 *
844 * Description:
845 * This function initializes the MAC Arbiter.
846 * It must not be called if there is still an
847 * initialized or active port.
848 *
849 * Returns:
850 * nothing
851 */
852static void SkGeInitMacArb(
853SK_AC *pAC, /* adapter context */
854SK_IOC IoC) /* IO context */
855{
856 /* release local reset */
857 SK_OUT16(IoC, B3_MA_TO_CTRL, MA_RST_CLR);
858
859 /* configure timeout values */
860 SK_OUT8(IoC, B3_MA_TOINI_RX1, SK_MAC_TO_53);
861 SK_OUT8(IoC, B3_MA_TOINI_RX2, SK_MAC_TO_53);
862 SK_OUT8(IoC, B3_MA_TOINI_TX1, SK_MAC_TO_53);
863 SK_OUT8(IoC, B3_MA_TOINI_TX2, SK_MAC_TO_53);
864
865 SK_OUT8(IoC, B3_MA_RCINI_RX1, 0);
866 SK_OUT8(IoC, B3_MA_RCINI_RX2, 0);
867 SK_OUT8(IoC, B3_MA_RCINI_TX1, 0);
868 SK_OUT8(IoC, B3_MA_RCINI_TX2, 0);
869
870 /* recovery values are needed for XMAC II Rev. B2 only */
871 /* Fast Output Enable Mode was intended to use with Rev. B2, but now? */
872
873 /*
874 * There is no start or enable button to push, therefore
875 * the MAC arbiter is configured and enabled now.
876 */
877} /* SkGeInitMacArb */
878
879
880/******************************************************************************
881 *
882 * SkGeInitPktArb() - Initialize the Packet Arbiter
883 *
884 * Description:
885 * This function initializes the Packet Arbiter.
886 * It must not be called if there is still an
887 * initialized or active port.
888 *
889 * Returns:
890 * nothing
891 */
892static void SkGeInitPktArb(
893SK_AC *pAC, /* adapter context */
894SK_IOC IoC) /* IO context */
895{
896 /* release local reset */
897 SK_OUT16(IoC, B3_PA_CTRL, PA_RST_CLR);
898
899 /* configure timeout values */
900 SK_OUT16(IoC, B3_PA_TOINI_RX1, SK_PKT_TO_MAX);
901 SK_OUT16(IoC, B3_PA_TOINI_RX2, SK_PKT_TO_MAX);
902 SK_OUT16(IoC, B3_PA_TOINI_TX1, SK_PKT_TO_MAX);
903 SK_OUT16(IoC, B3_PA_TOINI_TX2, SK_PKT_TO_MAX);
904
905 /*
906 * enable timeout timers if jumbo frames not used
907 * NOTE: the packet arbiter timeout interrupt is needed for
908 * half duplex hangup workaround
909 */
910 if (pAC->GIni.GIPortUsage != SK_JUMBO_LINK) {
911 if (pAC->GIni.GIMacsFound == 1) {
912 SK_OUT16(IoC, B3_PA_CTRL, PA_ENA_TO_TX1);
913 }
914 else {
915 SK_OUT16(IoC, B3_PA_CTRL, PA_ENA_TO_TX1 | PA_ENA_TO_TX2);
916 }
917 }
918} /* SkGeInitPktArb */
919
920
921/******************************************************************************
922 *
923 * SkGeInitMacFifo() - Initialize the MAC FIFOs
924 *
925 * Description:
926 * Initialize all MAC FIFOs of the specified port
927 *
928 * Returns:
929 * nothing
930 */
931static void SkGeInitMacFifo(
932SK_AC *pAC, /* adapter context */
933SK_IOC IoC, /* IO context */
934int Port) /* Port Index (MAC_1 + n) */
935{
936 SK_U16 Word;
937#ifdef VCPU
938 SK_U32 DWord;
939#endif /* VCPU */
940 /*
941 * For each FIFO:
942 * - release local reset
943 * - use default value for MAC FIFO size
944 * - setup defaults for the control register
945 * - enable the FIFO
946 */
947
948 Word = GMF_RX_CTRL_DEF;
949
950 if (pAC->GIni.GIGenesis) {
951 /* Configure Rx MAC FIFO */
952 SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_RST_CLR);
953 SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_RX_CTRL_DEF);
954 SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_ENA_OP_MD);
955
956 /* Configure Tx MAC FIFO */
957 SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_RST_CLR);
958 SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), MFF_TX_CTRL_DEF);
959 SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_ENA_OP_MD);
960
961 /* Enable frame flushing if jumbo frames used */
962 if (pAC->GIni.GIPortUsage == SK_JUMBO_LINK) {
963 SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_ENA_FLUSH);
964 }
965 }
966 else {
967 /* set Rx GMAC FIFO Flush Mask */
968 SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_FL_MSK), (SK_U16)RX_FF_FL_DEF_MSK);
969
970 if (pAC->GIni.GIYukonLite && pAC->GIni.GIChipId == CHIP_ID_YUKON) {
971
972 Word &= ~GMF_RX_F_FL_ON;
973 }
974
975 /* Configure Rx MAC FIFO */
976 SK_OUT8(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), (SK_U8)GMF_RST_CLR);
977 SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), Word);
978
979 /* set Rx GMAC FIFO Flush Threshold (default: 0x0a -> 56 bytes) */
980 SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF);
981
982 /* Configure Tx MAC FIFO */
983 SK_OUT8(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U8)GMF_RST_CLR);
984 SK_OUT16(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U16)GMF_TX_CTRL_DEF);
985
986#ifdef VCPU
987 SK_IN32(IoC, MR_ADDR(Port, RX_GMF_AF_THR), &DWord);
988 SK_IN32(IoC, MR_ADDR(Port, TX_GMF_AE_THR), &DWord);
989#endif /* VCPU */
990
991 /* set Tx GMAC FIFO Almost Empty Threshold */
992/* SK_OUT32(IoC, MR_ADDR(Port, TX_GMF_AE_THR), 0); */
993 }
994} /* SkGeInitMacFifo */
995
996
997/******************************************************************************
998 *
999 * SkGeLoadLnkSyncCnt() - Load the Link Sync Counter and starts counting
1000 *
1001 * Description:
1002 * This function starts the Link Sync Counter of the specified
1003 * port and enables the generation of an Link Sync IRQ.
1004 * The Link Sync Counter may be used to detect an active link,
1005 * if autonegotiation is not used.
1006 *
1007 * Note:
1008 * o To ensure receiving the Link Sync Event the LinkSyncCounter
1009 * should be initialized BEFORE clearing the XMAC's reset!
1010 * o Enable IS_LNK_SYNC_M1 and IS_LNK_SYNC_M2 after calling this
1011 * function.
1012 *
1013 * Returns:
1014 * nothing
1015 */
1016void SkGeLoadLnkSyncCnt(
1017SK_AC *pAC, /* adapter context */
1018SK_IOC IoC, /* IO context */
1019int Port, /* Port Index (MAC_1 + n) */
1020SK_U32 CntVal) /* Counter value */
1021{
1022 SK_U32 OrgIMsk;
1023 SK_U32 NewIMsk;
1024 SK_U32 ISrc;
1025 SK_BOOL IrqPend;
1026
1027 /* stop counter */
1028 SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_STOP);
1029
1030 /*
1031 * ASIC problem:
1032 * Each time starting the Link Sync Counter an IRQ is generated
1033 * by the adapter. See problem report entry from 21.07.98
1034 *
1035 * Workaround: Disable Link Sync IRQ and clear the unexpeced IRQ
1036 * if no IRQ is already pending.
1037 */
1038 IrqPend = SK_FALSE;
1039 SK_IN32(IoC, B0_ISRC, &ISrc);
1040 SK_IN32(IoC, B0_IMSK, &OrgIMsk);
1041 if (Port == MAC_1) {
1042 NewIMsk = OrgIMsk & ~IS_LNK_SYNC_M1;
1043 if ((ISrc & IS_LNK_SYNC_M1) != 0) {
1044 IrqPend = SK_TRUE;
1045 }
1046 }
1047 else {
1048 NewIMsk = OrgIMsk & ~IS_LNK_SYNC_M2;
1049 if ((ISrc & IS_LNK_SYNC_M2) != 0) {
1050 IrqPend = SK_TRUE;
1051 }
1052 }
1053 if (!IrqPend) {
1054 SK_OUT32(IoC, B0_IMSK, NewIMsk);
1055 }
1056
1057 /* load counter */
1058 SK_OUT32(IoC, MR_ADDR(Port, LNK_SYNC_INI), CntVal);
1059
1060 /* start counter */
1061 SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_START);
1062
1063 if (!IrqPend) {
1064 /* clear the unexpected IRQ, and restore the interrupt mask */
1065 SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_CLR_IRQ);
1066 SK_OUT32(IoC, B0_IMSK, OrgIMsk);
1067 }
1068} /* SkGeLoadLnkSyncCnt*/
1069
1070
1071/******************************************************************************
1072 *
1073 * SkGeCfgSync() - Configure synchronous bandwidth for this port.
1074 *
1075 * Description:
1076 * This function may be used to configure synchronous bandwidth
1077 * to the specified port. This may be done any time after
1078 * initializing the port. The configuration values are NOT saved
1079 * in the HWAC port structure and will be overwritten any
1080 * time when stopping and starting the port.
1081 * Any values for the synchronous configuration will be ignored
1082 * if the size of the synchronous queue is zero!
1083 *
1084 * The default configuration for the synchronous service is
1085 * TXA_ENA_FSYNC. This means if the size of
1086 * the synchronous queue is unequal zero but no specific
1087 * synchronous bandwidth is configured, the synchronous queue
1088 * will always have the 'unlimited' transmit priority!
1089 *
1090 * This mode will be restored if the synchronous bandwidth is
1091 * deallocated ('IntTime' = 0 and 'LimCount' = 0).
1092 *
1093 * Returns:
1094 * 0: success
1095 * 1: parameter configuration error
1096 * 2: try to configure quality of service although no
1097 * synchronous queue is configured
1098 */
1099int SkGeCfgSync(
1100SK_AC *pAC, /* adapter context */
1101SK_IOC IoC, /* IO context */
1102int Port, /* Port Index (MAC_1 + n) */
1103SK_U32 IntTime, /* Interval Timer Value in units of 8ns */
1104SK_U32 LimCount, /* Number of bytes to transfer during IntTime */
1105int SyncMode) /* Sync Mode: TXA_ENA_ALLOC | TXA_DIS_ALLOC | 0 */
1106{
1107 int Rtv;
1108
1109 Rtv = 0;
1110
1111 /* check the parameters */
1112 if (LimCount > IntTime ||
1113 (LimCount == 0 && IntTime != 0) ||
1114 (LimCount != 0 && IntTime == 0)) {
1115
1116 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, SKERR_HWI_E010MSG);
1117 return(1);
1118 }
1119
1120 if (pAC->GIni.GP[Port].PXSQSize == 0) {
1121 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E009, SKERR_HWI_E009MSG);
1122 return(2);
1123 }
1124
1125 /* calculate register values */
1126 IntTime = (IntTime / 2) * pAC->GIni.GIHstClkFact / 100;
1127 LimCount = LimCount / 8;
1128
1129 if (IntTime > TXA_MAX_VAL || LimCount > TXA_MAX_VAL) {
1130 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, SKERR_HWI_E010MSG);
1131 return(1);
1132 }
1133
1134 /*
1135 * - Enable 'Force Sync' to ensure the synchronous queue
1136 * has the priority while configuring the new values.
1137 * - Also 'disable alloc' to ensure the settings complies
1138 * to the SyncMode parameter.
1139 * - Disable 'Rate Control' to configure the new values.
1140 * - write IntTime and LimCount
1141 * - start 'Rate Control' and disable 'Force Sync'
1142 * if Interval Timer or Limit Counter not zero.
1143 */
1144 SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
1145 TXA_ENA_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);
1146
1147 SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), IntTime);
1148 SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), LimCount);
1149
1150 SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
1151 (SK_U8)(SyncMode & (TXA_ENA_ALLOC | TXA_DIS_ALLOC)));
1152
1153 if (IntTime != 0 || LimCount != 0) {
1154 SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_DIS_FSYNC | TXA_START_RC);
1155 }
1156
1157 return(0);
1158} /* SkGeCfgSync */
1159
1160
1161/******************************************************************************
1162 *
1163 * DoInitRamQueue() - Initialize the RAM Buffer Address of a single Queue
1164 *
1165 * Desccription:
1166 * If the queue is used, enable and initialize it.
1167 * Make sure the queue is still reset, if it is not used.
1168 *
1169 * Returns:
1170 * nothing
1171 */
1172static void DoInitRamQueue(
1173SK_AC *pAC, /* adapter context */
1174SK_IOC IoC, /* IO context */
1175int QuIoOffs, /* Queue IO Address Offset */
1176SK_U32 QuStartAddr, /* Queue Start Address */
1177SK_U32 QuEndAddr, /* Queue End Address */
1178int QuType) /* Queue Type (SK_RX_SRAM_Q|SK_RX_BRAM_Q|SK_TX_RAM_Q) */
1179{
1180 SK_U32 RxUpThresVal;
1181 SK_U32 RxLoThresVal;
1182
1183 if (QuStartAddr != QuEndAddr) {
1184 /* calculate thresholds, assume we have a big Rx queue */
1185 RxUpThresVal = (QuEndAddr + 1 - QuStartAddr - SK_RB_ULPP) / 8;
1186 RxLoThresVal = (QuEndAddr + 1 - QuStartAddr - SK_RB_LLPP_B)/8;
1187
1188 /* build HW address format */
1189 QuStartAddr = QuStartAddr / 8;
1190 QuEndAddr = QuEndAddr / 8;
1191
1192 /* release local reset */
1193 SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_RST_CLR);
1194
1195 /* configure addresses */
1196 SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_START), QuStartAddr);
1197 SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_END), QuEndAddr);
1198 SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_WP), QuStartAddr);
1199 SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RP), QuStartAddr);
1200
1201 switch (QuType) {
1202 case SK_RX_SRAM_Q:
1203 /* configure threshold for small Rx Queue */
1204 RxLoThresVal += (SK_RB_LLPP_B - SK_RB_LLPP_S) / 8;
1205
1206 /* continue with SK_RX_BRAM_Q */
1207 case SK_RX_BRAM_Q:
1208 /* write threshold for Rx Queue */
1209
1210 SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RX_UTPP), RxUpThresVal);
1211 SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RX_LTPP), RxLoThresVal);
1212
1213 /* the high priority threshold not used */
1214 break;
1215 case SK_TX_RAM_Q:
1216 /*
1217 * Do NOT use Store & Forward under normal operation due to
1218 * performance optimization (GENESIS only).
1219 * But if Jumbo Frames are configured (XMAC Tx FIFO is only 4 kB)
1220 * or YUKON is used ((GMAC Tx FIFO is only 1 kB)
1221 * we NEED Store & Forward of the RAM buffer.
1222 */
1223 if (pAC->GIni.GIPortUsage == SK_JUMBO_LINK ||
1224 !pAC->GIni.GIGenesis) {
1225 /* enable Store & Forward Mode for the Tx Side */
1226 SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_ENA_STFWD);
1227 }
1228 break;
1229 }
1230
1231 /* set queue operational */
1232 SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_ENA_OP_MD);
1233 }
1234 else {
1235 /* ensure the queue is still disabled */
1236 SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_RST_SET);
1237 }
1238} /* DoInitRamQueue */
1239
1240
1241/******************************************************************************
1242 *
1243 * SkGeInitRamBufs() - Initialize the RAM Buffer Queues
1244 *
1245 * Description:
1246 * Initialize all RAM Buffer Queues of the specified port
1247 *
1248 * Returns:
1249 * nothing
1250 */
1251static void SkGeInitRamBufs(
1252SK_AC *pAC, /* adapter context */
1253SK_IOC IoC, /* IO context */
1254int Port) /* Port Index (MAC_1 + n) */
1255{
1256 SK_GEPORT *pPrt;
1257 int RxQType;
1258
1259 pPrt = &pAC->GIni.GP[Port];
1260
1261 if (pPrt->PRxQSize == SK_MIN_RXQ_SIZE) {
1262 RxQType = SK_RX_SRAM_Q; /* small Rx Queue */
1263 }
1264 else {
1265 RxQType = SK_RX_BRAM_Q; /* big Rx Queue */
1266 }
1267
1268 DoInitRamQueue(pAC, IoC, pPrt->PRxQOff, pPrt->PRxQRamStart,
1269 pPrt->PRxQRamEnd, RxQType);
1270
1271 DoInitRamQueue(pAC, IoC, pPrt->PXsQOff, pPrt->PXsQRamStart,
1272 pPrt->PXsQRamEnd, SK_TX_RAM_Q);
1273
1274 DoInitRamQueue(pAC, IoC, pPrt->PXaQOff, pPrt->PXaQRamStart,
1275 pPrt->PXaQRamEnd, SK_TX_RAM_Q);
1276
1277} /* SkGeInitRamBufs */
1278
1279
1280/******************************************************************************
1281 *
1282 * SkGeInitRamIface() - Initialize the RAM Interface
1283 *
1284 * Description:
1285 * This function initializes the Adapters RAM Interface.
1286 *
1287 * Note:
1288 * This function is used in the diagnostics.
1289 *
1290 * Returns:
1291 * nothing
1292 */
1293void SkGeInitRamIface(
1294SK_AC *pAC, /* adapter context */
1295SK_IOC IoC) /* IO context */
1296{
1297 /* release local reset */
1298 SK_OUT16(IoC, B3_RI_CTRL, RI_RST_CLR);
1299
1300 /* configure timeout values */
1301 SK_OUT8(IoC, B3_RI_WTO_R1, SK_RI_TO_53);
1302 SK_OUT8(IoC, B3_RI_WTO_XA1, SK_RI_TO_53);
1303 SK_OUT8(IoC, B3_RI_WTO_XS1, SK_RI_TO_53);
1304 SK_OUT8(IoC, B3_RI_RTO_R1, SK_RI_TO_53);
1305 SK_OUT8(IoC, B3_RI_RTO_XA1, SK_RI_TO_53);
1306 SK_OUT8(IoC, B3_RI_RTO_XS1, SK_RI_TO_53);
1307 SK_OUT8(IoC, B3_RI_WTO_R2, SK_RI_TO_53);
1308 SK_OUT8(IoC, B3_RI_WTO_XA2, SK_RI_TO_53);
1309 SK_OUT8(IoC, B3_RI_WTO_XS2, SK_RI_TO_53);
1310 SK_OUT8(IoC, B3_RI_RTO_R2, SK_RI_TO_53);
1311 SK_OUT8(IoC, B3_RI_RTO_XA2, SK_RI_TO_53);
1312 SK_OUT8(IoC, B3_RI_RTO_XS2, SK_RI_TO_53);
1313
1314} /* SkGeInitRamIface */
1315
1316
1317/******************************************************************************
1318 *
1319 * SkGeInitBmu() - Initialize the BMU state machines
1320 *
1321 * Description:
1322 * Initialize all BMU state machines of the specified port
1323 *
1324 * Returns:
1325 * nothing
1326 */
1327static void SkGeInitBmu(
1328SK_AC *pAC, /* adapter context */
1329SK_IOC IoC, /* IO context */
1330int Port) /* Port Index (MAC_1 + n) */
1331{
1332 SK_GEPORT *pPrt;
1333 SK_U32 RxWm;
1334 SK_U32 TxWm;
1335
1336 pPrt = &pAC->GIni.GP[Port];
1337
1338 RxWm = SK_BMU_RX_WM;
1339 TxWm = SK_BMU_TX_WM;
1340
1341 if (!pAC->GIni.GIPciSlot64 && !pAC->GIni.GIPciClock66) {
1342 /* for better performance */
1343 RxWm /= 2;
1344 TxWm /= 2;
1345 }
1346
1347 /* Rx Queue: Release all local resets and set the watermark */
1348 SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_CLR_RESET);
1349 SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_F), RxWm);
1350
1351 /*
1352 * Tx Queue: Release all local resets if the queue is used !
1353 * set watermark
1354 */
1355 if (pPrt->PXSQSize != 0) {
1356 SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_CLR_RESET);
1357 SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_F), TxWm);
1358 }
1359
1360 if (pPrt->PXAQSize != 0) {
1361 SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_CLR_RESET);
1362 SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_F), TxWm);
1363 }
1364 /*
1365 * Do NOT enable the descriptor poll timers here, because
1366 * the descriptor addresses are not specified yet.
1367 */
1368} /* SkGeInitBmu */
1369
1370
1371/******************************************************************************
1372 *
1373 * TestStopBit() - Test the stop bit of the queue
1374 *
1375 * Description:
1376 * Stopping a queue is not as simple as it seems to be.
1377 * If descriptor polling is enabled, it may happen
1378 * that RX/TX stop is done and SV idle is NOT set.
1379 * In this case we have to issue another stop command.
1380 *
1381 * Returns:
1382 * The queues control status register
1383 */
1384static SK_U32 TestStopBit(
1385SK_AC *pAC, /* Adapter Context */
1386SK_IOC IoC, /* IO Context */
1387int QuIoOffs) /* Queue IO Address Offset */
1388{
1389 SK_U32 QuCsr; /* CSR contents */
1390
1391 SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr);
1392
1393 if ((QuCsr & (CSR_STOP | CSR_SV_IDLE)) == 0) {
1394 /* Stop Descriptor overridden by start command */
1395 SK_OUT32(IoC, Q_ADDR(QuIoOffs, Q_CSR), CSR_STOP);
1396
1397 SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr);
1398 }
1399
1400 return(QuCsr);
1401} /* TestStopBit */
1402
1403
1404/******************************************************************************
1405 *
1406 * SkGeStopPort() - Stop the Rx/Tx activity of the port 'Port'.
1407 *
1408 * Description:
1409 * After calling this function the descriptor rings and Rx and Tx
1410 * queues of this port may be reconfigured.
1411 *
1412 * It is possible to stop the receive and transmit path separate or
1413 * both together.
1414 *
1415 * Dir = SK_STOP_TX Stops the transmit path only and resets the MAC.
1416 * The receive queue is still active and
1417 * the pending Rx frames may be still transferred
1418 * into the RxD.
1419 * SK_STOP_RX Stop the receive path. The tansmit path
1420 * has to be stopped once before.
1421 * SK_STOP_ALL SK_STOP_TX + SK_STOP_RX
1422 *
1423 * RstMode = SK_SOFT_RST Resets the MAC. The PHY is still alive.
1424 * SK_HARD_RST Resets the MAC and the PHY.
1425 *
1426 * Example:
1427 * 1) A Link Down event was signaled for a port. Therefore the activity
1428 * of this port should be stopped and a hardware reset should be issued
1429 * to enable the workaround of XMAC errata #2. But the received frames
1430 * should not be discarded.
1431 * ...
1432 * SkGeStopPort(pAC, IoC, Port, SK_STOP_TX, SK_HARD_RST);
1433 * (transfer all pending Rx frames)
1434 * SkGeStopPort(pAC, IoC, Port, SK_STOP_RX, SK_HARD_RST);
1435 * ...
1436 *
1437 * 2) An event was issued which request the driver to switch
1438 * the 'virtual active' link to an other already active port
1439 * as soon as possible. The frames in the receive queue of this
1440 * port may be lost. But the PHY must not be reset during this
1441 * event.
1442 * ...
1443 * SkGeStopPort(pAC, IoC, Port, SK_STOP_ALL, SK_SOFT_RST);
1444 * ...
1445 *
1446 * Extended Description:
1447 * If SK_STOP_TX is set,
1448 * o disable the MAC's receive and transmitter to prevent
1449 * from sending incomplete frames
1450 * o stop the port's transmit queues before terminating the
1451 * BMUs to prevent from performing incomplete PCI cycles
1452 * on the PCI bus
1453 * - The network Rx and Tx activity and PCI Tx transfer is
1454 * disabled now.
1455 * o reset the MAC depending on the RstMode
1456 * o Stop Interval Timer and Limit Counter of Tx Arbiter,
1457 * also disable Force Sync bit and Enable Alloc bit.
1458 * o perform a local reset of the port's Tx path
1459 * - reset the PCI FIFO of the async Tx queue
1460 * - reset the PCI FIFO of the sync Tx queue
1461 * - reset the RAM Buffer async Tx queue
1462 * - reset the RAM Buffer sync Tx queue
1463 * - reset the MAC Tx FIFO
1464 * o switch Link and Tx LED off, stop the LED counters
1465 *
1466 * If SK_STOP_RX is set,
1467 * o stop the port's receive queue
1468 * - The path data transfer activity is fully stopped now.
1469 * o perform a local reset of the port's Rx path
1470 * - reset the PCI FIFO of the Rx queue
1471 * - reset the RAM Buffer receive queue
1472 * - reset the MAC Rx FIFO
1473 * o switch Rx LED off, stop the LED counter
1474 *
1475 * If all ports are stopped,
1476 * o reset the RAM Interface.
1477 *
1478 * Notes:
1479 * o This function may be called during the driver states RESET_PORT and
1480 * SWITCH_PORT.
1481 */
1482void SkGeStopPort(
1483SK_AC *pAC, /* adapter context */
1484SK_IOC IoC, /* I/O context */
1485int Port, /* port to stop (MAC_1 + n) */
1486int Dir, /* Direction to Stop (SK_STOP_RX, SK_STOP_TX, SK_STOP_ALL) */
1487int RstMode)/* Reset Mode (SK_SOFT_RST, SK_HARD_RST) */
1488{
1489#ifndef SK_DIAG
1490 SK_EVPARA Para;
1491#endif /* !SK_DIAG */
1492 SK_GEPORT *pPrt;
1493 SK_U32 DWord;
1494 SK_U32 XsCsr;
1495 SK_U32 XaCsr;
1496 SK_U64 ToutStart;
1497 int i;
1498 int ToutCnt;
1499
1500 pPrt = &pAC->GIni.GP[Port];
1501
1502 if ((Dir & SK_STOP_TX) != 0) {
1503 /* disable receiver and transmitter */
1504 SkMacRxTxDisable(pAC, IoC, Port);
1505
1506 /* stop both transmit queues */
1507 /*
1508 * If the BMU is in the reset state CSR_STOP will terminate
1509 * immediately.
1510 */
1511 SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_STOP);
1512 SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_STOP);
1513
1514 ToutStart = SkOsGetTime(pAC);
1515 ToutCnt = 0;
1516 do {
1517 /*
1518 * Clear packet arbiter timeout to make sure
1519 * this loop will terminate.
1520 */
1521 SK_OUT16(IoC, B3_PA_CTRL, (Port == MAC_1) ? PA_CLR_TO_TX1 :
1522 PA_CLR_TO_TX2);
1523
1524 /*
1525 * If the transfer stucks at the MAC the STOP command will not
1526 * terminate if we don't flush the XMAC's transmit FIFO !
1527 */
1528 SkMacFlushTxFifo(pAC, IoC, Port);
1529
1530 XsCsr = TestStopBit(pAC, IoC, pPrt->PXsQOff);
1531 XaCsr = TestStopBit(pAC, IoC, pPrt->PXaQOff);
1532
1533 if (SkOsGetTime(pAC) - ToutStart > (SK_TICKS_PER_SEC / 18)) {
1534 /*
1535 * Timeout of 1/18 second reached.
1536 * This needs to be checked at 1/18 sec only.
1537 */
1538 ToutCnt++;
1539 if (ToutCnt > 1) {
1540 /* Might be a problem when the driver event handler
1541 * calls StopPort again. XXX.
1542 */
1543
1544 /* Fatal Error, Loop aborted */
1545 SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_HWI_E018,
1546 SKERR_HWI_E018MSG);
1547#ifndef SK_DIAG
1548 Para.Para64 = Port;
1549 SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);
1550#endif /* !SK_DIAG */
1551 return;
1552 }
1553 /*
1554 * Cache incoherency workaround: Assume a start command
1555 * has been lost while sending the frame.
1556 */
1557 ToutStart = SkOsGetTime(pAC);
1558
1559 if ((XsCsr & CSR_STOP) != 0) {
1560 SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_START);
1561 }
1562 if ((XaCsr & CSR_STOP) != 0) {
1563 SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_START);
1564 }
1565 }
1566
1567 /*
1568 * Because of the ASIC problem report entry from 21.08.1998 it is
1569 * required to wait until CSR_STOP is reset and CSR_SV_IDLE is set.
1570 */
1571 } while ((XsCsr & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE ||
1572 (XaCsr & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE);
1573
1574 /* Reset the MAC depending on the RstMode */
1575 if (RstMode == SK_SOFT_RST) {
1576 SkMacSoftRst(pAC, IoC, Port);
1577 }
1578 else {
1579 SkMacHardRst(pAC, IoC, Port);
1580 }
1581
1582 /* Disable Force Sync bit and Enable Alloc bit */
1583 SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
1584 TXA_DIS_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);
1585
1586 /* Stop Interval Timer and Limit Counter of Tx Arbiter */
1587 SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), 0L);
1588 SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), 0L);
1589
1590 /* Perform a local reset of the port's Tx path */
1591
1592 /* Reset the PCI FIFO of the async Tx queue */
1593 SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_SET_RESET);
1594 /* Reset the PCI FIFO of the sync Tx queue */
1595 SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_SET_RESET);
1596 /* Reset the RAM Buffer async Tx queue */
1597 SK_OUT8(IoC, RB_ADDR(pPrt->PXaQOff, RB_CTRL), RB_RST_SET);
1598 /* Reset the RAM Buffer sync Tx queue */
1599 SK_OUT8(IoC, RB_ADDR(pPrt->PXsQOff, RB_CTRL), RB_RST_SET);
1600
1601 /* Reset Tx MAC FIFO */
1602 if (pAC->GIni.GIGenesis) {
1603 /* Note: MFF_RST_SET does NOT reset the XMAC ! */
1604 SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_RST_SET);
1605
1606 /* switch Link and Tx LED off, stop the LED counters */
1607 /* Link LED is switched off by the RLMT and the Diag itself */
1608 SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_DIS);
1609 }
1610 else {
1611 /* Reset TX MAC FIFO */
1612 SK_OUT8(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U8)GMF_RST_SET);
1613 }
1614 }
1615
1616 if ((Dir & SK_STOP_RX) != 0) {
1617 /*
1618 * The RX Stop Command will not terminate if no buffers
1619 * are queued in the RxD ring. But it will always reach
1620 * the Idle state. Therefore we can use this feature to
1621 * stop the transfer of received packets.
1622 */
1623 /* stop the port's receive queue */
1624 SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_STOP);
1625
1626 i = 100;
1627 do {
1628 /*
1629 * Clear packet arbiter timeout to make sure
1630 * this loop will terminate
1631 */
1632 SK_OUT16(IoC, B3_PA_CTRL, (Port == MAC_1) ? PA_CLR_TO_RX1 :
1633 PA_CLR_TO_RX2);
1634
1635 DWord = TestStopBit(pAC, IoC, pPrt->PRxQOff);
1636
1637 /* timeout if i==0 (bug fix for #10748) */
1638 if (--i == 0) {
1639 SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_HWI_E024,
1640 SKERR_HWI_E024MSG);
1641 break;
1642 }
1643 /*
1644 * because of the ASIC problem report entry from 21.08.98
1645 * it is required to wait until CSR_STOP is reset and
1646 * CSR_SV_IDLE is set.
1647 */
1648 } while ((DWord & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE);
1649
1650 /* The path data transfer activity is fully stopped now */
1651
1652 /* Perform a local reset of the port's Rx path */
1653
1654 /* Reset the PCI FIFO of the Rx queue */
1655 SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_SET_RESET);
1656 /* Reset the RAM Buffer receive queue */
1657 SK_OUT8(IoC, RB_ADDR(pPrt->PRxQOff, RB_CTRL), RB_RST_SET);
1658
1659 /* Reset Rx MAC FIFO */
1660 if (pAC->GIni.GIGenesis) {
1661
1662 SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_RST_SET);
1663
1664 /* switch Rx LED off, stop the LED counter */
1665 SkGeXmitLED(pAC, IoC, MR_ADDR(Port, RX_LED_INI), SK_LED_DIS);
1666 }
1667 else {
1668 /* Reset Rx MAC FIFO */
1669 SK_OUT8(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), (SK_U8)GMF_RST_SET);
1670 }
1671 }
1672} /* SkGeStopPort */
1673
1674
1675/******************************************************************************
1676 *
1677 * SkGeInit0() - Level 0 Initialization
1678 *
1679 * Description:
1680 * - Initialize the BMU address offsets
1681 *
1682 * Returns:
1683 * nothing
1684 */
1685static void SkGeInit0(
1686SK_AC *pAC, /* adapter context */
1687SK_IOC IoC) /* IO context */
1688{
1689 int i;
1690 SK_GEPORT *pPrt;
1691
1692 for (i = 0; i < SK_MAX_MACS; i++) {
1693 pPrt = &pAC->GIni.GP[i];
1694
1695 pPrt->PState = SK_PRT_RESET;
1696 pPrt->PRxQOff = QOffTab[i].RxQOff;
1697 pPrt->PXsQOff = QOffTab[i].XsQOff;
1698 pPrt->PXaQOff = QOffTab[i].XaQOff;
1699 pPrt->PCheckPar = SK_FALSE;
1700 pPrt->PIsave = 0;
1701 pPrt->PPrevShorts = 0;
1702 pPrt->PLinkResCt = 0;
1703 pPrt->PAutoNegTOCt = 0;
1704 pPrt->PPrevRx = 0;
1705 pPrt->PPrevFcs = 0;
1706 pPrt->PRxLim = SK_DEF_RX_WA_LIM;
1707 pPrt->PLinkMode = SK_LMODE_AUTOFULL;
1708 pPrt->PLinkSpeedCap = SK_LSPEED_CAP_1000MBPS;
1709 pPrt->PLinkSpeed = SK_LSPEED_1000MBPS;
1710 pPrt->PLinkSpeedUsed = SK_LSPEED_STAT_UNKNOWN;
1711 pPrt->PLinkModeConf = SK_LMODE_AUTOSENSE;
1712 pPrt->PFlowCtrlMode = SK_FLOW_MODE_SYM_OR_REM;
1713 pPrt->PLinkBroken = SK_TRUE; /* See WA code */
1714 pPrt->PLinkCap = (SK_LMODE_CAP_HALF | SK_LMODE_CAP_FULL |
1715 SK_LMODE_CAP_AUTOHALF | SK_LMODE_CAP_AUTOFULL);
1716 pPrt->PLinkModeStatus = SK_LMODE_STAT_UNKNOWN;
1717 pPrt->PFlowCtrlCap = SK_FLOW_MODE_SYM_OR_REM;
1718 pPrt->PFlowCtrlStatus = SK_FLOW_STAT_NONE;
1719 pPrt->PMSCap = 0;
1720 pPrt->PMSMode = SK_MS_MODE_AUTO;
1721 pPrt->PMSStatus = SK_MS_STAT_UNSET;
1722 pPrt->PAutoNegFail = SK_FALSE;
1723 pPrt->PLipaAutoNeg = SK_LIPA_UNKNOWN;
1724 pPrt->PHWLinkUp = SK_FALSE;
1725 }
1726
1727 pAC->GIni.GIPortUsage = SK_RED_LINK;
1728
1729} /* SkGeInit0*/
1730
1731#ifdef SK_PCI_RESET
1732
1733/******************************************************************************
1734 *
1735 * SkGePciReset() - Reset PCI interface
1736 *
1737 * Description:
1738 * o Read PCI configuration.
1739 * o Change power state to 3.
1740 * o Change power state to 0.
1741 * o Restore PCI configuration.
1742 *
1743 * Returns:
1744 * 0: Success.
1745 * 1: Power state could not be changed to 3.
1746 */
1747static int SkGePciReset(
1748SK_AC *pAC, /* adapter context */
1749SK_IOC IoC) /* IO context */
1750{
1751 int i;
1752 SK_U16 PmCtlSts;
1753 SK_U32 Bp1;
1754 SK_U32 Bp2;
1755 SK_U16 PciCmd;
1756 SK_U8 Cls;
1757 SK_U8 Lat;
1758 SK_U8 ConfigSpace[PCI_CFG_SIZE];
1759
1760 /*
1761 * Note: Switching to D3 state is like a software reset.
1762 * Switching from D3 to D0 is a hardware reset.
1763 * We have to save and restore the configuration space.
1764 */
1765 for (i = 0; i < PCI_CFG_SIZE; i++) {
1766 SkPciReadCfgDWord(pAC, i*4, &ConfigSpace[i]);
1767 }
1768
1769 /* We know the RAM Interface Arbiter is enabled. */
1770 SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D3);
1771 SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);
1772
1773 if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D3) {
1774 return(1);
1775 }
1776
1777 /* Return to D0 state. */
1778 SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D0);
1779
1780 /* Check for D0 state. */
1781 SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);
1782
1783 if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D0) {
1784 return(1);
1785 }
1786
1787 /* Check PCI Config Registers. */
1788 SkPciReadCfgWord(pAC, PCI_COMMAND, &PciCmd);
1789 SkPciReadCfgByte(pAC, PCI_CACHE_LSZ, &Cls);
1790 SkPciReadCfgDWord(pAC, PCI_BASE_1ST, &Bp1);
1791 SkPciReadCfgDWord(pAC, PCI_BASE_2ND, &Bp2);
1792 SkPciReadCfgByte(pAC, PCI_LAT_TIM, &Lat);
1793
1794 if (PciCmd != 0 || Cls != 0 || (Bp1 & 0xfffffff0L) != 0 || Bp2 != 1 ||
1795 Lat != 0) {
1796 return(1);
1797 }
1798
1799 /* Restore PCI Config Space. */
1800 for (i = 0; i < PCI_CFG_SIZE; i++) {
1801 SkPciWriteCfgDWord(pAC, i*4, ConfigSpace[i]);
1802 }
1803
1804 return(0);
1805} /* SkGePciReset */
1806
1807#endif /* SK_PCI_RESET */
1808
1809/******************************************************************************
1810 *
1811 * SkGeInit1() - Level 1 Initialization
1812 *
1813 * Description:
1814 * o Do a software reset.
1815 * o Clear all reset bits.
1816 * o Verify that the detected hardware is present.
1817 * Return an error if not.
1818 * o Get the hardware configuration
1819 * + Read the number of MACs/Ports.
1820 * + Read the RAM size.
1821 * + Read the PCI Revision Id.
1822 * + Find out the adapters host clock speed
1823 * + Read and check the PHY type
1824 *
1825 * Returns:
1826 * 0: success
1827 * 5: Unexpected PHY type detected
1828 * 6: HW self test failed
1829 */
1830static int SkGeInit1(
1831SK_AC *pAC, /* adapter context */
1832SK_IOC IoC) /* IO context */
1833{
1834 SK_U8 Byte;
1835 SK_U16 Word;
1836 SK_U16 CtrlStat;
1837 SK_U32 FlashAddr;
1838 int RetVal;
1839 int i;
1840
1841 RetVal = 0;
1842
1843 /* save CLK_RUN bits (YUKON-Lite) */
1844 SK_IN16(IoC, B0_CTST, &CtrlStat);
1845
1846#ifdef SK_PCI_RESET
1847 (void)SkGePciReset(pAC, IoC);
1848#endif /* SK_PCI_RESET */
1849
1850 /* do the SW-reset */
1851 SK_OUT8(IoC, B0_CTST, CS_RST_SET);
1852
1853 /* release the SW-reset */
1854 SK_OUT8(IoC, B0_CTST, CS_RST_CLR);
1855
1856 /* reset all error bits in the PCI STATUS register */
1857 /*
1858 * Note: PCI Cfg cycles cannot be used, because they are not
1859 * available on some platforms after 'boot time'.
1860 */
1861 SK_IN16(IoC, PCI_C(PCI_STATUS), &Word);
1862
1863 SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
1864 SK_OUT16(IoC, PCI_C(PCI_STATUS), Word | PCI_ERRBITS);
1865 SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
1866
1867 /* release Master Reset */
1868 SK_OUT8(IoC, B0_CTST, CS_MRST_CLR);
1869
1870#ifdef CLK_RUN
1871 CtrlStat |= CS_CLK_RUN_ENA;
1872#endif /* CLK_RUN */
1873
1874 /* restore CLK_RUN bits */
1875 SK_OUT16(IoC, B0_CTST, CtrlStat &
1876 (CS_CLK_RUN_HOT | CS_CLK_RUN_RST | CS_CLK_RUN_ENA));
1877
1878 /* read Chip Identification Number */
1879 SK_IN8(IoC, B2_CHIP_ID, &Byte);
1880 pAC->GIni.GIChipId = Byte;
1881
1882 /* read number of MACs */
1883 SK_IN8(IoC, B2_MAC_CFG, &Byte);
1884 pAC->GIni.GIMacsFound = (Byte & CFG_SNG_MAC) ? 1 : 2;
1885
1886 /* get Chip Revision Number */
1887 pAC->GIni.GIChipRev = (SK_U8)((Byte & CFG_CHIP_R_MSK) >> 4);
1888
1889 /* get diff. PCI parameters */
1890 SK_IN16(IoC, B0_CTST, &CtrlStat);
1891
1892 /* read the adapters RAM size */
1893 SK_IN8(IoC, B2_E_0, &Byte);
1894
1895 if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
1896
1897 pAC->GIni.GIGenesis = SK_TRUE;
1898
1899 if (Byte == 3) {
1900 /* special case: 4 x 64k x 36, offset = 0x80000 */
1901 pAC->GIni.GIRamSize = 1024;
1902 pAC->GIni.GIRamOffs = (SK_U32)512 * 1024;
1903 }
1904 else {
1905 pAC->GIni.GIRamSize = (int)Byte * 512;
1906 pAC->GIni.GIRamOffs = 0;
1907 }
1908 /* all GE adapters work with 53.125 MHz host clock */
1909 pAC->GIni.GIHstClkFact = SK_FACT_53;
1910
1911 /* set Descr. Poll Timer Init Value to 250 ms */
1912 pAC->GIni.GIPollTimerVal =
1913 SK_DPOLL_DEF * (SK_U32)pAC->GIni.GIHstClkFact / 100;
1914 }
1915 else {
1916 pAC->GIni.GIGenesis = SK_FALSE;
1917
1918#ifndef VCPU
1919 pAC->GIni.GIRamSize = (Byte == 0) ? 128 : (int)Byte * 4;
1920#else
1921 pAC->GIni.GIRamSize = 128;
1922#endif
1923 pAC->GIni.GIRamOffs = 0;
1924
1925 /* WA for chip Rev. A */
1926 pAC->GIni.GIWolOffs = (pAC->GIni.GIChipRev == 0) ? WOL_REG_OFFS : 0;
1927
1928 /* get PM Capabilities of PCI config space */
1929 SK_IN16(IoC, PCI_C(PCI_PM_CAP_REG), &Word);
1930
1931 /* check if VAUX is available */
1932 if (((CtrlStat & CS_VAUX_AVAIL) != 0) &&
1933 /* check also if PME from D3cold is set */
1934 ((Word & PCI_PME_D3C_SUP) != 0)) {
1935 /* set entry in GE init struct */
1936 pAC->GIni.GIVauxAvail = SK_TRUE;
1937 }
1938
1939 /* save Flash-Address Register */
1940 SK_IN32(IoC, B2_FAR, &FlashAddr);
1941
1942 /* test Flash-Address Register */
1943 SK_OUT8(IoC, B2_FAR + 3, 0xff);
1944 SK_IN8(IoC, B2_FAR + 3, &Byte);
1945
1946 pAC->GIni.GIYukonLite = (SK_BOOL)(Byte != 0);
1947
1948 /* restore Flash-Address Register */
1949 SK_OUT32(IoC, B2_FAR, FlashAddr);
1950
1951 for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
1952 /* set GMAC Link Control reset */
1953 SK_OUT16(IoC, MR_ADDR(i, GMAC_LINK_CTRL), GMLC_RST_SET);
1954
1955 /* clear GMAC Link Control reset */
1956 SK_OUT16(IoC, MR_ADDR(i, GMAC_LINK_CTRL), GMLC_RST_CLR);
1957 }
1958 /* all YU chips work with 78.125 MHz host clock */
1959 pAC->GIni.GIHstClkFact = SK_FACT_78;
1960
1961 pAC->GIni.GIPollTimerVal = SK_DPOLL_MAX; /* 215 ms */
1962 }
1963
1964 /* check if 64-bit PCI Slot is present */
1965 pAC->GIni.GIPciSlot64 = (SK_BOOL)((CtrlStat & CS_BUS_SLOT_SZ) != 0);
1966
1967 /* check if 66 MHz PCI Clock is active */
1968 pAC->GIni.GIPciClock66 = (SK_BOOL)((CtrlStat & CS_BUS_CLOCK) != 0);
1969
1970 /* read PCI HW Revision Id. */
1971 SK_IN8(IoC, PCI_C(PCI_REV_ID), &Byte);
1972 pAC->GIni.GIPciHwRev = Byte;
1973
1974 /* read the PMD type */
1975 SK_IN8(IoC, B2_PMD_TYP, &Byte);
1976 pAC->GIni.GICopperType = (SK_U8)(Byte == 'T');
1977
1978 /* read the PHY type */
1979 SK_IN8(IoC, B2_E_1, &Byte);
1980
1981 Byte &= 0x0f; /* the PHY type is stored in the lower nibble */
1982 for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
1983
1984 if (pAC->GIni.GIGenesis) {
1985 switch (Byte) {
1986 case SK_PHY_XMAC:
1987 pAC->GIni.GP[i].PhyAddr = PHY_ADDR_XMAC;
1988 break;
1989 case SK_PHY_BCOM:
1990 pAC->GIni.GP[i].PhyAddr = PHY_ADDR_BCOM;
1991 pAC->GIni.GP[i].PMSCap =
1992 SK_MS_CAP_AUTO | SK_MS_CAP_MASTER | SK_MS_CAP_SLAVE;
1993 break;
1994#ifdef OTHER_PHY
1995 case SK_PHY_LONE:
1996 pAC->GIni.GP[i].PhyAddr = PHY_ADDR_LONE;
1997 break;
1998 case SK_PHY_NAT:
1999 pAC->GIni.GP[i].PhyAddr = PHY_ADDR_NAT;
2000 break;
2001#endif /* OTHER_PHY */
2002 default:
2003 /* ERROR: unexpected PHY type detected */
2004 RetVal = 5;
2005 break;
2006 }
2007 }
2008 else {
2009 if (Byte == 0) {
2010 /* if this field is not initialized */
2011 Byte = SK_PHY_MARV_COPPER;
2012 pAC->GIni.GICopperType = SK_TRUE;
2013 }
2014 pAC->GIni.GP[i].PhyAddr = PHY_ADDR_MARV;
2015
2016 if (pAC->GIni.GICopperType) {
2017 pAC->GIni.GP[i].PLinkSpeedCap = SK_LSPEED_CAP_AUTO |
2018 SK_LSPEED_CAP_10MBPS | SK_LSPEED_CAP_100MBPS |
2019 SK_LSPEED_CAP_1000MBPS;
2020 pAC->GIni.GP[i].PLinkSpeed = SK_LSPEED_AUTO;
2021 pAC->GIni.GP[i].PMSCap =
2022 SK_MS_CAP_AUTO | SK_MS_CAP_MASTER | SK_MS_CAP_SLAVE;
2023 }
2024 else {
2025 Byte = SK_PHY_MARV_FIBER;
2026 }
2027 }
2028
2029 pAC->GIni.GP[i].PhyType = Byte;
2030
2031 SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
2032 ("PHY type: %d PHY addr: %04x\n", Byte,
2033 pAC->GIni.GP[i].PhyAddr));
2034 }
2035
2036 /* get Mac Type & set function pointers dependent on */
2037 if (pAC->GIni.GIGenesis) {
2038 pAC->GIni.GIMacType = SK_MAC_XMAC;
2039
2040 pAC->GIni.GIFunc.pFnMacUpdateStats = SkXmUpdateStats;
2041 pAC->GIni.GIFunc.pFnMacStatistic = SkXmMacStatistic;
2042 pAC->GIni.GIFunc.pFnMacResetCounter = SkXmResetCounter;
2043 pAC->GIni.GIFunc.pFnMacOverflow = SkXmOverflowStatus;
2044 }
2045 else {
2046 pAC->GIni.GIMacType = SK_MAC_GMAC;
2047
2048 pAC->GIni.GIFunc.pFnMacUpdateStats = SkGmUpdateStats;
2049 pAC->GIni.GIFunc.pFnMacStatistic = SkGmMacStatistic;
2050 pAC->GIni.GIFunc.pFnMacResetCounter = SkGmResetCounter;
2051 pAC->GIni.GIFunc.pFnMacOverflow = SkGmOverflowStatus;
2052
2053#ifdef SPECIAL_HANDLING
2054 if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
2055 /* check HW self test result */
2056 SK_IN8(IoC, B2_E_3, &Byte);
2057 if ((Byte & B2_E3_RES_MASK) != 0) {
2058 RetVal = 6;
2059 }
2060 }
2061#endif
2062 }
2063 return(RetVal);
2064} /* SkGeInit1 */
2065
2066
2067/******************************************************************************
2068 *
2069 * SkGeInit2() - Level 2 Initialization
2070 *
2071 * Description:
2072 * - start the Blink Source Counter
2073 * - start the Descriptor Poll Timer
2074 * - configure the MAC-Arbiter
2075 * - configure the Packet-Arbiter
2076 * - enable the Tx Arbiters
2077 * - enable the RAM Interface Arbiter
2078 *
2079 * Returns:
2080 * nothing
2081 */
2082static void SkGeInit2(
2083SK_AC *pAC, /* adapter context */
2084SK_IOC IoC) /* IO context */
2085{
2086 SK_U32 DWord;
2087 int i;
2088
2089 /* start the Descriptor Poll Timer */
2090 if (pAC->GIni.GIPollTimerVal != 0) {
2091 if (pAC->GIni.GIPollTimerVal > SK_DPOLL_MAX) {
2092 pAC->GIni.GIPollTimerVal = SK_DPOLL_MAX;
2093
2094 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E017, SKERR_HWI_E017MSG);
2095 }
2096 SK_OUT32(IoC, B28_DPT_INI, pAC->GIni.GIPollTimerVal);
2097 SK_OUT8(IoC, B28_DPT_CTRL, DPT_START);
2098 }
2099
2100 if (pAC->GIni.GIGenesis) {
2101 /* start the Blink Source Counter */
2102 DWord = SK_BLK_DUR * (SK_U32)pAC->GIni.GIHstClkFact / 100;
2103
2104 SK_OUT32(IoC, B2_BSC_INI, DWord);
2105 SK_OUT8(IoC, B2_BSC_CTRL, BSC_START);
2106
2107 /*
2108 * Configure the MAC Arbiter and the Packet Arbiter.
2109 * They will be started once and never be stopped.
2110 */
2111 SkGeInitMacArb(pAC, IoC);
2112
2113 SkGeInitPktArb(pAC, IoC);
2114 }
2115 else {
2116 /* start Time Stamp Timer */
2117 SK_OUT8(IoC, GMAC_TI_ST_CTRL, (SK_U8)GMT_ST_START);
2118 }
2119
2120 /* enable the Tx Arbiters */
2121 for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
2122 SK_OUT8(IoC, MR_ADDR(i, TXA_CTRL), TXA_ENA_ARB);
2123 }
2124
2125 /* enable the RAM Interface Arbiter */
2126 SkGeInitRamIface(pAC, IoC);
2127
2128} /* SkGeInit2 */
2129
2130/******************************************************************************
2131 *
2132 * SkGeInit() - Initialize the GE Adapter with the specified level.
2133 *
2134 * Description:
2135 * Level 0: Initialize the Module structures.
2136 * Level 1: Generic Hardware Initialization. The IOP/MemBase pointer has
2137 * to be set before calling this level.
2138 *
2139 * o Do a software reset.
2140 * o Clear all reset bits.
2141 * o Verify that the detected hardware is present.
2142 * Return an error if not.
2143 * o Get the hardware configuration
2144 * + Set GIMacsFound with the number of MACs.
2145 * + Store the RAM size in GIRamSize.
2146 * + Save the PCI Revision ID in GIPciHwRev.
2147 * o return an error
2148 * if Number of MACs > SK_MAX_MACS
2149 *
2150 * After returning from Level 0 the adapter
2151 * may be accessed with IO operations.
2152 *
2153 * Level 2: start the Blink Source Counter
2154 *
2155 * Returns:
2156 * 0: success
2157 * 1: Number of MACs exceeds SK_MAX_MACS (after level 1)
2158 * 2: Adapter not present or not accessible
2159 * 3: Illegal initialization level
2160 * 4: Initialization Level 1 Call missing
2161 * 5: Unexpected PHY type detected
2162 * 6: HW self test failed
2163 */
2164int SkGeInit(
2165SK_AC *pAC, /* adapter context */
2166SK_IOC IoC, /* IO context */
2167int Level) /* initialization level */
2168{
2169 int RetVal; /* return value */
2170 SK_U32 DWord;
2171
2172 RetVal = 0;
2173 SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
2174 ("SkGeInit(Level %d)\n", Level));
2175
2176 switch (Level) {
2177 case SK_INIT_DATA:
2178 /* Initialization Level 0 */
2179 SkGeInit0(pAC, IoC);
2180 pAC->GIni.GILevel = SK_INIT_DATA;
2181 break;
2182
2183 case SK_INIT_IO:
2184 /* Initialization Level 1 */
2185 RetVal = SkGeInit1(pAC, IoC);
2186 if (RetVal != 0) {
2187 break;
2188 }
2189
2190 /* check if the adapter seems to be accessible */
2191 SK_OUT32(IoC, B2_IRQM_INI, 0x11335577L);
2192 SK_IN32(IoC, B2_IRQM_INI, &DWord);
2193 SK_OUT32(IoC, B2_IRQM_INI, 0L);
2194
2195 if (DWord != 0x11335577L) {
2196 RetVal = 2;
2197 break;
2198 }
2199
2200 /* check if the number of GIMacsFound matches SK_MAX_MACS */
2201 if (pAC->GIni.GIMacsFound > SK_MAX_MACS) {
2202 RetVal = 1;
2203 break;
2204 }
2205
2206 /* Level 1 successfully passed */
2207 pAC->GIni.GILevel = SK_INIT_IO;
2208 break;
2209
2210 case SK_INIT_RUN:
2211 /* Initialization Level 2 */
2212 if (pAC->GIni.GILevel != SK_INIT_IO) {
2213#ifndef SK_DIAG
2214 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E002, SKERR_HWI_E002MSG);
2215#endif /* !SK_DIAG */
2216 RetVal = 4;
2217 break;
2218 }
2219 SkGeInit2(pAC, IoC);
2220
2221 /* Level 2 successfully passed */
2222 pAC->GIni.GILevel = SK_INIT_RUN;
2223 break;
2224
2225 default:
2226 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E003, SKERR_HWI_E003MSG);
2227 RetVal = 3;
2228 break;
2229 }
2230
2231 return(RetVal);
2232} /* SkGeInit */
2233
2234
2235/******************************************************************************
2236 *
2237 * SkGeDeInit() - Deinitialize the adapter
2238 *
2239 * Description:
2240 * All ports of the adapter will be stopped if not already done.
2241 * Do a software reset and switch off all LEDs.
2242 *
2243 * Returns:
2244 * nothing
2245 */
2246void SkGeDeInit(
2247SK_AC *pAC, /* adapter context */
2248SK_IOC IoC) /* IO context */
2249{
2250 int i;
2251 SK_U16 Word;
2252
2253#ifndef VCPU
2254 /* ensure I2C is ready */
2255 SkI2cWaitIrq(pAC, IoC);
2256#endif
2257
2258 /* stop all current transfer activity */
2259 for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
2260 if (pAC->GIni.GP[i].PState != SK_PRT_STOP &&
2261 pAC->GIni.GP[i].PState != SK_PRT_RESET) {
2262
2263 SkGeStopPort(pAC, IoC, i, SK_STOP_ALL, SK_HARD_RST);
2264 }
2265 }
2266
2267 /* Reset all bits in the PCI STATUS register */
2268 /*
2269 * Note: PCI Cfg cycles cannot be used, because they are not
2270 * available on some platforms after 'boot time'.
2271 */
2272 SK_IN16(IoC, PCI_C(PCI_STATUS), &Word);
2273
2274 SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2275 SK_OUT16(IoC, PCI_C(PCI_STATUS), Word | PCI_ERRBITS);
2276 SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2277
2278 /* do the reset, all LEDs are switched off now */
2279 SK_OUT8(IoC, B0_CTST, CS_RST_SET);
2280} /* SkGeDeInit */
2281
2282
2283/******************************************************************************
2284 *
2285 * SkGeInitPort() Initialize the specified port.
2286 *
2287 * Description:
2288 * PRxQSize, PXSQSize, and PXAQSize has to be
2289 * configured for the specified port before calling this function.
2290 * The descriptor rings has to be initialized too.
2291 *
2292 * o (Re)configure queues of the specified port.
2293 * o configure the MAC of the specified port.
2294 * o put ASIC and MAC(s) in operational mode.
2295 * o initialize Rx/Tx and Sync LED
2296 * o initialize RAM Buffers and MAC FIFOs
2297 *
2298 * The port is ready to connect when returning.
2299 *
2300 * Note:
2301 * The MAC's Rx and Tx state machine is still disabled when returning.
2302 *
2303 * Returns:
2304 * 0: success
2305 * 1: Queue size initialization error. The configured values
2306 * for PRxQSize, PXSQSize, or PXAQSize are invalid for one
2307 * or more queues. The specified port was NOT initialized.
2308 * An error log entry was generated.
2309 * 2: The port has to be stopped before it can be initialized again.
2310 */
2311int SkGeInitPort(
2312SK_AC *pAC, /* adapter context */
2313SK_IOC IoC, /* IO context */
2314int Port) /* Port to configure */
2315{
2316 SK_GEPORT *pPrt;
2317
2318 pPrt = &pAC->GIni.GP[Port];
2319
2320 if (SkGeCheckQSize(pAC, Port) != 0) {
2321 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E004, SKERR_HWI_E004MSG);
2322 return(1);
2323 }
2324
2325 if (pPrt->PState == SK_PRT_INIT || pPrt->PState == SK_PRT_RUN) {
2326 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E005, SKERR_HWI_E005MSG);
2327 return(2);
2328 }
2329
2330 /* configuration ok, initialize the Port now */
2331
2332 if (pAC->GIni.GIGenesis) {
2333 /* initialize Rx, Tx and Link LED */
2334 /*
2335 * If 1000BT Phy needs LED initialization than swap
2336 * LED and XMAC initialization order
2337 */
2338 SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_ENA);
2339 SkGeXmitLED(pAC, IoC, MR_ADDR(Port, RX_LED_INI), SK_LED_ENA);
2340 /* The Link LED is initialized by RLMT or Diagnostics itself */
2341
2342 SkXmInitMac(pAC, IoC, Port);
2343 }
2344 else {
2345
2346 SkGmInitMac(pAC, IoC, Port);
2347 }
2348
2349 /* do NOT initialize the Link Sync Counter */
2350
2351 SkGeInitMacFifo(pAC, IoC, Port);
2352
2353 SkGeInitRamBufs(pAC, IoC, Port);
2354
2355 if (pPrt->PXSQSize != 0) {
2356 /* enable Force Sync bit if synchronous queue available */
2357 SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_ENA_FSYNC);
2358 }
2359
2360 SkGeInitBmu(pAC, IoC, Port);
2361
2362 /* mark port as initialized */
2363 pPrt->PState = SK_PRT_INIT;
2364
2365 return(0);
2366} /* SkGeInitPort */