skgeinit.c 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151
  1. /******************************************************************************
  2. *
  3. * Name: skgeinit.c
  4. * Project: Gigabit Ethernet Adapters, Common Modules
  5. * Version: $Revision: 1.97 $
  6. * Date: $Date: 2003/10/02 16:45:31 $
  7. * Purpose: Contains functions to initialize the adapter
  8. *
  9. ******************************************************************************/
  10. /******************************************************************************
  11. *
  12. * (C)Copyright 1998-2002 SysKonnect.
  13. * (C)Copyright 2002-2003 Marvell.
  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. #include "h/skdrv1st.h"
  24. #include "h/skdrv2nd.h"
  25. /* global variables ***********************************************************/
  26. /* local variables ************************************************************/
  27. #if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
  28. static const char SysKonnectFileId[] =
  29. "@(#) $Id: skgeinit.c,v 1.97 2003/10/02 16:45:31 rschmidt Exp $ (C) Marvell.";
  30. #endif
  31. struct s_QOffTab {
  32. int RxQOff; /* Receive Queue Address Offset */
  33. int XsQOff; /* Sync Tx Queue Address Offset */
  34. int XaQOff; /* Async Tx Queue Address Offset */
  35. };
  36. static struct s_QOffTab QOffTab[] = {
  37. {Q_R1, Q_XS1, Q_XA1}, {Q_R2, Q_XS2, Q_XA2}
  38. };
  39. struct s_Config {
  40. char ScanString[8];
  41. SK_U32 Value;
  42. };
  43. static struct s_Config OemConfig = {
  44. {'O','E','M','_','C','o','n','f'},
  45. #ifdef SK_OEM_CONFIG
  46. OEM_CONFIG_VALUE,
  47. #else
  48. 0,
  49. #endif
  50. };
  51. /******************************************************************************
  52. *
  53. * SkGePollRxD() - Enable / Disable Descriptor Polling of RxD Ring
  54. *
  55. * Description:
  56. * Enable or disable the descriptor polling of the receive descriptor
  57. * ring (RxD) for port 'Port'.
  58. * The new configuration is *not* saved over any SkGeStopPort() and
  59. * SkGeInitPort() calls.
  60. *
  61. * Returns:
  62. * nothing
  63. */
  64. void SkGePollRxD(
  65. SK_AC *pAC, /* adapter context */
  66. SK_IOC IoC, /* IO context */
  67. int Port, /* Port Index (MAC_1 + n) */
  68. SK_BOOL PollRxD) /* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */
  69. {
  70. SK_GEPORT *pPrt;
  71. pPrt = &pAC->GIni.GP[Port];
  72. SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), (PollRxD) ?
  73. CSR_ENA_POL : CSR_DIS_POL);
  74. } /* SkGePollRxD */
  75. /******************************************************************************
  76. *
  77. * SkGePollTxD() - Enable / Disable Descriptor Polling of TxD Rings
  78. *
  79. * Description:
  80. * Enable or disable the descriptor polling of the transmit descriptor
  81. * ring(s) (TxD) for port 'Port'.
  82. * The new configuration is *not* saved over any SkGeStopPort() and
  83. * SkGeInitPort() calls.
  84. *
  85. * Returns:
  86. * nothing
  87. */
  88. void SkGePollTxD(
  89. SK_AC *pAC, /* adapter context */
  90. SK_IOC IoC, /* IO context */
  91. int Port, /* Port Index (MAC_1 + n) */
  92. SK_BOOL PollTxD) /* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */
  93. {
  94. SK_GEPORT *pPrt;
  95. SK_U32 DWord;
  96. pPrt = &pAC->GIni.GP[Port];
  97. DWord = (SK_U32)(PollTxD ? CSR_ENA_POL : CSR_DIS_POL);
  98. if (pPrt->PXSQSize != 0) {
  99. SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), DWord);
  100. }
  101. if (pPrt->PXAQSize != 0) {
  102. SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), DWord);
  103. }
  104. } /* SkGePollTxD */
  105. /******************************************************************************
  106. *
  107. * SkGeYellowLED() - Switch the yellow LED on or off.
  108. *
  109. * Description:
  110. * Switch the yellow LED on or off.
  111. *
  112. * Note:
  113. * This function may be called any time after SkGeInit(Level 1).
  114. *
  115. * Returns:
  116. * nothing
  117. */
  118. void SkGeYellowLED(
  119. SK_AC *pAC, /* adapter context */
  120. SK_IOC IoC, /* IO context */
  121. int State) /* yellow LED state, 0 = OFF, 0 != ON */
  122. {
  123. if (State == 0) {
  124. /* Switch yellow LED OFF */
  125. SK_OUT8(IoC, B0_LED, LED_STAT_OFF);
  126. }
  127. else {
  128. /* Switch yellow LED ON */
  129. SK_OUT8(IoC, B0_LED, LED_STAT_ON);
  130. }
  131. } /* SkGeYellowLED */
  132. #if (!defined(SK_SLIM) || defined(GENESIS))
  133. /******************************************************************************
  134. *
  135. * SkGeXmitLED() - Modify the Operational Mode of a transmission LED.
  136. *
  137. * Description:
  138. * The Rx or Tx LED which is specified by 'Led' will be
  139. * enabled, disabled or switched on in test mode.
  140. *
  141. * Note:
  142. * 'Led' must contain the address offset of the LEDs INI register.
  143. *
  144. * Usage:
  145. * SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_ENA);
  146. *
  147. * Returns:
  148. * nothing
  149. */
  150. void SkGeXmitLED(
  151. SK_AC *pAC, /* adapter context */
  152. SK_IOC IoC, /* IO context */
  153. int Led, /* offset to the LED Init Value register */
  154. int Mode) /* Mode may be SK_LED_DIS, SK_LED_ENA, SK_LED_TST */
  155. {
  156. SK_U32 LedIni;
  157. switch (Mode) {
  158. case SK_LED_ENA:
  159. LedIni = SK_XMIT_DUR * (SK_U32)pAC->GIni.GIHstClkFact / 100;
  160. SK_OUT32(IoC, Led + XMIT_LED_INI, LedIni);
  161. SK_OUT8(IoC, Led + XMIT_LED_CTRL, LED_START);
  162. break;
  163. case SK_LED_TST:
  164. SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_ON);
  165. SK_OUT32(IoC, Led + XMIT_LED_CNT, 100);
  166. SK_OUT8(IoC, Led + XMIT_LED_CTRL, LED_START);
  167. break;
  168. case SK_LED_DIS:
  169. default:
  170. /*
  171. * Do NOT stop the LED Timer here. The LED might be
  172. * in on state. But it needs to go off.
  173. */
  174. SK_OUT32(IoC, Led + XMIT_LED_CNT, 0);
  175. SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_OFF);
  176. break;
  177. }
  178. /*
  179. * 1000BT: The Transmit LED is driven by the PHY.
  180. * But the default LED configuration is used for
  181. * Level One and Broadcom PHYs.
  182. * (Broadcom: It may be that PHY_B_PEC_EN_LTR has to be set.)
  183. * (In this case it has to be added here. But we will see. XXX)
  184. */
  185. } /* SkGeXmitLED */
  186. #endif /* !SK_SLIM || GENESIS */
  187. /******************************************************************************
  188. *
  189. * DoCalcAddr() - Calculates the start and the end address of a queue.
  190. *
  191. * Description:
  192. * This function calculates the start and the end address of a queue.
  193. * Afterwards the 'StartVal' is incremented to the next start position.
  194. * If the port is already initialized the calculated values
  195. * will be checked against the configured values and an
  196. * error will be returned, if they are not equal.
  197. * If the port is not initialized the values will be written to
  198. * *StartAdr and *EndAddr.
  199. *
  200. * Returns:
  201. * 0: success
  202. * 1: configuration error
  203. */
  204. static int DoCalcAddr(
  205. SK_AC *pAC, /* adapter context */
  206. SK_GEPORT SK_FAR *pPrt, /* port index */
  207. int QuSize, /* size of the queue to configure in kB */
  208. SK_U32 SK_FAR *StartVal, /* start value for address calculation */
  209. SK_U32 SK_FAR *QuStartAddr,/* start addr to calculate */
  210. SK_U32 SK_FAR *QuEndAddr) /* end address to calculate */
  211. {
  212. SK_U32 EndVal;
  213. SK_U32 NextStart;
  214. int Rtv;
  215. Rtv = 0;
  216. if (QuSize == 0) {
  217. EndVal = *StartVal;
  218. NextStart = EndVal;
  219. }
  220. else {
  221. EndVal = *StartVal + ((SK_U32)QuSize * 1024) - 1;
  222. NextStart = EndVal + 1;
  223. }
  224. if (pPrt->PState >= SK_PRT_INIT) {
  225. if (*StartVal != *QuStartAddr || EndVal != *QuEndAddr) {
  226. Rtv = 1;
  227. }
  228. }
  229. else {
  230. *QuStartAddr = *StartVal;
  231. *QuEndAddr = EndVal;
  232. }
  233. *StartVal = NextStart;
  234. return(Rtv);
  235. } /* DoCalcAddr */
  236. /******************************************************************************
  237. *
  238. * SkGeInitAssignRamToQueues() - allocate default queue sizes
  239. *
  240. * Description:
  241. * This function assigns the memory to the different queues and ports.
  242. * When DualNet is set to SK_TRUE all ports get the same amount of memory.
  243. * Otherwise the first port gets most of the memory and all the
  244. * other ports just the required minimum.
  245. * This function can only be called when pAC->GIni.GIRamSize and
  246. * pAC->GIni.GIMacsFound have been initialized, usually this happens
  247. * at init level 1
  248. *
  249. * Returns:
  250. * 0 - ok
  251. * 1 - invalid input values
  252. * 2 - not enough memory
  253. */
  254. int SkGeInitAssignRamToQueues(
  255. SK_AC *pAC, /* Adapter context */
  256. int ActivePort, /* Active Port in RLMT mode */
  257. SK_BOOL DualNet) /* adapter context */
  258. {
  259. int i;
  260. int UsedKilobytes; /* memory already assigned */
  261. int ActivePortKilobytes; /* memory available for active port */
  262. SK_GEPORT *pGePort;
  263. UsedKilobytes = 0;
  264. if (ActivePort >= pAC->GIni.GIMacsFound) {
  265. SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
  266. ("SkGeInitAssignRamToQueues: ActivePort (%d) invalid\n",
  267. ActivePort));
  268. return(1);
  269. }
  270. if (((pAC->GIni.GIMacsFound * (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE)) +
  271. ((RAM_QUOTA_SYNC == 0) ? 0 : SK_MIN_TXQ_SIZE)) > pAC->GIni.GIRamSize) {
  272. SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
  273. ("SkGeInitAssignRamToQueues: Not enough memory (%d)\n",
  274. pAC->GIni.GIRamSize));
  275. return(2);
  276. }
  277. if (DualNet) {
  278. /* every port gets the same amount of memory */
  279. ActivePortKilobytes = pAC->GIni.GIRamSize / pAC->GIni.GIMacsFound;
  280. for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
  281. pGePort = &pAC->GIni.GP[i];
  282. /* take away the minimum memory for active queues */
  283. ActivePortKilobytes -= (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE);
  284. /* receive queue gets the minimum + 80% of the rest */
  285. pGePort->PRxQSize = (int) (ROUND_QUEUE_SIZE_KB((
  286. ActivePortKilobytes * (unsigned long) RAM_QUOTA_RX) / 100))
  287. + SK_MIN_RXQ_SIZE;
  288. ActivePortKilobytes -= (pGePort->PRxQSize - SK_MIN_RXQ_SIZE);
  289. /* synchronous transmit queue */
  290. pGePort->PXSQSize = 0;
  291. /* asynchronous transmit queue */
  292. pGePort->PXAQSize = (int) ROUND_QUEUE_SIZE_KB(ActivePortKilobytes +
  293. SK_MIN_TXQ_SIZE);
  294. }
  295. }
  296. else {
  297. /* Rlmt Mode or single link adapter */
  298. /* Set standby queue size defaults for all standby ports */
  299. for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
  300. if (i != ActivePort) {
  301. pGePort = &pAC->GIni.GP[i];
  302. pGePort->PRxQSize = SK_MIN_RXQ_SIZE;
  303. pGePort->PXAQSize = SK_MIN_TXQ_SIZE;
  304. pGePort->PXSQSize = 0;
  305. /* Count used RAM */
  306. UsedKilobytes += pGePort->PRxQSize + pGePort->PXAQSize;
  307. }
  308. }
  309. /* what's left? */
  310. ActivePortKilobytes = pAC->GIni.GIRamSize - UsedKilobytes;
  311. /* assign it to the active port */
  312. /* first take away the minimum memory */
  313. ActivePortKilobytes -= (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE);
  314. pGePort = &pAC->GIni.GP[ActivePort];
  315. /* receive queue get's the minimum + 80% of the rest */
  316. pGePort->PRxQSize = (int) (ROUND_QUEUE_SIZE_KB((ActivePortKilobytes *
  317. (unsigned long) RAM_QUOTA_RX) / 100)) + SK_MIN_RXQ_SIZE;
  318. ActivePortKilobytes -= (pGePort->PRxQSize - SK_MIN_RXQ_SIZE);
  319. /* synchronous transmit queue */
  320. pGePort->PXSQSize = 0;
  321. /* asynchronous transmit queue */
  322. pGePort->PXAQSize = (int) ROUND_QUEUE_SIZE_KB(ActivePortKilobytes) +
  323. SK_MIN_TXQ_SIZE;
  324. }
  325. #ifdef VCPU
  326. VCPUprintf(0, "PRxQSize=%u, PXSQSize=%u, PXAQSize=%u\n",
  327. pGePort->PRxQSize, pGePort->PXSQSize, pGePort->PXAQSize);
  328. #endif /* VCPU */
  329. return(0);
  330. } /* SkGeInitAssignRamToQueues */
  331. /******************************************************************************
  332. *
  333. * SkGeCheckQSize() - Checks the Adapters Queue Size Configuration
  334. *
  335. * Description:
  336. * This function verifies the Queue Size Configuration specified
  337. * in the variables PRxQSize, PXSQSize, and PXAQSize of all
  338. * used ports.
  339. * This requirements must be fullfilled to have a valid configuration:
  340. * - The size of all queues must not exceed GIRamSize.
  341. * - The queue sizes must be specified in units of 8 kB.
  342. * - The size of Rx queues of available ports must not be
  343. * smaller than 16 kB.
  344. * - The size of at least one Tx queue (synch. or asynch.)
  345. * of available ports must not be smaller than 16 kB
  346. * when Jumbo Frames are used.
  347. * - The RAM start and end addresses must not be changed
  348. * for ports which are already initialized.
  349. * Furthermore SkGeCheckQSize() defines the Start and End Addresses
  350. * of all ports and stores them into the HWAC port structure.
  351. *
  352. * Returns:
  353. * 0: Queue Size Configuration valid
  354. * 1: Queue Size Configuration invalid
  355. */
  356. static int SkGeCheckQSize(
  357. SK_AC *pAC, /* adapter context */
  358. int Port) /* port index */
  359. {
  360. SK_GEPORT *pPrt;
  361. int i;
  362. int Rtv;
  363. int Rtv2;
  364. SK_U32 StartAddr;
  365. #ifndef SK_SLIM
  366. int UsedMem; /* total memory used (max. found ports) */
  367. #endif
  368. Rtv = 0;
  369. #ifndef SK_SLIM
  370. UsedMem = 0;
  371. for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
  372. pPrt = &pAC->GIni.GP[i];
  373. if ((pPrt->PRxQSize & QZ_UNITS) != 0 ||
  374. (pPrt->PXSQSize & QZ_UNITS) != 0 ||
  375. (pPrt->PXAQSize & QZ_UNITS) != 0) {
  376. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E012, SKERR_HWI_E012MSG);
  377. return(1);
  378. }
  379. if (i == Port && pPrt->PRxQSize < SK_MIN_RXQ_SIZE) {
  380. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E011, SKERR_HWI_E011MSG);
  381. return(1);
  382. }
  383. /*
  384. * the size of at least one Tx queue (synch. or asynch.) has to be > 0.
  385. * if Jumbo Frames are used, this size has to be >= 16 kB.
  386. */
  387. if ((i == Port && pPrt->PXSQSize == 0 && pPrt->PXAQSize == 0) ||
  388. (pAC->GIni.GIPortUsage == SK_JUMBO_LINK &&
  389. ((pPrt->PXSQSize > 0 && pPrt->PXSQSize < SK_MIN_TXQ_SIZE) ||
  390. (pPrt->PXAQSize > 0 && pPrt->PXAQSize < SK_MIN_TXQ_SIZE)))) {
  391. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E023, SKERR_HWI_E023MSG);
  392. return(1);
  393. }
  394. UsedMem += pPrt->PRxQSize + pPrt->PXSQSize + pPrt->PXAQSize;
  395. }
  396. if (UsedMem > pAC->GIni.GIRamSize) {
  397. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E012, SKERR_HWI_E012MSG);
  398. return(1);
  399. }
  400. #endif /* !SK_SLIM */
  401. /* Now start address calculation */
  402. StartAddr = pAC->GIni.GIRamOffs;
  403. for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
  404. pPrt = &pAC->GIni.GP[i];
  405. /* Calculate/Check values for the receive queue */
  406. Rtv2 = DoCalcAddr(pAC, pPrt, pPrt->PRxQSize, &StartAddr,
  407. &pPrt->PRxQRamStart, &pPrt->PRxQRamEnd);
  408. Rtv |= Rtv2;
  409. /* Calculate/Check values for the synchronous Tx queue */
  410. Rtv2 = DoCalcAddr(pAC, pPrt, pPrt->PXSQSize, &StartAddr,
  411. &pPrt->PXsQRamStart, &pPrt->PXsQRamEnd);
  412. Rtv |= Rtv2;
  413. /* Calculate/Check values for the asynchronous Tx queue */
  414. Rtv2 = DoCalcAddr(pAC, pPrt, pPrt->PXAQSize, &StartAddr,
  415. &pPrt->PXaQRamStart, &pPrt->PXaQRamEnd);
  416. Rtv |= Rtv2;
  417. if (Rtv) {
  418. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E013, SKERR_HWI_E013MSG);
  419. return(1);
  420. }
  421. }
  422. return(0);
  423. } /* SkGeCheckQSize */
  424. #ifdef GENESIS
  425. /******************************************************************************
  426. *
  427. * SkGeInitMacArb() - Initialize the MAC Arbiter
  428. *
  429. * Description:
  430. * This function initializes the MAC Arbiter.
  431. * It must not be called if there is still an
  432. * initialized or active port.
  433. *
  434. * Returns:
  435. * nothing
  436. */
  437. static void SkGeInitMacArb(
  438. SK_AC *pAC, /* adapter context */
  439. SK_IOC IoC) /* IO context */
  440. {
  441. /* release local reset */
  442. SK_OUT16(IoC, B3_MA_TO_CTRL, MA_RST_CLR);
  443. /* configure timeout values */
  444. SK_OUT8(IoC, B3_MA_TOINI_RX1, SK_MAC_TO_53);
  445. SK_OUT8(IoC, B3_MA_TOINI_RX2, SK_MAC_TO_53);
  446. SK_OUT8(IoC, B3_MA_TOINI_TX1, SK_MAC_TO_53);
  447. SK_OUT8(IoC, B3_MA_TOINI_TX2, SK_MAC_TO_53);
  448. SK_OUT8(IoC, B3_MA_RCINI_RX1, 0);
  449. SK_OUT8(IoC, B3_MA_RCINI_RX2, 0);
  450. SK_OUT8(IoC, B3_MA_RCINI_TX1, 0);
  451. SK_OUT8(IoC, B3_MA_RCINI_TX2, 0);
  452. /* recovery values are needed for XMAC II Rev. B2 only */
  453. /* Fast Output Enable Mode was intended to use with Rev. B2, but now? */
  454. /*
  455. * There is no start or enable button to push, therefore
  456. * the MAC arbiter is configured and enabled now.
  457. */
  458. } /* SkGeInitMacArb */
  459. /******************************************************************************
  460. *
  461. * SkGeInitPktArb() - Initialize the Packet Arbiter
  462. *
  463. * Description:
  464. * This function initializes the Packet Arbiter.
  465. * It must not be called if there is still an
  466. * initialized or active port.
  467. *
  468. * Returns:
  469. * nothing
  470. */
  471. static void SkGeInitPktArb(
  472. SK_AC *pAC, /* adapter context */
  473. SK_IOC IoC) /* IO context */
  474. {
  475. /* release local reset */
  476. SK_OUT16(IoC, B3_PA_CTRL, PA_RST_CLR);
  477. /* configure timeout values */
  478. SK_OUT16(IoC, B3_PA_TOINI_RX1, SK_PKT_TO_MAX);
  479. SK_OUT16(IoC, B3_PA_TOINI_RX2, SK_PKT_TO_MAX);
  480. SK_OUT16(IoC, B3_PA_TOINI_TX1, SK_PKT_TO_MAX);
  481. SK_OUT16(IoC, B3_PA_TOINI_TX2, SK_PKT_TO_MAX);
  482. /*
  483. * enable timeout timers if jumbo frames not used
  484. * NOTE: the packet arbiter timeout interrupt is needed for
  485. * half duplex hangup workaround
  486. */
  487. if (pAC->GIni.GIPortUsage != SK_JUMBO_LINK) {
  488. if (pAC->GIni.GIMacsFound == 1) {
  489. SK_OUT16(IoC, B3_PA_CTRL, PA_ENA_TO_TX1);
  490. }
  491. else {
  492. SK_OUT16(IoC, B3_PA_CTRL, PA_ENA_TO_TX1 | PA_ENA_TO_TX2);
  493. }
  494. }
  495. } /* SkGeInitPktArb */
  496. #endif /* GENESIS */
  497. /******************************************************************************
  498. *
  499. * SkGeInitMacFifo() - Initialize the MAC FIFOs
  500. *
  501. * Description:
  502. * Initialize all MAC FIFOs of the specified port
  503. *
  504. * Returns:
  505. * nothing
  506. */
  507. static void SkGeInitMacFifo(
  508. SK_AC *pAC, /* adapter context */
  509. SK_IOC IoC, /* IO context */
  510. int Port) /* Port Index (MAC_1 + n) */
  511. {
  512. SK_U16 Word;
  513. #ifdef VCPU
  514. SK_U32 DWord;
  515. #endif /* VCPU */
  516. /*
  517. * For each FIFO:
  518. * - release local reset
  519. * - use default value for MAC FIFO size
  520. * - setup defaults for the control register
  521. * - enable the FIFO
  522. */
  523. #ifdef GENESIS
  524. if (pAC->GIni.GIGenesis) {
  525. /* Configure Rx MAC FIFO */
  526. SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_RST_CLR);
  527. SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_RX_CTRL_DEF);
  528. SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_ENA_OP_MD);
  529. /* Configure Tx MAC FIFO */
  530. SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_RST_CLR);
  531. SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), MFF_TX_CTRL_DEF);
  532. SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_ENA_OP_MD);
  533. /* Enable frame flushing if jumbo frames used */
  534. if (pAC->GIni.GIPortUsage == SK_JUMBO_LINK) {
  535. SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_ENA_FLUSH);
  536. }
  537. }
  538. #endif /* GENESIS */
  539. #ifdef YUKON
  540. if (pAC->GIni.GIYukon) {
  541. /* set Rx GMAC FIFO Flush Mask */
  542. SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_FL_MSK), (SK_U16)RX_FF_FL_DEF_MSK);
  543. Word = (SK_U16)GMF_RX_CTRL_DEF;
  544. /* disable Rx GMAC FIFO Flush for YUKON-Lite Rev. A0 only */
  545. if (pAC->GIni.GIYukonLite && pAC->GIni.GIChipId == CHIP_ID_YUKON) {
  546. Word &= ~GMF_RX_F_FL_ON;
  547. }
  548. /* Configure Rx MAC FIFO */
  549. SK_OUT8(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), (SK_U8)GMF_RST_CLR);
  550. SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), Word);
  551. /* set Rx GMAC FIFO Flush Threshold (default: 0x0a -> 56 bytes) */
  552. SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF);
  553. /* Configure Tx MAC FIFO */
  554. SK_OUT8(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U8)GMF_RST_CLR);
  555. SK_OUT16(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U16)GMF_TX_CTRL_DEF);
  556. #ifdef VCPU
  557. SK_IN32(IoC, MR_ADDR(Port, RX_GMF_AF_THR), &DWord);
  558. SK_IN32(IoC, MR_ADDR(Port, TX_GMF_AE_THR), &DWord);
  559. #endif /* VCPU */
  560. /* set Tx GMAC FIFO Almost Empty Threshold */
  561. /* SK_OUT32(IoC, MR_ADDR(Port, TX_GMF_AE_THR), 0); */
  562. }
  563. #endif /* YUKON */
  564. } /* SkGeInitMacFifo */
  565. #ifdef SK_LNK_SYNC_CNT
  566. /******************************************************************************
  567. *
  568. * SkGeLoadLnkSyncCnt() - Load the Link Sync Counter and starts counting
  569. *
  570. * Description:
  571. * This function starts the Link Sync Counter of the specified
  572. * port and enables the generation of an Link Sync IRQ.
  573. * The Link Sync Counter may be used to detect an active link,
  574. * if autonegotiation is not used.
  575. *
  576. * Note:
  577. * o To ensure receiving the Link Sync Event the LinkSyncCounter
  578. * should be initialized BEFORE clearing the XMAC's reset!
  579. * o Enable IS_LNK_SYNC_M1 and IS_LNK_SYNC_M2 after calling this
  580. * function.
  581. *
  582. * Returns:
  583. * nothing
  584. */
  585. void SkGeLoadLnkSyncCnt(
  586. SK_AC *pAC, /* adapter context */
  587. SK_IOC IoC, /* IO context */
  588. int Port, /* Port Index (MAC_1 + n) */
  589. SK_U32 CntVal) /* Counter value */
  590. {
  591. SK_U32 OrgIMsk;
  592. SK_U32 NewIMsk;
  593. SK_U32 ISrc;
  594. SK_BOOL IrqPend;
  595. /* stop counter */
  596. SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_STOP);
  597. /*
  598. * ASIC problem:
  599. * Each time starting the Link Sync Counter an IRQ is generated
  600. * by the adapter. See problem report entry from 21.07.98
  601. *
  602. * Workaround: Disable Link Sync IRQ and clear the unexpeced IRQ
  603. * if no IRQ is already pending.
  604. */
  605. IrqPend = SK_FALSE;
  606. SK_IN32(IoC, B0_ISRC, &ISrc);
  607. SK_IN32(IoC, B0_IMSK, &OrgIMsk);
  608. if (Port == MAC_1) {
  609. NewIMsk = OrgIMsk & ~IS_LNK_SYNC_M1;
  610. if ((ISrc & IS_LNK_SYNC_M1) != 0) {
  611. IrqPend = SK_TRUE;
  612. }
  613. }
  614. else {
  615. NewIMsk = OrgIMsk & ~IS_LNK_SYNC_M2;
  616. if ((ISrc & IS_LNK_SYNC_M2) != 0) {
  617. IrqPend = SK_TRUE;
  618. }
  619. }
  620. if (!IrqPend) {
  621. SK_OUT32(IoC, B0_IMSK, NewIMsk);
  622. }
  623. /* load counter */
  624. SK_OUT32(IoC, MR_ADDR(Port, LNK_SYNC_INI), CntVal);
  625. /* start counter */
  626. SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_START);
  627. if (!IrqPend) {
  628. /* clear the unexpected IRQ, and restore the interrupt mask */
  629. SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_CLR_IRQ);
  630. SK_OUT32(IoC, B0_IMSK, OrgIMsk);
  631. }
  632. } /* SkGeLoadLnkSyncCnt*/
  633. #endif /* SK_LNK_SYNC_CNT */
  634. #if defined(SK_DIAG) || defined(SK_CFG_SYNC)
  635. /******************************************************************************
  636. *
  637. * SkGeCfgSync() - Configure synchronous bandwidth for this port.
  638. *
  639. * Description:
  640. * This function may be used to configure synchronous bandwidth
  641. * to the specified port. This may be done any time after
  642. * initializing the port. The configuration values are NOT saved
  643. * in the HWAC port structure and will be overwritten any
  644. * time when stopping and starting the port.
  645. * Any values for the synchronous configuration will be ignored
  646. * if the size of the synchronous queue is zero!
  647. *
  648. * The default configuration for the synchronous service is
  649. * TXA_ENA_FSYNC. This means if the size of
  650. * the synchronous queue is unequal zero but no specific
  651. * synchronous bandwidth is configured, the synchronous queue
  652. * will always have the 'unlimited' transmit priority!
  653. *
  654. * This mode will be restored if the synchronous bandwidth is
  655. * deallocated ('IntTime' = 0 and 'LimCount' = 0).
  656. *
  657. * Returns:
  658. * 0: success
  659. * 1: parameter configuration error
  660. * 2: try to configure quality of service although no
  661. * synchronous queue is configured
  662. */
  663. int SkGeCfgSync(
  664. SK_AC *pAC, /* adapter context */
  665. SK_IOC IoC, /* IO context */
  666. int Port, /* Port Index (MAC_1 + n) */
  667. SK_U32 IntTime, /* Interval Timer Value in units of 8ns */
  668. SK_U32 LimCount, /* Number of bytes to transfer during IntTime */
  669. int SyncMode) /* Sync Mode: TXA_ENA_ALLOC | TXA_DIS_ALLOC | 0 */
  670. {
  671. int Rtv;
  672. Rtv = 0;
  673. /* check the parameters */
  674. if (LimCount > IntTime ||
  675. (LimCount == 0 && IntTime != 0) ||
  676. (LimCount != 0 && IntTime == 0)) {
  677. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, SKERR_HWI_E010MSG);
  678. return(1);
  679. }
  680. if (pAC->GIni.GP[Port].PXSQSize == 0) {
  681. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E009, SKERR_HWI_E009MSG);
  682. return(2);
  683. }
  684. /* calculate register values */
  685. IntTime = (IntTime / 2) * pAC->GIni.GIHstClkFact / 100;
  686. LimCount = LimCount / 8;
  687. if (IntTime > TXA_MAX_VAL || LimCount > TXA_MAX_VAL) {
  688. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, SKERR_HWI_E010MSG);
  689. return(1);
  690. }
  691. /*
  692. * - Enable 'Force Sync' to ensure the synchronous queue
  693. * has the priority while configuring the new values.
  694. * - Also 'disable alloc' to ensure the settings complies
  695. * to the SyncMode parameter.
  696. * - Disable 'Rate Control' to configure the new values.
  697. * - write IntTime and LimCount
  698. * - start 'Rate Control' and disable 'Force Sync'
  699. * if Interval Timer or Limit Counter not zero.
  700. */
  701. SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
  702. TXA_ENA_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);
  703. SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), IntTime);
  704. SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), LimCount);
  705. SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
  706. (SK_U8)(SyncMode & (TXA_ENA_ALLOC | TXA_DIS_ALLOC)));
  707. if (IntTime != 0 || LimCount != 0) {
  708. SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_DIS_FSYNC | TXA_START_RC);
  709. }
  710. return(0);
  711. } /* SkGeCfgSync */
  712. #endif /* SK_DIAG || SK_CFG_SYNC*/
  713. /******************************************************************************
  714. *
  715. * DoInitRamQueue() - Initialize the RAM Buffer Address of a single Queue
  716. *
  717. * Desccription:
  718. * If the queue is used, enable and initialize it.
  719. * Make sure the queue is still reset, if it is not used.
  720. *
  721. * Returns:
  722. * nothing
  723. */
  724. static void DoInitRamQueue(
  725. SK_AC *pAC, /* adapter context */
  726. SK_IOC IoC, /* IO context */
  727. int QuIoOffs, /* Queue IO Address Offset */
  728. SK_U32 QuStartAddr, /* Queue Start Address */
  729. SK_U32 QuEndAddr, /* Queue End Address */
  730. int QuType) /* Queue Type (SK_RX_SRAM_Q|SK_RX_BRAM_Q|SK_TX_RAM_Q) */
  731. {
  732. SK_U32 RxUpThresVal;
  733. SK_U32 RxLoThresVal;
  734. if (QuStartAddr != QuEndAddr) {
  735. /* calculate thresholds, assume we have a big Rx queue */
  736. RxUpThresVal = (QuEndAddr + 1 - QuStartAddr - SK_RB_ULPP) / 8;
  737. RxLoThresVal = (QuEndAddr + 1 - QuStartAddr - SK_RB_LLPP_B)/8;
  738. /* build HW address format */
  739. QuStartAddr = QuStartAddr / 8;
  740. QuEndAddr = QuEndAddr / 8;
  741. /* release local reset */
  742. SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_RST_CLR);
  743. /* configure addresses */
  744. SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_START), QuStartAddr);
  745. SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_END), QuEndAddr);
  746. SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_WP), QuStartAddr);
  747. SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RP), QuStartAddr);
  748. switch (QuType) {
  749. case SK_RX_SRAM_Q:
  750. /* configure threshold for small Rx Queue */
  751. RxLoThresVal += (SK_RB_LLPP_B - SK_RB_LLPP_S) / 8;
  752. /* continue with SK_RX_BRAM_Q */
  753. case SK_RX_BRAM_Q:
  754. /* write threshold for Rx Queue */
  755. SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RX_UTPP), RxUpThresVal);
  756. SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RX_LTPP), RxLoThresVal);
  757. /* the high priority threshold not used */
  758. break;
  759. case SK_TX_RAM_Q:
  760. /*
  761. * Do NOT use Store & Forward under normal operation due to
  762. * performance optimization (GENESIS only).
  763. * But if Jumbo Frames are configured (XMAC Tx FIFO is only 4 kB)
  764. * or YUKON is used ((GMAC Tx FIFO is only 1 kB)
  765. * we NEED Store & Forward of the RAM buffer.
  766. */
  767. if (pAC->GIni.GIPortUsage == SK_JUMBO_LINK ||
  768. pAC->GIni.GIYukon) {
  769. /* enable Store & Forward Mode for the Tx Side */
  770. SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_ENA_STFWD);
  771. }
  772. break;
  773. }
  774. /* set queue operational */
  775. SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_ENA_OP_MD);
  776. }
  777. else {
  778. /* ensure the queue is still disabled */
  779. SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_RST_SET);
  780. }
  781. } /* DoInitRamQueue */
  782. /******************************************************************************
  783. *
  784. * SkGeInitRamBufs() - Initialize the RAM Buffer Queues
  785. *
  786. * Description:
  787. * Initialize all RAM Buffer Queues of the specified port
  788. *
  789. * Returns:
  790. * nothing
  791. */
  792. static void SkGeInitRamBufs(
  793. SK_AC *pAC, /* adapter context */
  794. SK_IOC IoC, /* IO context */
  795. int Port) /* Port Index (MAC_1 + n) */
  796. {
  797. SK_GEPORT *pPrt;
  798. int RxQType;
  799. pPrt = &pAC->GIni.GP[Port];
  800. if (pPrt->PRxQSize == SK_MIN_RXQ_SIZE) {
  801. RxQType = SK_RX_SRAM_Q; /* small Rx Queue */
  802. }
  803. else {
  804. RxQType = SK_RX_BRAM_Q; /* big Rx Queue */
  805. }
  806. DoInitRamQueue(pAC, IoC, pPrt->PRxQOff, pPrt->PRxQRamStart,
  807. pPrt->PRxQRamEnd, RxQType);
  808. DoInitRamQueue(pAC, IoC, pPrt->PXsQOff, pPrt->PXsQRamStart,
  809. pPrt->PXsQRamEnd, SK_TX_RAM_Q);
  810. DoInitRamQueue(pAC, IoC, pPrt->PXaQOff, pPrt->PXaQRamStart,
  811. pPrt->PXaQRamEnd, SK_TX_RAM_Q);
  812. } /* SkGeInitRamBufs */
  813. /******************************************************************************
  814. *
  815. * SkGeInitRamIface() - Initialize the RAM Interface
  816. *
  817. * Description:
  818. * This function initializes the Adapters RAM Interface.
  819. *
  820. * Note:
  821. * This function is used in the diagnostics.
  822. *
  823. * Returns:
  824. * nothing
  825. */
  826. void SkGeInitRamIface(
  827. SK_AC *pAC, /* adapter context */
  828. SK_IOC IoC) /* IO context */
  829. {
  830. /* release local reset */
  831. SK_OUT16(IoC, B3_RI_CTRL, RI_RST_CLR);
  832. /* configure timeout values */
  833. SK_OUT8(IoC, B3_RI_WTO_R1, SK_RI_TO_53);
  834. SK_OUT8(IoC, B3_RI_WTO_XA1, SK_RI_TO_53);
  835. SK_OUT8(IoC, B3_RI_WTO_XS1, SK_RI_TO_53);
  836. SK_OUT8(IoC, B3_RI_RTO_R1, SK_RI_TO_53);
  837. SK_OUT8(IoC, B3_RI_RTO_XA1, SK_RI_TO_53);
  838. SK_OUT8(IoC, B3_RI_RTO_XS1, SK_RI_TO_53);
  839. SK_OUT8(IoC, B3_RI_WTO_R2, SK_RI_TO_53);
  840. SK_OUT8(IoC, B3_RI_WTO_XA2, SK_RI_TO_53);
  841. SK_OUT8(IoC, B3_RI_WTO_XS2, SK_RI_TO_53);
  842. SK_OUT8(IoC, B3_RI_RTO_R2, SK_RI_TO_53);
  843. SK_OUT8(IoC, B3_RI_RTO_XA2, SK_RI_TO_53);
  844. SK_OUT8(IoC, B3_RI_RTO_XS2, SK_RI_TO_53);
  845. } /* SkGeInitRamIface */
  846. /******************************************************************************
  847. *
  848. * SkGeInitBmu() - Initialize the BMU state machines
  849. *
  850. * Description:
  851. * Initialize all BMU state machines of the specified port
  852. *
  853. * Returns:
  854. * nothing
  855. */
  856. static void SkGeInitBmu(
  857. SK_AC *pAC, /* adapter context */
  858. SK_IOC IoC, /* IO context */
  859. int Port) /* Port Index (MAC_1 + n) */
  860. {
  861. SK_GEPORT *pPrt;
  862. SK_U32 RxWm;
  863. SK_U32 TxWm;
  864. pPrt = &pAC->GIni.GP[Port];
  865. RxWm = SK_BMU_RX_WM;
  866. TxWm = SK_BMU_TX_WM;
  867. if (!pAC->GIni.GIPciSlot64 && !pAC->GIni.GIPciClock66) {
  868. /* for better performance */
  869. RxWm /= 2;
  870. TxWm /= 2;
  871. }
  872. /* Rx Queue: Release all local resets and set the watermark */
  873. SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_CLR_RESET);
  874. SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_F), RxWm);
  875. /*
  876. * Tx Queue: Release all local resets if the queue is used !
  877. * set watermark
  878. */
  879. if (pPrt->PXSQSize != 0) {
  880. SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_CLR_RESET);
  881. SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_F), TxWm);
  882. }
  883. if (pPrt->PXAQSize != 0) {
  884. SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_CLR_RESET);
  885. SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_F), TxWm);
  886. }
  887. /*
  888. * Do NOT enable the descriptor poll timers here, because
  889. * the descriptor addresses are not specified yet.
  890. */
  891. } /* SkGeInitBmu */
  892. /******************************************************************************
  893. *
  894. * TestStopBit() - Test the stop bit of the queue
  895. *
  896. * Description:
  897. * Stopping a queue is not as simple as it seems to be.
  898. * If descriptor polling is enabled, it may happen
  899. * that RX/TX stop is done and SV idle is NOT set.
  900. * In this case we have to issue another stop command.
  901. *
  902. * Returns:
  903. * The queues control status register
  904. */
  905. static SK_U32 TestStopBit(
  906. SK_AC *pAC, /* Adapter Context */
  907. SK_IOC IoC, /* IO Context */
  908. int QuIoOffs) /* Queue IO Address Offset */
  909. {
  910. SK_U32 QuCsr; /* CSR contents */
  911. SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr);
  912. if ((QuCsr & (CSR_STOP | CSR_SV_IDLE)) == 0) {
  913. /* Stop Descriptor overridden by start command */
  914. SK_OUT32(IoC, Q_ADDR(QuIoOffs, Q_CSR), CSR_STOP);
  915. SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr);
  916. }
  917. return(QuCsr);
  918. } /* TestStopBit */
  919. /******************************************************************************
  920. *
  921. * SkGeStopPort() - Stop the Rx/Tx activity of the port 'Port'.
  922. *
  923. * Description:
  924. * After calling this function the descriptor rings and Rx and Tx
  925. * queues of this port may be reconfigured.
  926. *
  927. * It is possible to stop the receive and transmit path separate or
  928. * both together.
  929. *
  930. * Dir = SK_STOP_TX Stops the transmit path only and resets the MAC.
  931. * The receive queue is still active and
  932. * the pending Rx frames may be still transferred
  933. * into the RxD.
  934. * SK_STOP_RX Stop the receive path. The tansmit path
  935. * has to be stopped once before.
  936. * SK_STOP_ALL SK_STOP_TX + SK_STOP_RX
  937. *
  938. * RstMode = SK_SOFT_RST Resets the MAC. The PHY is still alive.
  939. * SK_HARD_RST Resets the MAC and the PHY.
  940. *
  941. * Example:
  942. * 1) A Link Down event was signaled for a port. Therefore the activity
  943. * of this port should be stopped and a hardware reset should be issued
  944. * to enable the workaround of XMAC Errata #2. But the received frames
  945. * should not be discarded.
  946. * ...
  947. * SkGeStopPort(pAC, IoC, Port, SK_STOP_TX, SK_HARD_RST);
  948. * (transfer all pending Rx frames)
  949. * SkGeStopPort(pAC, IoC, Port, SK_STOP_RX, SK_HARD_RST);
  950. * ...
  951. *
  952. * 2) An event was issued which request the driver to switch
  953. * the 'virtual active' link to an other already active port
  954. * as soon as possible. The frames in the receive queue of this
  955. * port may be lost. But the PHY must not be reset during this
  956. * event.
  957. * ...
  958. * SkGeStopPort(pAC, IoC, Port, SK_STOP_ALL, SK_SOFT_RST);
  959. * ...
  960. *
  961. * Extended Description:
  962. * If SK_STOP_TX is set,
  963. * o disable the MAC's receive and transmitter to prevent
  964. * from sending incomplete frames
  965. * o stop the port's transmit queues before terminating the
  966. * BMUs to prevent from performing incomplete PCI cycles
  967. * on the PCI bus
  968. * - The network Rx and Tx activity and PCI Tx transfer is
  969. * disabled now.
  970. * o reset the MAC depending on the RstMode
  971. * o Stop Interval Timer and Limit Counter of Tx Arbiter,
  972. * also disable Force Sync bit and Enable Alloc bit.
  973. * o perform a local reset of the port's Tx path
  974. * - reset the PCI FIFO of the async Tx queue
  975. * - reset the PCI FIFO of the sync Tx queue
  976. * - reset the RAM Buffer async Tx queue
  977. * - reset the RAM Buffer sync Tx queue
  978. * - reset the MAC Tx FIFO
  979. * o switch Link and Tx LED off, stop the LED counters
  980. *
  981. * If SK_STOP_RX is set,
  982. * o stop the port's receive queue
  983. * - The path data transfer activity is fully stopped now.
  984. * o perform a local reset of the port's Rx path
  985. * - reset the PCI FIFO of the Rx queue
  986. * - reset the RAM Buffer receive queue
  987. * - reset the MAC Rx FIFO
  988. * o switch Rx LED off, stop the LED counter
  989. *
  990. * If all ports are stopped,
  991. * o reset the RAM Interface.
  992. *
  993. * Notes:
  994. * o This function may be called during the driver states RESET_PORT and
  995. * SWITCH_PORT.
  996. */
  997. void SkGeStopPort(
  998. SK_AC *pAC, /* adapter context */
  999. SK_IOC IoC, /* I/O context */
  1000. int Port, /* port to stop (MAC_1 + n) */
  1001. int Dir, /* Direction to Stop (SK_STOP_RX, SK_STOP_TX, SK_STOP_ALL) */
  1002. int RstMode)/* Reset Mode (SK_SOFT_RST, SK_HARD_RST) */
  1003. {
  1004. #ifndef SK_DIAG
  1005. SK_EVPARA Para;
  1006. #endif /* !SK_DIAG */
  1007. SK_GEPORT *pPrt;
  1008. SK_U32 DWord;
  1009. SK_U32 XsCsr;
  1010. SK_U32 XaCsr;
  1011. SK_U64 ToutStart;
  1012. int i;
  1013. int ToutCnt;
  1014. pPrt = &pAC->GIni.GP[Port];
  1015. if ((Dir & SK_STOP_TX) != 0) {
  1016. /* disable receiver and transmitter */
  1017. SkMacRxTxDisable(pAC, IoC, Port);
  1018. /* stop both transmit queues */
  1019. /*
  1020. * If the BMU is in the reset state CSR_STOP will terminate
  1021. * immediately.
  1022. */
  1023. SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_STOP);
  1024. SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_STOP);
  1025. ToutStart = SkOsGetTime(pAC);
  1026. ToutCnt = 0;
  1027. do {
  1028. /*
  1029. * Clear packet arbiter timeout to make sure
  1030. * this loop will terminate.
  1031. */
  1032. SK_OUT16(IoC, B3_PA_CTRL, (SK_U16)((Port == MAC_1) ?
  1033. PA_CLR_TO_TX1 : PA_CLR_TO_TX2));
  1034. /*
  1035. * If the transfer stucks at the MAC the STOP command will not
  1036. * terminate if we don't flush the XMAC's transmit FIFO !
  1037. */
  1038. SkMacFlushTxFifo(pAC, IoC, Port);
  1039. XsCsr = TestStopBit(pAC, IoC, pPrt->PXsQOff);
  1040. XaCsr = TestStopBit(pAC, IoC, pPrt->PXaQOff);
  1041. if (SkOsGetTime(pAC) - ToutStart > (SK_TICKS_PER_SEC / 18)) {
  1042. /*
  1043. * Timeout of 1/18 second reached.
  1044. * This needs to be checked at 1/18 sec only.
  1045. */
  1046. ToutCnt++;
  1047. if (ToutCnt > 1) {
  1048. /* Might be a problem when the driver event handler
  1049. * calls StopPort again. XXX.
  1050. */
  1051. /* Fatal Error, Loop aborted */
  1052. SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_HWI_E018,
  1053. SKERR_HWI_E018MSG);
  1054. #ifndef SK_DIAG
  1055. Para.Para64 = Port;
  1056. SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);
  1057. #endif /* !SK_DIAG */
  1058. return;
  1059. }
  1060. /*
  1061. * Cache incoherency workaround: Assume a start command
  1062. * has been lost while sending the frame.
  1063. */
  1064. ToutStart = SkOsGetTime(pAC);
  1065. if ((XsCsr & CSR_STOP) != 0) {
  1066. SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_START);
  1067. }
  1068. if ((XaCsr & CSR_STOP) != 0) {
  1069. SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_START);
  1070. }
  1071. }
  1072. /*
  1073. * Because of the ASIC problem report entry from 21.08.1998 it is
  1074. * required to wait until CSR_STOP is reset and CSR_SV_IDLE is set.
  1075. */
  1076. } while ((XsCsr & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE ||
  1077. (XaCsr & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE);
  1078. /* Reset the MAC depending on the RstMode */
  1079. if (RstMode == SK_SOFT_RST) {
  1080. SkMacSoftRst(pAC, IoC, Port);
  1081. }
  1082. else {
  1083. SkMacHardRst(pAC, IoC, Port);
  1084. }
  1085. /* Disable Force Sync bit and Enable Alloc bit */
  1086. SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
  1087. TXA_DIS_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);
  1088. /* Stop Interval Timer and Limit Counter of Tx Arbiter */
  1089. SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), 0L);
  1090. SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), 0L);
  1091. /* Perform a local reset of the port's Tx path */
  1092. /* Reset the PCI FIFO of the async Tx queue */
  1093. SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_SET_RESET);
  1094. /* Reset the PCI FIFO of the sync Tx queue */
  1095. SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_SET_RESET);
  1096. /* Reset the RAM Buffer async Tx queue */
  1097. SK_OUT8(IoC, RB_ADDR(pPrt->PXaQOff, RB_CTRL), RB_RST_SET);
  1098. /* Reset the RAM Buffer sync Tx queue */
  1099. SK_OUT8(IoC, RB_ADDR(pPrt->PXsQOff, RB_CTRL), RB_RST_SET);
  1100. /* Reset Tx MAC FIFO */
  1101. #ifdef GENESIS
  1102. if (pAC->GIni.GIGenesis) {
  1103. /* Note: MFF_RST_SET does NOT reset the XMAC ! */
  1104. SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_RST_SET);
  1105. /* switch Link and Tx LED off, stop the LED counters */
  1106. /* Link LED is switched off by the RLMT and the Diag itself */
  1107. SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_DIS);
  1108. }
  1109. #endif /* GENESIS */
  1110. #ifdef YUKON
  1111. if (pAC->GIni.GIYukon) {
  1112. /* Reset TX MAC FIFO */
  1113. SK_OUT8(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U8)GMF_RST_SET);
  1114. }
  1115. #endif /* YUKON */
  1116. }
  1117. if ((Dir & SK_STOP_RX) != 0) {
  1118. /*
  1119. * The RX Stop Command will not terminate if no buffers
  1120. * are queued in the RxD ring. But it will always reach
  1121. * the Idle state. Therefore we can use this feature to
  1122. * stop the transfer of received packets.
  1123. */
  1124. /* stop the port's receive queue */
  1125. SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_STOP);
  1126. i = 100;
  1127. do {
  1128. /*
  1129. * Clear packet arbiter timeout to make sure
  1130. * this loop will terminate
  1131. */
  1132. SK_OUT16(IoC, B3_PA_CTRL, (SK_U16)((Port == MAC_1) ?
  1133. PA_CLR_TO_RX1 : PA_CLR_TO_RX2));
  1134. DWord = TestStopBit(pAC, IoC, pPrt->PRxQOff);
  1135. /* timeout if i==0 (bug fix for #10748) */
  1136. if (--i == 0) {
  1137. SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_HWI_E024,
  1138. SKERR_HWI_E024MSG);
  1139. break;
  1140. }
  1141. /*
  1142. * because of the ASIC problem report entry from 21.08.98
  1143. * it is required to wait until CSR_STOP is reset and
  1144. * CSR_SV_IDLE is set.
  1145. */
  1146. } while ((DWord & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE);
  1147. /* The path data transfer activity is fully stopped now */
  1148. /* Perform a local reset of the port's Rx path */
  1149. /* Reset the PCI FIFO of the Rx queue */
  1150. SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_SET_RESET);
  1151. /* Reset the RAM Buffer receive queue */
  1152. SK_OUT8(IoC, RB_ADDR(pPrt->PRxQOff, RB_CTRL), RB_RST_SET);
  1153. /* Reset Rx MAC FIFO */
  1154. #ifdef GENESIS
  1155. if (pAC->GIni.GIGenesis) {
  1156. SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_RST_SET);
  1157. /* switch Rx LED off, stop the LED counter */
  1158. SkGeXmitLED(pAC, IoC, MR_ADDR(Port, RX_LED_INI), SK_LED_DIS);
  1159. }
  1160. #endif /* GENESIS */
  1161. #ifdef YUKON
  1162. if (pAC->GIni.GIYukon) {
  1163. /* Reset Rx MAC FIFO */
  1164. SK_OUT8(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), (SK_U8)GMF_RST_SET);
  1165. }
  1166. #endif /* YUKON */
  1167. }
  1168. } /* SkGeStopPort */
  1169. /******************************************************************************
  1170. *
  1171. * SkGeInit0() - Level 0 Initialization
  1172. *
  1173. * Description:
  1174. * - Initialize the BMU address offsets
  1175. *
  1176. * Returns:
  1177. * nothing
  1178. */
  1179. static void SkGeInit0(
  1180. SK_AC *pAC, /* adapter context */
  1181. SK_IOC IoC) /* IO context */
  1182. {
  1183. int i;
  1184. SK_GEPORT *pPrt;
  1185. for (i = 0; i < SK_MAX_MACS; i++) {
  1186. pPrt = &pAC->GIni.GP[i];
  1187. pPrt->PState = SK_PRT_RESET;
  1188. pPrt->PRxQOff = QOffTab[i].RxQOff;
  1189. pPrt->PXsQOff = QOffTab[i].XsQOff;
  1190. pPrt->PXaQOff = QOffTab[i].XaQOff;
  1191. pPrt->PCheckPar = SK_FALSE;
  1192. pPrt->PIsave = 0;
  1193. pPrt->PPrevShorts = 0;
  1194. pPrt->PLinkResCt = 0;
  1195. pPrt->PAutoNegTOCt = 0;
  1196. pPrt->PPrevRx = 0;
  1197. pPrt->PPrevFcs = 0;
  1198. pPrt->PRxLim = SK_DEF_RX_WA_LIM;
  1199. pPrt->PLinkMode = (SK_U8)SK_LMODE_AUTOFULL;
  1200. pPrt->PLinkSpeedCap = (SK_U8)SK_LSPEED_CAP_1000MBPS;
  1201. pPrt->PLinkSpeed = (SK_U8)SK_LSPEED_1000MBPS;
  1202. pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_UNKNOWN;
  1203. pPrt->PLinkModeConf = (SK_U8)SK_LMODE_AUTOSENSE;
  1204. pPrt->PFlowCtrlMode = (SK_U8)SK_FLOW_MODE_SYM_OR_REM;
  1205. pPrt->PLinkCap = (SK_U8)(SK_LMODE_CAP_HALF | SK_LMODE_CAP_FULL |
  1206. SK_LMODE_CAP_AUTOHALF | SK_LMODE_CAP_AUTOFULL);
  1207. pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_UNKNOWN;
  1208. pPrt->PFlowCtrlCap = (SK_U8)SK_FLOW_MODE_SYM_OR_REM;
  1209. pPrt->PFlowCtrlStatus = (SK_U8)SK_FLOW_STAT_NONE;
  1210. pPrt->PMSCap = 0;
  1211. pPrt->PMSMode = (SK_U8)SK_MS_MODE_AUTO;
  1212. pPrt->PMSStatus = (SK_U8)SK_MS_STAT_UNSET;
  1213. pPrt->PLipaAutoNeg = (SK_U8)SK_LIPA_UNKNOWN;
  1214. pPrt->PAutoNegFail = SK_FALSE;
  1215. pPrt->PHWLinkUp = SK_FALSE;
  1216. pPrt->PLinkBroken = SK_TRUE; /* See WA code */
  1217. pPrt->PPhyPowerState = PHY_PM_OPERATIONAL_MODE;
  1218. pPrt->PMacColThres = TX_COL_DEF;
  1219. pPrt->PMacJamLen = TX_JAM_LEN_DEF;
  1220. pPrt->PMacJamIpgVal = TX_JAM_IPG_DEF;
  1221. pPrt->PMacJamIpgData = TX_IPG_JAM_DEF;
  1222. pPrt->PMacIpgData = IPG_DATA_DEF;
  1223. pPrt->PMacLimit4 = SK_FALSE;
  1224. }
  1225. pAC->GIni.GIPortUsage = SK_RED_LINK;
  1226. pAC->GIni.GILedBlinkCtrl = (SK_U16)OemConfig.Value;
  1227. pAC->GIni.GIValIrqMask = IS_ALL_MSK;
  1228. } /* SkGeInit0*/
  1229. #ifdef SK_PCI_RESET
  1230. /******************************************************************************
  1231. *
  1232. * SkGePciReset() - Reset PCI interface
  1233. *
  1234. * Description:
  1235. * o Read PCI configuration.
  1236. * o Change power state to 3.
  1237. * o Change power state to 0.
  1238. * o Restore PCI configuration.
  1239. *
  1240. * Returns:
  1241. * 0: Success.
  1242. * 1: Power state could not be changed to 3.
  1243. */
  1244. static int SkGePciReset(
  1245. SK_AC *pAC, /* adapter context */
  1246. SK_IOC IoC) /* IO context */
  1247. {
  1248. int i;
  1249. SK_U16 PmCtlSts;
  1250. SK_U32 Bp1;
  1251. SK_U32 Bp2;
  1252. SK_U16 PciCmd;
  1253. SK_U8 Cls;
  1254. SK_U8 Lat;
  1255. SK_U8 ConfigSpace[PCI_CFG_SIZE];
  1256. /*
  1257. * Note: Switching to D3 state is like a software reset.
  1258. * Switching from D3 to D0 is a hardware reset.
  1259. * We have to save and restore the configuration space.
  1260. */
  1261. for (i = 0; i < PCI_CFG_SIZE; i++) {
  1262. SkPciReadCfgDWord(pAC, i*4, &ConfigSpace[i]);
  1263. }
  1264. /* We know the RAM Interface Arbiter is enabled. */
  1265. SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D3);
  1266. SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);
  1267. if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D3) {
  1268. return(1);
  1269. }
  1270. /* Return to D0 state. */
  1271. SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D0);
  1272. /* Check for D0 state. */
  1273. SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);
  1274. if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D0) {
  1275. return(1);
  1276. }
  1277. /* Check PCI Config Registers. */
  1278. SkPciReadCfgWord(pAC, PCI_COMMAND, &PciCmd);
  1279. SkPciReadCfgByte(pAC, PCI_CACHE_LSZ, &Cls);
  1280. SkPciReadCfgDWord(pAC, PCI_BASE_1ST, &Bp1);
  1281. SkPciReadCfgDWord(pAC, PCI_BASE_2ND, &Bp2);
  1282. SkPciReadCfgByte(pAC, PCI_LAT_TIM, &Lat);
  1283. if (PciCmd != 0 || Cls != (SK_U8)0 || Lat != (SK_U8)0 ||
  1284. (Bp1 & 0xfffffff0L) != 0 || Bp2 != 1) {
  1285. return(1);
  1286. }
  1287. /* Restore PCI Config Space. */
  1288. for (i = 0; i < PCI_CFG_SIZE; i++) {
  1289. SkPciWriteCfgDWord(pAC, i*4, ConfigSpace[i]);
  1290. }
  1291. return(0);
  1292. } /* SkGePciReset */
  1293. #endif /* SK_PCI_RESET */
  1294. /******************************************************************************
  1295. *
  1296. * SkGeInit1() - Level 1 Initialization
  1297. *
  1298. * Description:
  1299. * o Do a software reset.
  1300. * o Clear all reset bits.
  1301. * o Verify that the detected hardware is present.
  1302. * Return an error if not.
  1303. * o Get the hardware configuration
  1304. * + Read the number of MACs/Ports.
  1305. * + Read the RAM size.
  1306. * + Read the PCI Revision Id.
  1307. * + Find out the adapters host clock speed
  1308. * + Read and check the PHY type
  1309. *
  1310. * Returns:
  1311. * 0: success
  1312. * 5: Unexpected PHY type detected
  1313. * 6: HW self test failed
  1314. */
  1315. static int SkGeInit1(
  1316. SK_AC *pAC, /* adapter context */
  1317. SK_IOC IoC) /* IO context */
  1318. {
  1319. SK_U8 Byte;
  1320. SK_U16 Word;
  1321. SK_U16 CtrlStat;
  1322. SK_U32 DWord;
  1323. int RetVal;
  1324. int i;
  1325. RetVal = 0;
  1326. /* save CLK_RUN bits (YUKON-Lite) */
  1327. SK_IN16(IoC, B0_CTST, &CtrlStat);
  1328. #ifdef SK_PCI_RESET
  1329. (void)SkGePciReset(pAC, IoC);
  1330. #endif /* SK_PCI_RESET */
  1331. /* do the SW-reset */
  1332. SK_OUT8(IoC, B0_CTST, CS_RST_SET);
  1333. /* release the SW-reset */
  1334. SK_OUT8(IoC, B0_CTST, CS_RST_CLR);
  1335. /* reset all error bits in the PCI STATUS register */
  1336. /*
  1337. * Note: PCI Cfg cycles cannot be used, because they are not
  1338. * available on some platforms after 'boot time'.
  1339. */
  1340. SK_IN16(IoC, PCI_C(PCI_STATUS), &Word);
  1341. SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
  1342. SK_OUT16(IoC, PCI_C(PCI_STATUS), (SK_U16)(Word | PCI_ERRBITS));
  1343. SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
  1344. /* release Master Reset */
  1345. SK_OUT8(IoC, B0_CTST, CS_MRST_CLR);
  1346. #ifdef CLK_RUN
  1347. CtrlStat |= CS_CLK_RUN_ENA;
  1348. #endif /* CLK_RUN */
  1349. /* restore CLK_RUN bits */
  1350. SK_OUT16(IoC, B0_CTST, (SK_U16)(CtrlStat &
  1351. (CS_CLK_RUN_HOT | CS_CLK_RUN_RST | CS_CLK_RUN_ENA)));
  1352. /* read Chip Identification Number */
  1353. SK_IN8(IoC, B2_CHIP_ID, &Byte);
  1354. pAC->GIni.GIChipId = Byte;
  1355. /* read number of MACs */
  1356. SK_IN8(IoC, B2_MAC_CFG, &Byte);
  1357. pAC->GIni.GIMacsFound = (Byte & CFG_SNG_MAC) ? 1 : 2;
  1358. /* get Chip Revision Number */
  1359. pAC->GIni.GIChipRev = (SK_U8)((Byte & CFG_CHIP_R_MSK) >> 4);
  1360. /* get diff. PCI parameters */
  1361. SK_IN16(IoC, B0_CTST, &CtrlStat);
  1362. /* read the adapters RAM size */
  1363. SK_IN8(IoC, B2_E_0, &Byte);
  1364. pAC->GIni.GIGenesis = SK_FALSE;
  1365. pAC->GIni.GIYukon = SK_FALSE;
  1366. pAC->GIni.GIYukonLite = SK_FALSE;
  1367. #ifdef GENESIS
  1368. if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
  1369. pAC->GIni.GIGenesis = SK_TRUE;
  1370. if (Byte == (SK_U8)3) {
  1371. /* special case: 4 x 64k x 36, offset = 0x80000 */
  1372. pAC->GIni.GIRamSize = 1024;
  1373. pAC->GIni.GIRamOffs = (SK_U32)512 * 1024;
  1374. }
  1375. else {
  1376. pAC->GIni.GIRamSize = (int)Byte * 512;
  1377. pAC->GIni.GIRamOffs = 0;
  1378. }
  1379. /* all GE adapters work with 53.125 MHz host clock */
  1380. pAC->GIni.GIHstClkFact = SK_FACT_53;
  1381. /* set Descr. Poll Timer Init Value to 250 ms */
  1382. pAC->GIni.GIPollTimerVal =
  1383. SK_DPOLL_DEF * (SK_U32)pAC->GIni.GIHstClkFact / 100;
  1384. }
  1385. #endif /* GENESIS */
  1386. #ifdef YUKON
  1387. if (pAC->GIni.GIChipId != CHIP_ID_GENESIS) {
  1388. pAC->GIni.GIYukon = SK_TRUE;
  1389. pAC->GIni.GIRamSize = (Byte == (SK_U8)0) ? 128 : (int)Byte * 4;
  1390. pAC->GIni.GIRamOffs = 0;
  1391. /* WA for chip Rev. A */
  1392. pAC->GIni.GIWolOffs = (pAC->GIni.GIChipId == CHIP_ID_YUKON &&
  1393. pAC->GIni.GIChipRev == 0) ? WOL_REG_OFFS : 0;
  1394. /* get PM Capabilities of PCI config space */
  1395. SK_IN16(IoC, PCI_C(PCI_PM_CAP_REG), &Word);
  1396. /* check if VAUX is available */
  1397. if (((CtrlStat & CS_VAUX_AVAIL) != 0) &&
  1398. /* check also if PME from D3cold is set */
  1399. ((Word & PCI_PME_D3C_SUP) != 0)) {
  1400. /* set entry in GE init struct */
  1401. pAC->GIni.GIVauxAvail = SK_TRUE;
  1402. }
  1403. if (pAC->GIni.GIChipId == CHIP_ID_YUKON_LITE) {
  1404. /* this is Rev. A1 */
  1405. pAC->GIni.GIYukonLite = SK_TRUE;
  1406. }
  1407. else {
  1408. /* save Flash-Address Register */
  1409. SK_IN32(IoC, B2_FAR, &DWord);
  1410. /* test Flash-Address Register */
  1411. SK_OUT8(IoC, B2_FAR + 3, 0xff);
  1412. SK_IN8(IoC, B2_FAR + 3, &Byte);
  1413. if (Byte != 0) {
  1414. /* this is Rev. A0 */
  1415. pAC->GIni.GIYukonLite = SK_TRUE;
  1416. /* restore Flash-Address Register */
  1417. SK_OUT32(IoC, B2_FAR, DWord);
  1418. }
  1419. }
  1420. /* switch power to VCC (WA for VAUX problem) */
  1421. SK_OUT8(IoC, B0_POWER_CTRL, (SK_U8)(PC_VAUX_ENA | PC_VCC_ENA |
  1422. PC_VAUX_OFF | PC_VCC_ON));
  1423. /* read the Interrupt source */
  1424. SK_IN32(IoC, B0_ISRC, &DWord);
  1425. if ((DWord & IS_HW_ERR) != 0) {
  1426. /* read the HW Error Interrupt source */
  1427. SK_IN32(IoC, B0_HWE_ISRC, &DWord);
  1428. if ((DWord & IS_IRQ_SENSOR) != 0) {
  1429. /* disable HW Error IRQ */
  1430. pAC->GIni.GIValIrqMask &= ~IS_HW_ERR;
  1431. }
  1432. }
  1433. for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
  1434. /* set GMAC Link Control reset */
  1435. SK_OUT16(IoC, MR_ADDR(i, GMAC_LINK_CTRL), GMLC_RST_SET);
  1436. /* clear GMAC Link Control reset */
  1437. SK_OUT16(IoC, MR_ADDR(i, GMAC_LINK_CTRL), GMLC_RST_CLR);
  1438. }
  1439. /* all YU chips work with 78.125 MHz host clock */
  1440. pAC->GIni.GIHstClkFact = SK_FACT_78;
  1441. pAC->GIni.GIPollTimerVal = SK_DPOLL_MAX; /* 215 ms */
  1442. }
  1443. #endif /* YUKON */
  1444. /* check if 64-bit PCI Slot is present */
  1445. pAC->GIni.GIPciSlot64 = (SK_BOOL)((CtrlStat & CS_BUS_SLOT_SZ) != 0);
  1446. /* check if 66 MHz PCI Clock is active */
  1447. pAC->GIni.GIPciClock66 = (SK_BOOL)((CtrlStat & CS_BUS_CLOCK) != 0);
  1448. /* read PCI HW Revision Id. */
  1449. SK_IN8(IoC, PCI_C(PCI_REV_ID), &Byte);
  1450. pAC->GIni.GIPciHwRev = Byte;
  1451. /* read the PMD type */
  1452. SK_IN8(IoC, B2_PMD_TYP, &Byte);
  1453. pAC->GIni.GICopperType = (SK_U8)(Byte == 'T');
  1454. /* read the PHY type */
  1455. SK_IN8(IoC, B2_E_1, &Byte);
  1456. Byte &= 0x0f; /* the PHY type is stored in the lower nibble */
  1457. for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
  1458. #ifdef GENESIS
  1459. if (pAC->GIni.GIGenesis) {
  1460. switch (Byte) {
  1461. case SK_PHY_XMAC:
  1462. pAC->GIni.GP[i].PhyAddr = PHY_ADDR_XMAC;
  1463. break;
  1464. case SK_PHY_BCOM:
  1465. pAC->GIni.GP[i].PhyAddr = PHY_ADDR_BCOM;
  1466. pAC->GIni.GP[i].PMSCap = (SK_U8)(SK_MS_CAP_AUTO |
  1467. SK_MS_CAP_MASTER | SK_MS_CAP_SLAVE);
  1468. break;
  1469. #ifdef OTHER_PHY
  1470. case SK_PHY_LONE:
  1471. pAC->GIni.GP[i].PhyAddr = PHY_ADDR_LONE;
  1472. break;
  1473. case SK_PHY_NAT:
  1474. pAC->GIni.GP[i].PhyAddr = PHY_ADDR_NAT;
  1475. break;
  1476. #endif /* OTHER_PHY */
  1477. default:
  1478. /* ERROR: unexpected PHY type detected */
  1479. RetVal = 5;
  1480. break;
  1481. }
  1482. }
  1483. #endif /* GENESIS */
  1484. #ifdef YUKON
  1485. if (pAC->GIni.GIYukon) {
  1486. if (Byte < (SK_U8)SK_PHY_MARV_COPPER) {
  1487. /* if this field is not initialized */
  1488. Byte = (SK_U8)SK_PHY_MARV_COPPER;
  1489. pAC->GIni.GICopperType = SK_TRUE;
  1490. }
  1491. pAC->GIni.GP[i].PhyAddr = PHY_ADDR_MARV;
  1492. if (pAC->GIni.GICopperType) {
  1493. pAC->GIni.GP[i].PLinkSpeedCap = (SK_U8)(SK_LSPEED_CAP_AUTO |
  1494. SK_LSPEED_CAP_10MBPS | SK_LSPEED_CAP_100MBPS |
  1495. SK_LSPEED_CAP_1000MBPS);
  1496. pAC->GIni.GP[i].PLinkSpeed = (SK_U8)SK_LSPEED_AUTO;
  1497. pAC->GIni.GP[i].PMSCap = (SK_U8)(SK_MS_CAP_AUTO |
  1498. SK_MS_CAP_MASTER | SK_MS_CAP_SLAVE);
  1499. }
  1500. else {
  1501. Byte = (SK_U8)SK_PHY_MARV_FIBER;
  1502. }
  1503. }
  1504. #endif /* YUKON */
  1505. pAC->GIni.GP[i].PhyType = (int)Byte;
  1506. SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
  1507. ("PHY type: %d PHY addr: %04x\n", Byte,
  1508. pAC->GIni.GP[i].PhyAddr));
  1509. }
  1510. /* get MAC Type & set function pointers dependent on */
  1511. #ifdef GENESIS
  1512. if (pAC->GIni.GIGenesis) {
  1513. pAC->GIni.GIMacType = SK_MAC_XMAC;
  1514. pAC->GIni.GIFunc.pFnMacUpdateStats = SkXmUpdateStats;
  1515. pAC->GIni.GIFunc.pFnMacStatistic = SkXmMacStatistic;
  1516. pAC->GIni.GIFunc.pFnMacResetCounter = SkXmResetCounter;
  1517. pAC->GIni.GIFunc.pFnMacOverflow = SkXmOverflowStatus;
  1518. }
  1519. #endif /* GENESIS */
  1520. #ifdef YUKON
  1521. if (pAC->GIni.GIYukon) {
  1522. pAC->GIni.GIMacType = SK_MAC_GMAC;
  1523. pAC->GIni.GIFunc.pFnMacUpdateStats = SkGmUpdateStats;
  1524. pAC->GIni.GIFunc.pFnMacStatistic = SkGmMacStatistic;
  1525. pAC->GIni.GIFunc.pFnMacResetCounter = SkGmResetCounter;
  1526. pAC->GIni.GIFunc.pFnMacOverflow = SkGmOverflowStatus;
  1527. #ifdef SPECIAL_HANDLING
  1528. if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
  1529. /* check HW self test result */
  1530. SK_IN8(IoC, B2_E_3, &Byte);
  1531. if (Byte & B2_E3_RES_MASK) {
  1532. RetVal = 6;
  1533. }
  1534. }
  1535. #endif
  1536. }
  1537. #endif /* YUKON */
  1538. return(RetVal);
  1539. } /* SkGeInit1 */
  1540. /******************************************************************************
  1541. *
  1542. * SkGeInit2() - Level 2 Initialization
  1543. *
  1544. * Description:
  1545. * - start the Blink Source Counter
  1546. * - start the Descriptor Poll Timer
  1547. * - configure the MAC-Arbiter
  1548. * - configure the Packet-Arbiter
  1549. * - enable the Tx Arbiters
  1550. * - enable the RAM Interface Arbiter
  1551. *
  1552. * Returns:
  1553. * nothing
  1554. */
  1555. static void SkGeInit2(
  1556. SK_AC *pAC, /* adapter context */
  1557. SK_IOC IoC) /* IO context */
  1558. {
  1559. #ifdef GENESIS
  1560. SK_U32 DWord;
  1561. #endif /* GENESIS */
  1562. int i;
  1563. /* start the Descriptor Poll Timer */
  1564. if (pAC->GIni.GIPollTimerVal != 0) {
  1565. if (pAC->GIni.GIPollTimerVal > SK_DPOLL_MAX) {
  1566. pAC->GIni.GIPollTimerVal = SK_DPOLL_MAX;
  1567. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E017, SKERR_HWI_E017MSG);
  1568. }
  1569. SK_OUT32(IoC, B28_DPT_INI, pAC->GIni.GIPollTimerVal);
  1570. SK_OUT8(IoC, B28_DPT_CTRL, DPT_START);
  1571. }
  1572. #ifdef GENESIS
  1573. if (pAC->GIni.GIGenesis) {
  1574. /* start the Blink Source Counter */
  1575. DWord = SK_BLK_DUR * (SK_U32)pAC->GIni.GIHstClkFact / 100;
  1576. SK_OUT32(IoC, B2_BSC_INI, DWord);
  1577. SK_OUT8(IoC, B2_BSC_CTRL, BSC_START);
  1578. /*
  1579. * Configure the MAC Arbiter and the Packet Arbiter.
  1580. * They will be started once and never be stopped.
  1581. */
  1582. SkGeInitMacArb(pAC, IoC);
  1583. SkGeInitPktArb(pAC, IoC);
  1584. }
  1585. #endif /* GENESIS */
  1586. #ifdef YUKON
  1587. if (pAC->GIni.GIYukon) {
  1588. /* start Time Stamp Timer */
  1589. SK_OUT8(IoC, GMAC_TI_ST_CTRL, (SK_U8)GMT_ST_START);
  1590. }
  1591. #endif /* YUKON */
  1592. /* enable the Tx Arbiters */
  1593. for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
  1594. SK_OUT8(IoC, MR_ADDR(i, TXA_CTRL), TXA_ENA_ARB);
  1595. }
  1596. /* enable the RAM Interface Arbiter */
  1597. SkGeInitRamIface(pAC, IoC);
  1598. } /* SkGeInit2 */
  1599. /******************************************************************************
  1600. *
  1601. * SkGeInit() - Initialize the GE Adapter with the specified level.
  1602. *
  1603. * Description:
  1604. * Level 0: Initialize the Module structures.
  1605. * Level 1: Generic Hardware Initialization. The IOP/MemBase pointer has
  1606. * to be set before calling this level.
  1607. *
  1608. * o Do a software reset.
  1609. * o Clear all reset bits.
  1610. * o Verify that the detected hardware is present.
  1611. * Return an error if not.
  1612. * o Get the hardware configuration
  1613. * + Set GIMacsFound with the number of MACs.
  1614. * + Store the RAM size in GIRamSize.
  1615. * + Save the PCI Revision ID in GIPciHwRev.
  1616. * o return an error
  1617. * if Number of MACs > SK_MAX_MACS
  1618. *
  1619. * After returning from Level 0 the adapter
  1620. * may be accessed with IO operations.
  1621. *
  1622. * Level 2: start the Blink Source Counter
  1623. *
  1624. * Returns:
  1625. * 0: success
  1626. * 1: Number of MACs exceeds SK_MAX_MACS (after level 1)
  1627. * 2: Adapter not present or not accessible
  1628. * 3: Illegal initialization level
  1629. * 4: Initialization Level 1 Call missing
  1630. * 5: Unexpected PHY type detected
  1631. * 6: HW self test failed
  1632. */
  1633. int SkGeInit(
  1634. SK_AC *pAC, /* adapter context */
  1635. SK_IOC IoC, /* IO context */
  1636. int Level) /* initialization level */
  1637. {
  1638. int RetVal; /* return value */
  1639. SK_U32 DWord;
  1640. RetVal = 0;
  1641. SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
  1642. ("SkGeInit(Level %d)\n", Level));
  1643. switch (Level) {
  1644. case SK_INIT_DATA:
  1645. /* Initialization Level 0 */
  1646. SkGeInit0(pAC, IoC);
  1647. pAC->GIni.GILevel = SK_INIT_DATA;
  1648. break;
  1649. case SK_INIT_IO:
  1650. /* Initialization Level 1 */
  1651. RetVal = SkGeInit1(pAC, IoC);
  1652. if (RetVal != 0) {
  1653. break;
  1654. }
  1655. /* check if the adapter seems to be accessible */
  1656. SK_OUT32(IoC, B2_IRQM_INI, SK_TEST_VAL);
  1657. SK_IN32(IoC, B2_IRQM_INI, &DWord);
  1658. SK_OUT32(IoC, B2_IRQM_INI, 0L);
  1659. if (DWord != SK_TEST_VAL) {
  1660. RetVal = 2;
  1661. break;
  1662. }
  1663. /* check if the number of GIMacsFound matches SK_MAX_MACS */
  1664. if (pAC->GIni.GIMacsFound > SK_MAX_MACS) {
  1665. RetVal = 1;
  1666. break;
  1667. }
  1668. /* Level 1 successfully passed */
  1669. pAC->GIni.GILevel = SK_INIT_IO;
  1670. break;
  1671. case SK_INIT_RUN:
  1672. /* Initialization Level 2 */
  1673. if (pAC->GIni.GILevel != SK_INIT_IO) {
  1674. #ifndef SK_DIAG
  1675. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E002, SKERR_HWI_E002MSG);
  1676. #endif /* !SK_DIAG */
  1677. RetVal = 4;
  1678. break;
  1679. }
  1680. SkGeInit2(pAC, IoC);
  1681. /* Level 2 successfully passed */
  1682. pAC->GIni.GILevel = SK_INIT_RUN;
  1683. break;
  1684. default:
  1685. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E003, SKERR_HWI_E003MSG);
  1686. RetVal = 3;
  1687. break;
  1688. }
  1689. return(RetVal);
  1690. } /* SkGeInit */
  1691. /******************************************************************************
  1692. *
  1693. * SkGeDeInit() - Deinitialize the adapter
  1694. *
  1695. * Description:
  1696. * All ports of the adapter will be stopped if not already done.
  1697. * Do a software reset and switch off all LEDs.
  1698. *
  1699. * Returns:
  1700. * nothing
  1701. */
  1702. void SkGeDeInit(
  1703. SK_AC *pAC, /* adapter context */
  1704. SK_IOC IoC) /* IO context */
  1705. {
  1706. int i;
  1707. SK_U16 Word;
  1708. #ifdef SK_PHY_LP_MODE
  1709. SK_U8 Byte;
  1710. SK_U16 PmCtlSts;
  1711. #endif /* SK_PHY_LP_MODE */
  1712. #if (!defined(SK_SLIM) && !defined(VCPU))
  1713. /* ensure I2C is ready */
  1714. SkI2cWaitIrq(pAC, IoC);
  1715. #endif
  1716. /* stop all current transfer activity */
  1717. for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
  1718. if (pAC->GIni.GP[i].PState != SK_PRT_STOP &&
  1719. pAC->GIni.GP[i].PState != SK_PRT_RESET) {
  1720. SkGeStopPort(pAC, IoC, i, SK_STOP_ALL, SK_HARD_RST);
  1721. }
  1722. }
  1723. #ifdef SK_PHY_LP_MODE
  1724. /*
  1725. * for power saving purposes within mobile environments
  1726. * we set the PHY to coma mode and switch to D3 power state.
  1727. */
  1728. if (pAC->GIni.GIYukonLite &&
  1729. pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
  1730. /* for all ports switch PHY to coma mode */
  1731. for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
  1732. SkGmEnterLowPowerMode(pAC, IoC, i, PHY_PM_DEEP_SLEEP);
  1733. }
  1734. if (pAC->GIni.GIVauxAvail) {
  1735. /* switch power to VAUX */
  1736. Byte = PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_ON | PC_VCC_OFF;
  1737. SK_OUT8(IoC, B0_POWER_CTRL, Byte);
  1738. }
  1739. /* switch to D3 state */
  1740. SK_IN16(IoC, PCI_C(PCI_PM_CTL_STS), &PmCtlSts);
  1741. PmCtlSts |= PCI_PM_STATE_D3;
  1742. SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
  1743. SK_OUT16(IoC, PCI_C(PCI_PM_CTL_STS), PmCtlSts);
  1744. }
  1745. #endif /* SK_PHY_LP_MODE */
  1746. /* Reset all bits in the PCI STATUS register */
  1747. /*
  1748. * Note: PCI Cfg cycles cannot be used, because they are not
  1749. * available on some platforms after 'boot time'.
  1750. */
  1751. SK_IN16(IoC, PCI_C(PCI_STATUS), &Word);
  1752. SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
  1753. SK_OUT16(IoC, PCI_C(PCI_STATUS), (SK_U16)(Word | PCI_ERRBITS));
  1754. SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
  1755. /* do the reset, all LEDs are switched off now */
  1756. SK_OUT8(IoC, B0_CTST, CS_RST_SET);
  1757. pAC->GIni.GILevel = SK_INIT_DATA;
  1758. } /* SkGeDeInit */
  1759. /******************************************************************************
  1760. *
  1761. * SkGeInitPort() Initialize the specified port.
  1762. *
  1763. * Description:
  1764. * PRxQSize, PXSQSize, and PXAQSize has to be
  1765. * configured for the specified port before calling this function.
  1766. * The descriptor rings has to be initialized too.
  1767. *
  1768. * o (Re)configure queues of the specified port.
  1769. * o configure the MAC of the specified port.
  1770. * o put ASIC and MAC(s) in operational mode.
  1771. * o initialize Rx/Tx and Sync LED
  1772. * o initialize RAM Buffers and MAC FIFOs
  1773. *
  1774. * The port is ready to connect when returning.
  1775. *
  1776. * Note:
  1777. * The MAC's Rx and Tx state machine is still disabled when returning.
  1778. *
  1779. * Returns:
  1780. * 0: success
  1781. * 1: Queue size initialization error. The configured values
  1782. * for PRxQSize, PXSQSize, or PXAQSize are invalid for one
  1783. * or more queues. The specified port was NOT initialized.
  1784. * An error log entry was generated.
  1785. * 2: The port has to be stopped before it can be initialized again.
  1786. */
  1787. int SkGeInitPort(
  1788. SK_AC *pAC, /* adapter context */
  1789. SK_IOC IoC, /* IO context */
  1790. int Port) /* Port to configure */
  1791. {
  1792. SK_GEPORT *pPrt;
  1793. pPrt = &pAC->GIni.GP[Port];
  1794. if (SkGeCheckQSize(pAC, Port) != 0) {
  1795. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E004, SKERR_HWI_E004MSG);
  1796. return(1);
  1797. }
  1798. if (pPrt->PState == SK_PRT_INIT || pPrt->PState == SK_PRT_RUN) {
  1799. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E005, SKERR_HWI_E005MSG);
  1800. return(2);
  1801. }
  1802. /* configuration ok, initialize the Port now */
  1803. #ifdef GENESIS
  1804. if (pAC->GIni.GIGenesis) {
  1805. /* initialize Rx, Tx and Link LED */
  1806. /*
  1807. * If 1000BT Phy needs LED initialization than swap
  1808. * LED and XMAC initialization order
  1809. */
  1810. SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_ENA);
  1811. SkGeXmitLED(pAC, IoC, MR_ADDR(Port, RX_LED_INI), SK_LED_ENA);
  1812. /* The Link LED is initialized by RLMT or Diagnostics itself */
  1813. SkXmInitMac(pAC, IoC, Port);
  1814. }
  1815. #endif /* GENESIS */
  1816. #ifdef YUKON
  1817. if (pAC->GIni.GIYukon) {
  1818. SkGmInitMac(pAC, IoC, Port);
  1819. }
  1820. #endif /* YUKON */
  1821. /* do NOT initialize the Link Sync Counter */
  1822. SkGeInitMacFifo(pAC, IoC, Port);
  1823. SkGeInitRamBufs(pAC, IoC, Port);
  1824. if (pPrt->PXSQSize != 0) {
  1825. /* enable Force Sync bit if synchronous queue available */
  1826. SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_ENA_FSYNC);
  1827. }
  1828. SkGeInitBmu(pAC, IoC, Port);
  1829. /* mark port as initialized */
  1830. pPrt->PState = SK_PRT_INIT;
  1831. return(0);
  1832. } /* SkGeInitPort */